
                             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mZ dd	lmZ dd
lmZ ddlmZ ddlmZ ddiZ G d dej0                        Zy)z!Command to delete an environment.    )absolute_import)division)unicode_literals)
exceptions)environments_util)base)delete_util)resource_args)util)log)
console_ioEXAMPLESzq          To delete the environment named ``environment-1'', run:

            $ {command} environment-1
        c                   *    e Zd ZdZeZed        Zd Zy)Deletea  Delete one or more Cloud Composer environments.

  Environments cannot be deleted unless they are in one of the RUNNING or
  ERROR states. If run asynchronously with `--async`, exits after printing
  one or more operation names that can be used to poll the status of the
  deletion(s) via:

    {top_command} composer operations describe

  If any of the environments are already in the process of being deleted,
  the original deletion operations are waited on (default) or printed
  (`--async`).
  c                 v    t        j                  | dddd       t        j                  j	                  |        y )Nz	to deleteT)pluralrequired
positional)r
   AddEnvironmentResourceArgr   
ASYNC_FLAGAddToParser)parsers    +lib/surface/composer/environments/delete.pyArgszDelete.Args<   s.    ++D4DJOO'    c                    |j                   j                  j                         }t        j                  t        j                  d|D cg c](  }dj                  |j                  |j                        * c}      ddd       t        j                  | j                               }d}|D ]  }d }d }d }	 t        j                  || j                               }dj                  |j                        }|j!                  |j#                         |	       t1        j2                  |j#                         d
d||        |j4                  s|j7                         xs |}|rt        j8                  d      y c c}w # t$        j&                  $ r5}	t)        j*                  |	      j,                  j.                  }d}Y d }	~	d }	~	ww xY w# t1        j2                  |j#                         d
d||       w xY w)Nz%Deleting the following environments: z[{}] in [{}]TzDeletion aborted by user.)messagecancel_on_nocancel_stringthrow_if_unattended)release_trackFzwith operation [{0}])environment_name	operationenvironment)kindis_asyncdetailsfailedzSome requested deletions did not succeed. Please, refer to https://cloud.google.com/composer/docs/how-to/managing/updating and Composer Delete Troubleshooting pages to resolve this issue.)CONCEPTSenvironmentsParser   PromptContinuecommand_utilConstructListformatenvironmentsIdlocationsIdr	   EnvironmentDeletionWaiterReleaseTrackenvironments_api_utilr   nameAddPendingDeleteRelativeNameapitools_exceptions	HttpErrorr   HttpExceptionpayloadstatus_messager   DeletedResourceasync_WaitEnvironmentDeleteError)
selfargsenv_refsenv_refwaiterencountered_errorsr#   r(   r'   es
             r   Runz
Delete.RunB   s   }}))//1H**3  (6  (G %%g&<&<&-&9&9;'6 1 	" 22'')+Fifg)004#4#4#68	 )//	?$113y 	  	J 	  "	 , ;;!;;=>,>//MN N I6& !** "))!,44CC!" 	  "	s6   -E96%E><G	>G+G<G	GG		*G3N)	__name__
__module____qualname____doc__DETAILED_HELPdetailed_helpstaticmethodr   rH    r   r   r   r   +   s&      -( (
-Nr   r   N)rL   
__future__r   r   r   apitools.base.pyr   r8   googlecloudsdk.api_lib.composerr   r4   googlecloudsdk.api_lib.utilgooglecloudsdk.callioper   #googlecloudsdk.command_lib.composerr	   r
   r   r-   googlecloudsdk.corer   googlecloudsdk.core.consoler   rM   DeleteCommandr   rP   r   r   <module>rZ      sU    ( &  ' > V 2 ( ; = D # 2 	DNT DNr   