software.amazon.awssdk.services.greengrassv2.DefaultGreengrassV2Client Maven / Gradle / Ivy
Show all versions of greengrassv2 Show documentation
/*
* 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.greengrassv2;
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.client.handler.AwsSyncClientHandler;
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.awscore.retry.AwsRetryStrategy;
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.ClientOverrideConfiguration;
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.retry.RetryMode;
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.retries.api.RetryStrategy;
import software.amazon.awssdk.services.greengrassv2.internal.GreengrassV2ServiceClientConfigurationBuilder;
import software.amazon.awssdk.services.greengrassv2.model.AccessDeniedException;
import software.amazon.awssdk.services.greengrassv2.model.AssociateServiceRoleToAccountRequest;
import software.amazon.awssdk.services.greengrassv2.model.AssociateServiceRoleToAccountResponse;
import software.amazon.awssdk.services.greengrassv2.model.BatchAssociateClientDeviceWithCoreDeviceRequest;
import software.amazon.awssdk.services.greengrassv2.model.BatchAssociateClientDeviceWithCoreDeviceResponse;
import software.amazon.awssdk.services.greengrassv2.model.BatchDisassociateClientDeviceFromCoreDeviceRequest;
import software.amazon.awssdk.services.greengrassv2.model.BatchDisassociateClientDeviceFromCoreDeviceResponse;
import software.amazon.awssdk.services.greengrassv2.model.CancelDeploymentRequest;
import software.amazon.awssdk.services.greengrassv2.model.CancelDeploymentResponse;
import software.amazon.awssdk.services.greengrassv2.model.ConflictException;
import software.amazon.awssdk.services.greengrassv2.model.CreateComponentVersionRequest;
import software.amazon.awssdk.services.greengrassv2.model.CreateComponentVersionResponse;
import software.amazon.awssdk.services.greengrassv2.model.CreateDeploymentRequest;
import software.amazon.awssdk.services.greengrassv2.model.CreateDeploymentResponse;
import software.amazon.awssdk.services.greengrassv2.model.DeleteComponentRequest;
import software.amazon.awssdk.services.greengrassv2.model.DeleteComponentResponse;
import software.amazon.awssdk.services.greengrassv2.model.DeleteCoreDeviceRequest;
import software.amazon.awssdk.services.greengrassv2.model.DeleteCoreDeviceResponse;
import software.amazon.awssdk.services.greengrassv2.model.DeleteDeploymentRequest;
import software.amazon.awssdk.services.greengrassv2.model.DeleteDeploymentResponse;
import software.amazon.awssdk.services.greengrassv2.model.DescribeComponentRequest;
import software.amazon.awssdk.services.greengrassv2.model.DescribeComponentResponse;
import software.amazon.awssdk.services.greengrassv2.model.DisassociateServiceRoleFromAccountRequest;
import software.amazon.awssdk.services.greengrassv2.model.DisassociateServiceRoleFromAccountResponse;
import software.amazon.awssdk.services.greengrassv2.model.GetComponentRequest;
import software.amazon.awssdk.services.greengrassv2.model.GetComponentResponse;
import software.amazon.awssdk.services.greengrassv2.model.GetComponentVersionArtifactRequest;
import software.amazon.awssdk.services.greengrassv2.model.GetComponentVersionArtifactResponse;
import software.amazon.awssdk.services.greengrassv2.model.GetConnectivityInfoRequest;
import software.amazon.awssdk.services.greengrassv2.model.GetConnectivityInfoResponse;
import software.amazon.awssdk.services.greengrassv2.model.GetCoreDeviceRequest;
import software.amazon.awssdk.services.greengrassv2.model.GetCoreDeviceResponse;
import software.amazon.awssdk.services.greengrassv2.model.GetDeploymentRequest;
import software.amazon.awssdk.services.greengrassv2.model.GetDeploymentResponse;
import software.amazon.awssdk.services.greengrassv2.model.GetServiceRoleForAccountRequest;
import software.amazon.awssdk.services.greengrassv2.model.GetServiceRoleForAccountResponse;
import software.amazon.awssdk.services.greengrassv2.model.GreengrassV2Exception;
import software.amazon.awssdk.services.greengrassv2.model.InternalServerException;
import software.amazon.awssdk.services.greengrassv2.model.ListClientDevicesAssociatedWithCoreDeviceRequest;
import software.amazon.awssdk.services.greengrassv2.model.ListClientDevicesAssociatedWithCoreDeviceResponse;
import software.amazon.awssdk.services.greengrassv2.model.ListComponentVersionsRequest;
import software.amazon.awssdk.services.greengrassv2.model.ListComponentVersionsResponse;
import software.amazon.awssdk.services.greengrassv2.model.ListComponentsRequest;
import software.amazon.awssdk.services.greengrassv2.model.ListComponentsResponse;
import software.amazon.awssdk.services.greengrassv2.model.ListCoreDevicesRequest;
import software.amazon.awssdk.services.greengrassv2.model.ListCoreDevicesResponse;
import software.amazon.awssdk.services.greengrassv2.model.ListDeploymentsRequest;
import software.amazon.awssdk.services.greengrassv2.model.ListDeploymentsResponse;
import software.amazon.awssdk.services.greengrassv2.model.ListEffectiveDeploymentsRequest;
import software.amazon.awssdk.services.greengrassv2.model.ListEffectiveDeploymentsResponse;
import software.amazon.awssdk.services.greengrassv2.model.ListInstalledComponentsRequest;
import software.amazon.awssdk.services.greengrassv2.model.ListInstalledComponentsResponse;
import software.amazon.awssdk.services.greengrassv2.model.ListTagsForResourceRequest;
import software.amazon.awssdk.services.greengrassv2.model.ListTagsForResourceResponse;
import software.amazon.awssdk.services.greengrassv2.model.RequestAlreadyInProgressException;
import software.amazon.awssdk.services.greengrassv2.model.ResolveComponentCandidatesRequest;
import software.amazon.awssdk.services.greengrassv2.model.ResolveComponentCandidatesResponse;
import software.amazon.awssdk.services.greengrassv2.model.ResourceNotFoundException;
import software.amazon.awssdk.services.greengrassv2.model.ServiceQuotaExceededException;
import software.amazon.awssdk.services.greengrassv2.model.TagResourceRequest;
import software.amazon.awssdk.services.greengrassv2.model.TagResourceResponse;
import software.amazon.awssdk.services.greengrassv2.model.ThrottlingException;
import software.amazon.awssdk.services.greengrassv2.model.UntagResourceRequest;
import software.amazon.awssdk.services.greengrassv2.model.UntagResourceResponse;
import software.amazon.awssdk.services.greengrassv2.model.UpdateConnectivityInfoRequest;
import software.amazon.awssdk.services.greengrassv2.model.UpdateConnectivityInfoResponse;
import software.amazon.awssdk.services.greengrassv2.model.ValidationException;
import software.amazon.awssdk.services.greengrassv2.transform.AssociateServiceRoleToAccountRequestMarshaller;
import software.amazon.awssdk.services.greengrassv2.transform.BatchAssociateClientDeviceWithCoreDeviceRequestMarshaller;
import software.amazon.awssdk.services.greengrassv2.transform.BatchDisassociateClientDeviceFromCoreDeviceRequestMarshaller;
import software.amazon.awssdk.services.greengrassv2.transform.CancelDeploymentRequestMarshaller;
import software.amazon.awssdk.services.greengrassv2.transform.CreateComponentVersionRequestMarshaller;
import software.amazon.awssdk.services.greengrassv2.transform.CreateDeploymentRequestMarshaller;
import software.amazon.awssdk.services.greengrassv2.transform.DeleteComponentRequestMarshaller;
import software.amazon.awssdk.services.greengrassv2.transform.DeleteCoreDeviceRequestMarshaller;
import software.amazon.awssdk.services.greengrassv2.transform.DeleteDeploymentRequestMarshaller;
import software.amazon.awssdk.services.greengrassv2.transform.DescribeComponentRequestMarshaller;
import software.amazon.awssdk.services.greengrassv2.transform.DisassociateServiceRoleFromAccountRequestMarshaller;
import software.amazon.awssdk.services.greengrassv2.transform.GetComponentRequestMarshaller;
import software.amazon.awssdk.services.greengrassv2.transform.GetComponentVersionArtifactRequestMarshaller;
import software.amazon.awssdk.services.greengrassv2.transform.GetConnectivityInfoRequestMarshaller;
import software.amazon.awssdk.services.greengrassv2.transform.GetCoreDeviceRequestMarshaller;
import software.amazon.awssdk.services.greengrassv2.transform.GetDeploymentRequestMarshaller;
import software.amazon.awssdk.services.greengrassv2.transform.GetServiceRoleForAccountRequestMarshaller;
import software.amazon.awssdk.services.greengrassv2.transform.ListClientDevicesAssociatedWithCoreDeviceRequestMarshaller;
import software.amazon.awssdk.services.greengrassv2.transform.ListComponentVersionsRequestMarshaller;
import software.amazon.awssdk.services.greengrassv2.transform.ListComponentsRequestMarshaller;
import software.amazon.awssdk.services.greengrassv2.transform.ListCoreDevicesRequestMarshaller;
import software.amazon.awssdk.services.greengrassv2.transform.ListDeploymentsRequestMarshaller;
import software.amazon.awssdk.services.greengrassv2.transform.ListEffectiveDeploymentsRequestMarshaller;
import software.amazon.awssdk.services.greengrassv2.transform.ListInstalledComponentsRequestMarshaller;
import software.amazon.awssdk.services.greengrassv2.transform.ListTagsForResourceRequestMarshaller;
import software.amazon.awssdk.services.greengrassv2.transform.ResolveComponentCandidatesRequestMarshaller;
import software.amazon.awssdk.services.greengrassv2.transform.TagResourceRequestMarshaller;
import software.amazon.awssdk.services.greengrassv2.transform.UntagResourceRequestMarshaller;
import software.amazon.awssdk.services.greengrassv2.transform.UpdateConnectivityInfoRequestMarshaller;
import software.amazon.awssdk.utils.Logger;
/**
* Internal implementation of {@link GreengrassV2Client}.
*
* @see GreengrassV2Client#builder()
*/
@Generated("software.amazon.awssdk:codegen")
@SdkInternalApi
final class DefaultGreengrassV2Client implements GreengrassV2Client {
private static final Logger log = Logger.loggerFor(DefaultGreengrassV2Client.class);
private static final AwsProtocolMetadata protocolMetadata = AwsProtocolMetadata.builder()
.serviceProtocol(AwsServiceProtocol.REST_JSON).build();
private final SyncClientHandler clientHandler;
private final AwsJsonProtocolFactory protocolFactory;
private final SdkClientConfiguration clientConfiguration;
protected DefaultGreengrassV2Client(SdkClientConfiguration clientConfiguration) {
this.clientHandler = new AwsSyncClientHandler(clientConfiguration);
this.clientConfiguration = clientConfiguration.toBuilder().option(SdkClientOption.SDK_CLIENT, this).build();
this.protocolFactory = init(AwsJsonProtocolFactory.builder()).build();
}
/**
*
* Associates a Greengrass service role with IoT Greengrass for your Amazon Web Services account in this Amazon Web
* Services Region. IoT Greengrass uses this role to verify the identity of client devices and manage core device
* connectivity information. The role must include the AWSGreengrassResourceAccessRolePolicy managed policy or a custom policy that defines equivalent permissions
* for the IoT Greengrass features that you use. For more information, see Greengrass service
* role in the IoT Greengrass Version 2 Developer Guide.
*
*
* @param associateServiceRoleToAccountRequest
* @return Result of the AssociateServiceRoleToAccount operation returned by the service.
* @throws ValidationException
* The request isn't valid. This can occur if your request contains malformed JSON or unsupported
* characters.
* @throws InternalServerException
* IoT Greengrass can't process your request right now. Try again later.
* @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 GreengrassV2Exception
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample GreengrassV2Client.AssociateServiceRoleToAccount
* @see AWS API Documentation
*/
@Override
public AssociateServiceRoleToAccountResponse associateServiceRoleToAccount(
AssociateServiceRoleToAccountRequest associateServiceRoleToAccountRequest) throws ValidationException,
InternalServerException, AwsServiceException, SdkClientException, GreengrassV2Exception {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, AssociateServiceRoleToAccountResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(associateServiceRoleToAccountRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration,
associateServiceRoleToAccountRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "GreengrassV2");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "AssociateServiceRoleToAccount");
return clientHandler
.execute(new ClientExecutionParams()
.withOperationName("AssociateServiceRoleToAccount").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(associateServiceRoleToAccountRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new AssociateServiceRoleToAccountRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Associates a list of client devices with a core device. Use this API operation to specify which client devices
* can discover a core device through cloud discovery. With cloud discovery, client devices connect to IoT
* Greengrass to retrieve associated core devices' connectivity information and certificates. For more information,
* see Configure
* cloud discovery in the IoT Greengrass V2 Developer Guide.
*
*
*
* Client devices are local IoT devices that connect to and communicate with an IoT Greengrass core device over
* MQTT. You can connect client devices to a core device to sync MQTT messages and data to Amazon Web Services IoT
* Core and interact with client devices in Greengrass components. For more information, see Interact
* with local IoT devices in the IoT Greengrass V2 Developer Guide.
*
*
*
* @param batchAssociateClientDeviceWithCoreDeviceRequest
* @return Result of the BatchAssociateClientDeviceWithCoreDevice operation returned by the service.
* @throws ValidationException
* The request isn't valid. This can occur if your request contains malformed JSON or unsupported
* characters.
* @throws ResourceNotFoundException
* The requested resource can't be found.
* @throws AccessDeniedException
* You don't have permission to perform the action.
* @throws InternalServerException
* IoT Greengrass can't process your request right now. Try again later.
* @throws ThrottlingException
* Your request exceeded a request rate quota. For example, you might have exceeded the amount of times that
* you can retrieve device or deployment status per second.
* @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 GreengrassV2Exception
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample GreengrassV2Client.BatchAssociateClientDeviceWithCoreDevice
* @see AWS API Documentation
*/
@Override
public BatchAssociateClientDeviceWithCoreDeviceResponse batchAssociateClientDeviceWithCoreDevice(
BatchAssociateClientDeviceWithCoreDeviceRequest batchAssociateClientDeviceWithCoreDeviceRequest)
throws ValidationException, ResourceNotFoundException, AccessDeniedException, InternalServerException,
ThrottlingException, AwsServiceException, SdkClientException, GreengrassV2Exception {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory
.createResponseHandler(operationMetadata, BatchAssociateClientDeviceWithCoreDeviceResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(
batchAssociateClientDeviceWithCoreDeviceRequest, this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration,
batchAssociateClientDeviceWithCoreDeviceRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "GreengrassV2");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "BatchAssociateClientDeviceWithCoreDevice");
return clientHandler
.execute(new ClientExecutionParams()
.withOperationName("BatchAssociateClientDeviceWithCoreDevice").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration)
.withInput(batchAssociateClientDeviceWithCoreDeviceRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new BatchAssociateClientDeviceWithCoreDeviceRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Disassociates a list of client devices from a core device. After you disassociate a client device from a core
* device, the client device won't be able to use cloud discovery to retrieve the core device's connectivity
* information and certificates.
*
*
* @param batchDisassociateClientDeviceFromCoreDeviceRequest
* @return Result of the BatchDisassociateClientDeviceFromCoreDevice operation returned by the service.
* @throws ValidationException
* The request isn't valid. This can occur if your request contains malformed JSON or unsupported
* characters.
* @throws ResourceNotFoundException
* The requested resource can't be found.
* @throws AccessDeniedException
* You don't have permission to perform the action.
* @throws InternalServerException
* IoT Greengrass can't process your request right now. Try again later.
* @throws ThrottlingException
* Your request exceeded a request rate quota. For example, you might have exceeded the amount of times that
* you can retrieve device or deployment status per second.
* @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 GreengrassV2Exception
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample GreengrassV2Client.BatchDisassociateClientDeviceFromCoreDevice
* @see AWS API Documentation
*/
@Override
public BatchDisassociateClientDeviceFromCoreDeviceResponse batchDisassociateClientDeviceFromCoreDevice(
BatchDisassociateClientDeviceFromCoreDeviceRequest batchDisassociateClientDeviceFromCoreDeviceRequest)
throws ValidationException, ResourceNotFoundException, AccessDeniedException, InternalServerException,
ThrottlingException, AwsServiceException, SdkClientException, GreengrassV2Exception {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory
.createResponseHandler(operationMetadata, BatchDisassociateClientDeviceFromCoreDeviceResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(
batchDisassociateClientDeviceFromCoreDeviceRequest, this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration,
batchDisassociateClientDeviceFromCoreDeviceRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "GreengrassV2");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "BatchDisassociateClientDeviceFromCoreDevice");
return clientHandler
.execute(new ClientExecutionParams()
.withOperationName("BatchDisassociateClientDeviceFromCoreDevice")
.withProtocolMetadata(protocolMetadata).withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler).withRequestConfiguration(clientConfiguration)
.withInput(batchDisassociateClientDeviceFromCoreDeviceRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new BatchDisassociateClientDeviceFromCoreDeviceRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Cancels a deployment. This operation cancels the deployment for devices that haven't yet received it. If a device
* already received the deployment, this operation doesn't change anything for that device.
*
*
* @param cancelDeploymentRequest
* @return Result of the CancelDeployment operation returned by the service.
* @throws ResourceNotFoundException
* The requested resource can't be found.
* @throws ValidationException
* The request isn't valid. This can occur if your request contains malformed JSON or unsupported
* characters.
* @throws AccessDeniedException
* You don't have permission to perform the action.
* @throws InternalServerException
* IoT Greengrass can't process your request right now. Try again later.
* @throws ConflictException
* Your request has conflicting operations. This can occur if you're trying to perform more than one
* operation on the same resource at the same time.
* @throws ThrottlingException
* Your request exceeded a request rate quota. For example, you might have exceeded the amount of times that
* you can retrieve device or deployment status per second.
* @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 GreengrassV2Exception
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample GreengrassV2Client.CancelDeployment
* @see AWS
* API Documentation
*/
@Override
public CancelDeploymentResponse cancelDeployment(CancelDeploymentRequest cancelDeploymentRequest)
throws ResourceNotFoundException, ValidationException, AccessDeniedException, InternalServerException,
ConflictException, ThrottlingException, AwsServiceException, SdkClientException, GreengrassV2Exception {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
CancelDeploymentResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(cancelDeploymentRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, cancelDeploymentRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "GreengrassV2");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "CancelDeployment");
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("CancelDeployment").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(cancelDeploymentRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new CancelDeploymentRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Creates a component. Components are software that run on Greengrass core devices. After you develop and test a
* component on your core device, you can use this operation to upload your component to IoT Greengrass. Then, you
* can deploy the component to other core devices.
*
*
* You can use this operation to do the following:
*
*
* -
*
* Create components from recipes
*
*
* Create a component from a recipe, which is a file that defines the component's metadata, parameters,
* dependencies, lifecycle, artifacts, and platform capability. For more information, see IoT Greengrass
* component recipe reference in the IoT Greengrass V2 Developer Guide.
*
*
* To create a component from a recipe, specify inlineRecipe
when you call this operation.
*
*
* -
*
* Create components from Lambda functions
*
*
* Create a component from an Lambda function that runs on IoT Greengrass. This creates a recipe and artifacts from
* the Lambda function's deployment package. You can use this operation to migrate Lambda functions from IoT
* Greengrass V1 to IoT Greengrass V2.
*
*
* This function accepts Lambda functions in all supported versions of Python, Node.js, and Java runtimes. IoT
* Greengrass doesn't apply any additional restrictions on deprecated Lambda runtime versions.
*
*
* To create a component from a Lambda function, specify lambdaFunction
when you call this operation.
*
*
*
* IoT Greengrass currently supports Lambda functions on only Linux core devices.
*
*
*
*
* @param createComponentVersionRequest
* @return Result of the CreateComponentVersion operation returned by the service.
* @throws ValidationException
* The request isn't valid. This can occur if your request contains malformed JSON or unsupported
* characters.
* @throws ServiceQuotaExceededException
* Your request exceeds a service quota. For example, you might have the maximum number of components that
* you can create.
* @throws AccessDeniedException
* You don't have permission to perform the action.
* @throws ConflictException
* Your request has conflicting operations. This can occur if you're trying to perform more than one
* operation on the same resource at the same time.
* @throws ThrottlingException
* Your request exceeded a request rate quota. For example, you might have exceeded the amount of times that
* you can retrieve device or deployment status per second.
* @throws InternalServerException
* IoT Greengrass can't process your request right now. Try again later.
* @throws RequestAlreadyInProgressException
* The request is already in progress. This exception occurs when you use a client token for multiple
* requests while IoT Greengrass is still processing an earlier request that uses the same client token.
* @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 GreengrassV2Exception
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample GreengrassV2Client.CreateComponentVersion
* @see AWS API Documentation
*/
@Override
public CreateComponentVersionResponse createComponentVersion(CreateComponentVersionRequest createComponentVersionRequest)
throws ValidationException, ServiceQuotaExceededException, AccessDeniedException, ConflictException,
ThrottlingException, InternalServerException, RequestAlreadyInProgressException, AwsServiceException,
SdkClientException, GreengrassV2Exception {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, CreateComponentVersionResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(createComponentVersionRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, createComponentVersionRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "GreengrassV2");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "CreateComponentVersion");
return clientHandler
.execute(new ClientExecutionParams()
.withOperationName("CreateComponentVersion").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(createComponentVersionRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new CreateComponentVersionRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Creates a continuous deployment for a target, which is a Greengrass core device or group of core devices. When
* you add a new core device to a group of core devices that has a deployment, IoT Greengrass deploys that group's
* deployment to the new device.
*
*
* You can define one deployment for each target. When you create a new deployment for a target that has an existing
* deployment, you replace the previous deployment. IoT Greengrass applies the new deployment to the target devices.
*
*
* Every deployment has a revision number that indicates how many deployment revisions you define for a target. Use
* this operation to create a new revision of an existing deployment.
*
*
* For more information, see the Create deployments in
* the IoT Greengrass V2 Developer Guide.
*
*
* @param createDeploymentRequest
* @return Result of the CreateDeployment operation returned by the service.
* @throws ResourceNotFoundException
* The requested resource can't be found.
* @throws ValidationException
* The request isn't valid. This can occur if your request contains malformed JSON or unsupported
* characters.
* @throws AccessDeniedException
* You don't have permission to perform the action.
* @throws ThrottlingException
* Your request exceeded a request rate quota. For example, you might have exceeded the amount of times that
* you can retrieve device or deployment status per second.
* @throws InternalServerException
* IoT Greengrass can't process your request right now. Try again later.
* @throws ConflictException
* Your request has conflicting operations. This can occur if you're trying to perform more than one
* operation on the same resource at the same time.
* @throws RequestAlreadyInProgressException
* The request is already in progress. This exception occurs when you use a client token for multiple
* requests while IoT Greengrass is still processing an earlier request that uses the same client token.
* @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 GreengrassV2Exception
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample GreengrassV2Client.CreateDeployment
* @see AWS
* API Documentation
*/
@Override
public CreateDeploymentResponse createDeployment(CreateDeploymentRequest createDeploymentRequest)
throws ResourceNotFoundException, ValidationException, AccessDeniedException, ThrottlingException,
InternalServerException, ConflictException, RequestAlreadyInProgressException, AwsServiceException,
SdkClientException, GreengrassV2Exception {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
CreateDeploymentResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(createDeploymentRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, createDeploymentRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "GreengrassV2");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "CreateDeployment");
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("CreateDeployment").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(createDeploymentRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new CreateDeploymentRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Deletes a version of a component from IoT Greengrass.
*
*
*
* This operation deletes the component's recipe and artifacts. As a result, deployments that refer to this
* component version will fail. If you have deployments that use this component version, you can remove the
* component from the deployment or update the deployment to use a valid version.
*
*
*
* @param deleteComponentRequest
* @return Result of the DeleteComponent operation returned by the service.
* @throws ValidationException
* The request isn't valid. This can occur if your request contains malformed JSON or unsupported
* characters.
* @throws AccessDeniedException
* You don't have permission to perform the action.
* @throws ConflictException
* Your request has conflicting operations. This can occur if you're trying to perform more than one
* operation on the same resource at the same time.
* @throws ResourceNotFoundException
* The requested resource can't be found.
* @throws ThrottlingException
* Your request exceeded a request rate quota. For example, you might have exceeded the amount of times that
* you can retrieve device or deployment status per second.
* @throws InternalServerException
* IoT Greengrass can't process your request right now. Try again later.
* @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 GreengrassV2Exception
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample GreengrassV2Client.DeleteComponent
* @see AWS
* API Documentation
*/
@Override
public DeleteComponentResponse deleteComponent(DeleteComponentRequest deleteComponentRequest) throws ValidationException,
AccessDeniedException, ConflictException, ResourceNotFoundException, ThrottlingException, InternalServerException,
AwsServiceException, SdkClientException, GreengrassV2Exception {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
DeleteComponentResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(deleteComponentRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, deleteComponentRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "GreengrassV2");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "DeleteComponent");
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("DeleteComponent").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(deleteComponentRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new DeleteComponentRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Deletes a Greengrass core device, which is an IoT thing. This operation removes the core device from the list of
* core devices. This operation doesn't delete the IoT thing. For more information about how to delete the IoT
* thing, see DeleteThing in
* the IoT API Reference.
*
*
* @param deleteCoreDeviceRequest
* @return Result of the DeleteCoreDevice operation returned by the service.
* @throws ValidationException
* The request isn't valid. This can occur if your request contains malformed JSON or unsupported
* characters.
* @throws ResourceNotFoundException
* The requested resource can't be found.
* @throws AccessDeniedException
* You don't have permission to perform the action.
* @throws InternalServerException
* IoT Greengrass can't process your request right now. Try again later.
* @throws ThrottlingException
* Your request exceeded a request rate quota. For example, you might have exceeded the amount of times that
* you can retrieve device or deployment status per second.
* @throws ConflictException
* Your request has conflicting operations. This can occur if you're trying to perform more than one
* operation on the same resource at the same time.
* @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 GreengrassV2Exception
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample GreengrassV2Client.DeleteCoreDevice
* @see AWS
* API Documentation
*/
@Override
public DeleteCoreDeviceResponse deleteCoreDevice(DeleteCoreDeviceRequest deleteCoreDeviceRequest) throws ValidationException,
ResourceNotFoundException, AccessDeniedException, InternalServerException, ThrottlingException, ConflictException,
AwsServiceException, SdkClientException, GreengrassV2Exception {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
DeleteCoreDeviceResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(deleteCoreDeviceRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, deleteCoreDeviceRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "GreengrassV2");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "DeleteCoreDevice");
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("DeleteCoreDevice").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(deleteCoreDeviceRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new DeleteCoreDeviceRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Deletes a deployment. To delete an active deployment, you must first cancel it. For more information, see CancelDeployment.
*
*
* Deleting a deployment doesn't affect core devices that run that deployment, because core devices store the
* deployment's configuration on the device. Additionally, core devices can roll back to a previous deployment that
* has been deleted.
*
*
* @param deleteDeploymentRequest
* @return Result of the DeleteDeployment operation returned by the service.
* @throws ResourceNotFoundException
* The requested resource can't be found.
* @throws ValidationException
* The request isn't valid. This can occur if your request contains malformed JSON or unsupported
* characters.
* @throws AccessDeniedException
* You don't have permission to perform the action.
* @throws InternalServerException
* IoT Greengrass can't process your request right now. Try again later.
* @throws ConflictException
* Your request has conflicting operations. This can occur if you're trying to perform more than one
* operation on the same resource at the same time.
* @throws ThrottlingException
* Your request exceeded a request rate quota. For example, you might have exceeded the amount of times that
* you can retrieve device or deployment status per second.
* @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 GreengrassV2Exception
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample GreengrassV2Client.DeleteDeployment
* @see AWS
* API Documentation
*/
@Override
public DeleteDeploymentResponse deleteDeployment(DeleteDeploymentRequest deleteDeploymentRequest)
throws ResourceNotFoundException, ValidationException, AccessDeniedException, InternalServerException,
ConflictException, ThrottlingException, AwsServiceException, SdkClientException, GreengrassV2Exception {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
DeleteDeploymentResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(deleteDeploymentRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, deleteDeploymentRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "GreengrassV2");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "DeleteDeployment");
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("DeleteDeployment").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(deleteDeploymentRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new DeleteDeploymentRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Retrieves metadata for a version of a component.
*
*
* @param describeComponentRequest
* @return Result of the DescribeComponent operation returned by the service.
* @throws ValidationException
* The request isn't valid. This can occur if your request contains malformed JSON or unsupported
* characters.
* @throws AccessDeniedException
* You don't have permission to perform the action.
* @throws ResourceNotFoundException
* The requested resource can't be found.
* @throws ThrottlingException
* Your request exceeded a request rate quota. For example, you might have exceeded the amount of times that
* you can retrieve device or deployment status per second.
* @throws InternalServerException
* IoT Greengrass can't process your request right now. Try again later.
* @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 GreengrassV2Exception
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample GreengrassV2Client.DescribeComponent
* @see AWS API Documentation
*/
@Override
public DescribeComponentResponse describeComponent(DescribeComponentRequest describeComponentRequest)
throws ValidationException, AccessDeniedException, ResourceNotFoundException, ThrottlingException,
InternalServerException, AwsServiceException, SdkClientException, GreengrassV2Exception {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
DescribeComponentResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(describeComponentRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, describeComponentRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "GreengrassV2");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "DescribeComponent");
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("DescribeComponent").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(describeComponentRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new DescribeComponentRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Disassociates the Greengrass service role from IoT Greengrass for your Amazon Web Services account in this Amazon
* Web Services Region. Without a service role, IoT Greengrass can't verify the identity of client devices or manage
* core device connectivity information. For more information, see Greengrass service
* role in the IoT Greengrass Version 2 Developer Guide.
*
*
* @param disassociateServiceRoleFromAccountRequest
* @return Result of the DisassociateServiceRoleFromAccount operation returned by the service.
* @throws InternalServerException
* IoT Greengrass can't process your request right now. Try again later.
* @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 GreengrassV2Exception
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample GreengrassV2Client.DisassociateServiceRoleFromAccount
* @see AWS API Documentation
*/
@Override
public DisassociateServiceRoleFromAccountResponse disassociateServiceRoleFromAccount(
DisassociateServiceRoleFromAccountRequest disassociateServiceRoleFromAccountRequest) throws InternalServerException,
AwsServiceException, SdkClientException, GreengrassV2Exception {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, DisassociateServiceRoleFromAccountResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(disassociateServiceRoleFromAccountRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration,
disassociateServiceRoleFromAccountRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "GreengrassV2");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "DisassociateServiceRoleFromAccount");
return clientHandler
.execute(new ClientExecutionParams()
.withOperationName("DisassociateServiceRoleFromAccount").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(disassociateServiceRoleFromAccountRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new DisassociateServiceRoleFromAccountRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Gets the recipe for a version of a component.
*
*
* @param getComponentRequest
* @return Result of the GetComponent operation returned by the service.
* @throws ValidationException
* The request isn't valid. This can occur if your request contains malformed JSON or unsupported
* characters.
* @throws AccessDeniedException
* You don't have permission to perform the action.
* @throws ResourceNotFoundException
* The requested resource can't be found.
* @throws ThrottlingException
* Your request exceeded a request rate quota. For example, you might have exceeded the amount of times that
* you can retrieve device or deployment status per second.
* @throws InternalServerException
* IoT Greengrass can't process your request right now. Try again later.
* @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 GreengrassV2Exception
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample GreengrassV2Client.GetComponent
* @see AWS API
* Documentation
*/
@Override
public GetComponentResponse getComponent(GetComponentRequest getComponentRequest) throws ValidationException,
AccessDeniedException, ResourceNotFoundException, ThrottlingException, InternalServerException, AwsServiceException,
SdkClientException, GreengrassV2Exception {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
GetComponentResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(getComponentRequest, this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, getComponentRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "GreengrassV2");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetComponent");
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("GetComponent").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(getComponentRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new GetComponentRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Gets the pre-signed URL to download a public or a Lambda component artifact. Core devices call this operation to
* identify the URL that they can use to download an artifact to install.
*
*
* @param getComponentVersionArtifactRequest
* @return Result of the GetComponentVersionArtifact operation returned by the service.
* @throws ValidationException
* The request isn't valid. This can occur if your request contains malformed JSON or unsupported
* characters.
* @throws AccessDeniedException
* You don't have permission to perform the action.
* @throws ResourceNotFoundException
* The requested resource can't be found.
* @throws ThrottlingException
* Your request exceeded a request rate quota. For example, you might have exceeded the amount of times that
* you can retrieve device or deployment status per second.
* @throws InternalServerException
* IoT Greengrass can't process your request right now. Try again later.
* @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 GreengrassV2Exception
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample GreengrassV2Client.GetComponentVersionArtifact
* @see AWS API Documentation
*/
@Override
public GetComponentVersionArtifactResponse getComponentVersionArtifact(
GetComponentVersionArtifactRequest getComponentVersionArtifactRequest) throws ValidationException,
AccessDeniedException, ResourceNotFoundException, ThrottlingException, InternalServerException, AwsServiceException,
SdkClientException, GreengrassV2Exception {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, GetComponentVersionArtifactResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(getComponentVersionArtifactRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, getComponentVersionArtifactRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "GreengrassV2");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetComponentVersionArtifact");
return clientHandler
.execute(new ClientExecutionParams()
.withOperationName("GetComponentVersionArtifact").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(getComponentVersionArtifactRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new GetComponentVersionArtifactRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Retrieves connectivity information for a Greengrass core device.
*
*
* Connectivity information includes endpoints and ports where client devices can connect to an MQTT broker on the
* core device. When a client device calls the IoT Greengrass
* discovery API, IoT Greengrass returns connectivity information for all of the core devices where the client
* device can connect. For more information, see Connect client
* devices to core devices in the IoT Greengrass Version 2 Developer Guide.
*
*
* @param getConnectivityInfoRequest
* @return Result of the GetConnectivityInfo operation returned by the service.
* @throws ValidationException
* The request isn't valid. This can occur if your request contains malformed JSON or unsupported
* characters.
* @throws InternalServerException
* IoT Greengrass can't process your request right now. Try again later.
* @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 GreengrassV2Exception
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample GreengrassV2Client.GetConnectivityInfo
* @see AWS API Documentation
*/
@Override
public GetConnectivityInfoResponse getConnectivityInfo(GetConnectivityInfoRequest getConnectivityInfoRequest)
throws ValidationException, InternalServerException, AwsServiceException, SdkClientException, GreengrassV2Exception {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, GetConnectivityInfoResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(getConnectivityInfoRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, getConnectivityInfoRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "GreengrassV2");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetConnectivityInfo");
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("GetConnectivityInfo").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(getConnectivityInfoRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new GetConnectivityInfoRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Retrieves metadata for a Greengrass core device.
*
*
*
* IoT Greengrass relies on individual devices to send status updates to the Amazon Web Services Cloud. If the IoT
* Greengrass Core software isn't running on the device, or if device isn't connected to the Amazon Web Services
* Cloud, then the reported status of that device might not reflect its current status. The status timestamp
* indicates when the device status was last updated.
*
*
* Core devices send status updates at the following times:
*
*
* -
*
* When the IoT Greengrass Core software starts
*
*
* -
*
* When the core device receives a deployment from the Amazon Web Services Cloud
*
*
* -
*
* When the status of any component on the core device becomes BROKEN
*
*
* -
*
* At a regular interval that you can configure, which defaults to 24 hours
*
*
* -
*
* For IoT Greengrass Core v2.7.0, the core device sends status updates upon local deployment and cloud deployment
*
*
*
*
*
* @param getCoreDeviceRequest
* @return Result of the GetCoreDevice operation returned by the service.
* @throws ValidationException
* The request isn't valid. This can occur if your request contains malformed JSON or unsupported
* characters.
* @throws ResourceNotFoundException
* The requested resource can't be found.
* @throws AccessDeniedException
* You don't have permission to perform the action.
* @throws InternalServerException
* IoT Greengrass can't process your request right now. Try again later.
* @throws ThrottlingException
* Your request exceeded a request rate quota. For example, you might have exceeded the amount of times that
* you can retrieve device or deployment status per second.
* @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 GreengrassV2Exception
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample GreengrassV2Client.GetCoreDevice
* @see AWS
* API Documentation
*/
@Override
public GetCoreDeviceResponse getCoreDevice(GetCoreDeviceRequest getCoreDeviceRequest) throws ValidationException,
ResourceNotFoundException, AccessDeniedException, InternalServerException, ThrottlingException, AwsServiceException,
SdkClientException, GreengrassV2Exception {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
GetCoreDeviceResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(getCoreDeviceRequest, this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, getCoreDeviceRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "GreengrassV2");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetCoreDevice");
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("GetCoreDevice").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(getCoreDeviceRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new GetCoreDeviceRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Gets a deployment. Deployments define the components that run on Greengrass core devices.
*
*
* @param getDeploymentRequest
* @return Result of the GetDeployment operation returned by the service.
* @throws ValidationException
* The request isn't valid. This can occur if your request contains malformed JSON or unsupported
* characters.
* @throws ResourceNotFoundException
* The requested resource can't be found.
* @throws AccessDeniedException
* You don't have permission to perform the action.
* @throws InternalServerException
* IoT Greengrass can't process your request right now. Try again later.
* @throws ThrottlingException
* Your request exceeded a request rate quota. For example, you might have exceeded the amount of times that
* you can retrieve device or deployment status per second.
* @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 GreengrassV2Exception
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample GreengrassV2Client.GetDeployment
* @see AWS
* API Documentation
*/
@Override
public GetDeploymentResponse getDeployment(GetDeploymentRequest getDeploymentRequest) throws ValidationException,
ResourceNotFoundException, AccessDeniedException, InternalServerException, ThrottlingException, AwsServiceException,
SdkClientException, GreengrassV2Exception {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
GetDeploymentResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(getDeploymentRequest, this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, getDeploymentRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "GreengrassV2");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetDeployment");
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("GetDeployment").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(getDeploymentRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new GetDeploymentRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Gets the service role associated with IoT Greengrass for your Amazon Web Services account in this Amazon Web
* Services Region. IoT Greengrass uses this role to verify the identity of client devices and manage core device
* connectivity information. For more information, see Greengrass service
* role in the IoT Greengrass Version 2 Developer Guide.
*
*
* @param getServiceRoleForAccountRequest
* @return Result of the GetServiceRoleForAccount operation returned by the service.
* @throws InternalServerException
* IoT Greengrass can't process your request right now. Try again later.
* @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 GreengrassV2Exception
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample GreengrassV2Client.GetServiceRoleForAccount
* @see AWS API Documentation
*/
@Override
public GetServiceRoleForAccountResponse getServiceRoleForAccount(
GetServiceRoleForAccountRequest getServiceRoleForAccountRequest) throws InternalServerException, AwsServiceException,
SdkClientException, GreengrassV2Exception {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, GetServiceRoleForAccountResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(getServiceRoleForAccountRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, getServiceRoleForAccountRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "GreengrassV2");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetServiceRoleForAccount");
return clientHandler
.execute(new ClientExecutionParams()
.withOperationName("GetServiceRoleForAccount").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(getServiceRoleForAccountRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new GetServiceRoleForAccountRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Retrieves a paginated list of client devices that are associated with a core device.
*
*
* @param listClientDevicesAssociatedWithCoreDeviceRequest
* @return Result of the ListClientDevicesAssociatedWithCoreDevice operation returned by the service.
* @throws ValidationException
* The request isn't valid. This can occur if your request contains malformed JSON or unsupported
* characters.
* @throws ResourceNotFoundException
* The requested resource can't be found.
* @throws AccessDeniedException
* You don't have permission to perform the action.
* @throws InternalServerException
* IoT Greengrass can't process your request right now. Try again later.
* @throws ThrottlingException
* Your request exceeded a request rate quota. For example, you might have exceeded the amount of times that
* you can retrieve device or deployment status per second.
* @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 GreengrassV2Exception
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample GreengrassV2Client.ListClientDevicesAssociatedWithCoreDevice
* @see AWS API Documentation
*/
@Override
public ListClientDevicesAssociatedWithCoreDeviceResponse listClientDevicesAssociatedWithCoreDevice(
ListClientDevicesAssociatedWithCoreDeviceRequest listClientDevicesAssociatedWithCoreDeviceRequest)
throws ValidationException, ResourceNotFoundException, AccessDeniedException, InternalServerException,
ThrottlingException, AwsServiceException, SdkClientException, GreengrassV2Exception {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory
.createResponseHandler(operationMetadata, ListClientDevicesAssociatedWithCoreDeviceResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(
listClientDevicesAssociatedWithCoreDeviceRequest, this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration,
listClientDevicesAssociatedWithCoreDeviceRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "GreengrassV2");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "ListClientDevicesAssociatedWithCoreDevice");
return clientHandler
.execute(new ClientExecutionParams()
.withOperationName("ListClientDevicesAssociatedWithCoreDevice")
.withProtocolMetadata(protocolMetadata).withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler).withRequestConfiguration(clientConfiguration)
.withInput(listClientDevicesAssociatedWithCoreDeviceRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new ListClientDevicesAssociatedWithCoreDeviceRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Retrieves a paginated list of all versions for a component. Greater versions are listed first.
*
*
* @param listComponentVersionsRequest
* @return Result of the ListComponentVersions operation returned by the service.
* @throws ValidationException
* The request isn't valid. This can occur if your request contains malformed JSON or unsupported
* characters.
* @throws AccessDeniedException
* You don't have permission to perform the action.
* @throws ResourceNotFoundException
* The requested resource can't be found.
* @throws ThrottlingException
* Your request exceeded a request rate quota. For example, you might have exceeded the amount of times that
* you can retrieve device or deployment status per second.
* @throws InternalServerException
* IoT Greengrass can't process your request right now. Try again later.
* @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 GreengrassV2Exception
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample GreengrassV2Client.ListComponentVersions
* @see AWS API Documentation
*/
@Override
public ListComponentVersionsResponse listComponentVersions(ListComponentVersionsRequest listComponentVersionsRequest)
throws ValidationException, AccessDeniedException, ResourceNotFoundException, ThrottlingException,
InternalServerException, AwsServiceException, SdkClientException, GreengrassV2Exception {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, ListComponentVersionsResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(listComponentVersionsRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, listComponentVersionsRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "GreengrassV2");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "ListComponentVersions");
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("ListComponentVersions").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(listComponentVersionsRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new ListComponentVersionsRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Retrieves a paginated list of component summaries. This list includes components that you have permission to
* view.
*
*
* @param listComponentsRequest
* @return Result of the ListComponents operation returned by the service.
* @throws ValidationException
* The request isn't valid. This can occur if your request contains malformed JSON or unsupported
* characters.
* @throws AccessDeniedException
* You don't have permission to perform the action.
* @throws ResourceNotFoundException
* The requested resource can't be found.
* @throws ThrottlingException
* Your request exceeded a request rate quota. For example, you might have exceeded the amount of times that
* you can retrieve device or deployment status per second.
* @throws InternalServerException
* IoT Greengrass can't process your request right now. Try again later.
* @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 GreengrassV2Exception
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample GreengrassV2Client.ListComponents
* @see AWS
* API Documentation
*/
@Override
public ListComponentsResponse listComponents(ListComponentsRequest listComponentsRequest) throws ValidationException,
AccessDeniedException, ResourceNotFoundException, ThrottlingException, InternalServerException, AwsServiceException,
SdkClientException, GreengrassV2Exception {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
ListComponentsResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(listComponentsRequest, this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, listComponentsRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "GreengrassV2");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "ListComponents");
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("ListComponents").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(listComponentsRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new ListComponentsRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Retrieves a paginated list of Greengrass core devices.
*
*
*
* IoT Greengrass relies on individual devices to send status updates to the Amazon Web Services Cloud. If the IoT
* Greengrass Core software isn't running on the device, or if device isn't connected to the Amazon Web Services
* Cloud, then the reported status of that device might not reflect its current status. The status timestamp
* indicates when the device status was last updated.
*
*
* Core devices send status updates at the following times:
*
*
* -
*
* When the IoT Greengrass Core software starts
*
*
* -
*
* When the core device receives a deployment from the Amazon Web Services Cloud
*
*
* -
*
* When the status of any component on the core device becomes BROKEN
*
*
* -
*
* At a regular interval that you can configure, which defaults to 24 hours
*
*
* -
*
* For IoT Greengrass Core v2.7.0, the core device sends status updates upon local deployment and cloud deployment
*
*
*
*
*
* @param listCoreDevicesRequest
* @return Result of the ListCoreDevices operation returned by the service.
* @throws ValidationException
* The request isn't valid. This can occur if your request contains malformed JSON or unsupported
* characters.
* @throws AccessDeniedException
* You don't have permission to perform the action.
* @throws InternalServerException
* IoT Greengrass can't process your request right now. Try again later.
* @throws ThrottlingException
* Your request exceeded a request rate quota. For example, you might have exceeded the amount of times that
* you can retrieve device or deployment status per second.
* @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 GreengrassV2Exception
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample GreengrassV2Client.ListCoreDevices
* @see AWS
* API Documentation
*/
@Override
public ListCoreDevicesResponse listCoreDevices(ListCoreDevicesRequest listCoreDevicesRequest) throws ValidationException,
AccessDeniedException, InternalServerException, ThrottlingException, AwsServiceException, SdkClientException,
GreengrassV2Exception {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
ListCoreDevicesResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(listCoreDevicesRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, listCoreDevicesRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "GreengrassV2");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "ListCoreDevices");
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("ListCoreDevices").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(listCoreDevicesRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new ListCoreDevicesRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Retrieves a paginated list of deployments.
*
*
* @param listDeploymentsRequest
* @return Result of the ListDeployments operation returned by the service.
* @throws ValidationException
* The request isn't valid. This can occur if your request contains malformed JSON or unsupported
* characters.
* @throws AccessDeniedException
* You don't have permission to perform the action.
* @throws InternalServerException
* IoT Greengrass can't process your request right now. Try again later.
* @throws ThrottlingException
* Your request exceeded a request rate quota. For example, you might have exceeded the amount of times that
* you can retrieve device or deployment status per second.
* @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 GreengrassV2Exception
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample GreengrassV2Client.ListDeployments
* @see AWS
* API Documentation
*/
@Override
public ListDeploymentsResponse listDeployments(ListDeploymentsRequest listDeploymentsRequest) throws ValidationException,
AccessDeniedException, InternalServerException, ThrottlingException, AwsServiceException, SdkClientException,
GreengrassV2Exception {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
ListDeploymentsResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(listDeploymentsRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, listDeploymentsRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "GreengrassV2");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "ListDeployments");
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("ListDeployments").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(listDeploymentsRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new ListDeploymentsRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Retrieves a paginated list of deployment jobs that IoT Greengrass sends to Greengrass core devices.
*
*
* @param listEffectiveDeploymentsRequest
* @return Result of the ListEffectiveDeployments operation returned by the service.
* @throws ValidationException
* The request isn't valid. This can occur if your request contains malformed JSON or unsupported
* characters.
* @throws ResourceNotFoundException
* The requested resource can't be found.
* @throws AccessDeniedException
* You don't have permission to perform the action.
* @throws InternalServerException
* IoT Greengrass can't process your request right now. Try again later.
* @throws ThrottlingException
* Your request exceeded a request rate quota. For example, you might have exceeded the amount of times that
* you can retrieve device or deployment status per second.
* @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 GreengrassV2Exception
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample GreengrassV2Client.ListEffectiveDeployments
* @see AWS API Documentation
*/
@Override
public ListEffectiveDeploymentsResponse listEffectiveDeployments(
ListEffectiveDeploymentsRequest listEffectiveDeploymentsRequest) throws ValidationException,
ResourceNotFoundException, AccessDeniedException, InternalServerException, ThrottlingException, AwsServiceException,
SdkClientException, GreengrassV2Exception {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, ListEffectiveDeploymentsResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(listEffectiveDeploymentsRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, listEffectiveDeploymentsRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "GreengrassV2");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "ListEffectiveDeployments");
return clientHandler
.execute(new ClientExecutionParams()
.withOperationName("ListEffectiveDeployments").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(listEffectiveDeploymentsRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new ListEffectiveDeploymentsRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Retrieves a paginated list of the components that a Greengrass core device runs. By default, this list doesn't
* include components that are deployed as dependencies of other components. To include dependencies in the
* response, set the topologyFilter
parameter to ALL
.
*
*
*
* IoT Greengrass relies on individual devices to send status updates to the Amazon Web Services Cloud. If the IoT
* Greengrass Core software isn't running on the device, or if device isn't connected to the Amazon Web Services
* Cloud, then the reported status of that device might not reflect its current status. The status timestamp
* indicates when the device status was last updated.
*
*
* Core devices send status updates at the following times:
*
*
* -
*
* When the IoT Greengrass Core software starts
*
*
* -
*
* When the core device receives a deployment from the Amazon Web Services Cloud
*
*
* -
*
* When the status of any component on the core device becomes BROKEN
*
*
* -
*
* At a regular interval that you can configure, which defaults to 24 hours
*
*
* -
*
* For IoT Greengrass Core v2.7.0, the core device sends status updates upon local deployment and cloud deployment
*
*
*
*
*
* @param listInstalledComponentsRequest
* @return Result of the ListInstalledComponents operation returned by the service.
* @throws ValidationException
* The request isn't valid. This can occur if your request contains malformed JSON or unsupported
* characters.
* @throws ResourceNotFoundException
* The requested resource can't be found.
* @throws AccessDeniedException
* You don't have permission to perform the action.
* @throws InternalServerException
* IoT Greengrass can't process your request right now. Try again later.
* @throws ThrottlingException
* Your request exceeded a request rate quota. For example, you might have exceeded the amount of times that
* you can retrieve device or deployment status per second.
* @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 GreengrassV2Exception
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample GreengrassV2Client.ListInstalledComponents
* @see AWS API Documentation
*/
@Override
public ListInstalledComponentsResponse listInstalledComponents(ListInstalledComponentsRequest listInstalledComponentsRequest)
throws ValidationException, ResourceNotFoundException, AccessDeniedException, InternalServerException,
ThrottlingException, AwsServiceException, SdkClientException, GreengrassV2Exception {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, ListInstalledComponentsResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(listInstalledComponentsRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, listInstalledComponentsRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "GreengrassV2");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "ListInstalledComponents");
return clientHandler
.execute(new ClientExecutionParams()
.withOperationName("ListInstalledComponents").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(listInstalledComponentsRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new ListInstalledComponentsRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Retrieves the list of tags for an IoT Greengrass resource.
*
*
* @param listTagsForResourceRequest
* @return Result of the ListTagsForResource operation returned by the service.
* @throws InternalServerException
* IoT Greengrass can't process your request right now. Try again later.
* @throws ValidationException
* The request isn't valid. This can occur if your request contains malformed JSON or unsupported
* characters.
* @throws ResourceNotFoundException
* The requested resource can't be found.
* @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 GreengrassV2Exception
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample GreengrassV2Client.ListTagsForResource
* @see AWS API Documentation
*/
@Override
public ListTagsForResourceResponse listTagsForResource(ListTagsForResourceRequest listTagsForResourceRequest)
throws InternalServerException, ValidationException, ResourceNotFoundException, AwsServiceException,
SdkClientException, GreengrassV2Exception {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, ListTagsForResourceResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
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, "GreengrassV2");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "ListTagsForResource");
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("ListTagsForResource").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(listTagsForResourceRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new ListTagsForResourceRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Retrieves a list of components that meet the component, version, and platform requirements of a deployment.
* Greengrass core devices call this operation when they receive a deployment to identify the components to install.
*
*
* This operation identifies components that meet all dependency requirements for a deployment. If the requirements
* conflict, then this operation returns an error and the deployment fails. For example, this occurs if component
* A
requires version >2.0.0
and component B
requires version
* <2.0.0
of a component dependency.
*
*
* When you specify the component candidates to resolve, IoT Greengrass compares each component's digest from the
* core device with the component's digest in the Amazon Web Services Cloud. If the digests don't match, then IoT
* Greengrass specifies to use the version from the Amazon Web Services Cloud.
*
*
*
* To use this operation, you must use the data plane API endpoint and authenticate with an IoT device certificate.
* For more information, see IoT Greengrass
* endpoints and quotas.
*
*
*
* @param resolveComponentCandidatesRequest
* @return Result of the ResolveComponentCandidates operation returned by the service.
* @throws ValidationException
* The request isn't valid. This can occur if your request contains malformed JSON or unsupported
* characters.
* @throws AccessDeniedException
* You don't have permission to perform the action.
* @throws ResourceNotFoundException
* The requested resource can't be found.
* @throws ConflictException
* Your request has conflicting operations. This can occur if you're trying to perform more than one
* operation on the same resource at the same time.
* @throws ThrottlingException
* Your request exceeded a request rate quota. For example, you might have exceeded the amount of times that
* you can retrieve device or deployment status per second.
* @throws InternalServerException
* IoT Greengrass can't process your request right now. Try again later.
* @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 GreengrassV2Exception
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample GreengrassV2Client.ResolveComponentCandidates
* @see AWS API Documentation
*/
@Override
public ResolveComponentCandidatesResponse resolveComponentCandidates(
ResolveComponentCandidatesRequest resolveComponentCandidatesRequest) throws ValidationException,
AccessDeniedException, ResourceNotFoundException, ConflictException, ThrottlingException, InternalServerException,
AwsServiceException, SdkClientException, GreengrassV2Exception {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, ResolveComponentCandidatesResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(resolveComponentCandidatesRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, resolveComponentCandidatesRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "GreengrassV2");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "ResolveComponentCandidates");
return clientHandler
.execute(new ClientExecutionParams()
.withOperationName("ResolveComponentCandidates").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(resolveComponentCandidatesRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new ResolveComponentCandidatesRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Adds tags to an IoT Greengrass resource. If a tag already exists for the resource, this operation updates the
* tag's value.
*
*
* @param tagResourceRequest
* @return Result of the TagResource operation returned by the service.
* @throws InternalServerException
* IoT Greengrass can't process your request right now. Try again later.
* @throws ValidationException
* The request isn't valid. This can occur if your request contains malformed JSON or unsupported
* characters.
* @throws ResourceNotFoundException
* The requested resource can't be found.
* @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 GreengrassV2Exception
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample GreengrassV2Client.TagResource
* @see AWS API
* Documentation
*/
@Override
public TagResourceResponse tagResource(TagResourceRequest tagResourceRequest) throws InternalServerException,
ValidationException, ResourceNotFoundException, AwsServiceException, SdkClientException, GreengrassV2Exception {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
TagResourceResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
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, "GreengrassV2");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "TagResource");
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("TagResource").withProtocolMetadata(protocolMetadata).withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler).withRequestConfiguration(clientConfiguration)
.withInput(tagResourceRequest).withMetricCollector(apiCallMetricCollector)
.withMarshaller(new TagResourceRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Removes a tag from an IoT Greengrass resource.
*
*
* @param untagResourceRequest
* @return Result of the UntagResource operation returned by the service.
* @throws InternalServerException
* IoT Greengrass can't process your request right now. Try again later.
* @throws ValidationException
* The request isn't valid. This can occur if your request contains malformed JSON or unsupported
* characters.
* @throws ResourceNotFoundException
* The requested resource can't be found.
* @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 GreengrassV2Exception
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample GreengrassV2Client.UntagResource
* @see AWS
* API Documentation
*/
@Override
public UntagResourceResponse untagResource(UntagResourceRequest untagResourceRequest) throws InternalServerException,
ValidationException, ResourceNotFoundException, AwsServiceException, SdkClientException, GreengrassV2Exception {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
UntagResourceResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
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, "GreengrassV2");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "UntagResource");
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("UntagResource").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(untagResourceRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new UntagResourceRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Updates connectivity information for a Greengrass core device.
*
*
* Connectivity information includes endpoints and ports where client devices can connect to an MQTT broker on the
* core device. When a client device calls the IoT Greengrass
* discovery API, IoT Greengrass returns connectivity information for all of the core devices where the client
* device can connect. For more information, see Connect client
* devices to core devices in the IoT Greengrass Version 2 Developer Guide.
*
*
* @param updateConnectivityInfoRequest
* @return Result of the UpdateConnectivityInfo operation returned by the service.
* @throws ValidationException
* The request isn't valid. This can occur if your request contains malformed JSON or unsupported
* characters.
* @throws InternalServerException
* IoT Greengrass can't process your request right now. Try again later.
* @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 GreengrassV2Exception
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample GreengrassV2Client.UpdateConnectivityInfo
* @see AWS API Documentation
*/
@Override
public UpdateConnectivityInfoResponse updateConnectivityInfo(UpdateConnectivityInfoRequest updateConnectivityInfoRequest)
throws ValidationException, InternalServerException, AwsServiceException, SdkClientException, GreengrassV2Exception {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, UpdateConnectivityInfoResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(updateConnectivityInfoRequest,
this.clientConfiguration);
List metricPublishers = resolveMetricPublishers(clientConfiguration, updateConnectivityInfoRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "GreengrassV2");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "UpdateConnectivityInfo");
return clientHandler
.execute(new ClientExecutionParams()
.withOperationName("UpdateConnectivityInfo").withProtocolMetadata(protocolMetadata)
.withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler)
.withRequestConfiguration(clientConfiguration).withInput(updateConnectivityInfoRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new UpdateConnectivityInfoRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
@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 void updateRetryStrategyClientConfiguration(SdkClientConfiguration.Builder configuration) {
ClientOverrideConfiguration.Builder builder = configuration.asOverrideConfigurationBuilder();
RetryMode retryMode = builder.retryMode();
if (retryMode != null) {
configuration.option(SdkClientOption.RETRY_STRATEGY, AwsRetryStrategy.forRetryMode(retryMode));
} else {
Consumer> configurator = builder.retryStrategyConfigurator();
if (configurator != null) {
RetryStrategy.Builder defaultBuilder = AwsRetryStrategy.defaultRetryStrategy().toBuilder();
configurator.accept(defaultBuilder);
configuration.option(SdkClientOption.RETRY_STRATEGY, defaultBuilder.build());
} else {
RetryStrategy retryStrategy = builder.retryStrategy();
if (retryStrategy != null) {
configuration.option(SdkClientOption.RETRY_STRATEGY, retryStrategy);
}
}
}
configuration.option(SdkClientOption.CONFIGURED_RETRY_MODE, null);
configuration.option(SdkClientOption.CONFIGURED_RETRY_STRATEGY, null);
configuration.option(SdkClientOption.CONFIGURED_RETRY_CONFIGURATOR, null);
}
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();
}
GreengrassV2ServiceClientConfigurationBuilder serviceConfigBuilder = new GreengrassV2ServiceClientConfigurationBuilder(
configuration);
for (SdkPlugin plugin : plugins) {
plugin.configureClient(serviceConfigBuilder);
}
updateRetryStrategyClientConfiguration(configuration);
return configuration.build();
}
private > T init(T builder) {
return builder
.clientConfiguration(clientConfiguration)
.defaultServiceExceptionSupplier(GreengrassV2Exception::builder)
.protocol(AwsJsonProtocol.REST_JSON)
.protocolVersion("1.1")
.registerModeledException(
ExceptionMetadata.builder().errorCode("RequestAlreadyInProgressException")
.exceptionBuilderSupplier(RequestAlreadyInProgressException::builder).httpStatusCode(400).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("ThrottlingException")
.exceptionBuilderSupplier(ThrottlingException::builder).httpStatusCode(429).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("ServiceQuotaExceededException")
.exceptionBuilderSupplier(ServiceQuotaExceededException::builder).httpStatusCode(402).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("InternalServerException")
.exceptionBuilderSupplier(InternalServerException::builder).httpStatusCode(500).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("AccessDeniedException")
.exceptionBuilderSupplier(AccessDeniedException::builder).httpStatusCode(403).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("ConflictException")
.exceptionBuilderSupplier(ConflictException::builder).httpStatusCode(409).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("ResourceNotFoundException")
.exceptionBuilderSupplier(ResourceNotFoundException::builder).httpStatusCode(404).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("ValidationException")
.exceptionBuilderSupplier(ValidationException::builder).httpStatusCode(400).build());
}
@Override
public final GreengrassV2ServiceClientConfiguration serviceClientConfiguration() {
return new GreengrassV2ServiceClientConfigurationBuilder(this.clientConfiguration.toBuilder()).build();
}
@Override
public void close() {
clientHandler.close();
}
}