Skip to content

Commit f93403a

Browse files
feat(api): api update
1 parent b4fae02 commit f93403a

9 files changed

Lines changed: 141 additions & 4 deletions

File tree

.stats.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
configured_endpoints: 20
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/nen-labs%2Fsteel-c30148e5d3a9b19312ab7c9860fac5dc5c4d773b1032fa8ce345e6386c04c945.yml
3-
openapi_spec_hash: ca45bef50c34ba9f4affa7549b2b915a
4-
config_hash: eceac094e0c141de74f2ed1fa1a9857c
1+
configured_endpoints: 21
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/nen-labs%2Fsteel-7fca3009423f0f22ea3f05e1e7d7639ee4f011c4e82f76b1db0eeede2c7aaf89.yml
3+
openapi_spec_hash: d5bbd2360a0eb0c87b640953e3c81453
4+
config_hash: afec2f07e489e6d6c8ac5ab70d52bf42

api.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ from steel.types import (
4444
SessionEventsResponse,
4545
SessionLiveDetailsResponse,
4646
SessionReleaseResponse,
47+
SessionReleaseAllResponse,
4748
)
4849
```
4950

@@ -56,6 +57,7 @@ Methods:
5657
- <code title="get /v1/sessions/{id}/events">client.sessions.<a href="./src/steel/resources/sessions/sessions.py">events</a>(id) -> <a href="./src/steel/types/session_events_response.py">SessionEventsResponse</a></code>
5758
- <code title="get /v1/sessions/{id}/live-details">client.sessions.<a href="./src/steel/resources/sessions/sessions.py">live_details</a>(id) -> <a href="./src/steel/types/session_live_details_response.py">SessionLiveDetailsResponse</a></code>
5859
- <code title="post /v1/sessions/{id}/release">client.sessions.<a href="./src/steel/resources/sessions/sessions.py">release</a>(id) -> <a href="./src/steel/types/session_release_response.py">SessionReleaseResponse</a></code>
60+
- <code title="post /v1/sessions/release">client.sessions.<a href="./src/steel/resources/sessions/sessions.py">release_all</a>() -> <a href="./src/steel/types/session_release_all_response.py">SessionReleaseAllResponse</a></code>
5961

6062
## Files
6163

src/steel/resources/sessions/sessions.py

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
from ...types.session_context import SessionContext
3333
from ...types.session_events_response import SessionEventsResponse
3434
from ...types.session_release_response import SessionReleaseResponse
35+
from ...types.session_release_all_response import SessionReleaseAllResponse
3536
from ...types.session_live_details_response import SessionLiveDetailsResponse
3637

3738
__all__ = ["SessionsResource", "AsyncSessionsResource"]
@@ -71,6 +72,7 @@ def create(
7172
is_selenium: bool | NotGiven = NOT_GIVEN,
7273
namespace: str | NotGiven = NOT_GIVEN,
7374
proxy_url: str | NotGiven = NOT_GIVEN,
75+
region: Literal["lax", "ord", "iad", "bom", "scl", "fra", "hkg"] | NotGiven = NOT_GIVEN,
7476
session_context: session_create_params.SessionContext | NotGiven = NOT_GIVEN,
7577
session_id: str | NotGiven = NOT_GIVEN,
7678
solve_captcha: bool | NotGiven = NOT_GIVEN,
@@ -105,6 +107,8 @@ def create(
105107
Steel-provided proxies in favor of your specified proxy. Format:
106108
http(s)://username:password@hostname:port
107109
110+
region: The desired region for the session to be started in
111+
108112
session_context: Session context data to be used in the created session. Sessions will start with
109113
an empty context by default.
110114
@@ -138,6 +142,7 @@ def create(
138142
"is_selenium": is_selenium,
139143
"namespace": namespace,
140144
"proxy_url": proxy_url,
145+
"region": region,
141146
"session_context": session_context,
142147
"session_id": session_id,
143148
"solve_captcha": solve_captcha,
@@ -369,6 +374,25 @@ def release(
369374
cast_to=SessionReleaseResponse,
370375
)
371376

377+
def release_all(
378+
self,
379+
*,
380+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
381+
# The extra values given here take precedence over values defined on the client or passed to this method.
382+
extra_headers: Headers | None = None,
383+
extra_query: Query | None = None,
384+
extra_body: Body | None = None,
385+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
386+
) -> SessionReleaseAllResponse:
387+
"""Releases all active sessions for the current organization."""
388+
return self._post(
389+
"/v1/sessions/release",
390+
options=make_request_options(
391+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
392+
),
393+
cast_to=SessionReleaseAllResponse,
394+
)
395+
372396

373397
class AsyncSessionsResource(AsyncAPIResource):
374398
@cached_property
@@ -404,6 +428,7 @@ async def create(
404428
is_selenium: bool | NotGiven = NOT_GIVEN,
405429
namespace: str | NotGiven = NOT_GIVEN,
406430
proxy_url: str | NotGiven = NOT_GIVEN,
431+
region: Literal["lax", "ord", "iad", "bom", "scl", "fra", "hkg"] | NotGiven = NOT_GIVEN,
407432
session_context: session_create_params.SessionContext | NotGiven = NOT_GIVEN,
408433
session_id: str | NotGiven = NOT_GIVEN,
409434
solve_captcha: bool | NotGiven = NOT_GIVEN,
@@ -438,6 +463,8 @@ async def create(
438463
Steel-provided proxies in favor of your specified proxy. Format:
439464
http(s)://username:password@hostname:port
440465
466+
region: The desired region for the session to be started in
467+
441468
session_context: Session context data to be used in the created session. Sessions will start with
442469
an empty context by default.
443470
@@ -471,6 +498,7 @@ async def create(
471498
"is_selenium": is_selenium,
472499
"namespace": namespace,
473500
"proxy_url": proxy_url,
501+
"region": region,
474502
"session_context": session_context,
475503
"session_id": session_id,
476504
"solve_captcha": solve_captcha,
@@ -702,6 +730,25 @@ async def release(
702730
cast_to=SessionReleaseResponse,
703731
)
704732

733+
async def release_all(
734+
self,
735+
*,
736+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
737+
# The extra values given here take precedence over values defined on the client or passed to this method.
738+
extra_headers: Headers | None = None,
739+
extra_query: Query | None = None,
740+
extra_body: Body | None = None,
741+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
742+
) -> SessionReleaseAllResponse:
743+
"""Releases all active sessions for the current organization."""
744+
return await self._post(
745+
"/v1/sessions/release",
746+
options=make_request_options(
747+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
748+
),
749+
cast_to=SessionReleaseAllResponse,
750+
)
751+
705752

706753
class SessionsResourceWithRawResponse:
707754
def __init__(self, sessions: SessionsResource) -> None:
@@ -728,6 +775,9 @@ def __init__(self, sessions: SessionsResource) -> None:
728775
self.release = to_raw_response_wrapper(
729776
sessions.release,
730777
)
778+
self.release_all = to_raw_response_wrapper(
779+
sessions.release_all,
780+
)
731781

732782
@cached_property
733783
def files(self) -> FilesResourceWithRawResponse:
@@ -759,6 +809,9 @@ def __init__(self, sessions: AsyncSessionsResource) -> None:
759809
self.release = async_to_raw_response_wrapper(
760810
sessions.release,
761811
)
812+
self.release_all = async_to_raw_response_wrapper(
813+
sessions.release_all,
814+
)
762815

763816
@cached_property
764817
def files(self) -> AsyncFilesResourceWithRawResponse:
@@ -790,6 +843,9 @@ def __init__(self, sessions: SessionsResource) -> None:
790843
self.release = to_streamed_response_wrapper(
791844
sessions.release,
792845
)
846+
self.release_all = to_streamed_response_wrapper(
847+
sessions.release_all,
848+
)
793849

794850
@cached_property
795851
def files(self) -> FilesResourceWithStreamingResponse:
@@ -821,6 +877,9 @@ def __init__(self, sessions: AsyncSessionsResource) -> None:
821877
self.release = async_to_streamed_response_wrapper(
822878
sessions.release,
823879
)
880+
self.release_all = async_to_streamed_response_wrapper(
881+
sessions.release_all,
882+
)
824883

825884
@cached_property
826885
def files(self) -> AsyncFilesResourceWithStreamingResponse:

src/steel/types/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,5 @@
2323
from .credential_create_response import CredentialCreateResponse as CredentialCreateResponse
2424
from .credential_delete_response import CredentialDeleteResponse as CredentialDeleteResponse
2525
from .credential_update_response import CredentialUpdateResponse as CredentialUpdateResponse
26+
from .session_release_all_response import SessionReleaseAllResponse as SessionReleaseAllResponse
2627
from .session_live_details_response import SessionLiveDetailsResponse as SessionLiveDetailsResponse

src/steel/types/session.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ class Session(BaseModel):
6262
proxy: Optional[str] = None
6363
"""Proxy server used for the session"""
6464

65+
region: Optional[Literal["lax", "ord", "iad", "bom", "scl", "fra", "hkg"]] = None
66+
"""The desired region for the session to be started in"""
67+
6568
solve_captcha: Optional[bool] = FieldInfo(alias="solveCaptcha", default=None)
6669
"""Indicates if captcha solving is enabled"""
6770

src/steel/types/session_create_params.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ class SessionCreateParams(TypedDict, total=False):
5151
proxy. Format: http(s)://username:password@hostname:port
5252
"""
5353

54+
region: Literal["lax", "ord", "iad", "bom", "scl", "fra", "hkg"]
55+
"""The desired region for the session to be started in"""
56+
5457
session_context: Annotated[SessionContext, PropertyInfo(alias="sessionContext")]
5558
"""Session context data to be used in the created session.
5659
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
from .._models import BaseModel
4+
5+
__all__ = ["SessionReleaseAllResponse"]
6+
7+
8+
class SessionReleaseAllResponse(BaseModel):
9+
message: str
10+
"""Details about the outcome of the release operation"""
11+
12+
success: bool
13+
"""Indicates if the sessions were successfully released"""

src/steel/types/sessionslist.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ class Session(BaseModel):
6262
proxy: Optional[str] = None
6363
"""Proxy server used for the session"""
6464

65+
region: Optional[Literal["lax", "ord", "iad", "bom", "scl", "fra", "hkg"]] = None
66+
"""The desired region for the session to be started in"""
67+
6568
solve_captcha: Optional[bool] = FieldInfo(alias="solveCaptcha", default=None)
6669
"""Indicates if captcha solving is enabled"""
6770

tests/api_resources/test_sessions.py

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
SessionContext,
1414
SessionEventsResponse,
1515
SessionReleaseResponse,
16+
SessionReleaseAllResponse,
1617
SessionLiveDetailsResponse,
1718
)
1819
from tests.utils import assert_matches_type
@@ -48,6 +49,7 @@ def test_method_create_with_all_params(self, client: Steel) -> None:
4849
is_selenium=True,
4950
namespace="namespace",
5051
proxy_url="https://example.com",
52+
region="lax",
5153
session_context={
5254
"cookies": [
5355
{
@@ -357,6 +359,31 @@ def test_path_params_release(self, client: Steel) -> None:
357359
"",
358360
)
359361

362+
@parametrize
363+
def test_method_release_all(self, client: Steel) -> None:
364+
session = client.sessions.release_all()
365+
assert_matches_type(SessionReleaseAllResponse, session, path=["response"])
366+
367+
@parametrize
368+
def test_raw_response_release_all(self, client: Steel) -> None:
369+
response = client.sessions.with_raw_response.release_all()
370+
371+
assert response.is_closed is True
372+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
373+
session = response.parse()
374+
assert_matches_type(SessionReleaseAllResponse, session, path=["response"])
375+
376+
@parametrize
377+
def test_streaming_response_release_all(self, client: Steel) -> None:
378+
with client.sessions.with_streaming_response.release_all() as response:
379+
assert not response.is_closed
380+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
381+
382+
session = response.parse()
383+
assert_matches_type(SessionReleaseAllResponse, session, path=["response"])
384+
385+
assert cast(Any, response.is_closed) is True
386+
360387

361388
class TestAsyncSessions:
362389
parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"])
@@ -383,6 +410,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncSteel) ->
383410
is_selenium=True,
384411
namespace="namespace",
385412
proxy_url="https://example.com",
413+
region="lax",
386414
session_context={
387415
"cookies": [
388416
{
@@ -691,3 +719,28 @@ async def test_path_params_release(self, async_client: AsyncSteel) -> None:
691719
await async_client.sessions.with_raw_response.release(
692720
"",
693721
)
722+
723+
@parametrize
724+
async def test_method_release_all(self, async_client: AsyncSteel) -> None:
725+
session = await async_client.sessions.release_all()
726+
assert_matches_type(SessionReleaseAllResponse, session, path=["response"])
727+
728+
@parametrize
729+
async def test_raw_response_release_all(self, async_client: AsyncSteel) -> None:
730+
response = await async_client.sessions.with_raw_response.release_all()
731+
732+
assert response.is_closed is True
733+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
734+
session = await response.parse()
735+
assert_matches_type(SessionReleaseAllResponse, session, path=["response"])
736+
737+
@parametrize
738+
async def test_streaming_response_release_all(self, async_client: AsyncSteel) -> None:
739+
async with async_client.sessions.with_streaming_response.release_all() as response:
740+
assert not response.is_closed
741+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
742+
743+
session = await response.parse()
744+
assert_matches_type(SessionReleaseAllResponse, session, path=["response"])
745+
746+
assert cast(Any, response.is_closed) is True

0 commit comments

Comments
 (0)