
                             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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 rS rS rS r SS jrS r " S S\R0                  5      rg)zFTraffic-specific printer and functions for generating traffic formats.    )absolute_import)division)print_function)unicode_literals)service)traffic_pair)	platforms)console_attr)custom_printer_basetraffic-c                    [         R                  " 5       [         R                  :X  a  U R                  R	                  [
        R                  5      nU R                  R	                  [
        R                  5      nX:X  a  U$ U=(       d    [        nU=(       d    [        nSR                  X5      $ U R                  R	                  [
        R                  5      [
        R                  :X  a  [
        R                  $ [
        R                  $ )z5Gets the ingress traffic allowed to call the service.z{} (currently {}))r	   GetPlatformPLATFORM_MANAGEDannotationsgetr   INGRESS_ANNOTATIONINGRESS_STATUS_ANNOTATION_INGRESS_UNSPECIFIEDformatlabelsENDPOINT_VISIBILITYCLUSTER_LOCALINGRESS_INTERNALINGRESS_ALL)recordspec_ingressstatus_ingresss      >lib/googlecloudsdk/command_lib/run/printers/traffic_printer.py_GetIngressr    !   s    	 : ::%%))'*D*DEL''++G,M,MNN%!9%9l%=)=n ''EE!!	#&-&;&;	<###    c                 T    U R                   R                  [        R                  5      $ )z1Gets the IAP traffic allowed to call the service.)r   r   r   IAP_ANNOTATION)r   s    r   _GetIapr$   3   s    					 6 6	77r!   c                 ,   U R                   (       a,  U R                  (       d  SR                  U R                  5      $ U R                   (       d,  U R                  (       a  SR                  U R                  5      $ SR                  U R                  5      $ )zHReturns the tag with padding and an adding/removing indicator if needed.z  {} (Adding):z  {} (Deleting):z  {}:)inSpecinStatusr   tag)r(   s    r   _GetTagAndStatusr)   8   sY    ZZ""377++::#,,$$SWW-->>#''""r!   c                    [         R                  " 5       nU R                  UR                  U R                  5      [
        R                  " U R                   Vs/ s H  nS[        U5      UR                  4PM     sn5      4$ s  snf )zDTransforms a single TrafficTargetPair into a marker class structure. )
r
   GetConsoleAttrdisplayPercent	EmphasizedisplayRevisionIdcpTabletagsr)   url)pairconsolets      r   _TransformTrafficPairr7   B   sk    '')'


w001G1GH
((diiHiR)!,aee4iH
I
K KHs   "BNc                    [         R                  " [         R                  " S U  5       5      /5      n[         R                  " SU4/5      /nUb(  UR	                  [         R                  " SU4/5      5        Ub(  UR	                  [         R                  " SU4/5      5        UR	                  [         R                  " SU4/5      5        [         R                  " USS9$ )zCTransforms a List[TrafficTargetPair] into a marker class structure.c              3   8   #    U  H  n[        U5      v   M     g 7f)N)r7   ).0ps     r   	<genexpr>)_TransformTrafficPairs.<locals>.<genexpr>N   s     @-Q%a((-s   URLIngresszIap EnabledTraffic<   )max_column_width)r0   Sectionr1   Labeledappend)traffic_pairsservice_urlservice_ingressservice_iaptraffic_sectionroute_sections         r   _TransformTrafficPairsrL   I   s     JJ	xx@-@@A/ ::{3456- i%A$BCDm[%A$BCDrzzI#?"@AB	MB	77r!   c                 4   U R                   SL n[        R                  " U R                  U R                  U R
                  U(       a  [        OU R                   R                  5      n[        UU(       a  SOU R                  [        U 5      [        U 5      5      $ )aU  Transforms a service's route fields into a marker class structure to print.

Generates the custom printing format for a service's url, ingress, and traffic
using the marker classes defined in custom_printer_base.

Args:
  service_record: A Service object.

Returns:
  A custom printer marker object describing the route fields print format.
Nr+   )statusr   GetTrafficTargetPairsspec_trafficstatus_traffic
is_managedr   latestReadyRevisionNamerL   domainr    r$   )service_record	no_statusrF   s      r   TransformRouteFieldsrW   Y   s     ##t+)44!!>#@#@
 '..FF	I-
 
 b>00.!n	
 r!   c                   6   ^  \ rS rSrSrSU 4S jjrS rSrU =r$ )TrafficPrinters   z=Prints a service's traffic in a custom human-readable format.c                 0   > [         [        U ]  USU5        g)z3Overrides ResourcePrinter.Print to set single=True.TN)superrY   Print)self	resourcessingleintermediate	__class__s       r   r]   TrafficPrinter.Printv   s     
.$%i|Dr!   c                 J    U(       a  US   R                   nOSn[        X5      $ )z@Transforms a List[TrafficTargetPair] into a marker class format.r   r+   )
serviceUrlrL   )r^   r   rG   s      r   	TransformTrafficPrinter.Transform   s$    1I((kk!&66r!    )FF)	__name__
__module____qualname____firstlineno____doc__r]   rf   __static_attributes____classcell__)rb   s   @r   rY   rY   s   s    E	E7 7r!   rY   )NN)rm   
__future__r   r   r   r   googlecloudsdk.api_lib.runr   r   googlecloudsdk.command_lib.runr	   googlecloudsdk.core.consoler
   googlecloudsdk.core.resourcer   r0   TRAFFIC_PRINTER_FORMATr   r    r$   r)   r7   rL   rW   CustomPrinterBaserY   rh   r!   r   <module>rw      sl    M &  % ' . 3 4 4 B #  $8
#K CG8 47R)) 7r!   