use of software.amazon.awssdk.services.sns.model.ListSubscriptionsByTopicRequest in project aws-doc-sdk-examples by awsdocs.
the class SnsService method getTopicArnValue.
// Returns the Sub ARN based on the given endpoint
private String getTopicArnValue(String endpoint) {
SnsClient snsClient = getSnsClient();
try {
String subArn = "";
ListSubscriptionsByTopicRequest request = ListSubscriptionsByTopicRequest.builder().topicArn(topicArn).build();
ListSubscriptionsByTopicResponse result = snsClient.listSubscriptionsByTopic(request);
List<Subscription> allSubs = result.subscriptions();
for (Subscription sub : allSubs) {
if (sub.endpoint().compareTo(endpoint) == 0) {
subArn = sub.subscriptionArn();
return subArn;
}
}
} catch (SnsException e) {
System.err.println(e.awsErrorDetails().errorMessage());
System.exit(1);
}
return "";
}
use of software.amazon.awssdk.services.sns.model.ListSubscriptionsByTopicRequest in project aws-doc-sdk-examples by awsdocs.
the class SnsService method getAllSubscriptions.
public String getAllSubscriptions() {
List subList = new ArrayList<String>();
try {
SnsClient snsClient = getSnsClient();
ListSubscriptionsByTopicRequest request = ListSubscriptionsByTopicRequest.builder().topicArn(topicArn).build();
ListSubscriptionsByTopicResponse result = snsClient.listSubscriptionsByTopic(request);
List<Subscription> allSubs = result.subscriptions();
for (Subscription sub : allSubs) {
subList.add(sub.endpoint());
}
} catch (SnsException e) {
System.err.println(e.awsErrorDetails().errorMessage());
System.exit(1);
}
return convertToString(toXml(subList));
}
Aggregations