got PATCH method working. Needs complicated input.
This commit is contained in:
47
testapi.py
47
testapi.py
@ -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):
|
||||
|
Reference in New Issue
Block a user