-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
759b20b
commit 49d2593
Showing
9 changed files
with
267 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# This file was auto-generated by Fern from our API Definition. | ||
|
||
from . import actions, agents, calls, numbers, prompts, usage, voices, webhooks | ||
from . import actions, agents, calls, numbers, prompts, usage, vector_databases, voices, webhooks | ||
|
||
__all__ = ["actions", "agents", "calls", "numbers", "prompts", "usage", "voices", "webhooks"] | ||
__all__ = ["actions", "agents", "calls", "numbers", "prompts", "usage", "vector_databases", "voices", "webhooks"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# This file was auto-generated by Fern from our API Definition. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,223 @@ | ||
# This file was auto-generated by Fern from our API Definition. | ||
|
||
import typing | ||
import urllib.parse | ||
from json.decoder import JSONDecodeError | ||
|
||
import pydantic | ||
|
||
from ...core.api_error import ApiError | ||
from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper | ||
from ...core.jsonable_encoder import jsonable_encoder | ||
from ...core.remove_none_from_dict import remove_none_from_dict | ||
from ...errors.unprocessable_entity_error import UnprocessableEntityError | ||
from ...types.http_validation_error import HttpValidationError | ||
from ...types.pinecone_vector_database import PineconeVectorDatabase | ||
from ...types.pinecone_vector_database_params import PineconeVectorDatabaseParams | ||
from ...types.pinecone_vector_database_update_params import PineconeVectorDatabaseUpdateParams | ||
from ...types.vector_database_page import VectorDatabasePage | ||
|
||
# this is used as the default value for optional parameters | ||
OMIT = typing.cast(typing.Any, ...) | ||
|
||
|
||
class VectorDatabasesClient: | ||
def __init__(self, *, client_wrapper: SyncClientWrapper): | ||
self._client_wrapper = client_wrapper | ||
|
||
def get_vector_database(self, *, id: str) -> PineconeVectorDatabase: | ||
""" | ||
Parameters: | ||
- id: str. | ||
""" | ||
_response = self._client_wrapper.httpx_client.request( | ||
"GET", | ||
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "v1/vector_databases"), | ||
params=remove_none_from_dict({"id": id}), | ||
headers=self._client_wrapper.get_headers(), | ||
timeout=60, | ||
) | ||
if 200 <= _response.status_code < 300: | ||
return pydantic.parse_obj_as(PineconeVectorDatabase, _response.json()) # type: ignore | ||
if _response.status_code == 422: | ||
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore | ||
try: | ||
_response_json = _response.json() | ||
except JSONDecodeError: | ||
raise ApiError(status_code=_response.status_code, body=_response.text) | ||
raise ApiError(status_code=_response.status_code, body=_response_json) | ||
|
||
def list_vector_databases( | ||
self, *, page: typing.Optional[int] = None, size: typing.Optional[int] = None | ||
) -> VectorDatabasePage: | ||
""" | ||
Parameters: | ||
- page: typing.Optional[int]. | ||
- size: typing.Optional[int]. | ||
""" | ||
_response = self._client_wrapper.httpx_client.request( | ||
"GET", | ||
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "v1/vector_databases/list"), | ||
params=remove_none_from_dict({"page": page, "size": size}), | ||
headers=self._client_wrapper.get_headers(), | ||
timeout=60, | ||
) | ||
if 200 <= _response.status_code < 300: | ||
return pydantic.parse_obj_as(VectorDatabasePage, _response.json()) # type: ignore | ||
if _response.status_code == 422: | ||
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore | ||
try: | ||
_response_json = _response.json() | ||
except JSONDecodeError: | ||
raise ApiError(status_code=_response.status_code, body=_response.text) | ||
raise ApiError(status_code=_response.status_code, body=_response_json) | ||
|
||
def create_vector_database(self, *, request: PineconeVectorDatabaseParams) -> PineconeVectorDatabase: | ||
""" | ||
Parameters: | ||
- request: PineconeVectorDatabaseParams. | ||
""" | ||
_response = self._client_wrapper.httpx_client.request( | ||
"POST", | ||
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "v1/vector_databases/create"), | ||
json=jsonable_encoder(request), | ||
headers=self._client_wrapper.get_headers(), | ||
timeout=60, | ||
) | ||
if 200 <= _response.status_code < 300: | ||
return pydantic.parse_obj_as(PineconeVectorDatabase, _response.json()) # type: ignore | ||
if _response.status_code == 422: | ||
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore | ||
try: | ||
_response_json = _response.json() | ||
except JSONDecodeError: | ||
raise ApiError(status_code=_response.status_code, body=_response.text) | ||
raise ApiError(status_code=_response.status_code, body=_response_json) | ||
|
||
def update_vector_database(self, *, id: str, request: PineconeVectorDatabaseUpdateParams) -> PineconeVectorDatabase: | ||
""" | ||
Parameters: | ||
- id: str. | ||
- request: PineconeVectorDatabaseUpdateParams. | ||
""" | ||
_response = self._client_wrapper.httpx_client.request( | ||
"POST", | ||
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "v1/vector_databases/update"), | ||
params=remove_none_from_dict({"id": id}), | ||
json=jsonable_encoder(request), | ||
headers=self._client_wrapper.get_headers(), | ||
timeout=60, | ||
) | ||
if 200 <= _response.status_code < 300: | ||
return pydantic.parse_obj_as(PineconeVectorDatabase, _response.json()) # type: ignore | ||
if _response.status_code == 422: | ||
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore | ||
try: | ||
_response_json = _response.json() | ||
except JSONDecodeError: | ||
raise ApiError(status_code=_response.status_code, body=_response.text) | ||
raise ApiError(status_code=_response.status_code, body=_response_json) | ||
|
||
|
||
class AsyncVectorDatabasesClient: | ||
def __init__(self, *, client_wrapper: AsyncClientWrapper): | ||
self._client_wrapper = client_wrapper | ||
|
||
async def get_vector_database(self, *, id: str) -> PineconeVectorDatabase: | ||
""" | ||
Parameters: | ||
- id: str. | ||
""" | ||
_response = await self._client_wrapper.httpx_client.request( | ||
"GET", | ||
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "v1/vector_databases"), | ||
params=remove_none_from_dict({"id": id}), | ||
headers=self._client_wrapper.get_headers(), | ||
timeout=60, | ||
) | ||
if 200 <= _response.status_code < 300: | ||
return pydantic.parse_obj_as(PineconeVectorDatabase, _response.json()) # type: ignore | ||
if _response.status_code == 422: | ||
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore | ||
try: | ||
_response_json = _response.json() | ||
except JSONDecodeError: | ||
raise ApiError(status_code=_response.status_code, body=_response.text) | ||
raise ApiError(status_code=_response.status_code, body=_response_json) | ||
|
||
async def list_vector_databases( | ||
self, *, page: typing.Optional[int] = None, size: typing.Optional[int] = None | ||
) -> VectorDatabasePage: | ||
""" | ||
Parameters: | ||
- page: typing.Optional[int]. | ||
- size: typing.Optional[int]. | ||
""" | ||
_response = await self._client_wrapper.httpx_client.request( | ||
"GET", | ||
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "v1/vector_databases/list"), | ||
params=remove_none_from_dict({"page": page, "size": size}), | ||
headers=self._client_wrapper.get_headers(), | ||
timeout=60, | ||
) | ||
if 200 <= _response.status_code < 300: | ||
return pydantic.parse_obj_as(VectorDatabasePage, _response.json()) # type: ignore | ||
if _response.status_code == 422: | ||
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore | ||
try: | ||
_response_json = _response.json() | ||
except JSONDecodeError: | ||
raise ApiError(status_code=_response.status_code, body=_response.text) | ||
raise ApiError(status_code=_response.status_code, body=_response_json) | ||
|
||
async def create_vector_database(self, *, request: PineconeVectorDatabaseParams) -> PineconeVectorDatabase: | ||
""" | ||
Parameters: | ||
- request: PineconeVectorDatabaseParams. | ||
""" | ||
_response = await self._client_wrapper.httpx_client.request( | ||
"POST", | ||
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "v1/vector_databases/create"), | ||
json=jsonable_encoder(request), | ||
headers=self._client_wrapper.get_headers(), | ||
timeout=60, | ||
) | ||
if 200 <= _response.status_code < 300: | ||
return pydantic.parse_obj_as(PineconeVectorDatabase, _response.json()) # type: ignore | ||
if _response.status_code == 422: | ||
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore | ||
try: | ||
_response_json = _response.json() | ||
except JSONDecodeError: | ||
raise ApiError(status_code=_response.status_code, body=_response.text) | ||
raise ApiError(status_code=_response.status_code, body=_response_json) | ||
|
||
async def update_vector_database( | ||
self, *, id: str, request: PineconeVectorDatabaseUpdateParams | ||
) -> PineconeVectorDatabase: | ||
""" | ||
Parameters: | ||
- id: str. | ||
- request: PineconeVectorDatabaseUpdateParams. | ||
""" | ||
_response = await self._client_wrapper.httpx_client.request( | ||
"POST", | ||
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "v1/vector_databases/update"), | ||
params=remove_none_from_dict({"id": id}), | ||
json=jsonable_encoder(request), | ||
headers=self._client_wrapper.get_headers(), | ||
timeout=60, | ||
) | ||
if 200 <= _response.status_code < 300: | ||
return pydantic.parse_obj_as(PineconeVectorDatabase, _response.json()) # type: ignore | ||
if _response.status_code == 422: | ||
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore | ||
try: | ||
_response_json = _response.json() | ||
except JSONDecodeError: | ||
raise ApiError(status_code=_response.status_code, body=_response.text) | ||
raise ApiError(status_code=_response.status_code, body=_response_json) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# This file was auto-generated by Fern from our API Definition. | ||
|
||
import datetime as dt | ||
import typing | ||
|
||
import pydantic | ||
|
||
from ..core.datetime_utils import serialize_datetime | ||
from .pinecone_vector_database import PineconeVectorDatabase | ||
|
||
|
||
class VectorDatabasePage(pydantic.BaseModel): | ||
items: typing.List[PineconeVectorDatabase] | ||
page: int | ||
size: int | ||
has_more: bool | ||
|
||
def json(self, **kwargs: typing.Any) -> str: | ||
kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} | ||
return super().json(**kwargs_with_defaults) | ||
|
||
def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: | ||
kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} | ||
return super().dict(**kwargs_with_defaults) | ||
|
||
class Config: | ||
frozen = True | ||
smart_union = True | ||
json_encoders = {dt.datetime: serialize_datetime} |