A simple library to handle Hetzner DNS API
Project description
hdns
Overview
This library is intended for people that do not have an static IP from their ISP but want to keep updated their A records at Hetzner DNS service
Installation
pip install hdns requests json sys
Example usage to update all A records with the current IPv4 ip
from hdns import arecords, ipv4
zone_id = "XXXXXXX"
auth_api_token = "XXXXXX"
ip = ipv4.get_ipv4()
records = arecords.get_all(zone_id, auth_api_token)
different_ip_zone_ids = []
for record in records:
if record["value"] != ip:
record["value"] = ip
different_ip_zone_ids.append(record)
if different_ip_zone_ids:
insert_records = arecords.insert_records(auth_api_token, different_ip_zone_ids)
print(insert_records)
else:
print("No need for update, IPv4 is still the same!")
ipv4: uses https://api.ipify.org API to get your IPv4 public IP arecords.get_all(): accepts two values the zone_id and the auth_api_token to be able to function ipv4.get_ipv4(): can be called without any value to return your public IP arecords.insert_records(): accepts two values auth_api_token and an json array object with records that need to be modified
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file hdns-0.7.tar.gz.
File metadata
- Download URL: hdns-0.7.tar.gz
- Upload date:
- Size: 2.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d3feb31be2a9bdf7dc900c7eaeccaedda8dd59065fea27d266d2c20ee5f7ab61
|
|
| MD5 |
402cfa2847b2200f7dfe7d3a462f25f2
|
|
| BLAKE2b-256 |
9266e61dc45bba3416b8506bc1bcc56120fa8b304c0d9124715dfac3ae034b6f
|
File details
Details for the file hdns-0.7-py3-none-any.whl.
File metadata
- Download URL: hdns-0.7-py3-none-any.whl
- Upload date:
- Size: 2.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0f387ebfd5108133217cce4e4c0544825bcbf0a298e7da57b1c192c9a3781a98
|
|
| MD5 |
20a263bce532767ea58766ea9c6d75dd
|
|
| BLAKE2b-256 |
4a3ac66c241309d6f13fc0d7d4af6bc5dff4de7213917459d1623169341542dc
|