
                            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)5Create a server certificate for a Cloud SQL instance.    )absolute_import)division)unicode_literals)api_util)
operations)validate)server_certs)base)flags)log)
propertiesc                   &    e Zd ZdZed        Zd Zy)_BaseAddCertz'Base class for sql server_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_CERTS_FORMAT)parsers    *lib/surface/sql/ssl/server_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                  |	       t9        j:                  |t.        j<                        S )
zCreate a server certificate for a Cloud SQL instance.

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

    Returns:
      The upcoming Server Cert, if the operation was successful.
    projectzsql.instances)params
collection)r   instancezsql.operations)	operationr   zCreating Server Certificatezsql.sslCerts)r   r   r    sha1Fingerprint)r   	SqlClientAPI_VERSION_DEFAULT
sql_clientsql_messagesr	   ValidateInstanceNamer    resource_parserParser   VALUEScorer   	GetOrFail	instancesAddServerCertificate'SqlInstancesAddServerCertificateRequestCreatenamer   OperationsV1Beta4WaitForOperationr
   GetNextServerCertificater"   r   CreatedResourcer   ServerCertForPrintNEXT_CERT_LABEL)
selfargsclientr%   r&   instance_refresult_operationoperation_refnext_server_certcert_refs
             r   Runz_BaseAddCert.Run)   s     < <=F""J&&L!!$--0))//:,,1199CCD" 0 $L
 "++@@<< ((<3H3H 	= 	
 **11"''$$ 2 &M
   11M#@ $<<L, %%,,!$$&&(88	 - H !##,66 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)rA   rB   rC   rD   rF   r   r   rH   rH   ^   s
    
 >r   rH   N)rD   
__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DefaultUniverseOnlyCreateCommandrH   rF   r   r   <module>rW      s    < &  ' / 1 / 7 ( 0 # *<6 <~ $++00$2C2C2I2I lD..  r   