Example usage for com.amazonaws.services.route53.model ChangeInfo setComment

List of usage examples for com.amazonaws.services.route53.model ChangeInfo setComment

Introduction

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

Prototype


public void setComment(String comment) 

Source Link

Document

A complex type that describes change information about changes made to your hosted zone.

Usage

From source file:com.msi.dns53.client.DNS53Client.java

License:Apache License

public CreateHostedZoneResult createHostedZone(CreateHostedZoneRequest req)
        throws AmazonServiceException, AmazonClientException {
    Client c = Client.create();//from   w ww . ja va2  s.  co m
    WebResource r = c.resource(this.serverURL);

    String entity = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
            + "<CreateHostedZoneRequest xmlns=\"https://route53.amazonaws.com/doc/2012-02-29/\">" + "<Name>"
            + req.getName() + "</Name>" + "<CallerReference>" + req.getCallerReference() + "</CallerReference>";
    if (req.getHostedZoneConfig() != null && req.getHostedZoneConfig().getComment() != null) {
        entity += "<HostedZoneConfig>" + "<Comment>" + req.getHostedZoneConfig().getComment() + "</Comment>"
                + "</HostedZoneConfig>";
    }
    entity += "</CreateHostedZoneRequest>";

    ClientResponse response = r
            .header("X-Amzn-Authorization",
                    "AWS3 AWSAccessKeyId=" + this.accessKey + "," + "Algorithm=HmacSHA256,"
                            + "SignedHeaders=Host;X-Amz-Date," + "Signature=THISISANEXAMPLESIGNATURE=")
            .type(MediaType.APPLICATION_XML_TYPE).accept(MediaType.TEXT_XML).entity(entity)
            .post(ClientResponse.class);

    String resultXml = response.getEntity(String.class);
    if (response.getStatus() > 299 || response.getStatus() < 200) {
        exceptionMapper(response, resultXml);
    }

    CreateHostedZoneResponsePOJO interResult = null;
    try {
        StringReader reader = new StringReader(resultXml);
        JAXBContext context = JAXBContext.newInstance(CreateHostedZoneResponsePOJO.class);
        Unmarshaller unmarshaller = context.createUnmarshaller();
        interResult = (CreateHostedZoneResponsePOJO) unmarshaller.unmarshal(reader);
    } catch (JAXBException e) {
        e.printStackTrace();
        return null;
    }
    if (interResult == null) {
        return null;
    }

    CreateHostedZoneResult result = new CreateHostedZoneResult();
    if (interResult.getHostedZone() != null) {
        HostedZone hostedZone = new HostedZone();
        hostedZone.setId(interResult.getHostedZone().getId());
        hostedZone.setName(interResult.getHostedZone().getName());
        hostedZone.setCallerReference(interResult.getHostedZone().getCallerReference());
        if (interResult.getHostedZone().getConfig() != null) {
            HostedZoneConfig config = new HostedZoneConfig();
            config.setComment(interResult.getHostedZone().getConfig().getComment());
            hostedZone.setConfig(config);
        }
        result.setHostedZone(hostedZone);
    }
    if (interResult.getChangeInfo() != null) {
        ChangeInfo changeInfo = new ChangeInfo();
        changeInfo.setId(interResult.getChangeInfo().getId());
        changeInfo.setStatus(interResult.getChangeInfo().getStatus());
        changeInfo.setSubmittedAt(interResult.getChangeInfo().getSubmittedAt());
        changeInfo.setComment(interResult.getChangeInfo().getComment());
        result.setChangeInfo(changeInfo);
    }
    if (interResult.getDelegationSet() != null) {
        DelegationSet dSet = new DelegationSet();
        dSet.setNameServers(interResult.getDelegationSet().getNameServers());
        result.setDelegationSet(dSet);
    }
    return result;
}

From source file:com.msi.dns53.client.DNS53Client.java

License:Apache License

