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: 91
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/datamini%2Fasktable-25d01530668d8650b601a2f2d00c3859cb907a58fb4bb0f2324ba92802da6979.yml
configured_endpoints: 90
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/datamini%2Fasktable-812fbef9135838630557abadedcc8c593c10d2133388aaea70b9a313fc546941.yml
11 changes: 8 additions & 3 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,17 +144,22 @@ Methods:
Types:

```python
from asktable.types import Datasource, Index, Meta, DatasourceDeleteResponse
from asktable.types import (
Datasource,
Index,
Meta,
DatasourceRetrieveResponse,
DatasourceDeleteResponse,
)
```

Methods:

- <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>
- <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>
- <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>
- <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>
- <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>
- <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/datasource.py">Datasource</a></code>

## Meta

Expand Down
154 changes: 22 additions & 132 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,12 +15,7 @@
MetaResourceWithStreamingResponse,
AsyncMetaResourceWithStreamingResponse,
)
from ...types import (
datasource_list_params,
datasource_create_params,
datasource_update_params,
datasource_create_from_file_params,
)
from ...types import datasource_list_params, datasource_create_params, datasource_update_params
from .indexes import (
IndexesResource,
AsyncIndexesResource,
Expand All @@ -29,11 +24,9 @@
IndexesResourceWithStreamingResponse,
AsyncIndexesResourceWithStreamingResponse,
)
from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven, FileTypes
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 All @@ -55,6 +48,7 @@
)
from ..._base_client import AsyncPaginator, make_request_options
from ...types.datasource import Datasource
from ...types.datasource_retrieve_response import DatasourceRetrieveResponse

__all__ = ["DatasourcesResource", "AsyncDatasourcesResource"]

Expand Down Expand Up @@ -160,7 +154,7 @@ def retrieve(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> Datasource:
) -> DatasourceRetrieveResponse:
"""
根据 id 获取指定数据源
Expand All @@ -180,7 +174,7 @@ def retrieve(
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
cast_to=Datasource,
cast_to=DatasourceRetrieveResponse,
)

def update(
Expand All @@ -189,6 +183,10 @@ def update(
*,
access_config: Optional[datasource_update_params.AccessConfig] | NotGiven = NOT_GIVEN,
desc: Optional[str] | NotGiven = NOT_GIVEN,
engine: Optional[
Literal["mysql", "tidb", "postgresql", "oceanbase", "clickhouse", "csv", "excel", "starrocks", "hive"]
]
| NotGiven = NOT_GIVEN,
field_count: Optional[int] | NotGiven = NOT_GIVEN,
meta_error: Optional[str] | NotGiven = NOT_GIVEN,
meta_status: Optional[Literal["processing", "failed", "success", "unprocessed"]] | NotGiven = NOT_GIVEN,
Expand All @@ -211,6 +209,8 @@ def update(
desc: 数据源描述
engine: 数据源引擎
field_count: 字段数量
meta_error: 元数据处理错误
Expand Down Expand Up @@ -241,6 +241,7 @@ def update(
{
"access_config": access_config,
"desc": desc,
"engine": engine,
"field_count": field_count,
"meta_error": meta_error,
"meta_status": meta_status,
Expand Down Expand Up @@ -339,59 +340,6 @@ def delete(
cast_to=object,
)

def create_from_file(
self,
*,
file: FileTypes,
async_process_meta: bool | NotGiven = NOT_GIVEN,
name: str | NotGiven = NOT_GIVEN,
value_index: 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:
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(
{
"async_process_meta": async_process_meta,
"name": name,
"value_index": value_index,
},
datasource_create_from_file_params.DatasourceCreateFromFileParams,
),
),
cast_to=Datasource,
)


class AsyncDatasourcesResource(AsyncAPIResource):
@cached_property
Expand Down Expand Up @@ -494,7 +442,7 @@ async def retrieve(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> Datasource:
) -> DatasourceRetrieveResponse:
"""
根据 id 获取指定数据源
Expand All @@ -514,7 +462,7 @@ async def retrieve(
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
cast_to=Datasource,
cast_to=DatasourceRetrieveResponse,
)

