use of software.amazon.awssdk.services.sns.model.SnsException in project aws-doc-sdk-examples by awsdocs.
the class SubscribeEmail method subEmail.
// snippet-start:[sns.java2.SubscribeEmail.main]
public static void subEmail(SnsClient snsClient, String topicArn, String email) {
try {
SubscribeRequest request = SubscribeRequest.builder().protocol("email").endpoint(email).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 ConfirmSubscription method confirmSub.
// snippet-start:[sns.java2.ConfirmSubscription.main]
public static void confirmSub(SnsClient snsClient, String subscriptionToken, String topicArn) {
try {
ConfirmSubscriptionRequest request = ConfirmSubscriptionRequest.builder().token(subscriptionToken).topicArn(topicArn).build();
ConfirmSubscriptionResponse result = snsClient.confirmSubscription(request);
System.out.println("\n\nStatus was " + result.sdkHttpResponse().statusCode() + "\n\nSubscription Arn: \n\n" + result.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 SubscribeHTTPS method subHTTPS.
// snippet-start:[sns.java2.SubscribeHTTPS.main]
public static void subHTTPS(SnsClient snsClient, String topicArn, String url) {
try {
SubscribeRequest request = SubscribeRequest.builder().protocol("http").endpoint(url).returnSubscriptionArn(true).topicArn(topicArn).build();
SubscribeResponse result = snsClient.subscribe(request);
System.out.println("Subscription ARN is " + 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 ListSubscriptions method listSNSSubscriptions.
// snippet-start:[sns.java2.ListSubscriptions.main]
public static void listSNSSubscriptions(SnsClient snsClient) {
try {
ListSubscriptionsRequest request = ListSubscriptionsRequest.builder().build();
ListSubscriptionsResponse result = snsClient.listSubscriptions(request);
System.out.println(result.subscriptions());
} catch (SnsException e) {
System.err.println(e.awsErrorDetails().errorMessage());
System.exit(1);
}
}
Aggregations