
    h
                         d Z ddlmZ ddlmZ ddlmZ ddlmZ ddlm	Z	 ddl
mZ ddlmZ dd	lZ G d
 de      Z G d de      Zy	)z(Common utilities for deleting resources.    )absolute_import)division)unicode_literals)operations_util)base)util)logNc                   N    e Zd ZdZej
                  j                  fdZd Zd Z	y)EnvironmentDeletionWaiterzGClass for waiting for synchronous deletion of one or more Environments.c                      g | _         || _        y N)pending_deletesrelease_track)selfr   s     6lib/googlecloudsdk/command_lib/composer/delete_util.py__init__z"EnvironmentDeletionWaiter.__init__   s    D&D    c                 N    | j                   j                  t        ||             y)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   AddPendingDeletez*EnvironmentDeletionWaiter.AddPendingDelete#   s$     	!"2I>@r   c           
      h   d}| j                   D ]H  }	 t        j                  |j                  dj	                  |j
                        | j                         J |S # t        j                  $ rB}d}t        j                  |j
                  ddt        j                  |             Y d}~d}~ww xY w)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   WaitzEnvironmentDeletionWaiter.Wait/   s    ..%,,$$,33//1,,		. /  (( %!++==#		% 	%%s   AAB1/8B,,B1N)
__name__
__module____qualname____doc__r   ReleaseTrackGAr   r   r+    r   r   r   r      s$    O#'#4#4#7#7 '
@r   r   c                       e Zd ZdZd Zy)r   zDData class holding information about a pending environment deletion.c                      || _         || _        y r   )r   r   r   s      r   r   z"_PendingEnvironmentDelete.__init__F   s    ,DDNr   N)r,   r-   r.   r/   r   r2   r   r   r   r   C   s
    Lr   r   )r/   
__future__r   r   r   googlecloudsdk.api_lib.composerr   r    googlecloudsdk.callioper   #googlecloudsdk.command_lib.composerr   r#   googlecloudsdk.corer	   r&   objectr   r   r2   r   r   <module>r;      s;    / &  ' R ( D # 
$ $N r   