async def update(
Expand All @@ -523,6 +471,10 @@ async def update(
*,
access_config: Optional[datasource_update_params.AccessConfig] | NotGiven = NOT_GIVEN,
desc: Optional[str] | NotGiven = NOT_GIVEN,
engine: Optional[
Literal["mysql", "tidb", "postgresql", "oceanbase", "clickhouse", "csv", "excel", "starrocks", "hive"]
]
| NotGiven = NOT_GIVEN,
field_count: Optional[int] | NotGiven = NOT_GIVEN,
meta_error: Optional[str] | NotGiven = NOT_GIVEN,
meta_status: Optional[Literal["processing", "failed", "success", "unprocessed"]] | NotGiven = NOT_GIVEN,
Expand All @@ -545,6 +497,8 @@ async def update(
desc: 数据源描述
engine: 数据源引擎
field_count: 字段数量
meta_error: 元数据处理错误
Expand Down Expand Up @@ -575,6 +529,7 @@ async def update(
{
"access_config": access_config,
"desc": desc,
"engine": engine,
"field_count": field_count,
"meta_error": meta_error,
"meta_status": meta_status,
Expand Down Expand Up @@ -673,59 +628,6 @@ async def delete(
cast_to=object,
)

async def create_from_file(
self,
*,
file: FileTypes,
async_process_meta: bool | NotGiven = NOT_GIVEN,
name: str | NotGiven = NOT_GIVEN,
value_index: 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:
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(
{
"async_process_meta": async_process_meta,
"name": name,
"value_index": value_index,
},
datasource_create_from_file_params.DatasourceCreateFromFileParams,
),
),
cast_to=Datasource,
)


class DatasourcesResourceWithRawResponse:
def __init__(self, datasources: DatasourcesResource) -> None:
Expand All @@ -746,9 +648,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 @@ -782,9 +681,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 @@ -818,9 +714,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 @@ -854,9 +747,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
2 changes: 1 addition & 1 deletion src/asktable/types/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
from .preference_update_response import PreferenceUpdateResponse as PreferenceUpdateResponse
from .securetunnel_create_params import SecuretunnelCreateParams as SecuretunnelCreateParams
from .securetunnel_update_params import SecuretunnelUpdateParams as SecuretunnelUpdateParams
from .datasource_retrieve_response import DatasourceRetrieveResponse as DatasourceRetrieveResponse
from .preference_retrieve_response import PreferenceRetrieveResponse as PreferenceRetrieveResponse
from .business_glossary_list_params import BusinessGlossaryListParams as BusinessGlossaryListParams
from .securetunnel_list_links_params import SecuretunnelListLinksParams as SecuretunnelListLinksParams
Expand All @@ -70,6 +71,5 @@
from .integration_excel_csv_ask_params import IntegrationExcelCsvAskParams as IntegrationExcelCsvAskParams
from .securetunnel_list_links_response import SecuretunnelListLinksResponse as SecuretunnelListLinksResponse
from .business_glossary_create_response import BusinessGlossaryCreateResponse as BusinessGlossaryCreateResponse
from .datasource_create_from_file_params import DatasourceCreateFromFileParams as DatasourceCreateFromFileParams
from .integration_create_excel_ds_params import IntegrationCreateExcelDsParams as IntegrationCreateExcelDsParams
from .project_list_model_groups_response import ProjectListModelGroupsResponse as ProjectListModelGroupsResponse
40 changes: 1 addition & 39 deletions src/asktable/types/datasource.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,42 +6,7 @@

from .._models import BaseModel

__all__ = ["Datasource", "AccessConfig"]


class AccessConfig(BaseModel):
atst_link_id: Optional[str] = None
"""安全隧道链接 ID"""

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

db_version: Optional[str] = None
"""数据库版本"""

host: Optional[str] = None
"""数据库地址"""

location_type: Optional[str] = None
"""Excel/CSV 文件位置"""

location_url: Optional[str] = None
"""Excel/CSV 文件下载地址"""

port: Optional[int] = None
"""数据库端口"""

proxy_host: Optional[str] = None
"""数据源代理地址"""

proxy_port: Optional[int] = None
"""数据源代理端口"""

securetunnel_id: Optional[str] = None
"""安全隧道 ID"""

user: Optional[str] = None
"""数据库用户名"""
__all__ = ["Datasource"]


class Datasource(BaseModel):
Expand All @@ -63,9 +28,6 @@ class Datasource(BaseModel):
project_id: str
"""项目 ID"""

access_config: Optional[AccessConfig] = None
"""访问数据源的配置信息"""

desc: Optional[str] = None
"""数据源描述"""

Expand Down
Loading