Skip to content

Commit a916cc1

Browse files
Adding support for missing AH fields (#14637) (#10435)
[upstream:66fb3ef41c92725f631b56116f94d32158f33c93] Signed-off-by: Modular Magician <magic-modules@google.com>
1 parent 49d1117 commit a916cc1

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-beta/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-beta/google-beta/tpgresource"
3434
transport_tpg "github.com/hashicorp/terraform-provider-google-beta/google-beta/transport"
35+
"github.com/hashicorp/terraform-provider-google-beta/google-beta/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-beta/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-beta/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-beta/google-beta/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-beta/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-beta/google-beta/tpgresource"
3434
transport_tpg "github.com/hashicorp/terraform-provider-google-beta/google-beta/transport"
35+
"github.com/hashicorp/terraform-provider-google-beta/google-beta/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,
@@ -157,6 +164,13 @@ func ResourceBigqueryAnalyticsHubListing() *schema.Resource {
157164
Optional: true,
158165
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).`,
159166
},
167+
"discovery_type": {
168+
Type: schema.TypeString,
169+
Computed: true,
170+
Optional: true,
171+
ValidateFunc: verify.ValidateEnum([]string{"DISCOVERY_TYPE_PRIVATE", "DISCOVERY_TYPE_PUBLIC", ""}),
172+
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"]`,
173+
},
160174
"documentation": {
161175
Type: schema.TypeString,
162176
Optional: true,
@@ -289,6 +303,11 @@ Possible values: COMMERCIAL_STATE_UNSPECIFIED, ONBOARDING, ACTIVE`,
289303
Computed: true,
290304
Description: `The resource name of the listing. e.g. "projects/myproject/locations/US/dataExchanges/123/listings/456"`,
291305
},
306+
"state": {
307+
Type: schema.TypeString,
308+
Computed: true,
309+
Description: `Current state of the listing.`,
310+
},
292311
"delete_commercial": {
293312
Type: schema.TypeBool,
294313
Optional: true,
@@ -391,6 +410,18 @@ func resourceBigqueryAnalyticsHubListingCreate(d *schema.ResourceData, meta inte
391410
} else if v, ok := d.GetOkExists("log_linked_dataset_query_user_email"); !tpgresource.IsEmptyValue(reflect.ValueOf(logLinkedDatasetQueryUserEmailProp)) && (ok || !reflect.DeepEqual(v, logLinkedDatasetQueryUserEmailProp)) {
392411
obj["logLinkedDatasetQueryUserEmail"] = logLinkedDatasetQueryUserEmailProp
393412
}
413+
discoveryTypeProp, err := expandBigqueryAnalyticsHubListingDiscoveryType(d.Get("discovery_type"), d, config)
414+
if err != nil {
415+
return err
416+
} else if v, ok := d.GetOkExists("discovery_type"); !tpgresource.IsEmptyValue(reflect.ValueOf(discoveryTypeProp)) && (ok || !reflect.DeepEqual(v, discoveryTypeProp)) {
417+
obj["discoveryType"] = discoveryTypeProp
418+
}
419+
allowOnlyMetadataSharingProp, err := expandBigqueryAnalyticsHubListingAllowOnlyMetadataSharing(d.Get("allow_only_metadata_sharing"), d, config)
420+
if err != nil {
421+
return err
422+
} else if v, ok := d.GetOkExists("allow_only_metadata_sharing"); !tpgresource.IsEmptyValue(reflect.ValueOf(allowOnlyMetadataSharingProp)) && (ok || !reflect.DeepEqual(v, allowOnlyMetadataSharingProp)) {
423+
obj["allowOnlyMetadataSharing"] = allowOnlyMetadataSharingProp
424+
}
394425

395426
url, err := tpgresource.ReplaceVars(d, config, "{{BigqueryAnalyticsHubBasePath}}projects/{{project}}/locations/{{location}}/dataExchanges/{{data_exchange_id}}/listings?listing_id={{listing_id}}")
396427
if err != nil {
@@ -523,6 +554,15 @@ func resourceBigqueryAnalyticsHubListingRead(d *schema.ResourceData, meta interf
523554
if err := d.Set("log_linked_dataset_query_user_email", flattenBigqueryAnalyticsHubListingLogLinkedDatasetQueryUserEmail(res["logLinkedDatasetQueryUserEmail"], d, config)); err != nil {
524555
return fmt.Errorf("Error reading Listing: %s", err)
525556
}
557+
if err := d.Set("state", flattenBigqueryAnalyticsHubListingState(res["state"], d, config)); err != nil {
558+
return fmt.Errorf("Error reading Listing: %s", err)
559+
}
560+
if err := d.Set("discovery_type", flattenBigqueryAnalyticsHubListingDiscoveryType(res["discoveryType"], d, config)); err != nil {
561+
return fmt.Errorf("Error reading Listing: %s", err)
562+
}
563+
if err := d.Set("allow_only_metadata_sharing", flattenBigqueryAnalyticsHubListingAllowOnlyMetadataSharing(res["allowOnlyMetadataSharing"], d, config)); err != nil {
564+
return fmt.Errorf("Error reading Listing: %s", err)
565+
}
526566
if err := d.Set("commercial_info", flattenBigqueryAnalyticsHubListingCommercialInfo(res["commercialInfo"], d, config)); err != nil {
527567
return fmt.Errorf("Error reading Listing: %s", err)
528568
}
@@ -618,6 +658,12 @@ func resourceBigqueryAnalyticsHubListingUpdate(d *schema.ResourceData, meta inte
618658
} else if v, ok := d.GetOkExists("log_linked_dataset_query_user_email"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, logLinkedDatasetQueryUserEmailProp)) {
619659
obj["logLinkedDatasetQueryUserEmail"] = logLinkedDatasetQueryUserEmailProp
620660
}
661+
discoveryTypeProp, err := expandBigqueryAnalyticsHubListingDiscoveryType(d.Get("discovery_type"), d, config)
662+
if err != nil {
663+
return err
664+
} else if v, ok := d.GetOkExists("discovery_type"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, discoveryTypeProp)) {
665+
obj["discoveryType"] = discoveryTypeProp
666+
}
621667

622668
url, err := tpgresource.ReplaceVars(d, config, "{{BigqueryAnalyticsHubBasePath}}projects/{{project}}/locations/{{location}}/dataExchanges/{{data_exchange_id}}/listings/{{listing_id}}")
623669
if err != nil {
@@ -675,6 +721,10 @@ func resourceBigqueryAnalyticsHubListingUpdate(d *schema.ResourceData, meta inte
675721
if d.HasChange("log_linked_dataset_query_user_email") {
676722
updateMask = append(updateMask, "logLinkedDatasetQueryUserEmail")
677723
}
724+
725+
if d.HasChange("discovery_type") {
726+
updateMask = append(updateMask, "discoveryType")
727+
}
678728
// updateMask is a URL parameter but not present in the schema, so ReplaceVars
679729
// won't set it
680730
url, err = transport_tpg.AddQueryParams(url, map[string]string{"updateMask": strings.Join(updateMask, ",")})
@@ -987,6 +1037,18 @@ func flattenBigqueryAnalyticsHubListingLogLinkedDatasetQueryUserEmail(v interfac
9871037
return v
9881038
}
9891039

1040+
func flattenBigqueryAnalyticsHubListingState(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
1041+
return v
1042+
}
1043+
1044+
func flattenBigqueryAnalyticsHubListingDiscoveryType(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
1045+
return v
1046+
}
1047+
1048+
func flattenBigqueryAnalyticsHubListingAllowOnlyMetadataSharing(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
1049+
return v
1050+
}
1051+
9901052
func flattenBigqueryAnalyticsHubListingCommercialInfo(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
9911053
if v == nil {
9921054
return nil
@@ -1269,3 +1331,11 @@ func expandBigqueryAnalyticsHubListingRestrictedExportConfigRestrictQueryResult(
12691331
func expandBigqueryAnalyticsHubListingLogLinkedDatasetQueryUserEmail(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
12701332
return v, nil
12711333
}
1334+
1335+
func expandBigqueryAnalyticsHubListingDiscoveryType(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
1336+
return v, nil
1337+
}
1338+
1339+
func expandBigqueryAnalyticsHubListingAllowOnlyMetadataSharing(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
1340+
return v, nil
1341+
}

google-beta/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.routine'
1011
- field: 'bigquery_dataset.selected_resources.table'
@@ -18,6 +19,7 @@ fields:
1819
- field: 'delete_commercial'
1920
provider_only: true
2021
- field: 'description'
22+
- field: 'discovery_type'
2123
- field: 'display_name'
2224
- field: 'documentation'
2325
- field: 'icon'
@@ -36,3 +38,4 @@ fields:
3638
- field: 'restricted_export_config.enabled'
3739
- field: 'restricted_export_config.restrict_direct_table_access'
3840
- field: 'restricted_export_config.restrict_query_result'
41+
- field: 'state'

0 commit comments

Comments
 (0)