aboutsummaryrefslogtreecommitdiffstats
path: root/lib/xsapiv1
diff options
context:
space:
mode:
authorSebastien Douheret <sebastien.douheret@iot.bzh>2017-12-22 21:26:40 +0100
committerSebastien Douheret <sebastien.douheret@iot.bzh>2017-12-22 21:29:59 +0100
commitf1c182ede3c4aed0d6196d05b0a64ff93372e755 (patch)
tree2cf95732a06808aac8325bccb5199346b33165a2 /lib/xsapiv1
parent285332c351777b74abca638b8b2a2cde3c68edc6 (diff)
Added SDKs management support.
Signed-off-by: Sebastien Douheret <sebastien.douheret@iot.bzh>
Diffstat (limited to 'lib/xsapiv1')
-rw-r--r--lib/xsapiv1/events.go12
-rw-r--r--lib/xsapiv1/sdks.go61
2 files changed, 62 insertions, 11 deletions
diff --git a/lib/xsapiv1/events.go b/lib/xsapiv1/events.go
index 1552579..84e62c1 100644
--- a/lib/xsapiv1/events.go
+++ b/lib/xsapiv1/events.go
@@ -24,8 +24,8 @@ import (
// EventRegisterArgs Parameters (json format) of /events/register command
type EventRegisterArgs struct {
- Name string `json:"name"`
- ProjectID string `json:"filterProjectID"`
+ Name string `json:"name"`
+ Filter string `json:"filter"`
}
// EventUnRegisterArgs Parameters of /events/unregister command
@@ -49,14 +49,18 @@ const (
// Supported Events type
EVTAll = EventTypePrefix + "all"
- EVTFolderChange = EventTypePrefix + "folder-change" // type EventMsg with Data type xsapiv1.???
- EVTFolderStateChange = EventTypePrefix + "folder-state-change" // type EventMsg with Data type xsapiv1.???
+ EVTFolderChange = EventTypePrefix + "folder-change" // type EventMsg with Data type xsapiv1.FolderConfig
+ EVTFolderStateChange = EventTypePrefix + "folder-state-change" // type EventMsg with Data type xsapiv1.FolderConfig
+ EVTSDKInstall = EventTypePrefix + "sdk-install" // type EventMsg with Data type xsapiv1.SDKManagementMsg
+ EVTSDKRemove = EventTypePrefix + "sdk-remove" // type EventMsg with Data type xsapiv1.SDKManagementMsg
)
// EVTAllList List of all supported events
var EVTAllList = []string{
EVTFolderChange,
EVTFolderStateChange,
+ EVTSDKInstall,
+ EVTSDKRemove,
}
// DecodeFolderConfig Helper to decode Data field type FolderConfig
diff --git a/lib/xsapiv1/sdks.go b/lib/xsapiv1/sdks.go
index 4bc390a..3a79c99 100644
--- a/lib/xsapiv1/sdks.go
+++ b/lib/xsapiv1/sdks.go
@@ -17,15 +17,62 @@
package xsapiv1
+// 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"`
// Not exported fields
- EnvFile string `json:"-"`
+ FamilyConf SDKFamilyConfig `json:"-"`
+}
+
+// SDKFamilyConfig Configuration structure to define a SDKs family
+type SDKFamilyConfig struct {
+ FamilyName string `json:"familyName"`
+ Description string `json:"description"`
+ RootDir string `json:"rootDir"`
+ EnvSetupFile string `json:"envSetupFilename"`
+ ScriptsDir string `json:"scriptsDir"`
+}
+
+// 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"`
}