Skip to main content

make simple dnsmadeeasy api calls

Project description

Dnsmeapi Python client

simplify dnsmadeeasy api calls :- https://api-docs.dnsmadeeasy.com/?version=latest#6a7eef29-27fb-4f37-af89-e3ec4a3dcf66 Python 3.7

Tests

From the project root directory

export PYTHONPATH=$(pwd)
pytest .

Dnsmeapi Class

class Dnsmeapi:
    hmac = None
    request_date = None
    api_key = ""
    api_secret_key = ""

    def __init__(self, api_key, api_secret_key):
        self.api_key = api_key
        self.api_secret_key = api_secret_key

    def make_request(self, method_type, url, payload):
        self.request_date = formatdate(timeval=None, localtime=False, usegmt=True)
        try:
            self.hmac = hmac.new(
                bytes(self.api_secret_key, "UTF-8"),
                bytes(self.request_date, "UTF-8"),
                hashlib.sha1,
            ).hexdigest()
        except Exception as e:
            raise e

        headers = {
            "Content-Type": "application/json",
            "x-dnsme-hmac": self.hmac,
            "x-dnsme-apiKey": self.api_key,
            "x-dnsme-requestDate": self.request_date,
        }

        try:
            response = requests.request(method_type, url, headers=headers, data=payload)
            return response.text.encode('utf-8')
        except Exception as e:
            raise e

Import

from dnsmeapi import Dnsmeapi

Initalise class

dnsmeapi = Dnsmeapi( "api_key", "api_secret_key" )

Send Request

dnsmeapi.make_request( "GET", "URL", {} )

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

dnsmeapi-0.0.2.tar.gz (2.2 kB view details)

Uploaded Source

File details

Details for the file dnsmeapi-0.0.2.tar.gz.

File metadata

  • Download URL: dnsmeapi-0.0.2.tar.gz
  • Upload date:
  • Size: 2.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.43.0 CPython/2.7.15

File hashes

Hashes for dnsmeapi-0.0.2.tar.gz
Algorithm Hash digest
SHA256 907c2f7c499df943614fdb566a4c9afb8f72c85c3039c955154bfa41687da6fb
MD5 3b127847c607f0b545defd3177113539
BLAKE2b-256 0aac12729547754538d00a24e8af14d09a24d74f6a9c4903523aad904b2ecdd2

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