Skip to content

Commit 004914a

Browse files
committed
api: Add operation IDs
1 parent f3d628f commit 004914a

File tree

5 files changed

+72
-52
lines changed

5 files changed

+72
-52
lines changed

pkg/api/rest/controller/health.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,16 @@ var OkMessage = model.SimpleMsg{}
1111
var IsReady = false
1212

1313
// CheckReady func is for checking Grasshopper server health.
14-
// @Summary Check Ready
15-
// @Description Check Grasshopper is ready
16-
// @Tags [Admin] System management
17-
// @Accept json
18-
// @Produce json
19-
// @Success 200 {object} model.SimpleMsg "Successfully get ready state."
20-
// @Failure 500 {object} common.ErrorResponse "Failed to check ready state."
2114
//
22-
// @Router /readyz [get]
15+
// @ID health-check-readyz
16+
// @Summary Check Ready
17+
// @Description Check Grasshopper is ready
18+
// @Tags [Admin] System management
19+
// @Accept json
20+
// @Produce json
21+
// @Success 200 {object} model.SimpleMsg "Successfully get ready state."
22+
// @Failure 500 {object} common.ErrorResponse "Failed to check ready state."
23+
// @Router /readyz [get]
2324
func CheckReady(c echo.Context) error {
2425
status := http.StatusOK
2526

pkg/api/rest/controller/software.go

Lines changed: 45 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -56,17 +56,18 @@ func uploadHandler(c echo.Context) (string, error) {
5656

5757
// RegisterSoftware godoc
5858
//
59-
// @Summary Register Software
60-
// @Description Register the software.<br><br>[JSON Body Example]<br>{"architecture":"x86_64","install_type":"ansible","match_names":["telegraf"],"name":"telegraf","os":"Ubuntu","os_version":"22.04","version":"1.0"}
61-
// @Tags [Software]
62-
// @Accept mpfd
63-
// @Produce json
64-
// @Param json formData string true "Software register request JSON body string."
65-
// @Param archive formData file true "Archive file to upload for ansible."
66-
// @Success 200 {object} model.SoftwareRegisterReq "Successfully registered the software."
67-
// @Failure 400 {object} common.ErrorResponse "Sent bad request."
68-
// @Failure 500 {object} common.ErrorResponse "Failed to sent SSH command."
69-
// @Router /software/register [post]
59+
// @ID register-software
60+
// @Summary Register Software
61+
// @Description Register the software.<br><br>[JSON Body Example]<br>{"architecture":"x86_64","install_type":"ansible","match_names":["telegraf"],"name":"telegraf","os":"Ubuntu","os_version":"22.04","version":"1.0"}
62+
// @Tags [Software]
63+
// @Accept mpfd
64+
// @Produce json
65+
// @Param json formData string true "Software register request JSON body string."
66+
// @Param archive formData file true "Archive file to upload for ansible."
67+
// @Success 200 {object} model.SoftwareRegisterReq "Successfully registered the software."
68+
// @Failure 400 {object} common.ErrorResponse "Sent bad request."
69+
// @Failure 500 {object} common.ErrorResponse "Failed to sent SSH command."
70+
// @Router /software/register [post]
7071
func RegisterSoftware(c echo.Context) error {
7172
err := c.Request().ParseMultipartForm(10 << 30) // 10GB
7273
if err != nil {
@@ -163,16 +164,17 @@ func RegisterSoftware(c echo.Context) error {
163164

164165
// GetExecutionList godoc
165166
//
166-
// @Summary Get Execution List
167-
// @Description Get software migration execution list.
168-
// @Tags [Software]
169-
// @Accept json
170-
// @Produce json
171-
// @Param getExecutionListReq body model.GetExecutionListReq true "Software info list."
172-
// @Success 200 {object} model.GetExecutionListRes "Successfully get migration execution list."
173-
// @Failure 400 {object} common.ErrorResponse "Sent bad request."
174-
// @Failure 500 {object} common.ErrorResponse "Failed to get migration execution list."
175-
// @Router /software/execution_list [post]
167+
// @ID get-execution-list
168+
// @Summary Get Execution List
169+
// @Description Get software migration execution list.
170+
// @Tags [Software]
171+
// @Accept json
172+
// @Produce json
173+
// @Param getExecutionListReq body model.GetExecutionListReq true "Software info list."
174+
// @Success 200 {object} model.GetExecutionListRes "Successfully get migration execution list."
175+
// @Failure 400 {object} common.ErrorResponse "Sent bad request."
176+
// @Failure 500 {object} common.ErrorResponse "Failed to get migration execution list."
177+
// @Router /software/execution_list [post]
176178
func GetExecutionList(c echo.Context) error {
177179
var err error
178180

@@ -192,16 +194,17 @@ func GetExecutionList(c echo.Context) error {
192194

193195
// InstallSoftware godoc
194196
//
195-
// @Summary Install Software
196-
// @Description Install pieces of software to target.
197-
// @Tags [Software]
198-
// @Accept json
199-
// @Produce json
200-
// @Param softwareInstallReq body model.SoftwareInstallReq true "Software install request."
201-
// @Success 200 {object} model.SoftwareInstallRes "Successfully sent SSH command."
202-
// @Failure 400 {object} common.ErrorResponse "Sent bad request."
203-
// @Failure 500 {object} common.ErrorResponse "Failed to sent SSH command."
204-
// @Router /software/install [post]
197+
// @ID install-software
198+
// @Summary Install Software
199+
// @Description Install pieces of software to target.
200+
// @Tags [Software]
201+
// @Accept json
202+
// @Produce json
203+
// @Param softwareInstallReq body model.SoftwareInstallReq true "Software install request."
204+
// @Success 200 {object} model.SoftwareInstallRes "Successfully sent SSH command."
205+
// @Failure 400 {object} common.ErrorResponse "Sent bad request."
206+
// @Failure 500 {object} common.ErrorResponse "Failed to sent SSH command."
207+
// @Router /software/install [post]
205208
func InstallSoftware(c echo.Context) error {
206209
softwareInstallReq := new(model.SoftwareInstallReq)
207210
err := c.Bind(softwareInstallReq)
@@ -241,16 +244,17 @@ func InstallSoftware(c echo.Context) error {
241244

242245
// DeleteSoftware godoc
243246
//
244-
// @Summary Delete Software
245-
// @Description Delete the software.
246-
// @Tags [Software]
247-
// @Accept json
248-
// @Produce json
249-
// @Param softwareId path string true "ID of the software."
250-
// @Success 200 {object} model.SimpleMsg "Successfully update the software"
251-
// @Failure 400 {object} common.ErrorResponse "Sent bad request."
252-
// @Failure 500 {object} common.ErrorResponse "Failed to delete the software"
253-
// @Router /software/{softwareId} [delete]
247+
// @ID delete-software
248+
// @Summary Delete Software
249+
// @Description Delete the software.
250+
// @Tags [Software]
251+
// @Accept json
252+
// @Produce json
253+
// @Param softwareId path string true "ID of the software."
254+
// @Success 200 {object} model.SimpleMsg "Successfully update the software"
255+
// @Failure 400 {object} common.ErrorResponse "Sent bad request."
256+
// @Failure 500 {object} common.ErrorResponse "Failed to delete the software"
257+
// @Router /software/{softwareId} [delete]
254258
func DeleteSoftware(c echo.Context) error {
255259
swID := c.Param("softwareId")
256260
if swID == "" {

pkg/api/rest/docs/docs.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,10 @@ const docTemplate = `{
2929
"application/json"
3030
],
3131
"tags": [
32-
"[Admin] System management"
32+
"[Admin]\tSystem management"
3333
],
3434
"summary": "Check Ready",
35+
"operationId": "health-check-readyz",
3536
"responses": {
3637
"200": {
3738
"description": "Successfully get ready state.",
@@ -61,6 +62,7 @@ const docTemplate = `{
6162
"[Software]"
6263
],
6364
"summary": "Get Execution List",
65+
"operationId": "get-execution-list",
6466
"parameters": [
6567
{
6668
"description": "Software info list.",
@@ -107,6 +109,7 @@ const docTemplate = `{
107109
"[Software]"
108110
],
109111
"summary": "Install Software",
112+
"operationId": "install-software",
110113
"parameters": [
111114
{
112115
"description": "Software install request.",
@@ -153,6 +156,7 @@ const docTemplate = `{
153156
"[Software]"
154157
],
155158
"summary": "Register Software",
159+
"operationId": "register-software",
156160
"parameters": [
157161
{
158162
"type": "string",
@@ -204,6 +208,7 @@ const docTemplate = `{
204208
"[Software]"
205209
],
206210
"summary": "Delete Software",
211+
"operationId": "delete-software",
207212
"parameters": [
208213
{
209214
"type": "string",

pkg/api/rest/docs/swagger.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,10 @@
2222
"application/json"
2323
],
2424
"tags": [
25-
"[Admin] System management"
25+
"[Admin]\tSystem management"
2626
],
2727
"summary": "Check Ready",
28+
"operationId": "health-check-readyz",
2829
"responses": {
2930
"200": {
3031
"description": "Successfully get ready state.",
@@ -54,6 +55,7 @@
5455
"[Software]"
5556
],
5657
"summary": "Get Execution List",
58+
"operationId": "get-execution-list",
5759
"parameters": [
5860
{
5961
"description": "Software info list.",
@@ -100,6 +102,7 @@
100102
"[Software]"
101103
],
102104
"summary": "Install Software",
105+
"operationId": "install-software",
103106
"parameters": [
104107
{
105108
"description": "Software install request.",
@@ -146,6 +149,7 @@
146149
"[Software]"
147150
],
148151
"summary": "Register Software",
152+
"operationId": "register-software",
149153
"parameters": [
150154
{
151155
"type": "string",
@@ -197,6 +201,7 @@
197201
"[Software]"
198202
],
199203
"summary": "Delete Software",
204+
"operationId": "delete-software",
200205
"parameters": [
201206
{
202207
"type": "string",

pkg/api/rest/docs/swagger.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ paths:
137137
consumes:
138138
- application/json
139139
description: Check Grasshopper is ready
140+
operationId: health-check-readyz
140141
produces:
141142
- application/json
142143
responses:
@@ -150,12 +151,13 @@ paths:
150151
$ref: '#/definitions/github_com_cloud-barista_cm-grasshopper_pkg_api_rest_common.ErrorResponse'
151152
summary: Check Ready
152153
tags:
153-
- '[Admin] System management'
154+
- "[Admin]\tSystem management"
154155
/software/{softwareId}:
155156
delete:
156157
consumes:
157158
- application/json
158159
description: Delete the software.
160+
operationId: delete-software
159161
parameters:
160162
- description: ID of the software.
161163
in: path
@@ -185,6 +187,7 @@ paths:
185187
consumes:
186188
- application/json
187189
description: Get software migration execution list.
190+
operationId: get-execution-list
188191
parameters:
189192
- description: Software info list.
190193
in: body
@@ -215,6 +218,7 @@ paths:
215218
consumes:
216219
- application/json
217220
description: Install pieces of software to target.
221+
operationId: install-software
218222
parameters:
219223
- description: Software install request.
220224
in: body
@@ -245,6 +249,7 @@ paths:
245249
consumes:
246250
- multipart/form-data
247251
description: Register the software.<br><br>[JSON Body Example]<br>{"architecture":"x86_64","install_type":"ansible","match_names":["telegraf"],"name":"telegraf","os":"Ubuntu","os_version":"22.04","version":"1.0"}
252+
operationId: register-software
248253
parameters:
249254
- description: Software register request JSON body string.
250255
in: formData

0 commit comments

Comments
 (0)