
                         l   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 ej"                  ej$                  j&                  ej$                  j(                  ej$                  j*                        ej,                   G d dej.                                      Zy)z>Retries a Cloud Deploy rollout job specified by job and phase.    )rollout)
exceptions)base)delivery_pipeline_util)deploy_policy_util)flags)resource_args)logz{description}aD       To retry a job 'test-job' in phase 'test-phase' on a rollout 'test-rollout' for delivery pipeline 'test-pipeline', release 'test-release' in region 'us-central1', run:

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

)DESCRIPTIONEXAMPLESc                   h    e Zd ZdZeZed        Z ej                  e
j                        d        Zy)RetryJobz8Retries a specified job, phase combination on a rollout.c                     t        j                  | d       t        j                  |        t        j                  |        t        j
                  |        y )NT)
positional)r	   AddRolloutResourceArgr   AddJobId
AddPhaseIdAddOverrideDeployPolicies)parsers    (lib/surface/deploy/rollouts/retry_job.pyArgszRetryJob.Args0   s:    ''4@	NN6	V	##F+    c                    |j                   j                  j                         }|j                         j                         }t	        j
                  |j                               }dj                  |j                               }t	        j                  ||       t        j                  j                  dj                  |j                  |j                  |j                                      t        j                  ||j                         }t        j"                         j%                  |j                         |j                  |j                  |      S )NzCannot retry job on rollout {}.z+Retrying job {} in phase {} of rollout {}.
)override_deploy_policies)CONCEPTSr   ParseParentr   GetPipelineRelativeNameformatThrowIfPipelineSuspendedr
   statusPrintjob_idphase_idr   CreateDeployPolicyNamesFromIDsr   RolloutClientr   )selfargsrollout_refpipeline_refpipeline_objfailed_activity_msgpoliciess          r   RunzRetryJob.Run7   s    --''--/K%%'..0L)55!!#%L;BB  "$33L4GI JJCJJT]]K$<$<$>@ A "@@d33H   "++  "!)	 ,  r   N)__name__
__module____qualname____doc___DETAILED_HELPdetailed_helpstaticmethodr   gcloud_exception CatchHTTPErrorRaiseHTTPExceptiondeploy_exceptionsHTTP_ERROR_FORMATr/    r   r   r   r   )   sJ     A -, , 544))r   r   N)r3   "googlecloudsdk.api_lib.clouddeployr   googlecloudsdk.api_lib.utilr   r7   googlecloudsdk.callioper   !googlecloudsdk.command_lib.deployr   r   r9   r   r	   googlecloudsdk.corer
   r4   ReleaseTracksReleaseTrackALPHABETAGADefaultUniverseOnlyCreateCommandr   r;   r   r   <module>rH      s    E 7 F ( D @ M 3 ; # 			
 D%%++T->->-C-C%%((*$t!! $ *$r   