use of software.amazon.awssdk.services.sns.model.SnsException in project aws-doc-sdk-examples by awsdocs.
the class DeleteTag method removeTag.
// snippet-start:[sns.java2.delete_tags.main]
public static void removeTag(SnsClient snsClient, String topicArn, String tagKey) {
try {
UntagResourceRequest resourceRequest = UntagResourceRequest.builder().resourceArn(topicArn).tagKeys(tagKey).build();
snsClient.untagResource(resourceRequest);
System.out.println(tagKey + " was deleted from " + topicArn);
} catch (SnsException e) {
System.err.println(e.awsErrorDetails().errorMessage());
System.exit(1);
}
}
use of software.amazon.awssdk.services.sns.model.SnsException in project aws-doc-sdk-examples by awsdocs.
the class GetSMSAtrributes method getSNSAttrutes.
// snippet-start:[sns.java2.GetSMSAtrributes.main]
public static void getSNSAttrutes(SnsClient snsClient, String topicArn) {
try {
GetSubscriptionAttributesRequest request = GetSubscriptionAttributesRequest.builder().subscriptionArn(topicArn).build();
// Get the Subscription attributes
GetSubscriptionAttributesResponse res = snsClient.getSubscriptionAttributes(request);
Map<String, String> map = res.attributes();
// Iterate through the map
Iterator iter = map.entrySet().iterator();
while (iter.hasNext()) {
Map.Entry entry = (Map.Entry) iter.next();
System.out.println("[Key] : " + entry.getKey() + " [Value] : " + entry.getValue());
}
} catch (SnsException e) {
System.err.println(e.awsErrorDetails().errorMessage());
System.exit(1);
}
System.out.println("\n\nStatus was good");
}
use of software.amazon.awssdk.services.sns.model.SnsException in project aws-doc-sdk-examples by awsdocs.
the class ListOptOut method listOpts.
// snippet-start:[sns.java2.ListOptOut.main]
public static void listOpts(SnsClient snsClient) {
try {
ListPhoneNumbersOptedOutRequest request = ListPhoneNumbersOptedOutRequest.builder().build();
ListPhoneNumbersOptedOutResponse result = snsClient.listPhoneNumbersOptedOut(request);
System.out.println("Status is " + result.sdkHttpResponse().statusCode() + "\n\nPhone Numbers: \n\n" + result.phoneNumbers());
} catch (SnsException e) {
System.err.println(e.awsErrorDetails().errorMessage());
System.exit(1);
}
}
use of software.amazon.awssdk.services.sns.model.SnsException in project aws-doc-sdk-examples by awsdocs.
the class ListTags method listTopicTags.
// snippet-start:[sns.java2.list_tags.main]
public static void listTopicTags(SnsClient snsClient, String topicArn) {
try {
ListTagsForResourceRequest tagsForResourceRequest = ListTagsForResourceRequest.builder().resourceArn(topicArn).build();
ListTagsForResourceResponse response = snsClient.listTagsForResource(tagsForResourceRequest);
System.out.println(String.format("Tags for topic %s are %s.\n", topicArn, response.tags()));
} catch (SnsException e) {
System.err.println(e.awsErrorDetails().errorMessage());
System.exit(1);
}
}
use of software.amazon.awssdk.services.sns.model.SnsException in project aws-doc-sdk-examples by awsdocs.
the class PublishTextSMS method pubTextSMS.
// snippet-start:[sns.java2.PublishTextSMS.main]
public static void pubTextSMS(SnsClient snsClient, String message, String phoneNumber) {
try {
PublishRequest request = PublishRequest.builder().message(message).phoneNumber(phoneNumber).build();
PublishResponse result = snsClient.publish(request);
System.out.println(result.messageId() + " Message sent. Status was " + result.sdkHttpResponse().statusCode());
} catch (SnsException e) {
System.err.println(e.awsErrorDetails().errorMessage());
System.exit(1);
}
}
Aggregations