
                            S r SSKJr  SSKJr  SSKJr  SSKrSSKJr  SSK	J
r
  SSKJr  SSKJr  SS	KJr  SS
KJr  SSS.r\R$                  \R&                  " \R(                  R*                  \R(                  R,                  \R(                  R.                  5       " S S\R0                  5      5       5       r\\l        g)zUpdate endpoint group command.    )absolute_import)division)unicode_literalsN)
exceptions)api)base)endpoint_group_flags)labels_utilz
          Update a intercept endpoint groups. Check the progress of endpoint
          group update by using `gcloud network-security intercept-endpoint-groups list`.

          For examples refer to the EXAMPLES section below.
        a  
            To update labels k1 and k2, run:

            $ {command} my-endpoint-group --project=my-project --location=us-central1-a --update-labels=k1=v1,k2=v2

            To remove labels k3 and k4, run:

            $ {command} my-endpoint-group --project=my-project --location=us-central1-a --remove-labels=k3,k4

            To clear all labels from the intercept endpoint group, run:

            $ {command} my-endpoint-group --project=my-project --location=us-central1-a --clear-labels

            To update description to 'new description', run:

            $ {command} my-endpoint-group --project=my-project --location=us-central1-a --description='new description'
        )DESCRIPTIONEXAMPLESc                   B    \ rS rSrSr/ SQr\S 5       rS rS r	S r
Srg	)
Update<   z"Update a Intercept Endpoint Group.)z--clear-labelsz--remove-labelsz--update-labelsc                 R   [         R                  " U R                  5       U5        [         R                  " US5        [         R                  " U5        [
        R                  R                  U5        [
        R                  R                  US5        [        R                  " U5        g )N20mT)r	   AddEndpointGroupResourceReleaseTrack
AddMaxWaitAddDescriptionArgr   
ASYNC_FLAGAddToParser
SetDefaultr
   AddUpdateLabelsFlags)clsparsers     @lib/surface/network_security/intercept_endpoint_groups/update.pyArgsUpdate.ArgsI   ss    11#2B2B2DfM## **62OO'OOvt,$$V,    c           	         [         R                  " U R                  5       5      nUR                  R                  R                  5       n UR                  UR                  5       5      n0 nU R                  X!U5      nU(       a  XeS'   U(       d   [        R                  " U R                  5      eUR                  UR                  5       [!        USS5      US9nUR"                  (       a  UR%                  S5      (       d  SUl        U$ U R)                  UUU[*        R,                  " UR.                  S	95      $ ! [        R                   a    [        R                  " SS5      ef = f)
Nzintercept-endpoint-groupz(Intercept endpoint group does not exist.labelsdescription )namer"   update_fieldsformatdefault)seconds)r   Clientr   CONCEPTSintercept_endpoint_groupParseDescribeEndpointGroupRelativeNameapitools_exceptionsHttpNotFoundErrorr   InvalidArgumentException_process_label_updatesMinimumArgumentException_valid_argumentsUpdateEndpointGroupgetattrasync_IsSpecifiedr&   _wait_for_operationdatetime	timedeltamax_wait)selfargsclientegoriginalr%   r!   	operations           r   Run
Update.RunU   s@   ZZ))+,F		/	/	5	5	7B--boo.?@h M((x@F &H//0E0EFF**__D-4# + I {{ h''##
4==1	 9 00 //
$
4 s   
D9 9,E%c                 "   [         R                  R                  U5      nUR                  5       (       d  gUR                  nUR                  UR                  R                  R                  U5      nUR                  (       a  UR                  nU$ )a   Processes the label update request.

Args:
  client: the client to use to make the API call.
  args: the args from the command line.
  original_eg: the original intercept endpoint group.

Returns:
  the labels we would like to update if there is any update. Otherwise,
  it returns None.
N)
r
   DiffFromUpdateArgsMayHaveUpdatesr!   ApplymessagesInterceptEndpointGroupLabelsValueneeds_update)r=   r?   r>   original_eglabels_diffr!   labels_updates          r   r2   Update._process_label_updates~   sx     ""11$7K%%''F%%..::M !!##fMr   c                 ~    UR                  UR                  U5      SR                  UR                  5       5      SUS9$ )Nz7waiting for intercept endpoint group [{}] to be updatedF)operation_refmessage
has_resultr<   )WaitForOperationGetOperationRefr&   r.   )r=   r?   rB   r@   r<   s        r   r9   Update._wait_for_operation   sH    "",,Y7ELL!  # 	 	r    N)__name__
__module____qualname____firstlineno____doc__r4   classmethodr   rC   r2   r9   __static_attributes__rY   r   r   r   r   <   s3    
 + 	- 	-'R4
r   r   )r^   
__future__r   r   r   r:   apitools.base.pyr   r/   Agooglecloudsdk.api_lib.network_security.intercept_endpoint_groupsr   googlecloudsdk.callioper   5googlecloudsdk.command_lib.network_security.interceptr	   $googlecloudsdk.command_lib.util.argsr
   DETAILED_HELPDefaultUniverseOnlyReleaseTracksr   ALPHABETAGAUpdateCommandr   detailed_helprY   r   r   <module>ro      s    % &  '  > Q ( . V <6 T..33T5F5F5I5IbT b bJ % r   