Example usage for com.amazonaws.services.route53.model ListHostedZonesRequest ListHostedZonesRequest

List of usage examples for com.amazonaws.services.route53.model ListHostedZonesRequest ListHostedZonesRequest

Introduction

In this page you can find the example usage for com.amazonaws.services.route53.model ListHostedZonesRequest ListHostedZonesRequest.

Prototype

ListHostedZonesRequest

Source Link

Usage

From source file:com.github.blacklocus.rdsecho.utl.Route53Find.java

License:Open Source License

public Iterable<HostedZone> hostedZones(final Predicate<HostedZone> predicate) {
    return new PagingIterable<HostedZone>(new Supplier<Iterable<HostedZone>>() {

        String nextMarker = null;
        boolean isTruncated = true;

        @Override/*w w w.  j a v  a 2 s  .  c  om*/
        public Iterable<HostedZone> get() {
            if (isTruncated) {
                ListHostedZonesRequest request = new ListHostedZonesRequest().withMarker(nextMarker);
                ListHostedZonesResult result = route53.listHostedZones();
                nextMarker = result.getNextMarker();
                isTruncated = result.isTruncated();
                return Iterables.filter(result.getHostedZones(), predicate);

            } else {
                return Collections.emptyList();
            }
        }
    });
}

From source file:com.msi.dns53.client.DNS53MetadataUtil.java

License:Apache License

public void populateServiceMetadata(final ServletConfig config, String serviceName) {
    logger.debug("init(): TXT record will be created for this service regarding its port and context path.");
    String contextPath = config.getServletContext().getContextPath();
    String port = Appctx.getBean("TOMCAT_PORT");
    String master_passwd = Appctx.getBean("DB_PASSWORD");

    final String fqdn = (String) ConfigurationUtil.getConfiguration(Arrays.asList(new String[] { "FQDN" }));
    final String domain = (String) ConfigurationUtil
            .getConfiguration(Arrays.asList(new String[] { "FQDN_DOMAIN" }));
    String txtRecordValue = ":" + port + contextPath;
    String baseDNSServerURL = "http://localhost:" + port + "/DNS53Server/2012-02-29/";

    logger.debug("Tomcat port = " + port + "; FQDN = " + fqdn + "; domain = " + domain + "; TXT Record Value = "
            + txtRecordValue + "; BaseDNSServerUrl = " + baseDNSServerURL);

    DNS53Client client = new DNS53Client(baseDNSServerURL + "hostedzone", baseDNSServerURL + "change", "admin",
            master_passwd);/*from   w  ww  . j av a 2 s  .  c o m*/

    logger.debug("Service name = " + serviceName);
    String recordName = serviceName + "-" + fqdn;
    logger.debug("TXT Record Name: " + recordName);

    logger.debug("init(): Calling ListHostedZones to find the target zone!");
    ListHostedZonesRequest lhzReq = new ListHostedZonesRequest();
    lhzReq.setMaxItems("1");

    ListHostedZonesResult lhzResult = client.listHostedZones(lhzReq);

    HostedZone zone = null;
    List<HostedZone> zones = lhzResult.getHostedZones();
    if (zones != null && zones.size() > 0) {
        for (HostedZone hz : zones) {
            if (hz.getName().equals(domain + ".") || hz.getName().equals(domain)) {
                zone = hz;
            }
        }
    } else {
        logger.error(
                "BaseAsyncServlet encountered an error while it was trying to find the target hosted zone.");
        throw ErrorResponse.InternalFailure();
    }

    if (zone == null) {
        logger.error("BaseAsyncServlet could not find any zone for this TopStackWeb instance.");
        throw ErrorResponse.InternalFailure();
    }

    // TODO (optional) check for the CNAME record for this service before proceeding

    logger.debug("init(): Creating a new TXT record for " + recordName + " with \"" + txtRecordValue
            + "\" as its value!");
    String zoneId = zone.getId();
    ChangeResourceRecordSetsRequest crrsReq = new ChangeResourceRecordSetsRequest();
    crrsReq.setHostedZoneId(zoneId);
    ChangeBatch cb = new ChangeBatch();
    cb.setComment(
            "BaseAsyncServlet => init(): Registering " + serviceName + " service for Transcend TopStack.");
    Collection<Change> changes = new LinkedList<Change>();
    Change change = new Change();
    change.setAction(ChangeAction.CREATE);
    ResourceRecordSet rrSet = new ResourceRecordSet();
    rrSet.setName(recordName);
    rrSet.setTTL(900L);
    rrSet.setType(RRType.TXT);
    Collection<ResourceRecord> rr = new LinkedList<ResourceRecord>();
    ResourceRecord record = new ResourceRecord();
    record.setValue(txtRecordValue);
    rr.add(record);
    rrSet.setResourceRecords(rr);
    change.setResourceRecordSet(rrSet);
    changes.add(change);
    cb.setChanges(changes);
    crrsReq.setChangeBatch(cb);
    ChangeResourceRecordSetsResult result = client.changeResourceRecordSets(crrsReq);
    logger.debug("Result for the last ChangeResourceRecordSets request: " + result.toString());
}

From source file:com.msi.dns53.server.query.ListHostedZones.java

License:Apache License

public ListHostedZonesRequest unmarshall(HttpServletRequest req) {
    logger.debug("Unmarshalling the ListHostedZones request.");
    ListHostedZonesRequest request = new ListHostedZonesRequest();
    Map<String, String[]> map = req.getParameterMap();
    String marker = QueryUtil.getString(map, "marker");
    String maxItems = QueryUtil.getString(map, "maxitems");
    request.setMarker(marker);//from   ww w .  ja  va  2  s .  c om
    request.setMaxItems(maxItems);
    return request;
}

From source file:com.netflix.edda.EddaRoute53Client.java

License:Apache License

public ListHostedZonesResult listHostedZones() {
    return listHostedZones(new ListHostedZonesRequest());
}

From source file:org.lendingclub.mercator.aws.Route53Scanner.java

License:Apache License

@Override
protected void doScan() {

    ListHostedZonesRequest request = new ListHostedZonesRequest();
    ListHostedZonesResult result = new ListHostedZonesResult();

    do {//from ww  w . j a v  a2s.c  om
        result = getClient().listHostedZones(request);
        for (HostedZone zone : result.getHostedZones()) {
            scanHostedZoneById(zone.getId());
        }
        request.setMarker(result.getMarker());
    } while (result.isTruncated());

}