Skip to content

Commit 029459f

Browse files
feat(api): api update (#101)
1 parent 1283ed2 commit 029459f

File tree

10 files changed

+188
-353
lines changed

10 files changed

+188
-353
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: 91
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/datamini%2Fasktable-25d01530668d8650b601a2f2d00c3859cb907a58fb4bb0f2324ba92802da6979.yml
1+
configured_endpoints: 90
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/datamini%2Fasktable-812fbef9135838630557abadedcc8c593c10d2133388aaea70b9a313fc546941.yml

api.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,17 +144,22 @@ Methods:
144144
Types:
145145

146146
```python
147-
from asktable.types import Datasource, Index, Meta, DatasourceDeleteResponse
147+
from asktable.types import (
148+
Datasource,
149+
Index,
150+
Meta,
151+
DatasourceRetrieveResponse,
152+
DatasourceDeleteResponse,
153+
)
148154
```
149155

150156
Methods:
151157

152158
- <code title="post /datasources">client.datasources.<a href="./src/asktable/resources/datasources/datasources.py">create</a>(\*\*<a href="src/asktable/types/datasource_create_params.py">params</a>) -> <a href="./src/asktable/types/datasource.py">Datasource</a></code>
153-
- <code title="get /datasources/{datasource_id}">client.datasources.<a href="./src/asktable/resources/datasources/datasources.py">retrieve</a>(datasource_id) -> <a href="./src/asktable/types/datasource.py">Datasource</a></code>
159+
- <code title="get /datasources/{datasource_id}">client.datasources.<a href="./src/asktable/resources/datasources/datasources.py">retrieve</a>(datasource_id) -> <a href="./src/asktable/types/datasource_retrieve_response.py">DatasourceRetrieveResponse</a></code>
154160
- <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/datasource.py">Datasource</a></code>
155161
- <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.py">SyncPage[Datasource]</a></code>
156162
- <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>
157-
- <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/datasource.py">Datasource</a></code>
158163

159164
## Meta
160165

src/asktable/resources/datasources/datasources.py

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

33
from __future__ import annotations
44

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

88
import httpx
@@ -15,12 +15,7 @@
1515
MetaResourceWithStreamingResponse,
1616
AsyncMetaResourceWithStreamingResponse,
1717
)
18-
from ...types import (
19-
datasource_list_params,
20-
datasource_create_params,
21-
datasource_update_params,
22-
datasource_create_from_file_params,
23-
)
18+
from ...types import datasource_list_params, datasource_create_params, datasource_update_params
2419
from .indexes import (
2520
IndexesResource,
2621
AsyncIndexesResource,
@@ -29,11 +24,9 @@
2924
IndexesResourceWithStreamingResponse,
3025
AsyncIndexesResourceWithStreamingResponse,
3126
)
32-
from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven, FileTypes
27+
from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven
3328
from ..._utils import (
34-
extract_files,
3529
maybe_transform,
36-
deepcopy_minimal,
3730
async_maybe_transform,
3831
)
3932
from ..._compat import cached_property
@@ -55,6 +48,7 @@
5548
)
5649
from ..._base_client import AsyncPaginator, make_request_options
5750
from ...types.datasource import Datasource
51+
from ...types.datasource_retrieve_response import DatasourceRetrieveResponse
5852

5953
__all__ = ["DatasourcesResource", "AsyncDatasourcesResource"]
6054

