
    R                        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 r\R&                  \R(                  " \R*                  R,                  \R*                  R.                  \R*                  R0                  5       " S S\R2                  5      5       5       rg)z&Command for creating network peerings.    )absolute_import)division)unicode_literals)base_classes)batch_helper)utils)actions)base)flags)log)
properties)	resourcesc                    U(       a  [         R                  " UU R                  R                  U R                  S9u  p4U(       d{  U Hs  n[
        R                  R                  SR                  UR                  5      5        [
        R                  R                  SR                  UR                  5      5        Mu     U$ [        R                  " U5         U$ U R                  U5      nU$ )zHHelper for making asynchronous or synchronous peering creation requests.)requestshttp	batch_urlz#Creating network peering for [{0}]
zMonitor its progress at [{0}]
)r   MakeRequestsapitools_clientr   r   r   statuswriteformat
targetLinkselfLinkr   RaiseToolException)clientr   is_async	responseserrors	operations         /lib/surface/compute/networks/peerings/create.py_MakeRequestsr!       s    $11##((""$I  )

?FF  " 	#

:AA  	! ! 
 v& 
 ##H-I	    c                   H    \ rS rSrSrSr\S 5       r\S 5       rS r	S r
Srg	)
Create7   a  Create a Compute Engine network peering.

*{command}* is used to create peerings between virtual networks. Each side of
a peering association is set up independently. Peering will be active only
when the configuration from both sides matches.

## EXAMPLES

To create a network peering with the name 'peering-name' between the network
'local-network' and the network 'peer-network' which exports and imports
custom routes and subnet routes with public IPs, run:

  $ {command} peering-name \
    --network=local-network \
    --peer-network=peer-network \
    --export-custom-routes \
    --import-custom-routes \
    --export-subnet-routes-with-public-ip \
    --import-subnet-routes-with-public-ip
Fc                    UR                  SSS9  UR                  SSSS9  UR                  SSS	S9  UR                  S
SSS9  [        R                  R                  U5        [        R
                  " U5        [        R                  " U5        [        R                  " U5        [        R                  " U5        [        R                  " U5        [        R                  " U5        g )NnamezThe name of the peering.)helpz	--networkTzRThe name of the network in the current project to be peered with the peer network.)requiredr(   z--peer-networkz>The name of the network to be peered with the current network.z--peer-projectFz]The name of the project for the peer network.  If not specified, defaults to current project.)add_argumentr
   
ASYNC_FLAGAddToParserr   AddImportCustomRoutesFlagAddExportCustomRoutesFlag%AddImportSubnetRoutesWithPublicIpFlag%AddExportSubnetRoutesWithPublicIpFlagAddStackTypeAddUpdateStrategy)clsparsers     r    
ArgsCommonCreate.ArgsCommonS   s     %?@
!  " M  O
 '  ( 	OO'	##F+	##F+	//7	//7	v	F#r"   c                 x    U R                  U5        [        R                  " SSSS9nUR                  SUSSSS9  g )	Nzauto-create-routeszPFlag --auto-create-routes is deprecated and will be removed in a future release.
store_true)warnactionz--auto-create-routesFzIf set, will automatically create routes for the network peering. Flag auto-create-routes is deprecated. Peer network subnet routes are always created in a network when peered.)r:   defaultr)   r(   )r5   r	   DeprecationActionr*   )r3   r4   r:   s      r    ArgsCreate.Argsu   sQ    NN6&&. F <  
r"   c                    [         R                  R                  UR                  SUR                  =(       d.    [
        R                  R                  R                  R                  0SS9nUR                  R                  UR                  UR                  5       SS9nUR                  Ul        UR                   Ul        UR$                  Ul        UR(                  Ul        [-        US5      (       a4  UR                  R                  R/                  UR0                  5      Ul        [-        US5      (       a4  UR                  R                  R5                  UR6                  5      Ul        U$ )Nprojectzcompute.networks)params
collectionT)r'   networkexchangeSubnetRoutes
stack_typeupdate_strategy)r   REGISTRYParsepeer_networkpeer_projectr   VALUEScorer@   	GetOrFailmessagesNetworkPeeringr'   RelativeNameexport_custom_routesexportCustomRoutesimport_custom_routesimportCustomRoutes#export_subnet_routes_with_public_ipexportSubnetRoutesWithPublicIp#import_subnet_routes_with_public_ipimportSubnetRoutesWithPublicIpgetattrStackTypeValueValuesEnumrE   	stackTypeUpdateStrategyValueValuesEnumrF   updateStrategy)selfr   argspeer_network_refnetwork_peerings        r    _CreateNetworkPeeringForRequest&Create._CreateNetworkPeeringForRequest   sD    ))//!!MZ%6%6%;%;%C%C%M%M

 & 0  oo44YY --/! 5 O
 *.)B)BO&)-)B)BO&00 2 	00 2 t\""
//
(
(
A
Aoo  t&''
//
(
(
F
F"" $ r"   c           	         [         R                  " U R                  5       5      nUR                  nUR                  R                  UR                  UR                  R                  U R                  X15      S9[        R                  R                  R                  R                  5       S9nUR                  R                  SU4/n[!        X5UR"                  5      $ )z4Issues the request necessary for adding the peering.)networkPeering)rC   networksAddPeeringRequestr@   
AddPeering)r   ComputeApiHolderReleaseTrackr   rN    ComputeNetworksAddPeeringRequestrC   NetworksAddPeeringRequestrb   r   rK   rL   r@   rM   r   networksr!   async_)r^   r_   holderr   requestr   s         r    Run
Create.Run   s    **4+<+<+>?F]]Foo>>"(//"K"K??M #L #O!!&&..88:	 ? <G ''00,HIH4;;77r"    N)__name__
__module____qualname____firstlineno____doc___support_stack_typeclassmethodr5   r=   rb   rp   __static_attributes__rr   r"   r    r$   r$   7   sA    
* $ $B  ,&P8r"   r$   N)rw   
__future__r   r   r   googlecloudsdk.api_lib.computer   r   r   googlecloudsdk.callioper	   r
   4googlecloudsdk.command_lib.compute.networks.peeringsr   googlecloudsdk.corer   r   r   r!   DefaultUniverseOnlyReleaseTracksri   GAALPHABETACommandr$   rr   r"   r    <module>r      s    - &  ' 7 7 0 + ( F # * ). $++1143D3D3I3IE8T\\ E8 E8r"   