Migrate from uuid to name

This commit is contained in:
2025-07-19 11:21:12 +02:00
parent c8e623ae7b
commit 13bbf07465
10 changed files with 1151 additions and 158 deletions

View File

@@ -19,6 +19,327 @@ const docTemplate = `{
"host": "{{.Host}}",
"basePath": "{{.BasePath}}",
"paths": {
"/instances": {
"get": {
"description": "Returns a list of all instances managed by the server",
"produces": [
"application/json"
],
"tags": [
"instances"
],
"summary": "List all instances",
"responses": {
"200": {
"description": "List of instances",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/llamactl.Instance"
}
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"type": "string"
}
}
}
},
"post": {
"description": "Creates a new instance with the provided configuration options",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"instances"
],
"summary": "Create and start a new instance",
"parameters": [
{
"description": "Instance configuration options",
"name": "options",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/llamactl.InstanceOptions"
}
}
],
"responses": {
"201": {
"description": "Created instance details",
"schema": {
"$ref": "#/definitions/llamactl.Instance"
}
},
"400": {
"description": "Invalid request body",
"schema": {
"type": "string"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"type": "string"
}
}
}
}
},
"/instances/{name}": {
"get": {
"description": "Returns the details of a specific instance by name",
"tags": [
"instances"
],
"summary": "Get details of a specific instance",
"parameters": [
{
"type": "string",
"description": "Instance Name",
"name": "name",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "Instance details",
"schema": {
"$ref": "#/definitions/llamactl.Instance"
}
},
"400": {
"description": "Invalid name format",
"schema": {
"type": "string"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"type": "string"
}
}
}
},
"put": {
"description": "Updates the configuration of a specific instance by name",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"instances"
],
"summary": "Update an instance's configuration",
"parameters": [
{
"type": "string",
"description": "Instance Name",
"name": "name",
"in": "path",
"required": true
},
{
"description": "Instance configuration options",
"name": "options",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/llamactl.InstanceOptions"
}
}
],
"responses": {
"200": {
"description": "Updated instance details",
"schema": {
"$ref": "#/definitions/llamactl.Instance"
}
},
"400": {
"description": "Invalid name format",
"schema": {
"type": "string"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"type": "string"
}
}
}
},
"delete": {
"description": "Stops and removes a specific instance by name",
"produces": [
"application/json"
],
"tags": [
"instances"
],
"summary": "Delete an instance",
"parameters": [
{
"type": "string",
"description": "Instance Name",
"name": "name",
"in": "path",
"required": true
}
],
"responses": {
"204": {
"description": "No Content"
},
"400": {
"description": "Invalid name format",
"schema": {
"type": "string"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"type": "string"
}
}
}
}
},
"/instances/{name}/restart": {
"post": {
"description": "Restarts a specific instance by name",
"produces": [
"application/json"
],
"tags": [
"instances"
],
"summary": "Restart a running instance",
"parameters": [
{
"type": "string",
"description": "Instance Name",
"name": "name",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "Restarted instance details",
"schema": {
"$ref": "#/definitions/llamactl.Instance"
}
},
"400": {
"description": "Invalid name format",
"schema": {
"type": "string"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"type": "string"
}
}
}
}
},
"/instances/{name}/start": {
"post": {
"description": "Starts a specific instance by name",
"produces": [
"application/json"
],
"tags": [
"instances"
],
"summary": "Start a stopped instance",
"parameters": [
{
"type": "string",
"description": "Instance Name",
"name": "name",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "Started instance details",
"schema": {
"$ref": "#/definitions/llamactl.Instance"
}
},
"400": {
"description": "Invalid name format",
"schema": {
"type": "string"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"type": "string"
}
}
}
}
},
"/instances/{name}/stop": {
"post": {
"description": "Stops a specific instance by name",
"produces": [
"application/json"
],
"tags": [
"instances"
],
"summary": "Stop a running instance",
"parameters": [
{
"type": "string",
"description": "Instance Name",
"name": "name",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "Stopped instance details",
"schema": {
"$ref": "#/definitions/llamactl.Instance"
}
},
"400": {
"description": "Invalid name format",
"schema": {
"type": "string"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"type": "string"
}
}
}
}
},
"/server/devices": {
"get": {
"description": "Returns a list of available devices for the llama server",
@@ -88,6 +409,31 @@ const docTemplate = `{
}
}
}
},
"definitions": {
"llamactl.Instance": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"running": {
"description": "Status",
"type": "boolean"
},
"stdErrChan": {
"description": "Channel for sending error messages",
"type": "object"
},
"stdOutChan": {
"description": "Output channels",
"type": "object"
}
}
},
"llamactl.InstanceOptions": {
"type": "object"
}
}
}`
@@ -97,8 +443,8 @@ var SwaggerInfo = &swag.Spec{
Host: "",
BasePath: "/api/v1",
Schemes: []string{},
Title: "Llama Server Control",
Description: "This is a control server for managing Llama Server instances.",
Title: "llamactl API",
Description: "llamactl is a control server for managing Llama Server instances.",
InfoInstanceName: "swagger",
SwaggerTemplate: docTemplate,
LeftDelim: "{{",