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

13 package com.amazonaws.services.sns;
14
15 import org.w3c.dom.*;
16
17 import java.net.*;
18 import java.util.*;
19
20 import javax.annotation.Generated;
21
22 import org.apache.commons.logging.*;
23
24 import com.amazonaws.*;
25 import com.amazonaws.annotation.SdkInternalApi;
26 import com.amazonaws.auth.*;
27
28 import com.amazonaws.handlers.*;
29 import com.amazonaws.http.*;
30 import com.amazonaws.internal.*;
31 import com.amazonaws.internal.auth.*;
32 import com.amazonaws.metrics.*;
33 import com.amazonaws.regions.*;
34 import com.amazonaws.transform.*;
35 import com.amazonaws.util.*;
36 import com.amazonaws.protocol.json.*;
37 import com.amazonaws.util.AWSRequestMetrics.Field;
38 import com.amazonaws.annotation.ThreadSafe;
39 import com.amazonaws.client.AwsSyncClientParams;
40 import com.amazonaws.client.builder.AdvancedConfig;
41
42 import com.amazonaws.services.sns.AmazonSNSClientBuilder;
43
44 import com.amazonaws.AmazonServiceException;
45
46 import com.amazonaws.services.sns.model.*;
47 import com.amazonaws.services.sns.model.transform.*;
48
49 /**
50  * Client for accessing Amazon SNS. All service calls made using this client are blocking, and will not return until the
51  * service call completes.
52  * <p>
53  * <fullname>Amazon Simple Notification Service</fullname>
54  * <p>
55  * Amazon Simple Notification Service (Amazon SNS) is a web service that enables you to build distributed web-enabled
56  * applications. Applications can use Amazon SNS to easily push real-time notification messages to interested
57  * subscribers over multiple delivery protocols. For more information about this product see <a
58  * href="http://aws.amazon.com/sns/">https://aws.amazon.com/sns</a>. For detailed information about Amazon SNS features
59  * and their associated API calls, see the <a href="https://docs.aws.amazon.com/sns/latest/dg/">Amazon SNS Developer
60  * Guide</a>.
61  * </p>
62  * <p>
63  * We also provide SDKs that enable you to access Amazon SNS from your preferred programming language. The SDKs contain
64  * functionality that automatically takes care of tasks such as: cryptographically signing your service requests,
65  * retrying requests, and handling error responses. For a list of available SDKs, go to <a
66  * href="http://aws.amazon.com/tools/">Tools for Amazon Web Services</a>.
67  * </p>
68  */

