UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

119 lines • 4.64 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Applications = exports.BaseApplications = 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 BaseApplications = /* @__PURE__ */ (() => { class BaseApplications extends resource_1.APIResource { /** * Create a custom application for an account. * * @example * ```ts * const application = * await client.zeroTrust.resourceLibrary.applications.create( * { * account_id: '023e105f4ecef8ad9ca31a8372d0c353', * hostnames: ['example.com', 'foo.com'], * }, * ); * ``` */ create(params, options) { const { account_id, ...body } = params; return this._client.post((0, path_1.path) `/accounts/${account_id}/resource-library/applications`, { body, ...options, })._thenUnwrap((obj) => obj.result); } /** * Replace the network matchers for a custom application and create a new version. * * @example * ```ts * const application = * await client.zeroTrust.resourceLibrary.applications.update( * 498, * { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * ); * ``` */ update(id, params, options) { const { account_id, ...body } = params; return this._client.patch((0, path_1.path) `/accounts/${account_id}/resource-library/applications/${id}`, { body, ...options, })._thenUnwrap((obj) => obj.result); } /** * List the applications available to an account, both the applications Cloudflare * curates and the custom applications the account has defined. * * Results are paginated. Use `filter` and `search` to narrow the list, `order_by` * to sort it, and `fields` to reduce each result to only the properties you need. * * The authenticated principal must have access to the account identified by * `account_id`. * * @example * ```ts * // Automatically fetches more pages as needed. * for await (const applicationListResponse of client.zeroTrust.resourceLibrary.applications.list( * { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * )) { * // ... * } * ``` */ list(params, options) { const { account_id, ...query } = params; return this._client.getAPIList((0, path_1.path) `/accounts/${account_id}/resource-library/applications`, (pagination_1.SinglePage), { query, ...options }); } /** * Delete a custom application and all of its versions. Deletion is rejected when * other resources reference the application. * * @example * ```ts * const application = * await client.zeroTrust.resourceLibrary.applications.delete( * 498, * { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * ); * ``` */ delete(id, params, options) { const { account_id } = params; return this._client.delete((0, path_1.path) `/accounts/${account_id}/resource-library/applications/${id}`, options)._thenUnwrap((obj) => obj.result); } /** * Get application by ID. * * @example * ```ts * const application = * await client.zeroTrust.resourceLibrary.applications.get( * 498, * { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * ); * ``` */ get(id, params, options) { const { account_id } = params; return this._client.get((0, path_1.path) `/accounts/${account_id}/resource-library/applications/${id}`, options)._thenUnwrap((obj) => obj.result); } } BaseApplications._key = Object.freeze([ 'zeroTrust', 'resourceLibrary', 'applications', ]); return BaseApplications; })(); exports.BaseApplications = BaseApplications; class Applications extends BaseApplications { } exports.Applications = Applications; //# sourceMappingURL=applications.js.map