
    O                         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\
R                  5      rg)z Command for spanner backup copy.    )absolute_import)division)unicode_literalsN)backup_operations)backups)base)resource_args)logc                   V    \ rS rSrSrS\R                  " S5      0r\S 5       r	S r
Srg)	Copy   z,Copies a backup of a Cloud Spanner database.EXAMPLESaj          To copy a backup within the same project, run:

          $ {command} --source-instance=SOURCE_INSTANCE_ID --source-backup=SOURCE_BACKUP_ID  --destination-instance=DESTINATION_INSTANCE_ID --destination-backup=DESTINATION_BACKUP_ID --expiration-date=2020-03-29T10:49:41Z

        To copy a backup to a different project, run:

          $ {command} --source-backup=projects/SOURCE_PROJECT_ID/instances/SOURCE_INSTANCE_ID/backups/SOURCE_BACKUP_ID --destination-backup=projects/DESTINATION_PROJECT_ID/instances/DESTINATION_INSTANCE_ID/backups/DESTINATION_BACKUP_ID --expiration-date=2020-03-29T10:49:41Z

        c                 H   [         R                  " U 5        U R                  SSS9nUR                  SSS9  UR                  SSS9  [        R
                  R                  U 5        U R                  5       n[         R                  " U5        [         R                  " US5        g	)
z Register flags for this command.T)mutexrequiredz--expiration-datezExpiration time of the backup, must be at least 6 hours and at most 366 days from the time when the source backup is created. See `$ gcloud topic datetimes` for information on date/time formats.)helpz--retention-periodzRetention period of the backup relative from now, must be at least 6 hours and at most 366 days from the time when the source backup is created. See `$ gcloud topic datetimes` for information on duration formats.z to copy the Cloud Spanner backupN)	r	   AddCopyBackupResourceArgsadd_argument_groupadd_argumentr   
ASYNC_FLAGAddToParserAddCopyBackupEncryptionTypeArgAddKmsKeyResourceArg)parsergroup_parserencryption_group_parsers      #lib/surface/spanner/backups/copy.pyArgs	Copy.Args/   s     ++F3,,4$,GLK  L
     	OO'$779001HI&&'>'IK    c                    UR                   R                  R                  5       nUR                   R                  R                  5       n[        R
                  " U5      n[        R                  " U5      n[        R                  " X#UXE5      nUR                  (       aX  [        R                  R                  SR                  UR                  5       UR                  5       UR                  5      5        U$ [         R"                  " USR                  UR                  5      5      nUR$                  c  [        R&                  " U5        U$ )z9This is what gets called when the user runs this command.zFCopy request issued from [{}] to [{}]
Check operation [{}] for status.z&Waiting for operation [{}] to complete)CONCEPTSsourceParsedestinationr	   GetCopyBackupEncryptionTypeGetAndValidateKmsKeyNamer   
CopyBackupasync_r
   statusPrintformatRelativeNamenamer   AwaiterrorCreatedResource)selfargssource_backup_refdestination_backup_refencryption_typekms_keyop	op_results           r   RunCopy.RunF   s    ,,224!]]66<<>#??EO44T:G			-t+
6B{{	jj ::@&,99;1>>@"'';KL i!''
4;;BGGDFI	xx	)$r     N)__name__
__module____qualname____firstlineno____doc__textwrapdedentdetailed_helpstaticmethodr   r:   __static_attributes__r<   r    r   r   r      s=    4 
// 	 	- K K,r    r   )rA   
__future__r   r   r   rB   googlecloudsdk.api_lib.spannerr   r   googlecloudsdk.callioper   "googlecloudsdk.command_lib.spannerr	   googlecloudsdk.corer
   Commandr   r<   r    r   <module>rM      s5    ' &  '  < 2 ( < #<4<< <r    