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 get_campaign_blueprint_with_http_info(self, blueprint_id, **kwargs): # noqa: E501 """Get a campaign blueprint # 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_campaign_blueprint_with_http_info(blueprint_id, async_req=True) >>> result = thread.get() :param async_req bool: execute request asynchronously :param int blueprint_id: (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(CampaignBlueprintResponse, status_code(int), headers(HTTPHeaderDict)) If the method is called asynchronously, returns the request thread. """ local_var_params = locals() all_params = ['blueprint_id'] 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_campaign_blueprint" % key) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'blueprint_id' is set if self.api_client.client_side_validation and ( 'blueprint_id' not in local_var_params or # noqa: E501 local_var_params['blueprint_id'] is None): # noqa: E501 raise ApiValueError( "Missing the required parameter `blueprint_id` when calling `get_campaign_blueprint`" ) # noqa: E501 collection_formats = {} path_params = {} if 'blueprint_id' in local_var_params: path_params['blueprint_id'] = local_var_params[ 'blueprint_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/json']) # noqa: E501 # Authentication setting auth_settings = ['OAuth2PasswordBearer'] # noqa: E501 return self.api_client.call_api( '/campaign-blueprints/{blueprint_id}', 'GET', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, response_type='CampaignBlueprintResponse', # 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 create_custom_attribute_with_http_info(self, list_id, create_custom_attribute, **kwargs): # noqa: E501 """Create a custom attribute # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.create_custom_attribute_with_http_info(list_id, create_custom_attribute, async_req=True) >>> result = thread.get() :param async_req bool: execute request asynchronously :param int list_id: (required) :param CreateCustomAttribute create_custom_attribute: (required) :param int account_id: :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(CreateAttributeResponse, status_code(int), headers(HTTPHeaderDict)) If the method is called asynchronously, returns the request thread. """ local_var_params = locals() all_params = [ 'list_id', 'create_custom_attribute', 'account_id' ] 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 create_custom_attribute" % key ) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'list_id' is set if self.api_client.client_side_validation and ('list_id' not in local_var_params or # noqa: E501 local_var_params['list_id'] is None): # noqa: E501 raise ApiValueError("Missing the required parameter `list_id` when calling `create_custom_attribute`") # noqa: E501 # verify the required parameter 'create_custom_attribute' is set if self.api_client.client_side_validation and ('create_custom_attribute' not in local_var_params or # noqa: E501 local_var_params['create_custom_attribute'] is None): # noqa: E501 raise ApiValueError("Missing the required parameter `create_custom_attribute` when calling `create_custom_attribute`") # noqa: E501 if self.api_client.client_side_validation and 'list_id' in local_var_params and local_var_params['list_id'] < 1: # noqa: E501 raise ApiValueError("Invalid value for parameter `list_id` when calling `create_custom_attribute`, must be a value greater than or equal to `1`") # noqa: E501 collection_formats = {} path_params = {} if 'list_id' in local_var_params: path_params['list_id'] = local_var_params['list_id'] # noqa: E501 query_params = [] if 'account_id' in local_var_params and local_var_params['account_id'] is not None: # noqa: E501 query_params.append(('account_id', local_var_params['account_id'])) # noqa: E501 header_params = {} form_params = [] local_var_files = {} body_params = None if 'create_custom_attribute' in local_var_params: body_params = local_var_params['create_custom_attribute'] # 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 = ['OAuth2PasswordBearer'] # noqa: E501 return self.api_client.call_api( '/lists/{list_id}/custom-attributes', 'POST', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, response_type='CreateAttributeResponse', # 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_suppressed_email_with_http_info(self, email, **kwargs): # noqa: E501 """Delete a suppressed email # 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_suppressed_email_with_http_info(email, async_req=True) >>> result = thread.get() :param async_req bool: execute request asynchronously :param str email: Full email, a local part wildcard or a domain wildcard. Examples: *@domain.com, john@*, [email protected] (required) :param int account_id: :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(DeleteSuppressedEmailResponse, status_code(int), headers(HTTPHeaderDict)) If the method is called asynchronously, returns the request thread. """ local_var_params = locals() all_params = [ 'email', 'account_id' ] 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 delete_suppressed_email" % key ) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'email' is set if self.api_client.client_side_validation and ('email' not in local_var_params or # noqa: E501 local_var_params['email'] is None): # noqa: E501 raise ApiValueError("Missing the required parameter `email` when calling `delete_suppressed_email`") # noqa: E501 if self.api_client.client_side_validation and 'email' in local_var_params and not re.search(r'(^\*@[^@*]+\.[^@*]+$|^[^@*]+@\*$|^[^@*]+@[^@*]+\.[^@*]+$)', local_var_params['email']): # noqa: E501 raise ApiValueError("Invalid value for parameter `email` when calling `delete_suppressed_email`, must conform to the pattern `/(^\*@[^@*]+\.[^@*]+$|^[^@*]+@\*$|^[^@*]+@[^@*]+\.[^@*]+$)/`") # noqa: E501 collection_formats = {} path_params = {} if 'email' in local_var_params: path_params['email'] = local_var_params['email'] # noqa: E501 query_params = [] if 'account_id' in local_var_params and local_var_params['account_id'] is not None: # noqa: E501 query_params.append(('account_id', local_var_params['account_id'])) # 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 = ['OAuth2PasswordBearer'] # noqa: E501 return self.api_client.call_api( '/suppressed-emails/{email}', 'DELETE', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, response_type='DeleteSuppressedEmailResponse', # 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 list_senders_with_http_info(self, **kwargs): # noqa: E501 """Show all senders # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.list_senders_with_http_info(async_req=True) >>> result = thread.get() :param async_req bool: execute request asynchronously :param int page: :param int per_page: :param int account_id: :param bool with_count: :param str sort: Sort term and direction, using syntax `[-|+]term`. Valid terms: - `name` - `email` - `confirmed` :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(SendersResponse, status_code(int), headers(HTTPHeaderDict)) If the method is called asynchronously, returns the request thread. """ local_var_params = locals() all_params = ['page', 'per_page', 'account_id', 'with_count', 'sort'] 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 list_senders" % key) local_var_params[key] = val del local_var_params['kwargs'] if self.api_client.client_side_validation and 'page' in local_var_params and local_var_params[ 'page'] < 1: # noqa: E501 raise ApiValueError( "Invalid value for parameter `page` when calling `list_senders`, must be a value greater than or equal to `1`" ) # noqa: E501 if self.api_client.client_side_validation and 'per_page' in local_var_params and local_var_params[ 'per_page'] < 1: # noqa: E501 raise ApiValueError( "Invalid value for parameter `per_page` when calling `list_senders`, must be a value greater than or equal to `1`" ) # noqa: E501 collection_formats = {} path_params = {} query_params = [] if 'page' in local_var_params and local_var_params[ 'page'] is not None: # noqa: E501 query_params.append( ('page', local_var_params['page'])) # noqa: E501 if 'per_page' in local_var_params and local_var_params[ 'per_page'] is not None: # noqa: E501 query_params.append( ('per_page', local_var_params['per_page'])) # noqa: E501 if 'account_id' in local_var_params and local_var_params[ 'account_id'] is not None: # noqa: E501 query_params.append( ('account_id', local_var_params['account_id'])) # noqa: E501 if 'with_count' in local_var_params and local_var_params[ 'with_count'] is not None: # noqa: E501 query_params.append( ('with_count', local_var_params['with_count'])) # noqa: E501 if 'sort' in local_var_params and local_var_params[ 'sort'] is not None: # noqa: E501 query_params.append( ('sort', local_var_params['sort'])) # 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 = ['OAuth2PasswordBearer'] # noqa: E501 return self.api_client.call_api( '/brands/default/senders', 'GET', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, response_type='SendersResponse', # 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 resend_account_verification_with_http_info(self, resend_verification_email, **kwargs): # noqa: E501 """Resend the account verification email # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.resend_account_verification_with_http_info(resend_verification_email, async_req=True) >>> result = thread.get() :param async_req bool: execute request asynchronously :param ResendVerificationEmail resend_verification_email: (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(ResendAccountVerificationEmailResponse, status_code(int), headers(HTTPHeaderDict)) If the method is called asynchronously, returns the request thread. """ local_var_params = locals() all_params = [ 'resend_verification_email' ] 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 resend_account_verification" % key ) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'resend_verification_email' is set if self.api_client.client_side_validation and ('resend_verification_email' not in local_var_params or # noqa: E501 local_var_params['resend_verification_email'] is None): # noqa: E501 raise ApiValueError("Missing the required parameter `resend_verification_email` when calling `resend_account_verification`") # noqa: E501 collection_formats = {} path_params = {} query_params = [] header_params = {} form_params = [] local_var_files = {} body_params = None if 'resend_verification_email' in local_var_params: body_params = local_var_params['resend_verification_email'] # 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( '/accounts/resend-verification-email', 'POST', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, response_type='ResendAccountVerificationEmailResponse', # 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_action_logs_with_http_info(self, workflow_id, action_id, **kwargs): # noqa: E501 """Show action logs # 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_action_logs_with_http_info(workflow_id, action_id, async_req=True) >>> result = thread.get() :param async_req bool: execute request asynchronously :param str workflow_id: (required) :param str action_id: (required) :param int account_id: :param int start_time: :param int end_time: :param int page: :param int per_page: :param bool with_count: :param str filter: Valid Terms: - `additional_info` - `link_id` - `contact_id` - `email` - `log_id` - `track_id` - `type` Valid Operators: - `==` Query separator: - `;` :param str sort: Sort term and direction, using syntax `[-|+]term`. Valid terms: - `time` - `log_id` :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(ActionLogsResponse, status_code(int), headers(HTTPHeaderDict)) If the method is called asynchronously, returns the request thread. """ local_var_params = locals() all_params = [ 'workflow_id', 'action_id', 'account_id', 'start_time', 'end_time', 'page', 'per_page', 'with_count', 'filter', 'sort' ] 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_action_logs" % key) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'workflow_id' is set if self.api_client.client_side_validation and ( 'workflow_id' not in local_var_params or # noqa: E501 local_var_params['workflow_id'] is None): # noqa: E501 raise ApiValueError( "Missing the required parameter `workflow_id` when calling `get_action_logs`" ) # noqa: E501 # verify the required parameter 'action_id' is set if self.api_client.client_side_validation and ( 'action_id' not in local_var_params or # noqa: E501 local_var_params['action_id'] is None): # noqa: E501 raise ApiValueError( "Missing the required parameter `action_id` when calling `get_action_logs`" ) # noqa: E501 if self.api_client.client_side_validation and 'start_time' in local_var_params and local_var_params[ 'start_time'] > 2147483647: # noqa: E501 raise ApiValueError( "Invalid value for parameter `start_time` when calling `get_action_logs`, must be a value less than or equal to `2147483647`" ) # noqa: E501 if self.api_client.client_side_validation and 'start_time' in local_var_params and local_var_params[ 'start_time'] < 1: # noqa: E501 raise ApiValueError( "Invalid value for parameter `start_time` when calling `get_action_logs`, must be a value greater than or equal to `1`" ) # noqa: E501 if self.api_client.client_side_validation and 'end_time' in local_var_params and local_var_params[ 'end_time'] > 2147483647: # noqa: E501 raise ApiValueError( "Invalid value for parameter `end_time` when calling `get_action_logs`, must be a value less than or equal to `2147483647`" ) # noqa: E501 if self.api_client.client_side_validation and 'end_time' in local_var_params and local_var_params[ 'end_time'] < 1: # noqa: E501 raise ApiValueError( "Invalid value for parameter `end_time` when calling `get_action_logs`, must be a value greater than or equal to `1`" ) # noqa: E501 if self.api_client.client_side_validation and 'page' in local_var_params and local_var_params[ 'page'] < 1: # noqa: E501 raise ApiValueError( "Invalid value for parameter `page` when calling `get_action_logs`, must be a value greater than or equal to `1`" ) # noqa: E501 if self.api_client.client_side_validation and 'per_page' in local_var_params and local_var_params[ 'per_page'] < 1: # noqa: E501 raise ApiValueError( "Invalid value for parameter `per_page` when calling `get_action_logs`, must be a value greater than or equal to `1`" ) # noqa: E501 if self.api_client.client_side_validation and 'sort' in local_var_params and not re.search( r'[-|+]?.*', local_var_params['sort']): # noqa: E501 raise ApiValueError( "Invalid value for parameter `sort` when calling `get_action_logs`, must conform to the pattern `/[-|+]?.*/`" ) # noqa: E501 collection_formats = {} path_params = {} if 'workflow_id' in local_var_params: path_params['workflow_id'] = local_var_params[ 'workflow_id'] # noqa: E501 if 'action_id' in local_var_params: path_params['action_id'] = local_var_params[ 'action_id'] # noqa: E501 query_params = [] if 'account_id' in local_var_params and local_var_params[ 'account_id'] is not None: # noqa: E501 query_params.append( ('account_id', local_var_params['account_id'])) # noqa: E501 if 'start_time' in local_var_params and local_var_params[ 'start_time'] is not None: # noqa: E501 query_params.append( ('start_time', local_var_params['start_time'])) # noqa: E501 if 'end_time' in local_var_params and local_var_params[ 'end_time'] is not None: # noqa: E501 query_params.append( ('end_time', local_var_params['end_time'])) # noqa: E501 if 'page' in local_var_params and local_var_params[ 'page'] is not None: # noqa: E501 query_params.append( ('page', local_var_params['page'])) # noqa: E501 if 'per_page' in local_var_params and local_var_params[ 'per_page'] is not None: # noqa: E501 query_params.append( ('per_page', local_var_params['per_page'])) # noqa: E501 if 'with_count' in local_var_params and local_var_params[ 'with_count'] is not None: # noqa: E501 query_params.append( ('with_count', local_var_params['with_count'])) # noqa: E501 if 'filter' in local_var_params and local_var_params[ 'filter'] is not None: # noqa: E501 query_params.append( ('filter', local_var_params['filter'])) # noqa: E501 if 'sort' in local_var_params and local_var_params[ 'sort'] is not None: # noqa: E501 query_params.append( ('sort', local_var_params['sort'])) # 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 = ['OAuth2PasswordBearer'] # noqa: E501 return self.api_client.call_api( '/logs/workflows/{workflow_id}/actions/{action_id}', 'GET', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, response_type='ActionLogsResponse', # 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 get_self_account_stats_with_http_info(self, start_time, end_time, **kwargs): # noqa: E501 """Show my account report # 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_self_account_stats_with_http_info(start_time, end_time, async_req=True) >>> result = thread.get() :param async_req bool: execute request asynchronously :param int start_time: (required) :param int end_time: (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(AccountStatsResponse, status_code(int), headers(HTTPHeaderDict)) If the method is called asynchronously, returns the request thread. """ local_var_params = locals() all_params = ['start_time', 'end_time'] 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_self_account_stats" % key) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'start_time' is set if self.api_client.client_side_validation and ( 'start_time' not in local_var_params or # noqa: E501 local_var_params['start_time'] is None): # noqa: E501 raise ApiValueError( "Missing the required parameter `start_time` when calling `get_self_account_stats`" ) # noqa: E501 # verify the required parameter 'end_time' is set if self.api_client.client_side_validation and ( 'end_time' not in local_var_params or # noqa: E501 local_var_params['end_time'] is None): # noqa: E501 raise ApiValueError( "Missing the required parameter `end_time` when calling `get_self_account_stats`" ) # noqa: E501 if self.api_client.client_side_validation and 'start_time' in local_var_params and local_var_params[ 'start_time'] > 2147483647: # noqa: E501 raise ApiValueError( "Invalid value for parameter `start_time` when calling `get_self_account_stats`, must be a value less than or equal to `2147483647`" ) # noqa: E501 if self.api_client.client_side_validation and 'start_time' in local_var_params and local_var_params[ 'start_time'] < 1: # noqa: E501 raise ApiValueError( "Invalid value for parameter `start_time` when calling `get_self_account_stats`, must be a value greater than or equal to `1`" ) # noqa: E501 if self.api_client.client_side_validation and 'end_time' in local_var_params and local_var_params[ 'end_time'] > 2147483647: # noqa: E501 raise ApiValueError( "Invalid value for parameter `end_time` when calling `get_self_account_stats`, must be a value less than or equal to `2147483647`" ) # noqa: E501 if self.api_client.client_side_validation and 'end_time' in local_var_params and local_var_params[ 'end_time'] < 1: # noqa: E501 raise ApiValueError( "Invalid value for parameter `end_time` when calling `get_self_account_stats`, must be a value greater than or equal to `1`" ) # noqa: E501 collection_formats = {} path_params = {} query_params = [] if 'start_time' in local_var_params and local_var_params[ 'start_time'] is not None: # noqa: E501 query_params.append( ('start_time', local_var_params['start_time'])) # noqa: E501 if 'end_time' in local_var_params and local_var_params[ 'end_time'] is not None: # noqa: E501 query_params.append( ('end_time', local_var_params['end_time'])) # 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 = ['OAuth2PasswordBearer'] # noqa: E501 return self.api_client.call_api( '/reports/accounts/self', 'GET', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, response_type='AccountStatsResponse', # 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 patch_domains_with_http_info(self, patch_domains, **kwargs): # noqa: E501 """Change domains # noqa: E501 Change the Tracking and Bounce domains. # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.patch_domains_with_http_info(patch_domains, async_req=True) >>> result = thread.get() :param async_req bool: execute request asynchronously :param PatchDomains patch_domains: (required) :param int account_id: :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(PatchDomainsResponse, status_code(int), headers(HTTPHeaderDict)) If the method is called asynchronously, returns the request thread. """ local_var_params = locals() all_params = ['patch_domains', 'account_id'] 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 patch_domains" % key) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'patch_domains' is set if self.api_client.client_side_validation and ( 'patch_domains' not in local_var_params or # noqa: E501 local_var_params['patch_domains'] is None): # noqa: E501 raise ApiValueError( "Missing the required parameter `patch_domains` when calling `patch_domains`" ) # noqa: E501 collection_formats = {} path_params = {} query_params = [] if 'account_id' in local_var_params and local_var_params[ 'account_id'] is not None: # noqa: E501 query_params.append( ('account_id', local_var_params['account_id'])) # noqa: E501 header_params = {} form_params = [] local_var_files = {} body_params = None if 'patch_domains' in local_var_params: body_params = local_var_params['patch_domains'] # 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 = ['OAuth2PasswordBearer'] # noqa: E501 return self.api_client.call_api( '/brands/default/domains/default', 'PATCH', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, response_type='PatchDomainsResponse', # 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 create_token_with_http_info(self, username, password, **kwargs): # noqa: E501 """Create a token # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.create_token_with_http_info(username, password, async_req=True) >>> result = thread.get() :param async_req bool: execute request asynchronously :param str username: (required) :param str password: (required) :param PasswordGrantType grant_type: :param int account_id: :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(TokenResponse, status_code(int), headers(HTTPHeaderDict)) If the method is called asynchronously, returns the request thread. """ local_var_params = locals() all_params = [ 'username', 'password', 'grant_type', 'account_id' ] 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 create_token" % 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 `create_token`") # 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 `create_token`") # noqa: E501 collection_formats = {} path_params = {} query_params = [] header_params = {} form_params = [] local_var_files = {} if 'grant_type' in local_var_params: form_params.append(('grant_type', local_var_params['grant_type'])) # noqa: E501 if 'username' in local_var_params: form_params.append(('username', local_var_params['username'])) # noqa: E501 if 'password' in local_var_params: form_params.append(('password', local_var_params['password'])) # noqa: E501 if 'account_id' in local_var_params: form_params.append(('account_id', local_var_params['account_id'])) # 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 ['application/x-www-form-urlencoded']) # noqa: E501 # Authentication setting auth_settings = [] # noqa: E501 return self.api_client.call_api( '/token', 'POST', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, response_type='TokenResponse', # 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) # log response body logger.debug("response body: %s", r.data) if not 200 <= r.status <= 299: raise ApiException(http_resp=r) return r