mcsmapi

package module
v1.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 16, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

README

MCSManager API Go SDK

MCSManager API Go SDK is a client library for Go that provides convenient access to the MCSManager API (a panel for managing Minecraft and other servers). The SDK covers all major entities of the panel: users, daemons, instances, files, dashboard, and more.

Features

  • User management (create, update, delete, search)
  • Daemon management (add, remove, connect)
  • Instance management (create, start, stop, delete, send commands)
  • File operations (list, read, write, copy, delete, archive)
  • Retrieve panel and daemon information
  • Flexible query parameter handling via Go structs and interfaces
  • Fully typed request and response structures

Installation

go get -u github.com/Dobytchick/mcsmapi

Quick Start

package main

import (
    "fmt"
    "github.com/Dobytchick/mcsmapi"
)

func main() {
    client := mcsmapi.NewClient("your-api-key", "http://localhost:23333", nil)

    // Get user list
    params := &mcsmapi.UserQueryParams{Page: 1, PageSize: 10}
    users, err := client.User.GetList(params)
    if err != nil {
        panic(err)
    }
    fmt.Printf("Users: %+v\n", users)
}

Usage Examples

Users
// Get user list
params := &mcsmapi.UserQueryParams{Page: 1, PageSize: 20}
resp, err := client.User.GetList(params)

// Create a user
createReq := &mcsmapi.CreateUserRequest{
    Username: "newuser",
    Password: "securepassword",
    Permission: 1,
}
createResp, err := client.User.CreateUser(createReq)
Daemons
addReq := &mcsmapi.AddDaemonRequest{IP: "127.0.0.1", Port: 24444, AccessKey: "daemon-key"}
resp, err := client.Daemon.Add(addReq)
Instances
listReq := &mcsmapi.ListInstancesQuery{DaemonID: "daemon-uuid", Page: 1, PageSize: 10}
instances, err

More Examples

More usage examples can be found here.

Documentation

Index

Constants

View Source
const (
	CompressModeZip CompressMode = 1
	CompressModeTar CompressMode = 2
	FileTypeFile    FileType     = 0
	FileTypeFolder  FileType     = 1
)
View Source
const HTTPTimeout = 10

Variables

This section is empty.

Functions

func BuildQueryString

func BuildQueryString(q interface{}) string

BuildQueryString constructs the URL-encoded query string

Types

type AddDaemonRequest

type AddDaemonRequest struct {
	IP        string `json:"ip"`
	Port      int    `json:"port"`
	Prefix    string `json:"prefix"`
	Title     string `json:"remarks"`
	AccessKey string `json:"apiKey"`
}

type BaseRequest

type BaseRequest struct {
	DaemonID string `url:"daemonId"`
	UUID     string `url:"uuid"`
}

BaseRequest includes common query parameters used across many request types

func (*BaseRequest) BuildQueryString

func (q *BaseRequest) BuildQueryString() string

type BaseResponse

type BaseResponse struct {
	Status int   `json:"status"`
	Data   any   `json:"data"`
	Time   int64 `json:"time"`
}

type BaseSuccessResponse added in v1.0.2

type BaseSuccessResponse struct {
	Status int   `json:"status"`
	Data   bool  `json:"data"`
	Time   int64 `json:"time"`
}

type BatchOperationQuery

type BatchOperationQuery struct {
	InstanceUUID string `url:"instanceUuid"`
	DaemonID     string `url:"daemonId"`
}

BatchOperationQuery defines the query parameters for batch operations (start, stop, restart, kill).

func (*BatchOperationQuery) BuildQueryString

func (q *BatchOperationQuery) BuildQueryString() string

type BoolResponse

type BoolResponse struct {
	Data bool `json:"data"`
	CommonResponse
}

type CPUMemChart

type CPUMemChart struct {
	CPU float64 `json:"cpu"` // CPU usage percentage
	Mem float64 `json:"mem"` // Memory usage percentage
}

CPUMemChart represents a single performance data point

type Chart

