Skip to content

Commit 978ad9c

Browse files
feat(api): api update
1 parent c64047c commit 978ad9c

4 files changed

Lines changed: 54 additions & 201 deletions

File tree

.stats.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 25
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/nen-labs%2Fsteel-e788c6b435e0200ec2804c2ba57649047f71029b0e4daeae13876bb4636829a9.yml
3-
openapi_spec_hash: 80b61a9157af36229eec5091cbe5e1e0
4-
config_hash: 8fee9983d818d458fca9da01d2013f05
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/nen-labs%2Fsteel-f81cef6f87adc0530d9bc21e8d47c95aadef9d5bc3c282837ae0ad41d7f71bac.yml
3+
openapi_spec_hash: 5b273b225abb80a969ea1485bf399745
4+
config_hash: 42515bf83f1e0e765071038fcf702122

src/steel/_client.py

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
)
3939
from .resources import files, credentials
4040
from ._streaming import Stream as Stream, AsyncStream as AsyncStream
41-
from ._exceptions import SteelError, APIStatusError
41+
from ._exceptions import APIStatusError
4242
from ._base_client import (
4343
DEFAULT_MAX_RETRIES,
4444
SyncAPIClient,
@@ -61,7 +61,7 @@ class Steel(SyncAPIClient):
6161
with_streaming_response: SteelWithStreamedResponse
6262

6363
# client options
64-
steel_api_key: str
64+
steel_api_key: str | None
6565

6666
def __init__(
6767
self,
@@ -92,10 +92,6 @@ def __init__(
9292
"""
9393
if steel_api_key is None:
9494
steel_api_key = os.environ.get("STEEL_API_KEY")
95-
if steel_api_key is None:
96-
raise SteelError(
97-
"The steel_api_key client option must be set either by passing steel_api_key to the client or by setting the STEEL_API_KEY environment variable"
98-
)
9995
self.steel_api_key = steel_api_key
10096

10197
if base_url is None:
@@ -129,6 +125,8 @@ def qs(self) -> Querystring:
129125
@override
130126
def auth_headers(self) -> dict[str, str]:
131127
steel_api_key = self.steel_api_key
128+
if steel_api_key is None:
129+
return {}
132130
return {"steel-api-key": steel_api_key}
133131

134132
@property
@@ -390,7 +388,7 @@ class AsyncSteel(AsyncAPIClient):
390388
with_streaming_response: AsyncSteelWithStreamedResponse
391389

392390
# client options
393-
steel_api_key: str
391+
steel_api_key: str | None
394392

395393
def __init__(
396394
self,
@@ -421,10 +419,6 @@ def __init__(
421419
"""
422420
if steel_api_key is None:
423421
steel_api_key = os.environ.get("STEEL_API_KEY")
424-
if steel_api_key is None:
425-
raise SteelError(
426-
"The steel_api_key client option must be set either by passing steel_api_key to the client or by setting the STEEL_API_KEY environment variable"
427-
)
428422
self.steel_api_key = steel_api_key
429423

430424
if base_url is None:
@@ -458,6 +452,8 @@ def qs(self) -> Querystring:
458452
@override
459453
def auth_headers(self) -> dict[str, str]:
460454
steel_api_key = self.steel_api_key
455+
if steel_api_key is None:
456+
return {}
461457
return {"steel-api-key": steel_api_key}
462458

463459
@property

tests/conftest.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,14 @@ def pytest_collection_modifyitems(items: list[pytest.Function]) -> None:
4545

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

48-
steel_api_key = "My Steel API Key"
49-
5048

5149
@pytest.fixture(scope="session")
5250
def client(request: FixtureRequest) -> Iterator[Steel]:
5351
strict = getattr(request, "param", True)
5452
if not isinstance(strict, bool):
5553
raise TypeError(f"Unexpected fixture parameter type {type(strict)}, expected {bool}")
5654

57-
with Steel(base_url=base_url, steel_api_key=steel_api_key, _strict_response_validation=strict) as client:
55+
with Steel(base_url=base_url, _strict_response_validation=strict) as client:
5856
yield client
5957

6058

@@ -78,7 +76,5 @@ async def async_client(request: FixtureRequest) -> AsyncIterator[AsyncSteel]:
7876
else:
7977
raise TypeError(f"Unexpected fixture parameter type {type(param)}, expected bool or dict")
8078

81-
async with AsyncSteel(
82-
base_url=base_url, steel_api_key=steel_api_key, _strict_response_validation=strict, http_client=http_client
83-
) as client:
79+
async with AsyncSteel(base_url=base_url, _strict_response_validation=strict, http_client=http_client) as client:
8480
yield client

0 commit comments

Comments
 (0)