cloudflare
Version:
The official TypeScript library for the Cloudflare API
124 lines • 5.21 kB
JavaScript
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from "../../../core/resource.mjs";
import * as TokensAPI from "./tokens.mjs";
import { BaseTokens, Tokens, } from "./tokens.mjs";
import { SinglePage } from "../../../core/pagination.mjs";
import { path } from "../../../internal/utils/path.mjs";
export var BaseRelays = /* @__PURE__ */ (() => {
class BaseRelays extends 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(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(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(path `/accounts/${account_id}/moq/relays`, (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(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(path `/accounts/${account_id}/moq/relays/${relayID}`, options)._thenUnwrap((obj) => obj.result);
}
}
BaseRelays._key = Object.freeze(['moq', 'relays']);
return BaseRelays;
})();
export var Relays = /* @__PURE__ */ (() => {
class Relays extends BaseRelays {
constructor() {
super(...arguments);
this.tokens = new TokensAPI.Tokens(this._client);
}
}
Relays.Tokens = Tokens;
Relays.BaseTokens = BaseTokens;
return Relays;
})();
//# sourceMappingURL=relays.mjs.map