
                             S 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	\4S
 jrS rS rS\	R"                  S\S\S\4S jrS\	R"                  S\4S jrS\	R"                  S\4S jrg)zstuff.    )List)types_utils)base)runapps_v1alpha1_messagesz'  "{edge_source}":n -> "{edge_dest}":n;z{type} | <n> {name}bindingsnamec              #     #    SR                  US9v   Sv   Sv   Sv   0 n0 n0 nU  HX  nUR                  nUR                  nXd[        U5      '   Xt[        U5      '   [	        X65        [	        X'5        [        Xg5      v   MZ     Sv   U HM  nXA   nUR                  UR                  S5      n	UR                  UR                  S5      n
[        XU
5      v   MO     Sv   g7f)	zProduce graph of the given bindings.

Args:
  bindings: the list of bindings.
  name: name of the graph

Yields:
  the binding graph in DOT format.
zstrict digraph {graph_name} {{)
graph_namez0  node [style="filled" shape=Mrecord penwidth=2]z  rankdir=LR
r   }N)	formatfrom_idto_id	_NodeName
_CountType_GraphvizEdgegettype_GraphvizNode)r   r   
in_counterout_counteridsbinding	source_iddest_idres_idin_count	out_counts              8lib/googlecloudsdk/command_lib/run/integrations/graph.pyGenerateBindingGraphr       s      	)//4/@@::**+
#gImmG )	)%	'{&z#
	
++  	*dYF~~fkk1-HQ/I
)
44	  	)s   CC c                 Z    U R                  UR                  S5      S-   XR                  '   g )Nr      )r   r   )counterr   s     r   r   r   D   s"     V[[!4q8'++    c                 N    [         R                  [        U 5      [        U5      S9$ )N)edge_source	edge_dest)_EDGE_FORMATr   r   )r   r   s     r   r   r   H   s*    			G$%  
 
 r$   r   r   r   returnc                     US:H  =(       a    US:  nUS:H  =(       a    US:  nU(       a  SnSnOU(       a  SnSnOSnSnSR                  [        U 5      [        U 5      XV5      $ )	zStyle for the node.

Args:
  res_id: resource ID of the node
  in_count: number of bindings going into this node
  out_count: number of bindings coming out of this node

Returns:
  node style code in DOT
r   z#e37400z#fdd663z#0d652dz#81c995z#174ea6z#8ab4f8z-  "{}" [label="{}" color="{}" fillcolor="{}"])r   r   
_NodeLabel)r   r   r   ingressbackingcolor	fillcolors          r   r   r   O   sp     M+i!m'N+x!|'EIEIEI5<<
F
Z/r$   c                 N    SR                  U R                  U R                  5      $ )Nz{}/{})r   r   r   )r   s    r   r   r   o   s    	V[[	11r$   c                     [         R                  " U R                  5      nU R                  R                  5       nU(       a  UR                  (       a  UR                  n[
        R                  X R                  S9$ )N)r   r   )r   GetTypeMetadataByResourceTyper   
capitalizelabel_LABEL_FORMATr   r   )r   type_metadata	type_names      r   r+   r+   s   sV    ;;FKKH-kk$$&)}**##I			9;;		??r$   N)__doc__typingr   'googlecloudsdk.api_lib.run.integrationsr   4googlecloudsdk.command_lib.run.integrations.typekitsr   6googlecloudsdk.generated_clients.apis.runapps.v1alpha1r   runappsr(   r5   BindingDatastrr    r   r   
ResourceIDintr   r   r+    r$   r   <module>rC      s      ? E g 9%$4(8(8#9 $ $N9*-:=@2g(( 2S 2@w)) @c @r$   