Search in sources :

Example 11 with XmlOperationMetadata

use of software.amazon.awssdk.protocols.xml.XmlOperationMetadata in project aws-sdk-java-v2 by aws.

the class DefaultXmlClient method streamingOutputOperation.

/**
 * Some operation with a streaming output
 *
 * @param streamingOutputOperationRequest
 * @param responseTransformer
 *        Functional interface for processing the streamed response content. The unmarshalled
 *        StreamingOutputOperationResponse and an InputStream to the response content are provided as parameters to
 *        the callback. The callback may return a transformed type which will be the return value of this method.
 *        See {@link software.amazon.awssdk.core.sync.ResponseTransformer} for details on implementing this
 *        interface and for links to pre-canned implementations for common scenarios like downloading to a file. The
 *        service documentation for the response content is as follows 'This be a stream'.
 * @return The transformed result of the ResponseTransformer.
 * @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.StreamingOutputOperation
 * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/xml-service-2010-05-08/StreamingOutputOperation"
 *      target="_top">AWS API Documentation</a>
 */
@Override
public <ReturnT> ReturnT streamingOutputOperation(StreamingOutputOperationRequest streamingOutputOperationRequest, ResponseTransformer<StreamingOutputOperationResponse, ReturnT> responseTransformer) throws AwsServiceException, SdkClientException, XmlException {
    HttpResponseHandler<StreamingOutputOperationResponse> responseHandler = protocolFactory.createResponseHandler(StreamingOutputOperationResponse::builder, new XmlOperationMetadata().withHasStreamingSuccessResponse(true));
    HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler();
    List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, streamingOutputOperationRequest.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, "StreamingOutputOperation");
        return clientHandler.execute(new ClientExecutionParams<StreamingOutputOperationRequest, StreamingOutputOperationResponse>().withOperationName("StreamingOutputOperation").withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler).withInput(streamingOutputOperationRequest).withMetricCollector(apiCallMetricCollector).withMarshaller(new StreamingOutputOperationRequestMarshaller(protocolFactory)), responseTransformer);
    } finally {
        metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
    }
}
Also used : StreamingOutputOperationRequestMarshaller(software.amazon.awssdk.services.xml.transform.StreamingOutputOperationRequestMarshaller) AwsServiceException(software.amazon.awssdk.awscore.exception.AwsServiceException) StreamingOutputOperationRequest(software.amazon.awssdk.services.xml.model.StreamingOutputOperationRequest) StreamingOutputOperationResponse(software.amazon.awssdk.services.xml.model.StreamingOutputOperationResponse) 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)

Example 12 with XmlOperationMetadata

use of software.amazon.awssdk.protocols.xml.XmlOperationMetadata in project aws-sdk-java-v2 by aws.

the class DefaultXmlClient method putOperationWithChecksum.

/**
 * Invokes the PutOperationWithChecksum operation.
 *
 * @param putOperationWithChecksumRequest
 * @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 '
 *        <p>
 *        Object data.
 *        </p>
 *        '
 * @param responseTransformer
 *        Functional interface for processing the streamed response content. The unmarshalled
 *        PutOperationWithChecksumResponse and an InputStream to the response content are provided as parameters to
 *        the callback. The callback may return a transformed type which will be the return value of this method.
 *        See {@link software.amazon.awssdk.core.sync.ResponseTransformer} for details on implementing this
 *        interface and for links to pre-canned implementations for common scenarios like downloading to a file. The
 *        service documentation for the response content is as follows '
 *        <p>
 *        Object data.
 *        </p>
 *        '.
 * @return The transformed result of the ResponseTransformer.
 * @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.PutOperationWithChecksum
 * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/xml-service-2010-05-08/PutOperationWithChecksum"
 *      target="_top">AWS API Documentation</a>
 */
