@@ -66,6 +66,36 @@ func ResourceIdentityPlatformTenant() *schema.Resource {
66
66
Optional : true ,
67
67
Description : `Whether to allow email/password user authentication.` ,
68
68
},
69
+ "client" : {
70
+ Type : schema .TypeList ,
71
+ Optional : true ,
72
+ Description : `Options related to how clients making requests on behalf of a tenant should be configured.` ,
73
+ MaxItems : 1 ,
74
+ Elem : & schema.Resource {
75
+ Schema : map [string ]* schema.Schema {
76
+ "permissions" : {
77
+ Type : schema .TypeList ,
78
+ Optional : true ,
79
+ Description : `Configuration related to restricting a user's ability to affect their account.` ,
80
+ MaxItems : 1 ,
81
+ Elem : & schema.Resource {
82
+ Schema : map [string ]* schema.Schema {
83
+ "disabled_user_deletion" : {
84
+ Type : schema .TypeBool ,
85
+ Optional : true ,
86
+ Description : `When true, end users cannot delete their account on the associated project through any of our API methods.` ,
87
+ },
88
+ "disabled_user_signup" : {
89
+ Type : schema .TypeBool ,
90
+ Optional : true ,
91
+ Description : `When true, end users cannot sign up for a new account on the associated project through any of our API methods.` ,
92
+ },
93
+ },
94
+ },
95
+ },
96
+ },
97
+ },
98
+ },
69
99
"disable_auth" : {
70
100
Type : schema .TypeBool ,
71
101
Optional : true ,
@@ -126,6 +156,12 @@ func resourceIdentityPlatformTenantCreate(d *schema.ResourceData, meta interface
126
156
} else if v , ok := d .GetOkExists ("disable_auth" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (disableAuthProp )) && (ok || ! reflect .DeepEqual (v , disableAuthProp )) {
127
157
obj ["disableAuth" ] = disableAuthProp
128
158
}
159
+ clientProp , err := expandIdentityPlatformTenantClient (d .Get ("client" ), d , config )
160
+ if err != nil {
161
+ return err
162
+ } else if v , ok := d .GetOkExists ("client" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (clientProp )) && (ok || ! reflect .DeepEqual (v , clientProp )) {
163
+ obj ["client" ] = clientProp
164
+ }
129
165
130
166
url , err := tpgresource .ReplaceVars (d , config , "{{IdentityPlatformBasePath}}projects/{{project}}/tenants" )
131
167
if err != nil {
@@ -248,6 +284,9 @@ func resourceIdentityPlatformTenantRead(d *schema.ResourceData, meta interface{}
248
284
if err := d .Set ("disable_auth" , flattenIdentityPlatformTenantDisableAuth (res ["disableAuth" ], d , config )); err != nil {
249
285
return fmt .Errorf ("Error reading Tenant: %s" , err )
250
286
}
287
+ if err := d .Set ("client" , flattenIdentityPlatformTenantClient (res ["client" ], d , config )); err != nil {
288
+ return fmt .Errorf ("Error reading Tenant: %s" , err )
289
+ }
251
290
252
291
return nil
253
292
}
@@ -292,6 +331,12 @@ func resourceIdentityPlatformTenantUpdate(d *schema.ResourceData, meta interface
292
331
} else if v , ok := d .GetOkExists ("disable_auth" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (v )) && (ok || ! reflect .DeepEqual (v , disableAuthProp )) {
293
332
obj ["disableAuth" ] = disableAuthProp
294
333
}
334
+ clientProp , err := expandIdentityPlatformTenantClient (d .Get ("client" ), d , config )
335
+ if err != nil {
336
+ return err
337
+ } else if v , ok := d .GetOkExists ("client" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (v )) && (ok || ! reflect .DeepEqual (v , clientProp )) {
338
+ obj ["client" ] = clientProp
339
+ }
295
340
296
341
url , err := tpgresource .ReplaceVars (d , config , "{{IdentityPlatformBasePath}}projects/{{project}}/tenants/{{name}}" )
297
342
if err != nil {
@@ -317,6 +362,10 @@ func resourceIdentityPlatformTenantUpdate(d *schema.ResourceData, meta interface
317
362
if d .HasChange ("disable_auth" ) {
318
363
updateMask = append (updateMask , "disableAuth" )
319
364
}
365
+
366
+ if d .HasChange ("client" ) {
367
+ updateMask = append (updateMask , "client" )
368
+ }
320
369
// updateMask is a URL parameter but not present in the schema, so ReplaceVars
321
370
// won't set it
322
371
url , err = transport_tpg .AddQueryParams (url , map [string ]string {"updateMask" : strings .Join (updateMask , "," )})
@@ -444,6 +493,42 @@ func flattenIdentityPlatformTenantDisableAuth(v interface{}, d *schema.ResourceD
444
493
return v
445
494
}
446
495
496
+ func flattenIdentityPlatformTenantClient (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
497
+ if v == nil {
498
+ return nil
499
+ }
500
+ original := v .(map [string ]interface {})
501
+ if len (original ) == 0 {
502
+ return nil
503
+ }
504
+ transformed := make (map [string ]interface {})
505
+ transformed ["permissions" ] =
506
+ flattenIdentityPlatformTenantClientPermissions (original ["permissions" ], d , config )
507
+ return []interface {}{transformed }
508
+ }
509
+ func flattenIdentityPlatformTenantClientPermissions (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
510
+ if v == nil {
511
+ return nil
512
+ }
513
+ original := v .(map [string ]interface {})
514
+ if len (original ) == 0 {
515
+ return nil
516
+ }
517
+ transformed := make (map [string ]interface {})
518
+ transformed ["disabled_user_signup" ] =
519
+ flattenIdentityPlatformTenantClientPermissionsDisabledUserSignup (original ["disabledUserSignup" ], d , config )
520
+ transformed ["disabled_user_deletion" ] =
521
+ flattenIdentityPlatformTenantClientPermissionsDisabledUserDeletion (original ["disabledUserDeletion" ], d , config )
522
+ return []interface {}{transformed }
523
+ }
524
+ func flattenIdentityPlatformTenantClientPermissionsDisabledUserSignup (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
525
+ return v
526
+ }
527
+
528
+ func flattenIdentityPlatformTenantClientPermissionsDisabledUserDeletion (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
529
+ return v
530
+ }
531
+
447
532
func expandIdentityPlatformTenantDisplayName (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
448
533
return v , nil
449
534
}
@@ -459,3 +544,56 @@ func expandIdentityPlatformTenantEnableEmailLinkSignin(v interface{}, d tpgresou
459
544
func expandIdentityPlatformTenantDisableAuth (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
460
545
return v , nil
461
546
}
547
+
548
+ func expandIdentityPlatformTenantClient (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
549
+ l := v .([]interface {})
550
+ if len (l ) == 0 || l [0 ] == nil {
551
+ return nil , nil
552
+ }
553
+ raw := l [0 ]
554
+ original := raw .(map [string ]interface {})
555
+ transformed := make (map [string ]interface {})
556
+
557
+ transformedPermissions , err := expandIdentityPlatformTenantClientPermissions (original ["permissions" ], d , config )
558
+ if err != nil {
559
+ return nil , err
560
+ } else if val := reflect .ValueOf (transformedPermissions ); val .IsValid () && ! tpgresource .IsEmptyValue (val ) {
561
+ transformed ["permissions" ] = transformedPermissions
562
+ }
563
+
564
+ return transformed , nil
565
+ }
566
+
567
+ func expandIdentityPlatformTenantClientPermissions (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
568
+ l := v .([]interface {})
569
+ if len (l ) == 0 || l [0 ] == nil {
570
+ return nil , nil
571
+ }
572
+ raw := l [0 ]
573
+ original := raw .(map [string ]interface {})
574
+ transformed := make (map [string ]interface {})
575
+
576
+ transformedDisabledUserSignup , err := expandIdentityPlatformTenantClientPermissionsDisabledUserSignup (original ["disabled_user_signup" ], d , config )
577
+ if err != nil {
578
+ return nil , err
579
+ } else if val := reflect .ValueOf (transformedDisabledUserSignup ); val .IsValid () && ! tpgresource .IsEmptyValue (val ) {
580
+ transformed ["disabledUserSignup" ] = transformedDisabledUserSignup
581
+ }
582
+
583
+ transformedDisabledUserDeletion , err := expandIdentityPlatformTenantClientPermissionsDisabledUserDeletion (original ["disabled_user_deletion" ], d , config )
584
+ if err != nil {
585
+ return nil , err
586
+ } else if val := reflect .ValueOf (transformedDisabledUserDeletion ); val .IsValid () && ! tpgresource .IsEmptyValue (val ) {
587
+ transformed ["disabledUserDeletion" ] = transformedDisabledUserDeletion
588
+ }
589
+
590
+ return transformed , nil
591
+ }
592
+
593
+ func expandIdentityPlatformTenantClientPermissionsDisabledUserSignup (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
594
+ return v , nil
595
+ }
596
+
597
+ func expandIdentityPlatformTenantClientPermissionsDisabledUserDeletion (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
598
+ return v , nil
599
+ }
0 commit comments