22
33from typing import TYPE_CHECKING , Any , NamedTuple
44
5- from ..actions import BoundAction , ResourceActionsClient
5+ from ..actions import ActionsPageResult , BoundAction , ResourceActionsClient
66from ..core import BoundModelBase , Meta , ResourceClientBase
77from .domain import CreatePrimaryIPResponse , PrimaryIP
88
@@ -26,6 +26,52 @@ def __init__(self, client: PrimaryIPsClient, data: dict, complete: bool = True):
2626
2727 super ().__init__ (client , data , complete )
2828
29+ def get_actions_list (
30+ self ,
31+ status : list [str ] | None = None ,
32+ sort : list [str ] | None = None ,
33+ page : int | None = None ,
34+ per_page : int | None = None ,
35+ ) -> ActionsPageResult :
36+ """
37+ Returns a paginated list of Actions for a Primary IP.
38+
39+ See https://docs.hetzner.cloud/reference/cloud#zones-list-zones
40+
41+ :param primary_ip: Primary IP to fetch the Actions from.
42+ :param status: Filter the actions by status. The response will only contain actions matching the specified statuses.
43+ :param sort: Sort resources by field and direction.
44+ :param page: Page number to return.
45+ :param per_page: Maximum number of entries returned per page.
46+ """
47+ return self ._client .get_actions_list (
48+ self ,
49+ status = status ,
50+ sort = sort ,
51+ page = page ,
52+ per_page = per_page ,
53+ )
54+
55+ def get_actions (
56+ self ,
57+ status : list [str ] | None = None ,
58+ sort : list [str ] | None = None ,
59+ ) -> list [BoundAction ]:
60+ """
61+ Returns all Actions for a Primary IP.
62+
63+ See https://docs.hetzner.cloud/reference/cloud#zones-list-zones
64+
65+ :param primary_ip: Primary IP to fetch the Actions from.
66+ :param status: Filter the actions by status. The response will only contain actions matching the specified statuses.
67+ :param sort: Sort resources by field and direction.
68+ """
69+ return self ._client .get_actions (
70+ self ,
71+ status = status ,
72+ sort = sort ,
73+ )
74+
2975 def update (
3076 self ,
3177 auto_delete : bool | None = None ,
@@ -115,6 +161,68 @@ def __init__(self, client: Client):
115161 super ().__init__ (client )
116162 self .actions = ResourceActionsClient (client , self ._base_url )
117163
164+ def get_actions_list (
165+ self ,
166+ primary_ip : PrimaryIP | BoundPrimaryIP ,
167+ status : list [str ] | None = None ,
168+ sort : list [str ] | None = None ,
169+ page : int | None = None ,
170+ per_page : int | None = None ,
171+ ) -> ActionsPageResult :
172+ """
173+ Returns a paginated list of Actions for a Primary IP.
174+
175+ See https://docs.hetzner.cloud/reference/cloud#zones-list-zones
176+
177+ :param primary_ip: Primary IP to fetch the Actions from.
178+ :param status: Filter the actions by status. The response will only contain actions matching the specified statuses.
179+ :param sort: Sort resources by field and direction.
180+ :param page: Page number to return.
181+ :param per_page: Maximum number of entries returned per page.
182+ """
183+ params : dict [str , Any ] = {}
184+ if status is not None :
185+ params ["status" ] = status
186+ if sort is not None :
187+ params ["sort" ] = sort
188+ if page is not None :
189+ params ["page" ] = page
190+ if per_page is not None :
191+ params ["per_page" ] = per_page
192+
193+ response = self ._client .request (
194+ url = f"{ self ._base_url } /{ primary_ip .id } /actions" ,
195+ method = "GET" ,
196+ params = params ,
197+ )
198+ actions = [
199+ BoundAction (self ._parent .actions , action_data )
200+ for action_data in response ["actions" ]
201+ ]
202+ return ActionsPageResult (actions , Meta .parse_meta (response ))
203+
204+ def get_actions (
205+ self ,
206+ primary_ip : PrimaryIP | BoundPrimaryIP ,
207+ status : list [str ] | None = None ,
208+ sort : list [str ] | None = None ,
209+ ) -> list [BoundAction ]:
210+ """
211+ Returns all Actions for a Primary IP.
212+
213+ See https://docs.hetzner.cloud/reference/cloud#zones-list-zones
214+
215+ :param primary_ip: Primary IP to fetch the Actions from.
216+ :param status: Filter the actions by status. The response will only contain actions matching the specified statuses.
217+ :param sort: Sort resources by field and direction.
218+ """
219+ return self ._iter_pages (
220+ self .get_actions_list ,
221+ primary_ip ,
222+ status = status ,
223+ sort = sort ,
224+ )
225+
118226 def get_by_id (self , id : int ) -> BoundPrimaryIP :
119227 """Returns a specific Primary IP object.
120228
0 commit comments