-
Notifications
You must be signed in to change notification settings - Fork 2
/
notification.go
368 lines (317 loc) · 13.7 KB
/
notification.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
// 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 cloudamqp
import (
"context"
"reflect"
"errors"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
// This resource allows you to create and manage recipients to receive alarm notifications. There will always be a default recipient created upon instance creation. This recipient will use team email and receive notifications from default alarms.
//
// Available for all subscription plans.
//
// ## Example Usage
//
// ```go
// package main
//
// import (
//
// "github.com/pulumi/pulumi-cloudamqp/sdk/v3/go/cloudamqp"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
//
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// _, err := cloudamqp.NewNotification(ctx, "emailRecipient", &cloudamqp.NotificationArgs{
// InstanceId: pulumi.Any(cloudamqp_instance.Instance.Id),
// Type: pulumi.String("email"),
// Value: pulumi.String("alarm@example.com"),
// })
// if err != nil {
// return err
// }
// _, err = cloudamqp.NewNotification(ctx, "victoropsRecipient", &cloudamqp.NotificationArgs{
// InstanceId: pulumi.Any(cloudamqp_instance.Instance.Id),
// Type: pulumi.String("victorops"),
// Value: pulumi.String("<UUID>"),
// Options: pulumi.StringMap{
// "rk": pulumi.String("ROUTINGKEY"),
// },
// })
// if err != nil {
// return err
// }
// _, err = cloudamqp.NewNotification(ctx, "pagerdutyRecipient", &cloudamqp.NotificationArgs{
// InstanceId: pulumi.Any(cloudamqp_instance.Instance.Id),
// Type: pulumi.String("pagerduty"),
// Value: pulumi.String("<integration-key>"),
// Options: pulumi.StringMap{
// "dedupkey": pulumi.String("DEDUPKEY"),
// },
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
//
// ```
// ## Notification Type reference
//
// Valid options for notification type.
//
// * email
// * webhook
// * pagerduty
// * victorops
// * opsgenie
// * opsgenie-eu
// * slack
// * teams
//
// ## Options parameter
//
// | Type | Options | Description | Note |
// |-----------|----------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------|
// | Victorops | rk | Routing key to route alarm notification | - |
// | PagerDuty | dedupkey | Default the dedup key for PagerDuty is generated depending on what alarm has triggered, but here you can set what `dedup` key to use so even if the same alarm is triggered for different resources you only get one notification. Leave blank to use the generated dedup key. | If multiple alarms are triggered using this recipient, since they all share `dedup` key only the first alarm will be shown in PagerDuty |
//
// ## Dependency
//
// This resource depends on CloudAMQP instance identifier, `cloudamqp_instance.instance.id`.
//
// ## Import
//
// `cloudamqp_notification` can be imported using CloudAMQP internal identifier of a recipient together (CSV separated) with the instance identifier. To retrieve the identifier of a recipient, use [CloudAMQP API](https://docs.cloudamqp.com/cloudamqp_api.html#list-notification-recipients)
//
// ```sh
//
// $ pulumi import cloudamqp:index/notification:Notification recipient <id>,<instance_id>`
//
// ```
type Notification struct {
pulumi.CustomResourceState
// The CloudAMQP instance ID.
InstanceId pulumi.IntOutput `pulumi:"instanceId"`
// Display name of the recipient.
Name pulumi.StringOutput `pulumi:"name"`
// Options argument (e.g. `rk` used for VictorOps routing key).
Options pulumi.StringMapOutput `pulumi:"options"`
// Type of the notification. See valid options below.
Type pulumi.StringOutput `pulumi:"type"`
// Integration/API key or endpoint to send the notification.
Value pulumi.StringOutput `pulumi:"value"`
}
// NewNotification registers a new resource with the given unique name, arguments, and options.
func NewNotification(ctx *pulumi.Context,
name string, args *NotificationArgs, opts ...pulumi.ResourceOption) (*Notification, error) {
if args == nil {
return nil, errors.New("missing one or more required arguments")
}
if args.InstanceId == nil {
return nil, errors.New("invalid value for required argument 'InstanceId'")
}
if args.Type == nil {
return nil, errors.New("invalid value for required argument 'Type'")
}
if args.Value == nil {
return nil, errors.New("invalid value for required argument 'Value'")
}
var resource Notification
err := ctx.RegisterResource("cloudamqp:index/notification:Notification", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// GetNotification gets an existing Notification 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 GetNotification(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *NotificationState, opts ...pulumi.ResourceOption) (*Notification, error) {
var resource Notification
err := ctx.ReadResource("cloudamqp:index/notification:Notification", name, id, state, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// Input properties used for looking up and filtering Notification resources.
type notificationState struct {
// The CloudAMQP instance ID.
InstanceId *int `pulumi:"instanceId"`
// Display name of the recipient.
Name *string `pulumi:"name"`
// Options argument (e.g. `rk` used for VictorOps routing key).
Options map[string]string `pulumi:"options"`
// Type of the notification. See valid options below.
Type *string `pulumi:"type"`
// Integration/API key or endpoint to send the notification.
Value *string `pulumi:"value"`
}
type NotificationState struct {
// The CloudAMQP instance ID.
InstanceId pulumi.IntPtrInput
// Display name of the recipient.
Name pulumi.StringPtrInput
// Options argument (e.g. `rk` used for VictorOps routing key).
Options pulumi.StringMapInput
// Type of the notification. See valid options below.
Type pulumi.StringPtrInput
// Integration/API key or endpoint to send the notification.
Value pulumi.StringPtrInput
}
func (NotificationState) ElementType() reflect.Type {
return reflect.TypeOf((*notificationState)(nil)).Elem()
}
type notificationArgs struct {
// The CloudAMQP instance ID.
InstanceId int `pulumi:"instanceId"`
// Display name of the recipient.
Name *string `pulumi:"name"`
// Options argument (e.g. `rk` used for VictorOps routing key).
Options map[string]string `pulumi:"options"`
// Type of the notification. See valid options below.
Type string `pulumi:"type"`
// Integration/API key or endpoint to send the notification.
Value string `pulumi:"value"`
}
// The set of arguments for constructing a Notification resource.
type NotificationArgs struct {
// The CloudAMQP instance ID.
InstanceId pulumi.IntInput
// Display name of the recipient.
Name pulumi.StringPtrInput
// Options argument (e.g. `rk` used for VictorOps routing key).
Options pulumi.StringMapInput
// Type of the notification. See valid options below.
Type pulumi.StringInput
// Integration/API key or endpoint to send the notification.
Value pulumi.StringInput
}
func (NotificationArgs) ElementType() reflect.Type {
return reflect.TypeOf((*notificationArgs)(nil)).Elem()
}
type NotificationInput interface {
pulumi.Input
ToNotificationOutput() NotificationOutput
ToNotificationOutputWithContext(ctx context.Context) NotificationOutput
}
func (*Notification) ElementType() reflect.Type {
return reflect.TypeOf((**Notification)(nil)).Elem()
}
func (i *Notification) ToNotificationOutput() NotificationOutput {
return i.ToNotificationOutputWithContext(context.Background())
}
func (i *Notification) ToNotificationOutputWithContext(ctx context.Context) NotificationOutput {
return pulumi.ToOutputWithContext(ctx, i).(NotificationOutput)
}
// NotificationArrayInput is an input type that accepts NotificationArray and NotificationArrayOutput values.
// You can construct a concrete instance of `NotificationArrayInput` via:
//
// NotificationArray{ NotificationArgs{...} }
type NotificationArrayInput interface {
pulumi.Input
ToNotificationArrayOutput() NotificationArrayOutput
ToNotificationArrayOutputWithContext(context.Context) NotificationArrayOutput
}
type NotificationArray []NotificationInput
func (NotificationArray) ElementType() reflect.Type {
return reflect.TypeOf((*[]*Notification)(nil)).Elem()
}
func (i NotificationArray) ToNotificationArrayOutput() NotificationArrayOutput {
return i.ToNotificationArrayOutputWithContext(context.Background())
}
func (i NotificationArray) ToNotificationArrayOutputWithContext(ctx context.Context) NotificationArrayOutput {
return pulumi.ToOutputWithContext(ctx, i).(NotificationArrayOutput)
}
// NotificationMapInput is an input type that accepts NotificationMap and NotificationMapOutput values.
// You can construct a concrete instance of `NotificationMapInput` via:
//
// NotificationMap{ "key": NotificationArgs{...} }
type NotificationMapInput interface {
pulumi.Input
ToNotificationMapOutput() NotificationMapOutput
ToNotificationMapOutputWithContext(context.Context) NotificationMapOutput
}
type NotificationMap map[string]NotificationInput
func (NotificationMap) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*Notification)(nil)).Elem()
}
func (i NotificationMap) ToNotificationMapOutput() NotificationMapOutput {
return i.ToNotificationMapOutputWithContext(context.Background())
}
func (i NotificationMap) ToNotificationMapOutputWithContext(ctx context.Context) NotificationMapOutput {
return pulumi.ToOutputWithContext(ctx, i).(NotificationMapOutput)
}
type NotificationOutput struct{ *pulumi.OutputState }
func (NotificationOutput) ElementType() reflect.Type {
return reflect.TypeOf((**Notification)(nil)).Elem()
}
func (o NotificationOutput) ToNotificationOutput() NotificationOutput {
return o
}
func (o NotificationOutput) ToNotificationOutputWithContext(ctx context.Context) NotificationOutput {
return o
}
// The CloudAMQP instance ID.
func (o NotificationOutput) InstanceId() pulumi.IntOutput {
return o.ApplyT(func(v *Notification) pulumi.IntOutput { return v.InstanceId }).(pulumi.IntOutput)
}
// Display name of the recipient.
func (o NotificationOutput) Name() pulumi.StringOutput {
return o.ApplyT(func(v *Notification) pulumi.StringOutput { return v.Name }).(pulumi.StringOutput)
}
// Options argument (e.g. `rk` used for VictorOps routing key).
func (o NotificationOutput) Options() pulumi.StringMapOutput {
return o.ApplyT(func(v *Notification) pulumi.StringMapOutput { return v.Options }).(pulumi.StringMapOutput)
}
// Type of the notification. See valid options below.
func (o NotificationOutput) Type() pulumi.StringOutput {
return o.ApplyT(func(v *Notification) pulumi.StringOutput { return v.Type }).(pulumi.StringOutput)
}
// Integration/API key or endpoint to send the notification.
func (o NotificationOutput) Value() pulumi.StringOutput {
return o.ApplyT(func(v *Notification) pulumi.StringOutput { return v.Value }).(pulumi.StringOutput)
}
type NotificationArrayOutput struct{ *pulumi.OutputState }
func (NotificationArrayOutput) ElementType() reflect.Type {
return reflect.TypeOf((*[]*Notification)(nil)).Elem()
}
func (o NotificationArrayOutput) ToNotificationArrayOutput() NotificationArrayOutput {
return o
}
func (o NotificationArrayOutput) ToNotificationArrayOutputWithContext(ctx context.Context) NotificationArrayOutput {
return o
}
func (o NotificationArrayOutput) Index(i pulumi.IntInput) NotificationOutput {
return pulumi.All(o, i).ApplyT(func(vs []interface{}) *Notification {
return vs[0].([]*Notification)[vs[1].(int)]
}).(NotificationOutput)
}
type NotificationMapOutput struct{ *pulumi.OutputState }
func (NotificationMapOutput) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*Notification)(nil)).Elem()
}
func (o NotificationMapOutput) ToNotificationMapOutput() NotificationMapOutput {
return o
}
func (o NotificationMapOutput) ToNotificationMapOutputWithContext(ctx context.Context) NotificationMapOutput {
return o
}
func (o NotificationMapOutput) MapIndex(k pulumi.StringInput) NotificationOutput {
return pulumi.All(o, k).ApplyT(func(vs []interface{}) *Notification {
return vs[0].(map[string]*Notification)[vs[1].(string)]
}).(NotificationOutput)
}
func init() {
pulumi.RegisterInputType(reflect.TypeOf((*NotificationInput)(nil)).Elem(), &Notification{})
pulumi.RegisterInputType(reflect.TypeOf((*NotificationArrayInput)(nil)).Elem(), NotificationArray{})
pulumi.RegisterInputType(reflect.TypeOf((*NotificationMapInput)(nil)).Elem(), NotificationMap{})
pulumi.RegisterOutputType(NotificationOutput{})
pulumi.RegisterOutputType(NotificationArrayOutput{})
pulumi.RegisterOutputType(NotificationMapOutput{})
}