use of software.amazon.awssdk.services.sns.model.SnsException in project aws-doc-sdk-examples by awsdocs.
the class SetTopicAttributes method setTopAttr.
// snippet-start:[sns.java2.SetTopicAttributes.main]
public static void setTopAttr(SnsClient snsClient, String attribute, String topicArn, String value) {
try {
SetTopicAttributesRequest request = SetTopicAttributesRequest.builder().attributeName(attribute).attributeValue(value).topicArn(topicArn).build();
SetTopicAttributesResponse result = snsClient.setTopicAttributes(request);
System.out.println("\n\nStatus was " + result.sdkHttpResponse().statusCode() + "\n\nTopic " + request.topicArn() + " updated " + request.attributeName() + " to " + request.attributeValue());
} 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 SubscribeLambda method subLambda.
// snippet-start:[sns.java2.SubscribeLambda.main]
public static String subLambda(SnsClient snsClient, String topicArn, String lambdaArn) {
try {
SubscribeRequest request = SubscribeRequest.builder().protocol("lambda").endpoint(lambdaArn).returnSubscriptionArn(true).topicArn(topicArn).build();
SubscribeResponse result = snsClient.subscribe(request);
return result.subscriptionArn();
} catch (SnsException e) {
System.err.println(e.awsErrorDetails().errorMessage());
System.exit(1);
}
return "";
}
use of software.amazon.awssdk.services.sns.model.SnsException in project aws-doc-sdk-examples by awsdocs.
the class SubscribeTextSMS method subTextSNS.
// snippet-start:[sns.java2.SubscribeTextSMS.main]
public static void subTextSNS(SnsClient snsClient, String topicArn, String phoneNumber) {
try {
SubscribeRequest request = SubscribeRequest.builder().protocol("sms").endpoint(phoneNumber).returnSubscriptionArn(true).topicArn(topicArn).build();
SubscribeResponse result = snsClient.subscribe(request);
System.out.println("Subscription ARN: " + result.subscriptionArn() + "\n\n 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 Unsubscribe method unSub.
// snippet-start:[sns.java2.Unsubscribe.main]
public static void unSub(SnsClient snsClient, String subscriptionArn) {
try {
UnsubscribeRequest request = UnsubscribeRequest.builder().subscriptionArn(subscriptionArn).build();
UnsubscribeResponse result = snsClient.unsubscribe(request);
System.out.println("\n\nStatus was " + result.sdkHttpResponse().statusCode() + "\n\nSubscription was removed for " + request.subscriptionArn());
} 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 SendNotifications method publishTextSMS.
private void publishTextSMS(SnsClient snsClient, String phoneNumber) {
String message = "Please be advised that your student was marked absent from school today.";
try {
PublishRequest request = PublishRequest.builder().message(message).phoneNumber(phoneNumber).build();
snsClient.publish(request);
} catch (SnsException e) {
System.err.println(e.awsErrorDetails().errorMessage());
System.exit(1);
}
}
Aggregations