UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

122 lines • 4.63 kB
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from "../../../core/resource.mjs"; import * as RegionsAPI from "./regions.mjs"; import { BaseRegions, Regions, } from "./regions.mjs"; import { SinglePage } from "../../../core/pagination.mjs"; import { path } from "../../../internal/utils/path.mjs"; export var BaseRegionalHostnames = /* @__PURE__ */ (() => { class BaseRegionalHostnames extends 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(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(path `/zones/${zone_id}/addressing/regional_hostnames`, (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(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(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(path `/zones/${zone_id}/addressing/regional_hostnames/${hostname}`, options)._thenUnwrap((obj) => obj.result); } } BaseRegionalHostnames._key = Object.freeze([ 'addressing', 'regionalHostnames', ]); return BaseRegionalHostnames; })(); export var RegionalHostnames = /* @__PURE__ */ (() => { class RegionalHostnames extends BaseRegionalHostnames { constructor() { super(...arguments); this.regions = new RegionsAPI.Regions(this._client); } } RegionalHostnames.Regions = Regions; RegionalHostnames.BaseRegions = BaseRegions; return RegionalHostnames; })(); //# sourceMappingURL=regional-hostnames.mjs.map