@@ -140,6 +140,7 @@ class FloatingIPsPageResult(NamedTuple):
140140
141141
142142class FloatingIPsClient (ResourceClientBase ):
143+ _base_url = "/floating_ips"
143144
144145 actions : ResourceActionsClient
145146 """Floating IPs scoped actions client
@@ -149,7 +150,7 @@ class FloatingIPsClient(ResourceClientBase):
149150
150151 def __init__ (self , client : Client ):
151152 super ().__init__ (client )
152- self .actions = ResourceActionsClient (client , "/floating_ips" )
153+ self .actions = ResourceActionsClient (client , self . _base_url )
153154
154155 def get_actions_list (
155156 self ,
@@ -182,7 +183,7 @@ def get_actions_list(
182183 if per_page is not None :
183184 params ["per_page" ] = per_page
184185 response = self ._client .request (
185- url = f"/floating_ips /{ floating_ip .id } /actions" ,
186+ url = f"{ self . _base_url } /{ floating_ip .id } /actions" ,
186187 method = "GET" ,
187188 params = params ,
188189 )
@@ -221,7 +222,7 @@ def get_by_id(self, id: int) -> BoundFloatingIP:
221222 :param id: int
222223 :return: :class:`BoundFloatingIP <hcloud.floating_ips.client.BoundFloatingIP>`
223224 """
224- response = self ._client .request (url = f"/floating_ips /{ id } " , method = "GET" )
225+ response = self ._client .request (url = f"{ self . _base_url } /{ id } " , method = "GET" )
225226 return BoundFloatingIP (self , response ["floating_ip" ])
226227
227228 def get_list (
@@ -254,9 +255,7 @@ def get_list(
254255 if name is not None :
255256 params ["name" ] = name
256257
257- response = self ._client .request (
258- url = "/floating_ips" , method = "GET" , params = params
259- )
258+ response = self ._client .request (url = self ._base_url , method = "GET" , params = params )
260259 floating_ips = [
261260 BoundFloatingIP (self , floating_ip_data )
262261 for floating_ip_data in response ["floating_ips" ]
@@ -324,7 +323,7 @@ def create(
324323 if name is not None :
325324 data ["name" ] = name
326325
327- response = self ._client .request (url = "/floating_ips" , json = data , method = "POST" )
326+ response = self ._client .request (url = self . _base_url , json = data , method = "POST" )
328327
329328 action = None
330329 if response .get ("action" ) is not None :
@@ -362,7 +361,7 @@ def update(
362361 data ["name" ] = name
363362
364363 response = self ._client .request (
365- url = f"/floating_ips /{ floating_ip .id } " ,
364+ url = f"{ self . _base_url } /{ floating_ip .id } " ,
366365 method = "PUT" ,
367366 json = data ,
368367 )
@@ -375,7 +374,7 @@ def delete(self, floating_ip: FloatingIP | BoundFloatingIP) -> bool:
375374 :return: boolean
376375 """
377376 self ._client .request (
378- url = f"/floating_ips /{ floating_ip .id } " ,
377+ url = f"{ self . _base_url } /{ floating_ip .id } " ,
379378 method = "DELETE" ,
380379 )
381380 # Return always true, because the API does not return an action for it. When an error occurs a HcloudAPIException will be raised
@@ -398,7 +397,7 @@ def change_protection(
398397 data .update ({"delete" : delete })
399398
400399 response = self ._client .request (
401- url = f"/floating_ips /{ floating_ip .id } /actions/change_protection" ,
400+ url = f"{ self . _base_url } /{ floating_ip .id } /actions/change_protection" ,
402401 method = "POST" ,
403402 json = data ,
404403 )
@@ -417,7 +416,7 @@ def assign(
417416 :return: :class:`BoundAction <hcloud.actions.client.BoundAction>`
418417 """
419418 response = self ._client .request (
420- url = f"/floating_ips /{ floating_ip .id } /actions/assign" ,
419+ url = f"{ self . _base_url } /{ floating_ip .id } /actions/assign" ,
421420 method = "POST" ,
422421 json = {"server" : server .id },
423422 )
@@ -430,7 +429,7 @@ def unassign(self, floating_ip: FloatingIP | BoundFloatingIP) -> BoundAction:
430429 :return: :class:`BoundAction <hcloud.actions.client.BoundAction>`
431430 """
432431 response = self ._client .request (
433- url = f"/floating_ips /{ floating_ip .id } /actions/unassign" ,
432+ url = f"{ self . _base_url } /{ floating_ip .id } /actions/unassign" ,
434433 method = "POST" ,
435434 )
436435 return BoundAction (self ._parent .actions , response ["action" ])
@@ -451,7 +450,7 @@ def change_dns_ptr(
451450 :return: :class:`BoundAction <hcloud.actions.client.BoundAction>`
452451 """
453452 response = self ._client .request (
454- url = f"/floating_ips /{ floating_ip .id } /actions/change_dns_ptr" ,
453+ url = f"{ self . _base_url } /{ floating_ip .id } /actions/change_dns_ptr" ,
455454 method = "POST" ,
456455 json = {"ip" : ip , "dns_ptr" : dns_ptr },
457456 )
0 commit comments