Search in sources :

Example 1 with OperationWithChecksumRequiredRequestMarshaller

use of software.amazon.awssdk.services.xml.transform.OperationWithChecksumRequiredRequestMarshaller in project aws-sdk-java-v2 by aws.

the class DefaultXmlAsyncClient method operationWithChecksumRequired.

/**
 * Invokes the OperationWithChecksumRequired operation asynchronously.
 *
 * @param operationWithChecksumRequiredRequest
 * @return A Java Future containing the result of the OperationWithChecksumRequired operation returned by the
 *         service.<br/>
 *         The CompletableFuture returned by this method can be completed exceptionally with the following
 *         exceptions.
 *         <ul>
 *         <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client).
 *         Can be used for catch all scenarios.</li>
 *         <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get
 *         credentials, etc.</li>
 *         <li>XmlException Base class for all service exceptions. Unknown exceptions will be thrown as an instance
 *         of this type.</li>
 *         </ul>
 * @sample XmlAsyncClient.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 CompletableFuture<OperationWithChecksumRequiredResponse> operationWithChecksumRequired(OperationWithChecksumRequiredRequest operationWithChecksumRequiredRequest) {
    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");
        HttpResponseHandler<Response<OperationWithChecksumRequiredResponse>> responseHandler = protocolFactory.createCombinedResponseHandler(OperationWithChecksumRequiredResponse::builder, new XmlOperationMetadata().withHasStreamingSuccessResponse(false));
        CompletableFuture<OperationWithChecksumRequiredResponse> executeFuture = clientHandler.execute(new ClientExecutionParams<OperationWithChecksumRequiredRequest, OperationWithChecksumRequiredResponse>().withOperationName("OperationWithChecksumRequired").withMarshaller(new OperationWithChecksumRequiredRequestMarshaller(protocolFactory)).withCombinedResponseHandler(responseHandler).withMetricCollector(apiCallMetricCollector).putExecutionAttribute(SdkInternalExecutionAttribute.HTTP_CHECKSUM_REQUIRED, HttpChecksumRequired.create()).withInput(operationWithChecksumRequiredRequest));
        CompletableFuture<OperationWithChecksumRequiredResponse> whenCompleteFuture = null;
        whenCompleteFuture = executeFuture.whenComplete((r, e) -> {
            metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
        });
        CompletableFutureUtils.forwardExceptionTo(whenCompleteFuture, executeFuture);
        return whenCompleteFuture;
    } catch (Throwable t) {
        metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
        return CompletableFutureUtils.failedFuture(t);
    }
}
Also used : ExceptionMetadata(software.amazon.awssdk.protocols.core.ExceptionMetadata) AwsAsyncClientHandler(software.amazon.awssdk.awscore.client.handler.AwsAsyncClientHandler) StreamingOutputOperationRequestMarshaller(software.amazon.awssdk.services.xml.transform.StreamingOutputOperationRequestMarshaller) EventStreamOperationResponseHandler(software.amazon.awssdk.services.xml.model.EventStreamOperationResponseHandler) GetOperationWithChecksumRequestMarshaller(software.amazon.awssdk.services.xml.transform.GetOperationWithChecksumRequestMarshaller) XmlRequest(software.amazon.awssdk.services.xml.model.XmlRequest) LoggerFactory(org.slf4j.LoggerFactory) StreamingOutputOperationRequest(software.amazon.awssdk.services.xml.model.StreamingOutputOperationRequest) RestEventStreamAsyncResponseTransformer(software.amazon.awssdk.awscore.eventstream.RestEventStreamAsyncResponseTransformer) StreamingInputOperationResponse(software.amazon.awssdk.services.xml.model.StreamingInputOperationResponse) XmlException(software.amazon.awssdk.services.xml.model.XmlException) MetricPublisher(software.amazon.awssdk.metrics.MetricPublisher) GetOperationWithChecksumResponse(software.amazon.awssdk.services.xml.model.GetOperationWithChecksumResponse) APostOperationRequest(software.amazon.awssdk.services.xml.model.APostOperationRequest) AsyncStreamingRequestMarshaller(software.amazon.awssdk.core.runtime.transform.AsyncStreamingRequestMarshaller) AsyncResponseTransformer(software.amazon.awssdk.core.async.AsyncResponseTransformer) SdkClientOption(software.amazon.awssdk.core.client.config.SdkClientOption) StreamingInputOperationRequest(software.amazon.awssdk.services.xml.model.StreamingInputOperationRequest) AsyncClientHandler(software.amazon.awssdk.core.client.handler.AsyncClientHandler) EventStreamOperationRequest(software.amazon.awssdk.services.xml.model.EventStreamOperationRequest) PutOperationWithChecksumRequestMarshaller(software.amazon.awssdk.services.xml.transform.PutOperationWithChecksumRequestMarshaller) AwsServiceException(software.amazon.awssdk.awscore.exception.AwsServiceException) XmlOperationMetadata(software.amazon.awssdk.protocols.xml.XmlOperationMetadata) OperationWithChecksumRequiredRequestMarshaller(software.amazon.awssdk.services.xml.transform.OperationWithChecksumRequiredRequestMarshaller) SdkPojoBuilder(software.amazon.awssdk.core.SdkPojoBuilder) EventStreamOperationRequestMarshaller(software.amazon.awssdk.services.xml.transform.EventStreamOperationRequestMarshaller) APostOperationRequestMarshaller(software.amazon.awssdk.services.xml.transform.APostOperationRequestMarshaller) List(java.util.List) AsyncRequestBody(software.amazon.awssdk.core.async.AsyncRequestBody) AwsXmlProtocolFactory(software.amazon.awssdk.protocols.xml.AwsXmlProtocolFactory) AsyncAws4Signer(software.amazon.awssdk.auth.signer.AsyncAws4Signer) SdkAdvancedAsyncClientOption(software.amazon.awssdk.core.client.config.SdkAdvancedAsyncClientOption) HttpResponseHandler(software.amazon.awssdk.core.http.HttpResponseHandler) Generated(software.amazon.awssdk.annotations.Generated) AsyncResponseTransformerUtils(software.amazon.awssdk.core.async.AsyncResponseTransformerUtils) GetOperationWithChecksumRequest(software.amazon.awssdk.services.xml.model.GetOperationWithChecksumRequest) AwsRequestOverrideConfiguration(software.amazon.awssdk.awscore.AwsRequestOverrideConfiguration) Signer(software.amazon.awssdk.core.signer.Signer) OperationWithChecksumRequiredRequest(software.amazon.awssdk.services.xml.model.OperationWithChecksumRequiredRequest) EventStreamAsyncResponseTransformer(software.amazon.awssdk.awscore.eventstream.EventStreamAsyncResponseTransformer) StreamingOutputOperationResponse(software.amazon.awssdk.services.xml.model.StreamingOutputOperationResponse) EventStreamTaggedUnionPojoSupplier(software.amazon.awssdk.awscore.eventstream.EventStreamTaggedUnionPojoSupplier) PutOperationWithChecksumResponse(software.amazon.awssdk.services.xml.model.PutOperationWithChecksumResponse) CompletableFutureUtils(software.amazon.awssdk.utils.CompletableFutureUtils) CompletableFuture(java.util.concurrent.CompletableFuture) SdkClientConfiguration(software.amazon.awssdk.core.client.config.SdkClientConfiguration) Response(software.amazon.awssdk.core.Response) HttpChecksumRequired(software.amazon.awssdk.core.interceptor.trait.HttpChecksumRequired) StreamingInputOperationRequestMarshaller(software.amazon.awssdk.services.xml.transform.StreamingInputOperationRequestMarshaller) CoreMetric(software.amazon.awssdk.core.metrics.CoreMetric) APostOperationWithOutputResponse(software.amazon.awssdk.services.xml.model.APostOperationWithOutputResponse) RequestOverrideConfiguration(software.amazon.awssdk.core.RequestOverrideConfiguration) EventStream(software.amazon.awssdk.services.xml.model.EventStream) NoOpMetricCollector(software.amazon.awssdk.metrics.NoOpMetricCollector) Logger(org.slf4j.Logger) SdkInternalExecutionAttribute(software.amazon.awssdk.core.interceptor.SdkInternalExecutionAttribute) MetricCollector(software.amazon.awssdk.metrics.MetricCollector) Executor(java.util.concurrent.Executor) APostOperationWithOutputRequestMarshaller(software.amazon.awssdk.services.xml.transform.APostOperationWithOutputRequestMarshaller) Pair(software.amazon.awssdk.utils.Pair) APostOperationResponse(software.amazon.awssdk.services.xml.model.APostOperationResponse) Consumer(java.util.function.Consumer) HttpChecksum(software.amazon.awssdk.core.interceptor.trait.HttpChecksum) InvalidInputException(software.amazon.awssdk.services.xml.model.InvalidInputException) APostOperationWithOutputRequest(software.amazon.awssdk.services.xml.model.APostOperationWithOutputRequest) ClientExecutionParams(software.amazon.awssdk.core.client.handler.ClientExecutionParams) PutOperationWithChecksumRequest(software.amazon.awssdk.services.xml.model.PutOperationWithChecksumRequest) SdkInternalApi(software.amazon.awssdk.annotations.SdkInternalApi) EventStreamOperationResponse(software.amazon.awssdk.services.xml.model.EventStreamOperationResponse) OperationWithChecksumRequiredResponse(software.amazon.awssdk.services.xml.model.OperationWithChecksumRequiredResponse) FunctionalUtils.runAndLogError(software.amazon.awssdk.utils.FunctionalUtils.runAndLogError) Collections(java.util.Collections) MetricPublisher(software.amazon.awssdk.metrics.MetricPublisher) OperationWithChecksumRequiredResponse(software.amazon.awssdk.services.xml.model.OperationWithChecksumRequiredResponse) StreamingInputOperationResponse(software.amazon.awssdk.services.xml.model.StreamingInputOperationResponse) GetOperationWithChecksumResponse(software.amazon.awssdk.services.xml.model.GetOperationWithChecksumResponse) StreamingOutputOperationResponse(software.amazon.awssdk.services.xml.model.StreamingOutputOperationResponse) PutOperationWithChecksumResponse(software.amazon.awssdk.services.xml.model.PutOperationWithChecksumResponse) Response(software.amazon.awssdk.core.Response) APostOperationWithOutputResponse(software.amazon.awssdk.services.xml.model.APostOperationWithOutputResponse) APostOperationResponse(software.amazon.awssdk.services.xml.model.APostOperationResponse) EventStreamOperationResponse(software.amazon.awssdk.services.xml.model.EventStreamOperationResponse) OperationWithChecksumRequiredResponse(software.amazon.awssdk.services.xml.model.OperationWithChecksumRequiredResponse) OperationWithChecksumRequiredRequest(software.amazon.awssdk.services.xml.model.OperationWithChecksumRequiredRequest) NoOpMetricCollector(software.amazon.awssdk.metrics.NoOpMetricCollector) MetricCollector(software.amazon.awssdk.metrics.MetricCollector) XmlOperationMetadata(software.amazon.awssdk.protocols.xml.XmlOperationMetadata) OperationWithChecksumRequiredRequestMarshaller(software.amazon.awssdk.services.xml.transform.OperationWithChecksumRequiredRequestMarshaller)

Example 2 with OperationWithChecksumRequiredRequestMarshaller

use of software.amazon.awssdk.services.xml.transform.OperationWithChecksumRequiredRequestMarshaller 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()));
    }
}
Also used : StreamingInputOperationResponse(software.amazon.awssdk.services.xml.model.StreamingInputOperationResponse) GetOperationWithChecksumResponse(software.amazon.awssdk.services.xml.model.GetOperationWithChecksumResponse) StreamingOutputOperationResponse(software.amazon.awssdk.services.xml.model.StreamingOutputOperationResponse) PutOperationWithChecksumResponse(software.amazon.awssdk.services.xml.model.PutOperationWithChecksumResponse) Response(software.amazon.awssdk.core.Response) APostOperationWithOutputResponse(software.amazon.awssdk.services.xml.model.APostOperationWithOutputResponse) APostOperationResponse(software.amazon.awssdk.services.xml.model.APostOperationResponse) OperationWithChecksumRequiredResponse(software.amazon.awssdk.services.xml.model.OperationWithChecksumRequiredResponse) OperationWithChecksumRequiredRequest(software.amazon.awssdk.services.xml.model.OperationWithChecksumRequiredRequest) OperationWithChecksumRequiredResponse(software.amazon.awssdk.services.xml.model.OperationWithChecksumRequiredResponse) MetricPublisher(software.amazon.awssdk.metrics.MetricPublisher) NoOpMetricCollector(software.amazon.awssdk.metrics.NoOpMetricCollector) MetricCollector(software.amazon.awssdk.metrics.MetricCollector) XmlOperationMetadata(software.amazon.awssdk.protocols.xml.XmlOperationMetadata) OperationWithChecksumRequiredRequestMarshaller(software.amazon.awssdk.services.xml.transform.OperationWithChecksumRequiredRequestMarshaller)

Aggregations

Response (software.amazon.awssdk.core.Response)2 MetricCollector (software.amazon.awssdk.metrics.MetricCollector)2 MetricPublisher (software.amazon.awssdk.metrics.MetricPublisher)2 NoOpMetricCollector (software.amazon.awssdk.metrics.NoOpMetricCollector)2 XmlOperationMetadata (software.amazon.awssdk.protocols.xml.XmlOperationMetadata)2 Collections (java.util.Collections)1 List (java.util.List)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 Executor (java.util.concurrent.Executor)1 Consumer (java.util.function.Consumer)1 Logger (org.slf4j.Logger)1 LoggerFactory (org.slf4j.LoggerFactory)1 Generated (software.amazon.awssdk.annotations.Generated)1 SdkInternalApi (software.amazon.awssdk.annotations.SdkInternalApi)1 AsyncAws4Signer (software.amazon.awssdk.auth.signer.AsyncAws4Signer)1 AwsRequestOverrideConfiguration (software.amazon.awssdk.awscore.AwsRequestOverrideConfiguration)1 AwsAsyncClientHandler (software.amazon.awssdk.awscore.client.handler.AwsAsyncClientHandler)1 EventStreamAsyncResponseTransformer (software.amazon.awssdk.awscore.eventstream.EventStreamAsyncResponseTransformer)1 EventStreamTaggedUnionPojoSupplier (software.amazon.awssdk.awscore.eventstream.EventStreamTaggedUnionPojoSupplier)1 RestEventStreamAsyncResponseTransformer (software.amazon.awssdk.awscore.eventstream.RestEventStreamAsyncResponseTransformer)1