2025-12-11 21:50:42 +00:00
|
|
|
# REST API Reference
|
|
|
|
|
|
|
|
|
|
This document provides comprehensive documentation for all REST API endpoints in provisioning.
|
|
|
|
|
|
|
|
|
|
## Overview
|
|
|
|
|
|
|
|
|
|
Provisioning exposes two main REST APIs:
|
2026-01-08 09:55:37 +00:00
|
|
|
|
2025-12-11 21:50:42 +00:00
|
|
|
- **Orchestrator API** (Port 8080): Core workflow management and batch operations
|
|
|
|
|
- **Control Center API** (Port 9080): Authentication, authorization, and policy management
|
|
|
|
|
|
|
|
|
|
## Base URLs
|
|
|
|
|
|
|
|
|
|
- **Orchestrator**: `http://localhost:9090`
|
|
|
|
|
- **Control Center**: `http://localhost:9080`
|
|
|
|
|
|
|
|
|
|
## Authentication
|
|
|
|
|
|
|
|
|
|
### JWT Authentication
|
2026-01-08 09:55:37 +00:00
|
|
|
|
2025-12-11 21:50:42 +00:00
|
|
|
All API endpoints (except health checks) require JWT authentication via the Authorization header:
|
|
|
|
|
|
|
|
|
|
```http
|
|
|
|
|
Authorization: Bearer <jwt_token>
|
2026-01-08 09:55:37 +00:00
|
|
|
```plaintext
|
2025-12-11 21:50:42 +00:00
|
|
|
|
|
|
|
|
### Getting Access Token
|
2026-01-08 09:55:37 +00:00
|
|
|
|
2025-12-11 21:50:42 +00:00
|
|
|
```http
|
|
|
|
|
POST /auth/login
|
|
|
|
|
Content-Type: application/json
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
"username": "admin",
|
|
|
|
|
"password": "password",
|
|
|
|
|
"mfa_code": "123456"
|
|
|
|
|
}
|
2026-01-08 09:55:37 +00:00
|
|
|
```plaintext
|
2025-12-11 21:50:42 +00:00
|
|
|
|
|
|
|
|
## Orchestrator API Endpoints
|
|
|
|
|
|
|
|
|
|
### Health Check
|
|
|
|
|
|
|
|
|
|
#### GET /health
|
2026-01-08 09:55:37 +00:00
|
|
|
|
2025-12-11 21:50:42 +00:00
|
|
|
Check orchestrator health status.
|
|
|
|
|
|
|
|
|
|
**Response:**
|
2026-01-08 09:55:37 +00:00
|
|
|
|
2025-12-11 21:50:42 +00:00
|
|
|
```json
|
|
|
|
|
{
|
|
|
|
|
"success": true,
|
|
|
|
|
"data": "Orchestrator is healthy"
|
|
|
|
|
}
|
2026-01-08 09:55:37 +00:00
|
|
|
```plaintext
|
2025-12-11 21:50:42 +00:00
|
|
|
|
|
|
|
|
### Task Management
|
|
|
|
|
|
|
|
|
|
#### GET /tasks
|
2026-01-08 09:55:37 +00:00
|
|
|
|
2025-12-11 21:50:42 +00:00
|
|
|
List all workflow tasks.
|
|
|
|
|
|
|
|
|
|
**Query Parameters:**
|
2026-01-08 09:55:37 +00:00
|
|
|
|
2025-12-11 21:50:42 +00:00
|
|
|
- `status` (optional): Filter by task status (Pending, Running, Completed, Failed, Cancelled)
|
|
|
|
|
- `limit` (optional): Maximum number of results
|
|
|
|
|
- `offset` (optional): Pagination offset
|
|
|
|
|
|
|
|
|
|
**Response:**
|
2026-01-08 09:55:37 +00:00
|
|
|
|
2025-12-11 21:50:42 +00:00
|
|
|
```json
|
|
|
|
|
{
|
|
|
|
|
"success": true,
|
|
|
|
|
"data": [
|
|
|
|
|
{
|
|
|
|
|
"id": "uuid-string",
|
|
|
|
|
"name": "create_servers",
|
|
|
|
|
"command": "/usr/local/provisioning servers create",
|
|
|
|
|
"args": ["--infra", "production", "--wait"],
|
|
|
|
|
"dependencies": [],
|
|
|
|
|
"status": "Completed",
|
|
|
|
|
"created_at": "2025-09-26T10:00:00Z",
|
|
|
|
|
"started_at": "2025-09-26T10:00:05Z",
|
|
|
|
|
"completed_at": "2025-09-26T10:05:30Z",
|
|
|
|
|
"output": "Successfully created 3 servers",
|
|
|
|
|
"error": null
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
}
|
2026-01-08 09:55:37 +00:00
|
|
|
```plaintext
|
2025-12-11 21:50:42 +00:00
|
|
|
|
|
|
|
|
#### GET /tasks/{id}
|
2026-01-08 09:55:37 +00:00
|
|
|
|
2025-12-11 21:50:42 +00:00
|
|
|
Get specific task status and details.
|
|
|
|
|
|
|
|
|
|
**Path Parameters:**
|
2026-01-08 09:55:37 +00:00
|
|
|
|
2025-12-11 21:50:42 +00:00
|
|
|
- `id`: Task UUID
|
|
|
|
|
|
|
|
|
|
**Response:**
|
2026-01-08 09:55:37 +00:00
|
|
|
|
2025-12-11 21:50:42 +00:00
|
|
|
```json
|
|
|
|
|
{
|
|
|
|
|
"success": true,
|
|
|
|
|
"data": {
|
|
|
|
|
"id": "uuid-string",
|
|
|
|
|
"name": "create_servers",
|
|
|
|
|
"command": "/usr/local/provisioning servers create",
|
|
|
|
|
"args": ["--infra", "production", "--wait"],
|
|
|
|
|
"dependencies": [],
|
|
|
|
|
"status": "Running",
|
|
|
|
|
"created_at": "2025-09-26T10:00:00Z",
|
|
|
|
|
"started_at": "2025-09-26T10:00:05Z",
|
|
|
|
|
"completed_at": null,
|
|
|
|
|
"output": null,
|
|
|
|
|
"error": null
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-01-08 09:55:37 +00:00
|
|
|
```plaintext
|
2025-12-11 21:50:42 +00:00
|
|
|
|
|
|
|
|
### Workflow Submission
|
|
|
|
|
|
|
|
|
|
#### POST /workflows/servers/create
|
2026-01-08 09:55:37 +00:00
|
|
|
|
2025-12-11 21:50:42 +00:00
|
|
|
Submit server creation workflow.
|
|
|
|
|
|
|
|
|
|
**Request Body:**
|
2026-01-08 09:55:37 +00:00
|
|
|
|
2025-12-11 21:50:42 +00:00
|
|
|
```json
|
|
|
|
|
{
|
|
|
|
|
"infra": "production",
|
2026-01-08 09:55:37 +00:00
|
|
|
"settings": "config.ncl",
|
2025-12-11 21:50:42 +00:00
|
|
|
"check_mode": false,
|
|
|
|
|
"wait": true
|
|
|
|
|
}
|
2026-01-08 09:55:37 +00:00
|
|
|
```plaintext
|
2025-12-11 21:50:42 +00:00
|
|
|
|
|
|
|
|
**Response:**
|
2026-01-08 09:55:37 +00:00
|
|
|
|
2025-12-11 21:50:42 +00:00
|
|
|
```json
|
|
|
|
|
{
|
|
|
|
|
"success": true,
|
|
|
|
|
"data": "uuid-task-id"
|
|
|
|
|
}
|
2026-01-08 09:55:37 +00:00
|
|
|
```plaintext
|
2025-12-11 21:50:42 +00:00
|
|
|
|
|
|
|
|
#### POST /workflows/taskserv/create
|
2026-01-08 09:55:37 +00:00
|
|
|
|
2025-12-11 21:50:42 +00:00
|
|
|
Submit task service workflow.
|
|
|
|
|
|
|
|
|
|
**Request Body:**
|
2026-01-08 09:55:37 +00:00
|
|
|
|
2025-12-11 21:50:42 +00:00
|
|
|
```json
|
|
|
|
|
{
|
|
|
|
|
"operation": "create",
|
|
|
|
|
"taskserv": "kubernetes",
|
|
|
|
|
"infra": "production",
|
2026-01-08 09:55:37 +00:00
|
|
|
"settings": "config.ncl",
|
2025-12-11 21:50:42 +00:00
|
|
|
"check_mode": false,
|
|
|
|
|
"wait": true
|
|
|
|
|
}
|
2026-01-08 09:55:37 +00:00
|
|
|
```plaintext
|
2025-12-11 21:50:42 +00:00
|
|
|
|
|
|
|
|
**Response:**
|
2026-01-08 09:55:37 +00:00
|
|
|
|
2025-12-11 21:50:42 +00:00
|
|
|
```json
|
|
|
|
|
{
|
|
|
|
|
"success": true,
|
|
|
|
|
"data": "uuid-task-id"
|
|
|
|
|
}
|
2026-01-08 09:55:37 +00:00
|
|
|
```plaintext
|
2025-12-11 21:50:42 +00:00
|
|
|
|
|
|
|
|
#### POST /workflows/cluster/create
|
2026-01-08 09:55:37 +00:00
|
|
|
|
2025-12-11 21:50:42 +00:00
|
|
|
Submit cluster workflow.
|
|
|
|
|
|
|
|
|
|
**Request Body:**
|
2026-01-08 09:55:37 +00:00
|
|
|
|
2025-12-11 21:50:42 +00:00
|
|
|
```json
|
|
|
|
|
{
|
|
|
|
|
"operation": "create",
|
|
|
|
|
"cluster_type": "buildkit",
|
|
|
|
|
"infra": "production",
|
2026-01-08 09:55:37 +00:00
|
|
|
"settings": "config.ncl",
|
2025-12-11 21:50:42 +00:00
|
|
|
"check_mode": false,
|
|
|
|
|
"wait": true
|
|
|
|
|
}
|
2026-01-08 09:55:37 +00:00
|
|
|
```plaintext
|
2025-12-11 21:50:42 +00:00
|
|
|
|
|
|
|
|
**Response:**
|
2026-01-08 09:55:37 +00:00
|
|
|
|
2025-12-11 21:50:42 +00:00
|
|
|
```json
|
|
|
|
|
{
|
|
|
|
|
"success": true,
|
|
|
|
|
"data": "uuid-task-id"
|
|
|
|
|
}
|
2026-01-08 09:55:37 +00:00
|
|
|
```plaintext
|
2025-12-11 21:50:42 +00:00
|
|
|
|
|
|
|
|
### Batch Operations
|
|
|
|
|
|
|
|
|
|
#### POST /batch/execute
|
2026-01-08 09:55:37 +00:00
|
|
|
|
2025-12-11 21:50:42 +00:00
|
|
|
Execute batch workflow operation.
|
|
|
|
|
|
|
|
|
|
**Request Body:**
|
2026-01-08 09:55:37 +00:00
|
|
|
|
2025-12-11 21:50:42 +00:00
|
|
|
```json
|
|
|
|
|
{
|
|
|
|
|
"name": "multi_cloud_deployment",
|
|
|
|
|
"version": "1.0.0",
|
|
|
|
|
"storage_backend": "surrealdb",
|
|
|
|
|
"parallel_limit": 5,
|
|
|
|
|
"rollback_enabled": true,
|
|
|
|
|
"operations": [
|
|
|
|
|
{
|
|
|
|
|
"id": "upcloud_servers",
|
|
|
|
|
"type": "server_batch",
|
|
|
|
|
"provider": "upcloud",
|
|
|
|
|
"dependencies": [],
|
|
|
|
|
"server_configs": [
|
2026-01-08 09:55:37 +00:00
|
|
|
{"name": "web-01", "plan": "1xCPU-2 GB", "zone": "de-fra1"},
|
|
|
|
|
{"name": "web-02", "plan": "1xCPU-2 GB", "zone": "us-nyc1"}
|
2025-12-11 21:50:42 +00:00
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"id": "aws_taskservs",
|
|
|
|
|
"type": "taskserv_batch",
|
|
|
|
|
"provider": "aws",
|
|
|
|
|
"dependencies": ["upcloud_servers"],
|
|
|
|
|
"taskservs": ["kubernetes", "cilium", "containerd"]
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
}
|
2026-01-08 09:55:37 +00:00
|
|
|
```plaintext
|
2025-12-11 21:50:42 +00:00
|
|
|
|
|
|
|
|
**Response:**
|
2026-01-08 09:55:37 +00:00
|
|
|
|
2025-12-11 21:50:42 +00:00
|
|
|
```json
|
|
|
|
|
{
|
|
|
|
|
"success": true,
|
|
|
|
|
"data": {
|
|
|
|
|
"batch_id": "uuid-string",
|
|
|
|
|
"status": "Running",
|
|
|
|
|
"operations": [
|
|
|
|
|
{
|
|
|
|
|
"id": "upcloud_servers",
|
|
|
|
|
"status": "Pending",
|
|
|
|
|
"progress": 0.0
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"id": "aws_taskservs",
|
|
|
|
|
"status": "Pending",
|
|
|
|
|
"progress": 0.0
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-01-08 09:55:37 +00:00
|
|
|
```plaintext
|
2025-12-11 21:50:42 +00:00
|
|
|
|
|
|
|
|
#### GET /batch/operations
|
2026-01-08 09:55:37 +00:00
|
|
|
|
2025-12-11 21:50:42 +00:00
|
|
|
List all batch operations.
|
|
|
|
|
|
|
|
|
|
**Response:**
|
2026-01-08 09:55:37 +00:00
|
|
|
|
2025-12-11 21:50:42 +00:00
|
|
|
```json
|
|
|
|
|
{
|
|
|
|
|
"success": true,
|
|
|
|
|
"data": [
|
|
|
|
|
{
|
|
|
|
|
"batch_id": "uuid-string",
|
|
|
|
|
"name": "multi_cloud_deployment",
|
|
|
|
|
"status": "Running",
|
|
|
|
|
"created_at": "2025-09-26T10:00:00Z",
|
|
|
|
|
"operations": [...]
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
}
|
2026-01-08 09:55:37 +00:00
|
|
|
```plaintext
|
2025-12-11 21:50:42 +00:00
|
|
|
|
|
|
|
|
#### GET /batch/operations/{id}
|
2026-01-08 09:55:37 +00:00
|
|
|
|
2025-12-11 21:50:42 +00:00
|
|
|
Get batch operation status.
|
|
|
|
|
|
|
|
|
|
**Path Parameters:**
|
2026-01-08 09:55:37 +00:00
|
|
|
|
2025-12-11 21:50:42 +00:00
|
|
|
- `id`: Batch operation ID
|
|
|
|
|
|
|
|
|
|
**Response:**
|
2026-01-08 09:55:37 +00:00
|
|
|
|
2025-12-11 21:50:42 +00:00
|
|
|
```json
|
|
|
|
|
{
|
|
|
|
|
"success": true,
|
|
|
|
|
"data": {
|
|
|
|
|
"batch_id": "uuid-string",
|
|
|
|
|
"name": "multi_cloud_deployment",
|
|
|
|
|
"status": "Running",
|
|
|
|
|
"operations": [
|
|
|
|
|
{
|
|
|
|
|
"id": "upcloud_servers",
|
|
|
|
|
"status": "Completed",
|
|
|
|
|
"progress": 100.0,
|
|
|
|
|
"results": {...}
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-01-08 09:55:37 +00:00
|
|
|
```plaintext
|
2025-12-11 21:50:42 +00:00
|
|
|
|
|
|
|
|
#### POST /batch/operations/{id}/cancel
|
2026-01-08 09:55:37 +00:00
|
|
|
|
2025-12-11 21:50:42 +00:00
|
|
|
Cancel running batch operation.
|
|
|
|
|
|
|
|
|
|
**Path Parameters:**
|
2026-01-08 09:55:37 +00:00
|
|
|
|
2025-12-11 21:50:42 +00:00
|
|
|
- `id`: Batch operation ID
|
|
|
|
|
|
|
|
|
|
**Response:**
|
2026-01-08 09:55:37 +00:00
|
|
|
|
2025-12-11 21:50:42 +00:00
|
|
|
```json
|
|
|
|
|
{
|
|
|
|
|
"success": true,
|
|
|
|
|
"data": "Operation cancelled"
|
|
|
|
|
}
|
2026-01-08 09:55:37 +00:00
|
|
|
```plaintext
|
2025-12-11 21:50:42 +00:00
|
|
|
|
|
|
|
|
### State Management
|
|
|
|
|
|
|
|
|
|
#### GET /state/workflows/{id}/progress
|
2026-01-08 09:55:37 +00:00
|
|
|
|
2025-12-11 21:50:42 +00:00
|
|
|
Get real-time workflow progress.
|
|
|
|
|
|
|
|
|
|
**Path Parameters:**
|
2026-01-08 09:55:37 +00:00
|
|
|
|
2025-12-11 21:50:42 +00:00
|
|
|
- `id`: Workflow ID
|
|
|
|
|
|
|
|
|
|
**Response:**
|
2026-01-08 09:55:37 +00:00
|
|
|
|
2025-12-11 21:50:42 +00:00
|
|
|
```json
|
|
|
|
|
{
|
|
|
|
|
"success": true,
|
|
|
|
|
"data": {
|
|
|
|
|
"workflow_id": "uuid-string",
|
|
|
|
|
"progress": 75.5,
|
|
|
|
|
"current_step": "Installing Kubernetes",
|
|
|
|
|
"total_steps": 8,
|
|
|
|
|
"completed_steps": 6,
|
|
|
|
|
"estimated_time_remaining": 180
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-01-08 09:55:37 +00:00
|
|
|
```plaintext
|
2025-12-11 21:50:42 +00:00
|
|
|
|
|
|
|
|
#### GET /state/workflows/{id}/snapshots
|
2026-01-08 09:55:37 +00:00
|
|
|
|
2025-12-11 21:50:42 +00:00
|
|
|
Get workflow state snapshots.
|
|
|
|
|
|
|
|
|
|
**Path Parameters:**
|
2026-01-08 09:55:37 +00:00
|
|
|
|
2025-12-11 21:50:42 +00:00
|
|
|
- `id`: Workflow ID
|
|
|
|
|
|
|
|
|
|
**Response:**
|
2026-01-08 09:55:37 +00:00
|
|
|
|
2025-12-11 21:50:42 +00:00
|
|
|
```json
|
|
|
|
|
{
|
|
|
|
|
"success": true,
|
|
|
|
|
"data": [
|
|
|
|
|
{
|
|
|
|
|
"snapshot_id": "uuid-string",
|
|
|
|
|
"timestamp": "2025-09-26T10:00:00Z",
|
|
|
|
|
"state": "running",
|
|
|
|
|
"details": {...}
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
}
|
2026-01-08 09:55:37 +00:00
|
|
|
```plaintext
|
2025-12-11 21:50:42 +00:00
|
|
|
|
|
|
|
|
#### GET /state/system/metrics
|
2026-01-08 09:55:37 +00:00
|
|
|
|
2025-12-11 21:50:42 +00:00
|
|
|
Get system-wide metrics.
|
|
|
|
|
|
|
|
|
|
**Response:**
|
2026-01-08 09:55:37 +00:00
|
|
|
|
2025-12-11 21:50:42 +00:00
|
|
|
```json
|
|
|
|
|
{
|
|
|
|
|
"success": true,
|
|
|
|
|
"data": {
|
|
|
|
|
"total_workflows": 150,
|
|
|
|
|
"active_workflows": 5,
|
|
|
|
|
"completed_workflows": 140,
|
|
|
|
|
"failed_workflows": 5,
|
|
|
|
|
"system_load": {
|
|
|
|
|
"cpu_usage": 45.2,
|
|
|
|
|
"memory_usage": 2048,
|
|
|
|
|
"disk_usage": 75.5
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-01-08 09:55:37 +00:00
|
|
|
```plaintext
|
2025-12-11 21:50:42 +00:00
|
|
|
|
|
|
|
|
#### GET /state/system/health
|
2026-01-08 09:55:37 +00:00
|
|
|
|
2025-12-11 21:50:42 +00:00
|
|
|
Get system health status.
|
|
|
|
|
|
|
|
|
|
**Response:**
|
2026-01-08 09:55:37 +00:00
|
|
|
|
2025-12-11 21:50:42 +00:00
|
|
|
```json
|
|
|
|
|
{
|
|
|
|
|
"success": true,
|
|
|
|
|
"data": {
|
|
|
|
|
"overall_status": "Healthy",
|
|
|
|
|
"components": {
|
|
|
|
|
"storage": "Healthy",
|
|
|
|
|
"batch_coordinator": "Healthy",
|
|
|
|
|
"monitoring": "Healthy"
|
|
|
|
|
},
|
|
|
|
|
"last_check": "2025-09-26T10:00:00Z"
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-01-08 09:55:37 +00:00
|
|
|
```plaintext
|
2025-12-11 21:50:42 +00:00
|
|
|
|
|
|
|
|
#### GET /state/statistics
|
2026-01-08 09:55:37 +00:00
|
|
|
|
2025-12-11 21:50:42 +00:00
|
|
|
Get state manager statistics.
|
|
|
|
|
|
|
|
|
|
**Response:**
|
2026-01-08 09:55:37 +00:00
|
|
|
|
2025-12-11 21:50:42 +00:00
|
|
|
```json
|
|
|
|
|
{
|
|
|
|
|
"success": true,
|
|
|
|
|
"data": {
|
|
|
|
|
"total_workflows": 150,
|
|
|
|
|
"active_snapshots": 25,
|
2026-01-08 09:55:37 +00:00
|
|
|
"storage_usage": "245 MB",
|
2025-12-11 21:50:42 +00:00
|
|
|
"average_workflow_duration": 300
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-01-08 09:55:37 +00:00
|
|
|
```plaintext
|
2025-12-11 21:50:42 +00:00
|
|
|
|
|
|
|
|
### Rollback and Recovery
|
|
|
|
|
|
|
|
|
|
#### POST /rollback/checkpoints
|
2026-01-08 09:55:37 +00:00
|
|
|
|
2025-12-11 21:50:42 +00:00
|
|
|
Create new checkpoint.
|
|
|
|
|
|
|
|
|
|
**Request Body:**
|
2026-01-08 09:55:37 +00:00
|
|
|
|
2025-12-11 21:50:42 +00:00
|
|
|
```json
|
|
|
|
|
{
|
|
|
|
|
"name": "before_major_update",
|
|
|
|
|
"description": "Checkpoint before deploying v2.0.0"
|
|
|
|
|
}
|
2026-01-08 09:55:37 +00:00
|
|
|
```plaintext
|
2025-12-11 21:50:42 +00:00
|
|
|
|
|
|
|
|
**Response:**
|
2026-01-08 09:55:37 +00:00
|
|
|
|
2025-12-11 21:50:42 +00:00
|
|
|
```json
|
|
|
|
|
{
|
|
|
|
|
"success": true,
|
|
|
|
|
"data": "checkpoint-uuid"
|
|
|
|
|
}
|
2026-01-08 09:55:37 +00:00
|
|
|
```plaintext
|
2025-12-11 21:50:42 +00:00
|
|
|
|
|
|
|
|
#### GET /rollback/checkpoints
|
2026-01-08 09:55:37 +00:00
|
|
|
|
2025-12-11 21:50:42 +00:00
|
|
|
List all checkpoints.
|
|
|
|
|
|
|
|
|
|
**Response:**
|
2026-01-08 09:55:37 +00:00
|
|
|
|
2025-12-11 21:50:42 +00:00
|
|
|
```json
|
|
|
|
|
{
|
|
|
|
|
"success": true,
|
|
|
|
|
"data": [
|
|
|
|
|
{
|
|
|
|
|
"id": "checkpoint-uuid",
|
|
|
|
|
"name": "before_major_update",
|
|
|
|
|
"description": "Checkpoint before deploying v2.0.0",
|
|
|
|
|
"created_at": "2025-09-26T10:00:00Z",
|
2026-01-08 09:55:37 +00:00
|
|
|
"size": "150 MB"
|
2025-12-11 21:50:42 +00:00
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
}
|
2026-01-08 09:55:37 +00:00
|
|
|
```plaintext
|
2025-12-11 21:50:42 +00:00
|
|
|
|
|
|
|
|
#### GET /rollback/checkpoints/{id}
|
2026-01-08 09:55:37 +00:00
|
|
|
|
2025-12-11 21:50:42 +00:00
|
|
|
Get specific checkpoint details.
|
|
|
|
|
|
|
|
|
|
**Path Parameters:**
|
2026-01-08 09:55:37 +00:00
|
|
|
|
2025-12-11 21:50:42 +00:00
|
|
|
- `id`: Checkpoint ID
|
|
|
|
|
|
|
|
|
|
**Response:**
|
2026-01-08 09:55:37 +00:00
|
|
|
|
2025-12-11 21:50:42 +00:00
|
|
|
```json
|
|
|
|
|
{
|
|
|
|
|
"success": true,
|
|
|
|
|
"data": {
|
|
|
|
|
"id": "checkpoint-uuid",
|
|
|
|
|
"name": "before_major_update",
|
|
|
|
|
"description": "Checkpoint before deploying v2.0.0",
|
|
|
|
|
"created_at": "2025-09-26T10:00:00Z",
|
2026-01-08 09:55:37 +00:00
|
|
|
"size": "150 MB",
|
2025-12-11 21:50:42 +00:00
|
|
|
"operations_count": 25
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-01-08 09:55:37 +00:00
|
|
|
```plaintext
|
2025-12-11 21:50:42 +00:00
|
|
|
|
|
|
|
|
#### POST /rollback/execute
|
2026-01-08 09:55:37 +00:00
|
|
|
|
2025-12-11 21:50:42 +00:00
|
|
|
Execute rollback operation.
|
|
|
|
|
|
|
|
|
|
**Request Body:**
|
2026-01-08 09:55:37 +00:00
|
|
|
|
2025-12-11 21:50:42 +00:00
|
|
|
```json
|
|
|
|
|
{
|
|
|
|
|
"checkpoint_id": "checkpoint-uuid"
|
|
|
|
|
}
|
2026-01-08 09:55:37 +00:00
|
|
|
```plaintext
|
2025-12-11 21:50:42 +00:00
|
|
|
|
|
|
|
|
Or for partial rollback:
|
2026-01-08 09:55:37 +00:00
|
|
|
|
2025-12-11 21:50:42 +00:00
|
|
|
```json
|
|
|
|
|
{
|
|
|
|
|
"operation_ids": ["op-1", "op-2", "op-3"]
|
|
|
|
|
}
|
2026-01-08 09:55:37 +00:00
|
|
|
```plaintext
|
2025-12-11 21:50:42 +00:00
|
|
|
|
|
|
|
|
**Response:**
|
2026-01-08 09:55:37 +00:00
|
|
|
|
2025-12-11 21:50:42 +00:00
|
|
|
```json
|
|
|
|
|
{
|
|
|
|
|
"success": true,
|
|
|
|
|
"data": {
|
|
|
|
|
"rollback_id": "rollback-uuid",
|
|
|
|
|
"success": true,
|
|
|
|
|
"operations_executed": 25,
|
|
|
|
|
"operations_failed": 0,
|
|
|
|
|
"duration": 45.5
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-01-08 09:55:37 +00:00
|
|
|
```plaintext
|
2025-12-11 21:50:42 +00:00
|
|
|
|
|
|
|
|
#### POST /rollback/restore/{id}
|
2026-01-08 09:55:37 +00:00
|
|
|
|
2025-12-11 21:50:42 +00:00
|
|
|
Restore system state from checkpoint.
|
|
|
|
|
|
|
|
|
|
**Path Parameters:**
|
2026-01-08 09:55:37 +00:00
|
|
|
|
2025-12-11 21:50:42 +00:00
|
|
|
- `id`: Checkpoint ID
|
|
|
|
|
|
|
|
|
|
**Response:**
|
2026-01-08 09:55:37 +00:00
|
|
|
|
2025-12-11 21:50:42 +00:00
|
|
|
```json
|
|
|
|
|
{
|
|
|
|
|
"success": true,
|
|
|
|
|
"data": "State restored from checkpoint checkpoint-uuid"
|
|
|
|
|
}
|
2026-01-08 09:55:37 +00:00
|
|
|
```plaintext
|
2025-12-11 21:50:42 +00:00
|
|
|
|
|
|
|
|
#### GET /rollback/statistics
|
2026-01-08 09:55:37 +00:00
|
|
|
|
2025-12-11 21:50:42 +00:00
|
|
|
Get rollback system statistics.
|
|
|
|
|
|
|
|
|
|
**Response:**
|
2026-01-08 09:55:37 +00:00
|
|
|
|
2025-12-11 21:50:42 +00:00
|
|
|
```json
|
|
|
|
|
{
|
|
|
|
|
"success": true,
|
|
|
|
|
"data": {
|
|
|
|
|
"total_checkpoints": 10,
|
|
|
|
|
"total_rollbacks": 3,
|
|
|
|
|
"success_rate": 100.0,
|
|
|
|
|
"average_rollback_time": 30.5
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-01-08 09:55:37 +00:00
|
|
|
```plaintext
|
2025-12-11 21:50:42 +00:00
|
|
|
|
|
|
|
|
## Control Center API Endpoints
|
|
|
|
|
|
|
|
|
|
### Authentication
|
|
|
|
|
|
|
|
|
|
#### POST /auth/login
|
2026-01-08 09:55:37 +00:00
|
|
|
|
2025-12-11 21:50:42 +00:00
|
|
|
Authenticate user and get JWT token.
|
|
|
|
|
|
|
|
|
|
**Request Body:**
|
2026-01-08 09:55:37 +00:00
|
|
|
|
2025-12-11 21:50:42 +00:00
|
|
|
```json
|
|
|
|
|
{
|
|
|
|
|
"username": "admin",
|
|
|
|
|
"password": "secure_password",
|
|
|
|
|
"mfa_code": "123456"
|
|
|
|
|
}
|
2026-01-08 09:55:37 +00:00
|
|
|
```plaintext
|
2025-12-11 21:50:42 +00:00
|
|
|
|
|
|
|
|
**Response:**
|
2026-01-08 09:55:37 +00:00
|
|
|
|
2025-12-11 21:50:42 +00:00
|
|
|
```json
|
|
|
|
|
{
|
|
|
|
|
"success": true,
|
|
|
|
|
"data": {
|
|
|
|
|
"token": "jwt-token-string",
|
|
|
|
|
"expires_at": "2025-09-26T18:00:00Z",
|
|
|
|
|
"user": {
|
|
|
|
|
"id": "user-uuid",
|
|
|
|
|
"username": "admin",
|
|
|
|
|
"email": "admin@example.com",
|
|
|
|
|
"roles": ["admin", "operator"]
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-01-08 09:55:37 +00:00
|
|
|
```plaintext
|
2025-12-11 21:50:42 +00:00
|
|
|
|
|
|
|
|
#### POST /auth/refresh
|
2026-01-08 09:55:37 +00:00
|
|
|
|
2025-12-11 21:50:42 +00:00
|
|
|
Refresh JWT token.
|
|
|
|
|
|
|
|
|
|
**Request Body:**
|
2026-01-08 09:55:37 +00:00
|
|
|
|
2025-12-11 21:50:42 +00:00
|
|
|
```json
|
|
|
|
|
{
|
|
|
|
|
"token": "current-jwt-token"
|
|
|
|
|
}
|
2026-01-08 09:55:37 +00:00
|
|
|
```plaintext
|
2025-12-11 21:50:42 +00:00
|
|
|
|
|
|
|
|
**Response:**
|
2026-01-08 09:55:37 +00:00
|
|
|
|
2025-12-11 21:50:42 +00:00
|
|
|
```json
|
|
|
|
|
{
|
|
|
|
|
"success": true,
|
|
|
|
|
"data": {
|
|
|
|
|
"token": "new-jwt-token",
|
|
|
|
|
"expires_at": "2025-09-26T18:00:00Z"
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-01-08 09:55:37 +00:00
|
|
|
```plaintext
|
2025-12-11 21:50:42 +00:00
|
|
|
|
|
|
|
|
#### POST /auth/logout
|
2026-01-08 09:55:37 +00:00
|
|
|
|
2025-12-11 21:50:42 +00:00
|
|
|
Logout and invalidate token.
|
|
|
|
|
|
|
|
|
|
**Response:**
|
2026-01-08 09:55:37 +00:00
|
|
|
|
2025-12-11 21:50:42 +00:00
|
|
|
```json
|
|
|
|
|
{
|
|
|
|
|
"success": true,
|
|
|
|
|
"data": "Successfully logged out"
|
|
|
|
|
}
|
2026-01-08 09:55:37 +00:00
|
|
|
```plaintext
|
2025-12-11 21:50:42 +00:00
|
|
|
|
|
|
|
|
### User Management
|
|
|
|
|
|
|
|
|
|
#### GET /users
|
2026-01-08 09:55:37 +00:00
|
|
|
|
2025-12-11 21:50:42 +00:00
|
|
|
List all users.
|
|
|
|
|
|
|
|
|
|
**Query Parameters:**
|
2026-01-08 09:55:37 +00:00
|
|
|
|
2025-12-11 21:50:42 +00:00
|
|
|
- `role` (optional): Filter by role
|
|
|
|
|
- `enabled` (optional): Filter by enabled status
|
|
|
|
|
|
|
|
|
|
**Response:**
|
2026-01-08 09:55:37 +00:00
|
|
|
|
2025-12-11 21:50:42 +00:00
|
|
|
```json
|
|
|
|
|
{
|
|
|
|
|
"success": true,
|
|
|
|
|
"data": [
|
|
|
|
|
{
|
|
|
|
|
"id": "user-uuid",
|
|
|
|
|
"username": "admin",
|
|
|
|
|
"email": "admin@example.com",
|
|
|
|
|
"roles": ["admin"],
|
|
|
|
|
"enabled": true,
|
|
|
|
|
"created_at": "2025-09-26T10:00:00Z",
|
|
|
|
|
"last_login": "2025-09-26T12:00:00Z"
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
}
|
2026-01-08 09:55:37 +00:00
|
|
|
```plaintext
|
2025-12-11 21:50:42 +00:00
|
|
|
|
|
|
|
|
#### POST /users
|
2026-01-08 09:55:37 +00:00
|
|
|
|
2025-12-11 21:50:42 +00:00
|
|
|
Create new user.
|
|
|
|
|
|
|
|
|
|
**Request Body:**
|
2026-01-08 09:55:37 +00:00
|
|
|
|
2025-12-11 21:50:42 +00:00
|
|
|
```json
|
|
|
|
|
{
|
|
|
|
|
"username": "newuser",
|
|
|
|
|
"email": "newuser@example.com",
|
|
|
|
|
"password": "secure_password",
|
|
|
|
|
"roles": ["operator"],
|
|
|
|
|
"enabled": true
|
|
|
|
|
}
|
2026-01-08 09:55:37 +00:00
|
|
|
```plaintext
|
2025-12-11 21:50:42 +00:00
|
|
|
|
|
|
|
|
**Response:**
|
2026-01-08 09:55:37 +00:00
|
|
|
|
2025-12-11 21:50:42 +00:00
|
|
|
```json
|
|
|
|
|
{
|
|
|
|
|
"success": true,
|
|
|
|
|
"data": {
|
|
|
|
|
"id": "new-user-uuid",
|
|
|
|
|
"username": "newuser",
|
|
|
|
|
"email": "newuser@example.com",
|
|
|
|
|
"roles": ["operator"],
|
|
|
|
|
"enabled": true
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-01-08 09:55:37 +00:00
|
|
|
```plaintext
|
2025-12-11 21:50:42 +00:00
|
|
|
|
|
|
|
|
#### PUT /users/{id}
|
2026-01-08 09:55:37 +00:00
|
|
|
|
2025-12-11 21:50:42 +00:00
|
|
|
Update existing user.
|
|
|
|
|
|
|
|
|
|
**Path Parameters:**
|
2026-01-08 09:55:37 +00:00
|
|
|
|
2025-12-11 21:50:42 +00:00
|
|
|
- `id`: User ID
|
|
|
|
|
|
|
|
|
|
**Request Body:**
|
2026-01-08 09:55:37 +00:00
|
|
|
|
2025-12-11 21:50:42 +00:00
|
|
|
```json
|
|
|
|
|
{
|
|
|
|
|
"email": "updated@example.com",
|
|
|
|
|
"roles": ["admin", "operator"],
|
|
|
|
|
"enabled": false
|
|
|
|
|
}
|
2026-01-08 09:55:37 +00:00
|
|
|
```plaintext
|
2025-12-11 21:50:42 +00:00
|
|
|
|
|
|
|
|
**Response:**
|
2026-01-08 09:55:37 +00:00
|
|
|
|
2025-12-11 21:50:42 +00:00
|
|
|
```json
|
|
|
|
|
{
|
|
|
|
|
"success": true,
|
|
|
|
|
"data": "User updated successfully"
|
|
|
|
|
}
|
2026-01-08 09:55:37 +00:00
|
|
|
```plaintext
|
2025-12-11 21:50:42 +00:00
|
|
|
|
|
|
|
|
#### DELETE /users/{id}
|
2026-01-08 09:55:37 +00:00
|
|
|
|
2025-12-11 21:50:42 +00:00
|
|
|
Delete user.
|
|
|
|
|
|
|
|
|
|
**Path Parameters:**
|
2026-01-08 09:55:37 +00:00
|
|
|
|
2025-12-11 21:50:42 +00:00
|
|
|
- `id`: User ID
|
|
|
|
|
|
|
|
|
|
**Response:**
|
2026-01-08 09:55:37 +00:00
|
|
|
|
2025-12-11 21:50:42 +00:00
|
|
|
```json
|
|
|
|
|
{
|
|
|
|
|
"success": true,
|
|
|
|
|
"data": "User deleted successfully"
|
|
|
|
|
}
|
2026-01-08 09:55:37 +00:00
|
|
|
```plaintext
|
2025-12-11 21:50:42 +00:00
|
|
|
|
|
|
|
|
### Policy Management
|
|
|
|
|
|
|
|
|
|
#### GET /policies
|
2026-01-08 09:55:37 +00:00
|
|
|
|
2025-12-11 21:50:42 +00:00
|
|
|
List all policies.
|
|
|
|
|
|
|
|
|
|
**Response:**
|
2026-01-08 09:55:37 +00:00
|
|
|
|
2025-12-11 21:50:42 +00:00
|
|
|
```json
|
|
|
|
|
{
|
|
|
|
|
"success": true,
|
|
|
|
|
"data": [
|
|
|
|
|
{
|
|
|
|
|
"id": "policy-uuid",
|
|
|
|
|
"name": "admin_access_policy",
|
|
|
|
|
"version": "1.0.0",
|
|
|
|
|
"rules": [...],
|
|
|
|
|
"created_at": "2025-09-26T10:00:00Z",
|
|
|
|
|
"enabled": true
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
}
|
2026-01-08 09:55:37 +00:00
|
|
|
```plaintext
|
2025-12-11 21:50:42 +00:00
|
|
|
|
|
|
|
|
#### POST /policies
|
2026-01-08 09:55:37 +00:00
|
|
|
|
2025-12-11 21:50:42 +00:00
|
|
|
Create new policy.
|
|
|
|
|
|
|
|
|
|
**Request Body:**
|
2026-01-08 09:55:37 +00:00
|
|
|
|
2025-12-11 21:50:42 +00:00
|
|
|
```json
|
|
|
|
|
{
|
|
|
|
|
"name": "new_policy",
|
|
|
|
|
"version": "1.0.0",
|
|
|
|
|
"rules": [
|
|
|
|
|
{
|
|
|
|
|
"effect": "Allow",
|
|
|
|
|
"resource": "servers:*",
|
|
|
|
|
"action": ["create", "read"],
|
|
|
|
|
"condition": "user.role == 'admin'"
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
}
|
2026-01-08 09:55:37 +00:00
|
|
|
```plaintext
|
2025-12-11 21:50:42 +00:00
|
|
|
|
|
|
|
|
**Response:**
|
2026-01-08 09:55:37 +00:00
|
|
|
|
2025-12-11 21:50:42 +00:00
|
|
|
```json
|
|
|
|
|
{
|
|
|
|
|
"success": true,
|
|
|
|
|
"data": {
|
|
|
|
|
"id": "new-policy-uuid",
|
|
|
|
|
"name": "new_policy",
|
|
|
|
|
"version": "1.0.0"
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-01-08 09:55:37 +00:00
|
|
|
```plaintext
|
2025-12-11 21:50:42 +00:00
|
|
|
|
|
|
|
|
#### PUT /policies/{id}
|
2026-01-08 09:55:37 +00:00
|
|
|
|
2025-12-11 21:50:42 +00:00
|
|
|
Update policy.
|
|
|
|
|
|
|
|
|
|
**Path Parameters:**
|
2026-01-08 09:55:37 +00:00
|
|
|
|
2025-12-11 21:50:42 +00:00
|
|
|
- `id`: Policy ID
|
|
|
|
|
|
|
|
|
|
**Request Body:**
|
2026-01-08 09:55:37 +00:00
|
|
|
|
2025-12-11 21:50:42 +00:00
|
|
|
```json
|
|
|
|
|
{
|
|
|
|
|
"name": "updated_policy",
|
|
|
|
|
"rules": [...]
|
|
|
|
|
}
|
2026-01-08 09:55:37 +00:00
|
|
|
```plaintext
|
2025-12-11 21:50:42 +00:00
|
|
|
|
|
|
|
|
**Response:**
|
2026-01-08 09:55:37 +00:00
|
|
|
|
2025-12-11 21:50:42 +00:00
|
|
|
```json
|
|
|
|
|
{
|
|
|
|
|
"success": true,
|
|
|
|
|
"data": "Policy updated successfully"
|
|
|
|
|
}
|
2026-01-08 09:55:37 +00:00
|
|
|
```plaintext
|
2025-12-11 21:50:42 +00:00
|
|
|
|
|
|
|
|
### Audit Logging
|
|
|
|
|
|
|
|
|
|
#### GET /audit/logs
|
2026-01-08 09:55:37 +00:00
|
|
|
|
2025-12-11 21:50:42 +00:00
|
|
|
Get audit logs.
|
|
|
|
|
|
|
|
|
|
**Query Parameters:**
|
2026-01-08 09:55:37 +00:00
|
|
|
|
2025-12-11 21:50:42 +00:00
|
|
|
- `user_id` (optional): Filter by user
|
|
|
|
|
- `action` (optional): Filter by action
|
|
|
|
|
- `resource` (optional): Filter by resource
|
|
|
|
|
- `from` (optional): Start date (ISO 8601)
|
|
|
|
|
- `to` (optional): End date (ISO 8601)
|
|
|
|
|
- `limit` (optional): Maximum results
|
|
|
|
|
- `offset` (optional): Pagination offset
|
|
|
|
|
|
|
|
|
|
**Response:**
|
2026-01-08 09:55:37 +00:00
|
|
|
|
2025-12-11 21:50:42 +00:00
|
|
|
```json
|
|
|
|
|
{
|
|
|
|
|
"success": true,
|
|
|
|
|
"data": [
|
|
|
|
|
{
|
|
|
|
|
"id": "audit-log-uuid",
|
|
|
|
|
"timestamp": "2025-09-26T10:00:00Z",
|
|
|
|
|
"user_id": "user-uuid",
|
|
|
|
|
"action": "server.create",
|
|
|
|
|
"resource": "servers/web-01",
|
|
|
|
|
"result": "success",
|
|
|
|
|
"details": {...}
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
}
|
2026-01-08 09:55:37 +00:00
|
|
|
```plaintext
|
2025-12-11 21:50:42 +00:00
|
|
|
|
|
|
|
|
## Error Responses
|
|
|
|
|
|
|
|
|
|
All endpoints may return error responses in this format:
|
|
|
|
|
|
|
|
|
|
```json
|
|
|
|
|
{
|
|
|
|
|
"success": false,
|
|
|
|
|
"error": "Detailed error message"
|
|
|
|
|
}
|
2026-01-08 09:55:37 +00:00
|
|
|
```plaintext
|
2025-12-11 21:50:42 +00:00
|
|
|
|
|
|
|
|
### HTTP Status Codes
|
|
|
|
|
|
|
|
|
|
- `200 OK`: Successful request
|
|
|
|
|
- `201 Created`: Resource created successfully
|
|
|
|
|
- `400 Bad Request`: Invalid request parameters
|
|
|
|
|
- `401 Unauthorized`: Authentication required or invalid
|
|
|
|
|
- `403 Forbidden`: Permission denied
|
|
|
|
|
- `404 Not Found`: Resource not found
|
|
|
|
|
- `422 Unprocessable Entity`: Validation error
|
|
|
|
|
- `500 Internal Server Error`: Server error
|
|
|
|
|
|
|
|
|
|
## Rate Limiting
|
|
|
|
|
|
|
|
|
|
API endpoints are rate-limited:
|
2026-01-08 09:55:37 +00:00
|
|
|
|
2025-12-11 21:50:42 +00:00
|
|
|
- Authentication: 5 requests per minute per IP
|
|
|
|
|
- General APIs: 100 requests per minute per user
|
|
|
|
|
- Batch operations: 10 requests per minute per user
|
|
|
|
|
|
|
|
|
|
Rate limit headers are included in responses:
|
2026-01-08 09:55:37 +00:00
|
|
|
|
2025-12-11 21:50:42 +00:00
|
|
|
```http
|
|
|
|
|
X-RateLimit-Limit: 100
|
|
|
|
|
X-RateLimit-Remaining: 95
|
|
|
|
|
X-RateLimit-Reset: 1632150000
|
2026-01-08 09:55:37 +00:00
|
|
|
```plaintext
|
2025-12-11 21:50:42 +00:00
|
|
|
|
|
|
|
|
## Monitoring Endpoints
|
|
|
|
|
|
|
|
|
|
### GET /metrics
|
2026-01-08 09:55:37 +00:00
|
|
|
|
2025-12-11 21:50:42 +00:00
|
|
|
Prometheus-compatible metrics endpoint.
|
|
|
|
|
|
|
|
|
|
**Response:**
|
2026-01-08 09:55:37 +00:00
|
|
|
|
|
|
|
|
```plaintext
|
2025-12-11 21:50:42 +00:00
|
|
|
# HELP orchestrator_tasks_total Total number of tasks
|
|
|
|
|
# TYPE orchestrator_tasks_total counter
|
|
|
|
|
orchestrator_tasks_total{status="completed"} 150
|
|
|
|
|
orchestrator_tasks_total{status="failed"} 5
|
|
|
|
|
|
|
|
|
|
# HELP orchestrator_task_duration_seconds Task execution duration
|
|
|
|
|
# TYPE orchestrator_task_duration_seconds histogram
|
|
|
|
|
orchestrator_task_duration_seconds_bucket{le="10"} 50
|
|
|
|
|
orchestrator_task_duration_seconds_bucket{le="30"} 120
|
|
|
|
|
orchestrator_task_duration_seconds_bucket{le="+Inf"} 155
|
2026-01-08 09:55:37 +00:00
|
|
|
```plaintext
|
2025-12-11 21:50:42 +00:00
|
|
|
|
|
|
|
|
### WebSocket /ws
|
2026-01-08 09:55:37 +00:00
|
|
|
|
2025-12-11 21:50:42 +00:00
|
|
|
Real-time event streaming via WebSocket connection.
|
|
|
|
|
|
|
|
|
|
**Connection:**
|
2026-01-08 09:55:37 +00:00
|
|
|
|
2025-12-11 21:50:42 +00:00
|
|
|
```javascript
|
|
|
|
|
const ws = new WebSocket('ws://localhost:9090/ws?token=jwt-token');
|
|
|
|
|
|
|
|
|
|
ws.onmessage = function(event) {
|
|
|
|
|
const data = JSON.parse(event.data);
|
|
|
|
|
console.log('Event:', data);
|
|
|
|
|
};
|
2026-01-08 09:55:37 +00:00
|
|
|
```plaintext
|
2025-12-11 21:50:42 +00:00
|
|
|
|
|
|
|
|
**Event Format:**
|
2026-01-08 09:55:37 +00:00
|
|
|
|
2025-12-11 21:50:42 +00:00
|
|
|
```json
|
|
|
|
|
{
|
|
|
|
|
"event_type": "TaskStatusChanged",
|
|
|
|
|
"timestamp": "2025-09-26T10:00:00Z",
|
|
|
|
|
"data": {
|
|
|
|
|
"task_id": "uuid-string",
|
|
|
|
|
"status": "completed"
|
|
|
|
|
},
|
|
|
|
|
"metadata": {
|
|
|
|
|
"task_id": "uuid-string",
|
|
|
|
|
"status": "completed"
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-01-08 09:55:37 +00:00
|
|
|
```plaintext
|
2025-12-11 21:50:42 +00:00
|
|
|
|
|
|
|
|
## SDK Examples
|
|
|
|
|
|
|
|
|
|
### Python SDK Example
|
2026-01-08 09:55:37 +00:00
|
|
|
|
2025-12-11 21:50:42 +00:00
|
|
|
```python
|
|
|
|
|
import requests
|
|
|
|
|
|
|
|
|
|
class ProvisioningClient:
|
|
|
|
|
def __init__(self, base_url, token):
|
|
|
|
|
self.base_url = base_url
|
|
|
|
|
self.headers = {
|
|
|
|
|
'Authorization': f'Bearer {token}',
|
|
|
|
|
'Content-Type': 'application/json'
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
def create_server_workflow(self, infra, settings, check_mode=False):
|
|
|
|
|
payload = {
|
|
|
|
|
'infra': infra,
|
|
|
|
|
'settings': settings,
|
|
|
|
|
'check_mode': check_mode,
|
|
|
|
|
'wait': True
|
|
|
|
|
}
|
|
|
|
|
response = requests.post(
|
|
|
|
|
f'{self.base_url}/workflows/servers/create',
|
|
|
|
|
json=payload,
|
|
|
|
|
headers=self.headers
|
|
|
|
|
)
|
|
|
|
|
return response.json()
|
|
|
|
|
|
|
|
|
|
def get_task_status(self, task_id):
|
|
|
|
|
response = requests.get(
|
|
|
|
|
f'{self.base_url}/tasks/{task_id}',
|
|
|
|
|
headers=self.headers
|
|
|
|
|
)
|
|
|
|
|
return response.json()
|
|
|
|
|
|
|
|
|
|
# Usage
|
|
|
|
|
client = ProvisioningClient('http://localhost:9090', 'your-jwt-token')
|
2026-01-08 09:55:37 +00:00
|
|
|
result = client.create_server_workflow('production', 'config.ncl')
|
2025-12-11 21:50:42 +00:00
|
|
|
print(f"Task ID: {result['data']}")
|
2026-01-08 09:55:37 +00:00
|
|
|
```plaintext
|
2025-12-11 21:50:42 +00:00
|
|
|
|
|
|
|
|
### JavaScript/Node.js SDK Example
|
2026-01-08 09:55:37 +00:00
|
|
|
|
2025-12-11 21:50:42 +00:00
|
|
|
```javascript
|
|
|
|
|
const axios = require('axios');
|
|
|
|
|
|
|
|
|
|
class ProvisioningClient {
|
|
|
|
|
constructor(baseUrl, token) {
|
|
|
|
|
this.client = axios.create({
|
|
|
|
|
baseURL: baseUrl,
|
|
|
|
|
headers: {
|
|
|
|
|
'Authorization': `Bearer ${token}`,
|
|
|
|
|
'Content-Type': 'application/json'
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async createServerWorkflow(infra, settings, checkMode = false) {
|
|
|
|
|
const response = await this.client.post('/workflows/servers/create', {
|
|
|
|
|
infra,
|
|
|
|
|
settings,
|
|
|
|
|
check_mode: checkMode,
|
|
|
|
|
wait: true
|
|
|
|
|
});
|
|
|
|
|
return response.data;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async getTaskStatus(taskId) {
|
|
|
|
|
const response = await this.client.get(`/tasks/${taskId}`);
|
|
|
|
|
return response.data;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Usage
|
|
|
|
|
const client = new ProvisioningClient('http://localhost:9090', 'your-jwt-token');
|
2026-01-08 09:55:37 +00:00
|
|
|
const result = await client.createServerWorkflow('production', 'config.ncl');
|
2025-12-11 21:50:42 +00:00
|
|
|
console.log(`Task ID: ${result.data}`);
|
2026-01-08 09:55:37 +00:00
|
|
|
```plaintext
|
2025-12-11 21:50:42 +00:00
|
|
|
|
|
|
|
|
## Webhook Integration
|
|
|
|
|
|
|
|
|
|
The system supports webhooks for external integrations:
|
|
|
|
|
|
|
|
|
|
### Webhook Configuration
|
2026-01-08 09:55:37 +00:00
|
|
|
|
2025-12-11 21:50:42 +00:00
|
|
|
Configure webhooks in the system configuration:
|
2026-01-08 09:55:37 +00:00
|
|
|
|
2025-12-11 21:50:42 +00:00
|
|
|
```toml
|
|
|
|
|
[webhooks]
|
|
|
|
|
enabled = true
|
|
|
|
|
endpoints = [
|
|
|
|
|
{
|
|
|
|
|
url = "https://your-system.com/webhook"
|
|
|
|
|
events = ["task.completed", "task.failed", "batch.completed"]
|
|
|
|
|
secret = "webhook-secret"
|
|
|
|
|
}
|
|
|
|
|
]
|
2026-01-08 09:55:37 +00:00
|
|
|
```plaintext
|
2025-12-11 21:50:42 +00:00
|
|
|
|
|
|
|
|
### Webhook Payload
|
2026-01-08 09:55:37 +00:00
|
|
|
|
2025-12-11 21:50:42 +00:00
|
|
|
```json
|
|
|
|
|
{
|
|
|
|
|
"event": "task.completed",
|
|
|
|
|
"timestamp": "2025-09-26T10:00:00Z",
|
|
|
|
|
"data": {
|
|
|
|
|
"task_id": "uuid-string",
|
|
|
|
|
"status": "completed",
|
|
|
|
|
"output": "Task completed successfully"
|
|
|
|
|
},
|
|
|
|
|
"signature": "sha256=calculated-signature"
|
|
|
|
|
}
|
2026-01-08 09:55:37 +00:00
|
|
|
```plaintext
|
2025-12-11 21:50:42 +00:00
|
|
|
|
|
|
|
|
## Pagination
|
|
|
|
|
|
|
|
|
|
For endpoints that return lists, use pagination parameters:
|
2026-01-08 09:55:37 +00:00
|
|
|
|
2025-12-11 21:50:42 +00:00
|
|
|
- `limit`: Maximum number of items per page (default: 50, max: 1000)
|
|
|
|
|
- `offset`: Number of items to skip
|
|
|
|
|
|
|
|
|
|
Pagination metadata is included in response headers:
|
2026-01-08 09:55:37 +00:00
|
|
|
|
2025-12-11 21:50:42 +00:00
|
|
|
```http
|
|
|
|
|
X-Total-Count: 1500
|
|
|
|
|
X-Limit: 50
|
|
|
|
|
X-Offset: 100
|
|
|
|
|
Link: </api/endpoint?offset=150&limit=50>; rel="next"
|
2026-01-08 09:55:37 +00:00
|
|
|
```plaintext
|
2025-12-11 21:50:42 +00:00
|
|
|
|
|
|
|
|
## API Versioning
|
|
|
|
|
|
|
|
|
|
The API uses header-based versioning:
|
2026-01-08 09:55:37 +00:00
|
|
|
|
2025-12-11 21:50:42 +00:00
|
|
|
```http
|
|
|
|
|
Accept: application/vnd.provisioning.v1+json
|
2026-01-08 09:55:37 +00:00
|
|
|
```plaintext
|
2025-12-11 21:50:42 +00:00
|
|
|
|
|
|
|
|
Current version: v1
|
|
|
|
|
|
|
|
|
|
## Testing
|
|
|
|
|
|
|
|
|
|
Use the included test suite to validate API functionality:
|
2026-01-08 09:55:37 +00:00
|
|
|
|
2025-12-11 21:50:42 +00:00
|
|
|
```bash
|
|
|
|
|
# Run API integration tests
|
|
|
|
|
cd src/orchestrator
|
|
|
|
|
cargo test --test api_tests
|
|
|
|
|
|
|
|
|
|
# Run load tests
|
|
|
|
|
cargo test --test load_tests --release
|
2026-01-08 09:55:37 +00:00
|
|
|
```plaintext
|