
                            S r SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSK	J
r
  SSKJr  SS	KJr  \R                  \R                   " \R"                  R$                  5       " S
 S\R&                  5      5       5       rg)zList protection summary.    )rbc_filter_rewrite)resource_backup_config)common_args)base)
exceptions)flags)log)resource_projection_specc                   D    \ rS rSrSrSSSSSS.r\S	 5       rS
 rS r	Sr
g)List   zpShow backup configuration metadata associated with specified resources in a particular location for the project.z@list backup configurations for a specified project and location.z{description}a%            `--project`: Project for which backup configurations should be listed.

          `--location`: Location for which backup configurations should be listed.

          `--filter`: The filter expression to filter results.

          `--sort-by`: The field to sort results by.
          a            `target_resource_display_name`: Name of the resource for which protection summary is to be listed.

          `target_resource_type`: Type of resource for which protection summary is to be displayed.

          Allowed values:
              * CLOUD_SQL_INSTANCE
              * COMPUTE_ENGINE_VM

          `backup_configured`: Displays if the specified resource has backups configured.

          `vaulted`: Displays if configured backups are protected using a backup vault.

          `backup_configs_details.backup_config_source_display_name`: Name of the backup schedule applied to the resource.

          `backup_configs_details.type`: Backup schedule type applied to the resource.

          Allowed values:
              * CLOUD_SQL_INSTANCE_BACKUP_CONFIG
              * COMPUTE_ENGINE_RESOURCE_POLICY
              * BACKUPDR_BACKUP_PLAN
              * BACKUPDR_TEMPLATE
          a            * To list protection summary for a resource named `resource-1`:

              $ {command} --project=sample-project --location=us-central1 --filter="target_resource_display_name=resource-1"

          * To list protection summary for a resource named `resource-1` that has backup configured:

              $ {command} --project=sample-project --location=us-central1 --filter="target_resource_display_name=resource-1 AND backup_configured=true"

        You can sort the results using the `--sort-by` flag. The only supported field for sorting is `target_resource_display_name`.

        Example of sorting:

          $ {command} --project=sample-project --location=us-central1 --sort-by="target_resource_display_name"
        )BRIEFDESCRIPTIONzFLAGS/ARGUMENTSSUBARGUMENTSEXAMPLESc                 2    [         R                  " U S5        g )N?Location for which the resource backup config should be listed.)r   AddLocationResourceArg)parsers    4lib/surface/backup_dr/resource_backup_config/list.pyArgs	List.ArgsV   s    	  I    c                    [         R                  " UR                  5      nUc  g UR                  S5      nU(       a8  [	        US   [
        5      (       a   US   S;  a  [        R                  " SS5      eSUS'   SR                  U5      nU$ )N r   )target_resource_display_nametargetResourceDisplayNamesort_byzkInvalid sort_by argument. Only sort_by target_resource_display_name/targetResourceDisplayName is supported.r   )	r   ParseSortByArgr   split
isinstancestrr   InvalidArgumentExceptionjoin)selfargsorder_byorder_by_fieldss       r   _Validate_and_Parse_SortByList._Validate_and_Parse_SortBy]   s    ))$,,7HnnS)Oq)3//ALM //
  8OAxx(HOr   c                    UR                   c  [        R                  " SS5      e[        R                  " 5       nUR
                  R                   R                  5       nUR                  5       n[        R                  " UR                  UR                  S9n[        R                  " 5       R                  UR                  US9u  pg[         R"                  " SUR                  U5        SUl        UR$                  b  ['        SUR$                  5      Ul        UR(                  (       d  SUl        U R+                  U5      nUR-                  UR/                  5       UUR$                  UR0                  US	9$ )
zConstructs and sends request.Nlocationr   )symbolsaliases)defaultsz$original_filter=%r, server_filter=%ri  json)parentfilters	page_sizelimitr'   )r,   r   RequiredArgumentExceptionr   ResourceBackupConfigClientCONCEPTSParseGetDisplayInfor
   ProjectionSpec
transformsr.   r   ListFilterRewriteRewritefilterr	   infor3   minformatr)   r   RelativeNamer4   )	r%   r&   client
parent_refdisplay_infor/   _server_filterr'   s	            r   RunList.Runs   s>    }}00

K 
 $>>@F''--/J &&(L'66''1E1EH *;;=EEh F (AHH3[[-) DK~~!3/dn;;dk..t4H;;&&(..jj   r    N)__name__
__module____qualname____firstlineno____doc__detailed_helpstaticmethodr   r)   rH   __static_attributes__rJ   r   r   r   r      sI     y M *K4-l  ,'r   r   N)rO   googlecloudsdk.api_lib.backupdrr   r   googlecloudsdk.api_lib.utilr   googlecloudsdk.callioper   r   #googlecloudsdk.command_lib.backupdrr   googlecloudsdk.corer	   googlecloudsdk.core.resourcer
   DefaultUniverseOnlyReleaseTracksReleaseTrackALPHAListCommandr   rJ   r   r   <module>r^      sm     ? B 3 ( . 5 # A D%%++,|4 | - |r   