GooglePubsubPlugin(credentials_file: str = '/home/blacklight/.credentials/platypush/google/pubsub.json', **kwargs)¶
Send messages over a Google pub/sub instance. You’ll need a Google Cloud active project and a set of credentials to use this plugin:
Create a project on the Google Cloud console if you don’t have one already.
In the Google Cloud API console create a new service account key. Select “New Service Account”, choose the role “Pub/Sub Editor” and leave the key type as JSON.
Download the JSON service credentials file. By default platypush will look for the credentials file under ~/.credentials/platypush/google/pubsub.json.
pip install google-cloud-pubsub)
__init__(credentials_file: str = '/home/blacklight/.credentials/platypush/google/pubsub.json', **kwargs)¶
credentials_file – Path to the JSON credentials file for Google pub/sub (default: ~/.credentials/platypush/google/pubsub.json)
send_message(topic: str, msg, **kwargs)¶
Sends a message to a topic
topic – Topic/channel where the message will be delivered. You can either specify the full topic name in the format
<project_id>must be the ID of your Google Pub/Sub project, or just
<topic_name>- in such case it’s implied that you refer to the
project_idof your service credentials.
msg – Message to be sent. It can be a list, a dict, or a Message object
kwargs – Extra arguments to be passed to .publish()