def prepare_request(self, api_info, params, doseq=0): for key in params: if type(params[key]) == int or type(params[key]) == float: params[key] = str(params[key]) elif type(params[key]) == list: if not doseq: params[key] = ','.join(params[key]) connection_timeout = self.service_info.connection_timeout socket_timeout = self.service_info.socket_timeout r = Request() r.set_shema(self.service_info.scheme) r.set_method(api_info.method) r.set_connection_timeout(connection_timeout) r.set_socket_timeout(socket_timeout) mheaders = self.merge(api_info.header, self.service_info.header) mheaders['Host'] = self.service_info.host r.set_headers(mheaders) mquery = self.merge(api_info.query, params) r.set_query(mquery) r.set_host(self.service_info.host) r.set_path(api_info.path) return r
def get_sign_url(self, api, params): if not (api in self.api_info): raise Exception("no such api") api_info = self.api_info[api] mquery = self.merge(api_info.query, params) r = Request() r.set_shema(self.service_info.scheme) r.set_method(api_info.method) r.set_path(api_info.path) r.set_query(mquery) return SignerV4.sign_url(r, self.service_info.credentials)