Mercurial > repos > guerler > springsuite
comparison planemo/lib/python3.7/site-packages/boto/ecs/__init__.py @ 0:d30785e31577 draft
"planemo upload commit 6eee67778febed82ddd413c3ca40b3183a3898f1"
author | guerler |
---|---|
date | Fri, 31 Jul 2020 00:18:57 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:d30785e31577 |
---|---|
1 # Copyright (c) 2010 Chris Moyer http://coredumped.org/ | |
2 # | |
3 # Permission is hereby granted, free of charge, to any person obtaining a | |
4 # copy of this software and associated documentation files (the | |
5 # "Software"), to deal in the Software without restriction, including | |
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 | |
8 # persons to whom the Software is furnished to do so, subject to the fol- | |
9 # lowing conditions: | |
10 # | |
11 # The above copyright notice and this permission notice shall be included | |
12 # in all copies or substantial portions of the Software. | |
13 # | |
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- | |
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, | |
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 | |
20 # IN THE SOFTWARE. | |
21 | |
22 import boto | |
23 from boto.connection import AWSQueryConnection, AWSAuthConnection | |
24 from boto.exception import BotoServerError | |
25 import time | |
26 import urllib | |
27 import xml.sax | |
28 from boto.ecs.item import ItemSet | |
29 from boto import handler | |
30 | |
31 class ECSConnection(AWSQueryConnection): | |
32 """ | |
33 ECommerce Connection | |
34 | |
35 For more information on how to use this module see: | |
36 | |
37 http://blog.coredumped.org/2010/09/search-for-books-on-amazon-using-boto.html | |
38 """ | |
39 | |
40 APIVersion = '2010-11-01' | |
41 | |
42 def __init__(self, aws_access_key_id=None, aws_secret_access_key=None, | |
43 is_secure=True, port=None, proxy=None, proxy_port=None, | |
44 proxy_user=None, proxy_pass=None, host='ecs.amazonaws.com', | |
45 debug=0, https_connection_factory=None, path='/', | |
46 security_token=None, profile_name=None): | |
47 super(ECSConnection, self).__init__(aws_access_key_id, aws_secret_access_key, | |
48 is_secure, port, proxy, proxy_port, proxy_user, proxy_pass, | |
49 host, debug, https_connection_factory, path, | |
50 security_token=security_token, | |
51 profile_name=profile_name) | |
52 | |
53 def _required_auth_capability(self): | |
54 return ['ecs'] | |
55 | |
56 def get_response(self, action, params, page=0, itemSet=None): | |
57 """ | |
58 Utility method to handle calls to ECS and parsing of responses. | |
59 """ | |
60 params['Service'] = "AWSECommerceService" | |
61 params['Operation'] = action | |
62 if page: | |
63 params['ItemPage'] = page | |
64 response = self.make_request(None, params, "/onca/xml") | |
65 body = response.read().decode('utf-8') | |
66 boto.log.debug(body) | |
67 | |
68 if response.status != 200: | |
69 boto.log.error('%s %s' % (response.status, response.reason)) | |
70 boto.log.error('%s' % body) | |
71 raise BotoServerError(response.status, response.reason, body) | |
72 | |
73 if itemSet is None: | |
74 rs = ItemSet(self, action, params, page) | |
75 else: | |
76 rs = itemSet | |
77 h = handler.XmlHandler(rs, self) | |
78 xml.sax.parseString(body.encode('utf-8'), h) | |
79 if not rs.is_valid: | |
80 raise BotoServerError(response.status, '{Code}: {Message}'.format(**rs.errors[0])) | |
81 return rs | |
82 | |
83 # | |
84 # Group methods | |
85 # | |
86 | |
87 def item_search(self, search_index, **params): | |
88 """ | |
89 Returns items that satisfy the search criteria, including one or more search | |
90 indices. | |
91 | |
92 For a full list of search terms, | |
93 :see: http://docs.amazonwebservices.com/AWSECommerceService/2010-09-01/DG/index.html?ItemSearch.html | |
94 """ | |
95 params['SearchIndex'] = search_index | |
96 return self.get_response('ItemSearch', params) | |
97 | |
98 def item_lookup(self, **params): | |
99 """ | |
100 Returns items that satisfy the lookup query. | |
101 | |
102 For a full list of parameters, see: | |
103 http://s3.amazonaws.com/awsdocs/Associates/2011-08-01/prod-adv-api-dg-2011-08-01.pdf | |
104 """ | |
105 return self.get_response('ItemLookup', params) |