Skip to content

Commit f8e9649

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

File tree

11 files changed

+45
-253
lines changed

11 files changed

+45
-253
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: 68
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/datamini%2Fasktable-f8d4f4ee9ccccf65054df0c205156f6022a8d207441b1494fa56bd950b44593b.yml
1+
configured_endpoints: 67
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/datamini%2Fasktable-40b24dabc4429084d4928122661865fb5b2feebac81de578d7de95c4d351621c.yml

README.md

Lines changed: 7 additions & 5 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={},
87+
access_config={"engine": "mysql"},
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={},
133+
access_config={"engine": "mysql"},
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={},
159+
access_config={"engine": "mysql"},
160160
engine="mysql",
161161
)
162162
```
@@ -198,7 +198,9 @@ from asktable import Asktable
198198

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

220222
```python
221223
with client.datasources.with_streaming_response.create(
222-
access_config={},
224+
access_config={"engine": "mysql"},
223225
engine="mysql",
224226
) as response:
225227
print(response.headers.get("X-My-Header"))

api.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ from asktable.types.chats import MessageModel, MessageListResponse
113113

114114
Methods:
115115

116-
- <code title="post /chats/{chat_id}/messages">client.chats.messages.<a href="./src/asktable/resources/chats/messages.py">create</a>(chat_id, \*\*<a href="src/asktable/types/chats/message_create_params.py">params</a>) -> <a href="./src/asktable/types/shared/message.py">Message</a></code>
116+
- <code title="post /chats/{chat_id}">client.chats.messages.<a href="./src/asktable/resources/chats/messages.py">create</a>(chat_id, \*\*<a href="src/asktable/types/chats/message_create_params.py">params</a>) -> <a href="./src/asktable/types/shared/message.py">Message</a></code>
117117
- <code title="get /chats/{chat_id}/messages/{message_id}">client.chats.messages.<a href="./src/asktable/resources/chats/messages.py">retrieve</a>(message_id, \*, chat_id) -> <a href="./src/asktable/types/shared/message.py">Message</a></code>
118118
- <code title="get /chats/{chat_id}/messages">client.chats.messages.<a href="./src/asktable/resources/chats/messages.py">list</a>(chat_id, \*\*<a href="src/asktable/types/chats/message_list_params.py">params</a>) -> <a href="./src/asktable/types/chats/message_list_response.py">MessageListResponse</a></code>
119119

@@ -132,7 +132,6 @@ 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>
136135

137136
## Meta
138137

src/asktable/resources/chats/messages.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def create(
7272
if not chat_id:
7373
raise ValueError(f"Expected a non-empty value for `chat_id` but received {chat_id!r}")
7474
return self._post(
75-
f"/chats/{chat_id}/messages",
75+
f"/chats/{chat_id}",
7676
options=make_request_options(
7777
extra_headers=extra_headers,
7878
extra_query=extra_query,
@@ -216,7 +216,7 @@ async def create(
216216
if not chat_id:
217217
raise ValueError(f"Expected a non-empty value for `chat_id` but received {chat_id!r}")
218218
return await self._post(
219-
f"/chats/{chat_id}/messages",
219+
f"/chats/{chat_id}",
220220
options=make_request_options(
221221
extra_headers=extra_headers,
222222
extra_query=extra_query,

src/asktable/resources/datasources/datasources.py

Lines changed: 3 additions & 136 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,17 +15,10 @@
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-
)
24-
from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven, FileTypes
18+
from ...types import datasource_list_params, datasource_create_params, datasource_update_params
19+
from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven
2520
from ..._utils import (
26-
extract_files,
2721
maybe_transform,
28-
deepcopy_minimal,
2922
async_maybe_transform,
3023
)
3124
from ..._compat import cached_property
@@ -326,63 +319,6 @@ def delete(
326319
cast_to=object,
327320
)
328321

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-
386322

387323
class AsyncDatasourcesResource(AsyncAPIResource):
388324
@cached_property
@@ -659,63 +595,6 @@ async def delete(
659595
cast_to=object,
660596
)
661597

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-
719598

720599
class DatasourcesResourceWithRawResponse:
721600
def __init__(self, datasources: DatasourcesResource) -> None:
@@ -736,9 +615,6 @@ def __init__(self, datasources: DatasourcesResource) -> None:
736615
self.delete = to_raw_response_wrapper(
737616
datasources.delete,
738617
)
739-
self.create_from_file = to_raw_response_wrapper(
740-
datasources.create_from_file,
741-
)
742618

743619
@cached_property
744620
def meta(self) -> MetaResourceWithRawResponse:
@@ -768,9 +644,6 @@ def __init__(self, datasources: AsyncDatasourcesResource) -> None:
768644
self.delete = async_to_raw_response_wrapper(
769645
datasources.delete,
770646
)
771-
self.create_from_file = async_to_raw_response_wrapper(
772-
datasources.create_from_file,
773-
)
774647

775648
@cached_property
776649
def meta(self) -> AsyncMetaResourceWithRawResponse:
@@ -800,9 +673,6 @@ def __init__(self, datasources: DatasourcesResource) -> None:
800673
self.delete = to_streamed_response_wrapper(
801674
datasources.delete,
802675
)
803-
self.create_from_file = to_streamed_response_wrapper(
804-
datasources.create_from_file,
805-
)
806676

807677
@cached_property
808678
def meta(self) -> MetaResourceWithStreamingResponse:
@@ -832,9 +702,6 @@ def __init__(self, datasources: AsyncDatasourcesResource) -> None:
832702
self.delete = async_to_streamed_response_wrapper(
833703
datasources.delete,
834704
)
835-
self.create_from_file = async_to_streamed_response_wrapper(
836-
datasources.create_from_file,
837-
)
838705

839706
@cached_property
840707
def meta(self) -> AsyncMetaResourceWithStreamingResponse:

src/asktable/types/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,3 @@
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: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010

1111

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

src/asktable/types/datasource_create_params.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ 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+
2932
db: Optional[str]
3033
"""数据库引擎可以管理多个数据库,此参数用于指定数据库名称"""
3134

src/asktable/types/datasource_update_params.py

Lines changed: 4 additions & 1 deletion
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, TypedDict
6+
from typing_extensions import Literal, Required, TypedDict
77

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

@@ -35,6 +35,9 @@ 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+
3841
db: Optional[str]
3942
"""数据库引擎可以管理多个数据库,此参数用于指定数据库名称"""
4043

0 commit comments

Comments
 (0)