-
Notifications
You must be signed in to change notification settings - Fork 2
/
escalationPolicy.go
213 lines (190 loc) · 7.34 KB
/
escalationPolicy.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
// *** 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"
)
// An [escalation policy](https://v2.developer.pagerduty.com/v2/page/api-reference#!/Escalation_Policies/get_escalation_policies) determines what user or schedule will be notified first, second, and so on when an incident is triggered. Escalation policies are used by one or more services.
//
// ## 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 {
// exampleTeam, err := pagerduty.NewTeam(ctx, "exampleTeam", &pagerduty.TeamArgs{
// Description: pulumi.String("All engineering"),
// })
// if err != nil {
// return err
// }
// exampleUser, err := pagerduty.NewUser(ctx, "exampleUser", &pagerduty.UserArgs{
// Email: pulumi.String("125.greenholt.earline@graham.name"),
// Teams: pulumi.StringArray{
// exampleTeam.ID(),
// },
// })
// if err != nil {
// return err
// }
// _, err = pagerduty.NewEscalationPolicy(ctx, "exampleEscalationPolicy", &pagerduty.EscalationPolicyArgs{
// NumLoops: pulumi.Int(2),
// Rules: pagerduty.EscalationPolicyRuleArray{
// &pagerduty.EscalationPolicyRuleArgs{
// EscalationDelayInMinutes: pulumi.Int(10),
// Targets: pagerduty.EscalationPolicyRuleTargetArray{
// &pagerduty.EscalationPolicyRuleTargetArgs{
// Id: exampleUser.ID(),
// Type: pulumi.String("user"),
// },
// },
// },
// },
// Teams: pulumi.StringArray{
// exampleTeam.ID(),
// },
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
// ```
//
// ## Import
//
// Escalation policies can be imported using the `id`, e.g.
//
// ```sh
// $ pulumi import pagerduty:index/escalationPolicy:EscalationPolicy main PLBP09X
// ```
type EscalationPolicy struct {
pulumi.CustomResourceState
Description pulumi.StringPtrOutput `pulumi:"description"`
// The name of the escalation policy.
Name pulumi.StringOutput `pulumi:"name"`
// The number of times the escalation policy will repeat after reaching the end of its escalation.
NumLoops pulumi.IntPtrOutput `pulumi:"numLoops"`
// An Escalation rule block. Escalation rules documented below.
Rules EscalationPolicyRuleArrayOutput `pulumi:"rules"`
// Teams associated with the policy. Account must have the `teams` ability to use this parameter.
Teams pulumi.StringArrayOutput `pulumi:"teams"`
}
// NewEscalationPolicy registers a new resource with the given unique name, arguments, and options.
func NewEscalationPolicy(ctx *pulumi.Context,
name string, args *EscalationPolicyArgs, opts ...pulumi.ResourceOption) (*EscalationPolicy, error) {
if args == nil || args.Rules == nil {
return nil, errors.New("missing required argument 'Rules'")
}
if args == nil {
args = &EscalationPolicyArgs{}
}
var resource EscalationPolicy
err := ctx.RegisterResource("pagerduty:index/escalationPolicy:EscalationPolicy", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// GetEscalationPolicy gets an existing EscalationPolicy 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 GetEscalationPolicy(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *EscalationPolicyState, opts ...pulumi.ResourceOption) (*EscalationPolicy, error) {
var resource EscalationPolicy
err := ctx.ReadResource("pagerduty:index/escalationPolicy:EscalationPolicy", name, id, state, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// Input properties used for looking up and filtering EscalationPolicy resources.
type escalationPolicyState struct {
Description *string `pulumi:"description"`
// The name of the escalation policy.
Name *string `pulumi:"name"`
// The number of times the escalation policy will repeat after reaching the end of its escalation.
NumLoops *int `pulumi:"numLoops"`
// An Escalation rule block. Escalation rules documented below.
Rules []EscalationPolicyRule `pulumi:"rules"`
// Teams associated with the policy. Account must have the `teams` ability to use this parameter.
Teams []string `pulumi:"teams"`
}
type EscalationPolicyState struct {
Description pulumi.StringPtrInput
// The name of the escalation policy.
Name pulumi.StringPtrInput
// The number of times the escalation policy will repeat after reaching the end of its escalation.
NumLoops pulumi.IntPtrInput
// An Escalation rule block. Escalation rules documented below.
Rules EscalationPolicyRuleArrayInput
// Teams associated with the policy. Account must have the `teams` ability to use this parameter.
Teams pulumi.StringArrayInput
}
func (EscalationPolicyState) ElementType() reflect.Type {
return reflect.TypeOf((*escalationPolicyState)(nil)).Elem()
}
type escalationPolicyArgs struct {
Description *string `pulumi:"description"`
// The name of the escalation policy.
Name *string `pulumi:"name"`
// The number of times the escalation policy will repeat after reaching the end of its escalation.
NumLoops *int `pulumi:"numLoops"`
// An Escalation rule block. Escalation rules documented below.
Rules []EscalationPolicyRule `pulumi:"rules"`
// Teams associated with the policy. Account must have the `teams` ability to use this parameter.
Teams []string `pulumi:"teams"`
}
// The set of arguments for constructing a EscalationPolicy resource.
type EscalationPolicyArgs struct {
Description pulumi.StringPtrInput
// The name of the escalation policy.
Name pulumi.StringPtrInput
// The number of times the escalation policy will repeat after reaching the end of its escalation.
NumLoops pulumi.IntPtrInput
// An Escalation rule block. Escalation rules documented below.
Rules EscalationPolicyRuleArrayInput
// Teams associated with the policy. Account must have the `teams` ability to use this parameter.
Teams pulumi.StringArrayInput
}
func (EscalationPolicyArgs) ElementType() reflect.Type {
return reflect.TypeOf((*escalationPolicyArgs)(nil)).Elem()
}
type EscalationPolicyInput interface {
pulumi.Input
ToEscalationPolicyOutput() EscalationPolicyOutput
ToEscalationPolicyOutputWithContext(ctx context.Context) EscalationPolicyOutput
}
func (EscalationPolicy) ElementType() reflect.Type {
return reflect.TypeOf((*EscalationPolicy)(nil)).Elem()
}
func (i EscalationPolicy) ToEscalationPolicyOutput() EscalationPolicyOutput {
return i.ToEscalationPolicyOutputWithContext(context.Background())
}
func (i EscalationPolicy) ToEscalationPolicyOutputWithContext(ctx context.Context) EscalationPolicyOutput {
return pulumi.ToOutputWithContext(ctx, i).(EscalationPolicyOutput)
}
type EscalationPolicyOutput struct {
*pulumi.OutputState
}
func (EscalationPolicyOutput) ElementType() reflect.Type {
return reflect.TypeOf((*EscalationPolicyOutput)(nil)).Elem()
}
func (o EscalationPolicyOutput) ToEscalationPolicyOutput() EscalationPolicyOutput {
return o
}
func (o EscalationPolicyOutput) ToEscalationPolicyOutputWithContext(ctx context.Context) EscalationPolicyOutput {
return o
}
func init() {
pulumi.RegisterOutputType(EscalationPolicyOutput{})
}