feat(infrahub): add Infrahub client for fabric intent (#42) #19

Closed
Damien wants to merge 6 commits from feature/42-infrahub-client into main
Owner

Summary

Implements the Python async client package (src/infrahub_client/) that wraps infrahub-sdk to fetch fabric intent data from Infrahub. Resolves fabric-orchestrator issue #42 Phase 2.

  • pyproject.toml — package config (arista-evpn-vxlan-infrahub-client) with infrahub-sdk>=0.16.0, pydantic>=2.0, ruff/pytest dev deps, Python ≥3.12
  • src/infrahub_client/exceptions.pyInfrahubClientError hierarchy (ConnectionError, QueryError, NotFoundError)
  • src/infrahub_client/models.py — 11 frozen Pydantic v2 models (DeviceIntent, VlanIntent, VniIntent, BgpRouterConfigIntent, BgpPeerGroupIntent, BgpSessionIntent, VrfIntent, VtepIntent, MlagDomainIntent, MlagPeerConfigIntent, EvpnInstanceIntent)
  • src/infrahub_client/client.pyFabricInfrahubClient async context manager with 10 public methods covering all schema entities (devices, VLANs, BGP, VRFs, VTEPs, EVPN instances, MLAG) and a TTL-based in-memory cache
  • src/infrahub_client/__init__.py — public API exports
  • tests/test_infrahub_client.py — unit tests with fully mocked SDK covering each method, InfrahubNotFoundError, branch forwarding, caching TTL expiry, and InfrahubQueryError propagation

Test plan

  • pip install -e ".[dev]" in the repo root
  • ruff check src/ tests/ — no lint errors
  • ruff format --check src/ tests/ — no formatting issues
  • pytest tests/ — all tests pass
  • Integration smoke test: point client at a running Infrahub instance and call get_device("leaf1")

🤖 Generated with Claude Code

## Summary Implements the Python async client package (`src/infrahub_client/`) that wraps `infrahub-sdk` to fetch fabric intent data from Infrahub. Resolves fabric-orchestrator issue #42 Phase 2. - **`pyproject.toml`** — package config (`arista-evpn-vxlan-infrahub-client`) with `infrahub-sdk>=0.16.0`, `pydantic>=2.0`, ruff/pytest dev deps, Python ≥3.12 - **`src/infrahub_client/exceptions.py`** — `InfrahubClientError` hierarchy (`ConnectionError`, `QueryError`, `NotFoundError`) - **`src/infrahub_client/models.py`** — 11 frozen Pydantic v2 models (`DeviceIntent`, `VlanIntent`, `VniIntent`, `BgpRouterConfigIntent`, `BgpPeerGroupIntent`, `BgpSessionIntent`, `VrfIntent`, `VtepIntent`, `MlagDomainIntent`, `MlagPeerConfigIntent`, `EvpnInstanceIntent`) - **`src/infrahub_client/client.py`** — `FabricInfrahubClient` async context manager with 10 public methods covering all schema entities (devices, VLANs, BGP, VRFs, VTEPs, EVPN instances, MLAG) and a TTL-based in-memory cache - **`src/infrahub_client/__init__.py`** — public API exports - **`tests/test_infrahub_client.py`** — unit tests with fully mocked SDK covering each method, `InfrahubNotFoundError`, branch forwarding, caching TTL expiry, and `InfrahubQueryError` propagation ## Test plan - [ ] `pip install -e ".[dev]"` in the repo root - [ ] `ruff check src/ tests/` — no lint errors - [ ] `ruff format --check src/ tests/` — no formatting issues - [ ] `pytest tests/` — all tests pass - [ ] Integration smoke test: point client at a running Infrahub instance and call `get_device("leaf1")` 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Damien added 6 commits 2026-02-26 12:44:33 +00:00
Damien closed this pull request 2026-02-26 12:46:22 +00:00

Pull request closed

Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Damien/arista-evpn-vxlan-clab#19