-
Notifications
You must be signed in to change notification settings - Fork 2
/
slackConnection.go
371 lines (317 loc) · 14.4 KB
/
slackConnection.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
369
370
371
// 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 [slack connection](https://developer.pagerduty.com/api-reference/YXBpOjExMjA5NTQ0-pager-duty-slack-integration-api) allows you to connect a workspace in Slack to a PagerDuty service or team which allows you to acknowledge and resolve PagerDuty incidents from the Slack user interface.
//
// **NOTES for using this resource:**
// * To first use this resource you will need to [map your PagerDuty account to a valid Slack Workspace](https://support.pagerduty.com/docs/slack-integration-guide#integration-walkthrough). *This can only be done through the PagerDuty UI.*
// * This resource requires a PagerDuty [user-level API key](https://support.pagerduty.com/docs/generating-api-keys#section-generating-a-personal-rest-api-key). This can be set as the `userToken` on the provider tag or as the `PAGERDUTY_USER_TOKEN` environment variable.
// * This resource is for configuring Slack V2 Next Generation connections. If you configured your Slack integration (V1 or V2) prior to August 10, 2021, you may migrate to the Slack V2 Next Generation update using this [migration instructions](https://support.pagerduty.com/docs/slack-integration-guide#migrate-to-slack-v2-next-generation), but if you configured your Slack integration after that date, you will have access to the update out of the box.
// ## 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 {
// foo, err := pagerduty.NewTeam(ctx, "foo", &pagerduty.TeamArgs{
// Name: pulumi.String("Team Foo"),
// })
// if err != nil {
// return err
// }
// p1, err := pagerduty.GetPriority(ctx, &pagerduty.GetPriorityArgs{
// Name: "P1",
// }, nil)
// if err != nil {
// return err
// }
// _, err = pagerduty.NewSlackConnection(ctx, "foo", &pagerduty.SlackConnectionArgs{
// SourceId: foo.ID(),
// SourceType: pulumi.String("team_reference"),
// WorkspaceId: pulumi.String("T02A123LV1A"),
// ChannelId: pulumi.String("C02CABCDAC9"),
// NotificationType: pulumi.String("responder"),
// Configs: pagerduty.SlackConnectionConfigArray{
// &pagerduty.SlackConnectionConfigArgs{
// Events: pulumi.StringArray{
// pulumi.String("incident.triggered"),
// pulumi.String("incident.acknowledged"),
// pulumi.String("incident.escalated"),
// pulumi.String("incident.resolved"),
// pulumi.String("incident.reassigned"),
// pulumi.String("incident.annotated"),
// pulumi.String("incident.unacknowledged"),
// pulumi.String("incident.delegated"),
// pulumi.String("incident.priority_updated"),
// pulumi.String("incident.responder.added"),
// pulumi.String("incident.responder.replied"),
// pulumi.String("incident.status_update_published"),
// pulumi.String("incident.reopened"),
// },
// Priorities: pulumi.StringArray{
// pulumi.String(p1.Id),
// },
// },
// },
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
//
// ```
//
// ## Import
//
// Slack connections can be imported using the related `workspace` ID and the `slack_connection` ID separated by a dot, e.g.
//
// ```sh
// $ pulumi import pagerduty:index/slackConnection:SlackConnection main T02A123LV1A.PUABCDL
// ```
type SlackConnection struct {
pulumi.CustomResourceState
ChannelId pulumi.StringOutput `pulumi:"channelId"`
// Name of the Slack channel in Slack connection.
ChannelName pulumi.StringOutput `pulumi:"channelName"`
Configs SlackConnectionConfigArrayOutput `pulumi:"configs"`
NotificationType pulumi.StringOutput `pulumi:"notificationType"`
SourceId pulumi.StringOutput `pulumi:"sourceId"`
// Name of the source (team or service) in Slack connection.
SourceName pulumi.StringOutput `pulumi:"sourceName"`
SourceType pulumi.StringOutput `pulumi:"sourceType"`
WorkspaceId pulumi.StringOutput `pulumi:"workspaceId"`
}
// NewSlackConnection registers a new resource with the given unique name, arguments, and options.
func NewSlackConnection(ctx *pulumi.Context,
name string, args *SlackConnectionArgs, opts ...pulumi.ResourceOption) (*SlackConnection, error) {
if args == nil {
return nil, errors.New("missing one or more required arguments")
}
if args.ChannelId == nil {
return nil, errors.New("invalid value for required argument 'ChannelId'")
}
if args.Configs == nil {
return nil, errors.New("invalid value for required argument 'Configs'")
}
if args.NotificationType == nil {
return nil, errors.New("invalid value for required argument 'NotificationType'")
}
if args.SourceId == nil {
return nil, errors.New("invalid value for required argument 'SourceId'")
}
if args.SourceType == nil {
return nil, errors.New("invalid value for required argument 'SourceType'")
}
if args.WorkspaceId == nil {
return nil, errors.New("invalid value for required argument 'WorkspaceId'")
}
opts = internal.PkgResourceDefaultOpts(opts)
var resource SlackConnection
err := ctx.RegisterResource("pagerduty:index/slackConnection:SlackConnection", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// GetSlackConnection gets an existing SlackConnection 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 GetSlackConnection(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *SlackConnectionState, opts ...pulumi.ResourceOption) (*SlackConnection, error) {
var resource SlackConnection
err := ctx.ReadResource("pagerduty:index/slackConnection:SlackConnection", name, id, state, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// Input properties used for looking up and filtering SlackConnection resources.
type slackConnectionState struct {
ChannelId *string `pulumi:"channelId"`
// Name of the Slack channel in Slack connection.
ChannelName *string `pulumi:"channelName"`
Configs []SlackConnectionConfig `pulumi:"configs"`
NotificationType *string `pulumi:"notificationType"`
SourceId *string `pulumi:"sourceId"`
// Name of the source (team or service) in Slack connection.
SourceName *string `pulumi:"sourceName"`
SourceType *string `pulumi:"sourceType"`
WorkspaceId *string `pulumi:"workspaceId"`
}
type SlackConnectionState struct {
ChannelId pulumi.StringPtrInput
// Name of the Slack channel in Slack connection.
ChannelName pulumi.StringPtrInput
Configs SlackConnectionConfigArrayInput
NotificationType pulumi.StringPtrInput
SourceId pulumi.StringPtrInput
// Name of the source (team or service) in Slack connection.
SourceName pulumi.StringPtrInput
SourceType pulumi.StringPtrInput
WorkspaceId pulumi.StringPtrInput
}
func (SlackConnectionState) ElementType() reflect.Type {
return reflect.TypeOf((*slackConnectionState)(nil)).Elem()
}
type slackConnectionArgs struct {
ChannelId string `pulumi:"channelId"`
Configs []SlackConnectionConfig `pulumi:"configs"`
NotificationType string `pulumi:"notificationType"`
SourceId string `pulumi:"sourceId"`
SourceType string `pulumi:"sourceType"`
WorkspaceId string `pulumi:"workspaceId"`
}
// The set of arguments for constructing a SlackConnection resource.
type SlackConnectionArgs struct {
ChannelId pulumi.StringInput
Configs SlackConnectionConfigArrayInput
NotificationType pulumi.StringInput
SourceId pulumi.StringInput
SourceType pulumi.StringInput
WorkspaceId pulumi.StringInput
}
func (SlackConnectionArgs) ElementType() reflect.Type {
return reflect.TypeOf((*slackConnectionArgs)(nil)).Elem()
}
type SlackConnectionInput interface {
pulumi.Input
ToSlackConnectionOutput() SlackConnectionOutput
ToSlackConnectionOutputWithContext(ctx context.Context) SlackConnectionOutput
}
func (*SlackConnection) ElementType() reflect.Type {
return reflect.TypeOf((**SlackConnection)(nil)).Elem()
}
func (i *SlackConnection) ToSlackConnectionOutput() SlackConnectionOutput {
return i.ToSlackConnectionOutputWithContext(context.Background())
}
func (i *SlackConnection) ToSlackConnectionOutputWithContext(ctx context.Context) SlackConnectionOutput {
return pulumi.ToOutputWithContext(ctx, i).(SlackConnectionOutput)
}
// SlackConnectionArrayInput is an input type that accepts SlackConnectionArray and SlackConnectionArrayOutput values.
// You can construct a concrete instance of `SlackConnectionArrayInput` via:
//
// SlackConnectionArray{ SlackConnectionArgs{...} }
type SlackConnectionArrayInput interface {
pulumi.Input
ToSlackConnectionArrayOutput() SlackConnectionArrayOutput
ToSlackConnectionArrayOutputWithContext(context.Context) SlackConnectionArrayOutput
}
type SlackConnectionArray []SlackConnectionInput
func (SlackConnectionArray) ElementType() reflect.Type {
return reflect.TypeOf((*[]*SlackConnection)(nil)).Elem()
}
func (i SlackConnectionArray) ToSlackConnectionArrayOutput() SlackConnectionArrayOutput {
return i.ToSlackConnectionArrayOutputWithContext(context.Background())
}
func (i SlackConnectionArray) ToSlackConnectionArrayOutputWithContext(ctx context.Context) SlackConnectionArrayOutput {
return pulumi.ToOutputWithContext(ctx, i).(SlackConnectionArrayOutput)
}
// SlackConnectionMapInput is an input type that accepts SlackConnectionMap and SlackConnectionMapOutput values.
// You can construct a concrete instance of `SlackConnectionMapInput` via:
//
// SlackConnectionMap{ "key": SlackConnectionArgs{...} }
type SlackConnectionMapInput interface {
pulumi.Input
ToSlackConnectionMapOutput() SlackConnectionMapOutput
ToSlackConnectionMapOutputWithContext(context.Context) SlackConnectionMapOutput
}
type SlackConnectionMap map[string]SlackConnectionInput
func (SlackConnectionMap) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*SlackConnection)(nil)).Elem()
}
func (i SlackConnectionMap) ToSlackConnectionMapOutput() SlackConnectionMapOutput {
return i.ToSlackConnectionMapOutputWithContext(context.Background())
}
func (i SlackConnectionMap) ToSlackConnectionMapOutputWithContext(ctx context.Context) SlackConnectionMapOutput {
return pulumi.ToOutputWithContext(ctx, i).(SlackConnectionMapOutput)
}
type SlackConnectionOutput struct{ *pulumi.OutputState }
func (SlackConnectionOutput) ElementType() reflect.Type {
return reflect.TypeOf((**SlackConnection)(nil)).Elem()
}
func (o SlackConnectionOutput) ToSlackConnectionOutput() SlackConnectionOutput {
return o
}
func (o SlackConnectionOutput) ToSlackConnectionOutputWithContext(ctx context.Context) SlackConnectionOutput {
return o
}
func (o SlackConnectionOutput) ChannelId() pulumi.StringOutput {
return o.ApplyT(func(v *SlackConnection) pulumi.StringOutput { return v.ChannelId }).(pulumi.StringOutput)
}
// Name of the Slack channel in Slack connection.
func (o SlackConnectionOutput) ChannelName() pulumi.StringOutput {
return o.ApplyT(func(v *SlackConnection) pulumi.StringOutput { return v.ChannelName }).(pulumi.StringOutput)
}
func (o SlackConnectionOutput) Configs() SlackConnectionConfigArrayOutput {
return o.ApplyT(func(v *SlackConnection) SlackConnectionConfigArrayOutput { return v.Configs }).(SlackConnectionConfigArrayOutput)
}
func (o SlackConnectionOutput) NotificationType() pulumi.StringOutput {
return o.ApplyT(func(v *SlackConnection) pulumi.StringOutput { return v.NotificationType }).(pulumi.StringOutput)
}
func (o SlackConnectionOutput) SourceId() pulumi.StringOutput {
return o.ApplyT(func(v *SlackConnection) pulumi.StringOutput { return v.SourceId }).(pulumi.StringOutput)
}
// Name of the source (team or service) in Slack connection.
func (o SlackConnectionOutput) SourceName() pulumi.StringOutput {
return o.ApplyT(func(v *SlackConnection) pulumi.StringOutput { return v.SourceName }).(pulumi.StringOutput)
}
func (o SlackConnectionOutput) SourceType() pulumi.StringOutput {
return o.ApplyT(func(v *SlackConnection) pulumi.StringOutput { return v.SourceType }).(pulumi.StringOutput)
}
func (o SlackConnectionOutput) WorkspaceId() pulumi.StringOutput {
return o.ApplyT(func(v *SlackConnection) pulumi.StringOutput { return v.WorkspaceId }).(pulumi.StringOutput)
}
type SlackConnectionArrayOutput struct{ *pulumi.OutputState }
func (SlackConnectionArrayOutput) ElementType() reflect.Type {
return reflect.TypeOf((*[]*SlackConnection)(nil)).Elem()
}
func (o SlackConnectionArrayOutput) ToSlackConnectionArrayOutput() SlackConnectionArrayOutput {
return o
}
func (o SlackConnectionArrayOutput) ToSlackConnectionArrayOutputWithContext(ctx context.Context) SlackConnectionArrayOutput {
return o
}
func (o SlackConnectionArrayOutput) Index(i pulumi.IntInput) SlackConnectionOutput {
return pulumi.All(o, i).ApplyT(func(vs []interface{}) *SlackConnection {
return vs[0].([]*SlackConnection)[vs[1].(int)]
}).(SlackConnectionOutput)
}
type SlackConnectionMapOutput struct{ *pulumi.OutputState }
func (SlackConnectionMapOutput) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*SlackConnection)(nil)).Elem()
}
func (o SlackConnectionMapOutput) ToSlackConnectionMapOutput() SlackConnectionMapOutput {
return o
}
func (o SlackConnectionMapOutput) ToSlackConnectionMapOutputWithContext(ctx context.Context) SlackConnectionMapOutput {
return o
}
func (o SlackConnectionMapOutput) MapIndex(k pulumi.StringInput) SlackConnectionOutput {
return pulumi.All(o, k).ApplyT(func(vs []interface{}) *SlackConnection {
return vs[0].(map[string]*SlackConnection)[vs[1].(string)]
}).(SlackConnectionOutput)
}
func init() {
pulumi.RegisterInputType(reflect.TypeOf((*SlackConnectionInput)(nil)).Elem(), &SlackConnection{})
pulumi.RegisterInputType(reflect.TypeOf((*SlackConnectionArrayInput)(nil)).Elem(), SlackConnectionArray{})
pulumi.RegisterInputType(reflect.TypeOf((*SlackConnectionMapInput)(nil)).Elem(), SlackConnectionMap{})
pulumi.RegisterOutputType(SlackConnectionOutput{})
pulumi.RegisterOutputType(SlackConnectionArrayOutput{})
pulumi.RegisterOutputType(SlackConnectionMapOutput{})
}