
    )%                     
   S 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KJr  SSKJr  SSKJr  S	\R$                  4S
 jrS\R(                  S\4S jrS\R(                  4S jrS\R(                  4S jr\R2                  " \R4                  R6                  5      \R8                   " S S\R:                  5      5       5       r\R2                  " \R4                  R>                  5       " S S\5      5       r g)z%Updates a Backup and DR Backup Vault.    N)
exceptions)util)BackupVaultsClient)base)flags)logparserc                    [         R                  " U S5        [         R                  " U 5        [         R                  " U S5        [         R                  " U 5        [         R
                  " U 5        [         R                  " U 5        [         R                  " U 5        [         R                  " U 5        [         R                  " U S5        g)mSpecifies additional command flags.

Args:
  parser: argparse.Parser: Parser object for command line inputs.
z,Name of the existing backup vault to update.FupdateN)
r   AddBackupVaultResourceArgAddNoAsyncFlagAddEnforcedRetentionAddDescriptionAddEffectiveTime#AddUnlockBackupMinEnforcedRetentionAddForceUpdateFlagAddForceUpdateAccessRestriction'AddBackupVaultAccessRestrictionEnumFlagr	   s    -lib/surface/backup_dr/backup_vaults/update.py_add_common_argsr      s     !!4 vVU+v ++F36"''///A    argsreturnc                    / nU R                  S5      (       a  UR                  S5        U R                  S5      (       a  UR                  S5        U R                  S5      (       d  U R                  S5      (       a  UR                  S5        U R                  S5      (       a  UR                  S5        S	R                  U5      $ )
zCreates the update mask for the update command.

Args:
  args: argparse.Namespace, An object that contains the values for the
    arguments specified in the .Args() method.

Returns:
  A string containing the update mask.
descriptionbackup_min_enforced_retention&backupMinimumEnforcedRetentionDuration$unlock_backup_min_enforced_retentioneffective_timeeffectiveTimeaccess_restrictionaccessRestriction,)IsSpecifiedappendjoin)r   updated_fieldss     r   _add_common_update_maskr*   2   s     .	m$$-(	566BC	, ())/*	*++-.	.	!!r   c                    [         R                  " U R                  5      nU R                  nU R                  (       a'  U R
                  (       a  [        R                  " S5      eU R                  (       a  [         R                  " 5       nO![         R                  " U R
                  S5      nU R                  (       a  U R                  nOSnUUUU4$ )a  Parses the update backup vault arguments.

Args:
  args: argparse.Namespace, An object that contains the values for the
    arguments specified in the .Args() method.

Returns:
  A tuple containing the backup min enforced retention, description and
  effective time.

Raises:
  calliope_exceptions.ConflictingArgumentsException: If both
    --unlock-backup-min-enforced-retention and --effective-time are specified.
zXOnly one of --unlock-backup-min-enforced-retention or --effective-time can be specified.zeffective-timeN)command_utilConvertIntToStrr   r   r    r!   calliope_exceptionsConflictingArgumentsExceptionResetEnforcedRetentionVerifyDateInFuturer#   )r   r   r   r!   r#   s        r   _parse_update_bvr2   J   s     #/">">
((#   +	..43F3F

;
;	- 
 
..!88:N!44-N 
00 $	
 r   c                    [        5       nUR                  R                  R                  5       nUR                  nUR
                  n U R                  X5      nU R                  U5      nUR                  UUUR                  UUS9nU(       ab  UR!                  UR#                  U5      SR%                  UR'                  5       5      SS9n
[(        R*                  " UR'                  5       SS9  U
$ [(        R*                  " UR'                  5       SS[        R,                  R%                  UR.                  5      S	9  U$ ! [        R                   a*  n	[        R                  " U	[        R                  5      eSn	A	ff = f)
a@  Constructs and sends request.

Args:
  self: The object that is calling this method.
  args: argparse.Namespace, An object that contains the values for the
    arguments specified in the .Args() method.

Returns:
  ProcessHttpResponse of the request made.

Raises:
  exceptions.HttpException: if the http request fails.
)force_updateupdate_maskforce_update_access_restrictionNzGUpdating backup vault [{}]. (This operation could take up to 1 minute.)F)operation_refmessage
has_resultzbackup vault)kindT)r:   is_asyncdetails)r   CONCEPTSbackup_vaultParseno_asyncr6   ParseUpdateBvGetUpdateMaskUpdater4   apitools_exceptions	HttpErrorr   HttpExceptionr   HTTP_ERROR_FORMATWaitForOperationGetOperationRefformatRelativeNamer   UpdatedResourceASYNC_OPERATION_MESSAGEname)selfr   clientr>   r@   r6   	parsed_bvr5   	operationeresources              r   _runrU   w   sZ   " &++113,]]($($H$H!>""40I$$T*K&&(G  I &&,,Y7%%+VL,E,E,G%H ' H 113.IO!**11)..A	 
+ 
	&	& >

"
"1d&<&<
==>s   ?D> >E<%E77E<c                       \ rS rSrSrSSSSS.r\S\R                  4S	 j5       r	S
\R                  S\4S jrS
\R                  S\4S jrS rSrg)rC      $Update a Backup and DR backup vault.z%Updates a Backup and DR backup vault.z{description}zThis command uses the backupdr/v1 API. The full documentation for this API can be found at: https://cloud.google.com/backup-disaster-recoverya          To update a backup vault BACKUP_VAULT in location MY_LOCATION with one update
        field, run:

        $ {command} BACKUP_VAULT --location=MY_LOCATION --effective-time="2024-03-22"

        To update a backup vault BACKUP_VAULT in location MY_LOCATION with multiple
        update fields, run:

        $ {command} BACKUP_VAULT --location=MY_LOCATION             --backup-min-enforced-retention="400000s" --description="Updated backup vault"
        )BRIEFDESCRIPTIONzAPI REFERENCEEXAMPLESr	   c                     [        U 5        gr   Nr   r   s    r   ArgsUpdate.Args        Vr   r   r   c                     [        U5      $ zReturns the update mask for the update command.

Args:
  args: argparse.Namespace, An object that contains the values for the
    arguments specified in the .Args() method.

Returns:
  A string containing the update mask.
r*   rO   r   s     r   rB   Update.GetUpdateMask   s     #4((r   rP   c                 F    [        U5      u  nnnnUR                  UUUUS9$ a  Parses the update backup vault arguments.

Args:
  args: argparse.Namespace, An object that contains the values for the
    arguments specified in the .Args() method.
  client: BackupVaultsClient, The client to use to parse the backup vault.

Returns:
  A parsed backup vault object.
)r   r   r!   r#   r2   ParseUpdaterO   r   rP   r   r   r!   r#   s          r   rA   Update.ParseUpdateBv   C      	% &C%-	   r   c                     [        X5      $ NrU   re   s     r   Run
Update.Run       r    N)__name__
__module____qualname____firstlineno____doc__detailed_helpstaticmethodargparseArgumentParserr_   	NamespacestrrB   r   rA   rq   __static_attributes__rt   r   r   rC   rC      sy     - 7$?-, 8**  
) 2 2 
)s 
) 2 2 <N 2r   rC   c                   z    \ rS rSrSr\S 5       rS\R                  S\	4S jr
S\R                  S\4S jrS	 rS
rg)UpdateAlpha   rX   c                     [        U 5        gr]   r^   r   s    r   r_   UpdateAlpha.Args  ra   r   r   rP   c                 F    [        U5      u  nnnnUR                  UUUUS9$ rh   ri   rk   s          r   rA   UpdateAlpha.ParseUpdateBv  rm   r   r   c                     [        U5      nU$ rc   rd   )rO   r   masks      r   rB   UpdateAlpha.GetUpdateMask%  s     #4(DKr   c                     [        X5      $ ro   rp   re   s     r   rq   UpdateAlpha.Run2  rs   r   rt   N)ru   rv   rw   rx   ry   r{   r_   r|   r~   r   rA   r   rB   rq   r   rt   r   r   r   r      sO    ,  2 2 <N 2 2 2 s r   r   )!ry   r|   apitools.base.pyr   rD   googlecloudsdk.api_lib.backupdrr   -googlecloudsdk.api_lib.backupdr.backup_vaultsr   googlecloudsdk.api_lib.utilgooglecloudsdk.callioper   r.   #googlecloudsdk.command_lib.backupdrr   r,   googlecloudsdk.corer   r}   r   r~   r   r*   r2   rU   ReleaseTracksReleaseTrackGADefaultUniverseOnlyUpdateCommandrC   ALPHAr   rt   r   r   <module>r      s    ,  > 0 L 2 ( E 5 D #BX44 B("("4"4 " "0*8-- *Z8


8v D%%(()HT H  *HV D%%++,3& 3 -3r   