@@ -110,6 +110,7 @@ func resourceDatastreamConnectionProfile() *schema.Resource {
110
110
},
111
111
},
112
112
},
113
+ ConflictsWith : []string {"private_connectivity" },
113
114
},
114
115
"gcs_profile" : {
115
116
Type : schema .TypeList ,
@@ -306,6 +307,22 @@ If this field is used then the 'client_certificate' and the
306
307
},
307
308
ExactlyOneOf : []string {"oracle_profile" , "gcs_profile" , "mysql_profile" , "bigquery_profile" , "postgresql_profile" },
308
309
},
310
+ "private_connectivity" : {
311
+ Type : schema .TypeList ,
312
+ Optional : true ,
313
+ Description : `Private connectivity.` ,
314
+ MaxItems : 1 ,
315
+ Elem : & schema.Resource {
316
+ Schema : map [string ]* schema.Schema {
317
+ "private_connection" : {
318
+ Type : schema .TypeString ,
319
+ Required : true ,
320
+ Description : `A reference to a private connection resource. Format: 'projects/{project}/locations/{location}/privateConnections/{name}'` ,
321
+ },
322
+ },
323
+ },
324
+ ConflictsWith : []string {"forward_ssh_connectivity" },
325
+ },
309
326
"name" : {
310
327
Type : schema .TypeString ,
311
328
Computed : true ,
@@ -378,6 +395,12 @@ func resourceDatastreamConnectionProfileCreate(d *schema.ResourceData, meta inte
378
395
} else if v , ok := d .GetOkExists ("forward_ssh_connectivity" ); ! isEmptyValue (reflect .ValueOf (forwardSshConnectivityProp )) && (ok || ! reflect .DeepEqual (v , forwardSshConnectivityProp )) {
379
396
obj ["forwardSshConnectivity" ] = forwardSshConnectivityProp
380
397
}
398
+ privateConnectivityProp , err := expandDatastreamConnectionProfilePrivateConnectivity (d .Get ("private_connectivity" ), d , config )
399
+ if err != nil {
400
+ return err
401
+ } else if v , ok := d .GetOkExists ("private_connectivity" ); ! isEmptyValue (reflect .ValueOf (privateConnectivityProp )) && (ok || ! reflect .DeepEqual (v , privateConnectivityProp )) {
402
+ obj ["privateConnectivity" ] = privateConnectivityProp
403
+ }
381
404
382
405
url , err := replaceVars (d , config , "{{DatastreamBasePath}}projects/{{project}}/locations/{{location}}/connectionProfiles?connectionProfileId={{connection_profile_id}}" )
383
406
if err != nil {
@@ -500,6 +523,9 @@ func resourceDatastreamConnectionProfileRead(d *schema.ResourceData, meta interf
500
523
if err := d .Set ("forward_ssh_connectivity" , flattenDatastreamConnectionProfileForwardSshConnectivity (res ["forwardSshConnectivity" ], d , config )); err != nil {
501
524
return fmt .Errorf ("Error reading ConnectionProfile: %s" , err )
502
525
}
526
+ if err := d .Set ("private_connectivity" , flattenDatastreamConnectionProfilePrivateConnectivity (res ["privateConnectivity" ], d , config )); err != nil {
527
+ return fmt .Errorf ("Error reading ConnectionProfile: %s" , err )
528
+ }
503
529
504
530
return nil
505
531
}
@@ -568,6 +594,12 @@ func resourceDatastreamConnectionProfileUpdate(d *schema.ResourceData, meta inte
568
594
} else if v , ok := d .GetOkExists ("forward_ssh_connectivity" ); ! isEmptyValue (reflect .ValueOf (v )) && (ok || ! reflect .DeepEqual (v , forwardSshConnectivityProp )) {
569
595
obj ["forwardSshConnectivity" ] = forwardSshConnectivityProp
570
596
}
597
+ privateConnectivityProp , err := expandDatastreamConnectionProfilePrivateConnectivity (d .Get ("private_connectivity" ), d , config )
598
+ if err != nil {
599
+ return err
600
+ } else if v , ok := d .GetOkExists ("private_connectivity" ); ! isEmptyValue (reflect .ValueOf (v )) && (ok || ! reflect .DeepEqual (v , privateConnectivityProp )) {
601
+ obj ["privateConnectivity" ] = privateConnectivityProp
602
+ }
571
603
572
604
url , err := replaceVars (d , config , "{{DatastreamBasePath}}projects/{{project}}/locations/{{location}}/connectionProfiles/{{connection_profile_id}}" )
573
605
if err != nil {
@@ -608,6 +640,10 @@ func resourceDatastreamConnectionProfileUpdate(d *schema.ResourceData, meta inte
608
640
if d .HasChange ("forward_ssh_connectivity" ) {
609
641
updateMask = append (updateMask , "forwardSshConnectivity" )
610
642
}
643
+
644
+ if d .HasChange ("private_connectivity" ) {
645
+ updateMask = append (updateMask , "privateConnectivity" )
646
+ }
611
647
// updateMask is a URL parameter but not present in the schema, so replaceVars
612
648
// won't set it
613
649
url , err = addQueryParams (url , map [string ]string {"updateMask" : strings .Join (updateMask , "," )})
@@ -1013,6 +1049,23 @@ func flattenDatastreamConnectionProfileForwardSshConnectivityPrivateKey(v interf
1013
1049
return d .Get ("forward_ssh_connectivity.0.private_key" )
1014
1050
}
1015
1051
1052
+ func flattenDatastreamConnectionProfilePrivateConnectivity (v interface {}, d * schema.ResourceData , config * Config ) interface {} {
1053
+ if v == nil {
1054
+ return nil
1055
+ }
1056
+ original := v .(map [string ]interface {})
1057
+ if len (original ) == 0 {
1058
+ return nil
1059
+ }
1060
+ transformed := make (map [string ]interface {})
1061
+ transformed ["private_connection" ] =
1062
+ flattenDatastreamConnectionProfilePrivateConnectivityPrivateConnection (original ["privateConnection" ], d , config )
1063
+ return []interface {}{transformed }
1064
+ }
1065
+ func flattenDatastreamConnectionProfilePrivateConnectivityPrivateConnection (v interface {}, d * schema.ResourceData , config * Config ) interface {} {
1066
+ return v
1067
+ }
1068
+
1016
1069
func expandDatastreamConnectionProfileLabels (v interface {}, d TerraformResourceData , config * Config ) (map [string ]string , error ) {
1017
1070
if v == nil {
1018
1071
return map [string ]string {}, nil
@@ -1436,3 +1489,26 @@ func expandDatastreamConnectionProfileForwardSshConnectivityPassword(v interface
1436
1489
func expandDatastreamConnectionProfileForwardSshConnectivityPrivateKey (v interface {}, d TerraformResourceData , config * Config ) (interface {}, error ) {
1437
1490
return v , nil
1438
1491
}
1492
+
1493
+ func expandDatastreamConnectionProfilePrivateConnectivity (v interface {}, d TerraformResourceData , config * Config ) (interface {}, error ) {
1494
+ l := v .([]interface {})
1495
+ if len (l ) == 0 || l [0 ] == nil {
1496
+ return nil , nil
1497
+ }
1498
+ raw := l [0 ]
1499
+ original := raw .(map [string ]interface {})
1500
+ transformed := make (map [string ]interface {})
1501
+
1502
+ transformedPrivateConnection , err := expandDatastreamConnectionProfilePrivateConnectivityPrivateConnection (original ["private_connection" ], d , config )
1503
+ if err != nil {
1504
+ return nil , err
1505
+ } else if val := reflect .ValueOf (transformedPrivateConnection ); val .IsValid () && ! isEmptyValue (val ) {
1506
+ transformed ["privateConnection" ] = transformedPrivateConnection
1507
+ }
1508
+
1509
+ return transformed , nil
1510
+ }
1511
+
1512
+ func expandDatastreamConnectionProfilePrivateConnectivityPrivateConnection (v interface {}, d TerraformResourceData , config * Config ) (interface {}, error ) {
1513
+ return v , nil
1514
+ }
0 commit comments