Skip to content

About

LORIOT Python Library - LORIOT NMS API

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

6 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LORIOT Python Library

Python library for LORIOT API interactions: authentication, resource retrieval, and CSV helpers.

Created by LORIOT AG. Licensed under the Apache License 2.0.

Requirements

  • Python >= 3.7
  • pip (and optionally build to create distributable packages)

Build and install

Create and activate a virtual environment (recommended):

python3 -m venv .venv
source .venv/bin/activate        # Windows: .venv\Scripts\activate

Install directly from a checkout:

pip install .

Editable install for development:

pip install -e .

Build distributable packages (wheel and sdist are written to dist/):

pip install build
python -m build
pip install dist/loriot-*.whl

Install straight from the repository:

pip install "git+https://bitbucket.org/loriot/loriot-python-library.git"

Verify the installation:

python -c "import loriot; print(loriot.getRequest)"

Modules

loriot.request

  • getRequest(host, api, session) - HTTP GET
  • postRequest(host, params, api, session) - HTTP POST
  • putRequest(host, params, api, session) - HTTP PUT
  • deleteRequest(host, api, session) - HTTP DELETE

loriot.loriot

  • loginAdme(host, user, password) - Admin login
  • loginImpersonate(host, userid, adminSessionId) - Impersonate user
  • login2FA(host, passcode, session) - 2FA login
  • is2FAEnabled(response) - Check 2FA requirement
  • getInstanceType(server, session) - Get server type
  • getResourcesFromPages(customerObj, session, api, apiFieldName) - Fetch all pages of a paginated endpoint (customerObj needs a server key)
  • getAccounts, getGateways, getOrganizations, getActiveDevicesCountLastMonth, getInOutFrames, getServerRelease - Resource retrieval (paginated, multithreaded)

loriot.csv_utils

  • loadNetworksFromCSV(csvPath) - Load networks from CSV
  • loadGatewaysFromCSV(csvPath) - Load gateways from CSV
  • loadDevicesFromCSV(csvPath) - Load devices from CSV
  • loadCSV(csvPath, field_mappings, resource_type) - Generic CSV loader

loriot.log

  • debugPrint(message, color) - Print debug messages when DEBUG is enabled
  • set_debug(enabled) - Enable/disable debug mode

Usage

from loriot import loginAdme, getRequest
from loriot.csv_utils import loadGatewaysFromCSV

# Login
login_resp = loginAdme('server.loriot.io', 'user@example.com', 'password')
session = login_resp['session']

# Make API call
data = getRequest('server.loriot.io', '/1/nwk/gateways', session)

# Load gateways from CSV
gateways = loadGatewaysFromCSV('gateways.csv')

Debugging

Call loriot.set_debug(True) to enable debug output.

License

Apache License, Version 2.0. See LICENSE.

About

LORIOT Python Library - LORIOT NMS API

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages