UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

99 lines 4.05 kB
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from "../../../../resource.mjs"; import { isRequestOptions } from "../../../../core.mjs"; import { CloudflareError } from "../../../../error.mjs"; import { SinglePage } from "../../../../pagination.mjs"; export class CAs extends APIResource { create(appId, params = {}, options) { if (isRequestOptions(params)) { return this.create(appId, {}, params); } const { account_id, zone_id } = params; if (!account_id && !zone_id) { throw new CloudflareError('You must provide either account_id or zone_id.'); } if (account_id && zone_id) { throw new 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.post(`/${accountOrZone}/${accountOrZoneId}/access/apps/${appId}/ca`, options)._thenUnwrap((obj) => obj.result); } list(params = {}, options) { if (isRequestOptions(params)) { return this.list({}, params); } const { account_id, zone_id } = params; if (!account_id && !zone_id) { throw new CloudflareError('You must provide either account_id or zone_id.'); } if (account_id && zone_id) { throw new 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(`/${accountOrZone}/${accountOrZoneId}/access/apps/ca`, CAsSinglePage, options); } delete(appId, params = {}, options) { if (isRequestOptions(params)) { return this.delete(appId, {}, params); } const { account_id, zone_id } = params; if (!account_id && !zone_id) { throw new CloudflareError('You must provide either account_id or zone_id.'); } if (account_id && zone_id) { throw new 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.delete(`/${accountOrZone}/${accountOrZoneId}/access/apps/${appId}/ca`, options)._thenUnwrap((obj) => obj.result); } get(appId, params = {}, options) { if (isRequestOptions(params)) { return this.get(appId, {}, params); } const { account_id, zone_id } = params; if (!account_id && !zone_id) { throw new CloudflareError('You must provide either account_id or zone_id.'); } if (account_id && zone_id) { throw new 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.get(`/${accountOrZone}/${accountOrZoneId}/access/apps/${appId}/ca`, options)._thenUnwrap((obj) => obj.result); } } export class CAsSinglePage extends SinglePage { } CAs.CAsSinglePage = CAsSinglePage; //# sourceMappingURL=cas.mjs.map