Skip to content

Conversation

@jtdub
Copy link
Contributor

@jtdub jtdub commented Jan 26, 2026

Summary

This PR introduces a complete REST API implementation for the hier_config library, enabling network engineers to programmatically compare, analyze, and remediate network configurations across multiple devices and platforms.

Key Changes

  • FastAPI Application: Created a production-ready FastAPI application with proper middleware configuration (CORS), health checks, and API documentation endpoints

  • Comprehensive API Endpoints: Implemented 20+ REST endpoints organized into 5 logical routers:

    • Configuration operations (parse, compare, predict, merge, search)
    • Remediation workflows (generate, apply tags, filter by tags)
    • Multi-device reporting (create reports, summarize changes, export formats)
    • Platform information (list platforms, get rules, validate configs)
    • Batch operations (create jobs, track progress, retrieve results)
  • Data Models: Created Pydantic models for all request/response types with comprehensive field documentation and validation

  • Service Layer: Implemented business logic services that wrap hier_config library functionality:

    • ConfigService: Handles configuration parsing, comparison, merging, and searching
    • RemediationService: Manages remediation generation and tag-based filtering
    • ReportService: Aggregates multi-device changes and exports in multiple formats
    • PlatformService: Provides platform information and batch job processing
  • Storage Abstraction: Added a storage utility layer for persisting remediation data, reports, and batch jobs

  • Documentation: Comprehensive README with:

    • Quick start guide with installation and running instructions
    • Detailed API endpoint documentation with curl examples
    • Development setup and testing instructions
    • Architecture overview

Notable Implementation Details

  • Platform support for Cisco IOS, NX-OS, IOS-XR, Juniper Junos, and Arista EOS
  • Tag-based filtering for remediation commands enabling selective deployment
  • Batch processing with progress tracking for multi-device operations
  • Multiple export formats (JSON, CSV, YAML) for reports
  • Proper error handling with descriptive HTTP exceptions
  • API documentation available at /api/docs (Swagger UI) and /api/redoc

Testing & Quality

  • Project structure supports pytest-based testing
  • Code quality tools configured (ruff, mypy)
  • Type hints throughout for better IDE support and type safety

Add complete FastAPI-based REST API for hier_config network configuration management with the following features:

Features:
- Configuration operations: parse, compare, predict, merge, and search
- Remediation workflows: generate remediation and rollback with tag-based filtering
- Multi-device reporting: aggregate and analyze changes across device fleets
- Platform support: Cisco IOS/NX-OS/IOS-XR, Juniper Junos, Arista EOS
- Batch processing: handle multiple devices in parallel
- Export formats: JSON, CSV, YAML

Technical Implementation:
- FastAPI framework with async support
- Pydantic models for request/response validation
- Service layer architecture for business logic
- In-memory storage for reports and batch jobs
- Comprehensive test suite with pytest (21 tests, 100% passing)
- Code quality tools: ruff, mypy, pylint (all passing)
- Poetry for dependency management

API Endpoints:
- /api/v1/configs/* - Configuration operations
- /api/v1/remediation/* - Remediation workflows
- /api/v1/reports/* - Multi-device reporting
- /api/v1/platforms/* - Platform information
- /api/v1/batch/* - Batch operations

Documentation:
- Comprehensive README with examples
- Interactive API docs via Swagger UI and ReDoc
- Full type annotations for IDE support
Changes:
- Update pyproject.toml to use hier-config from GitHub repo instead of PyPI
  - Points to https://github.com/netdevops/hier_config.git
  - This allows using the latest version with reports feature not yet on PyPI
- Update author email to james.williams@jtdub.com
- Fix Python version requirement to <4.0 for compatibility
- Add comprehensive GitHub Actions CI workflow
  - Lint job: runs ruff (linter + formatter) and mypy
  - Test job: runs pytest on Python 3.10, 3.11, and 3.12
  - Uses caching for faster builds
  - Uploads coverage to Codecov

The CI workflow will run on:
- Push to main and develop branches
- Pull requests to main and develop branches

All tests pass (21/21) with the GitHub version of hier-config.
Run 'ruff format .' to ensure code formatting consistency.
This fixes the CI formatting check that was failing.

8 files reformatted to comply with ruff formatting standards.
Create complete documentation site using MkDocs Material theme:

Documentation Structure:
- Getting Started: Installation, quickstart, configuration
- API Reference: Detailed documentation for all endpoints
  - Configuration operations (parse, compare, predict, merge, search)
  - Remediation workflows (generate, tag, filter)
  - Multi-device reports (create, summary, changes, export)
  - Platform information (list, rules, validate)
  - Batch operations (create, status, results)
- Guides: Development, contributing, deployment
- Examples: Basic usage, advanced workflows, Python client
- Code Reference: Auto-generated from docstrings

Features:
- MkDocs Material theme with dark mode support
- Auto-generated API reference from code using mkdocstrings
- Comprehensive examples with code snippets
- Search functionality
- Mobile-responsive design
- GitHub integration

GitHub Actions:
- Automated documentation builds on push/PR
- Auto-deployment to GitHub Pages on main branch

Dependencies Added:
- mkdocs: Static site generator
- mkdocs-material: Material Design theme
- mkdocstrings: Auto API docs from docstrings
- mkdocs-gen-files: Dynamic page generation
- mkdocs-literate-nav: Navigation from SUMMARY.md
- mkdocs-section-index: Section index pages

Build and serve locally:
  poetry run mkdocs serve

Build static site:
  poetry run mkdocs build
@jtdub jtdub merged commit d519e83 into main Jan 26, 2026
5 checks passed
@jtdub jtdub deleted the claude/design-hier-config-api-uft7J branch January 26, 2026 00:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants