
    #                     P   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lmZ dd	lmZ dd
lmZ ej(                   ej*                  ej,                  j.                  ej,                  j0                         G d dej2                                      Zy)Create an on-demand backup.    )absolute_import)division)unicode_literals)
exceptions)util)BackupPlanAssociationsClient)base)flags)logc                   2    e Zd ZdZddddZed        Zd Zy)	TriggerBackupz*Create an on-demand backup for a resource.r   zD{description} Trigger an on demand backup for the given backup rule.a3          To trigger an on demand backup for a backup plan association `sample-bpa` in project `sample-project` and location `us-central1` with backup rule `sample-backup-rule`, run:

          $ {command} sample-bpa --project=sample-project --location=us-central1 --backup-rule-id=sample-backup-rule
        )BRIEFDESCRIPTIONEXAMPLESc                     t         j                  j                  |        t         j                  j                  | d       t	        j
                  |        y)zySpecifies additional command flags.

    Args:
      parser: argparse.Parser: Parser object for command line inputs.
    TN)r
   
ASYNC_FLAGAddToParser
SetDefaultr   AddTriggerBackupFlags)parsers    @lib/surface/backup_dr/backup_plan_associations/trigger_backup.pyArgszTriggerBackup.Args1   s8     	OO'OOvt,	'    c           	         t               }|j                  }|j                  j                  j	                         }|j
                  }|j                  }|r|rt        j                  d      	 |j                  |||      }|rQt!        j"                  d|j%                         ddt        j&                  j)                  |j*                        d       y|j-                  |j/                  |      dj)                  |j%                                      t!        j"                  d|j%                         dd	ddd
       y# t        j                  $ r)}t        j                  |t        j                        d}~ww xY w)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.
    zmargument --custom-retention-days: At most one of --backup-rule-id | --custom-retention-days may be specified.Nzon demand backupzbackup plan associationT)kindis_asyncdetailsfailedztOn demand backup in progress [{}]. (This operation usually takes less than 15 minutes but could take up to 8 hours.))operation_refmessageFzon demand backup done for)r   r   r   r   operation_past_tense)r	   async_CONCEPTSbackup_plan_associationParsebackup_rule_idcustom_retention_dayscalliope_exceptionsMutualExclusionErrorr   apitools_exceptions	HttpErrorr   HttpExceptionr   HTTP_ERROR_FORMATr   _PrintResourceChangeRelativeNameASYNC_OPERATION_MESSAGEformatnameWaitForOperationGetOperationRef)	selfargsclientr   r%   backup_ruler(   	operationes	            r   RunzTriggerBackup.Run<   sp    *+F{{H"mmCCIIK%%K 66,447 
@&&
!;0Ei
  


!
.
.
0(..55innE 
,,Y7CCI6'446D	   ,,.&8 I (( @$$Q(>(>??@s   -D= =E9$E44E9N)__name__
__module____qualname____doc__detailed_helpstaticmethodr   r<    r   r   r   r       s4     3 -
P
- ( (?r   r   N)r@   
__future__r   r   r   apitools.base.pyr   r+   googlecloudsdk.api_lib.backupdrr   8googlecloudsdk.api_lib.backupdr.backup_plan_associationsr	   googlecloudsdk.api_lib.utilgooglecloudsdk.callioper
   r)   #googlecloudsdk.command_lib.backupdrr   googlecloudsdk.corer   DefaultUniverseOnlyReleaseTracksReleaseTrackALPHAGACommandr   rC   r   r   <module>rR      s    " '  ' > 0 a 2 ( E 5 # D%%++T->->-A-ABYDLL Y C Yr   