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

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

Issue 8386013: Merging in latest boto. (Closed) Base URL: svn://svn.chromium.org/boto
Patch Set: Redoing vendor drop by deleting and then merging. 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/sns/__init__.py ('k') | boto/sqs/__init__.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) 2010 Mitch Garnaat http://garnaat.org/ 1 # Copyright (c) 2010 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 #
11 # The above copyright notice and this permission notice shall be included 11 # The above copyright notice and this permission notice shall be included
12 # in all copies or substantial portions of the Software. 12 # in all copies or substantial portions of the Software.
13 # 13 #
14 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- 15 # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
16 # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 16 # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
17 # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 17 # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
18 # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 19 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 # IN THE SOFTWARE. 20 # IN THE SOFTWARE.
21 21
22 from boto.connection import AWSQueryConnection 22 from boto.connection import AWSQueryConnection
23 from boto.sdb.regioninfo import SDBRegionInfo 23 from boto.regioninfo import RegionInfo
24 import boto 24 import boto
25 import uuid 25 import uuid
26 try: 26 try:
27 import simplejson as json
28 except ImportError:
27 import json 29 import json
28 except ImportError:
29 import simplejson as json
30
31 #boto.set_stream_logger('sns')
32 30
33 class SNSConnection(AWSQueryConnection): 31 class SNSConnection(AWSQueryConnection):
34 32
35 DefaultRegionName = 'us-east-1' 33 DefaultRegionName = 'us-east-1'
36 DefaultRegionEndpoint = 'sns.us-east-1.amazonaws.com' 34 DefaultRegionEndpoint = 'sns.us-east-1.amazonaws.com'
37 APIVersion = '2010-03-31' 35 APIVersion = '2010-03-31'
38 36
39 def __init__(self, aws_access_key_id=None, aws_secret_access_key=None, 37 def __init__(self, aws_access_key_id=None, aws_secret_access_key=None,
40 is_secure=True, port=None, proxy=None, proxy_port=None, 38 is_secure=True, port=None, proxy=None, proxy_port=None,
41 proxy_user=None, proxy_pass=None, debug=0, 39 proxy_user=None, proxy_pass=None, debug=0,
42 https_connection_factory=None, region=None, path='/', converter =None): 40 https_connection_factory=None, region=None, path='/',
41 security_token=None):
43 if not region: 42 if not region:
44 region = SDBRegionInfo(self, self.DefaultRegionName, self.DefaultReg ionEndpoint) 43 region = RegionInfo(self, self.DefaultRegionName,
44 self.DefaultRegionEndpoint,
45 connection_cls=SNSConnection)
45 self.region = region 46 self.region = region
46 AWSQueryConnection.__init__(self, aws_access_key_id, aws_secret_access_k ey, 47 AWSQueryConnection.__init__(self, aws_access_key_id,
47 is_secure, port, proxy, proxy_port, proxy_us er, proxy_pass, 48 aws_secret_access_key,
48 self.region.endpoint, debug, https_connectio n_factory, path) 49 is_secure, port, proxy, proxy_port,
50 proxy_user, proxy_pass,
51 self.region.endpoint, debug,
52 https_connection_factory, path,
53 security_token=security_token)
49 54
50 def _required_auth_capability(self): 55 def _required_auth_capability(self):
51 return ['sns'] 56 return ['sns']
52 57
53 def get_all_topics(self, next_token=None): 58 def get_all_topics(self, next_token=None):
54 """ 59 """
55 :type next_token: string 60 :type next_token: string
56 :param next_token: Token returned by the previous call to 61 :param next_token: Token returned by the previous call to
57 this method. 62 this method.
58 63
(...skipping 22 matching lines...) Expand all
81 'TopicArn' : topic} 86 'TopicArn' : topic}
82 response = self.make_request('GetTopicAttributes', params, '/', 'GET') 87 response = self.make_request('GetTopicAttributes', params, '/', 'GET')
83 body = response.read() 88 body = response.read()
84 if response.status == 200: 89 if response.status == 200:
85 return json.loads(body) 90 return json.loads(body)
86 else: 91 else:
87 boto.log.error('%s %s' % (response.status, response.reason)) 92 boto.log.error('%s %s' % (response.status, response.reason))
88 boto.log.error('%s' % body) 93 boto.log.error('%s' % body)
89 raise self.ResponseError(response.status, response.reason, body) 94 raise self.ResponseError(response.status, response.reason, body)
90 95
96 def set_topic_attributes(self, topic, attr_name, attr_value):
97 """
98 Get attributes of a Topic
99
100 :type topic: string
101 :param topic: The ARN of the topic.
102
103 :type attr_name: string
104 :param attr_name: The name of the attribute you want to set.
105 Only a subset of the topic's attributes are mutable.
106 Valid values: Policy | DisplayName
107
108 :type attr_value: string
109 :param attr_value: The new value for the attribute.
110
111 """
112 params = {'ContentType' : 'JSON',
113 'TopicArn' : topic,
114 'AttributeName' : attr_name,
115 'AttributeValue' : attr_value}
116 response = self.make_request('SetTopicAttributes', params, '/', 'GET')
117 body = response.read()
118 if response.status == 200:
119 return json.loads(body)
120 else:
121 boto.log.error('%s %s' % (response.status, response.reason))
122 boto.log.error('%s' % body)
123 raise self.ResponseError(response.status, response.reason, body)
124
91 def add_permission(self, topic, label, account_ids, actions): 125 def add_permission(self, topic, label, account_ids, actions):
92 """ 126 """
93 Adds a statement to a topic's access control policy, granting 127 Adds a statement to a topic's access control policy, granting
94 access for the specified AWS accounts to the specified actions. 128 access for the specified AWS accounts to the specified actions.
95 129
96 :type topic: string 130 :type topic: string
97 :param topic: The ARN of the topic. 131 :param topic: The ARN of the topic.
98 132
99 :type label: string 133 :type label: string
100 :param label: A unique identifier for the new policy statement. 134 :param label: A unique identifier for the new policy statement.
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 265
232 :type endpoint: string 266 :type endpoint: string
233 :param endpoint: The location of the endpoint for 267 :param endpoint: The location of the endpoint for
234 the subscriber. 268 the subscriber.
235 * For email, this would be a valid email address 269 * For email, this would be a valid email address
236 * For email-json, this would be a valid email address 270 * For email-json, this would be a valid email address
237 * For http, this would be a URL beginning with http 271 * For http, this would be a URL beginning with http
238 * For https, this would be a URL beginning with https 272 * For https, this would be a URL beginning with https
239 * For sqs, this would be the ARN of an SQS Queue 273 * For sqs, this would be the ARN of an SQS Queue
240 274
241 :rtype: :class:`boto.sdb.domain.Domain` object
242 :return: The newly created domain
243 """ 275 """
244 params = {'ContentType' : 'JSON', 276 params = {'ContentType' : 'JSON',
245 'TopicArn' : topic, 277 'TopicArn' : topic,
246 'Protocol' : protocol, 278 'Protocol' : protocol,
247 'Endpoint' : endpoint} 279 'Endpoint' : endpoint}
248 response = self.make_request('Subscribe', params, '/', 'GET') 280 response = self.make_request('Subscribe', params, '/', 'GET')
249 body = response.read() 281 body = response.read()
250 if response.status == 200: 282 if response.status == 200:
251 return json.loads(body) 283 return json.loads(body)
252 else: 284 else:
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 412
381 :type next_token: string 413 :type next_token: string
382 :param next_token: Token returned by the previous call to 414 :param next_token: Token returned by the previous call to
383 this method. 415 this method.
384 416
385 """ 417 """
386 params = {'ContentType' : 'JSON', 418 params = {'ContentType' : 'JSON',
387 'TopicArn' : topic} 419 'TopicArn' : topic}
388 if next_token: 420 if next_token:
389 params['NextToken'] = next_token 421 params['NextToken'] = next_token
390 response = self.make_request('ListSubscriptions', params, '/', 'GET') 422 response = self.make_request('ListSubscriptionsByTopic', params,
423 '/', 'GET')
391 body = response.read() 424 body = response.read()
392 if response.status == 200: 425 if response.status == 200:
393 return json.loads(body) 426 return json.loads(body)
394 else: 427 else:
395 boto.log.error('%s %s' % (response.status, response.reason)) 428 boto.log.error('%s %s' % (response.status, response.reason))
396 boto.log.error('%s' % body) 429 boto.log.error('%s' % body)
397 raise self.ResponseError(response.status, response.reason, body) 430 raise self.ResponseError(response.status, response.reason, body)
398 431
OLDNEW
« no previous file with comments | « boto/sns/__init__.py ('k') | boto/sqs/__init__.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698