mirror of https://github.com/apache/jclouds.git
Merge pull request #1421 from jclouds/dynect-list-name
add support for list records by name in dynect
This commit is contained in:
commit
9dc73a98e4
|
@ -53,6 +53,14 @@ public interface RecordApi {
|
|||
*/
|
||||
FluentIterable<RecordId> list() throws JobStillRunningException;
|
||||
|
||||
/**
|
||||
* Retrieves a list of resource record ids for all records of the fqdn in the given zone
|
||||
*
|
||||
* @throws JobStillRunningException
|
||||
* if a different job in the session is still running
|
||||
*/
|
||||
FluentIterable<RecordId> listByFQDN(String fqdn) throws JobStillRunningException;
|
||||
|
||||
/**
|
||||
* Retrieves a list of resource record ids for all records of the fqdn and type in the given zone
|
||||
*
|
||||
|
|
|
@ -90,6 +90,17 @@ public interface RecordAsyncApi {
|
|||
@ResponseParser(ToRecordIds.class)
|
||||
ListenableFuture<FluentIterable<RecordId>> list() throws JobStillRunningException;
|
||||
|
||||
/**
|
||||
* @see RecordApi#listByFQDN
|
||||
*/
|
||||
@Named("GetRecord")
|
||||
@GET
|
||||
@Path("/AllRecord/{zone}/{fqdn}")
|
||||
@ResponseParser(ToRecordIds.class)
|
||||
@Fallback(EmptyFluentIterableOnNotFoundOr404.class)
|
||||
ListenableFuture<FluentIterable<RecordId>> listByFQDN(@PathParam("fqdn") String fqdn)
|
||||
throws JobStillRunningException;
|
||||
|
||||
/**
|
||||
* @see RecordApi#listByFQDNAndType
|
||||
*/
|
||||
|
|
|
@ -352,6 +352,23 @@ public class RecordApiExpectTest extends BaseDynECTApiExpectTest {
|
|||
new ListRecordsResponseTest().expected().toString());
|
||||
}
|
||||
|
||||
HttpRequest listByFQDN = HttpRequest.builder().method("GET")
|
||||
.endpoint("https://api2.dynect.net/REST/AllRecord/jclouds.org/www.foo.com")
|
||||
.addHeader("API-Version", "3.3.8")
|
||||
.addHeader(CONTENT_TYPE, APPLICATION_JSON)
|
||||
.addHeader("Auth-Token", authToken).build();
|
||||
|
||||
public void testListByFQDNWhenResponseIs2xx() {
|
||||
DynECTApi success = requestsSendResponses(createSession, createSessionResponse, listByFQDN, listResponse);
|
||||
assertEquals(success.getRecordApiForZone("jclouds.org").listByFQDN("www.foo.com").toString(),
|
||||
new ListRecordsResponseTest().expected().toString());
|
||||
}
|
||||
|
||||
public void testListByFQDNWhenResponseIs404() {
|
||||
DynECTApi fail = requestsSendResponses(createSession, createSessionResponse, listByFQDN, notFound);
|
||||
assertTrue(fail.getRecordApiForZone("jclouds.org").listByFQDN("www.foo.com").isEmpty());
|
||||
}
|
||||
|
||||
HttpRequest listByFQDNAndType = HttpRequest.builder().method("GET")
|
||||
.endpoint("https://api2.dynect.net/REST/ARecord/jclouds.org/www.foo.com")
|
||||
.addHeader("API-Version", "3.3.8")
|
||||
|
|
|
@ -247,7 +247,19 @@ public class RecordApiLiveTest extends BaseDynECTApiLiveTest {
|
|||
checkRecord(newRecord);
|
||||
}
|
||||
|
||||
@Test(dependsOnMethods = "testListByFQDNAndType")
|
||||
@Test(dependsOnMethods = "testCreateRecord")
|
||||
public void testListByFQDN() {
|
||||
id = api(zoneFQDN).listByFQDN(record.getFQDN()).toList().get(0);
|
||||
getAnonymousLogger().info(id.toString());
|
||||
Record<? extends Map<String, Object>> newRecord = api(zoneFQDN).get(id);
|
||||
assertEquals(newRecord.getFQDN(), record.getFQDN());
|
||||
assertEquals(newRecord.getType(), record.getType());
|
||||
assertEquals(newRecord.getTTL(), record.getTTL());
|
||||
assertEquals(newRecord.getRData(), record.getRData());
|
||||
checkRecord(newRecord);
|
||||
}
|
||||
|
||||
@Test(dependsOnMethods = { "testListByFQDNAndType", "testListByFQDN" })
|
||||
public void testDeleteRecord() {
|
||||
Job job = api(zoneFQDN).scheduleDelete(id);
|
||||
checkNotNull(job, "unable to delete record %s", id);
|
||||
|
|
Loading…
Reference in New Issue