
    !                        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  SS
KJr  SSKJr  SSKJr  SSS.r " S S\R(                  5      r " S S\R(                  5      r\
R.                  " \
R0                  R2                  5      \
R4                   " S S\
R6                  5      5       5       rg)zCommand to create a trigger.    )absolute_import)division)unicode_literals)encoding)triggers)base)flags)types)labels_util)
exceptions)logz{description}aA           To create a new trigger ``my-trigger'' for events of type ``google.cloud.pubsub.topic.v1.messagePublished'' with destination Cloud Run service ``my-service'', run:

          $ {command} my-trigger --event-filters="type=google.cloud.pubsub.topic.v1.messagePublished" --destination-run-service=my-service
        )DESCRIPTIONEXAMPLESc                       \ rS rSrSrSrg)#NoDestinationLocationSpecifiedError(   zFError when no destination location was specified for a global trigger. N__name__
__module____qualname____firstlineno____doc____static_attributes__r       'lib/surface/eventarc/triggers/create.pyr   r   (   s    Nr   r   c                       \ rS rSrSrSrg)UnsupportedDestinationError,   z?Error when none of the supported destination args is specified.r   Nr   r   r   r   r   r   ,   s    Gr   r   c                   >    \ rS rSrSr\r\S 5       rS r	S r
S rSrg)	Create0   zCreate an Eventarc trigger.c                 *   [         R                  " XR                  5       5        [         R                  " XR                  5       SS9  [         R                  " XR                  5       5        [         R
                  " XR                  5       5        [         R                  " U5        [         R                  " XR                  5       SS9  [         R                  " U5        [        R                  " U5        [        R                  R                  U5        g )NT)required)r	   AddCreateTrigerResourceArgsReleaseTrackAddEventFiltersArgAddEventFiltersPathPatternArgAddEventDataContentTypeArgAddServiceAccountArgAddCreateDestinationArgsAddTransportTopicResourceArgr   AddCreateLabelsFlagsr   
ASYNC_FLAGAddToParser)clsparsers     r   ArgsCreate.Args7   s    	%%f.>.>.@A	V%5%5%7$G	''0@0@0BC	$$V-=-=-?@	v&	""6+;+;+=M	&&v.$$V,OO'r   c                 
   [         R                  " 5       nUR                  R                  R	                  5       n[
        R                  " XR                  5       5      nUR                  R                  R	                  5       n[
        R                  " XR                  5       5      n[
        R                  " XR                  5       5      n[
        R                  " XR                  5       5      nUR                  S5      (       d  UR                  S5      (       a  UR                  S5      (       a  SOSn	U R                  UUSSR                  U	5      5      n
SU;   a  UR                   OSnUR#                  UR$                  UUR&                  U
5      nSR                  XR$                  =(       d    U5      nS	nGOUR                  S
5      (       a  U R                  XSS5      nUR(                  =(       d    SnUR+                  UR,                  UUUR.                  UR0                  5      nSR                  UR.                  UR,                  5      nSnGOUR                  S5      (       aE  UR3                  UR4                  UR6                  5      nSR                  UR4                  5      nSnGO'UR                  S5      (       ax  U R                  XSS5      nUR9                  UR;                  5       R;                  5       R=                  5       UR>                  U5      nSR                  UR>                  5      nS	nOUR                  S5      (       ax  U R                  XSS5      nURA                  UR;                  5       R;                  5       R=                  5       URB                  U5      nSR                  URB                  5      nS	nO[E        S5      eURG                  UUUUURH                  UUU[J        RL                  " XRO                  5       5      5	      nURQ                  UU5      nUS   U l)        URT                  (       a  U$ URW                  USX>5      n[X        RZ                  " U5      n[\        R^                  " U RR                  5      (       a  US   S   S   nUR                  S 5      (       a1  [`        Rb                  Re                  S!R                  UU5      5        U$ [`        Rb                  Re                  S"R                  U5      5        [`        Rb                  Re                  S#R                  U5      5        U$ )$zRun the create command.destination_run_servicedestination_run_jobservicejobdestination_run_regionzCloud Run {}NzCloud Run {} [{}] destination_gke_servicedestination_gke_locationzGKE servicedefaultz GKE service [{}] in cluster [{}]z'this operation may take several minutesdestination_http_endpoint_urizHTTP endpoint [{}]destination_workflowdestination_workflow_locationWorkflowzWorkflow [{}]destination_functiondestination_function_locationFunctionzCloud Function [{}]z!Must specify a valid destination.typeCreating	transportpubsubtopictransport_topicz6Publish to Pub/Sub topic [{}] to receive events in {}.zCreated Pub/Sub topic [{}].z.Publish to this topic to receive events in {}.)3r   TriggersClientV1CONCEPTStriggerParser	   GetChannelArgr&   rJ   GetEventFiltersArgGetEventFiltersPathPatternArgGetEventDataContentTypeArgIsSpecifiedIsKnownAndSpecifiedGetDestinationLocationformatr6   BuildCloudRunDestinationMessager5   destination_run_pathdestination_gke_namespaceBuildGKEDestinationMessagedestination_gke_clusterr;   destination_gke_path#BuildHTTPEndpointDestinationMessager>   network_attachmentBuildWorkflowDestinationMessageParentNamer?   BuildFunctionDestinationMessagerB   r   BuildTriggerMessageservice_accountr   ParseCreateArgsLabelsValueClassr!   _event_typeasync_WaitForr   MessageToPyValuer
   IsPubsubTyper   statusPrint)selfargsclienttrigger_refchannel_reftransport_topic_refevent_filtersevent_filters_path_patternevent_data_content_typeresource_typer9   run_jobdestination_messagedest_strloading_msgr<   rY   r@   rC   trigger_message	operationresponsetrigger_dictrI   s                           r   Run
Create.RunD   s   &&(F--''--/K%%d,=,=,?@K--77==?,,T3D3D3FGM!&!D!D!" $>>!
 122d6N6N7 7 ''(ABB)   $::


"



.	  '<t&C$
"
"  #BB

&
&


#
#
 	 %++
55@h k			3	4	4!%!<!<
7" #'"@"@"MI"==

&
&
"
#

&
&

#
# 4::

&
&(D(Dh >k			9	:	:"FF

,
,

!
! &,,T-O-OPh=k			0	1	1&*&A&A
<j'# #BB




%
%
'
,
,
.

#
#
'
 !''(A(ABhk			0	1	1&*&A&A
<j'# #BB




%
%
'
,
,
.

#
#
'
 '--d.G.GHhk'(KLL00"##D*A*A*CD
O k?;I$V,D{{~~i[NH,,X6L$**++;'1':e			+	,	,

DKKx	
 O	 	

6==eDE

<CCHM	
 Or   c                 z    U(       a4  [         R                  " SR                  [        R                  5      5        g g )NzBIt may take up to {} minutes for the new trigger to become active.)r   warningrV   r   MAX_ACTIVE_DELAY_MINUTES)rn   resources_were_displayeds     r   EpilogCreate.Epilog   s)    	kk
N6(334  r   c                     UR                  U5      (       dQ  UR                  5       R                  5       nUS:X  a*  [        SR	                  UR                  U5      U5      5      e U$ UR                  U5      nU$ )NglobalzOThe `{}` flag is required when creating a global trigger with a destination {}.)rS   r`   ra   r   rV   GetFlagGetValue)rn   ro   rq   location_arg_namedestination_typedestination_locations         r   rU   Create.GetDestinationLocation   s     -..(//1668		)1$f./1A
 	
 
*   "]]+<=r   )rg   N)r   r   r   r   r   _DETAILED_HELPdetailed_helpclassmethodr2   r   r   rU   r   r   r   r   r!   r!   0   s/     $ -
( 
(@D r   r!   N)r   
__future__r   r   r   apitools.base.pyr   googlecloudsdk.api_lib.eventarcr   googlecloudsdk.callioper   #googlecloudsdk.command_lib.eventarcr	   r
   $googlecloudsdk.command_lib.util.argsr   googlecloudsdk.corer   r   r   Errorr   r   ReleaseTracksr&   GADefaultUniverseOnlyCreateCommandr!   r   r   r   <module>r      s    # &  ' % 4 ( 5 5 < * # #O**:*: OH*"2"2 H D%%(()k T k   *k r   