type Chart struct {
	System  []SystemChart  `json:"system"`  // System resource charts (Memory&CPU usage on the panel)
	Request []RequestChart `json:"request"` // Request statistics charts
}

Chart contains performance metrics for visualization

type Client

type Client struct {
	Dashboard *dashboardClient
	Daemon    *daemonClient
	Instance  *instanceClient
	File      *fileClient
	User      *userClient
	Image     *imageClient
	// contains filtered or unexported fields
}

func NewClient

func NewClient(token string, baseURL string, httpClient *http.Client) *Client

type CommonResponse

type CommonResponse struct {
	Time int64 `json:"time"`
}

type CompressFile

type CompressFile struct {
	Target   *ZipFileRequest
	FileData *ZipFileRequestBody
}

type CompressMode

type CompressMode int

type CopyFile

type CopyFile struct {
	Target   *CopyFileRequest
	FileData *FileSourceTargetPairs
}

type CopyFileRequest

type CopyFileRequest struct {
	BaseRequest
}

func (*CopyFileRequest) BuildQueryString

func (q *CopyFileRequest) BuildQueryString() string

type CopyFileResponse

type CopyFileResponse BoolResponse

type CreateFolder

type CreateFolder struct {
	Target *CreateFolderRequest
	Body   *CreateFolderRequestBody
}

type CreateFolderRequest

type CreateFolderRequest struct {
	BaseRequest
}

func (*CreateFolderRequest) BuildQueryString

func (q *CreateFolderRequest) BuildQueryString() string

type CreateFolderRequestBody

type CreateFolderRequestBody TargetedFile

type CreateFolderResponse

type CreateFolderResponse BoolResponse

type CreateImageRequest added in v1.0.2

type CreateImageRequest struct {
	DockerFile string `json:"dockerFile"`
	Name       string `json:"name"`
	Tag        string `json:"tag"`
}

CreateImageRequest defines the request body for creating a Docker image.

type CreateInstanceResponse

type CreateInstanceResponse struct {
	Status int `json:"status"`
	Data   struct {
		InstanceUUID string          `json:"instanceUuid"`
		Config       *InstanceConfig `json:"config"`
	} `json:"data"`
	Time int64 `json:"time"`
}

CreateInstanceResponse represents the response structure after creating an instance.

type CreateUserRequest

type CreateUserRequest struct {
	Username   string `json:"username"`
	Password   string `json:"password"`
	Permission int    `json:"permission"` // 1=User, 10=Admin, -1=Banned
}

type CreateUserResponse

type CreateUserResponse struct {
	Status int             `json:"status"`
	Time   int64           `json:"time"`
	Data   CreatedUserData `json:"data"`
}

type CreatedUserData

type CreatedUserData struct {
	UUID       string `json:"uuid"`
	UserName   string `json:"userName"`
	Permission int    `json:"permission"`
}

type DaemonConfigActionQuery

type DaemonConfigActionQuery struct {
	UUID string `url:"uuid"`
}

func (*DaemonConfigActionQuery) BuildQueryString

func (q *DaemonConfigActionQuery) BuildQueryString() string

type DaemonProcess

type DaemonProcess struct {
	CPU    int    `json:"cpu"`    // CPU usage in nanoseconds
	Memory int    `json:"memory"` // Memory usage in bytes
	Cwd    string `json:"cwd"`    // Current working directory
}

DaemonProcess contains daemon-specific process information

type DaemonSystem

type DaemonSystem struct {
	Type       string    `json:"type"`       // OS type
	Hostname   string    `json:"hostname"`   // System hostname
	Platform   string    `json:"platform"`   // Platform identifier
	Release    string    `json:"release"`    // Kernel release version
	Uptime     float64   `json:"uptime"`     // System uptime in seconds
	Cwd        string    `json:"cwd"`        // Current working directory
	Loadavg    []float64 `json:"loadavg"`    // System load averages
	Freemem    int64     `json:"freemem"`    // Free memory in bytes
	CPUUsage   float64   `json:"cpuUsage"`   // Current CPU usage
	MemUsage   float64   `json:"memUsage"`   // Current memory usage
	Totalmem   int64     `json:"totalmem"`   // Total memory in bytes
	ProcessCPU float64   `json:"processCpu"` // Process CPU usage
	ProcessMem float64   `json:"processMem"` // Process memory usage
}

