Search in sources :

Example 1 with ListQueueTagsResponse

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

the class ListQueueTags method listTags.

// snippet-start:[sqs.java2.list_tags.main]
public static void listTags(SqsClient sqsClient, String queueName) {
    try {
        GetQueueUrlRequest urlRequest = GetQueueUrlRequest.builder().queueName(queueName).build();
        GetQueueUrlResponse getQueueUrlResponse = sqsClient.getQueueUrl(urlRequest);
        String queueUrl = getQueueUrlResponse.queueUrl();
        ListQueueTagsRequest listQueueTagsRequest = ListQueueTagsRequest.builder().queueUrl(queueUrl).build();
        ListQueueTagsResponse listQueueTagsResponse = sqsClient.listQueueTags(listQueueTagsRequest);
        System.out.println(String.format("ListQueueTags: \tTags for queue %s are %s.\n", queueName, listQueueTagsResponse.tags()));
    } catch (SqsException e) {
        System.err.println(e.awsErrorDetails().errorMessage());
        System.exit(1);
    }
}
Also used : GetQueueUrlRequest(software.amazon.awssdk.services.sqs.model.GetQueueUrlRequest) SqsException(software.amazon.awssdk.services.sqs.model.SqsException) GetQueueUrlResponse(software.amazon.awssdk.services.sqs.model.GetQueueUrlResponse) ListQueueTagsResponse(software.amazon.awssdk.services.sqs.model.ListQueueTagsResponse) ListQueueTagsRequest(software.amazon.awssdk.services.sqs.model.ListQueueTagsRequest)

Aggregations

GetQueueUrlRequest (software.amazon.awssdk.services.sqs.model.GetQueueUrlRequest)1 GetQueueUrlResponse (software.amazon.awssdk.services.sqs.model.GetQueueUrlResponse)1 ListQueueTagsRequest (software.amazon.awssdk.services.sqs.model.ListQueueTagsRequest)1 ListQueueTagsResponse (software.amazon.awssdk.services.sqs.model.ListQueueTagsResponse)1 SqsException (software.amazon.awssdk.services.sqs.model.SqsException)1