Skip to content
This repository was archived by the owner on Mar 31, 2026. It is now read-only.

Commit febece7

Browse files
authored
feat: Custom Placement Config Dual Region Support (#819)
* refactor: dual-region API update * test coverage
1 parent fda745e commit febece7

File tree

7 files changed

+77
-14
lines changed

7 files changed

+77
-14
lines changed

google/cloud/storage/bucket.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2418,13 +2418,27 @@ def location(self, value):
24182418
warnings.warn(_LOCATION_SETTER_MESSAGE, DeprecationWarning, stacklevel=2)
24192419
self._location = value
24202420

2421+
@property
2422+
def data_locations(self):
2423+
"""Retrieve the list of regional locations for custom dual-region buckets.
2424+
2425+
See https://cloud.google.com/storage/docs/json_api/v1/buckets and
2426+
https://cloud.google.com/storage/docs/locations
2427+
2428+
Returns ``None`` if the property has not been set before creation,
2429+
if the bucket's resource has not been loaded from the server,
2430+
or if the bucket is not a dual-regions bucket.
2431+
:rtype: list of str or ``NoneType``
2432+
"""
2433+
custom_placement_config = self._properties.get("customPlacementConfig", {})
2434+
return custom_placement_config.get("dataLocations")
2435+
24212436
@property
24222437
def location_type(self):
2423-
"""Retrieve or set the location type for the bucket.
2438+
"""Retrieve the location type for the bucket.
24242439
24252440
See https://cloud.google.com/storage/docs/storage-classes
24262441
2427-
:setter: Set the location type for this bucket.
24282442
:getter: Gets the the location type for this bucket.
24292443
24302444
:rtype: str or ``NoneType``

google/cloud/storage/client.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change