// CreateRecord Method to create a DNS record
514242
func (c *ConvenientClient) CreateRecord(record *Record) error {
	if record.FQDN == "" && record.Name == "" {
		record.FQDN = record.Zone
	} else if record.FQDN == "" {
		record.FQDN = fmt.Sprintf("%s.%s", record.Name, record.Zone)
	}
	rdata, err := buildRData(record)
	if err != nil {
		return fmt.Errorf("Failed to create Dyn RData: %s", err)
	}
	url := fmt.Sprintf("%sRecord/%s/%s", record.Type, record.Zone, record.FQDN)
	data := &RecordRequest{
		RData: rdata,
		TTL:   record.TTL,
	}
	return c.Do("POST", url, data, nil)
}
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
}
1116328
func (self *Record) Add(args RecordAdd) (*RecordInfo, error) {
	var res map[string]interface{}
	createArgs := map[string]interface{}{
		"name":  args.Name,
		"type":  args.Type,
		"value": args.Value,
		"ttl":   args.Ttl,
	}

	params := []interface{}{self.Key, args.Zone, args.Version, createArgs}
	if err := self.Call("domain.zone.record.add", params, &res); err != nil {
		return nil, err
	}
	return ToRecordInfo(res), nil
}
274028
func MakeEmptyRecord(recordID string) (record *Record, err error) {
	err = CheckRecordID(recordID)
	if err != nil {
		return
	}

	record = &Record{
		RecordID: recordID,
		Data:     map[string]interface{}{},
	}
	return
}
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
}
420993
func (c *Client) ReadRecord(domainID string, recordID string) (*Record, error) {
	body := bytes.NewBuffer(nil)
	path := retrieve.endpoint(domainID, recordID)
	req, err := c.NewRequest("GET", path, body, "")
	if err != nil {
		return nil, err
	}

	resp, err := checkResp(c.HTTP.Do(req))
	if err != nil {
		return nil, fmt.Errorf("Error retrieving record: %s", err)
	}

	dataResp := DataResponse{}
	err = decodeBody(resp, &dataResp)
	if err != nil {
		return nil, fmt.Errorf("Error decoding data response: %s", err)
	}
	var result Record
	var found bool
	for _, record := range dataResp.Data {
		if record.StringRecordID() == recordID {
			result = record // not pointer, so data copied
			found = true
			break
		}
	}

	if !found {
		return nil, fmt.Errorf("Unable to find record %s", recordID)
	}
	return &result, nil
}
109876
func (mr *MockServiceInterfaceMockRecorder) Create(arg0 interface{}) *gomock.Call {
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Create", reflect.TypeOf((*MockServiceInterface)(nil).Create), arg0)
}
1193966
func (api *Client) CreateRecordingTranscription(id string) (string, error) {
	_, headers, err := api.makeRequest(http.MethodPost, fmt.Sprintf("%s/%s/%s", api.concatUserPath(recordingsPath), id, transcriptionsPath))
	if err != nil {
		return "", err
	}
	return getIDFromLocationHeader(headers), nil
}
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)
	}
}
879456
func (s *DomainsService) GetRecord(domain string, recordID string) (Record, *Response, error) {
	path := recordAction("Info")

	payload := newPayLoad(s.client.CommonParams)

	payload.Add("domain_id", domain)
	payload.Add("record_id", recordID)

	returnedRecord := recordWrapper{}

	res, err := s.client.post(path, payload, &returnedRecord)
	if err != nil {
		return Record{}, res, err
	}

	if returnedRecord.Status.Code != "1" {
		return returnedRecord.Record, nil, fmt.Errorf("Could not get domains: %s", returnedRecord.Status.Message)
	}

	return returnedRecord.Record, res, nil
}
87316
func (client *Client) GetRecords(ctx context.Context, domain string) ([]DNSRecord, error) {
	resp, err := client.dnsRequest(ctx, "/v1/domains/"+domain+"/records", nil, "", "GET")
	if err != nil {
		return nil, err
	}

	var r []DNSRecordResponse
	if err = json.Unmarshal(resp, &r); err != nil {
		return nil, err
	}

	records := make([]DNSRecord, 0, len(r))
	for _, rec := range r {
		records = append(records, rec.Record)
	}

	return records, nil
}
1037183
func (s *session) AddRecord(key string, member interface{}, unixstamp int64) error {
	action, err := s.addRecord(key, member, unixstamp)
	if err != nil {
		return s.catch("AddRecord: "+action, err)
	}
	return nil
}
1201670
func (c *Client) UpdateRecord(domainID string, recordID string, cr map[string]interface{}) (string, error) {

	current, err := c.ReadRecord(domainID, recordID)
	if err != nil {
		return "", err
	}

	err = mergo.Map(current, cr)
	if err != nil {
		return "", err
	}

	buf := bytes.NewBuffer(nil)
	enc := json.NewEncoder(buf)
	if err := enc.Encode(current); err != nil {
		return "", err
	}

	path := update.endpoint(domainID, recordID)
	req, err := c.NewRequest("PUT", path, buf, "")
	if err != nil {
		return "", err
	}

	_, err = checkResp(c.HTTP.Do(req))
	if err != nil {
		return "", fmt.Errorf("Error updating record: %s", err)
	}

	// The request was successful
	return recordID, nil
}
942362
func (d *DNS) CreateNewMXRecord(name string, rdata string, ttl int, priority int) *DNSRecordSet {
	if rdata != "" && !strings.HasSuffix(rdata, ".") {
		rdata = rdata + "."
	}
	return &DNSRecordSet{
		// Name
		Name: name,
		// Type
		Type: "MX",
		// RData
		RData: fmt.Sprintf("%d %s", priority, rdata),
		// TTL
		TTL: ttl,
	}
}
473497
func (s *TemplatesService) CreateTemplateRecord(accountID string, templateIdentifier string, templateRecordAttributes TemplateRecord) (*templateRecordResponse, error) {
	path := versioned(templateRecordPath(accountID, templateIdentifier, 0))
	templateRecordResponse := &templateRecordResponse{}

	resp, err := s.client.post(path, templateRecordAttributes, templateRecordResponse)
	if err != nil {
		return nil, err
	}

	templateRecordResponse.HttpResponse = resp
	return templateRecordResponse, nil
}
1099098
func (records *Records) Create(ctx context.Context, record *Record) (err error) {
	buffer := new(bytes.Buffer)
	err = json.NewEncoder(buffer).Encode(record)
	if err != nil {
		return
	}
	response, err := httpDo(ctx, records.Options, "POST", apiURL("/zones/%s/dns_records", record.ZoneID), buffer)
	if err != nil {
		return
	}
	defer response.Body.Close()
	result, err := readResponse(response.Body)
	if err != nil {
		return
	}
	res := new(Record)
	err = json.Unmarshal(result.Result, &res)
	if err != nil {
		return
	}
	record.ID = res.ID
	record.TTL = res.TTL
	record.Locked = res.Locked
	record.Proxied = res.Proxied
	record.Proxiable = res.Proxiable
	record.CreatedOn = res.CreatedOn
	record.ModifiedOn = res.ModifiedOn
	return
}
1306489
func GetDNSRecordIdx(records []DNSRecord, record DNSRecord) (int, error) {
	for index, element := range records {
		if record.Destination == element.Destination && record.RecordType == element.RecordType {
			return index, nil
		}
	}
	return -1, fmt.Errorf("no DNS Record found")
}