Search in sources :

Example 1 with UnsubscribeResponse

use of software.amazon.awssdk.services.sns.model.UnsubscribeResponse 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);
    }
}
Also used : UnsubscribeRequest(software.amazon.awssdk.services.sns.model.UnsubscribeRequest) SnsException(software.amazon.awssdk.services.sns.model.SnsException) UnsubscribeResponse(software.amazon.awssdk.services.sns.model.UnsubscribeResponse)

Aggregations

SnsException (software.amazon.awssdk.services.sns.model.SnsException)1 UnsubscribeRequest (software.amazon.awssdk.services.sns.model.UnsubscribeRequest)1 UnsubscribeResponse (software.amazon.awssdk.services.sns.model.UnsubscribeResponse)1