cloudflare
Version:
The official TypeScript library for the Cloudflare API
173 lines • 6.61 kB
JavaScript
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from "../../core/resource.mjs";
import * as PageAPI from "./page.mjs";
import { BasePage, Page } from "./page.mjs";
import * as RulesAPI from "./rules.mjs";
import { BaseRules, Rules, } from "./rules.mjs";
import * as SettingsAPI from "./settings.mjs";
import { BaseSettings, Settings, } from "./settings.mjs";
import * as StatusesAPI from "./statuses.mjs";
import { BaseStatuses, Statuses } from "./statuses.mjs";
import * as EventsAPI from "./events/events.mjs";
import { BaseEvents, Events, } from "./events/events.mjs";
import { CloudflareError } from "../../core/error.mjs";
import { V4PagePaginationArray } from "../../core/pagination.mjs";
import { path } from "../../internal/utils/path.mjs";
export var BaseWaitingRooms = /* @__PURE__ */ (() => {
class BaseWaitingRooms extends APIResource {
/**
* Creates a new waiting room.
*
* @example
* ```ts
* const waitingRoom = await client.waitingRooms.create({
* zone_id: '023e105f4ecef8ad9ca31a8372d0c353',
* host: 'shop.example.com',
* name: 'production_webinar',
* new_users_per_minute: 200,
* total_active_users: 200,
* });
* ```
*/
create(params, options) {
const { zone_id, ...body } = params;
return this._client.post(path `/zones/${zone_id}/waiting_rooms`, { body, ...options })._thenUnwrap((obj) => obj.result);
}
/**
* Updates a configured waiting room.
*
* @example
* ```ts
* const waitingRoom = await client.waitingRooms.update(
* '699d98642c564d2e855e9661899b7252',
* {
* zone_id: '023e105f4ecef8ad9ca31a8372d0c353',
* host: 'shop.example.com',
* name: 'production_webinar',
* new_users_per_minute: 200,
* total_active_users: 200,
* },
* );
* ```
*/
update(waitingRoomID, params, options) {
const { zone_id, ...body } = params;
return this._client.put(path `/zones/${zone_id}/waiting_rooms/${waitingRoomID}`, {
body,
...options,
})._thenUnwrap((obj) => obj.result);
}
/**
* Lists waiting rooms for account or zone.
*
* @example
* ```ts
* // Automatically fetches more pages as needed.
* for await (const waitingRoom of client.waitingRooms.list({
* account_id: 'account_id',
* })) {
* // ...
* }
* ```
*/
list(params = {}, options) {
const { account_id, zone_id, ...query } = params ?? {};
if (!account_id && !zone_id) {
throw new CloudflareError('You must provide either account_id or zone_id.');
}
if (account_id && zone_id) {
throw new CloudflareError('You cannot provide both account_id and zone_id.');
}
const { accountOrZone, accountOrZoneId } = account_id ?
{
accountOrZone: 'accounts',
accountOrZoneId: account_id,
}
: {
accountOrZone: 'zones',
accountOrZoneId: zone_id,
};
return this._client.getAPIList(path `/${accountOrZone}/${accountOrZoneId}/waiting_rooms`, (V4PagePaginationArray), { query, ...options });
}
/**
* Deletes a waiting room.
*
* @example
* ```ts
* const waitingRoom = await client.waitingRooms.delete(
* '699d98642c564d2e855e9661899b7252',
* { zone_id: '023e105f4ecef8ad9ca31a8372d0c353' },
* );
* ```
*/
delete(waitingRoomID, params, options) {
const { zone_id } = params;
return this._client.delete(path `/zones/${zone_id}/waiting_rooms/${waitingRoomID}`, options)._thenUnwrap((obj) => obj.result);
}
/**
* Patches a configured waiting room.
*
* @example
* ```ts
* const waitingRoom = await client.waitingRooms.edit(
* '699d98642c564d2e855e9661899b7252',
* {
* zone_id: '023e105f4ecef8ad9ca31a8372d0c353',
* host: 'shop.example.com',
* name: 'production_webinar',
* new_users_per_minute: 200,
* total_active_users: 200,
* },
* );
* ```
*/
edit(waitingRoomID, params, options) {
const { zone_id, ...body } = params;
return this._client.patch(path `/zones/${zone_id}/waiting_rooms/${waitingRoomID}`, {
body,
...options,
})._thenUnwrap((obj) => obj.result);
}
/**
* Fetches a single configured waiting room.
*
* @example
* ```ts
* const waitingRoom = await client.waitingRooms.get(
* '699d98642c564d2e855e9661899b7252',
* { zone_id: '023e105f4ecef8ad9ca31a8372d0c353' },
* );
* ```
*/
get(waitingRoomID, params, options) {
const { zone_id } = params;
return this._client.get(path `/zones/${zone_id}/waiting_rooms/${waitingRoomID}`, options)._thenUnwrap((obj) => obj.result);
}
}
BaseWaitingRooms._key = Object.freeze(['waitingRooms']);
return BaseWaitingRooms;
})();
export var WaitingRooms = /* @__PURE__ */ (() => {
class WaitingRooms extends BaseWaitingRooms {
constructor() {
super(...arguments);
this.page = new PageAPI.Page(this._client);
this.events = new EventsAPI.Events(this._client);
this.rules = new RulesAPI.Rules(this._client);
this.statuses = new StatusesAPI.Statuses(this._client);
this.settings = new SettingsAPI.Settings(this._client);
}
}
WaitingRooms.Page = Page;
WaitingRooms.BasePage = BasePage;
WaitingRooms.Events = Events;
WaitingRooms.BaseEvents = BaseEvents;
WaitingRooms.Rules = Rules;
WaitingRooms.BaseRules = BaseRules;
WaitingRooms.Statuses = Statuses;
WaitingRooms.BaseStatuses = BaseStatuses;
WaitingRooms.Settings = Settings;
WaitingRooms.BaseSettings = BaseSettings;
return WaitingRooms;
})();
//# sourceMappingURL=waiting-rooms.mjs.map