software.amazon.awssdk.services.amp.DefaultAmpClient Maven / Gradle / Ivy
Show all versions of amp 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.amp;
import java.util.Collections;
import java.util.List;
import java.util.function.Consumer;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.annotations.SdkInternalApi;
import software.amazon.awssdk.awscore.AwsRequestOverrideConfiguration;
import software.amazon.awssdk.awscore.client.handler.AwsSyncClientHandler;
import software.amazon.awssdk.awscore.exception.AwsServiceException;
import software.amazon.awssdk.core.ApiName;
import software.amazon.awssdk.core.RequestOverrideConfiguration;
import software.amazon.awssdk.core.client.config.SdkClientConfiguration;
import software.amazon.awssdk.core.client.config.SdkClientOption;
import software.amazon.awssdk.core.client.handler.ClientExecutionParams;
import software.amazon.awssdk.core.client.handler.SyncClientHandler;
import software.amazon.awssdk.core.exception.SdkClientException;
import software.amazon.awssdk.core.http.HttpResponseHandler;
import software.amazon.awssdk.core.metrics.CoreMetric;
import software.amazon.awssdk.core.util.VersionInfo;
import software.amazon.awssdk.metrics.MetricCollector;
import software.amazon.awssdk.metrics.MetricPublisher;
import software.amazon.awssdk.metrics.NoOpMetricCollector;
import software.amazon.awssdk.protocols.core.ExceptionMetadata;
import software.amazon.awssdk.protocols.json.AwsJsonProtocol;
import software.amazon.awssdk.protocols.json.AwsJsonProtocolFactory;
import software.amazon.awssdk.protocols.json.BaseAwsJsonProtocolFactory;
import software.amazon.awssdk.protocols.json.JsonOperationMetadata;
import software.amazon.awssdk.services.amp.model.AccessDeniedException;
import software.amazon.awssdk.services.amp.model.AmpException;
import software.amazon.awssdk.services.amp.model.AmpRequest;
import software.amazon.awssdk.services.amp.model.ConflictException;
import software.amazon.awssdk.services.amp.model.CreateAlertManagerDefinitionRequest;
import software.amazon.awssdk.services.amp.model.CreateAlertManagerDefinitionResponse;
import software.amazon.awssdk.services.amp.model.CreateRuleGroupsNamespaceRequest;
import software.amazon.awssdk.services.amp.model.CreateRuleGroupsNamespaceResponse;
import software.amazon.awssdk.services.amp.model.CreateWorkspaceRequest;
import software.amazon.awssdk.services.amp.model.CreateWorkspaceResponse;
import software.amazon.awssdk.services.amp.model.DeleteAlertManagerDefinitionRequest;
import software.amazon.awssdk.services.amp.model.DeleteAlertManagerDefinitionResponse;
import software.amazon.awssdk.services.amp.model.DeleteRuleGroupsNamespaceRequest;
import software.amazon.awssdk.services.amp.model.DeleteRuleGroupsNamespaceResponse;
import software.amazon.awssdk.services.amp.model.DeleteWorkspaceRequest;
import software.amazon.awssdk.services.amp.model.DeleteWorkspaceResponse;
import software.amazon.awssdk.services.amp.model.DescribeAlertManagerDefinitionRequest;
import software.amazon.awssdk.services.amp.model.DescribeAlertManagerDefinitionResponse;
import software.amazon.awssdk.services.amp.model.DescribeRuleGroupsNamespaceRequest;
import software.amazon.awssdk.services.amp.model.DescribeRuleGroupsNamespaceResponse;
import software.amazon.awssdk.services.amp.model.DescribeWorkspaceRequest;
import software.amazon.awssdk.services.amp.model.DescribeWorkspaceResponse;
import software.amazon.awssdk.services.amp.model.InternalServerException;
import software.amazon.awssdk.services.amp.model.ListRuleGroupsNamespacesRequest;
import software.amazon.awssdk.services.amp.model.ListRuleGroupsNamespacesResponse;
import software.amazon.awssdk.services.amp.model.ListTagsForResourceRequest;
import software.amazon.awssdk.services.amp.model.ListTagsForResourceResponse;
import software.amazon.awssdk.services.amp.model.ListWorkspacesRequest;
import software.amazon.awssdk.services.amp.model.ListWorkspacesResponse;
import software.amazon.awssdk.services.amp.model.PutAlertManagerDefinitionRequest;
import software.amazon.awssdk.services.amp.model.PutAlertManagerDefinitionResponse;
import software.amazon.awssdk.services.amp.model.PutRuleGroupsNamespaceRequest;
import software.amazon.awssdk.services.amp.model.PutRuleGroupsNamespaceResponse;
import software.amazon.awssdk.services.amp.model.ResourceNotFoundException;
import software.amazon.awssdk.services.amp.model.ServiceQuotaExceededException;
import software.amazon.awssdk.services.amp.model.TagResourceRequest;
import software.amazon.awssdk.services.amp.model.TagResourceResponse;
import software.amazon.awssdk.services.amp.model.ThrottlingException;
import software.amazon.awssdk.services.amp.model.UntagResourceRequest;
import software.amazon.awssdk.services.amp.model.UntagResourceResponse;
import software.amazon.awssdk.services.amp.model.UpdateWorkspaceAliasRequest;
import software.amazon.awssdk.services.amp.model.UpdateWorkspaceAliasResponse;
import software.amazon.awssdk.services.amp.model.ValidationException;
import software.amazon.awssdk.services.amp.paginators.ListRuleGroupsNamespacesIterable;
import software.amazon.awssdk.services.amp.paginators.ListWorkspacesIterable;
import software.amazon.awssdk.services.amp.transform.CreateAlertManagerDefinitionRequestMarshaller;
import software.amazon.awssdk.services.amp.transform.CreateRuleGroupsNamespaceRequestMarshaller;
import software.amazon.awssdk.services.amp.transform.CreateWorkspaceRequestMarshaller;
import software.amazon.awssdk.services.amp.transform.DeleteAlertManagerDefinitionRequestMarshaller;
import software.amazon.awssdk.services.amp.transform.DeleteRuleGroupsNamespaceRequestMarshaller;
import software.amazon.awssdk.services.amp.transform.DeleteWorkspaceRequestMarshaller;
import software.amazon.awssdk.services.amp.transform.DescribeAlertManagerDefinitionRequestMarshaller;
import software.amazon.awssdk.services.amp.transform.DescribeRuleGroupsNamespaceRequestMarshaller;
import software.amazon.awssdk.services.amp.transform.DescribeWorkspaceRequestMarshaller;
import software.amazon.awssdk.services.amp.transform.ListRuleGroupsNamespacesRequestMarshaller;
import software.amazon.awssdk.services.amp.transform.ListTagsForResourceRequestMarshaller;
import software.amazon.awssdk.services.amp.transform.ListWorkspacesRequestMarshaller;
import software.amazon.awssdk.services.amp.transform.PutAlertManagerDefinitionRequestMarshaller;
import software.amazon.awssdk.services.amp.transform.PutRuleGroupsNamespaceRequestMarshaller;
import software.amazon.awssdk.services.amp.transform.TagResourceRequestMarshaller;
import software.amazon.awssdk.services.amp.transform.UntagResourceRequestMarshaller;
import software.amazon.awssdk.services.amp.transform.UpdateWorkspaceAliasRequestMarshaller;
import software.amazon.awssdk.services.amp.waiters.AmpWaiter;
import software.amazon.awssdk.utils.Logger;
/**
* Internal implementation of {@link AmpClient}.
*
* @see AmpClient#builder()
*/
@Generated("software.amazon.awssdk:codegen")
@SdkInternalApi
final class DefaultAmpClient implements AmpClient {
private static final Logger log = Logger.loggerFor(DefaultAmpClient.class);
private final SyncClientHandler clientHandler;
private final AwsJsonProtocolFactory protocolFactory;
private final SdkClientConfiguration clientConfiguration;
protected DefaultAmpClient(SdkClientConfiguration clientConfiguration) {
this.clientHandler = new AwsSyncClientHandler(clientConfiguration);
this.clientConfiguration = clientConfiguration;
this.protocolFactory = init(AwsJsonProtocolFactory.builder()).build();
}
@Override
public final String serviceName() {
return SERVICE_NAME;
}
/**
*
* Create an alert manager definition.
*
*
* @param createAlertManagerDefinitionRequest
* Represents the input of a CreateAlertManagerDefinition operation.
* @return Result of the CreateAlertManagerDefinition operation returned by the service.
* @throws ThrottlingException
* Request was denied due to request throttling.
* @throws ConflictException
* Updating or deleting a resource can cause an inconsistent state.
* @throws ValidationException
* The input fails to satisfy the constraints specified by an AWS service.
* @throws ResourceNotFoundException
* Request references a resource which does not exist.
* @throws AccessDeniedException
* User does not have sufficient access to perform this action.
* @throws InternalServerException
* Unexpected error during processing of request.
* @throws ServiceQuotaExceededException
* Request would cause a service quota to be exceeded.
* @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 AmpException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample AmpClient.CreateAlertManagerDefinition
* @see AWS API Documentation
*/
@Override
public CreateAlertManagerDefinitionResponse createAlertManagerDefinition(
CreateAlertManagerDefinitionRequest createAlertManagerDefinitionRequest) throws ThrottlingException,
ConflictException, ValidationException, ResourceNotFoundException, AccessDeniedException, InternalServerException,
ServiceQuotaExceededException, AwsServiceException, SdkClientException, AmpException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, CreateAlertManagerDefinitionResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
List metricPublishers = resolveMetricPublishers(clientConfiguration, createAlertManagerDefinitionRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "amp");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "CreateAlertManagerDefinition");
return clientHandler
.execute(new ClientExecutionParams()
.withOperationName("CreateAlertManagerDefinition").withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler).withInput(createAlertManagerDefinitionRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new CreateAlertManagerDefinitionRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Create a rule group namespace.
*
*
* @param createRuleGroupsNamespaceRequest
* Represents the input of a CreateRuleGroupsNamespace operation.
* @return Result of the CreateRuleGroupsNamespace operation returned by the service.
* @throws ThrottlingException
* Request was denied due to request throttling.
* @throws ConflictException
* Updating or deleting a resource can cause an inconsistent state.
* @throws ValidationException
* The input fails to satisfy the constraints specified by an AWS service.
* @throws ResourceNotFoundException
* Request references a resource which does not exist.
* @throws AccessDeniedException
* User does not have sufficient access to perform this action.
* @throws InternalServerException
* Unexpected error during processing of request.
* @throws ServiceQuotaExceededException
* Request would cause a service quota to be exceeded.
* @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 AmpException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample AmpClient.CreateRuleGroupsNamespace
* @see AWS
* API Documentation
*/
@Override
public CreateRuleGroupsNamespaceResponse createRuleGroupsNamespace(
CreateRuleGroupsNamespaceRequest createRuleGroupsNamespaceRequest) throws ThrottlingException, ConflictException,
ValidationException, ResourceNotFoundException, AccessDeniedException, InternalServerException,
ServiceQuotaExceededException, AwsServiceException, SdkClientException, AmpException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, CreateRuleGroupsNamespaceResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
List metricPublishers = resolveMetricPublishers(clientConfiguration, createRuleGroupsNamespaceRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "amp");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "CreateRuleGroupsNamespace");
return clientHandler
.execute(new ClientExecutionParams()
.withOperationName("CreateRuleGroupsNamespace").withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler).withInput(createRuleGroupsNamespaceRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new CreateRuleGroupsNamespaceRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Creates a new AMP workspace.
*
*
* @param createWorkspaceRequest
* Represents the input of a CreateWorkspace operation.
* @return Result of the CreateWorkspace operation returned by the service.
* @throws ThrottlingException
* Request was denied due to request throttling.
* @throws ConflictException
* Updating or deleting a resource can cause an inconsistent state.
* @throws ValidationException
* The input fails to satisfy the constraints specified by an AWS service.
* @throws AccessDeniedException
* User does not have sufficient access to perform this action.
* @throws InternalServerException
* Unexpected error during processing of request.
* @throws ServiceQuotaExceededException
* Request would cause a service quota to be exceeded.
* @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 AmpException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample AmpClient.CreateWorkspace
* @see AWS API
* Documentation
*/
@Override
public CreateWorkspaceResponse createWorkspace(CreateWorkspaceRequest createWorkspaceRequest) throws ThrottlingException,
ConflictException, ValidationException, AccessDeniedException, InternalServerException,
ServiceQuotaExceededException, AwsServiceException, SdkClientException, AmpException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
CreateWorkspaceResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
List metricPublishers = resolveMetricPublishers(clientConfiguration, createWorkspaceRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "amp");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "CreateWorkspace");
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("CreateWorkspace").withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler).withInput(createWorkspaceRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new CreateWorkspaceRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Deletes an alert manager definition.
*
*
* @param deleteAlertManagerDefinitionRequest
* Represents the input of a DeleteAlertManagerDefinition operation.
* @return Result of the DeleteAlertManagerDefinition operation returned by the service.
* @throws ThrottlingException
* Request was denied due to request throttling.
* @throws ConflictException
* Updating or deleting a resource can cause an inconsistent state.
* @throws ValidationException
* The input fails to satisfy the constraints specified by an AWS service.
* @throws ResourceNotFoundException
* Request references a resource which does not exist.
* @throws AccessDeniedException
* User does not have sufficient access to perform this action.
* @throws InternalServerException
* Unexpected error during processing of request.
* @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 AmpException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample AmpClient.DeleteAlertManagerDefinition
* @see AWS API Documentation
*/
@Override
public DeleteAlertManagerDefinitionResponse deleteAlertManagerDefinition(
DeleteAlertManagerDefinitionRequest deleteAlertManagerDefinitionRequest) throws ThrottlingException,
ConflictException, ValidationException, ResourceNotFoundException, AccessDeniedException, InternalServerException,
AwsServiceException, SdkClientException, AmpException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, DeleteAlertManagerDefinitionResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
List metricPublishers = resolveMetricPublishers(clientConfiguration, deleteAlertManagerDefinitionRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "amp");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "DeleteAlertManagerDefinition");
return clientHandler
.execute(new ClientExecutionParams()
.withOperationName("DeleteAlertManagerDefinition").withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler).withInput(deleteAlertManagerDefinitionRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new DeleteAlertManagerDefinitionRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Delete a rule groups namespace.
*
*
* @param deleteRuleGroupsNamespaceRequest
* Represents the input of a DeleteRuleGroupsNamespace operation.
* @return Result of the DeleteRuleGroupsNamespace operation returned by the service.
* @throws ThrottlingException
* Request was denied due to request throttling.
* @throws ConflictException
* Updating or deleting a resource can cause an inconsistent state.
* @throws ValidationException
* The input fails to satisfy the constraints specified by an AWS service.
* @throws ResourceNotFoundException
* Request references a resource which does not exist.
* @throws AccessDeniedException
* User does not have sufficient access to perform this action.
* @throws InternalServerException
* Unexpected error during processing of request.
* @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 AmpException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample AmpClient.DeleteRuleGroupsNamespace
* @see AWS
* API Documentation
*/
@Override
public DeleteRuleGroupsNamespaceResponse deleteRuleGroupsNamespace(
DeleteRuleGroupsNamespaceRequest deleteRuleGroupsNamespaceRequest) throws ThrottlingException, ConflictException,
ValidationException, ResourceNotFoundException, AccessDeniedException, InternalServerException, AwsServiceException,
SdkClientException, AmpException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, DeleteRuleGroupsNamespaceResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
List metricPublishers = resolveMetricPublishers(clientConfiguration, deleteRuleGroupsNamespaceRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "amp");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "DeleteRuleGroupsNamespace");
return clientHandler
.execute(new ClientExecutionParams()
.withOperationName("DeleteRuleGroupsNamespace").withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler).withInput(deleteRuleGroupsNamespaceRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new DeleteRuleGroupsNamespaceRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Deletes an AMP workspace.
*
*
* @param deleteWorkspaceRequest
* Represents the input of a DeleteWorkspace operation.
* @return Result of the DeleteWorkspace operation returned by the service.
* @throws ThrottlingException
* Request was denied due to request throttling.
* @throws ConflictException
* Updating or deleting a resource can cause an inconsistent state.
* @throws ValidationException
* The input fails to satisfy the constraints specified by an AWS service.
* @throws ResourceNotFoundException
* Request references a resource which does not exist.
* @throws AccessDeniedException
* User does not have sufficient access to perform this action.
* @throws InternalServerException
* Unexpected error during processing of request.
* @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 AmpException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample AmpClient.DeleteWorkspace
* @see AWS API
* Documentation
*/
@Override
public DeleteWorkspaceResponse deleteWorkspace(DeleteWorkspaceRequest deleteWorkspaceRequest) throws ThrottlingException,
ConflictException, ValidationException, ResourceNotFoundException, AccessDeniedException, InternalServerException,
AwsServiceException, SdkClientException, AmpException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
DeleteWorkspaceResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
List metricPublishers = resolveMetricPublishers(clientConfiguration, deleteWorkspaceRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "amp");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "DeleteWorkspace");
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("DeleteWorkspace").withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler).withInput(deleteWorkspaceRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new DeleteWorkspaceRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Describes an alert manager definition.
*
*
* @param describeAlertManagerDefinitionRequest
* Represents the input of a DescribeAlertManagerDefinition operation.
* @return Result of the DescribeAlertManagerDefinition operation returned by the service.
* @throws ThrottlingException
* Request was denied due to request throttling.
* @throws ValidationException
* The input fails to satisfy the constraints specified by an AWS service.
* @throws ResourceNotFoundException
* Request references a resource which does not exist.
* @throws AccessDeniedException
* User does not have sufficient access to perform this action.
* @throws InternalServerException
* Unexpected error during processing of request.
* @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 AmpException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample AmpClient.DescribeAlertManagerDefinition
* @see AWS API Documentation
*/
@Override
public DescribeAlertManagerDefinitionResponse describeAlertManagerDefinition(
DescribeAlertManagerDefinitionRequest describeAlertManagerDefinitionRequest) throws ThrottlingException,
ValidationException, ResourceNotFoundException, AccessDeniedException, InternalServerException, AwsServiceException,
SdkClientException, AmpException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, DescribeAlertManagerDefinitionResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
List metricPublishers = resolveMetricPublishers(clientConfiguration,
describeAlertManagerDefinitionRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "amp");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "DescribeAlertManagerDefinition");
return clientHandler
.execute(new ClientExecutionParams()
.withOperationName("DescribeAlertManagerDefinition").withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler).withInput(describeAlertManagerDefinitionRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new DescribeAlertManagerDefinitionRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Describe a rule groups namespace.
*
*
* @param describeRuleGroupsNamespaceRequest
* Represents the input of a DescribeRuleGroupsNamespace operation.
* @return Result of the DescribeRuleGroupsNamespace operation returned by the service.
* @throws ThrottlingException
* Request was denied due to request throttling.
* @throws ValidationException
* The input fails to satisfy the constraints specified by an AWS service.
* @throws ResourceNotFoundException
* Request references a resource which does not exist.
* @throws AccessDeniedException
* User does not have sufficient access to perform this action.
* @throws InternalServerException
* Unexpected error during processing of request.
* @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 AmpException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample AmpClient.DescribeRuleGroupsNamespace
* @see AWS API Documentation
*/
@Override
public DescribeRuleGroupsNamespaceResponse describeRuleGroupsNamespace(
DescribeRuleGroupsNamespaceRequest describeRuleGroupsNamespaceRequest) throws ThrottlingException,
ValidationException, ResourceNotFoundException, AccessDeniedException, InternalServerException, AwsServiceException,
SdkClientException, AmpException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, DescribeRuleGroupsNamespaceResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
List metricPublishers = resolveMetricPublishers(clientConfiguration, describeRuleGroupsNamespaceRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "amp");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "DescribeRuleGroupsNamespace");
return clientHandler
.execute(new ClientExecutionParams()
.withOperationName("DescribeRuleGroupsNamespace").withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler).withInput(describeRuleGroupsNamespaceRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new DescribeRuleGroupsNamespaceRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Describes an existing AMP workspace.
*
*
* @param describeWorkspaceRequest
* Represents the input of a DescribeWorkspace operation.
* @return Result of the DescribeWorkspace operation returned by the service.
* @throws ThrottlingException
* Request was denied due to request throttling.
* @throws ValidationException
* The input fails to satisfy the constraints specified by an AWS service.
* @throws ResourceNotFoundException
* Request references a resource which does not exist.
* @throws AccessDeniedException
* User does not have sufficient access to perform this action.
* @throws InternalServerException
* Unexpected error during processing of request.
* @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 AmpException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample AmpClient.DescribeWorkspace
* @see AWS API
* Documentation
*/
@Override
public DescribeWorkspaceResponse describeWorkspace(DescribeWorkspaceRequest describeWorkspaceRequest)
throws ThrottlingException, ValidationException, ResourceNotFoundException, AccessDeniedException,
InternalServerException, AwsServiceException, SdkClientException, AmpException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
DescribeWorkspaceResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
List metricPublishers = resolveMetricPublishers(clientConfiguration, describeWorkspaceRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "amp");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "DescribeWorkspace");
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("DescribeWorkspace").withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler).withInput(describeWorkspaceRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new DescribeWorkspaceRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Lists rule groups namespaces.
*
*
* @param listRuleGroupsNamespacesRequest
* Represents the input of a ListRuleGroupsNamespaces operation.
* @return Result of the ListRuleGroupsNamespaces operation returned by the service.
* @throws ThrottlingException
* Request was denied due to request throttling.
* @throws ValidationException
* The input fails to satisfy the constraints specified by an AWS service.
* @throws ResourceNotFoundException
* Request references a resource which does not exist.
* @throws AccessDeniedException
* User does not have sufficient access to perform this action.
* @throws InternalServerException
* Unexpected error during processing of request.
* @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 AmpException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample AmpClient.ListRuleGroupsNamespaces
* @see AWS
* API Documentation
*/
@Override
public ListRuleGroupsNamespacesResponse listRuleGroupsNamespaces(
ListRuleGroupsNamespacesRequest listRuleGroupsNamespacesRequest) throws ThrottlingException, ValidationException,
ResourceNotFoundException, AccessDeniedException, InternalServerException, AwsServiceException, SdkClientException,
AmpException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, ListRuleGroupsNamespacesResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
List metricPublishers = resolveMetricPublishers(clientConfiguration, listRuleGroupsNamespacesRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "amp");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "ListRuleGroupsNamespaces");
return clientHandler
.execute(new ClientExecutionParams()
.withOperationName("ListRuleGroupsNamespaces").withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler).withInput(listRuleGroupsNamespacesRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new ListRuleGroupsNamespacesRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Lists rule groups namespaces.
*
*
*
* This is a variant of
* {@link #listRuleGroupsNamespaces(software.amazon.awssdk.services.amp.model.ListRuleGroupsNamespacesRequest)}
* operation. The return type is a custom iterable that can be used to iterate through all the pages. SDK will
* internally handle making service calls for you.
*
*
* When this operation is called, a custom iterable is returned but no service calls are made yet. So there is no
* guarantee that the request is valid. As you iterate through the iterable, SDK will start lazily loading response
* pages by making service calls until there are no pages left or your iteration stops. If there are errors in your
* request, you will see the failures only after you start iterating through the iterable.
*
*
*
* The following are few ways to iterate through the response pages:
*
* 1) Using a Stream
*
*
* {@code
* software.amazon.awssdk.services.amp.paginators.ListRuleGroupsNamespacesIterable responses = client.listRuleGroupsNamespacesPaginator(request);
* responses.stream().forEach(....);
* }
*
*
* 2) Using For loop
*
*
* {
* @code
* software.amazon.awssdk.services.amp.paginators.ListRuleGroupsNamespacesIterable responses = client
* .listRuleGroupsNamespacesPaginator(request);
* for (software.amazon.awssdk.services.amp.model.ListRuleGroupsNamespacesResponse response : responses) {
* // do something;
* }
* }
*
*
* 3) Use iterator directly
*
*
* {@code
* software.amazon.awssdk.services.amp.paginators.ListRuleGroupsNamespacesIterable responses = client.listRuleGroupsNamespacesPaginator(request);
* responses.iterator().forEachRemaining(....);
* }
*
*
* Please notice that the configuration of maxResults won't limit the number of results you get with the
* paginator. It only limits the number of results in each page.
*
*
* Note: If you prefer to have control on service calls, use the
* {@link #listRuleGroupsNamespaces(software.amazon.awssdk.services.amp.model.ListRuleGroupsNamespacesRequest)}
* operation.
*
*
* @param listRuleGroupsNamespacesRequest
* Represents the input of a ListRuleGroupsNamespaces operation.
* @return A custom iterable that can be used to iterate through all the response pages.
* @throws ThrottlingException
* Request was denied due to request throttling.
* @throws ValidationException
* The input fails to satisfy the constraints specified by an AWS service.
* @throws ResourceNotFoundException
* Request references a resource which does not exist.
* @throws AccessDeniedException
* User does not have sufficient access to perform this action.
* @throws InternalServerException
* Unexpected error during processing of request.
* @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 AmpException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample AmpClient.ListRuleGroupsNamespaces
* @see AWS
* API Documentation
*/
@Override
public ListRuleGroupsNamespacesIterable listRuleGroupsNamespacesPaginator(
ListRuleGroupsNamespacesRequest listRuleGroupsNamespacesRequest) throws ThrottlingException, ValidationException,
ResourceNotFoundException, AccessDeniedException, InternalServerException, AwsServiceException, SdkClientException,
AmpException {
return new ListRuleGroupsNamespacesIterable(this, applyPaginatorUserAgent(listRuleGroupsNamespacesRequest));
}
/**
*
* Lists the tags you have assigned to the resource.
*
*
* @param listTagsForResourceRequest
* @return Result of the ListTagsForResource operation returned by the service.
* @throws ThrottlingException
* Request was denied due to request throttling.
* @throws ValidationException
* The input fails to satisfy the constraints specified by an AWS service.
* @throws ResourceNotFoundException
* Request references a resource which does not exist.
* @throws AccessDeniedException
* User does not have sufficient access to perform this action.
* @throws InternalServerException
* Unexpected error during processing of request.
* @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 AmpException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample AmpClient.ListTagsForResource
* @see AWS API
* Documentation
*/
@Override
public ListTagsForResourceResponse listTagsForResource(ListTagsForResourceRequest listTagsForResourceRequest)
throws ThrottlingException, ValidationException, ResourceNotFoundException, AccessDeniedException,
InternalServerException, AwsServiceException, SdkClientException, AmpException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, ListTagsForResourceResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
List metricPublishers = resolveMetricPublishers(clientConfiguration, listTagsForResourceRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "amp");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "ListTagsForResource");
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("ListTagsForResource").withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler).withInput(listTagsForResourceRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new ListTagsForResourceRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Lists all AMP workspaces, including workspaces being created or deleted.
*
*
* @param listWorkspacesRequest
* Represents the input of a ListWorkspaces operation.
* @return Result of the ListWorkspaces operation returned by the service.
* @throws ThrottlingException
* Request was denied due to request throttling.
* @throws ValidationException
* The input fails to satisfy the constraints specified by an AWS service.
* @throws AccessDeniedException
* User does not have sufficient access to perform this action.
* @throws InternalServerException
* Unexpected error during processing of request.
* @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 AmpException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample AmpClient.ListWorkspaces
* @see AWS API
* Documentation
*/
@Override
public ListWorkspacesResponse listWorkspaces(ListWorkspacesRequest listWorkspacesRequest) throws ThrottlingException,
ValidationException, AccessDeniedException, InternalServerException, AwsServiceException, SdkClientException,
AmpException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
ListWorkspacesResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
List metricPublishers = resolveMetricPublishers(clientConfiguration, listWorkspacesRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "amp");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "ListWorkspaces");
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("ListWorkspaces").withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler).withInput(listWorkspacesRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new ListWorkspacesRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Lists all AMP workspaces, including workspaces being created or deleted.
*
*
*
* This is a variant of {@link #listWorkspaces(software.amazon.awssdk.services.amp.model.ListWorkspacesRequest)}
* operation. The return type is a custom iterable that can be used to iterate through all the pages. SDK will
* internally handle making service calls for you.
*
*
* When this operation is called, a custom iterable is returned but no service calls are made yet. So there is no
* guarantee that the request is valid. As you iterate through the iterable, SDK will start lazily loading response
* pages by making service calls until there are no pages left or your iteration stops. If there are errors in your
* request, you will see the failures only after you start iterating through the iterable.
*
*
*
* The following are few ways to iterate through the response pages:
*
* 1) Using a Stream
*
*
* {@code
* software.amazon.awssdk.services.amp.paginators.ListWorkspacesIterable responses = client.listWorkspacesPaginator(request);
* responses.stream().forEach(....);
* }
*
*
* 2) Using For loop
*
*
* {
* @code
* software.amazon.awssdk.services.amp.paginators.ListWorkspacesIterable responses = client.listWorkspacesPaginator(request);
* for (software.amazon.awssdk.services.amp.model.ListWorkspacesResponse response : responses) {
* // do something;
* }
* }
*
*
* 3) Use iterator directly
*
*
* {@code
* software.amazon.awssdk.services.amp.paginators.ListWorkspacesIterable responses = client.listWorkspacesPaginator(request);
* responses.iterator().forEachRemaining(....);
* }
*
*
* Please notice that the configuration of maxResults won't limit the number of results you get with the
* paginator. It only limits the number of results in each page.
*
*
* Note: If you prefer to have control on service calls, use the
* {@link #listWorkspaces(software.amazon.awssdk.services.amp.model.ListWorkspacesRequest)} operation.
*
*
* @param listWorkspacesRequest
* Represents the input of a ListWorkspaces operation.
* @return A custom iterable that can be used to iterate through all the response pages.
* @throws ThrottlingException
* Request was denied due to request throttling.
* @throws ValidationException
* The input fails to satisfy the constraints specified by an AWS service.
* @throws AccessDeniedException
* User does not have sufficient access to perform this action.
* @throws InternalServerException
* Unexpected error during processing of request.
* @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 AmpException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample AmpClient.ListWorkspaces
* @see AWS API
* Documentation
*/
@Override
public ListWorkspacesIterable listWorkspacesPaginator(ListWorkspacesRequest listWorkspacesRequest)
throws ThrottlingException, ValidationException, AccessDeniedException, InternalServerException, AwsServiceException,
SdkClientException, AmpException {
return new ListWorkspacesIterable(this, applyPaginatorUserAgent(listWorkspacesRequest));
}
/**
*
* Update an alert manager definition.
*
*
* @param putAlertManagerDefinitionRequest
* Represents the input of a PutAlertManagerDefinition operation.
* @return Result of the PutAlertManagerDefinition operation returned by the service.
* @throws ThrottlingException
* Request was denied due to request throttling.
* @throws ConflictException
* Updating or deleting a resource can cause an inconsistent state.
* @throws ValidationException
* The input fails to satisfy the constraints specified by an AWS service.
* @throws ResourceNotFoundException
* Request references a resource which does not exist.
* @throws AccessDeniedException
* User does not have sufficient access to perform this action.
* @throws InternalServerException
* Unexpected error during processing of request.
* @throws ServiceQuotaExceededException
* Request would cause a service quota to be exceeded.
* @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 AmpException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample AmpClient.PutAlertManagerDefinition
* @see AWS
* API Documentation
*/
@Override
public PutAlertManagerDefinitionResponse putAlertManagerDefinition(
PutAlertManagerDefinitionRequest putAlertManagerDefinitionRequest) throws ThrottlingException, ConflictException,
ValidationException, ResourceNotFoundException, AccessDeniedException, InternalServerException,
ServiceQuotaExceededException, AwsServiceException, SdkClientException, AmpException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, PutAlertManagerDefinitionResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
List metricPublishers = resolveMetricPublishers(clientConfiguration, putAlertManagerDefinitionRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "amp");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "PutAlertManagerDefinition");
return clientHandler
.execute(new ClientExecutionParams()
.withOperationName("PutAlertManagerDefinition").withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler).withInput(putAlertManagerDefinitionRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new PutAlertManagerDefinitionRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Update a rule groups namespace.
*
*
* @param putRuleGroupsNamespaceRequest
* Represents the input of a PutRuleGroupsNamespace operation.
* @return Result of the PutRuleGroupsNamespace operation returned by the service.
* @throws ThrottlingException
* Request was denied due to request throttling.
* @throws ConflictException
* Updating or deleting a resource can cause an inconsistent state.
* @throws ValidationException
* The input fails to satisfy the constraints specified by an AWS service.
* @throws ResourceNotFoundException
* Request references a resource which does not exist.
* @throws AccessDeniedException
* User does not have sufficient access to perform this action.
* @throws InternalServerException
* Unexpected error during processing of request.
* @throws ServiceQuotaExceededException
* Request would cause a service quota to be exceeded.
* @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 AmpException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample AmpClient.PutRuleGroupsNamespace
* @see AWS
* API Documentation
*/
@Override
public PutRuleGroupsNamespaceResponse putRuleGroupsNamespace(PutRuleGroupsNamespaceRequest putRuleGroupsNamespaceRequest)
throws ThrottlingException, ConflictException, ValidationException, ResourceNotFoundException, AccessDeniedException,
InternalServerException, ServiceQuotaExceededException, AwsServiceException, SdkClientException, AmpException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, PutRuleGroupsNamespaceResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
List metricPublishers = resolveMetricPublishers(clientConfiguration, putRuleGroupsNamespaceRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "amp");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "PutRuleGroupsNamespace");
return clientHandler
.execute(new ClientExecutionParams()
.withOperationName("PutRuleGroupsNamespace").withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler).withInput(putRuleGroupsNamespaceRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new PutRuleGroupsNamespaceRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Creates tags for the specified resource.
*
*
* @param tagResourceRequest
* @return Result of the TagResource operation returned by the service.
* @throws ThrottlingException
* Request was denied due to request throttling.
* @throws ValidationException
* The input fails to satisfy the constraints specified by an AWS service.
* @throws ResourceNotFoundException
* Request references a resource which does not exist.
* @throws AccessDeniedException
* User does not have sufficient access to perform this action.
* @throws InternalServerException
* Unexpected error during processing of request.
* @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 AmpException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample AmpClient.TagResource
* @see AWS API
* Documentation
*/
@Override
public TagResourceResponse tagResource(TagResourceRequest tagResourceRequest) throws ThrottlingException,
ValidationException, ResourceNotFoundException, AccessDeniedException, InternalServerException, AwsServiceException,
SdkClientException, AmpException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
TagResourceResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
List metricPublishers = resolveMetricPublishers(clientConfiguration, tagResourceRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "amp");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "TagResource");
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("TagResource").withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler).withInput(tagResourceRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new TagResourceRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Deletes tags from the specified resource.
*
*
* @param untagResourceRequest
* @return Result of the UntagResource operation returned by the service.
* @throws ThrottlingException
* Request was denied due to request throttling.
* @throws ValidationException
* The input fails to satisfy the constraints specified by an AWS service.
* @throws ResourceNotFoundException
* Request references a resource which does not exist.
* @throws AccessDeniedException
* User does not have sufficient access to perform this action.
* @throws InternalServerException
* Unexpected error during processing of request.
* @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 AmpException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample AmpClient.UntagResource
* @see AWS API
* Documentation
*/
@Override
public UntagResourceResponse untagResource(UntagResourceRequest untagResourceRequest) throws ThrottlingException,
ValidationException, ResourceNotFoundException, AccessDeniedException, InternalServerException, AwsServiceException,
SdkClientException, AmpException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
UntagResourceResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
List metricPublishers = resolveMetricPublishers(clientConfiguration, untagResourceRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "amp");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "UntagResource");
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("UntagResource").withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler).withInput(untagResourceRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new UntagResourceRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
*
* Updates an AMP workspace alias.
*
*
* @param updateWorkspaceAliasRequest
* Represents the input of an UpdateWorkspaceAlias operation.
* @return Result of the UpdateWorkspaceAlias operation returned by the service.
* @throws ThrottlingException
* Request was denied due to request throttling.
* @throws ConflictException
* Updating or deleting a resource can cause an inconsistent state.
* @throws ValidationException
* The input fails to satisfy the constraints specified by an AWS service.
* @throws ResourceNotFoundException
* Request references a resource which does not exist.
* @throws AccessDeniedException
* User does not have sufficient access to perform this action.
* @throws InternalServerException
* Unexpected error during processing of request.
* @throws ServiceQuotaExceededException
* Request would cause a service quota to be exceeded.
* @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 AmpException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample AmpClient.UpdateWorkspaceAlias
* @see AWS API
* Documentation
*/
@Override
public UpdateWorkspaceAliasResponse updateWorkspaceAlias(UpdateWorkspaceAliasRequest updateWorkspaceAliasRequest)
throws ThrottlingException, ConflictException, ValidationException, ResourceNotFoundException, AccessDeniedException,
InternalServerException, ServiceQuotaExceededException, AwsServiceException, SdkClientException, AmpException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, UpdateWorkspaceAliasResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
List metricPublishers = resolveMetricPublishers(clientConfiguration, updateWorkspaceAliasRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "amp");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "UpdateWorkspaceAlias");
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("UpdateWorkspaceAlias").withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler).withInput(updateWorkspaceAliasRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new UpdateWorkspaceAliasRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
private static List resolveMetricPublishers(SdkClientConfiguration clientConfiguration,
RequestOverrideConfiguration requestOverrideConfiguration) {
List publishers = null;
if (requestOverrideConfiguration != null) {
publishers = requestOverrideConfiguration.metricPublishers();
}
if (publishers == null || publishers.isEmpty()) {
publishers = clientConfiguration.option(SdkClientOption.METRIC_PUBLISHERS);
}
if (publishers == null) {
publishers = Collections.emptyList();
}
return publishers;
}
private HttpResponseHandler createErrorResponseHandler(BaseAwsJsonProtocolFactory protocolFactory,
JsonOperationMetadata operationMetadata) {
return protocolFactory.createErrorResponseHandler(operationMetadata);
}
private > T init(T builder) {
return builder
.clientConfiguration(clientConfiguration)
.defaultServiceExceptionSupplier(AmpException::builder)
.protocol(AwsJsonProtocol.REST_JSON)
.protocolVersion("1.1")
.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("ThrottlingException")
.exceptionBuilderSupplier(ThrottlingException::builder).httpStatusCode(429).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("ValidationException")
.exceptionBuilderSupplier(ValidationException::builder).httpStatusCode(400).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("ServiceQuotaExceededException")
.exceptionBuilderSupplier(ServiceQuotaExceededException::builder).httpStatusCode(402).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("InternalServerException")
.exceptionBuilderSupplier(InternalServerException::builder).httpStatusCode(500).build());
}
@Override
public void close() {
clientHandler.close();
}
private T applyPaginatorUserAgent(T request) {
Consumer userAgentApplier = b -> b.addApiName(ApiName.builder()
.version(VersionInfo.SDK_VERSION).name("PAGINATED").build());
AwsRequestOverrideConfiguration overrideConfiguration = request.overrideConfiguration()
.map(c -> c.toBuilder().applyMutation(userAgentApplier).build())
.orElse((AwsRequestOverrideConfiguration.builder().applyMutation(userAgentApplier).build()));
return (T) request.toBuilder().overrideConfiguration(overrideConfiguration).build();
}
@Override
public AmpWaiter waiter() {
return AmpWaiter.builder().client(this).build();
}
}