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

@@ -1121,6 +1121,365 @@ const docTemplate = `{
}
}
},
"/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": [
@@ -1844,6 +2203,92 @@ const docTemplate = `{
}
}
},
"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": {

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": {

View File

@@ -243,6 +243,64 @@ definitions:
slug:
type: string
type: object
servers.createServerRequest:
properties:
hostname:
type: string
ip_address:
type: string
role:
example: master|worker|bastion
type: string
ssh_key_id:
type: string
ssh_user:
type: string
status:
example: pending|provisioning|ready|failed
type: string
type: object
servers.serverResponse:
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
type: object
servers.updateServerRequest:
properties:
hostname:
type: string
ip_address:
type: string
role:
example: master|worker|bastion
type: string
ssh_key_id:
type: string
ssh_user:
type: string
status:
description: 'enum: pending,provisioning,ready,failed'
example: pending|provisioning|ready|failed
type: string
type: object
ssh.createSSHRequest:
properties:
bits:
@@ -1003,6 +1061,241 @@ paths:
summary: Remove member from organization
tags:
- organizations
/api/v1/servers:
get:
consumes:
- application/json
description: 'Returns servers for the organization in X-Org-ID. Optional filters:
status, role.'
parameters:
- description: Organization UUID
in: header
name: X-Org-ID
required: true
type: string
- description: Filter by status (pending|provisioning|ready|failed)
in: query
name: status
type: string
- description: Filter by role
in: query
name: role
type: string
produces:
- application/json
responses:
"200":
description: OK
schema:
items:
$ref: '#/definitions/servers.serverResponse'
type: array
"401":
description: Unauthorized
schema:
type: string
"403":
description: organization required
schema:
type: string
"500":
description: failed to list servers
schema:
type: string
security:
- BearerAuth: []
summary: List servers (org scoped)
tags:
- servers
post:
consumes:
- application/json
description: Creates a server bound to the org in X-Org-ID. Validates that ssh_key_id
belongs to the org.
parameters:
- description: Organization UUID
in: header
name: X-Org-ID
required: true
type: string
- description: Server payload
in: body
name: body
required: true
schema:
$ref: '#/definitions/servers.createServerRequest'
produces:
- application/json
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
security:
- BearerAuth: []
summary: Create server (org scoped)
tags:
- servers
/api/v1/servers/{id}:
delete:
consumes:
- application/json
description: Permanently deletes the server.
parameters:
- description: Organization UUID
in: header
name: X-Org-ID
required: true
type: string
- description: Server ID (UUID)
in: path
name: id
required: true
type: string
produces:
- application/json
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
security:
- BearerAuth: []
summary: Delete server (org scoped)
tags:
- servers
get:
consumes:
- application/json
description: Returns one server in the given organization.
parameters:
- description: Organization UUID
in: header
name: X-Org-ID
required: true
type: string
- description: Server ID (UUID)
in: path
name: id
required: true
type: string
produces:
- application/json
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
security:
- BearerAuth: []
summary: Get server by ID (org scoped)
tags:
- servers
patch:
consumes:
- application/json
description: Partially update fields; changing ssh_key_id validates ownership.
parameters:
- description: Organization UUID
in: header
name: X-Org-ID
required: true
type: string
- description: Server ID (UUID)
in: path
name: id
required: true
type: string
- description: Fields to update
in: body
name: body
required: true
schema:
$ref: '#/definitions/servers.updateServerRequest'
produces:
- application/json
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
security:
- BearerAuth: []
summary: Update server (org scoped)
tags:
- servers
/api/v1/ssh:
get:
consumes: