
                            S 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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,                  5       " S S\
R.                  5      5       r\
R(                  " \
R*                  R2                  5       " S S\5      5       rS r\\l        g)z-Bare Metal Solution NFS share update command.    )absolute_import)division)unicode_literals)	BmsClient)waiter)base)flags)util)labels_util)log)	resourcesa  
          Update a Bare Metal Solution NFS share.

          This call returns immediately, but the update operation may take
          several minutes to complete. To check if the operation is complete,
          use the `describe` command for the NFS share.
        a  
          To update an NFS share called ``my-share'' in region ``us-central1'' with
          a new label ``key1=value1'', run:

          $ {command} my-share  --region=us-central1 --update-labels=key1=value1

          To clear all labels, run:

          $ {command} my-share --region=us-central1 --clear-labels

          To remove label ``key1'', run:

          $ {command} my-share --region=us-central1 --remove-labels=key1
        )DESCRIPTIONEXAMPLESc                   .    \ rS rSrSr\S 5       rS rSrg)Update9   'Update a Bare Metal Solution NFS share.c                     [         R                  " U SS9  [        R                  " U 5        [        R
                  R                  U 5        [         R                  " U SS9  g)z Register flags for this command.T)
positionalF)parserhiddenN)r	   AddNfsShareArgToParserr   AddUpdateLabelsFlagsr   
ASYNC_FLAGAddToParserAddNfsUpdateAllowedClientArgsr   s    $lib/surface/bms/nfs_shares/update.pyArgsUpdate.Args=   sD     
  D9$$V,OO'	''veD    c                    [         R                  R                  U5      nUR                  R                  R                  5       n[        5       nUR                  U5      nUR                  UR                  R                  R                  UR                  5      R                  5       n[        UUUUS9nUR                  UUUS9nUR                   (       a%  ["        R$                  " UR'                  5       SS9  U$ UR(                  (       aI  ["        R*                  R-                  SR/                  UR'                  5       UR0                  5      5        U$ [2        R4                  R7                  UR0                  SSS9n	[8        R:                  " UR<                  5      n
[8        R>                  " XS	R/                  UR0                  5      5      n["        R$                  " UR'                  5       SS9  U$ )
N)clientargsexisting_nfsnfs_share_resource)r&   labelsallowed_clientsz	NFS share)kindz@Update request issued for: [{}]
Check operation [{}] for status.z/baremetalsolution.projects.locations.operationsv2)
collectionapi_versionz&Waiting for operation [{}] to complete) r   DiffFromUpdateArgsCONCEPTS	nfs_shareParser   GetNfsShareApplymessagesNfsShareLabelsValuer'   	GetOrNone_ApplyNFSAllowedClientsUpdatesUpdateNfsSharedoner   UpdatedResourceNameasync_statusPrintformatnamer   REGISTRYParseRelativeNamer   CloudOperationPollerNoResourcesoperation_serviceWaitFor)selfr$   labels_diffr0   r#   orig_resourcelabels_updateupdated_allowed_clientsop_refop_resourcepollerress               r   Run
Update.RunE   s   ""11$7K''--/I[F&&y1M%%foo&>&>&J&J&3&:&:<<EIK <"$	& ""i*73J # LF {{	)..*=m{{	jj **0&1A17+>? m$$66D 7 K 33F4L4LMF
..077DFC 	({;Jr!    N)	__name__
__module____qualname____firstlineno____doc__staticmethodr   rP   __static_attributes__rR   r!   r   r   r   9   s    /E E$r!   r   c                   (    \ rS rSrSr\S 5       rSrg)UpdateAlphal   r   c                 .    [         R                  U 5        g )N)r   r   r   s    r   r   UpdateAlpha.Argsp   s     KKr!   rR   N)rS   rT   rU   rV   rW   rX   r   rY   rR   r!   r   r[   r[   l   s    / r!   r[   c                 T   UR                  S5      (       a  UR                  (       a  / $ UR                  S5      (       a)  U R                  UUR                  S9nUR                  U-   $ UR                  S5      (       a*  [
        R                  " UUR                  UR                  S9$ g)am  Applies the changes in args to the allowed_clients in existing_nfs.

Returns None if no changes were to be applied.

Args:
  client: BmsClient.
  args: The arguments passed to the command.
  existing_nfs: The existing nfs.
  nfs_share_resource: The ref to the NFS share.

Returns:
  List of allowed clients after applying updates or None if there are
  no changes.
clear_allowed_clientsadd_allowed_client)r&   allowed_clients_dictsremove_allowed_client)r&   r(   remove_key_dictsN)IsKnownAndSpecifiedr`   ParseAllowedClientsDictsra   allowedClientsr
   RemoveAllowedClientsrc   )r#   r$   r%   r&   new_clientss        r   r8   r8   v   s    " 
 #'#=#=I	23311-"55 2 7K &&44	566$$-$33335 5 7r!   N)rW   
__future__r   r   r   %googlecloudsdk.api_lib.bms.bms_clientr   googlecloudsdk.api_lib.utilr   googlecloudsdk.callioper   googlecloudsdk.command_lib.bmsr	   r
   $googlecloudsdk.command_lib.util.argsr   googlecloudsdk.corer   r   DETAILED_HELPReleaseTracksReleaseTrackGAUpdateCommandr   ALPHAr[   r8   detailed_helprR   r!   r   <module>rx      s    4 &  ' ; . ( 0 / < # )		6 D%%(()/T / */d D%%++,&  -5B % r!   