
                             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  G d
 de	j                        Zy)z bigtable tables restore command.    )absolute_import)division)unicode_literalsN)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)RestoreTablesz/Restore a Cloud Bigtable backup to a new table.zS
          This command restores a Cloud Bigtable backup to a new table.
          a  
          To restore table 'table2' from backup 'backup1', run:

            $ {command} --source-instance=instance1 --source-cluster=cluster1 --source=backup1 --destination-instance=instance1 --destination=table2

          To restore table 'table2' from backup 'backup1' in a different project, run:

            $ {command} --source=projects/project1/instances/instance1/clusters/cluster1/backups/backup1 --destination=projects/project2/instances/instance2/tables/table2
          )DESCRIPTIONEXAMPLESc                 t    t        j                  |        t        j                  |       j                          y)z Register flags for this command.N)r   AddTableRestoreResourceArgArgAdderAddAsync)parsers    0lib/surface/bigtable/instances/tables/restore.pyArgszRestoreTables.Args0   s)     ((0v'')    c                    t        j                         }t        j                         }|j                  j                  j                         }|j                  j                  j                         }|j                  |j                         |j                               }|j                  |j                         j                         |      }|j                  j                  |      }t        j                  |      }	|j                  rDt!        j"                  |	j                         dj%                  |j                               d       yt        j&                  |	dj%                  |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.
    )backuptableId)parentrestoreTableRequestzbigtable table {0}T)kindis_asyncNzCreating bigtable table {0})r   GetAdminClientGetAdminMessagesCONCEPTSsourceParsedestinationRestoreTableRequestRelativeNameName2BigtableadminProjectsInstancesTablesRestoreRequestParentprojects_instances_tablesRestoreGetOperationRefasync_r	   CreatedResourceformat
AwaitTable)
selfargsclimsgs
backup_ref	table_refrestore_requestmsg	operationoperation_refs
             r   RunzRestoreTables.Run6   s<    


C  "D%%++-J))//1I..&&( 	 / "O BB!..0+ C -C
 --55c:I((3M{{	

$
$
&#**9>>+;< ??%,,Y^^-=>@ @r   N)
__name__
__module____qualname____doc__textwrapdedentdetailed_helpstaticmethodr   r9    r   r   r   r      sP    7 (//   (//  -" * *
$@r   r   )r=   
__future__r   r   r   r>   googlecloudsdk.api_lib.bigtabler   googlecloudsdk.callioper   #googlecloudsdk.command_lib.bigtabler   googlecloudsdk.corer	   RestoreCommandr   rB   r   r   <module>rI      s6    ' &  '  0 ( 9 #=@D'' =@r   