
                             S r SSKJr  SSKJr  SSKJr  SSKrSSKJr  SSKJr  \R                  S-   r
S	rS
rSr " S S\R                  5      r " S S\R                   5      rg)z=Wraps a Cloud Run Execution message with convenience methods.    )absolute_import)division)unicode_literalsN)container_resource)
k8s_objectz/creatorStarted	Completedzrun.googleapis.com/jobc                       \ rS rSrSrSrSrg)RestartPolicy!   Never	OnFailure N)__name__
__module____qualname____firstlineno__NEVER
ON_FAILURE__static_attributes__r       +lib/googlecloudsdk/api_lib/run/execution.pyr   r   !   s    
%*r   r   c                   >   \ rS rSrSrSrS r\r\	" \
\15      r " S S\R                  5      r\S 5       r\S 5       r\S 5       r\R&                  S	 5       r\S
 5       r\R&                  S 5       r\S 5       r\R&                  S 5       r\S 5       r\S 5       rSrg)	Execution&   zCWraps a Cloud Run Execution message, making fields more convenient.zrun.googleapis.comc                      ^  \ rS rSrSrSr\U 4S j5       r\S 5       r	\S 5       r
\S 5       r\R                  S 5       rS	 r\S
 5       rSrU =r$ )Execution.TaskTemplateSpec.   z6Wrapper class for Execution subfield TaskTemplateSpec.TaskTemplateSpecc                    > [         [        R                  U ]  UR                  R
                  R                  UR                  5       5      nUR                  Ul        UR                  Ul
        U$ )a  Special wrapper for spec only that also covers partial metadata.

For a message type without its own metadata, like TaskTemplateSpec,
metadata fields should either raise AttributeErrors or refer to the
metadata of a different message depending on use case. This method handles
the annotations and labels of metadata by referencing the parent
execution's annotations and labels.
All other metadata fields will fall through to k8s_object which will
lead to AttributeErrors.

Args:
  execution: The parent execution for this TaskTemplateSpec

Returns:
  A new k8s_object to wrap the TaskTemplateSpec with only the spec
  fields and the metadata annotations and labels.
)superr   r   SpecOnlyspectemplateMessagesModuleannotations_annotationslabels_labels)cls	executionspec_wrapper	__class__s      r   SpecAndParitialMetadataOnly6Execution.TaskTemplateSpec.SpecAndParitialMetadataOnly3   sf    & 955))2)@)@)E)E)2)A)A)C!E  #,"7"7l&--lr   c                 N     U R                   $ ! [         a    [        S5      ef = f)z6Override to return the parent execution's annotations.zExecution templates do not have their own annotations. Initialize the wrapper with SpecAndAnnotationsOnly to be able to use annotations.)r'   AttributeError
ValueErrorselfs    r   r&   &Execution.TaskTemplateSpec.annotationsN   s4         	    $c                 N     U R                   $ ! [         a    [        S5      ef = f)z1Override to return the parent execution's labels.z~Execution templates do not have their own labels. Initialize the wrapper with SpecAndAnnotationsOnly to be able to use labels.)r)   r1   r2   r3   s    r   r(   !Execution.TaskTemplateSpec.labelsY   s2    
|| 

 	

r6   c                 .    U R                   R                  $ )z5The service account to use as the container identity.r#   serviceAccountNamer3   s    r   service_account*Execution.TaskTemplateSpec.service_accounte   s     YY)))r   c                 $    XR                   l        g Nr:   r4   values     r   r<   r=   j   s    %*ii"r   c                     U R                   R                  cD  [        R                  " U R                  R
                  R                  5      U R                   l        g g r?   )r#   nodeSelectorr   InitializedInstance	_messagesTaskSpecNodeSelectorValuer3   s    r   _EnsureNodeSelector.Execution.TaskTemplateSpec._EnsureNodeSelectorn   sA    				'!+!?!?NN##55"
		 
(r   c                     U R                  5         [        R                  " U R                  R                  R
                  U R                  R                  R                  R                  SSS9$ )z=The node selector as a dictionary { accelerator_type: value}.keyrA   )	key_fieldvalue_field)
rH   r   KeyValueListAsDictionaryWrapperr#   rC   additionalPropertiesrE   rF   rG   AdditionalPropertyr3   s    r   node_selector(Execution.TaskTemplateSpec.node_selectort   sU      77
))
 
 
5
5
..
!
!
3
3
F
F	 r   r   )r   r   r   r   __doc__KINDclassmethodr.   propertyr&   r(   r<   setterrH   rQ   r   __classcell__)r-   s   @r   r   r   .   s    @D 4   	
 	
 * * + +
  r   r   c                 @    [         R                  R                  U 5      $ r?   )r   r   r.   r3   s    r   r$   Execution.template   s    %%AA$GGr   c                 @    U R                   R                  [        5      $ r?   )r&   getAUTHOR_ANNOTATIONr3   s    r   authorExecution.author   s     122r   c                 .    U R                   R                  $ r?   r$   imager3   s    r   rb   Execution.image   s    ==r   c                 $    XR                   l        g r?   ra   r@   s     r   rb   rc      s    MMr   c                 .    U R                   R                  $ r?   r#   parallelismr3   s    r   rg   Execution.parallelism   s    99   r   c                 $    XR                   l        g r?   rf   r@   s     r   rg   rh      s    !IIr   c                 .    U R                   R                  $ r?   r#   	taskCountr3   s    r   
task_countExecution.task_count   s    99r   c                 $    XR                   l        g r?   rk   r@   s     r   rm   rn      s    IIr   c                 v    U R                   (       a(  [        U R                   ;   a  U R                   [           $ g g r?   )
conditionsSTARTED_CONDITIONr3   s    r   started_conditionExecution.started_condition   s-    ,?__.// @r   c                 (    U R                   [           $ r?   )r(   	JOB_LABELr3   s    r   job_nameExecution.job_name   s    ;;y!!r   r   N)r   r   r   r   rS   API_CATEGORYrT   COMPLETED_CONDITIONREADY_CONDITION	frozensetrr   TERMINAL_CONDITIONSr   ContainerResourcer   rV   r$   r^   rb   rW   rg   rm   rs   rw   r   r   r   r   r   r   &   s   K%,	$'/!#4o"FGO+== Ob H H 3 3   	<<    ! ! " "       0 0 " "r   r   )rS   
__future__r   r   r   enumgooglecloudsdk.api_lib.runr   r   	RUN_GROUPr]   rr   rz   rv   Enumr   KubernetesObjectr   r   r   r   <module>r      sc    D &  '  9 1((:5  ! $	DII 
@"
++ @"r   