DaemonSystem contains detailed daemon host system info

type Data

type Data struct {
	Version                string      `json:"version"`                // Panel software version
	SpecifiedDaemonVersion string      `json:"specifiedDaemonVersion"` // Required daemon version
	Process                Process     `json:"process"`                // Panel process information
	Record                 Record      `json:"record"`                 // Access statistics
	System                 System      `json:"system"`                 // Host system information
	Chart                  Chart       `json:"chart"`                  // Performance charts data
	RemoteCount            RemoteCount `json:"remoteCount"`            // Daemon connection stats
	Remote                 []Remote    `json:"remote"`                 // List of connected daemons
}

Data contains all core panel information and metrics

type DeleteFile

type DeleteFile struct {
	Target   *DeleteFileRequest
	FileData *DeleteFileRequestBody
}

type DeleteFileRequest

type DeleteFileRequest struct {
	BaseRequest
}

func (*DeleteFileRequest) BuildQueryString

func (q *DeleteFileRequest) BuildQueryString() string

type DeleteFileRequestBody

type DeleteFileRequestBody FileTargets

type DeleteFileResponse

type DeleteFileResponse BoolResponse

type DeleteInstanceBody

type DeleteInstanceBody struct {
	UUIDS      []string `json:"uuids"`
	DeleteFile bool     `json:"deleteFile"`
}

type DeleteInstancesResponse

type DeleteInstancesResponse struct {
	Status int      `json:"status"`
	Data   []string `json:"data"`
	Time   int64    `json:"time"`
}

DeleteInstancesResponse represents the response for deleting instances.

type DockerConfig

type DockerConfig struct {
	ContainerName  string   `json:"containerName"`
	Image          string   `json:"image"`
	Memory         int      `json:"memory"` // MB
	Ports          []string `json:"ports"`
	ExtraVolumes   []string `json:"extraVolumes"`
	MaxSpace       int      `json:"maxSpace"`
	Network        int      `json:"network"`
	IO             int      `json:"io"`
	NetworkMode    string   `json:"networkMode"`
	NetworkAliases []string `json:"networkAliases"`
	CpuSetCpus     string   `json:"cpusetCpus"`
	CPUUsage       int      `json:"cpuUsage"`
	WorkingDir     string   `json:"workingDir"`
	Env            []string `json:"env"`
}

DockerConfig represents the configuration for Docker-based instances.

type DockerContainer added in v1.0.2

type DockerContainer struct {
	ID      string   `json:"id"`
	Names   []string `json:"names"`
	Image   string   `json:"image"`
	ImageID string   `json:"imageID"`
	State   string   `json:"state"`
	Status  string   `json:"status"`
}

DockerContainer defines an individual Docker container.

type DockerContainerList added in v1.0.2

type DockerContainerList struct {
	Containers []DockerContainer `json:"containers"`
}

DockerContainerList defines a list of Docker containers.

type DockerImage

type DockerImage struct {
	RepoTags []string `json:"repoTags"` // List of repository tags for the image
	Size     int64    `json:"size"`     // Image size in bytes
	Created  string   `json:"created"`  // Creation date of the image
	ID       string   `json:"id"`       // Image ID
}

DockerImage defines an individual Docker image.

type DockerImageList

type DockerImageList struct {
	Images []DockerImage `json:"images"` // List of Docker images
}

DockerImageList defines a list of Docker images.

type DockerNetwork added in v1.0.2

type DockerNetwork struct {
	ID     string   `json:"id"`
	Name   string   `json:"name"`
	Driver string   `json:"driver"`
	Scope  string   `json:"scope"`
	IPAM   any      `json:"ipam"`
	Labels any      `json:"labels"`
	Peers  []string `json:"peers"`
}

DockerNetwork defines an individual Docker network.

type DockerNetworkList added in v1.0.2

