def update_params_for_auth(self, headers, querys, auth_settings): """Updates header and query params based on authentication setting. :param headers: Header parameters dict to be updated. :param querys: Query parameters tuple list to be updated. :param auth_settings: Authentication setting identifiers list. """ if not auth_settings: return for auth in auth_settings: auth_setting = self.configuration.auth_settings().get(auth) if auth_setting: if auth_setting['in'] == 'cookie': headers['Cookie'] = auth_setting['value'] elif auth_setting['in'] == 'header': headers[auth_setting['key']] = auth_setting['value'] elif auth_setting['in'] == 'query': querys.append((auth_setting['key'], auth_setting['value'])) else: raise ApiValueError( 'Authentication token must be in `query` or `header`')
def devices_v2_pass_check_with_http_info(self, id, check_devices_v2_pass_payload, **kwargs): # noqa: E501 """check devices_v2_pass # noqa: E501 Check if the password matches. # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.devices_v2_pass_check_with_http_info(id, check_devices_v2_pass_payload, async_req=True) >>> result = thread.get() :param async_req bool: execute request asynchronously :param str id: The id of the device (required) :param CheckDevicesV2PassPayload check_devices_v2_pass_payload: (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 = [ 'id', 'check_devices_v2_pass_payload' ] 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 devices_v2_pass_check" % key ) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'id' is set if self.api_client.client_side_validation and ('id' not in local_var_params or # noqa: E501 local_var_params['id'] is None): # noqa: E501 raise ApiValueError("Missing the required parameter `id` when calling `devices_v2_pass_check`") # noqa: E501 # verify the required parameter 'check_devices_v2_pass_payload' is set if self.api_client.client_side_validation and ('check_devices_v2_pass_payload' not in local_var_params or # noqa: E501 local_var_params['check_devices_v2_pass_payload'] is None): # noqa: E501 raise ApiValueError("Missing the required parameter `check_devices_v2_pass_payload` when calling `devices_v2_pass_check`") # noqa: E501 collection_formats = {} path_params = {} if 'id' in local_var_params: path_params['id'] = local_var_params['id'] # noqa: E501 query_params = [] header_params = {} form_params = [] local_var_files = {} body_params = None if 'check_devices_v2_pass_payload' in local_var_params: body_params = local_var_params['check_devices_v2_pass_payload'] # 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', 'application/x-www-form-urlencoded']) # noqa: E501 # Authentication setting auth_settings = ['oauth2'] # noqa: E501 return self.api_client.call_api( '/v2/devices/{id}/pass', '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 devices_v2_pass_get_with_http_info(self, id, **kwargs): # noqa: E501 """get devices_v2_pass # noqa: E501 Returns whether the password for this device is set or not. It doesn't return the password. # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.devices_v2_pass_get_with_http_info(id, async_req=True) >>> result = thread.get() :param async_req bool: execute request asynchronously :param str id: The id of the device (required) :param bool suggested_password: If true, return a suggested password :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(ArduinoDevicev2Pass, status_code(int), headers(HTTPHeaderDict)) If the method is called asynchronously, returns the request thread. """ local_var_params = locals() all_params = [ 'id', 'suggested_password' ] 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 devices_v2_pass_get" % key ) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'id' is set if self.api_client.client_side_validation and ('id' not in local_var_params or # noqa: E501 local_var_params['id'] is None): # noqa: E501 raise ApiValueError("Missing the required parameter `id` when calling `devices_v2_pass_get`") # noqa: E501 collection_formats = {} path_params = {} if 'id' in local_var_params: path_params['id'] = local_var_params['id'] # noqa: E501 query_params = [] if 'suggested_password' in local_var_params and local_var_params['suggested_password'] is not None: # noqa: E501 query_params.append(('suggested_password', local_var_params['suggested_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/json']) # noqa: E501 # Authentication setting auth_settings = ['oauth2'] # noqa: E501 return self.api_client.call_api( '/v2/devices/{id}/pass', 'GET', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, response_type='ArduinoDevicev2Pass', # 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 things_v2_tags_delete_with_http_info(self, id, key, **kwargs): # noqa: E501 """delete things_v2_tags # noqa: E501 Delete a tag associated to the thing given its key. # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.things_v2_tags_delete_with_http_info(id, key, async_req=True) >>> result = thread.get() :param async_req bool: execute request asynchronously :param str id: The id of the thing (required) :param str key: The key of the tag (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 = ['id', 'key'] 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 things_v2_tags_delete" % key) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'id' is set if self.api_client.client_side_validation and ( 'id' not in local_var_params or # noqa: E501 local_var_params['id'] is None): # noqa: E501 raise ApiValueError( "Missing the required parameter `id` when calling `things_v2_tags_delete`" ) # noqa: E501 # verify the required parameter 'key' is set if self.api_client.client_side_validation and ( 'key' not in local_var_params or # noqa: E501 local_var_params['key'] is None): # noqa: E501 raise ApiValueError( "Missing the required parameter `key` when calling `things_v2_tags_delete`" ) # noqa: E501 if self.api_client.client_side_validation and ( 'key' in local_var_params and # noqa: E501 len(local_var_params['key']) > 64): # noqa: E501 raise ApiValueError( "Invalid value for parameter `key` when calling `things_v2_tags_delete`, length must be less than or equal to `64`" ) # noqa: E501 collection_formats = {} path_params = {} if 'id' in local_var_params: path_params['id'] = local_var_params['id'] # noqa: E501 if 'key' in local_var_params: path_params['key'] = local_var_params['key'] # 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/json']) # noqa: E501 # Authentication setting auth_settings = ['oauth2'] # noqa: E501 return self.api_client.call_api( '/v2/things/{id}/tags/{key}', '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 things_v2_update_sketch_with_http_info(self, id, sketch_id, **kwargs): # noqa: E501 """updateSketch things_v2 # noqa: E501 Update an existing thing sketch # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.things_v2_update_sketch_with_http_info(id, sketch_id, async_req=True) >>> result = thread.get() :param async_req bool: execute request asynchronously :param str id: The id of the thing (required) :param str sketch_id: The id of the sketch (required) :param UpdateSketch update_sketch: :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(ArduinoThing, status_code(int), headers(HTTPHeaderDict)) If the method is called asynchronously, returns the request thread. """ local_var_params = locals() all_params = [ 'id', 'sketch_id', 'update_sketch' ] 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 things_v2_update_sketch" % key ) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'id' is set if self.api_client.client_side_validation and ('id' not in local_var_params or # noqa: E501 local_var_params['id'] is None): # noqa: E501 raise ApiValueError("Missing the required parameter `id` when calling `things_v2_update_sketch`") # noqa: E501 # verify the required parameter 'sketch_id' is set if self.api_client.client_side_validation and ('sketch_id' not in local_var_params or # noqa: E501 local_var_params['sketch_id'] is None): # noqa: E501 raise ApiValueError("Missing the required parameter `sketch_id` when calling `things_v2_update_sketch`") # noqa: E501 collection_formats = {} path_params = {} if 'id' in local_var_params: path_params['id'] = local_var_params['id'] # noqa: E501 if 'sketch_id' in local_var_params: path_params['sketchId'] = local_var_params['sketch_id'] # noqa: E501 query_params = [] header_params = {} form_params = [] local_var_files = {} body_params = None if 'update_sketch' in local_var_params: body_params = local_var_params['update_sketch'] # 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 = ['oauth2'] # noqa: E501 return self.api_client.call_api( '/v2/things/{id}/sketch/{sketchId}', 'PUT', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, response_type='ArduinoThing', # 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 things_v2_create_with_http_info(self, create_things_v2_payload, **kwargs): # noqa: E501 """create things_v2 # noqa: E501 Creates a new thing associated to the 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.things_v2_create_with_http_info(create_things_v2_payload, async_req=True) >>> result = thread.get() :param async_req bool: execute request asynchronously :param CreateThingsV2Payload create_things_v2_payload: ThingPayload describes a thing (required) :param bool force: If true, detach device from the other thing, and attach to this thing :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(ArduinoThing, status_code(int), headers(HTTPHeaderDict)) If the method is called asynchronously, returns the request thread. """ local_var_params = locals() all_params = [ 'create_things_v2_payload', 'force' ] 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 things_v2_create" % key ) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'create_things_v2_payload' is set if self.api_client.client_side_validation and ('create_things_v2_payload' not in local_var_params or # noqa: E501 local_var_params['create_things_v2_payload'] is None): # noqa: E501 raise ApiValueError("Missing the required parameter `create_things_v2_payload` when calling `things_v2_create`") # noqa: E501 collection_formats = {} path_params = {} query_params = [] if 'force' in local_var_params and local_var_params['force'] is not None: # noqa: E501 query_params.append(('force', local_var_params['force'])) # noqa: E501 header_params = {} form_params = [] local_var_files = {} body_params = None if 'create_things_v2_payload' in local_var_params: body_params = local_var_params['create_things_v2_payload'] # 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 = ['oauth2'] # noqa: E501 return self.api_client.call_api( '/v2/things', 'PUT', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, response_type='ArduinoThing', # 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 devices_v2_delete_with_http_info(self, id, **kwargs): # noqa: E501 """delete devices_v2 # noqa: E501 Removes a device associated to the 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.devices_v2_delete_with_http_info(id, async_req=True) >>> result = thread.get() :param async_req bool: execute request asynchronously :param str id: The id of the device (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 = ['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 devices_v2_delete" % key) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'id' is set if self.api_client.client_side_validation and ( 'id' not in local_var_params or # noqa: E501 local_var_params['id'] is None): # noqa: E501 raise ApiValueError( "Missing the required parameter `id` when calling `devices_v2_delete`" ) # noqa: E501 collection_formats = {} path_params = {} if 'id' in local_var_params: path_params['id'] = local_var_params['id'] # noqa: E501 query_params = [] header_params = {} form_params = [] local_var_files = {} body_params = None # Authentication setting auth_settings = ['oauth2'] # noqa: E501 return self.api_client.call_api( '/v2/devices/{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 series_v2_batch_query_with_http_info(self, batch_query_requests_media_v1, **kwargs): # noqa: E501 """batch_query series_v2 # noqa: E501 Returns the batch of time-series 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.series_v2_batch_query_with_http_info(batch_query_requests_media_v1, async_req=True) >>> result = thread.get() :param async_req bool: execute request asynchronously :param BatchQueryRequestsMediaV1 batch_query_requests_media_v1: (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(ArduinoSeriesBatch, status_code(int), headers(HTTPHeaderDict)) If the method is called asynchronously, returns the request thread. """ local_var_params = locals() all_params = ['batch_query_requests_media_v1'] 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 series_v2_batch_query" % key) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'batch_query_requests_media_v1' is set if self.api_client.client_side_validation and ( 'batch_query_requests_media_v1' not in local_var_params or # noqa: E501 local_var_params['batch_query_requests_media_v1'] is None ): # noqa: E501 raise ApiValueError( "Missing the required parameter `batch_query_requests_media_v1` when calling `series_v2_batch_query`" ) # noqa: E501 collection_formats = {} path_params = {} query_params = [] header_params = {} form_params = [] local_var_files = {} body_params = None if 'batch_query_requests_media_v1' in local_var_params: body_params = local_var_params['batch_query_requests_media_v1'] # 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', 'application/x-www-form-urlencoded']) # noqa: E501 # Authentication setting auth_settings = ['oauth2'] # noqa: E501 return self.api_client.call_api( '/v2/series/batch_query', 'POST', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, response_type='ArduinoSeriesBatch', # 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 devices_v2_certs_update_with_http_info(self, cid, id, devicev2_cert, **kwargs): # noqa: E501 """update devices_v2_certs # noqa: E501 Updates a cert associated to a device. The csr is signed and saved in database. The CommonName will be replaced with the device id. # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.devices_v2_certs_update_with_http_info(cid, id, devicev2_cert, async_req=True) >>> result = thread.get() :param async_req bool: execute request asynchronously :param str cid: The id of the cert (required) :param str id: The id of the device (required) :param Devicev2Cert devicev2_cert: (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(ArduinoDevicev2Cert, status_code(int), headers(HTTPHeaderDict)) If the method is called asynchronously, returns the request thread. """ local_var_params = locals() all_params = [ 'cid', 'id', 'devicev2_cert' ] 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 devices_v2_certs_update" % key ) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'cid' is set if self.api_client.client_side_validation and ('cid' not in local_var_params or # noqa: E501 local_var_params['cid'] is None): # noqa: E501 raise ApiValueError("Missing the required parameter `cid` when calling `devices_v2_certs_update`") # noqa: E501 # verify the required parameter 'id' is set if self.api_client.client_side_validation and ('id' not in local_var_params or # noqa: E501 local_var_params['id'] is None): # noqa: E501 raise ApiValueError("Missing the required parameter `id` when calling `devices_v2_certs_update`") # noqa: E501 # verify the required parameter 'devicev2_cert' is set if self.api_client.client_side_validation and ('devicev2_cert' not in local_var_params or # noqa: E501 local_var_params['devicev2_cert'] is None): # noqa: E501 raise ApiValueError("Missing the required parameter `devicev2_cert` when calling `devices_v2_certs_update`") # noqa: E501 collection_formats = {} path_params = {} if 'cid' in local_var_params: path_params['cid'] = local_var_params['cid'] # noqa: E501 if 'id' in local_var_params: path_params['id'] = local_var_params['id'] # noqa: E501 query_params = [] header_params = {} form_params = [] local_var_files = {} body_params = None if 'devicev2_cert' in local_var_params: body_params = local_var_params['devicev2_cert'] # 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 = ['oauth2'] # noqa: E501 return self.api_client.call_api( '/v2/devices/{id}/certs/{cid}', 'POST', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, response_type='ArduinoDevicev2Cert', # 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 devices_v2_ota_upload_with_http_info(self, id, ota_file, **kwargs): # noqa: E501 """upload devices_v2_ota # noqa: E501 Upload a binary and send it to a device # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.devices_v2_ota_upload_with_http_info(id, ota_file, async_req=True) >>> result = thread.get() :param async_req bool: execute request asynchronously :param str id: The id of the device (required) :param file ota_file: OTA file (required) :param bool _async: If false, wait for the full OTA process, until it gets a result from the device :param int expire_in_mins: Binary expire time in minutes, default 10 mins :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 = ['id', 'ota_file', '_async', 'expire_in_mins'] 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 devices_v2_ota_upload" % key) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'id' is set if self.api_client.client_side_validation and ( 'id' not in local_var_params or # noqa: E501 local_var_params['id'] is None): # noqa: E501 raise ApiValueError( "Missing the required parameter `id` when calling `devices_v2_ota_upload`" ) # noqa: E501 # verify the required parameter 'ota_file' is set if self.api_client.client_side_validation and ( 'ota_file' not in local_var_params or # noqa: E501 local_var_params['ota_file'] is None): # noqa: E501 raise ApiValueError( "Missing the required parameter `ota_file` when calling `devices_v2_ota_upload`" ) # noqa: E501 collection_formats = {} path_params = {} if 'id' in local_var_params: path_params['id'] = local_var_params['id'] # noqa: E501 query_params = [] header_params = {} form_params = [] local_var_files = {} if '_async' in local_var_params: form_params.append( ('async', local_var_params['_async'])) # noqa: E501 if 'expire_in_mins' in local_var_params: form_params.append( ('expire_in_mins', local_var_params['expire_in_mins'])) # noqa: E501 if 'ota_file' in local_var_params: local_var_files['ota_file'] = local_var_params[ 'ota_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 = ['oauth2'] # noqa: E501 return self.api_client.call_api( '/v2/devices/{id}/ota', '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 properties_v2_timeseries_with_http_info(self, id, pid, **kwargs): # noqa: E501 """timeseries properties_v2 # noqa: E501 Get numerical property's historic data binned on a specified time interval (note: the total number of data points should NOT be greater than 1000 otherwise the result will be truncated) # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.properties_v2_timeseries_with_http_info(id, pid, async_req=True) >>> result = thread.get() :param async_req bool: execute request asynchronously :param str id: The id of the thing (required) :param str pid: ID of a numerical property (required) :param bool desc: Whether data's ordering (by time) should be descending :param str _from: Get data with a timestamp >= to this date (default: 2 weeks ago, min: 1842-01-01T00:00:00Z, max: 2242-01-01T00:00:00Z) :param int interval: Binning interval in seconds (defaut: the smallest possible value compatibly with the limit of 1000 data points in the response) :param str to: Get data with a timestamp < to this date (default: now, min: 1842-01-01T00:00:00Z, max: 2242-01-01T00:00:00Z) :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(ArduinoTimeseriesmedia, status_code(int), headers(HTTPHeaderDict)) If the method is called asynchronously, returns the request thread. """ local_var_params = locals() all_params = ['id', 'pid', 'desc', '_from', 'interval', 'to'] 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 properties_v2_timeseries" % key) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'id' is set if self.api_client.client_side_validation and ( 'id' not in local_var_params or # noqa: E501 local_var_params['id'] is None): # noqa: E501 raise ApiValueError( "Missing the required parameter `id` when calling `properties_v2_timeseries`" ) # noqa: E501 # verify the required parameter 'pid' is set if self.api_client.client_side_validation and ( 'pid' not in local_var_params or # noqa: E501 local_var_params['pid'] is None): # noqa: E501 raise ApiValueError( "Missing the required parameter `pid` when calling `properties_v2_timeseries`" ) # noqa: E501 if self.api_client.client_side_validation and 'interval' in local_var_params and local_var_params[ 'interval'] < 1: # noqa: E501 raise ApiValueError( "Invalid value for parameter `interval` when calling `properties_v2_timeseries`, must be a value greater than or equal to `1`" ) # noqa: E501 collection_formats = {} path_params = {} if 'id' in local_var_params: path_params['id'] = local_var_params['id'] # noqa: E501 if 'pid' in local_var_params: path_params['pid'] = local_var_params['pid'] # noqa: E501 query_params = [] if 'desc' in local_var_params and local_var_params[ 'desc'] is not None: # noqa: E501 query_params.append( ('desc', local_var_params['desc'])) # noqa: E501 if '_from' in local_var_params and local_var_params[ '_from'] is not None: # noqa: E501 query_params.append( ('from', local_var_params['_from'])) # noqa: E501 if 'interval' in local_var_params and local_var_params[ 'interval'] is not None: # noqa: E501 query_params.append( ('interval', local_var_params['interval'])) # noqa: E501 if 'to' in local_var_params and local_var_params[ 'to'] is not None: # noqa: E501 query_params.append(('to', local_var_params['to'])) # 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/json']) # noqa: E501 # Authentication setting auth_settings = ['oauth2'] # noqa: E501 return self.api_client.call_api( '/v2/things/{id}/properties/{pid}/timeseries', 'GET', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, response_type='ArduinoTimeseriesmedia', # 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 lora_devices_v1_create_with_http_info(self, create_lora_devices_v1_payload, **kwargs): # noqa: E501 """create lora_devices_v1 # noqa: E501 Create a new lora device. Its info are saved on our database, and on the lora provider network. Creates a device_v2 automatically # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.lora_devices_v1_create_with_http_info(create_lora_devices_v1_payload, async_req=True) >>> result = thread.get() :param async_req bool: execute request asynchronously :param CreateLoraDevicesV1Payload create_lora_devices_v1_payload: (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(ArduinoLoradevicev1, status_code(int), headers(HTTPHeaderDict)) If the method is called asynchronously, returns the request thread. """ local_var_params = locals() all_params = [ 'create_lora_devices_v1_payload' ] 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 lora_devices_v1_create" % key ) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'create_lora_devices_v1_payload' is set if self.api_client.client_side_validation and ('create_lora_devices_v1_payload' not in local_var_params or # noqa: E501 local_var_params['create_lora_devices_v1_payload'] is None): # noqa: E501 raise ApiValueError("Missing the required parameter `create_lora_devices_v1_payload` when calling `lora_devices_v1_create`") # noqa: E501 collection_formats = {} path_params = {} query_params = [] header_params = {} form_params = [] local_var_files = {} body_params = None if 'create_lora_devices_v1_payload' in local_var_params: body_params = local_var_params['create_lora_devices_v1_payload'] # 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', 'application/x-www-form-urlencoded']) # noqa: E501 # Authentication setting auth_settings = [] # noqa: E501 return self.api_client.call_api( '/v1/lora-devices/', 'PUT', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, response_type='ArduinoLoradevicev1', # 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 properties_v2_publish_with_http_info(self, id, pid, property_value, **kwargs): # noqa: E501 """publish properties_v2 # noqa: E501 Publish a property value to MQTT # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.properties_v2_publish_with_http_info(id, pid, property_value, async_req=True) >>> result = thread.get() :param async_req bool: execute request asynchronously :param str id: The id of the thing (required) :param str pid: The id of the property (required) :param PropertyValue property_value: PropertyValuePayload describes a property value (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 = ['id', 'pid', 'property_value'] # 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 properties_v2_publish" % key) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'id' is set if self.api_client.client_side_validation and ( 'id' not in local_var_params or # noqa: E501 local_var_params['id'] is None): # noqa: E501 raise ApiValueError( "Missing the required parameter `id` when calling `properties_v2_publish`" ) # noqa: E501 # verify the required parameter 'pid' is set if self.api_client.client_side_validation and ( 'pid' not in local_var_params or # noqa: E501 local_var_params['pid'] is None): # noqa: E501 raise ApiValueError( "Missing the required parameter `pid` when calling `properties_v2_publish`" ) # noqa: E501 # verify the required parameter 'property_value' is set if self.api_client.client_side_validation and ( 'property_value' not in local_var_params or # noqa: E501 local_var_params['property_value'] is None): # noqa: E501 raise ApiValueError( "Missing the required parameter `property_value` when calling `properties_v2_publish`" ) # noqa: E501 collection_formats = {} path_params = {} if 'id' in local_var_params: path_params['id'] = local_var_params['id'] # noqa: E501 if 'pid' in local_var_params: path_params['pid'] = local_var_params['pid'] # noqa: E501 query_params = [] header_params = {} form_params = [] local_var_files = {} body_params = None if 'property_value' in local_var_params: body_params = local_var_params['property_value'] # 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 = ['oauth2'] # noqa: E501 return self.api_client.call_api( '/v2/things/{id}/properties/{pid}/publish', '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)