Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions src/cloudflare/resources/vectorize/indexes.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import httpx

from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven
from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven, FileTypes
from ..._utils import (
maybe_transform,
async_maybe_transform,
Expand Down Expand Up @@ -375,7 +375,7 @@ def insert(
index_name: str,
*,
account_id: str,
body: object,
body: FileTypes,
# 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,
Expand All @@ -390,6 +390,8 @@ def insert(
Args:
account_id: Identifier

body: ndjson file containing vectors to insert.

extra_headers: Send extra headers

extra_query: Add additional query parameters to the request
Expand Down Expand Up @@ -487,7 +489,7 @@ def upsert(
index_name: str,
*,
account_id: str,
body: object,
body: FileTypes,
# 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,
Expand All @@ -502,6 +504,8 @@ def upsert(
Args:
account_id: Identifier

body: ndjson file containing vectors to upsert.

extra_headers: Send extra headers

extra_query: Add additional query parameters to the request
Expand Down Expand Up @@ -859,7 +863,7 @@ async def insert(
index_name: str,
*,
account_id: str,
body: object,
body: FileTypes,
# 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,
Expand All @@ -874,6 +878,8 @@ async def insert(
Args:
account_id: Identifier

body: ndjson file containing vectors to insert.

extra_headers: Send extra headers

extra_query: Add additional query parameters to the request
Expand Down Expand Up @@ -971,7 +977,7 @@ async def upsert(
index_name: str,
*,
account_id: str,
body: object,
body: FileTypes,
# 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,
Expand All @@ -986,6 +992,8 @@ async def upsert(
Args:
account_id: Identifier

body: ndjson file containing vectors to upsert.

extra_headers: Send extra headers

extra_query: Add additional query parameters to the request
Expand Down
5 changes: 4 additions & 1 deletion src/cloudflare/types/vectorize/index_insert_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@

from typing_extensions import Required, TypedDict

from ..._types import FileTypes

__all__ = ["IndexInsertParams"]


class IndexInsertParams(TypedDict, total=False):
account_id: Required[str]
"""Identifier"""

body: Required[object]
body: Required[FileTypes]
"""ndjson file containing vectors to insert."""
5 changes: 4 additions & 1 deletion src/cloudflare/types/vectorize/index_upsert_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@

from typing_extensions import Required, TypedDict

from ..._types import FileTypes

__all__ = ["IndexUpsertParams"]


class IndexUpsertParams(TypedDict, total=False):
account_id: Required[str]
"""Identifier"""

body: Required[object]
body: Required[FileTypes]
"""ndjson file containing vectors to upsert."""
40 changes: 20 additions & 20 deletions tests/api_resources/vectorize/test_indexes.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ def test_method_insert(self, client: Cloudflare) -> None:
index = client.vectorize.indexes.insert(
"example-index",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
body={},
body=b"raw file contents",
)
assert_matches_type(Optional[IndexInsert], index, path=["response"])

Expand All @@ -413,7 +413,7 @@ def test_raw_response_insert(self, client: Cloudflare) -> None:
response = client.vectorize.indexes.with_raw_response.insert(
"example-index",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
body={},
body=b"raw file contents",
)

assert response.is_closed is True
Expand All @@ -427,7 +427,7 @@ def test_streaming_response_insert(self, client: Cloudflare) -> None:
with client.vectorize.indexes.with_streaming_response.insert(
"example-index",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
body={},
body=b"raw file contents",
) as response:
assert not response.is_closed
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
Expand All @@ -444,14 +444,14 @@ def test_path_params_insert(self, client: Cloudflare) -> None:
client.vectorize.indexes.with_raw_response.insert(
"example-index",
account_id="",
body={},
body=b"raw file contents",
)

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={},
body=b"raw file contents",
)

@parametrize
Expand Down Expand Up @@ -529,7 +529,7 @@ def test_method_upsert(self, client: Cloudflare) -> None:
index = client.vectorize.indexes.upsert(
"example-index",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
body={},
body=b"raw file contents",
)
assert_matches_type(Optional[IndexUpsert], index, path=["response"])

Expand All @@ -539,7 +539,7 @@ def test_raw_response_upsert(self, client: Cloudflare) -> None:
response = client.vectorize.indexes.with_raw_response.upsert(
"example-index",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
body={},
body=b"raw file contents",
)

assert response.is_closed is True
Expand All @@ -553,7 +553,7 @@ def test_streaming_response_upsert(self, client: Cloudflare) -> None:
with client.vectorize.indexes.with_streaming_response.upsert(
"example-index",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
body={},
body=b"raw file contents",
) as response:
assert not response.is_closed
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
Expand All @@ -570,14 +570,14 @@ def test_path_params_upsert(self, client: Cloudflare) -> None:
client.vectorize.indexes.with_raw_response.upsert(
"example-index",
account_id="",
body={},
body=b"raw file contents",
)

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={},
body=b"raw file contents",
)


Expand Down Expand Up @@ -962,7 +962,7 @@ async def test_method_insert(self, async_client: AsyncCloudflare) -> None:
index = await async_client.vectorize.indexes.insert(
"example-index",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
body={},
body=b"raw file contents",
)
assert_matches_type(Optional[IndexInsert], index, path=["response"])

Expand All @@ -972,7 +972,7 @@ 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={},
body=b"raw file contents",
)

assert response.is_closed is True
Expand All @@ -986,7 +986,7 @@ async def test_streaming_response_insert(self, async_client: AsyncCloudflare) ->
async with async_client.vectorize.indexes.with_streaming_response.insert(
"example-index",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
body={},
body=b"raw file contents",
) as response:
assert not response.is_closed
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
Expand All @@ -1003,14 +1003,14 @@ async def test_path_params_insert(self, async_client: AsyncCloudflare) -> None:
await async_client.vectorize.indexes.with_raw_response.insert(
"example-index",
account_id="",
body={},
body=b"raw file contents",
)

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={},
body=b"raw file contents",
)

@parametrize
Expand Down Expand Up @@ -1088,7 +1088,7 @@ async def test_method_upsert(self, async_client: AsyncCloudflare) -> None:
index = await async_client.vectorize.indexes.upsert(
"example-index",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
body={},
body=b"raw file contents",
)
assert_matches_type(Optional[IndexUpsert], index, path=["response"])

Expand All @@ -1098,7 +1098,7 @@ 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={},
body=b"raw file contents",
)

assert response.is_closed is True
Expand All @@ -1112,7 +1112,7 @@ async def test_streaming_response_upsert(self, async_client: AsyncCloudflare) ->
async with async_client.vectorize.indexes.with_streaming_response.upsert(
"example-index",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
body={},
body=b"raw file contents",
) as response:
assert not response.is_closed
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
Expand All @@ -1129,12 +1129,12 @@ async def test_path_params_upsert(self, async_client: AsyncCloudflare) -> None:
await async_client.vectorize.indexes.with_raw_response.upsert(
"example-index",
account_id="",
body={},
body=b"raw file contents",
)

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={},
body=b"raw file contents",
)