public DeleteHostedZoneResult deleteHostedZone(DeleteHostedZoneRequest req)
        throws AmazonServiceException, AmazonClientException {
    Client c = Client.create();/*from  w w  w  . j a  v  a 2s.c om*/
    WebResource r = c.resource(this.serverURL);
    ClientResponse response = r.path(req.getId()).type(MediaType.APPLICATION_XML_TYPE)
            .accept(MediaType.TEXT_XML)
            .header("X-Amzn-Authorization",
                    "AWS3 AWSAccessKeyId=" + this.accessKey + "," + "Algorithm=HmacSHA256,"
                            + "SignedHeaders=Host;X-Amz-Date," + "Signature=THISISANEXAMPLESIGNATURE=")
            .delete(ClientResponse.class);

    String resultXml = response.getEntity(String.class);
    if (response.getStatus() != 200) {
        exceptionMapper(response, resultXml);
    }

    DeleteHostedZoneResponsePOJO interResult = null;
    try {
        StringReader reader = new StringReader(resultXml);
        JAXBContext context = JAXBContext.newInstance(DeleteHostedZoneResponsePOJO.class);
        Unmarshaller unmarshaller = context.createUnmarshaller();
        interResult = (DeleteHostedZoneResponsePOJO) unmarshaller.unmarshal(reader);
    } catch (JAXBException e) {
        e.printStackTrace();
        return null;
    }
    if (interResult == null) {
        return null;
    }

    DeleteHostedZoneResult result = new DeleteHostedZoneResult();
    if (interResult.getChangeInfo() != null) {
        ChangeInfo ci = new ChangeInfo();
        if (interResult.getChangeInfo().getId() != null) {
            ci.setId(interResult.getChangeInfo().getId());
        }
        if (interResult.getChangeInfo().getStatus() != null) {
            ci.setStatus(interResult.getChangeInfo().getStatus());
        }
        if (interResult.getChangeInfo().getSubmittedAt() != null) {
            ci.setSubmittedAt(interResult.getChangeInfo().getSubmittedAt());
        }
        if (interResult.getChangeInfo().getComment() != null) {
            ci.setComment(interResult.getChangeInfo().getComment());
        }
        result.setChangeInfo(ci);
    }
    return result;
}

From source file:com.msi.dns53.client.DNS53Client.java

License:Apache License

