forked from grafana/grafana
-
Notifications
You must be signed in to change notification settings - Fork 0
/
datasource.go
117 lines (98 loc) · 2.99 KB
/
datasource.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
package models
import (
"errors"
"time"
)
const (
DS_GRAPHITE = "graphite"
DS_INFLUXDB = "influxdb"
DS_INFLUXDB_08 = "influxdb_08"
DS_ES = "elasticsearch"
DS_OPENTSDB = "opentsdb"
DS_ACCESS_DIRECT = "direct"
DS_ACCESS_PROXY = "proxy"
)
// Typed errors
var (
ErrDataSourceNotFound = errors.New("Data source not found")
)
type DsAccess string
type DataSource struct {
Id int64
OrgId int64
Version int
Name string
Type string
Access DsAccess
Url string
Password string
User string
Database string
BasicAuth bool
BasicAuthUser string
BasicAuthPassword string
IsDefault bool
JsonData map[string]interface{}
Created time.Time
Updated time.Time
}
// ----------------------
// COMMANDS
// Also acts as api DTO
type AddDataSourceCommand struct {
Name string `json:"name" binding:"Required"`
Type string `json:"type" binding:"Required"`
Access DsAccess `json:"access" binding:"Required"`
Url string `json:"url"`
Password string `json:"password"`
Database string `json:"database"`
User string `json:"user"`
BasicAuth bool `json:"basicAuth"`
BasicAuthUser string `json:"basicAuthUser"`
BasicAuthPassword string `json:"basicAuthPassword"`
IsDefault bool `json:"isDefault"`
JsonData map[string]interface{} `json:"jsonData"`
OrgId int64 `json:"-"`
Result *DataSource
}
// Also acts as api DTO
type UpdateDataSourceCommand struct {
Name string `json:"name" binding:"Required"`
Type string `json:"type" binding:"Required"`
Access DsAccess `json:"access" binding:"Required"`
Url string `json:"url"`
Password string `json:"password"`
User string `json:"user"`
Database string `json:"database"`
BasicAuth bool `json:"basicAuth"`
BasicAuthUser string `json:"basicAuthUser"`
BasicAuthPassword string `json:"basicAuthPassword"`
IsDefault bool `json:"isDefault"`
JsonData map[string]interface{} `json:"jsonData"`
OrgId int64 `json:"-"`
Id int64 `json:"-"`
}
type DeleteDataSourceCommand struct {
Id int64
OrgId int64
}
// ---------------------
// QUERIES
type GetDataSourcesQuery struct {
OrgId int64
Result []*DataSource
}
type GetDataSourceByIdQuery struct {
Id int64
OrgId int64
Result DataSource
}
type GetDataSourceByNameQuery struct {
Name string
OrgId int64
Result DataSource
}
// ---------------------
// EVENTS
type DataSourceCreatedEvent struct {
}