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 share_array_by_invite_with_http_info(self, namespace, array, email_invite, **kwargs): # noqa: E501 """share_array_by_invite # noqa: E501 Sends email to multiple recipients with sharing information regarding an array # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.share_array_by_invite_with_http_info(namespace, array, email_invite, async_req=True) >>> result = thread.get() :param async_req bool: execute request asynchronously :param str namespace: namespace array is in (an organization name or user's username) (required) :param str array: name/uri of array that is url-encoded (required) :param InvitationArrayShareEmail email_invite: list of email recipients (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 = ["namespace", "array", "email_invite"] 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 share_array_by_invite" % key) local_var_params[key] = val del local_var_params["kwargs"] # verify the required parameter 'namespace' is set if self.api_client.client_side_validation and ( "namespace" not in local_var_params or local_var_params["namespace"] is None # noqa: E501 ): # noqa: E501 raise ApiValueError( "Missing the required parameter `namespace` when calling `share_array_by_invite`" ) # noqa: E501 # verify the required parameter 'array' is set if self.api_client.client_side_validation and ( "array" not in local_var_params or local_var_params["array"] is None # noqa: E501 ): # noqa: E501 raise ApiValueError( "Missing the required parameter `array` when calling `share_array_by_invite`" ) # noqa: E501 # verify the required parameter 'email_invite' is set if self.api_client.client_side_validation and ( "email_invite" not in local_var_params or local_var_params["email_invite"] is None # noqa: E501 ): # noqa: E501 raise ApiValueError( "Missing the required parameter `email_invite` when calling `share_array_by_invite`" ) # noqa: E501 collection_formats = {} path_params = {} if "namespace" in local_var_params: path_params["namespace"] = local_var_params[ "namespace"] # noqa: E501 if "array" in local_var_params: path_params["array"] = local_var_params["array"] # noqa: E501 query_params = [] header_params = {} form_params = [] local_var_files = {} body_params = None if "email_invite" in local_var_params: body_params = local_var_params["email_invite"] # 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 = ["ApiKeyAuth", "BasicAuth"] # noqa: E501 return self.api_client.call_api( "/invitations/{namespace}/{array}/share", "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 accept_invitation_with_http_info(self, invitation, **kwargs): # noqa: E501 """accept_invitation # noqa: E501 Accepts invitation # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.accept_invitation_with_http_info(invitation, async_req=True) >>> result = thread.get() :param async_req bool: execute request asynchronously :param str invitation: the id of invitation about to be accepted (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 = ["invitation"] 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 accept_invitation" % key) local_var_params[key] = val del local_var_params["kwargs"] # verify the required parameter 'invitation' is set if self.api_client.client_side_validation and ( "invitation" not in local_var_params or local_var_params["invitation"] is None # noqa: E501 ): # noqa: E501 raise ApiValueError( "Missing the required parameter `invitation` when calling `accept_invitation`" ) # noqa: E501 collection_formats = {} path_params = {} if "invitation" in local_var_params: path_params["invitation"] = local_var_params[ "invitation"] # 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 = ["ApiKeyAuth", "BasicAuth"] # noqa: E501 return self.api_client.call_api( "/invitations/{invitation}", "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 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, post_params=post_params, _preload_content=_preload_content, _request_timeout=_request_timeout, body=body, ) 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 finalize_query_with_http_info(self, namespace, array, type, content_type, query, **kwargs): # noqa: E501 """finalize_query # noqa: E501 send a query to run against a specified array/URI registered to a group/project # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.finalize_query_with_http_info(namespace, array, type, content_type, query, async_req=True) >>> result = thread.get() :param async_req bool: execute request asynchronously :param str namespace: namespace array is in (an organization name or user's username) (required) :param str array: name/uri of array that is url-encoded (required) :param str type: type of query (required) :param str content_type: Content Type of input and return mime (required) :param Query query: query to run (required) :param str x_payer: Name of organization or user who should be charged for this request :param int open_at: open_at for array in unix epoch :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(Query, status_code(int), headers(HTTPHeaderDict)) If the method is called asynchronously, returns the request thread. """ local_var_params = locals() all_params = [ "namespace", "array", "type", "content_type", "query", "x_payer", "open_at", ] # 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 finalize_query" % key) local_var_params[key] = val del local_var_params["kwargs"] # verify the required parameter 'namespace' is set if "namespace" not in local_var_params or local_var_params[ "namespace"] is None: raise ApiValueError( "Missing the required parameter `namespace` when calling `finalize_query`" ) # noqa: E501 # verify the required parameter 'array' is set if "array" not in local_var_params or local_var_params["array"] is None: raise ApiValueError( "Missing the required parameter `array` when calling `finalize_query`" ) # noqa: E501 # verify the required parameter 'type' is set if "type" not in local_var_params or local_var_params["type"] is None: raise ApiValueError( "Missing the required parameter `type` when calling `finalize_query`" ) # noqa: E501 # verify the required parameter 'content_type' is set if ("content_type" not in local_var_params or local_var_params["content_type"] is None): raise ApiValueError( "Missing the required parameter `content_type` when calling `finalize_query`" ) # noqa: E501 # verify the required parameter 'query' is set if "query" not in local_var_params or local_var_params["query"] is None: raise ApiValueError( "Missing the required parameter `query` when calling `finalize_query`" ) # noqa: E501 collection_formats = {} path_params = {} if "namespace" in local_var_params: path_params["namespace"] = local_var_params[ "namespace"] # noqa: E501 if "array" in local_var_params: path_params["array"] = local_var_params["array"] # noqa: E501 query_params = [] if "type" in local_var_params: query_params.append( ("type", local_var_params["type"])) # noqa: E501 if "open_at" in local_var_params: query_params.append( ("open_at", local_var_params["open_at"])) # noqa: E501 header_params = {} if "content_type" in local_var_params: header_params["Content-Type"] = local_var_params[ "content_type"] # noqa: E501 if "x_payer" in local_var_params: header_params["X-Payer"] = local_var_params[ "x_payer"] # noqa: E501 form_params = [] local_var_files = {} body_params = None if "query" in local_var_params: body_params = local_var_params["query"] # HTTP header `Accept` header_params["Accept"] = self.api_client.select_header_accept( ["application/json", "application/capnp"]) # noqa: E501 # HTTP header `Content-Type` header_params[ "Content-Type"] = self.api_client.select_header_content_type( # noqa: E501 ["application/json", "application/capnp"]) # noqa: E501 # Authentication setting auth_settings = ["ApiKeyAuth", "BasicAuth"] # noqa: E501 return self.api_client.call_api( "/arrays/{namespace}/{array}/query/finalize", "POST", path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, response_type="Query", # 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 run_sql_with_http_info(self, namespace, sql, **kwargs): # noqa: E501 """run_sql # noqa: E501 Run a sql query # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.run_sql_with_http_info(namespace, sql, async_req=True) >>> result = thread.get() :param async_req bool: execute request asynchronously :param str namespace: namespace to run task under is in (an organization name or user's username) (required) :param SQLParameters sql: sql being submitted (required) :param str accept_encoding: Encoding to use :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[object], status_code(int), headers(HTTPHeaderDict)) If the method is called asynchronously, returns the request thread. """ local_var_params = locals() all_params = ["namespace", "sql", "accept_encoding"] # 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 run_sql" % key ) local_var_params[key] = val del local_var_params["kwargs"] # verify the required parameter 'namespace' is set if "namespace" not in local_var_params or local_var_params["namespace"] is None: raise ApiValueError( "Missing the required parameter `namespace` when calling `run_sql`" ) # noqa: E501 # verify the required parameter 'sql' is set if "sql" not in local_var_params or local_var_params["sql"] is None: raise ApiValueError( "Missing the required parameter `sql` when calling `run_sql`" ) # noqa: E501 collection_formats = {} path_params = {} if "namespace" in local_var_params: path_params["namespace"] = local_var_params["namespace"] # noqa: E501 query_params = [] header_params = {} if "accept_encoding" in local_var_params: header_params["Accept-Encoding"] = local_var_params[ "accept_encoding" ] # noqa: E501 form_params = [] local_var_files = {} body_params = None if "sql" in local_var_params: body_params = local_var_params["sql"] # 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 = ["ApiKeyAuth", "BasicAuth"] # noqa: E501 return self.api_client.call_api( "/sql/{namespace}", "POST", path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, response_type="list[object]", # 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 task_id_get_with_http_info(self, id, **kwargs): # noqa: E501 """task_id_get # noqa: E501 Fetch an array task # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.task_id_get_with_http_info(id, async_req=True) >>> result = thread.get() :param async_req bool: execute request asynchronously :param str id: task id to fetch (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(ArrayTask, status_code(int), headers(HTTPHeaderDict)) 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 task_id_get" % key ) local_var_params[key] = val del local_var_params["kwargs"] # verify the required parameter 'id' is set if "id" not in local_var_params or local_var_params["id"] is None: raise ApiValueError( "Missing the required parameter `id` when calling `task_id_get`" ) # 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 # HTTP header `Accept` header_params["Accept"] = self.api_client.select_header_accept( ["application/json"] ) # noqa: E501 # Authentication setting auth_settings = ["ApiKeyAuth", "BasicAuth"] # noqa: E501 return self.api_client.call_api( "/task/{id}", "GET", path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, response_type="ArrayTask", # 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_notebook_name_with_http_info(self, namespace, array, notebook_metadata, **kwargs): # noqa: E501 """update_notebook_name # noqa: E501 update name on a notebok, moving related s3 object to new location # 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_notebook_name_with_http_info(namespace, array, notebook_metadata, async_req=True) >>> result = thread.get() :param async_req bool: execute request asynchronously :param str namespace: namespace array is in (an organization name or user's username) (required) :param str array: name/uri of notebook (array) that is url-encoded (required) :param ArrayInfoUpdate notebook_metadata: notebook (array) metadata to update (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 = ["namespace", "array", "notebook_metadata"] 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_notebook_name" % key) local_var_params[key] = val del local_var_params["kwargs"] # verify the required parameter 'namespace' is set if "namespace" not in local_var_params or local_var_params[ "namespace"] is None: raise ApiValueError( "Missing the required parameter `namespace` when calling `update_notebook_name`" ) # verify the required parameter 'array' is set if "array" not in local_var_params or local_var_params["array"] is None: raise ApiValueError( "Missing the required parameter `array` when calling `update_notebook_name`" ) # verify the required parameter 'notebook_metadata' is set if ("notebook_metadata" not in local_var_params or local_var_params["notebook_metadata"] is None): raise ApiValueError( "Missing the required parameter `notebook_metadata` when calling `update_notebook_name`" ) collection_formats = {} path_params = {} if "namespace" in local_var_params: path_params["namespace"] = local_var_params[ "namespace"] # noqa: E501 if "array" in local_var_params: path_params["array"] = local_var_params["array"] # noqa: E501 query_params = [] header_params = {} form_params = [] local_var_files = {} body_params = None if "notebook_metadata" in local_var_params: body_params = local_var_params["notebook_metadata"] # 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 = ["ApiKeyAuth", "BasicAuth"] # noqa: E501 return self.api_client.call_api( "/notebooks/{namespace}/{array}/rename", "PATCH", 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 shutdown_notebook_server_with_http_info(self, namespace, **kwargs): # noqa: E501 """shutdown_notebook_server # noqa: E501 Shutdown a notebook server # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.shutdown_notebook_server_with_http_info(namespace, async_req=True) >>> result = thread.get() :param async_req bool: execute request asynchronously :param str namespace: namespace notebook is in (an organization name or user's username) (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 = ["namespace"] # 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 shutdown_notebook_server" % key) local_var_params[key] = val del local_var_params["kwargs"] # verify the required parameter 'namespace' is set if "namespace" not in local_var_params or local_var_params[ "namespace"] is None: raise ApiValueError( "Missing the required parameter `namespace` when calling `shutdown_notebook_server`" ) # noqa: E501 collection_formats = {} path_params = {} if "namespace" in local_var_params: path_params["namespace"] = local_var_params[ "namespace"] # 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 = ["ApiKeyAuth", "BasicAuth"] # noqa: E501 return self.api_client.call_api( "/notebooks/server/{namespace}", "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 join_organization_with_http_info(self, organization, email_invite, **kwargs): # noqa: E501 """join_organization # noqa: E501 Sends email to multiple recipients with joining information regarding an organization # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.join_organization_with_http_info(organization, email_invite, async_req=True) >>> result = thread.get() :param async_req bool: execute request asynchronously :param str organization: name or uuid of organization (required) :param InvitationOrganizationJoinEmail email_invite: list of email recipients (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 = ["organization", "email_invite"] # 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 join_organization" % key) local_var_params[key] = val del local_var_params["kwargs"] # verify the required parameter 'organization' is set if ("organization" not in local_var_params or local_var_params["organization"] is None): raise ApiValueError( "Missing the required parameter `organization` when calling `join_organization`" ) # noqa: E501 # verify the required parameter 'email_invite' is set if ("email_invite" not in local_var_params or local_var_params["email_invite"] is None): raise ApiValueError( "Missing the required parameter `email_invite` when calling `join_organization`" ) # noqa: E501 collection_formats = {} path_params = {} if "organization" in local_var_params: path_params["organization"] = local_var_params[ "organization"] # noqa: E501 query_params = [] header_params = {} form_params = [] local_var_files = {} body_params = None if "email_invite" in local_var_params: body_params = local_var_params["email_invite"] # 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 = ["ApiKeyAuth", "BasicAuth"] # noqa: E501 return self.api_client.call_api( "/invitations/{organization}/join", "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 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