com.amazonaws.protocol.json.JsonOperationMetadata Java Examples

The following examples show how to use com.amazonaws.protocol.json.JsonOperationMetadata. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AWSServerlessApplicationRepositoryClient.java    From realworld-serverless-application with Apache License 2.0 6 votes vote down vote up
/**
 * @param createApplicationRequest
 * @return Result of the CreateApplication operation returned by the service.
 * @throws TooManyRequestsException
 * @throws BadRequestException
 * @throws UnauthorizedException
 * @throws InternalServerErrorException
 * @throws ConflictException
 * @sample AWSServerlessApplicationRepository.CreateApplication
 * @see <a href="http://docs.aws.amazon.com/goto/WebAPI/xxx-2019-10-13/CreateApplication"
 *      target="_top">AWS API Documentation</a>
 */
@Override
public CreateApplicationResult createApplication(CreateApplicationRequest createApplicationRequest) {
  HttpResponseHandler<CreateApplicationResult> responseHandler = protocolFactory.createResponseHandler(new JsonOperationMetadata().withPayloadJson(true)
          .withHasStreamingSuccessResponse(false), new CreateApplicationResultJsonUnmarshaller());

  HttpResponseHandler<SdkBaseException> errorResponseHandler = createErrorResponseHandler(
          new JsonErrorShapeMetadata().withModeledClass(TooManyRequestsException.class).withHttpStatusCode(429), new JsonErrorShapeMetadata()
                  .withModeledClass(BadRequestException.class).withHttpStatusCode(400),
          new JsonErrorShapeMetadata().withModeledClass(UnauthorizedException.class).withHttpStatusCode(401), new JsonErrorShapeMetadata()
                  .withModeledClass(InternalServerErrorException.class).withHttpStatusCode(500),
          new JsonErrorShapeMetadata().withModeledClass(ConflictException.class).withHttpStatusCode(409));

  return clientHandler.execute(new ClientExecutionParams<CreateApplicationRequest, CreateApplicationResult>()
          .withMarshaller(new CreateApplicationRequestProtocolMarshaller(protocolFactory)).withResponseHandler(responseHandler)
          .withErrorResponseHandler(errorResponseHandler).withInput(createApplicationRequest));
}
 
Example #2
Source File: AWSServerlessApplicationRepositoryClient.java    From realworld-serverless-application with Apache License 2.0 6 votes vote down vote up
/**
 * @param deleteApplicationRequest
 * @return Result of the DeleteApplication operation returned by the service.
 * @throws NotFoundException
 * @throws TooManyRequestsException
 * @throws BadRequestException
 * @throws UnauthorizedException
 * @throws InternalServerErrorException
 * @sample AWSServerlessApplicationRepository.DeleteApplication
 * @see <a href="http://docs.aws.amazon.com/goto/WebAPI/xxx-2019-10-13/DeleteApplication"
 *      target="_top">AWS API Documentation</a>
 */
@Override
public DeleteApplicationResult deleteApplication(DeleteApplicationRequest deleteApplicationRequest) {
  HttpResponseHandler<DeleteApplicationResult> responseHandler = protocolFactory.createResponseHandler(new JsonOperationMetadata().withPayloadJson(true)
          .withHasStreamingSuccessResponse(false), new DeleteApplicationResultJsonUnmarshaller());

  HttpResponseHandler<SdkBaseException> errorResponseHandler = createErrorResponseHandler(
          new JsonErrorShapeMetadata().withModeledClass(NotFoundException.class).withHttpStatusCode(404),
          new JsonErrorShapeMetadata().withModeledClass(TooManyRequestsException.class).withHttpStatusCode(429), new JsonErrorShapeMetadata()
                  .withModeledClass(BadRequestException.class).withHttpStatusCode(400),
          new JsonErrorShapeMetadata().withModeledClass(UnauthorizedException.class).withHttpStatusCode(401), new JsonErrorShapeMetadata()
                  .withModeledClass(InternalServerErrorException.class).withHttpStatusCode(500));

  return clientHandler.execute(new ClientExecutionParams<DeleteApplicationRequest, DeleteApplicationResult>()
          .withMarshaller(new DeleteApplicationRequestProtocolMarshaller(protocolFactory)).withResponseHandler(responseHandler)
          .withErrorResponseHandler(errorResponseHandler).withInput(deleteApplicationRequest));
}
 
Example #3
Source File: AWSServerlessApplicationRepositoryClient.java    From realworld-serverless-application with Apache License 2.0 6 votes vote down vote up
/**
 * @param getApplicationRequest
 * @return Result of the GetApplication operation returned by the service.
 * @throws NotFoundException
 * @throws TooManyRequestsException
 * @throws BadRequestException
 * @throws UnauthorizedException
 * @throws InternalServerErrorException
 * @sample AWSServerlessApplicationRepository.GetApplication
 * @see <a href="http://docs.aws.amazon.com/goto/WebAPI/xxx-2019-10-13/GetApplication" target="_top">AWS
 *      API Documentation</a>
 */
