use of software.amazon.awssdk.services.route53.model.ListResourceRecordSetsRequest in project GNS by MobilityFirst.
the class Route53 method listRecordSetsForHostedZone.
// private void test() {
// route53.createHostedZone(new CreateHostedZoneRequest()
// .withName("myDomainName.com")
// .withCallerReference(CALLER_REFERENCE)
// .withHostedZoneConfig(new HostedZoneConfig()
// .withComment("my first Route 53 hosted zone!")));
// }
private static void listRecordSetsForHostedZone() {
ListResourceRecordSetsRequest request = new ListResourceRecordSetsRequest();
request.setHostedZoneId(HOSTED_ZONE_ID);
ListResourceRecordSetsResult result = route53.listResourceRecordSets(request);
List<ResourceRecordSet> recordSets = result.getResourceRecordSets();
for (ResourceRecordSet recordSet : recordSets) {
System.out.println(recordSet.toString());
}
}
use of software.amazon.awssdk.services.route53.model.ListResourceRecordSetsRequest in project Synapse-Stack-Builder by Sage-Bionetworks.
the class Route53Setup method getResourceRecordSetForRecordName.
// TODO: See if this could be done with a single call to listResourceRecordSets() to return all the CNAMEs,
// pass in a list of recordNames and getting back a list of ResourceRecordSets
ResourceRecordSet getResourceRecordSetForRecordName(String recordName) {
ListResourceRecordSetsRequest req = new ListResourceRecordSetsRequest();
req.setHostedZoneId(hostedZone.getId());
req.setStartRecordType(RRType.CNAME);
req.setStartRecordName(recordName);
req.setMaxItems("1");
ListResourceRecordSetsResult res = route53Client.listResourceRecordSets(req);
ResourceRecordSet rrs = null;
if ((res.getResourceRecordSets().size() > 0) && (recordName.equals(res.getResourceRecordSets().get(0).getName()))) {
rrs = res.getResourceRecordSets().get(0);
}
return rrs;
}
use of software.amazon.awssdk.services.route53.model.ListResourceRecordSetsRequest in project Synapse-Stack-Builder by Sage-Bionetworks.
the class Route53SetupTest method testGetResourceRecordSetForRecordNameAllFound.
@Test
public void testGetResourceRecordSetForRecordNameAllFound() {
String stack = "stack";
String hostedZoneDomainName = stack + ".sagebase.org.";
ListHostedZonesResult res = new ListHostedZonesResult();
List<HostedZone> expectedHostedZones = new ArrayList<HostedZone>();
HostedZone hz = new HostedZone().withName(hostedZoneDomainName);
expectedHostedZones.add(hz);
hz = new HostedZone().withName("anotherzone.sagebase.org");
expectedHostedZones.add(hz);
res.setHostedZones(expectedHostedZones);
Map<ListResourceRecordSetsRequest, ListResourceRecordSetsResult> expectedResourceRecordSetsResults = TestHelper.createListExpectedListResourceRecordSetsRequestAllFound(stack);
when(mockClient.listHostedZones()).thenReturn(res);
// Args for getResourceRecordSetForRecordName().listResourceRecordSets()
for (ListResourceRecordSetsRequest req : expectedResourceRecordSetsResults.keySet()) {
when(mockClient.listResourceRecordSets(req)).thenReturn(expectedResourceRecordSetsResults.get(req));
}
Route53Setup r53Setup = new Route53Setup(factory, config, resources);
for (String svcPrefix : Arrays.asList(Constants.PREFIX_PORTAL, Constants.PREFIX_REPO, Constants.PREFIX_WORKERS)) {
ResourceRecordSet rrs = r53Setup.getResourceRecordSetForRecordName(svcPrefix + ".stack.inst.r53.sagebase.org");
assertFalse(rrs == null);
assertEquals(rrs.getName(), svcPrefix + ".stack.inst.r53.sagebase.org");
assertEquals(rrs.getResourceRecords().get(0).getValue(), svcPrefix + "-stack-inst-sagebase-org.elasticbeanstalk.com");
}
}
use of software.amazon.awssdk.services.route53.model.ListResourceRecordSetsRequest in project Synapse-Stack-Builder by Sage-Bionetworks.
the class TestHelper method createListExpectedListResourceRecordSetsRequestAllFound.
public static Map<ListResourceRecordSetsRequest, ListResourceRecordSetsResult> createListExpectedListResourceRecordSetsRequestAllFound(String stack) {
Map<ListResourceRecordSetsRequest, ListResourceRecordSetsResult> m = new HashMap<ListResourceRecordSetsRequest, ListResourceRecordSetsResult>();
List<String> svcPrefixes = Arrays.asList(Constants.PREFIX_PORTAL, Constants.PREFIX_REPO, Constants.PREFIX_WORKERS);
Map<String, String> map = getSvcCNAMEsProps(stack, svcPrefixes);
for (String svcPrefix : svcPrefixes) {
ListResourceRecordSetsRequest req = new ListResourceRecordSetsRequest().withStartRecordType(RRType.CNAME).withStartRecordName(map.get(svcPrefix + ".service.environment.subdomain.cname")).withMaxItems("1");
ResourceRecord rr = new ResourceRecord().withValue(map.get(svcPrefix + ".service.environment.cname.prefix") + ".elasticbeanstalk.com");
ListResourceRecordSetsResult res = new ListResourceRecordSetsResult().withResourceRecordSets(new ResourceRecordSet().withName(map.get(svcPrefix + ".service.environment.subdomain.cname")).withTTL(300L).withType(RRType.CNAME).withResourceRecords(rr));
m.put(req, res);
}
return m;
}
use of software.amazon.awssdk.services.route53.model.ListResourceRecordSetsRequest in project iep by Netflix.
the class PaginationTest method route53ResourceRecordSets.
@Test
public void route53ResourceRecordSets() throws Exception {
SortedSet<String> pages = newPageSet(5);
final Iterator<String> reqIt = pages.iterator();
final Iterator<String> resIt = pages.iterator();
Function<ListResourceRecordSetsRequest, ListResourceRecordSetsResult> f = r -> {
if (r.getStartRecordName() != null) {
String expected = reqIt.next();
Assert.assertEquals(expected + "-id", r.getStartRecordIdentifier());
Assert.assertEquals(expected + "-name", r.getStartRecordName());
Assert.assertEquals(expected + "-type", r.getStartRecordType());
}
String next = resIt.hasNext() ? resIt.next() : null;
return new ListResourceRecordSetsResult().withNextRecordIdentifier((next != null) ? next + "-id" : null).withNextRecordName((next != null) ? next + "-name" : null).withNextRecordType((next != null) ? next + "-type" : null);
};
Publisher<ListResourceRecordSetsResult> publisher = Pagination.createPublisher(new ListResourceRecordSetsRequest(), f);
Iterable<String> iter = Flowable.fromPublisher(publisher).filter(r -> r.getNextRecordName() != null).map(ListResourceRecordSetsResult::getNextRecordName).blockingIterable();
SortedSet<String> results = new TreeSet<>();
for (String s : iter) {
results.add(s.substring(0, 5));
}
Assert.assertEquals(pages, results);
Assert.assertFalse(reqIt.hasNext());
}
Aggregations