Java 类com.amazonaws.services.apigateway.AmazonApiGateway 实例源码

项目:aws-maven-plugin    文件:ApiGatewayDeployer.java   
public void deploy(AwsKeyPair keyPair, String region, final String restApiName, final String stage, Proxy proxy) {
    final AWSCredentialsProvider credentials = new AWSStaticCredentialsProvider(
            new BasicAWSCredentials(keyPair.key, keyPair.secret));

    ClientConfiguration cc = Util.createConfiguration(proxy);

    AmazonApiGateway ag = AmazonApiGatewayClientBuilder.standard().withCredentials(credentials) //
            .withClientConfiguration(cc) //
            .withRegion(region) //
            .build();
    GetRestApisResult apis = ag.getRestApis(new GetRestApisRequest().withLimit(10000));
    Optional<RestApi> api = apis.getItems().stream().filter(item -> item.getName().equals(restApiName)).findFirst();
    RestApi a = api.orElseThrow(() -> new RuntimeException("no rest api found with name='" + restApiName + "'"));
    String restApiId = a.getId();
    log.info("creating deployment of " + restApiId + " to stage " + stage);
    CreateDeploymentResult r = ag
            .createDeployment(new CreateDeploymentRequest().withRestApiId(restApiId).withStageName(stage));
    Map<String, Map<String, MethodSnapshot>> summary = r.getApiSummary();
    log.info("created deployment");
    log.info("summary=" + summary);
}
项目:Sqawsh    文件:ApiGatewayCustomResourceLambda.java   
CreateResourceResult createTopLevelResourceOnApi(String resourceName, String restApiId,
    AmazonApiGateway client, LambdaLogger logger) {
  logger.log("Creating top-level resource: " + resourceName);
  // Short sleep - this avoids the Too Many Requests error in this
  // custom resource when creating the cloudformation stack.
  pause(logger);
  CreateResourceRequest createResourceRequest = new CreateResourceRequest();
  createResourceRequest.setRestApiId(restApiId);
  if (resourceName.equals("bookings")) {
    createResourceRequest.setPathPart("bookings");
  } else if (resourceName.equals("bookingrules")) {
    createResourceRequest.setPathPart("bookingrules");
  } else if (resourceName.equals("validdates")) {
    createResourceRequest.setPathPart("validdates");
  } else if (resourceName.equals("reservationform")) {
    createResourceRequest.setPathPart("reservationform");
  } else if (resourceName.equals("cancellationform")) {
    createResourceRequest.setPathPart("cancellationform");
  } else {
    throw new InvalidParameterException("Invalid resource name: " + resourceName);
  }

  // Get the id of the parent resource
  GetResourcesRequest getResourcesRequest = new GetResourcesRequest();
  // High enough limit for now
  getResourcesRequest.setLimit(10);
  getResourcesRequest.setRestApiId(restApiId);
  GetResourcesResult resourcesResult = client.getResources(getResourcesRequest);
  String rootResourceId = resourcesResult.getItems().stream()
      .filter(resource -> resource.getPath().equals("/")).findFirst().get().getId();
  logger.log("Parent(root) resource id: " + rootResourceId);
  createResourceRequest.setParentId(rootResourceId);

  return client.createResource(createResourceRequest);
}
项目:lambadaframework    文件:ApiGateway.java   
protected AmazonApiGateway getApiGatewayClient() {
    if (apiGatewayClient != null) {
        return apiGatewayClient;
    }

    RetryPolicy.RetryCondition retryCondition = new RetryPolicy.RetryCondition() {

        @Override
        public boolean shouldRetry(AmazonWebServiceRequest amazonWebServiceRequest, AmazonClientException amazonClientException, int i) {
            if (amazonClientException instanceof TooManyRequestsException) {
                return true;
            }
            return PredefinedRetryPolicies.DEFAULT_RETRY_CONDITION.shouldRetry(amazonWebServiceRequest,
                    amazonClientException, i);
        }
    };

    RetryPolicy retryPolicy = new RetryPolicy(retryCondition,
            PredefinedRetryPolicies.DEFAULT_BACKOFF_STRATEGY,
            10, true);

    ClientConfiguration clientConfig = new ClientConfiguration()
            .withRetryPolicy(retryPolicy);

    apiGatewayClient = new AmazonApiGatewayClient(getAWSCredentialsProvideChain(), clientConfig).withRegion(Region.getRegion(Regions.fromName(deployment.getRegion())));
    return apiGatewayClient;
}
项目:aws-apigateway-importer    文件:ApiImporterDefaultModule.java   
@Provides
protected ApiGateway provideAmazonApiGateway(AWSCredentialsProvider credsProvider,
                                             RetryPolicy.BackoffStrategy backoffStrategy,
                                             @Named("region") String region) {

    final RetryPolicy retrypolicy = new RetryPolicy(PredefinedRetryPolicies.DEFAULT_RETRY_CONDITION, backoffStrategy, 5, true);

    final ClientConfiguration clientConfig = new ClientConfiguration().withUserAgent(USER_AGENT).withRetryPolicy(retrypolicy);

    return new AmazonApiGateway(getEndpoint(region)).with(credsProvider).with(clientConfig).getApiGateway();
}
项目:aws-api-gateway    文件:ApiImporterDefaultModule.java   
@Provides
protected ApiGateway provideAmazonApiGateway(AWSCredentialsProvider credsProvider,
                                             RetryPolicy.BackoffStrategy backoffStrategy,
                                             @Named("region") String region) {

    final RetryPolicy retrypolicy = new RetryPolicy(PredefinedRetryPolicies.DEFAULT_RETRY_CONDITION, backoffStrategy, 5, true);

    final ClientConfiguration clientConfig = new ClientConfiguration().withUserAgent(USER_AGENT).withRetryPolicy(retrypolicy);

    return new AmazonApiGateway(getEndpoint(region)).with(credsProvider).with(clientConfig).getApiGateway();
}