forked from linode/linode_api4-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdomain.py
More file actions
60 lines (50 loc) · 2.07 KB
/
Copy pathdomain.py
File metadata and controls
60 lines (50 loc) · 2.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
from linode_api4.errors import UnexpectedResponseError
from linode_api4.objects import Base, DerivedBase, Property
class DomainRecord(DerivedBase):
api_endpoint = "/domains/{domain_id}/records/{id}"
derived_url_path = "records"
parent_id_name = "domain_id"
properties = {
'id': Property(identifier=True),
'domain_id': Property(identifier=True),
'type': Property(),
'name': Property(mutable=True, filterable=True),
'target': Property(mutable=True, filterable=True),
'priority': Property(mutable=True),
'weight': Property(mutable=True),
'port': Property(mutable=True),
'service': Property(mutable=True),
'protocol': Property(mutable=True),
'ttl_sec': Property(mutable=True),
'tag': Property(mutable=True),
}
class Domain(Base):
api_endpoint = "/domains/{id}"
properties = {
'id': Property(identifier=True),
'domain': Property(mutable=True, filterable=True),
'group': Property(mutable=True, filterable=True),
'description': Property(mutable=True),
'status': Property(mutable=True),
'soa_email': Property(mutable=True),
'retry_sec': Property(mutable=True),
'master_ips': Property(mutable=True, filterable=True),
'axfr_ips': Property(mutable=True),
'expire_sec': Property(mutable=True),
'refresh_sec': Property(mutable=True),
'ttl_sec': Property(mutable=True),
'records': Property(derived_class=DomainRecord),
'type': Property(mutable=True),
'tags': Property(mutable=True),
}
def record_create(self, record_type, **kwargs):
params = {
"type": record_type,
}
params.update(kwargs)
result = self._client.post("{}/records".format(Domain.api_endpoint), model=self, data=params)
self.invalidate()
if not 'id' in result:
raise UnexpectedResponseError('Unexpected response creating domain record!', json=result)
zr = DomainRecord(self._client, result['id'], self.id, result)
return zr