-
Notifications
You must be signed in to change notification settings - Fork 2
/
eventOrchestrationRouter.go
327 lines (278 loc) · 13.9 KB
/
eventOrchestrationRouter.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
// Code generated by the Pulumi Terraform Bridge (tfgen) Tool DO NOT EDIT.
// *** WARNING: Do not edit by hand unless you're certain you know what you are doing! ***
package pagerduty
import (
"context"
"reflect"
"errors"
"github.com/pulumi/pulumi-pagerduty/sdk/v4/go/pagerduty/internal"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
// An Orchestration Router allows users to create a set of Event Rules. The Router evaluates events sent to this Orchestration against each of its rules, one at a time, and routes the event to a specific Service based on the first rule that matches. If an event doesn't match any rules, it'll be sent to service specified in the `catchAll` or to the "Unrouted" Orchestration if no service is specified.
//
// ## Example of configuring Router rules for an Orchestration
//
// In this example the user has defined the Router with two rules, each routing to a different service.
//
// This example assumes services used in the `routeTo` configuration already exists. So it does not show creation of service resource.
//
// ```go
// package main
//
// import (
//
// "github.com/pulumi/pulumi-pagerduty/sdk/v4/go/pagerduty"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
//
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// _, err := pagerduty.NewEventOrchestrationRouter(ctx, "router", &pagerduty.EventOrchestrationRouterArgs{
// EventOrchestration: pulumi.Any(myMonitor.Id),
// Set: &pagerduty.EventOrchestrationRouterSetArgs{
// Id: pulumi.String("start"),
// Rules: pagerduty.EventOrchestrationRouterSetRuleArray{
// &pagerduty.EventOrchestrationRouterSetRuleArgs{
// Label: pulumi.String("Events relating to our relational database"),
// Conditions: pagerduty.EventOrchestrationRouterSetRuleConditionArray{
// &pagerduty.EventOrchestrationRouterSetRuleConditionArgs{
// Expression: pulumi.String("event.summary matches part 'database'"),
// },
// &pagerduty.EventOrchestrationRouterSetRuleConditionArgs{
// Expression: pulumi.String("event.source matches regex 'db[0-9]+-server'"),
// },
// },
// Actions: &pagerduty.EventOrchestrationRouterSetRuleActionsArgs{
// RouteTo: pulumi.Any(database.Id),
// },
// },
// &pagerduty.EventOrchestrationRouterSetRuleArgs{
// Conditions: pagerduty.EventOrchestrationRouterSetRuleConditionArray{
// &pagerduty.EventOrchestrationRouterSetRuleConditionArgs{
// Expression: pulumi.String("event.summary matches part 'www'"),
// },
// },
// Actions: &pagerduty.EventOrchestrationRouterSetRuleActionsArgs{
// RouteTo: pulumi.Any(www.Id),
// },
// },
// },
// },
// CatchAll: &pagerduty.EventOrchestrationRouterCatchAllArgs{
// Actions: &pagerduty.EventOrchestrationRouterCatchAllActionsArgs{
// RouteTo: pulumi.String("unrouted"),
// },
// },
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
//
// ```
//
// ## Import
//
// Router can be imported using the `id` of the Event Orchestration, e.g.
//
// ```sh
// $ pulumi import pagerduty:index/eventOrchestrationRouter:EventOrchestrationRouter router 1b49abe7-26db-4439-a715-c6d883acfb3e
// ```
type EventOrchestrationRouter struct {
pulumi.CustomResourceState
// When none of the rules match an event, the event will be routed according to the catchAll settings.
CatchAll EventOrchestrationRouterCatchAllOutput `pulumi:"catchAll"`
// ID of the Event Orchestration to which the Router belongs.
EventOrchestration pulumi.StringOutput `pulumi:"eventOrchestration"`
// The Router contains a single set of rules (the "start" set).
Set EventOrchestrationRouterSetOutput `pulumi:"set"`
}
// NewEventOrchestrationRouter registers a new resource with the given unique name, arguments, and options.
func NewEventOrchestrationRouter(ctx *pulumi.Context,
name string, args *EventOrchestrationRouterArgs, opts ...pulumi.ResourceOption) (*EventOrchestrationRouter, error) {
if args == nil {
return nil, errors.New("missing one or more required arguments")
}
if args.CatchAll == nil {
return nil, errors.New("invalid value for required argument 'CatchAll'")
}
if args.EventOrchestration == nil {
return nil, errors.New("invalid value for required argument 'EventOrchestration'")
}
if args.Set == nil {
return nil, errors.New("invalid value for required argument 'Set'")
}
opts = internal.PkgResourceDefaultOpts(opts)
var resource EventOrchestrationRouter
err := ctx.RegisterResource("pagerduty:index/eventOrchestrationRouter:EventOrchestrationRouter", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// GetEventOrchestrationRouter gets an existing EventOrchestrationRouter 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 GetEventOrchestrationRouter(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *EventOrchestrationRouterState, opts ...pulumi.ResourceOption) (*EventOrchestrationRouter, error) {
var resource EventOrchestrationRouter
err := ctx.ReadResource("pagerduty:index/eventOrchestrationRouter:EventOrchestrationRouter", name, id, state, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// Input properties used for looking up and filtering EventOrchestrationRouter resources.
type eventOrchestrationRouterState struct {
// When none of the rules match an event, the event will be routed according to the catchAll settings.
CatchAll *EventOrchestrationRouterCatchAll `pulumi:"catchAll"`
// ID of the Event Orchestration to which the Router belongs.
EventOrchestration *string `pulumi:"eventOrchestration"`
// The Router contains a single set of rules (the "start" set).
Set *EventOrchestrationRouterSet `pulumi:"set"`
}
type EventOrchestrationRouterState struct {
// When none of the rules match an event, the event will be routed according to the catchAll settings.
CatchAll EventOrchestrationRouterCatchAllPtrInput
// ID of the Event Orchestration to which the Router belongs.
EventOrchestration pulumi.StringPtrInput
// The Router contains a single set of rules (the "start" set).
Set EventOrchestrationRouterSetPtrInput
}
func (EventOrchestrationRouterState) ElementType() reflect.Type {
return reflect.TypeOf((*eventOrchestrationRouterState)(nil)).Elem()
}
type eventOrchestrationRouterArgs struct {
// When none of the rules match an event, the event will be routed according to the catchAll settings.
CatchAll EventOrchestrationRouterCatchAll `pulumi:"catchAll"`
// ID of the Event Orchestration to which the Router belongs.
EventOrchestration string `pulumi:"eventOrchestration"`
// The Router contains a single set of rules (the "start" set).
Set EventOrchestrationRouterSet `pulumi:"set"`
}
// The set of arguments for constructing a EventOrchestrationRouter resource.
type EventOrchestrationRouterArgs struct {
// When none of the rules match an event, the event will be routed according to the catchAll settings.
CatchAll EventOrchestrationRouterCatchAllInput
// ID of the Event Orchestration to which the Router belongs.
EventOrchestration pulumi.StringInput
// The Router contains a single set of rules (the "start" set).
Set EventOrchestrationRouterSetInput
}
func (EventOrchestrationRouterArgs) ElementType() reflect.Type {
return reflect.TypeOf((*eventOrchestrationRouterArgs)(nil)).Elem()
}
type EventOrchestrationRouterInput interface {
pulumi.Input
ToEventOrchestrationRouterOutput() EventOrchestrationRouterOutput
ToEventOrchestrationRouterOutputWithContext(ctx context.Context) EventOrchestrationRouterOutput
}
func (*EventOrchestrationRouter) ElementType() reflect.Type {
return reflect.TypeOf((**EventOrchestrationRouter)(nil)).Elem()
}
func (i *EventOrchestrationRouter) ToEventOrchestrationRouterOutput() EventOrchestrationRouterOutput {
return i.ToEventOrchestrationRouterOutputWithContext(context.Background())
}
func (i *EventOrchestrationRouter) ToEventOrchestrationRouterOutputWithContext(ctx context.Context) EventOrchestrationRouterOutput {
return pulumi.ToOutputWithContext(ctx, i).(EventOrchestrationRouterOutput)
}
// EventOrchestrationRouterArrayInput is an input type that accepts EventOrchestrationRouterArray and EventOrchestrationRouterArrayOutput values.
// You can construct a concrete instance of `EventOrchestrationRouterArrayInput` via:
//
// EventOrchestrationRouterArray{ EventOrchestrationRouterArgs{...} }
type EventOrchestrationRouterArrayInput interface {
pulumi.Input
ToEventOrchestrationRouterArrayOutput() EventOrchestrationRouterArrayOutput
ToEventOrchestrationRouterArrayOutputWithContext(context.Context) EventOrchestrationRouterArrayOutput
}
type EventOrchestrationRouterArray []EventOrchestrationRouterInput
func (EventOrchestrationRouterArray) ElementType() reflect.Type {
return reflect.TypeOf((*[]*EventOrchestrationRouter)(nil)).Elem()
}
func (i EventOrchestrationRouterArray) ToEventOrchestrationRouterArrayOutput() EventOrchestrationRouterArrayOutput {
return i.ToEventOrchestrationRouterArrayOutputWithContext(context.Background())
}
func (i EventOrchestrationRouterArray) ToEventOrchestrationRouterArrayOutputWithContext(ctx context.Context) EventOrchestrationRouterArrayOutput {
return pulumi.ToOutputWithContext(ctx, i).(EventOrchestrationRouterArrayOutput)
}
// EventOrchestrationRouterMapInput is an input type that accepts EventOrchestrationRouterMap and EventOrchestrationRouterMapOutput values.
// You can construct a concrete instance of `EventOrchestrationRouterMapInput` via:
//
// EventOrchestrationRouterMap{ "key": EventOrchestrationRouterArgs{...} }
type EventOrchestrationRouterMapInput interface {
pulumi.Input
ToEventOrchestrationRouterMapOutput() EventOrchestrationRouterMapOutput
ToEventOrchestrationRouterMapOutputWithContext(context.Context) EventOrchestrationRouterMapOutput
}
type EventOrchestrationRouterMap map[string]EventOrchestrationRouterInput
func (EventOrchestrationRouterMap) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*EventOrchestrationRouter)(nil)).Elem()
}
func (i EventOrchestrationRouterMap) ToEventOrchestrationRouterMapOutput() EventOrchestrationRouterMapOutput {
return i.ToEventOrchestrationRouterMapOutputWithContext(context.Background())
}
func (i EventOrchestrationRouterMap) ToEventOrchestrationRouterMapOutputWithContext(ctx context.Context) EventOrchestrationRouterMapOutput {
return pulumi.ToOutputWithContext(ctx, i).(EventOrchestrationRouterMapOutput)
}
type EventOrchestrationRouterOutput struct{ *pulumi.OutputState }
func (EventOrchestrationRouterOutput) ElementType() reflect.Type {
return reflect.TypeOf((**EventOrchestrationRouter)(nil)).Elem()
}
func (o EventOrchestrationRouterOutput) ToEventOrchestrationRouterOutput() EventOrchestrationRouterOutput {
return o
}
func (o EventOrchestrationRouterOutput) ToEventOrchestrationRouterOutputWithContext(ctx context.Context) EventOrchestrationRouterOutput {
return o
}
// When none of the rules match an event, the event will be routed according to the catchAll settings.
func (o EventOrchestrationRouterOutput) CatchAll() EventOrchestrationRouterCatchAllOutput {
return o.ApplyT(func(v *EventOrchestrationRouter) EventOrchestrationRouterCatchAllOutput { return v.CatchAll }).(EventOrchestrationRouterCatchAllOutput)
}
// ID of the Event Orchestration to which the Router belongs.
func (o EventOrchestrationRouterOutput) EventOrchestration() pulumi.StringOutput {
return o.ApplyT(func(v *EventOrchestrationRouter) pulumi.StringOutput { return v.EventOrchestration }).(pulumi.StringOutput)
}
// The Router contains a single set of rules (the "start" set).
func (o EventOrchestrationRouterOutput) Set() EventOrchestrationRouterSetOutput {
return o.ApplyT(func(v *EventOrchestrationRouter) EventOrchestrationRouterSetOutput { return v.Set }).(EventOrchestrationRouterSetOutput)
}
type EventOrchestrationRouterArrayOutput struct{ *pulumi.OutputState }
func (EventOrchestrationRouterArrayOutput) ElementType() reflect.Type {
return reflect.TypeOf((*[]*EventOrchestrationRouter)(nil)).Elem()
}
func (o EventOrchestrationRouterArrayOutput) ToEventOrchestrationRouterArrayOutput() EventOrchestrationRouterArrayOutput {
return o
}
func (o EventOrchestrationRouterArrayOutput) ToEventOrchestrationRouterArrayOutputWithContext(ctx context.Context) EventOrchestrationRouterArrayOutput {
return o
}
func (o EventOrchestrationRouterArrayOutput) Index(i pulumi.IntInput) EventOrchestrationRouterOutput {
return pulumi.All(o, i).ApplyT(func(vs []interface{}) *EventOrchestrationRouter {
return vs[0].([]*EventOrchestrationRouter)[vs[1].(int)]
}).(EventOrchestrationRouterOutput)
}
type EventOrchestrationRouterMapOutput struct{ *pulumi.OutputState }
func (EventOrchestrationRouterMapOutput) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*EventOrchestrationRouter)(nil)).Elem()
}
func (o EventOrchestrationRouterMapOutput) ToEventOrchestrationRouterMapOutput() EventOrchestrationRouterMapOutput {
return o
}
func (o EventOrchestrationRouterMapOutput) ToEventOrchestrationRouterMapOutputWithContext(ctx context.Context) EventOrchestrationRouterMapOutput {
return o
}
func (o EventOrchestrationRouterMapOutput) MapIndex(k pulumi.StringInput) EventOrchestrationRouterOutput {
return pulumi.All(o, k).ApplyT(func(vs []interface{}) *EventOrchestrationRouter {
return vs[0].(map[string]*EventOrchestrationRouter)[vs[1].(string)]
}).(EventOrchestrationRouterOutput)
}
func init() {
pulumi.RegisterInputType(reflect.TypeOf((*EventOrchestrationRouterInput)(nil)).Elem(), &EventOrchestrationRouter{})
pulumi.RegisterInputType(reflect.TypeOf((*EventOrchestrationRouterArrayInput)(nil)).Elem(), EventOrchestrationRouterArray{})
pulumi.RegisterInputType(reflect.TypeOf((*EventOrchestrationRouterMapInput)(nil)).Elem(), EventOrchestrationRouterMap{})
pulumi.RegisterOutputType(EventOrchestrationRouterOutput{})
pulumi.RegisterOutputType(EventOrchestrationRouterArrayOutput{})
pulumi.RegisterOutputType(EventOrchestrationRouterMapOutput{})
}