
    ^                         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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rSr " S S\R0                  5      r " S S\5      r " S S\5      rg)zService-specific printer.    )absolute_import)division)print_function)unicode_literalsN)service)threat_detection_util)k8s_object_printer_util)revision_printer)traffic_printer)console_attr)custom_printer_baser   zrun.googleapis.com/presetsc                   F    \ rS rSrSrSrS rS rS rS r	S r
S	 rS
 rSrg)ServicePrinter$   zPrints the run Service in a custom human-readable format.

Format specific to Cloud Run services. Only available on Cloud Run commands
that print services.
Fc                     SnUR                   c  SnO%SR                  UR                   R                  5      n[        R                  " 5       R                  U5      $ )N zUnknown revisionzRevision {})statusformatlatestCreatedRevisionNamer   GetConsoleAttr	Emphasize)selfrecordheaders      >lib/googlecloudsdk/command_lib/run/printers/service_printer.py_GetRevisionHeader!ServicePrinter._GetRevisionHeader-   sJ    F}}!f##FMM$K$KLf&&(226::    c           	         SnUR                   R                  [        R                  S5      S:X  a  Sn[        R
                  " U R                  (       a  U R                  U5      OSU R                  U5      [        R                  " UR                  R                  5      [        R                  R                  UR                  U5      /5      $ )zAdds printers for the revision.Fr   manualT)annotationsgetr   SERVICE_SCALING_MODE_ANNOTATIONcpLineswith_presets_GetPresetInfor   k8s_util	GetLabelstemplatelabelsr
   RevisionPrinterTransformSpec)r   r   manual_scaling_enableds      r   _RevisionPrinters ServicePrinter._RevisionPrinters5   s    "wFFK	  $88'+'8'8F#b'6??112((66OO3	
	  r   c                    [         R                  " S[        R                  " U5      4/5      /nU R	                  U5      nU(       a*  [         R                  " SU4/5      nUR                  U5        [        R                  " U5      nUb1  [         R                  " SU4/5      nSUl        UR                  U5        [        R                  " U5      nUb*  [         R                  " SU4/5      nUR                  U5        UR                  [         R                  " S[        R                  " UR                  5      4/5      5        [         R                  " U5      $ )zAdds service-level values.zBinary AuthorizationScalingzBreakglass JustificationFDescriptionzThreat Detection)r$   Labeledr(   GetBinAuthzPolicy_GetScalingModeappendGetBinAuthzBreakglass
skip_emptyGetDescription	crtd_utilPrintThreatDetectionStatethreat_detection_stateSection)	r   r   r+   scaling_modescaling_mode_labelbreakglass_valuebreakglass_labeldescriptiondescription_labels	            r   _GetServiceSettings"ServicePrinter._GetServiceSettingsF   sK    	

#X%?%?%GH
 	F ''/L::l
#' 	 mm&'55f=# %'7
8% 	 %*!mm$%))&1K**+
&& 	 mm%&
MM


"3311
 		 ::fr   c                 0   UR                   R                  [        5      nU(       GaY   [        R                  " U5      n[        U[        5      (       Ga+  U(       Ga#  / nU H  n[        U[        5      (       d  M  UR                  S5      (       d  M2  UR                  S5      n/ nUR                  5        Hg  u  pUS:X  aB  [        U	[        5      (       a-  U	R                  5        H  u  pUR                  X45        M     MM  US:w  d  MU  UR                  X45        Mi     UR                  U[        R                  " U5      45        M     U(       a-  [        R                  " S[        R                  " U5      4/5      $ gg! [        [        4 a     gf = f)z%Adds preset information if available.typeconfigPresetsr   )r!   r"   PRESET_ANNOTATIONjsonloads
isinstancelistdictitemsr7   r$   r4   Table
ValueError	TypeError)r   r   preset_annotationpresets_listpreset_sectionsppreset_typeparamskeyvalue
config_keyconfig_values               r   r'   ServicePrinter._GetPresetInfoq   s;   **../@Azz"34lD))l/a!T""quuV}}EE&Mkf !	*#(?z%'>'>27++-.jMM:"<= 3@F]--- !* $$k2::f3E%FG   ::	288O+DEFGG  )$ s&   AF ;F A4F A4F FFc                 .    [         R                  " U5      $ )Nr(   BuildHeaderr   r   s     r   rb   ServicePrinter.BuildHeader   s    ''r   c                    UR                   R                  [        R                  S5      nUS:X  a/  UR                   R                  [        R                  S5      nSU-  $ UR                   R                  [        R
                  S5      nUR                   R                  [        R                  S5      nU(       a  SU< SU< S3$ SU-  $ )	z(Returns the scaling mode of the service.r   r    zManual (Instances: %s)0zAuto (Min: z, Max: )zAuto (Min: %s))r!   r"   r   r#    MANUAL_INSTANCE_COUNT_ANNOTATIONSERVICE_MIN_SCALE_ANNOTATIONSERVICE_MAX_SCALE_ANNOTATION)r   r   r?   instance_countmin_instance_countmax_instance_counts         r   r6   ServicePrinter._GetScalingMode   s    %%))//L x))--

2
2Bn &66!--11

.
. "--11

.
. 

 	
  222r   c                    U R                  U5      nU R                  U5      [        R                  " UR                  5      /nUR                  S[        R                  " U5      SUUR                  5       (       a  SOS[        R                  " [        R                  " U5      U R                  U5      4/5      [        R                  " U5      /5        [        R                  " U5      $ )z@Transform a service into the output structure of marker classes. r   )rE   rb   r(   r)   r+   extendr   TransformRouteFieldsWillPrintOutputr$   r4   LastUpdatedMessager/   FormatReadyMessager%   )r   r   service_settingsliness       r   	TransformServicePrinter.Transform   s    //7 6==)E 
LL,,V4 0022


''/""6*
  	 	##F+  88E?r    N)__name__
__module____qualname____firstlineno____doc__r&   r   r/   rE   r'   rb   r6   rx   __static_attributes__rz   r   r   r   r   $   s2     ,;")V8(32r   r   c                       \ rS rSrSrSrSrg)ServicePrinterAlpha   z9Prints the run Service in a custom human-readable format.Trz   N)r{   r|   r}   r~   r   r&   r   rz   r   r   r   r      s
    A,r   r   c                       \ rS rSrSrS rSrg)MultiRegionServicePrinter   zDPrints the run MultiRegionService in a custom human-readable format.c                 ,    [         R                  " USS9$ )NT)is_multi_regionra   rc   s     r   rb   %MultiRegionServicePrinter.BuildHeader   s    ==r   rz   N)r{   r|   r}   r~   r   rb   r   rz   r   r   r   r      s
    L>r   r   )r   
__future__r   r   r   r   rL   googlecloudsdk.api_lib.runr   googlecloudsdk.command_lib.runr   r;   'googlecloudsdk.command_lib.run.printersr	   r(   r
   r   googlecloudsdk.core.consoler   googlecloudsdk.core.resourcer   r$   SERVICE_PRINTER_FORMATrK   CustomPrinterBaser   r   r   rz   r   r   <module>r      sg      &  % '  . M W D C 4 B" 0 XR)) Xv. > >r   