Skip to main content

Unofficial NonameDomain API module/client

Project description

PyNonameDomain

Unofficial NonameDomain.hu API module and CLI tool

Installation

pip install pynonamedomain  // Use pip3 if Python2 is the default on your system


nnd-cli

$ nnd-cli 
Usage: nnd-cli [OPTIONS] COMMAND [ARGS]...

  Unofficial CLI tool for NonameDomain.hu

Options:
  --help  Show this message and exit.

Commands:
  create   Create new entry in the zone.
  login    Aquire API token.
  read     Read/find DNS entries in the zone.
  remove   Remove DNS entry from the zone.
  update   Update DNS entry in the zone.
  version  Version info.

Autocomplete

eval "$(_NND_CLI_COMPLETE=source nnd-cli)"      # for BASH
eval "$(_NND_CLI_COMPLETE=source_zsh nnd-cli)"  # for ZSH

Basic usage

export NND_DOMAIN="example.com"      # optional
export NND_USERNAME="api_user"       # optional
export NND_PASSWORD="api_pw"         # optional
export NND_TOKEN=$(nnd-cli login -q) # optional
nnd-cli read | jq
nnd-cli create -r '{"type":"A","host":"test","ip":"192.168.0.1","ttl":300}'
nnd-cli read -r '{"type":"A"}' -o csv
nnd-cli update --hash d67053c0cc0a544e074696a63723b296feeec564d -r '{"host":"test2"}'
nnd-cli remove --hash d67053c0cc0a544e074696a63723b296feeec564d

See per command --help for more info.

Using with certbot

export NND_DOMAIN="example.com"      # recommended
export NND_USERNAME="api_user"       # mandatory
export NND_PASSWORD="api_pw"         # mandatory
export NND_TOKEN=$(nnd-cli login -q) # mandatory
certbot certonly --manual --preferred-challenges=dns --manual-auth-hook "nnd-cli create -c" --manual-cleanup-hook "nnd-cli remove -q" -d example.com --manual-public-ip-logging-ok --agree-tos -m "your@email.address"

Using with lego

cp /usr/lib/python3.7/site-packages/pynonamedomain/lego-helper.sh .
# edit ./lego-helper.sh with your credentials
export EXEC_PATH=$(pwd)/lego-helper.sh
lego --dns exec --domains example.com --email "your@email.address" --accept-tos run

Using with Traefik

Since Traefik uses lego for ACME certs, the same helper script can be used.

cp /usr/lib/python3.7/site-packages/pynonamedomain/lego-helper.sh .
# edit ./lego-helper.sh with your credentials
export EXEC_PATH=$(pwd)/lego-helper.sh
# Traefik will handle the rest


pynonamedomain

Usage

class NonameDomain(domain, api_user=None, api_pw=None, token=None)

Class to implement CRUD operations to the Noname Domain API

Log into the API.

Args

domain: the domain to manage

api_user: API user

api_pw: password of API user

token: API token

Raises

ValueError: if neither user+password or token provided

Examples

nnd = pynonamedomain.NonameDomain("example.com", "username", "password")

nnd = pynonamedomain.NonameDomain("example.org", token = "3e4n23y87tresnt32erstn48")


def create(self, **data)

Create new DNS entry.

Note: TTL must be 300 or higher

Args

**data: a dictionary with all the necessary data to create a new entry

Raises

SubdomainAlreadyExists: if entry already exists

requests.HTTPError: if HTTP error occurs

requests.SSLError: if SSL error occurs

Returns

'ok' if entry created successfully

Examples

nnd.create(type = "A", host = "test", "ip" = "192.168.0.1", ttl = 600)

nnd.create(type = "TXT", text = "something", host = "sample", ttl = 300)


def read(self, cached=True, **search)

Read the current entries in the zone.

Args

cached: returns cached list if True, otherwise query the API

**search: filter the entries based on their attributes

Raises

SubdomainNotFound: if entry not found

Returns

all subdomains if search is omitted, otherwise the matching subdomains

Examples

nnd.read()

nnd.read(cached = False)

nnd.read(type = "A")


def remove(self, record_hash)

Remove entry from the zone.

Args

record_hash: hash of the entry to be deleted

Raises

requests.HTTPError: if HTTP error occurs

requests.SSLError: if SSL error occurs

Returns

'ok' if entry removed successfully

Examples

nnd.remove("ab83e38eaquf86ye28e35E8c6")


def update(self, record_hash, new_values)

Update entry in the zone.

Args

record hash: hash of the entry to be updated

new_values: dictionary of the new attributes

Raises

ValueError: if new_values is not a dictionary

Returns

'ok' if entry updated successfully

Examples

nnd.update("ab83e38eaquf86ye28e35E8c6", text = "newtext", ttl = 300)

nnd.update("ab83e38eaquf86ye28e35E8c6", type = "A", ip = "192.168.1.38")

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pynonamedomain-1.0.3.tar.gz (9.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pynonamedomain-1.0.3-py3-none-any.whl (20.5 kB view details)

Uploaded Python 3

File details

Details for the file pynonamedomain-1.0.3.tar.gz.

File metadata

  • Download URL: pynonamedomain-1.0.3.tar.gz
  • Upload date:
  • Size: 9.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.1 requests-toolbelt/0.9.1 tqdm/4.55.1 CPython/3.9.1

File hashes

Hashes for pynonamedomain-1.0.3.tar.gz
Algorithm Hash digest
SHA256 eb5472461d64d2fbde996966023d83015278f55947fc30c78156d472e6621d5d
MD5 1467de839f1f34affe5befc4123b0743
BLAKE2b-256 eccfdc03620d4d93daa96a098dfc4dc4fcd800035d112af91eb40a3a161c2c95

See more details on using hashes here.

File details

Details for the file pynonamedomain-1.0.3-py3-none-any.whl.

File metadata

  • Download URL: pynonamedomain-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 20.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.1 requests-toolbelt/0.9.1 tqdm/4.55.1 CPython/3.9.1

File hashes

Hashes for pynonamedomain-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 c254319280be390a1b14425bb19c2dc24827ee92ef10cf3132a328ebb6be1592
MD5 9fa0f3b995ab0cf1261bad6018566816
BLAKE2b-256 73ff3bfbfdcf1c072347fab08e5483a790f5d70cea2d89c1910927352d6dd53b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page