Skip to content

Commit 1a43ad3

Browse files
feat(api): update via SDK Studio (#33)
1 parent 67dfb3e commit 1a43ad3

File tree

4 files changed

+18
-47
lines changed

4 files changed

+18
-47
lines changed

.stats.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
configured_endpoints: 15
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/brainbase-egrigokhan%2Fbrainbase-0c00485d66a3b7505f3247467ef293fa5fb43a64e90a8b03a4127a2d9b15e6ab.yml
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/brainbase-egrigokhan%2Fbrainbase-a197a88d1abbdbd5c886875d2cf12ffd6abf79aec7d4dbd0439ed50197692eba.yml

README.md

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ It is generated with [Stainless](https://www.stainlessapi.com/).
1010

1111
## Documentation
1212

13-
The REST API documentation can be found on [docs.usebrainbase.xyz](https://docs.usebrainbase.xyz). The full API of this library can be found in [api.md](api.md).
13+
The REST API documentation can be found on [docs.brainbase.com](https://docs.brainbase.com). The full API of this library can be found in [api.md](api.md).
1414

1515
## Installation
1616

@@ -24,32 +24,25 @@ pip install brainbase-labs
2424
The full API of this library can be found in [api.md](api.md).
2525

2626
```python
27-
import os
2827
from brainbase import Brainbase
2928

3029
client = Brainbase(
31-
api_key=os.environ.get("BRAINBASE_API_KEY"), # This is the default and can be omitted
30+
api_key="My API Key",
3231
)
3332

3433
client.workers.list()
3534
```
3635

37-
While you can provide an `api_key` keyword argument,
38-
we recommend using [python-dotenv](https://pypi.org/project/python-dotenv/)
39-
to add `BRAINBASE_API_KEY="My API Key"` to your `.env` file
40-
so that your API Key is not stored in source control.
41-
4236
## Async usage
4337

4438
Simply import `AsyncBrainbase` instead of `Brainbase` and use `await` with each API call:
4539

4640
```python
47-
import os
4841
import asyncio
4942
from brainbase import AsyncBrainbase
5043

5144
client = AsyncBrainbase(
52-
api_key=os.environ.get("BRAINBASE_API_KEY"), # This is the default and can be omitted
45+
api_key="My API Key",
5346
)
5447

5548

@@ -84,7 +77,9 @@ All errors inherit from `brainbase.APIError`.
8477
import brainbase
8578
from brainbase import Brainbase
8679

87-
client = Brainbase()
80+
client = Brainbase(
81+
api_key="My API Key",
82+
)
8883

8984
try:
9085
client.workers.list()
@@ -127,6 +122,7 @@ from brainbase import Brainbase
127122
client = Brainbase(
128123
# default is 2
129124
max_retries=0,
125+
api_key="My API Key",
130126
)
131127

132128
# Or, configure per-request:
@@ -145,11 +141,13 @@ from brainbase import Brainbase
145141
client = Brainbase(
146142
# 20 seconds (default is 1 minute)
147143
timeout=20.0,
144+
api_key="My API Key",
148145
)
149146

150147
# More granular control:
151148
client = Brainbase(
152149
timeout=httpx.Timeout(60.0, read=5.0, write=10.0, connect=2.0),
150+
api_key="My API Key",
153151
)
154152

155153
# Override per-request:
@@ -193,7 +191,9 @@ The "raw" Response object can be accessed by prefixing `.with_raw_response.` to
193191
```py
194192
from brainbase import Brainbase
195193

196-
client = Brainbase()
194+
client = Brainbase(
195+
api_key="My API Key",
196+
)
197197
response = client.workers.with_raw_response.list()
198198
print(response.headers.get('X-My-Header'))
199199

@@ -274,6 +274,7 @@ client = Brainbase(
274274
proxy="http://my.test.proxy.example.com",
275275
transport=httpx.HTTPTransport(local_address="0.0.0.0"),
276276
),
277+
api_key="My API Key",
277278
)
278279
```
279280

@@ -290,7 +291,9 @@ By default the library closes underlying HTTP connections whenever the client is
290291
```py
291292
from brainbase import Brainbase
292293

293-
with Brainbase() as client:
294+
with Brainbase(
295+
api_key="My API Key",
296+
) as client:
294297
# make requests here
295298
...
296299

src/brainbase/_client.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,6 @@ def __init__(
113113
def qs(self) -> Querystring:
114114
return Querystring(array_format="comma")
115115

116-
@property
117-
@override
118-
def auth_headers(self) -> dict[str, str]:
119-
api_key = self.api_key
120-
return {"x-api-key": api_key}
121-
122116
@property
123117
@override
124118
def default_headers(self) -> dict[str, str | Omit]:
@@ -281,12 +275,6 @@ def __init__(
281275
def qs(self) -> Querystring:
282276
return Querystring(array_format="comma")
283277

284-
@property
285-
@override
286-
def auth_headers(self) -> dict[str, str]:
287-
api_key = self.api_key
288-
return {"x-api-key": api_key}
289-
290278
@property
291279
@override
292280
def default_headers(self) -> dict[str, str | Omit]:

tests/test_client.py

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
from brainbase._types import Omit
2626
from brainbase._models import BaseModel, FinalRequestOptions
2727
from brainbase._constants import RAW_RESPONSE_HEADER
28-
from brainbase._exceptions import APIStatusError, BrainbaseError, APITimeoutError, APIResponseValidationError
28+
from brainbase._exceptions import APIStatusError, APITimeoutError, APIResponseValidationError
2929
from brainbase._base_client import (
3030
DEFAULT_TIMEOUT,
3131
HTTPX_DEFAULT_TIMEOUT,
@@ -334,16 +334,6 @@ def test_default_headers_option(self) -> None:
334334
assert request.headers.get("x-foo") == "stainless"
335335
assert request.headers.get("x-stainless-lang") == "my-overriding-header"
336336

337-
def test_validate_headers(self) -> None:
338-
client = Brainbase(base_url=base_url, api_key=api_key, _strict_response_validation=True)
339-
request = client._build_request(FinalRequestOptions(method="get", url="/foo"))
340-
assert request.headers.get("x-api-key") == api_key
341-
342-
with pytest.raises(BrainbaseError):
343-
with update_env(**{"BRAINBASE_API_KEY": Omit()}):
344-
client2 = Brainbase(base_url=base_url, api_key=None, _strict_response_validation=True)
345-
_ = client2
346-
347337
def test_default_query_option(self) -> None:
348338
client = Brainbase(
349339
base_url=base_url, api_key=api_key, _strict_response_validation=True, default_query={"query_param": "bar"}
@@ -1090,16 +1080,6 @@ def test_default_headers_option(self) -> None:
10901080
assert request.headers.get("x-foo") == "stainless"
10911081
assert request.headers.get("x-stainless-lang") == "my-overriding-header"
10921082

1093-
def test_validate_headers(self) -> None:
1094-
client = AsyncBrainbase(base_url=base_url, api_key=api_key, _strict_response_validation=True)
1095-
request = client._build_request(FinalRequestOptions(method="get", url="/foo"))
1096-
assert request.headers.get("x-api-key") == api_key
1097-
1098-
with pytest.raises(BrainbaseError):
1099-
with update_env(**{"BRAINBASE_API_KEY": Omit()}):
1100-
client2 = AsyncBrainbase(base_url=base_url, api_key=None, _strict_response_validation=True)
1101-
_ = client2
1102-
11031083
def test_default_query_option(self) -> None:
11041084
client = AsyncBrainbase(
11051085
base_url=base_url, api_key=api_key, _strict_response_validation=True, default_query={"query_param": "bar"}

0 commit comments

Comments
 (0)