Package: cdmon-automator
Python library for CRUD operations on cdmon.comThis project will let you manage programmatically your domains in cdmon.comHow 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:fromcdmonimportCDMONcdmon=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.envfile or by any other means.USERNAME=
PASSWORD=
TIMEOUT=10
DEBUG=True
NETDEBUG=TrueUSERNAME- 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 toTrueit will show Chrome's UI. DefaultFalse.NETDEBUG- If set toTrueit will showurllibdebug to stdout. DefaultFalse.Usage detailswork_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 beTXTSPFAAAAACNAMEMXSRVNSvalues- 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 / SPFredirect_type- The type of redirect. It can be@- The entire domain*- Undefined subdomainscustom- A custom subdomainsubdomain- The custom subdomain. This argument makes sense only whenredirect_typeis set tocustom.value- The value of the record.Examples:Create a TXT record for the domain itself, with the valuefoo bar xyzcdmon.create_record("TXT",{"redirect_type":"@","value":"foo bar xyz"})Create a TXT record fortest.mydomain.com, with the valuehicdmon.create_record("TXT",{"redirect_type":"custom","subdomain":"test","value":"hi"})A / AAAA / CNAME / NSredirect_type- The type of redirect. It can be@- The entire domain*- Undefined subdomainscustom- A custom subdomainsubdomain- The custom subdomain. This argument makes sense only whenredirect_typeis set tocustom.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 to127.0.0.1cdmon.create_record("A",{"redirect_type":"@","destination":"127.0.0.1"})Create an AAAA record for the domaintest.mydomain.com, pointing to127.0.0.1cdmon.create_record("AAAA",{"redirect_type":"custom","subdomain":"test","destination":"127.0.0.1"})Create a CNAME record for the domain itself, pointing towww.mydomain.comcdmon.create_record("CNAME",{"redirect_type":"@","destination":"www.mydomain.com"})Create an NS record for the domaintest.mydomain.com, pointing tomydomain.comcdmon.create_record("NS",{"redirect_type":"custom","subdomain":"test","destination":"mydomain.com"})SRVredirect_type- The type of redirect. It can be@- The entire domain*- Undefined subdomainscustom- A custom subdomainsubdomain- The custom subdomain. This argument makes sense only whenredirect_typeis set tocustom.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 tofoobar.com 5 800 22cdmon.create_record("SRV",{"redirect_type":"@","destination":"foobar.com""priority":"5","weight":"800","port":"22"})Create an SRV record for the domainmail.mydomain.com, pointing tosmtp.foo.bar 10 200 465cdmon.create_record("SRV",{"redirect_type":"custom","subdomain":"mail","destination":"foobar.com""priority":"10","weight":"200","port":"465"})MXsubdomain- 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 domainmail.mydomain.com, pointing tofoobar.com 10cdmon.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.valueshas the same
rules as thevaluesfrom thecreate_recordmethod.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, multipleTXTrecords on the@domain.terminate()Will close/quit Chrome.