
                             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lZej,                   G d dej.                               Zy)zDelete cluster command.    )absolute_import)division)unicode_literals)
exceptions)
kubeconfig)util)base)flags)log)
properties)
console_ioNc                   0    e Zd ZdZdddZed        Zd Zy)Deletea}  Delete an existing cluster for running containers.

  When you delete a cluster, the following resources are deleted:

  - The control plane resources
  - All of the node instances in the cluster
  - Any Pods that are running on those instances
  - Any firewalls and routes created by Kubernetes Engine at the time of cluster
    creation
  - Data stored in host hostPath and emptyDir volumes

  GKE will attempt to delete the following resources. Deletion of these
  resources is not always guaranteed:

  - External load balancers created by the cluster
  - Internal load balancers created by the cluster
  - Persistent disk volumes
  z{description}z`          To delete an existing cluster, run:

            $ {command} sample-cluster
          )DESCRIPTIONEXAMPLESc                     | j                  dddd       | j                  dt        ddd	
       t        j                  |        t        j                  |        y)zRegister flags for this command.

    Args:
      parser: An argparse.ArgumentParser-like object. It is mocked out in order
        to capture some information, but behaves like an ArgumentParser.
    namesNAME+z$The names of the clusters to delete.)metavarnargshelpz	--timeouti  Tz;Timeout (seconds) for waiting on the operation to complete.)typedefaulthiddenr   N)add_argumentintr
   AddAsyncFlagAddKubecontextOverrideFlag)parsers    (lib/surface/container/clusters/delete.pyArgszDelete.ArgsB   sf     3	  5
 J  L 
v	$$V,    c                 0   | j                   d   }| j                   d   } ||      }g }|j                  D ]#  }|j                  |j                  ||             % t	        j
                  t        j                  d|D cg c].  }dj                  |j                  |j                  |            0 c}      dd       g }g }	|D ]'  }
	 |j                  |
      }|j                  ||
f       ) |j(                  s |D ]  \  }}
	 |j+                  |d	j                  |
j                        |j,                  
       	 t        j.                  j1                  |
j                  |j                  |
      |
j2                  |j4                         t>        j@                  jB                  jD                  jG                         |
j                  k(  r8t?        jH                  t>        j@                  jB                  jD                  d       t;        jJ                  |
        |	r)t        j&                  t        j                  d|	            yc c}w # t        j                  $ rQ}|	j                  t        j                  t!        j"                  |t        j$                                     Y d}~d}~wt        j&                  $ r}|	j                  |       Y d}~d}~ww xY w# t6        j8                  $ r }t;        j<                  |       Y d}~d}~ww xY w# t        j                  $ r>}|	j                  t!        j"                  |t        j$                               Y d}~ed}~wt        j&                  $ r}|	j                  |       Y d}~d}~ww xY w)zThis is what gets called when the user runs this command.

    Args:
      args: an argparse namespace. All the arguments that were provided to this
        command invocation.

    Returns:
      Some value that we want to have printed later.
    api_adapterlocation_getz'The following clusters will be deleted.z[{name}] in [{zone}])namezoneT)messagethrow_if_unattendedcancel_on_noNzDeleting cluster {0})	timeout_szSome requests did not succeed:)&contextr   appendParseClusterr   PromptContinuer   ConstructListformat	clusterIdZoneDeleteClusterapitools_exceptions	HttpErrorsix	text_typer   HttpExceptionHTTP_ERROR_FORMATErrorasync_WaitForOperationtimeoutClusterConfigPurge	projectIdkubecontext_overridekconfigMissingEnvVarErrorr   warningr   VALUES	containerclusterGetPersistPropertyDeletedResource)selfargsadapterr&   locationcluster_refsr'   ref
operationserrorscluster_refop_referroroperation_refs                 r!   Runz
Delete.RunX   s
    ll=)G<</LD!HL

'..tX>? ""#L $O
 $ #))]]c): * <#O
 
 ! JF#&&{36;/0 $ ;;(2
$-	

"
"$++K,A,AB # &
$$%%[)%%))	 ((00446+:O:OO&&z'8'8'B'B'J'J'+-


k
*) )34 JJ


=v
FH H cO
 !** JMM((0F0FGI	J 	J ZZ e$ ++ KK #,, 	Q
--
008N8NO
P
Pzz 	
--

	s{   >3I	$I7L>AK!BLK AJ,,KKK!L4L	LLLN*3M##N9NNN)__name__
__module____qualname____doc__detailed_helpstaticmethodr"   rY    r#   r!   r   r   "   s3    * 		- - -*DHr#   r   )r]   
__future__r   r   r   apitools.base.pyr   r6    googlecloudsdk.api_lib.containerr   rD   r   googlecloudsdk.callioper	   $googlecloudsdk.command_lib.containerr
   googlecloudsdk.corer   r   googlecloudsdk.core.consoler   r8   DefaultUniverseOnlyDeleteCommandr   r`   r#   r!   <module>rj      s^     &  ' > B 1 ( . 6 # * 2 
 yHT yH yHr#   