// GetDNSRecords returns a list of all DNS records of a particular domain
19431
func (c *Client) GetDNSRecords(domain string) (records []DNSRecord, err error) {
	if err := c.get(`dns/records?domain=`+domain, &records); err != nil {
		return nil, err
	}
	sort.Sort(dnsrecords(records))
	return records, nil
}
707657
func (c *Client) GetRecords(domain string) ([]Record, error) {
	req, err := c.NewRequest(nil, "GET", "/domains/"+domain+"/records")
	if err != nil {
		return nil, err
	}
	resp, err := c.Http.Do(req)
	if err != nil {
		return nil, err
	}
	defer resp.Body.Close()
	recordResponses := make([]RecordResponse, 10)
	err = decode(resp.Body, &recordResponses)
	if err != nil {
		return nil, err
	}
	records := make([]Record, len(recordResponses))
	for i, rr := range recordResponses {
		records[i] = rr.Record
	}
	return records, nil
}
1285734
func (gen *RuleGen) GetDNSNames() (dnsNames []string) {
	gen.Lock()
	defer gen.Unlock()

	for name := range gen.namesToPoll {
		dnsNames = append(dnsNames, name)
	}

	return dnsNames
}
386472
func (d *DNSRecordSets) AddDNSRecordSet(name string, ip string) {
	var record DNSRecordSet
	var isExist = false
	for i := range d.ResourceRecordSets {
		if d.ResourceRecordSets[i].Name == name && d.ResourceRecordSets[i].Type == "A" {
			d.ResourceRecordSets[i].RData = ip
			isExist = true
		}
	}

	if !isExist {
		record = DNSRecordSet{
			// Name
			Name: name,
			// Type
			Type: "A",
			// RData
			RData: ip,
		}
		d.ResourceRecordSets = append(d.ResourceRecordSets, record)
	}
}
445674
func (c *Client) DeleteDNSRecord(domain string, recordID int) error {
	values := url.Values{
		"domain":   {domain},
		"RECORDID": {fmt.Sprintf("%v", recordID)},
	}

	if err := c.post(`dns/delete_record`, values, nil); err != nil {
		return err
	}
	return nil
}
458272
func getRecordsByName(client *godo.Client, zoneName, recordName string) ([]godo.DomainRecord, error) {
	records, err := getRecords(client, zoneName)
	if err != nil {
		return nil, err
	}

	// digitalocean record.Name returns record without the zone suffix
	// so normalize record by removing it
	normalizedRecordName := strings.TrimSuffix(recordName, ".")
	normalizedRecordName = strings.TrimSuffix(normalizedRecordName, "."+zoneName)

	var recordsByName []godo.DomainRecord
	for _, record := range records {
		if record.Name == normalizedRecordName {
			recordsByName = append(recordsByName, record)
		}
	}

	return recordsByName, nil
}
233548
func (_class SubjectClass) GetAllRecords(sessionID SessionRef) (_retval map[SubjectRef]SubjectRecord, _err error) {
	_method := "subject.get_all_records"
	_sessionIDArg, _err := convertSessionRefToXen(fmt.Sprintf("%s(%s)", _method, "session_id"), sessionID)
	if _err != nil {
		return
	}
	_result, _err := _class.client.APICall(_method, _sessionIDArg)
	if _err != nil {
		return
	}
	_retval, _err = convertSubjectRefToSubjectRecordMapToGo(_method + " -> ", _result.Value)
	return
}
1200386
func (c *collectorImpl) GetUserRecords() map[string]*collector.UserRecord {
	c.Lock()
	defer c.Unlock()

	if len(c.Users) == 0 {
		return nil
	}

	retval := c.Users
	c.Users = map[string]*collector.UserRecord{}
	return retval
}
607142
func (_class TunnelClass) GetAllRecords(sessionID SessionRef) (_retval map[TunnelRef]TunnelRecord, _err error) {
	_method := "tunnel.get_all_records"
	_sessionIDArg, _err := convertSessionRefToXen(fmt.Sprintf("%s(%s)", _method, "session_id"), sessionID)
	if _err != nil {
		return
	}
	_result, _err := _class.client.APICall(_method, _sessionIDArg)
	if _err != nil {
		return
	}
	_retval, _err = convertTunnelRefToTunnelRecordMapToGo(_method + " -> ", _result.Value)
	return
}
1099016
func (_class PVSServerClass) GetAllRecords(sessionID SessionRef) (_retval map[PVSServerRef]PVSServerRecord, _err error) {
	_method := "PVS_server.get_all_records"
	_sessionIDArg, _err := convertSessionRefToXen(fmt.Sprintf("%s(%s)", _method, "session_id"), sessionID)
	if _err != nil {
		return
	}
	_result, _err := _class.client.APICall(_method, _sessionIDArg)
	if _err != nil {
		return
	}
	_retval, _err = convertPVSServerRefToPVSServerRecordMapToGo(_method + " -> ", _result.Value)
	return
}
918611
func DNSServers(dnss []net.IP) func(*Server) error {
	return func(s *Server) error {
		s.dnsServers = dnss
		return nil
	}
}
538811
func (r *resourceRecordSets) List() ([]dnsprovider.ResourceRecordSet, error) {
	snapshot := r.zone.dnsView.Snapshot()

	records := snapshot.RecordsForZone(r.zone.zoneInfo)
	if records == nil {
		return nil, nil
	}

	var rrs []dnsprovider.ResourceRecordSet
	for _, rr := range records {
		rrs = append(rrs, &resourceRecordSet{data: rr})
	}
	return rrs, nil
}
77934
func (api *MobileGatewayAPI) GetDNS(id int64) (*sacloud.MobileGatewayResolver, error) {
	var (
		method = "GET"
		uri    = fmt.Sprintf("%s/%d/mobilegateway/dnsresolver", api.getResourceURL(), id)
	)

	data, err := api.client.newRequest(method, uri, nil)
	if err != nil {
		return nil, err
	}
	var res sacloud.MobileGatewayResolver
	if err := json.Unmarshal(data, &res); err != nil {
		return nil, err
	}
	return &res, err
}
83727
func (api *API) DNSRecords(zoneID string, rr DNSRecord) ([]DNSRecord, error) {
	// Construct a query string
	v := url.Values{}
	// Request as many records as possible per page - API max is 50
	v.Set("per_page", "50")
	if rr.Name != "" {
		v.Set("name", rr.Name)
	}
	if rr.Type != "" {
		v.Set("type", rr.Type)
	}
	if rr.Content != "" {
		v.Set("content", rr.Content)
	}

	var query string
	var records []DNSRecord
	page := 1

	// Loop over makeRequest until what we've fetched all records
	for {
		v.Set("page", strconv.Itoa(page))
		query = "?" + v.Encode()
		uri := "/zones/" + zoneID + "/dns_records" + query
		res, err := api.makeRequest("GET", uri, nil)
		if err != nil {
			return []DNSRecord{}, errors.Wrap(err, errMakeRequestError)
		}
		var r DNSListResponse
		err = json.Unmarshal(res, &r)
		if err != nil {
			return []DNSRecord{}, errors.Wrap(err, errUnmarshalError)
		}
		records = append(records, r.Result...)
		if r.ResultInfo.Page >= r.ResultInfo.TotalPages {
			break
		}
		// Loop around and fetch the next page
		page++
	}
	return records, nil
}
1033124
func (api *DNSAPI) DeleteDNSRecord(zoneName string, hostName string, ip string) error {
	dnsItem, err := api.findOrCreateBy(zoneName)
	if err != nil {
		return err
	}
	dnsItem.Settings.DNS.DeleteDNSRecordSet(hostName, ip)

	if dnsItem.HasDNSRecord() {
		_, err = api.updateDNSRecord(dnsItem)
		if err != nil {
			return err
		}

	} else {
		_, err = api.Delete(dnsItem.ID)
		if err != nil {
			return err
		}

	}
	return nil
}
1162283
func (r *resourceRecordSets) Get(name string) ([]dnsprovider.ResourceRecordSet, error) {
	records, err := r.List()
	if err != nil {
		return nil, err
	}

	var recordSets []dnsprovider.ResourceRecordSet
	for _, record := range records {
		if record.Name() == name {
			recordSets = append(recordSets, record)
		}
	}

	return recordSets, nil
}
492058
func (client *AuroraDNSClient) GetRecords(zoneID string) ([]records.GetRecordsResponse, error) {
	logrus.Debugf("GetRecords(%s)", zoneID)
	relativeURL := fmt.Sprintf("zones/%s/records", zoneID)

	response, err := client.requestor.Request(relativeURL, "GET", []byte(""))
	if err != nil {
		logrus.Errorf("Failed to receive records: %s", err)
		return nil, err
	}

	var respData []records.GetRecordsResponse
	err = json.Unmarshal(response, &respData)
	if err != nil {
		logrus.Errorf("Failed to unmarshall response: %s", err)
		return nil, err
	}

	return respData, nil
}