use of software.amazon.awssdk.services.sns.model.SnsException in project aws-doc-sdk-examples by awsdocs.
the class GetTopicAttributes method getSNSTopicAttributes.
// snippet-start:[sns.java2.GetTopicAttributes.main]
public static void getSNSTopicAttributes(SnsClient snsClient, String topicArn) {
try {
GetTopicAttributesRequest request = GetTopicAttributesRequest.builder().topicArn(topicArn).build();
GetTopicAttributesResponse result = snsClient.getTopicAttributes(request);
System.out.println("\n\nStatus is " + result.sdkHttpResponse().statusCode() + "\n\nAttributes: \n\n" + result.attributes());
} 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 ListTopics method listSNSTopics.
// snippet-start:[sns.java2.ListTopics.main]
public static void listSNSTopics(SnsClient snsClient) {
try {
ListTopicsRequest request = ListTopicsRequest.builder().build();
ListTopicsResponse result = snsClient.listTopics(request);
System.out.println("Status was " + result.sdkHttpResponse().statusCode() + "\n\nTopics\n\n" + result.topics());
} 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 PublishTopic method pubTopic.
// snippet-start:[sns.java2.PublishTopic.main]
public static void pubTopic(SnsClient snsClient, String message, String topicArn) {
try {
PublishRequest request = PublishRequest.builder().message(message).topicArn(topicArn).build();
PublishResponse result = snsClient.publish(request);
System.out.println(result.messageId() + " Message sent. Status is " + result.sdkHttpResponse().statusCode());
} 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 SetSMSAttributes method setSNSAttributes.
// snippet-start:[sns.java2.SetSMSAttributes.main]
public static void setSNSAttributes(SnsClient snsClient, HashMap<String, String> attributes) {
try {
SetSmsAttributesRequest request = SetSmsAttributesRequest.builder().attributes(attributes).build();
SetSmsAttributesResponse result = snsClient.setSMSAttributes(request);
System.out.println("Set default Attributes to " + attributes + ". Status was " + result.sdkHttpResponse().statusCode());
} 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 AddTags method addTopicTags.
// snippet-start:[sns.java2.add_tags.main]
public static void addTopicTags(SnsClient snsClient, String topicArn) {
try {
Tag tag = Tag.builder().key("Team").value("Development").build();
Tag tag2 = Tag.builder().key("Environment").value("Gamma").build();
List<Tag> tagList = new ArrayList<>();
tagList.add(tag);
tagList.add(tag2);
TagResourceRequest tagResourceRequest = TagResourceRequest.builder().resourceArn(topicArn).tags(tagList).build();
snsClient.tagResource(tagResourceRequest);
System.out.println("Tags have been added to " + topicArn);
} catch (SnsException e) {
System.err.println(e.awsErrorDetails().errorMessage());
System.exit(1);
}
}
Aggregations