Example usage for com.amazonaws.services.sns.model ConfirmSubscriptionResult getSubscriptionArn

List of usage examples for com.amazonaws.services.sns.model ConfirmSubscriptionResult getSubscriptionArn

Introduction

In this page you can find the example usage for com.amazonaws.services.sns.model ConfirmSubscriptionResult getSubscriptionArn.

Prototype


public String getSubscriptionArn() 

Source Link

Document

The ARN of the created subscription.

Usage

From source file:com.zotoh.cloudapi.aws.SNS.java

License:Open Source License

@Override
public String confirmSubscription(String topic, String token, boolean authUnsubscribe)
        throws CloudException, InternalException {
    ConfirmSubscriptionResult res = _svc.getCloud().getSNS()
            .confirmSubscription(new ConfirmSubscriptionRequest()
                    .withAuthenticateOnUnsubscribe(authUnsubscribe ? "true" : "false").withTopicArn(topic)
                    .withToken(token));//from w w w  . j a va 2s .c o  m
    return res == null ? null : res.getSubscriptionArn();
}

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

License:Apache License

@Override
public void confirmSubscription(INotificationEndpoint notificationEndpoint, String token) {
    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);/*w w w.  j  a v  a  2  s  .c  om*/

    try {
        ConfirmSubscriptionRequest request = new ConfirmSubscriptionRequest(notificationEndpoint.getTopicArn(),
                token);

        ConfirmSubscriptionResult result = sns.confirmSubscription(request);

        //
        // Event
        //
        INotificationResultObject<IAccount> nro = new NotificationResultObject<>(EntityReferenceType.Account,
                notificationEndpoint.getAccount(), result.getSubscriptionArn());
        IEventService eventService = context.getServiceFactory()
                .getEventService(notificationEndpoint.getAccount());
        eventService.recordEvent(EventType.NotificationSubscriptionConfirmed, notificationEndpoint.getAccount(),
                null, nro);
    } finally {
        sns.shutdown();
    }
}