Class Bucket.Builder (2.58.1) 
  
  
  
   
  
    
  
  
    
    
    
    
  Version 2.58.1keyboard_arrow_down  
  
 
    
    
    
    
      
  
  
  
    
public   static   class  Bucket . Builder   extends   BucketInfo . Builder  
  
  
  
  Methods
   
  build() 
  
  Creates a BucketInfo object.
    
      
        Returns  
      
        Type Description  
      
        Bucket  
     
  
  Overrides 
  
  clearCustomerManagedEncryptionEnforcementConfig() 
  
    
public   Bucket . Builder   clearCustomerManagedEncryptionEnforcementConfig ()  
  
  clearCustomerSuppliedEncryptionEnforcementConfig() 
  
    
public   Bucket . Builder   clearCustomerSuppliedEncryptionEnforcementConfig ()  
  
  clearGoogleManagedEncryptionEnforcementConfig() 
  
    
public   Bucket . Builder   clearGoogleManagedEncryptionEnforcementConfig ()  
  
  deleteLifecycleRules() 
  
    
public   Bucket . Builder   deleteLifecycleRules ()  
  Deletes the lifecycle rules of this bucket.
Overrides 
  
  setAcl(Iterable<Acl> acl) 
  
    
public   Bucket . Builder   setAcl ( Iterable<Acl>   acl )  
  Sets the bucket's access control configuration.
Overrides 
  
  setAutoclass(BucketInfo.Autoclass autoclass) 
  
    
public   Bucket . Builder   setAutoclass ( BucketInfo . Autoclass   autoclass )  
  
  
  Overrides 
  
  setCors(Iterable<Cors> cors) 
  
    
public   Bucket . Builder   setCors ( Iterable<Cors>   cors )  
  Sets the bucket's Cross-Origin Resource Sharing (CORS) configuration.
Overrides 
  
  setCustomPlacementConfig(BucketInfo.CustomPlacementConfig customPlacementConfig) 
  
    
public   Bucket . Builder   setCustomPlacementConfig ( BucketInfo . CustomPlacementConfig   customPlacementConfig )  
  
  
  Overrides 
  
  setCustomerManagedEncryptionEnforcementConfig(BucketInfo.CustomerManagedEncryptionEnforcementConfig customerManagedEncryptionEnforcementConfig) 
  
    
public   Bucket . Builder   setCustomerManagedEncryptionEnforcementConfig ( BucketInfo . CustomerManagedEncryptionEnforcementConfig   customerManagedEncryptionEnforcementConfig )  
  
  
  Overrides 
  
  setCustomerSuppliedEncryptionEnforcementConfig(BucketInfo.CustomerSuppliedEncryptionEnforcementConfig customerSuppliedEncryptionEnforcementConfig) 
  
    
public   Bucket . Builder   setCustomerSuppliedEncryptionEnforcementConfig ( BucketInfo . CustomerSuppliedEncryptionEnforcementConfig   customerSuppliedEncryptionEnforcementConfig )  
  
  
  Overrides 
  
  setDefaultAcl(Iterable<Acl> acl) 
  
    
public   Bucket . Builder   setDefaultAcl ( Iterable<Acl>   acl )  
  Sets the default access control configuration to apply to bucket's blobs when no other
 configuration is specified.
Overrides 
  
  setDefaultEventBasedHold(Boolean defaultEventBasedHold) 
  
    
public   Bucket . Builder   setDefaultEventBasedHold ( Boolean   defaultEventBasedHold )  
  Sets the default event-based hold for this bucket.
    
      
        Parameter  
      
        Name Description  
      
        defaultEventBasedHoldBoolean  
     
  
  
  Overrides 
  
  setDefaultKmsKeyName(String defaultKmsKeyName) 
  
    
public   Bucket . Builder   setDefaultKmsKeyName ( String   defaultKmsKeyName )  
  Sets the default Cloud KMS key name for this bucket.
    
      
        Parameter  
      
        Name Description  
      
        defaultKmsKeyNameString  
     
  
  
  Overrides 
  
  setDeleteRules(Iterable<? extends BucketInfo.DeleteRule> rules) (deprecated) 
  
    
public   Bucket . Builder   setDeleteRules ( Iterable <?   extends   BucketInfo . DeleteRule >  rules )  
  Deprecated.  Use #setLifecycleRules(Iterable)  instead, as in 
     setLifecycleRules(Collections.singletonList( new BucketInfo.LifecycleRule(
     LifecycleAction.newDeleteAction(), LifecycleCondition.newBuilder().setAge(5).build()))); 
Sets the bucket's lifecycle configuration as a number of delete rules.
    
      
        Parameter  
      
        Name Description  
      
        rulesIterable <? extends com.google.cloud.storage.BucketInfo.DeleteRule > 
     
  
  
  Overrides 
  
  setGoogleManagedEncryptionEnforcementConfig(BucketInfo.GoogleManagedEncryptionEnforcementConfig googleManagedEncryptionEnforcementConfig) 
  
    
public   Bucket . Builder   setGoogleManagedEncryptionEnforcementConfig ( BucketInfo . GoogleManagedEncryptionEnforcementConfig   googleManagedEncryptionEnforcementConfig )  
  
  
  Overrides 
  
  setHierarchicalNamespace(BucketInfo.HierarchicalNamespace hierarchicalNamespace) 
  
    
public   Bucket . Builder   setHierarchicalNamespace ( BucketInfo . HierarchicalNamespace   hierarchicalNamespace )  
  
  
  Overrides 
  
  setIamConfiguration(BucketInfo.IamConfiguration iamConfiguration) 
  
    
public   Bucket . Builder   setIamConfiguration ( BucketInfo . IamConfiguration   iamConfiguration )  
  Sets the IamConfiguration to specify whether IAM access should be enabled.
