1import * as cloudwatch from "@distilled.cloud/aws/cloudwatch";
2import * as Effect from "effect/Effect";
3import * as Binding from "../../Binding.ts";
4
5export interface GetMetricDataRequest extends cloudwatch.GetMetricDataInput {}
6
7/**
8 * Runtime binding for `cloudwatch:GetMetricData` — run metric-math queries
9 * over one or more metrics in a single call.
10 *
11 * Provide `CloudWatch.GetMetricDataHttp` on the hosting Lambda Function to
12 * satisfy the requirement.
13 * ### Querying Metrics
14 * **Example:** Query the Last Hour of a Custom Metric
15 * ```typescript
16 * // init — grants cloudwatch:GetMetricData
17 * const getMetricData = yield* AWS.CloudWatch.GetMetricData();
18 *
19 * // runtime
20 * const now = yield* Effect.sync(() => Date.now());
21 * const result = yield* getMetricData({
22 * StartTime: new Date(now - 3_600_000),
23 * EndTime: new Date(now),
24 * MetricDataQueries: [
25 * {
26 * Id: "m1",
27 * MetricStat: {
28 * Metric: { Namespace: "MyApp/Payments", MetricName: "PaymentProcessed" },
29 * Period: 60,
30 * Stat: "Sum",
31 * },
32 * },
33 * ],
34 * });
35 * const series = result.MetricDataResults ?? [];
36 * ```
37 *
38 * @binding
39 */
40export interface GetMetricData extends Binding.Service<
41 GetMetricData,
42 "AWS.CloudWatch.GetMetricData",
43 () => Effect.Effect<
44 (
45 request: GetMetricDataRequest,
46 ) => Effect.Effect<
47 cloudwatch.GetMetricDataOutput,
48 cloudwatch.GetMetricDataError
49 >
50 >
51> {}
52
53export const GetMetricData = Binding.Service<GetMetricData>(
54 "AWS.CloudWatch.GetMetricData",
55);