cloudflare
Version:
The official TypeScript library for the Cloudflare API
149 lines • 5.93 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.CAs = exports.BaseCAs = 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 BaseCAs = /* @__PURE__ */ (() => {
class BaseCAs extends resource_1.APIResource {
/**
* Generates a new short-lived certificate CA and public key.
*
* @example
* ```ts
* const ca =
* await client.zeroTrust.access.applications.cas.create(
* 'f174e90a-fafe-4643-bbbc-4a0ed4fc8415',
* { account_id: 'account_id' },
* );
* ```
*/
create(appID, 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.post((0, path_1.path) `/${accountOrZone}/${accountOrZoneId}/access/apps/${appID}/ca`, options)._thenUnwrap((obj) => obj.result);
}
/**
* Lists short-lived certificate CAs and their public keys.
*
* @example
* ```ts
* // Automatically fetches more pages as needed.
* for await (const ca of client.zeroTrust.access.applications.cas.list(
* { account_id: 'account_id' },
* )) {
* // ...
* }
* ```
*/
list(params = {}, options) {
const { account_id, zone_id, ...query } = 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/apps/ca`, (pagination_1.V4PagePaginationArray), { query, ...options });
}
/**
* Deletes a short-lived certificate CA.
*
* @example
* ```ts
* const ca =
* await client.zeroTrust.access.applications.cas.delete(
* 'f174e90a-fafe-4643-bbbc-4a0ed4fc8415',
* { account_id: 'account_id' },
* );
* ```
*/
delete(appID, 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.delete((0, path_1.path) `/${accountOrZone}/${accountOrZoneId}/access/apps/${appID}/ca`, options)._thenUnwrap((obj) => obj.result);
}
/**
* Fetches a short-lived certificate CA and its public key.
*
* @example
* ```ts
* const ca =
* await client.zeroTrust.access.applications.cas.get(
* 'f174e90a-fafe-4643-bbbc-4a0ed4fc8415',
* { account_id: 'account_id' },
* );
* ```
*/
get(appID, 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.get((0, path_1.path) `/${accountOrZone}/${accountOrZoneId}/access/apps/${appID}/ca`, options)._thenUnwrap((obj) => obj.result);
}
}
BaseCAs._key = Object.freeze([
'zeroTrust',
'access',
'applications',
'cas',
]);
return BaseCAs;
})();
exports.BaseCAs = BaseCAs;
class CAs extends BaseCAs {
}
exports.CAs = CAs;
//# sourceMappingURL=cas.js.map