5ae2b0380c2e7c2ea63276bf3c6047322b79700a
[src/xds/xds-server.git] / lib / apiv1 / sdks.go
1 package apiv1
2
3 import (
4         "net/http"
5         "strconv"
6
7         "github.com/gin-gonic/gin"
8         "github.com/iotbzh/xds-server/lib/common"
9 )
10
11 // getSdks returns all SDKs configuration
12 func (s *APIService) getSdks(c *gin.Context) {
13         c.JSON(http.StatusOK, s.sdks.GetAll())
14 }
15
16 // getSdk returns a specific Sdk configuration
17 func (s *APIService) getSdk(c *gin.Context) {
18         id, err := strconv.Atoi(c.Param("id"))
19         if err != nil {
20                 common.APIError(c, "Invalid id")
21                 return
22         }
23
24         sdk := s.sdks.Get(id)
25         if sdk.Profile == "" {
26                 common.APIError(c, "Invalid id")
27                 return
28         }
29
30         c.JSON(http.StatusOK, sdk)
31 }