
                            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dZdZd Z ej*                  ej,                  j.                  ej,                  j0                  ej,                  j2                        ej4                   G d dej6                                      Zy)z!Promote new Cloud Deploy release.    )release)
exceptions)base)delivery_pipeline_util)deploy_policy_util)flags)promote_util)release_util)resource_args)
console_ioz{description}z   To promote a release called 'test-release' for delivery pipeline 'test-pipeline' in region 'us-central1' to target 'prod', run:

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


)DESCRIPTIONEXAMPLESrolloutc                 >   t        j                  |        t        j                  |        t        j                  |        t        j
                  | t               t        j                  | t               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.
  N)
r   AddReleaseResourceArgr   AddToTargetAddRolloutIDAddAnnotationsFlag_ROLLOUTAddLabelsFlagAddStartingPhaseIdAddOverrideDeployPoliciesparsers    &lib/surface/deploy/releases/promote.py_CommonArgsr   ,   sj     %%f-FV68,fh'6"!!&)    c                   h    e Zd ZdZeZed        Z ej                  e
j                        d        Zy)PromotezPromotes a release from one target (source), to another (destination).

  If to-target is not specified the command promotes the release from the target
  that is farthest along in the promotion sequence to its next stage in the
  promotion sequence.
  c                     t        |        y )N)r   r   s    r   ArgszPromote.ArgsJ   s
    r   c                    |j                   j                  j                         }|j                         }t	        j
                  |j                               }dj                  |j                               }t	        j                  ||       t        j                         j                  |j                               }t        j                  |d       |j                  r$t        j                  d|j                               |j                   }|s-t#        j$                  |d      }t#        j&                  |||       t        j(                  |||j                          t+        j,                  dj                  |j/                         |      d       t1        j2                  ||j4                        }t#        j6                  |||d|j8                  |j:                  |j<                  |j>                  |	      }	|	S )	NzCannot promote release {}.zpromote this releasezCannot promote release.Fz"Promoting release {} to target {}.T)cancel_on_no)
rollout_idannotationslabelsstarting_phase_idoverride_deploy_policies) CONCEPTSr   ParseParentr   GetPipelineRelativeNameformatThrowIfPipelineSuspendedReleaseClientGetr
   CheckReleaseSupportState	abandoneddeploy_exceptionsAbandonedReleaseError	to_targetr	   GetToTargetIDCheckIfInProgressRollout	PrintDiffr   PromptContinueNamer   CreateDeployPolicyNamesFromIDsr(   r   r$   r%   r&   r'   )
selfargsrelease_refpipeline_refpipeline_objfailed_activity_msgrelease_objto_target_idpoliciesrollout_resources
             r   RunzPromote.RunN   s    --''--/K%%'L)55!!#L 7==  " 33) '')--k.F.F.HIK))+7MN33
#[%=%=%? 
 >>L!//UCl ++
{L ;T^^D,33	
 	 "@@d33H $++??$${{00!)
 r   N)__name__
__module____qualname____doc___DETAILED_HELPdetailed_helpstaticmethodr!   gcloud_exception CatchHTTPErrorRaiseHTTPExceptionr4   HTTP_ERROR_FORMATrG    r   r   r   r   <   sK    
 !-  544))88r   r   N)rK   "googlecloudsdk.api_lib.clouddeployr   googlecloudsdk.api_lib.utilr   rO   googlecloudsdk.callioper   !googlecloudsdk.command_lib.deployr   r   r4   r   r	   r
   r   googlecloudsdk.core.consoler   rL   r   r   ReleaseTracksReleaseTrackALPHABETAGADefaultUniverseOnlyCreateCommandr   rR   r   r   <module>r_      s    ( 7 F ( D @ M 3 : : ; 2 #	 *  T..33T5F5F5I5I Id   I Ir   