Sha256: 434d04efd83ce935b917e65bcf575bbfbda1189b6267f45ae22cfa2e66512c7a

Contents?: true

Size: 1.66 KB

Versions: 2

Compression:

Stored size: 1.66 KB

Contents

module Fog
  module AWS
    class SQS
      class Real

        require 'fog/aws/parsers/sqs/get_queue_attributes'

        # Get attributes of a queue
        #
        # ==== Parameters
        # * queue_url<~String> - Url of queue to get attributes for
        # * attribute_name<~Array> - Name of attribute to return, in ['All', 'ApproximateNumberOfMessages', 'ApproximateNumberOfMessagesNotVisible', 'CreatedTimestamp', 'LastModifiedTimestamp', 'MaximumMessageSize', 'MessageRetentionPeriod', 'Policy', 'QueueArn', 'VisibilityTimeout']
        #
        # ==== See Also
        # http://docs.amazonwebservices.com/AWSSimpleQueueService/latest/APIReference/Query_QueryGetQueueAttributes.html
        #

        def get_queue_attributes(queue_url, attribute_name)
          request({
            'Action'        => 'GetQueueAttributes',
            'AttributeName' => attribute_name,
            :path           => path_from_queue_url(queue_url),
            :parser         => Fog::Parsers::AWS::SQS::GetQueueAttributes.new
          })
        end

      end

      class Mock

        def get_queue_attributes(queue_url, attribute_name)
          Excon::Response.new.tap do |response|
            if (queue = data[:queues][queue_url])
              response.status = 200

              response.body = {
                'ResponseMetadata' => {
                  'RequestId' => Fog::AWS::Mock.request_id
                },
                'Attributes' => queue['Attributes']
              }
            else
              response.status = 404
              raise(Excon::Errors.status_error({:expects => 200}, response))
            end
          end
        end

      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
fog-1.22.0 lib/fog/aws/requests/sqs/get_queue_attributes.rb
fog-1.21.0 lib/fog/aws/requests/sqs/get_queue_attributes.rb