
                             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 update' command.    )absolute_import)division)unicode_literals)ExternalAccessRulesClient)arg_parsers)base)flags)logzI
          Update a VMware Engine external access firewall rule.
        a  
          To update an external access firewall rule named `my-external-access-rule` so that it denies the traffic for that rule, run:

            $ {command} my-external-access-rule --network-policy=my-network-policy --action=DENY --location=us-west2 --project=my-project

          Or:

            $ {command} my-external-access-rule --network-policy=my-network-policy --action=DENY

          In the second example, the project and the location are taken from gcloud properties core/project and compute/regions respectively.
    )DESCRIPTIONEXAMPLESc                   *    e Zd ZdZeZed        Zd Zy)Updatez&Update a VMware Engine network policy.c                    t        j                  | d       t        j                  j	                  |        t        j                  j                  | d       | j                  j                  d       | j                  dd       | j                  dt        j                  dd	      d
       | j                  dg dd       | j                  dt        j                  d      dd       | j                  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"       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.
        )typer   z--ip-protocol)TCPUDPICMPz\        Internet protocol covered by the rule. Valid values are TCP, UDP, and ICMP.
        )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   metavarr   z--destination-rangesDESTINATION_IP_RANGESz        A list of destination IP addresses that the rule applies to. Each entry in the list 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.
        z--destination-portsDESTINATION_PORTSzd        List of allowed destination ports. Each entry must be either an integer or a range.
        z--actionALLOWDENYze        Whether the firewall rule allows or denies traffic based on a successful rule match.
        N)r	   AddExternalAccessRuleToParserr   
ASYNC_FLAGAddToParser
SetDefaultdisplay_info	AddFormatadd_argumentr   
BoundedIntArgList)parsers    Clib/surface/vmware/network_policies/external_access_rules/update.pyArgszUpdate.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)                               d      }t        j                  |j)                         d       |S )Nz"VMware Engine external access ruleT)kindis_asyncz3waiting for external access rule [{}] to be updated)operation_refmessage
has_result)r0   )CONCEPTSexternal_access_ruleParser   async_r   priorityip_protocolsource_rangesdestination_rangessource_portsdestination_portsdescriptionactionr
   UpdatedResourcenameWaitForOperationGetOperationRefformatRelativeName)selfargsr6   clientr1   	operationresources          r,   Runz
Update.Runo   s   ====CCE&(F{{H2DMM"..0B0B"55t7H7H"44d6F6F"kk	+I
 	
..3 &&,,Y7ELL --/1	 ' H
 ))+1 Or.   N)	__name__
__module____qualname____doc__DETAILED_HELPdetailed_helpstaticmethodr-   rL    r.   r,   r   r   /   s"    .-8 8tr.   r   N)rP   
__future__r   r   r   1googlecloudsdk.api_lib.vmware.externalaccessrulesr   googlecloudsdk.callioper   r   2googlecloudsdk.command_lib.vmware.network_policiesr	   googlecloudsdk.corer
   rQ   ReleaseTracksReleaseTrackGAUpdateCommandr   rT   r.   r,   <module>r^      sp    5 &  ' W / ( D #	
	( D%%(()XT X *Xr.   