'Publishes messages to a Pub/Sub topic.
:param project: the GCP project name or ID in which to publish
:type project: string
:param topic: the Pub/Sub topic to which to publish; do not
include the \'projects/{project}/topics/\' prefix.
:type topic: string
:param messages: messages to publish; if the data field in a
message is set, it should already be base64 encoded.
:type messages: list of PubSub messages; see
http://cloud.google.com/pubsub/docs/reference/rest/v1/PubsubMessage'

def publish(self, project, topic, messages):

    body = {'messages': messages}
    full_topic = _format_topic(project, topic)
    request = self.get_conn().projects().topics().publish(topic=full_topic, body=body)
    try:
        request.execute()
    except errors.HttpError as e:
        raise Exception(('Error    publishing    to    topic    %s' % full_topic), e)
