/
emailProvider.go
359 lines (308 loc) · 13.5 KB
/
emailProvider.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
// 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 auth0
import (
"context"
"reflect"
"errors"
"github.com/pulumi/pulumi-auth0/sdk/v3/go/auth0/internal"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
// With Auth0, you can have standard welcome, password reset, and account verification email-based workflows built right into Auth0. This resource allows you to configure email providers, so you can route all emails that are part of Auth0's authentication workflows through the supported high-volume email service of your choice.
//
// ## Example Usage
//
// <!--Start PulumiCodeChooser -->
// ```go
// package main
//
// import (
//
// "github.com/pulumi/pulumi-auth0/sdk/v3/go/auth0"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
//
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// // This is an example on how to set up the email provider with Amazon SES.
// _, err := auth0.NewEmailProvider(ctx, "amazonSesEmailProvider", &auth0.EmailProviderArgs{
// Credentials: &auth0.EmailProviderCredentialsArgs{
// AccessKeyId: pulumi.String("AKIAXXXXXXXXXXXXXXXX"),
// Region: pulumi.String("us-east-1"),
// SecretAccessKey: pulumi.String("7e8c2148xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"),
// },
// DefaultFromAddress: pulumi.String("accounts@example.com"),
// Enabled: pulumi.Bool(true),
// })
// if err != nil {
// return err
// }
// // This is an example on how to set up the email provider with Sendgrid.
// _, err = auth0.NewEmailProvider(ctx, "sendgridEmailProvider", &auth0.EmailProviderArgs{
// Credentials: &auth0.EmailProviderCredentialsArgs{
// ApiKey: pulumi.String("secretAPIKey"),
// },
// DefaultFromAddress: pulumi.String("accounts@example.com"),
// Enabled: pulumi.Bool(true),
// })
// if err != nil {
// return err
// }
// // This is an example on how to set up the email provider with MS365.
// _, err = auth0.NewEmailProvider(ctx, "smtpEmailProvider", &auth0.EmailProviderArgs{
// Credentials: &auth0.EmailProviderCredentialsArgs{
// Ms365ClientId: pulumi.String("ms365_client_id"),
// Ms365ClientSecret: pulumi.String("ms365_client_secret"),
// Ms365TenantId: pulumi.String("ms365_tenant_id"),
// },
// DefaultFromAddress: pulumi.String("accounts@example.com"),
// Enabled: pulumi.Bool(true),
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
//
// ```
// <!--End PulumiCodeChooser -->
//
// ## Import
//
// As this is not a resource identifiable by an ID within the Auth0 Management API,
//
// email can be imported using a random string.
//
// #
//
// We recommend [Version 4 UUID](https://www.uuidgenerator.net/version4)
//
// #
//
// Example:
//
// ```sh
// $ pulumi import auth0:index/emailProvider:EmailProvider my_email_provider "b4213dc2-2eed-42c3-9516-c6131a9ce0b0"
// ```
type EmailProvider struct {
pulumi.CustomResourceState
// Configuration settings for the credentials for the email provider.
Credentials EmailProviderCredentialsOutput `pulumi:"credentials"`
// Email address to use as the sender when no other "from" address is specified.
DefaultFromAddress pulumi.StringOutput `pulumi:"defaultFromAddress"`
// Indicates whether the email provider is enabled.
Enabled pulumi.BoolPtrOutput `pulumi:"enabled"`
// Name of the email provider. Options include `azureCs`, `mailgun`, `mandrill`, `ms365`, `sendgrid`, `ses`, `smtp` and `sparkpost`.
Name pulumi.StringOutput `pulumi:"name"`
// Specific email provider settings.
Settings EmailProviderSettingsOutput `pulumi:"settings"`
}
// NewEmailProvider registers a new resource with the given unique name, arguments, and options.
func NewEmailProvider(ctx *pulumi.Context,
name string, args *EmailProviderArgs, opts ...pulumi.ResourceOption) (*EmailProvider, error) {
if args == nil {
return nil, errors.New("missing one or more required arguments")
}
if args.Credentials == nil {
return nil, errors.New("invalid value for required argument 'Credentials'")
}
if args.DefaultFromAddress == nil {
return nil, errors.New("invalid value for required argument 'DefaultFromAddress'")
}
opts = internal.PkgResourceDefaultOpts(opts)
var resource EmailProvider
err := ctx.RegisterResource("auth0:index/emailProvider:EmailProvider", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// GetEmailProvider gets an existing EmailProvider 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 GetEmailProvider(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *EmailProviderState, opts ...pulumi.ResourceOption) (*EmailProvider, error) {
var resource EmailProvider
err := ctx.ReadResource("auth0:index/emailProvider:EmailProvider", name, id, state, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// Input properties used for looking up and filtering EmailProvider resources.
type emailProviderState struct {
// Configuration settings for the credentials for the email provider.
Credentials *EmailProviderCredentials `pulumi:"credentials"`
// Email address to use as the sender when no other "from" address is specified.
DefaultFromAddress *string `pulumi:"defaultFromAddress"`
// Indicates whether the email provider is enabled.
Enabled *bool `pulumi:"enabled"`
// Name of the email provider. Options include `azureCs`, `mailgun`, `mandrill`, `ms365`, `sendgrid`, `ses`, `smtp` and `sparkpost`.
Name *string `pulumi:"name"`
// Specific email provider settings.
Settings *EmailProviderSettings `pulumi:"settings"`
}
type EmailProviderState struct {
// Configuration settings for the credentials for the email provider.
Credentials EmailProviderCredentialsPtrInput
// Email address to use as the sender when no other "from" address is specified.
DefaultFromAddress pulumi.StringPtrInput
// Indicates whether the email provider is enabled.
Enabled pulumi.BoolPtrInput
// Name of the email provider. Options include `azureCs`, `mailgun`, `mandrill`, `ms365`, `sendgrid`, `ses`, `smtp` and `sparkpost`.
Name pulumi.StringPtrInput
// Specific email provider settings.
Settings EmailProviderSettingsPtrInput
}
func (EmailProviderState) ElementType() reflect.Type {
return reflect.TypeOf((*emailProviderState)(nil)).Elem()
}
type emailProviderArgs struct {
// Configuration settings for the credentials for the email provider.
Credentials EmailProviderCredentials `pulumi:"credentials"`
// Email address to use as the sender when no other "from" address is specified.
DefaultFromAddress string `pulumi:"defaultFromAddress"`
// Indicates whether the email provider is enabled.
Enabled *bool `pulumi:"enabled"`
// Name of the email provider. Options include `azureCs`, `mailgun`, `mandrill`, `ms365`, `sendgrid`, `ses`, `smtp` and `sparkpost`.
Name *string `pulumi:"name"`
// Specific email provider settings.
Settings *EmailProviderSettings `pulumi:"settings"`
}
// The set of arguments for constructing a EmailProvider resource.
type EmailProviderArgs struct {
// Configuration settings for the credentials for the email provider.
Credentials EmailProviderCredentialsInput
// Email address to use as the sender when no other "from" address is specified.
DefaultFromAddress pulumi.StringInput
// Indicates whether the email provider is enabled.
Enabled pulumi.BoolPtrInput
// Name of the email provider. Options include `azureCs`, `mailgun`, `mandrill`, `ms365`, `sendgrid`, `ses`, `smtp` and `sparkpost`.
Name pulumi.StringPtrInput
// Specific email provider settings.
Settings EmailProviderSettingsPtrInput
}
func (EmailProviderArgs) ElementType() reflect.Type {
return reflect.TypeOf((*emailProviderArgs)(nil)).Elem()
}
type EmailProviderInput interface {
pulumi.Input
ToEmailProviderOutput() EmailProviderOutput
ToEmailProviderOutputWithContext(ctx context.Context) EmailProviderOutput
}
func (*EmailProvider) ElementType() reflect.Type {
return reflect.TypeOf((**EmailProvider)(nil)).Elem()
}
func (i *EmailProvider) ToEmailProviderOutput() EmailProviderOutput {
return i.ToEmailProviderOutputWithContext(context.Background())
}
func (i *EmailProvider) ToEmailProviderOutputWithContext(ctx context.Context) EmailProviderOutput {
return pulumi.ToOutputWithContext(ctx, i).(EmailProviderOutput)
}
// EmailProviderArrayInput is an input type that accepts EmailProviderArray and EmailProviderArrayOutput values.
// You can construct a concrete instance of `EmailProviderArrayInput` via:
//
// EmailProviderArray{ EmailProviderArgs{...} }
type EmailProviderArrayInput interface {
pulumi.Input
ToEmailProviderArrayOutput() EmailProviderArrayOutput
ToEmailProviderArrayOutputWithContext(context.Context) EmailProviderArrayOutput
}
type EmailProviderArray []EmailProviderInput
func (EmailProviderArray) ElementType() reflect.Type {
return reflect.TypeOf((*[]*EmailProvider)(nil)).Elem()
}
func (i EmailProviderArray) ToEmailProviderArrayOutput() EmailProviderArrayOutput {
return i.ToEmailProviderArrayOutputWithContext(context.Background())
}
func (i EmailProviderArray) ToEmailProviderArrayOutputWithContext(ctx context.Context) EmailProviderArrayOutput {
return pulumi.ToOutputWithContext(ctx, i).(EmailProviderArrayOutput)
}
// EmailProviderMapInput is an input type that accepts EmailProviderMap and EmailProviderMapOutput values.
// You can construct a concrete instance of `EmailProviderMapInput` via:
//
// EmailProviderMap{ "key": EmailProviderArgs{...} }
type EmailProviderMapInput interface {
pulumi.Input
ToEmailProviderMapOutput() EmailProviderMapOutput
ToEmailProviderMapOutputWithContext(context.Context) EmailProviderMapOutput
}
type EmailProviderMap map[string]EmailProviderInput
func (EmailProviderMap) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*EmailProvider)(nil)).Elem()
}
func (i EmailProviderMap) ToEmailProviderMapOutput() EmailProviderMapOutput {
return i.ToEmailProviderMapOutputWithContext(context.Background())
}
func (i EmailProviderMap) ToEmailProviderMapOutputWithContext(ctx context.Context) EmailProviderMapOutput {
return pulumi.ToOutputWithContext(ctx, i).(EmailProviderMapOutput)
}
type EmailProviderOutput struct{ *pulumi.OutputState }
func (EmailProviderOutput) ElementType() reflect.Type {
return reflect.TypeOf((**EmailProvider)(nil)).Elem()
}
func (o EmailProviderOutput) ToEmailProviderOutput() EmailProviderOutput {
return o
}
func (o EmailProviderOutput) ToEmailProviderOutputWithContext(ctx context.Context) EmailProviderOutput {
return o
}
// Configuration settings for the credentials for the email provider.
func (o EmailProviderOutput) Credentials() EmailProviderCredentialsOutput {
return o.ApplyT(func(v *EmailProvider) EmailProviderCredentialsOutput { return v.Credentials }).(EmailProviderCredentialsOutput)
}
// Email address to use as the sender when no other "from" address is specified.
func (o EmailProviderOutput) DefaultFromAddress() pulumi.StringOutput {
return o.ApplyT(func(v *EmailProvider) pulumi.StringOutput { return v.DefaultFromAddress }).(pulumi.StringOutput)
}
// Indicates whether the email provider is enabled.
func (o EmailProviderOutput) Enabled() pulumi.BoolPtrOutput {
return o.ApplyT(func(v *EmailProvider) pulumi.BoolPtrOutput { return v.Enabled }).(pulumi.BoolPtrOutput)
}
// Name of the email provider. Options include `azureCs`, `mailgun`, `mandrill`, `ms365`, `sendgrid`, `ses`, `smtp` and `sparkpost`.
func (o EmailProviderOutput) Name() pulumi.StringOutput {
return o.ApplyT(func(v *EmailProvider) pulumi.StringOutput { return v.Name }).(pulumi.StringOutput)
}
// Specific email provider settings.
func (o EmailProviderOutput) Settings() EmailProviderSettingsOutput {
return o.ApplyT(func(v *EmailProvider) EmailProviderSettingsOutput { return v.Settings }).(EmailProviderSettingsOutput)
}
type EmailProviderArrayOutput struct{ *pulumi.OutputState }
func (EmailProviderArrayOutput) ElementType() reflect.Type {
return reflect.TypeOf((*[]*EmailProvider)(nil)).Elem()
}
func (o EmailProviderArrayOutput) ToEmailProviderArrayOutput() EmailProviderArrayOutput {
return o
}
func (o EmailProviderArrayOutput) ToEmailProviderArrayOutputWithContext(ctx context.Context) EmailProviderArrayOutput {
return o
}
func (o EmailProviderArrayOutput) Index(i pulumi.IntInput) EmailProviderOutput {
return pulumi.All(o, i).ApplyT(func(vs []interface{}) *EmailProvider {
return vs[0].([]*EmailProvider)[vs[1].(int)]
}).(EmailProviderOutput)
}
type EmailProviderMapOutput struct{ *pulumi.OutputState }
func (EmailProviderMapOutput) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*EmailProvider)(nil)).Elem()
}
func (o EmailProviderMapOutput) ToEmailProviderMapOutput() EmailProviderMapOutput {
return o
}
func (o EmailProviderMapOutput) ToEmailProviderMapOutputWithContext(ctx context.Context) EmailProviderMapOutput {
return o
}
func (o EmailProviderMapOutput) MapIndex(k pulumi.StringInput) EmailProviderOutput {
return pulumi.All(o, k).ApplyT(func(vs []interface{}) *EmailProvider {
return vs[0].(map[string]*EmailProvider)[vs[1].(string)]
}).(EmailProviderOutput)
}
func init() {
pulumi.RegisterInputType(reflect.TypeOf((*EmailProviderInput)(nil)).Elem(), &EmailProvider{})
pulumi.RegisterInputType(reflect.TypeOf((*EmailProviderArrayInput)(nil)).Elem(), EmailProviderArray{})
pulumi.RegisterInputType(reflect.TypeOf((*EmailProviderMapInput)(nil)).Elem(), EmailProviderMap{})
pulumi.RegisterOutputType(EmailProviderOutput{})
pulumi.RegisterOutputType(EmailProviderArrayOutput{})
pulumi.RegisterOutputType(EmailProviderMapOutput{})
}