@Override
public <ReturnT> ReturnT putOperationWithChecksum(PutOperationWithChecksumRequest putOperationWithChecksumRequest, RequestBody requestBody, ResponseTransformer<PutOperationWithChecksumResponse, ReturnT> responseTransformer) throws AwsServiceException, SdkClientException, XmlException {
    HttpResponseHandler<PutOperationWithChecksumResponse> responseHandler = protocolFactory.createResponseHandler(PutOperationWithChecksumResponse::builder, new XmlOperationMetadata().withHasStreamingSuccessResponse(true));
    HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler();
    List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, putOperationWithChecksumRequest.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, "PutOperationWithChecksum");
        return clientHandler.execute(new ClientExecutionParams<PutOperationWithChecksumRequest, PutOperationWithChecksumResponse>().withOperationName("PutOperationWithChecksum").withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler).withInput(putOperationWithChecksumRequest).withMetricCollector(apiCallMetricCollector).putExecutionAttribute(SdkInternalExecutionAttribute.HTTP_CHECKSUM, HttpChecksum.builder().requestChecksumRequired(false).requestValidationMode(putOperationWithChecksumRequest.checksumModeAsString()).responseAlgorithms("CRC32C", "CRC32", "SHA1", "SHA256").isRequestStreaming(true).build()).withRequestBody(requestBody).withMarshaller(StreamingRequestMarshaller.builder().delegateMarshaller(new PutOperationWithChecksumRequestMarshaller(protocolFactory)).requestBody(requestBody).build()));
    } finally {
        metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
    }
}
Also used : PutOperationWithChecksumRequestMarshaller(software.amazon.awssdk.services.xml.transform.PutOperationWithChecksumRequestMarshaller) AwsServiceException(software.amazon.awssdk.awscore.exception.AwsServiceException) MetricPublisher(software.amazon.awssdk.metrics.MetricPublisher) NoOpMetricCollector(software.amazon.awssdk.metrics.NoOpMetricCollector) MetricCollector(software.amazon.awssdk.metrics.MetricCollector) PutOperationWithChecksumResponse(software.amazon.awssdk.services.xml.model.PutOperationWithChecksumResponse) XmlOperationMetadata(software.amazon.awssdk.protocols.xml.XmlOperationMetadata) PutOperationWithChecksumRequest(software.amazon.awssdk.services.xml.model.PutOperationWithChecksumRequest)

Example 13 with XmlOperationMetadata

use of software.amazon.awssdk.protocols.xml.XmlOperationMetadata in project aws-sdk-java-v2 by aws.

the class DefaultXmlAsyncClient method aPostOperationWithOutput.

/**
 * <p>
 * Performs a post operation to the xml service and has modelled output
 * </p>
 *
 * @param aPostOperationWithOutputRequest
 * @return A Java Future containing the result of the APostOperationWithOutput operation returned by the service.<br/>
 *         The CompletableFuture returned by this method can be completed exceptionally with the following
 *         exceptions.
 *         <ul>
 *         <li>InvalidInputException The request was rejected because an invalid or out-of-range value was supplied
 *         for an input parameter.</li>
 *         <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.APostOperationWithOutput
 * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/xml-service-2010-05-08/APostOperationWithOutput"
 *      target="_top">AWS API Documentation</a>
 */
@Override
public CompletableFuture<APostOperationWithOutputResponse> aPostOperationWithOutput(APostOperationWithOutputRequest aPostOperationWithOutputRequest) {
    List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, aPostOperationWithOutputRequest.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, "APostOperationWithOutput");
        HttpResponseHandler<Response<APostOperationWithOutputResponse>> responseHandler = protocolFactory.createCombinedResponseHandler(APostOperationWithOutputResponse::builder, new XmlOperationMetadata().withHasStreamingSuccessResponse(false));
        CompletableFuture<APostOperationWithOutputResponse> executeFuture = clientHandler.execute(new ClientExecutionParams<APostOperationWithOutputRequest, APostOperationWithOutputResponse>().withOperationName("APostOperationWithOutput").withMarshaller(new APostOperationWithOutputRequestMarshaller(protocolFactory)).withCombinedResponseHandler(responseHandler).withMetricCollector(apiCallMetricCollector).withInput(aPostOperationWithOutputRequest));
        CompletableFuture<APostOperationWithOutputResponse> 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 : 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) 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) ClientExecutionParams(software.amazon.awssdk.core.client.handler.ClientExecutionParams) 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) APostOperationWithOutputRequestMarshaller(software.amazon.awssdk.services.xml.transform.APostOperationWithOutputRequestMarshaller) APostOperationWithOutputResponse(software.amazon.awssdk.services.xml.model.APostOperationWithOutputResponse)

