All Downloads are FREE. Search and download functionalities are using the official Maven repository.

software.amazon.awssdk.services.iot1clickdevices.DefaultIot1ClickDevicesAsyncClient Maven / Gradle / Ivy

/*
 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
 * the License. A copy of the License is located at
 * 
 * http://aws.amazon.com/apache2.0
 * 
 * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
 * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
 * and limitations under the License.
 */

package software.amazon.awssdk.services.iot1clickdevices;

import java.util.Collections;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.annotations.SdkInternalApi;
import software.amazon.awssdk.awscore.client.handler.AwsAsyncClientHandler;
import software.amazon.awssdk.awscore.exception.AwsServiceException;
import software.amazon.awssdk.awscore.internal.AwsProtocolMetadata;
import software.amazon.awssdk.awscore.internal.AwsServiceProtocol;
import software.amazon.awssdk.core.RequestOverrideConfiguration;
import software.amazon.awssdk.core.SdkPlugin;
import software.amazon.awssdk.core.SdkRequest;
import software.amazon.awssdk.core.client.config.SdkClientConfiguration;
import software.amazon.awssdk.core.client.config.SdkClientOption;
import software.amazon.awssdk.core.client.handler.AsyncClientHandler;
import software.amazon.awssdk.core.client.handler.ClientExecutionParams;
import software.amazon.awssdk.core.http.HttpResponseHandler;
import software.amazon.awssdk.core.metrics.CoreMetric;
import software.amazon.awssdk.metrics.MetricCollector;
import software.amazon.awssdk.metrics.MetricPublisher;
import software.amazon.awssdk.metrics.NoOpMetricCollector;
import software.amazon.awssdk.protocols.core.ExceptionMetadata;
import software.amazon.awssdk.protocols.json.AwsJsonProtocol;
import software.amazon.awssdk.protocols.json.AwsJsonProtocolFactory;
import software.amazon.awssdk.protocols.json.BaseAwsJsonProtocolFactory;
import software.amazon.awssdk.protocols.json.JsonOperationMetadata;
import software.amazon.awssdk.services.iot1clickdevices.internal.Iot1ClickDevicesServiceClientConfigurationBuilder;
import software.amazon.awssdk.services.iot1clickdevices.model.ClaimDevicesByClaimCodeRequest;
import software.amazon.awssdk.services.iot1clickdevices.model.ClaimDevicesByClaimCodeResponse;
import software.amazon.awssdk.services.iot1clickdevices.model.DescribeDeviceRequest;
import software.amazon.awssdk.services.iot1clickdevices.model.DescribeDeviceResponse;
import software.amazon.awssdk.services.iot1clickdevices.model.FinalizeDeviceClaimRequest;
import software.amazon.awssdk.services.iot1clickdevices.model.FinalizeDeviceClaimResponse;
import software.amazon.awssdk.services.iot1clickdevices.model.ForbiddenException;
import software.amazon.awssdk.services.iot1clickdevices.model.GetDeviceMethodsRequest;
import software.amazon.awssdk.services.iot1clickdevices.model.GetDeviceMethodsResponse;
import software.amazon.awssdk.services.iot1clickdevices.model.InitiateDeviceClaimRequest;
import software.amazon.awssdk.services.iot1clickdevices.model.InitiateDeviceClaimResponse;
import software.amazon.awssdk.services.iot1clickdevices.model.InternalFailureException;
import software.amazon.awssdk.services.iot1clickdevices.model.InvalidRequestException;
import software.amazon.awssdk.services.iot1clickdevices.model.InvokeDeviceMethodRequest;
import software.amazon.awssdk.services.iot1clickdevices.model.InvokeDeviceMethodResponse;
import software.amazon.awssdk.services.iot1clickdevices.model.Iot1ClickDevicesException;
import software.amazon.awssdk.services.iot1clickdevices.model.ListDeviceEventsRequest;
import software.amazon.awssdk.services.iot1clickdevices.model.ListDeviceEventsResponse;
import software.amazon.awssdk.services.iot1clickdevices.model.ListDevicesRequest;
import software.amazon.awssdk.services.iot1clickdevices.model.ListDevicesResponse;
import software.amazon.awssdk.services.iot1clickdevices.model.ListTagsForResourceRequest;
import software.amazon.awssdk.services.iot1clickdevices.model.ListTagsForResourceResponse;
import software.amazon.awssdk.services.iot1clickdevices.model.PreconditionFailedException;
import software.amazon.awssdk.services.iot1clickdevices.model.RangeNotSatisfiableException;
import software.amazon.awssdk.services.iot1clickdevices.model.ResourceConflictException;
import software.amazon.awssdk.services.iot1clickdevices.model.ResourceNotFoundException;
import software.amazon.awssdk.services.iot1clickdevices.model.TagResourceRequest;
import software.amazon.awssdk.services.iot1clickdevices.model.TagResourceResponse;
import software.amazon.awssdk.services.iot1clickdevices.model.UnclaimDeviceRequest;
import software.amazon.awssdk.services.iot1clickdevices.model.UnclaimDeviceResponse;
import software.amazon.awssdk.services.iot1clickdevices.model.UntagResourceRequest;
import software.amazon.awssdk.services.iot1clickdevices.model.UntagResourceResponse;
import software.amazon.awssdk.services.iot1clickdevices.model.UpdateDeviceStateRequest;
import software.amazon.awssdk.services.iot1clickdevices.model.UpdateDeviceStateResponse;
import software.amazon.awssdk.services.iot1clickdevices.transform.ClaimDevicesByClaimCodeRequestMarshaller;
import software.amazon.awssdk.services.iot1clickdevices.transform.DescribeDeviceRequestMarshaller;
import software.amazon.awssdk.services.iot1clickdevices.transform.FinalizeDeviceClaimRequestMarshaller;
import software.amazon.awssdk.services.iot1clickdevices.transform.GetDeviceMethodsRequestMarshaller;
import software.amazon.awssdk.services.iot1clickdevices.transform.InitiateDeviceClaimRequestMarshaller;
import software.amazon.awssdk.services.iot1clickdevices.transform.InvokeDeviceMethodRequestMarshaller;
import software.amazon.awssdk.services.iot1clickdevices.transform.ListDeviceEventsRequestMarshaller;
import software.amazon.awssdk.services.iot1clickdevices.transform.ListDevicesRequestMarshaller;
import software.amazon.awssdk.services.iot1clickdevices.transform.ListTagsForResourceRequestMarshaller;
import software.amazon.awssdk.services.iot1clickdevices.transform.TagResourceRequestMarshaller;
import software.amazon.awssdk.services.iot1clickdevices.transform.UnclaimDeviceRequestMarshaller;
import software.amazon.awssdk.services.iot1clickdevices.transform.UntagResourceRequestMarshaller;
import software.amazon.awssdk.services.iot1clickdevices.transform.UpdateDeviceStateRequestMarshaller;
import software.amazon.awssdk.utils.CompletableFutureUtils;

