diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index ac9a2e75..ff261bad 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -3,7 +3,7 @@ FROM mcr.microsoft.com/vscode/devcontainers/python:0-${VARIANT} USER vscode -RUN curl -sSf https://rye.astral.sh/get | RYE_VERSION="0.35.0" RYE_INSTALL_OPTION="--yes" bash +RUN curl -sSf https://rye.astral.sh/get | RYE_VERSION="0.44.0" RYE_INSTALL_OPTION="--yes" bash ENV PATH=/home/vscode/.rye/shims:$PATH -RUN echo "[[ -d .venv ]] && source .venv/bin/activate" >> /home/vscode/.bashrc +RUN echo "[[ -d .venv ]] && source .venv/bin/activate || export PATH=\$PATH" >> /home/vscode/.bashrc diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index bbeb30b1..c17fdc16 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -24,6 +24,9 @@ } } } + }, + "features": { + "ghcr.io/devcontainers/features/node:1": {} } // Features to add to the dev container. More info: https://containers.dev/features. diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 40293964..3b286e5a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,7 +12,6 @@ jobs: lint: name: lint runs-on: ubuntu-latest - steps: - uses: actions/checkout@v4 @@ -22,7 +21,7 @@ jobs: curl -sSf https://rye.astral.sh/get | bash echo "$HOME/.rye/shims" >> $GITHUB_PATH env: - RYE_VERSION: '0.35.0' + RYE_VERSION: '0.44.0' RYE_INSTALL_OPTION: '--yes' - name: Install dependencies @@ -30,6 +29,7 @@ jobs: - name: Run lints run: ./scripts/lint + test: name: test runs-on: ubuntu-latest @@ -42,7 +42,7 @@ jobs: curl -sSf https://rye.astral.sh/get | bash echo "$HOME/.rye/shims" >> $GITHUB_PATH env: - RYE_VERSION: '0.35.0' + RYE_VERSION: '0.44.0' RYE_INSTALL_OPTION: '--yes' - name: Bootstrap @@ -50,4 +50,3 @@ jobs: - name: Run tests run: ./scripts/test - diff --git a/.github/workflows/publish-pypi.yml b/.github/workflows/publish-pypi.yml index f501f43e..188841d6 100644 --- a/.github/workflows/publish-pypi.yml +++ b/.github/workflows/publish-pypi.yml @@ -21,7 +21,7 @@ jobs: curl -sSf https://rye.astral.sh/get | bash echo "$HOME/.rye/shims" >> $GITHUB_PATH env: - RYE_VERSION: '0.35.0' + RYE_VERSION: '0.44.0' RYE_INSTALL_OPTION: '--yes' - name: Publish to PyPI diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 3d5f4e35..1269f909 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "4.5.0" + ".": "4.6.0" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index 42ece98b..559383cc 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ -configured_endpoints: 91 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/datamini%2Fasktable-69140680dde56332aa42ebbfbe12c0c3db2adf3904e4a821cee6465e491f4c57.yml +configured_endpoints: 93 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/datamini%2Fasktable-02fbb644978089e8596def9999f5729633b652fba35bf04e374dbb71e7630355.yml diff --git a/CHANGELOG.md b/CHANGELOG.md index 0ed73450..26d3824b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,53 @@ # Changelog +## 4.6.0 (2025-03-15) + +Full Changelog: [v4.5.0...v4.6.0](https://github.com/DataMini/asktable-python/compare/v4.5.0...v4.6.0) + +### Features + +* **api:** api update ([#144](https://github.com/DataMini/asktable-python/issues/144)) ([668a25d](https://github.com/DataMini/asktable-python/commit/668a25dd349090c2f095d068a0ada72587aac38f)) +* **api:** manual updates ([#167](https://github.com/DataMini/asktable-python/issues/167)) ([06c63d2](https://github.com/DataMini/asktable-python/commit/06c63d292a5278295e93c4d7a65cf25b02234e2b)) +* **api:** manual updates ([#168](https://github.com/DataMini/asktable-python/issues/168)) ([8990ba9](https://github.com/DataMini/asktable-python/commit/8990ba9c162f2224e23e8db58646f2c485f77e1c)) +* **client:** allow passing `NotGiven` for body ([#155](https://github.com/DataMini/asktable-python/issues/155)) ([153f86b](https://github.com/DataMini/asktable-python/commit/153f86b5c5c0099edc9b0622ebe36553b653e8ca)) +* **client:** send `X-Stainless-Read-Timeout` header ([#149](https://github.com/DataMini/asktable-python/issues/149)) ([2bbef8d](https://github.com/DataMini/asktable-python/commit/2bbef8d335a87602e14fbea387f3b7fe136424f0)) + + +### Bug Fixes + +* asyncify on non-asyncio runtimes ([#153](https://github.com/DataMini/asktable-python/issues/153)) ([92577a2](https://github.com/DataMini/asktable-python/commit/92577a2765975e59273e218ba20c93cbed7a05c1)) +* **client:** mark some request bodies as optional ([153f86b](https://github.com/DataMini/asktable-python/commit/153f86b5c5c0099edc9b0622ebe36553b653e8ca)) +* improve names for conflicting params ([#148](https://github.com/DataMini/asktable-python/issues/148)) ([3f9650f](https://github.com/DataMini/asktable-python/commit/3f9650f5519444a1517dcf85bf313780e5dd6cce)) +* **types:** handle more discriminated union shapes ([#166](https://github.com/DataMini/asktable-python/issues/166)) ([850d425](https://github.com/DataMini/asktable-python/commit/850d425cf365d48cc9f7a41d09d295e8547befdf)) + + +### Chores + +* **docs:** update client docstring ([#159](https://github.com/DataMini/asktable-python/issues/159)) ([5a0da4d](https://github.com/DataMini/asktable-python/commit/5a0da4dd6288d7d55b7b2d4585b12e876d384423)) +* **internal:** bummp ruff dependency ([#147](https://github.com/DataMini/asktable-python/issues/147)) ([9638e50](https://github.com/DataMini/asktable-python/commit/9638e50e2a5325ba4cb66e8cd987d96da80f37d5)) +* **internal:** bump rye to 0.44.0 ([#165](https://github.com/DataMini/asktable-python/issues/165)) ([5ead610](https://github.com/DataMini/asktable-python/commit/5ead610c43bcde3e61ec6e2e6e4fd892be1f4e59)) +* **internal:** change default timeout to an int ([#146](https://github.com/DataMini/asktable-python/issues/146)) ([f418605](https://github.com/DataMini/asktable-python/commit/f41860576a0d6e8ce78352de1e997c3e8149a52f)) +* **internal:** codegen related update ([#138](https://github.com/DataMini/asktable-python/issues/138)) ([e70fbf4](https://github.com/DataMini/asktable-python/commit/e70fbf41048ca082ffd9f4888ccfa7bd9f97c57f)) +* **internal:** codegen related update ([#141](https://github.com/DataMini/asktable-python/issues/141)) ([56d0462](https://github.com/DataMini/asktable-python/commit/56d0462efef6c92a6727fd91c638a19750195d4e)) +* **internal:** codegen related update ([#154](https://github.com/DataMini/asktable-python/issues/154)) ([2242fad](https://github.com/DataMini/asktable-python/commit/2242fad33cc31d4bf434bc6161ca444c7cf3bf36)) +* **internal:** codegen related update ([#164](https://github.com/DataMini/asktable-python/issues/164)) ([1cb3903](https://github.com/DataMini/asktable-python/commit/1cb390324e6894374519e8062b446873d138cde0)) +* **internal:** fix devcontainers setup ([#156](https://github.com/DataMini/asktable-python/issues/156)) ([944423e](https://github.com/DataMini/asktable-python/commit/944423e7d0c69dcf0a54141ce69127db2369b247)) +* **internal:** fix type traversing dictionary params ([#150](https://github.com/DataMini/asktable-python/issues/150)) ([0caeb28](https://github.com/DataMini/asktable-python/commit/0caeb28b8647a9753b16bbc8a2963f900e4dd9d2)) +* **internal:** minor formatting changes ([#143](https://github.com/DataMini/asktable-python/issues/143)) ([a4ac34f](https://github.com/DataMini/asktable-python/commit/a4ac34fcf7a8350bdd03b5c51917ca5896183c63)) +* **internal:** minor style changes ([#142](https://github.com/DataMini/asktable-python/issues/142)) ([cb5834c](https://github.com/DataMini/asktable-python/commit/cb5834c4e4819f6c9a99dcd9a9d8296b413d0317)) +* **internal:** minor type handling changes ([#151](https://github.com/DataMini/asktable-python/issues/151)) ([67e6469](https://github.com/DataMini/asktable-python/commit/67e6469d84d6fc761ae2e7fc55d47ffb07c49309)) +* **internal:** properly set __pydantic_private__ ([#157](https://github.com/DataMini/asktable-python/issues/157)) ([30a260f](https://github.com/DataMini/asktable-python/commit/30a260f78f2b32e82467afe05703e2f8aa88fc68)) +* **internal:** remove extra empty newlines ([#163](https://github.com/DataMini/asktable-python/issues/163)) ([d8b30ce](https://github.com/DataMini/asktable-python/commit/d8b30cec54b715e20a90de84a4a3393a0b556c33)) +* **internal:** remove unused http client options forwarding ([#160](https://github.com/DataMini/asktable-python/issues/160)) ([298eb9c](https://github.com/DataMini/asktable-python/commit/298eb9ca830efd80ca27e868a0081ff4822dc2db)) +* **internal:** update client tests ([#152](https://github.com/DataMini/asktable-python/issues/152)) ([02af016](https://github.com/DataMini/asktable-python/commit/02af016ec2d3f945765bbc76a24a0a102757b966)) + + +### Documentation + +* **raw responses:** fix duplicate `the` ([#140](https://github.com/DataMini/asktable-python/issues/140)) ([5580989](https://github.com/DataMini/asktable-python/commit/55809895dc745aa046c93493ad7f658ed652c869)) +* revise readme docs about nested params ([#161](https://github.com/DataMini/asktable-python/issues/161)) ([c4a4e34](https://github.com/DataMini/asktable-python/commit/c4a4e34b3ddc3a19aac34cd4f167af53e2665933)) +* update URLs from stainlessapi.com to stainless.com ([#158](https://github.com/DataMini/asktable-python/issues/158)) ([a8ee0e2](https://github.com/DataMini/asktable-python/commit/a8ee0e203076b01180be2c164174a469c2f444ef)) + ## 4.5.0 (2025-01-19) Full Changelog: [v4.4.0...v4.5.0](https://github.com/DataMini/asktable-python/compare/v4.4.0...v4.5.0) diff --git a/README.md b/README.md index 1bd49bbb..84a1c27b 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ The Asktable Python library provides convenient access to the Asktable REST API application. The library includes type definitions for all request params and response fields, and offers both synchronous and asynchronous clients powered by [httpx](https://github.com/encode/httpx). -It is generated with [Stainless](https://www.stainlessapi.com/). +It is generated with [Stainless](https://www.stainless.com/). ## Documentation @@ -134,6 +134,43 @@ for datasource in first_page.items: # Remove `await` for non-async usage. ``` +## Nested params + +Nested parameters are dictionaries, typed using `TypedDict`, for example: + +```python +from asktable import Asktable + +client = Asktable() + +response = client.sys.projects.api_keys.create_token( + project_id="project_id", + chat_role={ + "role_id": "1", + "role_variables": {"id": "42"}, + }, +) +print(response.chat_role) +``` + +## File uploads + +Request parameters that correspond to file uploads can be passed as `bytes`, a [`PathLike`](https://docs.python.org/3/library/os.html#os.PathLike) instance or a tuple of `(filename, contents, media type)`. + +```python +from pathlib import Path +from asktable import Asktable + +client = Asktable() + +client.datasources.add_file( + datasource_id="datasource_id", + file=Path("/path/to/file"), +) +``` + +The async client uses the exact same interface. If you pass a [`PathLike`](https://docs.python.org/3/library/os.html#os.PathLike) instance, the file contents will be read asynchronously automatically. + ## Handling errors When the library is unable to connect to the API (for example, due to network connection problems or a timeout), a subclass of `asktable.APIConnectionError` is raised. diff --git a/SECURITY.md b/SECURITY.md index d5013e3a..6cf7553c 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -2,9 +2,9 @@ ## Reporting Security Issues -This SDK is generated by [Stainless Software Inc](http://stainlessapi.com). Stainless takes security seriously, and encourages you to report any security vulnerability promptly so that appropriate action can be taken. +This SDK is generated by [Stainless Software Inc](http://stainless.com). Stainless takes security seriously, and encourages you to report any security vulnerability promptly so that appropriate action can be taken. -To report a security issue, please contact the Stainless team at security@stainlessapi.com. +To report a security issue, please contact the Stainless team at security@stainless.com. ## Responsible Disclosure diff --git a/api.md b/api.md index bfeed1ba..1f1f2ec8 100644 --- a/api.md +++ b/api.md @@ -22,12 +22,12 @@ from asktable.types.sys import ( Methods: -- client.sys.projects.create(\*\*params) -> Project -- client.sys.projects.retrieve(project_id) -> Project -- client.sys.projects.update(project_id, \*\*params) -> Project -- client.sys.projects.list(\*\*params) -> SyncPage[Project] -- client.sys.projects.delete(project_id) -> object -- client.sys.projects.model_groups() -> ProjectModelGroupsResponse +- client.sys.projects.create(\*\*params) -> Project +- client.sys.projects.retrieve(project_id) -> Project +- client.sys.projects.update(project_id, \*\*params) -> Project +- client.sys.projects.list(\*\*params) -> SyncPage[Project] +- client.sys.projects.delete(project_id) -> object +- client.sys.projects.model_groups() -> ProjectModelGroupsResponse ### APIKeys @@ -43,10 +43,10 @@ from asktable.types.sys.projects import ( Methods: -- client.sys.projects.api_keys.create(project_id, \*\*params) -> APIKeyCreateResponse -- client.sys.projects.api_keys.list(project_id) -> APIKeyListResponse -- client.sys.projects.api_keys.delete(key_id, \*, project_id) -> None -- client.sys.projects.api_keys.create_token(project_id, \*\*params) -> object +- client.sys.projects.api_keys.create(project_id, \*\*params) -> APIKeyCreateResponse +- client.sys.projects.api_keys.list(project_id) -> APIKeyListResponse +- client.sys.projects.api_keys.delete(key_id, \*, project_id) -> None +- client.sys.projects.api_keys.create_token(project_id, \*\*params) -> object # Securetunnels @@ -58,12 +58,12 @@ from asktable.types import SecureTunnel, SecuretunnelListLinksResponse Methods: -- client.securetunnels.create(\*\*params) -> SecureTunnel -- client.securetunnels.retrieve(securetunnel_id) -> SecureTunnel -- client.securetunnels.update(securetunnel_id, \*\*params) -> SecureTunnel -- client.securetunnels.list(\*\*params) -> SyncPage[SecureTunnel] -- client.securetunnels.delete(securetunnel_id) -> None -- client.securetunnels.list_links(securetunnel_id, \*\*params) -> SyncPage[SecuretunnelListLinksResponse] +- client.securetunnels.create(\*\*params) -> SecureTunnel +- client.securetunnels.retrieve(securetunnel_id) -> SecureTunnel +- client.securetunnels.update(securetunnel_id, \*\*params) -> SecureTunnel +- client.securetunnels.list(\*\*params) -> SyncPage[SecureTunnel] +- client.securetunnels.delete(securetunnel_id) -> None +- client.securetunnels.list_links(securetunnel_id, \*\*params) -> SyncPage[SecuretunnelListLinksResponse] # Roles @@ -80,23 +80,23 @@ from asktable.types import ( Methods: -- client.roles.create(\*\*params) -> Role -- client.roles.retrieve(role_id) -> Role -- client.roles.update(role_id, \*\*params) -> Role -- client.roles.list(\*\*params) -> SyncPage[Role] -- client.roles.delete(role_id) -> object -- client.roles.get_polices(role_id) -> RoleGetPolicesResponse -- client.roles.get_variables(role_id, \*\*params) -> object +- client.roles.create(\*\*params) -> Role +- client.roles.retrieve(role_id) -> Role +- client.roles.update(role_id, \*\*params) -> Role +- client.roles.list(\*\*params) -> SyncPage[Role] +- client.roles.delete(role_id) -> object +- client.roles.get_polices(role_id) -> RoleGetPolicesResponse +- client.roles.get_variables(role_id, \*\*params) -> object # Policies Methods: -- client.policies.create(\*\*params) -> Policy -- client.policies.retrieve(policy_id) -> Policy -- client.policies.update(policy_id, \*\*params) -> Policy -- client.policies.list(\*\*params) -> SyncPage[Policy] -- client.policies.delete(policy_id) -> None +- client.policies.create(\*\*params) -> Policy +- client.policies.retrieve(policy_id) -> Policy +- client.policies.update(policy_id, \*\*params) -> Policy +- client.policies.list(\*\*params) -> SyncPage[Policy] +- client.policies.delete(policy_id) -> None # Chats @@ -108,10 +108,10 @@ from asktable.types import AIMessage, Chat, ToolMessage, UserMessage, ChatRetrie Methods: -- client.chats.create(\*\*params) -> Chat -- client.chats.retrieve(chat_id) -> ChatRetrieveResponse -- client.chats.list(\*\*params) -> SyncPage[Chat] -- client.chats.delete(chat_id) -> None +- client.chats.create(\*\*params) -> Chat +- client.chats.retrieve(chat_id) -> ChatRetrieveResponse +- client.chats.list(\*\*params) -> SyncPage[Chat] +- client.chats.delete(chat_id) -> None ## Messages @@ -123,9 +123,9 @@ from asktable.types.chats import MessageCreateResponse, MessageRetrieveResponse, Methods: -- client.chats.messages.create(chat_id, \*\*params) -> MessageCreateResponse -- client.chats.messages.retrieve(message_id, \*, chat_id) -> MessageRetrieveResponse -- client.chats.messages.list(chat_id, \*\*params) -> SyncPage[MessageListResponse] +- client.chats.messages.create(chat_id, \*\*params) -> MessageCreateResponse +- client.chats.messages.retrieve(message_id, \*, chat_id) -> MessageRetrieveResponse +- client.chats.messages.list(chat_id, \*\*params) -> SyncPage[MessageListResponse] # Datasources @@ -145,13 +145,13 @@ from asktable.types import ( Methods: -- client.datasources.create(\*\*params) -> Datasource -- client.datasources.retrieve(datasource_id) -> DatasourceRetrieveResponse -- client.datasources.update(datasource_id, \*\*params) -> Datasource -- client.datasources.list(\*\*params) -> SyncPage[Datasource] -- 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.create(\*\*params) -> Datasource +- client.datasources.retrieve(datasource_id) -> DatasourceRetrieveResponse +- client.datasources.update(datasource_id, \*\*params) -> Datasource +- client.datasources.list(\*\*params) -> SyncPage[Datasource] +- client.datasources.delete(datasource_id) -> object +- client.datasources.add_file(datasource_id, \*\*params) -> object +- client.datasources.delete_file(file_id, \*, datasource_id) -> object ## Meta @@ -163,10 +163,10 @@ from asktable.types.datasources import MetaCreateResponse, MetaUpdateResponse, M Methods: -- client.datasources.meta.create(datasource_id, \*\*params) -> object -- client.datasources.meta.retrieve(datasource_id) -> Meta -- client.datasources.meta.update(datasource_id, \*\*params) -> object -- client.datasources.meta.annotate(datasource_id, \*\*params) -> object +- client.datasources.meta.create(datasource_id, \*\*params) -> object +- client.datasources.meta.retrieve(datasource_id) -> Meta +- client.datasources.meta.update(datasource_id, \*\*params) -> object +- client.datasources.meta.annotate(datasource_id, \*\*params) -> object ## UploadParams @@ -178,7 +178,7 @@ from asktable.types.datasources import UploadParamCreateResponse Methods: -- client.datasources.upload_params.create(\*\*params) -> object +- client.datasources.upload_params.create(\*\*params) -> object ## Indexes @@ -190,9 +190,9 @@ from asktable.types.datasources import IndexCreateResponse, IndexDeleteResponse Methods: -- client.datasources.indexes.create(ds_id, \*\*params) -> object -- client.datasources.indexes.list(ds_id, \*\*params) -> SyncPage[Index] -- client.datasources.indexes.delete(index_id, \*, ds_id) -> object +- client.datasources.indexes.create(ds_id, \*\*params) -> object +- client.datasources.indexes.list(ds_id, \*\*params) -> SyncPage[Index] +- client.datasources.indexes.delete(index_id, \*, ds_id) -> object # Bots @@ -204,12 +204,12 @@ from asktable.types import Chatbot, BotDeleteResponse, BotInviteResponse Methods: -- client.bots.create(\*\*params) -> Chatbot -- client.bots.retrieve(bot_id) -> Chatbot -- client.bots.update(bot_id, \*\*params) -> Chatbot -- client.bots.list(\*\*params) -> SyncPage[Chatbot] -- client.bots.delete(bot_id) -> object -- client.bots.invite(bot_id, \*\*params) -> object +- client.bots.create(\*\*params) -> Chatbot +- client.bots.retrieve(bot_id) -> Chatbot +- client.bots.update(bot_id, \*\*params) -> Chatbot +- client.bots.list(\*\*params) -> SyncPage[Chatbot] +- client.bots.delete(bot_id) -> object +- client.bots.invite(bot_id, \*\*params) -> object # Extapis @@ -221,11 +221,11 @@ from asktable.types import Extapi, ExtapiDeleteResponse Methods: -- client.extapis.create(\*\*params) -> Extapi -- client.extapis.retrieve(extapi_id) -> Extapi -- client.extapis.update(extapi_id, \*\*params) -> Extapi -- client.extapis.list(\*\*params) -> SyncPage[Extapi] -- client.extapis.delete(extapi_id) -> object +- client.extapis.create(\*\*params) -> Extapi +- client.extapis.retrieve(extapi_id) -> Extapi +- client.extapis.update(extapi_id, \*\*params) -> Extapi +- client.extapis.list(\*\*params) -> SyncPage[Extapi] +- client.extapis.delete(extapi_id) -> object ## Routes @@ -237,11 +237,11 @@ from asktable.types.extapis import ExtapiRoute, RouteListResponse Methods: -- client.extapis.routes.create(\*, path_extapi_id, \*\*params) -> ExtapiRoute -- client.extapis.routes.retrieve(route_id, \*, extapi_id) -> ExtapiRoute -- client.extapis.routes.update(route_id, \*, extapi_id, \*\*params) -> ExtapiRoute -- client.extapis.routes.list(extapi_id) -> RouteListResponse -- client.extapis.routes.delete(route_id, \*, extapi_id) -> None +- client.extapis.routes.create(path_extapi_id, \*\*params) -> ExtapiRoute +- client.extapis.routes.retrieve(route_id, \*, extapi_id) -> ExtapiRoute +- client.extapis.routes.update(route_id, \*, extapi_id, \*\*params) -> ExtapiRoute +- client.extapis.routes.list(extapi_id) -> RouteListResponse +- client.extapis.routes.delete(route_id, \*, extapi_id) -> None # Auth @@ -253,8 +253,8 @@ from asktable.types import AuthCreateTokenResponse, AuthMeResponse Methods: -- client.auth.create_token(\*\*params) -> object -- client.auth.me() -> object +- client.auth.create_token(\*\*params) -> object +- client.auth.me() -> AuthMeResponse # Answers @@ -266,8 +266,8 @@ from asktable.types import AnswerResponse Methods: -- client.answers.create(\*\*params) -> AnswerResponse -- client.answers.list(\*\*params) -> SyncPage[AnswerResponse] +- client.answers.create(\*\*params) -> AnswerResponse +- client.answers.list(\*\*params) -> SyncPage[AnswerResponse] # Sqls @@ -279,14 +279,14 @@ from asktable.types import QueryResponse Methods: -- client.sqls.create(\*\*params) -> QueryResponse -- client.sqls.list(\*\*params) -> SyncPage[QueryResponse] +- client.sqls.create(\*\*params) -> QueryResponse +- client.sqls.list(\*\*params) -> SyncPage[QueryResponse] # Caches Methods: -- client.caches.delete(cache_id) -> None +- client.caches.delete(cache_id) -> None # Integration @@ -298,8 +298,8 @@ from asktable.types import FileAskResponse Methods: -- client.integration.create_excel_ds(\*\*params) -> Datasource -- client.integration.excel_csv_ask(\*\*params) -> FileAskResponse +- client.integration.create_excel_ds(\*\*params) -> Datasource +- client.integration.excel_csv_ask(\*\*params) -> FileAskResponse # BusinessGlossary @@ -316,11 +316,11 @@ from asktable.types import ( Methods: -- client.business_glossary.create(\*\*params) -> BusinessGlossaryCreateResponse -- client.business_glossary.retrieve(entry_id) -> EntryWithDefinition -- client.business_glossary.update(entry_id, \*\*params) -> Entry -- client.business_glossary.list(\*\*params) -> SyncPage[EntryWithDefinition] -- client.business_glossary.delete(entry_id) -> object +- client.business_glossary.create(\*\*params) -> BusinessGlossaryCreateResponse +- client.business_glossary.retrieve(entry_id) -> EntryWithDefinition +- client.business_glossary.update(entry_id, \*\*params) -> Entry +- client.business_glossary.list(\*\*params) -> SyncPage[EntryWithDefinition] +- client.business_glossary.delete(entry_id) -> object # Preferences @@ -337,10 +337,10 @@ from asktable.types import ( Methods: -- client.preferences.create(\*\*params) -> PreferenceCreateResponse -- client.preferences.retrieve() -> PreferenceRetrieveResponse -- client.preferences.update(\*\*params) -> PreferenceUpdateResponse -- client.preferences.delete() -> object +- client.preferences.create(\*\*params) -> PreferenceCreateResponse +- client.preferences.retrieve() -> PreferenceRetrieveResponse +- client.preferences.update(\*\*params) -> PreferenceUpdateResponse +- client.preferences.delete() -> object # Trainings @@ -352,9 +352,9 @@ from asktable.types import TrainingCreateResponse, TrainingListResponse, Trainin Methods: -- client.trainings.create(\*\*params) -> TrainingCreateResponse -- client.trainings.list(\*\*params) -> SyncPage[TrainingListResponse] -- client.trainings.delete(id, \*\*params) -> object +- client.trainings.create(\*\*params) -> TrainingCreateResponse +- client.trainings.list(\*\*params) -> SyncPage[TrainingListResponse] +- client.trainings.delete(id, \*\*params) -> object # Project @@ -366,9 +366,9 @@ from asktable.types import ProjectListModelGroupsResponse Methods: -- client.project.retrieve() -> Project -- client.project.update(\*\*params) -> Project -- client.project.list_model_groups() -> ProjectListModelGroupsResponse +- client.project.retrieve() -> Project +- client.project.update(\*\*params) -> Project +- client.project.list_model_groups() -> ProjectListModelGroupsResponse # Scores @@ -380,4 +380,28 @@ from asktable.types import ScoreCreateResponse Methods: -- client.scores.create(\*\*params) -> ScoreCreateResponse +- client.scores.create(\*\*params) -> ScoreCreateResponse + +# Files + +Types: + +```python +from asktable.types import FileRetrieveResponse +``` + +Methods: + +- client.files.retrieve(file_id) -> object + +# Dataframes + +Types: + +```python +from asktable.types import DataframeRetrieveResponse +``` + +Methods: + +- client.dataframes.retrieve(dataframe_id) -> DataframeRetrieveResponse diff --git a/pyproject.toml b/pyproject.toml index ee8b68bd..1deb1146 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "asktable" -version = "4.5.0" +version = "4.6.0" description = "The official Python library for the Asktable API" dynamic = ["readme"] license = "Apache-2.0" @@ -38,7 +38,6 @@ Homepage = "https://github.com/DataMini/asktable-python" Repository = "https://github.com/DataMini/asktable-python" - [tool.rye] managed = true # version pins are in requirements-dev.lock @@ -129,6 +128,7 @@ testpaths = ["tests"] addopts = "--tb=short" xfail_strict = true asyncio_mode = "auto" +asyncio_default_fixture_loop_scope = "session" filterwarnings = [ "error" ] @@ -151,7 +151,6 @@ reportImplicitOverride = true reportImportCycles = false reportPrivateUsage = false - [tool.ruff] line-length = 120 output-format = "grouped" @@ -176,7 +175,7 @@ select = [ "T201", "T203", # misuse of typing.TYPE_CHECKING - "TCH004", + "TC004", # import rules "TID251", ] diff --git a/requirements-dev.lock b/requirements-dev.lock index f9651665..a151188f 100644 --- a/requirements-dev.lock +++ b/requirements-dev.lock @@ -7,6 +7,7 @@ # all-features: true # with-sources: false # generate-hashes: false +# universal: false -e file:. annotated-types==0.6.0 @@ -78,7 +79,7 @@ pytz==2023.3.post1 # via dirty-equals respx==0.22.0 rich==13.7.1 -ruff==0.6.9 +ruff==0.9.4 setuptools==68.2.2 # via nodeenv six==1.16.0 diff --git a/requirements.lock b/requirements.lock index 2cd112f9..fe5769b4 100644 --- a/requirements.lock +++ b/requirements.lock @@ -7,6 +7,7 @@ # all-features: true # with-sources: false # generate-hashes: false +# universal: false -e file:. annotated-types==0.6.0 diff --git a/scripts/bootstrap b/scripts/bootstrap index 8c5c60eb..e84fe62c 100755 --- a/scripts/bootstrap +++ b/scripts/bootstrap @@ -4,7 +4,7 @@ set -e cd "$(dirname "$0")/.." -if [ -f "Brewfile" ] && [ "$(uname -s)" = "Darwin" ]; then +if ! command -v rye >/dev/null 2>&1 && [ -f "Brewfile" ] && [ "$(uname -s)" = "Darwin" ]; then brew bundle check >/dev/null 2>&1 || { echo "==> Installing Homebrew dependencies…" brew bundle diff --git a/scripts/lint b/scripts/lint index beabb640..c49721d9 100755 --- a/scripts/lint +++ b/scripts/lint @@ -9,4 +9,3 @@ rye run lint echo "==> Making sure it imports" rye run python -c 'import asktable' - diff --git a/scripts/test b/scripts/test index 4fa5698b..2b878456 100755 --- a/scripts/test +++ b/scripts/test @@ -52,6 +52,8 @@ else echo fi +export DEFER_PYDANTIC_BUILD=false + echo "==> Running tests" rye run pytest "$@" diff --git a/scripts/utils/ruffen-docs.py b/scripts/utils/ruffen-docs.py index 37b3d94f..0cf2bd2f 100644 --- a/scripts/utils/ruffen-docs.py +++ b/scripts/utils/ruffen-docs.py @@ -47,7 +47,7 @@ def _md_match(match: Match[str]) -> str: with _collect_error(match): code = format_code_block(code) code = textwrap.indent(code, match["indent"]) - return f'{match["before"]}{code}{match["after"]}' + return f"{match['before']}{code}{match['after']}" def _pycon_match(match: Match[str]) -> str: code = "" @@ -97,7 +97,7 @@ def finish_fragment() -> None: def _md_pycon_match(match: Match[str]) -> str: code = _pycon_match(match) code = textwrap.indent(code, match["indent"]) - return f'{match["before"]}{code}{match["after"]}' + return f"{match['before']}{code}{match['after']}" src = MD_RE.sub(_md_match, src) src = MD_PYCON_RE.sub(_md_pycon_match, src) diff --git a/src/asktable/_base_client.py b/src/asktable/_base_client.py index 29ab94e6..b43d29e9 100644 --- a/src/asktable/_base_client.py +++ b/src/asktable/_base_client.py @@ -9,7 +9,6 @@ import inspect import logging import platform -import warnings import email.utils from types import TracebackType from random import random @@ -36,7 +35,7 @@ import httpx import distro import pydantic -from httpx import URL, Limits +from httpx import URL from pydantic import PrivateAttr from . import _exceptions @@ -51,19 +50,16 @@ Timeout, NotGiven, ResponseT, - Transport, AnyMapping, PostParser, - ProxiesTypes, RequestFiles, HttpxSendArgs, - AsyncTransport, RequestOptions, HttpxRequestFiles, ModelBuilderProtocol, ) from ._utils import is_dict, is_list, asyncify, is_given, lru_cache, is_mapping -from ._compat import model_copy, model_dump +from ._compat import PYDANTIC_V2, model_copy, model_dump from ._models import GenericModel, FinalRequestOptions, validate_type, construct_type from ._response import ( APIResponse, @@ -207,6 +203,9 @@ def _set_private_attributes( model: Type[_T], options: FinalRequestOptions, ) -> None: + if PYDANTIC_V2 and getattr(self, "__pydantic_private__", None) is None: + self.__pydantic_private__ = {} + self._model = model self._client = client self._options = options @@ -292,6 +291,9 @@ def _set_private_attributes( client: AsyncAPIClient, options: FinalRequestOptions, ) -> None: + if PYDANTIC_V2 and getattr(self, "__pydantic_private__", None) is None: + self.__pydantic_private__ = {} + self._model = model self._client = client self._options = options @@ -331,9 +333,6 @@ class BaseClient(Generic[_HttpxClientT, _DefaultStreamT]): _base_url: URL max_retries: int timeout: Union[float, Timeout, None] - _limits: httpx.Limits - _proxies: ProxiesTypes | None - _transport: Transport | AsyncTransport | None _strict_response_validation: bool _idempotency_header: str | None _default_stream_cls: type[_DefaultStreamT] | None = None @@ -346,9 +345,6 @@ def __init__( _strict_response_validation: bool, max_retries: int = DEFAULT_MAX_RETRIES, timeout: float | Timeout | None = DEFAULT_TIMEOUT, - limits: httpx.Limits, - transport: Transport | AsyncTransport | None, - proxies: ProxiesTypes | None, custom_headers: Mapping[str, str] | None = None, custom_query: Mapping[str, object] | None = None, ) -> None: @@ -356,9 +352,6 @@ def __init__( self._base_url = self._enforce_trailing_slash(URL(base_url)) self.max_retries = max_retries self.timeout = timeout - self._limits = limits - self._proxies = proxies - self._transport = transport self._custom_headers = custom_headers or {} self._custom_query = custom_query or {} self._strict_response_validation = _strict_response_validation @@ -418,10 +411,17 @@ def _build_headers(self, options: FinalRequestOptions, *, retries_taken: int = 0 if idempotency_header and options.method.lower() != "get" and idempotency_header not in headers: headers[idempotency_header] = options.idempotency_key or self._idempotency_key() - # Don't set the retry count header if it was already set or removed by the caller. We check + # Don't set these headers if they were already set or removed by the caller. We check # `custom_headers`, which can contain `Omit()`, instead of `headers` to account for the removal case. - if "x-stainless-retry-count" not in (header.lower() for header in custom_headers): + lower_custom_headers = [header.lower() for header in custom_headers] + if "x-stainless-retry-count" not in lower_custom_headers: headers["x-stainless-retry-count"] = str(retries_taken) + if "x-stainless-read-timeout" not in lower_custom_headers: + timeout = self.timeout if isinstance(options.timeout, NotGiven) else options.timeout + if isinstance(timeout, Timeout): + timeout = timeout.read + if timeout is not None: + headers["x-stainless-read-timeout"] = str(timeout) return headers @@ -511,7 +511,7 @@ def _build_request( # so that passing a `TypedDict` doesn't cause an error. # https://github.com/microsoft/pyright/issues/3526#event-6715453066 params=self.qs.stringify(cast(Mapping[str, Any], params)) if params else None, - json=json_data, + json=json_data if is_given(json_data) else None, files=files, **kwargs, ) @@ -787,46 +787,11 @@ def __init__( base_url: str | URL, max_retries: int = DEFAULT_MAX_RETRIES, timeout: float | Timeout | None | NotGiven = NOT_GIVEN, - transport: Transport | None = None, - proxies: ProxiesTypes | None = None, - limits: Limits | None = None, http_client: httpx.Client | None = None, custom_headers: Mapping[str, str] | None = None, custom_query: Mapping[str, object] | None = None, _strict_response_validation: bool, ) -> None: - kwargs: dict[str, Any] = {} - if limits is not None: - warnings.warn( - "The `connection_pool_limits` argument is deprecated. The `http_client` argument should be passed instead", - category=DeprecationWarning, - stacklevel=3, - ) - if http_client is not None: - raise ValueError("The `http_client` argument is mutually exclusive with `connection_pool_limits`") - else: - limits = DEFAULT_CONNECTION_LIMITS - - if transport is not None: - kwargs["transport"] = transport - warnings.warn( - "The `transport` argument is deprecated. The `http_client` argument should be passed instead", - category=DeprecationWarning, - stacklevel=3, - ) - if http_client is not None: - raise ValueError("The `http_client` argument is mutually exclusive with `transport`") - - if proxies is not None: - kwargs["proxies"] = proxies - warnings.warn( - "The `proxies` argument is deprecated. The `http_client` argument should be passed instead", - category=DeprecationWarning, - stacklevel=3, - ) - if http_client is not None: - raise ValueError("The `http_client` argument is mutually exclusive with `proxies`") - if not is_given(timeout): # if the user passed in a custom http client with a non-default # timeout set then we use that timeout. @@ -847,12 +812,9 @@ def __init__( super().__init__( version=version, - limits=limits, # cast to a valid type because mypy doesn't understand our type narrowing timeout=cast(Timeout, timeout), - proxies=proxies, base_url=base_url, - transport=transport, max_retries=max_retries, custom_query=custom_query, custom_headers=custom_headers, @@ -862,9 +824,6 @@ def __init__( base_url=base_url, # cast to a valid type because mypy doesn't understand our type narrowing timeout=cast(Timeout, timeout), - limits=limits, - follow_redirects=True, - **kwargs, # type: ignore ) def is_closed(self) -> bool: @@ -1359,45 +1318,10 @@ def __init__( _strict_response_validation: bool, max_retries: int = DEFAULT_MAX_RETRIES, timeout: float | Timeout | None | NotGiven = NOT_GIVEN, - transport: AsyncTransport | None = None, - proxies: ProxiesTypes | None = None, - limits: Limits | None = None, http_client: httpx.AsyncClient | None = None, custom_headers: Mapping[str, str] | None = None, custom_query: Mapping[str, object] | None = None, ) -> None: - kwargs: dict[str, Any] = {} - if limits is not None: - warnings.warn( - "The `connection_pool_limits` argument is deprecated. The `http_client` argument should be passed instead", - category=DeprecationWarning, - stacklevel=3, - ) - if http_client is not None: - raise ValueError("The `http_client` argument is mutually exclusive with `connection_pool_limits`") - else: - limits = DEFAULT_CONNECTION_LIMITS - - if transport is not None: - kwargs["transport"] = transport - warnings.warn( - "The `transport` argument is deprecated. The `http_client` argument should be passed instead", - category=DeprecationWarning, - stacklevel=3, - ) - if http_client is not None: - raise ValueError("The `http_client` argument is mutually exclusive with `transport`") - - if proxies is not None: - kwargs["proxies"] = proxies - warnings.warn( - "The `proxies` argument is deprecated. The `http_client` argument should be passed instead", - category=DeprecationWarning, - stacklevel=3, - ) - if http_client is not None: - raise ValueError("The `http_client` argument is mutually exclusive with `proxies`") - if not is_given(timeout): # if the user passed in a custom http client with a non-default # timeout set then we use that timeout. @@ -1419,11 +1343,8 @@ def __init__( super().__init__( version=version, base_url=base_url, - limits=limits, # cast to a valid type because mypy doesn't understand our type narrowing timeout=cast(Timeout, timeout), - proxies=proxies, - transport=transport, max_retries=max_retries, custom_query=custom_query, custom_headers=custom_headers, @@ -1433,9 +1354,6 @@ def __init__( base_url=base_url, # cast to a valid type because mypy doesn't understand our type narrowing timeout=cast(Timeout, timeout), - limits=limits, - follow_redirects=True, - **kwargs, # type: ignore ) def is_closed(self) -> bool: diff --git a/src/asktable/_client.py b/src/asktable/_client.py index 6f5676d5..1569ca30 100644 --- a/src/asktable/_client.py +++ b/src/asktable/_client.py @@ -28,6 +28,7 @@ auth, bots, sqls, + files, roles, caches, scores, @@ -35,6 +36,7 @@ project, policies, trainings, + dataframes, integration, preferences, securetunnels, @@ -83,6 +85,8 @@ class Asktable(SyncAPIClient): trainings: trainings.TrainingsResource project: project.ProjectResource scores: scores.ScoresResource + files: files.FilesResource + dataframes: dataframes.DataframesResource with_raw_response: AsktableWithRawResponse with_streaming_response: AsktableWithStreamedResponse @@ -158,6 +162,8 @@ def __init__( self.trainings = trainings.TrainingsResource(self) self.project = project.ProjectResource(self) self.scores = scores.ScoresResource(self) + self.files = files.FilesResource(self) + self.dataframes = dataframes.DataframesResource(self) self.with_raw_response = AsktableWithRawResponse(self) self.with_streaming_response = AsktableWithStreamedResponse(self) @@ -285,6 +291,8 @@ class AsyncAsktable(AsyncAPIClient): trainings: trainings.AsyncTrainingsResource project: project.AsyncProjectResource scores: scores.AsyncScoresResource + files: files.AsyncFilesResource + dataframes: dataframes.AsyncDataframesResource with_raw_response: AsyncAsktableWithRawResponse with_streaming_response: AsyncAsktableWithStreamedResponse @@ -314,7 +322,7 @@ def __init__( # part of our public interface in the future. _strict_response_validation: bool = False, ) -> None: - """Construct a new async Asktable client instance. + """Construct a new async AsyncAsktable client instance. This automatically infers the `api_key` argument from the `ASKTABLE_API_KEY` environment variable if it is not provided. """ @@ -360,6 +368,8 @@ def __init__( self.trainings = trainings.AsyncTrainingsResource(self) self.project = project.AsyncProjectResource(self) self.scores = scores.AsyncScoresResource(self) + self.files = files.AsyncFilesResource(self) + self.dataframes = dataframes.AsyncDataframesResource(self) self.with_raw_response = AsyncAsktableWithRawResponse(self) self.with_streaming_response = AsyncAsktableWithStreamedResponse(self) @@ -488,6 +498,8 @@ def __init__(self, client: Asktable) -> None: self.trainings = trainings.TrainingsResourceWithRawResponse(client.trainings) self.project = project.ProjectResourceWithRawResponse(client.project) self.scores = scores.ScoresResourceWithRawResponse(client.scores) + self.files = files.FilesResourceWithRawResponse(client.files) + self.dataframes = dataframes.DataframesResourceWithRawResponse(client.dataframes) class AsyncAsktableWithRawResponse: @@ -512,6 +524,8 @@ def __init__(self, client: AsyncAsktable) -> None: self.trainings = trainings.AsyncTrainingsResourceWithRawResponse(client.trainings) self.project = project.AsyncProjectResourceWithRawResponse(client.project) self.scores = scores.AsyncScoresResourceWithRawResponse(client.scores) + self.files = files.AsyncFilesResourceWithRawResponse(client.files) + self.dataframes = dataframes.AsyncDataframesResourceWithRawResponse(client.dataframes) class AsktableWithStreamedResponse: @@ -536,6 +550,8 @@ def __init__(self, client: Asktable) -> None: self.trainings = trainings.TrainingsResourceWithStreamingResponse(client.trainings) self.project = project.ProjectResourceWithStreamingResponse(client.project) self.scores = scores.ScoresResourceWithStreamingResponse(client.scores) + self.files = files.FilesResourceWithStreamingResponse(client.files) + self.dataframes = dataframes.DataframesResourceWithStreamingResponse(client.dataframes) class AsyncAsktableWithStreamedResponse: @@ -560,6 +576,8 @@ def __init__(self, client: AsyncAsktable) -> None: self.trainings = trainings.AsyncTrainingsResourceWithStreamingResponse(client.trainings) self.project = project.AsyncProjectResourceWithStreamingResponse(client.project) self.scores = scores.AsyncScoresResourceWithStreamingResponse(client.scores) + self.files = files.AsyncFilesResourceWithStreamingResponse(client.files) + self.dataframes = dataframes.AsyncDataframesResourceWithStreamingResponse(client.dataframes) Client = Asktable diff --git a/src/asktable/_constants.py b/src/asktable/_constants.py index c3f2250a..7f806dde 100644 --- a/src/asktable/_constants.py +++ b/src/asktable/_constants.py @@ -6,7 +6,7 @@ OVERRIDE_CAST_TO_HEADER = "____stainless_override_cast_to" # default timeout is 5 minutes -DEFAULT_TIMEOUT = httpx.Timeout(timeout=300.0, connect=5.0) +DEFAULT_TIMEOUT = httpx.Timeout(timeout=300, connect=5.0) DEFAULT_MAX_RETRIES = 2 DEFAULT_CONNECTION_LIMITS = httpx.Limits(max_connections=100, max_keepalive_connections=20) diff --git a/src/asktable/_files.py b/src/asktable/_files.py index 715cc207..25ff804f 100644 --- a/src/asktable/_files.py +++ b/src/asktable/_files.py @@ -34,7 +34,7 @@ def assert_is_file_content(obj: object, *, key: str | None = None) -> None: if not is_file_content(obj): prefix = f"Expected entry at `{key}`" if key is not None else f"Expected file input `{obj!r}`" raise RuntimeError( - f"{prefix} to be bytes, an io.IOBase instance, PathLike or a tuple but received {type(obj)} instead." + f"{prefix} to be bytes, an io.IOBase instance, PathLike or a tuple but received {type(obj)} instead. See https://github.com/DataMini/asktable-python/tree/main#file-uploads" ) from None diff --git a/src/asktable/_models.py b/src/asktable/_models.py index 9a918aab..b51a1bf5 100644 --- a/src/asktable/_models.py +++ b/src/asktable/_models.py @@ -65,7 +65,7 @@ from ._constants import RAW_RESPONSE_HEADER if TYPE_CHECKING: - from pydantic_core.core_schema import ModelField, LiteralSchema, ModelFieldsSchema + from pydantic_core.core_schema import ModelField, ModelSchema, LiteralSchema, ModelFieldsSchema __all__ = ["BaseModel", "GenericModel"] @@ -172,7 +172,7 @@ def to_json( @override def __str__(self) -> str: # mypy complains about an invalid self arg - return f'{self.__repr_name__()}({self.__repr_str__(", ")})' # type: ignore[misc] + return f"{self.__repr_name__()}({self.__repr_str__(', ')})" # type: ignore[misc] # Override the 'construct' method in a way that supports recursive parsing without validation. # Based on https://github.com/samuelcolvin/pydantic/issues/1168#issuecomment-817742836. @@ -426,10 +426,16 @@ def construct_type(*, value: object, type_: object) -> object: If the given value does not match the expected type then it is returned as-is. """ + + # store a reference to the original type we were given before we extract any inner + # types so that we can properly resolve forward references in `TypeAliasType` annotations + original_type = None + # we allow `object` as the input type because otherwise, passing things like # `Literal['value']` will be reported as a type error by type checkers type_ = cast("type[object]", type_) if is_type_alias_type(type_): + original_type = type_ # type: ignore[unreachable] type_ = type_.__value__ # type: ignore[unreachable] # unwrap `Annotated[T, ...]` -> `T` @@ -446,7 +452,7 @@ def construct_type(*, value: object, type_: object) -> object: if is_union(origin): try: - return validate_type(type_=cast("type[object]", type_), value=value) + return validate_type(type_=cast("type[object]", original_type or type_), value=value) except Exception: pass @@ -640,15 +646,18 @@ def _build_discriminated_union_meta(*, union: type, meta_annotations: tuple[Any, def _extract_field_schema_pv2(model: type[BaseModel], field_name: str) -> ModelField | None: schema = model.__pydantic_core_schema__ + if schema["type"] == "definitions": + schema = schema["schema"] + if schema["type"] != "model": return None + schema = cast("ModelSchema", schema) fields_schema = schema["schema"] if fields_schema["type"] != "model-fields": return None fields_schema = cast("ModelFieldsSchema", fields_schema) - field = fields_schema["fields"].get(field_name) if not field: return None diff --git a/src/asktable/_response.py b/src/asktable/_response.py index 15416ac8..e7528b55 100644 --- a/src/asktable/_response.py +++ b/src/asktable/_response.py @@ -136,6 +136,8 @@ def _parse(self, *, to: type[_T] | None = None) -> R | _T: if cast_to and is_annotated_type(cast_to): cast_to = extract_type_arg(cast_to, 0) + origin = get_origin(cast_to) or cast_to + if self._is_sse_stream: if to: if not is_stream_class_type(to): @@ -195,8 +197,6 @@ def _parse(self, *, to: type[_T] | None = None) -> R | _T: if cast_to == bool: return cast(R, response.text.lower() == "true") - origin = get_origin(cast_to) or cast_to - if origin == APIResponse: raise RuntimeError("Unexpected state - cast_to is `APIResponse`") diff --git a/src/asktable/_utils/_sync.py b/src/asktable/_utils/_sync.py index 8b3aaf2b..ad7ec71b 100644 --- a/src/asktable/_utils/_sync.py +++ b/src/asktable/_utils/_sync.py @@ -7,16 +7,20 @@ from typing import Any, TypeVar, Callable, Awaitable from typing_extensions import ParamSpec +import anyio +import sniffio +import anyio.to_thread + T_Retval = TypeVar("T_Retval") T_ParamSpec = ParamSpec("T_ParamSpec") if sys.version_info >= (3, 9): - to_thread = asyncio.to_thread + _asyncio_to_thread = asyncio.to_thread else: # backport of https://docs.python.org/3/library/asyncio-task.html#asyncio.to_thread # for Python 3.8 support - async def to_thread( + async def _asyncio_to_thread( func: Callable[T_ParamSpec, T_Retval], /, *args: T_ParamSpec.args, **kwargs: T_ParamSpec.kwargs ) -> Any: """Asynchronously run function *func* in a separate thread. @@ -34,6 +38,17 @@ async def to_thread( return await loop.run_in_executor(None, func_call) +async def to_thread( + func: Callable[T_ParamSpec, T_Retval], /, *args: T_ParamSpec.args, **kwargs: T_ParamSpec.kwargs +) -> T_Retval: + if sniffio.current_async_library() == "asyncio": + return await _asyncio_to_thread(func, *args, **kwargs) + + return await anyio.to_thread.run_sync( + functools.partial(func, *args, **kwargs), + ) + + # inspired by `asyncer`, https://github.com/tiangolo/asyncer def asyncify(function: Callable[T_ParamSpec, T_Retval]) -> Callable[T_ParamSpec, Awaitable[T_Retval]]: """ diff --git a/src/asktable/_utils/_transform.py b/src/asktable/_utils/_transform.py index a6b62cad..18afd9d8 100644 --- a/src/asktable/_utils/_transform.py +++ b/src/asktable/_utils/_transform.py @@ -25,7 +25,7 @@ is_annotated_type, strip_annotated_type, ) -from .._compat import model_dump, is_typeddict +from .._compat import get_origin, model_dump, is_typeddict _T = TypeVar("_T") @@ -164,9 +164,14 @@ def _transform_recursive( inner_type = annotation stripped_type = strip_annotated_type(inner_type) + origin = get_origin(stripped_type) or stripped_type if is_typeddict(stripped_type) and is_mapping(data): return _transform_typeddict(data, stripped_type) + if origin == dict and is_mapping(data): + items_type = get_args(stripped_type)[1] + return {key: _transform_recursive(value, annotation=items_type) for key, value in data.items()} + if ( # List[T] (is_list_type(stripped_type) and is_list(data)) @@ -307,9 +312,14 @@ async def _async_transform_recursive( inner_type = annotation stripped_type = strip_annotated_type(inner_type) + origin = get_origin(stripped_type) or stripped_type if is_typeddict(stripped_type) and is_mapping(data): return await _async_transform_typeddict(data, stripped_type) + if origin == dict and is_mapping(data): + items_type = get_args(stripped_type)[1] + return {key: _transform_recursive(value, annotation=items_type) for key, value in data.items()} + if ( # List[T] (is_list_type(stripped_type) and is_list(data)) diff --git a/src/asktable/_version.py b/src/asktable/_version.py index ba79aa28..a25e89c3 100644 --- a/src/asktable/_version.py +++ b/src/asktable/_version.py @@ -1,4 +1,4 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. __title__ = "asktable" -__version__ = "4.5.0" # x-release-please-version +__version__ = "4.6.0" # x-release-please-version diff --git a/src/asktable/resources/__init__.py b/src/asktable/resources/__init__.py index 44456326..45e0bfb5 100644 --- a/src/asktable/resources/__init__.py +++ b/src/asktable/resources/__init__.py @@ -40,6 +40,14 @@ ChatsResourceWithStreamingResponse, AsyncChatsResourceWithStreamingResponse, ) +from .files import ( + FilesResource, + AsyncFilesResource, + FilesResourceWithRawResponse, + AsyncFilesResourceWithRawResponse, + FilesResourceWithStreamingResponse, + AsyncFilesResourceWithStreamingResponse, +) from .roles import ( RolesResource, AsyncRolesResource, @@ -104,6 +112,14 @@ TrainingsResourceWithStreamingResponse, AsyncTrainingsResourceWithStreamingResponse, ) +from .dataframes import ( + DataframesResource, + AsyncDataframesResource, + DataframesResourceWithRawResponse, + AsyncDataframesResourceWithRawResponse, + DataframesResourceWithStreamingResponse, + AsyncDataframesResourceWithStreamingResponse, +) from .datasources import ( DatasourcesResource, AsyncDatasourcesResource, @@ -254,4 +270,16 @@ "AsyncScoresResourceWithRawResponse", "ScoresResourceWithStreamingResponse", "AsyncScoresResourceWithStreamingResponse", + "FilesResource", + "AsyncFilesResource", + "FilesResourceWithRawResponse", + "AsyncFilesResourceWithRawResponse", + "FilesResourceWithStreamingResponse", + "AsyncFilesResourceWithStreamingResponse", + "DataframesResource", + "AsyncDataframesResource", + "DataframesResourceWithRawResponse", + "AsyncDataframesResourceWithRawResponse", + "DataframesResourceWithStreamingResponse", + "AsyncDataframesResourceWithStreamingResponse", ] diff --git a/src/asktable/resources/answers.py b/src/asktable/resources/answers.py index 07c92971..155a89bd 100644 --- a/src/asktable/resources/answers.py +++ b/src/asktable/resources/answers.py @@ -31,7 +31,7 @@ class AnswersResource(SyncAPIResource): @cached_property def with_raw_response(self) -> AnswersResourceWithRawResponse: """ - This property can be used as a prefix for any HTTP method call to return the + 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 @@ -89,7 +89,7 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ return self._post( - "/single-turn/q2a", + "/v1/single-turn/q2a", body=maybe_transform( { "datasource_id": datasource_id, @@ -139,7 +139,7 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ return self._get_api_list( - "/single-turn/q2a", + "/v1/single-turn/q2a", page=SyncPage[AnswerResponse], options=make_request_options( extra_headers=extra_headers, @@ -163,7 +163,7 @@ class AsyncAnswersResource(AsyncAPIResource): @cached_property def with_raw_response(self) -> AsyncAnswersResourceWithRawResponse: """ - This property can be used as a prefix for any HTTP method call to return the + 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 @@ -221,7 +221,7 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ return await self._post( - "/single-turn/q2a", + "/v1/single-turn/q2a", body=await async_maybe_transform( { "datasource_id": datasource_id, @@ -271,7 +271,7 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ return self._get_api_list( - "/single-turn/q2a", + "/v1/single-turn/q2a", page=AsyncPage[AnswerResponse], options=make_request_options( extra_headers=extra_headers, diff --git a/src/asktable/resources/auth.py b/src/asktable/resources/auth.py index 7fdb442c..b8ed671d 100644 --- a/src/asktable/resources/auth.py +++ b/src/asktable/resources/auth.py @@ -22,6 +22,7 @@ async_to_streamed_response_wrapper, ) from .._base_client import make_request_options +from ..types.auth_me_response import AuthMeResponse __all__ = ["AuthResource", "AsyncAuthResource"] @@ -30,7 +31,7 @@ class AuthResource(SyncAPIResource): @cached_property def with_raw_response(self) -> AuthResourceWithRawResponse: """ - This property can be used as a prefix for any HTTP method call to return the + 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 @@ -81,7 +82,7 @@ def create_token( timeout: Override the client-level default timeout for this request, in seconds """ return self._post( - "/auth/tokens", + "/v1/auth/tokens", body=maybe_transform( { "ak_role": ak_role, @@ -106,14 +107,14 @@ def me( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> object: + ) -> AuthMeResponse: """获取当前登录的 TokenID""" return self._get( - "/auth/me", + "/v1/auth/me", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - cast_to=object, + cast_to=AuthMeResponse, ) @@ -121,7 +122,7 @@ class AsyncAuthResource(AsyncAPIResource): @cached_property def with_raw_response(self) -> AsyncAuthResourceWithRawResponse: """ - This property can be used as a prefix for any HTTP method call to return the + 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 @@ -172,7 +173,7 @@ async def create_token( timeout: Override the client-level default timeout for this request, in seconds """ return await self._post( - "/auth/tokens", + "/v1/auth/tokens", body=await async_maybe_transform( { "ak_role": ak_role, @@ -197,14 +198,14 @@ async def me( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> object: + ) -> AuthMeResponse: """获取当前登录的 TokenID""" return await self._get( - "/auth/me", + "/v1/auth/me", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), - cast_to=object, + cast_to=AuthMeResponse, ) diff --git a/src/asktable/resources/bots.py b/src/asktable/resources/bots.py index 3195172f..6ce7781e 100644 --- a/src/asktable/resources/bots.py +++ b/src/asktable/resources/bots.py @@ -31,7 +31,7 @@ class BotsResource(SyncAPIResource): @cached_property def with_raw_response(self) -> BotsResourceWithRawResponse: """ - This property can be used as a prefix for any HTTP method call to return the + 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 @@ -100,7 +100,7 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ return self._post( - "/bots", + "/v1/bots", body=maybe_transform( { "datasource_ids": datasource_ids, @@ -148,7 +148,7 @@ def retrieve( if not bot_id: raise ValueError(f"Expected a non-empty value for `bot_id` but received {bot_id!r}") return self._get( - f"/bots/{bot_id}", + f"/v1/bots/{bot_id}", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -214,7 +214,7 @@ def update( if not bot_id: raise ValueError(f"Expected a non-empty value for `bot_id` but received {bot_id!r}") return self._patch( - f"/bots/{bot_id}", + f"/v1/bots/{bot_id}", body=maybe_transform( { "avatar_url": avatar_url, @@ -269,7 +269,7 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ return self._get_api_list( - "/bots", + "/v1/bots", page=SyncPage[Chatbot], options=make_request_options( extra_headers=extra_headers, @@ -314,7 +314,7 @@ def delete( if not bot_id: raise ValueError(f"Expected a non-empty value for `bot_id` but received {bot_id!r}") return self._delete( - f"/bots/{bot_id}", + f"/v1/bots/{bot_id}", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -348,7 +348,7 @@ def invite( if not bot_id: raise ValueError(f"Expected a non-empty value for `bot_id` but received {bot_id!r}") return self._post( - f"/bots/{bot_id}/invite", + f"/v1/bots/{bot_id}/invite", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -364,7 +364,7 @@ class AsyncBotsResource(AsyncAPIResource): @cached_property def with_raw_response(self) -> AsyncBotsResourceWithRawResponse: """ - This property can be used as a prefix for any HTTP method call to return the + 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 @@ -433,7 +433,7 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ return await self._post( - "/bots", + "/v1/bots", body=await async_maybe_transform( { "datasource_ids": datasource_ids, @@ -481,7 +481,7 @@ async def retrieve( if not bot_id: raise ValueError(f"Expected a non-empty value for `bot_id` but received {bot_id!r}") return await self._get( - f"/bots/{bot_id}", + f"/v1/bots/{bot_id}", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -547,7 +547,7 @@ async def update( if not bot_id: raise ValueError(f"Expected a non-empty value for `bot_id` but received {bot_id!r}") return await self._patch( - f"/bots/{bot_id}", + f"/v1/bots/{bot_id}", body=await async_maybe_transform( { "avatar_url": avatar_url, @@ -602,7 +602,7 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ return self._get_api_list( - "/bots", + "/v1/bots", page=AsyncPage[Chatbot], options=make_request_options( extra_headers=extra_headers, @@ -647,7 +647,7 @@ async def delete( if not bot_id: raise ValueError(f"Expected a non-empty value for `bot_id` but received {bot_id!r}") return await self._delete( - f"/bots/{bot_id}", + f"/v1/bots/{bot_id}", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -681,7 +681,7 @@ async def invite( if not bot_id: raise ValueError(f"Expected a non-empty value for `bot_id` but received {bot_id!r}") return await self._post( - f"/bots/{bot_id}/invite", + f"/v1/bots/{bot_id}/invite", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/asktable/resources/business_glossary.py b/src/asktable/resources/business_glossary.py index 3f62097a..18700d43 100644 --- a/src/asktable/resources/business_glossary.py +++ b/src/asktable/resources/business_glossary.py @@ -37,7 +37,7 @@ class BusinessGlossaryResource(SyncAPIResource): @cached_property def with_raw_response(self) -> BusinessGlossaryResourceWithRawResponse: """ - This property can be used as a prefix for any HTTP method call to return the + 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 @@ -77,7 +77,7 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ return self._post( - "/business-glossary", + "/v1/business-glossary", body=maybe_transform(body, Iterable[business_glossary_create_params.Body]), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -111,7 +111,7 @@ def retrieve( if not entry_id: raise ValueError(f"Expected a non-empty value for `entry_id` but received {entry_id!r}") return self._get( - f"/business-glossary/{entry_id}", + f"/v1/business-glossary/{entry_id}", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -156,7 +156,7 @@ def update( if not entry_id: raise ValueError(f"Expected a non-empty value for `entry_id` but received {entry_id!r}") return self._patch( - f"/business-glossary/{entry_id}", + f"/v1/business-glossary/{entry_id}", body=maybe_transform( { "aliases": aliases, @@ -204,7 +204,7 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ return self._get_api_list( - "/business-glossary", + "/v1/business-glossary", page=SyncPage[EntryWithDefinition], options=make_request_options( extra_headers=extra_headers, @@ -249,7 +249,7 @@ def delete( if not entry_id: raise ValueError(f"Expected a non-empty value for `entry_id` but received {entry_id!r}") return self._delete( - f"/business-glossary/{entry_id}", + f"/v1/business-glossary/{entry_id}", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -261,7 +261,7 @@ class AsyncBusinessGlossaryResource(AsyncAPIResource): @cached_property def with_raw_response(self) -> AsyncBusinessGlossaryResourceWithRawResponse: """ - This property can be used as a prefix for any HTTP method call to return the + 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 @@ -301,7 +301,7 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ return await self._post( - "/business-glossary", + "/v1/business-glossary", body=await async_maybe_transform(body, Iterable[business_glossary_create_params.Body]), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -335,7 +335,7 @@ async def retrieve( if not entry_id: raise ValueError(f"Expected a non-empty value for `entry_id` but received {entry_id!r}") return await self._get( - f"/business-glossary/{entry_id}", + f"/v1/business-glossary/{entry_id}", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -380,7 +380,7 @@ async def update( if not entry_id: raise ValueError(f"Expected a non-empty value for `entry_id` but received {entry_id!r}") return await self._patch( - f"/business-glossary/{entry_id}", + f"/v1/business-glossary/{entry_id}", body=await async_maybe_transform( { "aliases": aliases, @@ -428,7 +428,7 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ return self._get_api_list( - "/business-glossary", + "/v1/business-glossary", page=AsyncPage[EntryWithDefinition], options=make_request_options( extra_headers=extra_headers, @@ -473,7 +473,7 @@ async def delete( if not entry_id: raise ValueError(f"Expected a non-empty value for `entry_id` but received {entry_id!r}") return await self._delete( - f"/business-glossary/{entry_id}", + f"/v1/business-glossary/{entry_id}", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), diff --git a/src/asktable/resources/caches.py b/src/asktable/resources/caches.py index 9dde4a13..b89b7d6b 100644 --- a/src/asktable/resources/caches.py +++ b/src/asktable/resources/caches.py @@ -22,7 +22,7 @@ class CachesResource(SyncAPIResource): @cached_property def with_raw_response(self) -> CachesResourceWithRawResponse: """ - This property can be used as a prefix for any HTTP method call to return the + 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 @@ -65,7 +65,7 @@ def delete( raise ValueError(f"Expected a non-empty value for `cache_id` but received {cache_id!r}") extra_headers = {"Accept": "*/*", **(extra_headers or {})} return self._delete( - f"/caches/{cache_id}", + f"/v1/caches/{cache_id}", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -77,7 +77,7 @@ class AsyncCachesResource(AsyncAPIResource): @cached_property def with_raw_response(self) -> AsyncCachesResourceWithRawResponse: """ - This property can be used as a prefix for any HTTP method call to return the + 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 @@ -120,7 +120,7 @@ async def delete( raise ValueError(f"Expected a non-empty value for `cache_id` but received {cache_id!r}") extra_headers = {"Accept": "*/*", **(extra_headers or {})} return await self._delete( - f"/caches/{cache_id}", + f"/v1/caches/{cache_id}", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), diff --git a/src/asktable/resources/chats/chats.py b/src/asktable/resources/chats/chats.py index 3c6606ed..661ca731 100644 --- a/src/asktable/resources/chats/chats.py +++ b/src/asktable/resources/chats/chats.py @@ -44,7 +44,7 @@ def messages(self) -> MessagesResource: @cached_property def with_raw_response(self) -> ChatsResourceWithRawResponse: """ - This property can be used as a prefix for any HTTP method call to return the + 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 @@ -100,7 +100,7 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ return self._post( - "/chats", + "/v1/chats", body=maybe_transform( { "bot_id": bot_id, @@ -143,7 +143,7 @@ def retrieve( if not chat_id: raise ValueError(f"Expected a non-empty value for `chat_id` but received {chat_id!r}") return self._get( - f"/chats/{chat_id}", + f"/v1/chats/{chat_id}", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -179,7 +179,7 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ return self._get_api_list( - "/chats", + "/v1/chats", page=SyncPage[Chat], options=make_request_options( extra_headers=extra_headers, @@ -224,7 +224,7 @@ def delete( raise ValueError(f"Expected a non-empty value for `chat_id` but received {chat_id!r}") extra_headers = {"Accept": "*/*", **(extra_headers or {})} return self._delete( - f"/chats/{chat_id}", + f"/v1/chats/{chat_id}", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -240,7 +240,7 @@ def messages(self) -> AsyncMessagesResource: @cached_property def with_raw_response(self) -> AsyncChatsResourceWithRawResponse: """ - This property can be used as a prefix for any HTTP method call to return the + 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 @@ -296,7 +296,7 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ return await self._post( - "/chats", + "/v1/chats", body=await async_maybe_transform( { "bot_id": bot_id, @@ -339,7 +339,7 @@ async def retrieve( if not chat_id: raise ValueError(f"Expected a non-empty value for `chat_id` but received {chat_id!r}") return await self._get( - f"/chats/{chat_id}", + f"/v1/chats/{chat_id}", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -375,7 +375,7 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ return self._get_api_list( - "/chats", + "/v1/chats", page=AsyncPage[Chat], options=make_request_options( extra_headers=extra_headers, @@ -420,7 +420,7 @@ async def delete( raise ValueError(f"Expected a non-empty value for `chat_id` but received {chat_id!r}") extra_headers = {"Accept": "*/*", **(extra_headers or {})} return await self._delete( - f"/chats/{chat_id}", + f"/v1/chats/{chat_id}", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), diff --git a/src/asktable/resources/chats/messages.py b/src/asktable/resources/chats/messages.py index fe26fef5..8ad81c31 100644 --- a/src/asktable/resources/chats/messages.py +++ b/src/asktable/resources/chats/messages.py @@ -33,7 +33,7 @@ class MessagesResource(SyncAPIResource): @cached_property def with_raw_response(self) -> MessagesResourceWithRawResponse: """ - This property can be used as a prefix for any HTTP method call to return the + 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 @@ -62,7 +62,7 @@ def create( timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, ) -> MessageCreateResponse: """ - 发消息 + Send a message to the chat Args: extra_headers: Send extra headers @@ -78,7 +78,7 @@ def create( return cast( MessageCreateResponse, self._post( - f"/chats/{chat_id}/messages", + f"/v1/chats/{chat_id}/messages", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -123,7 +123,7 @@ def retrieve( return cast( MessageRetrieveResponse, self._get( - f"/chats/{chat_id}/messages/{message_id}", + f"/v1/chats/{chat_id}/messages/{message_id}", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -165,7 +165,7 @@ def list( if not chat_id: raise ValueError(f"Expected a non-empty value for `chat_id` but received {chat_id!r}") return self._get_api_list( - f"/chats/{chat_id}/messages", + f"/v1/chats/{chat_id}/messages", page=SyncPage[MessageListResponse], options=make_request_options( extra_headers=extra_headers, @@ -188,7 +188,7 @@ class AsyncMessagesResource(AsyncAPIResource): @cached_property def with_raw_response(self) -> AsyncMessagesResourceWithRawResponse: """ - This property can be used as a prefix for any HTTP method call to return the + 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 @@ -217,7 +217,7 @@ async def create( timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, ) -> MessageCreateResponse: """ - 发消息 + Send a message to the chat Args: extra_headers: Send extra headers @@ -233,7 +233,7 @@ async def create( return cast( MessageCreateResponse, await self._post( - f"/chats/{chat_id}/messages", + f"/v1/chats/{chat_id}/messages", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -280,7 +280,7 @@ async def retrieve( return cast( MessageRetrieveResponse, await self._get( - f"/chats/{chat_id}/messages/{message_id}", + f"/v1/chats/{chat_id}/messages/{message_id}", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -322,7 +322,7 @@ def list( if not chat_id: raise ValueError(f"Expected a non-empty value for `chat_id` but received {chat_id!r}") return self._get_api_list( - f"/chats/{chat_id}/messages", + f"/v1/chats/{chat_id}/messages", page=AsyncPage[MessageListResponse], options=make_request_options( extra_headers=extra_headers, diff --git a/src/asktable/resources/dataframes.py b/src/asktable/resources/dataframes.py new file mode 100644 index 00000000..4320689d --- /dev/null +++ b/src/asktable/resources/dataframes.py @@ -0,0 +1,163 @@ +# 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 .._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.dataframe_retrieve_response import DataframeRetrieveResponse + +__all__ = ["DataframesResource", "AsyncDataframesResource"] + + +class DataframesResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> DataframesResourceWithRawResponse: + """ + 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 DataframesResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> DataframesResourceWithStreamingResponse: + """ + 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 DataframesResourceWithStreamingResponse(self) + + def retrieve( + self, + dataframe_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, + ) -> DataframeRetrieveResponse: + """ + Get Dataframe + + 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 dataframe_id: + raise ValueError(f"Expected a non-empty value for `dataframe_id` but received {dataframe_id!r}") + return self._get( + f"/v1/dataframes/{dataframe_id}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=DataframeRetrieveResponse, + ) + + +class AsyncDataframesResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncDataframesResourceWithRawResponse: + """ + 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 AsyncDataframesResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncDataframesResourceWithStreamingResponse: + """ + 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 AsyncDataframesResourceWithStreamingResponse(self) + + async def retrieve( + self, + dataframe_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, + ) -> DataframeRetrieveResponse: + """ + Get Dataframe + + 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 dataframe_id: + raise ValueError(f"Expected a non-empty value for `dataframe_id` but received {dataframe_id!r}") + return await self._get( + f"/v1/dataframes/{dataframe_id}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=DataframeRetrieveResponse, + ) + + +class DataframesResourceWithRawResponse: + def __init__(self, dataframes: DataframesResource) -> None: + self._dataframes = dataframes + + self.retrieve = to_raw_response_wrapper( + dataframes.retrieve, + ) + + +class AsyncDataframesResourceWithRawResponse: + def __init__(self, dataframes: AsyncDataframesResource) -> None: + self._dataframes = dataframes + + self.retrieve = async_to_raw_response_wrapper( + dataframes.retrieve, + ) + + +class DataframesResourceWithStreamingResponse: + def __init__(self, dataframes: DataframesResource) -> None: + self._dataframes = dataframes + + self.retrieve = to_streamed_response_wrapper( + dataframes.retrieve, + ) + + +class AsyncDataframesResourceWithStreamingResponse: + def __init__(self, dataframes: AsyncDataframesResource) -> None: + self._dataframes = dataframes + + self.retrieve = async_to_streamed_response_wrapper( + dataframes.retrieve, + ) diff --git a/src/asktable/resources/datasources/datasources.py b/src/asktable/resources/datasources/datasources.py index 96752375..a2b9d29d 100644 --- a/src/asktable/resources/datasources/datasources.py +++ b/src/asktable/resources/datasources/datasources.py @@ -76,7 +76,7 @@ def indexes(self) -> IndexesResource: @cached_property def with_raw_response(self) -> DatasourcesResourceWithRawResponse: """ - This property can be used as a prefix for any HTTP method call to return the + 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 @@ -108,9 +108,8 @@ def create( "oracle", "polardbmysql", "polardbpg", + "dameng", ], - async_process_meta: bool | NotGiven = NOT_GIVEN, - value_index: bool | NotGiven = NOT_GIVEN, access_config: Optional[datasource_create_params.AccessConfig] | NotGiven = NOT_GIVEN, name: Optional[str] | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -139,7 +138,7 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ return self._post( - "/datasources", + "/v1/datasources", body=maybe_transform( { "engine": engine, @@ -149,17 +148,7 @@ def create( datasource_create_params.DatasourceCreateParams, ), 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, - "value_index": value_index, - }, - datasource_create_params.DatasourceCreateParams, - ), + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), cast_to=Datasource, ) @@ -190,7 +179,7 @@ def retrieve( if not datasource_id: raise ValueError(f"Expected a non-empty value for `datasource_id` but received {datasource_id!r}") return self._get( - f"/datasources/{datasource_id}", + f"/v1/datasources/{datasource_id}", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -217,6 +206,7 @@ def update( "oracle", "polardbmysql", "polardbpg", + "dameng", ] ] | NotGiven = NOT_GIVEN, @@ -269,7 +259,7 @@ def update( if not datasource_id: raise ValueError(f"Expected a non-empty value for `datasource_id` but received {datasource_id!r}") return self._patch( - f"/datasources/{datasource_id}", + f"/v1/datasources/{datasource_id}", body=maybe_transform( { "access_config": access_config, @@ -321,7 +311,7 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ return self._get_api_list( - "/datasources", + "/v1/datasources", page=SyncPage[Datasource], options=make_request_options( extra_headers=extra_headers, @@ -366,7 +356,7 @@ def delete( if not datasource_id: raise ValueError(f"Expected a non-empty value for `datasource_id` but received {datasource_id!r}") return self._delete( - f"/datasources/{datasource_id}", + f"/v1/datasources/{datasource_id}", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -406,7 +396,7 @@ def add_file( # multipart/form-data; boundary=---abc-- extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})} return self._post( - f"/datasources/{datasource_id}/files", + f"/v1/datasources/{datasource_id}/files", body=maybe_transform(body, datasource_add_file_params.DatasourceAddFileParams), files=files, options=make_request_options( @@ -444,7 +434,7 @@ def delete_file( if not file_id: raise ValueError(f"Expected a non-empty value for `file_id` but received {file_id!r}") return self._delete( - f"/datasources/{datasource_id}/files/{file_id}", + f"/v1/datasources/{datasource_id}/files/{file_id}", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -537,7 +527,7 @@ def indexes(self) -> AsyncIndexesResource: @cached_property def with_raw_response(self) -> AsyncDatasourcesResourceWithRawResponse: """ - This property can be used as a prefix for any HTTP method call to return the + 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 @@ -569,9 +559,8 @@ async def create( "oracle", "polardbmysql", "polardbpg", + "dameng", ], - async_process_meta: bool | NotGiven = NOT_GIVEN, - value_index: bool | NotGiven = NOT_GIVEN, access_config: Optional[datasource_create_params.AccessConfig] | NotGiven = NOT_GIVEN, name: Optional[str] | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -600,7 +589,7 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ return await self._post( - "/datasources", + "/v1/datasources", body=await async_maybe_transform( { "engine": engine, @@ -610,17 +599,7 @@ async def create( datasource_create_params.DatasourceCreateParams, ), 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, - "value_index": value_index, - }, - datasource_create_params.DatasourceCreateParams, - ), + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), cast_to=Datasource, ) @@ -651,7 +630,7 @@ async def retrieve( 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"/datasources/{datasource_id}", + f"/v1/datasources/{datasource_id}", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -678,6 +657,7 @@ async def update( "oracle", "polardbmysql", "polardbpg", + "dameng", ] ] | NotGiven = NOT_GIVEN, @@ -730,7 +710,7 @@ async def update( 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"/datasources/{datasource_id}", + f"/v1/datasources/{datasource_id}", body=await async_maybe_transform( { "access_config": access_config, @@ -782,7 +762,7 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ return self._get_api_list( - "/datasources", + "/v1/datasources", page=AsyncPage[Datasource], options=make_request_options( extra_headers=extra_headers, @@ -827,7 +807,7 @@ async def delete( if not datasource_id: raise ValueError(f"Expected a non-empty value for `datasource_id` but received {datasource_id!r}") return await self._delete( - f"/datasources/{datasource_id}", + f"/v1/datasources/{datasource_id}", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -867,7 +847,7 @@ async def add_file( # multipart/form-data; boundary=---abc-- extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})} return await self._post( - f"/datasources/{datasource_id}/files", + f"/v1/datasources/{datasource_id}/files", body=await async_maybe_transform(body, datasource_add_file_params.DatasourceAddFileParams), files=files, options=make_request_options( @@ -905,7 +885,7 @@ async def delete_file( if not file_id: raise ValueError(f"Expected a non-empty value for `file_id` but received {file_id!r}") return await self._delete( - f"/datasources/{datasource_id}/files/{file_id}", + f"/v1/datasources/{datasource_id}/files/{file_id}", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), diff --git a/src/asktable/resources/datasources/indexes.py b/src/asktable/resources/datasources/indexes.py index 8c5e4638..a4df4476 100644 --- a/src/asktable/resources/datasources/indexes.py +++ b/src/asktable/resources/datasources/indexes.py @@ -29,7 +29,7 @@ class IndexesResource(SyncAPIResource): @cached_property def with_raw_response(self) -> IndexesResourceWithRawResponse: """ - This property can be used as a prefix for any HTTP method call to return the + 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 @@ -82,7 +82,7 @@ def create( if not ds_id: raise ValueError(f"Expected a non-empty value for `ds_id` but received {ds_id!r}") return self._post( - f"/datasources/{ds_id}/indexes", + f"/v1/datasources/{ds_id}/indexes", body=maybe_transform( { "field_name": field_name, @@ -134,7 +134,7 @@ def list( if not ds_id: raise ValueError(f"Expected a non-empty value for `ds_id` but received {ds_id!r}") return self._get_api_list( - f"/datasources/{ds_id}/indexes", + f"/v1/datasources/{ds_id}/indexes", page=SyncPage[Index], options=make_request_options( extra_headers=extra_headers, @@ -181,7 +181,7 @@ def delete( if not index_id: raise ValueError(f"Expected a non-empty value for `index_id` but received {index_id!r}") return self._delete( - f"/datasources/{ds_id}/indexes/{index_id}", + f"/v1/datasources/{ds_id}/indexes/{index_id}", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -193,7 +193,7 @@ class AsyncIndexesResource(AsyncAPIResource): @cached_property def with_raw_response(self) -> AsyncIndexesResourceWithRawResponse: """ - This property can be used as a prefix for any HTTP method call to return the + 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 @@ -246,7 +246,7 @@ async def create( if not ds_id: raise ValueError(f"Expected a non-empty value for `ds_id` but received {ds_id!r}") return await self._post( - f"/datasources/{ds_id}/indexes", + f"/v1/datasources/{ds_id}/indexes", body=await async_maybe_transform( { "field_name": field_name, @@ -300,7 +300,7 @@ def list( if not ds_id: raise ValueError(f"Expected a non-empty value for `ds_id` but received {ds_id!r}") return self._get_api_list( - f"/datasources/{ds_id}/indexes", + f"/v1/datasources/{ds_id}/indexes", page=AsyncPage[Index], options=make_request_options( extra_headers=extra_headers, @@ -347,7 +347,7 @@ async def delete( if not index_id: raise ValueError(f"Expected a non-empty value for `index_id` but received {index_id!r}") return await self._delete( - f"/datasources/{ds_id}/indexes/{index_id}", + f"/v1/datasources/{ds_id}/indexes/{index_id}", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), diff --git a/src/asktable/resources/datasources/meta.py b/src/asktable/resources/datasources/meta.py index e52b23c1..ab219d17 100644 --- a/src/asktable/resources/datasources/meta.py +++ b/src/asktable/resources/datasources/meta.py @@ -2,7 +2,7 @@ from __future__ import annotations -from typing import Dict +from typing import Dict, List, Optional import httpx @@ -30,7 +30,7 @@ class MetaResource(SyncAPIResource): @cached_property def with_raw_response(self) -> MetaResourceWithRawResponse: """ - This property can be used as a prefix for any HTTP method call to return the + 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 @@ -50,10 +50,10 @@ def create( self, datasource_id: str, *, - name: str, async_process_meta: bool | NotGiven = NOT_GIVEN, value_index: bool | NotGiven = NOT_GIVEN, - schemas: Dict[str, meta_create_params.Schemas] | NotGiven = NOT_GIVEN, + meta: Optional[meta_create_params.Meta] | NotGiven = NOT_GIVEN, + selected_tables: Optional[Dict[str, List[str]]] | 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, @@ -69,8 +69,6 @@ def create( 否则从数据源中自动获取。 Args: - name: metadata_name - extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -82,11 +80,11 @@ def create( if not datasource_id: raise ValueError(f"Expected a non-empty value for `datasource_id` but received {datasource_id!r}") return self._post( - f"/datasources/{datasource_id}/meta", + f"/v1/datasources/{datasource_id}/meta", body=maybe_transform( { - "name": name, - "schemas": schemas, + "meta": meta, + "selected_tables": selected_tables, }, meta_create_params.MetaCreateParams, ), @@ -132,7 +130,7 @@ def retrieve( if not datasource_id: raise ValueError(f"Expected a non-empty value for `datasource_id` but received {datasource_id!r}") return self._get( - f"/datasources/{datasource_id}/meta", + f"/v1/datasources/{datasource_id}/meta", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -143,8 +141,9 @@ def update( self, datasource_id: str, *, - name: str, - schemas: Dict[str, meta_update_params.Schemas] | NotGiven = NOT_GIVEN, + async_process_meta: bool | NotGiven = NOT_GIVEN, + meta: Optional[meta_update_params.Meta] | NotGiven = NOT_GIVEN, + selected_tables: Optional[Dict[str, List[str]]] | 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, @@ -156,8 +155,6 @@ def update( 用于更新 DB 类型的数据源的 Meta(增加新表或者删除老表) Args: - name: metadata_name - extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -169,16 +166,20 @@ def update( if not datasource_id: raise ValueError(f"Expected a non-empty value for `datasource_id` but received {datasource_id!r}") return self._put( - f"/datasources/{datasource_id}/meta", + f"/v1/datasources/{datasource_id}/meta", body=maybe_transform( { - "name": name, - "schemas": schemas, + "meta": meta, + "selected_tables": selected_tables, }, meta_update_params.MetaUpdateParams, ), options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform({"async_process_meta": async_process_meta}, meta_update_params.MetaUpdateParams), ), cast_to=object, ) @@ -210,7 +211,7 @@ def annotate( if not datasource_id: raise ValueError(f"Expected a non-empty value for `datasource_id` but received {datasource_id!r}") return self._patch( - f"/datasources/{datasource_id}/meta", + f"/v1/datasources/{datasource_id}/meta", body=maybe_transform({"schemas": schemas}, meta_annotate_params.MetaAnnotateParams), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -223,7 +224,7 @@ class AsyncMetaResource(AsyncAPIResource): @cached_property def with_raw_response(self) -> AsyncMetaResourceWithRawResponse: """ - This property can be used as a prefix for any HTTP method call to return the + 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 @@ -243,10 +244,10 @@ async def create( self, datasource_id: str, *, - name: str, async_process_meta: bool | NotGiven = NOT_GIVEN, value_index: bool | NotGiven = NOT_GIVEN, - schemas: Dict[str, meta_create_params.Schemas] | NotGiven = NOT_GIVEN, + meta: Optional[meta_create_params.Meta] | NotGiven = NOT_GIVEN, + selected_tables: Optional[Dict[str, List[str]]] | 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, @@ -262,8 +263,6 @@ async def create( 否则从数据源中自动获取。 Args: - name: metadata_name - extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -275,11 +274,11 @@ async def create( if not datasource_id: raise ValueError(f"Expected a non-empty value for `datasource_id` but received {datasource_id!r}") return await self._post( - f"/datasources/{datasource_id}/meta", + f"/v1/datasources/{datasource_id}/meta", body=await async_maybe_transform( { - "name": name, - "schemas": schemas, + "meta": meta, + "selected_tables": selected_tables, }, meta_create_params.MetaCreateParams, ), @@ -325,7 +324,7 @@ async def retrieve( 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"/datasources/{datasource_id}/meta", + f"/v1/datasources/{datasource_id}/meta", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -336,8 +335,9 @@ async def update( self, datasource_id: str, *, - name: str, - schemas: Dict[str, meta_update_params.Schemas] | NotGiven = NOT_GIVEN, + async_process_meta: bool | NotGiven = NOT_GIVEN, + meta: Optional[meta_update_params.Meta] | NotGiven = NOT_GIVEN, + selected_tables: Optional[Dict[str, List[str]]] | 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, @@ -349,8 +349,6 @@ async def update( 用于更新 DB 类型的数据源的 Meta(增加新表或者删除老表) Args: - name: metadata_name - extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -362,16 +360,22 @@ async def update( if not datasource_id: raise ValueError(f"Expected a non-empty value for `datasource_id` but received {datasource_id!r}") return await self._put( - f"/datasources/{datasource_id}/meta", + f"/v1/datasources/{datasource_id}/meta", body=await async_maybe_transform( { - "name": name, - "schemas": schemas, + "meta": meta, + "selected_tables": selected_tables, }, meta_update_params.MetaUpdateParams, ), options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + 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}, meta_update_params.MetaUpdateParams + ), ), cast_to=object, ) @@ -403,7 +407,7 @@ async def annotate( 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"/datasources/{datasource_id}/meta", + f"/v1/datasources/{datasource_id}/meta", body=await async_maybe_transform({"schemas": schemas}, meta_annotate_params.MetaAnnotateParams), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout diff --git a/src/asktable/resources/datasources/upload_params.py b/src/asktable/resources/datasources/upload_params.py index 8ce7e2cb..54fd1d93 100644 --- a/src/asktable/resources/datasources/upload_params.py +++ b/src/asktable/resources/datasources/upload_params.py @@ -29,7 +29,7 @@ class UploadParamsResource(SyncAPIResource): @cached_property def with_raw_response(self) -> UploadParamsResourceWithRawResponse: """ - This property can be used as a prefix for any HTTP method call to return the + 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 @@ -74,7 +74,7 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ return self._post( - "/datasources/upload_params", + "/v1/datasources/upload_params", body=maybe_transform( { "expiration": expiration, @@ -93,7 +93,7 @@ class AsyncUploadParamsResource(AsyncAPIResource): @cached_property def with_raw_response(self) -> AsyncUploadParamsResourceWithRawResponse: """ - This property can be used as a prefix for any HTTP method call to return the + 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 @@ -138,7 +138,7 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ return await self._post( - "/datasources/upload_params", + "/v1/datasources/upload_params", body=await async_maybe_transform( { "expiration": expiration, diff --git a/src/asktable/resources/extapis/extapis.py b/src/asktable/resources/extapis/extapis.py index 65fd75dd..9c392981 100644 --- a/src/asktable/resources/extapis/extapis.py +++ b/src/asktable/resources/extapis/extapis.py @@ -43,7 +43,7 @@ def routes(self) -> RoutesResource: @cached_property def with_raw_response(self) -> ExtapisResourceWithRawResponse: """ - This property can be used as a prefix for any HTTP method call to return the + 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 @@ -91,7 +91,7 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ return self._post( - "/extapis", + "/v1/extapis", body=maybe_transform( { "base_url": base_url, @@ -132,7 +132,7 @@ def retrieve( if not extapi_id: raise ValueError(f"Expected a non-empty value for `extapi_id` but received {extapi_id!r}") return self._get( - f"/extapis/{extapi_id}", + f"/v1/extapis/{extapi_id}", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -174,7 +174,7 @@ def update( if not extapi_id: raise ValueError(f"Expected a non-empty value for `extapi_id` but received {extapi_id!r}") return self._post( - f"/extapis/{extapi_id}", + f"/v1/extapis/{extapi_id}", body=maybe_transform( { "base_url": base_url, @@ -221,7 +221,7 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ return self._get_api_list( - "/extapis", + "/v1/extapis", page=SyncPage[Extapi], options=make_request_options( extra_headers=extra_headers, @@ -266,7 +266,7 @@ def delete( if not extapi_id: raise ValueError(f"Expected a non-empty value for `extapi_id` but received {extapi_id!r}") return self._delete( - f"/extapis/{extapi_id}", + f"/v1/extapis/{extapi_id}", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -282,7 +282,7 @@ def routes(self) -> AsyncRoutesResource: @cached_property def with_raw_response(self) -> AsyncExtapisResourceWithRawResponse: """ - This property can be used as a prefix for any HTTP method call to return the + 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 @@ -330,7 +330,7 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ return await self._post( - "/extapis", + "/v1/extapis", body=await async_maybe_transform( { "base_url": base_url, @@ -371,7 +371,7 @@ async def retrieve( if not extapi_id: raise ValueError(f"Expected a non-empty value for `extapi_id` but received {extapi_id!r}") return await self._get( - f"/extapis/{extapi_id}", + f"/v1/extapis/{extapi_id}", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -413,7 +413,7 @@ async def update( if not extapi_id: raise ValueError(f"Expected a non-empty value for `extapi_id` but received {extapi_id!r}") return await self._post( - f"/extapis/{extapi_id}", + f"/v1/extapis/{extapi_id}", body=await async_maybe_transform( { "base_url": base_url, @@ -460,7 +460,7 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ return self._get_api_list( - "/extapis", + "/v1/extapis", page=AsyncPage[Extapi], options=make_request_options( extra_headers=extra_headers, @@ -505,7 +505,7 @@ async def delete( if not extapi_id: raise ValueError(f"Expected a non-empty value for `extapi_id` but received {extapi_id!r}") return await self._delete( - f"/extapis/{extapi_id}", + f"/v1/extapis/{extapi_id}", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), diff --git a/src/asktable/resources/extapis/routes.py b/src/asktable/resources/extapis/routes.py index 994f1cb4..2551affa 100644 --- a/src/asktable/resources/extapis/routes.py +++ b/src/asktable/resources/extapis/routes.py @@ -33,7 +33,7 @@ class RoutesResource(SyncAPIResource): @cached_property def with_raw_response(self) -> RoutesResourceWithRawResponse: """ - This property can be used as a prefix for any HTTP method call to return the + 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 @@ -51,8 +51,8 @@ def with_streaming_response(self) -> RoutesResourceWithStreamingResponse: def create( self, - *, path_extapi_id: str, + *, id: str, created_at: Union[str, datetime], body_extapi_id: str, @@ -60,10 +60,10 @@ def create( name: str, path: str, project_id: str, + updated_at: Union[str, datetime], body_params_desc: Optional[str] | NotGiven = NOT_GIVEN, path_params_desc: Optional[str] | NotGiven = NOT_GIVEN, query_params_desc: Optional[str] | NotGiven = NOT_GIVEN, - updated_at: Union[str, datetime] | 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, @@ -98,7 +98,7 @@ def create( if not path_extapi_id: raise ValueError(f"Expected a non-empty value for `path_extapi_id` but received {path_extapi_id!r}") return self._post( - f"/extapis/{path_extapi_id}/routes", + f"/v1/extapis/{path_extapi_id}/routes", body=maybe_transform( { "id": id, @@ -108,10 +108,10 @@ def create( "name": name, "path": path, "project_id": project_id, + "updated_at": updated_at, "body_params_desc": body_params_desc, "path_params_desc": path_params_desc, "query_params_desc": query_params_desc, - "updated_at": updated_at, }, route_create_params.RouteCreateParams, ), @@ -150,7 +150,7 @@ def retrieve( if not route_id: raise ValueError(f"Expected a non-empty value for `route_id` but received {route_id!r}") return self._get( - f"/extapis/{extapi_id}/routes/{route_id}", + f"/v1/extapis/{extapi_id}/routes/{route_id}", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -204,7 +204,7 @@ def update( if not route_id: raise ValueError(f"Expected a non-empty value for `route_id` but received {route_id!r}") return self._post( - f"/extapis/{extapi_id}/routes/{route_id}", + f"/v1/extapis/{extapi_id}/routes/{route_id}", body=maybe_transform( { "body_params_desc": body_params_desc, @@ -248,7 +248,7 @@ def list( if not extapi_id: raise ValueError(f"Expected a non-empty value for `extapi_id` but received {extapi_id!r}") return self._get( - f"/extapis/{extapi_id}/routes", + f"/v1/extapis/{extapi_id}/routes", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -285,7 +285,7 @@ def delete( raise ValueError(f"Expected a non-empty value for `route_id` but received {route_id!r}") extra_headers = {"Accept": "*/*", **(extra_headers or {})} return self._delete( - f"/extapis/{extapi_id}/routes/{route_id}", + f"/v1/extapis/{extapi_id}/routes/{route_id}", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -297,7 +297,7 @@ class AsyncRoutesResource(AsyncAPIResource): @cached_property def with_raw_response(self) -> AsyncRoutesResourceWithRawResponse: """ - This property can be used as a prefix for any HTTP method call to return the + 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 @@ -315,8 +315,8 @@ def with_streaming_response(self) -> AsyncRoutesResourceWithStreamingResponse: async def create( self, - *, path_extapi_id: str, + *, id: str, created_at: Union[str, datetime], body_extapi_id: str, @@ -324,10 +324,10 @@ async def create( name: str, path: str, project_id: str, + updated_at: Union[str, datetime], body_params_desc: Optional[str] | NotGiven = NOT_GIVEN, path_params_desc: Optional[str] | NotGiven = NOT_GIVEN, query_params_desc: Optional[str] | NotGiven = NOT_GIVEN, - updated_at: Union[str, datetime] | 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, @@ -362,7 +362,7 @@ async def create( if not path_extapi_id: raise ValueError(f"Expected a non-empty value for `path_extapi_id` but received {path_extapi_id!r}") return await self._post( - f"/extapis/{path_extapi_id}/routes", + f"/v1/extapis/{path_extapi_id}/routes", body=await async_maybe_transform( { "id": id, @@ -372,10 +372,10 @@ async def create( "name": name, "path": path, "project_id": project_id, + "updated_at": updated_at, "body_params_desc": body_params_desc, "path_params_desc": path_params_desc, "query_params_desc": query_params_desc, - "updated_at": updated_at, }, route_create_params.RouteCreateParams, ), @@ -414,7 +414,7 @@ async def retrieve( if not route_id: raise ValueError(f"Expected a non-empty value for `route_id` but received {route_id!r}") return await self._get( - f"/extapis/{extapi_id}/routes/{route_id}", + f"/v1/extapis/{extapi_id}/routes/{route_id}", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -468,7 +468,7 @@ async def update( if not route_id: raise ValueError(f"Expected a non-empty value for `route_id` but received {route_id!r}") return await self._post( - f"/extapis/{extapi_id}/routes/{route_id}", + f"/v1/extapis/{extapi_id}/routes/{route_id}", body=await async_maybe_transform( { "body_params_desc": body_params_desc, @@ -512,7 +512,7 @@ async def list( if not extapi_id: raise ValueError(f"Expected a non-empty value for `extapi_id` but received {extapi_id!r}") return await self._get( - f"/extapis/{extapi_id}/routes", + f"/v1/extapis/{extapi_id}/routes", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -549,7 +549,7 @@ async def delete( raise ValueError(f"Expected a non-empty value for `route_id` but received {route_id!r}") extra_headers = {"Accept": "*/*", **(extra_headers or {})} return await self._delete( - f"/extapis/{extapi_id}/routes/{route_id}", + f"/v1/extapis/{extapi_id}/routes/{route_id}", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), diff --git a/src/asktable/resources/files.py b/src/asktable/resources/files.py new file mode 100644 index 00000000..6673a7bf --- /dev/null +++ b/src/asktable/resources/files.py @@ -0,0 +1,162 @@ +# 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 .._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 + +__all__ = ["FilesResource", "AsyncFilesResource"] + + +class FilesResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> FilesResourceWithRawResponse: + """ + 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 FilesResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> FilesResourceWithStreamingResponse: + """ + 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 FilesResourceWithStreamingResponse(self) + + def retrieve( + self, + file_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, + ) -> object: + """ + 获取文件 + + 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 file_id: + raise ValueError(f"Expected a non-empty value for `file_id` but received {file_id!r}") + return self._get( + f"/v1/files/{file_id}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=object, + ) + + +class AsyncFilesResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncFilesResourceWithRawResponse: + """ + 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 AsyncFilesResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncFilesResourceWithStreamingResponse: + """ + 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 AsyncFilesResourceWithStreamingResponse(self) + + async def retrieve( + self, + file_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, + ) -> object: + """ + 获取文件 + + 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 file_id: + raise ValueError(f"Expected a non-empty value for `file_id` but received {file_id!r}") + return await self._get( + f"/v1/files/{file_id}", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=object, + ) + + +class FilesResourceWithRawResponse: + def __init__(self, files: FilesResource) -> None: + self._files = files + + self.retrieve = to_raw_response_wrapper( + files.retrieve, + ) + + +class AsyncFilesResourceWithRawResponse: + def __init__(self, files: AsyncFilesResource) -> None: + self._files = files + + self.retrieve = async_to_raw_response_wrapper( + files.retrieve, + ) + + +class FilesResourceWithStreamingResponse: + def __init__(self, files: FilesResource) -> None: + self._files = files + + self.retrieve = to_streamed_response_wrapper( + files.retrieve, + ) + + +class AsyncFilesResourceWithStreamingResponse: + def __init__(self, files: AsyncFilesResource) -> None: + self._files = files + + self.retrieve = async_to_streamed_response_wrapper( + files.retrieve, + ) diff --git a/src/asktable/resources/integration.py b/src/asktable/resources/integration.py index 1b9a2934..f4384669 100644 --- a/src/asktable/resources/integration.py +++ b/src/asktable/resources/integration.py @@ -31,7 +31,7 @@ class IntegrationResource(SyncAPIResource): @cached_property def with_raw_response(self) -> IntegrationResourceWithRawResponse: """ - This property can be used as a prefix for any HTTP method call to return the + 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 @@ -72,7 +72,7 @@ def create_excel_ds( timeout: Override the client-level default timeout for this request, in seconds """ return self._post( - "/integration/create_excel_ds", + "/v1/integration/create_excel_ds", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -121,7 +121,7 @@ def excel_csv_ask( timeout: Override the client-level default timeout for this request, in seconds """ return self._post( - "/integration/excel_csv_ask", + "/v1/integration/excel_csv_ask", body=maybe_transform( { "file_url": file_url, @@ -141,7 +141,7 @@ class AsyncIntegrationResource(AsyncAPIResource): @cached_property def with_raw_response(self) -> AsyncIntegrationResourceWithRawResponse: """ - This property can be used as a prefix for any HTTP method call to return the + 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 @@ -182,7 +182,7 @@ async def create_excel_ds( timeout: Override the client-level default timeout for this request, in seconds """ return await self._post( - "/integration/create_excel_ds", + "/v1/integration/create_excel_ds", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -231,7 +231,7 @@ async def excel_csv_ask( timeout: Override the client-level default timeout for this request, in seconds """ return await self._post( - "/integration/excel_csv_ask", + "/v1/integration/excel_csv_ask", body=await async_maybe_transform( { "file_url": file_url, diff --git a/src/asktable/resources/policies.py b/src/asktable/resources/policies.py index 638787a2..7452080f 100644 --- a/src/asktable/resources/policies.py +++ b/src/asktable/resources/policies.py @@ -32,7 +32,7 @@ class PoliciesResource(SyncAPIResource): @cached_property def with_raw_response(self) -> PoliciesResourceWithRawResponse: """ - This property can be used as a prefix for any HTTP method call to return the + 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 @@ -80,7 +80,7 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ return self._post( - "/policies", + "/v1/policies", body=maybe_transform( { "dataset_config": dataset_config, @@ -121,7 +121,7 @@ def retrieve( if not policy_id: raise ValueError(f"Expected a non-empty value for `policy_id` but received {policy_id!r}") return self._get( - f"/policies/{policy_id}", + f"/v1/policies/{policy_id}", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -163,7 +163,7 @@ def update( if not policy_id: raise ValueError(f"Expected a non-empty value for `policy_id` but received {policy_id!r}") return self._patch( - f"/policies/{policy_id}", + f"/v1/policies/{policy_id}", body=maybe_transform( { "dataset_config": dataset_config, @@ -213,7 +213,7 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ return self._get_api_list( - "/policies", + "/v1/policies", page=SyncPage[Policy], options=make_request_options( extra_headers=extra_headers, @@ -260,7 +260,7 @@ def delete( raise ValueError(f"Expected a non-empty value for `policy_id` but received {policy_id!r}") extra_headers = {"Accept": "*/*", **(extra_headers or {})} return self._delete( - f"/policies/{policy_id}", + f"/v1/policies/{policy_id}", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -272,7 +272,7 @@ class AsyncPoliciesResource(AsyncAPIResource): @cached_property def with_raw_response(self) -> AsyncPoliciesResourceWithRawResponse: """ - This property can be used as a prefix for any HTTP method call to return the + 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 @@ -320,7 +320,7 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ return await self._post( - "/policies", + "/v1/policies", body=await async_maybe_transform( { "dataset_config": dataset_config, @@ -361,7 +361,7 @@ async def retrieve( if not policy_id: raise ValueError(f"Expected a non-empty value for `policy_id` but received {policy_id!r}") return await self._get( - f"/policies/{policy_id}", + f"/v1/policies/{policy_id}", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -403,7 +403,7 @@ async def update( if not policy_id: raise ValueError(f"Expected a non-empty value for `policy_id` but received {policy_id!r}") return await self._patch( - f"/policies/{policy_id}", + f"/v1/policies/{policy_id}", body=await async_maybe_transform( { "dataset_config": dataset_config, @@ -453,7 +453,7 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ return self._get_api_list( - "/policies", + "/v1/policies", page=AsyncPage[Policy], options=make_request_options( extra_headers=extra_headers, @@ -500,7 +500,7 @@ async def delete( raise ValueError(f"Expected a non-empty value for `policy_id` but received {policy_id!r}") extra_headers = {"Accept": "*/*", **(extra_headers or {})} return await self._delete( - f"/policies/{policy_id}", + f"/v1/policies/{policy_id}", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), diff --git a/src/asktable/resources/preferences.py b/src/asktable/resources/preferences.py index 2bba1daa..886db40e 100644 --- a/src/asktable/resources/preferences.py +++ b/src/asktable/resources/preferences.py @@ -32,7 +32,7 @@ class PreferencesResource(SyncAPIResource): @cached_property def with_raw_response(self) -> PreferencesResourceWithRawResponse: """ - This property can be used as a prefix for any HTTP method call to return the + 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 @@ -77,7 +77,7 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ return self._post( - "/preference", + "/v1/preference", body=maybe_transform( { "general_preference": general_preference, @@ -103,7 +103,7 @@ def retrieve( ) -> PreferenceRetrieveResponse: """获取偏好设置""" return self._get( - "/preference", + "/v1/preference", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -139,7 +139,7 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ return self._patch( - "/preference", + "/v1/preference", body=maybe_transform( { "general_preference": general_preference, @@ -165,7 +165,7 @@ def delete( ) -> object: """删除偏好设置""" return self._delete( - "/preference", + "/v1/preference", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -177,7 +177,7 @@ class AsyncPreferencesResource(AsyncAPIResource): @cached_property def with_raw_response(self) -> AsyncPreferencesResourceWithRawResponse: """ - This property can be used as a prefix for any HTTP method call to return the + 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 @@ -222,7 +222,7 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ return await self._post( - "/preference", + "/v1/preference", body=await async_maybe_transform( { "general_preference": general_preference, @@ -248,7 +248,7 @@ async def retrieve( ) -> PreferenceRetrieveResponse: """获取偏好设置""" return await self._get( - "/preference", + "/v1/preference", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -284,7 +284,7 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ return await self._patch( - "/preference", + "/v1/preference", body=await async_maybe_transform( { "general_preference": general_preference, @@ -310,7 +310,7 @@ async def delete( ) -> object: """删除偏好设置""" return await self._delete( - "/preference", + "/v1/preference", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), diff --git a/src/asktable/resources/project.py b/src/asktable/resources/project.py index 270aa2a5..3208457e 100644 --- a/src/asktable/resources/project.py +++ b/src/asktable/resources/project.py @@ -31,7 +31,7 @@ class ProjectResource(SyncAPIResource): @cached_property def with_raw_response(self) -> ProjectResourceWithRawResponse: """ - This property can be used as a prefix for any HTTP method call to return the + 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 @@ -59,7 +59,7 @@ def retrieve( ) -> Project: """Get My Project""" return self._get( - "/project", + "/v1/project", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -95,7 +95,7 @@ def update( timeout: Override the client-level default timeout for this request, in seconds """ return self._patch( - "/project", + "/v1/project", body=maybe_transform( { "llm_model_group": llm_model_group, @@ -121,7 +121,7 @@ def list_model_groups( ) -> ProjectListModelGroupsResponse: """Get Llm Model Groups""" return self._get( - "/project/model-groups", + "/v1/project/model-groups", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -133,7 +133,7 @@ class AsyncProjectResource(AsyncAPIResource): @cached_property def with_raw_response(self) -> AsyncProjectResourceWithRawResponse: """ - This property can be used as a prefix for any HTTP method call to return the + 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 @@ -161,7 +161,7 @@ async def retrieve( ) -> Project: """Get My Project""" return await self._get( - "/project", + "/v1/project", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -197,7 +197,7 @@ async def update( timeout: Override the client-level default timeout for this request, in seconds """ return await self._patch( - "/project", + "/v1/project", body=await async_maybe_transform( { "llm_model_group": llm_model_group, @@ -223,7 +223,7 @@ async def list_model_groups( ) -> ProjectListModelGroupsResponse: """Get Llm Model Groups""" return await self._get( - "/project/model-groups", + "/v1/project/model-groups", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), diff --git a/src/asktable/resources/roles.py b/src/asktable/resources/roles.py index eea360f5..6d64fcde 100644 --- a/src/asktable/resources/roles.py +++ b/src/asktable/resources/roles.py @@ -32,7 +32,7 @@ class RolesResource(SyncAPIResource): @cached_property def with_raw_response(self) -> RolesResourceWithRawResponse: """ - This property can be used as a prefix for any HTTP method call to return the + 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 @@ -77,7 +77,7 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ return self._post( - "/roles", + "/v1/roles", body=maybe_transform( { "name": name, @@ -117,7 +117,7 @@ def retrieve( if not role_id: raise ValueError(f"Expected a non-empty value for `role_id` but received {role_id!r}") return self._get( - f"/roles/{role_id}", + f"/v1/roles/{role_id}", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -156,7 +156,7 @@ def update( if not role_id: raise ValueError(f"Expected a non-empty value for `role_id` but received {role_id!r}") return self._patch( - f"/roles/{role_id}", + f"/v1/roles/{role_id}", body=maybe_transform( { "name": name, @@ -205,7 +205,7 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ return self._get_api_list( - "/roles", + "/v1/roles", page=SyncPage[Role], options=make_request_options( extra_headers=extra_headers, @@ -251,7 +251,7 @@ def delete( if not role_id: raise ValueError(f"Expected a non-empty value for `role_id` but received {role_id!r}") return self._delete( - f"/roles/{role_id}", + f"/v1/roles/{role_id}", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -284,7 +284,7 @@ def get_polices( if not role_id: raise ValueError(f"Expected a non-empty value for `role_id` but received {role_id!r}") return self._get( - f"/roles/{role_id}/policies", + f"/v1/roles/{role_id}/policies", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -323,7 +323,7 @@ def get_variables( if not role_id: raise ValueError(f"Expected a non-empty value for `role_id` but received {role_id!r}") return self._get( - f"/roles/{role_id}/variables", + f"/v1/roles/{role_id}/variables", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -345,7 +345,7 @@ class AsyncRolesResource(AsyncAPIResource): @cached_property def with_raw_response(self) -> AsyncRolesResourceWithRawResponse: """ - This property can be used as a prefix for any HTTP method call to return the + 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 @@ -390,7 +390,7 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ return await self._post( - "/roles", + "/v1/roles", body=await async_maybe_transform( { "name": name, @@ -430,7 +430,7 @@ async def retrieve( if not role_id: raise ValueError(f"Expected a non-empty value for `role_id` but received {role_id!r}") return await self._get( - f"/roles/{role_id}", + f"/v1/roles/{role_id}", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -469,7 +469,7 @@ async def update( if not role_id: raise ValueError(f"Expected a non-empty value for `role_id` but received {role_id!r}") return await self._patch( - f"/roles/{role_id}", + f"/v1/roles/{role_id}", body=await async_maybe_transform( { "name": name, @@ -518,7 +518,7 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ return self._get_api_list( - "/roles", + "/v1/roles", page=AsyncPage[Role], options=make_request_options( extra_headers=extra_headers, @@ -564,7 +564,7 @@ async def delete( if not role_id: raise ValueError(f"Expected a non-empty value for `role_id` but received {role_id!r}") return await self._delete( - f"/roles/{role_id}", + f"/v1/roles/{role_id}", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -597,7 +597,7 @@ async def get_polices( if not role_id: raise ValueError(f"Expected a non-empty value for `role_id` but received {role_id!r}") return await self._get( - f"/roles/{role_id}/policies", + f"/v1/roles/{role_id}/policies", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -636,7 +636,7 @@ async def get_variables( if not role_id: raise ValueError(f"Expected a non-empty value for `role_id` but received {role_id!r}") return await self._get( - f"/roles/{role_id}/variables", + f"/v1/roles/{role_id}/variables", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/asktable/resources/scores.py b/src/asktable/resources/scores.py index 6c178a07..cf0b5112 100644 --- a/src/asktable/resources/scores.py +++ b/src/asktable/resources/scores.py @@ -28,7 +28,7 @@ class ScoresResource(SyncAPIResource): @cached_property def with_raw_response(self) -> ScoresResourceWithRawResponse: """ - This property can be used as a prefix for any HTTP method call to return the + 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 @@ -76,7 +76,7 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ return self._post( - "/score", + "/v1/score", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -99,7 +99,7 @@ class AsyncScoresResource(AsyncAPIResource): @cached_property def with_raw_response(self) -> AsyncScoresResourceWithRawResponse: """ - This property can be used as a prefix for any HTTP method call to return the + 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 @@ -147,7 +147,7 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ return await self._post( - "/score", + "/v1/score", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/asktable/resources/securetunnels.py b/src/asktable/resources/securetunnels.py index 839ee70a..2614f8e1 100644 --- a/src/asktable/resources/securetunnels.py +++ b/src/asktable/resources/securetunnels.py @@ -37,7 +37,7 @@ class SecuretunnelsResource(SyncAPIResource): @cached_property def with_raw_response(self) -> SecuretunnelsResourceWithRawResponse: """ - This property can be used as a prefix for any HTTP method call to return the + 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 @@ -79,7 +79,7 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ return self._post( - "/securetunnels", + "/v1/securetunnels", body=maybe_transform({"name": name}, securetunnel_create_params.SecuretunnelCreateParams), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -113,7 +113,7 @@ def retrieve( if not securetunnel_id: raise ValueError(f"Expected a non-empty value for `securetunnel_id` but received {securetunnel_id!r}") return self._get( - f"/securetunnels/{securetunnel_id}", + f"/v1/securetunnels/{securetunnel_id}", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -124,8 +124,8 @@ def update( self, securetunnel_id: str, *, - name: str, client_info: Optional[object] | NotGiven = NOT_GIVEN, + name: Optional[str] | NotGiven = NOT_GIVEN, unique_key: Optional[str] | 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. @@ -138,10 +138,10 @@ def update( 更新某个 ATST Args: - name: SecureTunnel 名称,不超过 20 个字符 - client_info: 客户端信息 + name: SecureTunnel 名称,不超过 20 个字符 + unique_key: 唯一标识,用于更新客户端信息(容器 ID) extra_headers: Send extra headers @@ -155,11 +155,11 @@ def update( if not securetunnel_id: raise ValueError(f"Expected a non-empty value for `securetunnel_id` but received {securetunnel_id!r}") return self._patch( - f"/securetunnels/{securetunnel_id}", + f"/v1/securetunnels/{securetunnel_id}", body=maybe_transform( { - "name": name, "client_info": client_info, + "name": name, "unique_key": unique_key, }, securetunnel_update_params.SecuretunnelUpdateParams, @@ -199,7 +199,7 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ return self._get_api_list( - "/securetunnels", + "/v1/securetunnels", page=SyncPage[SecureTunnel], options=make_request_options( extra_headers=extra_headers, @@ -244,7 +244,7 @@ def delete( raise ValueError(f"Expected a non-empty value for `securetunnel_id` but received {securetunnel_id!r}") extra_headers = {"Accept": "*/*", **(extra_headers or {})} return self._delete( - f"/securetunnels/{securetunnel_id}", + f"/v1/securetunnels/{securetunnel_id}", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -283,7 +283,7 @@ def list_links( if not securetunnel_id: raise ValueError(f"Expected a non-empty value for `securetunnel_id` but received {securetunnel_id!r}") return self._get_api_list( - f"/securetunnels/{securetunnel_id}/links", + f"/v1/securetunnels/{securetunnel_id}/links", page=SyncPage[SecuretunnelListLinksResponse], options=make_request_options( extra_headers=extra_headers, @@ -306,7 +306,7 @@ class AsyncSecuretunnelsResource(AsyncAPIResource): @cached_property def with_raw_response(self) -> AsyncSecuretunnelsResourceWithRawResponse: """ - This property can be used as a prefix for any HTTP method call to return the + 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 @@ -348,7 +348,7 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ return await self._post( - "/securetunnels", + "/v1/securetunnels", body=await async_maybe_transform({"name": name}, securetunnel_create_params.SecuretunnelCreateParams), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -382,7 +382,7 @@ async def retrieve( if not securetunnel_id: raise ValueError(f"Expected a non-empty value for `securetunnel_id` but received {securetunnel_id!r}") return await self._get( - f"/securetunnels/{securetunnel_id}", + f"/v1/securetunnels/{securetunnel_id}", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -393,8 +393,8 @@ async def update( self, securetunnel_id: str, *, - name: str, client_info: Optional[object] | NotGiven = NOT_GIVEN, + name: Optional[str] | NotGiven = NOT_GIVEN, unique_key: Optional[str] | 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. @@ -407,10 +407,10 @@ async def update( 更新某个 ATST Args: - name: SecureTunnel 名称,不超过 20 个字符 - client_info: 客户端信息 + name: SecureTunnel 名称,不超过 20 个字符 + unique_key: 唯一标识,用于更新客户端信息(容器 ID) extra_headers: Send extra headers @@ -424,11 +424,11 @@ async def update( if not securetunnel_id: raise ValueError(f"Expected a non-empty value for `securetunnel_id` but received {securetunnel_id!r}") return await self._patch( - f"/securetunnels/{securetunnel_id}", + f"/v1/securetunnels/{securetunnel_id}", body=await async_maybe_transform( { - "name": name, "client_info": client_info, + "name": name, "unique_key": unique_key, }, securetunnel_update_params.SecuretunnelUpdateParams, @@ -468,7 +468,7 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ return self._get_api_list( - "/securetunnels", + "/v1/securetunnels", page=AsyncPage[SecureTunnel], options=make_request_options( extra_headers=extra_headers, @@ -513,7 +513,7 @@ async def delete( raise ValueError(f"Expected a non-empty value for `securetunnel_id` but received {securetunnel_id!r}") extra_headers = {"Accept": "*/*", **(extra_headers or {})} return await self._delete( - f"/securetunnels/{securetunnel_id}", + f"/v1/securetunnels/{securetunnel_id}", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -552,7 +552,7 @@ def list_links( if not securetunnel_id: raise ValueError(f"Expected a non-empty value for `securetunnel_id` but received {securetunnel_id!r}") return self._get_api_list( - f"/securetunnels/{securetunnel_id}/links", + f"/v1/securetunnels/{securetunnel_id}/links", page=AsyncPage[SecuretunnelListLinksResponse], options=make_request_options( extra_headers=extra_headers, diff --git a/src/asktable/resources/sqls.py b/src/asktable/resources/sqls.py index 987bf2b3..367f98b0 100644 --- a/src/asktable/resources/sqls.py +++ b/src/asktable/resources/sqls.py @@ -31,7 +31,7 @@ class SqlsResource(SyncAPIResource): @cached_property def with_raw_response(self) -> SqlsResourceWithRawResponse: """ - This property can be used as a prefix for any HTTP method call to return the + 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 @@ -83,7 +83,7 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ return self._post( - "/single-turn/q2s", + "/v1/single-turn/q2s", body=maybe_transform( { "datasource_id": datasource_id, @@ -131,7 +131,7 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ return self._get_api_list( - "/single-turn/q2s", + "/v1/single-turn/q2s", page=SyncPage[QueryResponse], options=make_request_options( extra_headers=extra_headers, @@ -155,7 +155,7 @@ class AsyncSqlsResource(AsyncAPIResource): @cached_property def with_raw_response(self) -> AsyncSqlsResourceWithRawResponse: """ - This property can be used as a prefix for any HTTP method call to return the + 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 @@ -207,7 +207,7 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ return await self._post( - "/single-turn/q2s", + "/v1/single-turn/q2s", body=await async_maybe_transform( { "datasource_id": datasource_id, @@ -255,7 +255,7 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ return self._get_api_list( - "/single-turn/q2s", + "/v1/single-turn/q2s", page=AsyncPage[QueryResponse], options=make_request_options( extra_headers=extra_headers, diff --git a/src/asktable/resources/sys/projects/api_keys.py b/src/asktable/resources/sys/projects/api_keys.py index fe34b0eb..11d84397 100644 --- a/src/asktable/resources/sys/projects/api_keys.py +++ b/src/asktable/resources/sys/projects/api_keys.py @@ -32,7 +32,7 @@ class APIKeysResource(SyncAPIResource): @cached_property def with_raw_response(self) -> APIKeysResourceWithRawResponse: """ - This property can be used as a prefix for any HTTP method call to return the + 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 @@ -77,7 +77,7 @@ def create( if not project_id: raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}") return self._post( - f"/sys/projects/{project_id}/api-keys", + f"/v1/sys/projects/{project_id}/api-keys", body=maybe_transform({"ak_role": ak_role}, api_key_create_params.APIKeyCreateParams), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -111,7 +111,7 @@ def list( if not project_id: raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}") return self._get( - f"/sys/projects/{project_id}/api-keys", + f"/v1/sys/projects/{project_id}/api-keys", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -148,7 +148,7 @@ def delete( raise ValueError(f"Expected a non-empty value for `key_id` but received {key_id!r}") extra_headers = {"Accept": "*/*", **(extra_headers or {})} return self._delete( - f"/sys/projects/{project_id}/api-keys/{key_id}", + f"/v1/sys/projects/{project_id}/api-keys/{key_id}", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -193,7 +193,7 @@ def create_token( if not project_id: raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}") return self._post( - f"/sys/projects/{project_id}/tokens", + f"/v1/sys/projects/{project_id}/tokens", body=maybe_transform( { "ak_role": ak_role, @@ -214,7 +214,7 @@ class AsyncAPIKeysResource(AsyncAPIResource): @cached_property def with_raw_response(self) -> AsyncAPIKeysResourceWithRawResponse: """ - This property can be used as a prefix for any HTTP method call to return the + 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 @@ -259,7 +259,7 @@ async def create( if not project_id: raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}") return await self._post( - f"/sys/projects/{project_id}/api-keys", + f"/v1/sys/projects/{project_id}/api-keys", body=await async_maybe_transform({"ak_role": ak_role}, api_key_create_params.APIKeyCreateParams), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -293,7 +293,7 @@ async def list( if not project_id: raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}") return await self._get( - f"/sys/projects/{project_id}/api-keys", + f"/v1/sys/projects/{project_id}/api-keys", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -330,7 +330,7 @@ async def delete( raise ValueError(f"Expected a non-empty value for `key_id` but received {key_id!r}") extra_headers = {"Accept": "*/*", **(extra_headers or {})} return await self._delete( - f"/sys/projects/{project_id}/api-keys/{key_id}", + f"/v1/sys/projects/{project_id}/api-keys/{key_id}", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -375,7 +375,7 @@ async def create_token( if not project_id: raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}") return await self._post( - f"/sys/projects/{project_id}/tokens", + f"/v1/sys/projects/{project_id}/tokens", body=await async_maybe_transform( { "ak_role": ak_role, diff --git a/src/asktable/resources/sys/projects/projects.py b/src/asktable/resources/sys/projects/projects.py index 5d4f0dcf..5d91c1ed 100644 --- a/src/asktable/resources/sys/projects/projects.py +++ b/src/asktable/resources/sys/projects/projects.py @@ -44,7 +44,7 @@ def api_keys(self) -> APIKeysResource: @cached_property def with_raw_response(self) -> ProjectsResourceWithRawResponse: """ - This property can be used as a prefix for any HTTP method call to return the + 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 @@ -86,7 +86,7 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ return self._post( - "/sys/projects", + "/v1/sys/projects", body=maybe_transform({"name": name}, project_create_params.ProjectCreateParams), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -120,7 +120,7 @@ def retrieve( if not project_id: raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}") return self._get( - f"/sys/projects/{project_id}", + f"/v1/sys/projects/{project_id}", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -162,7 +162,7 @@ def update( if not project_id: raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}") return self._patch( - f"/sys/projects/{project_id}", + f"/v1/sys/projects/{project_id}", body=maybe_transform( { "llm_model_group": llm_model_group, @@ -209,7 +209,7 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ return self._get_api_list( - "/sys/projects", + "/v1/sys/projects", page=SyncPage[Project], options=make_request_options( extra_headers=extra_headers, @@ -254,7 +254,7 @@ def delete( if not project_id: raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}") return self._delete( - f"/sys/projects/{project_id}", + f"/v1/sys/projects/{project_id}", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -273,7 +273,7 @@ def model_groups( ) -> ProjectModelGroupsResponse: """Get Llm Model Groups""" return self._get( - "/sys/projects/model-groups", + "/v1/sys/projects/model-groups", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -289,7 +289,7 @@ def api_keys(self) -> AsyncAPIKeysResource: @cached_property def with_raw_response(self) -> AsyncProjectsResourceWithRawResponse: """ - This property can be used as a prefix for any HTTP method call to return the + 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 @@ -331,7 +331,7 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ return await self._post( - "/sys/projects", + "/v1/sys/projects", body=await async_maybe_transform({"name": name}, project_create_params.ProjectCreateParams), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout @@ -365,7 +365,7 @@ async def retrieve( if not project_id: raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}") return await self._get( - f"/sys/projects/{project_id}", + f"/v1/sys/projects/{project_id}", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -407,7 +407,7 @@ async def update( if not project_id: raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}") return await self._patch( - f"/sys/projects/{project_id}", + f"/v1/sys/projects/{project_id}", body=await async_maybe_transform( { "llm_model_group": llm_model_group, @@ -454,7 +454,7 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ return self._get_api_list( - "/sys/projects", + "/v1/sys/projects", page=AsyncPage[Project], options=make_request_options( extra_headers=extra_headers, @@ -499,7 +499,7 @@ async def delete( if not project_id: raise ValueError(f"Expected a non-empty value for `project_id` but received {project_id!r}") return await self._delete( - f"/sys/projects/{project_id}", + f"/v1/sys/projects/{project_id}", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -518,7 +518,7 @@ async def model_groups( ) -> ProjectModelGroupsResponse: """Get Llm Model Groups""" return await self._get( - "/sys/projects/model-groups", + "/v1/sys/projects/model-groups", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), diff --git a/src/asktable/resources/sys/sys.py b/src/asktable/resources/sys/sys.py index c2fb5786..27f630db 100644 --- a/src/asktable/resources/sys/sys.py +++ b/src/asktable/resources/sys/sys.py @@ -24,7 +24,7 @@ def projects(self) -> ProjectsResource: @cached_property def with_raw_response(self) -> SysResourceWithRawResponse: """ - This property can be used as a prefix for any HTTP method call to return the + 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 @@ -49,7 +49,7 @@ def projects(self) -> AsyncProjectsResource: @cached_property def with_raw_response(self) -> AsyncSysResourceWithRawResponse: """ - This property can be used as a prefix for any HTTP method call to return the + 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 diff --git a/src/asktable/resources/trainings.py b/src/asktable/resources/trainings.py index 2ba657bb..0a7f0922 100644 --- a/src/asktable/resources/trainings.py +++ b/src/asktable/resources/trainings.py @@ -32,7 +32,7 @@ class TrainingsResource(SyncAPIResource): @cached_property def with_raw_response(self) -> TrainingsResourceWithRawResponse: """ - This property can be used as a prefix for any HTTP method call to return the + 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 @@ -75,7 +75,7 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ return self._post( - "/training", + "/v1/training", body=maybe_transform(body, Iterable[training_create_params.Body]), options=make_request_options( extra_headers=extra_headers, @@ -119,7 +119,7 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ return self._get_api_list( - "/training", + "/v1/training", page=SyncPage[TrainingListResponse], options=make_request_options( extra_headers=extra_headers, @@ -167,7 +167,7 @@ def delete( if not id: raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") return self._delete( - f"/training/{id}", + f"/v1/training/{id}", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -183,7 +183,7 @@ class AsyncTrainingsResource(AsyncAPIResource): @cached_property def with_raw_response(self) -> AsyncTrainingsResourceWithRawResponse: """ - This property can be used as a prefix for any HTTP method call to return the + 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 @@ -226,7 +226,7 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ return await self._post( - "/training", + "/v1/training", body=await async_maybe_transform(body, Iterable[training_create_params.Body]), options=make_request_options( extra_headers=extra_headers, @@ -272,7 +272,7 @@ def list( timeout: Override the client-level default timeout for this request, in seconds """ return self._get_api_list( - "/training", + "/v1/training", page=AsyncPage[TrainingListResponse], options=make_request_options( extra_headers=extra_headers, @@ -320,7 +320,7 @@ async def delete( if not id: raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") return await self._delete( - f"/training/{id}", + f"/v1/training/{id}", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, diff --git a/src/asktable/types/__init__.py b/src/asktable/types/__init__.py index 8cd2bd96..a132d23f 100644 --- a/src/asktable/types/__init__.py +++ b/src/asktable/types/__init__.py @@ -19,6 +19,7 @@ from .answer_response import AnswerResponse as AnswerResponse from .bot_list_params import BotListParams as BotListParams from .sql_list_params import SqlListParams as SqlListParams +from .auth_me_response import AuthMeResponse as AuthMeResponse from .chat_list_params import ChatListParams as ChatListParams from .role_list_params import RoleListParams as RoleListParams from .bot_create_params import BotCreateParams as BotCreateParams @@ -61,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 .dataframe_retrieve_response import DataframeRetrieveResponse as DataframeRetrieveResponse 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 diff --git a/src/asktable/types/auth_me_response.py b/src/asktable/types/auth_me_response.py new file mode 100644 index 00000000..0db427fa --- /dev/null +++ b/src/asktable/types/auth_me_response.py @@ -0,0 +1,24 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Optional +from typing_extensions import Literal + +from .._models import BaseModel + +__all__ = ["AuthMeResponse"] + + +class AuthMeResponse(BaseModel): + ak_role: Literal["sys", "admin", "asker", "visitor"] + + project_id: str + + ak_id: Optional[str] = None + + chat_role: Optional[object] = None + + exp: Optional[int] = None + + locked: Optional[bool] = None + + user_profile: Optional[object] = None diff --git a/src/asktable/types/chat.py b/src/asktable/types/chat.py index 5aacbcc2..5d26c3e8 100644 --- a/src/asktable/types/chat.py +++ b/src/asktable/types/chat.py @@ -2,6 +2,7 @@ from typing import Dict, Union, Optional from datetime import datetime +from typing_extensions import Literal from .._models import BaseModel @@ -20,6 +21,10 @@ class Chat(BaseModel): project_id: str + status: Literal["active", "pending", "error", "fatal"] + + status_message: Optional[str] = None + bot_id: Optional[str] = None """ 机器人 ID,如果需要使用高级功能,请使用 bot_id 来创建对话。在机器人中你可以定义 diff --git a/src/asktable/types/chat_retrieve_response.py b/src/asktable/types/chat_retrieve_response.py index 2a39fb44..2999466c 100644 --- a/src/asktable/types/chat_retrieve_response.py +++ b/src/asktable/types/chat_retrieve_response.py @@ -2,6 +2,7 @@ from typing import Dict, List, Union, Optional from datetime import datetime +from typing_extensions import Literal from .._models import BaseModel @@ -15,19 +16,23 @@ class ChatRetrieveResponse(BaseModel): created_at: datetime """创建时间""" - datasource_ids: List[str] - modified_at: datetime """修改时间""" project_id: str + status: Literal["active", "pending", "error", "fatal"] + + status_message: Optional[str] = None + bot_id: Optional[str] = None """ 机器人 ID,如果需要使用高级功能,请使用 bot_id 来创建对话。在机器人中你可以定义 可以访问的数据、可以执行的任务以及是否开启调试模式等设置。 """ + datasource_ids: Optional[List[str]] = None + name: Optional[str] = None """New name for the chat""" @@ -42,3 +47,5 @@ class ChatRetrieveResponse(BaseModel): user_profile: Optional[Dict[str, str]] = None """用户信息,用于在对话中传递用户的信息,用 Key-Value 形式传递""" + + welcome_message: Optional[str] = None diff --git a/src/asktable/types/dataframe_retrieve_response.py b/src/asktable/types/dataframe_retrieve_response.py new file mode 100644 index 00000000..75cdbde6 --- /dev/null +++ b/src/asktable/types/dataframe_retrieve_response.py @@ -0,0 +1,43 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List +from datetime import datetime + +from .._models import BaseModel + +__all__ = ["DataframeRetrieveResponse"] + + +class DataframeRetrieveResponse(BaseModel): + id: str + """ID""" + + chart_options: object + """图表选项""" + + content: List[object] + """内容""" + + created_at: datetime + """创建时间""" + + header: List[object] + """表头""" + + modified_at: datetime + """更新时间""" + + msg_id: str + """消息 ID""" + + project_id: str + """项目 ID""" + + row_count: int + """行数""" + + sql: str + """SQL""" + + title: str + """标题""" diff --git a/src/asktable/types/datasource.py b/src/asktable/types/datasource.py index 3969f435..678c320f 100644 --- a/src/asktable/types/datasource.py +++ b/src/asktable/types/datasource.py @@ -29,6 +29,7 @@ class Datasource(BaseModel): "oracle", "polardbmysql", "polardbpg", + "dameng", ] """数据源引擎""" diff --git a/src/asktable/types/datasource_create_params.py b/src/asktable/types/datasource_create_params.py index a3f96f4d..1079a4c5 100644 --- a/src/asktable/types/datasource_create_params.py +++ b/src/asktable/types/datasource_create_params.py @@ -28,14 +28,11 @@ class DatasourceCreateParams(TypedDict, total=False): "oracle", "polardbmysql", "polardbpg", + "dameng", ] ] """数据源引擎""" - async_process_meta: bool - - value_index: bool - access_config: Optional[AccessConfig] """不同引擎有不同的配置""" diff --git a/src/asktable/types/datasource_retrieve_response.py b/src/asktable/types/datasource_retrieve_response.py index 95dd70ad..18301f2a 100644 --- a/src/asktable/types/datasource_retrieve_response.py +++ b/src/asktable/types/datasource_retrieve_response.py @@ -74,6 +74,7 @@ class DatasourceRetrieveResponse(BaseModel): "oracle", "polardbmysql", "polardbpg", + "dameng", ] """数据源引擎""" diff --git a/src/asktable/types/datasource_update_params.py b/src/asktable/types/datasource_update_params.py index 41bef537..6f268d1d 100644 --- a/src/asktable/types/datasource_update_params.py +++ b/src/asktable/types/datasource_update_params.py @@ -34,6 +34,7 @@ class DatasourceUpdateParams(TypedDict, total=False): "oracle", "polardbmysql", "polardbpg", + "dameng", ] ] """数据源引擎""" diff --git a/src/asktable/types/datasources/meta_create_params.py b/src/asktable/types/datasources/meta_create_params.py index 1dc3abfb..5684c17b 100644 --- a/src/asktable/types/datasources/meta_create_params.py +++ b/src/asktable/types/datasources/meta_create_params.py @@ -2,55 +2,61 @@ from __future__ import annotations -from typing import Dict, Optional +from typing import Dict, List, Optional from typing_extensions import Required, TypedDict -__all__ = ["MetaCreateParams", "Schemas", "SchemasTables", "SchemasTablesFields"] +__all__ = ["MetaCreateParams", "Meta", "MetaSchemas", "MetaSchemasTables", "MetaSchemasTablesFields"] class MetaCreateParams(TypedDict, total=False): - name: Required[str] - """metadata_name""" - async_process_meta: bool value_index: bool - schemas: Dict[str, Schemas] + meta: Optional[Meta] + selected_tables: Optional[Dict[str, List[str]]] -class SchemasTablesFields(TypedDict, total=False): + +class MetaSchemasTablesFields(TypedDict, total=False): name: Required[str] """field_name""" + origin_desc: Required[str] + """field description from database""" + data_type: Optional[str] """field data type""" - origin_desc: Optional[str] - """field description from database""" - sample_data: Optional[str] """field sample data""" + visibility: bool + """field visibility""" -class SchemasTables(TypedDict, total=False): + +class MetaSchemasTables(TypedDict, total=False): name: Required[str] """table_name""" - fields: Dict[str, SchemasTablesFields] - - origin_desc: Optional[str] + origin_desc: Required[str] """table description from database""" + fields: Dict[str, MetaSchemasTablesFields] -class Schemas(TypedDict, total=False): + +class MetaSchemas(TypedDict, total=False): name: Required[str] """schema_name""" + origin_desc: Required[str] + """schema description from database""" + custom_configs: Optional[object] """custom configs""" - origin_desc: Optional[str] - """schema description from database""" + tables: Dict[str, MetaSchemasTables] + - tables: Dict[str, SchemasTables] +class Meta(TypedDict, total=False): + schemas: Required[Dict[str, MetaSchemas]] diff --git a/src/asktable/types/datasources/meta_update_params.py b/src/asktable/types/datasources/meta_update_params.py index d7afc781..997a0110 100644 --- a/src/asktable/types/datasources/meta_update_params.py +++ b/src/asktable/types/datasources/meta_update_params.py @@ -2,51 +2,59 @@ from __future__ import annotations -from typing import Dict, Optional +from typing import Dict, List, Optional from typing_extensions import Required, TypedDict -__all__ = ["MetaUpdateParams", "Schemas", "SchemasTables", "SchemasTablesFields"] +__all__ = ["MetaUpdateParams", "Meta", "MetaSchemas", "MetaSchemasTables", "MetaSchemasTablesFields"] class MetaUpdateParams(TypedDict, total=False): - name: Required[str] - """metadata_name""" + async_process_meta: bool + + meta: Optional[Meta] - schemas: Dict[str, Schemas] + selected_tables: Optional[Dict[str, List[str]]] -class SchemasTablesFields(TypedDict, total=False): +class MetaSchemasTablesFields(TypedDict, total=False): name: Required[str] """field_name""" + origin_desc: Required[str] + """field description from database""" + data_type: Optional[str] """field data type""" - origin_desc: Optional[str] - """field description from database""" - sample_data: Optional[str] """field sample data""" + visibility: bool + """field visibility""" + -class SchemasTables(TypedDict, total=False): +class MetaSchemasTables(TypedDict, total=False): name: Required[str] """table_name""" - fields: Dict[str, SchemasTablesFields] - - origin_desc: Optional[str] + origin_desc: Required[str] """table description from database""" + fields: Dict[str, MetaSchemasTablesFields] + -class Schemas(TypedDict, total=False): +class MetaSchemas(TypedDict, total=False): name: Required[str] """schema_name""" + origin_desc: Required[str] + """schema description from database""" + custom_configs: Optional[object] """custom configs""" - origin_desc: Optional[str] - """schema description from database""" + tables: Dict[str, MetaSchemasTables] + - tables: Dict[str, SchemasTables] +class Meta(TypedDict, total=False): + schemas: Required[Dict[str, MetaSchemas]] diff --git a/src/asktable/types/extapi.py b/src/asktable/types/extapi.py index 0d90cc1b..902ffbf0 100644 --- a/src/asktable/types/extapi.py +++ b/src/asktable/types/extapi.py @@ -21,7 +21,7 @@ class Extapi(BaseModel): project_id: str + updated_at: datetime + headers: Optional[Dict[str, str]] = None """HTTP Headers,JSON 格式""" - - updated_at: Optional[datetime] = None diff --git a/src/asktable/types/extapis/extapi_route.py b/src/asktable/types/extapis/extapi_route.py index 3525c711..299a7c94 100644 --- a/src/asktable/types/extapis/extapi_route.py +++ b/src/asktable/types/extapis/extapi_route.py @@ -27,6 +27,8 @@ class ExtapiRoute(BaseModel): project_id: str + updated_at: datetime + body_params_desc: Optional[str] = None """请求体参数描述""" @@ -35,5 +37,3 @@ class ExtapiRoute(BaseModel): query_params_desc: Optional[str] = None """查询参数描述""" - - updated_at: Optional[datetime] = None diff --git a/src/asktable/types/extapis/route_create_params.py b/src/asktable/types/extapis/route_create_params.py index cfaafef7..e58f6e3e 100644 --- a/src/asktable/types/extapis/route_create_params.py +++ b/src/asktable/types/extapis/route_create_params.py @@ -12,8 +12,6 @@ class RouteCreateParams(TypedDict, total=False): - path_extapi_id: Required[Annotated[str, PropertyInfo(alias="extapi_id")]] - id: Required[str] created_at: Required[Annotated[Union[str, datetime], PropertyInfo(format="iso8601")]] @@ -31,6 +29,8 @@ class RouteCreateParams(TypedDict, total=False): project_id: Required[str] + updated_at: Required[Annotated[Union[str, datetime], PropertyInfo(format="iso8601")]] + body_params_desc: Optional[str] """请求体参数描述""" @@ -39,5 +39,3 @@ class RouteCreateParams(TypedDict, total=False): query_params_desc: Optional[str] """查询参数描述""" - - updated_at: Annotated[Union[str, datetime], PropertyInfo(format="iso8601")] diff --git a/src/asktable/types/meta.py b/src/asktable/types/meta.py index 1395bdf5..c7c1877a 100644 --- a/src/asktable/types/meta.py +++ b/src/asktable/types/meta.py @@ -12,6 +12,9 @@ class SchemasTablesFields(BaseModel): created_at: datetime """created time""" + curr_desc: str + """current field description""" + curr_desc_stat: str """current field description status""" @@ -24,62 +27,59 @@ class SchemasTablesFields(BaseModel): name: str """field_name""" - curr_desc: Optional[str] = None - """current field description""" + origin_desc: str + """field description from database""" data_type: Optional[str] = None """field data type""" - origin_desc: Optional[str] = None - """field description from database""" - sample_data: Optional[str] = None """field sample data""" + visibility: Optional[bool] = None + """field visibility""" + class SchemasTables(BaseModel): + curr_desc: str + """current table description""" + curr_desc_stat: str """current table description status""" + fields: Dict[str, SchemasTablesFields] + full_name: str """field full name""" name: str """table_name""" - curr_desc: Optional[str] = None - """current table description""" - - fields: Optional[Dict[str, SchemasTablesFields]] = None - - origin_desc: Optional[str] = None + origin_desc: str """table description from database""" class Schemas(BaseModel): + curr_desc: str + """current schema description""" + curr_desc_stat: str """current schema description status""" name: str """schema_name""" - curr_desc: Optional[str] = None - """current schema description""" + origin_desc: str + """schema description from database""" + + tables: Dict[str, SchemasTables] custom_configs: Optional[object] = None """custom configs""" - origin_desc: Optional[str] = None - """schema description from database""" - - tables: Optional[Dict[str, SchemasTables]] = None - class Meta(BaseModel): datasource_id: str """datasource_id""" - name: str - """metadata_name""" - - schemas: Optional[Dict[str, Schemas]] = None + schemas: Dict[str, Schemas] diff --git a/src/asktable/types/securetunnel_update_params.py b/src/asktable/types/securetunnel_update_params.py index e42566a6..6322936a 100644 --- a/src/asktable/types/securetunnel_update_params.py +++ b/src/asktable/types/securetunnel_update_params.py @@ -3,17 +3,17 @@ from __future__ import annotations from typing import Optional -from typing_extensions import Required, TypedDict +from typing_extensions import TypedDict __all__ = ["SecuretunnelUpdateParams"] class SecuretunnelUpdateParams(TypedDict, total=False): - name: Required[str] - """SecureTunnel 名称,不超过 20 个字符""" - client_info: Optional[object] """客户端信息""" + name: Optional[str] + """SecureTunnel 名称,不超过 20 个字符""" + unique_key: Optional[str] """唯一标识,用于更新客户端信息(容器 ID)""" diff --git a/src/asktable/types/sys/model_group.py b/src/asktable/types/sys/model_group.py index fe4854ba..8d700122 100644 --- a/src/asktable/types/sys/model_group.py +++ b/src/asktable/types/sys/model_group.py @@ -1,6 +1,5 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List from ..._models import BaseModel @@ -11,14 +10,20 @@ class ModelGroup(BaseModel): id: str """模型组 ID""" - agent_model: str + agent: str """Agent 模型""" - image_models: List[str] - """图像模型列表""" + fast: str + """快速模型""" + + image: str + """图片模型""" name: str """模型组名称""" - text_models: List[str] - """文本模型列表""" + omni: str + """通用模型""" + + sql: str + """SQL 模型""" diff --git a/tests/api_resources/datasources/test_meta.py b/tests/api_resources/datasources/test_meta.py index 50d6f088..4b5c86a0 100644 --- a/tests/api_resources/datasources/test_meta.py +++ b/tests/api_resources/datasources/test_meta.py @@ -21,7 +21,6 @@ class TestMeta: def test_method_create(self, client: Asktable) -> None: meta = client.datasources.meta.create( datasource_id="datasource_id", - name="name", ) assert_matches_type(object, meta, path=["response"]) @@ -29,30 +28,33 @@ def test_method_create(self, client: Asktable) -> None: def test_method_create_with_all_params(self, client: Asktable) -> None: meta = client.datasources.meta.create( datasource_id="datasource_id", - name="name", async_process_meta=True, value_index=True, - schemas={ - "foo": { - "name": "name", - "custom_configs": {}, - "origin_desc": "origin_desc", - "tables": { - "foo": { - "name": "name", - "fields": { - "foo": { - "name": "name", - "data_type": "data_type", - "origin_desc": "origin_desc", - "sample_data": "sample_data", - } - }, - "origin_desc": "origin_desc", - } - }, + meta={ + "schemas": { + "foo": { + "name": "name", + "origin_desc": "origin_desc", + "custom_configs": {}, + "tables": { + "foo": { + "name": "name", + "origin_desc": "origin_desc", + "fields": { + "foo": { + "name": "name", + "origin_desc": "origin_desc", + "data_type": "data_type", + "sample_data": "sample_data", + "visibility": True, + } + }, + } + }, + } } }, + selected_tables={"foo": ["string"]}, ) assert_matches_type(object, meta, path=["response"]) @@ -60,7 +62,6 @@ def test_method_create_with_all_params(self, client: Asktable) -> None: def test_raw_response_create(self, client: Asktable) -> None: response = client.datasources.meta.with_raw_response.create( datasource_id="datasource_id", - name="name", ) assert response.is_closed is True @@ -72,7 +73,6 @@ def test_raw_response_create(self, client: Asktable) -> None: def test_streaming_response_create(self, client: Asktable) -> None: with client.datasources.meta.with_streaming_response.create( datasource_id="datasource_id", - name="name", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -87,7 +87,6 @@ def test_path_params_create(self, client: Asktable) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `datasource_id` but received ''"): client.datasources.meta.with_raw_response.create( datasource_id="", - name="name", ) @parametrize @@ -132,7 +131,6 @@ def test_path_params_retrieve(self, client: Asktable) -> None: def test_method_update(self, client: Asktable) -> None: meta = client.datasources.meta.update( datasource_id="datasource_id", - name="name", ) assert_matches_type(object, meta, path=["response"]) @@ -140,28 +138,32 @@ def test_method_update(self, client: Asktable) -> None: def test_method_update_with_all_params(self, client: Asktable) -> None: meta = client.datasources.meta.update( datasource_id="datasource_id", - name="name", - schemas={ - "foo": { - "name": "name", - "custom_configs": {}, - "origin_desc": "origin_desc", - "tables": { - "foo": { - "name": "name", - "fields": { - "foo": { - "name": "name", - "data_type": "data_type", - "origin_desc": "origin_desc", - "sample_data": "sample_data", - } - }, - "origin_desc": "origin_desc", - } - }, + async_process_meta=True, + meta={ + "schemas": { + "foo": { + "name": "name", + "origin_desc": "origin_desc", + "custom_configs": {}, + "tables": { + "foo": { + "name": "name", + "origin_desc": "origin_desc", + "fields": { + "foo": { + "name": "name", + "origin_desc": "origin_desc", + "data_type": "data_type", + "sample_data": "sample_data", + "visibility": True, + } + }, + } + }, + } } }, + selected_tables={"foo": ["string"]}, ) assert_matches_type(object, meta, path=["response"]) @@ -169,7 +171,6 @@ def test_method_update_with_all_params(self, client: Asktable) -> None: def test_raw_response_update(self, client: Asktable) -> None: response = client.datasources.meta.with_raw_response.update( datasource_id="datasource_id", - name="name", ) assert response.is_closed is True @@ -181,7 +182,6 @@ def test_raw_response_update(self, client: Asktable) -> None: def test_streaming_response_update(self, client: Asktable) -> None: with client.datasources.meta.with_streaming_response.update( datasource_id="datasource_id", - name="name", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -196,7 +196,6 @@ def test_path_params_update(self, client: Asktable) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `datasource_id` but received ''"): client.datasources.meta.with_raw_response.update( datasource_id="", - name="name", ) @parametrize @@ -249,7 +248,6 @@ class TestAsyncMeta: async def test_method_create(self, async_client: AsyncAsktable) -> None: meta = await async_client.datasources.meta.create( datasource_id="datasource_id", - name="name", ) assert_matches_type(object, meta, path=["response"]) @@ -257,30 +255,33 @@ async def test_method_create(self, async_client: AsyncAsktable) -> None: async def test_method_create_with_all_params(self, async_client: AsyncAsktable) -> None: meta = await async_client.datasources.meta.create( datasource_id="datasource_id", - name="name", async_process_meta=True, value_index=True, - schemas={ - "foo": { - "name": "name", - "custom_configs": {}, - "origin_desc": "origin_desc", - "tables": { - "foo": { - "name": "name", - "fields": { - "foo": { - "name": "name", - "data_type": "data_type", - "origin_desc": "origin_desc", - "sample_data": "sample_data", - } - }, - "origin_desc": "origin_desc", - } - }, + meta={ + "schemas": { + "foo": { + "name": "name", + "origin_desc": "origin_desc", + "custom_configs": {}, + "tables": { + "foo": { + "name": "name", + "origin_desc": "origin_desc", + "fields": { + "foo": { + "name": "name", + "origin_desc": "origin_desc", + "data_type": "data_type", + "sample_data": "sample_data", + "visibility": True, + } + }, + } + }, + } } }, + selected_tables={"foo": ["string"]}, ) assert_matches_type(object, meta, path=["response"]) @@ -288,7 +289,6 @@ async def test_method_create_with_all_params(self, async_client: AsyncAsktable) async def test_raw_response_create(self, async_client: AsyncAsktable) -> None: response = await async_client.datasources.meta.with_raw_response.create( datasource_id="datasource_id", - name="name", ) assert response.is_closed is True @@ -300,7 +300,6 @@ async def test_raw_response_create(self, async_client: AsyncAsktable) -> None: async def test_streaming_response_create(self, async_client: AsyncAsktable) -> None: async with async_client.datasources.meta.with_streaming_response.create( datasource_id="datasource_id", - name="name", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -315,7 +314,6 @@ async def test_path_params_create(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.meta.with_raw_response.create( datasource_id="", - name="name", ) @parametrize @@ -360,7 +358,6 @@ async def test_path_params_retrieve(self, async_client: AsyncAsktable) -> None: async def test_method_update(self, async_client: AsyncAsktable) -> None: meta = await async_client.datasources.meta.update( datasource_id="datasource_id", - name="name", ) assert_matches_type(object, meta, path=["response"]) @@ -368,28 +365,32 @@ async def test_method_update(self, async_client: AsyncAsktable) -> None: async def test_method_update_with_all_params(self, async_client: AsyncAsktable) -> None: meta = await async_client.datasources.meta.update( datasource_id="datasource_id", - name="name", - schemas={ - "foo": { - "name": "name", - "custom_configs": {}, - "origin_desc": "origin_desc", - "tables": { - "foo": { - "name": "name", - "fields": { - "foo": { - "name": "name", - "data_type": "data_type", - "origin_desc": "origin_desc", - "sample_data": "sample_data", - } - }, - "origin_desc": "origin_desc", - } - }, + async_process_meta=True, + meta={ + "schemas": { + "foo": { + "name": "name", + "origin_desc": "origin_desc", + "custom_configs": {}, + "tables": { + "foo": { + "name": "name", + "origin_desc": "origin_desc", + "fields": { + "foo": { + "name": "name", + "origin_desc": "origin_desc", + "data_type": "data_type", + "sample_data": "sample_data", + "visibility": True, + } + }, + } + }, + } } }, + selected_tables={"foo": ["string"]}, ) assert_matches_type(object, meta, path=["response"]) @@ -397,7 +398,6 @@ async def test_method_update_with_all_params(self, async_client: AsyncAsktable) async def test_raw_response_update(self, async_client: AsyncAsktable) -> None: response = await async_client.datasources.meta.with_raw_response.update( datasource_id="datasource_id", - name="name", ) assert response.is_closed is True @@ -409,7 +409,6 @@ async def test_raw_response_update(self, async_client: AsyncAsktable) -> None: async def test_streaming_response_update(self, async_client: AsyncAsktable) -> None: async with async_client.datasources.meta.with_streaming_response.update( datasource_id="datasource_id", - name="name", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -424,7 +423,6 @@ async def test_path_params_update(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.meta.with_raw_response.update( datasource_id="", - name="name", ) @parametrize diff --git a/tests/api_resources/extapis/test_routes.py b/tests/api_resources/extapis/test_routes.py index 5fa13718..1076391e 100644 --- a/tests/api_resources/extapis/test_routes.py +++ b/tests/api_resources/extapis/test_routes.py @@ -29,6 +29,7 @@ def test_method_create(self, client: Asktable) -> None: name="name", path="/resource", project_id="project_id", + updated_at=parse_datetime("2019-12-27T18:11:19.117Z"), ) assert_matches_type(ExtapiRoute, route, path=["response"]) @@ -43,10 +44,10 @@ def test_method_create_with_all_params(self, client: Asktable) -> None: name="name", path="/resource", project_id="project_id", + updated_at=parse_datetime("2019-12-27T18:11:19.117Z"), body_params_desc="body_params_desc", path_params_desc="path_params_desc", query_params_desc="query_params_desc", - updated_at=parse_datetime("2019-12-27T18:11:19.117Z"), ) assert_matches_type(ExtapiRoute, route, path=["response"]) @@ -61,6 +62,7 @@ def test_raw_response_create(self, client: Asktable) -> None: name="name", path="/resource", project_id="project_id", + updated_at=parse_datetime("2019-12-27T18:11:19.117Z"), ) assert response.is_closed is True @@ -79,6 +81,7 @@ def test_streaming_response_create(self, client: Asktable) -> None: name="name", path="/resource", project_id="project_id", + updated_at=parse_datetime("2019-12-27T18:11:19.117Z"), ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -100,6 +103,7 @@ def test_path_params_create(self, client: Asktable) -> None: name="name", path="/resource", project_id="project_id", + updated_at=parse_datetime("2019-12-27T18:11:19.117Z"), ) @parametrize @@ -313,6 +317,7 @@ async def test_method_create(self, async_client: AsyncAsktable) -> None: name="name", path="/resource", project_id="project_id", + updated_at=parse_datetime("2019-12-27T18:11:19.117Z"), ) assert_matches_type(ExtapiRoute, route, path=["response"]) @@ -327,10 +332,10 @@ async def test_method_create_with_all_params(self, async_client: AsyncAsktable) name="name", path="/resource", project_id="project_id", + updated_at=parse_datetime("2019-12-27T18:11:19.117Z"), body_params_desc="body_params_desc", path_params_desc="path_params_desc", query_params_desc="query_params_desc", - updated_at=parse_datetime("2019-12-27T18:11:19.117Z"), ) assert_matches_type(ExtapiRoute, route, path=["response"]) @@ -345,6 +350,7 @@ async def test_raw_response_create(self, async_client: AsyncAsktable) -> None: name="name", path="/resource", project_id="project_id", + updated_at=parse_datetime("2019-12-27T18:11:19.117Z"), ) assert response.is_closed is True @@ -363,6 +369,7 @@ async def test_streaming_response_create(self, async_client: AsyncAsktable) -> N name="name", path="/resource", project_id="project_id", + updated_at=parse_datetime("2019-12-27T18:11:19.117Z"), ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -384,6 +391,7 @@ async def test_path_params_create(self, async_client: AsyncAsktable) -> None: name="name", path="/resource", project_id="project_id", + updated_at=parse_datetime("2019-12-27T18:11:19.117Z"), ) @parametrize diff --git a/tests/api_resources/test_auth.py b/tests/api_resources/test_auth.py index 280554a4..a834d2c3 100644 --- a/tests/api_resources/test_auth.py +++ b/tests/api_resources/test_auth.py @@ -9,6 +9,7 @@ from asktable import Asktable, AsyncAsktable from tests.utils import assert_matches_type +from asktable.types import AuthMeResponse base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -57,7 +58,7 @@ def test_streaming_response_create_token(self, client: Asktable) -> None: @parametrize def test_method_me(self, client: Asktable) -> None: auth = client.auth.me() - assert_matches_type(object, auth, path=["response"]) + assert_matches_type(AuthMeResponse, auth, path=["response"]) @parametrize def test_raw_response_me(self, client: Asktable) -> None: @@ -66,7 +67,7 @@ def test_raw_response_me(self, client: Asktable) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" auth = response.parse() - assert_matches_type(object, auth, path=["response"]) + assert_matches_type(AuthMeResponse, auth, path=["response"]) @parametrize def test_streaming_response_me(self, client: Asktable) -> None: @@ -75,7 +76,7 @@ def test_streaming_response_me(self, client: Asktable) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" auth = response.parse() - assert_matches_type(object, auth, path=["response"]) + assert_matches_type(AuthMeResponse, auth, path=["response"]) assert cast(Any, response.is_closed) is True @@ -124,7 +125,7 @@ async def test_streaming_response_create_token(self, async_client: AsyncAsktable @parametrize async def test_method_me(self, async_client: AsyncAsktable) -> None: auth = await async_client.auth.me() - assert_matches_type(object, auth, path=["response"]) + assert_matches_type(AuthMeResponse, auth, path=["response"]) @parametrize async def test_raw_response_me(self, async_client: AsyncAsktable) -> None: @@ -133,7 +134,7 @@ async def test_raw_response_me(self, async_client: AsyncAsktable) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" auth = await response.parse() - assert_matches_type(object, auth, path=["response"]) + assert_matches_type(AuthMeResponse, auth, path=["response"]) @parametrize async def test_streaming_response_me(self, async_client: AsyncAsktable) -> None: @@ -142,6 +143,6 @@ async def test_streaming_response_me(self, async_client: AsyncAsktable) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" auth = await response.parse() - assert_matches_type(object, auth, path=["response"]) + assert_matches_type(AuthMeResponse, auth, path=["response"]) assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/test_dataframes.py b/tests/api_resources/test_dataframes.py new file mode 100644 index 00000000..8e71063a --- /dev/null +++ b/tests/api_resources/test_dataframes.py @@ -0,0 +1,98 @@ +# 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 DataframeRetrieveResponse + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestDataframes: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + def test_method_retrieve(self, client: Asktable) -> None: + dataframe = client.dataframes.retrieve( + "dataframe_id", + ) + assert_matches_type(DataframeRetrieveResponse, dataframe, path=["response"]) + + @parametrize + def test_raw_response_retrieve(self, client: Asktable) -> None: + response = client.dataframes.with_raw_response.retrieve( + "dataframe_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + dataframe = response.parse() + assert_matches_type(DataframeRetrieveResponse, dataframe, path=["response"]) + + @parametrize + def test_streaming_response_retrieve(self, client: Asktable) -> None: + with client.dataframes.with_streaming_response.retrieve( + "dataframe_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + dataframe = response.parse() + assert_matches_type(DataframeRetrieveResponse, dataframe, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_retrieve(self, client: Asktable) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `dataframe_id` but received ''"): + client.dataframes.with_raw_response.retrieve( + "", + ) + + +class TestAsyncDataframes: + parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + async def test_method_retrieve(self, async_client: AsyncAsktable) -> None: + dataframe = await async_client.dataframes.retrieve( + "dataframe_id", + ) + assert_matches_type(DataframeRetrieveResponse, dataframe, path=["response"]) + + @parametrize + async def test_raw_response_retrieve(self, async_client: AsyncAsktable) -> None: + response = await async_client.dataframes.with_raw_response.retrieve( + "dataframe_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + dataframe = await response.parse() + assert_matches_type(DataframeRetrieveResponse, dataframe, path=["response"]) + + @parametrize + async def test_streaming_response_retrieve(self, async_client: AsyncAsktable) -> None: + async with async_client.dataframes.with_streaming_response.retrieve( + "dataframe_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + dataframe = await response.parse() + assert_matches_type(DataframeRetrieveResponse, dataframe, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_retrieve(self, async_client: AsyncAsktable) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `dataframe_id` but received ''"): + await async_client.dataframes.with_raw_response.retrieve( + "", + ) diff --git a/tests/api_resources/test_datasources.py b/tests/api_resources/test_datasources.py index 5dc99ec4..6cb041a0 100644 --- a/tests/api_resources/test_datasources.py +++ b/tests/api_resources/test_datasources.py @@ -32,8 +32,6 @@ def test_method_create(self, client: Asktable) -> None: def test_method_create_with_all_params(self, client: Asktable) -> None: datasource = client.datasources.create( engine="mysql", - async_process_meta=True, - value_index=True, access_config={ "host": "192.168.0.10", "db": "at_test", @@ -351,8 +349,6 @@ async def test_method_create(self, async_client: AsyncAsktable) -> None: async def test_method_create_with_all_params(self, async_client: AsyncAsktable) -> None: datasource = await async_client.datasources.create( engine="mysql", - async_process_meta=True, - value_index=True, access_config={ "host": "192.168.0.10", "db": "at_test", diff --git a/tests/api_resources/test_files.py b/tests/api_resources/test_files.py new file mode 100644 index 00000000..6b979645 --- /dev/null +++ b/tests/api_resources/test_files.py @@ -0,0 +1,97 @@ +# 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 TestFiles: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + def test_method_retrieve(self, client: Asktable) -> None: + file = client.files.retrieve( + "file_id", + ) + assert_matches_type(object, file, path=["response"]) + + @parametrize + def test_raw_response_retrieve(self, client: Asktable) -> None: + response = client.files.with_raw_response.retrieve( + "file_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + file = response.parse() + assert_matches_type(object, file, path=["response"]) + + @parametrize + def test_streaming_response_retrieve(self, client: Asktable) -> None: + with client.files.with_streaming_response.retrieve( + "file_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + file = response.parse() + assert_matches_type(object, file, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_retrieve(self, client: Asktable) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `file_id` but received ''"): + client.files.with_raw_response.retrieve( + "", + ) + + +class TestAsyncFiles: + parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + async def test_method_retrieve(self, async_client: AsyncAsktable) -> None: + file = await async_client.files.retrieve( + "file_id", + ) + assert_matches_type(object, file, path=["response"]) + + @parametrize + async def test_raw_response_retrieve(self, async_client: AsyncAsktable) -> None: + response = await async_client.files.with_raw_response.retrieve( + "file_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + file = await response.parse() + assert_matches_type(object, file, path=["response"]) + + @parametrize + async def test_streaming_response_retrieve(self, async_client: AsyncAsktable) -> None: + async with async_client.files.with_streaming_response.retrieve( + "file_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + file = await response.parse() + assert_matches_type(object, file, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_retrieve(self, async_client: AsyncAsktable) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `file_id` but received ''"): + await async_client.files.with_raw_response.retrieve( + "", + ) diff --git a/tests/api_resources/test_securetunnels.py b/tests/api_resources/test_securetunnels.py index 1c9f0a84..6b2602a7 100644 --- a/tests/api_resources/test_securetunnels.py +++ b/tests/api_resources/test_securetunnels.py @@ -94,7 +94,6 @@ def test_path_params_retrieve(self, client: Asktable) -> None: def test_method_update(self, client: Asktable) -> None: securetunnel = client.securetunnels.update( securetunnel_id="securetunnel_id", - name="我的测试机", ) assert_matches_type(SecureTunnel, securetunnel, path=["response"]) @@ -102,8 +101,8 @@ def test_method_update(self, client: Asktable) -> None: def test_method_update_with_all_params(self, client: Asktable) -> None: securetunnel = client.securetunnels.update( securetunnel_id="securetunnel_id", - name="我的测试机", client_info={}, + name="我的测试机", unique_key="unique_key", ) assert_matches_type(SecureTunnel, securetunnel, path=["response"]) @@ -112,7 +111,6 @@ def test_method_update_with_all_params(self, client: Asktable) -> None: def test_raw_response_update(self, client: Asktable) -> None: response = client.securetunnels.with_raw_response.update( securetunnel_id="securetunnel_id", - name="我的测试机", ) assert response.is_closed is True @@ -124,7 +122,6 @@ def test_raw_response_update(self, client: Asktable) -> None: def test_streaming_response_update(self, client: Asktable) -> None: with client.securetunnels.with_streaming_response.update( securetunnel_id="securetunnel_id", - name="我的测试机", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -139,7 +136,6 @@ def test_path_params_update(self, client: Asktable) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `securetunnel_id` but received ''"): client.securetunnels.with_raw_response.update( securetunnel_id="", - name="我的测试机", ) @parametrize @@ -337,7 +333,6 @@ async def test_path_params_retrieve(self, async_client: AsyncAsktable) -> None: async def test_method_update(self, async_client: AsyncAsktable) -> None: securetunnel = await async_client.securetunnels.update( securetunnel_id="securetunnel_id", - name="我的测试机", ) assert_matches_type(SecureTunnel, securetunnel, path=["response"]) @@ -345,8 +340,8 @@ async def test_method_update(self, async_client: AsyncAsktable) -> None: async def test_method_update_with_all_params(self, async_client: AsyncAsktable) -> None: securetunnel = await async_client.securetunnels.update( securetunnel_id="securetunnel_id", - name="我的测试机", client_info={}, + name="我的测试机", unique_key="unique_key", ) assert_matches_type(SecureTunnel, securetunnel, path=["response"]) @@ -355,7 +350,6 @@ async def test_method_update_with_all_params(self, async_client: AsyncAsktable) async def test_raw_response_update(self, async_client: AsyncAsktable) -> None: response = await async_client.securetunnels.with_raw_response.update( securetunnel_id="securetunnel_id", - name="我的测试机", ) assert response.is_closed is True @@ -367,7 +361,6 @@ async def test_raw_response_update(self, async_client: AsyncAsktable) -> None: async def test_streaming_response_update(self, async_client: AsyncAsktable) -> None: async with async_client.securetunnels.with_streaming_response.update( securetunnel_id="securetunnel_id", - name="我的测试机", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -382,7 +375,6 @@ async def test_path_params_update(self, async_client: AsyncAsktable) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `securetunnel_id` but received ''"): await async_client.securetunnels.with_raw_response.update( securetunnel_id="", - name="我的测试机", ) @parametrize diff --git a/tests/test_client.py b/tests/test_client.py index 2f645e8f..1efc0ea1 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -6,6 +6,7 @@ import os import sys import json +import time import asyncio import inspect import subprocess @@ -22,6 +23,7 @@ from asktable import Asktable, AsyncAsktable, APIResponseValidationError from asktable._types import Omit +from asktable._utils import maybe_transform from asktable._models import BaseModel, FinalRequestOptions from asktable._constants import RAW_RESPONSE_HEADER from asktable._exceptions import APIStatusError, APITimeoutError, APIResponseValidationError @@ -31,6 +33,7 @@ BaseClient, make_request_options, ) +from asktable.types.datasource_create_params import DatasourceCreateParams from .utils import update_env @@ -701,12 +704,12 @@ def test_parse_retry_after_header(self, remaining_retries: int, retry_after: str @mock.patch("asktable._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout) @pytest.mark.respx(base_url=base_url) def test_retrying_timeout_errors_doesnt_leak(self, respx_mock: MockRouter) -> None: - respx_mock.post("/datasources").mock(side_effect=httpx.TimeoutException("Test timeout error")) + respx_mock.post("/v1/datasources").mock(side_effect=httpx.TimeoutException("Test timeout error")) with pytest.raises(APITimeoutError): self.client.post( - "/datasources", - body=cast(object, dict(engine="mysql")), + "/v1/datasources", + body=cast(object, maybe_transform(dict(engine="mysql"), DatasourceCreateParams)), cast_to=httpx.Response, options={"headers": {RAW_RESPONSE_HEADER: "stream"}}, ) @@ -716,12 +719,12 @@ def test_retrying_timeout_errors_doesnt_leak(self, respx_mock: MockRouter) -> No @mock.patch("asktable._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout) @pytest.mark.respx(base_url=base_url) def test_retrying_status_errors_doesnt_leak(self, respx_mock: MockRouter) -> None: - respx_mock.post("/datasources").mock(return_value=httpx.Response(500)) + respx_mock.post("/v1/datasources").mock(return_value=httpx.Response(500)) with pytest.raises(APIStatusError): self.client.post( - "/datasources", - body=cast(object, dict(engine="mysql")), + "/v1/datasources", + body=cast(object, maybe_transform(dict(engine="mysql"), DatasourceCreateParams)), cast_to=httpx.Response, options={"headers": {RAW_RESPONSE_HEADER: "stream"}}, ) @@ -752,7 +755,7 @@ def retry_handler(_request: httpx.Request) -> httpx.Response: return httpx.Response(500) return httpx.Response(200) - respx_mock.post("/datasources").mock(side_effect=retry_handler) + respx_mock.post("/v1/datasources").mock(side_effect=retry_handler) response = client.datasources.with_raw_response.create(engine="mysql") @@ -776,7 +779,7 @@ def retry_handler(_request: httpx.Request) -> httpx.Response: return httpx.Response(500) return httpx.Response(200) - respx_mock.post("/datasources").mock(side_effect=retry_handler) + respx_mock.post("/v1/datasources").mock(side_effect=retry_handler) response = client.datasources.with_raw_response.create( engine="mysql", extra_headers={"x-stainless-retry-count": Omit()} @@ -801,7 +804,7 @@ def retry_handler(_request: httpx.Request) -> httpx.Response: return httpx.Response(500) return httpx.Response(200) - respx_mock.post("/datasources").mock(side_effect=retry_handler) + respx_mock.post("/v1/datasources").mock(side_effect=retry_handler) response = client.datasources.with_raw_response.create( engine="mysql", extra_headers={"x-stainless-retry-count": "42"} @@ -1471,12 +1474,12 @@ async def test_parse_retry_after_header(self, remaining_retries: int, retry_afte @mock.patch("asktable._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout) @pytest.mark.respx(base_url=base_url) async def test_retrying_timeout_errors_doesnt_leak(self, respx_mock: MockRouter) -> None: - respx_mock.post("/datasources").mock(side_effect=httpx.TimeoutException("Test timeout error")) + respx_mock.post("/v1/datasources").mock(side_effect=httpx.TimeoutException("Test timeout error")) with pytest.raises(APITimeoutError): await self.client.post( - "/datasources", - body=cast(object, dict(engine="mysql")), + "/v1/datasources", + body=cast(object, maybe_transform(dict(engine="mysql"), DatasourceCreateParams)), cast_to=httpx.Response, options={"headers": {RAW_RESPONSE_HEADER: "stream"}}, ) @@ -1486,12 +1489,12 @@ async def test_retrying_timeout_errors_doesnt_leak(self, respx_mock: MockRouter) @mock.patch("asktable._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout) @pytest.mark.respx(base_url=base_url) async def test_retrying_status_errors_doesnt_leak(self, respx_mock: MockRouter) -> None: - respx_mock.post("/datasources").mock(return_value=httpx.Response(500)) + respx_mock.post("/v1/datasources").mock(return_value=httpx.Response(500)) with pytest.raises(APIStatusError): await self.client.post( - "/datasources", - body=cast(object, dict(engine="mysql")), + "/v1/datasources", + body=cast(object, maybe_transform(dict(engine="mysql"), DatasourceCreateParams)), cast_to=httpx.Response, options={"headers": {RAW_RESPONSE_HEADER: "stream"}}, ) @@ -1523,7 +1526,7 @@ def retry_handler(_request: httpx.Request) -> httpx.Response: return httpx.Response(500) return httpx.Response(200) - respx_mock.post("/datasources").mock(side_effect=retry_handler) + respx_mock.post("/v1/datasources").mock(side_effect=retry_handler) response = await client.datasources.with_raw_response.create(engine="mysql") @@ -1548,7 +1551,7 @@ def retry_handler(_request: httpx.Request) -> httpx.Response: return httpx.Response(500) return httpx.Response(200) - respx_mock.post("/datasources").mock(side_effect=retry_handler) + respx_mock.post("/v1/datasources").mock(side_effect=retry_handler) response = await client.datasources.with_raw_response.create( engine="mysql", extra_headers={"x-stainless-retry-count": Omit()} @@ -1574,7 +1577,7 @@ def retry_handler(_request: httpx.Request) -> httpx.Response: return httpx.Response(500) return httpx.Response(200) - respx_mock.post("/datasources").mock(side_effect=retry_handler) + respx_mock.post("/v1/datasources").mock(side_effect=retry_handler) response = await client.datasources.with_raw_response.create( engine="mysql", extra_headers={"x-stainless-retry-count": "42"} @@ -1609,10 +1612,20 @@ async def test_main() -> None: [sys.executable, "-c", test_code], text=True, ) as process: - try: - process.wait(2) - if process.returncode: - raise AssertionError("calling get_platform using asyncify resulted in a non-zero exit code") - except subprocess.TimeoutExpired as e: - process.kill() - raise AssertionError("calling get_platform using asyncify resulted in a hung process") from e + timeout = 10 # seconds + + start_time = time.monotonic() + while True: + return_code = process.poll() + if return_code is not None: + if return_code != 0: + raise AssertionError("calling get_platform using asyncify resulted in a non-zero exit code") + + # success + break + + if time.monotonic() - start_time > timeout: + process.kill() + raise AssertionError("calling get_platform using asyncify resulted in a hung process") + + time.sleep(0.1) diff --git a/tests/test_models.py b/tests/test_models.py index 0a584a88..89906cad 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -854,3 +854,35 @@ class Model(BaseModel): m = construct_type(value={"cls": "foo"}, type_=Model) assert isinstance(m, Model) assert isinstance(m.cls, str) + + +def test_discriminated_union_case() -> None: + class A(BaseModel): + type: Literal["a"] + + data: bool + + class B(BaseModel): + type: Literal["b"] + + data: List[Union[A, object]] + + class ModelA(BaseModel): + type: Literal["modelA"] + + data: int + + class ModelB(BaseModel): + type: Literal["modelB"] + + required: str + + data: Union[A, B] + + # when constructing ModelA | ModelB, value data doesn't match ModelB exactly - missing `required` + m = construct_type( + value={"type": "modelB", "data": {"type": "a", "data": True}}, + type_=cast(Any, Annotated[Union[ModelA, ModelB], PropertyInfo(discriminator="type")]), + ) + + assert isinstance(m, ModelB) diff --git a/tests/test_transform.py b/tests/test_transform.py index 33e681b0..581d749f 100644 --- a/tests/test_transform.py +++ b/tests/test_transform.py @@ -2,7 +2,7 @@ import io import pathlib -from typing import Any, List, Union, TypeVar, Iterable, Optional, cast +from typing import Any, Dict, List, Union, TypeVar, Iterable, Optional, cast from datetime import date, datetime from typing_extensions import Required, Annotated, TypedDict @@ -388,6 +388,15 @@ def my_iter() -> Iterable[Baz8]: } +@parametrize +@pytest.mark.asyncio +async def test_dictionary_items(use_async: bool) -> None: + class DictItems(TypedDict): + foo_baz: Annotated[str, PropertyInfo(alias="fooBaz")] + + assert await transform({"foo": {"foo_baz": "bar"}}, Dict[str, DictItems], use_async) == {"foo": {"fooBaz": "bar"}} + + class TypedDictIterableUnionStr(TypedDict): foo: Annotated[Union[str, Iterable[Baz8]], PropertyInfo(alias="FOO")]