type DockerNetworkList struct {
	Networks []DockerNetwork `json:"networks"`
}

DockerNetworkList defines a list of Docker networks.

type DownloadFileRequest

type DownloadFileRequest struct {
	BaseRequest
	FileName string `url:"file_name"`
}

func (*DownloadFileRequest) BuildQueryString

func (q *DownloadFileRequest) BuildQueryString() string

type DownloadFileResponse

type DownloadFileResponse struct {
	Data struct {
		Password string `json:"password"`
		Addr     string `json:"addr"`
	} `json:"data"`
	CommonResponse
}

type FileContents

type FileContents struct {
	Target *BaseRequest
	File   *GetFileContentsRequestBody
}

type FileItem

type FileItem struct {
	Name string   `json:"name"`
	Size int      `json:"size"`
	Time string   `json:"time"`
	Mode int      `json:"mode"`
	Type FileType `json:"type"` // 0 = Folder, 1 = File
}

type FileSourceTargetPairs

type FileSourceTargetPairs struct {
	Targets [][2]string `json:"targets"` // source, target
}

type FileTargets

type FileTargets struct {
	Targets []string `json:"targets"` // List of file/folder paths
}

type FileType

type FileType int

type GetBuildProgressResponse added in v1.0.2

type GetBuildProgressResponse struct {
	Status int            `json:"status"`
	Data   map[string]int `json:"data"` // image: status (-1 = Failed, 1 = Building, 2 = Complete)
	Time   int64          `json:"time"`
}

GetBuildProgressResponse defines the response structure for build progress.

type GetContainerListResponse added in v1.0.2

type GetContainerListResponse struct {
	Data DockerContainerList `json:"data"`
	Time int64               `json:"time"`
}

type GetFileContentsRequest

type GetFileContentsRequest struct {
	BaseRequest
}

func (*GetFileContentsRequest) BuildQueryString

func (q *GetFileContentsRequest) BuildQueryString() string

type GetFileContentsRequestBody

type GetFileContentsRequestBody TargetedFile

type GetFileContentsResponse

type GetFileContentsResponse struct {
	Data string `json:"data"`
	CommonResponse
}

type GetFileListRequest

type GetFileListRequest struct {
	BaseRequest
	Target   string `url:"target"`
	Page     int    `url:"page"`
	PageSize int    `url:"page_size"`
	FileName string `url:"file_name"`
}

func (*GetFileListRequest) BuildQueryString

func (q *GetFileListRequest) BuildQueryString() string

type GetFileListResponse

type GetFileListResponse struct {
	Status int `json:"status"`
	Data   struct {
		Items        []*FileItem `json:"items"`
		Page         int         `json:"page"`
		PageSize     int         `json:"page_size"`
		Total        int         `json:"total"`
		AbsolutePath string      `json:"absolute_path"`
	} `json:"data"`
	Time int64 `json:"time"`
}

type GetImageListRequest

type GetImageListRequest struct {
	DaemonID string `url:"daemonId"`
}

GetImageListRequest defines the query parameters for getting a list of images.

func (*GetImageListRequest) BuildQueryString

func (q *GetImageListRequest) BuildQueryString() string

type GetImageListResponse

type GetImageListResponse struct {
	Data DockerImageList `json:"data"`
	Time int64           `json:"time"`
}

GetImageListResponse defines the response structure for getting a list of images.

type GetInstanceQuery

type GetInstanceQuery struct {
	UUID     string `json:"uuid" url:"uuid"`
	DaemonID string `json:"daemonId" url:"daemonId"`
}

GetInstanceQuery defines the query parameters for retrieving a single instance by UUID.

func (*GetInstanceQuery) BuildQueryString

func (q *GetInstanceQuery) BuildQueryString() string

type GetNetworkListResponse added in v1.0.2

type GetNetworkListResponse struct {
	Data DockerNetworkList `json:"data"`
	Time int64             `json:"time"`
}

GetNetworkListResponse defines the response structure for getting a list of networks.

type Instance