@@ -160,7 +154,7 @@ def retrieve(
160154
extra_query: Query | None = None,
161155
extra_body: Body | None = None,
162156
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
163-
) -> Datasource:
157+
) -> DatasourceRetrieveResponse:
164158
"""
165159
根据 id 获取指定数据源
166160
@@ -180,7 +174,7 @@ def retrieve(
180174
options=make_request_options(
181175
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
182176
),
183-
cast_to=Datasource,
177+
cast_to=DatasourceRetrieveResponse,
184178
)
185179

186180
def update(
@@ -189,6 +183,10 @@ def update(
189183
*,
190184
access_config: Optional[datasource_update_params.AccessConfig] | NotGiven = NOT_GIVEN,
191185
desc: Optional[str] | NotGiven = NOT_GIVEN,
186+
engine: Optional[
187+
Literal["mysql", "tidb", "postgresql", "oceanbase", "clickhouse", "csv", "excel", "starrocks", "hive"]
188+
]
189+
| NotGiven = NOT_GIVEN,
192190
field_count: Optional[int] | NotGiven = NOT_GIVEN,
193191
meta_error: Optional[str] | NotGiven = NOT_GIVEN,
194192
meta_status: Optional[Literal["processing", "failed", "success", "unprocessed"]] | NotGiven = NOT_GIVEN,
@@ -211,6 +209,8 @@ def update(
211209
212210
desc: 数据源描述
213211
212+
engine: 数据源引擎
213+
214214
field_count: 字段数量
215215
216216
meta_error: 元数据处理错误
@@ -241,6 +241,7 @@ def update(
241241
{
242242
"access_config": access_config,
243243
"desc": desc,
244+
"engine": engine,
244245
"field_count": field_count,
245246
"meta_error": meta_error,
246247
"meta_status": meta_status,
@@ -339,59 +340,6 @@ def delete(
339340
cast_to=object,
340341
)
341342

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

396344
class AsyncDatasourcesResource(AsyncAPIResource):
397345
@cached_property
@@ -494,7 +442,7 @@ async def retrieve(
494442
extra_query: Query | None = None,
495443
extra_body: Body | None = None,
496444
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
497-
) -> Datasource:
445+
) -> DatasourceRetrieveResponse:
498446
"""
499447
根据 id 获取指定数据源
500448
@@ -514,7 +462,7 @@ async def retrieve(
514462
options=make_request_options(
515463
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
516464
),
517-
cast_to=Datasource,
465+
cast_to=DatasourceRetrieveResponse,
518466
)
519467

