1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

[rackspace|queues] adding YARD docs

This commit is contained in:
Kyle Rames 2013-11-22 10:42:43 -06:00
parent b6d1a62677
commit fd736a6698
14 changed files with 235 additions and 14 deletions

View file

@ -24,7 +24,7 @@ module Fog
end
# Fetch keypair details
# @param [String] key_name: name of the key to request
# @param [String] key_name name of the key to request
# @return [Fog::Compute::RackspaceV2::Keypair] the requested keypair or 'nil' when not found
# @raise [Fog::Compute::RackspaceV2::BadRequest]
# @raise [Fog::Compute::RackspaceV2::InternalServerError]

View file

@ -5,15 +5,42 @@ module Fog
class Queues
class Claim < Fog::Model
# @!attribute [r] identity
# @return [String] The claim's id
identity :identity
# @!attribute [rw] grace
# @return [Integer] The grace attribute specifies the message grace period in seconds. The value of grace value must be between 60 and 43200 seconds (12 hours).
# You must include a value for this attribute in your request. To deal with workers that have stopped responding (for up to 1209600 seconds or 14 days, including
# claim lifetime), the server extends the lifetime of claimed messages to be at least as long as the lifetime of the claim itself, plus the specified grace period.
# If a claimed message would normally live longer than the grace period, its expiration is not adjusted.
attribute :grace
# @!attribute [rw] ttl
# @return [Integer] The ttl attribute specifies how long the server waits before releasing the claim. The ttl value must be between 60 and 43200 seconds (12 hours).
attribute :ttl
# @!attribute [rw] limit
# @return [Integer] Specifies the number of messages to return, up to 20 messages. If limit is not specified, limit defaults to 10.
attribute :limit
# @!attribute [r] limit
# @return [Array<Fog::Rackspace::Queues::Messages>, Array<Strings>] Specifies the number of messages to return, up to 20 messages.
# If limit is not specified, limit defaults to 10.
attribute :messages
alias :id :identity
# Creates or updates a claim
#
# @return [Boolean] returns true if claim is being created
#
# @raise [Fog::Rackspace::Queues::NotFound] - HTTP 404
# @raise [Fog::Rackspace::Queues::BadRequest] - HTTP 400
# @raise [Fog::Rackspace::Queues::InternalServerError] - HTTP 500
# @raise [Fog::Rackspace::Queues::ServiceError]
# @see http://docs.rackspace.com/queues/api/v1.0/cq-devguide/content/POST_claimMessages__version__queues__queue_name__claims_claims-operations-dle001.html
# @see http://docs.rackspace.com/queues/api/v1.0/cq-devguide/content/PATCH_updateClaim__version__queues__queue_name__claims__claimId__claims-operations-dle001.html
def save
if identity.nil?
create
@ -22,6 +49,15 @@ module Fog
end
end
# Destroys Claim
#
# @return [Boolean] returns true if claim is deleted
#
# @raise [Fog::Rackspace::Queues::NotFound] - HTTP 404
# @raise [Fog::Rackspace::Queues::BadRequest] - HTTP 400
# @raise [Fog::Rackspace::Queues::InternalServerError] - HTTP 500
# @raise [Fog::Rackspace::Queues::ServiceError]
# @see http://docs.rackspace.com/queues/api/v1.0/cq-devguide/content/DELETE_deleteClaim__version__queues__queue_name__claims__claimId__claims-operations-dle001.html
def destroy
requires :identity, :queue
service.delete_claim(queue.name, identity)

View file

