0
votes

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.

1

1 Answers

1
votes

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);