
                         x   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	d
Zd Z e	j$                  e	j&                  j(                  e	j&                  j*                  e	j&                  j,                        e	j.                   G d de	j0                                      Zd Zy)zAbandons Cloud Deploy release.    )
exceptions)release)base)release_util)resource_args)
console_ioz{description}z   To abandon a release called `test-release` for delivery pipeline `test-pipeline` in region `us-central1`, run:

  $ {command} test-release --delivery-pipeline=test-pipeline --region=us-central1


)DESCRIPTIONEXAMPLESc                 4    t        j                  | dd       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.
  T)
positionalrequiredN)r   AddReleaseResourceArgparsers    &lib/surface/deploy/releases/abandon.py_CommonArgsr   *   s     %%fM    c                   h    e Zd ZdZeZed        Z ej                  e
j                        d        Zy)AbandonzAbandons a release.

  After a release is abandoned, no new rollouts can be created from it.

  Rollouts of abandoned releases can't be rolled back to.

  Existing rollouts of abandoned releases will be unaffected.
  c                     t        |        y )N)r   r   s    r   ArgszAbandon.ArgsC   s
    r   c                    |j                   j                  j                         }	 t        j                         j	                  |j                               }t        j                  ||j                        }t        |      }t        j                  |dj!                  |j#                               d       t        j                         j%                  |j&                         t        j(                  j+                  dj!                  |j                                      y # t        j                  $ r}t        j                  |      d }~ww xY w)Nz,Are you sure you want to abandon release {}.T)messageprompt_stringcancel_on_nozAbandoned release {})CONCEPTSr   ParseReleaseClientGetRelativeNameapitools_exceptions	HttpErrorr   HttpExceptionr   ListCurrentDeployedTargetstargetSnapshots_GetAbandonReleaseMessageStringr   PromptContinueformatNamer   namelogPrint)selfargsrelease_refrelease_objerrordeployed_targetsconsole_messages          r   RunzAbandon.RunG   s    --''--/K,))+//0H0H0JKk $>>[002 66FGODKK 	
 ##K$4$45NN/66  "$ % (( ,$$U++,s   1D! !E4E		EN)__name__
__module____qualname____doc___DETAILED_HELPdetailed_helpstaticmethodr   gcloud_exception CatchHTTPErrorRaiseHTTPExceptiondeploy_exceptionsHTTP_ERROR_FORMATr4    r   r   r   r   4   sK     !-  544))%%r   r   c                     | rUdj                  t        |       dj                  | D cg c]!  }dj                  |j                               # c}            S y c c}w )Nz/This release is the latest in {} target(s):
{}

z- {})r(   lenjoinr    )r2   
target_refs     r   r&   r&   ^   sc    >EEtyy.*
.
 MM*1134.*
   
 
	*
s   &AN)r8   apitools.base.pyr   r!   "googlecloudsdk.api_lib.clouddeployr   googlecloudsdk.api_lib.utilr<   googlecloudsdk.callioper   !googlecloudsdk.command_lib.deployr>   r   r   googlecloudsdk.core.consoler   r9   r   ReleaseTracksReleaseTrackALPHABETAGADefaultUniverseOnlyCreateCommandr   r&   r@   r   r   <module>rS      s    % ? 6 F ( . M : ; 2 			N D%%++T->->-C-C%%((*$%d   $% *$%Nr   