Code Monkey home page Code Monkey logo

orion-python-client's Introduction

orion-python-client

A python module and examples for using Orion Context Broker

The Orion Context Broker is a powerful means for collecting data IoT data in the cloud, and relaying it on. It combines a ReST front end to MongoDB, exposing nice Mongo features like geographical search; and a publish-subscribe mechanism. Documents can be created and updated with simple ReST calls. Another ReSt call can set up notifications, so that an app can be POSTed to when something changes.

The Orion documentation is at http://fiware-orion.readthedocs.org/

The examples in the Orion docs use CURL. We're using Python, so we made a little client with some wrapper functions. Hopefully this will save time for any Pythonista wanting to get to grips with Orion.

Make sure you run the CURL examples and get a token using the main Orion tutorial.

Installation

If you just want the code,

pip install orionclient

To get the tests too, clone this repo.

Basic use:

from test_settings import settings

client = OrionClient(
            orion_host_url=settings.orion_host_url,
            orion_host_port=settings.orion_host_port,
            authMethod=settings.authMethod,
            username=settings.username,
            password=settings.password,
            orion_token_url=settings.orion_token_url,
            )
client.token

print 'version'
pprint(client.orion_version)

print 'create a ZYXmeetingroom'
pprint(client.create_entity('ZYXMeetingRoom1',type_id="ZYXMeetingRoom", temperature=70,pressure=1030))

Read the source for the other methods - it's pretty short ;-)

Running the tests

There are no UNIT tests. Instead there is a functional test suite which can run against an Orion instance. This is in the Git repo, but You need to provide a little settings file with your credentials. To use the FIWARE Lab, copy 'test_settings.py.example' to a file 'test_settings.py', add your FIWARE Lab username and password, then run

python test.py

The settings file looks like this:

class settings:
    orion_host_url='http://orion.lab.fiware.org'
    orion_host_port=1026  #or 443
    authMethod='fiware-token'
    username='[email protected]'
    password='SECRET'
    orion_token_url='https://orion.lab.fiware.org/token'
settings=settings()

Add your own FIWARE Lab credentials, or those fo your own FIWARE instance if you wish. We run our own Orion environment from Docker, with a lightweight Python server in front which can serve tokens to us.

orion-python-client's People

Contributors

andy-robinson avatar captainrobbo avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

orion-python-client's Issues

Error when deleting entities

print client.delete_entity('Room2')

ErrorValue(status_code=400
,json={u'orionError': {u'code': u'400', u'details': u'Orion accepts no payload for GET/DELETE requests. HTTP header Content-Type is thus forbidden', u'reasonPhrase': u'Bad Request'}})

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.