List of usage examples for com.amazonaws.services.sns AmazonSNSClient unsubscribe
@Override
public UnsubscribeResult unsubscribe(String subscriptionArn)
From source file:awslabs.lab31.SolutionCode.java
License:Open Source License
@Override public void deleteSubscriptions(AmazonSNSClient snsClient, String topicArn) { // TODO: Construct a ListSubscriptionsByTopicRequest object using the provided topic ARN. ListSubscriptionsByTopicRequest listSubscriptionsByTopicRequest = new ListSubscriptionsByTopicRequest() .withTopicArn(topicArn);/*from w w w .ja va 2s . com*/ // TODO: Submit the request using the listSubscriptionsByTopic method of the snsClient object. ListSubscriptionsByTopicResult listSubscriptionsByTopicResult = snsClient .listSubscriptionsByTopic(listSubscriptionsByTopicRequest); // TODO: Iterate over the subscriptions in the request result. // TODO: For each subscription, construct an UnsubscribeRequest object using the subscription ARN. // TODO: For each unsubscribe request, submit it using the unsubscribe method of the snsClient object. for (Subscription subscription : listSubscriptionsByTopicResult.getSubscriptions()) { UnsubscribeRequest unsubscribeRequest = new UnsubscribeRequest() .withSubscriptionArn(subscription.getSubscriptionArn()); snsClient.unsubscribe(unsubscribeRequest); } }
From source file:awslabs.lab31.StudentCode.java
License:Open Source License
/** * Delete all subscriptions to the specified SNS topic. Hint: Call getSubscriptions() on the client object to get * all of the subscriptions and loop through them calling the client object's unsubscribe() method with details of * each subscription./* w ww.ja v a2 s . c om*/ * * @param snsClient The SNS client object. * @param topicArn The SNS topic to remove the subscriptions from. */ @Override public void deleteSubscriptions(AmazonSNSClient snsClient, String topicArn) { ListSubscriptionsByTopicRequest request = new ListSubscriptionsByTopicRequest(topicArn); ListSubscriptionsByTopicResult result = snsClient.listSubscriptionsByTopic(request); for (Subscription s : result.getSubscriptions()) { UnsubscribeRequest unsubscribeRequest = new UnsubscribeRequest(s.getSubscriptionArn()); snsClient.unsubscribe(unsubscribeRequest); } }
From source file:shnakkydoodle.notifying.provider.aws.AwsProvider.java
License:Open Source License
/** * Delete and endpoint// w ww . j a v a 2 s. co m * * @param topicName * @param protocol * @param endpoint */ @Override public void deleteNotificationSubscription(String topicName, String protocol, String endpoint) { AmazonSNSClient snsClient = getSNSClient(); String subscriptionId = retrieveSubscriptionId(topicName, protocol, endpoint); if (subscriptionId != null && !subscriptionId.equals("")) { snsClient.unsubscribe(subscriptionId); } }