Using Console
Using CLI
<retention_period>
with the duration for which you want to retain the objects in the bucket. For example, if you want to retain the objects in the bucket for 365 days, then you can set the retention period to 1 year. You can specify the retention period in seconds, minutes, hours, days, months, or years. For example, to set the retention period to 1 year, you can use the following command:
<bucket_name>
with the name of the bucket for which you want to set the retention policy.
Using Python
GOOGLE_APPLICATION_CREDENTIALS
environment variable to the path of the JSON key file.
Bucket
class in the google-cloud-storage
module. You can set the retention policy to a specific number of days using the retention_period
parameter.
retention_period
as per your requirement.
retentionPolicy
field.