4 "github.com/Sirupsen/logrus"
5 "github.com/gin-gonic/gin"
7 "github.com/iotbzh/xds-server/lib/crosssdk"
8 "github.com/iotbzh/xds-server/lib/model"
9 "github.com/iotbzh/xds-server/lib/session"
10 "github.com/iotbzh/xds-server/lib/xdsconfig"
14 type APIService struct {
16 apiRouter *gin.RouterGroup
17 sessions *session.Sessions
19 mfolders *model.Folders
24 // New creates a new instance of API service
25 func New(r *gin.Engine, sess *session.Sessions, cfg *xdsconfig.Config, mfolders *model.Folders, sdks *crosssdk.SDKs) *APIService {
29 apiRouter: r.Group("/api/v1"),
36 s.apiRouter.GET("/version", s.getVersion)
38 s.apiRouter.GET("/config", s.getConfig)
39 s.apiRouter.POST("/config", s.setConfig)
41 s.apiRouter.GET("/folders", s.getFolders)
42 s.apiRouter.GET("/folder/:id", s.getFolder)
43 s.apiRouter.POST("/folder", s.addFolder)
44 s.apiRouter.POST("/folder/sync/:id", s.syncFolder)
45 s.apiRouter.DELETE("/folder/:id", s.delFolder)
47 s.apiRouter.GET("/sdks", s.getSdks)
48 s.apiRouter.GET("/sdk/:id", s.getSdk)
50 s.apiRouter.POST("/make", s.buildMake)
51 s.apiRouter.POST("/make/:id", s.buildMake)
53 s.apiRouter.POST("/exec", s.execCmd)
54 s.apiRouter.POST("/exec/:id", s.execCmd)
55 s.apiRouter.POST("/signal", s.execSignalCmd)
57 s.apiRouter.GET("/events", s.eventsList)
58 s.apiRouter.POST("/events/register", s.eventsRegister)
59 s.apiRouter.POST("/events/unregister", s.eventsUnRegister)