com.amazonaws.http.HttpResponseHandler Java Examples

The following examples show how to use com.amazonaws.http.HttpResponseHandler. 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: EsHttpRequest.java    From charles-rest with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Ctor.
 * @param esEdp ElasticSearch URL.
 * @param uri REST path to the desired ElasticSearch endpoint.
 * @param respHandler Response handler.
 * @param errHandler Error handler.
 */
public EsHttpRequest(
	EsEndPoint esEdp,
    String uri,
    HttpResponseHandler<T> respHandler,
    HttpResponseHandler<AmazonServiceException> errHandler
){
	this.request = new DefaultRequest<Void>("es");
    String esEndpoint = esEdp.read();
    if(esEndpoint == null || esEndpoint.isEmpty()) {
        throw new IllegalStateException("ElasticSearch endpoint needs to be specified!");
    }
    if(esEndpoint.endsWith("/")) {
        esEndpoint += uri;
    } else {
        esEndpoint += "/" + uri;
    }
    this.request.setEndpoint(URI.create(esEndpoint));
    
    
    this.respHandler = respHandler;
    this.errHandler = errHandler;
}
 
Example #7
Source File: IvonaSpeechCloudClient.java    From ivona-speechcloud-sdk-java with Apache License 2.0 5 votes vote down vote up
private <X, Y extends AmazonWebServiceRequest> Response<X> invoke(
        Request<Y> request,
        HttpResponseHandler<AmazonWebServiceResponse<X>> responseHandler,
        ExecutionContext executionContext) {

    JsonErrorResponseHandler errorResponseHandler = new JsonErrorResponseHandler(exceptionUnmarshallers);

    Response<X> result = client.execute(
            prepareRequest(request, executionContext),
            responseHandler,
            errorResponseHandler,
            executionContext);

    return result;
}
 
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());
}
 
Example #9
Source File: AWSServerlessApplicationRepositoryClient.java    From realworld-serverless-application with Apache License 2.0 2 votes vote down vote up
/**
 * Create the error response handler for the operation.
 *
 * @param errorShapeMetadata
 *        Error metadata for the given operation
 * @return Configured error response handler to pass to HTTP layer
 */
private HttpResponseHandler<SdkBaseException> createErrorResponseHandler(JsonErrorShapeMetadata... errorShapeMetadata) {
  return protocolFactory.createErrorResponseHandler(new JsonErrorResponseMetadata().withErrorShapes(Arrays.asList(errorShapeMetadata)));
}