52af5066662e3e887d633753506d88d933157c17
[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         common "github.com/iotbzh/xds-common/golib"
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 }