Search in sources :

Example 1 with ListHostedZonesResult

use of com.amazonaws.services.route53.model.ListHostedZonesResult in project Synapse-Stack-Builder by Sage-Bionetworks.

the class Route53Setup method getHostedZone.

public HostedZone getHostedZone(String hostedZoneDomainName) {
    HostedZone zone = null;
    if (!hostedZoneDomainName.endsWith(".")) {
        hostedZoneDomainName = hostedZoneDomainName + ".";
    }
    ListHostedZonesResult res = route53Client.listHostedZones();
    List<HostedZone> l = res.getHostedZones();
    // Should only be one hz in our case, no need to handle getIstruncated() etc.
    for (HostedZone hz : l) {
        if (hz.getName().equals(hostedZoneDomainName)) {
            zone = hz;
            break;
        }
    }
    if (zone == null) {
        throw new IllegalArgumentException("Hosted zone for domain " + hostedZoneDomainName + " could not be found.");
    }
    return zone;
}
Also used : HostedZone(com.amazonaws.services.route53.model.HostedZone) ListHostedZonesResult(com.amazonaws.services.route53.model.ListHostedZonesResult)

Example 2 with ListHostedZonesResult

use of com.amazonaws.services.route53.model.ListHostedZonesResult 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");
    }
}
Also used : HostedZone(com.amazonaws.services.route53.model.HostedZone) ResourceRecordSet(com.amazonaws.services.route53.model.ResourceRecordSet) ListResourceRecordSetsRequest(com.amazonaws.services.route53.model.ListResourceRecordSetsRequest) ArrayList(java.util.ArrayList) ListHostedZonesResult(com.amazonaws.services.route53.model.ListHostedZonesResult) ListResourceRecordSetsResult(com.amazonaws.services.route53.model.ListResourceRecordSetsResult) Test(org.junit.Test)

Example 3 with ListHostedZonesResult

use of com.amazonaws.services.route53.model.ListHostedZonesResult in project Synapse-Stack-Builder by Sage-Bionetworks.

the class Route53SetupTest method testGetHostedZoneExistentZone.

// @After
// public void tearDown() {
// }
// 
@Test
public void testGetHostedZoneExistentZone() {
    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);
    when(mockClient.listHostedZones()).thenReturn(res);
    Route53Setup r53Setup = new Route53Setup(factory, config, resources);
    HostedZone z = r53Setup.getHostedZone(stack + ".sagebase.org");
    assertEquals(hostedZoneDomainName, z.getName());
}
Also used : HostedZone(com.amazonaws.services.route53.model.HostedZone) ArrayList(java.util.ArrayList) ListHostedZonesResult(com.amazonaws.services.route53.model.ListHostedZonesResult) Test(org.junit.Test)

Example 4 with ListHostedZonesResult

use of com.amazonaws.services.route53.model.ListHostedZonesResult in project iep by Netflix.

the class PaginationTest method route53HostedZones.

@Test
public void route53HostedZones() throws Exception {
    SortedSet<String> pages = newPageSet(5);
    final Iterator<String> reqIt = pages.iterator();
    final Iterator<String> resIt = pages.iterator();
    Function<ListHostedZonesRequest, ListHostedZonesResult> f = r -> {
        if (r.getMarker() != null) {
            Assert.assertEquals(reqIt.next(), r.getMarker());
        }
        return new ListHostedZonesResult().withNextMarker(resIt.hasNext() ? resIt.next() : null);
    };
    Publisher<ListHostedZonesResult> publisher = Pagination.createPublisher(new ListHostedZonesRequest(), f);
    Iterable<String> iter = Flowable.fromPublisher(publisher).filter(r -> r.getNextMarker() != null).map(ListHostedZonesResult::getNextMarker).blockingIterable();
    SortedSet<String> results = new TreeSet<>();
    for (String s : iter) {
        results.add(s);
    }
    Assert.assertEquals(pages, results);
    Assert.assertFalse(reqIt.hasNext());
}
Also used : ListHostedZonesResult(com.amazonaws.services.route53.model.ListHostedZonesResult) ListMetricsRequest(com.amazonaws.services.cloudwatch.model.ListMetricsRequest) SortedSet(java.util.SortedSet) ScanResult(com.amazonaws.services.dynamodbv2.model.ScanResult) RunWith(org.junit.runner.RunWith) HashMap(java.util.HashMap) ListMetricsResult(com.amazonaws.services.cloudwatch.model.ListMetricsResult) DescribeLoadBalancersRequest(com.amazonaws.services.elasticloadbalancing.model.DescribeLoadBalancersRequest) Function(java.util.function.Function) TreeSet(java.util.TreeSet) PutMetricDataRequest(com.amazonaws.services.cloudwatch.model.PutMetricDataRequest) DescribeTargetGroupsRequest(com.amazonaws.services.elasticloadbalancingv2.model.DescribeTargetGroupsRequest) Flowable(io.reactivex.Flowable) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) AttributeValue(com.amazonaws.services.dynamodbv2.model.AttributeValue) DescribeInstancesRequest(com.amazonaws.services.ec2.model.DescribeInstancesRequest) Map(java.util.Map) DescribeAutoScalingGroupsResult(com.amazonaws.services.autoscaling.model.DescribeAutoScalingGroupsResult) ListClustersResult(com.amazonaws.services.elasticmapreduce.model.ListClustersResult) DescribeTargetGroupsResult(com.amazonaws.services.elasticloadbalancingv2.model.DescribeTargetGroupsResult) Iterator(java.util.Iterator) ScanRequest(com.amazonaws.services.dynamodbv2.model.ScanRequest) Publisher(org.reactivestreams.Publisher) DescribeInstancesResult(com.amazonaws.services.ec2.model.DescribeInstancesResult) Test(org.junit.Test) JUnit4(org.junit.runners.JUnit4) DescribeAutoScalingGroupsRequest(com.amazonaws.services.autoscaling.model.DescribeAutoScalingGroupsRequest) ListResourceRecordSetsResult(com.amazonaws.services.route53.model.ListResourceRecordSetsResult) ListHostedZonesRequest(com.amazonaws.services.route53.model.ListHostedZonesRequest) ListClustersRequest(com.amazonaws.services.elasticmapreduce.model.ListClustersRequest) DescribeLoadBalancersResult(com.amazonaws.services.elasticloadbalancing.model.DescribeLoadBalancersResult) PutMetricDataResult(com.amazonaws.services.cloudwatch.model.PutMetricDataResult) Assert(org.junit.Assert) ListResourceRecordSetsRequest(com.amazonaws.services.route53.model.ListResourceRecordSetsRequest) TreeSet(java.util.TreeSet) ListHostedZonesResult(com.amazonaws.services.route53.model.ListHostedZonesResult) ListHostedZonesRequest(com.amazonaws.services.route53.model.ListHostedZonesRequest) Test(org.junit.Test)

