/// <summary> /// Add Aliyun DNS Record /// </summary> /// <param name="domainName"> Domain name </param> /// <param name="rr"> @.exmaple.com => @ </param> /// <param name="type"> A/NS/MX/TXT/CNAME/SRV/AAAA/CAA/REDIRECT_URL/FORWARD_URL </param> /// <param name="value"> Value </param> /// <param name="ttl"> Default 600 sec </param> /// <param name="priority"> Default 0(1-10 when type is MX) </param> /// <param name="line"> default </param> /// <returns> </returns> private async Task <DomainRecord> AddDomainRecord(string domainName, string rr, RecordType type, string value, long ttl = 600, long priority = 0, string line = "default") { var parameters = new Dictionary <string, string> { { "Action", "AddDomainRecord" }, { "DomainName", domainName }, { "RR", rr }, { "Type", type.ToString() }, { "Value", value }, { "TTL", ttl.ToString() }, { "Line", line } }; if (type == RecordType.MX) { if (priority < 1 || priority > 10) { throw new Exception("priority must in 1 to 10 when type is MX"); } parameters.Add("Priority", priority.ToString()); } var request = new AliDnsRequest(HttpMethod.Get, _accessKeyId, _accessKeySecret, parameters); var url = request.GetUrl(); using (var httpClient = new HttpClient()) { var response = await httpClient.GetAsync(url); var content = await response.Content.ReadAsStringAsync(); return(JsonConvert.DeserializeObject <DomainRecord>(content)); } }
private async Task <DomainRecord> DeleteDomainRecord(string recordId) { var parameters = new Dictionary <string, string> { { "Action", "DeleteDomainRecord" }, { "RecordId", recordId } }; var request = new AliDnsRequest(HttpMethod.Get, _accessKeyId, _accessKeySecret, parameters); var url = request.GetUrl(); using (var httpClient = new HttpClient()) { var response = await httpClient.GetAsync(url); var content = await response.Content.ReadAsStringAsync(); return(JsonConvert.DeserializeObject <DomainRecord>(content)); } }
private async Task <DescribeDomainsResponse> GetDomains(int pageNumber = 1, int pageSize = 20) { var parameters = new Dictionary <string, string>() { { "Action", "DescribeDomains" }, { "PageNumber", pageNumber.ToString() }, { "PageSize", pageSize.ToString() } }; var request = new AliDnsRequest(HttpMethod.Get, _accessKeyId, _accessKeySecret, parameters); var url = request.GetUrl(); using (var httpClient = new HttpClient()) { var response = await httpClient.GetAsync(url); var content = await response.Content.ReadAsStringAsync(); return(JsonConvert.DeserializeObject <DescribeDomainsResponse>(content)); } }