public ChangeResourceRecordSetsResult changeResourceRecordSets(ChangeResourceRecordSetsRequest req)
        throws AmazonServiceException, AmazonClientException {
    Client c = Client.create();//from  w ww  . j  a v  a  2s.c o  m
    WebResource r = c.resource(this.serverURL);

    String entity = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
            + "<ChangeResourceRecordSetsRequest xmlns=\"https://route53.amazonaws.com/doc/2012-02-29/\">";
    if (req.getChangeBatch() != null) {
        entity += "<ChangeBatch>";
        if (req.getChangeBatch().getComment() != null) {
            entity += "<Comment>" + req.getChangeBatch().getComment() + "</Comment>";
        }
        List<Change> changes = req.getChangeBatch().getChanges();
        if (changes != null && changes.size() > 0) {
            entity += "<Changes>";
            for (Change change : changes) {
                entity += "<Change>";
                entity += "<Action>" + change.getAction() + "</Action>";
                if (change.getResourceRecordSet() != null) {
                    entity += "<ResourceRecordSet>";
                    entity += "<Name>" + change.getResourceRecordSet().getName() + "</Name>";
                    entity += "<Type>" + change.getResourceRecordSet().getType() + "</Type>";
                    entity += "<TTL>" + change.getResourceRecordSet().getTTL() + "</TTL>";
                    List<ResourceRecord> records = change.getResourceRecordSet().getResourceRecords();
                    if (records != null && records.size() > 0) {
                        entity += "<ResourceRecords>";
                        for (ResourceRecord record : records) {
                            entity += "<ResourceRecord><Value>" + record.getValue()
                                    + "</Value></ResourceRecord>";
                        }
                        entity += "</ResourceRecords>";
                    }
                    entity += "</ResourceRecordSet>";
                }
                entity += "</Change>";
            }
            entity += "</Changes>";
        }
        entity += "</ChangeBatch>";
    }
    entity += "</ChangeResourceRecordSetsRequest>";

    ClientResponse response = r.path(req.getHostedZoneId() + "/rrset")
            .header("X-Amzn-Authorization",
                    "AWS3 AWSAccessKeyId=" + this.accessKey + "," + "Algorithm=HmacSHA256,"
                            + "SignedHeaders=Host;X-Amz-Date," + "Signature=THISISANEXAMPLESIGNATURE=")
            .type(MediaType.APPLICATION_XML_TYPE).accept(MediaType.TEXT_XML).entity(entity)
            .post(ClientResponse.class);

    String resultXml = response.getEntity(String.class);
    if (response.getStatus() != 200) {
        exceptionMapper(response, resultXml);
    }

    ChangeResourceRecordSetsResponsePOJO interResult = null;
    try {
        StringReader reader = new StringReader(resultXml);
        JAXBContext context = JAXBContext.newInstance(ChangeResourceRecordSetsResponsePOJO.class);
        Unmarshaller unmarshaller = context.createUnmarshaller();
        interResult = (ChangeResourceRecordSetsResponsePOJO) unmarshaller.unmarshal(reader);
    } catch (JAXBException e) {
        e.printStackTrace();
        return null;
    }
    if (interResult == null) {
        return null;
    }

    ChangeResourceRecordSetsResult result = new ChangeResourceRecordSetsResult();
    if (interResult.getChangeInfo() != null) {
        ChangeInfo ci = new ChangeInfo();
        ci.setComment(interResult.getChangeInfo().getComment());
        ci.setId(interResult.getChangeInfo().getId());
        ci.setStatus(interResult.getChangeInfo().getStatus());
        ci.setSubmittedAt(interResult.getChangeInfo().getSubmittedAt());
        result.setChangeInfo(ci);
    }

    return result;
}

From source file:com.msi.dns53.client.DNS53Client.java

License:Apache License

public GetChangeResult getChange(GetChangeRequest req) throws AmazonServiceException, AmazonClientException {
    Client c = Client.create();/*  ww  w.ja v  a2 s  .  c  o  m*/
    WebResource r = c.resource(this.changeURL);
    String resultXml = r.path(req.getId()).type(MediaType.APPLICATION_XML_TYPE).accept(MediaType.TEXT_XML)
            .header("X-Amzn-Authorization",
                    "AWS3 AWSAccessKeyId=" + this.accessKey + "," + "Algorithm=HmacSHA256,"
                            + "SignedHeaders=Host;X-Amz-Date," + "Signature=THISISANEXAMPLESIGNATURE=")
            .get(String.class);

    GetChangeResponsePOJO interResult = null;
    try {
        StringReader reader = new StringReader(resultXml);
        JAXBContext context = JAXBContext.newInstance(GetChangeResponsePOJO.class);
        Unmarshaller unmarshaller = context.createUnmarshaller();
        interResult = (GetChangeResponsePOJO) unmarshaller.unmarshal(reader);
    } catch (JAXBException e) {
        e.printStackTrace();
        return null;
    }
    if (interResult == null) {
        return null;
    }

    GetChangeResult result = new GetChangeResult();
    if (interResult.getChangeInfo() != null) {
        ChangeInfo ci = new ChangeInfo();
        ci.setComment(interResult.getChangeInfo().getComment());
        ci.setId(interResult.getChangeInfo().getId());
        ci.setStatus(interResult.getChangeInfo().getStatus());
        ci.setSubmittedAt(interResult.getChangeInfo().getSubmittedAt());
        result.setChangeInfo(ci);
    }
    return result;
}