Skip to content

feat(api): api update #39

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
Oct 29, 2024
Merged
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-873c7106986f864ce293afcccbe32239bc102bb7c1d27acfeafaca3b3e819ee3.yml
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/browserbase%2Fbrowserbase-b341dd9d5bb77c4f217b94b186763e730fd798fbb773a5e90bb4e2a8d4a2c822.yml
5 changes: 3 additions & 2 deletions src/browserbase/resources/sessions/sessions.py
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@

from __future__ import annotations

from typing import Union, Iterable
from typing_extensions import Literal

import httpx
@@ -104,7 +105,7 @@ def create(
browser_settings: session_create_params.BrowserSettings | NotGiven = NOT_GIVEN,
extension_id: str | NotGiven = NOT_GIVEN,
keep_alive: bool | NotGiven = NOT_GIVEN,
proxies: object | NotGiven = NOT_GIVEN,
proxies: Union[bool, Iterable[session_create_params.ProxiesUnionMember1]] | NotGiven = NOT_GIVEN,
region: Literal["us-west-2", "us-east-1", "eu-central-1", "ap-southeast-1"] | NotGiven = NOT_GIVEN,
api_timeout: int | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
@@ -358,7 +359,7 @@ async def create(
browser_settings: session_create_params.BrowserSettings | NotGiven = NOT_GIVEN,
extension_id: str | NotGiven = NOT_GIVEN,
keep_alive: bool | NotGiven = NOT_GIVEN,
proxies: object | NotGiven = NOT_GIVEN,
proxies: Union[bool, Iterable[session_create_params.ProxiesUnionMember1]] | NotGiven = NOT_GIVEN,
region: Literal["us-west-2", "us-east-1", "eu-central-1", "ap-southeast-1"] | NotGiven = NOT_GIVEN,
api_timeout: int | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
63 changes: 60 additions & 3 deletions src/browserbase/types/session_create_params.py
Original file line number Diff line number Diff line change
@@ -2,8 +2,8 @@

from __future__ import annotations

from typing import List
from typing_extensions import Literal, Required, Annotated, TypedDict
from typing import List, Union, Iterable
from typing_extensions import Literal, Required, Annotated, TypeAlias, TypedDict

from .._utils import PropertyInfo

@@ -14,6 +14,10 @@
"BrowserSettingsFingerprint",
"BrowserSettingsFingerprintScreen",
"BrowserSettingsViewport",
"ProxiesUnionMember1",
"ProxiesUnionMember1BrowserbaseProxyConfig",
"ProxiesUnionMember1BrowserbaseProxyConfigGeolocation",
"ProxiesUnionMember1ExternalProxyConfig",
]


@@ -38,7 +42,7 @@ class SessionCreateParams(TypedDict, total=False):
This is available on the Startup plan only.
"""

proxies: object
proxies: Union[bool, Iterable[ProxiesUnionMember1]]
"""Proxy configuration.

Can be true for default proxy, or an array of proxy configurations.
@@ -130,3 +134,56 @@ class BrowserSettings(TypedDict, total=False):
"""Enable or disable captcha solving in the browser. Defaults to `true`."""

viewport: BrowserSettingsViewport


class ProxiesUnionMember1BrowserbaseProxyConfigGeolocation(TypedDict, total=False):
country: Required[str]
"""Country code in ISO 3166-1 alpha-2 format"""

city: str
"""Name of the city. Use spaces for multi-word city names. Optional."""

state: str
"""US state code (2 characters). Must also specify US as the country. Optional."""


class ProxiesUnionMember1BrowserbaseProxyConfig(TypedDict, total=False):
type: Required[Literal["browserbase"]]
"""Type of proxy.

Always use 'browserbase' for the Browserbase managed proxy network.
"""

domain_pattern: Annotated[str, PropertyInfo(alias="domainPattern")]
"""Domain pattern for which this proxy should be used.

If omitted, defaults to all domains. Optional.
"""

geolocation: ProxiesUnionMember1BrowserbaseProxyConfigGeolocation
"""Configuration for geolocation"""


class ProxiesUnionMember1ExternalProxyConfig(TypedDict, total=False):
server: Required[str]
"""Server URL for external proxy. Required."""

type: Required[Literal["external"]]
"""Type of proxy. Always 'external' for this config."""

domain_pattern: Annotated[str, PropertyInfo(alias="domainPattern")]
"""Domain pattern for which this proxy should be used.

If omitted, defaults to all domains. Optional.
"""

password: str
"""Password for external proxy authentication. Optional."""

username: str
"""Username for external proxy authentication. Optional."""


ProxiesUnionMember1: TypeAlias = Union[
ProxiesUnionMember1BrowserbaseProxyConfig, ProxiesUnionMember1ExternalProxyConfig
]
4 changes: 2 additions & 2 deletions tests/api_resources/test_sessions.py
Original file line number Diff line number Diff line change
@@ -63,7 +63,7 @@ def test_method_create_with_all_params(self, client: Browserbase) -> None:
},
extension_id="extensionId",
keep_alive=True,
proxies={},
proxies=True,
region="us-west-2",
api_timeout=60,
)
@@ -292,7 +292,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncBrowserbas
},
extension_id="extensionId",
keep_alive=True,
proxies={},
proxies=True,
region="us-west-2",
api_timeout=60,
)