private void executeChange(Change change, HostedZone hostedZone) { logger.info("Execute change {} ", change); ChangeResourceRecordSetsRequest changeResourceRecordSetsRequest = new ChangeResourceRecordSetsRequest(); changeResourceRecordSetsRequest.setHostedZoneId(hostedZone.getId()); ChangeBatch changeBatch = new ChangeBatch(); changeBatch.withChanges(change); changeResourceRecordSetsRequest.setChangeBatch(changeBatch); amazonRoute53Client.changeResourceRecordSets(changeResourceRecordSetsRequest); }
@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getComment() == null) ? 0 : getComment().hashCode()); hashCode = prime * hashCode + ((getChanges() == null) ? 0 : getChanges().hashCode()); return hashCode; }
/** * <p> * <i>Optional:</i> Any comments you want to include about a change batch request. * </p> * * @param comment * <i>Optional:</i> Any comments you want to include about a change batch request. * @return Returns a reference to this object so that method calls can be chained together. */ public ChangeBatch withComment(String comment) { setComment(comment); return this; }
public ChangeBatch unmarshall(StaxUnmarshallerContext context) throws Exception { ChangeBatch changeBatch = new ChangeBatch(); int originalDepth = context.getCurrentDepth(); int targetDepth = originalDepth + 1; if (context.isStartOfDocument()) targetDepth += 1; while (true) { XMLEvent xmlEvent = context.nextEvent(); if (xmlEvent.isEndDocument()) return changeBatch; if (xmlEvent.isAttribute() || xmlEvent.isStartElement()) { if (context.testExpression("Comment", targetDepth)) { changeBatch.setComment(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; } if (context.testExpression("Changes", targetDepth)) { changeBatch.withChanges(new ArrayList<Change>()); continue; } if (context.testExpression("Changes/Change", targetDepth)) { changeBatch.withChanges(ChangeStaxUnmarshaller.getInstance().unmarshall(context)); continue; } } else if (xmlEvent.isEndElement()) { if (context.getCurrentDepth() < originalDepth) { return changeBatch; } } } }
protected void assignDomain(BindDomainsContext ctx, String record, String zoneId) { ChangeBatch changeBatch = new ChangeBatch(); changeBatch.setComment(format("Updated for env %s", ctx.getCurEnv().getCNAME())); changeBatch.getChanges().add(new Change(ChangeAction.DELETE, rrs)); changeBatch.getChanges().add(new Change(ChangeAction.CREATE, resourceRecordSet)); info("Changes to be sent: %s", changeBatch.getChanges());
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof ChangeResourceRecordSetsRequest == false) return false; ChangeResourceRecordSetsRequest other = (ChangeResourceRecordSetsRequest) obj; if (other.getHostedZoneId() == null ^ this.getHostedZoneId() == null) return false; if (other.getHostedZoneId() != null && other.getHostedZoneId().equals(this.getHostedZoneId()) == false) return false; if (other.getChangeBatch() == null ^ this.getChangeBatch() == null) return false; if (other.getChangeBatch() != null && other.getChangeBatch().equals(this.getChangeBatch()) == false) return false; return true; }
private void executeChange(Change change, HostedZone hostedZone) { logger.info("Execute change {} ", change); ChangeResourceRecordSetsRequest changeResourceRecordSetsRequest = new ChangeResourceRecordSetsRequest(); changeResourceRecordSetsRequest.setHostedZoneId(hostedZone.getId()); ChangeBatch changeBatch = new ChangeBatch(); changeBatch.withChanges(change); changeResourceRecordSetsRequest.setChangeBatch(changeBatch); amazonRoute53Client.changeResourceRecordSets(changeResourceRecordSetsRequest); }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof ChangeBatch == false) return false; ChangeBatch other = (ChangeBatch) obj; if (other.getComment() == null ^ this.getComment() == null) return false; if (other.getComment() != null && other.getComment().equals(this.getComment()) == false) return false; if (other.getChanges() == null ^ this.getChanges() == null) return false; if (other.getChanges() != null && other.getChanges().equals(this.getChanges()) == false) return false; return true; }
@TaskAction public void changeResourceRecordSets() { // to enable conventionMappings feature String hostedZoneId = getHostedZoneId(); String rrsName = getRrsName(); String resourceRecord = getResourceRecord(); AmazonRoute53PluginExtension ext = getProject().getExtensions().getByType(AmazonRoute53PluginExtension.class); AmazonRoute53 route53 = ext.getClient(); route53.changeResourceRecordSets(new ChangeResourceRecordSetsRequest() .withHostedZoneId(hostedZoneId) .withChangeBatch(new ChangeBatch() .withChanges(new Change(ChangeAction.CREATE, new ResourceRecordSet(rrsName, RRType.CNAME) .withResourceRecords(new ResourceRecord(resourceRecord)))))); getLogger().info("change {} requested", hostedZoneId); } }
/** * 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 (getComment() != null) sb.append("Comment: ").append(getComment()).append(","); if (getChanges() != null) sb.append("Changes: ").append(getChanges()); sb.append("}"); return sb.toString(); }
.withChangeBatch(new ChangeBatch() .withChanges(new Change() .withAction(ChangeAction.UPSERT) .withResourceRecordSet(resourceRecordSet)
xmlWriter.startElement("ChangeBatch"); if (changeBatch.getComment() != null) { xmlWriter.startElement("Comment").value(changeBatch.getComment()).endElement(); .getChanges(); if (!changeBatchChangesList.isEmpty() || !changeBatchChangesList.isAutoConstruct()) { xmlWriter.startElement("Changes");