
                         8    S r SSKJr  SSKJr  SSKJr  S rS rg)z0Common cert utility functions for sql instances.    )absolute_import)division)unicode_literalsc                     [        XX45      nU(       d  gUR                  SUR                  UR                  UR                  S9$ )a  Get a cert reference for a particular instance, given its common name.

Args:
  sql_client: apitools.BaseApiClient, A working client for the sql version to
      be used.
  sql_messages: module, The module that defines the messages for the sql
      version to be used.
  resources: resources.Registry, The registry that can create resource refs
      for the sql version to be used.
  instance_ref: resources.Resource, The instance whos ssl cert is being
      fetched.
  common_name: str, The common name of the ssl cert to be fetched.

Returns:
  resources.Resource, A ref for the ssl cert being fetched. Or None if it
  could not be found.
Nzsql.sslCerts)
collectionprojectinstancesha1Fingerprint)GetCertFromNameCreater   r	   r
   )
sql_clientsql_messages	resourcesinstance_refcommon_namecerts         &lib/googlecloudsdk/api_lib/sql/cert.pyGetCertRefFromNamer      sL    & 
<	M$				""$$**	 
 
, ,    c                     U R                   R                  UR                  UR                  UR                  S95      nUR
                   H  nUR                  U:X  d  M  Us  $    g)a?  Get a cert for a particular instance, given its common name.

In the SQL API, the last parameter of the URL is the sha1fingerprint, which is
not something writeable or readable by humans. Instead, the CLI will ask for
the common name. To allow this, we first query all the ssl certs for the
instance, and iterate through them to find the one with the correct common
name.

Args:
  sql_client: apitools.BaseApiClient, A working client for the sql version to
      be used.
  sql_messages: module, The module that defines the messages for the sql
      version to be used.
  instance_ref: resources.Resource, The instance whos ssl cert is being
      fetched.
  common_name: str, The common name of the ssl cert to be fetched.

Returns:
  resources.Resource, A ref for the ssl cert being fetched. Or None if it
  could not be found.
)r   r	   N)sslCertsListSqlSslCertsListRequestr   r	   items
commonName)r   r   r   r   certsr   s         r   r   r   6   sf    , 


"
"))&&1F1F * HI% kkd+%k  
r   N)__doc__
__future__r   r   r   r   r    r   r   <module>r       s    7 '  ',>r   