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.1.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.1-py3-none-any.whl (6.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pygenieacs-0.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 f477ffdd275eeb39472e29e3d32ecb7618904e3ea69d162671ae05e0974e2b1d
MD5 c08efcb907b518631a6ffac7483ef197
BLAKE2b-256 8f8439facdbd4dc56883f3aad54c913855522e2edba52de18a5394d7b6318e68

See more details on using hashes here.

Provenance

The following attestation bundles were made for pygenieacs-0.1.1.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.1-py3-none-any.whl.

File metadata

  • Download URL: pygenieacs-0.1.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6f4cf98eb12922f07ac44c60d6f8fc739dec3e5ccf6247c395846b6b41fc8d35
MD5 020c812ef4b0402ce01bf1d76bce351a
BLAKE2b-256 be13c2ee3ad4bb7eccaa2388ede83773c2f96a307dae9808cb6b5c5cc91898fb

See more details on using hashes here.

Provenance

The following attestation bundles were made for pygenieacs-0.1.1-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