From 67a7d6e46143410a5fa9cfa2554023ab7687ea34 Mon Sep 17 00:00:00 2001 From: Sebastien Douheret Date: Fri, 24 Nov 2017 01:28:00 +0100 Subject: Add folder update support and ClientData field. - folder config can be updated using PUT /folders/:id route - ClientData field of FolderConfig can be used by client to store any data (used from example by dashboard to save build settings) --- lib/apiv1/folders.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'lib/apiv1/folders.go') diff --git a/lib/apiv1/folders.go b/lib/apiv1/folders.go index 398e21c..073445c 100644 --- a/lib/apiv1/folders.go +++ b/lib/apiv1/folders.go @@ -105,3 +105,27 @@ func (s *APIService) delFolder(c *gin.Context) { } c.JSON(http.StatusOK, delEntry) } + +// updateFolder update some field of a folder +func (s *APIService) updateFolder(c *gin.Context) { + id, err := s.mfolders.ResolveID(c.Param("id")) + if err != nil { + common.APIError(c, err.Error()) + return + } + + s.log.Debugln("Update folder id ", id) + + var cfgArg folder.FolderConfig + if c.BindJSON(&cfgArg) != nil { + common.APIError(c, "Invalid arguments") + return + } + + upFld, err := s.mfolders.Update(id, cfgArg) + if err != nil { + common.APIError(c, err.Error()) + return + } + c.JSON(http.StatusOK, upFld) +} -- cgit 1.2.3-korg