-
Notifications
You must be signed in to change notification settings - Fork 0
/
routes.go
107 lines (94 loc) · 4.7 KB
/
routes.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
package endpoints
import (
"net/http"
"strings"
)
type router interface {
HandlerFunc(method, path string, handler http.HandlerFunc)
}
func registerRoutes(path string, router router, wrapper wrapper, writeOnly bool) {
if router == nil {
panic("router == nil")
}
path = strings.TrimRight(path, "/") + "/datatug"
route(router, wrapper, http.MethodGet, path+"/ping", Ping)
route(router, wrapper, http.MethodGet, path+"/agent-info", AgentInfo)
projectsRoutes(path, router, wrapper, writeOnly)
foldersRoutes(path, router, wrapper, writeOnly)
queriesRoutes(path, router, wrapper, writeOnly)
boardsRoutes(path, router, wrapper, writeOnly)
environmentsRoutes(path, router, wrapper, writeOnly)
dbServerRoutes(path, router, wrapper, writeOnly)
entitiesRoutes(path, router, wrapper, writeOnly)
recordsetsRoutes(path, router, wrapper, writeOnly)
executeRoutes(path, router, wrapper, writeOnly)
}
func foldersRoutes(path string, router router, wrap wrapper, writeOnly bool) {
route(router, wrap, http.MethodPut, path+"/folders/create_folder", createFolder)
route(router, wrap, http.MethodDelete, path+"/folders/delete_folder", deleteFolder)
}
func queriesRoutes(path string, router router, wrap wrapper, writeOnly bool) {
if !writeOnly {
//route(router, wrap, http.MethodGet, path+"/queries/all_queries", endpoints.GetQueries)
route(router, wrap, http.MethodGet, path+"/queries/get_query", getQueryHandler)
}
route(router, wrap, http.MethodPost, path+"/queries/create_query", createQuery)
route(router, wrap, http.MethodPut, path+"/queries/update_query", updateQuery)
route(router, wrap, http.MethodDelete, path+"/queries/delete_query", deleteQuery)
}
func boardsRoutes(path string, router router, wrap wrapper, writeOnly bool) {
if !writeOnly {
route(router, wrap, http.MethodGet, path+"/boards/board", getBoard)
}
route(router, wrap, http.MethodPost, path+"/boards/create_board", createBoard)
route(router, wrap, http.MethodPut, path+"/boards/save_board", saveBoard)
route(router, wrap, http.MethodDelete, path+"/boards/delete_board", deleteBoard)
}
func projectsRoutes(path string, router router, wrap wrapper, writeOnly bool) {
if !writeOnly {
route(router, wrap, http.MethodGet, path+"/projects/projects_summary", getProjects)
route(router, wrap, http.MethodGet, path+"/projects/project_summary", getProjectSummary)
route(router, wrap, http.MethodGet, path+"/projects/project_full", getProjectFull)
}
projectEndpoints := ProjectAgentEndpoints{}
route(router, wrap, http.MethodPost, path+"/projects/create_project", projectEndpoints.createProject)
route(router, wrap, http.MethodDelete, path+"/projects/delete_project", projectEndpoints.deleteProject)
}
func environmentsRoutes(path string, router router, wrap wrapper, writeOnly bool) {
if !writeOnly {
route(router, wrap, http.MethodGet, path+"/environment-summary", getEnvironmentSummary)
}
}
func dbServerRoutes(path string, router router, wrap wrapper, writeOnly bool) {
if !writeOnly {
route(router, wrap, http.MethodGet, path+"/dbserver-summary", getDbServerSummary)
route(router, wrap, http.MethodGet, path+"/dbserver-databases", getServerDatabases)
}
route(router, wrap, http.MethodPost, path+"/dbserver-add", addDbServer)
route(router, wrap, http.MethodDelete, path+"/dbserver-delete", deleteDbServer)
}
func entitiesRoutes(path string, router router, wrap wrapper, writeOnly bool) {
if !writeOnly {
route(router, wrap, http.MethodGet, path+"/entities/all_entities", getEntities)
route(router, wrap, http.MethodGet, path+"/entities/entity", getEntity)
}
route(router, wrap, http.MethodPost, path+"/entities/create_entity", saveEntity)
route(router, wrap, http.MethodPut, path+"/entities/save_entity", saveEntity)
route(router, wrap, http.MethodDelete, path+"/entities/delete_entity", deleteEntity)
}
func recordsetsRoutes(path string, router router, wrap wrapper, writeOnly bool) {
if !writeOnly {
route(router, wrap, http.MethodGet, path+"/recordsets/recordsets_summary", getRecordsetsSummary)
route(router, wrap, http.MethodGet, path+"/recordsets/recordset_definition", getRecordsetDefinition)
route(router, wrap, http.MethodGet, path+"/recordsets/recordset_data", getRecordsetData)
}
route(router, wrap, http.MethodPost, path+"/recordsets/recordset_add_rows", addRowsToRecordset)
route(router, wrap, http.MethodPut, path+"/recordsets/recordset_update_rows", updateRowsInRecordset)
route(router, wrap, http.MethodDelete, path+"/recordsets/recordset_delete_rows", deleteRowsFromRecordset)
}
func executeRoutes(path string, router router, wrap wrapper, writeOnly bool) {
if !writeOnly {
route(router, wrap, http.MethodPost, path+"/exec/execute_commands", executeCommandsHandler)
route(router, wrap, http.MethodGet, path+"/exec/select", executeSelectHandler)
}
}