Skip to content

Commit eb53ca2

Browse files
feat: Add optional url parameter to proxy check endpoint
1 parent 85570eb commit eb53ca2

File tree

6 files changed

+43
-6
lines changed

6 files changed

+43
-6
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
@@ -245,7 +245,7 @@ Methods:
245245
- <code title="get /proxies/{id}">client.proxies.<a href="./src/resources/proxies.ts">retrieve</a>(id) -> ProxyRetrieveResponse</code>
246246
- <code title="get /proxies">client.proxies.<a href="./src/resources/proxies.ts">list</a>() -> ProxyListResponse</code>
247247
- <code title="delete /proxies/{id}">client.proxies.<a href="./src/resources/proxies.ts">delete</a>(id) -> void</code>
248-
- <code title="post /proxies/{id}/check">client.proxies.<a href="./src/resources/proxies.ts">check</a>(id) -> ProxyCheckResponse</code>
248+
- <code title="post /proxies/{id}/check">client.proxies.<a href="./src/resources/proxies.ts">check</a>(id, { ...params }) -> ProxyCheckResponse</code>
249249

250250
# Extensions
251251

src/client.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ import {
9292
import { ProfileCreateParams, ProfileListParams, Profiles } from './resources/profiles';
9393
import {
9494
Proxies,
95+
ProxyCheckParams,
9596
ProxyCheckResponse,
9697
ProxyCreateParams,
9798
ProxyCreateResponse,
@@ -1021,6 +1022,7 @@ export declare namespace Kernel {
10211022
type ProxyListResponse as ProxyListResponse,
10221023
type ProxyCheckResponse as ProxyCheckResponse,
10231024
type ProxyCreateParams as ProxyCreateParams,
1025+
type ProxyCheckParams as ProxyCheckParams,
10241026
};
10251027

10261028
export {

src/resources/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,4 +103,5 @@ export {
103103
type ProxyListResponse,
104104
type ProxyCheckResponse,
105105
type ProxyCreateParams,
106+
type ProxyCheckParams,
106107
} from './proxies';

src/resources/proxies.ts

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,19 @@ export class Proxies extends APIResource {
4242
}
4343

4444
/**
45-
* Run a health check on the proxy to verify it's working.
45+
* Run a health check on the proxy to verify it's working. Optionally specify a URL
46+
* to test reachability against a specific target. For ISP and datacenter proxies,
47+
* this reliably tests whether the target site is reachable from the proxy's stable
48+
* exit IP. For residential and mobile proxies, the exit node varies between
49+
* requests, so this validates proxy configuration and connectivity rather than
50+
* guaranteeing site-specific reachability.
4651
*/
47-
check(id: string, options?: RequestOptions): APIPromise<ProxyCheckResponse> {
48-
return this._client.post(path`/proxies/${id}/check`, options);
52+
check(
53+
id: string,
54+
body: ProxyCheckParams | null | undefined = {},
55+
options?: RequestOptions,
56+
): APIPromise<ProxyCheckResponse> {
57+
return this._client.post(path`/proxies/${id}/check`, { body, ...options });
4958
}
5059
}
5160

@@ -1183,12 +1192,29 @@ export namespace ProxyCreateParams {
11831192
}
11841193
}
11851194

1195+
export interface ProxyCheckParams {
1196+
/**
1197+
* An optional URL to test reachability against. If provided, the proxy check will
1198+
* test connectivity to this URL instead of the default test URLs. Only HTTP and
1199+
* HTTPS schemes are allowed, and the URL must resolve to a public IP address. For
1200+
* ISP and datacenter proxies, the exit IP is stable, so a successful check
1201+
* reliably indicates that subsequent browser sessions will reach the target site
1202+
* with the same IP. For residential and mobile proxies, the exit node changes
1203+
* between requests, so a successful check validates proxy configuration but does
1204+
* not guarantee that a subsequent browser session will use the same exit IP or
1205+
* reach the same site — it is useful for verifying credentials and connectivity,
1206+
* not for predicting site-specific behavior.
1207+
*/
1208+
url?: string;
1209+
}
1210+
11861211
export declare namespace Proxies {
11871212
export {
11881213
type ProxyCreateResponse as ProxyCreateResponse,
11891214
type ProxyRetrieveResponse as ProxyRetrieveResponse,
11901215
type ProxyListResponse as ProxyListResponse,
11911216
type ProxyCheckResponse as ProxyCheckResponse,
11921217
type ProxyCreateParams as ProxyCreateParams,
1218+
type ProxyCheckParams as ProxyCheckParams,
11931219
};
11941220
}

tests/api-resources/proxies.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,4 +78,12 @@ describe('resource proxies', () => {
7878
expect(dataAndResponse.data).toBe(response);
7979
expect(dataAndResponse.response).toBe(rawResponse);
8080
});
81+
82+
// Mock server tests are disabled
83+
test.skip('check: request options and params are passed correctly', async () => {
84+
// ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
85+
await expect(
86+
client.proxies.check('id', { url: 'url' }, { path: '/_stainless_unknown_path' }),
87+
).rejects.toThrow(Kernel.NotFoundError);
88+
});
8189
});

0 commit comments

Comments
 (0)