Wrapper for Leshan IOT RESTful API
Project description
LeshanRestAPI
RESTful Library Wrapper for Leshan IOT.
Installation
Install using pip
pip install LeshanRestAPI
Getting Started
Find the url of the Leshan client you want to interface with. Some examples are found on on the leshan website
First import the library and instantiate a new class of Client(), passing in the url. If this is the first time you have connected to this client, the html will be extracted and cached in the cached_clients folder in the installation directory of this library. Future connections will use this json cache to avoid the time consuming process of extracting the html from the client webpage. If the webpage has changed from your cache, supply the parameter refresh=True to your instantiation of Client().
LeshanRestAPI uses json representation of the client objects and searches this dictionary for a match on the resource supplied by the user. The user can supply additional parameters instance or object_ if the client webpage has more than one resource with the same name.
Examples
from LeshanRestAPI import Client
runner = Client('https://leshan.eclipse.org/#/clients/358185090000024')
print(runner.read("Lifetime"))
runner.observe("Lifetime")
runner.execute("Update")
runner.discover("Lifetime")
Methods
Available methods are
read
write
observe
discover
excecute
AssertRead
These methods take the following inputs in order:
resource,object_=None,instance_=None,timeout=TIMEOUT
Write takes an additional parameter: text
text,resource,object_None,instance=None,timeout=TIMEOUT
Additional Details
The user does not need to enter all details of the object for it to be found. In most cases, the resource name is sufficient. Only when there is more than one resource does the user need to provide additional information such as instance or object_. Note in examples two and three that the instance can be overloaded in the object_ variable. The following example illustrates this on this client
read("Lifetime")
read("Lifetime",0) #search resource Lifetime on instance 0 with object not specified
read("Lifetime","0") #search resource Lifetime on instance 0 with object not specified
read("Lifetime",None,0) #search resource Lifetime on instance 0 with object not specified
read("Lifetime","LwM2M Server") #search resource LifeTime on Object LwM2M Server with instance not specified
read("Lifetime","LwM2M Server",0) #search resource LifeTime on Object LwM2M Server on instance 0
Since "Lifetime" resource exists only once on this client. The user can use any of the above to read from it.
Troubleshooting
If you cannot operate on a resource. Try operating on the resource directly through its webportal. Often times, methods are not allowed for a resource or the resource is not available.
More details of the leshan RESTful API is given here
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file LeshanRestAPI-0.1.2.tar.gz
.
File metadata
- Download URL: LeshanRestAPI-0.1.2.tar.gz
- Upload date:
- Size: 11.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/39.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.6.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fc5a3e8f5190f226b5de4cf187d15010be2f9d3e331a1bd09424d15a55d3b228 |
|
MD5 | e2fcfc3a5205a57d2444678ed4829268 |
|
BLAKE2b-256 | 78b65b28ac710eb10846b79b6128d65e283a38bbf777e7229602ee57fcf5d656 |
File details
Details for the file LeshanRestAPI-0.1.2-py3-none-any.whl
.
File metadata
- Download URL: LeshanRestAPI-0.1.2-py3-none-any.whl
- Upload date:
- Size: 14.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/39.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.6.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 98472522c96e023836c87e637abd7ad2196c99a476923a6f743dd9421c620dd6 |
|
MD5 | 808f0cb31a759b49e2875c558ede77e0 |
|
BLAKE2b-256 | 8610fd79acaea126edb337d6fb6117e1a79c0197e5bcff232f60c00e15618176 |