Skip to content

Commit 5dc1697

Browse files
authored
docs: add summaries to api endpoints (#49)
PLAT-86
2 parents 3327ff7 + e0216f5 commit 5dc1697

File tree

8 files changed

+168
-110
lines changed

8 files changed

+168
-110
lines changed

api/design/api.go

Lines changed: 77 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,36 +43,63 @@ var _ = g.API("control-plane", func() {
4343
})
4444

4545
var _ = g.Service("control-plane", func() {
46+
g.HTTP(func() {
47+
g.Meta("openapi:tag:Cluster:name", "Cluster")
48+
g.Meta("openapi:tag:Cluster:x-displayName", "Cluster")
49+
g.Meta("openapi:tag:Cluster:description", "Cluster operations")
50+
51+
g.Meta("openapi:tag:Host:name", "Host")
52+
g.Meta("openapi:tag:Host:x-displayName", "Hosts")
53+
g.Meta("openapi:tag:Host:description", "Host operations")
54+
55+
g.Meta("openapi:tag:Database:name", "Database")
56+
g.Meta("openapi:tag:Database:x-displayName", "Databases")
57+
g.Meta("openapi:tag:Database:description", "Database operations")
58+
59+
g.Meta("openapi:tag:System:name", "System")
60+
g.Meta("openapi:tag:System:x-displayName", "System")
61+
g.Meta("openapi:tag:System:description", "System operations")
62+
})
63+
4664
g.Error("server_error")
4765

4866
g.Method("init-cluster", func() {
4967
g.Description("Initializes a new cluster.")
68+
g.Meta("openapi:summary", "Initialize cluster")
5069
g.Result(ClusterJoinToken)
5170
g.Error("cluster_already_initialized")
5271

5372
g.HTTP(func() {
5473
g.GET("/cluster/init")
74+
75+
g.Meta("openapi:tag:Cluster")
5576
})
5677
})
5778

5879
g.Method("join-cluster", func() {
59-
g.Description("Join this host to an existing cluster.")
80+
g.Description("Joins this host to an existing cluster.")
81+
g.Meta("openapi:summary", "Join cluster")
6082
g.Payload(ClusterJoinToken)
6183
g.Error("cluster_already_initialized")
6284
g.Error("invalid_join_token")
6385

6486
g.HTTP(func() {
6587
g.POST("/cluster/join")
88+
89+
g.Meta("openapi:tag:Cluster")
6690
})
6791
})
6892

6993
g.Method("get-join-token", func() {
7094
g.Description("Gets the join token for this cluster.")
95+
g.Meta("openapi:summary", "Get cluster join token")
7196
g.Result(ClusterJoinToken)
7297
g.Error("cluster_not_initialized")
7398

7499
g.HTTP(func() {
75100
g.GET("/cluster/join-token")
101+
102+
g.Meta("openapi:tag:Cluster")
76103
})
77104
})
78105

@@ -91,26 +118,33 @@ var _ = g.Service("control-plane", func() {
91118

92119
g.Method("get-cluster", func() {
93120
g.Description("Returns information about the cluster.")
121+
g.Meta("openapi:summary", "Get cluster")
94122
g.Result(Cluster)
95123
g.Error("cluster_not_initialized")
96124

97125
g.HTTP(func() {
98126
g.GET("/cluster")
127+
128+
g.Meta("openapi:tag:Cluster")
99129
})
100130
})
101131

102132
g.Method("list-hosts", func() {
103133
g.Description("Lists all hosts within the cluster.")
134+
g.Meta("openapi:summary", "List hosts")
104135
g.Result(g.ArrayOf(Host))
105136
g.Error("cluster_not_initialized")
106137

107138
g.HTTP(func() {
108139
g.GET("/hosts")
140+
141+
g.Meta("openapi:tag:Host")
109142
})
110143
})
111144

112145
g.Method("get-host", func() {
113146
g.Description("Returns information about a particular host in the cluster.")
147+
g.Meta("openapi:summary", "Get host")
114148
g.Payload(func() {
115149
g.Attribute("host_id", g.String, func() {
116150
g.Description("ID of the host to get.")
@@ -124,11 +158,14 @@ var _ = g.Service("control-plane", func() {
124158

125159
g.HTTP(func() {
126160
g.GET("/hosts/{host_id}")
161+
162+
g.Meta("openapi:tag:Host")
127163
})
128164
})
129165

130166
g.Method("remove-host", func() {
131167
g.Description("Removes a host from the cluster.")
168+
g.Meta("openapi:summary", "Remove host")
132169
g.Payload(func() {
133170
g.Attribute("host_id", g.String, func() {
134171
g.Description("ID of the host to remove.")
@@ -141,23 +178,29 @@ var _ = g.Service("control-plane", func() {
141178

142179
g.HTTP(func() {
143180
g.DELETE("/hosts/{host_id}")
181+
182+
g.Meta("openapi:tag:Host")
144183
})
145184
})
146185

147186
g.Method("list-databases", func() {
148187
g.Description("Lists all databases in the cluster.")
188+
g.Meta("openapi:summary", "List databases")
149189
g.Result(g.CollectionOf(Database), func() {
150190
g.View("abbreviated")
151191
})
152192
g.Error("cluster_not_initialized")
153193

154194
g.HTTP(func() {
155195
g.GET("/databases")
196+
197+
g.Meta("openapi:tag:Database")
156198
})
157199
})
158200

159201
g.Method("create-database", func() {
160202
g.Description("Creates a new database in the cluster.")
203+
g.Meta("openapi:summary", "Create database")
161204
g.Payload(CreateDatabaseRequest)
162205
g.Result(CreateDatabaseResponse)
163206
g.Error("cluster_not_initialized")
@@ -168,11 +211,14 @@ var _ = g.Service("control-plane", func() {
168211
g.HTTP(func() {
169212
g.POST("/databases")
170213
g.Response("database_already_exists", http.StatusConflict)
214+
215+
g.Meta("openapi:tag:Database")
171216
})
172217
})
173218

174219
g.Method("get-database", func() {
175220
g.Description("Returns information about a particular database in the cluster.")
221+
g.Meta("openapi:summary", "Get database")
176222
g.Payload(func() {
177223
g.Attribute("database_id", g.String, func() {
178224
g.Description("ID of the database to get.")
@@ -188,11 +234,14 @@ var _ = g.Service("control-plane", func() {
188234

189235
g.HTTP(func() {
190236
g.GET("/databases/{database_id}")
237+
238+
g.Meta("openapi:tag:Database")
191239
})
192240
})
193241

194242
g.Method("update-database", func() {
195243
g.Description("Updates a database with the given specification.")
244+
g.Meta("openapi:summary", "Update database")
196245
g.Payload(func() {
197246
g.Attribute("database_id", g.String, func() {
198247
g.Description("ID of the database to update.")
@@ -215,11 +264,14 @@ var _ = g.Service("control-plane", func() {
215264
g.POST("/databases/{database_id}")
216265
g.Param("force_update")
217266
g.Body("request")
267+
268+
g.Meta("openapi:tag:Database")
218269
})
219270
})
220271

221272
g.Method("delete-database", func() {
222273
g.Description("Deletes a database from the cluster.")
274+
g.Meta("openapi:summary", "Delete database")
223275
g.Payload(func() {
224276
g.Attribute("database_id", g.String, func() {
225277
g.Format(g.FormatUUID)
@@ -238,11 +290,14 @@ var _ = g.Service("control-plane", func() {
238290

239291
g.HTTP(func() {
240292
g.DELETE("/databases/{database_id}")
293+
294+
g.Meta("openapi:tag:Database")
241295
})
242296
})
243297

244298
g.Method("backup-database-node", func() {
245299
g.Description("Initiates a backup for a database node.")
300+
g.Meta("openapi:summary", "Backup database node")
246301
g.Payload(func() {
247302
g.Attribute("database_id", g.String, func() {
248303
g.Format(g.FormatUUID)
@@ -267,11 +322,14 @@ var _ = g.Service("control-plane", func() {
267322
g.HTTP(func() {
268323
g.POST("/databases/{database_id}/nodes/{node_name}/backups")
269324
g.Body("options")
325+
326+
g.Meta("openapi:tag:Database")
270327
})
271328
})
272329

273330
g.Method("list-database-tasks", func() {
274331
g.Description("Lists all tasks for a database.")
332+
g.Meta("openapi:summary", "List database tasks")
275333
g.Payload(func() {
276334
g.Attribute("database_id", g.String, func() {
277335
g.Format(g.FormatUUID)
@@ -305,11 +363,14 @@ var _ = g.Service("control-plane", func() {
305363
g.Param("after_task_id")
306364
g.Param("limit")
307365
g.Param("sort_order")
366+
367+
g.Meta("openapi:tag:Database")
308368
})
309369
})
310370

311371
g.Method("get-database-task", func() {
312372
g.Description("Returns information about a particular task.")
373+
g.Meta("openapi:summary", "Get database task")
313374
g.Payload(func() {
314375
g.Attribute("database_id", g.String, func() {
315376
g.Format(g.FormatUUID)
@@ -331,11 +392,14 @@ var _ = g.Service("control-plane", func() {
331392

332393
g.HTTP(func() {
333394
g.GET("/databases/{database_id}/tasks/{task_id}")
395+
396+
g.Meta("openapi:tag:Database")
334397
})
335398
})
336399

337400
g.Method("get-database-task-log", func() {
338401
g.Description("Returns the log of a particular task for a database.")
402+
g.Meta("openapi:summary", "Get database task log")
339403
g.Payload(func() {
340404
g.Attribute("database_id", g.String, func() {
341405
g.Format(g.FormatUUID)
@@ -368,11 +432,14 @@ var _ = g.Service("control-plane", func() {
368432
g.GET("/databases/{database_id}/tasks/{task_id}/log")
369433
g.Param("after_entry_id")
370434
g.Param("limit")
435+
436+
g.Meta("openapi:tag:Database")
371437
})
372438
})
373439

374440
g.Method("restore-database", func() {
375441
g.Description("Perform an in-place restore one or more nodes using the given restore configuration.")
442+
g.Meta("openapi:summary", "Restore database")
376443
g.Payload(func() {
377444
g.Attribute("database_id", g.String, func() {
378445
g.Format(g.FormatUUID)
@@ -393,20 +460,27 @@ var _ = g.Service("control-plane", func() {
393460
g.HTTP(func() {
394461
g.POST("/databases/{database_id}/restore")
395462
g.Body("request")
463+
464+
g.Meta("openapi:tag:Database")
396465
})
397466
})
398467

399468
g.Method("get-version", func() {
400-
g.Description("Returns version information for the Control Plane server.")
469+
g.Description("Returns version information for this Control Plane server.")
470+
g.Meta("openapi:summary", "Get version")
401471
g.Result(VersionInfo)
402472

403473
g.HTTP(func() {
404474
g.GET("/version")
475+
476+
g.Meta("openapi:tag:System")
405477
})
406478
})
407479

408480
// Serves the OpenAPI spec as a static file
409-
g.Files("/openapi.json", "./gen/http/openapi3.json")
481+
g.Files("/openapi.json", "./gen/http/openapi3.json", func() {
482+
g.Meta("openapi:generate", "false")
483+
})
410484
})
411485

412486
var APIError = g.Type("APIError", func() {

api/gen/control_plane/service.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/gen/http/cli/control_plane/cli.go

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/gen/http/openapi.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)