520468
async def update(
@@ -523,6 +471,10 @@ async def update(
523471
*,
524472
access_config: Optional[datasource_update_params.AccessConfig] | NotGiven = NOT_GIVEN,
525473
desc: Optional[str] | NotGiven = NOT_GIVEN,
474+
engine: Optional[
475+
Literal["mysql", "tidb", "postgresql", "oceanbase", "clickhouse", "csv", "excel", "starrocks", "hive"]
476+
]
477+
| NotGiven = NOT_GIVEN,
526478
field_count: Optional[int] | NotGiven = NOT_GIVEN,
527479
meta_error: Optional[str] | NotGiven = NOT_GIVEN,
528480
meta_status: Optional[Literal["processing", "failed", "success", "unprocessed"]] | NotGiven = NOT_GIVEN,
@@ -545,6 +497,8 @@ async def update(
545497
546498
desc: 数据源描述
547499
500+
engine: 数据源引擎
501+
548502
field_count: 字段数量
549503
550504
meta_error: 元数据处理错误
@@ -575,6 +529,7 @@ async def update(
575529
{
576530
"access_config": access_config,
577531
"desc": desc,
532+
"engine": engine,
578533
"field_count": field_count,
579534
"meta_error": meta_error,
580535
"meta_status": meta_status,
@@ -673,59 +628,6 @@ async def delete(
673628
cast_to=object,
674629
)
675630

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

730632
class DatasourcesResourceWithRawResponse:
731633
def __init__(self, datasources: DatasourcesResource) -> None:
@@ -746,9 +648,6 @@ def __init__(self, datasources: DatasourcesResource) -> None:
746648
self.delete = to_raw_response_wrapper(
747649
datasources.delete,
748650
)
749-
self.create_from_file = to_raw_response_wrapper(
750-
datasources.create_from_file,
751-
)
752651

753652
@cached_property
754653
def meta(self) -> MetaResourceWithRawResponse:
@@ -782,9 +681,6 @@ def __init__(self, datasources: AsyncDatasourcesResource) -> None:
782681
self.delete = async_to_raw_response_wrapper(
783682
datasources.delete,
784683
)
785-
self.create_from_file = async_to_raw_response_wrapper(
786-
datasources.create_from_file,
787-
)
788684

789685
@cached_property
790686
def meta(self) -> AsyncMetaResourceWithRawResponse:
@@ -818,9 +714,6 @@ def __init__(self, datasources: DatasourcesResource) -> None:
818714
self.delete = to_streamed_response_wrapper(
819715
datasources.delete,
820716
)
821-
self.create_from_file = to_streamed_response_wrapper(
822-
datasources.create_from_file,
823-
)
824717

825718
@cached_property
826719
def meta(self) -> MetaResourceWithStreamingResponse:
@@ -854,9 +747,6 @@ def __init__(self, datasources: AsyncDatasourcesResource) -> None:
854747
self.delete = async_to_streamed_response_wrapper(
855748
datasources.delete,
856749
)
857-
self.create_from_file = async_to_streamed_response_wrapper(
858-
datasources.create_from_file,
859-
)
860750

861751
@cached_property
862752
def meta(self) -> AsyncMetaResourceWithStreamingResponse:

src/asktable/types/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
from .preference_update_response import PreferenceUpdateResponse as PreferenceUpdateResponse
6363
from .securetunnel_create_params import SecuretunnelCreateParams as SecuretunnelCreateParams
6464
from .securetunnel_update_params import SecuretunnelUpdateParams as SecuretunnelUpdateParams
65+
from .datasource_retrieve_response import DatasourceRetrieveResponse as DatasourceRetrieveResponse
6566
from .preference_retrieve_response import PreferenceRetrieveResponse as PreferenceRetrieveResponse
6667
from .business_glossary_list_params import BusinessGlossaryListParams as BusinessGlossaryListParams
6768
from .securetunnel_list_links_params import SecuretunnelListLinksParams as SecuretunnelListLinksParams
@@ -70,6 +71,5 @@
7071
from .integration_excel_csv_ask_params import IntegrationExcelCsvAskParams as IntegrationExcelCsvAskParams
7172
from .securetunnel_list_links_response import SecuretunnelListLinksResponse as SecuretunnelListLinksResponse
7273
from .business_glossary_create_response import BusinessGlossaryCreateResponse as BusinessGlossaryCreateResponse
73-
from .datasource_create_from_file_params import DatasourceCreateFromFileParams as DatasourceCreateFromFileParams
7474
from .integration_create_excel_ds_params import IntegrationCreateExcelDsParams as IntegrationCreateExcelDsParams
7575
from .project_list_model_groups_response import ProjectListModelGroupsResponse as ProjectListModelGroupsResponse

src/asktable/types/datasource.py

Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -6,42 +6,7 @@
66

77
from .._models import BaseModel
88

9-
__all__ = ["Datasource", "AccessConfig"]
10-
11-
12-
class AccessConfig(BaseModel):
13-
atst_link_id: Optional[str] = None
14-
"""安全隧道链接 ID"""
15-
16-
db: Optional[str] = None
17-
"""数据库引擎可以管理多个数据库,此参数用于指定数据库名称"""
18-
19-
db_version: Optional[str] = None
20-
"""数据库版本"""
21-
22-
host: Optional[str] = None
23-
"""数据库地址"""
24-
25-
location_type: Optional[str] = None
26-
"""Excel/CSV 文件位置"""
27-
28-
location_url: Optional[str] = None
29-
"""Excel/CSV 文件下载地址"""
30-
31-
port: Optional[int] = None
32-
"""数据库端口"""
33-
34-
proxy_host: Optional[str] = None
35-
"""数据源代理地址"""
36-
37-
proxy_port: Optional[int] = None
38-
"""数据源代理端口"""
39-
40-
securetunnel_id: Optional[str] = None
41-
"""安全隧道 ID"""
42-
43-
user: Optional[str] = None
44-
"""数据库用户名"""
9+
__all__ = ["Datasource"]
4510

4611

4712
class Datasource(BaseModel):
@@ -63,9 +28,6 @@ class Datasource(BaseModel):
6328
project_id: str
6429
"""项目 ID"""
6530

66-
access_config: Optional[AccessConfig] = None
67-
"""访问数据源的配置信息"""
68-
6931
desc: Optional[str] = None
7032
"""数据源描述"""
7133

0 commit comments

Comments
 (0)