Create new records
This commit is contained in:
parent
7d7c0c9570
commit
3763367510
6 changed files with 117 additions and 19 deletions
|
|
@ -106,7 +106,7 @@ func (dev *RouterosDevice) GetIdentity() (identity string, err error) { // {{{
|
|||
return
|
||||
} // }}}
|
||||
|
||||
func (dev *RouterosDevice) StaticDNSEntries() (records []DNSRecord, err error) {
|
||||
func (dev *RouterosDevice) StaticDNSEntries() (records []DNSRecord, err error) {// {{{
|
||||
records = []DNSRecord{}
|
||||
|
||||
var routerosEntries []DNSEntry
|
||||
|
|
@ -127,11 +127,16 @@ func (dev *RouterosDevice) StaticDNSEntries() (records []DNSRecord, err error) {
|
|||
logger.Info("FOO", "entry", records)
|
||||
|
||||
return
|
||||
}
|
||||
func (dev *RouterosDevice) UpdateDNSEntry(record DNSEntry) (err error) {
|
||||
}// }}}
|
||||
func (dev *RouterosDevice) UpdateDNSEntry(record DNSEntry) (entry DNSEntry, err error) {// {{{
|
||||
req, _ := json.Marshal(record)
|
||||
|
||||
_, err = dev.query("PATCH", "/ip/dns/static/"+record.ID, req)
|
||||
var body []byte
|
||||
if record.ID == "" {
|
||||
body, err = dev.query("PUT", "/ip/dns/static", req)
|
||||
} else {
|
||||
body, err = dev.query("PATCH", "/ip/dns/static/"+record.ID, req)
|
||||
}
|
||||
if err != nil {
|
||||
rosError := struct{ Detail string }{}
|
||||
if jsonError := json.Unmarshal([]byte(err.Error()), &rosError); jsonError == nil {
|
||||
|
|
@ -142,8 +147,9 @@ func (dev *RouterosDevice) UpdateDNSEntry(record DNSEntry) (err error) {
|
|||
return
|
||||
}
|
||||
|
||||
err = json.Unmarshal(body, &entry)
|
||||
return
|
||||
}
|
||||
}// }}}
|
||||
|
||||
/*
|
||||
// FillPeerDetails retrieves RouterOS resource ID, allowed-address and comment from the router
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue