Skip to content

Commit ace3d02

Browse files
committed
Add comprehensive documentation with MkDocs
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
1 parent c83c899 commit ace3d02

21 files changed

Lines changed: 4238 additions & 5 deletions

.github/workflows/docs.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Deploy Documentation
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
11+
permissions:
12+
contents: write
13+
14+
jobs:
15+
deploy:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v4
19+
20+
- name: Set up Python
21+
uses: actions/setup-python@v5
22+
with:
23+
python-version: "3.11"
24+
25+
- name: Install Poetry
26+
uses: snok/install-poetry@v1
27+
with:
28+
version: 2.3.1
29+
virtualenvs-create: true
30+
virtualenvs-in-project: true
31+
32+
- name: Load cached venv
33+
id: cached-poetry-dependencies
34+
uses: actions/cache@v4
35+
with:
36+
path: .venv
37+
key: venv-docs-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}
38+
39+
- name: Install dependencies
40+
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
41+
run: poetry install --no-interaction --no-root
42+
43+
- name: Install project
44+
run: poetry install --no-interaction
45+
46+
- name: Build documentation
47+
run: poetry run mkdocs build
48+
49+
- name: Deploy to GitHub Pages
50+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
51+
uses: peaceiris/actions-gh-pages@v4
52+
with:
53+
github_token: ${{ secrets.GITHUB_TOKEN }}
54+
publish_dir: ./site

docs/api/batch.md

Lines changed: 215 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,215 @@
1+
# Batch Operations
2+
3+
Process multiple devices in parallel for improved efficiency.
4+
5+
## Create Batch Remediation Job
6+
7+
Create a batch job to generate remediation for multiple devices.
8+
9+
**Endpoint:** `POST /api/v1/batch/remediation`
10+
11+
### Request
12+
13+
```json
14+
{
15+
"device_configs": [
16+
{
17+
"device_id": "router1",
18+
"platform": "cisco_ios",
19+
"running_config": "hostname router1",
20+
"intended_config": "hostname router1-new"
21+
},
22+
{
23+
"device_id": "router2",
24+
"platform": "cisco_ios",
25+
"running_config": "hostname router2",
26+
"intended_config": "hostname router2-new"
27+
},
28+
{
29+
"device_id": "switch1",
30+
"platform": "cisco_nxos",
31+
"running_config": "hostname switch1",
32+
"intended_config": "hostname switch1-new"
33+
}
34+
]
35+
}
36+
```
37+
38+
### Response
39+
40+
```json
41+
{
42+
"job_id": "job-abc-123-def-456",
43+
"total_devices": 3
44+
}
45+
```
46+
47+
---
48+
49+
## Get Batch Job Status
50+
51+
Get the current status and progress of a batch job.
52+
53+
**Endpoint:** `GET /api/v1/batch/jobs/{job_id}`
54+
55+
### Response
56+
57+
```json
58+
{
59+
"job_id": "job-abc-123-def-456",
60+
"status": "completed",
61+
"progress": 100.0,
62+
"total_devices": 3,
63+
"completed_devices": 3,
64+
"failed_devices": 0
65+
}
66+
```
67+
68+
| Field | Type | Description |
69+
|-------|------|-------------|
70+
| job_id | string | Unique job identifier |
71+
| status | string | Job status (pending, running, completed, failed) |
72+
| progress | float | Progress percentage (0-100) |
73+
| total_devices | integer | Total number of devices |
74+
| completed_devices | integer | Successfully processed devices |
75+
| failed_devices | integer | Failed devices |
76+
77+
### Status Values
78+
79+
- `pending` - Job created, not yet started
80+
- `running` - Job is currently processing
81+
- `completed` - Job finished successfully
82+
- `failed` - Job encountered fatal error
83+
84+
---
85+
86+
## Get Batch Job Results
87+
88+
Get the results of a completed batch job.
89+
90+
**Endpoint:** `GET /api/v1/batch/jobs/{job_id}/results`
91+
92+
### Response
93+
94+
```json
95+
{
96+
"job_id": "job-abc-123-def-456",
97+
"status": "completed",
98+
"results": [
99+
{
100+
"device_id": "router1",
101+
"status": "success",
102+
"remediation": "no hostname router1\nhostname router1-new",
103+
"rollback": "no hostname router1-new\nhostname router1"
104+
},
105+
{
106+
"device_id": "router2",
107+
"status": "success",
108+
"remediation": "no hostname router2\nhostname router2-new",
109+
"rollback": "no hostname router2-new\nhostname router2"
110+
},
111+
{
112+
"device_id": "switch1",
113+
"status": "failed",
114+
"error": "Configuration parsing error"
115+
}
116+
],
117+
"summary": {
118+
"total_devices": 3,
119+
"completed_devices": 2,
120+
"failed_devices": 1,
121+
"status": "completed"
122+
}
123+
}
124+
```
125+
126+
## Workflow Example
127+
128+
### 1. Submit Batch Job
129+
130+
```python
131+
import requests
132+
import time
133+
134+
# Prepare device list
135+
devices = []
136+
for i in range(100):
137+
devices.append({
138+
"device_id": f"router{i}",
139+
"platform": "cisco_ios",
140+
"running_config": f"hostname router{i}",
141+
"intended_config": f"hostname router{i}-new"
142+
})
143+
144+
# Create batch job
145+
response = requests.post(
146+
"http://localhost:8000/api/v1/batch/remediation",
147+
json={"device_configs": devices}
148+
)
149+
150+
job_id = response.json()["job_id"]
151+
print(f"Job created: {job_id}")
152+
```
153+
154+
### 2. Monitor Progress
155+
156+
```python
157+
# Poll for completion
158+
while True:
159+
status = requests.get(
160+
f"http://localhost:8000/api/v1/batch/jobs/{job_id}"
161+
).json()
162+
163+
print(f"Progress: {status['progress']:.1f}% "
164+
f"({status['completed_devices']}/{status['total_devices']})")
165+
166+
if status['status'] in ['completed', 'failed']:
167+
break
168+
169+
time.sleep(2)
170+
```
171+
172+
### 3. Get Results
173+
174+
```python
175+
# Fetch results
176+
results = requests.get(
177+
f"http://localhost:8000/api/v1/batch/jobs/{job_id}/results"
178+
).json()
179+
180+
# Process successful remediations
181+
for result in results['results']:
182+
if result['status'] == 'success':
183+
print(f"{result['device_id']}: Ready for deployment")
184+
print(result['remediation'])
185+
else:
186+
print(f"{result['device_id']}: FAILED - {result['error']}")
187+
```
188+
189+
## Performance Considerations
190+
191+
### Batch Size
192+
193+
Optimal batch size depends on:
194+
195+
- Server resources (CPU, memory)
196+
- Configuration complexity
197+
- Network latency
198+
199+
Recommended batch sizes:
200+
201+
- Small configs (<100 lines): 100-500 devices
202+
- Medium configs (100-1000 lines): 50-100 devices
203+
- Large configs (>1000 lines): 10-50 devices
204+
205+
### Timeouts
206+
207+
For large batches, consider:
208+
209+
- Increasing server timeout settings
210+
- Splitting into smaller batches
211+
- Using asynchronous processing
212+
213+
### Error Handling
214+
215+
Batch jobs continue processing even if individual devices fail. Always check the `failed_devices` count and review the error messages in the results.

0 commit comments

Comments
 (0)