Skip to content

Commit c90d835

Browse files
Fixed code as requested in the comments
1 parent bc8e69f commit c90d835

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

compute/cloud-client/src/main/java/compute/disks/CreateDiskWithSnapshotSchedule.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,13 @@ public static void main(String[] args)
4747
public static Status createDiskWithSnapshotSchedule(
4848
String projectId, String zone, String diskName, String snapshotScheduleName)
4949
throws IOException, ExecutionException, InterruptedException, TimeoutException {
50+
// Initialize client that will be used to send requests. This client only needs to be created
51+
// once, and can be reused for multiple requests.
5052
try (DisksClient disksClient = DisksClient.create()) {
51-
53+
String region = zone.substring(0, zone.lastIndexOf('-'));
5254
// Get the resource policy to link to the disk
5355
String resourcePolicyLink = String.format("projects/%s/regions/%s/resourcePolicies/%s",
54-
projectId, zone.substring(0, zone.lastIndexOf('-')), snapshotScheduleName);
56+
projectId, region, snapshotScheduleName);
5557

5658
Disk disk = Disk.newBuilder()
5759
.setName(diskName)

compute/cloud-client/src/test/java/compute/disks/DisksIT.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -345,10 +345,9 @@ public void testCreateDiskSecondaryRegional()
345345
@Test
346346
void testCreateDiskWithSnapshotSchedule()
347347
throws IOException, ExecutionException, InterruptedException, TimeoutException {
348-
Status status = CreateDiskWithSnapshotSchedule.createDiskWithSnapshotSchedule(
348+
CreateDiskWithSnapshotSchedule.createDiskWithSnapshotSchedule(
349349
PROJECT_ID, ZONE, DISK_WITH_SNAPSHOT_SCHEDULE, SNAPSHOT_SCHEDULE);
350350

351351
Assert.assertNotNull(Util.getDisk(PROJECT_ID, ZONE, DISK_WITH_SNAPSHOT_SCHEDULE));
352-
assertThat(status).isEqualTo(Status.DONE);
353352
}
354353
}

0 commit comments

Comments
 (0)