cloudflare
Version:
The official TypeScript library for the Cloudflare API
123 lines • 5.39 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Insights = exports.BaseInsights = void 0;
const tslib_1 = require("../../../internal/tslib.js");
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
const resource_1 = require("../../../core/resource.js");
const AuditLogsAPI = tslib_1.__importStar(require("./audit-logs.js"));
const audit_logs_1 = require("./audit-logs.js");
const ClassAPI = tslib_1.__importStar(require("./class.js"));
const class_1 = require("./class.js");
const ClassificationAPI = tslib_1.__importStar(require("./classification.js"));
const classification_1 = require("./classification.js");
const ContextAPI = tslib_1.__importStar(require("./context.js"));
const context_1 = require("./context.js");
const SeverityAPI = tslib_1.__importStar(require("./severity.js"));
const severity_1 = require("./severity.js");
const TypeAPI = tslib_1.__importStar(require("./type.js"));
const type_1 = require("./type.js");
const error_1 = require("../../../core/error.js");
const pagination_1 = require("../../../core/pagination.js");
const path_1 = require("../../../internal/utils/path.js");
var BaseInsights = /* @__PURE__ */ (() => {
class BaseInsights extends resource_1.APIResource {
/**
* Lists all Security Center insights for the account or zone, showing security
* findings and recommendations.
*
* @example
* ```ts
* // Automatically fetches more pages as needed.
* for await (const insightListResponse of client.securityCenter.insights.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}/security-center/insights`, (pagination_1.V4PagePagination), { query, ...options });
}
/**
* Archives a Security Center insight for an account or zone, removing it from the
* active insights list while preserving historical data.
*
* @example
* ```ts
* const response =
* await client.securityCenter.insights.dismiss('issue_id', {
* account_id: 'account_id',
* });
* ```
*/
dismiss(issueID, params, options) {
const { account_id, zone_id, ...body } = 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.put((0, path_1.path) `/${accountOrZone}/${accountOrZoneId}/security-center/insights/${issueID}/dismiss`, { body, ...options });
}
}
BaseInsights._key = Object.freeze([
'securityCenter',
'insights',
]);
return BaseInsights;
})();
exports.BaseInsights = BaseInsights;
var Insights = /* @__PURE__ */ (() => {
class Insights extends BaseInsights {
constructor() {
super(...arguments);
this.class = new ClassAPI.Class(this._client);
this.severity = new SeverityAPI.Severity(this._client);
this.type = new TypeAPI.Type(this._client);
this.auditLogs = new AuditLogsAPI.AuditLogs(this._client);
this.classification = new ClassificationAPI.Classification(this._client);
this.context = new ContextAPI.Context(this._client);
}
}
Insights.Class = class_1.Class;
Insights.BaseClass = class_1.BaseClass;
Insights.Severity = severity_1.Severity;
Insights.BaseSeverity = severity_1.BaseSeverity;
Insights.Type = type_1.Type;
Insights.BaseType = type_1.BaseType;
Insights.AuditLogs = audit_logs_1.AuditLogs;
Insights.BaseAuditLogs = audit_logs_1.BaseAuditLogs;
Insights.Classification = classification_1.Classification;
Insights.BaseClassification = classification_1.BaseClassification;
Insights.Context = context_1.Context;
Insights.BaseContext = context_1.BaseContext;
return Insights;
})();
exports.Insights = Insights;
//# sourceMappingURL=insights.js.map