Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(156)

Side by Side Diff: boto/sqs/connection.py

Issue 8669001: Pull in upstream boto from github at bcb719937de9ac2851e632d62b777352029a6d55 (Closed) Base URL: svn://svn.chromium.org/boto
Patch Set: Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « boto/sqs/__init__.py ('k') | boto/sqs/queue.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2006-2009 Mitch Garnaat http://garnaat.org/ 1 # Copyright (c) 2006-2009 Mitch Garnaat http://garnaat.org/
2 # 2 #
3 # Permission is hereby granted, free of charge, to any person obtaining a 3 # Permission is hereby granted, free of charge, to any person obtaining a
4 # copy of this software and associated documentation files (the 4 # copy of this software and associated documentation files (the
5 # "Software"), to deal in the Software without restriction, including 5 # "Software"), to deal in the Software without restriction, including
6 # without limitation the rights to use, copy, modify, merge, publish, dis- 6 # without limitation the rights to use, copy, modify, merge, publish, dis-
7 # tribute, sublicense, and/or sell copies of the Software, and to permit 7 # tribute, sublicense, and/or sell copies of the Software, and to permit
8 # persons to whom the Software is furnished to do so, subject to the fol- 8 # persons to whom the Software is furnished to do so, subject to the fol-
9 # lowing conditions: 9 # lowing conditions:
10 # 10 #
(...skipping 15 matching lines...) Expand all
26 from boto.sqs.attributes import Attributes 26 from boto.sqs.attributes import Attributes
27 from boto.exception import SQSError 27 from boto.exception import SQSError
28 28
29 29
30 class SQSConnection(AWSQueryConnection): 30 class SQSConnection(AWSQueryConnection):
31 """ 31 """
32 A Connection to the SQS Service. 32 A Connection to the SQS Service.
33 """ 33 """
34 DefaultRegionName = 'us-east-1' 34 DefaultRegionName = 'us-east-1'
35 DefaultRegionEndpoint = 'queue.amazonaws.com' 35 DefaultRegionEndpoint = 'queue.amazonaws.com'
36 APIVersion = '2009-02-01' 36 APIVersion = '2011-10-01'
37 DefaultContentType = 'text/plain' 37 DefaultContentType = 'text/plain'
38 ResponseError = SQSError 38 ResponseError = SQSError
39 39
40 def __init__(self, aws_access_key_id=None, aws_secret_access_key=None, 40 def __init__(self, aws_access_key_id=None, aws_secret_access_key=None,
41 is_secure=True, port=None, proxy=None, proxy_port=None, 41 is_secure=True, port=None, proxy=None, proxy_port=None,
42 proxy_user=None, proxy_pass=None, debug=0, 42 proxy_user=None, proxy_pass=None, debug=0,
43 https_connection_factory=None, region=None, path='/', 43 https_connection_factory=None, region=None, path='/',
44 security_token=None): 44 security_token=None):
45 if not region: 45 if not region:
46 region = SQSRegionInfo(self, self.DefaultRegionName, 46 region = SQSRegionInfo(self, self.DefaultRegionName,
47 self.DefaultRegionEndpoint) 47 self.DefaultRegionEndpoint)
48 self.region = region 48 self.region = region
49 AWSQueryConnection.__init__(self, aws_access_key_id, 49 AWSQueryConnection.__init__(self, aws_access_key_id,
(...skipping 28 matching lines...) Expand all
78 :param visibility_timeout: The default visibility timeout for all 78 :param visibility_timeout: The default visibility timeout for all
79 messages written in the queue. This can 79 messages written in the queue. This can
80 be overridden on a per-message. 80 be overridden on a per-message.
81 81
82 :rtype: :class:`boto.sqs.queue.Queue` 82 :rtype: :class:`boto.sqs.queue.Queue`
83 :return: The newly created queue. 83 :return: The newly created queue.
84 84
85 """ 85 """
86 params = {'QueueName': queue_name} 86 params = {'QueueName': queue_name}
87 if visibility_timeout: 87 if visibility_timeout:
88 params['DefaultVisibilityTimeout'] = '%d' % (visibility_timeout,) 88 params['Attribute.1.Name'] = 'VisibilityTimeout'
89 params['Attribute.1.Value'] = int(visibility_timeout)
89 return self.get_object('CreateQueue', params, Queue) 90 return self.get_object('CreateQueue', params, Queue)
90 91
91 def delete_queue(self, queue, force_deletion=False): 92 def delete_queue(self, queue, force_deletion=False):
92 """ 93 """
93 Delete an SQS Queue. 94 Delete an SQS Queue.
94 95
95 :type queue: A Queue object 96 :type queue: A Queue object
96 :param queue: The SQS queue to be deleted 97 :param queue: The SQS queue to be deleted
97 98
98 :type force_deletion: Boolean 99 :type force_deletion: Boolean
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 204
204 :type receipt_handle: str 205 :type receipt_handle: str
205 :param receipt_handle: The receipt handle for the message 206 :param receipt_handle: The receipt handle for the message
206 207
207 :rtype: bool 208 :rtype: bool
208 :return: True if successful, False otherwise. 209 :return: True if successful, False otherwise.
209 """ 210 """
210 params = {'ReceiptHandle' : receipt_handle} 211 params = {'ReceiptHandle' : receipt_handle}
211 return self.get_status('DeleteMessage', params, queue.id) 212 return self.get_status('DeleteMessage', params, queue.id)
212 213
213 def send_message(self, queue, message_content): 214 def send_message(self, queue, message_content, delay_seconds=None):
214 params = {'MessageBody' : message_content} 215 params = {'MessageBody' : message_content}
216 if delay_seconds:
217 params['DelaySeconds'] = int(delay_seconds)
215 return self.get_object('SendMessage', params, Message, 218 return self.get_object('SendMessage', params, Message,
216 queue.id, verb='POST') 219 queue.id, verb='POST')
217 220
218 def change_message_visibility(self, queue, receipt_handle, 221 def change_message_visibility(self, queue, receipt_handle,
219 visibility_timeout): 222 visibility_timeout):
220 """ 223 """
221 Extends the read lock timeout for the specified message from 224 Extends the read lock timeout for the specified message from
222 the specified queue to the specified value. 225 the specified queue to the specified value.
223 226
224 :type queue: A :class:`boto.sqs.queue.Queue` object 227 :type queue: A :class:`boto.sqs.queue.Queue` object
225 :param queue: The Queue from which messages are read. 228 :param queue: The Queue from which messages are read.
226 229
227 :type receipt_handle: str 230 :type receipt_handle: str
228 :param queue: The receipt handle associated with the message whose 231 :param queue: The receipt handle associated with the message whose
229 visibility timeout will be changed. 232 visibility timeout will be changed.
230 233
231 :type visibility_timeout: int 234 :type visibility_timeout: int
232 :param visibility_timeout: The new value of the message's visibility 235 :param visibility_timeout: The new value of the message's visibility
233 timeout in seconds. 236 timeout in seconds.
234 """ 237 """
235 params = {'ReceiptHandle' : receipt_handle, 238 params = {'ReceiptHandle' : receipt_handle,
236 'VisibilityTimeout' : visibility_timeout} 239 'VisibilityTimeout' : visibility_timeout}
237 return self.get_status('ChangeMessageVisibility', params, queue.id) 240 return self.get_status('ChangeMessageVisibility', params, queue.id)
238 241
239 def get_all_queues(self, prefix=''): 242 def get_all_queues(self, prefix=''):
240 params = {} 243 params = {}
241 if prefix: 244 if prefix:
242 params['QueueNamePrefix'] = prefix 245 params['QueueNamePrefix'] = prefix
243 return self.get_list('ListQueues', params, [('QueueUrl', Queue)]) 246 return self.get_list('ListQueues', params, [('QueueUrl', Queue)])
244 247
245 def get_queue(self, queue_name): 248 def get_queue(self, queue_name):
246 rs = self.get_all_queues(queue_name) 249 rs = self.get_all_queues(queue_name)
247 for q in rs: 250 for q in rs:
248 if q.url.endswith(queue_name): 251 if q.url.endswith(queue_name):
249 return q 252 return q
250 return None 253 return None
251 254
252 lookup = get_queue 255 lookup = get_queue
253 256
254 # 257 #
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 :type label: str or unicode 301 :type label: str or unicode
299 :param label: The unique label associated with the permission 302 :param label: The unique label associated with the permission
300 being removed. 303 being removed.
301 304
302 :rtype: bool 305 :rtype: bool
303 :return: True if successful, False otherwise. 306 :return: True if successful, False otherwise.
304 """ 307 """
305 params = {'Label': label} 308 params = {'Label': label}
306 return self.get_status('RemovePermission', params, queue.id) 309 return self.get_status('RemovePermission', params, queue.id)
307 310
308
309
310 311
311 312
313
314
OLDNEW
« no previous file with comments | « boto/sqs/__init__.py ('k') | boto/sqs/queue.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698