use of software.amazon.awssdk.services.sns.model.SubscribeRequest 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.SubscribeRequest 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.SubscribeRequest 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.SubscribeRequest 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);
}
}
Aggregations