UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

128 lines • 5.04 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.RegionalHostnames = exports.BaseRegionalHostnames = void 0; const tslib_1 = require("../../../internal/tslib.js"); // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. const resource_1 = require("../../../core/resource.js"); const RegionsAPI = tslib_1.__importStar(require("./regions.js")); const regions_1 = require("./regions.js"); const pagination_1 = require("../../../core/pagination.js"); const path_1 = require("../../../internal/utils/path.js"); var BaseRegionalHostnames = /* @__PURE__ */ (() => { class BaseRegionalHostnames extends resource_1.APIResource { /** * Create a new Regional Hostname entry. Cloudflare will only use data centers that * are physically located within the chosen region to decrypt and service HTTPS * traffic. Learn more about * [Regional Services](https://developers.cloudflare.com/data-localization/regional-services/get-started/). * * @example * ```ts * const regionalHostname = * await client.addressing.regionalHostnames.create({ * zone_id: '023e105f4ecef8ad9ca31a8372d0c353', * hostname: 'foo.example.com', * region_key: 'ca', * }); * ``` */ create(params, options) { const { zone_id, ...body } = params; return this._client.post((0, path_1.path) `/zones/${zone_id}/addressing/regional_hostnames`, { body, ...options, })._thenUnwrap((obj) => obj.result); } /** * List all Regional Hostnames within a zone. * * @example * ```ts * // Automatically fetches more pages as needed. * for await (const regionalHostnameListResponse of client.addressing.regionalHostnames.list( * { zone_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * )) { * // ... * } * ``` */ list(params, options) { const { zone_id } = params; return this._client.getAPIList((0, path_1.path) `/zones/${zone_id}/addressing/regional_hostnames`, (pagination_1.SinglePage), options); } /** * Delete the region configuration for a specific Regional Hostname. * * @example * ```ts * const regionalHostname = * await client.addressing.regionalHostnames.delete( * 'foo.example.com', * { zone_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * ); * ``` */ delete(hostname, params, options) { const { zone_id } = params; return this._client.delete((0, path_1.path) `/zones/${zone_id}/addressing/regional_hostnames/${hostname}`, options); } /** * Update the configuration for a specific Regional Hostname. Only the region_key * of a hostname is mutable. * * @example * ```ts * const response = * await client.addressing.regionalHostnames.edit( * 'foo.example.com', * { * zone_id: '023e105f4ecef8ad9ca31a8372d0c353', * region_key: 'ca', * }, * ); * ``` */ edit(hostname, params, options) { const { zone_id, ...body } = params; return this._client.patch((0, path_1.path) `/zones/${zone_id}/addressing/regional_hostnames/${hostname}`, { body, ...options, })._thenUnwrap((obj) => obj.result); } /** * Fetch the configuration for a specific Regional Hostname, within a zone. * * @example * ```ts * const regionalHostname = * await client.addressing.regionalHostnames.get( * 'foo.example.com', * { zone_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * ); * ``` */ get(hostname, params, options) { const { zone_id } = params; return this._client.get((0, path_1.path) `/zones/${zone_id}/addressing/regional_hostnames/${hostname}`, options)._thenUnwrap((obj) => obj.result); } } BaseRegionalHostnames._key = Object.freeze([ 'addressing', 'regionalHostnames', ]); return BaseRegionalHostnames; })(); exports.BaseRegionalHostnames = BaseRegionalHostnames; var RegionalHostnames = /* @__PURE__ */ (() => { class RegionalHostnames extends BaseRegionalHostnames { constructor() { super(...arguments); this.regions = new RegionsAPI.Regions(this._client); } } RegionalHostnames.Regions = regions_1.Regions; RegionalHostnames.BaseRegions = regions_1.BaseRegions; return RegionalHostnames; })(); exports.RegionalHostnames = RegionalHostnames; //# sourceMappingURL=regional-hostnames.js.map