diff options
Diffstat (limited to 'lib/apiv1/sdks.go')
-rw-r--r-- | lib/apiv1/sdks.go | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/lib/apiv1/sdks.go b/lib/apiv1/sdks.go new file mode 100644 index 0000000..5ae2b03 --- /dev/null +++ b/lib/apiv1/sdks.go @@ -0,0 +1,31 @@ +package apiv1 + +import ( + "net/http" + "strconv" + + "github.com/gin-gonic/gin" + "github.com/iotbzh/xds-server/lib/common" +) + +// getSdks returns all SDKs configuration +func (s *APIService) getSdks(c *gin.Context) { + c.JSON(http.StatusOK, s.sdks.GetAll()) +} + +// getSdk returns a specific Sdk configuration +func (s *APIService) getSdk(c *gin.Context) { + id, err := strconv.Atoi(c.Param("id")) + if err != nil { + common.APIError(c, "Invalid id") + return + } + + sdk := s.sdks.Get(id) + if sdk.Profile == "" { + common.APIError(c, "Invalid id") + return + } + + c.JSON(http.StatusOK, sdk) +} |