UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

137 lines • 6.67 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.CustomHostnames = exports.BaseCustomHostnames = 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 FallbackOriginAPI = tslib_1.__importStar(require("./fallback-origin.js")); const fallback_origin_1 = require("./fallback-origin.js"); const QuotaAPI = tslib_1.__importStar(require("./quota.js")); const quota_1 = require("./quota.js"); const CertificatePackAPI = tslib_1.__importStar(require("./certificate-pack/certificate-pack.js")); const certificate_pack_1 = require("./certificate-pack/certificate-pack.js"); const pagination_1 = require("../../core/pagination.js"); const path_1 = require("../../internal/utils/path.js"); var BaseCustomHostnames = /* @__PURE__ */ (() => { class BaseCustomHostnames extends resource_1.APIResource { /** * Add a new custom hostname and request that an SSL certificate be issued for it. * One of three validation methods—http, txt, email—should be used, with 'http' * recommended if the CNAME is already in place (or will be soon). Specifying * 'email' will send an email to the WHOIS contacts on file for the base domain * plus hostmaster, postmaster, webmaster, admin, administrator. If http is used * and the domain is not already pointing to the Managed CNAME host, the PATCH * method must be used once it is (to complete validation). Enable bundling of * certificates using the custom_cert_bundle field. The bundling process requires * the following condition One certificate in the bundle must use an RSA, and the * other must use an ECDSA. * * @example * ```ts * const customHostname = await client.customHostnames.create({ * zone_id: '023e105f4ecef8ad9ca31a8372d0c353', * hostname: 'app.example.com', * }); * ``` */ create(params, options) { const { zone_id, ...body } = params; return this._client.post((0, path_1.path) `/zones/${zone_id}/custom_hostnames`, { body, ...options })._thenUnwrap((obj) => obj.result); } /** * List, search, sort, and filter all of your custom hostnames. * * @example * ```ts * // Automatically fetches more pages as needed. * for await (const customHostnameListResponse of client.customHostnames.list( * { zone_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * )) { * // ... * } * ``` */ list(params, options) { const { zone_id, ...query } = params; return this._client.getAPIList((0, path_1.path) `/zones/${zone_id}/custom_hostnames`, (pagination_1.V4PagePaginationArray), { query, ...options }); } /** * Permanently deletes a custom hostname and revokes any SSL certificates that were * issued for it. This action cannot be undone. * * @example * ```ts * const customHostname = await client.customHostnames.delete( * '0d89c70d-ad9f-4843-b99f-6cc0252067e9', * { zone_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * ); * ``` */ delete(customHostnameID, params, options) { const { zone_id } = params; return this._client.delete((0, path_1.path) `/zones/${zone_id}/custom_hostnames/${customHostnameID}`, options); } /** * Modify SSL configuration for a custom hostname. When sent with SSL config that * matches existing config, used to indicate that hostname should pass domain * control validation (DCV). Can also be used to change validation type, e.g., from * 'http' to 'email'. Bundle an existing certificate with another certificate by * using the "custom_cert_bundle" field. The bundling process supports combining * certificates as long as the following condition is met. One certificate must use * the RSA algorithm, and the other must use the ECDSA algorithm. * * @example * ```ts * const response = await client.customHostnames.edit( * '0d89c70d-ad9f-4843-b99f-6cc0252067e9', * { zone_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * ); * ``` */ edit(customHostnameID, params, options) { const { zone_id, ...body } = params; return this._client.patch((0, path_1.path) `/zones/${zone_id}/custom_hostnames/${customHostnameID}`, { body, ...options, })._thenUnwrap((obj) => obj.result); } /** * Retrieves detailed information about a specific custom hostname, including SSL * certificate status, ownership verification, and origin configuration. * * @example * ```ts * const customHostname = await client.customHostnames.get( * '0d89c70d-ad9f-4843-b99f-6cc0252067e9', * { zone_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * ); * ``` */ get(customHostnameID, params, options) { const { zone_id } = params; return this._client.get((0, path_1.path) `/zones/${zone_id}/custom_hostnames/${customHostnameID}`, options)._thenUnwrap((obj) => obj.result); } } BaseCustomHostnames._key = Object.freeze(['customHostnames']); return BaseCustomHostnames; })(); exports.BaseCustomHostnames = BaseCustomHostnames; var CustomHostnames = /* @__PURE__ */ (() => { class CustomHostnames extends BaseCustomHostnames { constructor() { super(...arguments); this.fallbackOrigin = new FallbackOriginAPI.FallbackOrigin(this._client); this.certificatePack = new CertificatePackAPI.CertificatePack(this._client); this.quota = new QuotaAPI.Quota(this._client); } } CustomHostnames.FallbackOrigin = fallback_origin_1.FallbackOrigin; CustomHostnames.BaseFallbackOrigin = fallback_origin_1.BaseFallbackOrigin; CustomHostnames.CertificatePack = certificate_pack_1.CertificatePack; CustomHostnames.BaseCertificatePack = certificate_pack_1.BaseCertificatePack; CustomHostnames.Quota = quota_1.Quota; CustomHostnames.BaseQuota = quota_1.BaseQuota; return CustomHostnames; })(); exports.CustomHostnames = CustomHostnames; //# sourceMappingURL=custom-hostnames.js.map