/**
 * Internal implementation of {@link Iot1ClickDevicesAsyncClient}.
 *
 * @see Iot1ClickDevicesAsyncClient#builder()
 */
@Generated("software.amazon.awssdk:codegen")
@SdkInternalApi
final class DefaultIot1ClickDevicesAsyncClient implements Iot1ClickDevicesAsyncClient {
    private static final Logger log = LoggerFactory.getLogger(DefaultIot1ClickDevicesAsyncClient.class);

    private static final AwsProtocolMetadata protocolMetadata = AwsProtocolMetadata.builder()
            .serviceProtocol(AwsServiceProtocol.REST_JSON).build();

    private final AsyncClientHandler clientHandler;

    private final AwsJsonProtocolFactory protocolFactory;

    private final SdkClientConfiguration clientConfiguration;

    protected DefaultIot1ClickDevicesAsyncClient(SdkClientConfiguration clientConfiguration) {
        this.clientHandler = new AwsAsyncClientHandler(clientConfiguration);
        this.clientConfiguration = clientConfiguration.toBuilder().option(SdkClientOption.SDK_CLIENT, this).build();
        this.protocolFactory = init(AwsJsonProtocolFactory.builder()).build();
    }

    /**
     * 

* Adds device(s) to your account (i.e., claim one or more devices) if and only if you received a claim code with * the device(s). *

* * @param claimDevicesByClaimCodeRequest * @return A Java Future containing the result of the ClaimDevicesByClaimCode operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. The exception returned is wrapped with CompletionException, so you need to invoke * {@link Throwable#getCause} to retrieve the underlying exception. *
    *
  • InvalidRequestException 400 response
  • *
  • InternalFailureException 500 response
  • *
  • ForbiddenException 403 response
  • *
  • SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.
  • *
  • SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.
  • *
  • Iot1ClickDevicesException Base class for all service exceptions. Unknown exceptions will be thrown as * an instance of this type.
  • *
* @sample Iot1ClickDevicesAsyncClient.ClaimDevicesByClaimCode * @see AWS API Documentation */ @Override public CompletableFuture claimDevicesByClaimCode( ClaimDevicesByClaimCodeRequest claimDevicesByClaimCodeRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(claimDevicesByClaimCodeRequest, this.clientConfiguration); List metricPublishers = resolveMetricPublishers(clientConfiguration, claimDevicesByClaimCodeRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "IoT 1Click Devices Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "ClaimDevicesByClaimCode"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler( operationMetadata, ClaimDevicesByClaimCodeResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture executeFuture = clientHandler .execute(new ClientExecutionParams() .withOperationName("ClaimDevicesByClaimCode").withProtocolMetadata(protocolMetadata) .withMarshaller(new ClaimDevicesByClaimCodeRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(claimDevicesByClaimCodeRequest)); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return executeFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** *

* Given a device ID, returns a DescribeDeviceResponse object describing the details of the device. *

* * @param describeDeviceRequest * @return A Java Future containing the result of the DescribeDevice operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. The exception returned is wrapped with CompletionException, so you need to invoke * {@link Throwable#getCause} to retrieve the underlying exception. *
    *
  • ResourceNotFoundException 404 response
  • *
  • InvalidRequestException 400 response
  • *
  • InternalFailureException 500 response
  • *
  • SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.
  • *
  • SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.
  • *
  • Iot1ClickDevicesException Base class for all service exceptions. Unknown exceptions will be thrown as * an instance of this type.
  • *
* @sample Iot1ClickDevicesAsyncClient.DescribeDevice * @see AWS API * Documentation */ @Override public CompletableFuture describeDevice(DescribeDeviceRequest describeDeviceRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(describeDeviceRequest, this.clientConfiguration); List metricPublishers = resolveMetricPublishers(clientConfiguration, describeDeviceRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "IoT 1Click Devices Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "DescribeDevice"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler( operationMetadata, DescribeDeviceResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture executeFuture = clientHandler .execute(new ClientExecutionParams() .withOperationName("DescribeDevice").withProtocolMetadata(protocolMetadata) .withMarshaller(new DescribeDeviceRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(describeDeviceRequest)); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return executeFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** *

* Given a device ID, finalizes the claim request for the associated device. *

* *

* Claiming a device consists of initiating a claim, then publishing a device event, and finalizing the claim. For a * device of type button, a device event can be published by simply clicking the device. *

*
* * @param finalizeDeviceClaimRequest * @return A Java Future containing the result of the FinalizeDeviceClaim operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. The exception returned is wrapped with CompletionException, so you need to invoke * {@link Throwable#getCause} to retrieve the underlying exception. *
    *
  • ResourceNotFoundException 404 response
  • *
  • InvalidRequestException 400 response
  • *
  • InternalFailureException 500 response
  • *
  • PreconditionFailedException 412 response
  • *
  • ResourceConflictException 409 response
  • *
  • SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.
  • *
  • SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.
  • *
  • Iot1ClickDevicesException Base class for all service exceptions. Unknown exceptions will be thrown as * an instance of this type.
  • *
* @sample Iot1ClickDevicesAsyncClient.FinalizeDeviceClaim * @see AWS * API Documentation */ @Override public CompletableFuture finalizeDeviceClaim( FinalizeDeviceClaimRequest finalizeDeviceClaimRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(finalizeDeviceClaimRequest, this.clientConfiguration); List metricPublishers = resolveMetricPublishers(clientConfiguration, finalizeDeviceClaimRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "IoT 1Click Devices Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "FinalizeDeviceClaim"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler( operationMetadata, FinalizeDeviceClaimResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture executeFuture = clientHandler .execute(new ClientExecutionParams() .withOperationName("FinalizeDeviceClaim").withProtocolMetadata(protocolMetadata) .withMarshaller(new FinalizeDeviceClaimRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(finalizeDeviceClaimRequest)); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return executeFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** *

* Given a device ID, returns the invokable methods associated with the device. *

* * @param getDeviceMethodsRequest * @return A Java Future containing the result of the GetDeviceMethods operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. The exception returned is wrapped with CompletionException, so you need to invoke * {@link Throwable#getCause} to retrieve the underlying exception. *
    *
  • ResourceNotFoundException 404 response
  • *
  • InvalidRequestException 400 response
  • *
  • InternalFailureException 500 response
  • *
  • SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.
  • *
  • SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.
  • *
  • Iot1ClickDevicesException Base class for all service exceptions. Unknown exceptions will be thrown as * an instance of this type.
  • *
* @sample Iot1ClickDevicesAsyncClient.GetDeviceMethods * @see AWS API * Documentation */ @Override public CompletableFuture getDeviceMethods(GetDeviceMethodsRequest getDeviceMethodsRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(getDeviceMethodsRequest, this.clientConfiguration); List metricPublishers = resolveMetricPublishers(clientConfiguration, getDeviceMethodsRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "IoT 1Click Devices Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetDeviceMethods"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler( operationMetadata, GetDeviceMethodsResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture executeFuture = clientHandler .execute(new ClientExecutionParams() .withOperationName("GetDeviceMethods").withProtocolMetadata(protocolMetadata) .withMarshaller(new GetDeviceMethodsRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(getDeviceMethodsRequest)); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return executeFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** *

* Given a device ID, initiates a claim request for the associated device. *

* *

* Claiming a device consists of initiating a claim, then publishing a device event, and finalizing the claim. For a * device of type button, a device event can be published by simply clicking the device. *

*
* * @param initiateDeviceClaimRequest * @return A Java Future containing the result of the InitiateDeviceClaim operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. The exception returned is wrapped with CompletionException, so you need to invoke * {@link Throwable#getCause} to retrieve the underlying exception. *
    *
  • ResourceNotFoundException 404 response
  • *
  • InvalidRequestException 400 response
  • *
  • InternalFailureException 500 response
  • *
  • ResourceConflictException 409 response
  • *
  • SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.
  • *
  • SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.
  • *
  • Iot1ClickDevicesException Base class for all service exceptions. Unknown exceptions will be thrown as * an instance of this type.
  • *
* @sample Iot1ClickDevicesAsyncClient.InitiateDeviceClaim * @see AWS * API Documentation */ @Override public CompletableFuture initiateDeviceClaim( InitiateDeviceClaimRequest initiateDeviceClaimRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(initiateDeviceClaimRequest, this.clientConfiguration); List metricPublishers = resolveMetricPublishers(clientConfiguration, initiateDeviceClaimRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "IoT 1Click Devices Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "InitiateDeviceClaim"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler( operationMetadata, InitiateDeviceClaimResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture executeFuture = clientHandler .execute(new ClientExecutionParams() .withOperationName("InitiateDeviceClaim").withProtocolMetadata(protocolMetadata) .withMarshaller(new InitiateDeviceClaimRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(initiateDeviceClaimRequest)); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return executeFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** *

* Given a device ID, issues a request to invoke a named device method (with possible parameters). See the * "Example POST" code snippet below. *

* * @param invokeDeviceMethodRequest * @return A Java Future containing the result of the InvokeDeviceMethod operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. The exception returned is wrapped with CompletionException, so you need to invoke * {@link Throwable#getCause} to retrieve the underlying exception. *
    *
  • InvalidRequestException 400 response
  • *
  • PreconditionFailedException 412 response
  • *
  • InternalFailureException 500 response
  • *
  • ResourceNotFoundException 404 response
  • *
  • RangeNotSatisfiableException 416 response
  • *
  • ResourceConflictException 409 response
  • *
  • SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.
  • *
  • SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.
  • *
  • Iot1ClickDevicesException Base class for all service exceptions. Unknown exceptions will be thrown as * an instance of this type.
  • *
* @sample Iot1ClickDevicesAsyncClient.InvokeDeviceMethod * @see AWS * API Documentation */ @Override public CompletableFuture invokeDeviceMethod(InvokeDeviceMethodRequest invokeDeviceMethodRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(invokeDeviceMethodRequest, this.clientConfiguration); List metricPublishers = resolveMetricPublishers(clientConfiguration, invokeDeviceMethodRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "IoT 1Click Devices Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "InvokeDeviceMethod"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler( operationMetadata, InvokeDeviceMethodResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture executeFuture = clientHandler .execute(new ClientExecutionParams() .withOperationName("InvokeDeviceMethod").withProtocolMetadata(protocolMetadata) .withMarshaller(new InvokeDeviceMethodRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(invokeDeviceMethodRequest)); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return executeFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** *

* Using a device ID, returns a DeviceEventsResponse object containing an array of events for the device. *

* * @param listDeviceEventsRequest * @return A Java Future containing the result of the ListDeviceEvents operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. The exception returned is wrapped with CompletionException, so you need to invoke * {@link Throwable#getCause} to retrieve the underlying exception. *
    *
  • ResourceNotFoundException 404 response
  • *
  • RangeNotSatisfiableException 416 response
  • *
  • InvalidRequestException 400 response
  • *
  • InternalFailureException 500 response
  • *
  • SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.
  • *
  • SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.
  • *
  • Iot1ClickDevicesException Base class for all service exceptions. Unknown exceptions will be thrown as * an instance of this type.
  • *
* @sample Iot1ClickDevicesAsyncClient.ListDeviceEvents * @see AWS API * Documentation */ @Override public CompletableFuture listDeviceEvents(ListDeviceEventsRequest listDeviceEventsRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(listDeviceEventsRequest, this.clientConfiguration); List metricPublishers = resolveMetricPublishers(clientConfiguration, listDeviceEventsRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "IoT 1Click Devices Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "ListDeviceEvents"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler( operationMetadata, ListDeviceEventsResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture executeFuture = clientHandler .execute(new ClientExecutionParams() .withOperationName("ListDeviceEvents").withProtocolMetadata(protocolMetadata) .withMarshaller(new ListDeviceEventsRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(listDeviceEventsRequest)); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return executeFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** *

* Lists the 1-Click compatible devices associated with your AWS account. *

* * @param listDevicesRequest * @return A Java Future containing the result of the ListDevices operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. The exception returned is wrapped with CompletionException, so you need to invoke * {@link Throwable#getCause} to retrieve the underlying exception. *
    *
  • RangeNotSatisfiableException 416 response
  • *
  • InvalidRequestException 400 response
  • *
  • InternalFailureException 500 response
  • *
  • SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.
  • *
  • SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.
  • *
  • Iot1ClickDevicesException Base class for all service exceptions. Unknown exceptions will be thrown as * an instance of this type.
  • *
* @sample Iot1ClickDevicesAsyncClient.ListDevices * @see AWS API * Documentation */ @Override public CompletableFuture listDevices(ListDevicesRequest listDevicesRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(listDevicesRequest, this.clientConfiguration); List metricPublishers = resolveMetricPublishers(clientConfiguration, listDevicesRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "IoT 1Click Devices Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "ListDevices"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata, ListDevicesResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture executeFuture = clientHandler .execute(new ClientExecutionParams() .withOperationName("ListDevices").withProtocolMetadata(protocolMetadata) .withMarshaller(new ListDevicesRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(listDevicesRequest)); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return executeFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** *

* Lists the tags associated with the specified resource ARN. *

* * @param listTagsForResourceRequest * @return A Java Future containing the result of the ListTagsForResource operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. The exception returned is wrapped with CompletionException, so you need to invoke * {@link Throwable#getCause} to retrieve the underlying exception. *
    *
  • ResourceNotFoundException 404 response
  • *
  • InternalFailureException 500 response
  • *
  • SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.
  • *
  • SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.
  • *
  • Iot1ClickDevicesException Base class for all service exceptions. Unknown exceptions will be thrown as * an instance of this type.
  • *
* @sample Iot1ClickDevicesAsyncClient.ListTagsForResource * @see AWS * API Documentation */ @Override public CompletableFuture listTagsForResource( ListTagsForResourceRequest listTagsForResourceRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(listTagsForResourceRequest, this.clientConfiguration); List metricPublishers = resolveMetricPublishers(clientConfiguration, listTagsForResourceRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "IoT 1Click Devices Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "ListTagsForResource"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler( operationMetadata, ListTagsForResourceResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture executeFuture = clientHandler .execute(new ClientExecutionParams() .withOperationName("ListTagsForResource").withProtocolMetadata(protocolMetadata) .withMarshaller(new ListTagsForResourceRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(listTagsForResourceRequest)); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return executeFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** *

* Adds or updates the tags associated with the resource ARN. See AWS IoT * 1-Click Service Limits for the maximum number of tags allowed per resource. *

* * @param tagResourceRequest * @return A Java Future containing the result of the TagResource operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. The exception returned is wrapped with CompletionException, so you need to invoke * {@link Throwable#getCause} to retrieve the underlying exception. *
    *
  • ResourceNotFoundException 404 response
  • *
  • InvalidRequestException 400 response
  • *
  • InternalFailureException 500 response
  • *
  • SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.
  • *
  • SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.
  • *
  • Iot1ClickDevicesException Base class for all service exceptions. Unknown exceptions will be thrown as * an instance of this type.
  • *
* @sample Iot1ClickDevicesAsyncClient.TagResource * @see AWS API * Documentation */ @Override public CompletableFuture tagResource(TagResourceRequest tagResourceRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(tagResourceRequest, this.clientConfiguration); List metricPublishers = resolveMetricPublishers(clientConfiguration, tagResourceRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "IoT 1Click Devices Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "TagResource"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata, TagResourceResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture executeFuture = clientHandler .execute(new ClientExecutionParams() .withOperationName("TagResource").withProtocolMetadata(protocolMetadata) .withMarshaller(new TagResourceRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(tagResourceRequest)); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return executeFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** *

* Disassociates a device from your AWS account using its device ID. *

* * @param unclaimDeviceRequest * @return A Java Future containing the result of the UnclaimDevice operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. The exception returned is wrapped with CompletionException, so you need to invoke * {@link Throwable#getCause} to retrieve the underlying exception. *
    *
  • ResourceNotFoundException 404 response
  • *
  • InvalidRequestException 400 response
  • *
  • InternalFailureException 500 response
  • *
  • SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.
  • *
  • SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.
  • *
  • Iot1ClickDevicesException Base class for all service exceptions. Unknown exceptions will be thrown as * an instance of this type.
  • *
* @sample Iot1ClickDevicesAsyncClient.UnclaimDevice * @see AWS API * Documentation */ @Override public CompletableFuture unclaimDevice(UnclaimDeviceRequest unclaimDeviceRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(unclaimDeviceRequest, this.clientConfiguration); List metricPublishers = resolveMetricPublishers(clientConfiguration, unclaimDeviceRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "IoT 1Click Devices Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "UnclaimDevice"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata, UnclaimDeviceResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture executeFuture = clientHandler .execute(new ClientExecutionParams() .withOperationName("UnclaimDevice").withProtocolMetadata(protocolMetadata) .withMarshaller(new UnclaimDeviceRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(unclaimDeviceRequest)); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return executeFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** *

* Using tag keys, deletes the tags (key/value pairs) associated with the specified resource ARN. *

* * @param untagResourceRequest * @return A Java Future containing the result of the UntagResource operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. The exception returned is wrapped with CompletionException, so you need to invoke * {@link Throwable#getCause} to retrieve the underlying exception. *
    *
  • ResourceNotFoundException 404 response
  • *
  • InvalidRequestException 400 response
  • *
  • InternalFailureException 500 response
  • *
  • SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.
  • *
  • SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.
  • *
  • Iot1ClickDevicesException Base class for all service exceptions. Unknown exceptions will be thrown as * an instance of this type.
  • *
* @sample Iot1ClickDevicesAsyncClient.UntagResource * @see AWS API * Documentation */ @Override public CompletableFuture untagResource(UntagResourceRequest untagResourceRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(untagResourceRequest, this.clientConfiguration); List metricPublishers = resolveMetricPublishers(clientConfiguration, untagResourceRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "IoT 1Click Devices Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "UntagResource"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata, UntagResourceResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture executeFuture = clientHandler .execute(new ClientExecutionParams() .withOperationName("UntagResource").withProtocolMetadata(protocolMetadata) .withMarshaller(new UntagResourceRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(untagResourceRequest)); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return executeFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** *

* Using a Boolean value (true or false), this operation enables or disables the device given a device ID. *

* * @param updateDeviceStateRequest * @return A Java Future containing the result of the UpdateDeviceState operation returned by the service.
* The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. The exception returned is wrapped with CompletionException, so you need to invoke * {@link Throwable#getCause} to retrieve the underlying exception. *
    *
  • ResourceNotFoundException 404 response
  • *
  • InvalidRequestException 400 response
  • *
  • InternalFailureException 500 response
  • *
  • SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.
  • *
  • SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.
  • *
  • Iot1ClickDevicesException Base class for all service exceptions. Unknown exceptions will be thrown as * an instance of this type.
  • *
* @sample Iot1ClickDevicesAsyncClient.UpdateDeviceState * @see AWS API * Documentation */ @Override public CompletableFuture updateDeviceState(UpdateDeviceStateRequest updateDeviceStateRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(updateDeviceStateRequest, this.clientConfiguration); List metricPublishers = resolveMetricPublishers(clientConfiguration, updateDeviceStateRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "IoT 1Click Devices Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "UpdateDeviceState"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler( operationMetadata, UpdateDeviceStateResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture executeFuture = clientHandler .execute(new ClientExecutionParams() .withOperationName("UpdateDeviceState").withProtocolMetadata(protocolMetadata) .withMarshaller(new UpdateDeviceStateRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(updateDeviceStateRequest)); CompletableFuture whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return executeFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } @Override public final Iot1ClickDevicesServiceClientConfiguration serviceClientConfiguration() { return new Iot1ClickDevicesServiceClientConfigurationBuilder(this.clientConfiguration.toBuilder()).build(); } @Override public final String serviceName() { return SERVICE_NAME; } private > T init(T builder) { return builder .clientConfiguration(clientConfiguration) .defaultServiceExceptionSupplier(Iot1ClickDevicesException::builder) .protocol(AwsJsonProtocol.REST_JSON) .protocolVersion("1.1") .registerModeledException( ExceptionMetadata.builder().errorCode("InternalFailureException") .exceptionBuilderSupplier(InternalFailureException::builder).httpStatusCode(500).build()) .registerModeledException( ExceptionMetadata.builder().errorCode("InvalidRequestException") .exceptionBuilderSupplier(InvalidRequestException::builder).httpStatusCode(400).build()) .registerModeledException( ExceptionMetadata.builder().errorCode("PreconditionFailedException") .exceptionBuilderSupplier(PreconditionFailedException::builder).httpStatusCode(412).build()) .registerModeledException( ExceptionMetadata.builder().errorCode("ResourceNotFoundException") .exceptionBuilderSupplier(ResourceNotFoundException::builder).httpStatusCode(404).build()) .registerModeledException( ExceptionMetadata.builder().errorCode("RangeNotSatisfiableException") .exceptionBuilderSupplier(RangeNotSatisfiableException::builder).httpStatusCode(416).build()) .registerModeledException( ExceptionMetadata.builder().errorCode("ForbiddenException") .exceptionBuilderSupplier(ForbiddenException::builder).httpStatusCode(403).build()) .registerModeledException( ExceptionMetadata.builder().errorCode("ResourceConflictException") .exceptionBuilderSupplier(ResourceConflictException::builder).httpStatusCode(409).build()); } private static List resolveMetricPublishers(SdkClientConfiguration clientConfiguration, RequestOverrideConfiguration requestOverrideConfiguration) { List publishers = null; if (requestOverrideConfiguration != null) { publishers = requestOverrideConfiguration.metricPublishers(); } if (publishers == null || publishers.isEmpty()) { publishers = clientConfiguration.option(SdkClientOption.METRIC_PUBLISHERS); } if (publishers == null) { publishers = Collections.emptyList(); } return publishers; } private SdkClientConfiguration updateSdkClientConfiguration(SdkRequest request, SdkClientConfiguration clientConfiguration) { List plugins = request.overrideConfiguration().map(c -> c.plugins()).orElse(Collections.emptyList()); SdkClientConfiguration.Builder configuration = clientConfiguration.toBuilder(); if (plugins.isEmpty()) { return configuration.build(); } Iot1ClickDevicesServiceClientConfigurationBuilder serviceConfigBuilder = new Iot1ClickDevicesServiceClientConfigurationBuilder( configuration); for (SdkPlugin plugin : plugins) { plugin.configureClient(serviceConfigBuilder); } return configuration.build(); } private HttpResponseHandler createErrorResponseHandler(BaseAwsJsonProtocolFactory protocolFactory, JsonOperationMetadata operationMetadata) { return protocolFactory.createErrorResponseHandler(operationMetadata); } @Override public void close() { clientHandler.close(); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy