got PATCH method working. Needs complicated input.

This commit is contained in:
2025-05-14 15:44:32 +02:00
parent fe1077bfce
commit 33cbbc0373
3 changed files with 82 additions and 13 deletions

View File

@ -2,14 +2,57 @@
# import requests # unused for now
from pdnsapi import PdnsRestAdapter
# import json
import datetime
api = PdnsRestAdapter('localhost:8081/', 'pdns-supersecret')
# test1.nhn.no zone must exist for this to work
output = api.get('servers/localhost/zones/test1.nhn.no')
print("GET zones/test1.nhn.no:")
print(f"{output}")
print()
# NOTE: doesn't work yet. Maybe wrong arguments?
# api.post('servers/localhost/zones/test1.nhn.no/test.txt', {'type': 'A'}, {'type': 'A'})
# NOTE: this one puts two records into powerdns
input = {
"rrsets": [
{
"name": "test.test1.nhn.no.",
"type": "TXT",
"ttl": 60,
"changetype": "REPLACE",
"records": [
{
"content": f'"tester tekst-record {datetime.datetime.now().strftime('%d.%m.%Y %H:%M')}"',
"disabled": False,
"name": "test.test1.nhn.no",
"ttl": 60,
"type": "TXT"
}
]
},
{
"name": "testa.test1.nhn.no.",
"type": "A",
"ttl": 60,
"changetype": "REPLACE",
"records": [
{
"content": "127.0.0.1",
"disabled": False,
"name": "test.test1.nhn.no",
"ttl": 60,
"type": "A"
}
]
}
]
}
api.patch('servers/localhost/zones/test1.nhn.no', {}, input)
print("PATCH doesn't have output per now, should it? If you can see this it worked.")
# copy of error message:
# Traceback (most recent call last):