// GetDomainRecords queries Digital Ocean API for DNS records for a particular domain
GetDomainRecords queries Digital Ocean API for DNS records for a particular domain
// GetDomainRecords queries Digital Ocean API for DNS records for a particular domain
func GetDomainRecords(domain string, token string) ([]DomainRecord, error) {
	client := &http.Client{}
	req, err := http.NewRequest(
		"GET",
		"https://api.digitalocean.com/v2/domains/"+domain+"/records",
		nil,
	)
	if err != nil {
		return nil, err
	}
	req.Header.Add("Authorization", "Bearer "+token)
	req.Header.Add("Content-Type", "application/json")
	res, err := client.Do(req)
	if err != nil {
		return nil, err
	}
	defer res.Body.Close()
	body, err := ioutil.ReadAll(res.Body)
	if err != nil {
		return nil, err
	}
	var domainRecordsResponse DomainRecordResponse
	if err = json.Unmarshal(body, &domainRecordsResponse); err != nil {
		return nil, err
	}
	return domainRecordsResponse.DomainRecords, nil
}
func GetDomainRecords ( domain string , token string ) ( [ ] DomainRecord , error ) { client := & http . Client { } req , err := http . NewRequest ( " " , " " + domain + " " , nil , ) if err != nil { return nil , err } req . Header . Add ( " " , " " + token ) req . Header . Add ( " " , " " ) res , err := client . Do ( req ) if err != nil { return nil , err } defer res . Body . Close ( ) body , err := ioutil . ReadAll ( res . Body ) if err != nil { return nil , err } var domainRecordsResponse DomainRecordResponse if err = json . Unmarshal ( body , & domainRecordsResponse ) ; err != nil { return nil , err } return domainRecordsResponse . DomainRecords , nil }
GetDomainRecords queries Digital Ocean API for DNS records for a particular domain
GetDomainRecords queries Digital Ocean API for DNS records for a particular domain