Skip to content

Commit 1d378d3

Browse files
feat(api): add delete_browsers endpoint
1 parent 10e4c1e commit 1d378d3

File tree

4 files changed

+170
-5
lines changed

4 files changed

+170
-5
lines changed

.stats.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
configured_endpoints: 15
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-5d4e11bc46eeecee7363d56a9dfe946acee997d5b352c2b0a50c20e742c54d2d.yml
3-
openapi_spec_hash: 333e53ad9c706296b9afdb8ff73bec8f
4-
config_hash: 0fdf285ddd8dee229fd84ea57df9080f
1+
configured_endpoints: 16
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-b019e469425a59061f37c5fdc7a131a5291c66134ef0627db4f06bb1f4af0b15.yml
3+
openapi_spec_hash: f66a3c2efddb168db9539ba2507b10b8
4+
config_hash: aae6721b2be9ec8565dfc8f7eadfe105

api.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ Methods:
6767
- <code title="post /invocations">client.invocations.<a href="./src/kernel/resources/invocations.py">create</a>(\*\*<a href="src/kernel/types/invocation_create_params.py">params</a>) -> <a href="./src/kernel/types/invocation_create_response.py">InvocationCreateResponse</a></code>
6868
- <code title="get /invocations/{id}">client.invocations.<a href="./src/kernel/resources/invocations.py">retrieve</a>(id) -> <a href="./src/kernel/types/invocation_retrieve_response.py">InvocationRetrieveResponse</a></code>
6969
- <code title="patch /invocations/{id}">client.invocations.<a href="./src/kernel/resources/invocations.py">update</a>(id, \*\*<a href="src/kernel/types/invocation_update_params.py">params</a>) -> <a href="./src/kernel/types/invocation_update_response.py">InvocationUpdateResponse</a></code>
70+
- <code title="delete /invocations/{id}/browsers">client.invocations.<a href="./src/kernel/resources/invocations.py">delete_browsers</a>(id) -> None</code>
7071
- <code title="get /invocations/{id}/events">client.invocations.<a href="./src/kernel/resources/invocations.py">follow</a>(id) -> <a href="./src/kernel/types/invocation_follow_response.py">InvocationFollowResponse</a></code>
7172

7273
# Browsers

src/kernel/resources/invocations.py

Lines changed: 81 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import httpx
99

1010
from ..types import invocation_create_params, invocation_update_params
11-
from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven
11+
from .._types import NOT_GIVEN, Body, Query, Headers, NoneType, NotGiven
1212
from .._utils import maybe_transform, async_maybe_transform
1313
from .._compat import cached_property
1414
from .._resource import SyncAPIResource, AsyncAPIResource
@@ -183,6 +183,40 @@ def update(
183183
cast_to=InvocationUpdateResponse,
184184
)
185185

