aboutsummaryrefslogtreecommitdiffstats
path: root/lib/xaapiv1
diff options
context:
space:
mode:
authorSebastien Douheret <sebastien.douheret@iot.bzh>2017-12-21 15:07:04 +0100
committerSebastien Douheret <sebastien.douheret@iot.bzh>2017-12-23 00:43:11 +0100
commit45f6472d1e8ecad428da314a6d762143f033865d (patch)
tree3d4f3f413ab752fcb0d5c661fd3fec63ba5f5c24 /lib/xaapiv1
parenta85f3ef5017e7e1406476194cd5f3e848a3718f9 (diff)
Added new SDKs management supportv1.0.0-rc2
Signed-off-by: Sebastien Douheret <sebastien.douheret@iot.bzh>
Diffstat (limited to 'lib/xaapiv1')
-rw-r--r--lib/xaapiv1/events.go21
-rw-r--r--lib/xaapiv1/sdks.go50
2 files changed, 65 insertions, 6 deletions
diff --git a/lib/xaapiv1/events.go b/lib/xaapiv1/events.go
index 0ac08e8..16c2dd7 100644
--- a/lib/xaapiv1/events.go
+++ b/lib/xaapiv1/events.go
@@ -45,6 +45,8 @@ const (
EVTProjectAdd = EventTypePrefix + "project-add" // type EventMsg with Data type xaapiv1.ProjectConfig
EVTProjectDelete = EventTypePrefix + "project-delete" // type EventMsg with Data type xaapiv1.ProjectConfig
EVTProjectChange = EventTypePrefix + "project-state-change" // type EventMsg with Data type xaapiv1.ProjectConfig
+ EVTSDKInstall = EventTypePrefix + "sdk-install" // type EventMsg with Data type xaapiv1.SDKManagementMsg
+ EVTSDKRemove = EventTypePrefix + "sdk-remove" // type EventMsg with Data type xaapiv1.SDKManagementMsg
)
// EVTAllList List of all supported events
@@ -53,6 +55,8 @@ var EVTAllList = []string{
EVTProjectAdd,
EVTProjectDelete,
EVTProjectChange,
+ EVTSDKInstall,
+ EVTSDKRemove,
}
// EventMsg Event message send over Websocket, data format depend to Type (see DecodeXXX function)
@@ -92,3 +96,20 @@ func (e *EventMsg) DecodeProjectConfig() (ProjectConfig, error) {
}
return p, err
}
+
+// DecodeSDKMsg Helper to decode Data field type SDKManagementMsg
+func (e *EventMsg) DecodeSDKMsg() (SDKManagementMsg, error) {
+ var err error
+ s := SDKManagementMsg{}
+ switch e.Type {
+ case EVTSDKInstall, EVTSDKRemove:
+ d := []byte{}
+ d, err = json.Marshal(e.Data)
+ if err == nil {
+ err = json.Unmarshal(d, &s)
+ }
+ default:
+ err = fmt.Errorf("Invalid type")
+ }
+ return s, err
+}
diff --git a/lib/xaapiv1/sdks.go b/lib/xaapiv1/sdks.go
index 2dceecf..589f748 100644
--- a/lib/xaapiv1/sdks.go
+++ b/lib/xaapiv1/sdks.go
@@ -17,12 +17,50 @@
package xaapiv1
+// SDK status definition
+const (
+ SdkStatusDisable = "Disable"
+ SdkStatusNotInstalled = "Not Installed"
+ SdkStatusInstalling = "Installing"
+ SdkStatusUninstalling = "Un-installing"
+ SdkStatusInstalled = "Installed"
+)
+
// SDK Define a cross tool chain used to build application
type SDK struct {
- ID string `json:"id" binding:"required"`
- Name string `json:"name"`
- Profile string `json:"profile"`
- Version string `json:"version"`
- Arch string `json:"arch"`
- Path string `json:"path"`
+ ID string `json:"id" binding:"required"`
+ Name string `json:"name"`
+ Description string `json:"description"`
+ Profile string `json:"profile"`
+ Version string `json:"version"`
+ Arch string `json:"arch"`
+ Path string `json:"path"`
+ URL string `json:"url"`
+ Status string `json:"status"`
+ Date string `json:"date"`
+ Size string `json:"size"`
+ Md5sum string `json:"md5sum"`
+ SetupFile string `json:"setupFile"`
+ LastError string `json:"lastError"`
+}
+
+// SDKInstallArgs JSON parameters of POST /sdks or /sdks/abortinstall commands
+type SDKInstallArgs struct {
+ ID string `json:"id" binding:"required"` // install by ID (must be part of GET /sdks result)
+ Filename string `json:"filename"` // install by using a file
+ Force bool `json:"force"` // force SDK install when already existing
+ Timeout int `json:"timeout"` // 1800 == default 30 minutes
+}
+
+// SDKManagementMsg Message send during SDK installation or when installation is complete
+type SDKManagementMsg struct {
+ CmdID string `json:"cmdID"`
+ Timestamp string `json:"timestamp"`
+ Sdk SDK `json:"sdk"`
+ Stdout string `json:"stdout"`
+ Stderr string `json:"stderr"`
+ Progress int `json:"progress"` // 0 = not started to 100% = complete
+ Exited bool `json:"exited"`
+ Code int `json:"code"`
+ Error string `json:"error"`
}