@@ -376,6 +376,13 @@ account and all subaccounts, if they exist.
376
376
Optional : true ,
377
377
Description : `User data for display name in UI. Must be <= 60 chars.` ,
378
378
},
379
+ "ownership_scope" : {
380
+ Type : schema .TypeString ,
381
+ Optional : true ,
382
+ ValidateFunc : verify .ValidateEnum ([]string {"OWNERSHIP_SCOPE_UNSPECIFIED" , "ALL_USERS" , "BILLING_ACCOUNT" , "" }),
383
+ Description : `The ownership scope of the budget. The ownership scope and users'
384
+ IAM permissions determine who has full access to the budget's data. Possible values: ["OWNERSHIP_SCOPE_UNSPECIFIED", "ALL_USERS", "BILLING_ACCOUNT"]` ,
385
+ },
379
386
"threshold_rules" : {
380
387
Type : schema .TypeList ,
381
388
Optional : true ,
@@ -451,6 +458,12 @@ func resourceBillingBudgetCreate(d *schema.ResourceData, meta interface{}) error
451
458
} else if v , ok := d .GetOkExists ("all_updates_rule" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (notificationsRuleProp )) && (ok || ! reflect .DeepEqual (v , notificationsRuleProp )) {
452
459
obj ["notificationsRule" ] = notificationsRuleProp
453
460
}
461
+ ownershipScopeProp , err := expandBillingBudgetOwnershipScope (d .Get ("ownership_scope" ), d , config )
462
+ if err != nil {
463
+ return err
464
+ } else if v , ok := d .GetOkExists ("ownership_scope" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (ownershipScopeProp )) && (ok || ! reflect .DeepEqual (v , ownershipScopeProp )) {
465
+ obj ["ownershipScope" ] = ownershipScopeProp
466
+ }
454
467
455
468
url , err := tpgresource .ReplaceVars (d , config , "{{BillingBasePath}}billingAccounts/{{billing_account}}/budgets" )
456
469
if err != nil {
@@ -545,6 +558,9 @@ func resourceBillingBudgetRead(d *schema.ResourceData, meta interface{}) error {
545
558
if err := d .Set ("all_updates_rule" , flattenBillingBudgetAllUpdatesRule (res ["notificationsRule" ], d , config )); err != nil {
546
559
return fmt .Errorf ("Error reading Budget: %s" , err )
547
560
}
561
+ if err := d .Set ("ownership_scope" , flattenBillingBudgetOwnershipScope (res ["ownershipScope" ], d , config )); err != nil {
562
+ return fmt .Errorf ("Error reading Budget: %s" , err )
563
+ }
548
564
549
565
return nil
550
566
}
@@ -589,6 +605,12 @@ func resourceBillingBudgetUpdate(d *schema.ResourceData, meta interface{}) error
589
605
} else if v , ok := d .GetOkExists ("all_updates_rule" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (v )) && (ok || ! reflect .DeepEqual (v , notificationsRuleProp )) {
590
606
obj ["notificationsRule" ] = notificationsRuleProp
591
607
}
608
+ ownershipScopeProp , err := expandBillingBudgetOwnershipScope (d .Get ("ownership_scope" ), d , config )
609
+ if err != nil {
610
+ return err
611
+ } else if v , ok := d .GetOkExists ("ownership_scope" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (v )) && (ok || ! reflect .DeepEqual (v , ownershipScopeProp )) {
612
+ obj ["ownershipScope" ] = ownershipScopeProp
613
+ }
592
614
593
615
url , err := tpgresource .ReplaceVars (d , config , "{{BillingBasePath}}billingAccounts/{{billing_account}}/budgets/{{name}}" )
594
616
if err != nil {
@@ -631,6 +653,10 @@ func resourceBillingBudgetUpdate(d *schema.ResourceData, meta interface{}) error
631
653
"notificationsRule.monitoringNotificationChannels" ,
632
654
"notificationsRule.disableDefaultIamRecipients" )
633
655
}
656
+
657
+ if d .HasChange ("ownership_scope" ) {
658
+ updateMask = append (updateMask , "ownershipScope" )
659
+ }
634
660
// updateMask is a URL parameter but not present in the schema, so ReplaceVars
635
661
// won't set it
636
662
url , err = transport_tpg .AddQueryParams (url , map [string ]string {"updateMask" : strings .Join (updateMask , "," )})
@@ -1106,6 +1132,10 @@ func flattenBillingBudgetAllUpdatesRuleDisableDefaultIamRecipients(v interface{}
1106
1132
return v
1107
1133
}
1108
1134
1135
+ func flattenBillingBudgetOwnershipScope (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
1136
+ return v
1137
+ }
1138
+
1109
1139
func expandBillingBudgetDisplayName (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
1110
1140
return v , nil
1111
1141
}
@@ -1514,6 +1544,10 @@ func expandBillingBudgetAllUpdatesRuleDisableDefaultIamRecipients(v interface{},
1514
1544
return v , nil
1515
1545
}
1516
1546
1547
+ func expandBillingBudgetOwnershipScope (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
1548
+ return v , nil
1549
+ }
1550
+
1517
1551
func resourceBillingBudgetResourceV0 () * schema.Resource {
1518
1552
return & schema.Resource {
1519
1553
Schema : map [string ]* schema.Schema {
0 commit comments