|
| 1 | +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. |
| 2 | + |
| 3 | +import { APIResource } from '../../core/resource'; |
| 4 | +import { APIPromise } from '../../core/api-promise'; |
| 5 | +import { RequestOptions } from '../../internal/request-options'; |
| 6 | +import { path } from '../../internal/utils/path'; |
| 7 | + |
| 8 | +/** |
| 9 | + * Create and manage browser sessions. |
| 10 | + */ |
| 11 | +export class LiveView extends APIResource { |
| 12 | + /** |
| 13 | + * Creates a live view URL for a headful browser that grants either read-only or |
| 14 | + * control access. The URL works only for the live view: it cannot connect to CDP, |
| 15 | + * WebDriver, or any other browser endpoint. A read-only URL shows the browser but |
| 16 | + * cannot send input, regardless of query parameters. The URL stays valid until the |
| 17 | + * browser is deleted, or until `ttl_seconds` elapse when set. For a browser |
| 18 | + * acquired from a pool, it stops working when the browser is released. Nothing is |
| 19 | + * stored, so a URL cannot be revoked before then. |
| 20 | + * |
| 21 | + * @example |
| 22 | + * ```ts |
| 23 | + * const browserLiveView = |
| 24 | + * await client.browsers.liveView.create( |
| 25 | + * 'htzv5orfit78e1m2biiifpbv', |
| 26 | + * ); |
| 27 | + * ``` |
| 28 | + */ |
| 29 | + create( |
| 30 | + idOrName: string, |
| 31 | + body: LiveViewCreateParams | null | undefined = {}, |
| 32 | + options?: RequestOptions, |
| 33 | + ): APIPromise<BrowserLiveView> { |
| 34 | + return this._client.post(path`/browsers/${idOrName}/live_view`, { body, ...options }); |
| 35 | + } |
| 36 | +} |
| 37 | + |
| 38 | +export interface BrowserLiveView { |
| 39 | + /** |
| 40 | + * `read` shows the browser without accepting input. `control` also lets the viewer |
| 41 | + * drive the browser through the live view. |
| 42 | + */ |
| 43 | + scope: BrowserLiveViewScope; |
| 44 | + |
| 45 | + /** |
| 46 | + * Live view URL. Treat it as a credential. |
| 47 | + */ |
| 48 | + url: string; |
| 49 | + |
| 50 | + /** |
| 51 | + * When the URL expires. Absent when it stays valid until the browser is deleted. |
| 52 | + */ |
| 53 | + expires_at?: string; |
| 54 | +} |
| 55 | + |
| 56 | +export interface BrowserLiveViewRequest { |
| 57 | + /** |
| 58 | + * `read` shows the browser without accepting input. `control` also lets the viewer |
| 59 | + * drive the browser through the live view. |
| 60 | + */ |
| 61 | + scope?: BrowserLiveViewScope; |
| 62 | + |
| 63 | + /** |
| 64 | + * Seconds until the URL expires. Omit to keep it valid until the browser is |
| 65 | + * deleted. |
| 66 | + */ |
| 67 | + ttl_seconds?: number; |
| 68 | +} |
| 69 | + |
| 70 | +/** |
| 71 | + * `read` shows the browser without accepting input. `control` also lets the viewer |
| 72 | + * drive the browser through the live view. |
| 73 | + */ |
| 74 | +export type BrowserLiveViewScope = 'read' | 'control'; |
| 75 | + |
| 76 | +export interface LiveViewCreateParams { |
| 77 | + /** |
| 78 | + * `read` shows the browser without accepting input. `control` also lets the viewer |
| 79 | + * drive the browser through the live view. |
| 80 | + */ |
| 81 | + scope?: BrowserLiveViewScope; |
| 82 | + |
| 83 | + /** |
| 84 | + * Seconds until the URL expires. Omit to keep it valid until the browser is |
| 85 | + * deleted. |
| 86 | + */ |
| 87 | + ttl_seconds?: number; |
| 88 | +} |
| 89 | + |
| 90 | +export declare namespace LiveView { |
| 91 | + export { |
| 92 | + type BrowserLiveView as BrowserLiveView, |
| 93 | + type BrowserLiveViewRequest as BrowserLiveViewRequest, |
| 94 | + type BrowserLiveViewScope as BrowserLiveViewScope, |
| 95 | + type LiveViewCreateParams as LiveViewCreateParams, |
| 96 | + }; |
| 97 | +} |
0 commit comments