/
serviceEventRule.go
442 lines (382 loc) · 17 KB
/
serviceEventRule.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
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
// *** 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 pagerduty
import (
"context"
"reflect"
"github.com/pkg/errors"
"github.com/pulumi/pulumi/sdk/v2/go/pulumi"
)
// A [service event rule](https://support.pagerduty.com/docs/rulesets#service-event-rules) allows you to set actions that should be taken on events for a service that meet the designated rule criteria.
//
// ## Example Usage
//
// ```go
// package main
//
// import (
// "github.com/pulumi/pulumi-pagerduty/sdk/go/pagerduty"
// "github.com/pulumi/pulumi/sdk/v2/go/pulumi"
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// example, err := pagerduty.NewService(ctx, "example", &pagerduty.ServiceArgs{
// AutoResolveTimeout: pulumi.String("14400"),
// AcknowledgementTimeout: pulumi.String("600"),
// EscalationPolicy: pulumi.Any(pagerduty_escalation_policy.Example.Id),
// AlertCreation: pulumi.String("create_alerts_and_incidents"),
// })
// if err != nil {
// return err
// }
// _, err = pagerduty.NewServiceEventRule(ctx, "foo", &pagerduty.ServiceEventRuleArgs{
// Service: example.ID(),
// Position: pulumi.Int(0),
// Disabled: pulumi.Bool(true),
// Conditions: &pagerduty.ServiceEventRuleConditionsArgs{
// Operator: pulumi.String("and"),
// Subconditions: pagerduty.ServiceEventRuleConditionsSubconditionArray{
// &pagerduty.ServiceEventRuleConditionsSubconditionArgs{
// Operator: pulumi.String("contains"),
// Parameters: pagerduty.ServiceEventRuleConditionsSubconditionParameterArray{
// &pagerduty.ServiceEventRuleConditionsSubconditionParameterArgs{
// Value: pulumi.String("disk space"),
// Path: pulumi.String("summary"),
// },
// },
// },
// },
// },
// Variables: pagerduty.ServiceEventRuleVariableArray{
// &pagerduty.ServiceEventRuleVariableArgs{
// Type: pulumi.String("regex"),
// Name: pulumi.String("Src"),
// Parameters: pagerduty.ServiceEventRuleVariableParameterArray{
// &pagerduty.ServiceEventRuleVariableParameterArgs{
// Value: pulumi.String("(.*)"),
// Path: pulumi.String("source"),
// },
// },
// },
// },
// Actions: &pagerduty.ServiceEventRuleActionsArgs{
// Annotates: pagerduty.ServiceEventRuleActionsAnnotateArray{
// &pagerduty.ServiceEventRuleActionsAnnotateArgs{
// Value: pulumi.String("From Terraform"),
// },
// },
// Extractions: pagerduty.ServiceEventRuleActionsExtractionArray{
// &pagerduty.ServiceEventRuleActionsExtractionArgs{
// Target: pulumi.String("dedup_key"),
// Source: pulumi.String("source"),
// Regex: pulumi.String("(.*)"),
// },
// &pagerduty.ServiceEventRuleActionsExtractionArgs{
// Target: pulumi.String("summary"),
// Template: pulumi.String("Warning: Disk Space Low on {{Src}}"),
// },
// },
// },
// })
// if err != nil {
// return err
// }
// _, err = pagerduty.NewServiceEventRule(ctx, "bar", &pagerduty.ServiceEventRuleArgs{
// Service: pulumi.Any(pagerduty_service.Foo.Id),
// Position: pulumi.Int(1),
// Disabled: pulumi.Bool(true),
// Conditions: &pagerduty.ServiceEventRuleConditionsArgs{
// Operator: pulumi.String("and"),
// Subconditions: pagerduty.ServiceEventRuleConditionsSubconditionArray{
// &pagerduty.ServiceEventRuleConditionsSubconditionArgs{
// Operator: pulumi.String("contains"),
// Parameters: pagerduty.ServiceEventRuleConditionsSubconditionParameterArray{
// &pagerduty.ServiceEventRuleConditionsSubconditionParameterArgs{
// Value: pulumi.String("cpu spike"),
// Path: pulumi.String("summary"),
// },
// },
// },
// },
// },
// Actions: &pagerduty.ServiceEventRuleActionsArgs{
// Annotates: pagerduty.ServiceEventRuleActionsAnnotateArray{
// &pagerduty.ServiceEventRuleActionsAnnotateArgs{
// Value: pulumi.String("From Terraform"),
// },
// },
// },
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
// ```
//
// ## Import
//
// Service event rules can be imported using using the related `service` id and the `service_event_rule` id separated by a dot, e.g.
//
// ```sh
// $ pulumi import pagerduty:index/serviceEventRule:ServiceEventRule main a19cdca1-3d5e-4b52-bfea-8c8de04da243.19acac92-027a-4ea0-b06c-bbf516519601
// ```
type ServiceEventRule struct {
pulumi.CustomResourceState
// Actions to apply to an event if the conditions match.
Actions ServiceEventRuleActionsPtrOutput `pulumi:"actions"`
// Conditions evaluated to check if an event matches this event rule.
Conditions ServiceEventRuleConditionsPtrOutput `pulumi:"conditions"`
// Indicates whether the rule is disabled and would therefore not be evaluated.
Disabled pulumi.BoolPtrOutput `pulumi:"disabled"`
// Position/index of the rule within the service.
Position pulumi.IntPtrOutput `pulumi:"position"`
// The ID of the service that the rule belongs to.
Service pulumi.StringOutput `pulumi:"service"`
// Settings for [scheduling the rule](https://support.pagerduty.com/docs/rulesets#section-scheduled-event-rules).
TimeFrame ServiceEventRuleTimeFramePtrOutput `pulumi:"timeFrame"`
// Populate variables from event payloads and use those variables in other event actions. *NOTE: A rule can have multiple `variable` objects.*
Variables ServiceEventRuleVariableArrayOutput `pulumi:"variables"`
}
// NewServiceEventRule registers a new resource with the given unique name, arguments, and options.
func NewServiceEventRule(ctx *pulumi.Context,
name string, args *ServiceEventRuleArgs, opts ...pulumi.ResourceOption) (*ServiceEventRule, error) {
if args == nil {
return nil, errors.New("missing one or more required arguments")
}
if args.Service == nil {
return nil, errors.New("invalid value for required argument 'Service'")
}
var resource ServiceEventRule
err := ctx.RegisterResource("pagerduty:index/serviceEventRule:ServiceEventRule", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// GetServiceEventRule gets an existing ServiceEventRule 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 GetServiceEventRule(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *ServiceEventRuleState, opts ...pulumi.ResourceOption) (*ServiceEventRule, error) {
var resource ServiceEventRule
err := ctx.ReadResource("pagerduty:index/serviceEventRule:ServiceEventRule", name, id, state, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// Input properties used for looking up and filtering ServiceEventRule resources.
type serviceEventRuleState struct {
// Actions to apply to an event if the conditions match.
Actions *ServiceEventRuleActions `pulumi:"actions"`
// Conditions evaluated to check if an event matches this event rule.
Conditions *ServiceEventRuleConditions `pulumi:"conditions"`
// Indicates whether the rule is disabled and would therefore not be evaluated.
Disabled *bool `pulumi:"disabled"`
// Position/index of the rule within the service.
Position *int `pulumi:"position"`
// The ID of the service that the rule belongs to.
Service *string `pulumi:"service"`
// Settings for [scheduling the rule](https://support.pagerduty.com/docs/rulesets#section-scheduled-event-rules).
TimeFrame *ServiceEventRuleTimeFrame `pulumi:"timeFrame"`
// Populate variables from event payloads and use those variables in other event actions. *NOTE: A rule can have multiple `variable` objects.*
Variables []ServiceEventRuleVariable `pulumi:"variables"`
}
type ServiceEventRuleState struct {
// Actions to apply to an event if the conditions match.
Actions ServiceEventRuleActionsPtrInput
// Conditions evaluated to check if an event matches this event rule.
Conditions ServiceEventRuleConditionsPtrInput
// Indicates whether the rule is disabled and would therefore not be evaluated.
Disabled pulumi.BoolPtrInput
// Position/index of the rule within the service.
Position pulumi.IntPtrInput
// The ID of the service that the rule belongs to.
Service pulumi.StringPtrInput
// Settings for [scheduling the rule](https://support.pagerduty.com/docs/rulesets#section-scheduled-event-rules).
TimeFrame ServiceEventRuleTimeFramePtrInput
// Populate variables from event payloads and use those variables in other event actions. *NOTE: A rule can have multiple `variable` objects.*
Variables ServiceEventRuleVariableArrayInput
}
func (ServiceEventRuleState) ElementType() reflect.Type {
return reflect.TypeOf((*serviceEventRuleState)(nil)).Elem()
}
type serviceEventRuleArgs struct {
// Actions to apply to an event if the conditions match.
Actions *ServiceEventRuleActions `pulumi:"actions"`
// Conditions evaluated to check if an event matches this event rule.
Conditions *ServiceEventRuleConditions `pulumi:"conditions"`
// Indicates whether the rule is disabled and would therefore not be evaluated.
Disabled *bool `pulumi:"disabled"`
// Position/index of the rule within the service.
Position *int `pulumi:"position"`
// The ID of the service that the rule belongs to.
Service string `pulumi:"service"`
// Settings for [scheduling the rule](https://support.pagerduty.com/docs/rulesets#section-scheduled-event-rules).
TimeFrame *ServiceEventRuleTimeFrame `pulumi:"timeFrame"`
// Populate variables from event payloads and use those variables in other event actions. *NOTE: A rule can have multiple `variable` objects.*
Variables []ServiceEventRuleVariable `pulumi:"variables"`
}
// The set of arguments for constructing a ServiceEventRule resource.
type ServiceEventRuleArgs struct {
// Actions to apply to an event if the conditions match.
Actions ServiceEventRuleActionsPtrInput
// Conditions evaluated to check if an event matches this event rule.
Conditions ServiceEventRuleConditionsPtrInput
// Indicates whether the rule is disabled and would therefore not be evaluated.
Disabled pulumi.BoolPtrInput
// Position/index of the rule within the service.
Position pulumi.IntPtrInput
// The ID of the service that the rule belongs to.
Service pulumi.StringInput
// Settings for [scheduling the rule](https://support.pagerduty.com/docs/rulesets#section-scheduled-event-rules).
TimeFrame ServiceEventRuleTimeFramePtrInput
// Populate variables from event payloads and use those variables in other event actions. *NOTE: A rule can have multiple `variable` objects.*
Variables ServiceEventRuleVariableArrayInput
}
func (ServiceEventRuleArgs) ElementType() reflect.Type {
return reflect.TypeOf((*serviceEventRuleArgs)(nil)).Elem()
}
type ServiceEventRuleInput interface {
pulumi.Input
ToServiceEventRuleOutput() ServiceEventRuleOutput
ToServiceEventRuleOutputWithContext(ctx context.Context) ServiceEventRuleOutput
}
func (*ServiceEventRule) ElementType() reflect.Type {
return reflect.TypeOf((*ServiceEventRule)(nil))
}
func (i *ServiceEventRule) ToServiceEventRuleOutput() ServiceEventRuleOutput {
return i.ToServiceEventRuleOutputWithContext(context.Background())
}
func (i *ServiceEventRule) ToServiceEventRuleOutputWithContext(ctx context.Context) ServiceEventRuleOutput {
return pulumi.ToOutputWithContext(ctx, i).(ServiceEventRuleOutput)
}
func (i *ServiceEventRule) ToServiceEventRulePtrOutput() ServiceEventRulePtrOutput {
return i.ToServiceEventRulePtrOutputWithContext(context.Background())
}
func (i *ServiceEventRule) ToServiceEventRulePtrOutputWithContext(ctx context.Context) ServiceEventRulePtrOutput {
return pulumi.ToOutputWithContext(ctx, i).(ServiceEventRulePtrOutput)
}
type ServiceEventRulePtrInput interface {
pulumi.Input
ToServiceEventRulePtrOutput() ServiceEventRulePtrOutput
ToServiceEventRulePtrOutputWithContext(ctx context.Context) ServiceEventRulePtrOutput
}
type serviceEventRulePtrType ServiceEventRuleArgs
func (*serviceEventRulePtrType) ElementType() reflect.Type {
return reflect.TypeOf((**ServiceEventRule)(nil))
}
func (i *serviceEventRulePtrType) ToServiceEventRulePtrOutput() ServiceEventRulePtrOutput {
return i.ToServiceEventRulePtrOutputWithContext(context.Background())
}
func (i *serviceEventRulePtrType) ToServiceEventRulePtrOutputWithContext(ctx context.Context) ServiceEventRulePtrOutput {
return pulumi.ToOutputWithContext(ctx, i).(ServiceEventRulePtrOutput)
}
// ServiceEventRuleArrayInput is an input type that accepts ServiceEventRuleArray and ServiceEventRuleArrayOutput values.
// You can construct a concrete instance of `ServiceEventRuleArrayInput` via:
//
// ServiceEventRuleArray{ ServiceEventRuleArgs{...} }
type ServiceEventRuleArrayInput interface {
pulumi.Input
ToServiceEventRuleArrayOutput() ServiceEventRuleArrayOutput
ToServiceEventRuleArrayOutputWithContext(context.Context) ServiceEventRuleArrayOutput
}
type ServiceEventRuleArray []ServiceEventRuleInput
func (ServiceEventRuleArray) ElementType() reflect.Type {
return reflect.TypeOf(([]*ServiceEventRule)(nil))
}
func (i ServiceEventRuleArray) ToServiceEventRuleArrayOutput() ServiceEventRuleArrayOutput {
return i.ToServiceEventRuleArrayOutputWithContext(context.Background())
}
func (i ServiceEventRuleArray) ToServiceEventRuleArrayOutputWithContext(ctx context.Context) ServiceEventRuleArrayOutput {
return pulumi.ToOutputWithContext(ctx, i).(ServiceEventRuleArrayOutput)
}
// ServiceEventRuleMapInput is an input type that accepts ServiceEventRuleMap and ServiceEventRuleMapOutput values.
// You can construct a concrete instance of `ServiceEventRuleMapInput` via:
//
// ServiceEventRuleMap{ "key": ServiceEventRuleArgs{...} }
type ServiceEventRuleMapInput interface {
pulumi.Input
ToServiceEventRuleMapOutput() ServiceEventRuleMapOutput
ToServiceEventRuleMapOutputWithContext(context.Context) ServiceEventRuleMapOutput
}
type ServiceEventRuleMap map[string]ServiceEventRuleInput
func (ServiceEventRuleMap) ElementType() reflect.Type {
return reflect.TypeOf((map[string]*ServiceEventRule)(nil))
}
func (i ServiceEventRuleMap) ToServiceEventRuleMapOutput() ServiceEventRuleMapOutput {
return i.ToServiceEventRuleMapOutputWithContext(context.Background())
}
func (i ServiceEventRuleMap) ToServiceEventRuleMapOutputWithContext(ctx context.Context) ServiceEventRuleMapOutput {
return pulumi.ToOutputWithContext(ctx, i).(ServiceEventRuleMapOutput)
}
type ServiceEventRuleOutput struct {
*pulumi.OutputState
}
func (ServiceEventRuleOutput) ElementType() reflect.Type {
return reflect.TypeOf((*ServiceEventRule)(nil))
}
func (o ServiceEventRuleOutput) ToServiceEventRuleOutput() ServiceEventRuleOutput {
return o
}
func (o ServiceEventRuleOutput) ToServiceEventRuleOutputWithContext(ctx context.Context) ServiceEventRuleOutput {
return o
}
func (o ServiceEventRuleOutput) ToServiceEventRulePtrOutput() ServiceEventRulePtrOutput {
return o.ToServiceEventRulePtrOutputWithContext(context.Background())
}
func (o ServiceEventRuleOutput) ToServiceEventRulePtrOutputWithContext(ctx context.Context) ServiceEventRulePtrOutput {
return o.ApplyT(func(v ServiceEventRule) *ServiceEventRule {
return &v
}).(ServiceEventRulePtrOutput)
}
type ServiceEventRulePtrOutput struct {
*pulumi.OutputState
}
func (ServiceEventRulePtrOutput) ElementType() reflect.Type {
return reflect.TypeOf((**ServiceEventRule)(nil))
}
func (o ServiceEventRulePtrOutput) ToServiceEventRulePtrOutput() ServiceEventRulePtrOutput {
return o
}
func (o ServiceEventRulePtrOutput) ToServiceEventRulePtrOutputWithContext(ctx context.Context) ServiceEventRulePtrOutput {
return o
}
type ServiceEventRuleArrayOutput struct{ *pulumi.OutputState }
func (ServiceEventRuleArrayOutput) ElementType() reflect.Type {
return reflect.TypeOf((*[]ServiceEventRule)(nil))
}
func (o ServiceEventRuleArrayOutput) ToServiceEventRuleArrayOutput() ServiceEventRuleArrayOutput {
return o
}
func (o ServiceEventRuleArrayOutput) ToServiceEventRuleArrayOutputWithContext(ctx context.Context) ServiceEventRuleArrayOutput {
return o
}
func (o ServiceEventRuleArrayOutput) Index(i pulumi.IntInput) ServiceEventRuleOutput {
return pulumi.All(o, i).ApplyT(func(vs []interface{}) ServiceEventRule {
return vs[0].([]ServiceEventRule)[vs[1].(int)]
}).(ServiceEventRuleOutput)
}
type ServiceEventRuleMapOutput struct{ *pulumi.OutputState }
func (ServiceEventRuleMapOutput) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]ServiceEventRule)(nil))
}
func (o ServiceEventRuleMapOutput) ToServiceEventRuleMapOutput() ServiceEventRuleMapOutput {
return o
}
func (o ServiceEventRuleMapOutput) ToServiceEventRuleMapOutputWithContext(ctx context.Context) ServiceEventRuleMapOutput {
return o
}
func (o ServiceEventRuleMapOutput) MapIndex(k pulumi.StringInput) ServiceEventRuleOutput {
return pulumi.All(o, k).ApplyT(func(vs []interface{}) ServiceEventRule {
return vs[0].(map[string]ServiceEventRule)[vs[1].(string)]
}).(ServiceEventRuleOutput)
}
func init() {
pulumi.RegisterOutputType(ServiceEventRuleOutput{})
pulumi.RegisterOutputType(ServiceEventRulePtrOutput{})
pulumi.RegisterOutputType(ServiceEventRuleArrayOutput{})
pulumi.RegisterOutputType(ServiceEventRuleMapOutput{})
}