
    5                         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  G d de
j&                        Zy)z5Commands for updating network edge security services.    )absolute_import)division)unicode_literals)base_classes)client)base)
exceptions)flags)	resourcesc                   4    e Zd ZdZdZdZed        Zd Zd Z	y)UpdateaB  Update a network edge security service.

  *{command}* is used to update network edge security services.

  ## EXAMPLES

  To attach a new security policy 'my-policy' to a network edge security service
  with the name 'my-service' in region 'us-central1', run:

    $ {command} my-service \
      --security-policy=my-policy \
      --region=us-central1

  To remove the security policy attached to a network edge security service
  with the name 'my-service' in region 'us-central1', run:

    $ {command} my-service \
      --security-policy="" \
      --region=us-central1
  Nc                    t        j                         | _        | j                  j                  |d       |j	                  dd       t        j                  d      | _        | j                  j                  |       y)	z"Set up arguments for this command.update)operation_type--descriptionzGAn optional, textual description for the network edge security service.)helpznetwork edge security service)resourceN)r
   "NetworkEdgeSecurityServiceArgument!NETWORK_EDGE_SECURITY_SERVICE_ARGAddArgumentadd_argumentsecurity_policy_flags/SecurityPolicyRegionalArgumentForTargetResourceSECURITY_POLICY_ARG)clsparsers     <lib/surface/compute/network_edge_security_services/update.pyArgszUpdate.Args8   s     	002 )))55x 6 )
/  1 	MM4	6  ''/    c                 ~    |j                  d      s,|j                  d      sddg}t        j                  |d      yy)zValidates that at least one field to update is specified.

    Args:
      args: The arguments given to the update command.
    descriptionsecurity_policyr   z--security_policyz.Please specify at least one property to updateN)IsSpecifiedr	   MinimumArgumentException)selfargsparameter_namess      r   _ValidateArgszUpdate._ValidateArgsI   sQ     ]+./(*=>o//
KM M 0 ,r   c                    | j                  |       t        j                  | j                               }| j                  j                  ||j                        }t        j                  ||j                        }|j                         d   }|j                  }|j                  }g }|j                  d      r|j                  }|j                  d       t        |dd       F|j                  d       	 | j                  j                  ||j                        j!                         }|j                  j&                  j                  |||j(                        }	|j+                  |	|      S # t"        j$                  $ r d }Y \w xY w)N)refcompute_clientr   r!   r"   securityPolicy)r!   r,   fingerprint)network_edge_security_serviceupdate_mask)r(   r   ComputeApiHolderReleaseTrackr   ResolveAsResourcer   r   NetworkEdgeSecurityServiceDescriber!   r,   r#   appendgetattrr   SelfLinkresources_exceptionsInvalidResourceExceptionmessagesr-   Patch)
r%   r&   holderr*   r.   &existing_network_edge_security_servicer!   r"   r/   %updated_network_edge_security_services
             r   Runz
Update.RunU   s}   t**4+<+<+>?F

0
0
B
Bf C$*$E$E%/! 	&..03 +8DDK<KKOK&$$k't&-9)*22DD&""$$,HJ 	 	99#*>JJ 	: 	L * )..&K / ! ! ":: s   64E/ /FF)
__name__
__module____qualname____doc__r   r   classmethodr   r(   r?    r   r   r   r      s2    * '+#0 0 
M"!r   r   N)rC   
__future__r   r   r   googlecloudsdk.api_lib.computer   =googlecloudsdk.api_lib.compute.network_edge_security_servicesr   googlecloudsdk.callioper   r	   Agooglecloudsdk.command_lib.compute.network_edge_security_servicesr
   4googlecloudsdk.command_lib.compute.security_policiesr   googlecloudsdk.corer   r8   UpdateCommandr   rE   r   r   <module>rN      s>    < &  ' 7 P ( . S$ AX!T X!r   