UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

92 lines • 3.3 kB
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from "../../core/resource.mjs"; import { SinglePage } from "../../core/pagination.mjs"; import { path } from "../../internal/utils/path.mjs"; export var BaseTURN = /* @__PURE__ */ (() => { class BaseTURN extends APIResource { /** * Creates a new Realtime TURN key. * * @example * ```ts * const turn = await client.calls.turn.create({ * account_id: '023e105f4ecef8ad9ca31a8372d0c353', * }); * ``` */ create(params, options) { const { account_id, ...body } = params; return this._client.post(path `/accounts/${account_id}/calls/turn_keys`, { body, ...options })._thenUnwrap((obj) => obj.result); } /** * Updates details for a single TURN key. * * @example * ```ts * const turn = await client.calls.turn.update( * '2a95132c15732412d22c1476fa83f27a', * { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * ); * ``` */ update(keyID, params, options) { const { account_id, ...body } = params; return this._client.put(path `/accounts/${account_id}/calls/turn_keys/${keyID}`, { body, ...options, })._thenUnwrap((obj) => obj.result); } /** * Lists all TURN keys in the Cloudflare account. * * @example * ```ts * // Automatically fetches more pages as needed. * for await (const turnListResponse of client.calls.turn.list( * { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * )) { * // ... * } * ``` */ list(params, options) { const { account_id } = params; return this._client.getAPIList(path `/accounts/${account_id}/calls/turn_keys`, (SinglePage), options); } /** * Deletes a Realtime TURN key. * * @example * ```ts * const turn = await client.calls.turn.delete( * '2a95132c15732412d22c1476fa83f27a', * { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * ); * ``` */ delete(keyID, params, options) { const { account_id } = params; return this._client.delete(path `/accounts/${account_id}/calls/turn_keys/${keyID}`, options)._thenUnwrap((obj) => obj.result); } /** * Fetches details for a single TURN key. * * @example * ```ts * const turn = await client.calls.turn.get( * '2a95132c15732412d22c1476fa83f27a', * { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * ); * ``` */ get(keyID, params, options) { const { account_id } = params; return this._client.get(path `/accounts/${account_id}/calls/turn_keys/${keyID}`, options)._thenUnwrap((obj) => obj.result); } } BaseTURN._key = Object.freeze(['calls', 'turn']); return BaseTURN; })(); export class TURN extends BaseTURN { } //# sourceMappingURL=turn.mjs.map