|
1 | 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. |
2 | 2 |
|
3 | 3 | import { APIResource } from '../../core/resource'; |
4 | | -import * as BrowsersAPI from './browsers'; |
5 | 4 | import * as ComputerAPI from './computer'; |
6 | 5 | import { |
7 | 6 | Computer, |
@@ -63,6 +62,7 @@ import { |
63 | 62 | Fs, |
64 | 63 | } from './fs/fs'; |
65 | 64 | import { APIPromise } from '../../core/api-promise'; |
| 65 | +import { OffsetPagination, type OffsetPaginationParams, PagePromise } from '../../core/pagination'; |
66 | 66 | import { type Uploadable } from '../../core/uploads'; |
67 | 67 | import { buildHeaders } from '../../internal/headers'; |
68 | 68 | import { RequestOptions } from '../../internal/request-options'; |
@@ -107,15 +107,22 @@ export class Browsers extends APIResource { |
107 | 107 | } |
108 | 108 |
|
109 | 109 | /** |
110 | | - * List active browser sessions |
| 110 | + * List all browser sessions with pagination support. Use include_deleted=true to |
| 111 | + * include soft-deleted sessions in the results. |
111 | 112 | * |
112 | 113 | * @example |
113 | 114 | * ```ts |
114 | | - * const browsers = await client.browsers.list(); |
| 115 | + * // Automatically fetches more pages as needed. |
| 116 | + * for await (const browserListResponse of client.browsers.list()) { |
| 117 | + * // ... |
| 118 | + * } |
115 | 119 | * ``` |
116 | 120 | */ |
117 | | - list(options?: RequestOptions): APIPromise<BrowserListResponse> { |
118 | | - return this._client.get('/browsers', options); |
| 121 | + list( |
| 122 | + query: BrowserListParams | null | undefined = {}, |
| 123 | + options?: RequestOptions, |
| 124 | + ): PagePromise<BrowserListResponsesOffsetPagination, BrowserListResponse> { |
| 125 | + return this._client.getAPIList('/browsers', OffsetPagination<BrowserListResponse>, { query, ...options }); |
119 | 126 | } |
120 | 127 |
|
121 | 128 | /** |
@@ -181,6 +188,8 @@ export class Browsers extends APIResource { |
181 | 188 | } |
182 | 189 | } |
183 | 190 |
|
| 191 | +export type BrowserListResponsesOffsetPagination = OffsetPagination<BrowserListResponse>; |
| 192 | + |
184 | 193 | /** |
185 | 194 | * Optional persistence configuration for the browser session. |
186 | 195 | */ |
@@ -258,6 +267,11 @@ export interface BrowserCreateResponse { |
258 | 267 | */ |
259 | 268 | browser_live_view_url?: string; |
260 | 269 |
|
| 270 | + /** |
| 271 | + * When the browser session was soft-deleted. Only present for deleted sessions. |
| 272 | + */ |
| 273 | + deleted_at?: string; |
| 274 | + |
261 | 275 | /** |
262 | 276 | * Whether the browser session is running in kiosk mode. |
263 | 277 | */ |
@@ -358,6 +372,11 @@ export interface BrowserRetrieveResponse { |
358 | 372 | */ |
359 | 373 | browser_live_view_url?: string; |
360 | 374 |
|
| 375 | + /** |
| 376 | + * When the browser session was soft-deleted. Only present for deleted sessions. |
| 377 | + */ |
| 378 | + deleted_at?: string; |
| 379 | + |
361 | 380 | /** |
362 | 381 | * Whether the browser session is running in kiosk mode. |
363 | 382 | */ |
@@ -421,107 +440,108 @@ export namespace BrowserRetrieveResponse { |
421 | 440 | } |
422 | 441 | } |
423 | 442 |
|
424 | | -export type BrowserListResponse = Array<BrowserListResponse.BrowserListResponseItem>; |
| 443 | +export interface BrowserListResponse { |
| 444 | + /** |
| 445 | + * Websocket URL for Chrome DevTools Protocol connections to the browser session |
| 446 | + */ |
| 447 | + cdp_ws_url: string; |
425 | 448 |
|
426 | | -export namespace BrowserListResponse { |
427 | | - export interface BrowserListResponseItem { |
428 | | - /** |
429 | | - * Websocket URL for Chrome DevTools Protocol connections to the browser session |
430 | | - */ |
431 | | - cdp_ws_url: string; |
| 449 | + /** |
| 450 | + * When the browser session was created. |
| 451 | + */ |
| 452 | + created_at: string; |
432 | 453 |
|
433 | | - /** |
434 | | - * When the browser session was created. |
435 | | - */ |
436 | | - created_at: string; |
| 454 | + /** |
| 455 | + * Whether the browser session is running in headless mode. |
| 456 | + */ |
| 457 | + headless: boolean; |
437 | 458 |
|
438 | | - /** |
439 | | - * Whether the browser session is running in headless mode. |
440 | | - */ |
441 | | - headless: boolean; |
| 459 | + /** |
| 460 | + * Unique identifier for the browser session |
| 461 | + */ |
| 462 | + session_id: string; |
442 | 463 |
|
443 | | - /** |
444 | | - * Unique identifier for the browser session |
445 | | - */ |
446 | | - session_id: string; |
| 464 | + /** |
| 465 | + * Whether the browser session is running in stealth mode. |
| 466 | + */ |
| 467 | + stealth: boolean; |
447 | 468 |
|
448 | | - /** |
449 | | - * Whether the browser session is running in stealth mode. |
450 | | - */ |
451 | | - stealth: boolean; |
| 469 | + /** |
| 470 | + * The number of seconds of inactivity before the browser session is terminated. |
| 471 | + */ |
| 472 | + timeout_seconds: number; |
452 | 473 |
|
453 | | - /** |
454 | | - * The number of seconds of inactivity before the browser session is terminated. |
455 | | - */ |
456 | | - timeout_seconds: number; |
| 474 | + /** |
| 475 | + * Remote URL for live viewing the browser session. Only available for non-headless |
| 476 | + * browsers. |
| 477 | + */ |
| 478 | + browser_live_view_url?: string; |
457 | 479 |
|
458 | | - /** |
459 | | - * Remote URL for live viewing the browser session. Only available for non-headless |
460 | | - * browsers. |
461 | | - */ |
462 | | - browser_live_view_url?: string; |
| 480 | + /** |
| 481 | + * When the browser session was soft-deleted. Only present for deleted sessions. |
| 482 | + */ |
| 483 | + deleted_at?: string; |
463 | 484 |
|
464 | | - /** |
465 | | - * Whether the browser session is running in kiosk mode. |
466 | | - */ |
467 | | - kiosk_mode?: boolean; |
| 485 | + /** |
| 486 | + * Whether the browser session is running in kiosk mode. |
| 487 | + */ |
| 488 | + kiosk_mode?: boolean; |
468 | 489 |
|
469 | | - /** |
470 | | - * Optional persistence configuration for the browser session. |
471 | | - */ |
472 | | - persistence?: BrowsersAPI.BrowserPersistence; |
| 490 | + /** |
| 491 | + * Optional persistence configuration for the browser session. |
| 492 | + */ |
| 493 | + persistence?: BrowserPersistence; |
473 | 494 |
|
474 | | - /** |
475 | | - * Browser profile metadata. |
476 | | - */ |
477 | | - profile?: BrowsersAPI.Profile; |
| 495 | + /** |
| 496 | + * Browser profile metadata. |
| 497 | + */ |
| 498 | + profile?: Profile; |
| 499 | + |
| 500 | + /** |
| 501 | + * ID of the proxy associated with this browser session, if any. |
| 502 | + */ |
| 503 | + proxy_id?: string; |
| 504 | + |
| 505 | + /** |
| 506 | + * Initial browser window size in pixels with optional refresh rate. If omitted, |
| 507 | + * image defaults apply (commonly 1024x768@60). Only specific viewport |
| 508 | + * configurations are supported. The server will reject unsupported combinations. |
| 509 | + * Supported resolutions are: 2560x1440@10, 1920x1080@25, 1920x1200@25, |
| 510 | + * 1440x900@25, 1024x768@60, 1200x800@60 If refresh_rate is not provided, it will |
| 511 | + * be automatically determined from the width and height if they match a supported |
| 512 | + * configuration exactly. Note: Higher resolutions may affect the responsiveness of |
| 513 | + * live view browser |
| 514 | + */ |
| 515 | + viewport?: BrowserListResponse.Viewport; |
| 516 | +} |
478 | 517 |
|
| 518 | +export namespace BrowserListResponse { |
| 519 | + /** |
| 520 | + * Initial browser window size in pixels with optional refresh rate. If omitted, |
| 521 | + * image defaults apply (commonly 1024x768@60). Only specific viewport |
| 522 | + * configurations are supported. The server will reject unsupported combinations. |
| 523 | + * Supported resolutions are: 2560x1440@10, 1920x1080@25, 1920x1200@25, |
| 524 | + * 1440x900@25, 1024x768@60, 1200x800@60 If refresh_rate is not provided, it will |
| 525 | + * be automatically determined from the width and height if they match a supported |
| 526 | + * configuration exactly. Note: Higher resolutions may affect the responsiveness of |
| 527 | + * live view browser |
| 528 | + */ |
| 529 | + export interface Viewport { |
479 | 530 | /** |
480 | | - * ID of the proxy associated with this browser session, if any. |
| 531 | + * Browser window height in pixels. |
481 | 532 | */ |
482 | | - proxy_id?: string; |
| 533 | + height: number; |
483 | 534 |
|
484 | 535 | /** |
485 | | - * Initial browser window size in pixels with optional refresh rate. If omitted, |
486 | | - * image defaults apply (commonly 1024x768@60). Only specific viewport |
487 | | - * configurations are supported. The server will reject unsupported combinations. |
488 | | - * Supported resolutions are: 2560x1440@10, 1920x1080@25, 1920x1200@25, |
489 | | - * 1440x900@25, 1024x768@60, 1200x800@60 If refresh_rate is not provided, it will |
490 | | - * be automatically determined from the width and height if they match a supported |
491 | | - * configuration exactly. Note: Higher resolutions may affect the responsiveness of |
492 | | - * live view browser |
| 536 | + * Browser window width in pixels. |
493 | 537 | */ |
494 | | - viewport?: BrowserListResponseItem.Viewport; |
495 | | - } |
| 538 | + width: number; |
496 | 539 |
|
497 | | - export namespace BrowserListResponseItem { |
498 | 540 | /** |
499 | | - * Initial browser window size in pixels with optional refresh rate. If omitted, |
500 | | - * image defaults apply (commonly 1024x768@60). Only specific viewport |
501 | | - * configurations are supported. The server will reject unsupported combinations. |
502 | | - * Supported resolutions are: 2560x1440@10, 1920x1080@25, 1920x1200@25, |
503 | | - * 1440x900@25, 1024x768@60, 1200x800@60 If refresh_rate is not provided, it will |
504 | | - * be automatically determined from the width and height if they match a supported |
505 | | - * configuration exactly. Note: Higher resolutions may affect the responsiveness of |
506 | | - * live view browser |
| 541 | + * Display refresh rate in Hz. If omitted, automatically determined from width and |
| 542 | + * height. |
507 | 543 | */ |
508 | | - export interface Viewport { |
509 | | - /** |
510 | | - * Browser window height in pixels. |
511 | | - */ |
512 | | - height: number; |
513 | | - |
514 | | - /** |
515 | | - * Browser window width in pixels. |
516 | | - */ |
517 | | - width: number; |
518 | | - |
519 | | - /** |
520 | | - * Display refresh rate in Hz. If omitted, automatically determined from width and |
521 | | - * height. |
522 | | - */ |
523 | | - refresh_rate?: number; |
524 | | - } |
| 544 | + refresh_rate?: number; |
525 | 545 | } |
526 | 546 | } |
527 | 547 |
|
@@ -666,6 +686,14 @@ export namespace BrowserCreateParams { |
666 | 686 | } |
667 | 687 | } |
668 | 688 |
|
| 689 | +export interface BrowserListParams extends OffsetPaginationParams { |
| 690 | + /** |
| 691 | + * When true, includes soft-deleted browser sessions in the results alongside |
| 692 | + * active sessions. |
| 693 | + */ |
| 694 | + include_deleted?: boolean; |
| 695 | +} |
| 696 | + |
669 | 697 | export interface BrowserDeleteParams { |
670 | 698 | /** |
671 | 699 | * Persistent browser identifier |
@@ -709,7 +737,9 @@ export declare namespace Browsers { |
709 | 737 | type BrowserCreateResponse as BrowserCreateResponse, |
710 | 738 | type BrowserRetrieveResponse as BrowserRetrieveResponse, |
711 | 739 | type BrowserListResponse as BrowserListResponse, |
| 740 | + type BrowserListResponsesOffsetPagination as BrowserListResponsesOffsetPagination, |
712 | 741 | type BrowserCreateParams as BrowserCreateParams, |
| 742 | + type BrowserListParams as BrowserListParams, |
713 | 743 | type BrowserDeleteParams as BrowserDeleteParams, |
714 | 744 | type BrowserLoadExtensionsParams as BrowserLoadExtensionsParams, |
715 | 745 | }; |
|
0 commit comments