Skip to content

feat(api): api update #131

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
configured_endpoints: 18
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/browserbase%2Fbrowserbase-396a2b9092f645c5a9e46a1f3be8c2e45ca9ae079e1d39761eb0a73f56e24b15.yml
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/browserbase%2Fbrowserbase-a42637317cf43a3f4dacf3b88ac09b86e41d4dc44c51140aa92cef99b5d0c02a.yml
10 changes: 8 additions & 2 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,19 @@ Methods:
Types:

```python
from browserbase.types import Session, SessionLiveURLs, SessionCreateResponse, SessionListResponse
from browserbase.types import (
Session,
SessionLiveURLs,
SessionCreateResponse,
SessionRetrieveResponse,
SessionListResponse,
)
```

Methods:

- <code title="post /v1/sessions">client.sessions.<a href="./src/browserbase/resources/sessions/sessions.py">create</a>(\*\*<a href="src/browserbase/types/session_create_params.py">params</a>) -> <a href="./src/browserbase/types/session_create_response.py">SessionCreateResponse</a></code>
- <code title="get /v1/sessions/{id}">client.sessions.<a href="./src/browserbase/resources/sessions/sessions.py">retrieve</a>(id) -> <a href="./src/browserbase/types/session.py">Session</a></code>
- <code title="get /v1/sessions/{id}">client.sessions.<a href="./src/browserbase/resources/sessions/sessions.py">retrieve</a>(id) -> <a href="./src/browserbase/types/session_retrieve_response.py">SessionRetrieveResponse</a></code>
- <code title="post /v1/sessions/{id}">client.sessions.<a href="./src/browserbase/resources/sessions/sessions.py">update</a>(id, \*\*<a href="src/browserbase/types/session_update_params.py">params</a>) -> <a href="./src/browserbase/types/session.py">Session</a></code>
- <code title="get /v1/sessions">client.sessions.<a href="./src/browserbase/resources/sessions/sessions.py">list</a>(\*\*<a href="src/browserbase/types/session_list_params.py">params</a>) -> <a href="./src/browserbase/types/session_list_response.py">SessionListResponse</a></code>
- <code title="get /v1/sessions/{id}/debug">client.sessions.<a href="./src/browserbase/resources/sessions/sessions.py">debug</a>(id) -> <a href="./src/browserbase/types/session_live_urls.py">SessionLiveURLs</a></code>
Expand Down
9 changes: 5 additions & 4 deletions src/browserbase/resources/sessions/sessions.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
from ...types.session_live_urls import SessionLiveURLs
from ...types.session_list_response import SessionListResponse
from ...types.session_create_response import SessionCreateResponse
from ...types.session_retrieve_response import SessionRetrieveResponse

__all__ = ["SessionsResource", "AsyncSessionsResource"]

Expand Down Expand Up @@ -180,7 +181,7 @@ def retrieve(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> Session:
) -> SessionRetrieveResponse:
"""
Session

Expand All @@ -200,7 +201,7 @@ def retrieve(
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
cast_to=Session,
cast_to=SessionRetrieveResponse,
)

def update(
Expand Down Expand Up @@ -451,7 +452,7 @@ async def retrieve(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> Session:
) -> SessionRetrieveResponse:
"""
Session

Expand All @@ -471,7 +472,7 @@ async def retrieve(
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
cast_to=Session,
cast_to=SessionRetrieveResponse,
)

