
                            S r SSKJr  SSKJr  SSKJr  SSKJ	r	  SSK
Jr  SSK
Jr  SSK
Jr  SSK
Jr  SS	K
Jr  SS
KJr  SSKJr  SSS.r\	R*                  " \	R,                  R.                  \	R,                  R0                  \	R,                  R2                  5      \	R4                   " S S\	R6                  5      5       5       rg)z7Advances a Cloud Deploy rollout to the specified phase.    )rollout)apis)
exceptions)base)delivery_pipeline_util)deploy_policy_util)flags)resource_args)log)
console_ioz{description}a        To advance a rollout `test-rollout` to phase `test-phase` for delivery pipeline `test-pipeline`, release `test-release` in region `us-central1`, run:

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

)DESCRIPTIONEXAMPLESc                   v    \ rS rSrSr\r\S 5       r\	R                  " \R                  5      S 5       rS rSrg)Advance)   zAdvances a rollout.c                     [         R                  " U SS9  [        R                  " U SS9  [        R                  " U 5        g )NT)
positionalF)required)r
   AddRolloutResourceArgr	   
AddPhaseIdAddOverrideDeployPolicies)parsers    &lib/surface/deploy/rollouts/advance.pyArgsAdvance.Args2   s2    ''4@ 
Ve,	##F+    c                    UR                   R                  R                  5       nUR                  5       R                  5       n[        R
                  " UR                  5       5      nSR                  UR                  5       5      n[        R                  " XE5        UR                  nUc  U R                  U5      n[        R                  R                  SR                  UR                  5       U5      5        [        R                  " X1R                   5      n[        R"                  " 5       R%                  UR                  5       UUS9$ )NzCannot advance rollout {}.z"Advancing rollout {} to phase {}.
)override_deploy_policies)CONCEPTSr   ParseParentr   GetPipelineRelativeNameformatThrowIfPipelineSuspendedphase_id_DetermineNextPhaser   statusPrintr   CreateDeployPolicyNamesFromIDsr   RolloutClientAdvanceRollout)selfargsrollout_refpipeline_refpipeline_objfailed_activity_msgr&   policiess           r   RunAdvance.Run;   s     --''--/K%%'..0L)55!!#L 7==  " 33 }}H))+6hJJ-44$$&	
 "@@33H   "11  "!) 2  r   c                    [         R                  " SS5      n[        R                  " 5       R	                  UR                  5       5      nUR                  UR                  R                  R                  :w  a"  [        R                  " UR                  5       S9eSn[        UR                  5       H7  u  pVUR                  UR                  R                  R                  :X  d  M5  Un  O   Uc#  [        R                   " UR                  5       SS9eUS:X  a#  [        R                   " UR                  5       SS9eUR                  R                  R"                  UR                  R                  R$                  /nUR                  US	-
     nUR                  U;  aG  [        R                   " UR                  5       S
R'                  UR(                  UR                  5      S9eSR'                  UR                  5       UR                  U   R(                  5      n	[*        R,                  " U	SS9  UR                  U   R(                  $ )z?Determines the phase in which the advance command should apply.clouddeployv1)rollout_nameNzNo pending phases.)r9   r2   r   z(Cannot advance first phase of a rollout.   z7Prior phase {} is in {} state which is not advanceable.z8Are you sure you want to advance rollout {} to phase {}?T)cancel_on_no)	core_apisGetMessagesModuler   r+   Getr#   stateRolloutStateValueValuesEnumIN_PROGRESSdeploy_exceptionsRolloutNotInProgressError	enumeratephasesPhasePENDINGRolloutCannotAdvanceError	SUCCEEDEDSKIPPEDr$   idr   PromptContinue)
r-   r/   messagesropending_phase_indexindexphaseadvanceable_prior_phase_statesprior_phaseprompts
             r   r'   Advance._DetermineNextPhase^   s   **=$?H				 	$	$[%=%=%?	@B	xx8##88DDD77"//1  !")),	;;CC	C# - "77"//12  a77"//1H 
 	++55++33&" ))/!34K >>77"//1GNN..+"3"3  HNN  "BII.A$B$E$EF f4899(),,,r    N)__name__
__module____qualname____firstlineno____doc___DETAILED_HELPdetailed_helpstaticmethodr   gcloud_exception CatchHTTPErrorRaiseHTTPExceptionrC   HTTP_ERROR_FORMATr4   r'   __static_attributes__rW   r   r   r   r   )   sL    
  -, , 44))@--r   r   N)r\   "googlecloudsdk.api_lib.clouddeployr   googlecloudsdk.api_lib.utilr   r<   r   r`   googlecloudsdk.callioper   !googlecloudsdk.command_lib.deployr   r   rC   r	   r
   googlecloudsdk.corer   googlecloudsdk.core.consoler   r]   ReleaseTracksReleaseTrackALPHABETAGADefaultUniverseOnlyCreateCommandr   rW   r   r   <module>rq      s    > 7 9 F ( D @ M 3 ; # 2 # T..33T5F5F5I5I ^-d   ^- ^-r   