@Override
public GetApplicationResult getApplication(GetApplicationRequest getApplicationRequest) {
  HttpResponseHandler<GetApplicationResult> responseHandler = protocolFactory.createResponseHandler(new JsonOperationMetadata().withPayloadJson(true)
          .withHasStreamingSuccessResponse(false), new GetApplicationResultJsonUnmarshaller());

  HttpResponseHandler<SdkBaseException> errorResponseHandler = createErrorResponseHandler(
          new JsonErrorShapeMetadata().withModeledClass(NotFoundException.class).withHttpStatusCode(404),
          new JsonErrorShapeMetadata().withModeledClass(TooManyRequestsException.class).withHttpStatusCode(429), new JsonErrorShapeMetadata()
                  .withModeledClass(BadRequestException.class).withHttpStatusCode(400),
          new JsonErrorShapeMetadata().withModeledClass(UnauthorizedException.class).withHttpStatusCode(401), new JsonErrorShapeMetadata()
                  .withModeledClass(InternalServerErrorException.class).withHttpStatusCode(500));

  return clientHandler.execute(new ClientExecutionParams<GetApplicationRequest, GetApplicationResult>()
          .withMarshaller(new GetApplicationRequestProtocolMarshaller(protocolFactory)).withResponseHandler(responseHandler)
          .withErrorResponseHandler(errorResponseHandler).withInput(getApplicationRequest));
}
 
Example #4
Source File: AWSServerlessApplicationRepositoryClient.java    From realworld-serverless-application with Apache License 2.0 6 votes vote down vote up
/**
 * @param listApplicationsRequest
 * @return Result of the ListApplications operation returned by the service.
 * @throws TooManyRequestsException
 * @throws BadRequestException
 * @throws UnauthorizedException
 * @throws InternalServerErrorException
 * @sample AWSServerlessApplicationRepository.ListApplications
 * @see <a href="http://docs.aws.amazon.com/goto/WebAPI/xxx-2019-10-13/ListApplications" target="_top">AWS
 *      API Documentation</a>
 */
@Override
public ListApplicationsResult listApplications(ListApplicationsRequest listApplicationsRequest) {
  HttpResponseHandler<ListApplicationsResult> responseHandler = protocolFactory.createResponseHandler(new JsonOperationMetadata().withPayloadJson(true)
          .withHasStreamingSuccessResponse(false), new ListApplicationsResultJsonUnmarshaller());

  HttpResponseHandler<SdkBaseException> errorResponseHandler = createErrorResponseHandler(
          new JsonErrorShapeMetadata().withModeledClass(TooManyRequestsException.class).withHttpStatusCode(429), new JsonErrorShapeMetadata()
                  .withModeledClass(BadRequestException.class).withHttpStatusCode(400),
          new JsonErrorShapeMetadata().withModeledClass(UnauthorizedException.class).withHttpStatusCode(401), new JsonErrorShapeMetadata()
                  .withModeledClass(InternalServerErrorException.class).withHttpStatusCode(500));

  return clientHandler.execute(new ClientExecutionParams<ListApplicationsRequest, ListApplicationsResult>()
          .withMarshaller(new ListApplicationsRequestProtocolMarshaller(protocolFactory)).withResponseHandler(responseHandler)
          .withErrorResponseHandler(errorResponseHandler).withInput(listApplicationsRequest));
}
 
Example #5
Source File: AWSServerlessApplicationRepositoryClient.java    From realworld-serverless-application with Apache License 2.0 6 votes vote down vote up
/**
 * @param updateApplicationRequest
 * @return Result of the UpdateApplication operation returned by the service.
 * @throws NotFoundException
 * @throws TooManyRequestsException
 * @throws BadRequestException
 * @throws UnauthorizedException
 * @throws InternalServerErrorException
 * @sample AWSServerlessApplicationRepository.UpdateApplication
 * @see <a href="http://docs.aws.amazon.com/goto/WebAPI/xxx-2019-10-13/UpdateApplication"
 *      target="_top">AWS API Documentation</a>
 */
