-
Notifications
You must be signed in to change notification settings - Fork 638
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add annotations to deprecated services and introduce codegen integrat…
…ion for offboarding services at large (#2824)
- Loading branch information
Showing
5 changed files
with
56 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
] | ||
} |
42 changes: 42 additions & 0 deletions
42
...n/src/main/java/software/amazon/smithy/aws/go/codegen/customization/DeprecateService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<String> 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(); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.