software.amazon.awssdk.services.pinpointsmsvoice.DefaultPinpointSmsVoiceClient Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of pinpointsmsvoice Show documentation
Show all versions of pinpointsmsvoice Show documentation
The AWS Java SDK for Pinpoint SMS Voice module holds the client classes that are used for
communicating with Pinpoint SMS Voice.
/*
* 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.pinpointsmsvoice;
import java.util.Collections;
import java.util.List;
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.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.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.pinpointsmsvoice.model.AlreadyExistsException;
import software.amazon.awssdk.services.pinpointsmsvoice.model.BadRequestException;
import software.amazon.awssdk.services.pinpointsmsvoice.model.CreateConfigurationSetEventDestinationRequest;
import software.amazon.awssdk.services.pinpointsmsvoice.model.CreateConfigurationSetEventDestinationResponse;
import software.amazon.awssdk.services.pinpointsmsvoice.model.CreateConfigurationSetRequest;
import software.amazon.awssdk.services.pinpointsmsvoice.model.CreateConfigurationSetResponse;
import software.amazon.awssdk.services.pinpointsmsvoice.model.DeleteConfigurationSetEventDestinationRequest;
import software.amazon.awssdk.services.pinpointsmsvoice.model.DeleteConfigurationSetEventDestinationResponse;
import software.amazon.awssdk.services.pinpointsmsvoice.model.DeleteConfigurationSetRequest;
import software.amazon.awssdk.services.pinpointsmsvoice.model.DeleteConfigurationSetResponse;
import software.amazon.awssdk.services.pinpointsmsvoice.model.GetConfigurationSetEventDestinationsRequest;
import software.amazon.awssdk.services.pinpointsmsvoice.model.GetConfigurationSetEventDestinationsResponse;
import software.amazon.awssdk.services.pinpointsmsvoice.model.InternalServiceErrorException;
import software.amazon.awssdk.services.pinpointsmsvoice.model.LimitExceededException;
import software.amazon.awssdk.services.pinpointsmsvoice.model.ListConfigurationSetsRequest;
import software.amazon.awssdk.services.pinpointsmsvoice.model.ListConfigurationSetsResponse;
import software.amazon.awssdk.services.pinpointsmsvoice.model.NotFoundException;
import software.amazon.awssdk.services.pinpointsmsvoice.model.PinpointSmsVoiceException;
import software.amazon.awssdk.services.pinpointsmsvoice.model.SendVoiceMessageRequest;
import software.amazon.awssdk.services.pinpointsmsvoice.model.SendVoiceMessageResponse;
import software.amazon.awssdk.services.pinpointsmsvoice.model.TooManyRequestsException;
import software.amazon.awssdk.services.pinpointsmsvoice.model.UpdateConfigurationSetEventDestinationRequest;
import software.amazon.awssdk.services.pinpointsmsvoice.model.UpdateConfigurationSetEventDestinationResponse;
import software.amazon.awssdk.services.pinpointsmsvoice.transform.CreateConfigurationSetEventDestinationRequestMarshaller;
import software.amazon.awssdk.services.pinpointsmsvoice.transform.CreateConfigurationSetRequestMarshaller;
import software.amazon.awssdk.services.pinpointsmsvoice.transform.DeleteConfigurationSetEventDestinationRequestMarshaller;
import software.amazon.awssdk.services.pinpointsmsvoice.transform.DeleteConfigurationSetRequestMarshaller;
import software.amazon.awssdk.services.pinpointsmsvoice.transform.GetConfigurationSetEventDestinationsRequestMarshaller;
import software.amazon.awssdk.services.pinpointsmsvoice.transform.ListConfigurationSetsRequestMarshaller;
import software.amazon.awssdk.services.pinpointsmsvoice.transform.SendVoiceMessageRequestMarshaller;
import software.amazon.awssdk.services.pinpointsmsvoice.transform.UpdateConfigurationSetEventDestinationRequestMarshaller;
import software.amazon.awssdk.utils.Logger;
/**
* Internal implementation of {@link PinpointSmsVoiceClient}.
*
* @see PinpointSmsVoiceClient#builder()
*/
@Generated("software.amazon.awssdk:codegen")
@SdkInternalApi
final class DefaultPinpointSmsVoiceClient implements PinpointSmsVoiceClient {
private static final Logger log = Logger.loggerFor(DefaultPinpointSmsVoiceClient.class);
private final SyncClientHandler clientHandler;
private final AwsJsonProtocolFactory protocolFactory;
private final SdkClientConfiguration clientConfiguration;
private final PinpointSmsVoiceServiceClientConfiguration serviceClientConfiguration;
protected DefaultPinpointSmsVoiceClient(PinpointSmsVoiceServiceClientConfiguration serviceClientConfiguration,
SdkClientConfiguration clientConfiguration) {
this.clientHandler = new AwsSyncClientHandler(clientConfiguration);
this.clientConfiguration = clientConfiguration;
this.serviceClientConfiguration = serviceClientConfiguration;
this.protocolFactory = init(AwsJsonProtocolFactory.builder()).build();
}
/**
* Create a new configuration set. After you create the configuration set, you can add one or more event
* destinations to it.
*
* @param createConfigurationSetRequest
* A request to create a new configuration set.
* @return Result of the CreateConfigurationSet operation returned by the service.
* @throws TooManyRequestsException
* TooManyRequestsException
* @throws BadRequestException
* BadRequestException
* @throws LimitExceededException
* LimitExceededException
* @throws InternalServiceErrorException
* InternalServiceErrorException
* @throws AlreadyExistsException
* AlreadyExistsException
* @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 PinpointSmsVoiceException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample PinpointSmsVoiceClient.CreateConfigurationSet
* @see AWS API Documentation
*/
@Override
public CreateConfigurationSetResponse createConfigurationSet(CreateConfigurationSetRequest createConfigurationSetRequest)
throws TooManyRequestsException, BadRequestException, LimitExceededException, InternalServiceErrorException,
AlreadyExistsException, AwsServiceException, SdkClientException, PinpointSmsVoiceException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, CreateConfigurationSetResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
List metricPublishers = resolveMetricPublishers(clientConfiguration, createConfigurationSetRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Pinpoint SMS Voice");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "CreateConfigurationSet");
return clientHandler
.execute(new ClientExecutionParams()
.withOperationName("CreateConfigurationSet").withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler).withInput(createConfigurationSetRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new CreateConfigurationSetRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
* Create a new event destination in a configuration set.
*
* @param createConfigurationSetEventDestinationRequest
* Create a new event destination in a configuration set.
* @return Result of the CreateConfigurationSetEventDestination operation returned by the service.
* @throws BadRequestException
* BadRequestException
* @throws LimitExceededException
* LimitExceededException
* @throws InternalServiceErrorException
* InternalServiceErrorException
* @throws NotFoundException
* NotFoundException
* @throws TooManyRequestsException
* TooManyRequestsException
* @throws AlreadyExistsException
* AlreadyExistsException
* @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 PinpointSmsVoiceException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample PinpointSmsVoiceClient.CreateConfigurationSetEventDestination
* @see AWS API Documentation
*/
@Override
public CreateConfigurationSetEventDestinationResponse createConfigurationSetEventDestination(
CreateConfigurationSetEventDestinationRequest createConfigurationSetEventDestinationRequest)
throws BadRequestException, LimitExceededException, InternalServiceErrorException, NotFoundException,
TooManyRequestsException, AlreadyExistsException, AwsServiceException, SdkClientException, PinpointSmsVoiceException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory
.createResponseHandler(operationMetadata, CreateConfigurationSetEventDestinationResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
List metricPublishers = resolveMetricPublishers(clientConfiguration,
createConfigurationSetEventDestinationRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Pinpoint SMS Voice");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "CreateConfigurationSetEventDestination");
return clientHandler
.execute(new ClientExecutionParams()
.withOperationName("CreateConfigurationSetEventDestination").withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler)
.withInput(createConfigurationSetEventDestinationRequest).withMetricCollector(apiCallMetricCollector)
.withMarshaller(new CreateConfigurationSetEventDestinationRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
* Deletes an existing configuration set.
*
* @param deleteConfigurationSetRequest
* @return Result of the DeleteConfigurationSet operation returned by the service.
* @throws NotFoundException
* NotFoundException
* @throws TooManyRequestsException
* TooManyRequestsException
* @throws BadRequestException
* BadRequestException
* @throws InternalServiceErrorException
* InternalServiceErrorException
* @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 PinpointSmsVoiceException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample PinpointSmsVoiceClient.DeleteConfigurationSet
* @see AWS API Documentation
*/
@Override
public DeleteConfigurationSetResponse deleteConfigurationSet(DeleteConfigurationSetRequest deleteConfigurationSetRequest)
throws NotFoundException, TooManyRequestsException, BadRequestException, InternalServiceErrorException,
AwsServiceException, SdkClientException, PinpointSmsVoiceException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, DeleteConfigurationSetResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
List metricPublishers = resolveMetricPublishers(clientConfiguration, deleteConfigurationSetRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Pinpoint SMS Voice");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "DeleteConfigurationSet");
return clientHandler
.execute(new ClientExecutionParams()
.withOperationName("DeleteConfigurationSet").withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler).withInput(deleteConfigurationSetRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new DeleteConfigurationSetRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
* Deletes an event destination in a configuration set.
*
* @param deleteConfigurationSetEventDestinationRequest
* @return Result of the DeleteConfigurationSetEventDestination operation returned by the service.
* @throws NotFoundException
* NotFoundException
* @throws TooManyRequestsException
* TooManyRequestsException
* @throws BadRequestException
* BadRequestException
* @throws InternalServiceErrorException
* InternalServiceErrorException
* @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 PinpointSmsVoiceException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample PinpointSmsVoiceClient.DeleteConfigurationSetEventDestination
* @see AWS API Documentation
*/
@Override
public DeleteConfigurationSetEventDestinationResponse deleteConfigurationSetEventDestination(
DeleteConfigurationSetEventDestinationRequest deleteConfigurationSetEventDestinationRequest)
throws NotFoundException, TooManyRequestsException, BadRequestException, InternalServiceErrorException,
AwsServiceException, SdkClientException, PinpointSmsVoiceException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory
.createResponseHandler(operationMetadata, DeleteConfigurationSetEventDestinationResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
List metricPublishers = resolveMetricPublishers(clientConfiguration,
deleteConfigurationSetEventDestinationRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Pinpoint SMS Voice");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "DeleteConfigurationSetEventDestination");
return clientHandler
.execute(new ClientExecutionParams()
.withOperationName("DeleteConfigurationSetEventDestination").withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler)
.withInput(deleteConfigurationSetEventDestinationRequest).withMetricCollector(apiCallMetricCollector)
.withMarshaller(new DeleteConfigurationSetEventDestinationRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
* Obtain information about an event destination, including the types of events it reports, the Amazon Resource Name
* (ARN) of the destination, and the name of the event destination.
*
* @param getConfigurationSetEventDestinationsRequest
* @return Result of the GetConfigurationSetEventDestinations operation returned by the service.
* @throws NotFoundException
* NotFoundException
* @throws TooManyRequestsException
* TooManyRequestsException
* @throws BadRequestException
* BadRequestException
* @throws InternalServiceErrorException
* InternalServiceErrorException
* @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 PinpointSmsVoiceException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample PinpointSmsVoiceClient.GetConfigurationSetEventDestinations
* @see AWS API Documentation
*/
@Override
public GetConfigurationSetEventDestinationsResponse getConfigurationSetEventDestinations(
GetConfigurationSetEventDestinationsRequest getConfigurationSetEventDestinationsRequest) throws NotFoundException,
TooManyRequestsException, BadRequestException, InternalServiceErrorException, AwsServiceException,
SdkClientException, PinpointSmsVoiceException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory
.createResponseHandler(operationMetadata, GetConfigurationSetEventDestinationsResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
List metricPublishers = resolveMetricPublishers(clientConfiguration,
getConfigurationSetEventDestinationsRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Pinpoint SMS Voice");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetConfigurationSetEventDestinations");
return clientHandler
.execute(new ClientExecutionParams()
.withOperationName("GetConfigurationSetEventDestinations").withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler)
.withInput(getConfigurationSetEventDestinationsRequest).withMetricCollector(apiCallMetricCollector)
.withMarshaller(new GetConfigurationSetEventDestinationsRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
* List all of the configuration sets associated with your Amazon Pinpoint account in the current region.
*
* @param listConfigurationSetsRequest
* @return Result of the ListConfigurationSets operation returned by the service.
* @throws TooManyRequestsException
* TooManyRequestsException
* @throws BadRequestException
* BadRequestException
* @throws InternalServiceErrorException
* InternalServiceErrorException
* @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 PinpointSmsVoiceException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample PinpointSmsVoiceClient.ListConfigurationSets
* @see AWS API Documentation
*/
@Override
public ListConfigurationSetsResponse listConfigurationSets(ListConfigurationSetsRequest listConfigurationSetsRequest)
throws TooManyRequestsException, BadRequestException, InternalServiceErrorException, AwsServiceException,
SdkClientException, PinpointSmsVoiceException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(
operationMetadata, ListConfigurationSetsResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
List metricPublishers = resolveMetricPublishers(clientConfiguration, listConfigurationSetsRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Pinpoint SMS Voice");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "ListConfigurationSets");
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("ListConfigurationSets").withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler).withInput(listConfigurationSetsRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new ListConfigurationSetsRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
* Create a new voice message and send it to a recipient's phone number.
*
* @param sendVoiceMessageRequest
* SendVoiceMessageRequest
* @return Result of the SendVoiceMessage operation returned by the service.
* @throws TooManyRequestsException
* TooManyRequestsException
* @throws BadRequestException
* BadRequestException
* @throws InternalServiceErrorException
* InternalServiceErrorException
* @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 PinpointSmsVoiceException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample PinpointSmsVoiceClient.SendVoiceMessage
* @see AWS API Documentation
*/
@Override
public SendVoiceMessageResponse sendVoiceMessage(SendVoiceMessageRequest sendVoiceMessageRequest)
throws TooManyRequestsException, BadRequestException, InternalServiceErrorException, AwsServiceException,
SdkClientException, PinpointSmsVoiceException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory.createResponseHandler(operationMetadata,
SendVoiceMessageResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
List metricPublishers = resolveMetricPublishers(clientConfiguration, sendVoiceMessageRequest
.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Pinpoint SMS Voice");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "SendVoiceMessage");
return clientHandler.execute(new ClientExecutionParams()
.withOperationName("SendVoiceMessage").withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler).withInput(sendVoiceMessageRequest)
.withMetricCollector(apiCallMetricCollector)
.withMarshaller(new SendVoiceMessageRequestMarshaller(protocolFactory)));
} finally {
metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect()));
}
}
/**
* Update an event destination in a configuration set. An event destination is a location that you publish
* information about your voice calls to. For example, you can log an event to an Amazon CloudWatch destination when
* a call fails.
*
* @param updateConfigurationSetEventDestinationRequest
* UpdateConfigurationSetEventDestinationRequest
* @return Result of the UpdateConfigurationSetEventDestination operation returned by the service.
* @throws NotFoundException
* NotFoundException
* @throws TooManyRequestsException
* TooManyRequestsException
* @throws BadRequestException
* BadRequestException
* @throws InternalServiceErrorException
* InternalServiceErrorException
* @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 PinpointSmsVoiceException
* Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
* @sample PinpointSmsVoiceClient.UpdateConfigurationSetEventDestination
* @see AWS API Documentation
*/
@Override
public UpdateConfigurationSetEventDestinationResponse updateConfigurationSetEventDestination(
UpdateConfigurationSetEventDestinationRequest updateConfigurationSetEventDestinationRequest)
throws NotFoundException, TooManyRequestsException, BadRequestException, InternalServiceErrorException,
AwsServiceException, SdkClientException, PinpointSmsVoiceException {
JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false)
.isPayloadJson(true).build();
HttpResponseHandler responseHandler = protocolFactory
.createResponseHandler(operationMetadata, UpdateConfigurationSetEventDestinationResponse::builder);
HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory,
operationMetadata);
List metricPublishers = resolveMetricPublishers(clientConfiguration,
updateConfigurationSetEventDestinationRequest.overrideConfiguration().orElse(null));
MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector
.create("ApiCall");
try {
apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Pinpoint SMS Voice");
apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "UpdateConfigurationSetEventDestination");
return clientHandler
.execute(new ClientExecutionParams()
.withOperationName("UpdateConfigurationSetEventDestination").withResponseHandler(responseHandler)
.withErrorResponseHandler(errorResponseHandler)
.withInput(updateConfigurationSetEventDestinationRequest).withMetricCollector(apiCallMetricCollector)
.withMarshaller(new UpdateConfigurationSetEventDestinationRequestMarshaller(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 > T init(T builder) {
return builder
.clientConfiguration(clientConfiguration)
.defaultServiceExceptionSupplier(PinpointSmsVoiceException::builder)
.protocol(AwsJsonProtocol.REST_JSON)
.protocolVersion("1.1")
.registerModeledException(
ExceptionMetadata.builder().errorCode("NotFoundException")
.exceptionBuilderSupplier(NotFoundException::builder).httpStatusCode(404).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("InternalServiceErrorException")
.exceptionBuilderSupplier(InternalServiceErrorException::builder).httpStatusCode(500).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("AlreadyExistsException")
.exceptionBuilderSupplier(AlreadyExistsException::builder).httpStatusCode(409).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("TooManyRequestsException")
.exceptionBuilderSupplier(TooManyRequestsException::builder).httpStatusCode(429).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("BadRequestException")
.exceptionBuilderSupplier(BadRequestException::builder).httpStatusCode(400).build())
.registerModeledException(
ExceptionMetadata.builder().errorCode("LimitExceededException")
.exceptionBuilderSupplier(LimitExceededException::builder).httpStatusCode(412).build());
}
@Override
public final PinpointSmsVoiceServiceClientConfiguration serviceClientConfiguration() {
return this.serviceClientConfiguration;
}
@Override
public void close() {
clientHandler.close();
}
}