UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

114 lines • 4.35 kB
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from "../../../core/resource.mjs"; import { SinglePage } from "../../../core/pagination.mjs"; import { path } from "../../../internal/utils/path.mjs"; export var BaseApplications = /* @__PURE__ */ (() => { class BaseApplications extends 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(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(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(path `/accounts/${account_id}/resource-library/applications`, (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(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(path `/accounts/${account_id}/resource-library/applications/${id}`, options)._thenUnwrap((obj) => obj.result); } } BaseApplications._key = Object.freeze([ 'zeroTrust', 'resourceLibrary', 'applications', ]); return BaseApplications; })(); export class Applications extends BaseApplications { } //# sourceMappingURL=applications.mjs.map