11# -*- coding: utf-8 -*-
22from hcloud .actions .client import BoundAction
3- from hcloud .core .client import BoundModelBase , ClientEntityBase
3+ from hcloud .core .client import BoundModelBase , ClientEntityBase , GetEntityByNameMixin
44from hcloud .core .domain import add_meta_to_result
55
66from hcloud .floating_ips .domain import FloatingIP , CreateFloatingIPResponse
@@ -114,7 +114,7 @@ def change_dns_ptr(self, ip, dns_ptr):
114114 return self ._client .change_dns_ptr (self , ip , dns_ptr )
115115
116116
117- class FloatingIPsClient (ClientEntityBase ):
117+ class FloatingIPsClient (ClientEntityBase , GetEntityByNameMixin ):
118118 results_list_attribute_name = 'floating_ips'
119119
120120 def get_actions_list (self ,
@@ -184,7 +184,8 @@ def get_by_id(self, id):
184184 def get_list (self ,
185185 label_selector = None , # type: Optional[str]
186186 page = None , # type: Optional[int]
187- per_page = None # type: Optional[int]
187+ per_page = None , # type: Optional[int]
188+ name = None , # type: Optional[str]
188189 ):
189190 # type: (...) -> PageResults[List[BoundFloatingIP]]
190191 """Get a list of floating ips from this account
@@ -195,6 +196,8 @@ def get_list(self,
195196 Specifies the page to fetch
196197 :param per_page: int (optional)
197198 Specifies how many results are returned by page
199+ :param name: str (optional)
200+ Can be used to filter networks by their name.
198201 :return: (List[:class:`BoundFloatingIP <hcloud.floating_ips.client.BoundFloatingIP>`], :class:`Meta <hcloud.core.domain.Meta>`)
199202 """
200203 params = {}
@@ -205,21 +208,35 @@ def get_list(self,
205208 params ['page' ] = page
206209 if per_page :
207210 params ['per_page' ] = per_page
211+ if name :
212+ params ['name' ] = name
208213
209214 response = self ._client .request (url = "/floating_ips" , method = "GET" , params = params )
210215 floating_ips = [BoundFloatingIP (self , floating_ip_data ) for floating_ip_data in response ['floating_ips' ]]
211216
212217 return self ._add_meta_to_result (floating_ips , response )
213218
214- def get_all (self , label_selector = None ):
215- # type: (Optional[str]) -> List[BoundFloatingIP]
219+ def get_all (self , label_selector = None , name = None ):
220+ # type: (Optional[str], Optional[str] ) -> List[BoundFloatingIP]
216221 """Get all floating ips from this account
217222
218223 :param label_selector: str (optional)
219224 Can be used to filter Floating IPs by labels. The response will only contain Floating IPs matching the label selector.able values.
225+ :param name: str (optional)
226+ Can be used to filter networks by their name.
220227 :return: List[:class:`BoundFloatingIP <hcloud.floating_ips.client.BoundFloatingIP>`]
221228 """
222- return super (FloatingIPsClient , self ).get_all (label_selector = label_selector )
229+ return super (FloatingIPsClient , self ).get_all (label_selector = label_selector , name = name )
230+
231+ def get_by_name (self , name ):
232+ # type: (str) -> BoundFloatingIP
233+ """Get Floating IP by name
234+
235+ :param name: str
236+ Used to get Floating IP by name.
237+ :return: :class:`BoundFloatingIP <hcloud.floating_ips.client.BoundFloatingIP>`
238+ """
239+ return super (FloatingIPsClient , self ).get_by_name (name )
223240
224241 def create (self ,
225242 type , # type: str
0 commit comments