cloudflare
Version:
The official TypeScript library for the Cloudflare API
85 lines • 3.53 kB
JavaScript
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from "../../../core/resource.mjs";
import { CloudflareError } from "../../../core/error.mjs";
import { CursorPagination } from "../../../core/pagination.mjs";
import { path } from "../../../internal/utils/path.mjs";
export var BaseAuditLogs = /* @__PURE__ */ (() => {
class BaseAuditLogs extends APIResource {
/**
* Lists audit log entries for all Security Center insights in the account or zone,
* showing changes to insight status and classification.
*
* @example
* ```ts
* // Automatically fetches more pages as needed.
* for await (const auditLogListResponse of client.securityCenter.insights.auditLogs.list(
* { account_id: 'account_id' },
* )) {
* // ...
* }
* ```
*/
list(params = {}, options) {
const { account_id, zone_id, ...query } = 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(path `/${accountOrZone}/${accountOrZoneId}/security-center/insights/audit-log`, (CursorPagination), { query, ...options });
}
/**
* Lists audit log entries for a specific Security Center insight, showing changes
* to its status and classification over time.
*
* @example
* ```ts
* // Automatically fetches more pages as needed.
* for await (const auditLogListByInsightResponse of client.securityCenter.insights.auditLogs.listByInsight(
* 'issue_id',
* { account_id: 'account_id' },
* )) {
* // ...
* }
* ```
*/
listByInsight(issueID, params = {}, options) {
const { account_id, zone_id, ...query } = 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(path `/${accountOrZone}/${accountOrZoneId}/security-center/insights/${issueID}/audit-log`, (CursorPagination), { query, ...options });
}
}
BaseAuditLogs._key = Object.freeze([
'securityCenter',
'insights',
'auditLogs',
]);
return BaseAuditLogs;
})();
export class AuditLogs extends BaseAuditLogs {
}
//# sourceMappingURL=audit-logs.mjs.map