use of com.microsoft.azure.management.dns.SrvRecord in project azure-sdk-for-java by Azure.
the class Utils method print.
/**
* Print a dns zone.
* @param dnsZone a dns zone
*/
public static void print(DnsZone dnsZone) {
StringBuilder info = new StringBuilder();
info.append("DNS Zone: ").append(dnsZone.id()).append("\n\tName (Top level domain): ").append(dnsZone.name()).append("\n\tResource group: ").append(dnsZone.resourceGroupName()).append("\n\tRegion: ").append(dnsZone.regionName()).append("\n\tTags: ").append(dnsZone.tags()).append("\n\tName servers:");
for (String nameServer : dnsZone.nameServers()) {
info.append("\n\t\t").append(nameServer);
}
SoaRecordSet soaRecordSet = dnsZone.getSoaRecordSet();
SoaRecord soaRecord = soaRecordSet.record();
info.append("\n\tSOA Record:").append("\n\t\tHost:").append(soaRecord.host()).append("\n\t\tEmail:").append(soaRecord.email()).append("\n\t\tExpire time (seconds):").append(soaRecord.expireTime()).append("\n\t\tRefresh time (seconds):").append(soaRecord.refreshTime()).append("\n\t\tRetry time (seconds):").append(soaRecord.retryTime()).append("\n\t\tNegative response cache ttl (seconds):").append(soaRecord.minimumTtl()).append("\n\t\tTTL (seconds):").append(soaRecordSet.timeToLive());
PagedList<ARecordSet> aRecordSets = dnsZone.aRecordSets().list();
info.append("\n\tA Record sets:");
for (ARecordSet aRecordSet : aRecordSets) {
info.append("\n\t\tId: ").append(aRecordSet.id()).append("\n\t\tName: ").append(aRecordSet.name()).append("\n\t\tTTL (seconds): ").append(aRecordSet.timeToLive()).append("\n\t\tIP v4 addresses: ");
for (String ipAddress : aRecordSet.ipv4Addresses()) {
info.append("\n\t\t\t").append(ipAddress);
}
}
PagedList<AaaaRecordSet> aaaaRecordSets = dnsZone.aaaaRecordSets().list();
info.append("\n\tAAAA Record sets:");
for (AaaaRecordSet aaaaRecordSet : aaaaRecordSets) {
info.append("\n\t\tId: ").append(aaaaRecordSet.id()).append("\n\t\tName: ").append(aaaaRecordSet.name()).append("\n\t\tTTL (seconds): ").append(aaaaRecordSet.timeToLive()).append("\n\t\tIP v6 addresses: ");
for (String ipAddress : aaaaRecordSet.ipv6Addresses()) {
info.append("\n\t\t\t").append(ipAddress);
}
}
PagedList<CNameRecordSet> cnameRecordSets = dnsZone.cNameRecordSets().list();
info.append("\n\tCNAME Record sets:");
for (CNameRecordSet cnameRecordSet : cnameRecordSets) {
info.append("\n\t\tId: ").append(cnameRecordSet.id()).append("\n\t\tName: ").append(cnameRecordSet.name()).append("\n\t\tTTL (seconds): ").append(cnameRecordSet.timeToLive()).append("\n\t\tCanonical name: ").append(cnameRecordSet.canonicalName());
}
PagedList<MXRecordSet> mxRecordSets = dnsZone.mxRecordSets().list();
info.append("\n\tMX Record sets:");
for (MXRecordSet mxRecordSet : mxRecordSets) {
info.append("\n\t\tId: ").append(mxRecordSet.id()).append("\n\t\tName: ").append(mxRecordSet.name()).append("\n\t\tTTL (seconds): ").append(mxRecordSet.timeToLive()).append("\n\t\tRecords: ");
for (MxRecord mxRecord : mxRecordSet.records()) {
info.append("\n\t\t\tExchange server, Preference: ").append(mxRecord.exchange()).append(" ").append(mxRecord.preference());
}
}
PagedList<NSRecordSet> nsRecordSets = dnsZone.nsRecordSets().list();
info.append("\n\tNS Record sets:");
for (NSRecordSet nsRecordSet : nsRecordSets) {
info.append("\n\t\tId: ").append(nsRecordSet.id()).append("\n\t\tName: ").append(nsRecordSet.name()).append("\n\t\tTTL (seconds): ").append(nsRecordSet.timeToLive()).append("\n\t\tName servers: ");
for (String nameServer : nsRecordSet.nameServers()) {
info.append("\n\t\t\t").append(nameServer);
}
}
PagedList<PtrRecordSet> ptrRecordSets = dnsZone.ptrRecordSets().list();
info.append("\n\tPTR Record sets:");
for (PtrRecordSet ptrRecordSet : ptrRecordSets) {
info.append("\n\t\tId: ").append(ptrRecordSet.id()).append("\n\t\tName: ").append(ptrRecordSet.name()).append("\n\t\tTTL (seconds): ").append(ptrRecordSet.timeToLive()).append("\n\t\tTarget domain names: ");
for (String domainNames : ptrRecordSet.targetDomainNames()) {
info.append("\n\t\t\t").append(domainNames);
}
}
PagedList<SrvRecordSet> srvRecordSets = dnsZone.srvRecordSets().list();
info.append("\n\tSRV Record sets:");
for (SrvRecordSet srvRecordSet : srvRecordSets) {
info.append("\n\t\tId: ").append(srvRecordSet.id()).append("\n\t\tName: ").append(srvRecordSet.name()).append("\n\t\tTTL (seconds): ").append(srvRecordSet.timeToLive()).append("\n\t\tRecords: ");
for (SrvRecord srvRecord : srvRecordSet.records()) {
info.append("\n\t\t\tTarget, Port, Priority, Weight: ").append(srvRecord.target()).append(", ").append(srvRecord.port()).append(", ").append(srvRecord.priority()).append(", ").append(srvRecord.weight());
}
}
PagedList<TxtRecordSet> txtRecordSets = dnsZone.txtRecordSets().list();
info.append("\n\tTXT Record sets:");
for (TxtRecordSet txtRecordSet : txtRecordSets) {
info.append("\n\t\tId: ").append(txtRecordSet.id()).append("\n\t\tName: ").append(txtRecordSet.name()).append("\n\t\tTTL (seconds): ").append(txtRecordSet.timeToLive()).append("\n\t\tRecords: ");
for (TxtRecord txtRecord : txtRecordSet.records()) {
if (txtRecord.value().size() > 0) {
info.append("\n\t\t\tValue: ").append(txtRecord.value().get(0));
}
}
}
System.out.println(info.toString());
}
use of com.microsoft.azure.management.dns.SrvRecord in project azure-sdk-for-java by Azure.
the class TestDns method updateResource.
@Override
public DnsZone updateResource(DnsZone dnsZone) throws Exception {
dnsZone.update().withoutTxtRecordSet("www").withoutCNameRecordSet("userguide").withCNameRecordSet("help", "doc.contoso.com").updateNSRecordSet("partners").withoutNameServer("ns4-05.azure-dns.info").withNameServer("ns4-06.azure-dns.info").parent().updateARecordSet("www").withoutIPv4Address("23.96.104.40").withIPv4Address("23.96.104.42").parent().updateSrvRecordSet("_sip._tcp").withoutRecord("bigbox.contoso-service.com", 5060, 10, 60).withRecord("mainbox.contoso-service.com", 5060, 10, 60).parent().updateSoaRecord().withNegativeResponseCachingTimeToLiveInSeconds(600).withTimeToLive(7200).parent().defineMXRecordSet("email-internal").withMailExchange("mail.contoso-mail-exchange1.com", 1).withMailExchange("mail.contoso-mail-exchange2.com", 2).attach().apply();
// Check TXT records
PagedList<TxtRecordSet> txtRecordSets = dnsZone.txtRecordSets().list();
Assert.assertEquals(txtRecordSets.size(), 1);
// Check CNAME records
PagedList<CNameRecordSet> cnameRecordSets = dnsZone.cNameRecordSets().list();
Assert.assertEquals(cnameRecordSets.size(), 2);
for (CNameRecordSet cnameRecordSet : cnameRecordSets) {
Assert.assertTrue(cnameRecordSet.canonicalName().startsWith("doc.contoso.com"));
Assert.assertTrue(cnameRecordSet.name().startsWith("documents") || cnameRecordSet.name().startsWith("help"));
}
// Check NS records
PagedList<NSRecordSet> nsRecordSets = dnsZone.nsRecordSets().list();
// One created above with name 'partners' + the default '@'
Assert.assertTrue(nsRecordSets.size() == 2);
for (NSRecordSet nsRecordSet : nsRecordSets) {
Assert.assertTrue(nsRecordSet.name().startsWith("partners") || nsRecordSet.name().startsWith("@"));
if (nsRecordSet.name().startsWith("partners")) {
Assert.assertEquals(nsRecordSet.nameServers().size(), 4);
for (String nameServer : nsRecordSet.nameServers()) {
Assert.assertFalse(nameServer.startsWith("ns4-05.azure-dns.info"));
}
}
}
// Check A records
PagedList<ARecordSet> aRecordSets = dnsZone.aRecordSets().list();
Assert.assertEquals(aRecordSets.size(), 1);
ARecordSet aRecordSet = aRecordSets.get(0);
Assert.assertEquals(aRecordSet.ipv4Addresses().size(), 2);
for (String ipV4Address : aRecordSet.ipv4Addresses()) {
Assert.assertFalse(ipV4Address.startsWith("23.96.104.40"));
}
// Check SRV records
PagedList<SrvRecordSet> srvRecordSets = dnsZone.srvRecordSets().list();
Assert.assertTrue(srvRecordSets.size() == 1);
SrvRecordSet srvRecordSet = srvRecordSets.get(0);
Assert.assertTrue(srvRecordSet.records().size() == 4);
for (SrvRecord srvRecord : srvRecordSet.records()) {
Assert.assertFalse(srvRecord.target().startsWith("bigbox.contoso-service.com"));
}
// Check SOA Records
SoaRecordSet soaRecordSet = dnsZone.getSoaRecordSet();
Assert.assertTrue(soaRecordSet.name().startsWith("@"));
SoaRecord soaRecord = soaRecordSet.record();
Assert.assertNotNull(soaRecord);
Assert.assertEquals(soaRecord.minimumTtl(), Long.valueOf(600));
Assert.assertTrue(soaRecordSet.timeToLive() == 7200);
// Check MX records
PagedList<MXRecordSet> mxRecordSets = dnsZone.mxRecordSets().list();
Assert.assertTrue(mxRecordSets.size() == 2);
dnsZone.update().updateMXRecordSet("email").withoutMailExchange("mail.contoso-mail-exchange2.com", 2).withoutMetadata("mxa").withMetadata("mxc", "mxcc").withMetadata("mxd", "mxdd").parent().withTag("d", "dd").apply();
Assert.assertTrue(dnsZone.tags().size() == 3);
// Check "mail" MX record
MXRecordSet mxRecordSet = dnsZone.mxRecordSets().getByName("email");
Assert.assertTrue(mxRecordSet.records().size() == 1);
Assert.assertTrue(mxRecordSet.metadata().size() == 3);
Assert.assertTrue(mxRecordSet.records().get(0).exchange().startsWith("mail.contoso-mail-exchange1.com"));
return dnsZone;
}
use of com.microsoft.azure.management.dns.SrvRecord in project azure-sdk-for-java by Azure.
the class SrvRecordSetImpl method prepareForUpdate.
@Override
protected RecordSetInner prepareForUpdate(RecordSetInner resource) {
if (this.inner().srvRecords() != null && this.inner().srvRecords().size() > 0) {
if (resource.srvRecords() == null) {
resource.withSrvRecords(new ArrayList<SrvRecord>());
}
resource.srvRecords().addAll(this.inner().srvRecords());
this.inner().srvRecords().clear();
}
if (this.recordSetRemoveInfo.srvRecords().size() > 0) {
if (resource.srvRecords() != null) {
for (SrvRecord recordToRemove : this.recordSetRemoveInfo.srvRecords()) {
for (SrvRecord record : resource.srvRecords()) {
if (record.target().equalsIgnoreCase(recordToRemove.target()) && (record.port().intValue() == recordToRemove.port().intValue()) && (record.weight().intValue() == recordToRemove.weight().intValue()) && (record.priority().intValue() == recordToRemove.priority().intValue())) {
resource.srvRecords().remove(record);
break;
}
}
}
}
this.recordSetRemoveInfo.srvRecords().clear();
}
return resource;
}
use of com.microsoft.azure.management.dns.SrvRecord in project azure-sdk-for-java by Azure.
the class TestDns method print.
@Override
public void print(DnsZone dnsZone) {
StringBuilder info = new StringBuilder();
info.append("Dns Zone: ").append(dnsZone.id()).append("\n\tName (Top level domain): ").append(dnsZone.name()).append("\n\tResource group: ").append(dnsZone.resourceGroupName()).append("\n\tRegion: ").append(dnsZone.regionName()).append("\n\tTags: ").append(dnsZone.tags()).append("\n\tName servers:");
for (String nameServer : dnsZone.nameServers()) {
info.append("\n\t\t").append(nameServer);
}
SoaRecordSet soaRecordSet = dnsZone.getSoaRecordSet();
SoaRecord soaRecord = soaRecordSet.record();
info.append("\n\tSOA Record:").append("\n\t\tHost:").append(soaRecord.host()).append("\n\t\tEmail:").append(soaRecord.email()).append("\n\t\tExpire time (seconds):").append(soaRecord.expireTime()).append("\n\t\tRefresh time (seconds):").append(soaRecord.refreshTime()).append("\n\t\tRetry time (seconds):").append(soaRecord.retryTime()).append("\n\t\tNegative response cache ttl (seconds):").append(soaRecord.minimumTtl()).append("\n\t\tTTL (seconds):").append(soaRecordSet.timeToLive());
PagedList<ARecordSet> aRecordSets = dnsZone.aRecordSets().list();
info.append("\n\tA Record sets:");
for (ARecordSet aRecordSet : aRecordSets) {
info.append("\n\t\tId: ").append(aRecordSet.id()).append("\n\t\tName: ").append(aRecordSet.name()).append("\n\t\tTTL (seconds): ").append(aRecordSet.timeToLive()).append("\n\t\tIP v4 addresses: ");
for (String ipAddress : aRecordSet.ipv4Addresses()) {
info.append("\n\t\t\t").append(ipAddress);
}
}
PagedList<AaaaRecordSet> aaaaRecordSets = dnsZone.aaaaRecordSets().list();
info.append("\n\tAAAA Record sets:");
for (AaaaRecordSet aaaaRecordSet : aaaaRecordSets) {
info.append("\n\t\tId: ").append(aaaaRecordSet.id()).append("\n\t\tName: ").append(aaaaRecordSet.name()).append("\n\t\tTTL (seconds): ").append(aaaaRecordSet.timeToLive()).append("\n\t\tIP v6 addresses: ");
for (String ipAddress : aaaaRecordSet.ipv6Addresses()) {
info.append("\n\t\t\t").append(ipAddress);
}
}
PagedList<CNameRecordSet> cnameRecordSets = dnsZone.cNameRecordSets().list();
info.append("\n\tCNAME Record sets:");
for (CNameRecordSet cnameRecordSet : cnameRecordSets) {
info.append("\n\t\tId: ").append(cnameRecordSet.id()).append("\n\t\tName: ").append(cnameRecordSet.name()).append("\n\t\tTTL (seconds): ").append(cnameRecordSet.timeToLive()).append("\n\t\tCanonical name: ").append(cnameRecordSet.canonicalName());
}
PagedList<MXRecordSet> mxRecordSets = dnsZone.mxRecordSets().list();
info.append("\n\tMX Record sets:");
for (MXRecordSet mxRecordSet : mxRecordSets) {
info.append("\n\t\tId: ").append(mxRecordSet.id()).append("\n\t\tName: ").append(mxRecordSet.name()).append("\n\t\tTTL (seconds): ").append(mxRecordSet.timeToLive()).append("\n\t\tRecords: ");
for (MxRecord mxRecord : mxRecordSet.records()) {
info.append("\n\t\t\tExchange server, Preference: ").append(mxRecord.exchange()).append(" ").append(mxRecord.preference());
}
}
PagedList<NSRecordSet> nsRecordSets = dnsZone.nsRecordSets().list();
info.append("\n\tNS Record sets:");
for (NSRecordSet nsRecordSet : nsRecordSets) {
info.append("\n\t\tId: ").append(nsRecordSet.id()).append("\n\t\tName: ").append(nsRecordSet.name()).append("\n\t\tTTL (seconds): ").append(nsRecordSet.timeToLive()).append("\n\t\tName servers: ");
for (String nameServer : nsRecordSet.nameServers()) {
info.append("\n\t\t\t").append(nameServer);
}
}
PagedList<PtrRecordSet> ptrRecordSets = dnsZone.ptrRecordSets().list();
info.append("\n\tPTR Record sets:");
for (PtrRecordSet ptrRecordSet : ptrRecordSets) {
info.append("\n\t\tId: ").append(ptrRecordSet.id()).append("\n\t\tName: ").append(ptrRecordSet.name()).append("\n\t\tTTL (seconds): ").append(ptrRecordSet.timeToLive()).append("\n\t\tTarget domain names: ");
for (String domainNames : ptrRecordSet.targetDomainNames()) {
info.append("\n\t\t\t").append(domainNames);
}
}
PagedList<SrvRecordSet> srvRecordSets = dnsZone.srvRecordSets().list();
info.append("\n\tSRV Record sets:");
for (SrvRecordSet srvRecordSet : srvRecordSets) {
info.append("\n\t\tId: ").append(srvRecordSet.id()).append("\n\t\tName: ").append(srvRecordSet.name()).append("\n\t\tTTL (seconds): ").append(srvRecordSet.timeToLive()).append("\n\t\tRecords: ");
for (SrvRecord srvRecord : srvRecordSet.records()) {
info.append("\n\t\t\tTarget, Port, Priority, Weight: ").append(srvRecord.target()).append(", ").append(srvRecord.port()).append(", ").append(srvRecord.priority()).append(", ").append(srvRecord.weight());
}
}
PagedList<TxtRecordSet> txtRecordSets = dnsZone.txtRecordSets().list();
info.append("\n\tTXT Record sets:");
for (TxtRecordSet txtRecordSet : txtRecordSets) {
info.append("\n\t\tId: ").append(txtRecordSet.id()).append("\n\t\tName: ").append(txtRecordSet.name()).append("\n\t\tTTL (seconds): ").append(txtRecordSet.timeToLive()).append("\n\t\tRecords: ");
for (TxtRecord txtRecord : txtRecordSet.records()) {
if (txtRecord.value().size() > 0) {
info.append("\n\t\t\tValue: ").append(txtRecord.value().get(0));
}
}
}
System.out.println(info.toString());
}
Aggregations