Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

We will use the pubsub Golang library - https://pkg.go.dev/cloud.google.com/go/pubsub Pub/Sub Golang library, which uses a persistent TCP connection under the covers.

A google_pubsub: a new table for adding PubSub Pub/Sub connection details and topics: google_pubsub

name - : string column PK

system_key - : string column

project_id - : string column

credentials - : string column (encrypted. Will contain the credentials JSON file)

topics - : jsonb column (array of PubSub Pub/Sub topics)

There will be endpoints for CRUD . (Details details will be added later).

The topics entered during PubSub Pub/Sub connection creation will be added as subscribers to the topic tree. The PubSub Pub/Sub connection will implement the client interface in core_messaging/broker/client_manager.go. We will use the Publish func function to forward messages to Google.

Endpoints:

/admin/{systemKey}/{name}/google-integrations/pub-sub

GET, POST, PUT, and DELETE support

POST:

Body required. Body The body can have iotcore IoT Core and non iotcore -IoT Core topics. For iotcore IoT Core topics, type and target is are required. type can be 1 for events and 2 for state:

Code Block
{
    "credentials_map": { // this is the service account json object
        "type": "service_account",
        "project_id": "myprojectid",
        "private_key_id": "blahblahblah",
        "private_key": "<priv_key>",
        "client_email": "a@a.com",
        "client_id": "9126871624161341",
        "auth_uri": "https://accounts.google.com/o/oauth2/auth",
        "token_uri": "https://oauth2.googleapis.com/token",
        "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
        "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/dahjkdhajkd%40dajsdgajdadsad.iam.gserviceaccount.com"
    },
    "project_id": "myprojectid",
    "topics": [
        {"path": "iotdemo"}, // Non iot core topic
        {"path": "/devices/+/events", "type": 1, "target": "performance-testing"}, // iot core topic
        {"path": "/devices/+/events/sub", "type": 1, "target": "performance-testing-sub", "sub_folder": "sub"}, // iot core topic
        {"path": "/devices/+/state", "type": 2, "target": "performance-testing-state"} // iot core topic
    ]
}

path is the topic that the pubsub Pub/Sub client will subscribe to internally to the ClearBlade broker. type is the topic type. No type represents a non iotcore -IoT Core topic, 1 is for event, and 2 is for state. target is the topic that the pubsub Pub/Sub client will publish to in Google PubSubPub/Sub. And sub_folder is for the events event's topic if it has a subfolder.

...

No query support. Admin or Dev.

Returns the same object as the POST body.

/admin/{systemKey}/google-integrations/pub-sub

GET and DELETE support only. GET gets all pubsub Pub/Sub connections for that system, and DELETE , deletes all.