From 796e3d9b6cba38cc477a45719f6f7e5b76b75e43 Mon Sep 17 00:00:00 2001 From: stainless-bot Date: Tue, 29 Oct 2024 04:43:03 +0000 Subject: [PATCH] feat(api): api update --- .stats.yml | 2 +- .../resources/sessions/sessions.py | 5 +- .../types/session_create_params.py | 63 ++++++++++++++++++- tests/api_resources/test_sessions.py | 4 +- 4 files changed, 66 insertions(+), 8 deletions(-) diff --git a/.stats.yml b/.stats.yml index 26fe273..1a6b2b5 100644 --- a/.stats.yml +++ b/.stats.yml @@ -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 diff --git a/src/browserbase/resources/sessions/sessions.py b/src/browserbase/resources/sessions/sessions.py index d298c01..e05a0de 100644 --- a/src/browserbase/resources/sessions/sessions.py +++ b/src/browserbase/resources/sessions/sessions.py @@ -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. diff --git a/src/browserbase/types/session_create_params.py b/src/browserbase/types/session_create_params.py index 3b1920a..bd643b3 100644 --- a/src/browserbase/types/session_create_params.py +++ b/src/browserbase/types/session_create_params.py @@ -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 +] diff --git a/tests/api_resources/test_sessions.py b/tests/api_resources/test_sessions.py index dadadd4..8ebd5da 100644 --- a/tests/api_resources/test_sessions.py +++ b/tests/api_resources/test_sessions.py @@ -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, )