
    h
                         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r " S
 S\5      r " S S\5      rg	)z(Common utilities for deleting resources.    )absolute_import)division)unicode_literals)operations_util)base)util)logNc                   X    \ rS rSrSr\R                  R                  4S jrS r	S r
Srg)EnvironmentDeletionWaiter   zGClass for waiting for synchronous deletion of one or more Environments.c                     / U l         Xl        g Npending_deletesrelease_track)selfr   s     6lib/googlecloudsdk/command_lib/composer/delete_util.py__init__"EnvironmentDeletionWaiter.__init__   s    D&    c                 L    U R                   R                  [        X5      5        g)a  Adds an environment whose deletion to track.

Args:
  environment_name: str, the relative resource name of the environment
      being deleted
  operation: Operation, the longrunning operation object returned by the
      API when the deletion was initiated
N)r   append_PendingEnvironmentDeleter   environment_name	operations      r   AddPendingDelete*EnvironmentDeletionWaiter.AddPendingDelete#   s"     	!"2>@r   c           
      j   SnU R                    HG  n [        R                  " UR                  SR	                  UR
                  5      U R                  S9  MI     U$ ! [        R                   aB  nSn[        R                  " UR
                  SS[        R                  " U5      S9   SnAM  SnAff = f)z;Polls pending deletions and returns when they are complete.FzWaiting for [{}] to be deleted)r   Tenvironment)kindis_asyncfailedN)r   operations_api_utilWaitForOperationr   formatr   r   command_utilOperationErrorr	   DeletedResourcesix	text_type)r   encountered_errorspending_deletees       r   WaitEnvironmentDeletionWaiter.Wait/   s    ..%,,$$,33//1,,		. /  (( %!++==#		% 	%%s   AAB207B--B2r   N)__name__
__module____qualname____firstlineno____doc__r   ReleaseTrackGAr   r   r/   __static_attributes__ r   r   r   r      s$    O#'#4#4#7#7 '
@r   r   c                       \ rS rSrSrS rSrg)r   C   zDData class holding information about a pending environment deletion.c                     Xl         X l        g r   r   r   r   s      r   r   "_PendingEnvironmentDelete.__init__F   s    ,Nr   r=   N)r1   r2   r3   r4   r5   r   r8   r9   r   r   r   r   C   s
    Lr   r   )r5   
__future__r   r   r   googlecloudsdk.api_lib.composerr   r$   googlecloudsdk.callioper   #googlecloudsdk.command_lib.composerr   r'   googlecloudsdk.corer	   r*   objectr   r   r9   r   r   <module>rE      s;    / &  ' R ( D # 
$ $N r   