UNPKG

@grafana/alerting

Version:

Grafana Alerting Library – Build vertical integrations on top of the industry-leading alerting solution

47 lines (42 loc) 1.8 kB
'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var lodash = require('lodash'); "use strict"; const CAN_USE_ANNOTATION = "grafana.com/canUse"; function isUsableContactPoint(contactPoint) { var _a, _b; const canUse = (_b = (_a = contactPoint.metadata) == null ? void 0 : _a.annotations) == null ? void 0 : _b[CAN_USE_ANNOTATION]; return canUse === "true"; } function getContactPointInUseRoutes(contactPoint) { var _a, _b; const value = (_b = (_a = contactPoint.metadata) == null ? void 0 : _a.annotations) == null ? void 0 : _b["grafana.com/inUse/routes"]; return Number(value) || 0; } function getContactPointInUseRules(contactPoint) { var _a, _b; const value = (_b = (_a = contactPoint.metadata) == null ? void 0 : _a.annotations) == null ? void 0 : _b["grafana.com/inUse/rules"]; return Number(value) || 0; } function getContactPointInUse(contactPoint) { return { routes: getContactPointInUseRoutes(contactPoint), rules: getContactPointInUseRules(contactPoint) }; } function getContactPointDescription(contactPoint) { if (lodash.isEmpty(contactPoint.spec.integrations)) { return "<empty contact point>"; } const integrationCounts = lodash.countBy(contactPoint.spec.integrations, (integration) => integration.type); const description = Object.entries(integrationCounts).map(([type, count]) => { return count > 1 ? `${type} (${count})` : type; }).join(", "); return description; } exports.getContactPointDescription = getContactPointDescription; exports.getContactPointInUse = getContactPointInUse; exports.getContactPointInUseRoutes = getContactPointInUseRoutes; exports.getContactPointInUseRules = getContactPointInUseRules; exports.isUsableContactPoint = isUsableContactPoint; //# sourceMappingURL=utils.cjs.map