
                         0   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  ej$                         Z ej(                  d      Z ej,                  ej.                  j0                        ej2                   G d dej4                                      Z ej,                  ej.                  j8                         G d de             Z ej,                  ej.                  j<                         G d de             Zy)z$Command to create a new VPN gateway.    )absolute_import)division)unicode_literals)base_classes)vpn_gateways_utils)arg_parsers)base)resource_manager_tags_utils)flagszC  A reference to a network to which the VPN gateway is attached.
  c                   D    e Zd ZdZddiZdZed        Zd Zd Z	d Z
d	 Zy
)Create  Create a new Compute Engine Highly Available VPN gateway.

  *{command}* creates a new Highly Available VPN gateway.

  Highly Available VPN Gateway provides a means to create a VPN solution with a
  higher availability SLA compared to Classic Target VPN Gateway.
  Highly Available VPN gateways are simply referred to as VPN gateways in the
  API documentation and gcloud commands.
  A VPN Gateway can reference one or more VPN tunnels that connect it to
  external VPN gateways or Cloud VPN Gateways.
  EXAMPLESz          To create a VPN gateway, run:

              $ {command} my-vpn-gateway --region=us-central1 --network=default
          Fc                 ~   |j                   j                  t        j                         t        j                  |       t        j                  |d       | j                  r'|j                  dt        j                         dd       t        j                         j                  |       t        j                         j                  |       t        j                         j                  |       t        j                         j                  |       |j                   j!                  t        j"                         y)"Set up arguments for this command.create)operation_typez--resource-manager-tagsz	KEY=VALUEza            A comma-separated list of Resource Manager tags to apply to the VPN gateway.
        )typemetavarhelpN)display_info	AddFormatr   DEFAULT_LIST_FORMAT_NETWORK_ARGAddArgument_VPN_GATEWAY_ARG_support_tagging_at_creationadd_argumentr   ArgDictGetDescriptionFlagAddToParserGetInterconnectAttachmentsFlagGetStackTypeGetGatewayIpVersionAddCacheUpdaterVpnGatewaysCompleter)clsparsers     *lib/surface/compute/vpn_gateways/create.pyArgszCreate.Args:   s     !!%";";<V$   A
''
#""$	   
**62	((*66v>	$$V,	++F3
''(B(BC    c           
         t        j                  | j                               }t        j                  |      }|j
                  j                  }t        j                  ||j                        }t        j                  ||j                        }d}d}|j                  2| j                  ||j                  |j                  |j                        }| j                  r(|j                   | j#                  ||j                         }|j%                  |j'                         |j(                  |j+                         ||j,                  |j.                  | j                  |      }	|j1                  ||	      }
|j3                  ||
d      S )z/Issues the request to create a new VPN gateway.N)namedescriptionnetwork,vpn_interfaces_with_interconnect_attachments
stack_typegateway_ip_versionsupport_tagging_at_creationparamszCreating VPN Gateway)r   ComputeApiHolderReleaseTrackr   VpnGatewayHelperclientmessagesr   ResolveAsResource	resourcesr   interconnect_attachments_mapInterconnectAttachmentsregionprojectr   resource_manager_tags_CreateVpnGatewayParamsGetVpnGatewayForInsertNamer.   SelfLinkr1   r2   r   WaitForOperation)selfargsholderhelperr9   vpn_gateway_refnetwork_refr4   r0   vpn_gateway_to_insertoperation_refs              r)   _RunzCreate._RunO   sj   **4+<+<+>?F008F}}%%H&88v?O?OPO00v7G7GHKF370$$0

*
*$$%%	 3 ((		#	#	/--d00
 #99!!#$$$$&5a??22$($E$E : 	 MM/3HIM""(> r+   c                 2   |j                   }t        |      dk(  r+dt        j                  ||d   ||      j	                         iS t        j                  ||d   ||      j	                         t        j                  ||d   ||      j	                         dS )aR  Returns dict {interfaceId : interconnectAttachmentUrl} based on initial order of names in input interconnectAttachmentName and region and project of VPN Gateway.

    Args:
      args: Namespace, argparse.Namespace.
      resources: Generates resource references.
      region: VPN Gateway region.
      project: VPN Gateway project.
       r   )r   rP   )r<   lenr   GetInterconnectAttachmentRefrD   )rF   rG   r;   r>   r?   attachment_refss         r)   r=   z"Create._mapInterconnectAttachmentsv   s     33O
?q 
U//+VWHJ  //+VWHJ//+VWHJ r+   c                    t        j                  |      }|j                  }t        |j	                               D cg c]"  \  }}|j
                  j                  ||      $ }}} ||j                  |            S c c}}w )N)keyvalue)additionalProperties)resourceManagerTags)r
   GetResourceManagerTagsVpnGatewayParamssorteditemsResourceManagerTagsValueAdditionalProperty)rF   r9   r@   resource_manager_tags_mapr4   rU   rV   additional_propertiess           r)   rA   zCreate._CreateVpnGatewayParams   s    #::!	
 
 &&F !!:!@!@!BCCJC 	''::s%:PC   ";;!6 < 
 	s   'Bc                 $    | j                  |      S zSee base.CreateCommand.rN   rF   rG   s     r)   Runz
Create.Run       99T?r+   N)__name__
__module____qualname____doc__detailed_helpr   classmethodr*   rN   r=   rA   re    r+   r)   r   r   $   sI    
    -
 "'D D(%N4"r+   r   c                   B     e Zd ZdZdZdZdZdZe fd       Z	d Z
 xZS )
CreateBetar   NTFc                 ,    t         t        |   |       yr   N)superro   r*   r'   r(   	__class__s     r)   r*   zCreateBeta.Args   s     
*c'r+   c                 $    | j                  |      S rb   rc   rd   s     r)   re   zCreateBeta.Run   rf   r+   )rg   rh   ri   rj   
ROUTER_ARGINSTANCE_ARG_support_outer_vpn_ipv6r   rl   r*   re   __classcell__rt   s   @r)   ro   ro      s7    
 *, !&( (r+   ro   c                   >     e Zd ZdZdZdZdZe fd       Zd Z	 xZ
S )CreateAlphar   NTc                 ,    t         t        |   |       yrq   )rr   r|   r*   rs   s     r)   r*   zCreateAlpha.Args   s     
+s (r+   c                 $    | j                  |      S rb   rc   rd   s     r)   re   zCreateAlpha.Run   rf   r+   )rg   rh   ri   rj   rv   rw   r   rl   r*   re   ry   rz   s   @r)   r|   r|      s1    
 *,!%) )r+   r|   N) rj   
__future__r   r   r   googlecloudsdk.api_lib.computer   +googlecloudsdk.api_lib.compute.vpn_gatewaysr   googlecloudsdk.callioper   r	   "googlecloudsdk.command_lib.computer
   +googlecloudsdk.command_lib.compute.networksr   network_flags/googlecloudsdk.command_lib.compute.vpn_gatewaysGetVpnGatewayArgumentr   NetworkArgumentForOtherResourcer   ReleaseTracksr6   GAUniverseCompatibleCreateCommandr   BETAro   ALPHAr|   rm   r+   r)   <module>r      s   + &  ' 7 J / ( J N A /5..0 <}<< > 
 D%%(()}T }  *}@ D%%**+  ,: D%%++,&  -r+   