Example usage for com.amazonaws.services.sns AmazonSNS deleteTopic

List of usage examples for com.amazonaws.services.sns AmazonSNS deleteTopic

Introduction

In this page you can find the example usage for com.amazonaws.services.sns AmazonSNS deleteTopic.

Prototype

DeleteTopicResult deleteTopic(String topicArn);

Source Link

Document

Simplified method form for invoking the DeleteTopic operation.

Usage

From source file:com.dev.appx.sns.SNSMobilePush.java

License:Open Source License

public void deleteTopic(String topicArn) throws IOException {

    //AmazonSNSClient snsClient = new AmazonSNSClient(new ClasspathPropertiesFileCredentialsProvider());   

    AmazonSNS snsClient = new AmazonSNSClient(
            new PropertiesCredentials(SNSMobilePush.class.getResourceAsStream("AwsCredentials.properties")));
    //delete an SNS topic
    DeleteTopicRequest deleteTopicRequest = new DeleteTopicRequest(topicArn);
    snsClient.deleteTopic(deleteTopicRequest);
    //get request id for DeleteTopicRequest from SNS metadata
    System.out.println("DeleteTopicRequest - " + snsClient.getCachedResponseMetadata(deleteTopicRequest));

}

From source file:com.easarrive.aws.plugins.common.service.impl.SNSService.java

License:Open Source License

/**
 * {@inheritDoc}//from  w w  w .j av a  2 s  . c om
 */
@Override
public DeleteTopicResult deleteTopic(AmazonSNS client, SNSTopicRequest topicRequest) {
    if (topicRequest == null) {
        return null;
    }
    // delete an SNS topic
    DeleteTopicRequest deleteTopicRequest = new DeleteTopicRequest(topicRequest.getTopicArn());
    DeleteTopicResult result = client.deleteTopic(deleteTopicRequest);

    return result;
}

From source file:io.konig.maven.DeleteAwsSNS.java

License:Apache License

public AwsDeployment from(String path) throws Exception {
    String cfTemplatePresent = System.getProperty("cfTemplatePresent");
    if (cfTemplatePresent == null || cfTemplatePresent.equals("N")) {
        try {/* ww w . j  a v  a 2s  .  c  om*/
            File file = deployment.file(path);
            ObjectMapper mapper = new ObjectMapper();
            S3Bucket bucket = mapper.readValue(file, S3Bucket.class);
            deployment.verifyAWSCredentials();
            TopicConfiguration notificationConfig = bucket.getNotificationConfiguration()
                    .getTopicConfiguration();
            if (notificationConfig != null && notificationConfig.getTopic() != null) {
                Topic topic = notificationConfig.getTopic();
                Regions regions = Regions.fromName(topic.getRegion());
                AmazonSNS sns = AmazonSNSClientBuilder.standard().withCredentials(deployment.getCredential())
                        .withRegion(regions).build();
                String accountId = "";
                if (System.getProperty("aws-account-id") != null) {
                    accountId = System.getProperty("aws-account-id");
                }
                String topicArn = StringUtils.replaceOnce(notificationConfig.getTopicArn(), "${aws-account-id}",
                        accountId);
                sns.deleteTopic(topicArn);
                deployment.setResponse("Topic with ARN : " + topicArn + " is deleted");
            } else {
                deployment.setResponse("No topic is configured to the S3 Bucket");
            }

        } catch (Exception e) {
            throw e;
        }
    } else {
        deployment.setResponse("Topic will be deleted through cloud formation stack");
    }
    return deployment;
}

From source file:net.smartcosmos.plugin.service.aws.notification.AwsNotificationService.java

License:Apache License

@Override
public void deleteTopic(INotificationEndpoint notificationEndpoint) {
    Preconditions.checkArgument((notificationEndpoint != null), "Notification endpoint must not be null");

    Preconditions.checkArgument((notificationEndpoint.getTopicArn() != null),
            "Notification Topic ARN must not be null");

    AmazonSNS sns = new AmazonSNSClient(credentials);
    Region usEast1 = Region.getRegion(Regions.US_EAST_1);
    sns.setRegion(usEast1);/*from  www .  j  av a 2  s . c  o  m*/

    try {
        DeleteTopicRequest request = new DeleteTopicRequest(notificationEndpoint.getTopicArn());
        sns.deleteTopic(request);
    } finally {
        sns.shutdown();
    }

    //
    // Event
    //
    INotificationResultObject<IAccount> nro = new NotificationResultObject<>(EntityReferenceType.Account,
            notificationEndpoint.getAccount(), "");
    IEventService eventService = context.getServiceFactory().getEventService(notificationEndpoint.getAccount());
    eventService.recordEvent(EventType.NotificationWithdrawn, notificationEndpoint.getAccount(), null, nro);
}