diff --git a/.stats.yml b/.stats.yml index 559383cc..95102f37 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ -configured_endpoints: 93 +configured_endpoints: 98 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/datamini%2Fasktable-02fbb644978089e8596def9999f5729633b652fba35bf04e374dbb71e7630355.yml diff --git a/api.md b/api.md index 1f1f2ec8..741eeba0 100644 --- a/api.md +++ b/api.md @@ -140,6 +140,8 @@ from asktable.types import ( DatasourceDeleteResponse, DatasourceAddFileResponse, DatasourceDeleteFileResponse, + DatasourceRetrieveRuntimeMetaResponse, + DatasourceUpdateFieldResponse, ) ``` @@ -152,6 +154,8 @@ Methods: - client.datasources.delete(datasource_id) -> object - client.datasources.add_file(datasource_id, \*\*params) -> object - client.datasources.delete_file(file_id, \*, datasource_id) -> object +- client.datasources.retrieve_runtime_meta(datasource_id) -> DatasourceRetrieveRuntimeMetaResponse +- client.datasources.update_field(datasource_id, \*\*params) -> object ## Meta @@ -405,3 +409,30 @@ from asktable.types import DataframeRetrieveResponse Methods: - client.dataframes.retrieve(dataframe_id) -> DataframeRetrieveResponse + +# SingleTurn + +## Q2w + +Types: + +```python +from asktable.types.single_turn import Q2wCreateResponse, Q2wListResponse +``` + +Methods: + +- client.single_turn.q2w.create(\*\*params) -> object +- client.single_turn.q2w.list() -> object + +# Polish + +Types: + +```python +from asktable.types import PolishCreateResponse +``` + +Methods: + +- client.polish.create(\*\*params) -> PolishCreateResponse diff --git a/src/asktable/_client.py b/src/asktable/_client.py index 0fa09487..2c3407ee 100644 --- a/src/asktable/_client.py +++ b/src/asktable/_client.py @@ -31,6 +31,7 @@ files, roles, caches, + polish, scores, answers, project, @@ -53,6 +54,7 @@ from .resources.chats import chats from .resources.extapis import extapis from .resources.datasources import datasources +from .resources.single_turn import single_turn __all__ = [ "Timeout", @@ -87,6 +89,8 @@ class Asktable(SyncAPIClient): scores: scores.ScoresResource files: files.FilesResource dataframes: dataframes.DataframesResource + single_turn: single_turn.SingleTurnResource + polish: polish.PolishResource with_raw_response: AsktableWithRawResponse with_streaming_response: AsktableWithStreamedResponse @@ -131,7 +135,7 @@ def __init__( if base_url is None: base_url = os.environ.get("ASKTABLE_BASE_URL") if base_url is None: - base_url = f"https://api.asktable.com" + base_url = f"https://api.asktable.com/v1" super().__init__( version=__version__, @@ -164,6 +168,8 @@ def __init__( self.scores = scores.ScoresResource(self) self.files = files.FilesResource(self) self.dataframes = dataframes.DataframesResource(self) + self.single_turn = single_turn.SingleTurnResource(self) + self.polish = polish.PolishResource(self) self.with_raw_response = AsktableWithRawResponse(self) self.with_streaming_response = AsktableWithStreamedResponse(self) @@ -293,6 +299,8 @@ class AsyncAsktable(AsyncAPIClient): scores: scores.AsyncScoresResource files: files.AsyncFilesResource dataframes: dataframes.AsyncDataframesResource + single_turn: single_turn.AsyncSingleTurnResource + polish: polish.AsyncPolishResource with_raw_response: AsyncAsktableWithRawResponse with_streaming_response: AsyncAsktableWithStreamedResponse @@ -337,7 +345,7 @@ def __init__( if base_url is None: base_url = os.environ.get("ASKTABLE_BASE_URL") if base_url is None: - base_url = f"https://api.asktable.com" + base_url = f"https://api.asktable.com/v1" super().__init__( version=__version__, @@ -370,6 +378,8 @@ def __init__( self.scores = scores.AsyncScoresResource(self) self.files = files.AsyncFilesResource(self) self.dataframes = dataframes.AsyncDataframesResource(self) + self.single_turn = single_turn.AsyncSingleTurnResource(self) + self.polish = polish.AsyncPolishResource(self) self.with_raw_response = AsyncAsktableWithRawResponse(self) self.with_streaming_response = AsyncAsktableWithStreamedResponse(self) @@ -500,6 +510,8 @@ def __init__(self, client: Asktable) -> None: self.scores = scores.ScoresResourceWithRawResponse(client.scores) self.files = files.FilesResourceWithRawResponse(client.files) self.dataframes = dataframes.DataframesResourceWithRawResponse(client.dataframes) + self.single_turn = single_turn.SingleTurnResourceWithRawResponse(client.single_turn) + self.polish = polish.PolishResourceWithRawResponse(client.polish) class AsyncAsktableWithRawResponse: @@ -526,6 +538,8 @@ def __init__(self, client: AsyncAsktable) -> None: self.scores = scores.AsyncScoresResourceWithRawResponse(client.scores) self.files = files.AsyncFilesResourceWithRawResponse(client.files) self.dataframes = dataframes.AsyncDataframesResourceWithRawResponse(client.dataframes) + self.single_turn = single_turn.AsyncSingleTurnResourceWithRawResponse(client.single_turn) + self.polish = polish.AsyncPolishResourceWithRawResponse(client.polish) class AsktableWithStreamedResponse: @@ -552,6 +566,8 @@ def __init__(self, client: Asktable) -> None: self.scores = scores.ScoresResourceWithStreamingResponse(client.scores) self.files = files.FilesResourceWithStreamingResponse(client.files) self.dataframes = dataframes.DataframesResourceWithStreamingResponse(client.dataframes) + self.single_turn = single_turn.SingleTurnResourceWithStreamingResponse(client.single_turn) + self.polish = polish.PolishResourceWithStreamingResponse(client.polish) class AsyncAsktableWithStreamedResponse: @@ -578,6 +594,8 @@ def __init__(self, client: AsyncAsktable) -> None: self.scores = scores.AsyncScoresResourceWithStreamingResponse(client.scores) self.files = files.AsyncFilesResourceWithStreamingResponse(client.files) self.dataframes = dataframes.AsyncDataframesResourceWithStreamingResponse(client.dataframes) + self.single_turn = single_turn.AsyncSingleTurnResourceWithStreamingResponse(client.single_turn) + self.polish = polish.AsyncPolishResourceWithStreamingResponse(client.polish) Client = Asktable diff --git a/src/asktable/resources/__init__.py b/src/asktable/resources/__init__.py index 45e0bfb5..caab4d93 100644 --- a/src/asktable/resources/__init__.py +++ b/src/asktable/resources/__init__.py @@ -64,6 +64,14 @@ CachesResourceWithStreamingResponse, AsyncCachesResourceWithStreamingResponse, ) +from .polish import ( + PolishResource, + AsyncPolishResource, + PolishResourceWithRawResponse, + AsyncPolishResourceWithRawResponse, + PolishResourceWithStreamingResponse, + AsyncPolishResourceWithStreamingResponse, +) from .scores import ( ScoresResource, AsyncScoresResource, @@ -144,6 +152,14 @@ PreferencesResourceWithStreamingResponse, AsyncPreferencesResourceWithStreamingResponse, ) +from .single_turn import ( + SingleTurnResource, + AsyncSingleTurnResource, + SingleTurnResourceWithRawResponse, + AsyncSingleTurnResourceWithRawResponse, + SingleTurnResourceWithStreamingResponse, + AsyncSingleTurnResourceWithStreamingResponse, +) from .securetunnels import ( SecuretunnelsResource, AsyncSecuretunnelsResource, @@ -282,4 +298,16 @@ "AsyncDataframesResourceWithRawResponse", "DataframesResourceWithStreamingResponse", "AsyncDataframesResourceWithStreamingResponse", + "SingleTurnResource", + "AsyncSingleTurnResource", + "SingleTurnResourceWithRawResponse", + "AsyncSingleTurnResourceWithRawResponse", + "SingleTurnResourceWithStreamingResponse", + "AsyncSingleTurnResourceWithStreamingResponse", + "PolishResource", + "AsyncPolishResource", + "PolishResourceWithRawResponse", + "AsyncPolishResourceWithRawResponse", + "PolishResourceWithStreamingResponse", + "AsyncPolishResourceWithStreamingResponse", ] diff --git a/src/asktable/resources/datasources/datasources.py b/src/asktable/resources/datasources/datasources.py index c36be974..099d2695 100644 --- a/src/asktable/resources/datasources/datasources.py +++ b/src/asktable/resources/datasources/datasources.py @@ -20,6 +20,7 @@ datasource_create_params, datasource_update_params, datasource_add_file_params, + datasource_update_field_params, ) from .indexes import ( IndexesResource, @@ -56,6 +57,7 @@ from ..._base_client import AsyncPaginator, make_request_options from ...types.datasource import Datasource from ...types.datasource_retrieve_response import DatasourceRetrieveResponse +from ...types.datasource_retrieve_runtime_meta_response import DatasourceRetrieveRuntimeMetaResponse __all__ = ["DatasourcesResource", "AsyncDatasourcesResource"] @@ -441,6 +443,92 @@ def delete_file( cast_to=object, ) + def retrieve_runtime_meta( + self, + datasource_id: str, + *, + # 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, + ) -> DatasourceRetrieveRuntimeMetaResponse: + """ + 获取指定数据源的运行时元数据 + + 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 + """ + if not datasource_id: + raise ValueError(f"Expected a non-empty value for `datasource_id` but received {datasource_id!r}") + return self._get( + f"/v1/datasources/{datasource_id}/runtime-meta", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=DatasourceRetrieveRuntimeMetaResponse, + ) + + def update_field( + self, + datasource_id: str, + *, + field_name: str, + schema_name: str, + table_name: str, + visibility: Optional[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, + ) -> object: + """ + 更新数据源的某个字段的描述 + + Args: + visibility: field visibility + + 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 + """ + if not datasource_id: + raise ValueError(f"Expected a non-empty value for `datasource_id` but received {datasource_id!r}") + return self._patch( + f"/v1/datasources/{datasource_id}/field", + body=maybe_transform( + {"visibility": visibility}, datasource_update_field_params.DatasourceUpdateFieldParams + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "field_name": field_name, + "schema_name": schema_name, + "table_name": table_name, + }, + datasource_update_field_params.DatasourceUpdateFieldParams, + ), + ), + cast_to=object, + ) + class AsyncDatasourcesResource(AsyncAPIResource): @cached_property @@ -823,6 +911,92 @@ async def delete_file( cast_to=object, ) + async def retrieve_runtime_meta( + self, + datasource_id: str, + *, + # 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, + ) -> DatasourceRetrieveRuntimeMetaResponse: + """ + 获取指定数据源的运行时元数据 + + 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 + """ + if not datasource_id: + raise ValueError(f"Expected a non-empty value for `datasource_id` but received {datasource_id!r}") + return await self._get( + f"/v1/datasources/{datasource_id}/runtime-meta", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=DatasourceRetrieveRuntimeMetaResponse, + ) + + async def update_field( + self, + datasource_id: str, + *, + field_name: str, + schema_name: str, + table_name: str, + visibility: Optional[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, + ) -> object: + """ + 更新数据源的某个字段的描述 + + Args: + visibility: field visibility + + 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 + """ + if not datasource_id: + raise ValueError(f"Expected a non-empty value for `datasource_id` but received {datasource_id!r}") + return await self._patch( + f"/v1/datasources/{datasource_id}/field", + body=await async_maybe_transform( + {"visibility": visibility}, datasource_update_field_params.DatasourceUpdateFieldParams + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=await async_maybe_transform( + { + "field_name": field_name, + "schema_name": schema_name, + "table_name": table_name, + }, + datasource_update_field_params.DatasourceUpdateFieldParams, + ), + ), + cast_to=object, + ) + class DatasourcesResourceWithRawResponse: def __init__(self, datasources: DatasourcesResource) -> None: @@ -849,6 +1023,12 @@ def __init__(self, datasources: DatasourcesResource) -> None: self.delete_file = to_raw_response_wrapper( datasources.delete_file, ) + self.retrieve_runtime_meta = to_raw_response_wrapper( + datasources.retrieve_runtime_meta, + ) + self.update_field = to_raw_response_wrapper( + datasources.update_field, + ) @cached_property def meta(self) -> MetaResourceWithRawResponse: @@ -888,6 +1068,12 @@ def __init__(self, datasources: AsyncDatasourcesResource) -> None: self.delete_file = async_to_raw_response_wrapper( datasources.delete_file, ) + self.retrieve_runtime_meta = async_to_raw_response_wrapper( + datasources.retrieve_runtime_meta, + ) + self.update_field = async_to_raw_response_wrapper( + datasources.update_field, + ) @cached_property def meta(self) -> AsyncMetaResourceWithRawResponse: @@ -927,6 +1113,12 @@ def __init__(self, datasources: DatasourcesResource) -> None: self.delete_file = to_streamed_response_wrapper( datasources.delete_file, ) + self.retrieve_runtime_meta = to_streamed_response_wrapper( + datasources.retrieve_runtime_meta, + ) + self.update_field = to_streamed_response_wrapper( + datasources.update_field, + ) @cached_property def meta(self) -> MetaResourceWithStreamingResponse: @@ -966,6 +1158,12 @@ def __init__(self, datasources: AsyncDatasourcesResource) -> None: self.delete_file = async_to_streamed_response_wrapper( datasources.delete_file, ) + self.retrieve_runtime_meta = async_to_streamed_response_wrapper( + datasources.retrieve_runtime_meta, + ) + self.update_field = async_to_streamed_response_wrapper( + datasources.update_field, + ) @cached_property def meta(self) -> AsyncMetaResourceWithStreamingResponse: diff --git a/src/asktable/resources/polish.py b/src/asktable/resources/polish.py new file mode 100644 index 00000000..3343078e --- /dev/null +++ b/src/asktable/resources/polish.py @@ -0,0 +1,198 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Literal + +import httpx + +from ..types import polish_create_params +from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven +from .._utils import ( + maybe_transform, + async_maybe_transform, +) +from .._compat import cached_property +from .._resource import SyncAPIResource, AsyncAPIResource +from .._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from .._base_client import make_request_options +from ..types.polish_create_response import PolishCreateResponse + +__all__ = ["PolishResource", "AsyncPolishResource"] + + +class PolishResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> PolishResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/DataMini/asktable-python#accessing-raw-response-data-eg-headers + """ + return PolishResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> PolishResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/DataMini/asktable-python#with_streaming_response + """ + return PolishResourceWithStreamingResponse(self) + + def create( + self, + *, + max_word_count: int, + user_desc: str, + polish_mode: Literal[0] | 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, + ) -> PolishCreateResponse: + """ + Polish Table Desc + + Args: + max_word_count: 润色后的最大字数,注意:该值不是绝对值,实际优化后的字数可能会超过该值 + + user_desc: 需要润色的用户输入 + + polish_mode: 润色模式,默认是简化模式 + + 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 + """ + return self._post( + "/v1/polish", + body=maybe_transform( + { + "max_word_count": max_word_count, + "user_desc": user_desc, + "polish_mode": polish_mode, + }, + polish_create_params.PolishCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=PolishCreateResponse, + ) + + +class AsyncPolishResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncPolishResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/DataMini/asktable-python#accessing-raw-response-data-eg-headers + """ + return AsyncPolishResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncPolishResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/DataMini/asktable-python#with_streaming_response + """ + return AsyncPolishResourceWithStreamingResponse(self) + + async def create( + self, + *, + max_word_count: int, + user_desc: str, + polish_mode: Literal[0] | 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, + ) -> PolishCreateResponse: + """ + Polish Table Desc + + Args: + max_word_count: 润色后的最大字数,注意:该值不是绝对值,实际优化后的字数可能会超过该值 + + user_desc: 需要润色的用户输入 + + polish_mode: 润色模式,默认是简化模式 + + 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 + """ + return await self._post( + "/v1/polish", + body=await async_maybe_transform( + { + "max_word_count": max_word_count, + "user_desc": user_desc, + "polish_mode": polish_mode, + }, + polish_create_params.PolishCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=PolishCreateResponse, + ) + + +class PolishResourceWithRawResponse: + def __init__(self, polish: PolishResource) -> None: + self._polish = polish + + self.create = to_raw_response_wrapper( + polish.create, + ) + + +class AsyncPolishResourceWithRawResponse: + def __init__(self, polish: AsyncPolishResource) -> None: + self._polish = polish + + self.create = async_to_raw_response_wrapper( + polish.create, + ) + + +class PolishResourceWithStreamingResponse: + def __init__(self, polish: PolishResource) -> None: + self._polish = polish + + self.create = to_streamed_response_wrapper( + polish.create, + ) + + +class AsyncPolishResourceWithStreamingResponse: + def __init__(self, polish: AsyncPolishResource) -> None: + self._polish = polish + + self.create = async_to_streamed_response_wrapper( + polish.create, + ) diff --git a/src/asktable/resources/single_turn/__init__.py b/src/asktable/resources/single_turn/__init__.py new file mode 100644 index 00000000..25231734 --- /dev/null +++ b/src/asktable/resources/single_turn/__init__.py @@ -0,0 +1,33 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from .q2w import ( + Q2wResource, + AsyncQ2wResource, + Q2wResourceWithRawResponse, + AsyncQ2wResourceWithRawResponse, + Q2wResourceWithStreamingResponse, + AsyncQ2wResourceWithStreamingResponse, +) +from .single_turn import ( + SingleTurnResource, + AsyncSingleTurnResource, + SingleTurnResourceWithRawResponse, + AsyncSingleTurnResourceWithRawResponse, + SingleTurnResourceWithStreamingResponse, + AsyncSingleTurnResourceWithStreamingResponse, +) + +__all__ = [ + "Q2wResource", + "AsyncQ2wResource", + "Q2wResourceWithRawResponse", + "AsyncQ2wResourceWithRawResponse", + "Q2wResourceWithStreamingResponse", + "AsyncQ2wResourceWithStreamingResponse", + "SingleTurnResource", + "AsyncSingleTurnResource", + "SingleTurnResourceWithRawResponse", + "AsyncSingleTurnResourceWithRawResponse", + "SingleTurnResourceWithStreamingResponse", + "AsyncSingleTurnResourceWithStreamingResponse", +] diff --git a/src/asktable/resources/single_turn/q2w.py b/src/asktable/resources/single_turn/q2w.py new file mode 100644 index 00000000..c88191d2 --- /dev/null +++ b/src/asktable/resources/single_turn/q2w.py @@ -0,0 +1,215 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import httpx + +from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven +from ..._utils import ( + maybe_transform, + async_maybe_transform, +) +from ..._compat import cached_property +from ..._resource import SyncAPIResource, AsyncAPIResource +from ..._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ..._base_client import make_request_options +from ...types.single_turn import q2w_create_params + +__all__ = ["Q2wResource", "AsyncQ2wResource"] + + +class Q2wResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> Q2wResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/DataMini/asktable-python#accessing-raw-response-data-eg-headers + """ + return Q2wResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> Q2wResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/DataMini/asktable-python#with_streaming_response + """ + return Q2wResourceWithStreamingResponse(self) + + def create( + self, + *, + body: object, + # 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, + ) -> object: + """ + Create Q2W + + 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 + """ + return self._post( + "/v1/single-turn/q2w", + body=maybe_transform(body, q2w_create_params.Q2wCreateParams), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=object, + ) + + def list( + self, + *, + # 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, + ) -> object: + """获取所有的 Q2W 记录""" + return self._get( + "/v1/single-turn/q2w", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=object, + ) + + +class AsyncQ2wResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncQ2wResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/DataMini/asktable-python#accessing-raw-response-data-eg-headers + """ + return AsyncQ2wResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncQ2wResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/DataMini/asktable-python#with_streaming_response + """ + return AsyncQ2wResourceWithStreamingResponse(self) + + async def create( + self, + *, + body: object, + # 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, + ) -> object: + """ + Create Q2W + + 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 + """ + return await self._post( + "/v1/single-turn/q2w", + body=await async_maybe_transform(body, q2w_create_params.Q2wCreateParams), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=object, + ) + + async def list( + self, + *, + # 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, + ) -> object: + """获取所有的 Q2W 记录""" + return await self._get( + "/v1/single-turn/q2w", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=object, + ) + + +class Q2wResourceWithRawResponse: + def __init__(self, q2w: Q2wResource) -> None: + self._q2w = q2w + + self.create = to_raw_response_wrapper( + q2w.create, + ) + self.list = to_raw_response_wrapper( + q2w.list, + ) + + +class AsyncQ2wResourceWithRawResponse: + def __init__(self, q2w: AsyncQ2wResource) -> None: + self._q2w = q2w + + self.create = async_to_raw_response_wrapper( + q2w.create, + ) + self.list = async_to_raw_response_wrapper( + q2w.list, + ) + + +class Q2wResourceWithStreamingResponse: + def __init__(self, q2w: Q2wResource) -> None: + self._q2w = q2w + + self.create = to_streamed_response_wrapper( + q2w.create, + ) + self.list = to_streamed_response_wrapper( + q2w.list, + ) + + +class AsyncQ2wResourceWithStreamingResponse: + def __init__(self, q2w: AsyncQ2wResource) -> None: + self._q2w = q2w + + self.create = async_to_streamed_response_wrapper( + q2w.create, + ) + self.list = async_to_streamed_response_wrapper( + q2w.list, + ) diff --git a/src/asktable/resources/single_turn/single_turn.py b/src/asktable/resources/single_turn/single_turn.py new file mode 100644 index 00000000..ea0e0ecd --- /dev/null +++ b/src/asktable/resources/single_turn/single_turn.py @@ -0,0 +1,102 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from .q2w import ( + Q2wResource, + AsyncQ2wResource, + Q2wResourceWithRawResponse, + AsyncQ2wResourceWithRawResponse, + Q2wResourceWithStreamingResponse, + AsyncQ2wResourceWithStreamingResponse, +) +from ..._compat import cached_property +from ..._resource import SyncAPIResource, AsyncAPIResource + +__all__ = ["SingleTurnResource", "AsyncSingleTurnResource"] + + +class SingleTurnResource(SyncAPIResource): + @cached_property + def q2w(self) -> Q2wResource: + return Q2wResource(self._client) + + @cached_property + def with_raw_response(self) -> SingleTurnResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/DataMini/asktable-python#accessing-raw-response-data-eg-headers + """ + return SingleTurnResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> SingleTurnResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/DataMini/asktable-python#with_streaming_response + """ + return SingleTurnResourceWithStreamingResponse(self) + + +class AsyncSingleTurnResource(AsyncAPIResource): + @cached_property + def q2w(self) -> AsyncQ2wResource: + return AsyncQ2wResource(self._client) + + @cached_property + def with_raw_response(self) -> AsyncSingleTurnResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/DataMini/asktable-python#accessing-raw-response-data-eg-headers + """ + return AsyncSingleTurnResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncSingleTurnResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/DataMini/asktable-python#with_streaming_response + """ + return AsyncSingleTurnResourceWithStreamingResponse(self) + + +class SingleTurnResourceWithRawResponse: + def __init__(self, single_turn: SingleTurnResource) -> None: + self._single_turn = single_turn + + @cached_property + def q2w(self) -> Q2wResourceWithRawResponse: + return Q2wResourceWithRawResponse(self._single_turn.q2w) + + +class AsyncSingleTurnResourceWithRawResponse: + def __init__(self, single_turn: AsyncSingleTurnResource) -> None: + self._single_turn = single_turn + + @cached_property + def q2w(self) -> AsyncQ2wResourceWithRawResponse: + return AsyncQ2wResourceWithRawResponse(self._single_turn.q2w) + + +class SingleTurnResourceWithStreamingResponse: + def __init__(self, single_turn: SingleTurnResource) -> None: + self._single_turn = single_turn + + @cached_property + def q2w(self) -> Q2wResourceWithStreamingResponse: + return Q2wResourceWithStreamingResponse(self._single_turn.q2w) + + +class AsyncSingleTurnResourceWithStreamingResponse: + def __init__(self, single_turn: AsyncSingleTurnResource) -> None: + self._single_turn = single_turn + + @cached_property + def q2w(self) -> AsyncQ2wResourceWithStreamingResponse: + return AsyncQ2wResourceWithStreamingResponse(self._single_turn.q2w) diff --git a/src/asktable/types/__init__.py b/src/asktable/types/__init__.py index a132d23f..19d3b17f 100644 --- a/src/asktable/types/__init__.py +++ b/src/asktable/types/__init__.py @@ -39,12 +39,14 @@ from .extapi_update_params import ExtapiUpdateParams as ExtapiUpdateParams from .policy_create_params import PolicyCreateParams as PolicyCreateParams from .policy_update_params import PolicyUpdateParams as PolicyUpdateParams +from .polish_create_params import PolishCreateParams as PolishCreateParams from .training_list_params import TrainingListParams as TrainingListParams from .entry_with_definition import EntryWithDefinition as EntryWithDefinition from .project_update_params import ProjectUpdateParams as ProjectUpdateParams from .score_create_response import ScoreCreateResponse as ScoreCreateResponse from .chat_retrieve_response import ChatRetrieveResponse as ChatRetrieveResponse from .datasource_list_params import DatasourceListParams as DatasourceListParams +from .polish_create_response import PolishCreateResponse as PolishCreateResponse from .training_create_params import TrainingCreateParams as TrainingCreateParams from .training_delete_params import TrainingDeleteParams as TrainingDeleteParams from .training_list_response import TrainingListResponse as TrainingListResponse @@ -66,6 +68,7 @@ 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 .datasource_update_field_params import DatasourceUpdateFieldParams as DatasourceUpdateFieldParams from .securetunnel_list_links_params import SecuretunnelListLinksParams as SecuretunnelListLinksParams from .business_glossary_create_params import BusinessGlossaryCreateParams as BusinessGlossaryCreateParams from .business_glossary_update_params import BusinessGlossaryUpdateParams as BusinessGlossaryUpdateParams @@ -74,3 +77,6 @@ from .business_glossary_create_response import BusinessGlossaryCreateResponse as BusinessGlossaryCreateResponse from .integration_create_excel_ds_params import IntegrationCreateExcelDsParams as IntegrationCreateExcelDsParams from .project_list_model_groups_response import ProjectListModelGroupsResponse as ProjectListModelGroupsResponse +from .datasource_retrieve_runtime_meta_response import ( + DatasourceRetrieveRuntimeMetaResponse as DatasourceRetrieveRuntimeMetaResponse, +) diff --git a/src/asktable/types/datasource_retrieve_runtime_meta_response.py b/src/asktable/types/datasource_retrieve_runtime_meta_response.py new file mode 100644 index 00000000..4465ecb6 --- /dev/null +++ b/src/asktable/types/datasource_retrieve_runtime_meta_response.py @@ -0,0 +1,12 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Dict, List + +from .._models import BaseModel + +__all__ = ["DatasourceRetrieveRuntimeMetaResponse"] + + +class DatasourceRetrieveRuntimeMetaResponse(BaseModel): + schemas: Dict[str, List[str]] + """元数据""" diff --git a/src/asktable/types/datasource_update_field_params.py b/src/asktable/types/datasource_update_field_params.py new file mode 100644 index 00000000..9236c80e --- /dev/null +++ b/src/asktable/types/datasource_update_field_params.py @@ -0,0 +1,19 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Optional +from typing_extensions import Required, TypedDict + +__all__ = ["DatasourceUpdateFieldParams"] + + +class DatasourceUpdateFieldParams(TypedDict, total=False): + field_name: Required[str] + + schema_name: Required[str] + + table_name: Required[str] + + visibility: Optional[bool] + """field visibility""" diff --git a/src/asktable/types/polish_create_params.py b/src/asktable/types/polish_create_params.py new file mode 100644 index 00000000..08474fe4 --- /dev/null +++ b/src/asktable/types/polish_create_params.py @@ -0,0 +1,18 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Literal, Required, TypedDict + +__all__ = ["PolishCreateParams"] + + +class PolishCreateParams(TypedDict, total=False): + max_word_count: Required[int] + """润色后的最大字数,注意:该值不是绝对值,实际优化后的字数可能会超过该值""" + + user_desc: Required[str] + """需要润色的用户输入""" + + polish_mode: Literal[0] + """润色模式,默认是简化模式""" diff --git a/src/asktable/types/polish_create_response.py b/src/asktable/types/polish_create_response.py new file mode 100644 index 00000000..b92795cc --- /dev/null +++ b/src/asktable/types/polish_create_response.py @@ -0,0 +1,11 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + + +from .._models import BaseModel + +__all__ = ["PolishCreateResponse"] + + +class PolishCreateResponse(BaseModel): + polish_desc: str + """润色后的结果""" diff --git a/src/asktable/types/single_turn/__init__.py b/src/asktable/types/single_turn/__init__.py new file mode 100644 index 00000000..7d939a20 --- /dev/null +++ b/src/asktable/types/single_turn/__init__.py @@ -0,0 +1,5 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from .q2w_create_params import Q2wCreateParams as Q2wCreateParams diff --git a/src/asktable/types/single_turn/q2w_create_params.py b/src/asktable/types/single_turn/q2w_create_params.py new file mode 100644 index 00000000..4b03cfe5 --- /dev/null +++ b/src/asktable/types/single_turn/q2w_create_params.py @@ -0,0 +1,11 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Required, TypedDict + +__all__ = ["Q2wCreateParams"] + + +class Q2wCreateParams(TypedDict, total=False): + body: Required[object] diff --git a/tests/api_resources/single_turn/__init__.py b/tests/api_resources/single_turn/__init__.py new file mode 100644 index 00000000..fd8019a9 --- /dev/null +++ b/tests/api_resources/single_turn/__init__.py @@ -0,0 +1 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. diff --git a/tests/api_resources/single_turn/test_q2w.py b/tests/api_resources/single_turn/test_q2w.py new file mode 100644 index 00000000..bb01c335 --- /dev/null +++ b/tests/api_resources/single_turn/test_q2w.py @@ -0,0 +1,133 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from asktable import Asktable, AsyncAsktable +from tests.utils import assert_matches_type + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestQ2w: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + def test_method_create(self, client: Asktable) -> None: + q2w = client.single_turn.q2w.create( + body={}, + ) + assert_matches_type(object, q2w, path=["response"]) + + @parametrize + def test_raw_response_create(self, client: Asktable) -> None: + response = client.single_turn.q2w.with_raw_response.create( + body={}, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + q2w = response.parse() + assert_matches_type(object, q2w, path=["response"]) + + @parametrize + def test_streaming_response_create(self, client: Asktable) -> None: + with client.single_turn.q2w.with_streaming_response.create( + body={}, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + q2w = response.parse() + assert_matches_type(object, q2w, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_method_list(self, client: Asktable) -> None: + q2w = client.single_turn.q2w.list() + assert_matches_type(object, q2w, path=["response"]) + + @parametrize + def test_raw_response_list(self, client: Asktable) -> None: + response = client.single_turn.q2w.with_raw_response.list() + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + q2w = response.parse() + assert_matches_type(object, q2w, path=["response"]) + + @parametrize + def test_streaming_response_list(self, client: Asktable) -> None: + with client.single_turn.q2w.with_streaming_response.list() as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + q2w = response.parse() + assert_matches_type(object, q2w, path=["response"]) + + assert cast(Any, response.is_closed) is True + + +class TestAsyncQ2w: + parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + async def test_method_create(self, async_client: AsyncAsktable) -> None: + q2w = await async_client.single_turn.q2w.create( + body={}, + ) + assert_matches_type(object, q2w, path=["response"]) + + @parametrize + async def test_raw_response_create(self, async_client: AsyncAsktable) -> None: + response = await async_client.single_turn.q2w.with_raw_response.create( + body={}, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + q2w = await response.parse() + assert_matches_type(object, q2w, path=["response"]) + + @parametrize + async def test_streaming_response_create(self, async_client: AsyncAsktable) -> None: + async with async_client.single_turn.q2w.with_streaming_response.create( + body={}, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + q2w = await response.parse() + assert_matches_type(object, q2w, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_method_list(self, async_client: AsyncAsktable) -> None: + q2w = await async_client.single_turn.q2w.list() + assert_matches_type(object, q2w, path=["response"]) + + @parametrize + async def test_raw_response_list(self, async_client: AsyncAsktable) -> None: + response = await async_client.single_turn.q2w.with_raw_response.list() + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + q2w = await response.parse() + assert_matches_type(object, q2w, path=["response"]) + + @parametrize + async def test_streaming_response_list(self, async_client: AsyncAsktable) -> None: + async with async_client.single_turn.q2w.with_streaming_response.list() as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + q2w = await response.parse() + assert_matches_type(object, q2w, path=["response"]) + + assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/test_datasources.py b/tests/api_resources/test_datasources.py index 6cb041a0..a99d4858 100644 --- a/tests/api_resources/test_datasources.py +++ b/tests/api_resources/test_datasources.py @@ -12,6 +12,7 @@ from asktable.types import ( Datasource, DatasourceRetrieveResponse, + DatasourceRetrieveRuntimeMetaResponse, ) from asktable.pagination import SyncPage, AsyncPage @@ -334,6 +335,105 @@ def test_path_params_delete_file(self, client: Asktable) -> None: datasource_id="datasource_id", ) + @parametrize + def test_method_retrieve_runtime_meta(self, client: Asktable) -> None: + datasource = client.datasources.retrieve_runtime_meta( + "datasource_id", + ) + assert_matches_type(DatasourceRetrieveRuntimeMetaResponse, datasource, path=["response"]) + + @parametrize + def test_raw_response_retrieve_runtime_meta(self, client: Asktable) -> None: + response = client.datasources.with_raw_response.retrieve_runtime_meta( + "datasource_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + datasource = response.parse() + assert_matches_type(DatasourceRetrieveRuntimeMetaResponse, datasource, path=["response"]) + + @parametrize + def test_streaming_response_retrieve_runtime_meta(self, client: Asktable) -> None: + with client.datasources.with_streaming_response.retrieve_runtime_meta( + "datasource_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + datasource = response.parse() + assert_matches_type(DatasourceRetrieveRuntimeMetaResponse, datasource, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_retrieve_runtime_meta(self, client: Asktable) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `datasource_id` but received ''"): + client.datasources.with_raw_response.retrieve_runtime_meta( + "", + ) + + @parametrize + def test_method_update_field(self, client: Asktable) -> None: + datasource = client.datasources.update_field( + datasource_id="datasource_id", + field_name="field_name", + schema_name="schema_name", + table_name="table_name", + ) + assert_matches_type(object, datasource, path=["response"]) + + @parametrize + def test_method_update_field_with_all_params(self, client: Asktable) -> None: + datasource = client.datasources.update_field( + datasource_id="datasource_id", + field_name="field_name", + schema_name="schema_name", + table_name="table_name", + visibility=True, + ) + assert_matches_type(object, datasource, path=["response"]) + + @parametrize + def test_raw_response_update_field(self, client: Asktable) -> None: + response = client.datasources.with_raw_response.update_field( + datasource_id="datasource_id", + field_name="field_name", + schema_name="schema_name", + table_name="table_name", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + datasource = response.parse() + assert_matches_type(object, datasource, path=["response"]) + + @parametrize + def test_streaming_response_update_field(self, client: Asktable) -> None: + with client.datasources.with_streaming_response.update_field( + datasource_id="datasource_id", + field_name="field_name", + schema_name="schema_name", + table_name="table_name", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + datasource = response.parse() + assert_matches_type(object, datasource, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_update_field(self, client: Asktable) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `datasource_id` but received ''"): + client.datasources.with_raw_response.update_field( + datasource_id="", + field_name="field_name", + schema_name="schema_name", + table_name="table_name", + ) + class TestAsyncDatasources: parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) @@ -650,3 +750,102 @@ async def test_path_params_delete_file(self, async_client: AsyncAsktable) -> Non file_id="", datasource_id="datasource_id", ) + + @parametrize + async def test_method_retrieve_runtime_meta(self, async_client: AsyncAsktable) -> None: + datasource = await async_client.datasources.retrieve_runtime_meta( + "datasource_id", + ) + assert_matches_type(DatasourceRetrieveRuntimeMetaResponse, datasource, path=["response"]) + + @parametrize + async def test_raw_response_retrieve_runtime_meta(self, async_client: AsyncAsktable) -> None: + response = await async_client.datasources.with_raw_response.retrieve_runtime_meta( + "datasource_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + datasource = await response.parse() + assert_matches_type(DatasourceRetrieveRuntimeMetaResponse, datasource, path=["response"]) + + @parametrize + async def test_streaming_response_retrieve_runtime_meta(self, async_client: AsyncAsktable) -> None: + async with async_client.datasources.with_streaming_response.retrieve_runtime_meta( + "datasource_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + datasource = await response.parse() + assert_matches_type(DatasourceRetrieveRuntimeMetaResponse, datasource, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_retrieve_runtime_meta(self, async_client: AsyncAsktable) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `datasource_id` but received ''"): + await async_client.datasources.with_raw_response.retrieve_runtime_meta( + "", + ) + + @parametrize + async def test_method_update_field(self, async_client: AsyncAsktable) -> None: + datasource = await async_client.datasources.update_field( + datasource_id="datasource_id", + field_name="field_name", + schema_name="schema_name", + table_name="table_name", + ) + assert_matches_type(object, datasource, path=["response"]) + + @parametrize + async def test_method_update_field_with_all_params(self, async_client: AsyncAsktable) -> None: + datasource = await async_client.datasources.update_field( + datasource_id="datasource_id", + field_name="field_name", + schema_name="schema_name", + table_name="table_name", + visibility=True, + ) + assert_matches_type(object, datasource, path=["response"]) + + @parametrize + async def test_raw_response_update_field(self, async_client: AsyncAsktable) -> None: + response = await async_client.datasources.with_raw_response.update_field( + datasource_id="datasource_id", + field_name="field_name", + schema_name="schema_name", + table_name="table_name", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + datasource = await response.parse() + assert_matches_type(object, datasource, path=["response"]) + + @parametrize + async def test_streaming_response_update_field(self, async_client: AsyncAsktable) -> None: + async with async_client.datasources.with_streaming_response.update_field( + datasource_id="datasource_id", + field_name="field_name", + schema_name="schema_name", + table_name="table_name", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + datasource = await response.parse() + assert_matches_type(object, datasource, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_update_field(self, async_client: AsyncAsktable) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `datasource_id` but received ''"): + await async_client.datasources.with_raw_response.update_field( + datasource_id="", + field_name="field_name", + schema_name="schema_name", + table_name="table_name", + ) diff --git a/tests/api_resources/test_polish.py b/tests/api_resources/test_polish.py new file mode 100644 index 00000000..45ff3b66 --- /dev/null +++ b/tests/api_resources/test_polish.py @@ -0,0 +1,108 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from asktable import Asktable, AsyncAsktable +from tests.utils import assert_matches_type +from asktable.types import PolishCreateResponse + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestPolish: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + def test_method_create(self, client: Asktable) -> None: + polish = client.polish.create( + max_word_count=0, + user_desc="user_desc", + ) + assert_matches_type(PolishCreateResponse, polish, path=["response"]) + + @parametrize + def test_method_create_with_all_params(self, client: Asktable) -> None: + polish = client.polish.create( + max_word_count=0, + user_desc="user_desc", + polish_mode=0, + ) + assert_matches_type(PolishCreateResponse, polish, path=["response"]) + + @parametrize + def test_raw_response_create(self, client: Asktable) -> None: + response = client.polish.with_raw_response.create( + max_word_count=0, + user_desc="user_desc", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + polish = response.parse() + assert_matches_type(PolishCreateResponse, polish, path=["response"]) + + @parametrize + def test_streaming_response_create(self, client: Asktable) -> None: + with client.polish.with_streaming_response.create( + max_word_count=0, + user_desc="user_desc", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + polish = response.parse() + assert_matches_type(PolishCreateResponse, polish, path=["response"]) + + assert cast(Any, response.is_closed) is True + + +class TestAsyncPolish: + parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + async def test_method_create(self, async_client: AsyncAsktable) -> None: + polish = await async_client.polish.create( + max_word_count=0, + user_desc="user_desc", + ) + assert_matches_type(PolishCreateResponse, polish, path=["response"]) + + @parametrize + async def test_method_create_with_all_params(self, async_client: AsyncAsktable) -> None: + polish = await async_client.polish.create( + max_word_count=0, + user_desc="user_desc", + polish_mode=0, + ) + assert_matches_type(PolishCreateResponse, polish, path=["response"]) + + @parametrize + async def test_raw_response_create(self, async_client: AsyncAsktable) -> None: + response = await async_client.polish.with_raw_response.create( + max_word_count=0, + user_desc="user_desc", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + polish = await response.parse() + assert_matches_type(PolishCreateResponse, polish, path=["response"]) + + @parametrize + async def test_streaming_response_create(self, async_client: AsyncAsktable) -> None: + async with async_client.polish.with_streaming_response.create( + max_word_count=0, + user_desc="user_desc", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + polish = await response.parse() + assert_matches_type(PolishCreateResponse, polish, path=["response"]) + + assert cast(Any, response.is_closed) is True