diff --git a/.changelog/6616.txt b/.changelog/6616.txt new file mode 100644 index 0000000000..b7c0b7edf2 --- /dev/null +++ b/.changelog/6616.txt @@ -0,0 +1,3 @@ +```release-note:enhancement +datastream: Added field `bigquery_profile` to `google_datastream_connection_profile` +``` diff --git a/google/resource_datastream_connection_profile.go b/google/resource_datastream_connection_profile.go index f388759cc6..8008980686 100644 --- a/google/resource_datastream_connection_profile.go +++ b/google/resource_datastream_connection_profile.go @@ -59,6 +59,16 @@ func resourceDatastreamConnectionProfile() *schema.Resource { ForceNew: true, Description: `The name of the location this repository is located in.`, }, + "bigquery_profile": { + Type: schema.TypeList, + Optional: true, + Description: `BigQuery warehouse profile.`, + MaxItems: 1, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{}, + }, + ExactlyOneOf: []string{"oracle_profile", "gcs_profile", "mysql_profile", "bigquery_profile", "postgresql_profile"}, + }, "forward_ssh_connectivity": { Type: schema.TypeList, Optional: true, @@ -120,7 +130,7 @@ func resourceDatastreamConnectionProfile() *schema.Resource { }, }, }, - ExactlyOneOf: []string{"oracle_profile", "gcs_profile", "mysql_profile", "postgresql_profile"}, + ExactlyOneOf: []string{"oracle_profile", "gcs_profile", "mysql_profile", "bigquery_profile", "postgresql_profile"}, }, "labels": { Type: schema.TypeMap, @@ -212,7 +222,7 @@ If this field is used then the 'client_certificate' and the }, }, }, - ExactlyOneOf: []string{"oracle_profile", "gcs_profile", "mysql_profile", "postgresql_profile"}, + ExactlyOneOf: []string{"oracle_profile", "gcs_profile", "mysql_profile", "bigquery_profile", "postgresql_profile"}, }, "oracle_profile": { Type: schema.TypeList, @@ -256,7 +266,7 @@ If this field is used then the 'client_certificate' and the }, }, }, - ExactlyOneOf: []string{"oracle_profile", "gcs_profile", "mysql_profile", "postgresql_profile"}, + ExactlyOneOf: []string{"oracle_profile", "gcs_profile", "mysql_profile", "bigquery_profile", "postgresql_profile"}, }, "postgresql_profile": { Type: schema.TypeList, @@ -294,7 +304,7 @@ If this field is used then the 'client_certificate' and the }, }, }, - ExactlyOneOf: []string{"oracle_profile", "gcs_profile", "mysql_profile", "postgresql_profile"}, + ExactlyOneOf: []string{"oracle_profile", "gcs_profile", "mysql_profile", "bigquery_profile", "postgresql_profile"}, }, "name": { Type: schema.TypeString, @@ -350,6 +360,12 @@ func resourceDatastreamConnectionProfileCreate(d *schema.ResourceData, meta inte } else if v, ok := d.GetOkExists("mysql_profile"); !isEmptyValue(reflect.ValueOf(mysqlProfileProp)) && (ok || !reflect.DeepEqual(v, mysqlProfileProp)) { obj["mysqlProfile"] = mysqlProfileProp } + bigqueryProfileProp, err := expandDatastreamConnectionProfileBigqueryProfile(d.Get("bigquery_profile"), d, config) + if err != nil { + return err + } else if v, ok := d.GetOkExists("bigquery_profile"); ok || !reflect.DeepEqual(v, bigqueryProfileProp) { + obj["bigqueryProfile"] = bigqueryProfileProp + } postgresqlProfileProp, err := expandDatastreamConnectionProfilePostgresqlProfile(d.Get("postgresql_profile"), d, config) if err != nil { return err @@ -474,6 +490,9 @@ func resourceDatastreamConnectionProfileRead(d *schema.ResourceData, meta interf if err := d.Set("mysql_profile", flattenDatastreamConnectionProfileMysqlProfile(res["mysqlProfile"], d, config)); err != nil { return fmt.Errorf("Error reading ConnectionProfile: %s", err) } + if err := d.Set("bigquery_profile", flattenDatastreamConnectionProfileBigqueryProfile(res["bigqueryProfile"], d, config)); err != nil { + return fmt.Errorf("Error reading ConnectionProfile: %s", err) + } if err := d.Set("postgresql_profile", flattenDatastreamConnectionProfilePostgresqlProfile(res["postgresqlProfile"], d, config)); err != nil { return fmt.Errorf("Error reading ConnectionProfile: %s", err) } @@ -530,6 +549,12 @@ func resourceDatastreamConnectionProfileUpdate(d *schema.ResourceData, meta inte } else if v, ok := d.GetOkExists("mysql_profile"); !isEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, mysqlProfileProp)) { obj["mysqlProfile"] = mysqlProfileProp } + bigqueryProfileProp, err := expandDatastreamConnectionProfileBigqueryProfile(d.Get("bigquery_profile"), d, config) + if err != nil { + return err + } else if v, ok := d.GetOkExists("bigquery_profile"); ok || !reflect.DeepEqual(v, bigqueryProfileProp) { + obj["bigqueryProfile"] = bigqueryProfileProp + } postgresqlProfileProp, err := expandDatastreamConnectionProfilePostgresqlProfile(d.Get("postgresql_profile"), d, config) if err != nil { return err @@ -571,6 +596,10 @@ func resourceDatastreamConnectionProfileUpdate(d *schema.ResourceData, meta inte updateMask = append(updateMask, "mysqlProfile") } + if d.HasChange("bigquery_profile") { + updateMask = append(updateMask, "bigqueryProfile") + } + if d.HasChange("postgresql_profile") { updateMask = append(updateMask, "postgresqlProfile") } @@ -867,6 +896,14 @@ func flattenDatastreamConnectionProfileMysqlProfileSslConfigCaCertificateSet(v i return v } +func flattenDatastreamConnectionProfileBigqueryProfile(v interface{}, d *schema.ResourceData, config *Config) interface{} { + if v == nil { + return nil + } + transformed := make(map[string]interface{}) + return []interface{}{transformed} +} + func flattenDatastreamConnectionProfilePostgresqlProfile(v interface{}, d *schema.ResourceData, config *Config) interface{} { if v == nil { return nil @@ -1250,6 +1287,21 @@ func expandDatastreamConnectionProfileMysqlProfileSslConfigCaCertificateSet(v in return v, nil } +func expandDatastreamConnectionProfileBigqueryProfile(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { + l := v.([]interface{}) + if len(l) == 0 { + return nil, nil + } + + if l[0] == nil { + transformed := make(map[string]interface{}) + return transformed, nil + } + transformed := make(map[string]interface{}) + + return transformed, nil +} + func expandDatastreamConnectionProfilePostgresqlProfile(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) { l := v.([]interface{}) if len(l) == 0 || l[0] == nil { diff --git a/google/resource_datastream_connection_profile_generated_test.go b/google/resource_datastream_connection_profile_generated_test.go index 5c05e443a8..65cf3ae021 100644 --- a/google/resource_datastream_connection_profile_generated_test.go +++ b/google/resource_datastream_connection_profile_generated_test.go @@ -63,6 +63,43 @@ resource "google_datastream_connection_profile" "default" { `, context) } +func TestAccDatastreamConnectionProfile_datastreamConnectionProfileBigqueryExample(t *testing.T) { + t.Parallel() + + context := map[string]interface{}{ + "random_suffix": randString(t, 10), + } + + vcrTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckDatastreamConnectionProfileDestroyProducer(t), + Steps: []resource.TestStep{ + { + Config: testAccDatastreamConnectionProfile_datastreamConnectionProfileBigqueryExample(context), + }, + { + ResourceName: "google_datastream_connection_profile.default", + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"connection_profile_id", "location"}, + }, + }, + }) +} + +func testAccDatastreamConnectionProfile_datastreamConnectionProfileBigqueryExample(context map[string]interface{}) string { + return Nprintf(` +resource "google_datastream_connection_profile" "default" { + display_name = "Connection profile" + location = "us-central1" + connection_profile_id = "tf-test-my-profile%{random_suffix}" + + bigquery_profile {} +} +`, context) +} + func TestAccDatastreamConnectionProfile_datastreamConnectionProfileFullExample(t *testing.T) { t.Parallel() diff --git a/website/docs/r/data_catalog_tag.html.markdown b/website/docs/r/data_catalog_tag.html.markdown index 18f5ea26ed..5c07bce3ca 100644 --- a/website/docs/r/data_catalog_tag.html.markdown +++ b/website/docs/r/data_catalog_tag.html.markdown @@ -379,7 +379,6 @@ The following arguments are supported: * `enum_value` - (Optional) Holds the value for a tag field with enum type. This value must be one of the allowed values in the definition of this enum. - Structure is [documented below](#nested_enum_value). - - - diff --git a/website/docs/r/datastream_connection_profile.html.markdown b/website/docs/r/datastream_connection_profile.html.markdown index 059f9dfcd4..fb0385ec8f 100644 --- a/website/docs/r/datastream_connection_profile.html.markdown +++ b/website/docs/r/datastream_connection_profile.html.markdown @@ -52,6 +52,23 @@ resource "google_datastream_connection_profile" "default" { } } ``` +
+ + Open in Cloud Shell + +
+## Example Usage - Datastream Connection Profile Bigquery + + +```hcl +resource "google_datastream_connection_profile" "default" { + display_name = "Connection profile" + location = "us-central1" + connection_profile_id = "my-profile" + + bigquery_profile {} +} +```
Open in Cloud Shell @@ -188,6 +205,10 @@ The following arguments are supported: MySQL database profile. Structure is [documented below](#nested_mysql_profile). +* `bigquery_profile` - + (Optional) + BigQuery warehouse profile. + * `postgresql_profile` - (Optional) PostgreSQL database profile.