cloudflare
Version:
The official TypeScript library for the Cloudflare API
97 lines • 3.54 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.TURN = exports.BaseTURN = void 0;
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
const resource_1 = require("../../core/resource.js");
const pagination_1 = require("../../core/pagination.js");
const path_1 = require("../../internal/utils/path.js");
var BaseTURN = /* @__PURE__ */ (() => {
class BaseTURN extends resource_1.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((0, path_1.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((0, path_1.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((0, path_1.path) `/accounts/${account_id}/calls/turn_keys`, (pagination_1.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((0, path_1.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((0, path_1.path) `/accounts/${account_id}/calls/turn_keys/${keyID}`, options)._thenUnwrap((obj) => obj.result);
}
}
BaseTURN._key = Object.freeze(['calls', 'turn']);
return BaseTURN;
})();
exports.BaseTURN = BaseTURN;
class TURN extends BaseTURN {
}
exports.TURN = TURN;
//# sourceMappingURL=turn.js.map