/
eventsToMetricsRule.go
348 lines (288 loc) · 12.6 KB
/
eventsToMetricsRule.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
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
// *** WARNING: this file was generated by the Pulumi Terraform Bridge (tfgen) Tool. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
package newrelic
import (
"context"
"reflect"
"github.com/pkg/errors"
"github.com/pulumi/pulumi/sdk/v2/go/pulumi"
)
// Use this resource to create, update, and delete New Relic Events to Metrics rules.
//
// ## Example Usage
//
// ```go
// package main
//
// import (
// "github.com/pulumi/pulumi-newrelic/sdk/v3/go/newrelic"
// "github.com/pulumi/pulumi/sdk/v2/go/pulumi"
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// _, err := newrelic.NewEventsToMetricsRule(ctx, "foo", &newrelic.EventsToMetricsRuleArgs{
// AccountId: pulumi.Int(12345),
// Description: pulumi.String("Example description"),
// Nrql: pulumi.String("SELECT uniqueCount(account_id) AS ``Transaction.account_id`` FROM Transaction FACET appName, name"),
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
// ```
//
// ## Import
//
// New Relic Events to Metrics rules can be imported using a concatenated string of the format
//
// `<account_id>:<rule_id>`, e.g. bash
//
// ```sh
// $ pulumi import newrelic:index/eventsToMetricsRule:EventsToMetricsRule foo 12345:34567
// ```
type EventsToMetricsRule struct {
pulumi.CustomResourceState
// Account with the event and where the metrics will be put.
AccountId pulumi.IntOutput `pulumi:"accountId"`
// Provides additional information about the rule.
Description pulumi.StringPtrOutput `pulumi:"description"`
// True means this rule is enabled. False means the rule is currently not creating metrics.
Enabled pulumi.BoolPtrOutput `pulumi:"enabled"`
// The name of the rule. This must be unique within an account.
Name pulumi.StringOutput `pulumi:"name"`
// Explains how to create metrics from events.
Nrql pulumi.StringOutput `pulumi:"nrql"`
// The id, uniquely identifying the rule.
RuleId pulumi.StringOutput `pulumi:"ruleId"`
}
// NewEventsToMetricsRule registers a new resource with the given unique name, arguments, and options.
func NewEventsToMetricsRule(ctx *pulumi.Context,
name string, args *EventsToMetricsRuleArgs, opts ...pulumi.ResourceOption) (*EventsToMetricsRule, error) {
if args == nil {
return nil, errors.New("missing one or more required arguments")
}
if args.Nrql == nil {
return nil, errors.New("invalid value for required argument 'Nrql'")
}
var resource EventsToMetricsRule
err := ctx.RegisterResource("newrelic:index/eventsToMetricsRule:EventsToMetricsRule", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// GetEventsToMetricsRule gets an existing EventsToMetricsRule resource's state with the given name, ID, and optional
// state properties that are used to uniquely qualify the lookup (nil if not required).
func GetEventsToMetricsRule(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *EventsToMetricsRuleState, opts ...pulumi.ResourceOption) (*EventsToMetricsRule, error) {
var resource EventsToMetricsRule
err := ctx.ReadResource("newrelic:index/eventsToMetricsRule:EventsToMetricsRule", name, id, state, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// Input properties used for looking up and filtering EventsToMetricsRule resources.
type eventsToMetricsRuleState struct {
// Account with the event and where the metrics will be put.
AccountId *int `pulumi:"accountId"`
// Provides additional information about the rule.
Description *string `pulumi:"description"`
// True means this rule is enabled. False means the rule is currently not creating metrics.
Enabled *bool `pulumi:"enabled"`
// The name of the rule. This must be unique within an account.
Name *string `pulumi:"name"`
// Explains how to create metrics from events.
Nrql *string `pulumi:"nrql"`
// The id, uniquely identifying the rule.
RuleId *string `pulumi:"ruleId"`
}
type EventsToMetricsRuleState struct {
// Account with the event and where the metrics will be put.
AccountId pulumi.IntPtrInput
// Provides additional information about the rule.
Description pulumi.StringPtrInput
// True means this rule is enabled. False means the rule is currently not creating metrics.
Enabled pulumi.BoolPtrInput
// The name of the rule. This must be unique within an account.
Name pulumi.StringPtrInput
// Explains how to create metrics from events.
Nrql pulumi.StringPtrInput
// The id, uniquely identifying the rule.
RuleId pulumi.StringPtrInput
}
func (EventsToMetricsRuleState) ElementType() reflect.Type {
return reflect.TypeOf((*eventsToMetricsRuleState)(nil)).Elem()
}
type eventsToMetricsRuleArgs struct {
// Account with the event and where the metrics will be put.
AccountId *int `pulumi:"accountId"`
// Provides additional information about the rule.
Description *string `pulumi:"description"`
// True means this rule is enabled. False means the rule is currently not creating metrics.
Enabled *bool `pulumi:"enabled"`
// The name of the rule. This must be unique within an account.
Name *string `pulumi:"name"`
// Explains how to create metrics from events.
Nrql string `pulumi:"nrql"`
}
// The set of arguments for constructing a EventsToMetricsRule resource.
type EventsToMetricsRuleArgs struct {
// Account with the event and where the metrics will be put.
AccountId pulumi.IntPtrInput
// Provides additional information about the rule.
Description pulumi.StringPtrInput
// True means this rule is enabled. False means the rule is currently not creating metrics.
Enabled pulumi.BoolPtrInput
// The name of the rule. This must be unique within an account.
Name pulumi.StringPtrInput
// Explains how to create metrics from events.
Nrql pulumi.StringInput
}
func (EventsToMetricsRuleArgs) ElementType() reflect.Type {
return reflect.TypeOf((*eventsToMetricsRuleArgs)(nil)).Elem()
}
type EventsToMetricsRuleInput interface {
pulumi.Input
ToEventsToMetricsRuleOutput() EventsToMetricsRuleOutput
ToEventsToMetricsRuleOutputWithContext(ctx context.Context) EventsToMetricsRuleOutput
}
func (*EventsToMetricsRule) ElementType() reflect.Type {
return reflect.TypeOf((*EventsToMetricsRule)(nil))
}
func (i *EventsToMetricsRule) ToEventsToMetricsRuleOutput() EventsToMetricsRuleOutput {
return i.ToEventsToMetricsRuleOutputWithContext(context.Background())
}
func (i *EventsToMetricsRule) ToEventsToMetricsRuleOutputWithContext(ctx context.Context) EventsToMetricsRuleOutput {
return pulumi.ToOutputWithContext(ctx, i).(EventsToMetricsRuleOutput)
}
func (i *EventsToMetricsRule) ToEventsToMetricsRulePtrOutput() EventsToMetricsRulePtrOutput {
return i.ToEventsToMetricsRulePtrOutputWithContext(context.Background())
}
func (i *EventsToMetricsRule) ToEventsToMetricsRulePtrOutputWithContext(ctx context.Context) EventsToMetricsRulePtrOutput {
return pulumi.ToOutputWithContext(ctx, i).(EventsToMetricsRulePtrOutput)
}
type EventsToMetricsRulePtrInput interface {
pulumi.Input
ToEventsToMetricsRulePtrOutput() EventsToMetricsRulePtrOutput
ToEventsToMetricsRulePtrOutputWithContext(ctx context.Context) EventsToMetricsRulePtrOutput
}
type eventsToMetricsRulePtrType EventsToMetricsRuleArgs
func (*eventsToMetricsRulePtrType) ElementType() reflect.Type {
return reflect.TypeOf((**EventsToMetricsRule)(nil))
}
func (i *eventsToMetricsRulePtrType) ToEventsToMetricsRulePtrOutput() EventsToMetricsRulePtrOutput {
return i.ToEventsToMetricsRulePtrOutputWithContext(context.Background())
}
func (i *eventsToMetricsRulePtrType) ToEventsToMetricsRulePtrOutputWithContext(ctx context.Context) EventsToMetricsRulePtrOutput {
return pulumi.ToOutputWithContext(ctx, i).(EventsToMetricsRulePtrOutput)
}
// EventsToMetricsRuleArrayInput is an input type that accepts EventsToMetricsRuleArray and EventsToMetricsRuleArrayOutput values.
// You can construct a concrete instance of `EventsToMetricsRuleArrayInput` via:
//
// EventsToMetricsRuleArray{ EventsToMetricsRuleArgs{...} }
type EventsToMetricsRuleArrayInput interface {
pulumi.Input
ToEventsToMetricsRuleArrayOutput() EventsToMetricsRuleArrayOutput
ToEventsToMetricsRuleArrayOutputWithContext(context.Context) EventsToMetricsRuleArrayOutput
}
type EventsToMetricsRuleArray []EventsToMetricsRuleInput
func (EventsToMetricsRuleArray) ElementType() reflect.Type {
return reflect.TypeOf(([]*EventsToMetricsRule)(nil))
}
func (i EventsToMetricsRuleArray) ToEventsToMetricsRuleArrayOutput() EventsToMetricsRuleArrayOutput {
return i.ToEventsToMetricsRuleArrayOutputWithContext(context.Background())
}
func (i EventsToMetricsRuleArray) ToEventsToMetricsRuleArrayOutputWithContext(ctx context.Context) EventsToMetricsRuleArrayOutput {
return pulumi.ToOutputWithContext(ctx, i).(EventsToMetricsRuleArrayOutput)
}
// EventsToMetricsRuleMapInput is an input type that accepts EventsToMetricsRuleMap and EventsToMetricsRuleMapOutput values.
// You can construct a concrete instance of `EventsToMetricsRuleMapInput` via:
//
// EventsToMetricsRuleMap{ "key": EventsToMetricsRuleArgs{...} }
type EventsToMetricsRuleMapInput interface {
pulumi.Input
ToEventsToMetricsRuleMapOutput() EventsToMetricsRuleMapOutput
ToEventsToMetricsRuleMapOutputWithContext(context.Context) EventsToMetricsRuleMapOutput
}
type EventsToMetricsRuleMap map[string]EventsToMetricsRuleInput
func (EventsToMetricsRuleMap) ElementType() reflect.Type {
return reflect.TypeOf((map[string]*EventsToMetricsRule)(nil))
}
func (i EventsToMetricsRuleMap) ToEventsToMetricsRuleMapOutput() EventsToMetricsRuleMapOutput {
return i.ToEventsToMetricsRuleMapOutputWithContext(context.Background())
}
func (i EventsToMetricsRuleMap) ToEventsToMetricsRuleMapOutputWithContext(ctx context.Context) EventsToMetricsRuleMapOutput {
return pulumi.ToOutputWithContext(ctx, i).(EventsToMetricsRuleMapOutput)
}
type EventsToMetricsRuleOutput struct {
*pulumi.OutputState
}
func (EventsToMetricsRuleOutput) ElementType() reflect.Type {
return reflect.TypeOf((*EventsToMetricsRule)(nil))
}
func (o EventsToMetricsRuleOutput) ToEventsToMetricsRuleOutput() EventsToMetricsRuleOutput {
return o
}
func (o EventsToMetricsRuleOutput) ToEventsToMetricsRuleOutputWithContext(ctx context.Context) EventsToMetricsRuleOutput {
return o
}
func (o EventsToMetricsRuleOutput) ToEventsToMetricsRulePtrOutput() EventsToMetricsRulePtrOutput {
return o.ToEventsToMetricsRulePtrOutputWithContext(context.Background())
}
func (o EventsToMetricsRuleOutput) ToEventsToMetricsRulePtrOutputWithContext(ctx context.Context) EventsToMetricsRulePtrOutput {
return o.ApplyT(func(v EventsToMetricsRule) *EventsToMetricsRule {
return &v
}).(EventsToMetricsRulePtrOutput)
}
type EventsToMetricsRulePtrOutput struct {
*pulumi.OutputState
}
func (EventsToMetricsRulePtrOutput) ElementType() reflect.Type {
return reflect.TypeOf((**EventsToMetricsRule)(nil))
}
func (o EventsToMetricsRulePtrOutput) ToEventsToMetricsRulePtrOutput() EventsToMetricsRulePtrOutput {
return o
}
func (o EventsToMetricsRulePtrOutput) ToEventsToMetricsRulePtrOutputWithContext(ctx context.Context) EventsToMetricsRulePtrOutput {
return o
}
type EventsToMetricsRuleArrayOutput struct{ *pulumi.OutputState }
func (EventsToMetricsRuleArrayOutput) ElementType() reflect.Type {
return reflect.TypeOf((*[]EventsToMetricsRule)(nil))
}
func (o EventsToMetricsRuleArrayOutput) ToEventsToMetricsRuleArrayOutput() EventsToMetricsRuleArrayOutput {
return o
}
func (o EventsToMetricsRuleArrayOutput) ToEventsToMetricsRuleArrayOutputWithContext(ctx context.Context) EventsToMetricsRuleArrayOutput {
return o
}
func (o EventsToMetricsRuleArrayOutput) Index(i pulumi.IntInput) EventsToMetricsRuleOutput {
return pulumi.All(o, i).ApplyT(func(vs []interface{}) EventsToMetricsRule {
return vs[0].([]EventsToMetricsRule)[vs[1].(int)]
}).(EventsToMetricsRuleOutput)
}
type EventsToMetricsRuleMapOutput struct{ *pulumi.OutputState }
func (EventsToMetricsRuleMapOutput) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]EventsToMetricsRule)(nil))
}
func (o EventsToMetricsRuleMapOutput) ToEventsToMetricsRuleMapOutput() EventsToMetricsRuleMapOutput {
return o
}
func (o EventsToMetricsRuleMapOutput) ToEventsToMetricsRuleMapOutputWithContext(ctx context.Context) EventsToMetricsRuleMapOutput {
return o
}
func (o EventsToMetricsRuleMapOutput) MapIndex(k pulumi.StringInput) EventsToMetricsRuleOutput {
return pulumi.All(o, k).ApplyT(func(vs []interface{}) EventsToMetricsRule {
return vs[0].(map[string]EventsToMetricsRule)[vs[1].(string)]
}).(EventsToMetricsRuleOutput)
}
func init() {
pulumi.RegisterOutputType(EventsToMetricsRuleOutput{})
pulumi.RegisterOutputType(EventsToMetricsRulePtrOutput{})
pulumi.RegisterOutputType(EventsToMetricsRuleArrayOutput{})
pulumi.RegisterOutputType(EventsToMetricsRuleMapOutput{})
}