/
emailTemplate.go
429 lines (374 loc) · 20.2 KB
/
emailTemplate.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
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
// 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 templates to customize the look, feel, and sender identities of emails sent by Auth0. Used in conjunction with configured email providers.
//
// ## 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 {
// myEmailProvider, err := auth0.NewEmailProvider(ctx, "myEmailProvider", &auth0.EmailProviderArgs{
// Enabled: pulumi.Bool(true),
// DefaultFromAddress: pulumi.String("accounts@example.com"),
// Credentials: &auth0.EmailProviderCredentialsArgs{
// AccessKeyId: pulumi.String("AKIAXXXXXXXXXXXXXXXX"),
// SecretAccessKey: pulumi.String("7e8c2148xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"),
// Region: pulumi.String("us-east-1"),
// },
// })
// if err != nil {
// return err
// }
// _, err = auth0.NewEmailTemplate(ctx, "myEmailTemplate", &auth0.EmailTemplateArgs{
// Template: pulumi.String("welcome_email"),
// Body: pulumi.String("<html><body><h1>Welcome!</h1></body></html>"),
// From: pulumi.String("welcome@example.com"),
// ResultUrl: pulumi.String("https://example.com/welcome"),
// Subject: pulumi.String("Welcome"),
// Syntax: pulumi.String("liquid"),
// UrlLifetimeInSeconds: pulumi.Int(3600),
// Enabled: pulumi.Bool(true),
// }, pulumi.DependsOn([]pulumi.Resource{
// myEmailProvider,
// }))
// if err != nil {
// return err
// }
// return nil
// })
// }
//
// ```
// <!--End PulumiCodeChooser -->
//
// ## Import
//
// This resource can be imported using the pre-defined template name.
//
// #
//
// These names are `verify_email`, `verify_email_by_code`, `reset_email`,
//
// `welcome_email`, `blocked_account`, `stolen_credentials`,
//
// `enrollment_email`, `mfa_oob_code`, and `user_invitation`.
//
// #
//
// The names `change_password`, and `password_reset` are also supported
//
// for legacy scenarios.
//
// #
//
// Example:
//
// ```sh
// $ pulumi import auth0:index/emailTemplate:EmailTemplate my_email_template "welcome_email"
// ```
type EmailTemplate struct {
pulumi.CustomResourceState
// Body of the email template. You can include [common variables](https://auth0.com/docs/customize/email/email-templates#common-variables).
Body pulumi.StringOutput `pulumi:"body"`
// Indicates whether the template is enabled.
Enabled pulumi.BoolOutput `pulumi:"enabled"`
// Email address to use as the sender. You can include [common variables](https://auth0.com/docs/customize/email/email-templates#common-variables).
From pulumi.StringOutput `pulumi:"from"`
// Whether the `resetEmail` and `verifyEmail` templates should include the user's email address as the email parameter in the `returnUrl` (true) or whether no email address should be included in the redirect (false). Defaults to `true`.
IncludeEmailInRedirect pulumi.BoolOutput `pulumi:"includeEmailInRedirect"`
// URL to redirect the user to after a successful action. [Learn more](https://auth0.com/docs/customize/email/email-templates#configure-template-fields).
ResultUrl pulumi.StringPtrOutput `pulumi:"resultUrl"`
// Subject line of the email. You can include [common variables](https://auth0.com/docs/customize/email/email-templates#common-variables).
Subject pulumi.StringOutput `pulumi:"subject"`
// Syntax of the template body. You can use either text or HTML with Liquid syntax.
Syntax pulumi.StringOutput `pulumi:"syntax"`
// Template name. Options include `verifyEmail`, `verifyEmailByCode`, `resetEmail`, `welcomeEmail`, `blockedAccount`, `stolenCredentials`, `enrollmentEmail`, `mfaOobCode`, `userInvitation`, `changePassword` (legacy), or `passwordReset` (legacy).
Template pulumi.StringOutput `pulumi:"template"`
// Number of seconds during which the link within the email will be valid.
UrlLifetimeInSeconds pulumi.IntPtrOutput `pulumi:"urlLifetimeInSeconds"`
}
// NewEmailTemplate registers a new resource with the given unique name, arguments, and options.
func NewEmailTemplate(ctx *pulumi.Context,
name string, args *EmailTemplateArgs, opts ...pulumi.ResourceOption) (*EmailTemplate, error) {
if args == nil {
return nil, errors.New("missing one or more required arguments")
}
if args.Body == nil {
return nil, errors.New("invalid value for required argument 'Body'")
}
if args.Enabled == nil {
return nil, errors.New("invalid value for required argument 'Enabled'")
}
if args.From == nil {
return nil, errors.New("invalid value for required argument 'From'")
}
if args.Subject == nil {
return nil, errors.New("invalid value for required argument 'Subject'")
}
if args.Syntax == nil {
return nil, errors.New("invalid value for required argument 'Syntax'")
}
if args.Template == nil {
return nil, errors.New("invalid value for required argument 'Template'")
}
opts = internal.PkgResourceDefaultOpts(opts)
var resource EmailTemplate
err := ctx.RegisterResource("auth0:index/emailTemplate:EmailTemplate", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// GetEmailTemplate gets an existing EmailTemplate 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 GetEmailTemplate(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *EmailTemplateState, opts ...pulumi.ResourceOption) (*EmailTemplate, error) {
var resource EmailTemplate
err := ctx.ReadResource("auth0:index/emailTemplate:EmailTemplate", name, id, state, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// Input properties used for looking up and filtering EmailTemplate resources.
type emailTemplateState struct {
// Body of the email template. You can include [common variables](https://auth0.com/docs/customize/email/email-templates#common-variables).
Body *string `pulumi:"body"`
// Indicates whether the template is enabled.
Enabled *bool `pulumi:"enabled"`
// Email address to use as the sender. You can include [common variables](https://auth0.com/docs/customize/email/email-templates#common-variables).
From *string `pulumi:"from"`
// Whether the `resetEmail` and `verifyEmail` templates should include the user's email address as the email parameter in the `returnUrl` (true) or whether no email address should be included in the redirect (false). Defaults to `true`.
IncludeEmailInRedirect *bool `pulumi:"includeEmailInRedirect"`
// URL to redirect the user to after a successful action. [Learn more](https://auth0.com/docs/customize/email/email-templates#configure-template-fields).
ResultUrl *string `pulumi:"resultUrl"`
// Subject line of the email. You can include [common variables](https://auth0.com/docs/customize/email/email-templates#common-variables).
Subject *string `pulumi:"subject"`
// Syntax of the template body. You can use either text or HTML with Liquid syntax.
Syntax *string `pulumi:"syntax"`
// Template name. Options include `verifyEmail`, `verifyEmailByCode`, `resetEmail`, `welcomeEmail`, `blockedAccount`, `stolenCredentials`, `enrollmentEmail`, `mfaOobCode`, `userInvitation`, `changePassword` (legacy), or `passwordReset` (legacy).
Template *string `pulumi:"template"`
// Number of seconds during which the link within the email will be valid.
UrlLifetimeInSeconds *int `pulumi:"urlLifetimeInSeconds"`
}
type EmailTemplateState struct {
// Body of the email template. You can include [common variables](https://auth0.com/docs/customize/email/email-templates#common-variables).
Body pulumi.StringPtrInput
// Indicates whether the template is enabled.
Enabled pulumi.BoolPtrInput
// Email address to use as the sender. You can include [common variables](https://auth0.com/docs/customize/email/email-templates#common-variables).
From pulumi.StringPtrInput
// Whether the `resetEmail` and `verifyEmail` templates should include the user's email address as the email parameter in the `returnUrl` (true) or whether no email address should be included in the redirect (false). Defaults to `true`.
IncludeEmailInRedirect pulumi.BoolPtrInput
// URL to redirect the user to after a successful action. [Learn more](https://auth0.com/docs/customize/email/email-templates#configure-template-fields).
ResultUrl pulumi.StringPtrInput
// Subject line of the email. You can include [common variables](https://auth0.com/docs/customize/email/email-templates#common-variables).
Subject pulumi.StringPtrInput
// Syntax of the template body. You can use either text or HTML with Liquid syntax.
Syntax pulumi.StringPtrInput
// Template name. Options include `verifyEmail`, `verifyEmailByCode`, `resetEmail`, `welcomeEmail`, `blockedAccount`, `stolenCredentials`, `enrollmentEmail`, `mfaOobCode`, `userInvitation`, `changePassword` (legacy), or `passwordReset` (legacy).
Template pulumi.StringPtrInput
// Number of seconds during which the link within the email will be valid.
UrlLifetimeInSeconds pulumi.IntPtrInput
}
func (EmailTemplateState) ElementType() reflect.Type {
return reflect.TypeOf((*emailTemplateState)(nil)).Elem()
}
type emailTemplateArgs struct {
// Body of the email template. You can include [common variables](https://auth0.com/docs/customize/email/email-templates#common-variables).
Body string `pulumi:"body"`
// Indicates whether the template is enabled.
Enabled bool `pulumi:"enabled"`
// Email address to use as the sender. You can include [common variables](https://auth0.com/docs/customize/email/email-templates#common-variables).
From string `pulumi:"from"`
// Whether the `resetEmail` and `verifyEmail` templates should include the user's email address as the email parameter in the `returnUrl` (true) or whether no email address should be included in the redirect (false). Defaults to `true`.
IncludeEmailInRedirect *bool `pulumi:"includeEmailInRedirect"`
// URL to redirect the user to after a successful action. [Learn more](https://auth0.com/docs/customize/email/email-templates#configure-template-fields).
ResultUrl *string `pulumi:"resultUrl"`
// Subject line of the email. You can include [common variables](https://auth0.com/docs/customize/email/email-templates#common-variables).
Subject string `pulumi:"subject"`
// Syntax of the template body. You can use either text or HTML with Liquid syntax.
Syntax string `pulumi:"syntax"`
// Template name. Options include `verifyEmail`, `verifyEmailByCode`, `resetEmail`, `welcomeEmail`, `blockedAccount`, `stolenCredentials`, `enrollmentEmail`, `mfaOobCode`, `userInvitation`, `changePassword` (legacy), or `passwordReset` (legacy).
Template string `pulumi:"template"`
// Number of seconds during which the link within the email will be valid.
UrlLifetimeInSeconds *int `pulumi:"urlLifetimeInSeconds"`
}
// The set of arguments for constructing a EmailTemplate resource.
type EmailTemplateArgs struct {
// Body of the email template. You can include [common variables](https://auth0.com/docs/customize/email/email-templates#common-variables).
Body pulumi.StringInput
// Indicates whether the template is enabled.
Enabled pulumi.BoolInput
// Email address to use as the sender. You can include [common variables](https://auth0.com/docs/customize/email/email-templates#common-variables).
From pulumi.StringInput
// Whether the `resetEmail` and `verifyEmail` templates should include the user's email address as the email parameter in the `returnUrl` (true) or whether no email address should be included in the redirect (false). Defaults to `true`.
IncludeEmailInRedirect pulumi.BoolPtrInput
// URL to redirect the user to after a successful action. [Learn more](https://auth0.com/docs/customize/email/email-templates#configure-template-fields).
ResultUrl pulumi.StringPtrInput
// Subject line of the email. You can include [common variables](https://auth0.com/docs/customize/email/email-templates#common-variables).
Subject pulumi.StringInput
// Syntax of the template body. You can use either text or HTML with Liquid syntax.
Syntax pulumi.StringInput
// Template name. Options include `verifyEmail`, `verifyEmailByCode`, `resetEmail`, `welcomeEmail`, `blockedAccount`, `stolenCredentials`, `enrollmentEmail`, `mfaOobCode`, `userInvitation`, `changePassword` (legacy), or `passwordReset` (legacy).
Template pulumi.StringInput
// Number of seconds during which the link within the email will be valid.
UrlLifetimeInSeconds pulumi.IntPtrInput
}
func (EmailTemplateArgs) ElementType() reflect.Type {
return reflect.TypeOf((*emailTemplateArgs)(nil)).Elem()
}
type EmailTemplateInput interface {
pulumi.Input
ToEmailTemplateOutput() EmailTemplateOutput
ToEmailTemplateOutputWithContext(ctx context.Context) EmailTemplateOutput
}
func (*EmailTemplate) ElementType() reflect.Type {
return reflect.TypeOf((**EmailTemplate)(nil)).Elem()
}
func (i *EmailTemplate) ToEmailTemplateOutput() EmailTemplateOutput {
return i.ToEmailTemplateOutputWithContext(context.Background())
}
func (i *EmailTemplate) ToEmailTemplateOutputWithContext(ctx context.Context) EmailTemplateOutput {
return pulumi.ToOutputWithContext(ctx, i).(EmailTemplateOutput)
}
// EmailTemplateArrayInput is an input type that accepts EmailTemplateArray and EmailTemplateArrayOutput values.
// You can construct a concrete instance of `EmailTemplateArrayInput` via:
//
// EmailTemplateArray{ EmailTemplateArgs{...} }
type EmailTemplateArrayInput interface {
pulumi.Input
ToEmailTemplateArrayOutput() EmailTemplateArrayOutput
ToEmailTemplateArrayOutputWithContext(context.Context) EmailTemplateArrayOutput
}
type EmailTemplateArray []EmailTemplateInput
func (EmailTemplateArray) ElementType() reflect.Type {
return reflect.TypeOf((*[]*EmailTemplate)(nil)).Elem()
}
func (i EmailTemplateArray) ToEmailTemplateArrayOutput() EmailTemplateArrayOutput {
return i.ToEmailTemplateArrayOutputWithContext(context.Background())
}
func (i EmailTemplateArray) ToEmailTemplateArrayOutputWithContext(ctx context.Context) EmailTemplateArrayOutput {
return pulumi.ToOutputWithContext(ctx, i).(EmailTemplateArrayOutput)
}
// EmailTemplateMapInput is an input type that accepts EmailTemplateMap and EmailTemplateMapOutput values.
// You can construct a concrete instance of `EmailTemplateMapInput` via:
//
// EmailTemplateMap{ "key": EmailTemplateArgs{...} }
type EmailTemplateMapInput interface {
pulumi.Input
ToEmailTemplateMapOutput() EmailTemplateMapOutput
ToEmailTemplateMapOutputWithContext(context.Context) EmailTemplateMapOutput
}
type EmailTemplateMap map[string]EmailTemplateInput
func (EmailTemplateMap) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*EmailTemplate)(nil)).Elem()
}
func (i EmailTemplateMap) ToEmailTemplateMapOutput() EmailTemplateMapOutput {
return i.ToEmailTemplateMapOutputWithContext(context.Background())
}
func (i EmailTemplateMap) ToEmailTemplateMapOutputWithContext(ctx context.Context) EmailTemplateMapOutput {
return pulumi.ToOutputWithContext(ctx, i).(EmailTemplateMapOutput)
}
type EmailTemplateOutput struct{ *pulumi.OutputState }
func (EmailTemplateOutput) ElementType() reflect.Type {
return reflect.TypeOf((**EmailTemplate)(nil)).Elem()
}
func (o EmailTemplateOutput) ToEmailTemplateOutput() EmailTemplateOutput {
return o
}
func (o EmailTemplateOutput) ToEmailTemplateOutputWithContext(ctx context.Context) EmailTemplateOutput {
return o
}
// Body of the email template. You can include [common variables](https://auth0.com/docs/customize/email/email-templates#common-variables).
func (o EmailTemplateOutput) Body() pulumi.StringOutput {
return o.ApplyT(func(v *EmailTemplate) pulumi.StringOutput { return v.Body }).(pulumi.StringOutput)
}
// Indicates whether the template is enabled.
func (o EmailTemplateOutput) Enabled() pulumi.BoolOutput {
return o.ApplyT(func(v *EmailTemplate) pulumi.BoolOutput { return v.Enabled }).(pulumi.BoolOutput)
}
// Email address to use as the sender. You can include [common variables](https://auth0.com/docs/customize/email/email-templates#common-variables).
func (o EmailTemplateOutput) From() pulumi.StringOutput {
return o.ApplyT(func(v *EmailTemplate) pulumi.StringOutput { return v.From }).(pulumi.StringOutput)
}
// Whether the `resetEmail` and `verifyEmail` templates should include the user's email address as the email parameter in the `returnUrl` (true) or whether no email address should be included in the redirect (false). Defaults to `true`.
func (o EmailTemplateOutput) IncludeEmailInRedirect() pulumi.BoolOutput {
return o.ApplyT(func(v *EmailTemplate) pulumi.BoolOutput { return v.IncludeEmailInRedirect }).(pulumi.BoolOutput)
}
// URL to redirect the user to after a successful action. [Learn more](https://auth0.com/docs/customize/email/email-templates#configure-template-fields).
func (o EmailTemplateOutput) ResultUrl() pulumi.StringPtrOutput {
return o.ApplyT(func(v *EmailTemplate) pulumi.StringPtrOutput { return v.ResultUrl }).(pulumi.StringPtrOutput)
}
// Subject line of the email. You can include [common variables](https://auth0.com/docs/customize/email/email-templates#common-variables).
func (o EmailTemplateOutput) Subject() pulumi.StringOutput {
return o.ApplyT(func(v *EmailTemplate) pulumi.StringOutput { return v.Subject }).(pulumi.StringOutput)
}
// Syntax of the template body. You can use either text or HTML with Liquid syntax.
func (o EmailTemplateOutput) Syntax() pulumi.StringOutput {
return o.ApplyT(func(v *EmailTemplate) pulumi.StringOutput { return v.Syntax }).(pulumi.StringOutput)
}
// Template name. Options include `verifyEmail`, `verifyEmailByCode`, `resetEmail`, `welcomeEmail`, `blockedAccount`, `stolenCredentials`, `enrollmentEmail`, `mfaOobCode`, `userInvitation`, `changePassword` (legacy), or `passwordReset` (legacy).
func (o EmailTemplateOutput) Template() pulumi.StringOutput {
return o.ApplyT(func(v *EmailTemplate) pulumi.StringOutput { return v.Template }).(pulumi.StringOutput)
}
// Number of seconds during which the link within the email will be valid.
func (o EmailTemplateOutput) UrlLifetimeInSeconds() pulumi.IntPtrOutput {
return o.ApplyT(func(v *EmailTemplate) pulumi.IntPtrOutput { return v.UrlLifetimeInSeconds }).(pulumi.IntPtrOutput)
}
type EmailTemplateArrayOutput struct{ *pulumi.OutputState }
func (EmailTemplateArrayOutput) ElementType() reflect.Type {
return reflect.TypeOf((*[]*EmailTemplate)(nil)).Elem()
}
func (o EmailTemplateArrayOutput) ToEmailTemplateArrayOutput() EmailTemplateArrayOutput {
return o
}
func (o EmailTemplateArrayOutput) ToEmailTemplateArrayOutputWithContext(ctx context.Context) EmailTemplateArrayOutput {
return o
}
func (o EmailTemplateArrayOutput) Index(i pulumi.IntInput) EmailTemplateOutput {
return pulumi.All(o, i).ApplyT(func(vs []interface{}) *EmailTemplate {
return vs[0].([]*EmailTemplate)[vs[1].(int)]
}).(EmailTemplateOutput)
}
type EmailTemplateMapOutput struct{ *pulumi.OutputState }
func (EmailTemplateMapOutput) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*EmailTemplate)(nil)).Elem()
}
func (o EmailTemplateMapOutput) ToEmailTemplateMapOutput() EmailTemplateMapOutput {
return o
}
func (o EmailTemplateMapOutput) ToEmailTemplateMapOutputWithContext(ctx context.Context) EmailTemplateMapOutput {
return o
}
func (o EmailTemplateMapOutput) MapIndex(k pulumi.StringInput) EmailTemplateOutput {
return pulumi.All(o, k).ApplyT(func(vs []interface{}) *EmailTemplate {
return vs[0].(map[string]*EmailTemplate)[vs[1].(string)]
}).(EmailTemplateOutput)
}
func init() {
pulumi.RegisterInputType(reflect.TypeOf((*EmailTemplateInput)(nil)).Elem(), &EmailTemplate{})
pulumi.RegisterInputType(reflect.TypeOf((*EmailTemplateArrayInput)(nil)).Elem(), EmailTemplateArray{})
pulumi.RegisterInputType(reflect.TypeOf((*EmailTemplateMapInput)(nil)).Elem(), EmailTemplateMap{})
pulumi.RegisterOutputType(EmailTemplateOutput{})
pulumi.RegisterOutputType(EmailTemplateArrayOutput{})
pulumi.RegisterOutputType(EmailTemplateMapOutput{})
}