public Bucket enableDefaultEventBasedHold ( String bucketName ) throws StorageException { // [START storage_enable_default_event_based_hold] // Instantiate a Google Cloud Storage client Storage storage = StorageOptions . getDefaultInstance ( ) . getService ( ) ; // The name of a bucket, e.g. "my-bucket" // String bucketName = "my-bucket"; Bucket bucket = storage . update ( BucketInfo . newBuilder ( bucketName ) . setDefaultEventBasedHold ( true ) . build ( ) ) ; System . out . println ( "Default event-based hold was enabled for " + bucketName ) ; // [END storage_enable_default_event_based_hold] return bucket ; }
Example of how to enable default event - based hold for a bucket