"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ElasticSearchApiRequestsMetric = void 0;
const aws_cdk_lib_1 = require("aws-cdk-lib");
const _1 = require(".");
class ElasticSearchApiRequestsMetric extends aws_cdk_lib_1.aws_cloudwatch.MathExpression {
    constructor(props) {
        var _a, _b;
        const idx = (_a = props.metricIdx) !== null && _a !== void 0 ? _a : 0;
        const usingMetrics = {
            [`m2xx_${idx}`]: new aws_cdk_lib_1.aws_cloudwatch.Metric((0, _1.elasticSearchApiMetricPropsToMetricProps)(props, '2xx', '2xx', aws_cdk_lib_1.aws_cloudwatch.Statistic.SUM)),
            [`m3xx_${idx}`]: new aws_cdk_lib_1.aws_cloudwatch.Metric((0, _1.elasticSearchApiMetricPropsToMetricProps)(props, '3xx', '3xx', aws_cdk_lib_1.aws_cloudwatch.Statistic.SUM)),
            [`m4xx_${idx}`]: new aws_cdk_lib_1.aws_cloudwatch.Metric((0, _1.elasticSearchApiMetricPropsToMetricProps)(props, '4xx', '4xx', aws_cdk_lib_1.aws_cloudwatch.Statistic.SUM)),
            [`m5xx_${idx}`]: new aws_cdk_lib_1.aws_cloudwatch.Metric((0, _1.elasticSearchApiMetricPropsToMetricProps)(props, '5xx', '5xx', aws_cdk_lib_1.aws_cloudwatch.Statistic.SUM)),
        };
        super({
            label: (_b = props.label) !== null && _b !== void 0 ? _b : 'Requests',
            color: props.color,
            period: props.period,
            expression: `m2xx_${idx} + m3xx_${idx} + m4xx_${idx} + m5xx_${idx}`,
            usingMetrics,
        });
    }
}
exports.ElasticSearchApiRequestsMetric = ElasticSearchApiRequestsMetric;
