use of software.amazon.awssdk.core.Response in project aws-sdk-java-v2 by aws.
the class BaseSyncClientHandler method execute.
@Override
public <InputT extends SdkRequest, OutputT extends SdkResponse> OutputT execute(ClientExecutionParams<InputT, OutputT> executionParams) {
return measureApiCallSuccess(executionParams, () -> {
// Running beforeExecution interceptors and modifyRequest interceptors.
ExecutionContext executionContext = invokeInterceptorsAndCreateExecutionContext(executionParams);
HttpResponseHandler<Response<OutputT>> combinedResponseHandler = createCombinedResponseHandler(executionParams, executionContext);
return doExecute(executionParams, executionContext, combinedResponseHandler);
});
}
use of software.amazon.awssdk.core.Response in project aws-sdk-java-v2 by aws.
the class CombinedResponseAsyncHttpResponseHandlerTest method successResponse_shouldCompleteHeaderFuture.
@Test
void successResponse_shouldCompleteHeaderFuture() {
when(successResponseHandler.prepare()).thenReturn(CompletableFuture.completedFuture(null));
CompletableFuture<Response<Void>> future = responseHandler.prepare();
SdkHttpFullResponse sdkHttpFullResponse = SdkHttpFullResponse.builder().statusCode(200).build();
Flowable<ByteBuffer> publisher = publisher();
responseHandler.onHeaders(sdkHttpFullResponse);
responseHandler.onStream(publisher);
verify(successResponseHandler).prepare();
verify(successResponseHandler).onStream(publisher);
assertThat(future).isDone();
assertThat(future.join().httpResponse()).isEqualTo(sdkHttpFullResponse);
}
use of software.amazon.awssdk.core.Response in project aws-sdk-java-v2 by aws.
the class DefaultXmlClient method streamingInputOperation.
/**
* Some operation with a streaming input
*
* @param streamingInputOperationRequest
* @param requestBody
* The content to send to the service. A {@link RequestBody} can be created using one of several factory
* methods for various sources of data. For example, to create a request body from a file you can do the
* following.
*
* <pre>
* {@code RequestBody.fromFile(new File("myfile.txt"))}
* </pre>
*
* See documentation in {@link RequestBody} for additional details and which sources of data are supported.
* The service documentation for the request content is as follows 'This be a stream'
* @return Result of the StreamingInputOperation operation returned by the service.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws XmlException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample XmlClient.StreamingInputOperation
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/xml-service-2010-05-08/StreamingInputOperation"
* target="_top">AWS API Documentation</a>
*/
@Override
public StreamingInputOperationResponse streamingInputOperation(StreamingInputOperationRequest streamingInputOperationRequest, RequestBody requestBody) throws AwsServiceException, SdkClientException, XmlException {
HttpResponseHandler<Response<StreamingInputOperationResponse>> responseHandler = protocolFactory.createCombinedResponseHandler(StreamingInputOperationResponse::builder, new XmlOperationMetadata().withHasStreamingSuccessResponse(false));
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, streamingInputOperationRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Xml Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "StreamingInputOperation");
return clientHandler.execute(new ClientExecutionParams<StreamingInputOperationRequest, StreamingInputOperationResponse>().withOperationName("StreamingInputOperation").withCombinedResponseHandler(responseHandler).withMetricCollector(apiCallMetricCollector).withInput(streamingInputOperationRequest).withRequestBody(requestBody).withMarshaller(StreamingRequestMarshaller.builder().delegateMarshaller(new StreamingInputOperationRequestMarshaller(protocolFactory)).requestBody(requestBody).build()));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
use of software.amazon.awssdk.core.Response in project aws-sdk-java-v2 by aws.
the class DefaultXmlClient method operationWithChecksumRequired.
/**
* Invokes the OperationWithChecksumRequired operation.
*
* @param operationWithChecksumRequiredRequest
* @return Result of the OperationWithChecksumRequired operation returned by the service.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws XmlException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample XmlClient.OperationWithChecksumRequired
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/xml-service-2010-05-08/OperationWithChecksumRequired"
* target="_top">AWS API Documentation</a>
*/
@Override
public OperationWithChecksumRequiredResponse operationWithChecksumRequired(OperationWithChecksumRequiredRequest operationWithChecksumRequiredRequest) throws AwsServiceException, SdkClientException, XmlException {
HttpResponseHandler<Response<OperationWithChecksumRequiredResponse>> responseHandler = protocolFactory.createCombinedResponseHandler(OperationWithChecksumRequiredResponse::builder, new XmlOperationMetadata().withHasStreamingSuccessResponse(false));
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, operationWithChecksumRequiredRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Xml Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "OperationWithChecksumRequired");
return clientHandler.execute(new ClientExecutionParams<OperationWithChecksumRequiredRequest, OperationWithChecksumRequiredResponse>().withOperationName("OperationWithChecksumRequired").withCombinedResponseHandler(responseHandler).withMetricCollector(apiCallMetricCollector).withInput(operationWithChecksumRequiredRequest).putExecutionAttribute(SdkInternalExecutionAttribute.HTTP_CHECKSUM_REQUIRED, HttpChecksumRequired.create()).withMarshaller(new OperationWithChecksumRequiredRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
use of software.amazon.awssdk.core.Response in project aws-sdk-java-v2 by aws.
the class DefaultXmlClient method aPostOperation.
/**
* <p>
* Performs a post operation to the xml service and has no output
* </p>
*
* @param aPostOperationRequest
* @return Result of the APostOperation operation returned by the service.
* @throws InvalidInputException
* The request was rejected because an invalid or out-of-range value was supplied for an input parameter.
* @throws SdkException
* Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for
* catch all scenarios.
* @throws SdkClientException
* If any client side error occurs such as an IO related failure, failure to get credentials, etc.
* @throws XmlException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample XmlClient.APostOperation
* @see <a href="https://docs.aws.amazon.com/goto/WebAPI/xml-service-2010-05-08/APostOperation" target="_top">AWS
* API Documentation</a>
*/
@Override
public APostOperationResponse aPostOperation(APostOperationRequest aPostOperationRequest) throws InvalidInputException, AwsServiceException, SdkClientException, XmlException {
HttpResponseHandler<Response<APostOperationResponse>> responseHandler = protocolFactory.createCombinedResponseHandler(APostOperationResponse::builder, new XmlOperationMetadata().withHasStreamingSuccessResponse(false));
List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, aPostOperationRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Xml Service");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "APostOperation");
String hostPrefix = "foo-";
String resolvedHostExpression = "foo-";
return clientHandler.execute(new ClientExecutionParams<APostOperationRequest, APostOperationResponse>().withOperationName("APostOperation").withCombinedResponseHandler(responseHandler).withMetricCollector(apiCallMetricCollector).hostPrefixExpression(resolvedHostExpression).withInput(aPostOperationRequest).withMarshaller(new APostOperationRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
Aggregations