
                            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
lmZ ddlmZ ddlmZ ddZ ej(                  ej*                  j,                         G d dej.                               Z ej(                  ej*                  j2                  ej*                  j4                         G d de             Zy)z%Cloud Pub/Sub topics publish command.    )absolute_import)division)unicode_literals)topics)base)flags)resource_args)util)
properties)resource_projector)http_encodingc                 x   t        j                         }t        j                  | j                  |j
                        }t        | dd      }| j                  j                  j                         }|j                  |t        j                  |      ||      }|r t        j                  |      }|d   d   |d<   |S )zPublishes a message to a topic.)messagesordering_keyN
messageIdsr   )r   TopicsClientr
   ParseAttributes	attributer   getattrCONCEPTStopicParsePublishr   Encoder   MakeSerializable)argsmessage_bodylegacy_outputclient
attributesr   	topic_refresults           $lib/surface/pubsub/topics/publish.py_Runr$      s     &##DNNV__M*~t4,mm!!''))>>)]%9%9,%G$l4&   008F!,/2F<	-    c                   0    e Zd ZdZdddZed        Zd Zy)r   +Publishes a message to the specified topic.aJ            Publishes a message to the specified topic name for testing and
          troubleshooting. Use with caution: all associated subscribers must
          be able to consume and acknowledge any message you publish,
          otherwise the system will continuously re-attempt delivery of the
          bad message for 7 days.z          To publish messages in a batch to a specific Cloud Pub/Sub topic,
          run:

            $ {command} mytopic --message="Hello World!" --attribute=KEY1=VAL1,KEY2=VAL2
      )DESCRIPTIONEXAMPLESc                 Z    t        j                  |d       t        j                  |       y )Nto publish messages to.r	   AddTopicResourceArgr   AddPublishMessageFlagsclsparsers     r#   ArgszPublish.ArgsG   s!    %%f.GH	  (r%   c                 .    t        ||j                        S )N)r$   message)selfr   s     r#   RunzPublish.RunL   s    dll##r%   N)__name__
__module____qualname____doc__detailed_helpclassmethodr2   r6    r%   r#   r   r   2   s/    3%
-" ) )$r%   r   c                   &    e Zd ZdZed        Zd Zy)PublishBetar'   c                 ^    t        j                  |d       t        j                  |d       y )Nr+   T)add_deprecatedr,   r/   s     r#   r2   zPublishBeta.ArgsT   s#    %%f.GH	  =r%   c                     t        j                  |      }t        j                  j                  j
                  j                         }t        |||      S )N)r   )r   ParseMessageBodyr   VALUESpubsubr   GetBoolr$   )r5   r   r   r   s       r#   r6   zPublishBeta.RunY   sA    ))$/L%%,,::BBDMl-@@r%   N)r7   r8   r9   r:   r<   r2   r6   r=   r%   r#   r?   r?   P   s    3> >Ar%   r?   N)F)r:   
__future__r   r   r   googlecloudsdk.api_lib.pubsubr   googlecloudsdk.callioper   !googlecloudsdk.command_lib.pubsubr   r	   r
   googlecloudsdk.corer   googlecloudsdk.core.resourcer   googlecloudsdk.core.utilr   r$   ReleaseTracksReleaseTrackGACommandr   BETAALPHAr?   r=   r%   r#   <module>rT      s    , &  ' 0 ( 3 ; 2 * ; 2& D%%(()$dll $ *$: D%%**D,=,=,C,CDA' A EAr%   