Skip to content

Commit

Permalink
Add get mcis access info feature
Browse files Browse the repository at this point in the history
  • Loading branch information
seokho-son committed Oct 19, 2022
1 parent 957273f commit 816e48e
Show file tree
Hide file tree
Showing 6 changed files with 279 additions and 12 deletions.
67 changes: 64 additions & 3 deletions src/api/rest/docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -1750,7 +1750,7 @@ const docTemplate = `{
},
"/ns/{nsId}/mcis/{mcisId}": {
"get": {
"description": "Get MCIS object (option: status, vmID)",
"description": "Get MCIS object (option: status, accessInfo, vmId)",
"consumes": [
"application/json"
],
Expand All @@ -1760,7 +1760,7 @@ const docTemplate = `{
"tags": [
"[Infra service] MCIS Provisioning management"
],
"summary": "Get MCIS object (option: status, vmID)",
"summary": "Get MCIS object (option: status, accessInfo, vmId)",
"parameters": [
{
"type": "string",
Expand All @@ -1782,7 +1782,8 @@ const docTemplate = `{
"enum": [
"default",
"id",
"status"
"status",
"accessinfo"
],
"type": "string",
"description": "Option",
Expand Down Expand Up @@ -1815,6 +1816,9 @@ const docTemplate = `{
{
"type": "object",
"properties": {
"[AccessInfo]": {
"$ref": "#/definitions/mcis.McisAccessInfo"
},
"[DEFAULT]": {
"$ref": "#/definitions/mcis.TbMcisInfo"
},
Expand Down Expand Up @@ -8419,6 +8423,20 @@ const docTemplate = `{
"mcis.JSONResult": {
"type": "object"
},
"mcis.McisAccessInfo": {
"type": "object",
"properties": {
"mcisId": {
"type": "string"
},
"mcisSubGroupAccessInfo": {
"type": "array",
"items": {
"$ref": "#/definitions/mcis.McisSubGroupAccessInfo"
}
}
}
},
"mcis.McisCmdReq": {
"type": "object",
"required": [
Expand Down Expand Up @@ -8534,6 +8552,49 @@ const docTemplate = `{
}
}
},
"mcis.McisSubGroupAccessInfo": {
"type": "object",
"properties": {
"mcisVmAccessInfo": {
"type": "array",
"items": {
"$ref": "#/definitions/mcis.McisVmAccessInfo"
}
},
"nlbListener": {
"$ref": "#/definitions/mcis.TbNLBListenerInfo"
},
"subGroupId": {
"type": "string"
}
}
},
"mcis.McisVmAccessInfo": {
"type": "object",
"properties": {
"privateIP": {
"type": "string"
},
"privateKey": {
"type": "string"
},
"publicIP": {
"type": "string"
},
"sshPort": {
"type": "string"
},
"vmId": {
"type": "string"
},
"vmUserAccount": {
"type": "string"
},
"vmUserPassword": {
"type": "string"
}
}
},
"mcis.MonResultSimple": {
"type": "object",
"properties": {
Expand Down
67 changes: 64 additions & 3 deletions src/api/rest/docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -1742,7 +1742,7 @@
},
"/ns/{nsId}/mcis/{mcisId}": {
"get": {
"description": "Get MCIS object (option: status, vmID)",
"description": "Get MCIS object (option: status, accessInfo, vmId)",
"consumes": [
"application/json"
],
Expand All @@ -1752,7 +1752,7 @@
"tags": [
"[Infra service] MCIS Provisioning management"
],
"summary": "Get MCIS object (option: status, vmID)",
"summary": "Get MCIS object (option: status, accessInfo, vmId)",
"parameters": [
{
"type": "string",
Expand All @@ -1774,7 +1774,8 @@
"enum": [
"default",
"id",
"status"
"status",
"accessinfo"
],
"type": "string",
"description": "Option",
Expand Down Expand Up @@ -1807,6 +1808,9 @@
{
"type": "object",
"properties": {
"[AccessInfo]": {
"$ref": "#/definitions/mcis.McisAccessInfo"
},
"[DEFAULT]": {
"$ref": "#/definitions/mcis.TbMcisInfo"
},
Expand Down Expand Up @@ -8411,6 +8415,20 @@
"mcis.JSONResult": {
"type": "object"
},
"mcis.McisAccessInfo": {
"type": "object",
"properties": {
"mcisId": {
"type": "string"
},
"mcisSubGroupAccessInfo": {
"type": "array",
"items": {
"$ref": "#/definitions/mcis.McisSubGroupAccessInfo"
}
}
}
},
"mcis.McisCmdReq": {
"type": "object",
"required": [
Expand Down Expand Up @@ -8526,6 +8544,49 @@
}
}
},
"mcis.McisSubGroupAccessInfo": {
"type": "object",
"properties": {
"mcisVmAccessInfo": {
"type": "array",
"items": {
"$ref": "#/definitions/mcis.McisVmAccessInfo"
}
},
"nlbListener": {
"$ref": "#/definitions/mcis.TbNLBListenerInfo"
},
"subGroupId": {
"type": "string"
}
}
},
"mcis.McisVmAccessInfo": {
"type": "object",
"properties": {
"privateIP": {
"type": "string"
},
"privateKey": {
"type": "string"
},
"publicIP": {
"type": "string"
},
"sshPort": {
"type": "string"
},
"vmId": {
"type": "string"
},
"vmUserAccount": {
"type": "string"
},
"vmUserPassword": {
"type": "string"
}
}
},
"mcis.MonResultSimple": {
"type": "object",
"properties": {
Expand Down
44 changes: 42 additions & 2 deletions src/api/rest/docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1166,6 +1166,15 @@ definitions:
type: object
mcis.JSONResult:
type: object
mcis.McisAccessInfo:
properties:
mcisId:
type: string
mcisSubGroupAccessInfo:
items:
$ref: '#/definitions/mcis.McisSubGroupAccessInfo'
type: array
type: object
mcis.McisCmdReq:
properties:
command:
Expand Down Expand Up @@ -1249,6 +1258,34 @@ definitions:
$ref: '#/definitions/mcis.TbVmStatusInfo'
type: array
type: object
mcis.McisSubGroupAccessInfo:
properties:
mcisVmAccessInfo:
items:
$ref: '#/definitions/mcis.McisVmAccessInfo'
type: array
nlbListener:
$ref: '#/definitions/mcis.TbNLBListenerInfo'
subGroupId:
type: string
type: object
mcis.McisVmAccessInfo:
properties:
privateIP:
type: string
privateKey:
type: string
publicIP:
type: string
sshPort:
type: string
vmId:
type: string
vmUserAccount:
type: string
vmUserPassword:
type: string
type: object
mcis.MonResultSimple:
properties:
err:
Expand Down Expand Up @@ -3529,7 +3566,7 @@ paths:
get:
consumes:
- application/json
description: 'Get MCIS object (option: status, vmID)'
description: 'Get MCIS object (option: status, accessInfo, vmId)'
parameters:
- default: ns01
description: Namespace ID
Expand All @@ -3548,6 +3585,7 @@ paths:
- default
- id
- status
- accessinfo
in: query
name: option
type: string
Expand All @@ -3570,6 +3608,8 @@ paths:
allOf:
- $ref: '#/definitions/mcis.JSONResult'
- properties:
'[AccessInfo]':
$ref: '#/definitions/mcis.McisAccessInfo'
'[DEFAULT]':
$ref: '#/definitions/mcis.TbMcisInfo'
'[ID]':
Expand All @@ -3585,7 +3625,7 @@ paths:
description: Internal Server Error
schema:
$ref: '#/definitions/common.SimpleMsg'
summary: 'Get MCIS object (option: status, vmID)'
summary: 'Get MCIS object (option: status, accessInfo, vmId)'
tags:
- '[Infra service] MCIS Provisioning management'
/ns/{nsId}/mcis/{mcisId}/nlb:
Expand Down
19 changes: 15 additions & 4 deletions src/api/rest/server/mcis/manageInfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,17 @@ type JSONResult struct {
// Annotation for API documention Need to be revised.

// RestGetMcis godoc
// @Summary Get MCIS object (option: status, vmID)
// @Description Get MCIS object (option: status, vmID)
// @Summary Get MCIS object (option: status, accessInfo, vmId)
// @Description Get MCIS object (option: status, accessInfo, vmId)
// @Tags [Infra service] MCIS Provisioning management
// @Accept json
// @Produce json
// @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 option query string false "Option" Enums(default, id, status, accessinfo)
// @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"
// @success 200 {object} JSONResult{[DEFAULT]=mcis.TbMcisInfo,[ID]=common.IdList,[STATUS]=mcis.McisStatusInfo,[AccessInfo]=mcis.McisAccessInfo} "Different return structures by the given action param"
// @Failure 404 {object} common.SimpleMsg
// @Failure 500 {object} common.SimpleMsg
// @Router /ns/{nsId}/mcis/{mcisId} [get]
Expand Down Expand Up @@ -83,6 +83,17 @@ func RestGetMcis(c echo.Context) error {
common.PrintJsonPretty(content)
return c.JSON(http.StatusOK, &content)

} else if option == "accessinfo" {

result, err := mcis.GetMcisAccessInfo(nsId, mcisId)
if err != nil {
mapA := map[string]string{"message": err.Error()}
return c.JSON(http.StatusInternalServerError, &mapA)
}

common.PrintJsonPretty(result)
return c.JSON(http.StatusOK, &result)

} else {

result, err := mcis.GetMcisInfo(nsId, mcisId)
Expand Down
Loading

0 comments on commit 816e48e

Please sign in to comment.