
    
                        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dZe	j                   e	j                   e	j"                  j$                         G d de	j&                                      Zy)zCommand to publish channels.    )absolute_import)division)unicode_literals)channels)common_publishing)base)flags)logz{description}a           To publish an event to the channel `my-channel`
        with event id `1234`
        with event type `event-provider.event.v1.eventType`
        with event source `//event-provider/event/source`
        with event data `{ "key": "value" }`
        and  event attributes of `attribute1=value`, run:

          $ {command} my-channel --event-id=1234 --event-type=event-provider.event.v1.eventType --event-source="//event-provider/event/source" --event-data='{"key": "value"}' --event-attributes=attribute1=value
        )DESCRIPTIONEXAMPLESc                   *    e Zd ZdZeZed        Zd Zy)PublishzPublish to an Eventarc channel.c                 ^    t        j                  |dd       t        j                  |       y )NzChannel to Publish to.T)required)r	   AddChannelResourceArgAddEventPublishingArgs)clsparsers     (lib/surface/eventarc/channels/publish.pyArgszPublish.Args2   s#    	(@4P	  (    c           
         t        j                         }|j                  j                  j	                         }|j                         }t        j                  dj                  |j                  |             |j                  |t        j                  |j                  |j                  |j                  |j                  |j                                t        j"                  j%                  d      S )zRun the Publish command.z+Publishing event with id: {} to channel: {}zEvent published successfully)r   ChannelClientV1CONCEPTSchannelParseNamer
   debugformatevent_idr   r   CreateCloudEvent
event_typeevent_source
event_dataevent_attributesoutPrint)selfargsclientchannel_refnames        r   RunzPublish.Run7   s     %%'F--''--/KDII;BBt  NN**4==$//+/+<+<doo+/+@+@	BC 77==788r   N)	__name__
__module____qualname____doc___DETAILED_HELPdetailed_helpclassmethodr   r-    r   r   r   r   ,   s#     ( -) )9r   r   N)r1   
__future__r   r   r   googlecloudsdk.api_lib.eventarcr   r   googlecloudsdk.callioper   #googlecloudsdk.command_lib.eventarcr	   googlecloudsdk.corer
   r2   HiddenReleaseTracksReleaseTrackGACommandr   r5   r   r   <module>r@      sw    # &  ' 4 = ( 5 # 				" D%%(()9dll 9 * 9r   