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