UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

69 lines • 2.39 kB
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from "../../core/resource.mjs"; import { path } from "../../internal/utils/path.mjs"; export var BaseScheduleResource = /* @__PURE__ */ (() => { class BaseScheduleResource extends APIResource { /** * Creates a scheduled test for a page. * * @example * ```ts * const schedule = await client.speed.schedule.create( * 'example.com', * { zone_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * ); * ``` */ create(url, params, options) { const { zone_id, frequency, region } = params; return this._client.post(path `/zones/${zone_id}/speed_api/schedule/${url}`, { query: { frequency, region }, ...options, })._thenUnwrap((obj) => obj.result); } /** * Deletes a scheduled test for a page. * * @example * ```ts * const schedule = await client.speed.schedule.delete( * 'example.com', * { zone_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * ); * ``` */ delete(url, params, options) { const { zone_id, region } = params; return this._client.delete(path `/zones/${zone_id}/speed_api/schedule/${url}`, { query: { region }, ...options, })._thenUnwrap((obj) => obj.result); } /** * Retrieves the test schedule for a page in a specific region. * * @example * ```ts * const schedule = await client.speed.schedule.get( * 'example.com', * { zone_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * ); * ``` */ get(url, params, options) { const { zone_id, ...query } = params; return this._client.get(path `/zones/${zone_id}/speed_api/schedule/${url}`, { query, ...options, })._thenUnwrap((obj) => obj.result); } } BaseScheduleResource._key = Object.freeze([ 'speed', 'schedule', ]); return BaseScheduleResource; })(); export class ScheduleResource extends BaseScheduleResource { } //# sourceMappingURL=schedule.mjs.map