Skip to main content

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

Metadata

Release files for LeshanRestAPI 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for LeshanRestAPI 0.1.2
File Size Uploaded Provenance Actions
LeshanRestAPI-0.1.2.tar.gz 11.3 kB Without provenance Details for LeshanRestAPI-0.1.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for LeshanRestAPI 0.1.2
File Interpreter ABI Platform Actions
LeshanRestAPI-0.1.2-py3-none-any.whl Python 3 none any Details for LeshanRestAPI-0.1.2-py3-none-any.whl

Total release size: 25.7 kB

Release files / LeshanRestAPI-0.1.2.tar.gz

Download URL LeshanRestAPI-0.1.2.tar.gz
Size 11.3 kB
Tags Source
SHA-256 checksum
How to use checksums
fc5a3e8f5190f226b5de4cf187d15010be2f9d3e331a1bd09424d15a55d3b228
BLAKE2b-256 checksum
How to use checksums
78b65b28ac710eb10846b79b6128d65e283a38bbf777e7229602ee57fcf5d656
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / LeshanRestAPI-0.1.2-py3-none-any.whl

Download URL LeshanRestAPI-0.1.2-py3-none-any.whl
Size 14.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
98472522c96e023836c87e637abd7ad2196c99a476923a6f743dd9421c620dd6
BLAKE2b-256 checksum
How to use checksums
8610fd79acaea126edb337d6fb6117e1a79c0197e5bcff232f60c00e15618176
Upload date
Uploaded using Trusted Publishing?
What is 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

Security for LeshanRestAPI 0.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page