
    I                     `   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"                  ej$                  j&                  ej$                  j(                  ej$                  j*                         G d dej,                                      Zy)z8Update command to update a new Custom Intercept profile.    )absolute_import)division)unicode_literals)intercept_api)base)sp_flags)labels_util)logz

          Update a Custom Intercept Security Profile.

          The supported fields for update are `description` and `labels`.

        a(  
          To update the description of a Custom Intercept Security Profile named `intercept-profile`, run:

              $ {command} intercept-profile --description="A new description"               --organization=1234567890 --location=global

          To change the labels of a Custom Intercept Security Profile named `intercept-profile`, run:

              $ {command} intercept-profile
              --update-labels=key1=value1,key2=value2                --delete-labels=key3,key4               --organization=1234567890 --location=glob
        )DESCRIPTIONEXAMPLESc                   0    e Zd ZdZeZed        Zd Zd Z	y)Updatez#Updates a Custom Intercept Profile.c                    t        j                  || j                                t        j                  |       t        j
                  j                  |       t        j
                  j                  |d       t        j                  |       y )NF)
r   AddSecurityProfileResourceReleaseTrackAddProfileDescriptionr   
ASYNC_FLAGAddToParser
SetDefaultr	   AddUpdateLabelsFlags)clsparsers     Ilib/surface/network_security/security_profiles/custom_intercept/update.pyArgszUpdate.Args<   s]    ''0@0@0BC""6*OO'OOvu-$$V,    c                 |    t        j                   j                               |j                  j                  j                         |j                  }|j                  }t        j                  |j                  j                  j                   fd      }j                  j                         ||j                               }|r.|j                   }t"        j$                  j'                  d|       |S j)                  j+                  |      dj-                  j                               d      S )Nc                  (    j                         S N)	getLabels)clientsecurity_profileselfs   r   <lambda>zUpdate.Run.<locals>.<lambda>M   s    $..9I"Jr   )orig_labels_thunk)namedescriptionlabelsz9Check for operation completion status using operation ID:z/Waiting for security-profile [{}] to be updatedT)operation_refmessage
has_result)r   Clientr   CONCEPTSr!   Parser&   async_r	   ProcessUpdateArgsLazymessagesSecurityProfileLabelsValueUpdateSecurityProfileRelativeName	GetOrNoner%   r
   statusPrintWaitForOperationGetOperationsRefformat)	r"   argsr&   is_asynclabels_updateresponseoperation_idr    r!   s	   `      @@r   Runz
Update.RunD   s   !!$"3"3"56F}}55;;=""K{{H55''33JM ++**,&&( , H ]]l	jj
E
 o ""--h7AHH))+
  #  r   c                 T    |j                  |j                               j                  S r   )GetSecurityProfiler4   r'   )r"   r    r!   s      r   r   zUpdate.getLabelsh   s#    $$%5%B%B%DELLLr   N)
__name__
__module____qualname____doc__DETAILED_HELPdetailed_helpclassmethodr   r@   r    r   r   r   r   3   s*    
 ,-- -"HMr   r   N)rF   
__future__r   r   r   9googlecloudsdk.api_lib.network_security.security_profilesr   googlecloudsdk.callioper   +googlecloudsdk.command_lib.network_securityr   $googlecloudsdk.command_lib.util.argsr	   googlecloudsdk.corer
   rG   DefaultUniverseOnlyReleaseTracksr   ALPHABETAGAUpdateCommandr   rJ   r   r   <module>rW      s    ? &  ' S ( @ < #0 T..33T5F5F5I5I2MT 2M 2Mr   