
    
                        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)channel_connections)common_publishing)base)flags)logz{description}aD           To publish an event to your channel connection `my-channel-connection`
        with event id `1234`
        with event type `event-provider.event.v1.eventType`
        with event source `//event-provider/projects/project-id/resource-id`
        with event data `{ "key": "value" }`
        and  event attributes of `attribute1=value`, run:

          $ {command} my-channel-connection --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 connection.c                 Z    t        j                  |d       t        j                  |       y )Nz!Channel connection to publish to.)r	   AddChannelConnectionResourceArgAddEventPublishingArgs)clsparsers     3lib/surface/eventarc/channel_connections/publish.pyArgszPublish.Args2   s$    	))&*MO	  (    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.z6Publishing event with id: {} to channel connection: {}zEvent published successfully)r   ChannelConnectionClientV1CONCEPTSchannel_connectionParseNamer
   debugformatevent_idr   r   CreateCloudEvent
event_typeevent_source
event_dataevent_attributesoutPrint)selfargsclientchannel_connection_refnames        r   RunzPublish.Run8   s     !::<F!]]==CCE!&&(DIIFMM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#     3 -) )
9r   r   N)r0   
__future__r   r   r   googlecloudsdk.api_lib.eventarcr   r   googlecloudsdk.callioper   #googlecloudsdk.command_lib.eventarcr	   googlecloudsdk.corer
   r1   HiddenReleaseTracksReleaseTrackGACommandr   r4   r   r   <module>r?      sw    # &  ' ? = ( 5 # 				" D%%(()9dll 9 * 9r   