@Override
public UpdateApplicationResult updateApplication(UpdateApplicationRequest updateApplicationRequest) {
  HttpResponseHandler<UpdateApplicationResult> responseHandler = protocolFactory.createResponseHandler(new JsonOperationMetadata().withPayloadJson(true)
          .withHasStreamingSuccessResponse(false), new UpdateApplicationResultJsonUnmarshaller());

  HttpResponseHandler<SdkBaseException> errorResponseHandler = createErrorResponseHandler(
          new JsonErrorShapeMetadata().withModeledClass(NotFoundException.class).withHttpStatusCode(404),
          new JsonErrorShapeMetadata().withModeledClass(TooManyRequestsException.class).withHttpStatusCode(429), new JsonErrorShapeMetadata()
                  .withModeledClass(BadRequestException.class).withHttpStatusCode(400),
          new JsonErrorShapeMetadata().withModeledClass(UnauthorizedException.class).withHttpStatusCode(401), new JsonErrorShapeMetadata()
                  .withModeledClass(InternalServerErrorException.class).withHttpStatusCode(500));

  return clientHandler.execute(new ClientExecutionParams<UpdateApplicationRequest, UpdateApplicationResult>()
          .withMarshaller(new UpdateApplicationRequestProtocolMarshaller(protocolFactory)).withResponseHandler(responseHandler)
          .withErrorResponseHandler(errorResponseHandler).withInput(updateApplicationRequest));
}
 
Example #6
Source File: GenericApiGatewayClient.java    From apigateway-generic-java-sdk with Apache License 2.0 5 votes vote down vote up
GenericApiGatewayClient(ClientConfiguration clientConfiguration, String endpoint, Region region,
                        AWSCredentialsProvider credentials, String apiKey, AmazonHttpClient httpClient) {
    super(clientConfiguration);
    setRegion(region);
    setEndpoint(endpoint);
    this.credentials = credentials;
    this.apiKey = apiKey;
    this.signer = new AWS4Signer();
    this.signer.setServiceName(API_GATEWAY_SERVICE_NAME);
    this.signer.setRegionName(region.getName());

    final JsonOperationMetadata metadata = new JsonOperationMetadata().withHasStreamingSuccessResponse(false).withPayloadJson(false);
    final Unmarshaller<GenericApiGatewayResponse, JsonUnmarshallerContext> responseUnmarshaller = in -> new GenericApiGatewayResponse(in.getHttpResponse());
    this.responseHandler = SdkStructuredPlainJsonFactory.SDK_JSON_FACTORY.createResponseHandler(metadata, responseUnmarshaller);
    JsonErrorUnmarshaller defaultErrorUnmarshaller = new JsonErrorUnmarshaller(GenericApiGatewayException.class, null) {
        @Override
        public AmazonServiceException unmarshall(JsonNode jsonContent) throws Exception {
            return new GenericApiGatewayException(jsonContent.toString());
        }
    };
    this.errorResponseHandler = SdkStructuredPlainJsonFactory.SDK_JSON_FACTORY.createErrorResponseHandler(
            Collections.singletonList(defaultErrorUnmarshaller), null);

    if (httpClient != null) {
        super.client = httpClient;
    }
}
 
Example #7
Source File: GenericApiGatewayClient.java    From nifi with Apache License 2.0 5 votes vote down vote up
GenericApiGatewayClient(ClientConfiguration clientConfiguration, String endpoint, Region region,
                        AWSCredentialsProvider credentials, String apiKey, AmazonHttpClient httpClient) {
    super(clientConfiguration);
    setRegion(region);
    setEndpoint(endpoint);
    this.credentials = credentials;
    this.apiKey = apiKey;
    this.signer = new AWS4Signer();
    this.signer.setServiceName(API_GATEWAY_SERVICE_NAME);
    this.signer.setRegionName(region.getName());

    final JsonOperationMetadata metadata = new JsonOperationMetadata().withHasStreamingSuccessResponse(false).withPayloadJson(false);
    final Unmarshaller<GenericApiGatewayResponse, JsonUnmarshallerContext> responseUnmarshaller = in -> new GenericApiGatewayResponse(in.getHttpResponse());
    this.responseHandler = SdkStructuredPlainJsonFactory.SDK_JSON_FACTORY.createResponseHandler(metadata, responseUnmarshaller);
    JsonErrorUnmarshaller defaultErrorUnmarshaller = new JsonErrorUnmarshaller(GenericApiGatewayException.class, null) {
        @Override
        public AmazonServiceException unmarshall(JsonNode jsonContent) throws Exception {
            return new GenericApiGatewayException(jsonContent.toString());
        }
    };
    this.errorResponseHandler = SdkStructuredPlainJsonFactory.SDK_JSON_FACTORY.createErrorResponseHandler(
            Collections.singletonList(defaultErrorUnmarshaller), null);

    if (httpClient != null) {
        super.client = httpClient;
    }
}
 
Example #8
Source File: V1DynamoDbAttributeValue.java    From aws-sdk-java-v2 with Apache License 2.0 4 votes vote down vote up
private static HttpResponseHandler<AmazonWebServiceResponse<GetItemResult>> getItemJsonResponseHandler() {
    return PROTOCOL_FACTORY.createResponseHandler(new JsonOperationMetadata()
                                                      .withPayloadJson(true)
                                                      .withHasStreamingSuccessResponse(false),
                                                  new GetItemResultJsonUnmarshaller());
}