Sha256: 913f99945ff892f343cbc29202e460a1f33a83a16c22fe939d060dba93bb38e3

Contents?: true

Size: 1.54 KB

Versions: 3

Compression:

Stored size: 1.54 KB

Contents

require 'aws/api'
require 'aws/call_types/action_param'
require 'aws/signing/version2'

module AWS

  ##
  # Amazon's Simple Queue Service
  #
  # http://docs.amazonwebservices.com/AWSSimpleQueueService/latest/APIReference/Welcome.html
  #
  # All requests are POST and always through HTTPS. Use the third parameter to
  # #initialize if you need to talk to a region other than us-east-1.
  #
  # For the requests that act on a queue directly, like SendMessage, pass in the QueueURL
  # as the first parameter to the call:
  #
  #   sqs.send_message queue_url, params
  #
  # In accordance with the AWS documentation, SimpleAWS does not try to reconstruct
  # queue urls, use ListQueues or GetQueueUrl to get the correct queue url when needed.
  ##
  class SQS < API
    endpoint "sqs"
    use_https true
    version "2011-10-01"
    default_region "us-east-1"

    include CallTypes::ActionParam
    include Signing::Version2

    # Special handling here, we need to look for a QueueURL as the first
    # parameter and update the request URI accordingly
    def method_missing(name, *args)
      if args.first.is_a?(String)
        request_uri = args.first
        params = args.last
      else
        request_uri = self.uri
        params = args.first
      end

      uri = URI.parse(request_uri)

      request = AWS::Request.new :post, "#{uri.scheme}://#{uri.host}", uri.path
      request.params["Action"] = AWS::Util.camelcase(name.to_s)

      if params.is_a?(Hash)
        insert_params_from request, params
      end

      send_request request
    end
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
simple_aws-0.0.1d lib/aws/sqs.rb
simple_aws-0.0.1c lib/aws/sqs.rb
simple_aws-0.0.1b lib/aws/sqs.rb