-
Notifications
You must be signed in to change notification settings - Fork 2
/
userNotificationRule.go
205 lines (192 loc) · 8 KB
/
userNotificationRule.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
// *** 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 (
"reflect"
"github.com/pkg/errors"
"github.com/pulumi/pulumi/sdk/v2/go/pulumi"
)
// A [notification rule](https://v2.developer.pagerduty.com/v2/page/api-reference#!/Users/get_users_id_notification_rules_notification_rule_id) configures where and when a PagerDuty user is notified when a triggered incident is assigned to him. Unique notification rules can be created for both high and low-urgency incidents.
//
// ## 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.NewUser(ctx, "example", &pagerduty.UserArgs{
// Email: pulumi.String("125.greenholt.earline@graham.name"),
// })
// if err != nil {
// return err
// }
// email, err := pagerduty.NewUserContactMethod(ctx, "email", &pagerduty.UserContactMethodArgs{
// UserId: example.ID(),
// Type: pulumi.String("email_contact_method"),
// Address: pulumi.String("foo@bar.com"),
// Label: pulumi.String("Work"),
// })
// if err != nil {
// return err
// }
// phone, err := pagerduty.NewUserContactMethod(ctx, "phone", &pagerduty.UserContactMethodArgs{
// UserId: example.ID(),
// Type: pulumi.String("phone_contact_method"),
// CountryCode: pulumi.Int(1),
// Address: pulumi.String("2025550199"),
// Label: pulumi.String("Work"),
// })
// if err != nil {
// return err
// }
// sms, err := pagerduty.NewUserContactMethod(ctx, "sms", &pagerduty.UserContactMethodArgs{
// UserId: example.ID(),
// Type: pulumi.String("sms_contact_method"),
// CountryCode: pulumi.Int(1),
// Address: pulumi.String("2025550199"),
// Label: pulumi.String("Work"),
// })
// if err != nil {
// return err
// }
// _, err = pagerduty.NewUserNotificationRule(ctx, "highUrgencyPhone", &pagerduty.UserNotificationRuleArgs{
// UserId: example.ID(),
// StartDelayInMinutes: pulumi.Int(1),
// Urgency: pulumi.String("high"),
// ContactMethod: &pagerduty.UserNotificationRuleContactMethodArgs{
// Type: pulumi.String("phone_contact_method"),
// Id: phone.ID(),
// },
// })
// if err != nil {
// return err
// }
// _, err = pagerduty.NewUserNotificationRule(ctx, "lowUrgencyEmail", &pagerduty.UserNotificationRuleArgs{
// UserId: example.ID(),
// StartDelayInMinutes: pulumi.Int(1),
// Urgency: pulumi.String("low"),
// ContactMethod: &pagerduty.UserNotificationRuleContactMethodArgs{
// Type: pulumi.String("email_contact_method"),
// Id: email.ID(),
// },
// })
// if err != nil {
// return err
// }
// _, err = pagerduty.NewUserNotificationRule(ctx, "lowUrgencySms", &pagerduty.UserNotificationRuleArgs{
// UserId: example.ID(),
// StartDelayInMinutes: pulumi.Int(10),
// Urgency: pulumi.String("low"),
// ContactMethod: &pagerduty.UserNotificationRuleContactMethodArgs{
// Type: pulumi.String("sms_contact_method"),
// Id: sms.ID(),
// },
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
// ```
type UserNotificationRule struct {
pulumi.CustomResourceState
// A contact method block, configured as a block described below.
ContactMethod UserNotificationRuleContactMethodOutput `pulumi:"contactMethod"`
// The delay before firing the rule, in minutes.
StartDelayInMinutes pulumi.IntOutput `pulumi:"startDelayInMinutes"`
// Which incident urgency this rule is used for. Account must have the `urgencies` ability to have a low urgency notification rule. Can be `high` or `low`.
Urgency pulumi.StringOutput `pulumi:"urgency"`
// The ID of the user.
UserId pulumi.StringOutput `pulumi:"userId"`
}
// NewUserNotificationRule registers a new resource with the given unique name, arguments, and options.
func NewUserNotificationRule(ctx *pulumi.Context,
name string, args *UserNotificationRuleArgs, opts ...pulumi.ResourceOption) (*UserNotificationRule, error) {
if args == nil || args.ContactMethod == nil {
return nil, errors.New("missing required argument 'ContactMethod'")
}
if args == nil || args.StartDelayInMinutes == nil {
return nil, errors.New("missing required argument 'StartDelayInMinutes'")
}
if args == nil || args.Urgency == nil {
return nil, errors.New("missing required argument 'Urgency'")
}
if args == nil || args.UserId == nil {
return nil, errors.New("missing required argument 'UserId'")
}
if args == nil {
args = &UserNotificationRuleArgs{}
}
var resource UserNotificationRule
err := ctx.RegisterResource("pagerduty:index/userNotificationRule:UserNotificationRule", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// GetUserNotificationRule gets an existing UserNotificationRule 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 GetUserNotificationRule(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *UserNotificationRuleState, opts ...pulumi.ResourceOption) (*UserNotificationRule, error) {
var resource UserNotificationRule
err := ctx.ReadResource("pagerduty:index/userNotificationRule:UserNotificationRule", name, id, state, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// Input properties used for looking up and filtering UserNotificationRule resources.
type userNotificationRuleState struct {
// A contact method block, configured as a block described below.
ContactMethod *UserNotificationRuleContactMethod `pulumi:"contactMethod"`
// The delay before firing the rule, in minutes.
StartDelayInMinutes *int `pulumi:"startDelayInMinutes"`
// Which incident urgency this rule is used for. Account must have the `urgencies` ability to have a low urgency notification rule. Can be `high` or `low`.
Urgency *string `pulumi:"urgency"`
// The ID of the user.
UserId *string `pulumi:"userId"`
}
type UserNotificationRuleState struct {
// A contact method block, configured as a block described below.
ContactMethod UserNotificationRuleContactMethodPtrInput
// The delay before firing the rule, in minutes.
StartDelayInMinutes pulumi.IntPtrInput
// Which incident urgency this rule is used for. Account must have the `urgencies` ability to have a low urgency notification rule. Can be `high` or `low`.
Urgency pulumi.StringPtrInput
// The ID of the user.
UserId pulumi.StringPtrInput
}
func (UserNotificationRuleState) ElementType() reflect.Type {
return reflect.TypeOf((*userNotificationRuleState)(nil)).Elem()
}
type userNotificationRuleArgs struct {
// A contact method block, configured as a block described below.
ContactMethod UserNotificationRuleContactMethod `pulumi:"contactMethod"`
// The delay before firing the rule, in minutes.
StartDelayInMinutes int `pulumi:"startDelayInMinutes"`
// Which incident urgency this rule is used for. Account must have the `urgencies` ability to have a low urgency notification rule. Can be `high` or `low`.
Urgency string `pulumi:"urgency"`
// The ID of the user.
UserId string `pulumi:"userId"`
}
// The set of arguments for constructing a UserNotificationRule resource.
type UserNotificationRuleArgs struct {
// A contact method block, configured as a block described below.
ContactMethod UserNotificationRuleContactMethodInput
// The delay before firing the rule, in minutes.
StartDelayInMinutes pulumi.IntInput
// Which incident urgency this rule is used for. Account must have the `urgencies` ability to have a low urgency notification rule. Can be `high` or `low`.
Urgency pulumi.StringInput
// The ID of the user.
UserId pulumi.StringInput
}
func (UserNotificationRuleArgs) ElementType() reflect.Type {
return reflect.TypeOf((*userNotificationRuleArgs)(nil)).Elem()
}