mirror of https://github.com/apache/jclouds.git
Merge pull request #1423 from jclouds/route53-list-name
add support for list recordsets by name in route53
This commit is contained in:
commit
2e1cc3c281
|
@ -37,7 +37,8 @@ public class BindNextRecord implements Binder {
|
||||||
NextRecord from = NextRecord.class.cast(payload);
|
NextRecord from = NextRecord.class.cast(payload);
|
||||||
Builder<?> builder = request.toBuilder();
|
Builder<?> builder = request.toBuilder();
|
||||||
builder.addQueryParam("name", from.getName());
|
builder.addQueryParam("name", from.getName());
|
||||||
builder.addQueryParam("type", from.getType().toString());
|
if (from.getType().isPresent())
|
||||||
|
builder.addQueryParam("type", from.getType().get());
|
||||||
if (from.getIdentifier().isPresent())
|
if (from.getIdentifier().isPresent())
|
||||||
builder.addQueryParam("identifier", from.getIdentifier().get());
|
builder.addQueryParam("identifier", from.getIdentifier().get());
|
||||||
return (R) builder.build();
|
return (R) builder.build();
|
||||||
|
|
|
@ -88,6 +88,10 @@ public class ResourceRecordSetIterable extends IterableWithMarker<ResourceRecord
|
||||||
* If the results were truncated, this holds the position of the next item.
|
* If the results were truncated, this holds the position of the next item.
|
||||||
*/
|
*/
|
||||||
public static class NextRecord {
|
public static class NextRecord {
|
||||||
|
public static NextRecord name(String name) {
|
||||||
|
return new NextRecord(name, null, null);
|
||||||
|
}
|
||||||
|
|
||||||
public static NextRecord nameAndType(String name, String type) {
|
public static NextRecord nameAndType(String name, String type) {
|
||||||
return new NextRecord(name, type, null);
|
return new NextRecord(name, type, null);
|
||||||
}
|
}
|
||||||
|
@ -97,12 +101,12 @@ public class ResourceRecordSetIterable extends IterableWithMarker<ResourceRecord
|
||||||
}
|
}
|
||||||
|
|
||||||
private final String name;
|
private final String name;
|
||||||
private final String type;
|
private final Optional<String> type;
|
||||||
private final Optional<String> identifier;
|
private final Optional<String> identifier;
|
||||||
|
|
||||||
private NextRecord(String name, String type, String identifier) {
|
private NextRecord(String name, String type, String identifier) {
|
||||||
this.name = checkNotNull(name, "name");
|
this.name = checkNotNull(name, "name");
|
||||||
this.type = checkNotNull(type, "type for %s", name);
|
this.type = Optional.fromNullable(type);
|
||||||
this.identifier = Optional.fromNullable(identifier);
|
this.identifier = Optional.fromNullable(identifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,7 +120,7 @@ public class ResourceRecordSetIterable extends IterableWithMarker<ResourceRecord
|
||||||
/**
|
/**
|
||||||
* the type of the next record in the list.
|
* the type of the next record in the list.
|
||||||
*/
|
*/
|
||||||
public String getType() {
|
public Optional<String> getType() {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,13 +143,12 @@ public class ResourceRecordSetIterable extends IterableWithMarker<ResourceRecord
|
||||||
if (obj == null || getClass() != obj.getClass())
|
if (obj == null || getClass() != obj.getClass())
|
||||||
return false;
|
return false;
|
||||||
NextRecord that = NextRecord.class.cast(obj);
|
NextRecord that = NextRecord.class.cast(obj);
|
||||||
return equal(this.name, that.name) && equal(this.type, that.type)
|
return equal(this.name, that.name) && equal(this.type, that.type) && equal(this.identifier, that.identifier);
|
||||||
&& equal(this.identifier, that.identifier);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return toStringHelper("").omitNullValues().add("name", name).add("type", type)
|
return toStringHelper("").omitNullValues().add("name", name).add("type", type.orNull())
|
||||||
.add("identifier", identifier.orNull()).toString();
|
.add("identifier", identifier.orNull()).toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -110,13 +110,26 @@ public class ResourceRecordSetApiExpectTest extends BaseRoute53ApiExpectTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
HttpRequest listAt = HttpRequest.builder().method("GET")
|
HttpRequest listAt = HttpRequest.builder().method("GET")
|
||||||
.endpoint("https://route53.amazonaws.com/2012-02-29/hostedzone/Z1PA6795UKMFR9/rrset?name=testdoc2.example.com&type=NS")
|
.endpoint("https://route53.amazonaws.com/2012-02-29/hostedzone/Z1PA6795UKMFR9/rrset?name=testdoc2.example.com")
|
||||||
.addHeader("Host", "route53.amazonaws.com")
|
.addHeader("Host", "route53.amazonaws.com")
|
||||||
.addHeader("Date", "Mon, 21 Jan 02013 19:29:03 -0800")
|
.addHeader("Date", "Mon, 21 Jan 02013 19:29:03 -0800")
|
||||||
.addHeader("X-Amzn-Authorization", authForDate).build();
|
.addHeader("X-Amzn-Authorization", authForDate).build();
|
||||||
|
|
||||||
public void testListAtWhenResponseIs2xx() {
|
public void testListAtWhenResponseIs2xx() {
|
||||||
Route53Api apiWhenAtExist = requestSendsResponse(listAt, listResponse);
|
Route53Api apiWhenAtExist = requestSendsResponse(listAt, listResponse);
|
||||||
|
NextRecord next = NextRecord.name("testdoc2.example.com");
|
||||||
|
assertEquals(apiWhenAtExist.getResourceRecordSetApiForHostedZone("Z1PA6795UKMFR9").listAt(next).toString(),
|
||||||
|
new ListResourceRecordSetsResponseTest().expected().toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
HttpRequest listAtNameAndType = HttpRequest.builder().method("GET")
|
||||||
|
.endpoint("https://route53.amazonaws.com/2012-02-29/hostedzone/Z1PA6795UKMFR9/rrset?name=testdoc2.example.com&type=NS")
|
||||||
|
.addHeader("Host", "route53.amazonaws.com")
|
||||||
|
.addHeader("Date", "Mon, 21 Jan 02013 19:29:03 -0800")
|
||||||
|
.addHeader("X-Amzn-Authorization", authForDate).build();
|
||||||
|
|
||||||
|
public void testListAtNameAndTypeWhenResponseIs2xx() {
|
||||||
|
Route53Api apiWhenAtExist = requestSendsResponse(listAtNameAndType, listResponse);
|
||||||
NextRecord next = NextRecord.nameAndType("testdoc2.example.com", "NS");
|
NextRecord next = NextRecord.nameAndType("testdoc2.example.com", "NS");
|
||||||
assertEquals(apiWhenAtExist.getResourceRecordSetApiForHostedZone("Z1PA6795UKMFR9").listAt(next).toString(),
|
assertEquals(apiWhenAtExist.getResourceRecordSetApiForHostedZone("Z1PA6795UKMFR9").listAt(next).toString(),
|
||||||
new ListResourceRecordSetsResponseTest().expected().toString());
|
new ListResourceRecordSetsResponseTest().expected().toString());
|
||||||
|
@ -126,7 +139,7 @@ public class ResourceRecordSetApiExpectTest extends BaseRoute53ApiExpectTest {
|
||||||
HttpResponse noMore = HttpResponse.builder().statusCode(200)
|
HttpResponse noMore = HttpResponse.builder().statusCode(200)
|
||||||
.payload(payloadFromStringWithContentType("<ListResourceRecordSetsResponse />", "text/xml")).build();
|
.payload(payloadFromStringWithContentType("<ListResourceRecordSetsResponse />", "text/xml")).build();
|
||||||
|
|
||||||
Route53Api success = requestsSendResponses(list, listResponse, listAt, noMore);
|
Route53Api success = requestsSendResponses(list, listResponse, listAtNameAndType, noMore);
|
||||||
assertEquals(success.getResourceRecordSetApiForHostedZone("Z1PA6795UKMFR9").list().concat().toSet(), new ListResourceRecordSetsResponseTest().expected()
|
assertEquals(success.getResourceRecordSetApiForHostedZone("Z1PA6795UKMFR9").list().concat().toSet(), new ListResourceRecordSetsResponseTest().expected()
|
||||||
.toSet());
|
.toSet());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue