Class LocationPolicy.Builder (1.12.1) 
  
      
     
  
  
  
   
  
    
  
  
    
    
    
  Version 1.12.1keyboard_arrow_down  
  
 
    
    
    
    
      
  
  
  
    
public   static   final   class  LocationPolicy . Builder   extends   GeneratedMessageV3 . Builder<LocationPolicy . Builder >  implements   LocationPolicyOrBuilder  
   
   Configuration for location policy among multiple possible locations (e.g. preferences for zone selection among zones in a single region).
 Protobuf type google.cloud.compute.v1.LocationPolicy
 
  
  
  
  Static Methods
   
   
  getDescriptor() 
  
    
public   static   final   Descriptors . Descriptor   getDescriptor ()  
   
  Returns 
  
  Methods
   
   
  addRepeatedField(Descriptors.FieldDescriptor field, Object value) 
  
    
public   LocationPolicy . Builder   addRepeatedField ( Descriptors . FieldDescriptor   field ,   Object   value )  
   
  Parameters 
  
  Returns 
  
  Overrides 
  
   
  build() 
  
    
public   LocationPolicy   build ()  
   
  Returns 
  
   
  buildPartial() 
  
    
public   LocationPolicy   buildPartial ()  
   
  Returns 
  
   
  clear() 
  
    
public   LocationPolicy . Builder   clear ()  
   
  Returns 
  
  Overrides 
  
   
  clearField(Descriptors.FieldDescriptor field) 
  
    
public   LocationPolicy . Builder   clearField ( Descriptors . FieldDescriptor   field )  
   
  Parameter 
  
  Returns 
  
  Overrides 
  
   
  clearLocations() 
  
    
public   LocationPolicy . Builder   clearLocations ()  
   
  Returns 
  
   
  clearOneof(Descriptors.OneofDescriptor oneof) 
  
    
public   LocationPolicy . Builder   clearOneof ( Descriptors . OneofDescriptor   oneof )  
   
  Parameter 
  
  Returns 
  
  Overrides 
  
   
  clearTargetShape() 
  
    
public   LocationPolicy . Builder   clearTargetShape ()  
   
   Strategy for distributing VMs across zones in a region.
 Check the TargetShape enum for the list of possible values.
 optional string target_shape = 338621299;
 
  Returns 
  
   
  clone() 
  
    
public   LocationPolicy . Builder   clone ()  
   
  Returns 
  
  Overrides 
  
   
  containsLocations(String key) 
  
    
public   boolean   containsLocations ( String   key )  
   
   Location configurations mapped by location name. Currently only zone names are supported and must be represented as valid internal URLs, such as zones/us-central1-a.
 
 map<string, .google.cloud.compute.v1.LocationPolicyLocation> locations = 413423454;
 
 
  Parameter 
  
  Returns 
  
   
  getDefaultInstanceForType() 
  
    
public   LocationPolicy   getDefaultInstanceForType ()  
   
  Returns 
  
   
  getDescriptorForType() 
  
    
public   Descriptors . Descriptor   getDescriptorForType ()  
   
  Returns 
  
  Overrides 
  
   
  getLocations() 
  
    
public   Map<String , LocationPolicyLocation >  getLocations ()  
   
  
  Returns 
  
   
  getLocationsCount() 
  
    
public   int   getLocationsCount ()  
   
   Location configurations mapped by location name. Currently only zone names are supported and must be represented as valid internal URLs, such as zones/us-central1-a.
 map<string, .google.cloud.compute.v1.LocationPolicyLocation> locations = 413423454;
 
 
  Returns 
  
   
  getLocationsMap() 
  
    
public   Map<String , LocationPolicyLocation >  getLocationsMap ()  
   
   Location configurations mapped by location name. Currently only zone names are supported and must be represented as valid internal URLs, such as zones/us-central1-a.
 
 map<string, .google.cloud.compute.v1.LocationPolicyLocation> locations = 413423454;
 
 
  Returns 
  
   
  getLocationsOrDefault(String key, LocationPolicyLocation defaultValue) 
  
    
public   LocationPolicyLocation   getLocationsOrDefault ( String   key ,   LocationPolicyLocation   defaultValue )  
   
   Location configurations mapped by location name. Currently only zone names are supported and must be represented as valid internal URLs, such as zones/us-central1-a.
 
 map<string, .google.cloud.compute.v1.LocationPolicyLocation> locations = 413423454;
 
 
  Parameters 
  
  Returns 
  
   
  getLocationsOrThrow(String key) 
  
    
public   LocationPolicyLocation   getLocationsOrThrow ( String   key )  
   
   Location configurations mapped by location name. Currently only zone names are supported and must be represented as valid internal URLs, such as zones/us-central1-a.
 
 map<string, .google.cloud.compute.v1.LocationPolicyLocation> locations = 413423454;
 
 
  Parameter 
  
  Returns 
  
   
  getMutableLocations() 
  
    
public   Map<String , LocationPolicyLocation >  getMutableLocations ()  
   
  Use alternate mutation accessors instead.
 
  Returns 
  
   
  getTargetShape() 
  
    
public   String   getTargetShape ()  
   
   Strategy for distributing VMs across zones in a region.
 Check the TargetShape enum for the list of possible values.
 optional string target_shape = 338621299;
 
  Returns 
  
    
      
        Type  
        Description  
       
      
        String  
        The targetShape.
 
       
     
  
   
  getTargetShapeBytes() 
  
    
