Package com.google.cloud.spanner
Class Backup
- java.lang.Object
-
- com.google.cloud.spanner.BackupInfo
-
- com.google.cloud.spanner.Backup
-
public class Backup extends BackupInfo
Represents a Cloud Spanner database backup.Backup
adds a layer of service related functionality overBackupInfo
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Backup.Builder
-
Nested classes/interfaces inherited from class com.google.cloud.spanner.BackupInfo
BackupInfo.State
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description com.google.api.gax.longrunning.OperationFuture<Backup,CreateBackupMetadata>
create()
Creates a backup on the server based on the source of thisBackup
instance.void
delete()
Deletes this backup on Cloud Spanner.boolean
exists()
Returnstrue
if a backup with the id of thisBackup
exists on Cloud Spanner.com.google.cloud.Policy
getIAMPolicy()
Returns the IAMPolicy
for this backup.boolean
isReady()
Returnstrue
if this backup is ready to use.com.google.api.gax.paging.Page<com.google.longrunning.Operation>
listBackupOperations()
Returns all long-running backup operations for thisBackup
.Backup
reload()
Fetches the backup's current information and returns a newBackup
instance.com.google.api.gax.longrunning.OperationFuture<Database,RestoreDatabaseMetadata>
restore(DatabaseId database)
Restores this backup to the specified database.com.google.cloud.Policy
setIAMPolicy(com.google.cloud.Policy policy)
Updates the IAM policy for this backup and returns the resulting policy.Iterable<String>
testIAMPermissions(Iterable<String> permissions)
Tests for the given permissions on this backup for the caller.Backup.Builder
toBuilder()
void
updateExpireTime()
Updates the expire time of this backup on Cloud Spanner.-
Methods inherited from class com.google.cloud.spanner.BackupInfo
equals, getDatabase, getEncryptionConfig, getEncryptionInfo, getExpireTime, getId, getInstanceId, getMaxExpireTime, getProto, getReferencingBackups, getSize, getState, getVersionTime, hashCode, toString
-
-
-
-
Method Detail
-
create
public com.google.api.gax.longrunning.OperationFuture<Backup,CreateBackupMetadata> create()
Creates a backup on the server based on the source of thisBackup
instance.
-
exists
public boolean exists()
Returnstrue
if a backup with the id of thisBackup
exists on Cloud Spanner.
-
isReady
public boolean isReady()
Returnstrue
if this backup is ready to use. The value returned by this method could be out-of-sync with the value returned byBackupInfo.getState()
, as this method will make a round-trip to the server and return a value based on the response from the server.
-
reload
public Backup reload() throws SpannerException
Fetches the backup's current information and returns a newBackup
instance. It does not update this instance.- Throws:
SpannerException
-
delete
public void delete() throws SpannerException
Deletes this backup on Cloud Spanner.- Throws:
SpannerException
-
updateExpireTime
public void updateExpireTime()
Updates the expire time of this backup on Cloud Spanner. If thisBackup
does not have an expire time, the method will throw anIllegalStateException
.
-
restore
public com.google.api.gax.longrunning.OperationFuture<Database,RestoreDatabaseMetadata> restore(DatabaseId database)
Restores this backup to the specified database. The database must not already exist and will be created by this call. The database may be created in a different instance than where the backup is stored.
-
listBackupOperations
public com.google.api.gax.paging.Page<com.google.longrunning.Operation> listBackupOperations()
Returns all long-running backup operations for thisBackup
.
-
getIAMPolicy
public com.google.cloud.Policy getIAMPolicy()
Returns the IAMPolicy
for this backup.
-
setIAMPolicy
public com.google.cloud.Policy setIAMPolicy(com.google.cloud.Policy policy)
Updates the IAM policy for this backup and returns the resulting policy. It is highly recommended to first get the current policy and base the updated policy on the returned policy. SeePolicy.Builder.setEtag(String)
for information on the recommended read-modify-write cycle.
-
testIAMPermissions
public Iterable<String> testIAMPermissions(Iterable<String> permissions)
Tests for the given permissions on this backup for the caller.- Parameters:
permissions
- the permissions to test for. Permissions with wildcards (such as '*', 'spanner.*', 'spanner.instances.*') are not allowed.- Returns:
- the subset of the tested permissions that the caller is allowed.
-
toBuilder
public Backup.Builder toBuilder()
-
-