From 277f701be862cc5c362c5f0cf12920dd06f7aa94 Mon Sep 17 00:00:00 2001 From: Jen Hamon Date: Thu, 9 Nov 2023 18:42:01 -0500 Subject: [PATCH 1/4] Regenerate with environment in create_index call --- .../core/client/api/index_operations_api.py | 35 +-- pinecone/core/client/model/collection_meta.py | 38 ++- .../client/model/create_collection_request.py | 4 +- pinecone/core/client/model/create_request.py | 31 +- pinecone/core/client/model/index_list_meta.py | 286 ++++++++++++++++++ pinecone/core/client/model/index_meta.py | 20 +- .../core/client/model/index_meta_database.py | 40 ++- .../core/client/model/index_meta_status.py | 32 +- .../core/client/model/inline_response200.py | 262 ++++++++++++++++ pinecone/core/client/models/__init__.py | 2 + 10 files changed, 690 insertions(+), 60 deletions(-) create mode 100644 pinecone/core/client/model/index_list_meta.py create mode 100644 pinecone/core/client/model/inline_response200.py diff --git a/pinecone/core/client/api/index_operations_api.py b/pinecone/core/client/api/index_operations_api.py index 152af5ad2..0e31c7800 100644 --- a/pinecone/core/client/api/index_operations_api.py +++ b/pinecone/core/client/api/index_operations_api.py @@ -26,6 +26,7 @@ from pinecone.core.client.model.create_collection_request import CreateCollectionRequest from pinecone.core.client.model.create_request import CreateRequest from pinecone.core.client.model.index_meta import IndexMeta +from pinecone.core.client.model.inline_response200 import InlineResponse200 from pinecone.core.client.model.patch_request import PatchRequest @@ -81,7 +82,7 @@ def __configure_index( async_req (bool): execute request asynchronously Returns: - str + IndexMeta If the method is called asynchronously, returns the request thread. """ @@ -110,7 +111,7 @@ def __configure_index( self.configure_index = _Endpoint( settings={ - 'response_type': (str,), + 'response_type': (IndexMeta,), 'auth': [ 'ApiKeyAuth' ], @@ -119,7 +120,7 @@ def __configure_index( 'http_method': 'PATCH', 'servers': [ { - 'url': "https://controller.{environment}.pinecone.io", + 'url': "https://api.pinecone.io", 'description': "No description provided", 'variables': { 'environment': { @@ -168,7 +169,7 @@ def __configure_index( }, headers_map={ 'accept': [ - 'text/plain' + 'application/json' ], 'content_type': [ 'application/json' @@ -251,7 +252,7 @@ def __create_collection( 'http_method': 'POST', 'servers': [ { - 'url': "https://controller.{environment}.pinecone.io", + 'url': "https://api.pinecone.io", 'description': "No description provided", 'variables': { 'environment': { @@ -340,7 +341,7 @@ def __create_index( async_req (bool): execute request asynchronously Returns: - str + IndexMeta If the method is called asynchronously, returns the request thread. """ @@ -367,7 +368,7 @@ def __create_index( self.create_index = _Endpoint( settings={ - 'response_type': (str,), + 'response_type': (IndexMeta,), 'auth': [ 'ApiKeyAuth' ], @@ -376,7 +377,7 @@ def __create_index( 'http_method': 'POST', 'servers': [ { - 'url': "https://controller.{environment}.pinecone.io", + 'url': "https://api.pinecone.io", 'description': "No description provided", 'variables': { 'environment': { @@ -418,7 +419,7 @@ def __create_index( }, headers_map={ 'accept': [ - 'text/plain' + 'application/json' ], 'content_type': [ 'application/json' @@ -505,7 +506,7 @@ def __delete_collection( 'http_method': 'DELETE', 'servers': [ { - 'url': "https://controller.{environment}.pinecone.io", + 'url': "https://api.pinecone.io", 'description': "No description provided", 'variables': { 'environment': { @@ -635,7 +636,7 @@ def __delete_index( 'http_method': 'DELETE', 'servers': [ { - 'url': "https://controller.{environment}.pinecone.io", + 'url': "https://api.pinecone.io", 'description': "No description provided", 'variables': { 'environment': { @@ -765,7 +766,7 @@ def __describe_collection( 'http_method': 'GET', 'servers': [ { - 'url': "https://controller.{environment}.pinecone.io", + 'url': "https://api.pinecone.io", 'description': "No description provided", 'variables': { 'environment': { @@ -895,7 +896,7 @@ def __describe_index( 'http_method': 'GET', 'servers': [ { - 'url': "https://controller.{environment}.pinecone.io", + 'url': "https://api.pinecone.io", 'description': "No description provided", 'variables': { 'environment': { @@ -1020,7 +1021,7 @@ def __list_collections( 'http_method': 'GET', 'servers': [ { - 'url': "https://controller.{environment}.pinecone.io", + 'url': "https://api.pinecone.io", 'description': "No description provided", 'variables': { 'environment': { @@ -1102,7 +1103,7 @@ def __list_indexes( async_req (bool): execute request asynchronously Returns: - [str] + InlineResponse200 If the method is called asynchronously, returns the request thread. """ @@ -1129,7 +1130,7 @@ def __list_indexes( self.list_indexes = _Endpoint( settings={ - 'response_type': ([str],), + 'response_type': (InlineResponse200,), 'auth': [ 'ApiKeyAuth' ], @@ -1138,7 +1139,7 @@ def __list_indexes( 'http_method': 'GET', 'servers': [ { - 'url': "https://controller.{environment}.pinecone.io", + 'url': "https://api.pinecone.io", 'description': "No description provided", 'variables': { 'environment': { diff --git a/pinecone/core/client/model/collection_meta.py b/pinecone/core/client/model/collection_meta.py index cc3bfa5f1..9f33d5ef0 100644 --- a/pinecone/core/client/model/collection_meta.py +++ b/pinecone/core/client/model/collection_meta.py @@ -109,9 +109,16 @@ def discriminator(): @classmethod @convert_js_args_to_python_args - def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + def _from_openapi_data(cls, name, size, status, dimension, vector_count, *args, **kwargs): # noqa: E501 """CollectionMeta - a model defined in OpenAPI + Args: + name (str): + size (int): The size of the collection in bytes. + status (str): The status of the collection. + dimension (int): The dimension of the records stored in the collection + vector_count (int): The number of records stored in the collection + Keyword Args: _check_type (bool): if True, values for parameters in openapi_types will be type checked and a TypeError will be @@ -143,11 +150,6 @@ def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 Animal class but this time we won't travel through its discriminator because we passed in _visited_composed_classes = (Animal,) - name (str): [optional] # noqa: E501 - size (int): The size of the collection in bytes.. [optional] # noqa: E501 - status (str): The status of the collection.. [optional] # noqa: E501 - dimension (int): [optional] # noqa: E501 - vector_count (int): [optional] # noqa: E501 """ _check_type = kwargs.pop('_check_type', True) @@ -175,6 +177,11 @@ def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 self._configuration = _configuration self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.name = name + self.size = size + self.status = status + self.dimension = dimension + self.vector_count = vector_count for var_name, var_value in kwargs.items(): if var_name not in self.attribute_map and \ self._configuration is not None and \ @@ -195,9 +202,16 @@ def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 ]) @convert_js_args_to_python_args - def __init__(self, *args, **kwargs): # noqa: E501 + def __init__(self, name, size, status, dimension, vector_count, *args, **kwargs): # noqa: E501 """CollectionMeta - a model defined in OpenAPI + Args: + name (str): + size (int): The size of the collection in bytes. + status (str): The status of the collection. + dimension (int): The dimension of the records stored in the collection + vector_count (int): The number of records stored in the collection + Keyword Args: _check_type (bool): if True, values for parameters in openapi_types will be type checked and a TypeError will be @@ -229,11 +243,6 @@ def __init__(self, *args, **kwargs): # noqa: E501 Animal class but this time we won't travel through its discriminator because we passed in _visited_composed_classes = (Animal,) - name (str): [optional] # noqa: E501 - size (int): The size of the collection in bytes.. [optional] # noqa: E501 - status (str): The status of the collection.. [optional] # noqa: E501 - dimension (int): [optional] # noqa: E501 - vector_count (int): [optional] # noqa: E501 """ _check_type = kwargs.pop('_check_type', True) @@ -259,6 +268,11 @@ def __init__(self, *args, **kwargs): # noqa: E501 self._configuration = _configuration self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.name = name + self.size = size + self.status = status + self.dimension = dimension + self.vector_count = vector_count for var_name, var_value in kwargs.items(): if var_name not in self.attribute_map and \ self._configuration is not None and \ diff --git a/pinecone/core/client/model/create_collection_request.py b/pinecone/core/client/model/create_collection_request.py index ac5474413..6cf24b7a7 100644 --- a/pinecone/core/client/model/create_collection_request.py +++ b/pinecone/core/client/model/create_collection_request.py @@ -108,7 +108,7 @@ def _from_openapi_data(cls, name, source, *args, **kwargs): # noqa: E501 Args: name (str): The name of the collection to be created. - source (str): The name of the source index to be used as the source for the collection. + source (str): The name of the index to be used as the source for the collection. Keyword Args: _check_type (bool): if True, values for parameters in openapi_types @@ -195,7 +195,7 @@ def __init__(self, name, source, *args, **kwargs): # noqa: E501 Args: name (str): The name of the collection to be created. - source (str): The name of the source index to be used as the source for the collection. + source (str): The name of the index to be used as the source for the collection. Keyword Args: _check_type (bool): if True, values for parameters in openapi_types diff --git a/pinecone/core/client/model/create_request.py b/pinecone/core/client/model/create_request.py index 0dbb9f900..e19d8d9e4 100644 --- a/pinecone/core/client/model/create_request.py +++ b/pinecone/core/client/model/create_request.py @@ -56,6 +56,11 @@ class CreateRequest(ModelNormal): """ allowed_values = { + ('cloud',): { + 'GCP': "gcp", + 'AWS': "aws", + 'AZURE': "azure", + }, } validations = { @@ -84,6 +89,10 @@ def openapi_types(): return { 'name': (str,), # noqa: E501 'dimension': (int,), # noqa: E501 + 'region': (str,), # noqa: E501 + 'cloud': (str,), # noqa: E501 + 'capacity_mode': (str,), # noqa: E501 + 'environment': (str,), # noqa: E501 'index_type': (str,), # noqa: E501 'metric': (str,), # noqa: E501 'pods': (int,), # noqa: E501 @@ -103,6 +112,10 @@ def discriminator(): attribute_map = { 'name': 'name', # noqa: E501 'dimension': 'dimension', # noqa: E501 + 'region': 'region', # noqa: E501 + 'cloud': 'cloud', # noqa: E501 + 'capacity_mode': 'capacity_mode', # noqa: E501 + 'environment': 'environment', # noqa: E501 'index_type': 'index_type', # noqa: E501 'metric': 'metric', # noqa: E501 'pods': 'pods', # noqa: E501 @@ -121,12 +134,15 @@ def discriminator(): @classmethod @convert_js_args_to_python_args - def _from_openapi_data(cls, name, dimension, *args, **kwargs): # noqa: E501 + def _from_openapi_data(cls, name, dimension, region, cloud, capacity_mode, *args, **kwargs): # noqa: E501 """CreateRequest - a model defined in OpenAPI Args: name (str): The name of the index to be created. The maximum length is 45 characters. dimension (int): The dimensions of the vectors to be inserted in the index + region (str): The region where you would like your index to be created + cloud (str): The public cloud where you would like your index hosted + capacity_mode (str): The capacity mode for the index. Keyword Args: _check_type (bool): if True, values for parameters in openapi_types @@ -159,6 +175,7 @@ def _from_openapi_data(cls, name, dimension, *args, **kwargs): # noqa: E501 Animal class but this time we won't travel through its discriminator because we passed in _visited_composed_classes = (Animal,) + environment (str): The environment where you would like your index to be created. [optional] # noqa: E501 index_type (str): The type of vector index. Pinecone supports 'approximated'.. [optional] if omitted the server will use the default value of "approximated" # noqa: E501 metric (str): The distance metric to be used for similarity search. You can use 'euclidean', 'cosine', or 'dotproduct'.. [optional] if omitted the server will use the default value of "cosine" # noqa: E501 pods (int): The number of pods for the index to use,including replicas.. [optional] if omitted the server will use the default value of 1 # noqa: E501 @@ -197,6 +214,9 @@ def _from_openapi_data(cls, name, dimension, *args, **kwargs): # noqa: E501 self.name = name self.dimension = dimension + self.region = region + self.cloud = cloud + self.capacity_mode = capacity_mode for var_name, var_value in kwargs.items(): if var_name not in self.attribute_map and \ self._configuration is not None and \ @@ -217,12 +237,15 @@ def _from_openapi_data(cls, name, dimension, *args, **kwargs): # noqa: E501 ]) @convert_js_args_to_python_args - def __init__(self, name, dimension, *args, **kwargs): # noqa: E501 + def __init__(self, name, dimension, region, cloud, capacity_mode, *args, **kwargs): # noqa: E501 """CreateRequest - a model defined in OpenAPI Args: name (str): The name of the index to be created. The maximum length is 45 characters. dimension (int): The dimensions of the vectors to be inserted in the index + region (str): The region where you would like your index to be created + cloud (str): The public cloud where you would like your index hosted + capacity_mode (str): The capacity mode for the index. Keyword Args: _check_type (bool): if True, values for parameters in openapi_types @@ -255,6 +278,7 @@ def __init__(self, name, dimension, *args, **kwargs): # noqa: E501 Animal class but this time we won't travel through its discriminator because we passed in _visited_composed_classes = (Animal,) + environment (str): The environment where you would like your index to be created. [optional] # noqa: E501 index_type (str): The type of vector index. Pinecone supports 'approximated'.. [optional] if omitted the server will use the default value of "approximated" # noqa: E501 metric (str): The distance metric to be used for similarity search. You can use 'euclidean', 'cosine', or 'dotproduct'.. [optional] if omitted the server will use the default value of "cosine" # noqa: E501 pods (int): The number of pods for the index to use,including replicas.. [optional] if omitted the server will use the default value of 1 # noqa: E501 @@ -291,6 +315,9 @@ def __init__(self, name, dimension, *args, **kwargs): # noqa: E501 self.name = name self.dimension = dimension + self.region = region + self.cloud = cloud + self.capacity_mode = capacity_mode for var_name, var_value in kwargs.items(): if var_name not in self.attribute_map and \ self._configuration is not None and \ diff --git a/pinecone/core/client/model/index_list_meta.py b/pinecone/core/client/model/index_list_meta.py new file mode 100644 index 000000000..7cfbd92d9 --- /dev/null +++ b/pinecone/core/client/model/index_list_meta.py @@ -0,0 +1,286 @@ +""" + Pinecone API + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) # noqa: E501 + + The version of the OpenAPI document: version not set + Contact: support@pinecone.io + Generated by: https://openapi-generator.tech +""" + + +import re # noqa: F401 +import sys # noqa: F401 + +from pinecone.core.client.model_utils import ( # noqa: F401 + ApiTypeError, + ModelComposed, + ModelNormal, + ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, + date, + datetime, + file_type, + none_type, + validate_get_composed_info, +) +from ..model_utils import OpenApiModel +from pinecone.core.client.exceptions import ApiAttributeError + + + +class IndexListMeta(ModelNormal): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: + allowed_values (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + with a capitalized key describing the allowed value and an allowed + value. These dicts store the allowed enum values. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + discriminator_value_class_map (dict): A dict to go from the discriminator + variable value to the discriminator class name. + validations (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + that stores validations for max_length, min_length, max_items, + min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, + inclusive_minimum, and regex. + additional_properties_type (tuple): A tuple of classes accepted + as additional properties values. + """ + + allowed_values = { + } + + validations = { + } + + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 + + _nullable = False + + @cached_property + def openapi_types(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + + Returns + openapi_types (dict): The key is attribute name + and the value is attribute type. + """ + return { + 'name': (str,), # noqa: E501 + 'metric': (str,), # noqa: E501 + 'dimension': (int,), # noqa: E501 + 'capacity_mode': (str,), # noqa: E501 + 'host': (str,), # noqa: E501 + } + + @cached_property + def discriminator(): + return None + + + attribute_map = { + 'name': 'name', # noqa: E501 + 'metric': 'metric', # noqa: E501 + 'dimension': 'dimension', # noqa: E501 + 'capacity_mode': 'capacity_mode', # noqa: E501 + 'host': 'host', # noqa: E501 + } + + read_only_vars = { + } + + _composed_schemas = {} + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, name, metric, dimension, capacity_mode, host, *args, **kwargs): # noqa: E501 + """IndexListMeta - a model defined in OpenAPI + + Args: + name (str): + metric (str): + dimension (int): + capacity_mode (str): + host (str): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.name = name + self.metric = metric + self.dimension = dimension + self.capacity_mode = capacity_mode + self.host = host + for var_name, var_value in kwargs.items(): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: + # discard variable. + continue + setattr(self, var_name, var_value) + return self + + required_properties = set([ + '_data_store', + '_check_type', + '_spec_property_naming', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + ]) + + @convert_js_args_to_python_args + def __init__(self, name, metric, dimension, capacity_mode, host, *args, **kwargs): # noqa: E501 + """IndexListMeta - a model defined in OpenAPI + + Args: + name (str): + metric (str): + dimension (int): + capacity_mode (str): + host (str): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.name = name + self.metric = metric + self.dimension = dimension + self.capacity_mode = capacity_mode + self.host = host + for var_name, var_value in kwargs.items(): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: + # discard variable. + continue + setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError(f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes.") diff --git a/pinecone/core/client/model/index_meta.py b/pinecone/core/client/model/index_meta.py index 5f17947dd..baac4d5c4 100644 --- a/pinecone/core/client/model/index_meta.py +++ b/pinecone/core/client/model/index_meta.py @@ -111,9 +111,13 @@ def discriminator(): @classmethod @convert_js_args_to_python_args - def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + def _from_openapi_data(cls, database, status, *args, **kwargs): # noqa: E501 """IndexMeta - a model defined in OpenAPI + Args: + database (IndexMetaDatabase): + status (IndexMetaStatus): + Keyword Args: _check_type (bool): if True, values for parameters in openapi_types will be type checked and a TypeError will be @@ -145,8 +149,6 @@ def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 Animal class but this time we won't travel through its discriminator because we passed in _visited_composed_classes = (Animal,) - database (IndexMetaDatabase): [optional] # noqa: E501 - status (IndexMetaStatus): [optional] # noqa: E501 """ _check_type = kwargs.pop('_check_type', True) @@ -174,6 +176,8 @@ def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 self._configuration = _configuration self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.database = database + self.status = status for var_name, var_value in kwargs.items(): if var_name not in self.attribute_map and \ self._configuration is not None and \ @@ -194,9 +198,13 @@ def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 ]) @convert_js_args_to_python_args - def __init__(self, *args, **kwargs): # noqa: E501 + def __init__(self, database, status, *args, **kwargs): # noqa: E501 """IndexMeta - a model defined in OpenAPI + Args: + database (IndexMetaDatabase): + status (IndexMetaStatus): + Keyword Args: _check_type (bool): if True, values for parameters in openapi_types will be type checked and a TypeError will be @@ -228,8 +236,6 @@ def __init__(self, *args, **kwargs): # noqa: E501 Animal class but this time we won't travel through its discriminator because we passed in _visited_composed_classes = (Animal,) - database (IndexMetaDatabase): [optional] # noqa: E501 - status (IndexMetaStatus): [optional] # noqa: E501 """ _check_type = kwargs.pop('_check_type', True) @@ -255,6 +261,8 @@ def __init__(self, *args, **kwargs): # noqa: E501 self._configuration = _configuration self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.database = database + self.status = status for var_name, var_value in kwargs.items(): if var_name not in self.attribute_map and \ self._configuration is not None and \ diff --git a/pinecone/core/client/model/index_meta_database.py b/pinecone/core/client/model/index_meta_database.py index d93ddf057..22c9381f7 100644 --- a/pinecone/core/client/model/index_meta_database.py +++ b/pinecone/core/client/model/index_meta_database.py @@ -83,9 +83,10 @@ def openapi_types(): """ return { 'name': (str,), # noqa: E501 - 'dimension': (str,), # noqa: E501 - 'index_type': (str,), # noqa: E501 + 'dimension': (int,), # noqa: E501 + 'capacity_mode': (str,), # noqa: E501 'metric': (str,), # noqa: E501 + 'index_type': (str,), # noqa: E501 'pods': (int,), # noqa: E501 'replicas': (int,), # noqa: E501 'shards': (int,), # noqa: E501 @@ -102,8 +103,9 @@ def discriminator(): attribute_map = { 'name': 'name', # noqa: E501 'dimension': 'dimension', # noqa: E501 - 'index_type': 'index_type', # noqa: E501 + 'capacity_mode': 'capacity_mode', # noqa: E501 'metric': 'metric', # noqa: E501 + 'index_type': 'index_type', # noqa: E501 'pods': 'pods', # noqa: E501 'replicas': 'replicas', # noqa: E501 'shards': 'shards', # noqa: E501 @@ -119,10 +121,16 @@ def discriminator(): @classmethod @convert_js_args_to_python_args - def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + def _from_openapi_data(cls, name, dimension, capacity_mode, *args, **kwargs): # noqa: E501 """IndexMetaDatabase - a model defined in OpenAPI + Args: + name (str): + dimension (int): + capacity_mode (str): + Keyword Args: + metric (str): defaults to "cosine" # noqa: E501 _check_type (bool): if True, values for parameters in openapi_types will be type checked and a TypeError will be raised if the wrong type is input. @@ -153,10 +161,7 @@ def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 Animal class but this time we won't travel through its discriminator because we passed in _visited_composed_classes = (Animal,) - name (str): [optional] # noqa: E501 - dimension (str): [optional] # noqa: E501 index_type (str): [optional] # noqa: E501 - metric (str): [optional] # noqa: E501 pods (int): [optional] # noqa: E501 replicas (int): [optional] # noqa: E501 shards (int): [optional] # noqa: E501 @@ -165,6 +170,7 @@ def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 metadata_config ({str: (bool, date, datetime, dict, float, int, list, str, none_type)}): [optional] # noqa: E501 """ + metric = kwargs.get('metric', "cosine") _check_type = kwargs.pop('_check_type', True) _spec_property_naming = kwargs.pop('_spec_property_naming', False) _path_to_item = kwargs.pop('_path_to_item', ()) @@ -190,6 +196,10 @@ def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 self._configuration = _configuration self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.name = name + self.dimension = dimension + self.capacity_mode = capacity_mode + self.metric = metric for var_name, var_value in kwargs.items(): if var_name not in self.attribute_map and \ self._configuration is not None and \ @@ -210,10 +220,16 @@ def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 ]) @convert_js_args_to_python_args - def __init__(self, *args, **kwargs): # noqa: E501 + def __init__(self, name, dimension, capacity_mode, *args, **kwargs): # noqa: E501 """IndexMetaDatabase - a model defined in OpenAPI + Args: + name (str): + dimension (int): + capacity_mode (str): + Keyword Args: + metric (str): defaults to "cosine" # noqa: E501 _check_type (bool): if True, values for parameters in openapi_types will be type checked and a TypeError will be raised if the wrong type is input. @@ -244,10 +260,7 @@ def __init__(self, *args, **kwargs): # noqa: E501 Animal class but this time we won't travel through its discriminator because we passed in _visited_composed_classes = (Animal,) - name (str): [optional] # noqa: E501 - dimension (str): [optional] # noqa: E501 index_type (str): [optional] # noqa: E501 - metric (str): [optional] # noqa: E501 pods (int): [optional] # noqa: E501 replicas (int): [optional] # noqa: E501 shards (int): [optional] # noqa: E501 @@ -256,6 +269,7 @@ def __init__(self, *args, **kwargs): # noqa: E501 metadata_config ({str: (bool, date, datetime, dict, float, int, list, str, none_type)}): [optional] # noqa: E501 """ + metric = kwargs.get('metric', "cosine") _check_type = kwargs.pop('_check_type', True) _spec_property_naming = kwargs.pop('_spec_property_naming', False) _path_to_item = kwargs.pop('_path_to_item', ()) @@ -279,6 +293,10 @@ def __init__(self, *args, **kwargs): # noqa: E501 self._configuration = _configuration self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.name = name + self.dimension = dimension + self.capacity_mode = capacity_mode + self.metric = metric for var_name, var_value in kwargs.items(): if var_name not in self.attribute_map and \ self._configuration is not None and \ diff --git a/pinecone/core/client/model/index_meta_status.py b/pinecone/core/client/model/index_meta_status.py index 62abdbd66..43c28a839 100644 --- a/pinecone/core/client/model/index_meta_status.py +++ b/pinecone/core/client/model/index_meta_status.py @@ -117,9 +117,15 @@ def discriminator(): @classmethod @convert_js_args_to_python_args - def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + def _from_openapi_data(cls, ready, state, host, port, *args, **kwargs): # noqa: E501 """IndexMetaStatus - a model defined in OpenAPI + Args: + ready (bool): + state (str): + host (str): + port (int): + Keyword Args: _check_type (bool): if True, values for parameters in openapi_types will be type checked and a TypeError will be @@ -151,10 +157,6 @@ def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 Animal class but this time we won't travel through its discriminator because we passed in _visited_composed_classes = (Animal,) - ready (bool): [optional] # noqa: E501 - state (str): [optional] # noqa: E501 - host (str): [optional] # noqa: E501 - port (int): [optional] # noqa: E501 """ _check_type = kwargs.pop('_check_type', True) @@ -182,6 +184,10 @@ def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 self._configuration = _configuration self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.ready = ready + self.state = state + self.host = host + self.port = port for var_name, var_value in kwargs.items(): if var_name not in self.attribute_map and \ self._configuration is not None and \ @@ -202,9 +208,15 @@ def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 ]) @convert_js_args_to_python_args - def __init__(self, *args, **kwargs): # noqa: E501 + def __init__(self, ready, state, host, port, *args, **kwargs): # noqa: E501 """IndexMetaStatus - a model defined in OpenAPI + Args: + ready (bool): + state (str): + host (str): + port (int): + Keyword Args: _check_type (bool): if True, values for parameters in openapi_types will be type checked and a TypeError will be @@ -236,10 +248,6 @@ def __init__(self, *args, **kwargs): # noqa: E501 Animal class but this time we won't travel through its discriminator because we passed in _visited_composed_classes = (Animal,) - ready (bool): [optional] # noqa: E501 - state (str): [optional] # noqa: E501 - host (str): [optional] # noqa: E501 - port (int): [optional] # noqa: E501 """ _check_type = kwargs.pop('_check_type', True) @@ -265,6 +273,10 @@ def __init__(self, *args, **kwargs): # noqa: E501 self._configuration = _configuration self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + self.ready = ready + self.state = state + self.host = host + self.port = port for var_name, var_value in kwargs.items(): if var_name not in self.attribute_map and \ self._configuration is not None and \ diff --git a/pinecone/core/client/model/inline_response200.py b/pinecone/core/client/model/inline_response200.py new file mode 100644 index 000000000..c7e991067 --- /dev/null +++ b/pinecone/core/client/model/inline_response200.py @@ -0,0 +1,262 @@ +""" + Pinecone API + + No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) # noqa: E501 + + The version of the OpenAPI document: version not set + Contact: support@pinecone.io + Generated by: https://openapi-generator.tech +""" + + +import re # noqa: F401 +import sys # noqa: F401 + +from pinecone.core.client.model_utils import ( # noqa: F401 + ApiTypeError, + ModelComposed, + ModelNormal, + ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, + date, + datetime, + file_type, + none_type, + validate_get_composed_info, +) +from ..model_utils import OpenApiModel +from pinecone.core.client.exceptions import ApiAttributeError + + +def lazy_import(): + from pinecone.core.client.model.index_list_meta import IndexListMeta + globals()['IndexListMeta'] = IndexListMeta + + +class InlineResponse200(ModelNormal): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: + allowed_values (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + with a capitalized key describing the allowed value and an allowed + value. These dicts store the allowed enum values. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + discriminator_value_class_map (dict): A dict to go from the discriminator + variable value to the discriminator class name. + validations (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + that stores validations for max_length, min_length, max_items, + min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, + inclusive_minimum, and regex. + additional_properties_type (tuple): A tuple of classes accepted + as additional properties values. + """ + + allowed_values = { + } + + validations = { + } + + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + lazy_import() + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 + + _nullable = False + + @cached_property + def openapi_types(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + + Returns + openapi_types (dict): The key is attribute name + and the value is attribute type. + """ + lazy_import() + return { + 'databases': ([IndexListMeta],), # noqa: E501 + } + + @cached_property + def discriminator(): + return None + + + attribute_map = { + 'databases': 'databases', # noqa: E501 + } + + read_only_vars = { + } + + _composed_schemas = {} + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """InlineResponse200 - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + databases ([IndexListMeta]): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: + # discard variable. + continue + setattr(self, var_name, var_value) + return self + + required_properties = set([ + '_data_store', + '_check_type', + '_spec_property_naming', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + ]) + + @convert_js_args_to_python_args + def __init__(self, *args, **kwargs): # noqa: E501 + """InlineResponse200 - a model defined in OpenAPI + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + databases ([IndexListMeta]): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + for var_name, var_value in kwargs.items(): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: + # discard variable. + continue + setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError(f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes.") diff --git a/pinecone/core/client/models/__init__.py b/pinecone/core/client/models/__init__.py index 5c2079103..b514eb36f 100644 --- a/pinecone/core/client/models/__init__.py +++ b/pinecone/core/client/models/__init__.py @@ -18,9 +18,11 @@ from pinecone.core.client.model.describe_index_stats_response import DescribeIndexStatsResponse from pinecone.core.client.model.fetch_response import FetchResponse from pinecone.core.client.model.hnsw_config import HnswConfig +from pinecone.core.client.model.index_list_meta import IndexListMeta from pinecone.core.client.model.index_meta import IndexMeta from pinecone.core.client.model.index_meta_database import IndexMetaDatabase from pinecone.core.client.model.index_meta_status import IndexMetaStatus +from pinecone.core.client.model.inline_response200 import InlineResponse200 from pinecone.core.client.model.namespace_summary import NamespaceSummary from pinecone.core.client.model.patch_request import PatchRequest from pinecone.core.client.model.protobuf_any import ProtobufAny From 17fa74b197e7fedbd35aeffcdd510df9eaf025de Mon Sep 17 00:00:00 2001 From: Jen Hamon Date: Thu, 9 Nov 2023 21:58:51 -0500 Subject: [PATCH 2/4] Wire up environment field --- pinecone/control/pinecone.py | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/pinecone/control/pinecone.py b/pinecone/control/pinecone.py index 7f95bff3d..168f48e57 100644 --- a/pinecone/control/pinecone.py +++ b/pinecone/control/pinecone.py @@ -49,6 +49,7 @@ def create_index( cloud: str, region: str, capacity_mode: str, + environment: Optional[str] = None, timeout: Optional[int] = None, index_type: str = "approximated", metric: str = "cosine", @@ -100,7 +101,7 @@ def create_index( """ api_instance = self.index_api - api_instance.create_index( + if environment is None: create_request=CreateRequest( name=name, dimension=dimension, @@ -115,9 +116,28 @@ def create_index( pod_type=pod_type, index_config=index_config or {}, metadata_config=metadata_config, + source_collection=source_collection + ) + else: + create_request=CreateRequest( + name=name, + dimension=dimension, + cloud=cloud, + region=region, + capacity_mode=capacity_mode, + environment=environment, + index_type=index_type, + metric=metric, + replicas=replicas, + shards=shards, + pods=pods, + pod_type=pod_type, + index_config=index_config or {}, + metadata_config=metadata_config, source_collection=source_collection, ) - ) + + api_instance.create_index(create_request=create_request) def is_ready(): status = self._get_status(name) From 4d092074a6831eb993cb399e42cc4cce1ea54d3e Mon Sep 17 00:00:00 2001 From: Jen Hamon Date: Fri, 10 Nov 2023 08:58:54 -0500 Subject: [PATCH 3/4] Update docstrings for create_index --- pinecone/control/pinecone.py | 52 ++++++++++-------------------------- 1 file changed, 14 insertions(+), 38 deletions(-) diff --git a/pinecone/control/pinecone.py b/pinecone/control/pinecone.py index 168f48e57..f470972b6 100644 --- a/pinecone/control/pinecone.py +++ b/pinecone/control/pinecone.py @@ -66,9 +66,15 @@ def create_index( :param name: the name of the index. :type name: str :param dimension: the dimension of vectors that would be inserted in the index + :type dimension: int :param cloud: The cloud where you would like your index hosted. One of `{"aws", "gcp"}`. + :type cloud: str :param region: The region where you would like your index hosted. + :type region: str :param capacity_mode: The capacity mode for the index. One of `{"pod"}`. + :type capacity_mode: str + :param environment: The environment where you would like your index hosted, e.g. 'us-east1-gcp'. Find this value in the Pinecone web console along with your API keys. + :type environment: str, optional :param index_type: type of index, one of `{"approximated", "exact"}`, defaults to "approximated". The "approximated" index uses fast approximate search algorithms developed by Pinecone. The "exact" index uses accurate exact search algorithms. @@ -99,45 +105,15 @@ def create_index( :param timeout: Timeout for wait until index gets ready. If None, wait indefinitely; if >=0, time out after this many seconds; if -1, return immediately and do not wait. Default: None """ - api_instance = self.index_api - + create_args = locals() + del create_args["self"] if environment is None: - create_request=CreateRequest( - name=name, - dimension=dimension, - cloud=cloud, - region=region, - capacity_mode=capacity_mode, - index_type=index_type, - metric=metric, - replicas=replicas, - shards=shards, - pods=pods, - pod_type=pod_type, - index_config=index_config or {}, - metadata_config=metadata_config, - source_collection=source_collection - ) - else: - create_request=CreateRequest( - name=name, - dimension=dimension, - cloud=cloud, - region=region, - capacity_mode=capacity_mode, - environment=environment, - index_type=index_type, - metric=metric, - replicas=replicas, - shards=shards, - pods=pods, - pod_type=pod_type, - index_config=index_config or {}, - metadata_config=metadata_config, - source_collection=source_collection, - ) - - api_instance.create_index(create_request=create_request) + del create_args["environment"] + if index_config is None: + create_args["index_config"] = {} + + api_instance = self.index_api + api_instance.create_index(create_request=CreateRequest(**create_args)) def is_ready(): status = self._get_status(name) From e2a05bbd583864bb2e84efc7b55e4ce8c94a0d1d Mon Sep 17 00:00:00 2001 From: Jen Hamon Date: Fri, 10 Nov 2023 09:01:20 -0500 Subject: [PATCH 4/4] Simplify --- pinecone/control/pinecone.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pinecone/control/pinecone.py b/pinecone/control/pinecone.py index f470972b6..7155b08d4 100644 --- a/pinecone/control/pinecone.py +++ b/pinecone/control/pinecone.py @@ -57,7 +57,7 @@ def create_index( shards: int = 1, pods: int = 1, pod_type: str = "p1", - index_config: Optional[dict] = None, + index_config: Optional[dict] = {}, metadata_config: Optional[dict] = None, source_collection: str = "", ): @@ -109,8 +109,6 @@ def create_index( del create_args["self"] if environment is None: del create_args["environment"] - if index_config is None: - create_args["index_config"] = {} api_instance = self.index_api api_instance.create_index(create_request=CreateRequest(**create_args))