/
getUserContactMethod.go
197 lines (173 loc) · 8.37 KB
/
getUserContactMethod.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
// 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"
"github.com/pulumi/pulumi-pagerduty/sdk/v3/go/pagerduty/internal"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
// Use this data source to get information about a specific [contact method](https://developer.pagerduty.com/api-reference/b3A6Mjc0ODIzOQ-list-a-user-s-contact-methods) of a PagerDuty [user](https://developer.pagerduty.com/api-reference/b3A6Mjc0ODIzMw-list-users) that you can use for other PagerDuty resources.
//
// ## Example Usage
//
// ```go
// package main
//
// import (
//
// "github.com/pulumi/pulumi-pagerduty/sdk/v3/go/pagerduty"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
//
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// me, err := pagerduty.LookupUser(ctx, &pagerduty.LookupUserArgs{
// Email: "me@example.com",
// }, nil)
// if err != nil {
// return err
// }
// phonePush, err := pagerduty.LookupUserContactMethod(ctx, &pagerduty.LookupUserContactMethodArgs{
// UserId: me.Id,
// Type: "push_notification_contact_method",
// Label: "iPhone (John)",
// }, nil)
// if err != nil {
// return err
// }
// _, err = pagerduty.NewUserNotificationRule(ctx, "lowUrgencySms", &pagerduty.UserNotificationRuleArgs{
// UserId: *pulumi.String(me.Id),
// StartDelayInMinutes: pulumi.Int(5),
// Urgency: pulumi.String("high"),
// ContactMethod: pulumi.StringMap{
// "type": pulumi.String("push_notification_contact_method"),
// "id": *pulumi.String(phonePush.Id),
// },
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
//
// ```
func LookupUserContactMethod(ctx *pulumi.Context, args *LookupUserContactMethodArgs, opts ...pulumi.InvokeOption) (*LookupUserContactMethodResult, error) {
opts = internal.PkgInvokeDefaultOpts(opts)
var rv LookupUserContactMethodResult
err := ctx.Invoke("pagerduty:index/getUserContactMethod:getUserContactMethod", args, &rv, opts...)
if err != nil {
return nil, err
}
return &rv, nil
}
// A collection of arguments for invoking getUserContactMethod.
type LookupUserContactMethodArgs struct {
// The label (e.g., "Work", "Mobile", "Ashley's iPhone", etc.).
Label string `pulumi:"label"`
// The contact method type. May be (`emailContactMethod`, `phoneContactMethod`, `smsContactMethod`, `pushNotificationContactMethod`).
Type string `pulumi:"type"`
// The ID of the user.
UserId string `pulumi:"userId"`
}
// A collection of values returned by getUserContactMethod.
type LookupUserContactMethodResult struct {
// The "address" to deliver to: `email`, `phone number`, etc., depending on the type.
Address string `pulumi:"address"`
// If true, this phone has been blacklisted by PagerDuty and no messages will be sent to it. (Phone and SMS contact methods only.)
Blacklisted bool `pulumi:"blacklisted"`
// The 1-to-3 digit country calling code. (Phone and SMS contact methods only.)
CountryCode int `pulumi:"countryCode"`
// Either `ios` or `android`, depending on the type of the device receiving notifications. (Push notification contact method only.)
DeviceType string `pulumi:"deviceType"`
// If true, this phone is capable of receiving SMS messages. (Phone and SMS contact methods only.)
Enabled bool `pulumi:"enabled"`
// The provider-assigned unique ID for this managed resource.
Id string `pulumi:"id"`
// The label (e.g., "Work", "Mobile", "Ashley's iPhone", etc.).
Label string `pulumi:"label"`
// Send an abbreviated email message instead of the standard email output. (Email contact method only.)
SendShortEmail bool `pulumi:"sendShortEmail"`
// The type of the found contact method. May be (`emailContactMethod`, `phoneContactMethod`, `smsContactMethod`, `pushNotificationContactMethod`).
Type string `pulumi:"type"`
UserId string `pulumi:"userId"`
}
func LookupUserContactMethodOutput(ctx *pulumi.Context, args LookupUserContactMethodOutputArgs, opts ...pulumi.InvokeOption) LookupUserContactMethodResultOutput {
return pulumi.ToOutputWithContext(context.Background(), args).
ApplyT(func(v interface{}) (LookupUserContactMethodResult, error) {
args := v.(LookupUserContactMethodArgs)
r, err := LookupUserContactMethod(ctx, &args, opts...)
var s LookupUserContactMethodResult
if r != nil {
s = *r
}
return s, err
}).(LookupUserContactMethodResultOutput)
}
// A collection of arguments for invoking getUserContactMethod.
type LookupUserContactMethodOutputArgs struct {
// The label (e.g., "Work", "Mobile", "Ashley's iPhone", etc.).
Label pulumi.StringInput `pulumi:"label"`
// The contact method type. May be (`emailContactMethod`, `phoneContactMethod`, `smsContactMethod`, `pushNotificationContactMethod`).
Type pulumi.StringInput `pulumi:"type"`
// The ID of the user.
UserId pulumi.StringInput `pulumi:"userId"`
}
func (LookupUserContactMethodOutputArgs) ElementType() reflect.Type {
return reflect.TypeOf((*LookupUserContactMethodArgs)(nil)).Elem()
}
// A collection of values returned by getUserContactMethod.
type LookupUserContactMethodResultOutput struct{ *pulumi.OutputState }
func (LookupUserContactMethodResultOutput) ElementType() reflect.Type {
return reflect.TypeOf((*LookupUserContactMethodResult)(nil)).Elem()
}
func (o LookupUserContactMethodResultOutput) ToLookupUserContactMethodResultOutput() LookupUserContactMethodResultOutput {
return o
}
func (o LookupUserContactMethodResultOutput) ToLookupUserContactMethodResultOutputWithContext(ctx context.Context) LookupUserContactMethodResultOutput {
return o
}
// The "address" to deliver to: `email`, `phone number`, etc., depending on the type.
func (o LookupUserContactMethodResultOutput) Address() pulumi.StringOutput {
return o.ApplyT(func(v LookupUserContactMethodResult) string { return v.Address }).(pulumi.StringOutput)
}
// If true, this phone has been blacklisted by PagerDuty and no messages will be sent to it. (Phone and SMS contact methods only.)
func (o LookupUserContactMethodResultOutput) Blacklisted() pulumi.BoolOutput {
return o.ApplyT(func(v LookupUserContactMethodResult) bool { return v.Blacklisted }).(pulumi.BoolOutput)
}
// The 1-to-3 digit country calling code. (Phone and SMS contact methods only.)
func (o LookupUserContactMethodResultOutput) CountryCode() pulumi.IntOutput {
return o.ApplyT(func(v LookupUserContactMethodResult) int { return v.CountryCode }).(pulumi.IntOutput)
}
// Either `ios` or `android`, depending on the type of the device receiving notifications. (Push notification contact method only.)
func (o LookupUserContactMethodResultOutput) DeviceType() pulumi.StringOutput {
return o.ApplyT(func(v LookupUserContactMethodResult) string { return v.DeviceType }).(pulumi.StringOutput)
}
// If true, this phone is capable of receiving SMS messages. (Phone and SMS contact methods only.)
func (o LookupUserContactMethodResultOutput) Enabled() pulumi.BoolOutput {
return o.ApplyT(func(v LookupUserContactMethodResult) bool { return v.Enabled }).(pulumi.BoolOutput)
}
// The provider-assigned unique ID for this managed resource.
func (o LookupUserContactMethodResultOutput) Id() pulumi.StringOutput {
return o.ApplyT(func(v LookupUserContactMethodResult) string { return v.Id }).(pulumi.StringOutput)
}
// The label (e.g., "Work", "Mobile", "Ashley's iPhone", etc.).
func (o LookupUserContactMethodResultOutput) Label() pulumi.StringOutput {
return o.ApplyT(func(v LookupUserContactMethodResult) string { return v.Label }).(pulumi.StringOutput)
}
// Send an abbreviated email message instead of the standard email output. (Email contact method only.)
func (o LookupUserContactMethodResultOutput) SendShortEmail() pulumi.BoolOutput {
return o.ApplyT(func(v LookupUserContactMethodResult) bool { return v.SendShortEmail }).(pulumi.BoolOutput)
}
// The type of the found contact method. May be (`emailContactMethod`, `phoneContactMethod`, `smsContactMethod`, `pushNotificationContactMethod`).
func (o LookupUserContactMethodResultOutput) Type() pulumi.StringOutput {
return o.ApplyT(func(v LookupUserContactMethodResult) string { return v.Type }).(pulumi.StringOutput)
}
func (o LookupUserContactMethodResultOutput) UserId() pulumi.StringOutput {
return o.ApplyT(func(v LookupUserContactMethodResult) string { return v.UserId }).(pulumi.StringOutput)
}
func init() {
pulumi.RegisterOutputType(LookupUserContactMethodResultOutput{})
}