func CreateSecurity(c echo.Context) error {
	cblog.Info("call CreateSecurity()")
	req := securityGroupCreateReq{}
	if err := c.Bind(&req); err != nil {
		return echo.NewHTTPError(http.StatusInternalServerError, err.Error())
	}
	reqInfo := cres.SecurityReqInfo{
		IId:           cres.IID{req.ReqInfo.Name, req.ReqInfo.Name},  
		VpcIID:        cres.IID{req.ReqInfo.VPCName, ""},
		Direction:     req.ReqInfo.Direction,
		SecurityRules: req.ReqInfo.SecurityRules,
	}
	result, err := cmrt.CreateSecurity(req.ConnectionName, rsSG, reqInfo)
	if err != nil {
		return echo.NewHTTPError(http.StatusInternalServerError, err.Error())
	}
	return c.JSON(http.StatusOK, result)
}
/* // createSecurity godoc
@Summary Create Security Group
@Description Create Security Group
@Tags [CCM] Security Group management
@Accept  json
@Produce  json
@Param securityGroupCreateReq body securityGroupCreateReq true "Request body to create Security Group"
@Success 200 {object} resources.SecurityInfo
@Failure 404 {object} SimpleMsg
@Failure 500 {object} SimpleMsg
@Router /securitygroup [post]
package restruntime
import (
	cmrt "github.com/cloud-barista/cb-spider/api-runtime/common-runtime"
	cres "github.com/cloud-barista/cb-spider/cloud-control-manager/cloud-driver/interfaces/resources"
	"net/http"
	"net/url"
	"github.com/labstack/echo/v4"
	"strconv"
)
const (
	rsImage string = "image"
	rsVPC   string = "vpc"
	rsSubnet string = "subnet"	
	rsSG  string = "sg"
	rsKey string = "keypair"
	rsVM  string = "vm"
)
func CreateImage(c echo.Context) error {
	cblog.Info("call CreateImage()")
	var req struct {
		ConnectionName string
		ReqInfo        struct {
			Name string
		}
	}
	if err := c.Bind(&req); err != nil {
		return echo.NewHTTPError(http.StatusInternalServerError, err.Error())
	}
	reqInfo := cres.ImageReqInfo{
		IId: cres.IID{req.ReqInfo.Name, ""},
	}
	result, err := cmrt.CreateImage(req.ConnectionName, rsImage, reqInfo)
	if err != nil {
		return echo.NewHTTPError(http.StatusInternalServerError, err.Error())
	}
	return c.JSON(http.StatusOK, result)
}
func ListImage(c echo.Context) error {
	cblog.Info("call ListImage()")
	var req struct {
		ConnectionName string
	}
	if err := c.Bind(&req); err != nil {
		return echo.NewHTTPError(http.StatusInternalServerError, err.Error())
	}
	result, err := cmrt.ListImage(req.ConnectionName, rsImage)
	if err != nil {
		return echo.NewHTTPError(http.StatusInternalServerError, err.Error())
	}
	var jsonResult struct {
		Result []*cres.ImageInfo `json:"image"`
	}
	jsonResult.Result = result
	return c.JSON(http.StatusOK, &jsonResult)
}
func GetImage(c echo.Context) error {
	cblog.Info("call GetImage()")
	var req struct {
		ConnectionName string
	}
	if err := c.Bind(&req); err != nil {
		return echo.NewHTTPError(http.StatusInternalServerError, err.Error())
	}
	encodededImageName := c.Param("Name")
	decodedImageName, err := url.QueryUnescape(encodededImageName)
	if err != nil {
		cblog.Fatal(err)
		return echo.NewHTTPError(http.StatusInternalServerError, err.Error())
	}
	result, err := cmrt.GetImage(req.ConnectionName, rsImage, decodedImageName)
	if err != nil {
		return echo.NewHTTPError(http.StatusInternalServerError, err.Error())
	}
	return c.JSON(http.StatusOK, result)
}
func DeleteImage(c echo.Context) error {
	cblog.Info("call DeleteImage()")
	var req struct {
		ConnectionName string
	}
	if err := c.Bind(&req); err != nil {
		return echo.NewHTTPError(http.StatusInternalServerError, err.Error())
	}
	result, err := cmrt.DeleteImage(req.ConnectionName, rsImage, c.Param("Name"))
	if err != nil {
		return echo.NewHTTPError(http.StatusInternalServerError, err.Error())
	}
	resultInfo := BooleanInfo{
		Result: strconv.FormatBool(result),
	}
	return c.JSON(http.StatusOK, &resultInfo)
}
func ListVMSpec(c echo.Context) error {
	cblog.Info("call ListVMSpec()")
	var req struct {
		ConnectionName string
	}
	if err := c.Bind(&req); err != nil {
		return echo.NewHTTPError(http.StatusInternalServerError, err.Error())
	}
	result, err := cmrt.ListVMSpec(req.ConnectionName)
	if err != nil {
		return echo.NewHTTPError(http.StatusInternalServerError, err.Error())
	}
	var jsonResult struct {
		Result []*cres.VMSpecInfo `json:"vmspec"`
	}
	jsonResult.Result = result
	return c.JSON(http.StatusOK, &jsonResult)
}
func GetVMSpec(c echo.Context) error {
	cblog.Info("call GetVMSpec()")
	var req struct {
		ConnectionName string
	}
	if err := c.Bind(&req); err != nil {
		return echo.NewHTTPError(http.StatusInternalServerError, err.Error())
	}
	result, err := cmrt.GetVMSpec(req.ConnectionName, c.Param("Name"))
	if err != nil {
		return echo.NewHTTPError(http.StatusInternalServerError, err.Error())
	}
	return c.JSON(http.StatusOK, result)
}
func ListOrgVMSpec(c echo.Context) error {
	cblog.Info("call ListOrgVMSpec()")
	var req struct {
		ConnectionName string
	}
	if err := c.Bind(&req); err != nil {
		return echo.NewHTTPError(http.StatusInternalServerError, err.Error())
	}
	result, err := cmrt.ListOrgVMSpec(req.ConnectionName)
	if err != nil {
		return echo.NewHTTPError(http.StatusInternalServerError, err.Error())
	}
	return c.String(http.StatusOK, result)
}
func GetOrgVMSpec(c echo.Context) error {
	cblog.Info("call GetOrgVMSpec()")
	var req struct {
		ConnectionName string
	}
	if err := c.Bind(&req); err != nil {
		return echo.NewHTTPError(http.StatusInternalServerError, err.Error())
	}
	result, err := cmrt.GetOrgVMSpec(req.ConnectionName, c.Param("Name"))
	if err != nil {
		return echo.NewHTTPError(http.StatusInternalServerError, err.Error())
	}
	return c.String(http.StatusOK, result)
}
type vpcRegisterReq struct {
	ConnectionName string
	ReqInfo        struct {
		Name           string
		CSPId          string
	}
}
func RegisterVPC(c echo.Context) error {
        cblog.Info("call RegisterVPC()")
        req := vpcRegisterReq{}
        if err := c.Bind(&req); err != nil {
                return echo.NewHTTPError(http.StatusInternalServerError, err.Error())
        }
	userIId := cres.IID{req.ReqInfo.Name, req.ReqInfo.CSPId}
        result, err := cmrt.RegisterVPC(req.ConnectionName, userIId)
        if err != nil {
                return echo.NewHTTPError(http.StatusInternalServerError, err.Error())
        }
        return c.JSON(http.StatusOK, result)
}
func UnregisterVPC(c echo.Context) error {
        cblog.Info("call UnregisterVPC()")
        var req struct {
                ConnectionName string
        }
        if err := c.Bind(&req); err != nil {
                return echo.NewHTTPError(http.StatusInternalServerError, err.Error())
        }
        result, err := cmrt.UnregisterResource(req.ConnectionName, rsVPC, c.Param("Name"))
        if err != nil {
                return echo.NewHTTPError(http.StatusInternalServerError, err.Error())
        }
        resultInfo := BooleanInfo{
                Result: strconv.FormatBool(result),
        }
        return c.JSON(http.StatusOK, &resultInfo)
}
type vpcCreateReq struct {
        ConnectionName string
        ReqInfo        struct {
                Name           string
                IPv4_CIDR      string
                SubnetInfoList []struct {
                        Name      string
                        IPv4_CIDR string
                }
        }
}
func CreateVPC(c echo.Context) error {
	cblog.Info("call CreateVPC()")
	req := vpcCreateReq{}
	if err := c.Bind(&req); err != nil {
		return echo.NewHTTPError(http.StatusInternalServerError, err.Error())
	}
	subnetInfoList := []cres.SubnetInfo{}
	for _, info := range req.ReqInfo.SubnetInfoList {
		subnetInfo := cres.SubnetInfo{IId: cres.IID{info.Name, ""}, IPv4_CIDR: info.IPv4_CIDR}
		subnetInfoList = append(subnetInfoList, subnetInfo)
	}
	reqInfo := cres.VPCReqInfo{
		IId:            cres.IID{req.ReqInfo.Name, ""},
		IPv4_CIDR:      req.ReqInfo.IPv4_CIDR,
		SubnetInfoList: subnetInfoList,
	}
	result, err := cmrt.CreateVPC(req.ConnectionName, rsVPC, reqInfo)
	if err != nil {
		return echo.NewHTTPError(http.StatusInternalServerError, err.Error())
	}
	return c.JSON(http.StatusOK, result)
}
func ListVPC(c echo.Context) error {
	cblog.Info("call ListVPC()")
	var req struct {
		ConnectionName string
	}
	if err := c.Bind(&req); err != nil {
		return echo.NewHTTPError(http.StatusInternalServerError, err.Error())
	}
	result, err := cmrt.ListVPC(req.ConnectionName, rsVPC)
	if err != nil {
		return echo.NewHTTPError(http.StatusInternalServerError, err.Error())
	}
	var jsonResult struct {
		Result []*cres.VPCInfo `json:"vpc"`
	}
	jsonResult.Result = result
	return c.JSON(http.StatusOK, &jsonResult)
}
func ListAllVPC(c echo.Context) error {
	cblog.Info("call ListAllVPC()")
	var req struct {
		ConnectionName string
	}
	if err := c.Bind(&req); err != nil {
		return echo.NewHTTPError(http.StatusInternalServerError, err.Error())
	}
	allResourceList, err := cmrt.ListAllResource(req.ConnectionName, rsVPC)
	if err != nil {
		return echo.NewHTTPError(http.StatusInternalServerError, err.Error())
	}
	return c.JSON(http.StatusOK, &allResourceList)
}
func GetVPC(c echo.Context) error {
	cblog.Info("call GetVPC()")
	var req struct {
		ConnectionName string
	}
	if err := c.Bind(&req); err != nil {
		return echo.NewHTTPError(http.StatusInternalServerError, err.Error())
	}
	result, err := cmrt.GetVPC(req.ConnectionName, rsVPC, c.Param("Name"))
	if err != nil {
		return echo.NewHTTPError(http.StatusInternalServerError, err.Error())
	}
	return c.JSON(http.StatusOK, result)
}
func DeleteVPC(c echo.Context) error {
	cblog.Info("call DeleteVPC()")
	var req struct {
		ConnectionName string
	}
	if err := c.Bind(&req); err != nil {
		return echo.NewHTTPError(http.StatusInternalServerError, err.Error())
	}
	result, _, err := cmrt.DeleteResource(req.ConnectionName, rsVPC, c.Param("Name"), c.QueryParam("force"))
	if err != nil {
		return echo.NewHTTPError(http.StatusInternalServerError, err.Error())
	}
	resultInfo := BooleanInfo{
		Result: strconv.FormatBool(result),
	}
	return c.JSON(http.StatusOK, &resultInfo)
}
func DeleteCSPVPC(c echo.Context) error {
	cblog.Info("call DeleteCSPVPC()")
	var req struct {
		ConnectionName string
	}
	if err := c.Bind(&req); err != nil {
		return echo.NewHTTPError(http.StatusInternalServerError, err.Error())
	}
	result, _, err := cmrt.DeleteCSPResource(req.ConnectionName, rsVPC, c.Param("Id"))
	if err != nil {
		return echo.NewHTTPError(http.StatusInternalServerError, err.Error())
	}
	resultInfo := BooleanInfo{
		Result: strconv.FormatBool(result),
	}
	return c.JSON(http.StatusOK, &resultInfo)
}
func AddSubnet(c echo.Context) error {
	cblog.Info("call AddSubnet()")
	var req struct {
		ConnectionName string
		ReqInfo        struct {
			Name      string
			IPv4_CIDR string
		}
	}
	if err := c.Bind(&req); err != nil {
		return echo.NewHTTPError(http.StatusInternalServerError, err.Error())
	}
	reqSubnetInfo := cres.SubnetInfo{IId: cres.IID{req.ReqInfo.Name, ""}, IPv4_CIDR: req.ReqInfo.IPv4_CIDR}
	result, err := cmrt.AddSubnet(req.ConnectionName, rsSubnet, c.Param("VPCName"), reqSubnetInfo)
	if err != nil {
		return echo.NewHTTPError(http.StatusInternalServerError, err.Error())
	}
	return c.JSON(http.StatusOK, result)
}
func RemoveSubnet(c echo.Context) error {
	cblog.Info("call RemoveSubnet()")
	var req struct {
		ConnectionName string
	}
	if err := c.Bind(&req); err != nil {
		return echo.NewHTTPError(http.StatusInternalServerError, err.Error())
	}
	result, err := cmrt.RemoveSubnet(req.ConnectionName, c.Param("VPCName"), c.Param("SubnetName"), c.QueryParam("force"))
	if err != nil {
		return echo.NewHTTPError(http.StatusInternalServerError, err.Error())
	}
	resultInfo := BooleanInfo{
		Result: strconv.FormatBool(result),
	}
	return c.JSON(http.StatusOK, &resultInfo)
}
func RemoveCSPSubnet(c echo.Context) error {
	cblog.Info("call DeleteCSPVPC()")
	var req struct {
		ConnectionName string
	}
	if err := c.Bind(&req); err != nil {
		return echo.NewHTTPError(http.StatusInternalServerError, err.Error())
	}
	result, err := cmrt.RemoveCSPSubnet(req.ConnectionName, c.Param("VPCName"), c.Param("Id"))
	if err != nil {
		return echo.NewHTTPError(http.StatusInternalServerError, err.Error())
	}
	resultInfo := BooleanInfo{
		Result: strconv.FormatBool(result),
	}
	return c.JSON(http.StatusOK, &resultInfo)
}
type securityGroupRegisterReq struct {
        ConnectionName string
        ReqInfo        struct {
                VPCName           string
                Name           string
                CSPId          string
        }
}
func RegisterSecurity(c echo.Context) error {
        cblog.Info("call RegisterSecurity()")
        req := securityGroupRegisterReq{}
        if err := c.Bind(&req); err != nil {
                return echo.NewHTTPError(http.StatusInternalServerError, err.Error())
        }
        userIId := cres.IID{req.ReqInfo.Name, req.ReqInfo.CSPId}
        result, err := cmrt.RegisterSecurity(req.ConnectionName, req.ReqInfo.VPCName, userIId)
        if err != nil {
                return echo.NewHTTPError(http.StatusInternalServerError, err.Error())
        }
        return c.JSON(http.StatusOK, result)
}
func UnregisterSecurity(c echo.Context) error {
        cblog.Info("call UnregisterSecurity()")
        var req struct {
                ConnectionName string
        }
        if err := c.Bind(&req); err != nil {
                return echo.NewHTTPError(http.StatusInternalServerError, err.Error())
        }
        result, err := cmrt.UnregisterResource(req.ConnectionName, rsSG, c.Param("Name"))
        if err != nil {
                return echo.NewHTTPError(http.StatusInternalServerError, err.Error())
        }
        resultInfo := BooleanInfo{
                Result: strconv.FormatBool(result),
        }
        return c.JSON(http.StatusOK, &resultInfo)
}
type securityGroupCreateReq struct {
	ConnectionName string
	ReqInfo        struct {
		Name          string
		VPCName       string
		Direction     string
		SecurityRules *[]cres.SecurityRuleInfo
	}
}