type Instance struct {
	Running int `json:"running"` // Number of running instances
	Total   int `json:"total"`   // Total configured instances
}

Instance contains Minecraft instance statistics

type InstanceConfig

type InstanceConfig struct {
	Nickname          string        `json:"nickname"`
	StartCommand      string        `json:"startCommand"`
	StopCommand       string        `json:"stopCommand"`
	Cwd               string        `json:"cwd"`
	IE                string        `json:"ie"`
	OE                string        `json:"oe"`
	CreateDatetime    int64         `json:"createDatetime"`
	LastDatetime      int64         `json:"lastDatetime"`
	Type              string        `json:"type"`
	Tag               []string      `json:"tag"`
	EndTime           int64         `json:"endTime"`
	FileCode          string        `json:"fileCode"`
	ProcessType       string        `json:"processType"`
	UpdateCommand     string        `json:"updateCommand"`
	ActionCommandList []string      `json:"actionCommandList"`
	CrLf              int           `json:"crlf"`
	Docker            *DockerConfig `json:"docker"`

	// Steam RCON configuration
	EnableRcon   bool   `json:"enableRcon"`
	RconPassword string `json:"rconPassword"`
	RconPort     int    `json:"rconPort"`
	RconIp       string `json:"rconIp"`

	// Terminal options
	TerminalOption struct {
		HaveColor bool `json:"haveColor"`
		Pty       bool `json:"pty"`
	} `json:"terminalOption"`

	// Event task settings
	EventTask struct {
		AutoStart   bool `json:"autoStart"`
		AutoRestart bool `json:"autoRestart"`
		Ignore      bool `json:"ignore"`
	} `json:"eventTask"`

	// Ping config
	PingConfig struct {
		IP   string `json:"ip"`
		Port int    `json:"port"`
		Type int    `json:"type"`
	} `json:"pingConfig"`
}

type InstanceDetail

type InstanceDetail struct {
	Config *InstanceConfig `json:"config"`
	Info   struct {
		CurrentPlayers int      `json:"currentPlayers"`
		FileLock       int      `json:"fileLock"`
		MaxPlayers     int      `json:"maxPlayers"`
		OpenFrpStatus  bool     `json:"openFrpStatus"`
		PlayersChart   []string `json:"playersChart"`
		Version        string   `json:"version"`
	} `json:"info"`
	InstanceUUID string `json:"instanceUuid"`
	ProcessInfo  struct {
		CPU       int   `json:"cpu"`
		Memory    int   `json:"memory"`
		PPID      int   `json:"ppid"`
		PID       int   `json:"pid"`
		CTime     int64 `json:"ctime"`
		Elapsed   int64 `json:"elapsed"`
		Timestamp int64 `json:"timestamp"`
	} `json:"processInfo"`
	Space   int            `json:"space"`
	Started int            `json:"started"`
	Status  InstanceStatus `json:"status"` // Instance status (0: stopped, 1: starting, 2: running, etc.)
}

InstanceDetail represents detailed information about an instance.

type InstanceDetailResponse

type InstanceDetailResponse struct {
	Status int             `json:"status"`
	Data   *InstanceDetail `json:"data"`
	Time   int64           `json:"time"`
}

InstanceDetailResponse represents the response structure for a single instance.

type InstanceListResponse

type InstanceListResponse struct {
	Status int `json:"status"`
	Data   struct {
		MaxPage  int               `json:"maxPage"`
		PageSize int               `json:"pageSize"`
		AllTags  []string          `json:"allTags"`
		Data     []*InstanceDetail `json:"data"`
	} `json:"data"`
	Time int64 `json:"time"`
}

InstanceListResponse represents the response structure for a list of instances.

type InstanceStatus

type InstanceStatus int
const (
	InstanceStop     InstanceStatus = 0
	InstanceStarting InstanceStatus = 1
	InstanceRunning  InstanceStatus = 2
	// InstanceStopping Maybe exists status idk ¯\_(ツ)_/¯
	InstanceStopping InstanceStatus = 3
)

type KillInstanceQuery

