@@ -80,7 +80,7 @@ func ResourceDatastreamConnectionProfile() *schema.Resource {
80
80
Elem : & schema.Resource {
81
81
Schema : map [string ]* schema.Schema {},
82
82
},
83
- ExactlyOneOf : []string {"oracle_profile" , "gcs_profile" , "mysql_profile" , "bigquery_profile" , "postgresql_profile" },
83
+ ExactlyOneOf : []string {"oracle_profile" , "gcs_profile" , "mysql_profile" , "bigquery_profile" , "postgresql_profile" , "sql_server_profile" },
84
84
},
85
85
"create_without_validation" : {
86
86
Type : schema .TypeBool ,
@@ -151,7 +151,7 @@ func ResourceDatastreamConnectionProfile() *schema.Resource {
151
151
},
152
152
},
153
153
},
154
- ExactlyOneOf : []string {"oracle_profile" , "gcs_profile" , "mysql_profile" , "bigquery_profile" , "postgresql_profile" },
154
+ ExactlyOneOf : []string {"oracle_profile" , "gcs_profile" , "mysql_profile" , "bigquery_profile" , "postgresql_profile" , "sql_server_profile" },
155
155
},
156
156
"labels" : {
157
157
Type : schema .TypeMap ,
@@ -245,7 +245,7 @@ If this field is used then the 'client_certificate' and the
245
245
},
246
246
},
247
247
},
248
- ExactlyOneOf : []string {"oracle_profile" , "gcs_profile" , "mysql_profile" , "bigquery_profile" , "postgresql_profile" },
248
+ ExactlyOneOf : []string {"oracle_profile" , "gcs_profile" , "mysql_profile" , "bigquery_profile" , "postgresql_profile" , "sql_server_profile" },
249
249
},
250
250
"oracle_profile" : {
251
251
Type : schema .TypeList ,
@@ -289,7 +289,7 @@ If this field is used then the 'client_certificate' and the
289
289
},
290
290
},
291
291
},
292
- ExactlyOneOf : []string {"oracle_profile" , "gcs_profile" , "mysql_profile" , "bigquery_profile" , "postgresql_profile" },
292
+ ExactlyOneOf : []string {"oracle_profile" , "gcs_profile" , "mysql_profile" , "bigquery_profile" , "postgresql_profile" , "sql_server_profile" },
293
293
},
294
294
"postgresql_profile" : {
295
295
Type : schema .TypeList ,
@@ -327,7 +327,7 @@ If this field is used then the 'client_certificate' and the
327
327
},
328
328
},
329
329
},
330
- ExactlyOneOf : []string {"oracle_profile" , "gcs_profile" , "mysql_profile" , "bigquery_profile" , "postgresql_profile" },
330
+ ExactlyOneOf : []string {"oracle_profile" , "gcs_profile" , "mysql_profile" , "bigquery_profile" , "postgresql_profile" , "sql_server_profile" },
331
331
},
332
332
"private_connectivity" : {
333
333
Type : schema .TypeList ,
@@ -345,6 +345,44 @@ If this field is used then the 'client_certificate' and the
345
345
},
346
346
ConflictsWith : []string {"forward_ssh_connectivity" },
347
347
},
348
+ "sql_server_profile" : {
349
+ Type : schema .TypeList ,
350
+ Optional : true ,
351
+ Description : `SQL Server database profile.` ,
352
+ MaxItems : 1 ,
353
+ Elem : & schema.Resource {
354
+ Schema : map [string ]* schema.Schema {
355
+ "database" : {
356
+ Type : schema .TypeString ,
357
+ Required : true ,
358
+ Description : `Database for the SQL Server connection.` ,
359
+ },
360
+ "hostname" : {
361
+ Type : schema .TypeString ,
362
+ Required : true ,
363
+ Description : `Hostname for the SQL Server connection.` ,
364
+ },
365
+ "password" : {
366
+ Type : schema .TypeString ,
367
+ Required : true ,
368
+ Description : `Password for the SQL Server connection.` ,
369
+ Sensitive : true ,
370
+ },
371
+ "username" : {
372
+ Type : schema .TypeString ,
373
+ Required : true ,
374
+ Description : `Username for the SQL Server connection.` ,
375
+ },
376
+ "port" : {
377
+ Type : schema .TypeInt ,
378
+ Optional : true ,
379
+ Description : `Port for the SQL Server connection.` ,
380
+ Default : 1433 ,
381
+ },
382
+ },
383
+ },
384
+ ExactlyOneOf : []string {"oracle_profile" , "gcs_profile" , "mysql_profile" , "bigquery_profile" , "postgresql_profile" , "sql_server_profile" },
385
+ },
348
386
"effective_labels" : {
349
387
Type : schema .TypeMap ,
350
388
Computed : true ,
@@ -418,6 +456,12 @@ func resourceDatastreamConnectionProfileCreate(d *schema.ResourceData, meta inte
418
456
} else if v , ok := d .GetOkExists ("postgresql_profile" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (postgresqlProfileProp )) && (ok || ! reflect .DeepEqual (v , postgresqlProfileProp )) {
419
457
obj ["postgresqlProfile" ] = postgresqlProfileProp
420
458
}
459
+ sqlServerProfileProp , err := expandDatastreamConnectionProfileSqlServerProfile (d .Get ("sql_server_profile" ), d , config )
460
+ if err != nil {
461
+ return err
462
+ } else if v , ok := d .GetOkExists ("sql_server_profile" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (sqlServerProfileProp )) && (ok || ! reflect .DeepEqual (v , sqlServerProfileProp )) {
463
+ obj ["sqlServerProfile" ] = sqlServerProfileProp
464
+ }
421
465
forwardSshConnectivityProp , err := expandDatastreamConnectionProfileForwardSshConnectivity (d .Get ("forward_ssh_connectivity" ), d , config )
422
466
if err != nil {
423
467
return err
@@ -573,6 +617,9 @@ func resourceDatastreamConnectionProfileRead(d *schema.ResourceData, meta interf
573
617
if err := d .Set ("postgresql_profile" , flattenDatastreamConnectionProfilePostgresqlProfile (res ["postgresqlProfile" ], d , config )); err != nil {
574
618
return fmt .Errorf ("Error reading ConnectionProfile: %s" , err )
575
619
}
620
+ if err := d .Set ("sql_server_profile" , flattenDatastreamConnectionProfileSqlServerProfile (res ["sqlServerProfile" ], d , config )); err != nil {
621
+ return fmt .Errorf ("Error reading ConnectionProfile: %s" , err )
622
+ }
576
623
if err := d .Set ("forward_ssh_connectivity" , flattenDatastreamConnectionProfileForwardSshConnectivity (res ["forwardSshConnectivity" ], d , config )); err != nil {
577
624
return fmt .Errorf ("Error reading ConnectionProfile: %s" , err )
578
625
}
@@ -641,6 +688,12 @@ func resourceDatastreamConnectionProfileUpdate(d *schema.ResourceData, meta inte
641
688
} else if v , ok := d .GetOkExists ("postgresql_profile" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (v )) && (ok || ! reflect .DeepEqual (v , postgresqlProfileProp )) {
642
689
obj ["postgresqlProfile" ] = postgresqlProfileProp
643
690
}
691
+ sqlServerProfileProp , err := expandDatastreamConnectionProfileSqlServerProfile (d .Get ("sql_server_profile" ), d , config )
692
+ if err != nil {
693
+ return err
694
+ } else if v , ok := d .GetOkExists ("sql_server_profile" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (v )) && (ok || ! reflect .DeepEqual (v , sqlServerProfileProp )) {
695
+ obj ["sqlServerProfile" ] = sqlServerProfileProp
696
+ }
644
697
forwardSshConnectivityProp , err := expandDatastreamConnectionProfileForwardSshConnectivity (d .Get ("forward_ssh_connectivity" ), d , config )
645
698
if err != nil {
646
699
return err
@@ -693,6 +746,10 @@ func resourceDatastreamConnectionProfileUpdate(d *schema.ResourceData, meta inte
693
746
updateMask = append (updateMask , "postgresqlProfile" )
694
747
}
695
748
749
+ if d .HasChange ("sql_server_profile" ) {
750
+ updateMask = append (updateMask , "sqlServerProfile" )
751
+ }
752
+
696
753
if d .HasChange ("forward_ssh_connectivity" ) {
697
754
updateMask = append (updateMask , "forwardSshConnectivity" )
698
755
}
@@ -1089,6 +1146,60 @@ func flattenDatastreamConnectionProfilePostgresqlProfileDatabase(v interface{},
1089
1146
return v
1090
1147
}
1091
1148
1149
+ func flattenDatastreamConnectionProfileSqlServerProfile (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
1150
+ if v == nil {
1151
+ return nil
1152
+ }
1153
+ original := v .(map [string ]interface {})
1154
+ if len (original ) == 0 {
1155
+ return nil
1156
+ }
1157
+ transformed := make (map [string ]interface {})
1158
+ transformed ["hostname" ] =
1159
+ flattenDatastreamConnectionProfileSqlServerProfileHostname (original ["hostname" ], d , config )
1160
+ transformed ["port" ] =
1161
+ flattenDatastreamConnectionProfileSqlServerProfilePort (original ["port" ], d , config )
1162
+ transformed ["username" ] =
1163
+ flattenDatastreamConnectionProfileSqlServerProfileUsername (original ["username" ], d , config )
1164
+ transformed ["password" ] =
1165
+ flattenDatastreamConnectionProfileSqlServerProfilePassword (original ["password" ], d , config )
1166
+ transformed ["database" ] =
1167
+ flattenDatastreamConnectionProfileSqlServerProfileDatabase (original ["database" ], d , config )
1168
+ return []interface {}{transformed }
1169
+ }
1170
+ func flattenDatastreamConnectionProfileSqlServerProfileHostname (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
1171
+ return v
1172
+ }
1173
+
1174
+ func flattenDatastreamConnectionProfileSqlServerProfilePort (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
1175
+ // Handles the string fixed64 format
1176
+ if strVal , ok := v .(string ); ok {
1177
+ if intVal , err := tpgresource .StringToFixed64 (strVal ); err == nil {
1178
+ return intVal
1179
+ }
1180
+ }
1181
+
1182
+ // number values are represented as float64
1183
+ if floatVal , ok := v .(float64 ); ok {
1184
+ intVal := int (floatVal )
1185
+ return intVal
1186
+ }
1187
+
1188
+ return v // let terraform core handle it otherwise
1189
+ }
1190
+
1191
+ func flattenDatastreamConnectionProfileSqlServerProfileUsername (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
1192
+ return v
1193
+ }
1194
+
1195
+ func flattenDatastreamConnectionProfileSqlServerProfilePassword (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
1196
+ return d .Get ("sql_server_profile.0.password" )
1197
+ }
1198
+
1199
+ func flattenDatastreamConnectionProfileSqlServerProfileDatabase (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
1200
+ return v
1201
+ }
1202
+
1092
1203
func flattenDatastreamConnectionProfileForwardSshConnectivity (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
1093
1204
if v == nil {
1094
1205
return nil
@@ -1525,6 +1636,73 @@ func expandDatastreamConnectionProfilePostgresqlProfileDatabase(v interface{}, d
1525
1636
return v , nil
1526
1637
}
1527
1638
1639
+ func expandDatastreamConnectionProfileSqlServerProfile (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
1640
+ l := v .([]interface {})
1641
+ if len (l ) == 0 || l [0 ] == nil {
1642
+ return nil , nil
1643
+ }
1644
+ raw := l [0 ]
1645
+ original := raw .(map [string ]interface {})
1646
+ transformed := make (map [string ]interface {})
1647
+
1648
+ transformedHostname , err := expandDatastreamConnectionProfileSqlServerProfileHostname (original ["hostname" ], d , config )
1649
+ if err != nil {
1650
+ return nil , err
1651
+ } else if val := reflect .ValueOf (transformedHostname ); val .IsValid () && ! tpgresource .IsEmptyValue (val ) {
1652
+ transformed ["hostname" ] = transformedHostname
1653
+ }
1654
+
1655
+ transformedPort , err := expandDatastreamConnectionProfileSqlServerProfilePort (original ["port" ], d , config )
1656
+ if err != nil {
1657
+ return nil , err
1658
+ } else if val := reflect .ValueOf (transformedPort ); val .IsValid () && ! tpgresource .IsEmptyValue (val ) {
1659
+ transformed ["port" ] = transformedPort
1660
+ }
1661
+
1662
+ transformedUsername , err := expandDatastreamConnectionProfileSqlServerProfileUsername (original ["username" ], d , config )
1663
+ if err != nil {
1664
+ return nil , err
1665
+ } else if val := reflect .ValueOf (transformedUsername ); val .IsValid () && ! tpgresource .IsEmptyValue (val ) {
1666
+ transformed ["username" ] = transformedUsername
1667
+ }
1668
+
1669
+ transformedPassword , err := expandDatastreamConnectionProfileSqlServerProfilePassword (original ["password" ], d , config )
1670
+ if err != nil {
1671
+ return nil , err
1672
+ } else if val := reflect .ValueOf (transformedPassword ); val .IsValid () && ! tpgresource .IsEmptyValue (val ) {
1673
+ transformed ["password" ] = transformedPassword
1674
+ }
1675
+
1676
+ transformedDatabase , err := expandDatastreamConnectionProfileSqlServerProfileDatabase (original ["database" ], d , config )
1677
+ if err != nil {
1678
+ return nil , err
1679
+ } else if val := reflect .ValueOf (transformedDatabase ); val .IsValid () && ! tpgresource .IsEmptyValue (val ) {
1680
+ transformed ["database" ] = transformedDatabase
1681
+ }
1682
+
1683
+ return transformed , nil
1684
+ }
1685
+
1686
+ func expandDatastreamConnectionProfileSqlServerProfileHostname (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
1687
+ return v , nil
1688
+ }
1689
+
1690
+ func expandDatastreamConnectionProfileSqlServerProfilePort (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
1691
+ return v , nil
1692
+ }
1693
+
1694
+ func expandDatastreamConnectionProfileSqlServerProfileUsername (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
1695
+ return v , nil
1696
+ }
1697
+
1698
+ func expandDatastreamConnectionProfileSqlServerProfilePassword (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
1699
+ return v , nil
1700
+ }
1701
+
1702
+ func expandDatastreamConnectionProfileSqlServerProfileDatabase (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
1703
+ return v , nil
1704
+ }
1705
+
1528
1706
func expandDatastreamConnectionProfileForwardSshConnectivity (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
1529
1707
l := v .([]interface {})
1530
1708
if len (l ) == 0 || l [0 ] == nil {
0 commit comments