Skip to content

Commit

Permalink
Add API drafts to enhance network features
Browse files Browse the repository at this point in the history
  • Loading branch information
yunkon-kim committed Aug 14, 2024
1 parent c58e72d commit 7991e83
Show file tree
Hide file tree
Showing 7 changed files with 314 additions and 3 deletions.
85 changes: 85 additions & 0 deletions src/api/rest/docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -4574,6 +4574,60 @@ const docTemplate = `{
}
}
},
"/ns/{nsId}/mcis/{mcisId}/vnet": {
"get": {
"description": "Get vNets in specified MCIS (not yet implemented)",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"[Infra service] MCIS Provisioning management"
],
"summary": "Get vNets in specified MCIS (not yet implemented)",
"operationId": "RestGetMcisVNets",
"parameters": [
{
"type": "string",
"default": "ns01",
"description": "Namespace ID",
"name": "nsId",
"in": "path",
"required": true
},
{
"type": "string",
"default": "mcis01",
"description": "MCIS ID",
"name": "mcisId",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/mcis.RestGetMcisVnetsResponse"
}
},
"404": {
"description": "Not Found",
"schema": {
"$ref": "#/definitions/common.SimpleMsg"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/common.SimpleMsg"
}
}
}
}
},
"/ns/{nsId}/mcis/{mcisId}/vpn/{vpnId}": {
"get": {
"description": "Get resource info of a site-to-site VPN (Currently, GCP-AWS is supported)",
Expand Down Expand Up @@ -10782,6 +10836,9 @@ const docTemplate = `{
},
"name": {
"type": "string"
},
"zone": {
"type": "string"
}
}
},
Expand Down Expand Up @@ -11667,6 +11724,29 @@ const docTemplate = `{
}
}
},
"mcis.RestGetMcisVnetsResponse": {
"type": "object",
"properties": {
"cidrBlock": {
"type": "string"
},
"description": {
"type": "string"
},
"mcisId": {
"type": "string"
},
"nsId": {
"type": "string"
},
"vNet": {
"type": "array",
"items": {
"$ref": "#/definitions/mcir.TbVNetInfo"
}
}
}
},
"mcis.SpiderImageType": {
"type": "string",
"enum": [
Expand Down Expand Up @@ -12364,6 +12444,11 @@ const docTemplate = `{
"vm"
],
"properties": {
"cidrBlock": {
"description": "CidrBlock is a logical address block for the MCIS and is subnetted for vNets and subnets",
"type": "string",
"example": "10.10.0.0/16"
},
"description": {
"type": "string",
"example": "Made in CB-TB"
Expand Down
85 changes: 85 additions & 0 deletions src/api/rest/docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -4567,6 +4567,60 @@
}
}
},
"/ns/{nsId}/mcis/{mcisId}/vnet": {
"get": {
"description": "Get vNets in specified MCIS (not yet implemented)",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"[Infra service] MCIS Provisioning management"
],
"summary": "Get vNets in specified MCIS (not yet implemented)",
"operationId": "RestGetMcisVNets",
"parameters": [
{
"type": "string",
"default": "ns01",
"description": "Namespace ID",
"name": "nsId",
"in": "path",
"required": true
},
{
"type": "string",
"default": "mcis01",
"description": "MCIS ID",
"name": "mcisId",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/mcis.RestGetMcisVnetsResponse"
}
},
"404": {
"description": "Not Found",
"schema": {
"$ref": "#/definitions/common.SimpleMsg"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/common.SimpleMsg"
}
}
}
}
},
"/ns/{nsId}/mcis/{mcisId}/vpn/{vpnId}": {
"get": {
"description": "Get resource info of a site-to-site VPN (Currently, GCP-AWS is supported)",
Expand Down Expand Up @@ -10775,6 +10829,9 @@
},
"name": {
"type": "string"
},
"zone": {
"type": "string"
}
}
},
Expand Down Expand Up @@ -11660,6 +11717,29 @@
}
}
},
"mcis.RestGetMcisVnetsResponse": {
"type": "object",
"properties": {
"cidrBlock": {
"type": "string"
},
"description": {
"type": "string"
},
"mcisId": {
"type": "string"
},
"nsId": {
"type": "string"
},
"vNet": {
"type": "array",
"items": {
"$ref": "#/definitions/mcir.TbVNetInfo"
}
}
}
},
"mcis.SpiderImageType": {
"type": "string",
"enum": [
Expand Down Expand Up @@ -12357,6 +12437,11 @@
"vm"
],
"properties": {
"cidrBlock": {
"description": "CidrBlock is a logical address block for the MCIS and is subnetted for vNets and subnets",
"type": "string",
"example": "10.10.0.0/16"
},
"description": {
"type": "string",
"example": "Made in CB-TB"
Expand Down
59 changes: 59 additions & 0 deletions src/api/rest/docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1195,6 +1195,8 @@ definitions:
type: array
name:
type: string
zone:
type: string
required:
- ipv4_CIDR
- name
Expand Down Expand Up @@ -1799,6 +1801,21 @@ definitions:
host:
type: string
type: object
mcis.RestGetMcisVnetsResponse:
properties:
cidrBlock:
type: string
description:
type: string
mcisId:
type: string
nsId:
type: string
vNet:
items:
$ref: '#/definitions/mcir.TbVNetInfo'
type: array
type: object
mcis.SpiderImageType:
enum:
- PublicImage
Expand Down Expand Up @@ -2297,6 +2314,11 @@ definitions:
- TbK8sNodeGroupDeleting
mcis.TbMcisDynamicReq:
properties:
cidrBlock:
description: CidrBlock is a logical address block for the MCIS and is subnetted
for vNets and subnets
example: 10.10.0.0/16
type: string
description:
example: Made in CB-TB
type: string
Expand Down Expand Up @@ -6340,6 +6362,43 @@ paths:
summary: Create VM Dynamically and add it to MCIS
tags:
- '[Infra service] MCIS Provisioning management'
/ns/{nsId}/mcis/{mcisId}/vnet:
get:
consumes:
- application/json
description: Get vNets in specified MCIS (not yet implemented)
operationId: RestGetMcisVNets
parameters:
- default: ns01
description: Namespace ID
in: path
name: nsId
required: true
type: string
- default: mcis01
description: MCIS ID
in: path
name: mcisId
required: true
type: string
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/mcis.RestGetMcisVnetsResponse'
"404":
description: Not Found
schema:
$ref: '#/definitions/common.SimpleMsg'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/common.SimpleMsg'
summary: Get vNets in specified MCIS (not yet implemented)
tags:
- '[Infra service] MCIS Provisioning management'
/ns/{nsId}/mcis/{mcisId}/vpn/{vpnId}:
get:
consumes:
Expand Down
71 changes: 71 additions & 0 deletions src/api/rest/server/mcis/manageInfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"net/http"

"github.com/cloud-barista/cb-tumblebug/src/core/common"
"github.com/cloud-barista/cb-tumblebug/src/core/mcir"
"github.com/cloud-barista/cb-tumblebug/src/core/mcis"
"github.com/labstack/echo/v4"
"github.com/rs/zerolog/log"
Expand Down Expand Up @@ -392,3 +393,73 @@ func RestGetMcisGroupIds(c echo.Context) error {
content.IdList, err = mcis.ListSubGroupId(nsId, mcisId)
return common.EndRequestWithLog(c, reqID, err, content)
}

type RestGetMcisVnetsResponse struct {
NsId string `json:"nsId"`
McisId string `json:"mcisId"`
Description string `json:"description"`
CidrBlock string `json:"cidrBlock"`
VNet []mcir.TbVNetInfo `json:"vNet"`
}

// RestGetMcisVNets godoc
// @ID RestGetMcisVNets
// @Summary (To be implemented) Get vNets in specified MCIS
// @Description (To be implemented) Get vNets in specified MCIS
// @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)
// @success 200 {object} RestGetMcisVnetsResponse
// @Failure 404 {object} common.SimpleMsg
// @Failure 500 {object} common.SimpleMsg
// @Router /ns/{nsId}/mcis/{mcisId}/vnet [get]
func RestGetMcisVNets(c echo.Context) error {

nsId := c.Param("nsId")
if nsId == "" {
return c.JSON(http.StatusBadRequest, "NS ID is required")
}
mcisId := c.Param("mcisId")
if mcisId == "" {
return c.JSON(http.StatusBadRequest, "MCIS ID is required")
}

dummbyVnets := []mcir.TbVNetInfo{}
for i := 0; i < 3; i++ {
dummyVnet := mcir.TbVNetInfo{
Id: "mock-vnet-01",
Name: "mock-vnet-01",
ConnectionName: "mock-conn-name",
CidrBlock: "192.168.0.0/24",
SubnetInfoList: []mcir.TbSubnetInfo{
{
Id: "mock-subnet-01",
Name: "mock-subnet-01",
IPv4_CIDR: "",
KeyValueList: []common.KeyValue{},
Description: "not yet implemented",
},
},
CspVNetId: "mock-csp-vnet-id",
CspVNetName: "mock-csp-vnet-name",
Status: "mock-status",
KeyValueList: []common.KeyValue{},
AssociatedObjectList: []string{},
IsAutoGenerated: false,
SystemLabel: "mock-managed in" + mcisId,
}
dummbyVnets = append(dummbyVnets, dummyVnet)
}

dummyRes := RestGetMcisVnetsResponse{
NsId: nsId,
McisId: mcisId,
Description: "mock-description",
CidrBlock: "192.168.0.0./16",
VNet: dummbyVnets,
}

return c.JSON(http.StatusOK, dummyRes)
}
Loading

0 comments on commit 7991e83

Please sign in to comment.