@@ -791,6 +791,21 @@ def cors(self, entries):
791791 """
792792 self ._patch_property ('cors' , entries )
793793
794+ default_event_based_hold = _scalar_property ('defaultEventBasedHold' )
795+ """Are uploaded objects automatically placed under an even-based hold?
796+
797+ If True, uploaded objects will be placed under an event-based hold to
798+ be released at a future time. When released an object will then begin
799+ the retention period determined by the policy retention period for the
800+ object bucket.
801+
802+ See https://cloud.google.com/storage/docs/json_api/v1/buckets
803+
804+ If the property is not set locally, returns ``None``.
805+
806+ :rtype: bool or ``NoneType``
807+ """
808+
794809 @property
795810 def default_kms_key_name (self ):
796811 """Retrieve / set default KMS encryption key for objects in the bucket.
@@ -1019,6 +1034,64 @@ def project_number(self):
10191034 if project_number is not None :
10201035 return int (project_number )
10211036
1037+ @property
1038+ def retention_policy_effective_time (self ):
1039+ """Retrieve the effective time of the bucket's retention policy.
1040+
1041+ :rtype: datetime.datetime or ``NoneType``
1042+ :returns: point-in time at which the bucket's retention policy is
1043+ effective, or ``None`` if the property is not
1044+ set locally.
1045+ """
1046+ policy = self ._properties .get ('retentionPolicy' )
1047+ if policy is not None :
1048+ timestamp = policy .get ('effectiveTime' )
1049+ if timestamp is not None :
1050+ return _rfc3339_to_datetime (timestamp )
1051+
1052+ @property
1053+ def retention_policy_locked (self ):
1054+ """Retrieve whthere the bucket's retention policy is locked.
1055+
1056+ :rtype: bool
1057+ :returns: True if the bucket's policy is locked, or else False
1058+ if the policy is not locked, or the property is not
1059+ set locally.
1060+ """
1061+ policy = self ._properties .get ('retentionPolicy' )
1062+ if policy is not None :
1063+ return policy .get ('isLocked' )
1064+
1065+ @property
1066+ def retention_period (self ):
1067+ """Retrieve or set the retention period for items in the bucket.
1068+
1069+ :rtype: int or ``NoneType``
1070+ :returns: number of seconds to retain items after upload or release
1071+ from event-based lock, or ``None`` if the property is not
1072+ set locally.
1073+ """
1074+ policy = self ._properties .get ('retentionPolicy' )
1075+ if policy is not None :
1076+ period = policy .get ('retentionPeriod' )
1077+ if period is not None :
1078+ return int (period )
1079+
1080+ @retention_period .setter
1081+ def retention_period (self , value ):
1082+ """Set the retention period for items in the bucket.
1083+
1084+ :type value: int
1085+ :param value:
1086+ number of seconds to retain items after upload or release from
1087+ event-based lock.
1088+
1089+ :raises ValueError: if the bucket's retention policy is locked.
1090+ """
1091+ policy = self ._properties .setdefault ('retentionPolicy' , {})
1092+ policy ['retentionPeriod' ] = str (value )
1093+ self ._patch_property ('retentionPolicy' , policy )
1094+
10221095 @property
10231096 def self_link (self ):
10241097 """Retrieve the URI for the bucket.
0 commit comments