add custom snapshot
This commit is contained in:
66
api.go
66
api.go
@@ -2,6 +2,7 @@ package main
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
@@ -13,9 +14,72 @@ func ApiRun(c *gin.Context) {
|
||||
})
|
||||
}
|
||||
|
||||
func ApiSnapshotAdd(c *gin.Context) {
|
||||
if app, ok := cfg.apps[c.Param("app")]; ok {
|
||||
schedule := c.Param("schedule")
|
||||
if _, ok := app.schedule[schedule]; ok {
|
||||
if err := app.RunStandaloneSchedule(schedule); err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{
|
||||
"message": "error",
|
||||
"error": err,
|
||||
})
|
||||
} else {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"message": "done",
|
||||
})
|
||||
}
|
||||
} else {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{
|
||||
"message": "error",
|
||||
"error": "no schedule found",
|
||||
})
|
||||
}
|
||||
} else {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{
|
||||
"message": "error",
|
||||
"error": "no app found",
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func ApiSnapshotDel(c *gin.Context) {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{
|
||||
"message": "error",
|
||||
"error": "not implemented",
|
||||
})
|
||||
}
|
||||
|
||||
func ApiSnapshotList(c *gin.Context) {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{
|
||||
"message": "error",
|
||||
"error": "not implemented",
|
||||
})
|
||||
}
|
||||
|
||||
func ApiScheduleAdd(c *gin.Context) {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{
|
||||
"message": "error",
|
||||
"error": "not implemented",
|
||||
})
|
||||
}
|
||||
|
||||
func ApiScheduleDel(c *gin.Context) {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{
|
||||
"message": "error",
|
||||
"error": "not implemented",
|
||||
})
|
||||
}
|
||||
|
||||
func ApiScheduleList(c *gin.Context) {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{
|
||||
"message": "error",
|
||||
"error": "not implemented",
|
||||
})
|
||||
}
|
||||
|
||||
func ApiRunApp(c *gin.Context) {
|
||||
if app, ok := cfg.apps[c.Param("app")]; ok {
|
||||
if err := app.RunFull(); err != nil {
|
||||
if err := app.RunStandaloneTime(time.Now()); err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{
|
||||
"message": "error",
|
||||
"error": err,
|
||||
|
||||
Reference in New Issue
Block a user