Delete managed DNS record
D1StrX opened this issue · 2 comments
Describe the bug
With a post REST API call I was able to create a dns record, with managed: true
. Problem is that I cannot delete it through the GUI or a Delete REST call. Is it possible to make this more rigid against mistakes like this? And is there a way to delete managed records?
Expected result
Error Status 400, cannot create a DNS record with managed: true
.
Actual result
Status 201
Code Examples
If really needed I will send some snippets.
Wow - creative :-)
Actually it shouldn't have been possible to create a managed record like this, although obviously nothing kept the API from doing so. I must think a bit about this, but I'm fairly certain the most straightforward solution is to disallow the API from creating managed records directly.
As for the problem of getting rid of the record you created: Have you tried to set it to managed: False
using the API and then deleting it? By the way, that's also an operation that is supposed to be forbidden but probably isn't. [Update: It is]
If that doesn't work, just determine the ID of the record you created and use nbshell
like this (assuming the ID is 42, substitute the one you found for that value):
/opt/netbox/venv/bin/python3 /opt/netbox/netbox/manage.py nbshell
>>> from netbox_dns.models import Record
>>> Record.objects.get(pk=42).delete()
>>> quit()
OK, here's the result:
- It is possible to create a managed record via the API
- It is not possible to set a record to unmanaged via the API
- It is not possible to delete a managed record via the API
- It is, however, possible to set an unmanaged record to managed via the API
1 and 4 are definitely bugs and need to be fixed.