UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

118 lines • 4.38 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.CustomPages = exports.BaseCustomPages = void 0; // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. const resource_1 = require("../../../core/resource.js"); const pagination_1 = require("../../../core/pagination.js"); const path_1 = require("../../../internal/utils/path.js"); var BaseCustomPages = /* @__PURE__ */ (() => { class BaseCustomPages extends resource_1.APIResource { /** * Create a custom page * * @example * ```ts * const customPageWithoutHTML = * await client.zeroTrust.access.customPages.create({ * account_id: '023e105f4ecef8ad9ca31a8372d0c353', * custom_html: * '<html><body><h1>Access Denied</h1></body></html>', * name: 'name', * type: 'identity_denied', * }); * ``` */ create(params, options) { const { account_id, ...body } = params; return this._client.post((0, path_1.path) `/accounts/${account_id}/access/custom_pages`, { body, ...options, })._thenUnwrap((obj) => obj.result); } /** * Update a custom page * * @example * ```ts * const customPageWithoutHTML = * await client.zeroTrust.access.customPages.update( * 'f174e90a-fafe-4643-bbbc-4a0ed4fc8415', * { * account_id: '023e105f4ecef8ad9ca31a8372d0c353', * custom_html: * '<html><body><h1>Access Denied</h1></body></html>', * name: 'name', * type: 'identity_denied', * }, * ); * ``` */ update(customPageID, params, options) { const { account_id, ...body } = params; return this._client.put((0, path_1.path) `/accounts/${account_id}/access/custom_pages/${customPageID}`, { body, ...options, })._thenUnwrap((obj) => obj.result); } /** * List custom pages * * @example * ```ts * // Automatically fetches more pages as needed. * for await (const customPageWithoutHTML of client.zeroTrust.access.customPages.list( * { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * )) { * // ... * } * ``` */ list(params, options) { const { account_id, ...query } = params; return this._client.getAPIList((0, path_1.path) `/accounts/${account_id}/access/custom_pages`, (pagination_1.V4PagePaginationArray), { query, ...options }); } /** * Delete a custom page * * @example * ```ts * const customPage = * await client.zeroTrust.access.customPages.delete( * 'f174e90a-fafe-4643-bbbc-4a0ed4fc8415', * { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * ); * ``` */ delete(customPageID, params, options) { const { account_id } = params; return this._client.delete((0, path_1.path) `/accounts/${account_id}/access/custom_pages/${customPageID}`, options)._thenUnwrap((obj) => obj.result); } /** * Fetches a custom page and also returns its HTML. * * @example * ```ts * const customPage = * await client.zeroTrust.access.customPages.get( * 'f174e90a-fafe-4643-bbbc-4a0ed4fc8415', * { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * ); * ``` */ get(customPageID, params, options) { const { account_id } = params; return this._client.get((0, path_1.path) `/accounts/${account_id}/access/custom_pages/${customPageID}`, options)._thenUnwrap((obj) => obj.result); } } BaseCustomPages._key = Object.freeze([ 'zeroTrust', 'access', 'customPages', ]); return BaseCustomPages; })(); exports.BaseCustomPages = BaseCustomPages; class CustomPages extends BaseCustomPages { } exports.CustomPages = CustomPages; //# sourceMappingURL=custom-pages.js.map