Skip to content

Commit 8841b6a

Browse files
feat(api): added latest OpenAPI specification (#4)
1 parent e6234c7 commit 8841b6a

File tree

4 files changed

+95
-143
lines changed

4 files changed

+95
-143
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import os
3131
from isaacus import Isaacus
3232

3333
client = Isaacus(
34-
bearer_token=os.environ.get("ISAACUS_API_KEY"), # This is the default and can be omitted
34+
api_key=os.environ.get("ISAACUS_API_KEY"), # This is the default and can be omitted
3535
)
3636

3737
universal_classification = client.classifications.universal.create(
@@ -42,10 +42,10 @@ universal_classification = client.classifications.universal.create(
4242
print(universal_classification.chunks)
4343
```
4444

45-
While you can provide a `bearer_token` keyword argument,
45+
While you can provide an `api_key` keyword argument,
4646
we recommend using [python-dotenv](https://pypi.org/project/python-dotenv/)
47-
to add `ISAACUS_API_KEY="My Bearer Token"` to your `.env` file
48-
so that your Bearer Token is not stored in source control.
47+
to add `ISAACUS_API_KEY="My API Key"` to your `.env` file
48+
so that your API Key is not stored in source control.
4949

5050
## Async usage
5151

@@ -57,7 +57,7 @@ import asyncio
5757
from isaacus import AsyncIsaacus
5858

5959
client = AsyncIsaacus(
60-
bearer_token=os.environ.get("ISAACUS_API_KEY"), # This is the default and can be omitted
60+
api_key=os.environ.get("ISAACUS_API_KEY"), # This is the default and can be omitted
6161
)
6262

6363

src/isaacus/_client.py

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,12 @@ class Isaacus(SyncAPIClient):
4242
with_streaming_response: IsaacusWithStreamedResponse
4343

4444
# client options
45-
bearer_token: str
45+
api_key: str
4646

4747
def __init__(
4848
self,
4949
*,
50-
bearer_token: str | None = None,
50+
api_key: str | None = None,
5151
base_url: str | httpx.URL | None = None,
5252
timeout: Union[float, Timeout, None, NotGiven] = NOT_GIVEN,
5353
max_retries: int = DEFAULT_MAX_RETRIES,
@@ -69,15 +69,15 @@ def __init__(
6969
) -> None:
7070
"""Construct a new synchronous isaacus client instance.
7171
72-
This automatically infers the `bearer_token` argument from the `ISAACUS_API_KEY` environment variable if it is not provided.
72+
This automatically infers the `api_key` argument from the `ISAACUS_API_KEY` environment variable if it is not provided.
7373
"""
74-
if bearer_token is None:
75-
bearer_token = os.environ.get("ISAACUS_API_KEY")
76-
if bearer_token is None:
74+
if api_key is None:
75+
api_key = os.environ.get("ISAACUS_API_KEY")
76+
if api_key is None:
7777
raise IsaacusError(
78-
"The bearer_token client option must be set either by passing bearer_token to the client or by setting the ISAACUS_API_KEY environment variable"
78+
"The api_key client option must be set either by passing api_key to the client or by setting the ISAACUS_API_KEY environment variable"
7979
)
80-
self.bearer_token = bearer_token
80+
self.api_key = api_key
8181

8282
if base_url is None:
8383
base_url = os.environ.get("ISAACUS_BASE_URL")
@@ -107,8 +107,8 @@ def qs(self) -> Querystring:
107107
@property
108108
@override
109109
def auth_headers(self) -> dict[str, str]:
110-
bearer_token = self.bearer_token
111-
return {"Authorization": f"Bearer {bearer_token}"}
110+
api_key = self.api_key
111+
return {"Authorization": f"Bearer {api_key}"}
112112

113113
@property
114114
@override
@@ -122,7 +122,7 @@ def default_headers(self) -> dict[str, str | Omit]:
122122
def copy(
123123
self,
124124
*,
125-
bearer_token: str | None = None,
125+
api_key: str | None = None,
126126
base_url: str | httpx.URL | None = None,
127127
timeout: float | Timeout | None | NotGiven = NOT_GIVEN,
128128
http_client: httpx.Client | None = None,
@@ -156,7 +156,7 @@ def copy(
156156

157157
http_client = http_client or self._client
158158
return self.__class__(
159-
bearer_token=bearer_token or self.bearer_token,
159+
api_key=api_key or self.api_key,
160160
base_url=base_url or self.base_url,
161161
timeout=self.timeout if isinstance(timeout, NotGiven) else timeout,
162162
http_client=http_client,
@@ -210,12 +210,12 @@ class AsyncIsaacus(AsyncAPIClient):
210210
with_streaming_response: AsyncIsaacusWithStreamedResponse
211211

212212
# client options
213-
bearer_token: str
213+
api_key: str
214214

215215
def __init__(
216216
self,
217217
*,
218-
bearer_token: str | None = None,
218+
api_key: str | None = None,
219219
base_url: str | httpx.URL | None = None,
220220
timeout: Union[float, Timeout, None, NotGiven] = NOT_GIVEN,
221221
max_retries: int = DEFAULT_MAX_RETRIES,
@@ -237,15 +237,15 @@ def __init__(
237237
) -> None:
238238
"""Construct a new async isaacus client instance.
239239
240-
This automatically infers the `bearer_token` argument from the `ISAACUS_API_KEY` environment variable if it is not provided.
240+
This automatically infers the `api_key` argument from the `ISAACUS_API_KEY` environment variable if it is not provided.
241241
"""
242-
if bearer_token is None:
243-
bearer_token = os.environ.get("ISAACUS_API_KEY")
244-
if bearer_token is None:
242+
if api_key is None:
243+
api_key = os.environ.get("ISAACUS_API_KEY")
244+
if api_key is None:
245245
raise IsaacusError(
246-
"The bearer_token client option must be set either by passing bearer_token to the client or by setting the ISAACUS_API_KEY environment variable"
246+
"The api_key client option must be set either by passing api_key to the client or by setting the ISAACUS_API_KEY environment variable"
247247
)
248-
self.bearer_token = bearer_token
248+
self.api_key = api_key
249249

250250
if base_url is None:
251251
base_url = os.environ.get("ISAACUS_BASE_URL")
@@ -275,8 +275,8 @@ def qs(self) -> Querystring:
275275
@property
276276
@override
277277
def auth_headers(self) -> dict[str, str]:
278-
bearer_token = self.bearer_token
279-
return {"Authorization": f"Bearer {bearer_token}"}
278+
api_key = self.api_key
279+
return {"Authorization": f"Bearer {api_key}"}
280280

281281
@property
282282
@override
@@ -290,7 +290,7 @@ def default_headers(self) -> dict[str, str | Omit]:
290290
def copy(
291291
self,
292292
*,
293-
bearer_token: str | None = None,
293+
api_key: str | None = None,
294294
base_url: str | httpx.URL | None = None,
295295
timeout: float | Timeout | None | NotGiven = NOT_GIVEN,
296296
http_client: httpx.AsyncClient | None = None,
@@ -324,7 +324,7 @@ def copy(
324324

325325
http_client = http_client or self._client
326326
return self.__class__(
327-
bearer_token=bearer_token or self.bearer_token,
327+
api_key=api_key or self.api_key,
328328
base_url=base_url or self.base_url,
329329
timeout=self.timeout if isinstance(timeout, NotGiven) else timeout,
330330
http_client=http_client,

tests/conftest.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def pytest_collection_modifyitems(items: list[pytest.Function]) -> None:
2828

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

31-
bearer_token = "My Bearer Token"
31+
api_key = "My API Key"
3232

3333

3434
@pytest.fixture(scope="session")
@@ -37,7 +37,7 @@ def client(request: FixtureRequest) -> Iterator[Isaacus]:
3737
if not isinstance(strict, bool):
3838
raise TypeError(f"Unexpected fixture parameter type {type(strict)}, expected {bool}")
3939

40-
with Isaacus(base_url=base_url, bearer_token=bearer_token, _strict_response_validation=strict) as client:
40+
with Isaacus(base_url=base_url, api_key=api_key, _strict_response_validation=strict) as client:
4141
yield client
4242

4343

@@ -47,5 +47,5 @@ async def async_client(request: FixtureRequest) -> AsyncIterator[AsyncIsaacus]:
4747
if not isinstance(strict, bool):
4848
raise TypeError(f"Unexpected fixture parameter type {type(strict)}, expected {bool}")
4949

50-
async with AsyncIsaacus(base_url=base_url, bearer_token=bearer_token, _strict_response_validation=strict) as client:
50+
async with AsyncIsaacus(base_url=base_url, api_key=api_key, _strict_response_validation=strict) as client:
5151
yield client

0 commit comments

Comments
 (0)