
    '                        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 ddlmZ dd
lZ e	j$                  e	j&                  j(                        e	j*                   G d de	j,                                      Z e	j$                  e	j&                  j0                         G d de             Z e	j$                  e	j&                  j4                         G d de             Zy
)z)Command for creating target VPN Gateways.    )absolute_import)division)unicode_literals)base_classes)arg_parsers)base)flags)resource_manager_tags_utilsNc                   >    e Zd ZdZdZdZdZed        Zd Z	d Z
d Zy)Create|  Create a Cloud VPN Classic Target VPN Gateway.

    *{command}* is used to create a Cloud VPN Classic Target VPN Gateway. A
  Target VPN Gateway can reference one or more VPN tunnels that connect it to
  the remote tunnel endpoint. A Target VPN Gateway may also be referenced by
  one or more forwarding rules that define which packets the
  gateway is responsible for routing.
  NFc                 
   |j                   j                  t        j                         t	        j
                  d      | _        | j                  j                  |       t        j                         | _	        | j                  j                  |d       |j                  dd       | j                  r'|j                  dt        j                         dd	
       |j                   j                  t        j                         y)z&Adds arguments to the supplied parser.z]        A reference to a network in this project to
        contain the VPN Gateway.
        create)operation_typez--descriptionz<An optional, textual description for the target VPN Gateway.)helpz--resource-manager-tagsz	KEY=VALUEzh            A comma-separated list of Resource Manager tags to apply to the target VPN gateway.
        )typemetavarr   N)display_info	AddFormatr	   DEFAULT_LIST_FORMATnetwork_flagsNetworkArgumentForOtherResourceNETWORK_ARGAddArgumentTargetVpnGatewayArgumentTARGET_VPN_GATEWAY_ARGadd_argument_support_tagging_at_creationr   ArgDictAddCacheUpdaterTargetVpnGatewaysCompleter)clsparsers     1lib/surface/compute/target_vpn_gateways/create.pyArgszCreate.Args/   s     !!%";";<#CC	CO
 OO'!&!?!?!AC**6(*K
K  M ''
#""$	   ''(H(HI    c           
         t        j                  | j                               }|j                  }|j                  }| j
                  j                  ||j                  t        j                  |            }| j                  j                  ||j                        }d}| j                  r(|j                  | j                  ||j                        }| j                  rx|v|j                  j                  |j                  |j                   |j                  j#                  |j$                  |j'                         |j)                         |            }nt|j                  j                  |j                  |j                   |j                  j#                  |j$                  |j'                         |j)                                     }|j+                  |j,                  j.                  d|fg      S )zIssues API requests to construct Target VPN Gateways.

    Args:
      args: argparse.Namespace, The arguments received by this command.

    Returns:
      [protorpc.messages.Message], A list of responses returned
      by the compute API.
    )scope_listerN)descriptionnamenetworkparams)projectregiontargetVpnGateway)r)   r*   r+   Insert)r   ComputeApiHolderReleaseTrackclientmessagesr   ResolveAsResource	resourcescompute_flagsGetDefaultScopeListerr   r   resource_manager_tags_CreateTargetVpnGatewayParams%ComputeTargetVpnGatewaysInsertRequestr-   r.   TargetVpnGatewayr)   NameSelfLinkMakeRequestsapitools_clienttargetVpnGateways)	selfargsholderr3   r4   target_vpn_gateway_refnetwork_refr,   requests	            r$   _RunzCreate._RunK   s    **4+<+<+>?F]]FH "88JJ"88@ K B ""44T6;K;KLKF((		#	#	/33d00
 ((V-?EE(00'..!??;;**)..0!**,	 <  F 	g EE(00'..!??;;**)..0!**, <  F g 

 
 
2
2Hg	FG r&   c                    t        j                  |      }|j                  }t        t	        j
                  |            D cg c]"  \  }}|j                  j                  ||      $ }}} ||j                  |            S c c}}w )N)keyvalue)additionalProperties)resourceManagerTags)r
   GetResourceManagerTagsTargetVpnGatewayParamssortedsix	iteritemsResourceManagerTagsValueAdditionalProperty)rB   r4   r9   resource_manager_tags_mapr,   rJ   rK   additional_propertiess           r$   r:   z$Create._CreateTargetVpnGatewayParams   s    #::!	
 
 ,,F !/H!IJJJC 	''::s%:PJ   ";;!6 < 
 	s   'Bc                 $    | j                  |      S )z5Issues API requests to construct Target VPN gateways.rH   rB   rC   s     r$   Runz
Create.Run       99T?r&   )__name__
__module____qualname____doc__r   r   r   classmethodr%   rH   r:   rZ    r&   r$   r   r      s>     +!&J J63j"r&   r   c                   6     e Zd ZdZdZe fd       Zd Z xZS )
CreateBetar   Fc                 ,    t         t        |   |       yz"Set up arguments for this command.N)superrc   r%   r"   r#   	__class__s     r$   r%   zCreateBeta.Args   s     
*c'r&   c                 $    | j                  |      S zSee base.CreateCommand.rX   rY   s     r$   rZ   zCreateBeta.Run   r[   r&   	r\   r]   r^   r_   r   r`   r%   rZ   __classcell__rh   s   @r$   rc   rc      s'     "'( (r&   rc   c                   6     e Zd ZdZdZe fd       Zd Z xZS )CreateAlphar   Tc                 ,    t         t        |   |       yre   )rf   ro   r%   rg   s     r$   r%   zCreateAlpha.Args   s     
+s (r&   c                 $    | j                  |      S rj   rX   rY   s     r$   rZ   zCreateAlpha.Run   r[   r&   rk   rm   s   @r$   ro   ro      s'     "&) )r&   ro   )r_   
__future__r   r   r   googlecloudsdk.api_lib.computer   googlecloudsdk.callioper   r   "googlecloudsdk.command_lib.computer	   r7   r
   +googlecloudsdk.command_lib.compute.networksr   6googlecloudsdk.command_lib.compute.target_vpn_gatewaysrQ   ReleaseTracksr2   GAUniverseCompatibleCreateCommandr   BETArc   ALPHAro   ra   r&   r$   <module>r~      s    0 &  ' 7 / ( E J N H 
 D%%(()rT r  *rj D%%**+  ,, D%%++,&  -r&   