Package: transip-dns
TransIP DNS (DDNS)Transip_dns is a command line tool which interfaces with theTransIP Management APIBesidesordinaryrecord management (creation/deletion/listing), it can be used as anDDNStool to update yourhomerecord.InstallationUse the package manager to install transip_dnspip install transip_dns(Or get a copy from thereleases section of this repoor perform apython setup.py installfrom a copy of this repository.)PrerequisitesObtain anAPI key from TransIP; if using for DDNS, make sure you donotselect to accept only from ip addresses from the whitelist; if your ip has been changed it will probably not be in the whitelist and will then not allow you to use the key.UsageRunningtransip_dns--helpwill provide useful information.Three parameters are basicallyalwaysrequired; TransIP username, private key, and the domain in question. They can be specified as:transip_dns --user John --private_key_file /home/john/tip.key --domainname example.com --...Or as environment variables:TID_USER=JohnTID_PRIVATE_KEY_FILE=/home/john/tip.keyTID_DOMAINNAME=example.comFor readability, it is assumed that in all examples, these environment variables are presentSo my initial goal was to create a DDNS script:transip_dns--record_ttl300--record_namehomebase--query_ipv4This will update the record, or create it if it doesn’t exist.
Since record type isAby default, it’s not specified. By default the script useshttps://ipv4.icanhazip.comforArecords.You can check the result by listing the domain:transip_dns--listReminder; the user, key and domain are read from the environmentDeleting the record would be as simple as:transip_dns--record_namehomebaseAdvanced UsageReminder; the user, key and domain are read from the environmentManagement of other records can be done as well. E.g updating yourSPF record:transip_dns--record_typeTXT--record_name'@'--record_ttl300--record_data'v=spf1 include:spf.example.net -all'As a precaution, the script will not manage records with the same name, e.g. used as round-robin load balancing, or commonly used for MX records.Docker / KubernetesAs all parameters can be specified as environment variables, the script can easily run within a Docker container, or even as aCronJob in KubernetesCreating a container would be as easy as using the followingDockerfile:FROMpython:3.6RUNpipinstalltransip_dnsENTRYPOINT["transip_dns"]TestingBoth unit tests as integration tests are present. For the integration tests to work you need to provide credentials and a test domain. The integration tests will create, modify and delete record. But only the records it creates itself, and cleanup is part of the tests for record creation. Existing records should not be touched, and no test records should remain. But be sure to check the integration tests for the extremely small chance you have some of the same records. No guarantees there!For integration testing you need to create the filetests/integration/_transip_credentials.pywith you credentials (you can use/rename ``
For integration testing you need to create the filetests/integration/_transip_credentials.pywith you credentials (you can use/renametests/integration/_transip_credentials.pyby removing the underscore)As for running the tests, use tox, which will test against python version 3.6, 3.7, 3.8, 3.9 and 3.10 (if available).For testing and development, I have used:pyenvto switch and/or provide different Python versions.pipenvfor creation of virtualenvs and dependency managementTests are build usingpytesttoxfor automated testing on different Python versions (Unfortunately tox was installed in site-packages, as it didn’t work well within a pipenv…)Usage of the complete tox test assumes the availability of Python versions 3.6-3.10.
Development was done using Python 3.6.When pipenv and Python 3.6 is available, runningmakewill create the virtualenv, run the tests and build the distribution files.Referenced informationTransIP API documentation:https://api.transip.nl/rest/docs.htmlTransIP OpenAPI:https://api.transip.nl/rest/openapi.yamlHTTP status codes:https://tools.ietf.org/html/rfc7231#section-6HTTP registered status codes:https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtmlDNS record definitions:https://tools.ietf.org/html/rfc1035#section-3LicenseSee license file (MIT License, Copyright (c) 2020 Bob van den Heuvel)