;
This commit is contained in:
1 parent
9268833a3c
commit
314b7445a1
27 files changed
+1830
No files matched your search
@@ -0,0 +1,409 @@
|
||||
# Chronos API Documentation
|
||||
|
||||
This document describes the REST API endpoints available in Chronos.
|
||||
|
||||
## Versioning
|
||||
|
||||
All API endpoints are prefixed with `/api/v1/`.
|
||||
|
||||
## Authentication
|
||||
|
||||
All API requests require authentication. Include an `Authorization` header with a valid session token:
|
||||
|
||||
```
|
||||
Authorization: Bearer <session_token>
|
||||
```
|
||||
|
||||
## Error Responses
|
||||
|
||||
All error responses use standard HTTP status codes and include a JSON body with error details:
|
||||
|
||||
```json
|
||||
{
|
||||
"error": {
|
||||
"code": "VALIDATION_ERROR",
|
||||
"message": "Validation failed",
|
||||
"details": [
|
||||
{
|
||||
"field": "name",
|
||||
"reason": "Name is required"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Endpoints
|
||||
|
||||
### Authentication
|
||||
|
||||
#### POST `/api/v1/auth/login`
|
||||
Authenticate a user.
|
||||
|
||||
**Request:**
|
||||
```json
|
||||
{
|
||||
"username": "admin",
|
||||
"password": "secret"
|
||||
}
|
||||
```
|
||||
|
||||
**Response (200):**
|
||||
```json
|
||||
{
|
||||
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
|
||||
}
|
||||
```
|
||||
|
||||
#### POST `/api/v1/auth/logout`
|
||||
Logout the current user.
|
||||
|
||||
**Response (204):**
|
||||
|
||||
#### GET `/api/v1/auth/me`
|
||||
Get current user information.
|
||||
|
||||
**Response (200):**
|
||||
```json
|
||||
{
|
||||
"id": "1",
|
||||
"username": "admin",
|
||||
"role": "administrator"
|
||||
}
|
||||
```
|
||||
|
||||
### Users
|
||||
|
||||
#### GET `/api/v1/users`
|
||||
List all users.
|
||||
|
||||
**Response (200):**
|
||||
```json
|
||||
[
|
||||
{
|
||||
"id": "1",
|
||||
"username": "admin",
|
||||
"role": "administrator",
|
||||
"created_at": "2023-01-01T00:00:00Z"
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
#### POST `/api/v1/users`
|
||||
Create a new user.
|
||||
|
||||
**Request:**
|
||||
```json
|
||||
{
|
||||
"username": "operator",
|
||||
"password": "secret",
|
||||
"role": "operator"
|
||||
}
|
||||
```
|
||||
|
||||
**Response (201):**
|
||||
```json
|
||||
{
|
||||
"id": "2",
|
||||
"username": "operator",
|
||||
"role": "operator",
|
||||
"created_at": "2023-01-01T00:00:00Z"
|
||||
}
|
||||
```
|
||||
|
||||
#### GET `/api/v1/users/{id}`
|
||||
Get a specific user.
|
||||
|
||||
**Response (200):**
|
||||
```json
|
||||
{
|
||||
"id": "2",
|
||||
"username": "operator",
|
||||
"role": "operator",
|
||||
"created_at": "2023-01-01T00:00:00Z"
|
||||
}
|
||||
```
|
||||
|
||||
#### PUT `/api/v1/users/{id}`
|
||||
Update a user.
|
||||
|
||||
**Request:**
|
||||
```json
|
||||
{
|
||||
"role": "administrator"
|
||||
}
|
||||
```
|
||||
|
||||
**Response (200):**
|
||||
```json
|
||||
{
|
||||
"id": "2",
|
||||
"username": "operator",
|
||||
"role": "administrator",
|
||||
"created_at": "2023-01-01T00:00:00Z"
|
||||
}
|
||||
```
|
||||
|
||||
#### DELETE `/api/v1/users/{id}`
|
||||
Delete a user.
|
||||
|
||||
**Response (204):**
|
||||
|
||||
### Workflows
|
||||
|
||||
#### GET `/api/v1/workflows`
|
||||
List all workflows.
|
||||
|
||||
**Response (200):**
|
||||
```json
|
||||
[
|
||||
{
|
||||
"id": "1",
|
||||
"name": "Backup Workflow",
|
||||
"description": "Daily backup job",
|
||||
"created_at": "2023-01-01T00:00:00Z",
|
||||
"updated_at": "2023-01-01T00:00:00Z"
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
#### POST `/api/v1/workflows`
|
||||
Create a new workflow.
|
||||
|
||||
**Request:**
|
||||
```json
|
||||
{
|
||||
"name": "Backup Workflow",
|
||||
"description": "Daily backup job",
|
||||
"nodes": [
|
||||
{
|
||||
"id": "1",
|
||||
"type": "command",
|
||||
"config": {
|
||||
"command": "tar -czf /backups/backup-$(date +\\%Y\\%m\\%d).tar.gz /home"
|
||||
}
|
||||
}
|
||||
],
|
||||
"edges": []
|
||||
}
|
||||
```
|
||||
|
||||
**Response (201):**
|
||||
```json
|
||||
{
|
||||
"id": "1",
|
||||
"name": "Backup Workflow",
|
||||
"description": "Daily backup job",
|
||||
"created_at": "2023-01-01T00:00:00Z",
|
||||
"updated_at": "2023-01-01T00:00:00Z"
|
||||
}
|
||||
```
|
||||
|
||||
#### GET `/api/v1/workflows/{id}`
|
||||
Get a specific workflow.
|
||||
|
||||
**Response (200):**
|
||||
```json
|
||||
{
|
||||
"id": "1",
|
||||
"name": "Backup Workflow",
|
||||
"description": "Daily backup job",
|
||||
"nodes": [
|
||||
{
|
||||
"id": "1",
|
||||
"type": "command",
|
||||
"config": {
|
||||
"command": "tar -czf /backups/backup-$(date +\\%Y\\%m\\%d).tar.gz /home"
|
||||
}
|
||||
}
|
||||
],
|
||||
"edges": [],
|
||||
"created_at": "2023-01-01T00:00:00Z",
|
||||
"updated_at": "2023-01-01T00:00:00Z"
|
||||
}
|
||||
```
|
||||
|
||||
#### PUT `/api/v1/workflows/{id}`
|
||||
Update a workflow.
|
||||
|
||||
**Request:**
|
||||
```json
|
||||
{
|
||||
"name": "Updated Backup Workflow",
|
||||
"description": "Daily backup job with better compression"
|
||||
}
|
||||
```
|
||||
|
||||
**Response (200):**
|
||||
```json
|
||||
{
|
||||
"id": "1",
|
||||
"name": "Updated Backup Workflow",
|
||||
"description": "Daily backup job with better compression",
|
||||
"created_at": "2023-01-01T00:00:00Z",
|
||||
"updated_at": "2023-01-01T00:00:00Z"
|
||||
}
|
||||
```
|
||||
|
||||
#### DELETE `/api/v1/workflows/{id}`
|
||||
Delete a workflow.
|
||||
|
||||
**Response (204):**
|
||||
|
||||
### Schedules
|
||||
|
||||
#### GET `/api/v1/schedules`
|
||||
List all schedules.
|
||||
|
||||
**Response (200):**
|
||||
```json
|
||||
[
|
||||
{
|
||||
"id": "1",
|
||||
"workflow_id": "1",
|
||||
"name": "Daily Backup",
|
||||
"cron_expression": "0 0 * * *",
|
||||
"enabled": true,
|
||||
"created_at": "2023-01-01T00:00:00Z"
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
#### POST `/api/v1/schedules`
|
||||
Create a new schedule.
|
||||
|
||||
**Request:**
|
||||
```json
|
||||
{
|
||||
"workflow_id": "1",
|
||||
"name": "Daily Backup",
|
||||
"cron_expression": "0 0 * * *",
|
||||
"enabled": true
|
||||
}
|
||||
```
|
||||
|
||||
**Response (201):**
|
||||
```json
|
||||
{
|
||||
"id": "1",
|
||||
"workflow_id": "1",
|
||||
"name": "Daily Backup",
|
||||
"cron_expression": "0 0 * * *",
|
||||
"enabled": true,
|
||||
"created_at": "2023-01-01T00:00:00Z"
|
||||
}
|
||||
```
|
||||
|
||||
#### GET `/api/v1/schedules/{id}`
|
||||
Get a specific schedule.
|
||||
|
||||
**Response (200):**
|
||||
```json
|
||||
{
|
||||
"id": "1",
|
||||
"workflow_id": "1",
|
||||
"name": "Daily Backup",
|
||||
"cron_expression": "0 0 * * *",
|
||||
"enabled": true,
|
||||
"created_at": "2023-01-01T00:00:00Z"
|
||||
}
|
||||
```
|
||||
|
||||
#### PUT `/api/v1/schedules/{id}`
|
||||
Update a schedule.
|
||||
|
||||
**Request:**
|
||||
```json
|
||||
{
|
||||
"name": "Weekly Backup",
|
||||
"cron_expression": "0 0 * * 0"
|
||||
}
|
||||
```
|
||||
|
||||
**Response (200):**
|
||||
```json
|
||||
{
|
||||
"id": "1",
|
||||
"workflow_id": "1",
|
||||
"name": "Weekly Backup",
|
||||
"cron_expression": "0 0 * * 0",
|
||||
"enabled": true,
|
||||
"created_at": "2023-01-01T00:00:00Z"
|
||||
}
|
||||
```
|
||||
|
||||
#### DELETE `/api/v1/schedules/{id}`
|
||||
Delete a schedule.
|
||||
|
||||
**Response (204):**
|
||||
|
||||
### Executions
|
||||
|
||||
#### GET `/api/v1/executions`
|
||||
List all executions.
|
||||
|
||||
**Response (200):**
|
||||
```json
|
||||
[
|
||||
{
|
||||
"id": "1",
|
||||
"workflow_id": "1",
|
||||
"schedule_id": "1",
|
||||
"status": "completed",
|
||||
"started_at": "2023-01-01T00:00:00Z",
|
||||
"finished_at": "2023-01-01T00:00:05Z"
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
#### GET `/api/v1/executions/{id}`
|
||||
Get a specific execution.
|
||||
|
||||
**Response (200):**
|
||||
```json
|
||||
{
|
||||
"id": "1",
|
||||
"workflow_id": "1",
|
||||
"schedule_id": "1",
|
||||
"status": "completed",
|
||||
"started_at": "2023-01-01T00:00:00Z",
|
||||
"finished_at": "2023-01-01T00:00:05Z",
|
||||
"logs": [
|
||||
{
|
||||
"timestamp": "2023-01-01T00:00:00Z",
|
||||
"level": "info",
|
||||
"message": "Starting backup job"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### Workers
|
||||
|
||||
#### GET `/api/v1/workers`
|
||||
List all workers.
|
||||
|
||||
**Response (200):**
|
||||
```json
|
||||
[
|
||||
{
|
||||
"id": "1",
|
||||
"name": "worker-1",
|
||||
"status": "online",
|
||||
"last_heartbeat": "2023-01-01T00:00:00Z"
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
### Health
|
||||
|
||||
#### GET `/api/v1/health`
|
||||
Check service health.
|
||||
|
||||
**Response (200):**
|
||||
```json
|
||||
{
|
||||
"status": "healthy",
|
||||
"timestamp": "2023-01-01T00:00:00Z"
|
||||
}
|
||||
```
|
||||
Reference in new issue
Block a user