Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ class AnalyticsHubServiceAsyncClient:
parse_subscription_path = staticmethod(
AnalyticsHubServiceClient.parse_subscription_path
)
table_path = staticmethod(AnalyticsHubServiceClient.table_path)
parse_table_path = staticmethod(AnalyticsHubServiceClient.parse_table_path)
common_billing_account_path = staticmethod(
AnalyticsHubServiceClient.common_billing_account_path
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,28 @@ def parse_subscription_path(path: str) -> Dict[str, str]:
)
return m.groupdict() if m else {}

@staticmethod
def table_path(
project: str,
dataset: str,
table: str,
) -> str:
"""Returns a fully-qualified table string."""
return "projects/{project}/datasets/{dataset}/tables/{table}".format(
project=project,
dataset=dataset,
table=table,
)

@staticmethod
def parse_table_path(path: str) -> Dict[str, str]:
"""Parses a table path into its component segments."""
m = re.match(
r"^projects/(?P<project>.+?)/datasets/(?P<dataset>.+?)/tables/(?P<table>.+?)$",
path,
)
return m.groupdict() if m else {}

@staticmethod
def common_billing_account_path(
billing_account: str,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,47 @@ class DcrExchangeConfig(proto.Message):
r"""Data Clean Room (DCR), used for privacy-safe and secured data
sharing.


.. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields

Attributes:
single_selected_resource_sharing_restriction (bool):
Output only. If True, this DCR restricts the
contributors to sharing only a single resource
in a Listing. And no two resources should have
the same IDs. So if a contributor adds a view
with a conflicting name, the CreateListing API
will reject the request. if False, the data
contributor can publish an entire dataset (as
before). This is not configurable, and by
default, all new DCRs will have the restriction
set to True.

This field is a member of `oneof`_ ``_single_selected_resource_sharing_restriction``.
single_linked_dataset_per_cleanroom (bool):
Output only. If True, when subscribing to
this DCR, it will create only one linked dataset
containing all resources shared within the
cleanroom. If False, when subscribing to this
DCR, it will create 1 linked dataset per
listing. This is not configurable, and by
default, all new DCRs will have the restriction
set to True.

This field is a member of `oneof`_ ``_single_linked_dataset_per_cleanroom``.
"""

single_selected_resource_sharing_restriction: bool = proto.Field(
proto.BOOL,
number=1,
optional=True,
)
single_linked_dataset_per_cleanroom: bool = proto.Field(
proto.BOOL,
number=2,
optional=True,
)

default_exchange_config: DefaultExchangeConfig = proto.Field(
proto.MESSAGE,
number=1,
Expand Down Expand Up @@ -480,12 +519,45 @@ class BigQueryDatasetSource(proto.Message):
dataset (str):
Resource name of the dataset source for this listing. e.g.
``projects/myproject/datasets/123``
selected_resources (MutableSequence[google.cloud.bigquery_analyticshub_v1.types.Listing.BigQueryDatasetSource.SelectedResource]):
Optional. Resources in this dataset that are
selectively shared. If this field is empty, then
the entire dataset (all resources) are shared.
This field is only valid for data clean room
exchanges.
"""

class SelectedResource(proto.Message):
r"""Resource in this dataset that are selectively shared.

.. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields

Attributes:
table (str):
Optional. Format: For table:
``projects/{projectId}/datasets/{datasetId}/tables/{tableId}``
Example:"projects/test_project/datasets/test_dataset/tables/test_table".

This field is a member of `oneof`_ ``resource``.
"""

table: str = proto.Field(
proto.STRING,
number=1,
oneof="resource",
)

dataset: str = proto.Field(
proto.STRING,
number=1,
)
selected_resources: MutableSequence[
"Listing.BigQueryDatasetSource.SelectedResource"
] = proto.RepeatedField(
proto.MESSAGE,
number=2,
message="Listing.BigQueryDatasetSource.SelectedResource",
)

class RestrictedExportConfig(proto.Message):
r"""Restricted export config, used to configure restricted export
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8140,8 +8140,34 @@ def test_parse_subscription_path():
assert expected == actual


def test_table_path():
project = "squid"
dataset = "clam"
table = "whelk"
expected = "projects/{project}/datasets/{dataset}/tables/{table}".format(
project=project,
dataset=dataset,
table=table,
)
actual = AnalyticsHubServiceClient.table_path(project, dataset, table)
assert expected == actual


def test_parse_table_path():
expected = {
"project": "octopus",
"dataset": "oyster",
"table": "nudibranch",
}
path = AnalyticsHubServiceClient.table_path(**expected)

# Check that the path construction is reversible.
actual = AnalyticsHubServiceClient.parse_table_path(path)
assert expected == actual


def test_common_billing_account_path():
billing_account = "squid"
billing_account = "cuttlefish"
expected = "billingAccounts/{billing_account}".format(
billing_account=billing_account,
)
Expand All @@ -8151,7 +8177,7 @@ def test_common_billing_account_path():

def test_parse_common_billing_account_path():
expected = {
"billing_account": "clam",
"billing_account": "mussel",
}
path = AnalyticsHubServiceClient.common_billing_account_path(**expected)

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


def test_common_folder_path():
folder = "whelk"
folder = "winkle"
expected = "folders/{folder}".format(
folder=folder,
)
Expand All @@ -8171,7 +8197,7 @@ def test_common_folder_path():

def test_parse_common_folder_path():
expected = {
"folder": "octopus",
"folder": "nautilus",
}
path = AnalyticsHubServiceClient.common_folder_path(**expected)

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


def test_common_organization_path():
organization = "oyster"
organization = "scallop"
expected = "organizations/{organization}".format(
organization=organization,
)
Expand All @@ -8191,7 +8217,7 @@ def test_common_organization_path():

def test_parse_common_organization_path():
expected = {
"organization": "nudibranch",
"organization": "abalone",
}
path = AnalyticsHubServiceClient.common_organization_path(**expected)

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


def test_common_project_path():
project = "cuttlefish"
project = "squid"
expected = "projects/{project}".format(
project=project,
)
Expand All @@ -8211,7 +8237,7 @@ def test_common_project_path():

def test_parse_common_project_path():
expected = {
"project": "mussel",
"project": "clam",
}
path = AnalyticsHubServiceClient.common_project_path(**expected)

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


def test_common_location_path():
project = "winkle"
location = "nautilus"
project = "whelk"
location = "octopus"
expected = "projects/{project}/locations/{location}".format(
project=project,
location=location,
Expand All @@ -8233,8 +8259,8 @@ def test_common_location_path():

def test_parse_common_location_path():
expected = {
"project": "scallop",
"location": "abalone",
"project": "oyster",
"location": "nudibranch",
}
path = AnalyticsHubServiceClient.common_location_path(**expected)

Expand Down