Example: Integration
11 min
end to end walkthrough configure a cloud connector instance, add topics that map device tags to remote names, enable streaming setup from litmussdk integrations common import integrations, topics 1\ list available providers providers = integrations cloud providers() rest provider = next(p for p in providers if p\["name"] == "rest") provider id = rest provider\["id"] \# what does this provider need for instance config? schema = integrations cloud config schema(provider id) \# what does each topic need? tag schema = integrations cloud config tag schema(provider id) 2\ create an instance instance = integrations cloud connector create( provider id=provider id, provider config={ "name" "plant floor rest", "url" "https //my cloud example com/ingest", "auth" {"type" "bearer", "token" " "}, }, ) instance id = instance\["instanceid"] 3\ add topics (outbound) each topic maps a local litmus tag/topic to a remote name in the cloud system topic a = topics create topic( integration instance id=instance id, is local to remote=true, # outbound local name="plant/pump/01/pressure", remote name="pump pressure", enabled=true, description="pump pressure", config={}, ) topic b = topics create topic( integration instance id=instance id, is local to remote=true, local name="plant/pump/01/flow rate", remote name="pump flow", enabled=true, description="pump flow rate", config={}, ) 4\ enable the instance integrations cloud connector enable disable(instance id, enable=true) topics defined with enabled=true start streaming immediately 5\ toggle topics in bulk all topics = topics list topics(instance id) all topic ids = \[t\["topicid"] for t in all topics] \# disable all temporarily (e g during a maintenance window) topics enable disable multiple topics(instance id, all topic ids, enable=false) \# re enable topics enable disable multiple topics(instance id, all topic ids, enable=true) 6\ import topics from devicehub bulk import all tags on a device into this instance as topics topics import from dh( integration instance id=instance id, device id=device id, wildcard=false, # or true to also include sub topics ) 7\ csv export / import csv text = topics download csv(instance id) with open("topics csv", "w") as f f write(csv text) \# apply on another edge topics upload csv(instance id, file path="topics csv") 8\ graphql subscription api (4 0 x only) the same flow is also available via graphql with finer control this is the recommended path on 4 0 x from litmussdk integrations common import gql streaming \# bulk import from multiple sources gql streaming import topics( instance id=instance id, device hub=\[{"deviceid" device id, "tagids" \[tag id]}], digital twins=\[{"instanceid" dt id}], analytics=\[{"processorid" proc id}], ) 9\ cleanup topics delete multiple topics(instance id, all topic ids) integrations cloud connector instance delete(instance id) see also managing connections docid\ vwtfo9sxcmrbfx9cafenw le vs lem