
    k                     8   d Z ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddl	m
Z
 ddlmZ dd	lmZ  e
j                  e
j                   j"                  e
j                   j$                  e
j                   j&                         G d
 de
j(                               Zy)z7Command for listing internal IP addresses in a network.    )absolute_import)division)unicode_literals)
list_pager)base_classes)base)
properties)resource_projectorc                   6    e Zd ZdZdZddedZed        Zd Zy)
ListRoutesz=List received or advertised routes for a VPC network peering.z    List received routes for VPC network peering in us-central1:

      $ {command} peering-name         --network=network-name --region=us-central1 --direction=INCOMING
  z      *{command}* is used to list received or advertised routes for a VPC
      network peering. This includes subnetwork routes, static custom routes,
      and dynamic custom routes.
      )briefDESCRIPTIONEXAMPLESc                     | j                  dd       | j                  ddd       | j                  ddd	       | j                  d
ddddd d       | j                  j                  d       y )Nnamez'Name of the peering to list routes for.)helpz	--networkTzNetwork of the peering.)requiredr   z--regionzRegion to list the routes for.z--directionzTo list received routes.zTo list advertised routes.)INCOMINGOUTGOINGc                 "    | j                         S )N)upper)xs    4lib/surface/compute/networks/peerings/list_routes.py<lambda>z!ListRoutes.Args.<locals>.<lambda>C   s
    qwwy    z        Direction of the routes to list. To list received routes, use
        `INCOMING`. To list advertised routes, use `OUTGOING`.
        )r   choicestyper   z        table(
            dest_range,
            type,
            next_hop_region,
            priority,
            status)
    )add_argumentdisplay_info	AddFormat)parsers    r   ArgszListRoutes.Args5   s    
%NO
d)B  D
T(H  J
24
 !   !! # 	r   c              #     K   t        j                  | j                               }|j                  j                  }|j
                  }t        j                  j                  j                  j                  d      }|j                  } |||j                  |j                  |j                        }|j                  }|j                   dk(  r|j"                  |_        n|j$                  |_        t'        j(                  |j*                  |dd|j,                  d       }	d }
|	D ]4  }t/        j0                  |      } |
|j                   |d	         |d
<   | 6 y w)NT)r   )projectnetworkpeeringNameregionr   ListPeeringRoutesitems)methodfieldlimit
batch_sizec                 "    |r| dk(  ryy| dk(  ryy)z?Create customized status field based on direction and imported.r   acceptedzaccepted by peerzrejected by configzrejected by peer config )	directionimporteds     r   _TransformStatusz(ListRoutes.Run.<locals>._TransformStatusk   s!    	
"#
"%*r   r2   status)r   ComputeApiHolderReleaseTrackclientapitools_clientMESSAGES_MODULEr	   VALUEScorer$   Get'ComputeNetworksListPeeringRoutesRequestr%   r   r'   DirectionValueValuesEnumr1   r   r   r   YieldFromListnetworksr,   r
   MakeSerializable)selfargsholderr7   messagesr$   list_requestrequest
directionsr)   r3   itemroutes                r   RunzListRoutes.RunQ   s)    **4+<+<+>?F]]**F%%H$$,,00$0?GCCLII{{	G
 66J~~#$--g$--g$$"jjE+  11$7e(z9JKeHok	 s   EEN)	__name__
__module____qualname____doc__exampledetailed_helpstaticmethodr"   rK   r0   r   r   r   r      s?     F' J
 - 	 	6+r   r   N)rO   
__future__r   r   r   apitools.base.pyr   googlecloudsdk.api_lib.computer   googlecloudsdk.callioper   googlecloudsdk.corer	   googlecloudsdk.core.resourcer
   ReleaseTracksr6   ALPHABETAGAListCommandr   r0   r   r   <module>r^      s~    > &  ' ' 7 ( * ; D%%++T->->-C-C%%((*^!! ^*^r   