diff --git a/cmd/metal-api/internal/service/machine-service.go b/cmd/metal-api/internal/service/machine-service.go index 578612b6d..e95b6ea97 100644 --- a/cmd/metal-api/internal/service/machine-service.go +++ b/cmd/metal-api/internal/service/machine-service.go @@ -244,7 +244,17 @@ func (r *machineResource) webService() *restful.WebService { Returns(http.StatusOK, "OK", v1.MachineResponse{}). DefaultReturns("Error", httperrors.HTTPErrorResponse{})) - ws.Route(ws.POST("/issues"). + ws.Route(ws.GET("/issues"). + To(viewer(r.issues)). + Operation("listIssues"). + Doc("returns the list of issues that exist in the API"). + Metadata(restfulspec.KeyOpenAPITags, tags). + Metadata(auditing.Exclude, true). + Writes([]v1.MachineIssue{}). + Returns(http.StatusOK, "OK", []v1.MachineIssue{}). + DefaultReturns("Error", httperrors.HTTPErrorResponse{})) + + ws.Route(ws.POST("/issues/evaluate"). To(viewer(r.issues)). Operation("issues"). Doc("returns machine issues"). @@ -495,6 +505,25 @@ func (r *machineResource) updateMachine(request *restful.Request, response *rest r.send(request, response, http.StatusOK, resp) } +func (r *machineResource) listIssues(request *restful.Request, response *restful.Response) { + issues := issues.AllIssues() + + var issueResponse []v1.MachineIssue + for _, issue := range issues { + issue := issue + + issueResponse = append(issueResponse, v1.MachineIssue{ + ID: string(issue.Type), + Severity: string(issue.Severity), + Description: issue.Description, + RefURL: issue.RefURL, + Details: issue.Details, + }) + } + + r.send(request, response, http.StatusOK, issueResponse) +} + func (r *machineResource) issues(request *restful.Request, response *restful.Response) { var requestPayload v1.MachineIssuesRequest err := request.ReadEntity(&requestPayload) diff --git a/spec/metal-api.json b/spec/metal-api.json index acbf4f4f4..1b61ed960 100644 --- a/spec/metal-api.json +++ b/spec/metal-api.json @@ -6769,6 +6769,38 @@ } }, "/v1/machine/issues": { + "get": { + "consumes": [ + "application/json" + ], + "operationId": "listIssues", + "produces": [ + "application/json" + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "items": { + "$ref": "#/definitions/v1.MachineIssue" + }, + "type": "array" + } + }, + "default": { + "description": "Error", + "schema": { + "$ref": "#/definitions/httperrors.HTTPErrorResponse" + } + } + }, + "summary": "returns the list of issues that exist in the API", + "tags": [ + "machine" + ] + } + }, + "/v1/machine/issues/evaluate": { "post": { "consumes": [ "application/json"