@@ -449,6 +449,17 @@ def set_session_cookie(self):
449449        self .api_client .cookie  =  self .api_client .last_response .getheader ("Set-Cookie" )
450450
451451    def  wait_for_command_state (self , command_id , polling_interval ):
452+         """ 
453+         Waits for a command to complete by polling the its state until it completes. 
454+         A wait for the specified interval is done between each check. 
455+ 
456+         Inputs: 
457+             command_id : The identifier of the command to monitor. 
458+             polling_interval: The time (in seconds) to wait between polling attempts. 
459+ 
460+         Return: 
461+             tuple: The full response from `read_command_with_http_info`, containing command details. 
462+         """ 
452463        command_api_instance  =  CommandsResourceApi (self .api_client )
453464        while  True :
454465            get_command_state  =  command_api_instance .read_command_with_http_info (
@@ -458,7 +469,7 @@ def wait_for_command_state(self, command_id, polling_interval):
458469            if  not  state :
459470                break 
460471            sleep (polling_interval )
461-         return  True 
472+         return  get_command_state 
462473
463474    def  call_api (self , path , method , query = None , field = "items" , body = None ):
464475        """Wrapper to call a CM API endpoint path directly.""" 
@@ -491,6 +502,22 @@ def get_cm_config(self, scope: str = "summary") -> ApiConfigList:
491502        return  ClouderaManagerResourceApi (self .api_client ).get_config (view = scope ).items 
492503
493504    def  wait_command (self , command : ApiCommand , polling : int  =  10 , delay : int  =  5 ):
505+         """ 
506+         Waits for a specified command to complete, polling its status at regular intervals. 
507+         If the command exceeds the polling limit, it fails with a timeout error. 
508+         If the command completes unsuccessfully, it fails with the command's result message. 
509+ 
510+         Inputs: 
511+             command (ApiCommand): The command object to monitor. 
512+             polling (int, optional): The maximum number of polling attempts before timing out. Default is 10. 
513+             delay (int, optional): The time (in seconds) to wait between polling attempts. Default is 5. 
514+ 
515+         Raises: 
516+             module.fail_json: If the command times out or fails. 
517+ 
518+         Return: 
519+             None: The function returns successfully if the command completes and is marked as successful. 
520+         """ 
494521        poll_count  =  0 
495522        while  command .active :
496523            if  poll_count  >  polling :
0 commit comments