-
Notifications
You must be signed in to change notification settings - Fork 7
/
userRoles.go
332 lines (278 loc) · 9.85 KB
/
userRoles.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
// 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/v2/go/auth0/internal"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
"github.com/pulumi/pulumi/sdk/v3/go/pulumix"
)
// With this resource, you can manage assigned roles for a user.
//
// !> This resource manages all the roles assigned to a user. In contrast, the `UserRole` resource only appends a
// role to a user. To avoid potential issues, it is recommended not to use this resource in conjunction with the
// `UserRole` resource when managing roles for the same user id.
//
// ## Example Usage
//
// ```go
// package main
//
// import (
//
// "github.com/pulumi/pulumi-auth0/sdk/v2/go/auth0"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
//
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// admin, err := auth0.NewRole(ctx, "admin", &auth0.RoleArgs{
// Description: pulumi.String("Administrator"),
// })
// if err != nil {
// return err
// }
// user, err := auth0.NewUser(ctx, "user", &auth0.UserArgs{
// ConnectionName: pulumi.String("Username-Password-Authentication"),
// Username: pulumi.String("unique_username"),
// Email: pulumi.String("test@test.com"),
// Password: pulumi.String("passpass$12$12"),
// })
// if err != nil {
// return err
// }
// _, err = auth0.NewUserRoles(ctx, "userRoles", &auth0.UserRolesArgs{
// UserId: user.ID(),
// Roles: pulumi.StringArray{
// admin.ID(),
// },
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
//
// ```
//
// ## Import
//
// This resource can be imported using the user ID. # Example
//
// ```sh
//
// $ pulumi import auth0:index/userRoles:UserRoles user_roles "auth0|111111111111111111111111"
//
// ```
type UserRoles struct {
pulumi.CustomResourceState
// Set of IDs of roles assigned to the user.
Roles pulumi.StringArrayOutput `pulumi:"roles"`
// ID of the user.
UserId pulumi.StringOutput `pulumi:"userId"`
}
// NewUserRoles registers a new resource with the given unique name, arguments, and options.
func NewUserRoles(ctx *pulumi.Context,
name string, args *UserRolesArgs, opts ...pulumi.ResourceOption) (*UserRoles, error) {
if args == nil {
return nil, errors.New("missing one or more required arguments")
}
if args.Roles == nil {
return nil, errors.New("invalid value for required argument 'Roles'")
}
if args.UserId == nil {
return nil, errors.New("invalid value for required argument 'UserId'")
}
opts = internal.PkgResourceDefaultOpts(opts)
var resource UserRoles
err := ctx.RegisterResource("auth0:index/userRoles:UserRoles", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// GetUserRoles gets an existing UserRoles 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 GetUserRoles(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *UserRolesState, opts ...pulumi.ResourceOption) (*UserRoles, error) {
var resource UserRoles
err := ctx.ReadResource("auth0:index/userRoles:UserRoles", name, id, state, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// Input properties used for looking up and filtering UserRoles resources.
type userRolesState struct {
// Set of IDs of roles assigned to the user.
Roles []string `pulumi:"roles"`
// ID of the user.
UserId *string `pulumi:"userId"`
}
type UserRolesState struct {
// Set of IDs of roles assigned to the user.
Roles pulumi.StringArrayInput
// ID of the user.
UserId pulumi.StringPtrInput
}
func (UserRolesState) ElementType() reflect.Type {
return reflect.TypeOf((*userRolesState)(nil)).Elem()
}
type userRolesArgs struct {
// Set of IDs of roles assigned to the user.
Roles []string `pulumi:"roles"`
// ID of the user.
UserId string `pulumi:"userId"`
}
// The set of arguments for constructing a UserRoles resource.
type UserRolesArgs struct {
// Set of IDs of roles assigned to the user.
Roles pulumi.StringArrayInput
// ID of the user.
UserId pulumi.StringInput
}
func (UserRolesArgs) ElementType() reflect.Type {
return reflect.TypeOf((*userRolesArgs)(nil)).Elem()
}
type UserRolesInput interface {
pulumi.Input
ToUserRolesOutput() UserRolesOutput
ToUserRolesOutputWithContext(ctx context.Context) UserRolesOutput
}
func (*UserRoles) ElementType() reflect.Type {
return reflect.TypeOf((**UserRoles)(nil)).Elem()
}
func (i *UserRoles) ToUserRolesOutput() UserRolesOutput {
return i.ToUserRolesOutputWithContext(context.Background())
}
func (i *UserRoles) ToUserRolesOutputWithContext(ctx context.Context) UserRolesOutput {
return pulumi.ToOutputWithContext(ctx, i).(UserRolesOutput)
}
func (i *UserRoles) ToOutput(ctx context.Context) pulumix.Output[*UserRoles] {
return pulumix.Output[*UserRoles]{
OutputState: i.ToUserRolesOutputWithContext(ctx).OutputState,
}
}
// UserRolesArrayInput is an input type that accepts UserRolesArray and UserRolesArrayOutput values.
// You can construct a concrete instance of `UserRolesArrayInput` via:
//
// UserRolesArray{ UserRolesArgs{...} }
type UserRolesArrayInput interface {
pulumi.Input
ToUserRolesArrayOutput() UserRolesArrayOutput
ToUserRolesArrayOutputWithContext(context.Context) UserRolesArrayOutput
}
type UserRolesArray []UserRolesInput
func (UserRolesArray) ElementType() reflect.Type {
return reflect.TypeOf((*[]*UserRoles)(nil)).Elem()
}
func (i UserRolesArray) ToUserRolesArrayOutput() UserRolesArrayOutput {
return i.ToUserRolesArrayOutputWithContext(context.Background())
}
func (i UserRolesArray) ToUserRolesArrayOutputWithContext(ctx context.Context) UserRolesArrayOutput {
return pulumi.ToOutputWithContext(ctx, i).(UserRolesArrayOutput)
}
func (i UserRolesArray) ToOutput(ctx context.Context) pulumix.Output[[]*UserRoles] {
return pulumix.Output[[]*UserRoles]{
OutputState: i.ToUserRolesArrayOutputWithContext(ctx).OutputState,
}
}
// UserRolesMapInput is an input type that accepts UserRolesMap and UserRolesMapOutput values.
// You can construct a concrete instance of `UserRolesMapInput` via:
//
// UserRolesMap{ "key": UserRolesArgs{...} }
type UserRolesMapInput interface {
pulumi.Input
ToUserRolesMapOutput() UserRolesMapOutput
ToUserRolesMapOutputWithContext(context.Context) UserRolesMapOutput
}
type UserRolesMap map[string]UserRolesInput
func (UserRolesMap) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*UserRoles)(nil)).Elem()
}
func (i UserRolesMap) ToUserRolesMapOutput() UserRolesMapOutput {
return i.ToUserRolesMapOutputWithContext(context.Background())
}
func (i UserRolesMap) ToUserRolesMapOutputWithContext(ctx context.Context) UserRolesMapOutput {
return pulumi.ToOutputWithContext(ctx, i).(UserRolesMapOutput)
}
func (i UserRolesMap) ToOutput(ctx context.Context) pulumix.Output[map[string]*UserRoles] {
return pulumix.Output[map[string]*UserRoles]{
OutputState: i.ToUserRolesMapOutputWithContext(ctx).OutputState,
}
}
type UserRolesOutput struct{ *pulumi.OutputState }
func (UserRolesOutput) ElementType() reflect.Type {
return reflect.TypeOf((**UserRoles)(nil)).Elem()
}
func (o UserRolesOutput) ToUserRolesOutput() UserRolesOutput {
return o
}
func (o UserRolesOutput) ToUserRolesOutputWithContext(ctx context.Context) UserRolesOutput {
return o
}
func (o UserRolesOutput) ToOutput(ctx context.Context) pulumix.Output[*UserRoles] {
return pulumix.Output[*UserRoles]{
OutputState: o.OutputState,
}
}
// Set of IDs of roles assigned to the user.
func (o UserRolesOutput) Roles() pulumi.StringArrayOutput {
return o.ApplyT(func(v *UserRoles) pulumi.StringArrayOutput { return v.Roles }).(pulumi.StringArrayOutput)
}
// ID of the user.
func (o UserRolesOutput) UserId() pulumi.StringOutput {
return o.ApplyT(func(v *UserRoles) pulumi.StringOutput { return v.UserId }).(pulumi.StringOutput)
}
type UserRolesArrayOutput struct{ *pulumi.OutputState }
func (UserRolesArrayOutput) ElementType() reflect.Type {
return reflect.TypeOf((*[]*UserRoles)(nil)).Elem()
}
func (o UserRolesArrayOutput) ToUserRolesArrayOutput() UserRolesArrayOutput {
return o
}
func (o UserRolesArrayOutput) ToUserRolesArrayOutputWithContext(ctx context.Context) UserRolesArrayOutput {
return o
}
func (o UserRolesArrayOutput) ToOutput(ctx context.Context) pulumix.Output[[]*UserRoles] {
return pulumix.Output[[]*UserRoles]{
OutputState: o.OutputState,
}
}
func (o UserRolesArrayOutput) Index(i pulumi.IntInput) UserRolesOutput {
return pulumi.All(o, i).ApplyT(func(vs []interface{}) *UserRoles {
return vs[0].([]*UserRoles)[vs[1].(int)]
}).(UserRolesOutput)
}
type UserRolesMapOutput struct{ *pulumi.OutputState }
func (UserRolesMapOutput) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*UserRoles)(nil)).Elem()
}
func (o UserRolesMapOutput) ToUserRolesMapOutput() UserRolesMapOutput {
return o
}
func (o UserRolesMapOutput) ToUserRolesMapOutputWithContext(ctx context.Context) UserRolesMapOutput {
return o
}
func (o UserRolesMapOutput) ToOutput(ctx context.Context) pulumix.Output[map[string]*UserRoles] {
return pulumix.Output[map[string]*UserRoles]{
OutputState: o.OutputState,
}
}
func (o UserRolesMapOutput) MapIndex(k pulumi.StringInput) UserRolesOutput {
return pulumi.All(o, k).ApplyT(func(vs []interface{}) *UserRoles {
return vs[0].(map[string]*UserRoles)[vs[1].(string)]
}).(UserRolesOutput)
}
func init() {
pulumi.RegisterInputType(reflect.TypeOf((*UserRolesInput)(nil)).Elem(), &UserRoles{})
pulumi.RegisterInputType(reflect.TypeOf((*UserRolesArrayInput)(nil)).Elem(), UserRolesArray{})
pulumi.RegisterInputType(reflect.TypeOf((*UserRolesMapInput)(nil)).Elem(), UserRolesMap{})
pulumi.RegisterOutputType(UserRolesOutput{})
pulumi.RegisterOutputType(UserRolesArrayOutput{})
pulumi.RegisterOutputType(UserRolesMapOutput{})
}