forked from linode/linode_api4-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnode.py
More file actions
36 lines (30 loc) · 1.29 KB
/
Copy pathnode.py
File metadata and controls
36 lines (30 loc) · 1.29 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
from .. import DerivedBase, Property
from ..base import MappedObject
class NodeBalancerNode(DerivedBase):
api_name = 'nodes'
api_endpoint = '/nodebalancers/{nodebalancer_id}/configs/{config_id}/nodes/{id}'
derived_url_path = 'nodes'
parent_id_name='config_id'
properties = {
'id': Property(identifier=True),
'config_id': Property(identifier=True),
'nodebalancer_id': Property(identifier=True),
"label": Property(mutable=True),
"address": Property(mutable=True),
"weight": Property(mutable=True),
"mode": Property(mutable=True),
"status": Property(),
}
def __init__(self, client, id, parent_id, nodebalancer_id=None):
"""
We need a special constructor here because this object's parent
has a parent itself.
"""
if not nodebalancer_id and not isinstance(parent_id, tuple):
raise ValueError('NodeBalancerNode must either be created with a nodebalancer_id or a tuple of '
'(config_id, nodebalancer_id) for parent_id!')
if isinstance(parent_id, tuple):
nodebalancer_id = parent_id[1]
parent_id = parent_id[0]
DerivedBase.__init__(self, client, id, parent_id)
self._set('nodebalancer_id', nodebalancer_id)