
                             S r SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJ	r	  SSK
Jr  SS	KJr  S
r\R                  " \R                   R"                  5       " S S\	R$                  \R&                  5      5       rg)zoperations wait command.    )absolute_import)division)unicode_literals)dm_base)
exceptions)base)dm_write)logi   c                   6    \ rS rSrSrSS0r\S 5       rS rSr	g)	Wait    zWait for all operations specified to complete before returning.

Polls until all operations have finished, then prints the resulting operations
along with any operation errors.
EXAMPLESz          To poll until an operation has completed, run:

            $ {command} operation-name

          To poll until several operations have all completed, run:

            $ {command} operation-one operation-two operation-three
          c                 &    U R                  SSSS9  g)zArgs is called by calliope to gather arguments for this command.

Args:
  parser: An argparse parser that you can use to add arguments that go
      on the command line after this command. Positional arguments are
      allowed.
operation_name+zOperation name.)nargshelpN)add_argument)parsers    1lib/surface/deployment_manager/operations/wait.pyArgs	Wait.Args4   s     (:KL    c           
         / nUR                    HH  n [        R                  " U R                  U R                  US[
        R                  " 5       [        S9  MJ     U(       aS  [        U5      S:X  a  [        R                  " SUS   -  5      e[        R                  " SSR                  U5      -   5      e[        R                  R                  S5        g	! [        R                   a    UR                  U5         M  f = f)
a  Run 'operations wait'.

Args:
  args: argparse.Namespace, The arguments that this command was invoked
      with.

Raises:
  HttpException: An http error response was received while executing api
      request.
Raises:
  OperationError: Operation finished with error(s) or timed out.
 )timeout   z.Operation %s failed to complete or has errors.r   z3Some operations failed to complete without errors:

z&All operations completed successfully.N)r   r	   WaitForOperationclientmessagesr   
GetProjectOPERATION_TIMEOUTr   OperationErrorappendlenjoinr
   statusPrint)selfargs
failed_opsr   s       r   RunWait.Run?   s     J--*!!$++"&--"0"g6H6H6J*;	= . 	ZA	''<z!}LN 	N ''Bii
#$% 	% 
jj?@ && *.)*s   AC%C>=C> N)
__name__
__module____qualname____firstlineno____doc__detailed_helpstaticmethodr   r-   __static_attributes__r/   r   r   r   r       s4      
- M MAr   r   N)r4   
__future__r   r   r   )googlecloudsdk.api_lib.deployment_managerr   r   googlecloudsdk.callioper   -googlecloudsdk.command_lib.deployment_managerr	   googlecloudsdk.corer
   r#   UseDmApiDmApiVersionV2Command	DmCommandr   r/   r   r   <module>rB      sk      &  ' = @ ( B #   	'&&))*=A4<<** =A +=Ar   