@ -8,12 +8,29 @@ module Fog
model Fog::Rackspace::Queues::Claim
# @!attribute [rw] queue
# @return [String] The queue associated with the claim collection
attr_accessor :queue
# Returns list of claims
# @note The Rackspace Cloud does not currently provide a way to retrieve claims as such this list is maintained by fog. Claims are added to the claim collection
# as they are created.
# @return [Fog::Rackspace::Queues::Claims] Retrieves a collection of claims.
# @raise [Fog::Rackspace::Queues::NotFound] - HTTP 404
# @raise [Fog::Rackspace::Queues::BadRequest] - HTTP 400
# @raise [Fog::Rackspace::Queues::InternalServerError] - HTTP 500
# @raise [Fog::Rackspace::Queues::ServiceError]
def all
self
end
# This operation claims a set of messages (up to the value of the limit parameter) from oldest to newest and skips any messages that are already claimed.
# @return [Fog::Rackspace::Queues::Claim] Returns a claim
# @raise [Fog::Rackspace::Queues::NotFound] - HTTP 404
# @raise [Fog::Rackspace::Queues::BadRequest] - HTTP 400
# @raise [Fog::Rackspace::Queues::InternalServerError] - HTTP 500
# @raise [Fog::Rackspace::Queues::ServiceError]
# @see http://docs.rackspace.com/queues/api/v1.0/cq-devguide/content/POST_claimMessages__version__queues__queue_name__claims_claims-operations-dle001.html
def create(attributes = {})
object = new(attributes)
if object.save
@ -23,6 +40,14 @@ module Fog
end
end
# This operation queries the specified claim for the specified queue. Claims with malformed IDs or claims that are not found by ID are ignored.
#
# @param [Integer] claim_id Specifies the claim ID.
# @return [Fog::Rackspace::Queues::Claim] Returns a claim
# @raise [Fog::Rackspace::Queues::BadRequest] - HTTP 400
# @raise [Fog::Rackspace::Queues::InternalServerError] - HTTP 500
# @raise [Fog::Rackspace::Queues::ServiceError]
# @see http://docs.rackspace.com/queues/api/v1.0/cq-devguide/content/GET_queryClaim__version__queues__queue_name__claims__claimId__claims-operations-dle001.html
def get(claim_id)
requires :queue
data = service.get_claim(queue.identity, claim_id).body

View file

@ -5,12 +5,31 @@ module Fog
class Queues
class Message < Fog::Model
# @!attribute [r] age
# @return [Integer] The number of seconds relative to the server's clock.
attribute :age
# @!attribute [rw] ttl
# @return [Integer] specifies how long the server waits before marking the message as expired and removing it from the queue.
# @note The value of ttl must be between 60 and 1209600 seconds (14 days). Note that the server might not actually delete the message until its
# age has reached up to (ttl + 60) seconds, to allow for flexibility in storage implementations.
attribute :ttl
# @!attribute [rw] body
# @return [String, Hash, Array] specifies an arbitrary document that constitutes the body of the message being sent. The size of this body is limited to 256 KB, excluding whitespace. The document must be valid JSON.
attribute :body
# @!attribute [r] href
# @return [String] location of the message
attribute :href
# @!attribute [r] claim_id
# @return [String] the id of the claim
attribute :claim_id
# @!attribute [r] identity
# @return [String] The messages identity
def identity
return nil unless href
@ -19,6 +38,17 @@ module Fog
end
alias :id :identity
# Creates messages
# Requires queue, client_id, body, and ttl attributes to be populated
# @note messages cannot be updated
#
# @return [Boolean] returns true if message has been succesfully saved
#
# @raise [Fog::Rackspace::Queues::NotFound] - HTTP 404
# @raise [Fog::Rackspace::Queues::BadRequest] - HTTP 400
# @raise [Fog::Rackspace::Queues::InternalServerError] - HTTP 500
# @raise [Fog::Rackspace::Queues::ServiceError]
# @see http://docs.rackspace.com/queues/api/v1.0/cq-devguide/content/POST_postMessage__version__queues__queue_name__messages_message-operations-dle001.html
def save
requires :queue, :client_id, :body, :ttl
raise "Message has already been created and may not be updated." unless identity.nil?
@ -27,6 +57,15 @@ module Fog
true
end
# Destroys Message
#
# @return [Boolean] returns true if message is deleted
#
# @raise [Fog::Rackspace::Queues::NotFound] - HTTP 404
# @raise [Fog::Rackspace::Queues::BadRequest] - HTTP 400
# @raise [Fog::Rackspace::Queues::InternalServerError] - HTTP 500
# @raise [Fog::Rackspace::Queues::ServiceError]
# @see http://docs.rackspace.com/queues/api/v1.0/cq-devguide/content/DELETE_deleteMessage__version__queues__queue_name__messages__messageId__message-operations-dle001.html
def destroy
requires :identity, :queue
options = {}

