
    W                     v   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S.r\	R                   \	R"                  " \	R$                  R&                  \	R$                  R(                  \	R$                  R*                  5       " S S\	R,                  5      5       5       r\\l        g)z Update deployment group command.    )absolute_import)division)unicode_literalsN)api)base)
exceptions)deployment_group_flags)labels_utilz
          Update a mirroring deployment group. Check the progress of deployment group update
          by using `gcloud network-security mirroring-deployment-groups list`.

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

            $ {command} my-deployment-group --project=my-project --location=global --update-labels=k1=v1,k2=v2

            To remove labels k3 and k4, run:

            $ {command} my-deployment-group --project=my-project --location=global --remove-labels=k3,k4

            To clear all labels from the mirroring deployment group, run:

            $ {command} my-deployment-group --project=my-project --location=global --clear-labels

            To update description to 'new description', run:

            $ {command} my-deployment-group --project=my-project --location=global --description="new description"
        )DESCRIPTIONEXAMPLESc                   H    \ rS rSrSr/ SQr\S 5       rS rS r	S r
S rS	rg
)Update9   z$Update a Mirroring Deployment 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	   AddDeploymentGroupResourceReleaseTrack
AddMaxWaitAddDescriptionArgr   
ASYNC_FLAGAddToParser
SetDefaultr
   AddUpdateLabelsFlags)clsparsers     Blib/surface/network_security/mirroring_deployment_groups/update.pyArgsUpdate.ArgsE   sx    55F %% ,,V4OO'OOvt,$$V,    c           	         [         R                  " U R                  5       5      nUR                  R                  R                  5       nUR                  UR                  5       5      nU R                  U5        0 nU R                  X!U5      nU(       a  XeS'   U(       d   [        R                  " U R                  5      eUR                  UR                  5       U[        USS 5      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      $ )Nlabelsdescription)nameupdate_fieldsr"   formatdefault)seconds)r   Clientr   CONCEPTSmirroring_deployment_groupParseDescribeDeploymentGroupRelativeName#_validate_original_deployment_group_process_label_updatesr   MinimumArgumentException_valid_argumentsUpdateDeploymentGroupgetattrasync_IsSpecifiedr%   _wait_for_operationdatetime	timedeltamax_wait)selfargsclientdeployment_grouporiginalr$   r!   	operations           r   Run
Update.RunS   s   ZZ))+,F}}??EEG--.>.K.K.MNH,,X6M((x@F &H//0E0EFF,,**,#D-6 - I {{ h''##4==1	 r   c                 8    Uc  [         R                  " SS5      eg )Nzmirroring-deployment-groupz*Mirroring deployment group does not exist.)r   InvalidArgumentException)r:   r>   s     r   r.   *Update._validate_original_deployment_groupw   s&    //
&
6  r   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_dg: the original mirroring deployment 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MirroringDeploymentGroupLabelsValueneeds_update)r:   r<   r;   original_dglabels_diffr!   labels_updates          r   r/   Update._process_label_updates~   sx     ""11$7K%%''F%%00<<M !!##fMr   c                 ~    UR                  UR                  U5      SR                  UR                  5       5      SUS9$ )Nz9waiting for mirroring deployment group [{}] to be updatedF)operation_refmessage
has_resultr9   )WaitForOperationGetOperationRefr%   r-   )r:   r<   r?   r=   r9   s        r   r6   Update._wait_for_operation   sJ    "",,Y7GNN --/  # 	 	r    N)__name__
__module____qualname____firstlineno____doc__r1   classmethodr   r@   r.   r/   r6   __static_attributes__rY   r   r   r   r   9   s8     - - -"H4
r   r   )r^   
__future__r   r   r   r7   Cgooglecloudsdk.api_lib.network_security.mirroring_deployment_groupsr   googlecloudsdk.callioper   r   +googlecloudsdk.command_lib.network_securityr	   $googlecloudsdk.command_lib.util.argsr
   DETAILED_HELPDefaultUniverseOnlyReleaseTracksr   ALPHABETAGAUpdateCommandr   detailed_helprY   r   r   <module>rn      s    ' &  '  S ( . N <6 D%%++T->->-C-C%%((*fT f* fR % r   