Example usage for com.amazonaws.services.sns.model Subscription getTopicArn

List of usage examples for com.amazonaws.services.sns.model Subscription getTopicArn

Introduction

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

Prototype


public String getTopicArn() 

Source Link

Document

The ARN of the subscription's topic.

Usage

From source file:org.lendingclub.mercator.aws.SNSScanner.java

License:Apache License

private void projectSubscription(Topic topic, Subscription subscription) {

    ObjectNode n = mapper.createObjectNode();
    n.put("aws_topicArn", subscription.getTopicArn());
    n.put("aws_endpoint", subscription.getEndpoint());
    n.put("aws_protocol", subscription.getProtocol());
    n.put("aws_owner", subscription.getOwner());
    n.put("aws_region", getRegion().getName());
    n.put("aws_account", getAccountId());
    String cypher = "merge (s:AwsSnsSubscription {aws_arn:{arn}}) set s+={props}, s.updateTs=timestamp()";

    getNeoRxClient().execCypher(cypher, "arn", subscription.getSubscriptionArn(), "props", n);

    cypher = "match (a:AwsSnsSubscription {aws_arn:{subscriptionArn}}), (t:AwsSnsTopic {aws_arn:{topicArn}}) MERGE (t)-[r:HAS_SUBSCRIPTION]->(a) set r.updateTs=timestamp()";

    getNeoRxClient().execCypher(cypher, "subscriptionArn", subscription.getSubscriptionArn(), "topicArn",
            topic.getTopicArn());//from   www.  j  a v  a 2  s.com

    String targetArn = subscription.getEndpoint();
    if (targetArn.startsWith("arn:aws:sqs:")) {
        cypher = "match (a:AwsSnsTopic {aws_arn:{topicArn}}),(q:AwsSqsQueue {aws_arn:{queueArn}}) MERGE (a)-[r:PUBLISHES]->(q) set r.updateTs=timestamp()";
        getNeoRxClient().execCypher(cypher, "topicArn", subscription.getTopicArn(), "queueArn", targetArn);

    }
}

From source file:shnakkydoodle.notifying.provider.aws.AwsProvider.java

License:Open Source License

/**
 * Retrieve a specific subsctipion id/* w w w  . j  av a 2s . co m*/
 * 
 * @param topicName
 * @param protocol
 * @param endpoint
 * @return
 */
private String retrieveSubscriptionId(String topicName, String protocol, String endpoint) {

    // find the topic
    NotificationTopic notificationTopic = this.retrieveNotificationTopic(topicName);
    if (notificationTopic == null) {
        return null;
    }

    AmazonSNSClient snsClient = getSNSClient();
    for (Subscription subscription : snsClient.listSubscriptions().getSubscriptions()) {
        if (subscription.getTopicArn().equals(notificationTopic.getTopicId())) {
            if (subscription.getProtocol().equals(protocol) && subscription.getEndpoint().equals(endpoint)) {
                return subscription.getSubscriptionArn();
            }
        }
    }

    return null;
}

From source file:shnakkydoodle.notifying.provider.aws.AwsProvider.java

License:Open Source License

/**
 * Retrieve the notifcation subscriptions for a topic
 * /*  w  w w.  j  a v a 2  s .c  o m*/
 * @param topicName
 */
@Override
public ArrayList<NotificationSubscription> retrieveNotificationSubscriptions(String topicName) {
    ArrayList<NotificationSubscription> data = new ArrayList<NotificationSubscription>();

    // find the topic
    NotificationTopic notificationTopic = this.retrieveNotificationTopic(topicName);
    if (notificationTopic == null) {
        return data;
    }

    AmazonSNSClient snsClient = getSNSClient();
    for (Subscription subscription : snsClient.listSubscriptions().getSubscriptions()) {
        if (subscription.getTopicArn().equals(notificationTopic.getTopicId())) {
            NotificationSubscription instance = new NotificationSubscription();
            instance.setNotificationTopic(notificationTopic);
            instance.setProtocol(subscription.getProtocol());
            instance.setEndPoint(subscription.getEndpoint());
            data.add(instance);
        }
    }
    return data;
}