View file

@ -8,13 +8,43 @@ module Fog
model Fog::Rackspace::Queues::Message
# @!attribute [r] client_id
# @return [String] UUID for the client instance.
attr_accessor :client_id
# @!attribute [r] queue
# @return [String] The name of the queue associated with the message.
attr_accessor :queue
# @!attribute [rw] echo
# @return [Boolean] Determines whether the API returns a client's own messages. The echo parameter is a Boolean value (true or false) that determines whether the API
# returns a client's own messages, as determined by the uuid portion of the User-Agent header. If you do not specify a value, echo uses the default value of false.
# If you are experimenting with the API, you might want to set echo=true in order to see the messages that you posted.
attr_accessor :echo
# @!attribute [rw] limit
# @return [String] When more messages are available than can be returned in a single request, the client can pick up the next batch of messages by simply using the URI
# template parameters returned from the previous call in the "next" field. Specifies up to 10 messages (the default value) to return. If you do not specify a value
# for the limit parameter, the default value of 10 is used.
attr_accessor :limit
# @!attribute [rw] marker
# @return [String] Specifies an opaque string that the client can use to request the next batch of messages. The marker parameter communicates to the server which
# messages the client has already received. If you do not specify a value, the API returns all messages at the head of the queue (up to the limit).
attr_accessor :marker
# @!attribute [rw] include_claimed
# @return [String] Determines whether the API returns claimed messages and unclaimed messages. The include_claimed parameter is a Boolean value (true or false)
# that determines whether the API returns claimed messages and unclaimed messages. If you do not specify a value, include_claimed uses the default value of false
# (only unclaimed messages are returned).
attr_accessor :include_claimed
# Returns list of messages
#
# @return [Fog::Rackspace::Queues::Messages] Retrieves a collection of messages.
# @raise [Fog::Rackspace::Queues::NotFound] - HTTP 404
# @raise [Fog::Rackspace::Queues::BadRequest] - HTTP 400
# @raise [Fog::Rackspace::Queues::InternalServerError] - HTTP 500
def all
requires :client_id, :queue
response = service.list_messages(client_id, queue.name, options)
@ -26,6 +56,13 @@ module Fog
load(data)
end
# Returns the specified message from the queue.
#
# @param [Integer] message_id id of the message to be retrieved
# @return [Fog::Rackspace::Queues::Claim] Returns a claim
# @raise [Fog::Rackspace::Queues::BadRequest] - HTTP 400
# @raise [Fog::Rackspace::Queues::InternalServerError] - HTTP 500
# @raise [Fog::Rackspace::Queues::ServiceError]
def get(message_id)
requires :client_id, :queue
data = service.get_message(client_id, queue.name, message_id).body

View file

