diff --git a/DO_OPENAPI_COMMIT_SHA.txt b/DO_OPENAPI_COMMIT_SHA.txt index bb4e9802..4c58d73a 100644 --- a/DO_OPENAPI_COMMIT_SHA.txt +++ b/DO_OPENAPI_COMMIT_SHA.txt @@ -1 +1 @@ -e094801 +65127f6 diff --git a/docs/source/pydo.inference.aio.rst b/docs/source/pydo.inference.aio.rst new file mode 100644 index 00000000..567c14bd --- /dev/null +++ b/docs/source/pydo.inference.aio.rst @@ -0,0 +1,10 @@ +pydo.inference.aio package +========================== + +Module contents +--------------- + +.. automodule:: pydo.inference.aio + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/source/pydo.inference.rst b/docs/source/pydo.inference.rst new file mode 100644 index 00000000..004219ec --- /dev/null +++ b/docs/source/pydo.inference.rst @@ -0,0 +1,18 @@ +pydo.inference package +====================== + +Subpackages +----------- + +.. toctree:: + :maxdepth: 4 + + pydo.inference.aio + +Module contents +--------------- + +.. automodule:: pydo.inference + :members: + :undoc-members: + :show-inheritance: diff --git a/src/pydo/_client.py b/src/pydo/_client.py index 35abeb18..b190e6ab 100644 --- a/src/pydo/_client.py +++ b/src/pydo/_client.py @@ -60,6 +60,7 @@ SshKeysOperations, TagsOperations, UptimeOperations, + VectorDatabasesOperations, VolumeActionsOperations, VolumeSnapshotsOperations, VolumesOperations, @@ -160,6 +161,8 @@ class GeneratedClient: # pylint: disable=client-accepts-api-version-keyword,too :vartype spaces_key: pydo.operations.SpacesKeyOperations :ivar tags: TagsOperations operations :vartype tags: pydo.operations.TagsOperations + :ivar vector_databases: VectorDatabasesOperations operations + :vartype vector_databases: pydo.operations.VectorDatabasesOperations :ivar volumes: VolumesOperations operations :vartype volumes: pydo.operations.VolumesOperations :ivar volume_actions: VolumeActionsOperations operations @@ -348,6 +351,9 @@ def __init__( self.tags = TagsOperations( self._client, self._config, self._serialize, self._deserialize ) + self.vector_databases = VectorDatabasesOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.volumes = VolumesOperations( self._client, self._config, self._serialize, self._deserialize ) diff --git a/src/pydo/aio/_client.py b/src/pydo/aio/_client.py index b6666501..6a8b62f4 100644 --- a/src/pydo/aio/_client.py +++ b/src/pydo/aio/_client.py @@ -60,6 +60,7 @@ SshKeysOperations, TagsOperations, UptimeOperations, + VectorDatabasesOperations, VolumeActionsOperations, VolumeSnapshotsOperations, VolumesOperations, @@ -160,6 +161,8 @@ class GeneratedClient: # pylint: disable=client-accepts-api-version-keyword,too :vartype spaces_key: pydo.aio.operations.SpacesKeyOperations :ivar tags: TagsOperations operations :vartype tags: pydo.aio.operations.TagsOperations + :ivar vector_databases: VectorDatabasesOperations operations + :vartype vector_databases: pydo.aio.operations.VectorDatabasesOperations :ivar volumes: VolumesOperations operations :vartype volumes: pydo.aio.operations.VolumesOperations :ivar volume_actions: VolumeActionsOperations operations @@ -348,6 +351,9 @@ def __init__( self.tags = TagsOperations( self._client, self._config, self._serialize, self._deserialize ) + self.vector_databases = VectorDatabasesOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.volumes = VolumesOperations( self._client, self._config, self._serialize, self._deserialize ) diff --git a/src/pydo/aio/operations/__init__.py b/src/pydo/aio/operations/__init__.py index 4286825e..2de68fec 100644 --- a/src/pydo/aio/operations/__init__.py +++ b/src/pydo/aio/operations/__init__.py @@ -46,6 +46,7 @@ from ._operations import SnapshotsOperations from ._operations import SpacesKeyOperations from ._operations import TagsOperations +from ._operations import VectorDatabasesOperations from ._operations import VolumesOperations from ._operations import VolumeActionsOperations from ._operations import VolumeSnapshotsOperations @@ -104,6 +105,7 @@ "SnapshotsOperations", "SpacesKeyOperations", "TagsOperations", + "VectorDatabasesOperations", "VolumesOperations", "VolumeActionsOperations", "VolumeSnapshotsOperations", diff --git a/src/pydo/aio/operations/_operations.py b/src/pydo/aio/operations/_operations.py index bd5dd3a4..07763e83 100644 --- a/src/pydo/aio/operations/_operations.py +++ b/src/pydo/aio/operations/_operations.py @@ -632,6 +632,17 @@ build_uptime_list_checks_request, build_uptime_update_alert_request, build_uptime_update_check_request, + build_vector_databases_create_request, + build_vector_databases_delete_request, + build_vector_databases_get_credentials_request, + build_vector_databases_get_request, + build_vector_databases_get_restore_status_request, + build_vector_databases_list_backups_request, + build_vector_databases_list_request, + build_vector_databases_post_resize_request, + build_vector_databases_post_restore_backup_request, + build_vector_databases_update_request, + build_vector_databases_update_tags_request, build_volume_actions_get_request, build_volume_actions_list_request, build_volume_actions_post_by_id_request, @@ -192657,6 +192668,2602 @@ async def unassign_resources( return deserialized # type: ignore +class VectorDatabasesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~pydo.aio.GeneratedClient`'s + :attr:`vector_databases` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = ( + input_args.pop(0) if input_args else kwargs.pop("deserializer") + ) + + @distributed_trace_async + async def list( + self, + *, + page: Optional[int] = None, + per_page: Optional[int] = None, + **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """List All Vector Databases. + + To list all of the vector databases on your account, send a GET request to + ``/v2/vector-databases``. Use the ``page`` and ``per_page`` query parameters to paginate the + results. The response body contains a ``vector_dbs`` array of vector database objects and a + ``total`` field with the overall count. + + :keyword page: Default value is None. + :paramtype page: int + :keyword per_page: Default value is None. + :paramtype per_page: int + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "total": 0, # Optional. + "vector_dbs": [ + { + "config": { + "default_quantization": "str", # Optional. Default + vector compression for new collections: rq, pq, bq, or sq. Empty + means platform default (rq). + "enable_auto_schema": bool, # Optional. + VectorDBConfig holds optional, advanced cluster settings. + "weaviate_version": "str" # Optional. The Vector + Database version running on the cluster. + }, + "created_at": "2020-02-20 00:00:00", # Optional. + "endpoints": { + "grpc": "str", # Optional. Endpoint for gRPC + connections (e.g. + "my-db-tor1-a1b2c3d4-grpc.weaviate.ondigitalocean.com:443"). + "http": "str" # Optional. Endpoint for HTTPS + connections (e.g. + "https://my-db-tor1-a1b2c3d4.weaviate.ondigitalocean.com"). + }, + "forked_from_id": "str", # Optional. ID of the vector + database this instance was forked from. Empty when the instance was + created directly via CreateVectorDB. Read-only and set by the platform at + fork time; never modifiable through UpdateVectorDB. + "id": "str", # Optional. + "last_restore_id": "str", # Optional. Backup_id of the most + recent restore initiated against this instance. Empty if no restore has + ever been triggered. Lets callers recover the identifier of an in-flight + or last-completed restore without having to retain the + RestoreBackupResponse themselves. Use it with GetRestoreStatus to fetch + the live status. + "name": "str", # Optional. + "owner_uuid": "str", # Optional. + "project_id": "str", # Optional. Project this database + belongs to. + "region": "str", # Optional. + "size": "str", # Optional. Resource tier: small, medium, or + large. + "status": "str", # Optional. Lifecycle state: pending, + creating, active, errored, or deleting. + "tags": [ + "str" # Optional. + ], + "updated_at": "2020-02-20 00:00:00" # Optional. + } + ] + } + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + lambda response: ClientAuthenticationError(response=response), + ), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[JSON] = kwargs.pop("cls", None) + + _request = build_vector_databases_list_request( + page=page, + per_page=per_page, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + if _stream: + await response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + if response.status_code == 200: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 404: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + @overload + async def create( + self, + body: Optional[JSON] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Create a New Vector Database. + + To create a vector database, send a POST request to ``/v2/vector-databases``. The response body + contains a JSON object with a ``vector_db`` key holding the newly created database. Its initial + ``status`` is ``creating`` and changes to ``active`` once the database is ready to receive + traffic. + + :param body: Default value is None. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "name": "str", # Optional. Required. Human-readable name for the database. + "project_id": "str", # Optional. Required. ID of the project to create the + vector database in. + "region": "str", # Optional. Required. Region slug where the database will + be provisioned. + "size": "str", # Optional. Required. Resource tier: small, medium, or large. + "tags": [ + "str" # Optional. A set of arbitrary tags to organize your vector + database. + ] + } + + # response body for status code(s): 201 + response == { + "vector_db": { + "config": { + "default_quantization": "str", # Optional. Default vector + compression for new collections: rq, pq, bq, or sq. Empty means platform + default (rq). + "enable_auto_schema": bool, # Optional. VectorDBConfig holds + optional, advanced cluster settings. + "weaviate_version": "str" # Optional. The Vector Database + version running on the cluster. + }, + "created_at": "2020-02-20 00:00:00", # Optional. VectorDB represents + a provisioned vector database instance. + "endpoints": { + "grpc": "str", # Optional. Endpoint for gRPC connections + (e.g. "my-db-tor1-a1b2c3d4-grpc.weaviate.ondigitalocean.com:443"). + "http": "str" # Optional. Endpoint for HTTPS connections + (e.g. "https://my-db-tor1-a1b2c3d4.weaviate.ondigitalocean.com"). + }, + "forked_from_id": "str", # Optional. ID of the vector database this + instance was forked from. Empty when the instance was created directly via + CreateVectorDB. Read-only and set by the platform at fork time; never + modifiable through UpdateVectorDB. + "id": "str", # Optional. VectorDB represents a provisioned vector + database instance. + "last_restore_id": "str", # Optional. Backup_id of the most recent + restore initiated against this instance. Empty if no restore has ever been + triggered. Lets callers recover the identifier of an in-flight or + last-completed restore without having to retain the RestoreBackupResponse + themselves. Use it with GetRestoreStatus to fetch the live status. + "name": "str", # Optional. VectorDB represents a provisioned vector + database instance. + "owner_uuid": "str", # Optional. VectorDB represents a provisioned + vector database instance. + "project_id": "str", # Optional. Project this database belongs to. + "region": "str", # Optional. VectorDB represents a provisioned + vector database instance. + "size": "str", # Optional. Resource tier: small, medium, or large. + "status": "str", # Optional. Lifecycle state: pending, creating, + active, errored, or deleting. + "tags": [ + "str" # Optional. VectorDB represents a provisioned vector + database instance. + ], + "updated_at": "2020-02-20 00:00:00" # Optional. VectorDB represents + a provisioned vector database instance. + } + } + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + + @overload + async def create( + self, + body: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Create a New Vector Database. + + To create a vector database, send a POST request to ``/v2/vector-databases``. The response body + contains a JSON object with a ``vector_db`` key holding the newly created database. Its initial + ``status`` is ``creating`` and changes to ``active`` once the database is ready to receive + traffic. + + :param body: Default value is None. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 201 + response == { + "vector_db": { + "config": { + "default_quantization": "str", # Optional. Default vector + compression for new collections: rq, pq, bq, or sq. Empty means platform + default (rq). + "enable_auto_schema": bool, # Optional. VectorDBConfig holds + optional, advanced cluster settings. + "weaviate_version": "str" # Optional. The Vector Database + version running on the cluster. + }, + "created_at": "2020-02-20 00:00:00", # Optional. VectorDB represents + a provisioned vector database instance. + "endpoints": { + "grpc": "str", # Optional. Endpoint for gRPC connections + (e.g. "my-db-tor1-a1b2c3d4-grpc.weaviate.ondigitalocean.com:443"). + "http": "str" # Optional. Endpoint for HTTPS connections + (e.g. "https://my-db-tor1-a1b2c3d4.weaviate.ondigitalocean.com"). + }, + "forked_from_id": "str", # Optional. ID of the vector database this + instance was forked from. Empty when the instance was created directly via + CreateVectorDB. Read-only and set by the platform at fork time; never + modifiable through UpdateVectorDB. + "id": "str", # Optional. VectorDB represents a provisioned vector + database instance. + "last_restore_id": "str", # Optional. Backup_id of the most recent + restore initiated against this instance. Empty if no restore has ever been + triggered. Lets callers recover the identifier of an in-flight or + last-completed restore without having to retain the RestoreBackupResponse + themselves. Use it with GetRestoreStatus to fetch the live status. + "name": "str", # Optional. VectorDB represents a provisioned vector + database instance. + "owner_uuid": "str", # Optional. VectorDB represents a provisioned + vector database instance. + "project_id": "str", # Optional. Project this database belongs to. + "region": "str", # Optional. VectorDB represents a provisioned + vector database instance. + "size": "str", # Optional. Resource tier: small, medium, or large. + "status": "str", # Optional. Lifecycle state: pending, creating, + active, errored, or deleting. + "tags": [ + "str" # Optional. VectorDB represents a provisioned vector + database instance. + ], + "updated_at": "2020-02-20 00:00:00" # Optional. VectorDB represents + a provisioned vector database instance. + } + } + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + + @distributed_trace_async + async def create( + self, body: Optional[Union[JSON, IO[bytes]]] = None, **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Create a New Vector Database. + + To create a vector database, send a POST request to ``/v2/vector-databases``. The response body + contains a JSON object with a ``vector_db`` key holding the newly created database. Its initial + ``status`` is ``creating`` and changes to ``active`` once the database is ready to receive + traffic. + + :param body: Is either a JSON type or a IO[bytes] type. Default value is None. + :type body: JSON or IO[bytes] + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "name": "str", # Optional. Required. Human-readable name for the database. + "project_id": "str", # Optional. Required. ID of the project to create the + vector database in. + "region": "str", # Optional. Required. Region slug where the database will + be provisioned. + "size": "str", # Optional. Required. Resource tier: small, medium, or large. + "tags": [ + "str" # Optional. A set of arbitrary tags to organize your vector + database. + ] + } + + # response body for status code(s): 201 + response == { + "vector_db": { + "config": { + "default_quantization": "str", # Optional. Default vector + compression for new collections: rq, pq, bq, or sq. Empty means platform + default (rq). + "enable_auto_schema": bool, # Optional. VectorDBConfig holds + optional, advanced cluster settings. + "weaviate_version": "str" # Optional. The Vector Database + version running on the cluster. + }, + "created_at": "2020-02-20 00:00:00", # Optional. VectorDB represents + a provisioned vector database instance. + "endpoints": { + "grpc": "str", # Optional. Endpoint for gRPC connections + (e.g. "my-db-tor1-a1b2c3d4-grpc.weaviate.ondigitalocean.com:443"). + "http": "str" # Optional. Endpoint for HTTPS connections + (e.g. "https://my-db-tor1-a1b2c3d4.weaviate.ondigitalocean.com"). + }, + "forked_from_id": "str", # Optional. ID of the vector database this + instance was forked from. Empty when the instance was created directly via + CreateVectorDB. Read-only and set by the platform at fork time; never + modifiable through UpdateVectorDB. + "id": "str", # Optional. VectorDB represents a provisioned vector + database instance. + "last_restore_id": "str", # Optional. Backup_id of the most recent + restore initiated against this instance. Empty if no restore has ever been + triggered. Lets callers recover the identifier of an in-flight or + last-completed restore without having to retain the RestoreBackupResponse + themselves. Use it with GetRestoreStatus to fetch the live status. + "name": "str", # Optional. VectorDB represents a provisioned vector + database instance. + "owner_uuid": "str", # Optional. VectorDB represents a provisioned + vector database instance. + "project_id": "str", # Optional. Project this database belongs to. + "region": "str", # Optional. VectorDB represents a provisioned + vector database instance. + "size": "str", # Optional. Resource tier: small, medium, or large. + "status": "str", # Optional. Lifecycle state: pending, creating, + active, errored, or deleting. + "tags": [ + "str" # Optional. VectorDB represents a provisioned vector + database instance. + ], + "updated_at": "2020-02-20 00:00:00" # Optional. VectorDB represents + a provisioned vector database instance. + } + } + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + lambda response: ClientAuthenticationError(response=response), + ), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop( + "content_type", _headers.pop("Content-Type", None) + ) + cls: ClsType[JSON] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + if body is not None: + _json = body + else: + _json = None + + _request = build_vector_databases_create_request( + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [201, 404]: + if _stream: + await response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + if response.status_code == 201: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 404: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + @distributed_trace_async + async def get(self, id: str, **kwargs: Any) -> JSON: + # pylint: disable=line-too-long + """Retrieve an Existing Vector Database. + + To show information about an existing vector database, send a GET request to + ``/v2/vector-databases/{id}``. The response body contains a JSON object with a ``vector_db`` + key holding the standard vector database attributes, including an embedded ``endpoints`` object + with the connection information needed to access the database. + + :param id: ID of the vector database. Required. + :type id: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "vector_db": { + "config": { + "default_quantization": "str", # Optional. Default vector + compression for new collections: rq, pq, bq, or sq. Empty means platform + default (rq). + "enable_auto_schema": bool, # Optional. VectorDBConfig holds + optional, advanced cluster settings. + "weaviate_version": "str" # Optional. The Vector Database + version running on the cluster. + }, + "created_at": "2020-02-20 00:00:00", # Optional. VectorDB represents + a provisioned vector database instance. + "endpoints": { + "grpc": "str", # Optional. Endpoint for gRPC connections + (e.g. "my-db-tor1-a1b2c3d4-grpc.weaviate.ondigitalocean.com:443"). + "http": "str" # Optional. Endpoint for HTTPS connections + (e.g. "https://my-db-tor1-a1b2c3d4.weaviate.ondigitalocean.com"). + }, + "forked_from_id": "str", # Optional. ID of the vector database this + instance was forked from. Empty when the instance was created directly via + CreateVectorDB. Read-only and set by the platform at fork time; never + modifiable through UpdateVectorDB. + "id": "str", # Optional. VectorDB represents a provisioned vector + database instance. + "last_restore_id": "str", # Optional. Backup_id of the most recent + restore initiated against this instance. Empty if no restore has ever been + triggered. Lets callers recover the identifier of an in-flight or + last-completed restore without having to retain the RestoreBackupResponse + themselves. Use it with GetRestoreStatus to fetch the live status. + "name": "str", # Optional. VectorDB represents a provisioned vector + database instance. + "owner_uuid": "str", # Optional. VectorDB represents a provisioned + vector database instance. + "project_id": "str", # Optional. Project this database belongs to. + "region": "str", # Optional. VectorDB represents a provisioned + vector database instance. + "size": "str", # Optional. Resource tier: small, medium, or large. + "status": "str", # Optional. Lifecycle state: pending, creating, + active, errored, or deleting. + "tags": [ + "str" # Optional. VectorDB represents a provisioned vector + database instance. + ], + "updated_at": "2020-02-20 00:00:00" # Optional. VectorDB represents + a provisioned vector database instance. + } + } + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + lambda response: ClientAuthenticationError(response=response), + ), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[JSON] = kwargs.pop("cls", None) + + _request = build_vector_databases_get_request( + id=id, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + if _stream: + await response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + if response.status_code == 200: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 404: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + @overload + async def update( + self, + id: str, + body: Optional[JSON] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Update a Vector Database. + + To update an existing vector database, send a PUT request to ``/v2/vector-databases/{id}``. The + response body contains a JSON object with a ``vector_db`` key holding the updated vector + database. + + :param id: ID of the vector database. Required. + :type id: str + :param body: Default value is None. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "config": { + "default_quantization": "str", # Optional. Default vector + compression for new collections: rq, pq, bq, or sq. Empty means platform + default (rq). + "enable_auto_schema": bool, # Optional. VectorDBConfig holds + optional, advanced cluster settings. + "weaviate_version": "str" # Optional. The Vector Database version + running on the cluster. + }, + "id": "str", # Optional. ID of the vector database. + "project_id": "str" # Optional. Optional. New project UUID to assign the + database to. + } + + # response body for status code(s): 200 + response == { + "vector_db": { + "config": { + "default_quantization": "str", # Optional. Default vector + compression for new collections: rq, pq, bq, or sq. Empty means platform + default (rq). + "enable_auto_schema": bool, # Optional. VectorDBConfig holds + optional, advanced cluster settings. + "weaviate_version": "str" # Optional. The Vector Database + version running on the cluster. + }, + "created_at": "2020-02-20 00:00:00", # Optional. VectorDB represents + a provisioned vector database instance. + "endpoints": { + "grpc": "str", # Optional. Endpoint for gRPC connections + (e.g. "my-db-tor1-a1b2c3d4-grpc.weaviate.ondigitalocean.com:443"). + "http": "str" # Optional. Endpoint for HTTPS connections + (e.g. "https://my-db-tor1-a1b2c3d4.weaviate.ondigitalocean.com"). + }, + "forked_from_id": "str", # Optional. ID of the vector database this + instance was forked from. Empty when the instance was created directly via + CreateVectorDB. Read-only and set by the platform at fork time; never + modifiable through UpdateVectorDB. + "id": "str", # Optional. VectorDB represents a provisioned vector + database instance. + "last_restore_id": "str", # Optional. Backup_id of the most recent + restore initiated against this instance. Empty if no restore has ever been + triggered. Lets callers recover the identifier of an in-flight or + last-completed restore without having to retain the RestoreBackupResponse + themselves. Use it with GetRestoreStatus to fetch the live status. + "name": "str", # Optional. VectorDB represents a provisioned vector + database instance. + "owner_uuid": "str", # Optional. VectorDB represents a provisioned + vector database instance. + "project_id": "str", # Optional. Project this database belongs to. + "region": "str", # Optional. VectorDB represents a provisioned + vector database instance. + "size": "str", # Optional. Resource tier: small, medium, or large. + "status": "str", # Optional. Lifecycle state: pending, creating, + active, errored, or deleting. + "tags": [ + "str" # Optional. VectorDB represents a provisioned vector + database instance. + ], + "updated_at": "2020-02-20 00:00:00" # Optional. VectorDB represents + a provisioned vector database instance. + } + } + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + + @overload + async def update( + self, + id: str, + body: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Update a Vector Database. + + To update an existing vector database, send a PUT request to ``/v2/vector-databases/{id}``. The + response body contains a JSON object with a ``vector_db`` key holding the updated vector + database. + + :param id: ID of the vector database. Required. + :type id: str + :param body: Default value is None. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "vector_db": { + "config": { + "default_quantization": "str", # Optional. Default vector + compression for new collections: rq, pq, bq, or sq. Empty means platform + default (rq). + "enable_auto_schema": bool, # Optional. VectorDBConfig holds + optional, advanced cluster settings. + "weaviate_version": "str" # Optional. The Vector Database + version running on the cluster. + }, + "created_at": "2020-02-20 00:00:00", # Optional. VectorDB represents + a provisioned vector database instance. + "endpoints": { + "grpc": "str", # Optional. Endpoint for gRPC connections + (e.g. "my-db-tor1-a1b2c3d4-grpc.weaviate.ondigitalocean.com:443"). + "http": "str" # Optional. Endpoint for HTTPS connections + (e.g. "https://my-db-tor1-a1b2c3d4.weaviate.ondigitalocean.com"). + }, + "forked_from_id": "str", # Optional. ID of the vector database this + instance was forked from. Empty when the instance was created directly via + CreateVectorDB. Read-only and set by the platform at fork time; never + modifiable through UpdateVectorDB. + "id": "str", # Optional. VectorDB represents a provisioned vector + database instance. + "last_restore_id": "str", # Optional. Backup_id of the most recent + restore initiated against this instance. Empty if no restore has ever been + triggered. Lets callers recover the identifier of an in-flight or + last-completed restore without having to retain the RestoreBackupResponse + themselves. Use it with GetRestoreStatus to fetch the live status. + "name": "str", # Optional. VectorDB represents a provisioned vector + database instance. + "owner_uuid": "str", # Optional. VectorDB represents a provisioned + vector database instance. + "project_id": "str", # Optional. Project this database belongs to. + "region": "str", # Optional. VectorDB represents a provisioned + vector database instance. + "size": "str", # Optional. Resource tier: small, medium, or large. + "status": "str", # Optional. Lifecycle state: pending, creating, + active, errored, or deleting. + "tags": [ + "str" # Optional. VectorDB represents a provisioned vector + database instance. + ], + "updated_at": "2020-02-20 00:00:00" # Optional. VectorDB represents + a provisioned vector database instance. + } + } + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + + @distributed_trace_async + async def update( + self, id: str, body: Optional[Union[JSON, IO[bytes]]] = None, **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Update a Vector Database. + + To update an existing vector database, send a PUT request to ``/v2/vector-databases/{id}``. The + response body contains a JSON object with a ``vector_db`` key holding the updated vector + database. + + :param id: ID of the vector database. Required. + :type id: str + :param body: Is either a JSON type or a IO[bytes] type. Default value is None. + :type body: JSON or IO[bytes] + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "config": { + "default_quantization": "str", # Optional. Default vector + compression for new collections: rq, pq, bq, or sq. Empty means platform + default (rq). + "enable_auto_schema": bool, # Optional. VectorDBConfig holds + optional, advanced cluster settings. + "weaviate_version": "str" # Optional. The Vector Database version + running on the cluster. + }, + "id": "str", # Optional. ID of the vector database. + "project_id": "str" # Optional. Optional. New project UUID to assign the + database to. + } + + # response body for status code(s): 200 + response == { + "vector_db": { + "config": { + "default_quantization": "str", # Optional. Default vector + compression for new collections: rq, pq, bq, or sq. Empty means platform + default (rq). + "enable_auto_schema": bool, # Optional. VectorDBConfig holds + optional, advanced cluster settings. + "weaviate_version": "str" # Optional. The Vector Database + version running on the cluster. + }, + "created_at": "2020-02-20 00:00:00", # Optional. VectorDB represents + a provisioned vector database instance. + "endpoints": { + "grpc": "str", # Optional. Endpoint for gRPC connections + (e.g. "my-db-tor1-a1b2c3d4-grpc.weaviate.ondigitalocean.com:443"). + "http": "str" # Optional. Endpoint for HTTPS connections + (e.g. "https://my-db-tor1-a1b2c3d4.weaviate.ondigitalocean.com"). + }, + "forked_from_id": "str", # Optional. ID of the vector database this + instance was forked from. Empty when the instance was created directly via + CreateVectorDB. Read-only and set by the platform at fork time; never + modifiable through UpdateVectorDB. + "id": "str", # Optional. VectorDB represents a provisioned vector + database instance. + "last_restore_id": "str", # Optional. Backup_id of the most recent + restore initiated against this instance. Empty if no restore has ever been + triggered. Lets callers recover the identifier of an in-flight or + last-completed restore without having to retain the RestoreBackupResponse + themselves. Use it with GetRestoreStatus to fetch the live status. + "name": "str", # Optional. VectorDB represents a provisioned vector + database instance. + "owner_uuid": "str", # Optional. VectorDB represents a provisioned + vector database instance. + "project_id": "str", # Optional. Project this database belongs to. + "region": "str", # Optional. VectorDB represents a provisioned + vector database instance. + "size": "str", # Optional. Resource tier: small, medium, or large. + "status": "str", # Optional. Lifecycle state: pending, creating, + active, errored, or deleting. + "tags": [ + "str" # Optional. VectorDB represents a provisioned vector + database instance. + ], + "updated_at": "2020-02-20 00:00:00" # Optional. VectorDB represents + a provisioned vector database instance. + } + } + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + lambda response: ClientAuthenticationError(response=response), + ), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop( + "content_type", _headers.pop("Content-Type", None) + ) + cls: ClsType[JSON] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + if body is not None: + _json = body + else: + _json = None + + _request = build_vector_databases_update_request( + id=id, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + if _stream: + await response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + if response.status_code == 200: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 404: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + @distributed_trace_async + async def delete(self, id: str, **kwargs: Any) -> Optional[JSON]: + # pylint: disable=line-too-long + """Delete a Vector Database. + + To delete a vector database, send a DELETE request to ``/v2/vector-databases/{id}``. Deleting a + vector database is irreversible and destroys the underlying instance along with its data. + + :param id: ID of the vector database. Required. + :type id: str + :return: JSON object or None + :rtype: JSON or None + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + lambda response: ClientAuthenticationError(response=response), + ), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Optional[JSON]] = kwargs.pop("cls", None) + + _request = build_vector_databases_delete_request( + id=id, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [204, 404]: + if _stream: + await response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + deserialized = None + response_headers = {} + if response.status_code == 204: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.status_code == 404: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def list_backups(self, id: str, **kwargs: Any) -> JSON: + # pylint: disable=line-too-long + """List Backups for a Vector Database. + + To list the available backups for a vector database, send a GET request to + ``/v2/vector-databases/{id}/backups``. Only backups with a status of ``SUCCESS`` are returned. + + :param id: Required. ID of the vector database. Required. + :type id: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "backups": [ + { + "backup_id": "str", # Optional. Unique identifier for the + backup (e.g., "vectordb-{uuid}-20240101-120000"). + "completed_at": "2020-02-20 00:00:00", # Optional. Timestamp + when the backup process completed. + "started_at": "2020-02-20 00:00:00", # Optional. Timestamp + when the backup process started. + "status": "str" # Optional. Status of the backup: SUCCESS. + } + ] + } + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + lambda response: ClientAuthenticationError(response=response), + ), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[JSON] = kwargs.pop("cls", None) + + _request = build_vector_databases_list_backups_request( + id=id, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + if _stream: + await response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + if response.status_code == 200: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 404: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + @distributed_trace_async + async def get_restore_status(self, id: str, backup_id: str, **kwargs: Any) -> JSON: + # pylint: disable=line-too-long + """Retrieve the Status of a Restore. + + To check the status of a restore operation, send a GET request to + ``/v2/vector-databases/{id}/backups/{backup_id}/restore``. The response body contains the + current status of the restore. + + :param id: Required. ID of the vector database. Required. + :type id: str + :param backup_id: Required. ID of the backup being restored. Required. + :type backup_id: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "backup_id": "str", # Optional. The backup ID being restored. + "error": "str", # Optional. Error message if the restore failed. + "status": "str" # Optional. Current status: STARTED, TRANSFERRING, + TRANSFERRED, FINALIZING, SUCCESS, FAILED, CANCELLING, CANCELED. + } + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + lambda response: ClientAuthenticationError(response=response), + ), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[JSON] = kwargs.pop("cls", None) + + _request = build_vector_databases_get_restore_status_request( + id=id, + backup_id=backup_id, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + if _stream: + await response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + if response.status_code == 200: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 404: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + @overload + async def post_restore_backup( + self, + id: str, + backup_id: str, + body: Optional[JSON] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Restore a Vector Database from a Backup. + + To restore a vector database from a backup, send a POST request to + ``/v2/vector-databases/{id}/backups/{backup_id}/restore``. The restore runs asynchronously; use + the restore-status endpoint to monitor its progress. + + :param id: Required. ID of the vector database. Required. + :type id: str + :param backup_id: Required. ID of the backup to restore from. Required. + :type backup_id: str + :param body: Default value is None. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "backup_id": "str", # Optional. Required. ID of the backup to restore from. + "id": "str" # Optional. Required. ID of the vector database. + } + + # response body for status code(s): 200 + response == { + "backup_id": "str", # Optional. The backup ID being restored. + "status": "str" # Optional. Initial status of the restore operation (e.g., + "STARTED"). + } + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + + @overload + async def post_restore_backup( + self, + id: str, + backup_id: str, + body: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Restore a Vector Database from a Backup. + + To restore a vector database from a backup, send a POST request to + ``/v2/vector-databases/{id}/backups/{backup_id}/restore``. The restore runs asynchronously; use + the restore-status endpoint to monitor its progress. + + :param id: Required. ID of the vector database. Required. + :type id: str + :param backup_id: Required. ID of the backup to restore from. Required. + :type backup_id: str + :param body: Default value is None. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "backup_id": "str", # Optional. The backup ID being restored. + "status": "str" # Optional. Initial status of the restore operation (e.g., + "STARTED"). + } + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + + @distributed_trace_async + async def post_restore_backup( + self, + id: str, + backup_id: str, + body: Optional[Union[JSON, IO[bytes]]] = None, + **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Restore a Vector Database from a Backup. + + To restore a vector database from a backup, send a POST request to + ``/v2/vector-databases/{id}/backups/{backup_id}/restore``. The restore runs asynchronously; use + the restore-status endpoint to monitor its progress. + + :param id: Required. ID of the vector database. Required. + :type id: str + :param backup_id: Required. ID of the backup to restore from. Required. + :type backup_id: str + :param body: Is either a JSON type or a IO[bytes] type. Default value is None. + :type body: JSON or IO[bytes] + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "backup_id": "str", # Optional. Required. ID of the backup to restore from. + "id": "str" # Optional. Required. ID of the vector database. + } + + # response body for status code(s): 200 + response == { + "backup_id": "str", # Optional. The backup ID being restored. + "status": "str" # Optional. Initial status of the restore operation (e.g., + "STARTED"). + } + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + lambda response: ClientAuthenticationError(response=response), + ), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop( + "content_type", _headers.pop("Content-Type", None) + ) + cls: ClsType[JSON] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + if body is not None: + _json = body + else: + _json = None + + _request = build_vector_databases_post_restore_backup_request( + id=id, + backup_id=backup_id, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + if _stream: + await response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + if response.status_code == 200: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 404: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + @distributed_trace_async + async def get_credentials(self, id: str, **kwargs: Any) -> JSON: + # pylint: disable=line-too-long + """Retrieve Admin Credentials for a Vector Database. + + To retrieve the admin credentials for a vector database, send a GET request to + ``/v2/vector-databases/{id}/credentials``. The response body contains the ``user_id`` and + ``api_token`` for the admin user provisioned on the cluster. + + :param id: ID of the vector database. Required. + :type id: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "api_token": "str", # Optional. API token for that user. + "user_id": "str" # Optional. Database user id from the cluster secret + (opaque; matches what was provisioned). + } + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + lambda response: ClientAuthenticationError(response=response), + ), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[JSON] = kwargs.pop("cls", None) + + _request = build_vector_databases_get_credentials_request( + id=id, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + if _stream: + await response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + if response.status_code == 200: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 404: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + @overload + async def post_resize( + self, + id: str, + body: Optional[JSON] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Resize a Vector Database. + + To resize a vector database, send a POST request to ``/v2/vector-databases/{id}/resize``. This + changes the database's resource tier. The response body contains a JSON object with the updated + vector database. + + :param id: Required. ID of the vector database to resize. Required. + :type id: str + :param body: Default value is None. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "id": "str", # Optional. Required. ID of the vector database to resize. + "size": "str" # Optional. Required. Target resource tier: small, medium, or + large. + } + + # response body for status code(s): 200 + response == { + "vector_db": { + "config": { + "default_quantization": "str", # Optional. Default vector + compression for new collections: rq, pq, bq, or sq. Empty means platform + default (rq). + "enable_auto_schema": bool, # Optional. VectorDBConfig holds + optional, advanced cluster settings. + "weaviate_version": "str" # Optional. The Vector Database + version running on the cluster. + }, + "created_at": "2020-02-20 00:00:00", # Optional. VectorDB represents + a provisioned vector database instance. + "endpoints": { + "grpc": "str", # Optional. Endpoint for gRPC connections + (e.g. "my-db-tor1-a1b2c3d4-grpc.weaviate.ondigitalocean.com:443"). + "http": "str" # Optional. Endpoint for HTTPS connections + (e.g. "https://my-db-tor1-a1b2c3d4.weaviate.ondigitalocean.com"). + }, + "forked_from_id": "str", # Optional. ID of the vector database this + instance was forked from. Empty when the instance was created directly via + CreateVectorDB. Read-only and set by the platform at fork time; never + modifiable through UpdateVectorDB. + "id": "str", # Optional. VectorDB represents a provisioned vector + database instance. + "last_restore_id": "str", # Optional. Backup_id of the most recent + restore initiated against this instance. Empty if no restore has ever been + triggered. Lets callers recover the identifier of an in-flight or + last-completed restore without having to retain the RestoreBackupResponse + themselves. Use it with GetRestoreStatus to fetch the live status. + "name": "str", # Optional. VectorDB represents a provisioned vector + database instance. + "owner_uuid": "str", # Optional. VectorDB represents a provisioned + vector database instance. + "project_id": "str", # Optional. Project this database belongs to. + "region": "str", # Optional. VectorDB represents a provisioned + vector database instance. + "size": "str", # Optional. Resource tier: small, medium, or large. + "status": "str", # Optional. Lifecycle state: pending, creating, + active, errored, or deleting. + "tags": [ + "str" # Optional. VectorDB represents a provisioned vector + database instance. + ], + "updated_at": "2020-02-20 00:00:00" # Optional. VectorDB represents + a provisioned vector database instance. + } + } + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + + @overload + async def post_resize( + self, + id: str, + body: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Resize a Vector Database. + + To resize a vector database, send a POST request to ``/v2/vector-databases/{id}/resize``. This + changes the database's resource tier. The response body contains a JSON object with the updated + vector database. + + :param id: Required. ID of the vector database to resize. Required. + :type id: str + :param body: Default value is None. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "vector_db": { + "config": { + "default_quantization": "str", # Optional. Default vector + compression for new collections: rq, pq, bq, or sq. Empty means platform + default (rq). + "enable_auto_schema": bool, # Optional. VectorDBConfig holds + optional, advanced cluster settings. + "weaviate_version": "str" # Optional. The Vector Database + version running on the cluster. + }, + "created_at": "2020-02-20 00:00:00", # Optional. VectorDB represents + a provisioned vector database instance. + "endpoints": { + "grpc": "str", # Optional. Endpoint for gRPC connections + (e.g. "my-db-tor1-a1b2c3d4-grpc.weaviate.ondigitalocean.com:443"). + "http": "str" # Optional. Endpoint for HTTPS connections + (e.g. "https://my-db-tor1-a1b2c3d4.weaviate.ondigitalocean.com"). + }, + "forked_from_id": "str", # Optional. ID of the vector database this + instance was forked from. Empty when the instance was created directly via + CreateVectorDB. Read-only and set by the platform at fork time; never + modifiable through UpdateVectorDB. + "id": "str", # Optional. VectorDB represents a provisioned vector + database instance. + "last_restore_id": "str", # Optional. Backup_id of the most recent + restore initiated against this instance. Empty if no restore has ever been + triggered. Lets callers recover the identifier of an in-flight or + last-completed restore without having to retain the RestoreBackupResponse + themselves. Use it with GetRestoreStatus to fetch the live status. + "name": "str", # Optional. VectorDB represents a provisioned vector + database instance. + "owner_uuid": "str", # Optional. VectorDB represents a provisioned + vector database instance. + "project_id": "str", # Optional. Project this database belongs to. + "region": "str", # Optional. VectorDB represents a provisioned + vector database instance. + "size": "str", # Optional. Resource tier: small, medium, or large. + "status": "str", # Optional. Lifecycle state: pending, creating, + active, errored, or deleting. + "tags": [ + "str" # Optional. VectorDB represents a provisioned vector + database instance. + ], + "updated_at": "2020-02-20 00:00:00" # Optional. VectorDB represents + a provisioned vector database instance. + } + } + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + + @distributed_trace_async + async def post_resize( + self, id: str, body: Optional[Union[JSON, IO[bytes]]] = None, **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Resize a Vector Database. + + To resize a vector database, send a POST request to ``/v2/vector-databases/{id}/resize``. This + changes the database's resource tier. The response body contains a JSON object with the updated + vector database. + + :param id: Required. ID of the vector database to resize. Required. + :type id: str + :param body: Is either a JSON type or a IO[bytes] type. Default value is None. + :type body: JSON or IO[bytes] + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "id": "str", # Optional. Required. ID of the vector database to resize. + "size": "str" # Optional. Required. Target resource tier: small, medium, or + large. + } + + # response body for status code(s): 200 + response == { + "vector_db": { + "config": { + "default_quantization": "str", # Optional. Default vector + compression for new collections: rq, pq, bq, or sq. Empty means platform + default (rq). + "enable_auto_schema": bool, # Optional. VectorDBConfig holds + optional, advanced cluster settings. + "weaviate_version": "str" # Optional. The Vector Database + version running on the cluster. + }, + "created_at": "2020-02-20 00:00:00", # Optional. VectorDB represents + a provisioned vector database instance. + "endpoints": { + "grpc": "str", # Optional. Endpoint for gRPC connections + (e.g. "my-db-tor1-a1b2c3d4-grpc.weaviate.ondigitalocean.com:443"). + "http": "str" # Optional. Endpoint for HTTPS connections + (e.g. "https://my-db-tor1-a1b2c3d4.weaviate.ondigitalocean.com"). + }, + "forked_from_id": "str", # Optional. ID of the vector database this + instance was forked from. Empty when the instance was created directly via + CreateVectorDB. Read-only and set by the platform at fork time; never + modifiable through UpdateVectorDB. + "id": "str", # Optional. VectorDB represents a provisioned vector + database instance. + "last_restore_id": "str", # Optional. Backup_id of the most recent + restore initiated against this instance. Empty if no restore has ever been + triggered. Lets callers recover the identifier of an in-flight or + last-completed restore without having to retain the RestoreBackupResponse + themselves. Use it with GetRestoreStatus to fetch the live status. + "name": "str", # Optional. VectorDB represents a provisioned vector + database instance. + "owner_uuid": "str", # Optional. VectorDB represents a provisioned + vector database instance. + "project_id": "str", # Optional. Project this database belongs to. + "region": "str", # Optional. VectorDB represents a provisioned + vector database instance. + "size": "str", # Optional. Resource tier: small, medium, or large. + "status": "str", # Optional. Lifecycle state: pending, creating, + active, errored, or deleting. + "tags": [ + "str" # Optional. VectorDB represents a provisioned vector + database instance. + ], + "updated_at": "2020-02-20 00:00:00" # Optional. VectorDB represents + a provisioned vector database instance. + } + } + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + lambda response: ClientAuthenticationError(response=response), + ), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop( + "content_type", _headers.pop("Content-Type", None) + ) + cls: ClsType[JSON] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + if body is not None: + _json = body + else: + _json = None + + _request = build_vector_databases_post_resize_request( + id=id, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + if _stream: + await response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + if response.status_code == 200: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 404: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + @overload + async def update_tags( + self, + id: str, + body: Optional[JSON] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Update Tags on a Vector Database. + + To update the tags on a vector database, send a PUT request to + ``/v2/vector-databases/{id}/tags``. The supplied set of tags replaces the database's existing + tags. + + :param id: Required. ID of the vector database to update tags for. Required. + :type id: str + :param body: Default value is None. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "id": "str", # Optional. Required. ID of the vector database to update tags + for. + "tags": [ + "str" # Optional. Tags to set on the vector database. Replaces all + existing tags. + ] + } + + # response body for status code(s): 200 + response == { + "vector_db": { + "config": { + "default_quantization": "str", # Optional. Default vector + compression for new collections: rq, pq, bq, or sq. Empty means platform + default (rq). + "enable_auto_schema": bool, # Optional. VectorDBConfig holds + optional, advanced cluster settings. + "weaviate_version": "str" # Optional. The Vector Database + version running on the cluster. + }, + "created_at": "2020-02-20 00:00:00", # Optional. VectorDB represents + a provisioned vector database instance. + "endpoints": { + "grpc": "str", # Optional. Endpoint for gRPC connections + (e.g. "my-db-tor1-a1b2c3d4-grpc.weaviate.ondigitalocean.com:443"). + "http": "str" # Optional. Endpoint for HTTPS connections + (e.g. "https://my-db-tor1-a1b2c3d4.weaviate.ondigitalocean.com"). + }, + "forked_from_id": "str", # Optional. ID of the vector database this + instance was forked from. Empty when the instance was created directly via + CreateVectorDB. Read-only and set by the platform at fork time; never + modifiable through UpdateVectorDB. + "id": "str", # Optional. VectorDB represents a provisioned vector + database instance. + "last_restore_id": "str", # Optional. Backup_id of the most recent + restore initiated against this instance. Empty if no restore has ever been + triggered. Lets callers recover the identifier of an in-flight or + last-completed restore without having to retain the RestoreBackupResponse + themselves. Use it with GetRestoreStatus to fetch the live status. + "name": "str", # Optional. VectorDB represents a provisioned vector + database instance. + "owner_uuid": "str", # Optional. VectorDB represents a provisioned + vector database instance. + "project_id": "str", # Optional. Project this database belongs to. + "region": "str", # Optional. VectorDB represents a provisioned + vector database instance. + "size": "str", # Optional. Resource tier: small, medium, or large. + "status": "str", # Optional. Lifecycle state: pending, creating, + active, errored, or deleting. + "tags": [ + "str" # Optional. VectorDB represents a provisioned vector + database instance. + ], + "updated_at": "2020-02-20 00:00:00" # Optional. VectorDB represents + a provisioned vector database instance. + } + } + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + + @overload + async def update_tags( + self, + id: str, + body: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Update Tags on a Vector Database. + + To update the tags on a vector database, send a PUT request to + ``/v2/vector-databases/{id}/tags``. The supplied set of tags replaces the database's existing + tags. + + :param id: Required. ID of the vector database to update tags for. Required. + :type id: str + :param body: Default value is None. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "vector_db": { + "config": { + "default_quantization": "str", # Optional. Default vector + compression for new collections: rq, pq, bq, or sq. Empty means platform + default (rq). + "enable_auto_schema": bool, # Optional. VectorDBConfig holds + optional, advanced cluster settings. + "weaviate_version": "str" # Optional. The Vector Database + version running on the cluster. + }, + "created_at": "2020-02-20 00:00:00", # Optional. VectorDB represents + a provisioned vector database instance. + "endpoints": { + "grpc": "str", # Optional. Endpoint for gRPC connections + (e.g. "my-db-tor1-a1b2c3d4-grpc.weaviate.ondigitalocean.com:443"). + "http": "str" # Optional. Endpoint for HTTPS connections + (e.g. "https://my-db-tor1-a1b2c3d4.weaviate.ondigitalocean.com"). + }, + "forked_from_id": "str", # Optional. ID of the vector database this + instance was forked from. Empty when the instance was created directly via + CreateVectorDB. Read-only and set by the platform at fork time; never + modifiable through UpdateVectorDB. + "id": "str", # Optional. VectorDB represents a provisioned vector + database instance. + "last_restore_id": "str", # Optional. Backup_id of the most recent + restore initiated against this instance. Empty if no restore has ever been + triggered. Lets callers recover the identifier of an in-flight or + last-completed restore without having to retain the RestoreBackupResponse + themselves. Use it with GetRestoreStatus to fetch the live status. + "name": "str", # Optional. VectorDB represents a provisioned vector + database instance. + "owner_uuid": "str", # Optional. VectorDB represents a provisioned + vector database instance. + "project_id": "str", # Optional. Project this database belongs to. + "region": "str", # Optional. VectorDB represents a provisioned + vector database instance. + "size": "str", # Optional. Resource tier: small, medium, or large. + "status": "str", # Optional. Lifecycle state: pending, creating, + active, errored, or deleting. + "tags": [ + "str" # Optional. VectorDB represents a provisioned vector + database instance. + ], + "updated_at": "2020-02-20 00:00:00" # Optional. VectorDB represents + a provisioned vector database instance. + } + } + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + + @distributed_trace_async + async def update_tags( + self, id: str, body: Optional[Union[JSON, IO[bytes]]] = None, **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Update Tags on a Vector Database. + + To update the tags on a vector database, send a PUT request to + ``/v2/vector-databases/{id}/tags``. The supplied set of tags replaces the database's existing + tags. + + :param id: Required. ID of the vector database to update tags for. Required. + :type id: str + :param body: Is either a JSON type or a IO[bytes] type. Default value is None. + :type body: JSON or IO[bytes] + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "id": "str", # Optional. Required. ID of the vector database to update tags + for. + "tags": [ + "str" # Optional. Tags to set on the vector database. Replaces all + existing tags. + ] + } + + # response body for status code(s): 200 + response == { + "vector_db": { + "config": { + "default_quantization": "str", # Optional. Default vector + compression for new collections: rq, pq, bq, or sq. Empty means platform + default (rq). + "enable_auto_schema": bool, # Optional. VectorDBConfig holds + optional, advanced cluster settings. + "weaviate_version": "str" # Optional. The Vector Database + version running on the cluster. + }, + "created_at": "2020-02-20 00:00:00", # Optional. VectorDB represents + a provisioned vector database instance. + "endpoints": { + "grpc": "str", # Optional. Endpoint for gRPC connections + (e.g. "my-db-tor1-a1b2c3d4-grpc.weaviate.ondigitalocean.com:443"). + "http": "str" # Optional. Endpoint for HTTPS connections + (e.g. "https://my-db-tor1-a1b2c3d4.weaviate.ondigitalocean.com"). + }, + "forked_from_id": "str", # Optional. ID of the vector database this + instance was forked from. Empty when the instance was created directly via + CreateVectorDB. Read-only and set by the platform at fork time; never + modifiable through UpdateVectorDB. + "id": "str", # Optional. VectorDB represents a provisioned vector + database instance. + "last_restore_id": "str", # Optional. Backup_id of the most recent + restore initiated against this instance. Empty if no restore has ever been + triggered. Lets callers recover the identifier of an in-flight or + last-completed restore without having to retain the RestoreBackupResponse + themselves. Use it with GetRestoreStatus to fetch the live status. + "name": "str", # Optional. VectorDB represents a provisioned vector + database instance. + "owner_uuid": "str", # Optional. VectorDB represents a provisioned + vector database instance. + "project_id": "str", # Optional. Project this database belongs to. + "region": "str", # Optional. VectorDB represents a provisioned + vector database instance. + "size": "str", # Optional. Resource tier: small, medium, or large. + "status": "str", # Optional. Lifecycle state: pending, creating, + active, errored, or deleting. + "tags": [ + "str" # Optional. VectorDB represents a provisioned vector + database instance. + ], + "updated_at": "2020-02-20 00:00:00" # Optional. VectorDB represents + a provisioned vector database instance. + } + } + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + lambda response: ClientAuthenticationError(response=response), + ), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop( + "content_type", _headers.pop("Content-Type", None) + ) + cls: ClsType[JSON] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + if body is not None: + _json = body + else: + _json = None + + _request = build_vector_databases_update_tags_request( + id=id, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + if _stream: + await response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + if response.status_code == 200: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 404: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + class VolumesOperations: """ .. warning:: diff --git a/src/pydo/operations/__init__.py b/src/pydo/operations/__init__.py index 4286825e..2de68fec 100644 --- a/src/pydo/operations/__init__.py +++ b/src/pydo/operations/__init__.py @@ -46,6 +46,7 @@ from ._operations import SnapshotsOperations from ._operations import SpacesKeyOperations from ._operations import TagsOperations +from ._operations import VectorDatabasesOperations from ._operations import VolumesOperations from ._operations import VolumeActionsOperations from ._operations import VolumeSnapshotsOperations @@ -104,6 +105,7 @@ "SnapshotsOperations", "SpacesKeyOperations", "TagsOperations", + "VectorDatabasesOperations", "VolumesOperations", "VolumeActionsOperations", "VolumeSnapshotsOperations", diff --git a/src/pydo/operations/_operations.py b/src/pydo/operations/_operations.py index d71baa1e..ed6fe43c 100644 --- a/src/pydo/operations/_operations.py +++ b/src/pydo/operations/_operations.py @@ -11428,6 +11428,265 @@ def build_tags_unassign_resources_request(tag_id: str, **kwargs: Any) -> HttpReq return HttpRequest(method="DELETE", url=_url, headers=_headers, **kwargs) +def build_vector_databases_list_request( + *, page: Optional[int] = None, per_page: Optional[int] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/v2/vector-databases" + + # Construct parameters + if page is not None: + _params["page"] = _SERIALIZER.query("page", page, "int") + if per_page is not None: + _params["per_page"] = _SERIALIZER.query("per_page", per_page, "int") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest( + method="GET", url=_url, params=_params, headers=_headers, **kwargs + ) + + +def build_vector_databases_create_request(**kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + + content_type: Optional[str] = kwargs.pop( + "content_type", _headers.pop("Content-Type", None) + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/v2/vector-databases" + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header( + "content_type", content_type, "str" + ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, headers=_headers, **kwargs) + + +def build_vector_databases_get_request(id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/v2/vector-databases/{id}" + path_format_arguments = { + "id": _SERIALIZER.url("id", id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, headers=_headers, **kwargs) + + +def build_vector_databases_update_request(id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + + content_type: Optional[str] = kwargs.pop( + "content_type", _headers.pop("Content-Type", None) + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/v2/vector-databases/{id}" + path_format_arguments = { + "id": _SERIALIZER.url("id", id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header( + "content_type", content_type, "str" + ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, headers=_headers, **kwargs) + + +def build_vector_databases_delete_request(id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/v2/vector-databases/{id}" + path_format_arguments = { + "id": _SERIALIZER.url("id", id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, headers=_headers, **kwargs) + + +def build_vector_databases_list_backups_request( + id: str, **kwargs: Any +) -> HttpRequest: # pylint: disable=name-too-long + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/v2/vector-databases/{id}/backups" + path_format_arguments = { + "id": _SERIALIZER.url("id", id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, headers=_headers, **kwargs) + + +def build_vector_databases_get_restore_status_request( # pylint: disable=name-too-long + id: str, backup_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/v2/vector-databases/{id}/backups/{backup_id}/restore" + path_format_arguments = { + "id": _SERIALIZER.url("id", id, "str"), + "backup_id": _SERIALIZER.url("backup_id", backup_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, headers=_headers, **kwargs) + + +def build_vector_databases_post_restore_backup_request( # pylint: disable=name-too-long + id: str, backup_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + + content_type: Optional[str] = kwargs.pop( + "content_type", _headers.pop("Content-Type", None) + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/v2/vector-databases/{id}/backups/{backup_id}/restore" + path_format_arguments = { + "id": _SERIALIZER.url("id", id, "str"), + "backup_id": _SERIALIZER.url("backup_id", backup_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header( + "content_type", content_type, "str" + ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, headers=_headers, **kwargs) + + +def build_vector_databases_get_credentials_request( # pylint: disable=name-too-long + id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/v2/vector-databases/{id}/credentials" + path_format_arguments = { + "id": _SERIALIZER.url("id", id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, headers=_headers, **kwargs) + + +def build_vector_databases_post_resize_request( + id: str, **kwargs: Any +) -> HttpRequest: # pylint: disable=name-too-long + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + + content_type: Optional[str] = kwargs.pop( + "content_type", _headers.pop("Content-Type", None) + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/v2/vector-databases/{id}/resize" + path_format_arguments = { + "id": _SERIALIZER.url("id", id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header( + "content_type", content_type, "str" + ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, headers=_headers, **kwargs) + + +def build_vector_databases_update_tags_request( + id: str, **kwargs: Any +) -> HttpRequest: # pylint: disable=name-too-long + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + + content_type: Optional[str] = kwargs.pop( + "content_type", _headers.pop("Content-Type", None) + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/v2/vector-databases/{id}/tags" + path_format_arguments = { + "id": _SERIALIZER.url("id", id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header( + "content_type", content_type, "str" + ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, headers=_headers, **kwargs) + + def build_volumes_list_request( *, name: Optional[str] = None, @@ -207698,6 +207957,2602 @@ def unassign_resources( return deserialized # type: ignore +class VectorDatabasesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~pydo.GeneratedClient`'s + :attr:`vector_databases` attribute. + """ + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = ( + input_args.pop(0) if input_args else kwargs.pop("deserializer") + ) + + @distributed_trace + def list( + self, + *, + page: Optional[int] = None, + per_page: Optional[int] = None, + **kwargs: Any, + ) -> JSON: + # pylint: disable=line-too-long + """List All Vector Databases. + + To list all of the vector databases on your account, send a GET request to + ``/v2/vector-databases``. Use the ``page`` and ``per_page`` query parameters to paginate the + results. The response body contains a ``vector_dbs`` array of vector database objects and a + ``total`` field with the overall count. + + :keyword page: Default value is None. + :paramtype page: int + :keyword per_page: Default value is None. + :paramtype per_page: int + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "total": 0, # Optional. + "vector_dbs": [ + { + "config": { + "default_quantization": "str", # Optional. Default + vector compression for new collections: rq, pq, bq, or sq. Empty + means platform default (rq). + "enable_auto_schema": bool, # Optional. + VectorDBConfig holds optional, advanced cluster settings. + "weaviate_version": "str" # Optional. The Vector + Database version running on the cluster. + }, + "created_at": "2020-02-20 00:00:00", # Optional. + "endpoints": { + "grpc": "str", # Optional. Endpoint for gRPC + connections (e.g. + "my-db-tor1-a1b2c3d4-grpc.weaviate.ondigitalocean.com:443"). + "http": "str" # Optional. Endpoint for HTTPS + connections (e.g. + "https://my-db-tor1-a1b2c3d4.weaviate.ondigitalocean.com"). + }, + "forked_from_id": "str", # Optional. ID of the vector + database this instance was forked from. Empty when the instance was + created directly via CreateVectorDB. Read-only and set by the platform at + fork time; never modifiable through UpdateVectorDB. + "id": "str", # Optional. + "last_restore_id": "str", # Optional. Backup_id of the most + recent restore initiated against this instance. Empty if no restore has + ever been triggered. Lets callers recover the identifier of an in-flight + or last-completed restore without having to retain the + RestoreBackupResponse themselves. Use it with GetRestoreStatus to fetch + the live status. + "name": "str", # Optional. + "owner_uuid": "str", # Optional. + "project_id": "str", # Optional. Project this database + belongs to. + "region": "str", # Optional. + "size": "str", # Optional. Resource tier: small, medium, or + large. + "status": "str", # Optional. Lifecycle state: pending, + creating, active, errored, or deleting. + "tags": [ + "str" # Optional. + ], + "updated_at": "2020-02-20 00:00:00" # Optional. + } + ] + } + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + lambda response: ClientAuthenticationError(response=response), + ), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[JSON] = kwargs.pop("cls", None) + + _request = build_vector_databases_list_request( + page=page, + per_page=per_page, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + if _stream: + response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + if response.status_code == 200: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 404: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + @overload + def create( + self, + body: Optional[JSON] = None, + *, + content_type: str = "application/json", + **kwargs: Any, + ) -> JSON: + # pylint: disable=line-too-long + """Create a New Vector Database. + + To create a vector database, send a POST request to ``/v2/vector-databases``. The response body + contains a JSON object with a ``vector_db`` key holding the newly created database. Its initial + ``status`` is ``creating`` and changes to ``active`` once the database is ready to receive + traffic. + + :param body: Default value is None. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "name": "str", # Optional. Required. Human-readable name for the database. + "project_id": "str", # Optional. Required. ID of the project to create the + vector database in. + "region": "str", # Optional. Required. Region slug where the database will + be provisioned. + "size": "str", # Optional. Required. Resource tier: small, medium, or large. + "tags": [ + "str" # Optional. A set of arbitrary tags to organize your vector + database. + ] + } + + # response body for status code(s): 201 + response == { + "vector_db": { + "config": { + "default_quantization": "str", # Optional. Default vector + compression for new collections: rq, pq, bq, or sq. Empty means platform + default (rq). + "enable_auto_schema": bool, # Optional. VectorDBConfig holds + optional, advanced cluster settings. + "weaviate_version": "str" # Optional. The Vector Database + version running on the cluster. + }, + "created_at": "2020-02-20 00:00:00", # Optional. VectorDB represents + a provisioned vector database instance. + "endpoints": { + "grpc": "str", # Optional. Endpoint for gRPC connections + (e.g. "my-db-tor1-a1b2c3d4-grpc.weaviate.ondigitalocean.com:443"). + "http": "str" # Optional. Endpoint for HTTPS connections + (e.g. "https://my-db-tor1-a1b2c3d4.weaviate.ondigitalocean.com"). + }, + "forked_from_id": "str", # Optional. ID of the vector database this + instance was forked from. Empty when the instance was created directly via + CreateVectorDB. Read-only and set by the platform at fork time; never + modifiable through UpdateVectorDB. + "id": "str", # Optional. VectorDB represents a provisioned vector + database instance. + "last_restore_id": "str", # Optional. Backup_id of the most recent + restore initiated against this instance. Empty if no restore has ever been + triggered. Lets callers recover the identifier of an in-flight or + last-completed restore without having to retain the RestoreBackupResponse + themselves. Use it with GetRestoreStatus to fetch the live status. + "name": "str", # Optional. VectorDB represents a provisioned vector + database instance. + "owner_uuid": "str", # Optional. VectorDB represents a provisioned + vector database instance. + "project_id": "str", # Optional. Project this database belongs to. + "region": "str", # Optional. VectorDB represents a provisioned + vector database instance. + "size": "str", # Optional. Resource tier: small, medium, or large. + "status": "str", # Optional. Lifecycle state: pending, creating, + active, errored, or deleting. + "tags": [ + "str" # Optional. VectorDB represents a provisioned vector + database instance. + ], + "updated_at": "2020-02-20 00:00:00" # Optional. VectorDB represents + a provisioned vector database instance. + } + } + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + + @overload + def create( + self, + body: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any, + ) -> JSON: + # pylint: disable=line-too-long + """Create a New Vector Database. + + To create a vector database, send a POST request to ``/v2/vector-databases``. The response body + contains a JSON object with a ``vector_db`` key holding the newly created database. Its initial + ``status`` is ``creating`` and changes to ``active`` once the database is ready to receive + traffic. + + :param body: Default value is None. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 201 + response == { + "vector_db": { + "config": { + "default_quantization": "str", # Optional. Default vector + compression for new collections: rq, pq, bq, or sq. Empty means platform + default (rq). + "enable_auto_schema": bool, # Optional. VectorDBConfig holds + optional, advanced cluster settings. + "weaviate_version": "str" # Optional. The Vector Database + version running on the cluster. + }, + "created_at": "2020-02-20 00:00:00", # Optional. VectorDB represents + a provisioned vector database instance. + "endpoints": { + "grpc": "str", # Optional. Endpoint for gRPC connections + (e.g. "my-db-tor1-a1b2c3d4-grpc.weaviate.ondigitalocean.com:443"). + "http": "str" # Optional. Endpoint for HTTPS connections + (e.g. "https://my-db-tor1-a1b2c3d4.weaviate.ondigitalocean.com"). + }, + "forked_from_id": "str", # Optional. ID of the vector database this + instance was forked from. Empty when the instance was created directly via + CreateVectorDB. Read-only and set by the platform at fork time; never + modifiable through UpdateVectorDB. + "id": "str", # Optional. VectorDB represents a provisioned vector + database instance. + "last_restore_id": "str", # Optional. Backup_id of the most recent + restore initiated against this instance. Empty if no restore has ever been + triggered. Lets callers recover the identifier of an in-flight or + last-completed restore without having to retain the RestoreBackupResponse + themselves. Use it with GetRestoreStatus to fetch the live status. + "name": "str", # Optional. VectorDB represents a provisioned vector + database instance. + "owner_uuid": "str", # Optional. VectorDB represents a provisioned + vector database instance. + "project_id": "str", # Optional. Project this database belongs to. + "region": "str", # Optional. VectorDB represents a provisioned + vector database instance. + "size": "str", # Optional. Resource tier: small, medium, or large. + "status": "str", # Optional. Lifecycle state: pending, creating, + active, errored, or deleting. + "tags": [ + "str" # Optional. VectorDB represents a provisioned vector + database instance. + ], + "updated_at": "2020-02-20 00:00:00" # Optional. VectorDB represents + a provisioned vector database instance. + } + } + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + + @distributed_trace + def create( + self, body: Optional[Union[JSON, IO[bytes]]] = None, **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Create a New Vector Database. + + To create a vector database, send a POST request to ``/v2/vector-databases``. The response body + contains a JSON object with a ``vector_db`` key holding the newly created database. Its initial + ``status`` is ``creating`` and changes to ``active`` once the database is ready to receive + traffic. + + :param body: Is either a JSON type or a IO[bytes] type. Default value is None. + :type body: JSON or IO[bytes] + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "name": "str", # Optional. Required. Human-readable name for the database. + "project_id": "str", # Optional. Required. ID of the project to create the + vector database in. + "region": "str", # Optional. Required. Region slug where the database will + be provisioned. + "size": "str", # Optional. Required. Resource tier: small, medium, or large. + "tags": [ + "str" # Optional. A set of arbitrary tags to organize your vector + database. + ] + } + + # response body for status code(s): 201 + response == { + "vector_db": { + "config": { + "default_quantization": "str", # Optional. Default vector + compression for new collections: rq, pq, bq, or sq. Empty means platform + default (rq). + "enable_auto_schema": bool, # Optional. VectorDBConfig holds + optional, advanced cluster settings. + "weaviate_version": "str" # Optional. The Vector Database + version running on the cluster. + }, + "created_at": "2020-02-20 00:00:00", # Optional. VectorDB represents + a provisioned vector database instance. + "endpoints": { + "grpc": "str", # Optional. Endpoint for gRPC connections + (e.g. "my-db-tor1-a1b2c3d4-grpc.weaviate.ondigitalocean.com:443"). + "http": "str" # Optional. Endpoint for HTTPS connections + (e.g. "https://my-db-tor1-a1b2c3d4.weaviate.ondigitalocean.com"). + }, + "forked_from_id": "str", # Optional. ID of the vector database this + instance was forked from. Empty when the instance was created directly via + CreateVectorDB. Read-only and set by the platform at fork time; never + modifiable through UpdateVectorDB. + "id": "str", # Optional. VectorDB represents a provisioned vector + database instance. + "last_restore_id": "str", # Optional. Backup_id of the most recent + restore initiated against this instance. Empty if no restore has ever been + triggered. Lets callers recover the identifier of an in-flight or + last-completed restore without having to retain the RestoreBackupResponse + themselves. Use it with GetRestoreStatus to fetch the live status. + "name": "str", # Optional. VectorDB represents a provisioned vector + database instance. + "owner_uuid": "str", # Optional. VectorDB represents a provisioned + vector database instance. + "project_id": "str", # Optional. Project this database belongs to. + "region": "str", # Optional. VectorDB represents a provisioned + vector database instance. + "size": "str", # Optional. Resource tier: small, medium, or large. + "status": "str", # Optional. Lifecycle state: pending, creating, + active, errored, or deleting. + "tags": [ + "str" # Optional. VectorDB represents a provisioned vector + database instance. + ], + "updated_at": "2020-02-20 00:00:00" # Optional. VectorDB represents + a provisioned vector database instance. + } + } + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + lambda response: ClientAuthenticationError(response=response), + ), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop( + "content_type", _headers.pop("Content-Type", None) + ) + cls: ClsType[JSON] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + if body is not None: + _json = body + else: + _json = None + + _request = build_vector_databases_create_request( + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [201, 404]: + if _stream: + response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + if response.status_code == 201: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 404: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + @distributed_trace + def get(self, id: str, **kwargs: Any) -> JSON: + # pylint: disable=line-too-long + """Retrieve an Existing Vector Database. + + To show information about an existing vector database, send a GET request to + ``/v2/vector-databases/{id}``. The response body contains a JSON object with a ``vector_db`` + key holding the standard vector database attributes, including an embedded ``endpoints`` object + with the connection information needed to access the database. + + :param id: ID of the vector database. Required. + :type id: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "vector_db": { + "config": { + "default_quantization": "str", # Optional. Default vector + compression for new collections: rq, pq, bq, or sq. Empty means platform + default (rq). + "enable_auto_schema": bool, # Optional. VectorDBConfig holds + optional, advanced cluster settings. + "weaviate_version": "str" # Optional. The Vector Database + version running on the cluster. + }, + "created_at": "2020-02-20 00:00:00", # Optional. VectorDB represents + a provisioned vector database instance. + "endpoints": { + "grpc": "str", # Optional. Endpoint for gRPC connections + (e.g. "my-db-tor1-a1b2c3d4-grpc.weaviate.ondigitalocean.com:443"). + "http": "str" # Optional. Endpoint for HTTPS connections + (e.g. "https://my-db-tor1-a1b2c3d4.weaviate.ondigitalocean.com"). + }, + "forked_from_id": "str", # Optional. ID of the vector database this + instance was forked from. Empty when the instance was created directly via + CreateVectorDB. Read-only and set by the platform at fork time; never + modifiable through UpdateVectorDB. + "id": "str", # Optional. VectorDB represents a provisioned vector + database instance. + "last_restore_id": "str", # Optional. Backup_id of the most recent + restore initiated against this instance. Empty if no restore has ever been + triggered. Lets callers recover the identifier of an in-flight or + last-completed restore without having to retain the RestoreBackupResponse + themselves. Use it with GetRestoreStatus to fetch the live status. + "name": "str", # Optional. VectorDB represents a provisioned vector + database instance. + "owner_uuid": "str", # Optional. VectorDB represents a provisioned + vector database instance. + "project_id": "str", # Optional. Project this database belongs to. + "region": "str", # Optional. VectorDB represents a provisioned + vector database instance. + "size": "str", # Optional. Resource tier: small, medium, or large. + "status": "str", # Optional. Lifecycle state: pending, creating, + active, errored, or deleting. + "tags": [ + "str" # Optional. VectorDB represents a provisioned vector + database instance. + ], + "updated_at": "2020-02-20 00:00:00" # Optional. VectorDB represents + a provisioned vector database instance. + } + } + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + lambda response: ClientAuthenticationError(response=response), + ), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[JSON] = kwargs.pop("cls", None) + + _request = build_vector_databases_get_request( + id=id, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + if _stream: + response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + if response.status_code == 200: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 404: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + @overload + def update( + self, + id: str, + body: Optional[JSON] = None, + *, + content_type: str = "application/json", + **kwargs: Any, + ) -> JSON: + # pylint: disable=line-too-long + """Update a Vector Database. + + To update an existing vector database, send a PUT request to ``/v2/vector-databases/{id}``. The + response body contains a JSON object with a ``vector_db`` key holding the updated vector + database. + + :param id: ID of the vector database. Required. + :type id: str + :param body: Default value is None. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "config": { + "default_quantization": "str", # Optional. Default vector + compression for new collections: rq, pq, bq, or sq. Empty means platform + default (rq). + "enable_auto_schema": bool, # Optional. VectorDBConfig holds + optional, advanced cluster settings. + "weaviate_version": "str" # Optional. The Vector Database version + running on the cluster. + }, + "id": "str", # Optional. ID of the vector database. + "project_id": "str" # Optional. Optional. New project UUID to assign the + database to. + } + + # response body for status code(s): 200 + response == { + "vector_db": { + "config": { + "default_quantization": "str", # Optional. Default vector + compression for new collections: rq, pq, bq, or sq. Empty means platform + default (rq). + "enable_auto_schema": bool, # Optional. VectorDBConfig holds + optional, advanced cluster settings. + "weaviate_version": "str" # Optional. The Vector Database + version running on the cluster. + }, + "created_at": "2020-02-20 00:00:00", # Optional. VectorDB represents + a provisioned vector database instance. + "endpoints": { + "grpc": "str", # Optional. Endpoint for gRPC connections + (e.g. "my-db-tor1-a1b2c3d4-grpc.weaviate.ondigitalocean.com:443"). + "http": "str" # Optional. Endpoint for HTTPS connections + (e.g. "https://my-db-tor1-a1b2c3d4.weaviate.ondigitalocean.com"). + }, + "forked_from_id": "str", # Optional. ID of the vector database this + instance was forked from. Empty when the instance was created directly via + CreateVectorDB. Read-only and set by the platform at fork time; never + modifiable through UpdateVectorDB. + "id": "str", # Optional. VectorDB represents a provisioned vector + database instance. + "last_restore_id": "str", # Optional. Backup_id of the most recent + restore initiated against this instance. Empty if no restore has ever been + triggered. Lets callers recover the identifier of an in-flight or + last-completed restore without having to retain the RestoreBackupResponse + themselves. Use it with GetRestoreStatus to fetch the live status. + "name": "str", # Optional. VectorDB represents a provisioned vector + database instance. + "owner_uuid": "str", # Optional. VectorDB represents a provisioned + vector database instance. + "project_id": "str", # Optional. Project this database belongs to. + "region": "str", # Optional. VectorDB represents a provisioned + vector database instance. + "size": "str", # Optional. Resource tier: small, medium, or large. + "status": "str", # Optional. Lifecycle state: pending, creating, + active, errored, or deleting. + "tags": [ + "str" # Optional. VectorDB represents a provisioned vector + database instance. + ], + "updated_at": "2020-02-20 00:00:00" # Optional. VectorDB represents + a provisioned vector database instance. + } + } + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + + @overload + def update( + self, + id: str, + body: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any, + ) -> JSON: + # pylint: disable=line-too-long + """Update a Vector Database. + + To update an existing vector database, send a PUT request to ``/v2/vector-databases/{id}``. The + response body contains a JSON object with a ``vector_db`` key holding the updated vector + database. + + :param id: ID of the vector database. Required. + :type id: str + :param body: Default value is None. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "vector_db": { + "config": { + "default_quantization": "str", # Optional. Default vector + compression for new collections: rq, pq, bq, or sq. Empty means platform + default (rq). + "enable_auto_schema": bool, # Optional. VectorDBConfig holds + optional, advanced cluster settings. + "weaviate_version": "str" # Optional. The Vector Database + version running on the cluster. + }, + "created_at": "2020-02-20 00:00:00", # Optional. VectorDB represents + a provisioned vector database instance. + "endpoints": { + "grpc": "str", # Optional. Endpoint for gRPC connections + (e.g. "my-db-tor1-a1b2c3d4-grpc.weaviate.ondigitalocean.com:443"). + "http": "str" # Optional. Endpoint for HTTPS connections + (e.g. "https://my-db-tor1-a1b2c3d4.weaviate.ondigitalocean.com"). + }, + "forked_from_id": "str", # Optional. ID of the vector database this + instance was forked from. Empty when the instance was created directly via + CreateVectorDB. Read-only and set by the platform at fork time; never + modifiable through UpdateVectorDB. + "id": "str", # Optional. VectorDB represents a provisioned vector + database instance. + "last_restore_id": "str", # Optional. Backup_id of the most recent + restore initiated against this instance. Empty if no restore has ever been + triggered. Lets callers recover the identifier of an in-flight or + last-completed restore without having to retain the RestoreBackupResponse + themselves. Use it with GetRestoreStatus to fetch the live status. + "name": "str", # Optional. VectorDB represents a provisioned vector + database instance. + "owner_uuid": "str", # Optional. VectorDB represents a provisioned + vector database instance. + "project_id": "str", # Optional. Project this database belongs to. + "region": "str", # Optional. VectorDB represents a provisioned + vector database instance. + "size": "str", # Optional. Resource tier: small, medium, or large. + "status": "str", # Optional. Lifecycle state: pending, creating, + active, errored, or deleting. + "tags": [ + "str" # Optional. VectorDB represents a provisioned vector + database instance. + ], + "updated_at": "2020-02-20 00:00:00" # Optional. VectorDB represents + a provisioned vector database instance. + } + } + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + + @distributed_trace + def update( + self, id: str, body: Optional[Union[JSON, IO[bytes]]] = None, **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Update a Vector Database. + + To update an existing vector database, send a PUT request to ``/v2/vector-databases/{id}``. The + response body contains a JSON object with a ``vector_db`` key holding the updated vector + database. + + :param id: ID of the vector database. Required. + :type id: str + :param body: Is either a JSON type or a IO[bytes] type. Default value is None. + :type body: JSON or IO[bytes] + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "config": { + "default_quantization": "str", # Optional. Default vector + compression for new collections: rq, pq, bq, or sq. Empty means platform + default (rq). + "enable_auto_schema": bool, # Optional. VectorDBConfig holds + optional, advanced cluster settings. + "weaviate_version": "str" # Optional. The Vector Database version + running on the cluster. + }, + "id": "str", # Optional. ID of the vector database. + "project_id": "str" # Optional. Optional. New project UUID to assign the + database to. + } + + # response body for status code(s): 200 + response == { + "vector_db": { + "config": { + "default_quantization": "str", # Optional. Default vector + compression for new collections: rq, pq, bq, or sq. Empty means platform + default (rq). + "enable_auto_schema": bool, # Optional. VectorDBConfig holds + optional, advanced cluster settings. + "weaviate_version": "str" # Optional. The Vector Database + version running on the cluster. + }, + "created_at": "2020-02-20 00:00:00", # Optional. VectorDB represents + a provisioned vector database instance. + "endpoints": { + "grpc": "str", # Optional. Endpoint for gRPC connections + (e.g. "my-db-tor1-a1b2c3d4-grpc.weaviate.ondigitalocean.com:443"). + "http": "str" # Optional. Endpoint for HTTPS connections + (e.g. "https://my-db-tor1-a1b2c3d4.weaviate.ondigitalocean.com"). + }, + "forked_from_id": "str", # Optional. ID of the vector database this + instance was forked from. Empty when the instance was created directly via + CreateVectorDB. Read-only and set by the platform at fork time; never + modifiable through UpdateVectorDB. + "id": "str", # Optional. VectorDB represents a provisioned vector + database instance. + "last_restore_id": "str", # Optional. Backup_id of the most recent + restore initiated against this instance. Empty if no restore has ever been + triggered. Lets callers recover the identifier of an in-flight or + last-completed restore without having to retain the RestoreBackupResponse + themselves. Use it with GetRestoreStatus to fetch the live status. + "name": "str", # Optional. VectorDB represents a provisioned vector + database instance. + "owner_uuid": "str", # Optional. VectorDB represents a provisioned + vector database instance. + "project_id": "str", # Optional. Project this database belongs to. + "region": "str", # Optional. VectorDB represents a provisioned + vector database instance. + "size": "str", # Optional. Resource tier: small, medium, or large. + "status": "str", # Optional. Lifecycle state: pending, creating, + active, errored, or deleting. + "tags": [ + "str" # Optional. VectorDB represents a provisioned vector + database instance. + ], + "updated_at": "2020-02-20 00:00:00" # Optional. VectorDB represents + a provisioned vector database instance. + } + } + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + lambda response: ClientAuthenticationError(response=response), + ), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop( + "content_type", _headers.pop("Content-Type", None) + ) + cls: ClsType[JSON] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + if body is not None: + _json = body + else: + _json = None + + _request = build_vector_databases_update_request( + id=id, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + if _stream: + response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + if response.status_code == 200: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 404: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + @distributed_trace + def delete(self, id: str, **kwargs: Any) -> Optional[JSON]: + # pylint: disable=line-too-long + """Delete a Vector Database. + + To delete a vector database, send a DELETE request to ``/v2/vector-databases/{id}``. Deleting a + vector database is irreversible and destroys the underlying instance along with its data. + + :param id: ID of the vector database. Required. + :type id: str + :return: JSON object or None + :rtype: JSON or None + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + lambda response: ClientAuthenticationError(response=response), + ), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[Optional[JSON]] = kwargs.pop("cls", None) + + _request = build_vector_databases_delete_request( + id=id, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [204, 404]: + if _stream: + response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + deserialized = None + response_headers = {} + if response.status_code == 204: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.status_code == 404: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list_backups(self, id: str, **kwargs: Any) -> JSON: + # pylint: disable=line-too-long + """List Backups for a Vector Database. + + To list the available backups for a vector database, send a GET request to + ``/v2/vector-databases/{id}/backups``. Only backups with a status of ``SUCCESS`` are returned. + + :param id: Required. ID of the vector database. Required. + :type id: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "backups": [ + { + "backup_id": "str", # Optional. Unique identifier for the + backup (e.g., "vectordb-{uuid}-20240101-120000"). + "completed_at": "2020-02-20 00:00:00", # Optional. Timestamp + when the backup process completed. + "started_at": "2020-02-20 00:00:00", # Optional. Timestamp + when the backup process started. + "status": "str" # Optional. Status of the backup: SUCCESS. + } + ] + } + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + lambda response: ClientAuthenticationError(response=response), + ), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[JSON] = kwargs.pop("cls", None) + + _request = build_vector_databases_list_backups_request( + id=id, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + if _stream: + response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + if response.status_code == 200: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 404: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + @distributed_trace + def get_restore_status(self, id: str, backup_id: str, **kwargs: Any) -> JSON: + # pylint: disable=line-too-long + """Retrieve the Status of a Restore. + + To check the status of a restore operation, send a GET request to + ``/v2/vector-databases/{id}/backups/{backup_id}/restore``. The response body contains the + current status of the restore. + + :param id: Required. ID of the vector database. Required. + :type id: str + :param backup_id: Required. ID of the backup being restored. Required. + :type backup_id: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "backup_id": "str", # Optional. The backup ID being restored. + "error": "str", # Optional. Error message if the restore failed. + "status": "str" # Optional. Current status: STARTED, TRANSFERRING, + TRANSFERRED, FINALIZING, SUCCESS, FAILED, CANCELLING, CANCELED. + } + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + lambda response: ClientAuthenticationError(response=response), + ), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[JSON] = kwargs.pop("cls", None) + + _request = build_vector_databases_get_restore_status_request( + id=id, + backup_id=backup_id, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + if _stream: + response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + if response.status_code == 200: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 404: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + @overload + def post_restore_backup( + self, + id: str, + backup_id: str, + body: Optional[JSON] = None, + *, + content_type: str = "application/json", + **kwargs: Any, + ) -> JSON: + # pylint: disable=line-too-long + """Restore a Vector Database from a Backup. + + To restore a vector database from a backup, send a POST request to + ``/v2/vector-databases/{id}/backups/{backup_id}/restore``. The restore runs asynchronously; use + the restore-status endpoint to monitor its progress. + + :param id: Required. ID of the vector database. Required. + :type id: str + :param backup_id: Required. ID of the backup to restore from. Required. + :type backup_id: str + :param body: Default value is None. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "backup_id": "str", # Optional. Required. ID of the backup to restore from. + "id": "str" # Optional. Required. ID of the vector database. + } + + # response body for status code(s): 200 + response == { + "backup_id": "str", # Optional. The backup ID being restored. + "status": "str" # Optional. Initial status of the restore operation (e.g., + "STARTED"). + } + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + + @overload + def post_restore_backup( + self, + id: str, + backup_id: str, + body: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any, + ) -> JSON: + # pylint: disable=line-too-long + """Restore a Vector Database from a Backup. + + To restore a vector database from a backup, send a POST request to + ``/v2/vector-databases/{id}/backups/{backup_id}/restore``. The restore runs asynchronously; use + the restore-status endpoint to monitor its progress. + + :param id: Required. ID of the vector database. Required. + :type id: str + :param backup_id: Required. ID of the backup to restore from. Required. + :type backup_id: str + :param body: Default value is None. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "backup_id": "str", # Optional. The backup ID being restored. + "status": "str" # Optional. Initial status of the restore operation (e.g., + "STARTED"). + } + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + + @distributed_trace + def post_restore_backup( + self, + id: str, + backup_id: str, + body: Optional[Union[JSON, IO[bytes]]] = None, + **kwargs: Any, + ) -> JSON: + # pylint: disable=line-too-long + """Restore a Vector Database from a Backup. + + To restore a vector database from a backup, send a POST request to + ``/v2/vector-databases/{id}/backups/{backup_id}/restore``. The restore runs asynchronously; use + the restore-status endpoint to monitor its progress. + + :param id: Required. ID of the vector database. Required. + :type id: str + :param backup_id: Required. ID of the backup to restore from. Required. + :type backup_id: str + :param body: Is either a JSON type or a IO[bytes] type. Default value is None. + :type body: JSON or IO[bytes] + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "backup_id": "str", # Optional. Required. ID of the backup to restore from. + "id": "str" # Optional. Required. ID of the vector database. + } + + # response body for status code(s): 200 + response == { + "backup_id": "str", # Optional. The backup ID being restored. + "status": "str" # Optional. Initial status of the restore operation (e.g., + "STARTED"). + } + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + lambda response: ClientAuthenticationError(response=response), + ), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop( + "content_type", _headers.pop("Content-Type", None) + ) + cls: ClsType[JSON] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + if body is not None: + _json = body + else: + _json = None + + _request = build_vector_databases_post_restore_backup_request( + id=id, + backup_id=backup_id, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + if _stream: + response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + if response.status_code == 200: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 404: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + @distributed_trace + def get_credentials(self, id: str, **kwargs: Any) -> JSON: + # pylint: disable=line-too-long + """Retrieve Admin Credentials for a Vector Database. + + To retrieve the admin credentials for a vector database, send a GET request to + ``/v2/vector-databases/{id}/credentials``. The response body contains the ``user_id`` and + ``api_token`` for the admin user provisioned on the cluster. + + :param id: ID of the vector database. Required. + :type id: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "api_token": "str", # Optional. API token for that user. + "user_id": "str" # Optional. Database user id from the cluster secret + (opaque; matches what was provisioned). + } + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + lambda response: ClientAuthenticationError(response=response), + ), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[JSON] = kwargs.pop("cls", None) + + _request = build_vector_databases_get_credentials_request( + id=id, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + if _stream: + response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + if response.status_code == 200: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 404: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + @overload + def post_resize( + self, + id: str, + body: Optional[JSON] = None, + *, + content_type: str = "application/json", + **kwargs: Any, + ) -> JSON: + # pylint: disable=line-too-long + """Resize a Vector Database. + + To resize a vector database, send a POST request to ``/v2/vector-databases/{id}/resize``. This + changes the database's resource tier. The response body contains a JSON object with the updated + vector database. + + :param id: Required. ID of the vector database to resize. Required. + :type id: str + :param body: Default value is None. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "id": "str", # Optional. Required. ID of the vector database to resize. + "size": "str" # Optional. Required. Target resource tier: small, medium, or + large. + } + + # response body for status code(s): 200 + response == { + "vector_db": { + "config": { + "default_quantization": "str", # Optional. Default vector + compression for new collections: rq, pq, bq, or sq. Empty means platform + default (rq). + "enable_auto_schema": bool, # Optional. VectorDBConfig holds + optional, advanced cluster settings. + "weaviate_version": "str" # Optional. The Vector Database + version running on the cluster. + }, + "created_at": "2020-02-20 00:00:00", # Optional. VectorDB represents + a provisioned vector database instance. + "endpoints": { + "grpc": "str", # Optional. Endpoint for gRPC connections + (e.g. "my-db-tor1-a1b2c3d4-grpc.weaviate.ondigitalocean.com:443"). + "http": "str" # Optional. Endpoint for HTTPS connections + (e.g. "https://my-db-tor1-a1b2c3d4.weaviate.ondigitalocean.com"). + }, + "forked_from_id": "str", # Optional. ID of the vector database this + instance was forked from. Empty when the instance was created directly via + CreateVectorDB. Read-only and set by the platform at fork time; never + modifiable through UpdateVectorDB. + "id": "str", # Optional. VectorDB represents a provisioned vector + database instance. + "last_restore_id": "str", # Optional. Backup_id of the most recent + restore initiated against this instance. Empty if no restore has ever been + triggered. Lets callers recover the identifier of an in-flight or + last-completed restore without having to retain the RestoreBackupResponse + themselves. Use it with GetRestoreStatus to fetch the live status. + "name": "str", # Optional. VectorDB represents a provisioned vector + database instance. + "owner_uuid": "str", # Optional. VectorDB represents a provisioned + vector database instance. + "project_id": "str", # Optional. Project this database belongs to. + "region": "str", # Optional. VectorDB represents a provisioned + vector database instance. + "size": "str", # Optional. Resource tier: small, medium, or large. + "status": "str", # Optional. Lifecycle state: pending, creating, + active, errored, or deleting. + "tags": [ + "str" # Optional. VectorDB represents a provisioned vector + database instance. + ], + "updated_at": "2020-02-20 00:00:00" # Optional. VectorDB represents + a provisioned vector database instance. + } + } + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + + @overload + def post_resize( + self, + id: str, + body: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any, + ) -> JSON: + # pylint: disable=line-too-long + """Resize a Vector Database. + + To resize a vector database, send a POST request to ``/v2/vector-databases/{id}/resize``. This + changes the database's resource tier. The response body contains a JSON object with the updated + vector database. + + :param id: Required. ID of the vector database to resize. Required. + :type id: str + :param body: Default value is None. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "vector_db": { + "config": { + "default_quantization": "str", # Optional. Default vector + compression for new collections: rq, pq, bq, or sq. Empty means platform + default (rq). + "enable_auto_schema": bool, # Optional. VectorDBConfig holds + optional, advanced cluster settings. + "weaviate_version": "str" # Optional. The Vector Database + version running on the cluster. + }, + "created_at": "2020-02-20 00:00:00", # Optional. VectorDB represents + a provisioned vector database instance. + "endpoints": { + "grpc": "str", # Optional. Endpoint for gRPC connections + (e.g. "my-db-tor1-a1b2c3d4-grpc.weaviate.ondigitalocean.com:443"). + "http": "str" # Optional. Endpoint for HTTPS connections + (e.g. "https://my-db-tor1-a1b2c3d4.weaviate.ondigitalocean.com"). + }, + "forked_from_id": "str", # Optional. ID of the vector database this + instance was forked from. Empty when the instance was created directly via + CreateVectorDB. Read-only and set by the platform at fork time; never + modifiable through UpdateVectorDB. + "id": "str", # Optional. VectorDB represents a provisioned vector + database instance. + "last_restore_id": "str", # Optional. Backup_id of the most recent + restore initiated against this instance. Empty if no restore has ever been + triggered. Lets callers recover the identifier of an in-flight or + last-completed restore without having to retain the RestoreBackupResponse + themselves. Use it with GetRestoreStatus to fetch the live status. + "name": "str", # Optional. VectorDB represents a provisioned vector + database instance. + "owner_uuid": "str", # Optional. VectorDB represents a provisioned + vector database instance. + "project_id": "str", # Optional. Project this database belongs to. + "region": "str", # Optional. VectorDB represents a provisioned + vector database instance. + "size": "str", # Optional. Resource tier: small, medium, or large. + "status": "str", # Optional. Lifecycle state: pending, creating, + active, errored, or deleting. + "tags": [ + "str" # Optional. VectorDB represents a provisioned vector + database instance. + ], + "updated_at": "2020-02-20 00:00:00" # Optional. VectorDB represents + a provisioned vector database instance. + } + } + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + + @distributed_trace + def post_resize( + self, id: str, body: Optional[Union[JSON, IO[bytes]]] = None, **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Resize a Vector Database. + + To resize a vector database, send a POST request to ``/v2/vector-databases/{id}/resize``. This + changes the database's resource tier. The response body contains a JSON object with the updated + vector database. + + :param id: Required. ID of the vector database to resize. Required. + :type id: str + :param body: Is either a JSON type or a IO[bytes] type. Default value is None. + :type body: JSON or IO[bytes] + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "id": "str", # Optional. Required. ID of the vector database to resize. + "size": "str" # Optional. Required. Target resource tier: small, medium, or + large. + } + + # response body for status code(s): 200 + response == { + "vector_db": { + "config": { + "default_quantization": "str", # Optional. Default vector + compression for new collections: rq, pq, bq, or sq. Empty means platform + default (rq). + "enable_auto_schema": bool, # Optional. VectorDBConfig holds + optional, advanced cluster settings. + "weaviate_version": "str" # Optional. The Vector Database + version running on the cluster. + }, + "created_at": "2020-02-20 00:00:00", # Optional. VectorDB represents + a provisioned vector database instance. + "endpoints": { + "grpc": "str", # Optional. Endpoint for gRPC connections + (e.g. "my-db-tor1-a1b2c3d4-grpc.weaviate.ondigitalocean.com:443"). + "http": "str" # Optional. Endpoint for HTTPS connections + (e.g. "https://my-db-tor1-a1b2c3d4.weaviate.ondigitalocean.com"). + }, + "forked_from_id": "str", # Optional. ID of the vector database this + instance was forked from. Empty when the instance was created directly via + CreateVectorDB. Read-only and set by the platform at fork time; never + modifiable through UpdateVectorDB. + "id": "str", # Optional. VectorDB represents a provisioned vector + database instance. + "last_restore_id": "str", # Optional. Backup_id of the most recent + restore initiated against this instance. Empty if no restore has ever been + triggered. Lets callers recover the identifier of an in-flight or + last-completed restore without having to retain the RestoreBackupResponse + themselves. Use it with GetRestoreStatus to fetch the live status. + "name": "str", # Optional. VectorDB represents a provisioned vector + database instance. + "owner_uuid": "str", # Optional. VectorDB represents a provisioned + vector database instance. + "project_id": "str", # Optional. Project this database belongs to. + "region": "str", # Optional. VectorDB represents a provisioned + vector database instance. + "size": "str", # Optional. Resource tier: small, medium, or large. + "status": "str", # Optional. Lifecycle state: pending, creating, + active, errored, or deleting. + "tags": [ + "str" # Optional. VectorDB represents a provisioned vector + database instance. + ], + "updated_at": "2020-02-20 00:00:00" # Optional. VectorDB represents + a provisioned vector database instance. + } + } + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + lambda response: ClientAuthenticationError(response=response), + ), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop( + "content_type", _headers.pop("Content-Type", None) + ) + cls: ClsType[JSON] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + if body is not None: + _json = body + else: + _json = None + + _request = build_vector_databases_post_resize_request( + id=id, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + if _stream: + response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + if response.status_code == 200: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 404: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + @overload + def update_tags( + self, + id: str, + body: Optional[JSON] = None, + *, + content_type: str = "application/json", + **kwargs: Any, + ) -> JSON: + # pylint: disable=line-too-long + """Update Tags on a Vector Database. + + To update the tags on a vector database, send a PUT request to + ``/v2/vector-databases/{id}/tags``. The supplied set of tags replaces the database's existing + tags. + + :param id: Required. ID of the vector database to update tags for. Required. + :type id: str + :param body: Default value is None. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "id": "str", # Optional. Required. ID of the vector database to update tags + for. + "tags": [ + "str" # Optional. Tags to set on the vector database. Replaces all + existing tags. + ] + } + + # response body for status code(s): 200 + response == { + "vector_db": { + "config": { + "default_quantization": "str", # Optional. Default vector + compression for new collections: rq, pq, bq, or sq. Empty means platform + default (rq). + "enable_auto_schema": bool, # Optional. VectorDBConfig holds + optional, advanced cluster settings. + "weaviate_version": "str" # Optional. The Vector Database + version running on the cluster. + }, + "created_at": "2020-02-20 00:00:00", # Optional. VectorDB represents + a provisioned vector database instance. + "endpoints": { + "grpc": "str", # Optional. Endpoint for gRPC connections + (e.g. "my-db-tor1-a1b2c3d4-grpc.weaviate.ondigitalocean.com:443"). + "http": "str" # Optional. Endpoint for HTTPS connections + (e.g. "https://my-db-tor1-a1b2c3d4.weaviate.ondigitalocean.com"). + }, + "forked_from_id": "str", # Optional. ID of the vector database this + instance was forked from. Empty when the instance was created directly via + CreateVectorDB. Read-only and set by the platform at fork time; never + modifiable through UpdateVectorDB. + "id": "str", # Optional. VectorDB represents a provisioned vector + database instance. + "last_restore_id": "str", # Optional. Backup_id of the most recent + restore initiated against this instance. Empty if no restore has ever been + triggered. Lets callers recover the identifier of an in-flight or + last-completed restore without having to retain the RestoreBackupResponse + themselves. Use it with GetRestoreStatus to fetch the live status. + "name": "str", # Optional. VectorDB represents a provisioned vector + database instance. + "owner_uuid": "str", # Optional. VectorDB represents a provisioned + vector database instance. + "project_id": "str", # Optional. Project this database belongs to. + "region": "str", # Optional. VectorDB represents a provisioned + vector database instance. + "size": "str", # Optional. Resource tier: small, medium, or large. + "status": "str", # Optional. Lifecycle state: pending, creating, + active, errored, or deleting. + "tags": [ + "str" # Optional. VectorDB represents a provisioned vector + database instance. + ], + "updated_at": "2020-02-20 00:00:00" # Optional. VectorDB represents + a provisioned vector database instance. + } + } + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + + @overload + def update_tags( + self, + id: str, + body: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any, + ) -> JSON: + # pylint: disable=line-too-long + """Update Tags on a Vector Database. + + To update the tags on a vector database, send a PUT request to + ``/v2/vector-databases/{id}/tags``. The supplied set of tags replaces the database's existing + tags. + + :param id: Required. ID of the vector database to update tags for. Required. + :type id: str + :param body: Default value is None. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response == { + "vector_db": { + "config": { + "default_quantization": "str", # Optional. Default vector + compression for new collections: rq, pq, bq, or sq. Empty means platform + default (rq). + "enable_auto_schema": bool, # Optional. VectorDBConfig holds + optional, advanced cluster settings. + "weaviate_version": "str" # Optional. The Vector Database + version running on the cluster. + }, + "created_at": "2020-02-20 00:00:00", # Optional. VectorDB represents + a provisioned vector database instance. + "endpoints": { + "grpc": "str", # Optional. Endpoint for gRPC connections + (e.g. "my-db-tor1-a1b2c3d4-grpc.weaviate.ondigitalocean.com:443"). + "http": "str" # Optional. Endpoint for HTTPS connections + (e.g. "https://my-db-tor1-a1b2c3d4.weaviate.ondigitalocean.com"). + }, + "forked_from_id": "str", # Optional. ID of the vector database this + instance was forked from. Empty when the instance was created directly via + CreateVectorDB. Read-only and set by the platform at fork time; never + modifiable through UpdateVectorDB. + "id": "str", # Optional. VectorDB represents a provisioned vector + database instance. + "last_restore_id": "str", # Optional. Backup_id of the most recent + restore initiated against this instance. Empty if no restore has ever been + triggered. Lets callers recover the identifier of an in-flight or + last-completed restore without having to retain the RestoreBackupResponse + themselves. Use it with GetRestoreStatus to fetch the live status. + "name": "str", # Optional. VectorDB represents a provisioned vector + database instance. + "owner_uuid": "str", # Optional. VectorDB represents a provisioned + vector database instance. + "project_id": "str", # Optional. Project this database belongs to. + "region": "str", # Optional. VectorDB represents a provisioned + vector database instance. + "size": "str", # Optional. Resource tier: small, medium, or large. + "status": "str", # Optional. Lifecycle state: pending, creating, + active, errored, or deleting. + "tags": [ + "str" # Optional. VectorDB represents a provisioned vector + database instance. + ], + "updated_at": "2020-02-20 00:00:00" # Optional. VectorDB represents + a provisioned vector database instance. + } + } + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + + @distributed_trace + def update_tags( + self, id: str, body: Optional[Union[JSON, IO[bytes]]] = None, **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long + """Update Tags on a Vector Database. + + To update the tags on a vector database, send a PUT request to + ``/v2/vector-databases/{id}/tags``. The supplied set of tags replaces the database's existing + tags. + + :param id: Required. ID of the vector database to update tags for. Required. + :type id: str + :param body: Is either a JSON type or a IO[bytes] type. Default value is None. + :type body: JSON or IO[bytes] + :return: JSON object + :rtype: JSON + :raises ~azure.core.exceptions.HttpResponseError: + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + body = { + "id": "str", # Optional. Required. ID of the vector database to update tags + for. + "tags": [ + "str" # Optional. Tags to set on the vector database. Replaces all + existing tags. + ] + } + + # response body for status code(s): 200 + response == { + "vector_db": { + "config": { + "default_quantization": "str", # Optional. Default vector + compression for new collections: rq, pq, bq, or sq. Empty means platform + default (rq). + "enable_auto_schema": bool, # Optional. VectorDBConfig holds + optional, advanced cluster settings. + "weaviate_version": "str" # Optional. The Vector Database + version running on the cluster. + }, + "created_at": "2020-02-20 00:00:00", # Optional. VectorDB represents + a provisioned vector database instance. + "endpoints": { + "grpc": "str", # Optional. Endpoint for gRPC connections + (e.g. "my-db-tor1-a1b2c3d4-grpc.weaviate.ondigitalocean.com:443"). + "http": "str" # Optional. Endpoint for HTTPS connections + (e.g. "https://my-db-tor1-a1b2c3d4.weaviate.ondigitalocean.com"). + }, + "forked_from_id": "str", # Optional. ID of the vector database this + instance was forked from. Empty when the instance was created directly via + CreateVectorDB. Read-only and set by the platform at fork time; never + modifiable through UpdateVectorDB. + "id": "str", # Optional. VectorDB represents a provisioned vector + database instance. + "last_restore_id": "str", # Optional. Backup_id of the most recent + restore initiated against this instance. Empty if no restore has ever been + triggered. Lets callers recover the identifier of an in-flight or + last-completed restore without having to retain the RestoreBackupResponse + themselves. Use it with GetRestoreStatus to fetch the live status. + "name": "str", # Optional. VectorDB represents a provisioned vector + database instance. + "owner_uuid": "str", # Optional. VectorDB represents a provisioned + vector database instance. + "project_id": "str", # Optional. Project this database belongs to. + "region": "str", # Optional. VectorDB represents a provisioned + vector database instance. + "size": "str", # Optional. Resource tier: small, medium, or large. + "status": "str", # Optional. Lifecycle state: pending, creating, + active, errored, or deleting. + "tags": [ + "str" # Optional. VectorDB represents a provisioned vector + database instance. + ], + "updated_at": "2020-02-20 00:00:00" # Optional. VectorDB represents + a provisioned vector database instance. + } + } + # response body for status code(s): 404 + response == { + "id": "str", # A short identifier corresponding to the HTTP status code + returned. For example, the ID for a response returning a 404 status code would + be "not_found.". Required. + "message": "str", # A message providing additional information about the + error, including details to help resolve it when possible. Required. + "request_id": "str" # Optional. Optionally, some endpoints may include a + request ID that should be provided when reporting bugs or opening support + tickets to help identify the issue. + } + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 401: cast( + Type[HttpResponseError], + lambda response: ClientAuthenticationError(response=response), + ), + 429: HttpResponseError, + 500: HttpResponseError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop( + "content_type", _headers.pop("Content-Type", None) + ) + cls: ClsType[JSON] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + if body is not None: + _json = body + else: + _json = None + + _request = build_vector_databases_update_tags_request( + id=id, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = ( + self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 404]: + if _stream: + response.read() # Load the body in memory and close the socket + map_error(status_code=response.status_code, response=response, error_map=error_map) # type: ignore + raise HttpResponseError(response=response) + + response_headers = {} + if response.status_code == 200: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 404: + response_headers["ratelimit-limit"] = self._deserialize( + "int", response.headers.get("ratelimit-limit") + ) + response_headers["ratelimit-remaining"] = self._deserialize( + "int", response.headers.get("ratelimit-remaining") + ) + response_headers["ratelimit-reset"] = self._deserialize( + "int", response.headers.get("ratelimit-reset") + ) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, cast(JSON, deserialized), response_headers) # type: ignore + + return cast(JSON, deserialized) # type: ignore + + class VolumesOperations: """ .. warning::