forked from linode/linode_api4-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnodebalancer.py
More file actions
39 lines (33 loc) · 1.3 KB
/
Copy pathnodebalancer.py
File metadata and controls
39 lines (33 loc) · 1.3 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
from .. import Base, Property
from ..base import MappedObject
from ..networking.ipaddress import IPAddress
from ..region import Region
from .config import NodeBalancerConfig
class NodeBalancer(Base):
api_name = 'nodebalancers'
api_endpoint = '/nodebalancers/{id}'
properties = {
'id': Property(identifier=True),
'label': Property(mutable=True),
'hostname': Property(),
'client_conn_throttle': Property(mutable=True),
'status': Property(),
'created': Property(is_datetime=True),
'updated': Property(is_datetime=True),
'ipv4': Property(relationship=IPAddress),
'ipv6': Property(),
'region': Property(relationship=Region, filterable=True),
'configs': Property(derived_class=NodeBalancerConfig),
}
# create derived objects
def create_config(self, label=None, **kwargs):
params = kwargs
if label:
params['label'] = label
result = self._client.post("{}/configs".format(NodeBalancer.api_endpoint), model=self, data=params)
self.invalidate()
if not 'id' in result:
raise UnexpectedResponseError('Unexpected response creating config!', json=result)
c = NodeBalancerConfig(self._client, result['id'], self.id)
c._populate(result)
return c