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
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
configured_endpoints: 92
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/datamini%2Fasktable-812fbef9135838630557abadedcc8c593c10d2133388aaea70b9a313fc546941.yml
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/datamini%2Fasktable-8db0b80dcaf777d02fd5720543576e1484e9dc93db7c1b50a11ee85c215f88b4.yml
18 changes: 9 additions & 9 deletions src/asktable/resources/datasources/datasources.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from __future__ import annotations

from typing import List, Mapping, Optional, cast
from typing import Mapping, Optional, cast
from typing_extensions import Literal

import httpx
Expand Down Expand Up @@ -351,7 +351,7 @@ def add_files(
self,
datasource_id: str,
*,
files: List[FileTypes],
file: 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 @@ -373,16 +373,16 @@ def add_files(
"""
if not datasource_id:
raise ValueError(f"Expected a non-empty value for `datasource_id` but received {datasource_id!r}")
body = deepcopy_minimal({"files": files})
extracted_files = extract_files(cast(Mapping[str, object], body), paths=[["files", "<array>"]])
body = deepcopy_minimal({"file": file})
files = extract_files(cast(Mapping[str, object], body), paths=[["file"]])
# It should be noted that the actual Content-Type header that will be
# sent to the server will contain a `boundary` parameter, e.g.
# multipart/form-data; boundary=---abc--
extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})}
return self._post(
f"/datasources/{datasource_id}/files",
body=maybe_transform(body, datasource_add_files_params.DatasourceAddFilesParams),
files=extracted_files,
files=files,
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
Expand Down Expand Up @@ -717,7 +717,7 @@ async def add_files(
self,
datasource_id: str,
*,
files: List[FileTypes],
file: 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 @@ -739,16 +739,16 @@ async def add_files(
"""
if not datasource_id:
raise ValueError(f"Expected a non-empty value for `datasource_id` but received {datasource_id!r}")
body = deepcopy_minimal({"files": files})
extracted_files = extract_files(cast(Mapping[str, object], body), paths=[["files", "<array>"]])
body = deepcopy_minimal({"file": file})
files = extract_files(cast(Mapping[str, object], body), paths=[["file"]])
# It should be noted that the actual Content-Type header that will be
# sent to the server will contain a `boundary` parameter, e.g.
# multipart/form-data; boundary=---abc--
extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})}
return await self._post(
f"/datasources/{datasource_id}/files",
body=await async_maybe_transform(body, datasource_add_files_params.DatasourceAddFilesParams),
files=extracted_files,
files=files,
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
Expand Down
3 changes: 1 addition & 2 deletions src/asktable/types/datasource_add_files_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

from __future__ import annotations

from typing import List
from typing_extensions import Required, TypedDict

from .._types import FileTypes
Expand All @@ -11,4 +10,4 @@


class DatasourceAddFilesParams(TypedDict, total=False):
files: Required[List[FileTypes]]
file: Required[FileTypes]
16 changes: 8 additions & 8 deletions tests/api_resources/test_datasources.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,15 +248,15 @@ def test_path_params_delete(self, client: Asktable) -> None:
def test_method_add_files(self, client: Asktable) -> None:
datasource = client.datasources.add_files(
datasource_id="datasource_id",
files=[b"raw file contents"],
file=b"raw file contents",
)
assert_matches_type(object, datasource, path=["response"])

@parametrize
def test_raw_response_add_files(self, client: Asktable) -> None:
response = client.datasources.with_raw_response.add_files(
datasource_id="datasource_id",
files=[b"raw file contents"],
file=b"raw file contents",
)

assert response.is_closed is True
Expand All @@ -268,7 +268,7 @@ def test_raw_response_add_files(self, client: Asktable) -> None:
def test_streaming_response_add_files(self, client: Asktable) -> None:
with client.datasources.with_streaming_response.add_files(
datasource_id="datasource_id",
files=[b"raw file contents"],
file=b"raw file contents",
) as response:
assert not response.is_closed
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
Expand All @@ -283,7 +283,7 @@ def test_path_params_add_files(self, client: Asktable) -> None:
with pytest.raises(ValueError, match=r"Expected a non-empty value for `datasource_id` but received ''"):
client.datasources.with_raw_response.add_files(
datasource_id="",
files=[b"raw file contents"],
file=b"raw file contents",
)

@parametrize
Expand Down Expand Up @@ -565,15 +565,15 @@ async def test_path_params_delete(self, async_client: AsyncAsktable) -> None:
async def test_method_add_files(self, async_client: AsyncAsktable) -> None:
datasource = await async_client.datasources.add_files(
datasource_id="datasource_id",
files=[b"raw file contents"],
file=b"raw file contents",
)
assert_matches_type(object, datasource, path=["response"])

@parametrize
async def test_raw_response_add_files(self, async_client: AsyncAsktable) -> None:
response = await async_client.datasources.with_raw_response.add_files(
datasource_id="datasource_id",
files=[b"raw file contents"],
file=b"raw file contents",
)

assert response.is_closed is True
Expand All @@ -585,7 +585,7 @@ async def test_raw_response_add_files(self, async_client: AsyncAsktable) -> None
async def test_streaming_response_add_files(self, async_client: AsyncAsktable) -> None:
async with async_client.datasources.with_streaming_response.add_files(
datasource_id="datasource_id",
files=[b"raw file contents"],
file=b"raw file contents",
) as response:
assert not response.is_closed
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
Expand All @@ -600,7 +600,7 @@ async def test_path_params_add_files(self, async_client: AsyncAsktable) -> None:
with pytest.raises(ValueError, match=r"Expected a non-empty value for `datasource_id` but received ''"):
await async_client.datasources.with_raw_response.add_files(
datasource_id="",
files=[b"raw file contents"],
file=b"raw file contents",
)

@parametrize
Expand Down