
                            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Zej*                   ej,                  ej.                  j0                  ej.                  j2                  ej.                  j4                         G d dej6                                      Zy)Deletes a Cloud SQL instance.    )absolute_import)division)unicode_literals)
exceptions)api_util)
operations)validate)base)flags)log)
properties)
console_ioNc                   &    e Zd ZdZed        Zd Zy)Deleter   c                 R   t         j                  j                  |        | j                  dt        j
                  d       t	        j                  |        t	        j                  |        | j                  d      }t	        j                  |       t	        j                  |       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.
    instancezCloud SQL instance ID.)	completerhelpF)requiredN)r   
ASYNC_FLAGAddToParseradd_argumentr   InstanceCompleterAddEnableFinalBackupAddFinalbackupDescriptionadd_mutually_exclusive_group AddFinalBackupExpiryTimeArgumentAddFinalbackupRetentionDays)parser
expirations     #lib/surface/sql/instances/delete.pyArgszDelete.Args(   s     	OO'
))%  ' 
v&	##F+44e4DJ	**:6	%%j1    c           
      *   t        j                  t         j                        }|j                  }|j                  }d}t        j                  |j                         |j                  j                  |j                  dt        j                  j                  j                  j                  id      }	 |j                  j!                  |j#                  |j                  |j                              }||j0                  j2                  rd}	nd}	t5        j6                  |	      syd}
|j8                  |j8                  d	kD  r|j8                  }nd}|j:                  |j:                  j=                  d
      }
	 |j                  j?                  |jA                  |j                  |j                  |jB                  ||jD                  |
            }|j                  jG                  d|jH                  |j                        }|jJ                  r@|jL                  j!                  |jO                  |j                  |jP                              S tL        jR                  jU                  ||d       t)        jV                  |       y# t$        j&                  $ r6}d}t)        j*                  dt-        j.                  |             Y d}~d}~ww xY w# t$        j&                  $ r+ t)        j*                  dt-        j.                  |              w xY w)a  Deletes 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 delete was successful.
    Nprojectzsql.instances)params
collection)r&   r   z0Ignoring the error to get instance resource : %sz_All of the instance data will be lost except the existing backups when the instance is deleted.zCAll of the instance data will be lost when the instance is deleted.r   z%Y-%m-%dT%H:%M:%S.%fZ)r   r&   enableFinalBackupfinalBackupTtlDaysfinalBackupDescriptionfinalBackupExpiryTimezsql.operations)	operationr&   )r&   r-   zDeleting Cloud SQL instancezoperation : %s),r   	SqlClientAPI_VERSION_DEFAULT
sql_clientsql_messagesr
   ValidateInstanceNamer   resource_parserParser   VALUEScorer&   	GetOrFail	instancesGetSqlInstancesGetRequestr   	HttpErrorr   debugsix	text_typesettingsretainBackupsOnDeleter   PromptContinuefinal_backup_retention_daysfinal_backup_expiry_timestrftimer   SqlInstancesDeleteRequestenable_final_backupfinal_backup_descriptionCreatenameasync_r	   SqlOperationsGetRequestr-   OperationsV1Beta4WaitForOperationDeletedResource)selfargsclientr0   r1   operation_refinstance_refinstance_resourceerrorpromptexpiry_timeretention_daysresults                r"   Runz
Delete.Run<   s     < <=F""J&&LM!!$--0))//:,,1199CCD" 0 L$..22

-
-"**\5J5J .   	%&&<<+  P  $$V,K((4,,q077nn$$011::
!k##**

0
0#,,"** $ 8 8!/%)%B%B$/ 1 	f ,,33
fkk<;O;O 4 Qm 
$$((00%--'11 1 34 	4
 ""33
m%BD 
,'G   
ii
<
--
 J  	ii #--">?s,   4A J ;CK 6K K+KK>LN)__name__
__module____qualname____doc__staticmethodr#   rZ    r$   r"   r   r   "   s     &2 2&dr$   r   )r^   
__future__r   r   r   apitools.base.pyr   googlecloudsdk.api_lib.sqlr   r	   r
   googlecloudsdk.callioper   googlecloudsdk.command_lib.sqlr   googlecloudsdk.corer   r   googlecloudsdk.core.consoler   r=   DefaultUniverseOnlyReleaseTracksReleaseTrackGABETAALPHACommandr   r`   r$   r"   <module>ro      s    $ &  ' ' / 1 / ( 0 # * 2 
 D%%(($*;*;*@*@%%++-{T\\ {- {r$   