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

software.amazon.awssdk.services.iot1clickprojects.DefaultIot1ClickProjectsClient 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.iot1clickprojects;

import java.util.Collections;
import java.util.List;
import java.util.function.Consumer;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.annotations.SdkInternalApi;
import software.amazon.awssdk.awscore.AwsRequestOverrideConfiguration;
import software.amazon.awssdk.awscore.client.handler.AwsSyncClientHandler;
import software.amazon.awssdk.awscore.exception.AwsServiceException;
import software.amazon.awssdk.core.ApiName;
import software.amazon.awssdk.core.RequestOverrideConfiguration;
import software.amazon.awssdk.core.client.config.SdkClientConfiguration;
import software.amazon.awssdk.core.client.config.SdkClientOption;
import software.amazon.awssdk.core.client.handler.ClientExecutionParams;
import software.amazon.awssdk.core.client.handler.SyncClientHandler;
import software.amazon.awssdk.core.exception.SdkClientException;
import software.amazon.awssdk.core.http.HttpResponseHandler;
import software.amazon.awssdk.core.metrics.CoreMetric;
import software.amazon.awssdk.core.util.VersionInfo;
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.iot1clickprojects.model.AssociateDeviceWithPlacementRequest;
import software.amazon.awssdk.services.iot1clickprojects.model.AssociateDeviceWithPlacementResponse;
import software.amazon.awssdk.services.iot1clickprojects.model.CreatePlacementRequest;
import software.amazon.awssdk.services.iot1clickprojects.model.CreatePlacementResponse;
import software.amazon.awssdk.services.iot1clickprojects.model.CreateProjectRequest;
import software.amazon.awssdk.services.iot1clickprojects.model.CreateProjectResponse;
import software.amazon.awssdk.services.iot1clickprojects.model.DeletePlacementRequest;
import software.amazon.awssdk.services.iot1clickprojects.model.DeletePlacementResponse;
import software.amazon.awssdk.services.iot1clickprojects.model.DeleteProjectRequest;
import software.amazon.awssdk.services.iot1clickprojects.model.DeleteProjectResponse;
import software.amazon.awssdk.services.iot1clickprojects.model.DescribePlacementRequest;
import software.amazon.awssdk.services.iot1clickprojects.model.DescribePlacementResponse;
import software.amazon.awssdk.services.iot1clickprojects.model.DescribeProjectRequest;
import software.amazon.awssdk.services.iot1clickprojects.model.DescribeProjectResponse;
import software.amazon.awssdk.services.iot1clickprojects.model.DisassociateDeviceFromPlacementRequest;
import software.amazon.awssdk.services.iot1clickprojects.model.DisassociateDeviceFromPlacementResponse;
import software.amazon.awssdk.services.iot1clickprojects.model.GetDevicesInPlacementRequest;
import software.amazon.awssdk.services.iot1clickprojects.model.GetDevicesInPlacementResponse;
import software.amazon.awssdk.services.iot1clickprojects.model.InternalFailureException;
import software.amazon.awssdk.services.iot1clickprojects.model.InvalidRequestException;
import software.amazon.awssdk.services.iot1clickprojects.model.Iot1ClickProjectsException;
import software.amazon.awssdk.services.iot1clickprojects.model.Iot1ClickProjectsRequest;
import software.amazon.awssdk.services.iot1clickprojects.model.ListPlacementsRequest;
import software.amazon.awssdk.services.iot1clickprojects.model.ListPlacementsResponse;
import software.amazon.awssdk.services.iot1clickprojects.model.ListProjectsRequest;
import software.amazon.awssdk.services.iot1clickprojects.model.ListProjectsResponse;
import software.amazon.awssdk.services.iot1clickprojects.model.ListTagsForResourceRequest;
import software.amazon.awssdk.services.iot1clickprojects.model.ListTagsForResourceResponse;
import software.amazon.awssdk.services.iot1clickprojects.model.ResourceConflictException;
import software.amazon.awssdk.services.iot1clickprojects.model.ResourceNotFoundException;
import software.amazon.awssdk.services.iot1clickprojects.model.TagResourceRequest;
import software.amazon.awssdk.services.iot1clickprojects.model.TagResourceResponse;
import software.amazon.awssdk.services.iot1clickprojects.model.TooManyRequestsException;
import software.amazon.awssdk.services.iot1clickprojects.model.UntagResourceRequest;
import software.amazon.awssdk.services.iot1clickprojects.model.UntagResourceResponse;
import software.amazon.awssdk.services.iot1clickprojects.model.UpdatePlacementRequest;
import software.amazon.awssdk.services.iot1clickprojects.model.UpdatePlacementResponse;
import software.amazon.awssdk.services.iot1clickprojects.model.UpdateProjectRequest;
import software.amazon.awssdk.services.iot1clickprojects.model.UpdateProjectResponse;
import software.amazon.awssdk.services.iot1clickprojects.paginators.ListPlacementsIterable;
import software.amazon.awssdk.services.iot1clickprojects.paginators.ListProjectsIterable;
import software.amazon.awssdk.services.iot1clickprojects.transform.AssociateDeviceWithPlacementRequestMarshaller;
import software.amazon.awssdk.services.iot1clickprojects.transform.CreatePlacementRequestMarshaller;
import software.amazon.awssdk.services.iot1clickprojects.transform.CreateProjectRequestMarshaller;
import software.amazon.awssdk.services.iot1clickprojects.transform.DeletePlacementRequestMarshaller;
import software.amazon.awssdk.services.iot1clickprojects.transform.DeleteProjectRequestMarshaller;
import software.amazon.awssdk.services.iot1clickprojects.transform.DescribePlacementRequestMarshaller;
import software.amazon.awssdk.services.iot1clickprojects.transform.DescribeProjectRequestMarshaller;
import software.amazon.awssdk.services.iot1clickprojects.transform.DisassociateDeviceFromPlacementRequestMarshaller;
import software.amazon.awssdk.services.iot1clickprojects.transform.GetDevicesInPlacementRequestMarshaller;
import software.amazon.awssdk.services.iot1clickprojects.transform.ListPlacementsRequestMarshaller;
import software.amazon.awssdk.services.iot1clickprojects.transform.ListProjectsRequestMarshaller;
import software.amazon.awssdk.services.iot1clickprojects.transform.ListTagsForResourceRequestMarshaller;
import software.amazon.awssdk.services.iot1clickprojects.transform.TagResourceRequestMarshaller;
import software.amazon.awssdk.services.iot1clickprojects.transform.UntagResourceRequestMarshaller;
import software.amazon.awssdk.services.iot1clickprojects.transform.UpdatePlacementRequestMarshaller;
import software.amazon.awssdk.services.iot1clickprojects.transform.UpdateProjectRequestMarshaller;
import software.amazon.awssdk.utils.Logger;

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

    private final SyncClientHandler clientHandler;

    private final AwsJsonProtocolFactory protocolFactory;

    private final SdkClientConfiguration clientConfiguration;

    private final Iot1ClickProjectsServiceClientConfiguration serviceClientConfiguration;

    protected DefaultIot1ClickProjectsClient(Iot1ClickProjectsServiceClientConfiguration serviceClientConfiguration,
            SdkClientConfiguration clientConfiguration) {
        this.clientHandler = new AwsSyncClientHandler(clientConfiguration);
        this.clientConfiguration = clientConfiguration;
        this.serviceClientConfiguration = serviceClientConfiguration;
        this.protocolFactory = init(AwsJsonProtocolFactory.builder()).build();
    }

    /**
     * 

* Associates a physical device with a placement. *

* * @param associateDeviceWithPlacementRequest * @return Result of the AssociateDeviceWithPlacement operation returned by the service. * @throws InternalFailureException * @throws InvalidRequestException * @throws ResourceConflictException * @throws ResourceNotFoundException * @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 Iot1ClickProjectsException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample Iot1ClickProjectsClient.AssociateDeviceWithPlacement * @see AWS API Documentation */ @Override public AssociateDeviceWithPlacementResponse associateDeviceWithPlacement( AssociateDeviceWithPlacementRequest associateDeviceWithPlacementRequest) throws InternalFailureException, InvalidRequestException, ResourceConflictException, ResourceNotFoundException, AwsServiceException, SdkClientException, Iot1ClickProjectsException { JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler( operationMetadata, AssociateDeviceWithPlacementResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); List metricPublishers = resolveMetricPublishers(clientConfiguration, associateDeviceWithPlacementRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "IoT 1Click Projects"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "AssociateDeviceWithPlacement"); return clientHandler .execute(new ClientExecutionParams() .withOperationName("AssociateDeviceWithPlacement").withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler).withInput(associateDeviceWithPlacementRequest) .withMetricCollector(apiCallMetricCollector) .withMarshaller(new AssociateDeviceWithPlacementRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } /** *

* Creates an empty placement. *

* * @param createPlacementRequest * @return Result of the CreatePlacement operation returned by the service. * @throws InternalFailureException * @throws InvalidRequestException * @throws ResourceConflictException * @throws ResourceNotFoundException * @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 Iot1ClickProjectsException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample Iot1ClickProjectsClient.CreatePlacement * @see AWS API Documentation */ @Override public CreatePlacementResponse createPlacement(CreatePlacementRequest createPlacementRequest) throws InternalFailureException, InvalidRequestException, ResourceConflictException, ResourceNotFoundException, AwsServiceException, SdkClientException, Iot1ClickProjectsException { JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata, CreatePlacementResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); List metricPublishers = resolveMetricPublishers(clientConfiguration, createPlacementRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "IoT 1Click Projects"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "CreatePlacement"); return clientHandler.execute(new ClientExecutionParams() .withOperationName("CreatePlacement").withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler).withInput(createPlacementRequest) .withMetricCollector(apiCallMetricCollector) .withMarshaller(new CreatePlacementRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } /** *

* Creates an empty project with a placement template. A project contains zero or more placements that adhere to the * placement template defined in the project. *

* * @param createProjectRequest * @return Result of the CreateProject operation returned by the service. * @throws InternalFailureException * @throws InvalidRequestException * @throws ResourceConflictException * @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 Iot1ClickProjectsException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample Iot1ClickProjectsClient.CreateProject * @see AWS API Documentation */ @Override public CreateProjectResponse createProject(CreateProjectRequest createProjectRequest) throws InternalFailureException, InvalidRequestException, ResourceConflictException, AwsServiceException, SdkClientException, Iot1ClickProjectsException { JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata, CreateProjectResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); List metricPublishers = resolveMetricPublishers(clientConfiguration, createProjectRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "IoT 1Click Projects"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "CreateProject"); return clientHandler.execute(new ClientExecutionParams() .withOperationName("CreateProject").withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler).withInput(createProjectRequest) .withMetricCollector(apiCallMetricCollector) .withMarshaller(new CreateProjectRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } /** *

* Deletes a placement. To delete a placement, it must not have any devices associated with it. *

* *

* When you delete a placement, all associated data becomes irretrievable. *

*
* * @param deletePlacementRequest * @return Result of the DeletePlacement operation returned by the service. * @throws InternalFailureException * @throws InvalidRequestException * @throws ResourceNotFoundException * @throws TooManyRequestsException * @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 Iot1ClickProjectsException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample Iot1ClickProjectsClient.DeletePlacement * @see AWS API Documentation */ @Override public DeletePlacementResponse deletePlacement(DeletePlacementRequest deletePlacementRequest) throws InternalFailureException, InvalidRequestException, ResourceNotFoundException, TooManyRequestsException, AwsServiceException, SdkClientException, Iot1ClickProjectsException { JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata, DeletePlacementResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); List metricPublishers = resolveMetricPublishers(clientConfiguration, deletePlacementRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "IoT 1Click Projects"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "DeletePlacement"); return clientHandler.execute(new ClientExecutionParams() .withOperationName("DeletePlacement").withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler).withInput(deletePlacementRequest) .withMetricCollector(apiCallMetricCollector) .withMarshaller(new DeletePlacementRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } /** *

* Deletes a project. To delete a project, it must not have any placements associated with it. *

* *

* When you delete a project, all associated data becomes irretrievable. *

*
* * @param deleteProjectRequest * @return Result of the DeleteProject operation returned by the service. * @throws InternalFailureException * @throws InvalidRequestException * @throws ResourceNotFoundException * @throws TooManyRequestsException * @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 Iot1ClickProjectsException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample Iot1ClickProjectsClient.DeleteProject * @see AWS API Documentation */ @Override public DeleteProjectResponse deleteProject(DeleteProjectRequest deleteProjectRequest) throws InternalFailureException, InvalidRequestException, ResourceNotFoundException, TooManyRequestsException, AwsServiceException, SdkClientException, Iot1ClickProjectsException { JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata, DeleteProjectResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); List metricPublishers = resolveMetricPublishers(clientConfiguration, deleteProjectRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "IoT 1Click Projects"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "DeleteProject"); return clientHandler.execute(new ClientExecutionParams() .withOperationName("DeleteProject").withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler).withInput(deleteProjectRequest) .withMetricCollector(apiCallMetricCollector) .withMarshaller(new DeleteProjectRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } /** *

* Describes a placement in a project. *

* * @param describePlacementRequest * @return Result of the DescribePlacement operation returned by the service. * @throws InternalFailureException * @throws InvalidRequestException * @throws ResourceNotFoundException * @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 Iot1ClickProjectsException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample Iot1ClickProjectsClient.DescribePlacement * @see AWS API Documentation */ @Override public DescribePlacementResponse describePlacement(DescribePlacementRequest describePlacementRequest) throws InternalFailureException, InvalidRequestException, ResourceNotFoundException, AwsServiceException, SdkClientException, Iot1ClickProjectsException { JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata, DescribePlacementResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); List metricPublishers = resolveMetricPublishers(clientConfiguration, describePlacementRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "IoT 1Click Projects"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "DescribePlacement"); return clientHandler.execute(new ClientExecutionParams() .withOperationName("DescribePlacement").withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler).withInput(describePlacementRequest) .withMetricCollector(apiCallMetricCollector) .withMarshaller(new DescribePlacementRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } /** *

* Returns an object describing a project. *

* * @param describeProjectRequest * @return Result of the DescribeProject operation returned by the service. * @throws InternalFailureException * @throws InvalidRequestException * @throws ResourceNotFoundException * @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 Iot1ClickProjectsException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample Iot1ClickProjectsClient.DescribeProject * @see AWS API Documentation */ @Override public DescribeProjectResponse describeProject(DescribeProjectRequest describeProjectRequest) throws InternalFailureException, InvalidRequestException, ResourceNotFoundException, AwsServiceException, SdkClientException, Iot1ClickProjectsException { JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata, DescribeProjectResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); List metricPublishers = resolveMetricPublishers(clientConfiguration, describeProjectRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "IoT 1Click Projects"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "DescribeProject"); return clientHandler.execute(new ClientExecutionParams() .withOperationName("DescribeProject").withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler).withInput(describeProjectRequest) .withMetricCollector(apiCallMetricCollector) .withMarshaller(new DescribeProjectRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } /** *

* Removes a physical device from a placement. *

* * @param disassociateDeviceFromPlacementRequest * @return Result of the DisassociateDeviceFromPlacement operation returned by the service. * @throws InternalFailureException * @throws InvalidRequestException * @throws ResourceNotFoundException * @throws TooManyRequestsException * @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 Iot1ClickProjectsException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample Iot1ClickProjectsClient.DisassociateDeviceFromPlacement * @see AWS API Documentation */ @Override public DisassociateDeviceFromPlacementResponse disassociateDeviceFromPlacement( DisassociateDeviceFromPlacementRequest disassociateDeviceFromPlacementRequest) throws InternalFailureException, InvalidRequestException, ResourceNotFoundException, TooManyRequestsException, AwsServiceException, SdkClientException, Iot1ClickProjectsException { JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler( operationMetadata, DisassociateDeviceFromPlacementResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); List metricPublishers = resolveMetricPublishers(clientConfiguration, disassociateDeviceFromPlacementRequest.overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "IoT 1Click Projects"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "DisassociateDeviceFromPlacement"); return clientHandler .execute(new ClientExecutionParams() .withOperationName("DisassociateDeviceFromPlacement").withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler).withInput(disassociateDeviceFromPlacementRequest) .withMetricCollector(apiCallMetricCollector) .withMarshaller(new DisassociateDeviceFromPlacementRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } /** *

* Returns an object enumerating the devices in a placement. *

* * @param getDevicesInPlacementRequest * @return Result of the GetDevicesInPlacement operation returned by the service. * @throws InternalFailureException * @throws InvalidRequestException * @throws ResourceNotFoundException * @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 Iot1ClickProjectsException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample Iot1ClickProjectsClient.GetDevicesInPlacement * @see AWS API Documentation */ @Override public GetDevicesInPlacementResponse getDevicesInPlacement(GetDevicesInPlacementRequest getDevicesInPlacementRequest) throws InternalFailureException, InvalidRequestException, ResourceNotFoundException, AwsServiceException, SdkClientException, Iot1ClickProjectsException { JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler( operationMetadata, GetDevicesInPlacementResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); List metricPublishers = resolveMetricPublishers(clientConfiguration, getDevicesInPlacementRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "IoT 1Click Projects"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetDevicesInPlacement"); return clientHandler.execute(new ClientExecutionParams() .withOperationName("GetDevicesInPlacement").withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler).withInput(getDevicesInPlacementRequest) .withMetricCollector(apiCallMetricCollector) .withMarshaller(new GetDevicesInPlacementRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } /** *

* Lists the placement(s) of a project. *

* * @param listPlacementsRequest * @return Result of the ListPlacements operation returned by the service. * @throws InternalFailureException * @throws InvalidRequestException * @throws ResourceNotFoundException * @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 Iot1ClickProjectsException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample Iot1ClickProjectsClient.ListPlacements * @see AWS API Documentation */ @Override public ListPlacementsResponse listPlacements(ListPlacementsRequest listPlacementsRequest) throws InternalFailureException, InvalidRequestException, ResourceNotFoundException, AwsServiceException, SdkClientException, Iot1ClickProjectsException { JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata, ListPlacementsResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); List metricPublishers = resolveMetricPublishers(clientConfiguration, listPlacementsRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "IoT 1Click Projects"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "ListPlacements"); return clientHandler.execute(new ClientExecutionParams() .withOperationName("ListPlacements").withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler).withInput(listPlacementsRequest) .withMetricCollector(apiCallMetricCollector) .withMarshaller(new ListPlacementsRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } /** *

* Lists the placement(s) of a project. *

*
*

* This is a variant of * {@link #listPlacements(software.amazon.awssdk.services.iot1clickprojects.model.ListPlacementsRequest)} operation. * The return type is a custom iterable that can be used to iterate through all the pages. SDK will internally * handle making service calls for you. *

*

* When this operation is called, a custom iterable is returned but no service calls are made yet. So there is no * guarantee that the request is valid. As you iterate through the iterable, SDK will start lazily loading response * pages by making service calls until there are no pages left or your iteration stops. If there are errors in your * request, you will see the failures only after you start iterating through the iterable. *

* *

* The following are few ways to iterate through the response pages: *

* 1) Using a Stream * *
     * {@code
     * software.amazon.awssdk.services.iot1clickprojects.paginators.ListPlacementsIterable responses = client.listPlacementsPaginator(request);
     * responses.stream().forEach(....);
     * }
     * 
* * 2) Using For loop * *
     * {
     *     @code
     *     software.amazon.awssdk.services.iot1clickprojects.paginators.ListPlacementsIterable responses = client
     *             .listPlacementsPaginator(request);
     *     for (software.amazon.awssdk.services.iot1clickprojects.model.ListPlacementsResponse response : responses) {
     *         // do something;
     *     }
     * }
     * 
* * 3) Use iterator directly * *
     * {@code
     * software.amazon.awssdk.services.iot1clickprojects.paginators.ListPlacementsIterable responses = client.listPlacementsPaginator(request);
     * responses.iterator().forEachRemaining(....);
     * }
     * 
*

* Please notice that the configuration of maxResults won't limit the number of results you get with the * paginator. It only limits the number of results in each page. *

*

* Note: If you prefer to have control on service calls, use the * {@link #listPlacements(software.amazon.awssdk.services.iot1clickprojects.model.ListPlacementsRequest)} * operation. *

* * @param listPlacementsRequest * @return A custom iterable that can be used to iterate through all the response pages. * @throws InternalFailureException * @throws InvalidRequestException * @throws ResourceNotFoundException * @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 Iot1ClickProjectsException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample Iot1ClickProjectsClient.ListPlacements * @see AWS API Documentation */ @Override public ListPlacementsIterable listPlacementsPaginator(ListPlacementsRequest listPlacementsRequest) throws InternalFailureException, InvalidRequestException, ResourceNotFoundException, AwsServiceException, SdkClientException, Iot1ClickProjectsException { return new ListPlacementsIterable(this, applyPaginatorUserAgent(listPlacementsRequest)); } /** *

* Lists the AWS IoT 1-Click project(s) associated with your AWS account and region. *

* * @param listProjectsRequest * @return Result of the ListProjects operation returned by the service. * @throws InternalFailureException * @throws InvalidRequestException * @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 Iot1ClickProjectsException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample Iot1ClickProjectsClient.ListProjects * @see AWS API Documentation */ @Override public ListProjectsResponse listProjects(ListProjectsRequest listProjectsRequest) throws InternalFailureException, InvalidRequestException, AwsServiceException, SdkClientException, Iot1ClickProjectsException { JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata, ListProjectsResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); List metricPublishers = resolveMetricPublishers(clientConfiguration, listProjectsRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "IoT 1Click Projects"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "ListProjects"); return clientHandler.execute(new ClientExecutionParams() .withOperationName("ListProjects").withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler).withInput(listProjectsRequest) .withMetricCollector(apiCallMetricCollector) .withMarshaller(new ListProjectsRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } /** *

* Lists the AWS IoT 1-Click project(s) associated with your AWS account and region. *

*
*

* This is a variant of * {@link #listProjects(software.amazon.awssdk.services.iot1clickprojects.model.ListProjectsRequest)} operation. The * return type is a custom iterable that can be used to iterate through all the pages. SDK will internally handle * making service calls for you. *

*

* When this operation is called, a custom iterable is returned but no service calls are made yet. So there is no * guarantee that the request is valid. As you iterate through the iterable, SDK will start lazily loading response * pages by making service calls until there are no pages left or your iteration stops. If there are errors in your * request, you will see the failures only after you start iterating through the iterable. *

* *

* The following are few ways to iterate through the response pages: *

* 1) Using a Stream * *
     * {@code
     * software.amazon.awssdk.services.iot1clickprojects.paginators.ListProjectsIterable responses = client.listProjectsPaginator(request);
     * responses.stream().forEach(....);
     * }
     * 
* * 2) Using For loop * *
     * {
     *     @code
     *     software.amazon.awssdk.services.iot1clickprojects.paginators.ListProjectsIterable responses = client
     *             .listProjectsPaginator(request);
     *     for (software.amazon.awssdk.services.iot1clickprojects.model.ListProjectsResponse response : responses) {
     *         // do something;
     *     }
     * }
     * 
* * 3) Use iterator directly * *
     * {@code
     * software.amazon.awssdk.services.iot1clickprojects.paginators.ListProjectsIterable responses = client.listProjectsPaginator(request);
     * responses.iterator().forEachRemaining(....);
     * }
     * 
*

* Please notice that the configuration of maxResults won't limit the number of results you get with the * paginator. It only limits the number of results in each page. *

*

* Note: If you prefer to have control on service calls, use the * {@link #listProjects(software.amazon.awssdk.services.iot1clickprojects.model.ListProjectsRequest)} operation. *

* * @param listProjectsRequest * @return A custom iterable that can be used to iterate through all the response pages. * @throws InternalFailureException * @throws InvalidRequestException * @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 Iot1ClickProjectsException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample Iot1ClickProjectsClient.ListProjects * @see AWS API Documentation */ @Override public ListProjectsIterable listProjectsPaginator(ListProjectsRequest listProjectsRequest) throws InternalFailureException, InvalidRequestException, AwsServiceException, SdkClientException, Iot1ClickProjectsException { return new ListProjectsIterable(this, applyPaginatorUserAgent(listProjectsRequest)); } /** *

* Lists the tags (metadata key/value pairs) which you have assigned to the resource. *

* * @param listTagsForResourceRequest * @return Result of the ListTagsForResource operation returned by the service. * @throws InternalFailureException * @throws InvalidRequestException * @throws ResourceNotFoundException * @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 Iot1ClickProjectsException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample Iot1ClickProjectsClient.ListTagsForResource * @see AWS API Documentation */ @Override public ListTagsForResourceResponse listTagsForResource(ListTagsForResourceRequest listTagsForResourceRequest) throws InternalFailureException, InvalidRequestException, ResourceNotFoundException, AwsServiceException, SdkClientException, Iot1ClickProjectsException { JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler( operationMetadata, ListTagsForResourceResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); 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 Projects"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "ListTagsForResource"); return clientHandler.execute(new ClientExecutionParams() .withOperationName("ListTagsForResource").withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler).withInput(listTagsForResourceRequest) .withMetricCollector(apiCallMetricCollector) .withMarshaller(new ListTagsForResourceRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } /** *

* Creates or modifies tags for a resource. Tags are key/value pairs (metadata) that can be used to manage a * resource. For more information, see AWS Tagging Strategies. *

* * @param tagResourceRequest * @return Result of the TagResource operation returned by the service. * @throws InternalFailureException * @throws InvalidRequestException * @throws ResourceNotFoundException * @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 Iot1ClickProjectsException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample Iot1ClickProjectsClient.TagResource * @see AWS API Documentation */ @Override public TagResourceResponse tagResource(TagResourceRequest tagResourceRequest) throws InternalFailureException, InvalidRequestException, ResourceNotFoundException, AwsServiceException, SdkClientException, Iot1ClickProjectsException { JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata, TagResourceResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); 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 Projects"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "TagResource"); return clientHandler.execute(new ClientExecutionParams() .withOperationName("TagResource").withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler).withInput(tagResourceRequest) .withMetricCollector(apiCallMetricCollector) .withMarshaller(new TagResourceRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } /** *

* Removes one or more tags (metadata key/value pairs) from a resource. *

* * @param untagResourceRequest * @return Result of the UntagResource operation returned by the service. * @throws InternalFailureException * @throws InvalidRequestException * @throws ResourceNotFoundException * @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 Iot1ClickProjectsException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample Iot1ClickProjectsClient.UntagResource * @see AWS API Documentation */ @Override public UntagResourceResponse untagResource(UntagResourceRequest untagResourceRequest) throws InternalFailureException, InvalidRequestException, ResourceNotFoundException, AwsServiceException, SdkClientException, Iot1ClickProjectsException { JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata, UntagResourceResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); 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 Projects"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "UntagResource"); return clientHandler.execute(new ClientExecutionParams() .withOperationName("UntagResource").withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler).withInput(untagResourceRequest) .withMetricCollector(apiCallMetricCollector) .withMarshaller(new UntagResourceRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } /** *

* Updates a placement with the given attributes. To clear an attribute, pass an empty value (i.e., ""). *

* * @param updatePlacementRequest * @return Result of the UpdatePlacement operation returned by the service. * @throws InternalFailureException * @throws InvalidRequestException * @throws ResourceNotFoundException * @throws TooManyRequestsException * @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 Iot1ClickProjectsException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample Iot1ClickProjectsClient.UpdatePlacement * @see AWS API Documentation */ @Override public UpdatePlacementResponse updatePlacement(UpdatePlacementRequest updatePlacementRequest) throws InternalFailureException, InvalidRequestException, ResourceNotFoundException, TooManyRequestsException, AwsServiceException, SdkClientException, Iot1ClickProjectsException { JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata, UpdatePlacementResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); List metricPublishers = resolveMetricPublishers(clientConfiguration, updatePlacementRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "IoT 1Click Projects"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "UpdatePlacement"); return clientHandler.execute(new ClientExecutionParams() .withOperationName("UpdatePlacement").withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler).withInput(updatePlacementRequest) .withMetricCollector(apiCallMetricCollector) .withMarshaller(new UpdatePlacementRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } /** *

* Updates a project associated with your AWS account and region. With the exception of device template names, you * can pass just the values that need to be updated because the update request will change only the values that are * provided. To clear a value, pass the empty string (i.e., ""). *

* * @param updateProjectRequest * @return Result of the UpdateProject operation returned by the service. * @throws InternalFailureException * @throws InvalidRequestException * @throws ResourceNotFoundException * @throws TooManyRequestsException * @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 Iot1ClickProjectsException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample Iot1ClickProjectsClient.UpdateProject * @see AWS API Documentation */ @Override public UpdateProjectResponse updateProject(UpdateProjectRequest updateProjectRequest) throws InternalFailureException, InvalidRequestException, ResourceNotFoundException, TooManyRequestsException, AwsServiceException, SdkClientException, Iot1ClickProjectsException { JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata, UpdateProjectResponse::builder); HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); List metricPublishers = resolveMetricPublishers(clientConfiguration, updateProjectRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "IoT 1Click Projects"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "UpdateProject"); return clientHandler.execute(new ClientExecutionParams() .withOperationName("UpdateProject").withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler).withInput(updateProjectRequest) .withMetricCollector(apiCallMetricCollector) .withMarshaller(new UpdateProjectRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } private T applyPaginatorUserAgent(T request) { Consumer userAgentApplier = b -> b.addApiName(ApiName.builder() .version(VersionInfo.SDK_VERSION).name("PAGINATED").build()); AwsRequestOverrideConfiguration overrideConfiguration = request.overrideConfiguration() .map(c -> c.toBuilder().applyMutation(userAgentApplier).build()) .orElse((AwsRequestOverrideConfiguration.builder().applyMutation(userAgentApplier).build())); return (T) request.toBuilder().overrideConfiguration(overrideConfiguration).build(); } @Override public final String serviceName() { return SERVICE_NAME; } 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 HttpResponseHandler createErrorResponseHandler(BaseAwsJsonProtocolFactory protocolFactory, JsonOperationMetadata operationMetadata) { return protocolFactory.createErrorResponseHandler(operationMetadata); } private > T init(T builder) { return builder .clientConfiguration(clientConfiguration) .defaultServiceExceptionSupplier(Iot1ClickProjectsException::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("ResourceNotFoundException") .exceptionBuilderSupplier(ResourceNotFoundException::builder).httpStatusCode(404).build()) .registerModeledException( ExceptionMetadata.builder().errorCode("ResourceConflictException") .exceptionBuilderSupplier(ResourceConflictException::builder).httpStatusCode(409).build()) .registerModeledException( ExceptionMetadata.builder().errorCode("TooManyRequestsException") .exceptionBuilderSupplier(TooManyRequestsException::builder).httpStatusCode(429).build()); } @Override public final Iot1ClickProjectsServiceClientConfiguration serviceClientConfiguration() { return this.serviceClientConfiguration; } @Override public void close() { clientHandler.close(); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy