diff --git a/.stats.yml b/.stats.yml
index 0a0068803e8..ae473c1891a 100644
--- a/.stats.yml
+++ b/.stats.yml
@@ -1 +1 @@
-configured_endpoints: 1249
+configured_endpoints: 1259
diff --git a/api.md b/api.md
index 6736a9b06f1..08421013ea7 100644
--- a/api.md
+++ b/api.md
@@ -6021,9 +6021,24 @@ from cloudflare.types.vectorize import (
IndexInsert,
IndexQuery,
IndexUpsert,
+ IndexDeleteResponse,
+ IndexGetByIDsResponse,
)
```
+Methods:
+
+- client.vectorize.indexes.create(\*, account_id, \*\*params) -> Optional
+- client.vectorize.indexes.update(index_name, \*, account_id, \*\*params) -> Optional
+- client.vectorize.indexes.list(\*, account_id) -> SyncSinglePage[CreateIndex]
+- client.vectorize.indexes.delete(index_name, \*, account_id) -> IndexDeleteResponse
+- client.vectorize.indexes.delete_by_ids(index_name, \*, account_id, \*\*params) -> Optional
+- client.vectorize.indexes.get(index_name, \*, account_id) -> Optional
+- client.vectorize.indexes.get_by_ids(index_name, \*, account_id, \*\*params) -> object
+- client.vectorize.indexes.insert(index_name, \*, account_id, \*\*params) -> Optional
+- client.vectorize.indexes.query(index_name, \*, account_id, \*\*params) -> Optional
+- client.vectorize.indexes.upsert(index_name, \*, account_id, \*\*params) -> Optional
+
# URLScanner
Types:
diff --git a/src/cloudflare/_client.py b/src/cloudflare/_client.py
index 2f8e4431f73..a8d6e5dd25a 100644
--- a/src/cloudflare/_client.py
+++ b/src/cloudflare/_client.py
@@ -116,6 +116,7 @@ class Cloudflare(SyncAPIClient):
challenges: resources.Challenges
hyperdrive: resources.HyperdriveResource
rum: resources.RUM
+ vectorize: resources.Vectorize
url_scanner: resources.URLScanner
radar: resources.Radar
bot_management: resources.BotManagement
@@ -271,6 +272,7 @@ def __init__(
self.challenges = resources.Challenges(self)
self.hyperdrive = resources.HyperdriveResource(self)
self.rum = resources.RUM(self)
+ self.vectorize = resources.Vectorize(self)
self.url_scanner = resources.URLScanner(self)
self.radar = resources.Radar(self)
self.bot_management = resources.BotManagement(self)
@@ -529,6 +531,7 @@ class AsyncCloudflare(AsyncAPIClient):
challenges: resources.AsyncChallenges
hyperdrive: resources.AsyncHyperdriveResource
rum: resources.AsyncRUM
+ vectorize: resources.AsyncVectorize
url_scanner: resources.AsyncURLScanner
radar: resources.AsyncRadar
bot_management: resources.AsyncBotManagement
@@ -684,6 +687,7 @@ def __init__(
self.challenges = resources.AsyncChallenges(self)
self.hyperdrive = resources.AsyncHyperdriveResource(self)
self.rum = resources.AsyncRUM(self)
+ self.vectorize = resources.AsyncVectorize(self)
self.url_scanner = resources.AsyncURLScanner(self)
self.radar = resources.AsyncRadar(self)
self.bot_management = resources.AsyncBotManagement(self)
@@ -943,6 +947,7 @@ def __init__(self, client: Cloudflare) -> None:
self.challenges = resources.ChallengesWithRawResponse(client.challenges)
self.hyperdrive = resources.HyperdriveResourceWithRawResponse(client.hyperdrive)
self.rum = resources.RUMWithRawResponse(client.rum)
+ self.vectorize = resources.VectorizeWithRawResponse(client.vectorize)
self.url_scanner = resources.URLScannerWithRawResponse(client.url_scanner)
self.radar = resources.RadarWithRawResponse(client.radar)
self.bot_management = resources.BotManagementWithRawResponse(client.bot_management)
@@ -1033,6 +1038,7 @@ def __init__(self, client: AsyncCloudflare) -> None:
self.challenges = resources.AsyncChallengesWithRawResponse(client.challenges)
self.hyperdrive = resources.AsyncHyperdriveResourceWithRawResponse(client.hyperdrive)
self.rum = resources.AsyncRUMWithRawResponse(client.rum)
+ self.vectorize = resources.AsyncVectorizeWithRawResponse(client.vectorize)
self.url_scanner = resources.AsyncURLScannerWithRawResponse(client.url_scanner)
self.radar = resources.AsyncRadarWithRawResponse(client.radar)
self.bot_management = resources.AsyncBotManagementWithRawResponse(client.bot_management)
@@ -1123,6 +1129,7 @@ def __init__(self, client: Cloudflare) -> None:
self.challenges = resources.ChallengesWithStreamingResponse(client.challenges)
self.hyperdrive = resources.HyperdriveResourceWithStreamingResponse(client.hyperdrive)
self.rum = resources.RUMWithStreamingResponse(client.rum)
+ self.vectorize = resources.VectorizeWithStreamingResponse(client.vectorize)
self.url_scanner = resources.URLScannerWithStreamingResponse(client.url_scanner)
self.radar = resources.RadarWithStreamingResponse(client.radar)
self.bot_management = resources.BotManagementWithStreamingResponse(client.bot_management)
@@ -1219,6 +1226,7 @@ def __init__(self, client: AsyncCloudflare) -> None:
self.challenges = resources.AsyncChallengesWithStreamingResponse(client.challenges)
self.hyperdrive = resources.AsyncHyperdriveResourceWithStreamingResponse(client.hyperdrive)
self.rum = resources.AsyncRUMWithStreamingResponse(client.rum)
+ self.vectorize = resources.AsyncVectorizeWithStreamingResponse(client.vectorize)
self.url_scanner = resources.AsyncURLScannerWithStreamingResponse(client.url_scanner)
self.radar = resources.AsyncRadarWithStreamingResponse(client.radar)
self.bot_management = resources.AsyncBotManagementWithStreamingResponse(client.bot_management)
diff --git a/src/cloudflare/resources/__init__.py b/src/cloudflare/resources/__init__.py
index e097e9d3dc0..bc46849e478 100644
--- a/src/cloudflare/resources/__init__.py
+++ b/src/cloudflare/resources/__init__.py
@@ -320,6 +320,14 @@
RegistrarWithStreamingResponse,
AsyncRegistrarWithStreamingResponse,
)
+from .vectorize import (
+ Vectorize,
+ AsyncVectorize,
+ VectorizeWithRawResponse,
+ AsyncVectorizeWithRawResponse,
+ VectorizeWithStreamingResponse,
+ AsyncVectorizeWithStreamingResponse,
+)
from .addressing import (
Addressing,
AsyncAddressing,
@@ -1056,6 +1064,12 @@
"AsyncRUMWithRawResponse",
"RUMWithStreamingResponse",
"AsyncRUMWithStreamingResponse",
+ "Vectorize",
+ "AsyncVectorize",
+ "VectorizeWithRawResponse",
+ "AsyncVectorizeWithRawResponse",
+ "VectorizeWithStreamingResponse",
+ "AsyncVectorizeWithStreamingResponse",
"URLScanner",
"AsyncURLScanner",
"URLScannerWithRawResponse",
diff --git a/src/cloudflare/resources/vectorize/__init__.py b/src/cloudflare/resources/vectorize/__init__.py
new file mode 100644
index 00000000000..ded339e9554
--- /dev/null
+++ b/src/cloudflare/resources/vectorize/__init__.py
@@ -0,0 +1,33 @@
+# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+from .indexes import (
+ Indexes,
+ AsyncIndexes,
+ IndexesWithRawResponse,
+ AsyncIndexesWithRawResponse,
+ IndexesWithStreamingResponse,
+ AsyncIndexesWithStreamingResponse,
+)
+from .vectorize import (
+ Vectorize,
+ AsyncVectorize,
+ VectorizeWithRawResponse,
+ AsyncVectorizeWithRawResponse,
+ VectorizeWithStreamingResponse,
+ AsyncVectorizeWithStreamingResponse,
+)
+
+__all__ = [
+ "Indexes",
+ "AsyncIndexes",
+ "IndexesWithRawResponse",
+ "AsyncIndexesWithRawResponse",
+ "IndexesWithStreamingResponse",
+ "AsyncIndexesWithStreamingResponse",
+ "Vectorize",
+ "AsyncVectorize",
+ "VectorizeWithRawResponse",
+ "AsyncVectorizeWithRawResponse",
+ "VectorizeWithStreamingResponse",
+ "AsyncVectorizeWithStreamingResponse",
+]
diff --git a/src/cloudflare/resources/vectorize/indexes.py b/src/cloudflare/resources/vectorize/indexes.py
new file mode 100644
index 00000000000..541ac28eb10
--- /dev/null
+++ b/src/cloudflare/resources/vectorize/indexes.py
@@ -0,0 +1,1156 @@
+# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+from __future__ import annotations
+
+from typing import Any, List, Type, Iterable, Optional, cast
+
+import httpx
+
+from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven
+from ..._utils import (
+ maybe_transform,
+ async_maybe_transform,
+)
+from ..._compat import cached_property
+from ..._resource import SyncAPIResource, AsyncAPIResource
+from ..._response import (
+ to_raw_response_wrapper,
+ to_streamed_response_wrapper,
+ async_to_raw_response_wrapper,
+ async_to_streamed_response_wrapper,
+)
+from ..._wrappers import ResultWrapper
+from ...pagination import SyncSinglePage, AsyncSinglePage
+from ..._base_client import (
+ AsyncPaginator,
+ make_request_options,
+)
+from ...types.vectorize import (
+ IndexQuery,
+ CreateIndex,
+ IndexInsert,
+ IndexUpsert,
+ IndexDeleteResponse,
+ IndexDeleteVectorsByID,
+ index_query_params,
+ index_create_params,
+ index_insert_params,
+ index_update_params,
+ index_upsert_params,
+ index_get_by_ids_params,
+ index_delete_by_ids_params,
+)
+
+__all__ = ["Indexes", "AsyncIndexes"]
+
+
+class Indexes(SyncAPIResource):
+ @cached_property
+ def with_raw_response(self) -> IndexesWithRawResponse:
+ return IndexesWithRawResponse(self)
+
+ @cached_property
+ def with_streaming_response(self) -> IndexesWithStreamingResponse:
+ return IndexesWithStreamingResponse(self)
+
+ def create(
+ self,
+ *,
+ account_id: str,
+ config: index_create_params.Config,
+ name: str,
+ description: str | NotGiven = NOT_GIVEN,
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
+ # The extra values given here take precedence over values defined on the client or passed to this method.
+ extra_headers: Headers | None = None,
+ extra_query: Query | None = None,
+ extra_body: Body | None = None,
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
+ ) -> Optional[CreateIndex]:
+ """
+ Creates and returns a new Vectorize Index.
+
+ Args:
+ account_id: Identifier
+
+ config: Specifies the type of configuration to use for the index.
+
+ description: Specifies the description of the index.
+
+ extra_headers: Send extra headers
+
+ extra_query: Add additional query parameters to the request
+
+ extra_body: Add additional JSON properties to the request
+
+ timeout: Override the client-level default timeout for this request, in seconds
+ """
+ if not account_id:
+ raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
+ return self._post(
+ f"/accounts/{account_id}/vectorize/indexes",
+ body=maybe_transform(
+ {
+ "config": config,
+ "name": name,
+ "description": description,
+ },
+ index_create_params.IndexCreateParams,
+ ),
+ options=make_request_options(
+ extra_headers=extra_headers,
+ extra_query=extra_query,
+ extra_body=extra_body,
+ timeout=timeout,
+ post_parser=ResultWrapper._unwrapper,
+ ),
+ cast_to=cast(Type[Optional[CreateIndex]], ResultWrapper[CreateIndex]),
+ )
+
+ def update(
+ self,
+ index_name: str,
+ *,
+ account_id: str,
+ description: str,
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
+ # The extra values given here take precedence over values defined on the client or passed to this method.
+ extra_headers: Headers | None = None,
+ extra_query: Query | None = None,
+ extra_body: Body | None = None,
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
+ ) -> Optional[CreateIndex]:
+ """
+ Updates and returns the specified Vectorize Index.
+
+ Args:
+ account_id: Identifier
+
+ description: Specifies the description of the index.
+
+ extra_headers: Send extra headers
+
+ extra_query: Add additional query parameters to the request
+
+ extra_body: Add additional JSON properties to the request
+
+ timeout: Override the client-level default timeout for this request, in seconds
+ """
+ if not account_id:
+ raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
+ if not index_name:
+ raise ValueError(f"Expected a non-empty value for `index_name` but received {index_name!r}")
+ return self._put(
+ f"/accounts/{account_id}/vectorize/indexes/{index_name}",
+ body=maybe_transform({"description": description}, index_update_params.IndexUpdateParams),
+ options=make_request_options(
+ extra_headers=extra_headers,
+ extra_query=extra_query,
+ extra_body=extra_body,
+ timeout=timeout,
+ post_parser=ResultWrapper._unwrapper,
+ ),
+ cast_to=cast(Type[Optional[CreateIndex]], ResultWrapper[CreateIndex]),
+ )
+
+ def list(
+ self,
+ *,
+ account_id: str,
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
+ # The extra values given here take precedence over values defined on the client or passed to this method.
+ extra_headers: Headers | None = None,
+ extra_query: Query | None = None,
+ extra_body: Body | None = None,
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
+ ) -> SyncSinglePage[CreateIndex]:
+ """
+ Returns a list of Vectorize Indexes
+
+ Args:
+ account_id: Identifier
+
+ extra_headers: Send extra headers
+
+ extra_query: Add additional query parameters to the request
+
+ extra_body: Add additional JSON properties to the request
+
+ timeout: Override the client-level default timeout for this request, in seconds
+ """
+ if not account_id:
+ raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
+ return self._get_api_list(
+ f"/accounts/{account_id}/vectorize/indexes",
+ page=SyncSinglePage[CreateIndex],
+ options=make_request_options(
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
+ ),
+ model=CreateIndex,
+ )
+
+ def delete(
+ self,
+ index_name: str,
+ *,
+ account_id: str,
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
+ # The extra values given here take precedence over values defined on the client or passed to this method.
+ extra_headers: Headers | None = None,
+ extra_query: Query | None = None,
+ extra_body: Body | None = None,
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
+ ) -> IndexDeleteResponse:
+ """
+ Deletes the specified Vectorize Index.
+
+ Args:
+ account_id: Identifier
+
+ extra_headers: Send extra headers
+
+ extra_query: Add additional query parameters to the request
+
+ extra_body: Add additional JSON properties to the request
+
+ timeout: Override the client-level default timeout for this request, in seconds
+ """
+ if not account_id:
+ raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
+ if not index_name:
+ raise ValueError(f"Expected a non-empty value for `index_name` but received {index_name!r}")
+ return cast(
+ IndexDeleteResponse,
+ self._delete(
+ f"/accounts/{account_id}/vectorize/indexes/{index_name}",
+ options=make_request_options(
+ extra_headers=extra_headers,
+ extra_query=extra_query,
+ extra_body=extra_body,
+ timeout=timeout,
+ post_parser=ResultWrapper._unwrapper,
+ ),
+ cast_to=cast(
+ Any, ResultWrapper[IndexDeleteResponse]
+ ), # Union types cannot be passed in as arguments in the type system
+ ),
+ )
+
+ def delete_by_ids(
+ self,
+ index_name: str,
+ *,
+ account_id: str,
+ ids: List[str] | NotGiven = NOT_GIVEN,
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
+ # The extra values given here take precedence over values defined on the client or passed to this method.
+ extra_headers: Headers | None = None,
+ extra_query: Query | None = None,
+ extra_body: Body | None = None,
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
+ ) -> Optional[IndexDeleteVectorsByID]:
+ """
+ Delete a set of vectors from an index by their vector identifiers.
+
+ Args:
+ account_id: Identifier
+
+ ids: A list of vector identifiers to delete from the index indicated by the path.
+
+ extra_headers: Send extra headers
+
+ extra_query: Add additional query parameters to the request
+
+ extra_body: Add additional JSON properties to the request
+
+ timeout: Override the client-level default timeout for this request, in seconds
+ """
+ if not account_id:
+ raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
+ if not index_name:
+ raise ValueError(f"Expected a non-empty value for `index_name` but received {index_name!r}")
+ return self._post(
+ f"/accounts/{account_id}/vectorize/indexes/{index_name}/delete-by-ids",
+ body=maybe_transform({"ids": ids}, index_delete_by_ids_params.IndexDeleteByIDsParams),
+ options=make_request_options(
+ extra_headers=extra_headers,
+ extra_query=extra_query,
+ extra_body=extra_body,
+ timeout=timeout,
+ post_parser=ResultWrapper._unwrapper,
+ ),
+ cast_to=cast(Type[Optional[IndexDeleteVectorsByID]], ResultWrapper[IndexDeleteVectorsByID]),
+ )
+
+ def get(
+ self,
+ index_name: str,
+ *,
+ account_id: str,
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
+ # The extra values given here take precedence over values defined on the client or passed to this method.
+ extra_headers: Headers | None = None,
+ extra_query: Query | None = None,
+ extra_body: Body | None = None,
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
+ ) -> Optional[CreateIndex]:
+ """
+ Returns the specified Vectorize Index.
+
+ Args:
+ account_id: Identifier
+
+ extra_headers: Send extra headers
+
+ extra_query: Add additional query parameters to the request
+
+ extra_body: Add additional JSON properties to the request
+
+ timeout: Override the client-level default timeout for this request, in seconds
+ """
+ if not account_id:
+ raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
+ if not index_name:
+ raise ValueError(f"Expected a non-empty value for `index_name` but received {index_name!r}")
+ return self._get(
+ f"/accounts/{account_id}/vectorize/indexes/{index_name}",
+ options=make_request_options(
+ extra_headers=extra_headers,
+ extra_query=extra_query,
+ extra_body=extra_body,
+ timeout=timeout,
+ post_parser=ResultWrapper._unwrapper,
+ ),
+ cast_to=cast(Type[Optional[CreateIndex]], ResultWrapper[CreateIndex]),
+ )
+
+ def get_by_ids(
+ self,
+ index_name: str,
+ *,
+ account_id: str,
+ ids: List[str] | NotGiven = NOT_GIVEN,
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
+ # The extra values given here take precedence over values defined on the client or passed to this method.
+ extra_headers: Headers | None = None,
+ extra_query: Query | None = None,
+ extra_body: Body | None = None,
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
+ ) -> object:
+ """
+ Get a set of vectors from an index by their vector identifiers.
+
+ Args:
+ account_id: Identifier
+
+ ids: A list of vector identifiers to retrieve from the index indicated by the path.
+
+ extra_headers: Send extra headers
+
+ extra_query: Add additional query parameters to the request
+
+ extra_body: Add additional JSON properties to the request
+
+ timeout: Override the client-level default timeout for this request, in seconds
+ """
+ if not account_id:
+ raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
+ if not index_name:
+ raise ValueError(f"Expected a non-empty value for `index_name` but received {index_name!r}")
+ return self._post(
+ f"/accounts/{account_id}/vectorize/indexes/{index_name}/get-by-ids",
+ body=maybe_transform({"ids": ids}, index_get_by_ids_params.IndexGetByIDsParams),
+ options=make_request_options(
+ extra_headers=extra_headers,
+ extra_query=extra_query,
+ extra_body=extra_body,
+ timeout=timeout,
+ post_parser=ResultWrapper._unwrapper,
+ ),
+ cast_to=cast(Type[object], ResultWrapper[object]),
+ )
+
+ def insert(
+ self,
+ index_name: str,
+ *,
+ account_id: str,
+ body: object,
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
+ # The extra values given here take precedence over values defined on the client or passed to this method.
+ extra_headers: Headers | None = None,
+ extra_query: Query | None = None,
+ extra_body: Body | None = None,
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
+ ) -> Optional[IndexInsert]:
+ """
+ Inserts vectors into the specified index and returns the count of the vectors
+ successfully inserted.
+
+ Args:
+ account_id: Identifier
+
+ extra_headers: Send extra headers
+
+ extra_query: Add additional query parameters to the request
+
+ extra_body: Add additional JSON properties to the request
+
+ timeout: Override the client-level default timeout for this request, in seconds
+ """
+ if not account_id:
+ raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
+ if not index_name:
+ raise ValueError(f"Expected a non-empty value for `index_name` but received {index_name!r}")
+ return self._post(
+ f"/accounts/{account_id}/vectorize/indexes/{index_name}/insert",
+ body=maybe_transform(body, index_insert_params.IndexInsertParams),
+ options=make_request_options(
+ extra_headers=extra_headers,
+ extra_query=extra_query,
+ extra_body=extra_body,
+ timeout=timeout,
+ post_parser=ResultWrapper._unwrapper,
+ ),
+ cast_to=cast(Type[Optional[IndexInsert]], ResultWrapper[IndexInsert]),
+ )
+
+ def query(
+ self,
+ index_name: str,
+ *,
+ account_id: str,
+ vector: Iterable[float],
+ filter: object | NotGiven = NOT_GIVEN,
+ return_metadata: bool | NotGiven = NOT_GIVEN,
+ return_values: bool | NotGiven = NOT_GIVEN,
+ top_k: float | NotGiven = NOT_GIVEN,
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
+ # The extra values given here take precedence over values defined on the client or passed to this method.
+ extra_headers: Headers | None = None,
+ extra_query: Query | None = None,
+ extra_body: Body | None = None,
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
+ ) -> Optional[IndexQuery]:
+ """
+ Finds vectors closest to a given vector in an index.
+
+ Args:
+ account_id: Identifier
+
+ vector: The search vector that will be used to find the nearest neighbors.
+
+ filter: A metadata filter expression used to limit nearest neighbor results.
+
+ return_metadata: Whether to return the metadata associated with the closest vectors.
+
+ return_values: Whether to return the values associated with the closest vectors.
+
+ top_k: The number of nearest neighbors to find.
+
+ extra_headers: Send extra headers
+
+ extra_query: Add additional query parameters to the request
+
+ extra_body: Add additional JSON properties to the request
+
+ timeout: Override the client-level default timeout for this request, in seconds
+ """
+ if not account_id:
+ raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
+ if not index_name:
+ raise ValueError(f"Expected a non-empty value for `index_name` but received {index_name!r}")
+ return self._post(
+ f"/accounts/{account_id}/vectorize/indexes/{index_name}/query",
+ body=maybe_transform(
+ {
+ "vector": vector,
+ "filter": filter,
+ "return_metadata": return_metadata,
+ "return_values": return_values,
+ "top_k": top_k,
+ },
+ index_query_params.IndexQueryParams,
+ ),
+ options=make_request_options(
+ extra_headers=extra_headers,
+ extra_query=extra_query,
+ extra_body=extra_body,
+ timeout=timeout,
+ post_parser=ResultWrapper._unwrapper,
+ ),
+ cast_to=cast(Type[Optional[IndexQuery]], ResultWrapper[IndexQuery]),
+ )
+
+ def upsert(
+ self,
+ index_name: str,
+ *,
+ account_id: str,
+ body: object,
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
+ # The extra values given here take precedence over values defined on the client or passed to this method.
+ extra_headers: Headers | None = None,
+ extra_query: Query | None = None,
+ extra_body: Body | None = None,
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
+ ) -> Optional[IndexUpsert]:
+ """
+ Upserts vectors into the specified index, creating them if they do not exist and
+ returns the count of values and ids successfully inserted.
+
+ Args:
+ account_id: Identifier
+
+ extra_headers: Send extra headers
+
+ extra_query: Add additional query parameters to the request
+
+ extra_body: Add additional JSON properties to the request
+
+ timeout: Override the client-level default timeout for this request, in seconds
+ """
+ if not account_id:
+ raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
+ if not index_name:
+ raise ValueError(f"Expected a non-empty value for `index_name` but received {index_name!r}")
+ return self._post(
+ f"/accounts/{account_id}/vectorize/indexes/{index_name}/upsert",
+ body=maybe_transform(body, index_upsert_params.IndexUpsertParams),
+ options=make_request_options(
+ extra_headers=extra_headers,
+ extra_query=extra_query,
+ extra_body=extra_body,
+ timeout=timeout,
+ post_parser=ResultWrapper._unwrapper,
+ ),
+ cast_to=cast(Type[Optional[IndexUpsert]], ResultWrapper[IndexUpsert]),
+ )
+
+
+class AsyncIndexes(AsyncAPIResource):
+ @cached_property
+ def with_raw_response(self) -> AsyncIndexesWithRawResponse:
+ return AsyncIndexesWithRawResponse(self)
+
+ @cached_property
+ def with_streaming_response(self) -> AsyncIndexesWithStreamingResponse:
+ return AsyncIndexesWithStreamingResponse(self)
+
+ async def create(
+ self,
+ *,
+ account_id: str,
+ config: index_create_params.Config,
+ name: str,
+ description: str | NotGiven = NOT_GIVEN,
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
+ # The extra values given here take precedence over values defined on the client or passed to this method.
+ extra_headers: Headers | None = None,
+ extra_query: Query | None = None,
+ extra_body: Body | None = None,
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
+ ) -> Optional[CreateIndex]:
+ """
+ Creates and returns a new Vectorize Index.
+
+ Args:
+ account_id: Identifier
+
+ config: Specifies the type of configuration to use for the index.
+
+ description: Specifies the description of the index.
+
+ extra_headers: Send extra headers
+
+ extra_query: Add additional query parameters to the request
+
+ extra_body: Add additional JSON properties to the request
+
+ timeout: Override the client-level default timeout for this request, in seconds
+ """
+ if not account_id:
+ raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
+ return await self._post(
+ f"/accounts/{account_id}/vectorize/indexes",
+ body=await async_maybe_transform(
+ {
+ "config": config,
+ "name": name,
+ "description": description,
+ },
+ index_create_params.IndexCreateParams,
+ ),
+ options=make_request_options(
+ extra_headers=extra_headers,
+ extra_query=extra_query,
+ extra_body=extra_body,
+ timeout=timeout,
+ post_parser=ResultWrapper._unwrapper,
+ ),
+ cast_to=cast(Type[Optional[CreateIndex]], ResultWrapper[CreateIndex]),
+ )
+
+ async def update(
+ self,
+ index_name: str,
+ *,
+ account_id: str,
+ description: str,
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
+ # The extra values given here take precedence over values defined on the client or passed to this method.
+ extra_headers: Headers | None = None,
+ extra_query: Query | None = None,
+ extra_body: Body | None = None,
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
+ ) -> Optional[CreateIndex]:
+ """
+ Updates and returns the specified Vectorize Index.
+
+ Args:
+ account_id: Identifier
+
+ description: Specifies the description of the index.
+
+ extra_headers: Send extra headers
+
+ extra_query: Add additional query parameters to the request
+
+ extra_body: Add additional JSON properties to the request
+
+ timeout: Override the client-level default timeout for this request, in seconds
+ """
+ if not account_id:
+ raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
+ if not index_name:
+ raise ValueError(f"Expected a non-empty value for `index_name` but received {index_name!r}")
+ return await self._put(
+ f"/accounts/{account_id}/vectorize/indexes/{index_name}",
+ body=await async_maybe_transform({"description": description}, index_update_params.IndexUpdateParams),
+ options=make_request_options(
+ extra_headers=extra_headers,
+ extra_query=extra_query,
+ extra_body=extra_body,
+ timeout=timeout,
+ post_parser=ResultWrapper._unwrapper,
+ ),
+ cast_to=cast(Type[Optional[CreateIndex]], ResultWrapper[CreateIndex]),
+ )
+
+ def list(
+ self,
+ *,
+ account_id: str,
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
+ # The extra values given here take precedence over values defined on the client or passed to this method.
+ extra_headers: Headers | None = None,
+ extra_query: Query | None = None,
+ extra_body: Body | None = None,
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
+ ) -> AsyncPaginator[CreateIndex, AsyncSinglePage[CreateIndex]]:
+ """
+ Returns a list of Vectorize Indexes
+
+ Args:
+ account_id: Identifier
+
+ extra_headers: Send extra headers
+
+ extra_query: Add additional query parameters to the request
+
+ extra_body: Add additional JSON properties to the request
+
+ timeout: Override the client-level default timeout for this request, in seconds
+ """
+ if not account_id:
+ raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
+ return self._get_api_list(
+ f"/accounts/{account_id}/vectorize/indexes",
+ page=AsyncSinglePage[CreateIndex],
+ options=make_request_options(
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
+ ),
+ model=CreateIndex,
+ )
+
+ async def delete(
+ self,
+ index_name: str,
+ *,
+ account_id: str,
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
+ # The extra values given here take precedence over values defined on the client or passed to this method.
+ extra_headers: Headers | None = None,
+ extra_query: Query | None = None,
+ extra_body: Body | None = None,
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
+ ) -> IndexDeleteResponse:
+ """
+ Deletes the specified Vectorize Index.
+
+ Args:
+ account_id: Identifier
+
+ extra_headers: Send extra headers
+
+ extra_query: Add additional query parameters to the request
+
+ extra_body: Add additional JSON properties to the request
+
+ timeout: Override the client-level default timeout for this request, in seconds
+ """
+ if not account_id:
+ raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
+ if not index_name:
+ raise ValueError(f"Expected a non-empty value for `index_name` but received {index_name!r}")
+ return cast(
+ IndexDeleteResponse,
+ await self._delete(
+ f"/accounts/{account_id}/vectorize/indexes/{index_name}",
+ options=make_request_options(
+ extra_headers=extra_headers,
+ extra_query=extra_query,
+ extra_body=extra_body,
+ timeout=timeout,
+ post_parser=ResultWrapper._unwrapper,
+ ),
+ cast_to=cast(
+ Any, ResultWrapper[IndexDeleteResponse]
+ ), # Union types cannot be passed in as arguments in the type system
+ ),
+ )
+
+ async def delete_by_ids(
+ self,
+ index_name: str,
+ *,
+ account_id: str,
+ ids: List[str] | NotGiven = NOT_GIVEN,
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
+ # The extra values given here take precedence over values defined on the client or passed to this method.
+ extra_headers: Headers | None = None,
+ extra_query: Query | None = None,
+ extra_body: Body | None = None,
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
+ ) -> Optional[IndexDeleteVectorsByID]:
+ """
+ Delete a set of vectors from an index by their vector identifiers.
+
+ Args:
+ account_id: Identifier
+
+ ids: A list of vector identifiers to delete from the index indicated by the path.
+
+ extra_headers: Send extra headers
+
+ extra_query: Add additional query parameters to the request
+
+ extra_body: Add additional JSON properties to the request
+
+ timeout: Override the client-level default timeout for this request, in seconds
+ """
+ if not account_id:
+ raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
+ if not index_name:
+ raise ValueError(f"Expected a non-empty value for `index_name` but received {index_name!r}")
+ return await self._post(
+ f"/accounts/{account_id}/vectorize/indexes/{index_name}/delete-by-ids",
+ body=await async_maybe_transform({"ids": ids}, index_delete_by_ids_params.IndexDeleteByIDsParams),
+ options=make_request_options(
+ extra_headers=extra_headers,
+ extra_query=extra_query,
+ extra_body=extra_body,
+ timeout=timeout,
+ post_parser=ResultWrapper._unwrapper,
+ ),
+ cast_to=cast(Type[Optional[IndexDeleteVectorsByID]], ResultWrapper[IndexDeleteVectorsByID]),
+ )
+
+ async def get(
+ self,
+ index_name: str,
+ *,
+ account_id: str,
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
+ # The extra values given here take precedence over values defined on the client or passed to this method.
+ extra_headers: Headers | None = None,
+ extra_query: Query | None = None,
+ extra_body: Body | None = None,
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
+ ) -> Optional[CreateIndex]:
+ """
+ Returns the specified Vectorize Index.
+
+ Args:
+ account_id: Identifier
+
+ extra_headers: Send extra headers
+
+ extra_query: Add additional query parameters to the request
+
+ extra_body: Add additional JSON properties to the request
+
+ timeout: Override the client-level default timeout for this request, in seconds
+ """
+ if not account_id:
+ raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
+ if not index_name:
+ raise ValueError(f"Expected a non-empty value for `index_name` but received {index_name!r}")
+ return await self._get(
+ f"/accounts/{account_id}/vectorize/indexes/{index_name}",
+ options=make_request_options(
+ extra_headers=extra_headers,
+ extra_query=extra_query,
+ extra_body=extra_body,
+ timeout=timeout,
+ post_parser=ResultWrapper._unwrapper,
+ ),
+ cast_to=cast(Type[Optional[CreateIndex]], ResultWrapper[CreateIndex]),
+ )
+
+ async def get_by_ids(
+ self,
+ index_name: str,
+ *,
+ account_id: str,
+ ids: List[str] | NotGiven = NOT_GIVEN,
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
+ # The extra values given here take precedence over values defined on the client or passed to this method.
+ extra_headers: Headers | None = None,
+ extra_query: Query | None = None,
+ extra_body: Body | None = None,
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
+ ) -> object:
+ """
+ Get a set of vectors from an index by their vector identifiers.
+
+ Args:
+ account_id: Identifier
+
+ ids: A list of vector identifiers to retrieve from the index indicated by the path.
+
+ extra_headers: Send extra headers
+
+ extra_query: Add additional query parameters to the request
+
+ extra_body: Add additional JSON properties to the request
+
+ timeout: Override the client-level default timeout for this request, in seconds
+ """
+ if not account_id:
+ raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
+ if not index_name:
+ raise ValueError(f"Expected a non-empty value for `index_name` but received {index_name!r}")
+ return await self._post(
+ f"/accounts/{account_id}/vectorize/indexes/{index_name}/get-by-ids",
+ body=await async_maybe_transform({"ids": ids}, index_get_by_ids_params.IndexGetByIDsParams),
+ options=make_request_options(
+ extra_headers=extra_headers,
+ extra_query=extra_query,
+ extra_body=extra_body,
+ timeout=timeout,
+ post_parser=ResultWrapper._unwrapper,
+ ),
+ cast_to=cast(Type[object], ResultWrapper[object]),
+ )
+
+ async def insert(
+ self,
+ index_name: str,
+ *,
+ account_id: str,
+ body: object,
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
+ # The extra values given here take precedence over values defined on the client or passed to this method.
+ extra_headers: Headers | None = None,
+ extra_query: Query | None = None,
+ extra_body: Body | None = None,
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
+ ) -> Optional[IndexInsert]:
+ """
+ Inserts vectors into the specified index and returns the count of the vectors
+ successfully inserted.
+
+ Args:
+ account_id: Identifier
+
+ extra_headers: Send extra headers
+
+ extra_query: Add additional query parameters to the request
+
+ extra_body: Add additional JSON properties to the request
+
+ timeout: Override the client-level default timeout for this request, in seconds
+ """
+ if not account_id:
+ raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
+ if not index_name:
+ raise ValueError(f"Expected a non-empty value for `index_name` but received {index_name!r}")
+ return await self._post(
+ f"/accounts/{account_id}/vectorize/indexes/{index_name}/insert",
+ body=await async_maybe_transform(body, index_insert_params.IndexInsertParams),
+ options=make_request_options(
+ extra_headers=extra_headers,
+ extra_query=extra_query,
+ extra_body=extra_body,
+ timeout=timeout,
+ post_parser=ResultWrapper._unwrapper,
+ ),
+ cast_to=cast(Type[Optional[IndexInsert]], ResultWrapper[IndexInsert]),
+ )
+
+ async def query(
+ self,
+ index_name: str,
+ *,
+ account_id: str,
+ vector: Iterable[float],
+ filter: object | NotGiven = NOT_GIVEN,
+ return_metadata: bool | NotGiven = NOT_GIVEN,
+ return_values: bool | NotGiven = NOT_GIVEN,
+ top_k: float | NotGiven = NOT_GIVEN,
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
+ # The extra values given here take precedence over values defined on the client or passed to this method.
+ extra_headers: Headers | None = None,
+ extra_query: Query | None = None,
+ extra_body: Body | None = None,
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
+ ) -> Optional[IndexQuery]:
+ """
+ Finds vectors closest to a given vector in an index.
+
+ Args:
+ account_id: Identifier
+
+ vector: The search vector that will be used to find the nearest neighbors.
+
+ filter: A metadata filter expression used to limit nearest neighbor results.
+
+ return_metadata: Whether to return the metadata associated with the closest vectors.
+
+ return_values: Whether to return the values associated with the closest vectors.
+
+ top_k: The number of nearest neighbors to find.
+
+ extra_headers: Send extra headers
+
+ extra_query: Add additional query parameters to the request
+
+ extra_body: Add additional JSON properties to the request
+
+ timeout: Override the client-level default timeout for this request, in seconds
+ """
+ if not account_id:
+ raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
+ if not index_name:
+ raise ValueError(f"Expected a non-empty value for `index_name` but received {index_name!r}")
+ return await self._post(
+ f"/accounts/{account_id}/vectorize/indexes/{index_name}/query",
+ body=await async_maybe_transform(
+ {
+ "vector": vector,
+ "filter": filter,
+ "return_metadata": return_metadata,
+ "return_values": return_values,
+ "top_k": top_k,
+ },
+ index_query_params.IndexQueryParams,
+ ),
+ options=make_request_options(
+ extra_headers=extra_headers,
+ extra_query=extra_query,
+ extra_body=extra_body,
+ timeout=timeout,
+ post_parser=ResultWrapper._unwrapper,
+ ),
+ cast_to=cast(Type[Optional[IndexQuery]], ResultWrapper[IndexQuery]),
+ )
+
+ async def upsert(
+ self,
+ index_name: str,
+ *,
+ account_id: str,
+ body: object,
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
+ # The extra values given here take precedence over values defined on the client or passed to this method.
+ extra_headers: Headers | None = None,
+ extra_query: Query | None = None,
+ extra_body: Body | None = None,
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
+ ) -> Optional[IndexUpsert]:
+ """
+ Upserts vectors into the specified index, creating them if they do not exist and
+ returns the count of values and ids successfully inserted.
+
+ Args:
+ account_id: Identifier
+
+ extra_headers: Send extra headers
+
+ extra_query: Add additional query parameters to the request
+
+ extra_body: Add additional JSON properties to the request
+
+ timeout: Override the client-level default timeout for this request, in seconds
+ """
+ if not account_id:
+ raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
+ if not index_name:
+ raise ValueError(f"Expected a non-empty value for `index_name` but received {index_name!r}")
+ return await self._post(
+ f"/accounts/{account_id}/vectorize/indexes/{index_name}/upsert",
+ body=await async_maybe_transform(body, index_upsert_params.IndexUpsertParams),
+ options=make_request_options(
+ extra_headers=extra_headers,
+ extra_query=extra_query,
+ extra_body=extra_body,
+ timeout=timeout,
+ post_parser=ResultWrapper._unwrapper,
+ ),
+ cast_to=cast(Type[Optional[IndexUpsert]], ResultWrapper[IndexUpsert]),
+ )
+
+
+class IndexesWithRawResponse:
+ def __init__(self, indexes: Indexes) -> None:
+ self._indexes = indexes
+
+ self.create = to_raw_response_wrapper(
+ indexes.create,
+ )
+ self.update = to_raw_response_wrapper(
+ indexes.update,
+ )
+ self.list = to_raw_response_wrapper(
+ indexes.list,
+ )
+ self.delete = to_raw_response_wrapper(
+ indexes.delete,
+ )
+ self.delete_by_ids = to_raw_response_wrapper(
+ indexes.delete_by_ids,
+ )
+ self.get = to_raw_response_wrapper(
+ indexes.get,
+ )
+ self.get_by_ids = to_raw_response_wrapper(
+ indexes.get_by_ids,
+ )
+ self.insert = to_raw_response_wrapper(
+ indexes.insert,
+ )
+ self.query = to_raw_response_wrapper(
+ indexes.query,
+ )
+ self.upsert = to_raw_response_wrapper(
+ indexes.upsert,
+ )
+
+
+class AsyncIndexesWithRawResponse:
+ def __init__(self, indexes: AsyncIndexes) -> None:
+ self._indexes = indexes
+
+ self.create = async_to_raw_response_wrapper(
+ indexes.create,
+ )
+ self.update = async_to_raw_response_wrapper(
+ indexes.update,
+ )
+ self.list = async_to_raw_response_wrapper(
+ indexes.list,
+ )
+ self.delete = async_to_raw_response_wrapper(
+ indexes.delete,
+ )
+ self.delete_by_ids = async_to_raw_response_wrapper(
+ indexes.delete_by_ids,
+ )
+ self.get = async_to_raw_response_wrapper(
+ indexes.get,
+ )
+ self.get_by_ids = async_to_raw_response_wrapper(
+ indexes.get_by_ids,
+ )
+ self.insert = async_to_raw_response_wrapper(
+ indexes.insert,
+ )
+ self.query = async_to_raw_response_wrapper(
+ indexes.query,
+ )
+ self.upsert = async_to_raw_response_wrapper(
+ indexes.upsert,
+ )
+
+
+class IndexesWithStreamingResponse:
+ def __init__(self, indexes: Indexes) -> None:
+ self._indexes = indexes
+
+ self.create = to_streamed_response_wrapper(
+ indexes.create,
+ )
+ self.update = to_streamed_response_wrapper(
+ indexes.update,
+ )
+ self.list = to_streamed_response_wrapper(
+ indexes.list,
+ )
+ self.delete = to_streamed_response_wrapper(
+ indexes.delete,
+ )
+ self.delete_by_ids = to_streamed_response_wrapper(
+ indexes.delete_by_ids,
+ )
+ self.get = to_streamed_response_wrapper(
+ indexes.get,
+ )
+ self.get_by_ids = to_streamed_response_wrapper(
+ indexes.get_by_ids,
+ )
+ self.insert = to_streamed_response_wrapper(
+ indexes.insert,
+ )
+ self.query = to_streamed_response_wrapper(
+ indexes.query,
+ )
+ self.upsert = to_streamed_response_wrapper(
+ indexes.upsert,
+ )
+
+
+class AsyncIndexesWithStreamingResponse:
+ def __init__(self, indexes: AsyncIndexes) -> None:
+ self._indexes = indexes
+
+ self.create = async_to_streamed_response_wrapper(
+ indexes.create,
+ )
+ self.update = async_to_streamed_response_wrapper(
+ indexes.update,
+ )
+ self.list = async_to_streamed_response_wrapper(
+ indexes.list,
+ )
+ self.delete = async_to_streamed_response_wrapper(
+ indexes.delete,
+ )
+ self.delete_by_ids = async_to_streamed_response_wrapper(
+ indexes.delete_by_ids,
+ )
+ self.get = async_to_streamed_response_wrapper(
+ indexes.get,
+ )
+ self.get_by_ids = async_to_streamed_response_wrapper(
+ indexes.get_by_ids,
+ )
+ self.insert = async_to_streamed_response_wrapper(
+ indexes.insert,
+ )
+ self.query = async_to_streamed_response_wrapper(
+ indexes.query,
+ )
+ self.upsert = async_to_streamed_response_wrapper(
+ indexes.upsert,
+ )
diff --git a/src/cloudflare/resources/vectorize/vectorize.py b/src/cloudflare/resources/vectorize/vectorize.py
new file mode 100644
index 00000000000..bb5adf5237d
--- /dev/null
+++ b/src/cloudflare/resources/vectorize/vectorize.py
@@ -0,0 +1,80 @@
+# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+from __future__ import annotations
+
+from .indexes import (
+ Indexes,
+ AsyncIndexes,
+ IndexesWithRawResponse,
+ AsyncIndexesWithRawResponse,
+ IndexesWithStreamingResponse,
+ AsyncIndexesWithStreamingResponse,
+)
+from ..._compat import cached_property
+from ..._resource import SyncAPIResource, AsyncAPIResource
+
+__all__ = ["Vectorize", "AsyncVectorize"]
+
+
+class Vectorize(SyncAPIResource):
+ @cached_property
+ def indexes(self) -> Indexes:
+ return Indexes(self._client)
+
+ @cached_property
+ def with_raw_response(self) -> VectorizeWithRawResponse:
+ return VectorizeWithRawResponse(self)
+
+ @cached_property
+ def with_streaming_response(self) -> VectorizeWithStreamingResponse:
+ return VectorizeWithStreamingResponse(self)
+
+
+class AsyncVectorize(AsyncAPIResource):
+ @cached_property
+ def indexes(self) -> AsyncIndexes:
+ return AsyncIndexes(self._client)
+
+ @cached_property
+ def with_raw_response(self) -> AsyncVectorizeWithRawResponse:
+ return AsyncVectorizeWithRawResponse(self)
+
+ @cached_property
+ def with_streaming_response(self) -> AsyncVectorizeWithStreamingResponse:
+ return AsyncVectorizeWithStreamingResponse(self)
+
+
+class VectorizeWithRawResponse:
+ def __init__(self, vectorize: Vectorize) -> None:
+ self._vectorize = vectorize
+
+ @cached_property
+ def indexes(self) -> IndexesWithRawResponse:
+ return IndexesWithRawResponse(self._vectorize.indexes)
+
+
+class AsyncVectorizeWithRawResponse:
+ def __init__(self, vectorize: AsyncVectorize) -> None:
+ self._vectorize = vectorize
+
+ @cached_property
+ def indexes(self) -> AsyncIndexesWithRawResponse:
+ return AsyncIndexesWithRawResponse(self._vectorize.indexes)
+
+
+class VectorizeWithStreamingResponse:
+ def __init__(self, vectorize: Vectorize) -> None:
+ self._vectorize = vectorize
+
+ @cached_property
+ def indexes(self) -> IndexesWithStreamingResponse:
+ return IndexesWithStreamingResponse(self._vectorize.indexes)
+
+
+class AsyncVectorizeWithStreamingResponse:
+ def __init__(self, vectorize: AsyncVectorize) -> None:
+ self._vectorize = vectorize
+
+ @cached_property
+ def indexes(self) -> AsyncIndexesWithStreamingResponse:
+ return AsyncIndexesWithStreamingResponse(self._vectorize.indexes)
diff --git a/src/cloudflare/types/vectorize/__init__.py b/src/cloudflare/types/vectorize/__init__.py
index f8ee8b14b1c..756fca55ae5 100644
--- a/src/cloudflare/types/vectorize/__init__.py
+++ b/src/cloudflare/types/vectorize/__init__.py
@@ -1,3 +1,19 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
from __future__ import annotations
+
+from .index_query import IndexQuery as IndexQuery
+from .create_index import CreateIndex as CreateIndex
+from .index_insert import IndexInsert as IndexInsert
+from .index_upsert import IndexUpsert as IndexUpsert
+from .index_query_params import IndexQueryParams as IndexQueryParams
+from .index_create_params import IndexCreateParams as IndexCreateParams
+from .index_insert_params import IndexInsertParams as IndexInsertParams
+from .index_update_params import IndexUpdateParams as IndexUpdateParams
+from .index_upsert_params import IndexUpsertParams as IndexUpsertParams
+from .index_delete_response import IndexDeleteResponse as IndexDeleteResponse
+from .index_get_by_ids_params import IndexGetByIDsParams as IndexGetByIDsParams
+from .index_delete_by_ids_params import IndexDeleteByIDsParams as IndexDeleteByIDsParams
+from .index_delete_vectors_by_id import IndexDeleteVectorsByID as IndexDeleteVectorsByID
+from .index_dimension_configuration import IndexDimensionConfiguration as IndexDimensionConfiguration
+from .index_dimension_configuration_param import IndexDimensionConfigurationParam as IndexDimensionConfigurationParam
diff --git a/src/cloudflare/types/vectorize/create_index.py b/src/cloudflare/types/vectorize/create_index.py
new file mode 100644
index 00000000000..e28d4e352d4
--- /dev/null
+++ b/src/cloudflare/types/vectorize/create_index.py
@@ -0,0 +1,23 @@
+# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+from typing import Optional
+
+from ..._models import BaseModel
+from .index_dimension_configuration import IndexDimensionConfiguration
+
+__all__ = ["CreateIndex"]
+
+
+class CreateIndex(BaseModel):
+ config: Optional[IndexDimensionConfiguration] = None
+
+ created_on: Optional[str] = None
+ """Specifies the timestamp the resource was created as an ISO8601 string."""
+
+ description: Optional[str] = None
+ """Specifies the description of the index."""
+
+ modified_on: Optional[str] = None
+ """Specifies the timestamp the resource was modified as an ISO8601 string."""
+
+ name: Optional[str] = None
diff --git a/src/cloudflare/types/vectorize/index_create_params.py b/src/cloudflare/types/vectorize/index_create_params.py
new file mode 100644
index 00000000000..cd89ecd2673
--- /dev/null
+++ b/src/cloudflare/types/vectorize/index_create_params.py
@@ -0,0 +1,39 @@
+# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+from __future__ import annotations
+
+from typing import Union
+from typing_extensions import Literal, Required, TypedDict
+
+from .index_dimension_configuration_param import IndexDimensionConfigurationParam
+
+__all__ = ["IndexCreateParams", "Config", "ConfigVectorizeIndexPresetConfiguration"]
+
+
+class IndexCreateParams(TypedDict, total=False):
+ account_id: Required[str]
+ """Identifier"""
+
+ config: Required[Config]
+ """Specifies the type of configuration to use for the index."""
+
+ name: Required[str]
+
+ description: str
+ """Specifies the description of the index."""
+
+
+class ConfigVectorizeIndexPresetConfiguration(TypedDict, total=False):
+ preset: Required[
+ Literal[
+ "@cf/baai/bge-small-en-v1.5",
+ "@cf/baai/bge-base-en-v1.5",
+ "@cf/baai/bge-large-en-v1.5",
+ "openai/text-embedding-ada-002",
+ "cohere/embed-multilingual-v2.0",
+ ]
+ ]
+ """Specifies the preset to use for the index."""
+
+
+Config = Union[IndexDimensionConfigurationParam, ConfigVectorizeIndexPresetConfiguration]
diff --git a/src/cloudflare/types/vectorize/index_delete_by_ids_params.py b/src/cloudflare/types/vectorize/index_delete_by_ids_params.py
new file mode 100644
index 00000000000..606c8b152f2
--- /dev/null
+++ b/src/cloudflare/types/vectorize/index_delete_by_ids_params.py
@@ -0,0 +1,16 @@
+# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+from __future__ import annotations
+
+from typing import List
+from typing_extensions import Required, TypedDict
+
+__all__ = ["IndexDeleteByIDsParams"]
+
+
+class IndexDeleteByIDsParams(TypedDict, total=False):
+ account_id: Required[str]
+ """Identifier"""
+
+ ids: List[str]
+ """A list of vector identifiers to delete from the index indicated by the path."""
diff --git a/src/cloudflare/types/vectorize/index_delete_response.py b/src/cloudflare/types/vectorize/index_delete_response.py
new file mode 100644
index 00000000000..b64904cdd6e
--- /dev/null
+++ b/src/cloudflare/types/vectorize/index_delete_response.py
@@ -0,0 +1,7 @@
+# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+from typing import Union, Optional
+
+__all__ = ["IndexDeleteResponse"]
+
+IndexDeleteResponse = Union[Optional[str], Optional[object]]
diff --git a/src/cloudflare/types/vectorize/index_delete_vectors_by_id.py b/src/cloudflare/types/vectorize/index_delete_vectors_by_id.py
new file mode 100644
index 00000000000..b06650b76cb
--- /dev/null
+++ b/src/cloudflare/types/vectorize/index_delete_vectors_by_id.py
@@ -0,0 +1,18 @@
+# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+from typing import List, Optional
+
+from ..._models import BaseModel
+
+__all__ = ["IndexDeleteVectorsByID"]
+
+
+class IndexDeleteVectorsByID(BaseModel):
+ count: Optional[int] = None
+ """The count of the vectors successfully deleted."""
+
+ ids: Optional[List[str]] = None
+ """
+ Array of vector identifiers of the vectors that were successfully processed for
+ deletion.
+ """
diff --git a/src/cloudflare/types/vectorize/index_dimension_configuration.py b/src/cloudflare/types/vectorize/index_dimension_configuration.py
new file mode 100644
index 00000000000..f9450682916
--- /dev/null
+++ b/src/cloudflare/types/vectorize/index_dimension_configuration.py
@@ -0,0 +1,15 @@
+# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+from typing_extensions import Literal
+
+from ..._models import BaseModel
+
+__all__ = ["IndexDimensionConfiguration"]
+
+
+class IndexDimensionConfiguration(BaseModel):
+ dimensions: int
+ """Specifies the number of dimensions for the index"""
+
+ metric: Literal["cosine", "euclidean", "dot-product"]
+ """Specifies the type of metric to use calculating distance."""
diff --git a/src/cloudflare/types/vectorize/index_dimension_configuration_param.py b/src/cloudflare/types/vectorize/index_dimension_configuration_param.py
new file mode 100644
index 00000000000..13c383d6dc2
--- /dev/null
+++ b/src/cloudflare/types/vectorize/index_dimension_configuration_param.py
@@ -0,0 +1,15 @@
+# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+from __future__ import annotations
+
+from typing_extensions import Literal, Required, TypedDict
+
+__all__ = ["IndexDimensionConfigurationParam"]
+
+
+class IndexDimensionConfigurationParam(TypedDict, total=False):
+ dimensions: Required[int]
+ """Specifies the number of dimensions for the index"""
+
+ metric: Required[Literal["cosine", "euclidean", "dot-product"]]
+ """Specifies the type of metric to use calculating distance."""
diff --git a/src/cloudflare/types/vectorize/index_get_by_ids_params.py b/src/cloudflare/types/vectorize/index_get_by_ids_params.py
new file mode 100644
index 00000000000..89fdd20578e
--- /dev/null
+++ b/src/cloudflare/types/vectorize/index_get_by_ids_params.py
@@ -0,0 +1,16 @@
+# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+from __future__ import annotations
+
+from typing import List
+from typing_extensions import Required, TypedDict
+
+__all__ = ["IndexGetByIDsParams"]
+
+
+class IndexGetByIDsParams(TypedDict, total=False):
+ account_id: Required[str]
+ """Identifier"""
+
+ ids: List[str]
+ """A list of vector identifiers to retrieve from the index indicated by the path."""
diff --git a/src/cloudflare/types/vectorize/index_insert.py b/src/cloudflare/types/vectorize/index_insert.py
new file mode 100644
index 00000000000..17cc6ecbe4b
--- /dev/null
+++ b/src/cloudflare/types/vectorize/index_insert.py
@@ -0,0 +1,15 @@
+# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+from typing import List, Optional
+
+from ..._models import BaseModel
+
+__all__ = ["IndexInsert"]
+
+
+class IndexInsert(BaseModel):
+ count: Optional[int] = None
+ """Specifies the count of the vectors successfully inserted."""
+
+ ids: Optional[List[str]] = None
+ """Array of vector identifiers of the vectors successfully inserted."""
diff --git a/src/cloudflare/types/vectorize/index_insert_params.py b/src/cloudflare/types/vectorize/index_insert_params.py
new file mode 100644
index 00000000000..d5a829f9ee3
--- /dev/null
+++ b/src/cloudflare/types/vectorize/index_insert_params.py
@@ -0,0 +1,14 @@
+# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+from __future__ import annotations
+
+from typing_extensions import Required, TypedDict
+
+__all__ = ["IndexInsertParams"]
+
+
+class IndexInsertParams(TypedDict, total=False):
+ account_id: Required[str]
+ """Identifier"""
+
+ body: Required[object]
diff --git a/src/cloudflare/types/vectorize/index_query.py b/src/cloudflare/types/vectorize/index_query.py
new file mode 100644
index 00000000000..11de5c950e0
--- /dev/null
+++ b/src/cloudflare/types/vectorize/index_query.py
@@ -0,0 +1,27 @@
+# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+from typing import List, Optional
+
+from ..._models import BaseModel
+
+__all__ = ["IndexQuery", "Match"]
+
+
+class Match(BaseModel):
+ id: Optional[str] = None
+ """Identifier"""
+
+ metadata: Optional[object] = None
+
+ score: Optional[float] = None
+ """The score of the vector according to the index's distance metric"""
+
+ values: Optional[List[float]] = None
+
+
+class IndexQuery(BaseModel):
+ count: Optional[int] = None
+ """Specifies the count of vectors returned by the search"""
+
+ matches: Optional[List[Match]] = None
+ """Array of vectors matched by the search"""
diff --git a/src/cloudflare/types/vectorize/index_query_params.py b/src/cloudflare/types/vectorize/index_query_params.py
new file mode 100644
index 00000000000..97fe6efc32d
--- /dev/null
+++ b/src/cloudflare/types/vectorize/index_query_params.py
@@ -0,0 +1,30 @@
+# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+from __future__ import annotations
+
+from typing import Iterable
+from typing_extensions import Required, Annotated, TypedDict
+
+from ..._utils import PropertyInfo
+
+__all__ = ["IndexQueryParams"]
+
+
+class IndexQueryParams(TypedDict, total=False):
+ account_id: Required[str]
+ """Identifier"""
+
+ vector: Required[Iterable[float]]
+ """The search vector that will be used to find the nearest neighbors."""
+
+ filter: object
+ """A metadata filter expression used to limit nearest neighbor results."""
+
+ return_metadata: Annotated[bool, PropertyInfo(alias="returnMetadata")]
+ """Whether to return the metadata associated with the closest vectors."""
+
+ return_values: Annotated[bool, PropertyInfo(alias="returnValues")]
+ """Whether to return the values associated with the closest vectors."""
+
+ top_k: Annotated[float, PropertyInfo(alias="topK")]
+ """The number of nearest neighbors to find."""
diff --git a/src/cloudflare/types/vectorize/index_update_params.py b/src/cloudflare/types/vectorize/index_update_params.py
new file mode 100644
index 00000000000..2cb1ad85804
--- /dev/null
+++ b/src/cloudflare/types/vectorize/index_update_params.py
@@ -0,0 +1,15 @@
+# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+from __future__ import annotations
+
+from typing_extensions import Required, TypedDict
+
+__all__ = ["IndexUpdateParams"]
+
+
+class IndexUpdateParams(TypedDict, total=False):
+ account_id: Required[str]
+ """Identifier"""
+
+ description: Required[str]
+ """Specifies the description of the index."""
diff --git a/src/cloudflare/types/vectorize/index_upsert.py b/src/cloudflare/types/vectorize/index_upsert.py
new file mode 100644
index 00000000000..400b88324fa
--- /dev/null
+++ b/src/cloudflare/types/vectorize/index_upsert.py
@@ -0,0 +1,15 @@
+# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+from typing import List, Optional
+
+from ..._models import BaseModel
+
+__all__ = ["IndexUpsert"]
+
+
+class IndexUpsert(BaseModel):
+ count: Optional[int] = None
+ """Specifies the count of the vectors successfully inserted."""
+
+ ids: Optional[List[str]] = None
+ """Array of vector identifiers of the vectors successfully inserted."""
diff --git a/src/cloudflare/types/vectorize/index_upsert_params.py b/src/cloudflare/types/vectorize/index_upsert_params.py
new file mode 100644
index 00000000000..6b187a77059
--- /dev/null
+++ b/src/cloudflare/types/vectorize/index_upsert_params.py
@@ -0,0 +1,14 @@
+# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+from __future__ import annotations
+
+from typing_extensions import Required, TypedDict
+
+__all__ = ["IndexUpsertParams"]
+
+
+class IndexUpsertParams(TypedDict, total=False):
+ account_id: Required[str]
+ """Identifier"""
+
+ body: Required[object]
diff --git a/tests/api_resources/vectorize/test_indexes.py b/tests/api_resources/vectorize/test_indexes.py
new file mode 100644
index 00000000000..5b7bccfe4cf
--- /dev/null
+++ b/tests/api_resources/vectorize/test_indexes.py
@@ -0,0 +1,1212 @@
+# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+from __future__ import annotations
+
+import os
+from typing import Any, Optional, cast
+
+import pytest
+
+from cloudflare import Cloudflare, AsyncCloudflare
+from tests.utils import assert_matches_type
+from cloudflare.pagination import SyncSinglePage, AsyncSinglePage
+from cloudflare.types.vectorize import (
+ IndexQuery,
+ CreateIndex,
+ IndexInsert,
+ IndexUpsert,
+ IndexDeleteResponse,
+ IndexDeleteVectorsByID,
+)
+
+base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
+
+
+class TestIndexes:
+ parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"])
+
+ @pytest.mark.skip()
+ @parametrize
+ def test_method_create(self, client: Cloudflare) -> None:
+ index = client.vectorize.indexes.create(
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ config={
+ "dimensions": 768,
+ "metric": "cosine",
+ },
+ name="example-index",
+ )
+ assert_matches_type(Optional[CreateIndex], index, path=["response"])
+
+ @pytest.mark.skip()
+ @parametrize
+ def test_method_create_with_all_params(self, client: Cloudflare) -> None:
+ index = client.vectorize.indexes.create(
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ config={
+ "dimensions": 768,
+ "metric": "cosine",
+ },
+ name="example-index",
+ description="This is my example index.",
+ )
+ assert_matches_type(Optional[CreateIndex], index, path=["response"])
+
+ @pytest.mark.skip()
+ @parametrize
+ def test_raw_response_create(self, client: Cloudflare) -> None:
+ response = client.vectorize.indexes.with_raw_response.create(
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ config={
+ "dimensions": 768,
+ "metric": "cosine",
+ },
+ name="example-index",
+ )
+
+ assert response.is_closed is True
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+ index = response.parse()
+ assert_matches_type(Optional[CreateIndex], index, path=["response"])
+
+ @pytest.mark.skip()
+ @parametrize
+ def test_streaming_response_create(self, client: Cloudflare) -> None:
+ with client.vectorize.indexes.with_streaming_response.create(
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ config={
+ "dimensions": 768,
+ "metric": "cosine",
+ },
+ name="example-index",
+ ) as response:
+ assert not response.is_closed
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+
+ index = response.parse()
+ assert_matches_type(Optional[CreateIndex], index, path=["response"])
+
+ assert cast(Any, response.is_closed) is True
+
+ @pytest.mark.skip()
+ @parametrize
+ def test_path_params_create(self, client: Cloudflare) -> None:
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
+ client.vectorize.indexes.with_raw_response.create(
+ account_id="",
+ config={
+ "dimensions": 768,
+ "metric": "cosine",
+ },
+ name="example-index",
+ )
+
+ @pytest.mark.skip()
+ @parametrize
+ def test_method_update(self, client: Cloudflare) -> None:
+ index = client.vectorize.indexes.update(
+ "example-index",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ description="This is my example index.",
+ )
+ assert_matches_type(Optional[CreateIndex], index, path=["response"])
+
+ @pytest.mark.skip()
+ @parametrize
+ def test_raw_response_update(self, client: Cloudflare) -> None:
+ response = client.vectorize.indexes.with_raw_response.update(
+ "example-index",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ description="This is my example index.",
+ )
+
+ assert response.is_closed is True
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+ index = response.parse()
+ assert_matches_type(Optional[CreateIndex], index, path=["response"])
+
+ @pytest.mark.skip()
+ @parametrize
+ def test_streaming_response_update(self, client: Cloudflare) -> None:
+ with client.vectorize.indexes.with_streaming_response.update(
+ "example-index",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ description="This is my example index.",
+ ) as response:
+ assert not response.is_closed
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+
+ index = response.parse()
+ assert_matches_type(Optional[CreateIndex], index, path=["response"])
+
+ assert cast(Any, response.is_closed) is True
+
+ @pytest.mark.skip()
+ @parametrize
+ def test_path_params_update(self, client: Cloudflare) -> None:
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
+ client.vectorize.indexes.with_raw_response.update(
+ "example-index",
+ account_id="",
+ description="This is my example index.",
+ )
+
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `index_name` but received ''"):
+ client.vectorize.indexes.with_raw_response.update(
+ "",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ description="This is my example index.",
+ )
+
+ @pytest.mark.skip()
+ @parametrize
+ def test_method_list(self, client: Cloudflare) -> None:
+ index = client.vectorize.indexes.list(
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ )
+ assert_matches_type(SyncSinglePage[CreateIndex], index, path=["response"])
+
+ @pytest.mark.skip()
+ @parametrize
+ def test_raw_response_list(self, client: Cloudflare) -> None:
+ response = client.vectorize.indexes.with_raw_response.list(
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ )
+
+ assert response.is_closed is True
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+ index = response.parse()
+ assert_matches_type(SyncSinglePage[CreateIndex], index, path=["response"])
+
+ @pytest.mark.skip()
+ @parametrize
+ def test_streaming_response_list(self, client: Cloudflare) -> None:
+ with client.vectorize.indexes.with_streaming_response.list(
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ ) as response:
+ assert not response.is_closed
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+
+ index = response.parse()
+ assert_matches_type(SyncSinglePage[CreateIndex], index, path=["response"])
+
+ assert cast(Any, response.is_closed) is True
+
+ @pytest.mark.skip()
+ @parametrize
+ def test_path_params_list(self, client: Cloudflare) -> None:
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
+ client.vectorize.indexes.with_raw_response.list(
+ account_id="",
+ )
+
+ @pytest.mark.skip()
+ @parametrize
+ def test_method_delete(self, client: Cloudflare) -> None:
+ index = client.vectorize.indexes.delete(
+ "example-index",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ )
+ assert_matches_type(IndexDeleteResponse, index, path=["response"])
+
+ @pytest.mark.skip()
+ @parametrize
+ def test_raw_response_delete(self, client: Cloudflare) -> None:
+ response = client.vectorize.indexes.with_raw_response.delete(
+ "example-index",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ )
+
+ assert response.is_closed is True
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+ index = response.parse()
+ assert_matches_type(IndexDeleteResponse, index, path=["response"])
+
+ @pytest.mark.skip()
+ @parametrize
+ def test_streaming_response_delete(self, client: Cloudflare) -> None:
+ with client.vectorize.indexes.with_streaming_response.delete(
+ "example-index",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ ) as response:
+ assert not response.is_closed
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+
+ index = response.parse()
+ assert_matches_type(IndexDeleteResponse, index, path=["response"])
+
+ assert cast(Any, response.is_closed) is True
+
+ @pytest.mark.skip()
+ @parametrize
+ def test_path_params_delete(self, client: Cloudflare) -> None:
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
+ client.vectorize.indexes.with_raw_response.delete(
+ "example-index",
+ account_id="",
+ )
+
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `index_name` but received ''"):
+ client.vectorize.indexes.with_raw_response.delete(
+ "",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ )
+
+ @pytest.mark.skip()
+ @parametrize
+ def test_method_delete_by_ids(self, client: Cloudflare) -> None:
+ index = client.vectorize.indexes.delete_by_ids(
+ "example-index",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ )
+ assert_matches_type(Optional[IndexDeleteVectorsByID], index, path=["response"])
+
+ @pytest.mark.skip()
+ @parametrize
+ def test_method_delete_by_ids_with_all_params(self, client: Cloudflare) -> None:
+ index = client.vectorize.indexes.delete_by_ids(
+ "example-index",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ ids=["5121db81354a40c6aedc3fe1ace51c59", "f90eb49c2107486abdfd78c67e853430"],
+ )
+ assert_matches_type(Optional[IndexDeleteVectorsByID], index, path=["response"])
+
+ @pytest.mark.skip()
+ @parametrize
+ def test_raw_response_delete_by_ids(self, client: Cloudflare) -> None:
+ response = client.vectorize.indexes.with_raw_response.delete_by_ids(
+ "example-index",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ )
+
+ assert response.is_closed is True
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+ index = response.parse()
+ assert_matches_type(Optional[IndexDeleteVectorsByID], index, path=["response"])
+
+ @pytest.mark.skip()
+ @parametrize
+ def test_streaming_response_delete_by_ids(self, client: Cloudflare) -> None:
+ with client.vectorize.indexes.with_streaming_response.delete_by_ids(
+ "example-index",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ ) as response:
+ assert not response.is_closed
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+
+ index = response.parse()
+ assert_matches_type(Optional[IndexDeleteVectorsByID], index, path=["response"])
+
+ assert cast(Any, response.is_closed) is True
+
+ @pytest.mark.skip()
+ @parametrize
+ def test_path_params_delete_by_ids(self, client: Cloudflare) -> None:
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
+ client.vectorize.indexes.with_raw_response.delete_by_ids(
+ "example-index",
+ account_id="",
+ )
+
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `index_name` but received ''"):
+ client.vectorize.indexes.with_raw_response.delete_by_ids(
+ "",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ )
+
+ @pytest.mark.skip()
+ @parametrize
+ def test_method_get(self, client: Cloudflare) -> None:
+ index = client.vectorize.indexes.get(
+ "example-index",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ )
+ assert_matches_type(Optional[CreateIndex], index, path=["response"])
+
+ @pytest.mark.skip()
+ @parametrize
+ def test_raw_response_get(self, client: Cloudflare) -> None:
+ response = client.vectorize.indexes.with_raw_response.get(
+ "example-index",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ )
+
+ assert response.is_closed is True
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+ index = response.parse()
+ assert_matches_type(Optional[CreateIndex], index, path=["response"])
+
+ @pytest.mark.skip()
+ @parametrize
+ def test_streaming_response_get(self, client: Cloudflare) -> None:
+ with client.vectorize.indexes.with_streaming_response.get(
+ "example-index",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ ) as response:
+ assert not response.is_closed
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+
+ index = response.parse()
+ assert_matches_type(Optional[CreateIndex], index, path=["response"])
+
+ assert cast(Any, response.is_closed) is True
+
+ @pytest.mark.skip()
+ @parametrize
+ def test_path_params_get(self, client: Cloudflare) -> None:
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
+ client.vectorize.indexes.with_raw_response.get(
+ "example-index",
+ account_id="",
+ )
+
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `index_name` but received ''"):
+ client.vectorize.indexes.with_raw_response.get(
+ "",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ )
+
+ @pytest.mark.skip()
+ @parametrize
+ def test_method_get_by_ids(self, client: Cloudflare) -> None:
+ index = client.vectorize.indexes.get_by_ids(
+ "example-index",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ )
+ assert_matches_type(object, index, path=["response"])
+
+ @pytest.mark.skip()
+ @parametrize
+ def test_method_get_by_ids_with_all_params(self, client: Cloudflare) -> None:
+ index = client.vectorize.indexes.get_by_ids(
+ "example-index",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ ids=["5121db81354a40c6aedc3fe1ace51c59", "f90eb49c2107486abdfd78c67e853430"],
+ )
+ assert_matches_type(object, index, path=["response"])
+
+ @pytest.mark.skip()
+ @parametrize
+ def test_raw_response_get_by_ids(self, client: Cloudflare) -> None:
+ response = client.vectorize.indexes.with_raw_response.get_by_ids(
+ "example-index",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ )
+
+ assert response.is_closed is True
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+ index = response.parse()
+ assert_matches_type(object, index, path=["response"])
+
+ @pytest.mark.skip()
+ @parametrize
+ def test_streaming_response_get_by_ids(self, client: Cloudflare) -> None:
+ with client.vectorize.indexes.with_streaming_response.get_by_ids(
+ "example-index",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ ) as response:
+ assert not response.is_closed
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+
+ index = response.parse()
+ assert_matches_type(object, index, path=["response"])
+
+ assert cast(Any, response.is_closed) is True
+
+ @pytest.mark.skip()
+ @parametrize
+ def test_path_params_get_by_ids(self, client: Cloudflare) -> None:
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
+ client.vectorize.indexes.with_raw_response.get_by_ids(
+ "example-index",
+ account_id="",
+ )
+
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `index_name` but received ''"):
+ client.vectorize.indexes.with_raw_response.get_by_ids(
+ "",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ )
+
+ @pytest.mark.skip()
+ @parametrize
+ def test_method_insert(self, client: Cloudflare) -> None:
+ index = client.vectorize.indexes.insert(
+ "example-index",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ body={},
+ )
+ assert_matches_type(Optional[IndexInsert], index, path=["response"])
+
+ @pytest.mark.skip()
+ @parametrize
+ def test_raw_response_insert(self, client: Cloudflare) -> None:
+ response = client.vectorize.indexes.with_raw_response.insert(
+ "example-index",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ body={},
+ )
+
+ assert response.is_closed is True
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+ index = response.parse()
+ assert_matches_type(Optional[IndexInsert], index, path=["response"])
+
+ @pytest.mark.skip()
+ @parametrize
+ def test_streaming_response_insert(self, client: Cloudflare) -> None:
+ with client.vectorize.indexes.with_streaming_response.insert(
+ "example-index",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ body={},
+ ) as response:
+ assert not response.is_closed
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+
+ index = response.parse()
+ assert_matches_type(Optional[IndexInsert], index, path=["response"])
+
+ assert cast(Any, response.is_closed) is True
+
+ @pytest.mark.skip()
+ @parametrize
+ def test_path_params_insert(self, client: Cloudflare) -> None:
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
+ client.vectorize.indexes.with_raw_response.insert(
+ "example-index",
+ account_id="",
+ body={},
+ )
+
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `index_name` but received ''"):
+ client.vectorize.indexes.with_raw_response.insert(
+ "",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ body={},
+ )
+
+ @pytest.mark.skip()
+ @parametrize
+ def test_method_query(self, client: Cloudflare) -> None:
+ index = client.vectorize.indexes.query(
+ "example-index",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ vector=[0.5, 0.5, 0.5],
+ )
+ assert_matches_type(Optional[IndexQuery], index, path=["response"])
+
+ @pytest.mark.skip()
+ @parametrize
+ def test_method_query_with_all_params(self, client: Cloudflare) -> None:
+ index = client.vectorize.indexes.query(
+ "example-index",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ vector=[0.5, 0.5, 0.5],
+ filter={
+ "has_viewed": {"$ne": True},
+ "streaming_platform": "netflix",
+ },
+ return_metadata=True,
+ return_values=True,
+ top_k=5,
+ )
+ assert_matches_type(Optional[IndexQuery], index, path=["response"])
+
+ @pytest.mark.skip()
+ @parametrize
+ def test_raw_response_query(self, client: Cloudflare) -> None:
+ response = client.vectorize.indexes.with_raw_response.query(
+ "example-index",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ vector=[0.5, 0.5, 0.5],
+ )
+
+ assert response.is_closed is True
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+ index = response.parse()
+ assert_matches_type(Optional[IndexQuery], index, path=["response"])
+
+ @pytest.mark.skip()
+ @parametrize
+ def test_streaming_response_query(self, client: Cloudflare) -> None:
+ with client.vectorize.indexes.with_streaming_response.query(
+ "example-index",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ vector=[0.5, 0.5, 0.5],
+ ) as response:
+ assert not response.is_closed
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+
+ index = response.parse()
+ assert_matches_type(Optional[IndexQuery], index, path=["response"])
+
+ assert cast(Any, response.is_closed) is True
+
+ @pytest.mark.skip()
+ @parametrize
+ def test_path_params_query(self, client: Cloudflare) -> None:
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
+ client.vectorize.indexes.with_raw_response.query(
+ "example-index",
+ account_id="",
+ vector=[0.5, 0.5, 0.5],
+ )
+
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `index_name` but received ''"):
+ client.vectorize.indexes.with_raw_response.query(
+ "",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ vector=[0.5, 0.5, 0.5],
+ )
+
+ @pytest.mark.skip()
+ @parametrize
+ def test_method_upsert(self, client: Cloudflare) -> None:
+ index = client.vectorize.indexes.upsert(
+ "example-index",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ body={},
+ )
+ assert_matches_type(Optional[IndexUpsert], index, path=["response"])
+
+ @pytest.mark.skip()
+ @parametrize
+ def test_raw_response_upsert(self, client: Cloudflare) -> None:
+ response = client.vectorize.indexes.with_raw_response.upsert(
+ "example-index",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ body={},
+ )
+
+ assert response.is_closed is True
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+ index = response.parse()
+ assert_matches_type(Optional[IndexUpsert], index, path=["response"])
+
+ @pytest.mark.skip()
+ @parametrize
+ def test_streaming_response_upsert(self, client: Cloudflare) -> None:
+ with client.vectorize.indexes.with_streaming_response.upsert(
+ "example-index",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ body={},
+ ) as response:
+ assert not response.is_closed
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+
+ index = response.parse()
+ assert_matches_type(Optional[IndexUpsert], index, path=["response"])
+
+ assert cast(Any, response.is_closed) is True
+
+ @pytest.mark.skip()
+ @parametrize
+ def test_path_params_upsert(self, client: Cloudflare) -> None:
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
+ client.vectorize.indexes.with_raw_response.upsert(
+ "example-index",
+ account_id="",
+ body={},
+ )
+
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `index_name` but received ''"):
+ client.vectorize.indexes.with_raw_response.upsert(
+ "",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ body={},
+ )
+
+
+class TestAsyncIndexes:
+ parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"])
+
+ @pytest.mark.skip()
+ @parametrize
+ async def test_method_create(self, async_client: AsyncCloudflare) -> None:
+ index = await async_client.vectorize.indexes.create(
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ config={
+ "dimensions": 768,
+ "metric": "cosine",
+ },
+ name="example-index",
+ )
+ assert_matches_type(Optional[CreateIndex], index, path=["response"])
+
+ @pytest.mark.skip()
+ @parametrize
+ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None:
+ index = await async_client.vectorize.indexes.create(
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ config={
+ "dimensions": 768,
+ "metric": "cosine",
+ },
+ name="example-index",
+ description="This is my example index.",
+ )
+ assert_matches_type(Optional[CreateIndex], index, path=["response"])
+
+ @pytest.mark.skip()
+ @parametrize
+ async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None:
+ response = await async_client.vectorize.indexes.with_raw_response.create(
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ config={
+ "dimensions": 768,
+ "metric": "cosine",
+ },
+ name="example-index",
+ )
+
+ assert response.is_closed is True
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+ index = await response.parse()
+ assert_matches_type(Optional[CreateIndex], index, path=["response"])
+
+ @pytest.mark.skip()
+ @parametrize
+ async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None:
+ async with async_client.vectorize.indexes.with_streaming_response.create(
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ config={
+ "dimensions": 768,
+ "metric": "cosine",
+ },
+ name="example-index",
+ ) as response:
+ assert not response.is_closed
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+
+ index = await response.parse()
+ assert_matches_type(Optional[CreateIndex], index, path=["response"])
+
+ assert cast(Any, response.is_closed) is True
+
+ @pytest.mark.skip()
+ @parametrize
+ async def test_path_params_create(self, async_client: AsyncCloudflare) -> None:
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
+ await async_client.vectorize.indexes.with_raw_response.create(
+ account_id="",
+ config={
+ "dimensions": 768,
+ "metric": "cosine",
+ },
+ name="example-index",
+ )
+
+ @pytest.mark.skip()
+ @parametrize
+ async def test_method_update(self, async_client: AsyncCloudflare) -> None:
+ index = await async_client.vectorize.indexes.update(
+ "example-index",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ description="This is my example index.",
+ )
+ assert_matches_type(Optional[CreateIndex], index, path=["response"])
+
+ @pytest.mark.skip()
+ @parametrize
+ async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None:
+ response = await async_client.vectorize.indexes.with_raw_response.update(
+ "example-index",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ description="This is my example index.",
+ )
+
+ assert response.is_closed is True
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+ index = await response.parse()
+ assert_matches_type(Optional[CreateIndex], index, path=["response"])
+
+ @pytest.mark.skip()
+ @parametrize
+ async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None:
+ async with async_client.vectorize.indexes.with_streaming_response.update(
+ "example-index",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ description="This is my example index.",
+ ) as response:
+ assert not response.is_closed
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+
+ index = await response.parse()
+ assert_matches_type(Optional[CreateIndex], index, path=["response"])
+
+ assert cast(Any, response.is_closed) is True
+
+ @pytest.mark.skip()
+ @parametrize
+ async def test_path_params_update(self, async_client: AsyncCloudflare) -> None:
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
+ await async_client.vectorize.indexes.with_raw_response.update(
+ "example-index",
+ account_id="",
+ description="This is my example index.",
+ )
+
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `index_name` but received ''"):
+ await async_client.vectorize.indexes.with_raw_response.update(
+ "",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ description="This is my example index.",
+ )
+
+ @pytest.mark.skip()
+ @parametrize
+ async def test_method_list(self, async_client: AsyncCloudflare) -> None:
+ index = await async_client.vectorize.indexes.list(
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ )
+ assert_matches_type(AsyncSinglePage[CreateIndex], index, path=["response"])
+
+ @pytest.mark.skip()
+ @parametrize
+ async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None:
+ response = await async_client.vectorize.indexes.with_raw_response.list(
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ )
+
+ assert response.is_closed is True
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+ index = await response.parse()
+ assert_matches_type(AsyncSinglePage[CreateIndex], index, path=["response"])
+
+ @pytest.mark.skip()
+ @parametrize
+ async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None:
+ async with async_client.vectorize.indexes.with_streaming_response.list(
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ ) as response:
+ assert not response.is_closed
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+
+ index = await response.parse()
+ assert_matches_type(AsyncSinglePage[CreateIndex], index, path=["response"])
+
+ assert cast(Any, response.is_closed) is True
+
+ @pytest.mark.skip()
+ @parametrize
+ async def test_path_params_list(self, async_client: AsyncCloudflare) -> None:
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
+ await async_client.vectorize.indexes.with_raw_response.list(
+ account_id="",
+ )
+
+ @pytest.mark.skip()
+ @parametrize
+ async def test_method_delete(self, async_client: AsyncCloudflare) -> None:
+ index = await async_client.vectorize.indexes.delete(
+ "example-index",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ )
+ assert_matches_type(IndexDeleteResponse, index, path=["response"])
+
+ @pytest.mark.skip()
+ @parametrize
+ async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None:
+ response = await async_client.vectorize.indexes.with_raw_response.delete(
+ "example-index",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ )
+
+ assert response.is_closed is True
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+ index = await response.parse()
+ assert_matches_type(IndexDeleteResponse, index, path=["response"])
+
+ @pytest.mark.skip()
+ @parametrize
+ async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None:
+ async with async_client.vectorize.indexes.with_streaming_response.delete(
+ "example-index",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ ) as response:
+ assert not response.is_closed
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+
+ index = await response.parse()
+ assert_matches_type(IndexDeleteResponse, index, path=["response"])
+
+ assert cast(Any, response.is_closed) is True
+
+ @pytest.mark.skip()
+ @parametrize
+ async def test_path_params_delete(self, async_client: AsyncCloudflare) -> None:
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
+ await async_client.vectorize.indexes.with_raw_response.delete(
+ "example-index",
+ account_id="",
+ )
+
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `index_name` but received ''"):
+ await async_client.vectorize.indexes.with_raw_response.delete(
+ "",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ )
+
+ @pytest.mark.skip()
+ @parametrize
+ async def test_method_delete_by_ids(self, async_client: AsyncCloudflare) -> None:
+ index = await async_client.vectorize.indexes.delete_by_ids(
+ "example-index",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ )
+ assert_matches_type(Optional[IndexDeleteVectorsByID], index, path=["response"])
+
+ @pytest.mark.skip()
+ @parametrize
+ async def test_method_delete_by_ids_with_all_params(self, async_client: AsyncCloudflare) -> None:
+ index = await async_client.vectorize.indexes.delete_by_ids(
+ "example-index",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ ids=["5121db81354a40c6aedc3fe1ace51c59", "f90eb49c2107486abdfd78c67e853430"],
+ )
+ assert_matches_type(Optional[IndexDeleteVectorsByID], index, path=["response"])
+
+ @pytest.mark.skip()
+ @parametrize
+ async def test_raw_response_delete_by_ids(self, async_client: AsyncCloudflare) -> None:
+ response = await async_client.vectorize.indexes.with_raw_response.delete_by_ids(
+ "example-index",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ )
+
+ assert response.is_closed is True
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+ index = await response.parse()
+ assert_matches_type(Optional[IndexDeleteVectorsByID], index, path=["response"])
+
+ @pytest.mark.skip()
+ @parametrize
+ async def test_streaming_response_delete_by_ids(self, async_client: AsyncCloudflare) -> None:
+ async with async_client.vectorize.indexes.with_streaming_response.delete_by_ids(
+ "example-index",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ ) as response:
+ assert not response.is_closed
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+
+ index = await response.parse()
+ assert_matches_type(Optional[IndexDeleteVectorsByID], index, path=["response"])
+
+ assert cast(Any, response.is_closed) is True
+
+ @pytest.mark.skip()
+ @parametrize
+ async def test_path_params_delete_by_ids(self, async_client: AsyncCloudflare) -> None:
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
+ await async_client.vectorize.indexes.with_raw_response.delete_by_ids(
+ "example-index",
+ account_id="",
+ )
+
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `index_name` but received ''"):
+ await async_client.vectorize.indexes.with_raw_response.delete_by_ids(
+ "",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ )
+
+ @pytest.mark.skip()
+ @parametrize
+ async def test_method_get(self, async_client: AsyncCloudflare) -> None:
+ index = await async_client.vectorize.indexes.get(
+ "example-index",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ )
+ assert_matches_type(Optional[CreateIndex], index, path=["response"])
+
+ @pytest.mark.skip()
+ @parametrize
+ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None:
+ response = await async_client.vectorize.indexes.with_raw_response.get(
+ "example-index",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ )
+
+ assert response.is_closed is True
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+ index = await response.parse()
+ assert_matches_type(Optional[CreateIndex], index, path=["response"])
+
+ @pytest.mark.skip()
+ @parametrize
+ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None:
+ async with async_client.vectorize.indexes.with_streaming_response.get(
+ "example-index",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ ) as response:
+ assert not response.is_closed
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+
+ index = await response.parse()
+ assert_matches_type(Optional[CreateIndex], index, path=["response"])
+
+ assert cast(Any, response.is_closed) is True
+
+ @pytest.mark.skip()
+ @parametrize
+ async def test_path_params_get(self, async_client: AsyncCloudflare) -> None:
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
+ await async_client.vectorize.indexes.with_raw_response.get(
+ "example-index",
+ account_id="",
+ )
+
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `index_name` but received ''"):
+ await async_client.vectorize.indexes.with_raw_response.get(
+ "",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ )
+
+ @pytest.mark.skip()
+ @parametrize
+ async def test_method_get_by_ids(self, async_client: AsyncCloudflare) -> None:
+ index = await async_client.vectorize.indexes.get_by_ids(
+ "example-index",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ )
+ assert_matches_type(object, index, path=["response"])
+
+ @pytest.mark.skip()
+ @parametrize
+ async def test_method_get_by_ids_with_all_params(self, async_client: AsyncCloudflare) -> None:
+ index = await async_client.vectorize.indexes.get_by_ids(
+ "example-index",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ ids=["5121db81354a40c6aedc3fe1ace51c59", "f90eb49c2107486abdfd78c67e853430"],
+ )
+ assert_matches_type(object, index, path=["response"])
+
+ @pytest.mark.skip()
+ @parametrize
+ async def test_raw_response_get_by_ids(self, async_client: AsyncCloudflare) -> None:
+ response = await async_client.vectorize.indexes.with_raw_response.get_by_ids(
+ "example-index",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ )
+
+ assert response.is_closed is True
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+ index = await response.parse()
+ assert_matches_type(object, index, path=["response"])
+
+ @pytest.mark.skip()
+ @parametrize
+ async def test_streaming_response_get_by_ids(self, async_client: AsyncCloudflare) -> None:
+ async with async_client.vectorize.indexes.with_streaming_response.get_by_ids(
+ "example-index",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ ) as response:
+ assert not response.is_closed
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+
+ index = await response.parse()
+ assert_matches_type(object, index, path=["response"])
+
+ assert cast(Any, response.is_closed) is True
+
+ @pytest.mark.skip()
+ @parametrize
+ async def test_path_params_get_by_ids(self, async_client: AsyncCloudflare) -> None:
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
+ await async_client.vectorize.indexes.with_raw_response.get_by_ids(
+ "example-index",
+ account_id="",
+ )
+
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `index_name` but received ''"):
+ await async_client.vectorize.indexes.with_raw_response.get_by_ids(
+ "",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ )
+
+ @pytest.mark.skip()
+ @parametrize
+ async def test_method_insert(self, async_client: AsyncCloudflare) -> None:
+ index = await async_client.vectorize.indexes.insert(
+ "example-index",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ body={},
+ )
+ assert_matches_type(Optional[IndexInsert], index, path=["response"])
+
+ @pytest.mark.skip()
+ @parametrize
+ async def test_raw_response_insert(self, async_client: AsyncCloudflare) -> None:
+ response = await async_client.vectorize.indexes.with_raw_response.insert(
+ "example-index",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ body={},
+ )
+
+ assert response.is_closed is True
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+ index = await response.parse()
+ assert_matches_type(Optional[IndexInsert], index, path=["response"])
+
+ @pytest.mark.skip()
+ @parametrize
+ async def test_streaming_response_insert(self, async_client: AsyncCloudflare) -> None:
+ async with async_client.vectorize.indexes.with_streaming_response.insert(
+ "example-index",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ body={},
+ ) as response:
+ assert not response.is_closed
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+
+ index = await response.parse()
+ assert_matches_type(Optional[IndexInsert], index, path=["response"])
+
+ assert cast(Any, response.is_closed) is True
+
+ @pytest.mark.skip()
+ @parametrize
+ async def test_path_params_insert(self, async_client: AsyncCloudflare) -> None:
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
+ await async_client.vectorize.indexes.with_raw_response.insert(
+ "example-index",
+ account_id="",
+ body={},
+ )
+
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `index_name` but received ''"):
+ await async_client.vectorize.indexes.with_raw_response.insert(
+ "",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ body={},
+ )
+
+ @pytest.mark.skip()
+ @parametrize
+ async def test_method_query(self, async_client: AsyncCloudflare) -> None:
+ index = await async_client.vectorize.indexes.query(
+ "example-index",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ vector=[0.5, 0.5, 0.5],
+ )
+ assert_matches_type(Optional[IndexQuery], index, path=["response"])
+
+ @pytest.mark.skip()
+ @parametrize
+ async def test_method_query_with_all_params(self, async_client: AsyncCloudflare) -> None:
+ index = await async_client.vectorize.indexes.query(
+ "example-index",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ vector=[0.5, 0.5, 0.5],
+ filter={
+ "has_viewed": {"$ne": True},
+ "streaming_platform": "netflix",
+ },
+ return_metadata=True,
+ return_values=True,
+ top_k=5,
+ )
+ assert_matches_type(Optional[IndexQuery], index, path=["response"])
+
+ @pytest.mark.skip()
+ @parametrize
+ async def test_raw_response_query(self, async_client: AsyncCloudflare) -> None:
+ response = await async_client.vectorize.indexes.with_raw_response.query(
+ "example-index",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ vector=[0.5, 0.5, 0.5],
+ )
+
+ assert response.is_closed is True
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+ index = await response.parse()
+ assert_matches_type(Optional[IndexQuery], index, path=["response"])
+
+ @pytest.mark.skip()
+ @parametrize
+ async def test_streaming_response_query(self, async_client: AsyncCloudflare) -> None:
+ async with async_client.vectorize.indexes.with_streaming_response.query(
+ "example-index",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ vector=[0.5, 0.5, 0.5],
+ ) as response:
+ assert not response.is_closed
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+
+ index = await response.parse()
+ assert_matches_type(Optional[IndexQuery], index, path=["response"])
+
+ assert cast(Any, response.is_closed) is True
+
+ @pytest.mark.skip()
+ @parametrize
+ async def test_path_params_query(self, async_client: AsyncCloudflare) -> None:
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
+ await async_client.vectorize.indexes.with_raw_response.query(
+ "example-index",
+ account_id="",
+ vector=[0.5, 0.5, 0.5],
+ )
+
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `index_name` but received ''"):
+ await async_client.vectorize.indexes.with_raw_response.query(
+ "",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ vector=[0.5, 0.5, 0.5],
+ )
+
+ @pytest.mark.skip()
+ @parametrize
+ async def test_method_upsert(self, async_client: AsyncCloudflare) -> None:
+ index = await async_client.vectorize.indexes.upsert(
+ "example-index",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ body={},
+ )
+ assert_matches_type(Optional[IndexUpsert], index, path=["response"])
+
+ @pytest.mark.skip()
+ @parametrize
+ async def test_raw_response_upsert(self, async_client: AsyncCloudflare) -> None:
+ response = await async_client.vectorize.indexes.with_raw_response.upsert(
+ "example-index",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ body={},
+ )
+
+ assert response.is_closed is True
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+ index = await response.parse()
+ assert_matches_type(Optional[IndexUpsert], index, path=["response"])
+
+ @pytest.mark.skip()
+ @parametrize
+ async def test_streaming_response_upsert(self, async_client: AsyncCloudflare) -> None:
+ async with async_client.vectorize.indexes.with_streaming_response.upsert(
+ "example-index",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ body={},
+ ) as response:
+ assert not response.is_closed
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+
+ index = await response.parse()
+ assert_matches_type(Optional[IndexUpsert], index, path=["response"])
+
+ assert cast(Any, response.is_closed) is True
+
+ @pytest.mark.skip()
+ @parametrize
+ async def test_path_params_upsert(self, async_client: AsyncCloudflare) -> None:
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
+ await async_client.vectorize.indexes.with_raw_response.upsert(
+ "example-index",
+ account_id="",
+ body={},
+ )
+
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `index_name` but received ''"):
+ await async_client.vectorize.indexes.with_raw_response.upsert(
+ "",
+ account_id="023e105f4ecef8ad9ca31a8372d0c353",
+ body={},
+ )