httpnet 0.9.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.
- httpnet/__init__.py +0 -0
- httpnet/_core.py +520 -0
- httpnet/client.py +38 -0
- httpnet/dns.py +324 -0
- httpnet/domain.py +372 -0
- httpnet/email.py +179 -0
- httpnet-0.9.0.dist-info/METADATA +151 -0
- httpnet-0.9.0.dist-info/RECORD +10 -0
- httpnet-0.9.0.dist-info/WHEEL +4 -0
- httpnet-0.9.0.dist-info/licenses/LICENSE.txt +19 -0
httpnet/dns.py
ADDED
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
from collections.abc import Iterable
|
|
2
|
+
from datetime import datetime
|
|
3
|
+
from enum import Enum
|
|
4
|
+
|
|
5
|
+
from httpnet._core import CrudService, Element, Service
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class SoaValues(Element):
|
|
9
|
+
refresh: int
|
|
10
|
+
retry: int
|
|
11
|
+
expire: int
|
|
12
|
+
ttl: int
|
|
13
|
+
negative_ttl: int
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class TemplateReplacements(Element):
|
|
17
|
+
ipv4_replacement: str | None
|
|
18
|
+
ipv6_replacement: str | None
|
|
19
|
+
mail_ipv4_replacement: str | None
|
|
20
|
+
mail_ipv6_replacement: str | None
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class TemplateValues(Element):
|
|
24
|
+
template_id: str | None
|
|
25
|
+
template_name: str | None
|
|
26
|
+
tie_to_template: bool | None
|
|
27
|
+
template_replacements: TemplateReplacements | None
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class ZoneConfigType(Enum):
|
|
31
|
+
NATIVE = 'NATIVE'
|
|
32
|
+
MASTER = 'MASTER'
|
|
33
|
+
SLAVE = 'SLAVE'
|
|
34
|
+
|
|
35
|
+
def __repr__(self):
|
|
36
|
+
return f'{self.__class__.__qualname__}.{self.name}'
|
|
37
|
+
|
|
38
|
+
def __str__(self):
|
|
39
|
+
return self.value
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
class ZoneConfig(Element):
|
|
43
|
+
id: str | None
|
|
44
|
+
account_id: str | None
|
|
45
|
+
status: str | None
|
|
46
|
+
name: str | None
|
|
47
|
+
name_unicode: str | None
|
|
48
|
+
master_ip: str | None
|
|
49
|
+
type: ZoneConfigType | None
|
|
50
|
+
email_address: str | None
|
|
51
|
+
zone_transfer_whitelist: Iterable[str] | None
|
|
52
|
+
last_change_date: datetime | None
|
|
53
|
+
soa_values: SoaValues | None
|
|
54
|
+
template_values: TemplateValues | None
|
|
55
|
+
dns_sec_mode: str | None
|
|
56
|
+
dns_server_group_id: str | None
|
|
57
|
+
# undocumented
|
|
58
|
+
add_date: datetime | None
|
|
59
|
+
restorable_until: datetime | None
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
class RecordType(Enum):
|
|
63
|
+
A = 'A'
|
|
64
|
+
AAAA = 'AAAA'
|
|
65
|
+
ALIAS = 'ALIAS'
|
|
66
|
+
CAA = 'CAA'
|
|
67
|
+
CERT = 'CERT'
|
|
68
|
+
CNAME = 'CNAME'
|
|
69
|
+
DNSKEY = 'DNSKEY'
|
|
70
|
+
DS = 'DS'
|
|
71
|
+
MX = 'MX'
|
|
72
|
+
NS = 'NS'
|
|
73
|
+
NSEC = 'NSEC'
|
|
74
|
+
NSEC3 = 'NSEC3'
|
|
75
|
+
NSEC3PARAM = 'NSEC3PARAM'
|
|
76
|
+
NULLMX = 'NULLMX'
|
|
77
|
+
OPENPGPKEY = 'OPENPGPKEY'
|
|
78
|
+
PTR = 'PTR'
|
|
79
|
+
RRSIG = 'RRSIG'
|
|
80
|
+
# undocumented, but every zone answers with the SOA record of its zone
|
|
81
|
+
SOA = 'SOA'
|
|
82
|
+
SRV = 'SRV'
|
|
83
|
+
SSHFP = 'SSHFP'
|
|
84
|
+
TLSA = 'TLSA'
|
|
85
|
+
TXT = 'TXT'
|
|
86
|
+
|
|
87
|
+
def __repr__(self):
|
|
88
|
+
return f'{self.__class__.__qualname__}.{self.name}'
|
|
89
|
+
|
|
90
|
+
def __str__(self):
|
|
91
|
+
return self.value
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
class DnsRecord(Element):
|
|
95
|
+
id: str | None
|
|
96
|
+
zone_id: str | None
|
|
97
|
+
record_template_id: str | None
|
|
98
|
+
name: str | None
|
|
99
|
+
type: RecordType | None
|
|
100
|
+
content: str | None
|
|
101
|
+
ttl: int | None
|
|
102
|
+
priority: int | None
|
|
103
|
+
last_change_date: datetime | None
|
|
104
|
+
# undocumented
|
|
105
|
+
zone_config_id: str | None
|
|
106
|
+
account_id: str | None
|
|
107
|
+
add_date: datetime | None
|
|
108
|
+
comments: str | None
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
class Zone(Element):
|
|
112
|
+
zone_config: ZoneConfig | None
|
|
113
|
+
records: Iterable[DnsRecord]
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
class ZoneConfigService(Service[ZoneConfig]):
|
|
117
|
+
"""Zone configs are created, updated and deleted through :class:`ZoneService`."""
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
class RecordService(Service[DnsRecord]):
|
|
121
|
+
"""Records are created, updated and deleted through :class:`ZoneService`."""
|
|
122
|
+
|
|
123
|
+
@property
|
|
124
|
+
def _element_name(self) -> str:
|
|
125
|
+
return 'record'
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
class ZoneService(Service[Zone]):
|
|
129
|
+
# A zone is identified by its zone config, ``ZoneId`` is not a filter field.
|
|
130
|
+
_find_filter_name = 'ZoneConfigId'
|
|
131
|
+
|
|
132
|
+
def create(self, zone: Zone, nameserver_set_id: str | None = None,
|
|
133
|
+
use_default_nameserver_set: bool | None = None) -> Zone:
|
|
134
|
+
parameters = zone.to_json()
|
|
135
|
+
if nameserver_set_id is not None:
|
|
136
|
+
parameters['nameserverSetId'] = nameserver_set_id
|
|
137
|
+
if use_default_nameserver_set is not None:
|
|
138
|
+
parameters['useDefaultNameserverSet'] = use_default_nameserver_set
|
|
139
|
+
response = self._call(
|
|
140
|
+
method='zoneCreate',
|
|
141
|
+
parameters=parameters
|
|
142
|
+
)
|
|
143
|
+
return Zone.from_json(response.get('response', {}))
|
|
144
|
+
|
|
145
|
+
def recreate(self, zone: Zone, nameserver_set_id: str | None = None,
|
|
146
|
+
use_default_nameserver_set: bool | None = None) -> Zone:
|
|
147
|
+
parameters = zone.to_json()
|
|
148
|
+
if nameserver_set_id is not None:
|
|
149
|
+
parameters['nameserverSetId'] = nameserver_set_id
|
|
150
|
+
if use_default_nameserver_set is not None:
|
|
151
|
+
parameters['useDefaultNameserverSet'] = use_default_nameserver_set
|
|
152
|
+
response = self._call(
|
|
153
|
+
method='zoneRecreate',
|
|
154
|
+
parameters=parameters
|
|
155
|
+
)
|
|
156
|
+
return Zone.from_json(response.get('response', {}))
|
|
157
|
+
|
|
158
|
+
def update(self, zone_config: ZoneConfig, records_to_add: Iterable[DnsRecord] = (),
|
|
159
|
+
records_to_delete: Iterable[DnsRecord] = (),
|
|
160
|
+
records_to_modify: Iterable[DnsRecord] = ()) -> Zone:
|
|
161
|
+
response = self._call(
|
|
162
|
+
method='zoneUpdate',
|
|
163
|
+
parameters={
|
|
164
|
+
'zoneConfig': zone_config.to_json(),
|
|
165
|
+
'recordsToAdd': [r.to_json() for r in records_to_add],
|
|
166
|
+
'recordsToModify': [r.to_json() for r in records_to_modify],
|
|
167
|
+
'recordsToDelete': [r.to_json() for r in records_to_delete],
|
|
168
|
+
}
|
|
169
|
+
)
|
|
170
|
+
return Zone.from_json(response.get('response', {}))
|
|
171
|
+
|
|
172
|
+
def delete(self, zone_config_id: str) -> None:
|
|
173
|
+
self._call(
|
|
174
|
+
method='zoneDelete',
|
|
175
|
+
parameters={'zoneConfigId': zone_config_id}
|
|
176
|
+
)
|
|
177
|
+
|
|
178
|
+
def purge_restorable(self, zone_config_id: str) -> None:
|
|
179
|
+
self._call(
|
|
180
|
+
method='zonePurgeRestorable',
|
|
181
|
+
parameters={'zoneConfigId': zone_config_id}
|
|
182
|
+
)
|
|
183
|
+
|
|
184
|
+
def change_content(self, record_type: RecordType, old_content: str, new_content: str,
|
|
185
|
+
include_templates: bool, include_sub_accounts: bool) -> None:
|
|
186
|
+
self._call(
|
|
187
|
+
method='changeContent',
|
|
188
|
+
parameters={
|
|
189
|
+
'recordType': record_type,
|
|
190
|
+
'oldContent': old_content,
|
|
191
|
+
'newContent': new_content,
|
|
192
|
+
'includeTemplates': include_templates,
|
|
193
|
+
'includeSubAccounts': include_sub_accounts,
|
|
194
|
+
}
|
|
195
|
+
)
|
|
196
|
+
|
|
197
|
+
def untie_from_templates(self, zone_config_ids: Iterable[str] | None = None,
|
|
198
|
+
zone_config_names: Iterable[str] | None = None) -> None:
|
|
199
|
+
parameters = {}
|
|
200
|
+
if zone_config_ids:
|
|
201
|
+
parameters['zoneConfigIds'] = list(zone_config_ids)
|
|
202
|
+
elif zone_config_names:
|
|
203
|
+
parameters['zoneConfigNames'] = list(zone_config_names)
|
|
204
|
+
else:
|
|
205
|
+
raise ValueError('Either zone config ids or zone config names are required')
|
|
206
|
+
self._call(
|
|
207
|
+
method='zonesUntieFromTemplates',
|
|
208
|
+
parameters=parameters
|
|
209
|
+
)
|
|
210
|
+
|
|
211
|
+
def tie_to_templates(self, zone_config_ids: Iterable[str] | None = None,
|
|
212
|
+
zone_config_names: Iterable[str] | None = None) -> None:
|
|
213
|
+
parameters = {}
|
|
214
|
+
if zone_config_ids:
|
|
215
|
+
parameters['zoneConfigIds'] = list(zone_config_ids)
|
|
216
|
+
elif zone_config_names:
|
|
217
|
+
parameters['zoneConfigNames'] = list(zone_config_names)
|
|
218
|
+
else:
|
|
219
|
+
raise ValueError('Either zone config ids or zone config names are required')
|
|
220
|
+
self._call(
|
|
221
|
+
method='zonesTieToTemplates',
|
|
222
|
+
parameters=parameters
|
|
223
|
+
)
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
class NameserverSet(Element):
|
|
227
|
+
id: str | None
|
|
228
|
+
account_id: str | None
|
|
229
|
+
name: str
|
|
230
|
+
default_nameserver_set: bool | None
|
|
231
|
+
nameservers: Iterable[str]
|
|
232
|
+
# undocumented
|
|
233
|
+
type: str | None
|
|
234
|
+
add_date: datetime | None
|
|
235
|
+
last_change_date: datetime | None
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
class NameserverSetService(CrudService[NameserverSet]):
|
|
239
|
+
def get_default(self) -> NameserverSet:
|
|
240
|
+
response = self._call(
|
|
241
|
+
method='nameserverSetGetDefault',
|
|
242
|
+
)
|
|
243
|
+
return NameserverSet.from_json(response.get('response', {}))
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
class Template(Element):
|
|
247
|
+
id: str | None
|
|
248
|
+
account_id: str | None
|
|
249
|
+
name: str | None
|
|
250
|
+
# undocumented
|
|
251
|
+
email_address: str | None
|
|
252
|
+
add_date: datetime | None
|
|
253
|
+
last_change_date: datetime | None
|
|
254
|
+
|
|
255
|
+
def __init__(self, **kwargs):
|
|
256
|
+
super().__init__(**kwargs)
|
|
257
|
+
if not self.id and not self.name:
|
|
258
|
+
raise ValueError('Either id or name are required.')
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
class RecordTemplate(Element):
|
|
262
|
+
id: str | None
|
|
263
|
+
template_id: str | None
|
|
264
|
+
name: str | None
|
|
265
|
+
type: RecordType
|
|
266
|
+
content: str
|
|
267
|
+
ttl: int | None
|
|
268
|
+
priority: int | None
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
class TemplateService(Service[Template]):
|
|
272
|
+
def create(self, template: Template, record_templates: Iterable[RecordTemplate]) -> Template:
|
|
273
|
+
response = self._call(
|
|
274
|
+
method='templateCreate',
|
|
275
|
+
parameters={
|
|
276
|
+
'dnsTemplate': template.to_json(),
|
|
277
|
+
'recordTemplates': [r.to_json() for r in record_templates]
|
|
278
|
+
}
|
|
279
|
+
)
|
|
280
|
+
return Template.from_json(response.get('response', {}))
|
|
281
|
+
|
|
282
|
+
def recreate(self, template: Template, record_templates: Iterable[RecordTemplate],
|
|
283
|
+
replacements: TemplateReplacements | None = None) -> Template:
|
|
284
|
+
parameters = {
|
|
285
|
+
'dnsTemplate': template.to_json(),
|
|
286
|
+
'recordTemplates': [r.to_json() for r in record_templates]
|
|
287
|
+
}
|
|
288
|
+
if replacements:
|
|
289
|
+
parameters['replacements'] = replacements.to_json()
|
|
290
|
+
response = self._call(
|
|
291
|
+
method='templateRecreate',
|
|
292
|
+
parameters=parameters
|
|
293
|
+
)
|
|
294
|
+
return Template.from_json(response.get('response', {}))
|
|
295
|
+
|
|
296
|
+
def update(self, template: Template,
|
|
297
|
+
record_templates_to_add: Iterable[RecordTemplate],
|
|
298
|
+
record_templates_to_delete: Iterable[RecordTemplate],
|
|
299
|
+
replacements: TemplateReplacements | None = None) -> Template:
|
|
300
|
+
parameters = {
|
|
301
|
+
'dnsTemplate': template.to_json(),
|
|
302
|
+
'recordTemplatesToAdd': [r.to_json() for r in record_templates_to_add],
|
|
303
|
+
'recordTemplatesToDelete': [r.to_json() for r in record_templates_to_delete],
|
|
304
|
+
}
|
|
305
|
+
if replacements:
|
|
306
|
+
parameters['replacements'] = replacements.to_json()
|
|
307
|
+
response = self._call(
|
|
308
|
+
method='templateUpdate',
|
|
309
|
+
parameters=parameters
|
|
310
|
+
)
|
|
311
|
+
return Template.from_json(response.get('response', {}))
|
|
312
|
+
|
|
313
|
+
def delete(self, template_id: str | None = None, template_name: str | None = None) -> None:
|
|
314
|
+
parameters = {}
|
|
315
|
+
if template_id:
|
|
316
|
+
parameters['templateId'] = template_id
|
|
317
|
+
elif template_name:
|
|
318
|
+
parameters['templateName'] = template_name
|
|
319
|
+
else:
|
|
320
|
+
raise ValueError('Either id or name are required.')
|
|
321
|
+
self._call(
|
|
322
|
+
method='templateDelete',
|
|
323
|
+
parameters=parameters
|
|
324
|
+
)
|
httpnet/domain.py
ADDED
|
@@ -0,0 +1,372 @@
|
|
|
1
|
+
from collections.abc import Iterable, Sequence
|
|
2
|
+
from datetime import datetime
|
|
3
|
+
from enum import Enum
|
|
4
|
+
from typing import Any
|
|
5
|
+
|
|
6
|
+
from httpnet._core import Element, Service
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class ContactType(Enum):
|
|
10
|
+
PERSON = 'person'
|
|
11
|
+
ORGANIZATION = 'org'
|
|
12
|
+
ROLE = 'role'
|
|
13
|
+
|
|
14
|
+
def __repr__(self):
|
|
15
|
+
return f'{self.__class__.__qualname__}.{self.name}'
|
|
16
|
+
|
|
17
|
+
def __str__(self):
|
|
18
|
+
return self.value
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class Contact(Element):
|
|
22
|
+
account_id: str | None
|
|
23
|
+
id: str | None
|
|
24
|
+
handle: str | None
|
|
25
|
+
type: ContactType
|
|
26
|
+
name: str
|
|
27
|
+
organization: str | None
|
|
28
|
+
street: Sequence[str]
|
|
29
|
+
postal_code: str | None
|
|
30
|
+
city: str
|
|
31
|
+
state: str | None
|
|
32
|
+
country: str
|
|
33
|
+
email_address: str
|
|
34
|
+
phone_number: str
|
|
35
|
+
fax_number: str | None
|
|
36
|
+
sip_uri: str | None
|
|
37
|
+
hidden: bool | None
|
|
38
|
+
usable_by_sub_account: bool | None
|
|
39
|
+
add_date: datetime | None
|
|
40
|
+
last_change_date: datetime | None
|
|
41
|
+
# undocumented
|
|
42
|
+
comments: str | None
|
|
43
|
+
disclose: bool | None
|
|
44
|
+
email_is_verified: bool | None
|
|
45
|
+
ext_aero_identification_number: str | None
|
|
46
|
+
ext_aero_password: str | None
|
|
47
|
+
ext_ca_legal_type: str | None
|
|
48
|
+
ext_cat_intended_usage: str | None
|
|
49
|
+
ext_company_number: str | None
|
|
50
|
+
ext_company_number_country: str | None
|
|
51
|
+
ext_country_of_birth: str | None
|
|
52
|
+
ext_date_of_birth: datetime | None
|
|
53
|
+
ext_foreign_resident_identification_number: str | None
|
|
54
|
+
ext_gender: str | None
|
|
55
|
+
ext_identification_card_country: str | None
|
|
56
|
+
ext_identification_card_issue_date: datetime | None
|
|
57
|
+
ext_identification_card_issuing_authority: str | None
|
|
58
|
+
ext_identification_card_number: str | None
|
|
59
|
+
ext_identification_card_valid_until: datetime | None
|
|
60
|
+
ext_language: str | None
|
|
61
|
+
ext_nationality: str | None
|
|
62
|
+
ext_place_of_birth: str | None
|
|
63
|
+
ext_place_of_birth_postal_code: str | None
|
|
64
|
+
ext_remarks: str | None
|
|
65
|
+
ext_tax_id: str | None
|
|
66
|
+
ext_tax_id_country: str | None
|
|
67
|
+
ext_trade_mark_country: str | None
|
|
68
|
+
ext_trade_mark_date_of_application: datetime | None
|
|
69
|
+
ext_trade_mark_date_of_registration: datetime | None
|
|
70
|
+
ext_trade_mark_name: str | None
|
|
71
|
+
ext_trade_mark_register_number: str | None
|
|
72
|
+
ext_trade_mark_registration_authority: str | None
|
|
73
|
+
ext_trading_name: str | None
|
|
74
|
+
ext_travel_unique_identification_number: str | None
|
|
75
|
+
ext_uk_type: str | None
|
|
76
|
+
ext_vat_id: str | None
|
|
77
|
+
ext_vat_id_country: str | None
|
|
78
|
+
ext_xxx_member_id: str | None
|
|
79
|
+
placeholder_for_unreadable_supplier_contact: str | None
|
|
80
|
+
|
|
81
|
+
def __init__(self, **kwargs):
|
|
82
|
+
super().__init__(**kwargs)
|
|
83
|
+
if not self.id and not self.handle:
|
|
84
|
+
raise ValueError('Either "id" or "handle" are required')
|
|
85
|
+
if self.type == ContactType.ORGANIZATION and not self.organization:
|
|
86
|
+
raise ValueError(f'"The field organization" is required for when type is "{ContactType.ORGANIZATION}"')
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
class ContactService(Service[Contact]):
|
|
90
|
+
"""Contacts are retrieved by filtering ``contactsFind`` for ``ContactId``."""
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
class DomainContactType(Enum):
|
|
94
|
+
OWNER = 'owner'
|
|
95
|
+
ADMIN = 'admin'
|
|
96
|
+
TECH = 'tech'
|
|
97
|
+
ZONE = 'zone'
|
|
98
|
+
|
|
99
|
+
def __repr__(self):
|
|
100
|
+
return f'{self.__class__.__qualname__}.{self.name}'
|
|
101
|
+
|
|
102
|
+
def __str__(self):
|
|
103
|
+
return self.value
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
class DomainContact(Element):
|
|
107
|
+
type: DomainContactType
|
|
108
|
+
contact: str
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
class NameServer(Element):
|
|
112
|
+
name: str
|
|
113
|
+
ips: Iterable[str] | None
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
class DomainStatus(Enum):
|
|
117
|
+
ORDERED = 'ordered'
|
|
118
|
+
ACTIVE = 'active'
|
|
119
|
+
RESTORABLE = 'restorable'
|
|
120
|
+
FAILED = 'failed'
|
|
121
|
+
|
|
122
|
+
def __repr__(self):
|
|
123
|
+
return f'{self.__class__.__qualname__}.{self.name}'
|
|
124
|
+
|
|
125
|
+
def __str__(self):
|
|
126
|
+
return self.value
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
class DeletionType(Enum):
|
|
130
|
+
NONE = ''
|
|
131
|
+
DELETE = 'delete'
|
|
132
|
+
WITHDRAW = 'withdraw'
|
|
133
|
+
|
|
134
|
+
def __repr__(self):
|
|
135
|
+
return f'{self.__class__.__qualname__}.{self.name}'
|
|
136
|
+
|
|
137
|
+
def __str__(self):
|
|
138
|
+
return self.value
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
class Domain(Element):
|
|
142
|
+
name: str
|
|
143
|
+
transfer_lock_enabled: bool
|
|
144
|
+
contacts: Iterable[DomainContact]
|
|
145
|
+
nameservers: Iterable[NameServer]
|
|
146
|
+
id: str | None
|
|
147
|
+
account_id: str | None
|
|
148
|
+
name_unicode: str | None
|
|
149
|
+
status: DomainStatus | None
|
|
150
|
+
auth_info: str | None
|
|
151
|
+
create_date: datetime | None
|
|
152
|
+
current_contract_period_end: datetime | None
|
|
153
|
+
next_contract_period_start: datetime | None
|
|
154
|
+
deletion_type: DeletionType | None
|
|
155
|
+
deletion_date: datetime | None
|
|
156
|
+
add_date: datetime | None
|
|
157
|
+
last_change_date: datetime | None
|
|
158
|
+
# undocumented
|
|
159
|
+
bundle_id: str | None
|
|
160
|
+
deletion_scheduled_for: datetime | None
|
|
161
|
+
dns_sec_entries: Iterable[str] | None
|
|
162
|
+
latest_deletion_date_without_renew: datetime | None
|
|
163
|
+
paid_until: datetime | None
|
|
164
|
+
product_code: str | None
|
|
165
|
+
renew_on: datetime | None
|
|
166
|
+
restorable_until: datetime | None
|
|
167
|
+
restrictions: Iterable[str] | None
|
|
168
|
+
transfer_locked_by_owner_change_until: datetime | None
|
|
169
|
+
trustee_service_enabled: bool | None
|
|
170
|
+
|
|
171
|
+
def __init__(self, **kwargs) -> None:
|
|
172
|
+
super().__init__(**kwargs)
|
|
173
|
+
if not self.name:
|
|
174
|
+
raise ValueError('The field "name" is required')
|
|
175
|
+
if self.transfer_lock_enabled is None:
|
|
176
|
+
raise ValueError('The field "transfer_lock_enabled" is required')
|
|
177
|
+
if self.contacts is None:
|
|
178
|
+
raise ValueError('The field "contacts" is required')
|
|
179
|
+
if self.nameservers is None:
|
|
180
|
+
raise ValueError('The field "nameservers" is required')
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
class DomainAvailability(Enum):
|
|
184
|
+
ALREADY_REGISTERED = 'alreadyRegistered'
|
|
185
|
+
REGISTERED = 'registered'
|
|
186
|
+
NAME_CONTAINS_FORBIDDEN_CHARACTER = 'nameContainsForbiddenCharacter'
|
|
187
|
+
AVAILABLE = 'available'
|
|
188
|
+
SUFFIX_DOES_NOT_EXIST = 'suffixDoesNotExist'
|
|
189
|
+
SUFFIX_CANNOT_BE_REGISTERED = 'suffixCannotBeRegistered'
|
|
190
|
+
CAN_NOT_CHECK = 'canNotCheck'
|
|
191
|
+
UNKNOWN = 'unknown'
|
|
192
|
+
|
|
193
|
+
def __repr__(self):
|
|
194
|
+
return f'{self.__class__.__qualname__}.{self.name}'
|
|
195
|
+
|
|
196
|
+
def __str__(self):
|
|
197
|
+
return self.value
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
class TransferMethod(Enum):
|
|
201
|
+
OUT_OF_BAND = ''
|
|
202
|
+
AUTH_INFO = 'authInfo'
|
|
203
|
+
PUSH = 'push'
|
|
204
|
+
# undocumented, reported for suffixes that are transferred by registrar tag
|
|
205
|
+
PUSH_TAG = 'pushTag'
|
|
206
|
+
|
|
207
|
+
def __repr__(self):
|
|
208
|
+
return f'{self.__class__.__qualname__}.{self.name}'
|
|
209
|
+
|
|
210
|
+
def __str__(self):
|
|
211
|
+
return self.value
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
class DomainStatusResult(Element):
|
|
215
|
+
domain_name: str | None
|
|
216
|
+
domain_name_unicode: str | None
|
|
217
|
+
domain_suffix: str | None
|
|
218
|
+
status: DomainAvailability | None
|
|
219
|
+
transfer_method: TransferMethod | None
|
|
220
|
+
# undocumented
|
|
221
|
+
early_access_start: datetime | None
|
|
222
|
+
extension: str | None
|
|
223
|
+
general_availability_start: datetime | None
|
|
224
|
+
landrush_start: datetime | None
|
|
225
|
+
launch_phase: str | None
|
|
226
|
+
# Nested price structure that is only reported for premium domains. It is
|
|
227
|
+
# passed through unchanged instead of being modelled.
|
|
228
|
+
premium_prices: dict[str, Any] | None
|
|
229
|
+
registrar_tag: str | None
|
|
230
|
+
sunrise_start: datetime | None
|
|
231
|
+
transfer_owner_handling: str | None
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
class FoaRecipientType(Enum):
|
|
235
|
+
ADMIN = 'admin'
|
|
236
|
+
OWNER = 'owner'
|
|
237
|
+
BOTH = 'both'
|
|
238
|
+
|
|
239
|
+
def __repr__(self):
|
|
240
|
+
return f'{self.__class__.__qualname__}.{self.name}'
|
|
241
|
+
|
|
242
|
+
def __str__(self):
|
|
243
|
+
return self.value
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
class TransferData(Element):
|
|
247
|
+
auth_info: str | None
|
|
248
|
+
foa_recipient: FoaRecipientType | None
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
class DomainService(Service[Domain]):
|
|
252
|
+
_id_name = 'domainName'
|
|
253
|
+
|
|
254
|
+
def get(self, key: str, /) -> Domain:
|
|
255
|
+
"""
|
|
256
|
+
Retrieves a domain by its name. Domains are one of the few elements the
|
|
257
|
+
API provides an ``Info`` method for.
|
|
258
|
+
|
|
259
|
+
:param key: Name of the domain
|
|
260
|
+
:return: The domain
|
|
261
|
+
:raises ServiceException: if no domain with this name exists
|
|
262
|
+
"""
|
|
263
|
+
return self._get_by_info(key)
|
|
264
|
+
|
|
265
|
+
def status(self, *names: str) -> Iterable[DomainStatusResult]:
|
|
266
|
+
response = self._call(
|
|
267
|
+
method='domainStatus',
|
|
268
|
+
parameters={'domainNames': list(names)}
|
|
269
|
+
)
|
|
270
|
+
responses = response.get('responses', [])
|
|
271
|
+
return [DomainStatusResult.from_json(dsr) for dsr in responses]
|
|
272
|
+
|
|
273
|
+
def delete(self, name: str, exec_date: datetime | None = None) -> None:
|
|
274
|
+
parameters = {
|
|
275
|
+
'domainName': name,
|
|
276
|
+
}
|
|
277
|
+
if exec_date is not None:
|
|
278
|
+
parameters['execDate'] = exec_date.isoformat()
|
|
279
|
+
self._call(
|
|
280
|
+
method='domainDelete',
|
|
281
|
+
parameters=parameters
|
|
282
|
+
)
|
|
283
|
+
|
|
284
|
+
def withdraw(self, name: str, disconnect: bool, exec_date: datetime | None = None) -> None:
|
|
285
|
+
parameters = {
|
|
286
|
+
'domainName': name,
|
|
287
|
+
'disconnect': disconnect,
|
|
288
|
+
}
|
|
289
|
+
if exec_date is not None:
|
|
290
|
+
parameters['execDate'] = exec_date.isoformat()
|
|
291
|
+
self._call(
|
|
292
|
+
method='domainWithdraw',
|
|
293
|
+
parameters=parameters
|
|
294
|
+
)
|
|
295
|
+
|
|
296
|
+
def cancel_deletion(self, name: str) -> None:
|
|
297
|
+
self._call(
|
|
298
|
+
method='domainDeletionCancel',
|
|
299
|
+
parameters={'domainName': name}
|
|
300
|
+
)
|
|
301
|
+
|
|
302
|
+
def transfer(self, domain: Domain, transfer_data: TransferData) -> None:
|
|
303
|
+
self._call(
|
|
304
|
+
method='domainTransfer',
|
|
305
|
+
parameters={'domain': domain.to_json(), 'transferData': transfer_data.to_json()}
|
|
306
|
+
)
|
|
307
|
+
|
|
308
|
+
def acknowledge_transfer(self, name: str) -> None:
|
|
309
|
+
self._call(
|
|
310
|
+
method='domainTransferOutAck',
|
|
311
|
+
parameters={'domainName': name}
|
|
312
|
+
)
|
|
313
|
+
|
|
314
|
+
def restore(self, name: str) -> None:
|
|
315
|
+
self._call(
|
|
316
|
+
method='domainRestore',
|
|
317
|
+
parameters={'domainName': name}
|
|
318
|
+
)
|
|
319
|
+
|
|
320
|
+
def request_authinfo2(self, name: str) -> None:
|
|
321
|
+
self._call(
|
|
322
|
+
method='domainCreateAuthInfo2',
|
|
323
|
+
parameters={'domainName': name}
|
|
324
|
+
)
|
|
325
|
+
|
|
326
|
+
|
|
327
|
+
class JobEvent(Element):
|
|
328
|
+
action: str
|
|
329
|
+
data: str
|
|
330
|
+
execution_date: datetime
|
|
331
|
+
|
|
332
|
+
|
|
333
|
+
class JobTrigger(Element):
|
|
334
|
+
account_id: str
|
|
335
|
+
account_name: str
|
|
336
|
+
api_key_id: str
|
|
337
|
+
api_key_name: str
|
|
338
|
+
user_id: str
|
|
339
|
+
user_name: str
|
|
340
|
+
|
|
341
|
+
|
|
342
|
+
class Job(Element):
|
|
343
|
+
id: str
|
|
344
|
+
account_id: str
|
|
345
|
+
display_name: str
|
|
346
|
+
domain_name_ace: str
|
|
347
|
+
domain_name_unicode: str
|
|
348
|
+
handle: str
|
|
349
|
+
type: str
|
|
350
|
+
state: str
|
|
351
|
+
errors: str
|
|
352
|
+
warnings: str
|
|
353
|
+
client_transaction_id: str
|
|
354
|
+
server_transaction_id: str
|
|
355
|
+
execution_date: datetime
|
|
356
|
+
add_date: datetime
|
|
357
|
+
last_change_date: datetime
|
|
358
|
+
# undocumented
|
|
359
|
+
action: str
|
|
360
|
+
comments: str
|
|
361
|
+
events: Iterable[JobEvent]
|
|
362
|
+
object_id: str
|
|
363
|
+
object_type: str
|
|
364
|
+
# The API reports these alongside ``state``.
|
|
365
|
+
sub_state: str
|
|
366
|
+
status: str
|
|
367
|
+
sub_status: str
|
|
368
|
+
triggered_by: JobTrigger
|
|
369
|
+
|
|
370
|
+
|
|
371
|
+
class JobService(Service[Job]):
|
|
372
|
+
"""Jobs are created by the API itself and can only be queried."""
|