Skip to content

Commit cdd4b02

Browse files
feat: Add optional url parameter to proxy check endpoint
1 parent 420658a commit cdd4b02

File tree

6 files changed

+96
-16
lines changed

6 files changed

+96
-16
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: 104
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-403eadeddcd92ecf5c0ada739fb59d73d829a9b463788a81ac3ed97d0cd3a64b.yml
3-
openapi_spec_hash: 8fdd3a5bd5e035f0adeb72329c215ad7
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-f7024f4171c7c4ec558de1c27f338b1089ffddd0d2dbfdb9bb9f9c2abe8f47bf.yml
3+
openapi_spec_hash: ced43682b49e73a2862f99b49abb4fcd
44
config_hash: 16e4457a0bb26e98a335a1c2a572290a

api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ Methods:
282282
- <code title="get /proxies/{id}">client.proxies.<a href="./src/kernel/resources/proxies.py">retrieve</a>(id) -> <a href="./src/kernel/types/proxy_retrieve_response.py">ProxyRetrieveResponse</a></code>
283283
- <code title="get /proxies">client.proxies.<a href="./src/kernel/resources/proxies.py">list</a>() -> <a href="./src/kernel/types/proxy_list_response.py">ProxyListResponse</a></code>
284284
- <code title="delete /proxies/{id}">client.proxies.<a href="./src/kernel/resources/proxies.py">delete</a>(id) -> None</code>
285-
- <code title="post /proxies/{id}/check">client.proxies.<a href="./src/kernel/resources/proxies.py">check</a>(id) -> <a href="./src/kernel/types/proxy_check_response.py">ProxyCheckResponse</a></code>
285+
- <code title="post /proxies/{id}/check">client.proxies.<a href="./src/kernel/resources/proxies.py">check</a>(id, \*\*<a href="src/kernel/types/proxy_check_params.py">params</a>) -> <a href="./src/kernel/types/proxy_check_response.py">ProxyCheckResponse</a></code>
286286

287287
# Extensions
288288

src/kernel/resources/proxies.py

Lines changed: 43 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import httpx
88

