Refit source files to have a public xs-apiv1 lib package.
[src/xds/xds-server.git] / lib / xsapiv1 / folders.go
1 package xsapiv1
2
3 // FolderType definition
4 type FolderType string
5
6 const (
7         TypePathMap   = "PathMap"
8         TypeCloudSync = "CloudSync"
9         TypeCifsSmb   = "CIFS"
10 )
11
12 // Folder Status definition
13 const (
14         StatusErrorConfig = "ErrorConfig"
15         StatusDisable     = "Disable"
16         StatusEnable      = "Enable"
17         StatusPause       = "Pause"
18         StatusSyncing     = "Syncing"
19 )
20
21 // FolderConfig is the config for one folder
22 type FolderConfig struct {
23         ID         string     `json:"id"`
24         Label      string     `json:"label"`
25         ClientPath string     `json:"path"`
26         Type       FolderType `json:"type"`
27         Status     string     `json:"status"`
28         IsInSync   bool       `json:"isInSync"`
29         DefaultSdk string     `json:"defaultSdk"`
30         ClientData string     `json:"clientData"` // free form field that can used by client
31
32         // Not exported fields from REST API point of view
33         RootPath string `json:"-"`
34
35         // FIXME: better to define an equivalent to union data and then implement
36         // UnmarshalJSON/MarshalJSON to decode/encode according to Type value
37         // Data interface{} `json:"data"`
38
39         // Specific data depending on which Type is used
40         DataPathMap   PathMapConfig   `json:"dataPathMap,omitempty"`
41         DataCloudSync CloudSyncConfig `json:"dataCloudSync,omitempty"`
42 }
43
44 // FolderConfigUpdatableFields List fields that can be updated using Update function
45 var FolderConfigUpdatableFields = []string{
46         "Label", "DefaultSdk", "ClientData",
47 }
48
49 // PathMapConfig Path mapping specific data
50 type PathMapConfig struct {
51         ServerPath string `json:"serverPath"`
52
53         // Don't keep temporary file name (IOW we don't want to save it and reuse it)
54         CheckFile    string `json:"checkFile" xml:"-"`
55         CheckContent string `json:"checkContent" xml:"-"`
56 }
57
58 // CloudSyncConfig CloudSync (AKA Syncthing) specific data
59 type CloudSyncConfig struct {
60         SyncThingID string `json:"syncThingID"`
61 }