
                            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 jr\R(                  " \R*                  R,                  5       " S S\R.                  5      5       r\R(                  " \R*                  R2                  \R*                  R4                  5       " S S\5      5       rg)z%Cloud Pub/Sub topics publish command.    )absolute_import)division)unicode_literals)topics)base)flags)resource_args)util)
properties)resource_projector)http_encodingc                    [         R                  " 5       n[        R                  " U R                  UR
                  S9n[        U SS5      nU R                  R                  R                  5       nUR                  U[        R                  " U5      XE5      nU(       a!  [        R                  " U5      nUS   S   US'   U$ )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$4&   008F!,/2F<	-    c                   8    \ rS rSrSrSSS.r\S 5       rS rSr	g	)
r   2   +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                 ^    [         R                  " US5        [        R                  " U5        g )Nto publish messages to.r	   AddTopicResourceArgr   AddPublishMessageFlagsclsparsers     r#   ArgsPublish.ArgsG   s!    %%f.GH	  (r%   c                 ,    [        XR                  5      $ )N)r$   message)selfr   s     r#   RunPublish.RunL   s    ll##r%    N)
__name__
__module____qualname____firstlineno____doc__detailed_helpclassmethodr3   r8   __static_attributes__r:   r%   r#   r   r   2   s/    3%
-" ) )$r%   r   c                   .    \ rS rSrSr\S 5       rS rSrg)PublishBetaP   r(   c                 \    [         R                  " US5        [        R                  " USS9  g )Nr,   T)add_deprecatedr-   r0   s     r#   r3   PublishBeta.ArgsT   s#    %%f.GH	  =r%   c                     [         R                  " U5      n[        R                  R                  R
                  R                  5       n[        XUS9$ )N)r   )r   ParseMessageBodyr   VALUESpubsubr   GetBoolr$   )r7   r   r   r   s       r#   r8   PublishBeta.RunY   s?    ))$/L%%,,::BBDM-@@r%   r:   N)	r;   r<   r=   r>   r?   rA   r3   r8   rB   r:   r%   r#   rD   rD   P   s    3> >Ar%   rD   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ALPHArD   r:   r%   r#   <module>r\      s    , &  ' 0 ( 3 ; 2 * ; 2& D%%(()$dll $ *$: D%%**D,=,=,C,CDA' A EAr%   