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

Provide one-stop values for nlb api #1198

Merged
merged 1 commit into from
Oct 13, 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
101 changes: 76 additions & 25 deletions src/api/rest/docs/docs.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
// Package docs GENERATED BY SWAG; DO NOT EDIT
// Package docs GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
// This file was generated by swaggo/swag
package docs

import "github.com/swaggo/swag"
import (
"bytes"
"encoding/json"
"strings"
"text/template"

const docTemplate = `{
"github.com/swaggo/swag"
)

var doc = `{
"schemes": {{ marshal .Schemes }},
"swagger": "2.0",
"info": {
Expand Down Expand Up @@ -2127,6 +2134,7 @@ const docTemplate = `{
},
{
"type": "string",
"default": "group-0",
"description": "NLB ID",
"name": "nlbId",
"in": "path",
Expand Down Expand Up @@ -2239,6 +2247,7 @@ const docTemplate = `{
},
{
"type": "string",
"default": "group-0",
"description": "NLB ID",
"name": "nlbId",
"in": "path",
Expand Down Expand Up @@ -2299,6 +2308,7 @@ const docTemplate = `{
},
{
"type": "string",
"default": "group-0",
"description": "NLB ID",
"name": "nlbId",
"in": "path",
Expand Down Expand Up @@ -2366,6 +2376,7 @@ const docTemplate = `{
},
{
"type": "string",
"default": "group-0",
"description": "NLB ID",
"name": "nlbId",
"in": "path",
Expand Down Expand Up @@ -8291,7 +8302,7 @@ const docTemplate = `{
"port": {
"description": "1-65535",
"type": "string",
"example": "22"
"example": "80"
},
"protocol": {
"description": "TCP|UDP",
Expand Down Expand Up @@ -8799,8 +8810,7 @@ const docTemplate = `{
},
"systemLabel": {
"description": "SystemLabel is for describing the mcis in a keyword (any string can be used) for special System purpose",
"type": "string",
"example": ""
"type": "string"
},
"vm": {
"type": "array",
Expand Down Expand Up @@ -8910,8 +8920,7 @@ const docTemplate = `{
},
"systemLabel": {
"description": "SystemLabel is for describing the mcis in a keyword (any string can be used) for special System purpose",
"type": "string",
"example": ""
"type": "string"
},
"vm": {
"type": "array",
Expand Down Expand Up @@ -9057,12 +9066,12 @@ const docTemplate = `{
"dnsName": {
"description": "Optional, Auto Generated and attached",
"type": "string",
"example": ""
"example": "ns01-group-cd3.elb.ap-northeast-2.amazonaws.com"
},
"ip": {
"description": "Auto Generated and attached",
"type": "string",
"example": ""
"example": "x.x.x.x"
},
"keyValueList": {
"type": "array",
Expand All @@ -9073,7 +9082,7 @@ const docTemplate = `{
"port": {
"description": "1-65535",
"type": "string",
"example": "22"
"example": "80"
},
"protocol": {
"description": "TCP|UDP",
Expand All @@ -9093,15 +9102,18 @@ const docTemplate = `{
],
"properties": {
"cspNLBId": {
"description": "Existing NLB (used only for option=register)",
"type": "string"
},
"description": {
"type": "string"
},
"healthChecker": {
"description": "HealthChecker",
"$ref": "#/definitions/mcis.TbNLBHealthCheckerReq"
},
"listener": {
"description": "Frontend",
"$ref": "#/definitions/mcis.NLBListenerReq"
},
"scope": {
Expand All @@ -9114,6 +9126,7 @@ const docTemplate = `{
"example": "REGION"
},
"targetGroup": {
"description": "Backend",
"$ref": "#/definitions/mcis.TbNLBTargetGroupReq"
},
"type": {
Expand All @@ -9139,7 +9152,7 @@ const docTemplate = `{
"port": {
"description": "Listener Port or 1-65535",
"type": "string",
"example": "22"
"example": "80"
},
"protocol": {
"description": "TCP|HTTP|HTTPS",
Expand All @@ -9148,7 +9161,7 @@ const docTemplate = `{
},
"vmGroupId": {
"type": "string",
"example": "group-1"
"example": "group-0"
},
"vms": {
"type": "array",
Expand All @@ -9164,7 +9177,7 @@ const docTemplate = `{
"port": {
"description": "Listener Port or 1-65535",
"type": "string",
"example": "22"
"example": "80"
},
"protocol": {
"description": "TCP|HTTP|HTTPS",
Expand All @@ -9173,7 +9186,7 @@ const docTemplate = `{
},
"vmGroupId": {
"type": "string",
"example": "group-1"
"example": "group-0"
}
}
},
Expand Down Expand Up @@ -9685,18 +9698,56 @@ const docTemplate = `{
}
}`

type swaggerInfo struct {
Version string
Host string
BasePath string
Schemes []string
Title string
Description string
}

// SwaggerInfo holds exported Swagger Info so clients can modify it
var SwaggerInfo = &swag.Spec{
Version: "latest",
Host: "",
BasePath: "/tumblebug",
Schemes: []string{},
Title: "CB-Tumblebug REST API",
Description: "CB-Tumblebug REST API",
InfoInstanceName: "swagger",
SwaggerTemplate: docTemplate,
var SwaggerInfo = swaggerInfo{
Version: "latest",
Host: "",
BasePath: "/tumblebug",
Schemes: []string{},
Title: "CB-Tumblebug REST API",
Description: "CB-Tumblebug REST API",
}

type s struct{}

func (s *s) ReadDoc() string {
sInfo := SwaggerInfo
sInfo.Description = strings.Replace(sInfo.Description, "\n", "\\n", -1)

t, err := template.New("swagger_info").Funcs(template.FuncMap{
"marshal": func(v interface{}) string {
a, _ := json.Marshal(v)
return string(a)
},
"escape": func(v interface{}) string {
// escape tabs
str := strings.Replace(v.(string), "\t", "\\t", -1)
// replace " with \", and if that results in \\", replace that with \\\"
str = strings.Replace(str, "\"", "\\\"", -1)
return strings.Replace(str, "\\\\\"", "\\\\\\\"", -1)
},
}).Parse(doc)
if err != nil {
return doc
}

var tpl bytes.Buffer
if err := t.Execute(&tpl, sInfo); err != nil {
return doc
}

return tpl.String()
}

func init() {
swag.Register(SwaggerInfo.InstanceName(), SwaggerInfo)
swag.Register(swag.Name, &s{})
}
30 changes: 18 additions & 12 deletions src/api/rest/docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -2119,6 +2119,7 @@
},
{
"type": "string",
"default": "group-0",
"description": "NLB ID",
"name": "nlbId",
"in": "path",
Expand Down Expand Up @@ -2231,6 +2232,7 @@
},
{
"type": "string",
"default": "group-0",
"description": "NLB ID",
"name": "nlbId",
"in": "path",
Expand Down Expand Up @@ -2291,6 +2293,7 @@
},
{
"type": "string",
"default": "group-0",
"description": "NLB ID",
"name": "nlbId",
"in": "path",
Expand Down Expand Up @@ -2358,6 +2361,7 @@
},
{
"type": "string",
"default": "group-0",
"description": "NLB ID",
"name": "nlbId",
"in": "path",
Expand Down Expand Up @@ -8283,7 +8287,7 @@
"port": {
"description": "1-65535",
"type": "string",
"example": "22"
"example": "80"
},
"protocol": {
"description": "TCP|UDP",
Expand Down Expand Up @@ -8791,8 +8795,7 @@
},
"systemLabel": {
"description": "SystemLabel is for describing the mcis in a keyword (any string can be used) for special System purpose",
"type": "string",
"example": ""
"type": "string"
},
"vm": {
"type": "array",
Expand Down Expand Up @@ -8902,8 +8905,7 @@
},
"systemLabel": {
"description": "SystemLabel is for describing the mcis in a keyword (any string can be used) for special System purpose",
"type": "string",
"example": ""
"type": "string"
},
"vm": {
"type": "array",
Expand Down Expand Up @@ -9049,12 +9051,12 @@
"dnsName": {
"description": "Optional, Auto Generated and attached",
"type": "string",
"example": ""
"example": "ns01-group-cd3.elb.ap-northeast-2.amazonaws.com"
},
"ip": {
"description": "Auto Generated and attached",
"type": "string",
"example": ""
"example": "x.x.x.x"
},
"keyValueList": {
"type": "array",
Expand All @@ -9065,7 +9067,7 @@
"port": {
"description": "1-65535",
"type": "string",
"example": "22"
"example": "80"
},
"protocol": {
"description": "TCP|UDP",
Expand All @@ -9085,15 +9087,18 @@
],
"properties": {
"cspNLBId": {
"description": "Existing NLB (used only for option=register)",
"type": "string"
},
"description": {
"type": "string"
},
"healthChecker": {
"description": "HealthChecker",
"$ref": "#/definitions/mcis.TbNLBHealthCheckerReq"
},
"listener": {
"description": "Frontend",
"$ref": "#/definitions/mcis.NLBListenerReq"
},
"scope": {
Expand All @@ -9106,6 +9111,7 @@
"example": "REGION"
},
"targetGroup": {
"description": "Backend",
"$ref": "#/definitions/mcis.TbNLBTargetGroupReq"
},
"type": {
Expand All @@ -9131,7 +9137,7 @@
"port": {
"description": "Listener Port or 1-65535",
"type": "string",
"example": "22"
"example": "80"
},
"protocol": {
"description": "TCP|HTTP|HTTPS",
Expand All @@ -9140,7 +9146,7 @@
},
"vmGroupId": {
"type": "string",
"example": "group-1"
"example": "group-0"
},
"vms": {
"type": "array",
Expand All @@ -9156,7 +9162,7 @@
"port": {
"description": "Listener Port or 1-65535",
"type": "string",
"example": "22"
"example": "80"
},
"protocol": {
"description": "TCP|HTTP|HTTPS",
Expand All @@ -9165,7 +9171,7 @@
},
"vmGroupId": {
"type": "string",
"example": "group-1"
"example": "group-0"
}
}
},
Expand Down
Loading