Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat: add dataset access policy version attribute#2169

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Show file tree
Hide file tree
Changes fromall 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
15 changes: 13 additions & 2 deletionsgoogle/cloud/bigquery/dataset.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -589,6 +589,7 @@ class Dataset(object):
"default_rounding_mode": "defaultRoundingMode",
"resource_tags": "resourceTags",
"external_catalog_dataset_options": "externalCatalogDatasetOptions",
"access_policy_version": "accessPolicyVersion",
}

def __init__(self, dataset_ref) -> None:
Expand DownExpand Up@@ -979,6 +980,16 @@ def external_catalog_dataset_options(self, value):
self._PROPERTY_TO_API_FIELD["external_catalog_dataset_options"]
] = (value.to_api_repr() if value is not None else None)

@property
def access_policy_version(self):
return self._properties.get("accessPolicyVersion")

@access_policy_version.setter
def access_policy_version(self, value):
if not isinstance(value, int) and value is not None:
raise ValueError("Pass an integer, or None")
self._properties["accessPolicyVersion"] = value

@classmethod
def from_string(cls, full_dataset_id: str) -> "Dataset":
"""Construct a dataset from fully-qualified dataset ID.
Expand DownExpand Up@@ -1217,8 +1228,8 @@ def from_api_repr(cls, resource: Dict[str, Any]) -> "Condition":

return cls(
expression=resource["expression"],
title=resource.get("title", None),
description=resource.get("description", None),
title=resource.get("title"),
description=resource.get("description"),
)

def __eq__(self, other: object) -> bool:
Expand Down
30 changes: 30 additions & 0 deletionstests/unit/test_dataset.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1049,6 +1049,7 @@ def test_ctor_defaults(self):
self.assertIsNone(dataset.friendly_name)
self.assertIsNone(dataset.location)
self.assertEqual(dataset.is_case_insensitive, False)
self.assertIsNone(dataset.access_policy_version)

def test_ctor_string(self):
dataset = self._make_one("some-project.some_dset")
Expand DownExpand Up@@ -1423,6 +1424,35 @@ def test_external_catalog_dataset_options_to_api_repr(self):
expected = api_repr["externalCatalogDatasetOptions"]
assert result == expected

def test_access_policy_version_valid_input(self):
dataset = self._make_one(self.DS_REF)
# Valid inputs for access_policy_version are currently
# ints 1, 2, 3, and None
# We rely upon the BQ backend to validate acceptable integer
# values, rather than perform that validation in the client.
for expected in [1, 2, 3, None]:
# set property using setter and integer
dataset.access_policy_version = expected

# check getter and _properties dict
assert (
dataset.access_policy_version == expected
), f"Expected {expected} but got {dataset.access_policy_version}"
assert dataset._properties["accessPolicyVersion"] == expected

def test_access_policy_version_invalid_input(self):
dataset = self._make_one(self.DS_REF)
# Valid inputs for access_policy_version are currently
# ints 1, 2, 3, and None

with pytest.raises(ValueError):
invalid_value = "a string"
dataset.access_policy_version = invalid_value

with pytest.raises(ValueError):
invalid_value = 42.0
dataset.access_policy_version = invalid_value


class TestDatasetListItem(unittest.TestCase):
@staticmethod
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp