
                             S r SSKrSSKJr  SSKJr  SSKJr  SSKJr   " S S\R                  5      r
 " S	 S
5      r " S S\R                  5      rg)z<Wraps a Cloud Run Instance message with convenience methods.    N)container_resource)
k8s_object)console_attr)timesc                   ,    \ rS rSrSrSrSrSrSrSr	Sr
g	)
InstanceStatus   pendingrunningstopped	completedfailedunknown N)__name__
__module____qualname____firstlineno__PENDINGRUNNINGSTOPPED	COMPLETEDFAILEDUNKNOWN__static_attributes__r       *lib/googlecloudsdk/api_lib/run/instance.pyr   r      s     ''')&'r   r   c                   "    \ rS rSrSrSS jrSrg)InstanceSymbol#   z:A class to represent the symbol and color for an instance.Nc                 (    Xl         X l        X0l        g Nbestaltcolor)selfr$   r%   r&   s       r   __init__InstanceSymbol.__init__&   s    IHJr   )r%   r$   r&   r"   )r   r   r   r   __doc__r(   r   r   r   r   r   r   #   s
    Br   r   c                   z   \ rS rSrSrSrS rSrSrSr	Sr
Sr\R                  \" \S	S
S9\R                  \" \	SSS9\R                   \" \
SSS9\R"                  \" \SS9\R$                  \" SSSS90rS r\S 5       r\S 5       r\S 5       r\S 5       r\S 5       r\R6                  S 5       r\S 5       rS rSrg)Instance,   zBWraps a Cloud Run instance message, making fields more convenient.zrun.googleapis.comRunningu   …u   ▶u   ⏸u   ✔.yellowr#   +green-bluer$   r%   Xredc                     U R                   R                  cD  [        R                  " U R                  R
                  R                  5      U R                   l        g g r"   )specnodeSelectorr   InitializedInstance	_messagesInstanceSpecNodeSelectorValuer'   s    r   _EnsureNodeSelectorInstance._EnsureNodeSelectorF   sA    yy%)==
..
%
%
7
7 dii &r   c                 :    U R                   R                  SS5      $ )Nr.   F)
conditionsgetr?   s    r   
is_runningInstance.is_runningL   s    ??y%00r   c                     U $ r"   r   r?   s    r   templateInstance.templateP   s    Kr   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}.keyvalue)	key_fieldvalue_field)
r@   r   KeyValueListAsDictionaryWrapperr9   r:   additionalPropertiesr<   r=   r>   AdditionalPropertyr?   s    r   node_selectorInstance.node_selectorT   sU     	55		33##55HH	 r   c                     U R                   R                  (       aE  U R                   R                  R                  (       a   U R                   R                  R                  $ / $ )z!Return the URLs of this instance.)_mstatusurlsr?   s    r   rW   Instance.urls_   s8     ww~~$''..--WW^^   Ir   c                     U R                   R                  (       a=  [        [        R                  " U R                   R                  5      R
                  5      $ g)zThe timeout number in the revisionTemplate.

The lib can accept either a duration format like '1m20s' or integer like
'80' to set the timeout. The returned object is an integer value, which
assumes second the unit, e.g., 80.
N)r9   timeoutintr   ParseDurationtotal_secondsr?   s    r   rZ   Instance.timeoutf   s:     yy$$TYY%6%67EEFFr   c                     Uc  S U R                   l        g [        R                  " [	        U5      SS9n[        R
                  " U5      U R                   l        g )Ns)default_suffix)r9   rZ   r   r\   strFormatDurationForJson)r'   rL   durations      r   rZ   r^   r   s@    }dii$$SZDh55h?diir   c                    U R                   R                  U R                  S5      nU(       a  US   (       a  [        R                  $ U(       ae  US   (       d[  UR                  S5      (       d  [        R
                  $ UR                  S5      S:X  a  [        R                  $ [        R                  $ [        R                  $ )z#Return the status of this instance.NrV   reasonStopped)	rC   rD   READY_CONDITIONr   r   r   r   r   r   )r'   
ready_conds     r   rV   Instance.statusz   s     $$T%9%94@Jj*###	Jx0^^H%%'''>>(#y0%%% $$$ ###r   c                    U R                   n[        R                  " 5       R                  5       nU R                  R                  U[        SSS95      nU R                  UR                  UR                  U5      UR                  4$ )zAReturn a tuple of ready_symbol and display color for this object.?r5   )rV   r   GetConsoleAttrGetEncodingINSTANCE_SYMBOLSrD   r   _PickSymbolr$   r%   r&   )r'   rV   encodinginstance_symbols       r   ReadySymbolAndColorInstance.ReadySymbolAndColor   sw    [[F**,88:H++//CS1O
 	--/B/BHM r   r   N)r   r   r   r   r*   API_CATEGORYKINDrh   ELLIPSIS_SYMBOLPLAY_SYMBOLPAUSED_SYMBOLCHECK_MARK_SYMBOLr   r   r   r   r   r   r   ro   r@   propertyrE   rH   rR   rW   rZ   setterrV   rs   r   r   r   r   r,   r,   ,   sA   J%,	$/-/3++-, nCx n7 n#V 4E3 O^#UK 1 1       	 	 >>@ @ $ $(r   r,   )r*   enumgooglecloudsdk.api_lib.runr   r   googlecloudsdk.core.consoler   googlecloudsdk.core.utilr   Enumr   r   ContainerResourcer,   r   r   r   <module>r      sK    C  9 1 4 *TYY  n!33 nr   