Java 类com.amazonaws.services.route53.model.ChangeResourceRecordSetsResult 实例源码

项目:ec2-util    文件:AwsRoute53Client.java   
public static ChangeInfo changeResourceRecordSet(AmazonRoute53 route53, String hostedZoneId,
        ResourceRecordSet resourceRecordSet, ChangeAction changeAction) {
    Change change = new Change(changeAction, resourceRecordSet);
    ChangeBatch changeBatch = new ChangeBatch().withChanges(change);
    ChangeResourceRecordSetsRequest changeResourceRecordSetsRequest = new ChangeResourceRecordSetsRequest(
            hostedZoneId, changeBatch);
    ChangeResourceRecordSetsResult changeResourceRecordSetsResult = route53
            .changeResourceRecordSets(changeResourceRecordSetsRequest);
    ChangeInfo changeinfo = changeResourceRecordSetsResult.getChangeInfo();
    return changeinfo;
}
项目:TopStackDNS53    文件:ChangeResourceRecordSets.java   
@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);
    }
    return response.toString();
}
项目:TopStackDNS53    文件:ChangeResourceRecordSets.java   
@Override
public ChangeResourceRecordSetsResult process0(Session session,
        HttpServletRequest req, HttpServletResponse resp,
        Map<String, String[]> map) throws Exception {
    ChangeResourceRecordSetsRequest request = unmarshall(req);
    return changeResourceRecordSets(session, request);
}
项目:TopStackDNS53    文件:DNS53IntegrationTest.java   
@Test
public void changeResourceRecordSets0() {
    String batchComment = "I have no idea what I'm doing.";
    ChangeResourceRecordSetsRequest req = new ChangeResourceRecordSetsRequest();
    req.setHostedZoneId(getZoneId(zoneName0));
    ChangeBatch batch = new ChangeBatch();
    batch.setComment(batchComment);
    Collection<Change> changes = new LinkedList<Change>();
    ResourceRecord resourceRecord = new ResourceRecord()
            .withValue("172.31.255.235");
    changes.add(new Change().withAction("CREATE").withResourceRecordSet(
            new ResourceRecordSet().withName("www." + zoneName0)
                    .withType("A").withTTL(300L)
                    .withResourceRecords(resourceRecord)));
    batch.setChanges(changes);
    req.setChangeBatch(batch);
    ChangeResourceRecordSetsResult result = customDNS53Client
            .changeResourceRecordSets(req);

    assertNotNull(result);
    assertNotNull(result.getChangeInfo());
    assertNotNull(result.getChangeInfo().getId());
    assertNotNull(result.getChangeInfo().getStatus());
    assertNotNull(result.getChangeInfo().getSubmittedAt());

    System.out.println(result);
}
项目:TopStackDNS53    文件:DNS53IntegrationTest.java   
@Test
public void changeResourceRecordSets1() {
    String batchComment = "I have no idea what I'm doing.";
    ChangeResourceRecordSetsRequest req = new ChangeResourceRecordSetsRequest();
    req.setHostedZoneId(getZoneId(zoneName0));
    ChangeBatch batch = new ChangeBatch();
    batch.setComment(batchComment);
    Collection<Change> changes = new LinkedList<Change>();
    ResourceRecord resourceRecord = new ResourceRecord()
            .withValue("172.31.255.235");
    ResourceRecord resourceRecord2 = new ResourceRecord()
            .withValue("172.31.255.254");
    changes.add(new Change().withAction("CREATE").withResourceRecordSet(
            new ResourceRecordSet().withName("w2." + zoneName0)
                    .withType("A").withTTL(300L)
                    .withResourceRecords(resourceRecord, resourceRecord2)));
    batch.setChanges(changes);
    req.setChangeBatch(batch);
    ChangeResourceRecordSetsResult result = customDNS53Client
            .changeResourceRecordSets(req);

    assertNotNull(result);
    assertNotNull(result.getChangeInfo());
    assertNotNull(result.getChangeInfo().getId());
    assertNotNull(result.getChangeInfo().getStatus());
    assertNotNull(result.getChangeInfo().getSubmittedAt());

    System.out.println(result);
}
项目:TopStackDNS53    文件:DNS53IntegrationTest.java   
@Test
public void changeResourceRecordSets2() {
    String batchComment = "Now I know what I'm doing. Kind of...";
    ChangeResourceRecordSetsRequest req = new ChangeResourceRecordSetsRequest();
    req.setHostedZoneId(getZoneId(zoneName0));
    ChangeBatch batch = new ChangeBatch();
    batch.setComment(batchComment);
    Collection<Change> changes = new LinkedList<Change>();
    ResourceRecord resourceRecord = new ResourceRecord()
            .withValue("172.31.255.235");
    ResourceRecord resourceRecord2 = new ResourceRecord()
            .withValue("172.31.255.254");
    changes.add(new Change().withAction("DELETE").withResourceRecordSet(
            new ResourceRecordSet().withName("w2." + zoneName0)
                    .withType("A").withTTL(300L)
                    .withResourceRecords(resourceRecord, resourceRecord2)));
    batch.setChanges(changes);
    req.setChangeBatch(batch);
    ChangeResourceRecordSetsResult result = customDNS53Client
            .changeResourceRecordSets(req);

    assertNotNull(result);
    assertNotNull(result.getChangeInfo());
    assertNotNull(result.getChangeInfo().getId());
    assertNotNull(result.getChangeInfo().getStatus());
    assertNotNull(result.getChangeInfo().getSubmittedAt());

    System.out.println(result);
}
项目:TopStackDNS53    文件:DNS53IntegrationTest.java   
@Test
public void changeResourceRecordSets3() {
    String batchComment = "I definitely know what I'm doing.";
    ChangeResourceRecordSetsRequest req = new ChangeResourceRecordSetsRequest();
    req.setHostedZoneId(getZoneId(zoneName0));
    ChangeBatch batch = new ChangeBatch();
    batch.setComment(batchComment);
    Collection<Change> changes = new LinkedList<Change>();
    ResourceRecord resourceRecord = new ResourceRecord()
            .withValue("172.31.255.235");
    changes.add(new Change().withAction("DELETE").withResourceRecordSet(
            new ResourceRecordSet().withName("www." + zoneName0)
                    .withType("A").withTTL(300L)
                    .withResourceRecords(resourceRecord)));
    batch.setChanges(changes);
    req.setChangeBatch(batch);
    ChangeResourceRecordSetsResult result = customDNS53Client
            .changeResourceRecordSets(req);

    assertNotNull(result);
    assertNotNull(result.getChangeInfo());
    assertNotNull(result.getChangeInfo().getId());
    assertNotNull(result.getChangeInfo().getStatus());
    assertNotNull(result.getChangeInfo().getSubmittedAt());

    System.out.println(result);
}
项目:Ec2InstanceStarter    文件:SimpleRecordService.java   
@Override
public boolean updateRecord(String ip) {

    String recordName = config.getRecordName();

    ChangeResourceRecordSetsRequest changeRequest = new ChangeResourceRecordSetsRequest();
    changeRequest.setHostedZoneId(config.getZoneId());
    ChangeBatch batch = new ChangeBatch();
    Change change = new Change();

    ResourceRecordSet set = getCurrentRecordSet();
    if (set != null) {
        if (!equalsIgnoreCase("A", set.getType())) {
            log.error("Record already exists but not as Type A. No actions were performed.");
            return false;
        }
        change.setAction("UPSERT");
        log.info("Record [" + recordName
                + "] already present on AWS Route 53. Upating it..");
    } else {
        change.setAction("CREATE");
        log.info("Record [" + recordName
                + "] not present on AWS Route 53. Creating it..");
        set = new ResourceRecordSet().withName(recordName).withType("A");
    }

    set.setTTL(Long.parseLong(config.getTTL()));
    List<ResourceRecord> l = new ArrayList<ResourceRecord>();
    l.add(new ResourceRecord(ip));
    set.setResourceRecords(l);

    change.setResourceRecordSet(set);
    batch.withChanges(change);

    changeRequest.setChangeBatch(batch);

    log.info("Updating DNS " + recordName + " with IP " + ip);

    ChangeResourceRecordSetsResult result = config.getAmazonRoute53Client()
            .changeResourceRecordSets(changeRequest);
    log.info(result.toString());
    return true;
}
项目:awsroute53    文件:SimpleRecordService.java   
@Override
public boolean updateRecord(String ip) {

    String recordName = config.getRecordName();

    ChangeResourceRecordSetsRequest changeRequest = new ChangeResourceRecordSetsRequest();
    changeRequest.setHostedZoneId(config.getZoneId());
    ChangeBatch batch = new ChangeBatch();
    Change change = new Change();


    ResourceRecordSet set = getCurrentRecordSet();
    if (set!=null){
        if (!equalsIgnoreCase("A", set.getType())){
            log.error("Record already exists but not as Type A. No actions were performed.");
            return false;
        }
        change.setAction("UPSERT");
        log.info("Record ["+recordName+"] already present on AWS Route 53. Upating it..");
    } else{
        change.setAction("CREATE");
        log.info("Record ["+recordName+"] not present on AWS Route 53. Creating it..");
        set = new ResourceRecordSet().withName(recordName).withType("A");
    }


    set.setTTL(Long.parseLong(config.getTTL()));
    List<ResourceRecord> l = new ArrayList<ResourceRecord>();
    l.add(new ResourceRecord(ip));
    set.setResourceRecords(l);

    change.setResourceRecordSet(set);
    batch.withChanges(change);

    changeRequest.setChangeBatch(batch);

    log.info("Updating DNS "+recordName+" with IP "+ip);

    ChangeResourceRecordSetsResult result =  config.getAmazonClient().changeResourceRecordSets(changeRequest);
    log.info(result.toString()); 
    return true;
}
项目:TopStackDNS53    文件:DNS53MetadataUtil.java   
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);

    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());
}
项目:jwrapper-maven-plugin    文件:CarrotRoute53.java   
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;
    {
        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);

}