type KillInstanceQuery struct {
	UUID     string `url:"uuid"`
	DaemonID string `url:"daemonId"`
}

KillInstanceQuery defines the query parameters for killing an instance.

func (*KillInstanceQuery) BuildQueryString

func (q *KillInstanceQuery) BuildQueryString() string

type KillInstanceResponse

type KillInstanceResponse struct {
	Status int `json:"status"`
	Data   struct {
		InstanceUUID string `json:"instanceUuid"`
	} `json:"data"`
	Time int64 `json:"time"`
}

KillInstanceResponse represents the response for killing an instance.

type ListInstancesQuery

type ListInstancesQuery struct {
	DaemonID     string         `json:"daemonId" url:"daemonId"`
	Page         int            `json:"page" url:"page"`
	PageSize     int            `json:"page_size" url:"page_size"`
	InstanceName string         `json:"instance_name" url:"instance_name"`
	Status       InstanceStatus `json:"status" url:"status"`
}

ListInstancesQuery defines the query parameters for listing remote service instances.

func (*ListInstancesQuery) BuildQueryString

func (q *ListInstancesQuery) BuildQueryString() string

type MethodClient

type MethodClient struct {
	// contains filtered or unexported fields
}

type MoveFile

type MoveFile struct {
	Target   *MoveFileRequest
	FileData *FileSourceTargetPairs
}

type MoveFileRequest

type MoveFileRequest struct {
	BaseRequest
}

func (*MoveFileRequest) BuildQueryString

func (q *MoveFileRequest) BuildQueryString() string

type MoveFileResponse

type MoveFileResponse BoolResponse

type PanelData

type PanelData struct {
	Status int   `json:"status"` // HTTP status code
	Data   Data  `json:"data"`   // Main data payload
	Time   int64 `json:"time"`   // Timestamp of the response
}

PanelData represents the root structure of the MCSManager panel data

type Process

type Process struct {
	CPU    int    `json:"cpu"`    // CPU usage percentage
	Memory int    `json:"memory"` // Memory usage in bytes (Panel Memory Usage)
	Cwd    string `json:"cwd"`    // Current working directory
}

Process contains information about the panel process

type Query

type Query interface {
	BuildQueryString() string
}

type Record

type Record struct {
	Logined       int `json:"logined"`       // Successful logins count
	IllegalAccess int `json:"illegalAccess"` // Unauthorized access attempts
	Banips        int `json:"banips"`        // Banned IP addresses count
	LoginFailed   int `json:"loginFailed"`   // Failed login attempts
}

Record tracks authentication and security events

type Remote

type Remote struct {
	Version     string        `json:"version"`     // Daemon software version
	Process     DaemonProcess `json:"process"`     // Daemon process info
	Instance    Instance      `json:"instance"`    // Managed instances info
	System      DaemonSystem  `json:"system"`      // Daemon host system info (CPU and memory usage on the Daemon)
	CPUMemChart []CPUMemChart `json:"cpuMemChart"` // Performance metrics (CPU and memory usage on the Daemon Chart)
	UUID        string        `json:"uuid"`        // Unique daemon identifier
	IP          string        `json:"ip"`          // Connection IP/hostname
	Port        int           `json:"port"`        // Connection port
	Prefix      string        `json:"prefix"`      // URL prefix
	Available   bool          `json:"available"`   // Connection status
	Remarks     string        `json:"remarks"`     // Descriptive label
}

Remote represents a connected daemon instance

type RemoteCount

type RemoteCount struct {
	Available int `json:"available"` // Number of available daemons
	Total     int `json:"total"`     // Total registered daemons
}

RemoteCount tracks connected daemon statistics

type RequestChart

type RequestChart struct {
	Value           int `json:"value"`           // Current active requests
	TotalInstance   int `json:"totalInstance"`   // Total managed instances
	RunningInstance int `json:"runningInstance"` // Currently running instances
}

RequestChart represents application request metrics

type RestartInstanceQuery

type RestartInstanceQuery struct {
	UUID     string `url:"uuid"`
	DaemonID string `url:"daemonId"`
}

