Skip to content

Commit 4cbdddc

Browse files
stainless-app[bot]stainless-bot
authored andcommitted
feat(api): api update (#10)
1 parent 0956b01 commit 4cbdddc

File tree

11 files changed

+271
-42
lines changed

11 files changed

+271
-42
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: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ Methods:
132132
- <code title="patch /datasources/{datasource_id}">client.datasources.<a href="./src/asktable/resources/datasources/datasources.py">update</a>(datasource_id, \*\*<a href="src/asktable/types/datasource_update_params.py">params</a>) -> <a href="./src/asktable/types/data_source.py">DataSource</a></code>
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>
135+
- <code title="post /datasources/file">client.datasources.<a href="./src/asktable/resources/datasources/datasources.py">create_from_file</a>(\*\*<a href="src/asktable/types/datasource_create_from_file_params.py">params</a>) -> <a href="./src/asktable/types/data_source.py">DataSource</a></code>
135136

136137
## Meta
137138

src/asktable/resources/datasources/datasources.py

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

33
from __future__ import annotations
44

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

88
import httpx
@@ -15,10 +15,17 @@
1515
MetaResourceWithStreamingResponse,
1616
AsyncMetaResourceWithStreamingResponse,
1717
)
18-
from ...types import datasource_list_params, datasource_create_params, datasource_update_params
19-
from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven
18+
from ...types import (
19+
datasource_list_params,
20+
datasource_create_params,
21+
datasource_update_params,
22+
datasource_create_from_file_params,
23+
)
24+
from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven, FileTypes
2025
from ..._utils import (
26+
extract_files,
2127
maybe_transform,
28+
deepcopy_minimal,
2229
async_maybe_transform,
2330
)
2431
from ..._compat import cached_property
@@ -319,6 +326,63 @@ def delete(
319326
cast_to=object,
320327
)
321328

329+
def create_from_file(
330+
self,
331+
*,
332+
name: str,
333+
file: FileTypes,
334+
async_process_meta: bool | NotGiven = NOT_GIVEN,
335+
skip_process_meta: bool | NotGiven = NOT_GIVEN,
336+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
337+
# The extra values given here take precedence over values defined on the client or passed to this method.
338+
extra_headers: Headers | None = None,
339+
extra_query: Query | None = None,
340+
extra_body: Body | None = None,
341+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
342+
) -> DataSource:
343+
"""
344+
上传文件并创建数据源
345+
346+
Args:
347+
async_process_meta: 是否异步处理元数据
348+
349+
skip_process_meta: 是否跳过元数据处理
350+
351+
extra_headers: Send extra headers
352+
353+
extra_query: Add additional query parameters to the request
354+
355+
extra_body: Add additional JSON properties to the request
356+
357+
timeout: Override the client-level default timeout for this request, in seconds
358+
"""
359+
body = deepcopy_minimal({"file": file})
360+
files = extract_files(cast(Mapping[str, object], body), paths=[["file"]])
361+
# It should be noted that the actual Content-Type header that will be
362+
# sent to the server will contain a `boundary` parameter, e.g.
363+
# multipart/form-data; boundary=---abc--
364+
extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})}
365+
return self._post(
366+
"/datasources/file",
367+
body=maybe_transform(body, datasource_create_from_file_params.DatasourceCreateFromFileParams),
368+
files=files,
369+
options=make_request_options(
370+
extra_headers=extra_headers,
371+
extra_query=extra_query,
372+
extra_body=extra_body,
373+
timeout=timeout,
374+
query=maybe_transform(
375+
{
376+
"name": name,
377+
"async_process_meta": async_process_meta,
378+
"skip_process_meta": skip_process_meta,
379+
},
380+
datasource_create_from_file_params.DatasourceCreateFromFileParams,
381+
),
382+
),
383+
cast_to=DataSource,
384+
)
385+
322386

323387
class AsyncDatasourcesResource(AsyncAPIResource):
324388
@cached_property
@@ -595,6 +659,63 @@ async def delete(
595659
cast_to=object,
596660
)
597661

662+
async def create_from_file(
663+
self,
664+
*,
665+
name: str,
666+
file: FileTypes,
667+
async_process_meta: bool | NotGiven = NOT_GIVEN,
668+
skip_process_meta: bool | NotGiven = NOT_GIVEN,
669+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
670+
# The extra values given here take precedence over values defined on the client or passed to this method.
671+
extra_headers: Headers | None = None,
672+
extra_query: Query | None = None,
673+
extra_body: Body | None = None,
674+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
675+
) -> DataSource:
676+
"""
677+
上传文件并创建数据源
678+
679+
Args:
680+
async_process_meta: 是否异步处理元数据
681+
682+
skip_process_meta: 是否跳过元数据处理
683+
684+
extra_headers: Send extra headers
685+
686+
extra_query: Add additional query parameters to the request
687+
688+
extra_body: Add additional JSON properties to the request
689+
690+
timeout: Override the client-level default timeout for this request, in seconds
691+
"""
692+
body = deepcopy_minimal({"file": file})
693+
files = extract_files(cast(Mapping[str, object], body), paths=[["file"]])
694+
# It should be noted that the actual Content-Type header that will be
695+
# sent to the server will contain a `boundary` parameter, e.g.
696+
# multipart/form-data; boundary=---abc--
697+
extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})}
698+
return await self._post(
699+
"/datasources/file",
700+
body=await async_maybe_transform(body, datasource_create_from_file_params.DatasourceCreateFromFileParams),
701+
files=files,
702+
options=make_request_options(
703+
extra_headers=extra_headers,
704+
extra_query=extra_query,
705+
extra_body=extra_body,
706+
timeout=timeout,
707+
query=await async_maybe_transform(
708+
{
709+
"name": name,
710+
"async_process_meta": async_process_meta,
711+
"skip_process_meta": skip_process_meta,
712+
},
713+
datasource_create_from_file_params.DatasourceCreateFromFileParams,
714+
),
715+
),
716+
cast_to=DataSource,
717+
)
718+
598719