Example 14 with XmlOperationMetadata

use of software.amazon.awssdk.protocols.xml.XmlOperationMetadata in project aws-sdk-java-v2 by aws.

the class DefaultXmlAsyncClient method putOperationWithChecksum.

/**
 * Invokes the PutOperationWithChecksum operation asynchronously.
 *
 * @param putOperationWithChecksumRequest
 * @param requestBody
 *        Functional interface that can be implemented to produce the request content in a non-blocking manner. The
 *        size of the content is expected to be known up front. See {@link AsyncRequestBody} for specific details on
 *        implementing this interface as well as links to precanned implementations for common scenarios like
 *        uploading from a file. The service documentation for the request content is as follows '
 *        <p>
 *        Object data.
 *        </p>
 *        '
 * @param asyncResponseTransformer
 *        The response transformer for processing the streaming response in a non-blocking manner. See
 *        {@link AsyncResponseTransformer} for details on how this callback should be implemented and for links to
 *        precanned implementations for common scenarios like downloading to a file. The service documentation for
 *        the response content is as follows '
 *        <p>
 *        Object data.
 *        </p>
 *        '.
 * @return A future to the transformed result of the AsyncResponseTransformer.<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.PutOperationWithChecksum
 * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/xml-service-2010-05-08/PutOperationWithChecksum"
 *      target="_top">AWS API Documentation</a>
 */
