in common/data_mesh/src/data_mesh_client.py [0:0]
def create_policy_tag(
self,
project: str,
policy_tag_spec: dmt.PolicyTag,
taxonomy_name: str,
parent_policy: str = "",
existing_policy_tags: Optional[Dict[str, str]] = None) -> None:
"""Create the specified Policy Tag.
Args:
project: String representing project to create resources in.
policy_tag_spec: data_mesh_types.PolicyTag that specifies how to
create the policy tag.
taxonomy_name: String that specifies the taxonomy the policy tag
belongs to.
parent_policy: Parent policy tag. Empty for top level policy tags.
existing_policy_tags: Dictionary of display_name:unique name
containing the existing policy tags.
"""
existing_policy_tag_name = self._make_ready_to_create(
policy_tag_spec, existing_policy_tags)
if not existing_policy_tag_name:
existing_policy_tag_name = self._create_resource(
policy_tag_spec, taxonomy_name, parent_policy=parent_policy)
self._set_policy_tag_unmasked_readers(
existing_policy_tag_name, policy_tag_spec.unmasked_readers)
# Oddly, BQ data policies are direct children of the project, despite
# having no apparent way to reuse data policies across policy tags.
existing_data_policies = self._list_resources(
dmt.DataPolicy, self._parent_project(project))
for data_policy in policy_tag_spec.data_policies:
self.create_data_policy(project, data_policy,
existing_policy_tag_name,
existing_data_policies)
for child_policy_tag in policy_tag_spec.child_policy_tags:
self.create_policy_tag(project, child_policy_tag, taxonomy_name,
existing_policy_tag_name,
existing_policy_tags)