
                         \   S 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S
KJr  SSKJr  SSKJr  \
R$                  " \
R&                  R(                  \
R&                  R*                  \
R&                  R,                  5       " S S\
R.                  5      5       rg)z*Restores a backup of a Cloud SQL instance.    )absolute_import)division)unicode_literals)api_util)
operations)validate)base)flags)log)
properties)
console_ioc                   4    \ rS rSrSr\S 5       rS rS rSr	g)RestoreBackup   zRestores a backup of a Cloud SQL instance.

DEPRECATED: This command is deprecated and will be removed.
Use 'gcloud beta sql backups restore' instead.
c                     U R                  S[        R                  SS9  U R                  S[        SS9  U R                  S[        R                  SS9  [        R
                  R                  U 5        g	)
zArgs is called by calliope to gather arguments for this command.

Args:
  parser: An argparse parser that you can use to add arguments that go
      on the command line after this command. Positional arguments are
      allowed.
instancez,Cloud SQL instance ID that will be restored.)	completerhelpz--backup-idz)The ID of the backup run to restore from.)typer   z--backup-instancez6The ID of the instance that the backup was taken from.N)add_argumentr
   InstanceCompleterintr	   
ASYNC_FLAGAddToParser)parsers    +lib/surface/sql/instances/restore_backup.pyArgsRestoreBackup.Args(   s}     ));  = 8  : ))E  G 	OO'    c                     [         R                  " UR                  5        [        R                  " SSSS9  U R                  U5      $ )a  Restores a backup of a Cloud SQL instance.

Args:
  args: argparse.Namespace, The arguments that this command was invoked
      with.

Returns:
  A dict object representing the operations resource describing the
  restoreBackup operation if the restoreBackup was successful.
zIAll current data on the instance will be lost when the backup is restoredT)messagedefaultcancel_on_no)r   ValidateInstanceNamer   r   PromptContinue_HandleBackupId)selfargss     r   RunRestoreBackup.Run?   sB     !!$--0&	 %%r   c                    [         R                  " [         R                  5      nUR                  nUR                  nUR
                  R                  UR                  S[        R                  R                  R                  R                  0SS9nUR                  (       d  UR                  Ul        UR                  R                  UR!                  UR                  UR                  UR#                  UR%                  UR&                  UR                  S9S9S95      nUR
                  R)                  SUR*                  UR                  S9nUR,                  (       a=  UR.                  R1                  UR3                  UR                  UR4                  S	95      $ [.        R6                  R9                  X7S
5        [:        R<                  R?                  SRA                  US95        g)a1  Restores a backup using v1beta4. The backup is specified with backup_id.

Args:
  args: argparse.Namespace, The arguments that this command was invoked
      with.

Returns:
  A dict object representing the operations resource describing the
  restoreBackup operation if the restoreBackup was successful.
projectzsql.instances)params
collection)backupRunId
instanceId)restoreBackupContext)r,   r   instancesRestoreBackupRequestzsql.operations)	operationr,   )r,   r3   zRestoring Cloud SQL instancezRestored [{instance}].
)r   N)!r   	SqlClientAPI_VERSION_DEFAULT
sql_clientsql_messagesresource_parserParser   r   VALUEScorer,   	GetOrFailbackup_instance	instancesr    SqlInstancesRestoreBackupRequestInstancesRestoreBackupRequestRestoreBackupContext	backup_idCreatenameasync_r   GetSqlOperationsGetRequestr3   OperationsV1Beta4WaitForOperationr   statuswriteformat)r'   r(   clientr6   r7   instance_refresult_operationoperation_refs           r   r&   RestoreBackup._HandleBackupIdS   s     < <=F""J&&L))//:,,1199CCD" 0 $L
 !]]d!++9955 ((!**::)5)J)J$(NN#'#7#7 *K *: ; ;	 	6 	=> **11"''$$ 2 &M
 {{""&&

.
.#++}7N7N / PQ Q
   11#AC JJ/666MNr    N)
__name__
__module____qualname____firstlineno____doc__staticmethodr   r)   r&   __static_attributes__rR   r   r   r   r      s%     ( (,&(1r   r   N)rW   
__future__r   r   r   googlecloudsdk.api_lib.sqlr   r   r   googlecloudsdk.callioper	   googlecloudsdk.command_lib.sqlr
   googlecloudsdk.corer   r   googlecloudsdk.core.consoler   ReleaseTracksReleaseTrackGABETAALPHACommandr   rR   r   r   <module>rf      s    1 &  ' / 1 / ( 0 # * 2 D%%(($*;*;*@*@%%++-cDLL c-cr   