You are viewing documentation for version 1 of the AWS SDK for Ruby. Version 2 documentation can be found here.
Class: AWS::SQS::QueueCollection
- Inherits:
-
Object
- Object
- AWS::SQS::QueueCollection
- Includes:
- Core::Collection::Simple
- Defined in:
- lib/aws/sqs/queue_collection.rb
Overview
Represents all the Queue objects in your account.
If you have permission to access a queue created by another account, you can also use this collection to access that queue by URL.
Instance Attribute Summary collapse
-
#prefix ⇒ String
readonly
The queue name prefix by which this collection is filtered.
Instance Method Summary collapse
-
#[](url) ⇒ Queue
The queue with the given URL.
-
#create(name, options = {}) ⇒ Queue
Creates a new queue.
-
#named(queue_name, options = {}) ⇒ Queue
Returns the queue with the given name.
-
#url_for(queue_name, options = {}) ⇒ Object
Returns the url for the given queue.
-
#with_prefix(prefix) ⇒ QueueCollection
A new collection representing only the queues whose names start with the given prefix.
Methods included from Core::Collection
#each, #each_batch, #enum, #first, #in_groups_of, #page
Instance Attribute Details
#prefix ⇒ String (readonly)
Returns The queue name prefix by which this collection is filtered.
52 53 54 |
# File 'lib/aws/sqs/queue_collection.rb', line 52 def prefix @prefix end |
Instance Method Details
#[](url) ⇒ Queue
Returns The queue with the given URL.
127 128 129 |
# File 'lib/aws/sqs/queue_collection.rb', line 127 def [] url Queue.new(url, :config => config) end |
#create(name, options = {}) ⇒ Queue
If you delete a queue, you must wait at least 60 seconds before creating a queue with the same name.
Creates a new queue.
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/aws/sqs/queue_collection.rb', line 91 def create name, = {} # SQS removed the default prefix to the visibility timeout option # in the 2011-10-01 update -- this allows us to not break existing # customers. if [:default_visibility_timeout] [:visibility_timeout] = .delete(:default_visibility_timeout) end if policy = [:policy] [:policy] = policy.to_json unless policy.is_a?(String) end client_opts = {} client_opts[:queue_name] = name unless .empty? client_opts[:attributes] = .inject({}) do |attributes,(k,v)| attributes.merge(Core::Inflection.class_name(k.to_s) => v.to_s) end end response = client.create_queue(client_opts) Queue.new(response[:queue_url], :config => config) end |
#named(queue_name, options = {}) ⇒ Queue
Returns the queue with the given name. This requires making a request to SQS to get the queue url. If you know the url, you should use #[] instead.
142 143 144 |
# File 'lib/aws/sqs/queue_collection.rb', line 142 def named queue_name, = {} self[url_for(queue_name, = {})] end |
#url_for(queue_name, options = {}) ⇒ Object
Returns the url for the given queue.
162 163 164 165 166 |
# File 'lib/aws/sqs/queue_collection.rb', line 162 def url_for queue_name, = {} client_opts = {} client_opts[:queue_name] = queue_name client.get_queue_url(client_opts.merge())[:queue_url] end |
#with_prefix(prefix) ⇒ QueueCollection
Returns A new collection representing only the queues whose names start with the given prefix.
122 123 124 |
# File 'lib/aws/sqs/queue_collection.rb', line 122 def with_prefix(prefix) self.class.new(:prefix => prefix, :config => config) end |