Skip to main content

Python SDK

Project description

Python SDK

Python SDK, a python driver for Mainflux HTTP API.

Does both system administration (provisioning) and messaging.

Installation Import "github.com/mainflux/sdk-py" in your Python package.

Then call SDK Pythong functions to interact with the system.

API Reference

FUNCTIONS

class SDK:
    def __init__(
        self,
        users_url=default_url,
        things_url=default_url,
        messages_url=default_url,
        groups_url=default_url
    ):
        self.users = users.Users(users_url)
        self.things = things.Things(things_url)
        self.messages = messages.Messages(messages_url)
        self.channels = channels.Channels(things_url)
        self.groups = groups.Groups(groups_url)
        self.version_url = things_url

    def version(self):
        Version - server health check
        
class Users:
    def __init__(self, url):
        self.url = url

    def create(self, user):
        CreateUser - create user

    def login(self, user):
        CreateToken - create user token
    
    def get(self, user_id, token):
        User - gets user

    def get_all(self, token):
        Users - gets all users
    
    def update(self, user, token):
        UpdateUser - update user

    def update_password(self, old_password, password, token):
        UpdatePassword - update user password

class Things:
    def __init__(self, url):
        self.url = url

    def create(self, thing, token):
        CreateThing - creates new thing and generates thing UUID

    def construct_query(self, params):
        ConstructQuery - allows you to set query params: offset, limit, order, direction

    def create_bulk(self, things, token):
        CreateThings - creates bulk of things and generates things UUID

    def get(self, thing_id, token):
        Thing - gets thing
    
    def get_all(self, token, query_params=None):
        Things - gets all things

    def get_by_channel(self, channel_id, params, token):
        GetByChannel - Gets all things to which a specific thing is connected to

    def update(self, thing_id, token, thing):
        UpdateThing - updates thing by ID

    def delete(self, thing_id, token):
        DeleteThing - removes thing

    def connect(self, channel_ids, thing_ids, token):
        Connect - connect things to channels

    def disconnect(self, channel_ids, thing_ids, token):
        DisconnectThing - disconnect thing and channel

class Channels:
    def __init__(self, url):
        self.url = url

    def create(self, channel, token):
        CreateChannel - creates new channel and generates UUID
    
    def construct_query(self, params):
        ConstructQuery - allows you to set query params: offset, limit, order, direction

    def create_bulk(self, channels, token):
        CreateChannels - creates bulk of channels and generates channels UUID

    def get(self, channel_id, token):
        Channel - gets channel by ID

    def get_all(self, token, query_params=None):
        Channels - gets all channels

    def get_by_thing(self, thing_id, params, token):
        GetByThing - Gets all channels to which a specific channel is connected to

    def update(self, channel_id, token, channel):
        UpdateChannel - update a channel

    def delete(self, chanID, token):
        DeleteChannel - removes channel

class Messages:
    def __init__(self, url):
        self.url = url

    def send(self, channel_id, msg, token):
        Send - Sends message via HTTP protocol

    def read(self, channel_id, token):
        Read - Reads messages from database for a given channel

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

Mainflux-0.0.1.tar.gz (8.7 kB view details)

Uploaded Source

Built Distribution

Mainflux-0.0.1-py3-none-any.whl (13.9 kB view details)

Uploaded Python 3

File details

Details for the file Mainflux-0.0.1.tar.gz.

File metadata

  • Download URL: Mainflux-0.0.1.tar.gz
  • Upload date:
  • Size: 8.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.10

File hashes

Hashes for Mainflux-0.0.1.tar.gz
Algorithm Hash digest
SHA256 34e88ecadec18def8b9299108f0e20a978dd94498439d8e678fdd4150ca9c3c8
MD5 4d64339aa9b222f622ff8e86a09a4936
BLAKE2b-256 ea2f1795504ab93e05f5213f242360e06b87a397b2e41a03f9ad4d5faf387c3c

See more details on using hashes here.

File details

Details for the file Mainflux-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: Mainflux-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 13.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.10

File hashes

Hashes for Mainflux-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4f08bf121cd9561a8e76a7b857894b6d260f69c21f0e9bfa4704d66209ec8ee6
MD5 b4a6759ae396da82c0d0e5348d61e0ea
BLAKE2b-256 374772376637a7c029291de629ea4f271f94f0275b40234eb1ebb5f71befd71a

See more details on using hashes here.

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