@Generated(value="by gapic-generator") @BetaApi public class CloudRedisClient extends Object implements com.google.api.gax.core.BackgroundResource
Google Cloud Memorystore for Redis v1
The `redis.googleapis.com` service implements the Google Cloud Memorystore for Redis API and defines the following resource model for managing Redis instances: * The service works with a collection of cloud projects, named: `/projects/*` * Each project has a collection of available locations, named: `/locations/*` * Each location has a collection of Redis instances, named: `/instances/*` * As such, Redis instances are resources of the form: `/projects/{project_id}/locations/{location_id}/instances/{instance_id}`
Note that location_id must be referring to a GCP `region`; for example: * `projects/redpepper-1290/locations/us-central1/instances/my-redis`
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:
try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
InstanceName name = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]");
Instance response = cloudRedisClient.getInstance(name);
}
Note: close() needs to be called on the cloudRedisClient 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 CloudRedisSettings to create(). For example:
To customize credentials:
CloudRedisSettings cloudRedisSettings =
CloudRedisSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
CloudRedisClient cloudRedisClient =
CloudRedisClient.create(cloudRedisSettings);
To customize the endpoint:
CloudRedisSettings cloudRedisSettings =
CloudRedisSettings.newBuilder().setEndpoint(myEndpoint).build();
CloudRedisClient cloudRedisClient =
CloudRedisClient.create(cloudRedisSettings);
Modifier and Type | Class and Description |
---|---|
static class |
CloudRedisClient.ListInstancesFixedSizeCollection |
static class |
CloudRedisClient.ListInstancesPage |
static class |
CloudRedisClient.ListInstancesPagedResponse |
Modifier | Constructor and Description |
---|---|
protected |
CloudRedisClient(CloudRedisSettings settings)
Constructs an instance of CloudRedisClient, using the given settings.
|
protected |
CloudRedisClient(CloudRedisStub stub) |
Modifier and Type | Method and Description |
---|---|
boolean |
awaitTermination(long duration,
TimeUnit unit) |
void |
close() |
static CloudRedisClient |
create()
Constructs an instance of CloudRedisClient with default settings.
|
static CloudRedisClient |
create(CloudRedisSettings settings)
Constructs an instance of CloudRedisClient, using the given settings.
|
static CloudRedisClient |
create(CloudRedisStub stub)
Constructs an instance of CloudRedisClient, using the given stub for making calls.
|
com.google.api.gax.longrunning.OperationFuture<Instance,OperationMetadata> |
createInstanceAsync(CreateInstanceRequest request)
Creates a Redis instance based on the specified tier and memory size.
|
com.google.api.gax.longrunning.OperationFuture<Instance,OperationMetadata> |
createInstanceAsync(LocationName parent,
String instanceId,
Instance instance)
Creates a Redis instance based on the specified tier and memory size.
|
com.google.api.gax.longrunning.OperationFuture<Instance,OperationMetadata> |
createInstanceAsync(String parent,
String instanceId,
Instance instance)
Creates a Redis instance based on the specified tier and memory size.
|
com.google.api.gax.rpc.UnaryCallable<CreateInstanceRequest,com.google.longrunning.Operation> |
createInstanceCallable()
Creates a Redis instance based on the specified tier and memory size.
|
com.google.api.gax.rpc.OperationCallable<CreateInstanceRequest,Instance,OperationMetadata> |
createInstanceOperationCallable()
Creates a Redis instance based on the specified tier and memory size.
|
com.google.api.gax.longrunning.OperationFuture<Empty,OperationMetadata> |
deleteInstanceAsync(DeleteInstanceRequest request)
Deletes a specific Redis instance.
|
com.google.api.gax.longrunning.OperationFuture<Empty,OperationMetadata> |
deleteInstanceAsync(InstanceName name)
Deletes a specific Redis instance.
|
com.google.api.gax.longrunning.OperationFuture<Empty,OperationMetadata> |
deleteInstanceAsync(String name)
Deletes a specific Redis instance.
|
com.google.api.gax.rpc.UnaryCallable<DeleteInstanceRequest,com.google.longrunning.Operation> |
deleteInstanceCallable()
Deletes a specific Redis instance.
|
com.google.api.gax.rpc.OperationCallable<DeleteInstanceRequest,Empty,OperationMetadata> |
deleteInstanceOperationCallable()
Deletes a specific Redis instance.
|
com.google.api.gax.longrunning.OperationFuture<Instance,OperationMetadata> |
exportInstanceAsync(ExportInstanceRequest request)
Export Redis instance data into a Redis RDB format file in Cloud Storage.
|
com.google.api.gax.longrunning.OperationFuture<Instance,OperationMetadata> |
exportInstanceAsync(String name,
OutputConfig outputConfig)
Export Redis instance data into a Redis RDB format file in Cloud Storage.
|
com.google.api.gax.rpc.UnaryCallable<ExportInstanceRequest,com.google.longrunning.Operation> |
exportInstanceCallable()
Export Redis instance data into a Redis RDB format file in Cloud Storage.
|
com.google.api.gax.rpc.OperationCallable<ExportInstanceRequest,Instance,OperationMetadata> |
exportInstanceOperationCallable()
Export Redis instance data into a Redis RDB format file in Cloud Storage.
|
com.google.api.gax.longrunning.OperationFuture<Instance,OperationMetadata> |
failoverInstanceAsync(FailoverInstanceRequest request)
Initiates a failover of the master node to current replica node for a specific STANDARD tier
Cloud Memorystore for Redis instance.
|
com.google.api.gax.longrunning.OperationFuture<Instance,OperationMetadata> |
failoverInstanceAsync(InstanceName name,
FailoverInstanceRequest.DataProtectionMode dataProtectionMode)
Initiates a failover of the master node to current replica node for a specific STANDARD tier
Cloud Memorystore for Redis instance.
|
com.google.api.gax.longrunning.OperationFuture<Instance,OperationMetadata> |
failoverInstanceAsync(String name,
FailoverInstanceRequest.DataProtectionMode dataProtectionMode)
Initiates a failover of the master node to current replica node for a specific STANDARD tier
Cloud Memorystore for Redis instance.
|
com.google.api.gax.rpc.UnaryCallable<FailoverInstanceRequest,com.google.longrunning.Operation> |
failoverInstanceCallable()
Initiates a failover of the master node to current replica node for a specific STANDARD tier
Cloud Memorystore for Redis instance.
|
com.google.api.gax.rpc.OperationCallable<FailoverInstanceRequest,Instance,OperationMetadata> |
failoverInstanceOperationCallable()
Initiates a failover of the master node to current replica node for a specific STANDARD tier
Cloud Memorystore for Redis instance.
|
Instance |
getInstance(GetInstanceRequest request)
Gets the details of a specific Redis instance.
|
Instance |
getInstance(InstanceName name)
Gets the details of a specific Redis instance.
|
Instance |
getInstance(String name)
Gets the details of a specific Redis instance.
|
com.google.api.gax.rpc.UnaryCallable<GetInstanceRequest,Instance> |
getInstanceCallable()
Gets the details of a specific Redis instance.
|
com.google.longrunning.OperationsClient |
getOperationsClient()
Returns the OperationsClient that can be used to query the status of a long-running operation
returned by another API method call.
|
CloudRedisSettings |
getSettings() |
CloudRedisStub |
getStub() |
com.google.api.gax.longrunning.OperationFuture<Instance,OperationMetadata> |
importInstanceAsync(ImportInstanceRequest request)
Import a Redis RDB snapshot file from Cloud Storage into a Redis instance.
|
com.google.api.gax.longrunning.OperationFuture<Instance,OperationMetadata> |
importInstanceAsync(String name,
InputConfig inputConfig)
Import a Redis RDB snapshot file from Cloud Storage into a Redis instance.
|
com.google.api.gax.rpc.UnaryCallable<ImportInstanceRequest,com.google.longrunning.Operation> |
importInstanceCallable()
Import a Redis RDB snapshot file from Cloud Storage into a Redis instance.
|
com.google.api.gax.rpc.OperationCallable<ImportInstanceRequest,Instance,OperationMetadata> |
importInstanceOperationCallable()
Import a Redis RDB snapshot file from Cloud Storage into a Redis instance.
|
boolean |
isShutdown() |
boolean |
isTerminated() |
CloudRedisClient.ListInstancesPagedResponse |
listInstances(ListInstancesRequest request)
Lists all Redis instances owned by a project in either the specified location (region) or all
locations.
|
CloudRedisClient.ListInstancesPagedResponse |
listInstances(LocationName parent)
Lists all Redis instances owned by a project in either the specified location (region) or all
locations.
|
CloudRedisClient.ListInstancesPagedResponse |
listInstances(String parent)
Lists all Redis instances owned by a project in either the specified location (region) or all
locations.
|
com.google.api.gax.rpc.UnaryCallable<ListInstancesRequest,ListInstancesResponse> |
listInstancesCallable()
Lists all Redis instances owned by a project in either the specified location (region) or all
locations.
|
com.google.api.gax.rpc.UnaryCallable<ListInstancesRequest,CloudRedisClient.ListInstancesPagedResponse> |
listInstancesPagedCallable()
Lists all Redis instances owned by a project in either the specified location (region) or all
locations.
|
void |
shutdown() |
void |
shutdownNow() |
com.google.api.gax.longrunning.OperationFuture<Instance,OperationMetadata> |
updateInstanceAsync(FieldMask updateMask,
Instance instance)
Updates the metadata and configuration of a specific Redis instance.
|
com.google.api.gax.longrunning.OperationFuture<Instance,OperationMetadata> |
updateInstanceAsync(UpdateInstanceRequest request)
Updates the metadata and configuration of a specific Redis instance.
|
com.google.api.gax.rpc.UnaryCallable<UpdateInstanceRequest,com.google.longrunning.Operation> |
updateInstanceCallable()
Updates the metadata and configuration of a specific Redis instance.
|
com.google.api.gax.rpc.OperationCallable<UpdateInstanceRequest,Instance,OperationMetadata> |
updateInstanceOperationCallable()
Updates the metadata and configuration of a specific Redis instance.
|
protected CloudRedisClient(CloudRedisSettings settings) throws IOException
IOException
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") protected CloudRedisClient(CloudRedisStub stub)
public static final CloudRedisClient create() throws IOException
IOException
public static final CloudRedisClient create(CloudRedisSettings settings) throws IOException
IOException
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") public static final CloudRedisClient create(CloudRedisStub stub)
public final CloudRedisSettings getSettings()
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") public CloudRedisStub getStub()
@BetaApi(value="The surface for long-running operations is not stable yet and may change in the future.") public final com.google.longrunning.OperationsClient getOperationsClient()
public final CloudRedisClient.ListInstancesPagedResponse listInstances(LocationName parent)
The location should have the following format: * `projects/{project_id}/locations/{location_id}`
If `location_id` is specified as `-` (wildcard), then all regions available to the project are queried, and the results are aggregated.
Sample code:
try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
for (Instance element : cloudRedisClient.listInstances(parent).iterateAll()) {
// doThingsWith(element);
}
}
parent
- Required. The resource name of the instance location using the form:
`projects/{project_id}/locations/{location_id}` where `location_id` refers to a GCP region.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final CloudRedisClient.ListInstancesPagedResponse listInstances(String parent)
The location should have the following format: * `projects/{project_id}/locations/{location_id}`
If `location_id` is specified as `-` (wildcard), then all regions available to the project are queried, and the results are aggregated.
Sample code:
try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
for (Instance element : cloudRedisClient.listInstances(parent.toString()).iterateAll()) {
// doThingsWith(element);
}
}
parent
- Required. The resource name of the instance location using the form:
`projects/{project_id}/locations/{location_id}` where `location_id` refers to a GCP region.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final CloudRedisClient.ListInstancesPagedResponse listInstances(ListInstancesRequest request)
The location should have the following format: * `projects/{project_id}/locations/{location_id}`
If `location_id` is specified as `-` (wildcard), then all regions available to the project are queried, and the results are aggregated.
Sample code:
try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
ListInstancesRequest request = ListInstancesRequest.newBuilder()
.setParent(parent.toString())
.build();
for (Instance element : cloudRedisClient.listInstances(request).iterateAll()) {
// doThingsWith(element);
}
}
request
- The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<ListInstancesRequest,CloudRedisClient.ListInstancesPagedResponse> listInstancesPagedCallable()
The location should have the following format: * `projects/{project_id}/locations/{location_id}`
If `location_id` is specified as `-` (wildcard), then all regions available to the project are queried, and the results are aggregated.
Sample code:
try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
ListInstancesRequest request = ListInstancesRequest.newBuilder()
.setParent(parent.toString())
.build();
ApiFuture<ListInstancesPagedResponse> future = cloudRedisClient.listInstancesPagedCallable().futureCall(request);
// Do something
for (Instance element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
public final com.google.api.gax.rpc.UnaryCallable<ListInstancesRequest,ListInstancesResponse> listInstancesCallable()
The location should have the following format: * `projects/{project_id}/locations/{location_id}`
If `location_id` is specified as `-` (wildcard), then all regions available to the project are queried, and the results are aggregated.
Sample code:
try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
ListInstancesRequest request = ListInstancesRequest.newBuilder()
.setParent(parent.toString())
.build();
while (true) {
ListInstancesResponse response = cloudRedisClient.listInstancesCallable().call(request);
for (Instance element : response.getInstancesList()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
public final Instance getInstance(InstanceName name)
Sample code:
try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
InstanceName name = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]");
Instance response = cloudRedisClient.getInstance(name);
}
name
- Required. Redis instance resource name using the form:
`projects/{project_id}/locations/{location_id}/instances/{instance_id}` where `location_id`
refers to a GCP region.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final Instance getInstance(String name)
Sample code:
try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
InstanceName name = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]");
Instance response = cloudRedisClient.getInstance(name.toString());
}
name
- Required. Redis instance resource name using the form:
`projects/{project_id}/locations/{location_id}/instances/{instance_id}` where `location_id`
refers to a GCP region.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final Instance getInstance(GetInstanceRequest request)
Sample code:
try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
InstanceName name = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]");
GetInstanceRequest request = GetInstanceRequest.newBuilder()
.setName(name.toString())
.build();
Instance response = cloudRedisClient.getInstance(request);
}
request
- The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<GetInstanceRequest,Instance> getInstanceCallable()
Sample code:
try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
InstanceName name = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]");
GetInstanceRequest request = GetInstanceRequest.newBuilder()
.setName(name.toString())
.build();
ApiFuture<Instance> future = cloudRedisClient.getInstanceCallable().futureCall(request);
// Do something
Instance response = future.get();
}
@BetaApi(value="The surface for long-running operations is not stable yet and may change in the future.") public final com.google.api.gax.longrunning.OperationFuture<Instance,OperationMetadata> createInstanceAsync(LocationName parent, String instanceId, Instance instance)
By default, the instance is accessible from the project's [default network](/compute/docs/networks-and-firewalls#networks).
The creation is executed asynchronously and callers may check the returned operation to track its progress. Once the operation is completed the Redis instance will be fully functional. Completed longrunning.Operation will contain the new instance object in the response field.
The returned operation is automatically deleted after a few hours, so there is no need to call DeleteOperation.
Sample code:
try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
String instanceId = "test_instance";
Instance.Tier tier = Instance.Tier.BASIC;
int memorySizeGb = 1;
Instance instance = Instance.newBuilder()
.setTier(tier)
.setMemorySizeGb(memorySizeGb)
.build();
Instance response = cloudRedisClient.createInstanceAsync(parent, instanceId, instance).get();
}
parent
- Required. The resource name of the instance location using the form:
`projects/{project_id}/locations/{location_id}` where `location_id` refers to a GCP region.instanceId
- Required. The logical name of the Redis instance in the customer project with
the following restrictions:
* Must contain only lowercase letters, numbers, and hyphens. * Must start with a letter. * Must be between 1-40 characters. * Must end with a number or a letter. * Must be unique within the customer project / location
instance
- Required. A Redis [Instance] resourcecom.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi(value="The surface for long-running operations is not stable yet and may change in the future.") public final com.google.api.gax.longrunning.OperationFuture<Instance,OperationMetadata> createInstanceAsync(String parent, String instanceId, Instance instance)
By default, the instance is accessible from the project's [default network](/compute/docs/networks-and-firewalls#networks).
The creation is executed asynchronously and callers may check the returned operation to track its progress. Once the operation is completed the Redis instance will be fully functional. Completed longrunning.Operation will contain the new instance object in the response field.
The returned operation is automatically deleted after a few hours, so there is no need to call DeleteOperation.
Sample code:
try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
String instanceId = "test_instance";
Instance.Tier tier = Instance.Tier.BASIC;
int memorySizeGb = 1;
Instance instance = Instance.newBuilder()
.setTier(tier)
.setMemorySizeGb(memorySizeGb)
.build();
Instance response = cloudRedisClient.createInstanceAsync(parent.toString(), instanceId, instance).get();
}
parent
- Required. The resource name of the instance location using the form:
`projects/{project_id}/locations/{location_id}` where `location_id` refers to a GCP region.instanceId
- Required. The logical name of the Redis instance in the customer project with
the following restrictions:
* Must contain only lowercase letters, numbers, and hyphens. * Must start with a letter. * Must be between 1-40 characters. * Must end with a number or a letter. * Must be unique within the customer project / location
instance
- Required. A Redis [Instance] resourcecom.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi(value="The surface for long-running operations is not stable yet and may change in the future.") public final com.google.api.gax.longrunning.OperationFuture<Instance,OperationMetadata> createInstanceAsync(CreateInstanceRequest request)
By default, the instance is accessible from the project's [default network](/compute/docs/networks-and-firewalls#networks).
The creation is executed asynchronously and callers may check the returned operation to track its progress. Once the operation is completed the Redis instance will be fully functional. Completed longrunning.Operation will contain the new instance object in the response field.
The returned operation is automatically deleted after a few hours, so there is no need to call DeleteOperation.
Sample code:
try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
String instanceId = "test_instance";
Instance.Tier tier = Instance.Tier.BASIC;
int memorySizeGb = 1;
Instance instance = Instance.newBuilder()
.setTier(tier)
.setMemorySizeGb(memorySizeGb)
.build();
CreateInstanceRequest request = CreateInstanceRequest.newBuilder()
.setParent(parent.toString())
.setInstanceId(instanceId)
.setInstance(instance)
.build();
Instance response = cloudRedisClient.createInstanceAsync(request).get();
}
request
- The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi(value="The surface for use by generated code is not stable yet and may change in the future.") public final com.google.api.gax.rpc.OperationCallable<CreateInstanceRequest,Instance,OperationMetadata> createInstanceOperationCallable()
By default, the instance is accessible from the project's [default network](/compute/docs/networks-and-firewalls#networks).
The creation is executed asynchronously and callers may check the returned operation to track its progress. Once the operation is completed the Redis instance will be fully functional. Completed longrunning.Operation will contain the new instance object in the response field.
The returned operation is automatically deleted after a few hours, so there is no need to call DeleteOperation.
Sample code:
try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
String instanceId = "test_instance";
Instance.Tier tier = Instance.Tier.BASIC;
int memorySizeGb = 1;
Instance instance = Instance.newBuilder()
.setTier(tier)
.setMemorySizeGb(memorySizeGb)
.build();
CreateInstanceRequest request = CreateInstanceRequest.newBuilder()
.setParent(parent.toString())
.setInstanceId(instanceId)
.setInstance(instance)
.build();
OperationFuture<Instance, OperationMetadata> future = cloudRedisClient.createInstanceOperationCallable().futureCall(request);
// Do something
Instance response = future.get();
}
public final com.google.api.gax.rpc.UnaryCallable<CreateInstanceRequest,com.google.longrunning.Operation> createInstanceCallable()
By default, the instance is accessible from the project's [default network](/compute/docs/networks-and-firewalls#networks).
The creation is executed asynchronously and callers may check the returned operation to track its progress. Once the operation is completed the Redis instance will be fully functional. Completed longrunning.Operation will contain the new instance object in the response field.
The returned operation is automatically deleted after a few hours, so there is no need to call DeleteOperation.
Sample code:
try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
String instanceId = "test_instance";
Instance.Tier tier = Instance.Tier.BASIC;
int memorySizeGb = 1;
Instance instance = Instance.newBuilder()
.setTier(tier)
.setMemorySizeGb(memorySizeGb)
.build();
CreateInstanceRequest request = CreateInstanceRequest.newBuilder()
.setParent(parent.toString())
.setInstanceId(instanceId)
.setInstance(instance)
.build();
ApiFuture<Operation> future = cloudRedisClient.createInstanceCallable().futureCall(request);
// Do something
Operation response = future.get();
}
@BetaApi(value="The surface for long-running operations is not stable yet and may change in the future.") public final com.google.api.gax.longrunning.OperationFuture<Instance,OperationMetadata> updateInstanceAsync(FieldMask updateMask, Instance instance)
Completed longrunning.Operation will contain the new instance object in the response field. The returned operation is automatically deleted after a few hours, so there is no need to call DeleteOperation.
Sample code:
try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
String pathsElement = "display_name";
String pathsElement2 = "memory_size_gb";
List<String> paths = Arrays.asList(pathsElement, pathsElement2);
FieldMask updateMask = FieldMask.newBuilder()
.addAllPaths(paths)
.build();
String displayName = " instance.memory_size_gb=4";
Instance instance = Instance.newBuilder()
.setDisplayName(displayName)
.build();
Instance response = cloudRedisClient.updateInstanceAsync(updateMask, instance).get();
}
updateMask
- Required. Mask of fields to update. At least one path must be supplied in
this field. The elements of the repeated paths field may only include these fields from
[Instance][CloudRedis.Instance]:
* `displayName` * `labels` * `memorySizeGb` * `redisConfig`
instance
- Required. Update description. Only fields specified in update_mask are updated.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi(value="The surface for long-running operations is not stable yet and may change in the future.") public final com.google.api.gax.longrunning.OperationFuture<Instance,OperationMetadata> updateInstanceAsync(UpdateInstanceRequest request)
Completed longrunning.Operation will contain the new instance object in the response field. The returned operation is automatically deleted after a few hours, so there is no need to call DeleteOperation.
Sample code:
try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
String pathsElement = "display_name";
String pathsElement2 = "memory_size_gb";
List<String> paths = Arrays.asList(pathsElement, pathsElement2);
FieldMask updateMask = FieldMask.newBuilder()
.addAllPaths(paths)
.build();
String displayName = " instance.memory_size_gb=4";
Instance instance = Instance.newBuilder()
.setDisplayName(displayName)
.build();
UpdateInstanceRequest request = UpdateInstanceRequest.newBuilder()
.setUpdateMask(updateMask)
.setInstance(instance)
.build();
Instance response = cloudRedisClient.updateInstanceAsync(request).get();
}
request
- The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi(value="The surface for use by generated code is not stable yet and may change in the future.") public final com.google.api.gax.rpc.OperationCallable<UpdateInstanceRequest,Instance,OperationMetadata> updateInstanceOperationCallable()
Completed longrunning.Operation will contain the new instance object in the response field. The returned operation is automatically deleted after a few hours, so there is no need to call DeleteOperation.
Sample code:
try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
String pathsElement = "display_name";
String pathsElement2 = "memory_size_gb";
List<String> paths = Arrays.asList(pathsElement, pathsElement2);
FieldMask updateMask = FieldMask.newBuilder()
.addAllPaths(paths)
.build();
String displayName = " instance.memory_size_gb=4";
Instance instance = Instance.newBuilder()
.setDisplayName(displayName)
.build();
UpdateInstanceRequest request = UpdateInstanceRequest.newBuilder()
.setUpdateMask(updateMask)
.setInstance(instance)
.build();
OperationFuture<Instance, OperationMetadata> future = cloudRedisClient.updateInstanceOperationCallable().futureCall(request);
// Do something
Instance response = future.get();
}
public final com.google.api.gax.rpc.UnaryCallable<UpdateInstanceRequest,com.google.longrunning.Operation> updateInstanceCallable()
Completed longrunning.Operation will contain the new instance object in the response field. The returned operation is automatically deleted after a few hours, so there is no need to call DeleteOperation.
Sample code:
try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
String pathsElement = "display_name";
String pathsElement2 = "memory_size_gb";
List<String> paths = Arrays.asList(pathsElement, pathsElement2);
FieldMask updateMask = FieldMask.newBuilder()
.addAllPaths(paths)
.build();
String displayName = " instance.memory_size_gb=4";
Instance instance = Instance.newBuilder()
.setDisplayName(displayName)
.build();
UpdateInstanceRequest request = UpdateInstanceRequest.newBuilder()
.setUpdateMask(updateMask)
.setInstance(instance)
.build();
ApiFuture<Operation> future = cloudRedisClient.updateInstanceCallable().futureCall(request);
// Do something
Operation response = future.get();
}
@BetaApi(value="The surface for long-running operations is not stable yet and may change in the future.") public final com.google.api.gax.longrunning.OperationFuture<Instance,OperationMetadata> importInstanceAsync(String name, InputConfig inputConfig)
Redis may stop serving during this operation. Instance state will be IMPORTING for entire operation. When complete, the instance will contain only data from the imported file.
The returned operation is automatically deleted after a few hours, so there is no need to call DeleteOperation.
Sample code:
try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
String name = "";
InputConfig inputConfig = InputConfig.newBuilder().build();
Instance response = cloudRedisClient.importInstanceAsync(name, inputConfig).get();
}
name
- Required. Redis instance resource name using the form:
`projects/{project_id}/locations/{location_id}/instances/{instance_id}` where `location_id`
refers to a GCP region.inputConfig
- Required. Specify data to be imported.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi(value="The surface for long-running operations is not stable yet and may change in the future.") public final com.google.api.gax.longrunning.OperationFuture<Instance,OperationMetadata> importInstanceAsync(ImportInstanceRequest request)
Redis may stop serving during this operation. Instance state will be IMPORTING for entire operation. When complete, the instance will contain only data from the imported file.
The returned operation is automatically deleted after a few hours, so there is no need to call DeleteOperation.
Sample code:
try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
String name = "";
InputConfig inputConfig = InputConfig.newBuilder().build();
ImportInstanceRequest request = ImportInstanceRequest.newBuilder()
.setName(name)
.setInputConfig(inputConfig)
.build();
Instance response = cloudRedisClient.importInstanceAsync(request).get();
}
request
- The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi(value="The surface for use by generated code is not stable yet and may change in the future.") public final com.google.api.gax.rpc.OperationCallable<ImportInstanceRequest,Instance,OperationMetadata> importInstanceOperationCallable()
Redis may stop serving during this operation. Instance state will be IMPORTING for entire operation. When complete, the instance will contain only data from the imported file.
The returned operation is automatically deleted after a few hours, so there is no need to call DeleteOperation.
Sample code:
try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
String name = "";
InputConfig inputConfig = InputConfig.newBuilder().build();
ImportInstanceRequest request = ImportInstanceRequest.newBuilder()
.setName(name)
.setInputConfig(inputConfig)
.build();
OperationFuture<Instance, OperationMetadata> future = cloudRedisClient.importInstanceOperationCallable().futureCall(request);
// Do something
Instance response = future.get();
}
public final com.google.api.gax.rpc.UnaryCallable<ImportInstanceRequest,com.google.longrunning.Operation> importInstanceCallable()
Redis may stop serving during this operation. Instance state will be IMPORTING for entire operation. When complete, the instance will contain only data from the imported file.
The returned operation is automatically deleted after a few hours, so there is no need to call DeleteOperation.
Sample code:
try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
String name = "";
InputConfig inputConfig = InputConfig.newBuilder().build();
ImportInstanceRequest request = ImportInstanceRequest.newBuilder()
.setName(name)
.setInputConfig(inputConfig)
.build();
ApiFuture<Operation> future = cloudRedisClient.importInstanceCallable().futureCall(request);
// Do something
Operation response = future.get();
}
@BetaApi(value="The surface for long-running operations is not stable yet and may change in the future.") public final com.google.api.gax.longrunning.OperationFuture<Instance,OperationMetadata> exportInstanceAsync(String name, OutputConfig outputConfig)
Redis will continue serving during this operation.
The returned operation is automatically deleted after a few hours, so there is no need to call DeleteOperation.
Sample code:
try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
String name = "";
OutputConfig outputConfig = OutputConfig.newBuilder().build();
Instance response = cloudRedisClient.exportInstanceAsync(name, outputConfig).get();
}
name
- Required. Redis instance resource name using the form:
`projects/{project_id}/locations/{location_id}/instances/{instance_id}` where `location_id`
refers to a GCP region.outputConfig
- Required. Specify data to be exported.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi(value="The surface for long-running operations is not stable yet and may change in the future.") public final com.google.api.gax.longrunning.OperationFuture<Instance,OperationMetadata> exportInstanceAsync(ExportInstanceRequest request)
Redis will continue serving during this operation.
The returned operation is automatically deleted after a few hours, so there is no need to call DeleteOperation.
Sample code:
try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
String name = "";
OutputConfig outputConfig = OutputConfig.newBuilder().build();
ExportInstanceRequest request = ExportInstanceRequest.newBuilder()
.setName(name)
.setOutputConfig(outputConfig)
.build();
Instance response = cloudRedisClient.exportInstanceAsync(request).get();
}
request
- The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi(value="The surface for use by generated code is not stable yet and may change in the future.") public final com.google.api.gax.rpc.OperationCallable<ExportInstanceRequest,Instance,OperationMetadata> exportInstanceOperationCallable()
Redis will continue serving during this operation.
The returned operation is automatically deleted after a few hours, so there is no need to call DeleteOperation.
Sample code:
try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
String name = "";
OutputConfig outputConfig = OutputConfig.newBuilder().build();
ExportInstanceRequest request = ExportInstanceRequest.newBuilder()
.setName(name)
.setOutputConfig(outputConfig)
.build();
OperationFuture<Instance, OperationMetadata> future = cloudRedisClient.exportInstanceOperationCallable().futureCall(request);
// Do something
Instance response = future.get();
}
public final com.google.api.gax.rpc.UnaryCallable<ExportInstanceRequest,com.google.longrunning.Operation> exportInstanceCallable()
Redis will continue serving during this operation.
The returned operation is automatically deleted after a few hours, so there is no need to call DeleteOperation.
Sample code:
try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
String name = "";
OutputConfig outputConfig = OutputConfig.newBuilder().build();
ExportInstanceRequest request = ExportInstanceRequest.newBuilder()
.setName(name)
.setOutputConfig(outputConfig)
.build();
ApiFuture<Operation> future = cloudRedisClient.exportInstanceCallable().futureCall(request);
// Do something
Operation response = future.get();
}
@BetaApi(value="The surface for long-running operations is not stable yet and may change in the future.") public final com.google.api.gax.longrunning.OperationFuture<Instance,OperationMetadata> failoverInstanceAsync(InstanceName name, FailoverInstanceRequest.DataProtectionMode dataProtectionMode)
Sample code:
try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
InstanceName name = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]");
FailoverInstanceRequest.DataProtectionMode dataProtectionMode = FailoverInstanceRequest.DataProtectionMode.DATA_PROTECTION_MODE_UNSPECIFIED;
Instance response = cloudRedisClient.failoverInstanceAsync(name, dataProtectionMode).get();
}
name
- Required. Redis instance resource name using the form:
`projects/{project_id}/locations/{location_id}/instances/{instance_id}` where `location_id`
refers to a GCP region.dataProtectionMode
- Optional. Available data protection modes that the user can choose.
If it's unspecified, data protection mode will be LIMITED_DATA_LOSS by default.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi(value="The surface for long-running operations is not stable yet and may change in the future.") public final com.google.api.gax.longrunning.OperationFuture<Instance,OperationMetadata> failoverInstanceAsync(String name, FailoverInstanceRequest.DataProtectionMode dataProtectionMode)
Sample code:
try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
InstanceName name = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]");
FailoverInstanceRequest.DataProtectionMode dataProtectionMode = FailoverInstanceRequest.DataProtectionMode.DATA_PROTECTION_MODE_UNSPECIFIED;
Instance response = cloudRedisClient.failoverInstanceAsync(name.toString(), dataProtectionMode).get();
}
name
- Required. Redis instance resource name using the form:
`projects/{project_id}/locations/{location_id}/instances/{instance_id}` where `location_id`
refers to a GCP region.dataProtectionMode
- Optional. Available data protection modes that the user can choose.
If it's unspecified, data protection mode will be LIMITED_DATA_LOSS by default.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi(value="The surface for long-running operations is not stable yet and may change in the future.") public final com.google.api.gax.longrunning.OperationFuture<Instance,OperationMetadata> failoverInstanceAsync(FailoverInstanceRequest request)
Sample code:
try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
InstanceName name = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]");
FailoverInstanceRequest request = FailoverInstanceRequest.newBuilder()
.setName(name.toString())
.build();
Instance response = cloudRedisClient.failoverInstanceAsync(request).get();
}
request
- The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi(value="The surface for use by generated code is not stable yet and may change in the future.") public final com.google.api.gax.rpc.OperationCallable<FailoverInstanceRequest,Instance,OperationMetadata> failoverInstanceOperationCallable()
Sample code:
try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
InstanceName name = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]");
FailoverInstanceRequest request = FailoverInstanceRequest.newBuilder()
.setName(name.toString())
.build();
OperationFuture<Instance, OperationMetadata> future = cloudRedisClient.failoverInstanceOperationCallable().futureCall(request);
// Do something
Instance response = future.get();
}
public final com.google.api.gax.rpc.UnaryCallable<FailoverInstanceRequest,com.google.longrunning.Operation> failoverInstanceCallable()
Sample code:
try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
InstanceName name = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]");
FailoverInstanceRequest request = FailoverInstanceRequest.newBuilder()
.setName(name.toString())
.build();
ApiFuture<Operation> future = cloudRedisClient.failoverInstanceCallable().futureCall(request);
// Do something
Operation response = future.get();
}
@BetaApi(value="The surface for long-running operations is not stable yet and may change in the future.") public final com.google.api.gax.longrunning.OperationFuture<Empty,OperationMetadata> deleteInstanceAsync(InstanceName name)
Sample code:
try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
InstanceName name = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]");
cloudRedisClient.deleteInstanceAsync(name).get();
}
name
- Required. Redis instance resource name using the form:
`projects/{project_id}/locations/{location_id}/instances/{instance_id}` where `location_id`
refers to a GCP region.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi(value="The surface for long-running operations is not stable yet and may change in the future.") public final com.google.api.gax.longrunning.OperationFuture<Empty,OperationMetadata> deleteInstanceAsync(String name)
Sample code:
try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
InstanceName name = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]");
cloudRedisClient.deleteInstanceAsync(name.toString()).get();
}
name
- Required. Redis instance resource name using the form:
`projects/{project_id}/locations/{location_id}/instances/{instance_id}` where `location_id`
refers to a GCP region.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi(value="The surface for long-running operations is not stable yet and may change in the future.") public final com.google.api.gax.longrunning.OperationFuture<Empty,OperationMetadata> deleteInstanceAsync(DeleteInstanceRequest request)
Sample code:
try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
InstanceName name = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]");
DeleteInstanceRequest request = DeleteInstanceRequest.newBuilder()
.setName(name.toString())
.build();
cloudRedisClient.deleteInstanceAsync(request).get();
}
request
- The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi(value="The surface for use by generated code is not stable yet and may change in the future.") public final com.google.api.gax.rpc.OperationCallable<DeleteInstanceRequest,Empty,OperationMetadata> deleteInstanceOperationCallable()
Sample code:
try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
InstanceName name = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]");
DeleteInstanceRequest request = DeleteInstanceRequest.newBuilder()
.setName(name.toString())
.build();
OperationFuture<Empty, OperationMetadata> future = cloudRedisClient.deleteInstanceOperationCallable().futureCall(request);
// Do something
future.get();
}
public final com.google.api.gax.rpc.UnaryCallable<DeleteInstanceRequest,com.google.longrunning.Operation> deleteInstanceCallable()
Sample code:
try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
InstanceName name = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]");
DeleteInstanceRequest request = DeleteInstanceRequest.newBuilder()
.setName(name.toString())
.build();
ApiFuture<Operation> future = cloudRedisClient.deleteInstanceCallable().futureCall(request);
// Do something
future.get();
}
public final void close()
close
in interface AutoCloseable
public void shutdown()
shutdown
in interface com.google.api.gax.core.BackgroundResource
public boolean isShutdown()
isShutdown
in interface com.google.api.gax.core.BackgroundResource
public boolean isTerminated()
isTerminated
in interface com.google.api.gax.core.BackgroundResource
public void shutdownNow()
shutdownNow
in interface com.google.api.gax.core.BackgroundResource
public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException
awaitTermination
in interface com.google.api.gax.core.BackgroundResource
InterruptedException
Copyright © 2019 Google LLC. All rights reserved.