599720
class DatasourcesResourceWithRawResponse:
600721
def __init__(self, datasources: DatasourcesResource) -> None:
@@ -615,6 +736,9 @@ def __init__(self, datasources: DatasourcesResource) -> None:
615736
self.delete = to_raw_response_wrapper(
616737
datasources.delete,
617738
)
739+
self.create_from_file = to_raw_response_wrapper(
740+
datasources.create_from_file,
741+
)
618742

619743
@cached_property
620744
def meta(self) -> MetaResourceWithRawResponse:
@@ -644,6 +768,9 @@ def __init__(self, datasources: AsyncDatasourcesResource) -> None:
644768
self.delete = async_to_raw_response_wrapper(
645769
datasources.delete,
646770
)
771+
self.create_from_file = async_to_raw_response_wrapper(
772+
datasources.create_from_file,
773+
)
647774

648775
@cached_property
649776
def meta(self) -> AsyncMetaResourceWithRawResponse:
@@ -673,6 +800,9 @@ def __init__(self, datasources: DatasourcesResource) -> None:
673800
self.delete = to_streamed_response_wrapper(
674801
datasources.delete,
675802
)
803+
self.create_from_file = to_streamed_response_wrapper(
804+
datasources.create_from_file,
805+
)
676806

677807
@cached_property
678808
def meta(self) -> MetaResourceWithStreamingResponse:
@@ -702,6 +832,9 @@ def __init__(self, datasources: AsyncDatasourcesResource) -> None:
702832
self.delete = async_to_streamed_response_wrapper(
703833
datasources.delete,
704834
)
835+
self.create_from_file = async_to_streamed_response_wrapper(
836+
datasources.create_from_file,
837+
)
705838

706839
@cached_property
707840
def meta(self) -> AsyncMetaResourceWithStreamingResponse:

src/asktable/types/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,4 @@
4040
from .securetunnel_list_response import SecuretunnelListResponse as SecuretunnelListResponse
4141
from .securetunnel_update_params import SecuretunnelUpdateParams as SecuretunnelUpdateParams
4242
from .integration_excel_csv_ask_params import IntegrationExcelCsvAskParams as IntegrationExcelCsvAskParams
43+
from .datasource_create_from_file_params import DatasourceCreateFromFileParams as DatasourceCreateFromFileParams

src/asktable/types/data_source.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@
1010

1111

1212
class AccessConfig(BaseModel):
13-
engine: Literal["mysql", "tidb", "postgresql", "oceanbase", "clickhouse", "csv", "excel"]
14-
"""数据库引擎"""
15-
1613
db: Optional[str] = None
1714
"""数据库引擎可以管理多个数据库,此参数用于指定数据库名称"""
1815

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
from __future__ import annotations
4+
5+
from typing_extensions import Required, TypedDict
6+
7+
from .._types import FileTypes
8+
9+
__all__ = ["DatasourceCreateFromFileParams"]
10+
11+
12+
class DatasourceCreateFromFileParams(TypedDict, total=False):
13+
name: Required[str]
14+
15+
file: Required[FileTypes]
16+
17+
async_process_meta: bool
18+
"""是否异步处理元数据"""
19+
20+
skip_process_meta: bool
21+
"""是否跳过元数据处理"""

src/asktable/types/datasource_create_params.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@ class DatasourceCreateParams(TypedDict, total=False):
2626

2727

2828
class AccessConfig(TypedDict, total=False):
29-
engine: Required[Literal["mysql", "tidb", "postgresql", "oceanbase", "clickhouse", "csv", "excel"]]
30-
"""数据库引擎"""
31-
3229
db: Optional[str]
3330
"""数据库引擎可以管理多个数据库,此参数用于指定数据库名称"""
3431

src/asktable/types/datasource_update_params.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from __future__ import annotations
44

55
from typing import Optional
6-
from typing_extensions import Literal, Required, TypedDict
6+
from typing_extensions import Literal, TypedDict
77

88
__all__ = ["DatasourceUpdateParams", "AccessConfig"]
99

@@ -35,9 +35,6 @@ class DatasourceUpdateParams(TypedDict, total=False):
3535

3636

3737
class AccessConfig(TypedDict, total=False):
38-
engine: Required[Literal["mysql", "tidb", "postgresql", "oceanbase", "clickhouse", "csv", "excel"]]
39-
"""数据库引擎"""
40-
4138
db: Optional[str]
4239
"""数据库引擎可以管理多个数据库,此参数用于指定数据库名称"""
4340

0 commit comments

Comments
 (0)