cloudflare
Version:
The official TypeScript library for the Cloudflare API
103 lines • 4.12 kB
JavaScript
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from "../../../../core/resource.mjs";
import { path } from "../../../../internal/utils/path.mjs";
export var BaseTargets = /* @__PURE__ */ (() => {
class BaseTargets extends APIResource {
/**
* Opens a new tab in the browser. Optionally specify a URL to navigate to.
*
* @example
* ```ts
* const target =
* await client.browserRendering.devtools.browser.targets.create(
* '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
* { account_id: 'account_id' },
* );
* ```
*/
create(sessionID, params, options) {
const { account_id, liveViewUrlExpiresInMs, url } = params;
return this._client.put(path `/accounts/${account_id}/browser-rendering/devtools/browser/${sessionID}/json/new`, { query: { liveViewUrlExpiresInMs, url }, ...options });
}
/**
* Returns a list of all debuggable targets including tabs, pages, service workers,
* and other browser contexts.
*
* @example
* ```ts
* const targets =
* await client.browserRendering.devtools.browser.targets.list(
* '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
* { account_id: 'account_id' },
* );
* ```
*/
list(sessionID, params, options) {
const { account_id, ...query } = params;
return this._client.get(path `/accounts/${account_id}/browser-rendering/devtools/browser/${sessionID}/json/list`, { query, ...options });
}
/**
* Activates (brings to front) a specific browser target by its ID.
*
* @example
* ```ts
* const response =
* await client.browserRendering.devtools.browser.targets.activate(
* 'target_id',
* {
* account_id: 'account_id',
* session_id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
* },
* );
* ```
*/
activate(targetID, params, options) {
const { account_id, session_id } = params;
return this._client.get(path `/accounts/${account_id}/browser-rendering/devtools/browser/${session_id}/json/activate/${targetID}`, options);
}
/**
* Closes a specific browser target (tab, page, etc.) by its ID. Returns 'Target is
* closing' on success or an error if the target is not found.
*
* @example
* ```ts
* const response =
* await client.browserRendering.devtools.browser.targets.close(
* 'target_id',
* {
* account_id: 'account_id',
* session_id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
* },
* );
* ```
*/
close(targetID, params, options) {
const { account_id, session_id } = params;
return this._client.get(path `/accounts/${account_id}/browser-rendering/devtools/browser/${session_id}/json/close/${targetID}`, options);
}
/**
* Returns the debuggable target with the given ID.
*
* @example
* ```ts
* const target =
* await client.browserRendering.devtools.browser.targets.get(
* 'target_id',
* {
* account_id: 'account_id',
* session_id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
* },
* );
* ```
*/
get(targetID, params, options) {
const { account_id, session_id } = params;
return this._client.get(path `/accounts/${account_id}/browser-rendering/devtools/browser/${session_id}/json/list/${targetID}`, options);
}
}
BaseTargets._key = Object.freeze(['browserRendering', 'devtools', 'browser', 'targets']);
return BaseTargets;
})();
export class Targets extends BaseTargets {
}
//# sourceMappingURL=targets.mjs.map