
    
                     8   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  e	j                  e	j                  j                   e	j                  j"                  e	j                  j$                         G d
 de	j&                               Zy))Lists databases for a Cloud SQL instance.    )absolute_import)division)unicode_literals)api_util)validate)base)flags)
propertiesc                   &    e Zd ZdZed        Zd Zy)Listr   c                     t        j                  |        | j                  j                  d       | j                  j	                  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.
    zU
      table(
          name,
          charset,
          collation
        )
      N)r
   AddInstancedisplay_info	AddFormatAddCacheUpdaterDatabaseCompleter)parsers    !lib/surface/sql/databases/list.pyArgsz	List.Args!   sG     
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                              }t%        |j&                        S )a  Lists databases for a Cloud SQL instance.

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

    Returns:
      A dict object that has the list of database resources if the api request
      was successful.
    projectzsql.instances)params
collection)r   instance)r   	SqlClientAPI_VERSION_DEFAULT
sql_clientsql_messagesr   ValidateInstanceNamer   resource_parserParser   VALUEScorer   	GetOrFail	databasesr   SqlDatabasesListRequestiteritems)selfargsclientr   r    instance_refresults          r   RunzList.Run4   s      < <=F""J&&L!!$--0))//:,,1199CCD" 0 $L
 !!&&,, ((<3H3H 	- 	JKF r   N)__name__
__module____qualname____doc__staticmethodr   r0    r   r   r   r      s      2A A$r   r   N)r4   
__future__r   r   r   googlecloudsdk.api_lib.sqlr   r   googlecloudsdk.callioper	   googlecloudsdk.command_lib.sqlr
   googlecloudsdk.corer   ReleaseTracksReleaseTrackGABETAALPHAListCommandr   r6   r   r   <module>rB      s{    0 &  ' / / ( 0 * D%%(($*;*;*@*@%%++-.4 .-.r   