REST API for hier_config network configuration management.
This FastAPI-based REST API provides a comprehensive interface to the hier_config library, enabling network engineers to:
- Compare and diff network configurations
- Generate remediation and rollback commands
- Analyze configuration changes across multiple devices
- Validate configurations for different network platforms
- Configuration Operations: Parse, compare, merge, and search network configurations
- Remediation Workflows: Generate remediation and rollback configurations with tag-based filtering
- Multi-Device Reporting: Aggregate and analyze configuration changes across device fleets
- Platform Support: Cisco IOS, Cisco NX-OS, Cisco IOS-XR, Juniper Junos, Arista EOS
- Batch Processing: Process multiple devices in parallel
- Export Formats: JSON, CSV, YAML
# Clone the repository
git clone https://github.com/netdevops/hier-config-api.git
cd hier-config-api
# Install dependencies with poetry
poetry install
# Run the API server
poetry run uvicorn hier_config_api.main:app --reloadOnce the server is running, access the interactive API documentation at:
- Swagger UI: http://localhost:8000/api/docs
- ReDoc: http://localhost:8000/api/redoc
POST /api/v1/configs/parseParse raw configuration text into structured format.
Example:
curl -X POST http://localhost:8000/api/v1/configs/parse \
-H "Content-Type: application/json" \
-d '{
"platform": "cisco_ios",
"config_text": "hostname router1\ninterface GigabitEthernet0/0\n ip address 192.168.1.1 255.255.255.0"
}'POST /api/v1/configs/compareCompare running and intended configurations to show differences.
Example:
curl -X POST http://localhost:8000/api/v1/configs/compare \
-H "Content-Type: application/json" \
-d '{
"platform": "cisco_ios",
"running_config": "hostname old-router",
"intended_config": "hostname new-router"
}'POST /api/v1/configs/predictPredict configuration state after applying commands.
POST /api/v1/configs/mergeMerge multiple configuration snippets into one.
POST /api/v1/configs/searchSearch configuration using pattern matching.
POST /api/v1/remediation/generateGenerate remediation and rollback configurations.
Example:
curl -X POST http://localhost:8000/api/v1/remediation/generate \
-H "Content-Type: application/json" \
-d '{
"platform": "cisco_ios",
"running_config": "hostname router1\ninterface GigabitEthernet0/0\n ip address 192.168.1.1 255.255.255.0",
"intended_config": "hostname router2\ninterface GigabitEthernet0/0\n ip address 192.168.1.2 255.255.255.0"
}'Response:
{
"remediation_id": "abc-123",
"platform": "cisco_ios",
"remediation_config": "no hostname router1\nhostname router2\ninterface GigabitEthernet0/0\n no ip address 192.168.1.1 255.255.255.0\n ip address 192.168.1.2 255.255.255.0",
"rollback_config": "...",
"summary": {
"additions": 3,
"deletions": 2,
"modifications": 0
},
"tags": {}
}POST /api/v1/remediation/{remediation_id}/tagsApply tag rules to an existing remediation.
GET /api/v1/remediation/{remediation_id}/filter?include_tags=safe&exclude_tags=riskyFilter remediation commands by tags.
POST /api/v1/reportsCreate a multi-device configuration report.
Example:
curl -X POST http://localhost:8000/api/v1/reports \
-H "Content-Type: application/json" \
-d '{
"remediations": [
{
"device_id": "router1",
"platform": "cisco_ios",
"running_config": "...",
"intended_config": "..."
},
{
"device_id": "router2",
"platform": "cisco_ios",
"running_config": "...",
"intended_config": "..."
}
]
}'GET /api/v1/reports/{report_id}/summaryGet aggregated statistics for a report.
GET /api/v1/reports/{report_id}/changes?tag=safe&min_devices=2Get detailed change analysis showing which changes appear across multiple devices.
GET /api/v1/reports/{report_id}/export?format=json|csv|yamlExport report in specified format.
GET /api/v1/platformsList all supported network platforms.
GET /api/v1/platforms/{platform}/rulesGet platform-specific configuration rules.
POST /api/v1/platforms/{platform}/validateValidate configuration for a specific platform.
POST /api/v1/batch/remediationCreate a batch remediation job for multiple devices.
GET /api/v1/batch/jobs/{job_id}Get the status and progress of a batch job.
GET /api/v1/batch/jobs/{job_id}/resultsGet the results of a completed batch job.
# Run all tests
poetry run pytest
# Run with coverage
poetry run pytest --cov=hier_config_api --cov-report=html
# Run specific test file
poetry run pytest tests/test_configs.py -v# Run ruff linter
poetry run ruff check .
# Run ruff formatter
poetry run ruff format .
# Run mypy type checker
poetry run mypy hier_config_api
# Run all linters
poetry run ruff check . && poetry run mypy hier_config_api- Cisco IOS (
cisco_ios) - Cisco NX-OS (
cisco_nxos) - Cisco IOS-XR (
cisco_iosxr) - Juniper Junos (
juniper_junos) - Arista EOS (
arista_eos) - Generic (
generic)
hier-config-api/
├── hier_config_api/
│ ├── models/ # Pydantic models for request/response validation
│ ├── routers/ # API endpoint definitions
│ ├── services/ # Business logic layer
│ ├── utils/ # Utility functions (storage, etc.)
│ └── main.py # FastAPI application entry point
├── tests/ # Pytest test suite
└── pyproject.toml # Project configuration
See LICENSE file for details.
Contributions are welcome! Please feel free to submit a Pull Request.
- hier_config - The core library powering this API