Skip to main content

Enos subscribe client for python

Project description

Using EnOS Data Subscription SDK for Python

Table of Contents

EnOS Data Subscription Service improves the API calling efficiency of applications with active data push, which supports subscription to real-time asset data, offline asset data, asset alert data, and asset event data.

After configuring and starting data subscription jobs on the EnOS Management Console, you can use the Data Subscription SDK for Python to develop applications for consuming the subscribed data.

Installation

Prerequisites

The Data Subscription SDK for Python supports Python 2.7, Python 3.4, and newer versions.

You can install the SDK from pip, or build from source.

Installing from pip

The latest version of EnOS Data Subscription SDK for Python is available in the Python Package Index (PyPi) and can be installed using:

pip install enos-subscribe

Building From Source

  1. Obtain the source code of Data Subscription SDK for Python.

    • From GitHub:
    git clone https://github.com/EnvisionIot/enos-subscription-service-sdk-python.git
    
    • From EnOS SDK Center. Click SDK Center from the left navigation of EnOS Console, and obtain the SDK source code by clicking the GitHub icon in the Obtain column.
  2. From the directory where the source code is stored, run the following command:

    python setup.py install
    

The EnOS Data Subscription SDK for Python has the following dependency modules:

  • six
  • google.protobuf
  • websocket_client

Feature List

EnOS Enterprise Data Platform supports subscribing to asset time series data and alert data and pushing the subscribed data to applications, thus improving the data query efficiency of applications.

The features supported by this SDK include:

  • Consuming subscribed real-time asset data
  • Consuming subscribed alert data
  • Consuming subscribed offline asset data
  • Consuming subscribed event data

Sample Codes

Code Sample for Consuming Subscribed Real-time Data

from enos_subscribe import DataClient

if __name__ == '__main__':
    client = DataClient(host='sub-host', port='sub-port',
                        access_key='Your Access Key of this subscription',
                        access_secret='Your Access Secret of this subscription')

    client.subscribe(sub_id='Your subscription Id')

    for message in client:
        print(message)

Code Sample for Consuming Subscribed Alert Data

from enos_subscribe import AlertClient

if __name__ == '__main__':
    client = AlertClient(host='sub-host', port='sub-port',
                        access_key='Your Access Key of this subscription',
                        access_secret='Your Access Secret of this subscription')

    client.subscribe(sub_id='Your subscription Id')

    for message in client:
        print(message)

Code Sample for Consuming Subscribed Advanced Alert Data

from enos_subscribe import AdvancedAlertClient

if __name__ == '__main__':
    client = AdvancedAlertClient(host='sub-host', port='sub-port',
                        access_key='Your Access Key of this subscription',
                        access_secret='Your Access Secret of this subscription')

    client.subscribe(sub_id='Your subscription Id')

    for message in client:
        print(message)

Code Sample for Consuming Subscribed Offline Data

from enos_subscribe import OfflineClient

if __name__ == '__main__':
    client = OfflineClient(host='sub-host', port='sub-port',
                        access_key='Your Access Key of this subscription',
                        access_secret='Your Access Secret of this subscription')

    client.subscribe(sub_id='Your subscription Id')

    for message in client:
        print(message)

Code Sample for Consuming Subscribed Event Data

from enos_subscribe import EventClient

if __name__ == '__main__':
    client = EventClient(host='sub-host', port='sub-port',
                        access_key='Your Access Key of this subscription',
                        access_secret='Your Access Secret of this subscription')

    client.subscribe(sub_id='Your subscription Id')

    for message in client:
        print(message)

Related Information

To learn more about the Data Subscription feature of EnOS Enterprise Data Platform, see Data Subscription Overview.

Release Notes

  • 2020/03/03 (2.4.1): Initial release
  • 2020/04/08 (2.5.0): Added the feature of event data subscription
  • 2020/11/24 (2.6.0): Added the feature of advanced alert subscription

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

enos_subscribe-2.6.0.tar.gz (21.6 kB view hashes)

Uploaded Source

Built Distribution

enos_subscribe-2.6.0-py3-none-any.whl (23.1 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page