
                            S r SSKJr  SSKJr  SSKJr  SSKrSSKJr  SSKJ	r	  SSK
Jr  SS	K
Jr  S
SS.rSrSrS rS r\	R$                  " \	R&                  R(                  5      \	R*                   " S S\	R,                  5      5       5       rg)z7Command to list all triggers in a project and location.    )absolute_import)division)unicode_literalsN)triggers)base)flags)typesz{description}z         To list all triggers in location ``us-central1'', run:

          $ {command} --location=us-central1

        To list all triggers in all locations, run:

          $ {command} --location=-

        or

          $ {command}
        )DESCRIPTIONEXAMPLESz table(
    name.scope("triggers"):label=NAME,
    eventFilters.type():label=TYPE,
    destination():label=DESTINATION,
    active_status():label=ACTIVE,
    name.scope("locations").segment(0):label=LOCATION
)
a   table(
    name.scope("triggers"):label=NAME,
    matchingCriteria.type():label=TYPE,
    destination.cloudRunService.service:label=DESTINATION_RUN_SERVICE,
    destination.cloudRunService.path:label=DESTINATION_RUN_PATH,
    active_status():label=ACTIVE
)
c                     U R                  SU R                  S5      5      n[        R                  " U5      n[        R                  " X S   5      nU(       a  SR                  U5      $ S$ )NeventFiltersmatchingCriteria
updateTimezBy {}Yes)getr	   EventFiltersDictToTyper   TriggerActiveTimeformat)triggerevent_filters
event_typeactive_times       %lib/surface/eventarc/triggers/list.py_ActiveStatusr   D   sW    ++ngkk:L.MN-++M:***:|7LM+(3	$>>    c                 .   U R                  S5      nUc  gSU;   a\  UR                  S5      nUR                  S5      nU(       a  SR                  U5      $ UR                  S5      nSR                  U5      $ SU;   a1  UR                  S5      nS	R                  UR                  S5      5      $ S
U;   aR  SnUR                  S
5      n[        R                  " XR5      nU(       a   SR                  UR	                  S5      5      $ S$ SU;   aR  SnUR                  S5      n[        R                  " Xr5      nU(       a   SR                  UR	                  S5      5      $ S$ SU;   a1  UR                  S5      nSR                  UR                  S5      5      $ g)ak  Generate a destination string for the trigger.

Based on different destination types, this function returns a destination
string accordingly:

  * Cloud Run trigger: "Cloud Run: {cloud run service or job}"
  * GKE trigger: "GKE: {gke service}"
  * Workflows trigger: "Workflows: {workflow name}"
  * Cloud Functions trigger: "Cloud Functions: {cloud function name}"

For unknown destination (e.g. new types of destination and corrupted
destination), this function returns an empty string.

Args:
  trigger: eventarc trigger proto in python map format.

Returns:
  A string representing the destination for the trigger.
destination cloudRunjobzCloud Run job: {}servicezCloud Run service: {}gkezGKE: {}cloudFunctionz)^projects/.*/locations/.*/functions/(.*)$zCloud Functions: {}   workflowz)^projects/.*/locations/.*/workflows/(.*)$zWorkflows: {}httpEndpointzHTTP endpoint: {}uri)r   r   researchgroup)r   r   destr    r!   cloud_function_str_patternmatchworkflows_str_patterns           r   _Destinationr/   K   sl   ( M*+;??:&D
((5/C
 '',,hhy!G"))'22??5!DDHHY/00+%!L???+DII07E;@ ''A7HbH[ G??:&DII+2E5:?!!%++a.1CC$??>*D%%dhhuo66 r   c                   2    \ rS rSrSr\r\S 5       rS r	Sr
g)List   zList Eventarc triggers.c                 X   [         R                  " U SSSS9  [         R                  " U 5        U R                  R	                  [
        5        U R                  R                  [        R                  5        U R                  R                  [        [        [        R                  S.5        g )NzjThe location for which to list triggers. This should be either ``global'' or one of the supported regions.FT)requiredallow_aggregation)active_statusr   type)r   AddLocationResourceArgAddProjectResourceArgdisplay_info	AddFormat_FORMAT
AddUriFuncr   GetTriggerURIAddTransformsr   r/   r	   r   )parsers    r   Args	List.Args   s    	  	6 
'
!!'*
""8#9#9:
%%&#,,' r   c                    [         R                  " 5       nUR                  R                  R	                  5         UR                  R
                  R	                  5       nUR                  X1R                  UR                  5      $ )zRun the list command.)	r   TriggersClientV1CONCEPTSprojectParselocationr1   limit	page_size)selfargsclientlocation_refs       r   RunList.Run   sW    &&(FMM!==))//1L;;|ZZ@@r    N)__name__
__module____qualname____firstlineno____doc___DETAILED_HELPdetailed_helpstaticmethodrA   rO   __static_attributes__rQ   r   r   r1   r1      s$       - "Ar   r1   )rV   
__future__r   r   r   r(   googlecloudsdk.api_lib.eventarcr   googlecloudsdk.callioper   #googlecloudsdk.command_lib.eventarcr   r	   rW   r<   _FORMAT_BETAr   r/   ReleaseTracksReleaseTrackGADefaultUniverseOnlyListCommandr1   rQ   r   r   <module>re      s    > &  ' 	 4 ( 5 5 			&?2j D%%(()A4 A  *Ar   