
                             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rSrS	 rS
 rS rS r SS jrS rS r " S S\
R(                  5      rg)zFTraffic-specific printer and functions for generating traffic formats.    )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    /   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%   4   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   _TransformTrafficPairr3   >   sk    '')'


w001G1GH
((diiHiR)!,aee4iH
I
K KHs   "BNc                    [         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 bZ  [         R                  " [         R                  " S U  5       5      /5      nUR                  [         R                  " SU4/5      5        [         R                  " USS9$ )zCTransforms a List[TrafficTargetPair] into a marker class structure.URLIngresszIap Enabledc              3   8   #    U  H  n[        U5      v   M     g 7f)N)r3   ).0ps     r   	<genexpr>)_TransformTrafficPairs.<locals>.<genexpr>P   s     BMq'**Ms   Traffic<   )max_column_width)r,   LabeledappendSectionr-   )traffic_pairsservice_urlservice_ingressservice_iaproute_sectiontraffic_sections         r   _TransformTrafficPairsrH   E   s     ::{3456- i%A$BCDm[%A$BCDjj	BMB	BCO i%A$BCD	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   latestReadyRevisionNamerH   domainr   r    )service_record	no_statusrB   s      r   TransformRouteFieldsrS   V   s     ##t+)44!!>#@#@
 '..FF	I-
 
 b>00.!n	
 r   c                 l    U R                   (       d  g[        SU R                   S   [        U 5      5      $ )zTransforms an instance's route fields into a marker class structure.

Args:
  instance_record: An Instance object.

Returns:
  A custom printer marker object describing the route fields print format.
Nr   )urlsrH   r   )instance_records    r   TransformInstanceRouteFieldsrW   p   s6     
			
1/"
 r   c                   6   ^  \ rS rSrSrSU 4S jjrS rSrU =r$ )TrafficPrinter   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.Print   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'   )
serviceUrlrH   )r^   r   rC   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    E	E7 7r   rY   )NN)rm   googlecloudsdk.api_lib.runr   r   googlecloudsdk.command_lib.runr   googlecloudsdk.core.consoler   googlecloudsdk.core.resourcer   r,   TRAFFIC_PRINTER_FORMATr   r   r    r%   r3   rH   rS   rW   CustomPrinterBaserY   rh   r   r   <module>rv      sg    M / 3 4 4 B #  $8
#K CG8"4$7R)) 7r   