
    v                        d Z ddlmZ ddlmZ dZ G d dej                        Z G d dej                        Z G d d	ej                        Z	 G d
 dej                        Z
 G d dej                        Z G d dej                        Z G d dej                        Z G d dej                        Z G d dej                        Z G d dej                        Z G d dej                        Z G d dej                        Z G d dej                        Z G d dej                        Z G d  d!ej                        Z G d" d#ej                        Z G d$ d%ej.                        Zy&)'z&Exceptions for cloud deploy libraries.    )
exceptionsz-Status code: {status_code}. {status_message}.c                   "     e Zd ZdZ fdZ xZS )ParserErrorz%Error parsing JSON into a dictionary.c                 R    dj                  ||      }t        t        |   |       y)zInitialize a exceptions.ParserError.

    Args:
      path: str, build artifacts file path.
      msg: str, error message.
    zparsing {path}: {msg})pathmsgN)formatsuperr   __init__)selfr   r   	__class__s      3lib/googlecloudsdk/command_lib/deploy/exceptions.pyr   zParserError.__init__   s1     "
(
( ) C 
+t%c*    __name__
__module____qualname____doc__r   __classcell__r   s   @r   r   r      s    -+ +r   r   c                   "     e Zd ZdZ fdZ xZS )ReleaseInactiveErrorz3Error when a release is not deployed to any target.c                 ,    t         t        |   d       y )NzThis release is not deployed to a target in the active delivery pipeline. Include the --to-target parameter to indicate which target to promote to.)r
   r   r   r   r   s    r   r   zReleaseInactiveError.__init__,   s    	
.	r   r   r   s   @r   r   r   )   s    ; r   r   c                   "     e Zd ZdZ fdZ xZS )AbandonedReleaseErrorz7Error when an activity happens on an abandoned release.c                 P    dj                  ||      }t        t        |   |       y )Nz{} Release {} is abandoned.)r	   r
   r   r   )r   	error_msgrelease_nameerror_templater   s       r   r   zAbandonedReleaseError.__init__7   s*    299<N 

/?r   r   r   s   @r   r   r   4   s    ?@ @r   r   c                   "     e Zd ZdZ fdZ xZS )NoStagesErrorz9Error when a release doesn't contain any pipeline stages.c                 J    t         t        |   dj                  |             y )Nz%No pipeline stages in the release {}.)r
   r"   r   r	   r   r   r   s     r   r   zNoStagesError.__init__A   s     	-'/66|Dr   r   r   s   @r   r"   r"   >   s    A r   r"   c                   "     e Zd ZdZ fdZ xZS )InvalidReleaseNameErrorzFError when a release has extra $ signs after expanding template terms.c                 P    d}t         t        |   |j                  ||             y )Nz_Invalid character '$' for release name '{}' at indices: {}. Did you mean to use $DATE or $TIME?)r
   r&   r   r	   )r   r   error_indicesr   r   s       r   r   z InvalidReleaseNameError.__init__J   s/    	3 
 

