Skip to content

Commit

Permalink
Add permissions methods to Queue class. Cleaned up some doc strings.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mitch.Garnaat authored and Mitch.Garnaat committed Jul 2, 2009
1 parent 708eceb commit f79c9de
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 7 deletions.
8 changes: 4 additions & 4 deletions boto/sqs/connection.py
Expand Up @@ -39,8 +39,6 @@ class SQSConnection(AWSQueryConnection):
SignatureVersion = '2'
DefaultContentType = 'text/plain'
ResponseError = SQSError
ValidActions = ['SQS:*', 'SQS:SendMessage', 'SQS:ReceiveMessage', 'SQS:DeleteMessage',
'SQS:ChangeMessageVisibility', 'SQS:GetQueueAttributes']

def __init__(self, aws_access_key_id=None, aws_secret_access_key=None,
is_secure=True, port=None, proxy=None, proxy_port=None,
Expand Down Expand Up @@ -215,7 +213,9 @@ def add_permission(self, queue, label, aws_account_id, action_name):
about locating the AWS account identification.
@type action_name: str or unicode
@param action_name: The action. See ValidActions attributes for details.
@param action_name: The action. Valid choices are:
*|SendMessage|ReceiveMessage|DeleteMessage|
ChangeMessageVisibility|GetQueueAttributes
@rtype: bool
@return: True if successful, False otherwise.
Expand All @@ -228,7 +228,7 @@ def add_permission(self, queue, label, aws_account_id, action_name):

def remove_permission(self, queue, label):
"""
Add a permission to a queue.
Remove a permission from a queue.
@type queue: L{Queue<boto.sqs.queue.Queue>}
@param queue: The queue object
Expand Down
44 changes: 41 additions & 3 deletions boto/sqs/queue.py
Expand Up @@ -82,9 +82,9 @@ def get_attributes(self, attributes='All'):
them in an Attribute instance (subclass of a Dictionary).
@type attributes: string
@param attributes: String containing one of
All|ApproximateNumberOfMessages|VisibilityTimeout
Default value is "All"
@param attributes: String containing one of:
ApproximateNumberOfMessages, VisibilityTimeout, CreatedTimestamp,
LastModifiedTimestamp, Policy.
@rtype: Attribute object
@return: An Attribute object which is a mapping type holding the
requested name/value pairs
Expand Down Expand Up @@ -130,6 +130,44 @@ def set_timeout(self, visibility_timeout):
self.visibility_timeout = visibility_timeout
return retval

def add_permission(self, label, aws_account_id, action_name):
"""
Add a permission to a queue.
@type label: str or unicode
@param label: A unique identification of the permission you are setting.
Maximum of 80 characters [0-9a-zA-Z_-]
Example, AliceSendMessage
@type aws_account_id: str or unicode
@param principal_id: The AWS account number of the principal who will be given
permission. The principal must have an AWS account, but
does not need to be signed up for Amazon SQS. For information
about locating the AWS account identification.
@type action_name: str or unicode
@param action_name: The action. Valid choices are:
*|SendMessage|ReceiveMessage|DeleteMessage|
ChangeMessageVisibility|GetQueueAttributes
@rtype: bool
@return: True if successful, False otherwise.
"""
return self.connection.add_permission(self, label, aws_account_id, action_name)

def remove_permission(self, label):
"""
Remove a permission from a queue.
@type label: str or unicode
@param label: The unique label associated with the permission being removed.
@rtype: bool
@return: True if successful, False otherwise.
"""
return self.connection.remove_permission(self, label)

def read(self, visibility_timeout=None):
"""
Read a single message from the queue.
Expand Down

0 comments on commit f79c9de

Please sign in to comment.