Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 1.2k
Modified methods in ChangeRequest.#849
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
52567fd3becc748ad3e890f3dc9a74a4cf6File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -148,10 +148,42 @@ public Dns dns() { | ||
| } | ||
| /** | ||
| * Applies this change request to the associated zone. | ||
| * Applies this change request to the zone identified by {@code zoneName}. | ||
| * | ||
| * @throws DnsException upon failure or if zone is not found | ||
| */ | ||
| public ChangeRequest applyTo(Dns.ChangeRequestOption... options) { | ||
| return dns.applyChangeRequest(zone, this, options); | ||
| public ChangeRequest applyTo(String zoneName, Dns.ChangeRequestOption... options) { | ||
This comment was marked as spam.Sorry, something went wrong. Uh oh!There was an error while loading. Please reload this page.
This comment was marked as spam.Sorry, something went wrong. Uh oh!There was an error while loading. Please reload this page. | ||
| return dns.applyChangeRequest(zoneName, this, options); | ||
| } | ||
| /** | ||
| * Retrieves the up-to-date information about the change request from Google Cloud DNS. Parameter | ||
This comment was marked as spam.Sorry, something went wrong. Uh oh!There was an error while loading. Please reload this page.
This comment was marked as spam.Sorry, something went wrong. Uh oh!There was an error while loading. Please reload this page. | ||
| * {@code options} can be used to restrict the fields to be included in the updated object the | ||
| * same way as in {@link Dns#getChangeRequest(String, String, Dns.ChangeRequestOption...)}. If | ||
| * {@code options} are provided, any field other than generatedId which is not included in the | ||
| * {@code options} will be {@code null} regardless of whether they are initialized or not in | ||
| * {@code this} instance. | ||
| * | ||
| * @return an object with the updated information or {@code null} if it does not exist | ||
| * @throws DnsException upon failure of the API call or if the associated zone was not found | ||
| */ | ||
| public ChangeRequest reload(Dns.ChangeRequestOption... options) { | ||
| return dns.getChangeRequest(zone, generatedId(), options); | ||
| } | ||
| /** | ||
| * Returns {@code true} if the change request has been completed. If the status is not {@link | ||
| * Status#DONE} already, the method makes an API call to Google Cloud DNS to update the change | ||
| * request first. | ||
| * | ||
| * @throws DnsException upon failure of the API call or if the associated zone was not found | ||
| */ | ||
| public boolean isDone() { | ||
| if (status() == Status.DONE) { | ||
| return true; | ||
| } | ||
| ChangeRequest updated = reload(Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.STATUS)); | ||
| return updated == null || updated.status() == Status.DONE; | ||
This comment was marked as spam.Sorry, something went wrong. Uh oh!There was an error while loading. Please reload this page.
This comment was marked as spam.Sorry, something went wrong. Uh oh!There was an error while loading. Please reload this page. | ||
| } | ||
| @Override | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -147,12 +147,13 @@ private static void assertEqChangesIgnoreStatus(ChangeRequest expected, ChangeRe | ||
| } | ||
| private static void waitForChangeToComplete(String zoneName, String changeId) { | ||
| while (true) { | ||
| ChangeRequest changeRequest = DNS.getChangeRequest(zoneName, changeId, | ||
| Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.STATUS)); | ||
| if (ChangeRequest.Status.DONE.equals(changeRequest.status())) { | ||
| return; | ||
| } | ||
| ChangeRequest changeRequest = DNS.getChangeRequest(zoneName, changeId, | ||
This comment was marked as spam.Sorry, something went wrong. Uh oh!There was an error while loading. Please reload this page.
This comment was marked as spam.Sorry, something went wrong. Uh oh!There was an error while loading. Please reload this page. | ||
| Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.STATUS)); | ||
| waitForChangeToComplete(changeRequest); | ||
| } | ||
| private static void waitForChangeToComplete(ChangeRequest changeRequest) { | ||
| while (!changeRequest.isDone()) { | ||
| try { | ||
| Thread.sleep(500); | ||
| } catch (InterruptedException e) { | ||
| @@ -529,9 +530,9 @@ public void testCreateChange() { | ||
| assertTrue(ImmutableList.of(ChangeRequest.Status.PENDING, ChangeRequest.Status.DONE) | ||
| .contains(created.status())); | ||
| assertEqChangesIgnoreStatus(created, DNS.getChangeRequest(ZONE1.name(), "1")); | ||
| waitForChangeToComplete(ZONE1.name(), "1"); | ||
| DNS.applyChangeRequest(ZONE1.name(), CHANGE_DELETE_ZONE1); | ||
| waitForChangeToComplete(ZONE1.name(), "2"); | ||
| waitForChangeToComplete(created); | ||
| created = DNS.applyChangeRequest(ZONE1.name(), CHANGE_DELETE_ZONE1); | ||
| waitForChangeToComplete(created); | ||
| // with options | ||
| created = DNS.applyChangeRequest(ZONE1.name(), CHANGE_ADD_ZONE1, | ||
| Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.ID)); | ||
| @@ -540,29 +541,29 @@ public void testCreateChange() { | ||
| assertTrue(created.deletions().isEmpty()); | ||
| assertEquals("3", created.generatedId()); | ||
| assertNull(created.status()); | ||
| waitForChangeToComplete(ZONE1.name(), "3"); | ||
| DNS.applyChangeRequest(ZONE1.name(), CHANGE_DELETE_ZONE1); | ||
| waitForChangeToComplete(ZONE1.name(), "4"); | ||
| waitForChangeToComplete(created); | ||
| created = DNS.applyChangeRequest(ZONE1.name(), CHANGE_DELETE_ZONE1); | ||
| waitForChangeToComplete(created); | ||
| created = DNS.applyChangeRequest(ZONE1.name(), CHANGE_ADD_ZONE1, | ||
| Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.STATUS)); | ||
| assertTrue(created.additions().isEmpty()); | ||
| assertNull(created.startTimeMillis()); | ||
| assertTrue(created.deletions().isEmpty()); | ||
| assertEquals("5", created.generatedId()); | ||
| assertNotNull(created.status()); | ||
| waitForChangeToComplete(ZONE1.name(), "5"); | ||
| DNS.applyChangeRequest(ZONE1.name(), CHANGE_DELETE_ZONE1); | ||
| waitForChangeToComplete(ZONE1.name(), "6"); | ||
| waitForChangeToComplete(created); | ||
| created = DNS.applyChangeRequest(ZONE1.name(), CHANGE_DELETE_ZONE1); | ||
| waitForChangeToComplete(created); | ||
| created = DNS.applyChangeRequest(ZONE1.name(), CHANGE_ADD_ZONE1, | ||
| Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.START_TIME)); | ||
| assertTrue(created.additions().isEmpty()); | ||
| assertNotNull(created.startTimeMillis()); | ||
| assertTrue(created.deletions().isEmpty()); | ||
| assertEquals("7", created.generatedId()); | ||
| assertNull(created.status()); | ||
| waitForChangeToComplete(ZONE1.name(), "7"); | ||
| DNS.applyChangeRequest(ZONE1.name(), CHANGE_DELETE_ZONE1); | ||
| waitForChangeToComplete(ZONE1.name(), "8"); | ||
| waitForChangeToComplete(created); | ||
| created = DNS.applyChangeRequest(ZONE1.name(), CHANGE_DELETE_ZONE1); | ||
| waitForChangeToComplete(created); | ||
| created = DNS.applyChangeRequest(ZONE1.name(), CHANGE_ADD_ZONE1, | ||
| Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.ADDITIONS)); | ||
| assertEquals(CHANGE_ADD_ZONE1.additions(), created.additions()); | ||
| @@ -571,16 +572,16 @@ public void testCreateChange() { | ||
| assertEquals("9", created.generatedId()); | ||
| assertNull(created.status()); | ||
| // finishes with delete otherwise we cannot delete the zone | ||
| waitForChangeToComplete(ZONE1.name(), "9"); | ||
| waitForChangeToComplete(created); | ||
| created = DNS.applyChangeRequest(ZONE1.name(), CHANGE_DELETE_ZONE1, | ||
| Dns.ChangeRequestOption.fields(Dns.ChangeRequestField.DELETIONS)); | ||
| waitForChangeToComplete(ZONE1.name(), "10"); | ||
| waitForChangeToComplete(created); | ||
| assertEquals(CHANGE_DELETE_ZONE1.deletions(), created.deletions()); | ||
| assertNull(created.startTimeMillis()); | ||
| assertTrue(created.additions().isEmpty()); | ||
| assertEquals("10", created.generatedId()); | ||
| assertNull(created.status()); | ||
| waitForChangeToComplete(ZONE1.name(), "10"); | ||
| waitForChangeToComplete(created); | ||
| } finally { | ||
| clear(); | ||
| } | ||
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.