Example 5 with ListHostedZonesResult

use of com.amazonaws.services.route53.model.ListHostedZonesResult in project Synapse-Stack-Builder by Sage-Bionetworks.

the class Route53SetupTest method testSetupResourcesAllFound.

@Ignore
@Test
public void testSetupResourcesAllFound() throws Exception {
    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));
    }
    ChangeInfo expectedChangeInfo = new ChangeInfo().withId("changeInfoId").withStatus(ChangeStatus.INSYNC);
    ChangeResourceRecordSetsResult expectedChangeResourceRecordSetsResult = new ChangeResourceRecordSetsResult().withChangeInfo(expectedChangeInfo);
    when(mockClient.changeResourceRecordSets(any(ChangeResourceRecordSetsRequest.class))).thenReturn(expectedChangeResourceRecordSetsResult);
    Route53Setup r53Setup = new Route53Setup(factory, config, resources);
}
Also used : HostedZone(com.amazonaws.services.route53.model.HostedZone) ListResourceRecordSetsRequest(com.amazonaws.services.route53.model.ListResourceRecordSetsRequest) ChangeInfo(com.amazonaws.services.route53.model.ChangeInfo) ArrayList(java.util.ArrayList) ListHostedZonesResult(com.amazonaws.services.route53.model.ListHostedZonesResult) ChangeResourceRecordSetsResult(com.amazonaws.services.route53.model.ChangeResourceRecordSetsResult) ChangeResourceRecordSetsRequest(com.amazonaws.services.route53.model.ChangeResourceRecordSetsRequest) ListResourceRecordSetsResult(com.amazonaws.services.route53.model.ListResourceRecordSetsResult) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

ListHostedZonesResult (com.amazonaws.services.route53.model.ListHostedZonesResult)7 HostedZone (com.amazonaws.services.route53.model.HostedZone)6 Test (org.junit.Test)6 ArrayList (java.util.ArrayList)5 ListResourceRecordSetsRequest (com.amazonaws.services.route53.model.ListResourceRecordSetsRequest)4 ListResourceRecordSetsResult (com.amazonaws.services.route53.model.ListResourceRecordSetsResult)4 ResourceRecordSet (com.amazonaws.services.route53.model.ResourceRecordSet)2 DescribeAutoScalingGroupsRequest (com.amazonaws.services.autoscaling.model.DescribeAutoScalingGroupsRequest)1 DescribeAutoScalingGroupsResult (com.amazonaws.services.autoscaling.model.DescribeAutoScalingGroupsResult)1 ListMetricsRequest (com.amazonaws.services.cloudwatch.model.ListMetricsRequest)1 ListMetricsResult (com.amazonaws.services.cloudwatch.model.ListMetricsResult)1 PutMetricDataRequest (com.amazonaws.services.cloudwatch.model.PutMetricDataRequest)1 PutMetricDataResult (com.amazonaws.services.cloudwatch.model.PutMetricDataResult)1 AttributeValue (com.amazonaws.services.dynamodbv2.model.AttributeValue)1 ScanRequest (com.amazonaws.services.dynamodbv2.model.ScanRequest)1 ScanResult (com.amazonaws.services.dynamodbv2.model.ScanResult)1 DescribeInstancesRequest (com.amazonaws.services.ec2.model.DescribeInstancesRequest)1 DescribeInstancesResult (com.amazonaws.services.ec2.model.DescribeInstancesResult)1 DescribeLoadBalancersRequest (com.amazonaws.services.elasticloadbalancing.model.DescribeLoadBalancersRequest)1 DescribeLoadBalancersResult (com.amazonaws.services.elasticloadbalancing.model.DescribeLoadBalancersResult)1