1
# Copyright (c) 2010 Chris Moyer http://coredumped.org/
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-
11
# The above copyright notice and this permission notice shall be included
12
# in all copies or substantial portions of the Software.
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
23
from boto.connection import AWSQueryConnection, AWSAuthConnection
27
from boto.ecs.item import ItemSet
28
from boto import handler
30
class ECSConnection(AWSQueryConnection):
34
For more information on how to use this module see:
36
http://blog.coredumped.org/2010/09/search-for-books-on-amazon-using-boto.html
39
APIVersion = '2010-11-01'
41
def __init__(self, aws_access_key_id=None, aws_secret_access_key=None,
42
is_secure=True, port=None, proxy=None, proxy_port=None,
43
proxy_user=None, proxy_pass=None, host='ecs.amazonaws.com',
44
debug=0, https_connection_factory=None, path='/'):
45
AWSQueryConnection.__init__(self, aws_access_key_id, aws_secret_access_key,
46
is_secure, port, proxy, proxy_port, proxy_user, proxy_pass,
47
host, debug, https_connection_factory, path)
49
def _required_auth_capability(self):
52
def get_response(self, action, params, page=0, itemSet=None):
54
Utility method to handle calls to ECS and parsing of responses.
56
params['Service'] = "AWSECommerceService"
57
params['Operation'] = action
59
params['ItemPage'] = page
60
response = self.make_request(None, params, "/onca/xml")
61
body = response.read()
64
if response.status != 200:
65
boto.log.error('%s %s' % (response.status, response.reason))
66
boto.log.error('%s' % body)
67
raise self.ResponseError(response.status, response.reason, body)
70
rs = ItemSet(self, action, params, page)
73
h = handler.XmlHandler(rs, self)
74
xml.sax.parseString(body, h)
81
def item_search(self, search_index, **params):
83
Returns items that satisfy the search criteria, including one or more search
86
For a full list of search terms,
87
:see: http://docs.amazonwebservices.com/AWSECommerceService/2010-09-01/DG/index.html?ItemSearch.html
89
params['SearchIndex'] = search_index
90
return self.get_response('ItemSearch', params)