domainnameapi 1.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- domainnameapi/__init__.py +38 -0
- domainnameapi/_php.py +482 -0
- domainnameapi/_version.py +4 -0
- domainnameapi/client.py +275 -0
- domainnameapi/py.typed +0 -0
- domainnameapi/rest.py +1689 -0
- domainnameapi/shared.py +182 -0
- domainnameapi/telemetry.py +471 -0
- domainnameapi/transport.py +217 -0
- domainnameapi-1.0.0.dist-info/METADATA +1637 -0
- domainnameapi-1.0.0.dist-info/RECORD +13 -0
- domainnameapi-1.0.0.dist-info/WHEEL +4 -0
- domainnameapi-1.0.0.dist-info/licenses/LICENSE +201 -0
domainnameapi/client.py
ADDED
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
"""Public facade: :class:`DomainNameAPI`.
|
|
2
|
+
|
|
3
|
+
Port of php-dna ``DomainNameAPI_PHPLibrary``. Authenticates with a Reseller
|
|
4
|
+
ID (UUID) and an API Key and delegates to :class:`~domainnameapi.rest.DNARest`.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
import re
|
|
8
|
+
|
|
9
|
+
from . import _php as php
|
|
10
|
+
from .rest import DNARest
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def _parse_test_mode(value):
|
|
14
|
+
"""Panels store checkboxes as strings; ``"false"``/``"off"`` must stay off (BUG-10284)."""
|
|
15
|
+
if isinstance(value, str):
|
|
16
|
+
return php.filter_bool(php.trim(value))
|
|
17
|
+
return php.to_bool(value)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def _snake_case(name):
|
|
21
|
+
s = re.sub(r"(.)([A-Z][a-z]+)", r"\1_\2", name)
|
|
22
|
+
s = re.sub(r"([a-z0-9])([A-Z])", r"\1_\2", s)
|
|
23
|
+
return s.lower()
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class DomainNameAPI(object):
|
|
27
|
+
"""DomainNameAPI client.
|
|
28
|
+
|
|
29
|
+
:param reseller_id: Reseller ID (UUID) from the DomainNameAPI panel, API Settings.
|
|
30
|
+
:param api_key: API Key from the same page. Panel login credentials do not work.
|
|
31
|
+
:param test_mode: ``True`` (or ``"true"``, ``"1"``, ``"on"``, ``"yes"``) uses the
|
|
32
|
+
OTE test environment.
|
|
33
|
+
:param transport: optional object with ``send(HttpRequest) -> HttpResponse``,
|
|
34
|
+
replaces the default ``urllib`` transport (proxies, tests).
|
|
35
|
+
:param sentry_dsn: optional Sentry DSN overriding the built-in telemetry target.
|
|
36
|
+
|
|
37
|
+
Every network method returns a ``dict``/``list`` exactly like php-dna and
|
|
38
|
+
never raises for gateway or network failures: check ``result`` (``'OK'``
|
|
39
|
+
or ``'ERROR'``) and ``error`` (``Code``, ``Message``, ``Details``).
|
|
40
|
+
Methods are snake_case (``get_details``); the php-dna camelCase and
|
|
41
|
+
PascalCase names (``getDetails``, ``GetDetails``) work as aliases.
|
|
42
|
+
"""
|
|
43
|
+
|
|
44
|
+
def __init__(self, reseller_id="", api_key="", test_mode=False, transport=None, sentry_dsn=None):
|
|
45
|
+
reseller_id = php.trim(reseller_id)
|
|
46
|
+
api_key = php.trim(api_key)
|
|
47
|
+
self._client = DNARest(reseller_id, api_key, _parse_test_mode(test_mode),
|
|
48
|
+
transport=transport, sentry_dsn=sentry_dsn)
|
|
49
|
+
|
|
50
|
+
@property
|
|
51
|
+
def client(self):
|
|
52
|
+
"""The underlying :class:`~domainnameapi.rest.DNARest` instance."""
|
|
53
|
+
return self._client
|
|
54
|
+
|
|
55
|
+
def __getattr__(self, name):
|
|
56
|
+
# php-dna style names: getDetails / GetDetails -> get_details.
|
|
57
|
+
if name.startswith("_"):
|
|
58
|
+
raise AttributeError(name)
|
|
59
|
+
snake = _snake_case(name)
|
|
60
|
+
if snake != name and snake in type(self).__dict__:
|
|
61
|
+
return getattr(self, snake)
|
|
62
|
+
raise AttributeError("Method %s does not exist" % name)
|
|
63
|
+
|
|
64
|
+
# -- account ----------------------------------------------------------
|
|
65
|
+
|
|
66
|
+
def get_reseller_details(self):
|
|
67
|
+
"""Reseller account: id, name and balances (USD and TL)."""
|
|
68
|
+
return self._client.get_reseller_details()
|
|
69
|
+
|
|
70
|
+
def get_current_balance(self, currency_id="USD"):
|
|
71
|
+
"""Balance in one currency (``USD``, ``TRY``, ``EUR``, ``GBP``)."""
|
|
72
|
+
return self._client.get_current_balance(currency_id)
|
|
73
|
+
|
|
74
|
+
# -- search and lists ---------------------------------------------------
|
|
75
|
+
|
|
76
|
+
def check_availability(self, domains, extensions, period, command="create"):
|
|
77
|
+
"""Availability and price of every ``domain.extension`` combination."""
|
|
78
|
+
return self._client.check_availability(domains, extensions, period, command)
|
|
79
|
+
|
|
80
|
+
def get_list(self, extra_parameters=None):
|
|
81
|
+
"""Domains in the account (``PageNumber``/``PageSize``/``OrderColumn``/... filters)."""
|
|
82
|
+
return self._client.get_list(extra_parameters if extra_parameters is not None else {})
|
|
83
|
+
|
|
84
|
+
def get_tld_list(self, count=20):
|
|
85
|
+
"""TLDs with prices per period."""
|
|
86
|
+
return self._client.get_tld_list(count)
|
|
87
|
+
|
|
88
|
+
# -- domain -------------------------------------------------------------
|
|
89
|
+
|
|
90
|
+
def get_details(self, domain_name):
|
|
91
|
+
return self._client.get_details(domain_name)
|
|
92
|
+
|
|
93
|
+
def sync_from_registry(self, domain_name):
|
|
94
|
+
return self._client.sync_from_registry(domain_name)
|
|
95
|
+
|
|
96
|
+
def get_contacts(self, domain_name):
|
|
97
|
+
return self._client.get_contacts(domain_name)
|
|
98
|
+
|
|
99
|
+
def save_contacts(self, domain_name, contacts):
|
|
100
|
+
return self._client.save_contacts(domain_name, contacts)
|
|
101
|
+
|
|
102
|
+
def modify_name_server(self, domain_name, name_servers):
|
|
103
|
+
return self._client.modify_name_server(domain_name, name_servers)
|
|
104
|
+
|
|
105
|
+
def enable_theft_protection_lock(self, domain_name):
|
|
106
|
+
return self._client.enable_theft_protection_lock(domain_name)
|
|
107
|
+
|
|
108
|
+
def disable_theft_protection_lock(self, domain_name):
|
|
109
|
+
return self._client.disable_theft_protection_lock(domain_name)
|
|
110
|
+
|
|
111
|
+
def modify_privacy_protection_status(self, domain_name, status, reason="Owner request"):
|
|
112
|
+
return self._client.modify_privacy_protection_status(domain_name, status, reason)
|
|
113
|
+
|
|
114
|
+
def renew(self, domain_name, period):
|
|
115
|
+
return self._client.renew(domain_name, period)
|
|
116
|
+
|
|
117
|
+
def register_with_contact_info(self, domain_name, period, contacts, name_servers=None,
|
|
118
|
+
epp_lock=True, privacy_lock=False, additional_attributes=None):
|
|
119
|
+
return self._client.register_with_contact_info(
|
|
120
|
+
domain_name, period, contacts,
|
|
121
|
+
name_servers if name_servers is not None else [],
|
|
122
|
+
epp_lock, privacy_lock,
|
|
123
|
+
additional_attributes if additional_attributes is not None else [],
|
|
124
|
+
)
|
|
125
|
+
|
|
126
|
+
# -- child nameservers --------------------------------------------------
|
|
127
|
+
|
|
128
|
+
def add_child_name_server(self, domain_name, name_server, ip_address):
|
|
129
|
+
return self._client.add_child_name_server(domain_name, name_server, ip_address)
|
|
130
|
+
|
|
131
|
+
def delete_child_name_server(self, domain_name, name_server):
|
|
132
|
+
return self._client.delete_child_name_server(domain_name, name_server)
|
|
133
|
+
|
|
134
|
+
def modify_child_name_server(self, domain_name, name_server, ip_address):
|
|
135
|
+
return self._client.modify_child_name_server(domain_name, name_server, ip_address)
|
|
136
|
+
|
|
137
|
+
# -- transfers ------------------------------------------------------------
|
|
138
|
+
|
|
139
|
+
def transfer(self, domain_name, epp_code, period):
|
|
140
|
+
"""Start an incoming transfer with the EPP/auth code.
|
|
141
|
+
|
|
142
|
+
Contacts are never sent (the request carries ``"contacts": []``): the
|
|
143
|
+
registrar takes them over from the losing registrar.
|
|
144
|
+
"""
|
|
145
|
+
return self._client.transfer(domain_name, epp_code, period)
|
|
146
|
+
|
|
147
|
+
def cancel_transfer(self, domain_name):
|
|
148
|
+
return self._client.cancel_transfer(domain_name)
|
|
149
|
+
|
|
150
|
+
def approve_transfer(self, domain_name):
|
|
151
|
+
return self._client.approve_transfer(domain_name)
|
|
152
|
+
|
|
153
|
+
def reject_transfer(self, domain_name):
|
|
154
|
+
return self._client.reject_transfer(domain_name)
|
|
155
|
+
|
|
156
|
+
def check_transfer(self, domain_name, auth_code):
|
|
157
|
+
return self._client.check_transfer(domain_name, auth_code)
|
|
158
|
+
|
|
159
|
+
# -- DNS zone -------------------------------------------------------------
|
|
160
|
+
|
|
161
|
+
def get_resource_records(self, domain_name):
|
|
162
|
+
return self._client.get_resource_records(domain_name)
|
|
163
|
+
|
|
164
|
+
def add_resource_record(self, domain_name, name, type, content, ttl=3600, apply=True): # noqa: A002
|
|
165
|
+
return self._client.add_resource_record(domain_name, name, type, content, ttl, apply)
|
|
166
|
+
|
|
167
|
+
def edit_resource_record(self, domain_name, record_name, name, type, content, ttl=3600, apply=True): # noqa: A002
|
|
168
|
+
return self._client.edit_resource_record(domain_name, record_name, name, type, content, ttl, apply)
|
|
169
|
+
|
|
170
|
+
def delete_resource_record(self, domain_name, name, record, record_type, apply=True):
|
|
171
|
+
return self._client.delete_resource_record(domain_name, name, record, record_type, apply)
|
|
172
|
+
|
|
173
|
+
def apply_resource_records(self, domain_name):
|
|
174
|
+
return self._client.apply_resource_records(domain_name)
|
|
175
|
+
|
|
176
|
+
def set_resource_record_set(self, domain_name, name, type, contents, ttl=3600, apply=True): # noqa: A002
|
|
177
|
+
return self._client.set_resource_record_set(domain_name, name, type, contents, ttl, apply)
|
|
178
|
+
|
|
179
|
+
def delete_resource_record_set(self, domain_name, name, type, apply=True, known_value=""): # noqa: A002
|
|
180
|
+
return self._client.delete_resource_record_set(domain_name, name, type, apply, known_value)
|
|
181
|
+
|
|
182
|
+
def add_resource_record_value(self, domain_name, name, type, value, ttl=None, apply=True): # noqa: A002
|
|
183
|
+
return self._client.add_resource_record_value(domain_name, name, type, value, ttl, apply)
|
|
184
|
+
|
|
185
|
+
def remove_resource_record_value(self, domain_name, name, type, value, apply=True): # noqa: A002
|
|
186
|
+
return self._client.remove_resource_record_value(domain_name, name, type, value, apply)
|
|
187
|
+
|
|
188
|
+
def replace_resource_record_value(self, domain_name, name, type, old_value, new_value, ttl=None, apply=True): # noqa: A002
|
|
189
|
+
return self._client.replace_resource_record_value(domain_name, name, type, old_value, new_value, ttl, apply)
|
|
190
|
+
|
|
191
|
+
# -- forwarding -----------------------------------------------------------
|
|
192
|
+
|
|
193
|
+
def get_forwarding(self, domain_name):
|
|
194
|
+
return self._client.get_forwarding(domain_name)
|
|
195
|
+
|
|
196
|
+
def set_forwarding(self, domain_name, redirect_address, forward_type="Standard"):
|
|
197
|
+
"""Point the domain at a URL: ``'Standard'`` redirect or ``'Frame'`` (masked)."""
|
|
198
|
+
return self._client.set_forwarding(domain_name, redirect_address, forward_type)
|
|
199
|
+
|
|
200
|
+
def delete_forwarding(self, domain_name):
|
|
201
|
+
return self._client.delete_forwarding(domain_name)
|
|
202
|
+
|
|
203
|
+
# -- utilities (no network) -----------------------------------------------
|
|
204
|
+
|
|
205
|
+
def is_tr_tld(self, domain):
|
|
206
|
+
return self._client.is_tr_tld(domain)
|
|
207
|
+
|
|
208
|
+
def validate_contact(self, contact):
|
|
209
|
+
return self._client.validate_contact(contact)
|
|
210
|
+
|
|
211
|
+
# -- diagnostics ----------------------------------------------------------
|
|
212
|
+
|
|
213
|
+
def get_request_data(self):
|
|
214
|
+
return self._client.get_request_data()
|
|
215
|
+
|
|
216
|
+
def set_request_data(self, request):
|
|
217
|
+
self._client.set_request_data(request)
|
|
218
|
+
return self
|
|
219
|
+
|
|
220
|
+
def get_response_data(self):
|
|
221
|
+
return self._client.get_response_data()
|
|
222
|
+
|
|
223
|
+
def set_response_data(self, response):
|
|
224
|
+
self._client.set_response_data(response)
|
|
225
|
+
return self
|
|
226
|
+
|
|
227
|
+
def get_response_headers(self):
|
|
228
|
+
return self._client.get_response_headers()
|
|
229
|
+
|
|
230
|
+
def set_response_headers(self, headers):
|
|
231
|
+
self._client.set_response_headers(headers)
|
|
232
|
+
return self
|
|
233
|
+
|
|
234
|
+
def get_parsed_response_data(self):
|
|
235
|
+
return self._client.get_parsed_response_data()
|
|
236
|
+
|
|
237
|
+
def set_parsed_response_data(self, response):
|
|
238
|
+
self._client.set_parsed_response_data(response)
|
|
239
|
+
return self
|
|
240
|
+
|
|
241
|
+
def get_last_function(self):
|
|
242
|
+
return self._client.get_last_function()
|
|
243
|
+
|
|
244
|
+
def set_last_function(self, function):
|
|
245
|
+
self._client.set_last_function(function)
|
|
246
|
+
return self
|
|
247
|
+
|
|
248
|
+
def get_service_url(self):
|
|
249
|
+
return self._client.get_service_url()
|
|
250
|
+
|
|
251
|
+
def set_service_url(self, url):
|
|
252
|
+
self._client.set_service_url(url)
|
|
253
|
+
|
|
254
|
+
# -- settings -------------------------------------------------------------
|
|
255
|
+
|
|
256
|
+
def set_error_reporting_enabled(self, enabled):
|
|
257
|
+
"""Turn telemetry (error and performance reports) on or off."""
|
|
258
|
+
self._client.set_error_reporting_enabled(enabled)
|
|
259
|
+
|
|
260
|
+
def set_telemetry_minimal(self, minimal):
|
|
261
|
+
"""Send only error code/message, endpoint, timing, versions and reseller ID."""
|
|
262
|
+
self._client.set_telemetry_minimal(minimal)
|
|
263
|
+
|
|
264
|
+
def set_ssl_verification(self, enabled):
|
|
265
|
+
"""TLS certificate verification (on by default; switch off only for an outdated CA bundle)."""
|
|
266
|
+
self._client.set_ssl_verification(enabled)
|
|
267
|
+
|
|
268
|
+
@property
|
|
269
|
+
def zone_min_interval(self):
|
|
270
|
+
"""Minimum seconds between two DNS zone calls (default 1.0)."""
|
|
271
|
+
return self._client.zone_min_interval
|
|
272
|
+
|
|
273
|
+
@zone_min_interval.setter
|
|
274
|
+
def zone_min_interval(self, seconds):
|
|
275
|
+
self._client.zone_min_interval = float(seconds)
|
domainnameapi/py.typed
ADDED
|
File without changes
|