
    ;                        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 ddlmZ ddlmZ ej(                   ej*                  ej,                  j.                  ej,                  j0                  ej,                  j2                         G d dej4                                      Zy)z.Deletes a backup run for a Cloud SQL instance.    )absolute_import)division)unicode_literals)api_util)
exceptions)
operations)validate)base)flags)log)
properties)
console_ioc                   &    e Zd ZdZed        Zd Zy)Deletez(Delete a backup of a Cloud SQL instance.c                     t         j                  j                  |        t        j                  |        t        j
                  |        | j                  j                  d       y)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.
    N)r
   
ASYNC_FLAGAddToParserr   AddBackupIdAddOptionalInstancedisplay_infoAddCacheUpdater)parsers    !lib/surface/sql/backups/delete.pyArgszDelete.Args(   sF     	OO'	f	f%
''-    c           	      b   t        j                  t         j                        }|j                  }|j                  }d}t        j                  ddd       t        j                  |j                        }|r{|j                  j                  |j                  |j                              }|j                  j                  d|j                  |j                  j!                  d      d   	      }n|j"                  t%        j&                  d
      t)        j*                  |j"                         |j                  j-                  |j"                  dt.        j0                  j2                  j4                  j6                  id      }|j8                  j;                  |j=                  |j4                  |j"                  t?        |j                                    }|j                  j                  d|j                  |j4                  	      }|j@                  r@|jB                  jE                  |jG                  |j4                  |jH                              S d}	|rd}	tB        jJ                  jM                  ||djO                  |	             tQ        jR                  |j                  |	       y)a%  Deletes 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 delete
      operation if the api request was successful.
    Nz8The backup will be deleted. You cannot undo this action.T)messagedefaultcancel_on_no)namezsql.operations/   )	operationprojectz>[--instance | --i] is required for instance's backup deletion.r$   zsql.instances)params
collection)r$   instanceid)r$   r#   z
backup runbackupzDeleting {0})*r   	SqlClientAPI_VERSION_DEFAULT
sql_clientsql_messagesr   PromptContinuecommand_validateIsProjectLevelBackupRequestr(   backupsDeleteBackupSqlBackupsDeleteBackupRequestresource_parserCreater    splitr'   r   ArgumentErrorr	   ValidateInstanceNameParser   VALUEScorer$   	GetOrFail
backupRunsr   SqlBackupRunsDeleteRequestintasync_r   GetSqlOperationsGetRequestr#   OperationsV1Beta4WaitForOperationformatr   DeletedResource)
selfargsclientr,   r-   operation_ref is_project_level_backup_deletionresultinstance_refr   s
             r   Runz
Delete.Run6   sS     < <=F""J&&LM J 	44TWW= % (!!..

4
4$''
4
Bf ,,33
fkk477==;Ma;P 4 m 
	&&L
 	
 ##DMM2++11
--Z..33;;EEF$ 2 l
 $$++

1
1"**#,,TWW 2 f ,,33
fkk<;O;O 4 m {{""&&

.
.#++}7N7N /  
 G'g  11M>#8#8#A )r   N)__name__
__module____qualname____doc__staticmethodr   rN    r   r   r   r   !   s    
 1. .H*r   r   N)rR   
__future__r   r   r   googlecloudsdk.api_lib.sqlr   r   r   r	   googlecloudsdk.callioper
   googlecloudsdk.command_lib.sqlr   r/   googlecloudsdk.corer   r   googlecloudsdk.core.consoler   DefaultUniverseOnlyReleaseTracksReleaseTrackGABETAALPHADeleteCommandr   rT   r   r   <module>rb      s    5 &  ' / 1 1 / ( 0 G # * 2 $++00$2C2C2I2IY*T Y* Y*r   