cloudflare
Version:
The official TypeScript library for the Cloudflare API
73 lines • 2.92 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.FallbackOrigin = exports.BaseFallbackOrigin = 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 BaseFallbackOrigin = /* @__PURE__ */ (() => {
class BaseFallbackOrigin extends resource_1.APIResource {
/**
* Updates the fallback origin configuration for custom hostnames on a zone. Sets
* the default origin server for custom hostname traffic.
*
* @example
* ```ts
* const fallbackOrigin =
* await client.customHostnames.fallbackOrigin.update({
* zone_id: '023e105f4ecef8ad9ca31a8372d0c353',
* origin: 'fallback.example.com',
* });
* ```
*/
update(params, options) {
const { zone_id, ...body } = params;
return this._client.put((0, path_1.path) `/zones/${zone_id}/custom_hostnames/fallback_origin`, {
body,
...options,
})._thenUnwrap((obj) => obj.result);
}
/**
* Removes the fallback origin configuration for custom hostnames on a zone. Custom
* hostnames without specific origins will no longer have a fallback.
*
* @example
* ```ts
* const fallbackOrigin =
* await client.customHostnames.fallbackOrigin.delete({
* zone_id: '023e105f4ecef8ad9ca31a8372d0c353',
* });
* ```
*/
delete(params, options) {
const { zone_id } = params;
return this._client.delete((0, path_1.path) `/zones/${zone_id}/custom_hostnames/fallback_origin`, options)._thenUnwrap((obj) => obj.result);
}
/**
* Retrieves the current fallback origin configuration for custom hostnames on a
* zone. The fallback origin handles traffic when specific custom hostname origins
* are unavailable.
*
* @example
* ```ts
* const fallbackOrigin =
* await client.customHostnames.fallbackOrigin.get({
* zone_id: '023e105f4ecef8ad9ca31a8372d0c353',
* });
* ```
*/
get(params, options) {
const { zone_id } = params;
return this._client.get((0, path_1.path) `/zones/${zone_id}/custom_hostnames/fallback_origin`, options)._thenUnwrap((obj) => obj.result);
}
}
BaseFallbackOrigin._key = Object.freeze([
'customHostnames',
'fallbackOrigin',
]);
return BaseFallbackOrigin;
})();
exports.BaseFallbackOrigin = BaseFallbackOrigin;
class FallbackOrigin extends BaseFallbackOrigin {
}
exports.FallbackOrigin = FallbackOrigin;
//# sourceMappingURL=fallback-origin.js.map