diff --git a/.release-please-manifest.json b/.release-please-manifest.json
index 1f73031b..ff1c7af5 100644
--- a/.release-please-manifest.json
+++ b/.release-please-manifest.json
@@ -1,3 +1,3 @@
{
- ".": "3.2.0"
+ ".": "3.3.0"
}
\ No newline at end of file
diff --git a/.stats.yml b/.stats.yml
index 2e4c44cc..e3f9c0f6 100644
--- a/.stats.yml
+++ b/.stats.yml
@@ -1,2 +1,2 @@
-configured_endpoints: 74
-openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/datamini%2Fasktable-2501e64cd24ad589fc833556bbecd5f54321add8f57b18c6af3503a75be0101f.yml
+configured_endpoints: 81
+openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/datamini%2Fasktable-f78191153cae54be3e273ca76fbb91453dec4696f00fc6d679ca2ffc3d533ede.yml
diff --git a/CHANGELOG.md b/CHANGELOG.md
index faf060fe..62e70dd4 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,29 @@
# Changelog
+## 3.3.0 (2024-11-24)
+
+Full Changelog: [v3.2.0...v3.3.0](https://github.com/DataMini/asktable-python/compare/v3.2.0...v3.3.0)
+
+### Features
+
+* **api:** api update ([#31](https://github.com/DataMini/asktable-python/issues/31)) ([268e767](https://github.com/DataMini/asktable-python/commit/268e7672c52e944ce5b86bfb463417ae469b8d03))
+* **api:** api update ([#33](https://github.com/DataMini/asktable-python/issues/33)) ([5a4660f](https://github.com/DataMini/asktable-python/commit/5a4660f423deb1ec5edf2a30d44153e00e0771be))
+* **api:** api update ([#34](https://github.com/DataMini/asktable-python/issues/34)) ([5db3b77](https://github.com/DataMini/asktable-python/commit/5db3b773117673385135f57c382531417ad72704))
+* **api:** api update ([#35](https://github.com/DataMini/asktable-python/issues/35)) ([3d90aa2](https://github.com/DataMini/asktable-python/commit/3d90aa24c6b9312433627ded99833dae3fac32d7))
+* **api:** api update ([#36](https://github.com/DataMini/asktable-python/issues/36)) ([9433649](https://github.com/DataMini/asktable-python/commit/943364966023a54ae6a022a8da5b818f0617e3ee))
+* **api:** api update ([#39](https://github.com/DataMini/asktable-python/issues/39)) ([0e888dd](https://github.com/DataMini/asktable-python/commit/0e888dd2fcc907d7bb48d7a8cdcf0054063b2f28))
+* **api:** api update ([#40](https://github.com/DataMini/asktable-python/issues/40)) ([7d4f6fb](https://github.com/DataMini/asktable-python/commit/7d4f6fbc4ffa228a0a3a9faa2cda71c73cb6aa67))
+* **api:** api update ([#41](https://github.com/DataMini/asktable-python/issues/41)) ([95f8c27](https://github.com/DataMini/asktable-python/commit/95f8c270621f46c785261b7ef2356aa326b11905))
+* **api:** api update ([#42](https://github.com/DataMini/asktable-python/issues/42)) ([1e6ad9f](https://github.com/DataMini/asktable-python/commit/1e6ad9fa9fee86eb869a88a6a7457b10a321b1dd))
+* **api:** manual updates ([#43](https://github.com/DataMini/asktable-python/issues/43)) ([f58065b](https://github.com/DataMini/asktable-python/commit/f58065b10b0af77e5761d0e7bfc6120a5a33ab9b))
+* **api:** manual updates ([#44](https://github.com/DataMini/asktable-python/issues/44)) ([8e6183c](https://github.com/DataMini/asktable-python/commit/8e6183c1d338f7a2fe0179f190503ee0fdc520d1))
+
+
+### Chores
+
+* rebuild project due to codegen change ([#37](https://github.com/DataMini/asktable-python/issues/37)) ([3da94d2](https://github.com/DataMini/asktable-python/commit/3da94d2c69fc812bec6b5ef0dc5f934ba58e706e))
+* rebuild project due to codegen change ([#38](https://github.com/DataMini/asktable-python/issues/38)) ([34b494d](https://github.com/DataMini/asktable-python/commit/34b494d2398512da5a44cc6ae6e13a54d324247c))
+
## 3.2.0 (2024-11-12)
Full Changelog: [v3.1.0...v3.2.0](https://github.com/DataMini/asktable-python/compare/v3.1.0...v3.2.0)
diff --git a/README.md b/README.md
index 7684af56..a54f961c 100644
--- a/README.md
+++ b/README.md
@@ -28,8 +28,10 @@ from asktable import Asktable
client = Asktable()
-datasource = client.datasources.list()
-print(datasource.items)
+datasource = client.datasources.create(
+ engine="mysql",
+)
+print(datasource.id)
```
While you can provide an `api_key` keyword argument,
@@ -49,8 +51,10 @@ client = AsyncAsktable()
async def main() -> None:
- datasource = await client.datasources.list()
- print(datasource.items)
+ datasource = await client.datasources.create(
+ engine="mysql",
+ )
+ print(datasource.id)
asyncio.run(main())
@@ -67,6 +71,69 @@ Nested request parameters are [TypedDicts](https://docs.python.org/3/library/typ
Typed requests and responses provide autocomplete and documentation within your editor. If you would like to see type errors in VS Code to help catch bugs earlier, set `python.analysis.typeCheckingMode` to `basic`.
+## Pagination
+
+List methods in the Asktable API are paginated.
+
+This library provides auto-paginating iterators with each list response, so you do not have to request successive pages manually:
+
+```python
+from asktable import Asktable
+
+client = Asktable()
+
+all_datasources = []
+# Automatically fetches more pages as needed.
+for datasource in client.datasources.list():
+ # Do something with datasource here
+ all_datasources.append(datasource)
+print(all_datasources)
+```
+
+Or, asynchronously:
+
+```python
+import asyncio
+from asktable import AsyncAsktable
+
+client = AsyncAsktable()
+
+
+async def main() -> None:
+ all_datasources = []
+ # Iterate through items across all pages, issuing requests as needed.
+ async for datasource in client.datasources.list():
+ all_datasources.append(datasource)
+ print(all_datasources)
+
+
+asyncio.run(main())
+```
+
+Alternatively, you can use the `.has_next_page()`, `.next_page_info()`, or `.get_next_page()` methods for more granular control working with pages:
+
+```python
+first_page = await client.datasources.list()
+if first_page.has_next_page():
+ print(f"will fetch next page using these details: {first_page.next_page_info()}")
+ next_page = await first_page.get_next_page()
+ print(f"number of items we just fetched: {len(next_page.items)}")
+
+# Remove `await` for non-async usage.
+```
+
+Or just work directly with the returned data:
+
+```python
+first_page = await client.datasources.list()
+
+print(f"page number: {first_page.page}") # => "page number: 1"
+for datasource in first_page.items:
+ print(datasource.id)
+
+# Remove `await` for non-async usage.
+```
+
## 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/api.md b/api.md
index 18e8ce25..b0fc271d 100644
--- a/api.md
+++ b/api.md
@@ -1,91 +1,94 @@
# Shared Types
```python
-from asktable.types import AnswerModel, Message, Policy
+from asktable.types import Policy
```
-# Securetunnels
-
-Types:
-
-```python
-from asktable.types import SecureTunnel, SecuretunnelUpdateResponse, SecuretunnelListResponse
-```
-
-Methods:
-
-- client.securetunnels.create(\*\*params) -> SecureTunnel
-- client.securetunnels.retrieve(securetunnel_id) -> SecureTunnel
-- client.securetunnels.update(securetunnel_id, \*\*params) -> object
-- client.securetunnels.list(\*\*params) -> SecuretunnelListResponse
-- client.securetunnels.delete(securetunnel_id) -> None
+# Sys
-## Links
+## Projects
Types:
```python
-from asktable.types.securetunnels import SecureTunnelLink
+from asktable.types.sys import APIKey, Project, ProjectDeleteResponse
```
Methods:
-- client.securetunnels.links.list(securetunnel_id, \*\*params) -> SecureTunnelLink
+- 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
-# Roles
+### APIKeys
Types:
```python
-from asktable.types import Role, RoleListResponse, RoleDeleteResponse
+from asktable.types.sys.projects import (
+ APIKeyCreateResponse,
+ APIKeyListResponse,
+ APIKeyCreateTokenResponse,
+)
```
Methods:
-- client.roles.create(\*\*params) -> Role
-- client.roles.retrieve(role_id) -> Role
-- client.roles.update(role_id, \*\*params) -> Role
-- client.roles.list(\*\*params) -> RoleListResponse
-- client.roles.delete(role_id) -> 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
-## Policies
+# Securetunnels
Types:
```python
-from asktable.types.roles import PolicyListResponse
+from asktable.types import SecureTunnel, SecuretunnelListLinksResponse
```
Methods:
-- client.roles.policies.list(role_id) -> PolicyListResponse
+- 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]
-## Variables
+# Roles
Types:
```python
-from asktable.types.roles import VariableListResponse
+from asktable.types import (
+ Role,
+ RoleDeleteResponse,
+ RoleGetPolicesResponse,
+ RoleGetVariablesResponse,
+)
```
Methods:
-- client.roles.variables.list(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
-Types:
-
-```python
-from asktable.types import PolicyListResponse
-```
-
Methods:
- client.policies.create(\*\*params) -> Policy
- client.policies.retrieve(policy_id) -> Policy
- client.policies.update(policy_id, \*\*params) -> Policy
-- client.policies.list(\*\*params) -> PolicyListResponse
+- client.policies.list(\*\*params) -> SyncPage[Policy]
- client.policies.delete(policy_id) -> None
# Chats
@@ -93,66 +96,56 @@ Methods:
Types:
```python
-from asktable.types import ChatCreateResponse, ChatRetrieveResponse, ChatListResponse
+from asktable.types import Chat, Message
```
Methods:
-- client.chats.create(\*\*params) -> ChatCreateResponse
-- client.chats.retrieve(chat_id) -> ChatRetrieveResponse
-- client.chats.list(\*\*params) -> ChatListResponse
+- client.chats.create(\*\*params) -> Chat
+- client.chats.retrieve(chat_id) -> Chat
+- client.chats.list(\*\*params) -> SyncPage[Chat]
- client.chats.delete(chat_id) -> None
+- client.chats.send_message(chat_id, \*\*params) -> Message
## Messages
-Types:
-
-```python
-from asktable.types.chats import MessageModel, MessageListResponse
-```
-
Methods:
-- client.chats.messages.create(chat_id, \*\*params) -> Message
-- client.chats.messages.retrieve(message_id, \*, chat_id) -> Message
-- client.chats.messages.list(chat_id, \*\*params) -> MessageListResponse
+- client.chats.messages.retrieve(message_id, \*, chat_id) -> Message
+- client.chats.messages.list(chat_id, \*\*params) -> SyncPage[Message]
+- client.chats.messages.send_message(chat_id, \*\*params) -> Message
# Datasources
Types:
```python
-from asktable.types import DataSource, DatasourceListResponse, DatasourceDeleteResponse
+from asktable.types import Datasource, Index, Meta, DatasourceDeleteResponse
```
Methods:
-- client.datasources.create(\*\*params) -> DataSource
-- client.datasources.retrieve(datasource_id) -> DataSource
-- client.datasources.update(datasource_id, \*\*params) -> DataSource
-- client.datasources.list(\*\*params) -> DatasourceListResponse
+- client.datasources.create(\*\*params) -> Datasource
+- client.datasources.retrieve(datasource_id) -> Datasource
+- client.datasources.update(datasource_id, \*\*params) -> Datasource
+- client.datasources.list(\*\*params) -> SyncPage[Datasource]
- client.datasources.delete(datasource_id) -> object
-- client.datasources.create_from_file(\*\*params) -> DataSource
+- client.datasources.create_from_file(\*\*params) -> Datasource
## Meta
Types:
```python
-from asktable.types.datasources import (
- Meta,
- MetaCreateResponse,
- MetaUpdateResponse,
- MetaDeleteResponse,
-)
+from asktable.types.datasources import MetaCreateResponse, MetaUpdateResponse, MetaAnnotateResponse
```
Methods:
- client.datasources.meta.create(datasource_id, \*\*params) -> object
-- client.datasources.meta.retrieve(datasource_id) -> Meta
+- client.datasources.meta.retrieve(datasource_id) -> Meta
- client.datasources.meta.update(datasource_id, \*\*params) -> object
-- client.datasources.meta.delete(datasource_id) -> object
+- client.datasources.meta.annotate(datasource_id, \*\*params) -> object
## UploadParams
@@ -166,80 +159,81 @@ Methods:
- client.datasources.upload_params.create(\*\*params) -> object
-# Bots
+## Indexes
Types:
```python
-from asktable.types import ChatBot, BotListResponse, BotDeleteResponse, BotInviteResponse
+from asktable.types.datasources import IndexCreateResponse, IndexDeleteResponse
```
Methods:
-- client.bots.create(\*\*params) -> ChatBot
-- client.bots.retrieve(bot_id) -> ChatBot
-- client.bots.update(bot_id, \*\*params) -> ChatBot
-- client.bots.list(\*\*params) -> BotListResponse
-- client.bots.delete(bot_id) -> object
-- client.bots.invite(bot_id, \*\*params) -> 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
-# Extapis
+# Bots
Types:
```python
-from asktable.types import ExtAPIModel, ExtapiListResponse, ExtapiDeleteResponse
+from asktable.types import Chatbot, BotDeleteResponse, BotInviteResponse
```
Methods:
-- client.extapis.create(\*\*params) -> ExtAPIModel
-- client.extapis.retrieve(extapi_id) -> ExtAPIModel
-- client.extapis.update(extapi_id, \*\*params) -> ExtAPIModel
-- client.extapis.list(\*\*params) -> ExtapiListResponse
-- client.extapis.delete(extapi_id) -> 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
-## Routes
+# Extapis
Types:
```python
-from asktable.types.extapis import ExtAPIRouteModel, RouteListResponse
+from asktable.types import Extapi, ExtapiDeleteResponse
```
Methods:
-- client.extapis.routes.create(\*, path_extapi_id, \*\*params) -> ExtAPIRouteModel
-- client.extapis.routes.retrieve(route_id, \*, extapi_id) -> ExtAPIRouteModel
-- client.extapis.routes.update(route_id, \*, extapi_id, \*\*params) -> ExtAPIRouteModel
-- client.extapis.routes.list(extapi_id) -> RouteListResponse
-- client.extapis.routes.delete(route_id, \*, extapi_id) -> None
-
-# Auth
+- 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
-## Tokens
+## Routes
Types:
```python
-from asktable.types.auth import TokenCreateResponse
+from asktable.types.extapis import ExtapiRoute, RouteListResponse
```
Methods:
-- client.auth.tokens.create(\*\*params) -> object
+- 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
-## Me
+# Auth
Types:
```python
-from asktable.types.auth import MeRetrieveResponse
+from asktable.types import AuthCreateTokenResponse, AuthMeResponse
```
Methods:
-- client.auth.me.retrieve() -> object
+- client.auth.create_token(\*\*params) -> object
+- client.auth.me() -> object
# SingleTurn
@@ -248,112 +242,76 @@ Methods:
Types:
```python
-from asktable.types.single_turn import Q2aListResponse
+from asktable.types.single_turn import Q2aResponse
```
Methods:
-- client.single_turn.q2a.create(\*\*params) -> AnswerModel
-- client.single_turn.q2a.list(\*\*params) -> Q2aListResponse
+- client.single_turn.q2a.create(\*\*params) -> Q2aResponse
+- client.single_turn.q2a.list(\*\*params) -> SyncPage[Q2aResponse]
## Q2s
Types:
```python
-from asktable.types.single_turn import Q2sResponse, Q2ListResponse
+from asktable.types.single_turn import Q2sResponse
```
Methods:
- client.single_turn.q2s.create(\*\*params) -> Q2sResponse
-- client.single_turn.q2s.list(\*\*params) -> Q2ListResponse
-
-# Caches
-
-Methods:
-
-- client.caches.delete(cache_id) -> None
-
-# Integration
-
-Types:
-
-```python
-from asktable.types import AnswerDataSourceOut
-```
-
-Methods:
-
-- client.integration.excel_csv_ask(\*\*params) -> AnswerDataSourceOut
-
-## ExcelCsv
-
-Types:
-
-```python
-from asktable.types.integration import DatasourceOut
-```
-
-Methods:
-
-- client.integration.excel_csv.create(\*\*params) -> DataSource
-
-# Sys
+- client.single_turn.q2s.list(\*\*params) -> SyncPage[Q2sResponse]
-## Projects
+## Q2w
Types:
```python
-from asktable.types.sys import Project, ProjectListResponse, ProjectDeleteResponse
+from asktable.types.single_turn import Q2wCreateResponse, Q2wListResponse
```
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) -> ProjectListResponse
-- client.sys.projects.delete(project_id) -> object
-
-### APIKeys
-
-Types:
+- client.single_turn.q2w.create(\*\*params) -> object
+- client.single_turn.q2w.list() -> object
-```python
-from asktable.types.sys.projects import APIKey, APIKeyCreate, APIKeyListResponse
-```
+# Caches
Methods:
-- client.sys.projects.api_keys.create(project_id, \*\*params) -> APIKeyCreate
-- client.sys.projects.api_keys.list(project_id) -> APIKeyListResponse
-- client.sys.projects.api_keys.delete(key_id, \*, project_id) -> None
+- client.caches.delete(cache_id) -> None
-### Tokens
+# Integration
Types:
```python
-from asktable.types.sys.projects import TokenCreateResponse
+from asktable.types import FileAskResponse
```
Methods:
-- client.sys.projects.tokens.create(project_id, \*\*params) -> object
+- client.integration.create_excel_ds(\*\*params) -> Datasource
+- client.integration.excel_csv_ask(\*\*params) -> FileAskResponse
-# KB
+# BusinessGlossary
Types:
```python
-from asktable.types import Document, PageDocument, KBCreateResponse, KBDeleteResponse
+from asktable.types import (
+ Entry,
+ EntryWithDefinition,
+ BusinessGlossaryCreateResponse,
+ BusinessGlossaryDeleteResponse,
+)
```
Methods:
-- client.kb.create(\*\*params) -> KBCreateResponse
-- client.kb.retrieve(doc_id) -> Document
-- client.kb.list(\*\*params) -> PageDocument
-- client.kb.delete(doc_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[Entry]
+- client.business_glossary.delete(entry_id) -> object
diff --git a/pyproject.toml b/pyproject.toml
index 828bd3d9..dc93b544 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,6 +1,6 @@
[project]
name = "asktable"
-version = "3.2.0"
+version = "3.3.0"
description = "The official Python library for the asktable API"
dynamic = ["readme"]
license = "Apache-2.0"
@@ -55,6 +55,7 @@ dev-dependencies = [
"dirty-equals>=0.6.0",
"importlib-metadata>=6.7.0",
"rich>=13.7.1",
+ "nest_asyncio==1.6.0"
]
[tool.rye.scripts]
diff --git a/requirements-dev.lock b/requirements-dev.lock
index 021bde5d..17486d77 100644
--- a/requirements-dev.lock
+++ b/requirements-dev.lock
@@ -51,6 +51,7 @@ mdurl==0.1.2
mypy==1.13.0
mypy-extensions==1.0.0
# via mypy
+nest-asyncio==1.6.0
nodeenv==1.8.0
# via pyright
nox==2023.4.22
diff --git a/src/asktable/_client.py b/src/asktable/_client.py
index 588c2f15..eacc45f5 100644
--- a/src/asktable/_client.py
+++ b/src/asktable/_client.py
@@ -46,6 +46,7 @@
class Asktable(SyncAPIClient):
+ sys: resources.SysResource
securetunnels: resources.SecuretunnelsResource
roles: resources.RolesResource
policies: resources.PoliciesResource
@@ -57,8 +58,7 @@ class Asktable(SyncAPIClient):
single_turn: resources.SingleTurnResource
caches: resources.CachesResource
integration: resources.IntegrationResource
- sys: resources.SysResource
- kb: resources.KBResource
+ business_glossary: resources.BusinessGlossaryResource
with_raw_response: AsktableWithRawResponse
with_streaming_response: AsktableWithStreamedResponse
@@ -103,7 +103,7 @@ def __init__(
if base_url is None:
base_url = os.environ.get("ASKTABLE_BASE_URL")
if base_url is None:
- base_url = f"/v1"
+ base_url = f"https://api.asktable.com/v1"
super().__init__(
version=__version__,
@@ -116,6 +116,7 @@ def __init__(
_strict_response_validation=_strict_response_validation,
)
+ self.sys = resources.SysResource(self)
self.securetunnels = resources.SecuretunnelsResource(self)
self.roles = resources.RolesResource(self)
self.policies = resources.PoliciesResource(self)
@@ -127,8 +128,7 @@ def __init__(
self.single_turn = resources.SingleTurnResource(self)
self.caches = resources.CachesResource(self)
self.integration = resources.IntegrationResource(self)
- self.sys = resources.SysResource(self)
- self.kb = resources.KBResource(self)
+ self.business_glossary = resources.BusinessGlossaryResource(self)
self.with_raw_response = AsktableWithRawResponse(self)
self.with_streaming_response = AsktableWithStreamedResponse(self)
@@ -238,6 +238,7 @@ def _make_status_error(
class AsyncAsktable(AsyncAPIClient):
+ sys: resources.AsyncSysResource
securetunnels: resources.AsyncSecuretunnelsResource
roles: resources.AsyncRolesResource
policies: resources.AsyncPoliciesResource
@@ -249,8 +250,7 @@ class AsyncAsktable(AsyncAPIClient):
single_turn: resources.AsyncSingleTurnResource
caches: resources.AsyncCachesResource
integration: resources.AsyncIntegrationResource
- sys: resources.AsyncSysResource
- kb: resources.AsyncKBResource
+ business_glossary: resources.AsyncBusinessGlossaryResource
with_raw_response: AsyncAsktableWithRawResponse
with_streaming_response: AsyncAsktableWithStreamedResponse
@@ -295,7 +295,7 @@ def __init__(
if base_url is None:
base_url = os.environ.get("ASKTABLE_BASE_URL")
if base_url is None:
- base_url = f"/v1"
+ base_url = f"https://api.asktable.com/v1"
super().__init__(
version=__version__,
@@ -308,6 +308,7 @@ def __init__(
_strict_response_validation=_strict_response_validation,
)
+ self.sys = resources.AsyncSysResource(self)
self.securetunnels = resources.AsyncSecuretunnelsResource(self)
self.roles = resources.AsyncRolesResource(self)
self.policies = resources.AsyncPoliciesResource(self)
@@ -319,8 +320,7 @@ def __init__(
self.single_turn = resources.AsyncSingleTurnResource(self)
self.caches = resources.AsyncCachesResource(self)
self.integration = resources.AsyncIntegrationResource(self)
- self.sys = resources.AsyncSysResource(self)
- self.kb = resources.AsyncKBResource(self)
+ self.business_glossary = resources.AsyncBusinessGlossaryResource(self)
self.with_raw_response = AsyncAsktableWithRawResponse(self)
self.with_streaming_response = AsyncAsktableWithStreamedResponse(self)
@@ -431,6 +431,7 @@ def _make_status_error(
class AsktableWithRawResponse:
def __init__(self, client: Asktable) -> None:
+ self.sys = resources.SysResourceWithRawResponse(client.sys)
self.securetunnels = resources.SecuretunnelsResourceWithRawResponse(client.securetunnels)
self.roles = resources.RolesResourceWithRawResponse(client.roles)
self.policies = resources.PoliciesResourceWithRawResponse(client.policies)
@@ -442,12 +443,12 @@ def __init__(self, client: Asktable) -> None:
self.single_turn = resources.SingleTurnResourceWithRawResponse(client.single_turn)
self.caches = resources.CachesResourceWithRawResponse(client.caches)
self.integration = resources.IntegrationResourceWithRawResponse(client.integration)
- self.sys = resources.SysResourceWithRawResponse(client.sys)
- self.kb = resources.KBResourceWithRawResponse(client.kb)
+ self.business_glossary = resources.BusinessGlossaryResourceWithRawResponse(client.business_glossary)
class AsyncAsktableWithRawResponse:
def __init__(self, client: AsyncAsktable) -> None:
+ self.sys = resources.AsyncSysResourceWithRawResponse(client.sys)
self.securetunnels = resources.AsyncSecuretunnelsResourceWithRawResponse(client.securetunnels)
self.roles = resources.AsyncRolesResourceWithRawResponse(client.roles)
self.policies = resources.AsyncPoliciesResourceWithRawResponse(client.policies)
@@ -459,12 +460,12 @@ def __init__(self, client: AsyncAsktable) -> None:
self.single_turn = resources.AsyncSingleTurnResourceWithRawResponse(client.single_turn)
self.caches = resources.AsyncCachesResourceWithRawResponse(client.caches)
self.integration = resources.AsyncIntegrationResourceWithRawResponse(client.integration)
- self.sys = resources.AsyncSysResourceWithRawResponse(client.sys)
- self.kb = resources.AsyncKBResourceWithRawResponse(client.kb)
+ self.business_glossary = resources.AsyncBusinessGlossaryResourceWithRawResponse(client.business_glossary)
class AsktableWithStreamedResponse:
def __init__(self, client: Asktable) -> None:
+ self.sys = resources.SysResourceWithStreamingResponse(client.sys)
self.securetunnels = resources.SecuretunnelsResourceWithStreamingResponse(client.securetunnels)
self.roles = resources.RolesResourceWithStreamingResponse(client.roles)
self.policies = resources.PoliciesResourceWithStreamingResponse(client.policies)
@@ -476,12 +477,12 @@ def __init__(self, client: Asktable) -> None:
self.single_turn = resources.SingleTurnResourceWithStreamingResponse(client.single_turn)
self.caches = resources.CachesResourceWithStreamingResponse(client.caches)
self.integration = resources.IntegrationResourceWithStreamingResponse(client.integration)
- self.sys = resources.SysResourceWithStreamingResponse(client.sys)
- self.kb = resources.KBResourceWithStreamingResponse(client.kb)
+ self.business_glossary = resources.BusinessGlossaryResourceWithStreamingResponse(client.business_glossary)
class AsyncAsktableWithStreamedResponse:
def __init__(self, client: AsyncAsktable) -> None:
+ self.sys = resources.AsyncSysResourceWithStreamingResponse(client.sys)
self.securetunnels = resources.AsyncSecuretunnelsResourceWithStreamingResponse(client.securetunnels)
self.roles = resources.AsyncRolesResourceWithStreamingResponse(client.roles)
self.policies = resources.AsyncPoliciesResourceWithStreamingResponse(client.policies)
@@ -493,8 +494,7 @@ def __init__(self, client: AsyncAsktable) -> None:
self.single_turn = resources.AsyncSingleTurnResourceWithStreamingResponse(client.single_turn)
self.caches = resources.AsyncCachesResourceWithStreamingResponse(client.caches)
self.integration = resources.AsyncIntegrationResourceWithStreamingResponse(client.integration)
- self.sys = resources.AsyncSysResourceWithStreamingResponse(client.sys)
- self.kb = resources.AsyncKBResourceWithStreamingResponse(client.kb)
+ self.business_glossary = resources.AsyncBusinessGlossaryResourceWithStreamingResponse(client.business_glossary)
Client = Asktable
diff --git a/src/asktable/_utils/_sync.py b/src/asktable/_utils/_sync.py
index d0d81033..8b3aaf2b 100644
--- a/src/asktable/_utils/_sync.py
+++ b/src/asktable/_utils/_sync.py
@@ -1,56 +1,62 @@
from __future__ import annotations
+import sys
+import asyncio
import functools
-from typing import TypeVar, Callable, Awaitable
+import contextvars
+from typing import Any, TypeVar, Callable, Awaitable
from typing_extensions import ParamSpec
-import anyio
-import anyio.to_thread
-
-from ._reflection import function_has_argument
-
T_Retval = TypeVar("T_Retval")
T_ParamSpec = ParamSpec("T_ParamSpec")
-# copied from `asyncer`, https://github.com/tiangolo/asyncer
-def asyncify(
- function: Callable[T_ParamSpec, T_Retval],
- *,
- cancellable: bool = False,
- limiter: anyio.CapacityLimiter | None = None,
-) -> Callable[T_ParamSpec, Awaitable[T_Retval]]:
+if sys.version_info >= (3, 9):
+ 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(
+ func: Callable[T_ParamSpec, T_Retval], /, *args: T_ParamSpec.args, **kwargs: T_ParamSpec.kwargs
+ ) -> Any:
+ """Asynchronously run function *func* in a separate thread.
+
+ Any *args and **kwargs supplied for this function are directly passed
+ to *func*. Also, the current :class:`contextvars.Context` is propagated,
+ allowing context variables from the main thread to be accessed in the
+ separate thread.
+
+ Returns a coroutine that can be awaited to get the eventual result of *func*.
+ """
+ loop = asyncio.events.get_running_loop()
+ ctx = contextvars.copy_context()
+ func_call = functools.partial(ctx.run, func, *args, **kwargs)
+ return await loop.run_in_executor(None, func_call)
+
+
+# inspired by `asyncer`, https://github.com/tiangolo/asyncer
+def asyncify(function: Callable[T_ParamSpec, T_Retval]) -> Callable[T_ParamSpec, Awaitable[T_Retval]]:
"""
Take a blocking function and create an async one that receives the same
- positional and keyword arguments, and that when called, calls the original function
- in a worker thread using `anyio.to_thread.run_sync()`. Internally,
- `asyncer.asyncify()` uses the same `anyio.to_thread.run_sync()`, but it supports
- keyword arguments additional to positional arguments and it adds better support for
- autocompletion and inline errors for the arguments of the function called and the
- return value.
-
- If the `cancellable` option is enabled and the task waiting for its completion is
- cancelled, the thread will still run its course but its return value (or any raised
- exception) will be ignored.
+ positional and keyword arguments. For python version 3.9 and above, it uses
+ asyncio.to_thread to run the function in a separate thread. For python version
+ 3.8, it uses locally defined copy of the asyncio.to_thread function which was
+ introduced in python 3.9.
- Use it like this:
+ Usage:
- ```Python
- def do_work(arg1, arg2, kwarg1="", kwarg2="") -> str:
- # Do work
- return "Some result"
+ ```python
+ def blocking_func(arg1, arg2, kwarg1=None):
+ # blocking code
+ return result
- result = await to_thread.asyncify(do_work)("spam", "ham", kwarg1="a", kwarg2="b")
- print(result)
+ result = asyncify(blocking_function)(arg1, arg2, kwarg1=value1)
```
## Arguments
`function`: a blocking regular callable (e.g. a function)
- `cancellable`: `True` to allow cancellation of the operation
- `limiter`: capacity limiter to use to limit the total amount of threads running
- (if omitted, the default limiter is used)
## Return
@@ -60,22 +66,6 @@ def do_work(arg1, arg2, kwarg1="", kwarg2="") -> str:
"""
async def wrapper(*args: T_ParamSpec.args, **kwargs: T_ParamSpec.kwargs) -> T_Retval:
- partial_f = functools.partial(function, *args, **kwargs)
-
- # In `v4.1.0` anyio added the `abandon_on_cancel` argument and deprecated the old
- # `cancellable` argument, so we need to use the new `abandon_on_cancel` to avoid
- # surfacing deprecation warnings.
- if function_has_argument(anyio.to_thread.run_sync, "abandon_on_cancel"):
- return await anyio.to_thread.run_sync(
- partial_f,
- abandon_on_cancel=cancellable,
- limiter=limiter,
- )
-
- return await anyio.to_thread.run_sync(
- partial_f,
- cancellable=cancellable,
- limiter=limiter,
- )
+ return await to_thread(function, *args, **kwargs)
return wrapper
diff --git a/src/asktable/_version.py b/src/asktable/_version.py
index 58572c95..7d946cc1 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__ = "3.2.0" # x-release-please-version
+__version__ = "3.3.0" # x-release-please-version
diff --git a/src/asktable/pagination.py b/src/asktable/pagination.py
new file mode 100644
index 00000000..8e487278
--- /dev/null
+++ b/src/asktable/pagination.py
@@ -0,0 +1,64 @@
+# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+from typing import List, Generic, TypeVar, Optional, cast
+from typing_extensions import override
+
+from ._base_client import BasePage, PageInfo, BaseSyncPage, BaseAsyncPage
+
+__all__ = ["SyncPage", "AsyncPage"]
+
+_T = TypeVar("_T")
+
+
+class SyncPage(BaseSyncPage[_T], BasePage[_T], Generic[_T]):
+ items: List[_T]
+ page: Optional[int] = None
+ size: Optional[int] = None
+ pages: Optional[int] = None
+
+ @override
+ def _get_page_items(self) -> List[_T]:
+ items = self.items
+ if not items:
+ return []
+ return items
+
+ @override
+ def next_page_info(self) -> Optional[PageInfo]:
+ current_page = self.page
+ if current_page is None:
+ current_page = 1
+
+ last_page = cast("int | None", self._options.params.get("page"))
+ if last_page is not None and current_page <= last_page:
+ # The API didn't return a new page in the last request
+ return None
+
+ return PageInfo(params={"page": current_page + 1})
+
+
+class AsyncPage(BaseAsyncPage[_T], BasePage[_T], Generic[_T]):
+ items: List[_T]
+ page: Optional[int] = None
+ size: Optional[int] = None
+ pages: Optional[int] = None
+
+ @override
+ def _get_page_items(self) -> List[_T]:
+ items = self.items
+ if not items:
+ return []
+ return items
+
+ @override
+ def next_page_info(self) -> Optional[PageInfo]:
+ current_page = self.page
+ if current_page is None:
+ current_page = 1
+
+ last_page = cast("int | None", self._options.params.get("page"))
+ if last_page is not None and current_page <= last_page:
+ # The API didn't return a new page in the last request
+ return None
+
+ return PageInfo(params={"page": current_page + 1})
diff --git a/src/asktable/resources/__init__.py b/src/asktable/resources/__init__.py
index 20e2f664..79901b9f 100644
--- a/src/asktable/resources/__init__.py
+++ b/src/asktable/resources/__init__.py
@@ -1,13 +1,5 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-from .kb import (
- KBResource,
- AsyncKBResource,
- KBResourceWithRawResponse,
- AsyncKBResourceWithRawResponse,
- KBResourceWithStreamingResponse,
- AsyncKBResourceWithStreamingResponse,
-)
from .sys import (
SysResource,
AsyncSysResource,
@@ -104,8 +96,22 @@
SecuretunnelsResourceWithStreamingResponse,
AsyncSecuretunnelsResourceWithStreamingResponse,
)
+from .business_glossary import (
+ BusinessGlossaryResource,
+ AsyncBusinessGlossaryResource,
+ BusinessGlossaryResourceWithRawResponse,
+ AsyncBusinessGlossaryResourceWithRawResponse,
+ BusinessGlossaryResourceWithStreamingResponse,
+ AsyncBusinessGlossaryResourceWithStreamingResponse,
+)
__all__ = [
+ "SysResource",
+ "AsyncSysResource",
+ "SysResourceWithRawResponse",
+ "AsyncSysResourceWithRawResponse",
+ "SysResourceWithStreamingResponse",
+ "AsyncSysResourceWithStreamingResponse",
"SecuretunnelsResource",
"AsyncSecuretunnelsResource",
"SecuretunnelsResourceWithRawResponse",
@@ -172,16 +178,10 @@
"AsyncIntegrationResourceWithRawResponse",
"IntegrationResourceWithStreamingResponse",
"AsyncIntegrationResourceWithStreamingResponse",
- "SysResource",
- "AsyncSysResource",
- "SysResourceWithRawResponse",
- "AsyncSysResourceWithRawResponse",
- "SysResourceWithStreamingResponse",
- "AsyncSysResourceWithStreamingResponse",
- "KBResource",
- "AsyncKBResource",
- "KBResourceWithRawResponse",
- "AsyncKBResourceWithRawResponse",
- "KBResourceWithStreamingResponse",
- "AsyncKBResourceWithStreamingResponse",
+ "BusinessGlossaryResource",
+ "AsyncBusinessGlossaryResource",
+ "BusinessGlossaryResourceWithRawResponse",
+ "AsyncBusinessGlossaryResourceWithRawResponse",
+ "BusinessGlossaryResourceWithStreamingResponse",
+ "AsyncBusinessGlossaryResourceWithStreamingResponse",
]
diff --git a/src/asktable/resources/auth/tokens.py b/src/asktable/resources/auth.py
similarity index 55%
rename from src/asktable/resources/auth/tokens.py
rename to src/asktable/resources/auth.py
index 7ac8c64b..7fdb442c 100644
--- a/src/asktable/resources/auth/tokens.py
+++ b/src/asktable/resources/auth.py
@@ -7,50 +7,50 @@
import httpx
-from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven
-from ..._utils import (
+from ..types import auth_create_token_params
+from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven
+from .._utils import (
maybe_transform,
async_maybe_transform,
)
-from ..._compat import cached_property
-from ..._resource import SyncAPIResource, AsyncAPIResource
-from ..._response import (
+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 ...types.auth import token_create_params
-from ..._base_client import make_request_options
+from .._base_client import make_request_options
-__all__ = ["TokensResource", "AsyncTokensResource"]
+__all__ = ["AuthResource", "AsyncAuthResource"]
-class TokensResource(SyncAPIResource):
+class AuthResource(SyncAPIResource):
@cached_property
- def with_raw_response(self) -> TokensResourceWithRawResponse:
+ def with_raw_response(self) -> AuthResourceWithRawResponse:
"""
This property can be used as a prefix for any HTTP method call to return the
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 TokensResourceWithRawResponse(self)
+ return AuthResourceWithRawResponse(self)
@cached_property
- def with_streaming_response(self) -> TokensResourceWithStreamingResponse:
+ def with_streaming_response(self) -> AuthResourceWithStreamingResponse:
"""
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 TokensResourceWithStreamingResponse(self)
+ return AuthResourceWithStreamingResponse(self)
- def create(
+ def create_token(
self,
*,
ak_role: Literal["sys", "admin", "asker", "visitor"] | NotGiven = NOT_GIVEN,
- chat_role: Optional[token_create_params.ChatRole] | NotGiven = NOT_GIVEN,
+ chat_role: Optional[auth_create_token_params.ChatRole] | NotGiven = NOT_GIVEN,
token_ttl: int | NotGiven = NOT_GIVEN,
user_profile: Optional[object] | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
@@ -89,7 +89,7 @@ def create(
"token_ttl": token_ttl,
"user_profile": user_profile,
},
- token_create_params.TokenCreateParams,
+ auth_create_token_params.AuthCreateTokenParams,
),
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
@@ -97,32 +97,51 @@ def create(
cast_to=object,
)
+ def me(
+ self,
+ *,
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
+ # The extra values given here take precedence over values defined on the client or passed to this method.
+ extra_headers: Headers | None = None,
+ extra_query: Query | None = None,
+ extra_body: Body | None = None,
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
+ ) -> object:
+ """获取当前登录的 TokenID"""
+ return self._get(
+ "/auth/me",
+ options=make_request_options(
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
+ ),
+ cast_to=object,
+ )
+
-class AsyncTokensResource(AsyncAPIResource):
+class AsyncAuthResource(AsyncAPIResource):
@cached_property
- def with_raw_response(self) -> AsyncTokensResourceWithRawResponse:
+ def with_raw_response(self) -> AsyncAuthResourceWithRawResponse:
"""
This property can be used as a prefix for any HTTP method call to return the
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 AsyncTokensResourceWithRawResponse(self)
+ return AsyncAuthResourceWithRawResponse(self)
@cached_property
- def with_streaming_response(self) -> AsyncTokensResourceWithStreamingResponse:
+ def with_streaming_response(self) -> AsyncAuthResourceWithStreamingResponse:
"""
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 AsyncTokensResourceWithStreamingResponse(self)
+ return AsyncAuthResourceWithStreamingResponse(self)
- async def create(
+ async def create_token(
self,
*,
ak_role: Literal["sys", "admin", "asker", "visitor"] | NotGiven = NOT_GIVEN,
- chat_role: Optional[token_create_params.ChatRole] | NotGiven = NOT_GIVEN,
+ chat_role: Optional[auth_create_token_params.ChatRole] | NotGiven = NOT_GIVEN,
token_ttl: int | NotGiven = NOT_GIVEN,
user_profile: Optional[object] | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
@@ -161,8 +180,27 @@ async def create(
"token_ttl": token_ttl,
"user_profile": user_profile,
},
- token_create_params.TokenCreateParams,
+ auth_create_token_params.AuthCreateTokenParams,
+ ),
+ options=make_request_options(
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
+ cast_to=object,
+ )
+
+ async def me(
+ self,
+ *,
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
+ # The extra values given here take precedence over values defined on the client or passed to this method.
+ extra_headers: Headers | None = None,
+ extra_query: Query | None = None,
+ extra_body: Body | None = None,
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
+ ) -> object:
+ """获取当前登录的 TokenID"""
+ return await self._get(
+ "/auth/me",
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
@@ -170,37 +208,49 @@ async def create(
)
-class TokensResourceWithRawResponse:
- def __init__(self, tokens: TokensResource) -> None:
- self._tokens = tokens
+class AuthResourceWithRawResponse:
+ def __init__(self, auth: AuthResource) -> None:
+ self._auth = auth
- self.create = to_raw_response_wrapper(
- tokens.create,
+ self.create_token = to_raw_response_wrapper(
+ auth.create_token,
+ )
+ self.me = to_raw_response_wrapper(
+ auth.me,
)
-class AsyncTokensResourceWithRawResponse:
- def __init__(self, tokens: AsyncTokensResource) -> None:
- self._tokens = tokens
+class AsyncAuthResourceWithRawResponse:
+ def __init__(self, auth: AsyncAuthResource) -> None:
+ self._auth = auth
- self.create = async_to_raw_response_wrapper(
- tokens.create,
+ self.create_token = async_to_raw_response_wrapper(
+ auth.create_token,
+ )
+ self.me = async_to_raw_response_wrapper(
+ auth.me,
)
-class TokensResourceWithStreamingResponse:
- def __init__(self, tokens: TokensResource) -> None:
- self._tokens = tokens
+class AuthResourceWithStreamingResponse:
+ def __init__(self, auth: AuthResource) -> None:
+ self._auth = auth
- self.create = to_streamed_response_wrapper(
- tokens.create,
+ self.create_token = to_streamed_response_wrapper(
+ auth.create_token,
+ )
+ self.me = to_streamed_response_wrapper(
+ auth.me,
)
-class AsyncTokensResourceWithStreamingResponse:
- def __init__(self, tokens: AsyncTokensResource) -> None:
- self._tokens = tokens
+class AsyncAuthResourceWithStreamingResponse:
+ def __init__(self, auth: AsyncAuthResource) -> None:
+ self._auth = auth
- self.create = async_to_streamed_response_wrapper(
- tokens.create,
+ self.create_token = async_to_streamed_response_wrapper(
+ auth.create_token,
+ )
+ self.me = async_to_streamed_response_wrapper(
+ auth.me,
)
diff --git a/src/asktable/resources/auth/__init__.py b/src/asktable/resources/auth/__init__.py
deleted file mode 100644
index b7d7318b..00000000
--- a/src/asktable/resources/auth/__init__.py
+++ /dev/null
@@ -1,47 +0,0 @@
-# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-
-from .me import (
- MeResource,
- AsyncMeResource,
- MeResourceWithRawResponse,
- AsyncMeResourceWithRawResponse,
- MeResourceWithStreamingResponse,
- AsyncMeResourceWithStreamingResponse,
-)
-from .auth import (
- AuthResource,
- AsyncAuthResource,
- AuthResourceWithRawResponse,
- AsyncAuthResourceWithRawResponse,
- AuthResourceWithStreamingResponse,
- AsyncAuthResourceWithStreamingResponse,
-)
-from .tokens import (
- TokensResource,
- AsyncTokensResource,
- TokensResourceWithRawResponse,
- AsyncTokensResourceWithRawResponse,
- TokensResourceWithStreamingResponse,
- AsyncTokensResourceWithStreamingResponse,
-)
-
-__all__ = [
- "TokensResource",
- "AsyncTokensResource",
- "TokensResourceWithRawResponse",
- "AsyncTokensResourceWithRawResponse",
- "TokensResourceWithStreamingResponse",
- "AsyncTokensResourceWithStreamingResponse",
- "MeResource",
- "AsyncMeResource",
- "MeResourceWithRawResponse",
- "AsyncMeResourceWithRawResponse",
- "MeResourceWithStreamingResponse",
- "AsyncMeResourceWithStreamingResponse",
- "AuthResource",
- "AsyncAuthResource",
- "AuthResourceWithRawResponse",
- "AsyncAuthResourceWithRawResponse",
- "AuthResourceWithStreamingResponse",
- "AsyncAuthResourceWithStreamingResponse",
-]
diff --git a/src/asktable/resources/auth/auth.py b/src/asktable/resources/auth/auth.py
deleted file mode 100644
index b8ec4b4c..00000000
--- a/src/asktable/resources/auth/auth.py
+++ /dev/null
@@ -1,134 +0,0 @@
-# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-
-from __future__ import annotations
-
-from .me import (
- MeResource,
- AsyncMeResource,
- MeResourceWithRawResponse,
- AsyncMeResourceWithRawResponse,
- MeResourceWithStreamingResponse,
- AsyncMeResourceWithStreamingResponse,
-)
-from .tokens import (
- TokensResource,
- AsyncTokensResource,
- TokensResourceWithRawResponse,
- AsyncTokensResourceWithRawResponse,
- TokensResourceWithStreamingResponse,
- AsyncTokensResourceWithStreamingResponse,
-)
-from ..._compat import cached_property
-from ..._resource import SyncAPIResource, AsyncAPIResource
-
-__all__ = ["AuthResource", "AsyncAuthResource"]
-
-
-class AuthResource(SyncAPIResource):
- @cached_property
- def tokens(self) -> TokensResource:
- return TokensResource(self._client)
-
- @cached_property
- def me(self) -> MeResource:
- return MeResource(self._client)
-
- @cached_property
- def with_raw_response(self) -> AuthResourceWithRawResponse:
- """
- This property can be used as a prefix for any HTTP method call to return the
- 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 AuthResourceWithRawResponse(self)
-
- @cached_property
- def with_streaming_response(self) -> AuthResourceWithStreamingResponse:
- """
- 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 AuthResourceWithStreamingResponse(self)
-
-
-class AsyncAuthResource(AsyncAPIResource):
- @cached_property
- def tokens(self) -> AsyncTokensResource:
- return AsyncTokensResource(self._client)
-
- @cached_property
- def me(self) -> AsyncMeResource:
- return AsyncMeResource(self._client)
-
- @cached_property
- def with_raw_response(self) -> AsyncAuthResourceWithRawResponse:
- """
- This property can be used as a prefix for any HTTP method call to return the
- 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 AsyncAuthResourceWithRawResponse(self)
-
- @cached_property
- def with_streaming_response(self) -> AsyncAuthResourceWithStreamingResponse:
- """
- 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 AsyncAuthResourceWithStreamingResponse(self)
-
-
-class AuthResourceWithRawResponse:
- def __init__(self, auth: AuthResource) -> None:
- self._auth = auth
-
- @cached_property
- def tokens(self) -> TokensResourceWithRawResponse:
- return TokensResourceWithRawResponse(self._auth.tokens)
-
- @cached_property
- def me(self) -> MeResourceWithRawResponse:
- return MeResourceWithRawResponse(self._auth.me)
-
-
-class AsyncAuthResourceWithRawResponse:
- def __init__(self, auth: AsyncAuthResource) -> None:
- self._auth = auth
-
- @cached_property
- def tokens(self) -> AsyncTokensResourceWithRawResponse:
- return AsyncTokensResourceWithRawResponse(self._auth.tokens)
-
- @cached_property
- def me(self) -> AsyncMeResourceWithRawResponse:
- return AsyncMeResourceWithRawResponse(self._auth.me)
-
-
-class AuthResourceWithStreamingResponse:
- def __init__(self, auth: AuthResource) -> None:
- self._auth = auth
-
- @cached_property
- def tokens(self) -> TokensResourceWithStreamingResponse:
- return TokensResourceWithStreamingResponse(self._auth.tokens)
-
- @cached_property
- def me(self) -> MeResourceWithStreamingResponse:
- return MeResourceWithStreamingResponse(self._auth.me)
-
-
-class AsyncAuthResourceWithStreamingResponse:
- def __init__(self, auth: AsyncAuthResource) -> None:
- self._auth = auth
-
- @cached_property
- def tokens(self) -> AsyncTokensResourceWithStreamingResponse:
- return AsyncTokensResourceWithStreamingResponse(self._auth.tokens)
-
- @cached_property
- def me(self) -> AsyncMeResourceWithStreamingResponse:
- return AsyncMeResourceWithStreamingResponse(self._auth.me)
diff --git a/src/asktable/resources/auth/me.py b/src/asktable/resources/auth/me.py
deleted file mode 100644
index 9ee4954a..00000000
--- a/src/asktable/resources/auth/me.py
+++ /dev/null
@@ -1,134 +0,0 @@
-# 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__ = ["MeResource", "AsyncMeResource"]
-
-
-class MeResource(SyncAPIResource):
- @cached_property
- def with_raw_response(self) -> MeResourceWithRawResponse:
- """
- This property can be used as a prefix for any HTTP method call to return the
- 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 MeResourceWithRawResponse(self)
-
- @cached_property
- def with_streaming_response(self) -> MeResourceWithStreamingResponse:
- """
- 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 MeResourceWithStreamingResponse(self)
-
- def retrieve(
- self,
- *,
- # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
- # The extra values given here take precedence over values defined on the client or passed to this method.
- extra_headers: Headers | None = None,
- extra_query: Query | None = None,
- extra_body: Body | None = None,
- timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> object:
- """获取当前登录的 TokenID"""
- return self._get(
- "/auth/me",
- options=make_request_options(
- extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
- ),
- cast_to=object,
- )
-
-
-class AsyncMeResource(AsyncAPIResource):
- @cached_property
- def with_raw_response(self) -> AsyncMeResourceWithRawResponse:
- """
- This property can be used as a prefix for any HTTP method call to return the
- 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 AsyncMeResourceWithRawResponse(self)
-
- @cached_property
- def with_streaming_response(self) -> AsyncMeResourceWithStreamingResponse:
- """
- 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 AsyncMeResourceWithStreamingResponse(self)
-
- async def retrieve(
- self,
- *,
- # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
- # The extra values given here take precedence over values defined on the client or passed to this method.
- extra_headers: Headers | None = None,
- extra_query: Query | None = None,
- extra_body: Body | None = None,
- timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> object:
- """获取当前登录的 TokenID"""
- return await self._get(
- "/auth/me",
- options=make_request_options(
- extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
- ),
- cast_to=object,
- )
-
-
-class MeResourceWithRawResponse:
- def __init__(self, me: MeResource) -> None:
- self._me = me
-
- self.retrieve = to_raw_response_wrapper(
- me.retrieve,
- )
-
-
-class AsyncMeResourceWithRawResponse:
- def __init__(self, me: AsyncMeResource) -> None:
- self._me = me
-
- self.retrieve = async_to_raw_response_wrapper(
- me.retrieve,
- )
-
-
-class MeResourceWithStreamingResponse:
- def __init__(self, me: MeResource) -> None:
- self._me = me
-
- self.retrieve = to_streamed_response_wrapper(
- me.retrieve,
- )
-
-
-class AsyncMeResourceWithStreamingResponse:
- def __init__(self, me: AsyncMeResource) -> None:
- self._me = me
-
- self.retrieve = async_to_streamed_response_wrapper(
- me.retrieve,
- )
diff --git a/src/asktable/resources/bots.py b/src/asktable/resources/bots.py
index d8cb4108..3195172f 100644
--- a/src/asktable/resources/bots.py
+++ b/src/asktable/resources/bots.py
@@ -20,9 +20,9 @@
async_to_raw_response_wrapper,
async_to_streamed_response_wrapper,
)
-from .._base_client import make_request_options
-from ..types.chat_bot import ChatBot
-from ..types.bot_list_response import BotListResponse
+from ..pagination import SyncPage, AsyncPage
+from .._base_client import AsyncPaginator, make_request_options
+from ..types.chatbot import Chatbot
__all__ = ["BotsResource", "AsyncBotsResource"]
@@ -66,7 +66,7 @@ def create(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> ChatBot:
+ ) -> Chatbot:
"""
创建一个新的 Bot
@@ -119,7 +119,7 @@ def create(
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
- cast_to=ChatBot,
+ cast_to=Chatbot,
)
def retrieve(
@@ -132,7 +132,7 @@ def retrieve(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> ChatBot:
+ ) -> Chatbot:
"""
获取某个 Bot
@@ -152,7 +152,7 @@ def retrieve(
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
- cast_to=ChatBot,
+ cast_to=Chatbot,
)
def update(
@@ -176,7 +176,7 @@ def update(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> ChatBot:
+ ) -> Chatbot:
"""
更新某个 Bot
@@ -234,7 +234,7 @@ def update(
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
- cast_to=ChatBot,
+ cast_to=Chatbot,
)
def list(
@@ -249,7 +249,7 @@ def list(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> BotListResponse:
+ ) -> SyncPage[Chatbot]:
"""
查询所有 Bot
@@ -268,8 +268,9 @@ def list(
timeout: Override the client-level default timeout for this request, in seconds
"""
- return self._get(
+ return self._get_api_list(
"/bots",
+ page=SyncPage[Chatbot],
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
@@ -284,7 +285,7 @@ def list(
bot_list_params.BotListParams,
),
),
- cast_to=BotListResponse,
+ model=Chatbot,
)
def delete(
@@ -398,7 +399,7 @@ async def create(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> ChatBot:
+ ) -> Chatbot:
"""
创建一个新的 Bot
@@ -451,7 +452,7 @@ async def create(
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
- cast_to=ChatBot,
+ cast_to=Chatbot,
)
async def retrieve(
@@ -464,7 +465,7 @@ async def retrieve(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> ChatBot:
+ ) -> Chatbot:
"""
获取某个 Bot
@@ -484,7 +485,7 @@ async def retrieve(
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
- cast_to=ChatBot,
+ cast_to=Chatbot,
)
async def update(
@@ -508,7 +509,7 @@ async def update(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> ChatBot:
+ ) -> Chatbot:
"""
更新某个 Bot
@@ -566,10 +567,10 @@ async def update(
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
- cast_to=ChatBot,
+ cast_to=Chatbot,
)
- async def list(
+ def list(
self,
*,
name: Optional[str] | NotGiven = NOT_GIVEN,
@@ -581,7 +582,7 @@ async def list(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> BotListResponse:
+ ) -> AsyncPaginator[Chatbot, AsyncPage[Chatbot]]:
"""
查询所有 Bot
@@ -600,14 +601,15 @@ async def list(
timeout: Override the client-level default timeout for this request, in seconds
"""
- return await self._get(
+ return self._get_api_list(
"/bots",
+ page=AsyncPage[Chatbot],
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
- query=await async_maybe_transform(
+ query=maybe_transform(
{
"name": name,
"page": page,
@@ -616,7 +618,7 @@ async def list(
bot_list_params.BotListParams,
),
),
- cast_to=BotListResponse,
+ model=Chatbot,
)
async def delete(
diff --git a/src/asktable/resources/business_glossary.py b/src/asktable/resources/business_glossary.py
new file mode 100644
index 00000000..fff84880
--- /dev/null
+++ b/src/asktable/resources/business_glossary.py
@@ -0,0 +1,565 @@
+# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+from __future__ import annotations
+
+from typing import List, Iterable, Optional
+
+import httpx
+
+from ..types import (
+ business_glossary_list_params,
+ business_glossary_create_params,
+ business_glossary_update_params,
+)
+from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven
+from .._utils import (
+ maybe_transform,
+ async_maybe_transform,
+)
+from .._compat import cached_property
+from .._resource import SyncAPIResource, AsyncAPIResource
+from .._response import (
+ to_raw_response_wrapper,
+ to_streamed_response_wrapper,
+ async_to_raw_response_wrapper,
+ async_to_streamed_response_wrapper,
+)
+from ..pagination import SyncPage, AsyncPage
+from ..types.entry import Entry
+from .._base_client import AsyncPaginator, make_request_options
+from ..types.entry_with_definition import EntryWithDefinition
+from ..types.business_glossary_create_response import BusinessGlossaryCreateResponse
+
+__all__ = ["BusinessGlossaryResource", "AsyncBusinessGlossaryResource"]
+
+
+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
+ 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 BusinessGlossaryResourceWithRawResponse(self)
+
+ @cached_property
+ def with_streaming_response(self) -> BusinessGlossaryResourceWithStreamingResponse:
+ """
+ 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 BusinessGlossaryResourceWithStreamingResponse(self)
+
+ def create(
+ self,
+ *,
+ body: Iterable[business_glossary_create_params.Body],
+ # 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,
+ ) -> BusinessGlossaryCreateResponse:
+ """
+ 创建业务术语
+
+ Args:
+ extra_headers: Send extra headers
+
+ extra_query: Add additional query parameters to the request
+
+ extra_body: Add additional JSON properties to the request
+
+ timeout: Override the client-level default timeout for this request, in seconds
+ """
+ return self._post(
+ "/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
+ ),
+ cast_to=BusinessGlossaryCreateResponse,
+ )
+
+ def retrieve(
+ self,
+ entry_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,
+ ) -> EntryWithDefinition:
+ """
+ 获取某个业务术语
+
+ 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 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}",
+ options=make_request_options(
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
+ ),
+ cast_to=EntryWithDefinition,
+ )
+
+ def update(
+ self,
+ entry_id: str,
+ *,
+ aliases: Optional[List[str]] | NotGiven = NOT_GIVEN,
+ definition: Optional[str] | NotGiven = NOT_GIVEN,
+ payload: Optional[object] | NotGiven = NOT_GIVEN,
+ term: 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.
+ extra_headers: Headers | None = None,
+ extra_query: Query | None = None,
+ extra_body: Body | None = None,
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
+ ) -> Entry:
+ """
+ 更新业务术语
+
+ Args:
+ aliases: 业务术语同义词
+
+ definition: 业务术语定义
+
+ payload: 业务术语元数据
+
+ term: 业务术语
+
+ 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 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}",
+ body=maybe_transform(
+ {
+ "aliases": aliases,
+ "definition": definition,
+ "payload": payload,
+ "term": term,
+ },
+ business_glossary_update_params.BusinessGlossaryUpdateParams,
+ ),
+ options=make_request_options(
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
+ ),
+ cast_to=Entry,
+ )
+
+ def list(
+ self,
+ *,
+ page: int | NotGiven = NOT_GIVEN,
+ size: int | NotGiven = NOT_GIVEN,
+ term: 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,
+ extra_query: Query | None = None,
+ extra_body: Body | None = None,
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
+ ) -> SyncPage[Entry]:
+ """
+ 查询所有业务术语
+
+ Args:
+ page: Page number
+
+ size: Page size
+
+ term: 术语名称
+
+ extra_headers: Send extra headers
+
+ extra_query: Add additional query parameters to the request
+
+ extra_body: Add additional JSON properties to the request
+
+ timeout: Override the client-level default timeout for this request, in seconds
+ """
+ return self._get_api_list(
+ "/business-glossary",
+ page=SyncPage[Entry],
+ options=make_request_options(
+ extra_headers=extra_headers,
+ extra_query=extra_query,
+ extra_body=extra_body,
+ timeout=timeout,
+ query=maybe_transform(
+ {
+ "page": page,
+ "size": size,
+ "term": term,
+ },
+ business_glossary_list_params.BusinessGlossaryListParams,
+ ),
+ ),
+ model=Entry,
+ )
+
+ def delete(
+ self,
+ entry_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 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}",
+ options=make_request_options(
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
+ ),
+ cast_to=object,
+ )
+
+
+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
+ 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 AsyncBusinessGlossaryResourceWithRawResponse(self)
+
+ @cached_property
+ def with_streaming_response(self) -> AsyncBusinessGlossaryResourceWithStreamingResponse:
+ """
+ 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 AsyncBusinessGlossaryResourceWithStreamingResponse(self)
+
+ async def create(
+ self,
+ *,
+ body: Iterable[business_glossary_create_params.Body],
+ # 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,
+ ) -> BusinessGlossaryCreateResponse:
+ """
+ 创建业务术语
+
+ Args:
+ extra_headers: Send extra headers
+
+ extra_query: Add additional query parameters to the request
+
+ extra_body: Add additional JSON properties to the request
+
+ timeout: Override the client-level default timeout for this request, in seconds
+ """
+ return await self._post(
+ "/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
+ ),
+ cast_to=BusinessGlossaryCreateResponse,
+ )
+
+ async def retrieve(
+ self,
+ entry_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,
+ ) -> EntryWithDefinition:
+ """
+ 获取某个业务术语
+
+ 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 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}",
+ options=make_request_options(
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
+ ),
+ cast_to=EntryWithDefinition,
+ )
+
+ async def update(
+ self,
+ entry_id: str,
+ *,
+ aliases: Optional[List[str]] | NotGiven = NOT_GIVEN,
+ definition: Optional[str] | NotGiven = NOT_GIVEN,
+ payload: Optional[object] | NotGiven = NOT_GIVEN,
+ term: 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.
+ extra_headers: Headers | None = None,
+ extra_query: Query | None = None,
+ extra_body: Body | None = None,
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
+ ) -> Entry:
+ """
+ 更新业务术语
+
+ Args:
+ aliases: 业务术语同义词
+
+ definition: 业务术语定义
+
+ payload: 业务术语元数据
+
+ term: 业务术语
+
+ 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 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}",
+ body=await async_maybe_transform(
+ {
+ "aliases": aliases,
+ "definition": definition,
+ "payload": payload,
+ "term": term,
+ },
+ business_glossary_update_params.BusinessGlossaryUpdateParams,
+ ),
+ options=make_request_options(
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
+ ),
+ cast_to=Entry,
+ )
+
+ def list(
+ self,
+ *,
+ page: int | NotGiven = NOT_GIVEN,
+ size: int | NotGiven = NOT_GIVEN,
+ term: 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,
+ extra_query: Query | None = None,
+ extra_body: Body | None = None,
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
+ ) -> AsyncPaginator[Entry, AsyncPage[Entry]]:
+ """
+ 查询所有业务术语
+
+ Args:
+ page: Page number
+
+ size: Page size
+
+ term: 术语名称
+
+ extra_headers: Send extra headers
+
+ extra_query: Add additional query parameters to the request
+
+ extra_body: Add additional JSON properties to the request
+
+ timeout: Override the client-level default timeout for this request, in seconds
+ """
+ return self._get_api_list(
+ "/business-glossary",
+ page=AsyncPage[Entry],
+ options=make_request_options(
+ extra_headers=extra_headers,
+ extra_query=extra_query,
+ extra_body=extra_body,
+ timeout=timeout,
+ query=maybe_transform(
+ {
+ "page": page,
+ "size": size,
+ "term": term,
+ },
+ business_glossary_list_params.BusinessGlossaryListParams,
+ ),
+ ),
+ model=Entry,
+ )
+
+ async def delete(
+ self,
+ entry_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 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}",
+ options=make_request_options(
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
+ ),
+ cast_to=object,
+ )
+
+
+class BusinessGlossaryResourceWithRawResponse:
+ def __init__(self, business_glossary: BusinessGlossaryResource) -> None:
+ self._business_glossary = business_glossary
+
+ self.create = to_raw_response_wrapper(
+ business_glossary.create,
+ )
+ self.retrieve = to_raw_response_wrapper(
+ business_glossary.retrieve,
+ )
+ self.update = to_raw_response_wrapper(
+ business_glossary.update,
+ )
+ self.list = to_raw_response_wrapper(
+ business_glossary.list,
+ )
+ self.delete = to_raw_response_wrapper(
+ business_glossary.delete,
+ )
+
+
+class AsyncBusinessGlossaryResourceWithRawResponse:
+ def __init__(self, business_glossary: AsyncBusinessGlossaryResource) -> None:
+ self._business_glossary = business_glossary
+
+ self.create = async_to_raw_response_wrapper(
+ business_glossary.create,
+ )
+ self.retrieve = async_to_raw_response_wrapper(
+ business_glossary.retrieve,
+ )
+ self.update = async_to_raw_response_wrapper(
+ business_glossary.update,
+ )
+ self.list = async_to_raw_response_wrapper(
+ business_glossary.list,
+ )
+ self.delete = async_to_raw_response_wrapper(
+ business_glossary.delete,
+ )
+
+
+class BusinessGlossaryResourceWithStreamingResponse:
+ def __init__(self, business_glossary: BusinessGlossaryResource) -> None:
+ self._business_glossary = business_glossary
+
+ self.create = to_streamed_response_wrapper(
+ business_glossary.create,
+ )
+ self.retrieve = to_streamed_response_wrapper(
+ business_glossary.retrieve,
+ )
+ self.update = to_streamed_response_wrapper(
+ business_glossary.update,
+ )
+ self.list = to_streamed_response_wrapper(
+ business_glossary.list,
+ )
+ self.delete = to_streamed_response_wrapper(
+ business_glossary.delete,
+ )
+
+
+class AsyncBusinessGlossaryResourceWithStreamingResponse:
+ def __init__(self, business_glossary: AsyncBusinessGlossaryResource) -> None:
+ self._business_glossary = business_glossary
+
+ self.create = async_to_streamed_response_wrapper(
+ business_glossary.create,
+ )
+ self.retrieve = async_to_streamed_response_wrapper(
+ business_glossary.retrieve,
+ )
+ self.update = async_to_streamed_response_wrapper(
+ business_glossary.update,
+ )
+ self.list = async_to_streamed_response_wrapper(
+ business_glossary.list,
+ )
+ self.delete = async_to_streamed_response_wrapper(
+ business_glossary.delete,
+ )
diff --git a/src/asktable/resources/chats/chats.py b/src/asktable/resources/chats/chats.py
index 9d64d56b..54e32cd3 100644
--- a/src/asktable/resources/chats/chats.py
+++ b/src/asktable/resources/chats/chats.py
@@ -6,7 +6,7 @@
import httpx
-from ...types import chat_list_params, chat_create_params
+from ...types import chat_list_params, chat_create_params, chat_send_message_params
from ..._types import NOT_GIVEN, Body, Query, Headers, NoneType, NotGiven
from ..._utils import (
maybe_transform,
@@ -28,10 +28,10 @@
async_to_raw_response_wrapper,
async_to_streamed_response_wrapper,
)
-from ..._base_client import make_request_options
-from ...types.chat_list_response import ChatListResponse
-from ...types.chat_create_response import ChatCreateResponse
-from ...types.chat_retrieve_response import ChatRetrieveResponse
+from ...pagination import SyncPage, AsyncPage
+from ...types.chat import Chat
+from ..._base_client import AsyncPaginator, make_request_options
+from ...types.message import Message
__all__ = ["ChatsResource", "AsyncChatsResource"]
@@ -74,7 +74,7 @@ def create(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> ChatCreateResponse:
+ ) -> Chat:
"""
创建对话
@@ -114,7 +114,7 @@ def create(
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
- cast_to=ChatCreateResponse,
+ cast_to=Chat,
)
def retrieve(
@@ -127,7 +127,7 @@ def retrieve(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> ChatRetrieveResponse:
+ ) -> Chat:
"""
获取某个对话
@@ -147,7 +147,7 @@ def retrieve(
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
- cast_to=ChatRetrieveResponse,
+ cast_to=Chat,
)
def list(
@@ -161,7 +161,7 @@ def list(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> ChatListResponse:
+ ) -> SyncPage[Chat]:
"""
查询对话列表
@@ -178,8 +178,9 @@ def list(
timeout: Override the client-level default timeout for this request, in seconds
"""
- return self._get(
+ return self._get_api_list(
"/chats",
+ page=SyncPage[Chat],
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
@@ -193,7 +194,7 @@ def list(
chat_list_params.ChatListParams,
),
),
- cast_to=ChatListResponse,
+ model=Chat,
)
def delete(
@@ -230,6 +231,44 @@ def delete(
cast_to=NoneType,
)
+ def send_message(
+ self,
+ chat_id: str,
+ *,
+ question: 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,
+ ) -> Message:
+ """
+ 发消息
+
+ 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 chat_id:
+ raise ValueError(f"Expected a non-empty value for `chat_id` but received {chat_id!r}")
+ return self._post(
+ f"/chats/{chat_id}",
+ options=make_request_options(
+ extra_headers=extra_headers,
+ extra_query=extra_query,
+ extra_body=extra_body,
+ timeout=timeout,
+ query=maybe_transform({"question": question}, chat_send_message_params.ChatSendMessageParams),
+ ),
+ cast_to=Message,
+ )
+
class AsyncChatsResource(AsyncAPIResource):
@cached_property
@@ -269,7 +308,7 @@ async def create(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> ChatCreateResponse:
+ ) -> Chat:
"""
创建对话
@@ -309,7 +348,7 @@ async def create(
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
- cast_to=ChatCreateResponse,
+ cast_to=Chat,
)
async def retrieve(
@@ -322,7 +361,7 @@ async def retrieve(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> ChatRetrieveResponse:
+ ) -> Chat:
"""
获取某个对话
@@ -342,10 +381,10 @@ async def retrieve(
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
- cast_to=ChatRetrieveResponse,
+ cast_to=Chat,
)
- async def list(
+ def list(
self,
*,
page: int | NotGiven = NOT_GIVEN,
@@ -356,7 +395,7 @@ async def list(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> ChatListResponse:
+ ) -> AsyncPaginator[Chat, AsyncPage[Chat]]:
"""
查询对话列表
@@ -373,14 +412,15 @@ async def list(
timeout: Override the client-level default timeout for this request, in seconds
"""
- return await self._get(
+ return self._get_api_list(
"/chats",
+ page=AsyncPage[Chat],
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
- query=await async_maybe_transform(
+ query=maybe_transform(
{
"page": page,
"size": size,
@@ -388,7 +428,7 @@ async def list(
chat_list_params.ChatListParams,
),
),
- cast_to=ChatListResponse,
+ model=Chat,
)
async def delete(
@@ -425,6 +465,46 @@ async def delete(
cast_to=NoneType,
)
+ async def send_message(
+ self,
+ chat_id: str,
+ *,
+ question: 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,
+ ) -> Message:
+ """
+ 发消息
+
+ 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 chat_id:
+ raise ValueError(f"Expected a non-empty value for `chat_id` but received {chat_id!r}")
+ return await self._post(
+ f"/chats/{chat_id}",
+ options=make_request_options(
+ extra_headers=extra_headers,
+ extra_query=extra_query,
+ extra_body=extra_body,
+ timeout=timeout,
+ query=await async_maybe_transform(
+ {"question": question}, chat_send_message_params.ChatSendMessageParams
+ ),
+ ),
+ cast_to=Message,
+ )
+
class ChatsResourceWithRawResponse:
def __init__(self, chats: ChatsResource) -> None:
@@ -442,6 +522,9 @@ def __init__(self, chats: ChatsResource) -> None:
self.delete = to_raw_response_wrapper(
chats.delete,
)
+ self.send_message = to_raw_response_wrapper(
+ chats.send_message,
+ )
@cached_property
def messages(self) -> MessagesResourceWithRawResponse:
@@ -464,6 +547,9 @@ def __init__(self, chats: AsyncChatsResource) -> None:
self.delete = async_to_raw_response_wrapper(
chats.delete,
)
+ self.send_message = async_to_raw_response_wrapper(
+ chats.send_message,
+ )
@cached_property
def messages(self) -> AsyncMessagesResourceWithRawResponse:
@@ -486,6 +572,9 @@ def __init__(self, chats: ChatsResource) -> None:
self.delete = to_streamed_response_wrapper(
chats.delete,
)
+ self.send_message = to_streamed_response_wrapper(
+ chats.send_message,
+ )
@cached_property
def messages(self) -> MessagesResourceWithStreamingResponse:
@@ -508,6 +597,9 @@ def __init__(self, chats: AsyncChatsResource) -> None:
self.delete = async_to_streamed_response_wrapper(
chats.delete,
)
+ self.send_message = async_to_streamed_response_wrapper(
+ chats.send_message,
+ )
@cached_property
def messages(self) -> AsyncMessagesResourceWithStreamingResponse:
diff --git a/src/asktable/resources/chats/messages.py b/src/asktable/resources/chats/messages.py
index 1c89cb44..5f2416ba 100644
--- a/src/asktable/resources/chats/messages.py
+++ b/src/asktable/resources/chats/messages.py
@@ -17,10 +17,10 @@
async_to_raw_response_wrapper,
async_to_streamed_response_wrapper,
)
-from ...types.chats import message_list_params, message_create_params
-from ..._base_client import make_request_options
-from ...types.shared.message import Message
-from ...types.chats.message_list_response import MessageListResponse
+from ...pagination import SyncPage, AsyncPage
+from ...types.chats import message_list_params, message_send_message_params
+from ..._base_client import AsyncPaginator, make_request_options
+from ...types.message import Message
__all__ = ["MessagesResource", "AsyncMessagesResource"]
@@ -45,44 +45,6 @@ def with_streaming_response(self) -> MessagesResourceWithStreamingResponse:
"""
return MessagesResourceWithStreamingResponse(self)
- def create(
- self,
- chat_id: str,
- *,
- question: 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,
- ) -> Message:
- """
- 发消息
-
- 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 chat_id:
- raise ValueError(f"Expected a non-empty value for `chat_id` but received {chat_id!r}")
- return self._post(
- f"/chats/{chat_id}",
- options=make_request_options(
- extra_headers=extra_headers,
- extra_query=extra_query,
- extra_body=extra_body,
- timeout=timeout,
- query=maybe_transform({"question": question}, message_create_params.MessageCreateParams),
- ),
- cast_to=Message,
- )
-
def retrieve(
self,
message_id: str,
@@ -131,7 +93,7 @@ def list(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> MessageListResponse:
+ ) -> SyncPage[Message]:
"""
查询所有的消息
@@ -150,8 +112,9 @@ 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(
+ return self._get_api_list(
f"/chats/{chat_id}/messages",
+ page=SyncPage[Message],
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
@@ -165,31 +128,10 @@ def list(
message_list_params.MessageListParams,
),
),
- cast_to=MessageListResponse,
+ model=Message,
)
-
-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
- 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 AsyncMessagesResourceWithRawResponse(self)
-
- @cached_property
- def with_streaming_response(self) -> AsyncMessagesResourceWithStreamingResponse:
- """
- 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 AsyncMessagesResourceWithStreamingResponse(self)
-
- async def create(
+ def send_message(
self,
chat_id: str,
*,
@@ -215,18 +157,39 @@ async def create(
"""
if not chat_id:
raise ValueError(f"Expected a non-empty value for `chat_id` but received {chat_id!r}")
- return await self._post(
- f"/chats/{chat_id}",
+ return self._post(
+ f"/chats/{chat_id}/messages",
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
- query=await async_maybe_transform({"question": question}, message_create_params.MessageCreateParams),
+ query=maybe_transform({"question": question}, message_send_message_params.MessageSendMessageParams),
),
cast_to=Message,
)
+
+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
+ 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 AsyncMessagesResourceWithRawResponse(self)
+
+ @cached_property
+ def with_streaming_response(self) -> AsyncMessagesResourceWithStreamingResponse:
+ """
+ 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 AsyncMessagesResourceWithStreamingResponse(self)
+
async def retrieve(
self,
message_id: str,
@@ -263,7 +226,7 @@ async def retrieve(
cast_to=Message,
)
- async def list(
+ def list(
self,
chat_id: str,
*,
@@ -275,7 +238,7 @@ async def list(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> MessageListResponse:
+ ) -> AsyncPaginator[Message, AsyncPage[Message]]:
"""
查询所有的消息
@@ -294,14 +257,15 @@ async def list(
"""
if not chat_id:
raise ValueError(f"Expected a non-empty value for `chat_id` but received {chat_id!r}")
- return await self._get(
+ return self._get_api_list(
f"/chats/{chat_id}/messages",
+ page=AsyncPage[Message],
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
- query=await async_maybe_transform(
+ query=maybe_transform(
{
"page": page,
"size": size,
@@ -309,7 +273,47 @@ async def list(
message_list_params.MessageListParams,
),
),
- cast_to=MessageListResponse,
+ model=Message,
+ )
+
+ async def send_message(
+ self,
+ chat_id: str,
+ *,
+ question: 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,
+ ) -> Message:
+ """
+ 发消息
+
+ 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 chat_id:
+ raise ValueError(f"Expected a non-empty value for `chat_id` but received {chat_id!r}")
+ return await self._post(
+ f"/chats/{chat_id}/messages",
+ options=make_request_options(
+ extra_headers=extra_headers,
+ extra_query=extra_query,
+ extra_body=extra_body,
+ timeout=timeout,
+ query=await async_maybe_transform(
+ {"question": question}, message_send_message_params.MessageSendMessageParams
+ ),
+ ),
+ cast_to=Message,
)
@@ -317,57 +321,57 @@ class MessagesResourceWithRawResponse:
def __init__(self, messages: MessagesResource) -> None:
self._messages = messages
- self.create = to_raw_response_wrapper(
- messages.create,
- )
self.retrieve = to_raw_response_wrapper(
messages.retrieve,
)
self.list = to_raw_response_wrapper(
messages.list,
)
+ self.send_message = to_raw_response_wrapper(
+ messages.send_message,
+ )
class AsyncMessagesResourceWithRawResponse:
def __init__(self, messages: AsyncMessagesResource) -> None:
self._messages = messages
- self.create = async_to_raw_response_wrapper(
- messages.create,
- )
self.retrieve = async_to_raw_response_wrapper(
messages.retrieve,
)
self.list = async_to_raw_response_wrapper(
messages.list,
)
+ self.send_message = async_to_raw_response_wrapper(
+ messages.send_message,
+ )
class MessagesResourceWithStreamingResponse:
def __init__(self, messages: MessagesResource) -> None:
self._messages = messages
- self.create = to_streamed_response_wrapper(
- messages.create,
- )
self.retrieve = to_streamed_response_wrapper(
messages.retrieve,
)
self.list = to_streamed_response_wrapper(
messages.list,
)
+ self.send_message = to_streamed_response_wrapper(
+ messages.send_message,
+ )
class AsyncMessagesResourceWithStreamingResponse:
def __init__(self, messages: AsyncMessagesResource) -> None:
self._messages = messages
- self.create = async_to_streamed_response_wrapper(
- messages.create,
- )
self.retrieve = async_to_streamed_response_wrapper(
messages.retrieve,
)
self.list = async_to_streamed_response_wrapper(
messages.list,
)
+ self.send_message = async_to_streamed_response_wrapper(
+ messages.send_message,
+ )
diff --git a/src/asktable/resources/datasources/__init__.py b/src/asktable/resources/datasources/__init__.py
index 8bd1099b..98b05222 100644
--- a/src/asktable/resources/datasources/__init__.py
+++ b/src/asktable/resources/datasources/__init__.py
@@ -8,6 +8,14 @@
MetaResourceWithStreamingResponse,
AsyncMetaResourceWithStreamingResponse,
)
+from .indexes import (
+ IndexesResource,
+ AsyncIndexesResource,
+ IndexesResourceWithRawResponse,
+ AsyncIndexesResourceWithRawResponse,
+ IndexesResourceWithStreamingResponse,
+ AsyncIndexesResourceWithStreamingResponse,
+)
from .datasources import (
DatasourcesResource,
AsyncDatasourcesResource,
@@ -38,6 +46,12 @@
"AsyncUploadParamsResourceWithRawResponse",
"UploadParamsResourceWithStreamingResponse",
"AsyncUploadParamsResourceWithStreamingResponse",
+ "IndexesResource",
+ "AsyncIndexesResource",
+ "IndexesResourceWithRawResponse",
+ "AsyncIndexesResourceWithRawResponse",
+ "IndexesResourceWithStreamingResponse",
+ "AsyncIndexesResourceWithStreamingResponse",
"DatasourcesResource",
"AsyncDatasourcesResource",
"DatasourcesResourceWithRawResponse",
diff --git a/src/asktable/resources/datasources/datasources.py b/src/asktable/resources/datasources/datasources.py
index 99b57556..976019e6 100644
--- a/src/asktable/resources/datasources/datasources.py
+++ b/src/asktable/resources/datasources/datasources.py
@@ -21,6 +21,14 @@
datasource_update_params,
datasource_create_from_file_params,
)
+from .indexes import (
+ IndexesResource,
+ AsyncIndexesResource,
+ IndexesResourceWithRawResponse,
+ AsyncIndexesResourceWithRawResponse,
+ IndexesResourceWithStreamingResponse,
+ AsyncIndexesResourceWithStreamingResponse,
+)
from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven, FileTypes
from ..._utils import (
extract_files,
@@ -36,6 +44,7 @@
async_to_raw_response_wrapper,
async_to_streamed_response_wrapper,
)
+from ...pagination import SyncPage, AsyncPage
from .upload_params import (
UploadParamsResource,
AsyncUploadParamsResource,
@@ -44,9 +53,8 @@
UploadParamsResourceWithStreamingResponse,
AsyncUploadParamsResourceWithStreamingResponse,
)
-from ..._base_client import make_request_options
-from ...types.data_source import DataSource
-from ...types.datasource_list_response import DatasourceListResponse
+from ..._base_client import AsyncPaginator, make_request_options
+from ...types.datasource import Datasource
__all__ = ["DatasourcesResource", "AsyncDatasourcesResource"]
@@ -60,6 +68,10 @@ def meta(self) -> MetaResource:
def upload_params(self) -> UploadParamsResource:
return UploadParamsResource(self._client)
+ @cached_property
+ def indexes(self) -> IndexesResource:
+ return IndexesResource(self._client)
+
@cached_property
def with_raw_response(self) -> DatasourcesResourceWithRawResponse:
"""
@@ -92,7 +104,7 @@ def create(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> DataSource:
+ ) -> Datasource:
"""
创建一个新的数据源
@@ -130,7 +142,7 @@ def create(
{"async_process_meta": async_process_meta}, datasource_create_params.DatasourceCreateParams
),
),
- cast_to=DataSource,
+ cast_to=Datasource,
)
def retrieve(
@@ -143,7 +155,7 @@ def retrieve(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> DataSource:
+ ) -> Datasource:
"""
根据 id 获取指定数据源
@@ -163,7 +175,7 @@ def retrieve(
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
- cast_to=DataSource,
+ cast_to=Datasource,
)
def update(
@@ -171,10 +183,10 @@ def update(
datasource_id: str,
*,
access_config: Optional[datasource_update_params.AccessConfig] | NotGiven = NOT_GIVEN,
+ desc: Optional[str] | NotGiven = NOT_GIVEN,
field_count: Optional[int] | NotGiven = NOT_GIVEN,
meta_error: Optional[str] | NotGiven = NOT_GIVEN,
- meta_status: Optional[Literal["processing", "failed", "warning", "success", "unprocessed"]]
- | NotGiven = NOT_GIVEN,
+ meta_status: Optional[Literal["processing", "failed", "success", "unprocessed"]] | NotGiven = NOT_GIVEN,
name: Optional[str] | NotGiven = NOT_GIVEN,
sample_questions: Optional[str] | NotGiven = NOT_GIVEN,
schema_count: Optional[int] | NotGiven = NOT_GIVEN,
@@ -185,13 +197,15 @@ def update(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> DataSource:
+ ) -> Datasource:
"""
更新指定数据源信息
Args:
access_config: 不同引擎有不同的配置
+ desc: 数据源描述
+
field_count: 字段数量
meta_error: 元数据处理错误
@@ -221,6 +235,7 @@ def update(
body=maybe_transform(
{
"access_config": access_config,
+ "desc": desc,
"field_count": field_count,
"meta_error": meta_error,
"meta_status": meta_status,
@@ -234,7 +249,7 @@ def update(
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
- cast_to=DataSource,
+ cast_to=Datasource,
)
def list(
@@ -249,7 +264,7 @@ def list(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> DatasourceListResponse:
+ ) -> SyncPage[Datasource]:
"""
获取所有的数据源
@@ -266,8 +281,9 @@ def list(
timeout: Override the client-level default timeout for this request, in seconds
"""
- return self._get(
+ return self._get_api_list(
"/datasources",
+ page=SyncPage[Datasource],
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
@@ -282,7 +298,7 @@ def list(
datasource_list_params.DatasourceListParams,
),
),
- cast_to=DatasourceListResponse,
+ model=Datasource,
)
def delete(
@@ -321,16 +337,16 @@ def delete(
def create_from_file(
self,
*,
- name: str,
file: FileTypes,
async_process_meta: bool | NotGiven = NOT_GIVEN,
+ name: 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,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> DataSource:
+ ) -> Datasource:
"""
上传文件并创建数据源
@@ -360,13 +376,13 @@ def create_from_file(
timeout=timeout,
query=maybe_transform(
{
- "name": name,
"async_process_meta": async_process_meta,
+ "name": name,
},
datasource_create_from_file_params.DatasourceCreateFromFileParams,
),
),
- cast_to=DataSource,
+ cast_to=Datasource,
)
@@ -379,6 +395,10 @@ def meta(self) -> AsyncMetaResource:
def upload_params(self) -> AsyncUploadParamsResource:
return AsyncUploadParamsResource(self._client)
+ @cached_property
+ def indexes(self) -> AsyncIndexesResource:
+ return AsyncIndexesResource(self._client)
+
@cached_property
def with_raw_response(self) -> AsyncDatasourcesResourceWithRawResponse:
"""
@@ -411,7 +431,7 @@ async def create(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> DataSource:
+ ) -> Datasource:
"""
创建一个新的数据源
@@ -449,7 +469,7 @@ async def create(
{"async_process_meta": async_process_meta}, datasource_create_params.DatasourceCreateParams
),
),
- cast_to=DataSource,
+ cast_to=Datasource,
)
async def retrieve(
@@ -462,7 +482,7 @@ async def retrieve(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> DataSource:
+ ) -> Datasource:
"""
根据 id 获取指定数据源
@@ -482,7 +502,7 @@ async def retrieve(
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
- cast_to=DataSource,
+ cast_to=Datasource,
)
async def update(
@@ -490,10 +510,10 @@ async def update(
datasource_id: str,
*,
access_config: Optional[datasource_update_params.AccessConfig] | NotGiven = NOT_GIVEN,
+ desc: Optional[str] | NotGiven = NOT_GIVEN,
field_count: Optional[int] | NotGiven = NOT_GIVEN,
meta_error: Optional[str] | NotGiven = NOT_GIVEN,
- meta_status: Optional[Literal["processing", "failed", "warning", "success", "unprocessed"]]
- | NotGiven = NOT_GIVEN,
+ meta_status: Optional[Literal["processing", "failed", "success", "unprocessed"]] | NotGiven = NOT_GIVEN,
name: Optional[str] | NotGiven = NOT_GIVEN,
sample_questions: Optional[str] | NotGiven = NOT_GIVEN,
schema_count: Optional[int] | NotGiven = NOT_GIVEN,
@@ -504,13 +524,15 @@ async def update(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> DataSource:
+ ) -> Datasource:
"""
更新指定数据源信息
Args:
access_config: 不同引擎有不同的配置
+ desc: 数据源描述
+
field_count: 字段数量
meta_error: 元数据处理错误
@@ -540,6 +562,7 @@ async def update(
body=await async_maybe_transform(
{
"access_config": access_config,
+ "desc": desc,
"field_count": field_count,
"meta_error": meta_error,
"meta_status": meta_status,
@@ -553,10 +576,10 @@ async def update(
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
- cast_to=DataSource,
+ cast_to=Datasource,
)
- async def list(
+ def list(
self,
*,
name: Optional[str] | NotGiven = NOT_GIVEN,
@@ -568,7 +591,7 @@ async def list(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> DatasourceListResponse:
+ ) -> AsyncPaginator[Datasource, AsyncPage[Datasource]]:
"""
获取所有的数据源
@@ -585,14 +608,15 @@ async def list(
timeout: Override the client-level default timeout for this request, in seconds
"""
- return await self._get(
+ return self._get_api_list(
"/datasources",
+ page=AsyncPage[Datasource],
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
- query=await async_maybe_transform(
+ query=maybe_transform(
{
"name": name,
"page": page,
@@ -601,7 +625,7 @@ async def list(
datasource_list_params.DatasourceListParams,
),
),
- cast_to=DatasourceListResponse,
+ model=Datasource,
)
async def delete(
@@ -640,16 +664,16 @@ async def delete(
async def create_from_file(
self,
*,
- name: str,
file: FileTypes,
async_process_meta: bool | NotGiven = NOT_GIVEN,
+ name: 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,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> DataSource:
+ ) -> Datasource:
"""
上传文件并创建数据源
@@ -679,13 +703,13 @@ async def create_from_file(
timeout=timeout,
query=await async_maybe_transform(
{
- "name": name,
"async_process_meta": async_process_meta,
+ "name": name,
},
datasource_create_from_file_params.DatasourceCreateFromFileParams,
),
),
- cast_to=DataSource,
+ cast_to=Datasource,
)
@@ -720,6 +744,10 @@ def meta(self) -> MetaResourceWithRawResponse:
def upload_params(self) -> UploadParamsResourceWithRawResponse:
return UploadParamsResourceWithRawResponse(self._datasources.upload_params)
+ @cached_property
+ def indexes(self) -> IndexesResourceWithRawResponse:
+ return IndexesResourceWithRawResponse(self._datasources.indexes)
+
class AsyncDatasourcesResourceWithRawResponse:
def __init__(self, datasources: AsyncDatasourcesResource) -> None:
@@ -752,6 +780,10 @@ def meta(self) -> AsyncMetaResourceWithRawResponse:
def upload_params(self) -> AsyncUploadParamsResourceWithRawResponse:
return AsyncUploadParamsResourceWithRawResponse(self._datasources.upload_params)
+ @cached_property
+ def indexes(self) -> AsyncIndexesResourceWithRawResponse:
+ return AsyncIndexesResourceWithRawResponse(self._datasources.indexes)
+
class DatasourcesResourceWithStreamingResponse:
def __init__(self, datasources: DatasourcesResource) -> None:
@@ -784,6 +816,10 @@ def meta(self) -> MetaResourceWithStreamingResponse:
def upload_params(self) -> UploadParamsResourceWithStreamingResponse:
return UploadParamsResourceWithStreamingResponse(self._datasources.upload_params)
+ @cached_property
+ def indexes(self) -> IndexesResourceWithStreamingResponse:
+ return IndexesResourceWithStreamingResponse(self._datasources.indexes)
+
class AsyncDatasourcesResourceWithStreamingResponse:
def __init__(self, datasources: AsyncDatasourcesResource) -> None:
@@ -815,3 +851,7 @@ def meta(self) -> AsyncMetaResourceWithStreamingResponse:
@cached_property
def upload_params(self) -> AsyncUploadParamsResourceWithStreamingResponse:
return AsyncUploadParamsResourceWithStreamingResponse(self._datasources.upload_params)
+
+ @cached_property
+ def indexes(self) -> AsyncIndexesResourceWithStreamingResponse:
+ return AsyncIndexesResourceWithStreamingResponse(self._datasources.indexes)
diff --git a/src/asktable/resources/kb.py b/src/asktable/resources/datasources/indexes.py
similarity index 60%
rename from src/asktable/resources/kb.py
rename to src/asktable/resources/datasources/indexes.py
index a630d374..8c5e4638 100644
--- a/src/asktable/resources/kb.py
+++ b/src/asktable/resources/datasources/indexes.py
@@ -2,99 +2,75 @@
from __future__ import annotations
-from typing import Iterable
-
import httpx
-from ..types import kb_list_params, kb_create_params
-from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven
-from .._utils import (
+from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven
+from ..._utils import (
maybe_transform,
async_maybe_transform,
)
-from .._compat import cached_property
-from .._resource import SyncAPIResource, AsyncAPIResource
-from .._response import (
+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.document import Document
-from ..types.page_document import PageDocument
-from ..types.kb_create_response import KBCreateResponse
+from ...pagination import SyncPage, AsyncPage
+from ...types.index import Index
+from ..._base_client import AsyncPaginator, make_request_options
+from ...types.datasources import index_list_params, index_create_params
-__all__ = ["KBResource", "AsyncKBResource"]
+__all__ = ["IndexesResource", "AsyncIndexesResource"]
-class KBResource(SyncAPIResource):
+class IndexesResource(SyncAPIResource):
@cached_property
- def with_raw_response(self) -> KBResourceWithRawResponse:
+ def with_raw_response(self) -> IndexesResourceWithRawResponse:
"""
This property can be used as a prefix for any HTTP method call to return the
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 KBResourceWithRawResponse(self)
+ return IndexesResourceWithRawResponse(self)
@cached_property
- def with_streaming_response(self) -> KBResourceWithStreamingResponse:
+ def with_streaming_response(self) -> IndexesResourceWithStreamingResponse:
"""
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 KBResourceWithStreamingResponse(self)
+ return IndexesResourceWithStreamingResponse(self)
def create(
self,
+ ds_id: str,
*,
- body: Iterable[kb_create_params.Body],
+ field_name: str,
+ schema_name: str,
+ table_name: str,
+ async_process: bool | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> KBCreateResponse:
+ ) -> object:
"""
- 创建文档
+ 创建索引 Args: ds_id: 数据源 ID index: 索引创建参数,包含
+ schema_name、table_name 和 field_name Returns: 创建的索引完整信息
Args:
- extra_headers: Send extra headers
+ field_name: 字段名
- extra_query: Add additional query parameters to the request
+ schema_name: 模式名称
- extra_body: Add additional JSON properties to the request
+ table_name: 表名
- timeout: Override the client-level default timeout for this request, in seconds
- """
- return self._post(
- "/kb",
- body=maybe_transform(body, Iterable[kb_create_params.Body]),
- options=make_request_options(
- extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
- ),
- cast_to=KBCreateResponse,
- )
-
- def retrieve(
- self,
- doc_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,
- ) -> Document:
- """
- 获取某个文档
-
- Args:
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
@@ -103,20 +79,32 @@ def retrieve(
timeout: Override the client-level default timeout for this request, in seconds
"""
- if not doc_id:
- raise ValueError(f"Expected a non-empty value for `doc_id` but received {doc_id!r}")
- return self._get(
- f"/kb/{doc_id}",
+ 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",
+ body=maybe_transform(
+ {
+ "field_name": field_name,
+ "schema_name": schema_name,
+ "table_name": table_name,
+ },
+ index_create_params.IndexCreateParams,
+ ),
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": async_process}, index_create_params.IndexCreateParams),
),
- cast_to=Document,
+ cast_to=object,
)
def list(
self,
+ ds_id: str,
*,
- name: str | NotGiven = NOT_GIVEN,
page: int | NotGiven = NOT_GIVEN,
size: int | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
@@ -125,13 +113,12 @@ def list(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> PageDocument:
+ ) -> SyncPage[Index]:
"""
- 查询所有文档
+ 获取数据源的所有索引 Args: ds_id: 数据源 ID Returns: 索引列表,包含索引的完整信
+ 息
Args:
- name: 文档名称
-
page: Page number
size: Page size
@@ -144,8 +131,11 @@ def list(
timeout: Override the client-level default timeout for this request, in seconds
"""
- return self._get(
- "/kb",
+ 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",
+ page=SyncPage[Index],
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
@@ -153,20 +143,20 @@ def list(
timeout=timeout,
query=maybe_transform(
{
- "name": name,
"page": page,
"size": size,
},
- kb_list_params.KBListParams,
+ index_list_params.IndexListParams,
),
),
- cast_to=PageDocument,
+ model=Index,
)
def delete(
self,
- doc_id: str,
+ index_id: str,
*,
+ ds_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,
@@ -175,7 +165,7 @@ def delete(
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> object:
"""
- 删除某个文档
+ 删除索引 Args: ds_id: 数据源 ID index_id: 索引 ID
Args:
extra_headers: Send extra headers
@@ -186,10 +176,12 @@ def delete(
timeout: Override the client-level default timeout for this request, in seconds
"""
- if not doc_id:
- raise ValueError(f"Expected a non-empty value for `doc_id` but received {doc_id!r}")
+ if not ds_id:
+ raise ValueError(f"Expected a non-empty value for `ds_id` but received {ds_id!r}")
+ if not index_id:
+ raise ValueError(f"Expected a non-empty value for `index_id` but received {index_id!r}")
return self._delete(
- f"/kb/{doc_id}",
+ f"/datasources/{ds_id}/indexes/{index_id}",
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
@@ -197,73 +189,52 @@ def delete(
)
-class AsyncKBResource(AsyncAPIResource):
+class AsyncIndexesResource(AsyncAPIResource):
@cached_property
- def with_raw_response(self) -> AsyncKBResourceWithRawResponse:
+ def with_raw_response(self) -> AsyncIndexesResourceWithRawResponse:
"""
This property can be used as a prefix for any HTTP method call to return the
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 AsyncKBResourceWithRawResponse(self)
+ return AsyncIndexesResourceWithRawResponse(self)
@cached_property
- def with_streaming_response(self) -> AsyncKBResourceWithStreamingResponse:
+ def with_streaming_response(self) -> AsyncIndexesResourceWithStreamingResponse:
"""
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 AsyncKBResourceWithStreamingResponse(self)
+ return AsyncIndexesResourceWithStreamingResponse(self)
async def create(
self,
+ ds_id: str,
*,
- body: Iterable[kb_create_params.Body],
+ field_name: str,
+ schema_name: str,
+ table_name: str,
+ async_process: bool | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> KBCreateResponse:
+ ) -> object:
"""
- 创建文档
+ 创建索引 Args: ds_id: 数据源 ID index: 索引创建参数,包含
+ schema_name、table_name 和 field_name Returns: 创建的索引完整信息
Args:
- extra_headers: Send extra headers
-
- extra_query: Add additional query parameters to the request
+ field_name: 字段名
- extra_body: Add additional JSON properties to the request
+ schema_name: 模式名称
- timeout: Override the client-level default timeout for this request, in seconds
- """
- return await self._post(
- "/kb",
- body=await async_maybe_transform(body, Iterable[kb_create_params.Body]),
- options=make_request_options(
- extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
- ),
- cast_to=KBCreateResponse,
- )
+ table_name: 表名
- async def retrieve(
- self,
- doc_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,
- ) -> Document:
- """
- 获取某个文档
-
- Args:
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
@@ -272,20 +243,34 @@ async def retrieve(
timeout: Override the client-level default timeout for this request, in seconds
"""
- if not doc_id:
- raise ValueError(f"Expected a non-empty value for `doc_id` but received {doc_id!r}")
- return await self._get(
- f"/kb/{doc_id}",
+ 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",
+ body=await async_maybe_transform(
+ {
+ "field_name": field_name,
+ "schema_name": schema_name,
+ "table_name": table_name,
+ },
+ index_create_params.IndexCreateParams,
+ ),
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": async_process}, index_create_params.IndexCreateParams
+ ),
),
- cast_to=Document,
+ cast_to=object,
)
- async def list(
+ def list(
self,
+ ds_id: str,
*,
- name: str | NotGiven = NOT_GIVEN,
page: int | NotGiven = NOT_GIVEN,
size: int | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
@@ -294,13 +279,12 @@ async def list(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> PageDocument:
+ ) -> AsyncPaginator[Index, AsyncPage[Index]]:
"""
- 查询所有文档
+ 获取数据源的所有索引 Args: ds_id: 数据源 ID Returns: 索引列表,包含索引的完整信
+ 息
Args:
- name: 文档名称
-
page: Page number
size: Page size
@@ -313,29 +297,32 @@ async def list(
timeout: Override the client-level default timeout for this request, in seconds
"""
- return await self._get(
- "/kb",
+ 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",
+ page=AsyncPage[Index],
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
- query=await async_maybe_transform(
+ query=maybe_transform(
{
- "name": name,
"page": page,
"size": size,
},
- kb_list_params.KBListParams,
+ index_list_params.IndexListParams,
),
),
- cast_to=PageDocument,
+ model=Index,
)
async def delete(
self,
- doc_id: str,
+ index_id: str,
*,
+ ds_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,
@@ -344,7 +331,7 @@ async def delete(
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> object:
"""
- 删除某个文档
+ 删除索引 Args: ds_id: 数据源 ID index_id: 索引 ID
Args:
extra_headers: Send extra headers
@@ -355,10 +342,12 @@ async def delete(
timeout: Override the client-level default timeout for this request, in seconds
"""
- if not doc_id:
- raise ValueError(f"Expected a non-empty value for `doc_id` but received {doc_id!r}")
+ if not ds_id:
+ raise ValueError(f"Expected a non-empty value for `ds_id` but received {ds_id!r}")
+ 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"/kb/{doc_id}",
+ f"/datasources/{ds_id}/indexes/{index_id}",
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
@@ -366,73 +355,61 @@ async def delete(
)
-class KBResourceWithRawResponse:
- def __init__(self, kb: KBResource) -> None:
- self._kb = kb
+class IndexesResourceWithRawResponse:
+ def __init__(self, indexes: IndexesResource) -> None:
+ self._indexes = indexes
self.create = to_raw_response_wrapper(
- kb.create,
- )
- self.retrieve = to_raw_response_wrapper(
- kb.retrieve,
+ indexes.create,
)
self.list = to_raw_response_wrapper(
- kb.list,
+ indexes.list,
)
self.delete = to_raw_response_wrapper(
- kb.delete,
+ indexes.delete,
)
-class AsyncKBResourceWithRawResponse:
- def __init__(self, kb: AsyncKBResource) -> None:
- self._kb = kb
+class AsyncIndexesResourceWithRawResponse:
+ def __init__(self, indexes: AsyncIndexesResource) -> None:
+ self._indexes = indexes
self.create = async_to_raw_response_wrapper(
- kb.create,
- )
- self.retrieve = async_to_raw_response_wrapper(
- kb.retrieve,
+ indexes.create,
)
self.list = async_to_raw_response_wrapper(
- kb.list,
+ indexes.list,
)
self.delete = async_to_raw_response_wrapper(
- kb.delete,
+ indexes.delete,
)
-class KBResourceWithStreamingResponse:
- def __init__(self, kb: KBResource) -> None:
- self._kb = kb
+class IndexesResourceWithStreamingResponse:
+ def __init__(self, indexes: IndexesResource) -> None:
+ self._indexes = indexes
self.create = to_streamed_response_wrapper(
- kb.create,
- )
- self.retrieve = to_streamed_response_wrapper(
- kb.retrieve,
+ indexes.create,
)
self.list = to_streamed_response_wrapper(
- kb.list,
+ indexes.list,
)
self.delete = to_streamed_response_wrapper(
- kb.delete,
+ indexes.delete,
)
-class AsyncKBResourceWithStreamingResponse:
- def __init__(self, kb: AsyncKBResource) -> None:
- self._kb = kb
+class AsyncIndexesResourceWithStreamingResponse:
+ def __init__(self, indexes: AsyncIndexesResource) -> None:
+ self._indexes = indexes
self.create = async_to_streamed_response_wrapper(
- kb.create,
- )
- self.retrieve = async_to_streamed_response_wrapper(
- kb.retrieve,
+ indexes.create,
)
self.list = async_to_streamed_response_wrapper(
- kb.list,
+ indexes.list,
)
self.delete = async_to_streamed_response_wrapper(
- kb.delete,
+ indexes.delete,
)
diff --git a/src/asktable/resources/datasources/meta.py b/src/asktable/resources/datasources/meta.py
index 4e9e27ba..559131d8 100644
--- a/src/asktable/resources/datasources/meta.py
+++ b/src/asktable/resources/datasources/meta.py
@@ -21,9 +21,9 @@
async_to_raw_response_wrapper,
async_to_streamed_response_wrapper,
)
+from ...types.meta import Meta
from ..._base_client import make_request_options
-from ...types.datasources import meta_create_params, meta_update_params
-from ...types.datasources.meta import Meta
+from ...types.datasources import meta_create_params, meta_update_params, meta_annotate_params
__all__ = ["MetaResource", "AsyncMetaResource"]
@@ -54,7 +54,7 @@ def create(
datasource_id: str,
*,
name: str,
- schemas: Dict[str, meta_create_params.MetaBaseSchemas] | NotGiven = NOT_GIVEN,
+ schemas: Dict[str, meta_create_params.MetaCreateSchemas] | 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,
@@ -63,7 +63,7 @@ def create(
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> object:
"""
- 创建或刷新 数据源的 meta
+ 创建数据源的 meta,如果已经存在,则删除旧的
如果上传了 meta,则使用用户上传的数据创建。
@@ -96,7 +96,7 @@ def create(
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> object:
"""
- 创建或刷新 数据源的 meta
+ 创建数据源的 meta,如果已经存在,则删除旧的
如果上传了 meta,则使用用户上传的数据创建。
@@ -119,7 +119,7 @@ def create(
datasource_id: str,
*,
name: str | NotGiven = NOT_GIVEN,
- schemas: Dict[str, meta_create_params.MetaBaseSchemas] | NotGiven = NOT_GIVEN,
+ schemas: Dict[str, meta_create_params.MetaCreateSchemas] | NotGiven = NOT_GIVEN,
body: None | 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.
@@ -185,7 +185,7 @@ def update(
datasource_id: str,
*,
name: str,
- schemas: Dict[str, meta_update_params.MetaBaseSchemas] | NotGiven = NOT_GIVEN,
+ schemas: Dict[str, meta_update_params.MetaCreateSchemas] | 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,
@@ -242,7 +242,7 @@ def update(
datasource_id: str,
*,
name: str | NotGiven = NOT_GIVEN,
- schemas: Dict[str, meta_update_params.MetaBaseSchemas] | NotGiven = NOT_GIVEN,
+ schemas: Dict[str, meta_update_params.MetaCreateSchemas] | NotGiven = NOT_GIVEN,
body: None | 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.
@@ -269,10 +269,11 @@ def update(
cast_to=object,
)
- def delete(
+ def annotate(
self,
datasource_id: str,
*,
+ schemas: Dict[str, meta_annotate_params.Schemas],
# 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,
@@ -281,7 +282,7 @@ def delete(
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> object:
"""
- Delete Datasource Metadata
+ 修改数据 meta 的描述,用来修改表和字段的备注
Args:
extra_headers: Send extra headers
@@ -294,8 +295,9 @@ 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(
+ return self._patch(
f"/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
),
@@ -329,7 +331,7 @@ async def create(
datasource_id: str,
*,
name: str,
- schemas: Dict[str, meta_create_params.MetaBaseSchemas] | NotGiven = NOT_GIVEN,
+ schemas: Dict[str, meta_create_params.MetaCreateSchemas] | 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,
@@ -338,7 +340,7 @@ async def create(
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> object:
"""
- 创建或刷新 数据源的 meta
+ 创建数据源的 meta,如果已经存在,则删除旧的
如果上传了 meta,则使用用户上传的数据创建。
@@ -371,7 +373,7 @@ async def create(
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> object:
"""
- 创建或刷新 数据源的 meta
+ 创建数据源的 meta,如果已经存在,则删除旧的
如果上传了 meta,则使用用户上传的数据创建。
@@ -394,7 +396,7 @@ async def create(
datasource_id: str,
*,
name: str | NotGiven = NOT_GIVEN,
- schemas: Dict[str, meta_create_params.MetaBaseSchemas] | NotGiven = NOT_GIVEN,
+ schemas: Dict[str, meta_create_params.MetaCreateSchemas] | NotGiven = NOT_GIVEN,
body: None | 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.
@@ -460,7 +462,7 @@ async def update(
datasource_id: str,
*,
name: str,
- schemas: Dict[str, meta_update_params.MetaBaseSchemas] | NotGiven = NOT_GIVEN,
+ schemas: Dict[str, meta_update_params.MetaCreateSchemas] | 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,
@@ -517,7 +519,7 @@ async def update(
datasource_id: str,
*,
name: str | NotGiven = NOT_GIVEN,
- schemas: Dict[str, meta_update_params.MetaBaseSchemas] | NotGiven = NOT_GIVEN,
+ schemas: Dict[str, meta_update_params.MetaCreateSchemas] | NotGiven = NOT_GIVEN,
body: None | 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.
@@ -544,10 +546,11 @@ async def update(
cast_to=object,
)
- async def delete(
+ async def annotate(
self,
datasource_id: str,
*,
+ schemas: Dict[str, meta_annotate_params.Schemas],
# 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,
@@ -556,7 +559,7 @@ async def delete(
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> object:
"""
- Delete Datasource Metadata
+ 修改数据 meta 的描述,用来修改表和字段的备注
Args:
extra_headers: Send extra headers
@@ -569,8 +572,9 @@ 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(
+ return await self._patch(
f"/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
),
@@ -591,8 +595,8 @@ def __init__(self, meta: MetaResource) -> None:
self.update = to_raw_response_wrapper(
meta.update,
)
- self.delete = to_raw_response_wrapper(
- meta.delete,
+ self.annotate = to_raw_response_wrapper(
+ meta.annotate,
)
@@ -609,8 +613,8 @@ def __init__(self, meta: AsyncMetaResource) -> None:
self.update = async_to_raw_response_wrapper(
meta.update,
)
- self.delete = async_to_raw_response_wrapper(
- meta.delete,
+ self.annotate = async_to_raw_response_wrapper(
+ meta.annotate,
)
@@ -627,8 +631,8 @@ def __init__(self, meta: MetaResource) -> None:
self.update = to_streamed_response_wrapper(
meta.update,
)
- self.delete = to_streamed_response_wrapper(
- meta.delete,
+ self.annotate = to_streamed_response_wrapper(
+ meta.annotate,
)
@@ -645,6 +649,6 @@ def __init__(self, meta: AsyncMetaResource) -> None:
self.update = async_to_streamed_response_wrapper(
meta.update,
)
- self.delete = async_to_streamed_response_wrapper(
- meta.delete,
+ self.annotate = async_to_streamed_response_wrapper(
+ meta.annotate,
)
diff --git a/src/asktable/resources/extapis/extapis.py b/src/asktable/resources/extapis/extapis.py
index 66edd2fc..65fd75dd 100644
--- a/src/asktable/resources/extapis/extapis.py
+++ b/src/asktable/resources/extapis/extapis.py
@@ -2,8 +2,7 @@
from __future__ import annotations
-from typing import Dict, Union, Optional
-from datetime import datetime
+from typing import Dict, Optional
import httpx
@@ -29,9 +28,9 @@
async_to_raw_response_wrapper,
async_to_streamed_response_wrapper,
)
-from ..._base_client import make_request_options
-from ...types.ext_api_model import ExtAPIModel
-from ...types.extapi_list_response import ExtapiListResponse
+from ...pagination import SyncPage, AsyncPage
+from ..._base_client import AsyncPaginator, make_request_options
+from ...types.extapi import Extapi
__all__ = ["ExtapisResource", "AsyncExtapisResource"]
@@ -63,20 +62,16 @@ def with_streaming_response(self) -> ExtapisResourceWithStreamingResponse:
def create(
self,
*,
- id: str,
base_url: str,
- created_at: Union[str, datetime],
name: str,
- project_id: str,
headers: Optional[Dict[str, 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,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> ExtAPIModel:
+ ) -> Extapi:
"""
创建一个新的 ExtAPI
@@ -99,20 +94,16 @@ def create(
"/extapis",
body=maybe_transform(
{
- "id": id,
"base_url": base_url,
- "created_at": created_at,
"name": name,
- "project_id": project_id,
"headers": headers,
- "updated_at": updated_at,
},
extapi_create_params.ExtapiCreateParams,
),
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
- cast_to=ExtAPIModel,
+ cast_to=Extapi,
)
def retrieve(
@@ -125,7 +116,7 @@ def retrieve(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> ExtAPIModel:
+ ) -> Extapi:
"""
获取某个 ExtAPI
@@ -145,7 +136,7 @@ def retrieve(
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
- cast_to=ExtAPIModel,
+ cast_to=Extapi,
)
def update(
@@ -161,7 +152,7 @@ def update(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> ExtAPIModel:
+ ) -> Extapi:
"""
更新某个 ExtAPI
@@ -195,7 +186,7 @@ def update(
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
- cast_to=ExtAPIModel,
+ cast_to=Extapi,
)
def list(
@@ -210,7 +201,7 @@ def list(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> ExtapiListResponse:
+ ) -> SyncPage[Extapi]:
"""
查询所有 ExtAPI
@@ -229,8 +220,9 @@ def list(
timeout: Override the client-level default timeout for this request, in seconds
"""
- return self._get(
+ return self._get_api_list(
"/extapis",
+ page=SyncPage[Extapi],
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
@@ -245,7 +237,7 @@ def list(
extapi_list_params.ExtapiListParams,
),
),
- cast_to=ExtapiListResponse,
+ model=Extapi,
)
def delete(
@@ -309,20 +301,16 @@ def with_streaming_response(self) -> AsyncExtapisResourceWithStreamingResponse:
async def create(
self,
*,
- id: str,
base_url: str,
- created_at: Union[str, datetime],
name: str,
- project_id: str,
headers: Optional[Dict[str, 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,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> ExtAPIModel:
+ ) -> Extapi:
"""
创建一个新的 ExtAPI
@@ -345,20 +333,16 @@ async def create(
"/extapis",
body=await async_maybe_transform(
{
- "id": id,
"base_url": base_url,
- "created_at": created_at,
"name": name,
- "project_id": project_id,
"headers": headers,
- "updated_at": updated_at,
},
extapi_create_params.ExtapiCreateParams,
),
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
- cast_to=ExtAPIModel,
+ cast_to=Extapi,
)
async def retrieve(
@@ -371,7 +355,7 @@ async def retrieve(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> ExtAPIModel:
+ ) -> Extapi:
"""
获取某个 ExtAPI
@@ -391,7 +375,7 @@ async def retrieve(
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
- cast_to=ExtAPIModel,
+ cast_to=Extapi,
)
async def update(
@@ -407,7 +391,7 @@ async def update(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> ExtAPIModel:
+ ) -> Extapi:
"""
更新某个 ExtAPI
@@ -441,10 +425,10 @@ async def update(
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
- cast_to=ExtAPIModel,
+ cast_to=Extapi,
)
- async def list(
+ def list(
self,
*,
name: Optional[str] | NotGiven = NOT_GIVEN,
@@ -456,7 +440,7 @@ async def list(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> ExtapiListResponse:
+ ) -> AsyncPaginator[Extapi, AsyncPage[Extapi]]:
"""
查询所有 ExtAPI
@@ -475,14 +459,15 @@ async def list(
timeout: Override the client-level default timeout for this request, in seconds
"""
- return await self._get(
+ return self._get_api_list(
"/extapis",
+ page=AsyncPage[Extapi],
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
- query=await async_maybe_transform(
+ query=maybe_transform(
{
"name": name,
"page": page,
@@ -491,7 +476,7 @@ async def list(
extapi_list_params.ExtapiListParams,
),
),
- cast_to=ExtapiListResponse,
+ model=Extapi,
)
async def delete(
diff --git a/src/asktable/resources/extapis/routes.py b/src/asktable/resources/extapis/routes.py
index 54a48eec..994f1cb4 100644
--- a/src/asktable/resources/extapis/routes.py
+++ b/src/asktable/resources/extapis/routes.py
@@ -23,7 +23,7 @@
)
from ..._base_client import make_request_options
from ...types.extapis import route_create_params, route_update_params
-from ...types.extapis.ext_api_route_model import ExtAPIRouteModel
+from ...types.extapis.extapi_route import ExtapiRoute
from ...types.extapis.route_list_response import RouteListResponse
__all__ = ["RoutesResource", "AsyncRoutesResource"]
@@ -70,7 +70,7 @@ def create(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> ExtAPIRouteModel:
+ ) -> ExtapiRoute:
"""
为某个 ExtAPI 创建新的路径
@@ -118,7 +118,7 @@ def create(
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
- cast_to=ExtAPIRouteModel,
+ cast_to=ExtapiRoute,
)
def retrieve(
@@ -132,7 +132,7 @@ def retrieve(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> ExtAPIRouteModel:
+ ) -> ExtapiRoute:
"""
获取某个 ExtAPI Route
@@ -154,7 +154,7 @@ def retrieve(
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
- cast_to=ExtAPIRouteModel,
+ cast_to=ExtapiRoute,
)
def update(
@@ -174,7 +174,7 @@ def update(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> ExtAPIRouteModel:
+ ) -> ExtapiRoute:
"""
更新某个 ExtAPI Route
@@ -219,7 +219,7 @@ def update(
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
- cast_to=ExtAPIRouteModel,
+ cast_to=ExtapiRoute,
)
def list(
@@ -334,7 +334,7 @@ async def create(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> ExtAPIRouteModel:
+ ) -> ExtapiRoute:
"""
为某个 ExtAPI 创建新的路径
@@ -382,7 +382,7 @@ async def create(
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
- cast_to=ExtAPIRouteModel,
+ cast_to=ExtapiRoute,
)
async def retrieve(
@@ -396,7 +396,7 @@ async def retrieve(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> ExtAPIRouteModel:
+ ) -> ExtapiRoute:
"""
获取某个 ExtAPI Route
@@ -418,7 +418,7 @@ async def retrieve(
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
- cast_to=ExtAPIRouteModel,
+ cast_to=ExtapiRoute,
)
async def update(
@@ -438,7 +438,7 @@ async def update(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> ExtAPIRouteModel:
+ ) -> ExtapiRoute:
"""
更新某个 ExtAPI Route
@@ -483,7 +483,7 @@ async def update(
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
- cast_to=ExtAPIRouteModel,
+ cast_to=ExtapiRoute,
)
async def list(
diff --git a/src/asktable/resources/integration/integration.py b/src/asktable/resources/integration.py
similarity index 63%
rename from src/asktable/resources/integration/integration.py
rename to src/asktable/resources/integration.py
index 2e9af94d..0e332418 100644
--- a/src/asktable/resources/integration/integration.py
+++ b/src/asktable/resources/integration.py
@@ -6,39 +6,28 @@
import httpx
-from ...types import integration_excel_csv_ask_params
-from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven
-from ..._utils import (
+from ..types import integration_excel_csv_ask_params, integration_create_excel_ds_params
+from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven
+from .._utils import (
maybe_transform,
async_maybe_transform,
)
-from ..._compat import cached_property
-from .excel_csv import (
- ExcelCsvResource,
- AsyncExcelCsvResource,
- ExcelCsvResourceWithRawResponse,
- AsyncExcelCsvResourceWithRawResponse,
- ExcelCsvResourceWithStreamingResponse,
- AsyncExcelCsvResourceWithStreamingResponse,
-)
-from ..._resource import SyncAPIResource, AsyncAPIResource
-from ..._response import (
+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.answer_data_source_out import AnswerDataSourceOut
+from .._base_client import make_request_options
+from ..types.datasource import Datasource
+from ..types.file_ask_response import FileAskResponse
__all__ = ["IntegrationResource", "AsyncIntegrationResource"]
class IntegrationResource(SyncAPIResource):
- @cached_property
- def excel_csv(self) -> ExcelCsvResource:
- return ExcelCsvResource(self._client)
-
@cached_property
def with_raw_response(self) -> IntegrationResourceWithRawResponse:
"""
@@ -58,6 +47,43 @@ def with_streaming_response(self) -> IntegrationResourceWithStreamingResponse:
"""
return IntegrationResourceWithStreamingResponse(self)
+ def create_excel_ds(
+ self,
+ *,
+ file_url: 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,
+ ) -> Datasource:
+ """
+ 通过 Excel/CSV 文件 URL 创建数据源
+
+ Args:
+ extra_headers: Send extra headers
+
+ extra_query: Add additional query parameters to the request
+
+ extra_body: Add additional JSON properties to the request
+
+ timeout: Override the client-level default timeout for this request, in seconds
+ """
+ return self._post(
+ "/integration/create_excel_ds",
+ options=make_request_options(
+ extra_headers=extra_headers,
+ extra_query=extra_query,
+ extra_body=extra_body,
+ timeout=timeout,
+ query=maybe_transform(
+ {"file_url": file_url}, integration_create_excel_ds_params.IntegrationCreateExcelDsParams
+ ),
+ ),
+ cast_to=Datasource,
+ )
+
def excel_csv_ask(
self,
*,
@@ -70,7 +96,7 @@ def excel_csv_ask(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> AnswerDataSourceOut:
+ ) -> FileAskResponse:
"""
通过 Excel/CSV 文件 URL 添加数据并提问
@@ -102,15 +128,11 @@ def excel_csv_ask(
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
- cast_to=AnswerDataSourceOut,
+ cast_to=FileAskResponse,
)
class AsyncIntegrationResource(AsyncAPIResource):
- @cached_property
- def excel_csv(self) -> AsyncExcelCsvResource:
- return AsyncExcelCsvResource(self._client)
-
@cached_property
def with_raw_response(self) -> AsyncIntegrationResourceWithRawResponse:
"""
@@ -130,6 +152,43 @@ def with_streaming_response(self) -> AsyncIntegrationResourceWithStreamingRespon
"""
return AsyncIntegrationResourceWithStreamingResponse(self)
+ async def create_excel_ds(
+ self,
+ *,
+ file_url: 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,
+ ) -> Datasource:
+ """
+ 通过 Excel/CSV 文件 URL 创建数据源
+
+ Args:
+ extra_headers: Send extra headers
+
+ extra_query: Add additional query parameters to the request
+
+ extra_body: Add additional JSON properties to the request
+
+ timeout: Override the client-level default timeout for this request, in seconds
+ """
+ return await self._post(
+ "/integration/create_excel_ds",
+ options=make_request_options(
+ extra_headers=extra_headers,
+ extra_query=extra_query,
+ extra_body=extra_body,
+ timeout=timeout,
+ query=await async_maybe_transform(
+ {"file_url": file_url}, integration_create_excel_ds_params.IntegrationCreateExcelDsParams
+ ),
+ ),
+ cast_to=Datasource,
+ )
+
async def excel_csv_ask(
self,
*,
@@ -142,7 +201,7 @@ async def excel_csv_ask(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> AnswerDataSourceOut:
+ ) -> FileAskResponse:
"""
通过 Excel/CSV 文件 URL 添加数据并提问
@@ -174,7 +233,7 @@ async def excel_csv_ask(
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
- cast_to=AnswerDataSourceOut,
+ cast_to=FileAskResponse,
)
@@ -182,49 +241,45 @@ class IntegrationResourceWithRawResponse:
def __init__(self, integration: IntegrationResource) -> None:
self._integration = integration
+ self.create_excel_ds = to_raw_response_wrapper(
+ integration.create_excel_ds,
+ )
self.excel_csv_ask = to_raw_response_wrapper(
integration.excel_csv_ask,
)
- @cached_property
- def excel_csv(self) -> ExcelCsvResourceWithRawResponse:
- return ExcelCsvResourceWithRawResponse(self._integration.excel_csv)
-
class AsyncIntegrationResourceWithRawResponse:
def __init__(self, integration: AsyncIntegrationResource) -> None:
self._integration = integration
+ self.create_excel_ds = async_to_raw_response_wrapper(
+ integration.create_excel_ds,
+ )
self.excel_csv_ask = async_to_raw_response_wrapper(
integration.excel_csv_ask,
)
- @cached_property
- def excel_csv(self) -> AsyncExcelCsvResourceWithRawResponse:
- return AsyncExcelCsvResourceWithRawResponse(self._integration.excel_csv)
-
class IntegrationResourceWithStreamingResponse:
def __init__(self, integration: IntegrationResource) -> None:
self._integration = integration
+ self.create_excel_ds = to_streamed_response_wrapper(
+ integration.create_excel_ds,
+ )
self.excel_csv_ask = to_streamed_response_wrapper(
integration.excel_csv_ask,
)
- @cached_property
- def excel_csv(self) -> ExcelCsvResourceWithStreamingResponse:
- return ExcelCsvResourceWithStreamingResponse(self._integration.excel_csv)
-
class AsyncIntegrationResourceWithStreamingResponse:
def __init__(self, integration: AsyncIntegrationResource) -> None:
self._integration = integration
+ self.create_excel_ds = async_to_streamed_response_wrapper(
+ integration.create_excel_ds,
+ )
self.excel_csv_ask = async_to_streamed_response_wrapper(
integration.excel_csv_ask,
)
-
- @cached_property
- def excel_csv(self) -> AsyncExcelCsvResourceWithStreamingResponse:
- return AsyncExcelCsvResourceWithStreamingResponse(self._integration.excel_csv)
diff --git a/src/asktable/resources/integration/__init__.py b/src/asktable/resources/integration/__init__.py
deleted file mode 100644
index 1020e8b6..00000000
--- a/src/asktable/resources/integration/__init__.py
+++ /dev/null
@@ -1,33 +0,0 @@
-# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-
-from .excel_csv import (
- ExcelCsvResource,
- AsyncExcelCsvResource,
- ExcelCsvResourceWithRawResponse,
- AsyncExcelCsvResourceWithRawResponse,
- ExcelCsvResourceWithStreamingResponse,
- AsyncExcelCsvResourceWithStreamingResponse,
-)
-from .integration import (
- IntegrationResource,
- AsyncIntegrationResource,
- IntegrationResourceWithRawResponse,
- AsyncIntegrationResourceWithRawResponse,
- IntegrationResourceWithStreamingResponse,
- AsyncIntegrationResourceWithStreamingResponse,
-)
-
-__all__ = [
- "ExcelCsvResource",
- "AsyncExcelCsvResource",
- "ExcelCsvResourceWithRawResponse",
- "AsyncExcelCsvResourceWithRawResponse",
- "ExcelCsvResourceWithStreamingResponse",
- "AsyncExcelCsvResourceWithStreamingResponse",
- "IntegrationResource",
- "AsyncIntegrationResource",
- "IntegrationResourceWithRawResponse",
- "AsyncIntegrationResourceWithRawResponse",
- "IntegrationResourceWithStreamingResponse",
- "AsyncIntegrationResourceWithStreamingResponse",
-]
diff --git a/src/asktable/resources/integration/excel_csv.py b/src/asktable/resources/integration/excel_csv.py
deleted file mode 100644
index f6795a15..00000000
--- a/src/asktable/resources/integration/excel_csv.py
+++ /dev/null
@@ -1,172 +0,0 @@
-# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-
-from __future__ import annotations
-
-import httpx
-
-from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven
-from ..._utils import (
- maybe_transform,
- async_maybe_transform,
-)
-from ..._compat import cached_property
-from ..._resource import SyncAPIResource, AsyncAPIResource
-from ..._response import (
- to_raw_response_wrapper,
- to_streamed_response_wrapper,
- async_to_raw_response_wrapper,
- async_to_streamed_response_wrapper,
-)
-from ..._base_client import make_request_options
-from ...types.data_source import DataSource
-from ...types.integration import excel_csv_create_params
-
-__all__ = ["ExcelCsvResource", "AsyncExcelCsvResource"]
-
-
-class ExcelCsvResource(SyncAPIResource):
- @cached_property
- def with_raw_response(self) -> ExcelCsvResourceWithRawResponse:
- """
- This property can be used as a prefix for any HTTP method call to return the
- 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 ExcelCsvResourceWithRawResponse(self)
-
- @cached_property
- def with_streaming_response(self) -> ExcelCsvResourceWithStreamingResponse:
- """
- 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 ExcelCsvResourceWithStreamingResponse(self)
-
- def create(
- self,
- *,
- file_url: 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,
- ) -> DataSource:
- """
- 通过 Excel/CSV 文件 URL 创建数据源
-
- Args:
- extra_headers: Send extra headers
-
- extra_query: Add additional query parameters to the request
-
- extra_body: Add additional JSON properties to the request
-
- timeout: Override the client-level default timeout for this request, in seconds
- """
- return self._post(
- "/integration/create_excel_ds",
- options=make_request_options(
- extra_headers=extra_headers,
- extra_query=extra_query,
- extra_body=extra_body,
- timeout=timeout,
- query=maybe_transform({"file_url": file_url}, excel_csv_create_params.ExcelCsvCreateParams),
- ),
- cast_to=DataSource,
- )
-
-
-class AsyncExcelCsvResource(AsyncAPIResource):
- @cached_property
- def with_raw_response(self) -> AsyncExcelCsvResourceWithRawResponse:
- """
- This property can be used as a prefix for any HTTP method call to return the
- 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 AsyncExcelCsvResourceWithRawResponse(self)
-
- @cached_property
- def with_streaming_response(self) -> AsyncExcelCsvResourceWithStreamingResponse:
- """
- 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 AsyncExcelCsvResourceWithStreamingResponse(self)
-
- async def create(
- self,
- *,
- file_url: 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,
- ) -> DataSource:
- """
- 通过 Excel/CSV 文件 URL 创建数据源
-
- Args:
- extra_headers: Send extra headers
-
- extra_query: Add additional query parameters to the request
-
- extra_body: Add additional JSON properties to the request
-
- timeout: Override the client-level default timeout for this request, in seconds
- """
- return await self._post(
- "/integration/create_excel_ds",
- options=make_request_options(
- extra_headers=extra_headers,
- extra_query=extra_query,
- extra_body=extra_body,
- timeout=timeout,
- query=await async_maybe_transform({"file_url": file_url}, excel_csv_create_params.ExcelCsvCreateParams),
- ),
- cast_to=DataSource,
- )
-
-
-class ExcelCsvResourceWithRawResponse:
- def __init__(self, excel_csv: ExcelCsvResource) -> None:
- self._excel_csv = excel_csv
-
- self.create = to_raw_response_wrapper(
- excel_csv.create,
- )
-
-
-class AsyncExcelCsvResourceWithRawResponse:
- def __init__(self, excel_csv: AsyncExcelCsvResource) -> None:
- self._excel_csv = excel_csv
-
- self.create = async_to_raw_response_wrapper(
- excel_csv.create,
- )
-
-
-class ExcelCsvResourceWithStreamingResponse:
- def __init__(self, excel_csv: ExcelCsvResource) -> None:
- self._excel_csv = excel_csv
-
- self.create = to_streamed_response_wrapper(
- excel_csv.create,
- )
-
-
-class AsyncExcelCsvResourceWithStreamingResponse:
- def __init__(self, excel_csv: AsyncExcelCsvResource) -> None:
- self._excel_csv = excel_csv
-
- self.create = async_to_streamed_response_wrapper(
- excel_csv.create,
- )
diff --git a/src/asktable/resources/policies.py b/src/asktable/resources/policies.py
index ce990cce..638787a2 100644
--- a/src/asktable/resources/policies.py
+++ b/src/asktable/resources/policies.py
@@ -21,9 +21,9 @@
async_to_raw_response_wrapper,
async_to_streamed_response_wrapper,
)
-from .._base_client import make_request_options
+from ..pagination import SyncPage, AsyncPage
+from .._base_client import AsyncPaginator, make_request_options
from ..types.shared.policy import Policy
-from ..types.policy_list_response import PolicyListResponse
__all__ = ["PoliciesResource", "AsyncPoliciesResource"]
@@ -191,7 +191,7 @@ def list(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> PolicyListResponse:
+ ) -> SyncPage[Policy]:
"""
查询所有策略
@@ -212,8 +212,9 @@ def list(
timeout: Override the client-level default timeout for this request, in seconds
"""
- return self._get(
+ return self._get_api_list(
"/policies",
+ page=SyncPage[Policy],
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
@@ -229,7 +230,7 @@ def list(
policy_list_params.PolicyListParams,
),
),
- cast_to=PolicyListResponse,
+ model=Policy,
)
def delete(
@@ -417,7 +418,7 @@ async def update(
cast_to=Policy,
)
- async def list(
+ def list(
self,
*,
name: Optional[str] | NotGiven = NOT_GIVEN,
@@ -430,7 +431,7 @@ async def list(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> PolicyListResponse:
+ ) -> AsyncPaginator[Policy, AsyncPage[Policy]]:
"""
查询所有策略
@@ -451,14 +452,15 @@ async def list(
timeout: Override the client-level default timeout for this request, in seconds
"""
- return await self._get(
+ return self._get_api_list(
"/policies",
+ page=AsyncPage[Policy],
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
- query=await async_maybe_transform(
+ query=maybe_transform(
{
"name": name,
"page": page,
@@ -468,7 +470,7 @@ async def list(
policy_list_params.PolicyListParams,
),
),
- cast_to=PolicyListResponse,
+ model=Policy,
)
async def delete(
diff --git a/src/asktable/resources/roles/roles.py b/src/asktable/resources/roles.py
similarity index 71%
rename from src/asktable/resources/roles/roles.py
rename to src/asktable/resources/roles.py
index 3574a50e..eea360f5 100644
--- a/src/asktable/resources/roles/roles.py
+++ b/src/asktable/resources/roles.py
@@ -6,52 +6,29 @@
import httpx
-from ...types import role_list_params, role_create_params, role_update_params
-from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven
-from ..._utils import (
+from ..types import role_list_params, role_create_params, role_update_params, role_get_variables_params
+from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven
+from .._utils import (
maybe_transform,
async_maybe_transform,
)
-from .policies import (
- PoliciesResource,
- AsyncPoliciesResource,
- PoliciesResourceWithRawResponse,
- AsyncPoliciesResourceWithRawResponse,
- PoliciesResourceWithStreamingResponse,
- AsyncPoliciesResourceWithStreamingResponse,
-)
-from ..._compat import cached_property
-from .variables import (
- VariablesResource,
- AsyncVariablesResource,
- VariablesResourceWithRawResponse,
- AsyncVariablesResourceWithRawResponse,
- VariablesResourceWithStreamingResponse,
- AsyncVariablesResourceWithStreamingResponse,
-)
-from ..._resource import SyncAPIResource, AsyncAPIResource
-from ..._response import (
+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 ...types.role import Role
-from ..._base_client import make_request_options
-from ...types.role_list_response import RoleListResponse
+from ..pagination import SyncPage, AsyncPage
+from ..types.role import Role
+from .._base_client import AsyncPaginator, make_request_options
+from ..types.role_get_polices_response import RoleGetPolicesResponse
__all__ = ["RolesResource", "AsyncRolesResource"]
class RolesResource(SyncAPIResource):
- @cached_property
- def policies(self) -> PoliciesResource:
- return PoliciesResource(self._client)
-
- @cached_property
- def variables(self) -> VariablesResource:
- return VariablesResource(self._client)
-
@cached_property
def with_raw_response(self) -> RolesResourceWithRawResponse:
"""
@@ -206,7 +183,7 @@ def list(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> RoleListResponse:
+ ) -> SyncPage[Role]:
"""
查询所有的角色
@@ -227,8 +204,9 @@ def list(
timeout: Override the client-level default timeout for this request, in seconds
"""
- return self._get(
+ return self._get_api_list(
"/roles",
+ page=SyncPage[Role],
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
@@ -244,7 +222,7 @@ def list(
role_list_params.RoleListParams,
),
),
- cast_to=RoleListResponse,
+ model=Role,
)
def delete(
@@ -280,16 +258,90 @@ def delete(
cast_to=object,
)
+ def get_polices(
+ self,
+ role_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,
+ ) -> RoleGetPolicesResponse:
+ """
+ 查询某个角色的所有策略
-class AsyncRolesResource(AsyncAPIResource):
- @cached_property
- def policies(self) -> AsyncPoliciesResource:
- return AsyncPoliciesResource(self._client)
+ Args:
+ extra_headers: Send extra headers
- @cached_property
- def variables(self) -> AsyncVariablesResource:
- return AsyncVariablesResource(self._client)
+ 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 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",
+ options=make_request_options(
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
+ ),
+ cast_to=RoleGetPolicesResponse,
+ )
+
+ def get_variables(
+ self,
+ role_id: str,
+ *,
+ bot_id: Optional[str] | NotGiven = NOT_GIVEN,
+ datasource_ids: Optional[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,
+ extra_query: Query | None = None,
+ extra_body: Body | None = None,
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
+ ) -> object:
+ """
+ 查询某个角色的所有变量
+
+ Args:
+ bot_id: Bot ID
+
+ datasource_ids: 数据源 ID 列表
+
+ 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 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",
+ options=make_request_options(
+ extra_headers=extra_headers,
+ extra_query=extra_query,
+ extra_body=extra_body,
+ timeout=timeout,
+ query=maybe_transform(
+ {
+ "bot_id": bot_id,
+ "datasource_ids": datasource_ids,
+ },
+ role_get_variables_params.RoleGetVariablesParams,
+ ),
+ ),
+ cast_to=object,
+ )
+
+
+class AsyncRolesResource(AsyncAPIResource):
@cached_property
def with_raw_response(self) -> AsyncRolesResourceWithRawResponse:
"""
@@ -431,7 +483,7 @@ async def update(
cast_to=Role,
)
- async def list(
+ def list(
self,
*,
name: Optional[str] | NotGiven = NOT_GIVEN,
@@ -444,7 +496,7 @@ async def list(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> RoleListResponse:
+ ) -> AsyncPaginator[Role, AsyncPage[Role]]:
"""
查询所有的角色
@@ -465,14 +517,15 @@ async def list(
timeout: Override the client-level default timeout for this request, in seconds
"""
- return await self._get(
+ return self._get_api_list(
"/roles",
+ page=AsyncPage[Role],
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
- query=await async_maybe_transform(
+ query=maybe_transform(
{
"name": name,
"page": page,
@@ -482,7 +535,7 @@ async def list(
role_list_params.RoleListParams,
),
),
- cast_to=RoleListResponse,
+ model=Role,
)
async def delete(
@@ -518,6 +571,88 @@ async def delete(
cast_to=object,
)
+ async def get_polices(
+ self,
+ role_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,
+ ) -> RoleGetPolicesResponse:
+ """
+ 查询某个角色的所有策略
+
+ 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 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",
+ options=make_request_options(
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
+ ),
+ cast_to=RoleGetPolicesResponse,
+ )
+
+ async def get_variables(
+ self,
+ role_id: str,
+ *,
+ bot_id: Optional[str] | NotGiven = NOT_GIVEN,
+ datasource_ids: Optional[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,
+ extra_query: Query | None = None,
+ extra_body: Body | None = None,
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
+ ) -> object:
+ """
+ 查询某个角色的所有变量
+
+ Args:
+ bot_id: Bot ID
+
+ datasource_ids: 数据源 ID 列表
+
+ 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 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",
+ options=make_request_options(
+ extra_headers=extra_headers,
+ extra_query=extra_query,
+ extra_body=extra_body,
+ timeout=timeout,
+ query=await async_maybe_transform(
+ {
+ "bot_id": bot_id,
+ "datasource_ids": datasource_ids,
+ },
+ role_get_variables_params.RoleGetVariablesParams,
+ ),
+ ),
+ cast_to=object,
+ )
+
class RolesResourceWithRawResponse:
def __init__(self, roles: RolesResource) -> None:
@@ -538,14 +673,12 @@ def __init__(self, roles: RolesResource) -> None:
self.delete = to_raw_response_wrapper(
roles.delete,
)
-
- @cached_property
- def policies(self) -> PoliciesResourceWithRawResponse:
- return PoliciesResourceWithRawResponse(self._roles.policies)
-
- @cached_property
- def variables(self) -> VariablesResourceWithRawResponse:
- return VariablesResourceWithRawResponse(self._roles.variables)
+ self.get_polices = to_raw_response_wrapper(
+ roles.get_polices,
+ )
+ self.get_variables = to_raw_response_wrapper(
+ roles.get_variables,
+ )
class AsyncRolesResourceWithRawResponse:
@@ -567,14 +700,12 @@ def __init__(self, roles: AsyncRolesResource) -> None:
self.delete = async_to_raw_response_wrapper(
roles.delete,
)
-
- @cached_property
- def policies(self) -> AsyncPoliciesResourceWithRawResponse:
- return AsyncPoliciesResourceWithRawResponse(self._roles.policies)
-
- @cached_property
- def variables(self) -> AsyncVariablesResourceWithRawResponse:
- return AsyncVariablesResourceWithRawResponse(self._roles.variables)
+ self.get_polices = async_to_raw_response_wrapper(
+ roles.get_polices,
+ )
+ self.get_variables = async_to_raw_response_wrapper(
+ roles.get_variables,
+ )
class RolesResourceWithStreamingResponse:
@@ -596,14 +727,12 @@ def __init__(self, roles: RolesResource) -> None:
self.delete = to_streamed_response_wrapper(
roles.delete,
)
-
- @cached_property
- def policies(self) -> PoliciesResourceWithStreamingResponse:
- return PoliciesResourceWithStreamingResponse(self._roles.policies)
-
- @cached_property
- def variables(self) -> VariablesResourceWithStreamingResponse:
- return VariablesResourceWithStreamingResponse(self._roles.variables)
+ self.get_polices = to_streamed_response_wrapper(
+ roles.get_polices,
+ )
+ self.get_variables = to_streamed_response_wrapper(
+ roles.get_variables,
+ )
class AsyncRolesResourceWithStreamingResponse:
@@ -625,11 +754,9 @@ def __init__(self, roles: AsyncRolesResource) -> None:
self.delete = async_to_streamed_response_wrapper(
roles.delete,
)
-
- @cached_property
- def policies(self) -> AsyncPoliciesResourceWithStreamingResponse:
- return AsyncPoliciesResourceWithStreamingResponse(self._roles.policies)
-
- @cached_property
- def variables(self) -> AsyncVariablesResourceWithStreamingResponse:
- return AsyncVariablesResourceWithStreamingResponse(self._roles.variables)
+ self.get_polices = async_to_streamed_response_wrapper(
+ roles.get_polices,
+ )
+ self.get_variables = async_to_streamed_response_wrapper(
+ roles.get_variables,
+ )
diff --git a/src/asktable/resources/roles/__init__.py b/src/asktable/resources/roles/__init__.py
deleted file mode 100644
index d1c6b25d..00000000
--- a/src/asktable/resources/roles/__init__.py
+++ /dev/null
@@ -1,47 +0,0 @@
-# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-
-from .roles import (
- RolesResource,
- AsyncRolesResource,
- RolesResourceWithRawResponse,
- AsyncRolesResourceWithRawResponse,
- RolesResourceWithStreamingResponse,
- AsyncRolesResourceWithStreamingResponse,
-)
-from .policies import (
- PoliciesResource,
- AsyncPoliciesResource,
- PoliciesResourceWithRawResponse,
- AsyncPoliciesResourceWithRawResponse,
- PoliciesResourceWithStreamingResponse,
- AsyncPoliciesResourceWithStreamingResponse,
-)
-from .variables import (
- VariablesResource,
- AsyncVariablesResource,
- VariablesResourceWithRawResponse,
- AsyncVariablesResourceWithRawResponse,
- VariablesResourceWithStreamingResponse,
- AsyncVariablesResourceWithStreamingResponse,
-)
-
-__all__ = [
- "PoliciesResource",
- "AsyncPoliciesResource",
- "PoliciesResourceWithRawResponse",
- "AsyncPoliciesResourceWithRawResponse",
- "PoliciesResourceWithStreamingResponse",
- "AsyncPoliciesResourceWithStreamingResponse",
- "VariablesResource",
- "AsyncVariablesResource",
- "VariablesResourceWithRawResponse",
- "AsyncVariablesResourceWithRawResponse",
- "VariablesResourceWithStreamingResponse",
- "AsyncVariablesResourceWithStreamingResponse",
- "RolesResource",
- "AsyncRolesResource",
- "RolesResourceWithRawResponse",
- "AsyncRolesResourceWithRawResponse",
- "RolesResourceWithStreamingResponse",
- "AsyncRolesResourceWithStreamingResponse",
-]
diff --git a/src/asktable/resources/roles/variables.py b/src/asktable/resources/roles/variables.py
deleted file mode 100644
index ec2ec5a8..00000000
--- a/src/asktable/resources/roles/variables.py
+++ /dev/null
@@ -1,201 +0,0 @@
-# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-
-from __future__ import annotations
-
-from typing import List, Optional
-
-import httpx
-
-from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven
-from ..._utils import (
- maybe_transform,
- async_maybe_transform,
-)
-from ..._compat import cached_property
-from ..._resource import SyncAPIResource, AsyncAPIResource
-from ..._response import (
- to_raw_response_wrapper,
- to_streamed_response_wrapper,
- async_to_raw_response_wrapper,
- async_to_streamed_response_wrapper,
-)
-from ...types.roles import variable_list_params
-from ..._base_client import make_request_options
-
-__all__ = ["VariablesResource", "AsyncVariablesResource"]
-
-
-class VariablesResource(SyncAPIResource):
- @cached_property
- def with_raw_response(self) -> VariablesResourceWithRawResponse:
- """
- This property can be used as a prefix for any HTTP method call to return the
- 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 VariablesResourceWithRawResponse(self)
-
- @cached_property
- def with_streaming_response(self) -> VariablesResourceWithStreamingResponse:
- """
- 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 VariablesResourceWithStreamingResponse(self)
-
- def list(
- self,
- role_id: str,
- *,
- bot_id: Optional[str] | NotGiven = NOT_GIVEN,
- datasource_ids: Optional[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,
- extra_query: Query | None = None,
- extra_body: Body | None = None,
- timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> object:
- """
- 查询某个角色的所有变量
-
- Args:
- bot_id: Bot ID
-
- datasource_ids: 数据源 ID 列表
-
- 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 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",
- options=make_request_options(
- extra_headers=extra_headers,
- extra_query=extra_query,
- extra_body=extra_body,
- timeout=timeout,
- query=maybe_transform(
- {
- "bot_id": bot_id,
- "datasource_ids": datasource_ids,
- },
- variable_list_params.VariableListParams,
- ),
- ),
- cast_to=object,
- )
-
-
-class AsyncVariablesResource(AsyncAPIResource):
- @cached_property
- def with_raw_response(self) -> AsyncVariablesResourceWithRawResponse:
- """
- This property can be used as a prefix for any HTTP method call to return the
- 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 AsyncVariablesResourceWithRawResponse(self)
-
- @cached_property
- def with_streaming_response(self) -> AsyncVariablesResourceWithStreamingResponse:
- """
- 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 AsyncVariablesResourceWithStreamingResponse(self)
-
- async def list(
- self,
- role_id: str,
- *,
- bot_id: Optional[str] | NotGiven = NOT_GIVEN,
- datasource_ids: Optional[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,
- extra_query: Query | None = None,
- extra_body: Body | None = None,
- timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> object:
- """
- 查询某个角色的所有变量
-
- Args:
- bot_id: Bot ID
-
- datasource_ids: 数据源 ID 列表
-
- 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 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",
- options=make_request_options(
- extra_headers=extra_headers,
- extra_query=extra_query,
- extra_body=extra_body,
- timeout=timeout,
- query=await async_maybe_transform(
- {
- "bot_id": bot_id,
- "datasource_ids": datasource_ids,
- },
- variable_list_params.VariableListParams,
- ),
- ),
- cast_to=object,
- )
-
-
-class VariablesResourceWithRawResponse:
- def __init__(self, variables: VariablesResource) -> None:
- self._variables = variables
-
- self.list = to_raw_response_wrapper(
- variables.list,
- )
-
-
-class AsyncVariablesResourceWithRawResponse:
- def __init__(self, variables: AsyncVariablesResource) -> None:
- self._variables = variables
-
- self.list = async_to_raw_response_wrapper(
- variables.list,
- )
-
-
-class VariablesResourceWithStreamingResponse:
- def __init__(self, variables: VariablesResource) -> None:
- self._variables = variables
-
- self.list = to_streamed_response_wrapper(
- variables.list,
- )
-
-
-class AsyncVariablesResourceWithStreamingResponse:
- def __init__(self, variables: AsyncVariablesResource) -> None:
- self._variables = variables
-
- self.list = async_to_streamed_response_wrapper(
- variables.list,
- )
diff --git a/src/asktable/resources/securetunnels/securetunnels.py b/src/asktable/resources/securetunnels.py
similarity index 78%
rename from src/asktable/resources/securetunnels/securetunnels.py
rename to src/asktable/resources/securetunnels.py
index d7da912a..ed5b8198 100644
--- a/src/asktable/resources/securetunnels/securetunnels.py
+++ b/src/asktable/resources/securetunnels.py
@@ -6,40 +6,34 @@
import httpx
-from .links import (
- LinksResource,
- AsyncLinksResource,
- LinksResourceWithRawResponse,
- AsyncLinksResourceWithRawResponse,
- LinksResourceWithStreamingResponse,
- AsyncLinksResourceWithStreamingResponse,
+from ..types import (
+ securetunnel_list_params,
+ securetunnel_create_params,
+ securetunnel_update_params,
+ securetunnel_list_links_params,
)
-from ...types import securetunnel_list_params, securetunnel_create_params, securetunnel_update_params
-from ..._types import NOT_GIVEN, Body, Query, Headers, NoneType, NotGiven
-from ..._utils import (
+from .._types import NOT_GIVEN, Body, Query, Headers, NoneType, NotGiven
+from .._utils import (
maybe_transform,
async_maybe_transform,
)
-from ..._compat import cached_property
-from ..._resource import SyncAPIResource, AsyncAPIResource
-from ..._response import (
+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.secure_tunnel import SecureTunnel
-from ...types.securetunnel_list_response import SecuretunnelListResponse
+from ..pagination import SyncPage, AsyncPage
+from .._base_client import AsyncPaginator, make_request_options
+from ..types.secure_tunnel import SecureTunnel
+from ..types.securetunnel_list_links_response import SecuretunnelListLinksResponse
__all__ = ["SecuretunnelsResource", "AsyncSecuretunnelsResource"]
class SecuretunnelsResource(SyncAPIResource):
- @cached_property
- def links(self) -> LinksResource:
- return LinksResource(self._client)
-
@cached_property
def with_raw_response(self) -> SecuretunnelsResourceWithRawResponse:
"""
@@ -139,7 +133,7 @@ def update(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> object:
+ ) -> SecureTunnel:
"""
更新某个 ATST
@@ -173,7 +167,7 @@ def update(
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
- cast_to=object,
+ cast_to=SecureTunnel,
)
def list(
@@ -187,7 +181,7 @@ def list(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> SecuretunnelListResponse:
+ ) -> SyncPage[SecureTunnel]:
"""
查询安全隧道列表
@@ -204,8 +198,9 @@ def list(
timeout: Override the client-level default timeout for this request, in seconds
"""
- return self._get(
+ return self._get_api_list(
"/securetunnels",
+ page=SyncPage[SecureTunnel],
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
@@ -219,7 +214,7 @@ def list(
securetunnel_list_params.SecuretunnelListParams,
),
),
- cast_to=SecuretunnelListResponse,
+ model=SecureTunnel,
)
def delete(
@@ -256,12 +251,58 @@ def delete(
cast_to=NoneType,
)
+ def list_links(
+ self,
+ securetunnel_id: str,
+ *,
+ page: int | NotGiven = NOT_GIVEN,
+ size: int | NotGiven = NOT_GIVEN,
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
+ # The extra values given here take precedence over values defined on the client or passed to this method.
+ extra_headers: Headers | None = None,
+ extra_query: Query | None = None,
+ extra_body: Body | None = None,
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
+ ) -> SyncPage[SecuretunnelListLinksResponse]:
+ """
+ 查询安全隧道的所有 Link
-class AsyncSecuretunnelsResource(AsyncAPIResource):
- @cached_property
- def links(self) -> AsyncLinksResource:
- return AsyncLinksResource(self._client)
+ Args:
+ page: Page number
+
+ size: Page size
+
+ 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 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",
+ page=SyncPage[SecuretunnelListLinksResponse],
+ options=make_request_options(
+ extra_headers=extra_headers,
+ extra_query=extra_query,
+ extra_body=extra_body,
+ timeout=timeout,
+ query=maybe_transform(
+ {
+ "page": page,
+ "size": size,
+ },
+ securetunnel_list_links_params.SecuretunnelListLinksParams,
+ ),
+ ),
+ model=SecuretunnelListLinksResponse,
+ )
+
+
+class AsyncSecuretunnelsResource(AsyncAPIResource):
@cached_property
def with_raw_response(self) -> AsyncSecuretunnelsResourceWithRawResponse:
"""
@@ -361,7 +402,7 @@ async def update(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> object:
+ ) -> SecureTunnel:
"""
更新某个 ATST
@@ -395,10 +436,10 @@ async def update(
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
- cast_to=object,
+ cast_to=SecureTunnel,
)
- async def list(
+ def list(
self,
*,
page: int | NotGiven = NOT_GIVEN,
@@ -409,7 +450,7 @@ async def list(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> SecuretunnelListResponse:
+ ) -> AsyncPaginator[SecureTunnel, AsyncPage[SecureTunnel]]:
"""
查询安全隧道列表
@@ -426,14 +467,15 @@ async def list(
timeout: Override the client-level default timeout for this request, in seconds
"""
- return await self._get(
+ return self._get_api_list(
"/securetunnels",
+ page=AsyncPage[SecureTunnel],
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
- query=await async_maybe_transform(
+ query=maybe_transform(
{
"page": page,
"size": size,
@@ -441,7 +483,7 @@ async def list(
securetunnel_list_params.SecuretunnelListParams,
),
),
- cast_to=SecuretunnelListResponse,
+ model=SecureTunnel,
)
async def delete(
@@ -478,6 +520,56 @@ async def delete(
cast_to=NoneType,
)
+ def list_links(
+ self,
+ securetunnel_id: str,
+ *,
+ page: int | NotGiven = NOT_GIVEN,
+ size: int | NotGiven = NOT_GIVEN,
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
+ # The extra values given here take precedence over values defined on the client or passed to this method.
+ extra_headers: Headers | None = None,
+ extra_query: Query | None = None,
+ extra_body: Body | None = None,
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
+ ) -> AsyncPaginator[SecuretunnelListLinksResponse, AsyncPage[SecuretunnelListLinksResponse]]:
+ """
+ 查询安全隧道的所有 Link
+
+ Args:
+ page: Page number
+
+ size: Page size
+
+ 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 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",
+ page=AsyncPage[SecuretunnelListLinksResponse],
+ options=make_request_options(
+ extra_headers=extra_headers,
+ extra_query=extra_query,
+ extra_body=extra_body,
+ timeout=timeout,
+ query=maybe_transform(
+ {
+ "page": page,
+ "size": size,
+ },
+ securetunnel_list_links_params.SecuretunnelListLinksParams,
+ ),
+ ),
+ model=SecuretunnelListLinksResponse,
+ )
+
class SecuretunnelsResourceWithRawResponse:
def __init__(self, securetunnels: SecuretunnelsResource) -> None:
@@ -498,10 +590,9 @@ def __init__(self, securetunnels: SecuretunnelsResource) -> None:
self.delete = to_raw_response_wrapper(
securetunnels.delete,
)
-
- @cached_property
- def links(self) -> LinksResourceWithRawResponse:
- return LinksResourceWithRawResponse(self._securetunnels.links)
+ self.list_links = to_raw_response_wrapper(
+ securetunnels.list_links,
+ )
class AsyncSecuretunnelsResourceWithRawResponse:
@@ -523,10 +614,9 @@ def __init__(self, securetunnels: AsyncSecuretunnelsResource) -> None:
self.delete = async_to_raw_response_wrapper(
securetunnels.delete,
)
-
- @cached_property
- def links(self) -> AsyncLinksResourceWithRawResponse:
- return AsyncLinksResourceWithRawResponse(self._securetunnels.links)
+ self.list_links = async_to_raw_response_wrapper(
+ securetunnels.list_links,
+ )
class SecuretunnelsResourceWithStreamingResponse:
@@ -548,10 +638,9 @@ def __init__(self, securetunnels: SecuretunnelsResource) -> None:
self.delete = to_streamed_response_wrapper(
securetunnels.delete,
)
-
- @cached_property
- def links(self) -> LinksResourceWithStreamingResponse:
- return LinksResourceWithStreamingResponse(self._securetunnels.links)
+ self.list_links = to_streamed_response_wrapper(
+ securetunnels.list_links,
+ )
class AsyncSecuretunnelsResourceWithStreamingResponse:
@@ -573,7 +662,6 @@ def __init__(self, securetunnels: AsyncSecuretunnelsResource) -> None:
self.delete = async_to_streamed_response_wrapper(
securetunnels.delete,
)
-
- @cached_property
- def links(self) -> AsyncLinksResourceWithStreamingResponse:
- return AsyncLinksResourceWithStreamingResponse(self._securetunnels.links)
+ self.list_links = async_to_streamed_response_wrapper(
+ securetunnels.list_links,
+ )
diff --git a/src/asktable/resources/securetunnels/__init__.py b/src/asktable/resources/securetunnels/__init__.py
deleted file mode 100644
index 8bd1d4e6..00000000
--- a/src/asktable/resources/securetunnels/__init__.py
+++ /dev/null
@@ -1,33 +0,0 @@
-# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-
-from .links import (
- LinksResource,
- AsyncLinksResource,
- LinksResourceWithRawResponse,
- AsyncLinksResourceWithRawResponse,
- LinksResourceWithStreamingResponse,
- AsyncLinksResourceWithStreamingResponse,
-)
-from .securetunnels import (
- SecuretunnelsResource,
- AsyncSecuretunnelsResource,
- SecuretunnelsResourceWithRawResponse,
- AsyncSecuretunnelsResourceWithRawResponse,
- SecuretunnelsResourceWithStreamingResponse,
- AsyncSecuretunnelsResourceWithStreamingResponse,
-)
-
-__all__ = [
- "LinksResource",
- "AsyncLinksResource",
- "LinksResourceWithRawResponse",
- "AsyncLinksResourceWithRawResponse",
- "LinksResourceWithStreamingResponse",
- "AsyncLinksResourceWithStreamingResponse",
- "SecuretunnelsResource",
- "AsyncSecuretunnelsResource",
- "SecuretunnelsResourceWithRawResponse",
- "AsyncSecuretunnelsResourceWithRawResponse",
- "SecuretunnelsResourceWithStreamingResponse",
- "AsyncSecuretunnelsResourceWithStreamingResponse",
-]
diff --git a/src/asktable/resources/securetunnels/links.py b/src/asktable/resources/securetunnels/links.py
deleted file mode 100644
index 9976b714..00000000
--- a/src/asktable/resources/securetunnels/links.py
+++ /dev/null
@@ -1,200 +0,0 @@
-# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-
-from __future__ import annotations
-
-import httpx
-
-from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven
-from ..._utils import (
- maybe_transform,
- async_maybe_transform,
-)
-from ..._compat import cached_property
-from ..._resource import SyncAPIResource, AsyncAPIResource
-from ..._response import (
- to_raw_response_wrapper,
- to_streamed_response_wrapper,
- async_to_raw_response_wrapper,
- async_to_streamed_response_wrapper,
-)
-from ..._base_client import make_request_options
-from ...types.securetunnels import link_list_params
-from ...types.securetunnels.secure_tunnel_link import SecureTunnelLink
-
-__all__ = ["LinksResource", "AsyncLinksResource"]
-
-
-class LinksResource(SyncAPIResource):
- @cached_property
- def with_raw_response(self) -> LinksResourceWithRawResponse:
- """
- This property can be used as a prefix for any HTTP method call to return the
- 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 LinksResourceWithRawResponse(self)
-
- @cached_property
- def with_streaming_response(self) -> LinksResourceWithStreamingResponse:
- """
- 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 LinksResourceWithStreamingResponse(self)
-
- def list(
- self,
- securetunnel_id: str,
- *,
- page: int | NotGiven = NOT_GIVEN,
- size: int | NotGiven = NOT_GIVEN,
- # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
- # The extra values given here take precedence over values defined on the client or passed to this method.
- extra_headers: Headers | None = None,
- extra_query: Query | None = None,
- extra_body: Body | None = None,
- timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> SecureTunnelLink:
- """
- 查询安全隧道的所有 Link
-
- Args:
- page: Page number
-
- size: Page size
-
- 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 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}/links",
- options=make_request_options(
- extra_headers=extra_headers,
- extra_query=extra_query,
- extra_body=extra_body,
- timeout=timeout,
- query=maybe_transform(
- {
- "page": page,
- "size": size,
- },
- link_list_params.LinkListParams,
- ),
- ),
- cast_to=SecureTunnelLink,
- )
-
-
-class AsyncLinksResource(AsyncAPIResource):
- @cached_property
- def with_raw_response(self) -> AsyncLinksResourceWithRawResponse:
- """
- This property can be used as a prefix for any HTTP method call to return the
- 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 AsyncLinksResourceWithRawResponse(self)
-
- @cached_property
- def with_streaming_response(self) -> AsyncLinksResourceWithStreamingResponse:
- """
- 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 AsyncLinksResourceWithStreamingResponse(self)
-
- async def list(
- self,
- securetunnel_id: str,
- *,
- page: int | NotGiven = NOT_GIVEN,
- size: int | NotGiven = NOT_GIVEN,
- # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
- # The extra values given here take precedence over values defined on the client or passed to this method.
- extra_headers: Headers | None = None,
- extra_query: Query | None = None,
- extra_body: Body | None = None,
- timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> SecureTunnelLink:
- """
- 查询安全隧道的所有 Link
-
- Args:
- page: Page number
-
- size: Page size
-
- 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 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}/links",
- options=make_request_options(
- extra_headers=extra_headers,
- extra_query=extra_query,
- extra_body=extra_body,
- timeout=timeout,
- query=await async_maybe_transform(
- {
- "page": page,
- "size": size,
- },
- link_list_params.LinkListParams,
- ),
- ),
- cast_to=SecureTunnelLink,
- )
-
-
-class LinksResourceWithRawResponse:
- def __init__(self, links: LinksResource) -> None:
- self._links = links
-
- self.list = to_raw_response_wrapper(
- links.list,
- )
-
-
-class AsyncLinksResourceWithRawResponse:
- def __init__(self, links: AsyncLinksResource) -> None:
- self._links = links
-
- self.list = async_to_raw_response_wrapper(
- links.list,
- )
-
-
-class LinksResourceWithStreamingResponse:
- def __init__(self, links: LinksResource) -> None:
- self._links = links
-
- self.list = to_streamed_response_wrapper(
- links.list,
- )
-
-
-class AsyncLinksResourceWithStreamingResponse:
- def __init__(self, links: AsyncLinksResource) -> None:
- self._links = links
-
- self.list = async_to_streamed_response_wrapper(
- links.list,
- )
diff --git a/src/asktable/resources/single_turn/__init__.py b/src/asktable/resources/single_turn/__init__.py
index a8c43586..a8075418 100644
--- a/src/asktable/resources/single_turn/__init__.py
+++ b/src/asktable/resources/single_turn/__init__.py
@@ -16,6 +16,14 @@
Q2sResourceWithStreamingResponse,
AsyncQ2sResourceWithStreamingResponse,
)
+from .q2w import (
+ Q2wResource,
+ AsyncQ2wResource,
+ Q2wResourceWithRawResponse,
+ AsyncQ2wResourceWithRawResponse,
+ Q2wResourceWithStreamingResponse,
+ AsyncQ2wResourceWithStreamingResponse,
+)
from .single_turn import (
SingleTurnResource,
AsyncSingleTurnResource,
@@ -38,6 +46,12 @@
"AsyncQ2sResourceWithRawResponse",
"Q2sResourceWithStreamingResponse",
"AsyncQ2sResourceWithStreamingResponse",
+ "Q2wResource",
+ "AsyncQ2wResource",
+ "Q2wResourceWithRawResponse",
+ "AsyncQ2wResourceWithRawResponse",
+ "Q2wResourceWithStreamingResponse",
+ "AsyncQ2wResourceWithStreamingResponse",
"SingleTurnResource",
"AsyncSingleTurnResource",
"SingleTurnResourceWithRawResponse",
diff --git a/src/asktable/resources/single_turn/q2a.py b/src/asktable/resources/single_turn/q2a.py
index ae0e4faf..6b3bfeb9 100644
--- a/src/asktable/resources/single_turn/q2a.py
+++ b/src/asktable/resources/single_turn/q2a.py
@@ -19,10 +19,10 @@
async_to_raw_response_wrapper,
async_to_streamed_response_wrapper,
)
-from ..._base_client import make_request_options
+from ...pagination import SyncPage, AsyncPage
+from ..._base_client import AsyncPaginator, make_request_options
from ...types.single_turn import q2a_list_params, q2a_create_params
-from ...types.shared.answer_model import AnswerModel
-from ...types.single_turn.q2a_list_response import Q2aListResponse
+from ...types.single_turn.q2a_response import Q2aResponse
__all__ = ["Q2aResource", "AsyncQ2aResource"]
@@ -62,7 +62,7 @@ def create(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> AnswerModel:
+ ) -> Q2aResponse:
"""
发起查询的请求
@@ -104,7 +104,7 @@ def create(
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
- cast_to=AnswerModel,
+ cast_to=Q2aResponse,
)
def list(
@@ -119,7 +119,7 @@ def list(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> Q2aListResponse:
+ ) -> SyncPage[Q2aResponse]:
"""
获取所有的 Q2A 记录
@@ -138,8 +138,9 @@ def list(
timeout: Override the client-level default timeout for this request, in seconds
"""
- return self._get(
+ return self._get_api_list(
"/single-turn/q2a",
+ page=SyncPage[Q2aResponse],
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
@@ -154,7 +155,7 @@ def list(
q2a_list_params.Q2aListParams,
),
),
- cast_to=Q2aListResponse,
+ model=Q2aResponse,
)
@@ -193,7 +194,7 @@ async def create(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> AnswerModel:
+ ) -> Q2aResponse:
"""
发起查询的请求
@@ -235,10 +236,10 @@ async def create(
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
- cast_to=AnswerModel,
+ cast_to=Q2aResponse,
)
- async def list(
+ def list(
self,
*,
datasource_id: Optional[str] | NotGiven = NOT_GIVEN,
@@ -250,7 +251,7 @@ async def list(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> Q2aListResponse:
+ ) -> AsyncPaginator[Q2aResponse, AsyncPage[Q2aResponse]]:
"""
获取所有的 Q2A 记录
@@ -269,14 +270,15 @@ async def list(
timeout: Override the client-level default timeout for this request, in seconds
"""
- return await self._get(
+ return self._get_api_list(
"/single-turn/q2a",
+ page=AsyncPage[Q2aResponse],
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
- query=await async_maybe_transform(
+ query=maybe_transform(
{
"datasource_id": datasource_id,
"page": page,
@@ -285,7 +287,7 @@ async def list(
q2a_list_params.Q2aListParams,
),
),
- cast_to=Q2aListResponse,
+ model=Q2aResponse,
)
diff --git a/src/asktable/resources/single_turn/q2s.py b/src/asktable/resources/single_turn/q2s.py
index b8bfcac5..5dcd9a09 100644
--- a/src/asktable/resources/single_turn/q2s.py
+++ b/src/asktable/resources/single_turn/q2s.py
@@ -19,10 +19,10 @@
async_to_raw_response_wrapper,
async_to_streamed_response_wrapper,
)
-from ..._base_client import make_request_options
+from ...pagination import SyncPage, AsyncPage
+from ..._base_client import AsyncPaginator, make_request_options
from ...types.single_turn import q2_list_params, q2_create_params
from ...types.single_turn.q2s_response import Q2sResponse
-from ...types.single_turn.q2_list_response import Q2ListResponse
__all__ = ["Q2sResource", "AsyncQ2sResource"]
@@ -111,7 +111,7 @@ def list(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> Q2ListResponse:
+ ) -> SyncPage[Q2sResponse]:
"""
获取所有的 Q2S 记录
@@ -130,8 +130,9 @@ def list(
timeout: Override the client-level default timeout for this request, in seconds
"""
- return self._get(
+ return self._get_api_list(
"/single-turn/q2s",
+ page=SyncPage[Q2sResponse],
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
@@ -146,7 +147,7 @@ def list(
q2_list_params.Q2ListParams,
),
),
- cast_to=Q2ListResponse,
+ model=Q2sResponse,
)
@@ -222,7 +223,7 @@ async def create(
cast_to=Q2sResponse,
)
- async def list(
+ def list(
self,
*,
datasource_id: Optional[str] | NotGiven = NOT_GIVEN,
@@ -234,7 +235,7 @@ async def list(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> Q2ListResponse:
+ ) -> AsyncPaginator[Q2sResponse, AsyncPage[Q2sResponse]]:
"""
获取所有的 Q2S 记录
@@ -253,14 +254,15 @@ async def list(
timeout: Override the client-level default timeout for this request, in seconds
"""
- return await self._get(
+ return self._get_api_list(
"/single-turn/q2s",
+ page=AsyncPage[Q2sResponse],
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
- query=await async_maybe_transform(
+ query=maybe_transform(
{
"datasource_id": datasource_id,
"page": page,
@@ -269,7 +271,7 @@ async def list(
q2_list_params.Q2ListParams,
),
),
- cast_to=Q2ListResponse,
+ model=Q2sResponse,
)
diff --git a/src/asktable/resources/roles/policies.py b/src/asktable/resources/single_turn/q2w.py
similarity index 51%
rename from src/asktable/resources/roles/policies.py
rename to src/asktable/resources/single_turn/q2w.py
index 7c64f97f..3c86901e 100644
--- a/src/asktable/resources/roles/policies.py
+++ b/src/asktable/resources/single_turn/q2w.py
@@ -5,6 +5,10 @@
import httpx
from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven
+from ..._utils import (
+ maybe_transform,
+ async_maybe_transform,
+)
from ..._compat import cached_property
from ..._resource import SyncAPIResource, AsyncAPIResource
from ..._response import (
@@ -14,44 +18,44 @@
async_to_streamed_response_wrapper,
)
from ..._base_client import make_request_options
-from ...types.roles.policy_list_response import PolicyListResponse
+from ...types.single_turn import q2w_create_params
-__all__ = ["PoliciesResource", "AsyncPoliciesResource"]
+__all__ = ["Q2wResource", "AsyncQ2wResource"]
-class PoliciesResource(SyncAPIResource):
+class Q2wResource(SyncAPIResource):
@cached_property
- def with_raw_response(self) -> PoliciesResourceWithRawResponse:
+ def with_raw_response(self) -> Q2wResourceWithRawResponse:
"""
This property can be used as a prefix for any HTTP method call to return the
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 PoliciesResourceWithRawResponse(self)
+ return Q2wResourceWithRawResponse(self)
@cached_property
- def with_streaming_response(self) -> PoliciesResourceWithStreamingResponse:
+ def with_streaming_response(self) -> Q2wResourceWithStreamingResponse:
"""
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
For more information, see https://www.github.com/DataMini/asktable-python#with_streaming_response
"""
- return PoliciesResourceWithStreamingResponse(self)
+ return Q2wResourceWithStreamingResponse(self)
- def list(
+ def create(
self,
- role_id: str,
*,
+ body: object,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> PolicyListResponse:
+ ) -> object:
"""
- 查询某个角色的所有策略
+ Create Q2W
Args:
extra_headers: Send extra headers
@@ -62,50 +66,68 @@ def list(
timeout: Override the client-level default timeout for this request, in seconds
"""
- if not role_id:
- raise ValueError(f"Expected a non-empty value for `role_id` but received {role_id!r}")
+ return self._post(
+ "/single-turn/q2w",
+ body=maybe_transform(body, q2w_create_params.Q2wCreateParams),
+ options=make_request_options(
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
+ ),
+ cast_to=object,
+ )
+
+ def list(
+ self,
+ *,
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
+ # The extra values given here take precedence over values defined on the client or passed to this method.
+ extra_headers: Headers | None = None,
+ extra_query: Query | None = None,
+ extra_body: Body | None = None,
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
+ ) -> object:
+ """获取所有的 Q2W 记录"""
return self._get(
- f"/roles/{role_id}/policies",
+ "/single-turn/q2w",
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
- cast_to=PolicyListResponse,
+ cast_to=object,
)
-class AsyncPoliciesResource(AsyncAPIResource):
+class AsyncQ2wResource(AsyncAPIResource):
@cached_property
- def with_raw_response(self) -> AsyncPoliciesResourceWithRawResponse:
+ def with_raw_response(self) -> AsyncQ2wResourceWithRawResponse:
"""
This property can be used as a prefix for any HTTP method call to return the
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 AsyncPoliciesResourceWithRawResponse(self)
+ return AsyncQ2wResourceWithRawResponse(self)
@cached_property
- def with_streaming_response(self) -> AsyncPoliciesResourceWithStreamingResponse:
+ def with_streaming_response(self) -> AsyncQ2wResourceWithStreamingResponse:
"""
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
For more information, see https://www.github.com/DataMini/asktable-python#with_streaming_response
"""
- return AsyncPoliciesResourceWithStreamingResponse(self)
+ return AsyncQ2wResourceWithStreamingResponse(self)
- async def list(
+ async def create(
self,
- role_id: str,
*,
+ body: object,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> PolicyListResponse:
+ ) -> object:
"""
- 查询某个角色的所有策略
+ Create Q2W
Args:
extra_headers: Send extra headers
@@ -116,48 +138,78 @@ async def list(
timeout: Override the client-level default timeout for this request, in seconds
"""
- if not role_id:
- raise ValueError(f"Expected a non-empty value for `role_id` but received {role_id!r}")
+ return await self._post(
+ "/single-turn/q2w",
+ body=await async_maybe_transform(body, q2w_create_params.Q2wCreateParams),
+ options=make_request_options(
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
+ ),
+ cast_to=object,
+ )
+
+ async def list(
+ self,
+ *,
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
+ # The extra values given here take precedence over values defined on the client or passed to this method.
+ extra_headers: Headers | None = None,
+ extra_query: Query | None = None,
+ extra_body: Body | None = None,
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
+ ) -> object:
+ """获取所有的 Q2W 记录"""
return await self._get(
- f"/roles/{role_id}/policies",
+ "/single-turn/q2w",
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
- cast_to=PolicyListResponse,
+ cast_to=object,
)
-class PoliciesResourceWithRawResponse:
- def __init__(self, policies: PoliciesResource) -> None:
- self._policies = policies
+class Q2wResourceWithRawResponse:
+ def __init__(self, q2w: Q2wResource) -> None:
+ self._q2w = q2w
+ self.create = to_raw_response_wrapper(
+ q2w.create,
+ )
self.list = to_raw_response_wrapper(
- policies.list,
+ q2w.list,
)
-class AsyncPoliciesResourceWithRawResponse:
- def __init__(self, policies: AsyncPoliciesResource) -> None:
- self._policies = policies
+class AsyncQ2wResourceWithRawResponse:
+ def __init__(self, q2w: AsyncQ2wResource) -> None:
+ self._q2w = q2w
+ self.create = async_to_raw_response_wrapper(
+ q2w.create,
+ )
self.list = async_to_raw_response_wrapper(
- policies.list,
+ q2w.list,
)
-class PoliciesResourceWithStreamingResponse:
- def __init__(self, policies: PoliciesResource) -> None:
- self._policies = policies
+class Q2wResourceWithStreamingResponse:
+ def __init__(self, q2w: Q2wResource) -> None:
+ self._q2w = q2w
+ self.create = to_streamed_response_wrapper(
+ q2w.create,
+ )
self.list = to_streamed_response_wrapper(
- policies.list,
+ q2w.list,
)
-class AsyncPoliciesResourceWithStreamingResponse:
- def __init__(self, policies: AsyncPoliciesResource) -> None:
- self._policies = policies
+class AsyncQ2wResourceWithStreamingResponse:
+ def __init__(self, q2w: AsyncQ2wResource) -> None:
+ self._q2w = q2w
+ self.create = async_to_streamed_response_wrapper(
+ q2w.create,
+ )
self.list = async_to_streamed_response_wrapper(
- policies.list,
+ q2w.list,
)
diff --git a/src/asktable/resources/single_turn/single_turn.py b/src/asktable/resources/single_turn/single_turn.py
index e300e753..c84f7b95 100644
--- a/src/asktable/resources/single_turn/single_turn.py
+++ b/src/asktable/resources/single_turn/single_turn.py
@@ -18,6 +18,14 @@
Q2sResourceWithStreamingResponse,
AsyncQ2sResourceWithStreamingResponse,
)
+from .q2w import (
+ Q2wResource,
+ AsyncQ2wResource,
+ Q2wResourceWithRawResponse,
+ AsyncQ2wResourceWithRawResponse,
+ Q2wResourceWithStreamingResponse,
+ AsyncQ2wResourceWithStreamingResponse,
+)
from ..._compat import cached_property
from ..._resource import SyncAPIResource, AsyncAPIResource
@@ -33,6 +41,10 @@ def q2a(self) -> Q2aResource:
def q2s(self) -> Q2sResource:
return Q2sResource(self._client)
+ @cached_property
+ def q2w(self) -> Q2wResource:
+ return Q2wResource(self._client)
+
@cached_property
def with_raw_response(self) -> SingleTurnResourceWithRawResponse:
"""
@@ -62,6 +74,10 @@ def q2a(self) -> AsyncQ2aResource:
def q2s(self) -> AsyncQ2sResource:
return AsyncQ2sResource(self._client)
+ @cached_property
+ def q2w(self) -> AsyncQ2wResource:
+ return AsyncQ2wResource(self._client)
+
@cached_property
def with_raw_response(self) -> AsyncSingleTurnResourceWithRawResponse:
"""
@@ -94,6 +110,10 @@ def q2a(self) -> Q2aResourceWithRawResponse:
def q2s(self) -> Q2sResourceWithRawResponse:
return Q2sResourceWithRawResponse(self._single_turn.q2s)
+ @cached_property
+ def q2w(self) -> Q2wResourceWithRawResponse:
+ return Q2wResourceWithRawResponse(self._single_turn.q2w)
+
class AsyncSingleTurnResourceWithRawResponse:
def __init__(self, single_turn: AsyncSingleTurnResource) -> None:
@@ -107,6 +127,10 @@ def q2a(self) -> AsyncQ2aResourceWithRawResponse:
def q2s(self) -> AsyncQ2sResourceWithRawResponse:
return AsyncQ2sResourceWithRawResponse(self._single_turn.q2s)
+ @cached_property
+ def q2w(self) -> AsyncQ2wResourceWithRawResponse:
+ return AsyncQ2wResourceWithRawResponse(self._single_turn.q2w)
+
class SingleTurnResourceWithStreamingResponse:
def __init__(self, single_turn: SingleTurnResource) -> None:
@@ -120,6 +144,10 @@ def q2a(self) -> Q2aResourceWithStreamingResponse:
def q2s(self) -> Q2sResourceWithStreamingResponse:
return Q2sResourceWithStreamingResponse(self._single_turn.q2s)
+ @cached_property
+ def q2w(self) -> Q2wResourceWithStreamingResponse:
+ return Q2wResourceWithStreamingResponse(self._single_turn.q2w)
+
class AsyncSingleTurnResourceWithStreamingResponse:
def __init__(self, single_turn: AsyncSingleTurnResource) -> None:
@@ -132,3 +160,7 @@ def q2a(self) -> AsyncQ2aResourceWithStreamingResponse:
@cached_property
def q2s(self) -> AsyncQ2sResourceWithStreamingResponse:
return AsyncQ2sResourceWithStreamingResponse(self._single_turn.q2s)
+
+ @cached_property
+ def q2w(self) -> AsyncQ2wResourceWithStreamingResponse:
+ return AsyncQ2wResourceWithStreamingResponse(self._single_turn.q2w)
diff --git a/src/asktable/resources/sys/projects/__init__.py b/src/asktable/resources/sys/projects/__init__.py
index 323b0171..cad9a737 100644
--- a/src/asktable/resources/sys/projects/__init__.py
+++ b/src/asktable/resources/sys/projects/__init__.py
@@ -1,13 +1,5 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-from .tokens import (
- TokensResource,
- AsyncTokensResource,
- TokensResourceWithRawResponse,
- AsyncTokensResourceWithRawResponse,
- TokensResourceWithStreamingResponse,
- AsyncTokensResourceWithStreamingResponse,
-)
from .api_keys import (
APIKeysResource,
AsyncAPIKeysResource,
@@ -32,12 +24,6 @@
"AsyncAPIKeysResourceWithRawResponse",
"APIKeysResourceWithStreamingResponse",
"AsyncAPIKeysResourceWithStreamingResponse",
- "TokensResource",
- "AsyncTokensResource",
- "TokensResourceWithRawResponse",
- "AsyncTokensResourceWithRawResponse",
- "TokensResourceWithStreamingResponse",
- "AsyncTokensResourceWithStreamingResponse",
"ProjectsResource",
"AsyncProjectsResource",
"ProjectsResourceWithRawResponse",
diff --git a/src/asktable/resources/sys/projects/api_keys.py b/src/asktable/resources/sys/projects/api_keys.py
index 3a821e0f..fe34b0eb 100644
--- a/src/asktable/resources/sys/projects/api_keys.py
+++ b/src/asktable/resources/sys/projects/api_keys.py
@@ -2,6 +2,7 @@
from __future__ import annotations
+from typing import Optional
from typing_extensions import Literal
import httpx
@@ -20,9 +21,9 @@
async_to_streamed_response_wrapper,
)
from ...._base_client import make_request_options
-from ....types.sys.projects import api_key_create_params
-from ....types.sys.projects.api_key_create import APIKeyCreate
+from ....types.sys.projects import api_key_create_params, api_key_create_token_params
from ....types.sys.projects.api_key_list_response import APIKeyListResponse
+from ....types.sys.projects.api_key_create_response import APIKeyCreateResponse
__all__ = ["APIKeysResource", "AsyncAPIKeysResource"]
@@ -58,7 +59,7 @@ def create(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> APIKeyCreate:
+ ) -> APIKeyCreateResponse:
"""
创建 API Key
@@ -81,7 +82,7 @@ def create(
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
- cast_to=APIKeyCreate,
+ cast_to=APIKeyCreateResponse,
)
def list(
@@ -154,6 +155,60 @@ def delete(
cast_to=NoneType,
)
+ def create_token(
+ self,
+ project_id: str,
+ *,
+ ak_role: Literal["sys", "admin", "asker", "visitor"] | NotGiven = NOT_GIVEN,
+ chat_role: Optional[api_key_create_token_params.ChatRole] | NotGiven = NOT_GIVEN,
+ token_ttl: int | NotGiven = NOT_GIVEN,
+ user_profile: Optional[object] | NotGiven = NOT_GIVEN,
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
+ # The extra values given here take precedence over values defined on the client or passed to this method.
+ extra_headers: Headers | None = None,
+ extra_query: Query | None = None,
+ extra_body: Body | None = None,
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
+ ) -> object:
+ """
+ Create Token
+
+ Args:
+ ak_role: The role for the API key
+
+ chat_role: The chat role
+
+ token_ttl: The time-to-live for the token in seconds
+
+ user_profile: Optional user profile data
+
+ 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 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",
+ body=maybe_transform(
+ {
+ "ak_role": ak_role,
+ "chat_role": chat_role,
+ "token_ttl": token_ttl,
+ "user_profile": user_profile,
+ },
+ api_key_create_token_params.APIKeyCreateTokenParams,
+ ),
+ options=make_request_options(
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
+ ),
+ cast_to=object,
+ )
+
class AsyncAPIKeysResource(AsyncAPIResource):
@cached_property
@@ -186,7 +241,7 @@ async def create(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> APIKeyCreate:
+ ) -> APIKeyCreateResponse:
"""
创建 API Key
@@ -209,7 +264,7 @@ async def create(
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
- cast_to=APIKeyCreate,
+ cast_to=APIKeyCreateResponse,
)
async def list(
@@ -282,6 +337,60 @@ async def delete(
cast_to=NoneType,
)
+ async def create_token(
+ self,
+ project_id: str,
+ *,
+ ak_role: Literal["sys", "admin", "asker", "visitor"] | NotGiven = NOT_GIVEN,
+ chat_role: Optional[api_key_create_token_params.ChatRole] | NotGiven = NOT_GIVEN,
+ token_ttl: int | NotGiven = NOT_GIVEN,
+ user_profile: Optional[object] | NotGiven = NOT_GIVEN,
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
+ # The extra values given here take precedence over values defined on the client or passed to this method.
+ extra_headers: Headers | None = None,
+ extra_query: Query | None = None,
+ extra_body: Body | None = None,
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
+ ) -> object:
+ """
+ Create Token
+
+ Args:
+ ak_role: The role for the API key
+
+ chat_role: The chat role
+
+ token_ttl: The time-to-live for the token in seconds
+
+ user_profile: Optional user profile data
+
+ 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 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",
+ body=await async_maybe_transform(
+ {
+ "ak_role": ak_role,
+ "chat_role": chat_role,
+ "token_ttl": token_ttl,
+ "user_profile": user_profile,
+ },
+ api_key_create_token_params.APIKeyCreateTokenParams,
+ ),
+ options=make_request_options(
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
+ ),
+ cast_to=object,
+ )
+
class APIKeysResourceWithRawResponse:
def __init__(self, api_keys: APIKeysResource) -> None:
@@ -296,6 +405,9 @@ def __init__(self, api_keys: APIKeysResource) -> None:
self.delete = to_raw_response_wrapper(
api_keys.delete,
)
+ self.create_token = to_raw_response_wrapper(
+ api_keys.create_token,
+ )
class AsyncAPIKeysResourceWithRawResponse:
@@ -311,6 +423,9 @@ def __init__(self, api_keys: AsyncAPIKeysResource) -> None:
self.delete = async_to_raw_response_wrapper(
api_keys.delete,
)
+ self.create_token = async_to_raw_response_wrapper(
+ api_keys.create_token,
+ )
class APIKeysResourceWithStreamingResponse:
@@ -326,6 +441,9 @@ def __init__(self, api_keys: APIKeysResource) -> None:
self.delete = to_streamed_response_wrapper(
api_keys.delete,
)
+ self.create_token = to_streamed_response_wrapper(
+ api_keys.create_token,
+ )
class AsyncAPIKeysResourceWithStreamingResponse:
@@ -341,3 +459,6 @@ def __init__(self, api_keys: AsyncAPIKeysResource) -> None:
self.delete = async_to_streamed_response_wrapper(
api_keys.delete,
)
+ self.create_token = async_to_streamed_response_wrapper(
+ api_keys.create_token,
+ )
diff --git a/src/asktable/resources/sys/projects/projects.py b/src/asktable/resources/sys/projects/projects.py
index 6d2db13e..6275b274 100644
--- a/src/asktable/resources/sys/projects/projects.py
+++ b/src/asktable/resources/sys/projects/projects.py
@@ -6,14 +6,6 @@
import httpx
-from .tokens import (
- TokensResource,
- AsyncTokensResource,
- TokensResourceWithRawResponse,
- AsyncTokensResourceWithRawResponse,
- TokensResourceWithStreamingResponse,
- AsyncTokensResourceWithStreamingResponse,
-)
from .api_keys import (
APIKeysResource,
AsyncAPIKeysResource,
@@ -36,9 +28,9 @@
async_to_streamed_response_wrapper,
)
from ....types.sys import project_list_params, project_create_params, project_update_params
-from ...._base_client import make_request_options
+from ....pagination import SyncPage, AsyncPage
+from ...._base_client import AsyncPaginator, make_request_options
from ....types.sys.project import Project
-from ....types.sys.project_list_response import ProjectListResponse
__all__ = ["ProjectsResource", "AsyncProjectsResource"]
@@ -48,10 +40,6 @@ class ProjectsResource(SyncAPIResource):
def api_keys(self) -> APIKeysResource:
return APIKeysResource(self._client)
- @cached_property
- def tokens(self) -> TokensResource:
- return TokensResource(self._client)
-
@cached_property
def with_raw_response(self) -> ProjectsResourceWithRawResponse:
"""
@@ -196,7 +184,7 @@ def list(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> ProjectListResponse:
+ ) -> SyncPage[Project]:
"""
Get Projects
@@ -215,8 +203,9 @@ def list(
timeout: Override the client-level default timeout for this request, in seconds
"""
- return self._get(
+ return self._get_api_list(
"/sys/projects",
+ page=SyncPage[Project],
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
@@ -231,7 +220,7 @@ def list(
project_list_params.ProjectListParams,
),
),
- cast_to=ProjectListResponse,
+ model=Project,
)
def delete(
@@ -273,10 +262,6 @@ class AsyncProjectsResource(AsyncAPIResource):
def api_keys(self) -> AsyncAPIKeysResource:
return AsyncAPIKeysResource(self._client)
- @cached_property
- def tokens(self) -> AsyncTokensResource:
- return AsyncTokensResource(self._client)
-
@cached_property
def with_raw_response(self) -> AsyncProjectsResourceWithRawResponse:
"""
@@ -409,7 +394,7 @@ async def update(
cast_to=Project,
)
- async def list(
+ def list(
self,
*,
page: int | NotGiven = NOT_GIVEN,
@@ -421,7 +406,7 @@ async def list(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> ProjectListResponse:
+ ) -> AsyncPaginator[Project, AsyncPage[Project]]:
"""
Get Projects
@@ -440,14 +425,15 @@ async def list(
timeout: Override the client-level default timeout for this request, in seconds
"""
- return await self._get(
+ return self._get_api_list(
"/sys/projects",
+ page=AsyncPage[Project],
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
- query=await async_maybe_transform(
+ query=maybe_transform(
{
"page": page,
"project_ids": project_ids,
@@ -456,7 +442,7 @@ async def list(
project_list_params.ProjectListParams,
),
),
- cast_to=ProjectListResponse,
+ model=Project,
)
async def delete(
@@ -517,10 +503,6 @@ def __init__(self, projects: ProjectsResource) -> None:
def api_keys(self) -> APIKeysResourceWithRawResponse:
return APIKeysResourceWithRawResponse(self._projects.api_keys)
- @cached_property
- def tokens(self) -> TokensResourceWithRawResponse:
- return TokensResourceWithRawResponse(self._projects.tokens)
-
class AsyncProjectsResourceWithRawResponse:
def __init__(self, projects: AsyncProjectsResource) -> None:
@@ -546,10 +528,6 @@ def __init__(self, projects: AsyncProjectsResource) -> None:
def api_keys(self) -> AsyncAPIKeysResourceWithRawResponse:
return AsyncAPIKeysResourceWithRawResponse(self._projects.api_keys)
- @cached_property
- def tokens(self) -> AsyncTokensResourceWithRawResponse:
- return AsyncTokensResourceWithRawResponse(self._projects.tokens)
-
class ProjectsResourceWithStreamingResponse:
def __init__(self, projects: ProjectsResource) -> None:
@@ -575,10 +553,6 @@ def __init__(self, projects: ProjectsResource) -> None:
def api_keys(self) -> APIKeysResourceWithStreamingResponse:
return APIKeysResourceWithStreamingResponse(self._projects.api_keys)
- @cached_property
- def tokens(self) -> TokensResourceWithStreamingResponse:
- return TokensResourceWithStreamingResponse(self._projects.tokens)
-
class AsyncProjectsResourceWithStreamingResponse:
def __init__(self, projects: AsyncProjectsResource) -> None:
@@ -603,7 +577,3 @@ def __init__(self, projects: AsyncProjectsResource) -> None:
@cached_property
def api_keys(self) -> AsyncAPIKeysResourceWithStreamingResponse:
return AsyncAPIKeysResourceWithStreamingResponse(self._projects.api_keys)
-
- @cached_property
- def tokens(self) -> AsyncTokensResourceWithStreamingResponse:
- return AsyncTokensResourceWithStreamingResponse(self._projects.tokens)
diff --git a/src/asktable/resources/sys/projects/tokens.py b/src/asktable/resources/sys/projects/tokens.py
deleted file mode 100644
index 81636c6c..00000000
--- a/src/asktable/resources/sys/projects/tokens.py
+++ /dev/null
@@ -1,212 +0,0 @@
-# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-
-from __future__ import annotations
-
-from typing import Optional
-from typing_extensions import Literal
-
-import httpx
-
-from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven
-from ...._utils import (
- maybe_transform,
- async_maybe_transform,
-)
-from ...._compat import cached_property
-from ...._resource import SyncAPIResource, AsyncAPIResource
-from ...._response import (
- to_raw_response_wrapper,
- to_streamed_response_wrapper,
- async_to_raw_response_wrapper,
- async_to_streamed_response_wrapper,
-)
-from ...._base_client import make_request_options
-from ....types.sys.projects import token_create_params
-
-__all__ = ["TokensResource", "AsyncTokensResource"]
-
-
-class TokensResource(SyncAPIResource):
- @cached_property
- def with_raw_response(self) -> TokensResourceWithRawResponse:
- """
- This property can be used as a prefix for any HTTP method call to return the
- 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 TokensResourceWithRawResponse(self)
-
- @cached_property
- def with_streaming_response(self) -> TokensResourceWithStreamingResponse:
- """
- 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 TokensResourceWithStreamingResponse(self)
-
- def create(
- self,
- project_id: str,
- *,
- ak_role: Literal["sys", "admin", "asker", "visitor"] | NotGiven = NOT_GIVEN,
- chat_role: Optional[token_create_params.ChatRole] | NotGiven = NOT_GIVEN,
- token_ttl: int | NotGiven = NOT_GIVEN,
- user_profile: Optional[object] | NotGiven = NOT_GIVEN,
- # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
- # The extra values given here take precedence over values defined on the client or passed to this method.
- extra_headers: Headers | None = None,
- extra_query: Query | None = None,
- extra_body: Body | None = None,
- timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> object:
- """
- Create Token
-
- Args:
- ak_role: The role for the API key
-
- chat_role: The chat role
-
- token_ttl: The time-to-live for the token in seconds
-
- user_profile: Optional user profile data
-
- 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 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",
- body=maybe_transform(
- {
- "ak_role": ak_role,
- "chat_role": chat_role,
- "token_ttl": token_ttl,
- "user_profile": user_profile,
- },
- token_create_params.TokenCreateParams,
- ),
- options=make_request_options(
- extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
- ),
- cast_to=object,
- )
-
-
-class AsyncTokensResource(AsyncAPIResource):
- @cached_property
- def with_raw_response(self) -> AsyncTokensResourceWithRawResponse:
- """
- This property can be used as a prefix for any HTTP method call to return the
- 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 AsyncTokensResourceWithRawResponse(self)
-
- @cached_property
- def with_streaming_response(self) -> AsyncTokensResourceWithStreamingResponse:
- """
- 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 AsyncTokensResourceWithStreamingResponse(self)
-
- async def create(
- self,
- project_id: str,
- *,
- ak_role: Literal["sys", "admin", "asker", "visitor"] | NotGiven = NOT_GIVEN,
- chat_role: Optional[token_create_params.ChatRole] | NotGiven = NOT_GIVEN,
- token_ttl: int | NotGiven = NOT_GIVEN,
- user_profile: Optional[object] | NotGiven = NOT_GIVEN,
- # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
- # The extra values given here take precedence over values defined on the client or passed to this method.
- extra_headers: Headers | None = None,
- extra_query: Query | None = None,
- extra_body: Body | None = None,
- timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
- ) -> object:
- """
- Create Token
-
- Args:
- ak_role: The role for the API key
-
- chat_role: The chat role
-
- token_ttl: The time-to-live for the token in seconds
-
- user_profile: Optional user profile data
-
- 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 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",
- body=await async_maybe_transform(
- {
- "ak_role": ak_role,
- "chat_role": chat_role,
- "token_ttl": token_ttl,
- "user_profile": user_profile,
- },
- token_create_params.TokenCreateParams,
- ),
- options=make_request_options(
- extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
- ),
- cast_to=object,
- )
-
-
-class TokensResourceWithRawResponse:
- def __init__(self, tokens: TokensResource) -> None:
- self._tokens = tokens
-
- self.create = to_raw_response_wrapper(
- tokens.create,
- )
-
-
-class AsyncTokensResourceWithRawResponse:
- def __init__(self, tokens: AsyncTokensResource) -> None:
- self._tokens = tokens
-
- self.create = async_to_raw_response_wrapper(
- tokens.create,
- )
-
-
-class TokensResourceWithStreamingResponse:
- def __init__(self, tokens: TokensResource) -> None:
- self._tokens = tokens
-
- self.create = to_streamed_response_wrapper(
- tokens.create,
- )
-
-
-class AsyncTokensResourceWithStreamingResponse:
- def __init__(self, tokens: AsyncTokensResource) -> None:
- self._tokens = tokens
-
- self.create = async_to_streamed_response_wrapper(
- tokens.create,
- )
diff --git a/src/asktable/types/__init__.py b/src/asktable/types/__init__.py
index b54127f2..a80b0afb 100644
--- a/src/asktable/types/__init__.py
+++ b/src/asktable/types/__init__.py
@@ -2,47 +2,50 @@
from __future__ import annotations
+from .chat import Chat as Chat
+from .meta import Meta as Meta
from .role import Role as Role
-from .shared import Policy as Policy, Message as Message, AnswerModel as AnswerModel
-from .chat_bot import ChatBot as ChatBot
-from .document import Document as Document
-from .data_source import DataSource as DataSource
-from .ext_api_model import ExtAPIModel as ExtAPIModel
-from .page_document import PageDocument as PageDocument
+from .entry import Entry as Entry
+from .index import Index as Index
+from .extapi import Extapi as Extapi
+from .shared import Policy as Policy
+from .chatbot import Chatbot as Chatbot
+from .message import Message as Message
+from .datasource import Datasource as Datasource
from .secure_tunnel import SecureTunnel as SecureTunnel
-from .kb_list_params import KBListParams as KBListParams
from .bot_list_params import BotListParams as BotListParams
from .chat_list_params import ChatListParams as ChatListParams
-from .kb_create_params import KBCreateParams as KBCreateParams
from .role_list_params import RoleListParams as RoleListParams
from .bot_create_params import BotCreateParams as BotCreateParams
from .bot_invite_params import BotInviteParams as BotInviteParams
-from .bot_list_response import BotListResponse as BotListResponse
from .bot_update_params import BotUpdateParams as BotUpdateParams
+from .file_ask_response import FileAskResponse as FileAskResponse
from .chat_create_params import ChatCreateParams as ChatCreateParams
-from .chat_list_response import ChatListResponse as ChatListResponse
from .extapi_list_params import ExtapiListParams as ExtapiListParams
-from .kb_create_response import KBCreateResponse as KBCreateResponse
from .policy_list_params import PolicyListParams as PolicyListParams
from .role_create_params import RoleCreateParams as RoleCreateParams
-from .role_list_response import RoleListResponse as RoleListResponse
from .role_update_params import RoleUpdateParams as RoleUpdateParams
-from .chat_create_response import ChatCreateResponse as ChatCreateResponse
from .extapi_create_params import ExtapiCreateParams as ExtapiCreateParams
-from .extapi_list_response import ExtapiListResponse as ExtapiListResponse
from .extapi_update_params import ExtapiUpdateParams as ExtapiUpdateParams
from .policy_create_params import PolicyCreateParams as PolicyCreateParams
-from .policy_list_response import PolicyListResponse as PolicyListResponse
from .policy_update_params import PolicyUpdateParams as PolicyUpdateParams
-from .answer_data_source_out import AnswerDataSourceOut as AnswerDataSourceOut
-from .chat_retrieve_response import ChatRetrieveResponse as ChatRetrieveResponse
+from .entry_with_definition import EntryWithDefinition as EntryWithDefinition
from .datasource_list_params import DatasourceListParams as DatasourceListParams
+from .auth_create_token_params import AuthCreateTokenParams as AuthCreateTokenParams
+from .chat_send_message_params import ChatSendMessageParams as ChatSendMessageParams
from .datasource_create_params import DatasourceCreateParams as DatasourceCreateParams
-from .datasource_list_response import DatasourceListResponse as DatasourceListResponse
from .datasource_update_params import DatasourceUpdateParams as DatasourceUpdateParams
from .securetunnel_list_params import SecuretunnelListParams as SecuretunnelListParams
+from .role_get_polices_response import RoleGetPolicesResponse as RoleGetPolicesResponse
+from .role_get_variables_params import RoleGetVariablesParams as RoleGetVariablesParams
from .securetunnel_create_params import SecuretunnelCreateParams as SecuretunnelCreateParams
-from .securetunnel_list_response import SecuretunnelListResponse as SecuretunnelListResponse
from .securetunnel_update_params import SecuretunnelUpdateParams as SecuretunnelUpdateParams
+from .business_glossary_list_params import BusinessGlossaryListParams as BusinessGlossaryListParams
+from .securetunnel_list_links_params import SecuretunnelListLinksParams as SecuretunnelListLinksParams
+from .business_glossary_create_params import BusinessGlossaryCreateParams as BusinessGlossaryCreateParams
+from .business_glossary_update_params import BusinessGlossaryUpdateParams as BusinessGlossaryUpdateParams
from .integration_excel_csv_ask_params import IntegrationExcelCsvAskParams as IntegrationExcelCsvAskParams
+from .securetunnel_list_links_response import SecuretunnelListLinksResponse as SecuretunnelListLinksResponse
+from .business_glossary_create_response import BusinessGlossaryCreateResponse as BusinessGlossaryCreateResponse
from .datasource_create_from_file_params import DatasourceCreateFromFileParams as DatasourceCreateFromFileParams
+from .integration_create_excel_ds_params import IntegrationCreateExcelDsParams as IntegrationCreateExcelDsParams
diff --git a/src/asktable/types/answer_data_source_out.py b/src/asktable/types/answer_data_source_out.py
deleted file mode 100644
index f8360cd2..00000000
--- a/src/asktable/types/answer_data_source_out.py
+++ /dev/null
@@ -1,14 +0,0 @@
-# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-
-
-from .._models import BaseModel
-from .data_source import DataSource
-from .shared.answer_model import AnswerModel
-
-__all__ = ["AnswerDataSourceOut"]
-
-
-class AnswerDataSourceOut(BaseModel):
- answer: AnswerModel
-
- datasource: DataSource
diff --git a/src/asktable/types/auth/__init__.py b/src/asktable/types/auth/__init__.py
deleted file mode 100644
index cca0894f..00000000
--- a/src/asktable/types/auth/__init__.py
+++ /dev/null
@@ -1,5 +0,0 @@
-# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-
-from __future__ import annotations
-
-from .token_create_params import TokenCreateParams as TokenCreateParams
diff --git a/src/asktable/types/sys/projects/token_create_params.py b/src/asktable/types/auth_create_token_params.py
similarity index 86%
rename from src/asktable/types/sys/projects/token_create_params.py
rename to src/asktable/types/auth_create_token_params.py
index 1103150c..7764745b 100644
--- a/src/asktable/types/sys/projects/token_create_params.py
+++ b/src/asktable/types/auth_create_token_params.py
@@ -5,10 +5,10 @@
from typing import Optional
from typing_extensions import Literal, TypedDict
-__all__ = ["TokenCreateParams", "ChatRole"]
+__all__ = ["AuthCreateTokenParams", "ChatRole"]
-class TokenCreateParams(TypedDict, total=False):
+class AuthCreateTokenParams(TypedDict, total=False):
ak_role: Literal["sys", "admin", "asker", "visitor"]
"""The role for the API key"""
diff --git a/src/asktable/types/bot_list_response.py b/src/asktable/types/bot_list_response.py
deleted file mode 100644
index 5943103a..00000000
--- a/src/asktable/types/bot_list_response.py
+++ /dev/null
@@ -1,20 +0,0 @@
-# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-
-from typing import List, Optional
-
-from .._models import BaseModel
-from .chat_bot import ChatBot
-
-__all__ = ["BotListResponse"]
-
-
-class BotListResponse(BaseModel):
- items: List[ChatBot]
-
- page: Optional[int] = None
-
- size: Optional[int] = None
-
- total: Optional[int] = None
-
- pages: Optional[int] = None
diff --git a/src/asktable/types/kb_create_params.py b/src/asktable/types/business_glossary_create_params.py
similarity index 50%
rename from src/asktable/types/kb_create_params.py
rename to src/asktable/types/business_glossary_create_params.py
index 10037cd2..08220cef 100644
--- a/src/asktable/types/kb_create_params.py
+++ b/src/asktable/types/business_glossary_create_params.py
@@ -5,22 +5,22 @@
from typing import List, Iterable, Optional
from typing_extensions import Required, TypedDict
-__all__ = ["KBCreateParams", "Body"]
+__all__ = ["BusinessGlossaryCreateParams", "Body"]
-class KBCreateParams(TypedDict, total=False):
+class BusinessGlossaryCreateParams(TypedDict, total=False):
body: Required[Iterable[Body]]
class Body(TypedDict, total=False):
- content: Required[str]
- """文档内容"""
+ definition: Required[str]
+ """业务术语定义"""
- name: Required[str]
- """文档名称"""
+ term: Required[str]
+ """业务术语"""
- payload: Optional[object]
- """文档元数据"""
+ aliases: Optional[List[str]]
+ """业务术语同义词"""
- synonyms: Optional[List[str]]
- """文档同义词"""
+ payload: Optional[object]
+ """业务术语元数据"""
diff --git a/src/asktable/types/roles/policy_list_response.py b/src/asktable/types/business_glossary_create_response.py
similarity index 55%
rename from src/asktable/types/roles/policy_list_response.py
rename to src/asktable/types/business_glossary_create_response.py
index ada619cd..2b908192 100644
--- a/src/asktable/types/roles/policy_list_response.py
+++ b/src/asktable/types/business_glossary_create_response.py
@@ -3,8 +3,8 @@
from typing import List
from typing_extensions import TypeAlias
-from ..shared.policy import Policy
+from .entry import Entry
-__all__ = ["PolicyListResponse"]
+__all__ = ["BusinessGlossaryCreateResponse"]
-PolicyListResponse: TypeAlias = List[Policy]
+BusinessGlossaryCreateResponse: TypeAlias = List[Entry]
diff --git a/src/asktable/types/business_glossary_list_params.py b/src/asktable/types/business_glossary_list_params.py
new file mode 100644
index 00000000..b7753d3c
--- /dev/null
+++ b/src/asktable/types/business_glossary_list_params.py
@@ -0,0 +1,18 @@
+# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+from __future__ import annotations
+
+from typing_extensions import TypedDict
+
+__all__ = ["BusinessGlossaryListParams"]
+
+
+class BusinessGlossaryListParams(TypedDict, total=False):
+ page: int
+ """Page number"""
+
+ size: int
+ """Page size"""
+
+ term: str
+ """术语名称"""
diff --git a/src/asktable/types/business_glossary_update_params.py b/src/asktable/types/business_glossary_update_params.py
new file mode 100644
index 00000000..ea78c5db
--- /dev/null
+++ b/src/asktable/types/business_glossary_update_params.py
@@ -0,0 +1,22 @@
+# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+from __future__ import annotations
+
+from typing import List, Optional
+from typing_extensions import TypedDict
+
+__all__ = ["BusinessGlossaryUpdateParams"]
+
+
+class BusinessGlossaryUpdateParams(TypedDict, total=False):
+ aliases: Optional[List[str]]
+ """业务术语同义词"""
+
+ definition: Optional[str]
+ """业务术语定义"""
+
+ payload: Optional[object]
+ """业务术语元数据"""
+
+ term: Optional[str]
+ """业务术语"""
diff --git a/src/asktable/types/chat_create_response.py b/src/asktable/types/chat.py
similarity index 94%
rename from src/asktable/types/chat_create_response.py
rename to src/asktable/types/chat.py
index 927a51c3..5aacbcc2 100644
--- a/src/asktable/types/chat_create_response.py
+++ b/src/asktable/types/chat.py
@@ -5,10 +5,10 @@
from .._models import BaseModel
-__all__ = ["ChatCreateResponse"]
+__all__ = ["Chat"]
-class ChatCreateResponse(BaseModel):
+class Chat(BaseModel):
id: str
"""对话 ID"""
diff --git a/src/asktable/types/chat_list_response.py b/src/asktable/types/chat_list_response.py
deleted file mode 100644
index 698fdcb5..00000000
--- a/src/asktable/types/chat_list_response.py
+++ /dev/null
@@ -1,54 +0,0 @@
-# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-
-from typing import Dict, List, Union, Optional
-from datetime import datetime
-
-from .._models import BaseModel
-
-__all__ = ["ChatListResponse", "Item"]
-
-
-class Item(BaseModel):
- id: str
- """对话 ID"""
-
- created_at: datetime
- """创建时间"""
-
- modified_at: datetime
- """修改时间"""
-
- project_id: str
-
- bot_id: Optional[str] = None
- """
- 机器人 ID,如果需要使用高级功能,请使用 bot_id 来创建对话。在机器人中你可以定义
- 可以访问的数据、可以执行的任务以及是否开启调试模式等设置。
- """
-
- name: Optional[str] = None
- """New name for the chat"""
-
- role_id: Optional[str] = None
- """
- 角色 ID,将扮演这个角色来执行对话,用于权限控制。若无,则跳过鉴权,即可查询所有
- 数据
- """
-
- role_variables: Optional[Dict[str, Union[str, int, bool]]] = None
- """在扮演这个角色时需要传递的变量值,用 Key-Value 形式传递"""
-
- user_profile: Optional[Dict[str, str]] = None
- """用户信息,用于在对话中传递用户的信息,用 Key-Value 形式传递"""
-
-
-class ChatListResponse(BaseModel):
- items: List[Item]
-
- page: Optional[int] = None
-
- size: Optional[int] = None
-
- total: Optional[int] = None
-
- pages: Optional[int] = None
diff --git a/src/asktable/types/chat_retrieve_response.py b/src/asktable/types/chat_retrieve_response.py
deleted file mode 100644
index adf6b890..00000000
--- a/src/asktable/types/chat_retrieve_response.py
+++ /dev/null
@@ -1,42 +0,0 @@
-# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-
-from typing import Dict, Union, Optional
-from datetime import datetime
-
-from .._models import BaseModel
-
-__all__ = ["ChatRetrieveResponse"]
-
-
-class ChatRetrieveResponse(BaseModel):
- id: str
- """对话 ID"""
-
- created_at: datetime
- """创建时间"""
-
- modified_at: datetime
- """修改时间"""
-
- project_id: str
-
- bot_id: Optional[str] = None
- """
- 机器人 ID,如果需要使用高级功能,请使用 bot_id 来创建对话。在机器人中你可以定义
- 可以访问的数据、可以执行的任务以及是否开启调试模式等设置。
- """
-
- name: Optional[str] = None
- """New name for the chat"""
-
- role_id: Optional[str] = None
- """
- 角色 ID,将扮演这个角色来执行对话,用于权限控制。若无,则跳过鉴权,即可查询所有
- 数据
- """
-
- role_variables: Optional[Dict[str, Union[str, int, bool]]] = None
- """在扮演这个角色时需要传递的变量值,用 Key-Value 形式传递"""
-
- user_profile: Optional[Dict[str, str]] = None
- """用户信息,用于在对话中传递用户的信息,用 Key-Value 形式传递"""
diff --git a/src/asktable/types/chats/message_create_params.py b/src/asktable/types/chat_send_message_params.py
similarity index 69%
rename from src/asktable/types/chats/message_create_params.py
rename to src/asktable/types/chat_send_message_params.py
index 64600d94..b85e2df9 100644
--- a/src/asktable/types/chats/message_create_params.py
+++ b/src/asktable/types/chat_send_message_params.py
@@ -4,8 +4,8 @@
from typing_extensions import Required, TypedDict
-__all__ = ["MessageCreateParams"]
+__all__ = ["ChatSendMessageParams"]
-class MessageCreateParams(TypedDict, total=False):
+class ChatSendMessageParams(TypedDict, total=False):
question: Required[str]
diff --git a/src/asktable/types/chat_bot.py b/src/asktable/types/chatbot.py
similarity index 95%
rename from src/asktable/types/chat_bot.py
rename to src/asktable/types/chatbot.py
index b5f634ee..616249e5 100644
--- a/src/asktable/types/chat_bot.py
+++ b/src/asktable/types/chatbot.py
@@ -5,10 +5,10 @@
from .._models import BaseModel
-__all__ = ["ChatBot"]
+__all__ = ["Chatbot"]
-class ChatBot(BaseModel):
+class Chatbot(BaseModel):
id: str
created_at: datetime
diff --git a/src/asktable/types/chats/__init__.py b/src/asktable/types/chats/__init__.py
index ea7db84e..7b99b709 100644
--- a/src/asktable/types/chats/__init__.py
+++ b/src/asktable/types/chats/__init__.py
@@ -3,5 +3,4 @@
from __future__ import annotations
from .message_list_params import MessageListParams as MessageListParams
-from .message_create_params import MessageCreateParams as MessageCreateParams
-from .message_list_response import MessageListResponse as MessageListResponse
+from .message_send_message_params import MessageSendMessageParams as MessageSendMessageParams
diff --git a/src/asktable/types/chats/message_list_response.py b/src/asktable/types/chats/message_list_response.py
deleted file mode 100644
index 2b2821be..00000000
--- a/src/asktable/types/chats/message_list_response.py
+++ /dev/null
@@ -1,20 +0,0 @@
-# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-
-from typing import List, Optional
-
-from ..._models import BaseModel
-from ..shared.message import Message
-
-__all__ = ["MessageListResponse"]
-
-
-class MessageListResponse(BaseModel):
- items: List[Message]
-
- page: Optional[int] = None
-
- size: Optional[int] = None
-
- total: Optional[int] = None
-
- pages: Optional[int] = None
diff --git a/src/asktable/types/chats/message_send_message_params.py b/src/asktable/types/chats/message_send_message_params.py
new file mode 100644
index 00000000..2049c9e7
--- /dev/null
+++ b/src/asktable/types/chats/message_send_message_params.py
@@ -0,0 +1,11 @@
+# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+from __future__ import annotations
+
+from typing_extensions import Required, TypedDict
+
+__all__ = ["MessageSendMessageParams"]
+
+
+class MessageSendMessageParams(TypedDict, total=False):
+ question: Required[str]
diff --git a/src/asktable/types/data_source.py b/src/asktable/types/datasource.py
similarity index 76%
rename from src/asktable/types/data_source.py
rename to src/asktable/types/datasource.py
index a00af622..f3647f0d 100644
--- a/src/asktable/types/data_source.py
+++ b/src/asktable/types/datasource.py
@@ -6,10 +6,13 @@
from .._models import BaseModel
-__all__ = ["DataSource", "AccessConfig"]
+__all__ = ["Datasource", "AccessConfig"]
class AccessConfig(BaseModel):
+ atst_link_id: Optional[str] = None
+ """安全隧道链接 ID"""
+
db: Optional[str] = None
"""数据库引擎可以管理多个数据库,此参数用于指定数据库名称"""
@@ -25,6 +28,12 @@ class AccessConfig(BaseModel):
port: Optional[int] = None
"""数据库端口"""
+ proxy_host: Optional[str] = None
+ """数据源代理地址"""
+
+ proxy_port: Optional[int] = None
+ """数据源代理端口"""
+
securetunnel_id: Optional[str] = None
"""安全隧道 ID"""
@@ -32,7 +41,7 @@ class AccessConfig(BaseModel):
"""数据库用户名"""
-class DataSource(BaseModel):
+class Datasource(BaseModel):
id: str
"""数据源 ID"""
@@ -42,15 +51,21 @@ class DataSource(BaseModel):
engine: Literal["mysql", "tidb", "postgresql", "oceanbase", "clickhouse", "csv", "excel", "starrocks"]
"""数据源引擎"""
- meta_status: Literal["processing", "failed", "warning", "success", "unprocessed"]
+ meta_status: Literal["processing", "failed", "success", "unprocessed"]
"""元数据处理状态"""
+ modified_at: datetime
+ """修改时间"""
+
project_id: str
"""项目 ID"""
access_config: Optional[AccessConfig] = None
"""访问数据源的配置信息"""
+ desc: Optional[str] = None
+ """数据源描述"""
+
field_count: Optional[int] = None
"""字段数量"""
diff --git a/src/asktable/types/datasource_create_from_file_params.py b/src/asktable/types/datasource_create_from_file_params.py
index 70761d72..98aff51a 100644
--- a/src/asktable/types/datasource_create_from_file_params.py
+++ b/src/asktable/types/datasource_create_from_file_params.py
@@ -10,8 +10,8 @@
class DatasourceCreateFromFileParams(TypedDict, total=False):
- name: Required[str]
-
file: Required[FileTypes]
async_process_meta: bool
+
+ name: str
diff --git a/src/asktable/types/datasource_create_params.py b/src/asktable/types/datasource_create_params.py
index 845a390b..5f495b55 100644
--- a/src/asktable/types/datasource_create_params.py
+++ b/src/asktable/types/datasource_create_params.py
@@ -22,6 +22,9 @@ class DatasourceCreateParams(TypedDict, total=False):
class AccessConfig(TypedDict, total=False):
+ atst_link_id: Optional[str]
+ """安全隧道链接 ID"""
+
db: Optional[str]
"""数据库引擎可以管理多个数据库,此参数用于指定数据库名称"""
@@ -40,6 +43,12 @@ class AccessConfig(TypedDict, total=False):
port: Optional[int]
"""数据库端口"""
+ proxy_host: Optional[str]
+ """数据源代理地址"""
+
+ proxy_port: Optional[int]
+ """数据源代理端口"""
+
securetunnel_id: Optional[str]
"""安全隧道 ID"""
diff --git a/src/asktable/types/datasource_list_response.py b/src/asktable/types/datasource_list_response.py
deleted file mode 100644
index 924b3e61..00000000
--- a/src/asktable/types/datasource_list_response.py
+++ /dev/null
@@ -1,20 +0,0 @@
-# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-
-from typing import List, Optional
-
-from .._models import BaseModel
-from .data_source import DataSource
-
-__all__ = ["DatasourceListResponse"]
-
-
-class DatasourceListResponse(BaseModel):
- items: List[DataSource]
-
- page: Optional[int] = None
-
- size: Optional[int] = None
-
- total: Optional[int] = None
-
- pages: Optional[int] = None
diff --git a/src/asktable/types/datasource_update_params.py b/src/asktable/types/datasource_update_params.py
index 22248524..7ef08227 100644
--- a/src/asktable/types/datasource_update_params.py
+++ b/src/asktable/types/datasource_update_params.py
@@ -12,13 +12,16 @@ class DatasourceUpdateParams(TypedDict, total=False):
access_config: Optional[AccessConfig]
"""不同引擎有不同的配置"""
+ desc: Optional[str]
+ """数据源描述"""
+
field_count: Optional[int]
"""字段数量"""
meta_error: Optional[str]
"""元数据处理错误"""
- meta_status: Optional[Literal["processing", "failed", "warning", "success", "unprocessed"]]
+ meta_status: Optional[Literal["processing", "failed", "success", "unprocessed"]]
"""元数据处理状态"""
name: Optional[str]
@@ -35,6 +38,9 @@ class DatasourceUpdateParams(TypedDict, total=False):
class AccessConfig(TypedDict, total=False):
+ atst_link_id: Optional[str]
+ """安全隧道链接 ID"""
+
db: Optional[str]
"""数据库引擎可以管理多个数据库,此参数用于指定数据库名称"""
@@ -53,6 +59,12 @@ class AccessConfig(TypedDict, total=False):
port: Optional[int]
"""数据库端口"""
+ proxy_host: Optional[str]
+ """数据源代理地址"""
+
+ proxy_port: Optional[int]
+ """数据源代理端口"""
+
securetunnel_id: Optional[str]
"""安全隧道 ID"""
diff --git a/src/asktable/types/datasources/__init__.py b/src/asktable/types/datasources/__init__.py
index b42596dc..b015a299 100644
--- a/src/asktable/types/datasources/__init__.py
+++ b/src/asktable/types/datasources/__init__.py
@@ -2,7 +2,9 @@
from __future__ import annotations
-from .meta import Meta as Meta
+from .index_list_params import IndexListParams as IndexListParams
from .meta_create_params import MetaCreateParams as MetaCreateParams
from .meta_update_params import MetaUpdateParams as MetaUpdateParams
+from .index_create_params import IndexCreateParams as IndexCreateParams
+from .meta_annotate_params import MetaAnnotateParams as MetaAnnotateParams
from .upload_param_create_params import UploadParamCreateParams as UploadParamCreateParams
diff --git a/src/asktable/types/datasources/index_create_params.py b/src/asktable/types/datasources/index_create_params.py
new file mode 100644
index 00000000..df4e8bc9
--- /dev/null
+++ b/src/asktable/types/datasources/index_create_params.py
@@ -0,0 +1,20 @@
+# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+from __future__ import annotations
+
+from typing_extensions import Required, TypedDict
+
+__all__ = ["IndexCreateParams"]
+
+
+class IndexCreateParams(TypedDict, total=False):
+ field_name: Required[str]
+ """字段名"""
+
+ schema_name: Required[str]
+ """模式名称"""
+
+ table_name: Required[str]
+ """表名"""
+
+ async_process: bool
diff --git a/src/asktable/types/securetunnels/link_list_params.py b/src/asktable/types/datasources/index_list_params.py
similarity index 75%
rename from src/asktable/types/securetunnels/link_list_params.py
rename to src/asktable/types/datasources/index_list_params.py
index 5802a71c..b7b34e4d 100644
--- a/src/asktable/types/securetunnels/link_list_params.py
+++ b/src/asktable/types/datasources/index_list_params.py
@@ -4,10 +4,10 @@
from typing_extensions import TypedDict
-__all__ = ["LinkListParams"]
+__all__ = ["IndexListParams"]
-class LinkListParams(TypedDict, total=False):
+class IndexListParams(TypedDict, total=False):
page: int
"""Page number"""
diff --git a/src/asktable/types/datasources/meta_annotate_params.py b/src/asktable/types/datasources/meta_annotate_params.py
new file mode 100644
index 00000000..ce9eb9ce
--- /dev/null
+++ b/src/asktable/types/datasources/meta_annotate_params.py
@@ -0,0 +1,24 @@
+# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+from __future__ import annotations
+
+from typing import Dict, Optional
+from typing_extensions import Required, TypedDict
+
+__all__ = ["MetaAnnotateParams", "Schemas", "SchemasTables"]
+
+
+class MetaAnnotateParams(TypedDict, total=False):
+ schemas: Required[Dict[str, Schemas]]
+
+
+class SchemasTables(TypedDict, total=False):
+ fields: Required[Dict[str, str]]
+
+ desc: Optional[str]
+
+
+class Schemas(TypedDict, total=False):
+ tables: Required[Dict[str, SchemasTables]]
+
+ desc: Optional[str]
diff --git a/src/asktable/types/datasources/meta_create_params.py b/src/asktable/types/datasources/meta_create_params.py
index a6436ef7..a8102bf6 100644
--- a/src/asktable/types/datasources/meta_create_params.py
+++ b/src/asktable/types/datasources/meta_create_params.py
@@ -7,22 +7,22 @@
__all__ = [
"MetaCreateParams",
- "MetaBase",
- "MetaBaseSchemas",
- "MetaBaseSchemasTables",
- "MetaBaseSchemasTablesFields",
+ "MetaCreate",
+ "MetaCreateSchemas",
+ "MetaCreateSchemasTables",
+ "MetaCreateSchemasTablesFields",
"Variant1",
]
-class MetaBase(TypedDict, total=False):
+class MetaCreate(TypedDict, total=False):
name: Required[str]
"""metadata_name"""
- schemas: Dict[str, MetaBaseSchemas]
+ schemas: Dict[str, MetaCreateSchemas]
-class MetaBaseSchemasTablesFields(TypedDict, total=False):
+class MetaCreateSchemasTablesFields(TypedDict, total=False):
name: Required[str]
"""field_name"""
@@ -36,17 +36,17 @@ class MetaBaseSchemasTablesFields(TypedDict, total=False):
"""field sample data"""
-class MetaBaseSchemasTables(TypedDict, total=False):
+class MetaCreateSchemasTables(TypedDict, total=False):
name: Required[str]
"""table_name"""
- fields: Dict[str, MetaBaseSchemasTablesFields]
+ fields: Dict[str, MetaCreateSchemasTablesFields]
origin_desc: Optional[str]
"""table description from database"""
-class MetaBaseSchemas(TypedDict, total=False):
+class MetaCreateSchemas(TypedDict, total=False):
name: Required[str]
"""schema_name"""
@@ -56,11 +56,11 @@ class MetaBaseSchemas(TypedDict, total=False):
origin_desc: Optional[str]
"""schema description from database"""
- tables: Dict[str, MetaBaseSchemasTables]
+ tables: Dict[str, MetaCreateSchemasTables]
class Variant1(TypedDict, total=False):
body: Required[None]
-MetaCreateParams: TypeAlias = Union[MetaBase, Variant1]
+MetaCreateParams: TypeAlias = Union[MetaCreate, Variant1]
diff --git a/src/asktable/types/datasources/meta_update_params.py b/src/asktable/types/datasources/meta_update_params.py
index 6ff4b091..2e0f1435 100644
--- a/src/asktable/types/datasources/meta_update_params.py
+++ b/src/asktable/types/datasources/meta_update_params.py
@@ -7,22 +7,22 @@
__all__ = [
"MetaUpdateParams",
- "MetaBase",
- "MetaBaseSchemas",
- "MetaBaseSchemasTables",
- "MetaBaseSchemasTablesFields",
+ "MetaCreate",
+ "MetaCreateSchemas",
+ "MetaCreateSchemasTables",
+ "MetaCreateSchemasTablesFields",
"Variant1",
]
-class MetaBase(TypedDict, total=False):
+class MetaCreate(TypedDict, total=False):
name: Required[str]
"""metadata_name"""
- schemas: Dict[str, MetaBaseSchemas]
+ schemas: Dict[str, MetaCreateSchemas]
-class MetaBaseSchemasTablesFields(TypedDict, total=False):
+class MetaCreateSchemasTablesFields(TypedDict, total=False):
name: Required[str]
"""field_name"""
@@ -36,17 +36,17 @@ class MetaBaseSchemasTablesFields(TypedDict, total=False):
"""field sample data"""
-class MetaBaseSchemasTables(TypedDict, total=False):
+class MetaCreateSchemasTables(TypedDict, total=False):
name: Required[str]
"""table_name"""
- fields: Dict[str, MetaBaseSchemasTablesFields]
+ fields: Dict[str, MetaCreateSchemasTablesFields]
origin_desc: Optional[str]
"""table description from database"""
-class MetaBaseSchemas(TypedDict, total=False):
+class MetaCreateSchemas(TypedDict, total=False):
name: Required[str]
"""schema_name"""
@@ -56,11 +56,11 @@ class MetaBaseSchemas(TypedDict, total=False):
origin_desc: Optional[str]
"""schema description from database"""
- tables: Dict[str, MetaBaseSchemasTables]
+ tables: Dict[str, MetaCreateSchemasTables]
class Variant1(TypedDict, total=False):
body: Required[None]
-MetaUpdateParams: TypeAlias = Union[MetaBase, Variant1]
+MetaUpdateParams: TypeAlias = Union[MetaCreate, Variant1]
diff --git a/src/asktable/types/document.py b/src/asktable/types/entry.py
similarity index 59%
rename from src/asktable/types/document.py
rename to src/asktable/types/entry.py
index 1434313c..d493a3ef 100644
--- a/src/asktable/types/document.py
+++ b/src/asktable/types/entry.py
@@ -5,27 +5,27 @@
from .._models import BaseModel
-__all__ = ["Document"]
+__all__ = ["Entry"]
-class Document(BaseModel):
+class Entry(BaseModel):
id: str
- """文档 ID"""
+ """业务术语 ID"""
created_at: datetime
"""创建时间"""
- name: str
- """文档名称"""
+ modified_at: datetime
+ """更新时间"""
project_id: str
"""项目 ID"""
- updated_at: datetime
- """更新时间"""
+ term: str
+ """业务术语"""
- payload: Optional[object] = None
- """文档元数据"""
+ aliases: Optional[List[str]] = None
+ """业务术语同义词"""
- synonyms: Optional[List[str]] = None
- """文档同义词"""
+ payload: Optional[object] = None
+ """业务术语元数据"""
diff --git a/src/asktable/types/entry_with_definition.py b/src/asktable/types/entry_with_definition.py
new file mode 100644
index 00000000..d7011a9e
--- /dev/null
+++ b/src/asktable/types/entry_with_definition.py
@@ -0,0 +1,34 @@
+# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+from typing import List, Optional
+from datetime import datetime
+
+from .._models import BaseModel
+
+__all__ = ["EntryWithDefinition"]
+
+
+class EntryWithDefinition(BaseModel):
+ id: str
+ """业务术语 ID"""
+
+ created_at: datetime
+ """创建时间"""
+
+ definition: str
+ """业务术语定义"""
+
+ modified_at: datetime
+ """更新时间"""
+
+ project_id: str
+ """项目 ID"""
+
+ term: str
+ """业务术语"""
+
+ aliases: Optional[List[str]] = None
+ """业务术语同义词"""
+
+ payload: Optional[object] = None
+ """业务术语元数据"""
diff --git a/src/asktable/types/ext_api_model.py b/src/asktable/types/extapi.py
similarity index 89%
rename from src/asktable/types/ext_api_model.py
rename to src/asktable/types/extapi.py
index ee8a68fe..0d90cc1b 100644
--- a/src/asktable/types/ext_api_model.py
+++ b/src/asktable/types/extapi.py
@@ -5,10 +5,10 @@
from .._models import BaseModel
-__all__ = ["ExtAPIModel"]
+__all__ = ["Extapi"]
-class ExtAPIModel(BaseModel):
+class Extapi(BaseModel):
id: str
base_url: str
diff --git a/src/asktable/types/extapi_create_params.py b/src/asktable/types/extapi_create_params.py
index 4b2c17d6..77a795f4 100644
--- a/src/asktable/types/extapi_create_params.py
+++ b/src/asktable/types/extapi_create_params.py
@@ -2,29 +2,18 @@
from __future__ import annotations
-from typing import Dict, Union, Optional
-from datetime import datetime
-from typing_extensions import Required, Annotated, TypedDict
-
-from .._utils import PropertyInfo
+from typing import Dict, Optional
+from typing_extensions import Required, TypedDict
__all__ = ["ExtapiCreateParams"]
class ExtapiCreateParams(TypedDict, total=False):
- id: Required[str]
-
base_url: Required[str]
"""根 URL"""
- created_at: Required[Annotated[Union[str, datetime], PropertyInfo(format="iso8601")]]
-
name: Required[str]
"""名称,不超过 64 个字符"""
- project_id: Required[str]
-
headers: Optional[Dict[str, str]]
"""HTTP Headers,JSON 格式"""
-
- updated_at: Annotated[Union[str, datetime], PropertyInfo(format="iso8601")]
diff --git a/src/asktable/types/extapi_list_response.py b/src/asktable/types/extapi_list_response.py
deleted file mode 100644
index 53c0badb..00000000
--- a/src/asktable/types/extapi_list_response.py
+++ /dev/null
@@ -1,20 +0,0 @@
-# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-
-from typing import List, Optional
-
-from .._models import BaseModel
-from .ext_api_model import ExtAPIModel
-
-__all__ = ["ExtapiListResponse"]
-
-
-class ExtapiListResponse(BaseModel):
- items: List[ExtAPIModel]
-
- page: Optional[int] = None
-
- size: Optional[int] = None
-
- total: Optional[int] = None
-
- pages: Optional[int] = None
diff --git a/src/asktable/types/extapis/__init__.py b/src/asktable/types/extapis/__init__.py
index ab487bd5..fbd63ce0 100644
--- a/src/asktable/types/extapis/__init__.py
+++ b/src/asktable/types/extapis/__init__.py
@@ -2,7 +2,7 @@
from __future__ import annotations
-from .ext_api_route_model import ExtAPIRouteModel as ExtAPIRouteModel
+from .extapi_route import ExtapiRoute as ExtapiRoute
from .route_create_params import RouteCreateParams as RouteCreateParams
from .route_list_response import RouteListResponse as RouteListResponse
from .route_update_params import RouteUpdateParams as RouteUpdateParams
diff --git a/src/asktable/types/extapis/ext_api_route_model.py b/src/asktable/types/extapis/extapi_route.py
similarity index 91%
rename from src/asktable/types/extapis/ext_api_route_model.py
rename to src/asktable/types/extapis/extapi_route.py
index c27b1cd9..3525c711 100644
--- a/src/asktable/types/extapis/ext_api_route_model.py
+++ b/src/asktable/types/extapis/extapi_route.py
@@ -6,10 +6,10 @@
from ..._models import BaseModel
-__all__ = ["ExtAPIRouteModel"]
+__all__ = ["ExtapiRoute"]
-class ExtAPIRouteModel(BaseModel):
+class ExtapiRoute(BaseModel):
id: str
created_at: datetime
diff --git a/src/asktable/types/extapis/route_list_response.py b/src/asktable/types/extapis/route_list_response.py
index 24dc8c12..5a38d0b2 100644
--- a/src/asktable/types/extapis/route_list_response.py
+++ b/src/asktable/types/extapis/route_list_response.py
@@ -3,8 +3,8 @@
from typing import List
from typing_extensions import TypeAlias
-from .ext_api_route_model import ExtAPIRouteModel
+from .extapi_route import ExtapiRoute
__all__ = ["RouteListResponse"]
-RouteListResponse: TypeAlias = List[ExtAPIRouteModel]
+RouteListResponse: TypeAlias = List[ExtapiRoute]
diff --git a/src/asktable/types/file_ask_response.py b/src/asktable/types/file_ask_response.py
new file mode 100644
index 00000000..706e9977
--- /dev/null
+++ b/src/asktable/types/file_ask_response.py
@@ -0,0 +1,14 @@
+# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+
+from .._models import BaseModel
+from .datasource import Datasource
+from .single_turn.q2a_response import Q2aResponse
+
+__all__ = ["FileAskResponse"]
+
+
+class FileAskResponse(BaseModel):
+ answer: Q2aResponse
+
+ datasource: Datasource
diff --git a/src/asktable/types/index.py b/src/asktable/types/index.py
new file mode 100644
index 00000000..53012b27
--- /dev/null
+++ b/src/asktable/types/index.py
@@ -0,0 +1,49 @@
+# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+from typing import Optional
+from datetime import datetime
+
+from .._models import BaseModel
+
+__all__ = ["Index"]
+
+
+class Index(BaseModel):
+ id: str
+ """索引 ID"""
+
+ created_at: datetime
+ """创建时间"""
+
+ datasource_id: str
+ """数据源 ID"""
+
+ field_name: str
+ """字段名"""
+
+ index_value_count: int
+ """索引值总数"""
+
+ modified_at: datetime
+ """修改时间"""
+
+ schema_name: str
+ """模式名称"""
+
+ table_name: str
+ """表名"""
+
+ avg_length: Optional[float] = None
+ """平均长度"""
+
+ distinct_count: Optional[int] = None
+ """不同值数量"""
+
+ max_length: Optional[int] = None
+ """最大长度"""
+
+ min_length: Optional[int] = None
+ """最小长度"""
+
+ value_count: Optional[int] = None
+ """值总数"""
diff --git a/src/asktable/types/integration/__init__.py b/src/asktable/types/integration/__init__.py
deleted file mode 100644
index 558834ca..00000000
--- a/src/asktable/types/integration/__init__.py
+++ /dev/null
@@ -1,5 +0,0 @@
-# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-
-from __future__ import annotations
-
-from .excel_csv_create_params import ExcelCsvCreateParams as ExcelCsvCreateParams
diff --git a/src/asktable/types/integration/excel_csv_create_params.py b/src/asktable/types/integration_create_excel_ds_params.py
similarity index 65%
rename from src/asktable/types/integration/excel_csv_create_params.py
rename to src/asktable/types/integration_create_excel_ds_params.py
index c2292156..44032d27 100644
--- a/src/asktable/types/integration/excel_csv_create_params.py
+++ b/src/asktable/types/integration_create_excel_ds_params.py
@@ -4,8 +4,8 @@
from typing_extensions import Required, TypedDict
-__all__ = ["ExcelCsvCreateParams"]
+__all__ = ["IntegrationCreateExcelDsParams"]
-class ExcelCsvCreateParams(TypedDict, total=False):
+class IntegrationCreateExcelDsParams(TypedDict, total=False):
file_url: Required[str]
diff --git a/src/asktable/types/shared/message.py b/src/asktable/types/message.py
similarity index 85%
rename from src/asktable/types/shared/message.py
rename to src/asktable/types/message.py
index 3db5e827..a34e9be0 100644
--- a/src/asktable/types/shared/message.py
+++ b/src/asktable/types/message.py
@@ -4,7 +4,7 @@
from datetime import datetime
from typing_extensions import Literal
-from ..._models import BaseModel
+from .._models import BaseModel
__all__ = ["Message"]
@@ -20,3 +20,5 @@ class Message(BaseModel):
role: Literal["human", "ai"]
reply_to_msg_id: Optional[str] = None
+
+ trace_id: Optional[str] = None
diff --git a/src/asktable/types/datasources/meta.py b/src/asktable/types/meta.py
similarity index 98%
rename from src/asktable/types/datasources/meta.py
rename to src/asktable/types/meta.py
index f56a2026..6a42ac8a 100644
--- a/src/asktable/types/datasources/meta.py
+++ b/src/asktable/types/meta.py
@@ -2,7 +2,7 @@
from typing import Dict, Optional
-from ..._models import BaseModel
+from .._models import BaseModel
__all__ = ["Meta", "Schemas", "SchemasTables", "SchemasTablesFields"]
diff --git a/src/asktable/types/page_document.py b/src/asktable/types/page_document.py
deleted file mode 100644
index 4de810f0..00000000
--- a/src/asktable/types/page_document.py
+++ /dev/null
@@ -1,20 +0,0 @@
-# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-
-from typing import List, Optional
-
-from .._models import BaseModel
-from .document import Document
-
-__all__ = ["PageDocument"]
-
-
-class PageDocument(BaseModel):
- items: List[Document]
-
- page: Optional[int] = None
-
- size: Optional[int] = None
-
- total: Optional[int] = None
-
- pages: Optional[int] = None
diff --git a/src/asktable/types/policy_list_response.py b/src/asktable/types/policy_list_response.py
deleted file mode 100644
index a37170f5..00000000
--- a/src/asktable/types/policy_list_response.py
+++ /dev/null
@@ -1,20 +0,0 @@
-# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-
-from typing import List, Optional
-
-from .._models import BaseModel
-from .shared.policy import Policy
-
-__all__ = ["PolicyListResponse"]
-
-
-class PolicyListResponse(BaseModel):
- items: List[Policy]
-
- page: Optional[int] = None
-
- size: Optional[int] = None
-
- total: Optional[int] = None
-
- pages: Optional[int] = None
diff --git a/src/asktable/types/kb_create_response.py b/src/asktable/types/role_get_polices_response.py
similarity index 56%
rename from src/asktable/types/kb_create_response.py
rename to src/asktable/types/role_get_polices_response.py
index 03a774de..85b32bb2 100644
--- a/src/asktable/types/kb_create_response.py
+++ b/src/asktable/types/role_get_polices_response.py
@@ -3,8 +3,8 @@
from typing import List
from typing_extensions import TypeAlias
-from .document import Document
+from .shared.policy import Policy
-__all__ = ["KBCreateResponse"]
+__all__ = ["RoleGetPolicesResponse"]
-KBCreateResponse: TypeAlias = List[Document]
+RoleGetPolicesResponse: TypeAlias = List[Policy]
diff --git a/src/asktable/types/roles/variable_list_params.py b/src/asktable/types/role_get_variables_params.py
similarity index 77%
rename from src/asktable/types/roles/variable_list_params.py
rename to src/asktable/types/role_get_variables_params.py
index 9b3c5a73..cebb567c 100644
--- a/src/asktable/types/roles/variable_list_params.py
+++ b/src/asktable/types/role_get_variables_params.py
@@ -5,10 +5,10 @@
from typing import List, Optional
from typing_extensions import TypedDict
-__all__ = ["VariableListParams"]
+__all__ = ["RoleGetVariablesParams"]
-class VariableListParams(TypedDict, total=False):
+class RoleGetVariablesParams(TypedDict, total=False):
bot_id: Optional[str]
"""Bot ID"""
diff --git a/src/asktable/types/role_list_response.py b/src/asktable/types/role_list_response.py
deleted file mode 100644
index 3abeb28b..00000000
--- a/src/asktable/types/role_list_response.py
+++ /dev/null
@@ -1,20 +0,0 @@
-# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-
-from typing import List, Optional
-
-from .role import Role
-from .._models import BaseModel
-
-__all__ = ["RoleListResponse"]
-
-
-class RoleListResponse(BaseModel):
- items: List[Role]
-
- page: Optional[int] = None
-
- size: Optional[int] = None
-
- total: Optional[int] = None
-
- pages: Optional[int] = None
diff --git a/src/asktable/types/roles/__init__.py b/src/asktable/types/roles/__init__.py
deleted file mode 100644
index 5dc77e56..00000000
--- a/src/asktable/types/roles/__init__.py
+++ /dev/null
@@ -1,6 +0,0 @@
-# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-
-from __future__ import annotations
-
-from .policy_list_response import PolicyListResponse as PolicyListResponse
-from .variable_list_params import VariableListParams as VariableListParams
diff --git a/src/asktable/types/kb_list_params.py b/src/asktable/types/securetunnel_list_links_params.py
similarity index 68%
rename from src/asktable/types/kb_list_params.py
rename to src/asktable/types/securetunnel_list_links_params.py
index 7f8e4d7a..3ff4ce62 100644
--- a/src/asktable/types/kb_list_params.py
+++ b/src/asktable/types/securetunnel_list_links_params.py
@@ -4,13 +4,10 @@
from typing_extensions import TypedDict
-__all__ = ["KBListParams"]
+__all__ = ["SecuretunnelListLinksParams"]
-class KBListParams(TypedDict, total=False):
- name: str
- """文档名称"""
-
+class SecuretunnelListLinksParams(TypedDict, total=False):
page: int
"""Page number"""
diff --git a/src/asktable/types/securetunnel_list_links_response.py b/src/asktable/types/securetunnel_list_links_response.py
new file mode 100644
index 00000000..15b8b118
--- /dev/null
+++ b/src/asktable/types/securetunnel_list_links_response.py
@@ -0,0 +1,28 @@
+# 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__ = ["SecuretunnelListLinksResponse"]
+
+
+class SecuretunnelListLinksResponse(BaseModel):
+ id: str
+
+ atst_id: str
+
+ created_at: datetime
+
+ datasource_ids: List[str]
+
+ modified_at: datetime
+
+ proxy_port: int
+
+ status: str
+
+ target_host: str
+
+ target_port: int
diff --git a/src/asktable/types/securetunnel_list_response.py b/src/asktable/types/securetunnel_list_response.py
deleted file mode 100644
index 1366cfbf..00000000
--- a/src/asktable/types/securetunnel_list_response.py
+++ /dev/null
@@ -1,20 +0,0 @@
-# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-
-from typing import List, Optional
-
-from .._models import BaseModel
-from .secure_tunnel import SecureTunnel
-
-__all__ = ["SecuretunnelListResponse"]
-
-
-class SecuretunnelListResponse(BaseModel):
- items: List[SecureTunnel]
-
- page: Optional[int] = None
-
- size: Optional[int] = None
-
- total: Optional[int] = None
-
- pages: Optional[int] = None
diff --git a/src/asktable/types/securetunnels/__init__.py b/src/asktable/types/securetunnels/__init__.py
deleted file mode 100644
index 57b77612..00000000
--- a/src/asktable/types/securetunnels/__init__.py
+++ /dev/null
@@ -1,6 +0,0 @@
-# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-
-from __future__ import annotations
-
-from .link_list_params import LinkListParams as LinkListParams
-from .secure_tunnel_link import SecureTunnelLink as SecureTunnelLink
diff --git a/src/asktable/types/securetunnels/secure_tunnel_link.py b/src/asktable/types/securetunnels/secure_tunnel_link.py
deleted file mode 100644
index 23297881..00000000
--- a/src/asktable/types/securetunnels/secure_tunnel_link.py
+++ /dev/null
@@ -1,40 +0,0 @@
-# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-
-from typing import List, Optional
-from datetime import datetime
-
-from ..._models import BaseModel
-
-__all__ = ["SecureTunnelLink", "Item"]
-
-
-class Item(BaseModel):
- id: str
-
- created_at: datetime
-
- datasource_ids: List[str]
-
- modified_at: datetime
-
- proxy_port: int
-
- securetunnel_id: str
-
- status: str
-
- target_host: str
-
- target_port: int
-
-
-class SecureTunnelLink(BaseModel):
- items: List[Item]
-
- page: Optional[int] = None
-
- size: Optional[int] = None
-
- total: Optional[int] = None
-
- pages: Optional[int] = None
diff --git a/src/asktable/types/shared/__init__.py b/src/asktable/types/shared/__init__.py
index ec903e57..0784a6a1 100644
--- a/src/asktable/types/shared/__init__.py
+++ b/src/asktable/types/shared/__init__.py
@@ -1,5 +1,3 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
from .policy import Policy as Policy
-from .message import Message as Message
-from .answer_model import AnswerModel as AnswerModel
diff --git a/src/asktable/types/shared/answer_model.py b/src/asktable/types/shared/answer_model.py
deleted file mode 100644
index fe77eb55..00000000
--- a/src/asktable/types/shared/answer_model.py
+++ /dev/null
@@ -1,54 +0,0 @@
-# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-
-from typing import List, Optional
-
-from ..._models import BaseModel
-
-__all__ = ["AnswerModel", "Attachment", "QueryInsight", "QueryInsightInsight"]
-
-
-class Attachment(BaseModel):
- info: object
-
- type: str
- """The type of the attachment"""
-
-
-class QueryInsightInsight(BaseModel):
- duration: float
-
- name: str
-
- detail: Optional[object] = None
-
-
-class QueryInsight(BaseModel):
- datasource_id: str
-
- insight: List[QueryInsightInsight]
-
- question: str
-
- task: str
-
-
-class AnswerModel(BaseModel):
- attachments: Optional[List[Attachment]] = None
-
- duration: int
-
- error_detail: Optional[str] = None
-
- error_msg: Optional[str] = None
-
- payload: Optional[object] = None
-
- query_insight: Optional[QueryInsight] = None
-
- status: str
-
- text: str
-
- q2a_id: Optional[str] = None
-
- trace_id: Optional[str] = None
diff --git a/src/asktable/types/single_turn/__init__.py b/src/asktable/types/single_turn/__init__.py
index 448bcfb7..6b0bdb3c 100644
--- a/src/asktable/types/single_turn/__init__.py
+++ b/src/asktable/types/single_turn/__init__.py
@@ -2,10 +2,10 @@
from __future__ import annotations
+from .q2a_response import Q2aResponse as Q2aResponse
from .q2s_response import Q2sResponse as Q2sResponse
from .q2_list_params import Q2ListParams as Q2ListParams
from .q2a_list_params import Q2aListParams as Q2aListParams
from .q2_create_params import Q2CreateParams as Q2CreateParams
-from .q2_list_response import Q2ListResponse as Q2ListResponse
from .q2a_create_params import Q2aCreateParams as Q2aCreateParams
-from .q2a_list_response import Q2aListResponse as Q2aListResponse
+from .q2w_create_params import Q2wCreateParams as Q2wCreateParams
diff --git a/src/asktable/types/single_turn/q2_list_response.py b/src/asktable/types/single_turn/q2_list_response.py
deleted file mode 100644
index 0d4e0887..00000000
--- a/src/asktable/types/single_turn/q2_list_response.py
+++ /dev/null
@@ -1,54 +0,0 @@
-# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-
-from typing import List, Optional
-from datetime import datetime
-
-from ..._models import BaseModel
-
-__all__ = ["Q2ListResponse", "Item"]
-
-
-class Item(BaseModel):
- id: str
-
- created_at: datetime
-
- datasource_id: str
- """数据源 ID"""
-
- duration: Optional[int] = None
-
- modified_at: datetime
-
- project_id: str
-
- query: Optional[object] = None
-
- question: str
- """查询语句"""
-
- status: str
-
- err_msg: Optional[str] = None
- """错误信息"""
-
- role_id: Optional[str] = None
- """
- 角色 ID,将扮演这个角色来执行对话,用于权限控制。若无,则跳过鉴权,即可查询所有
- 数据
- """
-
- role_variables: Optional[object] = None
- """在扮演这个角色时需要传递的变量值,用 Key-Value 形式传递"""
-
-
-class Q2ListResponse(BaseModel):
- items: List[Item]
-
- page: Optional[int] = None
-
- size: Optional[int] = None
-
- total: Optional[int] = None
-
- pages: Optional[int] = None
diff --git a/src/asktable/types/single_turn/q2a_list_response.py b/src/asktable/types/single_turn/q2a_response.py
similarity index 77%
rename from src/asktable/types/single_turn/q2a_list_response.py
rename to src/asktable/types/single_turn/q2a_response.py
index 5f72e674..fae53ddd 100644
--- a/src/asktable/types/single_turn/q2a_list_response.py
+++ b/src/asktable/types/single_turn/q2a_response.py
@@ -1,14 +1,14 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-from typing import List, Optional
+from typing import Optional
from datetime import datetime
from ..._models import BaseModel
-__all__ = ["Q2aListResponse", "Item"]
+__all__ = ["Q2aResponse"]
-class Item(BaseModel):
+class Q2aResponse(BaseModel):
id: str
answer: Optional[object] = None
@@ -45,15 +45,3 @@ class Item(BaseModel):
with_json: Optional[bool] = None
"""是否同时将数据,作为 json 格式的附件一起返回"""
-
-
-class Q2aListResponse(BaseModel):
- items: List[Item]
-
- page: Optional[int] = None
-
- size: Optional[int] = None
-
- total: Optional[int] = None
-
- pages: Optional[int] = None
diff --git a/src/asktable/types/single_turn/q2s_response.py b/src/asktable/types/single_turn/q2s_response.py
index 3b07d399..c48e8987 100644
--- a/src/asktable/types/single_turn/q2s_response.py
+++ b/src/asktable/types/single_turn/q2s_response.py
@@ -1,31 +1,42 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-from typing import List, Optional
+from typing import Optional
+from datetime import datetime
from ..._models import BaseModel
-__all__ = ["Q2sResponse", "Question"]
+__all__ = ["Q2sResponse"]
-class Question(BaseModel):
- text: str
+class Q2sResponse(BaseModel):
+ id: str
- keywords: Optional[List[str]] = None
+ created_at: datetime
+ datasource_id: str
+ """数据源 ID"""
-class Q2sResponse(BaseModel):
- actual_used_table_names: List[str]
+ duration: Optional[int] = None
+
+ modified_at: datetime
- ds_id: str
+ project_id: str
- header: object
+ query: Optional[object] = None
- is_row_filtered: bool
+ question: str
+ """查询语句"""
- params: object
+ status: str
- prepared_statement: str
+ err_msg: Optional[str] = None
+ """错误信息"""
- question: Question
+ role_id: Optional[str] = None
+ """
+ 角色 ID,将扮演这个角色来执行对话,用于权限控制。若无,则跳过鉴权,即可查询所有
+ 数据
+ """
- cache_id: Optional[str] = None
+ role_variables: Optional[object] = None
+ """在扮演这个角色时需要传递的变量值,用 Key-Value 形式传递"""
diff --git a/src/asktable/types/single_turn/q2w_create_params.py b/src/asktable/types/single_turn/q2w_create_params.py
new file mode 100644
index 00000000..4b03cfe5
--- /dev/null
+++ b/src/asktable/types/single_turn/q2w_create_params.py
@@ -0,0 +1,11 @@
+# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+from __future__ import annotations
+
+from typing_extensions import Required, TypedDict
+
+__all__ = ["Q2wCreateParams"]
+
+
+class Q2wCreateParams(TypedDict, total=False):
+ body: Required[object]
diff --git a/src/asktable/types/sys/__init__.py b/src/asktable/types/sys/__init__.py
index 0b555d04..91995367 100644
--- a/src/asktable/types/sys/__init__.py
+++ b/src/asktable/types/sys/__init__.py
@@ -2,8 +2,8 @@
from __future__ import annotations
+from .api_key import APIKey as APIKey
from .project import Project as Project
from .project_list_params import ProjectListParams as ProjectListParams
from .project_create_params import ProjectCreateParams as ProjectCreateParams
-from .project_list_response import ProjectListResponse as ProjectListResponse
from .project_update_params import ProjectUpdateParams as ProjectUpdateParams
diff --git a/src/asktable/types/sys/projects/api_key.py b/src/asktable/types/sys/api_key.py
similarity index 94%
rename from src/asktable/types/sys/projects/api_key.py
rename to src/asktable/types/sys/api_key.py
index 045c6c00..1827ee5f 100644
--- a/src/asktable/types/sys/projects/api_key.py
+++ b/src/asktable/types/sys/api_key.py
@@ -4,7 +4,7 @@
from datetime import datetime
from typing_extensions import Literal
-from ...._models import BaseModel
+from ..._models import BaseModel
__all__ = ["APIKey"]
diff --git a/src/asktable/types/sys/project_list_response.py b/src/asktable/types/sys/project_list_response.py
deleted file mode 100644
index 75a4ed71..00000000
--- a/src/asktable/types/sys/project_list_response.py
+++ /dev/null
@@ -1,20 +0,0 @@
-# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-
-from typing import List, Optional
-
-from .project import Project
-from ..._models import BaseModel
-
-__all__ = ["ProjectListResponse"]
-
-
-class ProjectListResponse(BaseModel):
- items: List[Project]
-
- page: Optional[int] = None
-
- size: Optional[int] = None
-
- total: Optional[int] = None
-
- pages: Optional[int] = None
diff --git a/src/asktable/types/sys/projects/__init__.py b/src/asktable/types/sys/projects/__init__.py
index 2df1e9dd..6fd494c1 100644
--- a/src/asktable/types/sys/projects/__init__.py
+++ b/src/asktable/types/sys/projects/__init__.py
@@ -2,8 +2,7 @@
from __future__ import annotations
-from .api_key import APIKey as APIKey
-from .api_key_create import APIKeyCreate as APIKeyCreate
-from .token_create_params import TokenCreateParams as TokenCreateParams
from .api_key_create_params import APIKeyCreateParams as APIKeyCreateParams
from .api_key_list_response import APIKeyListResponse as APIKeyListResponse
+from .api_key_create_response import APIKeyCreateResponse as APIKeyCreateResponse
+from .api_key_create_token_params import APIKeyCreateTokenParams as APIKeyCreateTokenParams
diff --git a/src/asktable/types/sys/projects/api_key_create.py b/src/asktable/types/sys/projects/api_key_create_response.py
similarity index 89%
rename from src/asktable/types/sys/projects/api_key_create.py
rename to src/asktable/types/sys/projects/api_key_create_response.py
index 8c096e25..b468a0f8 100644
--- a/src/asktable/types/sys/projects/api_key_create.py
+++ b/src/asktable/types/sys/projects/api_key_create_response.py
@@ -6,10 +6,10 @@
from ...._models import BaseModel
-__all__ = ["APIKeyCreate"]
+__all__ = ["APIKeyCreateResponse"]
-class APIKeyCreate(BaseModel):
+class APIKeyCreateResponse(BaseModel):
id: str
"""API Key ID"""
diff --git a/src/asktable/types/auth/token_create_params.py b/src/asktable/types/sys/projects/api_key_create_token_params.py
similarity index 86%
rename from src/asktable/types/auth/token_create_params.py
rename to src/asktable/types/sys/projects/api_key_create_token_params.py
index 1103150c..212976c8 100644
--- a/src/asktable/types/auth/token_create_params.py
+++ b/src/asktable/types/sys/projects/api_key_create_token_params.py
@@ -5,10 +5,10 @@
from typing import Optional
from typing_extensions import Literal, TypedDict
-__all__ = ["TokenCreateParams", "ChatRole"]
+__all__ = ["APIKeyCreateTokenParams", "ChatRole"]
-class TokenCreateParams(TypedDict, total=False):
+class APIKeyCreateTokenParams(TypedDict, total=False):
ak_role: Literal["sys", "admin", "asker", "visitor"]
"""The role for the API key"""
diff --git a/src/asktable/types/sys/projects/api_key_list_response.py b/src/asktable/types/sys/projects/api_key_list_response.py
index e36d013f..41e5ca1e 100644
--- a/src/asktable/types/sys/projects/api_key_list_response.py
+++ b/src/asktable/types/sys/projects/api_key_list_response.py
@@ -3,7 +3,7 @@
from typing import List
from typing_extensions import TypeAlias
-from .api_key import APIKey
+from ..api_key import APIKey
__all__ = ["APIKeyListResponse"]
diff --git a/tests/api_resources/auth/__init__.py b/tests/api_resources/auth/__init__.py
deleted file mode 100644
index fd8019a9..00000000
--- a/tests/api_resources/auth/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
diff --git a/tests/api_resources/auth/test_me.py b/tests/api_resources/auth/test_me.py
deleted file mode 100644
index 281a8db2..00000000
--- a/tests/api_resources/auth/test_me.py
+++ /dev/null
@@ -1,71 +0,0 @@
-# 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 TestMe:
- parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"])
-
- @parametrize
- def test_method_retrieve(self, client: Asktable) -> None:
- me = client.auth.me.retrieve()
- assert_matches_type(object, me, path=["response"])
-
- @parametrize
- def test_raw_response_retrieve(self, client: Asktable) -> None:
- response = client.auth.me.with_raw_response.retrieve()
-
- assert response.is_closed is True
- assert response.http_request.headers.get("X-Stainless-Lang") == "python"
- me = response.parse()
- assert_matches_type(object, me, path=["response"])
-
- @parametrize
- def test_streaming_response_retrieve(self, client: Asktable) -> None:
- with client.auth.me.with_streaming_response.retrieve() as response:
- assert not response.is_closed
- assert response.http_request.headers.get("X-Stainless-Lang") == "python"
-
- me = response.parse()
- assert_matches_type(object, me, path=["response"])
-
- assert cast(Any, response.is_closed) is True
-
-
-class TestAsyncMe:
- parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"])
-
- @parametrize
- async def test_method_retrieve(self, async_client: AsyncAsktable) -> None:
- me = await async_client.auth.me.retrieve()
- assert_matches_type(object, me, path=["response"])
-
- @parametrize
- async def test_raw_response_retrieve(self, async_client: AsyncAsktable) -> None:
- response = await async_client.auth.me.with_raw_response.retrieve()
-
- assert response.is_closed is True
- assert response.http_request.headers.get("X-Stainless-Lang") == "python"
- me = await response.parse()
- assert_matches_type(object, me, path=["response"])
-
- @parametrize
- async def test_streaming_response_retrieve(self, async_client: AsyncAsktable) -> None:
- async with async_client.auth.me.with_streaming_response.retrieve() as response:
- assert not response.is_closed
- assert response.http_request.headers.get("X-Stainless-Lang") == "python"
-
- me = await response.parse()
- assert_matches_type(object, me, path=["response"])
-
- assert cast(Any, response.is_closed) is True
diff --git a/tests/api_resources/auth/test_tokens.py b/tests/api_resources/auth/test_tokens.py
deleted file mode 100644
index 0943713e..00000000
--- a/tests/api_resources/auth/test_tokens.py
+++ /dev/null
@@ -1,97 +0,0 @@
-# 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 TestTokens:
- parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"])
-
- @parametrize
- def test_method_create(self, client: Asktable) -> None:
- token = client.auth.tokens.create()
- assert_matches_type(object, token, path=["response"])
-
- @parametrize
- def test_method_create_with_all_params(self, client: Asktable) -> None:
- token = client.auth.tokens.create(
- ak_role="sys",
- chat_role={
- "role_id": "1",
- "role_variables": {"id": "42"},
- },
- token_ttl=900,
- user_profile={"name": "张三"},
- )
- assert_matches_type(object, token, path=["response"])
-
- @parametrize
- def test_raw_response_create(self, client: Asktable) -> None:
- response = client.auth.tokens.with_raw_response.create()
-
- assert response.is_closed is True
- assert response.http_request.headers.get("X-Stainless-Lang") == "python"
- token = response.parse()
- assert_matches_type(object, token, path=["response"])
-
- @parametrize
- def test_streaming_response_create(self, client: Asktable) -> None:
- with client.auth.tokens.with_streaming_response.create() as response:
- assert not response.is_closed
- assert response.http_request.headers.get("X-Stainless-Lang") == "python"
-
- token = response.parse()
- assert_matches_type(object, token, path=["response"])
-
- assert cast(Any, response.is_closed) is True
-
-
-class TestAsyncTokens:
- parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"])
-
- @parametrize
- async def test_method_create(self, async_client: AsyncAsktable) -> None:
- token = await async_client.auth.tokens.create()
- assert_matches_type(object, token, path=["response"])
-
- @parametrize
- async def test_method_create_with_all_params(self, async_client: AsyncAsktable) -> None:
- token = await async_client.auth.tokens.create(
- ak_role="sys",
- chat_role={
- "role_id": "1",
- "role_variables": {"id": "42"},
- },
- token_ttl=900,
- user_profile={"name": "张三"},
- )
- assert_matches_type(object, token, path=["response"])
-
- @parametrize
- async def test_raw_response_create(self, async_client: AsyncAsktable) -> None:
- response = await async_client.auth.tokens.with_raw_response.create()
-
- assert response.is_closed is True
- assert response.http_request.headers.get("X-Stainless-Lang") == "python"
- token = await response.parse()
- assert_matches_type(object, token, path=["response"])
-
- @parametrize
- async def test_streaming_response_create(self, async_client: AsyncAsktable) -> None:
- async with async_client.auth.tokens.with_streaming_response.create() as response:
- assert not response.is_closed
- assert response.http_request.headers.get("X-Stainless-Lang") == "python"
-
- token = await response.parse()
- assert_matches_type(object, token, path=["response"])
-
- assert cast(Any, response.is_closed) is True
diff --git a/tests/api_resources/chats/test_messages.py b/tests/api_resources/chats/test_messages.py
index 938b5f57..ce836623 100644
--- a/tests/api_resources/chats/test_messages.py
+++ b/tests/api_resources/chats/test_messages.py
@@ -9,8 +9,8 @@
from asktable import Asktable, AsyncAsktable
from tests.utils import assert_matches_type
-from asktable.types.chats import MessageListResponse
-from asktable.types.shared import Message
+from asktable.types import Message
+from asktable.pagination import SyncPage, AsyncPage
base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
@@ -18,48 +18,6 @@
class TestMessages:
parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"])
- @parametrize
- def test_method_create(self, client: Asktable) -> None:
- message = client.chats.messages.create(
- chat_id="chat_id",
- question="question",
- )
- assert_matches_type(Message, message, path=["response"])
-
- @parametrize
- def test_raw_response_create(self, client: Asktable) -> None:
- response = client.chats.messages.with_raw_response.create(
- chat_id="chat_id",
- question="question",
- )
-
- assert response.is_closed is True
- assert response.http_request.headers.get("X-Stainless-Lang") == "python"
- message = response.parse()
- assert_matches_type(Message, message, path=["response"])
-
- @parametrize
- def test_streaming_response_create(self, client: Asktable) -> None:
- with client.chats.messages.with_streaming_response.create(
- chat_id="chat_id",
- question="question",
- ) as response:
- assert not response.is_closed
- assert response.http_request.headers.get("X-Stainless-Lang") == "python"
-
- message = response.parse()
- assert_matches_type(Message, message, path=["response"])
-
- assert cast(Any, response.is_closed) is True
-
- @parametrize
- def test_path_params_create(self, client: Asktable) -> None:
- with pytest.raises(ValueError, match=r"Expected a non-empty value for `chat_id` but received ''"):
- client.chats.messages.with_raw_response.create(
- chat_id="",
- question="question",
- )
-
@parametrize
def test_method_retrieve(self, client: Asktable) -> None:
message = client.chats.messages.retrieve(
@@ -113,7 +71,7 @@ def test_method_list(self, client: Asktable) -> None:
message = client.chats.messages.list(
chat_id="chat_id",
)
- assert_matches_type(MessageListResponse, message, path=["response"])
+ assert_matches_type(SyncPage[Message], message, path=["response"])
@parametrize
def test_method_list_with_all_params(self, client: Asktable) -> None:
@@ -122,7 +80,7 @@ def test_method_list_with_all_params(self, client: Asktable) -> None:
page=1,
size=1,
)
- assert_matches_type(MessageListResponse, message, path=["response"])
+ assert_matches_type(SyncPage[Message], message, path=["response"])
@parametrize
def test_raw_response_list(self, client: Asktable) -> None:
@@ -133,7 +91,7 @@ def test_raw_response_list(self, client: Asktable) -> None:
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
message = response.parse()
- assert_matches_type(MessageListResponse, message, path=["response"])
+ assert_matches_type(SyncPage[Message], message, path=["response"])
@parametrize
def test_streaming_response_list(self, client: Asktable) -> None:
@@ -144,7 +102,7 @@ def test_streaming_response_list(self, client: Asktable) -> None:
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
message = response.parse()
- assert_matches_type(MessageListResponse, message, path=["response"])
+ assert_matches_type(SyncPage[Message], message, path=["response"])
assert cast(Any, response.is_closed) is True
@@ -155,52 +113,52 @@ def test_path_params_list(self, client: Asktable) -> None:
chat_id="",
)
-
-class TestAsyncMessages:
- parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"])
-
@parametrize
- async def test_method_create(self, async_client: AsyncAsktable) -> None:
- message = await async_client.chats.messages.create(
+ def test_method_send_message(self, client: Asktable) -> None:
+ message = client.chats.messages.send_message(
chat_id="chat_id",
question="question",
)
assert_matches_type(Message, message, path=["response"])
@parametrize
- async def test_raw_response_create(self, async_client: AsyncAsktable) -> None:
- response = await async_client.chats.messages.with_raw_response.create(
+ def test_raw_response_send_message(self, client: Asktable) -> None:
+ response = client.chats.messages.with_raw_response.send_message(
chat_id="chat_id",
question="question",
)
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
- message = await response.parse()
+ message = response.parse()
assert_matches_type(Message, message, path=["response"])
@parametrize
- async def test_streaming_response_create(self, async_client: AsyncAsktable) -> None:
- async with async_client.chats.messages.with_streaming_response.create(
+ def test_streaming_response_send_message(self, client: Asktable) -> None:
+ with client.chats.messages.with_streaming_response.send_message(
chat_id="chat_id",
question="question",
) as response:
assert not response.is_closed
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
- message = await response.parse()
+ message = response.parse()
assert_matches_type(Message, message, path=["response"])
assert cast(Any, response.is_closed) is True
@parametrize
- async def test_path_params_create(self, async_client: AsyncAsktable) -> None:
+ def test_path_params_send_message(self, client: Asktable) -> None:
with pytest.raises(ValueError, match=r"Expected a non-empty value for `chat_id` but received ''"):
- await async_client.chats.messages.with_raw_response.create(
+ client.chats.messages.with_raw_response.send_message(
chat_id="",
question="question",
)
+
+class TestAsyncMessages:
+ parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"])
+
@parametrize
async def test_method_retrieve(self, async_client: AsyncAsktable) -> None:
message = await async_client.chats.messages.retrieve(
@@ -254,7 +212,7 @@ async def test_method_list(self, async_client: AsyncAsktable) -> None:
message = await async_client.chats.messages.list(
chat_id="chat_id",
)
- assert_matches_type(MessageListResponse, message, path=["response"])
+ assert_matches_type(AsyncPage[Message], message, path=["response"])
@parametrize
async def test_method_list_with_all_params(self, async_client: AsyncAsktable) -> None:
@@ -263,7 +221,7 @@ async def test_method_list_with_all_params(self, async_client: AsyncAsktable) ->
page=1,
size=1,
)
- assert_matches_type(MessageListResponse, message, path=["response"])
+ assert_matches_type(AsyncPage[Message], message, path=["response"])
@parametrize
async def test_raw_response_list(self, async_client: AsyncAsktable) -> None:
@@ -274,7 +232,7 @@ async def test_raw_response_list(self, async_client: AsyncAsktable) -> None:
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
message = await response.parse()
- assert_matches_type(MessageListResponse, message, path=["response"])
+ assert_matches_type(AsyncPage[Message], message, path=["response"])
@parametrize
async def test_streaming_response_list(self, async_client: AsyncAsktable) -> None:
@@ -285,7 +243,7 @@ async def test_streaming_response_list(self, async_client: AsyncAsktable) -> Non
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
message = await response.parse()
- assert_matches_type(MessageListResponse, message, path=["response"])
+ assert_matches_type(AsyncPage[Message], message, path=["response"])
assert cast(Any, response.is_closed) is True
@@ -295,3 +253,45 @@ async def test_path_params_list(self, async_client: AsyncAsktable) -> None:
await async_client.chats.messages.with_raw_response.list(
chat_id="",
)
+
+ @parametrize
+ async def test_method_send_message(self, async_client: AsyncAsktable) -> None:
+ message = await async_client.chats.messages.send_message(
+ chat_id="chat_id",
+ question="question",
+ )
+ assert_matches_type(Message, message, path=["response"])
+
+ @parametrize
+ async def test_raw_response_send_message(self, async_client: AsyncAsktable) -> None:
+ response = await async_client.chats.messages.with_raw_response.send_message(
+ chat_id="chat_id",
+ question="question",
+ )
+
+ assert response.is_closed is True
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+ message = await response.parse()
+ assert_matches_type(Message, message, path=["response"])
+
+ @parametrize
+ async def test_streaming_response_send_message(self, async_client: AsyncAsktable) -> None:
+ async with async_client.chats.messages.with_streaming_response.send_message(
+ chat_id="chat_id",
+ question="question",
+ ) as response:
+ assert not response.is_closed
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+
+ message = await response.parse()
+ assert_matches_type(Message, message, path=["response"])
+
+ assert cast(Any, response.is_closed) is True
+
+ @parametrize
+ async def test_path_params_send_message(self, async_client: AsyncAsktable) -> None:
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `chat_id` but received ''"):
+ await async_client.chats.messages.with_raw_response.send_message(
+ chat_id="",
+ question="question",
+ )
diff --git a/tests/api_resources/datasources/test_indexes.py b/tests/api_resources/datasources/test_indexes.py
new file mode 100644
index 00000000..338264f7
--- /dev/null
+++ b/tests/api_resources/datasources/test_indexes.py
@@ -0,0 +1,335 @@
+# 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 Index
+from asktable.pagination import SyncPage, AsyncPage
+
+base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
+
+
+class TestIndexes:
+ parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"])
+
+ @parametrize
+ def test_method_create(self, client: Asktable) -> None:
+ index = client.datasources.indexes.create(
+ ds_id="ds_id",
+ field_name="field_name",
+ schema_name="schema_name",
+ table_name="table_name",
+ )
+ assert_matches_type(object, index, path=["response"])
+
+ @parametrize
+ def test_method_create_with_all_params(self, client: Asktable) -> None:
+ index = client.datasources.indexes.create(
+ ds_id="ds_id",
+ field_name="field_name",
+ schema_name="schema_name",
+ table_name="table_name",
+ async_process=True,
+ )
+ assert_matches_type(object, index, path=["response"])
+
+ @parametrize
+ def test_raw_response_create(self, client: Asktable) -> None:
+ response = client.datasources.indexes.with_raw_response.create(
+ ds_id="ds_id",
+ field_name="field_name",
+ schema_name="schema_name",
+ table_name="table_name",
+ )
+
+ assert response.is_closed is True
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+ index = response.parse()
+ assert_matches_type(object, index, path=["response"])
+
+ @parametrize
+ def test_streaming_response_create(self, client: Asktable) -> None:
+ with client.datasources.indexes.with_streaming_response.create(
+ ds_id="ds_id",
+ field_name="field_name",
+ schema_name="schema_name",
+ table_name="table_name",
+ ) as response:
+ assert not response.is_closed
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+
+ index = response.parse()
+ assert_matches_type(object, index, path=["response"])
+
+ assert cast(Any, response.is_closed) is True
+
+ @parametrize
+ def test_path_params_create(self, client: Asktable) -> None:
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `ds_id` but received ''"):
+ client.datasources.indexes.with_raw_response.create(
+ ds_id="",
+ field_name="field_name",
+ schema_name="schema_name",
+ table_name="table_name",
+ )
+
+ @parametrize
+ def test_method_list(self, client: Asktable) -> None:
+ index = client.datasources.indexes.list(
+ ds_id="ds_id",
+ )
+ assert_matches_type(SyncPage[Index], index, path=["response"])
+
+ @parametrize
+ def test_method_list_with_all_params(self, client: Asktable) -> None:
+ index = client.datasources.indexes.list(
+ ds_id="ds_id",
+ page=1,
+ size=1,
+ )
+ assert_matches_type(SyncPage[Index], index, path=["response"])
+
+ @parametrize
+ def test_raw_response_list(self, client: Asktable) -> None:
+ response = client.datasources.indexes.with_raw_response.list(
+ ds_id="ds_id",
+ )
+
+ assert response.is_closed is True
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+ index = response.parse()
+ assert_matches_type(SyncPage[Index], index, path=["response"])
+
+ @parametrize
+ def test_streaming_response_list(self, client: Asktable) -> None:
+ with client.datasources.indexes.with_streaming_response.list(
+ ds_id="ds_id",
+ ) as response:
+ assert not response.is_closed
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+
+ index = response.parse()
+ assert_matches_type(SyncPage[Index], index, path=["response"])
+
+ assert cast(Any, response.is_closed) is True
+
+ @parametrize
+ def test_path_params_list(self, client: Asktable) -> None:
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `ds_id` but received ''"):
+ client.datasources.indexes.with_raw_response.list(
+ ds_id="",
+ )
+
+ @parametrize
+ def test_method_delete(self, client: Asktable) -> None:
+ index = client.datasources.indexes.delete(
+ index_id="index_id",
+ ds_id="ds_id",
+ )
+ assert_matches_type(object, index, path=["response"])
+
+ @parametrize
+ def test_raw_response_delete(self, client: Asktable) -> None:
+ response = client.datasources.indexes.with_raw_response.delete(
+ index_id="index_id",
+ ds_id="ds_id",
+ )
+
+ assert response.is_closed is True
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+ index = response.parse()
+ assert_matches_type(object, index, path=["response"])
+
+ @parametrize
+ def test_streaming_response_delete(self, client: Asktable) -> None:
+ with client.datasources.indexes.with_streaming_response.delete(
+ index_id="index_id",
+ ds_id="ds_id",
+ ) as response:
+ assert not response.is_closed
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+
+ index = response.parse()
+ assert_matches_type(object, index, path=["response"])
+
+ assert cast(Any, response.is_closed) is True
+
+ @parametrize
+ def test_path_params_delete(self, client: Asktable) -> None:
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `ds_id` but received ''"):
+ client.datasources.indexes.with_raw_response.delete(
+ index_id="index_id",
+ ds_id="",
+ )
+
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `index_id` but received ''"):
+ client.datasources.indexes.with_raw_response.delete(
+ index_id="",
+ ds_id="ds_id",
+ )
+
+
+class TestAsyncIndexes:
+ parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"])
+
+ @parametrize
+ async def test_method_create(self, async_client: AsyncAsktable) -> None:
+ index = await async_client.datasources.indexes.create(
+ ds_id="ds_id",
+ field_name="field_name",
+ schema_name="schema_name",
+ table_name="table_name",
+ )
+ assert_matches_type(object, index, path=["response"])
+
+ @parametrize
+ async def test_method_create_with_all_params(self, async_client: AsyncAsktable) -> None:
+ index = await async_client.datasources.indexes.create(
+ ds_id="ds_id",
+ field_name="field_name",
+ schema_name="schema_name",
+ table_name="table_name",
+ async_process=True,
+ )
+ assert_matches_type(object, index, path=["response"])
+
+ @parametrize
+ async def test_raw_response_create(self, async_client: AsyncAsktable) -> None:
+ response = await async_client.datasources.indexes.with_raw_response.create(
+ ds_id="ds_id",
+ field_name="field_name",
+ schema_name="schema_name",
+ table_name="table_name",
+ )
+
+ assert response.is_closed is True
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+ index = await response.parse()
+ assert_matches_type(object, index, path=["response"])
+
+ @parametrize
+ async def test_streaming_response_create(self, async_client: AsyncAsktable) -> None:
+ async with async_client.datasources.indexes.with_streaming_response.create(
+ ds_id="ds_id",
+ field_name="field_name",
+ schema_name="schema_name",
+ table_name="table_name",
+ ) as response:
+ assert not response.is_closed
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+
+ index = await response.parse()
+ assert_matches_type(object, index, path=["response"])
+
+ assert cast(Any, response.is_closed) is True
+
+ @parametrize
+ async def test_path_params_create(self, async_client: AsyncAsktable) -> None:
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `ds_id` but received ''"):
+ await async_client.datasources.indexes.with_raw_response.create(
+ ds_id="",
+ field_name="field_name",
+ schema_name="schema_name",
+ table_name="table_name",
+ )
+
+ @parametrize
+ async def test_method_list(self, async_client: AsyncAsktable) -> None:
+ index = await async_client.datasources.indexes.list(
+ ds_id="ds_id",
+ )
+ assert_matches_type(AsyncPage[Index], index, path=["response"])
+
+ @parametrize
+ async def test_method_list_with_all_params(self, async_client: AsyncAsktable) -> None:
+ index = await async_client.datasources.indexes.list(
+ ds_id="ds_id",
+ page=1,
+ size=1,
+ )
+ assert_matches_type(AsyncPage[Index], index, path=["response"])
+
+ @parametrize
+ async def test_raw_response_list(self, async_client: AsyncAsktable) -> None:
+ response = await async_client.datasources.indexes.with_raw_response.list(
+ ds_id="ds_id",
+ )
+
+ assert response.is_closed is True
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+ index = await response.parse()
+ assert_matches_type(AsyncPage[Index], index, path=["response"])
+
+ @parametrize
+ async def test_streaming_response_list(self, async_client: AsyncAsktable) -> None:
+ async with async_client.datasources.indexes.with_streaming_response.list(
+ ds_id="ds_id",
+ ) as response:
+ assert not response.is_closed
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+
+ index = await response.parse()
+ assert_matches_type(AsyncPage[Index], index, path=["response"])
+
+ assert cast(Any, response.is_closed) is True
+
+ @parametrize
+ async def test_path_params_list(self, async_client: AsyncAsktable) -> None:
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `ds_id` but received ''"):
+ await async_client.datasources.indexes.with_raw_response.list(
+ ds_id="",
+ )
+
+ @parametrize
+ async def test_method_delete(self, async_client: AsyncAsktable) -> None:
+ index = await async_client.datasources.indexes.delete(
+ index_id="index_id",
+ ds_id="ds_id",
+ )
+ assert_matches_type(object, index, path=["response"])
+
+ @parametrize
+ async def test_raw_response_delete(self, async_client: AsyncAsktable) -> None:
+ response = await async_client.datasources.indexes.with_raw_response.delete(
+ index_id="index_id",
+ ds_id="ds_id",
+ )
+
+ assert response.is_closed is True
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+ index = await response.parse()
+ assert_matches_type(object, index, path=["response"])
+
+ @parametrize
+ async def test_streaming_response_delete(self, async_client: AsyncAsktable) -> None:
+ async with async_client.datasources.indexes.with_streaming_response.delete(
+ index_id="index_id",
+ ds_id="ds_id",
+ ) as response:
+ assert not response.is_closed
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+
+ index = await response.parse()
+ assert_matches_type(object, index, path=["response"])
+
+ assert cast(Any, response.is_closed) is True
+
+ @parametrize
+ async def test_path_params_delete(self, async_client: AsyncAsktable) -> None:
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `ds_id` but received ''"):
+ await async_client.datasources.indexes.with_raw_response.delete(
+ index_id="index_id",
+ ds_id="",
+ )
+
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `index_id` but received ''"):
+ await async_client.datasources.indexes.with_raw_response.delete(
+ index_id="",
+ ds_id="ds_id",
+ )
diff --git a/tests/api_resources/datasources/test_meta.py b/tests/api_resources/datasources/test_meta.py
index f57aebc5..9c58e10f 100644
--- a/tests/api_resources/datasources/test_meta.py
+++ b/tests/api_resources/datasources/test_meta.py
@@ -9,7 +9,7 @@
from asktable import Asktable, AsyncAsktable
from tests.utils import assert_matches_type
-from asktable.types.datasources import Meta
+from asktable.types import Meta
base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
@@ -282,16 +282,18 @@ def test_path_params_update_overload_2(self, client: Asktable) -> None:
)
@parametrize
- def test_method_delete(self, client: Asktable) -> None:
- meta = client.datasources.meta.delete(
- "datasource_id",
+ def test_method_annotate(self, client: Asktable) -> None:
+ meta = client.datasources.meta.annotate(
+ datasource_id="datasource_id",
+ schemas={"foo": {"tables": {"foo": {"fields": {"foo": "string"}}}}},
)
assert_matches_type(object, meta, path=["response"])
@parametrize
- def test_raw_response_delete(self, client: Asktable) -> None:
- response = client.datasources.meta.with_raw_response.delete(
- "datasource_id",
+ def test_raw_response_annotate(self, client: Asktable) -> None:
+ response = client.datasources.meta.with_raw_response.annotate(
+ datasource_id="datasource_id",
+ schemas={"foo": {"tables": {"foo": {"fields": {"foo": "string"}}}}},
)
assert response.is_closed is True
@@ -300,9 +302,10 @@ def test_raw_response_delete(self, client: Asktable) -> None:
assert_matches_type(object, meta, path=["response"])
@parametrize
- def test_streaming_response_delete(self, client: Asktable) -> None:
- with client.datasources.meta.with_streaming_response.delete(
- "datasource_id",
+ def test_streaming_response_annotate(self, client: Asktable) -> None:
+ with client.datasources.meta.with_streaming_response.annotate(
+ datasource_id="datasource_id",
+ schemas={"foo": {"tables": {"foo": {"fields": {"foo": "string"}}}}},
) as response:
assert not response.is_closed
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
@@ -313,10 +316,11 @@ def test_streaming_response_delete(self, client: Asktable) -> None:
assert cast(Any, response.is_closed) is True
@parametrize
- def test_path_params_delete(self, client: Asktable) -> None:
+ def test_path_params_annotate(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.delete(
- "",
+ client.datasources.meta.with_raw_response.annotate(
+ datasource_id="",
+ schemas={"foo": {"tables": {"foo": {"fields": {"foo": "string"}}}}},
)
@@ -588,16 +592,18 @@ async def test_path_params_update_overload_2(self, async_client: AsyncAsktable)
)
@parametrize
- async def test_method_delete(self, async_client: AsyncAsktable) -> None:
- meta = await async_client.datasources.meta.delete(
- "datasource_id",
+ async def test_method_annotate(self, async_client: AsyncAsktable) -> None:
+ meta = await async_client.datasources.meta.annotate(
+ datasource_id="datasource_id",
+ schemas={"foo": {"tables": {"foo": {"fields": {"foo": "string"}}}}},
)
assert_matches_type(object, meta, path=["response"])
@parametrize
- async def test_raw_response_delete(self, async_client: AsyncAsktable) -> None:
- response = await async_client.datasources.meta.with_raw_response.delete(
- "datasource_id",
+ async def test_raw_response_annotate(self, async_client: AsyncAsktable) -> None:
+ response = await async_client.datasources.meta.with_raw_response.annotate(
+ datasource_id="datasource_id",
+ schemas={"foo": {"tables": {"foo": {"fields": {"foo": "string"}}}}},
)
assert response.is_closed is True
@@ -606,9 +612,10 @@ async def test_raw_response_delete(self, async_client: AsyncAsktable) -> None:
assert_matches_type(object, meta, path=["response"])
@parametrize
- async def test_streaming_response_delete(self, async_client: AsyncAsktable) -> None:
- async with async_client.datasources.meta.with_streaming_response.delete(
- "datasource_id",
+ async def test_streaming_response_annotate(self, async_client: AsyncAsktable) -> None:
+ async with async_client.datasources.meta.with_streaming_response.annotate(
+ datasource_id="datasource_id",
+ schemas={"foo": {"tables": {"foo": {"fields": {"foo": "string"}}}}},
) as response:
assert not response.is_closed
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
@@ -619,8 +626,9 @@ async def test_streaming_response_delete(self, async_client: AsyncAsktable) -> N
assert cast(Any, response.is_closed) is True
@parametrize
- async def test_path_params_delete(self, async_client: AsyncAsktable) -> None:
+ async def test_path_params_annotate(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.delete(
- "",
+ await async_client.datasources.meta.with_raw_response.annotate(
+ datasource_id="",
+ schemas={"foo": {"tables": {"foo": {"fields": {"foo": "string"}}}}},
)
diff --git a/tests/api_resources/extapis/test_routes.py b/tests/api_resources/extapis/test_routes.py
index 1519901a..5fa13718 100644
--- a/tests/api_resources/extapis/test_routes.py
+++ b/tests/api_resources/extapis/test_routes.py
@@ -10,7 +10,7 @@
from asktable import Asktable, AsyncAsktable
from tests.utils import assert_matches_type
from asktable._utils import parse_datetime
-from asktable.types.extapis import ExtAPIRouteModel, RouteListResponse
+from asktable.types.extapis import ExtapiRoute, RouteListResponse
base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
@@ -30,7 +30,7 @@ def test_method_create(self, client: Asktable) -> None:
path="/resource",
project_id="project_id",
)
- assert_matches_type(ExtAPIRouteModel, route, path=["response"])
+ assert_matches_type(ExtapiRoute, route, path=["response"])
@parametrize
def test_method_create_with_all_params(self, client: Asktable) -> None:
@@ -48,7 +48,7 @@ def test_method_create_with_all_params(self, client: Asktable) -> None:
query_params_desc="query_params_desc",
updated_at=parse_datetime("2019-12-27T18:11:19.117Z"),
)
- assert_matches_type(ExtAPIRouteModel, route, path=["response"])
+ assert_matches_type(ExtapiRoute, route, path=["response"])
@parametrize
def test_raw_response_create(self, client: Asktable) -> None:
@@ -66,7 +66,7 @@ def test_raw_response_create(self, client: Asktable) -> None:
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
route = response.parse()
- assert_matches_type(ExtAPIRouteModel, route, path=["response"])
+ assert_matches_type(ExtapiRoute, route, path=["response"])
@parametrize
def test_streaming_response_create(self, client: Asktable) -> None:
@@ -84,7 +84,7 @@ def test_streaming_response_create(self, client: Asktable) -> None:
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
route = response.parse()
- assert_matches_type(ExtAPIRouteModel, route, path=["response"])
+ assert_matches_type(ExtapiRoute, route, path=["response"])
assert cast(Any, response.is_closed) is True
@@ -108,7 +108,7 @@ def test_method_retrieve(self, client: Asktable) -> None:
route_id="route_id",
extapi_id="extapi_id",
)
- assert_matches_type(ExtAPIRouteModel, route, path=["response"])
+ assert_matches_type(ExtapiRoute, route, path=["response"])
@parametrize
def test_raw_response_retrieve(self, client: Asktable) -> None:
@@ -120,7 +120,7 @@ def test_raw_response_retrieve(self, client: Asktable) -> None:
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
route = response.parse()
- assert_matches_type(ExtAPIRouteModel, route, path=["response"])
+ assert_matches_type(ExtapiRoute, route, path=["response"])
@parametrize
def test_streaming_response_retrieve(self, client: Asktable) -> None:
@@ -132,7 +132,7 @@ def test_streaming_response_retrieve(self, client: Asktable) -> None:
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
route = response.parse()
- assert_matches_type(ExtAPIRouteModel, route, path=["response"])
+ assert_matches_type(ExtapiRoute, route, path=["response"])
assert cast(Any, response.is_closed) is True
@@ -156,7 +156,7 @@ def test_method_update(self, client: Asktable) -> None:
route_id="route_id",
extapi_id="extapi_id",
)
- assert_matches_type(ExtAPIRouteModel, route, path=["response"])
+ assert_matches_type(ExtapiRoute, route, path=["response"])
@parametrize
def test_method_update_with_all_params(self, client: Asktable) -> None:
@@ -170,7 +170,7 @@ def test_method_update_with_all_params(self, client: Asktable) -> None:
path_params_desc="path_params_desc",
query_params_desc="query_params_desc",
)
- assert_matches_type(ExtAPIRouteModel, route, path=["response"])
+ assert_matches_type(ExtapiRoute, route, path=["response"])
@parametrize
def test_raw_response_update(self, client: Asktable) -> None:
@@ -182,7 +182,7 @@ def test_raw_response_update(self, client: Asktable) -> None:
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
route = response.parse()
- assert_matches_type(ExtAPIRouteModel, route, path=["response"])
+ assert_matches_type(ExtapiRoute, route, path=["response"])
@parametrize
def test_streaming_response_update(self, client: Asktable) -> None:
@@ -194,7 +194,7 @@ def test_streaming_response_update(self, client: Asktable) -> None:
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
route = response.parse()
- assert_matches_type(ExtAPIRouteModel, route, path=["response"])
+ assert_matches_type(ExtapiRoute, route, path=["response"])
assert cast(Any, response.is_closed) is True
@@ -314,7 +314,7 @@ async def test_method_create(self, async_client: AsyncAsktable) -> None:
path="/resource",
project_id="project_id",
)
- assert_matches_type(ExtAPIRouteModel, route, path=["response"])
+ assert_matches_type(ExtapiRoute, route, path=["response"])
@parametrize
async def test_method_create_with_all_params(self, async_client: AsyncAsktable) -> None:
@@ -332,7 +332,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncAsktable)
query_params_desc="query_params_desc",
updated_at=parse_datetime("2019-12-27T18:11:19.117Z"),
)
- assert_matches_type(ExtAPIRouteModel, route, path=["response"])
+ assert_matches_type(ExtapiRoute, route, path=["response"])
@parametrize
async def test_raw_response_create(self, async_client: AsyncAsktable) -> None:
@@ -350,7 +350,7 @@ async def test_raw_response_create(self, async_client: AsyncAsktable) -> None:
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
route = await response.parse()
- assert_matches_type(ExtAPIRouteModel, route, path=["response"])
+ assert_matches_type(ExtapiRoute, route, path=["response"])
@parametrize
async def test_streaming_response_create(self, async_client: AsyncAsktable) -> None:
@@ -368,7 +368,7 @@ async def test_streaming_response_create(self, async_client: AsyncAsktable) -> N
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
route = await response.parse()
- assert_matches_type(ExtAPIRouteModel, route, path=["response"])
+ assert_matches_type(ExtapiRoute, route, path=["response"])
assert cast(Any, response.is_closed) is True
@@ -392,7 +392,7 @@ async def test_method_retrieve(self, async_client: AsyncAsktable) -> None:
route_id="route_id",
extapi_id="extapi_id",
)
- assert_matches_type(ExtAPIRouteModel, route, path=["response"])
+ assert_matches_type(ExtapiRoute, route, path=["response"])
@parametrize
async def test_raw_response_retrieve(self, async_client: AsyncAsktable) -> None:
@@ -404,7 +404,7 @@ async def test_raw_response_retrieve(self, async_client: AsyncAsktable) -> None:
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
route = await response.parse()
- assert_matches_type(ExtAPIRouteModel, route, path=["response"])
+ assert_matches_type(ExtapiRoute, route, path=["response"])
@parametrize
async def test_streaming_response_retrieve(self, async_client: AsyncAsktable) -> None:
@@ -416,7 +416,7 @@ async def test_streaming_response_retrieve(self, async_client: AsyncAsktable) ->
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
route = await response.parse()
- assert_matches_type(ExtAPIRouteModel, route, path=["response"])
+ assert_matches_type(ExtapiRoute, route, path=["response"])
assert cast(Any, response.is_closed) is True
@@ -440,7 +440,7 @@ async def test_method_update(self, async_client: AsyncAsktable) -> None:
route_id="route_id",
extapi_id="extapi_id",
)
- assert_matches_type(ExtAPIRouteModel, route, path=["response"])
+ assert_matches_type(ExtapiRoute, route, path=["response"])
@parametrize
async def test_method_update_with_all_params(self, async_client: AsyncAsktable) -> None:
@@ -454,7 +454,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncAsktable)
path_params_desc="path_params_desc",
query_params_desc="query_params_desc",
)
- assert_matches_type(ExtAPIRouteModel, route, path=["response"])
+ assert_matches_type(ExtapiRoute, route, path=["response"])
@parametrize
async def test_raw_response_update(self, async_client: AsyncAsktable) -> None:
@@ -466,7 +466,7 @@ async def test_raw_response_update(self, async_client: AsyncAsktable) -> None:
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
route = await response.parse()
- assert_matches_type(ExtAPIRouteModel, route, path=["response"])
+ assert_matches_type(ExtapiRoute, route, path=["response"])
@parametrize
async def test_streaming_response_update(self, async_client: AsyncAsktable) -> None:
@@ -478,7 +478,7 @@ async def test_streaming_response_update(self, async_client: AsyncAsktable) -> N
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
route = await response.parse()
- assert_matches_type(ExtAPIRouteModel, route, path=["response"])
+ assert_matches_type(ExtapiRoute, route, path=["response"])
assert cast(Any, response.is_closed) is True
diff --git a/tests/api_resources/integration/__init__.py b/tests/api_resources/integration/__init__.py
deleted file mode 100644
index fd8019a9..00000000
--- a/tests/api_resources/integration/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
diff --git a/tests/api_resources/integration/test_excel_csv.py b/tests/api_resources/integration/test_excel_csv.py
deleted file mode 100644
index 2901a152..00000000
--- a/tests/api_resources/integration/test_excel_csv.py
+++ /dev/null
@@ -1,84 +0,0 @@
-# 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 DataSource
-
-base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
-
-
-class TestExcelCsv:
- parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"])
-
- @parametrize
- def test_method_create(self, client: Asktable) -> None:
- excel_csv = client.integration.excel_csv.create(
- file_url="file_url",
- )
- assert_matches_type(DataSource, excel_csv, path=["response"])
-
- @parametrize
- def test_raw_response_create(self, client: Asktable) -> None:
- response = client.integration.excel_csv.with_raw_response.create(
- file_url="file_url",
- )
-
- assert response.is_closed is True
- assert response.http_request.headers.get("X-Stainless-Lang") == "python"
- excel_csv = response.parse()
- assert_matches_type(DataSource, excel_csv, path=["response"])
-
- @parametrize
- def test_streaming_response_create(self, client: Asktable) -> None:
- with client.integration.excel_csv.with_streaming_response.create(
- file_url="file_url",
- ) as response:
- assert not response.is_closed
- assert response.http_request.headers.get("X-Stainless-Lang") == "python"
-
- excel_csv = response.parse()
- assert_matches_type(DataSource, excel_csv, path=["response"])
-
- assert cast(Any, response.is_closed) is True
-
-
-class TestAsyncExcelCsv:
- parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"])
-
- @parametrize
- async def test_method_create(self, async_client: AsyncAsktable) -> None:
- excel_csv = await async_client.integration.excel_csv.create(
- file_url="file_url",
- )
- assert_matches_type(DataSource, excel_csv, path=["response"])
-
- @parametrize
- async def test_raw_response_create(self, async_client: AsyncAsktable) -> None:
- response = await async_client.integration.excel_csv.with_raw_response.create(
- file_url="file_url",
- )
-
- assert response.is_closed is True
- assert response.http_request.headers.get("X-Stainless-Lang") == "python"
- excel_csv = await response.parse()
- assert_matches_type(DataSource, excel_csv, path=["response"])
-
- @parametrize
- async def test_streaming_response_create(self, async_client: AsyncAsktable) -> None:
- async with async_client.integration.excel_csv.with_streaming_response.create(
- file_url="file_url",
- ) as response:
- assert not response.is_closed
- assert response.http_request.headers.get("X-Stainless-Lang") == "python"
-
- excel_csv = await response.parse()
- assert_matches_type(DataSource, excel_csv, path=["response"])
-
- assert cast(Any, response.is_closed) is True
diff --git a/tests/api_resources/roles/__init__.py b/tests/api_resources/roles/__init__.py
deleted file mode 100644
index fd8019a9..00000000
--- a/tests/api_resources/roles/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
diff --git a/tests/api_resources/roles/test_policies.py b/tests/api_resources/roles/test_policies.py
deleted file mode 100644
index b19bcca3..00000000
--- a/tests/api_resources/roles/test_policies.py
+++ /dev/null
@@ -1,98 +0,0 @@
-# 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.roles import PolicyListResponse
-
-base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
-
-
-class TestPolicies:
- parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"])
-
- @parametrize
- def test_method_list(self, client: Asktable) -> None:
- policy = client.roles.policies.list(
- "role_id",
- )
- assert_matches_type(PolicyListResponse, policy, path=["response"])
-
- @parametrize
- def test_raw_response_list(self, client: Asktable) -> None:
- response = client.roles.policies.with_raw_response.list(
- "role_id",
- )
-
- assert response.is_closed is True
- assert response.http_request.headers.get("X-Stainless-Lang") == "python"
- policy = response.parse()
- assert_matches_type(PolicyListResponse, policy, path=["response"])
-
- @parametrize
- def test_streaming_response_list(self, client: Asktable) -> None:
- with client.roles.policies.with_streaming_response.list(
- "role_id",
- ) as response:
- assert not response.is_closed
- assert response.http_request.headers.get("X-Stainless-Lang") == "python"
-
- policy = response.parse()
- assert_matches_type(PolicyListResponse, policy, path=["response"])
-
- assert cast(Any, response.is_closed) is True
-
- @parametrize
- def test_path_params_list(self, client: Asktable) -> None:
- with pytest.raises(ValueError, match=r"Expected a non-empty value for `role_id` but received ''"):
- client.roles.policies.with_raw_response.list(
- "",
- )
-
-
-class TestAsyncPolicies:
- parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"])
-
- @parametrize
- async def test_method_list(self, async_client: AsyncAsktable) -> None:
- policy = await async_client.roles.policies.list(
- "role_id",
- )
- assert_matches_type(PolicyListResponse, policy, path=["response"])
-
- @parametrize
- async def test_raw_response_list(self, async_client: AsyncAsktable) -> None:
- response = await async_client.roles.policies.with_raw_response.list(
- "role_id",
- )
-
- assert response.is_closed is True
- assert response.http_request.headers.get("X-Stainless-Lang") == "python"
- policy = await response.parse()
- assert_matches_type(PolicyListResponse, policy, path=["response"])
-
- @parametrize
- async def test_streaming_response_list(self, async_client: AsyncAsktable) -> None:
- async with async_client.roles.policies.with_streaming_response.list(
- "role_id",
- ) as response:
- assert not response.is_closed
- assert response.http_request.headers.get("X-Stainless-Lang") == "python"
-
- policy = await response.parse()
- assert_matches_type(PolicyListResponse, policy, path=["response"])
-
- assert cast(Any, response.is_closed) is True
-
- @parametrize
- async def test_path_params_list(self, async_client: AsyncAsktable) -> None:
- with pytest.raises(ValueError, match=r"Expected a non-empty value for `role_id` but received ''"):
- await async_client.roles.policies.with_raw_response.list(
- "",
- )
diff --git a/tests/api_resources/roles/test_variables.py b/tests/api_resources/roles/test_variables.py
deleted file mode 100644
index 05a08fad..00000000
--- a/tests/api_resources/roles/test_variables.py
+++ /dev/null
@@ -1,115 +0,0 @@
-# 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 TestVariables:
- parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"])
-
- @parametrize
- def test_method_list(self, client: Asktable) -> None:
- variable = client.roles.variables.list(
- role_id="role_id",
- )
- assert_matches_type(object, variable, path=["response"])
-
- @parametrize
- def test_method_list_with_all_params(self, client: Asktable) -> None:
- variable = client.roles.variables.list(
- role_id="role_id",
- bot_id="bot_id",
- datasource_ids=["string", "string", "string"],
- )
- assert_matches_type(object, variable, path=["response"])
-
- @parametrize
- def test_raw_response_list(self, client: Asktable) -> None:
- response = client.roles.variables.with_raw_response.list(
- role_id="role_id",
- )
-
- assert response.is_closed is True
- assert response.http_request.headers.get("X-Stainless-Lang") == "python"
- variable = response.parse()
- assert_matches_type(object, variable, path=["response"])
-
- @parametrize
- def test_streaming_response_list(self, client: Asktable) -> None:
- with client.roles.variables.with_streaming_response.list(
- role_id="role_id",
- ) as response:
- assert not response.is_closed
- assert response.http_request.headers.get("X-Stainless-Lang") == "python"
-
- variable = response.parse()
- assert_matches_type(object, variable, path=["response"])
-
- assert cast(Any, response.is_closed) is True
-
- @parametrize
- def test_path_params_list(self, client: Asktable) -> None:
- with pytest.raises(ValueError, match=r"Expected a non-empty value for `role_id` but received ''"):
- client.roles.variables.with_raw_response.list(
- role_id="",
- )
-
-
-class TestAsyncVariables:
- parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"])
-
- @parametrize
- async def test_method_list(self, async_client: AsyncAsktable) -> None:
- variable = await async_client.roles.variables.list(
- role_id="role_id",
- )
- assert_matches_type(object, variable, path=["response"])
-
- @parametrize
- async def test_method_list_with_all_params(self, async_client: AsyncAsktable) -> None:
- variable = await async_client.roles.variables.list(
- role_id="role_id",
- bot_id="bot_id",
- datasource_ids=["string", "string", "string"],
- )
- assert_matches_type(object, variable, path=["response"])
-
- @parametrize
- async def test_raw_response_list(self, async_client: AsyncAsktable) -> None:
- response = await async_client.roles.variables.with_raw_response.list(
- role_id="role_id",
- )
-
- assert response.is_closed is True
- assert response.http_request.headers.get("X-Stainless-Lang") == "python"
- variable = await response.parse()
- assert_matches_type(object, variable, path=["response"])
-
- @parametrize
- async def test_streaming_response_list(self, async_client: AsyncAsktable) -> None:
- async with async_client.roles.variables.with_streaming_response.list(
- role_id="role_id",
- ) as response:
- assert not response.is_closed
- assert response.http_request.headers.get("X-Stainless-Lang") == "python"
-
- variable = await response.parse()
- assert_matches_type(object, variable, path=["response"])
-
- assert cast(Any, response.is_closed) is True
-
- @parametrize
- async def test_path_params_list(self, async_client: AsyncAsktable) -> None:
- with pytest.raises(ValueError, match=r"Expected a non-empty value for `role_id` but received ''"):
- await async_client.roles.variables.with_raw_response.list(
- role_id="",
- )
diff --git a/tests/api_resources/securetunnels/__init__.py b/tests/api_resources/securetunnels/__init__.py
deleted file mode 100644
index fd8019a9..00000000
--- a/tests/api_resources/securetunnels/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
diff --git a/tests/api_resources/securetunnels/test_links.py b/tests/api_resources/securetunnels/test_links.py
deleted file mode 100644
index b465ee58..00000000
--- a/tests/api_resources/securetunnels/test_links.py
+++ /dev/null
@@ -1,116 +0,0 @@
-# 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.securetunnels import SecureTunnelLink
-
-base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
-
-
-class TestLinks:
- parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"])
-
- @parametrize
- def test_method_list(self, client: Asktable) -> None:
- link = client.securetunnels.links.list(
- securetunnel_id="securetunnel_id",
- )
- assert_matches_type(SecureTunnelLink, link, path=["response"])
-
- @parametrize
- def test_method_list_with_all_params(self, client: Asktable) -> None:
- link = client.securetunnels.links.list(
- securetunnel_id="securetunnel_id",
- page=1,
- size=1,
- )
- assert_matches_type(SecureTunnelLink, link, path=["response"])
-
- @parametrize
- def test_raw_response_list(self, client: Asktable) -> None:
- response = client.securetunnels.links.with_raw_response.list(
- securetunnel_id="securetunnel_id",
- )
-
- assert response.is_closed is True
- assert response.http_request.headers.get("X-Stainless-Lang") == "python"
- link = response.parse()
- assert_matches_type(SecureTunnelLink, link, path=["response"])
-
- @parametrize
- def test_streaming_response_list(self, client: Asktable) -> None:
- with client.securetunnels.links.with_streaming_response.list(
- securetunnel_id="securetunnel_id",
- ) as response:
- assert not response.is_closed
- assert response.http_request.headers.get("X-Stainless-Lang") == "python"
-
- link = response.parse()
- assert_matches_type(SecureTunnelLink, link, path=["response"])
-
- assert cast(Any, response.is_closed) is True
-
- @parametrize
- def test_path_params_list(self, client: Asktable) -> None:
- with pytest.raises(ValueError, match=r"Expected a non-empty value for `securetunnel_id` but received ''"):
- client.securetunnels.links.with_raw_response.list(
- securetunnel_id="",
- )
-
-
-class TestAsyncLinks:
- parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"])
-
- @parametrize
- async def test_method_list(self, async_client: AsyncAsktable) -> None:
- link = await async_client.securetunnels.links.list(
- securetunnel_id="securetunnel_id",
- )
- assert_matches_type(SecureTunnelLink, link, path=["response"])
-
- @parametrize
- async def test_method_list_with_all_params(self, async_client: AsyncAsktable) -> None:
- link = await async_client.securetunnels.links.list(
- securetunnel_id="securetunnel_id",
- page=1,
- size=1,
- )
- assert_matches_type(SecureTunnelLink, link, path=["response"])
-
- @parametrize
- async def test_raw_response_list(self, async_client: AsyncAsktable) -> None:
- response = await async_client.securetunnels.links.with_raw_response.list(
- securetunnel_id="securetunnel_id",
- )
-
- assert response.is_closed is True
- assert response.http_request.headers.get("X-Stainless-Lang") == "python"
- link = await response.parse()
- assert_matches_type(SecureTunnelLink, link, path=["response"])
-
- @parametrize
- async def test_streaming_response_list(self, async_client: AsyncAsktable) -> None:
- async with async_client.securetunnels.links.with_streaming_response.list(
- securetunnel_id="securetunnel_id",
- ) as response:
- assert not response.is_closed
- assert response.http_request.headers.get("X-Stainless-Lang") == "python"
-
- link = await response.parse()
- assert_matches_type(SecureTunnelLink, link, path=["response"])
-
- assert cast(Any, response.is_closed) is True
-
- @parametrize
- async def test_path_params_list(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.links.with_raw_response.list(
- securetunnel_id="",
- )
diff --git a/tests/api_resources/single_turn/test_q2a.py b/tests/api_resources/single_turn/test_q2a.py
index 76d3d36a..7ff8e41e 100644
--- a/tests/api_resources/single_turn/test_q2a.py
+++ b/tests/api_resources/single_turn/test_q2a.py
@@ -9,8 +9,8 @@
from asktable import Asktable, AsyncAsktable
from tests.utils import assert_matches_type
-from asktable.types.shared import AnswerModel
-from asktable.types.single_turn import Q2aListResponse
+from asktable.pagination import SyncPage, AsyncPage
+from asktable.types.single_turn import Q2aResponse
base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
@@ -24,7 +24,7 @@ def test_method_create(self, client: Asktable) -> None:
datasource_id="datasource_id",
question="question",
)
- assert_matches_type(AnswerModel, q2a, path=["response"])
+ assert_matches_type(Q2aResponse, q2a, path=["response"])
@parametrize
def test_method_create_with_all_params(self, client: Asktable) -> None:
@@ -36,7 +36,7 @@ def test_method_create_with_all_params(self, client: Asktable) -> None:
role_variables={},
with_json=True,
)
- assert_matches_type(AnswerModel, q2a, path=["response"])
+ assert_matches_type(Q2aResponse, q2a, path=["response"])
@parametrize
def test_raw_response_create(self, client: Asktable) -> None:
@@ -48,7 +48,7 @@ def test_raw_response_create(self, client: Asktable) -> None:
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
q2a = response.parse()
- assert_matches_type(AnswerModel, q2a, path=["response"])
+ assert_matches_type(Q2aResponse, q2a, path=["response"])
@parametrize
def test_streaming_response_create(self, client: Asktable) -> None:
@@ -60,14 +60,14 @@ def test_streaming_response_create(self, client: Asktable) -> None:
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
q2a = response.parse()
- assert_matches_type(AnswerModel, q2a, path=["response"])
+ assert_matches_type(Q2aResponse, q2a, path=["response"])
assert cast(Any, response.is_closed) is True
@parametrize
def test_method_list(self, client: Asktable) -> None:
q2a = client.single_turn.q2a.list()
- assert_matches_type(Q2aListResponse, q2a, path=["response"])
+ assert_matches_type(SyncPage[Q2aResponse], q2a, path=["response"])
@parametrize
def test_method_list_with_all_params(self, client: Asktable) -> None:
@@ -76,7 +76,7 @@ def test_method_list_with_all_params(self, client: Asktable) -> None:
page=1,
size=1,
)
- assert_matches_type(Q2aListResponse, q2a, path=["response"])
+ assert_matches_type(SyncPage[Q2aResponse], q2a, path=["response"])
@parametrize
def test_raw_response_list(self, client: Asktable) -> None:
@@ -85,7 +85,7 @@ def test_raw_response_list(self, client: Asktable) -> None:
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
q2a = response.parse()
- assert_matches_type(Q2aListResponse, q2a, path=["response"])
+ assert_matches_type(SyncPage[Q2aResponse], q2a, path=["response"])
@parametrize
def test_streaming_response_list(self, client: Asktable) -> None:
@@ -94,7 +94,7 @@ def test_streaming_response_list(self, client: Asktable) -> None:
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
q2a = response.parse()
- assert_matches_type(Q2aListResponse, q2a, path=["response"])
+ assert_matches_type(SyncPage[Q2aResponse], q2a, path=["response"])
assert cast(Any, response.is_closed) is True
@@ -108,7 +108,7 @@ async def test_method_create(self, async_client: AsyncAsktable) -> None:
datasource_id="datasource_id",
question="question",
)
- assert_matches_type(AnswerModel, q2a, path=["response"])
+ assert_matches_type(Q2aResponse, q2a, path=["response"])
@parametrize
async def test_method_create_with_all_params(self, async_client: AsyncAsktable) -> None:
@@ -120,7 +120,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncAsktable)
role_variables={},
with_json=True,
)
- assert_matches_type(AnswerModel, q2a, path=["response"])
+ assert_matches_type(Q2aResponse, q2a, path=["response"])
@parametrize
async def test_raw_response_create(self, async_client: AsyncAsktable) -> None:
@@ -132,7 +132,7 @@ async def test_raw_response_create(self, async_client: AsyncAsktable) -> None:
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
q2a = await response.parse()
- assert_matches_type(AnswerModel, q2a, path=["response"])
+ assert_matches_type(Q2aResponse, q2a, path=["response"])
@parametrize
async def test_streaming_response_create(self, async_client: AsyncAsktable) -> None:
@@ -144,14 +144,14 @@ async def test_streaming_response_create(self, async_client: AsyncAsktable) -> N
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
q2a = await response.parse()
- assert_matches_type(AnswerModel, q2a, path=["response"])
+ assert_matches_type(Q2aResponse, q2a, path=["response"])
assert cast(Any, response.is_closed) is True
@parametrize
async def test_method_list(self, async_client: AsyncAsktable) -> None:
q2a = await async_client.single_turn.q2a.list()
- assert_matches_type(Q2aListResponse, q2a, path=["response"])
+ assert_matches_type(AsyncPage[Q2aResponse], q2a, path=["response"])
@parametrize
async def test_method_list_with_all_params(self, async_client: AsyncAsktable) -> None:
@@ -160,7 +160,7 @@ async def test_method_list_with_all_params(self, async_client: AsyncAsktable) ->
page=1,
size=1,
)
- assert_matches_type(Q2aListResponse, q2a, path=["response"])
+ assert_matches_type(AsyncPage[Q2aResponse], q2a, path=["response"])
@parametrize
async def test_raw_response_list(self, async_client: AsyncAsktable) -> None:
@@ -169,7 +169,7 @@ async def test_raw_response_list(self, async_client: AsyncAsktable) -> None:
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
q2a = await response.parse()
- assert_matches_type(Q2aListResponse, q2a, path=["response"])
+ assert_matches_type(AsyncPage[Q2aResponse], q2a, path=["response"])
@parametrize
async def test_streaming_response_list(self, async_client: AsyncAsktable) -> None:
@@ -178,6 +178,6 @@ async def test_streaming_response_list(self, async_client: AsyncAsktable) -> Non
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
q2a = await response.parse()
- assert_matches_type(Q2aListResponse, q2a, path=["response"])
+ assert_matches_type(AsyncPage[Q2aResponse], q2a, path=["response"])
assert cast(Any, response.is_closed) is True
diff --git a/tests/api_resources/single_turn/test_q2s.py b/tests/api_resources/single_turn/test_q2s.py
index 5f8b35db..0c792b2a 100644
--- a/tests/api_resources/single_turn/test_q2s.py
+++ b/tests/api_resources/single_turn/test_q2s.py
@@ -9,7 +9,8 @@
from asktable import Asktable, AsyncAsktable
from tests.utils import assert_matches_type
-from asktable.types.single_turn import Q2sResponse, Q2ListResponse
+from asktable.pagination import SyncPage, AsyncPage
+from asktable.types.single_turn import Q2sResponse
base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
@@ -64,7 +65,7 @@ def test_streaming_response_create(self, client: Asktable) -> None:
@parametrize
def test_method_list(self, client: Asktable) -> None:
q2 = client.single_turn.q2s.list()
- assert_matches_type(Q2ListResponse, q2, path=["response"])
+ assert_matches_type(SyncPage[Q2sResponse], q2, path=["response"])
@parametrize
def test_method_list_with_all_params(self, client: Asktable) -> None:
@@ -73,7 +74,7 @@ def test_method_list_with_all_params(self, client: Asktable) -> None:
page=1,
size=1,
)
- assert_matches_type(Q2ListResponse, q2, path=["response"])
+ assert_matches_type(SyncPage[Q2sResponse], q2, path=["response"])
@parametrize
def test_raw_response_list(self, client: Asktable) -> None:
@@ -82,7 +83,7 @@ def test_raw_response_list(self, client: Asktable) -> None:
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
q2 = response.parse()
- assert_matches_type(Q2ListResponse, q2, path=["response"])
+ assert_matches_type(SyncPage[Q2sResponse], q2, path=["response"])
@parametrize
def test_streaming_response_list(self, client: Asktable) -> None:
@@ -91,7 +92,7 @@ def test_streaming_response_list(self, client: Asktable) -> None:
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
q2 = response.parse()
- assert_matches_type(Q2ListResponse, q2, path=["response"])
+ assert_matches_type(SyncPage[Q2sResponse], q2, path=["response"])
assert cast(Any, response.is_closed) is True
@@ -146,7 +147,7 @@ async def test_streaming_response_create(self, async_client: AsyncAsktable) -> N
@parametrize
async def test_method_list(self, async_client: AsyncAsktable) -> None:
q2 = await async_client.single_turn.q2s.list()
- assert_matches_type(Q2ListResponse, q2, path=["response"])
+ assert_matches_type(AsyncPage[Q2sResponse], q2, path=["response"])
@parametrize
async def test_method_list_with_all_params(self, async_client: AsyncAsktable) -> None:
@@ -155,7 +156,7 @@ async def test_method_list_with_all_params(self, async_client: AsyncAsktable) ->
page=1,
size=1,
)
- assert_matches_type(Q2ListResponse, q2, path=["response"])
+ assert_matches_type(AsyncPage[Q2sResponse], q2, path=["response"])
@parametrize
async def test_raw_response_list(self, async_client: AsyncAsktable) -> None:
@@ -164,7 +165,7 @@ async def test_raw_response_list(self, async_client: AsyncAsktable) -> None:
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
q2 = await response.parse()
- assert_matches_type(Q2ListResponse, q2, path=["response"])
+ assert_matches_type(AsyncPage[Q2sResponse], q2, path=["response"])
@parametrize
async def test_streaming_response_list(self, async_client: AsyncAsktable) -> None:
@@ -173,6 +174,6 @@ async def test_streaming_response_list(self, async_client: AsyncAsktable) -> Non
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
q2 = await response.parse()
- assert_matches_type(Q2ListResponse, q2, path=["response"])
+ assert_matches_type(AsyncPage[Q2sResponse], q2, path=["response"])
assert cast(Any, response.is_closed) is True
diff --git a/tests/api_resources/single_turn/test_q2w.py b/tests/api_resources/single_turn/test_q2w.py
new file mode 100644
index 00000000..bb01c335
--- /dev/null
+++ b/tests/api_resources/single_turn/test_q2w.py
@@ -0,0 +1,133 @@
+# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+from __future__ import annotations
+
+import os
+from typing import Any, cast
+
+import pytest
+
+from asktable import Asktable, AsyncAsktable
+from tests.utils import assert_matches_type
+
+base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
+
+
+class TestQ2w:
+ parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"])
+
+ @parametrize
+ def test_method_create(self, client: Asktable) -> None:
+ q2w = client.single_turn.q2w.create(
+ body={},
+ )
+ assert_matches_type(object, q2w, path=["response"])
+
+ @parametrize
+ def test_raw_response_create(self, client: Asktable) -> None:
+ response = client.single_turn.q2w.with_raw_response.create(
+ body={},
+ )
+
+ assert response.is_closed is True
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+ q2w = response.parse()
+ assert_matches_type(object, q2w, path=["response"])
+
+ @parametrize
+ def test_streaming_response_create(self, client: Asktable) -> None:
+ with client.single_turn.q2w.with_streaming_response.create(
+ body={},
+ ) as response:
+ assert not response.is_closed
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+
+ q2w = response.parse()
+ assert_matches_type(object, q2w, path=["response"])
+
+ assert cast(Any, response.is_closed) is True
+
+ @parametrize
+ def test_method_list(self, client: Asktable) -> None:
+ q2w = client.single_turn.q2w.list()
+ assert_matches_type(object, q2w, path=["response"])
+
+ @parametrize
+ def test_raw_response_list(self, client: Asktable) -> None:
+ response = client.single_turn.q2w.with_raw_response.list()
+
+ assert response.is_closed is True
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+ q2w = response.parse()
+ assert_matches_type(object, q2w, path=["response"])
+
+ @parametrize
+ def test_streaming_response_list(self, client: Asktable) -> None:
+ with client.single_turn.q2w.with_streaming_response.list() as response:
+ assert not response.is_closed
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+
+ q2w = response.parse()
+ assert_matches_type(object, q2w, path=["response"])
+
+ assert cast(Any, response.is_closed) is True
+
+
+class TestAsyncQ2w:
+ parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"])
+
+ @parametrize
+ async def test_method_create(self, async_client: AsyncAsktable) -> None:
+ q2w = await async_client.single_turn.q2w.create(
+ body={},
+ )
+ assert_matches_type(object, q2w, path=["response"])
+
+ @parametrize
+ async def test_raw_response_create(self, async_client: AsyncAsktable) -> None:
+ response = await async_client.single_turn.q2w.with_raw_response.create(
+ body={},
+ )
+
+ assert response.is_closed is True
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+ q2w = await response.parse()
+ assert_matches_type(object, q2w, path=["response"])
+
+ @parametrize
+ async def test_streaming_response_create(self, async_client: AsyncAsktable) -> None:
+ async with async_client.single_turn.q2w.with_streaming_response.create(
+ body={},
+ ) as response:
+ assert not response.is_closed
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+
+ q2w = await response.parse()
+ assert_matches_type(object, q2w, path=["response"])
+
+ assert cast(Any, response.is_closed) is True
+
+ @parametrize
+ async def test_method_list(self, async_client: AsyncAsktable) -> None:
+ q2w = await async_client.single_turn.q2w.list()
+ assert_matches_type(object, q2w, path=["response"])
+
+ @parametrize
+ async def test_raw_response_list(self, async_client: AsyncAsktable) -> None:
+ response = await async_client.single_turn.q2w.with_raw_response.list()
+
+ assert response.is_closed is True
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+ q2w = await response.parse()
+ assert_matches_type(object, q2w, path=["response"])
+
+ @parametrize
+ async def test_streaming_response_list(self, async_client: AsyncAsktable) -> None:
+ async with async_client.single_turn.q2w.with_streaming_response.list() as response:
+ assert not response.is_closed
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+
+ q2w = await response.parse()
+ assert_matches_type(object, q2w, path=["response"])
+
+ assert cast(Any, response.is_closed) is True
diff --git a/tests/api_resources/sys/projects/test_api_keys.py b/tests/api_resources/sys/projects/test_api_keys.py
index db723a31..cf170f47 100644
--- a/tests/api_resources/sys/projects/test_api_keys.py
+++ b/tests/api_resources/sys/projects/test_api_keys.py
@@ -9,7 +9,10 @@
from asktable import Asktable, AsyncAsktable
from tests.utils import assert_matches_type
-from asktable.types.sys.projects import APIKeyCreate, APIKeyListResponse
+from asktable.types.sys.projects import (
+ APIKeyListResponse,
+ APIKeyCreateResponse,
+)
base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
@@ -23,7 +26,7 @@ def test_method_create(self, client: Asktable) -> None:
project_id="project_id",
ak_role="sys",
)
- assert_matches_type(APIKeyCreate, api_key, path=["response"])
+ assert_matches_type(APIKeyCreateResponse, api_key, path=["response"])
@parametrize
def test_raw_response_create(self, client: Asktable) -> None:
@@ -35,7 +38,7 @@ def test_raw_response_create(self, client: Asktable) -> None:
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
api_key = response.parse()
- assert_matches_type(APIKeyCreate, api_key, path=["response"])
+ assert_matches_type(APIKeyCreateResponse, api_key, path=["response"])
@parametrize
def test_streaming_response_create(self, client: Asktable) -> None:
@@ -47,7 +50,7 @@ def test_streaming_response_create(self, client: Asktable) -> None:
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
api_key = response.parse()
- assert_matches_type(APIKeyCreate, api_key, path=["response"])
+ assert_matches_type(APIKeyCreateResponse, api_key, path=["response"])
assert cast(Any, response.is_closed) is True
@@ -145,6 +148,58 @@ def test_path_params_delete(self, client: Asktable) -> None:
project_id="project_id",
)
+ @parametrize
+ def test_method_create_token(self, client: Asktable) -> None:
+ api_key = client.sys.projects.api_keys.create_token(
+ project_id="project_id",
+ )
+ assert_matches_type(object, api_key, path=["response"])
+
+ @parametrize
+ def test_method_create_token_with_all_params(self, client: Asktable) -> None:
+ api_key = client.sys.projects.api_keys.create_token(
+ project_id="project_id",
+ ak_role="sys",
+ chat_role={
+ "role_id": "1",
+ "role_variables": {"id": "42"},
+ },
+ token_ttl=900,
+ user_profile={"name": "张三"},
+ )
+ assert_matches_type(object, api_key, path=["response"])
+
+ @parametrize
+ def test_raw_response_create_token(self, client: Asktable) -> None:
+ response = client.sys.projects.api_keys.with_raw_response.create_token(
+ project_id="project_id",
+ )
+
+ assert response.is_closed is True
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+ api_key = response.parse()
+ assert_matches_type(object, api_key, path=["response"])
+
+ @parametrize
+ def test_streaming_response_create_token(self, client: Asktable) -> None:
+ with client.sys.projects.api_keys.with_streaming_response.create_token(
+ project_id="project_id",
+ ) as response:
+ assert not response.is_closed
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+
+ api_key = response.parse()
+ assert_matches_type(object, api_key, path=["response"])
+
+ assert cast(Any, response.is_closed) is True
+
+ @parametrize
+ def test_path_params_create_token(self, client: Asktable) -> None:
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `project_id` but received ''"):
+ client.sys.projects.api_keys.with_raw_response.create_token(
+ project_id="",
+ )
+
class TestAsyncAPIKeys:
parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"])
@@ -155,7 +210,7 @@ async def test_method_create(self, async_client: AsyncAsktable) -> None:
project_id="project_id",
ak_role="sys",
)
- assert_matches_type(APIKeyCreate, api_key, path=["response"])
+ assert_matches_type(APIKeyCreateResponse, api_key, path=["response"])
@parametrize
async def test_raw_response_create(self, async_client: AsyncAsktable) -> None:
@@ -167,7 +222,7 @@ async def test_raw_response_create(self, async_client: AsyncAsktable) -> None:
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
api_key = await response.parse()
- assert_matches_type(APIKeyCreate, api_key, path=["response"])
+ assert_matches_type(APIKeyCreateResponse, api_key, path=["response"])
@parametrize
async def test_streaming_response_create(self, async_client: AsyncAsktable) -> None:
@@ -179,7 +234,7 @@ async def test_streaming_response_create(self, async_client: AsyncAsktable) -> N
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
api_key = await response.parse()
- assert_matches_type(APIKeyCreate, api_key, path=["response"])
+ assert_matches_type(APIKeyCreateResponse, api_key, path=["response"])
assert cast(Any, response.is_closed) is True
@@ -276,3 +331,55 @@ async def test_path_params_delete(self, async_client: AsyncAsktable) -> None:
key_id="",
project_id="project_id",
)
+
+ @parametrize
+ async def test_method_create_token(self, async_client: AsyncAsktable) -> None:
+ api_key = await async_client.sys.projects.api_keys.create_token(
+ project_id="project_id",
+ )
+ assert_matches_type(object, api_key, path=["response"])
+
+ @parametrize
+ async def test_method_create_token_with_all_params(self, async_client: AsyncAsktable) -> None:
+ api_key = await async_client.sys.projects.api_keys.create_token(
+ project_id="project_id",
+ ak_role="sys",
+ chat_role={
+ "role_id": "1",
+ "role_variables": {"id": "42"},
+ },
+ token_ttl=900,
+ user_profile={"name": "张三"},
+ )
+ assert_matches_type(object, api_key, path=["response"])
+
+ @parametrize
+ async def test_raw_response_create_token(self, async_client: AsyncAsktable) -> None:
+ response = await async_client.sys.projects.api_keys.with_raw_response.create_token(
+ project_id="project_id",
+ )
+
+ assert response.is_closed is True
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+ api_key = await response.parse()
+ assert_matches_type(object, api_key, path=["response"])
+
+ @parametrize
+ async def test_streaming_response_create_token(self, async_client: AsyncAsktable) -> None:
+ async with async_client.sys.projects.api_keys.with_streaming_response.create_token(
+ project_id="project_id",
+ ) as response:
+ assert not response.is_closed
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+
+ api_key = await response.parse()
+ assert_matches_type(object, api_key, path=["response"])
+
+ assert cast(Any, response.is_closed) is True
+
+ @parametrize
+ async def test_path_params_create_token(self, async_client: AsyncAsktable) -> None:
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `project_id` but received ''"):
+ await async_client.sys.projects.api_keys.with_raw_response.create_token(
+ project_id="",
+ )
diff --git a/tests/api_resources/sys/projects/test_tokens.py b/tests/api_resources/sys/projects/test_tokens.py
deleted file mode 100644
index c8ab52ba..00000000
--- a/tests/api_resources/sys/projects/test_tokens.py
+++ /dev/null
@@ -1,125 +0,0 @@
-# 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 TestTokens:
- parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"])
-
- @parametrize
- def test_method_create(self, client: Asktable) -> None:
- token = client.sys.projects.tokens.create(
- project_id="project_id",
- )
- assert_matches_type(object, token, path=["response"])
-
- @parametrize
- def test_method_create_with_all_params(self, client: Asktable) -> None:
- token = client.sys.projects.tokens.create(
- project_id="project_id",
- ak_role="sys",
- chat_role={
- "role_id": "1",
- "role_variables": {"id": "42"},
- },
- token_ttl=900,
- user_profile={"name": "张三"},
- )
- assert_matches_type(object, token, path=["response"])
-
- @parametrize
- def test_raw_response_create(self, client: Asktable) -> None:
- response = client.sys.projects.tokens.with_raw_response.create(
- project_id="project_id",
- )
-
- assert response.is_closed is True
- assert response.http_request.headers.get("X-Stainless-Lang") == "python"
- token = response.parse()
- assert_matches_type(object, token, path=["response"])
-
- @parametrize
- def test_streaming_response_create(self, client: Asktable) -> None:
- with client.sys.projects.tokens.with_streaming_response.create(
- project_id="project_id",
- ) as response:
- assert not response.is_closed
- assert response.http_request.headers.get("X-Stainless-Lang") == "python"
-
- token = response.parse()
- assert_matches_type(object, token, path=["response"])
-
- assert cast(Any, response.is_closed) is True
-
- @parametrize
- def test_path_params_create(self, client: Asktable) -> None:
- with pytest.raises(ValueError, match=r"Expected a non-empty value for `project_id` but received ''"):
- client.sys.projects.tokens.with_raw_response.create(
- project_id="",
- )
-
-
-class TestAsyncTokens:
- parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"])
-
- @parametrize
- async def test_method_create(self, async_client: AsyncAsktable) -> None:
- token = await async_client.sys.projects.tokens.create(
- project_id="project_id",
- )
- assert_matches_type(object, token, path=["response"])
-
- @parametrize
- async def test_method_create_with_all_params(self, async_client: AsyncAsktable) -> None:
- token = await async_client.sys.projects.tokens.create(
- project_id="project_id",
- ak_role="sys",
- chat_role={
- "role_id": "1",
- "role_variables": {"id": "42"},
- },
- token_ttl=900,
- user_profile={"name": "张三"},
- )
- assert_matches_type(object, token, path=["response"])
-
- @parametrize
- async def test_raw_response_create(self, async_client: AsyncAsktable) -> None:
- response = await async_client.sys.projects.tokens.with_raw_response.create(
- project_id="project_id",
- )
-
- assert response.is_closed is True
- assert response.http_request.headers.get("X-Stainless-Lang") == "python"
- token = await response.parse()
- assert_matches_type(object, token, path=["response"])
-
- @parametrize
- async def test_streaming_response_create(self, async_client: AsyncAsktable) -> None:
- async with async_client.sys.projects.tokens.with_streaming_response.create(
- project_id="project_id",
- ) as response:
- assert not response.is_closed
- assert response.http_request.headers.get("X-Stainless-Lang") == "python"
-
- token = await response.parse()
- assert_matches_type(object, token, path=["response"])
-
- assert cast(Any, response.is_closed) is True
-
- @parametrize
- async def test_path_params_create(self, async_client: AsyncAsktable) -> None:
- with pytest.raises(ValueError, match=r"Expected a non-empty value for `project_id` but received ''"):
- await async_client.sys.projects.tokens.with_raw_response.create(
- project_id="",
- )
diff --git a/tests/api_resources/sys/test_projects.py b/tests/api_resources/sys/test_projects.py
index 0e290395..1808cc05 100644
--- a/tests/api_resources/sys/test_projects.py
+++ b/tests/api_resources/sys/test_projects.py
@@ -9,10 +9,8 @@
from asktable import Asktable, AsyncAsktable
from tests.utils import assert_matches_type
-from asktable.types.sys import (
- Project,
- ProjectListResponse,
-)
+from asktable.types.sys import Project
+from asktable.pagination import SyncPage, AsyncPage
base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
@@ -139,16 +137,16 @@ def test_path_params_update(self, client: Asktable) -> None:
@parametrize
def test_method_list(self, client: Asktable) -> None:
project = client.sys.projects.list()
- assert_matches_type(ProjectListResponse, project, path=["response"])
+ assert_matches_type(SyncPage[Project], project, path=["response"])
@parametrize
def test_method_list_with_all_params(self, client: Asktable) -> None:
project = client.sys.projects.list(
page=1,
- project_ids=["string", "string", "string"],
+ project_ids=["string"],
size=1,
)
- assert_matches_type(ProjectListResponse, project, path=["response"])
+ assert_matches_type(SyncPage[Project], project, path=["response"])
@parametrize
def test_raw_response_list(self, client: Asktable) -> None:
@@ -157,7 +155,7 @@ def test_raw_response_list(self, client: Asktable) -> None:
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
project = response.parse()
- assert_matches_type(ProjectListResponse, project, path=["response"])
+ assert_matches_type(SyncPage[Project], project, path=["response"])
@parametrize
def test_streaming_response_list(self, client: Asktable) -> None:
@@ -166,7 +164,7 @@ def test_streaming_response_list(self, client: Asktable) -> None:
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
project = response.parse()
- assert_matches_type(ProjectListResponse, project, path=["response"])
+ assert_matches_type(SyncPage[Project], project, path=["response"])
assert cast(Any, response.is_closed) is True
@@ -331,16 +329,16 @@ async def test_path_params_update(self, async_client: AsyncAsktable) -> None:
@parametrize
async def test_method_list(self, async_client: AsyncAsktable) -> None:
project = await async_client.sys.projects.list()
- assert_matches_type(ProjectListResponse, project, path=["response"])
+ assert_matches_type(AsyncPage[Project], project, path=["response"])
@parametrize
async def test_method_list_with_all_params(self, async_client: AsyncAsktable) -> None:
project = await async_client.sys.projects.list(
page=1,
- project_ids=["string", "string", "string"],
+ project_ids=["string"],
size=1,
)
- assert_matches_type(ProjectListResponse, project, path=["response"])
+ assert_matches_type(AsyncPage[Project], project, path=["response"])
@parametrize
async def test_raw_response_list(self, async_client: AsyncAsktable) -> None:
@@ -349,7 +347,7 @@ async def test_raw_response_list(self, async_client: AsyncAsktable) -> None:
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
project = await response.parse()
- assert_matches_type(ProjectListResponse, project, path=["response"])
+ assert_matches_type(AsyncPage[Project], project, path=["response"])
@parametrize
async def test_streaming_response_list(self, async_client: AsyncAsktable) -> None:
@@ -358,7 +356,7 @@ async def test_streaming_response_list(self, async_client: AsyncAsktable) -> Non
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
project = await response.parse()
- assert_matches_type(ProjectListResponse, project, path=["response"])
+ assert_matches_type(AsyncPage[Project], project, path=["response"])
assert cast(Any, response.is_closed) is True
diff --git a/tests/api_resources/test_auth.py b/tests/api_resources/test_auth.py
new file mode 100644
index 00000000..280554a4
--- /dev/null
+++ b/tests/api_resources/test_auth.py
@@ -0,0 +1,147 @@
+# 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 TestAuth:
+ parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"])
+
+ @parametrize
+ def test_method_create_token(self, client: Asktable) -> None:
+ auth = client.auth.create_token()
+ assert_matches_type(object, auth, path=["response"])
+
+ @parametrize
+ def test_method_create_token_with_all_params(self, client: Asktable) -> None:
+ auth = client.auth.create_token(
+ ak_role="sys",
+ chat_role={
+ "role_id": "1",
+ "role_variables": {"id": "42"},
+ },
+ token_ttl=900,
+ user_profile={"name": "张三"},
+ )
+ assert_matches_type(object, auth, path=["response"])
+
+ @parametrize
+ def test_raw_response_create_token(self, client: Asktable) -> None:
+ response = client.auth.with_raw_response.create_token()
+
+ 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"])
+
+ @parametrize
+ def test_streaming_response_create_token(self, client: Asktable) -> None:
+ with client.auth.with_streaming_response.create_token() as response:
+ assert not response.is_closed
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+
+ auth = response.parse()
+ assert_matches_type(object, auth, path=["response"])
+
+ assert cast(Any, response.is_closed) is True
+
+ @parametrize
+ def test_method_me(self, client: Asktable) -> None:
+ auth = client.auth.me()
+ assert_matches_type(object, auth, path=["response"])
+
+ @parametrize
+ def test_raw_response_me(self, client: Asktable) -> None:
+ response = client.auth.with_raw_response.me()
+
+ 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"])
+
+ @parametrize
+ def test_streaming_response_me(self, client: Asktable) -> None:
+ with client.auth.with_streaming_response.me() as response:
+ assert not response.is_closed
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+
+ auth = response.parse()
+ assert_matches_type(object, auth, path=["response"])
+
+ assert cast(Any, response.is_closed) is True
+
+
+class TestAsyncAuth:
+ parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"])
+
+ @parametrize
+ async def test_method_create_token(self, async_client: AsyncAsktable) -> None:
+ auth = await async_client.auth.create_token()
+ assert_matches_type(object, auth, path=["response"])
+
+ @parametrize
+ async def test_method_create_token_with_all_params(self, async_client: AsyncAsktable) -> None:
+ auth = await async_client.auth.create_token(
+ ak_role="sys",
+ chat_role={
+ "role_id": "1",
+ "role_variables": {"id": "42"},
+ },
+ token_ttl=900,
+ user_profile={"name": "张三"},
+ )
+ assert_matches_type(object, auth, path=["response"])
+
+ @parametrize
+ async def test_raw_response_create_token(self, async_client: AsyncAsktable) -> None:
+ response = await async_client.auth.with_raw_response.create_token()
+
+ 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"])
+
+ @parametrize
+ async def test_streaming_response_create_token(self, async_client: AsyncAsktable) -> None:
+ async with async_client.auth.with_streaming_response.create_token() as response:
+ assert not response.is_closed
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+
+ auth = await response.parse()
+ assert_matches_type(object, auth, path=["response"])
+
+ assert cast(Any, response.is_closed) is True
+
+ @parametrize
+ async def test_method_me(self, async_client: AsyncAsktable) -> None:
+ auth = await async_client.auth.me()
+ assert_matches_type(object, auth, path=["response"])
+
+ @parametrize
+ async def test_raw_response_me(self, async_client: AsyncAsktable) -> None:
+ response = await async_client.auth.with_raw_response.me()
+
+ 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"])
+
+ @parametrize
+ async def test_streaming_response_me(self, async_client: AsyncAsktable) -> None:
+ async with async_client.auth.with_streaming_response.me() as response:
+ assert not response.is_closed
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+
+ auth = await response.parse()
+ assert_matches_type(object, auth, path=["response"])
+
+ assert cast(Any, response.is_closed) is True
diff --git a/tests/api_resources/test_bots.py b/tests/api_resources/test_bots.py
index 2f288f52..37748566 100644
--- a/tests/api_resources/test_bots.py
+++ b/tests/api_resources/test_bots.py
@@ -9,10 +9,8 @@
from asktable import Asktable, AsyncAsktable
from tests.utils import assert_matches_type
-from asktable.types import (
- ChatBot,
- BotListResponse,
-)
+from asktable.types import Chatbot
+from asktable.pagination import SyncPage, AsyncPage
base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
@@ -26,7 +24,7 @@ def test_method_create(self, client: Asktable) -> None:
datasource_ids=["ds_sJAbnNOUzu3R4DdCCOwe"],
name="name",
)
- assert_matches_type(ChatBot, bot, path=["response"])
+ assert_matches_type(Chatbot, bot, path=["response"])
@parametrize
def test_method_create_with_all_params(self, client: Asktable) -> None:
@@ -35,14 +33,14 @@ def test_method_create_with_all_params(self, client: Asktable) -> None:
name="name",
color_theme="default",
debug=True,
- extapi_ids=["string", "string", "string"],
+ extapi_ids=["string"],
magic_input="magic_input",
max_rows=50,
publish=True,
sample_questions=["你好!今天中午有什么适合我的午餐?"],
welcome_message="欢迎使用AskTable",
)
- assert_matches_type(ChatBot, bot, path=["response"])
+ assert_matches_type(Chatbot, bot, path=["response"])
@parametrize
def test_raw_response_create(self, client: Asktable) -> None:
@@ -54,7 +52,7 @@ def test_raw_response_create(self, client: Asktable) -> None:
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
bot = response.parse()
- assert_matches_type(ChatBot, bot, path=["response"])
+ assert_matches_type(Chatbot, bot, path=["response"])
@parametrize
def test_streaming_response_create(self, client: Asktable) -> None:
@@ -66,7 +64,7 @@ def test_streaming_response_create(self, client: Asktable) -> None:
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
bot = response.parse()
- assert_matches_type(ChatBot, bot, path=["response"])
+ assert_matches_type(Chatbot, bot, path=["response"])
assert cast(Any, response.is_closed) is True
@@ -75,7 +73,7 @@ def test_method_retrieve(self, client: Asktable) -> None:
bot = client.bots.retrieve(
"bot_id",
)
- assert_matches_type(ChatBot, bot, path=["response"])
+ assert_matches_type(Chatbot, bot, path=["response"])
@parametrize
def test_raw_response_retrieve(self, client: Asktable) -> None:
@@ -86,7 +84,7 @@ def test_raw_response_retrieve(self, client: Asktable) -> None:
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
bot = response.parse()
- assert_matches_type(ChatBot, bot, path=["response"])
+ assert_matches_type(Chatbot, bot, path=["response"])
@parametrize
def test_streaming_response_retrieve(self, client: Asktable) -> None:
@@ -97,7 +95,7 @@ def test_streaming_response_retrieve(self, client: Asktable) -> None:
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
bot = response.parse()
- assert_matches_type(ChatBot, bot, path=["response"])
+ assert_matches_type(Chatbot, bot, path=["response"])
assert cast(Any, response.is_closed) is True
@@ -113,7 +111,7 @@ def test_method_update(self, client: Asktable) -> None:
bot = client.bots.update(
bot_id="bot_id",
)
- assert_matches_type(ChatBot, bot, path=["response"])
+ assert_matches_type(Chatbot, bot, path=["response"])
@parametrize
def test_method_update_with_all_params(self, client: Asktable) -> None:
@@ -123,7 +121,7 @@ def test_method_update_with_all_params(self, client: Asktable) -> None:
color_theme="default",
datasource_ids=["ds_sJAbnNOUzu3R4DdCCOwe"],
debug=True,
- extapi_ids=["string", "string", "string"],
+ extapi_ids=["string"],
magic_input="magic_input",
max_rows=50,
name="name",
@@ -131,7 +129,7 @@ def test_method_update_with_all_params(self, client: Asktable) -> None:
sample_questions=["你好!今天中午有什么适合我的午餐?"],
welcome_message="欢迎使用AskTable",
)
- assert_matches_type(ChatBot, bot, path=["response"])
+ assert_matches_type(Chatbot, bot, path=["response"])
@parametrize
def test_raw_response_update(self, client: Asktable) -> None:
@@ -142,7 +140,7 @@ def test_raw_response_update(self, client: Asktable) -> None:
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
bot = response.parse()
- assert_matches_type(ChatBot, bot, path=["response"])
+ assert_matches_type(Chatbot, bot, path=["response"])
@parametrize
def test_streaming_response_update(self, client: Asktable) -> None:
@@ -153,7 +151,7 @@ def test_streaming_response_update(self, client: Asktable) -> None:
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
bot = response.parse()
- assert_matches_type(ChatBot, bot, path=["response"])
+ assert_matches_type(Chatbot, bot, path=["response"])
assert cast(Any, response.is_closed) is True
@@ -167,7 +165,7 @@ def test_path_params_update(self, client: Asktable) -> None:
@parametrize
def test_method_list(self, client: Asktable) -> None:
bot = client.bots.list()
- assert_matches_type(BotListResponse, bot, path=["response"])
+ assert_matches_type(SyncPage[Chatbot], bot, path=["response"])
@parametrize
def test_method_list_with_all_params(self, client: Asktable) -> None:
@@ -176,7 +174,7 @@ def test_method_list_with_all_params(self, client: Asktable) -> None:
page=1,
size=1,
)
- assert_matches_type(BotListResponse, bot, path=["response"])
+ assert_matches_type(SyncPage[Chatbot], bot, path=["response"])
@parametrize
def test_raw_response_list(self, client: Asktable) -> None:
@@ -185,7 +183,7 @@ def test_raw_response_list(self, client: Asktable) -> None:
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
bot = response.parse()
- assert_matches_type(BotListResponse, bot, path=["response"])
+ assert_matches_type(SyncPage[Chatbot], bot, path=["response"])
@parametrize
def test_streaming_response_list(self, client: Asktable) -> None:
@@ -194,7 +192,7 @@ def test_streaming_response_list(self, client: Asktable) -> None:
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
bot = response.parse()
- assert_matches_type(BotListResponse, bot, path=["response"])
+ assert_matches_type(SyncPage[Chatbot], bot, path=["response"])
assert cast(Any, response.is_closed) is True
@@ -288,7 +286,7 @@ async def test_method_create(self, async_client: AsyncAsktable) -> None:
datasource_ids=["ds_sJAbnNOUzu3R4DdCCOwe"],
name="name",
)
- assert_matches_type(ChatBot, bot, path=["response"])
+ assert_matches_type(Chatbot, bot, path=["response"])
@parametrize
async def test_method_create_with_all_params(self, async_client: AsyncAsktable) -> None:
@@ -297,14 +295,14 @@ async def test_method_create_with_all_params(self, async_client: AsyncAsktable)
name="name",
color_theme="default",
debug=True,
- extapi_ids=["string", "string", "string"],
+ extapi_ids=["string"],
magic_input="magic_input",
max_rows=50,
publish=True,
sample_questions=["你好!今天中午有什么适合我的午餐?"],
welcome_message="欢迎使用AskTable",
)
- assert_matches_type(ChatBot, bot, path=["response"])
+ assert_matches_type(Chatbot, bot, path=["response"])
@parametrize
async def test_raw_response_create(self, async_client: AsyncAsktable) -> None:
@@ -316,7 +314,7 @@ async def test_raw_response_create(self, async_client: AsyncAsktable) -> None:
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
bot = await response.parse()
- assert_matches_type(ChatBot, bot, path=["response"])
+ assert_matches_type(Chatbot, bot, path=["response"])
@parametrize
async def test_streaming_response_create(self, async_client: AsyncAsktable) -> None:
@@ -328,7 +326,7 @@ async def test_streaming_response_create(self, async_client: AsyncAsktable) -> N
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
bot = await response.parse()
- assert_matches_type(ChatBot, bot, path=["response"])
+ assert_matches_type(Chatbot, bot, path=["response"])
assert cast(Any, response.is_closed) is True
@@ -337,7 +335,7 @@ async def test_method_retrieve(self, async_client: AsyncAsktable) -> None:
bot = await async_client.bots.retrieve(
"bot_id",
)
- assert_matches_type(ChatBot, bot, path=["response"])
+ assert_matches_type(Chatbot, bot, path=["response"])
@parametrize
async def test_raw_response_retrieve(self, async_client: AsyncAsktable) -> None:
@@ -348,7 +346,7 @@ async def test_raw_response_retrieve(self, async_client: AsyncAsktable) -> None:
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
bot = await response.parse()
- assert_matches_type(ChatBot, bot, path=["response"])
+ assert_matches_type(Chatbot, bot, path=["response"])
@parametrize
async def test_streaming_response_retrieve(self, async_client: AsyncAsktable) -> None:
@@ -359,7 +357,7 @@ async def test_streaming_response_retrieve(self, async_client: AsyncAsktable) ->
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
bot = await response.parse()
- assert_matches_type(ChatBot, bot, path=["response"])
+ assert_matches_type(Chatbot, bot, path=["response"])
assert cast(Any, response.is_closed) is True
@@ -375,7 +373,7 @@ async def test_method_update(self, async_client: AsyncAsktable) -> None:
bot = await async_client.bots.update(
bot_id="bot_id",
)
- assert_matches_type(ChatBot, bot, path=["response"])
+ assert_matches_type(Chatbot, bot, path=["response"])
@parametrize
async def test_method_update_with_all_params(self, async_client: AsyncAsktable) -> None:
@@ -385,7 +383,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncAsktable)
color_theme="default",
datasource_ids=["ds_sJAbnNOUzu3R4DdCCOwe"],
debug=True,
- extapi_ids=["string", "string", "string"],
+ extapi_ids=["string"],
magic_input="magic_input",
max_rows=50,
name="name",
@@ -393,7 +391,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncAsktable)
sample_questions=["你好!今天中午有什么适合我的午餐?"],
welcome_message="欢迎使用AskTable",
)
- assert_matches_type(ChatBot, bot, path=["response"])
+ assert_matches_type(Chatbot, bot, path=["response"])
@parametrize
async def test_raw_response_update(self, async_client: AsyncAsktable) -> None:
@@ -404,7 +402,7 @@ async def test_raw_response_update(self, async_client: AsyncAsktable) -> None:
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
bot = await response.parse()
- assert_matches_type(ChatBot, bot, path=["response"])
+ assert_matches_type(Chatbot, bot, path=["response"])
@parametrize
async def test_streaming_response_update(self, async_client: AsyncAsktable) -> None:
@@ -415,7 +413,7 @@ async def test_streaming_response_update(self, async_client: AsyncAsktable) -> N
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
bot = await response.parse()
- assert_matches_type(ChatBot, bot, path=["response"])
+ assert_matches_type(Chatbot, bot, path=["response"])
assert cast(Any, response.is_closed) is True
@@ -429,7 +427,7 @@ async def test_path_params_update(self, async_client: AsyncAsktable) -> None:
@parametrize
async def test_method_list(self, async_client: AsyncAsktable) -> None:
bot = await async_client.bots.list()
- assert_matches_type(BotListResponse, bot, path=["response"])
+ assert_matches_type(AsyncPage[Chatbot], bot, path=["response"])
@parametrize
async def test_method_list_with_all_params(self, async_client: AsyncAsktable) -> None:
@@ -438,7 +436,7 @@ async def test_method_list_with_all_params(self, async_client: AsyncAsktable) ->
page=1,
size=1,
)
- assert_matches_type(BotListResponse, bot, path=["response"])
+ assert_matches_type(AsyncPage[Chatbot], bot, path=["response"])
@parametrize
async def test_raw_response_list(self, async_client: AsyncAsktable) -> None:
@@ -447,7 +445,7 @@ async def test_raw_response_list(self, async_client: AsyncAsktable) -> None:
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
bot = await response.parse()
- assert_matches_type(BotListResponse, bot, path=["response"])
+ assert_matches_type(AsyncPage[Chatbot], bot, path=["response"])
@parametrize
async def test_streaming_response_list(self, async_client: AsyncAsktable) -> None:
@@ -456,7 +454,7 @@ async def test_streaming_response_list(self, async_client: AsyncAsktable) -> Non
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
bot = await response.parse()
- assert_matches_type(BotListResponse, bot, path=["response"])
+ assert_matches_type(AsyncPage[Chatbot], bot, path=["response"])
assert cast(Any, response.is_closed) is True
diff --git a/tests/api_resources/test_business_glossary.py b/tests/api_resources/test_business_glossary.py
new file mode 100644
index 00000000..3dfa78c5
--- /dev/null
+++ b/tests/api_resources/test_business_glossary.py
@@ -0,0 +1,437 @@
+# 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 (
+ Entry,
+ EntryWithDefinition,
+ BusinessGlossaryCreateResponse,
+)
+from asktable.pagination import SyncPage, AsyncPage
+
+base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
+
+
+class TestBusinessGlossary:
+ parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"])
+
+ @parametrize
+ def test_method_create(self, client: Asktable) -> None:
+ business_glossary = client.business_glossary.create(
+ body=[
+ {
+ "definition": "definition",
+ "term": "term",
+ }
+ ],
+ )
+ assert_matches_type(BusinessGlossaryCreateResponse, business_glossary, path=["response"])
+
+ @parametrize
+ def test_raw_response_create(self, client: Asktable) -> None:
+ response = client.business_glossary.with_raw_response.create(
+ body=[
+ {
+ "definition": "definition",
+ "term": "term",
+ }
+ ],
+ )
+
+ assert response.is_closed is True
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+ business_glossary = response.parse()
+ assert_matches_type(BusinessGlossaryCreateResponse, business_glossary, path=["response"])
+
+ @parametrize
+ def test_streaming_response_create(self, client: Asktable) -> None:
+ with client.business_glossary.with_streaming_response.create(
+ body=[
+ {
+ "definition": "definition",
+ "term": "term",
+ }
+ ],
+ ) as response:
+ assert not response.is_closed
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+
+ business_glossary = response.parse()
+ assert_matches_type(BusinessGlossaryCreateResponse, business_glossary, path=["response"])
+
+ assert cast(Any, response.is_closed) is True
+
+ @parametrize
+ def test_method_retrieve(self, client: Asktable) -> None:
+ business_glossary = client.business_glossary.retrieve(
+ "entry_id",
+ )
+ assert_matches_type(EntryWithDefinition, business_glossary, path=["response"])
+
+ @parametrize
+ def test_raw_response_retrieve(self, client: Asktable) -> None:
+ response = client.business_glossary.with_raw_response.retrieve(
+ "entry_id",
+ )
+
+ assert response.is_closed is True
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+ business_glossary = response.parse()
+ assert_matches_type(EntryWithDefinition, business_glossary, path=["response"])
+
+ @parametrize
+ def test_streaming_response_retrieve(self, client: Asktable) -> None:
+ with client.business_glossary.with_streaming_response.retrieve(
+ "entry_id",
+ ) as response:
+ assert not response.is_closed
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+
+ business_glossary = response.parse()
+ assert_matches_type(EntryWithDefinition, business_glossary, 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 `entry_id` but received ''"):
+ client.business_glossary.with_raw_response.retrieve(
+ "",
+ )
+
+ @parametrize
+ def test_method_update(self, client: Asktable) -> None:
+ business_glossary = client.business_glossary.update(
+ entry_id="entry_id",
+ )
+ assert_matches_type(Entry, business_glossary, path=["response"])
+
+ @parametrize
+ def test_method_update_with_all_params(self, client: Asktable) -> None:
+ business_glossary = client.business_glossary.update(
+ entry_id="entry_id",
+ aliases=["string"],
+ definition="definition",
+ payload={},
+ term="term",
+ )
+ assert_matches_type(Entry, business_glossary, path=["response"])
+
+ @parametrize
+ def test_raw_response_update(self, client: Asktable) -> None:
+ response = client.business_glossary.with_raw_response.update(
+ entry_id="entry_id",
+ )
+
+ assert response.is_closed is True
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+ business_glossary = response.parse()
+ assert_matches_type(Entry, business_glossary, path=["response"])
+
+ @parametrize
+ def test_streaming_response_update(self, client: Asktable) -> None:
+ with client.business_glossary.with_streaming_response.update(
+ entry_id="entry_id",
+ ) as response:
+ assert not response.is_closed
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+
+ business_glossary = response.parse()
+ assert_matches_type(Entry, business_glossary, path=["response"])
+
+ assert cast(Any, response.is_closed) is True
+
+ @parametrize
+ def test_path_params_update(self, client: Asktable) -> None:
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `entry_id` but received ''"):
+ client.business_glossary.with_raw_response.update(
+ entry_id="",
+ )
+
+ @parametrize
+ def test_method_list(self, client: Asktable) -> None:
+ business_glossary = client.business_glossary.list()
+ assert_matches_type(SyncPage[Entry], business_glossary, path=["response"])
+
+ @parametrize
+ def test_method_list_with_all_params(self, client: Asktable) -> None:
+ business_glossary = client.business_glossary.list(
+ page=1,
+ size=1,
+ term="term",
+ )
+ assert_matches_type(SyncPage[Entry], business_glossary, path=["response"])
+
+ @parametrize
+ def test_raw_response_list(self, client: Asktable) -> None:
+ response = client.business_glossary.with_raw_response.list()
+
+ assert response.is_closed is True
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+ business_glossary = response.parse()
+ assert_matches_type(SyncPage[Entry], business_glossary, path=["response"])
+
+ @parametrize
+ def test_streaming_response_list(self, client: Asktable) -> None:
+ with client.business_glossary.with_streaming_response.list() as response:
+ assert not response.is_closed
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+
+ business_glossary = response.parse()
+ assert_matches_type(SyncPage[Entry], business_glossary, path=["response"])
+
+ assert cast(Any, response.is_closed) is True
+
+ @parametrize
+ def test_method_delete(self, client: Asktable) -> None:
+ business_glossary = client.business_glossary.delete(
+ "entry_id",
+ )
+ assert_matches_type(object, business_glossary, path=["response"])
+
+ @parametrize
+ def test_raw_response_delete(self, client: Asktable) -> None:
+ response = client.business_glossary.with_raw_response.delete(
+ "entry_id",
+ )
+
+ assert response.is_closed is True
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+ business_glossary = response.parse()
+ assert_matches_type(object, business_glossary, path=["response"])
+
+ @parametrize
+ def test_streaming_response_delete(self, client: Asktable) -> None:
+ with client.business_glossary.with_streaming_response.delete(
+ "entry_id",
+ ) as response:
+ assert not response.is_closed
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+
+ business_glossary = response.parse()
+ assert_matches_type(object, business_glossary, path=["response"])
+
+ assert cast(Any, response.is_closed) is True
+
+ @parametrize
+ def test_path_params_delete(self, client: Asktable) -> None:
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `entry_id` but received ''"):
+ client.business_glossary.with_raw_response.delete(
+ "",
+ )
+
+
+class TestAsyncBusinessGlossary:
+ parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"])
+
+ @parametrize
+ async def test_method_create(self, async_client: AsyncAsktable) -> None:
+ business_glossary = await async_client.business_glossary.create(
+ body=[
+ {
+ "definition": "definition",
+ "term": "term",
+ }
+ ],
+ )
+ assert_matches_type(BusinessGlossaryCreateResponse, business_glossary, path=["response"])
+
+ @parametrize
+ async def test_raw_response_create(self, async_client: AsyncAsktable) -> None:
+ response = await async_client.business_glossary.with_raw_response.create(
+ body=[
+ {
+ "definition": "definition",
+ "term": "term",
+ }
+ ],
+ )
+
+ assert response.is_closed is True
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+ business_glossary = await response.parse()
+ assert_matches_type(BusinessGlossaryCreateResponse, business_glossary, path=["response"])
+
+ @parametrize
+ async def test_streaming_response_create(self, async_client: AsyncAsktable) -> None:
+ async with async_client.business_glossary.with_streaming_response.create(
+ body=[
+ {
+ "definition": "definition",
+ "term": "term",
+ }
+ ],
+ ) as response:
+ assert not response.is_closed
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+
+ business_glossary = await response.parse()
+ assert_matches_type(BusinessGlossaryCreateResponse, business_glossary, path=["response"])
+
+ assert cast(Any, response.is_closed) is True
+
+ @parametrize
+ async def test_method_retrieve(self, async_client: AsyncAsktable) -> None:
+ business_glossary = await async_client.business_glossary.retrieve(
+ "entry_id",
+ )
+ assert_matches_type(EntryWithDefinition, business_glossary, path=["response"])
+
+ @parametrize
+ async def test_raw_response_retrieve(self, async_client: AsyncAsktable) -> None:
+ response = await async_client.business_glossary.with_raw_response.retrieve(
+ "entry_id",
+ )
+
+ assert response.is_closed is True
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+ business_glossary = await response.parse()
+ assert_matches_type(EntryWithDefinition, business_glossary, path=["response"])
+
+ @parametrize
+ async def test_streaming_response_retrieve(self, async_client: AsyncAsktable) -> None:
+ async with async_client.business_glossary.with_streaming_response.retrieve(
+ "entry_id",
+ ) as response:
+ assert not response.is_closed
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+
+ business_glossary = await response.parse()
+ assert_matches_type(EntryWithDefinition, business_glossary, 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 `entry_id` but received ''"):
+ await async_client.business_glossary.with_raw_response.retrieve(
+ "",
+ )
+
+ @parametrize
+ async def test_method_update(self, async_client: AsyncAsktable) -> None:
+ business_glossary = await async_client.business_glossary.update(
+ entry_id="entry_id",
+ )
+ assert_matches_type(Entry, business_glossary, path=["response"])
+
+ @parametrize
+ async def test_method_update_with_all_params(self, async_client: AsyncAsktable) -> None:
+ business_glossary = await async_client.business_glossary.update(
+ entry_id="entry_id",
+ aliases=["string"],
+ definition="definition",
+ payload={},
+ term="term",
+ )
+ assert_matches_type(Entry, business_glossary, path=["response"])
+
+ @parametrize
+ async def test_raw_response_update(self, async_client: AsyncAsktable) -> None:
+ response = await async_client.business_glossary.with_raw_response.update(
+ entry_id="entry_id",
+ )
+
+ assert response.is_closed is True
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+ business_glossary = await response.parse()
+ assert_matches_type(Entry, business_glossary, path=["response"])
+
+ @parametrize
+ async def test_streaming_response_update(self, async_client: AsyncAsktable) -> None:
+ async with async_client.business_glossary.with_streaming_response.update(
+ entry_id="entry_id",
+ ) as response:
+ assert not response.is_closed
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+
+ business_glossary = await response.parse()
+ assert_matches_type(Entry, business_glossary, path=["response"])
+
+ assert cast(Any, response.is_closed) is True
+
+ @parametrize
+ async def test_path_params_update(self, async_client: AsyncAsktable) -> None:
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `entry_id` but received ''"):
+ await async_client.business_glossary.with_raw_response.update(
+ entry_id="",
+ )
+
+ @parametrize
+ async def test_method_list(self, async_client: AsyncAsktable) -> None:
+ business_glossary = await async_client.business_glossary.list()
+ assert_matches_type(AsyncPage[Entry], business_glossary, path=["response"])
+
+ @parametrize
+ async def test_method_list_with_all_params(self, async_client: AsyncAsktable) -> None:
+ business_glossary = await async_client.business_glossary.list(
+ page=1,
+ size=1,
+ term="term",
+ )
+ assert_matches_type(AsyncPage[Entry], business_glossary, path=["response"])
+
+ @parametrize
+ async def test_raw_response_list(self, async_client: AsyncAsktable) -> None:
+ response = await async_client.business_glossary.with_raw_response.list()
+
+ assert response.is_closed is True
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+ business_glossary = await response.parse()
+ assert_matches_type(AsyncPage[Entry], business_glossary, path=["response"])
+
+ @parametrize
+ async def test_streaming_response_list(self, async_client: AsyncAsktable) -> None:
+ async with async_client.business_glossary.with_streaming_response.list() as response:
+ assert not response.is_closed
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+
+ business_glossary = await response.parse()
+ assert_matches_type(AsyncPage[Entry], business_glossary, path=["response"])
+
+ assert cast(Any, response.is_closed) is True
+
+ @parametrize
+ async def test_method_delete(self, async_client: AsyncAsktable) -> None:
+ business_glossary = await async_client.business_glossary.delete(
+ "entry_id",
+ )
+ assert_matches_type(object, business_glossary, path=["response"])
+
+ @parametrize
+ async def test_raw_response_delete(self, async_client: AsyncAsktable) -> None:
+ response = await async_client.business_glossary.with_raw_response.delete(
+ "entry_id",
+ )
+
+ assert response.is_closed is True
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+ business_glossary = await response.parse()
+ assert_matches_type(object, business_glossary, path=["response"])
+
+ @parametrize
+ async def test_streaming_response_delete(self, async_client: AsyncAsktable) -> None:
+ async with async_client.business_glossary.with_streaming_response.delete(
+ "entry_id",
+ ) as response:
+ assert not response.is_closed
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+
+ business_glossary = await response.parse()
+ assert_matches_type(object, business_glossary, path=["response"])
+
+ assert cast(Any, response.is_closed) is True
+
+ @parametrize
+ async def test_path_params_delete(self, async_client: AsyncAsktable) -> None:
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `entry_id` but received ''"):
+ await async_client.business_glossary.with_raw_response.delete(
+ "",
+ )
diff --git a/tests/api_resources/test_chats.py b/tests/api_resources/test_chats.py
index 37d462cd..bc1c3086 100644
--- a/tests/api_resources/test_chats.py
+++ b/tests/api_resources/test_chats.py
@@ -9,11 +9,8 @@
from asktable import Asktable, AsyncAsktable
from tests.utils import assert_matches_type
-from asktable.types import (
- ChatListResponse,
- ChatCreateResponse,
- ChatRetrieveResponse,
-)
+from asktable.types import Chat, Message
+from asktable.pagination import SyncPage, AsyncPage
base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
@@ -24,7 +21,7 @@ class TestChats:
@parametrize
def test_method_create(self, client: Asktable) -> None:
chat = client.chats.create()
- assert_matches_type(ChatCreateResponse, chat, path=["response"])
+ assert_matches_type(Chat, chat, path=["response"])
@parametrize
def test_method_create_with_all_params(self, client: Asktable) -> None:
@@ -39,7 +36,7 @@ def test_method_create_with_all_params(self, client: Asktable) -> None:
"name": "张三",
},
)
- assert_matches_type(ChatCreateResponse, chat, path=["response"])
+ assert_matches_type(Chat, chat, path=["response"])
@parametrize
def test_raw_response_create(self, client: Asktable) -> None:
@@ -48,7 +45,7 @@ def test_raw_response_create(self, client: Asktable) -> None:
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
chat = response.parse()
- assert_matches_type(ChatCreateResponse, chat, path=["response"])
+ assert_matches_type(Chat, chat, path=["response"])
@parametrize
def test_streaming_response_create(self, client: Asktable) -> None:
@@ -57,7 +54,7 @@ def test_streaming_response_create(self, client: Asktable) -> None:
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
chat = response.parse()
- assert_matches_type(ChatCreateResponse, chat, path=["response"])
+ assert_matches_type(Chat, chat, path=["response"])
assert cast(Any, response.is_closed) is True
@@ -66,7 +63,7 @@ def test_method_retrieve(self, client: Asktable) -> None:
chat = client.chats.retrieve(
"chat_id",
)
- assert_matches_type(ChatRetrieveResponse, chat, path=["response"])
+ assert_matches_type(Chat, chat, path=["response"])
@parametrize
def test_raw_response_retrieve(self, client: Asktable) -> None:
@@ -77,7 +74,7 @@ def test_raw_response_retrieve(self, client: Asktable) -> None:
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
chat = response.parse()
- assert_matches_type(ChatRetrieveResponse, chat, path=["response"])
+ assert_matches_type(Chat, chat, path=["response"])
@parametrize
def test_streaming_response_retrieve(self, client: Asktable) -> None:
@@ -88,7 +85,7 @@ def test_streaming_response_retrieve(self, client: Asktable) -> None:
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
chat = response.parse()
- assert_matches_type(ChatRetrieveResponse, chat, path=["response"])
+ assert_matches_type(Chat, chat, path=["response"])
assert cast(Any, response.is_closed) is True
@@ -102,7 +99,7 @@ def test_path_params_retrieve(self, client: Asktable) -> None:
@parametrize
def test_method_list(self, client: Asktable) -> None:
chat = client.chats.list()
- assert_matches_type(ChatListResponse, chat, path=["response"])
+ assert_matches_type(SyncPage[Chat], chat, path=["response"])
@parametrize
def test_method_list_with_all_params(self, client: Asktable) -> None:
@@ -110,7 +107,7 @@ def test_method_list_with_all_params(self, client: Asktable) -> None:
page=1,
size=1,
)
- assert_matches_type(ChatListResponse, chat, path=["response"])
+ assert_matches_type(SyncPage[Chat], chat, path=["response"])
@parametrize
def test_raw_response_list(self, client: Asktable) -> None:
@@ -119,7 +116,7 @@ def test_raw_response_list(self, client: Asktable) -> None:
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
chat = response.parse()
- assert_matches_type(ChatListResponse, chat, path=["response"])
+ assert_matches_type(SyncPage[Chat], chat, path=["response"])
@parametrize
def test_streaming_response_list(self, client: Asktable) -> None:
@@ -128,7 +125,7 @@ def test_streaming_response_list(self, client: Asktable) -> None:
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
chat = response.parse()
- assert_matches_type(ChatListResponse, chat, path=["response"])
+ assert_matches_type(SyncPage[Chat], chat, path=["response"])
assert cast(Any, response.is_closed) is True
@@ -170,6 +167,48 @@ def test_path_params_delete(self, client: Asktable) -> None:
"",
)
+ @parametrize
+ def test_method_send_message(self, client: Asktable) -> None:
+ chat = client.chats.send_message(
+ chat_id="chat_id",
+ question="question",
+ )
+ assert_matches_type(Message, chat, path=["response"])
+
+ @parametrize
+ def test_raw_response_send_message(self, client: Asktable) -> None:
+ response = client.chats.with_raw_response.send_message(
+ chat_id="chat_id",
+ question="question",
+ )
+
+ assert response.is_closed is True
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+ chat = response.parse()
+ assert_matches_type(Message, chat, path=["response"])
+
+ @parametrize
+ def test_streaming_response_send_message(self, client: Asktable) -> None:
+ with client.chats.with_streaming_response.send_message(
+ chat_id="chat_id",
+ question="question",
+ ) as response:
+ assert not response.is_closed
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+
+ chat = response.parse()
+ assert_matches_type(Message, chat, path=["response"])
+
+ assert cast(Any, response.is_closed) is True
+
+ @parametrize
+ def test_path_params_send_message(self, client: Asktable) -> None:
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `chat_id` but received ''"):
+ client.chats.with_raw_response.send_message(
+ chat_id="",
+ question="question",
+ )
+
class TestAsyncChats:
parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"])
@@ -177,7 +216,7 @@ class TestAsyncChats:
@parametrize
async def test_method_create(self, async_client: AsyncAsktable) -> None:
chat = await async_client.chats.create()
- assert_matches_type(ChatCreateResponse, chat, path=["response"])
+ assert_matches_type(Chat, chat, path=["response"])
@parametrize
async def test_method_create_with_all_params(self, async_client: AsyncAsktable) -> None:
@@ -192,7 +231,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncAsktable)
"name": "张三",
},
)
- assert_matches_type(ChatCreateResponse, chat, path=["response"])
+ assert_matches_type(Chat, chat, path=["response"])
@parametrize
async def test_raw_response_create(self, async_client: AsyncAsktable) -> None:
@@ -201,7 +240,7 @@ async def test_raw_response_create(self, async_client: AsyncAsktable) -> None:
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
chat = await response.parse()
- assert_matches_type(ChatCreateResponse, chat, path=["response"])
+ assert_matches_type(Chat, chat, path=["response"])
@parametrize
async def test_streaming_response_create(self, async_client: AsyncAsktable) -> None:
@@ -210,7 +249,7 @@ async def test_streaming_response_create(self, async_client: AsyncAsktable) -> N
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
chat = await response.parse()
- assert_matches_type(ChatCreateResponse, chat, path=["response"])
+ assert_matches_type(Chat, chat, path=["response"])
assert cast(Any, response.is_closed) is True
@@ -219,7 +258,7 @@ async def test_method_retrieve(self, async_client: AsyncAsktable) -> None:
chat = await async_client.chats.retrieve(
"chat_id",
)
- assert_matches_type(ChatRetrieveResponse, chat, path=["response"])
+ assert_matches_type(Chat, chat, path=["response"])
@parametrize
async def test_raw_response_retrieve(self, async_client: AsyncAsktable) -> None:
@@ -230,7 +269,7 @@ async def test_raw_response_retrieve(self, async_client: AsyncAsktable) -> None:
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
chat = await response.parse()
- assert_matches_type(ChatRetrieveResponse, chat, path=["response"])
+ assert_matches_type(Chat, chat, path=["response"])
@parametrize
async def test_streaming_response_retrieve(self, async_client: AsyncAsktable) -> None:
@@ -241,7 +280,7 @@ async def test_streaming_response_retrieve(self, async_client: AsyncAsktable) ->
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
chat = await response.parse()
- assert_matches_type(ChatRetrieveResponse, chat, path=["response"])
+ assert_matches_type(Chat, chat, path=["response"])
assert cast(Any, response.is_closed) is True
@@ -255,7 +294,7 @@ async def test_path_params_retrieve(self, async_client: AsyncAsktable) -> None:
@parametrize
async def test_method_list(self, async_client: AsyncAsktable) -> None:
chat = await async_client.chats.list()
- assert_matches_type(ChatListResponse, chat, path=["response"])
+ assert_matches_type(AsyncPage[Chat], chat, path=["response"])
@parametrize
async def test_method_list_with_all_params(self, async_client: AsyncAsktable) -> None:
@@ -263,7 +302,7 @@ async def test_method_list_with_all_params(self, async_client: AsyncAsktable) ->
page=1,
size=1,
)
- assert_matches_type(ChatListResponse, chat, path=["response"])
+ assert_matches_type(AsyncPage[Chat], chat, path=["response"])
@parametrize
async def test_raw_response_list(self, async_client: AsyncAsktable) -> None:
@@ -272,7 +311,7 @@ async def test_raw_response_list(self, async_client: AsyncAsktable) -> None:
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
chat = await response.parse()
- assert_matches_type(ChatListResponse, chat, path=["response"])
+ assert_matches_type(AsyncPage[Chat], chat, path=["response"])
@parametrize
async def test_streaming_response_list(self, async_client: AsyncAsktable) -> None:
@@ -281,7 +320,7 @@ async def test_streaming_response_list(self, async_client: AsyncAsktable) -> Non
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
chat = await response.parse()
- assert_matches_type(ChatListResponse, chat, path=["response"])
+ assert_matches_type(AsyncPage[Chat], chat, path=["response"])
assert cast(Any, response.is_closed) is True
@@ -322,3 +361,45 @@ async def test_path_params_delete(self, async_client: AsyncAsktable) -> None:
await async_client.chats.with_raw_response.delete(
"",
)
+
+ @parametrize
+ async def test_method_send_message(self, async_client: AsyncAsktable) -> None:
+ chat = await async_client.chats.send_message(
+ chat_id="chat_id",
+ question="question",
+ )
+ assert_matches_type(Message, chat, path=["response"])
+
+ @parametrize
+ async def test_raw_response_send_message(self, async_client: AsyncAsktable) -> None:
+ response = await async_client.chats.with_raw_response.send_message(
+ chat_id="chat_id",
+ question="question",
+ )
+
+ assert response.is_closed is True
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+ chat = await response.parse()
+ assert_matches_type(Message, chat, path=["response"])
+
+ @parametrize
+ async def test_streaming_response_send_message(self, async_client: AsyncAsktable) -> None:
+ async with async_client.chats.with_streaming_response.send_message(
+ chat_id="chat_id",
+ question="question",
+ ) as response:
+ assert not response.is_closed
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+
+ chat = await response.parse()
+ assert_matches_type(Message, chat, path=["response"])
+
+ assert cast(Any, response.is_closed) is True
+
+ @parametrize
+ async def test_path_params_send_message(self, async_client: AsyncAsktable) -> None:
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `chat_id` but received ''"):
+ await async_client.chats.with_raw_response.send_message(
+ chat_id="",
+ question="question",
+ )
diff --git a/tests/api_resources/test_datasources.py b/tests/api_resources/test_datasources.py
index 0cffd26b..0cde3d96 100644
--- a/tests/api_resources/test_datasources.py
+++ b/tests/api_resources/test_datasources.py
@@ -10,9 +10,9 @@
from asktable import Asktable, AsyncAsktable
from tests.utils import assert_matches_type
from asktable.types import (
- DataSource,
- DatasourceListResponse,
+ Datasource,
)
+from asktable.pagination import SyncPage, AsyncPage
base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
@@ -25,7 +25,7 @@ def test_method_create(self, client: Asktable) -> None:
datasource = client.datasources.create(
engine="mysql",
)
- assert_matches_type(DataSource, datasource, path=["response"])
+ assert_matches_type(Datasource, datasource, path=["response"])
@parametrize
def test_method_create_with_all_params(self, client: Asktable) -> None:
@@ -33,18 +33,21 @@ def test_method_create_with_all_params(self, client: Asktable) -> None:
engine="mysql",
async_process_meta=True,
access_config={
+ "atst_link_id": "atst_link_123456",
"db": "test",
"host": "192.168.0.10",
"location_type": "local",
"location_url": "http://example.com/data.csv",
"password": "root",
"port": 3306,
+ "proxy_host": "192.168.0.10",
+ "proxy_port": 3306,
"securetunnel_id": "atst_123456",
"user": "root",
},
name="用户库",
)
- assert_matches_type(DataSource, datasource, path=["response"])
+ assert_matches_type(Datasource, datasource, path=["response"])
@parametrize
def test_raw_response_create(self, client: Asktable) -> None:
@@ -55,7 +58,7 @@ def test_raw_response_create(self, client: Asktable) -> None:
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
datasource = response.parse()
- assert_matches_type(DataSource, datasource, path=["response"])
+ assert_matches_type(Datasource, datasource, path=["response"])
@parametrize
def test_streaming_response_create(self, client: Asktable) -> None:
@@ -66,7 +69,7 @@ def test_streaming_response_create(self, client: Asktable) -> None:
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
datasource = response.parse()
- assert_matches_type(DataSource, datasource, path=["response"])
+ assert_matches_type(Datasource, datasource, path=["response"])
assert cast(Any, response.is_closed) is True
@@ -75,7 +78,7 @@ def test_method_retrieve(self, client: Asktable) -> None:
datasource = client.datasources.retrieve(
"datasource_id",
)
- assert_matches_type(DataSource, datasource, path=["response"])
+ assert_matches_type(Datasource, datasource, path=["response"])
@parametrize
def test_raw_response_retrieve(self, client: Asktable) -> None:
@@ -86,7 +89,7 @@ def test_raw_response_retrieve(self, client: Asktable) -> None:
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
datasource = response.parse()
- assert_matches_type(DataSource, datasource, path=["response"])
+ assert_matches_type(Datasource, datasource, path=["response"])
@parametrize
def test_streaming_response_retrieve(self, client: Asktable) -> None:
@@ -97,7 +100,7 @@ def test_streaming_response_retrieve(self, client: Asktable) -> None:
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
datasource = response.parse()
- assert_matches_type(DataSource, datasource, path=["response"])
+ assert_matches_type(Datasource, datasource, path=["response"])
assert cast(Any, response.is_closed) is True
@@ -113,22 +116,26 @@ def test_method_update(self, client: Asktable) -> None:
datasource = client.datasources.update(
datasource_id="datasource_id",
)
- assert_matches_type(DataSource, datasource, path=["response"])
+ assert_matches_type(Datasource, datasource, path=["response"])
@parametrize
def test_method_update_with_all_params(self, client: Asktable) -> None:
datasource = client.datasources.update(
datasource_id="datasource_id",
access_config={
+ "atst_link_id": "atst_link_123456",
"db": "test",
"host": "192.168.0.10",
"location_type": "local",
"location_url": "http://example.com/data.csv",
"password": "root",
"port": 3306,
+ "proxy_host": "192.168.0.10",
+ "proxy_port": 3306,
"securetunnel_id": "atst_123456",
"user": "root",
},
+ desc="数据源描述",
field_count=1,
meta_error="error message",
meta_status="processing",
@@ -137,7 +144,7 @@ def test_method_update_with_all_params(self, client: Asktable) -> None:
schema_count=1,
table_count=1,
)
- assert_matches_type(DataSource, datasource, path=["response"])
+ assert_matches_type(Datasource, datasource, path=["response"])
@parametrize
def test_raw_response_update(self, client: Asktable) -> None:
@@ -148,7 +155,7 @@ def test_raw_response_update(self, client: Asktable) -> None:
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
datasource = response.parse()
- assert_matches_type(DataSource, datasource, path=["response"])
+ assert_matches_type(Datasource, datasource, path=["response"])
@parametrize
def test_streaming_response_update(self, client: Asktable) -> None:
@@ -159,7 +166,7 @@ def test_streaming_response_update(self, client: Asktable) -> None:
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
datasource = response.parse()
- assert_matches_type(DataSource, datasource, path=["response"])
+ assert_matches_type(Datasource, datasource, path=["response"])
assert cast(Any, response.is_closed) is True
@@ -173,7 +180,7 @@ def test_path_params_update(self, client: Asktable) -> None:
@parametrize
def test_method_list(self, client: Asktable) -> None:
datasource = client.datasources.list()
- assert_matches_type(DatasourceListResponse, datasource, path=["response"])
+ assert_matches_type(SyncPage[Datasource], datasource, path=["response"])
@parametrize
def test_method_list_with_all_params(self, client: Asktable) -> None:
@@ -182,7 +189,7 @@ def test_method_list_with_all_params(self, client: Asktable) -> None:
page=1,
size=1,
)
- assert_matches_type(DatasourceListResponse, datasource, path=["response"])
+ assert_matches_type(SyncPage[Datasource], datasource, path=["response"])
@parametrize
def test_raw_response_list(self, client: Asktable) -> None:
@@ -191,7 +198,7 @@ def test_raw_response_list(self, client: Asktable) -> None:
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
datasource = response.parse()
- assert_matches_type(DatasourceListResponse, datasource, path=["response"])
+ assert_matches_type(SyncPage[Datasource], datasource, path=["response"])
@parametrize
def test_streaming_response_list(self, client: Asktable) -> None:
@@ -200,7 +207,7 @@ def test_streaming_response_list(self, client: Asktable) -> None:
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
datasource = response.parse()
- assert_matches_type(DatasourceListResponse, datasource, path=["response"])
+ assert_matches_type(SyncPage[Datasource], datasource, path=["response"])
assert cast(Any, response.is_closed) is True
@@ -245,43 +252,40 @@ def test_path_params_delete(self, client: Asktable) -> None:
@parametrize
def test_method_create_from_file(self, client: Asktable) -> None:
datasource = client.datasources.create_from_file(
- name="name",
file=b"raw file contents",
)
- assert_matches_type(DataSource, datasource, path=["response"])
+ assert_matches_type(Datasource, datasource, path=["response"])
@parametrize
def test_method_create_from_file_with_all_params(self, client: Asktable) -> None:
datasource = client.datasources.create_from_file(
- name="name",
file=b"raw file contents",
async_process_meta=True,
+ name="name",
)
- assert_matches_type(DataSource, datasource, path=["response"])
+ assert_matches_type(Datasource, datasource, path=["response"])
@parametrize
def test_raw_response_create_from_file(self, client: Asktable) -> None:
response = client.datasources.with_raw_response.create_from_file(
- name="name",
file=b"raw file contents",
)
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
datasource = response.parse()
- assert_matches_type(DataSource, datasource, path=["response"])
+ assert_matches_type(Datasource, datasource, path=["response"])
@parametrize
def test_streaming_response_create_from_file(self, client: Asktable) -> None:
with client.datasources.with_streaming_response.create_from_file(
- name="name",
file=b"raw file contents",
) as response:
assert not response.is_closed
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
datasource = response.parse()
- assert_matches_type(DataSource, datasource, path=["response"])
+ assert_matches_type(Datasource, datasource, path=["response"])
assert cast(Any, response.is_closed) is True
@@ -294,7 +298,7 @@ async def test_method_create(self, async_client: AsyncAsktable) -> None:
datasource = await async_client.datasources.create(
engine="mysql",
)
- assert_matches_type(DataSource, datasource, path=["response"])
+ assert_matches_type(Datasource, datasource, path=["response"])
@parametrize
async def test_method_create_with_all_params(self, async_client: AsyncAsktable) -> None:
@@ -302,18 +306,21 @@ async def test_method_create_with_all_params(self, async_client: AsyncAsktable)
engine="mysql",
async_process_meta=True,
access_config={
+ "atst_link_id": "atst_link_123456",
"db": "test",
"host": "192.168.0.10",
"location_type": "local",
"location_url": "http://example.com/data.csv",
"password": "root",
"port": 3306,
+ "proxy_host": "192.168.0.10",
+ "proxy_port": 3306,
"securetunnel_id": "atst_123456",
"user": "root",
},
name="用户库",
)
- assert_matches_type(DataSource, datasource, path=["response"])
+ assert_matches_type(Datasource, datasource, path=["response"])
@parametrize
async def test_raw_response_create(self, async_client: AsyncAsktable) -> None:
@@ -324,7 +331,7 @@ async def test_raw_response_create(self, async_client: AsyncAsktable) -> None:
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
datasource = await response.parse()
- assert_matches_type(DataSource, datasource, path=["response"])
+ assert_matches_type(Datasource, datasource, path=["response"])
@parametrize
async def test_streaming_response_create(self, async_client: AsyncAsktable) -> None:
@@ -335,7 +342,7 @@ async def test_streaming_response_create(self, async_client: AsyncAsktable) -> N
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
datasource = await response.parse()
- assert_matches_type(DataSource, datasource, path=["response"])
+ assert_matches_type(Datasource, datasource, path=["response"])
assert cast(Any, response.is_closed) is True
@@ -344,7 +351,7 @@ async def test_method_retrieve(self, async_client: AsyncAsktable) -> None:
datasource = await async_client.datasources.retrieve(
"datasource_id",
)
- assert_matches_type(DataSource, datasource, path=["response"])
+ assert_matches_type(Datasource, datasource, path=["response"])
@parametrize
async def test_raw_response_retrieve(self, async_client: AsyncAsktable) -> None:
@@ -355,7 +362,7 @@ async def test_raw_response_retrieve(self, async_client: AsyncAsktable) -> None:
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
datasource = await response.parse()
- assert_matches_type(DataSource, datasource, path=["response"])
+ assert_matches_type(Datasource, datasource, path=["response"])
@parametrize
async def test_streaming_response_retrieve(self, async_client: AsyncAsktable) -> None:
@@ -366,7 +373,7 @@ async def test_streaming_response_retrieve(self, async_client: AsyncAsktable) ->
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
datasource = await response.parse()
- assert_matches_type(DataSource, datasource, path=["response"])
+ assert_matches_type(Datasource, datasource, path=["response"])
assert cast(Any, response.is_closed) is True
@@ -382,22 +389,26 @@ async def test_method_update(self, async_client: AsyncAsktable) -> None:
datasource = await async_client.datasources.update(
datasource_id="datasource_id",
)
- assert_matches_type(DataSource, datasource, path=["response"])
+ assert_matches_type(Datasource, datasource, path=["response"])
@parametrize
async def test_method_update_with_all_params(self, async_client: AsyncAsktable) -> None:
datasource = await async_client.datasources.update(
datasource_id="datasource_id",
access_config={
+ "atst_link_id": "atst_link_123456",
"db": "test",
"host": "192.168.0.10",
"location_type": "local",
"location_url": "http://example.com/data.csv",
"password": "root",
"port": 3306,
+ "proxy_host": "192.168.0.10",
+ "proxy_port": 3306,
"securetunnel_id": "atst_123456",
"user": "root",
},
+ desc="数据源描述",
field_count=1,
meta_error="error message",
meta_status="processing",
@@ -406,7 +417,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncAsktable)
schema_count=1,
table_count=1,
)
- assert_matches_type(DataSource, datasource, path=["response"])
+ assert_matches_type(Datasource, datasource, path=["response"])
@parametrize
async def test_raw_response_update(self, async_client: AsyncAsktable) -> None:
@@ -417,7 +428,7 @@ async def test_raw_response_update(self, async_client: AsyncAsktable) -> None:
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
datasource = await response.parse()
- assert_matches_type(DataSource, datasource, path=["response"])
+ assert_matches_type(Datasource, datasource, path=["response"])
@parametrize
async def test_streaming_response_update(self, async_client: AsyncAsktable) -> None:
@@ -428,7 +439,7 @@ async def test_streaming_response_update(self, async_client: AsyncAsktable) -> N
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
datasource = await response.parse()
- assert_matches_type(DataSource, datasource, path=["response"])
+ assert_matches_type(Datasource, datasource, path=["response"])
assert cast(Any, response.is_closed) is True
@@ -442,7 +453,7 @@ async def test_path_params_update(self, async_client: AsyncAsktable) -> None:
@parametrize
async def test_method_list(self, async_client: AsyncAsktable) -> None:
datasource = await async_client.datasources.list()
- assert_matches_type(DatasourceListResponse, datasource, path=["response"])
+ assert_matches_type(AsyncPage[Datasource], datasource, path=["response"])
@parametrize
async def test_method_list_with_all_params(self, async_client: AsyncAsktable) -> None:
@@ -451,7 +462,7 @@ async def test_method_list_with_all_params(self, async_client: AsyncAsktable) ->
page=1,
size=1,
)
- assert_matches_type(DatasourceListResponse, datasource, path=["response"])
+ assert_matches_type(AsyncPage[Datasource], datasource, path=["response"])
@parametrize
async def test_raw_response_list(self, async_client: AsyncAsktable) -> None:
@@ -460,7 +471,7 @@ async def test_raw_response_list(self, async_client: AsyncAsktable) -> None:
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
datasource = await response.parse()
- assert_matches_type(DatasourceListResponse, datasource, path=["response"])
+ assert_matches_type(AsyncPage[Datasource], datasource, path=["response"])
@parametrize
async def test_streaming_response_list(self, async_client: AsyncAsktable) -> None:
@@ -469,7 +480,7 @@ async def test_streaming_response_list(self, async_client: AsyncAsktable) -> Non
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
datasource = await response.parse()
- assert_matches_type(DatasourceListResponse, datasource, path=["response"])
+ assert_matches_type(AsyncPage[Datasource], datasource, path=["response"])
assert cast(Any, response.is_closed) is True
@@ -514,42 +525,39 @@ async def test_path_params_delete(self, async_client: AsyncAsktable) -> None:
@parametrize
async def test_method_create_from_file(self, async_client: AsyncAsktable) -> None:
datasource = await async_client.datasources.create_from_file(
- name="name",
file=b"raw file contents",
)
- assert_matches_type(DataSource, datasource, path=["response"])
+ assert_matches_type(Datasource, datasource, path=["response"])
@parametrize
async def test_method_create_from_file_with_all_params(self, async_client: AsyncAsktable) -> None:
datasource = await async_client.datasources.create_from_file(
- name="name",
file=b"raw file contents",
async_process_meta=True,
+ name="name",
)
- assert_matches_type(DataSource, datasource, path=["response"])
+ assert_matches_type(Datasource, datasource, path=["response"])
@parametrize
async def test_raw_response_create_from_file(self, async_client: AsyncAsktable) -> None:
response = await async_client.datasources.with_raw_response.create_from_file(
- name="name",
file=b"raw file contents",
)
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
datasource = await response.parse()
- assert_matches_type(DataSource, datasource, path=["response"])
+ assert_matches_type(Datasource, datasource, path=["response"])
@parametrize
async def test_streaming_response_create_from_file(self, async_client: AsyncAsktable) -> None:
async with async_client.datasources.with_streaming_response.create_from_file(
- name="name",
file=b"raw file contents",
) as response:
assert not response.is_closed
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
datasource = await response.parse()
- assert_matches_type(DataSource, datasource, path=["response"])
+ assert_matches_type(Datasource, datasource, path=["response"])
assert cast(Any, response.is_closed) is True
diff --git a/tests/api_resources/test_extapis.py b/tests/api_resources/test_extapis.py
index c6242803..0e7bdaab 100644
--- a/tests/api_resources/test_extapis.py
+++ b/tests/api_resources/test_extapis.py
@@ -9,11 +9,8 @@
from asktable import Asktable, AsyncAsktable
from tests.utils import assert_matches_type
-from asktable.types import (
- ExtAPIModel,
- ExtapiListResponse,
-)
-from asktable._utils import parse_datetime
+from asktable.types import Extapi
+from asktable.pagination import SyncPage, AsyncPage
base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
@@ -24,56 +21,43 @@ class TestExtapis:
@parametrize
def test_method_create(self, client: Asktable) -> None:
extapi = client.extapis.create(
- id="id",
base_url="https://api.example.com/v1",
- created_at=parse_datetime("2019-12-27T18:11:19.117Z"),
name="name",
- project_id="project_id",
)
- assert_matches_type(ExtAPIModel, extapi, path=["response"])
+ assert_matches_type(Extapi, extapi, path=["response"])
@parametrize
def test_method_create_with_all_params(self, client: Asktable) -> None:
extapi = client.extapis.create(
- id="id",
base_url="https://api.example.com/v1",
- created_at=parse_datetime("2019-12-27T18:11:19.117Z"),
name="name",
- project_id="project_id",
headers={"Authorization": "Bearer "},
- updated_at=parse_datetime("2019-12-27T18:11:19.117Z"),
)
- assert_matches_type(ExtAPIModel, extapi, path=["response"])
+ assert_matches_type(Extapi, extapi, path=["response"])
@parametrize
def test_raw_response_create(self, client: Asktable) -> None:
response = client.extapis.with_raw_response.create(
- id="id",
base_url="https://api.example.com/v1",
- created_at=parse_datetime("2019-12-27T18:11:19.117Z"),
name="name",
- project_id="project_id",
)
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
extapi = response.parse()
- assert_matches_type(ExtAPIModel, extapi, path=["response"])
+ assert_matches_type(Extapi, extapi, path=["response"])
@parametrize
def test_streaming_response_create(self, client: Asktable) -> None:
with client.extapis.with_streaming_response.create(
- id="id",
base_url="https://api.example.com/v1",
- created_at=parse_datetime("2019-12-27T18:11:19.117Z"),
name="name",
- project_id="project_id",
) as response:
assert not response.is_closed
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
extapi = response.parse()
- assert_matches_type(ExtAPIModel, extapi, path=["response"])
+ assert_matches_type(Extapi, extapi, path=["response"])
assert cast(Any, response.is_closed) is True
@@ -82,7 +66,7 @@ def test_method_retrieve(self, client: Asktable) -> None:
extapi = client.extapis.retrieve(
"extapi_id",
)
- assert_matches_type(ExtAPIModel, extapi, path=["response"])
+ assert_matches_type(Extapi, extapi, path=["response"])
@parametrize
def test_raw_response_retrieve(self, client: Asktable) -> None:
@@ -93,7 +77,7 @@ def test_raw_response_retrieve(self, client: Asktable) -> None:
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
extapi = response.parse()
- assert_matches_type(ExtAPIModel, extapi, path=["response"])
+ assert_matches_type(Extapi, extapi, path=["response"])
@parametrize
def test_streaming_response_retrieve(self, client: Asktable) -> None:
@@ -104,7 +88,7 @@ def test_streaming_response_retrieve(self, client: Asktable) -> None:
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
extapi = response.parse()
- assert_matches_type(ExtAPIModel, extapi, path=["response"])
+ assert_matches_type(Extapi, extapi, path=["response"])
assert cast(Any, response.is_closed) is True
@@ -120,7 +104,7 @@ def test_method_update(self, client: Asktable) -> None:
extapi = client.extapis.update(
extapi_id="extapi_id",
)
- assert_matches_type(ExtAPIModel, extapi, path=["response"])
+ assert_matches_type(Extapi, extapi, path=["response"])
@parametrize
def test_method_update_with_all_params(self, client: Asktable) -> None:
@@ -130,7 +114,7 @@ def test_method_update_with_all_params(self, client: Asktable) -> None:
headers={"Authorization": "Bearer "},
name="name",
)
- assert_matches_type(ExtAPIModel, extapi, path=["response"])
+ assert_matches_type(Extapi, extapi, path=["response"])
@parametrize
def test_raw_response_update(self, client: Asktable) -> None:
@@ -141,7 +125,7 @@ def test_raw_response_update(self, client: Asktable) -> None:
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
extapi = response.parse()
- assert_matches_type(ExtAPIModel, extapi, path=["response"])
+ assert_matches_type(Extapi, extapi, path=["response"])
@parametrize
def test_streaming_response_update(self, client: Asktable) -> None:
@@ -152,7 +136,7 @@ def test_streaming_response_update(self, client: Asktable) -> None:
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
extapi = response.parse()
- assert_matches_type(ExtAPIModel, extapi, path=["response"])
+ assert_matches_type(Extapi, extapi, path=["response"])
assert cast(Any, response.is_closed) is True
@@ -166,7 +150,7 @@ def test_path_params_update(self, client: Asktable) -> None:
@parametrize
def test_method_list(self, client: Asktable) -> None:
extapi = client.extapis.list()
- assert_matches_type(ExtapiListResponse, extapi, path=["response"])
+ assert_matches_type(SyncPage[Extapi], extapi, path=["response"])
@parametrize
def test_method_list_with_all_params(self, client: Asktable) -> None:
@@ -175,7 +159,7 @@ def test_method_list_with_all_params(self, client: Asktable) -> None:
page=1,
size=1,
)
- assert_matches_type(ExtapiListResponse, extapi, path=["response"])
+ assert_matches_type(SyncPage[Extapi], extapi, path=["response"])
@parametrize
def test_raw_response_list(self, client: Asktable) -> None:
@@ -184,7 +168,7 @@ def test_raw_response_list(self, client: Asktable) -> None:
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
extapi = response.parse()
- assert_matches_type(ExtapiListResponse, extapi, path=["response"])
+ assert_matches_type(SyncPage[Extapi], extapi, path=["response"])
@parametrize
def test_streaming_response_list(self, client: Asktable) -> None:
@@ -193,7 +177,7 @@ def test_streaming_response_list(self, client: Asktable) -> None:
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
extapi = response.parse()
- assert_matches_type(ExtapiListResponse, extapi, path=["response"])
+ assert_matches_type(SyncPage[Extapi], extapi, path=["response"])
assert cast(Any, response.is_closed) is True
@@ -242,56 +226,43 @@ class TestAsyncExtapis:
@parametrize
async def test_method_create(self, async_client: AsyncAsktable) -> None:
extapi = await async_client.extapis.create(
- id="id",
base_url="https://api.example.com/v1",
- created_at=parse_datetime("2019-12-27T18:11:19.117Z"),
name="name",
- project_id="project_id",
)
- assert_matches_type(ExtAPIModel, extapi, path=["response"])
+ assert_matches_type(Extapi, extapi, path=["response"])
@parametrize
async def test_method_create_with_all_params(self, async_client: AsyncAsktable) -> None:
extapi = await async_client.extapis.create(
- id="id",
base_url="https://api.example.com/v1",
- created_at=parse_datetime("2019-12-27T18:11:19.117Z"),
name="name",
- project_id="project_id",
headers={"Authorization": "Bearer "},
- updated_at=parse_datetime("2019-12-27T18:11:19.117Z"),
)
- assert_matches_type(ExtAPIModel, extapi, path=["response"])
+ assert_matches_type(Extapi, extapi, path=["response"])
@parametrize
async def test_raw_response_create(self, async_client: AsyncAsktable) -> None:
response = await async_client.extapis.with_raw_response.create(
- id="id",
base_url="https://api.example.com/v1",
- created_at=parse_datetime("2019-12-27T18:11:19.117Z"),
name="name",
- project_id="project_id",
)
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
extapi = await response.parse()
- assert_matches_type(ExtAPIModel, extapi, path=["response"])
+ assert_matches_type(Extapi, extapi, path=["response"])
@parametrize
async def test_streaming_response_create(self, async_client: AsyncAsktable) -> None:
async with async_client.extapis.with_streaming_response.create(
- id="id",
base_url="https://api.example.com/v1",
- created_at=parse_datetime("2019-12-27T18:11:19.117Z"),
name="name",
- project_id="project_id",
) as response:
assert not response.is_closed
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
extapi = await response.parse()
- assert_matches_type(ExtAPIModel, extapi, path=["response"])
+ assert_matches_type(Extapi, extapi, path=["response"])
assert cast(Any, response.is_closed) is True
@@ -300,7 +271,7 @@ async def test_method_retrieve(self, async_client: AsyncAsktable) -> None:
extapi = await async_client.extapis.retrieve(
"extapi_id",
)
- assert_matches_type(ExtAPIModel, extapi, path=["response"])
+ assert_matches_type(Extapi, extapi, path=["response"])
@parametrize
async def test_raw_response_retrieve(self, async_client: AsyncAsktable) -> None:
@@ -311,7 +282,7 @@ async def test_raw_response_retrieve(self, async_client: AsyncAsktable) -> None:
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
extapi = await response.parse()
- assert_matches_type(ExtAPIModel, extapi, path=["response"])
+ assert_matches_type(Extapi, extapi, path=["response"])
@parametrize
async def test_streaming_response_retrieve(self, async_client: AsyncAsktable) -> None:
@@ -322,7 +293,7 @@ async def test_streaming_response_retrieve(self, async_client: AsyncAsktable) ->
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
extapi = await response.parse()
- assert_matches_type(ExtAPIModel, extapi, path=["response"])
+ assert_matches_type(Extapi, extapi, path=["response"])
assert cast(Any, response.is_closed) is True
@@ -338,7 +309,7 @@ async def test_method_update(self, async_client: AsyncAsktable) -> None:
extapi = await async_client.extapis.update(
extapi_id="extapi_id",
)
- assert_matches_type(ExtAPIModel, extapi, path=["response"])
+ assert_matches_type(Extapi, extapi, path=["response"])
@parametrize
async def test_method_update_with_all_params(self, async_client: AsyncAsktable) -> None:
@@ -348,7 +319,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncAsktable)
headers={"Authorization": "Bearer "},
name="name",
)
- assert_matches_type(ExtAPIModel, extapi, path=["response"])
+ assert_matches_type(Extapi, extapi, path=["response"])
@parametrize
async def test_raw_response_update(self, async_client: AsyncAsktable) -> None:
@@ -359,7 +330,7 @@ async def test_raw_response_update(self, async_client: AsyncAsktable) -> None:
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
extapi = await response.parse()
- assert_matches_type(ExtAPIModel, extapi, path=["response"])
+ assert_matches_type(Extapi, extapi, path=["response"])
@parametrize
async def test_streaming_response_update(self, async_client: AsyncAsktable) -> None:
@@ -370,7 +341,7 @@ async def test_streaming_response_update(self, async_client: AsyncAsktable) -> N
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
extapi = await response.parse()
- assert_matches_type(ExtAPIModel, extapi, path=["response"])
+ assert_matches_type(Extapi, extapi, path=["response"])
assert cast(Any, response.is_closed) is True
@@ -384,7 +355,7 @@ async def test_path_params_update(self, async_client: AsyncAsktable) -> None:
@parametrize
async def test_method_list(self, async_client: AsyncAsktable) -> None:
extapi = await async_client.extapis.list()
- assert_matches_type(ExtapiListResponse, extapi, path=["response"])
+ assert_matches_type(AsyncPage[Extapi], extapi, path=["response"])
@parametrize
async def test_method_list_with_all_params(self, async_client: AsyncAsktable) -> None:
@@ -393,7 +364,7 @@ async def test_method_list_with_all_params(self, async_client: AsyncAsktable) ->
page=1,
size=1,
)
- assert_matches_type(ExtapiListResponse, extapi, path=["response"])
+ assert_matches_type(AsyncPage[Extapi], extapi, path=["response"])
@parametrize
async def test_raw_response_list(self, async_client: AsyncAsktable) -> None:
@@ -402,7 +373,7 @@ async def test_raw_response_list(self, async_client: AsyncAsktable) -> None:
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
extapi = await response.parse()
- assert_matches_type(ExtapiListResponse, extapi, path=["response"])
+ assert_matches_type(AsyncPage[Extapi], extapi, path=["response"])
@parametrize
async def test_streaming_response_list(self, async_client: AsyncAsktable) -> None:
@@ -411,7 +382,7 @@ async def test_streaming_response_list(self, async_client: AsyncAsktable) -> Non
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
extapi = await response.parse()
- assert_matches_type(ExtapiListResponse, extapi, path=["response"])
+ assert_matches_type(AsyncPage[Extapi], extapi, path=["response"])
assert cast(Any, response.is_closed) is True
diff --git a/tests/api_resources/test_integration.py b/tests/api_resources/test_integration.py
index 15ca2e34..335bb917 100644
--- a/tests/api_resources/test_integration.py
+++ b/tests/api_resources/test_integration.py
@@ -9,7 +9,10 @@
from asktable import Asktable, AsyncAsktable
from tests.utils import assert_matches_type
-from asktable.types import AnswerDataSourceOut
+from asktable.types import (
+ Datasource,
+ FileAskResponse,
+)
base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
@@ -17,46 +20,77 @@
class TestIntegration:
parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"])
+ @parametrize
+ def test_method_create_excel_ds(self, client: Asktable) -> None:
+ integration = client.integration.create_excel_ds(
+ file_url="https://example.com",
+ )
+ assert_matches_type(Datasource, integration, path=["response"])
+
+ @parametrize
+ def test_raw_response_create_excel_ds(self, client: Asktable) -> None:
+ response = client.integration.with_raw_response.create_excel_ds(
+ file_url="https://example.com",
+ )
+
+ assert response.is_closed is True
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+ integration = response.parse()
+ assert_matches_type(Datasource, integration, path=["response"])
+
+ @parametrize
+ def test_streaming_response_create_excel_ds(self, client: Asktable) -> None:
+ with client.integration.with_streaming_response.create_excel_ds(
+ file_url="https://example.com",
+ ) as response:
+ assert not response.is_closed
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+
+ integration = response.parse()
+ assert_matches_type(Datasource, integration, path=["response"])
+
+ assert cast(Any, response.is_closed) is True
+
@parametrize
def test_method_excel_csv_ask(self, client: Asktable) -> None:
integration = client.integration.excel_csv_ask(
- file_url="file_url",
+ file_url="https://example.com",
question="question",
)
- assert_matches_type(AnswerDataSourceOut, integration, path=["response"])
+ assert_matches_type(FileAskResponse, integration, path=["response"])
@parametrize
def test_method_excel_csv_ask_with_all_params(self, client: Asktable) -> None:
integration = client.integration.excel_csv_ask(
- file_url="file_url",
+ file_url="https://example.com",
question="question",
with_json=True,
)
- assert_matches_type(AnswerDataSourceOut, integration, path=["response"])
+ assert_matches_type(FileAskResponse, integration, path=["response"])
@parametrize
def test_raw_response_excel_csv_ask(self, client: Asktable) -> None:
response = client.integration.with_raw_response.excel_csv_ask(
- file_url="file_url",
+ file_url="https://example.com",
question="question",
)
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
integration = response.parse()
- assert_matches_type(AnswerDataSourceOut, integration, path=["response"])
+ assert_matches_type(FileAskResponse, integration, path=["response"])
@parametrize
def test_streaming_response_excel_csv_ask(self, client: Asktable) -> None:
with client.integration.with_streaming_response.excel_csv_ask(
- file_url="file_url",
+ file_url="https://example.com",
question="question",
) as response:
assert not response.is_closed
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
integration = response.parse()
- assert_matches_type(AnswerDataSourceOut, integration, path=["response"])
+ assert_matches_type(FileAskResponse, integration, path=["response"])
assert cast(Any, response.is_closed) is True
@@ -64,45 +98,76 @@ def test_streaming_response_excel_csv_ask(self, client: Asktable) -> None:
class TestAsyncIntegration:
parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"])
+ @parametrize
+ async def test_method_create_excel_ds(self, async_client: AsyncAsktable) -> None:
+ integration = await async_client.integration.create_excel_ds(
+ file_url="https://example.com",
+ )
+ assert_matches_type(Datasource, integration, path=["response"])
+
+ @parametrize
+ async def test_raw_response_create_excel_ds(self, async_client: AsyncAsktable) -> None:
+ response = await async_client.integration.with_raw_response.create_excel_ds(
+ file_url="https://example.com",
+ )
+
+ assert response.is_closed is True
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+ integration = await response.parse()
+ assert_matches_type(Datasource, integration, path=["response"])
+
+ @parametrize
+ async def test_streaming_response_create_excel_ds(self, async_client: AsyncAsktable) -> None:
+ async with async_client.integration.with_streaming_response.create_excel_ds(
+ file_url="https://example.com",
+ ) as response:
+ assert not response.is_closed
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+
+ integration = await response.parse()
+ assert_matches_type(Datasource, integration, path=["response"])
+
+ assert cast(Any, response.is_closed) is True
+
@parametrize
async def test_method_excel_csv_ask(self, async_client: AsyncAsktable) -> None:
integration = await async_client.integration.excel_csv_ask(
- file_url="file_url",
+ file_url="https://example.com",
question="question",
)
- assert_matches_type(AnswerDataSourceOut, integration, path=["response"])
+ assert_matches_type(FileAskResponse, integration, path=["response"])
@parametrize
async def test_method_excel_csv_ask_with_all_params(self, async_client: AsyncAsktable) -> None:
integration = await async_client.integration.excel_csv_ask(
- file_url="file_url",
+ file_url="https://example.com",
question="question",
with_json=True,
)
- assert_matches_type(AnswerDataSourceOut, integration, path=["response"])
+ assert_matches_type(FileAskResponse, integration, path=["response"])
@parametrize
async def test_raw_response_excel_csv_ask(self, async_client: AsyncAsktable) -> None:
response = await async_client.integration.with_raw_response.excel_csv_ask(
- file_url="file_url",
+ file_url="https://example.com",
question="question",
)
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
integration = await response.parse()
- assert_matches_type(AnswerDataSourceOut, integration, path=["response"])
+ assert_matches_type(FileAskResponse, integration, path=["response"])
@parametrize
async def test_streaming_response_excel_csv_ask(self, async_client: AsyncAsktable) -> None:
async with async_client.integration.with_streaming_response.excel_csv_ask(
- file_url="file_url",
+ file_url="https://example.com",
question="question",
) as response:
assert not response.is_closed
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
integration = await response.parse()
- assert_matches_type(AnswerDataSourceOut, integration, path=["response"])
+ assert_matches_type(FileAskResponse, integration, path=["response"])
assert cast(Any, response.is_closed) is True
diff --git a/tests/api_resources/test_kb.py b/tests/api_resources/test_kb.py
deleted file mode 100644
index 297651d0..00000000
--- a/tests/api_resources/test_kb.py
+++ /dev/null
@@ -1,382 +0,0 @@
-# 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 Document, PageDocument, KBCreateResponse
-
-base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
-
-
-class TestKB:
- parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"])
-
- @parametrize
- def test_method_create(self, client: Asktable) -> None:
- kb = client.kb.create(
- body=[
- {
- "content": "content",
- "name": "name",
- },
- {
- "content": "content",
- "name": "name",
- },
- {
- "content": "content",
- "name": "name",
- },
- ],
- )
- assert_matches_type(KBCreateResponse, kb, path=["response"])
-
- @parametrize
- def test_raw_response_create(self, client: Asktable) -> None:
- response = client.kb.with_raw_response.create(
- body=[
- {
- "content": "content",
- "name": "name",
- },
- {
- "content": "content",
- "name": "name",
- },
- {
- "content": "content",
- "name": "name",
- },
- ],
- )
-
- assert response.is_closed is True
- assert response.http_request.headers.get("X-Stainless-Lang") == "python"
- kb = response.parse()
- assert_matches_type(KBCreateResponse, kb, path=["response"])
-
- @parametrize
- def test_streaming_response_create(self, client: Asktable) -> None:
- with client.kb.with_streaming_response.create(
- body=[
- {
- "content": "content",
- "name": "name",
- },
- {
- "content": "content",
- "name": "name",
- },
- {
- "content": "content",
- "name": "name",
- },
- ],
- ) as response:
- assert not response.is_closed
- assert response.http_request.headers.get("X-Stainless-Lang") == "python"
-
- kb = response.parse()
- assert_matches_type(KBCreateResponse, kb, path=["response"])
-
- assert cast(Any, response.is_closed) is True
-
- @parametrize
- def test_method_retrieve(self, client: Asktable) -> None:
- kb = client.kb.retrieve(
- "doc_id",
- )
- assert_matches_type(Document, kb, path=["response"])
-
- @parametrize
- def test_raw_response_retrieve(self, client: Asktable) -> None:
- response = client.kb.with_raw_response.retrieve(
- "doc_id",
- )
-
- assert response.is_closed is True
- assert response.http_request.headers.get("X-Stainless-Lang") == "python"
- kb = response.parse()
- assert_matches_type(Document, kb, path=["response"])
-
- @parametrize
- def test_streaming_response_retrieve(self, client: Asktable) -> None:
- with client.kb.with_streaming_response.retrieve(
- "doc_id",
- ) as response:
- assert not response.is_closed
- assert response.http_request.headers.get("X-Stainless-Lang") == "python"
-
- kb = response.parse()
- assert_matches_type(Document, kb, 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 `doc_id` but received ''"):
- client.kb.with_raw_response.retrieve(
- "",
- )
-
- @parametrize
- def test_method_list(self, client: Asktable) -> None:
- kb = client.kb.list()
- assert_matches_type(PageDocument, kb, path=["response"])
-
- @parametrize
- def test_method_list_with_all_params(self, client: Asktable) -> None:
- kb = client.kb.list(
- name="name",
- page=1,
- size=1,
- )
- assert_matches_type(PageDocument, kb, path=["response"])
-
- @parametrize
- def test_raw_response_list(self, client: Asktable) -> None:
- response = client.kb.with_raw_response.list()
-
- assert response.is_closed is True
- assert response.http_request.headers.get("X-Stainless-Lang") == "python"
- kb = response.parse()
- assert_matches_type(PageDocument, kb, path=["response"])
-
- @parametrize
- def test_streaming_response_list(self, client: Asktable) -> None:
- with client.kb.with_streaming_response.list() as response:
- assert not response.is_closed
- assert response.http_request.headers.get("X-Stainless-Lang") == "python"
-
- kb = response.parse()
- assert_matches_type(PageDocument, kb, path=["response"])
-
- assert cast(Any, response.is_closed) is True
-
- @parametrize
- def test_method_delete(self, client: Asktable) -> None:
- kb = client.kb.delete(
- "doc_id",
- )
- assert_matches_type(object, kb, path=["response"])
-
- @parametrize
- def test_raw_response_delete(self, client: Asktable) -> None:
- response = client.kb.with_raw_response.delete(
- "doc_id",
- )
-
- assert response.is_closed is True
- assert response.http_request.headers.get("X-Stainless-Lang") == "python"
- kb = response.parse()
- assert_matches_type(object, kb, path=["response"])
-
- @parametrize
- def test_streaming_response_delete(self, client: Asktable) -> None:
- with client.kb.with_streaming_response.delete(
- "doc_id",
- ) as response:
- assert not response.is_closed
- assert response.http_request.headers.get("X-Stainless-Lang") == "python"
-
- kb = response.parse()
- assert_matches_type(object, kb, path=["response"])
-
- assert cast(Any, response.is_closed) is True
-
- @parametrize
- def test_path_params_delete(self, client: Asktable) -> None:
- with pytest.raises(ValueError, match=r"Expected a non-empty value for `doc_id` but received ''"):
- client.kb.with_raw_response.delete(
- "",
- )
-
-
-class TestAsyncKB:
- parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"])
-
- @parametrize
- async def test_method_create(self, async_client: AsyncAsktable) -> None:
- kb = await async_client.kb.create(
- body=[
- {
- "content": "content",
- "name": "name",
- },
- {
- "content": "content",
- "name": "name",
- },
- {
- "content": "content",
- "name": "name",
- },
- ],
- )
- assert_matches_type(KBCreateResponse, kb, path=["response"])
-
- @parametrize
- async def test_raw_response_create(self, async_client: AsyncAsktable) -> None:
- response = await async_client.kb.with_raw_response.create(
- body=[
- {
- "content": "content",
- "name": "name",
- },
- {
- "content": "content",
- "name": "name",
- },
- {
- "content": "content",
- "name": "name",
- },
- ],
- )
-
- assert response.is_closed is True
- assert response.http_request.headers.get("X-Stainless-Lang") == "python"
- kb = await response.parse()
- assert_matches_type(KBCreateResponse, kb, path=["response"])
-
- @parametrize
- async def test_streaming_response_create(self, async_client: AsyncAsktable) -> None:
- async with async_client.kb.with_streaming_response.create(
- body=[
- {
- "content": "content",
- "name": "name",
- },
- {
- "content": "content",
- "name": "name",
- },
- {
- "content": "content",
- "name": "name",
- },
- ],
- ) as response:
- assert not response.is_closed
- assert response.http_request.headers.get("X-Stainless-Lang") == "python"
-
- kb = await response.parse()
- assert_matches_type(KBCreateResponse, kb, path=["response"])
-
- assert cast(Any, response.is_closed) is True
-
- @parametrize
- async def test_method_retrieve(self, async_client: AsyncAsktable) -> None:
- kb = await async_client.kb.retrieve(
- "doc_id",
- )
- assert_matches_type(Document, kb, path=["response"])
-
- @parametrize
- async def test_raw_response_retrieve(self, async_client: AsyncAsktable) -> None:
- response = await async_client.kb.with_raw_response.retrieve(
- "doc_id",
- )
-
- assert response.is_closed is True
- assert response.http_request.headers.get("X-Stainless-Lang") == "python"
- kb = await response.parse()
- assert_matches_type(Document, kb, path=["response"])
-
- @parametrize
- async def test_streaming_response_retrieve(self, async_client: AsyncAsktable) -> None:
- async with async_client.kb.with_streaming_response.retrieve(
- "doc_id",
- ) as response:
- assert not response.is_closed
- assert response.http_request.headers.get("X-Stainless-Lang") == "python"
-
- kb = await response.parse()
- assert_matches_type(Document, kb, 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 `doc_id` but received ''"):
- await async_client.kb.with_raw_response.retrieve(
- "",
- )
-
- @parametrize
- async def test_method_list(self, async_client: AsyncAsktable) -> None:
- kb = await async_client.kb.list()
- assert_matches_type(PageDocument, kb, path=["response"])
-
- @parametrize
- async def test_method_list_with_all_params(self, async_client: AsyncAsktable) -> None:
- kb = await async_client.kb.list(
- name="name",
- page=1,
- size=1,
- )
- assert_matches_type(PageDocument, kb, path=["response"])
-
- @parametrize
- async def test_raw_response_list(self, async_client: AsyncAsktable) -> None:
- response = await async_client.kb.with_raw_response.list()
-
- assert response.is_closed is True
- assert response.http_request.headers.get("X-Stainless-Lang") == "python"
- kb = await response.parse()
- assert_matches_type(PageDocument, kb, path=["response"])
-
- @parametrize
- async def test_streaming_response_list(self, async_client: AsyncAsktable) -> None:
- async with async_client.kb.with_streaming_response.list() as response:
- assert not response.is_closed
- assert response.http_request.headers.get("X-Stainless-Lang") == "python"
-
- kb = await response.parse()
- assert_matches_type(PageDocument, kb, path=["response"])
-
- assert cast(Any, response.is_closed) is True
-
- @parametrize
- async def test_method_delete(self, async_client: AsyncAsktable) -> None:
- kb = await async_client.kb.delete(
- "doc_id",
- )
- assert_matches_type(object, kb, path=["response"])
-
- @parametrize
- async def test_raw_response_delete(self, async_client: AsyncAsktable) -> None:
- response = await async_client.kb.with_raw_response.delete(
- "doc_id",
- )
-
- assert response.is_closed is True
- assert response.http_request.headers.get("X-Stainless-Lang") == "python"
- kb = await response.parse()
- assert_matches_type(object, kb, path=["response"])
-
- @parametrize
- async def test_streaming_response_delete(self, async_client: AsyncAsktable) -> None:
- async with async_client.kb.with_streaming_response.delete(
- "doc_id",
- ) as response:
- assert not response.is_closed
- assert response.http_request.headers.get("X-Stainless-Lang") == "python"
-
- kb = await response.parse()
- assert_matches_type(object, kb, path=["response"])
-
- assert cast(Any, response.is_closed) is True
-
- @parametrize
- async def test_path_params_delete(self, async_client: AsyncAsktable) -> None:
- with pytest.raises(ValueError, match=r"Expected a non-empty value for `doc_id` but received ''"):
- await async_client.kb.with_raw_response.delete(
- "",
- )
diff --git a/tests/api_resources/test_policies.py b/tests/api_resources/test_policies.py
index 06c71589..1832cc19 100644
--- a/tests/api_resources/test_policies.py
+++ b/tests/api_resources/test_policies.py
@@ -9,7 +9,7 @@
from asktable import Asktable, AsyncAsktable
from tests.utils import assert_matches_type
-from asktable.types import PolicyListResponse
+from asktable.pagination import SyncPage, AsyncPage
from asktable.types.shared import Policy
base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
@@ -21,7 +21,7 @@ class TestPolicies:
@parametrize
def test_method_create(self, client: Asktable) -> None:
policy = client.policies.create(
- dataset_config={"datasource_ids": ["string", "string", "string"]},
+ dataset_config={"datasource_ids": ["string"]},
name="name",
permission="allow",
)
@@ -31,7 +31,7 @@ def test_method_create(self, client: Asktable) -> None:
def test_method_create_with_all_params(self, client: Asktable) -> None:
policy = client.policies.create(
dataset_config={
- "datasource_ids": ["string", "string", "string"],
+ "datasource_ids": ["string"],
"regex_patterns": {
"fields_regex_pattern": ".*password.* | .*pwd.*",
"schemas_regex_pattern": "^public.*$",
@@ -55,7 +55,7 @@ def test_method_create_with_all_params(self, client: Asktable) -> None:
@parametrize
def test_raw_response_create(self, client: Asktable) -> None:
response = client.policies.with_raw_response.create(
- dataset_config={"datasource_ids": ["string", "string", "string"]},
+ dataset_config={"datasource_ids": ["string"]},
name="name",
permission="allow",
)
@@ -68,7 +68,7 @@ def test_raw_response_create(self, client: Asktable) -> None:
@parametrize
def test_streaming_response_create(self, client: Asktable) -> None:
with client.policies.with_streaming_response.create(
- dataset_config={"datasource_ids": ["string", "string", "string"]},
+ dataset_config={"datasource_ids": ["string"]},
name="name",
permission="allow",
) as response:
@@ -130,7 +130,7 @@ def test_method_update_with_all_params(self, client: Asktable) -> None:
policy = client.policies.update(
policy_id="policy_id",
dataset_config={
- "datasource_ids": ["string", "string", "string"],
+ "datasource_ids": ["string"],
"regex_patterns": {
"fields_regex_pattern": ".*password.* | .*pwd.*",
"schemas_regex_pattern": "^public.*$",
@@ -144,7 +144,7 @@ def test_method_update_with_all_params(self, client: Asktable) -> None:
"field_regex": "field_regex",
"operator_expression": "operator_expression",
"table_regex": "table_regex",
- "variables": ["string", "string", "string"],
+ "variables": ["string"],
}
],
"ds_sJAbnNOUzu3R4DdCCOwe": [
@@ -154,7 +154,7 @@ def test_method_update_with_all_params(self, client: Asktable) -> None:
"field_regex": "field_regex",
"operator_expression": "operator_expression",
"table_regex": "table_regex",
- "variables": ["string", "string", "string"],
+ "variables": ["string"],
},
{
"condition": "condition",
@@ -162,7 +162,7 @@ def test_method_update_with_all_params(self, client: Asktable) -> None:
"field_regex": "field_regex",
"operator_expression": "operator_expression",
"table_regex": "table_regex",
- "variables": ["string", "string", "string"],
+ "variables": ["string"],
},
{
"condition": "condition",
@@ -170,7 +170,7 @@ def test_method_update_with_all_params(self, client: Asktable) -> None:
"field_regex": "field_regex",
"operator_expression": "operator_expression",
"table_regex": "table_regex",
- "variables": ["string", "string", "string"],
+ "variables": ["string"],
},
{
"condition": "condition",
@@ -178,7 +178,7 @@ def test_method_update_with_all_params(self, client: Asktable) -> None:
"field_regex": "field_regex",
"operator_expression": "operator_expression",
"table_regex": "table_regex",
- "variables": ["string", "string", "string"],
+ "variables": ["string"],
},
],
},
@@ -222,17 +222,17 @@ def test_path_params_update(self, client: Asktable) -> None:
@parametrize
def test_method_list(self, client: Asktable) -> None:
policy = client.policies.list()
- assert_matches_type(PolicyListResponse, policy, path=["response"])
+ assert_matches_type(SyncPage[Policy], policy, path=["response"])
@parametrize
def test_method_list_with_all_params(self, client: Asktable) -> None:
policy = client.policies.list(
name="name",
page=1,
- policy_ids=["string", "string", "string"],
+ policy_ids=["string"],
size=1,
)
- assert_matches_type(PolicyListResponse, policy, path=["response"])
+ assert_matches_type(SyncPage[Policy], policy, path=["response"])
@parametrize
def test_raw_response_list(self, client: Asktable) -> None:
@@ -241,7 +241,7 @@ def test_raw_response_list(self, client: Asktable) -> None:
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
policy = response.parse()
- assert_matches_type(PolicyListResponse, policy, path=["response"])
+ assert_matches_type(SyncPage[Policy], policy, path=["response"])
@parametrize
def test_streaming_response_list(self, client: Asktable) -> None:
@@ -250,7 +250,7 @@ def test_streaming_response_list(self, client: Asktable) -> None:
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
policy = response.parse()
- assert_matches_type(PolicyListResponse, policy, path=["response"])
+ assert_matches_type(SyncPage[Policy], policy, path=["response"])
assert cast(Any, response.is_closed) is True
@@ -299,7 +299,7 @@ class TestAsyncPolicies:
@parametrize
async def test_method_create(self, async_client: AsyncAsktable) -> None:
policy = await async_client.policies.create(
- dataset_config={"datasource_ids": ["string", "string", "string"]},
+ dataset_config={"datasource_ids": ["string"]},
name="name",
permission="allow",
)
@@ -309,7 +309,7 @@ async def test_method_create(self, async_client: AsyncAsktable) -> None:
async def test_method_create_with_all_params(self, async_client: AsyncAsktable) -> None:
policy = await async_client.policies.create(
dataset_config={
- "datasource_ids": ["string", "string", "string"],
+ "datasource_ids": ["string"],
"regex_patterns": {
"fields_regex_pattern": ".*password.* | .*pwd.*",
"schemas_regex_pattern": "^public.*$",
@@ -333,7 +333,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncAsktable)
@parametrize
async def test_raw_response_create(self, async_client: AsyncAsktable) -> None:
response = await async_client.policies.with_raw_response.create(
- dataset_config={"datasource_ids": ["string", "string", "string"]},
+ dataset_config={"datasource_ids": ["string"]},
name="name",
permission="allow",
)
@@ -346,7 +346,7 @@ async def test_raw_response_create(self, async_client: AsyncAsktable) -> None:
@parametrize
async def test_streaming_response_create(self, async_client: AsyncAsktable) -> None:
async with async_client.policies.with_streaming_response.create(
- dataset_config={"datasource_ids": ["string", "string", "string"]},
+ dataset_config={"datasource_ids": ["string"]},
name="name",
permission="allow",
) as response:
@@ -408,7 +408,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncAsktable)
policy = await async_client.policies.update(
policy_id="policy_id",
dataset_config={
- "datasource_ids": ["string", "string", "string"],
+ "datasource_ids": ["string"],
"regex_patterns": {
"fields_regex_pattern": ".*password.* | .*pwd.*",
"schemas_regex_pattern": "^public.*$",
@@ -422,7 +422,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncAsktable)
"field_regex": "field_regex",
"operator_expression": "operator_expression",
"table_regex": "table_regex",
- "variables": ["string", "string", "string"],
+ "variables": ["string"],
}
],
"ds_sJAbnNOUzu3R4DdCCOwe": [
@@ -432,7 +432,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncAsktable)
"field_regex": "field_regex",
"operator_expression": "operator_expression",
"table_regex": "table_regex",
- "variables": ["string", "string", "string"],
+ "variables": ["string"],
},
{
"condition": "condition",
@@ -440,7 +440,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncAsktable)
"field_regex": "field_regex",
"operator_expression": "operator_expression",
"table_regex": "table_regex",
- "variables": ["string", "string", "string"],
+ "variables": ["string"],
},
{
"condition": "condition",
@@ -448,7 +448,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncAsktable)
"field_regex": "field_regex",
"operator_expression": "operator_expression",
"table_regex": "table_regex",
- "variables": ["string", "string", "string"],
+ "variables": ["string"],
},
{
"condition": "condition",
@@ -456,7 +456,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncAsktable)
"field_regex": "field_regex",
"operator_expression": "operator_expression",
"table_regex": "table_regex",
- "variables": ["string", "string", "string"],
+ "variables": ["string"],
},
],
},
@@ -500,17 +500,17 @@ async def test_path_params_update(self, async_client: AsyncAsktable) -> None:
@parametrize
async def test_method_list(self, async_client: AsyncAsktable) -> None:
policy = await async_client.policies.list()
- assert_matches_type(PolicyListResponse, policy, path=["response"])
+ assert_matches_type(AsyncPage[Policy], policy, path=["response"])
@parametrize
async def test_method_list_with_all_params(self, async_client: AsyncAsktable) -> None:
policy = await async_client.policies.list(
name="name",
page=1,
- policy_ids=["string", "string", "string"],
+ policy_ids=["string"],
size=1,
)
- assert_matches_type(PolicyListResponse, policy, path=["response"])
+ assert_matches_type(AsyncPage[Policy], policy, path=["response"])
@parametrize
async def test_raw_response_list(self, async_client: AsyncAsktable) -> None:
@@ -519,7 +519,7 @@ async def test_raw_response_list(self, async_client: AsyncAsktable) -> None:
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
policy = await response.parse()
- assert_matches_type(PolicyListResponse, policy, path=["response"])
+ assert_matches_type(AsyncPage[Policy], policy, path=["response"])
@parametrize
async def test_streaming_response_list(self, async_client: AsyncAsktable) -> None:
@@ -528,7 +528,7 @@ async def test_streaming_response_list(self, async_client: AsyncAsktable) -> Non
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
policy = await response.parse()
- assert_matches_type(PolicyListResponse, policy, path=["response"])
+ assert_matches_type(AsyncPage[Policy], policy, path=["response"])
assert cast(Any, response.is_closed) is True
diff --git a/tests/api_resources/test_roles.py b/tests/api_resources/test_roles.py
index 852c8528..b1105c52 100644
--- a/tests/api_resources/test_roles.py
+++ b/tests/api_resources/test_roles.py
@@ -9,7 +9,11 @@
from asktable import Asktable, AsyncAsktable
from tests.utils import assert_matches_type
-from asktable.types import Role, RoleListResponse
+from asktable.types import (
+ Role,
+ RoleGetPolicesResponse,
+)
+from asktable.pagination import SyncPage, AsyncPage
base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
@@ -144,17 +148,17 @@ def test_path_params_update(self, client: Asktable) -> None:
@parametrize
def test_method_list(self, client: Asktable) -> None:
role = client.roles.list()
- assert_matches_type(RoleListResponse, role, path=["response"])
+ assert_matches_type(SyncPage[Role], role, path=["response"])
@parametrize
def test_method_list_with_all_params(self, client: Asktable) -> None:
role = client.roles.list(
name="name",
page=1,
- role_ids=["string", "string", "string"],
+ role_ids=["string"],
size=1,
)
- assert_matches_type(RoleListResponse, role, path=["response"])
+ assert_matches_type(SyncPage[Role], role, path=["response"])
@parametrize
def test_raw_response_list(self, client: Asktable) -> None:
@@ -163,7 +167,7 @@ def test_raw_response_list(self, client: Asktable) -> None:
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
role = response.parse()
- assert_matches_type(RoleListResponse, role, path=["response"])
+ assert_matches_type(SyncPage[Role], role, path=["response"])
@parametrize
def test_streaming_response_list(self, client: Asktable) -> None:
@@ -172,7 +176,7 @@ def test_streaming_response_list(self, client: Asktable) -> None:
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
role = response.parse()
- assert_matches_type(RoleListResponse, role, path=["response"])
+ assert_matches_type(SyncPage[Role], role, path=["response"])
assert cast(Any, response.is_closed) is True
@@ -214,6 +218,91 @@ def test_path_params_delete(self, client: Asktable) -> None:
"",
)
+ @parametrize
+ def test_method_get_polices(self, client: Asktable) -> None:
+ role = client.roles.get_polices(
+ "role_id",
+ )
+ assert_matches_type(RoleGetPolicesResponse, role, path=["response"])
+
+ @parametrize
+ def test_raw_response_get_polices(self, client: Asktable) -> None:
+ response = client.roles.with_raw_response.get_polices(
+ "role_id",
+ )
+
+ assert response.is_closed is True
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+ role = response.parse()
+ assert_matches_type(RoleGetPolicesResponse, role, path=["response"])
+
+ @parametrize
+ def test_streaming_response_get_polices(self, client: Asktable) -> None:
+ with client.roles.with_streaming_response.get_polices(
+ "role_id",
+ ) as response:
+ assert not response.is_closed
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+
+ role = response.parse()
+ assert_matches_type(RoleGetPolicesResponse, role, path=["response"])
+
+ assert cast(Any, response.is_closed) is True
+
+ @parametrize
+ def test_path_params_get_polices(self, client: Asktable) -> None:
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `role_id` but received ''"):
+ client.roles.with_raw_response.get_polices(
+ "",
+ )
+
+ @parametrize
+ def test_method_get_variables(self, client: Asktable) -> None:
+ role = client.roles.get_variables(
+ role_id="role_id",
+ )
+ assert_matches_type(object, role, path=["response"])
+
+ @parametrize
+ def test_method_get_variables_with_all_params(self, client: Asktable) -> None:
+ role = client.roles.get_variables(
+ role_id="role_id",
+ bot_id="bot_id",
+ datasource_ids=["string"],
+ )
+ assert_matches_type(object, role, path=["response"])
+
+ @parametrize
+ def test_raw_response_get_variables(self, client: Asktable) -> None:
+ response = client.roles.with_raw_response.get_variables(
+ role_id="role_id",
+ )
+
+ assert response.is_closed is True
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+ role = response.parse()
+ assert_matches_type(object, role, path=["response"])
+
+ @parametrize
+ def test_streaming_response_get_variables(self, client: Asktable) -> None:
+ with client.roles.with_streaming_response.get_variables(
+ role_id="role_id",
+ ) as response:
+ assert not response.is_closed
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+
+ role = response.parse()
+ assert_matches_type(object, role, path=["response"])
+
+ assert cast(Any, response.is_closed) is True
+
+ @parametrize
+ def test_path_params_get_variables(self, client: Asktable) -> None:
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `role_id` but received ''"):
+ client.roles.with_raw_response.get_variables(
+ role_id="",
+ )
+
class TestAsyncRoles:
parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"])
@@ -345,17 +434,17 @@ async def test_path_params_update(self, async_client: AsyncAsktable) -> None:
@parametrize
async def test_method_list(self, async_client: AsyncAsktable) -> None:
role = await async_client.roles.list()
- assert_matches_type(RoleListResponse, role, path=["response"])
+ assert_matches_type(AsyncPage[Role], role, path=["response"])
@parametrize
async def test_method_list_with_all_params(self, async_client: AsyncAsktable) -> None:
role = await async_client.roles.list(
name="name",
page=1,
- role_ids=["string", "string", "string"],
+ role_ids=["string"],
size=1,
)
- assert_matches_type(RoleListResponse, role, path=["response"])
+ assert_matches_type(AsyncPage[Role], role, path=["response"])
@parametrize
async def test_raw_response_list(self, async_client: AsyncAsktable) -> None:
@@ -364,7 +453,7 @@ async def test_raw_response_list(self, async_client: AsyncAsktable) -> None:
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
role = await response.parse()
- assert_matches_type(RoleListResponse, role, path=["response"])
+ assert_matches_type(AsyncPage[Role], role, path=["response"])
@parametrize
async def test_streaming_response_list(self, async_client: AsyncAsktable) -> None:
@@ -373,7 +462,7 @@ async def test_streaming_response_list(self, async_client: AsyncAsktable) -> Non
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
role = await response.parse()
- assert_matches_type(RoleListResponse, role, path=["response"])
+ assert_matches_type(AsyncPage[Role], role, path=["response"])
assert cast(Any, response.is_closed) is True
@@ -414,3 +503,88 @@ async def test_path_params_delete(self, async_client: AsyncAsktable) -> None:
await async_client.roles.with_raw_response.delete(
"",
)
+
+ @parametrize
+ async def test_method_get_polices(self, async_client: AsyncAsktable) -> None:
+ role = await async_client.roles.get_polices(
+ "role_id",
+ )
+ assert_matches_type(RoleGetPolicesResponse, role, path=["response"])
+
+ @parametrize
+ async def test_raw_response_get_polices(self, async_client: AsyncAsktable) -> None:
+ response = await async_client.roles.with_raw_response.get_polices(
+ "role_id",
+ )
+
+ assert response.is_closed is True
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+ role = await response.parse()
+ assert_matches_type(RoleGetPolicesResponse, role, path=["response"])
+
+ @parametrize
+ async def test_streaming_response_get_polices(self, async_client: AsyncAsktable) -> None:
+ async with async_client.roles.with_streaming_response.get_polices(
+ "role_id",
+ ) as response:
+ assert not response.is_closed
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+
+ role = await response.parse()
+ assert_matches_type(RoleGetPolicesResponse, role, path=["response"])
+
+ assert cast(Any, response.is_closed) is True
+
+ @parametrize
+ async def test_path_params_get_polices(self, async_client: AsyncAsktable) -> None:
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `role_id` but received ''"):
+ await async_client.roles.with_raw_response.get_polices(
+ "",
+ )
+
+ @parametrize
+ async def test_method_get_variables(self, async_client: AsyncAsktable) -> None:
+ role = await async_client.roles.get_variables(
+ role_id="role_id",
+ )
+ assert_matches_type(object, role, path=["response"])
+
+ @parametrize
+ async def test_method_get_variables_with_all_params(self, async_client: AsyncAsktable) -> None:
+ role = await async_client.roles.get_variables(
+ role_id="role_id",
+ bot_id="bot_id",
+ datasource_ids=["string"],
+ )
+ assert_matches_type(object, role, path=["response"])
+
+ @parametrize
+ async def test_raw_response_get_variables(self, async_client: AsyncAsktable) -> None:
+ response = await async_client.roles.with_raw_response.get_variables(
+ role_id="role_id",
+ )
+
+ assert response.is_closed is True
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+ role = await response.parse()
+ assert_matches_type(object, role, path=["response"])
+
+ @parametrize
+ async def test_streaming_response_get_variables(self, async_client: AsyncAsktable) -> None:
+ async with async_client.roles.with_streaming_response.get_variables(
+ role_id="role_id",
+ ) as response:
+ assert not response.is_closed
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+
+ role = await response.parse()
+ assert_matches_type(object, role, path=["response"])
+
+ assert cast(Any, response.is_closed) is True
+
+ @parametrize
+ async def test_path_params_get_variables(self, async_client: AsyncAsktable) -> None:
+ with pytest.raises(ValueError, match=r"Expected a non-empty value for `role_id` but received ''"):
+ await async_client.roles.with_raw_response.get_variables(
+ role_id="",
+ )
diff --git a/tests/api_resources/test_securetunnels.py b/tests/api_resources/test_securetunnels.py
index e16aaf1d..896233fb 100644
--- a/tests/api_resources/test_securetunnels.py
+++ b/tests/api_resources/test_securetunnels.py
@@ -11,8 +11,9 @@
from tests.utils import assert_matches_type
from asktable.types import (
SecureTunnel,
- SecuretunnelListResponse,
+ SecuretunnelListLinksResponse,
)
+from asktable.pagination import SyncPage, AsyncPage
base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
@@ -95,7 +96,7 @@ def test_method_update(self, client: Asktable) -> None:
securetunnel = client.securetunnels.update(
securetunnel_id="securetunnel_id",
)
- assert_matches_type(object, securetunnel, path=["response"])
+ assert_matches_type(SecureTunnel, securetunnel, path=["response"])
@parametrize
def test_method_update_with_all_params(self, client: Asktable) -> None:
@@ -105,7 +106,7 @@ def test_method_update_with_all_params(self, client: Asktable) -> None:
name="我的测试机",
unique_key="unique_key",
)
- assert_matches_type(object, securetunnel, path=["response"])
+ assert_matches_type(SecureTunnel, securetunnel, path=["response"])
@parametrize
def test_raw_response_update(self, client: Asktable) -> None:
@@ -116,7 +117,7 @@ def test_raw_response_update(self, client: Asktable) -> None:
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
securetunnel = response.parse()
- assert_matches_type(object, securetunnel, path=["response"])
+ assert_matches_type(SecureTunnel, securetunnel, path=["response"])
@parametrize
def test_streaming_response_update(self, client: Asktable) -> None:
@@ -127,7 +128,7 @@ def test_streaming_response_update(self, client: Asktable) -> None:
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
securetunnel = response.parse()
- assert_matches_type(object, securetunnel, path=["response"])
+ assert_matches_type(SecureTunnel, securetunnel, path=["response"])
assert cast(Any, response.is_closed) is True
@@ -141,7 +142,7 @@ def test_path_params_update(self, client: Asktable) -> None:
@parametrize
def test_method_list(self, client: Asktable) -> None:
securetunnel = client.securetunnels.list()
- assert_matches_type(SecuretunnelListResponse, securetunnel, path=["response"])
+ assert_matches_type(SyncPage[SecureTunnel], securetunnel, path=["response"])
@parametrize
def test_method_list_with_all_params(self, client: Asktable) -> None:
@@ -149,7 +150,7 @@ def test_method_list_with_all_params(self, client: Asktable) -> None:
page=1,
size=1,
)
- assert_matches_type(SecuretunnelListResponse, securetunnel, path=["response"])
+ assert_matches_type(SyncPage[SecureTunnel], securetunnel, path=["response"])
@parametrize
def test_raw_response_list(self, client: Asktable) -> None:
@@ -158,7 +159,7 @@ def test_raw_response_list(self, client: Asktable) -> None:
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
securetunnel = response.parse()
- assert_matches_type(SecuretunnelListResponse, securetunnel, path=["response"])
+ assert_matches_type(SyncPage[SecureTunnel], securetunnel, path=["response"])
@parametrize
def test_streaming_response_list(self, client: Asktable) -> None:
@@ -167,7 +168,7 @@ def test_streaming_response_list(self, client: Asktable) -> None:
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
securetunnel = response.parse()
- assert_matches_type(SecuretunnelListResponse, securetunnel, path=["response"])
+ assert_matches_type(SyncPage[SecureTunnel], securetunnel, path=["response"])
assert cast(Any, response.is_closed) is True
@@ -209,6 +210,53 @@ def test_path_params_delete(self, client: Asktable) -> None:
"",
)
+ @parametrize
+ def test_method_list_links(self, client: Asktable) -> None:
+ securetunnel = client.securetunnels.list_links(
+ securetunnel_id="securetunnel_id",
+ )
+ assert_matches_type(SyncPage[SecuretunnelListLinksResponse], securetunnel, path=["response"])
+
+ @parametrize
+ def test_method_list_links_with_all_params(self, client: Asktable) -> None:
+ securetunnel = client.securetunnels.list_links(
+ securetunnel_id="securetunnel_id",
+ page=1,
+ size=1,
+ )
+ assert_matches_type(SyncPage[SecuretunnelListLinksResponse], securetunnel, path=["response"])
+
+ @parametrize
+ def test_raw_response_list_links(self, client: Asktable) -> None:
+ response = client.securetunnels.with_raw_response.list_links(
+ securetunnel_id="securetunnel_id",
+ )
+
+ assert response.is_closed is True
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+ securetunnel = response.parse()
+ assert_matches_type(SyncPage[SecuretunnelListLinksResponse], securetunnel, path=["response"])
+
+ @parametrize
+ def test_streaming_response_list_links(self, client: Asktable) -> None:
+ with client.securetunnels.with_streaming_response.list_links(
+ securetunnel_id="securetunnel_id",
+ ) as response:
+ assert not response.is_closed
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+
+ securetunnel = response.parse()
+ assert_matches_type(SyncPage[SecuretunnelListLinksResponse], securetunnel, path=["response"])
+
+ assert cast(Any, response.is_closed) is True
+
+ @parametrize
+ def test_path_params_list_links(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.list_links(
+ securetunnel_id="",
+ )
+
class TestAsyncSecuretunnels:
parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"])
@@ -288,7 +336,7 @@ async def test_method_update(self, async_client: AsyncAsktable) -> None:
securetunnel = await async_client.securetunnels.update(
securetunnel_id="securetunnel_id",
)
- assert_matches_type(object, securetunnel, path=["response"])
+ assert_matches_type(SecureTunnel, securetunnel, path=["response"])
@parametrize
async def test_method_update_with_all_params(self, async_client: AsyncAsktable) -> None:
@@ -298,7 +346,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncAsktable)
name="我的测试机",
unique_key="unique_key",
)
- assert_matches_type(object, securetunnel, path=["response"])
+ assert_matches_type(SecureTunnel, securetunnel, path=["response"])
@parametrize
async def test_raw_response_update(self, async_client: AsyncAsktable) -> None:
@@ -309,7 +357,7 @@ async def test_raw_response_update(self, async_client: AsyncAsktable) -> None:
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
securetunnel = await response.parse()
- assert_matches_type(object, securetunnel, path=["response"])
+ assert_matches_type(SecureTunnel, securetunnel, path=["response"])
@parametrize
async def test_streaming_response_update(self, async_client: AsyncAsktable) -> None:
@@ -320,7 +368,7 @@ async def test_streaming_response_update(self, async_client: AsyncAsktable) -> N
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
securetunnel = await response.parse()
- assert_matches_type(object, securetunnel, path=["response"])
+ assert_matches_type(SecureTunnel, securetunnel, path=["response"])
assert cast(Any, response.is_closed) is True
@@ -334,7 +382,7 @@ async def test_path_params_update(self, async_client: AsyncAsktable) -> None:
@parametrize
async def test_method_list(self, async_client: AsyncAsktable) -> None:
securetunnel = await async_client.securetunnels.list()
- assert_matches_type(SecuretunnelListResponse, securetunnel, path=["response"])
+ assert_matches_type(AsyncPage[SecureTunnel], securetunnel, path=["response"])
@parametrize
async def test_method_list_with_all_params(self, async_client: AsyncAsktable) -> None:
@@ -342,7 +390,7 @@ async def test_method_list_with_all_params(self, async_client: AsyncAsktable) ->
page=1,
size=1,
)
- assert_matches_type(SecuretunnelListResponse, securetunnel, path=["response"])
+ assert_matches_type(AsyncPage[SecureTunnel], securetunnel, path=["response"])
@parametrize
async def test_raw_response_list(self, async_client: AsyncAsktable) -> None:
@@ -351,7 +399,7 @@ async def test_raw_response_list(self, async_client: AsyncAsktable) -> None:
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
securetunnel = await response.parse()
- assert_matches_type(SecuretunnelListResponse, securetunnel, path=["response"])
+ assert_matches_type(AsyncPage[SecureTunnel], securetunnel, path=["response"])
@parametrize
async def test_streaming_response_list(self, async_client: AsyncAsktable) -> None:
@@ -360,7 +408,7 @@ async def test_streaming_response_list(self, async_client: AsyncAsktable) -> Non
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
securetunnel = await response.parse()
- assert_matches_type(SecuretunnelListResponse, securetunnel, path=["response"])
+ assert_matches_type(AsyncPage[SecureTunnel], securetunnel, path=["response"])
assert cast(Any, response.is_closed) is True
@@ -401,3 +449,50 @@ async def test_path_params_delete(self, async_client: AsyncAsktable) -> None:
await async_client.securetunnels.with_raw_response.delete(
"",
)
+
+ @parametrize
+ async def test_method_list_links(self, async_client: AsyncAsktable) -> None:
+ securetunnel = await async_client.securetunnels.list_links(
+ securetunnel_id="securetunnel_id",
+ )
+ assert_matches_type(AsyncPage[SecuretunnelListLinksResponse], securetunnel, path=["response"])
+
+ @parametrize
+ async def test_method_list_links_with_all_params(self, async_client: AsyncAsktable) -> None:
+ securetunnel = await async_client.securetunnels.list_links(
+ securetunnel_id="securetunnel_id",
+ page=1,
+ size=1,
+ )
+ assert_matches_type(AsyncPage[SecuretunnelListLinksResponse], securetunnel, path=["response"])
+
+ @parametrize
+ async def test_raw_response_list_links(self, async_client: AsyncAsktable) -> None:
+ response = await async_client.securetunnels.with_raw_response.list_links(
+ securetunnel_id="securetunnel_id",
+ )
+
+ assert response.is_closed is True
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+ securetunnel = await response.parse()
+ assert_matches_type(AsyncPage[SecuretunnelListLinksResponse], securetunnel, path=["response"])
+
+ @parametrize
+ async def test_streaming_response_list_links(self, async_client: AsyncAsktable) -> None:
+ async with async_client.securetunnels.with_streaming_response.list_links(
+ securetunnel_id="securetunnel_id",
+ ) as response:
+ assert not response.is_closed
+ assert response.http_request.headers.get("X-Stainless-Lang") == "python"
+
+ securetunnel = await response.parse()
+ assert_matches_type(AsyncPage[SecuretunnelListLinksResponse], securetunnel, path=["response"])
+
+ assert cast(Any, response.is_closed) is True
+
+ @parametrize
+ async def test_path_params_list_links(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.list_links(
+ securetunnel_id="",
+ )
diff --git a/tests/test_client.py b/tests/test_client.py
index 7bbaa500..75ea423f 100644
--- a/tests/test_client.py
+++ b/tests/test_client.py
@@ -4,11 +4,14 @@
import gc
import os
+import sys
import json
import asyncio
import inspect
+import subprocess
import tracemalloc
from typing import Any, Union, cast
+from textwrap import dedent
from unittest import mock
from typing_extensions import Literal
@@ -1578,3 +1581,38 @@ def retry_handler(_request: httpx.Request) -> httpx.Response:
)
assert response.http_request.headers.get("x-stainless-retry-count") == "42"
+
+ def test_get_platform(self) -> None:
+ # A previous implementation of asyncify could leave threads unterminated when
+ # used with nest_asyncio.
+ #
+ # Since nest_asyncio.apply() is global and cannot be un-applied, this
+ # test is run in a separate process to avoid affecting other tests.
+ test_code = dedent("""
+ import asyncio
+ import nest_asyncio
+ import threading
+
+ from asktable._utils import asyncify
+ from asktable._base_client import get_platform
+
+ async def test_main() -> None:
+ result = await asyncify(get_platform)()
+ print(result)
+ for thread in threading.enumerate():
+ print(thread.name)
+
+ nest_asyncio.apply()
+ asyncio.run(test_main())
+ """)
+ with subprocess.Popen(
+ [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