9-
from ..types import proxy_create_params
9+
from ..types import proxy_check_params, proxy_create_params
1010
from .._types import Body, Omit, Query, Headers, NoneType, NotGiven, SequenceNotStr, omit, not_given
1111
from .._utils import path_template, maybe_transform, async_maybe_transform
1212
from .._compat import cached_property
@@ -195,17 +195,35 @@ def check(
195195
self,
196196
id: str,
197197
*,
198+
url: str | Omit = omit,
198199
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
199200
# The extra values given here take precedence over values defined on the client or passed to this method.
200201
extra_headers: Headers | None = None,
201202
extra_query: Query | None = None,
202203
extra_body: Body | None = None,
203204
timeout: float | httpx.Timeout | None | NotGiven = not_given,
204205
) -> ProxyCheckResponse:
205-
"""
206-
Run a health check on the proxy to verify it's working.
206+
"""Run a health check on the proxy to verify it's working.
207+
208+
Optionally specify a URL
209+
to test reachability against a specific target. For ISP and datacenter proxies,
210+
this reliably tests whether the target site is reachable from the proxy's stable
211+
exit IP. For residential and mobile proxies, the exit node varies between
212+
requests, so this validates proxy configuration and connectivity rather than
213+
guaranteeing site-specific reachability.
207214
208215
Args:
216+
url: An optional URL to test reachability against. If provided, the proxy check will
217+
test connectivity to this URL instead of the default test URLs. Only HTTP and
218+
HTTPS schemes are allowed, and the URL must resolve to a public IP address. For
219+
ISP and datacenter proxies, the exit IP is stable, so a successful check
220+
reliably indicates that subsequent browser sessions will reach the target site
221+
with the same IP. For residential and mobile proxies, the exit node changes
222+
between requests, so a successful check validates proxy configuration but does
223+
not guarantee that a subsequent browser session will use the same exit IP or
224+
reach the same site — it is useful for verifying credentials and connectivity,
225+
not for predicting site-specific behavior.
226+
209227
extra_headers: Send extra headers
210228
211229
extra_query: Add additional query parameters to the request
@@ -218,6 +236,7 @@ def check(
218236
raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
219237
return self._post(
220238
path_template("/proxies/{id}/check", id=id),
239+
body=maybe_transform({"url": url}, proxy_check_params.ProxyCheckParams),
221240
options=make_request_options(
222241
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
223242
),
@@ -394,17 +413,35 @@ async def check(
394413
self,
395414
id: str,
396415
*,
416+
url: str | Omit = omit,
397417
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
398418
# The extra values given here take precedence over values defined on the client or passed to this method.
399419
extra_headers: Headers | None = None,
400420
extra_query: Query | None = None,
401421
extra_body: Body | None = None,
402422
timeout: float | httpx.Timeout | None | NotGiven = not_given,
403423
) -> ProxyCheckResponse:
404-
"""
405-
Run a health check on the proxy to verify it's working.
424+
"""Run a health check on the proxy to verify it's working.
425+
426+
Optionally specify a URL
427+
to test reachability against a specific target. For ISP and datacenter proxies,
428+
this reliably tests whether the target site is reachable from the proxy's stable
429+
exit IP. For residential and mobile proxies, the exit node varies between
430+
requests, so this validates proxy configuration and connectivity rather than
431+
guaranteeing site-specific reachability.
406432
407433
Args:
434+
url: An optional URL to test reachability against. If provided, the proxy check will
435+
test connectivity to this URL instead of the default test URLs. Only HTTP and
436+
HTTPS schemes are allowed, and the URL must resolve to a public IP address. For
437+
ISP and datacenter proxies, the exit IP is stable, so a successful check
438+
reliably indicates that subsequent browser sessions will reach the target site
439+
with the same IP. For residential and mobile proxies, the exit node changes
440+
between requests, so a successful check validates proxy configuration but does
441+
not guarantee that a subsequent browser session will use the same exit IP or
442+
reach the same site — it is useful for verifying credentials and connectivity,
443+
not for predicting site-specific behavior.
444+
408445
extra_headers: Send extra headers
409446
410447
extra_query: Add additional query parameters to the request
@@ -417,6 +454,7 @@ async def check(
417454
raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
418455
return await self._post(
419456
path_template("/proxies/{id}/check", id=id),
457+
body=await async_maybe_transform({"url": url}, proxy_check_params.ProxyCheckParams),
420458
options=make_request_options(
421459
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
422460
),

src/kernel/types/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
from .app_list_params import AppListParams as AppListParams
2121
from .browser_pool_ref import BrowserPoolRef as BrowserPoolRef
2222
from .app_list_response import AppListResponse as AppListResponse
23+
from .proxy_check_params import ProxyCheckParams as ProxyCheckParams
2324
from .browser_list_params import BrowserListParams as BrowserListParams
2425
from .browser_persistence import BrowserPersistence as BrowserPersistence
2526
from .credential_provider import CredentialProvider as CredentialProvider
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
from __future__ import annotations
4+
5+
from typing_extensions import TypedDict
6+
7+
__all__ = ["ProxyCheckParams"]
8+
9+
10+
class ProxyCheckParams(TypedDict, total=False):
11+
url: str
12+
"""An optional URL to test reachability against.
13+
14+
If provided, the proxy check will test connectivity to this URL instead of the
15+
default test URLs. Only HTTP and HTTPS schemes are allowed, and the URL must
16+
resolve to a public IP address. For ISP and datacenter proxies, the exit IP is
17+
stable, so a successful check reliably indicates that subsequent browser
18+
sessions will reach the target site with the same IP. For residential and mobile
19+
proxies, the exit node changes between requests, so a successful check validates
20+
proxy configuration but does not guarantee that a subsequent browser session
21+
will use the same exit IP or reach the same site — it is useful for verifying
22+
credentials and connectivity, not for predicting site-specific behavior.
23+
"""

tests/api_resources/test_proxies.py

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -184,15 +184,24 @@ def test_path_params_delete(self, client: Kernel) -> None:
184184
@parametrize
185185
def test_method_check(self, client: Kernel) -> None:
186186
proxy = client.proxies.check(
187-
"id",
187+
id="id",
188+
)
189+
assert_matches_type(ProxyCheckResponse, proxy, path=["response"])
190+
191+
@pytest.mark.skip(reason="Mock server tests are disabled")
192+
@parametrize
193+
def test_method_check_with_all_params(self, client: Kernel) -> None:
194+
proxy = client.proxies.check(
195+
id="id",
196+
url="url",
188197
)
189198
assert_matches_type(ProxyCheckResponse, proxy, path=["response"])
190199

191200
@pytest.mark.skip(reason="Mock server tests are disabled")
192201
@parametrize
193202
def test_raw_response_check(self, client: Kernel) -> None:
194203
response = client.proxies.with_raw_response.check(
195-
"id",
204+
id="id",
196205
)
197206

198207
assert response.is_closed is True
@@ -204,7 +213,7 @@ def test_raw_response_check(self, client: Kernel) -> None:
204213
@parametrize
205214
def test_streaming_response_check(self, client: Kernel) -> None:
206215
with client.proxies.with_streaming_response.check(
207-
"id",
216+
id="id",
208217
) as response:
209218
assert not response.is_closed
210219
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
@@ -219,7 +228,7 @@ def test_streaming_response_check(self, client: Kernel) -> None:
219228
def test_path_params_check(self, client: Kernel) -> None:
220229
with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"):
221230
client.proxies.with_raw_response.check(
222-
"",
231+
id="",
223232
)
224233

225234

@@ -390,15 +399,24 @@ async def test_path_params_delete(self, async_client: AsyncKernel) -> None:
390399
@parametrize
391400
async def test_method_check(self, async_client: AsyncKernel) -> None:
392401
proxy = await async_client.proxies.check(
393-
"id",
402+
id="id",
403+
)
404+
assert_matches_type(ProxyCheckResponse, proxy, path=["response"])
405+
406+
@pytest.mark.skip(reason="Mock server tests are disabled")
407+
@parametrize
408+
async def test_method_check_with_all_params(self, async_client: AsyncKernel) -> None:
409+
proxy = await async_client.proxies.check(
410+
id="id",
411+
url="url",
394412
)
395413
assert_matches_type(ProxyCheckResponse, proxy, path=["response"])
396414

397415
@pytest.mark.skip(reason="Mock server tests are disabled")
398416
@parametrize
399417
async def test_raw_response_check(self, async_client: AsyncKernel) -> None:
400418
response = await async_client.proxies.with_raw_response.check(
401-
"id",
419+
id="id",
402420
)
403421

404422
assert response.is_closed is True
@@ -410,7 +428,7 @@ async def test_raw_response_check(self, async_client: AsyncKernel) -> None:
410428
@parametrize
411429
async def test_streaming_response_check(self, async_client: AsyncKernel) -> None:
412430
async with async_client.proxies.with_streaming_response.check(
413-
"id",
431+
id="id",
414432
) as response:
415433
assert not response.is_closed
416434
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
@@ -425,5 +443,5 @@ async def test_streaming_response_check(self, async_client: AsyncKernel) -> None
425443
async def test_path_params_check(self, async_client: AsyncKernel) -> None:
426444
with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"):
427445
await async_client.proxies.with_raw_response.check(
428-
"",
446+
id="",
429447
)

0 commit comments

Comments
 (0)