diff options
Diffstat (limited to 'boto/sqs/queue.py')
-rw-r--r-- | boto/sqs/queue.py | 90 |
1 files changed, 65 insertions, 25 deletions
diff --git a/boto/sqs/queue.py b/boto/sqs/queue.py index 0ecb1f2c..ca5593c1 100644 --- a/boto/sqs/queue.py +++ b/boto/sqs/queue.py @@ -67,9 +67,10 @@ class Queue: def set_message_class(self, message_class): """ - Set the message class that should be used when instantiating messages read - from the queue. By default, the class boto.sqs.message.Message is used but - this can be overriden with any class that behaves like a message. + Set the message class that should be used when instantiating + messages read from the queue. By default, the class + :class:`boto.sqs.message.Message` is used but this can be overriden + with any class that behaves like a message. :type message_class: Message-like class :param message_class: The new Message class @@ -104,8 +105,8 @@ class Queue: only valid value at this time is: VisibilityTimeout :type value: int :param value: The new value for the attribute. - For VisibilityTimeout the value must be an - integer number of seconds from 0 to 86400. + For VisibilityTimeout the value must be an + integer number of seconds from 0 to 86400. :rtype: bool :return: True if successful, otherwise False. @@ -140,32 +141,34 @@ class 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 + 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. + :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 + *|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) + 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. + :param label: The unique label associated with the permission + being removed. :rtype: bool :return: True if successful, False otherwise. @@ -198,11 +201,29 @@ class Queue: :rtype: :class:`boto.sqs.message.Message` :return: The :class:`boto.sqs.message.Message` object that was written. """ - new_msg = self.connection.send_message(self, message.get_body_encoded(), delay_seconds) + new_msg = self.connection.send_message(self, + message.get_body_encoded(), + delay_seconds) message.id = new_msg.id message.md5 = new_msg.md5 return message + def write_batch(self, messages): + """ + Delivers up to 10 messages in a single request. + + :type messages: List of lists. + :param messages: A list of lists or tuples. Each inner + tuple represents a single message to be written + and consists of and ID (string) that must be unique + within the list of messages, the message body itself + which can be a maximum of 64K in length, and an + integer which represents the delay time (in seconds) + for the message (0-900) before the message will + be delivered to the queue. + """ + return self.connection.send_message_batch(self, messages) + def new_message(self, body=''): """ Create new message of appropriate class. @@ -224,20 +245,18 @@ class Queue: Get a variable number of messages. :type num_messages: int - :param num_messages: The maximum number of messages to read from the queue. + :param num_messages: The maximum number of messages to read from + the queue. :type visibility_timeout: int :param visibility_timeout: The VisibilityTimeout for the messages read. :type attributes: str - :param attributes: The name of additional attribute to return with response - or All if you want all attributes. The default is to - return no additional attributes. Valid values: - All - SenderId - SentTimestamp - ApproximateReceiveCount - ApproximateFirstReceiveTimestamp + :param attributes: The name of additional attribute to return + with response or All if you want all attributes. The + default is to return no additional attributes. Valid + values: All SenderId SentTimestamp ApproximateReceiveCount + ApproximateFirstReceiveTimestamp :rtype: list :return: A list of :class:`boto.sqs.message.Message` objects. @@ -258,6 +277,27 @@ class Queue: """ return self.connection.delete_message(self, message) + def delete_message_batch(self, messages): + """ + Deletes a list of messages in a single request. + + :type messages: List of :class:`boto.sqs.message.Message` objects. + :param messages: A list of message objects. + """ + return self.connection.delete_message_batch(self, messages) + + def change_message_visibility_batch(self, messages): + """ + A batch version of change_message_visibility that can act + on up to 10 messages at a time. + + :type messages: List of tuples. + :param messages: A list of tuples where each tuple consists + of a :class:`boto.sqs.message.Message` object and an integer + that represents the new visibility timeout for that message. + """ + return self.connection.change_message_visibility_batch(self, messages) + def delete(self): """ Delete the queue. |