use of software.amazon.awssdk.services.sns.SnsClient 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));
}
use of software.amazon.awssdk.services.sns.SnsClient in project aws-doc-sdk-examples by awsdocs.
the class ConfirmSubscription method main.
public static void main(String[] args) {
final String USAGE = "\n" + "Usage: " + " <subscriptionToken> <topicArn>\n\n" + "Where:\n" + " subscriptionToken - a short-lived token sent to an endpoint during the Subscribe action.\n\n" + " topicArn - the ARN of the topic. \n\n";
if (args.length != 2) {
System.out.println(USAGE);
System.exit(1);
}
String subscriptionToken = args[0];
String topicArn = args[1];
SnsClient snsClient = SnsClient.builder().region(Region.US_WEST_2).build();
confirmSub(snsClient, subscriptionToken, topicArn);
snsClient.close();
}
use of software.amazon.awssdk.services.sns.SnsClient in project aws-doc-sdk-examples by awsdocs.
the class Unsubscribe method main.
public static void main(String[] args) {
final String USAGE = "\n" + "Usage: " + " <subscriptionArn>\n\n" + "Where:\n" + " subscriptionArn - the ARN of the subscription to delete.\n\n";
if (args.length < 1) {
System.out.println(USAGE);
System.exit(1);
}
String subscriptionArn = args[0];
SnsClient snsClient = SnsClient.builder().region(Region.US_EAST_1).build();
unSub(snsClient, subscriptionArn);
snsClient.close();
}
use of software.amazon.awssdk.services.sns.SnsClient in project aws-doc-sdk-examples by awsdocs.
the class ListTags method main.
public static void main(String[] args) {
final String USAGE = "\n" + "Usage: " + " <topicArn>\n\n" + "Where:\n" + " topicArn - the ARN of the topic from which tags are listed.\n\n";
if (args.length != 1) {
System.out.println(USAGE);
System.exit(1);
}
String topicArn = args[0];
SnsClient snsClient = SnsClient.builder().region(Region.US_EAST_1).build();
listTopicTags(snsClient, topicArn);
snsClient.close();
}
use of software.amazon.awssdk.services.sns.SnsClient in project aws-doc-sdk-examples by awsdocs.
the class PublishTextSMS method main.
/**
* To run this Java V2 code example, ensure that you have setup your development environment, including your credentials.
*
* For information, see this documentation topic:
*
* https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/get-started.html
*/
public static void main(String[] args) {
final String USAGE = "\n" + "Usage: " + " <message> <phoneNumber>\n\n" + "Where:\n" + " message - the message text to send.\n\n" + " phoneNumber - the mobile phone number to which a message is sent (for example, +1XXX5550100). \n\n";
if (args.length != 2) {
System.out.println(USAGE);
System.exit(1);
}
String message = args[0];
String phoneNumber = args[1];
SnsClient snsClient = SnsClient.builder().region(Region.US_WEST_2).build();
pubTextSMS(snsClient, message, phoneNumber);
snsClient.close();
}
Aggregations