UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

117 lines • 4.91 kB
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from "../../../core/resource.mjs"; import * as AuditLogsAPI from "./audit-logs.mjs"; import { AuditLogs, BaseAuditLogs, } from "./audit-logs.mjs"; import * as ClassAPI from "./class.mjs"; import { BaseClass, Class } from "./class.mjs"; import * as ClassificationAPI from "./classification.mjs"; import { BaseClassification, Classification, } from "./classification.mjs"; import * as ContextAPI from "./context.mjs"; import { BaseContext, Context } from "./context.mjs"; import * as SeverityAPI from "./severity.mjs"; import { BaseSeverity, Severity } from "./severity.mjs"; import * as TypeAPI from "./type.mjs"; import { BaseType, Type } from "./type.mjs"; import { CloudflareError } from "../../../core/error.mjs"; import { V4PagePagination } from "../../../core/pagination.mjs"; import { path } from "../../../internal/utils/path.mjs"; export var BaseInsights = /* @__PURE__ */ (() => { class BaseInsights extends 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 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`, (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 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.put(path `/${accountOrZone}/${accountOrZoneId}/security-center/insights/${issueID}/dismiss`, { body, ...options }); } } BaseInsights._key = Object.freeze([ 'securityCenter', 'insights', ]); return BaseInsights; })(); export 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; Insights.BaseClass = BaseClass; Insights.Severity = Severity; Insights.BaseSeverity = BaseSeverity; Insights.Type = Type; Insights.BaseType = BaseType; Insights.AuditLogs = AuditLogs; Insights.BaseAuditLogs = BaseAuditLogs; Insights.Classification = Classification; Insights.BaseClassification = BaseClassification; Insights.Context = Context; Insights.BaseContext = BaseContext; return Insights; })(); //# sourceMappingURL=insights.mjs.map