|
3 | 3 | from __future__ import annotations |
4 | 4 |
|
5 | 5 | import typing_extensions |
6 | | -from typing import Mapping, Iterable, Optional, cast |
| 6 | +from typing import Dict, Mapping, Iterable, Optional, cast |
7 | 7 | from typing_extensions import Literal |
8 | 8 |
|
9 | 9 | import httpx |
|
25 | 25 | AsyncFsResourceWithStreamingResponse, |
26 | 26 | ) |
27 | 27 | from ...types import ( |
| 28 | + browser_curl_params, |
28 | 29 | browser_list_params, |
29 | 30 | browser_create_params, |
30 | 31 | browser_delete_params, |
|
76 | 77 | ) |
77 | 78 | from ...pagination import SyncOffsetPagination, AsyncOffsetPagination |
78 | 79 | from ..._base_client import AsyncPaginator, make_request_options |
| 80 | +from ...types.browser_curl_response import BrowserCurlResponse |
79 | 81 | from ...types.browser_list_response import BrowserListResponse |
80 | 82 | from ...types.browser_create_response import BrowserCreateResponse |
81 | 83 | from ...types.browser_update_response import BrowserUpdateResponse |
@@ -443,6 +445,70 @@ def delete( |
443 | 445 | cast_to=NoneType, |
444 | 446 | ) |
445 | 447 |
|
| 448 | + def curl( |
| 449 | + self, |
| 450 | + id: str, |
| 451 | + *, |
| 452 | + url: str, |
| 453 | + body: str | Omit = omit, |
| 454 | + headers: Dict[str, str] | Omit = omit, |
| 455 | + method: Literal["GET", "HEAD", "POST", "PUT", "PATCH", "DELETE", "OPTIONS"] | Omit = omit, |
| 456 | + response_encoding: Literal["utf8", "base64"] | Omit = omit, |
| 457 | + timeout_ms: int | Omit = omit, |
| 458 | + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 459 | + # The extra values given here take precedence over values defined on the client or passed to this method. |
| 460 | + extra_headers: Headers | None = None, |
| 461 | + extra_query: Query | None = None, |
| 462 | + extra_body: Body | None = None, |
| 463 | + timeout: float | httpx.Timeout | None | NotGiven = not_given, |
| 464 | + ) -> BrowserCurlResponse: |
| 465 | + """ |
| 466 | + Sends an HTTP request through Chrome's HTTP request stack, inheriting the |
| 467 | + browser's TLS fingerprint, cookies, proxy configuration, and headers. Returns a |
| 468 | + structured JSON response with status, headers, body, and timing. |
| 469 | +
|
| 470 | + Args: |
| 471 | + url: Target URL (must be http or https). |
| 472 | +
|
| 473 | + body: Request body (for POST/PUT/PATCH). |
| 474 | +
|
| 475 | + headers: Custom headers merged with browser defaults. |
| 476 | +
|
| 477 | + method: HTTP method. |
| 478 | +
|
| 479 | + response_encoding: Encoding for the response body. Use base64 for binary content. |
| 480 | +
|
| 481 | + timeout_ms: Request timeout in milliseconds. |
| 482 | +
|
| 483 | + extra_headers: Send extra headers |
| 484 | +
|
| 485 | + extra_query: Add additional query parameters to the request |
| 486 | +
|
| 487 | + extra_body: Add additional JSON properties to the request |
| 488 | +
|
| 489 | + timeout: Override the client-level default timeout for this request, in seconds |
| 490 | + """ |
| 491 | + if not id: |
| 492 | + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") |
| 493 | + return self._post( |
| 494 | + path_template("/browsers/{id}/curl", id=id), |
| 495 | + body=maybe_transform( |
| 496 | + { |
| 497 | + "url": url, |
| 498 | + "body": body, |
| 499 | + "headers": headers, |
| 500 | + "method": method, |
| 501 | + "response_encoding": response_encoding, |
| 502 | + "timeout_ms": timeout_ms, |
| 503 | + }, |
| 504 | + browser_curl_params.BrowserCurlParams, |
| 505 | + ), |
| 506 | + options=make_request_options( |
| 507 | + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout |
| 508 | + ), |
| 509 | + cast_to=BrowserCurlResponse, |
| 510 | + ) |
| 511 | + |
446 | 512 | def delete_by_id( |
447 | 513 | self, |
448 | 514 | id: str, |
@@ -881,6 +947,70 @@ async def delete( |
881 | 947 | cast_to=NoneType, |
882 | 948 | ) |
883 | 949 |
|
| 950 | + async def curl( |
| 951 | + self, |
| 952 | + id: str, |
| 953 | + *, |
| 954 | + url: str, |
| 955 | + body: str | Omit = omit, |
| 956 | + headers: Dict[str, str] | Omit = omit, |
| 957 | + method: Literal["GET", "HEAD", "POST", "PUT", "PATCH", "DELETE", "OPTIONS"] | Omit = omit, |
| 958 | + response_encoding: Literal["utf8", "base64"] | Omit = omit, |
| 959 | + timeout_ms: int | Omit = omit, |
| 960 | + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 961 | + # The extra values given here take precedence over values defined on the client or passed to this method. |
| 962 | + extra_headers: Headers | None = None, |
| 963 | + extra_query: Query | None = None, |
| 964 | + extra_body: Body | None = None, |
| 965 | + timeout: float | httpx.Timeout | None | NotGiven = not_given, |
| 966 | + ) -> BrowserCurlResponse: |
| 967 | + """ |
| 968 | + Sends an HTTP request through Chrome's HTTP request stack, inheriting the |
| 969 | + browser's TLS fingerprint, cookies, proxy configuration, and headers. Returns a |
| 970 | + structured JSON response with status, headers, body, and timing. |
| 971 | +
|
| 972 | + Args: |
| 973 | + url: Target URL (must be http or https). |
| 974 | +
|
| 975 | + body: Request body (for POST/PUT/PATCH). |
| 976 | +
|
| 977 | + headers: Custom headers merged with browser defaults. |
| 978 | +
|
| 979 | + method: HTTP method. |
| 980 | +
|
| 981 | + response_encoding: Encoding for the response body. Use base64 for binary content. |
| 982 | +
|
| 983 | + timeout_ms: Request timeout in milliseconds. |
| 984 | +
|
| 985 | + extra_headers: Send extra headers |
| 986 | +
|
| 987 | + extra_query: Add additional query parameters to the request |
| 988 | +
|
| 989 | + extra_body: Add additional JSON properties to the request |
| 990 | +
|
| 991 | + timeout: Override the client-level default timeout for this request, in seconds |
| 992 | + """ |
| 993 | + if not id: |
| 994 | + raise ValueError(f"Expected a non-empty value for `id` but received {id!r}") |
| 995 | + return await self._post( |
| 996 | + path_template("/browsers/{id}/curl", id=id), |
| 997 | + body=await async_maybe_transform( |
| 998 | + { |
| 999 | + "url": url, |
| 1000 | + "body": body, |
| 1001 | + "headers": headers, |
| 1002 | + "method": method, |
| 1003 | + "response_encoding": response_encoding, |
| 1004 | + "timeout_ms": timeout_ms, |
| 1005 | + }, |
| 1006 | + browser_curl_params.BrowserCurlParams, |
| 1007 | + ), |
| 1008 | + options=make_request_options( |
| 1009 | + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout |
| 1010 | + ), |
| 1011 | + cast_to=BrowserCurlResponse, |
| 1012 | + ) |
| 1013 | + |
884 | 1014 | async def delete_by_id( |
885 | 1015 | self, |
886 | 1016 | id: str, |
@@ -983,6 +1113,9 @@ def __init__(self, browsers: BrowsersResource) -> None: |
983 | 1113 | browsers.delete, # pyright: ignore[reportDeprecated], |
984 | 1114 | ) |
985 | 1115 | ) |
| 1116 | + self.curl = to_raw_response_wrapper( |
| 1117 | + browsers.curl, |
| 1118 | + ) |
986 | 1119 | self.delete_by_id = to_raw_response_wrapper( |
987 | 1120 | browsers.delete_by_id, |
988 | 1121 | ) |
@@ -1041,6 +1174,9 @@ def __init__(self, browsers: AsyncBrowsersResource) -> None: |
1041 | 1174 | browsers.delete, # pyright: ignore[reportDeprecated], |
1042 | 1175 | ) |
1043 | 1176 | ) |
| 1177 | + self.curl = async_to_raw_response_wrapper( |
| 1178 | + browsers.curl, |
| 1179 | + ) |
1044 | 1180 | self.delete_by_id = async_to_raw_response_wrapper( |
1045 | 1181 | browsers.delete_by_id, |
1046 | 1182 | ) |
@@ -1099,6 +1235,9 @@ def __init__(self, browsers: BrowsersResource) -> None: |
1099 | 1235 | browsers.delete, # pyright: ignore[reportDeprecated], |
1100 | 1236 | ) |
1101 | 1237 | ) |
| 1238 | + self.curl = to_streamed_response_wrapper( |
| 1239 | + browsers.curl, |
| 1240 | + ) |
1102 | 1241 | self.delete_by_id = to_streamed_response_wrapper( |
1103 | 1242 | browsers.delete_by_id, |
1104 | 1243 | ) |
@@ -1157,6 +1296,9 @@ def __init__(self, browsers: AsyncBrowsersResource) -> None: |
1157 | 1296 | browsers.delete, # pyright: ignore[reportDeprecated], |
1158 | 1297 | ) |
1159 | 1298 | ) |
| 1299 | + self.curl = async_to_streamed_response_wrapper( |
| 1300 | + browsers.curl, |
| 1301 | + ) |
1160 | 1302 | self.delete_by_id = async_to_streamed_response_wrapper( |
1161 | 1303 | browsers.delete_by_id, |
1162 | 1304 | ) |
|
0 commit comments