
    (                     0   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S
KJr  SSKJr  SSKJr  SSKJr  SSKr\R.                  " \R0                  R2                  5      \R4                   " S S\R6                  5      5       5       r\R.                  " \R0                  R:                  5       " S S\5      5       r\R.                  " \R0                  R>                  5       " S S\5      5       r   SS jr!S r"S r#g)z9Command for adding a BGP peer to a Compute Engine router.    )absolute_import)division)unicode_literals)base_classes)routers_utils)poller)waiter)base)flags)router_utils)log)	resourcesNc                   R    \ rS rSrSrSrSr\S 5       r\S 5       r	 S	S jr
S rSrg)

AddBgpPeer"   *Add a BGP peer to a Compute Engine router.Nc                    [         R                  " 5       U l        U R                  R                  U5        [        R
                  " 5       U l        U R                  R                  U5        [        R                  R                  U5        [         R                  " USS9  [         R                  " US5        [         R                  " U5        g )NT)for_add_bgp_peerpeer)r   RouterArgument
ROUTER_ARGAddArgumentinstance_flagsInstanceArgumentForRouterINSTANCE_ARGr
   
ASYNC_FLAGAddToParserAddBgpPeerArgs!AddReplaceCustomAdvertisementArgs!AddReplaceCustomLearnedRoutesArgsclsparsers     +lib/surface/compute/routers/add_bgp_peer.py_ArgsAddBgpPeer._Args*   s    ))+CNNNv&%??AC  (OO'	$7	++FF;	++F3    c                 &    U R                  U5        g Nr%   r!   s     r$   ArgsAddBgpPeer.Args5       IIfr'   c           	      &   [         R                  " U R                  5       5      nUR                  R                  nUR                  R
                  R                  nU R                  R                  XR                  5      nUR                  nUR                  U" S0 UR                  5       D65      nSn	UR                  bC  U R                  R                  UUR                  [        R                   " UR                  5      S9n	["        R$                  " X5      n
['        UUU
UU	S9n["        R(                  " U5      (       aZ  ["        R*                  " XDR,                  US9u  pnUUUS.n[.        R0                  " U5       H  u  nnUc  M  [3        UUU5        M     UR4                  b#  [6        R8                  " XAR4                  S9Ul        UR<                  R?                  U5        UR@                  b4  URC                  XR@                  S9nURD                  R?                  U5        URG                  URI                  URJ                  URL                  URO                  5       US95      n[        RP                  RS                  URT                  S	URJ                  URL                  S
.S9nURV                  (       aA  [X        RZ                  " USR]                  URO                  5       URT                  5      SSS9  U$ UR                  RS                  URO                  5       SURJ                  URL                  S
.S9n[^        R`                  " UU5      n[b        Rd                  " UUSR]                  URT                  URO                  5       5      5      $ )a  Runs the command.

Args:
  args: contains arguments passed to the command
  support_bfd_mode: The flag to indicate whether bfd mode is supported.

Returns:
  The result of patching the router adding the bgp peer with the
  information provided in the arguments.
N)scope_lister)md5_authentication_key_namesupport_bfd_modeinstance_ref)messagesresource_classargs)advertiseModeadvertisedGroupsadvertisedIpRanges)r3   	ip_ranges)namekey)projectregionrouterrouterResourcezcompute.regionOperations)r<   r=   )
collectionparamszrouter [{0}] to add peer [{1}]Tz[Run the [gcloud compute operations describe] command to check the status of this operation.)kindis_asyncdetailszcompute.routersz#Creating peer [{0}] in router [{1}] )3r   ComputeApiHolderReleaseTrackclientr3   apitools_clientroutersr   ResolveAsResourcer   ComputeRoutersGetRequestGetAsDictinstancer   r   GetInstanceZoneScopeListerr    GenerateMd5AuthenticationKeyName_CreateBgpPeerMessageHasReplaceAdvertisementFlagsParseAdvertisementsRouterBgpPeersix	iteritemssetattrset_custom_learned_route_rangesr   ParseCustomLearnedIpRangescustomLearnedIpRangesbgpPeersappendmd5_authentication_keyRouterMd5AuthenticationKeymd5AuthenticationKeysPatchComputeRoutersPatchRequestr<   r=   NameREGISTRYParser:   async_r   UpdatedResourceformatr   Pollerr	   WaitFor)selfr5   r1   holderr3   service
router_refrequest_typereplacementr2   r0   r   modegroupsrangesattrsattrvaluer^   resultoperation_reftarget_router_refoperation_pollers                          r$   _RunAddBgpPeer._Run9   sA    **4+<+<+>?F}}%%Hmm++33G2249I9IJJ44L++lAZ->->-@ABKL}} &&88



%@@O 9 l #/"O"O# !$?)!D 0066)==,B,BdF
  $ &e u-+$
$e
$ . ++7#0#K#K'K'K$d  %"".'BB*0K0K  C   ''../EF]]++&&$$??$&	 	, 	
F &&,,-!)) ''
 - M {{	
/66oo 7
 m((..$!)) ''
 /  }}W.?@>>-44IIz(	
 r'   c                 $    U R                  U5      $ )See base.UpdateCommand.r{   rk   r5   s     r$   RunAddBgpPeer.Run   s    99T?r'   rE   )F)__name__
__module____qualname____firstlineno____doc__r   r   classmethodr%   r+   r{   r   __static_attributes__rE   r'   r$   r   r   "   sH     3*,4 4   xtr'   r   c                   6    \ rS rSrSrSrSr\S 5       rS r	Sr
g)AddBgpPeerBeta   r   Nc                 &    U R                  U5        g r)   r*   r!   s     r$   r+   AddBgpPeerBeta.Args   r-   r'   c                 "    U R                  USS9$ )r~   Fr1   r   r   s     r$   r   AddBgpPeerBeta.Run   s    99TE922r'   rE   r   r   r   r   r   r   r   r   r+   r   r   rE   r'   r$   r   r      s&    2*, 3r'   r   c                   6    \ rS rSrSrSrSr\S 5       rS r	Sr
g)AddBgpPeerAlpha   r   Nc                 &    U R                  U5        g r)   r*   r!   s     r$   r+   AddBgpPeerAlpha.Args   r-   r'   c                 "    U R                  USS9$ )r~   Tr   r   r   s     r$   r   AddBgpPeerAlpha.Run   s    99   r'   rE   r   rE   r'   r$   r   r      s&    2*, r'   r   c                    U(       a  [        X5      nO[        X5      nSnUR                  bR  UR                  (       a!  U R                  R                  R
                  nO U R                  R                  R                  nU R                  UR                  UR                  UR                  UR                  UR                  UUUR                  UR                  UR                  UR                  UR                   UR"                  S9nUR$                  Ul        Ub  UR)                  5       Ul        UR,                  b  X'l        UR0                  b  UR0                  Ul        UR4                  b  UR4                  Ul        U$ )ah  Creates a BGP peer with base attributes based on flag arguments.

Args:
  messages: API messages holder.
  args: contains arguments passed to the command.
  md5_authentication_key_name: The md5 authentication key name.
  support_bfd_mode: The flag to indicate whether bfd mode is supported.
  instance_ref: An instance reference.

Returns:
  the RouterBgpPeer
N)r:   interfaceNamepeerIpAddresspeerAsnadvertisedRoutePriorityenablebfd
enableIpv6ipv6NexthopAddresspeerIpv6NexthopAddress
enableIpv4ipv4NexthopAddresspeerIpv4NexthopAddress)_CreateBgpPeerBfdMessageMode_CreateBgpPeerBfdMessageenabledrU   EnableValueValuesEnumTRUEFALSE	peer_name	interfacepeer_ip_addresspeer_asnadvertised_route_priorityenable_ipv6ipv6_nexthop_addresspeer_ipv6_nexthop_addressenable_ipv4ipv4_nexthop_addresspeer_ipv4_nexthop_addresscustom_learned_route_prioritycustomLearnedRoutePrioritySelfLinkrouterApplianceInstancer^   md5AuthenticationKeyNameexport_policiesexportPoliciesimport_policiesimportPolicies)r3   r5   r0   r1   r2   r   r   rw   s           r$   rR   rR      sI   & 
&x
6C
"8
2C&	\\||%%;;@@f%%;;AAf!!>>NN((mm"<<
!!22!;;!!22!;; " &  '+&H&H&#%1%:%:%<F"	  ,&A#	% 00F	% 00F	-r'   c                 |   UR                  S5      (       dC  UR                  S5      (       d-  UR                  S5      (       d  UR                  S5      (       d  gSnUR                  b%  U R                  R                  UR                  5      nU R                  UR                  UR
                  UUR                  S9$ )@Creates a BGP peer with base attributes based on flag arguments.bfd_min_receive_intervalbfd_min_transmit_intervalbfd_session_initialization_modebfd_multiplierN)minReceiveIntervalminTransmitIntervalsessionInitializationMode
multiplier)IsSpecifiedr   RouterBgpPeerBfd(SessionInitializationModeValueValuesEnumr   r   r   )r3   r5   r   s      r$   r   r     s     122			5	6	6			;	<	<			*	+	+$(!	))5!!JJ00	
 $
 
	"	"6688 ?$$	 
# 
 r'   c                    UR                  S5      (       dC  UR                  S5      (       d-  UR                  S5      (       d  UR                  S5      (       d  gSnSnUR                  bJ  U R                  R                  UR                  5      nU R                  R	                  UR                  5      nU R                  UR
                  UR                  UUUR                  S9$ )r   r   r   r   r   N)r   r   rq   r   r   )r   r   r   ModeValueValuesEnumr   r   r   r   )r3   r5   rq   r   s       r$   r   r   .  s     122			5	6	6			;	<	<			*	+	+	$$(!	))5$$88,,D 	!!JJ00	
 $
 
	"	"6688 ?$$ 
# 
 r'   )FN)$r   
__future__r   r   r   googlecloudsdk.api_lib.computer   r   )googlecloudsdk.api_lib.compute.operationsr   googlecloudsdk.api_lib.utilr	   googlecloudsdk.callioper
   ,googlecloudsdk.command_lib.compute.instancesr   r   *googlecloudsdk.command_lib.compute.routersr   googlecloudsdk.corer   r   rV   ReleaseTracksrG   GAUniverseCompatibleUpdateCommandr   BETAr   ALPHAr   rR   r   r   rE   r'   r$   <module>r      s    @ &  ' 7 8 < . ( P < C # ) 
 D%%(()Q## Q  *Qh D%%**+3Z 3 ,3 D%%++,n  -, 8v0r'   