Send feedback
  
   
 
  
    
      Class Instance (6.54.0)
    
    
       
    
    
      
      Stay organized with collections
     
    
      
      Save and categorize content based on your preferences.
     
    
  
      
     
  
  
   
  
    
  
  
    
    
    
  Version 6.54.0keyboard_arrow_down  
  
 
    
    
     
    
    
    
    
    
      
  
  
  
    
public   class  Instance   extends   InstanceInfo  
   
  Represents a Cloud Spanner Instance. Instance adds a layer of service related
 functionality over InstanceInfo.
 
  
  
  Methods
   
   
  createDatabase(String databaseId, Iterable<String> statements) 
  
    
public   OperationFuture<Database , CreateDatabaseMetadata >  createDatabase ( String   databaseId ,   Iterable<String>   statements )  
   
  Creates a new database in this instance.
 
  
    
      
        Parameters  
       
      
        Name  
        Description  
       
      
        databaseId 
        String the id of the database which will be created. It must conform to the regular
     expression a-z *[a-z0-9] and be between 2 and 30 characters in length
 
       
      
        statements 
        Iterable <String >DDL statements to run while creating the database, for example CREATE
     TABLE MyTable ( ... ). This should not include CREATE DATABASE statement.
 
       
     
  
  
  
   
  delete() 
  
   
  getBackup(String backupId) 
  
    
public   Backup   getBackup ( String   backupId )  
   
  Returns the backup with the given id on this instance.
 
  
    
      
        Parameter  
       
      
        Name  
        Description  
       
      
        backupId 
        String  
       
     
  
  
    
      
        Returns  
       
      
        Type  
        Description  
       
      
        Backup  
         
       
     
  
   
  getDatabase(String databaseId) 
  
    
public   Database   getDatabase ( String   databaseId )  
   
  
    
      
        Parameter  
       
      
        Name  
        Description  
       
      
        databaseId 
        String  
       
     
  
  
   
  getIAMPolicy() 
  
    
public   Policy   getIAMPolicy ()  
   
  Returns the IAM Policy  for this instance.
 
  
    
      
        Returns  
       
      
        Type  
        Description  
       
      
        com.google.cloud.Policy  
         
       
     
  
   
  listBackupOperations(Options.ListOption[] options) 
  
    
public   Page<Operation>   listBackupOperations ( Options . ListOption []   options )  
   
  Returns the long-running backup operations on this instance.
 
  
  
   
  listBackups(Options.ListOption[] options) 
  
    
public   Page<Backup>   listBackups ( Options . ListOption []   options )  
   
  Returns the backups belonging to this instance.
 
  
  
   
  listDatabaseOperations(Options.ListOption[] options) 
  
    
public   Page<Operation>   listDatabaseOperations ( Options . ListOption []   options )  
   
  Returns the long-running database operations on this instance.
 
  
  
   
  listDatabases(Options.ListOption[] options) 
  
    
public   Page<Database>   listDatabases ( Options . ListOption []   options )  
   
  
  
   
  reload() 
  
  
   
  setIAMPolicy(Policy policy) 
  
    
public   Policy   setIAMPolicy ( Policy   policy )  
   
  Updates the IAM policy for this instance and returns the resulting policy. It is highly
 recommended to first get the current policy and base the updated policy on the returned policy.
 See Policy.Builder#setEtag(String)  for information on the recommended read-modify-write
 cycle.
 
  
    
      
        Parameter  
       
      
        Name  
        Description  
       
      
        policy 
        com.google.cloud.Policy  
       
     
  
  
    
      
        Returns  
       
      
        Type  
        Description  
       
      
        com.google.cloud.Policy  
         
       
     
  
   
  testIAMPermissions(Iterable<String> permissions) 
  
    
public   Iterable<String>   testIAMPermissions ( Iterable<String>   permissions )  
   
  Tests for the given permissions on this instance for the caller.
 
  
    
      
        Parameter  
       
      
        Name  
        Description  
       
      
        permissions 
        Iterable <String >the permissions to test for. Permissions with wildcards (such as '',
     'spanner. ', 'spanner.instances.*') are not allowed.
 
       
     
  
  
    
      
        Returns  
       
      
        Type  
        Description  
       
      
        Iterable <String > 
        the subset of the tested permissions that the caller is allowed.
 
       
     
  
   
  toBuilder() 
  
    
public   Instance . Builder   toBuilder ()  
   
  
  Overrides 
  
   
  update(InstanceInfo.InstanceField[] fieldsToUpdate) 
  
    
public   OperationFuture<Instance , UpdateInstanceMetadata >  update ( InstanceInfo . InstanceField []   fieldsToUpdate )  
   
  
  
 
     
    
  
  
  
     
  
 
  
    
    
      
    
     
  
       
         
  
  
    
    Send feedback
  
   
 
       
    
    
  
  
 
  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.
 
 
  
  
    
    
    
      
  
  
    Need to tell us more?
  
   
 
     
  
  
    
      [[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-10-30 UTC."],[],[]]