Skip to content

Commit 72aa790

Browse files
feat(api): api update
1 parent b768b4f commit 72aa790

File tree

4 files changed

+160
-3
lines changed

4 files changed

+160
-3
lines changed

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
configured_endpoints: 18
1+
configured_endpoints: 19
22
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/browserbase%2Fbrowserbase-be7a4aeebb1605262935b4b3ab446a95b1fad8a7d18098943dd548c8a486ef13.yml
33
openapi_spec_hash: 1c950a109f80140711e7ae2cf87fddad
4-
config_hash: b3ca4ec5b02e5333af51ebc2e9fdef1b
4+
config_hash: b01d72cbe03bd762a73b05744086b2ec

api.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Methods:
1111
- <code title="post /v1/contexts">client.contexts.<a href="./src/browserbase/resources/contexts.py">create</a>(\*\*<a href="src/browserbase/types/context_create_params.py">params</a>) -> <a href="./src/browserbase/types/context_create_response.py">ContextCreateResponse</a></code>
1212
- <code title="get /v1/contexts/{id}">client.contexts.<a href="./src/browserbase/resources/contexts.py">retrieve</a>(id) -> <a href="./src/browserbase/types/context_retrieve_response.py">ContextRetrieveResponse</a></code>
1313
- <code title="put /v1/contexts/{id}">client.contexts.<a href="./src/browserbase/resources/contexts.py">update</a>(id) -> <a href="./src/browserbase/types/context_update_response.py">ContextUpdateResponse</a></code>
14+
- <code title="delete /v1/contexts/{id}">client.contexts.<a href="./src/browserbase/resources/contexts.py">delete</a>(id) -> None</code>
1415

1516
# Extensions
1617

src/browserbase/resources/contexts.py

Lines changed: 81 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import httpx
66

77
from ..types import context_create_params
8-
from .._types import Body, Query, Headers, NotGiven, not_given
8+
from .._types import Body, Query, Headers, NoneType, NotGiven, not_given
99
from .._utils import maybe_transform, async_maybe_transform
1010
from .._compat import cached_property
1111
from .._resource import SyncAPIResource, AsyncAPIResource
@@ -145,6 +145,40 @@ def update(
145145
cast_to=ContextUpdateResponse,
146146
)
147147

148+
def delete(
149+
self,
150+
id: str,
151+
*,
152+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
153+
# The extra values given here take precedence over values defined on the client or passed to this method.
154+
extra_headers: Headers | None = None,
155+
extra_query: Query | None = None,
156+
extra_body: Body | None = None,
157+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
158+
) -> None:
159+
"""
160+
Delete a Context
161+
162+
Args:
163+
extra_headers: Send extra headers
164+
165+
extra_query: Add additional query parameters to the request
166+
167+
extra_body: Add additional JSON properties to the request
168+
169+
timeout: Override the client-level default timeout for this request, in seconds
170+
"""
171+
if not id:
172+
raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
173+
extra_headers = {"Accept": "*/*", **(extra_headers or {})}
174+
return self._delete(
175+
f"/v1/contexts/{id}",
176+
options=make_request_options(
177+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
178+
),
179+
cast_to=NoneType,
180+
)
181+
148182

149183
class AsyncContextsResource(AsyncAPIResource):
150184
@cached_property
@@ -268,6 +302,40 @@ async def update(
268302
cast_to=ContextUpdateResponse,
269303
)
270304

305+
async def delete(
306+
self,
307+
id: str,
308+
*,
309+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
310+
# The extra values given here take precedence over values defined on the client or passed to this method.
311+
extra_headers: Headers | None = None,
312+
extra_query: Query | None = None,
313+
extra_body: Body | None = None,
314+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
315+
) -> None:
316+
"""
317+
Delete a Context
318+
319+
Args:
320+
extra_headers: Send extra headers
321+
322+
extra_query: Add additional query parameters to the request
323+
324+
extra_body: Add additional JSON properties to the request
325+
326+
timeout: Override the client-level default timeout for this request, in seconds
327+
"""
328+
if not id:
329+
raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
330+
extra_headers = {"Accept": "*/*", **(extra_headers or {})}
331+
return await self._delete(
332+
f"/v1/contexts/{id}",
333+
options=make_request_options(
334+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
335+
),
336+
cast_to=NoneType,
337+
)
338+
271339

