
                            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)1Create a server CA cert for a Cloud SQL instance.    )absolute_import)division)unicode_literals)api_util)
operations)validate)server_ca_certs)base)flags)log)
propertiesc                   &    e Zd ZdZed        Zd Zy)_BaseAddCertz*Base class for sql server_ca_certs create.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/create.pyArgsz_BaseAddCert.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      }|j                  j!                  |j#                  |j                  |j                              }|j                  j%                  d|j&                  |j                        }t(        j*                  j-                  ||d       t/        j0                  |||      }|j                  j%                  d|j                  |j                  |j2                  	      }	t5        j6                  |	       |S )
zCreate a server CA cert for a Cloud SQL instance.

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

    Returns:
      The upcoming Server CA Cert, if the operation was successful.
    projectzsql.instances)params
collection)r   instancezsql.operations)	operationr   zCreating Server CA Certificatezsql.sslCerts)r   r   r    sha1Fingerprint)r   	SqlClientAPI_VERSION_DEFAULT
sql_clientsql_messagesr	   ValidateInstanceNamer    resource_parserParser   VALUEScorer   	GetOrFail	instancesAddServerCaSqlInstancesAddServerCaRequestCreatenamer   OperationsV1Beta4WaitForOperationr
   GetNextServerCar"   r   CreatedResource)
selfargsclientr%   r&   instance_refresult_operationoperation_refnext_server_cacert_refs
             r   Runz_BaseAddCert.Run)   s     < <=F""J&&L!!$--0))//:,,1199CCD" 0 $L
 "++7733 ((<3H3H 	4 	JK **11"''$$ 2 &M
   11M#CE %44Z5ACN %%,,!$$&&&66	 - 8H !r   N)__name__
__module____qualname____doc__staticmethodr   r>    r   r   r   r      s    2@ @+r   r   c                       e Zd ZdZy)AddCertr   N)r?   r@   rA   rB   rD   r   r   rF   rF   W   s
    
 :r   rF   N)rB   
__future__r   r   r   googlecloudsdk.api_lib.sqlr   r   r	   googlecloudsdk.api_lib.sql.sslr
   googlecloudsdk.callioper   googlecloudsdk.command_lib.sqlr   googlecloudsdk.corer   r   objectr   ReleaseTracksReleaseTrackGABETAALPHAUniverseCompatibleCreateCommandrF   rD   r   r   <module>rU      s    8 &  ' / 1 / : ( 0 # *56 5p $++00$2C2C2I2I lD..  r   