@@ -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
3738func 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+
9771039func flattenBigqueryAnalyticsHubListingCommercialInfo (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
9781040 if v == nil {
9791041 return nil
@@ -1245,3 +1307,11 @@ func expandBigqueryAnalyticsHubListingRestrictedExportConfigRestrictQueryResult(
12451307func 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+ }
0 commit comments