Skip to main content

Itential Gateway Async Client

Project description

AsyncGateway

Async Python client for the Itential Automation Gateway (IAG) 4.x API.

Overview

asyncgateway provides async/await access to IAG 4.x across two layers:

  • Services (client.services.*) — thin async wrappers, one method per API endpoint, returning raw dicts.
  • Resources (client.resources.*) — declarative abstractions that compose service calls into idempotent operations (ensure, absent, run, load, dump).

Use services when you need direct API access. Use resources when you want declarative, state-based control.

Installation

pip install asyncgateway
uv add asyncgateway

Requires: Python 3.10+, ipsdk

Usage

Client initialization

import asyncio
import asyncgateway

config = {
    "host": "gateway.example.com",
    # "port": 3000,
    # "protocol": "https",
    # "username": "admin",
    # "password": "secret",
}

async def main():
    async with asyncgateway.client(**config) as client:
        ...

asyncio.run(main())

All **kwargs are passed through to ipsdk.gateway_factory().

Services layer

Direct, one-to-one wrappers around IAG API endpoints.

# Devices
devices = await client.services.devices.get_all()
device  = await client.services.devices.get("router1")
await client.services.devices.create("router1", {"ansible_host": "192.168.1.1"})
await client.services.devices.patch("router1", {"ansible_user": "admin"})
await client.services.devices.delete("router1")

# Playbooks
playbooks = await client.services.playbooks.get_all()
playbook  = await client.services.playbooks.get("network_config")
await client.services.playbooks.refresh()
schema = await client.services.playbooks.get_schema("network_config")
await client.services.playbooks.update_schema("network_config", schema)
await client.services.playbooks.delete_schema("network_config")

# Gateway configuration
config = await client.services.config.get()
await client.services.config.update({"max_concurrent_jobs": 10})

Resources layer

Declarative, idempotent operations that compose service calls.

from asyncgateway.services import Operation

# Ensure a device exists; create if missing, patch variables if present
device = await client.resources.devices.ensure("router1", {"ansible_host": "192.168.1.1"})

# Ensure a device does not exist (no-op if already absent)
await client.resources.devices.absent("router1")

# Bulk load devices from an in-memory list
data = [{"name": "router1", "variables": {"ansible_host": "192.168.1.1"}}]
result = await client.resources.devices.load(data, Operation.MERGE)

# Dump all devices to files
result = await client.resources.devices.dump(format_type="yaml", individual_files=True)

# Run a playbook
result = await client.resources.playbooks.run("network_config", {"target": "router1"})

# Dry run a playbook
result = await client.resources.playbooks.dry_run("network_config", {"target": "router1"})

Load operations:

Operation Behavior
Operation.MERGE Add missing resources; skip existing
Operation.OVERWRITE Add missing; replace existing
Operation.REPLACE Delete all existing, then add from data

Bulk file load

client.load(path, op) reads JSON/YAML files from {path}/{service_name}/ and dispatches to each service that supports load():

result = await client.load("/data", Operation.MERGE)

YAML support requires PyYAML (uv add PyYAML). Without it, YAML paths raise ValidationError.

Development

git clone https://github.com/itential/asyncgateway
cd asyncgateway
uv sync --group dev
uv run pytest          # all tests pass without a live IAG instance
make ci                # lint + typecheck + security + tests (full local CI)

See docs/development.md for the full contributor guide and CONTRIBUTING.md for contribution guidelines.

License

GPL-3.0-or-later. See LICENSE.

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

asyncgateway-0.1.0.tar.gz (151.9 kB view details)

Uploaded Source

Built Distribution

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

asyncgateway-0.1.0-py3-none-any.whl (75.5 kB view details)

Uploaded Python 3

File details

Details for the file asyncgateway-0.1.0.tar.gz.

File metadata

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

File hashes

Hashes for asyncgateway-0.1.0.tar.gz
Algorithm Hash digest
SHA256 0ffb27b567a5928c9cab5d85e691c3ba54e0f10e8d6e215dc3d918ab8e1e5226
MD5 5ab24303e37fd810ab887f75f571ff06
BLAKE2b-256 17828bcd532448af3f24f6502d267c5d3126ae548b608d3b9456f3fb14317b08

See more details on using hashes here.

Provenance

The following attestation bundles were made for asyncgateway-0.1.0.tar.gz:

Publisher: release.yaml on itential/asyncgateway

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

File details

Details for the file asyncgateway-0.1.0-py3-none-any.whl.

File metadata

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

File hashes

Hashes for asyncgateway-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 26d484b90337c76be373503388737a5d750fc979076e09f062c42fdaebb6bb86
MD5 5f6531f39e26b3fcdfed0e4e0674a1e9
BLAKE2b-256 0172df373e074528c7fd3c7507a6415d8320f9ae9e85096fba275198a7baa309

See more details on using hashes here.

Provenance

The following attestation bundles were made for asyncgateway-0.1.0-py3-none-any.whl:

Publisher: release.yaml on itential/asyncgateway

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