UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

92 lines • 3.75 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Settings = exports.BaseSettings = void 0; // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. const resource_1 = require("../../../../core/resource.js"); const error_1 = require("../../../../core/error.js"); const pagination_1 = require("../../../../core/pagination.js"); const path_1 = require("../../../../internal/utils/path.js"); var BaseSettings = /* @__PURE__ */ (() => { class BaseSettings extends resource_1.APIResource { /** * Updates an mTLS certificate's hostname settings. * * @example * ```ts * // Automatically fetches more pages as needed. * for await (const certificateSettings of client.zeroTrust.access.certificates.settings.update( * { * settings: [ * { * china_network: false, * client_certificate_forwarding: true, * hostname: 'admin.example.com', * }, * ], * account_id: 'account_id', * }, * )) { * // ... * } * ``` */ update(params, options) { const { account_id, zone_id, ...body } = params; if (!account_id && !zone_id) { throw new error_1.CloudflareError('You must provide either account_id or zone_id.'); } if (account_id && zone_id) { throw new error_1.CloudflareError('You cannot provide both account_id and zone_id.'); } const { accountOrZone, accountOrZoneId } = account_id ? { accountOrZone: 'accounts', accountOrZoneId: account_id, } : { accountOrZone: 'zones', accountOrZoneId: zone_id, }; return this._client.getAPIList((0, path_1.path) `/${accountOrZone}/${accountOrZoneId}/access/certificates/settings`, (pagination_1.SinglePage), { body, method: 'put', ...options }); } /** * List all mTLS hostname settings for this account or zone. * * @example * ```ts * // Automatically fetches more pages as needed. * for await (const certificateSettings of client.zeroTrust.access.certificates.settings.get( * { account_id: 'account_id' }, * )) { * // ... * } * ``` */ get(params = {}, options) { const { account_id, zone_id } = params ?? {}; if (!account_id && !zone_id) { throw new error_1.CloudflareError('You must provide either account_id or zone_id.'); } if (account_id && zone_id) { throw new error_1.CloudflareError('You cannot provide both account_id and zone_id.'); } const { accountOrZone, accountOrZoneId } = account_id ? { accountOrZone: 'accounts', accountOrZoneId: account_id, } : { accountOrZone: 'zones', accountOrZoneId: zone_id, }; return this._client.getAPIList((0, path_1.path) `/${accountOrZone}/${accountOrZoneId}/access/certificates/settings`, (pagination_1.SinglePage), options); } } BaseSettings._key = Object.freeze(['zeroTrust', 'access', 'certificates', 'settings']); return BaseSettings; })(); exports.BaseSettings = BaseSettings; class Settings extends BaseSettings { } exports.Settings = Settings; //# sourceMappingURL=settings.js.map