@Override
public <ReturnT> CompletableFuture<ReturnT> putOperationWithChecksum(PutOperationWithChecksumRequest putOperationWithChecksumRequest, AsyncRequestBody requestBody, AsyncResponseTransformer<PutOperationWithChecksumResponse, ReturnT> asyncResponseTransformer) {
    List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, putOperationWithChecksumRequest.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, "PutOperationWithChecksum");
        Pair<AsyncResponseTransformer<PutOperationWithChecksumResponse, ReturnT>, CompletableFuture<Void>> pair = AsyncResponseTransformerUtils.wrapWithEndOfStreamFuture(asyncResponseTransformer);
        asyncResponseTransformer = pair.left();
        CompletableFuture<Void> endOfStreamFuture = pair.right();
        if (!isSignerOverridden(clientConfiguration)) {
            putOperationWithChecksumRequest = applySignerOverride(putOperationWithChecksumRequest, AsyncAws4Signer.create());
        }
        HttpResponseHandler<PutOperationWithChecksumResponse> responseHandler = protocolFactory.createResponseHandler(PutOperationWithChecksumResponse::builder, new XmlOperationMetadata().withHasStreamingSuccessResponse(true));
        HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler();
        CompletableFuture<ReturnT> executeFuture = clientHandler.execute(new ClientExecutionParams<PutOperationWithChecksumRequest, PutOperationWithChecksumResponse>().withOperationName("PutOperationWithChecksum").withMarshaller(AsyncStreamingRequestMarshaller.builder().delegateMarshaller(new PutOperationWithChecksumRequestMarshaller(protocolFactory)).asyncRequestBody(requestBody).build()).withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler).withMetricCollector(apiCallMetricCollector).putExecutionAttribute(SdkInternalExecutionAttribute.HTTP_CHECKSUM, HttpChecksum.builder().requestChecksumRequired(false).requestValidationMode(putOperationWithChecksumRequest.checksumModeAsString()).responseAlgorithms("CRC32C", "CRC32", "SHA1", "SHA256").isRequestStreaming(true).build()).withAsyncRequestBody(requestBody).withInput(putOperationWithChecksumRequest), asyncResponseTransformer);
        CompletableFuture<ReturnT> whenCompleteFuture = null;
        AsyncResponseTransformer<PutOperationWithChecksumResponse, ReturnT> finalAsyncResponseTransformer = asyncResponseTransformer;
        whenCompleteFuture = executeFuture.whenComplete((r, e) -> {
            if (e != null) {
                runAndLogError(log, "Exception thrown in exceptionOccurred callback, ignoring", () -> finalAsyncResponseTransformer.exceptionOccurred(e));
            }
            endOfStreamFuture.whenComplete((r2, e2) -> {
                metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
            });
        });
        return CompletableFutureUtils.forwardExceptionTo(whenCompleteFuture, executeFuture);
    } catch (Throwable t) {
        AsyncResponseTransformer<PutOperationWithChecksumResponse, ReturnT> finalAsyncResponseTransformer = asyncResponseTransformer;
        runAndLogError(log, "Exception thrown in exceptionOccurred callback, ignoring", () -> finalAsyncResponseTransformer.exceptionOccurred(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) PutOperationWithChecksumRequest(software.amazon.awssdk.services.xml.model.PutOperationWithChecksumRequest) CompletableFuture(java.util.concurrent.CompletableFuture) RestEventStreamAsyncResponseTransformer(software.amazon.awssdk.awscore.eventstream.RestEventStreamAsyncResponseTransformer) AsyncResponseTransformer(software.amazon.awssdk.core.async.AsyncResponseTransformer) EventStreamAsyncResponseTransformer(software.amazon.awssdk.awscore.eventstream.EventStreamAsyncResponseTransformer) PutOperationWithChecksumRequestMarshaller(software.amazon.awssdk.services.xml.transform.PutOperationWithChecksumRequestMarshaller) AwsServiceException(software.amazon.awssdk.awscore.exception.AwsServiceException) NoOpMetricCollector(software.amazon.awssdk.metrics.NoOpMetricCollector) MetricCollector(software.amazon.awssdk.metrics.MetricCollector) PutOperationWithChecksumResponse(software.amazon.awssdk.services.xml.model.PutOperationWithChecksumResponse) XmlOperationMetadata(software.amazon.awssdk.protocols.xml.XmlOperationMetadata)

Aggregations

MetricCollector (software.amazon.awssdk.metrics.MetricCollector)14 MetricPublisher (software.amazon.awssdk.metrics.MetricPublisher)14 NoOpMetricCollector (software.amazon.awssdk.metrics.NoOpMetricCollector)14 XmlOperationMetadata (software.amazon.awssdk.protocols.xml.XmlOperationMetadata)14 PutOperationWithChecksumResponse (software.amazon.awssdk.services.xml.model.PutOperationWithChecksumResponse)13 StreamingOutputOperationResponse (software.amazon.awssdk.services.xml.model.StreamingOutputOperationResponse)13 Response (software.amazon.awssdk.core.Response)12 APostOperationResponse (software.amazon.awssdk.services.xml.model.APostOperationResponse)12 APostOperationWithOutputResponse (software.amazon.awssdk.services.xml.model.APostOperationWithOutputResponse)12 GetOperationWithChecksumResponse (software.amazon.awssdk.services.xml.model.GetOperationWithChecksumResponse)12 OperationWithChecksumRequiredResponse (software.amazon.awssdk.services.xml.model.OperationWithChecksumRequiredResponse)12 StreamingInputOperationResponse (software.amazon.awssdk.services.xml.model.StreamingInputOperationResponse)12 AwsServiceException (software.amazon.awssdk.awscore.exception.AwsServiceException)9 Collections (java.util.Collections)7 List (java.util.List)7 CompletableFuture (java.util.concurrent.CompletableFuture)7 Executor (java.util.concurrent.Executor)7 Consumer (java.util.function.Consumer)7 Logger (org.slf4j.Logger)7 LoggerFactory (org.slf4j.LoggerFactory)7