"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ApiMethodRequestsMetric = void 0;
const aws_cdk_lib_1 = require("aws-cdk-lib");
class ApiMethodRequestsMetric extends aws_cdk_lib_1.aws_cloudwatch.MathExpression {
    /**
     * Creates a search expression that finds all methods for a given API stage and returns the
     * request counts for each of the methods.
     */
    constructor(props) {
        var _a;
        const { apiName, stage } = props;
        const period = (_a = props.period) !== null && _a !== void 0 ? _a : aws_cdk_lib_1.Duration.minutes(5);
        const expression = `SEARCH('{AWS/ApiGateway,ApiName,Method,Resource,Stage} (\"Count\") ApiName=${apiName} Stage=${stage}',`
            + ` 'Sum', ${period.toSeconds()})`;
        super({
            expression,
            label: ' ', // blank out the label so it displays the found function name
            usingMetrics: {},
        });
    }
}
exports.ApiMethodRequestsMetric = ApiMethodRequestsMetric;
