-
Notifications
You must be signed in to change notification settings - Fork 2
/
webhookSubscription.go
343 lines (291 loc) · 13.3 KB
/
webhookSubscription.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
// 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"
)
// A [webhook subscription](https://developer.pagerduty.com/docs/ZG9jOjExMDI5NTkw-v3-overview) allow you to receive HTTP callbacks when incidents are created, updated and deleted. These are also known as V3 Webhooks.
//
// ## Example Usage
//
// ```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 {
// example, err := pagerduty.LookupService(ctx, &pagerduty.LookupServiceArgs{
// Name: "My Service",
// }, nil)
// if err != nil {
// return err
// }
// _, err = pagerduty.NewWebhookSubscription(ctx, "foo", &pagerduty.WebhookSubscriptionArgs{
// DeliveryMethods: pagerduty.WebhookSubscriptionDeliveryMethodArray{
// &pagerduty.WebhookSubscriptionDeliveryMethodArgs{
// Type: pulumi.String("http_delivery_method"),
// Url: pulumi.String("https://example.com/receive_a_pagerduty_webhook"),
// CustomHeaders: pagerduty.WebhookSubscriptionDeliveryMethodCustomHeaderArray{
// &pagerduty.WebhookSubscriptionDeliveryMethodCustomHeaderArgs{
// Name: pulumi.String("X-Foo"),
// Value: pulumi.String("foo"),
// },
// &pagerduty.WebhookSubscriptionDeliveryMethodCustomHeaderArgs{
// Name: pulumi.String("X-Bar"),
// Value: pulumi.String("bar"),
// },
// },
// },
// },
// Description: pulumi.String("%s"),
// Events: pulumi.StringArray{
// pulumi.String("incident.acknowledged"),
// pulumi.String("incident.annotated"),
// pulumi.String("incident.delegated"),
// pulumi.String("incident.escalated"),
// pulumi.String("incident.priority_updated"),
// pulumi.String("incident.reassigned"),
// pulumi.String("incident.reopened"),
// pulumi.String("incident.resolved"),
// pulumi.String("incident.responder.added"),
// pulumi.String("incident.responder.replied"),
// pulumi.String("incident.status_update_published"),
// pulumi.String("incident.triggered"),
// pulumi.String("incident.unacknowledged"),
// },
// Active: pulumi.Bool(true),
// Filters: pagerduty.WebhookSubscriptionFilterArray{
// &pagerduty.WebhookSubscriptionFilterArgs{
// Id: pulumi.String(example.Id),
// Type: pulumi.String("service_reference"),
// },
// },
// Type: pulumi.String("webhook_subscription"),
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
//
// ```
//
// ## Import
//
// Webhook Subscriptions can be imported using the `id`, e.g.
//
// ```sh
// $ pulumi import pagerduty:index/webhookSubscription:WebhookSubscription main PUABCDL
// ```
type WebhookSubscription struct {
pulumi.CustomResourceState
Active pulumi.BoolOutput `pulumi:"active"`
DeliveryMethods WebhookSubscriptionDeliveryMethodArrayOutput `pulumi:"deliveryMethods"`
Description pulumi.StringPtrOutput `pulumi:"description"`
Events pulumi.StringArrayOutput `pulumi:"events"`
Filters WebhookSubscriptionFilterArrayOutput `pulumi:"filters"`
Type pulumi.StringPtrOutput `pulumi:"type"`
}
// NewWebhookSubscription registers a new resource with the given unique name, arguments, and options.
func NewWebhookSubscription(ctx *pulumi.Context,
name string, args *WebhookSubscriptionArgs, opts ...pulumi.ResourceOption) (*WebhookSubscription, error) {
if args == nil {
return nil, errors.New("missing one or more required arguments")
}
if args.DeliveryMethods == nil {
return nil, errors.New("invalid value for required argument 'DeliveryMethods'")
}
if args.Events == nil {
return nil, errors.New("invalid value for required argument 'Events'")
}
if args.Filters == nil {
return nil, errors.New("invalid value for required argument 'Filters'")
}
opts = internal.PkgResourceDefaultOpts(opts)
var resource WebhookSubscription
err := ctx.RegisterResource("pagerduty:index/webhookSubscription:WebhookSubscription", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// GetWebhookSubscription gets an existing WebhookSubscription 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 GetWebhookSubscription(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *WebhookSubscriptionState, opts ...pulumi.ResourceOption) (*WebhookSubscription, error) {
var resource WebhookSubscription
err := ctx.ReadResource("pagerduty:index/webhookSubscription:WebhookSubscription", name, id, state, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// Input properties used for looking up and filtering WebhookSubscription resources.
type webhookSubscriptionState struct {
Active *bool `pulumi:"active"`
DeliveryMethods []WebhookSubscriptionDeliveryMethod `pulumi:"deliveryMethods"`
Description *string `pulumi:"description"`
Events []string `pulumi:"events"`
Filters []WebhookSubscriptionFilter `pulumi:"filters"`
Type *string `pulumi:"type"`
}
type WebhookSubscriptionState struct {
Active pulumi.BoolPtrInput
DeliveryMethods WebhookSubscriptionDeliveryMethodArrayInput
Description pulumi.StringPtrInput
Events pulumi.StringArrayInput
Filters WebhookSubscriptionFilterArrayInput
Type pulumi.StringPtrInput
}
func (WebhookSubscriptionState) ElementType() reflect.Type {
return reflect.TypeOf((*webhookSubscriptionState)(nil)).Elem()
}
type webhookSubscriptionArgs struct {
Active *bool `pulumi:"active"`
DeliveryMethods []WebhookSubscriptionDeliveryMethod `pulumi:"deliveryMethods"`
Description *string `pulumi:"description"`
Events []string `pulumi:"events"`
Filters []WebhookSubscriptionFilter `pulumi:"filters"`
Type *string `pulumi:"type"`
}
// The set of arguments for constructing a WebhookSubscription resource.
type WebhookSubscriptionArgs struct {
Active pulumi.BoolPtrInput
DeliveryMethods WebhookSubscriptionDeliveryMethodArrayInput
Description pulumi.StringPtrInput
Events pulumi.StringArrayInput
Filters WebhookSubscriptionFilterArrayInput
Type pulumi.StringPtrInput
}
func (WebhookSubscriptionArgs) ElementType() reflect.Type {
return reflect.TypeOf((*webhookSubscriptionArgs)(nil)).Elem()
}
type WebhookSubscriptionInput interface {
pulumi.Input
ToWebhookSubscriptionOutput() WebhookSubscriptionOutput
ToWebhookSubscriptionOutputWithContext(ctx context.Context) WebhookSubscriptionOutput
}
func (*WebhookSubscription) ElementType() reflect.Type {
return reflect.TypeOf((**WebhookSubscription)(nil)).Elem()
}
func (i *WebhookSubscription) ToWebhookSubscriptionOutput() WebhookSubscriptionOutput {
return i.ToWebhookSubscriptionOutputWithContext(context.Background())
}
func (i *WebhookSubscription) ToWebhookSubscriptionOutputWithContext(ctx context.Context) WebhookSubscriptionOutput {
return pulumi.ToOutputWithContext(ctx, i).(WebhookSubscriptionOutput)
}
// WebhookSubscriptionArrayInput is an input type that accepts WebhookSubscriptionArray and WebhookSubscriptionArrayOutput values.
// You can construct a concrete instance of `WebhookSubscriptionArrayInput` via:
//
// WebhookSubscriptionArray{ WebhookSubscriptionArgs{...} }
type WebhookSubscriptionArrayInput interface {
pulumi.Input
ToWebhookSubscriptionArrayOutput() WebhookSubscriptionArrayOutput
ToWebhookSubscriptionArrayOutputWithContext(context.Context) WebhookSubscriptionArrayOutput
}
type WebhookSubscriptionArray []WebhookSubscriptionInput
func (WebhookSubscriptionArray) ElementType() reflect.Type {
return reflect.TypeOf((*[]*WebhookSubscription)(nil)).Elem()
}
func (i WebhookSubscriptionArray) ToWebhookSubscriptionArrayOutput() WebhookSubscriptionArrayOutput {
return i.ToWebhookSubscriptionArrayOutputWithContext(context.Background())
}
func (i WebhookSubscriptionArray) ToWebhookSubscriptionArrayOutputWithContext(ctx context.Context) WebhookSubscriptionArrayOutput {
return pulumi.ToOutputWithContext(ctx, i).(WebhookSubscriptionArrayOutput)
}
// WebhookSubscriptionMapInput is an input type that accepts WebhookSubscriptionMap and WebhookSubscriptionMapOutput values.
// You can construct a concrete instance of `WebhookSubscriptionMapInput` via:
//
// WebhookSubscriptionMap{ "key": WebhookSubscriptionArgs{...} }
type WebhookSubscriptionMapInput interface {
pulumi.Input
ToWebhookSubscriptionMapOutput() WebhookSubscriptionMapOutput
ToWebhookSubscriptionMapOutputWithContext(context.Context) WebhookSubscriptionMapOutput
}
type WebhookSubscriptionMap map[string]WebhookSubscriptionInput
func (WebhookSubscriptionMap) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*WebhookSubscription)(nil)).Elem()
}
func (i WebhookSubscriptionMap) ToWebhookSubscriptionMapOutput() WebhookSubscriptionMapOutput {
return i.ToWebhookSubscriptionMapOutputWithContext(context.Background())
}
func (i WebhookSubscriptionMap) ToWebhookSubscriptionMapOutputWithContext(ctx context.Context) WebhookSubscriptionMapOutput {
return pulumi.ToOutputWithContext(ctx, i).(WebhookSubscriptionMapOutput)
}
type WebhookSubscriptionOutput struct{ *pulumi.OutputState }
func (WebhookSubscriptionOutput) ElementType() reflect.Type {
return reflect.TypeOf((**WebhookSubscription)(nil)).Elem()
}
func (o WebhookSubscriptionOutput) ToWebhookSubscriptionOutput() WebhookSubscriptionOutput {
return o
}
func (o WebhookSubscriptionOutput) ToWebhookSubscriptionOutputWithContext(ctx context.Context) WebhookSubscriptionOutput {
return o
}
func (o WebhookSubscriptionOutput) Active() pulumi.BoolOutput {
return o.ApplyT(func(v *WebhookSubscription) pulumi.BoolOutput { return v.Active }).(pulumi.BoolOutput)
}
func (o WebhookSubscriptionOutput) DeliveryMethods() WebhookSubscriptionDeliveryMethodArrayOutput {
return o.ApplyT(func(v *WebhookSubscription) WebhookSubscriptionDeliveryMethodArrayOutput { return v.DeliveryMethods }).(WebhookSubscriptionDeliveryMethodArrayOutput)
}
func (o WebhookSubscriptionOutput) Description() pulumi.StringPtrOutput {
return o.ApplyT(func(v *WebhookSubscription) pulumi.StringPtrOutput { return v.Description }).(pulumi.StringPtrOutput)
}
func (o WebhookSubscriptionOutput) Events() pulumi.StringArrayOutput {
return o.ApplyT(func(v *WebhookSubscription) pulumi.StringArrayOutput { return v.Events }).(pulumi.StringArrayOutput)
}
func (o WebhookSubscriptionOutput) Filters() WebhookSubscriptionFilterArrayOutput {
return o.ApplyT(func(v *WebhookSubscription) WebhookSubscriptionFilterArrayOutput { return v.Filters }).(WebhookSubscriptionFilterArrayOutput)
}
func (o WebhookSubscriptionOutput) Type() pulumi.StringPtrOutput {
return o.ApplyT(func(v *WebhookSubscription) pulumi.StringPtrOutput { return v.Type }).(pulumi.StringPtrOutput)
}
type WebhookSubscriptionArrayOutput struct{ *pulumi.OutputState }
func (WebhookSubscriptionArrayOutput) ElementType() reflect.Type {
return reflect.TypeOf((*[]*WebhookSubscription)(nil)).Elem()
}
func (o WebhookSubscriptionArrayOutput) ToWebhookSubscriptionArrayOutput() WebhookSubscriptionArrayOutput {
return o
}
func (o WebhookSubscriptionArrayOutput) ToWebhookSubscriptionArrayOutputWithContext(ctx context.Context) WebhookSubscriptionArrayOutput {
return o
}
func (o WebhookSubscriptionArrayOutput) Index(i pulumi.IntInput) WebhookSubscriptionOutput {
return pulumi.All(o, i).ApplyT(func(vs []interface{}) *WebhookSubscription {
return vs[0].([]*WebhookSubscription)[vs[1].(int)]
}).(WebhookSubscriptionOutput)
}
type WebhookSubscriptionMapOutput struct{ *pulumi.OutputState }
func (WebhookSubscriptionMapOutput) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*WebhookSubscription)(nil)).Elem()
}
func (o WebhookSubscriptionMapOutput) ToWebhookSubscriptionMapOutput() WebhookSubscriptionMapOutput {
return o
}
func (o WebhookSubscriptionMapOutput) ToWebhookSubscriptionMapOutputWithContext(ctx context.Context) WebhookSubscriptionMapOutput {
return o
}
func (o WebhookSubscriptionMapOutput) MapIndex(k pulumi.StringInput) WebhookSubscriptionOutput {
return pulumi.All(o, k).ApplyT(func(vs []interface{}) *WebhookSubscription {
return vs[0].(map[string]*WebhookSubscription)[vs[1].(string)]
}).(WebhookSubscriptionOutput)
}
func init() {
pulumi.RegisterInputType(reflect.TypeOf((*WebhookSubscriptionInput)(nil)).Elem(), &WebhookSubscription{})
pulumi.RegisterInputType(reflect.TypeOf((*WebhookSubscriptionArrayInput)(nil)).Elem(), WebhookSubscriptionArray{})
pulumi.RegisterInputType(reflect.TypeOf((*WebhookSubscriptionMapInput)(nil)).Elem(), WebhookSubscriptionMap{})
pulumi.RegisterOutputType(WebhookSubscriptionOutput{})
pulumi.RegisterOutputType(WebhookSubscriptionArrayOutput{})
pulumi.RegisterOutputType(WebhookSubscriptionMapOutput{})
}