
                             d Z ddlmZ ddlmZ ddlmZ ddl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  G d de
j                        Zy)zbigtable backups copy command.    )absolute_import)division)unicode_literalsN)backups)util)base)	arguments)logc                   p    e Zd ZdZ ej
                  d       ej
                  d      dZed        Zd Z	y)Copyz-Copy a Cloud Bigtable backup to a new backup.zM
          This command creates a copy of a Cloud Bigtable backup.
          a6          To copy a backup within the same project, run:

          $ {command} --source-instance=SOURCE_INSTANCE --source-cluster=SOURCE_CLUSTER  --source-backup=SOURCE_BACKUP --destination-instance=DESTINATION_INSTANCE --destination-cluster=DESTINATION_CLUSTER --destination-backup=DESTINATION_BACKUP --expiration-date=2023-09-01T10:49:41Z

        To copy a backup to a different project, run:

          $ {command} --source-backup=projects/SOURCE_PROJECT/instances/SOURCE_INSTANCE/clusters/SOURCE_CLUSTER/backups/SOURCE_BACKUP --destination-backup=projects/DESTINATION_PROJECT/instances/DESTINATION_INSTANCE/clusters/DESTINATION_CLUSTER/backups/DESTINATION_BACKUP --expiration-date=2022-08-01T10:49:41Z

        To set retention period and run asyncronously, run:

          $ {command} --source-backup=projects/SOURCE_PROJECT/instances/SOURCE_INSTANCE/clusters/SOURCE_CLUSTER/backups/SOURCE_BACKUP --destination-backup=projects/DESTINATION_PROJECT/instances/DESTINATION_INSTANCE/clusters/DESTINATION_CLUSTER/backups/DESTINATION_BACKUP --retention-period=2w --async

        )DESCRIPTIONEXAMPLESc                     t        j                  |        | j                  dd      }|j                  dd       |j                  dd       t        j
                  j                  |        y)	z Register flags for this command.T)mutexrequiredz--expiration-datezExpiration time of the backup, must be at least 6 hours and at most 30 days from the time 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 30 days from the time the source backup is created. See `$ gcloud topic datetimes` for information on duration formats.N)r	   AddCopyBackupResourceArgsadd_argument_groupadd_argumentr   
ASYNC_FLAGAddToParser)parsergroup_parsers     $lib/surface/bigtable/backups/copy.pyArgsz	Copy.Args4   st     ''/,,4$,GLO   !   	OO'    c                 V   |j                   j                  j                         }|j                   j                  j                         }t	        j
                  |||      }t        j                  |      }|j                  rXt        j                  j                  dj                  |j                         |j                         |j                               |S t        j                  |dj                  |j                              }|j                   t        j"                  |       |S )zThis is what gets called when the user runs this command.

    Args:
      args: an argparse namespace. All the arguments that were provided to this
        command invocation.

    Returns:
      Some value that we want to have printed later.
    zFCopy request issued from [{}] to [{}]
Check operation [{}] for status.z&Waiting for operation [{}] to complete)CONCEPTSsourceParsedestinationr   
CopyBackupr   GetOperationRefasync_r
   statusPrintformatRelativeNamenameAwaitBackuperrorCreatedResource)selfargssource_backup_refdestination_backup_refopoperation_ref	op_results          r   RunzCopy.RunM   s     ,,224!]]66<<>			-/Et	LB((,M{{	jj ::@&,99;1>>@"'';KL i  ?FFrwwOQI	xx	)$r   N)
__name__
__module____qualname____doc__textwrapdedentdetailed_helpstaticmethodr   r4    r   r   r   r      sM    5$X__ &  "(// # 	-( ( (0r   r   )r8   
__future__r   r   r   r9   googlecloudsdk.api_lib.bigtabler   r   googlecloudsdk.callioper   #googlecloudsdk.command_lib.bigtabler	   googlecloudsdk.corer
   Commandr   r=   r   r   <module>rD      s7    % &  '  3 0 ( 9 #I4<< Ir   