
                            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  G d de      Z ej(                  ej*                  j,                  ej*                  j.                  ej*                  j0                        ej2                   G d deej4                                      Zy)BRoll back to the previous server CA cert for a Cloud SQL instance.    )absolute_import)division)unicode_literals)api_util)
exceptions)
operations)validate)server_ca_certs)base)flags)
propertiesc                   &    e Zd ZdZed        Zd Zy)_BaseRollbackCertz,Base class for sql server_ca_certs rollback.c                     t         j                  j                  |        t        j                  |        | j
                  j                  t        j                         y)z=Declare flag and positional arguments for the command parser.N)r   
ASYNC_FLAGAddToParserr   AddInstancedisplay_info	AddFormatSERVER_CA_CERTS_FORMAT)parsers    /lib/surface/sql/ssl/server_ca_certs/rollback.pyArgsz_BaseRollbackCert.Args"   s>     	OO'	f
!!%">">?    c                 >   t        j                  t         j                        }|j                  }|j                  }t        j                  |j                         |j                  j                  |j                  dt        j                  j                  j                  j                  id      }t        j                   |||      }|st#        j$                  d      |j&                  j)                  |j+                  |j                  |j                  |j-                  |j/                  |j0                                          }|j                  j3                  d|j4                  |j                  	      }t6        j8                  j;                  ||d
       |S )a  Roll back to the previous server CA cert for a Cloud SQL instance.

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

    Returns:
      The Server CA Cert that was rolled back to, if the operation was
      successful.
    projectzsql.instances)params
collectionz)No previous Server CA Certificate exists.)nextVersion)rotateServerCaContext)r   instanceinstancesRotateServerCaRequestzsql.operations)	operationr   z.Rolling back to previous Server CA Certificate)r   	SqlClientAPI_VERSION_DEFAULT
sql_clientsql_messagesr
   ValidateInstanceNamer"   resource_parserParser   VALUEScorer   	GetOrFailr   GetPreviousServerCar   ResourceNotFoundError	instancesRotateServerCa!SqlInstancesRotateServerCaRequestInstancesRotateServerCaRequestRotateServerCaContextsha1FingerprintCreatenamer	   OperationsV1Beta4WaitForOperation)	selfargsclientr'   r(   instance_refprevious_server_caresult_operationoperation_refs	            r   Runz_BaseRollbackCert.Run)   s     < <=F""J&&L!!$--0))//:,,1199CCD" 0 $L
 )<<L,0 ,,
57 7 "++::66 ((!**+7**&2&H&H 2 B B 'I 'D + E	 	7 	FG **11"''$$ 2 &M
   11M8: r   N)__name__
__module____qualname____doc__staticmethodr   rB    r   r   r   r      s    4@ @/r   r   c                       e Zd ZdZy)RollbackCertr   N)rC   rD   rE   rF   rH   r   r   rJ   rJ   [   s    
 Kr   rJ   N)rF   
__future__r   r   r   googlecloudsdk.api_lib.sqlr   r   r	   r
   googlecloudsdk.api_lib.sql.sslr   googlecloudsdk.callioper   googlecloudsdk.command_lib.sqlr   googlecloudsdk.corer   objectr   ReleaseTracksReleaseTrackGABETAALPHAUniverseCompatibleCreateCommandrJ   rH   r   r   <module>rY      s    I &  ' / 1 1 / : ( 0 *9 9x $++00$2C2C2I2I $d&8&8  r   