Search in sources :

Example 6 with ListResourceRecordSetsRequest

use of software.amazon.awssdk.services.route53.model.ListResourceRecordSetsRequest in project aws-doc-sdk-examples by awsdocs.

the class ListResourceRecordSets method listResourceRecord.

// snippet-start:[route.java2.list_records.main]
public static void listResourceRecord(Route53Client route53Client, String hostedZoneId) {
    try {
        ListResourceRecordSetsRequest request = ListResourceRecordSetsRequest.builder().hostedZoneId(hostedZoneId).maxItems("12").build();
        ListResourceRecordSetsResponse listResourceRecordSets = route53Client.listResourceRecordSets(request);
        List<ResourceRecordSet> records = listResourceRecordSets.resourceRecordSets();
        for (ResourceRecordSet record : records) {
            System.out.println("The Record name is: " + record.name());
        }
    } catch (Route53Exception e) {
        System.err.println(e.getMessage());
        System.exit(1);
    }
}
Also used : ResourceRecordSet(software.amazon.awssdk.services.route53.model.ResourceRecordSet) Route53Exception(software.amazon.awssdk.services.route53.model.Route53Exception) ListResourceRecordSetsRequest(software.amazon.awssdk.services.route53.model.ListResourceRecordSetsRequest) ListResourceRecordSetsResponse(software.amazon.awssdk.services.route53.model.ListResourceRecordSetsResponse)

Example 7 with ListResourceRecordSetsRequest

use of software.amazon.awssdk.services.route53.model.ListResourceRecordSetsRequest 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)

Example 8 with ListResourceRecordSetsRequest

use of software.amazon.awssdk.services.route53.model.ListResourceRecordSetsRequest in project Synapse-Stack-Builder by Sage-Bionetworks.

the class Route53SetupTest method testGetResourceRecordSetForRecordNameNoneFound.

@Test
public void testGetResourceRecordSetForRecordNameNoneFound() {
    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.createListExpectedListResourceRecordSetsRequestNoneFound(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");
        assertTrue(rrs == null);
    }
}
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 9 with ListResourceRecordSetsRequest

use of software.amazon.awssdk.services.route53.model.ListResourceRecordSetsRequest in project Synapse-Stack-Builder by Sage-Bionetworks.

the class TestHelper method createListExpectedListResourceRecordSetsRequestNoneFound.

public static Map<ListResourceRecordSetsRequest, ListResourceRecordSetsResult> createListExpectedListResourceRecordSetsRequestNoneFound(String stack) {
    Map<ListResourceRecordSetsRequest, ListResourceRecordSetsResult> m = new HashMap<ListResourceRecordSetsRequest, ListResourceRecordSetsResult>();
    // For Auth and Portal, simulate 'not last' situation i.e. the next record is returned
    List<String> svcPrefixes = Arrays.asList(Constants.PREFIX_PORTAL);
    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") + "2.elasticbeanstalk.com");
        ListResourceRecordSetsResult res = new ListResourceRecordSetsResult().withResourceRecordSets(new ResourceRecordSet().withName(map.get(svcPrefix + ".service.environment.subdomain.cname") + "2").withTTL(300L).withType(RRType.CNAME).withResourceRecords(rr));
        m.put(req, res);
    }
    // For Repo and Workers, simulate 'last' situation i.e. no record is returned
    svcPrefixes = Arrays.asList(Constants.PREFIX_REPO, Constants.PREFIX_WORKERS);
    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 = null;
        ListResourceRecordSetsResult res = new ListResourceRecordSetsResult().withResourceRecordSets(new ArrayList<ResourceRecordSet>());
        m.put(req, res);
    }
    return m;
}
Also used : ResourceRecordSet(com.amazonaws.services.route53.model.ResourceRecordSet) ListResourceRecordSetsRequest(com.amazonaws.services.route53.model.ListResourceRecordSetsRequest) HashMap(java.util.HashMap) ResourceRecord(com.amazonaws.services.route53.model.ResourceRecord) ListResourceRecordSetsResult(com.amazonaws.services.route53.model.ListResourceRecordSetsResult)

Aggregations

ListResourceRecordSetsRequest (com.amazonaws.services.route53.model.ListResourceRecordSetsRequest)8 ListResourceRecordSetsResult (com.amazonaws.services.route53.model.ListResourceRecordSetsResult)8 ResourceRecordSet (com.amazonaws.services.route53.model.ResourceRecordSet)6 ListHostedZonesResult (com.amazonaws.services.route53.model.ListHostedZonesResult)4 Test (org.junit.Test)4 HostedZone (com.amazonaws.services.route53.model.HostedZone)3 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 ResourceRecord (com.amazonaws.services.route53.model.ResourceRecord)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