186+
def delete_browsers(
187+
self,
188+
id: str,
189+
*,
190+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
191+
# The extra values given here take precedence over values defined on the client or passed to this method.
192+
extra_headers: Headers | None = None,
193+
extra_query: Query | None = None,
194+
extra_body: Body | None = None,
195+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
196+
) -> None:
197+
"""
198+
Delete all browser sessions created within the specified invocation.
199+
200+
Args:
201+
extra_headers: Send extra headers
202+
203+
extra_query: Add additional query parameters to the request
204+
205+
extra_body: Add additional JSON properties to the request
206+
207+
timeout: Override the client-level default timeout for this request, in seconds
208+
"""
209+
if not id:
210+
raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
211+
extra_headers = {"Accept": "*/*", **(extra_headers or {})}
212+
return self._delete(
213+
f"/invocations/{id}/browsers",
214+
options=make_request_options(
215+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
216+
),
217+
cast_to=NoneType,
218+
)
219+
186220
def follow(
187221
self,
188222
id: str,
@@ -379,6 +413,40 @@ async def update(
379413
cast_to=InvocationUpdateResponse,
380414
)
381415

416+
async def delete_browsers(
417+
self,
418+
id: str,
419+
*,
420+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
421+
# The extra values given here take precedence over values defined on the client or passed to this method.
422+
extra_headers: Headers | None = None,
423+
extra_query: Query | None = None,
424+
extra_body: Body | None = None,
425+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
426+
) -> None:
427+
"""
428+
Delete all browser sessions created within the specified invocation.
429+
430+
Args:
431+
extra_headers: Send extra headers
432+
433+
extra_query: Add additional query parameters to the request
434+
435+
extra_body: Add additional JSON properties to the request
436+
437+
timeout: Override the client-level default timeout for this request, in seconds
438+
"""
439+
if not id:
440+
raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
441+
extra_headers = {"Accept": "*/*", **(extra_headers or {})}
442+
return await self._delete(
443+
f"/invocations/{id}/browsers",
444+
options=make_request_options(
445+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
446+
),
447+
cast_to=NoneType,
448+
)
449+
382450
async def follow(
383451
self,
384452
id: str,
@@ -433,6 +501,9 @@ def __init__(self, invocations: InvocationsResource) -> None:
433501
self.update = to_raw_response_wrapper(
434502
invocations.update,
435503
)
504+
self.delete_browsers = to_raw_response_wrapper(
505+
invocations.delete_browsers,
506+
)
436507
self.follow = to_raw_response_wrapper(
437508
invocations.follow,
438509
)
@@ -451,6 +522,9 @@ def __init__(self, invocations: AsyncInvocationsResource) -> None:
451522
self.update = async_to_raw_response_wrapper(
452523
invocations.update,
453524
)
525+
self.delete_browsers = async_to_raw_response_wrapper(
526+
invocations.delete_browsers,
527+
)
454528
self.follow = async_to_raw_response_wrapper(
455529
invocations.follow,
456530
)
@@ -469,6 +543,9 @@ def __init__(self, invocations: InvocationsResource) -> None:
469543
self.update = to_streamed_response_wrapper(
470544
invocations.update,
471545
)
546+
self.delete_browsers = to_streamed_response_wrapper(
547+
invocations.delete_browsers,
548+
)
472549
self.follow = to_streamed_response_wrapper(
473550
invocations.follow,
474551
)
@@ -487,6 +564,9 @@ def __init__(self, invocations: AsyncInvocationsResource) -> None:
487564
self.update = async_to_streamed_response_wrapper(
488565
invocations.update,
489566
)
567+
self.delete_browsers = async_to_streamed_response_wrapper(
568+
invocations.delete_browsers,
569+
)
490570
self.follow = async_to_streamed_response_wrapper(
491571
invocations.follow,
492572
)

tests/api_resources/test_invocations.py

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,48 @@ def test_path_params_update(self, client: Kernel) -> None:
171171
status="succeeded",
172172
)
173173

174+
@pytest.mark.skip()
175+
@parametrize
176+
def test_method_delete_browsers(self, client: Kernel) -> None:
177+
invocation = client.invocations.delete_browsers(
178+
"id",
179+
)
180+
assert invocation is None
181+
182+
@pytest.mark.skip()
183+
@parametrize
184+
def test_raw_response_delete_browsers(self, client: Kernel) -> None:
185+
response = client.invocations.with_raw_response.delete_browsers(
186+
"id",
187+
)
188+
189+
assert response.is_closed is True
190+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
191+
invocation = response.parse()
192+
assert invocation is None
193+
194+
@pytest.mark.skip()
195+
@parametrize
196+
def test_streaming_response_delete_browsers(self, client: Kernel) -> None:
197+
with client.invocations.with_streaming_response.delete_browsers(
198+
"id",
199+
) as response:
200+
assert not response.is_closed
201+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
202+
203+
invocation = response.parse()
204+
assert invocation is None
205+
206+
assert cast(Any, response.is_closed) is True
207+
208+
@pytest.mark.skip()
209+
@parametrize
210+
def test_path_params_delete_browsers(self, client: Kernel) -> None:
211+
with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"):
212+
client.invocations.with_raw_response.delete_browsers(
213+
"",
214+
)
215+
174216
@pytest.mark.skip(
175217
reason="currently no good way to test endpoints with content type text/event-stream, Prism mock server will fail"
176218
)
@@ -374,6 +416,48 @@ async def test_path_params_update(self, async_client: AsyncKernel) -> None:
374416
status="succeeded",
375417
)
376418

419+
@pytest.mark.skip()
420+
@parametrize
421+
async def test_method_delete_browsers(self, async_client: AsyncKernel) -> None:
422+
invocation = await async_client.invocations.delete_browsers(
423+
"id",
424+
)
425+
assert invocation is None
426+
427+
@pytest.mark.skip()
428+
@parametrize
429+
async def test_raw_response_delete_browsers(self, async_client: AsyncKernel) -> None:
430+
response = await async_client.invocations.with_raw_response.delete_browsers(
431+
"id",
432+
)
433+
434+
assert response.is_closed is True
435+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
436+
invocation = await response.parse()
437+
assert invocation is None
438+
439+
@pytest.mark.skip()
440+
@parametrize
441+
async def test_streaming_response_delete_browsers(self, async_client: AsyncKernel) -> None:
442+
async with async_client.invocations.with_streaming_response.delete_browsers(
443+
"id",
444+
) as response:
445+
assert not response.is_closed
446+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
447+
448+
invocation = await response.parse()
449+
assert invocation is None
450+
451+
assert cast(Any, response.is_closed) is True
452+
453+
@pytest.mark.skip()
454+
@parametrize
455+
async def test_path_params_delete_browsers(self, async_client: AsyncKernel) -> None:
456+
with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"):
457+
await async_client.invocations.with_raw_response.delete_browsers(
458+
"",
459+
)
460+
377461
@pytest.mark.skip(
378462
reason="currently no good way to test endpoints with content type text/event-stream, Prism mock server will fail"
379463
)

0 commit comments

Comments
 (0)