Library for CRUD operations on cdmon.com
Project description
Python library for CRUD operations on cdmon.com
This project will let you manage programmatically your domains in cdmon.com
How does it work?
It runs Chrome in headless mode and does what you'd do manually. There is no dark magic nor obscure hacks.
What do I need?
Any Python 3.x (+3.2 recommended) with PIP and Chrome (headless)
How can I use it?
A very basic usage example:
from cdmon import CDMON
cdmon = CDMON()
cdmon.login()
cdmon.work_on("foo.com")
cdmon.create_record("TXT", {
"redirect_type": "custom",
"subdomain": "bar",
"value": "123456789"
})
cdmon.work_on("mydomain.com")
cdmon.change_record("A", "www", "127.0.0.1")
cdmon.change_record("A", "mailcow", "1.2.3.4")
cdmon.change_record("TXT", "@", "v=spf1 ...")
cdmon.work_on("xyz.com")
cdmon.delete_record("TXT", "bar")
cdmon.terminate()
Keep in mind the library uses environment variables to get the login data.
You'll need to provide those, creating a .env
file or by any other means.
USERNAME=
PASSWORD=
TIMEOUT=10
DEBUG=True
NETDEBUG=True
USERNAME
- The username / email you use to login in cdmon.comPASSWORD
- The passwordTIMEOUT
- Make Selenium timeout after that amount of time (in seconds). Default10
.DEBUG
- If set toTrue
it will show Chrome's UI. DefaultFalse
.NETDEBUG
- If set toTrue
it will showurllib
debug to stdout. DefaultFalse
.
Usage details
work_on(domain_name)
You must call this method before doing any other work, in order to let the library know on which domain you want to do the work on.
create_record(record_type, values)
record_type
- The type of the record you're trying to create. It can be
TXT
SPF
A
AAAA
CNAME
MX
SRV
NS
values
- A hash containing specific data for the type of record you're
trying to create. Not all records need/use the same (amount of) variables. Use
the following list to make sure to use the correct data.
TXT / SPF
redirect_type
- The type of redirect. It can be
@
- The entire domain*
- Undefined subdomainscustom
- A custom subdomain
subdomain
- The custom subdomain. This argument makes sense only when
redirect_type
is set to custom
.
value
- The value of the record.
Examples:
-
Create a TXT record for the domain itself, with the value
foo bar xyz
cdmon.create_record("TXT", { "redirect_type": "@", "value": "foo bar xyz" })
-
Create a TXT record for
test.mydomain.com
, with the valuehi
cdmon.create_record("TXT", { "redirect_type": "custom", "subdomain": "test", "value": "hi" })
A / AAAA / CNAME / NS
redirect_type
- The type of redirect. It can be
@
- The entire domain*
- Undefined subdomainscustom
- A custom subdomain
subdomain
- The custom subdomain. This argument makes sense only when
redirect_type
is set to custom
.
destination
- The IP you want to assign to the record. Note that the library won't stop you from trying to assign invalid values.
Examples:
-
Create an A record for the domain itself, pointing to
127.0.0.1
cdmon.create_record("A", { "redirect_type": "@", "destination": "127.0.0.1" })
-
Create an AAAA record for the domain
test.mydomain.com
, pointing to127.0.0.1
cdmon.create_record("AAAA", { "redirect_type": "custom", "subdomain": "test", "destination": "127.0.0.1" })
-
Create a CNAME record for the domain itself, pointing to
www.mydomain.com
cdmon.create_record("CNAME", { "redirect_type": "@", "destination": "www.mydomain.com" })
-
Create an NS record for the domain
test.mydomain.com
, pointing tomydomain.com
cdmon.create_record("NS", { "redirect_type": "custom", "subdomain": "test", "destination": "mydomain.com" })
SRV
redirect_type
- The type of redirect. It can be
@
- The entire domain*
- Undefined subdomainscustom
- A custom subdomain
subdomain
- The custom subdomain. This argument makes sense only when
redirect_type
is set to custom
.
destination
- The destination you want to assign to the record. Note that the library won't stop you from trying to assign invalid values.
priority
- The priority of the record.
weight
- The weight of the record.
port
- The port of the record.
Examples:
-
Create a SRV record for the domain itself, pointing to
foobar.com 5 800 22
cdmon.create_record("SRV", { "redirect_type": "@", "destination": "foobar.com" "priority": "5", "weight": "800", "port": "22" })
-
Create an SRV record for the domain
mail.mydomain.com
, pointing tosmtp.foo.bar 10 200 465
cdmon.create_record("SRV", { "redirect_type": "custom", "subdomain": "mail", "destination": "foobar.com" "priority": "10", "weight": "200", "port": "465" })
MX
subdomain
- The subdomain.
destination
- The destination you want to assign to the record. Note that the library won't stop you from trying to assign invalid values.
priority
- The priority of the record.
Example:
-
Create an MX record for the domain
mail.mydomain.com
, pointing tofoobar.com 10
cdmon.create_record("MX", { "redirect_type": "custom", "subdomain": "mail", "destination": "foobar.com" "priority": "10" })
change_record(self, record_type, record_name, values)
This method will let you update the fields of a record. values
has the same
rules as the values
from the create_record
method.
Note that you can't update the subdomain of the record, only the rest of the fields. This is how cdmon.com works.
delete_record(record_type, record_name)
This method will let you delete a record. Note that the search is based on
the type and the name (subdomain), which means that it's error prone in
situation when multiple records of the same type and on the same subdomain
exist, for example, multiple TXT
records on the @
domain.
terminate()
Will close/quit Chrome.
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
Built Distribution
File details
Details for the file cdmon_automator-0.0.8.tar.gz
.
File metadata
- Download URL: cdmon_automator-0.0.8.tar.gz
- Upload date:
- Size: 5.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.7.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 664dd6f4a8e72df907154469fca2da79f5444d01ac30b6ed70afb824149272b5 |
|
MD5 | 79101da9783fb2a5e1ee77490b1a80e8 |
|
BLAKE2b-256 | 440ae339225116f285081287f23652c6870c0a678f5993d22017ba7c18918c85 |
File details
Details for the file cdmon_automator-0.0.8-py3-none-any.whl
.
File metadata
- Download URL: cdmon_automator-0.0.8-py3-none-any.whl
- Upload date:
- Size: 6.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.7.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d23cf710ef17c02b8c8d3d409714bfce1ed9e572a439f03924e9ecbc9bfc291d |
|
MD5 | d3441be70a850cfff30c52b864707375 |
|
BLAKE2b-256 | 65a0c1a631b7cc0ec2f9eaa2e591339bf0a7dc88f64a94feb1b2382cd8dc846c |