feat(api): OpenAPI spec update via Stainless API (#527)

This commit is contained in:
stainless-app[bot] 2024-05-15 22:35:23 +00:00 committed by stainless-bot
parent 64f7884c78
commit 6337e4591f
4 changed files with 41 additions and 27 deletions

View file

@ -6,7 +6,7 @@ from typing import Any, List, Type, Iterable, Optional, cast
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,
@ -375,7 +375,7 @@ class IndexesResource(SyncAPIResource):
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,
@ -390,6 +390,8 @@ class IndexesResource(SyncAPIResource):
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
@ -487,7 +489,7 @@ class IndexesResource(SyncAPIResource):
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,
@ -502,6 +504,8 @@ class IndexesResource(SyncAPIResource):
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
@ -859,7 +863,7 @@ class AsyncIndexesResource(AsyncAPIResource):
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,
@ -874,6 +878,8 @@ class AsyncIndexesResource(AsyncAPIResource):
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
@ -971,7 +977,7 @@ class AsyncIndexesResource(AsyncAPIResource):
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,
@ -986,6 +992,8 @@ class AsyncIndexesResource(AsyncAPIResource):
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

View file

@ -4,6 +4,8 @@ from __future__ import annotations
from typing_extensions import Required, TypedDict
from ..._types import FileTypes
__all__ = ["IndexInsertParams"]
@ -11,4 +13,5 @@ class IndexInsertParams(TypedDict, total=False):
account_id: Required[str]
"""Identifier"""
body: Required[object]
body: Required[FileTypes]
"""ndjson file containing vectors to insert."""

View file

@ -4,6 +4,8 @@ from __future__ import annotations
from typing_extensions import Required, TypedDict
from ..._types import FileTypes
__all__ = ["IndexUpsertParams"]
@ -11,4 +13,5 @@ class IndexUpsertParams(TypedDict, total=False):
account_id: Required[str]
"""Identifier"""
body: Required[object]
body: Required[FileTypes]
"""ndjson file containing vectors to upsert."""

View file

@ -403,7 +403,7 @@ class TestIndexes:
index = client.vectorize.indexes.insert(
"example-index",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
body={},
body=b"raw file contents",
)
assert_matches_type(Optional[IndexInsert], index, path=["response"])
@ -413,7 +413,7 @@ class TestIndexes:
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
@ -427,7 +427,7 @@ class TestIndexes:
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"
@ -444,14 +444,14 @@ class TestIndexes:
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
@ -529,7 +529,7 @@ class TestIndexes:
index = client.vectorize.indexes.upsert(
"example-index",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
body={},
body=b"raw file contents",
)
assert_matches_type(Optional[IndexUpsert], index, path=["response"])
@ -539,7 +539,7 @@ class TestIndexes:
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
@ -553,7 +553,7 @@ class TestIndexes:
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"
@ -570,14 +570,14 @@ class TestIndexes:
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",
)
@ -962,7 +962,7 @@ class TestAsyncIndexes:
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"])
@ -972,7 +972,7 @@ class TestAsyncIndexes:
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
@ -986,7 +986,7 @@ class TestAsyncIndexes:
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"
@ -1003,14 +1003,14 @@ class TestAsyncIndexes:
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
@ -1088,7 +1088,7 @@ class TestAsyncIndexes:
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"])
@ -1098,7 +1098,7 @@ class TestAsyncIndexes:
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
@ -1112,7 +1112,7 @@ class TestAsyncIndexes:
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"
@ -1129,12 +1129,12 @@ class TestAsyncIndexes:
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",
)