2 * Copyright (C) 2017-2018 "IoT.bzh"
3 * Author Sebastien Douheret <sebastien@iot.bzh>
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
21 "github.com/gin-gonic/gin"
25 type APIService struct {
27 apiRouter *gin.RouterGroup
30 // NewAPIV1 creates a new instance of API service
31 func NewAPIV1(ctx *Context) *APIService {
34 apiRouter: ctx.WWWServer.router.Group("/api/v1"),
37 s.apiRouter.GET("/version", s.getVersion)
39 s.apiRouter.GET("/config", s.getConfig)
40 s.apiRouter.POST("/config", s.setConfig)
42 s.apiRouter.GET("/folders", s.getFolders)
43 s.apiRouter.GET("/folders/:id", s.getFolder)
44 s.apiRouter.PUT("/folders/:id", s.updateFolder)
45 s.apiRouter.POST("/folders", s.addFolder)
46 s.apiRouter.POST("/folders/sync/:id", s.syncFolder)
47 s.apiRouter.DELETE("/folders/:id", s.delFolder)
49 s.apiRouter.GET("/sdks", s.getSdks)
50 s.apiRouter.GET("/sdks/:id", s.getSdk)
51 s.apiRouter.POST("/sdks", s.installSdk)
52 s.apiRouter.POST("/sdks/abortinstall", s.abortInstallSdk)
53 s.apiRouter.DELETE("/sdks/:id", s.removeSdk)
55 s.apiRouter.POST("/make", s.buildMake)
56 s.apiRouter.POST("/make/:id", s.buildMake)
58 s.apiRouter.POST("/exec", s.execCmd)
59 s.apiRouter.POST("/exec/:id", s.execCmd)
60 s.apiRouter.POST("/signal", s.execSignalCmd)
62 s.apiRouter.GET("/events", s.eventsList)
63 s.apiRouter.POST("/events/register", s.eventsRegister)
64 s.apiRouter.POST("/events/unregister", s.eventsUnRegister)
66 s.apiRouter.GET("/targets", s.getTargets)
67 s.apiRouter.GET("/targets/:id", s.getTarget)
68 s.apiRouter.POST("/targets", s.addTarget)
69 s.apiRouter.DELETE("/targets/:id", s.delTarget)
70 s.apiRouter.GET("/targets/:id/terminals", s.getTgtTerms)
71 s.apiRouter.GET("/targets/:id/terminals/:tid", s.getTgtTerm)
72 s.apiRouter.POST("/targets/:id/terminals", s.createTgtTerm)
73 s.apiRouter.PUT("/targets/:id/terminals/:tid", s.updateTgtTerm)
74 s.apiRouter.DELETE("/targets/:id/terminals/:tid", s.delTgtTerm)
75 s.apiRouter.POST("/targets/:id/terminals/:tid/open", s.openTgtTerm)
76 s.apiRouter.POST("/targets/:id/terminals/:tid/close", s.closeTgtTerm)
77 s.apiRouter.POST("/targets/:id/terminals/:tid/resize", s.resizeTgtTerm)
78 s.apiRouter.POST("/targets/:id/terminals/:tid/signal", s.signalTgtTerm)
79 s.apiRouter.POST("/targets/:id/terminals/:tid/signal/:sig", s.signalTgtTerm)
81 s.apiRouter.GET("/updates", s.getXdsSrvUpdate)
82 s.apiRouter.POST("/updates", s.xdsSrvUpdate)