Skip to content
Merged
Changes from all 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
11 changes: 11 additions & 0 deletions storage/cloud-client/bucket_lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def set_retention_policy(bucket_name, retention_period):
# [START storage_set_retention_policy]
# bucket_name = "my-bucket"
# retention_period = 10

storage_client = storage.Client()
bucket = storage_client.bucket(bucket_name)

Expand All @@ -40,6 +41,7 @@ def remove_retention_policy(bucket_name):
"""Removes the retention policy on a given bucket"""
# [START storage_remove_retention_policy]
# bucket_name = "my-bucket"

storage_client = storage.Client()
bucket = storage_client.bucket(bucket_name)
bucket.reload()
Expand All @@ -60,6 +62,7 @@ def lock_retention_policy(bucket_name):
"""Locks the retention policy on a given bucket"""
# [START storage_lock_retention_policy]
# bucket_name = "my-bucket"

storage_client = storage.Client()
# get_bucket gets the current metageneration value for the bucket,
# required by lock_retention_policy.
Expand All @@ -79,6 +82,7 @@ def get_retention_policy(bucket_name):
"""Gets the retention policy on a given bucket"""
# [START storage_get_retention_policy]
# bucket_name = "my-bucket"

storage_client = storage.Client()
bucket = storage_client.bucket(bucket_name)
bucket.reload()
Expand All @@ -99,6 +103,7 @@ def set_temporary_hold(bucket_name, blob_name):
# [START storage_set_temporary_hold]
# bucket_name = "my-bucket"
# blob_name = "my-blob"

storage_client = storage.Client()
bucket = storage_client.bucket(bucket_name)
blob = bucket.blob(blob_name)
Expand All @@ -115,6 +120,7 @@ def release_temporary_hold(bucket_name, blob_name):
# [START storage_release_temporary_hold]
# bucket_name = "my-bucket"
# blob_name = "my-blob"

storage_client = storage.Client()
bucket = storage_client.bucket(bucket_name)
blob = bucket.blob(blob_name)
Expand All @@ -131,6 +137,7 @@ def set_event_based_hold(bucket_name, blob_name):
# [START storage_set_event_based_hold]
# bucket_name = "my-bucket"
# blob_name = "my-blob"

storage_client = storage.Client()
bucket = storage_client.bucket(bucket_name)
blob = bucket.blob(blob_name)
Expand All @@ -147,6 +154,7 @@ def release_event_based_hold(bucket_name, blob_name):
# [START storage_release_event_based_hold]
# bucket_name = "my-bucket"
# blob_name = "my-blob"

storage_client = storage.Client()
bucket = storage_client.bucket(bucket_name)
blob = bucket.blob(blob_name)
Expand All @@ -162,6 +170,7 @@ def enable_default_event_based_hold(bucket_name):
"""Enables the default event based hold on a given bucket"""
# [START storage_enable_default_event_based_hold]
# bucket_name = "my-bucket"

storage_client = storage.Client()
bucket = storage_client.bucket(bucket_name)

Expand All @@ -176,6 +185,7 @@ def disable_default_event_based_hold(bucket_name):
"""Disables the default event based hold on a given bucket"""
# [START storage_disable_default_event_based_hold]
# bucket_name = "my-bucket"

storage_client = storage.Client()
bucket = storage_client.bucket(bucket_name)

Expand All @@ -190,6 +200,7 @@ def get_default_event_based_hold(bucket_name):
"""Gets the default event based hold on a given bucket"""
# [START storage_get_default_event_based_hold]
# bucket_name = "my-bucket"

storage_client = storage.Client()
bucket = storage_client.bucket(bucket_name)
bucket.reload()
Expand Down