Skip to content

Commit ebda977

Browse files
committed
Use from_dict method
1 parent 1355bbd commit ebda977

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

hcloud/networks/client.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ class BoundNetwork(BoundModelBase):
1212
def __init__(self, client, data, complete=True):
1313
subnets = data.get("subnets", [])
1414
if subnets is not None:
15-
subnets = [NetworkSubnet(type=subnet['type'], ip_range=subnet['ip_range'], gateway=subnet['gateway'], network_zone=subnet['network_zone']) for subnet in subnets]
15+
subnets = [NetworkSubnet.from_dict(subnet) for subnet in subnets]
1616
data['subnets'] = subnets
1717

1818
routes = data.get("routes", [])
1919
if routes is not None:
20-
routes = [NetworkRoute(**route) for route in routes]
20+
routes = [NetworkRoute.from_dict(route) for route in routes]
2121
data['routes'] = routes
2222

2323
from hcloud.servers.client import BoundServer
@@ -346,9 +346,10 @@ def add_subnet(self, network, subnet):
346346
"""
347347
data = {
348348
"type": subnet.type,
349-
"ip_range": subnet.ip_range,
350349
"network_zone": subnet.network_zone,
351350
}
351+
if subnet.ip_range is not None:
352+
data["ip_range"] = subnet.ip_range
352353

353354
response = self._client.request(
354355
url="/networks/{network_id}/actions/add_subnet".format(network_id=network.id),

0 commit comments

Comments
 (0)