Skip to main content

Python API client for GenieACS REST API

Project description

PyPI version License: MIT

pygenieacs

A Python async API client for GenieACS — a TR-069 / CWMP Auto-Configuration Server.
This library provides a simple interface to interact with the GenieACS REST API asynchronously.


✨ Features

  • List, inspect, and delete devices
  • Run tasks (reboot, factory reset, firmware upgrade, etc.)
  • Manage presets
  • Manage provisions
  • Fully async, Pythonic interface

📦 Installation

pip install pygenieacs

🚀 Usage Initialize Client

import asyncio
from pygenieacs import GenieACSClient, DevicesAPI, TasksAPI

async def main():
    async with GenieACSClient(base_url="http://localhost:7557") as client:
        devices = DevicesAPI(client)
        tasks = TasksAPI(client)

        # List devices
        all_devices = await devices.list()
        print(all_devices)

        # Get a specific device
        device_id = "001A2B3C4D"
        info = await devices.get(device_id)
        print(info)

        # Reboot a device
        await tasks.add(device_id, "reboot")

asyncio.run(main())

⚙️ Advanced

from pygenieacs import PresetsAPI

async def create_presets(client):
    presets = PresetsAPI(client)

    # Apply to all devices
    await presets.create("daily-reboot", {
        "weight": 0,
        "precondition": "true",
        "configurations": [
            {"parameter": "InternetGatewayDevice.ManagementServer.PeriodicInformInterval", "value": "60"}
        ]
    })

    # Apply only to MikroTik devices
    await presets.create("mikrotik-provision", {
        "weight": 1,
        "precondition": "DeviceId.Manufacturer == 'MikroTik'",
        "configurations": [],
        "provisions": ["default-config"],
    })

    # Apply firmware upgrade if version < 6.48
    await presets.create("firmware-upgrade", {
        "weight": 10,
        "precondition": "Device.DeviceInfo.SoftwareVersion < '6.48'",
        "configurations": [],
        "provisions": ["upgrade-firmware"],
    })

    # Apply to devices with specific OUI
    await presets.create("oui-target", {
        "weight": 5,
        "precondition": "DeviceId.OUI == '001A2B'",
        "configurations": [
            {
                "parameter": "InternetGatewayDevice.LANDevice.1.LANHostConfigManagement.DHCPServerEnable",
                "value": False
            }
        ],
        "provisions": [],
    })

Provisions

from pygenieacs import ProvisionsAPI

async def create_provision(client):
    provisions = ProvisionsAPI(client)

    # Ensure Inform Interval is set and default Wi-Fi SSID exists
    script = """
    let interval = declare("InternetGatewayDevice.ManagementServer.PeriodicInformInterval", {value: 1});
    if (interval.value[0] != 300) {
      declare("InternetGatewayDevice.ManagementServer.PeriodicInformInterval", null, {value: 300});
    }

    let ssid = declare("InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.SSID", {value: 1});
    if (!ssid.value[0]) {
      declare("InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.SSID", null, {value: "MyDefaultSSID"});
    }
    """

    await provisions.create("default-config", script)

🛠 Development Clone the repo and install locally:

git clone https://github.com/uberkie/pygenieacs.git
cd pygenieacs
pip install -e .

Run tests:

pytest

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pygenieacs-0.1.2.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pygenieacs-0.1.2-py3-none-any.whl (6.1 kB view details)

Uploaded Python 3

File details

Details for the file pygenieacs-0.1.2.tar.gz.

File metadata

  • Download URL: pygenieacs-0.1.2.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pygenieacs-0.1.2.tar.gz
Algorithm Hash digest
SHA256 364275363180feefcaabad1ceea85db988208f22a4653c5928bcd68bcf1aebe6
MD5 0c668856797087a4f0ec3a6e62e8efcf
BLAKE2b-256 79a42b278f36164981817802480175d20c8be09c51df32a394d36ee6ed825faf

See more details on using hashes here.

Provenance

The following attestation bundles were made for pygenieacs-0.1.2.tar.gz:

Publisher: python-publish.yml on uberkie/pygenieacs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pygenieacs-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: pygenieacs-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 6.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pygenieacs-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 0cc2a61a59d617eb792e73e7ac746e3899043f5445d2c46e296dd6ef5ada1791
MD5 3b9223040a6577f76ee4ce9925797e36
BLAKE2b-256 d0d03f9dce9bdf9308ce4c9c7e774f55a84ab323ddac42919c79e250477ca3b1

See more details on using hashes here.

Provenance

The following attestation bundles were made for pygenieacs-0.1.2-py3-none-any.whl:

Publisher: python-publish.yml on uberkie/pygenieacs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page