UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

131 lines • 6.22 kB
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from "../../core/resource.mjs"; import * as FallbackOriginAPI from "./fallback-origin.mjs"; import { BaseFallbackOrigin, FallbackOrigin, } from "./fallback-origin.mjs"; import * as QuotaAPI from "./quota.mjs"; import { BaseQuota, Quota } from "./quota.mjs"; import * as CertificatePackAPI from "./certificate-pack/certificate-pack.mjs"; import { BaseCertificatePack, CertificatePack } from "./certificate-pack/certificate-pack.mjs"; import { V4PagePaginationArray } from "../../core/pagination.mjs"; import { path } from "../../internal/utils/path.mjs"; export var BaseCustomHostnames = /* @__PURE__ */ (() => { class BaseCustomHostnames extends 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(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(path `/zones/${zone_id}/custom_hostnames`, (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(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(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(path `/zones/${zone_id}/custom_hostnames/${customHostnameID}`, options)._thenUnwrap((obj) => obj.result); } } BaseCustomHostnames._key = Object.freeze(['customHostnames']); return BaseCustomHostnames; })(); export 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 = FallbackOrigin; CustomHostnames.BaseFallbackOrigin = BaseFallbackOrigin; CustomHostnames.CertificatePack = CertificatePack; CustomHostnames.BaseCertificatePack = BaseCertificatePack; CustomHostnames.Quota = Quota; CustomHostnames.BaseQuota = BaseQuota; return CustomHostnames; })(); //# sourceMappingURL=custom-hostnames.mjs.map