
    B                         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 dd	lmZ e
j"                   G d
 de
j$                               Zddde_        y)z<Command for listing bgp routes from a Compute Engine router.    )absolute_import)division)unicode_literals)
list_pager)base_classes)base)flags)	arg_utilsc                   0    e Zd ZdZdZed        Zd Zd Zy)ListBgpRouteszdList routes advertised and learned on individual BGP sessions, both pre- and post-policy evaluation.Nc                    t        j                         t        _        t        j                  j	                  |d       |j
                  j                  t         j                         |j                  ddd       |j                  dt        j                  dd	d
dd       |j                  dt        j                  ddddd       |j                  dddd       |j                  ddd       y )Nlist)operation_typez--peerz6Limit results to routes learned from this peer (name).T)helprequiredz--address-familyzInterface with IPv4-based BGP.zInterface with IPv6-based BGP.)IPV4IPV6zCLimit results to routes learned for this Address Family Identifier.)typechoicesr   r   z--route-directionzLearned routes.zAdvertised routes.)INBOUNDOUTBOUNDz*Limit results to routes in this direction.z--policy-applied
store_truez+Routes returned are post-policy evaluation.)actiondefaultr   z--destination-rangezLimit results to prefixes.
CIDR_RANGE)r   metavar)r	   RouterArgumentr   
ROUTER_ARGAddArgumentdisplay_infoAddCacheUpdaterRoutersCompleteradd_argumentr
   ChoiceToEnumName)clsparsers     .lib/surface/compute/routers/list_bgp_routes.pyArgszListBgpRoutes.Args$   s
   $335M(((G
''(>(>?
I  
 ''44
 W  	 ''(,
 >  	 >	   -      c                    t        j                  | j                               }|j                  }t        j
                  j                  ||j                  t        j                  |            }|j                  j                  j                  |j                        }|j                  j                  j                  | j                  |j                               } |j                  j                  d	i |j#                         |j$                  |||j&                  |j(                  d}t+        j,                  |j.                  j0                  ||j2                  |j4                  ddddd	      S )
z@Issues a request necessary for listing bgp routes from a Router.)scope_lister)peeraddressFamily	routeTypepolicyApplieddestinationPrefixr   result	pageTokennextPageToken
maxResults)limit
batch_sizemethodfieldcurrent_token_attributenext_token_attributebatch_size_attribute )r   ComputeApiHolderReleaseTrackclientr   r   ResolveAsResource	resourcescompute_flagsGetDefaultScopeListermessages"ComputeRoutersListBgpRoutesRequestAddressFamilyValueValuesEnumaddress_familyRouteTypeValueValuesEnumConvertRouteDirectionroute_directionAsDictr,   policy_applieddestination_ranger   YieldFromListapitools_clientroutersr5   	page_size)selfargsholderr?   
router_refrG   
route_typerequests           r'   RunzListBgpRoutes.RunN   s@   **4+<+<+>?F]]F));;"88@ < J
 __GGddN CC\\""4#7#78J Afoo@@ 



YY$))00G ##&&jj>> +,)
 
r)   c                     |dk(  ry|dk(  ry|S )Nr   LEARNEDr   
ADVERTISEDr<   )rR   rJ   s     r'   rI   z#ListBgpRoutes.ConvertRouteDirections   s    )#	J	&r)   )	__name__
__module____qualname____doc__r   classmethodr(   rX   rI   r<   r)   r'   r   r      s(    l*' 'R#Jr)   r   zv  *{command}* lists routes advertised and learned on individual BGP sessions, both pre- and post-policy evaluation.
  a            To list inbound BGP routes limited to IPv4 addess family from a router `my-router` BGP peer `my-bgp-peer` in region `us-central1`, run:

              $ {command} my-router --region=us-central1 --address-family=IPV4 --peer=my-bgp-peer --route-direction=INBOUND"
          )DESCRIPTIONEXAMPLESN)r_   
__future__r   r   r   apitools.base.pyr   googlecloudsdk.api_lib.computer   googlecloudsdk.callioper   "googlecloudsdk.command_lib.computer	   rB   *googlecloudsdk.command_lib.compute.routers$googlecloudsdk.command_lib.util.apisr
   UniverseCompatibleListCommandr   detailed_helpr<   r)   r'   <module>rm      se     C &  ' ' 7 ( E < : ZD$$ Z Z|		 r)   