1
以下代碼將在AWS API網關中創建一個新的API密鑰。爲了好玩,我還得到了一個名爲「Basic」的現有使用計劃,其ID爲「1234」AWS Api網關JAVA SDK向API密鑰添加使用計劃
對於我的生活,我找不到如何使用我新創建的API密鑰並添加現有用法計劃。這可以通過「添加到使用計劃」按鈕在Web門戶網站上手動完成,但我想將我的新用戶添加到免費計劃中。
BasicAWSCredentials awsCreds = new BasicAWSCredentials(aws_id, aws_key);
apiGateway = AmazonApiGatewayClientBuilder.standard()
.withCredentials(new AWSStaticCredentialsProvider(awsCreds))
.withRegion(Regions.US_EAST_1).build();
CreateApiKeyRequest createApiKeyRequest = new CreateApiKeyRequest();
createApiKeyRequest.setName("awesome company);
createApiKeyRequest.setEnabled(true);
createApiKeyRequest.setCustomerId("someid");
CreateApiKeyResult result = apiGateway.createApiKey(createApiKeyRequest);
GetUsagePlanRequest getUsagePlanRequest = new GetUsagePlanRequest();
getUsagePlanRequest.setUsagePlanId("1234");
GetUsagePlanResult getUsagePlanResult = apiGateway.getUsagePlan(getUsagePlanRequest);
任何AWS開發工具包專家都知道如何將使用計劃連接到API密鑰?