Skip to content

Commit 3c38bd0

Browse files
feat(api): /browsers no longer requires invocation id
1 parent aa4fd0b commit 3c38bd0

File tree

6 files changed

+22
-47
lines changed

6 files changed

+22
-47
lines changed

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 16
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-2aec229ccf91f7c1ac95aa675ea2a59bd61af9e363a22c3b49677992f1eeb16a.yml
3-
openapi_spec_hash: c80cd5d52a79cd5366a76d4a825bd27a
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-ff8ccba8b5409eaa1128df9027582cb63f66e8accd75e511f70b7c27ef26c9ae.yml
3+
openapi_spec_hash: 1dbacc339695a7c78718f90f791d3f01
44
config_hash: b8e1fff080fbaa22656ab0a57b591777

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,6 @@ from kernel import Kernel
134134
client = Kernel()
135135

136136
browser = client.browsers.create(
137-
invocation_id="rr33xuugxj9h0bkf1rdt2bet",
138137
persistence={"id": "my-awesome-browser-for-user-1234"},
139138
)
140139
print(browser.persistence)

src/kernel/resources/browsers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def with_streaming_response(self) -> BrowsersResourceWithStreamingResponse:
4747
def create(
4848
self,
4949
*,
50-
invocation_id: str,
50+
invocation_id: str | NotGiven = NOT_GIVEN,
5151
persistence: BrowserPersistenceParam | NotGiven = NOT_GIVEN,
5252
stealth: bool | NotGiven = NOT_GIVEN,
5353
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
@@ -240,7 +240,7 @@ def with_streaming_response(self) -> AsyncBrowsersResourceWithStreamingResponse:
240240
async def create(
241241
self,
242242
*,
243-
invocation_id: str,
243+
invocation_id: str | NotGiven = NOT_GIVEN,
244244
persistence: BrowserPersistenceParam | NotGiven = NOT_GIVEN,
245245
stealth: bool | NotGiven = NOT_GIVEN,
246246
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.

src/kernel/types/browser_create_params.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
from __future__ import annotations
44

5-
from typing_extensions import Required, TypedDict
5+
from typing_extensions import TypedDict
66

77
from .browser_persistence_param import BrowserPersistenceParam
88

99
__all__ = ["BrowserCreateParams"]
1010

1111

1212
class BrowserCreateParams(TypedDict, total=False):
13-
invocation_id: Required[str]
13+
invocation_id: str
1414
"""action invocation ID"""
1515

1616
persistence: BrowserPersistenceParam

tests/api_resources/test_browsers.py

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@ class TestBrowsers:
2424
@pytest.mark.skip()
2525
@parametrize
2626
def test_method_create(self, client: Kernel) -> None:
27-
browser = client.browsers.create(
28-
invocation_id="rr33xuugxj9h0bkf1rdt2bet",
29-
)
27+
browser = client.browsers.create()
3028
assert_matches_type(BrowserCreateResponse, browser, path=["response"])
3129

3230
@pytest.mark.skip()
@@ -42,9 +40,7 @@ def test_method_create_with_all_params(self, client: Kernel) -> None:
4240
@pytest.mark.skip()
4341
@parametrize
4442
def test_raw_response_create(self, client: Kernel) -> None:
45-
response = client.browsers.with_raw_response.create(
46-
invocation_id="rr33xuugxj9h0bkf1rdt2bet",
47-
)
43+
response = client.browsers.with_raw_response.create()
4844

4945
assert response.is_closed is True
5046
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
@@ -54,9 +50,7 @@ def test_raw_response_create(self, client: Kernel) -> None:
5450
@pytest.mark.skip()
5551
@parametrize
5652
def test_streaming_response_create(self, client: Kernel) -> None:
57-
with client.browsers.with_streaming_response.create(
58-
invocation_id="rr33xuugxj9h0bkf1rdt2bet",
59-
) as response:
53+
with client.browsers.with_streaming_response.create() as response:
6054
assert not response.is_closed
6155
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
6256

@@ -220,9 +214,7 @@ class TestAsyncBrowsers:
220214
@pytest.mark.skip()
221215
@parametrize
222216
async def test_method_create(self, async_client: AsyncKernel) -> None:
223-
browser = await async_client.browsers.create(
224-
invocation_id="rr33xuugxj9h0bkf1rdt2bet",
225-
)
217+
browser = await async_client.browsers.create()
226218
assert_matches_type(BrowserCreateResponse, browser, path=["response"])
227219

228220
@pytest.mark.skip()
@@ -238,9 +230,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncKernel) ->
238230
@pytest.mark.skip()
239231
@parametrize
240232
async def test_raw_response_create(self, async_client: AsyncKernel) -> None:
241-
response = await async_client.browsers.with_raw_response.create(
242-
invocation_id="rr33xuugxj9h0bkf1rdt2bet",
243-
)
233+
response = await async_client.browsers.with_raw_response.create()
244234

245235
assert response.is_closed is True
246236
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
@@ -250,9 +240,7 @@ async def test_raw_response_create(self, async_client: AsyncKernel) -> None:
250240
@pytest.mark.skip()
251241
@parametrize
252242
async def test_streaming_response_create(self, async_client: AsyncKernel) -> None:
253-
async with async_client.browsers.with_streaming_response.create(
254-
invocation_id="rr33xuugxj9h0bkf1rdt2bet",
255-
) as response:
243+
async with async_client.browsers.with_streaming_response.create() as response:
256244
assert not response.is_closed
257245
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
258246

tests/test_client.py

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -724,7 +724,7 @@ def test_retrying_timeout_errors_doesnt_leak(self, respx_mock: MockRouter, clien
724724
respx_mock.post("/browsers").mock(side_effect=httpx.TimeoutException("Test timeout error"))
725725

726726
with pytest.raises(APITimeoutError):
727-
client.browsers.with_streaming_response.create(invocation_id="rr33xuugxj9h0bkf1rdt2bet").__enter__()
727+
client.browsers.with_streaming_response.create().__enter__()
728728

729729
assert _get_open_connections(self.client) == 0
730730

@@ -735,7 +735,7 @@ def test_retrying_status_errors_doesnt_leak(self, respx_mock: MockRouter, client
735735
respx_mock.post("/browsers").mock(return_value=httpx.Response(500))
736736

737737
with pytest.raises(APIStatusError):
738-
client.browsers.with_streaming_response.create(invocation_id="rr33xuugxj9h0bkf1rdt2bet").__enter__()
738+
client.browsers.with_streaming_response.create().__enter__()
739739
assert _get_open_connections(self.client) == 0
740740

741741
@pytest.mark.parametrize("failures_before_success", [0, 2, 4])
@@ -764,7 +764,7 @@ def retry_handler(_request: httpx.Request) -> httpx.Response:
764764

765765
respx_mock.post("/browsers").mock(side_effect=retry_handler)
766766

767-
response = client.browsers.with_raw_response.create(invocation_id="rr33xuugxj9h0bkf1rdt2bet")
767+
response = client.browsers.with_raw_response.create()
768768

769769
assert response.retries_taken == failures_before_success
770770
assert int(response.http_request.headers.get("x-stainless-retry-count")) == failures_before_success
@@ -788,9 +788,7 @@ def retry_handler(_request: httpx.Request) -> httpx.Response:
788788

789789
respx_mock.post("/browsers").mock(side_effect=retry_handler)
790790

791-
response = client.browsers.with_raw_response.create(
792-
invocation_id="rr33xuugxj9h0bkf1rdt2bet", extra_headers={"x-stainless-retry-count": Omit()}
793-
)
791+
response = client.browsers.with_raw_response.create(extra_headers={"x-stainless-retry-count": Omit()})
794792

795793
assert len(response.http_request.headers.get_list("x-stainless-retry-count")) == 0
796794

@@ -813,9 +811,7 @@ def retry_handler(_request: httpx.Request) -> httpx.Response:
813811

814812
respx_mock.post("/browsers").mock(side_effect=retry_handler)
815813

816-
response = client.browsers.with_raw_response.create(
817-
invocation_id="rr33xuugxj9h0bkf1rdt2bet", extra_headers={"x-stainless-retry-count": "42"}
818-
)
814+
response = client.browsers.with_raw_response.create(extra_headers={"x-stainless-retry-count": "42"})
819815

820816
assert response.http_request.headers.get("x-stainless-retry-count") == "42"
821817

@@ -1555,9 +1551,7 @@ async def test_retrying_timeout_errors_doesnt_leak(self, respx_mock: MockRouter,
15551551
respx_mock.post("/browsers").mock(side_effect=httpx.TimeoutException("Test timeout error"))
15561552

15571553
with pytest.raises(APITimeoutError):
1558-
await async_client.browsers.with_streaming_response.create(
1559-
invocation_id="rr33xuugxj9h0bkf1rdt2bet"
1560-
).__aenter__()
1554+
await async_client.browsers.with_streaming_response.create().__aenter__()
15611555

15621556
assert _get_open_connections(self.client) == 0
15631557

@@ -1568,9 +1562,7 @@ async def test_retrying_status_errors_doesnt_leak(self, respx_mock: MockRouter,
15681562
respx_mock.post("/browsers").mock(return_value=httpx.Response(500))
15691563

15701564
with pytest.raises(APIStatusError):
1571-
await async_client.browsers.with_streaming_response.create(
1572-
invocation_id="rr33xuugxj9h0bkf1rdt2bet"
1573-
).__aenter__()
1565+
await async_client.browsers.with_streaming_response.create().__aenter__()
15741566
assert _get_open_connections(self.client) == 0
15751567

15761568
@pytest.mark.parametrize("failures_before_success", [0, 2, 4])
@@ -1600,7 +1592,7 @@ def retry_handler(_request: httpx.Request) -> httpx.Response:
16001592

16011593
respx_mock.post("/browsers").mock(side_effect=retry_handler)
16021594

1603-
response = await client.browsers.with_raw_response.create(invocation_id="rr33xuugxj9h0bkf1rdt2bet")
1595+
response = await client.browsers.with_raw_response.create()
16041596

16051597
assert response.retries_taken == failures_before_success
16061598
assert int(response.http_request.headers.get("x-stainless-retry-count")) == failures_before_success
@@ -1625,9 +1617,7 @@ def retry_handler(_request: httpx.Request) -> httpx.Response:
16251617

16261618
respx_mock.post("/browsers").mock(side_effect=retry_handler)
16271619

1628-
response = await client.browsers.with_raw_response.create(
1629-
invocation_id="rr33xuugxj9h0bkf1rdt2bet", extra_headers={"x-stainless-retry-count": Omit()}
1630-
)
1620+
response = await client.browsers.with_raw_response.create(extra_headers={"x-stainless-retry-count": Omit()})
16311621

16321622
assert len(response.http_request.headers.get_list("x-stainless-retry-count")) == 0
16331623

@@ -1651,9 +1641,7 @@ def retry_handler(_request: httpx.Request) -> httpx.Response:
16511641

16521642
respx_mock.post("/browsers").mock(side_effect=retry_handler)
16531643

1654-
response = await client.browsers.with_raw_response.create(
1655-
invocation_id="rr33xuugxj9h0bkf1rdt2bet", extra_headers={"x-stainless-retry-count": "42"}
1656-
)
1644+
response = await client.browsers.with_raw_response.create(extra_headers={"x-stainless-retry-count": "42"})
16571645

16581646
assert response.http_request.headers.get("x-stainless-retry-count") == "42"
16591647

0 commit comments

Comments
 (0)