
                         z   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 ej$                   ej&                  ej(                  j*                  ej(                  j,                  ej(                  j.                         G d dej0                                      Zy)zLists all backups associated with a given instance.

Lists all backups associated with a given instance and configuration
in the reverse chronological order of the enqueued time.
    )absolute_import)division)unicode_literals)
list_pager)api_util)validate)base)filter_rewrite)flags)log)
propertiesc                   &    e Zd ZdZed        Zd Zy)ListzLists all backups associated with the project or a given instance.

  Lists all backups associated with the project or a given Cloud SQL instance
  and configuration in the reverse chronological order of the enqueued time.
  c                     t        j                  | d       | j                  j                  d       | j                  j	                  d        y )NTz
      table(
        id,
        windowStartTime.iso(),
        error.code.yesno(no="-"):label=ERROR,
        status,
        instance
      )
    )r   AddOptionalInstancedisplay_info	AddFormatAddCacheUpdater)parsers    lib/surface/sql/backups/list.pyArgsz	List.Args.   sA    	fd+
!! # 	 ''-    c           	      r   t        j                  t         j                        }|j                  }|j                  }|j
                  s6|j                         j                  j                  j                  d       t        j                         j                  |j                        \  |_        }|j                  r t        j                  d|j                         |rt        j                  d|       t!        j"                  |j$                  |j'                  dj)                  t*        j,                  j.                  j0                  j3                               |      |j4                  |j6                  ddd	      S t9        j:                  |j
                         |j<                  j?                  |j
                  d
t*        j,                  j.                  j0                  j2                  id      }t!        j"                  |j@                  |jC                  |j0                  |j
                              S )a  Lists all backups associated with a given instance.

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

    Returns:
      A dict object that has the list of backup run resources if the command ran
      successfully.
    a<  table(
            name,
            backupInterval.startTime.iso():label=WINDOW_START_TIME,
            error.errors[0].code.yesno(no="-"):label=ERROR,
            state:label=STATE,
            instance,
            type,
            instanceDeletionTime.iso(undefined='-'):label=INSTANCE_DELETION_TIME
          )zclient_filter: %szserver_filter: %szprojects/{0})parentfilterpageSizeListBackupsbackups)limit
batch_sizebatch_size_attributemethodfieldprojectzsql.instances)params
collection)r$   instance)"r   	SqlClientAPI_VERSION_DEFAULT
sql_clientsql_messagesr'   
_GetParserair   r   r
   BackendRewriter   r   infor   YieldFromListr   SqlBackupsListBackupsRequestformatr   VALUEScorer$   	GetOrFailr   	page_sizer   ValidateInstanceNameresource_parserParse
backupRunsSqlBackupRunsListRequest)selfargsclientr*   r+   server_filterinstance_refs          r   RunzList.Run<   s     < <=F""J&&L== oo''11 3  $2#9#9#;#C#C
++$ dk= 
$dkk2	$m4%%




3
3#**##((00::< #	 4  

^^)  !!$--0))//:,,1199CCD" 0 $L
 ##-- ((<3H3H 	. 	JK Kr   N)__name__
__module____qualname____doc__staticmethodr   rB    r   r   r   r   $   s!     . .>Kr   r   N)rF   
__future__r   r   r   apitools.base.pyr   googlecloudsdk.api_lib.sqlr   r   googlecloudsdk.callioper	   googlecloudsdk.command_lib.sqlr
   r   googlecloudsdk.corer   r   DefaultUniverseOnlyReleaseTracksReleaseTrackGABETAALPHAListCommandr   rH   r   r   <module>rV      s    '  ' ' / / ( 9 0 # * D%%(($*;*;*@*@%%++-SK4 SK- SKr   