Skip to content

Commit c703e2b

Browse files
committed
feat(api): update via SDK Studio
1 parent 41d3520 commit c703e2b

File tree

95 files changed

+5306
-731
lines changed

Some content is hidden

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

95 files changed

+5306
-731
lines changed

.stats.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
configured_endpoints: 51
1+
configured_endpoints: 67
22
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/datamini%2Fasktable-24a3d3655d208471c6d4a8716cb358eb6f6ed3c317428e9ca4d359b79a6c0e36.yml

README.md

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,17 @@ from asktable import Asktable
3131

3232
client = Asktable()
3333

34-
project_model = client.sys.projects.retrieve(
35-
"project_id",
34+
project = client.sys.projects.create(
35+
name="name",
3636
)
37-
print(project_model.id)
37+
print(project.id)
3838
```
3939

40+
While you can provide a `bearer_token` keyword argument,
41+
we recommend using [python-dotenv](https://pypi.org/project/python-dotenv/)
42+
to add `ASKTABLE_BEARER_TOKEN="My Bearer Token"` to your `.env` file
43+
so that your Bearer Token is not stored in source control.
44+
4045
## Async usage
4146

4247
Simply import `AsyncAsktable` instead of `Asktable` and use `await` with each API call:
@@ -49,10 +54,10 @@ client = AsyncAsktable()
4954

5055

5156
async def main() -> None:
52-
project_model = await client.sys.projects.retrieve(
53-
"project_id",
57+
project = await client.sys.projects.create(
58+
name="name",
5459
)
55-
print(project_model.id)
60+
print(project.id)
5661

5762

5863
asyncio.run(main())
@@ -85,8 +90,8 @@ from asktable import Asktable
8590
client = Asktable()
8691

8792
try:
88-
client.sys.projects.retrieve(
89-
"project_id",
93+
client.sys.projects.create(
94+
name="name",
9095
)
9196
except asktable.APIConnectionError as e:
9297
print("The server could not be reached")
@@ -130,8 +135,8 @@ client = Asktable(
130135
)
131136

132137
# Or, configure per-request:
133-
client.with_options(max_retries=5).sys.projects.retrieve(
134-
"project_id",
138+
client.with_options(max_retries=5).sys.projects.create(
139+
name="name",
135140
)
136141
```
137142

@@ -155,8 +160,8 @@ client = Asktable(
155160
)
156161

157162
# Override per-request:
158-
client.with_options(timeout=5.0).sys.projects.retrieve(
159-
"project_id",
163+
client.with_options(timeout=5.0).sys.projects.create(
164+
name="name",
160165
)
161166
```
162167

@@ -196,12 +201,12 @@ The "raw" Response object can be accessed by prefixing `.with_raw_response.` to
196201
from asktable import Asktable
197202

198203
client = Asktable()
199-
response = client.sys.projects.with_raw_response.retrieve(
200-
"project_id",
204+
response = client.sys.projects.with_raw_response.create(
205+
name="name",
201206
)
202207
print(response.headers.get('X-My-Header'))
203208

204-
project = response.parse() # get the object that `sys.projects.retrieve()` would have returned
209+
project = response.parse() # get the object that `sys.projects.create()` would have returned
205210
print(project.id)
206211
```
207212

@@ -216,8 +221,8 @@ The above interface eagerly reads the full response body when you make the reque
216221
To stream the response body, use `.with_streaming_response` instead, which requires a context manager and only reads the response body once you call `.read()`, `.text()`, `.json()`, `.iter_bytes()`, `.iter_text()`, `.iter_lines()` or `.parse()`. In the async client, these are async methods.
217222

218223
```python
219-
with client.sys.projects.with_streaming_response.retrieve(
220-
"project_id",
224+
with client.sys.projects.with_streaming_response.create(
225+
name="name",
221226
) as response:
222227
print(response.headers.get("X-My-Header"))
223228

api.md

Lines changed: 106 additions & 45 deletions
Large diffs are not rendered by default.

src/asktable/_client.py

Lines changed: 69 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
)
2626
from ._version import __version__
2727
from ._streaming import Stream as Stream, AsyncStream as AsyncStream
28-
from ._exceptions import APIStatusError
28+
from ._exceptions import AsktableError, APIStatusError
2929
from ._base_client import (
3030
DEFAULT_MAX_RETRIES,
3131
SyncAPIClient,
@@ -48,21 +48,26 @@
4848
class Asktable(SyncAPIClient):
4949
sys: resources.SysResource
5050
securetunnels: resources.SecuretunnelsResource
51+
roles: resources.RolesResource
52+
policies: resources.PoliciesResource
5153
chats: resources.ChatsResource
5254
datasources: resources.DatasourcesResource
5355
bots: resources.BotsResource
5456
extapis: resources.ExtapisResource
57+
auth: resources.AuthResource
5558
single_turn: resources.SingleTurnResource
5659
caches: resources.CachesResource
5760
integration: resources.IntegrationResource
5861
with_raw_response: AsktableWithRawResponse
5962
with_streaming_response: AsktableWithStreamedResponse
6063

6164
# client options
65+
bearer_token: str
6266

6367
def __init__(
6468
self,
6569
*,
70+
bearer_token: str | None = None,
6671
base_url: str | httpx.URL | None = None,
6772
timeout: Union[float, Timeout, None, NotGiven] = NOT_GIVEN,
6873
max_retries: int = DEFAULT_MAX_RETRIES,
@@ -82,7 +87,18 @@ def __init__(
8287
# part of our public interface in the future.
8388
_strict_response_validation: bool = False,
8489
) -> None:
85-
"""Construct a new synchronous asktable client instance."""
90+
"""Construct a new synchronous asktable client instance.
91+
92+
This automatically infers the `bearer_token` argument from the `ASKTABLE_BEARER_TOKEN` environment variable if it is not provided.
93+
"""
94+
if bearer_token is None:
95+
bearer_token = os.environ.get("ASKTABLE_BEARER_TOKEN")
96+
if bearer_token is None:
97+
raise AsktableError(
98+
"The bearer_token client option must be set either by passing bearer_token to the client or by setting the ASKTABLE_BEARER_TOKEN environment variable"
99+
)
100+
self.bearer_token = bearer_token
101+
86102
if base_url is None:
87103
base_url = os.environ.get("ASKTABLE_BASE_URL")
88104
if base_url is None:
@@ -101,10 +117,13 @@ def __init__(
101117

102118
self.sys = resources.SysResource(self)
103119
self.securetunnels = resources.SecuretunnelsResource(self)
120+
self.roles = resources.RolesResource(self)
121+
self.policies = resources.PoliciesResource(self)
104122
self.chats = resources.ChatsResource(self)
105123
self.datasources = resources.DatasourcesResource(self)
106124
self.bots = resources.BotsResource(self)
107125
self.extapis = resources.ExtapisResource(self)
126+
self.auth = resources.AuthResource(self)
108127
self.single_turn = resources.SingleTurnResource(self)
109128
self.caches = resources.CachesResource(self)
110129
self.integration = resources.IntegrationResource(self)
@@ -116,6 +135,12 @@ def __init__(
116135
def qs(self) -> Querystring:
117136
return Querystring(array_format="repeat")
118137

138+
@property
139+
@override
140+
def auth_headers(self) -> dict[str, str]:
141+
bearer_token = self.bearer_token
142+
return {"Authorization": f"Bearer {bearer_token}"}
143+
119144
@property
120145
@override
121146
def default_headers(self) -> dict[str, str | Omit]:
@@ -128,6 +153,7 @@ def default_headers(self) -> dict[str, str | Omit]:
128153
def copy(
129154
self,
130155
*,
156+
bearer_token: str | None = None,
131157
base_url: str | httpx.URL | None = None,
132158
timeout: float | Timeout | None | NotGiven = NOT_GIVEN,
133159
http_client: httpx.Client | None = None,
@@ -161,6 +187,7 @@ def copy(
161187

162188
http_client = http_client or self._client
163189
return self.__class__(
190+
bearer_token=bearer_token or self.bearer_token,
164191
base_url=base_url or self.base_url,
165192
timeout=self.timeout if isinstance(timeout, NotGiven) else timeout,
166193
http_client=http_client,
@@ -211,21 +238,26 @@ def _make_status_error(
211238
class AsyncAsktable(AsyncAPIClient):
212239
sys: resources.AsyncSysResource
213240
securetunnels: resources.AsyncSecuretunnelsResource
241+
roles: resources.AsyncRolesResource
242+
policies: resources.AsyncPoliciesResource
214243
chats: resources.AsyncChatsResource
215244
datasources: resources.AsyncDatasourcesResource
216245
bots: resources.AsyncBotsResource
217246
extapis: resources.AsyncExtapisResource
247+
auth: resources.AsyncAuthResource
218248
single_turn: resources.AsyncSingleTurnResource
219249
caches: resources.AsyncCachesResource
220250
integration: resources.AsyncIntegrationResource
221251
with_raw_response: AsyncAsktableWithRawResponse
222252
with_streaming_response: AsyncAsktableWithStreamedResponse
223253

224254
# client options
255+
bearer_token: str
225256

226257
def __init__(
227258
self,
228259
*,
260+
bearer_token: str | None = None,
229261
base_url: str | httpx.URL | None = None,
230262
timeout: Union[float, Timeout, None, NotGiven] = NOT_GIVEN,
231263
max_retries: int = DEFAULT_MAX_RETRIES,
@@ -245,7 +277,18 @@ def __init__(
245277
# part of our public interface in the future.
246278
_strict_response_validation: bool = False,
247279
) -> None:
248-
"""Construct a new async asktable client instance."""
280+
"""Construct a new async asktable client instance.
281+
282+
This automatically infers the `bearer_token` argument from the `ASKTABLE_BEARER_TOKEN` environment variable if it is not provided.
283+
"""
284+
if bearer_token is None:
285+
bearer_token = os.environ.get("ASKTABLE_BEARER_TOKEN")
286+
if bearer_token is None:
287+
raise AsktableError(
288+
"The bearer_token client option must be set either by passing bearer_token to the client or by setting the ASKTABLE_BEARER_TOKEN environment variable"
289+
)
290+
self.bearer_token = bearer_token
291+
249292
if base_url is None:
250293
base_url = os.environ.get("ASKTABLE_BASE_URL")
251294
if base_url is None:
@@ -264,10 +307,13 @@ def __init__(
264307

265308
self.sys = resources.AsyncSysResource(self)
266309
self.securetunnels = resources.AsyncSecuretunnelsResource(self)
310+
self.roles = resources.AsyncRolesResource(self)
311+
self.policies = resources.AsyncPoliciesResource(self)
267312
self.chats = resources.AsyncChatsResource(self)
268313
self.datasources = resources.AsyncDatasourcesResource(self)
269314
self.bots = resources.AsyncBotsResource(self)
270315
self.extapis = resources.AsyncExtapisResource(self)
316+
self.auth = resources.AsyncAuthResource(self)
271317
self.single_turn = resources.AsyncSingleTurnResource(self)
272318
self.caches = resources.AsyncCachesResource(self)
273319
self.integration = resources.AsyncIntegrationResource(self)
@@ -279,6 +325,12 @@ def __init__(
279325
def qs(self) -> Querystring:
280326
return Querystring(array_format="repeat")
281327

328+
@property
329+
@override
330+
def auth_headers(self) -> dict[str, str]:
331+
bearer_token = self.bearer_token
332+
return {"Authorization": f"Bearer {bearer_token}"}
333+
282334
@property
283335
@override
284336
def default_headers(self) -> dict[str, str | Omit]:
@@ -291,6 +343,7 @@ def default_headers(self) -> dict[str, str | Omit]:
291343
def copy(
292344
self,
293345
*,
346+
bearer_token: str | None = None,
294347
base_url: str | httpx.URL | None = None,
295348
timeout: float | Timeout | None | NotGiven = NOT_GIVEN,
296349
http_client: httpx.AsyncClient | None = None,
@@ -324,6 +377,7 @@ def copy(
324377

325378
http_client = http_client or self._client
326379
return self.__class__(
380+
bearer_token=bearer_token or self.bearer_token,
327381
base_url=base_url or self.base_url,
328382
timeout=self.timeout if isinstance(timeout, NotGiven) else timeout,
329383
http_client=http_client,
@@ -375,10 +429,13 @@ class AsktableWithRawResponse:
375429
def __init__(self, client: Asktable) -> None:
376430
self.sys = resources.SysResourceWithRawResponse(client.sys)
377431
self.securetunnels = resources.SecuretunnelsResourceWithRawResponse(client.securetunnels)
432+
self.roles = resources.RolesResourceWithRawResponse(client.roles)
433+
self.policies = resources.PoliciesResourceWithRawResponse(client.policies)
378434
self.chats = resources.ChatsResourceWithRawResponse(client.chats)
379435
self.datasources = resources.DatasourcesResourceWithRawResponse(client.datasources)
380436
self.bots = resources.BotsResourceWithRawResponse(client.bots)
381437
self.extapis = resources.ExtapisResourceWithRawResponse(client.extapis)
438+
self.auth = resources.AuthResourceWithRawResponse(client.auth)
382439
self.single_turn = resources.SingleTurnResourceWithRawResponse(client.single_turn)
383440
self.caches = resources.CachesResourceWithRawResponse(client.caches)
384441
self.integration = resources.IntegrationResourceWithRawResponse(client.integration)
@@ -388,10 +445,13 @@ class AsyncAsktableWithRawResponse:
388445
def __init__(self, client: AsyncAsktable) -> None:
389446
self.sys = resources.AsyncSysResourceWithRawResponse(client.sys)
390447
self.securetunnels = resources.AsyncSecuretunnelsResourceWithRawResponse(client.securetunnels)
448+
self.roles = resources.AsyncRolesResourceWithRawResponse(client.roles)
449+
self.policies = resources.AsyncPoliciesResourceWithRawResponse(client.policies)
391450
self.chats = resources.AsyncChatsResourceWithRawResponse(client.chats)
392451
self.datasources = resources.AsyncDatasourcesResourceWithRawResponse(client.datasources)
393452
self.bots = resources.AsyncBotsResourceWithRawResponse(client.bots)
394453
self.extapis = resources.AsyncExtapisResourceWithRawResponse(client.extapis)
454+
self.auth = resources.AsyncAuthResourceWithRawResponse(client.auth)
395455
self.single_turn = resources.AsyncSingleTurnResourceWithRawResponse(client.single_turn)
396456
self.caches = resources.AsyncCachesResourceWithRawResponse(client.caches)
397457
self.integration = resources.AsyncIntegrationResourceWithRawResponse(client.integration)
@@ -401,10 +461,13 @@ class AsktableWithStreamedResponse:
401461
def __init__(self, client: Asktable) -> None:
402462
self.sys = resources.SysResourceWithStreamingResponse(client.sys)
403463
self.securetunnels = resources.SecuretunnelsResourceWithStreamingResponse(client.securetunnels)
464+
self.roles = resources.RolesResourceWithStreamingResponse(client.roles)
465+
self.policies = resources.PoliciesResourceWithStreamingResponse(client.policies)
404466
self.chats = resources.ChatsResourceWithStreamingResponse(client.chats)
405467
self.datasources = resources.DatasourcesResourceWithStreamingResponse(client.datasources)
406468
self.bots = resources.BotsResourceWithStreamingResponse(client.bots)
407469
self.extapis = resources.ExtapisResourceWithStreamingResponse(client.extapis)
470+
self.auth = resources.AuthResourceWithStreamingResponse(client.auth)
408471
self.single_turn = resources.SingleTurnResourceWithStreamingResponse(client.single_turn)
409472
self.caches = resources.CachesResourceWithStreamingResponse(client.caches)
410473
self.integration = resources.IntegrationResourceWithStreamingResponse(client.integration)
@@ -414,10 +477,13 @@ class AsyncAsktableWithStreamedResponse:
414477
def __init__(self, client: AsyncAsktable) -> None:
415478
self.sys = resources.AsyncSysResourceWithStreamingResponse(client.sys)
416479
self.securetunnels = resources.AsyncSecuretunnelsResourceWithStreamingResponse(client.securetunnels)
480+
self.roles = resources.AsyncRolesResourceWithStreamingResponse(client.roles)
481+
self.policies = resources.AsyncPoliciesResourceWithStreamingResponse(client.policies)
417482
self.chats = resources.AsyncChatsResourceWithStreamingResponse(client.chats)
418483
self.datasources = resources.AsyncDatasourcesResourceWithStreamingResponse(client.datasources)
419484
self.bots = resources.AsyncBotsResourceWithStreamingResponse(client.bots)
420485
self.extapis = resources.AsyncExtapisResourceWithStreamingResponse(client.extapis)
486+
self.auth = resources.AsyncAuthResourceWithStreamingResponse(client.auth)
421487
self.single_turn = resources.AsyncSingleTurnResourceWithStreamingResponse(client.single_turn)
422488
self.caches = resources.AsyncCachesResourceWithStreamingResponse(client.caches)
423489
self.integration = resources.AsyncIntegrationResourceWithStreamingResponse(client.integration)

0 commit comments

Comments
 (0)