
    %                        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  G d de      Z ej,                  ej.                  j0                  ej.                  j2                  ej.                  j4                         G d deej6                               Zy)5Delete a client certificate for a Cloud SQL instance.    )absolute_import)division)unicode_literals)api_util)cert)
exceptions)
operations)validate)base)flags)log)
properties)
console_ioc                        e Zd ZdZed        Zy)_BaseDeletez+Base class for sql ssl client_certs delete.c                     t         j                  j                  |        | j                  dd       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.
    common_namez7User supplied name. Constrained to ```[a-zA-Z.-_ ]+```.)helpN)r   
ASYNC_FLAGAddToParseradd_argumentr   AddInstance)parsers    *lib/surface/sql/ssl/client_certs/delete.pyArgsz_BaseDelete.Args$   s@     	OO'
F  H 
f    N)__name__
__module____qualname____doc__staticmethodr    r   r   r   r   !   s    3 r   r   c                       e Zd ZdZd Zy)Deleter   c                    t        j                  t         j                        }|j                  }|j                  }t        j                  |j                         |j                  j                  |j                  dt        j                  j                  j                  j                  id      }t        j                   dj#                  |j$                        dd       t'        j(                  |||j                  ||j$                        }|s0t+        j,                  dj#                  |j$                  |            |j.                  j1                  |j3                  |j                  |j                  |j4                  	            }|j                  j7                  d
|j8                  |j                        }|j:                  r@|j<                  j?                  |jA                  |j                  |jB                              S t<        jD                  jG                  ||d       tI        jJ                  |       y)a  Delete a client certificate for 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.
    Raises:
      ResourceNotFoundError: The ssl cert could not be found for the instance.
    projectzsql.instances)params
collectionzy{0} will be deleted. New connections can no longer be made using this certificate. Existing connections are not affected.T)messagedefaultcancel_on_noz4no ssl cert named [{name}] for instance [{instance}])nameinstance)r'   r.   sha1Fingerprintzsql.operations)	operationr'   )r'   r0   zDeleting sslCertN)&r   	SqlClientAPI_VERSION_DEFAULT
sql_clientsql_messagesr   ValidateInstanceNamer.   resource_parserParser   VALUEScorer'   	GetOrFailr   PromptContinueformatr   r   GetCertRefFromNamer	   ResourceNotFoundErrorsslCertsr%   SqlSslCertsDeleteRequestr/   Creater-   async_r
   GetSqlOperationsGetRequestr0   OperationsV1Beta4WaitForOperationr   DeletedResource)	selfargsclientr3   r4   instance_refcert_refresultoperation_refs	            r   Runz
Delete.Run9   s     < <=F""J&&L!!$--0))//:,,1199CCD" 0 $L IIOJ &&z<'-'='=|'+'7'79H ,,
@
G
G##l H <= =   ''--$$&&$44 	. 	67F **11FKK9I9I 2 KM {{""&&

.
.#++%// / 12 2
   11*m2DF !r   N)r   r   r    r!   rO   r#   r   r   r%   r%   4   s     >;"r   r%   N)r!   
__future__r   r   r   googlecloudsdk.api_lib.sqlr   r   r	   r
   r   googlecloudsdk.callioper   googlecloudsdk.command_lib.sqlr   googlecloudsdk.corer   r   googlecloudsdk.core.consoler   objectr   ReleaseTracksReleaseTrackGABETAALPHACommandr%   r#   r   r   <module>r]      s    < &  ' / + 1 1 / ( 0 # * 2& & D%%(($*;*;*@*@%%++->"[$,, >"->"r   