cloudflare
Version:
The official TypeScript library for the Cloudflare API
130 lines • 5.55 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Relays = exports.BaseRelays = void 0;
const tslib_1 = require("../../../internal/tslib.js");
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
const resource_1 = require("../../../core/resource.js");
const TokensAPI = tslib_1.__importStar(require("./tokens.js"));
const tokens_1 = require("./tokens.js");
const pagination_1 = require("../../../core/pagination.js");
const path_1 = require("../../../internal/utils/path.js");
var BaseRelays = /* @__PURE__ */ (() => {
class BaseRelays extends resource_1.APIResource {
/**
* Provisions a new MoQ relay instance. Auto-creates a publish+subscribe token and
* a subscribe-only token. Token values are included in the response (shown once).
* Config is always set to defaults (upstreams off) and cannot be supplied here —
* sending a non-empty `config` is rejected (21014); `null` or `{}` is accepted as
* absent. Use PUT to configure the relay after it exists.
*
* @example
* ```ts
* const relay = await client.moq.relays.create({
* account_id: '023e105f4ecef8ad9ca31a8372d0c353',
* name: 'Production Live Stream',
* });
* ```
*/
create(params, options) {
const { account_id, ...body } = params;
return this._client.post((0, path_1.path) `/accounts/${account_id}/moq/relays`, { body, ...options })._thenUnwrap((obj) => obj.result);
}
/**
* Updates a relay's name and/or configuration. The relay ID goes in the URL path —
* `PUT /accounts/{account_id}/moq/relays/{relay_id}` — not the request body; there
* is no collection-level update endpoint. This is also the only way to set a
* relay's config (config cannot be set at create time). Partial updates: omitted
* fields are preserved; config sub-objects replace as whole objects when present.
*
* @example
* ```ts
* const relay = await client.moq.relays.update(
* 'a1b2c3d4e5f67890a1b2c3d4e5f67890',
* { account_id: '023e105f4ecef8ad9ca31a8372d0c353' },
* );
* ```
*/
update(relayID, params, options) {
const { account_id, ...body } = params;
return this._client.put((0, path_1.path) `/accounts/${account_id}/moq/relays/${relayID}`, {
body,
...options,
})._thenUnwrap((obj) => obj.result);
}
/**
* Lists all MoQ relays for the account. Returns only metadata. Config, status, and
* tokens are omitted.
*
* Results are cursor-paginated (keyset on the `created` timestamp). Use
* `created_before` / `created_after` with the `created` value of the first/last
* item in a page to fetch the adjacent page. `result_info` reports the page
* `count` and the `total` matching the cursor filters.
*
* @example
* ```ts
* // Automatically fetches more pages as needed.
* for await (const relayListResponse of client.moq.relays.list(
* { account_id: '023e105f4ecef8ad9ca31a8372d0c353' },
* )) {
* // ...
* }
* ```
*/
list(params, options) {
const { account_id, ...query } = params;
return this._client.getAPIList((0, path_1.path) `/accounts/${account_id}/moq/relays`, (pagination_1.SinglePage), {
query,
...options,
});
}
/**
* Soft-deletes a MoQ relay. The relay ID goes in the URL path —
* `DELETE /accounts/{account_id}/moq/relays/{relay_id}` — not the request body;
* there is no collection-level delete endpoint.
*
* @example
* ```ts
* const relay = await client.moq.relays.delete(
* 'a1b2c3d4e5f67890a1b2c3d4e5f67890',
* { account_id: '023e105f4ecef8ad9ca31a8372d0c353' },
* );
* ```
*/
delete(relayID, params, options) {
const { account_id } = params;
return this._client.delete((0, path_1.path) `/accounts/${account_id}/moq/relays/${relayID}`, options)._thenUnwrap((obj) => obj.result);
}
/**
* Retrieves a single MoQ relay including config and status. Tokens are NOT
* included.
*
* @example
* ```ts
* const relay = await client.moq.relays.get(
* 'a1b2c3d4e5f67890a1b2c3d4e5f67890',
* { account_id: '023e105f4ecef8ad9ca31a8372d0c353' },
* );
* ```
*/
get(relayID, params, options) {
const { account_id } = params;
return this._client.get((0, path_1.path) `/accounts/${account_id}/moq/relays/${relayID}`, options)._thenUnwrap((obj) => obj.result);
}
}
BaseRelays._key = Object.freeze(['moq', 'relays']);
return BaseRelays;
})();
exports.BaseRelays = BaseRelays;
var Relays = /* @__PURE__ */ (() => {
class Relays extends BaseRelays {
constructor() {
super(...arguments);
this.tokens = new TokensAPI.Tokens(this._client);
}
}
Relays.Tokens = tokens_1.Tokens;
Relays.BaseTokens = tokens_1.BaseTokens;
return Relays;
})();
exports.Relays = Relays;
//# sourceMappingURL=relays.js.map