-
Notifications
You must be signed in to change notification settings - Fork 17
/
MathExpression.go
254 lines (221 loc) · 5.57 KB
/
MathExpression.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
package awscloudwatch
import (
_init_ "github.com/aws/aws-cdk-go/awscdk/v2/jsii"
_jsii_ "github.com/aws/jsii-runtime-go/runtime"
"github.com/aws/aws-cdk-go/awscdk/v2"
"github.com/aws/constructs-go/constructs/v10"
)
// A math expression built with metric(s) emitted by a service.
//
// The math expression is a combination of an expression (x+y) and metrics to apply expression on.
// It also contains metadata which is used only in graphs, such as color and label.
// It makes sense to embed this in here, so that compound constructs can attach
// that metadata to metrics they expose.
//
// MathExpression can also be used for search expressions. In this case,
// it also optionally accepts a searchRegion and searchAccount property for cross-environment
// search expressions.
//
// This class does not represent a resource, so hence is not a construct. Instead,
// MathExpression is an abstraction that makes it easy to specify metrics for use in both
// alarms and graphs.
//
// Example:
// var fn function
//
//
// allProblems := cloudwatch.NewMathExpression(&MathExpressionProps{
// Expression: jsii.String("errors + throttles"),
// UsingMetrics: map[string]iMetric{
// "errors": fn.metricErrors(),
// "throttles": fn.metricThrottles(),
// },
// })
//
type MathExpression interface {
IMetric
// The hex color code, prefixed with '#' (e.g. '#00ff00'), to use when this metric is rendered on a graph. The `Color` class has a set of standard colors that can be used here.
Color() *string
// The expression defining the metric.
Expression() *string
// Label for this metric when added to a Graph.
Label() *string
// Aggregation period of this metric.
Period() awscdk.Duration
// Account to evaluate search expressions within.
SearchAccount() *string
// Region to evaluate search expressions within.
SearchRegion() *string
// The metrics used in the expression as KeyValuePair <id, metric>.
UsingMetrics() *map[string]IMetric
// Warnings generated by this math expression.
// Deprecated: - use warningsV2.
Warnings() *[]*string
// Warnings generated by this math expression.
WarningsV2() *map[string]*string
// Make a new Alarm for this metric.
//
// Combines both properties that may adjust the metric (aggregation) as well
// as alarm properties.
CreateAlarm(scope constructs.Construct, id *string, props *CreateAlarmOptions) Alarm
// Inspect the details of the metric object.
ToMetricConfig() *MetricConfig
// Returns a string representation of an object.
ToString() *string
// Return a copy of Metric with properties changed.
//
// All properties except namespace and metricName can be changed.
With(props *MathExpressionOptions) MathExpression
}
// The jsii proxy struct for MathExpression
type jsiiProxy_MathExpression struct {
jsiiProxy_IMetric
}
func (j *jsiiProxy_MathExpression) Color() *string {
var returns *string
_jsii_.Get(
j,
"color",
&returns,
)
return returns
}
func (j *jsiiProxy_MathExpression) Expression() *string {
var returns *string
_jsii_.Get(
j,
"expression",
&returns,
)
return returns
}
func (j *jsiiProxy_MathExpression) Label() *string {
var returns *string
_jsii_.Get(
j,
"label",
&returns,
)
return returns
}
func (j *jsiiProxy_MathExpression) Period() awscdk.Duration {
var returns awscdk.Duration
_jsii_.Get(
j,
"period",
&returns,
)
return returns
}
func (j *jsiiProxy_MathExpression) SearchAccount() *string {
var returns *string
_jsii_.Get(
j,
"searchAccount",
&returns,
)
return returns
}
func (j *jsiiProxy_MathExpression) SearchRegion() *string {
var returns *string
_jsii_.Get(
j,
"searchRegion",
&returns,
)
return returns
}
func (j *jsiiProxy_MathExpression) UsingMetrics() *map[string]IMetric {
var returns *map[string]IMetric
_jsii_.Get(
j,
"usingMetrics",
&returns,
)
return returns
}
func (j *jsiiProxy_MathExpression) Warnings() *[]*string {
var returns *[]*string
_jsii_.Get(
j,
"warnings",
&returns,
)
return returns
}
func (j *jsiiProxy_MathExpression) WarningsV2() *map[string]*string {
var returns *map[string]*string
_jsii_.Get(
j,
"warningsV2",
&returns,
)
return returns
}
func NewMathExpression(props *MathExpressionProps) MathExpression {
_init_.Initialize()
if err := validateNewMathExpressionParameters(props); err != nil {
panic(err)
}
j := jsiiProxy_MathExpression{}
_jsii_.Create(
"aws-cdk-lib.aws_cloudwatch.MathExpression",
[]interface{}{props},
&j,
)
return &j
}
func NewMathExpression_Override(m MathExpression, props *MathExpressionProps) {
_init_.Initialize()
_jsii_.Create(
"aws-cdk-lib.aws_cloudwatch.MathExpression",
[]interface{}{props},
m,
)
}
func (m *jsiiProxy_MathExpression) CreateAlarm(scope constructs.Construct, id *string, props *CreateAlarmOptions) Alarm {
if err := m.validateCreateAlarmParameters(scope, id, props); err != nil {
panic(err)
}
var returns Alarm
_jsii_.Invoke(
m,
"createAlarm",
[]interface{}{scope, id, props},
&returns,
)
return returns
}
func (m *jsiiProxy_MathExpression) ToMetricConfig() *MetricConfig {
var returns *MetricConfig
_jsii_.Invoke(
m,
"toMetricConfig",
nil, // no parameters
&returns,
)
return returns
}
func (m *jsiiProxy_MathExpression) ToString() *string {
var returns *string
_jsii_.Invoke(
m,
"toString",
nil, // no parameters
&returns,
)
return returns
}
func (m *jsiiProxy_MathExpression) With(props *MathExpressionOptions) MathExpression {
if err := m.validateWithParameters(props); err != nil {
panic(err)
}
var returns MathExpression
_jsii_.Invoke(
m,
"with",
[]interface{}{props},
&returns,
)
return returns
}