Skip to content

Commit cfdc8a1

Browse files
authored
Add documentation to objects/nodebalancer (#274)
## 📝 Description Add documentations to endpoint wrapper methods and resources classes under objects/nodebalancer. https://jira.linode.com/browse/TPT-1930
1 parent 6bbea84 commit cfdc8a1

2 files changed

Lines changed: 57 additions & 3 deletions

File tree

linode_api4/objects/nodebalancer.py

Lines changed: 55 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@
66

77

88
class NodeBalancerNode(DerivedBase):
9+
"""
10+
The information about a single Node, a backend for this NodeBalancer’s configured port.
11+
12+
API documentation: https://www.linode.com/docs/api/nodebalancers/#node-view
13+
"""
14+
915
api_endpoint = (
1016
"/nodebalancers/{nodebalancer_id}/configs/{config_id}/nodes/{id}"
1117
)
@@ -45,6 +51,12 @@ def __init__(self, client, id, parent_id, nodebalancer_id=None, json=None):
4551

4652

4753
class NodeBalancerConfig(DerivedBase):
54+
"""
55+
The configuration information for a single port of this NodeBalancer.
56+
57+
API documentation: https://www.linode.com/docs/api/nodebalancers/#config-view
58+
"""
59+
4860
api_endpoint = "/nodebalancers/{nodebalancer_id}/configs/{id}"
4961
derived_url_path = "configs"
5062
parent_id_name = "nodebalancer_id"
@@ -77,6 +89,14 @@ def nodes(self):
7789
"""
7890
This is a special derived_class relationship because NodeBalancerNode is the
7991
only api object that requires two parent_ids
92+
93+
Returns a paginated list of NodeBalancer nodes associated with this Config.
94+
These are the backends that will be sent traffic for this port.
95+
96+
API documentation: https://www.linode.com/docs/api/nodebalancers/#nodes-list
97+
98+
:returns: A paginated list of NodeBalancer nodes.
99+
:rtype: PaginatedList of NodeBalancerNode
80100
"""
81101
if not hasattr(self, "_nodes"):
82102
base_url = "{}/{}".format(
@@ -95,6 +115,24 @@ def nodes(self):
95115
return self._nodes
96116

97117
def node_create(self, label, address, **kwargs):
118+
"""
119+
Creates a NodeBalancer Node, a backend that can accept traffic for this
120+
NodeBalancer Config. Nodes are routed requests on the configured port based
121+
on their status.
122+
123+
API documentation: https://www.linode.com/docs/api/nodebalancers/#node-create
124+
125+
:param address: The private IP Address where this backend can be reached.
126+
This must be a private IP address.
127+
:type address: str
128+
129+
:param label: The label for this node. This is for display purposes only.
130+
Must have a length between 2 and 32 characters.
131+
:type label: str
132+
133+
:returns: The node which is created successfully.
134+
:rtype: NodeBalancerNode
135+
"""
98136
params = {
99137
"label": label,
100138
"address": address,
@@ -152,6 +190,12 @@ def load_ssl_data(self, cert_file, key_file):
152190

153191

154192
class NodeBalancer(Base):
193+
"""
194+
A single NodeBalancer you can access.
195+
196+
API documentation: https://www.linode.com/docs/api/nodebalancers/#nodebalancer-view
197+
"""
198+
155199
api_endpoint = "/nodebalancers/{id}"
156200
properties = {
157201
"id": Property(identifier=True),
@@ -168,10 +212,18 @@ class NodeBalancer(Base):
168212
}
169213

170214
# create derived objects
171-
def config_create(self, label=None, **kwargs):
215+
def config_create(self, **kwargs):
216+
"""
217+
Creates a NodeBalancer Config, which allows the NodeBalancer to accept traffic
218+
on a new port. You will need to add NodeBalancer Nodes to the new Config before
219+
it can actually serve requests.
220+
221+
API documentation: https://www.linode.com/docs/api/nodebalancers/#config-create
222+
223+
:returns: The config that created successfully.
224+
:rtype: NodeBalancerConfig
225+
"""
172226
params = kwargs
173-
if label:
174-
params["label"] = label
175227

176228
result = self._client.post(
177229
"{}/configs".format(NodeBalancer.api_endpoint),

linode_api4/objects/object_storage.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ class ObjectStorageACL:
2020
class ObjectStorageBucket(DerivedBase):
2121
"""
2222
A bucket where objects are stored in.
23+
24+
API documentation: https://www.linode.com/docs/api/object-storage/#object-storage-bucket-view
2325
"""
2426

2527
api_endpoint = "/object-storage/buckets/{cluster}/{label}"

0 commit comments

Comments
 (0)