
                             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dZ e	j                  e	j                   j"                         G d de	j$                               Zy)z.'vmware external-access-rules create' command.    )absolute_import)division)unicode_literals)ExternalAccessRulesClient)arg_parsers)base)flags)logz
          Create a VMware Engine external access firewall rule. Check the progress of a VMware Engine external access firewall rule creation using `{parent_command} list`.
        a~  
          To create an external access firewall rule called `my-external-access-rule`  associated with the network policy `my-network-policy` in the `us-west2` region, run:

            $ {command} my-external-access-rule --network-policy=my-network-policy --priority=1000 --ip-protocol=TCP --source-ranges=34.148.30.114/32 --destination-ranges=projects/sample-project/locations/us-west2-a/privateClouds/my-private-cloud/externalAddresses/my-external-address --source-ports=22,10000-11000 --destination-ports=22 --action=ALLOW --location=us-west2 --project=sample-project

          Or:

            $ {command} my-external-access-rule --network-policy=my-network-policy --priority=1000 --ip-protocol=TCP --source-ranges=34.148.30.114/32 --destination-ranges=projects/sample-project/locations/us-west2-a/privateClouds/my-private-cloud/externalAddresses/my-external-address --source-ports=22,10000-11000 --destination-ports=22

          In the second example, the project and the location are taken from gcloud properties core/project and compute/region respectively. The `--action` field also isn't specified, so its value defaults to `ALLOW`.
    )DESCRIPTIONEXAMPLESc                   *    e Zd ZdZeZed        Zd Zy)Createz5Create a VMware Engine external access firewall rule.c                    t        j                  | d       t        j                  j	                  |        t        j                  j                  | d       | j                  j                  d       | j                  dd       | j                  ddt        j                  dd	      d
       | j                  ddg dd       | j                  ddt        j                  d      dd       | j                  ddt        j                  d      dd       | j                  dt        j                  d      dd       | j                  dt        j                  d      dd       | j                  d d!d"gd!d#$       y%)&z Register flags for this command.T)
positionalyamlz--descriptionzG        User-provided description of the external access rule.
        )helpz
--priorityd   i   z        Priority of this external access rule. Valid values are numbers between 100 and 4096, with 100 being the highest priority. Firewall rules are processed from highest to lowest priority.
        )requiredtyper   z--ip-protocol)TCPUDPICMPz\        Internet protocol covered by the rule. Valid values are TCP, UDP, and ICMP.
        )r   choicesr   z--source-ranges   )
min_lengthSOURCE_IP_RANGESz        A list of source IP addresses that the rule applies to. Each entry in the list can be a CIDR notation or a single IP address. When the value is set to `0.0.0.0/0`, all IP addresses are allowed.
        )r   r   metavarr   z--destination-rangesDESTINATION_IP_RANGESz        A list of destination IP addresses that the rule applies to. Each entry in the list can be an ExternalAddress resource name or `0.0.0.0/0`. When the value is set to `0.0.0.0/0`, all IP addresses are allowed.
        z--source-portsSOURCE_PORTSz_        List of allowed source ports. Each entry must be either an integer or a range.
        )r   r   r   z--destination-portsDESTINATION_PORTSzd        List of allowed destination ports. Each entry must be either an integer or a range.
        z--actionALLOWDENYz        Whether the firewall rule allows or denies traffic based on a successful rule match. By default, the action is ALLOW.
        )r   defaultr   N)r	   AddExternalAccessRuleToParserr   
ASYNC_FLAGAddToParser
SetDefaultdisplay_info	AddFormatadd_argumentr   
BoundedIntArgList)parsers    Clib/surface/vmware/network_policies/external_access_rules/create.pyArgszCreate.Args4   s    
''4@OO'OOvt,
!!&)
  
 ##C.	   &	     A."     A.'     A.	     A.#	   &!	      c                 `   |j                   j                  j                         }t               }|j                  }|j                  ||j                  |j                  |j                  |j                  |j                  |j                  |j                  |j                  	      }|r#t        j                  |j                   dd       y |j#                  |j%                  |      dj'                  |j)                                     }t        j                  |j)                         d       |S )N)priorityip_protocolsource_rangesdestination_rangessource_portsdestination_portsdescriptionactionz"VMware Engine external access ruleT)kindis_asyncz3waiting for external access rule [{}] to be created)operation_refmessage)r:   )CONCEPTSexternal_access_ruleParser   async_r   r2   r3   r4   r5   r6   r7   r8   r9   r
   CreatedResourcenameWaitForOperationGetOperationRefformatRelativeName)selfargsr?   clientr;   	operationresources          r.   Runz
Create.Runt   s   ====CCE&(F{{H$$((22&&00$${{  
I 	
..3 &&,,Y7ELL --/
 ' H ))+1 Or0   N)	__name__
__module____qualname____doc__DETAILED_HELPdetailed_helpstaticmethodr/   rM    r0   r.   r   r   /   s"    =-= =~ r0   r   N)rQ   
__future__r   r   r   1googlecloudsdk.api_lib.vmware.externalaccessrulesr   googlecloudsdk.callioper   r   2googlecloudsdk.command_lib.vmware.network_policiesr	   googlecloudsdk.corer
   rR   ReleaseTracksReleaseTrackGACreateCommandr   rU   r0   r.   <module>r_      sp    5 &  ' W / ( D #	
	( D%%(()dT d *dr0   