22
33import { APIResource } from '../core/resource' ;
44import { APIPromise } from '../core/api-promise' ;
5+ import { OffsetPagination , type OffsetPaginationParams , PagePromise } from '../core/pagination' ;
56import { buildHeaders } from '../internal/headers' ;
67import { RequestOptions } from '../internal/request-options' ;
78import { path } from '../internal/utils/path' ;
@@ -27,8 +28,11 @@ export class Proxies extends APIResource {
2728 /**
2829 * List proxies owned by the caller's organization.
2930 */
30- list ( options ?: RequestOptions ) : APIPromise < ProxyListResponse > {
31- return this . _client . get ( '/proxies' , options ) ;
31+ list (
32+ query : ProxyListParams | null | undefined = { } ,
33+ options ?: RequestOptions ,
34+ ) : PagePromise < ProxyListResponsesOffsetPagination , ProxyListResponse > {
35+ return this . _client . getAPIList ( '/proxies' , OffsetPagination < ProxyListResponse > , { query, ...options } ) ;
3236 }
3337
3438 /**
@@ -58,6 +62,8 @@ export class Proxies extends APIResource {
5862 }
5963}
6064
65+ export type ProxyListResponsesOffsetPagination = OffsetPagination < ProxyListResponse > ;
66+
6167/**
6268 * Configuration for routing traffic through a proxy.
6369 */
@@ -370,163 +376,159 @@ export namespace ProxyRetrieveResponse {
370376 }
371377}
372378
373- export type ProxyListResponse = Array < ProxyListResponse . ProxyListResponseItem > ;
379+ /**
380+ * Configuration for routing traffic through a proxy.
381+ */
382+ export interface ProxyListResponse {
383+ /**
384+ * Proxy type to use. In terms of quality for avoiding bot-detection, from best to
385+ * worst: `mobile` > `residential` > `isp` > `datacenter`.
386+ */
387+ type : 'datacenter' | 'isp' | 'residential' | 'mobile' | 'custom' ;
388+
389+ id ?: string ;
390+
391+ /**
392+ * Hostnames that should bypass the parent proxy and connect directly.
393+ */
394+ bypass_hosts ?: Array < string > ;
395+
396+ /**
397+ * Configuration specific to the selected proxy `type`.
398+ */
399+ config ?:
400+ | ProxyListResponse . DatacenterProxyConfig
401+ | ProxyListResponse . IspProxyConfig
402+ | ProxyListResponse . ResidentialProxyConfig
403+ | ProxyListResponse . MobileProxyConfig
404+ | ProxyListResponse . CustomProxyConfig ;
405+
406+ /**
407+ * IP address that the proxy uses when making requests.
408+ */
409+ ip_address ?: string ;
410+
411+ /**
412+ * Timestamp of the last health check performed on this proxy.
413+ */
414+ last_checked ?: string ;
415+
416+ /**
417+ * Readable name of the proxy.
418+ */
419+ name ?: string ;
420+
421+ /**
422+ * Protocol to use for the proxy connection.
423+ */
424+ protocol ?: 'http' | 'https' ;
425+
426+ /**
427+ * Current health status of the proxy.
428+ */
429+ status ?: 'available' | 'unavailable' ;
430+ }
374431
375432export namespace ProxyListResponse {
376433 /**
377- * Configuration for routing traffic through a proxy.
434+ * Configuration for a datacenter proxy.
378435 */
379- export interface ProxyListResponseItem {
436+ export interface DatacenterProxyConfig {
380437 /**
381- * Proxy type to use. In terms of quality for avoiding bot-detection, from best to
382- * worst: `mobile` > `residential` > `isp` > `datacenter`.
438+ * ISO 3166 country code. Defaults to US if not provided.
383439 */
384- type : 'datacenter' | 'isp' | 'residential' | 'mobile' | 'custom' ;
385-
386- id ?: string ;
440+ country ?: string ;
441+ }
387442
443+ /**
444+ * Configuration for an ISP proxy.
445+ */
446+ export interface IspProxyConfig {
388447 /**
389- * Hostnames that should bypass the parent proxy and connect directly .
448+ * ISO 3166 country code. Defaults to US if not provided .
390449 */
391- bypass_hosts ?: Array < string > ;
450+ country ?: string ;
451+ }
392452
453+ /**
454+ * Configuration for residential proxies.
455+ */
456+ export interface ResidentialProxyConfig {
393457 /**
394- * Configuration specific to the selected proxy `type`.
458+ * Autonomous system number. See https://bgp.potaroo.net/cidr/autnums.html
395459 */
396- config ?:
397- | ProxyListResponseItem . DatacenterProxyConfig
398- | ProxyListResponseItem . IspProxyConfig
399- | ProxyListResponseItem . ResidentialProxyConfig
400- | ProxyListResponseItem . MobileProxyConfig
401- | ProxyListResponseItem . CustomProxyConfig ;
460+ asn ?: string ;
402461
403462 /**
404- * IP address that the proxy uses when making requests.
463+ * City name (no spaces, e.g. `sanfrancisco`). If provided, `country` must also be
464+ * provided.
405465 */
406- ip_address ?: string ;
466+ city ?: string ;
407467
408468 /**
409- * Timestamp of the last health check performed on this proxy .
469+ * ISO 3166 country code .
410470 */
411- last_checked ?: string ;
471+ country ?: string ;
412472
413473 /**
414- * Readable name of the proxy .
474+ * @deprecated Operating system of the residential device .
415475 */
416- name ?: string ;
476+ os ?: 'windows' | 'macos' | 'android' ;
417477
418478 /**
419- * Protocol to use for the proxy connection .
479+ * Two-letter state code .
420480 */
421- protocol ?: 'http' | 'https' ;
481+ state ?: string ;
422482
423483 /**
424- * Current health status of the proxy .
484+ * US ZIP code .
425485 */
426- status ?: 'available' | 'unavailable' ;
486+ zip ?: string ;
427487 }
428488
429- export namespace ProxyListResponseItem {
489+ /**
490+ * Configuration for mobile proxies.
491+ */
492+ export interface MobileProxyConfig {
430493 /**
431- * Configuration for a datacenter proxy .
494+ * Provider city alias. Mobile carrier routing can make observed geo vary .
432495 */
433- export interface DatacenterProxyConfig {
434- /**
435- * ISO 3166 country code. Defaults to US if not provided.
436- */
437- country ?: string ;
438- }
496+ city ?: string ;
439497
440498 /**
441- * Configuration for an ISP proxy.
499+ * ISO 3166 country code
442500 */
443- export interface IspProxyConfig {
444- /**
445- * ISO 3166 country code. Defaults to US if not provided.
446- */
447- country ?: string ;
448- }
501+ country ?: string ;
449502
450503 /**
451- * Configuration for residential proxies .
504+ * US-only state code. Mobile carrier routing can make observed geo vary .
452505 */
453- export interface ResidentialProxyConfig {
454- /**
455- * Autonomous system number. See https://bgp.potaroo.net/cidr/autnums.html
456- */
457- asn ?: string ;
458-
459- /**
460- * City name (no spaces, e.g. `sanfrancisco`). If provided, `country` must also be
461- * provided.
462- */
463- city ?: string ;
464-
465- /**
466- * ISO 3166 country code.
467- */
468- country ?: string ;
469-
470- /**
471- * @deprecated Operating system of the residential device.
472- */
473- os ?: 'windows' | 'macos' | 'android' ;
474-
475- /**
476- * Two-letter state code.
477- */
478- state ?: string ;
479-
480- /**
481- * US ZIP code.
482- */
483- zip ?: string ;
484- }
506+ state ?: string ;
507+ }
485508
509+ /**
510+ * Configuration for a custom proxy (e.g., private proxy server).
511+ */
512+ export interface CustomProxyConfig {
486513 /**
487- * Configuration for mobile proxies .
514+ * Proxy host address or IP .
488515 */
489- export interface MobileProxyConfig {
490- /**
491- * Provider city alias. Mobile carrier routing can make observed geo vary.
492- */
493- city ?: string ;
494-
495- /**
496- * ISO 3166 country code
497- */
498- country ?: string ;
499-
500- /**
501- * US-only state code. Mobile carrier routing can make observed geo vary.
502- */
503- state ?: string ;
504- }
516+ host : string ;
505517
506518 /**
507- * Configuration for a custom proxy (e.g., private proxy server) .
519+ * Proxy port .
508520 */
509- export interface CustomProxyConfig {
510- /**
511- * Proxy host address or IP.
512- */
513- host : string ;
514-
515- /**
516- * Proxy port.
517- */
518- port : number ;
521+ port : number ;
519522
520- /**
521- * Whether the proxy has a password.
522- */
523- has_password ?: boolean ;
523+ /**
524+ * Whether the proxy has a password.
525+ */
526+ has_password ?: boolean ;
524527
525- /**
526- * Username for proxy authentication.
527- */
528- username ?: string ;
529- }
528+ /**
529+ * Username for proxy authentication.
530+ */
531+ username ?: string ;
530532 }
531533}
532534
@@ -822,6 +824,8 @@ export namespace ProxyCreateParams {
822824 }
823825}
824826
827+ export interface ProxyListParams extends OffsetPaginationParams { }
828+
825829export interface ProxyCheckParams {
826830 /**
827831 * An optional URL to test reachability against. If provided, the proxy check will
@@ -846,7 +850,9 @@ export declare namespace Proxies {
846850 type ProxyRetrieveResponse as ProxyRetrieveResponse ,
847851 type ProxyListResponse as ProxyListResponse ,
848852 type ProxyCheckResponse as ProxyCheckResponse ,
853+ type ProxyListResponsesOffsetPagination as ProxyListResponsesOffsetPagination ,
849854 type ProxyCreateParams as ProxyCreateParams ,
855+ type ProxyListParams as ProxyListParams ,
850856 type ProxyCheckParams as ProxyCheckParams ,
851857 } ;
852858}
0 commit comments