Delete records
This commit is contained in:
parent
52bd8b34b3
commit
df936baa8f
5 changed files with 167 additions and 23 deletions
|
|
@ -58,7 +58,7 @@ func (dev *RouterosDevice) Init() { // {{{
|
|||
|
||||
// query sends a RouterOS REST API query and returns the unparsed body.
|
||||
func (dev RouterosDevice) query(method, path string, reqBody []byte) (body []byte, err error) { // {{{
|
||||
url := fmt.Sprintf("https://%s/rest%s", dev.Host, path)
|
||||
url := fmt.Sprintf("https://%s:%d/rest%s", dev.Host, dev.Port, path)
|
||||
logger.Info("URL", "method", method, "url", url)
|
||||
|
||||
var request *http.Request
|
||||
|
|
@ -150,6 +150,19 @@ func (dev *RouterosDevice) UpdateDNSEntry(record DNSEntry) (entry DNSEntry, err
|
|||
err = json.Unmarshal(body, &entry)
|
||||
return
|
||||
}// }}}
|
||||
func (dev *RouterosDevice) DeleteDNSEntry(id string) (err error) {
|
||||
_, err = dev.query("DELETE", "/ip/dns/static/"+id, []byte{})
|
||||
if err != nil {
|
||||
rosError := struct{ Detail string }{}
|
||||
if jsonError := json.Unmarshal([]byte(err.Error()), &rosError); jsonError == nil {
|
||||
logger.Error("routeros", "error", jsonError)
|
||||
err = errors.New(rosError.Detail)
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
/*
|
||||
// FillPeerDetails retrieves RouterOS resource ID, allowed-address and comment from the router
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue