| GitHub Repository | Product Reference |
Service Description: Service for managing database backups.
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 and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (SqlBackupRunsServiceClient sqlBackupRunsServiceClient =
SqlBackupRunsServiceClient.create()) {
SqlBackupRunsDeleteRequest request =
SqlBackupRunsDeleteRequest.newBuilder()
.setId(3355)
.setInstance("instance555127957")
.setProject("project-309310695")
.build();
Operation response = sqlBackupRunsServiceClient.delete(request);
}
Note: close() needs to be called on the SqlBackupRunsServiceClient object to clean up resources such as threads. In the example above, try-with-resources is used, which automatically calls close().
| Method | Description | Method Variants |
|---|---|---|
Delete |
Deletes the backup taken by a backup run. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
Get |
Retrieves a resource containing information about a backup run. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
Insert |
Creates a new backup run on demand. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
List |
Lists all backup runs associated with the project or a given instance and configuration in the reverse chronological order of the backup initiation time. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
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 SqlBackupRunsServiceSettings to create(). For example:
To customize credentials:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
SqlBackupRunsServiceSettings sqlBackupRunsServiceSettings =
SqlBackupRunsServiceSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
SqlBackupRunsServiceClient sqlBackupRunsServiceClient =
SqlBackupRunsServiceClient.create(sqlBackupRunsServiceSettings);
To customize the endpoint:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
SqlBackupRunsServiceSettings sqlBackupRunsServiceSettings =
SqlBackupRunsServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
SqlBackupRunsServiceClient sqlBackupRunsServiceClient =
SqlBackupRunsServiceClient.create(sqlBackupRunsServiceSettings);
To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over the wire:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
SqlBackupRunsServiceSettings sqlBackupRunsServiceSettings =
SqlBackupRunsServiceSettings.newHttpJsonBuilder().build();
SqlBackupRunsServiceClient sqlBackupRunsServiceClient =
SqlBackupRunsServiceClient.create(sqlBackupRunsServiceSettings);
Please refer to the GitHub repository's samples for more quickstart code snippets.
Static Methods
create()
public static final SqlBackupRunsServiceClient create()Constructs an instance of SqlBackupRunsServiceClient with default settings.
| Returns | |
|---|---|
| Type | Description |
SqlBackupRunsServiceClient |
|
| Exceptions | |
|---|---|
| Type | Description |
IOException |
|
create(SqlBackupRunsServiceSettings settings)
public static final SqlBackupRunsServiceClient create(SqlBackupRunsServiceSettings settings)Constructs an instance of SqlBackupRunsServiceClient, using the given settings. The channels are created based on the settings passed in, or defaults for any settings that are not set.
| Parameter | |
|---|---|
| Name | Description |
settings |
SqlBackupRunsServiceSettings |
| Returns | |
|---|---|
| Type | Description |
SqlBackupRunsServiceClient |
|
| Exceptions | |
|---|---|
| Type | Description |
IOException |
|
create(SqlBackupRunsServiceStub stub)
public static final SqlBackupRunsServiceClient create(SqlBackupRunsServiceStub stub)Constructs an instance of SqlBackupRunsServiceClient, using the given stub for making calls. This is for advanced usage - prefer using create(SqlBackupRunsServiceSettings).
| Parameter | |
|---|---|
| Name | Description |
stub |
SqlBackupRunsServiceStub |
| Returns | |
|---|---|
| Type | Description |
SqlBackupRunsServiceClient |
|
Constructors
SqlBackupRunsServiceClient(SqlBackupRunsServiceSettings settings)
protected SqlBackupRunsServiceClient(SqlBackupRunsServiceSettings settings)Constructs an instance of SqlBackupRunsServiceClient, using the given settings. This is protected so that it is easy to make a subclass, but otherwise, the static factory methods should be preferred.
| Parameter | |
|---|---|
| Name | Description |
settings |
SqlBackupRunsServiceSettings |
SqlBackupRunsServiceClient(SqlBackupRunsServiceStub stub)
protected SqlBackupRunsServiceClient(SqlBackupRunsServiceStub stub)| Parameter | |
|---|---|
| Name | Description |
stub |
SqlBackupRunsServiceStub |
Methods
awaitTermination(long duration, TimeUnit unit)
public boolean awaitTermination(long duration, TimeUnit unit)| Parameters | |
|---|---|
| Name | Description |
duration |
long |
unit |
TimeUnit |
| Returns | |
|---|---|
| Type | Description |
boolean |
|
| Exceptions | |
|---|---|
| Type | Description |
InterruptedException |
|
close()
public final void close()delete(SqlBackupRunsDeleteRequest request)
public final Operation delete(SqlBackupRunsDeleteRequest request)Deletes the backup taken by a backup run.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (SqlBackupRunsServiceClient sqlBackupRunsServiceClient =
SqlBackupRunsServiceClient.create()) {
SqlBackupRunsDeleteRequest request =
SqlBackupRunsDeleteRequest.newBuilder()
.setId(3355)
.setInstance("instance555127957")
.setProject("project-309310695")
.build();
Operation response = sqlBackupRunsServiceClient.delete(request);
}
| Parameter | |
|---|---|
| Name | Description |
request |
SqlBackupRunsDeleteRequestThe request object containing all of the parameters for the API call. |
| Returns | |
|---|---|
| Type | Description |
Operation |
|
deleteCallable()
public final UnaryCallable<SqlBackupRunsDeleteRequest,Operation> deleteCallable()Deletes the backup taken by a backup run.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (SqlBackupRunsServiceClient sqlBackupRunsServiceClient =
SqlBackupRunsServiceClient.create()) {
SqlBackupRunsDeleteRequest request =
SqlBackupRunsDeleteRequest.newBuilder()
.setId(3355)
.setInstance("instance555127957")
.setProject("project-309310695")
.build();
ApiFuture<Operation> future = sqlBackupRunsServiceClient.deleteCallable().futureCall(request);
// Do something.
Operation response = future.get();
}
| Returns | |
|---|---|
| Type | Description |
UnaryCallable<SqlBackupRunsDeleteRequest,Operation> |
|
get(SqlBackupRunsGetRequest request)
public final BackupRun get(SqlBackupRunsGetRequest request)Retrieves a resource containing information about a backup run.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (SqlBackupRunsServiceClient sqlBackupRunsServiceClient =
SqlBackupRunsServiceClient.create()) {
SqlBackupRunsGetRequest request =
SqlBackupRunsGetRequest.newBuilder()
.setId(3355)
.setInstance("instance555127957")
.setProject("project-309310695")
.build();
BackupRun response = sqlBackupRunsServiceClient.get(request);
}
| Parameter | |
|---|---|
| Name | Description |
request |
SqlBackupRunsGetRequestThe request object containing all of the parameters for the API call. |
| Returns | |
|---|---|
| Type | Description |
BackupRun |
|
getCallable()
public final UnaryCallable<SqlBackupRunsGetRequest,BackupRun> getCallable()Retrieves a resource containing information about a backup run.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (SqlBackupRunsServiceClient sqlBackupRunsServiceClient =
SqlBackupRunsServiceClient.create()) {
SqlBackupRunsGetRequest request =
SqlBackupRunsGetRequest.newBuilder()
.setId(3355)
.setInstance("instance555127957")
.setProject("project-309310695")
.build();
ApiFuture<BackupRun> future = sqlBackupRunsServiceClient.getCallable().futureCall(request);
// Do something.
BackupRun response = future.get();
}
| Returns | |
|---|---|
| Type | Description |
UnaryCallable<SqlBackupRunsGetRequest,BackupRun> |
|
getSettings()
public final @Nullable SqlBackupRunsServiceSettings getSettings()| Returns | |
|---|---|
| Type | Description |
@org.jspecify.annotations.Nullable com.google.cloud.sql.v1.SqlBackupRunsServiceSettings |
|
getStub()
public SqlBackupRunsServiceStub getStub()| Returns | |
|---|---|
| Type | Description |
SqlBackupRunsServiceStub |
|
insert(SqlBackupRunsInsertRequest request)
public final Operation insert(SqlBackupRunsInsertRequest request)Creates a new backup run on demand.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (SqlBackupRunsServiceClient sqlBackupRunsServiceClient =
SqlBackupRunsServiceClient.create()) {
SqlBackupRunsInsertRequest request =
SqlBackupRunsInsertRequest.newBuilder()
.setInstance("instance555127957")
.setProject("project-309310695")
.setBody(BackupRun.newBuilder().build())
.build();
Operation response = sqlBackupRunsServiceClient.insert(request);
}
| Parameter | |
|---|---|
| Name | Description |
request |
SqlBackupRunsInsertRequestThe request object containing all of the parameters for the API call. |
| Returns | |
|---|---|
| Type | Description |
Operation |
|
insertCallable()
public final UnaryCallable<SqlBackupRunsInsertRequest,Operation> insertCallable()Creates a new backup run on demand.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (SqlBackupRunsServiceClient sqlBackupRunsServiceClient =
SqlBackupRunsServiceClient.create()) {
SqlBackupRunsInsertRequest request =
SqlBackupRunsInsertRequest.newBuilder()
.setInstance("instance555127957")
.setProject("project-309310695")
.setBody(BackupRun.newBuilder().build())
.build();
ApiFuture<Operation> future = sqlBackupRunsServiceClient.insertCallable().futureCall(request);
// Do something.
Operation response = future.get();
}
| Returns | |
|---|---|
| Type | Description |
UnaryCallable<SqlBackupRunsInsertRequest,Operation> |
|
isShutdown()
public boolean isShutdown()| Returns | |
|---|---|
| Type | Description |
boolean |
|
isTerminated()
public boolean isTerminated()| Returns | |
|---|---|
| Type | Description |
boolean |
|
list(SqlBackupRunsListRequest request)
public final BackupRunsListResponse list(SqlBackupRunsListRequest request)Lists all backup runs associated with the project or a given instance and configuration in the reverse chronological order of the backup initiation time.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (SqlBackupRunsServiceClient sqlBackupRunsServiceClient =
SqlBackupRunsServiceClient.create()) {
SqlBackupRunsListRequest request =
SqlBackupRunsListRequest.newBuilder()
.setInstance("instance555127957")
.setMaxResults(1128457243)
.setPageToken("pageToken873572522")
.setProject("project-309310695")
.build();
BackupRunsListResponse response = sqlBackupRunsServiceClient.list(request);
}
| Parameter | |
|---|---|
| Name | Description |
request |
SqlBackupRunsListRequestThe request object containing all of the parameters for the API call. |
| Returns | |
|---|---|
| Type | Description |
BackupRunsListResponse |
|
listCallable()
public final UnaryCallable<SqlBackupRunsListRequest,BackupRunsListResponse> listCallable()Lists all backup runs associated with the project or a given instance and configuration in the reverse chronological order of the backup initiation time.
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (SqlBackupRunsServiceClient sqlBackupRunsServiceClient =
SqlBackupRunsServiceClient.create()) {
SqlBackupRunsListRequest request =
SqlBackupRunsListRequest.newBuilder()
.setInstance("instance555127957")
.setMaxResults(1128457243)
.setPageToken("pageToken873572522")
.setProject("project-309310695")
.build();
ApiFuture<BackupRunsListResponse> future =
sqlBackupRunsServiceClient.listCallable().futureCall(request);
// Do something.
BackupRunsListResponse response = future.get();
}
| Returns | |
|---|---|
| Type | Description |
UnaryCallable<SqlBackupRunsListRequest,BackupRunsListResponse> |
|
shutdown()
public void shutdown()shutdownNow()
public void shutdownNow()