def _parse_path_params(self, collection_formats, path_params, resource_path, update_path_params): path_params = self.post_process_params(path_params) or {} if path_params: path_params = http_utils.sanitize_for_serialization(path_params) path_params = http_utils.parameters_to_tuples(path_params, collection_formats) for k, v in path_params: resource_path = resource_path.replace('{%s}' % k, quote(str(v), safe='')) if update_path_params: update_path_params = http_utils.sanitize_for_serialization(update_path_params) update_path_params = http_utils.parameters_to_tuples(update_path_params, collection_formats) for k, v in update_path_params: resource_path = resource_path.replace('{%s}' % k, quote(str(v), safe='')) return resource_path
def _parse_query_params(self, collection_formats, query_params): query_params = self.post_process_params(query_params) or [] if query_params: query_params = http_utils.sanitize_for_serialization(query_params) query_params = http_utils.parameters_to_tuples( query_params, collection_formats) return query_params
def _parse_post_params(self, collection_formats, post_params): post_params = self.post_process_params( post_params) if post_params else {} if post_params: post_params = http_utils.sanitize_for_serialization(post_params) post_params = http_utils.parameters_to_tuples( post_params, collection_formats) return post_params
def _parse_header_params(self, collection_formats, header_params): header_params = self.post_process_params(header_params) or {} header_params.update(self.preset_headers) if header_params: header_params = http_utils.sanitize_for_serialization(header_params) header_params = dict(http_utils.parameters_to_tuples(header_params, collection_formats)) header_params.update(self._agent) return header_params
def _parse_body(cls, body, post_params): if body: if all([hasattr(body, '__iter__'), not isinstance(body, (str, bytes, list, tuple, Mapping))]): return body body = http_utils.sanitize_for_serialization(body) body = json.dumps(body) elif len(post_params) != 0: body = post_params else: body = "" return body