Skip to content

Commit 183987c

Browse files
authored
add annotations to deprecated services and introduce codegen integration for offboarding services at large (#2824)
1 parent b737dc9 commit 183987c

File tree

5 files changed

+56
-0
lines changed

5 files changed

+56
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"id": "a3b1dd91-e03f-4540-b760-1093acd4e231",
3+
"type": "documentation",
4+
"description": "Doc-only update to generate deprecated annotation for services that have been marked as deprecated.",
5+
"modules": [
6+
"service/chime",
7+
"service/sms"
8+
]
9+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package software.amazon.smithy.aws.go.codegen.customization;
2+
3+
import software.amazon.smithy.go.codegen.GoSettings;
4+
import software.amazon.smithy.go.codegen.integration.GoIntegration;
5+
import software.amazon.smithy.model.Model;
6+
import software.amazon.smithy.model.shapes.Shape;
7+
import software.amazon.smithy.model.traits.DeprecatedTrait;
8+
import software.amazon.smithy.model.transform.ModelTransformer;
9+
10+
import java.util.Set;
11+
12+
/**
13+
* Deprecates an entire service by applying @deprecated to every shape. This will reflect in IDEs and public package
14+
* documentation.
15+
*/
16+
public class DeprecateService implements GoIntegration {
17+
private static final String DEPRECATION_MESSAGE =
18+
"AWS has deprecated this service. It is no longer available for use.";
19+
private static final Set<String> DEPRECATED = Set.of(
20+
);
21+
22+
@Override
23+
public Model preprocessModel(Model model, GoSettings settings) {
24+
var service = settings.getService(model);
25+
if (!DEPRECATED.contains(service.getId().toString())) {
26+
return model;
27+
}
28+
29+
return ModelTransformer.create().mapShapes(model, shape -> {
30+
if (shape.isMemberShape()) {
31+
return shape;
32+
}
33+
34+
var deprecated = DeprecatedTrait.builder()
35+
.message(DEPRECATION_MESSAGE)
36+
.build();
37+
return Shape.shapeToBuilder(shape)
38+
.addTrait(deprecated)
39+
.build();
40+
});
41+
}
42+
}

‎codegen/smithy-aws-go-codegen/src/main/resources/META-INF/services/software.amazon.smithy.go.codegen.integration.GoIntegration

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,3 +85,4 @@ software.amazon.smithy.aws.go.codegen.customization.RetryModeUserAgent
8585
software.amazon.smithy.aws.go.codegen.customization.RequestCompressionUserAgent
8686
software.amazon.smithy.aws.go.codegen.customization.s3.ExpressUserAgent
8787
software.amazon.smithy.aws.go.codegen.customization.BackfillRequiredTrait
88+
software.amazon.smithy.aws.go.codegen.customization.DeprecateService

‎service/chime/doc.go

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎service/sms/doc.go

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)