
    2                     L   S r SSKJr  SSKJr  SSKJr  SSK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Jr  SSKJr  SSKrS rS r \RB                  " \RD                  RF                  5      \RH                   " S S\RJ                  5      5       5       r&S r'\RB                  " \RD                  RP                  \RD                  RR                  5      \RH                   " S S\&5      5       5       r*g)zCommand for creating routes.    )absolute_import)division)unicode_literalsN)base_classes)actions)arg_parsers)base)
exceptions)
completers)flags)resource_manager_tags_utils)
propertiesc                     U R                  SSS9  U R                  SSS9  [        R                  R                  U 5        U R                  SSS9  g)	z8Attach arguments for GA next-hops to the a parser group.z--next-hop-instancez      Specifies the name of an instance that should handle traffic
      matching this route. When this flag is specified, the zone of
      the instance must be specified using
      ``--next-hop-instance-zone''.
      helpz--next-hop-addressa         Specifies the IP address of an instance that should handle
      matching packets. The instance must have IP forwarding enabled
      (i.e., include ``--can-ip-forward'' when creating the instance
      using `gcloud compute instances create`)
      z--next-hop-vpn-tunnelz:The target VPN tunnel that will receive forwarded traffic.N)add_argumentr   NEXT_HOP_GATEWAY_ARGAddArgument)next_hop_groups    $lib/surface/compute/routes/create.py
_AddGaHopsr   )   sl     
   
   ((8H  K    c                    U R                  SSS9  U R                  SSSS9  U R                  S[        R                  " S	S
9/ SSS9  U R                  SSSS9  U R                  SS[        SS9  U R	                  SS9n[        U5        U R                  S[        R                  " [        R                  R                  R                  5      S[        R                  -   S9  U R                  SS[        R                  -   S9  UR                  SSS9  U R                  SS[        R                  -   S9  U R                  S [        R                   " 5       S!S"S#9  U R"                  R%                  [&        R(                  5        g$)%z!Add arguments for route creation.z--descriptionz/An optional, textual description for the route.r   z	--networkdefault9Specifies the network to which the route will be applied.)r   r   z--tags   )
min_lengthTAGz      Identifies the set of instances that this route will apply to. If no
      tags are provided, the route will apply to all instances in the network.
      )typer   metavarr   z--destination-rangeTz      The destination range of outgoing packets that the route will
      apply to. To match all traffic, use ``0.0.0.0/0''.
      )requiredr   z
--priorityi  z      Specifies the priority of this route relative to other routes
      with the same specificity. The lower the value, the higher the
      priority.
      )r   r   r   r!   z--next-hop-instance-zonez#The zone of the next hop instance. )actionr   z--next-hop-vpn-tunnel-regionz'The region of the next hop vpn tunnel. z--next-hop-ilba        Specifies the name or IP address of a forwarding rule for an internal TCP/UDP
      load balancer. The forwarding rule's `--load-balancing-scheme` must be
      `INTERNAL`. You can use any `--destination-range` that doesn't exactly
      match the destination of a subnet route and isn't more specific (has a
      longer subnet mask) than the destination of a subnet route. For
      more information, see
      https://cloud.google.com/load-balancing/docs/internal/ilb-next-hop-overview#destination_range.
      --next-hop-ilb-regionz,The region of the next hop forwarding rule. z--resource-manager-tagsz	KEY=VALUEzW          A comma-separated list of Resource Manager tags to apply to the route.
      )r   r    r   N)r   r   ArgListintadd_mutually_exclusive_groupr   r   StorePropertyr   VALUEScomputezoneinstance_flagsZONE_PROPERTY_EXPLANATIONcompute_flagsREGION_PROPERTY_EXPLANATIONArgDictdisplay_infoAddCacheUpdaterr   RoutesCompleter)parsernext_hops     r   _Argsr6   E   s    	M  O 	F  H
 	!,
   	
   	
	   00$0?(X "":#4#4#<#<#A#AB1445  7 	$5556  8
 
  
 	:556  8
 	 
	   	%%j&@&@Ar   c                   B    \ rS rSrSrSrSrSrSrSr	\
S 5       rS rSrg)Create   a  Create a new route.

  *{command}* is used to create routes. A route is a rule that
