Servers Page & API

This commit is contained in:
allanice001
2025-09-01 23:53:48 +01:00
parent 5425ed5dcc
commit 7f29580d3b
20 changed files with 2350 additions and 49 deletions

View File

@@ -1117,6 +1117,365 @@
}
}
},
"/api/v1/servers": {
"get": {
"security": [
{
"BearerAuth": []
}
],
"description": "Returns servers for the organization in X-Org-ID. Optional filters: status, role.",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"servers"
],
"summary": "List servers (org scoped)",
"parameters": [
{
"type": "string",
"description": "Organization UUID",
"name": "X-Org-ID",
"in": "header",
"required": true
},
{
"type": "string",
"description": "Filter by status (pending|provisioning|ready|failed)",
"name": "status",
"in": "query"
},
{
"type": "string",
"description": "Filter by role",
"name": "role",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/servers.serverResponse"
}
}
},
"401": {
"description": "Unauthorized",
"schema": {
"type": "string"
}
},
"403": {
"description": "organization required",
"schema": {
"type": "string"
}
},
"500": {
"description": "failed to list servers",
"schema": {
"type": "string"
}
}
}
},
"post": {
"security": [
{
"BearerAuth": []
}
],
"description": "Creates a server bound to the org in X-Org-ID. Validates that ssh_key_id belongs to the org.",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"servers"
],
"summary": "Create server (org scoped)",
"parameters": [
{
"type": "string",
"description": "Organization UUID",
"name": "X-Org-ID",
"in": "header",
"required": true
},
{
"description": "Server payload",
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/servers.createServerRequest"
}
}
],
"responses": {
"201": {
"description": "Created",
"schema": {
"$ref": "#/definitions/servers.serverResponse"
}
},
"400": {
"description": "invalid json / missing fields / invalid status / invalid ssh_key_id",
"schema": {
"type": "string"
}
},
"401": {
"description": "Unauthorized",
"schema": {
"type": "string"
}
},
"403": {
"description": "organization required",
"schema": {
"type": "string"
}
},
"500": {
"description": "create failed",
"schema": {
"type": "string"
}
}
}
}
},
"/api/v1/servers/{id}": {
"get": {
"security": [
{
"BearerAuth": []
}
],
"description": "Returns one server in the given organization.",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"servers"
],
"summary": "Get server by ID (org scoped)",
"parameters": [
{
"type": "string",
"description": "Organization UUID",
"name": "X-Org-ID",
"in": "header",
"required": true
},
{
"type": "string",
"description": "Server ID (UUID)",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/servers.serverResponse"
}
},
"400": {
"description": "invalid id",
"schema": {
"type": "string"
}
},
"401": {
"description": "Unauthorized",
"schema": {
"type": "string"
}
},
"403": {
"description": "organization required",
"schema": {
"type": "string"
}
},
"404": {
"description": "not found",
"schema": {
"type": "string"
}
},
"500": {
"description": "fetch failed",
"schema": {
"type": "string"
}
}
}
},
"delete": {
"security": [
{
"BearerAuth": []
}
],
"description": "Permanently deletes the server.",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"servers"
],
"summary": "Delete server (org scoped)",
"parameters": [
{
"type": "string",
"description": "Organization UUID",
"name": "X-Org-ID",
"in": "header",
"required": true
},
{
"type": "string",
"description": "Server ID (UUID)",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"204": {
"description": "No Content",
"schema": {
"type": "string"
}
},
"400": {
"description": "invalid id",
"schema": {
"type": "string"
}
},
"401": {
"description": "Unauthorized",
"schema": {
"type": "string"
}
},
"403": {
"description": "organization required",
"schema": {
"type": "string"
}
},
"500": {
"description": "delete failed",
"schema": {
"type": "string"
}
}
}
},
"patch": {
"security": [
{
"BearerAuth": []
}
],
"description": "Partially update fields; changing ssh_key_id validates ownership.",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"servers"
],
"summary": "Update server (org scoped)",
"parameters": [
{
"type": "string",
"description": "Organization UUID",
"name": "X-Org-ID",
"in": "header",
"required": true
},
{
"type": "string",
"description": "Server ID (UUID)",
"name": "id",
"in": "path",
"required": true
},
{
"description": "Fields to update",
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/servers.updateServerRequest"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/servers.serverResponse"
}
},
"400": {
"description": "invalid id / invalid json / invalid status / invalid ssh_key_id",
"schema": {
"type": "string"
}
},
"401": {
"description": "Unauthorized",
"schema": {
"type": "string"
}
},
"403": {
"description": "organization required",
"schema": {
"type": "string"
}
},
"404": {
"description": "not found",
"schema": {
"type": "string"
}
},
"500": {
"description": "update failed",
"schema": {
"type": "string"
}
}
}
}
},
"/api/v1/ssh": {
"get": {
"security": [
@@ -1840,6 +2199,92 @@
}
}
},
"servers.createServerRequest": {
"type": "object",
"properties": {
"hostname": {
"type": "string"
},
"ip_address": {
"type": "string"
},
"role": {
"type": "string",
"example": "master|worker|bastion"
},
"ssh_key_id": {
"type": "string"
},
"ssh_user": {
"type": "string"
},
"status": {
"type": "string",
"example": "pending|provisioning|ready|failed"
}
}
},
"servers.serverResponse": {
"type": "object",
"properties": {
"created_at": {
"type": "string"
},
"hostname": {
"type": "string"
},
"id": {
"type": "string"
},
"ip_address": {
"type": "string"
},
"organization_id": {
"type": "string"
},
"role": {
"type": "string"
},
"ssh_key_id": {
"type": "string"
},
"ssh_user": {
"type": "string"
},
"status": {
"type": "string"
},
"updated_at": {
"type": "string"
}
}
},
"servers.updateServerRequest": {
"type": "object",
"properties": {
"hostname": {
"type": "string"
},
"ip_address": {
"type": "string"
},
"role": {
"type": "string",
"example": "master|worker|bastion"
},
"ssh_key_id": {
"type": "string"
},
"ssh_user": {
"type": "string"
},
"status": {
"description": "enum: pending,provisioning,ready,failed",
"type": "string",
"example": "pending|provisioning|ready|failed"
}
}
},
"ssh.createSSHRequest": {
"type": "object",
"properties": {