Search in sources :

Example 1 with APostOperationResponse

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

the class DefaultXmlAsyncClient method aPostOperation.

/**
 * <p>
 * Performs a post operation to the xml service and has no output
 * </p>
 *
 * @param aPostOperationRequest
 * @return A Java Future containing the result of the APostOperation 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.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 CompletableFuture<APostOperationResponse> aPostOperation(APostOperationRequest aPostOperationRequest) {
    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");
        HttpResponseHandler<Response<APostOperationResponse>> responseHandler = protocolFactory.createCombinedResponseHandler(APostOperationResponse::builder, new XmlOperationMetadata().withHasStreamingSuccessResponse(false));
        String hostPrefix = "foo-";
        String resolvedHostExpression = "foo-";
        CompletableFuture<APostOperationResponse> executeFuture = clientHandler.execute(new ClientExecutionParams<APostOperationRequest, APostOperationResponse>().withOperationName("APostOperation").withMarshaller(new APostOperationRequestMarshaller(protocolFactory)).withCombinedResponseHandler(responseHandler).hostPrefixExpression(resolvedHostExpression).withMetricCollector(apiCallMetricCollector).withInput(aPostOperationRequest));
        CompletableFuture<APostOperationResponse> 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) APostOperationResponse(software.amazon.awssdk.services.xml.model.APostOperationResponse) APostOperationRequest(software.amazon.awssdk.services.xml.model.APostOperationRequest) MetricPublisher(software.amazon.awssdk.metrics.MetricPublisher) APostOperationRequestMarshaller(software.amazon.awssdk.services.xml.transform.APostOperationRequestMarshaller) 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) NoOpMetricCollector(software.amazon.awssdk.metrics.NoOpMetricCollector) MetricCollector(software.amazon.awssdk.metrics.MetricCollector) XmlOperationMetadata(software.amazon.awssdk.protocols.xml.XmlOperationMetadata)

Example 2 with APostOperationResponse

use of software.amazon.awssdk.services.xml.model.APostOperationResponse 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()));
    }
}
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) APostOperationResponse(software.amazon.awssdk.services.xml.model.APostOperationResponse) APostOperationRequest(software.amazon.awssdk.services.xml.model.APostOperationRequest) MetricPublisher(software.amazon.awssdk.metrics.MetricPublisher) NoOpMetricCollector(software.amazon.awssdk.metrics.NoOpMetricCollector) MetricCollector(software.amazon.awssdk.metrics.MetricCollector) APostOperationRequestMarshaller(software.amazon.awssdk.services.xml.transform.APostOperationRequestMarshaller) XmlOperationMetadata(software.amazon.awssdk.protocols.xml.XmlOperationMetadata)

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