
    J                     @   d Z ddlmZ ddlmZ ddlmZ ddl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 Z e
j*                  e
j,                  j.                        e
j0                   G d de
j2                                      Z e
j*                  e
j,                  j6                        e
j0                   G d de                    Z e
j*                  e
j,                  j:                        e
j0                   G d de                    Zy)zCommand for creating networks.    )absolute_import)division)unicode_literalsN)base_classes)networks_utils)base)flags)network_utils)log)resource_projectorc                     dj                  |       }t        j                  j                  t	        j
                  |             y)zText for firewall warning.a  
      Instances on this network will not be reachable until firewall rules
      are created. As an example, you can allow all internal traffic between
      instances as well as SSH, RDP, and ICMP by running:

      $ gcloud compute firewall-rules create <FIREWALL_NAME> --network {0} --allow tcp,udp,icmp --source-ranges <IP_RANGE>
      $ gcloud compute firewall-rules create <FIREWALL_NAME> --network {0} --allow tcp:22,tcp:3389,icmp
      N)formatr   statusPrinttextwrapdedent)network_namemessages     &lib/surface/compute/networks/create.py
EpilogTextr   !   s5    
 &
 
 **8??7+,    c                   :    e Zd ZdZdZdZdZed        Zd Z	ddZ
y)Create  Create a Compute Engine network.

  *{command}* is used to create virtual networks. A network
  performs the same function that a router does in a home
  network: it describes the network range and gateway IP
  address, handles communication between instances, and serves
  as a gateway between instances and callers outside the
  network.

  ## EXAMPLES

  To create a regional auto subnet mode network with the name 'network-name',
  run:

    $ {command} network-name

  To create a global custom subnet mode network with the name 'network-name',
  run:

    $ {command} network-name \
      --bgp-routing-mode=global \
      --subnet-mode=custom

  NTc                    |j                   j                  t        j                         t        j                         | _        | j
                  j                  |d       t        j                  |       t        j                  |       t        j                  |       t        j                  |       t        j                  |       t        j                  |       t        j                  |       t        j                  |       t        j                   |       t#        j$                  d      | _        | j&                  j                  |       |j                   j)                  t        j*                         y Ncreate)operation_typez-The network profile to apply to this network.)display_info	AddFormatr	   LIST_FORMAT_WITH_ULA_IPV6NetworkArgumentNETWORK_ARGAddArgumentr
   AddCreateBaseArgsAddCreateSubnetModeArgAddCreateBgpRoutingModeArg	AddMtuArgAddInternalIpv6RangeArgAddEnableUlaInternalIpv6Arg+AddNetworkFirewallPolicyEnforcementOrderArgAddBgpBestPathSelectionArgGroup
AddTagsArgnetwork_profile_flags&NetworkProfileArgumentForOtherResourceNETWORK_PROFILE_ARGAddCacheUpdaterNetworksCompleterclsparsers     r   ArgszCreate.ArgsO   s   
!!%"A"AB++-COOOx@##F+((0,,V4F#))&1--f5==fE11&9V$ 	DD;	
 
 ''/
''(?(?@r   c                    t        j                  | j                               }|j                  }|j                  }t        j                  |       | j                  j                  ||j                        }|j                         | _        | j                  j                  ||j                        }t        j                  ||||| j                        }|j                   j"                  d|j                  j%                  ||j&                        f}|j)                  |g      }	t+        j,                  |	d         }
t        j.                  |
      S )z4Issues the request necessary for adding the network.)messagesnetwork_refnetwork_argsnetwork_profile_refsupport_firewall_orderInsert)networkprojectr   )r   ComputeApiHolderReleaseTrackclientr8   r
   CheckRangeLegacyModeOrRaiser#   ResolveAsResource	resourcesName_network_namer0   r   CreateNetworkResourceFromArgs_support_firewall_orderapitools_clientnetworksComputeNetworksInsertRequestr?   MakeRequestsr   MakeSerializableAddModesForListFormat)selfargsholderrB   r8   r9   r;   network_resourcerequestresponseresource_dicts              r   Runz
Create.Runh   s*   **4+<+<+>?F]]FH--d3""44T6;K;KLK$))+D22DDf &CC/#;; 	''44$k.A.A 	5 	
G ""G9-H&77DM//>>r   c                 .    t        | j                         y N)r   rG   )rP   resources_were_displayeds     r   EpilogzCreate.Epilog   s    t!!"r   )T)__name__
__module____qualname____doc__r#   r0   rI   classmethodr6   rW   r[    r   r   r   r   /   s9    2 + A A0?B#r   r   c                   ,     e Zd ZdZe fd       Z xZS )
CreateBetar   c                 ,    t         t        |   |       y rY   )superrc   r6   )r4   r5   	__class__s     r   r6   zCreateBeta.Args   s    	*c'r   )r\   r]   r^   r_   r`   r6   __classcell__)rf   s   @r   rc   rc      s    2 ( (r   rc   c                   (    e Zd ZdZdZdZed        Zy)CreateAlphaaV  Create a Compute Engine network.

  *{command}* is used to create virtual networks. A network
  performs the same function that a router does in a home
  network: it describes the network range and gateway IP
  address, handles communication between instances, and serves
  as a gateway between instances and callers outside the
  network.
  TNc                    |j                   j                  t        j                         t        j                         | _        | j
                  j                  |d       t        j                  d      | _	        | j                  j                  |       t        j                  |       t        j                  |       t        j                  |       t        j                  |       t        j                  |       t        j                   |       t        j"                  |       t        j$                  |       t        j&                  |       |j                   j)                  t        j*                         y r   )r   r    r	   r!   r"   r#   r$   r.   r/   r0   r
   r%   r&   r'   r(   r)   r*   r+   r,   r-   r1   r2   r3   s     r   r6   zCreateAlpha.Args   s
   
!!%"A"AB++-COOOx@DD;	
 
 ''/##F+((0,,V4F#))&1--f5==fE11&9V$
''(?(?@r   )r\   r]   r^   r_   rI   r0   r`   r6   ra   r   r   ri   ri      s)     !A Ar   ri   )r_   
__future__r   r   r   r   googlecloudsdk.api_lib.computer   r   googlecloudsdk.callioper   3googlecloudsdk.command_lib.compute.network_profilesr	   r.   +googlecloudsdk.command_lib.compute.networksr
   googlecloudsdk.corer   googlecloudsdk.core.resourcer   r   ReleaseTracksrA   GAUniverseCompatibleCreateCommandr   BETArc   ALPHAri   ra   r   r   <module>rx      s   % &  '  7 9 ( ^ = E # ;- D%%(()Y#T Y#  *Y#x D%%**+( (  ,(> D%%++,$A* $A  -$Ar   