031e1d9278d38403528a59570f2503800059b7b9
[src/xds/xds-agent.git] / lib / agent / project-interface.go
1 package agent
2
3 // ProjectType definition
4 type ProjectType string
5
6 const (
7         TypePathMap   = "PathMap"
8         TypeCloudSync = "CloudSync"
9         TypeCifsSmb   = "CIFS"
10 )
11
12 // Project Status definition
13 const (
14         StatusErrorConfig = "ErrorConfig"
15         StatusDisable     = "Disable"
16         StatusEnable      = "Enable"
17         StatusPause       = "Pause"
18         StatusSyncing     = "Syncing"
19 )
20
21 type EventCBData map[string]interface{}
22 type EventCB func(cfg *ProjectConfig, data *EventCBData)
23
24 // IPROJECT Project interface
25 type IPROJECT interface {
26         Add(cfg ProjectConfig) (*ProjectConfig, error) // Add a new project
27         Delete() error                                 // Delete a project
28         GetProject() *ProjectConfig                    // Get project public configuration
29         SetProject(prj ProjectConfig) *ProjectConfig   // Set project configuration
30         GetServer() *XdsServer                         // Get XdsServer that holds this project
31         GetFullPath(dir string) string                 // Get project full path
32         Sync() error                                   // Force project files synchronization
33         IsInSync() (bool, error)                       // Check if project files are in-sync
34 }
35
36 // ProjectConfig is the config for one project
37 type ProjectConfig struct {
38         ID         string      `json:"id"`
39         ServerID   string      `json:"serverId"`
40         Label      string      `json:"label"`
41         ClientPath string      `json:"clientPath"`
42         ServerPath string      `json:"serverPath"`
43         Type       ProjectType `json:"type"`
44         Status     string      `json:"status"`
45         IsInSync   bool        `json:"isInSync"`
46         DefaultSdk string      `json:"defaultSdk"`
47 }