|
22 | 22 |
|
23 | 23 | package com.google.gcloud.examples.dns.snippets; |
24 | 24 |
|
| 25 | +import com.google.gcloud.dns.ChangeRequest; |
25 | 26 | import com.google.gcloud.dns.ChangeRequestInfo; |
26 | 27 | import com.google.gcloud.dns.Dns; |
27 | 28 | import com.google.gcloud.dns.DnsOptions; |
@@ -59,21 +60,17 @@ public static void main(String... args) { |
59 | 60 | // Build and apply the change request to our zone if it contains records to delete |
60 | 61 | ChangeRequestInfo changeRequest = changeBuilder.build(); |
61 | 62 | if (!changeRequest.deletions().isEmpty()) { |
62 | | - changeRequest = dns.applyChangeRequest(zoneName, changeRequest); |
| 63 | + ChangeRequest pendingRequest = dns.applyChangeRequest(zoneName, changeRequest); |
63 | 64 |
|
64 | | - // Wait for change to finish, but save data traffic by transferring only ID and status |
65 | | - Dns.ChangeRequestOption option = |
66 | | - Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.STATUS); |
67 | | - while (ChangeRequestInfo.Status.PENDING.equals(changeRequest.status())) { |
| 65 | + // Wait for the change request to complete |
| 66 | + while (!pendingRequest.isDone()) { |
68 | 67 | System.out.println("Waiting for change to complete. Going to sleep for 500ms..."); |
69 | 68 | try { |
70 | 69 | Thread.sleep(500); |
71 | 70 | } catch (InterruptedException e) { |
72 | 71 | System.err.println("The thread was interrupted while waiting for change request to be " |
73 | 72 | + "processed."); |
74 | 73 | } |
75 | | - // Update the change, but fetch only change ID and status |
76 | | - changeRequest = dns.getChangeRequest(zoneName, changeRequest.generatedId(), option); |
77 | 74 | } |
78 | 75 | } |
79 | 76 |
|
|
0 commit comments