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