use of com.amazonaws.services.sns.model.Topic in project camel by apache.
the class AmazonSNSClientMock method listTopics.
@Override
public ListTopicsResult listTopics(String nextToken) {
ListTopicsResult res = new ListTopicsResult();
Topic topic = new Topic();
topic.setTopicArn(DEFAULT_TOPIC_ARN);
List<Topic> list = new ArrayList<Topic>();
list.add(topic);
res.setTopics(list);
return res;
}
use of com.amazonaws.services.sns.model.Topic in project camel by apache.
the class SnsEndpoint method doStart.
@Override
public void doStart() throws Exception {
super.doStart();
snsClient = configuration.getAmazonSNSClient() != null ? configuration.getAmazonSNSClient() : createSNSClient();
// Override the setting Endpoint from url
if (ObjectHelper.isNotEmpty(configuration.getAmazonSNSEndpoint())) {
LOG.trace("Updating the SNS region with : {} " + configuration.getAmazonSNSEndpoint());
snsClient.setEndpoint(configuration.getAmazonSNSEndpoint());
}
// check the setting the headerFilterStrategy
if (headerFilterStrategy == null) {
headerFilterStrategy = new SnsHeaderFilterStrategy();
}
if (configuration.getTopicArn() == null) {
try {
String nextToken = null;
final String arnSuffix = ":" + configuration.getTopicName();
do {
final ListTopicsResult response = snsClient.listTopics(nextToken);
nextToken = response.getNextToken();
for (final Topic topic : response.getTopics()) {
if (topic.getTopicArn().endsWith(arnSuffix)) {
configuration.setTopicArn(topic.getTopicArn());
break;
}
}
} while (nextToken != null);
} catch (final AmazonServiceException ase) {
LOG.trace("The list topics operation return the following error code {}", ase.getErrorCode());
throw ase;
}
}
if (configuration.getTopicArn() == null) {
// creates a new topic, or returns the URL of an existing one
CreateTopicRequest request = new CreateTopicRequest(configuration.getTopicName());
LOG.trace("Creating topic [{}] with request [{}]...", configuration.getTopicName(), request);
CreateTopicResult result = snsClient.createTopic(request);
configuration.setTopicArn(result.getTopicArn());
LOG.trace("Topic created with Amazon resource name: {}", configuration.getTopicArn());
}
if (ObjectHelper.isNotEmpty(configuration.getPolicy())) {
LOG.trace("Updating topic [{}] with policy [{}]", configuration.getTopicArn(), configuration.getPolicy());
snsClient.setTopicAttributes(new SetTopicAttributesRequest(configuration.getTopicArn(), "Policy", configuration.getPolicy()));
LOG.trace("Topic policy updated");
}
}
use of com.amazonaws.services.sns.model.Topic in project Synapse-Stack-Builder by Sage-Bionetworks.
the class StackInstanceNotificationSetup method describeResources.
public void describeResources() {
String topicName;
String subscriptionEndpoint;
ListTopicsResult res;
List<Topic> topics;
topicName = config.getRDSAlertTopicName();
subscriptionEndpoint = config.getRDSAlertSubscriptionEndpoint();
res = client.listTopics();
// TopicArn ends with topic name
topics = res.getTopics();
for (Topic topic : topics) {
if (topic.getTopicArn().endsWith(topicName)) {
resources.setStackInstanceNotificationTopicArn(topic.getTopicArn());
break;
}
}
}
Aggregations