3737import compute .deleteprotection .SetDeleteProtection ;
3838import compute .disks .DeleteDisk ;
3939import compute .disks .DeleteSnapshot ;
40- import compute .disks .RegionalDelete ;
4140import compute .reservation .DeleteReservation ;
4241import java .io .IOException ;
4342import java .nio .charset .StandardCharsets ;
@@ -58,7 +57,7 @@ public abstract class Util {
5857 // resources
5958 // and delete the listed resources based on the timestamp.
6059
61- private static final int DELETION_THRESHOLD_TIME_HOURS = 24 ;
60+ private static final int DELETION_THRESHOLD_TIME_MINUTES = 30 ;
6261 // comma separate list of zone names
6362 private static final String TEST_ZONES_NAME = "JAVA_DOCS_COMPUTE_TEST_ZONES" ;
6463 private static final String DEFAULT_ZONES = "us-central1-a,us-west1-a,asia-south1-a" ;
@@ -127,7 +126,7 @@ && isCreatedBeforeThresholdTime(instance.getCreationTimestamp())) {
127126
128127 public static boolean isCreatedBeforeThresholdTime (String timestamp ) {
129128 return OffsetDateTime .parse (timestamp ).toInstant ()
130- .isBefore (Instant .now ().minus (DELETION_THRESHOLD_TIME_HOURS , ChronoUnit .HOURS ));
129+ .isBefore (Instant .now ().minus (DELETION_THRESHOLD_TIME_MINUTES , ChronoUnit .MINUTES ));
131130 }
132131
133132 public static String getBase64EncodedKey () {
@@ -218,22 +217,6 @@ && isCreatedBeforeThresholdTime(disk.getCreationTimestamp())) {
218217 }
219218 }
220219
221- // Delete disks which starts with the given prefixToDelete and
222- // has creation timestamp >24 hours.
223- public static void cleanUpExistingRegionalDisks (
224- String prefixToDelete , String projectId , String region )
225- throws IOException , ExecutionException , InterruptedException , TimeoutException {
226- try (RegionDisksClient disksClient = RegionDisksClient .create ()) {
227- for (Disk disk : disksClient .list (projectId , region ).iterateAll ()) {
228- if (disk .getName ().contains (prefixToDelete )
229- && disk .getRegion ().equals (region )
230- && isCreatedBeforeThresholdTime (disk .getCreationTimestamp ())) {
231- RegionalDelete .deleteRegionalDisk (projectId , region , disk .getName ());
232- }
233- }
234- }
235- }
236-
237220 // Delete snapshots which starts with the given prefixToDelete and
238221 // has creation timestamp >24 hours.
239222 public static void cleanUpExistingSnapshots (String prefixToDelete , String projectId )
0 commit comments