summaryrefslogtreecommitdiffstats
path: root/lib/folder
diff options
context:
space:
mode:
authorSebastien Douheret <sebastien.douheret@iot.bzh>2017-11-24 01:28:00 +0100
committerSebastien Douheret <sebastien.douheret@iot.bzh>2017-11-24 01:28:00 +0100
commit67a7d6e46143410a5fa9cfa2554023ab7687ea34 (patch)
tree6168592c5cc72a39795aa49a5683a81f2b872a19 /lib/folder
parentd2335afe1058153a3aad27fa483499b0639e096c (diff)
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)
Diffstat (limited to 'lib/folder')
-rw-r--r--lib/folder/folder-interface.go7
-rw-r--r--lib/folder/folder-pathmap.go9
-rw-r--r--lib/folder/folder-st-disable.go5
3 files changed, 21 insertions, 0 deletions
diff --git a/lib/folder/folder-interface.go b/lib/folder/folder-interface.go
index 9eb6829..3208869 100644
--- a/lib/folder/folder-interface.go
+++ b/lib/folder/folder-interface.go
@@ -30,6 +30,7 @@ type IFOLDER interface {
ConvPathCli2Svr(s string) string // Convert path from Client to Server
ConvPathSvr2Cli(s string) string // Convert path from Server to Client
Remove() error // Remove a folder
+ Update(cfg FolderConfig) (*FolderConfig, error) // Update a new folder
RegisterEventChange(cb *EventCB, data *EventCBData) error // Request events registration (sent through WS)
UnRegisterEventChange() error // Un-register events
Sync() error // Force folder files synchronization
@@ -45,6 +46,7 @@ type FolderConfig struct {
Status string `json:"status"`
IsInSync bool `json:"isInSync"`
DefaultSdk string `json:"defaultSdk"`
+ ClientData string `json:"clientData"` // free form field that can used by client
// Not exported fields from REST API point of view
RootPath string `json:"-"`
@@ -58,6 +60,11 @@ type FolderConfig struct {
DataCloudSync CloudSyncConfig `json:"dataCloudSync,omitempty"`
}
+// FolderConfigUpdatableFields List fields that can be updated using Update function
+var FolderConfigUpdatableFields = []string{
+ "Label", "DefaultSdk", "ClientData",
+}
+
// PathMapConfig Path mapping specific data
type PathMapConfig struct {
ServerPath string `json:"serverPath"`
diff --git a/lib/folder/folder-pathmap.go b/lib/folder/folder-pathmap.go
index e200164..c5691a3 100644
--- a/lib/folder/folder-pathmap.go
+++ b/lib/folder/folder-pathmap.go
@@ -145,6 +145,15 @@ func (f *PathMap) Remove() error {
return nil
}
+// Update update some fields of a folder
+func (f *PathMap) Update(cfg FolderConfig) (*FolderConfig, error) {
+ if f.config.ID != cfg.ID {
+ return nil, fmt.Errorf("Invalid id")
+ }
+ f.config = cfg
+ return &f.config, nil
+}
+
// RegisterEventChange requests registration for folder change event
func (f *PathMap) RegisterEventChange(cb *EventCB, data *EventCBData) error {
return nil
diff --git a/lib/folder/folder-st-disable.go b/lib/folder/folder-st-disable.go
index 7b53ca8..e936494 100644
--- a/lib/folder/folder-st-disable.go
+++ b/lib/folder/folder-st-disable.go
@@ -65,6 +65,11 @@ func (f *STFolderDisable) Remove() error {
return nil
}
+// Update update some fields of a folder
+func (f *STFolderDisable) Update(cfg FolderConfig) (*FolderConfig, error) {
+ return nil, nil
+}
+
// RegisterEventChange requests registration for folder change event
func (f *STFolderDisable) RegisterEventChange(cb *EventCB, data *EventCBData) error {
return nil