specifies how certain packets should be handled by the virtual
network. Routes are associated with virtual machine instances
by tag, and the set of routes for a particular VM is called
its routing table. For each packet leaving a virtual machine,
the system searches that machine's routing table for a single
best matching route.

Routes match packets by destination IP address, preferring
smaller or more specific ranges over larger ones (see
`--destination-range`). If there is a tie, the system selects
the route with the smallest priority value. The packet
is then forwarded as specified by `--next-hop-address`,
`--next-hop-instance`, `--next-hop-vpn-tunnel`, or
`--next-hop-gateway` of the winning route. Packets that do
not match any route in the sending virtual machine routing
table will be dropped.

Exactly one of `--next-hop-address`, `--next-hop-gateway`,
`--next-hop-vpn-tunnel`, or `--next-hop-instance` must be
provided with this command.

## EXAMPLES

To create a route with the name 'route-name' with destination range
'0.0.0.0/0' and with next hop gateway 'default-internet-gateway', run:

  $ {command} route-name \
    --destination-range=0.0.0.0/0 \
    --next-hop-gateway=default-internet-gateway

Nc                    UR                   R                  [        R                  5        [        R
                  " SSS9U l        [        R                  " SS9U l	        [        R                  " SS9U l        [        R                  " SS9U l        [        R                   " 5       U l        U R"                  R%                  USS9  ['        U5        g )Nr   Fr"   create)operation_type)r1   	AddFormatr   DEFAULT_LIST_FORMATnetwork_flagsNetworkArgumentForOtherResourceNETWORK_ARGr,   InstanceArgumentForRouteINSTANCE_ARG	vpn_flagsVpnTunnelArgumentForRouteVPN_TUNNEL_ARG	ilb_flagsForwardingRuleArgumentForRouteILB_ARGRouteArgument	ROUTE_ARGr   r6   )clsr4   s     r   ArgsCreate.Args   s    
!!%";";<#CCCCO &>>NC"<<eLC::EJCK'')CMMMfX>	&Mr   c                 x   [         R                  " U R                  5       5      nUR                  nU R                  R                  XR                  5      R                  5       nU R                  R                  XR                  5      nUR                  (       aH  U R                  R                  UUR                  [        R                  " U5      S9R                  5       nO)UR                  (       a  [        R                  " S5      eSnUR                   (       a:  ["        R$                  R                  XR                  5      nUR                  5       nOSnSn	UR&                  (       aH  U R(                  R                  UUR                  [*        R,                  " U5      S9R                  5       n	O'UR.                  (       a  [        R                  " S5      eSn
UR0                  (       aV   [2        R4                  " UR0                  5        UR6                  (       a  [8        R:                  " SS5      eUR0                  n
O(UR6                  (       a  [8        R:                  " SS5      eUR@                  RC                  URD                  UR@                  RG                  URH                  URJ                  URM                  5       UUURN                  UU	URP                  URR                  S9
S	9nXRT                  l+        URX                  b/  [[        UR@                  URX                  5      URT                  l.        UR_                  UR`                  Rb                  S
U4/5      $ ! [<         aK    U R>                  R                  UUR                  [*        R,                  " U5      S9R                  5       n
 GNMf = f)zEIssue API requests for route creation, callable from multiple tracks.)scope_listerz[[--next-hop-instance-zone] can only be specified in conjunction with [--next-hop-instance].Nza[--next-hop-vpn-tunnel-region] can only be specified in conjunction with [--next-hop-vpn-tunnel].r$   zKThis should not be specified if an IP address is used for [--next-hop-ilb].z@This can only be specified in conjunction with [--next-hop-ilb].)
description	destRangenamenetworknextHopInstance	nextHopIpnextHopGatewaynextHopVpnTunnelprioritytags)projectrouteInsert)2r   ComputeApiHolderReleaseTrackclientrA   ResolveAsResource	resourcesSelfLinkrK   next_hop_instancerC   r,   GetInstanceZoneScopeListernext_hop_instance_zonecompute_exceptionsArgumentErrornext_hop_gatewayr   r   next_hop_vpn_tunnelrF   r.   GetDefaultScopeListernext_hop_vpn_tunnel_regionnext_hop_ilb	ipaddress
ip_addressnext_hop_ilb_regionr
   InvalidArgumentException
ValueErrorrI   messagesComputeRoutesInsertRequestr[   RouterQ   destination_rangeNamenext_hop_addressrY   rZ   r\   
nextHopIlbresource_manager_tags_CreateRouteParamsparamsMakeRequestsapitools_clientroutes)selfargsholderr`   network_uri	route_refnext_hop_instance_urinext_hop_gateway_refnext_hop_gateway_urinext_hop_vpn_tunnel_urinext_hop_ilb_urirequests               r   Run
Create.Run   sM   **4+<+<+>?F]]F""44  (
  007G7GHI"//AA



%@@ B   xz	  
	$	$ ..*+ 	+ #"77II
  "1::<!" $ 3 3 E E



$::6B !F !D EMHJ  
	(	(,,67 7 $T../##33% (<= =  ,, 
	!	!//
! $/0 0 oo88!!oo##((,,!1++/4]] $ 
 9 G  0MM!!-/
//455gmm 

 
 
'
'7	;< C  $<<99&<< :  "	 	$s   .AM$ $AN98N9 )__name__
__module____qualname____firstlineno____doc__rA   rC   rF   rI   rK   classmethodrM   r   __static_attributes__r   r   r   r8   r8      s;    !F +,.')
 
Wr   r8   c           	         [         R                  " U5      nU R                  n[        [        R
                  " U5      5       VVs/ s H  u  pEUR                  R                  XES9PM      nnnU" UR                  US9S9$ s  snnf )N)keyvalue)additionalProperties)resourceManagerTags)r   GetResourceManagerTagsRouteParamssortedsix	iteritemsResourceManagerTagsValueAdditionalProperty)rs   rz   resource_manager_tags_mapr|   r   r   additional_propertiess          r   r{   r{   *  s    !889NO  & s}}-FGHH*# %%88S8NH   
 994 : 
 	s   %B c                       \ rS rSrSrSrg)CreateAlphaBetai:  a  Create a new route.

  *{command}* is used to create routes. A route is a rule that
specifies how certain packets should be handled by the virtual
network. Routes are associated with virtual machine instances
by tag, and the set of routes for a particular VM is called
its routing table. For each packet leaving a virtual machine,
the system searches that machine's routing table for a single
best matching route.

Routes match packets by destination IP address, preferring
smaller or more specific ranges over larger ones (see
``--destination-range''). If there is a tie, the system selects
the route with the smallest priority value. If there is still
a tie, it uses the layer 3 and 4 packet headers to
select just one of the remaining matching routes. The packet
is then forwarded as specified by ``--next-hop-address'',
``--next-hop-instance'', ``--next-hop-vpn-tunnel'', ``--next-hop-gateway'',
or ``--next-hop-ilb'' of the winning route. Packets that do
not match any route in the sending virtual machine routing
table will be dropped.

Exactly one of ``--next-hop-address'', ``--next-hop-gateway'',
``--next-hop-vpn-tunnel'', ``--next-hop-instance'', or ``--next-hop-ilb''
must be provided with this command.

## EXAMPLES

To create a route with the name 'route-name' with destination range
'0.0.0.0/0' and with next hop gateway 'default-internet-gateway', run:

  $ {command} route-name \
    --destination-range=0.0.0.0/0 \
    --next-hop-gateway=default-internet-gateway

r   N)r   r   r   r   r   r   r   r   r   r   r   :  s    #r   r   )+r   
__future__r   r   r   rn   googlecloudsdk.api_lib.computer   googlecloudsdk.callioper   r   r	   r
   "googlecloudsdk.command_lib.computer   rg   r   r.   r   3googlecloudsdk.command_lib.compute.forwarding_rulesrG   ,googlecloudsdk.command_lib.compute.instancesr,   +googlecloudsdk.command_lib.compute.networksr?   )googlecloudsdk.command_lib.compute.routes.googlecloudsdk.command_lib.compute.vpn_tunnelsrD   googlecloudsdk.corer   r   r   r6   ReleaseTracksr_   GAUniverseCompatibleCreateCommandr8   r{   ALPHABETAr   r   r   r   <module>r      s    # &  '  7 + / ( . 9 O E J R P N ; M * 
K8OBd D%%(()NT N  *Nb  D%%++T->->-C-CD$f $  E$r   