UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

86 lines • 3.59 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Holds = exports.BaseHolds = void 0; // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. const resource_1 = require("../../core/resource.js"); const path_1 = require("../../internal/utils/path.js"); var BaseHolds = /* @__PURE__ */ (() => { class BaseHolds extends resource_1.APIResource { /** * Enforce a zone hold on the zone, blocking the creation and activation of zones * with this zone's hostname. Zone holds cannot be enabled on CDN-only zones. * * @example * ```ts * const zoneHold = await client.zones.holds.create({ * zone_id: '023e105f4ecef8ad9ca31a8372d0c353', * }); * ``` */ create(params, options) { const { zone_id, include_subdomains } = params; return this._client.post((0, path_1.path) `/zones/${zone_id}/hold`, { query: { include_subdomains }, ...options, })._thenUnwrap((obj) => obj.result); } /** * Stop enforcement of a zone hold on the zone, permanently or temporarily, * allowing the creation and activation of zones with this zone's hostname. * Existing zone holds can be removed from CDN-only zones when `hold_after` is not * provided. Active holds are automatically disabled when a zone transitions to * CDN-only mode. * * @example * ```ts * const zoneHold = await client.zones.holds.delete({ * zone_id: '023e105f4ecef8ad9ca31a8372d0c353', * }); * ``` */ delete(params, options) { const { zone_id, hold_after } = params; return this._client.delete((0, path_1.path) `/zones/${zone_id}/hold`, { query: { hold_after }, ...options })._thenUnwrap((obj) => obj.result); } /** * Update the `hold_after` and/or `include_subdomains` values on an existing zone * hold. The hold is enabled if the `hold_after` date-time value is in the past. * Existing zone holds can be removed from CDN-only zones by setting `hold_after` * to `null`. Other zone hold updates cannot be made on CDN-only zones. Active * holds are automatically disabled when a zone transitions to CDN-only mode. * * @example * ```ts * const zoneHold = await client.zones.holds.edit({ * zone_id: '023e105f4ecef8ad9ca31a8372d0c353', * }); * ``` */ edit(params, options) { const { zone_id, ...body } = params; return this._client.patch((0, path_1.path) `/zones/${zone_id}/hold`, { body, ...options })._thenUnwrap((obj) => obj.result); } /** * Retrieve whether the zone is subject to a zone hold, and metadata about the * hold. * * @example * ```ts * const zoneHold = await client.zones.holds.get({ * zone_id: '023e105f4ecef8ad9ca31a8372d0c353', * }); * ``` */ get(params, options) { const { zone_id } = params; return this._client.get((0, path_1.path) `/zones/${zone_id}/hold`, options)._thenUnwrap((obj) => obj.result); } } BaseHolds._key = Object.freeze(['zones', 'holds']); return BaseHolds; })(); exports.BaseHolds = BaseHolds; class Holds extends BaseHolds { } exports.Holds = Holds; //# sourceMappingURL=holds.js.map