Skip to content

Commit

Permalink
Add list endpoint.
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerrit91 committed Oct 2, 2023
1 parent a203d19 commit 5e0b9e5
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 1 deletion.
31 changes: 30 additions & 1 deletion cmd/metal-api/internal/service/machine-service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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").
Expand Down Expand Up @@ -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) {

Check failure on line 508 in cmd/metal-api/internal/service/machine-service.go

View workflow job for this annotation

GitHub Actions / Docker Build

func `(*machineResource).listIssues` is unused (unused)
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)
Expand Down
32 changes: 32 additions & 0 deletions spec/metal-api.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 5e0b9e5

Please sign in to comment.