Example usage for com.amazonaws.services.route53.model GetHostedZoneResult getHostedZone

List of usage examples for com.amazonaws.services.route53.model GetHostedZoneResult getHostedZone

Introduction

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

Prototype


public HostedZone getHostedZone() 

Source Link

Document

A complex type that contains general information about the specified hosted zone.

Usage

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

License:Apache License

@Override
public String marshall(MarshallStruct<GetHostedZoneResult> input, HttpServletResponse resp) throws Exception {
    GetHostedZoneResult result = input.getMainObject();
    XMLNode response = new XMLNode(DNS53Constants.GETHOSTEDZONERESPONSE);
    response.addAttr(DNS53Constants.XMLNS, DNS53Constants.XMLNS_VALUE);

    DNS53QueryUtil.marshallHostedZone(result.getHostedZone(), response);
    DNS53QueryUtil.marshallDelegationSet(result.getDelegationSet(), response);

    return response.toString();
}

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

License:Apache License

ObjectNode toJson(GetHostedZoneResult hzResult) {
    HostedZone hz = hzResult.getHostedZone();

    ObjectNode n = mapper.createObjectNode();
    n.put("aws_account", getAccountId());
    n.put("aws_id", hz.getId());
    n.put("aws_name", hz.getName());
    n.put("aws_callerReference", hz.getCallerReference());
    n.put("aws_resourceRecordSetCount", hz.getResourceRecordSetCount());
    n.put("aws_comment", hz.getConfig().getComment());
    n.put("aws_privateZone", hz.getConfig().getPrivateZone());
    n.put("aws_arn", "arn:aws:route53:::hostedzone/" + hz.getId());

    ArrayNode an = mapper.createArrayNode();
    if (hzResult.getDelegationSet() != null) {
        hzResult.getDelegationSet().getNameServers().forEach(ns -> {
            an.add(ns);//  w ww  . j a va 2  s .  co  m
        });
    }
    n.set("aws_nameServers", an);
    return n;

}

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

License:Apache License

protected void projectHostedZoneResult(GetHostedZoneResult hostedZoneResult) {

    HostedZone hz = hostedZoneResult.getHostedZone();
    ObjectNode n = toJson(hostedZoneResult);

    getNeoRxClient().execCypher(//from www  .ja va  2 s .co  m
            "merge (a:AwsRoute53HostedZone {aws_id:{aws_id}}) set a+={props}, a.updateTs=timestamp() return a",
            "aws_id", n.get("aws_id").asText(), "props", n);

    ListResourceRecordSetsRequest request = new ListResourceRecordSetsRequest();
    request.setHostedZoneId(hz.getId());
    ListResourceRecordSetsResult result;

    int i = 0;
    long timestamp = System.currentTimeMillis();

    do {
        result = getClient().listResourceRecordSets(request);
        request.setStartRecordName(result.getNextRecordName());

        for (ResourceRecordSet rs : result.getResourceRecordSets()) {

            projectResourceRecordSet(hz.getId(), rs, timestamp);

        }

    } while (result.isTruncated());

    getNeoRxClient().execCypher(
            "match (z:AwsRoute53HostedZone {aws_id:{aws_id}})--(r:AwsRoute53RecordSet) where r.updateTs<{ts} detach delete r",
            "ts", timestamp, "aws_id", hz.getId());
    getNeoRxClient().execCypher(
            "match (a:AwsRoute53RecordSet) where not (a)-[:CONTAINS]-(:AwsRoute53HostedZone) detach delete a");
}

From source file:org.ofbiz.tenant.amazonaws.AwsServices.java

License:Apache License

/**
 * get Amazon Rout53 hosted zone/* w w w .  ja va 2  s.  c  o m*/
 * @param ctx
 * @param context
 * @return
 */
public static Map<String, Object> getAmazonRoute53HostedZone(DispatchContext ctx, Map<String, Object> context) {
    String hostedZoneId = (String) context.get("hostedZoneId");

    AmazonRoute53 route53 = AwsFactory.getAmazonRoute53();
    GetHostedZoneRequest request = new GetHostedZoneRequest(hostedZoneId);
    GetHostedZoneResult hostedZoneResult = route53.getHostedZone(request);
    HostedZone hostedZone = hostedZoneResult.getHostedZone();
    if (UtilValidate.isEmpty(hostedZone)) {
        return ServiceUtil.returnError("Could not find hosted zone: " + hostedZoneId);
    }
    DelegationSet delegationSet = hostedZoneResult.getDelegationSet();
    Map<String, Object> results = ServiceUtil.returnSuccess();
    results.put("hostedZone", hostedZone);
    results.put("delegationSet", delegationSet);
    return results;
}