@@ -801,6 +801,21 @@ def cors(self, entries):
801801 """
802802 self ._patch_property ('cors' , entries )
803803
804+ default_event_based_hold = _scalar_property ('defaultEventBasedHold' )
805+ """Are uploaded objects automatically placed under an even-based hold?
806+
807+ If True, uploaded objects will be placed under an event-based hold to
808+ be released at a future time. When released an object will then begin
809+ the retention period determined by the policy retention period for the
810+ object bucket.
811+
812+ See https://cloud.google.com/storage/docs/json_api/v1/buckets
813+
814+ If the property is not set locally, returns ``None``.
815+
816+ :rtype: bool or ``NoneType``
817+ """
818+
804819 @property
805820 def default_kms_key_name (self ):
806821 """Retrieve / set default KMS encryption key for objects in the bucket.
@@ -1055,6 +1070,64 @@ def project_number(self):
10551070 if project_number is not None :
10561071 return int (project_number )
10571072
1073+ @property
1074+ def retention_policy_effective_time (self ):
1075+ """Retrieve the effective time of the bucket's retention policy.
1076+
1077+ :rtype: datetime.datetime or ``NoneType``
1078+ :returns: point-in time at which the bucket's retention policy is
1079+ effective, or ``None`` if the property is not
1080+ set locally.
1081+ """
1082+ policy = self ._properties .get ('retentionPolicy' )
1083+ if policy is not None :
1084+ timestamp = policy .get ('effectiveTime' )
1085+ if timestamp is not None :
1086+ return _rfc3339_to_datetime (timestamp )
1087+
1088+ @property
1089+ def retention_policy_locked (self ):
1090+ """Retrieve whthere the bucket's retention policy is locked.
1091+
1092+ :rtype: bool
1093+ :returns: True if the bucket's policy is locked, or else False
1094+ if the policy is not locked, or the property is not
1095+ set locally.
1096+ """
1097+ policy = self ._properties .get ('retentionPolicy' )
1098+ if policy is not None :
1099+ return policy .get ('isLocked' )
1100+
1101+ @property
1102+ def retention_period (self ):
1103+ """Retrieve or set the retention period for items in the bucket.
1104+
1105+ :rtype: int or ``NoneType``
1106+ :returns: number of seconds to retain items after upload or release
1107+ from event-based lock, or ``None`` if the property is not
1108+ set locally.
1109+ """
1110+ policy = self ._properties .get ('retentionPolicy' )
1111+ if policy is not None :
1112+ period = policy .get ('retentionPeriod' )
1113+ if period is not None :
1114+ return int (period )
1115+
1116+ @retention_period .setter
1117+ def retention_period (self , value ):
1118+ """Set the retention period for items in the bucket.
1119+
1120+ :type value: int
1121+ :param value:
1122+ number of seconds to retain items after upload or release from
1123+ event-based lock.
1124+
1125+ :raises ValueError: if the bucket's retention policy is locked.
1126+ """
1127+ policy = self ._properties .setdefault ('retentionPolicy' , {})
1128+ policy ['retentionPeriod' ] = str (value )
1129+ self ._patch_property ('retentionPolicy' , policy )
1130+
10581131 @property
10591132 def self_link (self ):
10601133 """Retrieve the URI for the bucket.
0 commit comments