{"id":13929842,"url":"https://github.com/outini/python-powerdns","last_synced_at":"2025-08-08T06:32:24.854Z","repository":{"id":46020780,"uuid":"214998717","full_name":"outini/python-powerdns","owner":"outini","description":"PowerDNS web api python client and interface","archived":false,"fork":false,"pushed_at":"2023-08-31T09:11:23.000Z","size":314,"stargazers_count":38,"open_issues_count":9,"forks_count":17,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-12-01T10:37:45.073Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/outini.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2019-10-14T09:13:08.000Z","updated_at":"2024-11-11T16:58:19.000Z","dependencies_parsed_at":"2024-01-17T05:24:33.740Z","dependency_job_id":"223870a4-33df-4f05-bb04-253761289d90","html_url":"https://github.com/outini/python-powerdns","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/outini%2Fpython-powerdns","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/outini%2Fpython-powerdns/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/outini%2Fpython-powerdns/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/outini%2Fpython-powerdns/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/outini","download_url":"https://codeload.github.com/outini/python-powerdns/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":229097388,"owners_count":18019735,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-07T18:02:35.217Z","updated_at":"2024-12-10T16:55:09.800Z","avatar_url":"https://github.com/outini.png","language":"Python","funding_links":[],"categories":["others"],"sub_categories":[],"readme":"[![PythonSupport][1]][1l] [![License][2]][2l] [![PyPI version][3]][3l]\n\n# python-powerdns -- PowerDNS web api python client and interface\n\n**Contact:** Denis 'jawa' Pompilio \u003cdenis.pompilio@gmail.com\u003e\n\n**Sources:** \u003chttps://github.com/outini/python-powerdns\u003e\n\n## About\n\nThis package provides intuitive and easy to use python client and interface\nfor the PowerDNS web API.\n\n## Installation\n\n```bash\npython setup.py install\n```\n\nor\n\n```bash\npip install python-powerdns\n```\n\n## Helpers\n\n### pdns-zone-creator\n\n```bash\nusage: pdns-create-zone [-h] -A API -K APIKEY -z ZONE -o ORIGIN -c ZONE -d DNS\n                        [-t TIMERS]\n\nPowerDNS zone creator\n\noptional arguments:\n  -h, --help            show this help message and exit\n  -A API, --api API     PowerDNS api (eg. https://api.domain.tld/api/v1\n  -K APIKEY, --key APIKEY\n                        PowerDNS api key\n  -z ZONE, --zone ZONE  Zone name (canonical)\n  -o ORIGIN, --origin ORIGIN\n                        Zone origin (for SOA)\n  -c ZONE, --contact ZONE\n                        Zone contact (for SOA)\n  -d DNS, --dns DNS     Zone nameservers comma separated\n  -t TIMERS, --timers TIMERS\n                        Zone timers (eg. '28800 7200 604800 86400')\n```\n\n```bash\n./bin/pdns-create-zone -A \"https://api.domain.tld/api/v1\" -K \"xxxxxxxxx\" \\\n                       -z \"myzone.domain.tld.\" \\\n                       -o \"ns01.domain.tld.\" -c \"admin.domain.tld.\" \\\n                       -d \"nsd01.domain.tld.,nsd02.domain.tld.\"\npowerdns.interface INFO: listing available PowerDNS servers\npowerdns.interface INFO: getting available servers from API\npowerdns.client INFO: request: GET https://api.domain.tld/api/v1/servers\npowerdns.client INFO: request response code: 200\npowerdns.interface INFO: 1 server(s) listed\npowerdns.interface INFO: creation of zone: myzone.domain.tld.\npowerdns.client INFO: request: POST https://api.domain.tld/api/v1/servers/localhost/zones\npowerdns.client INFO: request response code: 201\npowerdns.interface INFO: zone myzone.domain.tld. successfully created\n```\n\n## Examples\n\n### Basic initialization\n\n```python\nimport powerdns\n\nPDNS_API = \"https://my.pdns.api.domain.tld/api/v1\"\nPDNS_KEY = \"mysupersecretbase64key\"\n\napi_client = powerdns.PDNSApiClient(api_endpoint=PDNS_API, api_key=PDNS_KEY)\napi = powerdns.PDNSEndpoint(api_client)\n```\n\n### Creation and deletion of zones\n\n```python\nfrom datetime import date\n\n# Creating new zone on first PowerDNS server\nserial = date.today().strftime(\"%Y%m%d00\")\nsoa = \"ns0.domain.tld. admin.domain.tld. %s 28800 7200 604800 86400\" % serial\nsoa_r = powerdns.RRSet(name='test.python-powerdns.domain.tld.',\n                       rtype=\"SOA\",\n                       records=[(soa, False)],\n                       ttl=86400)\nzone = api.servers[0].create_zone(name=\"test.python-powerdns.domain.tld.\",\n                                  kind=\"Native\",\n                                  rrsets=[soa_r],\n                                  nameservers=[\"ns1.domain.tld.\",\n                                               \"ns2.domain.tld.\"])\n\n# Getting new zone info\nprint(zone)\nprint(zone.details)\n\n# Deleting newly created zone\napi.servers[0].delete_zone(zone.name)\n```\n\n### Creation and deletion of DNS records\n\n```python\nzone = api.servers[0].get_zone(\"test.python-powerdns.domain.tld.\")\n\ncomments = [powerdns.Comment(\"test comment\", \"admin\")]\n\nzone.create_records([\n    powerdns.RRSet('a', 'A', [('1.1.1.1', False)], comments=comments),\n    powerdns.RRSet('b', 'A', ['1.1.1.2', '1.1.1.3']),\n    powerdns.RRSet('c', 'A', [('1.1.1.4', False)]),\n    powerdns.RRSet('d', 'CNAME', ['a'])\n])\n\nzone.delete_records([\n    powerdns.RRSet('a', 'A', [('1.1.1.1', False)]),\n    powerdns.RRSet('d', 'CNAME', ['a'])\n])\n```\n\nWhere (for the first RRSet):\n\n* `a` is the NAME of the record\n* `A` is the TYPE of the record\n* `[('1.1.1.1', False)]` is a list of RDATA entries (tuples or just strings), where:\n  * `'1.1.1.1'` is the RDATA\n  * `False` tells that this RDATA entry is NOT disabled\n\n### Backup and restoration of zones\n\n```python\n# Backup every zone of every PowerDNS server\nfor server in api.servers:\n    backup_dir = \"backups/%s\" % server.id\n    for zone in server.zones:\n        zone.backup(backup_dir)\n\n# Restore a single zone on first PowerDNS server\nzone_file = \"backups/pdns-server-01/my.domain.tld.json\"\napi.servers[0].restore_zone(zone_file)\n```\n\n## Tests\n\n### PowerDNS service\n\nA simple [Dockerfile] is provided to spawn a basic powerdns service for tests\npurposes. The container is built using:\n\n```bash\ndocker build --tag pdns .\n```\n\nAnd started using:\n\n```bash\ndocker run --rm -it pdns\n```\n\n### Python Unit-Tests\n\nPython unit-tests are available in the [tests] directory. Based on [unittests],\nthose are run using `coverage run -m unittest discover` or integrated in your\nIDE for development purposes. Those tests require a PDNS service to connect to\n(see _PowerDNS service_ section above).\n\nThose tests are very limited at the moment and will be improved in the future.\n\n## License\n\nMIT LICENSE *(see LICENSE file)*\n\n## Miscellaneous\n\n```\n    ╚⊙ ⊙╝\n  ╚═(███)═╝\n ╚═(███)═╝\n╚═(███)═╝\n ╚═(███)═╝\n  ╚═(███)═╝\n   ╚═(███)═╝\n```\n\n[1]: https://img.shields.io/badge/python-2.7,3.4+-blue.svg\n[1l]: https://github.com/outini/python-powerdns\n[2]: https://img.shields.io/badge/license-MIT-blue.svg\n[2l]: https://github.com/outini/python-powerdns\n[3]: https://badge.fury.io/py/python-powerdns.svg\n[3l]: https://pypi.org/project/python-powerdns\n[Dockerfile]: files/Dockerfile\n[tests]: tests\n[unittests]: https://docs.python.org/3/library/unittest.html\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foutini%2Fpython-powerdns","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foutini%2Fpython-powerdns","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foutini%2Fpython-powerdns/lists"}