Skip to main content

Python wrapper for the Websupport.sk REST API

Project description

python-websupportsk

Python wrapper for the Websupport.sk REST API.
The Websupportsk REST API can be found here.

Current API support

✅ DNS management (v0.1.0+)
❌ Hosting management
❌ VPS management

Python 2.x vs 3.x support

Code is Python3 clean, developed under version 3.9. Python2 is not supported.

Installation

Two methods are provided to install this software. Use PyPi (see package details) or GitHub (see package details).

Via PyPI

    $ sudo pip install websupportsk
    $

Via GitHub

    $ git clone https://github.com/JozefGalbicka/python-websupportsk
    $ cd python-websupportsk
    $ ./setup.py build
    $ sudo ./setup.py install
    $

Example code

All example code is available on GitHub (see package in the examples folder).

Getting Started

Direct authentication in code itself.

import websupportsk

identifier = "your-identifier"
secret_key = "your-secret-key"
domain = "example.com"

client = websupportsk.Client(identifier, secret_key, domain)

print(client.test_connection())


File based authentication. This or similar solution is more secure and recommended, as you can limit file privileges to root only.

import websupportsk
import json

with open("/path/to/config.json", "r") as config_file:
    config = json.load(config_file)

client = websupportsk.Client(config['authentication']['identifier'],
                             config['authentication']['secret_key'],
                             config['registered_domain'])

print(client.test_connection())


DNS record creation with error example.

import websupportsk
import json
client = websupportsk.Client("your-identifier", "your-secret_key", "example.com")

ip_addresses = ["56.67.78.89", "45.56.67.78"]

for ip in ip_addresses:
    response = client.create_record(type_="A", name="www", content=ip)
    if response['errors']:  # if error key in response is not empty(contains some errors)
        print("Request failed, response:")
        print(json.dumps(response, indent=4))  # pretty-printed JSON

# Request failed, response:
# {
#     "status": "error",
#     "item": {
#         "type": "A",
#         "id": null,
#         "name": "www",
#         "content": "45.56.67.78",
#         "ttl": 600,
#         "note": null,
#         "zone": {
#             "name": "example.com",
#             "service_id": 1234657,
#             "updateTime": 1234567890
#         }
#     },
#     "errors": {
#         "content": [
#             "For specified address already exists A record. It can not be overwritten. You need to edit it or delete it."
#         ]
#     }
# }

Debugging

If you feel like debugging, here is simple logger configuration to show debug messages.

import logging

logging.basicConfig()
logging.getLogger('urllib3').setLevel(logging.WARNING) # disable `requests` debug messages if you want to.
logger = logging.getLogger()
logger.setLevel(logging.DEBUG)

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

websupportsk-0.1.2.tar.gz (6.7 kB view details)

Uploaded Source

File details

Details for the file websupportsk-0.1.2.tar.gz.

File metadata

  • Download URL: websupportsk-0.1.2.tar.gz
  • Upload date:
  • Size: 6.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.8.5

File hashes

Hashes for websupportsk-0.1.2.tar.gz
Algorithm Hash digest
SHA256 7070e51fb9278b1ab4fb425de46a739fc1b9f8c20f87840b22bd033463c8717b
MD5 11b8d50dfd5a342796984c3ccc7bd2d1
BLAKE2b-256 cc9a6291c2bac87ed83baf9fc3b3cc0af8d35060efc59f58b1ddf537ea416917

See more details on using hashes here.

Supported by

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