| 1 | package GetQueueAttributes; | ||
| 2 | |||
| 3 | use strict; | ||
| 4 | use warnings; | ||
| 5 | |||
| 6 | use English qw(-no_match_vars); | ||
| 7 | use Amazon::SQS::Model::GetQueueAttributesRequest; | ||
| 8 | use Data::Dumper; | ||
| 9 | |||
| 10 | use parent qw(Amazon::SQS::Sample); | ||
| 11 | |||
| 12 | ######################################################################## | ||
| 13 | sub sample { | ||
| 14 | ######################################################################## | ||
| 15 | my ( $self, $attributes, $queue_url ) = @_; | ||
| 16 | |||
| 17 | $attributes //= 'All'; | ||
| 18 | |||
| 19 | $attributes = [ split /\s*,\s*/xsm, $attributes ]; | ||
| 20 | |||
| 21 | my $service = $self->get_service; | ||
| 22 | |||
| 23 | my $config = $self->get_config; | ||
| 24 | $queue_url //= $config && $config->get_queue_url; | ||
| 25 | |||
| 26 | if ( !$queue_url ) { | ||
| 27 | $self->help(); | ||
| 28 | } | ||
| 29 | |||
| 30 | my $request = Amazon::SQS::Model::GetQueueAttributesRequest->new( | ||
| 31 | { QueueUrl => $queue_url, | ||
| 32 | AttributeName => $attributes, | ||
| 33 | } | ||
| 34 | ); | ||
| 35 | |||
| 36 | my $response = $service->getQueueAttributes($request); | ||
| 37 | |||
| 38 | if ( $response->isSetResponseMetadata() ) { | ||
| 39 | my $responseMetadata = $response->getResponseMetadata(); | ||
| 40 | |||
| 41 | if ( $responseMetadata->isSetRequestId() ) { | ||
| 42 | my $requestId = $responseMetadata->getRequestId(); | ||
| 43 | } | ||
| 44 | } | ||
| 45 | |||
| 46 | if ( $response->isSetGetQueueAttributesResult() ) { | ||
| 47 | |||
| 48 | my $getQueueAttributesResult = $response->getGetQueueAttributesResult(); | ||
| 49 | my $attributeList = $getQueueAttributesResult->getAttribute(); | ||
| 50 | |||
| 51 | my %attributes; | ||
| 52 | |||
| 53 | foreach ( @{$attributeList} ) { | ||
| 54 | if ( $_->isSetName() ) { | ||
| 55 | $attributes{ $_->getName } = $_->getValue; | ||
| 56 | } | ||
| 57 | } | ||
| 58 | |||
| 59 | print {*STDERR} Dumper( [ attributes => \%attributes ] ); | ||
| 60 | } | ||
| 61 | |||
| 62 | return; | ||
| 63 | } | ||
| 64 | |||
| 65 | 1; | ||
| 66 | |||
| 67 | ## no critic | ||
| 68 | |||
| 69 | __END__ |