
    &                         d Z ddlmZ ddlmZ ddlmZ ej                   ej                  ej                  j                         G d dej                                      Zy)zSurface for listing alerts.    )alerts)base)resource_argsc                   B     e Zd ZdZdZddddZe fd       Zd Z xZ	S )	ListzList alerts.Fz          This command uses the monitoring/v3 API. The full documentation for this
          API can be found at: https://cloud.google.com/monitoring/api/zList alerts for a project.a        To list all open alerts:

        $ {command} --filter="state='OPEN'"

      To order alerts by when the alert was opened:

        $ {command} --sort-by=openTime

      To order alerts by when the alert was opened in reverse order:

        $ {command} --sort-by="~openTime"

      To list alerts for a specific policy:

        $ {command} --filter="policy.displayName='My Policy'"

      More information can be found at
      https://cloud.google.com/sdk/gcloud/reference/topic/filters)zAPI REFERENCEDESCRIPTIONEXAMPLESc                 2   t        j                  | dd       t        t        t          |        t
        j                  j                  | d       | j                  j                  d       | j                  j                  t        j                                y)z Register flags for this command.zlist alerts fromTi  yamlN)r   AddProjectResourceArgsuperr   Argsr   PAGE_SIZE_FLAG
SetDefaultdisplay_info	AddFormat
AddUriFuncGetAlertResourceUriFunc)parser	__class__s    %lib/surface/monitoring/alerts/list.pyr   z	List.Args7   sp     ''0BDI 
$6"""640
!!&)
""=#H#H#JK    c                 .   |j                   j                  j                         }t        j                         }|j
                  rdj                  |j
                        nd}|j                  ||j                  ||j                        }|j                  S )zThis is what gets called when the user runs this command.

    Args:
      args: an argparse namespace. All the arguments that were provided to this
        command invocation.

    Returns:
      The list of alerts.
    ,N)a_filterorder_by	page_size)
CONCEPTSprojectParser   AlertsClientsort_byjoinr   filterr   )selfargsproject_refclientorder_by_stringresponses         r   RunzList.RunC   sy     --''--/K  "F04chht||,$O {{ ..	  H ??r   )
__name__
__module____qualname____doc__CLIENT_SIDE_FILTERSdetailed_helpstaticmethodr   r+   __classcell__)r   s   @r   r   r      sA     K 2E-4 	L 	Lr   r   N)r/   !googlecloudsdk.api_lib.monitoringr   googlecloudsdk.callioper   %googlecloudsdk.command_lib.monitoringr   UniverseCompatibleReleaseTracksReleaseTrackALPHAListCommandr    r   r   <module>r=      s^    " 4 ( ? D%%++,A4 A - Ar   