pinecone.openapi_support.asyncio_endpoint
1from .model_utils import none_type 2from .api_client_utils import HeaderUtil 3from .endpoint_utils import EndpointUtils, ExtraOpenApiKwargsTypedDict 4 5 6class AsyncioEndpoint(object): 7 def __init__( 8 self, 9 settings=None, 10 params_map=None, 11 root_map=None, 12 headers_map=None, 13 api_client=None, 14 callable=None, 15 ) -> None: 16 """Creates an endpoint 17 18 Args: 19 settings (dict): see below key value pairs 20 'response_type' (tuple/None): response type 21 'auth' (list): a list of auth type keys 22 'endpoint_path' (str): the endpoint path 23 'operation_id' (str): endpoint string identifier 24 'http_method' (str): POST/PUT/PATCH/GET etc 25 'servers' (list): list of str servers that this endpoint is at 26 params_map (dict): see below key value pairs 27 'all' (list): list of str endpoint parameter names 28 'required' (list): list of required parameter names 29 'nullable' (list): list of nullable parameter names 30 'enum' (list): list of parameters with enum values 31 'validation' (list): list of parameters with validations 32 root_map 33 'validations' (dict): the dict mapping endpoint parameter tuple 34 paths to their validation dictionaries 35 'allowed_values' (dict): the dict mapping endpoint parameter 36 tuple paths to their allowed_values (enum) dictionaries 37 'openapi_types' (dict): param_name to openapi type 38 'attribute_map' (dict): param_name to camelCase name 39 'location_map' (dict): param_name to 'body', 'file', 'form', 40 'header', 'path', 'query' 41 collection_format_map (dict): param_name to `csv` etc. 42 headers_map (dict): see below key value pairs 43 'accept' (list): list of Accept header strings 44 'content_type' (list): list of Content-Type header strings 45 api_client (AsyncioApiClient) api client instance 46 callable (function): the function which is invoked when the 47 Endpoint is called 48 """ 49 self.settings = settings 50 self.params_map = params_map 51 self.params_map["all"].extend( 52 [ 53 "_preload_content", 54 "_request_timeout", 55 "_return_http_data_only", 56 "_check_input_type", 57 "_check_return_type", 58 ] 59 ) 60 self.params_map["nullable"].extend(["_request_timeout"]) 61 self.validations = root_map["validations"] 62 self.allowed_values = root_map["allowed_values"] 63 self.openapi_types = root_map["openapi_types"] 64 extra_types = { 65 "_preload_content": (bool,), 66 "_request_timeout": (none_type, float, (float,), [float], int, (int,), [int]), 67 "_return_http_data_only": (bool,), 68 "_check_input_type": (bool,), 69 "_check_return_type": (bool,), 70 } 71 self.openapi_types.update(extra_types) 72 self.attribute_map = root_map["attribute_map"] 73 self.location_map = root_map["location_map"] 74 self.collection_format_map = root_map["collection_format_map"] 75 self.headers_map = headers_map 76 self.api_client = api_client 77 self.callable = callable 78 79 async def __call__(self, *args, **kwargs): 80 """This method is invoked when endpoints are called 81 Example: 82 83 api_instance = InferenceApi() 84 api_instance.embed # this is an instance of the class Endpoint 85 api_instance.embed() # this invokes api_instance.embed.__call__() 86 which then invokes the callable functions stored in that endpoint at 87 api_instance.embed.callable or self.callable in this class 88 89 """ 90 return await self.callable(self, *args, **kwargs) 91 92 async def call_with_http_info(self, **kwargs): 93 _host = self.api_client.configuration.host 94 95 EndpointUtils.raise_if_unexpected_param( 96 params_map=self.params_map, settings=self.settings, kwargs=kwargs 97 ) 98 99 EndpointUtils.raise_if_missing_required_params( 100 params_map=self.params_map, settings=self.settings, kwargs=kwargs 101 ) 102 103 EndpointUtils.raise_if_invalid_inputs( 104 config=self.api_client.configuration, 105 params_map=self.params_map, 106 allowed_values=self.allowed_values, 107 validations=self.validations, 108 openapi_types=self.openapi_types, 109 kwargs=kwargs, 110 ) 111 112 params = EndpointUtils.gather_params( 113 attribute_map=self.attribute_map, 114 location_map=self.location_map, 115 openapi_types=self.openapi_types, 116 collection_format_map=self.collection_format_map, 117 kwargs=kwargs, 118 ) 119 120 HeaderUtil.prepare_headers(headers_map=self.headers_map, params=params) 121 122 return await self.api_client.call_api( 123 self.settings["endpoint_path"], 124 self.settings["http_method"], 125 params["path"], 126 params["query"], 127 params["header"], 128 body=params["body"], 129 post_params=params["form"], 130 files=params["file"], 131 response_type=self.settings["response_type"], 132 auth_settings=self.settings["auth"], 133 _check_type=kwargs["_check_return_type"], 134 _return_http_data_only=kwargs["_return_http_data_only"], 135 _preload_content=kwargs["_preload_content"], 136 _request_timeout=kwargs["_request_timeout"], 137 _host=_host, 138 collection_formats=params["collection_format"], 139 ) 140 141 def _process_openapi_kwargs( 142 self, kwargs: ExtraOpenApiKwargsTypedDict 143 ) -> ExtraOpenApiKwargsTypedDict: 144 kwargs["_return_http_data_only"] = kwargs.get("_return_http_data_only", True) 145 kwargs["_preload_content"] = kwargs.get("_preload_content", True) 146 kwargs["_request_timeout"] = kwargs.get("_request_timeout", None) 147 kwargs["_check_input_type"] = kwargs.get("_check_input_type", True) 148 kwargs["_check_return_type"] = kwargs.get("_check_return_type", True) 149 return kwargs
class
AsyncioEndpoint:
7class AsyncioEndpoint(object): 8 def __init__( 9 self, 10 settings=None, 11 params_map=None, 12 root_map=None, 13 headers_map=None, 14 api_client=None, 15 callable=None, 16 ) -> None: 17 """Creates an endpoint 18 19 Args: 20 settings (dict): see below key value pairs 21 'response_type' (tuple/None): response type 22 'auth' (list): a list of auth type keys 23 'endpoint_path' (str): the endpoint path 24 'operation_id' (str): endpoint string identifier 25 'http_method' (str): POST/PUT/PATCH/GET etc 26 'servers' (list): list of str servers that this endpoint is at 27 params_map (dict): see below key value pairs 28 'all' (list): list of str endpoint parameter names 29 'required' (list): list of required parameter names 30 'nullable' (list): list of nullable parameter names 31 'enum' (list): list of parameters with enum values 32 'validation' (list): list of parameters with validations 33 root_map 34 'validations' (dict): the dict mapping endpoint parameter tuple 35 paths to their validation dictionaries 36 'allowed_values' (dict): the dict mapping endpoint parameter 37 tuple paths to their allowed_values (enum) dictionaries 38 'openapi_types' (dict): param_name to openapi type 39 'attribute_map' (dict): param_name to camelCase name 40 'location_map' (dict): param_name to 'body', 'file', 'form', 41 'header', 'path', 'query' 42 collection_format_map (dict): param_name to `csv` etc. 43 headers_map (dict): see below key value pairs 44 'accept' (list): list of Accept header strings 45 'content_type' (list): list of Content-Type header strings 46 api_client (AsyncioApiClient) api client instance 47 callable (function): the function which is invoked when the 48 Endpoint is called 49 """ 50 self.settings = settings 51 self.params_map = params_map 52 self.params_map["all"].extend( 53 [ 54 "_preload_content", 55 "_request_timeout", 56 "_return_http_data_only", 57 "_check_input_type", 58 "_check_return_type", 59 ] 60 ) 61 self.params_map["nullable"].extend(["_request_timeout"]) 62 self.validations = root_map["validations"] 63 self.allowed_values = root_map["allowed_values"] 64 self.openapi_types = root_map["openapi_types"] 65 extra_types = { 66 "_preload_content": (bool,), 67 "_request_timeout": (none_type, float, (float,), [float], int, (int,), [int]), 68 "_return_http_data_only": (bool,), 69 "_check_input_type": (bool,), 70 "_check_return_type": (bool,), 71 } 72 self.openapi_types.update(extra_types) 73 self.attribute_map = root_map["attribute_map"] 74 self.location_map = root_map["location_map"] 75 self.collection_format_map = root_map["collection_format_map"] 76 self.headers_map = headers_map 77 self.api_client = api_client 78 self.callable = callable 79 80 async def __call__(self, *args, **kwargs): 81 """This method is invoked when endpoints are called 82 Example: 83 84 api_instance = InferenceApi() 85 api_instance.embed # this is an instance of the class Endpoint 86 api_instance.embed() # this invokes api_instance.embed.__call__() 87 which then invokes the callable functions stored in that endpoint at 88 api_instance.embed.callable or self.callable in this class 89 90 """ 91 return await self.callable(self, *args, **kwargs) 92 93 async def call_with_http_info(self, **kwargs): 94 _host = self.api_client.configuration.host 95 96 EndpointUtils.raise_if_unexpected_param( 97 params_map=self.params_map, settings=self.settings, kwargs=kwargs 98 ) 99 100 EndpointUtils.raise_if_missing_required_params( 101 params_map=self.params_map, settings=self.settings, kwargs=kwargs 102 ) 103 104 EndpointUtils.raise_if_invalid_inputs( 105 config=self.api_client.configuration, 106 params_map=self.params_map, 107 allowed_values=self.allowed_values, 108 validations=self.validations, 109 openapi_types=self.openapi_types, 110 kwargs=kwargs, 111 ) 112 113 params = EndpointUtils.gather_params( 114 attribute_map=self.attribute_map, 115 location_map=self.location_map, 116 openapi_types=self.openapi_types, 117 collection_format_map=self.collection_format_map, 118 kwargs=kwargs, 119 ) 120 121 HeaderUtil.prepare_headers(headers_map=self.headers_map, params=params) 122 123 return await self.api_client.call_api( 124 self.settings["endpoint_path"], 125 self.settings["http_method"], 126 params["path"], 127 params["query"], 128 params["header"], 129 body=params["body"], 130 post_params=params["form"], 131 files=params["file"], 132 response_type=self.settings["response_type"], 133 auth_settings=self.settings["auth"], 134 _check_type=kwargs["_check_return_type"], 135 _return_http_data_only=kwargs["_return_http_data_only"], 136 _preload_content=kwargs["_preload_content"], 137 _request_timeout=kwargs["_request_timeout"], 138 _host=_host, 139 collection_formats=params["collection_format"], 140 ) 141 142 def _process_openapi_kwargs( 143 self, kwargs: ExtraOpenApiKwargsTypedDict 144 ) -> ExtraOpenApiKwargsTypedDict: 145 kwargs["_return_http_data_only"] = kwargs.get("_return_http_data_only", True) 146 kwargs["_preload_content"] = kwargs.get("_preload_content", True) 147 kwargs["_request_timeout"] = kwargs.get("_request_timeout", None) 148 kwargs["_check_input_type"] = kwargs.get("_check_input_type", True) 149 kwargs["_check_return_type"] = kwargs.get("_check_return_type", True) 150 return kwargs
AsyncioEndpoint( settings=None, params_map=None, root_map=None, headers_map=None, api_client=None, callable=None)
8 def __init__( 9 self, 10 settings=None, 11 params_map=None, 12 root_map=None, 13 headers_map=None, 14 api_client=None, 15 callable=None, 16 ) -> None: 17 """Creates an endpoint 18 19 Args: 20 settings (dict): see below key value pairs 21 'response_type' (tuple/None): response type 22 'auth' (list): a list of auth type keys 23 'endpoint_path' (str): the endpoint path 24 'operation_id' (str): endpoint string identifier 25 'http_method' (str): POST/PUT/PATCH/GET etc 26 'servers' (list): list of str servers that this endpoint is at 27 params_map (dict): see below key value pairs 28 'all' (list): list of str endpoint parameter names 29 'required' (list): list of required parameter names 30 'nullable' (list): list of nullable parameter names 31 'enum' (list): list of parameters with enum values 32 'validation' (list): list of parameters with validations 33 root_map 34 'validations' (dict): the dict mapping endpoint parameter tuple 35 paths to their validation dictionaries 36 'allowed_values' (dict): the dict mapping endpoint parameter 37 tuple paths to their allowed_values (enum) dictionaries 38 'openapi_types' (dict): param_name to openapi type 39 'attribute_map' (dict): param_name to camelCase name 40 'location_map' (dict): param_name to 'body', 'file', 'form', 41 'header', 'path', 'query' 42 collection_format_map (dict): param_name to `csv` etc. 43 headers_map (dict): see below key value pairs 44 'accept' (list): list of Accept header strings 45 'content_type' (list): list of Content-Type header strings 46 api_client (AsyncioApiClient) api client instance 47 callable (function): the function which is invoked when the 48 Endpoint is called 49 """ 50 self.settings = settings 51 self.params_map = params_map 52 self.params_map["all"].extend( 53 [ 54 "_preload_content", 55 "_request_timeout", 56 "_return_http_data_only", 57 "_check_input_type", 58 "_check_return_type", 59 ] 60 ) 61 self.params_map["nullable"].extend(["_request_timeout"]) 62 self.validations = root_map["validations"] 63 self.allowed_values = root_map["allowed_values"] 64 self.openapi_types = root_map["openapi_types"] 65 extra_types = { 66 "_preload_content": (bool,), 67 "_request_timeout": (none_type, float, (float,), [float], int, (int,), [int]), 68 "_return_http_data_only": (bool,), 69 "_check_input_type": (bool,), 70 "_check_return_type": (bool,), 71 } 72 self.openapi_types.update(extra_types) 73 self.attribute_map = root_map["attribute_map"] 74 self.location_map = root_map["location_map"] 75 self.collection_format_map = root_map["collection_format_map"] 76 self.headers_map = headers_map 77 self.api_client = api_client 78 self.callable = callable
Creates an endpoint
Arguments:
- settings (dict): see below key value pairs 'response_type' (tuple/None): response type 'auth' (list): a list of auth type keys 'endpoint_path' (str): the endpoint path 'operation_id' (str): endpoint string identifier 'http_method' (str): POST/PUT/PATCH/GET etc 'servers' (list): list of str servers that this endpoint is at
- params_map (dict): see below key value pairs 'all' (list): list of str endpoint parameter names 'required' (list): list of required parameter names 'nullable' (list): list of nullable parameter names 'enum' (list): list of parameters with enum values 'validation' (list): list of parameters with validations
- root_map
'validations' (dict): the dict mapping endpoint parameter tuple
paths to their validation dictionaries
'allowed_values' (dict): the dict mapping endpoint parameter
tuple paths to their allowed_values (enum) dictionaries
'openapi_types' (dict): param_name to openapi type
'attribute_map' (dict): param_name to camelCase name
'location_map' (dict): param_name to 'body', 'file', 'form',
'header', 'path', 'query'
collection_format_map (dict): param_name to
csv
etc. - headers_map (dict): see below key value pairs 'accept' (list): list of Accept header strings 'content_type' (list): list of Content-Type header strings
- api_client (AsyncioApiClient) api client instance
- callable (function): the function which is invoked when the Endpoint is called
async def
call_with_http_info(self, **kwargs):
93 async def call_with_http_info(self, **kwargs): 94 _host = self.api_client.configuration.host 95 96 EndpointUtils.raise_if_unexpected_param( 97 params_map=self.params_map, settings=self.settings, kwargs=kwargs 98 ) 99 100 EndpointUtils.raise_if_missing_required_params( 101 params_map=self.params_map, settings=self.settings, kwargs=kwargs 102 ) 103 104 EndpointUtils.raise_if_invalid_inputs( 105 config=self.api_client.configuration, 106 params_map=self.params_map, 107 allowed_values=self.allowed_values, 108 validations=self.validations, 109 openapi_types=self.openapi_types, 110 kwargs=kwargs, 111 ) 112 113 params = EndpointUtils.gather_params( 114 attribute_map=self.attribute_map, 115 location_map=self.location_map, 116 openapi_types=self.openapi_types, 117 collection_format_map=self.collection_format_map, 118 kwargs=kwargs, 119 ) 120 121 HeaderUtil.prepare_headers(headers_map=self.headers_map, params=params) 122 123 return await self.api_client.call_api( 124 self.settings["endpoint_path"], 125 self.settings["http_method"], 126 params["path"], 127 params["query"], 128 params["header"], 129 body=params["body"], 130 post_params=params["form"], 131 files=params["file"], 132 response_type=self.settings["response_type"], 133 auth_settings=self.settings["auth"], 134 _check_type=kwargs["_check_return_type"], 135 _return_http_data_only=kwargs["_return_http_data_only"], 136 _preload_content=kwargs["_preload_content"], 137 _request_timeout=kwargs["_request_timeout"], 138 _host=_host, 139 collection_formats=params["collection_format"], 140 )