|
1 |
| -// Copyright 2016-2018, Pulumi Corporation. |
2 |
| -// |
3 |
| -// Licensed under the Apache License, Version 2.0 (the "License"); |
4 |
| -// you may not use this file except in compliance with the License. |
5 |
| -// You may obtain a copy of the License at |
6 |
| -// |
7 |
| -// http://www.apache.org/licenses/LICENSE-2.0 |
8 |
| -// |
9 |
| -// Unless required by applicable law or agreed to in writing, software |
10 |
| -// distributed under the License is distributed on an "AS IS" BASIS, |
11 |
| -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
12 |
| -// See the License for the specific language governing permissions and |
13 |
| -// limitations under the License. |
14 |
| - |
15 |
| -import * as pulumi from "@pulumi/pulumi"; |
16 |
| -import * as wjson from "./widgets_json"; |
17 |
| - |
18 |
| -import { MetricWidget, MetricWidgetArgs } from "./widgets_simple"; |
19 |
| - |
20 |
| -// Contains all the classes for easily making graph widgets in a dashboard. |
21 |
| - |
22 |
| -export interface GraphMetricWidgetArgs extends MetricWidgetArgs { |
23 |
| - /** |
24 |
| - * Limits for the minimums and maximums of the y-axis. This applies to every metric being |
25 |
| - * graphed, unless specific metrics override it. |
26 |
| - */ |
27 |
| - yAxis?: pulumi.Input<YAxis>; |
28 |
| -} |
29 |
| - |
30 |
| -export interface YAxis { |
31 |
| - /** Optional min and max settings for the left Y-axis. */ |
32 |
| - left?: MinMax; |
33 |
| - |
34 |
| - /** Optional min and max settings for the right Y-axis. */ |
35 |
| - right?: MinMax; |
36 |
| -} |
37 |
| - |
38 |
| -export interface MinMax { |
39 |
| - /** The minimum value for this Y-axis */ |
40 |
| - min?: number; |
41 |
| - /** The maximum value for this Y-axis */ |
42 |
| - max?: number; |
43 |
| -} |
44 |
| - |
45 |
| - |
46 |
| -/** |
47 |
| - * Base type for widets that display metrics as a graph (either a line or stacked graph). |
48 |
| - * |
49 |
| - * See https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/graph_metrics.html for more |
50 |
| - * details. |
51 |
| - */ |
52 |
| -export abstract class GraphMetricWidget extends MetricWidget { |
53 |
| - constructor(private readonly graphArgs: GraphMetricWidgetArgs) { |
54 |
| - super(graphArgs); |
55 |
| - } |
56 |
| - |
57 |
| - protected computeView = (): wjson.MetricWidgetPropertiesJson["view"] => "timeSeries"; |
58 |
| - protected computeYAxis = (): wjson.MetricWidgetPropertiesJson["yAxis"] => this.graphArgs.yAxis; |
59 |
| -} |
60 |
| - |
61 |
| -/** |
62 |
| - * Displays a set of metrics as a line graph. |
63 |
| - */ |
64 |
| -export class LineGraphMetricWidget extends GraphMetricWidget { |
65 |
| - constructor(args: GraphMetricWidgetArgs) { |
66 |
| - super(args); |
67 |
| - } |
68 |
| - |
69 |
| - protected computedStacked = () => false; |
70 |
| -} |
71 |
| - |
72 |
| -/** |
73 |
| - * Displays a set of metrics as a stacked area graph. |
74 |
| - */ |
75 |
| -export class StackedAreaGraphMetricWidget extends GraphMetricWidget { |
76 |
| - constructor(args: GraphMetricWidgetArgs) { |
77 |
| - super(args); |
78 |
| - } |
79 |
| - |
80 |
| - protected computedStacked = () => true; |
81 |
| -} |
82 |
| - |
83 |
| -/** |
84 |
| - * Displays a set of metrics as a single number. |
85 |
| - */ |
86 |
| -export class SingleNumberMetricWidget extends MetricWidget { |
87 |
| - constructor(args: MetricWidgetArgs) { |
88 |
| - super(args); |
89 |
| - } |
90 |
| - |
91 |
| - protected computedStacked = () => false; |
92 |
| - protected computeView = (): wjson.MetricWidgetPropertiesJson["view"] => "singleValue"; |
93 |
| - protected computeYAxis = (): wjson.MetricWidgetPropertiesJson["yAxis"] => undefined; |
94 |
| -} |
| 1 | +// Copyright 2016-2018, Pulumi Corporation. |
| 2 | +// |
| 3 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +// you may not use this file except in compliance with the License. |
| 5 | +// You may obtain a copy of the License at |
| 6 | +// |
| 7 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +// |
| 9 | +// Unless required by applicable law or agreed to in writing, software |
| 10 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +// See the License for the specific language governing permissions and |
| 13 | +// limitations under the License. |
| 14 | + |
| 15 | +import * as pulumi from "@pulumi/pulumi"; |
| 16 | +import * as wjson from "./widgets_json"; |
| 17 | + |
| 18 | +import { MetricWidget, MetricWidgetArgs } from "./widgets_simple"; |
| 19 | + |
| 20 | +type DeepRequired<T> = { |
| 21 | + [K in keyof T]: Required<DeepRequired<T[K]>> |
| 22 | +} |
| 23 | +// Contains all the classes for easily making graph widgets in a dashboard. |
| 24 | + |
| 25 | +export interface GraphMetricWidgetArgs extends MetricWidgetArgs { |
| 26 | + /** |
| 27 | + * Limits for the minimums and maximums of the y-axis. This applies to every metric being |
| 28 | + * graphed, unless specific metrics override it. |
| 29 | + */ |
| 30 | + yAxis?: pulumi.Input<YAxis>; |
| 31 | +} |
| 32 | + |
| 33 | +export interface GaugeMetricWidgetArgs extends MetricWidgetArgs { |
| 34 | + /** |
| 35 | + * Limits for the minimums and maximums of the y-axis. Needed for Gauge Widget. |
| 36 | + */ |
| 37 | + yAxis: pulumi.Input<DeepRequired<YAxis>>; |
| 38 | +} |
| 39 | + |
| 40 | + |
| 41 | +export interface YAxis { |
| 42 | + /** Optional min and max settings for the left Y-axis. */ |
| 43 | + left?: MinMax; |
| 44 | + |
| 45 | + /** Optional min and max settings for the right Y-axis. */ |
| 46 | + right?: MinMax; |
| 47 | +} |
| 48 | + |
| 49 | +export interface MinMax { |
| 50 | + /** The minimum value for this Y-axis */ |
| 51 | + min?: number; |
| 52 | + /** The maximum value for this Y-axis */ |
| 53 | + max?: number; |
| 54 | +} |
| 55 | + |
| 56 | + |
| 57 | +/** |
| 58 | + * Base type for widets that display metrics as a graph (either a line or stacked graph). |
| 59 | + * |
| 60 | + * See https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/graph_metrics.html for more |
| 61 | + * details. |
| 62 | + */ |
| 63 | +export abstract class GraphMetricWidget extends MetricWidget { |
| 64 | + constructor(private readonly graphArgs: GraphMetricWidgetArgs) { |
| 65 | + super(graphArgs); |
| 66 | + } |
| 67 | + |
| 68 | + protected computeView = (): wjson.MetricWidgetPropertiesJson["view"] => "timeSeries"; |
| 69 | + protected computeYAxis = (): wjson.MetricWidgetPropertiesJson["yAxis"] => this.graphArgs.yAxis; |
| 70 | +} |
| 71 | + |
| 72 | +/** |
| 73 | + * Displays a set of metrics as a line graph. |
| 74 | + */ |
| 75 | +export class LineGraphMetricWidget extends GraphMetricWidget { |
| 76 | + constructor(args: GraphMetricWidgetArgs) { |
| 77 | + super(args); |
| 78 | + } |
| 79 | + |
| 80 | + protected computedStacked = () => false; |
| 81 | +} |
| 82 | + |
| 83 | +/** |
| 84 | + * Displays a set of metrics as a stacked area graph. |
| 85 | + */ |
| 86 | +export class StackedAreaGraphMetricWidget extends GraphMetricWidget { |
| 87 | + constructor(args: GraphMetricWidgetArgs) { |
| 88 | + super(args); |
| 89 | + } |
| 90 | + |
| 91 | + protected computedStacked = () => true; |
| 92 | +} |
| 93 | + |
| 94 | +/** |
| 95 | + * Displays a set of metrics as a single number. |
| 96 | + */ |
| 97 | +export class SingleNumberMetricWidget extends MetricWidget { |
| 98 | + constructor(args: MetricWidgetArgs) { |
| 99 | + super(args); |
| 100 | + } |
| 101 | + |
| 102 | + protected computedStacked = () => false; |
| 103 | + protected computeView = (): wjson.MetricWidgetPropertiesJson["view"] => "singleValue"; |
| 104 | + protected computeYAxis = (): wjson.MetricWidgetPropertiesJson["yAxis"] => undefined; |
| 105 | +} |
| 106 | + |
| 107 | +/** |
| 108 | + * Displays a set of metrics as a gauge number. |
| 109 | + */ |
| 110 | +export class GaugeMetricWidget extends MetricWidget { |
| 111 | + constructor(private readonly gaugeArgs: GaugeMetricWidgetArgs) { |
| 112 | + super(gaugeArgs); |
| 113 | + } |
| 114 | + |
| 115 | + protected computedStacked = () => false; |
| 116 | + protected computeView = (): wjson.MetricWidgetPropertiesJson["view"] => "gauge"; |
| 117 | + protected computeYAxis = (): wjson.MetricWidgetPropertiesJson["yAxis"] => this.gaugeArgs.yAxis; |
| 118 | +} |
0 commit comments