Skip to content

Commit 6d705b0

Browse files
feat(api): api update
1 parent 783819b commit 6d705b0

File tree

75 files changed

+346
-277
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+346
-277
lines changed

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 105
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/datamini%2Fasktable-62931b1d6bd2cf04f9887c2779e09de89d43cf8ea9323dbbe36b52e5fad4472f.yml
3-
openapi_spec_hash: a4508a681714884c7d56077656fef3c4
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/datamini%2Fasktable-9b3127f357a8502fba6b108515b97e5acb04e50cb2f933c654c05532b6a5ab19.yml
3+
openapi_spec_hash: aa447a038dd69ccbad1eadad7204d5ad
44
config_hash: acdf4142177ed1932c2d82372693f811

README.md

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -191,24 +191,6 @@ response = client.sys.projects.api_keys.create_token(
191191
print(response.chat_role)
192192
```
193193

194-
## File uploads
195-
196-
Request parameters that correspond to file uploads can be passed as `bytes`, or a [`PathLike`](https://docs.python.org/3/library/os.html#os.PathLike) instance or a tuple of `(filename, contents, media type)`.
197-
198-
```python
199-
from pathlib import Path
200-
from asktable import Asktable
201-
202-
client = Asktable()
203-
204-
client.datasources.add_file(
205-
datasource_id="datasource_id",
206-
file=Path("/path/to/file"),
207-
)
208-
```
209-
210-
The async client uses the exact same interface. If you pass a [`PathLike`](https://docs.python.org/3/library/os.html#os.PathLike) instance, the file contents will be read asynchronously automatically.
211-
212194
## Handling errors
213195

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

api.md

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,13 @@ from asktable.types import Policy
1111
Types:
1212

1313
```python
14-
from asktable.types.sys import APIKey, Project, ProjectModelGroupsResponse
14+
from asktable.types.sys import (
15+
APIKey,
16+
Project,
17+
ProjectExportResponse,
18+
ProjectImportResponse,
19+
ProjectModelGroupsResponse,
20+
)
1521
```
1622

1723
Methods:
@@ -21,24 +27,28 @@ Methods:
2127
- <code title="patch /v1/sys/projects/{project_id}">client.sys.projects.<a href="./src/asktable/resources/sys/projects/projects.py">update</a>(project_id, \*\*<a href="src/asktable/types/sys/project_update_params.py">params</a>) -> <a href="./src/asktable/types/sys/project.py">Project</a></code>
2228
- <code title="get /v1/sys/projects">client.sys.projects.<a href="./src/asktable/resources/sys/projects/projects.py">list</a>(\*\*<a href="src/asktable/types/sys/project_list_params.py">params</a>) -> <a href="./src/asktable/types/sys/project.py">SyncPage[Project]</a></code>
2329
- <code title="delete /v1/sys/projects/{project_id}">client.sys.projects.<a href="./src/asktable/resources/sys/projects/projects.py">delete</a>(project_id) -> object</code>
24-
- <code title="post /v1/sys/projects/{project_id}/export">client.sys.projects.<a href="./src/asktable/resources/sys/projects/projects.py">export</a>(project_id) -> object</code>
25-
- <code title="post /v1/sys/projects/import">client.sys.projects.<a href="./src/asktable/resources/sys/projects/projects.py">import\_</a>(\*\*<a href="src/asktable/types/sys/project_import_params.py">params</a>) -> object</code>
30+
- <code title="post /v1/sys/projects/{project_id}/export">client.sys.projects.<a href="./src/asktable/resources/sys/projects/projects.py">export</a>(project_id) -> <a href="./src/asktable/types/sys/project_export_response.py">ProjectExportResponse</a></code>
31+
- <code title="post /v1/sys/projects/import">client.sys.projects.<a href="./src/asktable/resources/sys/projects/projects.py">import\_</a>(\*\*<a href="src/asktable/types/sys/project_import_params.py">params</a>) -> <a href="./src/asktable/types/sys/project_import_response.py">ProjectImportResponse</a></code>
2632
- <code title="get /v1/sys/projects/model-groups">client.sys.projects.<a href="./src/asktable/resources/sys/projects/projects.py">model_groups</a>() -> <a href="./src/asktable/types/sys/project_model_groups_response.py">ProjectModelGroupsResponse</a></code>
2733

2834
### APIKeys
2935

3036
Types:
3137

3238
```python
33-
from asktable.types.sys.projects import APIKeyCreateResponse, APIKeyListResponse
39+
from asktable.types.sys.projects import (
40+
APIKeyCreateResponse,
41+
APIKeyListResponse,
42+
APIKeyCreateTokenResponse,
43+
)
3444
```
3545

3646
Methods:
3747

3848
- <code title="post /v1/sys/projects/{project_id}/api-keys">client.sys.projects.api_keys.<a href="./src/asktable/resources/sys/projects/api_keys.py">create</a>(project_id, \*\*<a href="src/asktable/types/sys/projects/api_key_create_params.py">params</a>) -> <a href="./src/asktable/types/sys/projects/api_key_create_response.py">APIKeyCreateResponse</a></code>
3949
- <code title="get /v1/sys/projects/{project_id}/api-keys">client.sys.projects.api_keys.<a href="./src/asktable/resources/sys/projects/api_keys.py">list</a>(project_id) -> <a href="./src/asktable/types/sys/projects/api_key_list_response.py">APIKeyListResponse</a></code>
4050
- <code title="delete /v1/sys/projects/{project_id}/api-keys/{key_id}">client.sys.projects.api_keys.<a href="./src/asktable/resources/sys/projects/api_keys.py">delete</a>(key_id, \*, project_id) -> None</code>
41-
- <code title="post /v1/sys/projects/{project_id}/tokens">client.sys.projects.api_keys.<a href="./src/asktable/resources/sys/projects/api_keys.py">create_token</a>(project_id, \*\*<a href="src/asktable/types/sys/projects/api_key_create_token_params.py">params</a>) -> object</code>
51+
- <code title="post /v1/sys/projects/{project_id}/tokens">client.sys.projects.api_keys.<a href="./src/asktable/resources/sys/projects/api_keys.py">create_token</a>(project_id, \*\*<a href="src/asktable/types/sys/projects/api_key_create_token_params.py">params</a>) -> <a href="./src/asktable/types/sys/projects/api_key_create_token_response.py">APIKeyCreateTokenResponse</a></code>
4252

4353
# Securetunnels
4454

@@ -62,7 +72,7 @@ Methods:
6272
Types:
6373

6474
```python
65-
from asktable.types import Role, RoleGetPolicesResponse
75+
from asktable.types import Role, RoleGetPolicesResponse, RoleGetVariablesResponse
6676
```
6777

6878
Methods:
@@ -73,7 +83,7 @@ Methods:
7383
- <code title="get /v1/roles">client.roles.<a href="./src/asktable/resources/roles.py">list</a>(\*\*<a href="src/asktable/types/role_list_params.py">params</a>) -> <a href="./src/asktable/types/role.py">SyncPage[Role]</a></code>
7484
- <code title="delete /v1/roles/{role_id}">client.roles.<a href="./src/asktable/resources/roles.py">delete</a>(role_id) -> object</code>
7585
- <code title="get /v1/roles/{role_id}/policies">client.roles.<a href="./src/asktable/resources/roles.py">get_polices</a>(role_id) -> <a href="./src/asktable/types/role_get_polices_response.py">RoleGetPolicesResponse</a></code>
76-
- <code title="get /v1/roles/{role_id}/variables">client.roles.<a href="./src/asktable/resources/roles.py">get_variables</a>(role_id, \*\*<a href="src/asktable/types/role_get_variables_params.py">params</a>) -> object</code>
86+
- <code title="get /v1/roles/{role_id}/variables">client.roles.<a href="./src/asktable/resources/roles.py">get_variables</a>(role_id, \*\*<a href="src/asktable/types/role_get_variables_params.py">params</a>) -> <a href="./src/asktable/types/role_get_variables_response.py">RoleGetVariablesResponse</a></code>
7787

7888
# Policies
7989

@@ -158,9 +168,15 @@ Methods:
158168

159169
## UploadParams
160170

171+
Types:
172+
173+
```python
174+
from asktable.types.datasources import UploadParamCreateResponse
175+
```
176+
161177
Methods:
162178

163-
- <code title="post /v1/datasources/upload_params">client.datasources.upload_params.<a href="./src/asktable/resources/datasources/upload_params.py">create</a>(\*\*<a href="src/asktable/types/datasources/upload_param_create_params.py">params</a>) -> object</code>
179+
- <code title="post /v1/datasources/upload_params">client.datasources.upload_params.<a href="./src/asktable/resources/datasources/upload_params.py">create</a>(\*\*<a href="src/asktable/types/datasources/upload_param_create_params.py">params</a>) -> <a href="./src/asktable/types/datasources/upload_param_create_response.py">UploadParamCreateResponse</a></code>
164180

165181
## Indexes
166182

@@ -175,7 +191,7 @@ Methods:
175191
Types:
176192

177193
```python
178-
from asktable.types import Chatbot
194+
from asktable.types import Chatbot, BotInviteResponse
179195
```
180196

181197
Methods:
@@ -185,19 +201,19 @@ Methods:
185201
- <code title="patch /v1/bots/{bot_id}">client.bots.<a href="./src/asktable/resources/bots.py">update</a>(bot_id, \*\*<a href="src/asktable/types/bot_update_params.py">params</a>) -> <a href="./src/asktable/types/chatbot.py">Chatbot</a></code>
186202
- <code title="get /v1/bots">client.bots.<a href="./src/asktable/resources/bots.py">list</a>(\*\*<a href="src/asktable/types/bot_list_params.py">params</a>) -> <a href="./src/asktable/types/chatbot.py">SyncPage[Chatbot]</a></code>
187203
- <code title="delete /v1/bots/{bot_id}">client.bots.<a href="./src/asktable/resources/bots.py">delete</a>(bot_id) -> object</code>
188-
- <code title="post /v1/bots/{bot_id}/invite">client.bots.<a href="./src/asktable/resources/bots.py">invite</a>(bot_id, \*\*<a href="src/asktable/types/bot_invite_params.py">params</a>) -> object</code>
204+
- <code title="post /v1/bots/{bot_id}/invite">client.bots.<a href="./src/asktable/resources/bots.py">invite</a>(bot_id, \*\*<a href="src/asktable/types/bot_invite_params.py">params</a>) -> <a href="./src/asktable/types/bot_invite_response.py">BotInviteResponse</a></code>
189205

190206
# Auth
191207

192208
Types:
193209

194210
```python
195-
from asktable.types import AuthMeResponse
211+
from asktable.types import AuthCreateTokenResponse, AuthMeResponse
196212
```
197213

198214
Methods:
199215

200-
- <code title="post /v1/auth/tokens">client.auth.<a href="./src/asktable/resources/auth.py">create_token</a>(\*\*<a href="src/asktable/types/auth_create_token_params.py">params</a>) -> object</code>
216+
- <code title="post /v1/auth/tokens">client.auth.<a href="./src/asktable/resources/auth.py">create_token</a>(\*\*<a href="src/asktable/types/auth_create_token_params.py">params</a>) -> <a href="./src/asktable/types/auth_create_token_response.py">AuthCreateTokenResponse</a></code>
201217
- <code title="get /v1/auth/me">client.auth.<a href="./src/asktable/resources/auth.py">me</a>() -> <a href="./src/asktable/types/auth_me_response.py">AuthMeResponse</a></code>
202218

203219
# Answers

src/asktable/_files.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def assert_is_file_content(obj: object, *, key: str | None = None) -> None:
3434
if not is_file_content(obj):
3535
prefix = f"Expected entry at `{key}`" if key is not None else f"Expected file input `{obj!r}`"
3636
raise RuntimeError(
37-
f"{prefix} to be bytes, an io.IOBase instance, PathLike or a tuple but received {type(obj)} instead. See https://github.com/DataMini/asktable-python/tree/main#file-uploads"
37+
f"{prefix} to be bytes, an io.IOBase instance, PathLike or a tuple but received {type(obj)} instead."
3838
) from None
3939

4040

src/asktable/resources/answers.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from __future__ import annotations
44

5-
from typing import Optional
5+
from typing import Dict, Optional
66

77
import httpx
88

@@ -53,7 +53,7 @@ def create(
5353
question: str,
5454
max_rows: Optional[int] | Omit = omit,
5555
role_id: Optional[str] | Omit = omit,
56-
role_variables: Optional[object] | Omit = omit,
56+
role_variables: Optional[Dict[str, object]] | Omit = omit,
5757
with_json: Optional[bool] | Omit = omit,
5858
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
5959
# The extra values given here take precedence over values defined on the client or passed to this method.
@@ -187,7 +187,7 @@ async def create(
187187
question: str,
188188
max_rows: Optional[int] | Omit = omit,
189189
role_id: Optional[str] | Omit = omit,
190-
role_variables: Optional[object] | Omit = omit,
190+
role_variables: Optional[Dict[str, object]] | Omit = omit,
191191
with_json: Optional[bool] | Omit = omit,
192192
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
193193
# The extra values given here take precedence over values defined on the client or passed to this method.

src/asktable/resources/ats/test_case.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from __future__ import annotations
44

5-
from typing import Optional
5+
from typing import Dict, Optional
66

77
import httpx
88

@@ -57,7 +57,7 @@ def create(
5757
expected_sql: str,
5858
question: str,
5959
role_id: Optional[str] | Omit = omit,
60-
role_variables: Optional[object] | Omit = omit,
60+
role_variables: Optional[Dict[str, object]] | Omit = omit,
6161
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
6262
# The extra values given here take precedence over values defined on the client or passed to this method.
6363
extra_headers: Headers | None = None,
@@ -148,7 +148,7 @@ def update(
148148
expected_sql: str,
149149
question: str,
150150
role_id: Optional[str] | Omit = omit,
151-
role_variables: Optional[object] | Omit = omit,
151+
role_variables: Optional[Dict[str, object]] | Omit = omit,
152152
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
153153
# The extra values given here take precedence over values defined on the client or passed to this method.
154154
extra_headers: Headers | None = None,
@@ -313,7 +313,7 @@ async def create(
313313
expected_sql: str,
314314
question: str,
315315
role_id: Optional[str] | Omit = omit,
316-
role_variables: Optional[object] | Omit = omit,
316+
role_variables: Optional[Dict[str, object]] | Omit = omit,
317317
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
318318
# The extra values given here take precedence over values defined on the client or passed to this method.
319319
extra_headers: Headers | None = None,
@@ -404,7 +404,7 @@ async def update(
404404
expected_sql: str,
405405
question: str,
406406
role_id: Optional[str] | Omit = omit,
407-
role_variables: Optional[object] | Omit = omit,
407+
role_variables: Optional[Dict[str, object]] | Omit = omit,
408408
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
409409
# The extra values given here take precedence over values defined on the client or passed to this method.
410410
extra_headers: Headers | None = None,

src/asktable/resources/auth.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from __future__ import annotations
44

5-
from typing import Optional
5+
from typing import Dict, Optional
66
from typing_extensions import Literal
77

88
import httpx
@@ -20,6 +20,7 @@
2020
)
2121
from .._base_client import make_request_options
2222
from ..types.auth_me_response import AuthMeResponse
23+
from ..types.auth_create_token_response import AuthCreateTokenResponse
2324

2425
__all__ = ["AuthResource", "AsyncAuthResource"]
2526

@@ -52,14 +53,14 @@ def create_token(
5253
ak_role: Literal["sys", "admin", "asker", "visitor"] | Omit = omit,
5354
chat_role: Optional[auth_create_token_params.ChatRole] | Omit = omit,
5455
token_ttl: int | Omit = omit,
55-
user_profile: Optional[object] | Omit = omit,
56+
user_profile: Optional[Dict[str, object]] | Omit = omit,
5657
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
5758
# The extra values given here take precedence over values defined on the client or passed to this method.
5859
extra_headers: Headers | None = None,
5960
extra_query: Query | None = None,
6061
extra_body: Body | None = None,
6162
timeout: float | httpx.Timeout | None | NotGiven = not_given,
62-
) -> object:
63+
) -> AuthCreateTokenResponse:
6364
"""
6465
Create Token
6566
@@ -94,7 +95,7 @@ def create_token(
9495
options=make_request_options(
9596
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
9697
),
97-
cast_to=object,
98+
cast_to=AuthCreateTokenResponse,
9899
)
99100

100101
def me(
@@ -145,14 +146,14 @@ async def create_token(
145146
ak_role: Literal["sys", "admin", "asker", "visitor"] | Omit = omit,
146147
chat_role: Optional[auth_create_token_params.ChatRole] | Omit = omit,
147148
token_ttl: int | Omit = omit,
148-
user_profile: Optional[object] | Omit = omit,
149+
user_profile: Optional[Dict[str, object]] | Omit = omit,
149150
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
150151
# The extra values given here take precedence over values defined on the client or passed to this method.
151152
extra_headers: Headers | None = None,
152153
extra_query: Query | None = None,
153154
extra_body: Body | None = None,
154155
timeout: float | httpx.Timeout | None | NotGiven = not_given,
155-
) -> object:
156+
) -> AuthCreateTokenResponse:
156157
"""
157158
Create Token
158159
@@ -187,7 +188,7 @@ async def create_token(
187188
options=make_request_options(
188189
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
189190
),
190-
cast_to=object,
191+
cast_to=AuthCreateTokenResponse,
191192
)
192193

193194
async def me(

src/asktable/resources/bots.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
from ..pagination import SyncPage, AsyncPage
2121
from .._base_client import AsyncPaginator, make_request_options
2222
from ..types.chatbot import Chatbot
23+
from ..types.bot_invite_response import BotInviteResponse
2324

2425
__all__ = ["BotsResource", "AsyncBotsResource"]
2526

@@ -351,7 +352,7 @@ def invite(
351352
extra_query: Query | None = None,
352353
extra_body: Body | None = None,
353354
timeout: float | httpx.Timeout | None | NotGiven = not_given,
354-
) -> object:
355+
) -> BotInviteResponse:
355356
"""
356357
邀请用户加入对话
357358
@@ -375,7 +376,7 @@ def invite(
375376
timeout=timeout,
376377
query=maybe_transform({"project_id": project_id}, bot_invite_params.BotInviteParams),
377378
),
378-
cast_to=object,
379+
cast_to=BotInviteResponse,
379380
)
380381

381382

@@ -706,7 +707,7 @@ async def invite(
706707
extra_query: Query | None = None,
707708
extra_body: Body | None = None,
708709
timeout: float | httpx.Timeout | None | NotGiven = not_given,
709-
) -> object:
710+
) -> BotInviteResponse:
710711
"""
711712
邀请用户加入对话
712713
@@ -730,7 +731,7 @@ async def invite(
730731
timeout=timeout,
731732
query=await async_maybe_transform({"project_id": project_id}, bot_invite_params.BotInviteParams),
732733
),
733-
cast_to=object,
734+
cast_to=BotInviteResponse,
734735
)
735736

736737

src/asktable/resources/business_glossary.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from __future__ import annotations
44

5-
from typing import Iterable, Optional
5+
from typing import Dict, Iterable, Optional
66

77
import httpx
88

@@ -120,7 +120,7 @@ def update(
120120
active: Optional[bool] | Omit = omit,
121121
aliases: Optional[SequenceNotStr[str]] | Omit = omit,
122122
definition: Optional[str] | Omit = omit,
123-
payload: Optional[object] | Omit = omit,
123+
payload: Optional[Dict[str, object]] | Omit = omit,
124124
term: Optional[str] | Omit = omit,
125125
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
126126
# The extra values given here take precedence over values defined on the client or passed to this method.
@@ -350,7 +350,7 @@ async def update(
350350
active: Optional[bool] | Omit = omit,
351351
aliases: Optional[SequenceNotStr[str]] | Omit = omit,
352352
definition: Optional[str] | Omit = omit,
353-
payload: Optional[object] | Omit = omit,
353+
payload: Optional[Dict[str, object]] | Omit = omit,
354354
term: Optional[str] | Omit = omit,
355355
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
356356
# The extra values given here take precedence over values defined on the client or passed to this method.

0 commit comments

Comments
 (0)