* main.py -status command gets SOA record * main.py -push command broken (API returns 405) * dsc.py general connection to API works
28 lines
1.1 KiB
Python
28 lines
1.1 KiB
Python
from __future__ import print_function
|
|
import time
|
|
import powerdns_client
|
|
from powerdns_client.rest import ApiException
|
|
from pprint import pprint
|
|
from decouple import config
|
|
|
|
# Configure API key authorization: APIKeyHeader
|
|
configuration = powerdns_client.Configuration()
|
|
print(f"{configuration.host=}")
|
|
configuration.host = config('PDNS_SERVER', default='https://localhost') + '/api/v1'
|
|
print(f"{configuration.host=}")
|
|
configuration.api_key['X-API-Key'] = config('PDNS_APIKEY', default='YOUR_API_KEY')
|
|
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
|
|
# configuration.api_key_prefix['X-API-Key'] = 'Bearer'
|
|
|
|
# create an instance of the API class
|
|
api_instance = powerdns_client.ConfigApi(powerdns_client.ApiClient(configuration))
|
|
# server_id = 'server_id_example' # str | The id of the server to retrieve
|
|
server_id = 'localhost'
|
|
|
|
try:
|
|
# Returns all ConfigSettings for a single server
|
|
api_response = api_instance.get_config(server_id)
|
|
# pprint(api_response)
|
|
except ApiException as e:
|
|
print("Exception when calling ConfigApi->get_config: %s\n" % e)
|