@Generated(value="by gapic-generator-java") public class DatabaseAdminClient extends Object implements BackgroundResource
The Cloud Spanner Database Admin API can be used to: * create, drop, and list databases * update the schema of pre-existing databases * create, delete and list backups for a database * restore a database from an existing backup
This class provides the ability to make remote calls to the backing service through method calls that map to API methods. Sample code to get started:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
DatabaseName name = DatabaseName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]");
Database response = databaseAdminClient.getDatabase(name);
}
Note: close() needs to be called on the DatabaseAdminClient object to clean up resources such as threads. In the example above, try-with-resources is used, which automatically calls close().
The surface of this class includes several types of Java methods for each of the API's methods:
See the individual methods for example code.
Many parameters require resource names to be formatted in a particular way. To assist with these names, this class includes a format method for each type of name, and additionally a parse method to extract the individual identifiers contained within names that are returned.
This class can be customized by passing in a custom instance of DatabaseAdminSettings to create(). For example:
To customize credentials:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
DatabaseAdminSettings databaseAdminSettings =
DatabaseAdminSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create(databaseAdminSettings);
To customize the endpoint:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
DatabaseAdminSettings databaseAdminSettings =
DatabaseAdminSettings.newBuilder().setEndpoint(myEndpoint).build();
DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create(databaseAdminSettings);
Please refer to the GitHub repository's samples for more quickstart code snippets.
Modifier and Type | Class and Description |
---|---|
static class |
DatabaseAdminClient.ListBackupOperationsFixedSizeCollection |
static class |
DatabaseAdminClient.ListBackupOperationsPage |
static class |
DatabaseAdminClient.ListBackupOperationsPagedResponse |
static class |
DatabaseAdminClient.ListBackupsFixedSizeCollection |
static class |
DatabaseAdminClient.ListBackupsPage |
static class |
DatabaseAdminClient.ListBackupsPagedResponse |
static class |
DatabaseAdminClient.ListDatabaseOperationsFixedSizeCollection |
static class |
DatabaseAdminClient.ListDatabaseOperationsPage |
static class |
DatabaseAdminClient.ListDatabaseOperationsPagedResponse |
static class |
DatabaseAdminClient.ListDatabasesFixedSizeCollection |
static class |
DatabaseAdminClient.ListDatabasesPage |
static class |
DatabaseAdminClient.ListDatabasesPagedResponse |
Modifier | Constructor and Description |
---|---|
protected |
DatabaseAdminClient(DatabaseAdminSettings settings)
Constructs an instance of DatabaseAdminClient, using the given settings.
|
protected |
DatabaseAdminClient(DatabaseAdminStub stub) |
Modifier and Type | Method and Description |
---|---|
boolean |
awaitTermination(long duration,
TimeUnit unit) |
void |
close() |
OperationFuture<Backup,CopyBackupMetadata> |
copyBackupAsync(CopyBackupRequest request)
Starts copying a Cloud Spanner Backup.
|
OperationFuture<Backup,CopyBackupMetadata> |
copyBackupAsync(InstanceName parent,
String backupId,
BackupName sourceBackup,
Timestamp expireTime)
Starts copying a Cloud Spanner Backup.
|
OperationFuture<Backup,CopyBackupMetadata> |
copyBackupAsync(InstanceName parent,
String backupId,
String sourceBackup,
Timestamp expireTime)
Starts copying a Cloud Spanner Backup.
|
OperationFuture<Backup,CopyBackupMetadata> |
copyBackupAsync(String parent,
String backupId,
BackupName sourceBackup,
Timestamp expireTime)
Starts copying a Cloud Spanner Backup.
|
OperationFuture<Backup,CopyBackupMetadata> |
copyBackupAsync(String parent,
String backupId,
String sourceBackup,
Timestamp expireTime)
Starts copying a Cloud Spanner Backup.
|
UnaryCallable<CopyBackupRequest,Operation> |
copyBackupCallable()
Starts copying a Cloud Spanner Backup.
|
OperationCallable<CopyBackupRequest,Backup,CopyBackupMetadata> |
copyBackupOperationCallable()
Starts copying a Cloud Spanner Backup.
|
static DatabaseAdminClient |
create()
Constructs an instance of DatabaseAdminClient with default settings.
|
static DatabaseAdminClient |
create(DatabaseAdminSettings settings)
Constructs an instance of DatabaseAdminClient, using the given settings.
|
static DatabaseAdminClient |
create(DatabaseAdminStub stub)
Constructs an instance of DatabaseAdminClient, using the given stub for making calls.
|
OperationFuture<Backup,CreateBackupMetadata> |
createBackupAsync(CreateBackupRequest request)
Starts creating a new Cloud Spanner Backup.
|
OperationFuture<Backup,CreateBackupMetadata> |
createBackupAsync(InstanceName parent,
Backup backup,
String backupId)
Starts creating a new Cloud Spanner Backup.
|
OperationFuture<Backup,CreateBackupMetadata> |
createBackupAsync(String parent,
Backup backup,
String backupId)
Starts creating a new Cloud Spanner Backup.
|
UnaryCallable<CreateBackupRequest,Operation> |
createBackupCallable()
Starts creating a new Cloud Spanner Backup.
|
OperationCallable<CreateBackupRequest,Backup,CreateBackupMetadata> |
createBackupOperationCallable()
Starts creating a new Cloud Spanner Backup.
|
OperationFuture<Database,CreateDatabaseMetadata> |
createDatabaseAsync(CreateDatabaseRequest request)
Creates a new Cloud Spanner database and starts to prepare it for serving.
|
OperationFuture<Database,CreateDatabaseMetadata> |
createDatabaseAsync(InstanceName parent,
String createStatement)
Creates a new Cloud Spanner database and starts to prepare it for serving.
|
OperationFuture<Database,CreateDatabaseMetadata> |
createDatabaseAsync(String parent,
String createStatement)
Creates a new Cloud Spanner database and starts to prepare it for serving.
|
UnaryCallable<CreateDatabaseRequest,Operation> |
createDatabaseCallable()
Creates a new Cloud Spanner database and starts to prepare it for serving.
|
OperationCallable<CreateDatabaseRequest,Database,CreateDatabaseMetadata> |
createDatabaseOperationCallable()
Creates a new Cloud Spanner database and starts to prepare it for serving.
|
void |
deleteBackup(BackupName name)
Deletes a pending or completed [Backup][google.spanner.admin.database.v1.Backup].
|
void |
deleteBackup(DeleteBackupRequest request)
Deletes a pending or completed [Backup][google.spanner.admin.database.v1.Backup].
|
void |
deleteBackup(String name)
Deletes a pending or completed [Backup][google.spanner.admin.database.v1.Backup].
|
UnaryCallable<DeleteBackupRequest,Empty> |
deleteBackupCallable()
Deletes a pending or completed [Backup][google.spanner.admin.database.v1.Backup].
|
void |
dropDatabase(DatabaseName database)
Drops (aka deletes) a Cloud Spanner database.
|
void |
dropDatabase(DropDatabaseRequest request)
Drops (aka deletes) a Cloud Spanner database.
|
void |
dropDatabase(String database)
Drops (aka deletes) a Cloud Spanner database.
|
UnaryCallable<DropDatabaseRequest,Empty> |
dropDatabaseCallable()
Drops (aka deletes) a Cloud Spanner database.
|
Backup |
getBackup(BackupName name)
Gets metadata on a pending or completed [Backup][google.spanner.admin.database.v1.Backup].
|
Backup |
getBackup(GetBackupRequest request)
Gets metadata on a pending or completed [Backup][google.spanner.admin.database.v1.Backup].
|
Backup |
getBackup(String name)
Gets metadata on a pending or completed [Backup][google.spanner.admin.database.v1.Backup].
|
UnaryCallable<GetBackupRequest,Backup> |
getBackupCallable()
Gets metadata on a pending or completed [Backup][google.spanner.admin.database.v1.Backup].
|
Database |
getDatabase(DatabaseName name)
Gets the state of a Cloud Spanner database.
|
Database |
getDatabase(GetDatabaseRequest request)
Gets the state of a Cloud Spanner database.
|
Database |
getDatabase(String name)
Gets the state of a Cloud Spanner database.
|
UnaryCallable<GetDatabaseRequest,Database> |
getDatabaseCallable()
Gets the state of a Cloud Spanner database.
|
GetDatabaseDdlResponse |
getDatabaseDdl(DatabaseName database)
Returns the schema of a Cloud Spanner database as a list of formatted DDL statements.
|
GetDatabaseDdlResponse |
getDatabaseDdl(GetDatabaseDdlRequest request)
Returns the schema of a Cloud Spanner database as a list of formatted DDL statements.
|
GetDatabaseDdlResponse |
getDatabaseDdl(String database)
Returns the schema of a Cloud Spanner database as a list of formatted DDL statements.
|
UnaryCallable<GetDatabaseDdlRequest,GetDatabaseDdlResponse> |
getDatabaseDdlCallable()
Returns the schema of a Cloud Spanner database as a list of formatted DDL statements.
|
com.google.iam.v1.Policy |
getIamPolicy(com.google.iam.v1.GetIamPolicyRequest request)
Gets the access control policy for a database or backup resource.
|
com.google.iam.v1.Policy |
getIamPolicy(com.google.api.resourcenames.ResourceName resource)
Gets the access control policy for a database or backup resource.
|
com.google.iam.v1.Policy |
getIamPolicy(String resource)
Gets the access control policy for a database or backup resource.
|
UnaryCallable<com.google.iam.v1.GetIamPolicyRequest,com.google.iam.v1.Policy> |
getIamPolicyCallable()
Gets the access control policy for a database or backup resource.
|
OperationsClient |
getOperationsClient()
Returns the OperationsClient that can be used to query the status of a long-running operation
returned by another API method call.
|
DatabaseAdminSettings |
getSettings() |
DatabaseAdminStub |
getStub() |
boolean |
isShutdown() |
boolean |
isTerminated() |
DatabaseAdminClient.ListBackupOperationsPagedResponse |
listBackupOperations(InstanceName parent)
Lists the backup [long-running operations][google.longrunning.Operation] in the given instance.
|
DatabaseAdminClient.ListBackupOperationsPagedResponse |
listBackupOperations(ListBackupOperationsRequest request)
Lists the backup [long-running operations][google.longrunning.Operation] in the given instance.
|
DatabaseAdminClient.ListBackupOperationsPagedResponse |
listBackupOperations(String parent)
Lists the backup [long-running operations][google.longrunning.Operation] in the given instance.
|
UnaryCallable<ListBackupOperationsRequest,ListBackupOperationsResponse> |
listBackupOperationsCallable()
Lists the backup [long-running operations][google.longrunning.Operation] in the given instance.
|
UnaryCallable<ListBackupOperationsRequest,DatabaseAdminClient.ListBackupOperationsPagedResponse> |
listBackupOperationsPagedCallable()
Lists the backup [long-running operations][google.longrunning.Operation] in the given instance.
|
DatabaseAdminClient.ListBackupsPagedResponse |
listBackups(InstanceName parent)
Lists completed and pending backups.
|
DatabaseAdminClient.ListBackupsPagedResponse |
listBackups(ListBackupsRequest request)
Lists completed and pending backups.
|
DatabaseAdminClient.ListBackupsPagedResponse |
listBackups(String parent)
Lists completed and pending backups.
|
UnaryCallable<ListBackupsRequest,ListBackupsResponse> |
listBackupsCallable()
Lists completed and pending backups.
|
UnaryCallable<ListBackupsRequest,DatabaseAdminClient.ListBackupsPagedResponse> |
listBackupsPagedCallable()
Lists completed and pending backups.
|
DatabaseAdminClient.ListDatabaseOperationsPagedResponse |
listDatabaseOperations(InstanceName parent)
Lists database [longrunning-operations][google.longrunning.Operation].
|
DatabaseAdminClient.ListDatabaseOperationsPagedResponse |
listDatabaseOperations(ListDatabaseOperationsRequest request)
Lists database [longrunning-operations][google.longrunning.Operation].
|
DatabaseAdminClient.ListDatabaseOperationsPagedResponse |
listDatabaseOperations(String parent)
Lists database [longrunning-operations][google.longrunning.Operation].
|
UnaryCallable<ListDatabaseOperationsRequest,ListDatabaseOperationsResponse> |
listDatabaseOperationsCallable()
Lists database [longrunning-operations][google.longrunning.Operation].
|
UnaryCallable<ListDatabaseOperationsRequest,DatabaseAdminClient.ListDatabaseOperationsPagedResponse> |
listDatabaseOperationsPagedCallable()
Lists database [longrunning-operations][google.longrunning.Operation].
|
DatabaseAdminClient.ListDatabasesPagedResponse |
listDatabases(InstanceName parent)
Lists Cloud Spanner databases.
|
DatabaseAdminClient.ListDatabasesPagedResponse |
listDatabases(ListDatabasesRequest request)
Lists Cloud Spanner databases.
|
DatabaseAdminClient.ListDatabasesPagedResponse |
listDatabases(String parent)
Lists Cloud Spanner databases.
|
UnaryCallable<ListDatabasesRequest,ListDatabasesResponse> |
listDatabasesCallable()
Lists Cloud Spanner databases.
|
UnaryCallable<ListDatabasesRequest,DatabaseAdminClient.ListDatabasesPagedResponse> |
listDatabasesPagedCallable()
Lists Cloud Spanner databases.
|
OperationFuture<Database,RestoreDatabaseMetadata> |
restoreDatabaseAsync(InstanceName parent,
String databaseId,
BackupName backup)
Create a new database by restoring from a completed backup.
|
OperationFuture<Database,RestoreDatabaseMetadata> |
restoreDatabaseAsync(InstanceName parent,
String databaseId,
String backup)
Create a new database by restoring from a completed backup.
|
OperationFuture<Database,RestoreDatabaseMetadata> |
restoreDatabaseAsync(RestoreDatabaseRequest request)
Create a new database by restoring from a completed backup.
|
OperationFuture<Database,RestoreDatabaseMetadata> |
restoreDatabaseAsync(String parent,
String databaseId,
BackupName backup)
Create a new database by restoring from a completed backup.
|
OperationFuture<Database,RestoreDatabaseMetadata> |
restoreDatabaseAsync(String parent,
String databaseId,
String backup)
Create a new database by restoring from a completed backup.
|
UnaryCallable<RestoreDatabaseRequest,Operation> |
restoreDatabaseCallable()
Create a new database by restoring from a completed backup.
|
OperationCallable<RestoreDatabaseRequest,Database,RestoreDatabaseMetadata> |
restoreDatabaseOperationCallable()
Create a new database by restoring from a completed backup.
|
com.google.iam.v1.Policy |
setIamPolicy(com.google.api.resourcenames.ResourceName resource,
com.google.iam.v1.Policy policy)
Sets the access control policy on a database or backup resource.
|
com.google.iam.v1.Policy |
setIamPolicy(com.google.iam.v1.SetIamPolicyRequest request)
Sets the access control policy on a database or backup resource.
|
com.google.iam.v1.Policy |
setIamPolicy(String resource,
com.google.iam.v1.Policy policy)
Sets the access control policy on a database or backup resource.
|
UnaryCallable<com.google.iam.v1.SetIamPolicyRequest,com.google.iam.v1.Policy> |
setIamPolicyCallable()
Sets the access control policy on a database or backup resource.
|
void |
shutdown() |
void |
shutdownNow() |
com.google.iam.v1.TestIamPermissionsResponse |
testIamPermissions(com.google.api.resourcenames.ResourceName resource,
List<String> permissions)
Returns permissions that the caller has on the specified database or backup resource.
|
com.google.iam.v1.TestIamPermissionsResponse |
testIamPermissions(String resource,
List<String> permissions)
Returns permissions that the caller has on the specified database or backup resource.
|
com.google.iam.v1.TestIamPermissionsResponse |
testIamPermissions(com.google.iam.v1.TestIamPermissionsRequest request)
Returns permissions that the caller has on the specified database or backup resource.
|
UnaryCallable<com.google.iam.v1.TestIamPermissionsRequest,com.google.iam.v1.TestIamPermissionsResponse> |
testIamPermissionsCallable()
Returns permissions that the caller has on the specified database or backup resource.
|
Backup |
updateBackup(Backup backup,
FieldMask updateMask)
Updates a pending or completed [Backup][google.spanner.admin.database.v1.Backup].
|
Backup |
updateBackup(UpdateBackupRequest request)
Updates a pending or completed [Backup][google.spanner.admin.database.v1.Backup].
|
UnaryCallable<UpdateBackupRequest,Backup> |
updateBackupCallable()
Updates a pending or completed [Backup][google.spanner.admin.database.v1.Backup].
|
OperationFuture<Empty,UpdateDatabaseDdlMetadata> |
updateDatabaseDdlAsync(DatabaseName database,
List<String> statements)
Updates the schema of a Cloud Spanner database by creating/altering/dropping tables, columns,
indexes, etc.
|
OperationFuture<Empty,UpdateDatabaseDdlMetadata> |
updateDatabaseDdlAsync(String database,
List<String> statements)
Updates the schema of a Cloud Spanner database by creating/altering/dropping tables, columns,
indexes, etc.
|
OperationFuture<Empty,UpdateDatabaseDdlMetadata> |
updateDatabaseDdlAsync(UpdateDatabaseDdlRequest request)
Updates the schema of a Cloud Spanner database by creating/altering/dropping tables, columns,
indexes, etc.
|
UnaryCallable<UpdateDatabaseDdlRequest,Operation> |
updateDatabaseDdlCallable()
Updates the schema of a Cloud Spanner database by creating/altering/dropping tables, columns,
indexes, etc.
|
OperationCallable<UpdateDatabaseDdlRequest,Empty,UpdateDatabaseDdlMetadata> |
updateDatabaseDdlOperationCallable()
Updates the schema of a Cloud Spanner database by creating/altering/dropping tables, columns,
indexes, etc.
|
protected DatabaseAdminClient(DatabaseAdminSettings settings) throws IOException
IOException
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") protected DatabaseAdminClient(DatabaseAdminStub stub)
public static final DatabaseAdminClient create() throws IOException
IOException
public static final DatabaseAdminClient create(DatabaseAdminSettings settings) throws IOException
IOException
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") public static final DatabaseAdminClient create(DatabaseAdminStub stub)
public final DatabaseAdminSettings getSettings()
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") public DatabaseAdminStub getStub()
public final OperationsClient getOperationsClient()
public final DatabaseAdminClient.ListDatabasesPagedResponse listDatabases(InstanceName parent)
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
for (Database element : databaseAdminClient.listDatabases(parent).iterateAll()) {
// doThingsWith(element);
}
}
parent
- Required. The instance whose databases should be listed. Values are of the form
`projects/<project>/instances/<instance>`.ApiException
- if the remote call failspublic final DatabaseAdminClient.ListDatabasesPagedResponse listDatabases(String parent)
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
String parent = InstanceName.of("[PROJECT]", "[INSTANCE]").toString();
for (Database element : databaseAdminClient.listDatabases(parent).iterateAll()) {
// doThingsWith(element);
}
}
parent
- Required. The instance whose databases should be listed. Values are of the form
`projects/<project>/instances/<instance>`.ApiException
- if the remote call failspublic final DatabaseAdminClient.ListDatabasesPagedResponse listDatabases(ListDatabasesRequest request)
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
ListDatabasesRequest request =
ListDatabasesRequest.newBuilder()
.setParent(InstanceName.of("[PROJECT]", "[INSTANCE]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
for (Database element : databaseAdminClient.listDatabases(request).iterateAll()) {
// doThingsWith(element);
}
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<ListDatabasesRequest,DatabaseAdminClient.ListDatabasesPagedResponse> listDatabasesPagedCallable()
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
ListDatabasesRequest request =
ListDatabasesRequest.newBuilder()
.setParent(InstanceName.of("[PROJECT]", "[INSTANCE]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
ApiFuture<Database> future =
databaseAdminClient.listDatabasesPagedCallable().futureCall(request);
// Do something.
for (Database element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
public final UnaryCallable<ListDatabasesRequest,ListDatabasesResponse> listDatabasesCallable()
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
ListDatabasesRequest request =
ListDatabasesRequest.newBuilder()
.setParent(InstanceName.of("[PROJECT]", "[INSTANCE]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
while (true) {
ListDatabasesResponse response = databaseAdminClient.listDatabasesCallable().call(request);
for (Database element : response.getResponsesList()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
public final OperationFuture<Database,CreateDatabaseMetadata> createDatabaseAsync(InstanceName parent, String createStatement)
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
String createStatement = "createStatement744686547";
Database response = databaseAdminClient.createDatabaseAsync(parent, createStatement).get();
}
parent
- Required. The name of the instance that will serve the new database. Values are
of the form `projects/<project>/instances/<instance>`.createStatement
- Required. A `CREATE DATABASE` statement, which specifies the ID of the
new database. The database ID must conform to the regular expression
`[a-z][a-z0-9_\\-]*[a-z0-9]` and be between 2 and 30 characters in length. If the
database ID is a reserved word or if it contains a hyphen, the database ID must be enclosed
in backticks (`` ` ``).ApiException
- if the remote call failspublic final OperationFuture<Database,CreateDatabaseMetadata> createDatabaseAsync(String parent, String createStatement)
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
String parent = InstanceName.of("[PROJECT]", "[INSTANCE]").toString();
String createStatement = "createStatement744686547";
Database response = databaseAdminClient.createDatabaseAsync(parent, createStatement).get();
}
parent
- Required. The name of the instance that will serve the new database. Values are
of the form `projects/<project>/instances/<instance>`.createStatement
- Required. A `CREATE DATABASE` statement, which specifies the ID of the
new database. The database ID must conform to the regular expression
`[a-z][a-z0-9_\\-]*[a-z0-9]` and be between 2 and 30 characters in length. If the
database ID is a reserved word or if it contains a hyphen, the database ID must be enclosed
in backticks (`` ` ``).ApiException
- if the remote call failspublic final OperationFuture<Database,CreateDatabaseMetadata> createDatabaseAsync(CreateDatabaseRequest request)
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
CreateDatabaseRequest request =
CreateDatabaseRequest.newBuilder()
.setParent(InstanceName.of("[PROJECT]", "[INSTANCE]").toString())
.setCreateStatement("createStatement744686547")
.addAllExtraStatements(new ArrayList<String>())
.setEncryptionConfig(EncryptionConfig.newBuilder().build())
.setDatabaseDialect(DatabaseDialect.forNumber(0))
.build();
Database response = databaseAdminClient.createDatabaseAsync(request).get();
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final OperationCallable<CreateDatabaseRequest,Database,CreateDatabaseMetadata> createDatabaseOperationCallable()
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
CreateDatabaseRequest request =
CreateDatabaseRequest.newBuilder()
.setParent(InstanceName.of("[PROJECT]", "[INSTANCE]").toString())
.setCreateStatement("createStatement744686547")
.addAllExtraStatements(new ArrayList<String>())
.setEncryptionConfig(EncryptionConfig.newBuilder().build())
.setDatabaseDialect(DatabaseDialect.forNumber(0))
.build();
OperationFuture<Database, CreateDatabaseMetadata> future =
databaseAdminClient.createDatabaseOperationCallable().futureCall(request);
// Do something.
Database response = future.get();
}
public final UnaryCallable<CreateDatabaseRequest,Operation> createDatabaseCallable()
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
CreateDatabaseRequest request =
CreateDatabaseRequest.newBuilder()
.setParent(InstanceName.of("[PROJECT]", "[INSTANCE]").toString())
.setCreateStatement("createStatement744686547")
.addAllExtraStatements(new ArrayList<String>())
.setEncryptionConfig(EncryptionConfig.newBuilder().build())
.setDatabaseDialect(DatabaseDialect.forNumber(0))
.build();
ApiFuture<Operation> future =
databaseAdminClient.createDatabaseCallable().futureCall(request);
// Do something.
Operation response = future.get();
}
public final Database getDatabase(DatabaseName name)
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
DatabaseName name = DatabaseName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]");
Database response = databaseAdminClient.getDatabase(name);
}
name
- Required. The name of the requested database. Values are of the form
`projects/<project>/instances/<instance>/databases/<database>`.ApiException
- if the remote call failspublic final Database getDatabase(String name)
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
String name = DatabaseName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]").toString();
Database response = databaseAdminClient.getDatabase(name);
}
name
- Required. The name of the requested database. Values are of the form
`projects/<project>/instances/<instance>/databases/<database>`.ApiException
- if the remote call failspublic final Database getDatabase(GetDatabaseRequest request)
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
GetDatabaseRequest request =
GetDatabaseRequest.newBuilder()
.setName(DatabaseName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]").toString())
.build();
Database response = databaseAdminClient.getDatabase(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<GetDatabaseRequest,Database> getDatabaseCallable()
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
GetDatabaseRequest request =
GetDatabaseRequest.newBuilder()
.setName(DatabaseName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]").toString())
.build();
ApiFuture<Database> future = databaseAdminClient.getDatabaseCallable().futureCall(request);
// Do something.
Database response = future.get();
}
public final OperationFuture<Empty,UpdateDatabaseDdlMetadata> updateDatabaseDdlAsync(DatabaseName database, List<String> statements)
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
DatabaseName database = DatabaseName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]");
List<String> statements = new ArrayList<>();
databaseAdminClient.updateDatabaseDdlAsync(database, statements).get();
}
database
- Required. The database to update.statements
- Required. DDL statements to be applied to the database.ApiException
- if the remote call failspublic final OperationFuture<Empty,UpdateDatabaseDdlMetadata> updateDatabaseDdlAsync(String database, List<String> statements)
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
String database = DatabaseName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]").toString();
List<String> statements = new ArrayList<>();
databaseAdminClient.updateDatabaseDdlAsync(database, statements).get();
}
database
- Required. The database to update.statements
- Required. DDL statements to be applied to the database.ApiException
- if the remote call failspublic final OperationFuture<Empty,UpdateDatabaseDdlMetadata> updateDatabaseDdlAsync(UpdateDatabaseDdlRequest request)
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
UpdateDatabaseDdlRequest request =
UpdateDatabaseDdlRequest.newBuilder()
.setDatabase(DatabaseName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]").toString())
.addAllStatements(new ArrayList<String>())
.setOperationId("operationId129704162")
.build();
databaseAdminClient.updateDatabaseDdlAsync(request).get();
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final OperationCallable<UpdateDatabaseDdlRequest,Empty,UpdateDatabaseDdlMetadata> updateDatabaseDdlOperationCallable()
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
UpdateDatabaseDdlRequest request =
UpdateDatabaseDdlRequest.newBuilder()
.setDatabase(DatabaseName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]").toString())
.addAllStatements(new ArrayList<String>())
.setOperationId("operationId129704162")
.build();
OperationFuture<Empty, UpdateDatabaseDdlMetadata> future =
databaseAdminClient.updateDatabaseDdlOperationCallable().futureCall(request);
// Do something.
future.get();
}
public final UnaryCallable<UpdateDatabaseDdlRequest,Operation> updateDatabaseDdlCallable()
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
UpdateDatabaseDdlRequest request =
UpdateDatabaseDdlRequest.newBuilder()
.setDatabase(DatabaseName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]").toString())
.addAllStatements(new ArrayList<String>())
.setOperationId("operationId129704162")
.build();
ApiFuture<Operation> future =
databaseAdminClient.updateDatabaseDdlCallable().futureCall(request);
// Do something.
future.get();
}
public final void dropDatabase(DatabaseName database)
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
DatabaseName database = DatabaseName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]");
databaseAdminClient.dropDatabase(database);
}
database
- Required. The database to be dropped.ApiException
- if the remote call failspublic final void dropDatabase(String database)
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
String database = DatabaseName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]").toString();
databaseAdminClient.dropDatabase(database);
}
database
- Required. The database to be dropped.ApiException
- if the remote call failspublic final void dropDatabase(DropDatabaseRequest request)
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
DropDatabaseRequest request =
DropDatabaseRequest.newBuilder()
.setDatabase(DatabaseName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]").toString())
.build();
databaseAdminClient.dropDatabase(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<DropDatabaseRequest,Empty> dropDatabaseCallable()
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
DropDatabaseRequest request =
DropDatabaseRequest.newBuilder()
.setDatabase(DatabaseName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]").toString())
.build();
ApiFuture<Empty> future = databaseAdminClient.dropDatabaseCallable().futureCall(request);
// Do something.
future.get();
}
public final GetDatabaseDdlResponse getDatabaseDdl(DatabaseName database)
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
DatabaseName database = DatabaseName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]");
GetDatabaseDdlResponse response = databaseAdminClient.getDatabaseDdl(database);
}
database
- Required. The database whose schema we wish to get. Values are of the form
`projects/<project>/instances/<instance>/databases/<database>`ApiException
- if the remote call failspublic final GetDatabaseDdlResponse getDatabaseDdl(String database)
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
String database = DatabaseName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]").toString();
GetDatabaseDdlResponse response = databaseAdminClient.getDatabaseDdl(database);
}
database
- Required. The database whose schema we wish to get. Values are of the form
`projects/<project>/instances/<instance>/databases/<database>`ApiException
- if the remote call failspublic final GetDatabaseDdlResponse getDatabaseDdl(GetDatabaseDdlRequest request)
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
GetDatabaseDdlRequest request =
GetDatabaseDdlRequest.newBuilder()
.setDatabase(DatabaseName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]").toString())
.build();
GetDatabaseDdlResponse response = databaseAdminClient.getDatabaseDdl(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<GetDatabaseDdlRequest,GetDatabaseDdlResponse> getDatabaseDdlCallable()
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
GetDatabaseDdlRequest request =
GetDatabaseDdlRequest.newBuilder()
.setDatabase(DatabaseName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]").toString())
.build();
ApiFuture<GetDatabaseDdlResponse> future =
databaseAdminClient.getDatabaseDdlCallable().futureCall(request);
// Do something.
GetDatabaseDdlResponse response = future.get();
}
public final com.google.iam.v1.Policy setIamPolicy(com.google.api.resourcenames.ResourceName resource, com.google.iam.v1.Policy policy)
Authorization requires `spanner.databases.setIamPolicy` permission on [resource][google.iam.v1.SetIamPolicyRequest.resource]. For backups, authorization requires `spanner.backups.setIamPolicy` permission on [resource][google.iam.v1.SetIamPolicyRequest.resource].
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
ResourceName resource = BackupName.of("[PROJECT]", "[INSTANCE]", "[BACKUP]");
Policy policy = Policy.newBuilder().build();
Policy response = databaseAdminClient.setIamPolicy(resource, policy);
}
resource
- REQUIRED: The resource for which the policy is being specified. See the
operation documentation for the appropriate value for this field.policy
- REQUIRED: The complete policy to be applied to the `resource`. The size of the
policy is limited to a few 10s of KB. An empty policy is a valid policy but certain Cloud
Platform services (such as Projects) might reject them.ApiException
- if the remote call failspublic final com.google.iam.v1.Policy setIamPolicy(String resource, com.google.iam.v1.Policy policy)
Authorization requires `spanner.databases.setIamPolicy` permission on [resource][google.iam.v1.SetIamPolicyRequest.resource]. For backups, authorization requires `spanner.backups.setIamPolicy` permission on [resource][google.iam.v1.SetIamPolicyRequest.resource].
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
String resource = BackupName.of("[PROJECT]", "[INSTANCE]", "[BACKUP]").toString();
Policy policy = Policy.newBuilder().build();
Policy response = databaseAdminClient.setIamPolicy(resource, policy);
}
resource
- REQUIRED: The resource for which the policy is being specified. See the
operation documentation for the appropriate value for this field.policy
- REQUIRED: The complete policy to be applied to the `resource`. The size of the
policy is limited to a few 10s of KB. An empty policy is a valid policy but certain Cloud
Platform services (such as Projects) might reject them.ApiException
- if the remote call failspublic final com.google.iam.v1.Policy setIamPolicy(com.google.iam.v1.SetIamPolicyRequest request)
Authorization requires `spanner.databases.setIamPolicy` permission on [resource][google.iam.v1.SetIamPolicyRequest.resource]. For backups, authorization requires `spanner.backups.setIamPolicy` permission on [resource][google.iam.v1.SetIamPolicyRequest.resource].
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
SetIamPolicyRequest request =
SetIamPolicyRequest.newBuilder()
.setResource(BackupName.of("[PROJECT]", "[INSTANCE]", "[BACKUP]").toString())
.setPolicy(Policy.newBuilder().build())
.setUpdateMask(FieldMask.newBuilder().build())
.build();
Policy response = databaseAdminClient.setIamPolicy(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<com.google.iam.v1.SetIamPolicyRequest,com.google.iam.v1.Policy> setIamPolicyCallable()
Authorization requires `spanner.databases.setIamPolicy` permission on [resource][google.iam.v1.SetIamPolicyRequest.resource]. For backups, authorization requires `spanner.backups.setIamPolicy` permission on [resource][google.iam.v1.SetIamPolicyRequest.resource].
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
SetIamPolicyRequest request =
SetIamPolicyRequest.newBuilder()
.setResource(BackupName.of("[PROJECT]", "[INSTANCE]", "[BACKUP]").toString())
.setPolicy(Policy.newBuilder().build())
.setUpdateMask(FieldMask.newBuilder().build())
.build();
ApiFuture<Policy> future = databaseAdminClient.setIamPolicyCallable().futureCall(request);
// Do something.
Policy response = future.get();
}
public final com.google.iam.v1.Policy getIamPolicy(com.google.api.resourcenames.ResourceName resource)
Authorization requires `spanner.databases.getIamPolicy` permission on [resource][google.iam.v1.GetIamPolicyRequest.resource]. For backups, authorization requires `spanner.backups.getIamPolicy` permission on [resource][google.iam.v1.GetIamPolicyRequest.resource].
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
ResourceName resource = BackupName.of("[PROJECT]", "[INSTANCE]", "[BACKUP]");
Policy response = databaseAdminClient.getIamPolicy(resource);
}
resource
- REQUIRED: The resource for which the policy is being requested. See the
operation documentation for the appropriate value for this field.ApiException
- if the remote call failspublic final com.google.iam.v1.Policy getIamPolicy(String resource)
Authorization requires `spanner.databases.getIamPolicy` permission on [resource][google.iam.v1.GetIamPolicyRequest.resource]. For backups, authorization requires `spanner.backups.getIamPolicy` permission on [resource][google.iam.v1.GetIamPolicyRequest.resource].
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
String resource = BackupName.of("[PROJECT]", "[INSTANCE]", "[BACKUP]").toString();
Policy response = databaseAdminClient.getIamPolicy(resource);
}
resource
- REQUIRED: The resource for which the policy is being requested. See the
operation documentation for the appropriate value for this field.ApiException
- if the remote call failspublic final com.google.iam.v1.Policy getIamPolicy(com.google.iam.v1.GetIamPolicyRequest request)
Authorization requires `spanner.databases.getIamPolicy` permission on [resource][google.iam.v1.GetIamPolicyRequest.resource]. For backups, authorization requires `spanner.backups.getIamPolicy` permission on [resource][google.iam.v1.GetIamPolicyRequest.resource].
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
GetIamPolicyRequest request =
GetIamPolicyRequest.newBuilder()
.setResource(BackupName.of("[PROJECT]", "[INSTANCE]", "[BACKUP]").toString())
.setOptions(GetPolicyOptions.newBuilder().build())
.build();
Policy response = databaseAdminClient.getIamPolicy(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<com.google.iam.v1.GetIamPolicyRequest,com.google.iam.v1.Policy> getIamPolicyCallable()
Authorization requires `spanner.databases.getIamPolicy` permission on [resource][google.iam.v1.GetIamPolicyRequest.resource]. For backups, authorization requires `spanner.backups.getIamPolicy` permission on [resource][google.iam.v1.GetIamPolicyRequest.resource].
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
GetIamPolicyRequest request =
GetIamPolicyRequest.newBuilder()
.setResource(BackupName.of("[PROJECT]", "[INSTANCE]", "[BACKUP]").toString())
.setOptions(GetPolicyOptions.newBuilder().build())
.build();
ApiFuture<Policy> future = databaseAdminClient.getIamPolicyCallable().futureCall(request);
// Do something.
Policy response = future.get();
}
public final com.google.iam.v1.TestIamPermissionsResponse testIamPermissions(com.google.api.resourcenames.ResourceName resource, List<String> permissions)
Attempting this RPC on a non-existent Cloud Spanner database will result in a NOT_FOUND error if the user has `spanner.databases.list` permission on the containing Cloud Spanner instance. Otherwise returns an empty set of permissions. Calling this method on a backup that does not exist will result in a NOT_FOUND error if the user has `spanner.backups.list` permission on the containing instance.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
ResourceName resource = BackupName.of("[PROJECT]", "[INSTANCE]", "[BACKUP]");
List<String> permissions = new ArrayList<>();
TestIamPermissionsResponse response =
databaseAdminClient.testIamPermissions(resource, permissions);
}
resource
- REQUIRED: The resource for which the policy detail is being requested. See the
operation documentation for the appropriate value for this field.permissions
- The set of permissions to check for the `resource`. Permissions with
wildcards (such as '*' or 'storage.*') are not allowed. For more information see
[IAM Overview](https://cloud.google.com/iam/docs/overview#permissions).ApiException
- if the remote call failspublic final com.google.iam.v1.TestIamPermissionsResponse testIamPermissions(String resource, List<String> permissions)
Attempting this RPC on a non-existent Cloud Spanner database will result in a NOT_FOUND error if the user has `spanner.databases.list` permission on the containing Cloud Spanner instance. Otherwise returns an empty set of permissions. Calling this method on a backup that does not exist will result in a NOT_FOUND error if the user has `spanner.backups.list` permission on the containing instance.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
String resource = BackupName.of("[PROJECT]", "[INSTANCE]", "[BACKUP]").toString();
List<String> permissions = new ArrayList<>();
TestIamPermissionsResponse response =
databaseAdminClient.testIamPermissions(resource, permissions);
}
resource
- REQUIRED: The resource for which the policy detail is being requested. See the
operation documentation for the appropriate value for this field.permissions
- The set of permissions to check for the `resource`. Permissions with
wildcards (such as '*' or 'storage.*') are not allowed. For more information see
[IAM Overview](https://cloud.google.com/iam/docs/overview#permissions).ApiException
- if the remote call failspublic final com.google.iam.v1.TestIamPermissionsResponse testIamPermissions(com.google.iam.v1.TestIamPermissionsRequest request)
Attempting this RPC on a non-existent Cloud Spanner database will result in a NOT_FOUND error if the user has `spanner.databases.list` permission on the containing Cloud Spanner instance. Otherwise returns an empty set of permissions. Calling this method on a backup that does not exist will result in a NOT_FOUND error if the user has `spanner.backups.list` permission on the containing instance.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
TestIamPermissionsRequest request =
TestIamPermissionsRequest.newBuilder()
.setResource(BackupName.of("[PROJECT]", "[INSTANCE]", "[BACKUP]").toString())
.addAllPermissions(new ArrayList<String>())
.build();
TestIamPermissionsResponse response = databaseAdminClient.testIamPermissions(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<com.google.iam.v1.TestIamPermissionsRequest,com.google.iam.v1.TestIamPermissionsResponse> testIamPermissionsCallable()
Attempting this RPC on a non-existent Cloud Spanner database will result in a NOT_FOUND error if the user has `spanner.databases.list` permission on the containing Cloud Spanner instance. Otherwise returns an empty set of permissions. Calling this method on a backup that does not exist will result in a NOT_FOUND error if the user has `spanner.backups.list` permission on the containing instance.
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
TestIamPermissionsRequest request =
TestIamPermissionsRequest.newBuilder()
.setResource(BackupName.of("[PROJECT]", "[INSTANCE]", "[BACKUP]").toString())
.addAllPermissions(new ArrayList<String>())
.build();
ApiFuture<TestIamPermissionsResponse> future =
databaseAdminClient.testIamPermissionsCallable().futureCall(request);
// Do something.
TestIamPermissionsResponse response = future.get();
}
public final OperationFuture<Backup,CreateBackupMetadata> createBackupAsync(InstanceName parent, Backup backup, String backupId)
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
Backup backup = Backup.newBuilder().build();
String backupId = "backupId2121930365";
Backup response = databaseAdminClient.createBackupAsync(parent, backup, backupId).get();
}
parent
- Required. The name of the instance in which the backup will be created. This must
be the same instance that contains the database the backup will be created from. The backup
will be stored in the location(s) specified in the instance configuration of this instance.
Values are of the form `projects/<project>/instances/<instance>`.backup
- Required. The backup to create.backupId
- Required. The id of the backup to be created. The `backup_id` appended to
`parent` forms the full backup name of the form
`projects/<project>/instances/<instance>/backups/<backup_id>`.ApiException
- if the remote call failspublic final OperationFuture<Backup,CreateBackupMetadata> createBackupAsync(String parent, Backup backup, String backupId)
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
String parent = InstanceName.of("[PROJECT]", "[INSTANCE]").toString();
Backup backup = Backup.newBuilder().build();
String backupId = "backupId2121930365";
Backup response = databaseAdminClient.createBackupAsync(parent, backup, backupId).get();
}
parent
- Required. The name of the instance in which the backup will be created. This must
be the same instance that contains the database the backup will be created from. The backup
will be stored in the location(s) specified in the instance configuration of this instance.
Values are of the form `projects/<project>/instances/<instance>`.backup
- Required. The backup to create.backupId
- Required. The id of the backup to be created. The `backup_id` appended to
`parent` forms the full backup name of the form
`projects/<project>/instances/<instance>/backups/<backup_id>`.ApiException
- if the remote call failspublic final OperationFuture<Backup,CreateBackupMetadata> createBackupAsync(CreateBackupRequest request)
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
CreateBackupRequest request =
CreateBackupRequest.newBuilder()
.setParent(InstanceName.of("[PROJECT]", "[INSTANCE]").toString())
.setBackupId("backupId2121930365")
.setBackup(Backup.newBuilder().build())
.setEncryptionConfig(CreateBackupEncryptionConfig.newBuilder().build())
.build();
Backup response = databaseAdminClient.createBackupAsync(request).get();
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final OperationCallable<CreateBackupRequest,Backup,CreateBackupMetadata> createBackupOperationCallable()
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
CreateBackupRequest request =
CreateBackupRequest.newBuilder()
.setParent(InstanceName.of("[PROJECT]", "[INSTANCE]").toString())
.setBackupId("backupId2121930365")
.setBackup(Backup.newBuilder().build())
.setEncryptionConfig(CreateBackupEncryptionConfig.newBuilder().build())
.build();
OperationFuture<Backup, CreateBackupMetadata> future =
databaseAdminClient.createBackupOperationCallable().futureCall(request);
// Do something.
Backup response = future.get();
}
public final UnaryCallable<CreateBackupRequest,Operation> createBackupCallable()
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
CreateBackupRequest request =
CreateBackupRequest.newBuilder()
.setParent(InstanceName.of("[PROJECT]", "[INSTANCE]").toString())
.setBackupId("backupId2121930365")
.setBackup(Backup.newBuilder().build())
.setEncryptionConfig(CreateBackupEncryptionConfig.newBuilder().build())
.build();
ApiFuture<Operation> future = databaseAdminClient.createBackupCallable().futureCall(request);
// Do something.
Operation response = future.get();
}
public final OperationFuture<Backup,CopyBackupMetadata> copyBackupAsync(InstanceName parent, String backupId, BackupName sourceBackup, Timestamp expireTime)
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
String backupId = "backupId2121930365";
BackupName sourceBackup = BackupName.of("[PROJECT]", "[INSTANCE]", "[BACKUP]");
Timestamp expireTime = Timestamp.newBuilder().build();
Backup response =
databaseAdminClient.copyBackupAsync(parent, backupId, sourceBackup, expireTime).get();
}
parent
- Required. The name of the destination instance that will contain the backup copy.
Values are of the form: `projects/<project>/instances/<instance>`.backupId
- Required. The id of the backup copy. The `backup_id` appended to `parent` forms
the full backup_uri of the form
`projects/<project>/instances/<instance>/backups/<backup>`.sourceBackup
- Required. The source backup to be copied. The source backup needs to be in
READY state for it to be copied. Once CopyBackup is in progress, the source backup cannot
be deleted or cleaned up on expiration until CopyBackup is finished. Values are of the
form: `projects/<project>/instances/<instance>/backups/<backup>`.expireTime
- Required. The expiration time of the backup in microsecond granularity. The
expiration time must be at least 6 hours and at most 366 days from the `create_time` of the
source backup. Once the `expire_time` has passed, the backup is eligible to be
automatically deleted by Cloud Spanner to free the resources used by the backup.ApiException
- if the remote call failspublic final OperationFuture<Backup,CopyBackupMetadata> copyBackupAsync(InstanceName parent, String backupId, String sourceBackup, Timestamp expireTime)
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
String backupId = "backupId2121930365";
String sourceBackup = BackupName.of("[PROJECT]", "[INSTANCE]", "[BACKUP]").toString();
Timestamp expireTime = Timestamp.newBuilder().build();
Backup response =
databaseAdminClient.copyBackupAsync(parent, backupId, sourceBackup, expireTime).get();
}
parent
- Required. The name of the destination instance that will contain the backup copy.
Values are of the form: `projects/<project>/instances/<instance>`.backupId
- Required. The id of the backup copy. The `backup_id` appended to `parent` forms
the full backup_uri of the form
`projects/<project>/instances/<instance>/backups/<backup>`.sourceBackup
- Required. The source backup to be copied. The source backup needs to be in
READY state for it to be copied. Once CopyBackup is in progress, the source backup cannot
be deleted or cleaned up on expiration until CopyBackup is finished. Values are of the
form: `projects/<project>/instances/<instance>/backups/<backup>`.expireTime
- Required. The expiration time of the backup in microsecond granularity. The
expiration time must be at least 6 hours and at most 366 days from the `create_time` of the
source backup. Once the `expire_time` has passed, the backup is eligible to be
automatically deleted by Cloud Spanner to free the resources used by the backup.ApiException
- if the remote call failspublic final OperationFuture<Backup,CopyBackupMetadata> copyBackupAsync(String parent, String backupId, BackupName sourceBackup, Timestamp expireTime)
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
String parent = InstanceName.of("[PROJECT]", "[INSTANCE]").toString();
String backupId = "backupId2121930365";
BackupName sourceBackup = BackupName.of("[PROJECT]", "[INSTANCE]", "[BACKUP]");
Timestamp expireTime = Timestamp.newBuilder().build();
Backup response =
databaseAdminClient.copyBackupAsync(parent, backupId, sourceBackup, expireTime).get();
}
parent
- Required. The name of the destination instance that will contain the backup copy.
Values are of the form: `projects/<project>/instances/<instance>`.backupId
- Required. The id of the backup copy. The `backup_id` appended to `parent` forms
the full backup_uri of the form
`projects/<project>/instances/<instance>/backups/<backup>`.sourceBackup
- Required. The source backup to be copied. The source backup needs to be in
READY state for it to be copied. Once CopyBackup is in progress, the source backup cannot
be deleted or cleaned up on expiration until CopyBackup is finished. Values are of the
form: `projects/<project>/instances/<instance>/backups/<backup>`.expireTime
- Required. The expiration time of the backup in microsecond granularity. The
expiration time must be at least 6 hours and at most 366 days from the `create_time` of the
source backup. Once the `expire_time` has passed, the backup is eligible to be
automatically deleted by Cloud Spanner to free the resources used by the backup.ApiException
- if the remote call failspublic final OperationFuture<Backup,CopyBackupMetadata> copyBackupAsync(String parent, String backupId, String sourceBackup, Timestamp expireTime)
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
String parent = InstanceName.of("[PROJECT]", "[INSTANCE]").toString();
String backupId = "backupId2121930365";
String sourceBackup = BackupName.of("[PROJECT]", "[INSTANCE]", "[BACKUP]").toString();
Timestamp expireTime = Timestamp.newBuilder().build();
Backup response =
databaseAdminClient.copyBackupAsync(parent, backupId, sourceBackup, expireTime).get();
}
parent
- Required. The name of the destination instance that will contain the backup copy.
Values are of the form: `projects/<project>/instances/<instance>`.backupId
- Required. The id of the backup copy. The `backup_id` appended to `parent` forms
the full backup_uri of the form
`projects/<project>/instances/<instance>/backups/<backup>`.sourceBackup
- Required. The source backup to be copied. The source backup needs to be in
READY state for it to be copied. Once CopyBackup is in progress, the source backup cannot
be deleted or cleaned up on expiration until CopyBackup is finished. Values are of the
form: `projects/<project>/instances/<instance>/backups/<backup>`.expireTime
- Required. The expiration time of the backup in microsecond granularity. The
expiration time must be at least 6 hours and at most 366 days from the `create_time` of the
source backup. Once the `expire_time` has passed, the backup is eligible to be
automatically deleted by Cloud Spanner to free the resources used by the backup.ApiException
- if the remote call failspublic final OperationFuture<Backup,CopyBackupMetadata> copyBackupAsync(CopyBackupRequest request)
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
CopyBackupRequest request =
CopyBackupRequest.newBuilder()
.setParent(InstanceName.of("[PROJECT]", "[INSTANCE]").toString())
.setBackupId("backupId2121930365")
.setSourceBackup(BackupName.of("[PROJECT]", "[INSTANCE]", "[BACKUP]").toString())
.setExpireTime(Timestamp.newBuilder().build())
.setEncryptionConfig(CopyBackupEncryptionConfig.newBuilder().build())
.build();
Backup response = databaseAdminClient.copyBackupAsync(request).get();
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final OperationCallable<CopyBackupRequest,Backup,CopyBackupMetadata> copyBackupOperationCallable()
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
CopyBackupRequest request =
CopyBackupRequest.newBuilder()
.setParent(InstanceName.of("[PROJECT]", "[INSTANCE]").toString())
.setBackupId("backupId2121930365")
.setSourceBackup(BackupName.of("[PROJECT]", "[INSTANCE]", "[BACKUP]").toString())
.setExpireTime(Timestamp.newBuilder().build())
.setEncryptionConfig(CopyBackupEncryptionConfig.newBuilder().build())
.build();
OperationFuture<Backup, CopyBackupMetadata> future =
databaseAdminClient.copyBackupOperationCallable().futureCall(request);
// Do something.
Backup response = future.get();
}
public final UnaryCallable<CopyBackupRequest,Operation> copyBackupCallable()
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
CopyBackupRequest request =
CopyBackupRequest.newBuilder()
.setParent(InstanceName.of("[PROJECT]", "[INSTANCE]").toString())
.setBackupId("backupId2121930365")
.setSourceBackup(BackupName.of("[PROJECT]", "[INSTANCE]", "[BACKUP]").toString())
.setExpireTime(Timestamp.newBuilder().build())
.setEncryptionConfig(CopyBackupEncryptionConfig.newBuilder().build())
.build();
ApiFuture<Operation> future = databaseAdminClient.copyBackupCallable().futureCall(request);
// Do something.
Operation response = future.get();
}
public final Backup getBackup(BackupName name)
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
BackupName name = BackupName.of("[PROJECT]", "[INSTANCE]", "[BACKUP]");
Backup response = databaseAdminClient.getBackup(name);
}
name
- Required. Name of the backup. Values are of the form
`projects/<project>/instances/<instance>/backups/<backup>`.ApiException
- if the remote call failspublic final Backup getBackup(String name)
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
String name = BackupName.of("[PROJECT]", "[INSTANCE]", "[BACKUP]").toString();
Backup response = databaseAdminClient.getBackup(name);
}
name
- Required. Name of the backup. Values are of the form
`projects/<project>/instances/<instance>/backups/<backup>`.ApiException
- if the remote call failspublic final Backup getBackup(GetBackupRequest request)
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
GetBackupRequest request =
GetBackupRequest.newBuilder()
.setName(BackupName.of("[PROJECT]", "[INSTANCE]", "[BACKUP]").toString())
.build();
Backup response = databaseAdminClient.getBackup(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<GetBackupRequest,Backup> getBackupCallable()
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
GetBackupRequest request =
GetBackupRequest.newBuilder()
.setName(BackupName.of("[PROJECT]", "[INSTANCE]", "[BACKUP]").toString())
.build();
ApiFuture<Backup> future = databaseAdminClient.getBackupCallable().futureCall(request);
// Do something.
Backup response = future.get();
}
public final Backup updateBackup(Backup backup, FieldMask updateMask)
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
Backup backup = Backup.newBuilder().build();
FieldMask updateMask = FieldMask.newBuilder().build();
Backup response = databaseAdminClient.updateBackup(backup, updateMask);
}
backup
- Required. The backup to update. `backup.name`, and the fields to be updated as
specified by `update_mask` are required. Other fields are ignored. Update is only supported
for the following fields: * `backup.expire_time`.updateMask
- Required. A mask specifying which fields (e.g. `expire_time`) in the Backup
resource should be updated. This mask is relative to the Backup resource, not to the
request message. The field mask must always be specified; this prevents any future fields
from being erased accidentally by clients that do not know about them.ApiException
- if the remote call failspublic final Backup updateBackup(UpdateBackupRequest request)
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
UpdateBackupRequest request =
UpdateBackupRequest.newBuilder()
.setBackup(Backup.newBuilder().build())
.setUpdateMask(FieldMask.newBuilder().build())
.build();
Backup response = databaseAdminClient.updateBackup(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<UpdateBackupRequest,Backup> updateBackupCallable()
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
UpdateBackupRequest request =
UpdateBackupRequest.newBuilder()
.setBackup(Backup.newBuilder().build())
.setUpdateMask(FieldMask.newBuilder().build())
.build();
ApiFuture<Backup> future = databaseAdminClient.updateBackupCallable().futureCall(request);
// Do something.
Backup response = future.get();
}
public final void deleteBackup(BackupName name)
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
BackupName name = BackupName.of("[PROJECT]", "[INSTANCE]", "[BACKUP]");
databaseAdminClient.deleteBackup(name);
}
name
- Required. Name of the backup to delete. Values are of the form
`projects/<project>/instances/<instance>/backups/<backup>`.ApiException
- if the remote call failspublic final void deleteBackup(String name)
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
String name = BackupName.of("[PROJECT]", "[INSTANCE]", "[BACKUP]").toString();
databaseAdminClient.deleteBackup(name);
}
name
- Required. Name of the backup to delete. Values are of the form
`projects/<project>/instances/<instance>/backups/<backup>`.ApiException
- if the remote call failspublic final void deleteBackup(DeleteBackupRequest request)
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
DeleteBackupRequest request =
DeleteBackupRequest.newBuilder()
.setName(BackupName.of("[PROJECT]", "[INSTANCE]", "[BACKUP]").toString())
.build();
databaseAdminClient.deleteBackup(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<DeleteBackupRequest,Empty> deleteBackupCallable()
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
DeleteBackupRequest request =
DeleteBackupRequest.newBuilder()
.setName(BackupName.of("[PROJECT]", "[INSTANCE]", "[BACKUP]").toString())
.build();
ApiFuture<Empty> future = databaseAdminClient.deleteBackupCallable().futureCall(request);
// Do something.
future.get();
}
public final DatabaseAdminClient.ListBackupsPagedResponse listBackups(InstanceName parent)
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
for (Backup element : databaseAdminClient.listBackups(parent).iterateAll()) {
// doThingsWith(element);
}
}
parent
- Required. The instance to list backups from. Values are of the form
`projects/<project>/instances/<instance>`.ApiException
- if the remote call failspublic final DatabaseAdminClient.ListBackupsPagedResponse listBackups(String parent)
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
String parent = InstanceName.of("[PROJECT]", "[INSTANCE]").toString();
for (Backup element : databaseAdminClient.listBackups(parent).iterateAll()) {
// doThingsWith(element);
}
}
parent
- Required. The instance to list backups from. Values are of the form
`projects/<project>/instances/<instance>`.ApiException
- if the remote call failspublic final DatabaseAdminClient.ListBackupsPagedResponse listBackups(ListBackupsRequest request)
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
ListBackupsRequest request =
ListBackupsRequest.newBuilder()
.setParent(InstanceName.of("[PROJECT]", "[INSTANCE]").toString())
.setFilter("filter-1274492040")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
for (Backup element : databaseAdminClient.listBackups(request).iterateAll()) {
// doThingsWith(element);
}
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<ListBackupsRequest,DatabaseAdminClient.ListBackupsPagedResponse> listBackupsPagedCallable()
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
ListBackupsRequest request =
ListBackupsRequest.newBuilder()
.setParent(InstanceName.of("[PROJECT]", "[INSTANCE]").toString())
.setFilter("filter-1274492040")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
ApiFuture<Backup> future = databaseAdminClient.listBackupsPagedCallable().futureCall(request);
// Do something.
for (Backup element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
public final UnaryCallable<ListBackupsRequest,ListBackupsResponse> listBackupsCallable()
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
ListBackupsRequest request =
ListBackupsRequest.newBuilder()
.setParent(InstanceName.of("[PROJECT]", "[INSTANCE]").toString())
.setFilter("filter-1274492040")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
while (true) {
ListBackupsResponse response = databaseAdminClient.listBackupsCallable().call(request);
for (Backup element : response.getResponsesList()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
public final OperationFuture<Database,RestoreDatabaseMetadata> restoreDatabaseAsync(InstanceName parent, String databaseId, BackupName backup)
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
String databaseId = "databaseId1688905718";
BackupName backup = BackupName.of("[PROJECT]", "[INSTANCE]", "[BACKUP]");
Database response =
databaseAdminClient.restoreDatabaseAsync(parent, databaseId, backup).get();
}
parent
- Required. The name of the instance in which to create the restored database. This
instance must be in the same project and have the same instance configuration as the
instance containing the source backup. Values are of the form
`projects/<project>/instances/<instance>`.databaseId
- Required. The id of the database to create and restore to. This database must
not already exist. The `database_id` appended to `parent` forms the full database name of
the form
`projects/<project>/instances/<instance>/databases/<database_id>`.backup
- Name of the backup from which to restore. Values are of the form
`projects/<project>/instances/<instance>/backups/<backup>`.ApiException
- if the remote call failspublic final OperationFuture<Database,RestoreDatabaseMetadata> restoreDatabaseAsync(InstanceName parent, String databaseId, String backup)
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
String databaseId = "databaseId1688905718";
String backup = BackupName.of("[PROJECT]", "[INSTANCE]", "[BACKUP]").toString();
Database response =
databaseAdminClient.restoreDatabaseAsync(parent, databaseId, backup).get();
}
parent
- Required. The name of the instance in which to create the restored database. This
instance must be in the same project and have the same instance configuration as the
instance containing the source backup. Values are of the form
`projects/<project>/instances/<instance>`.databaseId
- Required. The id of the database to create and restore to. This database must
not already exist. The `database_id` appended to `parent` forms the full database name of
the form
`projects/<project>/instances/<instance>/databases/<database_id>`.backup
- Name of the backup from which to restore. Values are of the form
`projects/<project>/instances/<instance>/backups/<backup>`.ApiException
- if the remote call failspublic final OperationFuture<Database,RestoreDatabaseMetadata> restoreDatabaseAsync(String parent, String databaseId, BackupName backup)
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
String parent = InstanceName.of("[PROJECT]", "[INSTANCE]").toString();
String databaseId = "databaseId1688905718";
BackupName backup = BackupName.of("[PROJECT]", "[INSTANCE]", "[BACKUP]");
Database response =
databaseAdminClient.restoreDatabaseAsync(parent, databaseId, backup).get();
}
parent
- Required. The name of the instance in which to create the restored database. This
instance must be in the same project and have the same instance configuration as the
instance containing the source backup. Values are of the form
`projects/<project>/instances/<instance>`.databaseId
- Required. The id of the database to create and restore to. This database must
not already exist. The `database_id` appended to `parent` forms the full database name of
the form
`projects/<project>/instances/<instance>/databases/<database_id>`.backup
- Name of the backup from which to restore. Values are of the form
`projects/<project>/instances/<instance>/backups/<backup>`.ApiException
- if the remote call failspublic final OperationFuture<Database,RestoreDatabaseMetadata> restoreDatabaseAsync(String parent, String databaseId, String backup)
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
String parent = InstanceName.of("[PROJECT]", "[INSTANCE]").toString();
String databaseId = "databaseId1688905718";
String backup = BackupName.of("[PROJECT]", "[INSTANCE]", "[BACKUP]").toString();
Database response =
databaseAdminClient.restoreDatabaseAsync(parent, databaseId, backup).get();
}
parent
- Required. The name of the instance in which to create the restored database. This
instance must be in the same project and have the same instance configuration as the
instance containing the source backup. Values are of the form
`projects/<project>/instances/<instance>`.databaseId
- Required. The id of the database to create and restore to. This database must
not already exist. The `database_id` appended to `parent` forms the full database name of
the form
`projects/<project>/instances/<instance>/databases/<database_id>`.backup
- Name of the backup from which to restore. Values are of the form
`projects/<project>/instances/<instance>/backups/<backup>`.ApiException
- if the remote call failspublic final OperationFuture<Database,RestoreDatabaseMetadata> restoreDatabaseAsync(RestoreDatabaseRequest request)
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
RestoreDatabaseRequest request =
RestoreDatabaseRequest.newBuilder()
.setParent(InstanceName.of("[PROJECT]", "[INSTANCE]").toString())
.setDatabaseId("databaseId1688905718")
.setEncryptionConfig(RestoreDatabaseEncryptionConfig.newBuilder().build())
.build();
Database response = databaseAdminClient.restoreDatabaseAsync(request).get();
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final OperationCallable<RestoreDatabaseRequest,Database,RestoreDatabaseMetadata> restoreDatabaseOperationCallable()
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
RestoreDatabaseRequest request =
RestoreDatabaseRequest.newBuilder()
.setParent(InstanceName.of("[PROJECT]", "[INSTANCE]").toString())
.setDatabaseId("databaseId1688905718")
.setEncryptionConfig(RestoreDatabaseEncryptionConfig.newBuilder().build())
.build();
OperationFuture<Database, RestoreDatabaseMetadata> future =
databaseAdminClient.restoreDatabaseOperationCallable().futureCall(request);
// Do something.
Database response = future.get();
}
public final UnaryCallable<RestoreDatabaseRequest,Operation> restoreDatabaseCallable()
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
RestoreDatabaseRequest request =
RestoreDatabaseRequest.newBuilder()
.setParent(InstanceName.of("[PROJECT]", "[INSTANCE]").toString())
.setDatabaseId("databaseId1688905718")
.setEncryptionConfig(RestoreDatabaseEncryptionConfig.newBuilder().build())
.build();
ApiFuture<Operation> future =
databaseAdminClient.restoreDatabaseCallable().futureCall(request);
// Do something.
Operation response = future.get();
}
public final DatabaseAdminClient.ListDatabaseOperationsPagedResponse listDatabaseOperations(InstanceName parent)
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
for (Operation element : databaseAdminClient.listDatabaseOperations(parent).iterateAll()) {
// doThingsWith(element);
}
}
parent
- Required. The instance of the database operations. Values are of the form
`projects/<project>/instances/<instance>`.ApiException
- if the remote call failspublic final DatabaseAdminClient.ListDatabaseOperationsPagedResponse listDatabaseOperations(String parent)
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
String parent = InstanceName.of("[PROJECT]", "[INSTANCE]").toString();
for (Operation element : databaseAdminClient.listDatabaseOperations(parent).iterateAll()) {
// doThingsWith(element);
}
}
parent
- Required. The instance of the database operations. Values are of the form
`projects/<project>/instances/<instance>`.ApiException
- if the remote call failspublic final DatabaseAdminClient.ListDatabaseOperationsPagedResponse listDatabaseOperations(ListDatabaseOperationsRequest request)
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
ListDatabaseOperationsRequest request =
ListDatabaseOperationsRequest.newBuilder()
.setParent(InstanceName.of("[PROJECT]", "[INSTANCE]").toString())
.setFilter("filter-1274492040")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
for (Operation element : databaseAdminClient.listDatabaseOperations(request).iterateAll()) {
// doThingsWith(element);
}
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<ListDatabaseOperationsRequest,DatabaseAdminClient.ListDatabaseOperationsPagedResponse> listDatabaseOperationsPagedCallable()
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
ListDatabaseOperationsRequest request =
ListDatabaseOperationsRequest.newBuilder()
.setParent(InstanceName.of("[PROJECT]", "[INSTANCE]").toString())
.setFilter("filter-1274492040")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
ApiFuture<Operation> future =
databaseAdminClient.listDatabaseOperationsPagedCallable().futureCall(request);
// Do something.
for (Operation element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
public final UnaryCallable<ListDatabaseOperationsRequest,ListDatabaseOperationsResponse> listDatabaseOperationsCallable()
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
ListDatabaseOperationsRequest request =
ListDatabaseOperationsRequest.newBuilder()
.setParent(InstanceName.of("[PROJECT]", "[INSTANCE]").toString())
.setFilter("filter-1274492040")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
while (true) {
ListDatabaseOperationsResponse response =
databaseAdminClient.listDatabaseOperationsCallable().call(request);
for (Operation element : response.getResponsesList()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
public final DatabaseAdminClient.ListBackupOperationsPagedResponse listBackupOperations(InstanceName parent)
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
for (Operation element : databaseAdminClient.listBackupOperations(parent).iterateAll()) {
// doThingsWith(element);
}
}
parent
- Required. The instance of the backup operations. Values are of the form
`projects/<project>/instances/<instance>`.ApiException
- if the remote call failspublic final DatabaseAdminClient.ListBackupOperationsPagedResponse listBackupOperations(String parent)
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
String parent = InstanceName.of("[PROJECT]", "[INSTANCE]").toString();
for (Operation element : databaseAdminClient.listBackupOperations(parent).iterateAll()) {
// doThingsWith(element);
}
}
parent
- Required. The instance of the backup operations. Values are of the form
`projects/<project>/instances/<instance>`.ApiException
- if the remote call failspublic final DatabaseAdminClient.ListBackupOperationsPagedResponse listBackupOperations(ListBackupOperationsRequest request)
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
ListBackupOperationsRequest request =
ListBackupOperationsRequest.newBuilder()
.setParent(InstanceName.of("[PROJECT]", "[INSTANCE]").toString())
.setFilter("filter-1274492040")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
for (Operation element : databaseAdminClient.listBackupOperations(request).iterateAll()) {
// doThingsWith(element);
}
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<ListBackupOperationsRequest,DatabaseAdminClient.ListBackupOperationsPagedResponse> listBackupOperationsPagedCallable()
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
ListBackupOperationsRequest request =
ListBackupOperationsRequest.newBuilder()
.setParent(InstanceName.of("[PROJECT]", "[INSTANCE]").toString())
.setFilter("filter-1274492040")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
ApiFuture<Operation> future =
databaseAdminClient.listBackupOperationsPagedCallable().futureCall(request);
// Do something.
for (Operation element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
public final UnaryCallable<ListBackupOperationsRequest,ListBackupOperationsResponse> listBackupOperationsCallable()
Sample code:
// This snippet has been automatically generated for illustrative purposes only.
// It may require modifications to work in your environment.
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
ListBackupOperationsRequest request =
ListBackupOperationsRequest.newBuilder()
.setParent(InstanceName.of("[PROJECT]", "[INSTANCE]").toString())
.setFilter("filter-1274492040")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
while (true) {
ListBackupOperationsResponse response =
databaseAdminClient.listBackupOperationsCallable().call(request);
for (Operation element : response.getResponsesList()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
public final void close()
close
in interface AutoCloseable
public void shutdown()
shutdown
in interface BackgroundResource
public boolean isShutdown()
isShutdown
in interface BackgroundResource
public boolean isTerminated()
isTerminated
in interface BackgroundResource
public void shutdownNow()
shutdownNow
in interface BackgroundResource
public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException
awaitTermination
in interface BackgroundResource
InterruptedException
Copyright © 2022 Google LLC. All rights reserved.