An API client library for Opengear Lighthouse
Project description
The client is tightly tied to the RESTful API RAML specification, which is very well exposed here.
Authentication
The Lighthouse API Client expects to find the following environment variables:
(required) OGLH_API_USER a valid Lighthouse user
(required) OGLH_API_PASS a valid Lighthouse user’s password
(required) OGLH_API_URL the Lighthouse API url without /api/v1
Conventions
All the methods follow the convention specified as follows. A call for an url like:
GET /system/global_enrollment_token HTTP/1.0
would be performed through the client as:
>>> from oglhclient import LighthouseApiClient
>>> api = LighthouseApiClient()
>>> client = api.get_client()
>>> client.system.global_enrollment_token.get()
Basically, all / must be replaced by . followed by an action:
GET: find()
Used when asking for a specific object
Example:
GET /nodes/smartgroups/myGrouId HTTP/1.0
Becomes:
smartgroup = client.nodes.smartgroups.find(id='myGrouId')
or
smartgroup = client.nodes.smartgroups.find('myGrouId')
In case of a child object like in /nodes/{id}/tags/{tag_value_id}, with a possible call like:
GET /nodes/nodes-13/tags/London HTTP/1.0
The python call should be:
tag = client.nodes.tags.find(id='myTagId', parent_id='myNodeId')
Also possible to make:
tag = client.nodes.tags.find(id='myTagId', node_id='myNodeId')
Always paying attention to the simple plural formatting removal:
nodes: node
properties: property
GET: list()
Used when asking for a list of objects
Example:
GET /nodes/smartgroups HTTP/1.0
Becomes:
smartgroups = client.nodes.smartgroups.list()
parameters may apply like page, per_page, and so on:
smartgroups = client.nodes.smartgroups.list(page=1,per_page=5)
GET: get()
Only used when the two previous do not apply, like:
GET /system/webui_session_timeout HTTP/1.0
Becomes:
timeout = client.system.webui_session_timeout.get()
POST: create()
As the name suggests, it is used to create objects, for instance:
POST /tags/node_tags HTTP/1.0 Content-Type: application/json {"node_tag": {"name": "Location","values": [{"value": "USA.NewYork"},{"value": "UK.London"}]}}
could be performed as:
result = client.tags.node_tags.create(data={"username":"root","password":"default"})
PUT: update()
It is used to update a given object, like:
PUT /tags/node_tags/nodes_tags-1 HTTP/1.0 Content-Type: application/json {"node_tag": {"name": "Location","values": [{"id": "tags_node_tags_values_90","value": "USA.NewYork"}]}}
could be performed as:
data = {
"node_tag": {
"name": "Location",
"values": [
{
"id": "tags_node_tags_values_90",
"value": "USA.NewYork"
}
]
}
}
result = client.tags.node_tags.update(tag_value_id='nodes_tags-1', data=data)
DELETE: delete()
It is used for deleting an object by its id, for instance:
DELETE /tags/node_tags/nodes_tags-1 HTTP/1.0
could be performed as:
result = client.tags.node_tags.delete(tag_value_id='nodes_tags-1')
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
File details
Details for the file oglhclient-1.0.0.tar.gz
.
File metadata
- Download URL: oglhclient-1.0.0.tar.gz
- Upload date:
- Size: 54.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8c24d01f011cc49355d20ad96f22f448e2761194aaf53969577d88631bc222e5 |
|
MD5 | 95f3b6cc28b6664651de678e16a34bd0 |
|
BLAKE2b-256 | 85795b1fdfe5adf1f9813e626a97823f375e211429426cdf242536e3cf6ba604 |