Skip to content

Commit 334d0b3

Browse files
feat: [google-cloud-bigquery-analyticshub] support selective sharing on data clean room Listings (googleapis#12467)
BEGIN_COMMIT_OVERRIDE feat: support selective sharing on data clean room Listings feat: support output fields on DcrExchangeConfig specifying selective sharing behavior on a data clean room END_COMMIT_OVERRIDE - [ ] Regenerate this pull request now. feat: support output fields on DcrExchangeConfig specifying selective sharing behavior on a data clean room PiperOrigin-RevId: 616259882 Source-Link: googleapis/googleapis@5b66360 Source-Link: https://github.com/googleapis/googleapis-gen/commit/d971ee9270b3a46f4d410b7b3720bc42b4c1a69b Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLWJpZ3F1ZXJ5LWFuYWx5dGljc2h1Yi8uT3dsQm90LnlhbWwiLCJoIjoiZDk3MWVlOTI3MGIzYTQ2ZjRkNDEwYjdiMzcyMGJjNDJiNGMxYTY5YiJ9 --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> Co-authored-by: ohmayr <omairnaveed@ymail.com>
1 parent 06d3f6f commit 334d0b3

4 files changed

Lines changed: 134 additions & 12 deletions

File tree

packages/google-cloud-bigquery-analyticshub/google/cloud/bigquery_analyticshub_v1/services/analytics_hub_service/async_client.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ class AnalyticsHubServiceAsyncClient:
9090
parse_subscription_path = staticmethod(
9191
AnalyticsHubServiceClient.parse_subscription_path
9292
)
93+
table_path = staticmethod(AnalyticsHubServiceClient.table_path)
94+
parse_table_path = staticmethod(AnalyticsHubServiceClient.parse_table_path)
9395
common_billing_account_path = staticmethod(
9496
AnalyticsHubServiceClient.common_billing_account_path
9597
)

packages/google-cloud-bigquery-analyticshub/google/cloud/bigquery_analyticshub_v1/services/analytics_hub_service/client.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,28 @@ def parse_subscription_path(path: str) -> Dict[str, str]:
281281
)
282282
return m.groupdict() if m else {}
283283

