Skip to content

Commit 8ac4185

Browse files
stainless-app[bot]stainless-bot
authored andcommitted
feat(api): api update (#12)
1 parent f8e9649 commit 8ac4185

File tree

14 files changed

+428
-39
lines changed

14 files changed

+428
-39
lines changed

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
configured_endpoints: 67
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/datamini%2Fasktable-40b24dabc4429084d4928122661865fb5b2feebac81de578d7de95c4d351621c.yml
1+
configured_endpoints: 68
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/datamini%2Fasktable-f8d4f4ee9ccccf65054df0c205156f6022a8d207441b1494fa56bd950b44593b.yml

README.md

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ client = Asktable()
8484

8585
try:
8686
client.datasources.create(
87-
access_config={"engine": "mysql"},
87+
access_config={},
8888
engine="mysql",
8989
)
9090
except asktable.APIConnectionError as e:
@@ -130,7 +130,7 @@ client = Asktable(
130130

131131
# Or, configure per-request:
132132
client.with_options(max_retries=5).datasources.create(
133-
access_config={"engine": "mysql"},
133+
access_config={},
134134
engine="mysql",
135135
)
136136
```
@@ -156,7 +156,7 @@ client = Asktable(
156156

157157
# Override per-request:
158158
client.with_options(timeout=5.0).datasources.create(
159-
access_config={"engine": "mysql"},
159+
access_config={},
160160
engine="mysql",
161161
)
162162
```
@@ -198,9 +198,7 @@ from asktable import Asktable
198198

199199
client = Asktable()
200200
response = client.datasources.with_raw_response.create(
201-
access_config={
202-
"engine": "mysql"
203-
},
201+
access_config={},
204202
engine="mysql",
205203
)
206204
print(response.headers.get('X-My-Header'))
@@ -221,7 +219,7 @@ To stream the response body, use `.with_streaming_response` instead, which requi
221219

222220
```python
223221
with client.datasources.with_streaming_response.create(
224-
access_config={"engine": "mysql"},
222+
access_config={},
225223
engine="mysql",
226224
) as response:
227225
print(response.headers.get("X-My-Header"))

api.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,12 @@ Methods:
133133
- <code title="get /datasources">client.datasources.<a href="./src/asktable/resources/datasources/datasources.py">list</a>(\*\*<a href="src/asktable/types/datasource_list_params.py">params</a>) -> <a href="./src/asktable/types/datasource_list_response.py">DatasourceListResponse</a></code>
134134
- <code title="delete /datasources/{datasource_id}">client.datasources.<a href="./src/asktable/resources/datasources/datasources.py">delete</a>(datasource_id) -> <a href="./src/asktable/types/datasource_delete_response.py">object</a></code>
135135

136+
## File
137+
138+
Methods:
139+
140+
- <code title="post /datasources/file">client.datasources.file.<a href="./src/asktable/resources/datasources/file.py">create</a>(\*\*<a href="src/asktable/types/datasources/file_create_params.py">params</a>) -> <a href="./src/asktable/types/data_source.py">DataSource</a></code>
141+
136142
## Meta
137143

138144
Types:

src/asktable/resources/datasources/__init__.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
22

3+
from .file import (
4+
FileResource,
5+
AsyncFileResource,
6+
FileResourceWithRawResponse,
7+
AsyncFileResourceWithRawResponse,
8+
FileResourceWithStreamingResponse,
9+
AsyncFileResourceWithStreamingResponse,
10+
)
311
from .meta import (
412
MetaResource,
513
AsyncMetaResource,
@@ -26,6 +34,12 @@
2634
)
2735

2836
__all__ = [
37+
"FileResource",
38+
"AsyncFileResource",
39+
"FileResourceWithRawResponse",
40+
"AsyncFileResourceWithRawResponse",
41+
"FileResourceWithStreamingResponse",
42+
"AsyncFileResourceWithStreamingResponse",
2943
"MetaResource",
3044
"AsyncMetaResource",
3145
"MetaResourceWithRawResponse",

src/asktable/resources/datasources/datasources.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@
77

88
import httpx
99

10+
from .file import (
11+
FileResource,
12+
AsyncFileResource,
13+
FileResourceWithRawResponse,
14+
AsyncFileResourceWithRawResponse,
15+
FileResourceWithStreamingResponse,
16+
AsyncFileResourceWithStreamingResponse,
17+
)
1018
from .meta import (
1119
MetaResource,
1220
AsyncMetaResource,
@@ -45,6 +53,10 @@
4553

4654

4755
class DatasourcesResource(SyncAPIResource):
56+
@cached_property
57+
def file(self) -> FileResource:
58+
return FileResource(self._client)
59+
4860
@cached_property
4961
def meta(self) -> MetaResource:
5062
return MetaResource(self._client)
@@ -321,6 +333,10 @@ def delete(
321333

322334

323335
class AsyncDatasourcesResource(AsyncAPIResource):
336+
@cached_property
337+
def file(self) -> AsyncFileResource:
338+
return AsyncFileResource(self._client)
339+
324340
@cached_property
325341
def meta(self) -> AsyncMetaResource:
326342
return AsyncMetaResource(self._client)
@@ -616,6 +632,10 @@ def __init__(self, datasources: DatasourcesResource) -> None:
616632
datasources.delete,
617633
)
618634

635+
@cached_property
636+
def file(self) -> FileResourceWithRawResponse:
637+
return FileResourceWithRawResponse(self._datasources.file)
638+
619639
@cached_property
620640
def meta(self) -> MetaResourceWithRawResponse:
621641
return MetaResourceWithRawResponse(self._datasources.meta)
@@ -645,6 +665,10 @@ def __init__(self, datasources: AsyncDatasourcesResource) -> None:
645665
datasources.delete,
646666
)
647667

668+
@cached_property
669+
def file(self) -> AsyncFileResourceWithRawResponse:
670+
return AsyncFileResourceWithRawResponse(self._datasources.file)
671+
648672
@cached_property
649673
def meta(self) -> AsyncMetaResourceWithRawResponse:
650674
return AsyncMetaResourceWithRawResponse(self._datasources.meta)
@@ -674,6 +698,10 @@ def __init__(self, datasources: DatasourcesResource) -> None:
674698
datasources.delete,
675699
)
676700

701+
@cached_property
702+
def file(self) -> FileResourceWithStreamingResponse:
703+
return FileResourceWithStreamingResponse(self._datasources.file)
704+
677705
@cached_property
678706
def meta(self) -> MetaResourceWithStreamingResponse:
679707
return MetaResourceWithStreamingResponse(self._datasources.meta)
@@ -703,6 +731,10 @@ def __init__(self, datasources: AsyncDatasourcesResource) -> None:
703731
datasources.delete,
704732
)
705733

734+
@cached_property
735+
def file(self) -> AsyncFileResourceWithStreamingResponse:
736+
return AsyncFileResourceWithStreamingResponse(self._datasources.file)
737+
706738
@cached_property
707739
def meta(self) -> AsyncMetaResourceWithStreamingResponse:
708740
return AsyncMetaResourceWithStreamingResponse(self._datasources.meta)
Lines changed: 220 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,220 @@
1+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
from __future__ import annotations
4+
5+
from typing import Mapping, cast
6+
7+
import httpx
8+
9+
from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven, FileTypes
10+
from ..._utils import (
11+
extract_files,
12+
maybe_transform,
13+
deepcopy_minimal,
14+
async_maybe_transform,
15+
)
16+
from ..._compat import cached_property
17+
from ..._resource import SyncAPIResource, AsyncAPIResource
18+
from ..._response import (
19+
to_raw_response_wrapper,
20+
to_streamed_response_wrapper,
21+
async_to_raw_response_wrapper,
22+
async_to_streamed_response_wrapper,
23+
)
24+
from ..._base_client import make_request_options
25+
from ...types.data_source import DataSource
26+
from ...types.datasources import file_create_params
27+
28+
__all__ = ["FileResource", "AsyncFileResource"]
29+
30+
31+
class FileResource(SyncAPIResource):
32+
@cached_property
33+
def with_raw_response(self) -> FileResourceWithRawResponse:
34+
"""
35+
This property can be used as a prefix for any HTTP method call to return the
36+
the raw response object instead of the parsed content.
37+
38+
For more information, see https://www.github.com/DataMini/asktable-python#accessing-raw-response-data-eg-headers
39+
"""
40+
return FileResourceWithRawResponse(self)
41+
42+
@cached_property
43+
def with_streaming_response(self) -> FileResourceWithStreamingResponse:
44+
"""
45+
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
46+
47+
For more information, see https://www.github.com/DataMini/asktable-python#with_streaming_response
48+
"""
49+
return FileResourceWithStreamingResponse(self)
50+
51+
def create(
52+
self,
53+
*,
54+
name: str,
55+
file: FileTypes,
56+
async_process_meta: bool | NotGiven = NOT_GIVEN,
57+
skip_process_meta: bool | NotGiven = NOT_GIVEN,
58+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
59+
# The extra values given here take precedence over values defined on the client or passed to this method.
60+
extra_headers: Headers | None = None,
61+
extra_query: Query | None = None,
62+
extra_body: Body | None = None,
63+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
64+
) -> DataSource:
65+
"""
66+
上传文件并创建数据源
67+
68+
Args:
69+
async_process_meta: 是否异步处理元数据
70+
71+
skip_process_meta: 是否跳过元数据处理
72+
73+
extra_headers: Send extra headers
74+
75+
extra_query: Add additional query parameters to the request
76+
77+
extra_body: Add additional JSON properties to the request
78+
79+
timeout: Override the client-level default timeout for this request, in seconds
80+
"""
81+
body = deepcopy_minimal({"file": file})
82+
files = extract_files(cast(Mapping[str, object], body), paths=[["file"]])
83+
# It should be noted that the actual Content-Type header that will be
84+
# sent to the server will contain a `boundary` parameter, e.g.
85+
# multipart/form-data; boundary=---abc--
86+
extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})}
87+
return self._post(
88+
"/datasources/file",
89+
body=maybe_transform(body, file_create_params.FileCreateParams),
90+
files=files,
91+
options=make_request_options(
92+
extra_headers=extra_headers,
93+
extra_query=extra_query,
94+
extra_body=extra_body,
95+
timeout=timeout,
96+
query=maybe_transform(
97+
{
98+
"name": name,
99+
"async_process_meta": async_process_meta,
100+
"skip_process_meta": skip_process_meta,
101+
},
102+
file_create_params.FileCreateParams,
103+
),
104+
),
105+
cast_to=DataSource,
106+
)
107+
108+
109+
class AsyncFileResource(AsyncAPIResource):
110+
@cached_property
111+
def with_raw_response(self) -> AsyncFileResourceWithRawResponse:
112+
"""
113+
This property can be used as a prefix for any HTTP method call to return the
114+
the raw response object instead of the parsed content.
115+
116+
For more information, see https://www.github.com/DataMini/asktable-python#accessing-raw-response-data-eg-headers
117+
"""
118+
return AsyncFileResourceWithRawResponse(self)
119+
120+
@cached_property
121+
def with_streaming_response(self) -> AsyncFileResourceWithStreamingResponse:
122+
"""
123+
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
124+
125+
For more information, see https://www.github.com/DataMini/asktable-python#with_streaming_response
126+
"""
127+
return AsyncFileResourceWithStreamingResponse(self)
128+
129+
async def create(
130+
self,
131+
*,
132+
name: str,
133+
file: FileTypes,
134+
async_process_meta: bool | NotGiven = NOT_GIVEN,
135+
skip_process_meta: bool | NotGiven = NOT_GIVEN,
136+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
137+
# The extra values given here take precedence over values defined on the client or passed to this method.
138+
extra_headers: Headers | None = None,
139+
extra_query: Query | None = None,
140+
extra_body: Body | None = None,
141+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
142+
) -> DataSource:
143+
"""
144+
上传文件并创建数据源
145+
146+
Args:
147+
async_process_meta: 是否异步处理元数据
148+
149+
skip_process_meta: 是否跳过元数据处理
150+
151+
extra_headers: Send extra headers
152+
153+
extra_query: Add additional query parameters to the request
154+
155+
extra_body: Add additional JSON properties to the request
156+
157+
timeout: Override the client-level default timeout for this request, in seconds
158+
"""
159+
body = deepcopy_minimal({"file": file})
160+
files = extract_files(cast(Mapping[str, object], body), paths=[["file"]])
161+
# It should be noted that the actual Content-Type header that will be
162+
# sent to the server will contain a `boundary` parameter, e.g.
163+
# multipart/form-data; boundary=---abc--
164+
extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})}
165+
return await self._post(
166+
"/datasources/file",
167+
body=await async_maybe_transform(body, file_create_params.FileCreateParams),
168+
files=files,
169+
options=make_request_options(
170+
extra_headers=extra_headers,
171+
extra_query=extra_query,
172+
extra_body=extra_body,
173+
timeout=timeout,
174+
query=await async_maybe_transform(
175+
{
176+
"name": name,
177+
"async_process_meta": async_process_meta,
178+
"skip_process_meta": skip_process_meta,
179+
},
180+
file_create_params.FileCreateParams,
181+
),
182+
),
183+
cast_to=DataSource,
184+
)
185+
186+
187+
class FileResourceWithRawResponse:
188+
def __init__(self, file: FileResource) -> None:
189+
self._file = file
190+
191+
self.create = to_raw_response_wrapper(
192+
file.create,
193+
)
194+
195+
196+
class AsyncFileResourceWithRawResponse:
197+
def __init__(self, file: AsyncFileResource) -> None:
198+
self._file = file
199+
200+
self.create = async_to_raw_response_wrapper(
201+
file.create,
202+
)
203+
204+
205+
class FileResourceWithStreamingResponse:
206+
def __init__(self, file: FileResource) -> None:
207+
self._file = file
208+
209+
self.create = to_streamed_response_wrapper(
210+
file.create,
211+
)
212+
213+
214+
class AsyncFileResourceWithStreamingResponse:
215+
def __init__(self, file: AsyncFileResource) -> None:
216+
self._file = file
217+
218+
self.create = async_to_streamed_response_wrapper(
219+
file.create,
220+
)

0 commit comments

Comments
 (0)