@@ -165,6 +165,26 @@ func ResourceBigqueryAnalyticsHubListing() *schema.Resource {
165
165
Optional : true ,
166
166
Description : `Email or URL of the request access of the listing. Subscribers can use this reference to request access.` ,
167
167
},
168
+ "restricted_export_config" : {
169
+ Type : schema .TypeList ,
170
+ Optional : true ,
171
+ Description : `If set, restricted export configuration will be propagated and enforced on the linked dataset.` ,
172
+ MaxItems : 1 ,
173
+ Elem : & schema.Resource {
174
+ Schema : map [string ]* schema.Schema {
175
+ "enabled" : {
176
+ Type : schema .TypeBool ,
177
+ Optional : true ,
178
+ Description : `If true, enable restricted export.` ,
179
+ },
180
+ "restrict_query_result" : {
181
+ Type : schema .TypeBool ,
182
+ Optional : true ,
183
+ Description : `If true, restrict export of query result derived from restricted linked dataset table.` ,
184
+ },
185
+ },
186
+ },
187
+ },
168
188
"name" : {
169
189
Type : schema .TypeString ,
170
190
Computed : true ,
@@ -249,6 +269,12 @@ func resourceBigqueryAnalyticsHubListingCreate(d *schema.ResourceData, meta inte
249
269
} else if v , ok := d .GetOkExists ("bigquery_dataset" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (bigqueryDatasetProp )) && (ok || ! reflect .DeepEqual (v , bigqueryDatasetProp )) {
250
270
obj ["bigqueryDataset" ] = bigqueryDatasetProp
251
271
}
272
+ restrictedExportConfigProp , err := expandBigqueryAnalyticsHubListingRestrictedExportConfig (d .Get ("restricted_export_config" ), d , config )
273
+ if err != nil {
274
+ return err
275
+ } else if v , ok := d .GetOkExists ("restricted_export_config" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (restrictedExportConfigProp )) && (ok || ! reflect .DeepEqual (v , restrictedExportConfigProp )) {
276
+ obj ["restrictedExportConfig" ] = restrictedExportConfigProp
277
+ }
252
278
253
279
url , err := tpgresource .ReplaceVars (d , config , "{{BigqueryAnalyticsHubBasePath}}projects/{{project}}/locations/{{location}}/dataExchanges/{{data_exchange_id}}/listings?listing_id={{listing_id}}" )
254
280
if err != nil {
@@ -370,6 +396,9 @@ func resourceBigqueryAnalyticsHubListingRead(d *schema.ResourceData, meta interf
370
396
if err := d .Set ("bigquery_dataset" , flattenBigqueryAnalyticsHubListingBigqueryDataset (res ["bigqueryDataset" ], d , config )); err != nil {
371
397
return fmt .Errorf ("Error reading Listing: %s" , err )
372
398
}
399
+ if err := d .Set ("restricted_export_config" , flattenBigqueryAnalyticsHubListingRestrictedExportConfig (res ["restrictedExportConfig" ], d , config )); err != nil {
400
+ return fmt .Errorf ("Error reading Listing: %s" , err )
401
+ }
373
402
374
403
return nil
375
404
}
@@ -450,6 +479,12 @@ func resourceBigqueryAnalyticsHubListingUpdate(d *schema.ResourceData, meta inte
450
479
} else if v , ok := d .GetOkExists ("bigquery_dataset" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (v )) && (ok || ! reflect .DeepEqual (v , bigqueryDatasetProp )) {
451
480
obj ["bigqueryDataset" ] = bigqueryDatasetProp
452
481
}
482
+ restrictedExportConfigProp , err := expandBigqueryAnalyticsHubListingRestrictedExportConfig (d .Get ("restricted_export_config" ), d , config )
483
+ if err != nil {
484
+ return err
485
+ } else if v , ok := d .GetOkExists ("restricted_export_config" ); ! tpgresource .IsEmptyValue (reflect .ValueOf (v )) && (ok || ! reflect .DeepEqual (v , restrictedExportConfigProp )) {
486
+ obj ["restrictedExportConfig" ] = restrictedExportConfigProp
487
+ }
453
488
454
489
url , err := tpgresource .ReplaceVars (d , config , "{{BigqueryAnalyticsHubBasePath}}projects/{{project}}/locations/{{location}}/dataExchanges/{{data_exchange_id}}/listings/{{listing_id}}" )
455
490
if err != nil {
@@ -498,6 +533,10 @@ func resourceBigqueryAnalyticsHubListingUpdate(d *schema.ResourceData, meta inte
498
533
if d .HasChange ("bigquery_dataset" ) {
499
534
updateMask = append (updateMask , "bigqueryDataset" )
500
535
}
536
+
537
+ if d .HasChange ("restricted_export_config" ) {
538
+ updateMask = append (updateMask , "restrictedExportConfig" )
539
+ }
501
540
// updateMask is a URL parameter but not present in the schema, so ReplaceVars
502
541
// won't set it
503
542
url , err = transport_tpg .AddQueryParams (url , map [string ]string {"updateMask" : strings .Join (updateMask , "," )})
@@ -693,6 +732,29 @@ func flattenBigqueryAnalyticsHubListingBigqueryDatasetDataset(v interface{}, d *
693
732
return v
694
733
}
695
734
735
+ func flattenBigqueryAnalyticsHubListingRestrictedExportConfig (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
736
+ if v == nil {
737
+ return nil
738
+ }
739
+ original := v .(map [string ]interface {})
740
+ if len (original ) == 0 {
741
+ return nil
742
+ }
743
+ transformed := make (map [string ]interface {})
744
+ transformed ["enabled" ] =
745
+ flattenBigqueryAnalyticsHubListingRestrictedExportConfigEnabled (original ["enabled" ], d , config )
746
+ transformed ["restrict_query_result" ] =
747
+ flattenBigqueryAnalyticsHubListingRestrictedExportConfigRestrictQueryResult (original ["restrictQueryResult" ], d , config )
748
+ return []interface {}{transformed }
749
+ }
750
+ func flattenBigqueryAnalyticsHubListingRestrictedExportConfigEnabled (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
751
+ return v
752
+ }
753
+
754
+ func flattenBigqueryAnalyticsHubListingRestrictedExportConfigRestrictQueryResult (v interface {}, d * schema.ResourceData , config * transport_tpg.Config ) interface {} {
755
+ return v
756
+ }
757
+
696
758
func expandBigqueryAnalyticsHubListingDisplayName (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
697
759
return v , nil
698
760
}
@@ -811,3 +873,37 @@ func expandBigqueryAnalyticsHubListingBigqueryDataset(v interface{}, d tpgresour
811
873
func expandBigqueryAnalyticsHubListingBigqueryDatasetDataset (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
812
874
return v , nil
813
875
}
876
+
877
+ func expandBigqueryAnalyticsHubListingRestrictedExportConfig (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
878
+ l := v .([]interface {})
879
+ if len (l ) == 0 || l [0 ] == nil {
880
+ return nil , nil
881
+ }
882
+ raw := l [0 ]
883
+ original := raw .(map [string ]interface {})
884
+ transformed := make (map [string ]interface {})
885
+
886
+ transformedEnabled , err := expandBigqueryAnalyticsHubListingRestrictedExportConfigEnabled (original ["enabled" ], d , config )
887
+ if err != nil {
888
+ return nil , err
889
+ } else if val := reflect .ValueOf (transformedEnabled ); val .IsValid () && ! tpgresource .IsEmptyValue (val ) {
890
+ transformed ["enabled" ] = transformedEnabled
891
+ }
892
+
893
+ transformedRestrictQueryResult , err := expandBigqueryAnalyticsHubListingRestrictedExportConfigRestrictQueryResult (original ["restrict_query_result" ], d , config )
894
+ if err != nil {
895
+ return nil , err
896
+ } else if val := reflect .ValueOf (transformedRestrictQueryResult ); val .IsValid () && ! tpgresource .IsEmptyValue (val ) {
897
+ transformed ["restrictQueryResult" ] = transformedRestrictQueryResult
898
+ }
899
+
900
+ return transformed , nil
901
+ }
902
+
903
+ func expandBigqueryAnalyticsHubListingRestrictedExportConfigEnabled (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
904
+ return v , nil
905
+ }
906
+
907
+ func expandBigqueryAnalyticsHubListingRestrictedExportConfigRestrictQueryResult (v interface {}, d tpgresource.TerraformResourceData , config * transport_tpg.Config ) (interface {}, error ) {
908
+ return v , nil
909
+ }
0 commit comments