简体   繁体   中英

How to set CloudWatch Settings for AWS APIGateway Stage

in AWS ApiGateway, after using the JAVA api to deploy a new stage, how can I enable the CloudWatch Settings with Java API rather than through aws console?

For the create-stage , I can get the CloudWatch settings in the MethodSetting under the CreateStage output, but I cannot set the settings when I create the stage or create deployment.

You should be able to update the CloudWatch settings for your stage with a patch request to the update-stage operation

Here's a sample code snippet (I haven't actually tested this; but the basic principal should work):

AmazonApiGateway apiGateway = ...;
UpdateStageRequest req = new UpdateStageRequest().withRestApiId(<api-id>).
            withStageName(<stage-name>).
            withPatchOperations(
                new PatchOperation().withPath("*/*/metrics/enabled")
                                    .withOp("replace")
                                    .withValue("true"));

apiGateway.upate(req);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM