UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

157 lines • 6.15 kB
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from "../../../core/resource.mjs"; import * as DetailsAPI from "./details.mjs"; import { BaseDetails, Details } from "./details.mjs"; import { V4PagePaginationArray, } from "../../../core/pagination.mjs"; import { path } from "../../../internal/utils/path.mjs"; export var BaseEvents = /* @__PURE__ */ (() => { class BaseEvents extends APIResource { /** * Only available for the Waiting Room Advanced subscription. Creates an event for * a waiting room. An event takes place during a specified period of time, * temporarily changing the behavior of a waiting room. While the event is active, * some of the properties in the event's configuration may either override or * inherit from the waiting room's configuration. Note that events cannot overlap * with each other, so only one event can be active at a time. * * @example * ```ts * const event = await client.waitingRooms.events.create( * '699d98642c564d2e855e9661899b7252', * { * zone_id: '023e105f4ecef8ad9ca31a8372d0c353', * event_end_time: '2021-09-28T17:00:00Z', * event_start_time: '2021-09-28T15:30:00Z', * name: 'production_webinar_event', * }, * ); * ``` */ create(waitingRoomID, params, options) { const { zone_id, ...body } = params; return this._client.post(path `/zones/${zone_id}/waiting_rooms/${waitingRoomID}/events`, { body, ...options, })._thenUnwrap((obj) => obj.result); } /** * Updates a configured event for a waiting room. * * @example * ```ts * const event = await client.waitingRooms.events.update( * '25756b2dfe6e378a06b033b670413757', * { * zone_id: '023e105f4ecef8ad9ca31a8372d0c353', * waiting_room_id: '699d98642c564d2e855e9661899b7252', * event_end_time: '2021-09-28T17:00:00Z', * event_start_time: '2021-09-28T15:30:00Z', * name: 'production_webinar_event', * }, * ); * ``` */ update(eventID, params, options) { const { zone_id, waiting_room_id, ...body } = params; return this._client.put(path `/zones/${zone_id}/waiting_rooms/${waiting_room_id}/events/${eventID}`, { body, ...options, })._thenUnwrap((obj) => obj.result); } /** * Lists events for a waiting room. * * @example * ```ts * // Automatically fetches more pages as needed. * for await (const event of client.waitingRooms.events.list( * '699d98642c564d2e855e9661899b7252', * { zone_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * )) { * // ... * } * ``` */ list(waitingRoomID, params, options) { const { zone_id, ...query } = params; return this._client.getAPIList(path `/zones/${zone_id}/waiting_rooms/${waitingRoomID}/events`, (V4PagePaginationArray), { query, ...options }); } /** * Deletes an event for a waiting room. * * @example * ```ts * const event = await client.waitingRooms.events.delete( * '25756b2dfe6e378a06b033b670413757', * { * zone_id: '023e105f4ecef8ad9ca31a8372d0c353', * waiting_room_id: '699d98642c564d2e855e9661899b7252', * }, * ); * ``` */ delete(eventID, params, options) { const { zone_id, waiting_room_id } = params; return this._client.delete(path `/zones/${zone_id}/waiting_rooms/${waiting_room_id}/events/${eventID}`, options)._thenUnwrap((obj) => obj.result); } /** * Patches a configured event for a waiting room. * * @example * ```ts * const event = await client.waitingRooms.events.edit( * '25756b2dfe6e378a06b033b670413757', * { * zone_id: '023e105f4ecef8ad9ca31a8372d0c353', * waiting_room_id: '699d98642c564d2e855e9661899b7252', * event_end_time: '2021-09-28T17:00:00Z', * event_start_time: '2021-09-28T15:30:00Z', * name: 'production_webinar_event', * }, * ); * ``` */ edit(eventID, params, options) { const { zone_id, waiting_room_id, ...body } = params; return this._client.patch(path `/zones/${zone_id}/waiting_rooms/${waiting_room_id}/events/${eventID}`, { body, ...options, })._thenUnwrap((obj) => obj.result); } /** * Fetches a single configured event for a waiting room. * * @example * ```ts * const event = await client.waitingRooms.events.get( * '25756b2dfe6e378a06b033b670413757', * { * zone_id: '023e105f4ecef8ad9ca31a8372d0c353', * waiting_room_id: '699d98642c564d2e855e9661899b7252', * }, * ); * ``` */ get(eventID, params, options) { const { zone_id, waiting_room_id } = params; return this._client.get(path `/zones/${zone_id}/waiting_rooms/${waiting_room_id}/events/${eventID}`, options)._thenUnwrap((obj) => obj.result); } } BaseEvents._key = Object.freeze([ 'waitingRooms', 'events', ]); return BaseEvents; })(); export var Events = /* @__PURE__ */ (() => { class Events extends BaseEvents { constructor() { super(...arguments); this.details = new DetailsAPI.Details(this._client); } } Events.Details = Details; Events.BaseDetails = BaseDetails; return Events; })(); //# sourceMappingURL=events.mjs.map