RestartInstanceQuery defines the query parameters for restarting an instance.

func (*RestartInstanceQuery) BuildQueryString

func (q *RestartInstanceQuery) BuildQueryString() string

type RestartInstanceResponse

type RestartInstanceResponse struct {
	Status int `json:"status"`
	Data   struct {
		InstanceUUID string `json:"instanceUuid"`
	} `json:"data"`
	Time int64 `json:"time"`
}

RestartInstanceResponse represents the response for restarting an instance.

type StartInstanceQuery

type StartInstanceQuery struct {
	UUID     string `url:"uuid"`
	DaemonID string `url:"daemonId"`
}

StartInstanceQuery defines the query parameters for starting an instance.

func (*StartInstanceQuery) BuildQueryString

func (q *StartInstanceQuery) BuildQueryString() string

type StartInstanceResponse

type StartInstanceResponse struct {
	Status int `json:"status"`
	Data   struct {
		InstanceUUID string `json:"instanceUuid"`
	} `json:"data"`
	Time int64 `json:"time"`
}

StartInstanceResponse represents the response for starting an instance.

type StopInstanceQuery

type StopInstanceQuery struct {
	UUID     string `url:"uuid"`
	DaemonID string `url:"daemonId"`
}

StopInstanceQuery defines the query parameters for stopping an instance.

func (*StopInstanceQuery) BuildQueryString

func (q *StopInstanceQuery) BuildQueryString() string

type StopInstanceResponse

type StopInstanceResponse struct {
	Status int `json:"status"`
	Data   struct {
		InstanceUUID string `json:"instanceUuid"`
	} `json:"data"`
	Time int64 `json:"time"`
}

StopInstanceResponse represents the response for stopping an instance.

type System

type System struct {
	User     User    `json:"user"`     // System user information
	Time     int64   `json:"time"`     // Timestamp (Memory usage on the panel)
	Totalmem int64   `json:"totalmem"` // Total system memory in bytes
	Freemem  int64   `json:"freemem"`  // Free memory in bytes
	Type     string  `json:"type"`     // OS type (Windows_NT/Linux)
	Version  string  `json:"version"`  // OS version
	Node     string  `json:"node"`     // Node.js version
	Hostname string  `json:"hostname"` // System hostname
	Loadavg  []int   `json:"loadavg"`  // System load averages (Linux only)
	Platform string  `json:"platform"` // Platform identifier
	Release  string  `json:"release"`  // Kernel release version
	Uptime   float64 `json:"uptime"`   // System uptime in seconds
	CPU      float64 `json:"cpu"`      // Overall CPU usage percentage
}

System contains detailed host system information

type SystemChart

type SystemChart struct {
	CPU float64 `json:"cpu"` // CPU usage percentage
	Mem float64 `json:"mem"` // Memory usage percentage
}

SystemChart represents a single data point for system metrics

type TargetedFile

type TargetedFile struct {
	Target string `json:"target"`
}

type TouchFile

type TouchFile struct {
	Target   *TouchFileRequest
	FileData *TouchFileRequestBody
}

type TouchFileRequest

type TouchFileRequest struct {
	BaseRequest
}

func (*TouchFileRequest) BuildQueryString

func (q *TouchFileRequest) BuildQueryString() string

type TouchFileRequestBody

type TouchFileRequestBody TargetedFile

type TouchFileResponse

type TouchFileResponse BoolResponse

type TryConnectDaemonQuery

type TryConnectDaemonQuery struct {
	UUID string `url:"uuid"`
}

func (*TryConnectDaemonQuery) BuildQueryString

func (q *TryConnectDaemonQuery) BuildQueryString() string

type UnzipFileResponse

type UnzipFileResponse BoolResponse

type UpdateConfigQuery

type UpdateConfigQuery struct {
	UUID     string `url:"uuid"`
	DaemonID string `url:"daemonId"`
}

UpdateConfigQuery defines the query parameters for updating an instance config.

func (*UpdateConfigQuery) BuildQueryString

func (q *UpdateConfigQuery) BuildQueryString() string