!41}5r   r   r   s   @r   r&   r&   G   s    N r   r&   c                   @    e Zd ZdZed        Zed        Zed        Zy)CloudDeployConfigErrorz8Error raised for errors in the cloud deploy yaml config.c                      | d| d|       S )NzError parsing manifest #z:  )clsnummessages      r   for_unnamed_manifestz+CloudDeployConfigError.for_unnamed_manifestX   s    )#b	:;;r   c                 $     | d| d| d|       S )NError parsing  "": r,   )r-   kindnamer/   s       r   for_resourcez#CloudDeployConfigError.for_resource\   s     vRvS	:;;r   c           
      *     | d| d| d| d|       S )Nr2   r3   z	" field "r4   r,   )r-   r5   r6   fieldr/   s        r   for_resource_fieldz)CloudDeployConfigError.for_resource_field`   s&    vRvYugS	JKKr   N)r   r   r   r   classmethodr0   r7   r:   r,   r   r   r*   r*   U   sA    @< < < < L Lr   r*   c                       e Zd ZdZy)ManifestTransformExceptionz:Error raised when a manifest transform fails due to a bug.N)r   r   r   r   r,   r   r   r=   r=   e   s    Br   r=   c                   "     e Zd ZdZ fdZ xZS )ListRolloutsErrorzDError when it failed to list the rollouts that belongs to a release.c                 J    t         t        |   dj                  |             y )NzFailed to list rollouts for {}.)r
   r?   r   r	   r$   s     r   r   zListRolloutsError.__init__l   s!    	
T+)00>r   r   r   s   @r   r?   r?   i   s    L r   r?   c                   "     e Zd ZdZ fdZ xZS )RedeployRolloutErrorzError when a rollout can't be redeployed.

  Redeploy can only be used for rollouts that are in a SUCCEEDED or FAILED
  state.
  c                 R    dj                  |||      }t        t        |   |       y )NzPUnable to redeploy target {}. Rollout {} is in state {} that can't be redeployed)r	   r
   rB   r   )r   target_namerollout_namerollout_stater   r   s        r   r   zRedeployRolloutError.__init__y   s-    	{L-H  

.y9r   r   r   s   @r   rB   rB   r   s    : :r   rB   c                   "     e Zd ZdZ fdZ xZS )RolloutIDExhaustedErrorz;Error when there are too many rollouts for a given release.c                 J    t         t        |   dj                  |             y )NzSRollout name space exhausted in release {}. Use --rollout-id to specify rollout ID.)r
   rH   r   r	   r$   s     r   r   z RolloutIDExhaustedError.__init__   s"    	
!41	$f\2r   r   r   s   @r   rH   rH      s    C r   rH   c                   "     e Zd ZdZ fdZ xZS )RolloutInProgressErrorzbError when there is a rollout in progress, no to-target value is given and a promote is attempted.c                 L    t         t        |   dj                  ||             y )NzLUnable to promote release {} to target {}. A rollout is already in progress.)r
   rK   r   r	   )r   r   rD   r   s      r   r   zRolloutInProgressError.__init__   s$    	
 $0	,,2F<,Mr   r   r   s   @r   rK   rK      s    j r   rK   c                   "     e Zd ZdZ fdZ xZS )RolloutNotInProgressErrorz?Error when a rollout is not in_progress, but is expected to be.c                 J    t         t        |   dj                  |             y )NzRollout {} is not IN_PROGRESS.)r
   rN   r   r	   )r   rE   r   s     r   r   z"RolloutNotInProgressError.__init__   s!    	
#T3(//=r   r   r   s   @r   rN   rN      s    G r   rN   c                   "     e Zd ZdZ fdZ xZS )RolloutCannotAdvanceErrorzIError when a rollout cannot be advanced because of a failed precondition.c                 P    dj                  ||      }t        t        |   |       y )Nz!{} Rollout {} cannot be advanced.)r	   r
   rQ   r   )r   rE   failed_activity_msgr   r   s       r   r   z"RolloutCannotAdvanceError.__init__   s*    3::\I 

#T3I>r   r   r   s   @r   rQ   rQ      s    Q? ?r   rQ   c                   "     e Zd ZdZ fdZ xZS )PipelineSuspendedErrorz?Error when a user performs an activity on a suspended pipeline.c                 P    dj                  ||      }t        t        |   |       y )Nz${} DeliveryPipeline {} is suspended.)r	   r
   rU   r   )r   pipeline_namerS   r   r   s       r   r   zPipelineSuspendedError.__init__   s*    6==]I 

 $0;r   r   r   s   @r   rU   rU      s    G< <r   rU   c                   "     e Zd ZdZ fdZ xZS )AutomationNameFormatErrorTError when the name of the automation in the config file is not formatted correctly.c                 J    t         t        |   dj                  |             y )Nz]Automation name {} in the configuration should be in the format of pipeline_id/automation_id.)r
   rY   r   r	   )r   automation_namer   s     r   r   z"AutomationNameFormatError.__init__   s"    	
#T3	))/)@r   r   r   s   @r   rY   rY      s    \ r   rY   c                   "     e Zd ZdZ fdZ xZS )AutomationWaitFormatErrorrZ   c                 ,    t         t        |   d       y )Nz8Wait must be numbers with the last character m, e.g. 5m.)r
   r^   r   r   s    r   r   z"AutomationWaitFormatError.__init__   s    	
#T3Br   r   r   s   @r   r^   r^      s    \ r   r^   c                   "     e Zd ZdZ fdZ xZS ) MissingCoupledArgumentsExceptionz^An exception for when only one of several arguments that need to be passed together is passed.c                 4    t         t        |   d| d       y )NzAll of these flags z must be supplied together)r
   ra   r   )r   parameter_namesr   s     r   r   z)MissingCoupledArgumentsException.__init__   s!    	
*D:
o..HIr   r   r   s   @r   ra   ra      s    f r   ra   N)r   googlecloudsdk.callioper   c_exceptionsgooglecloudsdk.coreHTTP_ERROR_FORMATErrorr   r   r   r"   r&   r*   r=   r?   rB   rH   rK   rN   rQ   rU   rY   r^   ToolExceptionra   r,   r   r   <module>rj      sP   - ? *C +*"" +":++ @J,, @J$$ j.. LZ-- L C!1!1 C
(( ::++ :j.. Z-- 
 0 0 ?
 0 0 ?<Z-- <
 0 0 
 0 0 |'A'A r   