{
    "openapi": "3.0.0",
    "info": {
        "title": "TurboStack API",
        "contact": {
            "email": "support@hosted-power.com"
        },
        "version": "v1"
    },
    "paths": {
        "/api/v1/clients": {
            "get": {
                "tags": [
                    "Clients"
                ],
                "summary": "List of all clients",
                "description": "List clients",
                "operationId": "clients",
                "parameters": [
                    {
                        "name": "size",
                        "in": "query",
                        "description": "Number of items per page",
                        "required": false,
                        "schema": {
                            "type": "integer",
                            "default": 15
                        }
                    },
                    {
                        "name": "page",
                        "in": "query",
                        "description": "Page number for pagination",
                        "required": false,
                        "schema": {
                            "type": "integer",
                            "default": 1
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Lists of Clients",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "array",
                                    "items": {
                                        "properties": {
                                            "id": {
                                                "type": "number"
                                            },
                                            "firstname": {
                                                "type": "string"
                                            },
                                            "lastname": {
                                                "type": "string"
                                            },
                                            "email": {
                                                "type": "string"
                                            },
                                            "created_at": {
                                                "type": "string",
                                                "format": "date-time"
                                            },
                                            "updated_at": {
                                                "type": "string",
                                                "format": "date-time"
                                            }
                                        },
                                        "type": "object"
                                    }
                                }
                            }
                        }
                    }
                },
                "security": [
                    {
                        "bearerAuth": []
                    }
                ]
            }
        },
        "/api/v1/clients/{id}": {
            "get": {
                "tags": [
                    "Clients"
                ],
                "summary": "Fetch one specific client",
                "description": "Fetch a specific client by ID",
                "operationId": "client/id",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "description": "ID of the client",
                        "required": true,
                        "schema": {
                            "type": "integer",
                            "format": "int64"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "One Client",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "properties": {
                                        "id": {
                                            "type": "number"
                                        },
                                        "firstname": {
                                            "type": "string"
                                        },
                                        "lastname": {
                                            "type": "string"
                                        },
                                        "email": {
                                            "type": "string"
                                        },
                                        "created_at": {
                                            "type": "string",
                                            "format": "date-time"
                                        },
                                        "updated_at": {
                                            "type": "string",
                                            "format": "date-time"
                                        }
                                    },
                                    "type": "object"
                                }
                            }
                        }
                    }
                },
                "security": [
                    {
                        "bearerAuth": []
                    }
                ]
            }
        },
        "/api/v1/clients/{id}/hosts": {
            "get": {
                "tags": [
                    "Clients"
                ],
                "summary": "Get all hosts of client",
                "description": "Lists hosts by client",
                "operationId": "clients/id/hosts",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "description": "ID of the client",
                        "required": true,
                        "schema": {
                            "type": "integer",
                            "format": "int64"
                        }
                    },
                    {
                        "name": "size",
                        "in": "query",
                        "description": "Number of items per page",
                        "required": false,
                        "schema": {
                            "type": "integer",
                            "default": 15
                        }
                    },
                    {
                        "name": "page",
                        "in": "query",
                        "description": "Page number for pagination",
                        "required": false,
                        "schema": {
                            "type": "integer",
                            "default": 1
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Lists hosts of Client",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "array",
                                    "items": {
                                        "properties": {
                                            "id": {
                                                "type": "number"
                                            },
                                            "client_id": {
                                                "type": "number"
                                            },
                                            "active": {
                                                "type": "number"
                                            },
                                            "name": {
                                                "type": "string"
                                            },
                                            "json": {
                                                "format": "string"
                                            },
                                            "created_at": {
                                                "type": "string",
                                                "format": "date-time"
                                            },
                                            "updated_at": {
                                                "type": "string",
                                                "format": "date-time"
                                            },
                                            "monitoring": {
                                                "description": "Live server status read from Redis (populated by icinga-monitoring:sync)",
                                                "properties": {
                                                    "load": {
                                                        "type": "object"
                                                    },
                                                    "disk": {
                                                        "type": "object"
                                                    },
                                                    "memory": {
                                                        "type": "object"
                                                    }
                                                },
                                                "type": "object"
                                            }
                                        },
                                        "type": "object"
                                    }
                                }
                            }
                        }
                    }
                },
                "security": [
                    {
                        "bearerAuth": []
                    }
                ]
            }
        },
        "/api/v1/clients/{id}/groups": {
            "get": {
                "tags": [
                    "Clients"
                ],
                "summary": "Get all groups of client",
                "description": "List groups by client",
                "operationId": "clients/id/groups",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "description": "ID of the client",
                        "required": true,
                        "schema": {
                            "type": "integer",
                            "format": "int64"
                        }
                    },
                    {
                        "name": "size",
                        "in": "query",
                        "description": "Number of items per page",
                        "required": false,
                        "schema": {
                            "type": "integer",
                            "default": 15
                        }
                    },
                    {
                        "name": "page",
                        "in": "query",
                        "description": "Page number for pagination",
                        "required": false,
                        "schema": {
                            "type": "integer",
                            "default": 1
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Lists groups of Client",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "array",
                                    "items": {
                                        "properties": {
                                            "id": {
                                                "type": "number"
                                            },
                                            "client_id": {
                                                "type": "number"
                                            },
                                            "name": {
                                                "type": "string"
                                            },
                                            "json": {
                                                "format": "string"
                                            },
                                            "created_at": {
                                                "type": "string",
                                                "format": "date-time"
                                            },
                                            "updated_at": {
                                                "type": "string",
                                                "format": "date-time"
                                            }
                                        },
                                        "type": "object"
                                    }
                                }
                            }
                        }
                    }
                },
                "security": [
                    {
                        "bearerAuth": []
                    }
                ]
            }
        },
        "/api/v1/hosts": {
            "get": {
                "tags": [
                    "Hosts"
                ],
                "summary": "List of all hosts",
                "description": "List hosts",
                "operationId": "hosts",
                "parameters": [
                    {
                        "name": "size",
                        "in": "query",
                        "description": "Number of items per page",
                        "required": false,
                        "schema": {
                            "type": "integer",
                            "default": 15
                        }
                    },
                    {
                        "name": "page",
                        "in": "query",
                        "description": "Page number for pagination",
                        "required": false,
                        "schema": {
                            "type": "integer",
                            "default": 1
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Lists of Hosts",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "array",
                                    "items": {
                                        "properties": {
                                            "id": {
                                                "type": "number"
                                            },
                                            "client_id": {
                                                "type": "number"
                                            },
                                            "active": {
                                                "type": "number"
                                            },
                                            "name": {
                                                "type": "string"
                                            },
                                            "json": {
                                                "format": "string"
                                            },
                                            "created_at": {
                                                "type": "string",
                                                "format": "date-time"
                                            },
                                            "updated_at": {
                                                "type": "string",
                                                "format": "date-time"
                                            },
                                            "monitoring": {
                                                "description": "Live server status read from Redis (populated by icinga-monitoring:sync)",
                                                "properties": {
                                                    "load": {
                                                        "type": "object"
                                                    },
                                                    "disk": {
                                                        "type": "object"
                                                    },
                                                    "memory": {
                                                        "type": "object"
                                                    }
                                                },
                                                "type": "object"
                                            }
                                        },
                                        "type": "object"
                                    }
                                }
                            }
                        }
                    }
                },
                "security": [
                    {
                        "bearerAuth": []
                    }
                ]
            }
        },
        "/api/v1/hosts/{id}": {
            "get": {
                "tags": [
                    "Hosts"
                ],
                "summary": "Fetch one specific host",
                "description": "Host detail",
                "operationId": "hosts/id",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "description": "ID of the Host",
                        "required": true,
                        "schema": {
                            "type": "integer",
                            "format": "int64"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Lists of Hosts",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "properties": {
                                        "id": {
                                            "type": "number"
                                        },
                                        "client_id": {
                                            "type": "number"
                                        },
                                        "active": {
                                            "type": "number"
                                        },
                                        "name": {
                                            "type": "string"
                                        },
                                        "json": {
                                            "format": "string"
                                        },
                                        "created_at": {
                                            "type": "string",
                                            "format": "date-time"
                                        },
                                        "updated_at": {
                                            "type": "string",
                                            "format": "date-time"
                                        },
                                        "monitoring": {
                                            "description": "Live server status read from Redis (populated by icinga-monitoring:sync)",
                                            "properties": {
                                                "load": {
                                                    "type": "object"
                                                },
                                                "disk": {
                                                    "type": "object"
                                                },
                                                "memory": {
                                                    "type": "object"
                                                }
                                            },
                                            "type": "object"
                                        }
                                    },
                                    "type": "object"
                                }
                            }
                        }
                    }
                },
                "security": [
                    {
                        "bearerAuth": []
                    }
                ]
            },
            "post": {
                "tags": [
                    "Hosts"
                ],
                "summary": "Update JSON (configuration) of host",
                "description": "Save host",
                "operationId": "hosts/id/save",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "description": "ID of the Host",
                        "required": true,
                        "schema": {
                            "type": "integer",
                            "format": "int64"
                        }
                    }
                ],
                "requestBody": {
                    "content": {
                        "application/json": {
                            "schema": {
                                "required": [
                                    "json"
                                ],
                                "properties": {
                                    "json": {
                                        "type": "object"
                                    }
                                },
                                "type": "object"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Saved Successfully",
                        "content": {
                            "application/json": {
                                "schema": {}
                            }
                        }
                    }
                },
                "security": [
                    {
                        "bearerAuth": []
                    }
                ]
            }
        },
        "/api/v1/hosts/{id}/deploy": {
            "get": {
                "tags": [
                    "Hosts"
                ],
                "summary": "Get status of deploy",
                "description": "Get deploy status",
                "operationId": "hosts/id/deploy-status",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "description": "ID of the Host",
                        "required": true,
                        "schema": {
                            "type": "integer",
                            "format": "int64"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Deploy Status",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                }
                            }
                        }
                    }
                },
                "security": [
                    {
                        "bearerAuth": []
                    }
                ]
            },
            "post": {
                "tags": [
                    "Hosts"
                ],
                "summary": "Start deploy of host",
                "description": "Start deploy of host",
                "operationId": "hosts/id/deploy-start",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "description": "ID of the Host",
                        "required": true,
                        "schema": {
                            "type": "integer",
                            "format": "int64"
                        }
                    }
                ],
                "requestBody": {
                    "content": {
                        "application/json": {
                            "schema": {
                                "required": [
                                    "type"
                                ],
                                "properties": {
                                    "type": {
                                        "description": "Type of deployment to execute",
                                        "type": "string",
                                        "enum": [
                                            "deploy",
                                            "fullDeploy",
                                            "fullResetDeploy"
                                        ]
                                    }
                                },
                                "type": "object"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Deploy Started",
                        "content": {
                            "application/json": {
                                "schema": {}
                            }
                        }
                    }
                },
                "security": [
                    {
                        "bearerAuth": []
                    }
                ]
            }
        },
        "/api/v1/groups": {
            "get": {
                "tags": [
                    "Groups"
                ],
                "summary": "List of all groups",
                "description": "List Groups",
                "operationId": "groups",
                "parameters": [
                    {
                        "name": "size",
                        "in": "query",
                        "description": "Number of items per page",
                        "required": false,
                        "schema": {
                            "type": "integer",
                            "default": 15
                        }
                    },
                    {
                        "name": "page",
                        "in": "query",
                        "description": "Page number for pagination",
                        "required": false,
                        "schema": {
                            "type": "integer",
                            "default": 1
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "List of Groups",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "array",
                                    "items": {
                                        "properties": {
                                            "id": {
                                                "type": "number"
                                            },
                                            "name": {
                                                "type": "string"
                                            },
                                            "json": {
                                                "format": "string"
                                            },
                                            "created_at": {
                                                "type": "string",
                                                "format": "date-time"
                                            },
                                            "updated_at": {
                                                "type": "string",
                                                "format": "date-time"
                                            }
                                        },
                                        "type": "object"
                                    }
                                }
                            }
                        }
                    }
                },
                "security": [
                    {
                        "bearerAuth": []
                    }
                ]
            }
        },
        "/api/v1/groups/{id}": {
            "get": {
                "tags": [
                    "Groups"
                ],
                "summary": "Fetch one specific group",
                "description": "Group detail",
                "operationId": "groups/id",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "description": "ID of the Group",
                        "required": true,
                        "schema": {
                            "type": "integer",
                            "format": "int64"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Object of Group",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "properties": {
                                        "id": {
                                            "type": "number"
                                        },
                                        "name": {
                                            "type": "string"
                                        },
                                        "json": {
                                            "format": "string"
                                        },
                                        "created_at": {
                                            "type": "string",
                                            "format": "date-time"
                                        },
                                        "updated_at": {
                                            "type": "string",
                                            "format": "date-time"
                                        }
                                    },
                                    "type": "object"
                                }
                            }
                        }
                    }
                },
                "security": [
                    {
                        "bearerAuth": []
                    }
                ]
            },
            "post": {
                "tags": [
                    "Groups"
                ],
                "summary": "Save or update a specific group",
                "description": "Save Group",
                "operationId": "saveGroup",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "description": "ID of the Group",
                        "required": true,
                        "schema": {
                            "type": "integer",
                            "format": "int64"
                        }
                    }
                ],
                "requestBody": {
                    "content": {
                        "application/json": {
                            "schema": {
                                "required": [
                                    "json"
                                ],
                                "properties": {
                                    "json": {
                                        "type": "object"
                                    }
                                },
                                "type": "object"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Group ID after saving",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "integer"
                                },
                                "example": 1
                            }
                        }
                    },
                    "403": {
                        "description": "Forbidden",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "string"
                                },
                                "example": "Forbidden"
                            }
                        }
                    },
                    "404": {
                        "description": "Group not found",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "properties": {
                                        "error": {
                                            "type": "string",
                                            "example": "Group not found"
                                        }
                                    },
                                    "type": "object"
                                }
                            }
                        }
                    }
                },
                "security": [
                    {
                        "bearerAuth": []
                    }
                ]
            }
        },
        "/api/v1/hosts/{id}/credentials": {
            "get": {
                "tags": [
                    "Hosts"
                ],
                "summary": "Get credentials for a specific host",
                "description": "Get host credentials from Vault + YAML",
                "operationId": "hosts/id/credentials",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "description": "ID of the Host",
                        "required": true,
                        "schema": {
                            "type": "integer",
                            "format": "int64"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Host credentials and configuration",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "Unauthorized"
                    },
                    "403": {
                        "description": "Forbidden"
                    },
                    "404": {
                        "description": "Host not found"
                    },
                    "500": {
                        "description": "Internal server error"
                    }
                },
                "security": [
                    {
                        "bearerAuth": []
                    }
                ]
            }
        }
    },
    "components": {
        "securitySchemes": {
            "bearerAuth": {
                "type": "apiKey",
                "description": "Enter token in format: Bearer {your-token}",
                "name": "Authorization",
                "in": "header"
            }
        }
    },
    "tags": [
        {
            "name": "Clients",
            "description": "Clients"
        },
        {
            "name": "Hosts",
            "description": "Hosts"
        },
        {
            "name": "Groups",
            "description": "Groups"
        }
    ]
}