summaryrefslogtreecommitdiffstats
path: root/lib/xsapiv1
diff options
context:
space:
mode:
Diffstat (limited to 'lib/xsapiv1')
-rw-r--r--lib/xsapiv1/config.go18
-rw-r--r--lib/xsapiv1/events.go31
-rw-r--r--lib/xsapiv1/exec.go76
-rw-r--r--lib/xsapiv1/folders.go61
-rw-r--r--lib/xsapiv1/sdks.go14
-rw-r--r--lib/xsapiv1/version.go9
6 files changed, 209 insertions, 0 deletions
diff --git a/lib/xsapiv1/config.go b/lib/xsapiv1/config.go
new file mode 100644
index 0000000..33bc116
--- /dev/null
+++ b/lib/xsapiv1/config.go
@@ -0,0 +1,18 @@
+package xsapiv1
+
+// APIConfig parameters (json format) of /config command
+type APIConfig struct {
+ ServerUID string `json:"id"`
+ Version string `json:"version"`
+ APIVersion string `json:"apiVersion"`
+ VersionGitTag string `json:"gitTag"`
+ SupportedSharing map[string]bool `json:"supportedSharing"`
+ Builder BuilderConfig `json:"builder"`
+}
+
+// BuilderConfig represents the builder container configuration
+type BuilderConfig struct {
+ IP string `json:"ip"`
+ Port string `json:"port"`
+ SyncThingID string `json:"syncThingID"`
+}
diff --git a/lib/xsapiv1/events.go b/lib/xsapiv1/events.go
new file mode 100644
index 0000000..1304b3a
--- /dev/null
+++ b/lib/xsapiv1/events.go
@@ -0,0 +1,31 @@
+package xsapiv1
+
+// EventRegisterArgs Parameters (json format) of /events/register command
+type EventRegisterArgs struct {
+ Name string `json:"name"`
+ ProjectID string `json:"filterProjectID"`
+}
+
+// EventUnRegisterArgs Parameters of /events/unregister command
+type EventUnRegisterArgs struct {
+ Name string `json:"name"`
+ ID int `json:"id"`
+}
+
+// EventMsg Message send
+type EventMsg struct {
+ Time string `json:"time"`
+ Type string `json:"type"`
+ Folder FolderConfig `json:"folder"`
+}
+
+// EventEvent Event send in WS when an internal event (eg. Syncthing event is received)
+const (
+ // EventTypePrefix Used as event prefix
+ EventTypePrefix = "event:" // following by event type
+
+ // 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.???
+)
diff --git a/lib/xsapiv1/exec.go b/lib/xsapiv1/exec.go
new file mode 100644
index 0000000..dce9eff
--- /dev/null
+++ b/lib/xsapiv1/exec.go
@@ -0,0 +1,76 @@
+package xsapiv1
+
+type (
+ // ExecArgs JSON parameters of /exec command
+ ExecArgs struct {
+ ID string `json:"id" binding:"required"`
+ SdkID string `json:"sdkID"` // sdk ID to use for setting env
+ CmdID string `json:"cmdID"` // command unique ID
+ Cmd string `json:"cmd" binding:"required"`
+ Args []string `json:"args"`
+ Env []string `json:"env"`
+ RPath string `json:"rpath"` // relative path into project
+ TTY bool `json:"tty"` // Use a tty, specific to gdb --tty option
+ TTYGdbserverFix bool `json:"ttyGdbserverFix"` // Set to true to activate gdbserver workaround about inferior output
+ ExitImmediate bool `json:"exitImmediate"` // when true, exit event sent immediately when command exited (IOW, don't wait file synchronization)
+ CmdTimeout int `json:"timeout"` // command completion timeout in Second
+ }
+
+ // ExecResult JSON result of /exec command
+ ExecResult struct {
+ Status string `json:"status"` // status OK
+ CmdID string `json:"cmdID"` // command unique ID
+ }
+
+ // ExecSigResult JSON result of /signal command
+ ExecSigResult struct {
+ Status string `json:"status"` // status OK
+ CmdID string `json:"cmdID"` // command unique ID
+ }
+
+ // ExecInMsg Message used to received input characters (stdin)
+ ExecInMsg struct {
+ CmdID string `json:"cmdID"`
+ Timestamp string `json:"timestamp"`
+ Stdin string `json:"stdin"`
+ }
+
+ // ExecOutMsg Message used to send output characters (stdout+stderr)
+ ExecOutMsg struct {
+ CmdID string `json:"cmdID"`
+ Timestamp string `json:"timestamp"`
+ Stdout string `json:"stdout"`
+ Stderr string `json:"stderr"`
+ }
+
+ // ExecExitMsg Message sent when executed command exited
+ ExecExitMsg struct {
+ CmdID string `json:"cmdID"`
+ Timestamp string `json:"timestamp"`
+ Code int `json:"code"`
+ Error error `json:"error"`
+ }
+
+ // ExecSignalArgs JSON parameters of /exec/signal command
+ ExecSignalArgs struct {
+ CmdID string `json:"cmdID" binding:"required"` // command id
+ Signal string `json:"signal" binding:"required"` // signal number
+ }
+)
+
+const (
+ // ExecInEvent Event send in WS when characters are sent (stdin)
+ ExecInEvent = "exec:input"
+
+ // ExecOutEvent Event send in WS when characters are received (stdout or stderr)
+ ExecOutEvent = "exec:output"
+
+ // ExecExitEvent Event send in WS when program exited
+ ExecExitEvent = "exec:exit"
+
+ // ExecInferiorInEvent Event send in WS when characters are sent to an inferior (used by gdb inferior/tty)
+ ExecInferiorInEvent = "exec:inferior-input"
+
+ // ExecInferiorOutEvent Event send in WS when characters are received by an inferior
+ ExecInferiorOutEvent = "exec:inferior-output"
+)
diff --git a/lib/xsapiv1/folders.go b/lib/xsapiv1/folders.go
new file mode 100644
index 0000000..9506a1d
--- /dev/null
+++ b/lib/xsapiv1/folders.go
@@ -0,0 +1,61 @@
+package xsapiv1
+
+// FolderType definition
+type FolderType string
+
+const (
+ TypePathMap = "PathMap"
+ TypeCloudSync = "CloudSync"
+ TypeCifsSmb = "CIFS"
+)
+
+// Folder Status definition
+const (
+ StatusErrorConfig = "ErrorConfig"
+ StatusDisable = "Disable"
+ StatusEnable = "Enable"
+ StatusPause = "Pause"
+ StatusSyncing = "Syncing"
+)
+
+// FolderConfig is the config for one folder
+type FolderConfig struct {
+ ID string `json:"id"`
+ Label string `json:"label"`
+ ClientPath string `json:"path"`
+ Type FolderType `json:"type"`
+ 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:"-"`
+
+ // FIXME: better to define an equivalent to union data and then implement
+ // UnmarshalJSON/MarshalJSON to decode/encode according to Type value
+ // Data interface{} `json:"data"`
+
+ // Specific data depending on which Type is used
+ DataPathMap PathMapConfig `json:"dataPathMap,omitempty"`
+ 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"`
+
+ // Don't keep temporary file name (IOW we don't want to save it and reuse it)
+ CheckFile string `json:"checkFile" xml:"-"`
+ CheckContent string `json:"checkContent" xml:"-"`
+}
+
+// CloudSyncConfig CloudSync (AKA Syncthing) specific data
+type CloudSyncConfig struct {
+ SyncThingID string `json:"syncThingID"`
+}
diff --git a/lib/xsapiv1/sdks.go b/lib/xsapiv1/sdks.go
new file mode 100644
index 0000000..5ca4dd5
--- /dev/null
+++ b/lib/xsapiv1/sdks.go
@@ -0,0 +1,14 @@
+package xsapiv1
+
+// 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"`
+
+ // Not exported fields
+ EnvFile string `json:"-"`
+}
diff --git a/lib/xsapiv1/version.go b/lib/xsapiv1/version.go
new file mode 100644
index 0000000..8c3a742
--- /dev/null
+++ b/lib/xsapiv1/version.go
@@ -0,0 +1,9 @@
+package xsapiv1
+
+// XDS server Version
+type Version struct {
+ ID string `json:"id"`
+ Version string `json:"version"`
+ APIVersion string `json:"apiVersion"`
+ VersionGitTag string `json:"gitTag"`
+}