/** * Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be * redacted from this string using a placeholder value. * * @return A string representation of this object. * * @see java.lang.Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getHostedZone() != null) sb.append("HostedZone: ").append(getHostedZone()).append(","); if (getDelegationSet() != null) sb.append("DelegationSet: ").append(getDelegationSet()).append(","); if (getVPCs() != null) sb.append("VPCs: ").append(getVPCs()); sb.append("}"); return sb.toString(); }
@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getHostedZone() == null) ? 0 : getHostedZone().hashCode()); hashCode = prime * hashCode + ((getDelegationSet() == null) ? 0 : getDelegationSet().hashCode()); hashCode = prime * hashCode + ((getVPCs() == null) ? 0 : getVPCs().hashCode()); return hashCode; }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof GetHostedZoneResult == false) return false; GetHostedZoneResult other = (GetHostedZoneResult) obj; if (other.getHostedZone() == null ^ this.getHostedZone() == null) return false; if (other.getHostedZone() != null && other.getHostedZone().equals(this.getHostedZone()) == false) return false; if (other.getDelegationSet() == null ^ this.getDelegationSet() == null) return false; if (other.getDelegationSet() != null && other.getDelegationSet().equals(this.getDelegationSet()) == false) return false; if (other.getVPCs() == null ^ this.getVPCs() == null) return false; if (other.getVPCs() != null && other.getVPCs().equals(this.getVPCs()) == false) return false; return true; }
} else if (obj instanceof GetHostedZoneResult) { GetHostedZoneResult result = (GetHostedZoneResult)obj; removePrefix(result.getHostedZone()); } else if (obj instanceof ListHostedZonesResult) { ListHostedZonesResult result = (ListHostedZonesResult)obj;
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); }); } n.set("aws_nameServers", an); return n; }
protected void projectHostedZoneResult(GetHostedZoneResult hostedZoneResult) { HostedZone hz = hostedZoneResult.getHostedZone(); ObjectNode n = toJson(hostedZoneResult); getNeoRxClient().execCypher( "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; long timestamp = System.currentTimeMillis(); do { rateLimit(); 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"); }