
    o                        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$                  S
S4S jrS
\4S jr\R,                  \R.                  " \R0                  R2                  5       " S S\R4                  5      5       5       r\R.                  " \R0                  R8                  5       " S S\5      5       rg)zUpdates a Backup and DR Backup.    N)
exceptions)util)BackupsClient)base)flags)logparserreturnc                     [         R                  R                  U 5        [         R                  R                  U S5        [        R
                  " U S5        [        R                  " U 5        g)zmSpecifies additional command flags.

Args:
  parser: argparse.Parser: Parser object for command line inputs.
TzName of the backup to update.N)r   
ASYNC_FLAGAddToParser
SetDefaultr   AddBackupResourceArgAddUpdateBackupFlagsr	   s    'lib/surface/backup_dr/backups/update.py_add_common_argsr      sN     //f%//VT*% V$    c                 $  ^  / nT R                  S5      (       a  UR                  S5        T R                  S5      (       a  UR                  S5        / SQn[        U 4S jU 5       5      (       a  UR                  S5        SR                  U5      $ )	Nenforced_retention_end_timeenforcedRetentionEndTimeexpire_time
expireTimeupdate_labelsremove_labelsclear_labelsc              3   F   >#    U  H  nTR                  U5      v   M     g 7fNIsSpecified.0flagargss     r   	<genexpr>#_get_update_mask.<locals>.<genexpr>3   s     8KD		$		K   !labels,)r!   appendanyjoin)r%   updated_fieldslabel_flagss   `  r   _get_update_maskr0   ,   s{    .	34445	m$$,'B+8K888(#	.	!!r   c                   `    \ rS rSrSrSSSS.r\S\R                  SS	4S
 j5       r	S r
S rSrg	)Update8   Update the specified Backup.zUpdates a specific backupz{description}a          To update the enforced retention of a backup sample-backup in backup vault sample-vault, data source
        sample-ds, project sample-project and location us-central1, run:

          $ {command} sample-backup --backup-vault=sample-vault --data-source=sample-ds --project=sample-project --location=us-central1 --enforced-retention-end-time="2025-02-14T01:10:20Z"

        To update the labels on a backup named `my-backup` in the `test-bv` vault and `us-central1` location, run:

            $ {command} my-backup --backup-vault=test-bv --location=us-central1 --update-labels=env=prod,team=storage

        To remove the `env` label from the same backup, run:

            $ {command} my-backup --backup-vault=test-bv --location=us-central1 --remove-labels=env

        To clear all labels from the backup, run:

            $ {command} my-backup --backup-vault=test-bv --location=us-central1 --clear-labels
        )BRIEFDESCRIPTIONEXAMPLESr	   r
   Nc                     [        U 5        g r   r   r   s    r   ArgsUpdate.ArgsT   
    Vr   c                     [         R                  " UR                  S5      n[         R                  " UR                  S5      nUR	                  UUUUR
                  UR                  UR                  5      $ Nzenforced-retention-end-timezexpire-timecommand_utilVerifyDateInFuturer   r   ParseUpdater   r   r   selfbackupr%   clientupdated_enforced_retentionr   s         r   rB   Update.ParseUpdateX   u    !-!@!@((*G" 11-K " r   c                   ^ [        5       nTR                  nTR                  R                  R	                  5       n/ SQn[        U4S jU 5       5      nTR                  S5      nTR                  S5      nU=(       d    Un	U(       d  U	(       d  [        R                  " SS5      e U R                  UTU5      n
[        T5      nUR                  UU
US9nU(       aN  [$        R&                  " UR)                  5       S	S
[         R*                  R-                  UR.                  5      S9  U$ UR1                  UR3                  U5      SR-                  UR)                  5       5      SS9n[$        R&                  " UR)                  5       S	S9  U$ ! [        R                   a*  n[        R                  " U[         R"                  5      eSnAff = f)zConstructs and sends request.

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

Returns:
  ProcessHttpResponse of the request made.
r   c              3   F   >#    U  H  nTR                  U5      v   M     g 7fr   r    r"   s     r   r&   Update.Run.<locals>.<genexpr>y   s     HKD))$//Kr(   r   r   zd--update-labels | --remove-labels | --clear-labels | (--enforced-retention-end-time | --expire-time)z2At least one of the update flags must be provided.)update_maskNrE   T)kindis_asyncdetailszHUpdating backup [{}]. (This operation usually takes less than 1 minute.)F)operation_refmessage
has_result)rN   )r   async_CONCEPTSrE   Parser,   r!   calliope_exceptionsRequiredArgumentExceptionrB   r0   r2   apitools_exceptions	HttpErrorr   HttpExceptionr   HTTP_ERROR_FORMATr   UpdatedResourceRelativeNameASYNC_OPERATION_MESSAGEformatnameWaitForOperationGetOperationRef)rD   r%   rF   rO   rE   r/   has_label_flaghas_enforced_retentionhas_expire_timehas_time_flagparsed_backuprM   	operationeresponses    `             r   Run
Update.Runj   s    _F{{H]]!!'')FDKHKHHN!--.KL&&}5O*=oMm99<
> @&&vtV<m$T*k--

!   i 	



..55innE	 &&,,Y7v2245 ' H ++-H=O- (( @$$Q(>(>??@s   (/F G"%GG )__name__
__module____qualname____firstlineno____doc__detailed_helpstaticmethodargparseArgumentParserr:   rB   rl   __static_attributes__rn   r   r   r2   r2   8   sM     % +$-. 8** t  $;r   r2   c                   T    \ rS rSrSr\S\R                  SS4S j5       rS r	S r
S	rg)
UpdateAlpha   r4   r	   r
   Nc                     [        U 5        g r   r9   r   s    r   r:   UpdateAlpha.Args   r<   r   c                     [         R                  " UR                  S5      n[         R                  " UR                  S5      nUR	                  UUUUR
                  UR                  UR                  5      $ r>   r?   rC   s         r   rB   UpdateAlpha.ParseUpdate   rI   r   c                     [        U5      $ r   )r0   )rD   r%   s     r   GetUpdateMaskUpdateAlpha.GetUpdateMask   s    D!!r   rn   )ro   rp   rq   rr   rs   ru   rv   rw   r:   rB   r   rx   rn   r   r   rz   rz      s5    $8** t  $"r   rz   )rs   rv   apitools.base.pyr   rY   googlecloudsdk.api_lib.backupdrr   'googlecloudsdk.api_lib.backupdr.backupsr   googlecloudsdk.api_lib.utilgooglecloudsdk.callioper   rW   #googlecloudsdk.command_lib.backupdrr   r@   googlecloudsdk.corer   rw   r   strr0   DefaultUniverseOnlyReleaseTracksReleaseTrackGAUpdateCommandr2   ALPHArz   rn   r   r   <module>r      s    &  > 0 A 2 ( E 5 D #%X44 % %	"c 	" D%%(()kT k * k\ D%%++,"& " -"r   