Skip to content

Commit f781a02

Browse files
chore(api): update composite API spec
1 parent 3ebe4bc commit f781a02

15 files changed

Lines changed: 292 additions & 41 deletions

File tree

.stats.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
configured_endpoints: 2184
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-95d8075980561cae9cc6ce09b5f930b84eae6f0864cb155abe47db94df2ee294.yml
3-
openapi_spec_hash: 056ce7b95f00677a933e6da00b21c37c
1+
configured_endpoints: 2185
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-8afbe34627bb47c62422bcfe82d49e1ab7e5ea8e2f0d655a6a0ba3e4648c5e47.yml
3+
openapi_spec_hash: 5a1a5d008c6f779c308ac0ae5a096de0
44
config_hash: 95239e8fc62638979bc21e538307bbe3

src/cloudflare/resources/browser_rendering/api.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ from cloudflare.types.browser_rendering.devtools.browser import (
160160
TargetCreateResponse,
161161
TargetListResponse,
162162
TargetActivateResponse,
163+
TargetCloseResponse,
163164
TargetGetResponse,
164165
)
165166
```
@@ -169,4 +170,5 @@ Methods:
169170
- <code title="put /accounts/{account_id}/browser-rendering/devtools/browser/{session_id}/json/new">client.browser_rendering.devtools.browser.targets.<a href="./src/cloudflare/resources/browser_rendering/devtools/browser/targets.py">create</a>(session_id, \*, account_id, \*\*<a href="src/cloudflare/types/browser_rendering/devtools/browser/target_create_params.py">params</a>) -> <a href="./src/cloudflare/types/browser_rendering/devtools/browser/target_create_response.py">TargetCreateResponse</a></code>
170171
- <code title="get /accounts/{account_id}/browser-rendering/devtools/browser/{session_id}/json/list">client.browser_rendering.devtools.browser.targets.<a href="./src/cloudflare/resources/browser_rendering/devtools/browser/targets.py">list</a>(session_id, \*, account_id) -> <a href="./src/cloudflare/types/browser_rendering/devtools/browser/target_list_response.py">TargetListResponse</a></code>
171172
- <code title="get /accounts/{account_id}/browser-rendering/devtools/browser/{session_id}/json/activate/{target_id}">client.browser_rendering.devtools.browser.targets.<a href="./src/cloudflare/resources/browser_rendering/devtools/browser/targets.py">activate</a>(target_id, \*, account_id, session_id) -> <a href="./src/cloudflare/types/browser_rendering/devtools/browser/target_activate_response.py">TargetActivateResponse</a></code>
173+
- <code title="get /accounts/{account_id}/browser-rendering/devtools/browser/{session_id}/json/close/{target_id}">client.browser_rendering.devtools.browser.targets.<a href="./src/cloudflare/resources/browser_rendering/devtools/browser/targets.py">close</a>(target_id, \*, account_id, session_id) -> <a href="./src/cloudflare/types/browser_rendering/devtools/browser/target_close_response.py">TargetCloseResponse</a></code>
172174
- <code title="get /accounts/{account_id}/browser-rendering/devtools/browser/{session_id}/json/list/{target_id}">client.browser_rendering.devtools.browser.targets.<a href="./src/cloudflare/resources/browser_rendering/devtools/browser/targets.py">get</a>(target_id, \*, account_id, session_id) -> <a href="./src/cloudflare/types/browser_rendering/devtools/browser/target_get_response.py">TargetGetResponse</a></code>

src/cloudflare/resources/browser_rendering/devtools/browser/targets.py

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
from .....types.browser_rendering.devtools.browser import target_create_params
1919
from .....types.browser_rendering.devtools.browser.target_get_response import TargetGetResponse
2020
from .....types.browser_rendering.devtools.browser.target_list_response import TargetListResponse
21+
from .....types.browser_rendering.devtools.browser.target_close_response import TargetCloseResponse
2122
from .....types.browser_rendering.devtools.browser.target_create_response import TargetCreateResponse
2223
from .....types.browser_rendering.devtools.browser.target_activate_response import TargetActivateResponse
2324

@@ -189,6 +190,58 @@ def activate(
189190
cast_to=TargetActivateResponse,
190191
)
191192

193+
def close(
194+
self,
195+
target_id: str,
196+
*,
197+
account_id: str,
198+
session_id: str,
199+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
200+
# The extra values given here take precedence over values defined on the client or passed to this method.
201+
extra_headers: Headers | None = None,
202+
extra_query: Query | None = None,
203+
extra_body: Body | None = None,
204+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
205+
) -> TargetCloseResponse:
206+
"""Closes a specific browser target (tab, page, etc.) by its ID.
207+
208+
Returns 'Target is
209+
closing' on success or an error if the target is not found.
210+
211+
Args:
212+
account_id: Account ID.
213+
214+
session_id: Browser session ID.
215+
216+
target_id: Target ID to close.
217+
218+
extra_headers: Send extra headers
219+
220+
extra_query: Add additional query parameters to the request
221+
222+
extra_body: Add additional JSON properties to the request
223+
224+
timeout: Override the client-level default timeout for this request, in seconds
225+
"""
226+
if not account_id:
227+
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
228+
if not session_id:
229+
raise ValueError(f"Expected a non-empty value for `session_id` but received {session_id!r}")
230+
if not target_id:
231+
raise ValueError(f"Expected a non-empty value for `target_id` but received {target_id!r}")
232+
return self._get(
233+
path_template(
234+
"/accounts/{account_id}/browser-rendering/devtools/browser/{session_id}/json/close/{target_id}",
235+
account_id=account_id,
236+
session_id=session_id,
237+
target_id=target_id,
238+
),
239+
options=make_request_options(
240+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
241+
),
242+
cast_to=TargetCloseResponse,
243+
)
244+
192245
def get(
193246
self,
194247
target_id: str,
@@ -405,6 +458,58 @@ async def activate(
405458
cast_to=TargetActivateResponse,
406459
)
407460

461+
async def close(
462+
self,
463+
target_id: str,
464+
*,
465+
account_id: str,
466+
session_id: str,
467+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
468+
# The extra values given here take precedence over values defined on the client or passed to this method.
469+
extra_headers: Headers | None = None,
470+
extra_query: Query | None = None,
471+
extra_body: Body | None = None,
472+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
473+
) -> TargetCloseResponse:
474+
"""Closes a specific browser target (tab, page, etc.) by its ID.
475+
476+
Returns 'Target is
477+
closing' on success or an error if the target is not found.
478+
479+
Args:
480+
account_id: Account ID.
481+
482+
session_id: Browser session ID.
483+
484+
target_id: Target ID to close.
485+
486+
extra_headers: Send extra headers
487+
488+
extra_query: Add additional query parameters to the request
489+
490+
extra_body: Add additional JSON properties to the request
491+
492+
timeout: Override the client-level default timeout for this request, in seconds
493+
"""
494+
if not account_id:
495+
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
496+
if not session_id:
497+
raise ValueError(f"Expected a non-empty value for `session_id` but received {session_id!r}")
498+
if not target_id:
499+
raise ValueError(f"Expected a non-empty value for `target_id` but received {target_id!r}")
500+
return await self._get(
501+
path_template(
502+
"/accounts/{account_id}/browser-rendering/devtools/browser/{session_id}/json/close/{target_id}",
503+
account_id=account_id,
504+
session_id=session_id,
505+
target_id=target_id,
506+
),
507+
options=make_request_options(
508+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
509+
),
510+
cast_to=TargetCloseResponse,
511+
)
512+
408513
async def get(
409514
self,
410515
target_id: str,
@@ -469,6 +574,9 @@ def __init__(self, targets: TargetsResource) -> None:
469574
self.activate = to_raw_response_wrapper(
470575
targets.activate,
471576
)
577+
self.close = to_raw_response_wrapper(
578+
targets.close,
579+
)
472580
self.get = to_raw_response_wrapper(
473581
targets.get,
474582
)
@@ -487,6 +595,9 @@ def __init__(self, targets: AsyncTargetsResource) -> None:
487595
self.activate = async_to_raw_response_wrapper(
488596
targets.activate,
489597
)
598+
self.close = async_to_raw_response_wrapper(
599+
targets.close,
600+
)
490601
self.get = async_to_raw_response_wrapper(
491602
targets.get,
492603
)
@@ -505,6 +616,9 @@ def __init__(self, targets: TargetsResource) -> None:
505616
self.activate = to_streamed_response_wrapper(
506617
targets.activate,
507618
)
619+
self.close = to_streamed_response_wrapper(
620+
targets.close,
621+
)
508622
self.get = to_streamed_response_wrapper(
509623
targets.get,
510624
)
@@ -523,6 +637,9 @@ def __init__(self, targets: AsyncTargetsResource) -> None:
523637
self.activate = async_to_streamed_response_wrapper(
524638
targets.activate,
525639
)
640+
self.close = async_to_streamed_response_wrapper(
641+
targets.close,
642+
)
526643
self.get = async_to_streamed_response_wrapper(
527644
targets.get,
528645
)

src/cloudflare/types/browser_rendering/devtools/browser/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@
55
from .target_get_response import TargetGetResponse as TargetGetResponse
66
from .target_create_params import TargetCreateParams as TargetCreateParams
77
from .target_list_response import TargetListResponse as TargetListResponse
8+
from .target_close_response import TargetCloseResponse as TargetCloseResponse
89
from .target_create_response import TargetCreateResponse as TargetCreateResponse
910
from .target_activate_response import TargetActivateResponse as TargetActivateResponse
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
from ....._models import BaseModel
4+
5+
__all__ = ["TargetCloseResponse"]
6+
7+
8+
class TargetCloseResponse(BaseModel):
9+
message: str
10+
"""Target is closing."""

tests/api_resources/browser_rendering/devtools/browser/test_targets.py

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from cloudflare.types.browser_rendering.devtools.browser import (
1313
TargetGetResponse,
1414
TargetListResponse,
15+
TargetCloseResponse,
1516
TargetCreateResponse,
1617
TargetActivateResponse,
1718
)
@@ -187,6 +188,66 @@ def test_path_params_activate(self, client: Cloudflare) -> None:
187188
session_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
188189
)
189190

191+
@parametrize
192+
def test_method_close(self, client: Cloudflare) -> None:
193+
target = client.browser_rendering.devtools.browser.targets.close(
194+
target_id="target_id",
195+
account_id="account_id",
196+
session_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
197+
)
198+
assert_matches_type(TargetCloseResponse, target, path=["response"])
199+
200+
@parametrize
201+
def test_raw_response_close(self, client: Cloudflare) -> None:
202+
response = client.browser_rendering.devtools.browser.targets.with_raw_response.close(
203+
target_id="target_id",
204+
account_id="account_id",
205+
session_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
206+
)
207+
208+
assert response.is_closed is True
209+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
210+
target = response.parse()
211+
assert_matches_type(TargetCloseResponse, target, path=["response"])
212+
213+
@parametrize
214+
def test_streaming_response_close(self, client: Cloudflare) -> None:
215+
with client.browser_rendering.devtools.browser.targets.with_streaming_response.close(
216+
target_id="target_id",
217+
account_id="account_id",
218+
session_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
219+
) as response:
220+
assert not response.is_closed
221+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
222+
223+
target = response.parse()
224+
assert_matches_type(TargetCloseResponse, target, path=["response"])
225+
226+
assert cast(Any, response.is_closed) is True
227+
228+
@parametrize
229+
def test_path_params_close(self, client: Cloudflare) -> None:
230+
with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
231+
client.browser_rendering.devtools.browser.targets.with_raw_response.close(
232+
target_id="target_id",
233+
account_id="",
234+
session_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
235+
)
236+
237+
with pytest.raises(ValueError, match=r"Expected a non-empty value for `session_id` but received ''"):
238+
client.browser_rendering.devtools.browser.targets.with_raw_response.close(
239+
target_id="target_id",
240+
account_id="account_id",
241+
session_id="",
242+
)
243+
244+
with pytest.raises(ValueError, match=r"Expected a non-empty value for `target_id` but received ''"):
245+
client.browser_rendering.devtools.browser.targets.with_raw_response.close(
246+
target_id="",
247+
account_id="account_id",
248+
session_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
249+
)
250+
190251
@parametrize
191252
def test_method_get(self, client: Cloudflare) -> None:
192253
target = client.browser_rendering.devtools.browser.targets.get(
@@ -418,6 +479,66 @@ async def test_path_params_activate(self, async_client: AsyncCloudflare) -> None
418479
session_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
419480
)
420481

482+
@parametrize
483+
async def test_method_close(self, async_client: AsyncCloudflare) -> None:
484+
target = await async_client.browser_rendering.devtools.browser.targets.close(
485+
target_id="target_id",
486+
account_id="account_id",
487+
session_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
488+
)
489+
assert_matches_type(TargetCloseResponse, target, path=["response"])
490+
491+
@parametrize
492+
async def test_raw_response_close(self, async_client: AsyncCloudflare) -> None:
493+
response = await async_client.browser_rendering.devtools.browser.targets.with_raw_response.close(
494+
target_id="target_id",
495+
account_id="account_id",
496+
session_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
497+
)
498+
499+
assert response.is_closed is True
500+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
501+
target = await response.parse()
502+
assert_matches_type(TargetCloseResponse, target, path=["response"])
503+
504+
@parametrize
505+
async def test_streaming_response_close(self, async_client: AsyncCloudflare) -> None:
506+
async with async_client.browser_rendering.devtools.browser.targets.with_streaming_response.close(
507+
target_id="target_id",
508+
account_id="account_id",
509+
session_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
510+
) as response:
511+
assert not response.is_closed
512+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
513+
514+
target = await response.parse()
515+
assert_matches_type(TargetCloseResponse, target, path=["response"])
516+
517+
assert cast(Any, response.is_closed) is True
518+
519+
@parametrize
520+
async def test_path_params_close(self, async_client: AsyncCloudflare) -> None:
521+
with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
522+
await async_client.browser_rendering.devtools.browser.targets.with_raw_response.close(
523+
target_id="target_id",
524+
account_id="",
525+
session_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
526+
)
527+
528+
with pytest.raises(ValueError, match=r"Expected a non-empty value for `session_id` but received ''"):
529+
await async_client.browser_rendering.devtools.browser.targets.with_raw_response.close(
530+
target_id="target_id",
531+
account_id="account_id",
532+
session_id="",
533+
)
534+
535+
with pytest.raises(ValueError, match=r"Expected a non-empty value for `target_id` but received ''"):
536+
await async_client.browser_rendering.devtools.browser.targets.with_raw_response.close(
537+
target_id="",
538+
account_id="account_id",
539+
session_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
540+
)
541+
421542
@parametrize
422543
async def test_method_get(self, async_client: AsyncCloudflare) -> None:
423544
target = await async_client.browser_rendering.devtools.browser.targets.get(

tests/api_resources/browser_rendering/test_content.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def test_method_create_with_all_params_overload_1(self, client: Cloudflare) -> N
2929
content = client.browser_rendering.content.create(
3030
account_id="account_id",
3131
url="https://example.com/",
32-
cache_ttl=86400,
32+
cache_ttl=0,
3333
action_timeout=120000,
3434
add_script_tag=[
3535
{
@@ -147,7 +147,7 @@ def test_method_create_with_all_params_overload_2(self, client: Cloudflare) -> N
147147
content = client.browser_rendering.content.create(
148148
account_id="account_id",
149149
html="<h1>Hello World!</h1>",
150-
cache_ttl=86400,
150+
cache_ttl=0,
151151
action_timeout=120000,
152152
add_script_tag=[
153153
{
@@ -271,7 +271,7 @@ async def test_method_create_with_all_params_overload_1(self, async_client: Asyn
271271
content = await async_client.browser_rendering.content.create(
272272
account_id="account_id",
273273
url="https://example.com/",
274-
cache_ttl=86400,
274+
cache_ttl=0,
275275
action_timeout=120000,
276276
add_script_tag=[
277277
{
@@ -389,7 +389,7 @@ async def test_method_create_with_all_params_overload_2(self, async_client: Asyn
389389
content = await async_client.browser_rendering.content.create(
390390
account_id="account_id",
391391
html="<h1>Hello World!</h1>",
392-
cache_ttl=86400,
392+
cache_ttl=0,
393393
action_timeout=120000,
394394
add_script_tag=[
395395
{

0 commit comments

Comments
 (0)