
                            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
KJr  SSKJ
r  SSKJr  S\R*                  4S jrS\4S jr\R2                  \R4                  " \R6                  R8                  5       " S S\R:                  5      5       5       r\R4                  " \R6                  R>                  5       " S S\5      5       r g)zUpdates a Backup and DR Backup.    )absolute_import)division)unicode_literalsN)
exceptions)util)BackupsClient)base)flags)logparserc                     [         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$    returnc                     / nU R                  S5      (       a  UR                  S5        U R                  S5      (       a  UR                  S5        SR                  U5      $ )Nenforced_retention_end_timeenforcedRetentionEndTimeexpire_time
expireTime,)IsSpecifiedappendjoin)argsupdated_fieldss     r   _add_common_update_maskr#   .   sV    .	34445	m$$,'	.	!!r   c                   b    \ rS rSrSrSSSS.r\S\R                  4S j5       r	S	 r
S
 rS rSrg)Update7   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"
        )BRIEFDESCRIPTIONEXAMPLESr   c                     [        U 5        g Nr   r   s    r   ArgsUpdate.ArgsG   
    Vr   c                     [         R                  " UR                  S5      n[         R                  " UR                  S5      nUR	                  X45      nU$ Nzenforced-retention-end-timezexpire-timecommand_utilVerifyDateInFuturer   r   ParseUpdateselfr!   clientupdated_enforced_retentionr   parsed_backups         r   r6   Update.ParseUpdateK   U    !-!@!@((*G" 11-K &&'AOMr   c                     [        U5      $ r,   r#   r8   r!   s     r   GetUpdateMaskUpdate.GetUpdateMaskX       "4((r   c                    [        5       nUR                  nUR                  R                  R	                  5       n U R                  X5      nU R                  U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R)                  UR+                  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.
)update_maskNbackupT)kindis_asyncdetailszHUpdating backup [{}]. (This operation usually takes less than 1 minute.)F)operation_refmessage
has_result)rG   )r   async_CONCEPTSrF   Parser6   rA   r%   apitools_exceptions	HttpErrorr   HttpExceptionr   HTTP_ERROR_FORMATr   UpdatedResourceRelativeNameASYNC_OPERATION_MESSAGEformatnameWaitForOperationGetOperationRef)
r8   r!   r9   rH   rF   r;   rE   	operationeresponses
             r   Run
Update.Run[   sD    _F{{H]]!!'')F@&&t4m&&t,k--

!   i 	



..55innE	 &&,,Y7v2245 ' H ++-H=O- (( @$$Q(>(>??@s   3D& &E$:%EE$ N)__name__
__module____qualname____firstlineno____doc__detailed_helpstaticmethodargparseArgumentParserr.   r6   rA   r^   __static_attributes__r`   r   r   r%   r%   7   sK     % +$	- 8**  )-r   r%   c                   P    \ rS rSrSr\S\R                  4S j5       rS r	S r
Srg)	UpdateAlpha   r'   r   c                     [        U 5        g r,   r-   r   s    r   r.   UpdateAlpha.Args   r0   r   c                     [         R                  " UR                  S5      n[         R                  " UR                  S5      nUR	                  X45      nU$ r2   r3   r7   s         r   r6   UpdateAlpha.ParseUpdate   r=   r   c                     [        U5      $ r,   r?   r@   s     r   rA   UpdateAlpha.GetUpdateMask   rC   r   r`   N)ra   rb   rc   rd   re   rg   rh   ri   r.   r6   rA   rj   r`   r   r   rl   rl      s.    $8**  )r   rl   )!re   
__future__r   r   r   rh   apitools.base.pyr   rP   googlecloudsdk.api_lib.backupdrr   'googlecloudsdk.api_lib.backupdr.backupsr   googlecloudsdk.api_lib.utilgooglecloudsdk.callioper	   #googlecloudsdk.command_lib.backupdrr
   r4   googlecloudsdk.corer   ri   r   strr#   DefaultUniverseOnlyReleaseTracksReleaseTrackGAUpdateCommandr%   ALPHArl   r`   r   r   <module>r      s    & &  '  > 0 A 2 ( 5 D #%X44 %"S " D%%(()OT O * Od D%%++,)& ) -)r   