@ -5,8 +5,17 @@ module Fog
class Queues
class Queue < Fog::Model
# @!attribute [rw] name
# @return [String] name of queue
identity :name
# Returns list of messages in the queue
#
# @return [Fog::Rackspace::Queues::Messages] Retrieves a collection of messages.
# @raise [Fog::Rackspace::Queues::NotFound] - HTTP 404
# @raise [Fog::Rackspace::Queues::BadRequest] - HTTP 400
# @raise [Fog::Rackspace::Queues::InternalServerError] - HTTP 500
# @see http://docs.rackspace.com/queues/api/v1.0/cq-devguide/content/GET_getMessages__version__queues__queue_name__messages_message-operations-dle001.html
def messages
@messages ||= begin
Fog::Rackspace::Queues::Messages.new({
@ -18,10 +27,25 @@ module Fog
end
end
# Returns queue statistics, including how many messages are in the queue, categorized by status.
#
# @return [Hash] Retrieves a collection of messages.
# @raise [Fog::Rackspace::Queues::NotFound] - HTTP 404
# @raise [Fog::Rackspace::Queues::BadRequest] - HTTP 400
# @raise [Fog::Rackspace::Queues::InternalServerError] - HTTP 500
# @see http://docs.rackspace.com/queues/api/v1.0/cq-devguide/content/GET_getQueueStats__version__queues__queue_name__stats_queue-operations-dle001.html
def stats
service.get_queue_stats(name).body['messages']
end
# Returns list of claims
# @note The Rackspace Cloud does not currently provide a way to retrieve claims as such this list is maintained by fog. Claims are added to the claim collection
# as they are created.
# @return [Fog::Rackspace::Queues::Claims] Retrieves a collection of claims.
# @raise [Fog::Rackspace::Queues::NotFound] - HTTP 404
# @raise [Fog::Rackspace::Queues::BadRequest] - HTTP 400
# @raise [Fog::Rackspace::Queues::InternalServerError] - HTTP 500
# @raise [Fog::Rackspace::Queues::ServiceError]
def claims
@claims ||= begin
Fog::Rackspace::Queues::Claims.new({
@ -31,12 +55,32 @@ module Fog
end
end
#Helper method to enqueue a single message
# Helper method to enqueue a single message
#
# @param [String, Hash, Array] body The body attribute specifies an arbitrary document that constitutes the body of the message being sent. The size of this body is limited to 256 KB, excluding whitespace. The document must be valid JSON.
# @param [Integer] ttl The ttl attribute specifies how long the server waits before releasing the claim. The ttl value must be between 60 and 43200 seconds (12 hours).
# @param [Hash] options
# @return [Boolean] returns true if message has been succesfully enqueued
# @raise [Fog::Rackspace::Queues::NotFound] - HTTP 404
# @raise [Fog::Rackspace::Queues::BadRequest] - HTTP 400
# @raise [Fog::Rackspace::Queues::InternalServerError] - HTTP 500
# @raise [Fog::Rackspace::Queues::ServiceError]
# @see http://docs.rackspace.com/queues/api/v1.0/cq-devguide/content/POST_postMessage__version__queues__queue_name__messages_message-operations-dle001.html
def enqueue(body, ttl, options = {})
messages.create(options.merge({:body => body, :ttl => ttl}))
end
#Helper method to claim (dequeue) a single message, including destroying it
# Helper method to claim (dequeue) a single message, yield the message, and then destroy it
#
# @param [Integer] ttl The ttl attribute specifies how long the server waits before releasing the claim. The ttl value must be between 60 and 43200 seconds (12 hours).
# @param [Integer] grace The grace attribute specifies the message grace period in seconds. The value of grace value must be between 60 and 43200 seconds (12 hours).
# @param [Hash] options
# @yieldparam message claimed [Fog::Rackspace::Queues::Message]
# @return [Boolean] Returns true if claim was successfully made
# @raise [Fog::Rackspace::Queues::NotFound] - HTTP 404
# @raise [Fog::Rackspace::Queues::BadRequest] - HTTP 400
# @raise [Fog::Rackspace::Queues::InternalServerError] - HTTP 500
# @raise [Fog::Rackspace::Queues::ServiceError]
def dequeue(ttl, grace, options = {}, &block)
claim = claims.create(
options.merge(
@ -56,12 +100,31 @@ module Fog
end
end
# Creates queue
# Requires name attribute to be populated
#
# @return [Boolean] returns true if queue has been succesfully saved
#
# @raise [Fog::Rackspace::Queues::NotFound] - HTTP 404
# @raise [Fog::Rackspace::Queues::BadRequest] - HTTP 400
# @raise [Fog::Rackspace::Queues::InternalServerError] - HTTP 500
# @raise [Fog::Rackspace::Queues::ServiceError]
# @see http://docs.rackspace.com/queues/api/v1.0/cq-devguide/content/POST_postMessage__version__queues__queue_name__messages_message-operations-dle001.html
def save
requires :name
data = service.create_queue(name)
true
end
# Destroys queue
#
# @return [Boolean] returns true if queue is deleted
#
# @raise [Fog::Rackspace::Queues::NotFound] - HTTP 404
# @raise [Fog::Rackspace::Queues::BadRequest] - HTTP 400
# @raise [Fog::Rackspace::Queues::InternalServerError] - HTTP 500
# @raise [Fog::Rackspace::Queues::ServiceError]
# @see http://docs.rackspace.com/queues/api/v1.0/cq-devguide/content/DELETE_deleteQueue__version__queues__queue_name__queue-operations-dle001.html
def destroy
requires :name
service.delete_queue(name)

View file

@ -8,6 +8,13 @@ module Fog
model Fog::Rackspace::Queues::Queue
# Returns list of queues
#
# @return [Fog::Rackspace::Queues::Queues] Retrieves a collection of queues.
# @raise [Fog::Rackspace::Queues::NotFound] - HTTP 404
# @raise [Fog::Rackspace::Queues::BadRequest] - HTTP 400
# @raise [Fog::Rackspace::Queues::InternalServerError] - HTTP 500
# @see http://docs.rackspace.com/queues/api/v1.0/cq-devguide/content/GET_listQueues__version__queues_.html
def all
response = service.list_queues
if service.list_queues.status == 204
@ -18,6 +25,14 @@ module Fog
load(data)
end
# This operation queries the specified queue.
#
# @param [String] queue_name Specifies the queue name
# @return [Fog::Rackspace::Queues::Queue] Returns a queue
# @raise [Fog::Rackspace::Queues::BadRequest] - HTTP 400
# @raise [Fog::Rackspace::Queues::InternalServerError] - HTTP 500
# @raise [Fog::Rackspace::Queues::ServiceError]
# @see http://docs.rackspace.com/queues/api/v1.0/cq-devguide/content/GET_checkQueueExists__version__queues__queue_name__queue-operations-dle001.html
def get(queue_name)
#204 no content is returned on success. That's why no data is passed
# from the GET to the constructor.

View file

@ -139,7 +139,7 @@ module Fog
end
# Set last modified
# @param [String, Fog::Time] timestamp
# @param [String, Fog::Time] obj
def last_modified=(obj)
if obj.nil? || obj == "" || obj.is_a?(Time)
attributes[:last_modified] = obj

View file

@ -4,7 +4,7 @@ module Fog
class Real
# Delete the key specified with key_name
# @param [String] key_name: name of the key to delete
# @param [String] key_name name of the key to delete
# @return [Excon::Response] response
# @raise [Fog::Compute::RackspaceV2::NotFound]
# @raise [Fog::Compute::RackspaceV2::BadRequest]

View file

@ -4,7 +4,7 @@ module Fog
class Real
# Retreive single keypair details
# @param [String] key_name: name of the key for which to request the details
# @param [String] key_name name of the key for which to request the details
# @return [Excon::Response] response :
# * body [Hash]: -
# * 'keypair' [Hash]: -

View file

@ -8,9 +8,9 @@ module Fog
#
# @param [String] client_id UUID for the client instance.
# @param [String] queue_name Specifies the name of the queue.
# @param [String, Hash, Array] body The body attribute specifies an arbitrary document that constitutes the body of the message being sent. The size of this body is limited to 256 KB, excluding whitespace. The document must be valid JSON.
# @param [String, Hash, Array] body The body attribute specifies an arbitrary document that constitutes the body of the message being sent.
# The size of this body is limited to 256 KB, excluding whitespace. The document must be valid JSON.
# @param [Integer] ttl The ttl attribute specifies how long the server waits before releasing the claim. The ttl value must be between 60 and 43200 seconds (12 hours).
# @param [Integer] grace The grace attribute specifies the message grace period in seconds. The value of grace value must be between 60 and 43200 seconds (12 hours).
# @return [Excon::Response] response
# @raise [Fog::Rackspace::Queues::NotFound] - HTTP 404
# @raise [Fog::Rackspace::Queues::BadRequest] - HTTP 400

View file

@ -7,7 +7,7 @@ module Fog
# Claims with malformed IDs or claims that are not found by ID are ignored.
#
# @param [String] queue_name Specifies the name of the queue.
# @param [String] Specifies the claim ID.
# @param [String] claim_id Specifies the claim ID.
# @return [Excon::Response] response
# @raise [Fog::Rackspace::Queues::NotFound] - HTTP 404
# @raise [Fog::Rackspace::Queues::BadRequest] - HTTP 400

View file

@ -4,7 +4,6 @@ module Fog
class Real
# This operation gets the specified message from the specified queue.
# If no unclaimed messages are available, the API returns a 204 No Content message.
#
# @param [String] client_id UUID for the client instance.
# @param [String] queue_name Specifies the name of the queue.

View file

@ -11,10 +11,17 @@ module Fog
# @param [String] client_id UUID for the client instance.
# @param [String] queue_name Specifies the name of the queue.
# @param [Hash] options
# @option options [String] :marker - Specifies an opaque string that the client can use to request the next batch of messages. The marker parameter communicates to the server which messages the client has already received. If you do not specify a value, the API returns all messages at the head of the queue (up to the limit).
# @option options [Integer] :limit - When more messages are available than can be returned in a single request, the client can pick up the next batch of messages by simply using the URI template parameters returned from the previous call in the "next" field. Specifies up to 10 messages (the default value) to return. If you do not specify a value for the limit parameter, the default value of 10 is used.
# @option options [String] :echo - Determines whether the API returns a client's own messages. The echo parameter is a Boolean value (true or false) that determines whether the API returns a client's own messages, as determined by the uuid portion of the User-Agent header. If you do not specify a value, echo uses the default value of false. If you are experimenting with the API, you might want to set echo=true in order to see the messages that you posted.
# @option options [String] :include_claimed - Determines whether the API returns claimed messages and unclaimed messages. The include_claimed parameter is a Boolean value (true or false) that determines whether the API returns claimed messages and unclaimed messages. If you do not specify a value, include_claimed uses the default value of false (only unclaimed messages are returned).
# @option options [String] :marker - Specifies an opaque string that the client can use to request the next batch of messages. The marker parameter communicates to the
# server which messages the client has already received. If you do not specify a value, the API returns all messages at the head of the queue (up to the limit).
# @option options [Integer] :limit - When more messages are available than can be returned in a single request, the client can pick up the next batch of messages
# by simply using the URI template parameters returned from the previous call in the "next" field. Specifies up to 10 messages (the default value) to return.
# If you do not specify a value for the limit parameter, the default value of 10 is used.
# @option options [String] :echo - Determines whether the API returns a client's own messages. The echo parameter is a Boolean value (true or false) that determines
# whether the API returns a client's own messages, as determined by the uuid portion of the User-Agent header. If you do not specify a value, echo uses the default
# value of false. If you are experimenting with the API, you might want to set echo=true in order to see the messages that you posted.
# @option options [String] :include_claimed - Determines whether the API returns claimed messages and unclaimed messages. The include_claimed parameter is a Boolean
# value (true or false) that determines whether the API returns claimed messages and unclaimed messages. If you do not specify a value, include_claimed uses the
# default value of false (only unclaimed messages are returned).
# @return [Excon::Response] response
# @raise [Fog::Rackspace::Queues::NotFound] - HTTP 404
# @raise [Fog::Rackspace::Queues::BadRequest] - HTTP 400