Skip to content

Commit 4596400

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

File tree

4 files changed

+87
-135
lines changed

4 files changed

+87
-135
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ project = client.sys.projects.create(
3737
print(project.id)
3838
```
3939

40-
While you can provide a `bearer_token` keyword argument,
40+
While you can provide an `api_key` keyword argument,
4141
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.
42+
to add `ASKTABLE_API_KEY="My API Key"` to your `.env` file
43+
so that your API Key is not stored in source control.
4444

4545
## Async usage
4646

src/asktable/_client.py

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,12 @@ class Asktable(SyncAPIClient):
6262
with_streaming_response: AsktableWithStreamedResponse
6363

6464
# client options
65-
bearer_token: str
65+
api_key: str
6666

6767
def __init__(
6868
self,
6969
*,
70-
bearer_token: str | None = None,
70+
api_key: str | None = None,
7171
base_url: str | httpx.URL | None = None,
7272
timeout: Union[float, Timeout, None, NotGiven] = NOT_GIVEN,
7373
max_retries: int = DEFAULT_MAX_RETRIES,
@@ -89,15 +89,15 @@ def __init__(
8989
) -> None:
9090
"""Construct a new synchronous asktable client instance.
9191
92-
This automatically infers the `bearer_token` argument from the `ASKTABLE_BEARER_TOKEN` environment variable if it is not provided.
92+
This automatically infers the `api_key` argument from the `ASKTABLE_API_KEY` environment variable if it is not provided.
9393
"""
94-
if bearer_token is None:
95-
bearer_token = os.environ.get("ASKTABLE_BEARER_TOKEN")
96-
if bearer_token is None:
94+
if api_key is None:
95+
api_key = os.environ.get("ASKTABLE_API_KEY")
96+
if api_key is None:
9797
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"
98+
"The api_key client option must be set either by passing api_key to the client or by setting the ASKTABLE_API_KEY environment variable"
9999
)
100-
self.bearer_token = bearer_token
100+
self.api_key = api_key
101101

102102
if base_url is None:
103103
base_url = os.environ.get("ASKTABLE_BASE_URL")
@@ -138,8 +138,8 @@ def qs(self) -> Querystring:
138138
@property
139139
@override
140140
def auth_headers(self) -> dict[str, str]:
141-
bearer_token = self.bearer_token
142-
return {"Authorization": f"Bearer {bearer_token}"}
141+
api_key = self.api_key
142+
return {"Authorization": f"Bearer {api_key}"}
143143

144144
@property
145145
@override
@@ -153,7 +153,7 @@ def default_headers(self) -> dict[str, str | Omit]:
153153
def copy(
154154
self,
155155
*,
156-
bearer_token: str | None = None,
156+
api_key: str | None = None,
157157
base_url: str | httpx.URL | None = None,
158158
timeout: float | Timeout | None | NotGiven = NOT_GIVEN,
159159
http_client: httpx.Client | None = None,
@@ -187,7 +187,7 @@ def copy(
187187

188188
http_client = http_client or self._client
189189
return self.__class__(
190-
bearer_token=bearer_token or self.bearer_token,
190+
api_key=api_key or self.api_key,
191191
base_url=base_url or self.base_url,
192192
timeout=self.timeout if isinstance(timeout, NotGiven) else timeout,
193193
http_client=http_client,
@@ -252,12 +252,12 @@ class AsyncAsktable(AsyncAPIClient):
252252
with_streaming_response: AsyncAsktableWithStreamedResponse
253253

254254
# client options
255-
bearer_token: str
255+
api_key: str
256256

257257
def __init__(
258258
self,
259259
*,
260-
bearer_token: str | None = None,
260+
api_key: str | None = None,
261261
base_url: str | httpx.URL | None = None,
262262
timeout: Union[float, Timeout, None, NotGiven] = NOT_GIVEN,
263263
max_retries: int = DEFAULT_MAX_RETRIES,
@@ -279,15 +279,15 @@ def __init__(
279279
) -> None:
280280
"""Construct a new async asktable client instance.
281281
282-
This automatically infers the `bearer_token` argument from the `ASKTABLE_BEARER_TOKEN` environment variable if it is not provided.
282+
This automatically infers the `api_key` argument from the `ASKTABLE_API_KEY` environment variable if it is not provided.
283283
"""
284-
if bearer_token is None:
285-
bearer_token = os.environ.get("ASKTABLE_BEARER_TOKEN")
286-
if bearer_token is None:
284+
if api_key is None:
285+
api_key = os.environ.get("ASKTABLE_API_KEY")
286+
if api_key is None:
287287
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"
288+
"The api_key client option must be set either by passing api_key to the client or by setting the ASKTABLE_API_KEY environment variable"
289289
)
290-
self.bearer_token = bearer_token
290+
self.api_key = api_key
291291

292292
if base_url is None:
293293
base_url = os.environ.get("ASKTABLE_BASE_URL")
@@ -328,8 +328,8 @@ def qs(self) -> Querystring:
328328
@property
329329
@override
330330
def auth_headers(self) -> dict[str, str]:
331-
bearer_token = self.bearer_token
332-
return {"Authorization": f"Bearer {bearer_token}"}
331+
api_key = self.api_key
332+
return {"Authorization": f"Bearer {api_key}"}
333333

334334
@property
335335
@override
@@ -343,7 +343,7 @@ def default_headers(self) -> dict[str, str | Omit]:
343343
def copy(
344344
self,
345345
*,
346-
bearer_token: str | None = None,
346+
api_key: str | None = None,
347347
base_url: str | httpx.URL | None = None,
348348
timeout: float | Timeout | None | NotGiven = NOT_GIVEN,
349349
http_client: httpx.AsyncClient | None = None,
@@ -377,7 +377,7 @@ def copy(
377377

378378
http_client = http_client or self._client
379379
return self.__class__(
380-
bearer_token=bearer_token or self.bearer_token,
380+
api_key=api_key or self.api_key,
381381
base_url=base_url or self.base_url,
382382
timeout=self.timeout if isinstance(timeout, NotGiven) else timeout,
383383
http_client=http_client,

tests/conftest.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def event_loop() -> Iterator[asyncio.AbstractEventLoop]:
2626

2727
base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
2828

29-
bearer_token = "My Bearer Token"
29+
api_key = "My API Key"
3030

3131

3232
@pytest.fixture(scope="session")
@@ -35,7 +35,7 @@ def client(request: FixtureRequest) -> Iterator[Asktable]:
3535
if not isinstance(strict, bool):
3636
raise TypeError(f"Unexpected fixture parameter type {type(strict)}, expected {bool}")
3737

38-
with Asktable(base_url=base_url, bearer_token=bearer_token, _strict_response_validation=strict) as client:
38+
with Asktable(base_url=base_url, api_key=api_key, _strict_response_validation=strict) as client:
3939
yield client
4040

4141

@@ -45,7 +45,5 @@ async def async_client(request: FixtureRequest) -> AsyncIterator[AsyncAsktable]:
4545
if not isinstance(strict, bool):
4646
raise TypeError(f"Unexpected fixture parameter type {type(strict)}, expected {bool}")
4747

48-
async with AsyncAsktable(
49-
base_url=base_url, bearer_token=bearer_token, _strict_response_validation=strict
50-
) as client:
48+
async with AsyncAsktable(base_url=base_url, api_key=api_key, _strict_response_validation=strict) as client:
5149
yield client

0 commit comments

Comments
 (0)