Metadata-Version: 2.1
Name: python-powerdns
Version: 0.2.1
Summary: PowerDNS web api python client and interface
Home-page: https://github.com/vente-privee/python-powerdns
Author: Denis Pompilio (jawa)
Author-email: dpompilio@vente-privee.com
Maintainer: Denis Pompilio (jawa)
Maintainer-email: dpompilio@vente-privee.com
License: MIT
Description: [![PythonSupport][1]][1l][![License][2]][2l]
        
        # python-powerdns -- PowerDNS web api python client and interface
        
        **Contact:** Denis 'jawa' Pompilio <dpompilio@vente-privee.com>
        
        **Sources:** https://github.com/vente-privee/python-powerdns
        
        ## About
        
        This package provides intuitive and easy to use python client and interface
        for the PowerDNS web API.
        
        ## Installation
        
        ```bash
        python setup.py install
        ```
        or
        ```bash
        pip install python-powerdns
        ```
        
        ## Helpers
        
        **pdns-zone-creator**
        ```bash
        usage: pdns-create-zone [-h] -A API -K APIKEY -z ZONE -o ORIGIN -c ZONE -d DNS
                                [-t TIMERS]
        
        PowerDNS zone creator
        
        optional arguments:
          -h, --help            show this help message and exit
          -A API, --api API     PowerDNS api (eg. https://api.domain.tld/api/v1
          -K APIKEY, --key APIKEY
                                PowerDNS api key
          -z ZONE, --zone ZONE  Zone name (canonical)
          -o ORIGIN, --origin ORIGIN
                                Zone origin (for SOA)
          -c ZONE, --contact ZONE
                                Zone contact (for SOA)
          -d DNS, --dns DNS     Zone nameservers comma separated
          -t TIMERS, --timers TIMERS
                                Zone timers (eg. '28800 7200 604800 86400')
        ```
        ```bash
        ./bin/pdns-create-zone -A "https://api.domain.tld/api/v1" -K "xxxxxxxxx" \
                               -z "myzone.domain.tld." \
                               -o "ns01.domain.tld." -c "admin.domain.tld." \
                               -d "nsd01.domain.tld.,nsd02.domain.tld."
        powerdns.interface INFO: listing available PowerDNS servers
        powerdns.interface INFO: getting available servers from API
        powerdns.client INFO: request: GET https://api.domain.tld/api/v1/servers
        powerdns.client INFO: request response code: 200
        powerdns.interface INFO: 1 server(s) listed
        powerdns.interface INFO: creation of zone: myzone.domain.tld.
        powerdns.client INFO: request: POST https://api.domain.tld/api/v1/servers/localhost/zones
        powerdns.client INFO: request response code: 201
        powerdns.interface INFO: zone myzone.domain.tld. successfully created
        ```
        
        ## Exemples
        
        Basic initialization:
        ```python
        import powerdns
        
        PDNS_API = "https://my.pdns.api.domain.tld/api/v1"
        PDNS_KEY = "mysupersecretbase64key"
        
        api_client = powerdns.PDNSApiClient(api_endpoint=PDNS_API, api_key=PDNS_KEY)
        api = powerdns.PDNSEndpoint(api_client)
        ```
        
        Creation and deletion of zones:
        ```python
        from datetime import date
        
        # Creating new zone on first PowerDNS server
        serial = date.today().strftime("%Y%m%d00")
        soa = "ns0.domain.tld. admin.domain.tld. %s 28800 7200 604800 86400" % serial
        soa_r = powerdns.RRSet(name='test.python-powerdns.domain.tld.',
                               rtype="SOA",
                               records=[(soa, False)],
                               ttl=86400)
        zone = api.servers[0].create_zone(name="test.python-powerdns.domain.tld.",
                                          kind="Native",
                                          rrsets=[soa_r],
                                          nameservers=["ns1.domain.tld.",
                                                       "ns2.domain.tld."])
        
        # Getting new zone info
        print(zone)
        print(zone.details)
        
        # Deleting newly created zone
        api.servers[0].delete_zone(zone.name)
        ```
        
        Creation and deletion of DNS records:
        ```python
        zone = api.server[0].get_zone("test.python-powerdns.domain.tld.")
        
        zone.create_records([
            powerdns.RRSet('a', 'A', [('1.1.1.1', False)]),
            powerdns.RRSet('b', 'A', ['1.1.1.2', '1.1.1.3']),
            powerdns.RRSet('c', 'A', [('1.1.1.4', False)]),
            powerdns.RRSet('d', 'CNAME', ['a'])
        ])
        
        zone.delete_record([
            powerdns.RRSet('a', 'A', [('1.1.1.1', False)]),
            powerdns.RRSet('d', 'CNAME', ['a'])
        ])
        ```
        
        Backup and restoration of zones:
        ```python
        # Backup every zone of every PowerDNS server
        for server in api.servers:
            backup_dir = "backups/%s" % server.id
            for zone in server.zones:
                zone.backup(backup_dir)
        
        # Restore a single zone on first PowerDNS server
        zone_file = "backups/pdns-server-01/my.domain.tld.json"
        api.servers[0].restore_zone(zone_file)
        ```
        
        ## License
        
        MIT LICENSE *(see LICENSE file)*
        
        ## Miscellaneous
        
        ```
            ╚⊙ ⊙╝
          ╚═(███)═╝
         ╚═(███)═╝
        ╚═(███)═╝
         ╚═(███)═╝
          ╚═(███)═╝
           ╚═(███)═╝
        ```
        
        [1]: https://img.shields.io/badge/python-2.7,3.4+-blue.svg
        [1l]: https://github.com/vente-privee/python-powerdns
        [2]: https://img.shields.io/badge/license-MIT-blue.svg
        [2l]: https://github.com/vente-privee/python-powerdns
        
Keywords: dns,powerdns,api
Platform: UNIX
Classifier: Development Status :: 5 - Production/Stable
Classifier: Operating System :: POSIX :: BSD
Classifier: Operating System :: POSIX :: Linux
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Classifier: Environment :: Web Environment
Classifier: Topic :: Utilities
Requires: urllib3
Requires: requests
Description-Content-Type: text/markdown