type UpdateConfigResponse

type UpdateConfigResponse struct {
	Status int `json:"status"`
	Data   struct {
		InstanceUUID string `json:"instanceUuid"`
	} `json:"data"`
	Time int64 `json:"time"`
}

type UpdateFile

type UpdateFile struct {
	Target   *UpdateFileRequest
	FileData *UpdateFileRequestBody
}

type UpdateFileRequest

type UpdateFileRequest BaseRequest

type UpdateFileRequestBody

type UpdateFileRequestBody struct {
	Target string `json:"target"`
	Text   string `json:"text"`
}

type UpdateFileResponse

type UpdateFileResponse BoolResponse

type UpdateUserRequest added in v1.0.2

type UpdateUserRequest struct {
	UUID   string   `json:"uuid"`
	Config UserData `json:"config"`
}

UpdateUser updates user data by uuid. PUT /auth

type UploadFileRequest

type UploadFileRequest DownloadFileRequest

func (*UploadFileRequest) BuildQueryString

func (q *UploadFileRequest) BuildQueryString() string

type UploadFileResponse

type UploadFileResponse DownloadFileResponse

type User

type User struct {
	UID      int    `json:"uid"`      // User ID
	GID      int    `json:"gid"`      // Group ID
	Username string `json:"username"` // Username
	Homedir  string `json:"homedir"`  // Home directory path
	Shell    any    `json:"shell"`    // Shell path (nullable)
}

User contains system user account information

type UserData

type UserData struct {
	UUID         string         `json:"uuid"`
	UserName     string         `json:"userName"`
	PassWord     string         `json:"passWord"`
	PassWordType int            `json:"passWordType"`
	Salt         string         `json:"salt"`
	Permission   int            `json:"permission"`
	RegisterTime string         `json:"registerTime"`
	LoginTime    string         `json:"loginTime"`
	Instances    []UserInstance `json:"instances"`
	ApiKey       string         `json:"apiKey"`
	IsInit       bool           `json:"isInit"`
	Secret       string         `json:"secret"`
	Open2FA      bool           `json:"open2FA"`
}

UserData represents user information and authentication details.

type UserInstance

type UserInstance struct {
	InstanceUUID string `json:"instanceUuid"`
	DaemonID     string `json:"daemonId"`
}

type UserListData

type UserListData struct {
	Data     []UserData `json:"data"`
	MaxPage  int        `json:"maxPage"`
	Page     int        `json:"page"`
	PageSize int        `json:"pageSize"`
	Total    int        `json:"total"`
}

UserListData represents a paginated list of users returned by the API.

type UserListResponse

type UserListResponse struct {
	Status int          `json:"status"`
	Data   UserListData `json:"data"`
	Time   int64        `json:"time"`
}

type UserQueryParams

type UserQueryParams struct {
	UserName *string `url:"userName,omitempty"` // Optional: Filter by username (partial match)
	Page     int     `url:"page"`               // Required: Page number (1-based index)
	PageSize int     `url:"page_size"`          // Required: Number of items per page
	Role     *string `url:"role,omitempty"`     // Optional: Filter by permission role ("1", "10", or "-1")
}

UserQueryParams — parameters for searching/filtering users for /auth/search

func (*UserQueryParams) BuildQueryString

func (u *UserQueryParams) BuildQueryString() string

type UserRole added in v1.0.2

type UserRole string
const (
	RoleUser   UserRole = "1"
	RoleAdmin  UserRole = "10"
	RoleBanned UserRole = "-1"
)

type ZipFileRequest

type ZipFileRequest struct {
	BaseRequest
}

func (*ZipFileRequest) BuildQueryString

func (q *ZipFileRequest) BuildQueryString() string

type ZipFileRequestBody

type ZipFileRequestBody struct {
	Type    CompressMode `json:"type"`   // 1 for zip
	Code    string       `json:"code"`   // "utf-8"
	Source  string       `json:"source"` // Zip file path
	Targets []string     `json:"targets"`
}

type ZipFileResponse

type ZipFileResponse BoolResponse

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL