@@ -30,6 +30,7 @@ import (
30
30
31
31
"github.com/hashicorp/terraform-provider-google/google/tpgresource"
32
32
transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport"
33
+ "github.com/hashicorp/terraform-provider-google/google/verify"
33
34
)
34
35
35
36
func ResourceBigtableAppProfile () * schema.Resource {
@@ -108,6 +109,23 @@ It is unsafe to send these requests to the same table/row/column in multiple clu
108
109
},
109
110
ExactlyOneOf : []string {"single_cluster_routing" , "multi_cluster_routing_use_any" },
110
111
},
112
+ "standard_isolation" : {
113
+ Type : schema .TypeList ,
114
+ Computed : true ,
115
+ Optional : true ,
116
+ Description : `The standard options used for isolating this app profile's traffic from other use cases.` ,
117
+ MaxItems : 1 ,
118
+ Elem : & schema.Resource {
119
+ Schema : map [string ]* schema.Schema {
120
+ "priority" : {
121
+ Type : schema .TypeString ,
122
+ Required : true ,
123
+ ValidateFunc : verify .ValidateEnum ([]string {"PRIORITY_LOW" , "PRIORITY_MEDIUM" , "PRIORITY_HIGH" }),
124
+ Description : `The priority of requests sent using this app profile. Possible values: ["PRIORITY_LOW", "PRIORITY_MEDIUM", "PRIORITY_HIGH"]` ,
125
+ },
126
+ },
127
+ },
128
+ },
111
129
"name" : {
112
130
Type : schema .TypeString ,
113
131
Computed : true ,
@@ -159,6 +177,12 @@ func resourceBigtableAppProfileCreate(d *schema.ResourceData, meta interface{})
159
177
} else if v , ok := d .GetOkExists ("single_cluster_routing" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (singleClusterRoutingProp )) && (ok || ! reflect .DeepEqual (v , singleClusterRoutingProp )) {
160
178
obj ["singleClusterRouting" ] = singleClusterRoutingProp
161
179
}
180
+ standardIsolationProp , err := expandBigtableAppProfileStandardIsolation (d .Get ("standard_isolation" ), d , config )
181
+ if err != nil {
182
+ return err
183
+ } else if v , ok := d .GetOkExists ("standard_isolation" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (standardIsolationProp )) && (ok || ! reflect .DeepEqual (v , standardIsolationProp )) {
184
+ obj ["standardIsolation" ] = standardIsolationProp
185
+ }
162
186
163
187
obj , err = resourceBigtableAppProfileEncoder (d , meta , obj )
164
188
if err != nil {
@@ -264,6 +288,9 @@ func resourceBigtableAppProfileRead(d *schema.ResourceData, meta interface{}) er
264
288
if err := d .Set ("single_cluster_routing" , flattenBigtableAppProfileSingleClusterRouting (res ["singleClusterRouting" ], d , config )); err != nil {
265
289
return fmt .Errorf ("Error reading AppProfile: %s" , err )
266
290
}
291
+ if err := d .Set ("standard_isolation" , flattenBigtableAppProfileStandardIsolation (res ["standardIsolation" ], d , config )); err != nil {
292
+ return fmt .Errorf ("Error reading AppProfile: %s" , err )
293
+ }
267
294
268
295
return nil
269
296
}
@@ -302,6 +329,12 @@ func resourceBigtableAppProfileUpdate(d *schema.ResourceData, meta interface{})
302
329
} else if v , ok := d .GetOkExists ("single_cluster_routing" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (v )) && (ok || ! reflect .DeepEqual (v , singleClusterRoutingProp )) {
303
330
obj ["singleClusterRouting" ] = singleClusterRoutingProp
304
331
}
332
+ standardIsolationProp , err := expandBigtableAppProfileStandardIsolation (d .Get ("standard_isolation" ), d , config )
333
+ if err != nil {
334
+ return err
335
+ } else if v , ok := d .GetOkExists ("standard_isolation" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (v )) && (ok || ! reflect .DeepEqual (v , standardIsolationProp )) {
336
+ obj ["standardIsolation" ] = standardIsolationProp
337
+ }
305
338
306
339
obj , err = resourceBigtableAppProfileEncoder (d , meta , obj )
307
340
if err != nil {
@@ -327,6 +360,10 @@ func resourceBigtableAppProfileUpdate(d *schema.ResourceData, meta interface{})
327
360
if d .HasChange ("single_cluster_routing" ) {
328
361
updateMask = append (updateMask , "singleClusterRouting" )
329
362
}
363
+
364
+ if d .HasChange ("standard_isolation" ) {
365
+ updateMask = append (updateMask , "standardIsolation" )
366
+ }
330
367
// updateMask is a URL parameter but not present in the schema, so ReplaceVars
331
368
// won't set it
332
369
url , err = transport_tpg .AddQueryParams (url , map [string ]string {"updateMask" : strings .Join (updateMask , "," )})
@@ -502,6 +539,23 @@ func flattenBigtableAppProfileSingleClusterRoutingAllowTransactionalWrites(v int
502
539
return v
503
540
}
504
541
542
+ func flattenBigtableAppProfileStandardIsolation (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
543
+ if v == nil {
544
+ return nil
545
+ }
546
+ original := v .(map [string ]interface {})
547
+ if len (original ) == 0 {
548
+ return nil
549
+ }
550
+ transformed := make (map [string ]interface {})
551
+ transformed ["priority" ] =
552
+ flattenBigtableAppProfileStandardIsolationPriority (original ["priority" ], d , config )
553
+ return []interface {}{transformed }
554
+ }
555
+ func flattenBigtableAppProfileStandardIsolationPriority (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
556
+ return v
557
+ }
558
+
505
559
func expandBigtableAppProfileDescription (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
506
560
return v , nil
507
561
}
@@ -556,6 +610,29 @@ func expandBigtableAppProfileSingleClusterRoutingAllowTransactionalWrites(v inte
556
610
return v , nil
557
611
}
558
612
613
+ func expandBigtableAppProfileStandardIsolation (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
614
+ l := v .([]interface {})
615
+ if len (l ) == 0 || l [0 ] == nil {
616
+ return nil , nil
617
+ }
618
+ raw := l [0 ]
619
+ original := raw .(map [string ]interface {})
620
+ transformed := make (map [string ]interface {})
621
+
622
+ transformedPriority , err := expandBigtableAppProfileStandardIsolationPriority (original ["priority" ], d , config )
623
+ if err != nil {
624
+ return nil , err
625
+ } else if val := reflect .ValueOf (transformedPriority ); val .IsValid () && ! tpgresource .IsEmptyValue (val ) {
626
+ transformed ["priority" ] = transformedPriority
627
+ }
628
+
629
+ return transformed , nil
630
+ }
631
+
632
+ func expandBigtableAppProfileStandardIsolationPriority (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
633
+ return v , nil
634
+ }
635
+
559
636
func resourceBigtableAppProfileEncoder (d * schema.ResourceData , meta interface {}, obj map [string ]interface {}) (map [string ]interface {}, error ) {
560
637
// Instance is a URL parameter only, so replace self-link/path with resource name only.
561
638
if err := d .Set ("instance" , tpgresource .GetResourceNameFromSelfLink (d .Get ("instance" ).(string ))); err != nil {
0 commit comments