Documentation ¶
Index ¶
- Constants
- type Context
- type FileInfo
- type FilePath
- type Service
- func (s *Service) CacheUpload(c *Context)
- func (s *Service) DataExport(c *Context)
- func (s *Service) DataImport(c *Context)
- func (s *Service) DeleteCommandHistory(c *Context)
- func (s *Service) DeleteFile(c *Context)
- func (s *Service) DeleteFileOrDir(hostId int, path string) error
- func (s *Service) DeleteGroup(c *Context)
- func (s *Service) DeleteHost(c *Context)
- func (s *Service) DeleteInstances(c *Context)
- func (s *Service) DeleteJob(c *Context)
- func (s *Service) DeletePlayBook(c *Context)
- func (s *Service) DeletePrivateKey(c *Context)
- func (s *Service) DeleteQuicklyCommand(c *Context)
- func (s *Service) DeleteTag(c *Context)
- func (s *Service) DeleteTunnel(c *Context)
- func (s *Service) DownLoadFile(c *Context)
- func (s *Service) DownloadFile(hostId int, path string) *sftp.File
- func (s *Service) DownloadInstanceLog(c *Context)
- func (s *Service) ExecJob(c *Context)
- func (s *Service) FilePreview(c *Context)
- func (s *Service) FileUploadCancel(c *Context)
- func (s *Service) FileUploadV2(c *Context)
- func (s *Service) GetCommandHistory(c *Context)
- func (s *Service) GetGroups(c *Context)
- func (s *Service) GetHosts(c *Context)
- func (s *Service) GetIndexPage(c *gin.Context)
- func (s *Service) GetInstanceLog(c *Context)
- func (s *Service) GetInstances(c *Context)
- func (s *Service) GetJobs(c *Context)
- func (s *Service) GetOneGroup(c *Context)
- func (s *Service) GetOneHost(c *Context)
- func (s *Service) GetOneJob(c *Context)
- func (s *Service) GetOnePlayBook(c *Context)
- func (s *Service) GetOnePrivateKey(c *Context)
- func (s *Service) GetOneQuicklyCommand(c *Context)
- func (s *Service) GetOneTag(c *Context)
- func (s *Service) GetOneTunnel(c *Context)
- func (s *Service) GetPathInfo(c *Context)
- func (s *Service) GetPathInfoExec(hostId int, p string) (*FilePath, error)
- func (s *Service) GetPlayBooks(c *Context)
- func (s *Service) GetPluginSchema(c *Context)
- func (s *Service) GetPrivateKeys(c *Context)
- func (s *Service) GetQuicklyCommand(c *Context)
- func (s *Service) GetRWFile(hostId int, path string) *sftp.File
- func (s *Service) GetSSHManager() *ssh.Manager
- func (s *Service) GetTags(c *Context)
- func (s *Service) GetTunnels(c *Context)
- func (s *Service) GetVersion(c *Context)
- func (s *Service) GetWebsocketIndex(c *gin.Context)
- func (s *Service) GetWebsocketSSH(c *gin.Context)
- func (s *Service) GetWebsocketVNC(c *gin.Context)
- func (s *Service) MakeDir(hostId int, p, dir string) error
- func (s *Service) MakeDirRemote(c *Context)
- func (s *Service) ModifyFile(c *Context)
- func (s *Service) PlayerExport(c *Context)
- func (s *Service) PlayerImport(c *Context)
- func (s *Service) PluginUpload(c *Context)
- func (s *Service) PostGroup(c *Context)
- func (s *Service) PostHost(c *Context)
- func (s *Service) PostJob(c *Context)
- func (s *Service) PostPlayBook(c *Context)
- func (s *Service) PostPrivateKey(c *Context)
- func (s *Service) PostQuicklyCommand(c *Context)
- func (s *Service) PostTag(c *Context)
- func (s *Service) PostTunnel(c *Context)
- func (s *Service) PutGroup(c *Context)
- func (s *Service) PutHost(c *Context)
- func (s *Service) PutJob(c *Context)
- func (s *Service) PutPlayBook(c *Context)
- func (s *Service) PutPrivateKey(c *Context)
- func (s *Service) PutQuicklyCommand(c *Context)
- func (s *Service) PutTag(c *Context)
- func (s *Service) PutTunnel(c *Context)
- func (s *Service) RunCmd(c *Context)
- func (s *Service) RunCmdExec(hosts []*models.Host, cmd string, sudo bool) []*ssh.Result
- func (s *Service) RunCmdOneAsync(host *models.Host, cmd string, sudo bool, ch chan *ssh.Result, ...)
- func (s *Service) RunCmdWithContext(host *models.Host, cmd ssh.Command, ch chan *ssh.Result)
- func (s *Service) StartJob(c *Context)
- func (s *Service) StopJob(c *Context)
- func (s *Service) UploadFileStream(hosts []*models.Host, tmp *ssh.TempFile, remotePath string, ...)
Constants ¶
const ( MaxPreviewSize = 8 * 1024 * 1024 Utf8Dom = "\xEF\xBB\xBF" )
const ( HttpStatusOk = "200" HttpStatusError = "400" HttpResponseSuccess = "success" )
const IndexPage = "omsUI/dist/index.html"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Context ¶
func (*Context) ResponseError ¶
func (*Context) ResponseOk ¶
func (c *Context) ResponseOk(data interface{})
type FileInfo ¶
type FileInfo struct { Id string `json:"id"` Name string `json:"name"` ModTime time.Time `json:"modDate"` Size int64 `json:"size"` IsDir bool `json:"isDir,omitempty"` IsSymlink bool `json:"isSymlink,omitempty"` IsHidden bool `json:"isHidden,omitempty"` Ext string `json:"ext"` ChildrenCount int `json:"childrenCount,omitempty"` ParentId string `json:"parentId,omitempty"` ChildrenIds []string `json:"children_ids,omitempty"` Icon string `json:"icon,omitempty"` }
type Service ¶
type Service struct { Engine *gin.Engine Addr string Logger *logger.Logger // contains filtered or unexported fields }
func NewService ¶
func (*Service) CacheUpload ¶
CacheUpload @Summary 上传临时文件 @Description 上传临时文件 @Param files formData file true "multi文件" @Tags player @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response @Failure 400 {object} payload.Response @Router /cache/upload [post]
func (*Service) DataExport ¶
DataExport @Summary 导出资产文件csv @Description 导出资产文件csv @Tags tool @Accept x-www-form-urlencoded @Produce application/octet-stream @Success 200 @Failure 400 {object} payload.Response @Router /tools/export [get]
func (*Service) DataImport ¶
DataImport @Summary 导入资产文件csv @Description 导入资产文件csv @Param files formData file true "csv文件" @Tags tool @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response{data=models.HostExport} @Failure 400 {object} payload.Response @Router /tools/import [post]
func (*Service) DeleteCommandHistory ¶
DeleteCommandHistory @Summary 删除命令历史 @Description 删除命令历史 @Param id path int true "命令历史 ID" @Tags command @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response @Failure 400 {object} payload.Response @Router /command/history/{id} [delete]
func (*Service) DeleteFile ¶
DeleteFile @Summary 删除文件 @Description 删除文件 @Param id formData string true "远端文件路径" @Param host_id formData integer true "主机 ID" @Tags tool @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response @Failure 400 {object} payload.Response @Router /tools/delete [post]
func (*Service) DeleteGroup ¶
DeleteGroup @Summary 删除组 @Description 删除组 @Param id path int true "组 ID" @Tags group @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response @Failure 400 {object} payload.Response @Router /group/{id} [delete]
func (*Service) DeleteHost ¶
DeleteHost @Summary 删除主机 @Description 删除主机 @Param id path int true "主机 ID" @Tags host @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response @Failure 400 {object} payload.Response @Router /host/{id} [delete]
func (*Service) DeleteInstances ¶
DeleteInstances @Summary 删除任务执行结果 @Description 删除任务执行结果 @Param job_id formData integer false "任务 ID" @Param time_stamp formData integer false "截止时间戳(之前的数据都将删除)" @Tags job @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response @Failure 400 {object} payload.Response @Router /task/instance [delete]
func (*Service) DeleteJob ¶
DeleteJob @Summary 删除任务 @Description 删除任务 @Param id path int true "任务 ID" @Tags job @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response @Failure 400 {object} payload.Response @Router /job/{id} [delete]
func (*Service) DeletePlayBook ¶
DeletePlayBook @Summary 删除剧本 @Description 删除剧本 @Param id path int true "剧本 ID" @Tags player @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response @Failure 400 {object} payload.Response @Router /player/{id} [delete]
func (*Service) DeletePrivateKey ¶
DeletePrivateKey @Summary 删除密钥 @Description 删除密钥 @Param id path int true "密钥 ID" @Tags private_key @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response @Failure 400 {object} payload.Response @Router /private_key/{id} [delete]
func (*Service) DeleteQuicklyCommand ¶
DeleteQuicklyCommand @Summary 删除快捷命令 @Description 删除快捷命令 @Param id path int true "快捷命令 ID" @Tags command @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response @Failure 400 {object} payload.Response @Router /quick_command/{id} [delete]
func (*Service) DeleteTag ¶
DeleteTag @Summary 删除标签 @Description 删除标签 @Param id path int true "标签 ID" @Tags tag @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response @Failure 400 {object} payload.Response @Router /tag/{id} [delete]
func (*Service) DeleteTunnel ¶
DeleteTunnel @Summary 删除隧道 @Description 删除隧道 @Param id path int true "隧道 ID" @Tags group @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response @Failure 400 {object} payload.Response @Router /tunnel/{id} [delete]
func (*Service) DownLoadFile ¶
DownLoadFile @Summary 下载文件 @Description 下载文件 @Param id query string true "远端文件路径" @Param host_id query integer true "主机 ID" @Tags tool @Accept x-www-form-urlencoded @Produce application/octet-stream @Success 200 @Failure 400 {object} payload.Response @Router /tools/download [get]
func (*Service) DownloadInstanceLog ¶
func (*Service) ExecJob ¶
ExecJob @Summary 单次执行任务 @Description 单次执行任务 @Param id formData integer true "任务 ID" @Tags job @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response{data=models.Job} @Failure 400 {object} payload.Response @Router /job/exec [post]
func (*Service) FilePreview ¶
FilePreview @Summary 文件预览 @Description 文件预览 @Param id query string true "远端文件路径" @Param host_id query integer true "主机 ID" @Tags tool @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response @Failure 400 {object} payload.Response @Router /tools/preview [get]
func (*Service) FileUploadCancel ¶
FileUploadCancel @Summary 取消文件上传任务 @Description 取消文件上传任务 @Param addr formData string true "地址和端口" @Param file formData string true "文件名" @Tags tool @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response @Failure 400 {object} payload.Response @Router /tools/upload/cancel [post]
func (*Service) FileUploadV2 ¶
FileUploadV2 @Summary 上传文件到主机 @Description 上传文件到主机 @Param X-Files header string true "预处理文件列表" example({"filename base64": "file.size"}) @Param id formData integer true "执行者 ID" @Param type formData string true "执行者类型" example(host,group,tag) @Param remote formData string true "远端文件夹" @Tags tool @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response @Failure 400 {object} payload.Response @Router /tools/upload [post]
func (*Service) GetCommandHistory ¶
GetCommandHistory @Summary 模糊查询历史命令 @Description 模糊查询历史命令 @Param keyword query string true "关键词" @Param limit query integer false "limit" @Tags command @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response{data=[]string} @Failure 400 {object} payload.Response @Router /command/history [get]
func (*Service) GetGroups ¶
GetGroups @Summary 获取所有组 @Description 获取所有组 @Tags group @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response{data=[]models.Group} @Failure 400 {object} payload.Response @Router /group [get]
func (*Service) GetHosts ¶
GetHosts @Summary 获取所有主机 @Description 获取所有主机 @Param page_num query int false "页码数" @Param page_size query int false "分页尺寸" default(20) @Tags host @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response{data=[]models.Host} @Failure 400 {object} payload.Response @Router /host [get]
func (*Service) GetIndexPage ¶
func (*Service) GetInstanceLog ¶
GetInstanceLog @Summary 获取任务执行日志 @Description 获取任务执行日志 @Param id query integer true "执行记录 ID" @Tags tool @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response @Failure 400 {object} payload.Response @Router /task/instance/log/get [get]
func (*Service) GetInstances ¶
GetInstances @Summary 获取所有任务执行结果 @Description 获取所有任务执行结果 @Param job_id query int false "任务 ID" @Param page_num query int false "页码数" @Param page_size query int false "分页尺寸" default(20) @Tags job @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response{data=[]models.TaskInstance} @Failure 400 {object} payload.Response @Router /task/instance [get]
func (*Service) GetJobs ¶
GetJobs @Summary 获取所有任务 @Description 获取所有任务 @Tags job @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response{data=[]models.Job} @Failure 400 {object} payload.Response @Router /job [get]
func (*Service) GetOneGroup ¶
GetOneGroup @Summary 获取单个组 @Description 获取单个组 @Param id path int true "组 ID" @Tags group @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response{data=models.Group} @Failure 400 {object} payload.Response @Router /group/{id} [get]
func (*Service) GetOneHost ¶
GetOneHost @Summary 获取单个主机 @Description 获取单个主机 @Param id path int true "主机 ID" @Tags host @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response{data=models.Host} @Failure 400 {object} payload.Response @Router /host/{id} [get]
func (*Service) GetOneJob ¶
GetOneJob @Summary 获取单个任务 @Description 获取单个任务 @Param id path int true "任务 ID" @Tags job @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response{data=models.Job} @Failure 400 {object} payload.Response @Router /job/{id} [get]
func (*Service) GetOnePlayBook ¶
GetOnePlayBook @Summary 获取单个剧本 @Description 获取单个剧本 @Param id path int true "剧本 ID" @Tags player @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response{data=models.PlayBook} @Failure 400 {object} payload.Response @Router /player/{id} [get]
func (*Service) GetOnePrivateKey ¶
GetOnePrivateKey @Summary 获取单个密钥 @Description 获取单个密钥 @Param id path int true "密钥 ID" @Tags private_key @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response{data=models.PrivateKey} @Failure 400 {object} payload.Response @Router /private_key/{id} [get]
func (*Service) GetOneQuicklyCommand ¶
GetOneQuicklyCommand @Summary 获取单个快捷命令 @Description 获取单个快捷命令 @Param id path int true "快捷命令 ID" @Tags command @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response{data=models.QuicklyCommand} @Failure 400 {object} payload.Response @Router /quick_command/{id} [get]
func (*Service) GetOneTag ¶
GetOneTag @Summary 获取单个标签 @Description 获取单个标签 @Param id path int true "标签 ID" @Tags tag @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response{data=models.Tag} @Failure 400 {object} payload.Response @Router /tag/{id} [get]
func (*Service) GetOneTunnel ¶
GetOneTunnel @Summary 获取单个隧道 @Description 获取单个隧道 @Param id path int true "隧道 ID" @Tags tunnel @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response{data=models.Tunnel} @Failure 400 {object} payload.Response @Router /tunnel/{id} [get]
func (*Service) GetPathInfo ¶
GetPathInfo @Summary 目录列表 @Description 目录列表 @Param id query string true "远端文件路径" @Param host_id query integer true "主机 ID" @Tags tool @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response{data=FilePath} @Failure 400 {object} payload.Response @Router /tools/browse [get]
func (*Service) GetPathInfoExec ¶
func (*Service) GetPlayBooks ¶
GetPlayBooks @Summary 获取所有剧本 @Description 获取所有剧本 @Tags player @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response{data=[]models.PlayBook} @Failure 400 {object} payload.Response @Router /player [get]
func (*Service) GetPluginSchema ¶
GetPluginSchema @Summary 获取所有插件Schema @Description 获取所有插件Schema @Tags player @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response{data=[]ssh.Schema} @Failure 400 {object} payload.Response @Router /schema [get]
func (*Service) GetPrivateKeys ¶
GetPrivateKeys @Summary 获取所有密钥 @Description 获取所有密钥 @Tags private_key @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response{data=[]models.PrivateKey} @Failure 400 {object} payload.Response @Router /private_key [get]
func (*Service) GetQuicklyCommand ¶
GetQuicklyCommand @Summary 获取所有快捷命令 @Description 获取所有快捷命令 @Tags command @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response{data=[]models.QuicklyCommand} @Failure 400 {object} payload.Response @Router /quick_command [get]
func (*Service) GetSSHManager ¶
func (*Service) GetTags ¶
GetTags @Summary 获取所有标签 @Description 获取所有标签 @Tags tag @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response{data=[]models.Tag} @Failure 400 {object} payload.Response @Router /tag [get]
func (*Service) GetTunnels ¶
GetTunnels @Summary 获取所有隧道 @Description 获取所有隧道 @Tags tunnel @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response{data=[]models.Tunnel} @Failure 400 {object} payload.Response @Router /tunnel [get]
func (*Service) GetVersion ¶
GetVersion @Summary 获取当前版本 @Description 获取当前版本 @Tags system @Accept x-www-form-urlencoded @Success 200 {object} string @Router /version [get]
func (*Service) GetWebsocketIndex ¶
GetWebsocketIndex default websocket router
func (*Service) GetWebsocketSSH ¶
GetWebsocketSSH func websocket ssh
func (*Service) GetWebsocketVNC ¶
GetWebsocketVNC func websocket vnc proxy https://github.com/novnc/websockify-other
func (*Service) MakeDirRemote ¶
MakeDirRemote @Summary 创建文件夹 @Description 创建文件夹 @Param id formData string true "远端文件路径" @Param host_id formData integer true "主机 ID" @Param dir formData string true "远端目录地址" @Tags tool @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response @Failure 400 {object} payload.Response @Router /tools/mkdir [post]
func (*Service) ModifyFile ¶
ModifyFile
@Summary 文件修改 @Description 文件修改 @Param id query string true "远端文件路径" @Param host_id query integer true "主机 ID" @Tags tool @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response @Failure 400 {object} payload.Response @Router /tools/modify [post]
func (*Service) PlayerExport ¶
PlayerExport @Summary 导出剧本 @Description 导出剧本 @Tags player @Accept x-www-form-urlencoded @Produce json @Success 200 @Failure 400 {object} payload.Response @Router /player/export [get]
func (*Service) PlayerImport ¶
PlayerImport @Summary 导入剧本 @Description 导入剧本 @Param files formData file true "剧本导出文件(zip)" @Tags player @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response @Failure 400 {object} payload.Response @Router /player/import [post]
func (*Service) PluginUpload ¶
PluginUpload @Summary 上传插件 @Description 上传插件 @Param files formData file true "插件文件(zip or tar.gz)" @Tags player @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response @Failure 400 {object} payload.Response @Router /plugin/upload [post]
func (*Service) PostGroup ¶
PostGroup @Summary 创建组 @Description 创建组 @Param name formData string true "组名称" @Param params formData string false "组参数" @Param mode formData int true "组类型" example(0:主机模式,1:匹配模式) @Tags group @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response{data=models.Group} @Failure 400 {object} payload.Response @Router /group [post]
func (*Service) PostHost ¶
PostHost @Summary 创建主机 @Description 创建主机 @Param hostname formData string true "主机名称" @Param user formData string true "用户名" @Param addr formData string true "地址" @Param port formData integer true "SSH端口" @Param password formData string false "SSH密码" @Param group formData integer false "组ID" @Param private_key_id formData integer false "密钥ID" @Param tags formData string false "标签ID列表序列化字符串" @Param vnc_port formData integer false "VNC端口" @Tags host @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response{data=models.Host} @Failure 400 {object} payload.Response @Router /host [post]
func (*Service) PostJob ¶
PostJob @Summary 创建任务 @Description 创建任务 @Param name formData string true "任务名称" @Param type formData string true "任务类型" example(cron,local) @Param spec formData string false "Cron表达式" @Param cmd formData string false "任务命令" @Param cmd_id formData integer false "剧本ID" @Param cmd_type formData string true "任务命令类型" example(cmd,player) @Param execute_id formData integer true "执行者 ID" @Param execute_type formData string true "执行者类型" example(host,group,tag) @Tags job @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response{data=models.Job} @Failure 400 {object} payload.Response @Router /job [post]
func (*Service) PostPlayBook ¶
PostPlayBook @Summary 创建剧本 @Description 创建剧本 @Param name formData string true "剧本名称" @Param steps formData string true "剧本步骤序列化字符串" example([{"seq":0,"type":"cmd","name":"执行ls","caches":"null","params":"{\"cmd\":\"ls\"}"}]) @Tags player @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response{data=models.PlayBook} @Failure 400 {object} payload.Response @Router /player [post]
func (*Service) PostPrivateKey ¶
PostPrivateKey @Summary 创建密钥 @Description 创建密钥 @Param name formData string true "密钥名称" @Param passphrase formData string false "密钥密码" @Param key_file formData file true "密钥文件" @Tags private_key @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response{data=models.PrivateKey} @Failure 400 {object} payload.Response @Router /private_key [post]
func (*Service) PostQuicklyCommand ¶
PostQuicklyCommand @Summary 创建快捷命令 @Description 创建快捷命令 @Param name formData string true "快捷命令名称" @Param cmd formData string true "快捷命令文本" @Param append_cr formData bool false "是否追加CR" @Tags command @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response{data=models.QuicklyCommand} @Failure 400 {object} payload.Response @Router /quick_command [post]
func (*Service) PostTag ¶
PostTag @Summary 创建标签 @Description 创建标签 @Param name formData string true "标签名称" @Tags tag @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response{data=models.Tag} @Failure 400 {object} payload.Response @Router /tag [post]
func (*Service) PostTunnel ¶
PostTunnel @Summary 创建隧道 @Description 创建隧道 @Param mode formData string true "隧道模式" example(local,remote) @Param source formData string true "源地址" @Param destination formData int true "目的地址" @Param host_id formData int true "主机 ID" @Tags tunnel @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response{data=models.Tunnel} @Failure 400 {object} payload.Response @Router /tunnel [post]
func (*Service) PutGroup ¶
PutGroup @Summary 更新组 @Description 更新组 @Param id formData integer true "组 ID" @Param name formData string false "组名称" @Param params formData string false "组参数" @Param mode formData int false "组类型" example(0:主机模式,1:匹配模式) @Tags group @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response{data=models.Group} @Failure 400 {object} payload.Response @Router /group [put]
func (*Service) PutHost ¶
PutHost @Summary 更新主机 @Description 更新主机 @Param id formData integer true "主机 ID" @Param hostname formData string false "主机名称" @Param user formData string false "用户名" @Param addr formData string false "地址" @Param port formData integer false "SSH端口" @Param password formData string false "SSH密码" @Param group formData integer false "组ID" @Param private_key_id formData integer false "密钥ID" @Param tags formData string false "标签ID列表序列化字符串" @Param vnc_port formData integer false "VNC端口" @Tags host @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response{data=models.Host} @Failure 400 {object} payload.Response @Router /host [put]
func (*Service) PutJob ¶
PutJob @Summary 更新任务 @Description 更新任务 @Param id formData integer true "任务 ID" @Param name formData string false "任务名称" @Param type formData string false "任务类型" example(cron,local) @Param spec formData string false "Cron表达式" @Param cmd formData string false "任务命令" @Param cmd_id formData integer false "剧本ID" @Param cmd_type formData string false "任务命令类型" example(cmd,player) @Tags job @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response{data=models.Job} @Failure 400 {object} payload.Response @Router /job [put]
func (*Service) PutPlayBook ¶
PutPlayBook @Summary 更新剧本 @Description 更新剧本 @Param id formData integer true "剧本 ID" @Param name formData string false "剧本名称" @Param steps formData string false "剧本步骤序列化字符串" example([{"seq":0,"type":"cmd","name":"执行ls","caches":"null","params":"{\"cmd\":\"ls\"}"}]) @Tags player @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response{data=models.PlayBook} @Failure 400 {object} payload.Response @Router /player [put]
func (*Service) PutPrivateKey ¶
PutPrivateKey @Summary 更新密钥 @Description 更新密钥 @Param id formData integer true "密钥 ID" @Param name formData string false "密钥名称" @Param passphrase formData string false "密钥密码" @Param key_file formData file false "密钥文件" @Tags private_key @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response{data=models.PrivateKey} @Failure 400 {object} payload.Response @Router /private_key [put]
func (*Service) PutQuicklyCommand ¶
PutQuicklyCommand @Summary 更新快捷命令 @Description 更新快捷命令 @Param id formData integer true "快捷命令 ID" @Param name formData string false "快捷命令名称" @Param cmd formData string false "快捷命令文本" @Param append_cr formData bool false "是否追加CR" @Tags command @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response{data=models.QuicklyCommand} @Failure 400 {object} payload.Response @Router /quick_command [put]
func (*Service) PutTag ¶
PutTag @Summary 更新标签 @Description 更新标签 @Param id formData integer true "标签 ID" @Param name formData string false "标签名称" @Tags tag @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response{data=models.Tag} @Failure 400 {object} payload.Response @Router /tag [put]
func (*Service) PutTunnel ¶
PutTunnel @Summary 更新隧道 @Description 更新隧道 @Param id formData integer true "隧道 ID" @Param mode formData string false "隧道模式" example(local,remote) @Param source formData string false "源地址" @Param destination formData int false "目的地址" @Param host_id formData int false "主机 ID" @Tags tunnel @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response{data=models.Tunnel} @Failure 400 {object} payload.Response @Router /tunnel [put]
func (*Service) RunCmd ¶
RunCmd @Summary 执行一条命令 @Description 执行一条命令 @Param id query integer true "执行者 ID" @Param type query string true "执行者类型" example(host,group,tag) @Param cmd query string true "命令" @Param sudo query bool false "是否sudo执行" @Tags tool @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response{data=[]ssh.Result} @Failure 400 {object} payload.Response @Router /tools/cmd [get]
func (*Service) RunCmdExec ¶
RunCmdExec 用于http接口
func (*Service) RunCmdOneAsync ¶
func (s *Service) RunCmdOneAsync(host *models.Host, cmd string, sudo bool, ch chan *ssh.Result, wg *sync.WaitGroup)
RunCmdOneAsync 搭配RunCmd使用
func (*Service) RunCmdWithContext ¶
RunCmdWithContext 使用在websocket接口上
func (*Service) StartJob ¶
StartJob @Summary 启动任务调度 @Description 启动任务调度 @Param id formData integer true "任务 ID" @Tags job @Accept x-www-form-urlencoded @Produce json @Success 200 {object} payload.Response{data=models.Job} @Failure 400 {object} payload.Response @Router /job/start [post]