Search in sources :

Example 1 with CreateTopicRequest

use of software.amazon.awssdk.services.sns.model.CreateTopicRequest in project aws-doc-sdk-examples by awsdocs.

the class CreateTopic method createSNSTopic.

// snippet-start:[sns.java2.CreateTopic.main]
public static String createSNSTopic(SnsClient snsClient, String topicName) {
    CreateTopicResponse result = null;
    try {
        CreateTopicRequest request = CreateTopicRequest.builder().name(topicName).build();
        result = snsClient.createTopic(request);
        return result.topicArn();
    } catch (SnsException e) {
        System.err.println(e.awsErrorDetails().errorMessage());
        System.exit(1);
    }
    return "";
}
Also used : CreateTopicRequest(software.amazon.awssdk.services.sns.model.CreateTopicRequest) SnsException(software.amazon.awssdk.services.sns.model.SnsException) CreateTopicResponse(software.amazon.awssdk.services.sns.model.CreateTopicResponse)

Aggregations

CreateTopicRequest (software.amazon.awssdk.services.sns.model.CreateTopicRequest)1 CreateTopicResponse (software.amazon.awssdk.services.sns.model.CreateTopicResponse)1 SnsException (software.amazon.awssdk.services.sns.model.SnsException)1