The SimpleDNS REST Client is designed to abstract the SimpleDNS HTTP API and present the developer with a simplified and strongly typed implementation. Much of the underlying mechanics have therefore purposefully been abstracted behind private modifiers.
Both RestSharp and Newtonsoft.Json are required dependencies.
The client has been tested up to version 8 build 108 of SimpleDNS. Version 9 brings breaking changes which may prevent the client from retrieving or updating SimpleDNS settings.
string adminUrl = "https://localhost/v2";
string adminUsername = "admin";
string adminPassword = "password";
SimpleDnsManager simpleDns = new SimpleDnsManager(
adminUrl, AuthenticationMode.Digest,
adminUsername, adminPassword, true);
string zoneDomain = "domain.text";
string recordFqdn = "www.domain.text";
string recordIpAddress = "198.51.100.3";
simpleDns.PatchZoneRecords(zoneDomain, new List<ZoneRecord> {
new ZoneRecord {
Name = recordFqdn,
Type = RecordType.A,
Data = recordIpAddress,
Ttl = 14400 }
});
string zoneDomain = "domain.text";
string recordFqdn = "www.domain.text";
List<ZoneRecord> zoneRecords = simpleDns.GetZoneRecords(zoneDomain);
ZoneRecord zoneRecord = zoneRecords.Find(z => z.Name == recordFqdn);
if (zoneRecord != null)
simpleDns.PatchZoneRecords(zoneDomain, new List<ZoneRecord> {
new ZoneRecord {
Name = recordFqdn,
Remove = true }
});
var options = simpleDns.GetOptions();
options.DnsCacheReload = false;
simpleDns.PatchOptions(options);