From 4292bca198b60f9ee478ac59ae2afc670bf25677 Mon Sep 17 00:00:00 2001 From: Priamo Germosen <6233424+pgermosen@users.noreply.github.com> Date: Wed, 18 Nov 2026 08:27:23 -0400 Subject: [PATCH] docs: check the REST service matrix rows against their controllers (#8861) Every Service Matrix row now has its operation count checked, or a stated reason it cannot be. The REST rows map their JAX-RS controllers in action_count_sources, with: - rename_actions for a method not named after its AWS action, and a list for a method that answers several actions by query parameter (CreateRestApi and ImportRestApi on POST /restapis?mode=import) - route_prefix and skip_route_prefix on a REST source, so API Gateway's v1 and v2 rows split the one controller that serves both - a tag_handler source mode: a TagHandler class is what gives a service the three tagging actions the shared /tags controllers serve - exclude_actions for operations that always fail (InvokeModelWithResponseStream answers 501, ExecuteSql BadRequestException, Amazon MQ's user calls BadRequestException for RabbitMQ brokers) A new coverage gate fails when a row is neither checked nor listed under hand_counted with its reason, when two rows share a link target, or when a row has no numeric count. It replaces the required-sources list. S3 is the one hand-counted row: its handlers pick most operations by query string. Most REST rows were undercounted, EKS by the most (7, served 35). IoT Data gets its own anchor, as it shared iot.md with IoT Core and its count was never read. The AppSync, CloudFront, EKS, Lambda and Pipes pages now list the operations their controllers serve: AppSync's listed names that do not exist, and CloudFront's called stored-only operations unsupported. Closes #4999 --- docs/services/appsync.md | 28 +-- docs/services/cloudfront.md | 69 +++++- docs/services/eks.md | 1 + docs/services/index.md | 49 ++-- docs/services/iot.md | 19 ++ docs/services/lambda.md | 6 + docs/services/pipes.md | 3 + tools/docs/check_service_matrix.py | 188 +++++++++++----- tools/docs/regen_action_docs.py | 99 ++++++-- tools/docs/service_matrix.yaml | 288 +++++++++++++++++++++++- tools/docs/test_check_service_matrix.py | 159 +++++++++++-- tools/docs/test_regen_action_docs.py | 64 ++++++ 12 files changed, 829 insertions(+), 144 deletions(-) diff --git a/docs/services/appsync.md b/docs/services/appsync.md index 50326628bc..b200519b50 100644 --- a/docs/services/appsync.md +++ b/docs/services/appsync.md @@ -59,8 +59,7 @@ targets and HTTP URLs that use a literal private or loopback address. | `GetResolver` | Get a resolver by type and field | | `UpdateResolver` | Update a resolver | | `DeleteResolver` | Delete a resolver | -| `ListResolvers` | List all resolvers for an API | -| `ListResolversByType` | List resolvers for a specific type | +| `ListResolvers` | List the resolvers of a type | | `ListResolversByFunction` | List resolvers attached to a specific function | ### Functions @@ -88,7 +87,6 @@ targets and HTTP URLs that use a literal private or loopback address. | Operation | Description | |---|---| | `CreateApiKey` | Create an API key | -| `GetApiKey` | Get an API key by ID | | `UpdateApiKey` | Update an API key | | `DeleteApiKey` | Delete an API key | | `ListApiKeys` | List all API keys for an API | @@ -107,8 +105,8 @@ As on AWS, `ApiKey.id` is the key value itself (`da2-` followed by 26 lowercase | Operation | Description | |---|---| -| `GetEnvironmentVariables` | Get environment variables for an API | -| `PutEnvironmentVariables` | Set environment variables for an API | +| `GetGraphqlApiEnvironmentVariables` | Get environment variables for an API | +| `PutGraphqlApiEnvironmentVariables` | Set environment variables for an API | ### Domain Names @@ -120,9 +118,8 @@ As on AWS, `ApiKey.id` is the key value itself (`da2-` followed by 26 lowercase | `ListDomainNames` | List all domain names | | `DeleteDomainName` | Delete a custom domain name | | `AssociateApi` | Associate a domain name with a GraphQL API | -| `GetAssociatedApi` | Get the API associated with a domain name | +| `GetApiAssociation` | Get the API associated with a domain name | | `DisassociateApi` | Disassociate a domain name from a GraphQL API | -| `ListApiAssociations` | List all associations for an API | ### Channel Namespaces @@ -138,16 +135,15 @@ As on AWS, `ApiKey.id` is the key value itself (`da2-` followed by 26 lowercase | Operation | Description | |---|---| -| `CreateApiAssociation` | Associate a source API with a merged API | -| `GetApiAssociation` | Get a merged API association | -| `DeleteApiAssociation` | Delete a merged API association | -| `ListApiAssociations` | List all merged API associations | +| `AssociateSourceGraphqlApi` | Associate a source API with a merged API, from the merged API's side | +| `AssociateMergedGraphqlApi` | Associate a source API with a merged API, from the source API's side | +| `GetSourceApiAssociation` | Get a source API association | +| `UpdateSourceApiAssociation` | Update a source API association's description or merge type | +| `ListSourceApiAssociations` | List the source API associations of an API | +| `DisassociateSourceGraphqlApi` | Remove a source API association, from the merged API's side | +| `DisassociateMergedGraphqlApi` | Remove a source API association, from the source API's side | -### Enhanced Metrics - -| Operation | Description | -|---|---| -| `GetEnhancedMetricsConfig` | Get the enhanced metrics configuration | +An API's `enhancedMetricsConfig` is kept with it by `CreateGraphqlApi` and `UpdateGraphqlApi`. ## Schema Registry diff --git a/docs/services/cloudfront.md b/docs/services/cloudfront.md index 630088786f..890c3833c1 100644 --- a/docs/services/cloudfront.md +++ b/docs/services/cloudfront.md @@ -147,6 +147,64 @@ the path: | `DeleteKeyGroup` | DELETE | `/2020-05-31/key-group/{Id}` | | `ListKeyGroups` | GET | `/2020-05-31/key-group` | +### Stored configurations + +These operations store what they are given and return it, so code that manages these resources works, but Floci does not act on them: a continuous deployment policy never diverts a primary distribution's requests to its staging distribution, no real-time log or monitoring-subscription metric is delivered, no field is encrypted, and a streaming distribution serves no RTMP. A staging distribution made by `CopyDistribution` still answers on its own domain name, as any enabled distribution does. + +#### Staging distributions and continuous deployment + +| Operation | Method | Path | +|---|---|---| +| `CopyDistribution` | POST | `/2020-05-31/distribution/{PrimaryDistributionId}/copy` | +| `CreateContinuousDeploymentPolicy` | POST | `/2020-05-31/continuous-deployment-policy` | +| `GetContinuousDeploymentPolicy` | GET | `/2020-05-31/continuous-deployment-policy/{Id}` | +| `UpdateContinuousDeploymentPolicy` | PUT | `/2020-05-31/continuous-deployment-policy/{Id}` | +| `DeleteContinuousDeploymentPolicy` | DELETE | `/2020-05-31/continuous-deployment-policy/{Id}` | +| `ListContinuousDeploymentPolicies` | GET | `/2020-05-31/continuous-deployment-policy` | + +#### Real-time log configs + +| Operation | Method | Path | +|---|---|---| +| `CreateRealtimeLogConfig` | POST | `/2020-05-31/realtime-log-config` | +| `GetRealtimeLogConfig` | POST | `/2020-05-31/get-realtime-log-config` | +| `UpdateRealtimeLogConfig` | PUT | `/2020-05-31/realtime-log-config` | +| `DeleteRealtimeLogConfig` | POST | `/2020-05-31/delete-realtime-log-config` | +| `ListRealtimeLogConfigs` | GET | `/2020-05-31/realtime-log-config` | + +#### Field-level encryption + +| Operation | Method | Path | +|---|---|---| +| `CreateFieldLevelEncryptionConfig` | POST | `/2020-05-31/field-level-encryption` | +| `GetFieldLevelEncryptionConfig` | GET | `/2020-05-31/field-level-encryption/{Id}/config` | +| `UpdateFieldLevelEncryptionConfig` | PUT | `/2020-05-31/field-level-encryption/{Id}/config` | +| `DeleteFieldLevelEncryptionConfig` | DELETE | `/2020-05-31/field-level-encryption/{Id}` | +| `ListFieldLevelEncryptionConfigs` | GET | `/2020-05-31/field-level-encryption` | +| `CreateFieldLevelEncryptionProfile` | POST | `/2020-05-31/field-level-encryption-profile` | +| `GetFieldLevelEncryptionProfile` | GET | `/2020-05-31/field-level-encryption-profile/{Id}` | +| `UpdateFieldLevelEncryptionProfile` | PUT | `/2020-05-31/field-level-encryption-profile/{Id}/config` | +| `DeleteFieldLevelEncryptionProfile` | DELETE | `/2020-05-31/field-level-encryption-profile/{Id}` | +| `ListFieldLevelEncryptionProfiles` | GET | `/2020-05-31/field-level-encryption-profile` | + +#### Monitoring subscriptions + +| Operation | Method | Path | +|---|---|---| +| `CreateMonitoringSubscription` | POST | `/2020-05-31/distributions/{DistributionId}/monitoring-subscription` | +| `GetMonitoringSubscription` | GET | `/2020-05-31/distributions/{DistributionId}/monitoring-subscription` | +| `DeleteMonitoringSubscription` | DELETE | `/2020-05-31/distributions/{DistributionId}/monitoring-subscription` | + +#### Streaming distributions + +| Operation | Method | Path | +|---|---|---| +| `CreateStreamingDistribution` | POST | `/2020-05-31/streaming-distribution` | +| `GetStreamingDistribution` | GET | `/2020-05-31/streaming-distribution/{Id}` | +| `GetStreamingDistributionConfig` | GET | `/2020-05-31/streaming-distribution/{Id}/config` | +| `UpdateStreamingDistribution` | PUT | `/2020-05-31/streaming-distribution/{Id}/config` | +| `DeleteStreamingDistribution` | DELETE | `/2020-05-31/streaming-distribution/{Id}` | + ### Tagging | Operation | Method | Path | @@ -624,12 +682,11 @@ signatures must still return 403. Verify those cases through the proxy after con ## Not Supported (Phase 2) -- Continuous deployment policies (`CreateContinuousDeploymentPolicy`, etc.) -- `CopyDistribution` (staging distributions) -- Real-time log configs (`CreateRealtimeLogConfig`, etc.) -- Field-level encryption (`CreateFieldLevelEncryptionConfig`, etc.) +- Continuous deployment: a policy never diverts a primary distribution's requests to its staging + distribution (see [Stored configurations](#stored-configurations)) +- Delivering real-time logs, and encrypting fields with field-level encryption - `TestFunction` execution (function is stored, not executed) -- Streaming distributions (RTMP — deprecated by AWS) +- Serving RTMP for a streaming distribution (deprecated by AWS) - VPC origins, Anycast IP lists - Importing keys into a key value store from S3: `CreateKeyValueStore` with an `ImportSource` is rejected with `InvalidArgument` @@ -637,7 +694,7 @@ signatures must still return 403. Verify those cases through the proxy after con from a function with `cf.kvs()` - CloudFormation provisioning of `AWS::CloudFront::KeyValueStore`, and `KeyValueStoreAssociations` on `AWS::CloudFront::Function` -- Monitoring subscriptions +- Publishing the additional metrics a monitoring subscription turns on - CloudFormation provisioning of custom `AWS::CloudFront::ResponseHeadersPolicy` resources (literal custom or managed policy IDs are supported on distributions) - Persistent edge caching and global CDN propagation diff --git a/docs/services/eks.md b/docs/services/eks.md index 54a71939bc..2183e0f9db 100644 --- a/docs/services/eks.md +++ b/docs/services/eks.md @@ -69,6 +69,7 @@ or list operations. Resource tags are not retained for post-deletion policy cond | `DescribeFargateProfile` | Describe a Fargate profile by cluster and name | | `ListFargateProfiles` | List Fargate profile names for a cluster | | `DeleteFargateProfile` | Delete a Fargate profile | +| `ListIdentityProviderConfigs` | List a cluster's identity provider configs, always empty since none can be associated | | `TagResource` | Add tags to a cluster | | `UntagResource` | Remove tags from a cluster | | `ListTagsForResource` | List tags on a cluster | diff --git a/docs/services/index.md b/docs/services/index.md index 81fdf0a513..e6514cc1de 100644 --- a/docs/services/index.md +++ b/docs/services/index.md @@ -6,7 +6,7 @@ This page is the canonical reference for supported service and operation counts. ## Service Matrix -Operation counts are exact. For dispatch-table services (Query and JSON 1.1) each count reflects one case per AWS action in the handler. For REST-based services (S3, Lambda, API Gateway v1) the count reflects distinct AWS SDK operations, collapsing routes where one JAX-RS handler fans out via query-string or header markers (e.g. `PUT /{bucket}/{key}` → `PutObject`, `PutObjectTagging`, `PutObjectAcl`, etc.). +Operation counts are exact. For dispatch-table services (Query and JSON 1.1) each count reflects one case per AWS action in the handler. For REST-based services the count reflects distinct AWS SDK operations, collapsing routes where one JAX-RS handler fans out via query-string or header markers (e.g. `PUT /{bucket}/{key}` → `PutObject`, `PutObjectTagging`, `PutObjectAcl`, etc.). `make docs-check` checks every count against the handlers that serve it, except S3's, which is kept by hand because its handlers pick most operations by query string. | Service | Endpoint | Protocol | Supported operations | |---|---|---|---| @@ -15,14 +15,14 @@ Operation counts are exact. For dispatch-table services (Query and JSON 1.1) eac | [SNS](sns.md) | `POST /` with `Action=` param | Query / JSON | 39 | | [S3](s3.md) | `/{bucket}/{key}` | REST XML | 58 | | [S3 Vectors](s3vectors.md) | `POST /{OperationName}` | REST JSON | 16 | -| [S3 Tables](s3tables.md) | `/buckets`, `/namespaces/*`, `/tables/*` | REST JSON | 25 | +| [S3 Tables](s3tables.md) | `/buckets`, `/namespaces/*`, `/tables/*` | REST JSON | 27 | | [DynamoDB](dynamodb.md) | `POST /` + `X-Amz-Target: DynamoDB_20120810.*` | JSON 1.1 | 53 | | [DynamoDB Streams](dynamodb.md#streams) | `POST /` + `X-Amz-Target: DynamoDBStreams_20120810.*` | JSON 1.1 | 4 | -| [Lambda](lambda.md) | `/2015-03-31/functions/...` + `/2025-12-01/durable-executions/...` | REST JSON | 55 | -| [Lambda MicroVMs](lambda-microvms.md) | `/2025-09-09/...` + `/2026-04-04/...` | REST JSON | 22 | +| [Lambda](lambda.md) | `/2015-03-31/functions/...` + `/2025-12-01/durable-executions/...` | REST JSON | 68 | +| [Lambda MicroVMs](lambda-microvms.md) | `/2025-09-09/...` + `/2026-04-04/...` | REST JSON | 23 | | [Lambda Web Functions](lambda-web-functions.md) | `/2025-03-07/web-functions/...` | REST JSON | 20 | -| [API Gateway v1](api-gateway.md) | `/restapis/...` | REST JSON | 85 | -| [API Gateway v2](api-gateway.md#v2) | `/v2/apis/...` | REST JSON | 53 + data-plane | +| [API Gateway v1](api-gateway.md) | `/restapis/...` | REST JSON | 101 | +| [API Gateway v2](api-gateway.md#v2) | `/v2/apis/...` | REST JSON | 66 (+ the data plane) | | [IAM](iam.md) | `POST /` with `Action=` param | Query | 180 | | [STS](sts.md) | `POST /` with `Action=` param | Query | 11 | | [AWS Sign-In](iam.md#aws-sign-in-login-credentials) | `/v1/authorize`, `/v1/token` | REST JSON | 2 | @@ -44,13 +44,13 @@ Operation counts are exact. For dispatch-table services (Query and JSON 1.1) eac | [EventBridge](eventbridge.md) | `POST /` + `X-Amz-Target: AmazonEventBridge.*` | JSON 1.1 | 41 | | [EventBridge V2](eventbridgev2.md) | `POST /service/AWSEventsV2/operation/*` | Smithy RPC v2 CBOR | 10 | | [EventBridge Scheduler](scheduler.md) | `/schedules/*`, `/schedule-groups/*`, `/tags/*` | REST JSON | 12 | -| [EventBridge Pipes](pipes.md) | `/v1/pipes/*` | REST JSON | 7 | +| [EventBridge Pipes](pipes.md) | `/v1/pipes/*` | REST JSON | 10 | | [CloudWatch OAM](oam.md) | REST paths such as `POST /CreateSink` and `POST /CreateLink` | REST JSON | 15 | | [CloudWatch Logs](cloudwatch.md) | `POST /` + `X-Amz-Target: Logs.*` | JSON 1.1 | 53 | | [CloudWatch Metrics](cloudwatch.md#metrics) | `POST /` with `Action=` or JSON 1.1 | Query / JSON | 25 | | [CloudWatch RUM](rum.md) | `/appmonitor`, `/appmonitor/{name}`, `/appmonitors` | REST JSON | 5 | | [X-Ray](xray.md) | `/TraceSegments`, `/Traces`, `/TraceSummaries`, `/ServiceGraph`, `/TraceGraph`, `/GetSamplingRules`, `/CreateSamplingRule`, `/SamplingTargets`, `/TelemetryRecords` | REST JSON | 11 | -| [GuardDuty](guardduty.md) | `/detector`, `/detector/{detectorId}`, `/detector/{detectorId}/admin`, `/admin/*`, `/tags/*` | REST JSON | 28 | +| [GuardDuty](guardduty.md) | `/detector`, `/detector/{detectorId}`, `/detector/{detectorId}/admin`, `/admin/*`, `/tags/*` | REST JSON | 25 | | [AWS Account Management](account.md) | `/putAlternateContact`, `/getAlternateContact`, `/deleteAlternateContact`, `/putContactInformation`, `/getContactInformation`, `/getAccountInformation`, `/putAccountName` | REST JSON | 7 | | [IAM Access Analyzer](access-analyzer.md) | `/analyzer`, `/analyzer/{name}`, `/policy/validation` | REST JSON | 5 | | [IAM Identity Center (SSO Admin)](ssoadmin.md) | `POST /` + `X-Amz-Target: SWBExternalService.*` | JSON 1.1 | 79 | @@ -69,14 +69,14 @@ Operation counts are exact. For dispatch-table services (Query and JSON 1.1) eac | [MemoryDB](memorydb.md) | `POST /` + `X-Amz-Target: AmazonMemoryDB.*` + TCP proxy | JSON 1.1 + RESP | 13 | | [Aurora DSQL](dsql.md) | `/cluster`, `/cluster/{identifier}`, `/cluster/{identifier}/policy` + TLS endpoint | REST JSON + wire | 9 | | [RDS](rds.md) | `POST /` with `Action=` param + TCP proxy | Query + wire | 121 | -| [RDS Data API](rds-data.md) | `/Execute`, `/BeginTransaction`, `/CommitTransaction`, `/RollbackTransaction` | REST JSON | 4 | +| [RDS Data API](rds-data.md) | `/Execute`, `/BatchExecute`, `/BeginTransaction`, `/CommitTransaction`, `/RollbackTransaction` | REST JSON | 5 | | [Timestream for InfluxDB](timestream-influxdb.md) | `POST /` + `X-Amz-Target: AmazonTimestreamInfluxDB.*` + InfluxDB container | JSON 1.0 + InfluxDB HTTP | 24 | -| [MSK](msk.md) | `/v1/clusters/...`, `/api/v2/clusters/...` + Redpanda broker | REST JSON + Kafka | 8 | -| [Amazon MQ](amazonmq.md) | `/v1/brokers/...` + RabbitMQ broker | REST JSON + AMQP | 5 | +| [MSK](msk.md) | `/v1/clusters/...`, `/api/v2/clusters/...` + Redpanda broker | REST JSON + Kafka | 21 | +| [Amazon MQ](amazonmq.md) | `/v1/brokers/...` + RabbitMQ broker | REST JSON + AMQP | 6 | | [MWAA](mwaa.md) | `/` REST paths for environments + CLI/web proxy | REST JSON | 10 | | [Athena](athena.md) | `POST /` + `X-Amz-Target: AmazonAthena.*` | JSON 1.1 | 27 | | [Glue](glue.md) | `POST /` + `X-Amz-Target: AWSGlue.*` | JSON 1.1 | 140 | -| [Lake Formation](lakeformation.md) | `POST /` | REST JSON | 16 | +| [Lake Formation](lakeformation.md) | `POST /` | REST JSON | 17 | | [Neptune](neptune.md) | `POST /` with `Action=` param + Gremlin TCP proxy | Query + WebSocket | 14 | | [DocumentDB](docdb.md) | `POST /` with `Action=` param + MongoDB container | Query + MongoDB wire | 17 | | [DMS](dms.md) | `POST /` + `X-Amz-Target: AmazonDMSv20160101.*` | JSON 1.1 | 20 | @@ -86,7 +86,7 @@ Operation counts are exact. For dispatch-table services (Query and JSON 1.1) eac | [Redshift Serverless](redshift-serverless.md) | `POST /` + `X-Amz-Target: RedshiftServerless.*` | JSON 1.1 | 58 | | [EMR](emr.md) | `POST /` + `X-Amz-Target: ElasticMapReduce.*` | JSON 1.1 | 64 | | [EMR on EKS](emr-containers.md) | `/virtualclusters/*`, `/jobtemplates/*`, `/securityconfigurations/*`, `/tags/*` | REST JSON | 25 | -| [EMR Serverless](emr-serverless.md) | `/applications/*`, `/tags/*` | REST JSON | 15 | +| [EMR Serverless](emr-serverless.md) | `/applications/*`, `/tags/*` | REST JSON | 22 | | [Data Firehose](firehose.md) | `POST /` + `X-Amz-Target: Firehose_20150804.*` | JSON 1.1 | 12 | | [ECS](ecs.md) | `POST /` + `X-Amz-Target: AmazonEC2ContainerServiceV20141113.*` | JSON 1.1 | 59 | | [EFS](efs.md) | `/2015-02-01/...` | REST JSON | 26 | @@ -100,15 +100,15 @@ Operation counts are exact. For dispatch-table services (Query and JSON 1.1) eac | [Resource Explorer](resource-explorer.md) | `POST /{OperationName}`, rewritten to `/_re2/*` for the four paths S3 Vectors also claims | REST JSON | 32 | | [SES](ses.md) | `POST /` with `Action=` param | Query | 70 | | [SES v2](ses.md#v2) | `/v2/email/*` | REST JSON | 102 | -| [OpenSearch](opensearch.md) | `/2021-01-01/opensearch/...` | REST JSON | 24 | -| [AppConfig](appconfig.md) | `/applications/...`, `/deploymentstrategies/...` | REST JSON | 16 | +| [OpenSearch](opensearch.md) | `/2021-01-01/opensearch/...`, legacy `/2015-01-01/es/...` | REST JSON | 36 | +| [AppConfig](appconfig.md) | `/applications/...`, `/deploymentstrategies/...` | REST JSON | 29 | | [AppConfigData](appconfig.md#data-plane) | `/configurationsessions`, `/configuration` | REST JSON | 2 | -| [AppSync](appsync.md) | `/v1/apis/...` | REST JSON | 33 | +| [AppSync](appsync.md) | `/v1/apis/...` | REST JSON | 58 | | [Amazon Bedrock](bedrock.md) | `/guardrails`, `/guardrails/{guardrailIdentifier}`, `/foundation-models`, `/foundation-models/{modelIdentifier}`, `/inference-profiles`, `/inference-profiles/{inferenceProfileIdentifier}`, `/resource-policy`, `/resource-policy/{resourceArn}`, `/tagResource`, `/untagResource`, `/listTagsForResource` | REST JSON | 18 | -| [Bedrock Runtime](bedrock-runtime.md) | `/model/{modelId}/converse`, `/model/{modelId}/invoke` | REST JSON | 2 (stub; streaming returns 501) | +| [Bedrock Runtime](bedrock-runtime.md) | `/model/{modelId}/converse`, `/model/{modelId}/converse-stream`, `/model/{modelId}/invoke` | REST JSON | 3 (`InvokeModelWithResponseStream` answers 501) | | [Bedrock AgentCore Control](bedrock-agentcore.md) | `/runtimes/*`, `/gateways/*`, `/memories/*`, `/identities/*`, `/browsers*`, `/browser-profiles*`, `/code-interpreters*`, `/harnesses*`, `/resourcepolicy/*`, `/tags/{resourceArn}` | REST JSON | 71 (+ 3 tagging via shared `/tags/{arn}` route) | | [Bedrock AgentCore](bedrock-agentcore.md#data-plane-invokeagentruntime) | `/runtimes/{agentRuntimeArn}/invocations` | REST JSON (binary payload) | 1 (canned-response stub) | -| [EKS](eks.md) | `/clusters`, `/clusters/{name}`, `/tags/{resourceArn}` | REST JSON | 7 | +| [EKS](eks.md) | `/clusters`, `/clusters/{name}`, `/tags/{resourceArn}` | REST JSON | 35 | | [ELB v2](elb.md) | `POST /` with `Action=` param | Query | 37 | | [ELB Classic (v1)](elb-classic.md) | `POST /` with `Action=` and `Version=2012-06-01` | Query | 20 | | [WAF v2](wafv2.md) | `POST /` + `X-Amz-Target: AWSWAF_20190729.*` | JSON 1.1 | 35 | @@ -116,7 +116,7 @@ Operation counts are exact. For dispatch-table services (Query and JSON 1.1) eac | [Application Auto Scaling](applicationautoscaling.md) | `POST /` + `X-Amz-Target: AnyScaleFrontendService.*` | JSON 1.1 | 13 | | [Elastic Beanstalk](elastic-beanstalk.md) | `POST /` with `Action=` or `Operation=` param | Query | 14 | | [CodeBuild](codebuild.md) | `POST /` + `X-Amz-Target: CodeBuild_20161006.*` | JSON 1.1 | 20 | -| [AWS Batch](batch.md) | `/v1/...` | REST JSON | 10 | +| [AWS Batch](batch.md) | `/v1/...` | REST JSON | 19 | | [CodeDeploy](codedeploy.md) | `POST /` + `X-Amz-Target: CodeDeploy_20141006.*` | JSON 1.1 | 35 | | [CodePipeline](codepipeline.md) | `POST /` + `X-Amz-Target: CodePipeline_20150709.*` | JSON 1.1 | 44 | | [AWS Signer](signer.md) | `/signing-profiles`, `/signing-jobs`, `/signing-platforms`, `/revocations` | REST JSON | 18 | @@ -127,13 +127,14 @@ Operation counts are exact. For dispatch-table services (Query and JSON 1.1) eac | [AWS RAM](ram.md) | `POST /{operationname}` (lowercase), `DELETE /deleteresourceshare` | REST JSON | 16 | | [Control Catalog](controlcatalog.md) | `/get-control`, `/list-controls` | REST JSON | 2 | | [AWS Marketplace](marketplace.md) | Marketplace Catalog API | REST JSON | 56 | -| [Control Tower](controltower.md) | `/list-landingzones`, `/get-landingzone`, `/create-landingzone`, `/*-baseline*` | REST JSON | 15 | +| [Control Tower](controltower.md) | `/list-landingzones`, `/get-landingzone`, `/create-landingzone`, `/*-baseline*` | REST JSON | 24 | | [Managed Prometheus (AMP)](managed-prometheus.md) | `/workspaces/*`, `/workspaces/*/rulegroupsnamespaces/*`, `/tags/*` | REST JSON | 13 | -| [AWS Backup](backup.md) | `/backup-vaults/*`, `/logically-air-gapped-backup-vaults/*`, `/backup/plans/*`, `/backup-jobs/*`, `/supported-resource-types` | REST JSON | 35 | +| [AWS Backup](backup.md) | `/backup-vaults/*`, `/logically-air-gapped-backup-vaults/*`, `/backup/plans/*`, `/backup-jobs/*`, `/supported-resource-types` | REST JSON | 33 | | [AWS FIS](fis.md) | `/experimentTemplates/*`, `/experiments/*`, `/actions/*`, `/targetResourceTypes/*`, `/safetyLevers/*`, `/tags/*` | REST JSON | 26 | | [CodeGuru Reviewer](codegurureviewer.md) | `/associations`, `/associations/{associationArn}`, `/tags/*` | REST JSON | 7 | | [CodeArtifact](codeartifact.md) | `/v1/domain*`, `/v1/repository*`, `/v1/package`, `/v1/package/version*`, `/v1/package-group*`, `/v1/list-associated-packages`, `/v1/get-associated-package-group`, `/v1/tag*`, `/v1/authorization-token`, `/codeartifact/maven/*`, `/codeartifact/npm/*`, `/codeartifact/pypi/*` | REST JSON | 48 | -| [CloudFront](cloudfront.md) | `/2020-05-31/distribution/*`, `/2020-05-31/cache-policy/*`, `/2020-05-31/function/*`, `/2020-05-31/key-value-store/*`, `/key-value-stores/*` | REST XML, REST JSON | 61 | +| [CloudFront](cloudfront.md) | `/2020-05-31/distribution/*`, `/2020-05-31/cache-policy/*`, `/2020-05-31/function/*`, `/2020-05-31/key-value-store/*` | REST XML | 97 | +| [CloudFront KeyValueStore](cloudfront.md#key-value-stores) | `/key-value-stores/*` | REST JSON | 6 | | [Route53](route53.md) | `/2013-04-01/hostedzone/*`, `/2013-04-01/healthcheck/*`, `/2013-04-01/change/*`, `/2013-04-01/delegationset/*` | REST XML | 31 | | [Route 53 Resolver](route53resolver.md) | `POST /` + `X-Amz-Target: Route53Resolver.*` | JSON 1.1 | 22 | | [Amazon SageMaker](sagemaker.md) | `POST /` + `X-Amz-Target: SageMaker.*` | JSON 1.1 | 20 | @@ -153,8 +154,8 @@ Operation counts are exact. For dispatch-table services (Query and JSON 1.1) eac | [BCM Data Exports](bcm-data-exports.md) | `POST /` + `X-Amz-Target: AWSBillingAndCostManagementDataExports.*` | JSON 1.1 | 7 | | [Transfer Family](transfer.md) | `POST /` + `X-Amz-Target: TransferService.*` | JSON 1.1 | 17 | | [DataSync](datasync.md) | `POST /` + `X-Amz-Target: FmrsService.*` | JSON 1.1 | 48 | -| [IoT Core](iot.md) | `/things/...`, `/endpoint`, rules/policies REST paths | REST JSON | 78 | -| [IoT Data](iot.md) | `/things/{thingName}/shadow`, MQTT topics | REST JSON | 11 | +| [IoT Core](iot.md) | `/things/...`, `/endpoint`, rules/policies REST paths | REST JSON | 83 | +| [IoT Data](iot.md#iot-data) | `/things/{thingName}/shadow`, MQTT topics | REST JSON | 11 | **Lambda, ElastiCache, RDS, MSK, MWAA, ECS, EKS, and OpenSearch** spin up real Docker containers and support IAM authentication and SigV4 request signing, the same auth flow as production AWS. **RDS Data API** executes SQL against the local RDS containers through AWS-compatible REST JSON routes. diff --git a/docs/services/iot.md b/docs/services/iot.md index 20081545de..65c57d8c3f 100644 --- a/docs/services/iot.md +++ b/docs/services/iot.md @@ -172,6 +172,25 @@ Current limitations: - `connectivity.sessionExpiry` and the socket information of `filter.connectivity.includeSocketInformation` are not reported. - `managedFields` and `customFields` sent in the thing group configuration are checked (the custom fields for their types only) but not stored: `GetIndexingConfiguration` reports the managed fields the mode selects and no custom fields. +## IoT Data API {#iot-data} + +The IoT Data plane answers on the same endpoint as the control plane. The notes under +MVP 1 and MVP 2 above describe how each call behaves. + +| Action | Description | +|---|---| +| `GetThingShadow` | Read a thing's classic shadow, or a named one with `name` | +| `UpdateThingShadow` | Update a thing's classic or named shadow | +| `DeleteThingShadow` | Delete a thing's classic or named shadow | +| `ListNamedShadowsForThing` | List a thing's named shadows | +| `Publish` | Publish a message to an MQTT topic, retained with `retain=true` | +| `GetRetainedMessage` | Read the retained message of a topic | +| `ListRetainedMessages` | List retained messages, paginated | +| `GetConnection` | Read a live MQTT client session | +| `DeleteConnection` | Close a live MQTT client session | +| `ListSubscriptions` | List the topic subscriptions of a live MQTT client session | +| `SendDirectMessage` | Send a message to a connected client's topic, delivered to that topic's subscribers | + ## MQTT Broker Status: complete. diff --git a/docs/services/lambda.md b/docs/services/lambda.md index 30eff0fbe5..8e2ce4c1b0 100644 --- a/docs/services/lambda.md +++ b/docs/services/lambda.md @@ -46,6 +46,12 @@ Floci Lambda runs your function code locally inside real Docker containers - clo | `ListFunctionUrlConfigs` | List a function's URL configurations across its unpublished version and aliases, with marker pagination | | `UpdateFunctionUrlConfig` | Update function URL config | | `DeleteFunctionUrlConfig` | Delete function URL config | +| `PublishLayerVersion` | Publish a layer version from a zip or an S3 object (see Layers below) | +| `GetLayerVersion` | Get a layer version by name and version number | +| `GetLayerVersionByArn` | Get a layer version by its ARN | +| `ListLayerVersions` | List the versions of a layer, optionally by runtime and architecture | +| `ListLayers` | List layers with their newest version, optionally by runtime and architecture | +| `DeleteLayerVersion` | Delete a layer version | | `ListTags` | List tags on a function or event source mapping | | `TagResource` | Tag a function or event source mapping | | `UntagResource` | Untag a function or event source mapping | diff --git a/docs/services/pipes.md b/docs/services/pipes.md index cb2c688afb..f901c05a6c 100644 --- a/docs/services/pipes.md +++ b/docs/services/pipes.md @@ -14,6 +14,9 @@ | `ListPipes` | List all pipes with optional filtering by state and prefix | | `StartPipe` | Start a stopped pipe | | `StopPipe` | Stop a running pipe | +| `TagResource` | Add tags to a pipe | +| `UntagResource` | Remove tags from a pipe | +| `ListTagsForResource` | List the tags of a pipe | ## Configuration diff --git a/tools/docs/check_service_matrix.py b/tools/docs/check_service_matrix.py index 67367fa554..7613a63d08 100644 --- a/tools/docs/check_service_matrix.py +++ b/tools/docs/check_service_matrix.py @@ -21,6 +21,11 @@ matrix row, unless listed under `facet_pages:` in the registry, so a page can no longer exist in the nav with no row (elb-classic.md did, hidden by the `elb` key exact-matching the v2 page). +Each row's operation count is checked as well: against the page's generated action +table, or against the dispatchers `action_count_sources:` names for it. A row neither +covers fails unless `hand_counted:` lists it with the reason it cannot be derived, so a +new row cannot quietly fall back to a hand-kept number. + Run from anywhere in the repo: python3 tools/docs/check_service_matrix.py # print warnings only python3 tools/docs/check_service_matrix.py --strict # exit non-zero on warnings @@ -48,19 +53,10 @@ CATALOG_SOURCE = f"{PACKAGE_DIR}/core/common/ResolvedServiceCatalog.java" MATRIX_DOC = "docs/services/index.md" REGISTRY = "tools/docs/service_matrix.yaml" -# Rows whose count comes from their dispatchers; removing a registry entry must not -# silently turn off their count check. -REQUIRED_ACTION_COUNT_SOURCES = frozenset({ - "autoscaling", "bcm-data-exports", "bcm-pricing-calculator", "cloudcontrol", - "cloudmap", "cloudwatch", "cloudwatch#metrics", "codebuild", "codedeploy", - "codepipeline", "cognito", "config", "cur", "dynamodb", "dynamodb#streams", "ec2", - "ecr", "ecs", "elastic-beanstalk", "elb", "elb-classic", "glue", "iam", "lightsail", - "pricing", "resource-groups-tagging", "ses", "sns", "ssm", "sts", "textract", - "transcribe", "transfer", -}) - -# Keys an action_count_sources mapping entry may carry, beside the plain-path form. -ACTION_COUNT_SOURCE_KEYS = frozenset({"sources", "exclude_actions"}) +# Keys an action_count_sources mapping entry may carry, beside the plain-path form, +# and the keys of one of its sources. +ACTION_COUNT_SOURCE_KEYS = frozenset({"sources", "rename_actions", "exclude_actions"}) +SOURCE_KEYS = frozenset({"path", "mode", "route_prefix", "skip_route_prefix"}) MATRIX_HEADING = "## Service Matrix" MATRIX_END_HEADING = "## Common Setup" @@ -76,10 +72,16 @@ DESCRIPTOR_KEY_RE = re.compile(r'\bdescriptor\(\s*"([^"]+)"') # definition itself, the one place "descriptor(" appears that isn't a call. ALL_DESCRIPTOR_CALLS_RE = re.compile(r"(? `cloudwatch#metrics`); the slug alone is the doc filename. +MATRIX_CELL_LINK_RE = re.compile(r"\]\(([a-z0-9][a-z0-9\-]*)\.md(#[^)]*)?\)") +MATRIX_HEADER_CELL = "Service" +MATRIX_SEPARATOR_RE = re.compile(r"^\|[\s:|-]+\|$") + +# The operation count closing a row: a number, optionally followed by one +# parenthetical note. +MATRIX_COUNT_RE = re.compile(r"\|\s*(\d+)(?:\s*\([^)]*\))?\s*\|$") SERVICES_DIR = "docs/services" @@ -105,13 +107,11 @@ def count_descriptor_calls(java_source: str) -> int: return len(ALL_DESCRIPTOR_CALLS_RE.findall(java_source)) -def extract_matrix_slugs(md_source: str) -> set[str]: - """Doc filenames (no extension, no anchor) linked from the Service Matrix table. +def _matrix_table(md_source: str) -> str: + """The Service Matrix table, between MATRIX_HEADING and MATRIX_END_HEADING. - Scoped to the table between MATRIX_HEADING and MATRIX_END_HEADING so an unrelated - markdown link elsewhere on the page (prose, footer) can never be mistaken for a - documented row. Raises ValueError if either heading is missing, rather than letting - a renamed heading silently empty the table (and every service look undocumented). + Raises ValueError if either heading is missing, rather than letting a renamed + heading silently empty the table (and every service look undocumented). """ try: start = md_source.index(MATRIX_HEADING) @@ -121,8 +121,45 @@ def extract_matrix_slugs(md_source: str) -> set[str]: f"{MATRIX_DOC}: could not find '{MATRIX_HEADING}' ... '{MATRIX_END_HEADING}' " "(has a heading been renamed or reordered?)" ) from None - table = md_source[start:end] - return set(MATRIX_LINK_RE.findall(table)) + return md_source[start:end] + + +def _matrix_rows(md_source: str) -> list[tuple[str, str]]: + """(key, line) of each Service Matrix row, the key being its first cell's link target. + + Presence, counts and coverage all read the rows from here, so a row cannot count as + documented while escaping the count checks. A row whose first cell links no page + is refused rather than skipped. + """ + rows: list[tuple[str, str]] = [] + for line in _matrix_table(md_source).splitlines(): + line = line.strip() + if not line.startswith("|") or MATRIX_SEPARATOR_RE.match(line): + continue + first_cell = line.split("|")[1].strip() + link = MATRIX_CELL_LINK_RE.search(first_cell) + if link: + rows.append((link.group(1) + (link.group(2) or ""), line)) + elif first_cell != MATRIX_HEADER_CELL: + raise ValueError(f"{MATRIX_DOC}: the Service Matrix row '{first_cell}' links no docs/services page " + "from its first cell") + return rows + + +def extract_matrix_slugs(md_source: str) -> set[str]: + """Doc filenames (no extension, no anchor) linked from the Service Matrix rows. + + Scoped to the table so an unrelated markdown link elsewhere on the page (prose, + footer) can never be mistaken for a documented row. + """ + return {key.split("#")[0] for key, _line in _matrix_rows(md_source)} + + +def extract_matrix_row_keys(md_source: str) -> list[str]: + """Every Service Matrix row's link target, `slug` or `slug#anchor`, in table order, + whether or not its count is numeric.""" + return [key for key, _line in _matrix_rows(md_source)] + def extract_matrix_action_counts(md_source: str) -> dict[str, int]: """Extract documented operation counts, keyed by the row's link target. @@ -133,35 +170,14 @@ def extract_matrix_action_counts(md_source: str) -> dict[str, int]: keyed ``slug#anchor`` (``dynamodb#streams``), so a page documenting two services gives each row its own count. """ - try: - start = md_source.index(MATRIX_HEADING) - end = md_source.index(MATRIX_END_HEADING, start) - except ValueError: - raise ValueError( - f"{MATRIX_DOC}: could not find '{MATRIX_HEADING}' ... " - f"'{MATRIX_END_HEADING}' (has a heading been renamed or reordered?)" - ) from None - counts: dict[str, int] = {} - - for line in md_source[start:end].splitlines(): - match = re.match( - r"^\|\s*\[[^\]]+\]\(([a-z0-9][a-z0-9\-]*)\.md" - r"(#[^)]*)?\)\s*\|.*\|\s*(\d+)" - r"(?:\s*\([^)]*\))?\s*\|$", - line, - ) - if not match: - continue - - slug, anchor, base_count = match.groups() - - counts.setdefault(slug + (anchor or ""), int(base_count)) - + for key, line in _matrix_rows(md_source): + count = MATRIX_COUNT_RE.search(line) + if count: + counts.setdefault(key, int(count.group(1))) return counts - def count_generated_actions(md_source: str) -> int | None: """Count action rows inside a generated action-table marker pair. @@ -202,9 +218,10 @@ def _action_count_entry(repo_root: Path, key: str, spec: object) -> regen_action """The regen_action_docs entry an action_count_sources value describes. A value is either one source path, read as a switch dispatcher, or a mapping with - `sources:` (paths, or `{path, mode}` for another regen_action_docs mode) and an - optional `exclude_actions:` list for labels a dispatcher's file carries beside - its actions. + `sources:` (paths, or `{path, mode}` for another regen_action_docs mode), an + optional `rename_actions:` mapping for a controller method not named after its + AWS action, and an optional `exclude_actions:` list for labels or methods that are + not actions of the row. """ if isinstance(spec, str): spec = {"sources": [spec]} @@ -222,7 +239,19 @@ def _action_count_entry(repo_root: Path, key: str, spec: object) -> regen_action raw = {"path": raw, "mode": "switch"} if not isinstance(raw, dict) or not isinstance(raw.get("path"), str) or not isinstance(raw.get("mode"), str): raise ValueError(f"{REGISTRY}: action count source '{key}' has a source without a path and mode: {raw!r}") - sources.append(regen_action_docs.Source(path=repo_root / package_source(raw["path"]), mode=raw["mode"])) + unknown = raw.keys() - SOURCE_KEYS + if unknown: + raise ValueError(f"{REGISTRY}: action count source '{key}' has a source with unknown key(s): " + f"{', '.join(sorted(unknown))}") + sources.append(regen_action_docs.Source( + path=repo_root / package_source(raw["path"]), + mode=raw["mode"], + route_prefix=raw.get("route_prefix"), + skip_route_prefix=raw.get("skip_route_prefix"), + )) + renamed = spec.get("rename_actions") or {} + if not isinstance(renamed, dict): + raise ValueError(f"{REGISTRY}: action count source '{key}' needs rename_actions as a mapping") excluded = spec.get("exclude_actions") or [] if not isinstance(excluded, list): raise ValueError(f"{REGISTRY}: action count source '{key}' needs exclude_actions as a list") @@ -230,6 +259,7 @@ def _action_count_entry(repo_root: Path, key: str, spec: object) -> regen_action service=key, doc=repo_root / MATRIX_DOC, sources=sources, + rename_actions=dict(renamed), exclude_actions=frozenset(excluded), ) @@ -252,7 +282,7 @@ def count_source_actions(repo_root: Path, key: str, spec: object) -> int: raise ValueError(f"{REGISTRY}: action count source '{key}' {exc}") from None -def extract_action_counts(repo_root: Path, required_sources: frozenset[str] = frozenset()) -> dict[str, int]: +def extract_action_counts(repo_root: Path) -> dict[str, int]: """Extract mechanically verifiable action counts. Generated service documents are counted from their generated action-table markers. Rows mapped in action_count_sources are counted from their @@ -286,9 +316,6 @@ def extract_action_counts(repo_root: Path, required_sources: frozenset[str] = fr sources = registry.get("action_count_sources") if not isinstance(sources, dict) or not sources: raise ValueError(f"{REGISTRY}: action_count_sources must be a non-empty mapping") - missing = required_sources - sources.keys() - if missing: - raise ValueError(f"{REGISTRY}: required action count source(s) missing: {', '.join(sorted(missing))}") for key, spec in sources.items(): if key not in matrix_counts: raise ValueError(f"{REGISTRY}: action count source '{key}' has no numeric matrix row") @@ -298,6 +325,45 @@ def extract_action_counts(repo_root: Path, required_sources: frozenset[str] = fr return counts + +def load_hand_counted(repo_root: Path) -> dict[str, str]: + """Rows `hand_counted:` exempts from the count check, each with the reason why.""" + raw = yaml.safe_load((repo_root / REGISTRY).read_text(encoding="utf-8")) or {} + hand_counted = raw.get("hand_counted") or {} + if not isinstance(hand_counted, dict): + raise ValueError(f"{REGISTRY}: hand_counted must map a row to the reason it is counted by hand") + for key, reason in hand_counted.items(): + if not isinstance(reason, str) or not reason.strip(): + raise ValueError(f"{REGISTRY}: hand_counted row '{key}' needs the reason it is counted by hand") + return hand_counted + + +def find_unchecked_rows(row_keys: list[str], matrix_counts: dict[str, int], + checked: set[str], hand_counted: dict[str, str]) -> list[str]: + """Warnings for rows whose count nothing checks, and for stale hand_counted entries.""" + warnings: list[str] = [] + seen: set[str] = set() + for key in row_keys: + if key in seen: + warnings.append( + f"two rows in {MATRIX_DOC} link to '{key}'; give one an anchor so each row has its own count" + ) + continue + seen.add(key) + if key not in matrix_counts: + warnings.append(f"row '{key}' in {MATRIX_DOC} has no numeric operation count") + elif key in checked and key in hand_counted: + warnings.append(f"row '{key}' is checked, so drop it from hand_counted in {REGISTRY}") + elif key not in checked and key not in hand_counted: + warnings.append( + f"nothing checks the count of row '{key}' in {MATRIX_DOC}; map its dispatchers under " + f"action_count_sources in {REGISTRY}, or list it under hand_counted with the reason" + ) + for key in sorted(hand_counted.keys() - seen): + warnings.append(f"hand_counted row '{key}' in {REGISTRY} is not a row of {MATRIX_DOC}") + return warnings + + def find_unlinked_pages(services_dir: Path, slugs: set[str], facet_pages: set[str]) -> list[str]: """docs/services pages (by slug) that no matrix row links and no facet entry excuses. @@ -416,8 +482,10 @@ def main(argv: list[str] | None = None) -> int: return 1 try: + matrix_row_keys = extract_matrix_row_keys(md_source) matrix_action_counts = extract_matrix_action_counts(md_source) - source_action_counts = extract_action_counts(repo_root, REQUIRED_ACTION_COUNT_SOURCES) + source_action_counts = extract_action_counts(repo_root) + hand_counted = load_hand_counted(repo_root) except (ValueError, OSError, yaml.YAMLError) as exc: print(f"error: {exc}", file=sys.stderr) return 1 @@ -438,6 +506,8 @@ def main(argv: list[str] | None = None) -> int: f"in {MATRIX_DOC}, but the action source contains {source_count}; " "update the matrix count" ) + warnings.extend(find_unchecked_rows( + matrix_row_keys, matrix_action_counts, set(source_action_counts), hand_counted)) for d in expired_deferred: warnings.append( f"deferred entry '{d.key}' expired on {d.by.isoformat()} ({d.reason}); " diff --git a/tools/docs/regen_action_docs.py b/tools/docs/regen_action_docs.py index ae28ac33fe..22109dcd32 100644 --- a/tools/docs/regen_action_docs.py +++ b/tools/docs/regen_action_docs.py @@ -54,6 +54,15 @@ SWITCH_LABEL_RE = re.compile(r'"([A-Z][a-z][A-Za-z0-9]*)"') # key has the same PascalCase head as a switch label. MAP_ENTRY_KEY_RE = re.compile(r'\bMap\.entry\(\s*"([A-Z][a-z][A-Za-z0-9]*)"') +# A class implementing core.common.TagHandler: SharedTagsController and V1TagsController +# serve tagging on /tags/{arn} and /v1/tags/{arn} for every service with one, so that +# class is what gives a service the three tagging actions. A service naming one of them +# differently (Backup's ListTags) renames it. A @TaggingApiOnly handler is left out of +# those controllers (its service tags through routes of its own), so it gives none. +TAG_HANDLER_RE = re.compile(r"\bclass\s+\w+[^{]*\bimplements\b[^{]*\bTagHandler\b") +TAGGING_API_ONLY_RE = re.compile(r"^\s*@TaggingApiOnly\b", re.MULTILINE) +TAG_HANDLER_ACTIONS = ("TagResource", "UntagResource", "ListTagsForResource") + # REST controllers: a JAX-RS verb annotation followed by the public method it decorates, # inside a class that carries a class-level @Path. The action is ucfirst(methodName), # corrected per-service via rename_actions / exclude_actions (method names are not @@ -65,12 +74,20 @@ PUBLIC_METHOD_RE = re.compile(r"^\s*public\s+\S+(?:<[^>]*>)?\s+([a-z][A-Za-z0-9] # Line/block-comment lines (Javadoc) that may sit between the verb annotation and the # method signature; skipped so they don't reset the `pending` flag mid-lookahead. COMMENT_LINE_RE = re.compile(r"^\s*(?://|/\*|\*)") +# A JAX-RS @Path value, and the class declaration that separates the class-level @Path +# from the method-level ones; together they give each method its route. +PATH_VALUE_RE = re.compile(r'^\s*(?:@\w+\s+)*@Path\(\s*"([^"]*)"') +CLASS_DECLARATION_RE = re.compile(r"^\s*(?:public\s+)?(?:abstract\s+|final\s+)*class\s+\w+") @dataclass(frozen=True) class Source: path: Path - mode: str # 'switch' | 'rest' | 'map_entries' + mode: str # 'switch' | 'rest' | 'map_entries' | 'tag_handler' + # rest only: keep the methods whose route starts with route_prefix, or drop those whose + # route starts with skip_route_prefix (API Gateway serves v1 and /v2/ from one controller). + route_prefix: str | None = None + skip_route_prefix: str | None = None @dataclass(frozen=True) @@ -78,7 +95,9 @@ class ServiceEntry: service: str doc: Path sources: list[Source] - rename_actions: dict[str, str] = field(default_factory=dict) + # A list value is one method serving several actions, picked by a query parameter + # (Lambda's provisioned-concurrency GET answers Get... and List... by `List=ALL`). + rename_actions: dict[str, str | list[str]] = field(default_factory=dict) exclude_actions: frozenset[str] = field(default_factory=frozenset) handler: Path | None = None # optional explicit handler path for excluded services @@ -103,19 +122,46 @@ def extract_map_entry_actions(java_source: str) -> list[str]: return MAP_ENTRY_KEY_RE.findall(java_source) +def extract_tag_handler_actions(java_source: str) -> list[str]: + """The shared tagging actions, when the source declares a TagHandler implementation + the shared /tags controllers serve.""" + if not TAG_HANDLER_RE.search(java_source) or TAGGING_API_ONLY_RE.search(java_source): + return [] + return list(TAG_HANDLER_ACTIONS) + + CLASS_EXTENDS_RE = re.compile(r"public\s+(?:abstract\s+)?class\s+\w+\s+extends\s+([A-Za-z0-9_]+)") -def _extract_raw_rest_methods(java_source: str) -> list[str]: - actions: list[str] = [] +def _join_route(class_path: str, method_path: str) -> str: + return "/" + "/".join(part.strip("/") for part in (class_path, method_path) if part.strip("/")) + + +def _extract_raw_rest_routes(java_source: str) -> list[tuple[str, str]]: + """(action, route) of each JAX-RS method; the route joins the class and method @Path.""" + routes: list[tuple[str, str]] = [] pending = False + in_class = False + class_path = "" + method_path = "" for line in java_source.splitlines(): if not line.strip(): continue + path_match = PATH_VALUE_RE.match(line) + if path_match: + if in_class: + method_path = path_match.group(1) + else: + class_path = path_match.group(1) + if not in_class and CLASS_DECLARATION_RE.match(line): + in_class = True + continue if HTTP_ANNO_RE.match(line): pending = True continue if not pending: + if PUBLIC_METHOD_RE.match(line): + method_path = "" continue if ANNOTATION_LINE_RE.match(line): continue @@ -124,37 +170,45 @@ def _extract_raw_rest_methods(java_source: str) -> list[str]: m = PUBLIC_METHOD_RE.match(line) if m: name = m.group(1) - actions.append(name[0].upper() + name[1:]) + routes.append((name[0].upper() + name[1:], _join_route(class_path, method_path))) pending = False - return actions + method_path = "" + return routes -def extract_rest_actions(java_source: str, source_path: Path | None = None) -> list[str]: +def extract_rest_actions(java_source: str, source_path: Path | None = None, + route_prefix: str | None = None, skip_route_prefix: str | None = None) -> list[str]: """ucfirst(method name) of @GET/@POST/@PUT/@DELETE/@PATCH methods, source order. Only applies to classes containing a class-level @Path. Returns [] otherwise. Inherited methods from a superclass in the same directory are included first. + route_prefix keeps only the methods whose route starts with it; skip_route_prefix + drops those whose route does. """ if not CLASS_PATH_RE.search(java_source): return [] - actions: list[str] = [] + routes: list[tuple[str, str]] = [] if source_path is not None: extends_match = CLASS_EXTENDS_RE.search(java_source) if extends_match: super_name = extends_match.group(1) super_path = source_path.parent / f"{super_name}.java" if super_path.exists(): - actions.extend(_extract_raw_rest_methods(super_path.read_text(encoding="utf-8"))) - actions.extend(_extract_raw_rest_methods(java_source)) - return actions + routes.extend(_extract_raw_rest_routes(super_path.read_text(encoding="utf-8"))) + routes.extend(_extract_raw_rest_routes(java_source)) + return [ + action for action, route in routes + if (route_prefix is None or route.startswith(route_prefix)) + and (skip_route_prefix is None or not route.startswith(skip_route_prefix)) + ] def extract_actions(entry: ServiceEntry) -> list[str]: """Merged, deduped, override-corrected action list for a service. Order: first appearance across the source list in registry order. rename_actions - is applied before dedup (so a renamed collision dedupes correctly); excluded - names are dropped after rename. + is applied before dedup (so a renamed collision dedupes correctly), a list value + standing for each action it names; excluded names are dropped after rename. """ seen: set[str] = set() out: list[str] = [] @@ -163,18 +217,21 @@ def extract_actions(entry: ServiceEntry) -> list[str]: if source.mode == "switch": raw = extract_switch_actions(text) elif source.mode == "rest": - raw = extract_rest_actions(text, source.path) + raw = extract_rest_actions(text, source.path, source.route_prefix, source.skip_route_prefix) elif source.mode == "map_entries": raw = extract_map_entry_actions(text) + elif source.mode == "tag_handler": + raw = extract_tag_handler_actions(text) else: raise ValueError(f"unknown mode: {source.mode!r}") - for name in raw: - name = entry.rename_actions.get(name, name) - if name in entry.exclude_actions: - continue - if name not in seen: - seen.add(name) - out.append(name) + for raw_name in raw: + renamed = entry.rename_actions.get(raw_name, raw_name) + for name in renamed if isinstance(renamed, list) else [renamed]: + if name in entry.exclude_actions: + continue + if name not in seen: + seen.add(name) + out.append(name) return out diff --git a/tools/docs/service_matrix.yaml b/tools/docs/service_matrix.yaml index 20ecfe707b..41f131263f 100644 --- a/tools/docs/service_matrix.yaml +++ b/tools/docs/service_matrix.yaml @@ -71,14 +71,118 @@ deferred: [] # flattening the grouped or multi-table page into one generated table. The key is the # row's link target: `slug`, or `slug#anchor` for a row linking to a section of a page # that documents more than one service. A value is one switch dispatcher's path, or a -# mapping with `sources:` (paths, or `{ path, mode }` for another regen_action_docs.py -# mode) and `exclude_actions:` for labels a file carries beside its actions. -# Paths are relative to the Java package root, PACKAGE_DIR in tools/java_sources.py. +# mapping with: +# sources: paths, or `{ path, mode }` for another regen_action_docs.py mode: +# `rest` (JAX-RS methods, optionally narrowed by `route_prefix` or +# `skip_route_prefix`), `map_entries`, or `tag_handler` (a TagHandler +# class, for which the shared /tags controllers serve TagResource, +# UntagResource and ListTagsForResource) +# rename_actions: a method not named after its AWS action, or a list for a method +# serving several actions picked by a query parameter +# exclude_actions: labels or methods that are not actions of the row +# Every row of the matrix needs a generated action table, an entry here, or a +# hand_counted entry below. Paths are relative to the Java package root, PACKAGE_DIR +# in tools/java_sources.py. action_count_sources: + amazonmq: + sources: + - { path: services/amazonmq/AmazonMqController.java, mode: rest } + exclude_actions: # BadRequestException for RabbitMQ brokers, as on AWS + - CreateUser + - DescribeUser + - ListUsers + - DeleteUser + api-gateway: # v1; the same controller serves v2 under /v2/ + sources: + - { path: services/apigateway/ApiGatewayController.java, mode: rest, skip_route_prefix: /v2/ } + - { path: services/apigateway/ApiGatewayTagHandler.java, mode: tag_handler } + rename_actions: + CreateRestApi: [CreateRestApi, ImportRestApi] # mode=import + PostApiKeys: [CreateApiKey, ImportApiKeys] # mode=import + CreateV1VpcLink: CreateVpcLink + GetV1VpcLinks: GetVpcLinks + GetV1VpcLink: GetVpcLink + UpdateV1VpcLink: UpdateVpcLink + DeleteV1VpcLink: DeleteVpcLink + ListTagsForResource: GetTags + api-gateway#v2: + sources: + - { path: services/apigateway/ApiGatewayController.java, mode: rest, route_prefix: /v2/ } + - services/apigatewayv2/ApiGatewayV2JsonHandler.java + rename_actions: + CreateV2Authorizer: CreateAuthorizer + GetV2Authorizer: GetAuthorizer + GetV2Authorizers: GetAuthorizers + UpdateV2Authorizer: UpdateAuthorizer + DeleteV2Authorizer: DeleteAuthorizer + CreateV2Deployment: CreateDeployment + GetV2Deployment: GetDeployment + GetV2Deployments: GetDeployments + UpdateV2Deployment: UpdateDeployment + DeleteV2Deployment: DeleteDeployment + CreateV2DomainName: CreateDomainName + GetV2DomainName: GetDomainName + GetV2DomainNames: GetDomainNames + UpdateV2DomainName: UpdateDomainName + DeleteV2DomainName: DeleteDomainName + CreateV2Model: CreateModel + GetV2Model: GetModel + GetV2Models: GetModels + UpdateV2Model: UpdateModel + DeleteV2Model: DeleteModel + CreateV2Stage: CreateStage + GetV2Stage: GetStage + GetV2Stages: GetStages + UpdateV2Stage: UpdateStage + DeleteV2Stage: DeleteStage + UpdateV2Integration: UpdateIntegration + GetTagsForResource: GetTags + appconfig: + sources: + - { path: services/appconfig/AppConfigController.java, mode: rest } + - { path: services/appconfig/AppConfigTagHandler.java, mode: tag_handler } + appconfig#data-plane: + sources: + - { path: services/appconfig/AppConfigDataController.java, mode: rest } + appsync: + sources: + - { path: services/appsync/AppSyncController.java, mode: rest } + - { path: services/appsync/AppSyncTagHandler.java, mode: tag_handler } + rename_actions: + ListResolversByType: ListResolvers + GetEnvironmentVariables: GetGraphqlApiEnvironmentVariables + PutEnvironmentVariables: PutGraphqlApiEnvironmentVariables autoscaling: services/autoscaling/AutoScalingQueryHandler.java + backup: + sources: + - { path: services/backup/BackupController.java, mode: rest } + - { path: services/backup/BackupTagHandler.java, mode: tag_handler } + rename_actions: + ListTagsForResource: ListTags + batch: + sources: + - { path: services/batch/BatchController.java, mode: rest } + - { path: services/batch/BatchTagHandler.java, mode: tag_handler } bcm-data-exports: services/bcmdataexports/BcmDataExportsJsonHandler.java bcm-pricing-calculator: services/bcmpricingcalculator/BcmPricingCalculatorJsonHandler.java + bedrock-agentcore#data-plane-invokeagentruntime: + sources: + - { path: services/bedrockagentcore/BedrockAgentCoreController.java, mode: rest } + bedrock-runtime: + sources: + - { path: services/bedrockruntime/BedrockRuntimeController.java, mode: rest } + exclude_actions: + - InvokeModelWithResponseStream # answers 501 cloudcontrol: services/cloudcontrol/CloudControlJsonHandler.java + cloudfront: + sources: + - { path: services/cloudfront/CloudFrontController.java, mode: rest } + rename_actions: + CreateDistribution: [CreateDistribution, CreateDistributionWithTags] # WithTags + Tagging: [TagResource, UntagResource] # Operation=Tag|Untag + cloudfront#key-value-stores: # the cloudfront-keyvaluestore data plane, a client of its own + sources: + - { path: services/cloudfront/CloudFrontKeyValueStoreController.java, mode: rest } cloudmap: services/cloudmap/CloudMapHandler.java cloudwatch: services/cloudwatch/logs/CloudWatchLogsHandler.java # the CloudWatch Logs row; it routes the nested handlers by name cloudwatch#metrics: @@ -103,24 +207,197 @@ action_count_sources: - VariableCheck cognito: services/cognito/CognitoJsonHandler.java config: services/configservice/ConfigServiceJsonHandler.java + controltower: + sources: + - { path: services/controltower/ControlTowerController.java, mode: rest } + - { path: services/controltower/ControlTowerControlController.java, mode: rest } + - { path: services/controltower/ControlTowerTagHandler.java, mode: tag_handler } + rename_actions: + Enable: EnableControl + List: ListEnabledControls + Get: GetEnabledControl + Update: UpdateEnabledControl + Reset: ResetEnabledControl + Operation: GetControlOperation cur: services/cur/CurJsonHandler.java dynamodb: services/dynamodb/NativeDynamoDbJsonHandler.java dynamodb#streams: services/dynamodb/NativeDynamoDbStreamsJsonHandler.java ec2: services/ec2/Ec2QueryHandler.java ecr: services/ecr/EcrJsonHandler.java ecs: services/ecs/EcsJsonHandler.java + eks: + sources: + - { path: services/eks/EksController.java, mode: rest } + - { path: services/eks/EksService.java, mode: tag_handler } + rename_actions: + CreateNodeGroup: CreateNodegroup + DescribeNodeGroup: DescribeNodegroup + ListNodeGroups: ListNodegroups + DeleteNodeGroup: DeleteNodegroup elastic-beanstalk: services/elasticbeanstalk/ElasticBeanstalkQueryHandler.java elb: services/elbv2/ElbV2QueryHandler.java elb-classic: services/elb/ElbClassicQueryHandler.java + emr-serverless: + sources: + - { path: services/emrserverless/EmrServerlessController.java, mode: rest } + - { path: services/emrserverless/EmrServerlessTagHandler.java, mode: tag_handler } glue: services/glue/GlueJsonHandler.java + guardduty: + sources: + - { path: services/guardduty/GuardDutyController.java, mode: rest } + - { path: services/securityadmin/SecurityAdminController.java, mode: rest, route_prefix: /admin } # shared with Macie + - { path: services/guardduty/GuardDutyTagHandler.java, mode: tag_handler } + rename_actions: + ListAdmin: ListOrganizationAdminAccounts iam: services/iam/IamQueryHandler.java + iam#aws-sign-in-login-credentials: + sources: + - { path: services/signin/SigninController.java, mode: rest } + rename_actions: + Authorize: AuthorizeOAuth2Access + Token: CreateOAuth2Token + exclude_actions: # the local sign-in pages the browser flow shows + - ConsentPage + - Consent + - ConfirmationPage + iot: + sources: + - { path: services/iot/IotController.java, mode: rest } + - { path: services/iot/IotAuthorizerController.java, mode: rest } + - { path: services/iot/IotDomainConfigurationController.java, mode: rest } + - { path: services/iot/IotFleetIndexingController.java, mode: rest } + - { path: services/iot/IotTagHandler.java, mode: tag_handler } + rename_actions: + RegisterCertificateWithoutCa: RegisterCertificateWithoutCA + ListAttachedPoliciesPost: ListAttachedPolicies + ListTargetsForPolicyPost: ListTargetsForPolicy + CreateTopicRulePost: CreateTopicRule + ListJobExecutionsForThing: [ListJobExecutionsForThing, GetPendingJobExecutions] # one answer carries both + iot#iot-data: + sources: + - { path: services/iot/IotDataController.java, mode: rest } + lakeformation: + sources: + - { path: services/lakeformation/LakeFormationController.java, mode: rest } + lambda: + sources: + - { path: services/lambda/LambdaController.java, mode: rest } + - { path: services/lambda/LambdaAccountSettingsController.java, mode: rest } + - { path: services/lambda/LambdaCodeSigningController.java, mode: rest } + - { path: services/lambda/LambdaCodeSigningConfigFunctionsController.java, mode: rest } + - { path: services/lambda/LambdaConcurrencyController.java, mode: rest } + - { path: services/lambda/LambdaProvisionedConcurrencyController.java, mode: rest } + - { path: services/lambda/LambdaEventInvokeController.java, mode: rest } + - { path: services/lambda/LambdaLayerController.java, mode: rest } + - { path: services/lambda/LambdaTagController.java, mode: rest } + - { path: services/lambda/LambdaUrlController.java, mode: rest } + - { path: services/lambda/durable/DurableExecutionController.java, mode: rest } + rename_actions: + ListLayers: [ListLayers, GetLayerVersionByArn] # find=LayerVersion + Put: PutProvisionedConcurrencyConfig + Get: [GetProvisionedConcurrencyConfig, ListProvisionedConcurrencyConfigs] # List=ALL + Delete: DeleteProvisionedConcurrencyConfig + Checkpoint: CheckpointDurableExecution + GetState: GetDurableExecutionState + GetHistory: GetDurableExecutionHistory + GetExecution: GetDurableExecution + ListByFunction: ListDurableExecutionsByFunction + Stop: StopDurableExecution + CallbackSucceed: SendDurableExecutionCallbackSuccess + CallbackFail: SendDurableExecutionCallbackFailure + CallbackHeartbeat: SendDurableExecutionCallbackHeartbeat + lambda-microvms: + sources: + - { path: services/lambdamicrovms/LambdaMicrovmsController.java, mode: rest } + - { path: services/lambdamicrovms/LambdaNetworkConnectorsController.java, mode: rest } + rename_actions: + ListVersions: ListMicrovmImageVersions + GetVersion: GetMicrovmImageVersion + UpdateVersion: UpdateMicrovmImageVersion + DeleteVersion: DeleteMicrovmImageVersion + ListBuilds: ListMicrovmImageBuilds + GetBuild: GetMicrovmImageBuild + ListManagedImages: ListManagedMicrovmImages + ListManagedImageVersions: ListManagedMicrovmImageVersions lightsail: # local responses: switch arms plus the empty-list answers sources: - services/lightsail/LightsailJsonHandler.java - { path: services/lightsail/LightsailJsonHandler.java, mode: map_entries } + managed-prometheus: + sources: + - { path: services/aps/ApsController.java, mode: rest } + - { path: services/aps/ApsService.java, mode: tag_handler } + msk: + sources: + - { path: services/msk/MskController.java, mode: rest } + - { path: services/msk/MskTagHandler.java, mode: tag_handler } + mwaa: + sources: + - { path: services/mwaa/MwaaController.java, mode: rest } + - { path: services/mwaa/MwaaService.java, mode: tag_handler } + oam: + sources: + - { path: services/oam/OamController.java, mode: rest } + rename_actions: + ListTags: ListTagsForResource + Tag: TagResource + Untag: UntagResource + opensearch: # with the legacy Elasticsearch API at /2015-01-01/es + sources: + - { path: services/opensearch/OpenSearchController.java, mode: rest } + - { path: services/opensearch/ElasticsearchController.java, mode: rest } + pipes: + sources: + - { path: services/pipes/PipesController.java, mode: rest } + - { path: services/pipes/PipesService.java, mode: tag_handler } pricing: services/pricing/PricingJsonHandler.java + rds-data: + sources: + - { path: services/rdsdata/RdsDataController.java, mode: rest } + exclude_actions: + - ExecuteSql # answers BadRequestException, not supported resource-groups-tagging: services/resourcegroupstagging/ResourceGroupsTaggingJsonHandler.java + rum: + sources: + - { path: services/rum/RumController.java, mode: rest } + s3tables: + sources: + - { path: services/s3tables/S3TablesController.java, mode: rest } + s3vectors: + sources: + - { path: services/s3vectors/S3VectorsController.java, mode: rest } + sagemaker#endpoint-hosting: + sources: + - { path: services/sagemaker/SageMakerRuntimeController.java, mode: rest } + rename_actions: + Invoke: InvokeEndpoint + scheduler: + sources: + - { path: services/scheduler/SchedulerController.java, mode: rest } + - { path: services/scheduler/SchedulerTagHandler.java, mode: tag_handler } ses: services/ses/SesQueryHandler.java + ses#v2: + sources: + - { path: services/ses/SesAccountController.java, mode: rest } + - { path: services/ses/SesConfigurationSetController.java, mode: rest } + - { path: services/ses/SesContactController.java, mode: rest } + - { path: services/ses/SesCvetController.java, mode: rest } + - { path: services/ses/SesDedicatedIpController.java, mode: rest } + - { path: services/ses/SesExportJobController.java, mode: rest } + - { path: services/ses/SesIdentityController.java, mode: rest } + - { path: services/ses/SesImportJobController.java, mode: rest } + - { path: services/ses/SesInsightsController.java, mode: rest } + - { path: services/ses/SesMetricsController.java, mode: rest } + - { path: services/ses/SesRecommendationController.java, mode: rest } + - { path: services/ses/SesReputationEntityController.java, mode: rest } + - { path: services/ses/SesSendController.java, mode: rest } + - { path: services/ses/SesSuppressionController.java, mode: rest } + - { path: services/ses/SesTagController.java, mode: rest } + - { path: services/ses/SesTemplateController.java, mode: rest } + - { path: services/ses/SesTenantController.java, mode: rest } + rename_actions: + ListConfigurationSetsWithFilter: ListConfigurationSets + ListEmailIdentitiesWithFilter: ListEmailIdentities sns: sources: - services/sns/SnsJsonHandler.java @@ -134,6 +411,11 @@ action_count_sources: transcribe: services/transcribe/TranscribeJsonHandler.java transfer: services/transfer/TransferHandler.java +# Rows whose count cannot be derived from their dispatchers, each with the reason. These +# are the only counts still kept by hand. +hand_counted: + s3: one controller method answers many operations, picked by query-string subresources (?tagging, ?acl, ?versioning, ...) + # docs/services pages that intentionally have no Service Matrix row of their own. facet_pages: - cloudfront-private-origin diff --git a/tools/docs/test_check_service_matrix.py b/tools/docs/test_check_service_matrix.py index 9e1d923edf..4ae11f6727 100644 --- a/tools/docs/test_check_service_matrix.py +++ b/tools/docs/test_check_service_matrix.py @@ -218,23 +218,20 @@ def test_non_tabular_action_sources_cannot_be_disabled(tmp_path, source_entry): c.extract_action_counts(root) -def test_non_tabular_action_source_cannot_be_removed_silently(tmp_path): +def test_removing_a_rows_source_leaves_it_checked_by_nothing(tmp_path): root = _repo( tmp_path, ["| [Glue](glue.md) | Query | JSON | 2 |", "| [EC2](ec2.md) | Query | Query | 1 |"], - "action_count_sources:\n glue: services/GlueJsonHandler.java\n" - " ec2: services/Ec2QueryHandler.java\n", - { - "services/GlueJsonHandler.java": 'case "CreateTable" -> create();\ncase "GetTable" -> get();\n', - "services/Ec2QueryHandler.java": 'case "DescribeInstances" -> describe();\n', - }, + "action_count_sources:\n glue: services/GlueJsonHandler.java\n", + {"services/GlueJsonHandler.java": 'case "CreateTable" -> create();\ncase "GetTable" -> get();\n'}, ) + md = (root / c.MATRIX_DOC).read_text(encoding="utf-8") - required = frozenset({"glue", "ec2"}) - assert c.extract_action_counts(root, required) == {"glue": 2, "ec2": 1} - (root / c.REGISTRY).write_text("action_count_sources:\n glue: services/GlueJsonHandler.java\n", encoding="utf-8") - with pytest.raises(ValueError, match="required action count source\\(s\\) missing: ec2"): - c.extract_action_counts(root, required) + warnings = c.find_unchecked_rows(c.extract_matrix_row_keys(md), c.extract_matrix_action_counts(md), + set(c.extract_action_counts(root)), {}) + + assert len(warnings) == 1 + assert "nothing checks the count of row 'ec2'" in warnings[0] def test_an_anchored_row_is_counted_from_its_own_dispatcher(tmp_path): @@ -324,6 +321,9 @@ def test_a_source_without_actions_fails_rather_than_lowering_the_count(tmp_path) ("{ sources: [services/SnsJsonHandler.java], exclude_actions: Publish }", "exclude_actions as a list"), ("[services/SnsJsonHandler.java]", "needs a source path"), ("{ sources: [{ path: services/SnsJsonHandler.java, mode: rst }] }", "'sns' unknown mode: 'rst'"), + ("{ sources: [{ path: services/SnsJsonHandler.java, mode: rest, prefix: /v2/ }] }", + "a source with unknown key\\(s\\): prefix"), + ("{ sources: [services/SnsJsonHandler.java], rename_actions: [Publish] }", "rename_actions as a mapping"), ]) def test_a_malformed_source_entry_is_refused(tmp_path, entry, message): root = _repo( @@ -337,11 +337,140 @@ def test_a_malformed_source_entry_is_refused(tmp_path, entry, message): c.extract_action_counts(root) -def test_the_registry_checks_every_row_a_dispatcher_counts(): +def test_every_row_of_the_real_matrix_is_checked_or_hand_counted(): root = c._repo_root() - counts = c.extract_action_counts(root, c.REQUIRED_ACTION_COUNT_SOURCES) + md = (root / c.MATRIX_DOC).read_text(encoding="utf-8") + + assert c.find_unchecked_rows(c.extract_matrix_row_keys(md), c.extract_matrix_action_counts(md), + set(c.extract_action_counts(root)), c.load_hand_counted(root)) == [] + + +# --------------------------------------------------------------------------- # +# Coverage: every row checked or hand-counted +# --------------------------------------------------------------------------- # +def test_a_formatted_first_cell_link_still_makes_a_row(): + # Presence and coverage read the same rows, so a bold link cannot count as documented + # while escaping the count checks. + md = "## Service Matrix\n\n| **[Glue](glue.md)** | ... | JSON 1.1 | 2 |\n\n## Common Setup\n" + + assert c.extract_matrix_row_keys(md) == ["glue"] + assert c.extract_matrix_slugs(md) == {"glue"} + assert c.extract_matrix_action_counts(md) == {"glue": 2} + + +def test_a_row_linking_no_page_is_refused(): + md = ( + "## Service Matrix\n\n| Service | Endpoint | Protocol | Supported operations |\n|---|---|---|---|\n" + "| Glue | ... | JSON 1.1 | 2 |\n\n## Common Setup\n" + ) + + with pytest.raises(ValueError, match="row 'Glue' links no docs/services page"): + c.extract_matrix_row_keys(md) + + +def test_extract_matrix_row_keys_keeps_rows_without_a_count(): + md = ( + "## Service Matrix\n\n" + "| [S3](s3.md) | ... | REST XML | 58 |\n" + "| [API Gateway v2](api-gateway.md#v2) | ... | REST JSON | 53 + data-plane |\n" + "| [IoT Data](iot.md) | ... | REST JSON | 11 |\n" + "\n## Common Setup\n" + ) + + assert c.extract_matrix_row_keys(md) == ["s3", "api-gateway#v2", "iot"] + + +def test_an_unchecked_row_needs_a_source_or_a_hand_counted_reason(): + keys = ["s3", "glue"] + counts = {"s3": 58, "glue": 2} + + assert len(c.find_unchecked_rows(keys, counts, {"glue"}, {})) == 1 + assert c.find_unchecked_rows(keys, counts, {"glue"}, {"s3": "query-string subresources"}) == [] + + +def test_a_checked_row_cannot_also_be_hand_counted(): + warnings = c.find_unchecked_rows(["glue"], {"glue": 2}, {"glue"}, {"glue": "why"}) + + assert warnings == [f"row 'glue' is checked, so drop it from hand_counted in {c.REGISTRY}"] + + +def test_a_hand_counted_entry_must_name_a_row(): + warnings = c.find_unchecked_rows(["glue"], {"glue": 2}, {"glue"}, {"s3": "why"}) + + assert warnings == [f"hand_counted row 's3' in {c.REGISTRY} is not a row of {c.MATRIX_DOC}"] + + +def test_two_rows_on_one_link_target_are_refused(): + # IoT Core and IoT Data both linked iot.md; the second row's count was never read. + warnings = c.find_unchecked_rows(["iot", "iot"], {"iot": 83}, {"iot"}, {}) + + assert len(warnings) == 1 + assert "two rows" in warnings[0] and "'iot'" in warnings[0] + + +def test_a_row_without_a_numeric_count_is_refused(): + warnings = c.find_unchecked_rows(["api-gateway#v2"], {}, set(), {}) + + assert warnings == [f"row 'api-gateway#v2' in {c.MATRIX_DOC} has no numeric operation count"] + + +@pytest.mark.parametrize("entry", ["[s3]", "{ s3: '' }", "{ s3: 3 }"]) +def test_a_hand_counted_row_needs_its_reason(tmp_path, entry): + root = _repo(tmp_path, ["| [S3](s3.md) | ... | REST XML | 58 |"], f"hand_counted: {entry}\n") + + with pytest.raises(ValueError, match="hand_counted"): + c.load_hand_counted(root) + + +def test_route_prefixes_split_one_controller_between_two_rows(tmp_path): + # API Gateway serves v1 and, under /v2/, v2 from the same controller. + controller = ( + '@Path("/")\npublic class ApiGatewayController {\n' + ' @POST\n @Path("/restapis")\n public Response createRestApi() { return null; }\n' + ' @POST\n @Path("/v2/apis")\n public Response createApi() { return null; }\n' + ' @GET\n @Path("/v2/apis")\n public Response getApis() { return null; }\n' + '}\n' + ) + root = _repo( + tmp_path, + ["| [API Gateway v1](api-gateway.md) | ... | REST JSON | 1 |", + "| [API Gateway v2](api-gateway.md#v2) | ... | REST JSON | 2 |"], + "action_count_sources:\n" + " api-gateway:\n sources:\n" + " - { path: services/ApiGatewayController.java, mode: rest, skip_route_prefix: /v2/ }\n" + " api-gateway#v2:\n sources:\n" + " - { path: services/ApiGatewayController.java, mode: rest, route_prefix: /v2/ }\n", + {"services/ApiGatewayController.java": controller}, + ) + + assert c.extract_action_counts(root) == {"api-gateway": 1, "api-gateway#v2": 2} + + +def test_renames_and_tag_handlers_count_the_actions_a_row_serves(tmp_path): + controller = ( + '@Path("/")\npublic class EksController {\n' + ' @POST\n @Path("/clusters/{name}/node-groups")\n public Response createNodeGroup() { return null; }\n' + ' @GET\n @Path("/clusters/{name}/provisioned")\n public Response get() { return null; }\n' + '}\n' + ) + root = _repo( + tmp_path, + ["| [EKS](eks.md) | ... | REST JSON | 6 |"], + "action_count_sources:\n eks:\n sources:\n" + " - { path: services/EksController.java, mode: rest }\n" + " - { path: services/EksService.java, mode: tag_handler }\n" + " rename_actions:\n" + " CreateNodeGroup: CreateNodegroup\n" + " Get: [GetThing, ListThings]\n", + { + "services/EksController.java": controller, + "services/EksService.java": "public class EksService implements Startable, TagHandler {\n}\n", + }, + ) + + assert c.extract_action_counts(root) == {"eks": 6} + - assert c.REQUIRED_ACTION_COUNT_SOURCES <= counts.keys() def test_extract_matrix_slugs_raises_on_missing_heading(): diff --git a/tools/docs/test_regen_action_docs.py b/tools/docs/test_regen_action_docs.py index 66e04439e4..20f687903b 100644 --- a/tools/docs/test_regen_action_docs.py +++ b/tools/docs/test_regen_action_docs.py @@ -182,6 +182,70 @@ def test_extract_actions_dedupes_across_sources(tmp_path: Path): assert r.extract_actions(entry) == ["Foo", "Bar", "Baz"] +ROUTED_CONTROLLER = """ +@Path("/2015-03-31") +public class FunctionsController { + @GET + @Path("/functions") + public Response listFunctions() { return ok(); } + + @Path("/v2/functions/{name}") + @DELETE + public Response deleteV2Function() { return ok(); } + + @POST @Path("/v2/functions") + public Response createV2Function() { return ok(); } + + @Path("/locator") + public Object helper() { return this; } + + @PUT + public Response putRoot() { return ok(); } +} +""" + + +def test_extract_rest_routes_join_the_class_and_method_paths(): + # @Path before or after the verb, or on the verb's own line; a method without one + # takes the class path, and a sub-resource locator's @Path is not carried over. + assert r._extract_raw_rest_routes(ROUTED_CONTROLLER) == [ + ("ListFunctions", "/2015-03-31/functions"), + ("DeleteV2Function", "/2015-03-31/v2/functions/{name}"), + ("CreateV2Function", "/2015-03-31/v2/functions"), + ("PutRoot", "/2015-03-31"), + ] + + +def test_extract_rest_actions_filters_by_route_prefix(): + assert r.extract_rest_actions(ROUTED_CONTROLLER, route_prefix="/2015-03-31/v2/") == [ + "DeleteV2Function", "CreateV2Function"] + assert r.extract_rest_actions(ROUTED_CONTROLLER, skip_route_prefix="/2015-03-31/v2/") == [ + "ListFunctions", "PutRoot"] + + +@pytest.mark.parametrize("declaration,expected", [ + ("public class BatchTagHandler implements TagHandler {", list(r.TAG_HANDLER_ACTIONS)), + ("public class EksService implements Startable,\n TagHandler {", list(r.TAG_HANDLER_ACTIONS)), + ("public class EksService implements Startable {\n private TagHandler tags;", []), + # Lambda and CloudWatch Logs tag through routes of their own, so /tags never serves them. + ("@ApplicationScoped\n@TaggingApiOnly\npublic class LambdaTagHandler implements TagHandler {", []), +]) +def test_extract_tag_handler_actions(declaration, expected): + assert r.extract_tag_handler_actions(declaration) == expected + + +def test_a_rename_to_a_list_stands_for_each_action(tmp_path: Path): + src = tmp_path / "LayerController.java" + src.write_text('@Path("/")\npublic class LayerController {\n @GET\n public Response listLayers() { return ok(); }\n}\n') + entry = r.ServiceEntry( + service="lambda", + doc=tmp_path / "lambda.md", + sources=[r.Source(path=src, mode="rest")], + rename_actions={"ListLayers": ["ListLayers", "GetLayerVersionByArn"]}, + ) + assert r.extract_actions(entry) == ["ListLayers", "GetLayerVersionByArn"] + + def test_extract_map_entry_keys(): src = """ private static final Map EMPTY_LIST_RESULTS = Map.ofEntries(