Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regenerate Redis client #4738

Merged
merged 3 commits into from
Mar 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -984,9 +984,44 @@ public final UnaryCallable<DeleteInstanceRequest, Operation> deleteInstanceCalla
*
* <pre><code>
* try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
* String formattedName = InstanceName.format("[PROJECT]", "[LOCATION]", "[INSTANCE]");
* InstanceName name = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]");
* FailoverInstanceRequest.DataProtectionMode dataProtectionMode = FailoverInstanceRequest.DataProtectionMode.DATA_PROTECTION_MODE_UNSPECIFIED;
* Instance response = cloudRedisClient.failoverInstanceAsync(formattedName, dataProtectionMode).get();
* Instance response = cloudRedisClient.failoverInstanceAsync(name, dataProtectionMode).get();
* }
* </code></pre>
*
* @param 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
* @param 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.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
@BetaApi(
"The surface for long-running operations is not stable yet and may change in the future.")
public final OperationFuture<Instance, OperationMetadata> failoverInstanceAsync(
InstanceName name, FailoverInstanceRequest.DataProtectionMode dataProtectionMode) {

FailoverInstanceRequest request =
FailoverInstanceRequest.newBuilder()
.setName(name == null ? null : name.toString())
.setDataProtectionMode(dataProtectionMode)
.build();
return failoverInstanceAsync(request);
}

// AUTO-GENERATED DOCUMENTATION AND METHOD
/**
* Failover the master role to current replica node against a specific STANDARD tier redis
* instance.
*
* <p>Sample code:
*
* <pre><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();
* }
* </code></pre>
*
Expand Down Expand Up @@ -1019,10 +1054,10 @@ public final OperationFuture<Instance, OperationMetadata> failoverInstanceAsync(
*
* <pre><code>
* try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
* String formattedName = InstanceName.format("[PROJECT]", "[LOCATION]", "[INSTANCE]");
* InstanceName name = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]");
* FailoverInstanceRequest.DataProtectionMode dataProtectionMode = FailoverInstanceRequest.DataProtectionMode.DATA_PROTECTION_MODE_UNSPECIFIED;
* FailoverInstanceRequest request = FailoverInstanceRequest.newBuilder()
* .setName(formattedName)
* .setName(name.toString())
* .setDataProtectionMode(dataProtectionMode)
* .build();
* Instance response = cloudRedisClient.failoverInstanceAsync(request).get();
Expand All @@ -1048,10 +1083,10 @@ public final OperationFuture<Instance, OperationMetadata> failoverInstanceAsync(
*
* <pre><code>
* try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
* String formattedName = InstanceName.format("[PROJECT]", "[LOCATION]", "[INSTANCE]");
* InstanceName name = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]");
* FailoverInstanceRequest.DataProtectionMode dataProtectionMode = FailoverInstanceRequest.DataProtectionMode.DATA_PROTECTION_MODE_UNSPECIFIED;
* FailoverInstanceRequest request = FailoverInstanceRequest.newBuilder()
* .setName(formattedName)
* .setName(name.toString())
* .setDataProtectionMode(dataProtectionMode)
* .build();
* OperationFuture&lt;Instance, OperationMetadata&gt; future = cloudRedisClient.failoverInstanceOperationCallable().futureCall(request);
Expand All @@ -1075,10 +1110,10 @@ public final OperationFuture<Instance, OperationMetadata> failoverInstanceAsync(
*
* <pre><code>
* try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
* String formattedName = InstanceName.format("[PROJECT]", "[LOCATION]", "[INSTANCE]");
* InstanceName name = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]");
* FailoverInstanceRequest.DataProtectionMode dataProtectionMode = FailoverInstanceRequest.DataProtectionMode.DATA_PROTECTION_MODE_UNSPECIFIED;
* FailoverInstanceRequest request = FailoverInstanceRequest.newBuilder()
* .setName(formattedName)
* .setName(name.toString())
* .setDataProtectionMode(dataProtectionMode)
* .build();
* ApiFuture&lt;Operation&gt; future = cloudRedisClient.failoverInstanceCallable().futureCall(request);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -446,18 +446,18 @@ public void failoverInstanceTest() throws Exception {
.build();
mockCloudRedis.addResponse(resultOperation);

String formattedName = InstanceName.format("[PROJECT]", "[LOCATION]", "[INSTANCE]");
InstanceName name = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]");
FailoverInstanceRequest.DataProtectionMode dataProtectionMode =
FailoverInstanceRequest.DataProtectionMode.DATA_PROTECTION_MODE_UNSPECIFIED;

Instance actualResponse = client.failoverInstanceAsync(formattedName, dataProtectionMode).get();
Instance actualResponse = client.failoverInstanceAsync(name, dataProtectionMode).get();
Assert.assertEquals(expectedResponse, actualResponse);

List<GeneratedMessageV3> actualRequests = mockCloudRedis.getRequests();
Assert.assertEquals(1, actualRequests.size());
FailoverInstanceRequest actualRequest = (FailoverInstanceRequest) actualRequests.get(0);

Assert.assertEquals(formattedName, actualRequest.getName());
Assert.assertEquals(name, InstanceName.parse(actualRequest.getName()));
Assert.assertEquals(dataProtectionMode, actualRequest.getDataProtectionMode());
Assert.assertTrue(
channelProvider.isHeaderSent(
Expand All @@ -472,11 +472,11 @@ public void failoverInstanceExceptionTest() throws Exception {
mockCloudRedis.addException(exception);

try {
String formattedName = InstanceName.format("[PROJECT]", "[LOCATION]", "[INSTANCE]");
InstanceName name = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]");
FailoverInstanceRequest.DataProtectionMode dataProtectionMode =
FailoverInstanceRequest.DataProtectionMode.DATA_PROTECTION_MODE_UNSPECIFIED;

client.failoverInstanceAsync(formattedName, dataProtectionMode).get();
client.failoverInstanceAsync(name, dataProtectionMode).get();
Assert.fail("No exception raised");
} catch (ExecutionException e) {
Assert.assertEquals(InvalidArgumentException.class, e.getCause().getClass());
Expand Down