def get_user_by_name_with_http_info(self, username, **kwargs): # noqa: E501 """Get user by user name # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.get_user_by_name_with_http_info(username, async_req=True) >>> result = thread.get() :param async_req bool :param str username: The name that needs to be fetched. Use user1 for testing. (required) :return: User If the method is called asynchronously, returns the request thread. """ local_var_params = locals() all_params = ['username'] # noqa: E501 all_params.append('async_req') all_params.append('_return_http_data_only') all_params.append('_preload_content') all_params.append('_request_timeout') for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: raise ApiTypeError( "Got an unexpected keyword argument '%s'" " to method get_user_by_name" % key ) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'username' is set if ('username' not in local_var_params or local_var_params['username'] is None): raise ApiValueError("Missing the required parameter `username` when calling `get_user_by_name`") # noqa: E501 collection_formats = {} path_params = {} if 'username' in local_var_params: path_params['username'] = local_var_params['username'] # noqa: E501 query_params = [] header_params = {} form_params = [] local_var_files = {} body_params = None # HTTP header `Accept` header_params['Accept'] = self.api_client.select_header_accept( ['application/xml', 'application/json']) # noqa: E501 # Authentication setting auth_settings = [] # noqa: E501 return self.api_client.call_api( '/user/{username}', 'GET', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, response_type='User', # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), collection_formats=collection_formats)
def upload_file_with_required_file_with_http_info(self, pet_id, required_file, **kwargs): # noqa: E501 """uploads an image (required) # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.upload_file_with_required_file_with_http_info(pet_id, required_file, async_req=True) >>> result = thread.get() :param async_req bool: execute request asynchronously :param int pet_id: ID of pet to update (required) :param file required_file: file to upload (required) :param str additional_metadata: Additional data to pass to server :param _return_http_data_only: response data without head status code and headers :param _preload_content: if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. :param _request_timeout: timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. :return: tuple(ApiResponse, status_code(int), headers(HTTPHeaderDict)) If the method is called asynchronously, returns the request thread. """ local_var_params = locals() all_params = ['pet_id', 'required_file', 'additional_metadata'] # noqa: E501 all_params.append('async_req') all_params.append('_return_http_data_only') all_params.append('_preload_content') all_params.append('_request_timeout') for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: raise ApiTypeError( "Got an unexpected keyword argument '%s'" " to method upload_file_with_required_file" % key) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'pet_id' is set if ('pet_id' not in local_var_params or local_var_params['pet_id'] is None): raise ApiValueError( "Missing the required parameter `pet_id` when calling `upload_file_with_required_file`" ) # noqa: E501 # verify the required parameter 'required_file' is set if ('required_file' not in local_var_params or local_var_params['required_file'] is None): raise ApiValueError( "Missing the required parameter `required_file` when calling `upload_file_with_required_file`" ) # noqa: E501 collection_formats = {} path_params = {} if 'pet_id' in local_var_params: path_params['petId'] = local_var_params['pet_id'] # noqa: E501 query_params = [] header_params = {} form_params = [] local_var_files = {} if 'additional_metadata' in local_var_params: form_params.append( ('additionalMetadata', local_var_params['additional_metadata'])) # noqa: E501 if 'required_file' in local_var_params: local_var_files['requiredFile'] = local_var_params[ 'required_file'] # noqa: E501 body_params = None # HTTP header `Accept` header_params['Accept'] = self.api_client.select_header_accept( ['application/json']) # noqa: E501 # HTTP header `Content-Type` header_params[ 'Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 ['multipart/form-data']) # noqa: E501 # Authentication setting auth_settings = ['petstore_auth'] # noqa: E501 return self.api_client.call_api( '/fake/{petId}/uploadImageWithRequiredFile', 'POST', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, response_type='ApiResponse', # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get( '_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), collection_formats=collection_formats)
def request(self, method, url, query_params=None, headers=None, body=None, post_params=None, _preload_content=True, _request_timeout=None): """Perform requests. :param method: http request method :param url: http request url :param query_params: query parameters in the url :param headers: http request headers :param body: request json body, for `application/json` :param post_params: request post parameters, `application/x-www-form-urlencoded` and `multipart/form-data` :param _preload_content: if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. :param _request_timeout: timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. """ method = method.upper() assert method in [ 'GET', 'HEAD', 'DELETE', 'POST', 'PUT', 'PATCH', 'OPTIONS' ] if post_params and body: raise ApiValueError( "body parameter cannot be used with post_params parameter.") post_params = post_params or {} headers = headers or {} timeout = None if _request_timeout: if isinstance(_request_timeout, (int, ) if six.PY3 else (int, long)): # noqa: E501,F821 timeout = urllib3.Timeout(total=_request_timeout) elif (isinstance(_request_timeout, tuple) and len(_request_timeout) == 2): timeout = urllib3.Timeout(connect=_request_timeout[0], read=_request_timeout[1]) if 'Content-Type' not in headers: headers['Content-Type'] = 'application/json' try: # For `POST`, `PUT`, `PATCH`, `OPTIONS`, `DELETE` if method in ['POST', 'PUT', 'PATCH', 'OPTIONS', 'DELETE']: if query_params: url += '?' + urlencode(query_params) if re.search('json', headers['Content-Type'], re.IGNORECASE): request_body = None if body is not None: request_body = json.dumps(body) r = self.pool_manager.request( method, url, body=request_body, preload_content=_preload_content, timeout=timeout, headers=headers) elif headers[ 'Content-Type'] == 'application/x-www-form-urlencoded': # noqa: E501 r = self.pool_manager.request( method, url, fields=post_params, encode_multipart=False, preload_content=_preload_content, timeout=timeout, headers=headers) elif headers['Content-Type'] == 'multipart/form-data': # must del headers['Content-Type'], or the correct # Content-Type which generated by urllib3 will be # overwritten. del headers['Content-Type'] r = self.pool_manager.request( method, url, fields=post_params, encode_multipart=True, preload_content=_preload_content, timeout=timeout, headers=headers) # Pass a `string` parameter directly in the body to support # other content types than Json when `body` argument is # provided in serialized form elif isinstance(body, str) or isinstance(body, bytes): request_body = body r = self.pool_manager.request( method, url, body=request_body, preload_content=_preload_content, timeout=timeout, headers=headers) else: # Cannot generate the request from given parameters msg = """Cannot prepare a request message for provided arguments. Please check that your arguments match declared content type.""" raise ApiException(status=0, reason=msg) # For `GET`, `HEAD` else: r = self.pool_manager.request(method, url, fields=query_params, preload_content=_preload_content, timeout=timeout, headers=headers) except urllib3.exceptions.SSLError as e: msg = "{0}\n{1}".format(type(e).__name__, str(e)) raise ApiException(status=0, reason=msg) if _preload_content: r = RESTResponse(r) # In the python 3, the response.data is bytes. # we need to decode it to string. if six.PY3: r.data = r.data.decode('utf8') # log response body logger.debug("response body: %s", r.data) if not 200 <= r.status <= 299: raise ApiException(http_resp=r) return r
def find_pets_by_tags_with_http_info(self, tags, **kwargs): # noqa: E501 """Finds Pets by tags # noqa: E501 Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.find_pets_by_tags_with_http_info(tags, async_req=True) >>> result = thread.get() :param async_req bool: execute request asynchronously :param list[str] tags: Tags to filter by (required) :param _return_http_data_only: response data without head status code and headers :param _preload_content: if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. :param _request_timeout: timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. :return: tuple(list[Pet], status_code(int), headers(HTTPHeaderDict)) If the method is called asynchronously, returns the request thread. """ local_var_params = locals() all_params = ['tags'] # noqa: E501 all_params.append('async_req') all_params.append('_return_http_data_only') all_params.append('_preload_content') all_params.append('_request_timeout') for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method find_pets_by_tags" % key) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'tags' is set if ('tags' not in local_var_params or local_var_params['tags'] is None): raise ApiValueError( "Missing the required parameter `tags` when calling `find_pets_by_tags`" ) # noqa: E501 collection_formats = {} path_params = {} query_params = [] if 'tags' in local_var_params: query_params.append( ('tags', local_var_params['tags'])) # noqa: E501 collection_formats['tags'] = 'csv' # noqa: E501 header_params = {} form_params = [] local_var_files = {} body_params = None # HTTP header `Accept` header_params['Accept'] = self.api_client.select_header_accept( ['application/xml', 'application/json']) # noqa: E501 # Authentication setting auth_settings = ['petstore_auth'] # noqa: E501 return self.api_client.call_api( '/pet/findByTags', 'GET', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, response_type='list[Pet]', # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get( '_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), collection_formats=collection_formats)
def update_pet_with_http_info(self, pet, **kwargs): # noqa: E501 """Update an existing pet # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.update_pet_with_http_info(pet, async_req=True) >>> result = thread.get() :param async_req bool: execute request asynchronously :param Pet pet: Pet object that needs to be added to the store (required) :param _return_http_data_only: response data without head status code and headers :param _preload_content: if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. :param _request_timeout: timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. :return: None If the method is called asynchronously, returns the request thread. """ local_var_hosts = [ 'http://petstore.swagger.io/v2', 'http://path-server-test.petstore.local/v2' ] # noqa: E501 local_var_host = local_var_hosts[0] if kwargs.get('_host_index'): if int(kwags.get('_host_index')) < 0 or int( kawgs.get('_host_index')) >= len(local_var_hosts): raise ApiValueError( "Invalid host index. Must be 0 <= index < %s" % len(local_var_host)) local_var_host = local_var_hosts[int(kwargs.get('_host_index'))] local_var_params = locals() all_params = ['pet'] # noqa: E501 all_params.append('async_req') all_params.append('_return_http_data_only') all_params.append('_preload_content') all_params.append('_request_timeout') for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params and key != "_host_index": raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method update_pet" % key) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'pet' is set if ('pet' not in local_var_params or local_var_params['pet'] is None): raise ApiValueError( "Missing the required parameter `pet` when calling `update_pet`" ) # noqa: E501 collection_formats = {} path_params = {} query_params = [] header_params = {} form_params = [] local_var_files = {} body_params = None if 'pet' in local_var_params: body_params = local_var_params['pet'] # HTTP header `Content-Type` header_params[ 'Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 ['application/json', 'application/xml']) # noqa: E501 # Authentication setting auth_settings = ['petstore_auth'] # noqa: E501 return self.api_client.call_api( '/pet', 'PUT', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, response_type=None, # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get( '_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), _host=local_var_host, collection_formats=collection_formats)
def login_user_with_http_info(self, username, password, **kwargs): # noqa: E501 """Logs user into the system # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.login_user_with_http_info(username, password, async_req=True) >>> result = thread.get() :param username: The user name for login (required) :type username: str :param password: The password for login in clear text (required) :type password: str :param async_req: Whether to execute the request asynchronously. :type async_req: bool, optional :param _return_http_data_only: response data without head status code and headers :type _return_http_data_only: bool, optional :param _preload_content: if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. :type _preload_content: bool, optional :param _request_timeout: timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. :param _request_auth: set to override the auth_settings for an a single request; this effectively ignores the authentication in the spec for a single request. :type _request_auth: dict, optional :return: Returns the result object. If the method is called asynchronously, returns the request thread. :rtype: tuple(str, status_code(int), headers(HTTPHeaderDict)) """ local_var_params = locals() all_params = ['username', 'password'] all_params.extend([ 'async_req', '_return_http_data_only', '_preload_content', '_request_timeout', '_request_auth' ]) for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method login_user" % key) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'username' is set if self.api_client.client_side_validation and ( 'username' not in local_var_params or # noqa: E501 local_var_params['username'] is None): # noqa: E501 raise ApiValueError( "Missing the required parameter `username` when calling `login_user`" ) # noqa: E501 # verify the required parameter 'password' is set if self.api_client.client_side_validation and ( 'password' not in local_var_params or # noqa: E501 local_var_params['password'] is None): # noqa: E501 raise ApiValueError( "Missing the required parameter `password` when calling `login_user`" ) # noqa: E501 collection_formats = {} path_params = {} query_params = [] if 'username' in local_var_params and local_var_params[ 'username'] is not None: # noqa: E501 query_params.append( ('username', local_var_params['username'])) # noqa: E501 if 'password' in local_var_params and local_var_params[ 'password'] is not None: # noqa: E501 query_params.append( ('password', local_var_params['password'])) # noqa: E501 header_params = {} form_params = [] local_var_files = {} body_params = None # HTTP header `Accept` header_params['Accept'] = self.api_client.select_header_accept( ['application/xml', 'application/json']) # noqa: E501 # Authentication setting auth_settings = [] # noqa: E501 response_types_map = { 200: "str", 400: None, } return self.api_client.call_api( '/user/login', 'GET', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, response_types_map=response_types_map, auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get( '_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), collection_formats=collection_formats, _request_auth=local_var_params.get('_request_auth'))
def request(self, method, url, query_params=None, headers=None, body=None, post_params=None, _preload_content=True, _request_timeout=None): """Execute Request :param method: http request method :param url: http request url :param query_params: query parameters in the url :param headers: http request headers :param body: request json body, for `application/json` :param post_params: request post parameters, `application/x-www-form-urlencoded` and `multipart/form-data` :param _preload_content: this is a non-applicable field for the AiohttpClient. :param _request_timeout: timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. """ method = method.upper() assert method in [ 'GET', 'HEAD', 'DELETE', 'POST', 'PUT', 'PATCH', 'OPTIONS' ] if post_params and body: raise ApiValueError( "body parameter cannot be used with post_params parameter.") request = httpclient.HTTPRequest(url) request.allow_nonstandard_methods = True request.ca_certs = self.ca_certs request.client_key = self.client_key request.client_cert = self.client_cert request.proxy_host = self.proxy_host request.proxy_port = self.proxy_port request.method = method if headers: request.headers = headers if 'Content-Type' not in headers: request.headers['Content-Type'] = 'application/json' request.request_timeout = _request_timeout or 5 * 60 post_params = post_params or {} if query_params: request.url += '?' + urlencode(query_params) # For `POST`, `PUT`, `PATCH`, `OPTIONS`, `DELETE` if method in ['POST', 'PUT', 'PATCH', 'OPTIONS', 'DELETE']: if re.search('json', headers['Content-Type'], re.IGNORECASE): if body: body = json.dumps(body) request.body = body elif headers[ 'Content-Type'] == 'application/x-www-form-urlencoded': # noqa: E501 request.body = urlencode(post_params) elif headers['Content-Type'] == 'multipart/form-data': multipart = encode_multipart_formdata(post_params) request.body, headers['Content-Type'] = multipart # Pass a `bytes` parameter directly in the body to support # other content types than Json when `body` argument is provided # in serialized form elif isinstance(body, bytes): request.body = body else: # Cannot generate the request from given parameters msg = """Cannot prepare a request message for provided arguments. Please check that your arguments match declared content type.""" raise ApiException(status=0, reason=msg) r = yield self.pool_manager.fetch(request, raise_error=False) if _preload_content: r = RESTResponse(r) # log response body logger.debug("response body: %s", r.data) if not 200 <= r.status <= 299: raise ApiException(http_resp=r) raise tornado.gen.Return(r)
def get_order_by_id_with_http_info(self, order_id, **kwargs): # noqa: E501 """Find purchase order by ID # noqa: E501 For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.get_order_by_id_with_http_info(order_id, async_req=True) >>> result = thread.get() :param async_req bool :param int order_id: ID of pet that needs to be fetched (required) :return: Order If the method is called asynchronously, returns the request thread. """ local_var_params = locals() all_params = ['order_id'] # noqa: E501 all_params.append('async_req') all_params.append('_return_http_data_only') all_params.append('_preload_content') all_params.append('_request_timeout') for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: raise ApiTypeError( "Got an unexpected keyword argument '%s'" " to method get_order_by_id" % key ) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'order_id' is set if ('order_id' not in local_var_params or local_var_params['order_id'] is None): raise ApiValueError("Missing the required parameter `order_id` when calling `get_order_by_id`") # noqa: E501 if 'order_id' in local_var_params and local_var_params['order_id'] > 5: # noqa: E501 raise ApiValueError("Invalid value for parameter `order_id` when calling `get_order_by_id`, must be a value less than or equal to `5`") # noqa: E501 if 'order_id' in local_var_params and local_var_params['order_id'] < 1: # noqa: E501 raise ApiValueError("Invalid value for parameter `order_id` when calling `get_order_by_id`, must be a value greater than or equal to `1`") # noqa: E501 collection_formats = {} path_params = {} if 'order_id' in local_var_params: path_params['order_id'] = local_var_params['order_id'] # noqa: E501 query_params = [] header_params = {} form_params = [] local_var_files = {} body_params = None # HTTP header `Accept` header_params['Accept'] = self.api_client.select_header_accept( ['application/xml', 'application/json']) # noqa: E501 # Authentication setting auth_settings = [] # noqa: E501 return self.api_client.call_api( '/store/order/{order_id}', 'GET', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, response_type='Order', # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), collection_formats=collection_formats)
def place_order_with_http_info(self, order, **kwargs): # noqa: E501 """Place an order for a pet # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.place_order_with_http_info(order, async_req=True) >>> result = thread.get() :param async_req bool :param Order order: order placed for purchasing the pet (required) :return: Order If the method is called asynchronously, returns the request thread. """ local_var_params = locals() all_params = ['order'] # noqa: E501 all_params.append('async_req') all_params.append('_return_http_data_only') all_params.append('_preload_content') all_params.append('_request_timeout') for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: raise ApiTypeError( "Got an unexpected keyword argument '%s'" " to method place_order" % key ) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'order' is set if ('order' not in local_var_params or local_var_params['order'] is None): raise ApiValueError("Missing the required parameter `order` when calling `place_order`") # noqa: E501 collection_formats = {} path_params = {} query_params = [] header_params = {} form_params = [] local_var_files = {} body_params = None if 'order' in local_var_params: body_params = local_var_params['order'] # HTTP header `Accept` header_params['Accept'] = self.api_client.select_header_accept( ['application/xml', 'application/json']) # noqa: E501 # HTTP header `Content-Type` header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 ['application/json']) # noqa: E501 # Authentication setting auth_settings = [] # noqa: E501 return self.api_client.call_api( '/store/order', 'POST', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, response_type='Order', # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), collection_formats=collection_formats)
def get_order_by_id_with_http_info(self, order_id, **kwargs): # noqa: E501 """Find purchase order by ID # noqa: E501 For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.get_order_by_id_with_http_info(order_id, async_req=True) >>> result = thread.get() :param order_id: ID of pet that needs to be fetched (required) :type order_id: int :param async_req: Whether to execute the request asynchronously. :type async_req: bool, optional :param _return_http_data_only: response data without head status code and headers :type _return_http_data_only: bool, optional :param _preload_content: if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. :type _preload_content: bool, optional :param _request_timeout: timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. :param _request_auth: set to override the auth_settings for an a single request; this effectively ignores the authentication in the spec for a single request. :type _request_auth: dict, optional :type _content_type: string, optional: force content-type for the request :return: Returns the result object. If the method is called asynchronously, returns the request thread. :rtype: tuple(Order, status_code(int), headers(HTTPHeaderDict)) """ local_var_params = locals() all_params = ['order_id'] all_params.extend([ 'async_req', '_return_http_data_only', '_preload_content', '_request_timeout', '_request_auth', '_content_type' ]) for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method get_order_by_id" % key) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'order_id' is set if self.api_client.client_side_validation and ( 'order_id' not in local_var_params or # noqa: E501 local_var_params['order_id'] is None): # noqa: E501 raise ApiValueError( "Missing the required parameter `order_id` when calling `get_order_by_id`" ) # noqa: E501 if self.api_client.client_side_validation and 'order_id' in local_var_params and local_var_params[ 'order_id'] > 5: # noqa: E501 raise ApiValueError( "Invalid value for parameter `order_id` when calling `get_order_by_id`, must be a value less than or equal to `5`" ) # noqa: E501 if self.api_client.client_side_validation and 'order_id' in local_var_params and local_var_params[ 'order_id'] < 1: # noqa: E501 raise ApiValueError( "Invalid value for parameter `order_id` when calling `get_order_by_id`, must be a value greater than or equal to `1`" ) # noqa: E501 collection_formats = {} path_params = {} if 'order_id' in local_var_params: path_params['order_id'] = local_var_params[ 'order_id'] # noqa: E501 query_params = [] header_params = {} form_params = [] local_var_files = {} body_params = None # HTTP header `Accept` header_params['Accept'] = self.api_client.select_header_accept( ['application/xml', 'application/json']) # noqa: E501 # Authentication setting auth_settings = [] # noqa: E501 response_types_map = { 200: "Order", 400: None, 404: None, } return self.api_client.call_api( '/store/order/{order_id}', 'GET', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, response_types_map=response_types_map, auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get( '_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), collection_formats=collection_formats, _request_auth=local_var_params.get('_request_auth'))
def delete_order_with_http_info(self, order_id, **kwargs): # noqa: E501 """Delete purchase order by ID # noqa: E501 For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.delete_order_with_http_info(order_id, async_req=True) >>> result = thread.get() :param order_id: ID of the order that needs to be deleted (required) :type order_id: str :param async_req: Whether to execute the request asynchronously. :type async_req: bool, optional :param _return_http_data_only: response data without head status code and headers :type _return_http_data_only: bool, optional :param _preload_content: if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. :type _preload_content: bool, optional :param _request_timeout: timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. :param _request_auth: set to override the auth_settings for an a single request; this effectively ignores the authentication in the spec for a single request. :type _request_auth: dict, optional :type _content_type: string, optional: force content-type for the request :return: Returns the result object. If the method is called asynchronously, returns the request thread. :rtype: None """ local_var_params = locals() all_params = ['order_id'] all_params.extend([ 'async_req', '_return_http_data_only', '_preload_content', '_request_timeout', '_request_auth', '_content_type' ]) for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method delete_order" % key) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'order_id' is set if self.api_client.client_side_validation and ( 'order_id' not in local_var_params or # noqa: E501 local_var_params['order_id'] is None): # noqa: E501 raise ApiValueError( "Missing the required parameter `order_id` when calling `delete_order`" ) # noqa: E501 collection_formats = {} path_params = {} if 'order_id' in local_var_params: path_params['order_id'] = local_var_params[ 'order_id'] # noqa: E501 query_params = [] header_params = {} form_params = [] local_var_files = {} body_params = None # Authentication setting auth_settings = [] # noqa: E501 response_types_map = {} return self.api_client.call_api( '/store/order/{order_id}', 'DELETE', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, response_types_map=response_types_map, auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get( '_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), collection_formats=collection_formats, _request_auth=local_var_params.get('_request_auth'))
def call_123_test_special_tags_with_http_info(self, client, **kwargs): # noqa: E501 """To test special tags # noqa: E501 To test special tags and operation ID starting with number # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.call_123_test_special_tags_with_http_info(client, async_req=True) >>> result = thread.get() :param async_req bool :param Client client: client model (required) :return: Client If the method is called asynchronously, returns the request thread. """ local_var_params = locals() all_params = ['client'] # noqa: E501 all_params.append('async_req') all_params.append('_return_http_data_only') all_params.append('_preload_content') all_params.append('_request_timeout') for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: raise ApiTypeError( "Got an unexpected keyword argument '%s'" " to method call_123_test_special_tags" % key ) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'client' is set if ('client' not in local_var_params or local_var_params['client'] is None): raise ApiValueError("Missing the required parameter `client` when calling `call_123_test_special_tags`") # noqa: E501 collection_formats = {} path_params = {} query_params = [] header_params = {} form_params = [] local_var_files = {} body_params = None if 'client' in local_var_params: body_params = local_var_params['client'] # HTTP header `Accept` header_params['Accept'] = self.api_client.select_header_accept( ['application/json']) # noqa: E501 # HTTP header `Content-Type` header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 ['application/json']) # noqa: E501 # Authentication setting auth_settings = [] # noqa: E501 return self.api_client.call_api( '/another-fake/dummy', 'PATCH', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, response_type='Client', # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), collection_formats=collection_formats)
def update_user_with_http_info(self, username, user, **kwargs): # noqa: E501 """Updated user # noqa: E501 This can only be done by the logged in user. # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.update_user_with_http_info(username, user, async_req=True) >>> result = thread.get() :param async_req bool :param str username: name that need to be deleted (required) :param User user: Updated user object (required) :return: None If the method is called asynchronously, returns the request thread. """ local_var_params = locals() all_params = ['username', 'user'] # noqa: E501 all_params.append('async_req') all_params.append('_return_http_data_only') all_params.append('_preload_content') all_params.append('_request_timeout') for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: raise ApiTypeError( "Got an unexpected keyword argument '%s'" " to method update_user" % key ) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'username' is set if ('username' not in local_var_params or local_var_params['username'] is None): raise ApiValueError("Missing the required parameter `username` when calling `update_user`") # noqa: E501 # verify the required parameter 'user' is set if ('user' not in local_var_params or local_var_params['user'] is None): raise ApiValueError("Missing the required parameter `user` when calling `update_user`") # noqa: E501 collection_formats = {} path_params = {} if 'username' in local_var_params: path_params['username'] = local_var_params['username'] # noqa: E501 query_params = [] header_params = {} form_params = [] local_var_files = {} body_params = None if 'user' in local_var_params: body_params = local_var_params['user'] # HTTP header `Content-Type` header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 ['application/json']) # noqa: E501 # Authentication setting auth_settings = [] # noqa: E501 return self.api_client.call_api( '/user/{username}', 'PUT', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, response_type=None, # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), collection_formats=collection_formats)
def login_user_with_http_info(self, username, password, **kwargs): # noqa: E501 """Logs user into the system # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.login_user_with_http_info(username, password, async_req=True) >>> result = thread.get() :param async_req bool :param str username: The user name for login (required) :param str password: The password for login in clear text (required) :return: str If the method is called asynchronously, returns the request thread. """ local_var_params = locals() all_params = ['username', 'password'] # noqa: E501 all_params.append('async_req') all_params.append('_return_http_data_only') all_params.append('_preload_content') all_params.append('_request_timeout') for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: raise ApiTypeError( "Got an unexpected keyword argument '%s'" " to method login_user" % key ) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'username' is set if ('username' not in local_var_params or local_var_params['username'] is None): raise ApiValueError("Missing the required parameter `username` when calling `login_user`") # noqa: E501 # verify the required parameter 'password' is set if ('password' not in local_var_params or local_var_params['password'] is None): raise ApiValueError("Missing the required parameter `password` when calling `login_user`") # noqa: E501 collection_formats = {} path_params = {} query_params = [] if 'username' in local_var_params: query_params.append(('username', local_var_params['username'])) # noqa: E501 if 'password' in local_var_params: query_params.append(('password', local_var_params['password'])) # noqa: E501 header_params = {} form_params = [] local_var_files = {} body_params = None # HTTP header `Accept` header_params['Accept'] = self.api_client.select_header_accept( ['application/xml', 'application/json']) # noqa: E501 # Authentication setting auth_settings = [] # noqa: E501 return self.api_client.call_api( '/user/login', 'GET', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, response_type='str', # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), collection_formats=collection_formats)
def upload_file_with_http_info(self, pet_id, **kwargs): # noqa: E501 """uploads an image # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.upload_file_with_http_info(pet_id, async_req=True) >>> result = thread.get() :param async_req bool :param int pet_id: ID of pet to update (required) :param str additional_metadata: Additional data to pass to server :param file file: file to upload :return: ApiResponse If the method is called asynchronously, returns the request thread. """ local_var_params = locals() all_params = ['pet_id', 'additional_metadata', 'file'] # noqa: E501 all_params.append('async_req') all_params.append('_return_http_data_only') all_params.append('_preload_content') all_params.append('_request_timeout') for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method upload_file" % key) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'pet_id' is set if ('pet_id' not in local_var_params or local_var_params['pet_id'] is None): raise ApiValueError( "Missing the required parameter `pet_id` when calling `upload_file`" ) # noqa: E501 collection_formats = {} path_params = {} if 'pet_id' in local_var_params: path_params['petId'] = local_var_params['pet_id'] # noqa: E501 query_params = [] header_params = {} form_params = [] local_var_files = {} if 'additional_metadata' in local_var_params: form_params.append( ('additionalMetadata', local_var_params['additional_metadata'])) # noqa: E501 if 'file' in local_var_params: local_var_files['file'] = local_var_params['file'] # noqa: E501 body_params = None # HTTP header `Accept` header_params['Accept'] = self.api_client.select_header_accept( ['application/json']) # noqa: E501 # HTTP header `Content-Type` header_params[ 'Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 ['multipart/form-data']) # noqa: E501 # Authentication setting auth_settings = ['petstore_auth'] # noqa: E501 return self.api_client.call_api( '/pet/{petId}/uploadImage', 'POST', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, response_type='ApiResponse', # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get( '_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), collection_formats=collection_formats)
def delete_order_with_http_info(self, order_id, **kwargs): # noqa: E501 """Delete purchase order by ID # noqa: E501 For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.delete_order_with_http_info(order_id, async_req=True) >>> result = thread.get() :param async_req bool :param str order_id: ID of the order that needs to be deleted (required) :return: None If the method is called asynchronously, returns the request thread. """ local_var_params = locals() all_params = ['order_id'] # noqa: E501 all_params.append('async_req') all_params.append('_return_http_data_only') all_params.append('_preload_content') all_params.append('_request_timeout') for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: raise ApiTypeError( "Got an unexpected keyword argument '%s'" " to method delete_order" % key ) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'order_id' is set if ('order_id' not in local_var_params or local_var_params['order_id'] is None): raise ApiValueError("Missing the required parameter `order_id` when calling `delete_order`") # noqa: E501 collection_formats = {} path_params = {} if 'order_id' in local_var_params: path_params['order_id'] = local_var_params['order_id'] # noqa: E501 query_params = [] header_params = {} form_params = [] local_var_files = {} body_params = None # Authentication setting auth_settings = [] # noqa: E501 return self.api_client.call_api( '/store/order/{order_id}', 'DELETE', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, response_type=None, # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), collection_formats=collection_formats)
def call_123_test_special_tags_with_http_info(self, body, **kwargs): # noqa: E501 """To test special tags # noqa: E501 To test special tags and operation ID starting with number # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.call_123_test_special_tags_with_http_info(body, async_req=True) >>> result = thread.get() :param body: client model (required) :type body: Client :param async_req: Whether to execute the request asynchronously. :type async_req: bool, optional :param _return_http_data_only: response data without head status code and headers :type _return_http_data_only: bool, optional :param _preload_content: if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. :type _preload_content: bool, optional :param _request_timeout: timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. :param _request_auth: set to override the auth_settings for an a single request; this effectively ignores the authentication in the spec for a single request. :type _request_auth: dict, optional :return: Returns the result object. If the method is called asynchronously, returns the request thread. :rtype: tuple(Client, status_code(int), headers(HTTPHeaderDict)) """ local_var_params = locals() all_params = [ 'body' ] all_params.extend( [ 'async_req', '_return_http_data_only', '_preload_content', '_request_timeout', '_request_auth' ] ) for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: raise ApiTypeError( "Got an unexpected keyword argument '%s'" " to method call_123_test_special_tags" % key ) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'body' is set if self.api_client.client_side_validation and ('body' not in local_var_params or # noqa: E501 local_var_params['body'] is None): # noqa: E501 raise ApiValueError("Missing the required parameter `body` when calling `call_123_test_special_tags`") # noqa: E501 collection_formats = {} path_params = {} query_params = [] header_params = {} form_params = [] local_var_files = {} body_params = None if 'body' in local_var_params: body_params = local_var_params['body'] # HTTP header `Accept` header_params['Accept'] = self.api_client.select_header_accept( ['application/json']) # noqa: E501 # HTTP header `Content-Type` header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 ['application/json']) # noqa: E501 # Authentication setting auth_settings = [] # noqa: E501 response_types_map = { 200: "Client", } return self.api_client.call_api( '/another-fake/dummy', 'PATCH', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, response_types_map=response_types_map, auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), collection_formats=collection_formats, _request_auth=local_var_params.get('_request_auth'))
def get_user_by_name_with_http_info(self, username, **kwargs): # noqa: E501 """Get user by user name # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.get_user_by_name_with_http_info(username, async_req=True) >>> result = thread.get() :param async_req bool: execute request asynchronously :param str username: The name that needs to be fetched. Use user1 for testing. (required) :param _return_http_data_only: response data without head status code and headers :param _preload_content: if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. :param _request_timeout: timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. :return: tuple(User, status_code(int), headers(HTTPHeaderDict)) If the method is called asynchronously, returns the request thread. """ local_var_params = locals() all_params = ['username'] all_params.extend([ 'async_req', '_return_http_data_only', '_preload_content', '_request_timeout' ]) for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method get_user_by_name" % key) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'username' is set if self.api_client.client_side_validation and ( 'username' not in local_var_params or # noqa: E501 local_var_params['username'] is None): # noqa: E501 raise ApiValueError( "Missing the required parameter `username` when calling `get_user_by_name`" ) # noqa: E501 collection_formats = {} path_params = {} if 'username' in local_var_params: path_params['username'] = local_var_params[ 'username'] # noqa: E501 query_params = [] header_params = {} form_params = [] local_var_files = {} body_params = None # HTTP header `Accept` header_params['Accept'] = self.api_client.select_header_accept( ['application/xml', 'application/json']) # noqa: E501 # Authentication setting auth_settings = [] # noqa: E501 return self.api_client.call_api( '/user/{username}', 'GET', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, response_type='User', # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get( '_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), collection_formats=collection_formats)
def update_user_with_http_info(self, username, user, **kwargs): # noqa: E501 """Updated user # noqa: E501 This can only be done by the logged in user. # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.update_user_with_http_info(username, user, async_req=True) >>> result = thread.get() :param username: name that need to be deleted (required) :type username: str :param user: Updated user object (required) :type user: User :param async_req: Whether to execute the request asynchronously. :type async_req: bool, optional :param _return_http_data_only: response data without head status code and headers :type _return_http_data_only: bool, optional :param _preload_content: if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. :type _preload_content: bool, optional :param _request_timeout: timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. :param _request_auth: set to override the auth_settings for an a single request; this effectively ignores the authentication in the spec for a single request. :type _request_auth: dict, optional :return: Returns the result object. If the method is called asynchronously, returns the request thread. :rtype: None """ local_var_params = locals() all_params = ['username', 'user'] all_params.extend([ 'async_req', '_return_http_data_only', '_preload_content', '_request_timeout', '_request_auth' ]) for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method update_user" % key) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'username' is set if self.api_client.client_side_validation and ( 'username' not in local_var_params or # noqa: E501 local_var_params['username'] is None): # noqa: E501 raise ApiValueError( "Missing the required parameter `username` when calling `update_user`" ) # noqa: E501 # verify the required parameter 'user' is set if self.api_client.client_side_validation and ( 'user' not in local_var_params or # noqa: E501 local_var_params['user'] is None): # noqa: E501 raise ApiValueError( "Missing the required parameter `user` when calling `update_user`" ) # noqa: E501 collection_formats = {} path_params = {} if 'username' in local_var_params: path_params['username'] = local_var_params[ 'username'] # noqa: E501 query_params = [] header_params = {} form_params = [] local_var_files = {} body_params = None if 'user' in local_var_params: body_params = local_var_params['user'] # HTTP header `Content-Type` header_params[ 'Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 ['application/json']) # noqa: E501 # Authentication setting auth_settings = [] # noqa: E501 response_types_map = {} return self.api_client.call_api( '/user/{username}', 'PUT', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, response_types_map=response_types_map, auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get( '_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), collection_formats=collection_formats, _request_auth=local_var_params.get('_request_auth'))
def update_user_with_http_info(self, username, body, **kwargs): # noqa: E501 """Updated user # noqa: E501 This can only be done by the logged in user. # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.update_user_with_http_info(username, body, async_req=True) >>> result = thread.get() :param async_req bool: execute request asynchronously :param str username: name that need to be deleted (required) :param User body: Updated user object (required) :param _return_http_data_only: response data without head status code and headers :param _preload_content: if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. :param _request_timeout: timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. :return: None If the method is called asynchronously, returns the request thread. """ local_var_params = locals() all_params = ['username', 'body'] all_params.extend([ 'async_req', '_return_http_data_only', '_preload_content', '_request_timeout' ]) for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method update_user" % key) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'username' is set if self.api_client.client_side_validation and ( 'username' not in local_var_params or # noqa: E501 local_var_params['username'] is None): # noqa: E501 raise ApiValueError( "Missing the required parameter `username` when calling `update_user`" ) # noqa: E501 # verify the required parameter 'body' is set if self.api_client.client_side_validation and ( 'body' not in local_var_params or # noqa: E501 local_var_params['body'] is None): # noqa: E501 raise ApiValueError( "Missing the required parameter `body` when calling `update_user`" ) # noqa: E501 collection_formats = {} path_params = {} if 'username' in local_var_params: path_params['username'] = local_var_params[ 'username'] # noqa: E501 query_params = [] header_params = {} form_params = [] local_var_files = {} body_params = None if 'body' in local_var_params: body_params = local_var_params['body'] # Authentication setting auth_settings = [] # noqa: E501 return self.api_client.call_api( '/user/{username}', 'PUT', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, response_type=None, # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get( '_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), collection_formats=collection_formats)
def request(self, method, url, query_params=None, headers=None, post_params=None, body=None, _preload_content=True, _request_timeout=None): """Makes the HTTP request using RESTClient.""" if method == "GET": return self.rest_client.GET(url, query_params=query_params, _preload_content=_preload_content, _request_timeout=_request_timeout, headers=headers) elif method == "HEAD": return self.rest_client.HEAD(url, query_params=query_params, _preload_content=_preload_content, _request_timeout=_request_timeout, headers=headers) elif method == "OPTIONS": return self.rest_client.OPTIONS(url, query_params=query_params, headers=headers, _preload_content=_preload_content, _request_timeout=_request_timeout) elif method == "POST": return self.rest_client.POST(url, query_params=query_params, headers=headers, post_params=post_params, _preload_content=_preload_content, _request_timeout=_request_timeout, body=body) elif method == "PUT": return self.rest_client.PUT(url, query_params=query_params, headers=headers, post_params=post_params, _preload_content=_preload_content, _request_timeout=_request_timeout, body=body) elif method == "PATCH": return self.rest_client.PATCH(url, query_params=query_params, headers=headers, post_params=post_params, _preload_content=_preload_content, _request_timeout=_request_timeout, body=body) elif method == "DELETE": return self.rest_client.DELETE(url, query_params=query_params, headers=headers, _preload_content=_preload_content, _request_timeout=_request_timeout, body=body) else: raise ApiValueError("http method must be `GET`, `HEAD`, `OPTIONS`," " `POST`, `PATCH`, `PUT` or `DELETE`.")
def delete_pet_with_http_info(self, pet_id, **kwargs): # noqa: E501 """Deletes a pet # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.delete_pet_with_http_info(pet_id, async_req=True) >>> result = thread.get() :param async_req bool :param int pet_id: Pet id to delete (required) :param str api_key: :return: None If the method is called asynchronously, returns the request thread. """ local_var_params = locals() all_params = ['pet_id', 'api_key'] # noqa: E501 all_params.append('async_req') all_params.append('_return_http_data_only') all_params.append('_preload_content') all_params.append('_request_timeout') for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method delete_pet" % key) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'pet_id' is set if ('pet_id' not in local_var_params or local_var_params['pet_id'] is None): raise ApiValueError( "Missing the required parameter `pet_id` when calling `delete_pet`" ) # noqa: E501 collection_formats = {} path_params = {} if 'pet_id' in local_var_params: path_params['petId'] = local_var_params['pet_id'] # noqa: E501 query_params = [] header_params = {} if 'api_key' in local_var_params: header_params['api_key'] = local_var_params[ 'api_key'] # noqa: E501 form_params = [] local_var_files = {} body_params = None # Authentication setting auth_settings = ['petstore_auth'] # noqa: E501 return self.api_client.call_api( '/pet/{petId}', 'DELETE', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, response_type=None, # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get( '_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), collection_formats=collection_formats)
def get_pet_by_id_with_http_info(self, pet_id, **kwargs): # noqa: E501 """Find pet by ID # noqa: E501 Returns a single pet # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.get_pet_by_id_with_http_info(pet_id, async_req=True) >>> result = thread.get() :param async_req bool: execute request asynchronously :param int pet_id: ID of pet to return (required) :param _return_http_data_only: response data without head status code and headers :param _preload_content: if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. :param _request_timeout: timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. :return: tuple(Pet, status_code(int), headers(HTTPHeaderDict)) If the method is called asynchronously, returns the request thread. """ local_var_params = locals() all_params = ['pet_id'] # noqa: E501 all_params.append('async_req') all_params.append('_return_http_data_only') all_params.append('_preload_content') all_params.append('_request_timeout') for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method get_pet_by_id" % key) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'pet_id' is set if ('pet_id' not in local_var_params or local_var_params['pet_id'] is None): raise ApiValueError( "Missing the required parameter `pet_id` when calling `get_pet_by_id`" ) # noqa: E501 collection_formats = {} path_params = {} if 'pet_id' in local_var_params: path_params['petId'] = local_var_params['pet_id'] # noqa: E501 query_params = [] header_params = {} form_params = [] local_var_files = {} body_params = None # HTTP header `Accept` header_params['Accept'] = self.api_client.select_header_accept( ['application/xml', 'application/json']) # noqa: E501 # Authentication setting auth_settings = ['api_key'] # noqa: E501 return self.api_client.call_api( '/pet/{petId}', 'GET', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, response_type='Pet', # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get( '_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), collection_formats=collection_formats)
def find_pets_by_status_with_http_info(self, status, **kwargs): # noqa: E501 """Finds Pets by status # noqa: E501 Multiple status values can be provided with comma separated strings # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.find_pets_by_status_with_http_info(status, async_req=True) >>> result = thread.get() :param async_req bool :param list[str] status: Status values that need to be considered for filter (required) :return: list[Pet] If the method is called asynchronously, returns the request thread. """ local_var_params = locals() all_params = ['status'] # noqa: E501 all_params.append('async_req') all_params.append('_return_http_data_only') all_params.append('_preload_content') all_params.append('_request_timeout') for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method find_pets_by_status" % key) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'status' is set if ('status' not in local_var_params or local_var_params['status'] is None): raise ApiValueError( "Missing the required parameter `status` when calling `find_pets_by_status`" ) # noqa: E501 collection_formats = {} path_params = {} query_params = [] if 'status' in local_var_params: query_params.append( ('status', local_var_params['status'])) # noqa: E501 collection_formats['status'] = 'csv' # noqa: E501 header_params = {} form_params = [] local_var_files = {} body_params = None # HTTP header `Accept` header_params['Accept'] = self.api_client.select_header_accept( ['application/xml', 'application/json']) # noqa: E501 # Authentication setting auth_settings = ['petstore_auth'] # noqa: E501 return self.api_client.call_api( '/pet/findByStatus', 'GET', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, response_type='list[Pet]', # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get( '_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), collection_formats=collection_formats)
def update_pet_with_form_with_http_info(self, pet_id, **kwargs): # noqa: E501 """Updates a pet in the store with form data # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.update_pet_with_form_with_http_info(pet_id, async_req=True) >>> result = thread.get() :param async_req bool: execute request asynchronously :param int pet_id: ID of pet that needs to be updated (required) :param str name: Updated name of the pet :param str status: Updated status of the pet :param _return_http_data_only: response data without head status code and headers :param _preload_content: if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. :param _request_timeout: timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. :return: None If the method is called asynchronously, returns the request thread. """ local_var_params = locals() all_params = ['pet_id', 'name', 'status'] # noqa: E501 all_params.append('async_req') all_params.append('_return_http_data_only') all_params.append('_preload_content') all_params.append('_request_timeout') for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method update_pet_with_form" % key) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'pet_id' is set if ('pet_id' not in local_var_params or local_var_params['pet_id'] is None): raise ApiValueError( "Missing the required parameter `pet_id` when calling `update_pet_with_form`" ) # noqa: E501 collection_formats = {} path_params = {} if 'pet_id' in local_var_params: path_params['petId'] = local_var_params['pet_id'] # noqa: E501 query_params = [] header_params = {} form_params = [] local_var_files = {} if 'name' in local_var_params: form_params.append( ('name', local_var_params['name'])) # noqa: E501 if 'status' in local_var_params: form_params.append( ('status', local_var_params['status'])) # noqa: E501 body_params = None # HTTP header `Content-Type` header_params[ 'Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 ['application/x-www-form-urlencoded']) # noqa: E501 # Authentication setting auth_settings = ['petstore_auth'] # noqa: E501 return self.api_client.call_api( '/pet/{petId}', 'POST', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, response_type=None, # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get( '_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), collection_formats=collection_formats)
def get_pet_by_id_with_http_info(self, pet_id, **kwargs): # noqa: E501 """Find pet by ID # noqa: E501 Returns a single pet # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.get_pet_by_id_with_http_info(pet_id, async_req=True) >>> result = thread.get() :param async_req bool :param int pet_id: ID of pet to return (required) :return: Pet If the method is called asynchronously, returns the request thread. """ local_var_params = locals() all_params = ['pet_id'] # noqa: E501 all_params.append('async_req') all_params.append('_return_http_data_only') all_params.append('_preload_content') all_params.append('_request_timeout') for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method get_pet_by_id" % key) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'pet_id' is set if ('pet_id' not in local_var_params or local_var_params['pet_id'] is None): raise ApiValueError( "Missing the required parameter `pet_id` when calling `get_pet_by_id`" ) # noqa: E501 collection_formats = {} path_params = {} if 'pet_id' in local_var_params: path_params['petId'] = local_var_params['pet_id'] # noqa: E501 query_params = [] header_params = {} form_params = [] local_var_files = {} body_params = None # HTTP header `Accept` header_params['Accept'] = self.api_client.select_header_accept( ['application/xml', 'application/json']) # noqa: E501 # Authentication setting auth_settings = ['api_key'] # noqa: E501 return self.api_client.call_api( '/pet/{petId}', 'GET', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, response_type='Pet', # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get( '_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), collection_formats=collection_formats)
def test_classname_with_http_info(self, body, **kwargs): # noqa: E501 """To test class name in snake case # noqa: E501 To test class name in snake case # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.test_classname_with_http_info(body, async_req=True) >>> result = thread.get() :param async_req bool: execute request asynchronously :param Client body: client model (required) :param _return_http_data_only: response data without head status code and headers :param _preload_content: if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. :param _request_timeout: timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. :return: tuple(Client, status_code(int), headers(HTTPHeaderDict)) If the method is called asynchronously, returns the request thread. """ local_var_params = locals() all_params = ['body'] # noqa: E501 all_params.append('async_req') all_params.append('_return_http_data_only') all_params.append('_preload_content') all_params.append('_request_timeout') for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method test_classname" % key) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'body' is set if self.api_client.client_side_validation and ( 'body' not in local_var_params or # noqa: E501 local_var_params['body'] is None): # noqa: E501 raise ApiValueError( "Missing the required parameter `body` when calling `test_classname`" ) # noqa: E501 collection_formats = {} path_params = {} query_params = [] header_params = {} form_params = [] local_var_files = {} body_params = None if 'body' in local_var_params: body_params = local_var_params['body'] # HTTP header `Accept` header_params['Accept'] = self.api_client.select_header_accept( ['application/json']) # noqa: E501 # HTTP header `Content-Type` header_params[ 'Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 ['application/json']) # noqa: E501 # Authentication setting auth_settings = ['api_key_query'] # noqa: E501 return self.api_client.call_api( '/fake_classname_test', 'PATCH', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, response_type='Client', # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get( '_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), collection_formats=collection_formats)
def update_pet_with_http_info(self, body, **kwargs): # noqa: E501 """Update an existing pet # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.update_pet_with_http_info(body, async_req=True) >>> result = thread.get() :param async_req bool :param Pet body: Pet object that needs to be added to the store (required) :return: None If the method is called asynchronously, returns the request thread. """ local_var_params = locals() all_params = ['body'] # noqa: E501 all_params.append('async_req') all_params.append('_return_http_data_only') all_params.append('_preload_content') all_params.append('_request_timeout') for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method update_pet" % key) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'body' is set if ('body' not in local_var_params or local_var_params['body'] is None): raise ApiValueError( "Missing the required parameter `body` when calling `update_pet`" ) # noqa: E501 collection_formats = {} path_params = {} query_params = [] header_params = {} form_params = [] local_var_files = {} body_params = None if 'body' in local_var_params: body_params = local_var_params['body'] # HTTP header `Content-Type` header_params[ 'Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 ['application/json', 'application/xml']) # noqa: E501 # Authentication setting auth_settings = ['petstore_auth'] # noqa: E501 return self.api_client.call_api( '/pet', 'PUT', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, response_type=None, # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get( '_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), collection_formats=collection_formats)
def call_with_http_info(self, **kwargs): try: _host = self.settings['servers'][kwargs['_host_index']] except IndexError: if self.settings['servers']: raise ApiValueError( "Invalid host index. Must be 0 <= index < %s" % len(self.settings['servers'])) _host = None for key, value in six.iteritems(kwargs): if key not in self.params_map['all']: raise ApiTypeError("Got an unexpected parameter '%s'" " to method `%s`" % (key, self.settings['operation_id'])) # only throw this nullable ApiValueError if _check_input_type # is False, if _check_input_type==True we catch this case # in self.__validate_inputs if (key not in self.params_map['nullable'] and value is None and kwargs['_check_input_type'] is False): raise ApiValueError( "Value may not be None for non-nullable parameter `%s`" " when calling `%s`" % (key, self.settings['operation_id'])) for key in self.params_map['required']: if key not in kwargs.keys(): raise ApiValueError( "Missing the required parameter `%s` when calling " "`%s`" % (key, self.settings['operation_id'])) self.__validate_inputs(kwargs) params = self.__gather_params(kwargs) accept_headers_list = self.headers_map['accept'] if accept_headers_list: params['header']['Accept'] = self.api_client.select_header_accept( accept_headers_list) content_type_headers_list = self.headers_map['content_type'] if content_type_headers_list: header_list = self.api_client.select_header_content_type( content_type_headers_list) params['header']['Content-Type'] = header_list return self.api_client.call_api( self.settings['endpoint_path'], self.settings['http_method'], params['path'], params['query'], params['header'], body=params['body'], post_params=params['form'], files=params['file'], response_type=self.settings['response_type'], auth_settings=self.settings['auth'], async_req=kwargs['async_req'], _check_type=kwargs['_check_return_type'], _return_http_data_only=kwargs['_return_http_data_only'], _preload_content=kwargs['_preload_content'], _request_timeout=kwargs['_request_timeout'], _host=_host, collection_formats=params['collection_format'])
async def request(self, method, url, query_params=None, headers=None, body=None, post_params=None, _preload_content=True, _request_timeout=None): """Execute request :param method: http request method :param url: http request url :param query_params: query parameters in the url :param headers: http request headers :param body: request json body, for `application/json` :param post_params: request post parameters, `application/x-www-form-urlencoded` and `multipart/form-data` :param _preload_content: this is a non-applicable field for the AiohttpClient. :param _request_timeout: timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. """ method = method.upper() assert method in [ 'GET', 'HEAD', 'DELETE', 'POST', 'PUT', 'PATCH', 'OPTIONS' ] if post_params and body: raise ApiValueError( "body parameter cannot be used with post_params parameter.") post_params = post_params or {} headers = headers or {} timeout = _request_timeout or 5 * 60 if 'Content-Type' not in headers: headers['Content-Type'] = 'application/json' args = { "method": method, "url": url, "timeout": timeout, "headers": headers } if self.proxy: args["proxy"] = self.proxy if self.proxy_headers: args["proxy_headers"] = self.proxy_headers if query_params: args["url"] += '?' + urlencode(query_params) # For `POST`, `PUT`, `PATCH`, `OPTIONS`, `DELETE` if method in ['POST', 'PUT', 'PATCH', 'OPTIONS', 'DELETE']: if re.search('json', headers['Content-Type'], re.IGNORECASE): if body is not None: body = json.dumps(body) args["data"] = body elif headers[ 'Content-Type'] == 'application/x-www-form-urlencoded': # noqa: E501 args["data"] = aiohttp.FormData(post_params) elif headers['Content-Type'] == 'multipart/form-data': # must del headers['Content-Type'], or the correct # Content-Type which generated by aiohttp del headers['Content-Type'] data = aiohttp.FormData() for param in post_params: k, v = param if isinstance(v, tuple) and len(v) == 3: data.add_field(k, value=v[1], filename=v[0], content_type=v[2]) else: data.add_field(k, v) args["data"] = data # Pass a `bytes` parameter directly in the body to support # other content types than Json when `body` argument is provided # in serialized form elif isinstance(body, bytes): args["data"] = body else: # Cannot generate the request from given parameters msg = """Cannot prepare a request message for provided arguments. Please check that your arguments match declared content type.""" raise ApiException(status=0, reason=msg) r = await self.pool_manager.request(**args) if _preload_content: data = await r.read() r = RESTResponse(r, data) # log response body logger.debug("response body: %s", r.data) if not 200 <= r.status <= 299: raise ApiException(http_resp=r) return r