Skip to content

Commit 45220a8

Browse files
Adding support for missing AH fields (#14637) (#23801)
[upstream:66fb3ef41c92725f631b56116f94d32158f33c93] Signed-off-by: Modular Magician <[email protected]>
1 parent 784d51d commit 45220a8

11 files changed

+420
-1
lines changed

.changelog/14637.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
```release-note:enhancement
2+
bigqueryanalyticshub: added `discovery_type` field to `google_bigquery_analytics_hub_data_exchange` resource
3+
```
4+
5+
```release-note:enhancement
6+
bigqueryanalyticshub: added `state`, `discovery_type`, and `allow_only_metadata_sharing` fields to `google_bigquery_analytics_hub_listing` resource
7+
```

google/services/bigqueryanalyticshub/resource_bigquery_analytics_hub_data_exchange.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import (
3232

3333
"github.com/hashicorp/terraform-provider-google/google/tpgresource"
3434
transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport"
35+
"github.com/hashicorp/terraform-provider-google/google/verify"
3536
)
3637

3738
func ResourceBigqueryAnalyticsHubDataExchange() *schema.Resource {
@@ -78,6 +79,13 @@ func ResourceBigqueryAnalyticsHubDataExchange() *schema.Resource {
7879
Optional: true,
7980
Description: `Description of the data exchange.`,
8081
},
82+
"discovery_type": {
83+
Type: schema.TypeString,
84+
Computed: true,
85+
Optional: true,
86+
ValidateFunc: verify.ValidateEnum([]string{"DISCOVERY_TYPE_PRIVATE", "DISCOVERY_TYPE_PUBLIC", ""}),
87+
Description: `Type of discovery on the discovery page for all the listings under this exchange. Cannot be set for a Data Clean Room. Updating this field also updates (overwrites) the discoveryType field for all the listings under this exchange. Possible values: ["DISCOVERY_TYPE_PRIVATE", "DISCOVERY_TYPE_PUBLIC"]`,
88+
},
8189
"documentation": {
8290
Type: schema.TypeString,
8391
Optional: true,
@@ -199,6 +207,12 @@ func resourceBigqueryAnalyticsHubDataExchangeCreate(d *schema.ResourceData, meta
199207
} else if v, ok := d.GetOkExists("sharing_environment_config"); !tpgresource.IsEmptyValue(reflect.ValueOf(sharingEnvironmentConfigProp)) && (ok || !reflect.DeepEqual(v, sharingEnvironmentConfigProp)) {
200208
obj["sharingEnvironmentConfig"] = sharingEnvironmentConfigProp
201209
}
210+
discoveryTypeProp, err := expandBigqueryAnalyticsHubDataExchangeDiscoveryType(d.Get("discovery_type"), d, config)
211+
if err != nil {
212+
return err
213+
} else if v, ok := d.GetOkExists("discovery_type"); !tpgresource.IsEmptyValue(reflect.ValueOf(discoveryTypeProp)) && (ok || !reflect.DeepEqual(v, discoveryTypeProp)) {
214+
obj["discoveryType"] = discoveryTypeProp
215+
}
202216
logLinkedDatasetQueryUserEmailProp, err := expandBigqueryAnalyticsHubDataExchangeLogLinkedDatasetQueryUserEmail(d.Get("log_linked_dataset_query_user_email"), d, config)
203217
if err != nil {
204218
return err
@@ -318,6 +332,9 @@ func resourceBigqueryAnalyticsHubDataExchangeRead(d *schema.ResourceData, meta i
318332
if err := d.Set("sharing_environment_config", flattenBigqueryAnalyticsHubDataExchangeSharingEnvironmentConfig(res["sharingEnvironmentConfig"], d, config)); err != nil {
319333
return fmt.Errorf("Error reading DataExchange: %s", err)
320334
}
335+
if err := d.Set("discovery_type", flattenBigqueryAnalyticsHubDataExchangeDiscoveryType(res["discoveryType"], d, config)); err != nil {
336+
return fmt.Errorf("Error reading DataExchange: %s", err)
337+
}
321338
if err := d.Set("log_linked_dataset_query_user_email", flattenBigqueryAnalyticsHubDataExchangeLogLinkedDatasetQueryUserEmail(res["logLinkedDatasetQueryUserEmail"], d, config)); err != nil {
322339
return fmt.Errorf("Error reading DataExchange: %s", err)
323340
}
@@ -371,6 +388,12 @@ func resourceBigqueryAnalyticsHubDataExchangeUpdate(d *schema.ResourceData, meta
371388
} else if v, ok := d.GetOkExists("icon"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, iconProp)) {
372389
obj["icon"] = iconProp
373390
}
391+
discoveryTypeProp, err := expandBigqueryAnalyticsHubDataExchangeDiscoveryType(d.Get("discovery_type"), d, config)
392+
if err != nil {
393+
return err
394+
} else if v, ok := d.GetOkExists("discovery_type"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, discoveryTypeProp)) {
395+
obj["discoveryType"] = discoveryTypeProp
396+
}
374397
logLinkedDatasetQueryUserEmailProp, err := expandBigqueryAnalyticsHubDataExchangeLogLinkedDatasetQueryUserEmail(d.Get("log_linked_dataset_query_user_email"), d, config)
375398
if err != nil {
376399
return err
@@ -407,6 +430,10 @@ func resourceBigqueryAnalyticsHubDataExchangeUpdate(d *schema.ResourceData, meta
407430
updateMask = append(updateMask, "icon")
408431
}
409432

433+
if d.HasChange("discovery_type") {
434+
updateMask = append(updateMask, "discoveryType")
435+
}
436+
410437
if d.HasChange("log_linked_dataset_query_user_email") {
411438
updateMask = append(updateMask, "logLinkedDatasetQueryUserEmail")
412439
}
@@ -587,6 +614,10 @@ func flattenBigqueryAnalyticsHubDataExchangeSharingEnvironmentConfigDcrExchangeC
587614
return []interface{}{transformed}
588615
}
589616

617+
func flattenBigqueryAnalyticsHubDataExchangeDiscoveryType(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
618+
return v
619+
}
620+
590621
func flattenBigqueryAnalyticsHubDataExchangeLogLinkedDatasetQueryUserEmail(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
591622
return v
592623
}
@@ -667,6 +698,10 @@ func expandBigqueryAnalyticsHubDataExchangeSharingEnvironmentConfigDcrExchangeCo
667698
return transformed, nil
668699
}
669700

701+
func expandBigqueryAnalyticsHubDataExchangeDiscoveryType(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
702+
return v, nil
703+
}
704+
670705
func expandBigqueryAnalyticsHubDataExchangeLogLinkedDatasetQueryUserEmail(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
671706
return v, nil
672707
}

google/services/bigqueryanalyticshub/resource_bigquery_analytics_hub_data_exchange_generated_meta.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ fields:
88
- field: 'data_exchange_id'
99
provider_only: true
1010
- field: 'description'
11+
- field: 'discovery_type'
1112
- field: 'display_name'
1213
- field: 'documentation'
1314
- field: 'icon'

google/services/bigqueryanalyticshub/resource_bigquery_analytics_hub_data_exchange_generated_test.go

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,43 @@ resource "google_bigquery_analytics_hub_data_exchange" "data_exchange" {
142142
`, context)
143143
}
144144

145+
func TestAccBigqueryAnalyticsHubDataExchange_bigqueryAnalyticshubPublicDataExchangeExample(t *testing.T) {
146+
t.Parallel()
147+
148+
context := map[string]interface{}{
149+
"random_suffix": acctest.RandString(t, 10),
150+
}
151+
152+
acctest.VcrTest(t, resource.TestCase{
153+
PreCheck: func() { acctest.AccTestPreCheck(t) },
154+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
155+
CheckDestroy: testAccCheckBigqueryAnalyticsHubDataExchangeDestroyProducer(t),
156+
Steps: []resource.TestStep{
157+
{
158+
Config: testAccBigqueryAnalyticsHubDataExchange_bigqueryAnalyticshubPublicDataExchangeExample(context),
159+
},
160+
{
161+
ResourceName: "google_bigquery_analytics_hub_data_exchange.data_exchange",
162+
ImportState: true,
163+
ImportStateVerify: true,
164+
ImportStateVerifyIgnore: []string{"data_exchange_id", "location"},
165+
},
166+
},
167+
})
168+
}
169+
170+
func testAccBigqueryAnalyticsHubDataExchange_bigqueryAnalyticshubPublicDataExchangeExample(context map[string]interface{}) string {
171+
return acctest.Nprintf(`
172+
resource "google_bigquery_analytics_hub_data_exchange" "data_exchange" {
173+
location = "US"
174+
data_exchange_id = "tf_test_public_data_exchange%{random_suffix}"
175+
display_name = "tf_test_public_data_exchange%{random_suffix}"
176+
description = "Example for public data exchange%{random_suffix}"
177+
discovery_type = "DISCOVERY_TYPE_PUBLIC"
178+
}
179+
`, context)
180+
}
181+
145182
func testAccCheckBigqueryAnalyticsHubDataExchangeDestroyProducer(t *testing.T) func(s *terraform.State) error {
146183
return func(s *terraform.State) error {
147184
for name, rs := range s.RootModule().Resources {
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
// Copyright (c) HashiCorp, Inc.
2+
// SPDX-License-Identifier: MPL-2.0
3+
// ----------------------------------------------------------------------------
4+
//
5+
// *** AUTO GENERATED CODE *** Type: Handwritten ***
6+
//
7+
// ----------------------------------------------------------------------------
8+
//
9+
// This code is generated by Magic Modules using the following:
10+
//
11+
// Source file: https://github.com/GoogleCloudPlatform/magic-modules/tree/main/mmv1/third_party/terraform/services/bigqueryanalyticshub/resource_bigquery_analytics_hub_dataexchange_test.go
12+
//
13+
// DO NOT EDIT this file directly. Any changes made to this file will be
14+
// overwritten during the next generation cycle.
15+
//
16+
// ----------------------------------------------------------------------------
17+
package bigqueryanalyticshub_test
18+
19+
import (
20+
"testing"
21+
22+
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
23+
"github.com/hashicorp/terraform-provider-google/google/acctest"
24+
)
25+
26+
func TestAccBigqueryAnalyticsHubDataExchange_bigqueryAnalyticshubPublicDataExchangeUpdate(t *testing.T) {
27+
t.Parallel()
28+
29+
context := map[string]interface{}{
30+
"random_suffix": acctest.RandString(t, 10),
31+
}
32+
33+
acctest.VcrTest(t, resource.TestCase{
34+
PreCheck: func() { acctest.AccTestPreCheck(t) },
35+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
36+
CheckDestroy: testAccCheckBigqueryAnalyticsHubDataExchangeDestroyProducer(t),
37+
Steps: []resource.TestStep{
38+
{
39+
Config: testAccBigqueryAnalyticsHubDataExchange_bigqueryAnalyticshubPublicDataExchangeExample(context),
40+
},
41+
{
42+
ResourceName: "google_bigquery_analytics_hub_data_exchange.data_exchange",
43+
ImportState: true,
44+
ImportStateVerify: true,
45+
ImportStateVerifyIgnore: []string{"data_exchange_id", "location"},
46+
},
47+
{
48+
Config: testAccBigqueryAnalyticsHubDataExchange_bigqueryAnalyticshubPublicDataExchangeUpdate(context),
49+
},
50+
{
51+
ResourceName: "google_bigquery_analytics_hub_data_exchange.data_exchange",
52+
ImportState: true,
53+
ImportStateVerify: true,
54+
ImportStateVerifyIgnore: []string{"data_exchange_id", "location"},
55+
},
56+
},
57+
})
58+
}
59+
60+
func testAccBigqueryAnalyticsHubDataExchange_bigqueryAnalyticshubPublicDataExchangeUpdate(context map[string]interface{}) string {
61+
return acctest.Nprintf(`
62+
resource "google_bigquery_analytics_hub_data_exchange" "data_exchange" {
63+
location = "US"
64+
data_exchange_id = "tf_test_public_data_exchange%{random_suffix}"
65+
display_name = "tf_test_public_data_exchange%{random_suffix}"
66+
description = "Example for public data exchange%{random_suffix}"
67+
discovery_type = "DISCOVERY_TYPE_PRIVATE"
68+
}
69+
`, context)
70+
}

google/services/bigqueryanalyticshub/resource_bigquery_analytics_hub_listing.go

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import (
3232

3333
"github.com/hashicorp/terraform-provider-google/google/tpgresource"
3434
transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport"
35+
"github.com/hashicorp/terraform-provider-google/google/verify"
3536
)
3637

3738
func ResourceBigqueryAnalyticsHubListing() *schema.Resource {
@@ -79,6 +80,12 @@ func ResourceBigqueryAnalyticsHubListing() *schema.Resource {
7980
ForceNew: true,
8081
Description: `The name of the location this data exchange listing.`,
8182
},
83+
"allow_only_metadata_sharing": {
84+
Type: schema.TypeBool,
85+
Optional: true,
86+
ForceNew: true,
87+
Description: `If true, the listing is only available to get the resource metadata. Listing is non subscribable.`,
88+
},
8289
"bigquery_dataset": {
8390
Type: schema.TypeList,
8491
Optional: true,
@@ -149,6 +156,13 @@ func ResourceBigqueryAnalyticsHubListing() *schema.Resource {
149156
Optional: true,
150157
Description: `Short description of the listing. The description must not contain Unicode non-characters and C0 and C1 control codes except tabs (HT), new lines (LF), carriage returns (CR), and page breaks (FF).`,
151158
},
159+
"discovery_type": {
160+
Type: schema.TypeString,
161+
Computed: true,
162+
Optional: true,
163+
ValidateFunc: verify.ValidateEnum([]string{"DISCOVERY_TYPE_PRIVATE", "DISCOVERY_TYPE_PUBLIC", ""}),
164+
Description: `Specifies the type of discovery on the discovery page. Cannot be set for a restricted listing. Note that this does not control the visibility of the exchange/listing which is defined by IAM permission. Possible values: ["DISCOVERY_TYPE_PRIVATE", "DISCOVERY_TYPE_PUBLIC"]`,
165+
},
152166
"documentation": {
153167
Type: schema.TypeString,
154168
Optional: true,
@@ -281,6 +295,11 @@ Possible values: COMMERCIAL_STATE_UNSPECIFIED, ONBOARDING, ACTIVE`,
281295
Computed: true,
282296
Description: `The resource name of the listing. e.g. "projects/myproject/locations/US/dataExchanges/123/listings/456"`,
283297
},
298+
"state": {
299+
Type: schema.TypeString,
300+
Computed: true,
301+
Description: `Current state of the listing.`,
302+
},
284303
"delete_commercial": {
285304
Type: schema.TypeBool,
286305
Optional: true,
@@ -383,6 +402,18 @@ func resourceBigqueryAnalyticsHubListingCreate(d *schema.ResourceData, meta inte
383402
} else if v, ok := d.GetOkExists("log_linked_dataset_query_user_email"); !tpgresource.IsEmptyValue(reflect.ValueOf(logLinkedDatasetQueryUserEmailProp)) && (ok || !reflect.DeepEqual(v, logLinkedDatasetQueryUserEmailProp)) {
384403
obj["logLinkedDatasetQueryUserEmail"] = logLinkedDatasetQueryUserEmailProp
385404
}
405+
discoveryTypeProp, err := expandBigqueryAnalyticsHubListingDiscoveryType(d.Get("discovery_type"), d, config)
406+
if err != nil {
407+
return err
408+
} else if v, ok := d.GetOkExists("discovery_type"); !tpgresource.IsEmptyValue(reflect.ValueOf(discoveryTypeProp)) && (ok || !reflect.DeepEqual(v, discoveryTypeProp)) {
409+
obj["discoveryType"] = discoveryTypeProp
410+
}
411+
allowOnlyMetadataSharingProp, err := expandBigqueryAnalyticsHubListingAllowOnlyMetadataSharing(d.Get("allow_only_metadata_sharing"), d, config)
412+
if err != nil {
413+
return err
414+
} else if v, ok := d.GetOkExists("allow_only_metadata_sharing"); !tpgresource.IsEmptyValue(reflect.ValueOf(allowOnlyMetadataSharingProp)) && (ok || !reflect.DeepEqual(v, allowOnlyMetadataSharingProp)) {
415+
obj["allowOnlyMetadataSharing"] = allowOnlyMetadataSharingProp
416+
}
386417

387418
url, err := tpgresource.ReplaceVars(d, config, "{{BigqueryAnalyticsHubBasePath}}projects/{{project}}/locations/{{location}}/dataExchanges/{{data_exchange_id}}/listings?listing_id={{listing_id}}")
388419
if err != nil {
@@ -515,6 +546,15 @@ func resourceBigqueryAnalyticsHubListingRead(d *schema.ResourceData, meta interf
515546
if err := d.Set("log_linked_dataset_query_user_email", flattenBigqueryAnalyticsHubListingLogLinkedDatasetQueryUserEmail(res["logLinkedDatasetQueryUserEmail"], d, config)); err != nil {
516547
return fmt.Errorf("Error reading Listing: %s", err)
517548
}
549+
if err := d.Set("state", flattenBigqueryAnalyticsHubListingState(res["state"], d, config)); err != nil {
550+
return fmt.Errorf("Error reading Listing: %s", err)
551+
}
552+
if err := d.Set("discovery_type", flattenBigqueryAnalyticsHubListingDiscoveryType(res["discoveryType"], d, config)); err != nil {
553+
return fmt.Errorf("Error reading Listing: %s", err)
554+
}
555+
if err := d.Set("allow_only_metadata_sharing", flattenBigqueryAnalyticsHubListingAllowOnlyMetadataSharing(res["allowOnlyMetadataSharing"], d, config)); err != nil {
556+
return fmt.Errorf("Error reading Listing: %s", err)
557+
}
518558
if err := d.Set("commercial_info", flattenBigqueryAnalyticsHubListingCommercialInfo(res["commercialInfo"], d, config)); err != nil {
519559
return fmt.Errorf("Error reading Listing: %s", err)
520560
}
@@ -610,6 +650,12 @@ func resourceBigqueryAnalyticsHubListingUpdate(d *schema.ResourceData, meta inte
610650
} else if v, ok := d.GetOkExists("log_linked_dataset_query_user_email"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, logLinkedDatasetQueryUserEmailProp)) {
611651
obj["logLinkedDatasetQueryUserEmail"] = logLinkedDatasetQueryUserEmailProp
612652
}
653+
discoveryTypeProp, err := expandBigqueryAnalyticsHubListingDiscoveryType(d.Get("discovery_type"), d, config)
654+
if err != nil {
655+
return err
656+
} else if v, ok := d.GetOkExists("discovery_type"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, discoveryTypeProp)) {
657+
obj["discoveryType"] = discoveryTypeProp
658+
}
613659

614660
url, err := tpgresource.ReplaceVars(d, config, "{{BigqueryAnalyticsHubBasePath}}projects/{{project}}/locations/{{location}}/dataExchanges/{{data_exchange_id}}/listings/{{listing_id}}")
615661
if err != nil {
@@ -667,6 +713,10 @@ func resourceBigqueryAnalyticsHubListingUpdate(d *schema.ResourceData, meta inte
667713
if d.HasChange("log_linked_dataset_query_user_email") {
668714
updateMask = append(updateMask, "logLinkedDatasetQueryUserEmail")
669715
}
716+
717+
if d.HasChange("discovery_type") {
718+
updateMask = append(updateMask, "discoveryType")
719+
}
670720
// updateMask is a URL parameter but not present in the schema, so ReplaceVars
671721
// won't set it
672722
url, err = transport_tpg.AddQueryParams(url, map[string]string{"updateMask": strings.Join(updateMask, ",")})
@@ -974,6 +1024,18 @@ func flattenBigqueryAnalyticsHubListingLogLinkedDatasetQueryUserEmail(v interfac
9741024
return v
9751025
}
9761026

1027+
func flattenBigqueryAnalyticsHubListingState(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
1028+
return v
1029+
}
1030+
1031+
func flattenBigqueryAnalyticsHubListingDiscoveryType(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
1032+
return v
1033+
}
1034+
1035+
func flattenBigqueryAnalyticsHubListingAllowOnlyMetadataSharing(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
1036+
return v
1037+
}
1038+
9771039
func flattenBigqueryAnalyticsHubListingCommercialInfo(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
9781040
if v == nil {
9791041
return nil
@@ -1245,3 +1307,11 @@ func expandBigqueryAnalyticsHubListingRestrictedExportConfigRestrictQueryResult(
12451307
func expandBigqueryAnalyticsHubListingLogLinkedDatasetQueryUserEmail(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
12461308
return v, nil
12471309
}
1310+
1311+
func expandBigqueryAnalyticsHubListingDiscoveryType(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
1312+
return v, nil
1313+
}
1314+
1315+
func expandBigqueryAnalyticsHubListingAllowOnlyMetadataSharing(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
1316+
return v, nil
1317+
}

google/services/bigqueryanalyticshub/resource_bigquery_analytics_hub_listing_generated_meta.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ api_service_name: 'analyticshub.googleapis.com'
55
api_version: 'v1'
66
api_resource_type_kind: 'Listing'
77
fields:
8+
- field: 'allow_only_metadata_sharing'
89
- field: 'bigquery_dataset.dataset'
910
- field: 'bigquery_dataset.selected_resources.table'
1011
- field: 'categories'
@@ -17,6 +18,7 @@ fields:
1718
- field: 'delete_commercial'
1819
provider_only: true
1920
- field: 'description'
21+
- field: 'discovery_type'
2022
- field: 'display_name'
2123
- field: 'documentation'
2224
- field: 'icon'
@@ -35,3 +37,4 @@ fields:
3537
- field: 'restricted_export_config.enabled'
3638
- field: 'restricted_export_config.restrict_direct_table_access'
3739
- field: 'restricted_export_config.restrict_query_result'
40+
- field: 'state'

0 commit comments

Comments
 (0)