@@ -44,7 +44,7 @@ def delete(self):
4444 # type: () -> BoundAction
4545 """Deletes a network.
4646
47- :return: :class:`BoundAction <hcloud.actions.client.BoundAction>`
47+ :return: boolean
4848 """
4949 return self ._client .delete (self )
5050
@@ -245,12 +245,12 @@ def delete(self, network):
245245 """Deletes a network.
246246
247247 :param network: :class:`BoundNetwork <hcloud.networks.client.BoundNetwork>` or :class:`Network <hcloud.networks.domain.Network>`
248- :return: :class:`BoundAction <hcloud.actions.client.BoundAction>`
248+ :return: boolean
249249 """
250- response = self ._client .request (
250+ self ._client .request (
251251 url = "/networks/{network_id}" .format (network_id = network .id ), method = "DELETE"
252252 )
253- return BoundAction ( self . _client . actions , response [ "action" ])
253+ return True
254254
255255 def get_actions_list (
256256 self , network , status = None , sort = None , page = None , per_page = None
@@ -307,28 +307,97 @@ def get_actions(self, network, status=None, sort=None):
307307
308308 def add_subnet (self , network , subnet ):
309309 # type: (Union[Network, BoundNetwork], NetworkSubnet) -> List[BoundAction]
310- # TODO
311- pass
310+ """Adds a subnet entry to a network.
311+
312+ :param network: :class:`BoundNetwork <hcloud.networks.client.BoundNetwork>` or :class:`Network <hcloud.networks.domain.Network>`
313+ :param subnet: :class:`NetworkSubnet <hcloud.networks.domain.NetworkSubnet>`
314+ The NetworkSubnet you want to add to the Network
315+ :return: :class:`BoundAction <hcloud.actions.client.BoundAction>`
316+ """
317+ data = {
318+ "type" : subnet .type ,
319+ "ip_range" : subnet .ip_range ,
320+ "network_zone" : subnet .network_zone ,
321+ }
312322
313- def remove_subnet (self , network , subnet ):
323+ response = self ._client .request (
324+ url = "/networks/{network_id}/actions/add_subnet" .format (network_id = network .id ),
325+ method = "POST" , json = data )
326+ return BoundAction (self ._client .actions , response ['action' ])
327+
328+ def delete_subnet (self , network , subnet ):
314329 # type: (Union[Network, BoundNetwork], NetworkSubnet) -> List[BoundAction]
315- # TODO
316- pass
330+ """Removes a subnet entry from a network
331+
332+ :param network: :class:`BoundNetwork <hcloud.networks.client.BoundNetwork>` or :class:`Network <hcloud.networks.domain.Network>`
333+ :param subnet: :class:`NetworkSubnet <hcloud.networks.domain.NetworkSubnet>`
334+ The NetworkSubnet you want to remove from the Network
335+ :return: :class:`BoundAction <hcloud.actions.client.BoundAction>`
336+ """
337+ data = {
338+ "ip_range" : subnet .ip_range ,
339+ }
340+
341+ response = self ._client .request (
342+ url = "/networks/{network_id}/actions/delete_subnet" .format (network_id = network .id ),
343+ method = "POST" , json = data )
344+ return BoundAction (self ._client .actions , response ['action' ])
317345
318346 def add_route (self , network , route ):
319347 # type: (Union[Network, BoundNetwork], NetworkRoute) -> List[BoundAction]
320- # TODO
321- pass
348+ """Adds a route entry to a network.
349+
350+ :param network: :class:`BoundNetwork <hcloud.networks.client.BoundNetwork>` or :class:`Network <hcloud.networks.domain.Network>`
351+ :param route: :class:`NetworkRoute <hcloud.networks.domain.NetworkRoute>`
352+ The NetworkRoute you want to add to the Network
353+ :return: :class:`BoundAction <hcloud.actions.client.BoundAction>`
354+ """
355+ data = {
356+ "destination" : route .destination ,
357+ "gateway" : route .gateway ,
358+ }
322359
323- def remove_route (self , network , route ):
360+ response = self ._client .request (
361+ url = "/networks/{network_id}/actions/add_route" .format (network_id = network .id ),
362+ method = "POST" , json = data )
363+ return BoundAction (self ._client .actions , response ['action' ])
364+
365+ def delete_route (self , network , route ):
324366 # type: (Union[Network, BoundNetwork], NetworkRoute) -> List[BoundAction]
325- # TODO
326- pass
367+ """Removes a route entry to a network.
368+
369+ :param network: :class:`BoundNetwork <hcloud.networks.client.BoundNetwork>` or :class:`Network <hcloud.networks.domain.Network>`
370+ :param route: :class:`NetworkRoute <hcloud.networks.domain.NetworkRoute>`
371+ The NetworkRoute you want to remove from the Network
372+ :return: :class:`BoundAction <hcloud.actions.client.BoundAction>`
373+ """
374+ data = {
375+ "destination" : route .destination ,
376+ "gateway" : route .gateway ,
377+ }
378+
379+ response = self ._client .request (
380+ url = "/networks/{network_id}/actions/delete_route" .format (network_id = network .id ),
381+ method = "POST" , json = data )
382+ return BoundAction (self ._client .actions , response ['action' ])
327383
328384 def change_ip_range (self , network , ip_range ):
329385 # type: (Union[Network, BoundNetwork], str) -> List[BoundAction]
330- # TODO
331- pass
386+ """Changes the IP range of a network.
387+
388+ :param network: :class:`BoundNetwork <hcloud.networks.client.BoundNetwork>` or :class:`Network <hcloud.networks.domain.Network>`
389+ :param ip_range: str
390+ The new prefix for the whole network.
391+ :return: :class:`BoundAction <hcloud.actions.client.BoundAction>`
392+ """
393+ data = {
394+ "ip_range" : ip_range ,
395+ }
396+
397+ response = self ._client .request (
398+ url = "/networks/{network_id}/actions/change_ip_range" .format (network_id = network .id ),
399+ method = "POST" , json = data )
400+ return BoundAction (self ._client .actions , response ['action' ])
332401
333402 def change_protection (self , network , delete = None ):
334403 # type: (Union[Network, BoundNetwork], Optional[bool]) -> BoundAction
0 commit comments