运维 API
1. "更新代理元数据"
- route definition
- Url: /api/v1/ops/agent-meta
- Method: PUT
- Request:
OpsAgentMetaUpdateRequest - Response:
OpsAgentMetaResponse
- request definition
go
type OpsAgentMetaUpdateRequest struct {
AgentID string `json:"agentId"`
Meta interface{} `json:"meta"`
}- response definition
go
type OpsAgentMetaResponse struct {
Code int `json:"code"`
Message string `json:"message"`
Data interface{} `json:"data,omitempty"`
}2. "获取 Agent 列表"
- route definition
- Url: /api/v1/ops/agents
- Method: GET
- Request:
OpsAgentsListRequest - Response:
OpsAgentsListResponse
- request definition
go
type OpsAgentsListRequest struct {
}- response definition
go
type OpsAgentsListResponse struct {
Code int `json:"code"`
Message string `json:"message"`
Data []OpsAgentInfo `json:"data,omitempty"`
}3. "在 Agent 上执行命令(高风险)"
- route definition
- Url: /api/v1/ops/agents/:agentId/exec
- Method: POST
- Request:
OpsExecCommandRequest - Response:
OpsExecCommandResponse
- request definition
go
type OpsExecCommandRequest struct {
AgentID string `path:"agentId"`
Command string `json:"command"`
Args []string `json:"args,optional"`
Timeout int32 `json:"timeout,optional"`
}- response definition
go
type OpsExecCommandResponse struct {
Code int `json:"code"`
Message string `json:"message"`
Data OpsExecCommandResult `json:"data,omitempty"`
}
type OpsExecCommandResult struct {
Success bool `json:"success"`
ExitCode int32 `json:"exitCode"`
Stdout string `json:"stdout"`
Stderr string `json:"stderr"`
}4. "获取 Agent 进程列表"
- route definition
- Url: /api/v1/ops/agents/:agentId/processes
- Method: GET
- Request:
OpsAgentProcessesRequest - Response:
OpsAgentProcessesResponse
- request definition
go
type OpsAgentProcessesRequest struct {
AgentID string `path:"agentId"`
}- response definition
go
type OpsAgentProcessesResponse struct {
Code int `json:"code"`
Message string `json:"message"`
Data []OpsManagedProcess `json:"data,omitempty"`
}5. "重启 Agent 进程"
- route definition
- Url: /api/v1/ops/agents/:agentId/processes/:name/restart
- Method: POST
- Request:
OpsProcessActionRequest - Response:
OpsProcessActionResponse
- request definition
go
type OpsProcessActionRequest struct {
AgentID string `path:"agentId"`
Name string `path:"name"`
Force bool `json:"force,optional"`
}- response definition
go
type OpsProcessActionResponse struct {
Code int `json:"code"`
Message string `json:"message"`
Data int32 `json:"pid,omitempty"`
}6. "启动 Agent 进程"
- route definition
- Url: /api/v1/ops/agents/:agentId/processes/:name/start
- Method: POST
- Request:
OpsProcessStartRequest - Response:
OpsProcessStartResponse
- request definition
go
type OpsProcessStartRequest struct {
AgentID string `path:"agentId"`
Name string `path:"name"`
}- response definition
go
type OpsProcessStartResponse struct {
Code int `json:"code"`
Message string `json:"message"`
Data int32 `json:"pid,omitempty"`
}7. "停止 Agent 进程"
- route definition
- Url: /api/v1/ops/agents/:agentId/processes/:name/stop
- Method: POST
- Request:
OpsProcessActionRequest - Response:
OpsProcessActionResponse
- request definition
go
type OpsProcessActionRequest struct {
AgentID string `path:"agentId"`
Name string `path:"name"`
Force bool `json:"force,optional"`
}- response definition
go
type OpsProcessActionResponse struct {
Code int `json:"code"`
Message string `json:"message"`
Data int32 `json:"pid,omitempty"`
}8. "获取 Agent 系统信息"
- route definition
- Url: /api/v1/ops/agents/:agentId/system-info
- Method: GET
- Request:
OpsAgentSystemInfoRequest - Response:
OpsAgentSystemInfoResponse
- request definition
go
type OpsAgentSystemInfoRequest struct {
AgentID string `path:"agentId"`
}- response definition
go
type OpsAgentSystemInfoResponse struct {
Code int `json:"code"`
Message string `json:"message"`
Data OpsAgentSystemInfo `json:"data,omitempty"`
}
type OpsAgentSystemInfo struct {
Hostname string `json:"hostname"`
OS string `json:"os"`
OSVersion string `json:"osVersion"`
KernelVersion string `json:"kernelVersion"`
Arch string `json:"arch"`
CPUCores int32 `json:"cpuCores"`
TotalMemory uint64 `json:"totalMemory"`
BootTime string `json:"bootTime"`
AgentVersion string `json:"agentVersion"`
}9. "获取 Agent 指标"
- route definition
- Url: /api/v1/ops/agents/metrics
- Method: GET
- Request:
OpsAgentMetricsRequest - Response:
OpsAgentMetricsResponse
- request definition
go
type OpsAgentMetricsRequest struct {
AgentID string `form:"agentId,optional"`
Since string `form:"since,optional"`
Limit int `form:"limit,optional"`
}- response definition
go
type OpsAgentMetricsResponse struct {
Code int `json:"code"`
Message string `json:"message"`
Data []OpsMetricsData `json:"data,omitempty"`
}10. "获取告警列表"
- route definition
- Url: /api/v1/ops/alerts
- Method: GET
- Request:
OpsAlertsRequest - Response:
OpsAlertsResponse
- request definition
go
type OpsAlertsRequest struct {
}- response definition
go
type OpsAlertsResponse struct {
Alerts []OpsAlert `json:"alerts"`
}11. "静默告警"
- route definition
- Url: /api/v1/ops/alerts/silence
- Method: POST
- Request:
OpsAlertSilenceRequest - Response:
OpsAlertSilenceResponse
- request definition
go
type OpsAlertSilenceRequest struct {
AlertID string `json:"alertId"`
Duration int `json:"duration"` // 静默时长(分钟)
}- response definition
go
type OpsAlertSilenceResponse struct {
Code int `json:"code"`
Message string `json:"message"`
Data interface{} `json:"data,omitempty"`
}12. "创建备份"
- route definition
- Url: /api/v1/ops/backups
- Method: POST
- Request:
OpsBackupCreateRequest - Response:
OpsBackupCreateResponse
- request definition
go
type OpsBackupCreateRequest struct {
Name string `json:"name,optional"`
}- response definition
go
type OpsBackupCreateResponse struct {
Code int `json:"code"`
Message string `json:"message"`
Data interface{} `json:"data,omitempty"`
}13. "获取备份列表"
- route definition
- Url: /api/v1/ops/backups
- Method: GET
- Request:
OpsBackupsListRequest - Response:
OpsBackupsListResponse
- request definition
go
type OpsBackupsListRequest struct {
Page int `form:"page,optional"`
PageSize int `form:"pageSize,optional"`
}- response definition
go
type OpsBackupsListResponse struct {
Code int `json:"code"`
Message string `json:"message"`
Data interface{} `json:"data,omitempty"`
}14. "删除备份"
- route definition
- Url: /api/v1/ops/backups/:id
- Method: DELETE
- Request:
OpsBackupDeleteRequest - Response:
OpsBackupDeleteResponse
- request definition
go
type OpsBackupDeleteRequest struct {
ID string `path:"id"`
}- response definition
go
type OpsBackupDeleteResponse struct {
Code int `json:"code"`
Message string `json:"message"`
Data interface{} `json:"data,omitempty"`
}15. "下载备份"
- route definition
- Url: /api/v1/ops/backups/:id/download
- Method: GET
- Request:
OpsBackupDownloadRequest - Response:
OpsBackupDownloadResponse
- request definition
go
type OpsBackupDownloadRequest struct {
ID string `path:"id"`
}- response definition
go
type OpsBackupDownloadResponse struct {
Code int `json:"code"`
Message string `json:"message"`
Data interface{} `json:"data,omitempty"`
}16. "获取运维配置"
- route definition
- Url: /api/v1/ops/config
- Method: GET
- Request:
OpsConfigRequest - Response:
OpsConfigResponse
- request definition
go
type OpsConfigRequest struct {
}- response definition
go
type OpsConfigResponse struct {
Code int `json:"code"`
Message string `json:"message"`
Data interface{} `json:"data,omitempty"`
}17. "获取函数列表"
- route definition
- Url: /api/v1/ops/functions
- Method: GET
- Request:
OpsFunctionsRequest - Response:
OpsFunctionsResponse
- request definition
go
type OpsFunctionsRequest struct {
}- response definition
go
type OpsFunctionsResponse struct {
Code int `json:"code"`
Message string `json:"message"`
Data interface{} `json:"data,omitempty"`
}18. "获取健康状态"
- route definition
- Url: /api/v1/ops/health
- Method: GET
- Request:
OpsHealthGetRequest - Response:
OpsHealthGetResponse
- request definition
go
type OpsHealthGetRequest struct {
}- response definition
go
type OpsHealthGetResponse struct {
Code int `json:"code"`
Message string `json:"message"`
Data interface{} `json:"data,omitempty"`
}19. "更新健康检查配置"
- route definition
- Url: /api/v1/ops/health
- Method: PUT
- Request:
OpsHealthUpdateRequest - Response:
OpsHealthUpdateResponse
- request definition
go
type OpsHealthUpdateRequest struct {
Enabled bool `json:"enabled"`
Checks []OpsHealthCheck `json:"checks,optional"`
}- response definition
go
type OpsHealthUpdateResponse struct {
Code int `json:"code"`
Message string `json:"message"`
Data interface{} `json:"data,omitempty"`
}20. "运行健康检查"
- route definition
- Url: /api/v1/ops/health/run
- Method: POST
- Request:
OpsHealthRunRequest - Response:
OpsHealthRunResponse
- request definition
go
type OpsHealthRunRequest struct {
ID string `json:"id,optional"`
}- response definition
go
type OpsHealthRunResponse struct {
Code int `json:"code"`
Message string `json:"message"`
Data interface{} `json:"data,omitempty"`
}21. "获取维护模式状态"
- route definition
- Url: /api/v1/ops/maintenance
- Method: GET
- Request:
OpsMaintenanceGetRequest - Response:
OpsMaintenanceGetResponse
- request definition
go
type OpsMaintenanceGetRequest struct {
}- response definition
go
type OpsMaintenanceGetResponse struct {
Code int `json:"code"`
Message string `json:"message"`
Data interface{} `json:"data,omitempty"`
}22. "更新维护模式"
- route definition
- Url: /api/v1/ops/maintenance
- Method: PUT
- Request:
OpsMaintenanceUpdateRequest - Response:
OpsMaintenanceUpdateResponse
- request definition
go
type OpsMaintenanceUpdateRequest struct {
Enabled bool `json:"enabled"`
Message string `json:"message,optional"`
Windows []OpsMaintenanceWindow `json:"windows,optional"`
}- response definition
go
type OpsMaintenanceUpdateResponse struct {
Code int `json:"code"`
Message string `json:"message"`
Data interface{} `json:"data,omitempty"`
}23. "获取指标"
- route definition
- Url: /api/v1/ops/metrics
- Method: GET
- Request:
OpsMetricsQuery - Response:
OpsMetricsResponse
- request definition
go
type OpsMetricsQuery struct {
Start string `form:"start,optional"`
End string `form:"end,optional"`
}- response definition
go
type OpsMetricsResponse struct {
Code int `json:"code"`
Message string `json:"message"`
Data interface{} `json:"data,omitempty"`
}24. "获取消息队列状态"
- route definition
- Url: /api/v1/ops/mq
- Method: GET
- Request:
OpsMQRequest - Response:
OpsMQResponse
- request definition
go
type OpsMQRequest struct {
}- response definition
go
type OpsMQResponse struct {
Code int `json:"code"`
Message string `json:"message"`
Data interface{} `json:"data,omitempty"`
}25. "获取节点列表"
- route definition
- Url: /api/v1/ops/nodes
- Method: GET
- Request:
OpsNodesRequest - Response:
OpsNodesResponse
- request definition
go
type OpsNodesRequest struct {
}- response definition
go
type OpsNodesResponse struct {
Code int `json:"code"`
Message string `json:"message"`
Data interface{} `json:"data,omitempty"`
}
// Data 实际为 []Node。Node 描述一个接入的 Agent 节点;
// SDKLanguage / SDKVersion 来自该 Agent 上 provider 的元数据(Instance.Metadata 端到端透传)。
type Node struct {
Id string `json:"id"`
Hostname string `json:"hostname"`
Addr string `json:"addr"`
GameId string `json:"gameId"` // 作用域:游戏
Env string `json:"env"` // 作用域:环境
Status string `json:"status"` // active / inactive
Labels map[string]string `json:"labels"`
LastSeen string `json:"lastSeen"` // RFC3339
SDKLanguage string `json:"sdkLanguage,omitempty"` // go/java/python/cpp/csharp/node/custom
SDKVersion string `json:"sdkVersion,omitempty"`
}26. "排空节点"
- route definition
- Url: /api/v1/ops/nodes/:nodeId/drain
- Method: POST
- Request:
OpsNodeActionRequest - Response:
OpsNodeDrainResponse
- request definition
go
type OpsNodeActionRequest struct {
NodeID string `path:"nodeId"`
}- response definition
go
type OpsNodeDrainResponse struct {
Code int `json:"code"`
Message string `json:"message"`
Data interface{} `json:"data,omitempty"`
}27. "获取节点元数据"
- route definition
- Url: /api/v1/ops/nodes/:nodeId/meta
- Method: GET
- Request:
OpsNodeMetaRequest - Response:
OpsNodeMetaResponse
- request definition
go
type OpsNodeMetaRequest struct {
NodeID string `path:"nodeId"`
}- response definition
go
type OpsNodeMetaResponse struct {
Code int `json:"code"`
Message string `json:"message"`
Data interface{} `json:"data,omitempty"`
}28. "重启节点"
- route definition
- Url: /api/v1/ops/nodes/:nodeId/restart
- Method: POST
- Request:
OpsNodeActionRequest - Response:
OpsNodeRestartResponse
- request definition
go
type OpsNodeActionRequest struct {
NodeID string `path:"nodeId"`
}- response definition
go
type OpsNodeRestartResponse struct {
Code int `json:"code"`
Message string `json:"message"`
Data interface{} `json:"data,omitempty"`
}29. "取消排空节点"
- route definition
- Url: /api/v1/ops/nodes/:nodeId/undrain
- Method: POST
- Request:
OpsNodeActionRequest - Response:
OpsNodeUndrainResponse
- request definition
go
type OpsNodeActionRequest struct {
NodeID string `path:"nodeId"`
}- response definition
go
type OpsNodeUndrainResponse struct {
Code int `json:"code"`
Message string `json:"message"`
Data interface{} `json:"data,omitempty"`
}30. "获取节点命令"
- route definition
- Url: /api/v1/ops/nodes/commands
- Method: GET
- Request:
OpsNodeCommandsQuery - Response:
OpsNodeCommandsResponse
- request definition
go
type OpsNodeCommandsQuery struct {
NodeID string `form:"nodeId"`
}- response definition
go
type OpsNodeCommandsResponse struct {
Code int `json:"code"`
Message string `json:"message"`
Data interface{} `json:"data,omitempty"`
}31. "获取通知配置"
- route definition
- Url: /api/v1/ops/notifications
- Method: GET
- Request:
OpsNotificationsGetRequest - Response:
OpsNotificationsGetResponse
- request definition
go
type OpsNotificationsGetRequest struct {
}- response definition
go
type OpsNotificationsGetResponse struct {
Code int `json:"code"`
Message string `json:"message"`
Data interface{} `json:"data,omitempty"`
}32. "更新通知配置"
- route definition
- Url: /api/v1/ops/notifications
- Method: PUT
- Request:
OpsNotificationsUpdateRequest - Response:
OpsNotificationsUpdateResponse
- request definition
go
type OpsNotificationsUpdateRequest struct {
Enabled bool `json:"enabled"`
Channels []OpsNotificationChannel `json:"channels,optional"`
Rules []OpsNotificationRule `json:"rules,optional"`
}- response definition
go
type OpsNotificationsUpdateResponse struct {
Code int `json:"code"`
Message string `json:"message"`
Data interface{} `json:"data,omitempty"`
}33. "获取服务列表"
- route definition
- Url: /api/v1/ops/services
- Method: GET
- Request:
OpsServicesRequest - Response:
OpsServicesResponse
- request definition
go
type OpsServicesRequest struct {
}- response definition
go
type OpsServicesResponse struct {
Code int `json:"code"`
Message string `json:"message"`
Data interface{} `json:"data,omitempty"`
}34. "获取静默规则列表"
- route definition
- Url: /api/v1/ops/silences
- Method: GET
- Request:
OpsSilencesRequest - Response:
OpsSilencesResponse
- request definition
go
type OpsSilencesRequest struct {
}- response definition
go
type OpsSilencesResponse struct {
Code int `json:"code"`
Message string `json:"message"`
Data interface{} `json:"data,omitempty"`
}35. "删除静默规则"
- route definition
- Url: /api/v1/ops/silences/:id
- Method: DELETE
- Request:
OpsAlertSilenceDeleteRequest - Response:
OpsSilenceDeleteResponse
- request definition
go
type OpsAlertSilenceDeleteRequest struct {
ID string `path:"id"`
}- response definition
go
type OpsSilenceDeleteResponse struct {
Code int `json:"code"`
Message string `json:"message"`
Data interface{} `json:"data,omitempty"`
}