1- from ..rest import RestClient
1+ from __future__ import annotations
2+
3+ from typing import Any
4+
5+ from ..rest import RestClient , RestClientOptions
6+ from ..types import TimeoutType
27
38
49class Actions :
@@ -17,28 +22,31 @@ class Actions:
1722 both values separately or a float to set both to it.
1823 (defaults to 5.0 for both)
1924
20- rest_options (RestClientOptions): Pass an instance of
25+ protocol (str, optional): Protocol to use when making requests.
26+ (defaults to "https")
27+
28+ rest_options (RestClientOptions, optional): Pass an instance of
2129 RestClientOptions to configure additional RestClient
2230 options, such as rate-limit retries.
2331 (defaults to None)
2432 """
2533
2634 def __init__ (
2735 self ,
28- domain ,
29- token ,
30- telemetry = True ,
31- timeout = 5.0 ,
32- protocol = "https" ,
33- rest_options = None ,
34- ):
36+ domain : str ,
37+ token : str ,
38+ telemetry : bool = True ,
39+ timeout : TimeoutType = 5.0 ,
40+ protocol : str = "https" ,
41+ rest_options : RestClientOptions | None = None ,
42+ ) -> None :
3543 self .domain = domain
3644 self .protocol = protocol
3745 self .client = RestClient (
3846 jwt = token , telemetry = telemetry , timeout = timeout , options = rest_options
3947 )
4048
41- def _url (self , * args ) :
49+ def _url (self , * args : str | None ) -> str :
4250 url = f"{ self .protocol } ://{ self .domain } /api/v2/actions"
4351 for p in args :
4452 if p is not None :
@@ -47,13 +55,13 @@ def _url(self, *args):
4755
4856 def get_actions (
4957 self ,
50- trigger_id = None ,
51- action_name = None ,
52- deployed = None ,
53- installed = False ,
54- page = None ,
55- per_page = None ,
56- ):
58+ trigger_id : str | None = None ,
59+ action_name : str | None = None ,
60+ deployed : bool | None = None ,
61+ installed : bool = False ,
62+ page : int | None = None ,
63+ per_page : int | None = None ,
64+ ) -> Any :
5765 """Get all actions.
5866
5967 Args:
@@ -77,21 +85,20 @@ def get_actions(
7785 See: https://auth0.com/docs/api/management/v2#!/Actions/get_actions
7886 """
7987
80- if deployed is not None :
81- deployed = str (deployed ).lower ()
88+ deployed_str = str (deployed ).lower () if deployed is not None else None
8289
8390 params = {
8491 "triggerId" : trigger_id ,
8592 "actionName" : action_name ,
86- "deployed" : deployed ,
93+ "deployed" : deployed_str ,
8794 "installed" : str (installed ).lower (),
8895 "page" : page ,
8996 "per_page" : per_page ,
9097 }
9198
9299 return self .client .get (self ._url ("actions" ), params = params )
93100
94- def create_action (self , body ) :
101+ def create_action (self , body : dict [ str , Any ]) -> dict [ str , Any ] :
95102 """Create a new action.
96103
97104 Args:
@@ -102,7 +109,7 @@ def create_action(self, body):
102109
103110 return self .client .post (self ._url ("actions" ), data = body )
104111
105- def update_action (self , id , body ) :
112+ def update_action (self , id : str , body : dict [ str , Any ]) -> dict [ str , Any ] :
106113 """Updates an action.
107114
108115 Args:
@@ -115,7 +122,7 @@ def update_action(self, id, body):
115122
116123 return self .client .patch (self ._url ("actions" , id ), data = body )
117124
118- def get_action (self , id ) :
125+ def get_action (self , id : str ) -> dict [ str , Any ] :
119126 """Retrieves an action by its ID.
120127
121128 Args:
@@ -127,7 +134,7 @@ def get_action(self, id):
127134
128135 return self .client .get (self ._url ("actions" , id ), params = params )
129136
130- def delete_action (self , id , force = False ):
137+ def delete_action (self , id : str , force : bool = False ) -> Any :
131138 """Deletes an action and all of its associated versions.
132139
133140 Args:
@@ -142,7 +149,7 @@ def delete_action(self, id, force=False):
142149
143150 return self .client .delete (self ._url ("actions" , id ), params = params )
144151
145- def get_triggers (self ):
152+ def get_triggers (self ) -> dict [ str , Any ] :
146153 """Retrieve the set of triggers currently available within actions.
147154
148155 See: https://auth0.com/docs/api/management/v2#!/Actions/get_triggers
@@ -151,7 +158,7 @@ def get_triggers(self):
151158
152159 return self .client .get (self ._url ("triggers" ), params = params )
153160
154- def get_execution (self , id ) :
161+ def get_execution (self , id : str ) -> dict [ str , Any ] :
155162 """Get information about a specific execution of a trigger.
156163
157164 Args:
@@ -163,7 +170,9 @@ def get_execution(self, id):
163170
164171 return self .client .get (self ._url ("executions" , id ), params = params )
165172
166- def get_action_versions (self , id , page = None , per_page = None ):
173+ def get_action_versions (
174+ self , id : str , page : int | None = None , per_page : int | None = None
175+ ) -> dict [str , Any ]:
167176 """Get all of an action's versions.
168177
169178 Args:
@@ -181,7 +190,9 @@ def get_action_versions(self, id, page=None, per_page=None):
181190
182191 return self .client .get (self ._url ("actions" , id , "versions" ), params = params )
183192
184- def get_trigger_bindings (self , id , page = None , per_page = None ):
193+ def get_trigger_bindings (
194+ self , id : str , page : int | None = None , per_page : int | None = None
195+ ) -> dict [str , Any ]:
185196 """Get the actions that are bound to a trigger.
186197
187198 Args:
@@ -198,7 +209,7 @@ def get_trigger_bindings(self, id, page=None, per_page=None):
198209 params = {"page" : page , "per_page" : per_page }
199210 return self .client .get (self ._url ("triggers" , id , "bindings" ), params = params )
200211
201- def get_action_version (self , action_id , version_id ) :
212+ def get_action_version (self , action_id : str , version_id : str ) -> dict [ str , Any ] :
202213 """Retrieve a specific version of an action.
203214
204215 Args:
@@ -214,7 +225,7 @@ def get_action_version(self, action_id, version_id):
214225 self ._url ("actions" , action_id , "versions" , version_id ), params = params
215226 )
216227
217- def deploy_action (self , id ) :
228+ def deploy_action (self , id : str ) -> dict [ str , Any ] :
218229 """Deploy an action.
219230
220231 Args:
@@ -224,7 +235,9 @@ def deploy_action(self, id):
224235 """
225236 return self .client .post (self ._url ("actions" , id , "deploy" ))
226237
227- def rollback_action_version (self , action_id , version_id ):
238+ def rollback_action_version (
239+ self , action_id : str , version_id : str
240+ ) -> dict [str , Any ]:
228241 """Roll back to a previous version of an action.
229242
230243 Args:
@@ -238,7 +251,7 @@ def rollback_action_version(self, action_id, version_id):
238251 self ._url ("actions" , action_id , "versions" , version_id , "deploy" ), data = {}
239252 )
240253
241- def update_trigger_bindings (self , id , body ) :
254+ def update_trigger_bindings (self , id : str , body : dict [ str , Any ]) -> dict [ str , Any ] :
242255 """Update a trigger's bindings.
243256
244257 Args:
0 commit comments