Overrides 
  
  setIndexPage(String indexPage) 
  
    
public   Bucket . Builder   setIndexPage ( String   indexPage )  
  Sets the bucket's website index page. Behaves as the bucket's directory index where missing
 blobs are treated as potential directories.
    
      
        Parameter  
      
        Name Description  
      
        indexPageString  
     
  
  
  Overrides 
  
  setIpFilter(BucketInfo.IpFilter ipFilter) 
  
    
public   Bucket . Builder   setIpFilter ( BucketInfo . IpFilter   ipFilter )  
  
  
  Overrides 
  
  setLabels(@Nullable Map<@NonNull String,@Nullable String> labels) 
  
    
public   Bucket . Builder   setLabels ( @Nullable   Map <@NonNull   String , @Nullable   String >  labels )  
  Sets the label of this bucket.
    
      
        Parameter  
      
        Name Description  
      
        labels@org.checkerframework.checker.nullness.qual.Nullable java.util.Map <@org.checkerframework.checker.nullness.qual.NonNull java.lang.String ,@org.checkerframework.checker.nullness.qual.Nullable java.lang.String > 
     
  
  
  Overrides 
  
  setLifecycleRules(Iterable<? extends BucketInfo.LifecycleRule> rules) 
  
    
public   Bucket . Builder   setLifecycleRules ( Iterable <?   extends   BucketInfo . LifecycleRule >  rules )  
  Sets the bucket's lifecycle configuration as a number of lifecycle rules, consisting of an
 action and a condition.
    
      
        Parameter  
      
        Name Description  
      
        rulesIterable <? extends com.google.cloud.storage.BucketInfo.LifecycleRule > 
     
  
  
  Overrides 
  
  setLocation(String location) 
  
    
public   Bucket . Builder   setLocation ( String   location )  
  Sets the bucket's location. Data for blobs in the bucket resides in physical storage within
 this region or regions. A list of supported values is available here .
    
      
        Parameter  
      
        Name Description  
      
        locationString  
     
  
  
  Overrides 
  
  setLogging(BucketInfo.Logging logging) 
  
    
public   Bucket . Builder   setLogging ( BucketInfo . Logging   logging )  
  
  
  Overrides 
  
  setName(String name) 
  
    
public   Bucket . Builder   setName ( String   name )  
  
  
    
      
        Parameter  
      
        Name Description  
      
        nameString  
     
  
  
  Overrides 
  
  setNotFoundPage(String notFoundPage) 
  
    
public   Bucket . Builder   setNotFoundPage ( String   notFoundPage )  
  Sets the custom object to return when a requested resource is not found.
    
      
        Parameter  
      
        Name Description  
      
        notFoundPageString  
     
  
  
  Overrides 
  
  setRequesterPays(Boolean requesterPays) 
  
    
public   Bucket . Builder   setRequesterPays ( Boolean   requesterPays )  
  Sets whether a user accessing the bucket or an object it contains should assume the transit
 costs related to the access.
    
      
        Parameter  
      
        Name Description  
      
        requesterPaysBoolean  
     
  
  
  Overrides 
  
  setRetentionPeriod(Long retentionPeriod) (deprecated) 
  
    
public   Bucket . Builder   setRetentionPeriod ( Long   retentionPeriod )  
  Deprecated.  Use #setRetentionPeriodDuration(Duration)  
If policy is not locked this value can be cleared, increased, and decreased. If policy is
 locked the retention period can only be increased.
    
      
        Parameter  
      
        Name Description  
      
        retentionPeriodLong  
     
  
  
  Overrides 
  
  setRetentionPeriodDuration(Duration retentionPeriod) 
  
    
public   BucketInfo . Builder   setRetentionPeriodDuration ( Duration   retentionPeriod )  
  If policy is not locked this value can be cleared, increased, and decreased. If policy is
 locked the retention period can only be increased.
    
      
        Parameter  
      
        Name Description  
      
        retentionPeriodDuration  
     
  
  
  Overrides 
  
  setRpo(Rpo rpo) 
  
    
public   Bucket . Builder   setRpo ( Rpo   rpo )  
  Sets the bucket's Recovery Point Objective (RPO). This can only be set for a dual-region
 bucket, and determines the speed at which data will be replicated between regions. See the
 Rpo class for supported values, and here  for additional
 details.
    
      
        Parameter  
      
        Name Description  
      
        rpoRpo  
     
  
  
  Overrides 
  
  setSoftDeletePolicy(BucketInfo.SoftDeletePolicy softDeletePolicy) 
  
    
public   Bucket . Builder   setSoftDeletePolicy ( BucketInfo . SoftDeletePolicy   softDeletePolicy )  
  
  
  Overrides 
  
  setStorageClass(StorageClass storageClass) 
  
    
public   Bucket . Builder   setStorageClass ( StorageClass   storageClass )  
  Sets the bucket's storage class. This defines how blobs in the bucket are stored and
 determines the SLA and the cost of storage. A list of supported values is available here .
Overrides 
  
  setVersioningEnabled(Boolean enable) 
  
    
public   Bucket . Builder   setVersioningEnabled ( Boolean   enable )  
  Sets whether versioning should be enabled for this bucket. When set to true, versioning is
 fully enabled.
    
      
        Parameter  
      
        Name Description  
      
        enableBoolean  
     
  
  
  Overrides 
  
 
     
    
  
  
  
     
  
    
    
      
       
    
    
  
  
 
  Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License , and code samples are licensed under the Apache 2.0 License . For details, see the Google Developers Site Policies . Java is a registered trademark of Oracle and/or its affiliates.
  Last updated 2025-10-29 UTC.
 
 
  
  
  
    
      [[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-10-29 UTC."],[],[]]