From efd4e0e99125d5dd5d8ac5f82560e308265b7e33 Mon Sep 17 00:00:00 2001 From: Jen Hamon Date: Thu, 7 Mar 2024 03:28:32 -0500 Subject: [PATCH 1/6] Add template files and codegen scripts --- .gitignore | 4 + Makefile | 68 +- codegen/grpc.sh | 8 + .../openapi-generator-args.python.json | 4 + .../openapi/templates5.2.0/README.mustache | 55 + .../templates5.2.0/README_common.mustache | 111 ++ .../README_onlypackage.mustache | 42 + .../openapi/templates5.2.0/__init__.mustache | 0 .../templates5.2.0/__init__api.mustache | 9 + .../templates5.2.0/__init__apis.mustache | 23 + .../templates5.2.0/__init__model.mustache | 5 + .../templates5.2.0/__init__models.mustache | 16 + .../templates5.2.0/__init__package.mustache | 26 + codegen/openapi/templates5.2.0/api.mustache | 306 +++ .../templates5.2.0/api_client.mustache | 870 +++++++++ .../openapi/templates5.2.0/api_doc.mustache | 77 + .../templates5.2.0/api_doc_example.mustache | 76 + .../openapi/templates5.2.0/api_test.mustache | 32 + .../templates5.2.0/asyncio/rest.mustache | 236 +++ .../templates5.2.0/configuration.mustache | 626 ++++++ .../templates5.2.0/exceptions.mustache | 151 ++ .../templates5.2.0/git_push.sh.mustache | 58 + .../openapi/templates5.2.0/gitignore.mustache | 66 + .../openapi/templates5.2.0/gitlab-ci.mustache | 29 + codegen/openapi/templates5.2.0/model.mustache | 58 + .../openapi/templates5.2.0/model_doc.mustache | 37 + .../model_templates/classvars.mustache | 138 ++ .../docstring_allowed.mustache | 4 + .../docstring_init_required_kwargs.mustache | 30 + .../docstring_openapi_validations.mustache | 7 + .../model_templates/invalid_pos_args.mustache | 9 + ...method_from_openapi_data_composed.mustache | 66 + .../method_from_openapi_data_normal.mustache | 17 + .../method_from_openapi_data_shared.mustache | 49 + .../method_from_openapi_data_simple.mustache | 62 + .../method_init_composed.mustache | 80 + .../method_init_normal.mustache | 30 + .../method_init_shared.mustache | 52 + .../method_init_simple.mustache | 66 + .../method_set_attribute.mustache | 51 + .../methods_setattr_getattr_composed.mustache | 103 + .../methods_setattr_getattr_normal.mustache | 32 + .../model_templates/methods_shared.mustache | 15 + .../methods_todict_tostr_eq_shared.mustache | 24 + .../methods_tostr_eq_simple.mustache | 16 + .../model_templates/model_composed.mustache | 74 + .../model_templates/model_normal.mustache | 44 + .../model_templates/model_simple.mustache | 22 + .../model_templates/validations.mustache | 34 + .../templates5.2.0/model_test.mustache | 34 + .../templates5.2.0/model_utils.mustache | 1693 +++++++++++++++++ .../templates5.2.0/partial_header.mustache | 17 + .../python_doc_auth_partial.mustache | 109 ++ .../templates5.2.0/requirements.mustache | 3 + codegen/openapi/templates5.2.0/rest.mustache | 319 ++++ codegen/openapi/templates5.2.0/setup.mustache | 51 + .../openapi/templates5.2.0/setup_cfg.mustache | 13 + .../openapi/templates5.2.0/signing.mustache | 408 ++++ .../templates5.2.0/test-requirements.mustache | 13 + .../templates5.2.0/tornado/rest.mustache | 222 +++ codegen/openapi/templates5.2.0/tox.mustache | 9 + .../openapi/templates5.2.0/travis.mustache | 18 + 62 files changed, 6884 insertions(+), 43 deletions(-) create mode 100755 codegen/grpc.sh create mode 100644 codegen/openapi/openapi-generator-args.python.json create mode 100644 codegen/openapi/templates5.2.0/README.mustache create mode 100644 codegen/openapi/templates5.2.0/README_common.mustache create mode 100644 codegen/openapi/templates5.2.0/README_onlypackage.mustache create mode 100644 codegen/openapi/templates5.2.0/__init__.mustache create mode 100644 codegen/openapi/templates5.2.0/__init__api.mustache create mode 100644 codegen/openapi/templates5.2.0/__init__apis.mustache create mode 100644 codegen/openapi/templates5.2.0/__init__model.mustache create mode 100644 codegen/openapi/templates5.2.0/__init__models.mustache create mode 100644 codegen/openapi/templates5.2.0/__init__package.mustache create mode 100644 codegen/openapi/templates5.2.0/api.mustache create mode 100644 codegen/openapi/templates5.2.0/api_client.mustache create mode 100644 codegen/openapi/templates5.2.0/api_doc.mustache create mode 100644 codegen/openapi/templates5.2.0/api_doc_example.mustache create mode 100644 codegen/openapi/templates5.2.0/api_test.mustache create mode 100644 codegen/openapi/templates5.2.0/asyncio/rest.mustache create mode 100644 codegen/openapi/templates5.2.0/configuration.mustache create mode 100644 codegen/openapi/templates5.2.0/exceptions.mustache create mode 100644 codegen/openapi/templates5.2.0/git_push.sh.mustache create mode 100644 codegen/openapi/templates5.2.0/gitignore.mustache create mode 100644 codegen/openapi/templates5.2.0/gitlab-ci.mustache create mode 100644 codegen/openapi/templates5.2.0/model.mustache create mode 100644 codegen/openapi/templates5.2.0/model_doc.mustache create mode 100644 codegen/openapi/templates5.2.0/model_templates/classvars.mustache create mode 100644 codegen/openapi/templates5.2.0/model_templates/docstring_allowed.mustache create mode 100644 codegen/openapi/templates5.2.0/model_templates/docstring_init_required_kwargs.mustache create mode 100644 codegen/openapi/templates5.2.0/model_templates/docstring_openapi_validations.mustache create mode 100644 codegen/openapi/templates5.2.0/model_templates/invalid_pos_args.mustache create mode 100644 codegen/openapi/templates5.2.0/model_templates/method_from_openapi_data_composed.mustache create mode 100644 codegen/openapi/templates5.2.0/model_templates/method_from_openapi_data_normal.mustache create mode 100644 codegen/openapi/templates5.2.0/model_templates/method_from_openapi_data_shared.mustache create mode 100644 codegen/openapi/templates5.2.0/model_templates/method_from_openapi_data_simple.mustache create mode 100644 codegen/openapi/templates5.2.0/model_templates/method_init_composed.mustache create mode 100644 codegen/openapi/templates5.2.0/model_templates/method_init_normal.mustache create mode 100644 codegen/openapi/templates5.2.0/model_templates/method_init_shared.mustache create mode 100644 codegen/openapi/templates5.2.0/model_templates/method_init_simple.mustache create mode 100644 codegen/openapi/templates5.2.0/model_templates/method_set_attribute.mustache create mode 100644 codegen/openapi/templates5.2.0/model_templates/methods_setattr_getattr_composed.mustache create mode 100644 codegen/openapi/templates5.2.0/model_templates/methods_setattr_getattr_normal.mustache create mode 100644 codegen/openapi/templates5.2.0/model_templates/methods_shared.mustache create mode 100644 codegen/openapi/templates5.2.0/model_templates/methods_todict_tostr_eq_shared.mustache create mode 100644 codegen/openapi/templates5.2.0/model_templates/methods_tostr_eq_simple.mustache create mode 100644 codegen/openapi/templates5.2.0/model_templates/model_composed.mustache create mode 100644 codegen/openapi/templates5.2.0/model_templates/model_normal.mustache create mode 100644 codegen/openapi/templates5.2.0/model_templates/model_simple.mustache create mode 100644 codegen/openapi/templates5.2.0/model_templates/validations.mustache create mode 100644 codegen/openapi/templates5.2.0/model_test.mustache create mode 100644 codegen/openapi/templates5.2.0/model_utils.mustache create mode 100644 codegen/openapi/templates5.2.0/partial_header.mustache create mode 100644 codegen/openapi/templates5.2.0/python_doc_auth_partial.mustache create mode 100644 codegen/openapi/templates5.2.0/requirements.mustache create mode 100644 codegen/openapi/templates5.2.0/rest.mustache create mode 100644 codegen/openapi/templates5.2.0/setup.mustache create mode 100644 codegen/openapi/templates5.2.0/setup_cfg.mustache create mode 100644 codegen/openapi/templates5.2.0/signing.mustache create mode 100644 codegen/openapi/templates5.2.0/test-requirements.mustache create mode 100644 codegen/openapi/templates5.2.0/tornado/rest.mustache create mode 100644 codegen/openapi/templates5.2.0/tox.mustache create mode 100644 codegen/openapi/templates5.2.0/travis.mustache diff --git a/.gitignore b/.gitignore index 3f6050533..7d0171cf3 100644 --- a/.gitignore +++ b/.gitignore @@ -154,3 +154,7 @@ dmypy.json # Datasets *.hdf5 *~ + +# Code generation files +gen/ +downloads/ \ No newline at end of file diff --git a/Makefile b/Makefile index 45e13cefc..4218f933d 100644 --- a/Makefile +++ b/Makefile @@ -1,48 +1,30 @@ -.PHONY: image develop tests tag-and-push docs version package upload upload-spruce license +SHELL = /bin/bash mkfile_path := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) -PYPI_USERNAME ?= __token__ +gcloud-auth: + gcloud auth login + gcloud config set project development-pinecone -image: - MODULE=pinecone ../scripts/build.sh ./ +clean: + rm -rf downloads + rm -rf gen -develop: - poetry install -E grpc - -test-unit: - @echo "Running tests..." - poetry run pytest --cov=pinecone --timeout=120 tests/unit - -test-grpc-unit: - @echo "Running tests..." - poetry run pytest --cov=pinecone --timeout=120 tests/unit_grpc - -make type-check: - poetry run mypy pinecone --exclude pinecone/core - -version: - poetry version - -package: - poetry build - -upload: - poetry publish --verbose --username ${PYPI_USERNAME} --password ${PYPI_PASSWORD} - -upload-spruce: - # Configure Poetry for publishing to testpypi - poetry config repositories.test-pypi https://test.pypi.org/legacy/ - poetry publish --verbose -r test-pypi --username ${PYPI_USERNAME} --password ${PYPI_PASSWORD} +regenerate: clean + mkdir downloads + gcloud storage cp gs://api-codegen/_latest downloads --recursive -license: - # Add license header using https://github.com/google/addlicense. - # If the license header already exists in a file, re-running this command has no effect. - pushd ${mkfile_path}/pinecone && \ - docker run --rm -it -v ${mkfile_path}/pinecone:/src ghcr.io/google/addlicense:latest -f ./license_header.txt *.py */*.py */*/*.py */*/*/*.py */*/*/*/*.py */*/*/*/*/*.py */*/*/*/*/*/*.py; \ - popd - -set-production: - echo "production" > pinecone/__environment__ - -set-development: - echo "" > pinecone/__environment__ + # Generate new openapi rest client + rm -rf pinecone/core + mkdir -p pinecone/core + docker run --rm -v ${mkfile_path}:/workspace openapitools/openapi-generator-cli:v5.2.0 generate \ + --input-spec /workspace/downloads/_latest/openapi/pinecone_api.json \ + --config /workspace/codegen/openapi/openapi-generator-args.python.json \ + --generator-name python \ + --template-dir /workspace/codegen/openapi/templates5.2.0 \ + --output /workspace/gen/python + cp -r ${mkfile_path}gen/python/pinecone/core/* ${mkfile_path}pinecone/core/ + + # Update grpc client + mkdir -p pinecone/core/grpc/protos + cp -r ${mkfile_path}downloads/_latest/python/pinecone/data/v1/* ${mkfile_path}pinecone/core/grpc/protos + ${mkfile_path}codegen/grpc.sh \ No newline at end of file diff --git a/codegen/grpc.sh b/codegen/grpc.sh new file mode 100755 index 000000000..4feabe268 --- /dev/null +++ b/codegen/grpc.sh @@ -0,0 +1,8 @@ +module="vector_service" +dest="pinecone/core/grpc/protos" +module_prefix="pinecone.core.grpc.protos" + +head -n 4 "${dest}/${module}_pb2_grpc.py" > "${dest}/tmp.py" +echo "import ${module_prefix}.${module}_pb2 as $(echo "${module}_pb2" | sed 's/_/__/g')" >> "${dest}/tmp.py" +tail -n +7 "${dest}/${module}_pb2_grpc.py" >> "${dest}/tmp.py" +mv "${dest}/tmp.py" "${dest}/${module}_pb2_grpc.py" \ No newline at end of file diff --git a/codegen/openapi/openapi-generator-args.python.json b/codegen/openapi/openapi-generator-args.python.json new file mode 100644 index 000000000..989497e69 --- /dev/null +++ b/codegen/openapi/openapi-generator-args.python.json @@ -0,0 +1,4 @@ +{ + "packageName": "pinecone.core.client", + "pythonAttrNoneIfUnset": true +} \ No newline at end of file diff --git a/codegen/openapi/templates5.2.0/README.mustache b/codegen/openapi/templates5.2.0/README.mustache new file mode 100644 index 000000000..65a06eaae --- /dev/null +++ b/codegen/openapi/templates5.2.0/README.mustache @@ -0,0 +1,55 @@ +# {{{projectName}}} +{{#appDescriptionWithNewLines}} +{{{appDescriptionWithNewLines}}} +{{/appDescriptionWithNewLines}} + +This Python package is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project: + +- API version: {{appVersion}} +- Package version: {{packageVersion}} +{{^hideGenerationTimestamp}} +- Build date: {{generatedDate}} +{{/hideGenerationTimestamp}} +- Build package: {{generatorClass}} +{{#infoUrl}} +For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}}) +{{/infoUrl}} + +## Requirements. + +Python >= 3.6 + +## Installation & Usage +### pip install + +If the python package is hosted on a repository, you can install directly using: + +```sh +pip install git+https://{{gitHost}}/{{{gitUserId}}}/{{{gitRepoId}}}.git +``` +(you may need to run `pip` with root permission: `sudo pip install git+https://{{gitHost}}/{{{gitUserId}}}/{{{gitRepoId}}}.git`) + +Then import the package: +```python +import {{{packageName}}} +``` + +### Setuptools + +Install via [Setuptools](http://pypi.python.org/pypi/setuptools). + +```sh +python setup.py install --user +``` +(or `sudo python setup.py install` to install the package for all users) + +Then import the package: +```python +import {{{packageName}}} +``` + +## Getting Started + +Please follow the [installation procedure](#installation--usage) and then run the following: + +{{> README_common }} diff --git a/codegen/openapi/templates5.2.0/README_common.mustache b/codegen/openapi/templates5.2.0/README_common.mustache new file mode 100644 index 000000000..fec956614 --- /dev/null +++ b/codegen/openapi/templates5.2.0/README_common.mustache @@ -0,0 +1,111 @@ +```python +{{#apiInfo}}{{#apis}}{{#-last}}{{#hasHttpSignatureMethods}}import datetime{{/hasHttpSignatureMethods}}{{/-last}}{{/apis}}{{/apiInfo}} +import time +import {{{packageName}}} +from pprint import pprint +{{#apiInfo}} +{{#apis}} +{{#-first}} +from {{apiPackage}} import {{classVarName}} +{{#imports}} +{{{import}}} +{{/imports}} +{{#operations}} +{{#operation}} +{{#-first}} +{{> python_doc_auth_partial}} + +# Enter a context with an instance of the API client +with {{{packageName}}}.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = {{classVarName}}.{{{classname}}}(api_client) + {{#allParams}}{{paramName}} = {{{example}}} # {{{dataType}}} | {{{description}}}{{^required}} (optional){{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}} + {{/allParams}} + + try: + {{#summary}} # {{{.}}} + {{/summary}} {{#returnType}}api_response = {{/returnType}}api_instance.{{{operationId}}}({{#allParams}}{{#required}}{{paramName}}{{/required}}{{^required}}{{paramName}}={{paramName}}{{/required}}{{^-last}}, {{/-last}}{{/allParams}}){{#returnType}} + pprint(api_response){{/returnType}} + except {{{packageName}}}.PineconeApiException as e: + print("Exception when calling {{classname}}->{{operationId}}: %s\n" % e) +{{/-first}} +{{/operation}} +{{/operations}} +{{/-first}} +{{/apis}} +{{/apiInfo}} +``` + +## Documentation for API Endpoints + +All URIs are relative to *{{basePath}}* + +Class | Method | HTTP request | Description +------------ | ------------- | ------------- | ------------- +{{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}*{{classname}}* | [**{{operationId}}**]({{apiDocPath}}{{classname}}.md#{{operationIdLowerCase}}) | **{{httpMethod}}** {{path}} | {{#summary}}{{summary}}{{/summary}} +{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}} + +## Documentation For Models + +{{#models}}{{#model}} - [{{{classname}}}]({{modelDocPath}}{{{classname}}}.md) +{{/model}}{{/models}} + +## Documentation For Authorization + +{{^authMethods}} + All endpoints do not require authorization. +{{/authMethods}} +{{#authMethods}} +{{#last}} Authentication schemes defined for the API:{{/last}} +## {{{name}}} + +{{#isApiKey}} +- **Type**: API key +- **API key parameter name**: {{{keyParamName}}} +- **Location**: {{#isKeyInQuery}}URL query string{{/isKeyInQuery}}{{#isKeyInHeader}}HTTP header{{/isKeyInHeader}} +{{/isApiKey}} +{{#isBasic}} +{{#isBasicBasic}} +- **Type**: HTTP basic authentication +{{/isBasicBasic}} +{{#isBasicBearer}} +- **Type**: Bearer authentication{{#bearerFormat}} ({{{.}}}){{/bearerFormat}} +{{/isBasicBearer}} +{{#isHttpSignature}} +- **Type**: HTTP signature authentication +{{/isHttpSignature}} +{{/isBasic}} +{{#isOAuth}} +- **Type**: OAuth +- **Flow**: {{{flow}}} +- **Authorization URL**: {{{authorizationUrl}}} +- **Scopes**: {{^scopes}}N/A{{/scopes}} +{{#scopes}} - **{{{scope}}}**: {{{description}}} +{{/scopes}} +{{/isOAuth}} + +{{/authMethods}} + +## Author + +{{#apiInfo}}{{#apis}}{{#-last}}{{infoEmail}} +{{/-last}}{{/apis}}{{/apiInfo}} + +## Notes for Large OpenAPI documents +If the OpenAPI document is large, imports in {{{packageName}}}.apis and {{{packageName}}}.models may fail with a +RecursionError indicating the maximum recursion limit has been exceeded. In that case, there are a couple of solutions: + +Solution 1: +Use specific imports for apis and models like: +- `from {{{packageName}}}.api.default_api import DefaultApi` +- `from {{{packageName}}}.model.pet import Pet` + +Solution 2: +Before importing the package, adjust the maximum recursion limit as shown below: +``` +import sys +sys.setrecursionlimit(1500) +import {{{packageName}}} +from {{{packageName}}}.apis import * +from {{{packageName}}}.models import * +``` diff --git a/codegen/openapi/templates5.2.0/README_onlypackage.mustache b/codegen/openapi/templates5.2.0/README_onlypackage.mustache new file mode 100644 index 000000000..7202059fb --- /dev/null +++ b/codegen/openapi/templates5.2.0/README_onlypackage.mustache @@ -0,0 +1,42 @@ +# {{{projectName}}} +{{#appDescription}} +{{{appDescription}}} +{{/appDescription}} + +The `{{packageName}}` package is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project: + +- API version: {{appVersion}} +- Package version: {{packageVersion}} +{{^hideGenerationTimestamp}} +- Build date: {{generatedDate}} +{{/hideGenerationTimestamp}} +- Build package: {{generatorClass}} +{{#infoUrl}} +For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}}) +{{/infoUrl}} + +## Requirements. + +Python >= 3.6 + +## Installation & Usage + +This python library package is generated without supporting files like setup.py or requirements files + +To be able to use it, you will need these dependencies in your own package that uses this library: + +* urllib3 >= 1.25.3 +* python-dateutil +{{#asyncio}} +* aiohttp +{{/asyncio}} +{{#tornado}} +* tornado>=4.2,<5 +{{/tornado}} + +## Getting Started + +In your own code, to use this library to connect and interact with {{{projectName}}}, +you can run the following: + +{{> README_common }} diff --git a/codegen/openapi/templates5.2.0/__init__.mustache b/codegen/openapi/templates5.2.0/__init__.mustache new file mode 100644 index 000000000..e69de29bb diff --git a/codegen/openapi/templates5.2.0/__init__api.mustache b/codegen/openapi/templates5.2.0/__init__api.mustache new file mode 100644 index 000000000..8a9e6b91b --- /dev/null +++ b/codegen/openapi/templates5.2.0/__init__api.mustache @@ -0,0 +1,9 @@ +{{#apiInfo}} +{{#apis}} +{{#-first}} +# do not import all apis into this module because that uses a lot of memory and stack frames +# if you need the ability to import all apis from one package, import them with +# from {{packageName}}.apis import {{classname}} +{{/-first}} +{{/apis}} +{{/apiInfo}} diff --git a/codegen/openapi/templates5.2.0/__init__apis.mustache b/codegen/openapi/templates5.2.0/__init__apis.mustache new file mode 100644 index 000000000..b4ec8a9a4 --- /dev/null +++ b/codegen/openapi/templates5.2.0/__init__apis.mustache @@ -0,0 +1,23 @@ +{{#apiInfo}} +{{#apis}} +{{#-first}} + +# flake8: noqa + +# Import all APIs into this package. +# If you have many APIs here with many many models used in each API this may +# raise a `RecursionError`. +# In order to avoid this, import only the API that you directly need like: +# +# from {{packagename}}.api.{{classVarName}} import {{classname}} +# +# or import this package, but before doing it, use: +# +# import sys +# sys.setrecursionlimit(n) + +# Import APIs into API package: +{{/-first}} +from {{apiPackage}}.{{classVarName}} import {{classname}} +{{/apis}} +{{/apiInfo}} diff --git a/codegen/openapi/templates5.2.0/__init__model.mustache b/codegen/openapi/templates5.2.0/__init__model.mustache new file mode 100644 index 000000000..cfe32b784 --- /dev/null +++ b/codegen/openapi/templates5.2.0/__init__model.mustache @@ -0,0 +1,5 @@ +# we can not import model classes here because that would create a circular +# reference which would not work in python2 +# do not import all models into this module because that uses a lot of memory and stack frames +# if you need the ability to import all models from one package, import them with +# from {{packageName}.models import ModelA, ModelB diff --git a/codegen/openapi/templates5.2.0/__init__models.mustache b/codegen/openapi/templates5.2.0/__init__models.mustache new file mode 100644 index 000000000..76d91fc5d --- /dev/null +++ b/codegen/openapi/templates5.2.0/__init__models.mustache @@ -0,0 +1,16 @@ +# flake8: noqa + +# import all models into this package +# if you have many models here with many references from one model to another this may +# raise a RecursionError +# to avoid this, import only the models that you directly need like: +# from from {{modelPackage}}.pet import Pet +# or import this package, but before doing it, use: +# import sys +# sys.setrecursionlimit(n) + +{{#models}} +{{#model}} +from {{modelPackage}}.{{classFilename}} import {{classname}} +{{/model}} +{{/models}} diff --git a/codegen/openapi/templates5.2.0/__init__package.mustache b/codegen/openapi/templates5.2.0/__init__package.mustache new file mode 100644 index 000000000..b798bf3f2 --- /dev/null +++ b/codegen/openapi/templates5.2.0/__init__package.mustache @@ -0,0 +1,26 @@ +# flake8: noqa + +{{>partial_header}} + +__version__ = "{{packageVersion}}" + +# import ApiClient +from {{packageName}}.api_client import ApiClient + +# import Configuration +from {{packageName}}.configuration import Configuration +{{#hasHttpSignatureMethods}} +from {{packageName}}.signing import HttpSigningConfiguration +{{/hasHttpSignatureMethods}} + +# import exceptions +from {{packageName}}.exceptions import PineconeException +from {{packageName}}.exceptions import PineconeApiAttributeError +from {{packageName}}.exceptions import PineconeApiTypeError +from {{packageName}}.exceptions import PineconeApiValueError +from {{packageName}}.exceptions import PineconeApiKeyError +from {{packageName}}.exceptions import PineconeApiException +{{#recursionLimit}} + +__import__('sys').setrecursionlimit({{{.}}}) +{{/recursionLimit}} diff --git a/codegen/openapi/templates5.2.0/api.mustache b/codegen/openapi/templates5.2.0/api.mustache new file mode 100644 index 000000000..4be68cdf1 --- /dev/null +++ b/codegen/openapi/templates5.2.0/api.mustache @@ -0,0 +1,306 @@ +{{>partial_header}} + +import re # noqa: F401 +import sys # noqa: F401 + +from {{packageName}}.api_client import ApiClient, Endpoint as _Endpoint +from {{packageName}}.model_utils import ( # noqa: F401 + check_allowed_values, + check_validations, + date, + datetime, + file_type, + none_type, + validate_and_convert_types +) +{{#imports}} +{{{import}}} +{{/imports}} + + +{{#operations}} +class {{classname}}(object): + """NOTE: This class is auto generated by OpenAPI Generator + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + def __init__(self, api_client=None): + if api_client is None: + api_client = ApiClient() + self.api_client = api_client +{{#operation}} + + def __{{operationId}}( + self, +{{#requiredParams}} +{{^defaultValue}} + {{paramName}}, +{{/defaultValue}} +{{/requiredParams}} +{{#requiredParams}} +{{#defaultValue}} + {{paramName}}={{{defaultValue}}}, +{{/defaultValue}} +{{/requiredParams}} + **kwargs + ): + """{{#summary}}{{{.}}}{{/summary}}{{^summary}}{{operationId}}{{/summary}} # noqa: E501 + +{{#notes}} + {{{notes}}} # noqa: E501 +{{/notes}} + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.{{operationId}}({{#requiredParams}}{{^defaultValue}}{{paramName}}, {{/defaultValue}}{{/requiredParams}}{{#requiredParams}}{{#defaultValue}}{{paramName}}={{{defaultValue}}}, {{/defaultValue}}{{/requiredParams}}async_req=True) + >>> result = thread.get() + +{{#requiredParams}} +{{#-last}} + Args: +{{/-last}} +{{/requiredParams}} +{{#requiredParams}} +{{^defaultValue}} + {{paramName}} ({{dataType}}):{{#description}} {{{description}}}{{/description}} +{{/defaultValue}} +{{/requiredParams}} +{{#requiredParams}} +{{#defaultValue}} + {{paramName}} ({{dataType}}):{{#description}} {{{description}}}.{{/description}} defaults to {{{defaultValue}}}, must be one of [{{{defaultValue}}}] +{{/defaultValue}} +{{/requiredParams}} + + Keyword Args:{{#optionalParams}} + {{paramName}} ({{dataType}}):{{#description}} {{{description}}}.{{/description}} [optional]{{#defaultValue}} if omitted the server will use the default value of {{{defaultValue}}}{{/defaultValue}}{{/optionalParams}} + _return_http_data_only (bool): response data without head status + code and headers. Default is True. + _preload_content (bool): if False, the urllib3.HTTPResponse object + will be returned without reading/decoding response data. + Default is True. + _request_timeout (int/float/tuple): 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. + Default is None. + _check_input_type (bool): specifies if type checking + should be done one the data sent to the server. + Default is True. + _check_return_type (bool): specifies if type checking + should be done one the data received from the server. + Default is True. + _host_index (int/None): specifies the index of the server + that we want to use. + Default is read from the configuration. + async_req (bool): execute request asynchronously + + Returns: + {{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}None{{/returnType}} + If the method is called asynchronously, returns the request + thread. + """ + kwargs['async_req'] = kwargs.get( + 'async_req', False + ) + kwargs['_return_http_data_only'] = kwargs.get( + '_return_http_data_only', True + ) + kwargs['_preload_content'] = kwargs.get( + '_preload_content', True + ) + kwargs['_request_timeout'] = kwargs.get( + '_request_timeout', None + ) + kwargs['_check_input_type'] = kwargs.get( + '_check_input_type', True + ) + kwargs['_check_return_type'] = kwargs.get( + '_check_return_type', True + ) + kwargs['_host_index'] = kwargs.get('_host_index') +{{#requiredParams}} + kwargs['{{paramName}}'] = \ + {{paramName}} +{{/requiredParams}} + return self.call_with_http_info(**kwargs) + + self.{{operationId}} = _Endpoint( + settings={ + 'response_type': {{#returnType}}({{{returnType}}},){{/returnType}}{{^returnType}}None{{/returnType}}, +{{#authMethods}} +{{#-first}} + 'auth': [ +{{/-first}} + '{{name}}'{{^-last}},{{/-last}} +{{#-last}} + ], +{{/-last}} +{{/authMethods}} +{{^authMethods}} + 'auth': [], +{{/authMethods}} + 'endpoint_path': '{{{path}}}', + 'operation_id': '{{operationId}}', + 'http_method': '{{httpMethod}}', +{{#servers}} +{{#-first}} + 'servers': [ +{{/-first}} + { + 'url': "{{{url}}}", + 'description': "{{{description}}}{{^description}}No description provided{{/description}}", + {{#variables}} + {{#-first}} + 'variables': { + {{/-first}} + '{{{name}}}': { + 'description': "{{{description}}}{{^description}}No description provided{{/description}}", + 'default_value': "{{{defaultValue}}}", + {{#enumValues}} + {{#-first}} + 'enum_values': [ + {{/-first}} + "{{{.}}}"{{^-last}},{{/-last}} + {{#-last}} + ] + {{/-last}} + {{/enumValues}} + }{{^-last}},{{/-last}} + {{#-last}} + } + {{/-last}} + {{/variables}} + }, +{{#-last}} + ] +{{/-last}} +{{/servers}} +{{^servers}} + 'servers': None, +{{/servers}} + }, + params_map={ + 'all': [ +{{#allParams}} + '{{paramName}}', +{{/allParams}} + ], +{{#requiredParams}} +{{#-first}} + 'required': [ +{{/-first}} + '{{paramName}}', +{{#-last}} + ], +{{/-last}} +{{/requiredParams}} +{{^requiredParams}} + 'required': [], +{{/requiredParams}} + 'nullable': [ +{{#allParams}} +{{#isNullable}} + '{{paramName}}', +{{/isNullable}} +{{/allParams}} + ], + 'enum': [ +{{#allParams}} +{{#isEnum}} + '{{paramName}}', +{{/isEnum}} +{{/allParams}} + ], + 'validation': [ +{{#allParams}} +{{#hasValidation}} + '{{paramName}}', +{{/hasValidation}} +{{/allParams}} + ] + }, + root_map={ + 'validations': { +{{#allParams}} +{{#hasValidation}} + ('{{paramName}}',): { +{{#maxLength}} + 'max_length': {{maxLength}},{{/maxLength}}{{#minLength}} + 'min_length': {{minLength}},{{/minLength}}{{#maxItems}} + 'max_items': {{maxItems}},{{/maxItems}}{{#minItems}} + 'min_items': {{minItems}},{{/minItems}}{{#maximum}} + {{#exclusiveMaximum}}'exclusive_maximum'{{/exclusiveMaximum}}{{^exclusiveMaximum}}'inclusive_maximum'{{/exclusiveMaximum}}: {{maximum}},{{/maximum}}{{#minimum}} + {{#exclusiveMinimum}}'exclusive_minimum'{{/exclusiveMinimum}}{{^exclusiveMinimum}}'inclusive_minimum'{{/exclusiveMinimum}}: {{minimum}},{{/minimum}}{{#pattern}} + 'regex': { + 'pattern': r'{{{vendorExtensions.x-regex}}}', # noqa: E501{{#vendorExtensions.x-modifiers}} + {{#-first}}'flags': (re.{{.}}{{/-first}}{{^-first}} re.{{.}}{{/-first}}{{^-last}} | {{/-last}}{{#-last}}){{/-last}}{{/vendorExtensions.x-modifiers}} + },{{/pattern}} + }, +{{/hasValidation}} +{{/allParams}} + }, + 'allowed_values': { +{{#allParams}} +{{#isEnum}} + ('{{paramName}}',): { +{{#isNullable}} + 'None': None,{{/isNullable}}{{#allowableValues}}{{#enumVars}} + "{{name}}": {{{value}}}{{^-last}},{{/-last}}{{/enumVars}}{{/allowableValues}} + }, +{{/isEnum}} +{{/allParams}} + }, + 'openapi_types': { +{{#allParams}} + '{{paramName}}': + ({{{dataType}}},), +{{/allParams}} + }, + 'attribute_map': { +{{#allParams}} +{{^isBodyParam}} + '{{paramName}}': '{{baseName}}', +{{/isBodyParam}} +{{/allParams}} + }, + 'location_map': { +{{#allParams}} + '{{paramName}}': '{{#isFormParam}}form{{/isFormParam}}{{#isQueryParam}}query{{/isQueryParam}}{{#isPathParam}}path{{/isPathParam}}{{#isHeaderParam}}header{{/isHeaderParam}}{{#isCookieParam}}cookie{{/isCookieParam}}{{#isBodyParam}}body{{/isBodyParam}}', +{{/allParams}} + }, + 'collection_format_map': { +{{#allParams}} +{{#collectionFormat}} + '{{paramName}}': '{{collectionFormat}}', +{{/collectionFormat}} +{{/allParams}} + } + }, + headers_map={ +{{#hasProduces}} + 'accept': [ +{{#produces}} + '{{{mediaType}}}'{{^-last}},{{/-last}} +{{/produces}} + ], +{{/hasProduces}} +{{^hasProduces}} + 'accept': [], +{{/hasProduces}} +{{#hasConsumes}} + 'content_type': [ +{{#consumes}} + '{{{mediaType}}}'{{^-last}},{{/-last}} +{{/consumes}} + ] +{{/hasConsumes}} +{{^hasConsumes}} + 'content_type': [], +{{/hasConsumes}} + }, + api_client=api_client, + callable=__{{operationId}} + ) +{{/operation}} +{{/operations}} diff --git a/codegen/openapi/templates5.2.0/api_client.mustache b/codegen/openapi/templates5.2.0/api_client.mustache new file mode 100644 index 000000000..93ed83524 --- /dev/null +++ b/codegen/openapi/templates5.2.0/api_client.mustache @@ -0,0 +1,870 @@ +{{>partial_header}} + +import json +import atexit +import mimetypes +from multiprocessing.pool import ThreadPool +import io +import os +import re +import typing +from urllib.parse import quote +from urllib3.fields import RequestField + +{{#tornado}} +import tornado.gen +{{/tornado}} + +from {{packageName}} import rest +from {{packageName}}.configuration import Configuration +from {{packageName}}.exceptions import PineconeApiTypeError, PineconeApiValueError, PineconeApiException +from {{packageName}}.model_utils import ( + ModelNormal, + ModelSimple, + ModelComposed, + check_allowed_values, + check_validations, + date, + datetime, + deserialize_file, + file_type, + model_to_dict, + none_type, + validate_and_convert_types +) + + +class ApiClient(object): + """Generic API client for OpenAPI client library builds. + + OpenAPI generic API client. This client handles the client- + server communication, and is invariant across implementations. Specifics of + the methods and models for each application are generated from the OpenAPI + templates. + + NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + Do not edit the class manually. + + :param configuration: .Configuration object for this client + :param header_name: a header to pass when making calls to the API. + :param header_value: a header value to pass when making calls to + the API. + :param cookie: a cookie to include in the header when making calls + to the API + :param pool_threads: The number of threads to use for async requests + to the API. More threads means more concurrent API requests. + """ + + _pool = None + + def __init__(self, configuration=None, header_name=None, header_value=None, + cookie=None, pool_threads=1): + if configuration is None: + configuration = Configuration.get_default_copy() + self.configuration = configuration + self.pool_threads = pool_threads + + self.rest_client = rest.RESTClientObject(configuration) + self.default_headers = {} + if header_name is not None: + self.default_headers[header_name] = header_value + self.cookie = cookie + # Set default User-Agent. + self.user_agent = '{{#httpUserAgent}}{{{.}}}{{/httpUserAgent}}{{^httpUserAgent}}OpenAPI-Generator/{{{packageVersion}}}/python{{/httpUserAgent}}' + + def __enter__(self): + return self + + def __exit__(self, exc_type, exc_value, traceback): + self.close() + + def close(self): + if self._pool: + self._pool.close() + self._pool.join() + self._pool = None + if hasattr(atexit, 'unregister'): + atexit.unregister(self.close) + + @property + def pool(self): + """Create thread pool on first request + avoids instantiating unused threadpool for blocking clients. + """ + if self._pool is None: + atexit.register(self.close) + self._pool = ThreadPool(self.pool_threads) + return self._pool + + @property + def user_agent(self): + """User agent for this API client""" + return self.default_headers['User-Agent'] + + @user_agent.setter + def user_agent(self, value): + self.default_headers['User-Agent'] = value + + def set_default_header(self, header_name, header_value): + self.default_headers[header_name] = header_value + + {{#tornado}} + @tornado.gen.coroutine + {{/tornado}} + {{#asyncio}}async {{/asyncio}}def __call_api( + self, + resource_path: str, + method: str, + path_params: typing.Optional[typing.Dict[str, typing.Any]] = None, + query_params: typing.Optional[typing.List[typing.Tuple[str, typing.Any]]] = None, + header_params: typing.Optional[typing.Dict[str, typing.Any]] = None, + body: typing.Optional[typing.Any] = None, + post_params: typing.Optional[typing.List[typing.Tuple[str, typing.Any]]] = None, + files: typing.Optional[typing.Dict[str, typing.List[io.IOBase]]] = None, + response_type: typing.Optional[typing.Tuple[typing.Any]] = None, + auth_settings: typing.Optional[typing.List[str]] = None, + _return_http_data_only: typing.Optional[bool] = None, + collection_formats: typing.Optional[typing.Dict[str, str]] = None, + _preload_content: bool = True, + _request_timeout: typing.Optional[typing.Union[int, float, typing.Tuple]] = None, + _host: typing.Optional[str] = None, + _check_type: typing.Optional[bool] = None + ): + + config = self.configuration + + # header parameters + header_params = header_params or {} + header_params.update(self.default_headers) + if self.cookie: + header_params['Cookie'] = self.cookie + if header_params: + header_params = self.sanitize_for_serialization(header_params) + header_params = dict(self.parameters_to_tuples(header_params, + collection_formats)) + + # path parameters + if path_params: + path_params = self.sanitize_for_serialization(path_params) + path_params = self.parameters_to_tuples(path_params, + collection_formats) + for k, v in path_params: + # specified safe chars, encode everything + resource_path = resource_path.replace( + '{%s}' % k, + quote(str(v), safe=config.safe_chars_for_path_param) + ) + + # query parameters + if query_params: + query_params = self.sanitize_for_serialization(query_params) + query_params = self.parameters_to_tuples(query_params, + collection_formats) + + # post parameters + if post_params or files: + post_params = post_params if post_params else [] + post_params = self.sanitize_for_serialization(post_params) + post_params = self.parameters_to_tuples(post_params, + collection_formats) + post_params.extend(self.files_parameters(files)) + if header_params['Content-Type'].startswith("multipart"): + post_params = self.parameters_to_multipart(post_params, + (dict) ) + + # body + if body: + body = self.sanitize_for_serialization(body) + + # auth setting + self.update_params_for_auth(header_params, query_params, + auth_settings, resource_path, method, body) + + # request url + if _host is None: + url = self.configuration.host + resource_path + else: + # use server/host defined in path or operation instead + url = _host + resource_path + + try: + # perform request and return response + response_data = {{#asyncio}}await {{/asyncio}}{{#tornado}}yield {{/tornado}}self.request( + method, url, query_params=query_params, headers=header_params, + post_params=post_params, body=body, + _preload_content=_preload_content, + _request_timeout=_request_timeout) + except PineconeApiException as e: + e.body = e.body.decode('utf-8') + raise e + + self.last_response = response_data + + return_data = response_data + + if not _preload_content: + {{^tornado}} + return (return_data) + {{/tornado}} + {{#tornado}} + raise tornado.gen.Return(return_data) + {{/tornado}} + return return_data + + # deserialize response data + if response_type: + if response_type != (file_type,): + encoding = "utf-8" + content_type = response_data.getheader('content-type') + if content_type is not None: + match = re.search(r"charset=([a-zA-Z\-\d]+)[\s\;]?", content_type) + if match: + encoding = match.group(1) + response_data.data = response_data.data.decode(encoding) + + return_data = self.deserialize( + response_data, + response_type, + _check_type + ) + else: + return_data = None + +{{^tornado}} + if _return_http_data_only: + return (return_data) + else: + return (return_data, response_data.status, + response_data.getheaders()) +{{/tornado}} +{{#tornado}} + if _return_http_data_only: + raise tornado.gen.Return(return_data) + else: + raise tornado.gen.Return((return_data, response_data.status, + response_data.getheaders())) +{{/tornado}} + + def parameters_to_multipart(self, params, collection_types): + """Get parameters as list of tuples, formatting as json if value is collection_types + + :param params: Parameters as list of two-tuples + :param dict collection_types: Parameter collection types + :return: Parameters as list of tuple or urllib3.fields.RequestField + """ + new_params = [] + if collection_types is None: + collection_types = (dict) + for k, v in params.items() if isinstance(params, dict) else params: # noqa: E501 + if isinstance(v, collection_types): # v is instance of collection_type, formatting as application/json + v = json.dumps(v, ensure_ascii=False).encode("utf-8") + field = RequestField(k, v) + field.make_multipart(content_type="application/json; charset=utf-8") + new_params.append(field) + else: + new_params.append((k, v)) + return new_params + + @classmethod + def sanitize_for_serialization(cls, obj): + """Prepares data for transmission before it is sent with the rest client + If obj is None, return None. + If obj is str, int, long, float, bool, return directly. + If obj is datetime.datetime, datetime.date + convert to string in iso8601 format. + If obj is list, sanitize each element in the list. + If obj is dict, return the dict. + If obj is OpenAPI model, return the properties dict. + If obj is io.IOBase, return the bytes + :param obj: The data to serialize. + :return: The serialized form of data. + """ + if isinstance(obj, (ModelNormal, ModelComposed)): + return { + key: cls.sanitize_for_serialization(val) for key, val in model_to_dict(obj, serialize=True).items() + } + elif isinstance(obj, io.IOBase): + return cls.get_file_data_and_close_file(obj) + elif isinstance(obj, (str, int, float, none_type, bool)): + return obj + elif isinstance(obj, (datetime, date)): + return obj.isoformat() + elif isinstance(obj, ModelSimple): + return cls.sanitize_for_serialization(obj.value) + elif isinstance(obj, (list, tuple)): + return [cls.sanitize_for_serialization(item) for item in obj] + if isinstance(obj, dict): + return {key: cls.sanitize_for_serialization(val) for key, val in obj.items()} + raise PineconeApiValueError('Unable to prepare type {} for serialization'.format(obj.__class__.__name__)) + + def deserialize(self, response, response_type, _check_type): + """Deserializes response into an object. + + :param response: RESTResponse object to be deserialized. + :param response_type: For the response, a tuple containing: + valid classes + a list containing valid classes (for list schemas) + a dict containing a tuple of valid classes as the value + Example values: + (str,) + (Pet,) + (float, none_type) + ([int, none_type],) + ({str: (bool, str, int, float, date, datetime, str, none_type)},) + :param _check_type: boolean, whether to check the types of the data + received from the server + :type _check_type: bool + + :return: deserialized object. + """ + # handle file downloading + # save response body into a tmp file and return the instance + if response_type == (file_type,): + content_disposition = response.getheader("Content-Disposition") + return deserialize_file(response.data, self.configuration, + content_disposition=content_disposition) + + # fetch data from response object + try: + received_data = json.loads(response.data) + except ValueError: + received_data = response.data + + # store our data under the key of 'received_data' so users have some + # context if they are deserializing a string and the data type is wrong + deserialized_data = validate_and_convert_types( + received_data, + response_type, + ['received_data'], + True, + _check_type, + configuration=self.configuration + ) + return deserialized_data + + def call_api( + self, + resource_path: str, + method: str, + path_params: typing.Optional[typing.Dict[str, typing.Any]] = None, + query_params: typing.Optional[typing.List[typing.Tuple[str, typing.Any]]] = None, + header_params: typing.Optional[typing.Dict[str, typing.Any]] = None, + body: typing.Optional[typing.Any] = None, + post_params: typing.Optional[typing.List[typing.Tuple[str, typing.Any]]] = None, + files: typing.Optional[typing.Dict[str, typing.List[io.IOBase]]] = None, + response_type: typing.Optional[typing.Tuple[typing.Any]] = None, + auth_settings: typing.Optional[typing.List[str]] = None, + async_req: typing.Optional[bool] = None, + _return_http_data_only: typing.Optional[bool] = None, + collection_formats: typing.Optional[typing.Dict[str, str]] = None, + _preload_content: bool = True, + _request_timeout: typing.Optional[typing.Union[int, float, typing.Tuple]] = None, + _host: typing.Optional[str] = None, + _check_type: typing.Optional[bool] = None + ): + """Makes the HTTP request (synchronous) and returns deserialized data. + + To make an async_req request, set the async_req parameter. + + :param resource_path: Path to method endpoint. + :param method: Method to call. + :param path_params: Path parameters in the url. + :param query_params: Query parameters in the url. + :param header_params: Header parameters to be + placed in the request header. + :param body: Request body. + :param post_params dict: Request post form parameters, + for `application/x-www-form-urlencoded`, `multipart/form-data`. + :param auth_settings list: Auth Settings names for the request. + :param response_type: For the response, a tuple containing: + valid classes + a list containing valid classes (for list schemas) + a dict containing a tuple of valid classes as the value + Example values: + (str,) + (Pet,) + (float, none_type) + ([int, none_type],) + ({str: (bool, str, int, float, date, datetime, str, none_type)},) + :param files: key -> field name, value -> a list of open file + objects for `multipart/form-data`. + :type files: dict + :param async_req bool: execute request asynchronously + :type async_req: bool, optional + :param _return_http_data_only: response data without head status code + and headers + :type _return_http_data_only: bool, optional + :param collection_formats: dict of collection formats for path, query, + header, and post parameters. + :type collection_formats: dict, optional + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :type _preload_content: bool, optional + :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. + :param _check_type: boolean describing if the data back from the server + should have its type checked. + :type _check_type: bool, optional + :return: + If async_req parameter is True, + the request will be called asynchronously. + The method will return the request thread. + If parameter async_req is False or missing, + then the method will return the response directly. + """ + if not async_req: + return self.__call_api(resource_path, method, + path_params, query_params, header_params, + body, post_params, files, + response_type, auth_settings, + _return_http_data_only, collection_formats, + _preload_content, _request_timeout, _host, + _check_type) + + return self.pool.apply_async(self.__call_api, (resource_path, + method, path_params, + query_params, + header_params, body, + post_params, files, + response_type, + auth_settings, + _return_http_data_only, + collection_formats, + _preload_content, + _request_timeout, + _host, _check_type)) + + 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 PineconeApiValueError( + "http method must be `GET`, `HEAD`, `OPTIONS`," + " `POST`, `PATCH`, `PUT` or `DELETE`." + ) + + def parameters_to_tuples(self, params, collection_formats): + """Get parameters as list of tuples, formatting collections. + + :param params: Parameters as dict or list of two-tuples + :param dict collection_formats: Parameter collection formats + :return: Parameters as list of tuples, collections formatted + """ + new_params = [] + if collection_formats is None: + collection_formats = {} + for k, v in params.items() if isinstance(params, dict) else params: # noqa: E501 + if k in collection_formats: + collection_format = collection_formats[k] + if collection_format == 'multi': + new_params.extend((k, value) for value in v) + else: + if collection_format == 'ssv': + delimiter = ' ' + elif collection_format == 'tsv': + delimiter = '\t' + elif collection_format == 'pipes': + delimiter = '|' + else: # csv is the default + delimiter = ',' + new_params.append( + (k, delimiter.join(str(value) for value in v))) + else: + new_params.append((k, v)) + return new_params + + @staticmethod + def get_file_data_and_close_file(file_instance: io.IOBase) -> bytes: + file_data = file_instance.read() + file_instance.close() + return file_data + + def files_parameters(self, files: typing.Optional[typing.Dict[str, typing.List[io.IOBase]]] = None): + """Builds form parameters. + + :param files: None or a dict with key=param_name and + value is a list of open file objects + :return: List of tuples of form parameters with file data + """ + if files is None: + return [] + + params = [] + for param_name, file_instances in files.items(): + if file_instances is None: + # if the file field is nullable, skip None values + continue + for file_instance in file_instances: + if file_instance is None: + # if the file field is nullable, skip None values + continue + if file_instance.closed is True: + raise PineconeApiValueError( + "Cannot read a closed file. The passed in file_type " + "for %s must be open." % param_name + ) + filename = os.path.basename(file_instance.name) + filedata = self.get_file_data_and_close_file(file_instance) + mimetype = (mimetypes.guess_type(filename)[0] or + 'application/octet-stream') + params.append( + tuple([param_name, tuple([filename, filedata, mimetype])])) + + return params + + def select_header_accept(self, accepts): + """Returns `Accept` based on an array of accepts provided. + + :param accepts: List of headers. + :return: Accept (e.g. application/json). + """ + if not accepts: + return + + accepts = [x.lower() for x in accepts] + + if 'application/json' in accepts: + return 'application/json' + else: + return ', '.join(accepts) + + def select_header_content_type(self, content_types): + """Returns `Content-Type` based on an array of content_types provided. + + :param content_types: List of content-types. + :return: Content-Type (e.g. application/json). + """ + if not content_types: + return 'application/json' + + content_types = [x.lower() for x in content_types] + + if 'application/json' in content_types or '*/*' in content_types: + return 'application/json' + else: + return content_types[0] + + def update_params_for_auth(self, headers, querys, auth_settings, + resource_path, method, body): + """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. + :param resource_path: A string representation of the HTTP request resource path. + :param method: A string representation of the HTTP request method. + :param body: A object representing the body of the HTTP request. + The object type is the return value of _encoder.default(). + """ + 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': + if auth_setting['type'] != 'http-signature': + headers[auth_setting['key']] = auth_setting['value'] +{{#hasHttpSignatureMethods}} + else: + # The HTTP signature scheme requires multiple HTTP headers + # that are calculated dynamically. + signing_info = self.configuration.signing_info + auth_headers = signing_info.get_http_signature_headers( + resource_path, method, headers, body, querys) + headers.update(auth_headers) +{{/hasHttpSignatureMethods}} + elif auth_setting['in'] == 'query': + querys.append((auth_setting['key'], auth_setting['value'])) + else: + raise PineconeApiValueError( + 'Authentication token must be in `query` or `header`' + ) + + +class Endpoint(object): + def __init__(self, settings=None, params_map=None, root_map=None, + headers_map=None, api_client=None, callable=None): + """Creates an endpoint + + Args: + 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 + """ + self.settings = settings + self.params_map = params_map + self.params_map['all'].extend([ + 'async_req', + '_host_index', + '_preload_content', + '_request_timeout', + '_return_http_data_only', + '_check_input_type', + '_check_return_type' + ]) + self.params_map['nullable'].extend(['_request_timeout']) + self.validations = root_map['validations'] + self.allowed_values = root_map['allowed_values'] + self.openapi_types = root_map['openapi_types'] + extra_types = { + 'async_req': (bool,), + '_host_index': (none_type, int), + '_preload_content': (bool,), + '_request_timeout': (none_type, float, (float,), [float], int, (int,), [int]), + '_return_http_data_only': (bool,), + '_check_input_type': (bool,), + '_check_return_type': (bool,) + } + self.openapi_types.update(extra_types) + self.attribute_map = root_map['attribute_map'] + self.location_map = root_map['location_map'] + self.collection_format_map = root_map['collection_format_map'] + self.headers_map = headers_map + self.api_client = api_client + self.callable = callable + + def __validate_inputs(self, kwargs): + for param in self.params_map['enum']: + if param in kwargs: + check_allowed_values( + self.allowed_values, + (param,), + kwargs[param] + ) + + for param in self.params_map['validation']: + if param in kwargs: + check_validations( + self.validations, + (param,), + kwargs[param], + configuration=self.api_client.configuration + ) + + if kwargs['_check_input_type'] is False: + return + + for key, value in kwargs.items(): + fixed_val = validate_and_convert_types( + value, + self.openapi_types[key], + [key], + False, + kwargs['_check_input_type'], + configuration=self.api_client.configuration + ) + kwargs[key] = fixed_val + + def __gather_params(self, kwargs): + params = { + 'body': None, + 'collection_format': {}, + 'file': {}, + 'form': [], + 'header': {}, + 'path': {}, + 'query': [] + } + + for param_name, param_value in kwargs.items(): + param_location = self.location_map.get(param_name) + if param_location is None: + continue + if param_location: + if param_location == 'body': + params['body'] = param_value + continue + base_name = self.attribute_map[param_name] + if (param_location == 'form' and + self.openapi_types[param_name] == (file_type,)): + params['file'][param_name] = [param_value] + elif (param_location == 'form' and + self.openapi_types[param_name] == ([file_type],)): + # param_value is already a list + params['file'][param_name] = param_value + elif param_location in {'form', 'query'}: + param_value_full = (base_name, param_value) + params[param_location].append(param_value_full) + if param_location not in {'form', 'query'}: + params[param_location][base_name] = param_value + collection_format = self.collection_format_map.get(param_name) + if collection_format: + params['collection_format'][base_name] = collection_format + + return params + + def __call__(self, *args, **kwargs): + """ This method is invoked when endpoints are called + Example: +{{#apiInfo}}{{#apis}}{{#-first}}{{#operations}}{{#operation}}{{#-first}} + api_instance = {{classname}}() + api_instance.{{operationId}} # this is an instance of the class Endpoint + api_instance.{{operationId}}() # this invokes api_instance.{{operationId}}.__call__() + which then invokes the callable functions stored in that endpoint at + api_instance.{{operationId}}.callable or self.callable in this class +{{/-first}}{{/operation}}{{/operations}}{{/-first}}{{/apis}}{{/apiInfo}} + """ + return self.callable(self, *args, **kwargs) + + def call_with_http_info(self, **kwargs): + + try: + index = self.api_client.configuration.server_operation_index.get( + self.settings['operation_id'], self.api_client.configuration.server_index + ) if kwargs['_host_index'] is None else kwargs['_host_index'] + server_variables = self.api_client.configuration.server_operation_variables.get( + self.settings['operation_id'], self.api_client.configuration.server_variables + ) + _host = self.api_client.configuration.get_host_from_settings( + index, variables=server_variables, servers=self.settings['servers'] + ) + except IndexError: + if self.settings['servers']: + raise PineconeApiValueError( + "Invalid host index. Must be 0 <= index < %s" % + len(self.settings['servers']) + ) + _host = None + + for key, value in kwargs.items(): + if key not in self.params_map['all']: + raise PineconeApiTypeError( + "Got an unexpected parameter '%s'" + " to method `%s`" % + (key, self.settings['operation_id']) + ) + # only throw this nullable PineconeApiValueError if _check_input_type + # is False, if _check_input_type==True we catch this case + # in self.__validate_inputs + if (key not in self.params_map['nullable'] and value is None + and kwargs['_check_input_type'] is False): + raise PineconeApiValueError( + "Value may not be None for non-nullable parameter `%s`" + " when calling `%s`" % + (key, self.settings['operation_id']) + ) + + for key in self.params_map['required']: + if key not in kwargs.keys(): + raise PineconeApiValueError( + "Missing the required parameter `%s` when calling " + "`%s`" % (key, self.settings['operation_id']) + ) + + self.__validate_inputs(kwargs) + + params = self.__gather_params(kwargs) + + accept_headers_list = self.headers_map['accept'] + if accept_headers_list: + params['header']['Accept'] = self.api_client.select_header_accept( + accept_headers_list) + + content_type_headers_list = self.headers_map['content_type'] + if content_type_headers_list: + header_list = self.api_client.select_header_content_type( + content_type_headers_list) + params['header']['Content-Type'] = header_list + + return self.api_client.call_api( + self.settings['endpoint_path'], self.settings['http_method'], + params['path'], + params['query'], + params['header'], + body=params['body'], + post_params=params['form'], + files=params['file'], + response_type=self.settings['response_type'], + auth_settings=self.settings['auth'], + async_req=kwargs['async_req'], + _check_type=kwargs['_check_return_type'], + _return_http_data_only=kwargs['_return_http_data_only'], + _preload_content=kwargs['_preload_content'], + _request_timeout=kwargs['_request_timeout'], + _host=_host, + collection_formats=params['collection_format']) diff --git a/codegen/openapi/templates5.2.0/api_doc.mustache b/codegen/openapi/templates5.2.0/api_doc.mustache new file mode 100644 index 000000000..7c19d58eb --- /dev/null +++ b/codegen/openapi/templates5.2.0/api_doc.mustache @@ -0,0 +1,77 @@ +# {{packageName}}.{{classname}}{{#description}} +{{description}}{{/description}} + +All URIs are relative to *{{basePath}}* + +Method | HTTP request | Description +------------- | ------------- | ------------- +{{#operations}}{{#operation}}[**{{operationId}}**]({{classname}}.md#{{operationId}}) | **{{httpMethod}}** {{path}} | {{#summary}}{{summary}}{{/summary}} +{{/operation}}{{/operations}} + +{{#operations}} +{{#operation}} +# **{{{operationId}}}** +> {{#returnType}}{{{returnType}}} {{/returnType}}{{{operationId}}}({{#requiredParams}}{{^defaultValue}}{{paramName}}{{^-last}}, {{/-last}}{{/defaultValue}}{{/requiredParams}}) + +{{{summary}}}{{#notes}} + +{{{notes}}}{{/notes}} + +### Example + +{{#hasAuthMethods}} +{{#authMethods}} +{{#isBasic}} +{{#isBasicBasic}} +* Basic Authentication ({{name}}): +{{/isBasicBasic}} +{{#isBasicBearer}} +* Bearer{{#bearerFormat}} ({{{.}}}){{/bearerFormat}} Authentication ({{name}}): +{{/isBasicBearer}} +{{/isBasic}} +{{#isApiKey}} +* Api Key Authentication ({{name}}): +{{/isApiKey }} +{{#isOAuth}} +* OAuth Authentication ({{name}}): +{{/isOAuth }} +{{/authMethods}} +{{/hasAuthMethods}} +{{> api_doc_example }} + +### Parameters +{{^allParams}}This endpoint does not need any parameter.{{/allParams}}{{#allParams}}{{#-last}} +Name | Type | Description | Notes +------------- | ------------- | ------------- | -------------{{/-last}}{{/allParams}} +{{#requiredParams}}{{^defaultValue}} **{{paramName}}** | {{^baseType}}**{{dataType}}**{{/baseType}}{{#baseType}}[**{{dataType}}**]({{baseType}}.md){{/baseType}}| {{description}} | +{{/defaultValue}}{{/requiredParams}}{{#requiredParams}}{{#defaultValue}} **{{paramName}}** | {{^baseType}}**{{dataType}}**{{/baseType}}{{#baseType}}[**{{dataType}}**]({{baseType}}.md){{/baseType}}| {{description}} | defaults to {{{.}}} +{{/defaultValue}}{{/requiredParams}}{{#optionalParams}} **{{paramName}}** | {{^baseType}}**{{dataType}}**{{/baseType}}{{#baseType}}[**{{dataType}}**]({{baseType}}.md){{/baseType}}| {{description}} | [optional]{{#defaultValue}} if omitted the server will use the default value of {{{.}}}{{/defaultValue}} +{{/optionalParams}} + +### Return type + +{{#returnType}}{{#returnTypeIsPrimitive}}**{{{returnType}}}**{{/returnTypeIsPrimitive}}{{^returnTypeIsPrimitive}}[**{{{returnType}}}**]({{returnBaseType}}.md){{/returnTypeIsPrimitive}}{{/returnType}}{{^returnType}}void (empty response body){{/returnType}} + +### Authorization + +{{^authMethods}}No authorization required{{/authMethods}}{{#authMethods}}[{{{name}}}](../README.md#{{{name}}}){{^-last}}, {{/-last}}{{/authMethods}} + +### HTTP request headers + + - **Content-Type**: {{#consumes}}{{{mediaType}}}{{^-last}}, {{/-last}}{{/consumes}}{{^consumes}}Not defined{{/consumes}} + - **Accept**: {{#produces}}{{{mediaType}}}{{^-last}}, {{/-last}}{{/produces}}{{^produces}}Not defined{{/produces}} + +{{#responses.0}} + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +{{#responses}} +**{{code}}** | {{message}} | {{#headers}} * {{baseName}} - {{description}}
{{/headers}}{{^headers.0}} - {{/headers.0}} | +{{/responses}} +{{/responses.0}} + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +{{/operation}} +{{/operations}} diff --git a/codegen/openapi/templates5.2.0/api_doc_example.mustache b/codegen/openapi/templates5.2.0/api_doc_example.mustache new file mode 100644 index 000000000..aa060b790 --- /dev/null +++ b/codegen/openapi/templates5.2.0/api_doc_example.mustache @@ -0,0 +1,76 @@ +```python +import time +import {{{packageName}}} +from {{apiPackage}} import {{classVarName}} +{{#imports}} +{{{.}}} +{{/imports}} +from pprint import pprint +{{> python_doc_auth_partial}} +# Enter a context with an instance of the API client +{{#hasAuthMethods}} +with {{{packageName}}}.ApiClient(configuration) as api_client: +{{/hasAuthMethods}} +{{^hasAuthMethods}} +with {{{packageName}}}.ApiClient() as api_client: +{{/hasAuthMethods}} + # Create an instance of the API class + api_instance = {{classVarName}}.{{{classname}}}(api_client) +{{#requiredParams}} +{{^defaultValue}} + {{paramName}} = {{{example}}} # {{{dataType}}} | {{{description}}} +{{/defaultValue}} +{{/requiredParams}} +{{#optionalParams}} + {{paramName}} = {{{example}}} # {{{dataType}}} | {{{description}}}{{^required}} (optional){{/required}}{{#defaultValue}} if omitted the server will use the default value of {{{defaultValue}}}{{/defaultValue}} +{{/optionalParams}} +{{#requiredParams}} +{{#-last}} + + # example passing only required values which don't have defaults set + try: +{{#summary}} + # {{{.}}} +{{/summary}} + {{#returnType}}api_response = {{/returnType}}api_instance.{{{operationId}}}({{#requiredParams}}{{^defaultValue}}{{paramName}}{{^-last}}, {{/-last}}{{/defaultValue}}{{/requiredParams}}) +{{#returnType}} + pprint(api_response) +{{/returnType}} + except {{{packageName}}}.PineconeApiException as e: + print("Exception when calling {{classname}}->{{operationId}}: %s\n" % e) +{{/-last}} +{{/requiredParams}} +{{#optionalParams}} +{{#-last}} + + # example passing only required values which don't have defaults set + # and optional values + try: +{{#summary}} + # {{{.}}} +{{/summary}} + {{#returnType}}api_response = {{/returnType}}api_instance.{{{operationId}}}({{#requiredParams}}{{^defaultValue}}{{paramName}}, {{/defaultValue}}{{/requiredParams}}{{#optionalParams}}{{paramName}}={{paramName}}{{^-last}}, {{/-last}}{{/optionalParams}}) +{{#returnType}} + pprint(api_response) +{{/returnType}} + except {{{packageName}}}.PineconeApiException as e: + print("Exception when calling {{classname}}->{{operationId}}: %s\n" % e) +{{/-last}} +{{/optionalParams}} +{{^requiredParams}} +{{^optionalParams}} + + # example, this endpoint has no required or optional parameters + try: +{{#summary}} + # {{{.}}} +{{/summary}} + {{#returnType}}api_response = {{/returnType}}api_instance.{{{operationId}}}() +{{#returnType}} + pprint(api_response) +{{/returnType}} + except {{{packageName}}}.PineconeApiException as e: + print("Exception when calling {{classname}}->{{operationId}}: %s\n" % e) +{{/optionalParams}} +{{/requiredParams}} +``` diff --git a/codegen/openapi/templates5.2.0/api_test.mustache b/codegen/openapi/templates5.2.0/api_test.mustache new file mode 100644 index 000000000..bf2cd1928 --- /dev/null +++ b/codegen/openapi/templates5.2.0/api_test.mustache @@ -0,0 +1,32 @@ +{{>partial_header}} + +import unittest + +import {{packageName}} +from {{apiPackage}}.{{classVarName}} import {{classname}} # noqa: E501 + + +class {{#operations}}Test{{classname}}(unittest.TestCase): + """{{classname}} unit test stubs""" + + def setUp(self): + self.api = {{classname}}() # noqa: E501 + + def tearDown(self): + pass + + {{#operation}} + def test_{{operationId}}(self): + """Test case for {{{operationId}}} + +{{#summary}} + {{{summary}}} # noqa: E501 +{{/summary}} + """ + pass + + {{/operation}} +{{/operations}} + +if __name__ == '__main__': + unittest.main() diff --git a/codegen/openapi/templates5.2.0/asyncio/rest.mustache b/codegen/openapi/templates5.2.0/asyncio/rest.mustache new file mode 100644 index 000000000..718eb81c4 --- /dev/null +++ b/codegen/openapi/templates5.2.0/asyncio/rest.mustache @@ -0,0 +1,236 @@ +{{>partial_header}} + +import io +import json +import logging +import re +import ssl + +import aiohttp +# python 2 and python 3 compatibility library +from six.moves.urllib.parse import urlencode + +from {{packageName}}.exceptions import PineconeApiException, PineconeApiValueError + +logger = logging.getLogger(__name__) + + +class RESTResponse(io.IOBase): + + def __init__(self, resp, data): + self.aiohttp_response = resp + self.status = resp.status + self.reason = resp.reason + self.data = data + + def getheaders(self): + """Returns a CIMultiDictProxy of the response headers.""" + return self.aiohttp_response.headers + + def getheader(self, name, default=None): + """Returns a given response header.""" + return self.aiohttp_response.headers.get(name, default) + + +class RESTClientObject(object): + + def __init__(self, configuration, pools_size=4, maxsize=None): + + # maxsize is number of requests to host that are allowed in parallel + if maxsize is None: + maxsize = configuration.connection_pool_maxsize + + ssl_context = ssl.create_default_context(cafile=configuration.ssl_ca_cert) + if configuration.cert_file: + ssl_context.load_cert_chain( + configuration.cert_file, keyfile=configuration.key_file + ) + + if not configuration.verify_ssl: + ssl_context.check_hostname = False + ssl_context.verify_mode = ssl.CERT_NONE + + connector = aiohttp.TCPConnector( + limit=maxsize, + ssl=ssl_context + ) + + self.proxy = configuration.proxy + self.proxy_headers = configuration.proxy_headers + + # https pool manager + self.pool_manager = aiohttp.ClientSession( + connector=connector + ) + + async def close(self): + await self.pool_manager.close() + + async def request(self, method, url, query_params=None, headers=None, + body=None, post_params=None, _preload_content=True, + _request_timeout=None): + """Execute request + + :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: this is a non-applicable field for + the AiohttpClient. + :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 PineconeApiValueError( + "body parameter cannot be used with post_params parameter." + ) + + post_params = post_params or {} + headers = headers or {} + timeout = _request_timeout or 5 * 60 + + if 'Content-Type' not in headers: + headers['Content-Type'] = 'application/json' + + args = { + "method": method, + "url": url, + "timeout": timeout, + "headers": headers + } + + if self.proxy: + args["proxy"] = self.proxy + if self.proxy_headers: + args["proxy_headers"] = self.proxy_headers + + if query_params: + args["url"] += '?' + urlencode(query_params) + + # For `POST`, `PUT`, `PATCH`, `OPTIONS`, `DELETE` + if method in ['POST', 'PUT', 'PATCH', 'OPTIONS', 'DELETE']: + if re.search('json', headers['Content-Type'], re.IGNORECASE): + if body is not None: + body = json.dumps(body) + args["data"] = body + elif headers['Content-Type'] == 'application/x-www-form-urlencoded': # noqa: E501 + args["data"] = aiohttp.FormData(post_params) + elif headers['Content-Type'] == 'multipart/form-data': + # must del headers['Content-Type'], or the correct + # Content-Type which generated by aiohttp + del headers['Content-Type'] + data = aiohttp.FormData() + for param in post_params: + k, v = param + if isinstance(v, tuple) and len(v) == 3: + data.add_field(k, + value=v[1], + filename=v[0], + content_type=v[2]) + else: + data.add_field(k, v) + args["data"] = data + + # Pass a `bytes` parameter directly in the body to support + # other content types than Json when `body` argument is provided + # in serialized form + elif isinstance(body, bytes): + args["data"] = body + 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 PineconeApiException(status=0, reason=msg) + + r = await self.pool_manager.request(**args) + if _preload_content: + + data = await r.read() + r = RESTResponse(r, data) + + # log response body + logger.debug("response body: %s", r.data) + + if not 200 <= r.status <= 299: + raise PineconeApiException(http_resp=r) + + return r + + async def GET(self, url, headers=None, query_params=None, + _preload_content=True, _request_timeout=None): + return (await self.request("GET", url, + headers=headers, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + query_params=query_params)) + + async def HEAD(self, url, headers=None, query_params=None, + _preload_content=True, _request_timeout=None): + return (await self.request("HEAD", url, + headers=headers, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + query_params=query_params)) + + async def OPTIONS(self, url, headers=None, query_params=None, + post_params=None, body=None, _preload_content=True, + _request_timeout=None): + return (await self.request("OPTIONS", url, + headers=headers, + query_params=query_params, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body)) + + async def DELETE(self, url, headers=None, query_params=None, body=None, + _preload_content=True, _request_timeout=None): + return (await self.request("DELETE", url, + headers=headers, + query_params=query_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body)) + + async def POST(self, url, headers=None, query_params=None, + post_params=None, body=None, _preload_content=True, + _request_timeout=None): + return (await self.request("POST", url, + headers=headers, + query_params=query_params, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body)) + + async def PUT(self, url, headers=None, query_params=None, post_params=None, + body=None, _preload_content=True, _request_timeout=None): + return (await self.request("PUT", url, + headers=headers, + query_params=query_params, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body)) + + async def PATCH(self, url, headers=None, query_params=None, + post_params=None, body=None, _preload_content=True, + _request_timeout=None): + return (await self.request("PATCH", url, + headers=headers, + query_params=query_params, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body)) diff --git a/codegen/openapi/templates5.2.0/configuration.mustache b/codegen/openapi/templates5.2.0/configuration.mustache new file mode 100644 index 000000000..7800b2dac --- /dev/null +++ b/codegen/openapi/templates5.2.0/configuration.mustache @@ -0,0 +1,626 @@ +{{>partial_header}} + +import copy +import logging +{{^asyncio}} +import multiprocessing +{{/asyncio}} +import sys +import urllib3 + +from http import client as http_client +from {{packageName}}.exceptions import PineconeApiValueError + + +JSON_SCHEMA_VALIDATION_KEYWORDS = { + 'multipleOf', 'maximum', 'exclusiveMaximum', + 'minimum', 'exclusiveMinimum', 'maxLength', + 'minLength', 'pattern', 'maxItems', 'minItems' +} + +class Configuration(object): + """NOTE: This class is auto generated by OpenAPI Generator + + Ref: https://openapi-generator.tech + Do not edit the class manually. + + :param host: Base url + :param api_key: Dict to store API key(s). + Each entry in the dict specifies an API key. + The dict key is the name of the security scheme in the OAS specification. + The dict value is the API key secret. + :param api_key_prefix: Dict to store API prefix (e.g. Bearer) + The dict key is the name of the security scheme in the OAS specification. + The dict value is an API key prefix when generating the auth data. + :param username: Username for HTTP basic authentication + :param password: Password for HTTP basic authentication + :param discard_unknown_keys: Boolean value indicating whether to discard + unknown properties. A server may send a response that includes additional + properties that are not known by the client in the following scenarios: + 1. The OpenAPI document is incomplete, i.e. it does not match the server + implementation. + 2. The client was generated using an older version of the OpenAPI document + and the server has been upgraded since then. + If a schema in the OpenAPI document defines the additionalProperties attribute, + then all undeclared properties received by the server are injected into the + additional properties map. In that case, there are undeclared properties, and + nothing to discard. + :param disabled_client_side_validations (string): Comma-separated list of + JSON schema validation keywords to disable JSON schema structural validation + rules. The following keywords may be specified: multipleOf, maximum, + exclusiveMaximum, minimum, exclusiveMinimum, maxLength, minLength, pattern, + maxItems, minItems. + By default, the validation is performed for data generated locally by the client + and data received from the server, independent of any validation performed by + the server side. If the input data does not satisfy the JSON schema validation + rules specified in the OpenAPI document, an exception is raised. + If disabled_client_side_validations is set, structural validation is + disabled. This can be useful to troubleshoot data validation problem, such as + when the OpenAPI document validation rules do not match the actual API data + received by the server. +{{#hasHttpSignatureMethods}} + :param signing_info: Configuration parameters for the HTTP signature security scheme. + Must be an instance of {{{packageName}}}.signing.HttpSigningConfiguration +{{/hasHttpSignatureMethods}} + :param server_index: Index to servers configuration. + :param server_variables: Mapping with string values to replace variables in + templated server configuration. The validation of enums is performed for + variables with defined enum values before. + :param server_operation_index: Mapping from operation ID to an index to server + configuration. + :param server_operation_variables: Mapping from operation ID to a mapping with + string values to replace variables in templated server configuration. + The validation of enums is performed for variables with defined enum values before. + :param ssl_ca_cert: str - the path to a file of concatenated CA certificates + in PEM format + +{{#hasAuthMethods}} + :Example: +{{#hasApiKeyMethods}} + + API Key Authentication Example. + Given the following security scheme in the OpenAPI specification: + components: + securitySchemes: + cookieAuth: # name for the security scheme + type: apiKey + in: cookie + name: JSESSIONID # cookie name + + You can programmatically set the cookie: + +conf = {{{packageName}}}.Configuration( + api_key={'cookieAuth': 'abc123'} + api_key_prefix={'cookieAuth': 'JSESSIONID'} +) + + The following cookie will be added to the HTTP request: + Cookie: JSESSIONID abc123 +{{/hasApiKeyMethods}} +{{#hasHttpBasicMethods}} + + HTTP Basic Authentication Example. + Given the following security scheme in the OpenAPI specification: + components: + securitySchemes: + http_basic_auth: + type: http + scheme: basic + + Configure API client with HTTP basic authentication: + +conf = {{{packageName}}}.Configuration( + username='the-user', + password='the-password', +) + +{{/hasHttpBasicMethods}} +{{#hasHttpSignatureMethods}} + + HTTP Signature Authentication Example. + Given the following security scheme in the OpenAPI specification: + components: + securitySchemes: + http_basic_auth: + type: http + scheme: signature + + Configure API client with HTTP signature authentication. Use the 'hs2019' signature scheme, + sign the HTTP requests with the RSA-SSA-PSS signature algorithm, and set the expiration time + of the signature to 5 minutes after the signature has been created. + Note you can use the constants defined in the {{{packageName}}}.signing module, and you can + also specify arbitrary HTTP headers to be included in the HTTP signature, except for the + 'Authorization' header, which is used to carry the signature. + + One may be tempted to sign all headers by default, but in practice it rarely works. + This is beccause explicit proxies, transparent proxies, TLS termination endpoints or + load balancers may add/modify/remove headers. Include the HTTP headers that you know + are not going to be modified in transit. + +conf = {{{packageName}}}.Configuration( + signing_info = {{{packageName}}}.signing.HttpSigningConfiguration( + key_id = 'my-key-id', + private_key_path = 'rsa.pem', + signing_scheme = {{{packageName}}}.signing.SCHEME_HS2019, + signing_algorithm = {{{packageName}}}.signing.ALGORITHM_RSASSA_PSS, + signed_headers = [{{{packageName}}}.signing.HEADER_REQUEST_TARGET, + {{{packageName}}}.signing.HEADER_CREATED, + {{{packageName}}}.signing.HEADER_EXPIRES, + {{{packageName}}}.signing.HEADER_HOST, + {{{packageName}}}.signing.HEADER_DATE, + {{{packageName}}}.signing.HEADER_DIGEST, + 'Content-Type', + 'User-Agent' + ], + signature_max_validity = datetime.timedelta(minutes=5) + ) +) +{{/hasHttpSignatureMethods}} +{{/hasAuthMethods}} + """ + + _default = None + + def __init__(self, host=None, + api_key=None, api_key_prefix=None, + access_token=None, + username=None, password=None, + discard_unknown_keys=False, + disabled_client_side_validations="", +{{#hasHttpSignatureMethods}} + signing_info=None, +{{/hasHttpSignatureMethods}} + server_index=None, server_variables=None, + server_operation_index=None, server_operation_variables=None, + ssl_ca_cert=None, + ): + """Constructor + """ + self._base_path = "{{{basePath}}}" if host is None else host + """Default Base url + """ + self.server_index = 0 if server_index is None and host is None else server_index + self.server_operation_index = server_operation_index or {} + """Default server index + """ + self.server_variables = server_variables or {} + self.server_operation_variables = server_operation_variables or {} + """Default server variables + """ + self.temp_folder_path = None + """Temp file folder for downloading files + """ + # Authentication Settings + self.access_token = access_token + self.api_key = {} + if api_key: + self.api_key = api_key + """dict to store API key(s) + """ + self.api_key_prefix = {} + if api_key_prefix: + self.api_key_prefix = api_key_prefix + """dict to store API prefix (e.g. Bearer) + """ + self.refresh_api_key_hook = None + """function hook to refresh API key if expired + """ + self.username = username + """Username for HTTP basic authentication + """ + self.password = password + """Password for HTTP basic authentication + """ + self.discard_unknown_keys = discard_unknown_keys + self.disabled_client_side_validations = disabled_client_side_validations +{{#hasHttpSignatureMethods}} + if signing_info is not None: + signing_info.host = host + self.signing_info = signing_info + """The HTTP signing configuration + """ +{{/hasHttpSignatureMethods}} + self.logger = {} + """Logging Settings + """ + self.logger["package_logger"] = logging.getLogger("{{packageName}}") + self.logger["urllib3_logger"] = logging.getLogger("urllib3") + self.logger_format = '%(asctime)s %(levelname)s %(message)s' + """Log format + """ + self.logger_stream_handler = None + """Log stream handler + """ + self.logger_file_handler = None + """Log file handler + """ + self.logger_file = None + """Debug file location + """ + self.debug = False + """Debug switch + """ + + self.verify_ssl = True + """SSL/TLS verification + Set this to false to skip verifying SSL certificate when calling API + from https server. + """ + self.ssl_ca_cert = ssl_ca_cert + """Set this to customize the certificate file to verify the peer. + """ + self.cert_file = None + """client certificate file + """ + self.key_file = None + """client key file + """ + self.assert_hostname = None + """Set this to True/False to enable/disable SSL hostname verification. + """ + + {{#asyncio}} + self.connection_pool_maxsize = 100 + """This value is passed to the aiohttp to limit simultaneous connections. + Default values is 100, None means no-limit. + """ + {{/asyncio}} + {{^asyncio}} + self.connection_pool_maxsize = multiprocessing.cpu_count() * 5 + """urllib3 connection pool's maximum number of connections saved + per pool. urllib3 uses 1 connection as default value, but this is + not the best value when you are making a lot of possibly parallel + requests to the same host, which is often the case here. + cpu_count * 5 is used as default value to increase performance. + """ + {{/asyncio}} + + self.proxy = None + """Proxy URL + """ + self.proxy_headers = None + """Proxy headers + """ + self.safe_chars_for_path_param = '' + """Safe chars for path_param + """ + self.retries = None + """Adding retries to override urllib3 default value 3 + """ + # Enable client side validation + self.client_side_validation = True + + # Options to pass down to the underlying urllib3 socket + self.socket_options = None + + def __deepcopy__(self, memo): + cls = self.__class__ + result = cls.__new__(cls) + memo[id(self)] = result + for k, v in self.__dict__.items(): + if k not in ('logger', 'logger_file_handler'): + setattr(result, k, copy.deepcopy(v, memo)) + # shallow copy of loggers + result.logger = copy.copy(self.logger) + # use setters to configure loggers + result.logger_file = self.logger_file + result.debug = self.debug + return result + + def __setattr__(self, name, value): + object.__setattr__(self, name, value) + if name == 'disabled_client_side_validations': + s = set(filter(None, value.split(','))) + for v in s: + if v not in JSON_SCHEMA_VALIDATION_KEYWORDS: + raise PineconeApiValueError( + "Invalid keyword: '{0}''".format(v)) + self._disabled_client_side_validations = s +{{#hasHttpSignatureMethods}} + if name == "signing_info" and value is not None: + # Ensure the host paramater from signing info is the same as + # Configuration.host. + value.host = self.host +{{/hasHttpSignatureMethods}} + + @classmethod + def set_default(cls, default): + """Set default instance of configuration. + + It stores default configuration, which can be + returned by get_default_copy method. + + :param default: object of Configuration + """ + cls._default = copy.deepcopy(default) + + @classmethod + def get_default_copy(cls): + """Return new instance of configuration. + + This method returns newly created, based on default constructor, + object of Configuration class or returns a copy of default + configuration passed by the set_default method. + + :return: The configuration object. + """ + if cls._default is not None: + return copy.deepcopy(cls._default) + return Configuration() + + @property + def logger_file(self): + """The logger file. + + If the logger_file is None, then add stream handler and remove file + handler. Otherwise, add file handler and remove stream handler. + + :param value: The logger_file path. + :type: str + """ + return self.__logger_file + + @logger_file.setter + def logger_file(self, value): + """The logger file. + + If the logger_file is None, then add stream handler and remove file + handler. Otherwise, add file handler and remove stream handler. + + :param value: The logger_file path. + :type: str + """ + self.__logger_file = value + if self.__logger_file: + # If set logging file, + # then add file handler and remove stream handler. + self.logger_file_handler = logging.FileHandler(self.__logger_file) + self.logger_file_handler.setFormatter(self.logger_formatter) + for _, logger in self.logger.items(): + logger.addHandler(self.logger_file_handler) + + @property + def debug(self): + """Debug status + + :param value: The debug status, True or False. + :type: bool + """ + return self.__debug + + @debug.setter + def debug(self, value): + """Debug status + + :param value: The debug status, True or False. + :type: bool + """ + self.__debug = value + if self.__debug: + # if debug status is True, turn on debug logging + for _, logger in self.logger.items(): + logger.setLevel(logging.DEBUG) + # turn on http_client debug + http_client.HTTPConnection.debuglevel = 1 + else: + # if debug status is False, turn off debug logging, + # setting log level to default `logging.WARNING` + for _, logger in self.logger.items(): + logger.setLevel(logging.WARNING) + # turn off http_client debug + http_client.HTTPConnection.debuglevel = 0 + + @property + def logger_format(self): + """The logger format. + + The logger_formatter will be updated when sets logger_format. + + :param value: The format string. + :type: str + """ + return self.__logger_format + + @logger_format.setter + def logger_format(self, value): + """The logger format. + + The logger_formatter will be updated when sets logger_format. + + :param value: The format string. + :type: str + """ + self.__logger_format = value + self.logger_formatter = logging.Formatter(self.__logger_format) + + def get_api_key_with_prefix(self, identifier, alias=None): + """Gets API key (with prefix if set). + + :param identifier: The identifier of apiKey. + :param alias: The alternative identifier of apiKey. + :return: The token for api key authentication. + """ + if self.refresh_api_key_hook is not None: + self.refresh_api_key_hook(self) + key = self.api_key.get(identifier, self.api_key.get(alias) if alias is not None else None) + if key: + prefix = self.api_key_prefix.get(identifier) + if prefix: + return "%s %s" % (prefix, key) + else: + return key + + def get_basic_auth_token(self): + """Gets HTTP basic authentication header (string). + + :return: The token for basic HTTP authentication. + """ + username = "" + if self.username is not None: + username = self.username + password = "" + if self.password is not None: + password = self.password + return urllib3.util.make_headers( + basic_auth=username + ':' + password + ).get('authorization') + + def auth_settings(self): + """Gets Auth Settings dict for api client. + + :return: The Auth Settings information dict. + """ + auth = {} +{{#authMethods}} +{{#isApiKey}} + if '{{name}}' in self.api_key{{#vendorExtensions.x-auth-id-alias}} or '{{.}}' in self.api_key{{/vendorExtensions.x-auth-id-alias}}: + auth['{{name}}'] = { + 'type': 'api_key', + 'in': {{#isKeyInCookie}}'cookie'{{/isKeyInCookie}}{{#isKeyInHeader}}'header'{{/isKeyInHeader}}{{#isKeyInQuery}}'query'{{/isKeyInQuery}}, + 'key': '{{keyParamName}}', + 'value': self.get_api_key_with_prefix( + '{{name}}',{{#vendorExtensions.x-auth-id-alias}} + alias='{{.}}',{{/vendorExtensions.x-auth-id-alias}} + ), + } +{{/isApiKey}} +{{#isBasic}} + {{#isBasicBasic}} + if self.username is not None and self.password is not None: + auth['{{name}}'] = { + 'type': 'basic', + 'in': 'header', + 'key': 'Authorization', + 'value': self.get_basic_auth_token() + } + {{/isBasicBasic}} + {{#isBasicBearer}} + if self.access_token is not None: + auth['{{name}}'] = { + 'type': 'bearer', + 'in': 'header', + {{#bearerFormat}} + 'format': '{{{.}}}', + {{/bearerFormat}} + 'key': 'Authorization', + 'value': 'Bearer ' + self.access_token + } + {{/isBasicBearer}} + {{#isHttpSignature}} + if self.signing_info is not None: + auth['{{name}}'] = { + 'type': 'http-signature', + 'in': 'header', + 'key': 'Authorization', + 'value': None # Signature headers are calculated for every HTTP request + } + {{/isHttpSignature}} +{{/isBasic}} +{{#isOAuth}} + if self.access_token is not None: + auth['{{name}}'] = { + 'type': 'oauth2', + 'in': 'header', + 'key': 'Authorization', + 'value': 'Bearer ' + self.access_token + } +{{/isOAuth}} +{{/authMethods}} + return auth + + def to_debug_report(self): + """Gets the essential information for debugging. + + :return: The report for debugging. + """ + return "Python SDK Debug Report:\n"\ + "OS: {env}\n"\ + "Python Version: {pyversion}\n"\ + "Version of the API: {{version}}\n"\ + "SDK Package Version: {{packageVersion}}".\ + format(env=sys.platform, pyversion=sys.version) + + def get_host_settings(self): + """Gets an array of host settings + + :return: An array of host settings + """ + return [ + {{#servers}} + { + 'url': "{{{url}}}", + 'description': "{{{description}}}{{^description}}No description provided{{/description}}", + {{#variables}} + {{#-first}} + 'variables': { + {{/-first}} + '{{{name}}}': { + 'description': "{{{description}}}{{^description}}No description provided{{/description}}", + 'default_value': "{{{defaultValue}}}", + {{#enumValues}} + {{#-first}} + 'enum_values': [ + {{/-first}} + "{{{.}}}"{{^-last}},{{/-last}} + {{#-last}} + ] + {{/-last}} + {{/enumValues}} + }{{^-last}},{{/-last}} + {{#-last}} + } + {{/-last}} + {{/variables}} + }{{^-last}},{{/-last}} + {{/servers}} + ] + + def get_host_from_settings(self, index, variables=None, servers=None): + """Gets host URL based on the index and variables + :param index: array index of the host settings + :param variables: hash of variable and the corresponding value + :param servers: an array of host settings or None + :return: URL based on host settings + """ + if index is None: + return self._base_path + + variables = {} if variables is None else variables + servers = self.get_host_settings() if servers is None else servers + + try: + server = servers[index] + except IndexError: + raise ValueError( + "Invalid index {0} when selecting the host settings. " + "Must be less than {1}".format(index, len(servers))) + + url = server['url'] + + # go through variables and replace placeholders + for variable_name, variable in server.get('variables', {}).items(): + used_value = variables.get( + variable_name, variable['default_value']) + + if 'enum_values' in variable \ + and used_value not in variable['enum_values']: + raise ValueError( + "The variable `{0}` in the host URL has invalid value " + "{1}. Must be {2}.".format( + variable_name, variables[variable_name], + variable['enum_values'])) + + url = url.replace("{" + variable_name + "}", used_value) + + return url + + @property + def host(self): + """Return generated host.""" + return self.get_host_from_settings(self.server_index, variables=self.server_variables) + + @host.setter + def host(self, value): + """Fix base path.""" + self._base_path = value + self.server_index = None diff --git a/codegen/openapi/templates5.2.0/exceptions.mustache b/codegen/openapi/templates5.2.0/exceptions.mustache new file mode 100644 index 000000000..5235fd00a --- /dev/null +++ b/codegen/openapi/templates5.2.0/exceptions.mustache @@ -0,0 +1,151 @@ +{{>partial_header}} + + +class PineconeException(Exception): + """The base exception class for all exceptions in the Pinecone Python SDK""" + + +class PineconeApiTypeError(PineconeException, TypeError): + def __init__(self, msg, path_to_item=None, valid_classes=None, + key_type=None): + """ Raises an exception for TypeErrors + + Args: + msg (str): the exception message + + Keyword Args: + path_to_item (list): a list of keys an indices to get to the + current_item + None if unset + valid_classes (tuple): the primitive classes that current item + should be an instance of + None if unset + key_type (bool): False if our value is a value in a dict + True if it is a key in a dict + False if our item is an item in a list + None if unset + """ + self.path_to_item = path_to_item + self.valid_classes = valid_classes + self.key_type = key_type + full_msg = msg + if path_to_item: + full_msg = "{0} at {1}".format(msg, render_path(path_to_item)) + super(PineconeApiTypeError, self).__init__(full_msg) + + +class PineconeApiValueError(PineconeException, ValueError): + def __init__(self, msg, path_to_item=None): + """ + Args: + msg (str): the exception message + + Keyword Args: + path_to_item (list) the path to the exception in the + received_data dict. None if unset + """ + + self.path_to_item = path_to_item + full_msg = msg + if path_to_item: + full_msg = "{0} at {1}".format(msg, render_path(path_to_item)) + super(PineconeApiValueError, self).__init__(full_msg) + + +class PineconeApiAttributeError(PineconeException, AttributeError): + def __init__(self, msg, path_to_item=None): + """ + Raised when an attribute reference or assignment fails. + + Args: + msg (str): the exception message + + Keyword Args: + path_to_item (None/list) the path to the exception in the + received_data dict + """ + self.path_to_item = path_to_item + full_msg = msg + if path_to_item: + full_msg = "{0} at {1}".format(msg, render_path(path_to_item)) + super(PineconeApiAttributeError, self).__init__(full_msg) + + +class PineconeApiKeyError(PineconeException, KeyError): + def __init__(self, msg, path_to_item=None): + """ + Args: + msg (str): the exception message + + Keyword Args: + path_to_item (None/list) the path to the exception in the + received_data dict + """ + self.path_to_item = path_to_item + full_msg = msg + if path_to_item: + full_msg = "{0} at {1}".format(msg, render_path(path_to_item)) + super(PineconeApiKeyError, self).__init__(full_msg) + + +class PineconeApiException(PineconeException): + + def __init__(self, status=None, reason=None, http_resp=None): + if http_resp: + self.status = http_resp.status + self.reason = http_resp.reason + self.body = http_resp.data + self.headers = http_resp.getheaders() + else: + self.status = status + self.reason = reason + self.body = None + self.headers = None + + def __str__(self): + """Custom error messages for exception""" + error_message = "({0})\n"\ + "Reason: {1}\n".format(self.status, self.reason) + if self.headers: + error_message += "HTTP response headers: {0}\n".format( + self.headers) + + if self.body: + error_message += "HTTP response body: {0}\n".format(self.body) + + return error_message + + +class NotFoundException(PineconeApiException): + + def __init__(self, status=None, reason=None, http_resp=None): + super(NotFoundException, self).__init__(status, reason, http_resp) + + +class UnauthorizedException(PineconeApiException): + + def __init__(self, status=None, reason=None, http_resp=None): + super(UnauthorizedException, self).__init__(status, reason, http_resp) + + +class ForbiddenException(PineconeApiException): + + def __init__(self, status=None, reason=None, http_resp=None): + super(ForbiddenException, self).__init__(status, reason, http_resp) + + +class ServiceException(PineconeApiException): + + def __init__(self, status=None, reason=None, http_resp=None): + super(ServiceException, self).__init__(status, reason, http_resp) + + +def render_path(path_to_item): + """Returns a string representation of a path""" + result = "" + for pth in path_to_item: + if isinstance(pth, int): + result += "[{0}]".format(pth) + else: + result += "['{0}']".format(pth) + return result diff --git a/codegen/openapi/templates5.2.0/git_push.sh.mustache b/codegen/openapi/templates5.2.0/git_push.sh.mustache new file mode 100644 index 000000000..8b3f689c9 --- /dev/null +++ b/codegen/openapi/templates5.2.0/git_push.sh.mustache @@ -0,0 +1,58 @@ +#!/bin/sh +# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ +# +# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update" "gitlab.com" + +git_user_id=$1 +git_repo_id=$2 +release_note=$3 +git_host=$4 + +if [ "$git_host" = "" ]; then + git_host="{{{gitHost}}}" + echo "[INFO] No command line input provided. Set \$git_host to $git_host" +fi + +if [ "$git_user_id" = "" ]; then + git_user_id="{{{gitUserId}}}" + echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" +fi + +if [ "$git_repo_id" = "" ]; then + git_repo_id="{{{gitRepoId}}}" + echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" +fi + +if [ "$release_note" = "" ]; then + release_note="{{{releaseNote}}}" + echo "[INFO] No command line input provided. Set \$release_note to $release_note" +fi + +# Initialize the local directory as a Git repository +git init + +# Adds the files in the local repository and stages them for commit. +git add . + +# Commits the tracked changes and prepares them to be pushed to a remote repository. +git commit -m "$release_note" + +# Sets the new remote +git_remote=`git remote` +if [ "$git_remote" = "" ]; then # git remote not defined + + if [ "$GIT_TOKEN" = "" ]; then + echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment." + git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git + else + git remote add origin https://${git_user_id}:${GIT_TOKEN}@${git_host}/${git_user_id}/${git_repo_id}.git + fi + +fi + +git pull origin master + +# Pushes (Forces) the changes in the local repository up to the remote repository +echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git" +git push origin master 2>&1 | grep -v 'To https' + diff --git a/codegen/openapi/templates5.2.0/gitignore.mustache b/codegen/openapi/templates5.2.0/gitignore.mustache new file mode 100644 index 000000000..43995bd42 --- /dev/null +++ b/codegen/openapi/templates5.2.0/gitignore.mustache @@ -0,0 +1,66 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +env/ +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +*.egg-info/ +.installed.cfg +*.egg + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*,cover +.hypothesis/ +venv/ +.venv/ +.python-version +.pytest_cache + +# Translations +*.mo +*.pot + +# Django stuff: +*.log + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +#Ipython Notebook +.ipynb_checkpoints diff --git a/codegen/openapi/templates5.2.0/gitlab-ci.mustache b/codegen/openapi/templates5.2.0/gitlab-ci.mustache new file mode 100644 index 000000000..cf785a80a --- /dev/null +++ b/codegen/openapi/templates5.2.0/gitlab-ci.mustache @@ -0,0 +1,29 @@ +# ref: https://docs.gitlab.com/ee/ci/README.html + +stages: + - test + +.tests: + stage: test + script: + - pip install -r requirements.txt + - pip install -r test-requirements.txt + {{#useNose}} + - nosetests + {{/useNose}} + {{^useNose}} + - pytest --cov={{{packageName}}} + {{/useNose}} + +test-3.6: + extends: .tests + image: python:3.6-alpine +test-3.7: + extends: .tests + image: python:3.7-alpine +test-3.8: + extends: .tests + image: python:3.8-alpine +test-3.9: + extends: .tests + image: python:3.9-alpine diff --git a/codegen/openapi/templates5.2.0/model.mustache b/codegen/openapi/templates5.2.0/model.mustache new file mode 100644 index 000000000..e96adf5cf --- /dev/null +++ b/codegen/openapi/templates5.2.0/model.mustache @@ -0,0 +1,58 @@ +{{> partial_header }} + +import re # noqa: F401 +import sys # noqa: F401 + +from {{packageName}}.model_utils import ( # noqa: F401 + PineconeApiTypeError, + 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 {{packageName}}.exceptions import PineconeApiAttributeError + +{{#models}} +{{#model}} +{{#imports}} +{{#-first}} + +def lazy_import(): +{{/-first}} + {{{.}}} +{{/imports}} + + +{{^interfaces}} +{{#isArray}} +{{> model_templates/model_simple }} +{{/isArray}} +{{#isEnum}} +{{> model_templates/model_simple }} +{{/isEnum}} +{{#isAlias}} +{{> model_templates/model_simple }} +{{/isAlias}} +{{^isArray}} +{{^isEnum}} +{{^isAlias}} +{{> model_templates/model_normal }} +{{/isAlias}} +{{/isEnum}} +{{/isArray}} +{{/interfaces}} +{{#interfaces}} +{{#-last}} +{{> model_templates/model_composed }} +{{/-last}} +{{/interfaces}} +{{/model}} +{{/models}} diff --git a/codegen/openapi/templates5.2.0/model_doc.mustache b/codegen/openapi/templates5.2.0/model_doc.mustache new file mode 100644 index 000000000..3f7c8263d --- /dev/null +++ b/codegen/openapi/templates5.2.0/model_doc.mustache @@ -0,0 +1,37 @@ +{{#models}}{{#model}}# {{classname}} + +{{#description}}{{&description}} +{{/description}} + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +{{#isEnum}} +**value** | {{^arrayModelType}}**{{dataType}}**{{/arrayModelType}} | {{description}} | {{#defaultValue}}{{#hasRequired}} if omitted the server will use the default value of {{/hasRequired}}{{^hasRequired}}defaults to {{/hasRequired}}{{{.}}}{{/defaultValue}}{{#allowableValues}}{{#defaultValue}}, {{/defaultValue}} must be one of [{{#enumVars}}{{{value}}}, {{/enumVars}}]{{/allowableValues}} +{{/isEnum}} +{{#isAlias}} +**value** | {{^arrayModelType}}**{{dataType}}**{{/arrayModelType}} | {{description}} | {{#defaultValue}}{{#hasRequired}} if omitted the server will use the default value of {{/hasRequired}}{{^hasRequired}}defaults to {{/hasRequired}}{{{.}}}{{/defaultValue}} +{{/isAlias}} +{{#isArray}} +**value** | {{^arrayModelType}}**{{dataType}}**{{/arrayModelType}}{{#arrayModelType}}[**{{dataType}}**]({{arrayModelType}}.md){{/arrayModelType}} | {{description}} | {{#defaultValue}}{{#hasRequired}} if omitted the server will use the default value of {{/hasRequired}}{{^hasRequired}}defaults to {{/hasRequired}}{{{.}}}{{/defaultValue}} +{{/isArray}} +{{#requiredVars}} +{{^defaultValue}} +**{{name}}** | {{^complexType}}**{{dataType}}**{{/complexType}}{{#complexType}}[**{{dataType}}**]({{complexType}}.md){{/complexType}} | {{description}} | {{#isReadOnly}}[readonly] {{/isReadOnly}} +{{/defaultValue}} +{{/requiredVars}} +{{#requiredVars}} +{{#defaultValue}} +**{{name}}** | {{^complexType}}**{{dataType}}**{{/complexType}}{{#complexType}}[**{{dataType}}**]({{complexType}}.md){{/complexType}} | {{description}} | {{^required}}[optional] {{/required}}{{#isReadOnly}}[readonly] {{/isReadOnly}}{{#defaultValue}}defaults to {{{.}}}{{/defaultValue}} +{{/defaultValue}} +{{/requiredVars}} +{{#optionalVars}} +**{{name}}** | {{^complexType}}**{{dataType}}**{{/complexType}}{{#complexType}}[**{{dataType}}**]({{complexType}}.md){{/complexType}} | {{description}} | [optional] {{#isReadOnly}}[readonly] {{/isReadOnly}}{{#defaultValue}} if omitted the server will use the default value of {{{.}}}{{/defaultValue}} +{{/optionalVars}} +{{#additionalProperties}} +**any string name** | {{^complexType}}**{{dataType}}**{{/complexType}}{{#complexType}}[**{{dataType}}**]({{complexType}}.md){{/complexType}} | any string name can be used but the value must be the correct type | [optional] +{{/additionalProperties}} + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + +{{/model}}{{/models}} diff --git a/codegen/openapi/templates5.2.0/model_templates/classvars.mustache b/codegen/openapi/templates5.2.0/model_templates/classvars.mustache new file mode 100644 index 000000000..0e5ff25b9 --- /dev/null +++ b/codegen/openapi/templates5.2.0/model_templates/classvars.mustache @@ -0,0 +1,138 @@ + allowed_values = { +{{#isEnum}} + ('value',): { +{{#isNullable}} + 'None': None, +{{/isNullable}} +{{#allowableValues}} +{{#enumVars}} + '{{name}}': {{{value}}}, +{{/enumVars}} +{{/allowableValues}} + }, +{{/isEnum}} +{{#requiredVars}} +{{#isEnum}} + ('{{name}}',): { +{{#isNullable}} + 'None': None, +{{/isNullable}} +{{#allowableValues}} +{{#enumVars}} + '{{name}}': {{{value}}}, +{{/enumVars}} +{{/allowableValues}} + }, +{{/isEnum}} +{{/requiredVars}} +{{#optionalVars}} +{{#isEnum}} + ('{{name}}',): { +{{#isNullable}} + 'None': None, +{{/isNullable}} +{{#allowableValues}} +{{#enumVars}} + '{{name}}': {{{value}}}, +{{/enumVars}} +{{/allowableValues}} + }, +{{/isEnum}} +{{/optionalVars}} + } + + validations = { +{{#hasValidation}} + ('value',): { +{{> model_templates/validations }} +{{/hasValidation}} +{{#requiredVars}} +{{#hasValidation}} + ('{{name}}',): { +{{> model_templates/validations }} +{{/hasValidation}} +{{/requiredVars}} +{{#optionalVars}} +{{#hasValidation}} + ('{{name}}',): { +{{> model_templates/validations }} +{{/hasValidation}} +{{/optionalVars}} + } + +{{#additionalProperties}} + @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 + """ +{{#imports}} +{{#-first}} + lazy_import() +{{/-first}} +{{/imports}} + return ({{{dataType}}},) # noqa: E501 +{{/additionalProperties}} +{{^additionalProperties}} + additional_properties_type = None +{{/additionalProperties}} + + _nullable = {{#isNullable}}True{{/isNullable}}{{^isNullable}}False{{/isNullable}} + + @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. + """ +{{#imports}} +{{#-first}} + lazy_import() +{{/-first}} +{{/imports}} + return { +{{#isAlias}} + 'value': ({{{dataType}}},), +{{/isAlias}} +{{#isEnum}} + 'value': ({{{dataType}}},), +{{/isEnum}} +{{#isArray}} + 'value': ({{{dataType}}},), +{{/isArray}} +{{#requiredVars}} + '{{name}}': ({{{dataType}}},), # noqa: E501 +{{/requiredVars}} +{{#optionalVars}} + '{{name}}': ({{{dataType}}},), # noqa: E501 +{{/optionalVars}} + } + + @cached_property + def discriminator(): +{{^discriminator}} + return None +{{/discriminator}} +{{#discriminator}} +{{#mappedModels}} +{{#-first}} +{{#imports}} +{{#-first}} + lazy_import() +{{/-first}} +{{/imports}} +{{/-first}} +{{/mappedModels}} + val = { +{{#mappedModels}} + '{{mappingName}}': {{{modelName}}}, +{{/mappedModels}} + } + if not val: + return None + return {'{{{discriminatorName}}}': val}{{/discriminator}} \ No newline at end of file diff --git a/codegen/openapi/templates5.2.0/model_templates/docstring_allowed.mustache b/codegen/openapi/templates5.2.0/model_templates/docstring_allowed.mustache new file mode 100644 index 000000000..ab20932b2 --- /dev/null +++ b/codegen/openapi/templates5.2.0/model_templates/docstring_allowed.mustache @@ -0,0 +1,4 @@ + 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. \ No newline at end of file diff --git a/codegen/openapi/templates5.2.0/model_templates/docstring_init_required_kwargs.mustache b/codegen/openapi/templates5.2.0/model_templates/docstring_init_required_kwargs.mustache new file mode 100644 index 000000000..b09f3950b --- /dev/null +++ b/codegen/openapi/templates5.2.0/model_templates/docstring_init_required_kwargs.mustache @@ -0,0 +1,30 @@ + _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,) \ No newline at end of file diff --git a/codegen/openapi/templates5.2.0/model_templates/docstring_openapi_validations.mustache b/codegen/openapi/templates5.2.0/model_templates/docstring_openapi_validations.mustache new file mode 100644 index 000000000..f933b86c5 --- /dev/null +++ b/codegen/openapi/templates5.2.0/model_templates/docstring_openapi_validations.mustache @@ -0,0 +1,7 @@ + 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. \ No newline at end of file diff --git a/codegen/openapi/templates5.2.0/model_templates/invalid_pos_args.mustache b/codegen/openapi/templates5.2.0/model_templates/invalid_pos_args.mustache new file mode 100644 index 000000000..9815d81fd --- /dev/null +++ b/codegen/openapi/templates5.2.0/model_templates/invalid_pos_args.mustache @@ -0,0 +1,9 @@ + if args: + raise PineconeApiTypeError( + "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__,), + ) \ No newline at end of file diff --git a/codegen/openapi/templates5.2.0/model_templates/method_from_openapi_data_composed.mustache b/codegen/openapi/templates5.2.0/model_templates/method_from_openapi_data_composed.mustache new file mode 100644 index 000000000..81a4af3f8 --- /dev/null +++ b/codegen/openapi/templates5.2.0/model_templates/method_from_openapi_data_composed.mustache @@ -0,0 +1,66 @@ + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 + """{{classname}} - a model defined in OpenAPI + + Keyword Args: +{{#requiredVars}} +{{#defaultValue}} + {{name}} ({{{dataType}}}):{{#description}} {{{description}}}.{{/description}} defaults to {{{defaultValue}}}{{#allowableValues}}, must be one of [{{#enumVars}}{{{value}}}, {{/enumVars}}]{{/allowableValues}} # noqa: E501 +{{/defaultValue}} +{{^defaultValue}} + {{name}} ({{{dataType}}}):{{#description}} {{{description}}}{{/description}} +{{/defaultValue}} +{{/requiredVars}} +{{> model_templates/docstring_init_required_kwargs }} +{{#optionalVars}} + {{name}} ({{{dataType}}}):{{#description}} {{{description}}}.{{/description}} [optional]{{#defaultValue}} if omitted the server will use the default value of {{{defaultValue}}}{{/defaultValue}} # noqa: E501 +{{/optionalVars}} + """ + +{{#requiredVars}} +{{#defaultValue}} + {{name}} = kwargs.get('{{name}}', {{{defaultValue}}}) +{{/defaultValue}} +{{/requiredVars}} + _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) + +{{> model_templates/invalid_pos_args }} + + 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__,) + + constant_args = { + '_check_type': _check_type, + '_path_to_item': _path_to_item, + '_spec_property_naming': _spec_property_naming, + '_configuration': _configuration, + '_visited_composed_classes': self._visited_composed_classes, + } + composed_info = validate_get_composed_info( + constant_args, kwargs, self) + self._composed_instances = composed_info[0] + self._var_name_to_model_instances = composed_info[1] + self._additional_properties_model_instances = composed_info[2] + discarded_args = composed_info[3] + + for var_name, var_value in kwargs.items(): + if var_name in discarded_args and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self._additional_properties_model_instances: + # discard variable. + continue + setattr(self, var_name, var_value) + + return self \ No newline at end of file diff --git a/codegen/openapi/templates5.2.0/model_templates/method_from_openapi_data_normal.mustache b/codegen/openapi/templates5.2.0/model_templates/method_from_openapi_data_normal.mustache new file mode 100644 index 000000000..3b82ba7fc --- /dev/null +++ b/codegen/openapi/templates5.2.0/model_templates/method_from_openapi_data_normal.mustache @@ -0,0 +1,17 @@ +{{> model_templates/method_from_openapi_data_shared }} + +{{#isEnum}} + self.value = value +{{/isEnum}} +{{#requiredVars}} + self.{{name}} = {{name}} +{{/requiredVars}} + 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 \ No newline at end of file diff --git a/codegen/openapi/templates5.2.0/model_templates/method_from_openapi_data_shared.mustache b/codegen/openapi/templates5.2.0/model_templates/method_from_openapi_data_shared.mustache new file mode 100644 index 000000000..9dd84236b --- /dev/null +++ b/codegen/openapi/templates5.2.0/model_templates/method_from_openapi_data_shared.mustache @@ -0,0 +1,49 @@ + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls{{#requiredVars}}{{^defaultValue}}, {{name}}{{/defaultValue}}{{/requiredVars}}, *args, **kwargs): # noqa: E501 + """{{classname}} - a model defined in OpenAPI + +{{#requiredVars}} +{{#-first}} + Args: +{{/-first}} +{{^defaultValue}} + {{name}} ({{{dataType}}}):{{#description}} {{{description}}}{{/description}} +{{/defaultValue}} +{{#-last}} + +{{/-last}} +{{/requiredVars}} + Keyword Args: +{{#requiredVars}} +{{#defaultValue}} + {{name}} ({{{dataType}}}):{{#description}} {{{description}}}.{{/description}} defaults to {{{defaultValue}}}{{#allowableValues}}, must be one of [{{#enumVars}}{{{value}}}, {{/enumVars}}]{{/allowableValues}} # noqa: E501 +{{/defaultValue}} +{{/requiredVars}} +{{> model_templates/docstring_init_required_kwargs }} +{{#optionalVars}} + {{name}} ({{{dataType}}}):{{#description}} {{{description}}}.{{/description}} [optional]{{#defaultValue}} if omitted the server will use the default value of {{{defaultValue}}}{{/defaultValue}} # noqa: E501 +{{/optionalVars}} + """ + +{{#requiredVars}} +{{#defaultValue}} + {{name}} = kwargs.get('{{name}}', {{{defaultValue}}}) +{{/defaultValue}} +{{/requiredVars}} + _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) + +{{> model_templates/invalid_pos_args }} + + 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__,) \ No newline at end of file diff --git a/codegen/openapi/templates5.2.0/model_templates/method_from_openapi_data_simple.mustache b/codegen/openapi/templates5.2.0/model_templates/method_from_openapi_data_simple.mustache new file mode 100644 index 000000000..a34927573 --- /dev/null +++ b/codegen/openapi/templates5.2.0/model_templates/method_from_openapi_data_simple.mustache @@ -0,0 +1,62 @@ + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, *args, **kwargs): + """{{classname}} - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] ({{{dataType}}}):{{#description}} {{{description}}}.{{/description}}{{#defaultValue}} if omitted defaults to {{{defaultValue}}}{{/defaultValue}}{{#allowableValues}}, must be one of [{{#enumVars}}{{{value}}}, {{/enumVars}}]{{/allowableValues}} # noqa: E501 + + Keyword Args: + value ({{{dataType}}}):{{#description}} {{{description}}}.{{/description}}{{#defaultValue}} if omitted defaults to {{{defaultValue}}}{{/defaultValue}}{{#allowableValues}}, must be one of [{{#enumVars}}{{{value}}}, {{/enumVars}}]{{/allowableValues}} # noqa: E501 +{{> model_templates/docstring_init_required_kwargs }} + """ + # required up here when default value is not given + _path_to_item = kwargs.pop('_path_to_item', ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if 'value' in kwargs: + value = kwargs.pop('value') + elif args: + args = list(args) + value = args.pop(0) +{{#defaultValue}} + else: + value = {{{defaultValue}}} +{{/defaultValue}} +{{^defaultValue}} + else: + raise PineconeApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) +{{/defaultValue}} + + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + +{{> model_templates/invalid_pos_args }} + + 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.value = value + if kwargs: + raise PineconeApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + return self \ No newline at end of file diff --git a/codegen/openapi/templates5.2.0/model_templates/method_init_composed.mustache b/codegen/openapi/templates5.2.0/model_templates/method_init_composed.mustache new file mode 100644 index 000000000..efdfb55d9 --- /dev/null +++ b/codegen/openapi/templates5.2.0/model_templates/method_init_composed.mustache @@ -0,0 +1,80 @@ + required_properties = set([ + '_data_store', + '_check_type', + '_spec_property_naming', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + '_composed_instances', + '_var_name_to_model_instances', + '_additional_properties_model_instances', + ]) + + @convert_js_args_to_python_args + def __init__(self, *args, **kwargs): # noqa: E501 + """{{classname}} - a model defined in OpenAPI + + Keyword Args: +{{#requiredVars}} +{{^isReadOnly}} +{{#defaultValue}} + {{name}} ({{{dataType}}}):{{#description}} {{{description}}}.{{/description}} defaults to {{{defaultValue}}}{{#allowableValues}}, must be one of [{{#enumVars}}{{{value}}}, {{/enumVars}}]{{/allowableValues}} # noqa: E501 +{{/defaultValue}} +{{^defaultValue}} + {{name}} ({{{dataType}}}):{{#description}} {{{description}}}{{/description}} +{{/defaultValue}} +{{/isReadOnly}} +{{/requiredVars}} +{{> model_templates/docstring_init_required_kwargs }} +{{#optionalVars}} + {{name}} ({{{dataType}}}):{{#description}} {{{description}}}.{{/description}} [optional]{{#defaultValue}} if omitted the server will use the default value of {{{defaultValue}}}{{/defaultValue}} # noqa: E501 +{{/optionalVars}} + """ + +{{#requiredVars}} +{{^isReadOnly}} +{{#defaultValue}} + {{name}} = kwargs.get('{{name}}', {{{defaultValue}}}) +{{/defaultValue}} +{{/isReadOnly}} +{{/requiredVars}} + _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', ()) + +{{> model_templates/invalid_pos_args }} + + 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__,) + + constant_args = { + '_check_type': _check_type, + '_path_to_item': _path_to_item, + '_spec_property_naming': _spec_property_naming, + '_configuration': _configuration, + '_visited_composed_classes': self._visited_composed_classes, + } + composed_info = validate_get_composed_info( + constant_args, kwargs, self) + self._composed_instances = composed_info[0] + self._var_name_to_model_instances = composed_info[1] + self._additional_properties_model_instances = composed_info[2] + discarded_args = composed_info[3] + + for var_name, var_value in kwargs.items(): + if var_name in discarded_args and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self._additional_properties_model_instances: + # discard variable. + continue + setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise PineconeApiAttributeError(f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes.") \ No newline at end of file diff --git a/codegen/openapi/templates5.2.0/model_templates/method_init_normal.mustache b/codegen/openapi/templates5.2.0/model_templates/method_init_normal.mustache new file mode 100644 index 000000000..1211cafc9 --- /dev/null +++ b/codegen/openapi/templates5.2.0/model_templates/method_init_normal.mustache @@ -0,0 +1,30 @@ + required_properties = set([ + '_data_store', + '_check_type', + '_spec_property_naming', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + ]) + +{{> model_templates/method_init_shared }} + +{{#isEnum}} + self.value = value +{{/isEnum}} +{{#requiredVars}} +{{^isReadOnly}} + self.{{name}} = {{name}} +{{/isReadOnly}} +{{/requiredVars}} + 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 PineconeApiAttributeError(f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes.") \ No newline at end of file diff --git a/codegen/openapi/templates5.2.0/model_templates/method_init_shared.mustache b/codegen/openapi/templates5.2.0/model_templates/method_init_shared.mustache new file mode 100644 index 000000000..0eb4de6a1 --- /dev/null +++ b/codegen/openapi/templates5.2.0/model_templates/method_init_shared.mustache @@ -0,0 +1,52 @@ + @convert_js_args_to_python_args + def __init__(self{{#requiredVars}}{{^isReadOnly}}{{^defaultValue}}, {{name}}{{/defaultValue}}{{/isReadOnly}}{{/requiredVars}}, *args, **kwargs): # noqa: E501 + """{{classname}} - a model defined in OpenAPI + +{{#requiredVars}} +{{^isReadOnly}} +{{#-first}} + Args: +{{/-first}} +{{^defaultValue}} + {{name}} ({{{dataType}}}):{{#description}} {{{description}}}{{/description}} +{{/defaultValue}} +{{#-last}} + +{{/-last}} +{{/isReadOnly}} +{{/requiredVars}} + Keyword Args: +{{#requiredVars}} +{{^isReadOnly}} +{{#defaultValue}} + {{name}} ({{{dataType}}}):{{#description}} {{{description}}}.{{/description}} defaults to {{{defaultValue}}}{{#allowableValues}}, must be one of [{{#enumVars}}{{{value}}}, {{/enumVars}}]{{/allowableValues}} # noqa: E501 +{{/defaultValue}} +{{/isReadOnly}} +{{/requiredVars}} +{{> model_templates/docstring_init_required_kwargs }} +{{#optionalVars}} + {{name}} ({{{dataType}}}):{{#description}} {{{description}}}.{{/description}} [optional]{{#defaultValue}} if omitted the server will use the default value of {{{defaultValue}}}{{/defaultValue}} # noqa: E501 +{{/optionalVars}} + """ + +{{#requiredVars}} +{{^isReadOnly}} +{{#defaultValue}} + {{name}} = kwargs.get('{{name}}', {{{defaultValue}}}) +{{/defaultValue}} +{{/isReadOnly}} +{{/requiredVars}} + _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', ()) + +{{> model_templates/invalid_pos_args }} + + 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__,) \ No newline at end of file diff --git a/codegen/openapi/templates5.2.0/model_templates/method_init_simple.mustache b/codegen/openapi/templates5.2.0/model_templates/method_init_simple.mustache new file mode 100644 index 000000000..f28b0c423 --- /dev/null +++ b/codegen/openapi/templates5.2.0/model_templates/method_init_simple.mustache @@ -0,0 +1,66 @@ + 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): + """{{classname}} - a model defined in OpenAPI + + Note that value can be passed either in args or in kwargs, but not in both. + + Args: + args[0] ({{{dataType}}}):{{#description}} {{{description}}}.{{/description}}{{#defaultValue}} if omitted defaults to {{{defaultValue}}}{{/defaultValue}}{{#allowableValues}}, must be one of [{{#enumVars}}{{{value}}}, {{/enumVars}}]{{/allowableValues}} # noqa: E501 + + Keyword Args: + value ({{{dataType}}}):{{#description}} {{{description}}}.{{/description}}{{#defaultValue}} if omitted defaults to {{{defaultValue}}}{{/defaultValue}}{{#allowableValues}}, must be one of [{{#enumVars}}{{{value}}}, {{/enumVars}}]{{/allowableValues}} # noqa: E501 +{{> model_templates/docstring_init_required_kwargs }} + """ + # required up here when default value is not given + _path_to_item = kwargs.pop('_path_to_item', ()) + + if 'value' in kwargs: + value = kwargs.pop('value') + elif args: + args = list(args) + value = args.pop(0) +{{#defaultValue}} + else: + value = {{{defaultValue}}} +{{/defaultValue}} +{{^defaultValue}} + else: + raise PineconeApiTypeError( + "value is required, but not passed in args or kwargs and doesn't have default", + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) +{{/defaultValue}} + + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + +{{> model_templates/invalid_pos_args }} + + 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.value = value + if kwargs: + raise PineconeApiTypeError( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." % ( + kwargs, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) \ No newline at end of file diff --git a/codegen/openapi/templates5.2.0/model_templates/method_set_attribute.mustache b/codegen/openapi/templates5.2.0/model_templates/method_set_attribute.mustache new file mode 100644 index 000000000..e8b67bd09 --- /dev/null +++ b/codegen/openapi/templates5.2.0/model_templates/method_set_attribute.mustache @@ -0,0 +1,51 @@ + def set_attribute(self, name, value): + # this is only used to set properties on self + + path_to_item = [] + if self._path_to_item: + path_to_item.extend(self._path_to_item) + path_to_item.append(name) + + if name in self.openapi_types: + required_types_mixed = self.openapi_types[name] + elif self.additional_properties_type is None: + raise PineconeApiAttributeError( + "{0} has no attribute '{1}'".format( + type(self).__name__, name), + path_to_item + ) + elif self.additional_properties_type is not None: + required_types_mixed = self.additional_properties_type + + if get_simple_class(name) != str: + error_msg = type_error_message( + var_name=name, + var_value=name, + valid_classes=(str,), + key_type=True + ) + raise PineconeApiTypeError( + error_msg, + path_to_item=path_to_item, + valid_classes=(str,), + key_type=True + ) + + if self._check_type: + value = validate_and_convert_types( + value, required_types_mixed, path_to_item, self._spec_property_naming, + self._check_type, configuration=self._configuration) + if (name,) in self.allowed_values: + check_allowed_values( + self.allowed_values, + (name,), + value + ) + if (name,) in self.validations: + check_validations( + self.validations, + (name,), + value, + self._configuration + ) + self.__dict__['_data_store'][name] = value \ No newline at end of file diff --git a/codegen/openapi/templates5.2.0/model_templates/methods_setattr_getattr_composed.mustache b/codegen/openapi/templates5.2.0/model_templates/methods_setattr_getattr_composed.mustache new file mode 100644 index 000000000..488b82200 --- /dev/null +++ b/codegen/openapi/templates5.2.0/model_templates/methods_setattr_getattr_composed.mustache @@ -0,0 +1,103 @@ + def __setitem__(self, name, value): + """set the value of an attribute using square-bracket notation: `instance[attr] = val`""" + if name in self.required_properties: + self.__dict__[name] = value + return + + """ + Use cases: + 1. additional_properties_type is None (additionalProperties == False in spec) + Check for property presence in self.openapi_types + if not present then throw an error + if present set in self, set attribute + always set on composed schemas + 2. additional_properties_type exists + set attribute on self + always set on composed schemas + """ + if self.additional_properties_type is None: + """ + For an attribute to exist on a composed schema it must: + - fulfill schema_requirements in the self composed schema not considering oneOf/anyOf/allOf schemas AND + - fulfill schema_requirements in each oneOf/anyOf/allOf schemas + + schema_requirements: + For an attribute to exist on a schema it must: + - be present in properties at the schema OR + - have additionalProperties unset (defaults additionalProperties = any type) OR + - have additionalProperties set + """ + if name not in self.openapi_types: + raise PineconeApiAttributeError( + "{0} has no attribute '{1}'".format( + type(self).__name__, name), + [e for e in [self._path_to_item, name] if e] + ) + # attribute must be set on self and composed instances + self.set_attribute(name, value) + for model_instance in self._composed_instances: + setattr(model_instance, name, value) + if name not in self._var_name_to_model_instances: + # we assigned an additional property + self.__dict__['_var_name_to_model_instances'][name] = self._composed_instances + [self] + return None + + __unset_attribute_value__ = object() + + def get(self, name, default=None): + """returns the value of an attribute or some default value if the attribute was not set""" + if name in self.required_properties: + return self.__dict__[name] + + # get the attribute from the correct instance + model_instances = self._var_name_to_model_instances.get(name) + values = [] + # A composed model stores self and child (oneof/anyOf/allOf) models under + # self._var_name_to_model_instances. + # Any property must exist in self and all model instances + # The value stored in all model instances must be the same + if model_instances: + for model_instance in model_instances: + if name in model_instance._data_store: + v = model_instance._data_store[name] + if v not in values: + values.append(v) + len_values = len(values) + if len_values == 0: + return default + elif len_values == 1: + return values[0] + elif len_values > 1: + raise PineconeApiValueError( + "Values stored for property {0} in {1} differ when looking " + "at self and self's composed instances. All values must be " + "the same".format(name, type(self).__name__), + [e for e in [self._path_to_item, name] if e] + ) + + def __getitem__(self, name): + """get the value of an attribute using square-bracket notation: `instance[attr]`""" + value = self.get(name, self.__unset_attribute_value__) + if value is self.__unset_attribute_value__: + raise PineconeApiAttributeError( + "{0} has no attribute '{1}'".format( + type(self).__name__, name), + [e for e in [self._path_to_item, name] if e] + ) + return value + + def __contains__(self, name): + """used by `in` operator to check if an attrbute value was set in an instance: `'attr' in instance`""" + + if name in self.required_properties: + return name in self.__dict__ + + model_instances = self._var_name_to_model_instances.get( + name, self._additional_properties_model_instances) + + if model_instances: + for model_instance in model_instances: + if name in model_instance._data_store: + return True + + return False \ No newline at end of file diff --git a/codegen/openapi/templates5.2.0/model_templates/methods_setattr_getattr_normal.mustache b/codegen/openapi/templates5.2.0/model_templates/methods_setattr_getattr_normal.mustache new file mode 100644 index 000000000..6da9c12ad --- /dev/null +++ b/codegen/openapi/templates5.2.0/model_templates/methods_setattr_getattr_normal.mustache @@ -0,0 +1,32 @@ + def __setitem__(self, name, value): + """set the value of an attribute using square-bracket notation: `instance[attr] = val`""" + if name in self.required_properties: + self.__dict__[name] = value + return + + self.set_attribute(name, value) + + def get(self, name, default=None): + """returns the value of an attribute or some default value if the attribute was not set""" + if name in self.required_properties: + return self.__dict__[name] + + return self.__dict__['_data_store'].get(name, default) + + def __getitem__(self, name): + """get the value of an attribute using square-bracket notation: `instance[attr]`""" + if name in self: + return self.get(name) + + raise PineconeApiAttributeError( + "{0} has no attribute '{1}'".format( + type(self).__name__, name), + [e for e in [self._path_to_item, name] if e] + ) + + def __contains__(self, name): + """used by `in` operator to check if an attrbute value was set in an instance: `'attr' in instance`""" + if name in self.required_properties: + return name in self.__dict__ + + return name in self.__dict__['_data_store'] \ No newline at end of file diff --git a/codegen/openapi/templates5.2.0/model_templates/methods_shared.mustache b/codegen/openapi/templates5.2.0/model_templates/methods_shared.mustache new file mode 100644 index 000000000..43bcf6fd0 --- /dev/null +++ b/codegen/openapi/templates5.2.0/model_templates/methods_shared.mustache @@ -0,0 +1,15 @@ + def __repr__(self): + """For `print` and `pprint`""" + return self.to_str() + + def __ne__(self, other): + """Returns true if both objects are not equal""" + return not self == other + + def __setattr__(self, attr, value): + """set the value of an attribute using dot notation: `instance.attr = val`""" + self[attr] = value + + def __getattr__(self, attr): + """get the value of an attribute using dot notation: `instance.attr`""" + return self.{{#attrNoneIfUnset}}get{{/attrNoneIfUnset}}{{^attrNoneIfUnset}}__getitem__{{/attrNoneIfUnset}}(attr) \ No newline at end of file diff --git a/codegen/openapi/templates5.2.0/model_templates/methods_todict_tostr_eq_shared.mustache b/codegen/openapi/templates5.2.0/model_templates/methods_todict_tostr_eq_shared.mustache new file mode 100644 index 000000000..17c441196 --- /dev/null +++ b/codegen/openapi/templates5.2.0/model_templates/methods_todict_tostr_eq_shared.mustache @@ -0,0 +1,24 @@ + def to_dict(self): + """Returns the model properties as a dict""" + return model_to_dict(self, serialize=False) + + def to_str(self): + """Returns the string representation of the model""" + return pprint.pformat(self.to_dict()) + + def __eq__(self, other): + """Returns true if both objects are equal""" + if not isinstance(other, self.__class__): + return False + + if not set(self._data_store.keys()) == set(other._data_store.keys()): + return False + for _var_name, this_val in self._data_store.items(): + that_val = other._data_store[_var_name] + types = set() + types.add(this_val.__class__) + types.add(that_val.__class__) + vals_equal = this_val == that_val + if not vals_equal: + return False + return True \ No newline at end of file diff --git a/codegen/openapi/templates5.2.0/model_templates/methods_tostr_eq_simple.mustache b/codegen/openapi/templates5.2.0/model_templates/methods_tostr_eq_simple.mustache new file mode 100644 index 000000000..4a7ef6ae5 --- /dev/null +++ b/codegen/openapi/templates5.2.0/model_templates/methods_tostr_eq_simple.mustache @@ -0,0 +1,16 @@ + def to_str(self): + """Returns the string representation of the model""" + return str(self.value) + + def __eq__(self, other): + """Returns true if both objects are equal""" + if not isinstance(other, self.__class__): + return False + + this_val = self._data_store['value'] + that_val = other._data_store['value'] + types = set() + types.add(this_val.__class__) + types.add(that_val.__class__) + vals_equal = this_val == that_val + return vals_equal \ No newline at end of file diff --git a/codegen/openapi/templates5.2.0/model_templates/model_composed.mustache b/codegen/openapi/templates5.2.0/model_templates/model_composed.mustache new file mode 100644 index 000000000..9a5ab0f66 --- /dev/null +++ b/codegen/openapi/templates5.2.0/model_templates/model_composed.mustache @@ -0,0 +1,74 @@ +class {{classname}}(ModelComposed): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: +{{> model_templates/docstring_allowed }} + 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. +{{> model_templates/docstring_openapi_validations }} + """ + +{{> model_templates/classvars }} + + attribute_map = { +{{#requiredVars}} + '{{name}}': '{{baseName}}', # noqa: E501 +{{/requiredVars}} +{{#optionalVars}} + '{{name}}': '{{baseName}}', # noqa: E501 +{{/optionalVars}} + } + + read_only_vars = { +{{#requiredVars}} +{{#isReadOnly}} + '{{name}}', # noqa: E501 +{{/isReadOnly}} +{{/requiredVars}} +{{#optionalVars}} +{{#isReadOnly}} + '{{name}}', # noqa: E501 +{{/isReadOnly}} +{{/optionalVars}} + } + +{{> model_templates/method_from_openapi_data_composed }} + +{{> model_templates/method_init_composed }} + + @cached_property + def _composed_schemas(): + # we need this here to make our import statements work + # we must store _composed_schemas in here so the code is only run + # when we invoke this method. If we kept this at the class + # level we would get an error beause the class level + # code would be run when this module is imported, and these composed + # classes don't exist yet because their module has not finished + # loading +{{#imports}} +{{#-first}} + lazy_import() +{{/-first}} +{{/imports}} + return { + 'anyOf': [ +{{#anyOf}} + {{{.}}}, +{{/anyOf}} + ], + 'allOf': [ +{{#allOf}} + {{{.}}}, +{{/allOf}} + ], + 'oneOf': [ +{{#oneOf}} + {{{.}}}, +{{/oneOf}} + ], + } \ No newline at end of file diff --git a/codegen/openapi/templates5.2.0/model_templates/model_normal.mustache b/codegen/openapi/templates5.2.0/model_templates/model_normal.mustache new file mode 100644 index 000000000..513aa01e6 --- /dev/null +++ b/codegen/openapi/templates5.2.0/model_templates/model_normal.mustache @@ -0,0 +1,44 @@ +class {{classname}}(ModelNormal): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: +{{> model_templates/docstring_allowed }} + 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. +{{> model_templates/docstring_openapi_validations }} + """ + +{{> model_templates/classvars }} + + attribute_map = { +{{#requiredVars}} + '{{name}}': '{{baseName}}', # noqa: E501 +{{/requiredVars}} +{{#optionalVars}} + '{{name}}': '{{baseName}}', # noqa: E501 +{{/optionalVars}} + } + + read_only_vars = { +{{#requiredVars}} +{{#isReadOnly}} + '{{name}}', # noqa: E501 +{{/isReadOnly}} +{{/requiredVars}} +{{#optionalVars}} +{{#isReadOnly}} + '{{name}}', # noqa: E501 +{{/isReadOnly}} +{{/optionalVars}} + } + + _composed_schemas = {} + +{{> model_templates/method_from_openapi_data_normal}} + +{{> model_templates/method_init_normal}} \ No newline at end of file diff --git a/codegen/openapi/templates5.2.0/model_templates/model_simple.mustache b/codegen/openapi/templates5.2.0/model_templates/model_simple.mustache new file mode 100644 index 000000000..1a41a9cf7 --- /dev/null +++ b/codegen/openapi/templates5.2.0/model_templates/model_simple.mustache @@ -0,0 +1,22 @@ +class {{classname}}(ModelSimple): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: +{{> model_templates/docstring_allowed }} +{{> model_templates/docstring_openapi_validations }} + """ + +{{> model_templates/classvars }} + + attribute_map = {} + + read_only_vars = set() + + _composed_schemas = None + +{{> model_templates/method_init_simple}} + +{{> model_templates/method_from_openapi_data_simple}} \ No newline at end of file diff --git a/codegen/openapi/templates5.2.0/model_templates/validations.mustache b/codegen/openapi/templates5.2.0/model_templates/validations.mustache new file mode 100644 index 000000000..9e26146d8 --- /dev/null +++ b/codegen/openapi/templates5.2.0/model_templates/validations.mustache @@ -0,0 +1,34 @@ +{{#maxLength}} + 'max_length': {{maxLength}}, +{{/maxLength}} +{{#minLength}} + 'min_length': {{minLength}}, +{{/minLength}} +{{#maxItems}} + 'max_items': {{maxItems}}, +{{/maxItems}} +{{#minProperties}} + 'min_properties': {{minProperties}}, +{{/minProperties}} +{{#maxProperties}} + 'max_properties': {{maxProperties}}, +{{/maxProperties}} +{{#minItems}} + 'min_items': {{minItems}}, +{{/minItems}} +{{#maximum}} + {{#exclusiveMaximum}}'exclusive_maximum'{{/exclusiveMaximum}}'inclusive_maximum'{{^exclusiveMaximum}}{{/exclusiveMaximum}}: {{maximum}}, +{{/maximum}} +{{#minimum}} + {{#exclusiveMinimum}}'exclusive_minimum'{{/exclusiveMinimum}}'inclusive_minimum'{{^exclusiveMinimum}}{{/exclusiveMinimum}}: {{minimum}}, +{{/minimum}} +{{#pattern}} + 'regex': { + 'pattern': r'{{{vendorExtensions.x-regex}}}', # noqa: E501{{#vendorExtensions.x-modifiers}} + {{#-first}}'flags': (re.{{.}}{{/-first}}{{^-first}} re.{{.}}{{/-first}}{{^-last}} | {{/-last}}{{#-last}}){{/-last}}{{/vendorExtensions.x-modifiers}} + }, +{{/pattern}} +{{#multipleOf}} + 'multiple_of': {{multipleOf}}, +{{/multipleOf}} + }, \ No newline at end of file diff --git a/codegen/openapi/templates5.2.0/model_test.mustache b/codegen/openapi/templates5.2.0/model_test.mustache new file mode 100644 index 000000000..aa95f6494 --- /dev/null +++ b/codegen/openapi/templates5.2.0/model_test.mustache @@ -0,0 +1,34 @@ +{{>partial_header}} + +import sys +import unittest + +import {{packageName}} +{{#models}} +{{#model}} +{{#imports}} +{{{.}}} +{{/imports}} +from {{modelPackage}}.{{classFilename}} import {{classname}} + + +class Test{{classname}}(unittest.TestCase): + """{{classname}} unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def test{{classname}}(self): + """Test {{classname}}""" + # FIXME: construct object with mandatory attributes with example values + # model = {{classname}}() # noqa: E501 + pass + +{{/model}} +{{/models}} + +if __name__ == '__main__': + unittest.main() diff --git a/codegen/openapi/templates5.2.0/model_utils.mustache b/codegen/openapi/templates5.2.0/model_utils.mustache new file mode 100644 index 000000000..51469479e --- /dev/null +++ b/codegen/openapi/templates5.2.0/model_utils.mustache @@ -0,0 +1,1693 @@ +{{>partial_header}} + +from datetime import date, datetime # noqa: F401 +import inspect +import io +import os +import pprint +import re +import tempfile + +from {{packageName}}.exceptions import ( + PineconeApiKeyError, + PineconeApiAttributeError, + PineconeApiTypeError, + PineconeApiValueError, +) + +none_type = type(None) +file_type = io.IOBase + + +def convert_js_args_to_python_args(fn): + from functools import wraps + @wraps(fn) + def wrapped_init(_self, *args, **kwargs): + """ + An attribute named `self` received from the api will conflicts with the reserved `self` + parameter of a class method. During generation, `self` attributes are mapped + to `_self` in models. Here, we name `_self` instead of `self` to avoid conflicts. + """ + spec_property_naming = kwargs.get('_spec_property_naming', False) + if spec_property_naming: + kwargs = change_keys_js_to_python(kwargs, _self if isinstance(_self, type) else _self.__class__) + return fn(_self, *args, **kwargs) + return wrapped_init + + +class cached_property(object): + # this caches the result of the function call for fn with no inputs + # use this as a decorator on function methods that you want converted + # into cached properties + result_key = '_results' + + def __init__(self, fn): + self._fn = fn + + def __get__(self, instance, cls=None): + if self.result_key in vars(self): + return vars(self)[self.result_key] + else: + result = self._fn() + setattr(self, self.result_key, result) + return result + + +PRIMITIVE_TYPES = (list, float, int, bool, str, file_type) + +def allows_single_value_input(cls): + """ + This function returns True if the input composed schema model or any + descendant model allows a value only input + This is true for cases where oneOf contains items like: + oneOf: + - float + - NumberWithValidation + - StringEnum + - ArrayModel + - null + TODO: lru_cache this + """ + if ( + issubclass(cls, ModelSimple) or + cls in PRIMITIVE_TYPES + ): + return True + elif issubclass(cls, ModelComposed): + if not cls._composed_schemas['oneOf']: + return False + return any(allows_single_value_input(c) for c in cls._composed_schemas['oneOf']) + return False + +def composed_model_input_classes(cls): + """ + This function returns a list of the possible models that can be accepted as + inputs. + TODO: lru_cache this + """ + if issubclass(cls, ModelSimple) or cls in PRIMITIVE_TYPES: + return [cls] + elif issubclass(cls, ModelNormal): + if cls.discriminator is None: + return [cls] + else: + return get_discriminated_classes(cls) + elif issubclass(cls, ModelComposed): + if not cls._composed_schemas['oneOf']: + return [] + if cls.discriminator is None: + input_classes = [] + for c in cls._composed_schemas['oneOf']: + input_classes.extend(composed_model_input_classes(c)) + return input_classes + else: + return get_discriminated_classes(cls) + return [] + + +class OpenApiModel(object): + """The base class for all OpenAPIModels""" + +{{> model_templates/method_set_attribute }} + +{{> model_templates/methods_shared }} + + def __new__(cls, *args, **kwargs): + # this function uses the discriminator to + # pick a new schema/class to instantiate because a discriminator + # propertyName value was passed in + + if len(args) == 1: + arg = args[0] + if arg is None and is_type_nullable(cls): + # The input data is the 'null' value and the type is nullable. + return None + + if issubclass(cls, ModelComposed) and allows_single_value_input(cls): + model_kwargs = {} + oneof_instance = get_oneof_instance(cls, model_kwargs, kwargs, model_arg=arg) + return oneof_instance + + + visited_composed_classes = kwargs.get('_visited_composed_classes', ()) + if ( + cls.discriminator is None or + cls in visited_composed_classes + ): + # Use case 1: this openapi schema (cls) does not have a discriminator + # Use case 2: we have already visited this class before and are sure that we + # want to instantiate it this time. We have visited this class deserializing + # a payload with a discriminator. During that process we traveled through + # this class but did not make an instance of it. Now we are making an + # instance of a composed class which contains cls in it, so this time make an instance of cls. + # + # Here's an example of use case 2: 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 the composed schema dog Dog, we will make an instance of the + # Animal class (because Dal has allOf: Animal) but this time we won't travel + # through Animal's discriminator because we passed in + # _visited_composed_classes = (Animal,) + + return super(OpenApiModel, cls).__new__(cls) + + # Get the name and value of the discriminator property. + # The discriminator name is obtained from the discriminator meta-data + # and the discriminator value is obtained from the input data. + discr_propertyname_py = list(cls.discriminator.keys())[0] + discr_propertyname_js = cls.attribute_map[discr_propertyname_py] + if discr_propertyname_js in kwargs: + discr_value = kwargs[discr_propertyname_js] + elif discr_propertyname_py in kwargs: + discr_value = kwargs[discr_propertyname_py] + else: + # The input data does not contain the discriminator property. + path_to_item = kwargs.get('_path_to_item', ()) + raise PineconeApiValueError( + "Cannot deserialize input data due to missing discriminator. " + "The discriminator property '%s' is missing at path: %s" % + (discr_propertyname_js, path_to_item) + ) + + # Implementation note: the last argument to get_discriminator_class + # is a list of visited classes. get_discriminator_class may recursively + # call itself and update the list of visited classes, and the initial + # value must be an empty list. Hence not using 'visited_composed_classes' + new_cls = get_discriminator_class( + cls, discr_propertyname_py, discr_value, []) + if new_cls is None: + path_to_item = kwargs.get('_path_to_item', ()) + disc_prop_value = kwargs.get( + discr_propertyname_js, kwargs.get(discr_propertyname_py)) + raise PineconeApiValueError( + "Cannot deserialize input data due to invalid discriminator " + "value. The OpenAPI document has no mapping for discriminator " + "property '%s'='%s' at path: %s" % + (discr_propertyname_js, disc_prop_value, path_to_item) + ) + + if new_cls in visited_composed_classes: + # if we are making an instance of a composed schema Descendent + # which allOf includes Ancestor, then Ancestor contains + # a discriminator that includes Descendent. + # So if we make an instance of Descendent, we have to make an + # instance of Ancestor to hold the allOf properties. + # This code detects that use case and makes the instance of Ancestor + # For example: + # When making an instance of Dog, _visited_composed_classes = (Dog,) + # then we make an instance of Animal to include in dog._composed_instances + # so when we are here, cls is Animal + # cls.discriminator != None + # cls not in _visited_composed_classes + # new_cls = Dog + # but we know we know that we already have Dog + # because it is in visited_composed_classes + # so make Animal here + return super(OpenApiModel, cls).__new__(cls) + + # Build a list containing all oneOf and anyOf descendants. + oneof_anyof_classes = None + if cls._composed_schemas is not None: + oneof_anyof_classes = ( + cls._composed_schemas.get('oneOf', ()) + + cls._composed_schemas.get('anyOf', ())) + oneof_anyof_child = new_cls in oneof_anyof_classes + kwargs['_visited_composed_classes'] = visited_composed_classes + (cls,) + + if cls._composed_schemas.get('allOf') and oneof_anyof_child: + # Validate that we can make self because when we make the + # new_cls it will not include the allOf validations in self + self_inst = super(OpenApiModel, cls).__new__(cls) + self_inst.__init__(*args, **kwargs) + + new_inst = new_cls.__new__(new_cls, *args, **kwargs) + new_inst.__init__(*args, **kwargs) + return new_inst + + + @classmethod + @convert_js_args_to_python_args + def _new_from_openapi_data(cls, *args, **kwargs): + # this function uses the discriminator to + # pick a new schema/class to instantiate because a discriminator + # propertyName value was passed in + + if len(args) == 1: + arg = args[0] + if arg is None and is_type_nullable(cls): + # The input data is the 'null' value and the type is nullable. + return None + + if issubclass(cls, ModelComposed) and allows_single_value_input(cls): + model_kwargs = {} + oneof_instance = get_oneof_instance(cls, model_kwargs, kwargs, model_arg=arg) + return oneof_instance + + + visited_composed_classes = kwargs.get('_visited_composed_classes', ()) + if ( + cls.discriminator is None or + cls in visited_composed_classes + ): + # Use case 1: this openapi schema (cls) does not have a discriminator + # Use case 2: we have already visited this class before and are sure that we + # want to instantiate it this time. We have visited this class deserializing + # a payload with a discriminator. During that process we traveled through + # this class but did not make an instance of it. Now we are making an + # instance of a composed class which contains cls in it, so this time make an instance of cls. + # + # Here's an example of use case 2: 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 the composed schema dog Dog, we will make an instance of the + # Animal class (because Dal has allOf: Animal) but this time we won't travel + # through Animal's discriminator because we passed in + # _visited_composed_classes = (Animal,) + + return cls._from_openapi_data(*args, **kwargs) + + # Get the name and value of the discriminator property. + # The discriminator name is obtained from the discriminator meta-data + # and the discriminator value is obtained from the input data. + discr_propertyname_py = list(cls.discriminator.keys())[0] + discr_propertyname_js = cls.attribute_map[discr_propertyname_py] + if discr_propertyname_js in kwargs: + discr_value = kwargs[discr_propertyname_js] + elif discr_propertyname_py in kwargs: + discr_value = kwargs[discr_propertyname_py] + else: + # The input data does not contain the discriminator property. + path_to_item = kwargs.get('_path_to_item', ()) + raise PineconeApiValueError( + "Cannot deserialize input data due to missing discriminator. " + "The discriminator property '%s' is missing at path: %s" % + (discr_propertyname_js, path_to_item) + ) + + # Implementation note: the last argument to get_discriminator_class + # is a list of visited classes. get_discriminator_class may recursively + # call itself and update the list of visited classes, and the initial + # value must be an empty list. Hence not using 'visited_composed_classes' + new_cls = get_discriminator_class( + cls, discr_propertyname_py, discr_value, []) + if new_cls is None: + path_to_item = kwargs.get('_path_to_item', ()) + disc_prop_value = kwargs.get( + discr_propertyname_js, kwargs.get(discr_propertyname_py)) + raise PineconeApiValueError( + "Cannot deserialize input data due to invalid discriminator " + "value. The OpenAPI document has no mapping for discriminator " + "property '%s'='%s' at path: %s" % + (discr_propertyname_js, disc_prop_value, path_to_item) + ) + + if new_cls in visited_composed_classes: + # if we are making an instance of a composed schema Descendent + # which allOf includes Ancestor, then Ancestor contains + # a discriminator that includes Descendent. + # So if we make an instance of Descendent, we have to make an + # instance of Ancestor to hold the allOf properties. + # This code detects that use case and makes the instance of Ancestor + # For example: + # When making an instance of Dog, _visited_composed_classes = (Dog,) + # then we make an instance of Animal to include in dog._composed_instances + # so when we are here, cls is Animal + # cls.discriminator != None + # cls not in _visited_composed_classes + # new_cls = Dog + # but we know we know that we already have Dog + # because it is in visited_composed_classes + # so make Animal here + return cls._from_openapi_data(*args, **kwargs) + + # Build a list containing all oneOf and anyOf descendants. + oneof_anyof_classes = None + if cls._composed_schemas is not None: + oneof_anyof_classes = ( + cls._composed_schemas.get('oneOf', ()) + + cls._composed_schemas.get('anyOf', ())) + oneof_anyof_child = new_cls in oneof_anyof_classes + kwargs['_visited_composed_classes'] = visited_composed_classes + (cls,) + + if cls._composed_schemas.get('allOf') and oneof_anyof_child: + # Validate that we can make self because when we make the + # new_cls it will not include the allOf validations in self + self_inst = cls._from_openapi_data(*args, **kwargs) + + + new_inst = new_cls._new_from_openapi_data(*args, **kwargs) + return new_inst + + +class ModelSimple(OpenApiModel): + """the parent class of models whose type != object in their + swagger/openapi""" + +{{> model_templates/methods_setattr_getattr_normal }} + +{{> model_templates/methods_tostr_eq_simple }} + + +class ModelNormal(OpenApiModel): + """the parent class of models whose type == object in their + swagger/openapi""" + +{{> model_templates/methods_setattr_getattr_normal }} + +{{> model_templates/methods_todict_tostr_eq_shared}} + + +class ModelComposed(OpenApiModel): + """the parent class of models whose type == object in their + swagger/openapi and have oneOf/allOf/anyOf + + When one sets a property we use var_name_to_model_instances to store the value in + the correct class instances + run any type checking + validation code. + When one gets a property we use var_name_to_model_instances to get the value + from the correct class instances. + This allows multiple composed schemas to contain the same property with additive + constraints on the value. + + _composed_schemas (dict) stores the anyOf/allOf/oneOf classes + key (str): allOf/oneOf/anyOf + value (list): the classes in the XOf definition. + Note: none_type can be included when the openapi document version >= 3.1.0 + _composed_instances (list): stores a list of instances of the composed schemas + defined in _composed_schemas. When properties are accessed in the self instance, + they are returned from the self._data_store or the data stores in the instances + in self._composed_schemas + _var_name_to_model_instances (dict): maps between a variable name on self and + the composed instances (self included) which contain that data + key (str): property name + value (list): list of class instances, self or instances in _composed_instances + which contain the value that the key is referring to. + """ + +{{> model_templates/methods_setattr_getattr_composed }} + +{{> model_templates/methods_todict_tostr_eq_shared}} + + +COERCION_INDEX_BY_TYPE = { + ModelComposed: 0, + ModelNormal: 1, + ModelSimple: 2, + none_type: 3, # The type of 'None'. + list: 4, + dict: 5, + float: 6, + int: 7, + bool: 8, + # datetime: 9, + # date: 10, + str: 11, + file_type: 12, # 'file_type' is an alias for the built-in 'file' or 'io.IOBase' type. +} + +# these are used to limit what type conversions we try to do +# when we have a valid type already and we want to try converting +# to another type +UPCONVERSION_TYPE_PAIRS = ( + # (str, datetime), + # (str, date), + (int, float), # A float may be serialized as an integer, e.g. '3' is a valid serialized float. + (list, ModelComposed), + (dict, ModelComposed), + (str, ModelComposed), + (int, ModelComposed), + (float, ModelComposed), + (list, ModelComposed), + (list, ModelNormal), + (dict, ModelNormal), + (str, ModelSimple), + (int, ModelSimple), + (float, ModelSimple), + (list, ModelSimple), +) + +COERCIBLE_TYPE_PAIRS = { + False: ( # client instantiation of a model with client data + # (dict, ModelComposed), + # (list, ModelComposed), + # (dict, ModelNormal), + # (list, ModelNormal), + # (str, ModelSimple), + # (int, ModelSimple), + # (float, ModelSimple), + # (list, ModelSimple), + # (str, int), + # (str, float), + # (str, datetime), + # (str, date), + # (int, str), + # (float, str), + ), + True: ( # server -> client data + (dict, ModelComposed), + (list, ModelComposed), + (dict, ModelNormal), + (list, ModelNormal), + (str, ModelSimple), + (int, ModelSimple), + (float, ModelSimple), + (list, ModelSimple), + # (str, int), + # (str, float), + # (str, datetime), + # (str, date), + # (int, str), + # (float, str), + (str, file_type) + ), +} + + +def get_simple_class(input_value): + """Returns an input_value's simple class that we will use for type checking + Python2: + float and int will return int, where int is the python3 int backport + str and unicode will return str, where str is the python3 str backport + Note: float and int ARE both instances of int backport + Note: str_py2 and unicode_py2 are NOT both instances of str backport + + Args: + input_value (class/class_instance): the item for which we will return + the simple class + """ + if isinstance(input_value, type): + # input_value is a class + return input_value + elif isinstance(input_value, tuple): + return tuple + elif isinstance(input_value, list): + return list + elif isinstance(input_value, dict): + return dict + elif isinstance(input_value, none_type): + return none_type + elif isinstance(input_value, file_type): + return file_type + elif isinstance(input_value, bool): + # this must be higher than the int check because + # isinstance(True, int) == True + return bool + elif isinstance(input_value, int): + return int + # elif isinstance(input_value, datetime): + # # this must be higher than the date check because + # # isinstance(datetime_instance, date) == True + # return datetime + # elif isinstance(input_value, date): + # return date + elif isinstance(input_value, str): + return str + return type(input_value) + + +def check_allowed_values(allowed_values, input_variable_path, input_values): + """Raises an exception if the input_values are not allowed + + Args: + allowed_values (dict): the allowed_values dict + input_variable_path (tuple): the path to the input variable + input_values (list/str/int/float/date/datetime): the values that we + are checking to see if they are in allowed_values + """ + these_allowed_values = list(allowed_values[input_variable_path].values()) + if (isinstance(input_values, list) + and not set(input_values).issubset( + set(these_allowed_values))): + invalid_values = ", ".join( + map(str, set(input_values) - set(these_allowed_values))), + raise PineconeApiValueError( + "Invalid values for `%s` [%s], must be a subset of [%s]" % + ( + input_variable_path[0], + invalid_values, + ", ".join(map(str, these_allowed_values)) + ) + ) + elif (isinstance(input_values, dict) + and not set( + input_values.keys()).issubset(set(these_allowed_values))): + invalid_values = ", ".join( + map(str, set(input_values.keys()) - set(these_allowed_values))) + raise PineconeApiValueError( + "Invalid keys in `%s` [%s], must be a subset of [%s]" % + ( + input_variable_path[0], + invalid_values, + ", ".join(map(str, these_allowed_values)) + ) + ) + elif (not isinstance(input_values, (list, dict)) + and input_values not in these_allowed_values): + raise PineconeApiValueError( + "Invalid value for `%s` (%s), must be one of %s" % + ( + input_variable_path[0], + input_values, + these_allowed_values + ) + ) + + +def is_json_validation_enabled(schema_keyword, configuration=None): + """Returns true if JSON schema validation is enabled for the specified + validation keyword. This can be used to skip JSON schema structural validation + as requested in the configuration. + + Args: + schema_keyword (string): the name of a JSON schema validation keyword. + configuration (Configuration): the configuration class. + """ + + return (configuration is None or + not hasattr(configuration, '_disabled_client_side_validations') or + schema_keyword not in configuration._disabled_client_side_validations) + + +def check_validations( + validations, input_variable_path, input_values, + configuration=None): + """Raises an exception if the input_values are invalid + + Args: + validations (dict): the validation dictionary. + input_variable_path (tuple): the path to the input variable. + input_values (list/str/int/float/date/datetime): the values that we + are checking. + configuration (Configuration): the configuration class. + """ + + if input_values is None: + return + + current_validations = validations[input_variable_path] + if (is_json_validation_enabled('multipleOf', configuration) and + 'multiple_of' in current_validations and + isinstance(input_values, (int, float)) and + not (float(input_values) / current_validations['multiple_of']).is_integer()): + # Note 'multipleOf' will be as good as the floating point arithmetic. + raise PineconeApiValueError( + "Invalid value for `%s`, value must be a multiple of " + "`%s`" % ( + input_variable_path[0], + current_validations['multiple_of'] + ) + ) + + if (is_json_validation_enabled('maxLength', configuration) and + 'max_length' in current_validations and + len(input_values) > current_validations['max_length']): + raise PineconeApiValueError( + "Invalid value for `%s`, length must be less than or equal to " + "`%s`" % ( + input_variable_path[0], + current_validations['max_length'] + ) + ) + + if (is_json_validation_enabled('minLength', configuration) and + 'min_length' in current_validations and + len(input_values) < current_validations['min_length']): + raise PineconeApiValueError( + "Invalid value for `%s`, length must be greater than or equal to " + "`%s`" % ( + input_variable_path[0], + current_validations['min_length'] + ) + ) + + if (is_json_validation_enabled('maxItems', configuration) and + 'max_items' in current_validations and + len(input_values) > current_validations['max_items']): + raise PineconeApiValueError( + "Invalid value for `%s`, number of items must be less than or " + "equal to `%s`" % ( + input_variable_path[0], + current_validations['max_items'] + ) + ) + + if (is_json_validation_enabled('minItems', configuration) and + 'min_items' in current_validations and + len(input_values) < current_validations['min_items']): + raise ValueError( + "Invalid value for `%s`, number of items must be greater than or " + "equal to `%s`" % ( + input_variable_path[0], + current_validations['min_items'] + ) + ) + + items = ('exclusive_maximum', 'inclusive_maximum', 'exclusive_minimum', + 'inclusive_minimum') + if (any(item in current_validations for item in items)): + if isinstance(input_values, list): + max_val = max(input_values) + min_val = min(input_values) + elif isinstance(input_values, dict): + max_val = max(input_values.values()) + min_val = min(input_values.values()) + else: + max_val = input_values + min_val = input_values + + if (is_json_validation_enabled('exclusiveMaximum', configuration) and + 'exclusive_maximum' in current_validations and + max_val >= current_validations['exclusive_maximum']): + raise PineconeApiValueError( + "Invalid value for `%s`, must be a value less than `%s`" % ( + input_variable_path[0], + current_validations['exclusive_maximum'] + ) + ) + + if (is_json_validation_enabled('maximum', configuration) and + 'inclusive_maximum' in current_validations and + max_val > current_validations['inclusive_maximum']): + raise PineconeApiValueError( + "Invalid value for `%s`, must be a value less than or equal to " + "`%s`" % ( + input_variable_path[0], + current_validations['inclusive_maximum'] + ) + ) + + if (is_json_validation_enabled('exclusiveMinimum', configuration) and + 'exclusive_minimum' in current_validations and + min_val <= current_validations['exclusive_minimum']): + raise PineconeApiValueError( + "Invalid value for `%s`, must be a value greater than `%s`" % + ( + input_variable_path[0], + current_validations['exclusive_maximum'] + ) + ) + + if (is_json_validation_enabled('minimum', configuration) and + 'inclusive_minimum' in current_validations and + min_val < current_validations['inclusive_minimum']): + raise PineconeApiValueError( + "Invalid value for `%s`, must be a value greater than or equal " + "to `%s`" % ( + input_variable_path[0], + current_validations['inclusive_minimum'] + ) + ) + flags = current_validations.get('regex', {}).get('flags', 0) + if (is_json_validation_enabled('pattern', configuration) and + 'regex' in current_validations and + not re.search(current_validations['regex']['pattern'], + input_values, flags=flags)): + err_msg = r"Invalid value for `%s`, must match regular expression `%s`" % ( + input_variable_path[0], + current_validations['regex']['pattern'] + ) + if flags != 0: + # Don't print the regex flags if the flags are not + # specified in the OAS document. + err_msg = r"%s with flags=`%s`" % (err_msg, flags) + raise PineconeApiValueError(err_msg) + + +def order_response_types(required_types): + """Returns the required types sorted in coercion order + + Args: + required_types (list/tuple): collection of classes or instance of + list or dict with class information inside it. + + Returns: + (list): coercion order sorted collection of classes or instance + of list or dict with class information inside it. + """ + + def index_getter(class_or_instance): + if isinstance(class_or_instance, list): + return COERCION_INDEX_BY_TYPE[list] + elif isinstance(class_or_instance, dict): + return COERCION_INDEX_BY_TYPE[dict] + elif (inspect.isclass(class_or_instance) + and issubclass(class_or_instance, ModelComposed)): + return COERCION_INDEX_BY_TYPE[ModelComposed] + elif (inspect.isclass(class_or_instance) + and issubclass(class_or_instance, ModelNormal)): + return COERCION_INDEX_BY_TYPE[ModelNormal] + elif (inspect.isclass(class_or_instance) + and issubclass(class_or_instance, ModelSimple)): + return COERCION_INDEX_BY_TYPE[ModelSimple] + elif class_or_instance in COERCION_INDEX_BY_TYPE: + return COERCION_INDEX_BY_TYPE[class_or_instance] + raise PineconeApiValueError("Unsupported type: %s" % class_or_instance) + + sorted_types = sorted( + required_types, + key=lambda class_or_instance: index_getter(class_or_instance) + ) + return sorted_types + + +def remove_uncoercible(required_types_classes, current_item, spec_property_naming, + must_convert=True): + """Only keeps the type conversions that are possible + + Args: + required_types_classes (tuple): tuple of classes that are required + these should be ordered by COERCION_INDEX_BY_TYPE + 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 variables names in the input data are python + variable names in PEP-8 snake case. + current_item (any): the current item (input data) to be converted + + Keyword Args: + must_convert (bool): if True the item to convert is of the wrong + type and we want a big list of coercibles + if False, we want a limited list of coercibles + + Returns: + (list): the remaining coercible required types, classes only + """ + current_type_simple = get_simple_class(current_item) + + results_classes = [] + for required_type_class in required_types_classes: + # convert our models to OpenApiModel + required_type_class_simplified = required_type_class + if isinstance(required_type_class_simplified, type): + if issubclass(required_type_class_simplified, ModelComposed): + required_type_class_simplified = ModelComposed + elif issubclass(required_type_class_simplified, ModelNormal): + required_type_class_simplified = ModelNormal + elif issubclass(required_type_class_simplified, ModelSimple): + required_type_class_simplified = ModelSimple + + if required_type_class_simplified == current_type_simple: + # don't consider converting to one's own class + continue + + class_pair = (current_type_simple, required_type_class_simplified) + if must_convert and class_pair in COERCIBLE_TYPE_PAIRS[spec_property_naming]: + results_classes.append(required_type_class) + elif class_pair in UPCONVERSION_TYPE_PAIRS: + results_classes.append(required_type_class) + return results_classes + +def get_discriminated_classes(cls): + """ + Returns all the classes that a discriminator converts to + TODO: lru_cache this + """ + possible_classes = [] + key = list(cls.discriminator.keys())[0] + if is_type_nullable(cls): + possible_classes.append(cls) + for discr_cls in cls.discriminator[key].values(): + if hasattr(discr_cls, 'discriminator') and discr_cls.discriminator is not None: + possible_classes.extend(get_discriminated_classes(discr_cls)) + else: + possible_classes.append(discr_cls) + return possible_classes + + +def get_possible_classes(cls, from_server_context): + # TODO: lru_cache this + possible_classes = [cls] + if from_server_context: + return possible_classes + if hasattr(cls, 'discriminator') and cls.discriminator is not None: + possible_classes = [] + possible_classes.extend(get_discriminated_classes(cls)) + elif issubclass(cls, ModelComposed): + possible_classes.extend(composed_model_input_classes(cls)) + return possible_classes + + +def get_required_type_classes(required_types_mixed, spec_property_naming): + """Converts the tuple required_types into a tuple and a dict described + below + + Args: + required_types_mixed (tuple/list): will contain either classes or + instance of list or dict + spec_property_naming (bool): if True these values came from the + server, and we use the data types in our endpoints. + If False, we are client side and we need to include + oneOf and discriminator classes inside the data types in our endpoints + + Returns: + (valid_classes, dict_valid_class_to_child_types_mixed): + valid_classes (tuple): the valid classes that the current item + should be + dict_valid_class_to_child_types_mixed (dict): + valid_class (class): this is the key + child_types_mixed (list/dict/tuple): describes the valid child + types + """ + valid_classes = [] + child_req_types_by_current_type = {} + for required_type in required_types_mixed: + if isinstance(required_type, list): + valid_classes.append(list) + child_req_types_by_current_type[list] = required_type + elif isinstance(required_type, tuple): + valid_classes.append(tuple) + child_req_types_by_current_type[tuple] = required_type + elif isinstance(required_type, dict): + valid_classes.append(dict) + child_req_types_by_current_type[dict] = required_type[str] + else: + valid_classes.extend(get_possible_classes(required_type, spec_property_naming)) + return tuple(valid_classes), child_req_types_by_current_type + + +def change_keys_js_to_python(input_dict, model_class): + """ + Converts from javascript_key keys in the input_dict to python_keys in + the output dict using the mapping in model_class. + If the input_dict contains a key which does not declared in the model_class, + the key is added to the output dict as is. The assumption is the model_class + may have undeclared properties (additionalProperties attribute in the OAS + document). + """ + + if getattr(model_class, 'attribute_map', None) is None: + return input_dict + output_dict = {} + reversed_attr_map = {value: key for key, value in + model_class.attribute_map.items()} + for javascript_key, value in input_dict.items(): + python_key = reversed_attr_map.get(javascript_key) + if python_key is None: + # if the key is unknown, it is in error or it is an + # additionalProperties variable + python_key = javascript_key + output_dict[python_key] = value + return output_dict + + +def get_type_error(var_value, path_to_item, valid_classes, key_type=False): + error_msg = type_error_message( + var_name=path_to_item[-1], + var_value=var_value, + valid_classes=valid_classes, + key_type=key_type + ) + return PineconeApiTypeError( + error_msg, + path_to_item=path_to_item, + valid_classes=valid_classes, + key_type=key_type + ) + + +def deserialize_primitive(data, klass, path_to_item): + """Deserializes string to primitive type. + + :param data: str/int/float + :param klass: str/class the class to convert to + + :return: int, float, str, bool + """ + additional_message = "" + try: + # if klass in {datetime, date}: + # additional_message = ( + # "If you need your parameter to have a fallback " + # "string value, please set its type as `type: {}` in your " + # "spec. That allows the value to be any type. " + # ) + # if klass == datetime: + # if len(data) < 8: + # raise ValueError("This is not a datetime") + # # The string should be in iso8601 datetime format. + # parsed_datetime = parse(data) + # date_only = ( + # parsed_datetime.hour == 0 and + # parsed_datetime.minute == 0 and + # parsed_datetime.second == 0 and + # parsed_datetime.tzinfo is None and + # 8 <= len(data) <= 10 + # ) + # if date_only: + # raise ValueError("This is a date, not a datetime") + # return parsed_datetime + # elif klass == date: + # if len(data) < 8: + # raise ValueError("This is not a date") + # return parse(data).date() + # else: + converted_value = klass(data) + if isinstance(data, str) and klass == float: + if str(converted_value) != data: + # '7' -> 7.0 -> '7.0' != '7' + raise ValueError('This is not a float') + return converted_value + except (OverflowError, ValueError) as ex: + # parse can raise OverflowError + raise PineconeApiValueError( + "{0}Failed to parse {1} as {2}".format( + additional_message, repr(data), klass.__name__ + ), + path_to_item=path_to_item + ) from ex + + +def get_discriminator_class(model_class, + discr_name, + discr_value, cls_visited): + """Returns the child class specified by the discriminator. + + Args: + model_class (OpenApiModel): the model class. + discr_name (string): the name of the discriminator property. + discr_value (any): the discriminator value. + cls_visited (list): list of model classes that have been visited. + Used to determine the discriminator class without + visiting circular references indefinitely. + + Returns: + used_model_class (class/None): the chosen child class that will be used + to deserialize the data, for example dog.Dog. + If a class is not found, None is returned. + """ + + if model_class in cls_visited: + # The class has already been visited and no suitable class was found. + return None + cls_visited.append(model_class) + used_model_class = None + if discr_name in model_class.discriminator: + class_name_to_discr_class = model_class.discriminator[discr_name] + used_model_class = class_name_to_discr_class.get(discr_value) + if used_model_class is None: + # We didn't find a discriminated class in class_name_to_discr_class. + # So look in the ancestor or descendant discriminators + # The discriminator mapping may exist in a descendant (anyOf, oneOf) + # or ancestor (allOf). + # Ancestor example: in the GrandparentAnimal -> ParentPet -> ChildCat + # hierarchy, the discriminator mappings may be defined at any level + # in the hierarchy. + # Descendant example: mammal -> whale/zebra/Pig -> BasquePig/DanishPig + # if we try to make BasquePig from mammal, we need to travel through + # the oneOf descendant discriminators to find BasquePig + descendant_classes = model_class._composed_schemas.get('oneOf', ()) + \ + model_class._composed_schemas.get('anyOf', ()) + ancestor_classes = model_class._composed_schemas.get('allOf', ()) + possible_classes = descendant_classes + ancestor_classes + for cls in possible_classes: + # Check if the schema has inherited discriminators. + if hasattr(cls, 'discriminator') and cls.discriminator is not None: + used_model_class = get_discriminator_class( + cls, discr_name, discr_value, cls_visited) + if used_model_class is not None: + return used_model_class + return used_model_class + + +def deserialize_model(model_data, model_class, path_to_item, check_type, + configuration, spec_property_naming): + """Deserializes model_data to model instance. + + Args: + model_data (int/str/float/bool/none_type/list/dict): data to instantiate the model + model_class (OpenApiModel): the model class + path_to_item (list): path to the model in the received data + check_type (bool): whether to check the data tupe for the values in + the model + configuration (Configuration): the instance to use to convert files + 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 variables names in the input data are python + variable names in PEP-8 snake case. + + Returns: + model instance + + Raise: + PineconeApiTypeError + PineconeApiValueError + PineconeApiKeyError + """ + + kw_args = dict(_check_type=check_type, + _path_to_item=path_to_item, + _configuration=configuration, + _spec_property_naming=spec_property_naming) + + if issubclass(model_class, ModelSimple): + return model_class._new_from_openapi_data(model_data, **kw_args) + elif isinstance(model_data, list): + return model_class._new_from_openapi_data(*model_data, **kw_args) + if isinstance(model_data, dict): + kw_args.update(model_data) + return model_class._new_from_openapi_data(**kw_args) + elif isinstance(model_data, PRIMITIVE_TYPES): + return model_class._new_from_openapi_data(model_data, **kw_args) + + +def deserialize_file(response_data, configuration, content_disposition=None): + """Deserializes body to file + + Saves response body into a file in a temporary folder, + using the filename from the `Content-Disposition` header if provided. + + Args: + param response_data (str): the file data to write + configuration (Configuration): the instance to use to convert files + + Keyword Args: + content_disposition (str): the value of the Content-Disposition + header + + Returns: + (file_type): the deserialized file which is open + The user is responsible for closing and reading the file + """ + fd, path = tempfile.mkstemp(dir=configuration.temp_folder_path) + os.close(fd) + os.remove(path) + + if content_disposition: + filename = re.search(r'filename=[\'"]?([^\'"\s]+)[\'"]?', + content_disposition).group(1) + path = os.path.join(os.path.dirname(path), filename) + + with open(path, "wb") as f: + if isinstance(response_data, str): + # change str to bytes so we can write it + response_data = response_data.encode('utf-8') + f.write(response_data) + + f = open(path, "rb") + return f + + +def attempt_convert_item(input_value, valid_classes, path_to_item, + configuration, spec_property_naming, key_type=False, + must_convert=False, check_type=True): + """ + Args: + input_value (any): the data to convert + valid_classes (any): the classes that are valid + path_to_item (list): the path to the item to convert + configuration (Configuration): the instance to use to convert files + 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 variables names in the input data are python + variable names in PEP-8 snake case. + key_type (bool): if True we need to convert a key type (not supported) + must_convert (bool): if True we must convert + check_type (bool): if True we check the type or the returned data in + ModelComposed/ModelNormal/ModelSimple instances + + Returns: + instance (any) the fixed item + + Raises: + PineconeApiTypeError + PineconeApiValueError + PineconeApiKeyError + """ + valid_classes_ordered = order_response_types(valid_classes) + valid_classes_coercible = remove_uncoercible( + valid_classes_ordered, input_value, spec_property_naming) + if not valid_classes_coercible or key_type: + # we do not handle keytype errors, json will take care + # of this for us + if configuration is None or not configuration.discard_unknown_keys: + raise get_type_error(input_value, path_to_item, valid_classes, + key_type=key_type) + for valid_class in valid_classes_coercible: + try: + if issubclass(valid_class, OpenApiModel): + return deserialize_model(input_value, valid_class, + path_to_item, check_type, + configuration, spec_property_naming) + elif valid_class == file_type: + return deserialize_file(input_value, configuration) + return deserialize_primitive(input_value, valid_class, + path_to_item) + except (PineconeApiTypeError, PineconeApiValueError, PineconeApiKeyError) as conversion_exc: + if must_convert: + raise conversion_exc + # if we have conversion errors when must_convert == False + # we ignore the exception and move on to the next class + continue + # we were unable to convert, must_convert == False + return input_value + + +def is_type_nullable(input_type): + """ + Returns true if None is an allowed value for the specified input_type. + + A type is nullable if at least one of the following conditions is true: + 1. The OAS 'nullable' attribute has been specified, + 1. The type is the 'null' type, + 1. The type is a anyOf/oneOf composed schema, and a child schema is + the 'null' type. + Args: + input_type (type): the class of the input_value that we are + checking + Returns: + bool + """ + if input_type is none_type: + return True + if issubclass(input_type, OpenApiModel) and input_type._nullable: + return True + if issubclass(input_type, ModelComposed): + # If oneOf/anyOf, check if the 'null' type is one of the allowed types. + for t in input_type._composed_schemas.get('oneOf', ()): + if is_type_nullable(t): return True + for t in input_type._composed_schemas.get('anyOf', ()): + if is_type_nullable(t): return True + return False + + +def is_valid_type(input_class_simple, valid_classes): + """ + Args: + input_class_simple (class): the class of the input_value that we are + checking + valid_classes (tuple): the valid classes that the current item + should be + Returns: + bool + """ + valid_type = input_class_simple in valid_classes + if not valid_type and ( + issubclass(input_class_simple, OpenApiModel) or + input_class_simple is none_type): + for valid_class in valid_classes: + if input_class_simple is none_type and is_type_nullable(valid_class): + # Schema is oneOf/anyOf and the 'null' type is one of the allowed types. + return True + if not (issubclass(valid_class, OpenApiModel) and valid_class.discriminator): + continue + discr_propertyname_py = list(valid_class.discriminator.keys())[0] + discriminator_classes = ( + valid_class.discriminator[discr_propertyname_py].values() + ) + valid_type = is_valid_type(input_class_simple, discriminator_classes) + if valid_type: + return True + return valid_type + + +def validate_and_convert_types(input_value, required_types_mixed, path_to_item, + spec_property_naming, _check_type, configuration=None): + """Raises a TypeError is there is a problem, otherwise returns value + + Args: + input_value (any): the data to validate/convert + required_types_mixed (list/dict/tuple): A list of + valid classes, or a list tuples of valid classes, or a dict where + the value is a tuple of value classes + path_to_item: (list) the path to the data being validated + this stores a list of keys or indices to get to the data being + validated + 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 variables names in the input data are python + variable names in PEP-8 snake case. + _check_type: (boolean) if true, type will be checked and conversion + will be attempted. + configuration: (Configuration): the configuration class to use + when converting file_type items. + If passed, conversion will be attempted when possible + If not passed, no conversions will be attempted and + exceptions will be raised + + Returns: + the correctly typed value + + Raises: + PineconeApiTypeError + """ + results = get_required_type_classes(required_types_mixed, spec_property_naming) + valid_classes, child_req_types_by_current_type = results + + input_class_simple = get_simple_class(input_value) + valid_type = is_valid_type(input_class_simple, valid_classes) + if not valid_type: + if configuration: + # if input_value is not valid_type try to convert it + converted_instance = attempt_convert_item( + input_value, + valid_classes, + path_to_item, + configuration, + spec_property_naming, + key_type=False, + must_convert=True, + check_type=_check_type + ) + return converted_instance + else: + raise get_type_error(input_value, path_to_item, valid_classes, + key_type=False) + + # input_value's type is in valid_classes + if len(valid_classes) > 1 and configuration: + # there are valid classes which are not the current class + valid_classes_coercible = remove_uncoercible( + valid_classes, input_value, spec_property_naming, must_convert=False) + if valid_classes_coercible: + converted_instance = attempt_convert_item( + input_value, + valid_classes_coercible, + path_to_item, + configuration, + spec_property_naming, + key_type=False, + must_convert=False, + check_type=_check_type + ) + return converted_instance + + if child_req_types_by_current_type == {}: + # all types are of the required types and there are no more inner + # variables left to look at + return input_value + inner_required_types = child_req_types_by_current_type.get( + type(input_value) + ) + if inner_required_types is None: + # for this type, there are not more inner variables left to look at + return input_value + if isinstance(input_value, list): + if input_value == []: + # allow an empty list + return input_value + for index, inner_value in enumerate(input_value): + inner_path = list(path_to_item) + inner_path.append(index) + input_value[index] = validate_and_convert_types( + inner_value, + inner_required_types, + inner_path, + spec_property_naming, + _check_type, + configuration=configuration + ) + elif isinstance(input_value, dict): + if input_value == {}: + # allow an empty dict + return input_value + for inner_key, inner_val in input_value.items(): + inner_path = list(path_to_item) + inner_path.append(inner_key) + if get_simple_class(inner_key) != str: + raise get_type_error(inner_key, inner_path, valid_classes, + key_type=True) + input_value[inner_key] = validate_and_convert_types( + inner_val, + inner_required_types, + inner_path, + spec_property_naming, + _check_type, + configuration=configuration + ) + return input_value + + +def model_to_dict(model_instance, serialize=True): + """Returns the model properties as a dict + + Args: + model_instance (one of your model instances): the model instance that + will be converted to a dict. + + Keyword Args: + serialize (bool): if True, the keys in the dict will be values from + attribute_map + """ + result = {} + + model_instances = [model_instance] + if model_instance._composed_schemas: + model_instances.extend(model_instance._composed_instances) + seen_json_attribute_names = set() + used_fallback_python_attribute_names = set() + py_to_json_map = {} + for model_instance in model_instances: + for attr, value in model_instance._data_store.items(): + if serialize: + # we use get here because additional property key names do not + # exist in attribute_map + try: + attr = model_instance.attribute_map[attr] + py_to_json_map.update(model_instance.attribute_map) + seen_json_attribute_names.add(attr) + except KeyError: + used_fallback_python_attribute_names.add(attr) + if isinstance(value, list): + if not value: + # empty list or None + result[attr] = value + else: + res = [] + for v in value: + if isinstance(v, PRIMITIVE_TYPES) or v is None: + res.append(v) + elif isinstance(v, ModelSimple): + res.append(v.value) + else: + res.append(model_to_dict(v, serialize=serialize)) + result[attr] = res + elif isinstance(value, dict): + result[attr] = dict(map( + lambda item: (item[0], + model_to_dict(item[1], serialize=serialize)) + if hasattr(item[1], '_data_store') else item, + value.items() + )) + elif isinstance(value, ModelSimple): + result[attr] = value.value + elif hasattr(value, '_data_store'): + result[attr] = model_to_dict(value, serialize=serialize) + else: + result[attr] = value + if serialize: + for python_key in used_fallback_python_attribute_names: + json_key = py_to_json_map.get(python_key) + if json_key is None: + continue + if python_key == json_key: + continue + json_key_assigned_no_need_for_python_key = json_key in seen_json_attribute_names + if json_key_assigned_no_need_for_python_key: + del result[python_key] + + return result + + +def type_error_message(var_value=None, var_name=None, valid_classes=None, + key_type=None): + """ + Keyword Args: + var_value (any): the variable which has the type_error + var_name (str): the name of the variable which has the typ error + valid_classes (tuple): the accepted classes for current_item's + value + key_type (bool): False if our value is a value in a dict + True if it is a key in a dict + False if our item is an item in a list + """ + key_or_value = 'value' + if key_type: + key_or_value = 'key' + valid_classes_phrase = get_valid_classes_phrase(valid_classes) + msg = ( + "Invalid type for variable '{0}'. Required {1} type {2} and " + "passed type was {3}".format( + var_name, + key_or_value, + valid_classes_phrase, + type(var_value).__name__, + ) + ) + return msg + + +def get_valid_classes_phrase(input_classes): + """Returns a string phrase describing what types are allowed + """ + all_classes = list(input_classes) + all_classes = sorted(all_classes, key=lambda cls: cls.__name__) + all_class_names = [cls.__name__ for cls in all_classes] + if len(all_class_names) == 1: + return 'is {0}'.format(all_class_names[0]) + return "is one of [{0}]".format(", ".join(all_class_names)) + + +def get_allof_instances(self, model_args, constant_args): + """ + Args: + self: the class we are handling + model_args (dict): var_name to var_value + used to make instances + constant_args (dict): + metadata arguments: + _check_type + _path_to_item + _spec_property_naming + _configuration + _visited_composed_classes + + Returns + composed_instances (list) + """ + composed_instances = [] + for allof_class in self._composed_schemas['allOf']: + + try: + allof_instance = allof_class(**model_args, **constant_args) + composed_instances.append(allof_instance) + except Exception as ex: + raise PineconeApiValueError( + "Invalid inputs given to generate an instance of '%s'. The " + "input data was invalid for the allOf schema '%s' in the composed " + "schema '%s'. Error=%s" % ( + allof_class.__name__, + allof_class.__name__, + self.__class__.__name__, + str(ex) + ) + ) from ex + return composed_instances + + +def get_oneof_instance(cls, model_kwargs, constant_kwargs, model_arg=None): + """ + Find the oneOf schema that matches the input data (e.g. payload). + If exactly one schema matches the input data, an instance of that schema + is returned. + If zero or more than one schema match the input data, an exception is raised. + In OAS 3.x, the payload MUST, by validation, match exactly one of the + schemas described by oneOf. + + Args: + cls: the class we are handling + model_kwargs (dict): var_name to var_value + The input data, e.g. the payload that must match a oneOf schema + in the OpenAPI document. + constant_kwargs (dict): var_name to var_value + args that every model requires, including configuration, server + and path to item. + + Kwargs: + model_arg: (int, float, bool, str, ModelSimple, None): + the value to assign to a primitive class or ModelSimple class + Notes: + - this is only passed in when oneOf includes types which are not object + - None is used to suppress handling of model_arg, nullable models are handled in __new__ + + Returns + oneof_instance (instance) + """ + if len(cls._composed_schemas['oneOf']) == 0: + return None + + oneof_instances = [] + # Iterate over each oneOf schema and determine if the input data + # matches the oneOf schemas. + for oneof_class in cls._composed_schemas['oneOf']: + # The composed oneOf schema allows the 'null' type and the input data + # is the null value. This is a OAS >= 3.1 feature. + if oneof_class is none_type: + # skip none_types because we are deserializing dict data. + # none_type deserialization is handled in the __new__ method + continue + + single_value_input = allows_single_value_input(oneof_class) + + try: + if not single_value_input: + oneof_instance = oneof_class(**model_kwargs, **constant_kwargs) + else: + if issubclass(oneof_class, ModelSimple): + oneof_instance = oneof_class(model_arg, **constant_kwargs) + elif oneof_class in PRIMITIVE_TYPES: + oneof_instance = validate_and_convert_types( + model_arg, + (oneof_class,), + constant_kwargs['_path_to_item'], + constant_kwargs['_spec_property_naming'], + constant_kwargs['_check_type'], + configuration=constant_kwargs['_configuration'] + ) + oneof_instances.append(oneof_instance) + except Exception: + pass + if len(oneof_instances) == 0: + raise PineconeApiValueError( + "Invalid inputs given to generate an instance of %s. None " + "of the oneOf schemas matched the input data." % + cls.__name__ + ) + elif len(oneof_instances) > 1: + raise PineconeApiValueError( + "Invalid inputs given to generate an instance of %s. Multiple " + "oneOf schemas matched the inputs, but a max of one is allowed." % + cls.__name__ + ) + return oneof_instances[0] + + +def get_anyof_instances(self, model_args, constant_args): + """ + Args: + self: the class we are handling + model_args (dict): var_name to var_value + The input data, e.g. the payload that must match at least one + anyOf child schema in the OpenAPI document. + constant_args (dict): var_name to var_value + args that every model requires, including configuration, server + and path to item. + + Returns + anyof_instances (list) + """ + anyof_instances = [] + if len(self._composed_schemas['anyOf']) == 0: + return anyof_instances + + for anyof_class in self._composed_schemas['anyOf']: + # The composed oneOf schema allows the 'null' type and the input data + # is the null value. This is a OAS >= 3.1 feature. + if anyof_class is none_type: + # skip none_types because we are deserializing dict data. + # none_type deserialization is handled in the __new__ method + continue + + try: + anyof_instance = anyof_class(**model_args, **constant_args) + anyof_instances.append(anyof_instance) + except Exception: + pass + if len(anyof_instances) == 0: + raise PineconeApiValueError( + "Invalid inputs given to generate an instance of %s. None of the " + "anyOf schemas matched the inputs." % + self.__class__.__name__ + ) + return anyof_instances + + +def get_discarded_args(self, composed_instances, model_args): + """ + Gathers the args that were discarded by configuration.discard_unknown_keys + """ + model_arg_keys = model_args.keys() + discarded_args = set() + # arguments passed to self were already converted to python names + # before __init__ was called + for instance in composed_instances: + if instance.__class__ in self._composed_schemas['allOf']: + try: + keys = instance.to_dict().keys() + discarded_keys = model_args - keys + discarded_args.update(discarded_keys) + except Exception: + # allOf integer schema will throw exception + pass + else: + try: + all_keys = set(model_to_dict(instance, serialize=False).keys()) + js_keys = model_to_dict(instance, serialize=True).keys() + all_keys.update(js_keys) + discarded_keys = model_arg_keys - all_keys + discarded_args.update(discarded_keys) + except Exception: + # allOf integer schema will throw exception + pass + return discarded_args + + +def validate_get_composed_info(constant_args, model_args, self): + """ + For composed schemas, generate schema instances for + all schemas in the oneOf/anyOf/allOf definition. If additional + properties are allowed, also assign those properties on + all matched schemas that contain additionalProperties. + Openapi schemas are python classes. + + Exceptions are raised if: + - 0 or > 1 oneOf schema matches the model_args input data + - no anyOf schema matches the model_args input data + - any of the allOf schemas do not match the model_args input data + + Args: + constant_args (dict): these are the args that every model requires + model_args (dict): these are the required and optional spec args that + were passed in to make this model + self (class): the class that we are instantiating + This class contains self._composed_schemas + + Returns: + composed_info (list): length three + composed_instances (list): the composed instances which are not + self + var_name_to_model_instances (dict): a dict going from var_name + to the model_instance which holds that var_name + the model_instance may be self or an instance of one of the + classes in self.composed_instances() + additional_properties_model_instances (list): a list of the + model instances which have the property + additional_properties_type. This list can include self + """ + # create composed_instances + composed_instances = [] + allof_instances = get_allof_instances(self, model_args, constant_args) + composed_instances.extend(allof_instances) + oneof_instance = get_oneof_instance(self.__class__, model_args, constant_args) + if oneof_instance is not None: + composed_instances.append(oneof_instance) + anyof_instances = get_anyof_instances(self, model_args, constant_args) + composed_instances.extend(anyof_instances) + """ + set additional_properties_model_instances + additional properties must be evaluated at the schema level + so self's additional properties are most important + If self is a composed schema with: + - no properties defined in self + - additionalProperties: False + Then for object payloads every property is an additional property + and they are not allowed, so only empty dict is allowed + + Properties must be set on all matching schemas + so when a property is assigned toa composed instance, it must be set on all + composed instances regardless of additionalProperties presence + keeping it to prevent breaking changes in v5.0.1 + TODO remove cls._additional_properties_model_instances in 6.0.0 + """ + additional_properties_model_instances = [] + if self.additional_properties_type is not None: + additional_properties_model_instances = [self] + + """ + no need to set properties on self in here, they will be set in __init__ + By here all composed schema oneOf/anyOf/allOf instances have their properties set using + model_args + """ + discarded_args = get_discarded_args(self, composed_instances, model_args) + + # map variable names to composed_instances + var_name_to_model_instances = {} + for prop_name in model_args: + if prop_name not in discarded_args: + var_name_to_model_instances[prop_name] = [self] + composed_instances + + return [ + composed_instances, + var_name_to_model_instances, + additional_properties_model_instances, + discarded_args + ] diff --git a/codegen/openapi/templates5.2.0/partial_header.mustache b/codegen/openapi/templates5.2.0/partial_header.mustache new file mode 100644 index 000000000..c52fbceb1 --- /dev/null +++ b/codegen/openapi/templates5.2.0/partial_header.mustache @@ -0,0 +1,17 @@ +""" +{{#appName}} + {{{appName}}} +{{/appName}} + +{{#appDescription}} + {{{appDescription}}} # noqa: E501 +{{/appDescription}} + + {{#version}} + The version of the OpenAPI document: {{{version}}} + {{/version}} + {{#infoEmail}} + Contact: {{{infoEmail}}} + {{/infoEmail}} + Generated by: https://openapi-generator.tech +""" diff --git a/codegen/openapi/templates5.2.0/python_doc_auth_partial.mustache b/codegen/openapi/templates5.2.0/python_doc_auth_partial.mustache new file mode 100644 index 000000000..5106632d2 --- /dev/null +++ b/codegen/openapi/templates5.2.0/python_doc_auth_partial.mustache @@ -0,0 +1,109 @@ +# Defining the host is optional and defaults to {{{basePath}}} +# See configuration.py for a list of all supported configuration parameters. +configuration = {{{packageName}}}.Configuration( + host = "{{{basePath}}}" +) + +{{#hasAuthMethods}} +# The client must configure the authentication and authorization parameters +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. +{{#authMethods}} +{{#isBasic}} +{{#isBasicBasic}} + +# Configure HTTP basic authorization: {{{name}}} +configuration = {{{packageName}}}.Configuration( + username = 'YOUR_USERNAME', + password = 'YOUR_PASSWORD' +) +{{/isBasicBasic}} +{{#isBasicBearer}} + +# Configure Bearer authorization{{#bearerFormat}} ({{{.}}}){{/bearerFormat}}: {{{name}}} +configuration = {{{packageName}}}.Configuration( + access_token = 'YOUR_BEARER_TOKEN' +) +{{/isBasicBearer}} +{{#isHttpSignature}} + +# Configure HTTP message signature: {{{name}}} +# The HTTP Signature Header mechanism that can be used by a client to +# authenticate the sender of a message and ensure that particular headers +# have not been modified in transit. +# +# You can specify the signing key-id, private key path, signing scheme, +# signing algorithm, list of signed headers and signature max validity. +# The 'key_id' parameter is an opaque string that the API server can use +# to lookup the client and validate the signature. +# The 'private_key_path' parameter should be the path to a file that +# contains a DER or base-64 encoded private key. +# The 'private_key_passphrase' parameter is optional. Set the passphrase +# if the private key is encrypted. +# The 'signed_headers' parameter is used to specify the list of +# HTTP headers included when generating the signature for the message. +# You can specify HTTP headers that you want to protect with a cryptographic +# signature. Note that proxies may add, modify or remove HTTP headers +# for legitimate reasons, so you should only add headers that you know +# will not be modified. For example, if you want to protect the HTTP request +# body, you can specify the Digest header. In that case, the client calculates +# the digest of the HTTP request body and includes the digest in the message +# signature. +# The 'signature_max_validity' parameter is optional. It is configured as a +# duration to express when the signature ceases to be valid. The client calculates +# the expiration date every time it generates the cryptographic signature +# of an HTTP request. The API server may have its own security policy +# that controls the maximum validity of the signature. The client max validity +# must be lower than the server max validity. +# The time on the client and server must be synchronized, otherwise the +# server may reject the client signature. +# +# The client must use a combination of private key, signing scheme, +# signing algorithm and hash algorithm that matches the security policy of +# the API server. +# +# See {{{packageName}}}.signing for a list of all supported parameters. +configuration = {{{packageName}}}.Configuration( + host = "{{{basePath}}}", + signing_info = {{{packageName}}}.signing.HttpSigningConfiguration( + key_id = 'my-key-id', + private_key_path = 'private_key.pem', + private_key_passphrase = 'YOUR_PASSPHRASE', + signing_scheme = {{{packageName}}}.signing.SCHEME_HS2019, + signing_algorithm = {{{packageName}}}.signing.ALGORITHM_ECDSA_MODE_FIPS_186_3, + hash_algorithm = {{{packageName}}}.signing.SCHEME_RSA_SHA256, + signed_headers = [ + {{{packageName}}}.signing.HEADER_REQUEST_TARGET, + {{{packageName}}}.signing.HEADER_CREATED, + {{{packageName}}}.signing.HEADER_EXPIRES, + {{{packageName}}}.signing.HEADER_HOST, + {{{packageName}}}.signing.HEADER_DATE, + {{{packageName}}}.signing.HEADER_DIGEST, + 'Content-Type', + 'Content-Length', + 'User-Agent' + ], + signature_max_validity = datetime.timedelta(minutes=5) + ) +) +{{/isHttpSignature}} +{{/isBasic}} +{{#isApiKey}} + +# Configure API key authorization: {{{name}}} +configuration.api_key['{{{name}}}'] = 'YOUR_API_KEY' + +# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed +# configuration.api_key_prefix['{{name}}'] = 'Bearer' +{{/isApiKey}} +{{#isOAuth}} + +# Configure OAuth2 access token for authorization: {{{name}}} +configuration = {{{packageName}}}.Configuration( + host = "{{{basePath}}}" +) +configuration.access_token = 'YOUR_ACCESS_TOKEN' +{{/isOAuth}} +{{/authMethods}} +{{/hasAuthMethods}} diff --git a/codegen/openapi/templates5.2.0/requirements.mustache b/codegen/openapi/templates5.2.0/requirements.mustache new file mode 100644 index 000000000..96947f604 --- /dev/null +++ b/codegen/openapi/templates5.2.0/requirements.mustache @@ -0,0 +1,3 @@ +python_dateutil >= 2.5.3 +setuptools >= 21.0.0 +urllib3 >= 1.25.3 diff --git a/codegen/openapi/templates5.2.0/rest.mustache b/codegen/openapi/templates5.2.0/rest.mustache new file mode 100644 index 000000000..53a2c9b09 --- /dev/null +++ b/codegen/openapi/templates5.2.0/rest.mustache @@ -0,0 +1,319 @@ +{{>partial_header}} + +import io +import json +import logging +import re +import ssl +import os +from urllib.parse import urlencode + +import urllib3 + +from {{packageName}}.exceptions import PineconeApiException, UnauthorizedException, ForbiddenException, NotFoundException, ServiceException, PineconeApiValueError + + +class bcolors: + HEADER = '\033[95m' + OKBLUE = '\033[94m' + OKCYAN = '\033[96m' + OKGREEN = '\033[92m' + WARNING = '\033[93m' + FAIL = '\033[91m' + ENDC = '\033[0m' + BOLD = '\033[1m' + UNDERLINE = '\033[4m' + +logger = logging.getLogger(__name__) + + +class RESTResponse(io.IOBase): + + def __init__(self, resp): + self.urllib3_response = resp + self.status = resp.status + self.reason = resp.reason + self.data = resp.data + + def getheaders(self): + """Returns a dictionary of the response headers.""" + return self.urllib3_response.headers + + def getheader(self, name, default=None): + """Returns a given response header.""" + return self.urllib3_response.headers.get(name, default) + + +class RESTClientObject(object): + + def __init__(self, configuration, pools_size=4, maxsize=None): + # urllib3.PoolManager will pass all kw parameters to connectionpool + # https://github.com/shazow/urllib3/blob/f9409436f83aeb79fbaf090181cd81b784f1b8ce/urllib3/poolmanager.py#L75 # noqa: E501 + # https://github.com/shazow/urllib3/blob/f9409436f83aeb79fbaf090181cd81b784f1b8ce/urllib3/connectionpool.py#L680 # noqa: E501 + # maxsize is the number of requests to host that are allowed in parallel # noqa: E501 + # Custom SSL certificates and client certificates: http://urllib3.readthedocs.io/en/latest/advanced-usage.html # noqa: E501 + + # cert_reqs + if configuration.verify_ssl: + cert_reqs = ssl.CERT_REQUIRED + else: + cert_reqs = ssl.CERT_NONE + + addition_pool_args = {} + if configuration.assert_hostname is not None: + addition_pool_args['assert_hostname'] = configuration.assert_hostname # noqa: E501 + + if configuration.retries is not None: + addition_pool_args['retries'] = configuration.retries + + if configuration.socket_options is not None: + addition_pool_args['socket_options'] = configuration.socket_options + + if maxsize is None: + if configuration.connection_pool_maxsize is not None: + maxsize = configuration.connection_pool_maxsize + else: + maxsize = 4 + + # https pool manager + if configuration.proxy: + self.pool_manager = urllib3.ProxyManager( + num_pools=pools_size, + maxsize=maxsize, + cert_reqs=cert_reqs, + ca_certs=configuration.ssl_ca_cert, + cert_file=configuration.cert_file, + key_file=configuration.key_file, + proxy_url=configuration.proxy, + proxy_headers=configuration.proxy_headers, + **addition_pool_args + ) + else: + self.pool_manager = urllib3.PoolManager( + num_pools=pools_size, + maxsize=maxsize, + cert_reqs=cert_reqs, + ca_certs=configuration.ssl_ca_cert, + cert_file=configuration.cert_file, + key_file=configuration.key_file, + **addition_pool_args + ) + + 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 os.environ.get('PINECONE_DEBUG_CURL'): + formatted_headers = ' '.join(["-H '{0}: {1}'".format(k, v) + for k, v in headers.items()]) + formatted_query = urlencode(query_params) + if formatted_query: + formatted_url = f'{url}?{formatted_query}' + else: + formatted_url = url + if body is None: + print(bcolors.OKBLUE + "curl -X {method} '{url}' {formatted_headers}".format(method=method, url=formatted_url, formatted_headers=formatted_headers) + bcolors.ENDC) + else: + formatted_body = json.dumps(body) + print(bcolors.OKBLUE + "curl -X {method} '{url}' {formatted_headers} -d '{data}'".format(method=method, url=formatted_url, formatted_headers=formatted_headers, data=formatted_body) + bcolors.ENDC) + + if post_params and body: + raise PineconeApiValueError( + "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, float)): # 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]) + + try: + # For `POST`, `PUT`, `PATCH`, `OPTIONS`, `DELETE` + if method in ['POST', 'PUT', 'PATCH', 'OPTIONS', 'DELETE']: + # Only set a default Content-Type for POST, PUT, PATCH and OPTIONS requests + if (method != 'DELETE') and ('Content-Type' not in headers): + headers['Content-Type'] = 'application/json' + if query_params: + url += '?' + urlencode(query_params) + if ('Content-Type' not in headers) or (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 PineconeApiException(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 PineconeApiException(status=0, reason=msg) + + if os.environ.get('PINECONE_DEBUG_CURL'): + o = RESTResponse(r) + + if o.status <= 300: + print(bcolors.OKGREEN + o.data.decode('utf-8') + bcolors.ENDC) + else: + print(bcolors.FAIL + o.data.decode('utf-8') + bcolors.ENDC) + + + if _preload_content: + r = RESTResponse(r) + + # log response body + logger.debug("response body: %s", r.data) + + if not 200 <= r.status <= 299: + if r.status == 401: + raise UnauthorizedException(http_resp=r) + + if r.status == 403: + raise ForbiddenException(http_resp=r) + + if r.status == 404: + raise NotFoundException(http_resp=r) + + if 500 <= r.status <= 599: + raise ServiceException(http_resp=r) + + raise PineconeApiException(http_resp=r) + + return r + + def GET(self, url, headers=None, query_params=None, _preload_content=True, + _request_timeout=None): + return self.request("GET", url, + headers=headers, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + query_params=query_params) + + def HEAD(self, url, headers=None, query_params=None, _preload_content=True, + _request_timeout=None): + return self.request("HEAD", url, + headers=headers, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + query_params=query_params) + + def OPTIONS(self, url, headers=None, query_params=None, post_params=None, + body=None, _preload_content=True, _request_timeout=None): + return self.request("OPTIONS", url, + headers=headers, + query_params=query_params, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + + def DELETE(self, url, headers=None, query_params=None, body=None, + _preload_content=True, _request_timeout=None): + return self.request("DELETE", url, + headers=headers, + query_params=query_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + + def POST(self, url, headers=None, query_params=None, post_params=None, + body=None, _preload_content=True, _request_timeout=None): + return self.request("POST", url, + headers=headers, + query_params=query_params, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + + def PUT(self, url, headers=None, query_params=None, post_params=None, + body=None, _preload_content=True, _request_timeout=None): + return self.request("PUT", url, + headers=headers, + query_params=query_params, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + + def PATCH(self, url, headers=None, query_params=None, post_params=None, + body=None, _preload_content=True, _request_timeout=None): + return self.request("PATCH", url, + headers=headers, + query_params=query_params, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) diff --git a/codegen/openapi/templates5.2.0/setup.mustache b/codegen/openapi/templates5.2.0/setup.mustache new file mode 100644 index 000000000..d5154f3fa --- /dev/null +++ b/codegen/openapi/templates5.2.0/setup.mustache @@ -0,0 +1,51 @@ +{{>partial_header}} + +from setuptools import setup, find_packages # noqa: H301 + +NAME = "{{{projectName}}}" +VERSION = "{{packageVersion}}" +{{#apiInfo}} +{{#apis}} +{{#-last}} +# To install the library, run the following +# +# python setup.py install +# +# prerequisite: setuptools +# http://pypi.python.org/pypi/setuptools + +REQUIRES = [ + "urllib3 >= 1.25.3", + "python-dateutil", +{{#asyncio}} + "aiohttp >= 3.0.0", +{{/asyncio}} +{{#tornado}} + "tornado>=4.2,<5", +{{/tornado}} +{{#hasHttpSignatureMethods}} + "pem>=19.3.0", + "pycryptodome>=3.9.0", +{{/hasHttpSignatureMethods}} +] + +setup( + name=NAME, + version=VERSION, + description="{{appName}}", + author="{{#infoName}}{{infoName}}{{/infoName}}{{^infoName}}OpenAPI Generator community{{/infoName}}", + author_email="{{#infoEmail}}{{infoEmail}}{{/infoEmail}}{{^infoEmail}}team@openapitools.org{{/infoEmail}}", + url="{{packageUrl}}", + keywords=["OpenAPI", "OpenAPI-Generator", "{{{appName}}}"], + python_requires=">=3.6", + install_requires=REQUIRES, + packages=find_packages(exclude=["test", "tests"]), + include_package_data=True, + {{#licenseInfo}}license="{{licenseInfo}}", + {{/licenseInfo}}long_description="""\ + {{appDescription}} # noqa: E501 + """ +) +{{/-last}} +{{/apis}} +{{/apiInfo}} diff --git a/codegen/openapi/templates5.2.0/setup_cfg.mustache b/codegen/openapi/templates5.2.0/setup_cfg.mustache new file mode 100644 index 000000000..931f02c5d --- /dev/null +++ b/codegen/openapi/templates5.2.0/setup_cfg.mustache @@ -0,0 +1,13 @@ +{{#useNose}} +[nosetests] +logging-clear-handlers=true +verbosity=2 +randomize=true +exe=true +with-coverage=true +cover-package={{{packageName}}} +cover-erase=true + +{{/useNose}} +[flake8] +max-line-length=99 diff --git a/codegen/openapi/templates5.2.0/signing.mustache b/codegen/openapi/templates5.2.0/signing.mustache new file mode 100644 index 000000000..8dfbf5148 --- /dev/null +++ b/codegen/openapi/templates5.2.0/signing.mustache @@ -0,0 +1,408 @@ +{{>partial_header}} + +from base64 import b64encode +from Crypto.IO import PEM, PKCS8 +from Crypto.Hash import SHA256, SHA512 +from Crypto.PublicKey import RSA, ECC +from Crypto.Signature import PKCS1_v1_5, pss, DSS +from email.utils import formatdate +import json +import os +import re +from time import time +from urllib.parse import urlencode, urlparse + +# The constants below define a subset of HTTP headers that can be included in the +# HTTP signature scheme. Additional headers may be included in the signature. + +# The '(request-target)' header is a calculated field that includes the HTTP verb, +# the URL path and the URL query. +HEADER_REQUEST_TARGET = '(request-target)' +# The time when the HTTP signature was generated. +HEADER_CREATED = '(created)' +# The time when the HTTP signature expires. The API server should reject HTTP requests +# that have expired. +HEADER_EXPIRES = '(expires)' +# The 'Host' header. +HEADER_HOST = 'Host' +# The 'Date' header. +HEADER_DATE = 'Date' +# When the 'Digest' header is included in the HTTP signature, the client automatically +# computes the digest of the HTTP request body, per RFC 3230. +HEADER_DIGEST = 'Digest' +# The 'Authorization' header is automatically generated by the client. It includes +# the list of signed headers and a base64-encoded signature. +HEADER_AUTHORIZATION = 'Authorization' + +# The constants below define the cryptographic schemes for the HTTP signature scheme. +SCHEME_HS2019 = 'hs2019' +SCHEME_RSA_SHA256 = 'rsa-sha256' +SCHEME_RSA_SHA512 = 'rsa-sha512' + +# The constants below define the signature algorithms that can be used for the HTTP +# signature scheme. +ALGORITHM_RSASSA_PSS = 'RSASSA-PSS' +ALGORITHM_RSASSA_PKCS1v15 = 'RSASSA-PKCS1-v1_5' + +ALGORITHM_ECDSA_MODE_FIPS_186_3 = 'fips-186-3' +ALGORITHM_ECDSA_MODE_DETERMINISTIC_RFC6979 = 'deterministic-rfc6979' +ALGORITHM_ECDSA_KEY_SIGNING_ALGORITHMS = { + ALGORITHM_ECDSA_MODE_FIPS_186_3, + ALGORITHM_ECDSA_MODE_DETERMINISTIC_RFC6979 +} + +# The cryptographic hash algorithm for the message signature. +HASH_SHA256 = 'sha256' +HASH_SHA512 = 'sha512' + + +class HttpSigningConfiguration(object): + """The configuration parameters for the HTTP signature security scheme. + The HTTP signature security scheme is used to sign HTTP requests with a private key + which is in possession of the API client. + An 'Authorization' header is calculated by creating a hash of select headers, + and optionally the body of the HTTP request, then signing the hash value using + a private key. The 'Authorization' header is added to outbound HTTP requests. + + NOTE: This class is auto generated by OpenAPI Generator + + Ref: https://openapi-generator.tech + Do not edit the class manually. + + :param key_id: A string value specifying the identifier of the cryptographic key, + when signing HTTP requests. + :param signing_scheme: A string value specifying the signature scheme, when + signing HTTP requests. + Supported value are hs2019, rsa-sha256, rsa-sha512. + Avoid using rsa-sha256, rsa-sha512 as they are deprecated. These values are + available for server-side applications that only support the older + HTTP signature algorithms. + :param private_key_path: A string value specifying the path of the file containing + a private key. The private key is used to sign HTTP requests. + :param private_key_passphrase: A string value specifying the passphrase to decrypt + the private key. + :param signed_headers: A list of strings. Each value is the name of a HTTP header + that must be included in the HTTP signature calculation. + The two special signature headers '(request-target)' and '(created)' SHOULD be + included in SignedHeaders. + The '(created)' header expresses when the signature was created. + The '(request-target)' header is a concatenation of the lowercased :method, an + ASCII space, and the :path pseudo-headers. + When signed_headers is not specified, the client defaults to a single value, + '(created)', in the list of HTTP headers. + When SignedHeaders contains the 'Digest' value, the client performs the + following operations: + 1. Calculate a digest of request body, as specified in RFC3230, section 4.3.2. + 2. Set the 'Digest' header in the request body. + 3. Include the 'Digest' header and value in the HTTP signature. + :param signing_algorithm: A string value specifying the signature algorithm, when + signing HTTP requests. + Supported values are: + 1. For RSA keys: RSASSA-PSS, RSASSA-PKCS1-v1_5. + 2. For ECDSA keys: fips-186-3, deterministic-rfc6979. + If None, the signing algorithm is inferred from the private key. + The default signing algorithm for RSA keys is RSASSA-PSS. + The default signing algorithm for ECDSA keys is fips-186-3. + :param hash_algorithm: The hash algorithm for the signature. Supported values are + sha256 and sha512. + If the signing_scheme is rsa-sha256, the hash algorithm must be set + to None or sha256. + If the signing_scheme is rsa-sha512, the hash algorithm must be set + to None or sha512. + :param signature_max_validity: The signature max validity, expressed as + a datetime.timedelta value. It must be a positive value. + """ + def __init__(self, key_id, signing_scheme, private_key_path, + private_key_passphrase=None, + signed_headers=None, + signing_algorithm=None, + hash_algorithm=None, + signature_max_validity=None): + self.key_id = key_id + if signing_scheme not in {SCHEME_HS2019, SCHEME_RSA_SHA256, SCHEME_RSA_SHA512}: + raise Exception("Unsupported security scheme: {0}".format(signing_scheme)) + self.signing_scheme = signing_scheme + if not os.path.exists(private_key_path): + raise Exception("Private key file does not exist") + self.private_key_path = private_key_path + self.private_key_passphrase = private_key_passphrase + self.signing_algorithm = signing_algorithm + self.hash_algorithm = hash_algorithm + if signing_scheme == SCHEME_RSA_SHA256: + if self.hash_algorithm is None: + self.hash_algorithm = HASH_SHA256 + elif self.hash_algorithm != HASH_SHA256: + raise Exception("Hash algorithm must be sha256 when security scheme is %s" % + SCHEME_RSA_SHA256) + elif signing_scheme == SCHEME_RSA_SHA512: + if self.hash_algorithm is None: + self.hash_algorithm = HASH_SHA512 + elif self.hash_algorithm != HASH_SHA512: + raise Exception("Hash algorithm must be sha512 when security scheme is %s" % + SCHEME_RSA_SHA512) + elif signing_scheme == SCHEME_HS2019: + if self.hash_algorithm is None: + self.hash_algorithm = HASH_SHA256 + elif self.hash_algorithm not in {HASH_SHA256, HASH_SHA512}: + raise Exception("Invalid hash algorithm") + if signature_max_validity is not None and signature_max_validity.total_seconds() < 0: + raise Exception("The signature max validity must be a positive value") + self.signature_max_validity = signature_max_validity + # If the user has not provided any signed_headers, the default must be set to '(created)', + # as specified in the 'HTTP signature' standard. + if signed_headers is None or len(signed_headers) == 0: + signed_headers = [HEADER_CREATED] + if self.signature_max_validity is None and HEADER_EXPIRES in signed_headers: + raise Exception( + "Signature max validity must be set when " + "'(expires)' signature parameter is specified") + if len(signed_headers) != len(set(signed_headers)): + raise Exception("Cannot have duplicates in the signed_headers parameter") + if HEADER_AUTHORIZATION in signed_headers: + raise Exception("'Authorization' header cannot be included in signed headers") + self.signed_headers = signed_headers + self.private_key = None + """The private key used to sign HTTP requests. + Initialized when the PEM-encoded private key is loaded from a file. + """ + self.host = None + """The host name, optionally followed by a colon and TCP port number. + """ + self._load_private_key() + + def get_http_signature_headers(self, resource_path, method, headers, body, query_params): + """Create a cryptographic message signature for the HTTP request and add the signed headers. + + :param resource_path : A string representation of the HTTP request resource path. + :param method: A string representation of the HTTP request method, e.g. GET, POST. + :param headers: A dict containing the HTTP request headers. + :param body: The object representing the HTTP request body. + :param query_params: A string representing the HTTP request query parameters. + :return: A dict of HTTP headers that must be added to the outbound HTTP request. + """ + if method is None: + raise Exception("HTTP method must be set") + if resource_path is None: + raise Exception("Resource path must be set") + + signed_headers_list, request_headers_dict = self._get_signed_header_info( + resource_path, method, headers, body, query_params) + + header_items = [ + "{0}: {1}".format(key.lower(), value) for key, value in signed_headers_list] + string_to_sign = "\n".join(header_items) + + digest, digest_prefix = self._get_message_digest(string_to_sign.encode()) + b64_signed_msg = self._sign_digest(digest) + + request_headers_dict[HEADER_AUTHORIZATION] = self._get_authorization_header( + signed_headers_list, b64_signed_msg) + + return request_headers_dict + + def get_public_key(self): + """Returns the public key object associated with the private key. + """ + pubkey = None + if isinstance(self.private_key, RSA.RsaKey): + pubkey = self.private_key.publickey() + elif isinstance(self.private_key, ECC.EccKey): + pubkey = self.private_key.public_key() + return pubkey + + def _load_private_key(self): + """Load the private key used to sign HTTP requests. + The private key is used to sign HTTP requests as defined in + https://datatracker.ietf.org/doc/draft-cavage-http-signatures/. + """ + if self.private_key is not None: + return + with open(self.private_key_path, 'r') as f: + pem_data = f.read() + # Verify PEM Pre-Encapsulation Boundary + r = re.compile(r"\s*-----BEGIN (.*)-----\s+") + m = r.match(pem_data) + if not m: + raise ValueError("Not a valid PEM pre boundary") + pem_header = m.group(1) + if pem_header == 'RSA PRIVATE KEY': + self.private_key = RSA.importKey(pem_data, self.private_key_passphrase) + elif pem_header == 'EC PRIVATE KEY': + self.private_key = ECC.import_key(pem_data, self.private_key_passphrase) + elif pem_header in {'PRIVATE KEY', 'ENCRYPTED PRIVATE KEY'}: + # Key is in PKCS8 format, which is capable of holding many different + # types of private keys, not just EC keys. + (key_binary, pem_header, is_encrypted) = \ + PEM.decode(pem_data, self.private_key_passphrase) + (oid, privkey, params) = \ + PKCS8.unwrap(key_binary, passphrase=self.private_key_passphrase) + if oid == '1.2.840.10045.2.1': + self.private_key = ECC.import_key(pem_data, self.private_key_passphrase) + else: + raise Exception("Unsupported key: {0}. OID: {1}".format(pem_header, oid)) + else: + raise Exception("Unsupported key: {0}".format(pem_header)) + # Validate the specified signature algorithm is compatible with the private key. + if self.signing_algorithm is not None: + supported_algs = None + if isinstance(self.private_key, RSA.RsaKey): + supported_algs = {ALGORITHM_RSASSA_PSS, ALGORITHM_RSASSA_PKCS1v15} + elif isinstance(self.private_key, ECC.EccKey): + supported_algs = ALGORITHM_ECDSA_KEY_SIGNING_ALGORITHMS + if supported_algs is not None and self.signing_algorithm not in supported_algs: + raise Exception( + "Signing algorithm {0} is not compatible with private key".format( + self.signing_algorithm)) + + def _get_signed_header_info(self, resource_path, method, headers, body, query_params): + """Build the HTTP headers (name, value) that need to be included in + the HTTP signature scheme. + + :param resource_path : A string representation of the HTTP request resource path. + :param method: A string representation of the HTTP request method, e.g. GET, POST. + :param headers: A dict containing the HTTP request headers. + :param body: The object (e.g. a dict) representing the HTTP request body. + :param query_params: A string representing the HTTP request query parameters. + :return: A tuple containing two dict objects: + The first dict contains the HTTP headers that are used to calculate + the HTTP signature. + The second dict contains the HTTP headers that must be added to + the outbound HTTP request. + """ + + if body is None: + body = '' + else: + body = json.dumps(body) + + # Build the '(request-target)' HTTP signature parameter. + target_host = urlparse(self.host).netloc + target_path = urlparse(self.host).path + request_target = method.lower() + " " + target_path + resource_path + if query_params: + request_target += "?" + urlencode(query_params) + + # Get UNIX time, e.g. seconds since epoch, not including leap seconds. + now = time() + # Format date per RFC 7231 section-7.1.1.2. An example is: + # Date: Wed, 21 Oct 2015 07:28:00 GMT + cdate = formatdate(timeval=now, localtime=False, usegmt=True) + # The '(created)' value MUST be a Unix timestamp integer value. + # Subsecond precision is not supported. + created = int(now) + if self.signature_max_validity is not None: + expires = now + self.signature_max_validity.total_seconds() + + signed_headers_list = [] + request_headers_dict = {} + for hdr_key in self.signed_headers: + hdr_key = hdr_key.lower() + if hdr_key == HEADER_REQUEST_TARGET: + value = request_target + elif hdr_key == HEADER_CREATED: + value = '{0}'.format(created) + elif hdr_key == HEADER_EXPIRES: + value = '{0}'.format(expires) + elif hdr_key == HEADER_DATE.lower(): + value = cdate + request_headers_dict[HEADER_DATE] = '{0}'.format(cdate) + elif hdr_key == HEADER_DIGEST.lower(): + request_body = body.encode() + body_digest, digest_prefix = self._get_message_digest(request_body) + b64_body_digest = b64encode(body_digest.digest()) + value = digest_prefix + b64_body_digest.decode('ascii') + request_headers_dict[HEADER_DIGEST] = '{0}{1}'.format( + digest_prefix, b64_body_digest.decode('ascii')) + elif hdr_key == HEADER_HOST.lower(): + value = target_host + request_headers_dict[HEADER_HOST] = '{0}'.format(target_host) + else: + value = next((v for k, v in headers.items() if k.lower() == hdr_key), None) + if value is None: + raise Exception( + "Cannot sign HTTP request. " + "Request does not contain the '{0}' header".format(hdr_key)) + signed_headers_list.append((hdr_key, value)) + + return signed_headers_list, request_headers_dict + + def _get_message_digest(self, data): + """Calculates and returns a cryptographic digest of a specified HTTP request. + + :param data: The string representation of the date to be hashed with a cryptographic hash. + :return: A tuple of (digest, prefix). + The digest is a hashing object that contains the cryptographic digest of + the HTTP request. + The prefix is a string that identifies the cryptographc hash. It is used + to generate the 'Digest' header as specified in RFC 3230. + """ + if self.hash_algorithm == HASH_SHA512: + digest = SHA512.new() + prefix = 'SHA-512=' + elif self.hash_algorithm == HASH_SHA256: + digest = SHA256.new() + prefix = 'SHA-256=' + else: + raise Exception("Unsupported hash algorithm: {0}".format(self.hash_algorithm)) + digest.update(data) + return digest, prefix + + def _sign_digest(self, digest): + """Signs a message digest with a private key specified in the signing_info. + + :param digest: A hashing object that contains the cryptographic digest of the HTTP request. + :return: A base-64 string representing the cryptographic signature of the input digest. + """ + sig_alg = self.signing_algorithm + if isinstance(self.private_key, RSA.RsaKey): + if sig_alg is None or sig_alg == ALGORITHM_RSASSA_PSS: + # RSASSA-PSS in Section 8.1 of RFC8017. + signature = pss.new(self.private_key).sign(digest) + elif sig_alg == ALGORITHM_RSASSA_PKCS1v15: + # RSASSA-PKCS1-v1_5 in Section 8.2 of RFC8017. + signature = PKCS1_v1_5.new(self.private_key).sign(digest) + else: + raise Exception("Unsupported signature algorithm: {0}".format(sig_alg)) + elif isinstance(self.private_key, ECC.EccKey): + if sig_alg is None: + sig_alg = ALGORITHM_ECDSA_MODE_FIPS_186_3 + if sig_alg in ALGORITHM_ECDSA_KEY_SIGNING_ALGORITHMS: + # draft-ietf-httpbis-message-signatures-00 does not specify the ECDSA encoding. + # Issue: https://github.com/w3c-ccg/http-signatures/issues/107 + signature = DSS.new(key=self.private_key, mode=sig_alg, + encoding='der').sign(digest) + else: + raise Exception("Unsupported signature algorithm: {0}".format(sig_alg)) + else: + raise Exception("Unsupported private key: {0}".format(type(self.private_key))) + return b64encode(signature) + + def _get_authorization_header(self, signed_headers, signed_msg): + """Calculates and returns the value of the 'Authorization' header when signing HTTP requests. + + :param signed_headers : A list of tuples. Each value is the name of a HTTP header that + must be included in the HTTP signature calculation. + :param signed_msg: A base-64 encoded string representation of the signature. + :return: The string value of the 'Authorization' header, representing the signature + of the HTTP request. + """ + created_ts = None + expires_ts = None + for k, v in signed_headers: + if k == HEADER_CREATED: + created_ts = v + elif k == HEADER_EXPIRES: + expires_ts = v + lower_keys = [k.lower() for k, v in signed_headers] + headers_value = " ".join(lower_keys) + + auth_str = "Signature keyId=\"{0}\",algorithm=\"{1}\",".format( + self.key_id, self.signing_scheme) + if created_ts is not None: + auth_str = auth_str + "created={0},".format(created_ts) + if expires_ts is not None: + auth_str = auth_str + "expires={0},".format(expires_ts) + auth_str = auth_str + "headers=\"{0}\",signature=\"{1}\"".format( + headers_value, signed_msg.decode('ascii')) + + return auth_str diff --git a/codegen/openapi/templates5.2.0/test-requirements.mustache b/codegen/openapi/templates5.2.0/test-requirements.mustache new file mode 100644 index 000000000..635b816e7 --- /dev/null +++ b/codegen/openapi/templates5.2.0/test-requirements.mustache @@ -0,0 +1,13 @@ +{{#useNose}} +coverage>=4.0.3 +nose>=1.3.7 +pluggy>=0.3.1 +py>=1.4.31 +randomize>=0.13 +{{/useNose}} +{{^useNose}} +pytest-cov>=2.8.1 +{{/useNose}} +{{#hasHttpSignatureMethods}} +pycryptodome>=3.9.0 +{{/hasHttpSignatureMethods}} diff --git a/codegen/openapi/templates5.2.0/tornado/rest.mustache b/codegen/openapi/templates5.2.0/tornado/rest.mustache new file mode 100644 index 000000000..26c633504 --- /dev/null +++ b/codegen/openapi/templates5.2.0/tornado/rest.mustache @@ -0,0 +1,222 @@ +{{>partial_header}} + +import io +import json +import logging +import re + +# python 2 and python 3 compatibility library +from six.moves.urllib.parse import urlencode +import tornado +import tornado.gen +from tornado import httpclient +from urllib3.filepost import encode_multipart_formdata + +from {{packageName}}.exceptions import PineconeApiException, PineconeApiValueError + +logger = logging.getLogger(__name__) + + +class RESTResponse(io.IOBase): + + def __init__(self, resp): + self.tornado_response = resp + self.status = resp.code + self.reason = resp.reason + + if resp.body: + self.data = resp.body + else: + self.data = None + + def getheaders(self): + """Returns a CIMultiDictProxy of the response headers.""" + return self.tornado_response.headers + + def getheader(self, name, default=None): + """Returns a given response header.""" + return self.tornado_response.headers.get(name, default) + + +class RESTClientObject(object): + + def __init__(self, configuration, pools_size=4, maxsize=4): + # maxsize is number of requests to host that are allowed in parallel + + self.ca_certs = configuration.ssl_ca_cert + self.client_key = configuration.key_file + self.client_cert = configuration.cert_file + + self.proxy_port = self.proxy_host = None + + # https pool manager + if configuration.proxy: + self.proxy_port = 80 + self.proxy_host = configuration.proxy + + self.pool_manager = httpclient.AsyncHTTPClient() + + @tornado.gen.coroutine + def request(self, method, url, query_params=None, headers=None, body=None, + post_params=None, _preload_content=True, + _request_timeout=None): + """Execute Request + + :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: this is a non-applicable field for + the AiohttpClient. + :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 PineconeApiValueError( + "body parameter cannot be used with post_params parameter." + ) + + request = httpclient.HTTPRequest(url) + request.allow_nonstandard_methods = True + request.ca_certs = self.ca_certs + request.client_key = self.client_key + request.client_cert = self.client_cert + request.proxy_host = self.proxy_host + request.proxy_port = self.proxy_port + request.method = method + if headers: + request.headers = headers + if 'Content-Type' not in headers: + request.headers['Content-Type'] = 'application/json' + request.request_timeout = _request_timeout or 5 * 60 + + post_params = post_params or {} + + if query_params: + request.url += '?' + urlencode(query_params) + + # For `POST`, `PUT`, `PATCH`, `OPTIONS`, `DELETE` + if method in ['POST', 'PUT', 'PATCH', 'OPTIONS', 'DELETE']: + if re.search('json', headers['Content-Type'], re.IGNORECASE): + if body: + body = json.dumps(body) + request.body = body + elif headers['Content-Type'] == 'application/x-www-form-urlencoded': # noqa: E501 + request.body = urlencode(post_params) + elif headers['Content-Type'] == 'multipart/form-data': + multipart = encode_multipart_formdata(post_params) + request.body, headers['Content-Type'] = multipart + # Pass a `bytes` parameter directly in the body to support + # other content types than Json when `body` argument is provided + # in serialized form + elif isinstance(body, bytes): + request.body = body + 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 PineconeApiException(status=0, reason=msg) + + r = yield self.pool_manager.fetch(request, raise_error=False) + + if _preload_content: + + r = RESTResponse(r) + + # log response body + logger.debug("response body: %s", r.data) + + if not 200 <= r.status <= 299: + raise PineconeApiException(http_resp=r) + + raise tornado.gen.Return(r) + + @tornado.gen.coroutine + def GET(self, url, headers=None, query_params=None, _preload_content=True, + _request_timeout=None): + result = yield self.request("GET", url, + headers=headers, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + query_params=query_params) + raise tornado.gen.Return(result) + + @tornado.gen.coroutine + def HEAD(self, url, headers=None, query_params=None, _preload_content=True, + _request_timeout=None): + result = yield self.request("HEAD", url, + headers=headers, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + query_params=query_params) + raise tornado.gen.Return(result) + + @tornado.gen.coroutine + def OPTIONS(self, url, headers=None, query_params=None, post_params=None, + body=None, _preload_content=True, _request_timeout=None): + result = yield self.request("OPTIONS", url, + headers=headers, + query_params=query_params, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + raise tornado.gen.Return(result) + + @tornado.gen.coroutine + def DELETE(self, url, headers=None, query_params=None, body=None, + _preload_content=True, _request_timeout=None): + result = yield self.request("DELETE", url, + headers=headers, + query_params=query_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + raise tornado.gen.Return(result) + + @tornado.gen.coroutine + def POST(self, url, headers=None, query_params=None, post_params=None, + body=None, _preload_content=True, _request_timeout=None): + result = yield self.request("POST", url, + headers=headers, + query_params=query_params, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + raise tornado.gen.Return(result) + + @tornado.gen.coroutine + def PUT(self, url, headers=None, query_params=None, post_params=None, + body=None, _preload_content=True, _request_timeout=None): + result = yield self.request("PUT", url, + headers=headers, + query_params=query_params, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + raise tornado.gen.Return(result) + + @tornado.gen.coroutine + def PATCH(self, url, headers=None, query_params=None, post_params=None, + body=None, _preload_content=True, _request_timeout=None): + result = yield self.request("PATCH", url, + headers=headers, + query_params=query_params, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + raise tornado.gen.Return(result) diff --git a/codegen/openapi/templates5.2.0/tox.mustache b/codegen/openapi/templates5.2.0/tox.mustache new file mode 100644 index 000000000..4c771c472 --- /dev/null +++ b/codegen/openapi/templates5.2.0/tox.mustache @@ -0,0 +1,9 @@ +[tox] +envlist = py3 + +[testenv] +deps=-r{toxinidir}/requirements.txt + -r{toxinidir}/test-requirements.txt + +commands= + {{^useNose}}pytest --cov={{{packageName}}}{{/useNose}}{{#useNose}}nosetests{{/useNose}} diff --git a/codegen/openapi/templates5.2.0/travis.mustache b/codegen/openapi/templates5.2.0/travis.mustache new file mode 100644 index 000000000..a26c984f3 --- /dev/null +++ b/codegen/openapi/templates5.2.0/travis.mustache @@ -0,0 +1,18 @@ +# ref: https://docs.travis-ci.com/user/languages/python +language: python +python: + - "3.6" + - "3.7" + - "3.8" + - "3.9" +# command to install dependencies +install: + - "pip install -r requirements.txt" + - "pip install -r test-requirements.txt" +# command to run tests +{{#useNose}} +script: nosetests +{{/useNose}} +{{^useNose}} +script: pytest --cov={{{packageName}}} +{{/useNose}} From c13abc9896689d085bd7aa97399a899c692f8b2d Mon Sep 17 00:00:00 2001 From: Jen Hamon Date: Thu, 7 Mar 2024 04:53:32 -0500 Subject: [PATCH 2/6] Remove problematic param --- Makefile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Makefile b/Makefile index 4218f933d..3f687f6b9 100644 --- a/Makefile +++ b/Makefile @@ -12,6 +12,10 @@ clean: regenerate: clean mkdir downloads gcloud storage cp gs://api-codegen/_latest downloads --recursive + + # Remove problematic query param + jq 'walk(if type == "array" then map(if type == "object" then select(.name != "filter") else . end) else . end)' downloads/_latest/openapi/pinecone_api.json > tmp.json + mv tmp.json downloads/_latest/openapi/pinecone_api.json # Generate new openapi rest client rm -rf pinecone/core From 1bcf5cf2b64a1c5cf020b995612f6bec8d0d1b38 Mon Sep 17 00:00:00 2001 From: Jen Hamon Date: Thu, 7 Mar 2024 03:38:40 -0500 Subject: [PATCH 3/6] Regenerate --- pinecone/core/client/api/data_plane_api.py | 29 +- pinecone/core/client/model/delete_request.py | 2 - pinecone/core/client/model/protobuf_any.py | 12 +- .../core/client/model/protobuf_null_value.py | 8 +- pinecone/core/client/model/query_request.py | 4 - pinecone/core/client/model/query_vector.py | 2 - pinecone/core/client/model/sparse_values.py | 4 - pinecone/core/client/model/update_request.py | 2 - pinecone/core/client/model/upsert_request.py | 2 - pinecone/core/client/model/vector.py | 2 - .../core/grpc/protos/vector_service_pb2.py | 1819 ++--------------- .../core/grpc/protos/vector_service_pb2.pyi | 1042 ++++++---- .../grpc/protos/vector_service_pb2_grpc.py | 88 +- 13 files changed, 888 insertions(+), 2128 deletions(-) diff --git a/pinecone/core/client/api/data_plane_api.py b/pinecone/core/client/api/data_plane_api.py index b4ad0548a..32ed8c6d6 100644 --- a/pinecone/core/client/api/data_plane_api.py +++ b/pinecone/core/client/api/data_plane_api.py @@ -33,6 +33,7 @@ from pinecone.core.client.model.update_request import UpdateRequest from pinecone.core.client.model.upsert_request import UpsertRequest from pinecone.core.client.model.upsert_response import UpsertResponse +from pinecone.core.client.model.str_bool_date_datetime_dict_float_int_list_str_none_type import StrBoolDateDatetimeDictFloatIntListStrNoneType class DataPlaneApi(object): @@ -65,6 +66,7 @@ def __alt_delete( ids ([str]): Vectors to delete.. [optional] delete_all (bool): This indicates that all vectors in the index namespace should be deleted.. [optional] if omitted the server will use the default value of False namespace (str): The namespace to delete vectors from, if applicable.. [optional] + filter ({str: (bool, date, datetime, dict, float, int, list, str, none_type)}): If specified, the metadata filter here will be used to select the vectors to delete. This is mutually exclusive with specifying ids to delete in the ids param or using delete_all=True. See https://www.pinecone.io/docs/metadata-filtering/.. [optional] _return_http_data_only (bool): response data without head status code and headers. Default is True. _preload_content (bool): if False, the urllib3.HTTPResponse object @@ -127,6 +129,7 @@ def __alt_delete( 'ids', 'delete_all', 'namespace', + 'filter', ], 'required': [], 'nullable': [ @@ -148,16 +151,20 @@ def __alt_delete( (bool,), 'namespace': (str,), + 'filter': + ({str: (bool, date, datetime, dict, float, int, list, str, none_type)},), }, 'attribute_map': { 'ids': 'ids', 'delete_all': 'deleteAll', 'namespace': 'namespace', + 'filter': 'filter', }, 'location_map': { 'ids': 'query', 'delete_all': 'query', 'namespace': 'query', + 'filter': 'query', }, 'collection_format_map': { 'ids': 'multi', @@ -188,6 +195,7 @@ def __alt_describe_index_stats( Keyword Args: + filter ({str: (bool, date, datetime, dict, float, int, list, str, none_type)}): If this parameter is present, the operation only returns statistics for vectors that satisfy the filter. See https://www.pinecone.io/docs/metadata-filtering/.. [optional] _return_http_data_only (bool): response data without head status code and headers. Default is True. _preload_content (bool): if False, the urllib3.HTTPResponse object @@ -247,6 +255,7 @@ def __alt_describe_index_stats( }, params_map={ 'all': [ + 'filter', ], 'required': [], 'nullable': [ @@ -262,10 +271,14 @@ def __alt_describe_index_stats( 'allowed_values': { }, 'openapi_types': { + 'filter': + ({str: (bool, date, datetime, dict, float, int, list, str, none_type)},), }, 'attribute_map': { + 'filter': 'filter', }, 'location_map': { + 'filter': 'query', }, 'collection_format_map': { } @@ -295,7 +308,7 @@ def __delete( >>> result = thread.get() Args: - delete_request (DeleteRequest): + delete_request (DeleteRequest): The request for the `Delete` operation. Keyword Args: _return_http_data_only (bool): response data without head status @@ -415,7 +428,7 @@ def __describe_index_stats( >>> result = thread.get() Args: - describe_index_stats_request (DescribeIndexStatsRequest): + describe_index_stats_request (DescribeIndexStatsRequest): The request for the `describe_index_stats` operation. Keyword Args: _return_http_data_only (bool): response data without head status @@ -527,7 +540,7 @@ def __fetch( ): """Fetch vectors # noqa: E501 - The `fetch` operation looks up and returns vectors, by ID, from a single namespace. The returned vectors include the vector data and/or metadata. For guidance and examples, see [Fetch data](https://docs.pinecone.io/reference/fetch). # noqa: E501 + The `fetch` operation looks up and returns vectors, by ID, from a single namespace. The returned vectors include the vector data and/or metadata. For guidance and examples, see [Fetch data](https://docs.pinecone.io/docs/fetch-data). # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True @@ -662,7 +675,7 @@ def __list( Keyword Args: prefix (str): The vector IDs to fetch. Does not accept values containing spaces.. [optional] - limit (int): Max number of ids to return.. [optional] + limit (int): Max number of IDs to return per page.. [optional] pagination_token (str): Pagination token to continue a previous listing operation.. [optional] namespace (str): [optional] _return_http_data_only (bool): response data without head status @@ -792,7 +805,7 @@ def __query( >>> result = thread.get() Args: - query_request (QueryRequest): + query_request (QueryRequest): The request for the `query` operation. Keyword Args: _return_http_data_only (bool): response data without head status @@ -904,7 +917,7 @@ def __update( ): """Update a vector # noqa: E501 - The `update` operation updates a vector in a namespace. If a value is included, it will overwrite the previous value. If a `set_metadata` is included, the values of the fields specified in it will be added or overwrite the previous value. For guidance and examples, see [Update data](https://docs.pinecone.io/reference/update). # noqa: E501 + The `update` operation updates a vector in a namespace. If a value is included, it will overwrite the previous value. If a `set_metadata` is included, the values of the fields specified in it will be added or overwrite the previous value. For guidance and examples, see [Update data](https://docs.pinecone.io/docs/update-data). # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True @@ -912,7 +925,7 @@ def __update( >>> result = thread.get() Args: - update_request (UpdateRequest): + update_request (UpdateRequest): The request for the `update` operation. Keyword Args: _return_http_data_only (bool): response data without head status @@ -1032,7 +1045,7 @@ def __upsert( >>> result = thread.get() Args: - upsert_request (UpsertRequest): + upsert_request (UpsertRequest): The request for the `upsert` operation. Keyword Args: _return_http_data_only (bool): response data without head status diff --git a/pinecone/core/client/model/delete_request.py b/pinecone/core/client/model/delete_request.py index b324c8d4f..8344beff0 100644 --- a/pinecone/core/client/model/delete_request.py +++ b/pinecone/core/client/model/delete_request.py @@ -59,8 +59,6 @@ class DeleteRequest(ModelNormal): } validations = { - ('ids',): { - }, } @cached_property diff --git a/pinecone/core/client/model/protobuf_any.py b/pinecone/core/client/model/protobuf_any.py index e35f81eb5..10765481a 100644 --- a/pinecone/core/client/model/protobuf_any.py +++ b/pinecone/core/client/model/protobuf_any.py @@ -82,8 +82,7 @@ def openapi_types(): and the value is attribute type. """ return { - 'type_url': (str,), # noqa: E501 - 'value': (str,), # noqa: E501 + 'type': (str,), # noqa: E501 } @cached_property @@ -92,8 +91,7 @@ def discriminator(): attribute_map = { - 'type_url': 'typeUrl', # noqa: E501 - 'value': 'value', # noqa: E501 + 'type': '@type', # noqa: E501 } read_only_vars = { @@ -137,8 +135,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,) - type_url (str): [optional] # noqa: E501 - value (str): [optional] # noqa: E501 + type (str): [optional] # noqa: E501 """ _check_type = kwargs.pop('_check_type', True) @@ -220,8 +217,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,) - type_url (str): [optional] # noqa: E501 - value (str): [optional] # noqa: E501 + type (str): [optional] # noqa: E501 """ _check_type = kwargs.pop('_check_type', True) diff --git a/pinecone/core/client/model/protobuf_null_value.py b/pinecone/core/client/model/protobuf_null_value.py index 7b5b0f1da..5d9894442 100644 --- a/pinecone/core/client/model/protobuf_null_value.py +++ b/pinecone/core/client/model/protobuf_null_value.py @@ -111,10 +111,10 @@ def __init__(self, *args, **kwargs): Note that value can be passed either in args or in kwargs, but not in both. Args: - args[0] (str): `NullValue` is a singleton enumeration to represent the null value for the `Value` type union. The JSON representation for `NullValue` is JSON `null`. - NULL_VALUE: Null value.. if omitted defaults to "NULL_VALUE", must be one of ["NULL_VALUE", ] # noqa: E501 + args[0] (str): `NullValue` is a singleton enumeration to represent the null value for the `Value` type union. The JSON representation for `NullValue` is JSON `null`. - NULL_VALUE: Null value.. if omitted defaults to "NULL_VALUE", must be one of ["NULL_VALUE", ] # noqa: E501 Keyword Args: - value (str): `NullValue` is a singleton enumeration to represent the null value for the `Value` type union. The JSON representation for `NullValue` is JSON `null`. - NULL_VALUE: Null value.. if omitted defaults to "NULL_VALUE", must be one of ["NULL_VALUE", ] # noqa: E501 + value (str): `NullValue` is a singleton enumeration to represent the null value for the `Value` type union. The JSON representation for `NullValue` is JSON `null`. - NULL_VALUE: Null value.. if omitted defaults to "NULL_VALUE", must be one of ["NULL_VALUE", ] # 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. @@ -197,10 +197,10 @@ def _from_openapi_data(cls, *args, **kwargs): Note that value can be passed either in args or in kwargs, but not in both. Args: - args[0] (str): `NullValue` is a singleton enumeration to represent the null value for the `Value` type union. The JSON representation for `NullValue` is JSON `null`. - NULL_VALUE: Null value.. if omitted defaults to "NULL_VALUE", must be one of ["NULL_VALUE", ] # noqa: E501 + args[0] (str): `NullValue` is a singleton enumeration to represent the null value for the `Value` type union. The JSON representation for `NullValue` is JSON `null`. - NULL_VALUE: Null value.. if omitted defaults to "NULL_VALUE", must be one of ["NULL_VALUE", ] # noqa: E501 Keyword Args: - value (str): `NullValue` is a singleton enumeration to represent the null value for the `Value` type union. The JSON representation for `NullValue` is JSON `null`. - NULL_VALUE: Null value.. if omitted defaults to "NULL_VALUE", must be one of ["NULL_VALUE", ] # noqa: E501 + value (str): `NullValue` is a singleton enumeration to represent the null value for the `Value` type union. The JSON representation for `NullValue` is JSON `null`. - NULL_VALUE: Null value.. if omitted defaults to "NULL_VALUE", must be one of ["NULL_VALUE", ] # 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. diff --git a/pinecone/core/client/model/query_request.py b/pinecone/core/client/model/query_request.py index 1e2c6466a..8f1a812a0 100644 --- a/pinecone/core/client/model/query_request.py +++ b/pinecone/core/client/model/query_request.py @@ -69,10 +69,6 @@ class QueryRequest(ModelNormal): 'inclusive_maximum': 10000, 'inclusive_minimum': 1, }, - ('queries',): { - }, - ('vector',): { - }, ('id',): { 'max_length': 512, }, diff --git a/pinecone/core/client/model/query_vector.py b/pinecone/core/client/model/query_vector.py index eed194e63..fbf8c18b1 100644 --- a/pinecone/core/client/model/query_vector.py +++ b/pinecone/core/client/model/query_vector.py @@ -63,8 +63,6 @@ class QueryVector(ModelNormal): } validations = { - ('values',): { - }, ('top_k',): { 'inclusive_maximum': 10000, 'inclusive_minimum': 1, diff --git a/pinecone/core/client/model/sparse_values.py b/pinecone/core/client/model/sparse_values.py index a001217bb..b63f80c29 100644 --- a/pinecone/core/client/model/sparse_values.py +++ b/pinecone/core/client/model/sparse_values.py @@ -59,10 +59,6 @@ class SparseValues(ModelNormal): } validations = { - ('indices',): { - }, - ('values',): { - }, } @cached_property diff --git a/pinecone/core/client/model/update_request.py b/pinecone/core/client/model/update_request.py index fc94d0312..f720aa8b1 100644 --- a/pinecone/core/client/model/update_request.py +++ b/pinecone/core/client/model/update_request.py @@ -67,8 +67,6 @@ class UpdateRequest(ModelNormal): 'max_length': 512, 'min_length': 1, }, - ('values',): { - }, } @cached_property diff --git a/pinecone/core/client/model/upsert_request.py b/pinecone/core/client/model/upsert_request.py index 980f734c2..e33a55344 100644 --- a/pinecone/core/client/model/upsert_request.py +++ b/pinecone/core/client/model/upsert_request.py @@ -63,8 +63,6 @@ class UpsertRequest(ModelNormal): } validations = { - ('vectors',): { - }, } @cached_property diff --git a/pinecone/core/client/model/vector.py b/pinecone/core/client/model/vector.py index 63fed80e6..2e737096d 100644 --- a/pinecone/core/client/model/vector.py +++ b/pinecone/core/client/model/vector.py @@ -67,8 +67,6 @@ class Vector(ModelNormal): 'max_length': 512, 'min_length': 1, }, - ('values',): { - }, } @cached_property diff --git a/pinecone/core/grpc/protos/vector_service_pb2.py b/pinecone/core/grpc/protos/vector_service_pb2.py index 6982eab57..45e2844bc 100644 --- a/pinecone/core/grpc/protos/vector_service_pb2.py +++ b/pinecone/core/grpc/protos/vector_service_pb2.py @@ -1,11 +1,12 @@ # -*- coding: utf-8 -*- # Generated by the protocol buffer compiler. DO NOT EDIT! -# source: vector_service.proto +# source: pinecone/data/v1/vector_service.proto +# Protobuf Python Version: 4.25.3 """Generated protocol buffer code.""" from google.protobuf import descriptor as _descriptor -from google.protobuf import message as _message -from google.protobuf import reflection as _reflection +from google.protobuf import descriptor_pool as _descriptor_pool from google.protobuf import symbol_database as _symbol_database +from google.protobuf.internal import builder as _builder # @@protoc_insertion_point(imports) _sym_db = _symbol_database.Default() @@ -17,1630 +18,190 @@ from protoc_gen_openapiv2.options import annotations_pb2 as protoc__gen__openapiv2_dot_options_dot_annotations__pb2 -DESCRIPTOR = _descriptor.FileDescriptor( - name='vector_service.proto', - package='', - syntax='proto3', - serialized_options=b'\n\021io.pinecone.protoP\001Z+github.com/pinecone-io/go-pinecone/pinecone\222A\311\002\022K\n\014Pinecone API\";\n\017Pinecone.io Ops\022\023https://pinecone.io\032\023support@pinecone.io\032\014{index_host}*\001\0022\020application/json:\020application/jsonZx\nv\n\nApiKeyAuth\022h\010\002\022YAn API Key is required to call Pinecone APIs. Get yours at https://www.pinecone.io/start/\032\007Api-Key \002b\020\n\016\n\nApiKeyAuth\022\000r9\n\031More Pinecone.io API docs\022\034https://www.pinecone.io/docs', - create_key=_descriptor._internal_create_key, - serialized_pb=b'\n\x14vector_service.proto\x1a\x1cgoogle/protobuf/struct.proto\x1a\x1cgoogle/api/annotations.proto\x1a\x1fgoogle/api/field_behavior.proto\x1a.protoc-gen-openapiv2/options/annotations.proto\"~\n\x0cSparseValues\x12\x35\n\x07indices\x18\x01 \x03(\rB$\x92\x41\x1eJ\x16[1, 312, 822, 14, 980]x\xe8\x07\x80\x01\x01\xe0\x41\x02\x12\x37\n\x06values\x18\x02 \x03(\x02\x42\'\x92\x41!J\x19[0.1, 0.2, 0.3, 0.4, 0.5]x\xe8\x07\x80\x01\x01\xe0\x41\x02\"\xfd\x01\n\x06Vector\x12,\n\x02id\x18\x01 \x01(\tB \x92\x41\x1aJ\x12\"example-vector-1\"x\x80\x04\x80\x01\x01\xe0\x41\x02\x12G\n\x06values\x18\x02 \x03(\x02\x42\x37\x92\x41\x31J([0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8]x\xa0\x9c\x01\x80\x01\x01\xe0\x41\x02\x12$\n\rsparse_values\x18\x04 \x01(\x0b\x32\r.SparseValues\x12V\n\x08metadata\x18\x03 \x01(\x0b\x32\x17.google.protobuf.StructB+\x92\x41(J&{\"genre\": \"documentary\", \"year\": 2019}\"\x93\x02\n\x0cScoredVector\x12,\n\x02id\x18\x01 \x01(\tB \x92\x41\x1aJ\x12\"example-vector-1\"x\x80\x04\x80\x01\x01\xe0\x41\x02\x12\x18\n\x05score\x18\x02 \x01(\x02\x42\t\x92\x41\x06J\x04\x30.08\x12=\n\x06values\x18\x03 \x03(\x02\x42-\x92\x41*J([0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8]\x12$\n\rsparse_values\x18\x05 \x01(\x0b\x32\r.SparseValues\x12V\n\x08metadata\x18\x04 \x01(\x0b\x32\x17.google.protobuf.StructB+\x92\x41(J&{\"genre\": \"documentary\", \"year\": 2019}\"\x89\x01\n\x0cRequestUnion\x12 \n\x06upsert\x18\x01 \x01(\x0b\x32\x0e.UpsertRequestH\x00\x12 \n\x06\x64\x65lete\x18\x02 \x01(\x0b\x32\x0e.DeleteRequestH\x00\x12 \n\x06update\x18\x03 \x01(\x0b\x32\x0e.UpdateRequestH\x00\x42\x13\n\x11RequestUnionInner\"d\n\rUpsertRequest\x12&\n\x07vectors\x18\x01 \x03(\x0b\x32\x07.VectorB\x0c\x92\x41\x06x\xe8\x07\x80\x01\x01\xe0\x41\x02\x12+\n\tnamespace\x18\x02 \x01(\tB\x18\x92\x41\x15J\x13\"example-namespace\"\"1\n\x0eUpsertResponse\x12\x1f\n\x0eupserted_count\x18\x01 \x01(\rB\x07\x92\x41\x04J\x02\x31\x30\"\xb6\x01\n\rDeleteRequest\x12(\n\x03ids\x18\x01 \x03(\tB\x1b\x92\x41\x18J\x10[\"id-0\", \"id-1\"]x\xe8\x07\x80\x01\x01\x12%\n\ndelete_all\x18\x02 \x01(\x08\x42\x11\x92\x41\x0e:\x05\x66\x61lseJ\x05\x66\x61lse\x12+\n\tnamespace\x18\x03 \x01(\tB\x18\x92\x41\x15J\x13\"example-namespace\"\x12\'\n\x06\x66ilter\x18\x04 \x01(\x0b\x32\x17.google.protobuf.Struct\"\x10\n\x0e\x44\x65leteResponse\"h\n\x0c\x46\x65tchRequest\x12+\n\x03ids\x18\x01 \x03(\tB\x1e\x92\x41\x18J\x10[\"id-0\", \"id-1\"]x\xe8\x07\x80\x01\x01\xe0\x41\x02\x12+\n\tnamespace\x18\x02 \x01(\tB\x18\x92\x41\x15J\x13\"example-namespace\"\"\xe1\x01\n\rFetchResponse\x12,\n\x07vectors\x18\x01 \x03(\x0b\x32\x1b.FetchResponse.VectorsEntry\x12+\n\tnamespace\x18\x02 \x01(\tB\x18\x92\x41\x15J\x13\"example-namespace\"\x12\x32\n\x05usage\x18\x03 \x01(\x0b\x32\x06.UsageB\x16\x92\x41\x13J\x11{\"read_units\": 5}H\x00\x88\x01\x01\x1a\x37\n\x0cVectorsEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\x16\n\x05value\x18\x02 \x01(\x0b\x32\x07.Vector:\x02\x38\x01\x42\x08\n\x06_usage\"\xf8\x01\n\x0bListRequest\x12,\n\x06prefix\x18\x01 \x01(\tB\x17\x92\x41\x14J\x0c\"document1#\"x\xe8\x07\x80\x01\x01H\x00\x88\x01\x01\x12 \n\x05limit\x18\x02 \x01(\rB\x0c\x92\x41\t:\x03\x31\x30\x30J\x02\x31\x32H\x01\x88\x01\x01\x12\x42\n\x10pagination_token\x18\x03 \x01(\tB#\x92\x41 J\x1e\"Tm90aGluZyB0byBzZWUgaGVyZQo=\"H\x02\x88\x01\x01\x12+\n\tnamespace\x18\x04 \x01(\tB\x18\x92\x41\x15J\x13\"example-namespace\"B\t\n\x07_prefixB\x08\n\x06_limitB\x13\n\x11_pagination_token\"?\n\nPagination\x12\x31\n\x04next\x18\x01 \x01(\tB#\x92\x41 J\x1e\"Tm90aGluZyB0byBzZWUgaGVyZQo=\"\",\n\x08ListItem\x12 \n\x02id\x18\x01 \x01(\tB\x14\x92\x41\x11J\x0f\"document1#abb\"\"\x83\x02\n\x0cListResponse\x12S\n\x07vectors\x18\x01 \x03(\x0b\x32\t.ListItemB7\x92\x41\x34J2[{\"id\": \"document1#abb\"}, {\"id\": \"document1#abc\"}]\x12$\n\npagination\x18\x02 \x01(\x0b\x32\x0b.PaginationH\x00\x88\x01\x01\x12+\n\tnamespace\x18\x03 \x01(\tB\x18\x92\x41\x15J\x13\"example-namespace\"\x12\x32\n\x05usage\x18\x04 \x01(\x0b\x32\x06.UsageB\x16\x92\x41\x13J\x11{\"read_units\": 1}H\x01\x88\x01\x01\x42\r\n\x0b_paginationB\x08\n\x06_usage\"\xd0\x02\n\x0bQueryVector\x12G\n\x06values\x18\x01 \x03(\x02\x42\x37\x92\x41\x31J([0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8]x\xa0\x9c\x01\x80\x01\x01\xe0\x41\x02\x12$\n\rsparse_values\x18\x05 \x01(\x0b\x32\r.SparseValues\x12(\n\x05top_k\x18\x02 \x01(\rB\x19\x92\x41\x16J\x02\x31\x30Y\x00\x00\x00\x00\x00\x88\xc3@i\x00\x00\x00\x00\x00\x00\xf0?\x12+\n\tnamespace\x18\x03 \x01(\tB\x18\x92\x41\x15J\x13\"example-namespace\"\x12{\n\x06\x66ilter\x18\x04 \x01(\x0b\x32\x17.google.protobuf.StructBR\x92\x41OJM{\"genre\": {\"$in\": [\"comedy\", \"documentary\", \"drama\"]}, \"year\": {\"$eq\": 2019}}\"\xfa\x03\n\x0cQueryRequest\x12+\n\tnamespace\x18\x01 \x01(\tB\x18\x92\x41\x15J\x13\"example-namespace\"\x12+\n\x05top_k\x18\x02 \x01(\rB\x1c\x92\x41\x16J\x02\x31\x30Y\x00\x00\x00\x00\x00\x88\xc3@i\x00\x00\x00\x00\x00\x00\xf0?\xe0\x41\x02\x12{\n\x06\x66ilter\x18\x03 \x01(\x0b\x32\x17.google.protobuf.StructBR\x92\x41OJM{\"genre\": {\"$in\": [\"comedy\", \"documentary\", \"drama\"]}, \"year\": {\"$eq\": 2019}}\x12(\n\x0einclude_values\x18\x04 \x01(\x08\x42\x10\x92\x41\r:\x05\x66\x61lseJ\x04true\x12*\n\x10include_metadata\x18\x05 \x01(\x08\x42\x10\x92\x41\r:\x05\x66\x61lseJ\x04true\x12)\n\x07queries\x18\x06 \x03(\x0b\x32\x0c.QueryVectorB\n\x18\x01\x92\x41\x05x\n\x80\x01\x01\x12\x44\n\x06vector\x18\x07 \x03(\x02\x42\x34\x92\x41\x31J([0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8]x\xa0\x9c\x01\x80\x01\x01\x12$\n\rsparse_vector\x18\t \x01(\x0b\x32\r.SparseValues\x12&\n\x02id\x18\x08 \x01(\tB\x1a\x92\x41\x17J\x12\"example-vector-1\"x\x80\x04\"a\n\x12SingleQueryResults\x12\x1e\n\x07matches\x18\x01 \x03(\x0b\x32\r.ScoredVector\x12+\n\tnamespace\x18\x02 \x01(\tB\x18\x92\x41\x15J\x13\"example-namespace\"\"\xaa\x01\n\rQueryResponse\x12(\n\x07results\x18\x01 \x03(\x0b\x32\x13.SingleQueryResultsB\x02\x18\x01\x12\x1e\n\x07matches\x18\x02 \x03(\x0b\x32\r.ScoredVector\x12\x11\n\tnamespace\x18\x03 \x01(\t\x12\x32\n\x05usage\x18\x04 \x01(\x0b\x32\x06.UsageB\x16\x92\x41\x13J\x11{\"read_units\": 5}H\x00\x88\x01\x01\x42\x08\n\x06_usage\"7\n\x05Usage\x12\x1f\n\nread_units\x18\x01 \x01(\rB\x06\x92\x41\x03J\x01\x35H\x00\x88\x01\x01\x42\r\n\x0b_read_units\"\xb2\x02\n\rUpdateRequest\x12,\n\x02id\x18\x01 \x01(\tB \x92\x41\x1aJ\x12\"example-vector-1\"x\x80\x04\x80\x01\x01\xe0\x41\x02\x12\x44\n\x06values\x18\x02 \x03(\x02\x42\x34\x92\x41\x31J([0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8]x\xa0\x9c\x01\x80\x01\x01\x12$\n\rsparse_values\x18\x05 \x01(\x0b\x32\r.SparseValues\x12Z\n\x0cset_metadata\x18\x03 \x01(\x0b\x32\x17.google.protobuf.StructB+\x92\x41(J&{\"genre\": \"documentary\", \"year\": 2019}\x12+\n\tnamespace\x18\x04 \x01(\tB\x18\x92\x41\x15J\x13\"example-namespace\"\"\x10\n\x0eUpdateResponse\"D\n\x19\x44\x65scribeIndexStatsRequest\x12\'\n\x06\x66ilter\x18\x01 \x01(\x0b\x32\x17.google.protobuf.Struct\"4\n\x10NamespaceSummary\x12 \n\x0cvector_count\x18\x01 \x01(\rB\n\x92\x41\x07J\x05\x35\x30\x30\x30\x30\"\x9a\x03\n\x1a\x44\x65scribeIndexStatsResponse\x12?\n\nnamespaces\x18\x01 \x03(\x0b\x32+.DescribeIndexStatsResponse.NamespacesEntry\x12\x1c\n\tdimension\x18\x02 \x01(\rB\t\x92\x41\x06J\x04\x31\x30\x32\x34\x12 \n\x0eindex_fullness\x18\x03 \x01(\x02\x42\x08\x92\x41\x05J\x03\x30.4\x12&\n\x12total_vector_count\x18\x04 \x01(\rB\n\x92\x41\x07J\x05\x38\x30\x30\x30\x30\x1a\x44\n\x0fNamespacesEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12 \n\x05value\x18\x02 \x01(\x0b\x32\x11.NamespaceSummary:\x02\x38\x01:\x8c\x01\x92\x41\x88\x01\x32\x85\x01{\"namespaces\": {\"\": {\"vectorCount\": 50000}, \"example-namespace-2\": {\"vectorCount\": 30000}}, \"dimension\": 1024, \"index_fullness\": 0.4}2\x95\x06\n\rVectorService\x12\x63\n\x06Upsert\x12\x0e.UpsertRequest\x1a\x0f.UpsertResponse\"8\x82\xd3\xe4\x93\x02\x14\"\x0f/vectors/upsert:\x01*\x92\x41\x1b\n\x11Vector Operations*\x06upsert\x12v\n\x06\x44\x65lete\x12\x0e.DeleteRequest\x1a\x0f.DeleteResponse\"K\x82\xd3\xe4\x93\x02\'\"\x0f/vectors/delete:\x01*Z\x11*\x0f/vectors/delete\x92\x41\x1b\n\x11Vector Operations*\x06\x64\x65lete\x12[\n\x05\x46\x65tch\x12\r.FetchRequest\x1a\x0e.FetchResponse\"3\x82\xd3\xe4\x93\x02\x10\x12\x0e/vectors/fetch\x92\x41\x1a\n\x11Vector Operations*\x05\x66\x65tch\x12V\n\x04List\x12\x0c.ListRequest\x1a\r.ListResponse\"1\x82\xd3\xe4\x93\x02\x0f\x12\r/vectors/list\x92\x41\x19\n\x11Vector Operations*\x04list\x12V\n\x05Query\x12\r.QueryRequest\x1a\x0e.QueryResponse\".\x82\xd3\xe4\x93\x02\x0b\"\x06/query:\x01*\x92\x41\x1a\n\x11Vector Operations*\x05query\x12\x63\n\x06Update\x12\x0e.UpdateRequest\x1a\x0f.UpdateResponse\"8\x82\xd3\xe4\x93\x02\x14\"\x0f/vectors/update:\x01*\x92\x41\x1b\n\x11Vector Operations*\x06update\x12\xb4\x01\n\x12\x44\x65scribeIndexStats\x12\x1a.DescribeIndexStatsRequest\x1a\x1b.DescribeIndexStatsResponse\"e\x82\xd3\xe4\x93\x02\x33\"\x15/describe_index_stats:\x01*Z\x17\x12\x15/describe_index_stats\x92\x41)\n\x11Vector Operations*\x14\x64\x65scribe_index_statsB\x8f\x03\n\x11io.pinecone.protoP\x01Z+github.com/pinecone-io/go-pinecone/pinecone\x92\x41\xc9\x02\x12K\n\x0cPinecone API\";\n\x0fPinecone.io Ops\x12\x13https://pinecone.io\x1a\x13support@pinecone.io\x1a\x0c{index_host}*\x01\x02\x32\x10\x61pplication/json:\x10\x61pplication/jsonZx\nv\n\nApiKeyAuth\x12h\x08\x02\x12YAn API Key is required to call Pinecone APIs. Get yours at https://www.pinecone.io/start/\x1a\x07\x41pi-Key \x02\x62\x10\n\x0e\n\nApiKeyAuth\x12\x00r9\n\x19More Pinecone.io API docs\x12\x1chttps://www.pinecone.io/docsb\x06proto3' - , - dependencies=[google_dot_protobuf_dot_struct__pb2.DESCRIPTOR,google_dot_api_dot_annotations__pb2.DESCRIPTOR,google_dot_api_dot_field__behavior__pb2.DESCRIPTOR,protoc__gen__openapiv2_dot_options_dot_annotations__pb2.DESCRIPTOR,]) - - - - -_SPARSEVALUES = _descriptor.Descriptor( - name='SparseValues', - full_name='SparseValues', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='indices', full_name='SparseValues.indices', index=0, - number=1, type=13, cpp_type=3, label=3, - has_default_value=False, default_value=[], - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=b'\222A\036J\026[1, 312, 822, 14, 980]x\350\007\200\001\001\340A\002', file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='values', full_name='SparseValues.values', index=1, - number=2, type=2, cpp_type=6, label=3, - has_default_value=False, default_value=[], - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=b'\222A!J\031[0.1, 0.2, 0.3, 0.4, 0.5]x\350\007\200\001\001\340A\002', file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - ], - extensions=[ - ], - nested_types=[], - enum_types=[ - ], - serialized_options=None, - is_extendable=False, - syntax='proto3', - extension_ranges=[], - oneofs=[ - ], - serialized_start=165, - serialized_end=291, -) - - -_VECTOR = _descriptor.Descriptor( - name='Vector', - full_name='Vector', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='id', full_name='Vector.id', index=0, - number=1, type=9, cpp_type=9, label=1, - has_default_value=False, default_value=b"".decode('utf-8'), - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=b'\222A\032J\022\"example-vector-1\"x\200\004\200\001\001\340A\002', file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='values', full_name='Vector.values', index=1, - number=2, type=2, cpp_type=6, label=3, - has_default_value=False, default_value=[], - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=b'\222A1J([0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8]x\240\234\001\200\001\001\340A\002', file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='sparse_values', full_name='Vector.sparse_values', index=2, - number=4, type=11, cpp_type=10, label=1, - has_default_value=False, default_value=None, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='metadata', full_name='Vector.metadata', index=3, - number=3, type=11, cpp_type=10, label=1, - has_default_value=False, default_value=None, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=b'\222A(J&{\"genre\": \"documentary\", \"year\": 2019}', file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - ], - extensions=[ - ], - nested_types=[], - enum_types=[ - ], - serialized_options=None, - is_extendable=False, - syntax='proto3', - extension_ranges=[], - oneofs=[ - ], - serialized_start=294, - serialized_end=547, -) - - -_SCOREDVECTOR = _descriptor.Descriptor( - name='ScoredVector', - full_name='ScoredVector', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='id', full_name='ScoredVector.id', index=0, - number=1, type=9, cpp_type=9, label=1, - has_default_value=False, default_value=b"".decode('utf-8'), - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=b'\222A\032J\022\"example-vector-1\"x\200\004\200\001\001\340A\002', file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='score', full_name='ScoredVector.score', index=1, - number=2, type=2, cpp_type=6, label=1, - has_default_value=False, default_value=float(0), - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=b'\222A\006J\0040.08', file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='values', full_name='ScoredVector.values', index=2, - number=3, type=2, cpp_type=6, label=3, - has_default_value=False, default_value=[], - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=b'\222A*J([0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8]', file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='sparse_values', full_name='ScoredVector.sparse_values', index=3, - number=5, type=11, cpp_type=10, label=1, - has_default_value=False, default_value=None, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='metadata', full_name='ScoredVector.metadata', index=4, - number=4, type=11, cpp_type=10, label=1, - has_default_value=False, default_value=None, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=b'\222A(J&{\"genre\": \"documentary\", \"year\": 2019}', file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - ], - extensions=[ - ], - nested_types=[], - enum_types=[ - ], - serialized_options=None, - is_extendable=False, - syntax='proto3', - extension_ranges=[], - oneofs=[ - ], - serialized_start=550, - serialized_end=825, -) - - -_REQUESTUNION = _descriptor.Descriptor( - name='RequestUnion', - full_name='RequestUnion', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='upsert', full_name='RequestUnion.upsert', index=0, - number=1, type=11, cpp_type=10, label=1, - has_default_value=False, default_value=None, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='delete', full_name='RequestUnion.delete', index=1, - number=2, type=11, cpp_type=10, label=1, - has_default_value=False, default_value=None, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='update', full_name='RequestUnion.update', index=2, - number=3, type=11, cpp_type=10, label=1, - has_default_value=False, default_value=None, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - ], - extensions=[ - ], - nested_types=[], - enum_types=[ - ], - serialized_options=None, - is_extendable=False, - syntax='proto3', - extension_ranges=[], - oneofs=[ - _descriptor.OneofDescriptor( - name='RequestUnionInner', full_name='RequestUnion.RequestUnionInner', - index=0, containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[]), - ], - serialized_start=828, - serialized_end=965, -) - - -_UPSERTREQUEST = _descriptor.Descriptor( - name='UpsertRequest', - full_name='UpsertRequest', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='vectors', full_name='UpsertRequest.vectors', index=0, - number=1, type=11, cpp_type=10, label=3, - has_default_value=False, default_value=[], - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=b'\222A\006x\350\007\200\001\001\340A\002', file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='namespace', full_name='UpsertRequest.namespace', index=1, - number=2, type=9, cpp_type=9, label=1, - has_default_value=False, default_value=b"".decode('utf-8'), - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=b'\222A\025J\023\"example-namespace\"', file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - ], - extensions=[ - ], - nested_types=[], - enum_types=[ - ], - serialized_options=None, - is_extendable=False, - syntax='proto3', - extension_ranges=[], - oneofs=[ - ], - serialized_start=967, - serialized_end=1067, -) - - -_UPSERTRESPONSE = _descriptor.Descriptor( - name='UpsertResponse', - full_name='UpsertResponse', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='upserted_count', full_name='UpsertResponse.upserted_count', index=0, - number=1, type=13, cpp_type=3, label=1, - has_default_value=False, default_value=0, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=b'\222A\004J\00210', file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - ], - extensions=[ - ], - nested_types=[], - enum_types=[ - ], - serialized_options=None, - is_extendable=False, - syntax='proto3', - extension_ranges=[], - oneofs=[ - ], - serialized_start=1069, - serialized_end=1118, -) - - -_DELETEREQUEST = _descriptor.Descriptor( - name='DeleteRequest', - full_name='DeleteRequest', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='ids', full_name='DeleteRequest.ids', index=0, - number=1, type=9, cpp_type=9, label=3, - has_default_value=False, default_value=[], - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=b'\222A\030J\020[\"id-0\", \"id-1\"]x\350\007\200\001\001', file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='delete_all', full_name='DeleteRequest.delete_all', index=1, - number=2, type=8, cpp_type=7, label=1, - has_default_value=False, default_value=False, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=b'\222A\016:\005falseJ\005false', file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='namespace', full_name='DeleteRequest.namespace', index=2, - number=3, type=9, cpp_type=9, label=1, - has_default_value=False, default_value=b"".decode('utf-8'), - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=b'\222A\025J\023\"example-namespace\"', file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='filter', full_name='DeleteRequest.filter', index=3, - number=4, type=11, cpp_type=10, label=1, - has_default_value=False, default_value=None, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - ], - extensions=[ - ], - nested_types=[], - enum_types=[ - ], - serialized_options=None, - is_extendable=False, - syntax='proto3', - extension_ranges=[], - oneofs=[ - ], - serialized_start=1121, - serialized_end=1303, -) - - -_DELETERESPONSE = _descriptor.Descriptor( - name='DeleteResponse', - full_name='DeleteResponse', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - ], - extensions=[ - ], - nested_types=[], - enum_types=[ - ], - serialized_options=None, - is_extendable=False, - syntax='proto3', - extension_ranges=[], - oneofs=[ - ], - serialized_start=1305, - serialized_end=1321, -) - - -_FETCHREQUEST = _descriptor.Descriptor( - name='FetchRequest', - full_name='FetchRequest', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='ids', full_name='FetchRequest.ids', index=0, - number=1, type=9, cpp_type=9, label=3, - has_default_value=False, default_value=[], - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=b'\222A\030J\020[\"id-0\", \"id-1\"]x\350\007\200\001\001\340A\002', file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='namespace', full_name='FetchRequest.namespace', index=1, - number=2, type=9, cpp_type=9, label=1, - has_default_value=False, default_value=b"".decode('utf-8'), - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=b'\222A\025J\023\"example-namespace\"', file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - ], - extensions=[ - ], - nested_types=[], - enum_types=[ - ], - serialized_options=None, - is_extendable=False, - syntax='proto3', - extension_ranges=[], - oneofs=[ - ], - serialized_start=1323, - serialized_end=1427, -) - - -_FETCHRESPONSE_VECTORSENTRY = _descriptor.Descriptor( - name='VectorsEntry', - full_name='FetchResponse.VectorsEntry', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='key', full_name='FetchResponse.VectorsEntry.key', index=0, - number=1, type=9, cpp_type=9, label=1, - has_default_value=False, default_value=b"".decode('utf-8'), - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='value', full_name='FetchResponse.VectorsEntry.value', index=1, - number=2, type=11, cpp_type=10, label=1, - has_default_value=False, default_value=None, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - ], - extensions=[ - ], - nested_types=[], - enum_types=[ - ], - serialized_options=b'8\001', - is_extendable=False, - syntax='proto3', - extension_ranges=[], - oneofs=[ - ], - serialized_start=1590, - serialized_end=1645, -) - -_FETCHRESPONSE = _descriptor.Descriptor( - name='FetchResponse', - full_name='FetchResponse', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='vectors', full_name='FetchResponse.vectors', index=0, - number=1, type=11, cpp_type=10, label=3, - has_default_value=False, default_value=[], - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='namespace', full_name='FetchResponse.namespace', index=1, - number=2, type=9, cpp_type=9, label=1, - has_default_value=False, default_value=b"".decode('utf-8'), - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=b'\222A\025J\023\"example-namespace\"', file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='usage', full_name='FetchResponse.usage', index=2, - number=3, type=11, cpp_type=10, label=1, - has_default_value=False, default_value=None, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=b'\222A\023J\021{\"read_units\": 5}', file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - ], - extensions=[ - ], - nested_types=[_FETCHRESPONSE_VECTORSENTRY, ], - enum_types=[ - ], - serialized_options=None, - is_extendable=False, - syntax='proto3', - extension_ranges=[], - oneofs=[ - _descriptor.OneofDescriptor( - name='_usage', full_name='FetchResponse._usage', - index=0, containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[]), - ], - serialized_start=1430, - serialized_end=1655, -) - - -_LISTREQUEST = _descriptor.Descriptor( - name='ListRequest', - full_name='ListRequest', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='prefix', full_name='ListRequest.prefix', index=0, - number=1, type=9, cpp_type=9, label=1, - has_default_value=False, default_value=b"".decode('utf-8'), - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=b'\222A\024J\014\"document1#\"x\350\007\200\001\001', file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='limit', full_name='ListRequest.limit', index=1, - number=2, type=13, cpp_type=3, label=1, - has_default_value=False, default_value=0, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=b'\222A\t:\003100J\00212', file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='pagination_token', full_name='ListRequest.pagination_token', index=2, - number=3, type=9, cpp_type=9, label=1, - has_default_value=False, default_value=b"".decode('utf-8'), - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=b'\222A J\036\"Tm90aGluZyB0byBzZWUgaGVyZQo=\"', file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='namespace', full_name='ListRequest.namespace', index=3, - number=4, type=9, cpp_type=9, label=1, - has_default_value=False, default_value=b"".decode('utf-8'), - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=b'\222A\025J\023\"example-namespace\"', file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - ], - extensions=[ - ], - nested_types=[], - enum_types=[ - ], - serialized_options=None, - is_extendable=False, - syntax='proto3', - extension_ranges=[], - oneofs=[ - _descriptor.OneofDescriptor( - name='_prefix', full_name='ListRequest._prefix', - index=0, containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[]), - _descriptor.OneofDescriptor( - name='_limit', full_name='ListRequest._limit', - index=1, containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[]), - _descriptor.OneofDescriptor( - name='_pagination_token', full_name='ListRequest._pagination_token', - index=2, containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[]), - ], - serialized_start=1658, - serialized_end=1906, -) - - -_PAGINATION = _descriptor.Descriptor( - name='Pagination', - full_name='Pagination', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='next', full_name='Pagination.next', index=0, - number=1, type=9, cpp_type=9, label=1, - has_default_value=False, default_value=b"".decode('utf-8'), - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=b'\222A J\036\"Tm90aGluZyB0byBzZWUgaGVyZQo=\"', file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - ], - extensions=[ - ], - nested_types=[], - enum_types=[ - ], - serialized_options=None, - is_extendable=False, - syntax='proto3', - extension_ranges=[], - oneofs=[ - ], - serialized_start=1908, - serialized_end=1971, -) - - -_LISTITEM = _descriptor.Descriptor( - name='ListItem', - full_name='ListItem', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='id', full_name='ListItem.id', index=0, - number=1, type=9, cpp_type=9, label=1, - has_default_value=False, default_value=b"".decode('utf-8'), - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=b'\222A\021J\017\"document1#abb\"', file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - ], - extensions=[ - ], - nested_types=[], - enum_types=[ - ], - serialized_options=None, - is_extendable=False, - syntax='proto3', - extension_ranges=[], - oneofs=[ - ], - serialized_start=1973, - serialized_end=2017, -) - - -_LISTRESPONSE = _descriptor.Descriptor( - name='ListResponse', - full_name='ListResponse', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='vectors', full_name='ListResponse.vectors', index=0, - number=1, type=11, cpp_type=10, label=3, - has_default_value=False, default_value=[], - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=b'\222A4J2[{\"id\": \"document1#abb\"}, {\"id\": \"document1#abc\"}]', file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='pagination', full_name='ListResponse.pagination', index=1, - number=2, type=11, cpp_type=10, label=1, - has_default_value=False, default_value=None, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='namespace', full_name='ListResponse.namespace', index=2, - number=3, type=9, cpp_type=9, label=1, - has_default_value=False, default_value=b"".decode('utf-8'), - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=b'\222A\025J\023\"example-namespace\"', file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='usage', full_name='ListResponse.usage', index=3, - number=4, type=11, cpp_type=10, label=1, - has_default_value=False, default_value=None, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=b'\222A\023J\021{\"read_units\": 1}', file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - ], - extensions=[ - ], - nested_types=[], - enum_types=[ - ], - serialized_options=None, - is_extendable=False, - syntax='proto3', - extension_ranges=[], - oneofs=[ - _descriptor.OneofDescriptor( - name='_pagination', full_name='ListResponse._pagination', - index=0, containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[]), - _descriptor.OneofDescriptor( - name='_usage', full_name='ListResponse._usage', - index=1, containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[]), - ], - serialized_start=2020, - serialized_end=2279, -) - - -_QUERYVECTOR = _descriptor.Descriptor( - name='QueryVector', - full_name='QueryVector', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='values', full_name='QueryVector.values', index=0, - number=1, type=2, cpp_type=6, label=3, - has_default_value=False, default_value=[], - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=b'\222A1J([0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8]x\240\234\001\200\001\001\340A\002', file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='sparse_values', full_name='QueryVector.sparse_values', index=1, - number=5, type=11, cpp_type=10, label=1, - has_default_value=False, default_value=None, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='top_k', full_name='QueryVector.top_k', index=2, - number=2, type=13, cpp_type=3, label=1, - has_default_value=False, default_value=0, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=b'\222A\026J\00210Y\000\000\000\000\000\210\303@i\000\000\000\000\000\000\360?', file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='namespace', full_name='QueryVector.namespace', index=3, - number=3, type=9, cpp_type=9, label=1, - has_default_value=False, default_value=b"".decode('utf-8'), - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=b'\222A\025J\023\"example-namespace\"', file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='filter', full_name='QueryVector.filter', index=4, - number=4, type=11, cpp_type=10, label=1, - has_default_value=False, default_value=None, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=b'\222AOJM{\"genre\": {\"$in\": [\"comedy\", \"documentary\", \"drama\"]}, \"year\": {\"$eq\": 2019}}', file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - ], - extensions=[ - ], - nested_types=[], - enum_types=[ - ], - serialized_options=None, - is_extendable=False, - syntax='proto3', - extension_ranges=[], - oneofs=[ - ], - serialized_start=2282, - serialized_end=2618, -) - - -_QUERYREQUEST = _descriptor.Descriptor( - name='QueryRequest', - full_name='QueryRequest', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='namespace', full_name='QueryRequest.namespace', index=0, - number=1, type=9, cpp_type=9, label=1, - has_default_value=False, default_value=b"".decode('utf-8'), - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=b'\222A\025J\023\"example-namespace\"', file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='top_k', full_name='QueryRequest.top_k', index=1, - number=2, type=13, cpp_type=3, label=1, - has_default_value=False, default_value=0, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=b'\222A\026J\00210Y\000\000\000\000\000\210\303@i\000\000\000\000\000\000\360?\340A\002', file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='filter', full_name='QueryRequest.filter', index=2, - number=3, type=11, cpp_type=10, label=1, - has_default_value=False, default_value=None, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=b'\222AOJM{\"genre\": {\"$in\": [\"comedy\", \"documentary\", \"drama\"]}, \"year\": {\"$eq\": 2019}}', file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='include_values', full_name='QueryRequest.include_values', index=3, - number=4, type=8, cpp_type=7, label=1, - has_default_value=False, default_value=False, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=b'\222A\r:\005falseJ\004true', file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='include_metadata', full_name='QueryRequest.include_metadata', index=4, - number=5, type=8, cpp_type=7, label=1, - has_default_value=False, default_value=False, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=b'\222A\r:\005falseJ\004true', file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='queries', full_name='QueryRequest.queries', index=5, - number=6, type=11, cpp_type=10, label=3, - has_default_value=False, default_value=[], - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=b'\030\001\222A\005x\n\200\001\001', file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='vector', full_name='QueryRequest.vector', index=6, - number=7, type=2, cpp_type=6, label=3, - has_default_value=False, default_value=[], - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=b'\222A1J([0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8]x\240\234\001\200\001\001', file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='sparse_vector', full_name='QueryRequest.sparse_vector', index=7, - number=9, type=11, cpp_type=10, label=1, - has_default_value=False, default_value=None, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='id', full_name='QueryRequest.id', index=8, - number=8, type=9, cpp_type=9, label=1, - has_default_value=False, default_value=b"".decode('utf-8'), - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=b'\222A\027J\022\"example-vector-1\"x\200\004', file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - ], - extensions=[ - ], - nested_types=[], - enum_types=[ - ], - serialized_options=None, - is_extendable=False, - syntax='proto3', - extension_ranges=[], - oneofs=[ - ], - serialized_start=2621, - serialized_end=3127, -) - - -_SINGLEQUERYRESULTS = _descriptor.Descriptor( - name='SingleQueryResults', - full_name='SingleQueryResults', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='matches', full_name='SingleQueryResults.matches', index=0, - number=1, type=11, cpp_type=10, label=3, - has_default_value=False, default_value=[], - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='namespace', full_name='SingleQueryResults.namespace', index=1, - number=2, type=9, cpp_type=9, label=1, - has_default_value=False, default_value=b"".decode('utf-8'), - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=b'\222A\025J\023\"example-namespace\"', file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - ], - extensions=[ - ], - nested_types=[], - enum_types=[ - ], - serialized_options=None, - is_extendable=False, - syntax='proto3', - extension_ranges=[], - oneofs=[ - ], - serialized_start=3129, - serialized_end=3226, -) - - -_QUERYRESPONSE = _descriptor.Descriptor( - name='QueryResponse', - full_name='QueryResponse', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='results', full_name='QueryResponse.results', index=0, - number=1, type=11, cpp_type=10, label=3, - has_default_value=False, default_value=[], - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=b'\030\001', file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='matches', full_name='QueryResponse.matches', index=1, - number=2, type=11, cpp_type=10, label=3, - has_default_value=False, default_value=[], - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='namespace', full_name='QueryResponse.namespace', index=2, - number=3, type=9, cpp_type=9, label=1, - has_default_value=False, default_value=b"".decode('utf-8'), - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='usage', full_name='QueryResponse.usage', index=3, - number=4, type=11, cpp_type=10, label=1, - has_default_value=False, default_value=None, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=b'\222A\023J\021{\"read_units\": 5}', file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - ], - extensions=[ - ], - nested_types=[], - enum_types=[ - ], - serialized_options=None, - is_extendable=False, - syntax='proto3', - extension_ranges=[], - oneofs=[ - _descriptor.OneofDescriptor( - name='_usage', full_name='QueryResponse._usage', - index=0, containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[]), - ], - serialized_start=3229, - serialized_end=3399, -) - - -_USAGE = _descriptor.Descriptor( - name='Usage', - full_name='Usage', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='read_units', full_name='Usage.read_units', index=0, - number=1, type=13, cpp_type=3, label=1, - has_default_value=False, default_value=0, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=b'\222A\003J\0015', file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - ], - extensions=[ - ], - nested_types=[], - enum_types=[ - ], - serialized_options=None, - is_extendable=False, - syntax='proto3', - extension_ranges=[], - oneofs=[ - _descriptor.OneofDescriptor( - name='_read_units', full_name='Usage._read_units', - index=0, containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[]), - ], - serialized_start=3401, - serialized_end=3456, -) - - -_UPDATEREQUEST = _descriptor.Descriptor( - name='UpdateRequest', - full_name='UpdateRequest', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='id', full_name='UpdateRequest.id', index=0, - number=1, type=9, cpp_type=9, label=1, - has_default_value=False, default_value=b"".decode('utf-8'), - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=b'\222A\032J\022\"example-vector-1\"x\200\004\200\001\001\340A\002', file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='values', full_name='UpdateRequest.values', index=1, - number=2, type=2, cpp_type=6, label=3, - has_default_value=False, default_value=[], - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=b'\222A1J([0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8]x\240\234\001\200\001\001', file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='sparse_values', full_name='UpdateRequest.sparse_values', index=2, - number=5, type=11, cpp_type=10, label=1, - has_default_value=False, default_value=None, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='set_metadata', full_name='UpdateRequest.set_metadata', index=3, - number=3, type=11, cpp_type=10, label=1, - has_default_value=False, default_value=None, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=b'\222A(J&{\"genre\": \"documentary\", \"year\": 2019}', file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='namespace', full_name='UpdateRequest.namespace', index=4, - number=4, type=9, cpp_type=9, label=1, - has_default_value=False, default_value=b"".decode('utf-8'), - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=b'\222A\025J\023\"example-namespace\"', file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - ], - extensions=[ - ], - nested_types=[], - enum_types=[ - ], - serialized_options=None, - is_extendable=False, - syntax='proto3', - extension_ranges=[], - oneofs=[ - ], - serialized_start=3459, - serialized_end=3765, -) - - -_UPDATERESPONSE = _descriptor.Descriptor( - name='UpdateResponse', - full_name='UpdateResponse', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - ], - extensions=[ - ], - nested_types=[], - enum_types=[ - ], - serialized_options=None, - is_extendable=False, - syntax='proto3', - extension_ranges=[], - oneofs=[ - ], - serialized_start=3767, - serialized_end=3783, -) - - -_DESCRIBEINDEXSTATSREQUEST = _descriptor.Descriptor( - name='DescribeIndexStatsRequest', - full_name='DescribeIndexStatsRequest', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='filter', full_name='DescribeIndexStatsRequest.filter', index=0, - number=1, type=11, cpp_type=10, label=1, - has_default_value=False, default_value=None, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - ], - extensions=[ - ], - nested_types=[], - enum_types=[ - ], - serialized_options=None, - is_extendable=False, - syntax='proto3', - extension_ranges=[], - oneofs=[ - ], - serialized_start=3785, - serialized_end=3853, -) - - -_NAMESPACESUMMARY = _descriptor.Descriptor( - name='NamespaceSummary', - full_name='NamespaceSummary', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='vector_count', full_name='NamespaceSummary.vector_count', index=0, - number=1, type=13, cpp_type=3, label=1, - has_default_value=False, default_value=0, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=b'\222A\007J\00550000', file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - ], - extensions=[ - ], - nested_types=[], - enum_types=[ - ], - serialized_options=None, - is_extendable=False, - syntax='proto3', - extension_ranges=[], - oneofs=[ - ], - serialized_start=3855, - serialized_end=3907, -) - - -_DESCRIBEINDEXSTATSRESPONSE_NAMESPACESENTRY = _descriptor.Descriptor( - name='NamespacesEntry', - full_name='DescribeIndexStatsResponse.NamespacesEntry', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='key', full_name='DescribeIndexStatsResponse.NamespacesEntry.key', index=0, - number=1, type=9, cpp_type=9, label=1, - has_default_value=False, default_value=b"".decode('utf-8'), - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='value', full_name='DescribeIndexStatsResponse.NamespacesEntry.value', index=1, - number=2, type=11, cpp_type=10, label=1, - has_default_value=False, default_value=None, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - ], - extensions=[ - ], - nested_types=[], - enum_types=[ - ], - serialized_options=b'8\001', - is_extendable=False, - syntax='proto3', - extension_ranges=[], - oneofs=[ - ], - serialized_start=4109, - serialized_end=4177, -) - -_DESCRIBEINDEXSTATSRESPONSE = _descriptor.Descriptor( - name='DescribeIndexStatsResponse', - full_name='DescribeIndexStatsResponse', - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name='namespaces', full_name='DescribeIndexStatsResponse.namespaces', index=0, - number=1, type=11, cpp_type=10, label=3, - has_default_value=False, default_value=[], - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='dimension', full_name='DescribeIndexStatsResponse.dimension', index=1, - number=2, type=13, cpp_type=3, label=1, - has_default_value=False, default_value=0, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=b'\222A\006J\0041024', file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='index_fullness', full_name='DescribeIndexStatsResponse.index_fullness', index=2, - number=3, type=2, cpp_type=6, label=1, - has_default_value=False, default_value=float(0), - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=b'\222A\005J\0030.4', file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - _descriptor.FieldDescriptor( - name='total_vector_count', full_name='DescribeIndexStatsResponse.total_vector_count', index=3, - number=4, type=13, cpp_type=3, label=1, - has_default_value=False, default_value=0, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - serialized_options=b'\222A\007J\00580000', file=DESCRIPTOR, create_key=_descriptor._internal_create_key), - ], - extensions=[ - ], - nested_types=[_DESCRIBEINDEXSTATSRESPONSE_NAMESPACESENTRY, ], - enum_types=[ - ], - serialized_options=b'\222A\210\0012\205\001{\"namespaces\": {\"\": {\"vectorCount\": 50000}, \"example-namespace-2\": {\"vectorCount\": 30000}}, \"dimension\": 1024, \"index_fullness\": 0.4}', - is_extendable=False, - syntax='proto3', - extension_ranges=[], - oneofs=[ - ], - serialized_start=3910, - serialized_end=4320, -) - -_VECTOR.fields_by_name['sparse_values'].message_type = _SPARSEVALUES -_VECTOR.fields_by_name['metadata'].message_type = google_dot_protobuf_dot_struct__pb2._STRUCT -_SCOREDVECTOR.fields_by_name['sparse_values'].message_type = _SPARSEVALUES -_SCOREDVECTOR.fields_by_name['metadata'].message_type = google_dot_protobuf_dot_struct__pb2._STRUCT -_REQUESTUNION.fields_by_name['upsert'].message_type = _UPSERTREQUEST -_REQUESTUNION.fields_by_name['delete'].message_type = _DELETEREQUEST -_REQUESTUNION.fields_by_name['update'].message_type = _UPDATEREQUEST -_REQUESTUNION.oneofs_by_name['RequestUnionInner'].fields.append( - _REQUESTUNION.fields_by_name['upsert']) -_REQUESTUNION.fields_by_name['upsert'].containing_oneof = _REQUESTUNION.oneofs_by_name['RequestUnionInner'] -_REQUESTUNION.oneofs_by_name['RequestUnionInner'].fields.append( - _REQUESTUNION.fields_by_name['delete']) -_REQUESTUNION.fields_by_name['delete'].containing_oneof = _REQUESTUNION.oneofs_by_name['RequestUnionInner'] -_REQUESTUNION.oneofs_by_name['RequestUnionInner'].fields.append( - _REQUESTUNION.fields_by_name['update']) -_REQUESTUNION.fields_by_name['update'].containing_oneof = _REQUESTUNION.oneofs_by_name['RequestUnionInner'] -_UPSERTREQUEST.fields_by_name['vectors'].message_type = _VECTOR -_DELETEREQUEST.fields_by_name['filter'].message_type = google_dot_protobuf_dot_struct__pb2._STRUCT -_FETCHRESPONSE_VECTORSENTRY.fields_by_name['value'].message_type = _VECTOR -_FETCHRESPONSE_VECTORSENTRY.containing_type = _FETCHRESPONSE -_FETCHRESPONSE.fields_by_name['vectors'].message_type = _FETCHRESPONSE_VECTORSENTRY -_FETCHRESPONSE.fields_by_name['usage'].message_type = _USAGE -_FETCHRESPONSE.oneofs_by_name['_usage'].fields.append( - _FETCHRESPONSE.fields_by_name['usage']) -_FETCHRESPONSE.fields_by_name['usage'].containing_oneof = _FETCHRESPONSE.oneofs_by_name['_usage'] -_LISTREQUEST.oneofs_by_name['_prefix'].fields.append( - _LISTREQUEST.fields_by_name['prefix']) -_LISTREQUEST.fields_by_name['prefix'].containing_oneof = _LISTREQUEST.oneofs_by_name['_prefix'] -_LISTREQUEST.oneofs_by_name['_limit'].fields.append( - _LISTREQUEST.fields_by_name['limit']) -_LISTREQUEST.fields_by_name['limit'].containing_oneof = _LISTREQUEST.oneofs_by_name['_limit'] -_LISTREQUEST.oneofs_by_name['_pagination_token'].fields.append( - _LISTREQUEST.fields_by_name['pagination_token']) -_LISTREQUEST.fields_by_name['pagination_token'].containing_oneof = _LISTREQUEST.oneofs_by_name['_pagination_token'] -_LISTRESPONSE.fields_by_name['vectors'].message_type = _LISTITEM -_LISTRESPONSE.fields_by_name['pagination'].message_type = _PAGINATION -_LISTRESPONSE.fields_by_name['usage'].message_type = _USAGE -_LISTRESPONSE.oneofs_by_name['_pagination'].fields.append( - _LISTRESPONSE.fields_by_name['pagination']) -_LISTRESPONSE.fields_by_name['pagination'].containing_oneof = _LISTRESPONSE.oneofs_by_name['_pagination'] -_LISTRESPONSE.oneofs_by_name['_usage'].fields.append( - _LISTRESPONSE.fields_by_name['usage']) -_LISTRESPONSE.fields_by_name['usage'].containing_oneof = _LISTRESPONSE.oneofs_by_name['_usage'] -_QUERYVECTOR.fields_by_name['sparse_values'].message_type = _SPARSEVALUES -_QUERYVECTOR.fields_by_name['filter'].message_type = google_dot_protobuf_dot_struct__pb2._STRUCT -_QUERYREQUEST.fields_by_name['filter'].message_type = google_dot_protobuf_dot_struct__pb2._STRUCT -_QUERYREQUEST.fields_by_name['queries'].message_type = _QUERYVECTOR -_QUERYREQUEST.fields_by_name['sparse_vector'].message_type = _SPARSEVALUES -_SINGLEQUERYRESULTS.fields_by_name['matches'].message_type = _SCOREDVECTOR -_QUERYRESPONSE.fields_by_name['results'].message_type = _SINGLEQUERYRESULTS -_QUERYRESPONSE.fields_by_name['matches'].message_type = _SCOREDVECTOR -_QUERYRESPONSE.fields_by_name['usage'].message_type = _USAGE -_QUERYRESPONSE.oneofs_by_name['_usage'].fields.append( - _QUERYRESPONSE.fields_by_name['usage']) -_QUERYRESPONSE.fields_by_name['usage'].containing_oneof = _QUERYRESPONSE.oneofs_by_name['_usage'] -_USAGE.oneofs_by_name['_read_units'].fields.append( - _USAGE.fields_by_name['read_units']) -_USAGE.fields_by_name['read_units'].containing_oneof = _USAGE.oneofs_by_name['_read_units'] -_UPDATEREQUEST.fields_by_name['sparse_values'].message_type = _SPARSEVALUES -_UPDATEREQUEST.fields_by_name['set_metadata'].message_type = google_dot_protobuf_dot_struct__pb2._STRUCT -_DESCRIBEINDEXSTATSREQUEST.fields_by_name['filter'].message_type = google_dot_protobuf_dot_struct__pb2._STRUCT -_DESCRIBEINDEXSTATSRESPONSE_NAMESPACESENTRY.fields_by_name['value'].message_type = _NAMESPACESUMMARY -_DESCRIBEINDEXSTATSRESPONSE_NAMESPACESENTRY.containing_type = _DESCRIBEINDEXSTATSRESPONSE -_DESCRIBEINDEXSTATSRESPONSE.fields_by_name['namespaces'].message_type = _DESCRIBEINDEXSTATSRESPONSE_NAMESPACESENTRY -DESCRIPTOR.message_types_by_name['SparseValues'] = _SPARSEVALUES -DESCRIPTOR.message_types_by_name['Vector'] = _VECTOR -DESCRIPTOR.message_types_by_name['ScoredVector'] = _SCOREDVECTOR -DESCRIPTOR.message_types_by_name['RequestUnion'] = _REQUESTUNION -DESCRIPTOR.message_types_by_name['UpsertRequest'] = _UPSERTREQUEST -DESCRIPTOR.message_types_by_name['UpsertResponse'] = _UPSERTRESPONSE -DESCRIPTOR.message_types_by_name['DeleteRequest'] = _DELETEREQUEST -DESCRIPTOR.message_types_by_name['DeleteResponse'] = _DELETERESPONSE -DESCRIPTOR.message_types_by_name['FetchRequest'] = _FETCHREQUEST -DESCRIPTOR.message_types_by_name['FetchResponse'] = _FETCHRESPONSE -DESCRIPTOR.message_types_by_name['ListRequest'] = _LISTREQUEST -DESCRIPTOR.message_types_by_name['Pagination'] = _PAGINATION -DESCRIPTOR.message_types_by_name['ListItem'] = _LISTITEM -DESCRIPTOR.message_types_by_name['ListResponse'] = _LISTRESPONSE -DESCRIPTOR.message_types_by_name['QueryVector'] = _QUERYVECTOR -DESCRIPTOR.message_types_by_name['QueryRequest'] = _QUERYREQUEST -DESCRIPTOR.message_types_by_name['SingleQueryResults'] = _SINGLEQUERYRESULTS -DESCRIPTOR.message_types_by_name['QueryResponse'] = _QUERYRESPONSE -DESCRIPTOR.message_types_by_name['Usage'] = _USAGE -DESCRIPTOR.message_types_by_name['UpdateRequest'] = _UPDATEREQUEST -DESCRIPTOR.message_types_by_name['UpdateResponse'] = _UPDATERESPONSE -DESCRIPTOR.message_types_by_name['DescribeIndexStatsRequest'] = _DESCRIBEINDEXSTATSREQUEST -DESCRIPTOR.message_types_by_name['NamespaceSummary'] = _NAMESPACESUMMARY -DESCRIPTOR.message_types_by_name['DescribeIndexStatsResponse'] = _DESCRIBEINDEXSTATSRESPONSE -_sym_db.RegisterFileDescriptor(DESCRIPTOR) - -SparseValues = _reflection.GeneratedProtocolMessageType('SparseValues', (_message.Message,), { - 'DESCRIPTOR' : _SPARSEVALUES, - '__module__' : 'vector_service_pb2' - # @@protoc_insertion_point(class_scope:SparseValues) - }) -_sym_db.RegisterMessage(SparseValues) - -Vector = _reflection.GeneratedProtocolMessageType('Vector', (_message.Message,), { - 'DESCRIPTOR' : _VECTOR, - '__module__' : 'vector_service_pb2' - # @@protoc_insertion_point(class_scope:Vector) - }) -_sym_db.RegisterMessage(Vector) - -ScoredVector = _reflection.GeneratedProtocolMessageType('ScoredVector', (_message.Message,), { - 'DESCRIPTOR' : _SCOREDVECTOR, - '__module__' : 'vector_service_pb2' - # @@protoc_insertion_point(class_scope:ScoredVector) - }) -_sym_db.RegisterMessage(ScoredVector) - -RequestUnion = _reflection.GeneratedProtocolMessageType('RequestUnion', (_message.Message,), { - 'DESCRIPTOR' : _REQUESTUNION, - '__module__' : 'vector_service_pb2' - # @@protoc_insertion_point(class_scope:RequestUnion) - }) -_sym_db.RegisterMessage(RequestUnion) - -UpsertRequest = _reflection.GeneratedProtocolMessageType('UpsertRequest', (_message.Message,), { - 'DESCRIPTOR' : _UPSERTREQUEST, - '__module__' : 'vector_service_pb2' - # @@protoc_insertion_point(class_scope:UpsertRequest) - }) -_sym_db.RegisterMessage(UpsertRequest) - -UpsertResponse = _reflection.GeneratedProtocolMessageType('UpsertResponse', (_message.Message,), { - 'DESCRIPTOR' : _UPSERTRESPONSE, - '__module__' : 'vector_service_pb2' - # @@protoc_insertion_point(class_scope:UpsertResponse) - }) -_sym_db.RegisterMessage(UpsertResponse) - -DeleteRequest = _reflection.GeneratedProtocolMessageType('DeleteRequest', (_message.Message,), { - 'DESCRIPTOR' : _DELETEREQUEST, - '__module__' : 'vector_service_pb2' - # @@protoc_insertion_point(class_scope:DeleteRequest) - }) -_sym_db.RegisterMessage(DeleteRequest) - -DeleteResponse = _reflection.GeneratedProtocolMessageType('DeleteResponse', (_message.Message,), { - 'DESCRIPTOR' : _DELETERESPONSE, - '__module__' : 'vector_service_pb2' - # @@protoc_insertion_point(class_scope:DeleteResponse) - }) -_sym_db.RegisterMessage(DeleteResponse) - -FetchRequest = _reflection.GeneratedProtocolMessageType('FetchRequest', (_message.Message,), { - 'DESCRIPTOR' : _FETCHREQUEST, - '__module__' : 'vector_service_pb2' - # @@protoc_insertion_point(class_scope:FetchRequest) - }) -_sym_db.RegisterMessage(FetchRequest) - -FetchResponse = _reflection.GeneratedProtocolMessageType('FetchResponse', (_message.Message,), { - - 'VectorsEntry' : _reflection.GeneratedProtocolMessageType('VectorsEntry', (_message.Message,), { - 'DESCRIPTOR' : _FETCHRESPONSE_VECTORSENTRY, - '__module__' : 'vector_service_pb2' - # @@protoc_insertion_point(class_scope:FetchResponse.VectorsEntry) - }) - , - 'DESCRIPTOR' : _FETCHRESPONSE, - '__module__' : 'vector_service_pb2' - # @@protoc_insertion_point(class_scope:FetchResponse) - }) -_sym_db.RegisterMessage(FetchResponse) -_sym_db.RegisterMessage(FetchResponse.VectorsEntry) - -ListRequest = _reflection.GeneratedProtocolMessageType('ListRequest', (_message.Message,), { - 'DESCRIPTOR' : _LISTREQUEST, - '__module__' : 'vector_service_pb2' - # @@protoc_insertion_point(class_scope:ListRequest) - }) -_sym_db.RegisterMessage(ListRequest) - -Pagination = _reflection.GeneratedProtocolMessageType('Pagination', (_message.Message,), { - 'DESCRIPTOR' : _PAGINATION, - '__module__' : 'vector_service_pb2' - # @@protoc_insertion_point(class_scope:Pagination) - }) -_sym_db.RegisterMessage(Pagination) - -ListItem = _reflection.GeneratedProtocolMessageType('ListItem', (_message.Message,), { - 'DESCRIPTOR' : _LISTITEM, - '__module__' : 'vector_service_pb2' - # @@protoc_insertion_point(class_scope:ListItem) - }) -_sym_db.RegisterMessage(ListItem) - -ListResponse = _reflection.GeneratedProtocolMessageType('ListResponse', (_message.Message,), { - 'DESCRIPTOR' : _LISTRESPONSE, - '__module__' : 'vector_service_pb2' - # @@protoc_insertion_point(class_scope:ListResponse) - }) -_sym_db.RegisterMessage(ListResponse) - -QueryVector = _reflection.GeneratedProtocolMessageType('QueryVector', (_message.Message,), { - 'DESCRIPTOR' : _QUERYVECTOR, - '__module__' : 'vector_service_pb2' - # @@protoc_insertion_point(class_scope:QueryVector) - }) -_sym_db.RegisterMessage(QueryVector) - -QueryRequest = _reflection.GeneratedProtocolMessageType('QueryRequest', (_message.Message,), { - 'DESCRIPTOR' : _QUERYREQUEST, - '__module__' : 'vector_service_pb2' - # @@protoc_insertion_point(class_scope:QueryRequest) - }) -_sym_db.RegisterMessage(QueryRequest) - -SingleQueryResults = _reflection.GeneratedProtocolMessageType('SingleQueryResults', (_message.Message,), { - 'DESCRIPTOR' : _SINGLEQUERYRESULTS, - '__module__' : 'vector_service_pb2' - # @@protoc_insertion_point(class_scope:SingleQueryResults) - }) -_sym_db.RegisterMessage(SingleQueryResults) - -QueryResponse = _reflection.GeneratedProtocolMessageType('QueryResponse', (_message.Message,), { - 'DESCRIPTOR' : _QUERYRESPONSE, - '__module__' : 'vector_service_pb2' - # @@protoc_insertion_point(class_scope:QueryResponse) - }) -_sym_db.RegisterMessage(QueryResponse) - -Usage = _reflection.GeneratedProtocolMessageType('Usage', (_message.Message,), { - 'DESCRIPTOR' : _USAGE, - '__module__' : 'vector_service_pb2' - # @@protoc_insertion_point(class_scope:Usage) - }) -_sym_db.RegisterMessage(Usage) - -UpdateRequest = _reflection.GeneratedProtocolMessageType('UpdateRequest', (_message.Message,), { - 'DESCRIPTOR' : _UPDATEREQUEST, - '__module__' : 'vector_service_pb2' - # @@protoc_insertion_point(class_scope:UpdateRequest) - }) -_sym_db.RegisterMessage(UpdateRequest) - -UpdateResponse = _reflection.GeneratedProtocolMessageType('UpdateResponse', (_message.Message,), { - 'DESCRIPTOR' : _UPDATERESPONSE, - '__module__' : 'vector_service_pb2' - # @@protoc_insertion_point(class_scope:UpdateResponse) - }) -_sym_db.RegisterMessage(UpdateResponse) - -DescribeIndexStatsRequest = _reflection.GeneratedProtocolMessageType('DescribeIndexStatsRequest', (_message.Message,), { - 'DESCRIPTOR' : _DESCRIBEINDEXSTATSREQUEST, - '__module__' : 'vector_service_pb2' - # @@protoc_insertion_point(class_scope:DescribeIndexStatsRequest) - }) -_sym_db.RegisterMessage(DescribeIndexStatsRequest) - -NamespaceSummary = _reflection.GeneratedProtocolMessageType('NamespaceSummary', (_message.Message,), { - 'DESCRIPTOR' : _NAMESPACESUMMARY, - '__module__' : 'vector_service_pb2' - # @@protoc_insertion_point(class_scope:NamespaceSummary) - }) -_sym_db.RegisterMessage(NamespaceSummary) - -DescribeIndexStatsResponse = _reflection.GeneratedProtocolMessageType('DescribeIndexStatsResponse', (_message.Message,), { - - 'NamespacesEntry' : _reflection.GeneratedProtocolMessageType('NamespacesEntry', (_message.Message,), { - 'DESCRIPTOR' : _DESCRIBEINDEXSTATSRESPONSE_NAMESPACESENTRY, - '__module__' : 'vector_service_pb2' - # @@protoc_insertion_point(class_scope:DescribeIndexStatsResponse.NamespacesEntry) - }) - , - 'DESCRIPTOR' : _DESCRIBEINDEXSTATSRESPONSE, - '__module__' : 'vector_service_pb2' - # @@protoc_insertion_point(class_scope:DescribeIndexStatsResponse) - }) -_sym_db.RegisterMessage(DescribeIndexStatsResponse) -_sym_db.RegisterMessage(DescribeIndexStatsResponse.NamespacesEntry) - - -DESCRIPTOR._options = None -_SPARSEVALUES.fields_by_name['indices']._options = None -_SPARSEVALUES.fields_by_name['values']._options = None -_VECTOR.fields_by_name['id']._options = None -_VECTOR.fields_by_name['values']._options = None -_VECTOR.fields_by_name['metadata']._options = None -_SCOREDVECTOR.fields_by_name['id']._options = None -_SCOREDVECTOR.fields_by_name['score']._options = None -_SCOREDVECTOR.fields_by_name['values']._options = None -_SCOREDVECTOR.fields_by_name['metadata']._options = None -_UPSERTREQUEST.fields_by_name['vectors']._options = None -_UPSERTREQUEST.fields_by_name['namespace']._options = None -_UPSERTRESPONSE.fields_by_name['upserted_count']._options = None -_DELETEREQUEST.fields_by_name['ids']._options = None -_DELETEREQUEST.fields_by_name['delete_all']._options = None -_DELETEREQUEST.fields_by_name['namespace']._options = None -_FETCHREQUEST.fields_by_name['ids']._options = None -_FETCHREQUEST.fields_by_name['namespace']._options = None -_FETCHRESPONSE_VECTORSENTRY._options = None -_FETCHRESPONSE.fields_by_name['namespace']._options = None -_FETCHRESPONSE.fields_by_name['usage']._options = None -_LISTREQUEST.fields_by_name['prefix']._options = None -_LISTREQUEST.fields_by_name['limit']._options = None -_LISTREQUEST.fields_by_name['pagination_token']._options = None -_LISTREQUEST.fields_by_name['namespace']._options = None -_PAGINATION.fields_by_name['next']._options = None -_LISTITEM.fields_by_name['id']._options = None -_LISTRESPONSE.fields_by_name['vectors']._options = None -_LISTRESPONSE.fields_by_name['namespace']._options = None -_LISTRESPONSE.fields_by_name['usage']._options = None -_QUERYVECTOR.fields_by_name['values']._options = None -_QUERYVECTOR.fields_by_name['top_k']._options = None -_QUERYVECTOR.fields_by_name['namespace']._options = None -_QUERYVECTOR.fields_by_name['filter']._options = None -_QUERYREQUEST.fields_by_name['namespace']._options = None -_QUERYREQUEST.fields_by_name['top_k']._options = None -_QUERYREQUEST.fields_by_name['filter']._options = None -_QUERYREQUEST.fields_by_name['include_values']._options = None -_QUERYREQUEST.fields_by_name['include_metadata']._options = None -_QUERYREQUEST.fields_by_name['queries']._options = None -_QUERYREQUEST.fields_by_name['vector']._options = None -_QUERYREQUEST.fields_by_name['id']._options = None -_SINGLEQUERYRESULTS.fields_by_name['namespace']._options = None -_QUERYRESPONSE.fields_by_name['results']._options = None -_QUERYRESPONSE.fields_by_name['usage']._options = None -_USAGE.fields_by_name['read_units']._options = None -_UPDATEREQUEST.fields_by_name['id']._options = None -_UPDATEREQUEST.fields_by_name['values']._options = None -_UPDATEREQUEST.fields_by_name['set_metadata']._options = None -_UPDATEREQUEST.fields_by_name['namespace']._options = None -_NAMESPACESUMMARY.fields_by_name['vector_count']._options = None -_DESCRIBEINDEXSTATSRESPONSE_NAMESPACESENTRY._options = None -_DESCRIBEINDEXSTATSRESPONSE.fields_by_name['dimension']._options = None -_DESCRIBEINDEXSTATSRESPONSE.fields_by_name['index_fullness']._options = None -_DESCRIBEINDEXSTATSRESPONSE.fields_by_name['total_vector_count']._options = None -_DESCRIBEINDEXSTATSRESPONSE._options = None - -_VECTORSERVICE = _descriptor.ServiceDescriptor( - name='VectorService', - full_name='VectorService', - file=DESCRIPTOR, - index=0, - serialized_options=None, - create_key=_descriptor._internal_create_key, - serialized_start=4323, - serialized_end=5112, - methods=[ - _descriptor.MethodDescriptor( - name='Upsert', - full_name='VectorService.Upsert', - index=0, - containing_service=None, - input_type=_UPSERTREQUEST, - output_type=_UPSERTRESPONSE, - serialized_options=b'\202\323\344\223\002\024\"\017/vectors/upsert:\001*\222A\033\n\021Vector Operations*\006upsert', - create_key=_descriptor._internal_create_key, - ), - _descriptor.MethodDescriptor( - name='Delete', - full_name='VectorService.Delete', - index=1, - containing_service=None, - input_type=_DELETEREQUEST, - output_type=_DELETERESPONSE, - serialized_options=b'\202\323\344\223\002\'\"\017/vectors/delete:\001*Z\021*\017/vectors/delete\222A\033\n\021Vector Operations*\006delete', - create_key=_descriptor._internal_create_key, - ), - _descriptor.MethodDescriptor( - name='Fetch', - full_name='VectorService.Fetch', - index=2, - containing_service=None, - input_type=_FETCHREQUEST, - output_type=_FETCHRESPONSE, - serialized_options=b'\202\323\344\223\002\020\022\016/vectors/fetch\222A\032\n\021Vector Operations*\005fetch', - create_key=_descriptor._internal_create_key, - ), - _descriptor.MethodDescriptor( - name='List', - full_name='VectorService.List', - index=3, - containing_service=None, - input_type=_LISTREQUEST, - output_type=_LISTRESPONSE, - serialized_options=b'\202\323\344\223\002\017\022\r/vectors/list\222A\031\n\021Vector Operations*\004list', - create_key=_descriptor._internal_create_key, - ), - _descriptor.MethodDescriptor( - name='Query', - full_name='VectorService.Query', - index=4, - containing_service=None, - input_type=_QUERYREQUEST, - output_type=_QUERYRESPONSE, - serialized_options=b'\202\323\344\223\002\013\"\006/query:\001*\222A\032\n\021Vector Operations*\005query', - create_key=_descriptor._internal_create_key, - ), - _descriptor.MethodDescriptor( - name='Update', - full_name='VectorService.Update', - index=5, - containing_service=None, - input_type=_UPDATEREQUEST, - output_type=_UPDATERESPONSE, - serialized_options=b'\202\323\344\223\002\024\"\017/vectors/update:\001*\222A\033\n\021Vector Operations*\006update', - create_key=_descriptor._internal_create_key, - ), - _descriptor.MethodDescriptor( - name='DescribeIndexStats', - full_name='VectorService.DescribeIndexStats', - index=6, - containing_service=None, - input_type=_DESCRIBEINDEXSTATSREQUEST, - output_type=_DESCRIBEINDEXSTATSRESPONSE, - serialized_options=b'\202\323\344\223\0023\"\025/describe_index_stats:\001*Z\027\022\025/describe_index_stats\222A)\n\021Vector Operations*\024describe_index_stats', - create_key=_descriptor._internal_create_key, - ), -]) -_sym_db.RegisterServiceDescriptor(_VECTORSERVICE) - -DESCRIPTOR.services_by_name['VectorService'] = _VECTORSERVICE - +DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n%pinecone/data/v1/vector_service.proto\x1a\x1cgoogle/protobuf/struct.proto\x1a\x1cgoogle/api/annotations.proto\x1a\x1fgoogle/api/field_behavior.proto\x1a.protoc-gen-openapiv2/options/annotations.proto\"\x91\x01\n\x0cSparseValues\x12?\n\x07indices\x18\x01 \x03(\rB%\x92\x41\x1eJ\x16[1, 312, 822, 14, 980]x\xe8\x07\x80\x01\x01\xe2\x41\x01\x02R\x07indices\x12@\n\x06values\x18\x02 \x03(\x02\x42(\x92\x41!J\x19[0.1, 0.2, 0.3, 0.4, 0.5]x\xe8\x07\x80\x01\x01\xe2\x41\x01\x02R\x06values\"\xa3\x02\n\x06Vector\x12\x31\n\x02id\x18\x01 \x01(\tB!\x92\x41\x1aJ\x12\"example-vector-1\"x\x80\x04\x80\x01\x01\xe2\x41\x01\x02R\x02id\x12P\n\x06values\x18\x02 \x03(\x02\x42\x38\x92\x41\x31J([0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8]x\xa0\x9c\x01\x80\x01\x01\xe2\x41\x01\x02R\x06values\x12\x32\n\rsparse_values\x18\x04 \x01(\x0b\x32\r.SparseValuesR\x0csparseValues\x12`\n\x08metadata\x18\x03 \x01(\x0b\x32\x17.google.protobuf.StructB+\x92\x41(J&{\"genre\": \"documentary\", \"year\": 2019}R\x08metadata\"\xbf\x02\n\x0cScoredVector\x12\x31\n\x02id\x18\x01 \x01(\tB!\x92\x41\x1aJ\x12\"example-vector-1\"x\x80\x04\x80\x01\x01\xe2\x41\x01\x02R\x02id\x12\x1f\n\x05score\x18\x02 \x01(\x02\x42\t\x92\x41\x06J\x04\x30.08R\x05score\x12\x45\n\x06values\x18\x03 \x03(\x02\x42-\x92\x41*J([0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8]R\x06values\x12\x32\n\rsparse_values\x18\x05 \x01(\x0b\x32\r.SparseValuesR\x0csparseValues\x12`\n\x08metadata\x18\x04 \x01(\x0b\x32\x17.google.protobuf.StructB+\x92\x41(J&{\"genre\": \"documentary\", \"year\": 2019}R\x08metadata\"\xa1\x01\n\x0cRequestUnion\x12(\n\x06upsert\x18\x01 \x01(\x0b\x32\x0e.UpsertRequestH\x00R\x06upsert\x12(\n\x06\x64\x65lete\x18\x02 \x01(\x0b\x32\x0e.DeleteRequestH\x00R\x06\x64\x65lete\x12(\n\x06update\x18\x03 \x01(\x0b\x32\x0e.UpdateRequestH\x00R\x06updateB\x13\n\x11RequestUnionInner\"y\n\rUpsertRequest\x12\x30\n\x07vectors\x18\x01 \x03(\x0b\x32\x07.VectorB\r\x92\x41\x06x\xe8\x07\x80\x01\x01\xe2\x41\x01\x02R\x07vectors\x12\x36\n\tnamespace\x18\x02 \x01(\tB\x18\x92\x41\x15J\x13\"example-namespace\"R\tnamespace\"@\n\x0eUpsertResponse\x12.\n\x0eupserted_count\x18\x01 \x01(\rB\x07\x92\x41\x04J\x02\x31\x30R\rupsertedCount\"\xd9\x01\n\rDeleteRequest\x12-\n\x03ids\x18\x01 \x03(\tB\x1b\x92\x41\x18J\x10[\"id-0\", \"id-1\"]x\xe8\x07\x80\x01\x01R\x03ids\x12\x30\n\ndelete_all\x18\x02 \x01(\x08\x42\x11\x92\x41\x0e:\x05\x66\x61lseJ\x05\x66\x61lseR\tdeleteAll\x12\x36\n\tnamespace\x18\x03 \x01(\tB\x18\x92\x41\x15J\x13\"example-namespace\"R\tnamespace\x12/\n\x06\x66ilter\x18\x04 \x01(\x0b\x32\x17.google.protobuf.StructR\x06\x66ilter\"\x10\n\x0e\x44\x65leteResponse\"y\n\x0c\x46\x65tchRequest\x12\x31\n\x03ids\x18\x01 \x03(\tB\x1f\x92\x41\x18J\x10[\"id-0\", \"id-1\"]x\xe8\x07\x80\x01\x01\xe2\x41\x01\x02R\x03ids\x12\x36\n\tnamespace\x18\x02 \x01(\tB\x18\x92\x41\x15J\x13\"example-namespace\"R\tnamespace\"\x88\x02\n\rFetchResponse\x12\x35\n\x07vectors\x18\x01 \x03(\x0b\x32\x1b.FetchResponse.VectorsEntryR\x07vectors\x12\x36\n\tnamespace\x18\x02 \x01(\tB\x18\x92\x41\x15J\x13\"example-namespace\"R\tnamespace\x12\x39\n\x05usage\x18\x03 \x01(\x0b\x32\x06.UsageB\x16\x92\x41\x13J\x11{\"read_units\": 5}H\x00R\x05usage\x88\x01\x01\x1a\x43\n\x0cVectorsEntry\x12\x10\n\x03key\x18\x01 \x01(\tR\x03key\x12\x1d\n\x05value\x18\x02 \x01(\x0b\x32\x07.VectorR\x05value:\x02\x38\x01\x42\x08\n\x06_usage\"\xa3\x02\n\x0bListRequest\x12\x34\n\x06prefix\x18\x01 \x01(\tB\x17\x92\x41\x14J\x0c\"document1#\"x\xe8\x07\x80\x01\x01H\x00R\x06prefix\x88\x01\x01\x12\'\n\x05limit\x18\x02 \x01(\rB\x0c\x92\x41\t:\x03\x31\x30\x30J\x02\x31\x32H\x01R\x05limit\x88\x01\x01\x12S\n\x10pagination_token\x18\x03 \x01(\tB#\x92\x41 J\x1e\"Tm90aGluZyB0byBzZWUgaGVyZQo=\"H\x02R\x0fpaginationToken\x88\x01\x01\x12\x36\n\tnamespace\x18\x04 \x01(\tB\x18\x92\x41\x15J\x13\"example-namespace\"R\tnamespaceB\t\n\x07_prefixB\x08\n\x06_limitB\x13\n\x11_pagination_token\"E\n\nPagination\x12\x37\n\x04next\x18\x01 \x01(\tB#\x92\x41 J\x1e\"Tm90aGluZyB0byBzZWUgaGVyZQo=\"R\x04next\"0\n\x08ListItem\x12$\n\x02id\x18\x01 \x01(\tB\x14\x92\x41\x11J\x0f\"document1#abb\"R\x02id\"\xaa\x02\n\x0cListResponse\x12\\\n\x07vectors\x18\x01 \x03(\x0b\x32\t.ListItemB7\x92\x41\x34J2[{\"id\": \"document1#abb\"}, {\"id\": \"document1#abc\"}]R\x07vectors\x12\x30\n\npagination\x18\x02 \x01(\x0b\x32\x0b.PaginationH\x00R\npagination\x88\x01\x01\x12\x36\n\tnamespace\x18\x03 \x01(\tB\x18\x92\x41\x15J\x13\"example-namespace\"R\tnamespace\x12\x39\n\x05usage\x18\x04 \x01(\x0b\x32\x06.UsageB\x16\x92\x41\x13J\x11{\"read_units\": 1}H\x01R\x05usage\x88\x01\x01\x42\r\n\x0b_paginationB\x08\n\x06_usage\"\x81\x03\n\x0bQueryVector\x12P\n\x06values\x18\x01 \x03(\x02\x42\x38\x92\x41\x31J([0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8]x\xa0\x9c\x01\x80\x01\x01\xe2\x41\x01\x02R\x06values\x12\x32\n\rsparse_values\x18\x05 \x01(\x0b\x32\r.SparseValuesR\x0csparseValues\x12.\n\x05top_k\x18\x02 \x01(\rB\x19\x92\x41\x16J\x02\x31\x30Y\x00\x00\x00\x00\x00\x88\xc3@i\x00\x00\x00\x00\x00\x00\xf0?R\x04topK\x12\x36\n\tnamespace\x18\x03 \x01(\tB\x18\x92\x41\x15J\x13\"example-namespace\"R\tnamespace\x12\x83\x01\n\x06\x66ilter\x18\x04 \x01(\x0b\x32\x17.google.protobuf.StructBR\x92\x41OJM{\"genre\": {\"$in\": [\"comedy\", \"documentary\", \"drama\"]}, \"year\": {\"$eq\": 2019}}R\x06\x66ilter\"\xd8\x04\n\x0cQueryRequest\x12\x36\n\tnamespace\x18\x01 \x01(\tB\x18\x92\x41\x15J\x13\"example-namespace\"R\tnamespace\x12\x32\n\x05top_k\x18\x02 \x01(\rB\x1d\x92\x41\x16J\x02\x31\x30Y\x00\x00\x00\x00\x00\x88\xc3@i\x00\x00\x00\x00\x00\x00\xf0?\xe2\x41\x01\x02R\x04topK\x12\x83\x01\n\x06\x66ilter\x18\x03 \x01(\x0b\x32\x17.google.protobuf.StructBR\x92\x41OJM{\"genre\": {\"$in\": [\"comedy\", \"documentary\", \"drama\"]}, \"year\": {\"$eq\": 2019}}R\x06\x66ilter\x12\x37\n\x0einclude_values\x18\x04 \x01(\x08\x42\x10\x92\x41\r:\x05\x66\x61lseJ\x04trueR\rincludeValues\x12;\n\x10include_metadata\x18\x05 \x01(\x08\x42\x10\x92\x41\r:\x05\x66\x61lseJ\x04trueR\x0fincludeMetadata\x12\x32\n\x07queries\x18\x06 \x03(\x0b\x32\x0c.QueryVectorB\n\x18\x01\x92\x41\x05x\n\x80\x01\x01R\x07queries\x12L\n\x06vector\x18\x07 \x03(\x02\x42\x34\x92\x41\x31J([0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8]x\xa0\x9c\x01\x80\x01\x01R\x06vector\x12\x32\n\rsparse_vector\x18\t \x01(\x0b\x32\r.SparseValuesR\x0csparseVector\x12*\n\x02id\x18\x08 \x01(\tB\x1a\x92\x41\x17J\x12\"example-vector-1\"x\x80\x04R\x02id\"u\n\x12SingleQueryResults\x12\'\n\x07matches\x18\x01 \x03(\x0b\x32\r.ScoredVectorR\x07matches\x12\x36\n\tnamespace\x18\x02 \x01(\tB\x18\x92\x41\x15J\x13\"example-namespace\"R\tnamespace\"\xce\x01\n\rQueryResponse\x12\x31\n\x07results\x18\x01 \x03(\x0b\x32\x13.SingleQueryResultsB\x02\x18\x01R\x07results\x12\'\n\x07matches\x18\x02 \x03(\x0b\x32\r.ScoredVectorR\x07matches\x12\x1c\n\tnamespace\x18\x03 \x01(\tR\tnamespace\x12\x39\n\x05usage\x18\x04 \x01(\x0b\x32\x06.UsageB\x16\x92\x41\x13J\x11{\"read_units\": 5}H\x00R\x05usage\x88\x01\x01\x42\x08\n\x06_usage\"B\n\x05Usage\x12*\n\nread_units\x18\x01 \x01(\rB\x06\x92\x41\x03J\x01\x35H\x00R\treadUnits\x88\x01\x01\x42\r\n\x0b_read_units\"\xe5\x02\n\rUpdateRequest\x12\x31\n\x02id\x18\x01 \x01(\tB!\x92\x41\x1aJ\x12\"example-vector-1\"x\x80\x04\x80\x01\x01\xe2\x41\x01\x02R\x02id\x12L\n\x06values\x18\x02 \x03(\x02\x42\x34\x92\x41\x31J([0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8]x\xa0\x9c\x01\x80\x01\x01R\x06values\x12\x32\n\rsparse_values\x18\x05 \x01(\x0b\x32\r.SparseValuesR\x0csparseValues\x12g\n\x0cset_metadata\x18\x03 \x01(\x0b\x32\x17.google.protobuf.StructB+\x92\x41(J&{\"genre\": \"documentary\", \"year\": 2019}R\x0bsetMetadata\x12\x36\n\tnamespace\x18\x04 \x01(\tB\x18\x92\x41\x15J\x13\"example-namespace\"R\tnamespace\"\x10\n\x0eUpdateResponse\"L\n\x19\x44\x65scribeIndexStatsRequest\x12/\n\x06\x66ilter\x18\x01 \x01(\x0b\x32\x17.google.protobuf.StructR\x06\x66ilter\"A\n\x10NamespaceSummary\x12-\n\x0cvector_count\x18\x01 \x01(\rB\n\x92\x41\x07J\x05\x35\x30\x30\x30\x30R\x0bvectorCount\"\xde\x03\n\x1a\x44\x65scribeIndexStatsResponse\x12K\n\nnamespaces\x18\x01 \x03(\x0b\x32+.DescribeIndexStatsResponse.NamespacesEntryR\nnamespaces\x12\'\n\tdimension\x18\x02 \x01(\rB\t\x92\x41\x06J\x04\x31\x30\x32\x34R\tdimension\x12/\n\x0eindex_fullness\x18\x03 \x01(\x02\x42\x08\x92\x41\x05J\x03\x30.4R\rindexFullness\x12\x38\n\x12total_vector_count\x18\x04 \x01(\rB\n\x92\x41\x07J\x05\x38\x30\x30\x30\x30R\x10totalVectorCount\x1aP\n\x0fNamespacesEntry\x12\x10\n\x03key\x18\x01 \x01(\tR\x03key\x12\'\n\x05value\x18\x02 \x01(\x0b\x32\x11.NamespaceSummaryR\x05value:\x02\x38\x01:\x8c\x01\x92\x41\x88\x01\x32\x85\x01{\"namespaces\": {\"\": {\"vectorCount\": 50000}, \"example-namespace-2\": {\"vectorCount\": 30000}}, \"dimension\": 1024, \"index_fullness\": 0.4}2\x95\x06\n\rVectorService\x12\x63\n\x06Upsert\x12\x0e.UpsertRequest\x1a\x0f.UpsertResponse\"8\x92\x41\x1b\n\x11Vector Operations*\x06upsert\x82\xd3\xe4\x93\x02\x14\"\x0f/vectors/upsert:\x01*\x12v\n\x06\x44\x65lete\x12\x0e.DeleteRequest\x1a\x0f.DeleteResponse\"K\x92\x41\x1b\n\x11Vector Operations*\x06\x64\x65lete\x82\xd3\xe4\x93\x02\'\"\x0f/vectors/delete:\x01*Z\x11*\x0f/vectors/delete\x12[\n\x05\x46\x65tch\x12\r.FetchRequest\x1a\x0e.FetchResponse\"3\x92\x41\x1a\n\x11Vector Operations*\x05\x66\x65tch\x82\xd3\xe4\x93\x02\x10\x12\x0e/vectors/fetch\x12V\n\x04List\x12\x0c.ListRequest\x1a\r.ListResponse\"1\x92\x41\x19\n\x11Vector Operations*\x04list\x82\xd3\xe4\x93\x02\x0f\x12\r/vectors/list\x12V\n\x05Query\x12\r.QueryRequest\x1a\x0e.QueryResponse\".\x92\x41\x1a\n\x11Vector Operations*\x05query\x82\xd3\xe4\x93\x02\x0b\"\x06/query:\x01*\x12\x63\n\x06Update\x12\x0e.UpdateRequest\x1a\x0f.UpdateResponse\"8\x92\x41\x1b\n\x11Vector Operations*\x06update\x82\xd3\xe4\x93\x02\x14\"\x0f/vectors/update:\x01*\x12\xb4\x01\n\x12\x44\x65scribeIndexStats\x12\x1a.DescribeIndexStatsRequest\x1a\x1b.DescribeIndexStatsResponse\"e\x92\x41)\n\x11Vector Operations*\x14\x64\x65scribe_index_stats\x82\xd3\xe4\x93\x02\x33\"\x15/describe_index_stats:\x01*Z\x17\x12\x15/describe_index_statsB\xa3\x03\n\x11io.pinecone.protoB\x12VectorServiceProtoP\x01Z+github.com/pinecone-io/go-pinecone/pinecone\x92\x41\xc9\x02\x12K\n\x0cPinecone API\";\n\x0fPinecone.io Ops\x12\x13https://pinecone.io\x1a\x13support@pinecone.io\x1a\x0c{index_host}*\x01\x02\x32\x10\x61pplication/json:\x10\x61pplication/jsonZx\nv\n\nApiKeyAuth\x12h\x08\x02\x12YAn API Key is required to call Pinecone APIs. Get yours at https://www.pinecone.io/start/\x1a\x07\x41pi-Key \x02\x62\x10\n\x0e\n\nApiKeyAuth\x12\x00r9\n\x19More Pinecone.io API docs\x12\x1chttps://www.pinecone.io/docsb\x06proto3') + +_globals = globals() +_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) +_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'pinecone.data.v1.vector_service_pb2', _globals) +if _descriptor._USE_C_DESCRIPTORS == False: + _globals['DESCRIPTOR']._options = None + _globals['DESCRIPTOR']._serialized_options = b'\n\021io.pinecone.protoB\022VectorServiceProtoP\001Z+github.com/pinecone-io/go-pinecone/pinecone\222A\311\002\022K\n\014Pinecone API\";\n\017Pinecone.io Ops\022\023https://pinecone.io\032\023support@pinecone.io\032\014{index_host}*\001\0022\020application/json:\020application/jsonZx\nv\n\nApiKeyAuth\022h\010\002\022YAn API Key is required to call Pinecone APIs. Get yours at https://www.pinecone.io/start/\032\007Api-Key \002b\020\n\016\n\nApiKeyAuth\022\000r9\n\031More Pinecone.io API docs\022\034https://www.pinecone.io/docs' + _globals['_SPARSEVALUES'].fields_by_name['indices']._options = None + _globals['_SPARSEVALUES'].fields_by_name['indices']._serialized_options = b'\222A\036J\026[1, 312, 822, 14, 980]x\350\007\200\001\001\342A\001\002' + _globals['_SPARSEVALUES'].fields_by_name['values']._options = None + _globals['_SPARSEVALUES'].fields_by_name['values']._serialized_options = b'\222A!J\031[0.1, 0.2, 0.3, 0.4, 0.5]x\350\007\200\001\001\342A\001\002' + _globals['_VECTOR'].fields_by_name['id']._options = None + _globals['_VECTOR'].fields_by_name['id']._serialized_options = b'\222A\032J\022\"example-vector-1\"x\200\004\200\001\001\342A\001\002' + _globals['_VECTOR'].fields_by_name['values']._options = None + _globals['_VECTOR'].fields_by_name['values']._serialized_options = b'\222A1J([0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8]x\240\234\001\200\001\001\342A\001\002' + _globals['_VECTOR'].fields_by_name['metadata']._options = None + _globals['_VECTOR'].fields_by_name['metadata']._serialized_options = b'\222A(J&{\"genre\": \"documentary\", \"year\": 2019}' + _globals['_SCOREDVECTOR'].fields_by_name['id']._options = None + _globals['_SCOREDVECTOR'].fields_by_name['id']._serialized_options = b'\222A\032J\022\"example-vector-1\"x\200\004\200\001\001\342A\001\002' + _globals['_SCOREDVECTOR'].fields_by_name['score']._options = None + _globals['_SCOREDVECTOR'].fields_by_name['score']._serialized_options = b'\222A\006J\0040.08' + _globals['_SCOREDVECTOR'].fields_by_name['values']._options = None + _globals['_SCOREDVECTOR'].fields_by_name['values']._serialized_options = b'\222A*J([0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8]' + _globals['_SCOREDVECTOR'].fields_by_name['metadata']._options = None + _globals['_SCOREDVECTOR'].fields_by_name['metadata']._serialized_options = b'\222A(J&{\"genre\": \"documentary\", \"year\": 2019}' + _globals['_UPSERTREQUEST'].fields_by_name['vectors']._options = None + _globals['_UPSERTREQUEST'].fields_by_name['vectors']._serialized_options = b'\222A\006x\350\007\200\001\001\342A\001\002' + _globals['_UPSERTREQUEST'].fields_by_name['namespace']._options = None + _globals['_UPSERTREQUEST'].fields_by_name['namespace']._serialized_options = b'\222A\025J\023\"example-namespace\"' + _globals['_UPSERTRESPONSE'].fields_by_name['upserted_count']._options = None + _globals['_UPSERTRESPONSE'].fields_by_name['upserted_count']._serialized_options = b'\222A\004J\00210' + _globals['_DELETEREQUEST'].fields_by_name['ids']._options = None + _globals['_DELETEREQUEST'].fields_by_name['ids']._serialized_options = b'\222A\030J\020[\"id-0\", \"id-1\"]x\350\007\200\001\001' + _globals['_DELETEREQUEST'].fields_by_name['delete_all']._options = None + _globals['_DELETEREQUEST'].fields_by_name['delete_all']._serialized_options = b'\222A\016:\005falseJ\005false' + _globals['_DELETEREQUEST'].fields_by_name['namespace']._options = None + _globals['_DELETEREQUEST'].fields_by_name['namespace']._serialized_options = b'\222A\025J\023\"example-namespace\"' + _globals['_FETCHREQUEST'].fields_by_name['ids']._options = None + _globals['_FETCHREQUEST'].fields_by_name['ids']._serialized_options = b'\222A\030J\020[\"id-0\", \"id-1\"]x\350\007\200\001\001\342A\001\002' + _globals['_FETCHREQUEST'].fields_by_name['namespace']._options = None + _globals['_FETCHREQUEST'].fields_by_name['namespace']._serialized_options = b'\222A\025J\023\"example-namespace\"' + _globals['_FETCHRESPONSE_VECTORSENTRY']._options = None + _globals['_FETCHRESPONSE_VECTORSENTRY']._serialized_options = b'8\001' + _globals['_FETCHRESPONSE'].fields_by_name['namespace']._options = None + _globals['_FETCHRESPONSE'].fields_by_name['namespace']._serialized_options = b'\222A\025J\023\"example-namespace\"' + _globals['_FETCHRESPONSE'].fields_by_name['usage']._options = None + _globals['_FETCHRESPONSE'].fields_by_name['usage']._serialized_options = b'\222A\023J\021{\"read_units\": 5}' + _globals['_LISTREQUEST'].fields_by_name['prefix']._options = None + _globals['_LISTREQUEST'].fields_by_name['prefix']._serialized_options = b'\222A\024J\014\"document1#\"x\350\007\200\001\001' + _globals['_LISTREQUEST'].fields_by_name['limit']._options = None + _globals['_LISTREQUEST'].fields_by_name['limit']._serialized_options = b'\222A\t:\003100J\00212' + _globals['_LISTREQUEST'].fields_by_name['pagination_token']._options = None + _globals['_LISTREQUEST'].fields_by_name['pagination_token']._serialized_options = b'\222A J\036\"Tm90aGluZyB0byBzZWUgaGVyZQo=\"' + _globals['_LISTREQUEST'].fields_by_name['namespace']._options = None + _globals['_LISTREQUEST'].fields_by_name['namespace']._serialized_options = b'\222A\025J\023\"example-namespace\"' + _globals['_PAGINATION'].fields_by_name['next']._options = None + _globals['_PAGINATION'].fields_by_name['next']._serialized_options = b'\222A J\036\"Tm90aGluZyB0byBzZWUgaGVyZQo=\"' + _globals['_LISTITEM'].fields_by_name['id']._options = None + _globals['_LISTITEM'].fields_by_name['id']._serialized_options = b'\222A\021J\017\"document1#abb\"' + _globals['_LISTRESPONSE'].fields_by_name['vectors']._options = None + _globals['_LISTRESPONSE'].fields_by_name['vectors']._serialized_options = b'\222A4J2[{\"id\": \"document1#abb\"}, {\"id\": \"document1#abc\"}]' + _globals['_LISTRESPONSE'].fields_by_name['namespace']._options = None + _globals['_LISTRESPONSE'].fields_by_name['namespace']._serialized_options = b'\222A\025J\023\"example-namespace\"' + _globals['_LISTRESPONSE'].fields_by_name['usage']._options = None + _globals['_LISTRESPONSE'].fields_by_name['usage']._serialized_options = b'\222A\023J\021{\"read_units\": 1}' + _globals['_QUERYVECTOR'].fields_by_name['values']._options = None + _globals['_QUERYVECTOR'].fields_by_name['values']._serialized_options = b'\222A1J([0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8]x\240\234\001\200\001\001\342A\001\002' + _globals['_QUERYVECTOR'].fields_by_name['top_k']._options = None + _globals['_QUERYVECTOR'].fields_by_name['top_k']._serialized_options = b'\222A\026J\00210Y\000\000\000\000\000\210\303@i\000\000\000\000\000\000\360?' + _globals['_QUERYVECTOR'].fields_by_name['namespace']._options = None + _globals['_QUERYVECTOR'].fields_by_name['namespace']._serialized_options = b'\222A\025J\023\"example-namespace\"' + _globals['_QUERYVECTOR'].fields_by_name['filter']._options = None + _globals['_QUERYVECTOR'].fields_by_name['filter']._serialized_options = b'\222AOJM{\"genre\": {\"$in\": [\"comedy\", \"documentary\", \"drama\"]}, \"year\": {\"$eq\": 2019}}' + _globals['_QUERYREQUEST'].fields_by_name['namespace']._options = None + _globals['_QUERYREQUEST'].fields_by_name['namespace']._serialized_options = b'\222A\025J\023\"example-namespace\"' + _globals['_QUERYREQUEST'].fields_by_name['top_k']._options = None + _globals['_QUERYREQUEST'].fields_by_name['top_k']._serialized_options = b'\222A\026J\00210Y\000\000\000\000\000\210\303@i\000\000\000\000\000\000\360?\342A\001\002' + _globals['_QUERYREQUEST'].fields_by_name['filter']._options = None + _globals['_QUERYREQUEST'].fields_by_name['filter']._serialized_options = b'\222AOJM{\"genre\": {\"$in\": [\"comedy\", \"documentary\", \"drama\"]}, \"year\": {\"$eq\": 2019}}' + _globals['_QUERYREQUEST'].fields_by_name['include_values']._options = None + _globals['_QUERYREQUEST'].fields_by_name['include_values']._serialized_options = b'\222A\r:\005falseJ\004true' + _globals['_QUERYREQUEST'].fields_by_name['include_metadata']._options = None + _globals['_QUERYREQUEST'].fields_by_name['include_metadata']._serialized_options = b'\222A\r:\005falseJ\004true' + _globals['_QUERYREQUEST'].fields_by_name['queries']._options = None + _globals['_QUERYREQUEST'].fields_by_name['queries']._serialized_options = b'\030\001\222A\005x\n\200\001\001' + _globals['_QUERYREQUEST'].fields_by_name['vector']._options = None + _globals['_QUERYREQUEST'].fields_by_name['vector']._serialized_options = b'\222A1J([0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8]x\240\234\001\200\001\001' + _globals['_QUERYREQUEST'].fields_by_name['id']._options = None + _globals['_QUERYREQUEST'].fields_by_name['id']._serialized_options = b'\222A\027J\022\"example-vector-1\"x\200\004' + _globals['_SINGLEQUERYRESULTS'].fields_by_name['namespace']._options = None + _globals['_SINGLEQUERYRESULTS'].fields_by_name['namespace']._serialized_options = b'\222A\025J\023\"example-namespace\"' + _globals['_QUERYRESPONSE'].fields_by_name['results']._options = None + _globals['_QUERYRESPONSE'].fields_by_name['results']._serialized_options = b'\030\001' + _globals['_QUERYRESPONSE'].fields_by_name['usage']._options = None + _globals['_QUERYRESPONSE'].fields_by_name['usage']._serialized_options = b'\222A\023J\021{\"read_units\": 5}' + _globals['_USAGE'].fields_by_name['read_units']._options = None + _globals['_USAGE'].fields_by_name['read_units']._serialized_options = b'\222A\003J\0015' + _globals['_UPDATEREQUEST'].fields_by_name['id']._options = None + _globals['_UPDATEREQUEST'].fields_by_name['id']._serialized_options = b'\222A\032J\022\"example-vector-1\"x\200\004\200\001\001\342A\001\002' + _globals['_UPDATEREQUEST'].fields_by_name['values']._options = None + _globals['_UPDATEREQUEST'].fields_by_name['values']._serialized_options = b'\222A1J([0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8]x\240\234\001\200\001\001' + _globals['_UPDATEREQUEST'].fields_by_name['set_metadata']._options = None + _globals['_UPDATEREQUEST'].fields_by_name['set_metadata']._serialized_options = b'\222A(J&{\"genre\": \"documentary\", \"year\": 2019}' + _globals['_UPDATEREQUEST'].fields_by_name['namespace']._options = None + _globals['_UPDATEREQUEST'].fields_by_name['namespace']._serialized_options = b'\222A\025J\023\"example-namespace\"' + _globals['_NAMESPACESUMMARY'].fields_by_name['vector_count']._options = None + _globals['_NAMESPACESUMMARY'].fields_by_name['vector_count']._serialized_options = b'\222A\007J\00550000' + _globals['_DESCRIBEINDEXSTATSRESPONSE_NAMESPACESENTRY']._options = None + _globals['_DESCRIBEINDEXSTATSRESPONSE_NAMESPACESENTRY']._serialized_options = b'8\001' + _globals['_DESCRIBEINDEXSTATSRESPONSE'].fields_by_name['dimension']._options = None + _globals['_DESCRIBEINDEXSTATSRESPONSE'].fields_by_name['dimension']._serialized_options = b'\222A\006J\0041024' + _globals['_DESCRIBEINDEXSTATSRESPONSE'].fields_by_name['index_fullness']._options = None + _globals['_DESCRIBEINDEXSTATSRESPONSE'].fields_by_name['index_fullness']._serialized_options = b'\222A\005J\0030.4' + _globals['_DESCRIBEINDEXSTATSRESPONSE'].fields_by_name['total_vector_count']._options = None + _globals['_DESCRIBEINDEXSTATSRESPONSE'].fields_by_name['total_vector_count']._serialized_options = b'\222A\007J\00580000' + _globals['_DESCRIBEINDEXSTATSRESPONSE']._options = None + _globals['_DESCRIBEINDEXSTATSRESPONSE']._serialized_options = b'\222A\210\0012\205\001{\"namespaces\": {\"\": {\"vectorCount\": 50000}, \"example-namespace-2\": {\"vectorCount\": 30000}}, \"dimension\": 1024, \"index_fullness\": 0.4}' + _globals['_VECTORSERVICE'].methods_by_name['Upsert']._options = None + _globals['_VECTORSERVICE'].methods_by_name['Upsert']._serialized_options = b'\222A\033\n\021Vector Operations*\006upsert\202\323\344\223\002\024\"\017/vectors/upsert:\001*' + _globals['_VECTORSERVICE'].methods_by_name['Delete']._options = None + _globals['_VECTORSERVICE'].methods_by_name['Delete']._serialized_options = b'\222A\033\n\021Vector Operations*\006delete\202\323\344\223\002\'\"\017/vectors/delete:\001*Z\021*\017/vectors/delete' + _globals['_VECTORSERVICE'].methods_by_name['Fetch']._options = None + _globals['_VECTORSERVICE'].methods_by_name['Fetch']._serialized_options = b'\222A\032\n\021Vector Operations*\005fetch\202\323\344\223\002\020\022\016/vectors/fetch' + _globals['_VECTORSERVICE'].methods_by_name['List']._options = None + _globals['_VECTORSERVICE'].methods_by_name['List']._serialized_options = b'\222A\031\n\021Vector Operations*\004list\202\323\344\223\002\017\022\r/vectors/list' + _globals['_VECTORSERVICE'].methods_by_name['Query']._options = None + _globals['_VECTORSERVICE'].methods_by_name['Query']._serialized_options = b'\222A\032\n\021Vector Operations*\005query\202\323\344\223\002\013\"\006/query:\001*' + _globals['_VECTORSERVICE'].methods_by_name['Update']._options = None + _globals['_VECTORSERVICE'].methods_by_name['Update']._serialized_options = b'\222A\033\n\021Vector Operations*\006update\202\323\344\223\002\024\"\017/vectors/update:\001*' + _globals['_VECTORSERVICE'].methods_by_name['DescribeIndexStats']._options = None + _globals['_VECTORSERVICE'].methods_by_name['DescribeIndexStats']._serialized_options = b'\222A)\n\021Vector Operations*\024describe_index_stats\202\323\344\223\0023\"\025/describe_index_stats:\001*Z\027\022\025/describe_index_stats' + _globals['_SPARSEVALUES']._serialized_start=183 + _globals['_SPARSEVALUES']._serialized_end=328 + _globals['_VECTOR']._serialized_start=331 + _globals['_VECTOR']._serialized_end=622 + _globals['_SCOREDVECTOR']._serialized_start=625 + _globals['_SCOREDVECTOR']._serialized_end=944 + _globals['_REQUESTUNION']._serialized_start=947 + _globals['_REQUESTUNION']._serialized_end=1108 + _globals['_UPSERTREQUEST']._serialized_start=1110 + _globals['_UPSERTREQUEST']._serialized_end=1231 + _globals['_UPSERTRESPONSE']._serialized_start=1233 + _globals['_UPSERTRESPONSE']._serialized_end=1297 + _globals['_DELETEREQUEST']._serialized_start=1300 + _globals['_DELETEREQUEST']._serialized_end=1517 + _globals['_DELETERESPONSE']._serialized_start=1519 + _globals['_DELETERESPONSE']._serialized_end=1535 + _globals['_FETCHREQUEST']._serialized_start=1537 + _globals['_FETCHREQUEST']._serialized_end=1658 + _globals['_FETCHRESPONSE']._serialized_start=1661 + _globals['_FETCHRESPONSE']._serialized_end=1925 + _globals['_FETCHRESPONSE_VECTORSENTRY']._serialized_start=1848 + _globals['_FETCHRESPONSE_VECTORSENTRY']._serialized_end=1915 + _globals['_LISTREQUEST']._serialized_start=1928 + _globals['_LISTREQUEST']._serialized_end=2219 + _globals['_PAGINATION']._serialized_start=2221 + _globals['_PAGINATION']._serialized_end=2290 + _globals['_LISTITEM']._serialized_start=2292 + _globals['_LISTITEM']._serialized_end=2340 + _globals['_LISTRESPONSE']._serialized_start=2343 + _globals['_LISTRESPONSE']._serialized_end=2641 + _globals['_QUERYVECTOR']._serialized_start=2644 + _globals['_QUERYVECTOR']._serialized_end=3029 + _globals['_QUERYREQUEST']._serialized_start=3032 + _globals['_QUERYREQUEST']._serialized_end=3632 + _globals['_SINGLEQUERYRESULTS']._serialized_start=3634 + _globals['_SINGLEQUERYRESULTS']._serialized_end=3751 + _globals['_QUERYRESPONSE']._serialized_start=3754 + _globals['_QUERYRESPONSE']._serialized_end=3960 + _globals['_USAGE']._serialized_start=3962 + _globals['_USAGE']._serialized_end=4028 + _globals['_UPDATEREQUEST']._serialized_start=4031 + _globals['_UPDATEREQUEST']._serialized_end=4388 + _globals['_UPDATERESPONSE']._serialized_start=4390 + _globals['_UPDATERESPONSE']._serialized_end=4406 + _globals['_DESCRIBEINDEXSTATSREQUEST']._serialized_start=4408 + _globals['_DESCRIBEINDEXSTATSREQUEST']._serialized_end=4484 + _globals['_NAMESPACESUMMARY']._serialized_start=4486 + _globals['_NAMESPACESUMMARY']._serialized_end=4551 + _globals['_DESCRIBEINDEXSTATSRESPONSE']._serialized_start=4554 + _globals['_DESCRIBEINDEXSTATSRESPONSE']._serialized_end=5032 + _globals['_DESCRIBEINDEXSTATSRESPONSE_NAMESPACESENTRY']._serialized_start=4809 + _globals['_DESCRIBEINDEXSTATSRESPONSE_NAMESPACESENTRY']._serialized_end=4889 + _globals['_VECTORSERVICE']._serialized_start=5035 + _globals['_VECTORSERVICE']._serialized_end=5824 # @@protoc_insertion_point(module_scope) diff --git a/pinecone/core/grpc/protos/vector_service_pb2.pyi b/pinecone/core/grpc/protos/vector_service_pb2.pyi index 3ffa7f4c8..89945d66a 100644 --- a/pinecone/core/grpc/protos/vector_service_pb2.pyi +++ b/pinecone/core/grpc/protos/vector_service_pb2.pyi @@ -2,503 +2,711 @@ @generated by mypy-protobuf. Do not edit manually! isort:skip_file """ -from google.protobuf.descriptor import ( - Descriptor as google___protobuf___descriptor___Descriptor, - FileDescriptor as google___protobuf___descriptor___FileDescriptor, -) - -from google.protobuf.internal.containers import ( - MessageMap as google___protobuf___internal___containers___MessageMap, - RepeatedCompositeFieldContainer as google___protobuf___internal___containers___RepeatedCompositeFieldContainer, - RepeatedScalarFieldContainer as google___protobuf___internal___containers___RepeatedScalarFieldContainer, -) - -from google.protobuf.message import ( - Message as google___protobuf___message___Message, -) - -from google.protobuf.struct_pb2 import ( - Struct as google___protobuf___struct_pb2___Struct, -) - -from typing import ( - Iterable as typing___Iterable, - Mapping as typing___Mapping, - Optional as typing___Optional, - Text as typing___Text, - overload as typing___overload, -) - -from typing_extensions import ( - Literal as typing_extensions___Literal, -) - - -builtin___bool = bool -builtin___bytes = bytes -builtin___float = float -builtin___int = int - - -DESCRIPTOR: google___protobuf___descriptor___FileDescriptor = ... - -class SparseValues(google___protobuf___message___Message): - DESCRIPTOR: google___protobuf___descriptor___Descriptor = ... - indices: google___protobuf___internal___containers___RepeatedScalarFieldContainer[builtin___int] = ... - values: google___protobuf___internal___containers___RepeatedScalarFieldContainer[builtin___float] = ... - - def __init__(self, +import builtins +import collections.abc +import google.protobuf.descriptor +import google.protobuf.internal.containers +import google.protobuf.message +import google.protobuf.struct_pb2 +import sys +import typing + +if sys.version_info >= (3, 8): + import typing as typing_extensions +else: + import typing_extensions + +DESCRIPTOR: google.protobuf.descriptor.FileDescriptor + +@typing_extensions.final +class SparseValues(google.protobuf.message.Message): + DESCRIPTOR: google.protobuf.descriptor.Descriptor + + INDICES_FIELD_NUMBER: builtins.int + VALUES_FIELD_NUMBER: builtins.int + @property + def indices(self) -> google.protobuf.internal.containers.RepeatedScalarFieldContainer[builtins.int]: ... + @property + def values(self) -> google.protobuf.internal.containers.RepeatedScalarFieldContainer[builtins.float]: ... + def __init__( + self, *, - indices : typing___Optional[typing___Iterable[builtin___int]] = None, - values : typing___Optional[typing___Iterable[builtin___float]] = None, - ) -> None: ... - def ClearField(self, field_name: typing_extensions___Literal[u"indices",b"indices",u"values",b"values"]) -> None: ... -type___SparseValues = SparseValues + indices: collections.abc.Iterable[builtins.int] | None = ..., + values: collections.abc.Iterable[builtins.float] | None = ..., + ) -> None: ... + def ClearField(self, field_name: typing_extensions.Literal["indices", b"indices", "values", b"values"]) -> None: ... + +global___SparseValues = SparseValues + +@typing_extensions.final +class Vector(google.protobuf.message.Message): + DESCRIPTOR: google.protobuf.descriptor.Descriptor + + ID_FIELD_NUMBER: builtins.int + VALUES_FIELD_NUMBER: builtins.int + SPARSE_VALUES_FIELD_NUMBER: builtins.int + METADATA_FIELD_NUMBER: builtins.int + id: builtins.str + """This is the vector's unique id.""" + @property + def values(self) -> google.protobuf.internal.containers.RepeatedScalarFieldContainer[builtins.float]: + """This is the vector data included in the request.""" + @property + def sparse_values(self) -> global___SparseValues: ... + @property + def metadata(self) -> google.protobuf.struct_pb2.Struct: + """This is the metadata included in the request.""" + def __init__( + self, + *, + id: builtins.str = ..., + values: collections.abc.Iterable[builtins.float] | None = ..., + sparse_values: global___SparseValues | None = ..., + metadata: google.protobuf.struct_pb2.Struct | None = ..., + ) -> None: ... + def HasField(self, field_name: typing_extensions.Literal["metadata", b"metadata", "sparse_values", b"sparse_values"]) -> builtins.bool: ... + def ClearField(self, field_name: typing_extensions.Literal["id", b"id", "metadata", b"metadata", "sparse_values", b"sparse_values", "values", b"values"]) -> None: ... + +global___Vector = Vector + +@typing_extensions.final +class ScoredVector(google.protobuf.message.Message): + DESCRIPTOR: google.protobuf.descriptor.Descriptor + + ID_FIELD_NUMBER: builtins.int + SCORE_FIELD_NUMBER: builtins.int + VALUES_FIELD_NUMBER: builtins.int + SPARSE_VALUES_FIELD_NUMBER: builtins.int + METADATA_FIELD_NUMBER: builtins.int + id: builtins.str + """This is the vector's unique id.""" + score: builtins.float + """This is a measure of similarity between this vector and the query vector. The higher the score, the more they are similar.""" + @property + def values(self) -> google.protobuf.internal.containers.RepeatedScalarFieldContainer[builtins.float]: + """This is the vector data, if it is requested.""" + @property + def sparse_values(self) -> global___SparseValues: + """This is the sparse data, if it is requested.""" + @property + def metadata(self) -> google.protobuf.struct_pb2.Struct: + """This is the metadata, if it is requested.""" + def __init__( + self, + *, + id: builtins.str = ..., + score: builtins.float = ..., + values: collections.abc.Iterable[builtins.float] | None = ..., + sparse_values: global___SparseValues | None = ..., + metadata: google.protobuf.struct_pb2.Struct | None = ..., + ) -> None: ... + def HasField(self, field_name: typing_extensions.Literal["metadata", b"metadata", "sparse_values", b"sparse_values"]) -> builtins.bool: ... + def ClearField(self, field_name: typing_extensions.Literal["id", b"id", "metadata", b"metadata", "score", b"score", "sparse_values", b"sparse_values", "values", b"values"]) -> None: ... + +global___ScoredVector = ScoredVector + +@typing_extensions.final +class RequestUnion(google.protobuf.message.Message): + """This is a container to hold mutating vector requests. This is not actually used + in any public APIs. + """ + + DESCRIPTOR: google.protobuf.descriptor.Descriptor + + UPSERT_FIELD_NUMBER: builtins.int + DELETE_FIELD_NUMBER: builtins.int + UPDATE_FIELD_NUMBER: builtins.int + @property + def upsert(self) -> global___UpsertRequest: ... + @property + def delete(self) -> global___DeleteRequest: ... + @property + def update(self) -> global___UpdateRequest: ... + def __init__( + self, + *, + upsert: global___UpsertRequest | None = ..., + delete: global___DeleteRequest | None = ..., + update: global___UpdateRequest | None = ..., + ) -> None: ... + def HasField(self, field_name: typing_extensions.Literal["RequestUnionInner", b"RequestUnionInner", "delete", b"delete", "update", b"update", "upsert", b"upsert"]) -> builtins.bool: ... + def ClearField(self, field_name: typing_extensions.Literal["RequestUnionInner", b"RequestUnionInner", "delete", b"delete", "update", b"update", "upsert", b"upsert"]) -> None: ... + def WhichOneof(self, oneof_group: typing_extensions.Literal["RequestUnionInner", b"RequestUnionInner"]) -> typing_extensions.Literal["upsert", "delete", "update"] | None: ... -class Vector(google___protobuf___message___Message): - DESCRIPTOR: google___protobuf___descriptor___Descriptor = ... - id: typing___Text = ... - values: google___protobuf___internal___containers___RepeatedScalarFieldContainer[builtin___float] = ... +global___RequestUnion = RequestUnion - @property - def sparse_values(self) -> type___SparseValues: ... +@typing_extensions.final +class UpsertRequest(google.protobuf.message.Message): + """The request for the `upsert` operation.""" - @property - def metadata(self) -> google___protobuf___struct_pb2___Struct: ... + DESCRIPTOR: google.protobuf.descriptor.Descriptor - def __init__(self, + VECTORS_FIELD_NUMBER: builtins.int + NAMESPACE_FIELD_NUMBER: builtins.int + @property + def vectors(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___Vector]: + """An array containing the vectors to upsert. Recommended batch limit is 100 vectors.""" + namespace: builtins.str + """This is the namespace name where you upsert vectors.""" + def __init__( + self, *, - id : typing___Optional[typing___Text] = None, - values : typing___Optional[typing___Iterable[builtin___float]] = None, - sparse_values : typing___Optional[type___SparseValues] = None, - metadata : typing___Optional[google___protobuf___struct_pb2___Struct] = None, - ) -> None: ... - def HasField(self, field_name: typing_extensions___Literal[u"metadata",b"metadata",u"sparse_values",b"sparse_values"]) -> builtin___bool: ... - def ClearField(self, field_name: typing_extensions___Literal[u"id",b"id",u"metadata",b"metadata",u"sparse_values",b"sparse_values",u"values",b"values"]) -> None: ... -type___Vector = Vector + vectors: collections.abc.Iterable[global___Vector] | None = ..., + namespace: builtins.str = ..., + ) -> None: ... + def ClearField(self, field_name: typing_extensions.Literal["namespace", b"namespace", "vectors", b"vectors"]) -> None: ... -class ScoredVector(google___protobuf___message___Message): - DESCRIPTOR: google___protobuf___descriptor___Descriptor = ... - id: typing___Text = ... - score: builtin___float = ... - values: google___protobuf___internal___containers___RepeatedScalarFieldContainer[builtin___float] = ... +global___UpsertRequest = UpsertRequest - @property - def sparse_values(self) -> type___SparseValues: ... +@typing_extensions.final +class UpsertResponse(google.protobuf.message.Message): + """The response for the `upsert` operation.""" - @property - def metadata(self) -> google___protobuf___struct_pb2___Struct: ... + DESCRIPTOR: google.protobuf.descriptor.Descriptor - def __init__(self, + UPSERTED_COUNT_FIELD_NUMBER: builtins.int + upserted_count: builtins.int + """The number of vectors upserted.""" + def __init__( + self, *, - id : typing___Optional[typing___Text] = None, - score : typing___Optional[builtin___float] = None, - values : typing___Optional[typing___Iterable[builtin___float]] = None, - sparse_values : typing___Optional[type___SparseValues] = None, - metadata : typing___Optional[google___protobuf___struct_pb2___Struct] = None, - ) -> None: ... - def HasField(self, field_name: typing_extensions___Literal[u"metadata",b"metadata",u"sparse_values",b"sparse_values"]) -> builtin___bool: ... - def ClearField(self, field_name: typing_extensions___Literal[u"id",b"id",u"metadata",b"metadata",u"score",b"score",u"sparse_values",b"sparse_values",u"values",b"values"]) -> None: ... -type___ScoredVector = ScoredVector + upserted_count: builtins.int = ..., + ) -> None: ... + def ClearField(self, field_name: typing_extensions.Literal["upserted_count", b"upserted_count"]) -> None: ... -class RequestUnion(google___protobuf___message___Message): - DESCRIPTOR: google___protobuf___descriptor___Descriptor = ... +global___UpsertResponse = UpsertResponse - @property - def upsert(self) -> type___UpsertRequest: ... +@typing_extensions.final +class DeleteRequest(google.protobuf.message.Message): + """The request for the `Delete` operation.""" - @property - def delete(self) -> type___DeleteRequest: ... + DESCRIPTOR: google.protobuf.descriptor.Descriptor + IDS_FIELD_NUMBER: builtins.int + DELETE_ALL_FIELD_NUMBER: builtins.int + NAMESPACE_FIELD_NUMBER: builtins.int + FILTER_FIELD_NUMBER: builtins.int @property - def update(self) -> type___UpdateRequest: ... - - def __init__(self, + def ids(self) -> google.protobuf.internal.containers.RepeatedScalarFieldContainer[builtins.str]: + """Vectors to delete.""" + delete_all: builtins.bool + """This indicates that all vectors in the index namespace should be deleted.""" + namespace: builtins.str + """The namespace to delete vectors from, if applicable.""" + @property + def filter(self) -> google.protobuf.struct_pb2.Struct: + """If specified, the metadata filter here will be used to select the vectors to delete. This is mutually exclusive + with specifying ids to delete in the ids param or using delete_all=True. + See https://www.pinecone.io/docs/metadata-filtering/. + """ + def __init__( + self, *, - upsert : typing___Optional[type___UpsertRequest] = None, - delete : typing___Optional[type___DeleteRequest] = None, - update : typing___Optional[type___UpdateRequest] = None, - ) -> None: ... - def HasField(self, field_name: typing_extensions___Literal[u"RequestUnionInner",b"RequestUnionInner",u"delete",b"delete",u"update",b"update",u"upsert",b"upsert"]) -> builtin___bool: ... - def ClearField(self, field_name: typing_extensions___Literal[u"RequestUnionInner",b"RequestUnionInner",u"delete",b"delete",u"update",b"update",u"upsert",b"upsert"]) -> None: ... - def WhichOneof(self, oneof_group: typing_extensions___Literal[u"RequestUnionInner",b"RequestUnionInner"]) -> typing_extensions___Literal["upsert","delete","update"]: ... -type___RequestUnion = RequestUnion + ids: collections.abc.Iterable[builtins.str] | None = ..., + delete_all: builtins.bool = ..., + namespace: builtins.str = ..., + filter: google.protobuf.struct_pb2.Struct | None = ..., + ) -> None: ... + def HasField(self, field_name: typing_extensions.Literal["filter", b"filter"]) -> builtins.bool: ... + def ClearField(self, field_name: typing_extensions.Literal["delete_all", b"delete_all", "filter", b"filter", "ids", b"ids", "namespace", b"namespace"]) -> None: ... -class UpsertRequest(google___protobuf___message___Message): - DESCRIPTOR: google___protobuf___descriptor___Descriptor = ... - namespace: typing___Text = ... +global___DeleteRequest = DeleteRequest - @property - def vectors(self) -> google___protobuf___internal___containers___RepeatedCompositeFieldContainer[type___Vector]: ... +@typing_extensions.final +class DeleteResponse(google.protobuf.message.Message): + """The response for the `Delete` operation.""" - def __init__(self, - *, - vectors : typing___Optional[typing___Iterable[type___Vector]] = None, - namespace : typing___Optional[typing___Text] = None, - ) -> None: ... - def ClearField(self, field_name: typing_extensions___Literal[u"namespace",b"namespace",u"vectors",b"vectors"]) -> None: ... -type___UpsertRequest = UpsertRequest + DESCRIPTOR: google.protobuf.descriptor.Descriptor -class UpsertResponse(google___protobuf___message___Message): - DESCRIPTOR: google___protobuf___descriptor___Descriptor = ... - upserted_count: builtin___int = ... + def __init__( + self, + ) -> None: ... - def __init__(self, - *, - upserted_count : typing___Optional[builtin___int] = None, - ) -> None: ... - def ClearField(self, field_name: typing_extensions___Literal[u"upserted_count",b"upserted_count"]) -> None: ... -type___UpsertResponse = UpsertResponse +global___DeleteResponse = DeleteResponse -class DeleteRequest(google___protobuf___message___Message): - DESCRIPTOR: google___protobuf___descriptor___Descriptor = ... - ids: google___protobuf___internal___containers___RepeatedScalarFieldContainer[typing___Text] = ... - delete_all: builtin___bool = ... - namespace: typing___Text = ... +@typing_extensions.final +class FetchRequest(google.protobuf.message.Message): + """The request for the `fetch` operation.""" - @property - def filter(self) -> google___protobuf___struct_pb2___Struct: ... + DESCRIPTOR: google.protobuf.descriptor.Descriptor - def __init__(self, + IDS_FIELD_NUMBER: builtins.int + NAMESPACE_FIELD_NUMBER: builtins.int + @property + def ids(self) -> google.protobuf.internal.containers.RepeatedScalarFieldContainer[builtins.str]: + """The vector IDs to fetch. Does not accept values containing spaces.""" + namespace: builtins.str + def __init__( + self, *, - ids : typing___Optional[typing___Iterable[typing___Text]] = None, - delete_all : typing___Optional[builtin___bool] = None, - namespace : typing___Optional[typing___Text] = None, - filter : typing___Optional[google___protobuf___struct_pb2___Struct] = None, - ) -> None: ... - def HasField(self, field_name: typing_extensions___Literal[u"filter",b"filter"]) -> builtin___bool: ... - def ClearField(self, field_name: typing_extensions___Literal[u"delete_all",b"delete_all",u"filter",b"filter",u"ids",b"ids",u"namespace",b"namespace"]) -> None: ... -type___DeleteRequest = DeleteRequest + ids: collections.abc.Iterable[builtins.str] | None = ..., + namespace: builtins.str = ..., + ) -> None: ... + def ClearField(self, field_name: typing_extensions.Literal["ids", b"ids", "namespace", b"namespace"]) -> None: ... -class DeleteResponse(google___protobuf___message___Message): - DESCRIPTOR: google___protobuf___descriptor___Descriptor = ... +global___FetchRequest = FetchRequest - def __init__(self, - ) -> None: ... -type___DeleteResponse = DeleteResponse - -class FetchRequest(google___protobuf___message___Message): - DESCRIPTOR: google___protobuf___descriptor___Descriptor = ... - ids: google___protobuf___internal___containers___RepeatedScalarFieldContainer[typing___Text] = ... - namespace: typing___Text = ... +@typing_extensions.final +class FetchResponse(google.protobuf.message.Message): + """The response for the `fetch` operation.""" - def __init__(self, - *, - ids : typing___Optional[typing___Iterable[typing___Text]] = None, - namespace : typing___Optional[typing___Text] = None, - ) -> None: ... - def ClearField(self, field_name: typing_extensions___Literal[u"ids",b"ids",u"namespace",b"namespace"]) -> None: ... -type___FetchRequest = FetchRequest + DESCRIPTOR: google.protobuf.descriptor.Descriptor -class FetchResponse(google___protobuf___message___Message): - DESCRIPTOR: google___protobuf___descriptor___Descriptor = ... - class VectorsEntry(google___protobuf___message___Message): - DESCRIPTOR: google___protobuf___descriptor___Descriptor = ... - key: typing___Text = ... + @typing_extensions.final + class VectorsEntry(google.protobuf.message.Message): + DESCRIPTOR: google.protobuf.descriptor.Descriptor + KEY_FIELD_NUMBER: builtins.int + VALUE_FIELD_NUMBER: builtins.int + key: builtins.str @property - def value(self) -> type___Vector: ... - - def __init__(self, + def value(self) -> global___Vector: ... + def __init__( + self, *, - key : typing___Optional[typing___Text] = None, - value : typing___Optional[type___Vector] = None, - ) -> None: ... - def HasField(self, field_name: typing_extensions___Literal[u"value",b"value"]) -> builtin___bool: ... - def ClearField(self, field_name: typing_extensions___Literal[u"key",b"key",u"value",b"value"]) -> None: ... - type___VectorsEntry = VectorsEntry - - namespace: typing___Text = ... + key: builtins.str = ..., + value: global___Vector | None = ..., + ) -> None: ... + def HasField(self, field_name: typing_extensions.Literal["value", b"value"]) -> builtins.bool: ... + def ClearField(self, field_name: typing_extensions.Literal["key", b"key", "value", b"value"]) -> None: ... + VECTORS_FIELD_NUMBER: builtins.int + NAMESPACE_FIELD_NUMBER: builtins.int + USAGE_FIELD_NUMBER: builtins.int @property - def vectors(self) -> google___protobuf___internal___containers___MessageMap[typing___Text, type___Vector]: ... - + def vectors(self) -> google.protobuf.internal.containers.MessageMap[builtins.str, global___Vector]: + """The fetched vectors, in the form of a map between the fetched ids and the fetched vectors""" + namespace: builtins.str + """The namespace of the vectors.""" @property - def usage(self) -> type___Usage: ... - - def __init__(self, + def usage(self) -> global___Usage: + """ The usage for this operation.""" + def __init__( + self, *, - vectors : typing___Optional[typing___Mapping[typing___Text, type___Vector]] = None, - namespace : typing___Optional[typing___Text] = None, - usage : typing___Optional[type___Usage] = None, - ) -> None: ... - def HasField(self, field_name: typing_extensions___Literal[u"_usage",b"_usage",u"usage",b"usage"]) -> builtin___bool: ... - def ClearField(self, field_name: typing_extensions___Literal[u"_usage",b"_usage",u"namespace",b"namespace",u"usage",b"usage",u"vectors",b"vectors"]) -> None: ... - def WhichOneof(self, oneof_group: typing_extensions___Literal[u"_usage",b"_usage"]) -> typing_extensions___Literal["usage"]: ... -type___FetchResponse = FetchResponse - -class ListRequest(google___protobuf___message___Message): - DESCRIPTOR: google___protobuf___descriptor___Descriptor = ... - prefix: typing___Text = ... - limit: builtin___int = ... - pagination_token: typing___Text = ... - namespace: typing___Text = ... - - def __init__(self, + vectors: collections.abc.Mapping[builtins.str, global___Vector] | None = ..., + namespace: builtins.str = ..., + usage: global___Usage | None = ..., + ) -> None: ... + def HasField(self, field_name: typing_extensions.Literal["_usage", b"_usage", "usage", b"usage"]) -> builtins.bool: ... + def ClearField(self, field_name: typing_extensions.Literal["_usage", b"_usage", "namespace", b"namespace", "usage", b"usage", "vectors", b"vectors"]) -> None: ... + def WhichOneof(self, oneof_group: typing_extensions.Literal["_usage", b"_usage"]) -> typing_extensions.Literal["usage"] | None: ... + +global___FetchResponse = FetchResponse + +@typing_extensions.final +class ListRequest(google.protobuf.message.Message): + """The request for the `list` operation.""" + + DESCRIPTOR: google.protobuf.descriptor.Descriptor + + PREFIX_FIELD_NUMBER: builtins.int + LIMIT_FIELD_NUMBER: builtins.int + PAGINATION_TOKEN_FIELD_NUMBER: builtins.int + NAMESPACE_FIELD_NUMBER: builtins.int + prefix: builtins.str + """The vector IDs to fetch. Does not accept values containing spaces.""" + limit: builtins.int + """Max number of IDs to return per page.""" + pagination_token: builtins.str + """Pagination token to continue a previous listing operation.""" + namespace: builtins.str + def __init__( + self, *, - prefix : typing___Optional[typing___Text] = None, - limit : typing___Optional[builtin___int] = None, - pagination_token : typing___Optional[typing___Text] = None, - namespace : typing___Optional[typing___Text] = None, - ) -> None: ... - def HasField(self, field_name: typing_extensions___Literal[u"_limit",b"_limit",u"_pagination_token",b"_pagination_token",u"_prefix",b"_prefix",u"limit",b"limit",u"pagination_token",b"pagination_token",u"prefix",b"prefix"]) -> builtin___bool: ... - def ClearField(self, field_name: typing_extensions___Literal[u"_limit",b"_limit",u"_pagination_token",b"_pagination_token",u"_prefix",b"_prefix",u"limit",b"limit",u"namespace",b"namespace",u"pagination_token",b"pagination_token",u"prefix",b"prefix"]) -> None: ... - @typing___overload - def WhichOneof(self, oneof_group: typing_extensions___Literal[u"_limit",b"_limit"]) -> typing_extensions___Literal["limit"]: ... - @typing___overload - def WhichOneof(self, oneof_group: typing_extensions___Literal[u"_pagination_token",b"_pagination_token"]) -> typing_extensions___Literal["pagination_token"]: ... - @typing___overload - def WhichOneof(self, oneof_group: typing_extensions___Literal[u"_prefix",b"_prefix"]) -> typing_extensions___Literal["prefix"]: ... -type___ListRequest = ListRequest - -class Pagination(google___protobuf___message___Message): - DESCRIPTOR: google___protobuf___descriptor___Descriptor = ... - next: typing___Text = ... - - def __init__(self, + prefix: builtins.str | None = ..., + limit: builtins.int | None = ..., + pagination_token: builtins.str | None = ..., + namespace: builtins.str = ..., + ) -> None: ... + def HasField(self, field_name: typing_extensions.Literal["_limit", b"_limit", "_pagination_token", b"_pagination_token", "_prefix", b"_prefix", "limit", b"limit", "pagination_token", b"pagination_token", "prefix", b"prefix"]) -> builtins.bool: ... + def ClearField(self, field_name: typing_extensions.Literal["_limit", b"_limit", "_pagination_token", b"_pagination_token", "_prefix", b"_prefix", "limit", b"limit", "namespace", b"namespace", "pagination_token", b"pagination_token", "prefix", b"prefix"]) -> None: ... + @typing.overload + def WhichOneof(self, oneof_group: typing_extensions.Literal["_limit", b"_limit"]) -> typing_extensions.Literal["limit"] | None: ... + @typing.overload + def WhichOneof(self, oneof_group: typing_extensions.Literal["_pagination_token", b"_pagination_token"]) -> typing_extensions.Literal["pagination_token"] | None: ... + @typing.overload + def WhichOneof(self, oneof_group: typing_extensions.Literal["_prefix", b"_prefix"]) -> typing_extensions.Literal["prefix"] | None: ... + +global___ListRequest = ListRequest + +@typing_extensions.final +class Pagination(google.protobuf.message.Message): + DESCRIPTOR: google.protobuf.descriptor.Descriptor + + NEXT_FIELD_NUMBER: builtins.int + next: builtins.str + def __init__( + self, *, - next : typing___Optional[typing___Text] = None, - ) -> None: ... - def ClearField(self, field_name: typing_extensions___Literal[u"next",b"next"]) -> None: ... -type___Pagination = Pagination + next: builtins.str = ..., + ) -> None: ... + def ClearField(self, field_name: typing_extensions.Literal["next", b"next"]) -> None: ... -class ListItem(google___protobuf___message___Message): - DESCRIPTOR: google___protobuf___descriptor___Descriptor = ... - id: typing___Text = ... +global___Pagination = Pagination - def __init__(self, +@typing_extensions.final +class ListItem(google.protobuf.message.Message): + DESCRIPTOR: google.protobuf.descriptor.Descriptor + + ID_FIELD_NUMBER: builtins.int + id: builtins.str + def __init__( + self, *, - id : typing___Optional[typing___Text] = None, - ) -> None: ... - def ClearField(self, field_name: typing_extensions___Literal[u"id",b"id"]) -> None: ... -type___ListItem = ListItem + id: builtins.str = ..., + ) -> None: ... + def ClearField(self, field_name: typing_extensions.Literal["id", b"id"]) -> None: ... -class ListResponse(google___protobuf___message___Message): - DESCRIPTOR: google___protobuf___descriptor___Descriptor = ... - namespace: typing___Text = ... +global___ListItem = ListItem - @property - def vectors(self) -> google___protobuf___internal___containers___RepeatedCompositeFieldContainer[type___ListItem]: ... +@typing_extensions.final +class ListResponse(google.protobuf.message.Message): + """The response for the `List` operation.""" - @property - def pagination(self) -> type___Pagination: ... + DESCRIPTOR: google.protobuf.descriptor.Descriptor + VECTORS_FIELD_NUMBER: builtins.int + PAGINATION_FIELD_NUMBER: builtins.int + NAMESPACE_FIELD_NUMBER: builtins.int + USAGE_FIELD_NUMBER: builtins.int @property - def usage(self) -> type___Usage: ... - - def __init__(self, + def vectors(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___ListItem]: + """A list of ids""" + @property + def pagination(self) -> global___Pagination: + """Pagination token to continue past this listing""" + namespace: builtins.str + """The namespace of the vectors.""" + @property + def usage(self) -> global___Usage: + """ The usage for this operation.""" + def __init__( + self, *, - vectors : typing___Optional[typing___Iterable[type___ListItem]] = None, - pagination : typing___Optional[type___Pagination] = None, - namespace : typing___Optional[typing___Text] = None, - usage : typing___Optional[type___Usage] = None, - ) -> None: ... - def HasField(self, field_name: typing_extensions___Literal[u"_pagination",b"_pagination",u"_usage",b"_usage",u"pagination",b"pagination",u"usage",b"usage"]) -> builtin___bool: ... - def ClearField(self, field_name: typing_extensions___Literal[u"_pagination",b"_pagination",u"_usage",b"_usage",u"namespace",b"namespace",u"pagination",b"pagination",u"usage",b"usage",u"vectors",b"vectors"]) -> None: ... - @typing___overload - def WhichOneof(self, oneof_group: typing_extensions___Literal[u"_pagination",b"_pagination"]) -> typing_extensions___Literal["pagination"]: ... - @typing___overload - def WhichOneof(self, oneof_group: typing_extensions___Literal[u"_usage",b"_usage"]) -> typing_extensions___Literal["usage"]: ... -type___ListResponse = ListResponse - -class QueryVector(google___protobuf___message___Message): - DESCRIPTOR: google___protobuf___descriptor___Descriptor = ... - values: google___protobuf___internal___containers___RepeatedScalarFieldContainer[builtin___float] = ... - top_k: builtin___int = ... - namespace: typing___Text = ... - + vectors: collections.abc.Iterable[global___ListItem] | None = ..., + pagination: global___Pagination | None = ..., + namespace: builtins.str = ..., + usage: global___Usage | None = ..., + ) -> None: ... + def HasField(self, field_name: typing_extensions.Literal["_pagination", b"_pagination", "_usage", b"_usage", "pagination", b"pagination", "usage", b"usage"]) -> builtins.bool: ... + def ClearField(self, field_name: typing_extensions.Literal["_pagination", b"_pagination", "_usage", b"_usage", "namespace", b"namespace", "pagination", b"pagination", "usage", b"usage", "vectors", b"vectors"]) -> None: ... + @typing.overload + def WhichOneof(self, oneof_group: typing_extensions.Literal["_pagination", b"_pagination"]) -> typing_extensions.Literal["pagination"] | None: ... + @typing.overload + def WhichOneof(self, oneof_group: typing_extensions.Literal["_usage", b"_usage"]) -> typing_extensions.Literal["usage"] | None: ... + +global___ListResponse = ListResponse + +@typing_extensions.final +class QueryVector(google.protobuf.message.Message): + """A single query vector within a `QueryRequest`.""" + + DESCRIPTOR: google.protobuf.descriptor.Descriptor + + VALUES_FIELD_NUMBER: builtins.int + SPARSE_VALUES_FIELD_NUMBER: builtins.int + TOP_K_FIELD_NUMBER: builtins.int + NAMESPACE_FIELD_NUMBER: builtins.int + FILTER_FIELD_NUMBER: builtins.int @property - def sparse_values(self) -> type___SparseValues: ... - + def values(self) -> google.protobuf.internal.containers.RepeatedScalarFieldContainer[builtins.float]: + """The query vector values. This should be the same length as the dimension of the index being queried.""" @property - def filter(self) -> google___protobuf___struct_pb2___Struct: ... - - def __init__(self, + def sparse_values(self) -> global___SparseValues: + """The query sparse values.""" + top_k: builtins.int + """An override for the number of results to return for this query vector.""" + namespace: builtins.str + """An override the namespace to search.""" + @property + def filter(self) -> google.protobuf.struct_pb2.Struct: + """An override for the metadata filter to apply. This replaces the request-level filter.""" + def __init__( + self, *, - values : typing___Optional[typing___Iterable[builtin___float]] = None, - sparse_values : typing___Optional[type___SparseValues] = None, - top_k : typing___Optional[builtin___int] = None, - namespace : typing___Optional[typing___Text] = None, - filter : typing___Optional[google___protobuf___struct_pb2___Struct] = None, - ) -> None: ... - def HasField(self, field_name: typing_extensions___Literal[u"filter",b"filter",u"sparse_values",b"sparse_values"]) -> builtin___bool: ... - def ClearField(self, field_name: typing_extensions___Literal[u"filter",b"filter",u"namespace",b"namespace",u"sparse_values",b"sparse_values",u"top_k",b"top_k",u"values",b"values"]) -> None: ... -type___QueryVector = QueryVector - -class QueryRequest(google___protobuf___message___Message): - DESCRIPTOR: google___protobuf___descriptor___Descriptor = ... - namespace: typing___Text = ... - top_k: builtin___int = ... - include_values: builtin___bool = ... - include_metadata: builtin___bool = ... - vector: google___protobuf___internal___containers___RepeatedScalarFieldContainer[builtin___float] = ... - id: typing___Text = ... - + values: collections.abc.Iterable[builtins.float] | None = ..., + sparse_values: global___SparseValues | None = ..., + top_k: builtins.int = ..., + namespace: builtins.str = ..., + filter: google.protobuf.struct_pb2.Struct | None = ..., + ) -> None: ... + def HasField(self, field_name: typing_extensions.Literal["filter", b"filter", "sparse_values", b"sparse_values"]) -> builtins.bool: ... + def ClearField(self, field_name: typing_extensions.Literal["filter", b"filter", "namespace", b"namespace", "sparse_values", b"sparse_values", "top_k", b"top_k", "values", b"values"]) -> None: ... + +global___QueryVector = QueryVector + +@typing_extensions.final +class QueryRequest(google.protobuf.message.Message): + """The request for the `query` operation.""" + + DESCRIPTOR: google.protobuf.descriptor.Descriptor + + NAMESPACE_FIELD_NUMBER: builtins.int + TOP_K_FIELD_NUMBER: builtins.int + FILTER_FIELD_NUMBER: builtins.int + INCLUDE_VALUES_FIELD_NUMBER: builtins.int + INCLUDE_METADATA_FIELD_NUMBER: builtins.int + QUERIES_FIELD_NUMBER: builtins.int + VECTOR_FIELD_NUMBER: builtins.int + SPARSE_VECTOR_FIELD_NUMBER: builtins.int + ID_FIELD_NUMBER: builtins.int + namespace: builtins.str + """The namespace to query.""" + top_k: builtins.int + """The number of results to return for each query.""" @property - def filter(self) -> google___protobuf___struct_pb2___Struct: ... - + def filter(self) -> google.protobuf.struct_pb2.Struct: + """The filter to apply. You can use vector metadata to limit your search. See https://www.pinecone.io/docs/metadata-filtering/.""" + include_values: builtins.bool + """Indicates whether vector values are included in the response.""" + include_metadata: builtins.bool + """Indicates whether metadata is included in the response as well as the ids.""" @property - def queries(self) -> google___protobuf___internal___containers___RepeatedCompositeFieldContainer[type___QueryVector]: ... - + def queries(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___QueryVector]: + """DEPRECATED. The query vectors. Each `query()` request can contain only one of the parameters `queries`, `vector`, or `id`.""" @property - def sparse_vector(self) -> type___SparseValues: ... - - def __init__(self, + def vector(self) -> google.protobuf.internal.containers.RepeatedScalarFieldContainer[builtins.float]: + """The query vector. This should be the same length as the dimension of the index being queried. Each `query()` request can contain only one of the parameters `id` or `vector`.""" + @property + def sparse_vector(self) -> global___SparseValues: + """The query sparse values.""" + id: builtins.str + """The unique ID of the vector to be used as a query vector. Each `query()` request can contain only one of the parameters `queries`, `vector`, or `id`.""" + def __init__( + self, *, - namespace : typing___Optional[typing___Text] = None, - top_k : typing___Optional[builtin___int] = None, - filter : typing___Optional[google___protobuf___struct_pb2___Struct] = None, - include_values : typing___Optional[builtin___bool] = None, - include_metadata : typing___Optional[builtin___bool] = None, - queries : typing___Optional[typing___Iterable[type___QueryVector]] = None, - vector : typing___Optional[typing___Iterable[builtin___float]] = None, - sparse_vector : typing___Optional[type___SparseValues] = None, - id : typing___Optional[typing___Text] = None, - ) -> None: ... - def HasField(self, field_name: typing_extensions___Literal[u"filter",b"filter",u"sparse_vector",b"sparse_vector"]) -> builtin___bool: ... - def ClearField(self, field_name: typing_extensions___Literal[u"filter",b"filter",u"id",b"id",u"include_metadata",b"include_metadata",u"include_values",b"include_values",u"namespace",b"namespace",u"queries",b"queries",u"sparse_vector",b"sparse_vector",u"top_k",b"top_k",u"vector",b"vector"]) -> None: ... -type___QueryRequest = QueryRequest - -class SingleQueryResults(google___protobuf___message___Message): - DESCRIPTOR: google___protobuf___descriptor___Descriptor = ... - namespace: typing___Text = ... - + namespace: builtins.str = ..., + top_k: builtins.int = ..., + filter: google.protobuf.struct_pb2.Struct | None = ..., + include_values: builtins.bool = ..., + include_metadata: builtins.bool = ..., + queries: collections.abc.Iterable[global___QueryVector] | None = ..., + vector: collections.abc.Iterable[builtins.float] | None = ..., + sparse_vector: global___SparseValues | None = ..., + id: builtins.str = ..., + ) -> None: ... + def HasField(self, field_name: typing_extensions.Literal["filter", b"filter", "sparse_vector", b"sparse_vector"]) -> builtins.bool: ... + def ClearField(self, field_name: typing_extensions.Literal["filter", b"filter", "id", b"id", "include_metadata", b"include_metadata", "include_values", b"include_values", "namespace", b"namespace", "queries", b"queries", "sparse_vector", b"sparse_vector", "top_k", b"top_k", "vector", b"vector"]) -> None: ... + +global___QueryRequest = QueryRequest + +@typing_extensions.final +class SingleQueryResults(google.protobuf.message.Message): + """The query results for a single `QueryVector`""" + + DESCRIPTOR: google.protobuf.descriptor.Descriptor + + MATCHES_FIELD_NUMBER: builtins.int + NAMESPACE_FIELD_NUMBER: builtins.int @property - def matches(self) -> google___protobuf___internal___containers___RepeatedCompositeFieldContainer[type___ScoredVector]: ... - - def __init__(self, + def matches(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___ScoredVector]: + """The matches for the vectors.""" + namespace: builtins.str + """The namespace for the vectors.""" + def __init__( + self, *, - matches : typing___Optional[typing___Iterable[type___ScoredVector]] = None, - namespace : typing___Optional[typing___Text] = None, - ) -> None: ... - def ClearField(self, field_name: typing_extensions___Literal[u"matches",b"matches",u"namespace",b"namespace"]) -> None: ... -type___SingleQueryResults = SingleQueryResults + matches: collections.abc.Iterable[global___ScoredVector] | None = ..., + namespace: builtins.str = ..., + ) -> None: ... + def ClearField(self, field_name: typing_extensions.Literal["matches", b"matches", "namespace", b"namespace"]) -> None: ... -class QueryResponse(google___protobuf___message___Message): - DESCRIPTOR: google___protobuf___descriptor___Descriptor = ... - namespace: typing___Text = ... +global___SingleQueryResults = SingleQueryResults - @property - def results(self) -> google___protobuf___internal___containers___RepeatedCompositeFieldContainer[type___SingleQueryResults]: ... +@typing_extensions.final +class QueryResponse(google.protobuf.message.Message): + """The response for the `query` operation. These are the matches found for a particular query vector. The matches are ordered from most similar to least similar.""" - @property - def matches(self) -> google___protobuf___internal___containers___RepeatedCompositeFieldContainer[type___ScoredVector]: ... + DESCRIPTOR: google.protobuf.descriptor.Descriptor + RESULTS_FIELD_NUMBER: builtins.int + MATCHES_FIELD_NUMBER: builtins.int + NAMESPACE_FIELD_NUMBER: builtins.int + USAGE_FIELD_NUMBER: builtins.int @property - def usage(self) -> type___Usage: ... - - def __init__(self, + def results(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___SingleQueryResults]: + """DEPRECATED. The results of each query. The order is the same as `QueryRequest.queries`.""" + @property + def matches(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___ScoredVector]: + """The matches for the vectors.""" + namespace: builtins.str + """The namespace for the vectors.""" + @property + def usage(self) -> global___Usage: + """The usage for this operation.""" + def __init__( + self, *, - results : typing___Optional[typing___Iterable[type___SingleQueryResults]] = None, - matches : typing___Optional[typing___Iterable[type___ScoredVector]] = None, - namespace : typing___Optional[typing___Text] = None, - usage : typing___Optional[type___Usage] = None, - ) -> None: ... - def HasField(self, field_name: typing_extensions___Literal[u"_usage",b"_usage",u"usage",b"usage"]) -> builtin___bool: ... - def ClearField(self, field_name: typing_extensions___Literal[u"_usage",b"_usage",u"matches",b"matches",u"namespace",b"namespace",u"results",b"results",u"usage",b"usage"]) -> None: ... - def WhichOneof(self, oneof_group: typing_extensions___Literal[u"_usage",b"_usage"]) -> typing_extensions___Literal["usage"]: ... -type___QueryResponse = QueryResponse - -class Usage(google___protobuf___message___Message): - DESCRIPTOR: google___protobuf___descriptor___Descriptor = ... - read_units: builtin___int = ... - - def __init__(self, + results: collections.abc.Iterable[global___SingleQueryResults] | None = ..., + matches: collections.abc.Iterable[global___ScoredVector] | None = ..., + namespace: builtins.str = ..., + usage: global___Usage | None = ..., + ) -> None: ... + def HasField(self, field_name: typing_extensions.Literal["_usage", b"_usage", "usage", b"usage"]) -> builtins.bool: ... + def ClearField(self, field_name: typing_extensions.Literal["_usage", b"_usage", "matches", b"matches", "namespace", b"namespace", "results", b"results", "usage", b"usage"]) -> None: ... + def WhichOneof(self, oneof_group: typing_extensions.Literal["_usage", b"_usage"]) -> typing_extensions.Literal["usage"] | None: ... + +global___QueryResponse = QueryResponse + +@typing_extensions.final +class Usage(google.protobuf.message.Message): + DESCRIPTOR: google.protobuf.descriptor.Descriptor + + READ_UNITS_FIELD_NUMBER: builtins.int + read_units: builtins.int + """The number of read units consumed by this operation.""" + def __init__( + self, *, - read_units : typing___Optional[builtin___int] = None, - ) -> None: ... - def HasField(self, field_name: typing_extensions___Literal[u"_read_units",b"_read_units",u"read_units",b"read_units"]) -> builtin___bool: ... - def ClearField(self, field_name: typing_extensions___Literal[u"_read_units",b"_read_units",u"read_units",b"read_units"]) -> None: ... - def WhichOneof(self, oneof_group: typing_extensions___Literal[u"_read_units",b"_read_units"]) -> typing_extensions___Literal["read_units"]: ... -type___Usage = Usage + read_units: builtins.int | None = ..., + ) -> None: ... + def HasField(self, field_name: typing_extensions.Literal["_read_units", b"_read_units", "read_units", b"read_units"]) -> builtins.bool: ... + def ClearField(self, field_name: typing_extensions.Literal["_read_units", b"_read_units", "read_units", b"read_units"]) -> None: ... + def WhichOneof(self, oneof_group: typing_extensions.Literal["_read_units", b"_read_units"]) -> typing_extensions.Literal["read_units"] | None: ... + +global___Usage = Usage + +@typing_extensions.final +class UpdateRequest(google.protobuf.message.Message): + """The request for the `update` operation.""" + + DESCRIPTOR: google.protobuf.descriptor.Descriptor + + ID_FIELD_NUMBER: builtins.int + VALUES_FIELD_NUMBER: builtins.int + SPARSE_VALUES_FIELD_NUMBER: builtins.int + SET_METADATA_FIELD_NUMBER: builtins.int + NAMESPACE_FIELD_NUMBER: builtins.int + id: builtins.str + """Vector's unique id.""" + @property + def values(self) -> google.protobuf.internal.containers.RepeatedScalarFieldContainer[builtins.float]: + """Vector data.""" + @property + def sparse_values(self) -> global___SparseValues: ... + @property + def set_metadata(self) -> google.protobuf.struct_pb2.Struct: + """Metadata to *set* for the vector.""" + namespace: builtins.str + """Namespace name where to update the vector.""" + def __init__( + self, + *, + id: builtins.str = ..., + values: collections.abc.Iterable[builtins.float] | None = ..., + sparse_values: global___SparseValues | None = ..., + set_metadata: google.protobuf.struct_pb2.Struct | None = ..., + namespace: builtins.str = ..., + ) -> None: ... + def HasField(self, field_name: typing_extensions.Literal["set_metadata", b"set_metadata", "sparse_values", b"sparse_values"]) -> builtins.bool: ... + def ClearField(self, field_name: typing_extensions.Literal["id", b"id", "namespace", b"namespace", "set_metadata", b"set_metadata", "sparse_values", b"sparse_values", "values", b"values"]) -> None: ... -class UpdateRequest(google___protobuf___message___Message): - DESCRIPTOR: google___protobuf___descriptor___Descriptor = ... - id: typing___Text = ... - values: google___protobuf___internal___containers___RepeatedScalarFieldContainer[builtin___float] = ... - namespace: typing___Text = ... +global___UpdateRequest = UpdateRequest - @property - def sparse_values(self) -> type___SparseValues: ... +@typing_extensions.final +class UpdateResponse(google.protobuf.message.Message): + """The response for the `update` operation.""" - @property - def set_metadata(self) -> google___protobuf___struct_pb2___Struct: ... + DESCRIPTOR: google.protobuf.descriptor.Descriptor - def __init__(self, - *, - id : typing___Optional[typing___Text] = None, - values : typing___Optional[typing___Iterable[builtin___float]] = None, - sparse_values : typing___Optional[type___SparseValues] = None, - set_metadata : typing___Optional[google___protobuf___struct_pb2___Struct] = None, - namespace : typing___Optional[typing___Text] = None, - ) -> None: ... - def HasField(self, field_name: typing_extensions___Literal[u"set_metadata",b"set_metadata",u"sparse_values",b"sparse_values"]) -> builtin___bool: ... - def ClearField(self, field_name: typing_extensions___Literal[u"id",b"id",u"namespace",b"namespace",u"set_metadata",b"set_metadata",u"sparse_values",b"sparse_values",u"values",b"values"]) -> None: ... -type___UpdateRequest = UpdateRequest + def __init__( + self, + ) -> None: ... -class UpdateResponse(google___protobuf___message___Message): - DESCRIPTOR: google___protobuf___descriptor___Descriptor = ... +global___UpdateResponse = UpdateResponse - def __init__(self, - ) -> None: ... -type___UpdateResponse = UpdateResponse +@typing_extensions.final +class DescribeIndexStatsRequest(google.protobuf.message.Message): + """The request for the `describe_index_stats` operation.""" -class DescribeIndexStatsRequest(google___protobuf___message___Message): - DESCRIPTOR: google___protobuf___descriptor___Descriptor = ... + DESCRIPTOR: google.protobuf.descriptor.Descriptor + FILTER_FIELD_NUMBER: builtins.int @property - def filter(self) -> google___protobuf___struct_pb2___Struct: ... - - def __init__(self, + def filter(self) -> google.protobuf.struct_pb2.Struct: + """If this parameter is present, the operation only returns statistics + for vectors that satisfy the filter. + See https://www.pinecone.io/docs/metadata-filtering/. + """ + def __init__( + self, *, - filter : typing___Optional[google___protobuf___struct_pb2___Struct] = None, - ) -> None: ... - def HasField(self, field_name: typing_extensions___Literal[u"filter",b"filter"]) -> builtin___bool: ... - def ClearField(self, field_name: typing_extensions___Literal[u"filter",b"filter"]) -> None: ... -type___DescribeIndexStatsRequest = DescribeIndexStatsRequest + filter: google.protobuf.struct_pb2.Struct | None = ..., + ) -> None: ... + def HasField(self, field_name: typing_extensions.Literal["filter", b"filter"]) -> builtins.bool: ... + def ClearField(self, field_name: typing_extensions.Literal["filter", b"filter"]) -> None: ... + +global___DescribeIndexStatsRequest = DescribeIndexStatsRequest + +@typing_extensions.final +class NamespaceSummary(google.protobuf.message.Message): + """A summary of the contents of a namespace.""" + + DESCRIPTOR: google.protobuf.descriptor.Descriptor + + VECTOR_COUNT_FIELD_NUMBER: builtins.int + vector_count: builtins.int + """The number of vectors stored in this namespace. Note that updates to this field may lag behind updates to the + underlying index and corresponding query results, etc. + """ + def __init__( + self, + *, + vector_count: builtins.int = ..., + ) -> None: ... + def ClearField(self, field_name: typing_extensions.Literal["vector_count", b"vector_count"]) -> None: ... -class NamespaceSummary(google___protobuf___message___Message): - DESCRIPTOR: google___protobuf___descriptor___Descriptor = ... - vector_count: builtin___int = ... +global___NamespaceSummary = NamespaceSummary - def __init__(self, - *, - vector_count : typing___Optional[builtin___int] = None, - ) -> None: ... - def ClearField(self, field_name: typing_extensions___Literal[u"vector_count",b"vector_count"]) -> None: ... -type___NamespaceSummary = NamespaceSummary +@typing_extensions.final +class DescribeIndexStatsResponse(google.protobuf.message.Message): + """The response for the `describe_index_stats` operation.""" -class DescribeIndexStatsResponse(google___protobuf___message___Message): - DESCRIPTOR: google___protobuf___descriptor___Descriptor = ... - class NamespacesEntry(google___protobuf___message___Message): - DESCRIPTOR: google___protobuf___descriptor___Descriptor = ... - key: typing___Text = ... + DESCRIPTOR: google.protobuf.descriptor.Descriptor - @property - def value(self) -> type___NamespaceSummary: ... + @typing_extensions.final + class NamespacesEntry(google.protobuf.message.Message): + DESCRIPTOR: google.protobuf.descriptor.Descriptor - def __init__(self, + KEY_FIELD_NUMBER: builtins.int + VALUE_FIELD_NUMBER: builtins.int + key: builtins.str + @property + def value(self) -> global___NamespaceSummary: ... + def __init__( + self, *, - key : typing___Optional[typing___Text] = None, - value : typing___Optional[type___NamespaceSummary] = None, - ) -> None: ... - def HasField(self, field_name: typing_extensions___Literal[u"value",b"value"]) -> builtin___bool: ... - def ClearField(self, field_name: typing_extensions___Literal[u"key",b"key",u"value",b"value"]) -> None: ... - type___NamespacesEntry = NamespacesEntry - - dimension: builtin___int = ... - index_fullness: builtin___float = ... - total_vector_count: builtin___int = ... + key: builtins.str = ..., + value: global___NamespaceSummary | None = ..., + ) -> None: ... + def HasField(self, field_name: typing_extensions.Literal["value", b"value"]) -> builtins.bool: ... + def ClearField(self, field_name: typing_extensions.Literal["key", b"key", "value", b"value"]) -> None: ... + NAMESPACES_FIELD_NUMBER: builtins.int + DIMENSION_FIELD_NUMBER: builtins.int + INDEX_FULLNESS_FIELD_NUMBER: builtins.int + TOTAL_VECTOR_COUNT_FIELD_NUMBER: builtins.int @property - def namespaces(self) -> google___protobuf___internal___containers___MessageMap[typing___Text, type___NamespaceSummary]: ... - - def __init__(self, + def namespaces(self) -> google.protobuf.internal.containers.MessageMap[builtins.str, global___NamespaceSummary]: + """A mapping for each namespace in the index from the namespace name to a + summary of its contents. If a metadata filter expression is present, the + summary will reflect only vectors matching that expression. + """ + dimension: builtins.int + """The dimension of the indexed vectors.""" + index_fullness: builtins.float + """The fullness of the index, regardless of whether a metadata filter expression was passed. The granularity of this metric is 10%.""" + total_vector_count: builtins.int + """The total number of vectors in the index, regardless of whether a metadata filter expression was passed""" + def __init__( + self, *, - namespaces : typing___Optional[typing___Mapping[typing___Text, type___NamespaceSummary]] = None, - dimension : typing___Optional[builtin___int] = None, - index_fullness : typing___Optional[builtin___float] = None, - total_vector_count : typing___Optional[builtin___int] = None, - ) -> None: ... - def ClearField(self, field_name: typing_extensions___Literal[u"dimension",b"dimension",u"index_fullness",b"index_fullness",u"namespaces",b"namespaces",u"total_vector_count",b"total_vector_count"]) -> None: ... -type___DescribeIndexStatsResponse = DescribeIndexStatsResponse + namespaces: collections.abc.Mapping[builtins.str, global___NamespaceSummary] | None = ..., + dimension: builtins.int = ..., + index_fullness: builtins.float = ..., + total_vector_count: builtins.int = ..., + ) -> None: ... + def ClearField(self, field_name: typing_extensions.Literal["dimension", b"dimension", "index_fullness", b"index_fullness", "namespaces", b"namespaces", "total_vector_count", b"total_vector_count"]) -> None: ... + +global___DescribeIndexStatsResponse = DescribeIndexStatsResponse diff --git a/pinecone/core/grpc/protos/vector_service_pb2_grpc.py b/pinecone/core/grpc/protos/vector_service_pb2_grpc.py index cdde2f852..492648a77 100644 --- a/pinecone/core/grpc/protos/vector_service_pb2_grpc.py +++ b/pinecone/core/grpc/protos/vector_service_pb2_grpc.py @@ -17,38 +17,38 @@ def __init__(self, channel): """ self.Upsert = channel.unary_unary( '/VectorService/Upsert', - request_serializer=vector__service__pb2.UpsertRequest.SerializeToString, - response_deserializer=vector__service__pb2.UpsertResponse.FromString, + request_serializer=pinecone_dot_data_dot_v1_dot_vector__service__pb2.UpsertRequest.SerializeToString, + response_deserializer=pinecone_dot_data_dot_v1_dot_vector__service__pb2.UpsertResponse.FromString, ) self.Delete = channel.unary_unary( '/VectorService/Delete', - request_serializer=vector__service__pb2.DeleteRequest.SerializeToString, - response_deserializer=vector__service__pb2.DeleteResponse.FromString, + request_serializer=pinecone_dot_data_dot_v1_dot_vector__service__pb2.DeleteRequest.SerializeToString, + response_deserializer=pinecone_dot_data_dot_v1_dot_vector__service__pb2.DeleteResponse.FromString, ) self.Fetch = channel.unary_unary( '/VectorService/Fetch', - request_serializer=vector__service__pb2.FetchRequest.SerializeToString, - response_deserializer=vector__service__pb2.FetchResponse.FromString, + request_serializer=pinecone_dot_data_dot_v1_dot_vector__service__pb2.FetchRequest.SerializeToString, + response_deserializer=pinecone_dot_data_dot_v1_dot_vector__service__pb2.FetchResponse.FromString, ) self.List = channel.unary_unary( '/VectorService/List', - request_serializer=vector__service__pb2.ListRequest.SerializeToString, - response_deserializer=vector__service__pb2.ListResponse.FromString, + request_serializer=pinecone_dot_data_dot_v1_dot_vector__service__pb2.ListRequest.SerializeToString, + response_deserializer=pinecone_dot_data_dot_v1_dot_vector__service__pb2.ListResponse.FromString, ) self.Query = channel.unary_unary( '/VectorService/Query', - request_serializer=vector__service__pb2.QueryRequest.SerializeToString, - response_deserializer=vector__service__pb2.QueryResponse.FromString, + request_serializer=pinecone_dot_data_dot_v1_dot_vector__service__pb2.QueryRequest.SerializeToString, + response_deserializer=pinecone_dot_data_dot_v1_dot_vector__service__pb2.QueryResponse.FromString, ) self.Update = channel.unary_unary( '/VectorService/Update', - request_serializer=vector__service__pb2.UpdateRequest.SerializeToString, - response_deserializer=vector__service__pb2.UpdateResponse.FromString, + request_serializer=pinecone_dot_data_dot_v1_dot_vector__service__pb2.UpdateRequest.SerializeToString, + response_deserializer=pinecone_dot_data_dot_v1_dot_vector__service__pb2.UpdateResponse.FromString, ) self.DescribeIndexStats = channel.unary_unary( '/VectorService/DescribeIndexStats', - request_serializer=vector__service__pb2.DescribeIndexStatsRequest.SerializeToString, - response_deserializer=vector__service__pb2.DescribeIndexStatsResponse.FromString, + request_serializer=pinecone_dot_data_dot_v1_dot_vector__service__pb2.DescribeIndexStatsRequest.SerializeToString, + response_deserializer=pinecone_dot_data_dot_v1_dot_vector__service__pb2.DescribeIndexStatsResponse.FromString, ) @@ -84,7 +84,7 @@ def Fetch(self, request, context): The `fetch` operation looks up and returns vectors, by ID, from a single namespace. The returned vectors include the vector data and/or metadata. - For guidance and examples, see [Fetch data](https://docs.pinecone.io/reference/fetch). + For guidance and examples, see [Fetch data](https://docs.pinecone.io/docs/fetch-data). """ context.set_code(grpc.StatusCode.UNIMPLEMENTED) context.set_details('Method not implemented!') @@ -121,7 +121,7 @@ def Update(self, request, context): The `update` operation updates a vector in a namespace. If a value is included, it will overwrite the previous value. If a `set_metadata` is included, the values of the fields specified in it will be added or overwrite the previous value. - For guidance and examples, see [Update data](https://docs.pinecone.io/reference/update). + For guidance and examples, see [Update data](https://docs.pinecone.io/docs/update-data). """ context.set_code(grpc.StatusCode.UNIMPLEMENTED) context.set_details('Method not implemented!') @@ -145,38 +145,38 @@ def add_VectorServiceServicer_to_server(servicer, server): rpc_method_handlers = { 'Upsert': grpc.unary_unary_rpc_method_handler( servicer.Upsert, - request_deserializer=vector__service__pb2.UpsertRequest.FromString, - response_serializer=vector__service__pb2.UpsertResponse.SerializeToString, + request_deserializer=pinecone_dot_data_dot_v1_dot_vector__service__pb2.UpsertRequest.FromString, + response_serializer=pinecone_dot_data_dot_v1_dot_vector__service__pb2.UpsertResponse.SerializeToString, ), 'Delete': grpc.unary_unary_rpc_method_handler( servicer.Delete, - request_deserializer=vector__service__pb2.DeleteRequest.FromString, - response_serializer=vector__service__pb2.DeleteResponse.SerializeToString, + request_deserializer=pinecone_dot_data_dot_v1_dot_vector__service__pb2.DeleteRequest.FromString, + response_serializer=pinecone_dot_data_dot_v1_dot_vector__service__pb2.DeleteResponse.SerializeToString, ), 'Fetch': grpc.unary_unary_rpc_method_handler( servicer.Fetch, - request_deserializer=vector__service__pb2.FetchRequest.FromString, - response_serializer=vector__service__pb2.FetchResponse.SerializeToString, + request_deserializer=pinecone_dot_data_dot_v1_dot_vector__service__pb2.FetchRequest.FromString, + response_serializer=pinecone_dot_data_dot_v1_dot_vector__service__pb2.FetchResponse.SerializeToString, ), 'List': grpc.unary_unary_rpc_method_handler( servicer.List, - request_deserializer=vector__service__pb2.ListRequest.FromString, - response_serializer=vector__service__pb2.ListResponse.SerializeToString, + request_deserializer=pinecone_dot_data_dot_v1_dot_vector__service__pb2.ListRequest.FromString, + response_serializer=pinecone_dot_data_dot_v1_dot_vector__service__pb2.ListResponse.SerializeToString, ), 'Query': grpc.unary_unary_rpc_method_handler( servicer.Query, - request_deserializer=vector__service__pb2.QueryRequest.FromString, - response_serializer=vector__service__pb2.QueryResponse.SerializeToString, + request_deserializer=pinecone_dot_data_dot_v1_dot_vector__service__pb2.QueryRequest.FromString, + response_serializer=pinecone_dot_data_dot_v1_dot_vector__service__pb2.QueryResponse.SerializeToString, ), 'Update': grpc.unary_unary_rpc_method_handler( servicer.Update, - request_deserializer=vector__service__pb2.UpdateRequest.FromString, - response_serializer=vector__service__pb2.UpdateResponse.SerializeToString, + request_deserializer=pinecone_dot_data_dot_v1_dot_vector__service__pb2.UpdateRequest.FromString, + response_serializer=pinecone_dot_data_dot_v1_dot_vector__service__pb2.UpdateResponse.SerializeToString, ), 'DescribeIndexStats': grpc.unary_unary_rpc_method_handler( servicer.DescribeIndexStats, - request_deserializer=vector__service__pb2.DescribeIndexStatsRequest.FromString, - response_serializer=vector__service__pb2.DescribeIndexStatsResponse.SerializeToString, + request_deserializer=pinecone_dot_data_dot_v1_dot_vector__service__pb2.DescribeIndexStatsRequest.FromString, + response_serializer=pinecone_dot_data_dot_v1_dot_vector__service__pb2.DescribeIndexStatsResponse.SerializeToString, ), } generic_handler = grpc.method_handlers_generic_handler( @@ -202,8 +202,8 @@ def Upsert(request, timeout=None, metadata=None): return grpc.experimental.unary_unary(request, target, '/VectorService/Upsert', - vector__service__pb2.UpsertRequest.SerializeToString, - vector__service__pb2.UpsertResponse.FromString, + pinecone_dot_data_dot_v1_dot_vector__service__pb2.UpsertRequest.SerializeToString, + pinecone_dot_data_dot_v1_dot_vector__service__pb2.UpsertResponse.FromString, options, channel_credentials, insecure, call_credentials, compression, wait_for_ready, timeout, metadata) @@ -219,8 +219,8 @@ def Delete(request, timeout=None, metadata=None): return grpc.experimental.unary_unary(request, target, '/VectorService/Delete', - vector__service__pb2.DeleteRequest.SerializeToString, - vector__service__pb2.DeleteResponse.FromString, + pinecone_dot_data_dot_v1_dot_vector__service__pb2.DeleteRequest.SerializeToString, + pinecone_dot_data_dot_v1_dot_vector__service__pb2.DeleteResponse.FromString, options, channel_credentials, insecure, call_credentials, compression, wait_for_ready, timeout, metadata) @@ -236,8 +236,8 @@ def Fetch(request, timeout=None, metadata=None): return grpc.experimental.unary_unary(request, target, '/VectorService/Fetch', - vector__service__pb2.FetchRequest.SerializeToString, - vector__service__pb2.FetchResponse.FromString, + pinecone_dot_data_dot_v1_dot_vector__service__pb2.FetchRequest.SerializeToString, + pinecone_dot_data_dot_v1_dot_vector__service__pb2.FetchResponse.FromString, options, channel_credentials, insecure, call_credentials, compression, wait_for_ready, timeout, metadata) @@ -253,8 +253,8 @@ def List(request, timeout=None, metadata=None): return grpc.experimental.unary_unary(request, target, '/VectorService/List', - vector__service__pb2.ListRequest.SerializeToString, - vector__service__pb2.ListResponse.FromString, + pinecone_dot_data_dot_v1_dot_vector__service__pb2.ListRequest.SerializeToString, + pinecone_dot_data_dot_v1_dot_vector__service__pb2.ListResponse.FromString, options, channel_credentials, insecure, call_credentials, compression, wait_for_ready, timeout, metadata) @@ -270,8 +270,8 @@ def Query(request, timeout=None, metadata=None): return grpc.experimental.unary_unary(request, target, '/VectorService/Query', - vector__service__pb2.QueryRequest.SerializeToString, - vector__service__pb2.QueryResponse.FromString, + pinecone_dot_data_dot_v1_dot_vector__service__pb2.QueryRequest.SerializeToString, + pinecone_dot_data_dot_v1_dot_vector__service__pb2.QueryResponse.FromString, options, channel_credentials, insecure, call_credentials, compression, wait_for_ready, timeout, metadata) @@ -287,8 +287,8 @@ def Update(request, timeout=None, metadata=None): return grpc.experimental.unary_unary(request, target, '/VectorService/Update', - vector__service__pb2.UpdateRequest.SerializeToString, - vector__service__pb2.UpdateResponse.FromString, + pinecone_dot_data_dot_v1_dot_vector__service__pb2.UpdateRequest.SerializeToString, + pinecone_dot_data_dot_v1_dot_vector__service__pb2.UpdateResponse.FromString, options, channel_credentials, insecure, call_credentials, compression, wait_for_ready, timeout, metadata) @@ -304,7 +304,7 @@ def DescribeIndexStats(request, timeout=None, metadata=None): return grpc.experimental.unary_unary(request, target, '/VectorService/DescribeIndexStats', - vector__service__pb2.DescribeIndexStatsRequest.SerializeToString, - vector__service__pb2.DescribeIndexStatsResponse.FromString, + pinecone_dot_data_dot_v1_dot_vector__service__pb2.DescribeIndexStatsRequest.SerializeToString, + pinecone_dot_data_dot_v1_dot_vector__service__pb2.DescribeIndexStatsResponse.FromString, options, channel_credentials, insecure, call_credentials, compression, wait_for_ready, timeout, metadata) From 314b4a2e01c8b8ab6c8bde7296dc683fcd052d0b Mon Sep 17 00:00:00 2001 From: Jen Hamon Date: Thu, 7 Mar 2024 04:35:04 -0500 Subject: [PATCH 4/6] Manual line fix --- pinecone/core/client/api/data_plane_api.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pinecone/core/client/api/data_plane_api.py b/pinecone/core/client/api/data_plane_api.py index 32ed8c6d6..b501deb08 100644 --- a/pinecone/core/client/api/data_plane_api.py +++ b/pinecone/core/client/api/data_plane_api.py @@ -33,7 +33,7 @@ from pinecone.core.client.model.update_request import UpdateRequest from pinecone.core.client.model.upsert_request import UpsertRequest from pinecone.core.client.model.upsert_response import UpsertResponse -from pinecone.core.client.model.str_bool_date_datetime_dict_float_int_list_str_none_type import StrBoolDateDatetimeDictFloatIntListStrNoneType +# from pinecone.core.client.model.str_bool_date_datetime_dict_float_int_list_str_none_type import StrBoolDateDatetimeDictFloatIntListStrNoneType class DataPlaneApi(object): From 0893aed68752c3877b2667181bcea82aadb43f46 Mon Sep 17 00:00:00 2001 From: Jen Hamon Date: Thu, 7 Mar 2024 04:55:32 -0500 Subject: [PATCH 5/6] Remove problematic param --- pinecone/core/client/api/data_plane_api.py | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/pinecone/core/client/api/data_plane_api.py b/pinecone/core/client/api/data_plane_api.py index b501deb08..912a0eab1 100644 --- a/pinecone/core/client/api/data_plane_api.py +++ b/pinecone/core/client/api/data_plane_api.py @@ -33,7 +33,6 @@ from pinecone.core.client.model.update_request import UpdateRequest from pinecone.core.client.model.upsert_request import UpsertRequest from pinecone.core.client.model.upsert_response import UpsertResponse -# from pinecone.core.client.model.str_bool_date_datetime_dict_float_int_list_str_none_type import StrBoolDateDatetimeDictFloatIntListStrNoneType class DataPlaneApi(object): @@ -66,7 +65,6 @@ def __alt_delete( ids ([str]): Vectors to delete.. [optional] delete_all (bool): This indicates that all vectors in the index namespace should be deleted.. [optional] if omitted the server will use the default value of False namespace (str): The namespace to delete vectors from, if applicable.. [optional] - filter ({str: (bool, date, datetime, dict, float, int, list, str, none_type)}): If specified, the metadata filter here will be used to select the vectors to delete. This is mutually exclusive with specifying ids to delete in the ids param or using delete_all=True. See https://www.pinecone.io/docs/metadata-filtering/.. [optional] _return_http_data_only (bool): response data without head status code and headers. Default is True. _preload_content (bool): if False, the urllib3.HTTPResponse object @@ -129,7 +127,6 @@ def __alt_delete( 'ids', 'delete_all', 'namespace', - 'filter', ], 'required': [], 'nullable': [ @@ -151,20 +148,16 @@ def __alt_delete( (bool,), 'namespace': (str,), - 'filter': - ({str: (bool, date, datetime, dict, float, int, list, str, none_type)},), }, 'attribute_map': { 'ids': 'ids', 'delete_all': 'deleteAll', 'namespace': 'namespace', - 'filter': 'filter', }, 'location_map': { 'ids': 'query', 'delete_all': 'query', 'namespace': 'query', - 'filter': 'query', }, 'collection_format_map': { 'ids': 'multi', @@ -195,7 +188,6 @@ def __alt_describe_index_stats( Keyword Args: - filter ({str: (bool, date, datetime, dict, float, int, list, str, none_type)}): If this parameter is present, the operation only returns statistics for vectors that satisfy the filter. See https://www.pinecone.io/docs/metadata-filtering/.. [optional] _return_http_data_only (bool): response data without head status code and headers. Default is True. _preload_content (bool): if False, the urllib3.HTTPResponse object @@ -255,7 +247,6 @@ def __alt_describe_index_stats( }, params_map={ 'all': [ - 'filter', ], 'required': [], 'nullable': [ @@ -271,14 +262,10 @@ def __alt_describe_index_stats( 'allowed_values': { }, 'openapi_types': { - 'filter': - ({str: (bool, date, datetime, dict, float, int, list, str, none_type)},), }, 'attribute_map': { - 'filter': 'filter', }, 'location_map': { - 'filter': 'query', }, 'collection_format_map': { } From 232093272b0ed41b3ffc707795bd5b13d42db0cb Mon Sep 17 00:00:00 2001 From: Jen Hamon Date: Thu, 7 Mar 2024 05:43:57 -0500 Subject: [PATCH 6/6] Adjust import path --- pinecone/core/grpc/protos/vector_service_pb2_grpc.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pinecone/core/grpc/protos/vector_service_pb2_grpc.py b/pinecone/core/grpc/protos/vector_service_pb2_grpc.py index 492648a77..39c460b52 100644 --- a/pinecone/core/grpc/protos/vector_service_pb2_grpc.py +++ b/pinecone/core/grpc/protos/vector_service_pb2_grpc.py @@ -2,7 +2,8 @@ """Client and server classes corresponding to protobuf-defined services.""" import grpc -import pinecone.core.grpc.protos.vector_service_pb2 as vector__service__pb2 +from pinecone.core.grpc.protos import vector_service_pb2 as pinecone_dot_data_dot_v1_dot_vector__service__pb2 + class VectorServiceStub(object): """The `VectorService` interface is exposed by Pinecone's vector index services.