@@ -19,6 +19,18 @@ def _create_spec(
1919 app_key : str = "" ,
2020 app_version : int = - 1 ,
2121) -> RequestSpec :
22+ """Creates a request specification for creating a new action task.
23+
24+ Args:
25+ title: The title of the action task
26+ data: Optional dictionary containing input data for the action
27+ action_schema: Optional schema defining the action's inputs, outputs, and outcomes
28+ app_key: The unique identifier of the application
29+ app_version: The version of the application
30+
31+ Returns:
32+ RequestSpec: A specification for creating an action task
33+ """
2234 field_list = []
2335 outcome_list = []
2436 if action_schema :
@@ -101,6 +113,14 @@ def _create_spec(
101113
102114
103115def _retrieve_action_spec (action_key : str ) -> RequestSpec :
116+ """Creates a request specification for retrieving an action by its key.
117+
118+ Args:
119+ action_key: The unique identifier of the action to retrieve
120+
121+ Returns:
122+ RequestSpec: A specification for retrieving an action
123+ """
104124 return RequestSpec (
105125 method = "GET" ,
106126 endpoint = Endpoint ("/orchestrator_/tasks/GenericTasks/GetTaskDataByKey" ),
@@ -109,6 +129,15 @@ def _retrieve_action_spec(action_key: str) -> RequestSpec:
109129
110130
111131def _assign_task_spec (task_key : str , assignee : str ) -> RequestSpec :
132+ """Creates a request specification for assigning a task to a user.
133+
134+ Args:
135+ task_key: The unique identifier of the task
136+ assignee: The username or email of the user to assign the task to
137+
138+ Returns:
139+ RequestSpec: A specification for assigning a task
140+ """
112141 return RequestSpec (
113142 method = "POST" ,
114143 endpoint = Endpoint (
@@ -121,6 +150,17 @@ def _assign_task_spec(task_key: str, assignee: str) -> RequestSpec:
121150
122151
123152def _retrieve_app_key_spec (app_name : str ) -> RequestSpec :
153+ """Creates a request specification for retrieving an application's key by its name.
154+
155+ Args:
156+ app_name: The name of the application to retrieve
157+
158+ Returns:
159+ RequestSpec: A specification for retrieving an application key
160+
161+ Raises:
162+ Exception: If the tenant ID environment variable is not set
163+ """
124164 tenant_id = os .getenv (ENV_TENANT_ID , None )
125165 if not tenant_id :
126166 raise Exception (f"{ ENV_TENANT_ID } env var is not set" )
@@ -142,9 +182,17 @@ class ActionsService(FolderContext, BaseService):
142182 This service provides methods to create and retrieve actions, supporting
143183 both app-specific and generic actions. It inherits folder context management
144184 capabilities from FolderContext.
185+
186+ Reference: https://docs.uipath.com/automation-cloud/docs/actions
145187 """
146188
147189 def __init__ (self , config : Config , execution_context : ExecutionContext ) -> None :
190+ """Initializes the ActionsService with configuration and execution context.
191+
192+ Args:
193+ config: The configuration object containing API settings
194+ execution_context: The execution context for the service
195+ """
148196 super ().__init__ (config = config , execution_context = execution_context )
149197
150198 async def create_async (
@@ -157,6 +205,25 @@ async def create_async(
157205 app_version : int = - 1 ,
158206 assignee : str = "" ,
159207 ) -> Action :
208+ """Creates a new action asynchronously.
209+
210+ This method creates a new action task in UiPath Orchestrator. The action can be
211+ either app-specific (using app_name or app_key) or a generic action.
212+
213+ Args:
214+ title: The title of the action
215+ data: Optional dictionary containing input data for the action
216+ app_name: The name of the application (if creating an app-specific action)
217+ app_key: The key of the application (if creating an app-specific action)
218+ app_version: The version of the application
219+ assignee: Optional username or email to assign the task to
220+
221+ Returns:
222+ Action: The created action object
223+
224+ Raises:
225+ Exception: If neither app_name nor app_key is provided for app-specific actions
226+ """
160227 (key , action_schema ) = (
161228 (app_key , None )
162229 if app_key
@@ -189,6 +256,25 @@ def create(
189256 app_version : int = - 1 ,
190257 assignee : str = "" ,
191258 ) -> Action :
259+ """Creates a new action synchronously.
260+
261+ This method creates a new action task in UiPath Orchestrator. The action can be
262+ either app-specific (using app_name or app_key) or a generic action.
263+
264+ Args:
265+ title: The title of the action
266+ data: Optional dictionary containing input data for the action
267+ app_name: The name of the application (if creating an app-specific action)
268+ app_key: The key of the application (if creating an app-specific action)
269+ app_version: The version of the application
270+ assignee: Optional username or email to assign the task to
271+
272+ Returns:
273+ Action: The created action object
274+
275+ Raises:
276+ Exception: If neither app_name nor app_key is provided for app-specific actions
277+ """
192278 (key , action_schema ) = (
193279 (app_key , None ) if app_key else self .__get_app_key_and_schema (app_name )
194280 )
@@ -212,6 +298,14 @@ def retrieve(
212298 self ,
213299 action_key : str ,
214300 ) -> Action :
301+ """Retrieves an action by its key synchronously.
302+
303+ Args:
304+ action_key: The unique identifier of the action to retrieve
305+
306+ Returns:
307+ Action: The retrieved action object
308+ """
215309 spec = _retrieve_action_spec (action_key = action_key )
216310 response = self .request (spec .method , spec .endpoint , params = spec .params )
217311
@@ -221,6 +315,14 @@ async def retrieve_async(
221315 self ,
222316 action_key : str ,
223317 ) -> Action :
318+ """Retrieves an action by its key asynchronously.
319+
320+ Args:
321+ action_key: The unique identifier of the action to retrieve
322+
323+ Returns:
324+ Action: The retrieved action object
325+ """
224326 spec = _retrieve_action_spec (action_key = action_key )
225327 response = await self .request_async (
226328 spec .method , spec .endpoint , params = spec .params
@@ -231,6 +333,17 @@ async def retrieve_async(
231333 async def __get_app_key_and_schema_async (
232334 self , app_name : str
233335 ) -> Tuple [str , Optional [ActionSchema ]]:
336+ """Retrieves an application's key and schema asynchronously.
337+
338+ Args:
339+ app_name: The name of the application to retrieve
340+
341+ Returns:
342+ Tuple[str, Optional[ActionSchema]]: A tuple containing the application key and schema
343+
344+ Raises:
345+ Exception: If app_name is not provided
346+ """
234347 if not app_name :
235348 raise Exception ("appName or appKey is required" )
236349 spec = _retrieve_app_key_spec (app_name = app_name )
@@ -244,6 +357,17 @@ async def __get_app_key_and_schema_async(
244357 def __get_app_key_and_schema (
245358 self , app_name : str
246359 ) -> Tuple [str , Optional [ActionSchema ]]:
360+ """Retrieves an application's key and schema synchronously.
361+
362+ Args:
363+ app_name: The name of the application to retrieve
364+
365+ Returns:
366+ Tuple[str, Optional[ActionSchema]]: A tuple containing the application key and schema
367+
368+ Raises:
369+ Exception: If app_name is not provided
370+ """
247371 if not app_name :
248372 raise Exception ("appName or appKey is required" )
249373
@@ -268,4 +392,9 @@ def __get_app_key_and_schema(
268392
269393 @property
270394 def custom_headers (self ) -> Dict [str , str ]:
395+ """Gets the custom headers required for folder context.
396+
397+ Returns:
398+ Dict[str, str]: A dictionary of custom headers
399+ """
271400 return self .folder_headers
0 commit comments