284+
@staticmethod
285+
def table_path(
286+
project: str,
287+
dataset: str,
288+
table: str,
289+
) -> str:
290+
"""Returns a fully-qualified table string."""
291+
return "projects/{project}/datasets/{dataset}/tables/{table}".format(
292+
project=project,
293+
dataset=dataset,
294+
table=table,
295+
)
296+
297+
@staticmethod
298+
def parse_table_path(path: str) -> Dict[str, str]:
299+
"""Parses a table path into its component segments."""
300+
m = re.match(
301+
r"^projects/(?P<project>.+?)/datasets/(?P<dataset>.+?)/tables/(?P<table>.+?)$",
302+
path,
303+
)
304+
return m.groupdict() if m else {}
305+
284306
@staticmethod
285307
def common_billing_account_path(
286308
billing_account: str,

packages/google-cloud-bigquery-analyticshub/google/cloud/bigquery_analyticshub_v1/types/analyticshub.py

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,47 @@ class DcrExchangeConfig(proto.Message):
183183
r"""Data Clean Room (DCR), used for privacy-safe and secured data
184184
sharing.
185185
186+
187+
.. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields
188+
189+
Attributes:
190+
single_selected_resource_sharing_restriction (bool):
191+
Output only. If True, this DCR restricts the
192+
contributors to sharing only a single resource
193+
in a Listing. And no two resources should have
194+
the same IDs. So if a contributor adds a view
195+
with a conflicting name, the CreateListing API
196+
will reject the request. if False, the data
197+
contributor can publish an entire dataset (as
198+
before). This is not configurable, and by
199+
default, all new DCRs will have the restriction
200+
set to True.
201+
202+
This field is a member of `oneof`_ ``_single_selected_resource_sharing_restriction``.
203+
single_linked_dataset_per_cleanroom (bool):
204+
Output only. If True, when subscribing to
205+
this DCR, it will create only one linked dataset
206+
containing all resources shared within the
207+
cleanroom. If False, when subscribing to this
208+
DCR, it will create 1 linked dataset per
209+
listing. This is not configurable, and by
210+
default, all new DCRs will have the restriction
211+
set to True.
212+
213+
This field is a member of `oneof`_ ``_single_linked_dataset_per_cleanroom``.
186214
"""
187215

216+
single_selected_resource_sharing_restriction: bool = proto.Field(
217+
proto.BOOL,
218+
number=1,
219+
optional=True,
220+
)
221+
single_linked_dataset_per_cleanroom: bool = proto.Field(
222+
proto.BOOL,
223+
number=2,
224+
optional=True,
225+
)
226+
188227
default_exchange_config: DefaultExchangeConfig = proto.Field(
189228
proto.MESSAGE,
190229
number=1,
@@ -480,12 +519,45 @@ class BigQueryDatasetSource(proto.Message):
480519
dataset (str):
481520
Resource name of the dataset source for this listing. e.g.
482521
``projects/myproject/datasets/123``
522+
selected_resources (MutableSequence[google.cloud.bigquery_analyticshub_v1.types.Listing.BigQueryDatasetSource.SelectedResource]):
523+
Optional. Resources in this dataset that are
524+
selectively shared. If this field is empty, then
525+
the entire dataset (all resources) are shared.
526+
This field is only valid for data clean room
527+
exchanges.
483528
"""
484529

530+
class SelectedResource(proto.Message):
531+
r"""Resource in this dataset that are selectively shared.
532+
533+
.. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields
534+
535+
Attributes:
536+
table (str):
537+
Optional. Format: For table:
538+
``projects/{projectId}/datasets/{datasetId}/tables/{tableId}``
539+
Example:"projects/test_project/datasets/test_dataset/tables/test_table".
540+
541+
This field is a member of `oneof`_ ``resource``.
542+
"""
543+
544+
table: str = proto.Field(
545+
proto.STRING,
546+
number=1,
547+
oneof="resource",
548+
)
549+
485550
dataset: str = proto.Field(
486551
proto.STRING,
487552
number=1,
488553
)
554+
selected_resources: MutableSequence[
555+
"Listing.BigQueryDatasetSource.SelectedResource"
556+
] = proto.RepeatedField(
557+
proto.MESSAGE,
558+
number=2,
559+
message="Listing.BigQueryDatasetSource.SelectedResource",
560+
)
489561

490562
class RestrictedExportConfig(proto.Message):
491563
r"""Restricted export config, used to configure restricted export

packages/google-cloud-bigquery-analyticshub/tests/unit/gapic/bigquery_analyticshub_v1/test_analytics_hub_service.py

Lines changed: 38 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8140,8 +8140,34 @@ def test_parse_subscription_path():
81408140
assert expected == actual
81418141

81428142

8143+
def test_table_path():
8144+
project = "squid"
8145+
dataset = "clam"
8146+
table = "whelk"
8147+
expected = "projects/{project}/datasets/{dataset}/tables/{table}".format(
8148+
project=project,
8149+
dataset=dataset,
8150+
table=table,
8151+
)
8152+
actual = AnalyticsHubServiceClient.table_path(project, dataset, table)
8153+
assert expected == actual
8154+
8155+
8156+
def test_parse_table_path():
8157+
expected = {
8158+
"project": "octopus",
8159+
"dataset": "oyster",
8160+
"table": "nudibranch",
8161+
}
8162+
path = AnalyticsHubServiceClient.table_path(**expected)
8163+
8164+
# Check that the path construction is reversible.
8165+
actual = AnalyticsHubServiceClient.parse_table_path(path)
8166+
assert expected == actual
8167+
8168+
81438169
def test_common_billing_account_path():
8144-
billing_account = "squid"
8170+
billing_account = "cuttlefish"
81458171
expected = "billingAccounts/{billing_account}".format(
81468172
billing_account=billing_account,
81478173
)
@@ -8151,7 +8177,7 @@ def test_common_billing_account_path():
81518177

81528178
def test_parse_common_billing_account_path():
81538179
expected = {
8154-
"billing_account": "clam",
8180+
"billing_account": "mussel",
81558181
}
81568182
path = AnalyticsHubServiceClient.common_billing_account_path(**expected)
81578183

@@ -8161,7 +8187,7 @@ def test_parse_common_billing_account_path():
81618187

81628188

81638189
def test_common_folder_path():
8164-
folder = "whelk"
8190+
folder = "winkle"
81658191
expected = "folders/{folder}".format(
81668192
folder=folder,
81678193
)
@@ -8171,7 +8197,7 @@ def test_common_folder_path():
81718197

81728198
def test_parse_common_folder_path():
81738199
expected = {
8174-
"folder": "octopus",
8200+
"folder": "nautilus",
81758201
}
81768202
path = AnalyticsHubServiceClient.common_folder_path(**expected)
81778203

@@ -8181,7 +8207,7 @@ def test_parse_common_folder_path():
81818207

81828208

81838209
def test_common_organization_path():
8184-
organization = "oyster"
8210+
organization = "scallop"
81858211
expected = "organizations/{organization}".format(
81868212
organization=organization,
81878213
)
@@ -8191,7 +8217,7 @@ def test_common_organization_path():
81918217

81928218
def test_parse_common_organization_path():
81938219
expected = {
8194-
"organization": "nudibranch",
8220+
"organization": "abalone",
81958221
}
81968222
path = AnalyticsHubServiceClient.common_organization_path(**expected)
81978223

@@ -8201,7 +8227,7 @@ def test_parse_common_organization_path():
82018227

82028228

82038229
def test_common_project_path():
8204-
project = "cuttlefish"
8230+
project = "squid"
82058231
expected = "projects/{project}".format(
82068232
project=project,
82078233
)
@@ -8211,7 +8237,7 @@ def test_common_project_path():
82118237

82128238
def test_parse_common_project_path():
82138239
expected = {
8214-
"project": "mussel",
8240+
"project": "clam",
82158241
}
82168242
path = AnalyticsHubServiceClient.common_project_path(**expected)
82178243

@@ -8221,8 +8247,8 @@ def test_parse_common_project_path():
82218247

82228248

82238249
def test_common_location_path():
8224-
project = "winkle"
8225-
location = "nautilus"
8250+
project = "whelk"
8251+
location = "octopus"
82268252
expected = "projects/{project}/locations/{location}".format(
82278253
project=project,
82288254
location=location,
@@ -8233,8 +8259,8 @@ def test_common_location_path():
82338259

82348260
def test_parse_common_location_path():
82358261
expected = {
8236-
"project": "scallop",
8237-
"location": "abalone",
8262+
"project": "oyster",
8263+
"location": "nudibranch",
82388264
}
82398265
path = AnalyticsHubServiceClient.common_location_path(**expected)
82408266

0 commit comments

Comments
 (0)