1+ from upcloud_api .api import API
12from upcloud_api .ip_address import IPAddress
23
34
@@ -6,20 +7,22 @@ class IPManager:
67 Functions for managing IP-addresses. Intended to be used as a mixin for CloudManager.
78 """
89
10+ api : API
11+
912 def get_ip (self , address : str ) -> IPAddress :
1013 """
1114 Get an IPAddress object with the IP address (string) from the API.
1215
1316 e.g manager.get_ip('80.69.175.210')
1417 """
15- res = self .get_request ('/ip_address/' + address )
18+ res = self .api . get_request ('/ip_address/' + address )
1619 return IPAddress (cloud_manager = self , ** res ['ip_address' ])
1720
1821 def get_ips (self , ignore_ips_without_server = False ):
1922 """
2023 Get all IPAddress objects from the API.
2124 """
22- res = self .get_request ('/ip_address' )
25+ res = self .api . get_request ('/ip_address' )
2326 IPs = IPAddress ._create_ip_address_objs (
2427 res ['ip_addresses' ], self , ignore_ips_without_server
2528 )
@@ -31,7 +34,7 @@ def attach_ip(self, server: str, family: str = 'IPv4') -> IPAddress:
3134 """
3235 body = {'ip_address' : {'server' : str (server ), 'family' : family }}
3336
34- res = self .post_request ('/ip_address' , body )
37+ res = self .api . post_request ('/ip_address' , body )
3538 return IPAddress (cloud_manager = self , ** res ['ip_address' ])
3639
3740 def modify_ip (self , ip_addr : str , ptr_record : str ) -> IPAddress :
@@ -42,7 +45,7 @@ def modify_ip(self, ip_addr: str, ptr_record: str) -> IPAddress:
4245 """
4346 body = {'ip_address' : {'ptr_record' : ptr_record }}
4447
45- res = self .put_request ('/ip_address/' + str (ip_addr ), body )
48+ res = self .api . put_request ('/ip_address/' + str (ip_addr ), body )
4649 return IPAddress (cloud_manager = self , ** res ['ip_address' ])
4750
4851 def release_ip (self , ip_addr ):
@@ -51,4 +54,4 @@ def release_ip(self, ip_addr):
5154
5255 Accepts an IPAddress instance (object) or its address (string).
5356 """
54- return self .delete_request ('/ip_address/' + str (ip_addr ))
57+ return self .api . delete_request ('/ip_address/' + str (ip_addr ))
0 commit comments