69 @ThreadSafe
70 @Generated("com.amazonaws:aws-java-sdk-code-generator")
71 public class AmazonSNSClient extends AmazonWebServiceClient implements AmazonSNS {
72
73     /** Provider for AWS credentials. */
74     private final AWSCredentialsProvider awsCredentialsProvider;
75
76     private static final Log log = LogFactory.getLog(AmazonSNS.class);
77
78     /** Default signing name for the service. */
79     private static final String DEFAULT_SIGNING_NAME = "sns";
80
81     /** Client configuration factory providing ClientConfigurations tailored to this client */
82     protected static final ClientConfigurationFactory configFactory = new ClientConfigurationFactory();
83
84     private final AdvancedConfig advancedConfig;
85
86     /**
87      * List of exception unmarshallers for all modeled exceptions
88      */

89     protected final List<Unmarshaller<AmazonServiceException, Node>> exceptionUnmarshallers = new ArrayList<Unmarshaller<AmazonServiceException, Node>>();
90
91     /**
92      * Constructs a new client to invoke service methods on Amazon SNS. A credentials provider chain will be used that
93      * searches for credentials in this order:
94      * <ul>
95      * <li>Environment Variables - AWS_ACCESS_KEY_ID and AWS_SECRET_KEY</li>
96      * <li>Java System Properties - aws.accessKeyId and aws.secretKey</li>
97      * <li>Instance profile credentials delivered through the Amazon EC2 metadata service</li>
98      * </ul>
99      *
100      * <p>
101      * All service calls made using this new client object are blocking, and will not return until the service call
102      * completes.
103      *
104      * @see DefaultAWSCredentialsProviderChain
105      * @deprecated use {@link AmazonSNSClientBuilder#defaultClient()}
106      */

107     @Deprecated
108     public AmazonSNSClient() {
109         this(DefaultAWSCredentialsProviderChain.getInstance(), configFactory.getConfig());
110     }
111
112     /**
113      * Constructs a new client to invoke service methods on Amazon SNS. A credentials provider chain will be used that
114      * searches for credentials in this order:
115      * <ul>
116      * <li>Environment Variables - AWS_ACCESS_KEY_ID and AWS_SECRET_KEY</li>
117      * <li>Java System Properties - aws.accessKeyId and aws.secretKey</li>
118      * <li>Instance profile credentials delivered through the Amazon EC2 metadata service</li>
119      * </ul>
120      *
121      * <p>
122      * All service calls made using this new client object are blocking, and will not return until the service call
123      * completes.
124      *
125      * @param clientConfiguration
126      *        The client configuration options controlling how this client connects to Amazon SNS (ex: proxy settings,
127      *        retry counts, etc.).
128      *
129      * @see DefaultAWSCredentialsProviderChain
130      * @deprecated use {@link AmazonSNSClientBuilder#withClientConfiguration(ClientConfiguration)}
131      */

132     @Deprecated
133     public AmazonSNSClient(ClientConfiguration clientConfiguration) {
134         this(DefaultAWSCredentialsProviderChain.getInstance(), clientConfiguration);
135     }
136
137     /**
138      * Constructs a new client to invoke service methods on Amazon SNS using the specified AWS account credentials.
139      *
140      * <p>
141      * All service calls made using this new client object are blocking, and will not return until the service call
142      * completes.
143      *
144      * @param awsCredentials
145      *        The AWS credentials (access key ID and secret key) to use when authenticating with AWS services.
146      * @deprecated use {@link AmazonSNSClientBuilder#withCredentials(AWSCredentialsProvider)} for example:
147      *             {@code AmazonSNSClientBuilder.standard().withCredentials(new AWSStaticCredentialsProvider(awsCredentials)).build();}
148      */

149     @Deprecated
150     public AmazonSNSClient(AWSCredentials awsCredentials) {
151         this(awsCredentials, configFactory.getConfig());
152     }
153
154     /**
155      * Constructs a new client to invoke service methods on Amazon SNS using the specified AWS account credentials and
156      * client configuration options.
157      *
158      * <p>
159      * All service calls made using this new client object are blocking, and will not return until the service call
160      * completes.
161      *
162      * @param awsCredentials
163      *        The AWS credentials (access key ID and secret key) to use when authenticating with AWS services.
164      * @param clientConfiguration
165      *        The client configuration options controlling how this client connects to Amazon SNS (ex: proxy settings,
166      *        retry counts, etc.).
167      * @deprecated use {@link AmazonSNSClientBuilder#withCredentials(AWSCredentialsProvider)} and
168      *             {@link AmazonSNSClientBuilder#withClientConfiguration(ClientConfiguration)}
169      */

170     @Deprecated
171     public AmazonSNSClient(AWSCredentials awsCredentials, ClientConfiguration clientConfiguration) {
172         super(clientConfiguration);
173         this.awsCredentialsProvider = new StaticCredentialsProvider(awsCredentials);
174         this.advancedConfig = AdvancedConfig.EMPTY;
175         init();
176     }
177
178     /**
179      * Constructs a new client to invoke service methods on Amazon SNS using the specified AWS account credentials
180      * provider.
181      *
182      * <p>
183      * All service calls made using this new client object are blocking, and will not return until the service call
184      * completes.
185      *
186      * @param awsCredentialsProvider
187      *        The AWS credentials provider which will provide credentials to authenticate requests with AWS services.
188      * @deprecated use {@link AmazonSNSClientBuilder#withCredentials(AWSCredentialsProvider)}
189      */

190     @Deprecated
191     public AmazonSNSClient(AWSCredentialsProvider awsCredentialsProvider) {
192         this(awsCredentialsProvider, configFactory.getConfig());
193     }
194
195     /**
196      * Constructs a new client to invoke service methods on Amazon SNS using the specified AWS account credentials
197      * provider and client configuration options.
198      *
199      * <p>
200      * All service calls made using this new client object are blocking, and will not return until the service call
201      * completes.
202      *
203      * @param awsCredentialsProvider
204      *        The AWS credentials provider which will provide credentials to authenticate requests with AWS services.
205      * @param clientConfiguration
206      *        The client configuration options controlling how this client connects to Amazon SNS (ex: proxy settings,
207      *        retry counts, etc.).
208      * @deprecated use {@link AmazonSNSClientBuilder#withCredentials(AWSCredentialsProvider)} and
209      *             {@link AmazonSNSClientBuilder#withClientConfiguration(ClientConfiguration)}
210      */

211     @Deprecated
212     public AmazonSNSClient(AWSCredentialsProvider awsCredentialsProvider, ClientConfiguration clientConfiguration) {
213         this(awsCredentialsProvider, clientConfiguration, null);
214     }
215
216     /**
217      * Constructs a new client to invoke service methods on Amazon SNS using the specified AWS account credentials
218      * provider, client configuration options, and request metric collector.
219      *
220      * <p>
221      * All service calls made using this new client object are blocking, and will not return until the service call
222      * completes.
223      *
224      * @param awsCredentialsProvider
225      *        The AWS credentials provider which will provide credentials to authenticate requests with AWS services.
226      * @param clientConfiguration
227      *        The client configuration options controlling how this client connects to Amazon SNS (ex: proxy settings,
228      *        retry counts, etc.).
229      * @param requestMetricCollector
230      *        optional request metric collector
231      * @deprecated use {@link AmazonSNSClientBuilder#withCredentials(AWSCredentialsProvider)} and
232      *             {@link AmazonSNSClientBuilder#withClientConfiguration(ClientConfiguration)} and
233      *             {@link AmazonSNSClientBuilder#withMetricsCollector(RequestMetricCollector)}
234      */

235     @Deprecated
236     public AmazonSNSClient(AWSCredentialsProvider awsCredentialsProvider, ClientConfiguration clientConfiguration, RequestMetricCollector requestMetricCollector) {
237         super(clientConfiguration, requestMetricCollector);
238         this.awsCredentialsProvider = awsCredentialsProvider;
239         this.advancedConfig = AdvancedConfig.EMPTY;
240         init();
241     }
242
243     public static AmazonSNSClientBuilder builder() {
244         return AmazonSNSClientBuilder.standard();
245     }
246
247     /**
248      * Constructs a new client to invoke service methods on Amazon SNS using the specified parameters.
249      *
250      * <p>
251      * All service calls made using this new client object are blocking, and will not return until the service call
252      * completes.
253      *
254      * @param clientParams
255      *        Object providing client parameters.
256      */

257     AmazonSNSClient(AwsSyncClientParams clientParams) {
258         this(clientParams, false);
259     }
260
261     /**
262      * Constructs a new client to invoke service methods on Amazon SNS using the specified parameters.
263      *
264      * <p>
265      * All service calls made using this new client object are blocking, and will not return until the service call
266      * completes.
267      *
268      * @param clientParams
269      *        Object providing client parameters.
270      */

271     AmazonSNSClient(AwsSyncClientParams clientParams, boolean endpointDiscoveryEnabled) {
272         super(clientParams);
273         this.awsCredentialsProvider = clientParams.getCredentialsProvider();
274         this.advancedConfig = clientParams.getAdvancedConfig();
275         init();
276     }
277
278     private void init() {
279         exceptionUnmarshallers.add(new SubscriptionLimitExceededExceptionUnmarshaller());
280         exceptionUnmarshallers.add(new InvalidParameterExceptionUnmarshaller());
281         exceptionUnmarshallers.add(new InvalidParameterValueExceptionUnmarshaller());
282         exceptionUnmarshallers.add(new EndpointDisabledExceptionUnmarshaller());
283         exceptionUnmarshallers.add(new FilterPolicyLimitExceededExceptionUnmarshaller());
284         exceptionUnmarshallers.add(new KMSOptInRequiredExceptionUnmarshaller());
285         exceptionUnmarshallers.add(new ResourceNotFoundExceptionUnmarshaller());
286         exceptionUnmarshallers.add(new KMSAccessDeniedExceptionUnmarshaller());
287         exceptionUnmarshallers.add(new KMSInvalidStateExceptionUnmarshaller());
288         exceptionUnmarshallers.add(new StaleTagExceptionUnmarshaller());
289         exceptionUnmarshallers.add(new NotFoundExceptionUnmarshaller());
290         exceptionUnmarshallers.add(new KMSDisabledExceptionUnmarshaller());
291         exceptionUnmarshallers.add(new KMSNotFoundExceptionUnmarshaller());
292         exceptionUnmarshallers.add(new TopicLimitExceededExceptionUnmarshaller());
293         exceptionUnmarshallers.add(new TagPolicyExceptionUnmarshaller());
294         exceptionUnmarshallers.add(new TagLimitExceededExceptionUnmarshaller());
295         exceptionUnmarshallers.add(new ThrottledExceptionUnmarshaller());
296         exceptionUnmarshallers.add(new PlatformApplicationDisabledExceptionUnmarshaller());
297         exceptionUnmarshallers.add(new InternalErrorExceptionUnmarshaller());
298         exceptionUnmarshallers.add(new KMSThrottlingExceptionUnmarshaller());
299         exceptionUnmarshallers.add(new AuthorizationErrorExceptionUnmarshaller());
300         exceptionUnmarshallers.add(new ConcurrentAccessExceptionUnmarshaller());
301         exceptionUnmarshallers.add(new InvalidSecurityExceptionUnmarshaller());
302         exceptionUnmarshallers.add(new StandardErrorUnmarshaller(com.amazonaws.services.sns.model.AmazonSNSException.class));
303
304         setServiceNameIntern(DEFAULT_SIGNING_NAME);
305         setEndpointPrefix(ENDPOINT_PREFIX);
306         // calling this.setEndPoint(...) will also modify the signer accordingly
307         this.setEndpoint("https://sns.us-east-1.amazonaws.com");
308         HandlerChainFactory chainFactory = new HandlerChainFactory();
309         requestHandler2s.addAll(chainFactory.newRequestHandlerChain("/com/amazonaws/services/sns/request.handlers"));
310         requestHandler2s.addAll(chainFactory.newRequestHandler2Chain("/com/amazonaws/services/sns/request.handler2s"));
311         requestHandler2s.addAll(chainFactory.getGlobalHandlers());
312     }
313
314     /**
315      * <p>
316      * Adds a statement to a topic's access control policy, granting access for the specified AWS accounts to the
317      * specified actions.
318      * </p>
319      * 
320      * @param addPermissionRequest
321      * @return Result of the AddPermission operation returned by the service.
322      * @throws InvalidParameterException
323      *         Indicates that a request parameter does not comply with the associated constraints.
324      * @throws InternalErrorException
325      *         Indicates an internal service error.
326      * @throws AuthorizationErrorException
327      *         Indicates that the user has been denied access to the requested resource.
328      * @throws NotFoundException
329      *         Indicates that the requested resource does not exist.
330      * @sample AmazonSNS.AddPermission
331      * @see <a href="http://docs.aws.amazon.com/goto/WebAPI/sns-2010-03-31/AddPermission" target="_top">AWS API
332      *      Documentation</a>
333      */

334     @Override
335     public AddPermissionResult addPermission(AddPermissionRequest request) {
336         request = beforeClientExecution(request);
337         return executeAddPermission(request);
338     }
339
340     @SdkInternalApi
341     final AddPermissionResult executeAddPermission(AddPermissionRequest addPermissionRequest) {
342
343         ExecutionContext executionContext = createExecutionContext(addPermissionRequest);
344         AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
345         awsRequestMetrics.startEvent(Field.ClientExecuteTime);
346         Request<AddPermissionRequest> request = null;
347         Response<AddPermissionResult> response = null;
348
349         try {
350             awsRequestMetrics.startEvent(Field.RequestMarshallTime);
351             try {
352                 request = new AddPermissionRequestMarshaller().marshall(super.beforeMarshalling(addPermissionRequest));
353                 // Binds the request metrics to the current request.
354                 request.setAWSRequestMetrics(awsRequestMetrics);
355                 request.addHandlerContext(HandlerContextKey.SIGNING_REGION, getSigningRegion());
356                 request.addHandlerContext(HandlerContextKey.SERVICE_ID, "SNS");
357                 request.addHandlerContext(HandlerContextKey.OPERATION_NAME, "AddPermission");
358                 request.addHandlerContext(HandlerContextKey.ADVANCED_CONFIG, advancedConfig);
359
360             } finally {
361                 awsRequestMetrics.endEvent(Field.RequestMarshallTime);
362             }
363
364             StaxResponseHandler<AddPermissionResult> responseHandler = new StaxResponseHandler<AddPermissionResult>(new AddPermissionResultStaxUnmarshaller());
365             response = invoke(request, responseHandler, executionContext);
366
367             return response.getAwsResponse();
368
369         } finally {
370
371             endClientExecution(awsRequestMetrics, request, response);
372         }
373     }
374
375     @Override
376     public AddPermissionResult addPermission(String topicArn, String label, java.util.List<String> aWSAccountIds, java.util.List<String> actionNames) {
377         return addPermission(new AddPermissionRequest().withTopicArn(topicArn).withLabel(label).withAWSAccountIds(aWSAccountIds).withActionNames(actionNames));
378     }
379
380     /**
381      * <p>
382      * Accepts a phone number and indicates whether the phone holder has opted out of receiving SMS messages from your
383      * account. You cannot send SMS messages to a number that is opted out.
384      * </p>
385      * <p>
386      * To resume sending messages, you can opt in the number by using the <code>OptInPhoneNumber</code> action.
387      * </p>
388      * 
389      * @param checkIfPhoneNumberIsOptedOutRequest
390      *        The input for the <code>CheckIfPhoneNumberIsOptedOut</code> action.
391      * @return Result of the CheckIfPhoneNumberIsOptedOut operation returned by the service.
392      * @throws ThrottledException
393      *         Indicates that the rate at which requests have been submitted for this action exceeds the limit for your
394      *         account.
395      * @throws InternalErrorException
396      *         Indicates an internal service error.
397      * @throws AuthorizationErrorException
398      *         Indicates that the user has been denied access to the requested resource.
399      * @throws InvalidParameterException
400      *         Indicates that a request parameter does not comply with the associated constraints.
401      * @sample AmazonSNS.CheckIfPhoneNumberIsOptedOut
402      * @see <a href="http://docs.aws.amazon.com/goto/WebAPI/sns-2010-03-31/CheckIfPhoneNumberIsOptedOut"
403      *      target="_top">AWS API Documentation</a>
404      */

405     @Override
406     public CheckIfPhoneNumberIsOptedOutResult checkIfPhoneNumberIsOptedOut(CheckIfPhoneNumberIsOptedOutRequest request) {
407         request = beforeClientExecution(request);
408         return executeCheckIfPhoneNumberIsOptedOut(request);
409     }
410
411     @SdkInternalApi
412     final CheckIfPhoneNumberIsOptedOutResult executeCheckIfPhoneNumberIsOptedOut(CheckIfPhoneNumberIsOptedOutRequest checkIfPhoneNumberIsOptedOutRequest) {
413
414         ExecutionContext executionContext = createExecutionContext(checkIfPhoneNumberIsOptedOutRequest);
415         AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
416         awsRequestMetrics.startEvent(Field.ClientExecuteTime);
417         Request<CheckIfPhoneNumberIsOptedOutRequest> request = null;
418         Response<CheckIfPhoneNumberIsOptedOutResult> response = null;
419
420         try {
421             awsRequestMetrics.startEvent(Field.RequestMarshallTime);
422             try {
423                 request = new CheckIfPhoneNumberIsOptedOutRequestMarshaller().marshall(super.beforeMarshalling(checkIfPhoneNumberIsOptedOutRequest));
424                 // Binds the request metrics to the current request.
425                 request.setAWSRequestMetrics(awsRequestMetrics);
426                 request.addHandlerContext(HandlerContextKey.SIGNING_REGION, getSigningRegion());
427                 request.addHandlerContext(HandlerContextKey.SERVICE_ID, "SNS");
428                 request.addHandlerContext(HandlerContextKey.OPERATION_NAME, "CheckIfPhoneNumberIsOptedOut");
429                 request.addHandlerContext(HandlerContextKey.ADVANCED_CONFIG, advancedConfig);
430
431             } finally {
432                 awsRequestMetrics.endEvent(Field.RequestMarshallTime);
433             }
434
435             StaxResponseHandler<CheckIfPhoneNumberIsOptedOutResult> responseHandler = new StaxResponseHandler<CheckIfPhoneNumberIsOptedOutResult>(
436                     new CheckIfPhoneNumberIsOptedOutResultStaxUnmarshaller());
437             response = invoke(request, responseHandler, executionContext);
438
439             return response.getAwsResponse();
440
441         } finally {
442
443             endClientExecution(awsRequestMetrics, request, response);
444         }
445     }
446
447     /**
448      * <p>
449      * Verifies an endpoint owner's intent to receive messages by validating the token sent to the endpoint by an
450      * earlier <code>Subscribe</code> action. If the token is valid, the action creates a new subscription and returns
451      * its Amazon Resource Name (ARN). This call requires an AWS signature only when the
452      * <code>AuthenticateOnUnsubscribe</code> flag is set to "true".
453      * </p>
454      * 
455      * @param confirmSubscriptionRequest
456      *        Input for ConfirmSubscription action.
457      * @return Result of the ConfirmSubscription operation returned by the service.
458      * @throws SubscriptionLimitExceededException
459      *         Indicates that the customer already owns the maximum allowed number of subscriptions.
460      * @throws InvalidParameterException
461      *         Indicates that a request parameter does not comply with the associated constraints.
462      * @throws NotFoundException
463      *         Indicates that the requested resource does not exist.
464      * @throws InternalErrorException
465      *         Indicates an internal service error.
466      * @throws AuthorizationErrorException
467      *         Indicates that the user has been denied access to the requested resource.
468      * @throws FilterPolicyLimitExceededException
469      *         Indicates that the number of filter polices in your AWS account exceeds the limit. To add more filter
470      *         polices, submit an SNS Limit Increase case in the AWS Support Center.
471      * @sample AmazonSNS.ConfirmSubscription
472      * @see <a href="http://docs.aws.amazon.com/goto/WebAPI/sns-2010-03-31/ConfirmSubscription" target="_top">AWS API
473      *      Documentation</a>
474      */

475     @Override
476     public ConfirmSubscriptionResult confirmSubscription(ConfirmSubscriptionRequest request) {
477         request = beforeClientExecution(request);
478         return executeConfirmSubscription(request);
479     }
480
481     @SdkInternalApi
482     final ConfirmSubscriptionResult executeConfirmSubscription(ConfirmSubscriptionRequest confirmSubscriptionRequest) {
483
484         ExecutionContext executionContext = createExecutionContext(confirmSubscriptionRequest);
485         AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
486         awsRequestMetrics.startEvent(Field.ClientExecuteTime);
487         Request<ConfirmSubscriptionRequest> request = null;
488         Response<ConfirmSubscriptionResult> response = null;
489
490         try {
491             awsRequestMetrics.startEvent(Field.RequestMarshallTime);
492             try {
493                 request = new ConfirmSubscriptionRequestMarshaller().marshall(super.beforeMarshalling(confirmSubscriptionRequest));
494                 // Binds the request metrics to the current request.
495                 request.setAWSRequestMetrics(awsRequestMetrics);
496                 request.addHandlerContext(HandlerContextKey.SIGNING_REGION, getSigningRegion());
497                 request.addHandlerContext(HandlerContextKey.SERVICE_ID, "SNS");
498                 request.addHandlerContext(HandlerContextKey.OPERATION_NAME, "ConfirmSubscription");
499                 request.addHandlerContext(HandlerContextKey.ADVANCED_CONFIG, advancedConfig);
500
501             } finally {
502                 awsRequestMetrics.endEvent(Field.RequestMarshallTime);
503             }
504
505             StaxResponseHandler<ConfirmSubscriptionResult> responseHandler = new StaxResponseHandler<ConfirmSubscriptionResult>(
506                     new ConfirmSubscriptionResultStaxUnmarshaller());
507             response = invoke(request, responseHandler, executionContext);
508
509             return response.getAwsResponse();
510
511         } finally {
512
513             endClientExecution(awsRequestMetrics, request, response);
514         }
515     }
516
517     @Override
518     public ConfirmSubscriptionResult confirmSubscription(String topicArn, String token, String authenticateOnUnsubscribe) {
519         return confirmSubscription(new ConfirmSubscriptionRequest().withTopicArn(topicArn).withToken(token)
520                 .withAuthenticateOnUnsubscribe(authenticateOnUnsubscribe));
521     }
522
523     @Override
524     public ConfirmSubscriptionResult confirmSubscription(String topicArn, String token) {
525         return confirmSubscription(new ConfirmSubscriptionRequest().withTopicArn(topicArn).withToken(token));
526     }
527
528     /**
529      * <p>
530      * Creates a platform application object for one of the supported push notification services, such as APNS and FCM,
531      * to which devices and mobile apps may register. You must specify PlatformPrincipal and PlatformCredential
532      * attributes when using the <code>CreatePlatformApplication</code> action. The PlatformPrincipal is received from
533      * the notification service. For APNS/APNS_SANDBOX, PlatformPrincipal is "SSL certificate". For FCM,
534      * PlatformPrincipal is not applicable. For ADM, PlatformPrincipal is "client id". The PlatformCredential is also
535      * received from the notification service. For WNS, PlatformPrincipal is "Package Security Identifier". For MPNS,
536      * PlatformPrincipal is "TLS certificate". For Baidu, PlatformPrincipal is "API key".
537      * </p>
538      * <p>
539      * For APNS/APNS_SANDBOX, PlatformCredential is "private key". For FCM, PlatformCredential is "API key". For ADM,
540      * PlatformCredential is "client secret". For WNS, PlatformCredential is "secret key". For MPNS, PlatformCredential
541      * is "private key". For Baidu, PlatformCredential is "secret key". The PlatformApplicationArn that is returned when
542      * using <code>CreatePlatformApplication</code> is then used as an attribute for the
543      * <code>CreatePlatformEndpoint</code> action.
544      * </p>
545      * 
546      * @param createPlatformApplicationRequest
547      *        Input for CreatePlatformApplication action.
548      * @return Result of the CreatePlatformApplication operation returned by the service.
549      * @throws InvalidParameterException
550      *         Indicates that a request parameter does not comply with the associated constraints.
551      * @throws InternalErrorException
552      *         Indicates an internal service error.
553      * @throws AuthorizationErrorException
554      *         Indicates that the user has been denied access to the requested resource.
555      * @sample AmazonSNS.CreatePlatformApplication
556      * @see <a href="http://docs.aws.amazon.com/goto/WebAPI/sns-2010-03-31/CreatePlatformApplication" target="_top">AWS
557      *      API Documentation</a>
558      */

559     @Override
560     public CreatePlatformApplicationResult createPlatformApplication(CreatePlatformApplicationRequest request) {
561         request = beforeClientExecution(request);
562         return executeCreatePlatformApplication(request);
563     }
564
565     @SdkInternalApi
566     final CreatePlatformApplicationResult executeCreatePlatformApplication(CreatePlatformApplicationRequest createPlatformApplicationRequest) {
567
568         ExecutionContext executionContext = createExecutionContext(createPlatformApplicationRequest);
569         AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
570         awsRequestMetrics.startEvent(Field.ClientExecuteTime);
571         Request<CreatePlatformApplicationRequest> request = null;
572         Response<CreatePlatformApplicationResult> response = null;
573
574         try {
575             awsRequestMetrics.startEvent(Field.RequestMarshallTime);
576             try {
577                 request = new CreatePlatformApplicationRequestMarshaller().marshall(super.beforeMarshalling(createPlatformApplicationRequest));
578                 // Binds the request metrics to the current request.
579                 request.setAWSRequestMetrics(awsRequestMetrics);
580                 request.addHandlerContext(HandlerContextKey.SIGNING_REGION, getSigningRegion());
581                 request.addHandlerContext(HandlerContextKey.SERVICE_ID, "SNS");
582                 request.addHandlerContext(HandlerContextKey.OPERATION_NAME, "CreatePlatformApplication");
583                 request.addHandlerContext(HandlerContextKey.ADVANCED_CONFIG, advancedConfig);
584
585             } finally {
586                 awsRequestMetrics.endEvent(Field.RequestMarshallTime);
587             }
588
589             StaxResponseHandler<CreatePlatformApplicationResult> responseHandler = new StaxResponseHandler<CreatePlatformApplicationResult>(
590                     new CreatePlatformApplicationResultStaxUnmarshaller());
591             response = invoke(request, responseHandler, executionContext);
592
593             return response.getAwsResponse();
594
595         } finally {
596
597             endClientExecution(awsRequestMetrics, request, response);
598         }
599     }
600
601     /**
602      * <p>
603      * Creates an endpoint for a device and mobile app on one of the supported push notification services, such as FCM
604      * and APNS. <code>CreatePlatformEndpoint</code> requires the PlatformApplicationArn that is returned from
605      * <code>CreatePlatformApplication</code>. The EndpointArn that is returned when using
606      * <code>CreatePlatformEndpoint</code> can then be used by the <code>Publish</code> action to send a message to a
607      * mobile app or by the <code>Subscribe</code> action for subscription to a topic. The
608      * <code>CreatePlatformEndpoint</code> action is idempotent, so if the requester already owns an endpoint with the
609      * same device token and attributes, that endpoint's ARN is returned without creating a new endpoint. For more
610      * information, see <a href="https://docs.aws.amazon.com/sns/latest/dg/SNSMobilePush.html">Using Amazon SNS Mobile
611      * Push Notifications</a>.
612      * </p>
613      * <p>
614      * When using <code>CreatePlatformEndpoint</code> with Baidu, two attributes must be provided: ChannelId and UserId.
615      * The token field must also contain the ChannelId. For more information, see <a
616      * href="https://docs.aws.amazon.com/sns/latest/dg/SNSMobilePushBaiduEndpoint.html">Creating an Amazon SNS Endpoint
617      * for Baidu</a>.
618      * </p>
619      * 
620      * @param createPlatformEndpointRequest
621      *        Input for CreatePlatformEndpoint action.
622      * @return Result of the CreatePlatformEndpoint operation returned by the service.
623      * @throws InvalidParameterException
624      *         Indicates that a request parameter does not comply with the associated constraints.
625      * @throws InternalErrorException
626      *         Indicates an internal service error.
627      * @throws AuthorizationErrorException
628      *         Indicates that the user has been denied access to the requested resource.
629      * @throws NotFoundException
630      *         Indicates that the requested resource does not exist.
631      * @sample AmazonSNS.CreatePlatformEndpoint
632      * @see <a href="http://docs.aws.amazon.com/goto/WebAPI/sns-2010-03-31/CreatePlatformEndpoint" target="_top">AWS API
633      *      Documentation</a>
634      */

635     @Override
636     public CreatePlatformEndpointResult createPlatformEndpoint(CreatePlatformEndpointRequest request) {
637         request = beforeClientExecution(request);
638         return executeCreatePlatformEndpoint(request);
639     }
640
641     @SdkInternalApi
642     final CreatePlatformEndpointResult executeCreatePlatformEndpoint(CreatePlatformEndpointRequest createPlatformEndpointRequest) {
643
644         ExecutionContext executionContext = createExecutionContext(createPlatformEndpointRequest);
645         AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
646         awsRequestMetrics.startEvent(Field.ClientExecuteTime);
647         Request<CreatePlatformEndpointRequest> request = null;
648         Response<CreatePlatformEndpointResult> response = null;
649
650         try {
651             awsRequestMetrics.startEvent(Field.RequestMarshallTime);
652             try {
653                 request = new CreatePlatformEndpointRequestMarshaller().marshall(super.beforeMarshalling(createPlatformEndpointRequest));
654                 // Binds the request metrics to the current request.
655                 request.setAWSRequestMetrics(awsRequestMetrics);
656                 request.addHandlerContext(HandlerContextKey.SIGNING_REGION, getSigningRegion());
657                 request.addHandlerContext(HandlerContextKey.SERVICE_ID, "SNS");
658                 request.addHandlerContext(HandlerContextKey.OPERATION_NAME, "CreatePlatformEndpoint");
659                 request.addHandlerContext(HandlerContextKey.ADVANCED_CONFIG, advancedConfig);
660
661             } finally {
662                 awsRequestMetrics.endEvent(Field.RequestMarshallTime);
663             }
664
665             StaxResponseHandler<CreatePlatformEndpointResult> responseHandler = new StaxResponseHandler<CreatePlatformEndpointResult>(
666                     new CreatePlatformEndpointResultStaxUnmarshaller());
667             response = invoke(request, responseHandler, executionContext);
668
669             return response.getAwsResponse();
670
671         } finally {
672
673             endClientExecution(awsRequestMetrics, request, response);
674         }
675     }
676
677     /**
678      * <p>
679      * Creates a topic to which notifications can be published. Users can create at most 100,000 topics. For more
680      * information, see <a href="http://aws.amazon.com/sns/">https://aws.amazon.com/sns</a>. This action is idempotent,
681      * so if the requester already owns a topic with the specified name, that topic's ARN is returned without creating a
682      * new topic.
683      * </p>
684      * 
685      * @param createTopicRequest
686      *        Input for CreateTopic action.
687      * @return Result of the CreateTopic operation returned by the service.
688      * @throws InvalidParameterException
689      *         Indicates that a request parameter does not comply with the associated constraints.
690      * @throws TopicLimitExceededException
691      *         Indicates that the customer already owns the maximum allowed number of topics.
692      * @throws InternalErrorException
693      *         Indicates an internal service error.
694      * @throws AuthorizationErrorException
695      *         Indicates that the user has been denied access to the requested resource.
696      * @throws InvalidSecurityException
697      *         The credential signature isn't valid. You must use an HTTPS endpoint and sign your request using
698      *         Signature Version 4.
699      * @throws TagLimitExceededException
700      *         Can't add more than 50 tags to a topic.
701      * @throws StaleTagException
702      *         A tag has been added to a resource with the same ARN as a deleted resource. Wait a short while and then
703      *         retry the operation.
704      * @throws TagPolicyException
705      *         The request doesn't comply with the IAM tag policy. Correct your request and then retry it.
706      * @throws ConcurrentAccessException
707      *         Can't perform multiple operations on a tag simultaneously. Perform the operations sequentially.
708      * @sample AmazonSNS.CreateTopic
709      * @see <a href="http://docs.aws.amazon.com/goto/WebAPI/sns-2010-03-31/CreateTopic" target="_top">AWS API
710      *      Documentation</a>
711      */

712     @Override
713     public CreateTopicResult createTopic(CreateTopicRequest request) {
714         request = beforeClientExecution(request);
715         return executeCreateTopic(request);
716     }
717
718     @SdkInternalApi
719     final CreateTopicResult executeCreateTopic(CreateTopicRequest createTopicRequest) {
720
721         ExecutionContext executionContext = createExecutionContext(createTopicRequest);
722         AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
723         awsRequestMetrics.startEvent(Field.ClientExecuteTime);
724         Request<CreateTopicRequest> request = null;
725         Response<CreateTopicResult> response = null;
726
727         try {
728             awsRequestMetrics.startEvent(Field.RequestMarshallTime);
729             try {
730                 request = new CreateTopicRequestMarshaller().marshall(super.beforeMarshalling(createTopicRequest));
731                 // Binds the request metrics to the current request.
732                 request.setAWSRequestMetrics(awsRequestMetrics);
733                 request.addHandlerContext(HandlerContextKey.SIGNING_REGION, getSigningRegion());
734                 request.addHandlerContext(HandlerContextKey.SERVICE_ID, "SNS");
735                 request.addHandlerContext(HandlerContextKey.OPERATION_NAME, "CreateTopic");
736                 request.addHandlerContext(HandlerContextKey.ADVANCED_CONFIG, advancedConfig);
737
738             } finally {
739                 awsRequestMetrics.endEvent(Field.RequestMarshallTime);
740             }
741
742             StaxResponseHandler<CreateTopicResult> responseHandler = new StaxResponseHandler<CreateTopicResult>(new CreateTopicResultStaxUnmarshaller());
743             response = invoke(request, responseHandler, executionContext);
744
745             return response.getAwsResponse();
746
747         } finally {
748
749             endClientExecution(awsRequestMetrics, request, response);
750         }
751     }
752
753     @Override
754     public CreateTopicResult createTopic(String name) {
755         return createTopic(new CreateTopicRequest().withName(name));
756     }
757
758     /**
759      * <p>
760      * Deletes the endpoint for a device and mobile app from Amazon SNS. This action is idempotent. For more
761      * information, see <a href="https://docs.aws.amazon.com/sns/latest/dg/SNSMobilePush.html">Using Amazon SNS Mobile
762      * Push Notifications</a>.
763      * </p>
764      * <p>
765      * When you delete an endpoint that is also subscribed to a topic, then you must also unsubscribe the endpoint from
766      * the topic.
767      * </p>
768      * 
769      * @param deleteEndpointRequest
770      *        Input for DeleteEndpoint action.
771      * @return Result of the DeleteEndpoint operation returned by the service.
772      * @throws InvalidParameterException
773      *         Indicates that a request parameter does not comply with the associated constraints.
774      * @throws InternalErrorException
775      *         Indicates an internal service error.
776      * @throws AuthorizationErrorException
777      *         Indicates that the user has been denied access to the requested resource.
778      * @sample AmazonSNS.DeleteEndpoint
779      * @see <a href="http://docs.aws.amazon.com/goto/WebAPI/sns-2010-03-31/DeleteEndpoint" target="_top">AWS API
780      *      Documentation</a>
781      */

782     @Override
783     public DeleteEndpointResult deleteEndpoint(DeleteEndpointRequest request) {
784         request = beforeClientExecution(request);
785         return executeDeleteEndpoint(request);
786     }
787
788     @SdkInternalApi
789     final DeleteEndpointResult executeDeleteEndpoint(DeleteEndpointRequest deleteEndpointRequest) {
790
791         ExecutionContext executionContext = createExecutionContext(deleteEndpointRequest);
792         AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
793         awsRequestMetrics.startEvent(Field.ClientExecuteTime);
794         Request<DeleteEndpointRequest> request = null;
795         Response<DeleteEndpointResult> response = null;
796
797         try {
798             awsRequestMetrics.startEvent(Field.RequestMarshallTime);
799             try {
800                 request = new DeleteEndpointRequestMarshaller().marshall(super.beforeMarshalling(deleteEndpointRequest));
801                 // Binds the request metrics to the current request.
802                 request.setAWSRequestMetrics(awsRequestMetrics);
803                 request.addHandlerContext(HandlerContextKey.SIGNING_REGION, getSigningRegion());
804                 request.addHandlerContext(HandlerContextKey.SERVICE_ID, "SNS");
805                 request.addHandlerContext(HandlerContextKey.OPERATION_NAME, "DeleteEndpoint");
806                 request.addHandlerContext(HandlerContextKey.ADVANCED_CONFIG, advancedConfig);
807
808             } finally {
809                 awsRequestMetrics.endEvent(Field.RequestMarshallTime);
810             }
811
812             StaxResponseHandler<DeleteEndpointResult> responseHandler = new StaxResponseHandler<DeleteEndpointResult>(
813                     new DeleteEndpointResultStaxUnmarshaller());
814             response = invoke(request, responseHandler, executionContext);
815
816             return response.getAwsResponse();
817
818         } finally {
819
820             endClientExecution(awsRequestMetrics, request, response);
821         }
822     }
823
824     /**
825      * <p>
826      * Deletes a platform application object for one of the supported push notification services, such as APNS and FCM.
827      * For more information, see <a href="https://docs.aws.amazon.com/sns/latest/dg/SNSMobilePush.html">Using Amazon SNS
828      * Mobile Push Notifications</a>.
829      * </p>
830      * 
831      * @param deletePlatformApplicationRequest
832      *        Input for DeletePlatformApplication action.
833      * @return Result of the DeletePlatformApplication operation returned by the service.
834      * @throws InvalidParameterException
835      *         Indicates that a request parameter does not comply with the associated constraints.
836      * @throws InternalErrorException
837      *         Indicates an internal service error.
838      * @throws AuthorizationErrorException
839      *         Indicates that the user has been denied access to the requested resource.
840      * @sample AmazonSNS.DeletePlatformApplication
841      * @see <a href="http://docs.aws.amazon.com/goto/WebAPI/sns-2010-03-31/DeletePlatformApplication" target="_top">AWS
842      *      API Documentation</a>
843      */

844     @Override
845     public DeletePlatformApplicationResult deletePlatformApplication(DeletePlatformApplicationRequest request) {
846         request = beforeClientExecution(request);
847         return executeDeletePlatformApplication(request);
848     }
849
850     @SdkInternalApi
851     final DeletePlatformApplicationResult executeDeletePlatformApplication(DeletePlatformApplicationRequest deletePlatformApplicationRequest) {
852
853         ExecutionContext executionContext = createExecutionContext(deletePlatformApplicationRequest);
854         AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
855         awsRequestMetrics.startEvent(Field.ClientExecuteTime);
856         Request<DeletePlatformApplicationRequest> request = null;
857         Response<DeletePlatformApplicationResult> response = null;
858
859         try {
860             awsRequestMetrics.startEvent(Field.RequestMarshallTime);
861             try {
862                 request = new DeletePlatformApplicationRequestMarshaller().marshall(super.beforeMarshalling(deletePlatformApplicationRequest));
863                 // Binds the request metrics to the current request.
864                 request.setAWSRequestMetrics(awsRequestMetrics);
865                 request.addHandlerContext(HandlerContextKey.SIGNING_REGION, getSigningRegion());
866                 request.addHandlerContext(HandlerContextKey.SERVICE_ID, "SNS");
867                 request.addHandlerContext(HandlerContextKey.OPERATION_NAME, "DeletePlatformApplication");
868                 request.addHandlerContext(HandlerContextKey.ADVANCED_CONFIG, advancedConfig);
869
870             } finally {
871                 awsRequestMetrics.endEvent(Field.RequestMarshallTime);
872             }
873
874             StaxResponseHandler<DeletePlatformApplicationResult> responseHandler = new StaxResponseHandler<DeletePlatformApplicationResult>(
875                     new DeletePlatformApplicationResultStaxUnmarshaller());
876             response = invoke(request, responseHandler, executionContext);
877
878             return response.getAwsResponse();
879
880         } finally {
881
882             endClientExecution(awsRequestMetrics, request, response);
883         }
884     }
885
886     /**
887      * <p>
888      * Deletes a topic and all its subscriptions. Deleting a topic might prevent some messages previously sent to the
889      * topic from being delivered to subscribers. This action is idempotent, so deleting a topic that does not exist
890      * does not result in an error.
891      * </p>
892      * 
893      * @param deleteTopicRequest
894      * @return Result of the DeleteTopic operation returned by the service.
895      * @throws InvalidParameterException
896      *         Indicates that a request parameter does not comply with the associated constraints.
897      * @throws InternalErrorException
898      *         Indicates an internal service error.
899      * @throws AuthorizationErrorException
900      *         Indicates that the user has been denied access to the requested resource.
901      * @throws NotFoundException
902      *         Indicates that the requested resource does not exist.
903      * @throws StaleTagException
904      *         A tag has been added to a resource with the same ARN as a deleted resource. Wait a short while and then
905      *         retry the operation.
906      * @throws TagPolicyException
907      *         The request doesn't comply with the IAM tag policy. Correct your request and then retry it.
908      * @throws ConcurrentAccessException
909      *         Can't perform multiple operations on a tag simultaneously. Perform the operations sequentially.
910      * @sample AmazonSNS.DeleteTopic
911      * @see <a href="http://docs.aws.amazon.com/goto/WebAPI/sns-2010-03-31/DeleteTopic" target="_top">AWS API
912      *      Documentation</a>
913      */

914     @Override
915     public DeleteTopicResult deleteTopic(DeleteTopicRequest request) {
916         request = beforeClientExecution(request);
917         return executeDeleteTopic(request);
918     }
919
920     @SdkInternalApi
921     final DeleteTopicResult executeDeleteTopic(DeleteTopicRequest deleteTopicRequest) {
922
923         ExecutionContext executionContext = createExecutionContext(deleteTopicRequest);
924         AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
925         awsRequestMetrics.startEvent(Field.ClientExecuteTime);
926         Request<DeleteTopicRequest> request = null;
927         Response<DeleteTopicResult> response = null;
928
929         try {
930             awsRequestMetrics.startEvent(Field.RequestMarshallTime);
931             try {
932                 request = new DeleteTopicRequestMarshaller().marshall(super.beforeMarshalling(deleteTopicRequest));
933                 // Binds the request metrics to the current request.
934                 request.setAWSRequestMetrics(awsRequestMetrics);
935                 request.addHandlerContext(HandlerContextKey.SIGNING_REGION, getSigningRegion());
936                 request.addHandlerContext(HandlerContextKey.SERVICE_ID, "SNS");
937                 request.addHandlerContext(HandlerContextKey.OPERATION_NAME, "DeleteTopic");
938                 request.addHandlerContext(HandlerContextKey.ADVANCED_CONFIG, advancedConfig);
939
940             } finally {
941                 awsRequestMetrics.endEvent(Field.RequestMarshallTime);
942             }
943
944             StaxResponseHandler<DeleteTopicResult> responseHandler = new StaxResponseHandler<DeleteTopicResult>(new DeleteTopicResultStaxUnmarshaller());
945             response = invoke(request, responseHandler, executionContext);
946
947             return response.getAwsResponse();
948
949         } finally {
950
951             endClientExecution(awsRequestMetrics, request, response);
952         }
953     }
954
955     @Override
956     public DeleteTopicResult deleteTopic(String topicArn) {
957         return deleteTopic(new DeleteTopicRequest().withTopicArn(topicArn));
958     }
959
960     /**
961      * <p>
962      * Retrieves the endpoint attributes for a device on one of the supported push notification services, such as FCM
963      * and APNS. For more information, see <a href="https://docs.aws.amazon.com/sns/latest/dg/SNSMobilePush.html">Using
964      * Amazon SNS Mobile Push Notifications</a>.
965      * </p>
966      * 
967      * @param getEndpointAttributesRequest
968      *        Input for GetEndpointAttributes action.
969      * @return Result of the GetEndpointAttributes operation returned by the service.
970      * @throws InvalidParameterException
971      *         Indicates that a request parameter does not comply with the associated constraints.
972      * @throws InternalErrorException
973      *         Indicates an internal service error.
974      * @throws AuthorizationErrorException
975      *         Indicates that the user has been denied access to the requested resource.
976      * @throws NotFoundException
977      *         Indicates that the requested resource does not exist.
978      * @sample AmazonSNS.GetEndpointAttributes
979      * @see <a href="http://docs.aws.amazon.com/goto/WebAPI/sns-2010-03-31/GetEndpointAttributes" target="_top">AWS API
980      *      Documentation</a>
981      */

982     @Override
983     public GetEndpointAttributesResult getEndpointAttributes(GetEndpointAttributesRequest request) {
984         request = beforeClientExecution(request);
985         return executeGetEndpointAttributes(request);
986     }
987
988     @SdkInternalApi
989     final GetEndpointAttributesResult executeGetEndpointAttributes(GetEndpointAttributesRequest getEndpointAttributesRequest) {
990
991         ExecutionContext executionContext = createExecutionContext(getEndpointAttributesRequest);
992         AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
993         awsRequestMetrics.startEvent(Field.ClientExecuteTime);
994         Request<GetEndpointAttributesRequest> request = null;
995         Response<GetEndpointAttributesResult> response = null;
996
997         try {
998             awsRequestMetrics.startEvent(Field.RequestMarshallTime);
999             try {
1000                 request = new GetEndpointAttributesRequestMarshaller().marshall(super.beforeMarshalling(getEndpointAttributesRequest));
1001                 // Binds the request metrics to the current request.
1002                 request.setAWSRequestMetrics(awsRequestMetrics);
1003                 request.addHandlerContext(HandlerContextKey.SIGNING_REGION, getSigningRegion());
1004                 request.addHandlerContext(HandlerContextKey.SERVICE_ID, "SNS");
1005                 request.addHandlerContext(HandlerContextKey.OPERATION_NAME, "GetEndpointAttributes");
1006                 request.addHandlerContext(HandlerContextKey.ADVANCED_CONFIG, advancedConfig);
1007
1008             } finally {
1009                 awsRequestMetrics.endEvent(Field.RequestMarshallTime);
1010             }
1011
1012             StaxResponseHandler<GetEndpointAttributesResult> responseHandler = new StaxResponseHandler<GetEndpointAttributesResult>(
1013                     new GetEndpointAttributesResultStaxUnmarshaller());
1014             response = invoke(request, responseHandler, executionContext);
1015
1016             return response.getAwsResponse();
1017
1018         } finally {
1019
1020             endClientExecution(awsRequestMetrics, request, response);
1021         }
1022     }
1023
1024     /**
1025      * <p>
1026      * Retrieves the attributes of the platform application object for the supported push notification services, such as
1027      * APNS and FCM. For more information, see <a
1028      * href="https://docs.aws.amazon.com/sns/latest/dg/SNSMobilePush.html">Using Amazon SNS Mobile Push
1029      * Notifications</a>.
1030      * </p>
1031      * 
1032      * @param getPlatformApplicationAttributesRequest
1033      *        Input for GetPlatformApplicationAttributes action.
1034      * @return Result of the GetPlatformApplicationAttributes operation returned by the service.
1035      * @throws InvalidParameterException
1036      *         Indicates that a request parameter does not comply with the associated constraints.
1037      * @throws InternalErrorException
1038      *         Indicates an internal service error.
1039      * @throws AuthorizationErrorException
1040      *         Indicates that the user has been denied access to the requested resource.
1041      * @throws NotFoundException
1042      *         Indicates that the requested resource does not exist.
1043      * @sample AmazonSNS.GetPlatformApplicationAttributes
1044      * @see <a href="http://docs.aws.amazon.com/goto/WebAPI/sns-2010-03-31/GetPlatformApplicationAttributes"
1045      *      target="_top">AWS API Documentation</a>
1046      */

1047     @Override
1048     public GetPlatformApplicationAttributesResult getPlatformApplicationAttributes(GetPlatformApplicationAttributesRequest request) {
1049         request = beforeClientExecution(request);
1050         return executeGetPlatformApplicationAttributes(request);
1051     }
1052
1053     @SdkInternalApi
1054     final GetPlatformApplicationAttributesResult executeGetPlatformApplicationAttributes(
1055             GetPlatformApplicationAttributesRequest getPlatformApplicationAttributesRequest) {
1056
1057         ExecutionContext executionContext = createExecutionContext(getPlatformApplicationAttributesRequest);
1058         AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
1059         awsRequestMetrics.startEvent(Field.ClientExecuteTime);
1060         Request<GetPlatformApplicationAttributesRequest> request = null;
1061         Response<GetPlatformApplicationAttributesResult> response = null;
1062
1063         try {
1064             awsRequestMetrics.startEvent(Field.RequestMarshallTime);
1065             try {
1066                 request = new GetPlatformApplicationAttributesRequestMarshaller().marshall(super.beforeMarshalling(getPlatformApplicationAttributesRequest));
1067                 // Binds the request metrics to the current request.
1068                 request.setAWSRequestMetrics(awsRequestMetrics);
1069                 request.addHandlerContext(HandlerContextKey.SIGNING_REGION, getSigningRegion());
1070                 request.addHandlerContext(HandlerContextKey.SERVICE_ID, "SNS");
1071                 request.addHandlerContext(HandlerContextKey.OPERATION_NAME, "GetPlatformApplicationAttributes");
1072                 request.addHandlerContext(HandlerContextKey.ADVANCED_CONFIG, advancedConfig);
1073
1074             } finally {
1075                 awsRequestMetrics.endEvent(Field.RequestMarshallTime);
1076             }
1077
1078             StaxResponseHandler<GetPlatformApplicationAttributesResult> responseHandler = new StaxResponseHandler<GetPlatformApplicationAttributesResult>(
1079                     new GetPlatformApplicationAttributesResultStaxUnmarshaller());
1080             response = invoke(request, responseHandler, executionContext);
1081
1082             return response.getAwsResponse();
1083
1084         } finally {
1085
1086             endClientExecution(awsRequestMetrics, request, response);
1087         }
1088     }
1089
1090     /**
1091      * <p>
1092      * Returns the settings for sending SMS messages from your account.
1093      * </p>
1094      * <p>
1095      * These settings are set with the <code>SetSMSAttributes</code> action.
1096      * </p>
1097      * 
1098      * @param getSMSAttributesRequest
1099      *        The input for the <code>GetSMSAttributes</code> request.
1100      * @return Result of the GetSMSAttributes operation returned by the service.
1101      * @throws ThrottledException
1102      *         Indicates that the rate at which requests have been submitted for this action exceeds the limit for your
1103      *         account.
1104      * @throws InternalErrorException
1105      *         Indicates an internal service error.
1106      * @throws AuthorizationErrorException
1107      *         Indicates that the user has been denied access to the requested resource.
1108      * @throws InvalidParameterException
1109      *         Indicates that a request parameter does not comply with the associated constraints.
1110      * @sample AmazonSNS.GetSMSAttributes
1111      * @see <a href="http://docs.aws.amazon.com/goto/WebAPI/sns-2010-03-31/GetSMSAttributes" target="_top">AWS API
1112      *      Documentation</a>
1113      */

1114     @Override
1115     public GetSMSAttributesResult getSMSAttributes(GetSMSAttributesRequest request) {
1116         request = beforeClientExecution(request);
1117         return executeGetSMSAttributes(request);
1118     }
1119
1120     @SdkInternalApi
1121     final GetSMSAttributesResult executeGetSMSAttributes(GetSMSAttributesRequest getSMSAttributesRequest) {
1122
1123         ExecutionContext executionContext = createExecutionContext(getSMSAttributesRequest);
1124         AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
1125         awsRequestMetrics.startEvent(Field.ClientExecuteTime);
1126         Request<GetSMSAttributesRequest> request = null;
1127         Response<GetSMSAttributesResult> response = null;
1128
1129         try {
1130             awsRequestMetrics.startEvent(Field.RequestMarshallTime);
1131             try {
1132                 request = new GetSMSAttributesRequestMarshaller().marshall(super.beforeMarshalling(getSMSAttributesRequest));
1133                 // Binds the request metrics to the current request.
1134                 request.setAWSRequestMetrics(awsRequestMetrics);
1135                 request.addHandlerContext(HandlerContextKey.SIGNING_REGION, getSigningRegion());
1136                 request.addHandlerContext(HandlerContextKey.SERVICE_ID, "SNS");
1137                 request.addHandlerContext(HandlerContextKey.OPERATION_NAME, "GetSMSAttributes");
1138                 request.addHandlerContext(HandlerContextKey.ADVANCED_CONFIG, advancedConfig);
1139
1140             } finally {
1141                 awsRequestMetrics.endEvent(Field.RequestMarshallTime);
1142             }
1143
1144             StaxResponseHandler<GetSMSAttributesResult> responseHandler = new StaxResponseHandler<GetSMSAttributesResult>(
1145                     new GetSMSAttributesResultStaxUnmarshaller());
1146             response = invoke(request, responseHandler, executionContext);
1147
1148             return response.getAwsResponse();
1149
1150         } finally {
1151
1152             endClientExecution(awsRequestMetrics, request, response);
1153         }
1154     }
1155
1156     /**
1157      * <p>
1158      * Returns all of the properties of a subscription.
1159      * </p>
1160      * 
1161      * @param getSubscriptionAttributesRequest
1162      *        Input for GetSubscriptionAttributes.
1163      * @return Result of the GetSubscriptionAttributes operation returned by the service.
1164      * @throws InvalidParameterException
1165      *         Indicates that a request parameter does not comply with the associated constraints.
1166      * @throws InternalErrorException
1167      *         Indicates an internal service error.
1168      * @throws NotFoundException
1169      *         Indicates that the requested resource does not exist.
1170      * @throws AuthorizationErrorException
1171      *         Indicates that the user has been denied access to the requested resource.
1172      * @sample AmazonSNS.GetSubscriptionAttributes
1173      * @see <a href="http://docs.aws.amazon.com/goto/WebAPI/sns-2010-03-31/GetSubscriptionAttributes" target="_top">AWS
1174      *      API Documentation</a>
1175      */

1176     @Override
1177     public GetSubscriptionAttributesResult getSubscriptionAttributes(GetSubscriptionAttributesRequest request) {
1178         request = beforeClientExecution(request);
1179         return executeGetSubscriptionAttributes(request);
1180     }
1181
1182     @SdkInternalApi
1183     final GetSubscriptionAttributesResult executeGetSubscriptionAttributes(GetSubscriptionAttributesRequest getSubscriptionAttributesRequest) {
1184
1185         ExecutionContext executionContext = createExecutionContext(getSubscriptionAttributesRequest);
1186         AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
1187         awsRequestMetrics.startEvent(Field.ClientExecuteTime);
1188         Request<GetSubscriptionAttributesRequest> request = null;
1189         Response<GetSubscriptionAttributesResult> response = null;
1190
1191         try {
1192             awsRequestMetrics.startEvent(Field.RequestMarshallTime);
1193             try {
1194                 request = new GetSubscriptionAttributesRequestMarshaller().marshall(super.beforeMarshalling(getSubscriptionAttributesRequest));
1195                 // Binds the request metrics to the current request.
1196                 request.setAWSRequestMetrics(awsRequestMetrics);
1197                 request.addHandlerContext(HandlerContextKey.SIGNING_REGION, getSigningRegion());
1198                 request.addHandlerContext(HandlerContextKey.SERVICE_ID, "SNS");
1199                 request.addHandlerContext(HandlerContextKey.OPERATION_NAME, "GetSubscriptionAttributes");
1200                 request.addHandlerContext(HandlerContextKey.ADVANCED_CONFIG, advancedConfig);
1201
1202             } finally {
1203                 awsRequestMetrics.endEvent(Field.RequestMarshallTime);
1204             }
1205
1206             StaxResponseHandler<GetSubscriptionAttributesResult> responseHandler = new StaxResponseHandler<GetSubscriptionAttributesResult>(
1207                     new GetSubscriptionAttributesResultStaxUnmarshaller());
1208             response = invoke(request, responseHandler, executionContext);
1209
1210             return response.getAwsResponse();
1211
1212         } finally {
1213
1214             endClientExecution(awsRequestMetrics, request, response);
1215         }
1216     }
1217
1218     @Override
1219     public GetSubscriptionAttributesResult getSubscriptionAttributes(String subscriptionArn) {
1220         return getSubscriptionAttributes(new GetSubscriptionAttributesRequest().withSubscriptionArn(subscriptionArn));
1221     }
1222
1223     /**
1224      * <p>
1225      * Returns all of the properties of a topic. Topic properties returned might differ based on the authorization of
1226      * the user.
1227      * </p>
1228      * 
1229      * @param getTopicAttributesRequest
1230      *        Input for GetTopicAttributes action.
1231      * @return Result of the GetTopicAttributes operation returned by the service.
1232      * @throws InvalidParameterException
1233      *         Indicates that a request parameter does not comply with the associated constraints.
1234      * @throws InternalErrorException
1235      *         Indicates an internal service error.
1236      * @throws NotFoundException
1237      *         Indicates that the requested resource does not exist.
1238      * @throws AuthorizationErrorException
1239      *         Indicates that the user has been denied access to the requested resource.
1240      * @throws InvalidSecurityException
1241      *         The credential signature isn't valid. You must use an HTTPS endpoint and sign your request using
1242      *         Signature Version 4.
1243      * @sample AmazonSNS.GetTopicAttributes
1244      * @see <a href="http://docs.aws.amazon.com/goto/WebAPI/sns-2010-03-31/GetTopicAttributes" target="_top">AWS API
1245      *      Documentation</a>
1246      */

1247     @Override
1248     public GetTopicAttributesResult getTopicAttributes(GetTopicAttributesRequest request) {
1249         request = beforeClientExecution(request);
1250         return executeGetTopicAttributes(request);
1251     }
1252
1253     @SdkInternalApi
1254     final GetTopicAttributesResult executeGetTopicAttributes(GetTopicAttributesRequest getTopicAttributesRequest) {
1255
1256         ExecutionContext executionContext = createExecutionContext(getTopicAttributesRequest);
1257         AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
1258         awsRequestMetrics.startEvent(Field.ClientExecuteTime);
1259         Request<GetTopicAttributesRequest> request = null;
1260         Response<GetTopicAttributesResult> response = null;
1261
1262         try {
1263             awsRequestMetrics.startEvent(Field.RequestMarshallTime);
1264             try {
1265                 request = new GetTopicAttributesRequestMarshaller().marshall(super.beforeMarshalling(getTopicAttributesRequest));
1266                 // Binds the request metrics to the current request.
1267                 request.setAWSRequestMetrics(awsRequestMetrics);
1268                 request.addHandlerContext(HandlerContextKey.SIGNING_REGION, getSigningRegion());
1269                 request.addHandlerContext(HandlerContextKey.SERVICE_ID, "SNS");
1270                 request.addHandlerContext(HandlerContextKey.OPERATION_NAME, "GetTopicAttributes");
1271                 request.addHandlerContext(HandlerContextKey.ADVANCED_CONFIG, advancedConfig);
1272
1273             } finally {
1274                 awsRequestMetrics.endEvent(Field.RequestMarshallTime);
1275             }
1276
1277             StaxResponseHandler<GetTopicAttributesResult> responseHandler = new StaxResponseHandler<GetTopicAttributesResult>(
1278                     new GetTopicAttributesResultStaxUnmarshaller());
1279             response = invoke(request, responseHandler, executionContext);
1280
1281             return response.getAwsResponse();
1282
1283         } finally {
1284
1285             endClientExecution(awsRequestMetrics, request, response);
1286         }
1287     }
1288
1289     @Override
1290     public GetTopicAttributesResult getTopicAttributes(String topicArn) {
1291         return getTopicAttributes(new GetTopicAttributesRequest().withTopicArn(topicArn));
1292     }
1293
1294     /**
1295      * <p>
1296      * Lists the endpoints and endpoint attributes for devices in a supported push notification service, such as FCM and
1297      * APNS. The results for <code>ListEndpointsByPlatformApplication</code> are paginated and return a limited list of
1298      * endpoints, up to 100. If additional records are available after the first page results, then a NextToken string
1299      * will be returned. To receive the next page, you call <code>ListEndpointsByPlatformApplication</code> again using
1300      * the NextToken string received from the previous call. When there are no more records to return, NextToken will be
1301      * null. For more information, see <a href="https://docs.aws.amazon.com/sns/latest/dg/SNSMobilePush.html">Using
1302      * Amazon SNS Mobile Push Notifications</a>.
1303      * </p>
1304      * <p>
1305      * This action is throttled at 30 transactions per second (TPS).
1306      * </p>
1307      * 
1308      * @param listEndpointsByPlatformApplicationRequest
1309      *        Input for ListEndpointsByPlatformApplication action.
1310      * @return Result of the ListEndpointsByPlatformApplication operation returned by the service.
1311      * @throws InvalidParameterException
1312      *         Indicates that a request parameter does not comply with the associated constraints.
1313      * @throws InternalErrorException
1314      *         Indicates an internal service error.
1315      * @throws AuthorizationErrorException
1316      *         Indicates that the user has been denied access to the requested resource.
1317      * @throws NotFoundException
1318      *         Indicates that the requested resource does not exist.
1319      * @sample AmazonSNS.ListEndpointsByPlatformApplication
1320      * @see <a href="http://docs.aws.amazon.com/goto/WebAPI/sns-2010-03-31/ListEndpointsByPlatformApplication"
1321      *      target="_top">AWS API Documentation</a>
1322      */

1323     @Override
1324     public ListEndpointsByPlatformApplicationResult listEndpointsByPlatformApplication(ListEndpointsByPlatformApplicationRequest request) {
1325         request = beforeClientExecution(request);
1326         return executeListEndpointsByPlatformApplication(request);
1327     }
1328
1329     @SdkInternalApi
1330     final ListEndpointsByPlatformApplicationResult executeListEndpointsByPlatformApplication(
1331             ListEndpointsByPlatformApplicationRequest listEndpointsByPlatformApplicationRequest) {
1332
1333         ExecutionContext executionContext = createExecutionContext(listEndpointsByPlatformApplicationRequest);
1334         AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
1335         awsRequestMetrics.startEvent(Field.ClientExecuteTime);
1336         Request<ListEndpointsByPlatformApplicationRequest> request = null;
1337         Response<ListEndpointsByPlatformApplicationResult> response = null;
1338
1339         try {
1340             awsRequestMetrics.startEvent(Field.RequestMarshallTime);
1341             try {
1342                 request = new ListEndpointsByPlatformApplicationRequestMarshaller()
1343                         .marshall(super.beforeMarshalling(listEndpointsByPlatformApplicationRequest));
1344                 // Binds the request metrics to the current request.
1345                 request.setAWSRequestMetrics(awsRequestMetrics);
1346                 request.addHandlerContext(HandlerContextKey.SIGNING_REGION, getSigningRegion());
1347                 request.addHandlerContext(HandlerContextKey.SERVICE_ID, "SNS");
1348                 request.addHandlerContext(HandlerContextKey.OPERATION_NAME, "ListEndpointsByPlatformApplication");
1349                 request.addHandlerContext(HandlerContextKey.ADVANCED_CONFIG, advancedConfig);
1350
1351             } finally {
1352                 awsRequestMetrics.endEvent(Field.RequestMarshallTime);
1353             }
1354
1355             StaxResponseHandler<ListEndpointsByPlatformApplicationResult> responseHandler = new StaxResponseHandler<ListEndpointsByPlatformApplicationResult>(
1356                     new ListEndpointsByPlatformApplicationResultStaxUnmarshaller());
1357             response = invoke(request, responseHandler, executionContext);
1358
1359             return response.getAwsResponse();
1360
1361         } finally {
1362
1363             endClientExecution(awsRequestMetrics, request, response);
1364         }
1365     }
1366
1367     /**
1368      * <p>
1369      * Returns a list of phone numbers that are opted out, meaning you cannot send SMS messages to them.
1370      * </p>
1371      * <p>
1372      * The results for <code>ListPhoneNumbersOptedOut</code> are paginated, and each page returns up to 100 phone
1373      * numbers. If additional phone numbers are available after the first page of results, then a <code>NextToken</code>
1374      * string will be returned. To receive the next page, you call <code>ListPhoneNumbersOptedOut</code> again using the
1375      * <code>NextToken</code> string received from the previous call. When there are no more records to return,
1376      * <code>NextToken</code> will be null.
1377      * </p>
1378      * 
1379      * @param listPhoneNumbersOptedOutRequest
1380      *        The input for the <code>ListPhoneNumbersOptedOut</code> action.
1381      * @return Result of the ListPhoneNumbersOptedOut operation returned by the service.
1382      * @throws ThrottledException
1383      *         Indicates that the rate at which requests have been submitted for this action exceeds the limit for your
1384      *         account.
1385      * @throws InternalErrorException
1386      *         Indicates an internal service error.
1387      * @throws AuthorizationErrorException
1388      *         Indicates that the user has been denied access to the requested resource.
1389      * @throws InvalidParameterException
1390      *         Indicates that a request parameter does not comply with the associated constraints.
1391      * @sample AmazonSNS.ListPhoneNumbersOptedOut
1392      * @see <a href="http://docs.aws.amazon.com/goto/WebAPI/sns-2010-03-31/ListPhoneNumbersOptedOut" target="_top">AWS
1393      *      API Documentation</a>
1394      */

1395     @Override
1396     public ListPhoneNumbersOptedOutResult listPhoneNumbersOptedOut(ListPhoneNumbersOptedOutRequest request) {
1397         request = beforeClientExecution(request);
1398         return executeListPhoneNumbersOptedOut(request);
1399     }
1400
1401     @SdkInternalApi
1402     final ListPhoneNumbersOptedOutResult executeListPhoneNumbersOptedOut(ListPhoneNumbersOptedOutRequest listPhoneNumbersOptedOutRequest) {
1403
1404         ExecutionContext executionContext = createExecutionContext(listPhoneNumbersOptedOutRequest);
1405         AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
1406         awsRequestMetrics.startEvent(Field.ClientExecuteTime);
1407         Request<ListPhoneNumbersOptedOutRequest> request = null;
1408         Response<ListPhoneNumbersOptedOutResult> response = null;
1409
1410         try {
1411             awsRequestMetrics.startEvent(Field.RequestMarshallTime);
1412             try {
1413                 request = new ListPhoneNumbersOptedOutRequestMarshaller().marshall(super.beforeMarshalling(listPhoneNumbersOptedOutRequest));
1414                 // Binds the request metrics to the current request.
1415                 request.setAWSRequestMetrics(awsRequestMetrics);
1416                 request.addHandlerContext(HandlerContextKey.SIGNING_REGION, getSigningRegion());
1417                 request.addHandlerContext(HandlerContextKey.SERVICE_ID, "SNS");
1418                 request.addHandlerContext(HandlerContextKey.OPERATION_NAME, "ListPhoneNumbersOptedOut");
1419                 request.addHandlerContext(HandlerContextKey.ADVANCED_CONFIG, advancedConfig);
1420
1421             } finally {
1422                 awsRequestMetrics.endEvent(Field.RequestMarshallTime);
1423             }
1424
1425             StaxResponseHandler<ListPhoneNumbersOptedOutResult> responseHandler = new StaxResponseHandler<ListPhoneNumbersOptedOutResult>(
1426                     new ListPhoneNumbersOptedOutResultStaxUnmarshaller());
1427             response = invoke(request, responseHandler, executionContext);
1428
1429             return response.getAwsResponse();
1430
1431         } finally {
1432
1433             endClientExecution(awsRequestMetrics, request, response);
1434         }
1435     }
1436
1437     /**
1438      * <p>
1439      * Lists the platform application objects for the supported push notification services, such as APNS and FCM. The
1440      * results for <code>ListPlatformApplications</code> are paginated and return a limited list of applications, up to
1441      * 100. If additional records are available after the first page results, then a NextToken string will be returned.
1442      * To receive the next page, you call <code>ListPlatformApplications</code> using the NextToken string received from
1443      * the previous call. When there are no more records to return, NextToken will be null. For more information, see <a
1444      * href="https://docs.aws.amazon.com/sns/latest/dg/SNSMobilePush.html">Using Amazon SNS Mobile Push
1445      * Notifications</a>.
1446      * </p>
1447      * <p>
1448      * This action is throttled at 15 transactions per second (TPS).
1449      * </p>
1450      * 
1451      * @param listPlatformApplicationsRequest
1452      *        Input for ListPlatformApplications action.
1453      * @return Result of the ListPlatformApplications operation returned by the service.
1454      * @throws InvalidParameterException
1455      *         Indicates that a request parameter does not comply with the associated constraints.
1456      * @throws InternalErrorException
1457      *         Indicates an internal service error.
1458      * @throws AuthorizationErrorException
1459      *         Indicates that the user has been denied access to the requested resource.
1460      * @sample AmazonSNS.ListPlatformApplications
1461      * @see <a href="http://docs.aws.amazon.com/goto/WebAPI/sns-2010-03-31/ListPlatformApplications" target="_top">AWS
1462      *      API Documentation</a>
1463      */

1464     @Override
1465     public ListPlatformApplicationsResult listPlatformApplications(ListPlatformApplicationsRequest request) {
1466         request = beforeClientExecution(request);
1467         return executeListPlatformApplications(request);
1468     }
1469
1470     @SdkInternalApi
1471     final ListPlatformApplicationsResult executeListPlatformApplications(ListPlatformApplicationsRequest listPlatformApplicationsRequest) {
1472
1473         ExecutionContext executionContext = createExecutionContext(listPlatformApplicationsRequest);
1474         AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
1475         awsRequestMetrics.startEvent(Field.ClientExecuteTime);
1476         Request<ListPlatformApplicationsRequest> request = null;
1477         Response<ListPlatformApplicationsResult> response = null;
1478
1479         try {
1480             awsRequestMetrics.startEvent(Field.RequestMarshallTime);
1481             try {
1482                 request = new ListPlatformApplicationsRequestMarshaller().marshall(super.beforeMarshalling(listPlatformApplicationsRequest));
1483                 // Binds the request metrics to the current request.
1484                 request.setAWSRequestMetrics(awsRequestMetrics);
1485                 request.addHandlerContext(HandlerContextKey.SIGNING_REGION, getSigningRegion());
1486                 request.addHandlerContext(HandlerContextKey.SERVICE_ID, "SNS");
1487                 request.addHandlerContext(HandlerContextKey.OPERATION_NAME, "ListPlatformApplications");
1488                 request.addHandlerContext(HandlerContextKey.ADVANCED_CONFIG, advancedConfig);
1489
1490             } finally {
1491                 awsRequestMetrics.endEvent(Field.RequestMarshallTime);
1492             }
1493
1494             StaxResponseHandler<ListPlatformApplicationsResult> responseHandler = new StaxResponseHandler<ListPlatformApplicationsResult>(
1495                     new ListPlatformApplicationsResultStaxUnmarshaller());
1496             response = invoke(request, responseHandler, executionContext);
1497
1498             return response.getAwsResponse();
1499
1500         } finally {
1501
1502             endClientExecution(awsRequestMetrics, request, response);
1503         }
1504     }
1505
1506     @Override
1507     public ListPlatformApplicationsResult listPlatformApplications() {
1508         return listPlatformApplications(new ListPlatformApplicationsRequest());
1509     }
1510
1511     /**
1512      * <p>
1513      * Returns a list of the requester's subscriptions. Each call returns a limited list of subscriptions, up to 100. If
1514      * there are more subscriptions, a <code>NextToken</code> is also returned. Use the <code>NextToken</code> parameter
1515      * in a new <code>ListSubscriptions</code> call to get further results.
1516      * </p>
1517      * <p>
1518      * This action is throttled at 30 transactions per second (TPS).
1519      * </p>
1520      * 
1521      * @param listSubscriptionsRequest
1522      *        Input for ListSubscriptions action.
1523      * @return Result of the ListSubscriptions operation returned by the service.
1524      * @throws InvalidParameterException
1525      *         Indicates that a request parameter does not comply with the associated constraints.
1526      * @throws InternalErrorException
1527      *         Indicates an internal service error.
1528      * @throws AuthorizationErrorException
1529      *         Indicates that the user has been denied access to the requested resource.
1530      * @sample AmazonSNS.ListSubscriptions
1531      * @see <a href="http://docs.aws.amazon.com/goto/WebAPI/sns-2010-03-31/ListSubscriptions" target="_top">AWS API
1532      *      Documentation</a>
1533      */

1534     @Override
1535     public ListSubscriptionsResult listSubscriptions(ListSubscriptionsRequest request) {
1536         request = beforeClientExecution(request);
1537         return executeListSubscriptions(request);
1538     }
1539
1540     @SdkInternalApi
1541     final ListSubscriptionsResult executeListSubscriptions(ListSubscriptionsRequest listSubscriptionsRequest) {
1542
1543         ExecutionContext executionContext = createExecutionContext(listSubscriptionsRequest);
1544         AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
1545         awsRequestMetrics.startEvent(Field.ClientExecuteTime);
1546         Request<ListSubscriptionsRequest> request = null;
1547         Response<ListSubscriptionsResult> response = null;
1548
1549         try {
1550             awsRequestMetrics.startEvent(Field.RequestMarshallTime);
1551             try {
1552                 request = new ListSubscriptionsRequestMarshaller().marshall(super.beforeMarshalling(listSubscriptionsRequest));
1553                 // Binds the request metrics to the current request.
1554                 request.setAWSRequestMetrics(awsRequestMetrics);
1555                 request.addHandlerContext(HandlerContextKey.SIGNING_REGION, getSigningRegion());
1556                 request.addHandlerContext(HandlerContextKey.SERVICE_ID, "SNS");
1557                 request.addHandlerContext(HandlerContextKey.OPERATION_NAME, "ListSubscriptions");
1558                 request.addHandlerContext(HandlerContextKey.ADVANCED_CONFIG, advancedConfig);
1559
1560             } finally {
1561                 awsRequestMetrics.endEvent(Field.RequestMarshallTime);
1562             }
1563
1564             StaxResponseHandler<ListSubscriptionsResult> responseHandler = new StaxResponseHandler<ListSubscriptionsResult>(
1565                     new ListSubscriptionsResultStaxUnmarshaller());
1566             response = invoke(request, responseHandler, executionContext);
1567
1568             return response.getAwsResponse();
1569
1570         } finally {
1571
1572             endClientExecution(awsRequestMetrics, request, response);
1573         }
1574     }
1575
1576     @Override
1577     public ListSubscriptionsResult listSubscriptions() {
1578         return listSubscriptions(new ListSubscriptionsRequest());
1579     }
1580
1581     @Override
1582     public ListSubscriptionsResult listSubscriptions(String nextToken) {
1583         return listSubscriptions(new ListSubscriptionsRequest().withNextToken(nextToken));
1584     }
1585
1586     /**
1587      * <p>
1588      * Returns a list of the subscriptions to a specific topic. Each call returns a limited list of subscriptions, up to
1589      * 100. If there are more subscriptions, a <code>NextToken</code> is also returned. Use the <code>NextToken</code>
1590      * parameter in a new <code>ListSubscriptionsByTopic</code> call to get further results.
1591      * </p>
1592      * <p>
1593      * This action is throttled at 30 transactions per second (TPS).
1594      * </p>
1595      * 
1596      * @param listSubscriptionsByTopicRequest
1597      *        Input for ListSubscriptionsByTopic action.
1598      * @return Result of the ListSubscriptionsByTopic operation returned by the service.
1599      * @throws InvalidParameterException
1600      *         Indicates that a request parameter does not comply with the associated constraints.
1601      * @throws InternalErrorException
1602      *         Indicates an internal service error.
1603      * @throws NotFoundException
1604      *         Indicates that the requested resource does not exist.
1605      * @throws AuthorizationErrorException
1606      *         Indicates that the user has been denied access to the requested resource.
1607      * @sample AmazonSNS.ListSubscriptionsByTopic
1608      * @see <a href="http://docs.aws.amazon.com/goto/WebAPI/sns-2010-03-31/ListSubscriptionsByTopic" target="_top">AWS
1609      *      API Documentation</a>
1610      */

1611     @Override
1612     public ListSubscriptionsByTopicResult listSubscriptionsByTopic(ListSubscriptionsByTopicRequest request) {
1613         request = beforeClientExecution(request);
1614         return executeListSubscriptionsByTopic(request);
1615     }
1616
1617     @SdkInternalApi
1618     final ListSubscriptionsByTopicResult executeListSubscriptionsByTopic(ListSubscriptionsByTopicRequest listSubscriptionsByTopicRequest) {
1619
1620         ExecutionContext executionContext = createExecutionContext(listSubscriptionsByTopicRequest);
1621         AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
1622         awsRequestMetrics.startEvent(Field.ClientExecuteTime);
1623         Request<ListSubscriptionsByTopicRequest> request = null;
1624         Response<ListSubscriptionsByTopicResult> response = null;
1625
1626         try {
1627             awsRequestMetrics.startEvent(Field.RequestMarshallTime);
1628             try {
1629                 request = new ListSubscriptionsByTopicRequestMarshaller().marshall(super.beforeMarshalling(listSubscriptionsByTopicRequest));
1630                 // Binds the request metrics to the current request.
1631                 request.setAWSRequestMetrics(awsRequestMetrics);
1632                 request.addHandlerContext(HandlerContextKey.SIGNING_REGION, getSigningRegion());
1633                 request.addHandlerContext(HandlerContextKey.SERVICE_ID, "SNS");
1634                 request.addHandlerContext(HandlerContextKey.OPERATION_NAME, "ListSubscriptionsByTopic");
1635                 request.addHandlerContext(HandlerContextKey.ADVANCED_CONFIG, advancedConfig);
1636
1637             } finally {
1638                 awsRequestMetrics.endEvent(Field.RequestMarshallTime);
1639             }
1640
1641             StaxResponseHandler<ListSubscriptionsByTopicResult> responseHandler = new StaxResponseHandler<ListSubscriptionsByTopicResult>(
1642                     new ListSubscriptionsByTopicResultStaxUnmarshaller());
1643             response = invoke(request, responseHandler, executionContext);
1644
1645             return response.getAwsResponse();
1646
1647         } finally {
1648
1649             endClientExecution(awsRequestMetrics, request, response);
1650         }
1651     }
1652
1653     @Override
1654     public ListSubscriptionsByTopicResult listSubscriptionsByTopic(String topicArn) {
1655         return listSubscriptionsByTopic(new ListSubscriptionsByTopicRequest().withTopicArn(topicArn));
1656     }
1657
1658     @Override
1659     public ListSubscriptionsByTopicResult listSubscriptionsByTopic(String topicArn, String nextToken) {
1660         return listSubscriptionsByTopic(new ListSubscriptionsByTopicRequest().withTopicArn(topicArn).withNextToken(nextToken));
1661     }
1662
1663     /**
1664      * <p>
1665      * List all tags added to the specified Amazon SNS topic. For an overview, see <a
1666      * href="https://docs.aws.amazon.com/sns/latest/dg/sns-tags.html">Amazon SNS Tags</a> in the <i>Amazon Simple
1667      * Notification Service Developer Guide</i>.
1668      * </p>
1669      * 
1670      * @param listTagsForResourceRequest
1671      * @return Result of the ListTagsForResource operation returned by the service.
1672      * @throws ResourceNotFoundException
1673      *         Can't tag resource. Verify that the topic exists.
1674      * @throws TagPolicyException
1675      *         The request doesn't comply with the IAM tag policy. Correct your request and then retry it.
1676      * @throws InvalidParameterException
1677      *         Indicates that a request parameter does not comply with the associated constraints.
1678      * @throws AuthorizationErrorException
1679      *         Indicates that the user has been denied access to the requested resource.
1680      * @throws ConcurrentAccessException
1681      *         Can't perform multiple operations on a tag simultaneously. Perform the operations sequentially.
1682      * @sample AmazonSNS.ListTagsForResource
1683      * @see <a href="http://docs.aws.amazon.com/goto/WebAPI/sns-2010-03-31/ListTagsForResource" target="_top">AWS API
1684      *      Documentation</a>
1685      */

1686     @Override
1687     public ListTagsForResourceResult listTagsForResource(ListTagsForResourceRequest request) {
1688         request = beforeClientExecution(request);
1689         return executeListTagsForResource(request);
1690     }
1691
1692     @SdkInternalApi
1693     final ListTagsForResourceResult executeListTagsForResource(ListTagsForResourceRequest listTagsForResourceRequest) {
1694
1695         ExecutionContext executionContext = createExecutionContext(listTagsForResourceRequest);
1696         AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
1697         awsRequestMetrics.startEvent(Field.ClientExecuteTime);
1698         Request<ListTagsForResourceRequest> request = null;
1699         Response<ListTagsForResourceResult> response = null;
1700
1701         try {
1702             awsRequestMetrics.startEvent(Field.RequestMarshallTime);
1703             try {
1704                 request = new ListTagsForResourceRequestMarshaller().marshall(super.beforeMarshalling(listTagsForResourceRequest));
1705                 // Binds the request metrics to the current request.
1706                 request.setAWSRequestMetrics(awsRequestMetrics);
1707                 request.addHandlerContext(HandlerContextKey.SIGNING_REGION, getSigningRegion());
1708                 request.addHandlerContext(HandlerContextKey.SERVICE_ID, "SNS");
1709                 request.addHandlerContext(HandlerContextKey.OPERATION_NAME, "ListTagsForResource");
1710                 request.addHandlerContext(HandlerContextKey.ADVANCED_CONFIG, advancedConfig);
1711
1712             } finally {
1713                 awsRequestMetrics.endEvent(Field.RequestMarshallTime);
1714             }
1715
1716             StaxResponseHandler<ListTagsForResourceResult> responseHandler = new StaxResponseHandler<ListTagsForResourceResult>(
1717                     new ListTagsForResourceResultStaxUnmarshaller());
1718             response = invoke(request, responseHandler, executionContext);
1719
1720             return response.getAwsResponse();
1721
1722         } finally {
1723
1724             endClientExecution(awsRequestMetrics, request, response);
1725         }
1726     }
1727
1728     /**
1729      * <p>
1730      * Returns a list of the requester's topics. Each call returns a limited list of topics, up to 100. If there are
1731      * more topics, a <code>NextToken</code> is also returned. Use the <code>NextToken</code> parameter in a new
1732      * <code>ListTopics</code> call to get further results.
1733      * </p>
1734      * <p>
1735      * This action is throttled at 30 transactions per second (TPS).
1736      * </p>
1737      * 
1738      * @param listTopicsRequest
1739      * @return Result of the ListTopics operation returned by the service.
1740      * @throws InvalidParameterException
1741      *         Indicates that a request parameter does not comply with the associated constraints.
1742      * @throws InternalErrorException
1743      *         Indicates an internal service error.
1744      * @throws AuthorizationErrorException
1745      *         Indicates that the user has been denied access to the requested resource.
1746      * @sample AmazonSNS.ListTopics
1747      * @see <a href="http://docs.aws.amazon.com/goto/WebAPI/sns-2010-03-31/ListTopics" target="_top">AWS API
1748      *      Documentation</a>
1749      */

1750     @Override
1751     public ListTopicsResult listTopics(ListTopicsRequest request) {
1752         request = beforeClientExecution(request);
1753         return executeListTopics(request);
1754     }
1755
1756     @SdkInternalApi
1757     final ListTopicsResult executeListTopics(ListTopicsRequest listTopicsRequest) {
1758
1759         ExecutionContext executionContext = createExecutionContext(listTopicsRequest);
1760         AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
1761         awsRequestMetrics.startEvent(Field.ClientExecuteTime);
1762         Request<ListTopicsRequest> request = null;
1763         Response<ListTopicsResult> response = null;
1764
1765         try {
1766             awsRequestMetrics.startEvent(Field.RequestMarshallTime);
1767             try {
1768                 request = new ListTopicsRequestMarshaller().marshall(super.beforeMarshalling(listTopicsRequest));
1769                 // Binds the request metrics to the current request.
1770                 request.setAWSRequestMetrics(awsRequestMetrics);
1771                 request.addHandlerContext(HandlerContextKey.SIGNING_REGION, getSigningRegion());
1772                 request.addHandlerContext(HandlerContextKey.SERVICE_ID, "SNS");
1773                 request.addHandlerContext(HandlerContextKey.OPERATION_NAME, "ListTopics");
1774                 request.addHandlerContext(HandlerContextKey.ADVANCED_CONFIG, advancedConfig);
1775
1776             } finally {
1777                 awsRequestMetrics.endEvent(Field.RequestMarshallTime);
1778             }
1779
1780             StaxResponseHandler<ListTopicsResult> responseHandler = new StaxResponseHandler<ListTopicsResult>(new ListTopicsResultStaxUnmarshaller());
1781             response = invoke(request, responseHandler, executionContext);
1782
1783             return response.getAwsResponse();
1784
1785         } finally {
1786
1787             endClientExecution(awsRequestMetrics, request, response);
1788         }
1789     }
1790
1791     @Override
1792     public ListTopicsResult listTopics() {
1793         return listTopics(new ListTopicsRequest());
1794     }
1795
1796     @Override
1797     public ListTopicsResult listTopics(String nextToken) {
1798         return listTopics(new ListTopicsRequest().withNextToken(nextToken));
1799     }
1800
1801     /**
1802      * <p>
1803      * Use this request to opt in a phone number that is opted out, which enables you to resume sending SMS messages to
1804      * the number.
1805      * </p>
1806      * <p>
1807      * You can opt in a phone number only once every 30 days.
1808      * </p>
1809      * 
1810      * @param optInPhoneNumberRequest
1811      *        Input for the OptInPhoneNumber action.
1812      * @return Result of the OptInPhoneNumber operation returned by the service.
1813      * @throws ThrottledException
1814      *         Indicates that the rate at which requests have been submitted for this action exceeds the limit for your
1815      *         account.
1816      * @throws InternalErrorException
1817      *         Indicates an internal service error.
1818      * @throws AuthorizationErrorException
1819      *         Indicates that the user has been denied access to the requested resource.
1820      * @throws InvalidParameterException
1821      *         Indicates that a request parameter does not comply with the associated constraints.
1822      * @sample AmazonSNS.OptInPhoneNumber
1823      * @see <a href="http://docs.aws.amazon.com/goto/WebAPI/sns-2010-03-31/OptInPhoneNumber" target="_top">AWS API
1824      *      Documentation</a>
1825      */

1826     @Override
1827     public OptInPhoneNumberResult optInPhoneNumber(OptInPhoneNumberRequest request) {
1828         request = beforeClientExecution(request);
1829         return executeOptInPhoneNumber(request);
1830     }
1831
1832     @SdkInternalApi
1833     final OptInPhoneNumberResult executeOptInPhoneNumber(OptInPhoneNumberRequest optInPhoneNumberRequest) {
1834
1835         ExecutionContext executionContext = createExecutionContext(optInPhoneNumberRequest);
1836         AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
1837         awsRequestMetrics.startEvent(Field.ClientExecuteTime);
1838         Request<OptInPhoneNumberRequest> request = null;
1839         Response<OptInPhoneNumberResult> response = null;
1840
1841         try {
1842             awsRequestMetrics.startEvent(Field.RequestMarshallTime);
1843             try {
1844                 request = new OptInPhoneNumberRequestMarshaller().marshall(super.beforeMarshalling(optInPhoneNumberRequest));
1845                 // Binds the request metrics to the current request.
1846                 request.setAWSRequestMetrics(awsRequestMetrics);
1847                 request.addHandlerContext(HandlerContextKey.SIGNING_REGION, getSigningRegion());
1848                 request.addHandlerContext(HandlerContextKey.SERVICE_ID, "SNS");
1849                 request.addHandlerContext(HandlerContextKey.OPERATION_NAME, "OptInPhoneNumber");
1850                 request.addHandlerContext(HandlerContextKey.ADVANCED_CONFIG, advancedConfig);
1851
1852             } finally {
1853                 awsRequestMetrics.endEvent(Field.RequestMarshallTime);
1854             }
1855
1856             StaxResponseHandler<OptInPhoneNumberResult> responseHandler = new StaxResponseHandler<OptInPhoneNumberResult>(
1857                     new OptInPhoneNumberResultStaxUnmarshaller());
1858             response = invoke(request, responseHandler, executionContext);
1859
1860             return response.getAwsResponse();
1861
1862         } finally {
1863
1864             endClientExecution(awsRequestMetrics, request, response);
1865         }
1866     }
1867
1868     /**
1869      * <p>
1870      * Sends a message to an Amazon SNS topic or sends a text message (SMS message) directly to a phone number.
1871      * </p>
1872      * <p>
1873      * If you send a message to a topic, Amazon SNS delivers the message to each endpoint that is subscribed to the
1874      * topic. The format of the message depends on the notification protocol for each subscribed endpoint.
1875      * </p>
1876      * <p>
1877      * When a <code>messageId</code> is returned, the message has been saved and Amazon SNS will attempt to deliver it
1878      * shortly.
1879      * </p>
1880      * <p>
1881      * To use the <code>Publish</code> action for sending a message to a mobile endpoint, such as an app on a Kindle
1882      * device or mobile phone, you must specify the EndpointArn for the TargetArn parameter. The EndpointArn is returned
1883      * when making a call with the <code>CreatePlatformEndpoint</code> action.
1884      * </p>
1885      * <p>
1886      * For more information about formatting messages, see <a
1887      * href="https://docs.aws.amazon.com/sns/latest/dg/mobile-push-send-custommessage.html">Send Custom
1888      * Platform-Specific Payloads in Messages to Mobile Devices</a>.
1889      * </p>
1890      * 
1891      * @param publishRequest
1892      *        Input for Publish action.
1893      * @return Result of the Publish operation returned by the service.
1894      * @throws InvalidParameterException
1895      *         Indicates that a request parameter does not comply with the associated constraints.
1896      * @throws InvalidParameterValueException
1897      *         Indicates that a request parameter does not comply with the associated constraints.
1898      * @throws InternalErrorException
1899      *         Indicates an internal service error.
1900      * @throws NotFoundException
1901      *         Indicates that the requested resource does not exist.
1902      * @throws EndpointDisabledException
1903      *         Exception error indicating endpoint disabled.
1904      * @throws PlatformApplicationDisabledException
1905      *         Exception error indicating platform application disabled.
1906      * @throws AuthorizationErrorException
1907      *         Indicates that the user has been denied access to the requested resource.
1908      * @throws KMSDisabledException
1909      *         The request was rejected because the specified customer master key (CMK) isn't enabled.
1910      * @throws KMSInvalidStateException
1911      *         The request was rejected because the state of the specified resource isn't valid for this request. For
1912      *         more information, see <a href="https://docs.aws.amazon.com/kms/latest/developerguide/key-state.html">How
1913      *         Key State Affects Use of a Customer Master Key</a> in the <i>AWS Key Management Service Developer
1914      *         Guide</i>.
1915      * @throws KMSNotFoundException
1916      *         The request was rejected because the specified entity or resource can't be found.
1917      * @throws KMSOptInRequiredException
1918      *         The AWS access key ID needs a subscription for the service.
1919      * @throws KMSThrottlingException
1920      *         The request was denied due to request throttling. For more information about throttling, see <a
1921      *         href="https://docs.aws.amazon.com/kms/latest/developerguide/limits.html#requests-per-second">Limits</a>
1922      *         in the <i>AWS Key Management Service Developer Guide.</i>
1923      * @throws KMSAccessDeniedException
1924      *         The ciphertext references a key that doesn't exist or that you don't have access to.
1925      * @throws InvalidSecurityException
1926      *         The credential signature isn't valid. You must use an HTTPS endpoint and sign your request using
1927      *         Signature Version 4.
1928      * @sample AmazonSNS.Publish
1929      * @see <a href="http://docs.aws.amazon.com/goto/WebAPI/sns-2010-03-31/Publish" target="_top">AWS API
1930      *      Documentation</a>
1931      */

1932     @Override
1933     public PublishResult publish(PublishRequest request) {
1934         request = beforeClientExecution(request);
1935         return executePublish(request);
1936     }
1937
1938     @SdkInternalApi
1939     final PublishResult executePublish(PublishRequest publishRequest) {
1940
1941         ExecutionContext executionContext = createExecutionContext(publishRequest);
1942         AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
1943         awsRequestMetrics.startEvent(Field.ClientExecuteTime);
1944         Request<PublishRequest> request = null;
1945         Response<PublishResult> response = null;
1946
1947         try {
1948             awsRequestMetrics.startEvent(Field.RequestMarshallTime);
1949             try {
1950                 request = new PublishRequestMarshaller().marshall(super.beforeMarshalling(publishRequest));
1951                 // Binds the request metrics to the current request.
1952                 request.setAWSRequestMetrics(awsRequestMetrics);
1953                 request.addHandlerContext(HandlerContextKey.SIGNING_REGION, getSigningRegion());
1954                 request.addHandlerContext(HandlerContextKey.SERVICE_ID, "SNS");
1955                 request.addHandlerContext(HandlerContextKey.OPERATION_NAME, "Publish");
1956                 request.addHandlerContext(HandlerContextKey.ADVANCED_CONFIG, advancedConfig);
1957
1958             } finally {
1959                 awsRequestMetrics.endEvent(Field.RequestMarshallTime);
1960             }
1961
1962             StaxResponseHandler<PublishResult> responseHandler = new StaxResponseHandler<PublishResult>(new PublishResultStaxUnmarshaller());
1963             response = invoke(request, responseHandler, executionContext);
1964
1965             return response.getAwsResponse();
1966
1967         } finally {
1968
1969             endClientExecution(awsRequestMetrics, request, response);
1970         }
1971     }
1972
1973     @Override
1974     public PublishResult publish(String topicArn, String message) {
1975         return publish(new PublishRequest().withTopicArn(topicArn).withMessage(message));
1976     }
1977
1978     @Override
1979     public PublishResult publish(String topicArn, String message, String subject) {
1980         return publish(new PublishRequest().withTopicArn(topicArn).withMessage(message).withSubject(subject));
1981     }
1982
1983     /**
1984      * <p>
1985      * Removes a statement from a topic's access control policy.
1986      * </p>
1987      * 
1988      * @param removePermissionRequest
1989      *        Input for RemovePermission action.
1990      * @return Result of the RemovePermission operation returned by the service.
1991      * @throws InvalidParameterException
1992      *         Indicates that a request parameter does not comply with the associated constraints.
1993      * @throws InternalErrorException
1994      *         Indicates an internal service error.
1995      * @throws AuthorizationErrorException
1996      *         Indicates that the user has been denied access to the requested resource.
1997      * @throws NotFoundException
1998      *         Indicates that the requested resource does not exist.
1999      * @sample AmazonSNS.RemovePermission
2000      * @see <a href="http://docs.aws.amazon.com/goto/WebAPI/sns-2010-03-31/RemovePermission" target="_top">AWS API
2001      *      Documentation</a>
2002      */

2003     @Override
2004     public RemovePermissionResult removePermission(RemovePermissionRequest request) {
2005         request = beforeClientExecution(request);
2006         return executeRemovePermission(request);
2007     }
2008
2009     @SdkInternalApi
2010     final RemovePermissionResult executeRemovePermission(RemovePermissionRequest removePermissionRequest) {
2011
2012         ExecutionContext executionContext = createExecutionContext(removePermissionRequest);
2013         AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
2014         awsRequestMetrics.startEvent(Field.ClientExecuteTime);
2015         Request<RemovePermissionRequest> request = null;
2016         Response<RemovePermissionResult> response = null;
2017
2018         try {
2019             awsRequestMetrics.startEvent(Field.RequestMarshallTime);
2020             try {
2021                 request = new RemovePermissionRequestMarshaller().marshall(super.beforeMarshalling(removePermissionRequest));
2022                 // Binds the request metrics to the current request.
2023                 request.setAWSRequestMetrics(awsRequestMetrics);
2024                 request.addHandlerContext(HandlerContextKey.SIGNING_REGION, getSigningRegion());
2025                 request.addHandlerContext(HandlerContextKey.SERVICE_ID, "SNS");
2026                 request.addHandlerContext(HandlerContextKey.OPERATION_NAME, "RemovePermission");
2027                 request.addHandlerContext(HandlerContextKey.ADVANCED_CONFIG, advancedConfig);
2028
2029             } finally {
2030                 awsRequestMetrics.endEvent(Field.RequestMarshallTime);
2031             }
2032
2033             StaxResponseHandler<RemovePermissionResult> responseHandler = new StaxResponseHandler<RemovePermissionResult>(
2034                     new RemovePermissionResultStaxUnmarshaller());
2035             response = invoke(request, responseHandler, executionContext);
2036
2037             return response.getAwsResponse();
2038
2039         } finally {
2040
2041             endClientExecution(awsRequestMetrics, request, response);
2042         }
2043     }
2044
2045     @Override
2046     public RemovePermissionResult removePermission(String topicArn, String label) {
2047         return removePermission(new RemovePermissionRequest().withTopicArn(topicArn).withLabel(label));
2048     }
2049
2050     /**
2051      * <p>
2052      * Sets the attributes for an endpoint for a device on one of the supported push notification services, such as FCM
2053      * and APNS. For more information, see <a href="https://docs.aws.amazon.com/sns/latest/dg/SNSMobilePush.html">Using
2054      * Amazon SNS Mobile Push Notifications</a>.
2055      * </p>
2056      * 
2057      * @param setEndpointAttributesRequest
2058      *        Input for SetEndpointAttributes action.
2059      * @return Result of the SetEndpointAttributes operation returned by the service.
2060      * @throws InvalidParameterException
2061      *         Indicates that a request parameter does not comply with the associated constraints.
2062      * @throws InternalErrorException
2063      *         Indicates an internal service error.
2064      * @throws AuthorizationErrorException
2065      *         Indicates that the user has been denied access to the requested resource.
2066      * @throws NotFoundException
2067      *         Indicates that the requested resource does not exist.
2068      * @sample AmazonSNS.SetEndpointAttributes
2069      * @see <a href="http://docs.aws.amazon.com/goto/WebAPI/sns-2010-03-31/SetEndpointAttributes" target="_top">AWS API
2070      *      Documentation</a>
2071      */

2072     @Override
2073     public SetEndpointAttributesResult setEndpointAttributes(SetEndpointAttributesRequest request) {
2074         request = beforeClientExecution(request);
2075         return executeSetEndpointAttributes(request);
2076     }
2077
2078     @SdkInternalApi
2079     final SetEndpointAttributesResult executeSetEndpointAttributes(SetEndpointAttributesRequest setEndpointAttributesRequest) {
2080
2081         ExecutionContext executionContext = createExecutionContext(setEndpointAttributesRequest);
2082         AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
2083         awsRequestMetrics.startEvent(Field.ClientExecuteTime);
2084         Request<SetEndpointAttributesRequest> request = null;
2085         Response<SetEndpointAttributesResult> response = null;
2086
2087         try {
2088             awsRequestMetrics.startEvent(Field.RequestMarshallTime);
2089             try {
2090                 request = new SetEndpointAttributesRequestMarshaller().marshall(super.beforeMarshalling(setEndpointAttributesRequest));
2091                 // Binds the request metrics to the current request.
2092                 request.setAWSRequestMetrics(awsRequestMetrics);
2093                 request.addHandlerContext(HandlerContextKey.SIGNING_REGION, getSigningRegion());
2094                 request.addHandlerContext(HandlerContextKey.SERVICE_ID, "SNS");
2095                 request.addHandlerContext(HandlerContextKey.OPERATION_NAME, "SetEndpointAttributes");
2096                 request.addHandlerContext(HandlerContextKey.ADVANCED_CONFIG, advancedConfig);
2097
2098             } finally {
2099                 awsRequestMetrics.endEvent(Field.RequestMarshallTime);
2100             }
2101
2102             StaxResponseHandler<SetEndpointAttributesResult> responseHandler = new StaxResponseHandler<SetEndpointAttributesResult>(
2103                     new SetEndpointAttributesResultStaxUnmarshaller());
2104             response = invoke(request, responseHandler, executionContext);
2105
2106             return response.getAwsResponse();
2107
2108         } finally {
2109
2110             endClientExecution(awsRequestMetrics, request, response);
2111         }
2112     }
2113
2114     /**
2115      * <p>
2116      * Sets the attributes of the platform application object for the supported push notification services, such as APNS
2117      * and FCM. For more information, see <a href="https://docs.aws.amazon.com/sns/latest/dg/SNSMobilePush.html">Using
2118      * Amazon SNS Mobile Push Notifications</a>. For information on configuring attributes for message delivery status,
2119      * see <a href="https://docs.aws.amazon.com/sns/latest/dg/sns-msg-status.html">Using Amazon SNS Application
2120      * Attributes for Message Delivery Status</a>.
2121      * </p>
2122      * 
2123      * @param setPlatformApplicationAttributesRequest
2124      *        Input for SetPlatformApplicationAttributes action.
2125      * @return Result of the SetPlatformApplicationAttributes operation returned by the service.
2126      * @throws InvalidParameterException
2127      *         Indicates that a request parameter does not comply with the associated constraints.
2128      * @throws InternalErrorException
2129      *         Indicates an internal service error.
2130      * @throws AuthorizationErrorException
2131      *         Indicates that the user has been denied access to the requested resource.
2132      * @throws NotFoundException
2133      *         Indicates that the requested resource does not exist.
2134      * @sample AmazonSNS.SetPlatformApplicationAttributes
2135      * @see <a href="http://docs.aws.amazon.com/goto/WebAPI/sns-2010-03-31/SetPlatformApplicationAttributes"
2136      *      target="_top">AWS API Documentation</a>
2137      */

2138     @Override
2139     public SetPlatformApplicationAttributesResult setPlatformApplicationAttributes(SetPlatformApplicationAttributesRequest request) {
2140         request = beforeClientExecution(request);
2141         return executeSetPlatformApplicationAttributes(request);
2142     }
2143
2144     @SdkInternalApi
2145     final SetPlatformApplicationAttributesResult executeSetPlatformApplicationAttributes(
2146             SetPlatformApplicationAttributesRequest setPlatformApplicationAttributesRequest) {
2147
2148         ExecutionContext executionContext = createExecutionContext(setPlatformApplicationAttributesRequest);
2149         AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
2150         awsRequestMetrics.startEvent(Field.ClientExecuteTime);
2151         Request<SetPlatformApplicationAttributesRequest> request = null;
2152         Response<SetPlatformApplicationAttributesResult> response = null;
2153
2154         try {
2155             awsRequestMetrics.startEvent(Field.RequestMarshallTime);
2156             try {
2157                 request = new SetPlatformApplicationAttributesRequestMarshaller().marshall(super.beforeMarshalling(setPlatformApplicationAttributesRequest));
2158                 // Binds the request metrics to the current request.
2159                 request.setAWSRequestMetrics(awsRequestMetrics);
2160                 request.addHandlerContext(HandlerContextKey.SIGNING_REGION, getSigningRegion());
2161                 request.addHandlerContext(HandlerContextKey.SERVICE_ID, "SNS");
2162                 request.addHandlerContext(HandlerContextKey.OPERATION_NAME, "SetPlatformApplicationAttributes");
2163                 request.addHandlerContext(HandlerContextKey.ADVANCED_CONFIG, advancedConfig);
2164
2165             } finally {
2166                 awsRequestMetrics.endEvent(Field.RequestMarshallTime);
2167             }
2168
2169             StaxResponseHandler<SetPlatformApplicationAttributesResult> responseHandler = new StaxResponseHandler<SetPlatformApplicationAttributesResult>(
2170                     new SetPlatformApplicationAttributesResultStaxUnmarshaller());
2171             response = invoke(request, responseHandler, executionContext);
2172
2173             return response.getAwsResponse();
2174
2175         } finally {
2176
2177             endClientExecution(awsRequestMetrics, request, response);
2178         }
2179     }
2180
2181     /**
2182      * <p>
2183      * Use this request to set the default settings for sending SMS messages and receiving daily SMS usage reports.
2184      * </p>
2185      * <p>
2186      * You can override some of these settings for a single message when you use the <code>Publish</code> action with
2187      * the <code>MessageAttributes.entry.N</code> parameter. For more information, see <a
2188      * href="https://docs.aws.amazon.com/sns/latest/dg/sms_publish-to-phone.html">Sending an SMS Message</a> in the
2189      * <i>Amazon SNS Developer Guide</i>.
2190      * </p>
2191      * 
2192      * @param setSMSAttributesRequest
2193      *        The input for the SetSMSAttributes action.
2194      * @return Result of the SetSMSAttributes operation returned by the service.
2195      * @throws InvalidParameterException
2196      *         Indicates that a request parameter does not comply with the associated constraints.
2197      * @throws ThrottledException
2198      *         Indicates that the rate at which requests have been submitted for this action exceeds the limit for your
2199      *         account.
2200      * @throws InternalErrorException
2201      *         Indicates an internal service error.
2202      * @throws AuthorizationErrorException
2203      *         Indicates that the user has been denied access to the requested resource.
2204      * @sample AmazonSNS.SetSMSAttributes
2205      * @see <a href="http://docs.aws.amazon.com/goto/WebAPI/sns-2010-03-31/SetSMSAttributes" target="_top">AWS API
2206      *      Documentation</a>
2207      */

2208     @Override
2209     public SetSMSAttributesResult setSMSAttributes(SetSMSAttributesRequest request) {
2210         request = beforeClientExecution(request);
2211         return executeSetSMSAttributes(request);
2212     }
2213
2214     @SdkInternalApi
2215     final SetSMSAttributesResult executeSetSMSAttributes(SetSMSAttributesRequest setSMSAttributesRequest) {
2216
2217         ExecutionContext executionContext = createExecutionContext(setSMSAttributesRequest);
2218         AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
2219         awsRequestMetrics.startEvent(Field.ClientExecuteTime);
2220         Request<SetSMSAttributesRequest> request = null;
2221         Response<SetSMSAttributesResult> response = null;
2222
2223         try {
2224             awsRequestMetrics.startEvent(Field.RequestMarshallTime);
2225             try {
2226                 request = new SetSMSAttributesRequestMarshaller().marshall(super.beforeMarshalling(setSMSAttributesRequest));
2227                 // Binds the request metrics to the current request.
2228                 request.setAWSRequestMetrics(awsRequestMetrics);
2229                 request.addHandlerContext(HandlerContextKey.SIGNING_REGION, getSigningRegion());
2230                 request.addHandlerContext(HandlerContextKey.SERVICE_ID, "SNS");
2231                 request.addHandlerContext(HandlerContextKey.OPERATION_NAME, "SetSMSAttributes");
2232                 request.addHandlerContext(HandlerContextKey.ADVANCED_CONFIG, advancedConfig);
2233
2234             } finally {
2235                 awsRequestMetrics.endEvent(Field.RequestMarshallTime);
2236             }
2237
2238             StaxResponseHandler<SetSMSAttributesResult> responseHandler = new StaxResponseHandler<SetSMSAttributesResult>(
2239                     new SetSMSAttributesResultStaxUnmarshaller());
2240             response = invoke(request, responseHandler, executionContext);
2241
2242             return response.getAwsResponse();
2243
2244         } finally {
2245
2246             endClientExecution(awsRequestMetrics, request, response);
2247         }
2248     }
2249
2250     /**
2251      * <p>
2252      * Allows a subscription owner to set an attribute of the subscription to a new value.
2253      * </p>
2254      * 
2255      * @param setSubscriptionAttributesRequest
2256      *        Input for SetSubscriptionAttributes action.
2257      * @return Result of the SetSubscriptionAttributes operation returned by the service.
2258      * @throws InvalidParameterException
2259      *         Indicates that a request parameter does not comply with the associated constraints.
2260      * @throws FilterPolicyLimitExceededException
2261      *         Indicates that the number of filter polices in your AWS account exceeds the limit. To add more filter
2262      *         polices, submit an SNS Limit Increase case in the AWS Support Center.
2263      * @throws InternalErrorException
2264      *         Indicates an internal service error.
2265      * @throws NotFoundException
2266      *         Indicates that the requested resource does not exist.
2267      * @throws AuthorizationErrorException
2268      *         Indicates that the user has been denied access to the requested resource.
2269      * @sample AmazonSNS.SetSubscriptionAttributes
2270      * @see <a href="http://docs.aws.amazon.com/goto/WebAPI/sns-2010-03-31/SetSubscriptionAttributes" target="_top">AWS
2271      *      API Documentation</a>
2272      */

2273     @Override
2274     public SetSubscriptionAttributesResult setSubscriptionAttributes(SetSubscriptionAttributesRequest request) {
2275         request = beforeClientExecution(request);
2276         return executeSetSubscriptionAttributes(request);
2277     }
2278
2279     @SdkInternalApi
2280     final SetSubscriptionAttributesResult executeSetSubscriptionAttributes(SetSubscriptionAttributesRequest setSubscriptionAttributesRequest) {
2281
2282         ExecutionContext executionContext = createExecutionContext(setSubscriptionAttributesRequest);
2283         AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
2284         awsRequestMetrics.startEvent(Field.ClientExecuteTime);
2285         Request<SetSubscriptionAttributesRequest> request = null;
2286         Response<SetSubscriptionAttributesResult> response = null;
2287
2288         try {
2289             awsRequestMetrics.startEvent(Field.RequestMarshallTime);
2290             try {
2291                 request = new SetSubscriptionAttributesRequestMarshaller().marshall(super.beforeMarshalling(setSubscriptionAttributesRequest));
2292                 // Binds the request metrics to the current request.
2293                 request.setAWSRequestMetrics(awsRequestMetrics);
2294                 request.addHandlerContext(HandlerContextKey.SIGNING_REGION, getSigningRegion());
2295                 request.addHandlerContext(HandlerContextKey.SERVICE_ID, "SNS");
2296                 request.addHandlerContext(HandlerContextKey.OPERATION_NAME, "SetSubscriptionAttributes");
2297                 request.addHandlerContext(HandlerContextKey.ADVANCED_CONFIG, advancedConfig);
2298
2299             } finally {
2300                 awsRequestMetrics.endEvent(Field.RequestMarshallTime);
2301             }
2302
2303             StaxResponseHandler<SetSubscriptionAttributesResult> responseHandler = new StaxResponseHandler<SetSubscriptionAttributesResult>(
2304                     new SetSubscriptionAttributesResultStaxUnmarshaller());
2305             response = invoke(request, responseHandler, executionContext);
2306
2307             return response.getAwsResponse();
2308
2309         } finally {
2310
2311             endClientExecution(awsRequestMetrics, request, response);
2312         }
2313     }
2314
2315     @Override
2316     public SetSubscriptionAttributesResult setSubscriptionAttributes(String subscriptionArn, String attributeName, String attributeValue) {
2317         return setSubscriptionAttributes(new SetSubscriptionAttributesRequest().withSubscriptionArn(subscriptionArn).withAttributeName(attributeName)
2318                 .withAttributeValue(attributeValue));
2319     }
2320
2321     /**
2322      * <p>
2323      * Allows a topic owner to set an attribute of the topic to a new value.
2324      * </p>
2325      * 
2326      * @param setTopicAttributesRequest
2327      *        Input for SetTopicAttributes action.
2328      * @return Result of the SetTopicAttributes operation returned by the service.
2329      * @throws InvalidParameterException
2330      *         Indicates that a request parameter does not comply with the associated constraints.
2331      * @throws InternalErrorException
2332      *         Indicates an internal service error.
2333      * @throws NotFoundException
2334      *         Indicates that the requested resource does not exist.
2335      * @throws AuthorizationErrorException
2336      *         Indicates that the user has been denied access to the requested resource.
2337      * @throws InvalidSecurityException
2338      *         The credential signature isn't valid. You must use an HTTPS endpoint and sign your request using
2339      *         Signature Version 4.
2340      * @sample AmazonSNS.SetTopicAttributes
2341      * @see <a href="http://docs.aws.amazon.com/goto/WebAPI/sns-2010-03-31/SetTopicAttributes" target="_top">AWS API
2342      *      Documentation</a>
2343      */

2344     @Override
2345     public SetTopicAttributesResult setTopicAttributes(SetTopicAttributesRequest request) {
2346         request = beforeClientExecution(request);
2347         return executeSetTopicAttributes(request);
2348     }
2349
2350     @SdkInternalApi
2351     final SetTopicAttributesResult executeSetTopicAttributes(SetTopicAttributesRequest setTopicAttributesRequest) {
2352
2353         ExecutionContext executionContext = createExecutionContext(setTopicAttributesRequest);
2354         AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
2355         awsRequestMetrics.startEvent(Field.ClientExecuteTime);
2356         Request<SetTopicAttributesRequest> request = null;
2357         Response<SetTopicAttributesResult> response = null;
2358
2359         try {
2360             awsRequestMetrics.startEvent(Field.RequestMarshallTime);
2361             try {
2362                 request = new SetTopicAttributesRequestMarshaller().marshall(super.beforeMarshalling(setTopicAttributesRequest));
2363                 // Binds the request metrics to the current request.
2364                 request.setAWSRequestMetrics(awsRequestMetrics);
2365                 request.addHandlerContext(HandlerContextKey.SIGNING_REGION, getSigningRegion());
2366                 request.addHandlerContext(HandlerContextKey.SERVICE_ID, "SNS");
2367                 request.addHandlerContext(HandlerContextKey.OPERATION_NAME, "SetTopicAttributes");
2368                 request.addHandlerContext(HandlerContextKey.ADVANCED_CONFIG, advancedConfig);
2369
2370             } finally {
2371                 awsRequestMetrics.endEvent(Field.RequestMarshallTime);
2372             }
2373
2374             StaxResponseHandler<SetTopicAttributesResult> responseHandler = new StaxResponseHandler<SetTopicAttributesResult>(
2375                     new SetTopicAttributesResultStaxUnmarshaller());
2376             response = invoke(request, responseHandler, executionContext);
2377
2378             return response.getAwsResponse();
2379
2380         } finally {
2381
2382             endClientExecution(awsRequestMetrics, request, response);
2383         }
2384     }
2385
2386     @Override
2387     public SetTopicAttributesResult setTopicAttributes(String topicArn, String attributeName, String attributeValue) {
2388         return setTopicAttributes(new SetTopicAttributesRequest().withTopicArn(topicArn).withAttributeName(attributeName).withAttributeValue(attributeValue));
2389     }
2390
2391     /**
2392      * <p>
2393      * Prepares to subscribe an endpoint by sending the endpoint a confirmation message. To actually create a
2394      * subscription, the endpoint owner must call the <code>ConfirmSubscription</code> action with the token from the
2395      * confirmation message. Confirmation tokens are valid for three days.
2396      * </p>
2397      * <p>
2398      * This action is throttled at 100 transactions per second (TPS).
2399      * </p>
2400      * 
2401      * @param subscribeRequest
2402      *        Input for Subscribe action.
2403      * @return Result of the Subscribe operation returned by the service.
2404      * @throws SubscriptionLimitExceededException
2405      *         Indicates that the customer already owns the maximum allowed number of subscriptions.
2406      * @throws FilterPolicyLimitExceededException
2407      *         Indicates that the number of filter polices in your AWS account exceeds the limit. To add more filter
2408      *         polices, submit an SNS Limit Increase case in the AWS Support Center.
2409      * @throws InvalidParameterException
2410      *         Indicates that a request parameter does not comply with the associated constraints.
2411      * @throws InternalErrorException
2412      *         Indicates an internal service error.
2413      * @throws NotFoundException
2414      *         Indicates that the requested resource does not exist.
2415      * @throws AuthorizationErrorException
2416      *         Indicates that the user has been denied access to the requested resource.
2417      * @throws InvalidSecurityException
2418      *         The credential signature isn't valid. You must use an HTTPS endpoint and sign your request using
2419      *         Signature Version 4.
2420      * @sample AmazonSNS.Subscribe
2421      * @see <a href="http://docs.aws.amazon.com/goto/WebAPI/sns-2010-03-31/Subscribe" target="_top">AWS API
2422      *      Documentation</a>
2423      */

2424     @Override
2425     public SubscribeResult subscribe(SubscribeRequest request) {
2426         request = beforeClientExecution(request);
2427         return executeSubscribe(request);
2428     }
2429
2430     @SdkInternalApi
2431     final SubscribeResult executeSubscribe(SubscribeRequest subscribeRequest) {
2432
2433         ExecutionContext executionContext = createExecutionContext(subscribeRequest);
2434         AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
2435         awsRequestMetrics.startEvent(Field.ClientExecuteTime);
2436         Request<SubscribeRequest> request = null;
2437         Response<SubscribeResult> response = null;
2438
2439         try {
2440             awsRequestMetrics.startEvent(Field.RequestMarshallTime);
2441             try {
2442                 request = new SubscribeRequestMarshaller().marshall(super.beforeMarshalling(subscribeRequest));
2443                 // Binds the request metrics to the current request.
2444                 request.setAWSRequestMetrics(awsRequestMetrics);
2445                 request.addHandlerContext(HandlerContextKey.SIGNING_REGION, getSigningRegion());
2446                 request.addHandlerContext(HandlerContextKey.SERVICE_ID, "SNS");
2447                 request.addHandlerContext(HandlerContextKey.OPERATION_NAME, "Subscribe");
2448                 request.addHandlerContext(HandlerContextKey.ADVANCED_CONFIG, advancedConfig);
2449
2450             } finally {
2451                 awsRequestMetrics.endEvent(Field.RequestMarshallTime);
2452             }
2453
2454             StaxResponseHandler<SubscribeResult> responseHandler = new StaxResponseHandler<SubscribeResult>(new SubscribeResultStaxUnmarshaller());
2455             response = invoke(request, responseHandler, executionContext);
2456
2457             return response.getAwsResponse();
2458
2459         } finally {
2460
2461             endClientExecution(awsRequestMetrics, request, response);
2462         }
2463     }
2464
2465     @Override
2466     public SubscribeResult subscribe(String topicArn, String protocol, String endpoint) {
2467         return subscribe(new SubscribeRequest().withTopicArn(topicArn).withProtocol(protocol).withEndpoint(endpoint));
2468     }
2469
2470     /**
2471      * <p>
2472      * Add tags to the specified Amazon SNS topic. For an overview, see <a
2473      * href="https://docs.aws.amazon.com/sns/latest/dg/sns-tags.html">Amazon SNS Tags</a> in the <i>Amazon SNS Developer
2474      * Guide</i>.
2475      * </p>
2476      * <p>
2477      * When you use topic tags, keep the following guidelines in mind:
2478      * </p>
2479      * <ul>
2480      * <li>
2481      * <p>
2482      * Adding more than 50 tags to a topic isn't recommended.
2483      * </p>
2484      * </li>
2485      * <li>
2486      * <p>
2487      * Tags don't have any semantic meaning. Amazon SNS interprets tags as character strings.
2488      * </p>
2489      * </li>
2490      * <li>
2491      * <p>
2492      * Tags are case-sensitive.
2493      * </p>
2494      * </li>
2495      * <li>
2496      * <p>
2497      * A new tag with a key identical to that of an existing tag overwrites the existing tag.
2498      * </p>
2499      * </li>
2500      * <li>
2501      * <p>
2502      * Tagging actions are limited to 10 TPS per AWS account, per AWS region. If your application requires a higher
2503      * throughput, file a <a
2504      * href="https://console.aws.amazon.com/support/home#/case/create?issueType=technical">technical support
2505      * request</a>.
2506      * </p>
2507      * </li>
2508      * </ul>
2509      * 
2510      * @param tagResourceRequest
2511      * @return Result of the TagResource operation returned by the service.
2512      * @throws ResourceNotFoundException
2513      *         Can't tag resource. Verify that the topic exists.
2514      * @throws TagLimitExceededException
2515      *         Can't add more than 50 tags to a topic.
2516      * @throws StaleTagException
2517      *         A tag has been added to a resource with the same ARN as a deleted resource. Wait a short while and then
2518      *         retry the operation.
2519      * @throws TagPolicyException
2520      *         The request doesn't comply with the IAM tag policy. Correct your request and then retry it.
2521      * @throws InvalidParameterException
2522      *         Indicates that a request parameter does not comply with the associated constraints.
2523      * @throws AuthorizationErrorException
2524      *         Indicates that the user has been denied access to the requested resource.
2525      * @throws ConcurrentAccessException
2526      *         Can't perform multiple operations on a tag simultaneously. Perform the operations sequentially.
2527      * @sample AmazonSNS.TagResource
2528      * @see <a href="http://docs.aws.amazon.com/goto/WebAPI/sns-2010-03-31/TagResource" target="_top">AWS API
2529      *      Documentation</a>
2530      */

2531     @Override
2532     public TagResourceResult tagResource(TagResourceRequest request) {
2533         request = beforeClientExecution(request);
2534         return executeTagResource(request);
2535     }
2536
2537     @SdkInternalApi
2538     final TagResourceResult executeTagResource(TagResourceRequest tagResourceRequest) {
2539
2540         ExecutionContext executionContext = createExecutionContext(tagResourceRequest);
2541         AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
2542         awsRequestMetrics.startEvent(Field.ClientExecuteTime);
2543         Request<TagResourceRequest> request = null;
2544         Response<TagResourceResult> response = null;
2545
2546         try {
2547             awsRequestMetrics.startEvent(Field.RequestMarshallTime);
2548             try {
2549                 request = new TagResourceRequestMarshaller().marshall(super.beforeMarshalling(tagResourceRequest));
2550                 // Binds the request metrics to the current request.
2551                 request.setAWSRequestMetrics(awsRequestMetrics);
2552                 request.addHandlerContext(HandlerContextKey.SIGNING_REGION, getSigningRegion());
2553                 request.addHandlerContext(HandlerContextKey.SERVICE_ID, "SNS");
2554                 request.addHandlerContext(HandlerContextKey.OPERATION_NAME, "TagResource");
2555                 request.addHandlerContext(HandlerContextKey.ADVANCED_CONFIG, advancedConfig);
2556
2557             } finally {
2558                 awsRequestMetrics.endEvent(Field.RequestMarshallTime);
2559             }
2560
2561             StaxResponseHandler<TagResourceResult> responseHandler = new StaxResponseHandler<TagResourceResult>(new TagResourceResultStaxUnmarshaller());
2562             response = invoke(request, responseHandler, executionContext);
2563
2564             return response.getAwsResponse();
2565
2566         } finally {
2567
2568             endClientExecution(awsRequestMetrics, request, response);
2569         }
2570     }
2571
2572     /**
2573      * <p>
2574      * Deletes a subscription. If the subscription requires authentication for deletion, only the owner of the
2575      * subscription or the topic's owner can unsubscribe, and an AWS signature is required. If the
2576      * <code>Unsubscribe</code> call does not require authentication and the requester is not the subscription owner, a
2577      * final cancellation message is delivered to the endpoint, so that the endpoint owner can easily resubscribe to the
2578      * topic if the <code>Unsubscribe</code> request was unintended.
2579      * </p>
2580      * <p>
2581      * This action is throttled at 100 transactions per second (TPS).
2582      * </p>
2583      * 
2584      * @param unsubscribeRequest
2585      *        Input for Unsubscribe action.
2586      * @return Result of the Unsubscribe operation returned by the service.
2587      * @throws InvalidParameterException
2588      *         Indicates that a request parameter does not comply with the associated constraints.
2589      * @throws InternalErrorException
2590      *         Indicates an internal service error.
2591      * @throws AuthorizationErrorException
2592      *         Indicates that the user has been denied access to the requested resource.
2593      * @throws NotFoundException
2594      *         Indicates that the requested resource does not exist.
2595      * @throws InvalidSecurityException
2596      *         The credential signature isn't valid. You must use an HTTPS endpoint and sign your request using
2597      *         Signature Version 4.
2598      * @sample AmazonSNS.Unsubscribe
2599      * @see <a href="http://docs.aws.amazon.com/goto/WebAPI/sns-2010-03-31/Unsubscribe" target="_top">AWS API
2600      *      Documentation</a>
2601      */

2602     @Override
2603     public UnsubscribeResult unsubscribe(UnsubscribeRequest request) {
2604         request = beforeClientExecution(request);
2605         return executeUnsubscribe(request);
2606     }
2607
2608     @SdkInternalApi
2609     final UnsubscribeResult executeUnsubscribe(UnsubscribeRequest unsubscribeRequest) {
2610
2611         ExecutionContext executionContext = createExecutionContext(unsubscribeRequest);
2612         AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
2613         awsRequestMetrics.startEvent(Field.ClientExecuteTime);
2614         Request<UnsubscribeRequest> request = null;
2615         Response<UnsubscribeResult> response = null;
2616
2617         try {
2618             awsRequestMetrics.startEvent(Field.RequestMarshallTime);
2619             try {
2620                 request = new UnsubscribeRequestMarshaller().marshall(super.beforeMarshalling(unsubscribeRequest));
2621                 // Binds the request metrics to the current request.
2622                 request.setAWSRequestMetrics(awsRequestMetrics);
2623                 request.addHandlerContext(HandlerContextKey.SIGNING_REGION, getSigningRegion());
2624                 request.addHandlerContext(HandlerContextKey.SERVICE_ID, "SNS");
2625                 request.addHandlerContext(HandlerContextKey.OPERATION_NAME, "Unsubscribe");
2626                 request.addHandlerContext(HandlerContextKey.ADVANCED_CONFIG, advancedConfig);
2627
2628             } finally {
2629                 awsRequestMetrics.endEvent(Field.RequestMarshallTime);
2630             }
2631
2632             StaxResponseHandler<UnsubscribeResult> responseHandler = new StaxResponseHandler<UnsubscribeResult>(new UnsubscribeResultStaxUnmarshaller());
2633             response = invoke(request, responseHandler, executionContext);
2634
2635             return response.getAwsResponse();
2636
2637         } finally {
2638
2639             endClientExecution(awsRequestMetrics, request, response);
2640         }
2641     }
2642
2643     @Override
2644     public UnsubscribeResult unsubscribe(String subscriptionArn) {
2645         return unsubscribe(new UnsubscribeRequest().withSubscriptionArn(subscriptionArn));
2646     }
2647
2648     /**
2649      * <p>
2650      * Remove tags from the specified Amazon SNS topic. For an overview, see <a
2651      * href="https://docs.aws.amazon.com/sns/latest/dg/sns-tags.html">Amazon SNS Tags</a> in the <i>Amazon SNS Developer
2652      * Guide</i>.
2653      * </p>
2654      * 
2655      * @param untagResourceRequest
2656      * @return Result of the UntagResource operation returned by the service.
2657      * @throws ResourceNotFoundException
2658      *         Can't tag resource. Verify that the topic exists.
2659      * @throws TagLimitExceededException
2660      *         Can't add more than 50 tags to a topic.
2661      * @throws StaleTagException
2662      *         A tag has been added to a resource with the same ARN as a deleted resource. Wait a short while and then
2663      *         retry the operation.
2664      * @throws TagPolicyException
2665      *         The request doesn't comply with the IAM tag policy. Correct your request and then retry it.
2666      * @throws InvalidParameterException
2667      *         Indicates that a request parameter does not comply with the associated constraints.
2668      * @throws AuthorizationErrorException
2669      *         Indicates that the user has been denied access to the requested resource.
2670      * @throws ConcurrentAccessException
2671      *         Can't perform multiple operations on a tag simultaneously. Perform the operations sequentially.
2672      * @sample AmazonSNS.UntagResource
2673      * @see <a href="http://docs.aws.amazon.com/goto/WebAPI/sns-2010-03-31/UntagResource" target="_top">AWS API
2674      *      Documentation</a>
2675      */

2676     @Override
2677     public UntagResourceResult untagResource(UntagResourceRequest request) {
2678         request = beforeClientExecution(request);
2679         return executeUntagResource(request);
2680     }
2681
2682     @SdkInternalApi
2683     final UntagResourceResult executeUntagResource(UntagResourceRequest untagResourceRequest) {
2684
2685         ExecutionContext executionContext = createExecutionContext(untagResourceRequest);
2686         AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
2687         awsRequestMetrics.startEvent(Field.ClientExecuteTime);
2688         Request<UntagResourceRequest> request = null;
2689         Response<UntagResourceResult> response = null;
2690
2691         try {
2692             awsRequestMetrics.startEvent(Field.RequestMarshallTime);
2693             try {
2694                 request = new UntagResourceRequestMarshaller().marshall(super.beforeMarshalling(untagResourceRequest));
2695                 // Binds the request metrics to the current request.
2696                 request.setAWSRequestMetrics(awsRequestMetrics);
2697                 request.addHandlerContext(HandlerContextKey.SIGNING_REGION, getSigningRegion());
2698                 request.addHandlerContext(HandlerContextKey.SERVICE_ID, "SNS");
2699                 request.addHandlerContext(HandlerContextKey.OPERATION_NAME, "UntagResource");
2700                 request.addHandlerContext(HandlerContextKey.ADVANCED_CONFIG, advancedConfig);
2701
2702             } finally {
2703                 awsRequestMetrics.endEvent(Field.RequestMarshallTime);
2704             }
2705
2706             StaxResponseHandler<UntagResourceResult> responseHandler = new StaxResponseHandler<UntagResourceResult>(new UntagResourceResultStaxUnmarshaller());
2707             response = invoke(request, responseHandler, executionContext);
2708
2709             return response.getAwsResponse();
2710
2711         } finally {
2712
2713             endClientExecution(awsRequestMetrics, request, response);
2714         }
2715     }
2716
2717     /**
2718      * Returns additional metadata for a previously executed successful, request, typically used for debugging issues
2719      * where a service isn't acting as expected. This data isn't considered part of the result data returned by an
2720      * operation, so it's available through this separate, diagnostic interface.
2721      * <p>
2722      * Response metadata is only cached for a limited period of time, so if you need to access this extra diagnostic
2723      * information for an executed request, you should use this method to retrieve it as soon as possible after
2724      * executing the request.
2725      *
2726      * @param request
2727      *        The originally executed request
2728      *
2729      * @return The response metadata for the specified request, or null if none is available.
2730      */

2731     public ResponseMetadata getCachedResponseMetadata(AmazonWebServiceRequest request) {
2732         return client.getResponseMetadataForRequest(request);
2733     }
2734
2735     /**
2736      * Normal invoke with authentication. Credentials are required and may be overriden at the request level.
2737      **/

2738     private <X, Y extends AmazonWebServiceRequest> Response<X> invoke(Request<Y> request, HttpResponseHandler<AmazonWebServiceResponse<X>> responseHandler,
2739             ExecutionContext executionContext) {
2740
2741         return invoke(request, responseHandler, executionContext, nullnull);
2742     }
2743
2744     /**
2745      * Normal invoke with authentication. Credentials are required and may be overriden at the request level.
2746      **/

2747     private <X, Y extends AmazonWebServiceRequest> Response<X> invoke(Request<Y> request, HttpResponseHandler<AmazonWebServiceResponse<X>> responseHandler,
2748             ExecutionContext executionContext, URI cachedEndpoint, URI uriFromEndpointTrait) {
2749
2750         executionContext.setCredentialsProvider(CredentialUtils.getCredentialsProvider(request.getOriginalRequest(), awsCredentialsProvider));
2751
2752         return doInvoke(request, responseHandler, executionContext, cachedEndpoint, uriFromEndpointTrait);
2753     }
2754
2755     /**
2756      * Invoke with no authentication. Credentials are not required and any credentials set on the client or request will
2757      * be ignored for this operation.
2758      **/

2759     private <X, Y extends AmazonWebServiceRequest> Response<X> anonymousInvoke(Request<Y> request,
2760             HttpResponseHandler<AmazonWebServiceResponse<X>> responseHandler, ExecutionContext executionContext) {
2761
2762         return doInvoke(request, responseHandler, executionContext, nullnull);
2763     }
2764
2765     /**
2766      * Invoke the request using the http client. Assumes credentials (or lack thereof) have been configured in the
2767      * ExecutionContext beforehand.
2768      **/

2769     private <X, Y extends AmazonWebServiceRequest> Response<X> doInvoke(Request<Y> request, HttpResponseHandler<AmazonWebServiceResponse<X>> responseHandler,
2770             ExecutionContext executionContext, URI discoveredEndpoint, URI uriFromEndpointTrait) {
2771
2772         if (discoveredEndpoint != null) {
2773             request.setEndpoint(discoveredEndpoint);
2774             request.getOriginalRequest().getRequestClientOptions().appendUserAgent("endpoint-discovery");
2775         } else if (uriFromEndpointTrait != null) {
2776             request.setEndpoint(uriFromEndpointTrait);
2777         } else {
2778             request.setEndpoint(endpoint);
2779         }
2780
2781         request.setTimeOffset(timeOffset);
2782
2783         DefaultErrorResponseHandler errorResponseHandler = new DefaultErrorResponseHandler(exceptionUnmarshallers);
2784
2785         return client.execute(request, responseHandler, errorResponseHandler, executionContext);
2786     }
2787
2788 }
2789