async def update(
Expand Down
1 change: 1 addition & 0 deletions src/browserbase/types/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@
from .context_update_response import ContextUpdateResponse as ContextUpdateResponse
from .extension_create_params import ExtensionCreateParams as ExtensionCreateParams
from .session_create_response import SessionCreateResponse as SessionCreateResponse
from .session_retrieve_response import SessionRetrieveResponse as SessionRetrieveResponse
64 changes: 64 additions & 0 deletions src/browserbase/types/session_retrieve_response.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from typing import Dict, Optional
from datetime import datetime
from typing_extensions import Literal

from pydantic import Field as FieldInfo

from .._models import BaseModel

__all__ = ["SessionRetrieveResponse"]


class SessionRetrieveResponse(BaseModel):
id: str

created_at: datetime = FieldInfo(alias="createdAt")

expires_at: datetime = FieldInfo(alias="expiresAt")

keep_alive: bool = FieldInfo(alias="keepAlive")
"""Indicates if the Session was created to be kept alive upon disconnections"""

project_id: str = FieldInfo(alias="projectId")
"""The Project ID linked to the Session."""

proxy_bytes: int = FieldInfo(alias="proxyBytes")
"""Bytes used via the [Proxy](/features/stealth-mode#proxies-and-residential-ips)"""

region: Literal["us-west-2", "us-east-1", "eu-central-1", "ap-southeast-1"]
"""The region where the Session is running."""

started_at: datetime = FieldInfo(alias="startedAt")

status: Literal["RUNNING", "ERROR", "TIMED_OUT", "COMPLETED"]

updated_at: datetime = FieldInfo(alias="updatedAt")

avg_cpu_usage: Optional[int] = FieldInfo(alias="avgCpuUsage", default=None)
"""CPU used by the Session"""

connect_url: Optional[str] = FieldInfo(alias="connectUrl", default=None)
"""WebSocket URL to connect to the Session."""

context_id: Optional[str] = FieldInfo(alias="contextId", default=None)
"""Optional. The Context linked to the Session."""

ended_at: Optional[datetime] = FieldInfo(alias="endedAt", default=None)

memory_usage: Optional[int] = FieldInfo(alias="memoryUsage", default=None)
"""Memory used by the Session"""

selenium_remote_url: Optional[str] = FieldInfo(alias="seleniumRemoteUrl", default=None)
"""HTTP URL to connect to the Session."""

signing_key: Optional[str] = FieldInfo(alias="signingKey", default=None)
"""Signing key to use when connecting to the Session via HTTP."""

user_metadata: Optional[Dict[str, object]] = FieldInfo(alias="userMetadata", default=None)
"""Arbitrary user metadata to attach to the session.

To learn more about user metadata, see
[User Metadata](/features/sessions#user-metadata).
"""
13 changes: 7 additions & 6 deletions tests/api_resources/test_sessions.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
SessionLiveURLs,
SessionListResponse,
SessionCreateResponse,
SessionRetrieveResponse,
)

base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
Expand Down Expand Up @@ -100,7 +101,7 @@ def test_method_retrieve(self, client: Browserbase) -> None:
session = client.sessions.retrieve(
"id",
)
assert_matches_type(Session, session, path=["response"])
assert_matches_type(SessionRetrieveResponse, session, path=["response"])

@parametrize
def test_raw_response_retrieve(self, client: Browserbase) -> None:
Expand All @@ -111,7 +112,7 @@ def test_raw_response_retrieve(self, client: Browserbase) -> None:
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
session = response.parse()
assert_matches_type(Session, session, path=["response"])
assert_matches_type(SessionRetrieveResponse, session, path=["response"])

@parametrize
def test_streaming_response_retrieve(self, client: Browserbase) -> None:
Expand All @@ -122,7 +123,7 @@ def test_streaming_response_retrieve(self, client: Browserbase) -> None:
assert response.http_request.headers.get("X-Stainless-Lang") == "python"

session = response.parse()
assert_matches_type(Session, session, path=["response"])
assert_matches_type(SessionRetrieveResponse, session, path=["response"])

assert cast(Any, response.is_closed) is True

Expand Down Expand Up @@ -332,7 +333,7 @@ async def test_method_retrieve(self, async_client: AsyncBrowserbase) -> None:
session = await async_client.sessions.retrieve(
"id",
)
assert_matches_type(Session, session, path=["response"])
assert_matches_type(SessionRetrieveResponse, session, path=["response"])

@parametrize
async def test_raw_response_retrieve(self, async_client: AsyncBrowserbase) -> None:
Expand All @@ -343,7 +344,7 @@ async def test_raw_response_retrieve(self, async_client: AsyncBrowserbase) -> No
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
session = await response.parse()
assert_matches_type(Session, session, path=["response"])
assert_matches_type(SessionRetrieveResponse, session, path=["response"])

@parametrize
async def test_streaming_response_retrieve(self, async_client: AsyncBrowserbase) -> None:
Expand All @@ -354,7 +355,7 @@ async def test_streaming_response_retrieve(self, async_client: AsyncBrowserbase)
assert response.http_request.headers.get("X-Stainless-Lang") == "python"

session = await response.parse()
assert_matches_type(Session, session, path=["response"])
assert_matches_type(SessionRetrieveResponse, session, path=["response"])

assert cast(Any, response.is_closed) is True

Expand Down