public   ByteString   getTargetShapeBytes ()  
   
   Strategy for distributing VMs across zones in a region.
 Check the TargetShape enum for the list of possible values.
 optional string target_shape = 338621299;
 
  Returns 
  
    
      
        Type  
        Description  
       
      
        ByteString  
        The bytes for targetShape.
 
       
     
  
   
  hasTargetShape() 
  
    
public   boolean   hasTargetShape ()  
   
   Strategy for distributing VMs across zones in a region.
 Check the TargetShape enum for the list of possible values.
 optional string target_shape = 338621299;
 
  Returns 
  
    
      
        Type  
        Description  
       
      
        boolean  
        Whether the targetShape field is set.
 
       
     
  
   
  internalGetFieldAccessorTable() 
  
    
protected   GeneratedMessageV3 . FieldAccessorTable   internalGetFieldAccessorTable ()  
   
  Returns 
  
  Overrides 
  
   
  internalGetMapField(int number) 
  
    
protected   MapField   internalGetMapField ( int   number )  
   
  Parameter 
  
    
      
        Name  
        Description  
       
      
        number  
        int  
       
     
  
  Returns 
  
  Overrides 
  
   
  internalGetMutableMapField(int number) 
  
    
protected   MapField   internalGetMutableMapField ( int   number )  
   
  Parameter 
  
    
      
        Name  
        Description  
       
      
        number  
        int  
       
     
  
  Returns 
  
  Overrides 
  
   
  isInitialized() 
  
    
public   final   boolean   isInitialized ()  
   
  Returns 
  
  Overrides 
  
   
  mergeFrom(LocationPolicy other) 
  
    
public   LocationPolicy . Builder   mergeFrom ( LocationPolicy   other )  
   
  Parameter 
  
  Returns 
  
   
  
  
    
public   LocationPolicy . Builder   mergeFrom ( CodedInputStream   input ,   ExtensionRegistryLite   extensionRegistry )  
   
  Parameters 
  
  Returns 
  
  Overrides 
  
  Exceptions 
  
   
  mergeFrom(Message other) 
  
    
public   LocationPolicy . Builder   mergeFrom ( Message   other )  
   
  Parameter 
  
  Returns 
  
  Overrides 
  
   
  mergeUnknownFields(UnknownFieldSet unknownFields) 
  
    
public   final   LocationPolicy . Builder   mergeUnknownFields ( UnknownFieldSet   unknownFields )  
   
  Parameter 
  
  Returns 
  
  Overrides 
  
   
  putAllLocations(Map<String,LocationPolicyLocation> values) 
  
    
public   LocationPolicy . Builder   putAllLocations ( Map<String , LocationPolicyLocation >  values )  
   
   Location configurations mapped by location name. Currently only zone names are supported and must be represented as valid internal URLs, such as zones/us-central1-a.
 
 map<string, .google.cloud.compute.v1.LocationPolicyLocation> locations = 413423454;
 
 
  Parameter 
  
  Returns 
  
   
  putLocations(String key, LocationPolicyLocation value) 
  
    
public   LocationPolicy . Builder   putLocations ( String   key ,   LocationPolicyLocation   value )  
   
   Location configurations mapped by location name. Currently only zone names are supported and must be represented as valid internal URLs, such as zones/us-central1-a.
 
 map<string, .google.cloud.compute.v1.LocationPolicyLocation> locations = 413423454;
 
 
  Parameters 
  
  Returns 
  
   
  removeLocations(String key) 
  
    
public   LocationPolicy . Builder   removeLocations ( String   key )  
   
   Location configurations mapped by location name. Currently only zone names are supported and must be represented as valid internal URLs, such as zones/us-central1-a.
 
 map<string, .google.cloud.compute.v1.LocationPolicyLocation> locations = 413423454;
 
 
  Parameter 
  
  Returns 
  
   
  setField(Descriptors.FieldDescriptor field, Object value) 
  
    
public   LocationPolicy . Builder   setField ( Descriptors . FieldDescriptor   field ,   Object   value )  
   
  Parameters 
  
  Returns 
  
  Overrides 
  
   
  setRepeatedField(Descriptors.FieldDescriptor field, int index, Object value) 
  
    
public   LocationPolicy . Builder   setRepeatedField ( Descriptors . FieldDescriptor   field ,   int   index ,   Object   value )  
   
  Parameters 
  
  Returns 
  
  Overrides 
  
   
  setTargetShape(String value) 
  
    
public   LocationPolicy . Builder   setTargetShape ( String   value )  
   
   Strategy for distributing VMs across zones in a region.
 Check the TargetShape enum for the list of possible values.
 optional string target_shape = 338621299;
 
  Parameter 
  
    
      
        Name  
        Description  
       
      
        value  
        String The targetShape to set.
 
       
     
  
  Returns 
  
   
  setTargetShapeBytes(ByteString value) 
  
    
public   LocationPolicy . Builder   setTargetShapeBytes ( ByteString   value )  
   
   Strategy for distributing VMs across zones in a region.
 Check the TargetShape enum for the list of possible values.
 optional string target_shape = 338621299;
 
  Parameter 
  
    
      
        Name  
        Description  
       
      
        value  
        ByteString The bytes for targetShape to set.
 
       
     
  
  Returns 
  
   
  setUnknownFields(UnknownFieldSet unknownFields) 
  
    
public   final   LocationPolicy . Builder   setUnknownFields ( UnknownFieldSet   unknownFields )  
   
  Parameter 
  
  Returns 
  
  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-30 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-30 UTC."],[],[]]