272340
class ContextsResourceWithRawResponse:
273341
def __init__(self, contexts: ContextsResource) -> None:
@@ -282,6 +350,9 @@ def __init__(self, contexts: ContextsResource) -> None:
282350
self.update = to_raw_response_wrapper(
283351
contexts.update,
284352
)
353+
self.delete = to_raw_response_wrapper(
354+
contexts.delete,
355+
)
285356

286357

287358
class AsyncContextsResourceWithRawResponse:
@@ -297,6 +368,9 @@ def __init__(self, contexts: AsyncContextsResource) -> None:
297368
self.update = async_to_raw_response_wrapper(
298369
contexts.update,
299370
)
371+
self.delete = async_to_raw_response_wrapper(
372+
contexts.delete,
373+
)
300374

301375

302376
class ContextsResourceWithStreamingResponse:
@@ -312,6 +386,9 @@ def __init__(self, contexts: ContextsResource) -> None:
312386
self.update = to_streamed_response_wrapper(
313387
contexts.update,
314388
)
389+
self.delete = to_streamed_response_wrapper(
390+
contexts.delete,
391+
)
315392

316393

317394
class AsyncContextsResourceWithStreamingResponse:
@@ -327,3 +404,6 @@ def __init__(self, contexts: AsyncContextsResource) -> None:
327404
self.update = async_to_streamed_response_wrapper(
328405
contexts.update,
329406
)
407+
self.delete = async_to_streamed_response_wrapper(
408+
contexts.delete,
409+
)

tests/api_resources/test_contexts.py

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,44 @@ def test_path_params_update(self, client: Browserbase) -> None:
128128
"",
129129
)
130130

131+
@parametrize
132+
def test_method_delete(self, client: Browserbase) -> None:
133+
context = client.contexts.delete(
134+
"id",
135+
)
136+
assert context is None
137+
138+
@parametrize
139+
def test_raw_response_delete(self, client: Browserbase) -> None:
140+
response = client.contexts.with_raw_response.delete(
141+
"id",
142+
)
143+
144+
assert response.is_closed is True
145+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
146+
context = response.parse()
147+
assert context is None
148+
149+
@parametrize
150+
def test_streaming_response_delete(self, client: Browserbase) -> None:
151+
with client.contexts.with_streaming_response.delete(
152+
"id",
153+
) as response:
154+
assert not response.is_closed
155+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
156+
157+
context = response.parse()
158+
assert context is None
159+
160+
assert cast(Any, response.is_closed) is True
161+
162+
@parametrize
163+
def test_path_params_delete(self, client: Browserbase) -> None:
164+
with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"):
165+
client.contexts.with_raw_response.delete(
166+
"",
167+
)
168+
131169

132170
class TestAsyncContexts:
133171
parametrize = pytest.mark.parametrize(
@@ -240,3 +278,41 @@ async def test_path_params_update(self, async_client: AsyncBrowserbase) -> None:
240278
await async_client.contexts.with_raw_response.update(
241279
"",
242280
)
281+
282+
@parametrize
283+
async def test_method_delete(self, async_client: AsyncBrowserbase) -> None:
284+
context = await async_client.contexts.delete(
285+
"id",
286+
)
287+
assert context is None
288+
289+
@parametrize
290+
async def test_raw_response_delete(self, async_client: AsyncBrowserbase) -> None:
291+
response = await async_client.contexts.with_raw_response.delete(
292+
"id",
293+
)
294+
295+
assert response.is_closed is True
296+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
297+
context = await response.parse()
298+
assert context is None
299+
300+
@parametrize
301+
async def test_streaming_response_delete(self, async_client: AsyncBrowserbase) -> None:
302+
async with async_client.contexts.with_streaming_response.delete(
303+
"id",
304+
) as response:
305+
assert not response.is_closed
306+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
307+
308+
context = await response.parse()
309+
assert context is None
310+
311+
assert cast(Any, response.is_closed) is True
312+
313+
@parametrize
314+
async def test_path_params_delete(self, async_client: AsyncBrowserbase) -> None:
315+
with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"):
316+
await async_client.contexts.with_raw_response.delete(
317+
"",
318+
)

0 commit comments

Comments
 (0)