Some checks failed
Build docker and publish / build (20.15.1) (push) Failing after 6m27s
feat: 添加版本和构建时间变量 fix: 修正短信队列类型注释错误 style: 清理未使用的代码和测试文件 docs: 更新安装文档中的下载链接 chore: 迁移数据库脚本添加日志和订阅配置
213 lines
5.7 KiB
Plaintext
213 lines
5.7 KiB
Plaintext
syntax = "v1"
|
|
|
|
info (
|
|
title: "Node API"
|
|
desc: "API for ppanel"
|
|
author: "Tension"
|
|
email: "tension@ppanel.com"
|
|
version: "0.0.1"
|
|
)
|
|
|
|
import "../types.api"
|
|
|
|
type (
|
|
ServerOnlineIP {
|
|
IP string `json:"ip"`
|
|
Protocol string `json:"protocol"`
|
|
}
|
|
ServerOnlineUser {
|
|
IP []ServerOnlineIP `json:"ip"`
|
|
UserId int64 `json:"user_id"`
|
|
Subscribe string `json:"subscribe"`
|
|
SubscribeId int64 `json:"subscribe_id"`
|
|
Traffic int64 `json:"traffic"`
|
|
ExpiredAt int64 `json:"expired_at"`
|
|
}
|
|
ServerStatus {
|
|
Cpu float64 `json:"cpu"`
|
|
Mem float64 `json:"mem"`
|
|
Disk float64 `json:"disk"`
|
|
Protocol string `json:"protocol"`
|
|
Online []ServerOnlineUser `json:"online"`
|
|
Status string `json:"status"`
|
|
}
|
|
Server {
|
|
Id int64 `json:"id"`
|
|
Name string `json:"name"`
|
|
Country string `json:"country"`
|
|
City string `json:"city"`
|
|
Address string `json:"address"`
|
|
Sort int `json:"sort"`
|
|
Protocols []Protocol `json:"protocols"`
|
|
LastReportedAt int64 `json:"last_reported_at"`
|
|
Status ServerStatus `json:"status"`
|
|
CreatedAt int64 `json:"created_at"`
|
|
UpdatedAt int64 `json:"updated_at"`
|
|
}
|
|
CreateServerRequest {
|
|
Name string `json:"name"`
|
|
Country string `json:"country,omitempty"`
|
|
City string `json:"city,omitempty"`
|
|
Address string `json:"address"`
|
|
Sort int `json:"sort,omitempty"`
|
|
Protocols []Protocol `json:"protocols"`
|
|
}
|
|
UpdateServerRequest {
|
|
Id int64 `json:"id"`
|
|
Name string `json:"name"`
|
|
Country string `json:"country,omitempty"`
|
|
City string `json:"city,omitempty"`
|
|
Address string `json:"address"`
|
|
Sort int `json:"sort,omitempty"`
|
|
Protocols []Protocol `json:"protocols"`
|
|
}
|
|
DeleteServerRequest {
|
|
Id int64 `json:"id"`
|
|
}
|
|
FilterServerListRequest {
|
|
Page int `form:"page"`
|
|
Size int `form:"size"`
|
|
Search string `form:"search,omitempty"`
|
|
}
|
|
FilterServerListResponse {
|
|
Total int64 `json:"total"`
|
|
List []Server `json:"list"`
|
|
}
|
|
GetServerProtocolsRequest {
|
|
Id int64 `form:"id"`
|
|
}
|
|
GetServerProtocolsResponse {
|
|
Protocols []Protocol `json:"protocols"`
|
|
}
|
|
Node {
|
|
Id int64 `json:"id"`
|
|
Name string `json:"name"`
|
|
Tags []string `json:"tags"`
|
|
Port uint16 `json:"port"`
|
|
Address string `json:"address"`
|
|
ServerId int64 `json:"server_id"`
|
|
Protocol string `json:"protocol"`
|
|
Enabled *bool `json:"enabled"`
|
|
Sort int `json:"sort,omitempty"`
|
|
CreatedAt int64 `json:"created_at"`
|
|
UpdatedAt int64 `json:"updated_at"`
|
|
}
|
|
CreateNodeRequest {
|
|
Name string `json:"name"`
|
|
Tags []string `json:"tags,omitempty"`
|
|
Port uint16 `json:"port"`
|
|
Address string `json:"address"`
|
|
ServerId int64 `json:"server_id"`
|
|
Protocol string `json:"protocol"`
|
|
Enabled *bool `json:"enabled"`
|
|
}
|
|
UpdateNodeRequest {
|
|
Id int64 `json:"id"`
|
|
Name string `json:"name"`
|
|
Tags []string `json:"tags,omitempty"`
|
|
Port uint16 `json:"port"`
|
|
Address string `json:"address"`
|
|
ServerId int64 `json:"server_id"`
|
|
Protocol string `json:"protocol"`
|
|
Enabled *bool `json:"enabled"`
|
|
}
|
|
ToggleNodeStatusRequest {
|
|
Id int64 `json:"id"`
|
|
Enable *bool `json:"enable"`
|
|
}
|
|
DeleteNodeRequest {
|
|
Id int64 `json:"id"`
|
|
}
|
|
FilterNodeListRequest {
|
|
Page int `form:"page"`
|
|
Size int `form:"size"`
|
|
Search string `form:"search,omitempty"`
|
|
}
|
|
FilterNodeListResponse {
|
|
Total int64 `json:"total"`
|
|
List []Node `json:"list"`
|
|
}
|
|
HasMigrateSeverNodeResponse {
|
|
HasMigrate bool `json:"has_migrate"`
|
|
}
|
|
MigrateServerNodeResponse {
|
|
Succee uint64 `json:"succee"`
|
|
Fail uint64 `json:"fail"`
|
|
Message string `json:"message,omitempty"`
|
|
}
|
|
ResetSortRequest {
|
|
Sort []SortItem `json:"sort"`
|
|
}
|
|
QueryNodeTagResponse {
|
|
Tags []string `json:"tags"`
|
|
}
|
|
)
|
|
|
|
@server (
|
|
prefix: v1/admin/server
|
|
group: admin/server
|
|
middleware: AuthMiddleware
|
|
)
|
|
service ppanel {
|
|
@doc "Create Server"
|
|
@handler CreateServer
|
|
post /create (CreateServerRequest)
|
|
|
|
@doc "Update Server"
|
|
@handler UpdateServer
|
|
post /update (UpdateServerRequest)
|
|
|
|
@doc "Delete Server"
|
|
@handler DeleteServer
|
|
post /delete (DeleteServerRequest)
|
|
|
|
@doc "Filter Server List"
|
|
@handler FilterServerList
|
|
get /list (FilterServerListRequest) returns (FilterServerListResponse)
|
|
|
|
@doc "Get Server Protocols"
|
|
@handler GetServerProtocols
|
|
get /protocols (GetServerProtocolsRequest) returns (GetServerProtocolsResponse)
|
|
|
|
@doc "Create Node"
|
|
@handler CreateNode
|
|
post /node/create (CreateNodeRequest)
|
|
|
|
@doc "Update Node"
|
|
@handler UpdateNode
|
|
post /node/update (UpdateNodeRequest)
|
|
|
|
@doc "Delete Node"
|
|
@handler DeleteNode
|
|
post /node/delete (DeleteNodeRequest)
|
|
|
|
@doc "Filter Node List"
|
|
@handler FilterNodeList
|
|
get /node/list (FilterNodeListRequest) returns (FilterNodeListResponse)
|
|
|
|
@doc "Toggle Node Status"
|
|
@handler ToggleNodeStatus
|
|
post /node/status/toggle (ToggleNodeStatusRequest)
|
|
|
|
@doc "Check if there is any server or node to migrate"
|
|
@handler HasMigrateSeverNode
|
|
get /migrate/has returns (HasMigrateSeverNodeResponse)
|
|
|
|
@doc "Migrate server and node data to new database"
|
|
@handler MigrateServerNode
|
|
post /migrate/run returns (MigrateServerNodeResponse)
|
|
|
|
@doc "Reset server sort"
|
|
@handler ResetSortWithServer
|
|
post /server/sort (ResetSortRequest)
|
|
|
|
@doc "Reset node sort"
|
|
@handler ResetSortWithNode
|
|
post /node/sort (ResetSortRequest)
|
|
|
|
@doc "Query all node tags"
|
|
@handler QueryNodeTag
|
|
get /node/tags returns (QueryNodeTagResponse)
|
|
}
|
|
|