TransIP REST Client¶
Under normal circumstances, this is the only class you have to use. Once instantiated, you can call the different members to access functions at TransIP. All returned data structures are Python objects (either nested lists/dicts, or simple strings. Exceptions are raised when something is wrong.
-
class
transip_rest_client.transip_rest_client.
TransipRestClient
(user: str, rsaprivate_key: str, base_url: str = 'https://api.transip.nl/v6', timeout: int = 10, global_key: bool = False, token: str = None)[source]¶ Python abstraction of the TransIP Rest API
General implementation considerations:
- a get request returns a (possible nested) dict or list (can be empty)
- a post/put/patch request will not return anything
- exceptions will be raised if needed. Exceptions are based on TransipRestException
- ‘related resources’ are discarded
TransIP documentation: https://api.transip.nl/rest/docs.html
Parameters: - user (str) – accountname for TransIP
- rsaprivate_key (str) – The (converted to) RSA Private key for this account
- base_url (str) – URL to authenticate to. default https://api.transip.nl/v6
- timeout (int) – timeout for connection in seconds
Raises: TransipRestprivatekeyException – when authentication does not succeed.
-
delete_dns_entry
(domain: str = None, name: str = None, expire: int = 86400, record_type: str = None, content: str = None) → None[source]¶ Remove a single DNS entry in an existing DNS zone
TransIP documentation: https://api.transip.nl/rest/docs.html#domains-dns-delete
Parameters: - domain (str) – an existing DNS domain (e.g. ‘example.com’)
- name (str) – the name of the record (e.g. ‘www’)
- expire (int) – expiry in seconds for caching this record (e.g. 86400)
- record_type (str) – a valid DNS type (e.g. ‘A’, ‘AAAA’, ‘TXT’)
- content (str) – current content for this DNS record
Return type: None
-
get_dns_entries
(domain: str = None) → list[source]¶ Returns DNS records for a domain
TransIP documentation: https://api.transip.nl/rest/docs.html#domains-dns-get
Parameters: domain (str) – an existing DNS domain (e.g. ‘example.com’) Return type: dict Returns: a list of dicts describing the DNS records in this zone example:
[ {'content': '37.97.254.27', 'expire': '300', 'name': '@', 'type': 'A'}, { 'content': '2a01:7c8:3:1337::27', 'expire': '300', 'name': '@', 'type': 'AAAA'} ]
Raises: TransIPRestDomainNotFound – when the domain is not found
-
get_dnssec
(domain: str = None) → dict[source]¶ lists all DNSSEC entries for a domain once set.
Note: TransIP will not publish the details for domains that use the TransIP nameservers. This call will only return results for domains that are registered at Transip, but use non-TransIP DNS.
TransIP documentation: https://api.transip.nl/rest/docs.html#domains-dnssec-get
Parameters: domain (str) – an existing DNS domain (e.g. ‘example.com’) Return type: dict Returns: A dictionary with the DNSSec settings for this domain
-
get_domain
(domain: str = None) → dict[source]¶ Returns administrative information about a signle domain
TransIP documentation: https://api.transip.nl/rest/docs.html#domains-domains-get-1
Parameters: domain (str) – an existing DNS domain Return type: dict Returns: A dict with administrative details about the domain example:
{ 'authCode': 'V496K%3A7N', 'cancellationDate': None, 'cancellationStatus': None, 'hasActionRunning': False, 'isDnsOnly': False, 'isTransferLocked': False, 'isWhitelabel': False, 'name': 'example.com', 'registrationDate': '2019-12-10', 'renewalDate': '2020-12-10', 'supportsLocking': True, 'tags': ['mytag'] }
Raises: TransIPRestDomainNotFound – when the domain is not found
-
get_domain_actions
(domain: str = None) → dict[source]¶ get current (administrative) actions on a domain
TransIP documentation: https://api.transip.nl/rest/docs.html#domains-actions-get
Parameters: domain (str) – an existing domain hosted by TransIP Return type: dict Returns: A dict with the name of the action, a message and a boolean indicating the result example:
{'name': 'changeNameservers', 'message': 'success', 'hasFailed': False }
-
get_domain_zone_file
(domain: str = None) → str[source]¶ get the zonefile (BIND format) as a signle string
TransIP documentation: https://api.transip.nl/rest/docs.html#domains-zone-file-get
Parameters: domain (str) – an existing domain hosted by TransIP Return type: str Returns: A string with the zone file Raises:
-
get_domains
() → dict[source]¶ Returns all domains present in this TransIP account
TransIP documentation: https://api.transip.nl/rest/docs.html#domains-domains-get
Return type: str Returns: A list of dicts, each list entry contains a dict with administrative details about a domain example:
[ { 'authCode': 'V496K%3A7N', 'cancellationDate': None, 'cancellationStatus': None, 'hasActionRunning': False, 'isDnsOnly': False, 'isTransferLocked': False, 'isWhitelabel': False, 'name': 'example.com', 'registrationDate': '2019-12-10', 'renewalDate': '2020-12-10', 'supportsLocking': True, 'tags': ['mytag']} ]
-
get_nameservers
(domain: str = None) → list[source]¶ Lists nameservers for a domain
TransIP documentation: https://api.transip.nl/rest/docs.html#domains-nameservers-get
Parameters: domain (str) – a domain that is hosted by TransIP Return type: list Returns: A list of dicts with information about the nameservers for this domain. Note: currently only the hostnames are returned for transip nameservers
example:
[{'hostname': 'ns0.transip.net', 'ipv4': '', 'ipv6': ''}, {'hostname': 'ns1.transip.nl', 'ipv4': '', 'ipv6': ''}, {'hostname': 'ns2.transip.eu', 'ipv4': '', 'ipv6': ''}]
Raises: TransIPRestDomainNotFound – when the domain is not found
-
get_products
() → dict[source]¶ Returns all available products currently offered by TransIP.
TransIP documentation: https://api.transip.nl/rest/docs.html#general-products-get
Return type: dict Returns: A dict with information about TransIP products and prices example:
{ 'bigStorage': [ { 'description': 'St Disk 2000 GB', 'name': 'vol-storage-contr', 'price': 10, 'recurringPrice': 10}, { 'description': '2000 GB', 'name': 'vol-storage-addon-contr', 'price': 10} ] }
-
patch_dns_entry
(domain: str = None, name: str = None, expire: int = 86400, record_type: str = None, content: str = None) → None[source]¶ Update the content of a single DNS entry, identified by the name, expire, type attributes.
When multiple or none of the current DNS entries matches, an exception will be thrown.
TransIP documentation: https://api.transip.nl/rest/docs.html#domains-dns-patch
Parameters: - domain (str) – an existing DNS domain (e.g. ‘example.com’)
- name (str) – the name of the record (e.g. ‘www’)
- expire (int) – expiry in seconds for caching this record (e.g. 86400)
- record_type (str) – a valid DNS type (e.g. ‘A’, ‘AAAA’, ‘TXT’)
- content (str) – new content for this DNS record (e.g. ‘127.0.0.1’ for an ‘A’-type record)
Return type: None
Raise: TransipRestException: not all required arguments are passed
Raise: TransipRestException: when an invalid type is passed
-
ping
() → str[source]¶ A simple test resource to check everything is working
Return type: str Returns: a string containing ‘pong’ when connection and authentication is working
-
post_dns_entry
(domain: str = None, name: str = None, expire: int = 86400, record_type: str = None, content: str = None) → None[source]¶ Add a DNS record to an existing DNS zone
TransIP documentation: https://api.transip.nl/rest/docs.html#domains-dns-post
Parameters: - domain (str) – an existing DNS domain (e.g. ‘example.com’)
- name (str) – the name of the record (e.g. ‘www’)
- expire (int) – expiry in seconds for caching this record (e.g. 86400)
- record_type (str) – a valid DNS type (e.g. ‘A’, ‘AAAA’, ‘TXT’)
- content (str) – valid content for this type of DNS record (e.g. ‘127.0.0.1’ for an ‘A’-type record)
Return type: None
Raises: - TransipRestException – not all required arguments are passed
- TransipRestException – when an invalid type is passed