From 183987cda0c2487a1b25c8e9cbf8dba510046c73 Mon Sep 17 00:00:00 2001 From: Luc Talatinian <102624213+lucix-aws@users.noreply.github.com> Date: Tue, 8 Oct 2024 11:31:10 -0400 Subject: [PATCH] add annotations to deprecated services and introduce codegen integration for offboarding services at large (#2824) --- .../a3b1dd91e03f4540b7601093acd4e231.json | 9 ++++ .../customization/DeprecateService.java | 42 +++++++++++++++++++ ...mithy.go.codegen.integration.GoIntegration | 1 + service/chime/doc.go | 2 + service/sms/doc.go | 2 + 5 files changed, 56 insertions(+) create mode 100644 .changelog/a3b1dd91e03f4540b7601093acd4e231.json create mode 100644 codegen/smithy-aws-go-codegen/src/main/java/software/amazon/smithy/aws/go/codegen/customization/DeprecateService.java diff --git a/.changelog/a3b1dd91e03f4540b7601093acd4e231.json b/.changelog/a3b1dd91e03f4540b7601093acd4e231.json new file mode 100644 index 00000000000..207ac1eee86 --- /dev/null +++ b/.changelog/a3b1dd91e03f4540b7601093acd4e231.json @@ -0,0 +1,9 @@ +{ + "id": "a3b1dd91-e03f-4540-b760-1093acd4e231", + "type": "documentation", + "description": "Doc-only update to generate deprecated annotation for services that have been marked as deprecated.", + "modules": [ + "service/chime", + "service/sms" + ] +} \ No newline at end of file diff --git a/codegen/smithy-aws-go-codegen/src/main/java/software/amazon/smithy/aws/go/codegen/customization/DeprecateService.java b/codegen/smithy-aws-go-codegen/src/main/java/software/amazon/smithy/aws/go/codegen/customization/DeprecateService.java new file mode 100644 index 00000000000..18fe911497b --- /dev/null +++ b/codegen/smithy-aws-go-codegen/src/main/java/software/amazon/smithy/aws/go/codegen/customization/DeprecateService.java @@ -0,0 +1,42 @@ +package software.amazon.smithy.aws.go.codegen.customization; + +import software.amazon.smithy.go.codegen.GoSettings; +import software.amazon.smithy.go.codegen.integration.GoIntegration; +import software.amazon.smithy.model.Model; +import software.amazon.smithy.model.shapes.Shape; +import software.amazon.smithy.model.traits.DeprecatedTrait; +import software.amazon.smithy.model.transform.ModelTransformer; + +import java.util.Set; + +/** + * Deprecates an entire service by applying @deprecated to every shape. This will reflect in IDEs and public package + * documentation. + */ +public class DeprecateService implements GoIntegration { + private static final String DEPRECATION_MESSAGE = + "AWS has deprecated this service. It is no longer available for use."; + private static final Set DEPRECATED = Set.of( + ); + + @Override + public Model preprocessModel(Model model, GoSettings settings) { + var service = settings.getService(model); + if (!DEPRECATED.contains(service.getId().toString())) { + return model; + } + + return ModelTransformer.create().mapShapes(model, shape -> { + if (shape.isMemberShape()) { + return shape; + } + + var deprecated = DeprecatedTrait.builder() + .message(DEPRECATION_MESSAGE) + .build(); + return Shape.shapeToBuilder(shape) + .addTrait(deprecated) + .build(); + }); + } +} diff --git a/codegen/smithy-aws-go-codegen/src/main/resources/META-INF/services/software.amazon.smithy.go.codegen.integration.GoIntegration b/codegen/smithy-aws-go-codegen/src/main/resources/META-INF/services/software.amazon.smithy.go.codegen.integration.GoIntegration index 90f15c70e4c..b4f24f9552b 100644 --- a/codegen/smithy-aws-go-codegen/src/main/resources/META-INF/services/software.amazon.smithy.go.codegen.integration.GoIntegration +++ b/codegen/smithy-aws-go-codegen/src/main/resources/META-INF/services/software.amazon.smithy.go.codegen.integration.GoIntegration @@ -85,3 +85,4 @@ software.amazon.smithy.aws.go.codegen.customization.RetryModeUserAgent software.amazon.smithy.aws.go.codegen.customization.RequestCompressionUserAgent software.amazon.smithy.aws.go.codegen.customization.s3.ExpressUserAgent software.amazon.smithy.aws.go.codegen.customization.BackfillRequiredTrait +software.amazon.smithy.aws.go.codegen.customization.DeprecateService diff --git a/service/chime/doc.go b/service/chime/doc.go index 0f2914c904f..20ddf4593ad 100644 --- a/service/chime/doc.go +++ b/service/chime/doc.go @@ -42,6 +42,8 @@ // Management (IAM). For more information, see [Identity and Access Management for Amazon Chime]in the Amazon Chime Administration // Guide. // +// Deprecated: This namespace has been deprecated +// // [Identity and Access Management for Amazon Chime]: https://docs.aws.amazon.com/chime/latest/ag/security-iam.html // [Migrating from the Amazon Chime namespace]: https://docs.aws.amazon.com/chime-sdk/latest/dg/migrate-from-chm-namespace.html // [Installing the AWS Command Line Interface]: https://docs.aws.amazon.com/cli/latest/userguide/installing.html diff --git a/service/sms/doc.go b/service/sms/doc.go index d3a780c62d1..cae4ae9cc8c 100644 --- a/service/sms/doc.go +++ b/service/sms/doc.go @@ -18,6 +18,8 @@ // // [Server Migration Service User Guide] // +// Deprecated: AWS Server Migration Service is Deprecated. +// // [Server Migration Service User Guide]: https://docs.aws.amazon.com/server-migration-service/latest/userguide/ // [Amazon Web Services Application Migration Service]: http://aws.amazon.com/application-migration-service // [Server Migration Service product page]: http://aws.amazon.com/server-migration-service/