Skip to content

Commit 08bb9e3

Browse files
feat(api): api update (#117)
1 parent dced8d4 commit 08bb9e3

File tree

4 files changed

+19
-20
lines changed

4 files changed

+19
-20
lines changed

.stats.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
configured_endpoints: 92
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/datamini%2Fasktable-812fbef9135838630557abadedcc8c593c10d2133388aaea70b9a313fc546941.yml
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/datamini%2Fasktable-8db0b80dcaf777d02fd5720543576e1484e9dc93db7c1b50a11ee85c215f88b4.yml

src/asktable/resources/datasources/datasources.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from __future__ import annotations
44

5-
from typing import List, Mapping, Optional, cast
5+
from typing import Mapping, Optional, cast
66
from typing_extensions import Literal
77

88
import httpx
@@ -351,7 +351,7 @@ def add_files(
351351
self,
352352
datasource_id: str,
353353
*,
354-
files: List[FileTypes],
354+
file: FileTypes,
355355
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
356356
# The extra values given here take precedence over values defined on the client or passed to this method.
357357
extra_headers: Headers | None = None,
@@ -373,16 +373,16 @@ def add_files(
373373
"""
374374
if not datasource_id:
375375
raise ValueError(f"Expected a non-empty value for `datasource_id` but received {datasource_id!r}")
376-
body = deepcopy_minimal({"files": files})
377-
extracted_files = extract_files(cast(Mapping[str, object], body), paths=[["files", "<array>"]])
376+
body = deepcopy_minimal({"file": file})
377+
files = extract_files(cast(Mapping[str, object], body), paths=[["file"]])
378378
# It should be noted that the actual Content-Type header that will be
379379
# sent to the server will contain a `boundary` parameter, e.g.
380380
# multipart/form-data; boundary=---abc--
381381
extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})}
382382
return self._post(
383383
f"/datasources/{datasource_id}/files",
384384
body=maybe_transform(body, datasource_add_files_params.DatasourceAddFilesParams),
385-
files=extracted_files,
385+
files=files,
386386
options=make_request_options(
387387
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
388388
),
@@ -782,7 +782,7 @@ async def add_files(
782782
self,
783783
datasource_id: str,
784784
*,
785-
files: List[FileTypes],
785+
file: FileTypes,
786786
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
787787
# The extra values given here take precedence over values defined on the client or passed to this method.
788788
extra_headers: Headers | None = None,
@@ -804,16 +804,16 @@ async def add_files(
804804
"""
805805
if not datasource_id:
806806
raise ValueError(f"Expected a non-empty value for `datasource_id` but received {datasource_id!r}")
807-
body = deepcopy_minimal({"files": files})
808-
extracted_files = extract_files(cast(Mapping[str, object], body), paths=[["files", "<array>"]])
807+
body = deepcopy_minimal({"file": file})
808+
files = extract_files(cast(Mapping[str, object], body), paths=[["file"]])
809809
# It should be noted that the actual Content-Type header that will be
810810
# sent to the server will contain a `boundary` parameter, e.g.
811811
# multipart/form-data; boundary=---abc--
812812
extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})}
813813
return await self._post(
814814
f"/datasources/{datasource_id}/files",
815815
body=await async_maybe_transform(body, datasource_add_files_params.DatasourceAddFilesParams),
816-
files=extracted_files,
816+
files=files,
817817
options=make_request_options(
818818
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
819819
),

src/asktable/types/datasource_add_files_params.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
from __future__ import annotations
44

5-
from typing import List
65
from typing_extensions import Required, TypedDict
76

87
from .._types import FileTypes
@@ -11,4 +10,4 @@
1110

1211

1312
class DatasourceAddFilesParams(TypedDict, total=False):
14-
files: Required[List[FileTypes]]
13+
file: Required[FileTypes]

tests/api_resources/test_datasources.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -248,15 +248,15 @@ def test_path_params_delete(self, client: Asktable) -> None:
248248
def test_method_add_files(self, client: Asktable) -> None:
249249
datasource = client.datasources.add_files(
250250
datasource_id="datasource_id",
251-
files=[b"raw file contents"],
251+
file=b"raw file contents",
252252
)
253253
assert_matches_type(object, datasource, path=["response"])
254254

255255
@parametrize
256256
def test_raw_response_add_files(self, client: Asktable) -> None:
257257
response = client.datasources.with_raw_response.add_files(
258258
datasource_id="datasource_id",
259-
files=[b"raw file contents"],
259+
file=b"raw file contents",
260260
)
261261

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

289289
@parametrize
@@ -565,15 +565,15 @@ async def test_path_params_delete(self, async_client: AsyncAsktable) -> None:
565565
async def test_method_add_files(self, async_client: AsyncAsktable) -> None:
566566
datasource = await async_client.datasources.add_files(
567567
datasource_id="datasource_id",
568-
files=[b"raw file contents"],
568+
file=b"raw file contents",
569569
)
570570
assert_matches_type(object, datasource, path=["response"])
571571

572572
@parametrize
573573
async def test_raw_response_add_files(self, async_client: AsyncAsktable) -> None:
574574
response = await async_client.datasources.with_raw_response.add_files(
575575
datasource_id="datasource_id",
576-
files=[b"raw file contents"],
576+
file=b"raw file contents",
577577
)
578578

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

606606
@parametrize

0 commit comments

Comments
 (0)