Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add vm (id) list filtering feature #1216

Merged
merged 1 commit into from
Oct 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/api/rest/docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -1788,6 +1788,20 @@ const docTemplate = `{
"description": "Option",
"name": "option",
"in": "query"
},
{
"type": "string",
"default": "connectionName",
"description": "(for option==id) Field key for filtering (ex: connectionName)",
"name": "filterKey",
"in": "query"
},
{
"type": "string",
"default": "aws-ap-northeast-2",
"description": "(for option==id) Field value for filtering (ex: aws-ap-northeast-2)",
"name": "filterVal",
"in": "query"
}
],
"responses": {
Expand Down
14 changes: 14 additions & 0 deletions src/api/rest/docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -1780,6 +1780,20 @@
"description": "Option",
"name": "option",
"in": "query"
},
{
"type": "string",
"default": "connectionName",
"description": "(for option==id) Field key for filtering (ex: connectionName)",
"name": "filterKey",
"in": "query"
},
{
"type": "string",
"default": "aws-ap-northeast-2",
"description": "(for option==id) Field value for filtering (ex: aws-ap-northeast-2)",
"name": "filterVal",
"in": "query"
}
],
"responses": {
Expand Down
10 changes: 10 additions & 0 deletions src/api/rest/docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3551,6 +3551,16 @@ paths:
in: query
name: option
type: string
- default: connectionName
description: '(for option==id) Field key for filtering (ex: connectionName)'
in: query
name: filterKey
type: string
- default: aws-ap-northeast-2
description: '(for option==id) Field value for filtering (ex: aws-ap-northeast-2)'
in: query
name: filterVal
type: string
produces:
- application/json
responses:
Expand Down
6 changes: 5 additions & 1 deletion src/api/rest/server/mcis/manageInfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ type JSONResult struct {
// @Param nsId path string true "Namespace ID" default(ns01)
// @Param mcisId path string true "MCIS ID" default(mcis01)
// @Param option query string false "Option" Enums(default, id, status)
// @Param filterKey query string false "(for option==id) Field key for filtering (ex: connectionName)" default(connectionName)
// @Param filterVal query string false "(for option==id) Field value for filtering (ex: aws-ap-northeast-2)" default(aws-ap-northeast-2)
// @success 200 {object} JSONResult{[DEFAULT]=mcis.TbMcisInfo,[ID]=common.IdList,[STATUS]=mcis.McisStatusInfo} "Different return structures by the given action param"
// @Failure 404 {object} common.SimpleMsg
// @Failure 500 {object} common.SimpleMsg
Expand All @@ -52,11 +54,13 @@ func RestGetMcis(c echo.Context) error {
mcisId := c.Param("mcisId")

option := c.QueryParam("option")
filterKey := c.QueryParam("filterKey")
filterVal := c.QueryParam("filterVal")

if option == "id" {
content := common.IdList{}
var err error
content.IdList, err = mcis.ListVmId(nsId, mcisId)
content.IdList, err = mcis.ListVmByFilter(nsId, mcisId, filterKey, filterVal)
if err != nil {
mapA := map[string]string{"message": err.Error()}
return c.JSON(http.StatusInternalServerError, &mapA)
Expand Down