Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
configured_endpoints: 68
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/datamini%2Fasktable-f8d4f4ee9ccccf65054df0c205156f6022a8d207441b1494fa56bd950b44593b.yml
configured_endpoints: 67
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/datamini%2Fasktable-40b24dabc4429084d4928122661865fb5b2feebac81de578d7de95c4d351621c.yml
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ client = Asktable()

try:
client.datasources.create(
access_config={},
access_config={"engine": "mysql"},
engine="mysql",
)
except asktable.APIConnectionError as e:
Expand Down Expand Up @@ -130,7 +130,7 @@ client = Asktable(

# Or, configure per-request:
client.with_options(max_retries=5).datasources.create(
access_config={},
access_config={"engine": "mysql"},
engine="mysql",
)
```
Expand All @@ -156,7 +156,7 @@ client = Asktable(

# Override per-request:
client.with_options(timeout=5.0).datasources.create(
access_config={},
access_config={"engine": "mysql"},
engine="mysql",
)
```
Expand Down Expand Up @@ -198,7 +198,9 @@ from asktable import Asktable

client = Asktable()
response = client.datasources.with_raw_response.create(
access_config={},
access_config={
"engine": "mysql"
},
engine="mysql",
)
print(response.headers.get('X-My-Header'))
Expand All @@ -219,7 +221,7 @@ To stream the response body, use `.with_streaming_response` instead, which requi

```python
with client.datasources.with_streaming_response.create(
access_config={},
access_config={"engine": "mysql"},
engine="mysql",
) as response:
print(response.headers.get("X-My-Header"))
Expand Down
3 changes: 1 addition & 2 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ from asktable.types.chats import MessageModel, MessageListResponse

Methods:

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

Expand All @@ -132,7 +132,6 @@ Methods:
- <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>
- <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>
- <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>
- <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>

## Meta

Expand Down
4 changes: 2 additions & 2 deletions src/asktable/resources/chats/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def create(
if not chat_id:
raise ValueError(f"Expected a non-empty value for `chat_id` but received {chat_id!r}")
return self._post(
f"/chats/{chat_id}/messages",
f"/chats/{chat_id}",
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
Expand Down Expand Up @@ -216,7 +216,7 @@ async def create(
if not chat_id:
raise ValueError(f"Expected a non-empty value for `chat_id` but received {chat_id!r}")
return await self._post(
f"/chats/{chat_id}/messages",
f"/chats/{chat_id}",
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
Expand Down
139 changes: 3 additions & 136 deletions src/asktable/resources/datasources/datasources.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from __future__ import annotations

from typing import Mapping, Optional, cast
from typing import Optional
from typing_extensions import Literal

import httpx
Expand All @@ -15,17 +15,10 @@
MetaResourceWithStreamingResponse,
AsyncMetaResourceWithStreamingResponse,
)
from ...types import (
datasource_list_params,
datasource_create_params,
datasource_update_params,
datasource_create_from_file_params,
)
from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven, FileTypes
from ...types import datasource_list_params, datasource_create_params, datasource_update_params
from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven
from ..._utils import (
extract_files,
maybe_transform,
deepcopy_minimal,
async_maybe_transform,
)
from ..._compat import cached_property
Expand Down Expand Up @@ -326,63 +319,6 @@ def delete(
cast_to=object,
)

def create_from_file(
self,
*,
name: str,
file: FileTypes,
async_process_meta: bool | NotGiven = NOT_GIVEN,
skip_process_meta: bool | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> DataSource:
"""
上传文件并创建数据源

Args:
async_process_meta: 是否异步处理元数据

skip_process_meta: 是否跳过元数据处理

extra_headers: Send extra headers

extra_query: Add additional query parameters to the request

extra_body: Add additional JSON properties to the request

timeout: Override the client-level default timeout for this request, in seconds
"""
body = deepcopy_minimal({"file": file})
files = extract_files(cast(Mapping[str, object], body), paths=[["file"]])
# It should be noted that the actual Content-Type header that will be
# sent to the server will contain a `boundary` parameter, e.g.
# multipart/form-data; boundary=---abc--
extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})}
return self._post(
"/datasources/file",
body=maybe_transform(body, datasource_create_from_file_params.DatasourceCreateFromFileParams),
files=files,
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
query=maybe_transform(
{
"name": name,
"async_process_meta": async_process_meta,
"skip_process_meta": skip_process_meta,
},
datasource_create_from_file_params.DatasourceCreateFromFileParams,
),
),
cast_to=DataSource,
)


class AsyncDatasourcesResource(AsyncAPIResource):
@cached_property
Expand Down Expand Up @@ -659,63 +595,6 @@ async def delete(
cast_to=object,
)

async def create_from_file(
self,
*,
name: str,
file: FileTypes,
async_process_meta: bool | NotGiven = NOT_GIVEN,
skip_process_meta: bool | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> DataSource:
"""
上传文件并创建数据源

Args:
async_process_meta: 是否异步处理元数据

skip_process_meta: 是否跳过元数据处理

extra_headers: Send extra headers

extra_query: Add additional query parameters to the request

extra_body: Add additional JSON properties to the request

timeout: Override the client-level default timeout for this request, in seconds
"""
body = deepcopy_minimal({"file": file})
files = extract_files(cast(Mapping[str, object], body), paths=[["file"]])
# It should be noted that the actual Content-Type header that will be
# sent to the server will contain a `boundary` parameter, e.g.
# multipart/form-data; boundary=---abc--
extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})}
return await self._post(
"/datasources/file",
body=await async_maybe_transform(body, datasource_create_from_file_params.DatasourceCreateFromFileParams),
files=files,
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
query=await async_maybe_transform(
{
"name": name,
"async_process_meta": async_process_meta,
"skip_process_meta": skip_process_meta,
},
datasource_create_from_file_params.DatasourceCreateFromFileParams,
),
),
cast_to=DataSource,
)


class DatasourcesResourceWithRawResponse:
def __init__(self, datasources: DatasourcesResource) -> None:
Expand All @@ -736,9 +615,6 @@ def __init__(self, datasources: DatasourcesResource) -> None:
self.delete = to_raw_response_wrapper(
datasources.delete,
)
self.create_from_file = to_raw_response_wrapper(
datasources.create_from_file,
)

@cached_property
def meta(self) -> MetaResourceWithRawResponse:
Expand Down Expand Up @@ -768,9 +644,6 @@ def __init__(self, datasources: AsyncDatasourcesResource) -> None:
self.delete = async_to_raw_response_wrapper(
datasources.delete,
)
self.create_from_file = async_to_raw_response_wrapper(
datasources.create_from_file,
)

@cached_property
def meta(self) -> AsyncMetaResourceWithRawResponse:
Expand Down Expand Up @@ -800,9 +673,6 @@ def __init__(self, datasources: DatasourcesResource) -> None:
self.delete = to_streamed_response_wrapper(
datasources.delete,
)
self.create_from_file = to_streamed_response_wrapper(
datasources.create_from_file,
)

@cached_property
def meta(self) -> MetaResourceWithStreamingResponse:
Expand Down Expand Up @@ -832,9 +702,6 @@ def __init__(self, datasources: AsyncDatasourcesResource) -> None:
self.delete = async_to_streamed_response_wrapper(
datasources.delete,
)
self.create_from_file = async_to_streamed_response_wrapper(
datasources.create_from_file,
)

@cached_property
def meta(self) -> AsyncMetaResourceWithStreamingResponse:
Expand Down
1 change: 0 additions & 1 deletion src/asktable/types/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,3 @@
from .securetunnel_list_response import SecuretunnelListResponse as SecuretunnelListResponse
from .securetunnel_update_params import SecuretunnelUpdateParams as SecuretunnelUpdateParams
from .integration_excel_csv_ask_params import IntegrationExcelCsvAskParams as IntegrationExcelCsvAskParams
from .datasource_create_from_file_params import DatasourceCreateFromFileParams as DatasourceCreateFromFileParams
3 changes: 3 additions & 0 deletions src/asktable/types/data_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@


class AccessConfig(BaseModel):
engine: Literal["mysql", "tidb", "postgresql", "oceanbase", "clickhouse", "csv", "excel"]
"""数据库引擎"""

db: Optional[str] = None
"""数据库引擎可以管理多个数据库,此参数用于指定数据库名称"""

Expand Down
3 changes: 3 additions & 0 deletions src/asktable/types/datasource_create_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ class DatasourceCreateParams(TypedDict, total=False):


class AccessConfig(TypedDict, total=False):
engine: Required[Literal["mysql", "tidb", "postgresql", "oceanbase", "clickhouse", "csv", "excel"]]
"""数据库引擎"""

db: Optional[str]
"""数据库引擎可以管理多个数据库,此参数用于指定数据库名称"""

Expand Down
5 changes: 4 additions & 1 deletion src/asktable/types/datasource_update_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from __future__ import annotations

from typing import Optional
from typing_extensions import Literal, TypedDict
from typing_extensions import Literal, Required, TypedDict

__all__ = ["DatasourceUpdateParams", "AccessConfig"]

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


class AccessConfig(TypedDict, total=False):
engine: Required[Literal["mysql", "tidb", "postgresql", "oceanbase", "clickhouse", "csv", "excel"]]
"""数据库引擎"""

db: Optional[str]
"""数据库引擎可以管理多个数据库,此参数用于指定数据库名称"""

Expand Down
Loading