Skip to content

Commit 035d57b

Browse files
committed
Add more endpoints to Swagger
1 parent 2392751 commit 035d57b

File tree

5 files changed

+527
-0
lines changed

5 files changed

+527
-0
lines changed

dashboard/swagger.json

Lines changed: 324 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,268 @@
3636
}
3737
}
3838
},
39+
"/api/clusters/{clusterName}/actions/master-physical-backup": {
40+
"get": {
41+
"produces": [
42+
"text/plain"
43+
],
44+
"operationId": "master-physical-backup",
45+
"parameters": [
46+
{
47+
"type": "string",
48+
"description": "cluster to filter by",
49+
"name": "clusterName",
50+
"in": "path",
51+
"required": true
52+
}
53+
],
54+
"responses": {
55+
"200": {
56+
"description": "OK",
57+
"headers": {
58+
"Access-Control-Allow-Origin": {
59+
"type": "string"
60+
}
61+
}
62+
},
63+
"400": {
64+
"description": "No cluster found",
65+
"schema": {
66+
"type": "string"
67+
},
68+
"headers": {
69+
"Access-Control-Allow-Origin": {
70+
"type": "string"
71+
}
72+
},
73+
"examples": {
74+
"text/plain": "No cluster found:cluster_1"
75+
}
76+
},
77+
"403": {
78+
"description": "No valid ACL",
79+
"schema": {
80+
"type": "string"
81+
},
82+
"headers": {
83+
"Access-Control-Allow-Origin": {
84+
"type": "string"
85+
}
86+
},
87+
"examples": {
88+
"text/plain": "No valid ACL"
89+
}
90+
}
91+
}
92+
}
93+
},
94+
"/api/clusters/{clusterName}/servers/{serverName}/is-master": {
95+
"get": {
96+
"produces": [
97+
"text/plain"
98+
],
99+
"operationId": "serverName-is-master",
100+
"parameters": [
101+
{
102+
"type": "string",
103+
"description": "cluster to filter by",
104+
"name": "clusterName",
105+
"in": "path",
106+
"required": true
107+
},
108+
{
109+
"type": "string",
110+
"description": "server to filter by",
111+
"name": "serverName",
112+
"in": "path",
113+
"required": true
114+
}
115+
],
116+
"responses": {
117+
"200": {
118+
"description": "OK",
119+
"schema": {
120+
"type": "string"
121+
},
122+
"headers": {
123+
"Access-Control-Allow-Origin": {
124+
"type": "string"
125+
}
126+
},
127+
"examples": {
128+
"text/plain": "200 -Valid Master!"
129+
}
130+
},
131+
"500": {
132+
"description": "No cluster",
133+
"schema": {
134+
"type": "string"
135+
},
136+
"headers": {
137+
"Access-Control-Allow-Origin": {
138+
"type": "string"
139+
}
140+
},
141+
"examples": {
142+
"text/plain": "No cluster"
143+
}
144+
},
145+
"503": {
146+
"description": "Not a Valid Master",
147+
"schema": {
148+
"type": "string"
149+
},
150+
"headers": {
151+
"Access-Control-Allow-Origin": {
152+
"type": "string"
153+
}
154+
},
155+
"examples": {
156+
"text/plain": "503 -Not a Valid Master!"
157+
}
158+
}
159+
}
160+
}
161+
},
162+
"/api/clusters/{clusterName}/servers/{serverName}/is-slave": {
163+
"get": {
164+
"produces": [
165+
"text/plain"
166+
],
167+
"operationId": "serverName-is-slave",
168+
"parameters": [
169+
{
170+
"type": "string",
171+
"description": "cluster to filter by",
172+
"name": "clusterName",
173+
"in": "path",
174+
"required": true
175+
},
176+
{
177+
"type": "string",
178+
"description": "server to filter by",
179+
"name": "serverName",
180+
"in": "path",
181+
"required": true
182+
}
183+
],
184+
"responses": {
185+
"200": {
186+
"description": "OK",
187+
"schema": {
188+
"type": "string"
189+
},
190+
"headers": {
191+
"Access-Control-Allow-Origin": {
192+
"type": "string"
193+
}
194+
},
195+
"examples": {
196+
"text/plain": "200 -Valid Slave!"
197+
}
198+
},
199+
"500": {
200+
"description": "No cluster",
201+
"schema": {
202+
"type": "string"
203+
},
204+
"headers": {
205+
"Access-Control-Allow-Origin": {
206+
"type": "string"
207+
}
208+
},
209+
"examples": {
210+
"text/plain": "No cluster"
211+
}
212+
},
213+
"503": {
214+
"description": "Not a Valid Slave!",
215+
"schema": {
216+
"type": "string"
217+
},
218+
"headers": {
219+
"Access-Control-Allow-Origin": {
220+
"type": "string"
221+
}
222+
},
223+
"examples": {
224+
"text/plain": "503 -Not a Valid Slave!"
225+
}
226+
}
227+
}
228+
}
229+
},
230+
"/api/clusters/{clusterName}/servers/{serverName}/master-status": {
231+
"get": {
232+
"produces": [
233+
"text/plain"
234+
],
235+
"operationId": "serverName-master-status",
236+
"parameters": [
237+
{
238+
"type": "string",
239+
"description": "cluster to filter by",
240+
"name": "clusterName",
241+
"in": "path",
242+
"required": true
243+
},
244+
{
245+
"type": "string",
246+
"description": "server to filter by",
247+
"name": "serverName",
248+
"in": "path",
249+
"required": true
250+
}
251+
],
252+
"responses": {
253+
"200": {
254+
"description": "OK"
255+
},
256+
"403": {
257+
"description": "No valid ACL",
258+
"schema": {
259+
"type": "string"
260+
},
261+
"headers": {
262+
"Access-Control-Allow-Origin": {
263+
"type": "string"
264+
}
265+
},
266+
"examples": {
267+
"text/plain": "No valid ACL"
268+
}
269+
},
270+
"500": {
271+
"description": "No cluster",
272+
"schema": {
273+
"type": "string"
274+
},
275+
"headers": {
276+
"Access-Control-Allow-Origin": {
277+
"type": "string"
278+
}
279+
},
280+
"examples": {
281+
"text/plain": "No cluster"
282+
}
283+
},
284+
"503": {
285+
"description": "Not a Valid Server!",
286+
"schema": {
287+
"type": "string"
288+
},
289+
"headers": {
290+
"Access-Control-Allow-Origin": {
291+
"type": "string"
292+
}
293+
},
294+
"examples": {
295+
"text/plain": "503 -Not a Valid Server!"
296+
}
297+
}
298+
}
299+
}
300+
},
39301
"/api/clusters/{clusterName}/status": {
40302
"get": {
41303
"description": "Shows the status for that specific named cluster",
@@ -56,6 +318,16 @@
56318
}
57319
}
58320
},
321+
"/api/heartbeat": {
322+
"get": {
323+
"operationId": "heartbeat",
324+
"responses": {
325+
"200": {
326+
"$ref": "#/responses/heartbeat"
327+
}
328+
}
329+
}
330+
},
59331
"/api/prometheus": {
60332
"get": {
61333
"description": "Returns the Prometheus metrics for all database instances on the server\nin the Prometheus text format",
@@ -68,6 +340,11 @@
68340
"description": "Prometheus file format",
69341
"schema": {
70342
"type": "string"
343+
},
344+
"headers": {
345+
"Access-Control-Allow-Origin": {
346+
"type": "string"
347+
}
71348
}
72349
}
73350
}
@@ -2369,6 +2646,47 @@
23692646
},
23702647
"x-go-package": "github.com/signal18/replication-manager/utils/gtid"
23712648
},
2649+
"Heartbeat": {
2650+
"type": "object",
2651+
"properties": {
2652+
"cluster": {
2653+
"type": "string",
2654+
"x-go-name": "Cluster"
2655+
},
2656+
"failed": {
2657+
"type": "integer",
2658+
"format": "int64",
2659+
"x-go-name": "Failed"
2660+
},
2661+
"hosts": {
2662+
"type": "integer",
2663+
"format": "int64",
2664+
"x-go-name": "Hosts"
2665+
},
2666+
"id": {
2667+
"type": "integer",
2668+
"format": "int64",
2669+
"x-go-name": "UID"
2670+
},
2671+
"master": {
2672+
"type": "string",
2673+
"x-go-name": "Master"
2674+
},
2675+
"secret": {
2676+
"type": "string",
2677+
"x-go-name": "Secret"
2678+
},
2679+
"status": {
2680+
"type": "string",
2681+
"x-go-name": "Status"
2682+
},
2683+
"uuid": {
2684+
"type": "string",
2685+
"x-go-name": "UUID"
2686+
}
2687+
},
2688+
"x-go-package": "github.com/signal18/replication-manager/server"
2689+
},
23722690
"HttpLog": {
23732691
"description": "Collection of log messages",
23742692
"type": "object",
@@ -2641,6 +2959,12 @@
26412959
}
26422960
}
26432961
},
2962+
"heartbeat": {
2963+
"description": "A Heartbeat returns a quick overview of the cluster status",
2964+
"schema": {
2965+
"$ref": "#/definitions/Heartbeat"
2966+
}
2967+
},
26442968
"httplog": {
26452969
"description": "Collection of log messages",
26462970
"headers": {

server/api.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,9 @@ func (repman *ReplicationManager) handlerMuxClusterAdd(w http.ResponseWriter, r
367367
// description: Prometheus file format
368368
// schema:
369369
// type: string
370+
// headers:
371+
// Access-Control-Allow-Origin:
372+
// type: string
370373
func (repman *ReplicationManager) handlerMuxPrometheus(w http.ResponseWriter, r *http.Request) {
371374

372375
w.Header().Set("Access-Control-Allow-Origin", "*")
@@ -441,6 +444,11 @@ func (repman *ReplicationManager) handlerMuxTimeout(w http.ResponseWriter, r *ht
441444
io.WriteString(w, `{"alive": "running"}`)
442445
}
443446

447+
// swagger:route GET /api/heartbeat heartbeat
448+
//
449+
// Responses:
450+
// 200: heartbeat
451+
444452
func (repman *ReplicationManager) handlerMuxMonitorHeartbeat(w http.ResponseWriter, r *http.Request) {
445453
var send Heartbeat
446454
send.UUID = repman.UUID

0 commit comments

Comments
 (0)