List of usage examples for com.amazonaws.services.route53.model ChangeResourceRecordSetsResult getChangeInfo
public ChangeInfo getChangeInfo()
A complex type that contains information about changes made to your hosted zone.
From source file:com.carrotgarden.maven.aws.dns.CarrotRoute53.java
License:BSD License
public void ensureCNAME(final String source, final String target) throws Exception { final HostedZone zone = findZone(source); Util.assertNotNull(zone, "missing zone for " + source); final String zoneId = zone.getId(); final boolean isPresent; final ResourceRecordSet recordOld; {//from w ww .j av a2 s .c o m final ResourceRecordSet recordFound = findRecord(zoneId, source); if (recordFound == null) { isPresent = false; recordOld = makeRecordCNAME(source, target); } else { isPresent = true; recordOld = recordFound; } } final ResourceRecordSet recordNew = makeRecordCNAME(source, target); recordNew.setTTL(recordOld.getTTL()); // final Collection<Change> changeList = new LinkedList<Change>(); if (isPresent) { changeList.add(new Change(ChangeAction.DELETE, recordOld)); changeList.add(new Change(ChangeAction.CREATE, recordNew)); } else { changeList.add(new Change(ChangeAction.CREATE, recordNew)); } final ChangeBatch changeRequest = new ChangeBatch(); changeRequest.setComment("updated : " + new Date()); changeRequest.setChanges(changeList); final ChangeResourceRecordSetsRequest request = new ChangeResourceRecordSetsRequest(); request.setHostedZoneId(zone.getId()); request.setChangeBatch(changeRequest); final ChangeResourceRecordSetsResult result = amazonClient.changeResourceRecordSets(request); final ChangeInfo changeResult = result.getChangeInfo(); logger.info("changeResult : \n{}", changeResult); }
From source file:com.msi.dns53.server.query.ChangeResourceRecordSets.java
License:Apache License
@Override public String marshall(MarshallStruct<ChangeResourceRecordSetsResult> input, HttpServletResponse resp) throws Exception { ChangeResourceRecordSetsResult result = input.getMainObject(); ChangeInfo ci = result.getChangeInfo(); XMLNode response = new XMLNode(DNS53Constants.CHANGERESOURCERECORDSETSRESPONSE); response.addAttr(DNS53Constants.XMLNS, DNS53Constants.XMLNS_VALUE); if (ci != null) { DNS53QueryUtil.marshallChangeInfo(ci, response); }//from ww w. ja v a2 s. co m return response.toString(); }
From source file:net.za.slyfox.dyn53.route53.Route53Updater.java
License:Apache License
/** * Updates the configured resource record set with the value of an IP address. * * @param inetAddress the address to update the resource record set with */// ww w. j a v a2s. c om @Override public void accept(InetAddress inetAddress) { final String address = inetAddress.getHostAddress(); logger.info("Updating resource record set {} in hosted zone {} to {}", resourceRecordSetName, hostedZoneId, address); final ResourceRecordSet resourceRecordSet = new ResourceRecordSet(resourceRecordSetName, getResourceRecordType(inetAddress)).withResourceRecords(new ResourceRecord(address)) .withTTL(resourceRecordSetTtl); final Change change = new Change(ChangeAction.UPSERT, resourceRecordSet); final ChangeBatch changeBatch = new ChangeBatch().withChanges(change).withComment("Dyn53 update"); final ChangeResourceRecordSetsRequest request = new ChangeResourceRecordSetsRequest() .withHostedZoneId(hostedZoneId).withChangeBatch(changeBatch); if (logger.isDebugEnabled()) { logger.debug("Requesting change: {}", change); } final ChangeResourceRecordSetsResult result = route53.changeResourceRecordSets(request); if (logger.isInfoEnabled()) { logger.info("Result of change request {}: {}", result.getChangeInfo().getId(), result.getChangeInfo().getStatus()); } }
From source file:org.ofbiz.tenant.amazonaws.AwsServices.java
License:Apache License
/** * create Amazon Rout53 resource record set * @param ctx//w w w . ja v a 2 s .co m * @param context * @return */ public static Map<String, Object> createAmazonRoute53ResourceRecordSet(DispatchContext ctx, Map<String, Object> context) { String hostedZoneId = (String) context.get("hostedZoneId"); String recordSetName = (String) context.get("recordSetName"); String recordSetType = (String) context.get("recordSetType"); List<String> domainNames = UtilGenerics.checkList(context.get("domainNames")); String dNSName = (String) context.get("dNSName"); String resourceRecordSetId = (String) context.get("resourceRecordSetId"); Long weight = (Long) context.get("weight"); Long tTL = (Long) context.get("tTL"); try { AmazonRoute53 route53 = AwsFactory.getAmazonRoute53(); RRType rrType = AwsUtil.getRRType(recordSetType); ResourceRecordSet resourceRecordSet = new ResourceRecordSet(recordSetName, rrType); // set alias target if (UtilValidate.isNotEmpty(dNSName)) { AliasTarget aliasTarget = new AliasTarget(hostedZoneId, dNSName); resourceRecordSet.setAliasTarget(aliasTarget); } // set resource record set identifier if (UtilValidate.isNotEmpty(resourceRecordSetId)) { resourceRecordSet.setSetIdentifier(resourceRecordSetId); } // set resource records List<ResourceRecord> resourceRecords = FastList.newInstance(); for (String domainName : domainNames) { ResourceRecord resourceRecord = new ResourceRecord(domainName); resourceRecords.add(resourceRecord); } resourceRecordSet.setResourceRecords(resourceRecords); // set weight if (UtilValidate.isEmpty(weight)) { weight = 0L; } resourceRecordSet.setWeight(weight); // set TTL if (UtilValidate.isEmpty(tTL)) { tTL = 300L; } resourceRecordSet.setTTL(tTL); Change change = new Change(ChangeAction.CREATE, resourceRecordSet); List<Change> changes = FastList.newInstance(); changes.add(change); ChangeBatch changeBatch = new ChangeBatch(changes); ChangeResourceRecordSetsRequest request = new ChangeResourceRecordSetsRequest(hostedZoneId, changeBatch); ChangeResourceRecordSetsResult resourceRecordSetsResult = route53.changeResourceRecordSets(request); ChangeInfo changeInfo = resourceRecordSetsResult.getChangeInfo(); String changeId = changeInfo.getId(); String status = changeInfo.getStatus(); Date submittedAt = changeInfo.getSubmittedAt(); String comment = changeInfo.getComment(); Map<String, Object> results = ServiceUtil.returnSuccess(); results.put("changeId", changeId); results.put("status", status); results.put("submittedAt", submittedAt); results.put("comment", comment); return results; } catch (Exception e) { Debug.logError(e, module); return ServiceUtil.returnError(e.getMessage()); } }
From source file:org.ofbiz.tenant.amazonaws.AwsServices.java
License:Apache License
/** * update Amazon Rout53 resource record set * @param ctx//from w w w. j a va 2s . c o m * @param context * @return */ public static Map<String, Object> updateAmazonRoute53ResourceRecordSet(DispatchContext ctx, Map<String, Object> context) { String hostedZoneId = (String) context.get("hostedZoneId"); String recordSetName = (String) context.get("recordSetName"); String recordSetType = (String) context.get("recordSetType"); List<String> domainNames = UtilGenerics.checkList(context.get("domainNames")); List<String> newDomainNames = UtilGenerics.checkList(context.get("newDomainNames")); String dNSName = (String) context.get("dNSName"); String resourceRecordSetId = (String) context.get("resourceRecordSetId"); Long weight = (Long) context.get("weight"); Long tTL = (Long) context.get("tTL"); try { AmazonRoute53 route53 = AwsFactory.getAmazonRoute53(); RRType rrType = AwsUtil.getRRType(recordSetType); ResourceRecordSet deleteResourceRecordSet = new ResourceRecordSet(recordSetName, rrType); ResourceRecordSet createResourceRecordSet = new ResourceRecordSet(recordSetName, rrType); // set alias target if (UtilValidate.isNotEmpty(dNSName)) { AliasTarget aliasTarget = new AliasTarget(hostedZoneId, dNSName); deleteResourceRecordSet.setAliasTarget(aliasTarget); createResourceRecordSet.setAliasTarget(aliasTarget); } // set resource record set identifier if (UtilValidate.isNotEmpty(resourceRecordSetId)) { deleteResourceRecordSet.setSetIdentifier(resourceRecordSetId); createResourceRecordSet.setSetIdentifier(resourceRecordSetId); } // set weight if (UtilValidate.isEmpty(weight)) { weight = 0L; } deleteResourceRecordSet.setWeight(weight); createResourceRecordSet.setWeight(weight); // set TTL if (UtilValidate.isEmpty(tTL)) { tTL = 300L; } deleteResourceRecordSet.setTTL(tTL); createResourceRecordSet.setTTL(tTL); //--------- Delete Resource Record Set Change List<ResourceRecord> deleteResourceRecords = FastList.newInstance(); // set delete resource records for (String domainName : domainNames) { ResourceRecord resourceRecord = new ResourceRecord(domainName); deleteResourceRecords.add(resourceRecord); } deleteResourceRecordSet.setResourceRecords(deleteResourceRecords); Change deleteChange = new Change(ChangeAction.DELETE, deleteResourceRecordSet); //-------- Create New Resource Record Set Change List<ResourceRecord> createResourceRecords = FastList.newInstance(); // set create resource records for (String newDomainName : newDomainNames) { ResourceRecord resourceRecord = new ResourceRecord(newDomainName); createResourceRecords.add(resourceRecord); } createResourceRecordSet.setResourceRecords(createResourceRecords); Change createChange = new Change(ChangeAction.CREATE, createResourceRecordSet); // send request List<Change> changes = FastList.newInstance(); changes.add(deleteChange); changes.add(createChange); ChangeBatch changeBatch = new ChangeBatch(changes); ChangeResourceRecordSetsRequest request = new ChangeResourceRecordSetsRequest(hostedZoneId, changeBatch); ChangeResourceRecordSetsResult resourceRecordSetsResult = route53.changeResourceRecordSets(request); ChangeInfo changeInfo = resourceRecordSetsResult.getChangeInfo(); String changeId = changeInfo.getId(); String status = changeInfo.getStatus(); Date submittedAt = changeInfo.getSubmittedAt(); String comment = changeInfo.getComment(); Map<String, Object> results = ServiceUtil.returnSuccess(); results.put("changeId", changeId); results.put("status", status); results.put("submittedAt", submittedAt); results.put("comment", comment); return results; } catch (Exception e) { Debug.logError(e, module); return ServiceUtil.returnError(e.getMessage()); } }
From source file:org.ofbiz.tenant.amazonaws.AwsServices.java
License:Apache License
/** * delete Amazon Rout53 resource record set * @param ctx/*from w w w . ja v a 2 s.c om*/ * @param context * @return */ public static Map<String, Object> deleteAmazonRoute53ResourceRecordSet(DispatchContext ctx, Map<String, Object> context) { String hostedZoneId = (String) context.get("hostedZoneId"); String recordSetName = (String) context.get("recordSetName"); String recordSetType = (String) context.get("recordSetType"); List<String> domainNames = UtilGenerics.checkList(context.get("domainNames")); String dNSName = (String) context.get("dNSName"); String resourceRecordSetId = (String) context.get("resourceRecordSetId"); Long weight = (Long) context.get("weight"); Long tTL = (Long) context.get("tTL"); try { AmazonRoute53 route53 = AwsFactory.getAmazonRoute53(); RRType rrType = AwsUtil.getRRType(recordSetType); ResourceRecordSet resourceRecordSet = new ResourceRecordSet(recordSetName, rrType); // set alias target if (UtilValidate.isNotEmpty(dNSName)) { AliasTarget aliasTarget = new AliasTarget(hostedZoneId, dNSName); resourceRecordSet.setAliasTarget(aliasTarget); } // set resource record set identifier if (UtilValidate.isNotEmpty(resourceRecordSetId)) { resourceRecordSet.setSetIdentifier(resourceRecordSetId); } // set resource records List<ResourceRecord> resourceRecords = FastList.newInstance(); for (String domainName : domainNames) { ResourceRecord resourceRecord = new ResourceRecord(domainName); resourceRecords.add(resourceRecord); } resourceRecordSet.setResourceRecords(resourceRecords); // set weight if (UtilValidate.isEmpty(weight)) { weight = 0L; } resourceRecordSet.setWeight(weight); // set TTL if (UtilValidate.isEmpty(tTL)) { tTL = 300L; } resourceRecordSet.setTTL(tTL); Change change = new Change(ChangeAction.DELETE, resourceRecordSet); List<Change> changes = FastList.newInstance(); changes.add(change); ChangeBatch changeBatch = new ChangeBatch(changes); ChangeResourceRecordSetsRequest request = new ChangeResourceRecordSetsRequest(hostedZoneId, changeBatch); ChangeResourceRecordSetsResult resourceRecordSetsResult = route53.changeResourceRecordSets(request); ChangeInfo changeInfo = resourceRecordSetsResult.getChangeInfo(); String changeId = changeInfo.getId(); String status = changeInfo.getStatus(); Date submittedAt = changeInfo.getSubmittedAt(); String comment = changeInfo.getComment(); Map<String, Object> results = ServiceUtil.returnSuccess(); results.put("changeId", changeId); results.put("status", status); results.put("submittedAt", submittedAt); results.put("comment", comment); return results; } catch (Exception e) { Debug.logError(e, module); return ServiceUtil.returnError(e.getMessage()); } }
From source file:tech.greenfield.aws.route53.Tools.java
License:Open Source License
/** * Wait until the specified change request has been applied on Route53 servers * @param reqRes the result of submitting a change request *//*from w ww . j ava 2s . c o m*/ public static void waitFor(ChangeResourceRecordSetsResult reqRes) { ChangeInfo ci = reqRes.getChangeInfo(); while (ci.getStatus().equals("PENDING")) { synchronized (ci) { try { ci.wait(WAIT_PULSE); } catch (InterruptedException e) { } } ci = route53().getChange(new GetChangeRequest(ci.getId())).getChangeInfo(); } }