Skip to content

Commit 0bf38d0

Browse files
feat(api): /browsers no longer requires invocation id
1 parent c39bfa6 commit 0bf38d0

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
@@ -723,7 +723,7 @@ def test_retrying_timeout_errors_doesnt_leak(self, respx_mock: MockRouter, clien
723723
respx_mock.post("/browsers").mock(side_effect=httpx.TimeoutException("Test timeout error"))
724724

725725
with pytest.raises(APITimeoutError):
726-
client.browsers.with_streaming_response.create(invocation_id="rr33xuugxj9h0bkf1rdt2bet").__enter__()
726+
client.browsers.with_streaming_response.create().__enter__()
727727

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

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

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

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

763763
respx_mock.post("/browsers").mock(side_effect=retry_handler)
764764

765-
response = client.browsers.with_raw_response.create(invocation_id="rr33xuugxj9h0bkf1rdt2bet")
765+
response = client.browsers.with_raw_response.create()
766766

767767
assert response.retries_taken == failures_before_success
768768
assert int(response.http_request.headers.get("x-stainless-retry-count")) == failures_before_success
@@ -786,9 +786,7 @@ def retry_handler(_request: httpx.Request) -> httpx.Response:
786786

787787
respx_mock.post("/browsers").mock(side_effect=retry_handler)
788788

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

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

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

812810
respx_mock.post("/browsers").mock(side_effect=retry_handler)
813811

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

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

@@ -1552,9 +1548,7 @@ async def test_retrying_timeout_errors_doesnt_leak(self, respx_mock: MockRouter,
15521548
respx_mock.post("/browsers").mock(side_effect=httpx.TimeoutException("Test timeout error"))
15531549

15541550
with pytest.raises(APITimeoutError):
1555-
await async_client.browsers.with_streaming_response.create(
1556-
invocation_id="rr33xuugxj9h0bkf1rdt2bet"
1557-
).__aenter__()
1551+
await async_client.browsers.with_streaming_response.create().__aenter__()
15581552

15591553
assert _get_open_connections(self.client) == 0
15601554

@@ -1564,9 +1558,7 @@ async def test_retrying_status_errors_doesnt_leak(self, respx_mock: MockRouter,
15641558
respx_mock.post("/browsers").mock(return_value=httpx.Response(500))
15651559

15661560
with pytest.raises(APIStatusError):
1567-
await async_client.browsers.with_streaming_response.create(
1568-
invocation_id="rr33xuugxj9h0bkf1rdt2bet"
1569-
).__aenter__()
1561+
await async_client.browsers.with_streaming_response.create().__aenter__()
15701562
assert _get_open_connections(self.client) == 0
15711563

15721564
@pytest.mark.parametrize("failures_before_success", [0, 2, 4])
@@ -1596,7 +1588,7 @@ def retry_handler(_request: httpx.Request) -> httpx.Response:
15961588

15971589
respx_mock.post("/browsers").mock(side_effect=retry_handler)
15981590

1599-
response = await client.browsers.with_raw_response.create(invocation_id="rr33xuugxj9h0bkf1rdt2bet")
1591+
response = await client.browsers.with_raw_response.create()
16001592

16011593
assert response.retries_taken == failures_before_success
16021594
assert int(response.http_request.headers.get("x-stainless-retry-count")) == failures_before_success
@@ -1621,9 +1613,7 @@ def retry_handler(_request: httpx.Request) -> httpx.Response:
16211613

16221614
respx_mock.post("/browsers").mock(side_effect=retry_handler)
16231615

1624-
response = await client.browsers.with_raw_response.create(
1625-
invocation_id="rr33xuugxj9h0bkf1rdt2bet", extra_headers={"x-stainless-retry-count": Omit()}
1626-
)
1616+
response = await client.browsers.with_raw_response.create(extra_headers={"x-stainless-retry-count": Omit()})
16271617

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

@@ -1647,9 +1637,7 @@ def retry_handler(_request: httpx.Request) -> httpx.Response:
16471637

16481638
respx_mock.post("/browsers").mock(side_effect=retry_handler)
16491639

1650-
response = await client.browsers.with_raw_response.create(
1651-
invocation_id="rr33xuugxj9h0bkf1rdt2bet", extra_headers={"x-stainless-retry-count": "42"}
1652-
)
1640+
response = await client.browsers.with_raw_response.create(extra_headers={"x-stainless-retry-count": "42"})
16531641

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

0 commit comments

Comments
 (0)