diff --git a/api-runtime/rest-runtime/CBSpiderRuntime.go b/api-runtime/rest-runtime/CBSpiderRuntime.go index 473e27d56..36be3a2b1 100644 --- a/api-runtime/rest-runtime/CBSpiderRuntime.go +++ b/api-runtime/rest-runtime/CBSpiderRuntime.go @@ -75,15 +75,6 @@ func init() { cr.ServicePort = getServicePort("SERVICE_ADDRESS") } -// REST API Return struct for boolean type -type BooleanInfo struct { - Result string // true or false -} - -type StatusInfo struct { - Status string // PENDING | RUNNING | SUSPENDING | SUSPENDED | REBOOTING | TERMINATING | TERMINATED -} - // ex) {"POST", "/driver", registerCloudDriver} type route struct { method, path string diff --git a/api-runtime/rest-runtime/CommonRest.go b/api-runtime/rest-runtime/CommonRest.go index ac3866d74..985ddd28e 100644 --- a/api-runtime/rest-runtime/CommonRest.go +++ b/api-runtime/rest-runtime/CommonRest.go @@ -37,6 +37,22 @@ const ( NODEGROUP string = string(cres.NODEGROUP) ) +//================ Common Request & Response + +// ConnectionRequest represents the request body for common use. +type ConnectionRequest struct { + ConnectionName string `json:"ConnectionName" validate:"required" example:"aws-connection"` +} + +// REST API Return struct for boolean type +type BooleanInfo struct { + Result string `json:"Result" validate:"required" example:"true"` // true or false +} + +type StatusInfo struct { + Status string `json:"Status" validate:"required" example:"RUNNING"` // "RUNNING,SUSPENDING,SUSPENDED,REBOOTING,TERMINATING,TERMINATED,NOTEXIST,FAILED" +} + //================ Get CSP Resource Name func GetCSPResourceName(c echo.Context) error { diff --git a/api-runtime/rest-runtime/VMRest.go b/api-runtime/rest-runtime/VMRest.go index 3f09fd8ce..9cb62e211 100644 --- a/api-runtime/rest-runtime/VMRest.go +++ b/api-runtime/rest-runtime/VMRest.go @@ -22,22 +22,43 @@ import ( //================ VM Handler +// VMUsingResources represents the structure of the resources associated with a VM. +type VMUsingResources struct { + Resources struct { + VPC *cres.IID `json:"VPC" validate:"required"` // example:"{NameId: 'vpc-01', SystemId: 'vpc-12345678'}" + SGList []*cres.IID `json:"SGList" validate:"required"` // example:"[{NameId: 'sg-01', SystemId: 'sg-12345678'}]" + VMKey *cres.IID `json:"VMKey,omitempty" validate:"omitempty"` // example:"{NameId: 'keypair-01', SystemId: 'keypair-12345678'}" + } `json:"Resources" validate:"required"` +} + +// getVMUsingRS godoc +// @ID get-vm-using-rs +// @Summary Get VM Using Resource +// @Description Retrieve details of a VM using resource ID. +// @Tags [VM management] +// @Accept json +// @Produce json +// @Param ConnectionName query string true "Connection name for the VM" +// @Param CSPId query string true "CSP ID of the VM" +// @Success 200 {object} restruntime.VMUsingResources "Details of the VM using resource" +// @Failure 400 {object} SimpleMsg "Bad Request, possibly due to invalid query parameters" +// @Failure 404 {object} SimpleMsg "Resource Not Found" +// @Failure 500 {object} SimpleMsg "Internal Server Error" +// @Router /getvmusingresources [get] func GetVMUsingRS(c echo.Context) error { cblog.Info("call GetVMUsingRS()") - var req struct { - ConnectionName string - ReqInfo struct { - CSPId string - } - } + // Parse query parameters + connectionName := c.QueryParam("ConnectionName") + cspID := c.QueryParam("CSPId") - if err := c.Bind(&req); err != nil { - return echo.NewHTTPError(http.StatusInternalServerError, err.Error()) + // Validate required parameters + if connectionName == "" || cspID == "" { + return echo.NewHTTPError(http.StatusBadRequest, "ConnectionName and CSPId are required") } // Call common-runtime API - result, err := cmrt.GetVMUsingRS(req.ConnectionName, req.ReqInfo.CSPId) + result, err := cmrt.GetVMUsingRS(connectionName, cspID) if err != nil { return echo.NewHTTPError(http.StatusInternalServerError, err.Error()) } @@ -45,18 +66,32 @@ func GetVMUsingRS(c echo.Context) error { return c.JSON(http.StatusOK, result) } -type vmRegisterReq struct { - ConnectionName string +// VMRegisterRequest represents the request body for registering a VM. +type VMRegisterRequest struct { + ConnectionName string `json:"ConnectionName" validate:"required" example:"aws-connection"` ReqInfo struct { - Name string - CSPId string - } + Name string `json:"Name" validate:"required" example:"vm-01"` + CSPId string `json:"CSPId" validate:"required" example:"csp-vm-1234"` + } `json:"ReqInfo" validate:"required"` } +// registerVM godoc +// @ID register-vm +// @Summary Register VM +// @Description Register a new Virtual Machine (VM) with the specified name and CSP ID. +// @Tags [VM management] +// @Accept json +// @Produce json +// @Param VMRegisterRequest body restruntime.VMRegisterRequest true "Request body for registering a VM" +// @Success 200 {object} cres.VMInfo "Details of the registered VM" +// @Failure 400 {object} SimpleMsg "Bad Request, possibly due to invalid JSON structure or missing fields" +// @Failure 404 {object} SimpleMsg "Resource Not Found" +// @Failure 500 {object} SimpleMsg "Internal Server Error" +// @Router /regvm [post] func RegisterVM(c echo.Context) error { cblog.Info("call RegisterVM()") - req := vmRegisterReq{} + req := VMRegisterRequest{} if err := c.Bind(&req); err != nil { return echo.NewHTTPError(http.StatusInternalServerError, err.Error()) @@ -74,15 +109,24 @@ func RegisterVM(c echo.Context) error { return c.JSON(http.StatusOK, result) } -// (1) get args from REST Call -// (2) call common-runtime API -// (3) return REST Json Format +// unregisterVM godoc +// @ID unregister-vm +// @Summary Unregister VM +// @Description Unregister a Virtual Machine (VM) with the specified name. +// @Tags [VM management] +// @Accept json +// @Produce json +// @Param ConnectionRequest body restruntime.ConnectionRequest true "Request body for unregistering a VM" +// @Param Name path string true "The name of the VM to unregister" +// @Success 200 {object} BooleanInfo "Result of the unregister operation" +// @Failure 400 {object} SimpleMsg "Bad Request, possibly due to invalid JSON structure or missing fields" +// @Failure 404 {object} SimpleMsg "Resource Not Found" +// @Failure 500 {object} SimpleMsg "Internal Server Error" +// @Router /regvm/{Name} [delete] func UnregisterVM(c echo.Context) error { cblog.Info("call UnregisterVM()") - var req struct { - ConnectionName string - } + var req ConnectionRequest if err := c.Bind(&req); err != nil { return echo.NewHTTPError(http.StatusInternalServerError, err.Error()) @@ -101,33 +145,49 @@ func UnregisterVM(c echo.Context) error { return c.JSON(http.StatusOK, &resultInfo) } +// VMStartRequest represents the request body for starting a VM. +type VMStartRequest struct { + ConnectionName string `json:"ConnectionName" validate:"required" example:"aws-connection"` + IDTransformMode string `json:"IDTransformMode,omitempty" validate:"omitempty" example:"ON"` // ON: transform CSP ID, OFF: no-transform CSP ID + ReqInfo struct { + Name string `json:"Name" validate:"required" example:"vm-01"` + ImageType string `json:"ImageType" validate:"required" example:"PublicImage"` // PublicImage or MyImage + ImageName string `json:"ImageName" validate:"required" example:"ami-12345678"` + VMSpecName string `json:"VMSpecName" validate:"required" example:"t2.micro"` + + VPCName string `json:"VPCName" validate:"required" example:"vpc-01"` + SubnetName string `json:"SubnetName" validate:"required" example:"subnet-01"` + SecurityGroupNames []string `json:"SecurityGroupNames" validate:"required" example:"sg-01,sg-02"` + KeyPairName string `json:"KeyPairName" validate:"required" example:"keypair-01"` + + RootDiskType string `json:"RootDiskType,omitempty" validate:"omitempty" example:"gp2"` // gp2 or default, if not specified, default is used + RootDiskSize string `json:"RootDiskSize,omitempty" validate:"omitempty" example:"30"` // GB, 30 or default, if not specified, default is used + DataDiskNames []string `json:"DataDiskNames,omitempty" validate:"omitempty" example:"data-disk-01, data-disk-02"` // same zone as this VM + + VMUserId string `json:"VMUserId,omitempty" validate:"omitempty" example:"Administrator"` // Administrator, Windows Only + VMUserPasswd string `json:"VMUserPasswd,omitempty" validate:"omitempty" example:"password1234"` // Windows Only + + TagList []cres.KeyValue `json:"TagList,omitempty" validate:"omitempty"` + } `json:"ReqInfo" validate:"required"` +} + +// startVM godoc +// @ID start-vm +// @Summary Start VM +// @Description Start a new Virtual Machine (VM) with specified configurations. +// @Tags [VM management] +// @Accept json +// @Produce json +// @Param VMStartRequest body restruntime.VMStartRequest true "Request body for starting a VM" +// @Success 200 {object} cres.VMInfo "Details of the started VM" +// @Failure 400 {object} SimpleMsg "Bad Request, possibly due to invalid JSON structure or missing fields" +// @Failure 404 {object} SimpleMsg "Resource Not Found" +// @Failure 500 {object} SimpleMsg "Internal Server Error" +// @Router /vm [post] func StartVM(c echo.Context) error { cblog.Info("call StartVM()") - var req struct { - ConnectionName string - IDTransformMode string // ON | OFF, default is ON - ReqInfo struct { - Name string - ImageType string - ImageName string - VPCName string - SubnetName string - SecurityGroupNames []string - VMSpecName string - KeyPairName string - - RootDiskType string - RootDiskSize string - - DataDiskNames []string - - VMUserId string - VMUserPasswd string - - TagList []cres.KeyValue - } - } + req := VMStartRequest{} if err := c.Bind(&req); err != nil { return echo.NewHTTPError(http.StatusInternalServerError, err.Error()) @@ -137,9 +197,6 @@ func StartVM(c echo.Context) error { // (1) create SecurityGroup IID List sgIIDList := []cres.IID{} for _, sgName := range req.ReqInfo.SecurityGroupNames { - // SG NameID format => {VPC NameID} + cm.SG_DELIMITER + {SG NameID} - // transform: SG NameID => {VPC NameID}-{SG NameID} - //sgIID := cres.IID{req.ReqInfo.VPCName + cm.SG_DELIMITER + sgName, ""} sgIID := cres.IID{sgName, ""} sgIIDList = append(sgIIDList, sgIID) } @@ -183,12 +240,28 @@ func StartVM(c echo.Context) error { return c.JSON(http.StatusOK, result) } +// VMListResponse represents the response body structure for listing VMs. +type VMListResponse struct { + VMs []*cres.VMInfo `json:"vm" validate:"required"` +} + +// listVM godoc +// @ID list-vm +// @Summary List VMs +// @Description Retrieve a list of Virtual Machines (VMs) associated with a specific connection. +// @Tags [VM management] +// @Accept json +// @Produce json +// @Param ConnectionName query string true "The name of the Connection to list VMs for" +// @Success 200 {object} VMListResponse "List of VMs" +// @Failure 400 {object} SimpleMsg "Bad Request, possibly due to invalid query parameter" +// @Failure 404 {object} SimpleMsg "Resource Not Found" +// @Failure 500 {object} SimpleMsg "Internal Server Error" +// @Router /vm [get] func ListVM(c echo.Context) error { cblog.Info("call ListVM()") - var req struct { - ConnectionName string - } + var req ConnectionRequest if err := c.Bind(&req); err != nil { return echo.NewHTTPError(http.StatusInternalServerError, err.Error()) @@ -205,24 +278,30 @@ func ListVM(c echo.Context) error { return echo.NewHTTPError(http.StatusInternalServerError, err.Error()) } - var jsonResult struct { - Result []*cres.VMInfo `json:"vm"` + jsonResult := VMListResponse{ + VMs: result, } - jsonResult.Result = result return c.JSON(http.StatusOK, &jsonResult) } -// list all VMs for management -// (1) get args from REST Call -// (2) get all VM List by common-runtime API -// (3) return REST Json Format +// listAllVM godoc +// @ID list-all-vm +// @Summary List All VMs +// @Description Retrieve a list of all Virtual Machines (VMs) across all connections. +// @Tags [VM management] +// @Accept json +// @Produce json +// @Param ConnectionName query string true "The name of the Connection" +// @Success 200 {object} AllResourceListResponse "List of all VMs with their respective lists" +// @Failure 400 {object} SimpleMsg "Bad Request, possibly due to invalid JSON structure or missing fields" +// @Failure 404 {object} SimpleMsg "Resource Not Found" +// @Failure 500 {object} SimpleMsg "Internal Server Error" +// @Router /allvm [get] func ListAllVM(c echo.Context) error { cblog.Info("call ListAllVM()") - var req struct { - ConnectionName string - } + var req ConnectionRequest if err := c.Bind(&req); err != nil { return echo.NewHTTPError(http.StatusInternalServerError, err.Error()) @@ -242,12 +321,24 @@ func ListAllVM(c echo.Context) error { return c.JSON(http.StatusOK, &allResourceList) } +// getVM godoc +// @ID get-vm +// @Summary Get VM +// @Description Retrieve details of a specific Virtual Machine (VM). +// @Tags [VM management] +// @Accept json +// @Produce json +// @Param ConnectionName query string true "The name of the Connection to get a VM for" +// @Param Name path string true "The name of the VM to retrieve" +// @Success 200 {object} cres.VMInfo "Details of the VM" +// @Failure 400 {object} SimpleMsg "Bad Request, possibly due to invalid JSON structure or missing fields" +// @Failure 404 {object} SimpleMsg "Resource Not Found" +// @Failure 500 {object} SimpleMsg "Internal Server Error" +// @Router /vm/{Name} [get] func GetVM(c echo.Context) error { cblog.Info("call GetVM()") - var req struct { - ConnectionName string - } + var req ConnectionRequest if err := c.Bind(&req); err != nil { return echo.NewHTTPError(http.StatusInternalServerError, err.Error()) @@ -267,12 +358,24 @@ func GetVM(c echo.Context) error { return c.JSON(http.StatusOK, result) } +// getCSPVM godoc +// @ID get-csp-vm +// @Summary Get CSP VM +// @Description Retrieve details of a specific CSP Virtual Machine (VM). +// @Tags [VM management] +// @Accept json +// @Produce json +// @Param ConnectionName query string true "The name of the Connection to get a CSP VM for" +// @Param Id path string true "The CSP VM ID to retrieve" +// @Success 200 {object} cres.VMInfo "Details of the CSP VM" +// @Failure 400 {object} SimpleMsg "Bad Request, possibly due to invalid JSON structure or missing fields" +// @Failure 404 {object} SimpleMsg "Resource Not Found" +// @Failure 500 {object} SimpleMsg "Internal Server Error" +// @Router /cspvm/{Id} [get] func GetCSPVM(c echo.Context) error { cblog.Info("call GetCSPVM()") - var req struct { - ConnectionName string - } + var req ConnectionRequest if err := c.Bind(&req); err != nil { return echo.NewHTTPError(http.StatusInternalServerError, err.Error()) @@ -292,15 +395,25 @@ func GetCSPVM(c echo.Context) error { return c.JSON(http.StatusOK, result) } -// (1) get args from REST Call -// (2) call common-runtime API -// (3) return REST Json Format +// terminateVM godoc +// @ID terminate-vm +// @Summary Terminate VM +// @Description Terminate a specified Virtual Machine (VM). +// @Tags [VM management] +// @Accept json +// @Produce json +// @Param ConnectionRequest body restruntime.ConnectionRequest true "Request body for terminating a VM" +// @Param Name path string true "The name of the VM to terminate" +// @Param force query string false "Force terminate the VM" +// @Success 200 {object} StatusInfo "Result of the terminate operation" +// @Failure 400 {object} SimpleMsg "Bad Request, possibly due to invalid JSON structure or missing fields" +// @Failure 404 {object} SimpleMsg "Resource Not Found" +// @Failure 500 {object} SimpleMsg "Internal Server Error" +// @Router /vm/{Name} [delete] func TerminateVM(c echo.Context) error { cblog.Info("call TerminateVM()") - var req struct { - ConnectionName string - } + var req ConnectionRequest if err := c.Bind(&req); err != nil { return echo.NewHTTPError(http.StatusInternalServerError, err.Error()) @@ -319,15 +432,24 @@ func TerminateVM(c echo.Context) error { return c.JSON(http.StatusOK, &resultInfo) } -// (1) get args from REST Call -// (2) call common-runtime API -// (3) return REST Json Format +// terminateCSPVM godoc +// @ID terminate-csp-vm +// @Summary Terminate CSP VM +// @Description Terminate a specified CSP Virtual Machine (VM). +// @Tags [VM management] +// @Accept json +// @Produce json +// @Param ConnectionRequest body restruntime.ConnectionRequest true "Request body for terminating a CSP VM" +// @Param Id path string true "The CSP VM ID to terminate" +// @Success 200 {object} StatusInfo "Result of the terminate operation" +// @Failure 400 {object} SimpleMsg "Bad Request, possibly due to invalid JSON structure or missing fields" +// @Failure 404 {object} SimpleMsg "Resource Not Found" +// @Failure 500 {object} SimpleMsg "Internal Server Error" +// @Router /cspvm/{Id} [delete] func TerminateCSPVM(c echo.Context) error { cblog.Info("call TerminateCSPVM()") - var req struct { - ConnectionName string - } + var req ConnectionRequest if err := c.Bind(&req); err != nil { return echo.NewHTTPError(http.StatusInternalServerError, err.Error()) @@ -346,12 +468,28 @@ func TerminateCSPVM(c echo.Context) error { return c.JSON(http.StatusOK, &resultInfo) } +// VMStatusResponse represents the response body structure for VM status APIs. +type VMStatusResponse struct { + Status string `json:"Status" validate:"required" example:"Running"` // Creating,Running,Suspending,Suspended,Resuming,Rebooting,Terminating,Terminated,NotExist,Failed +} + +// listVMStatus godoc +// @ID list-vm-status +// @Summary List VM Statuses +// @Description Retrieve a list of statuses for Virtual Machines (VMs) associated with a specific connection. +// @Tags [VM management] +// @Accept json +// @Produce json +// @Param ConnectionName query string true "The name of the Connection to list VM statuses for" +// @Success 200 {object} VMStatusResponse "List of VM statuses" +// @Failure 400 {object} SimpleMsg "Bad Request, possibly due to invalid query parameter" +// @Failure 404 {object} SimpleMsg "Resource Not Found" +// @Failure 500 {object} SimpleMsg "Internal Server Error" +// @Router /vmstatus [get] func ListVMStatus(c echo.Context) error { cblog.Info("call ListVMStatus()") - var req struct { - ConnectionName string - } + var req ConnectionRequest if err := c.Bind(&req); err != nil { return echo.NewHTTPError(http.StatusInternalServerError, err.Error()) @@ -376,12 +514,24 @@ func ListVMStatus(c echo.Context) error { return c.JSON(http.StatusOK, &jsonResult) } +// getVMStatus godoc +// @ID get-vm-status +// @Summary Get VM Status +// @Description Retrieve the status of a specific Virtual Machine (VM). +// @Tags [VM management] +// @Accept json +// @Produce json +// @Param ConnectionName query string true "The name of the Connection to get a VM status for" +// @Param Name path string true "The name of the VM to retrieve the status of" +// @Success 200 {object} VMStatusResponse "Details of the VM status" +// @Failure 400 {object} SimpleMsg "Bad Request, possibly due to invalid JSON structure or missing fields" +// @Failure 404 {object} SimpleMsg "Resource Not Found" +// @Failure 500 {object} SimpleMsg "Internal Server Error" +// @Router /vmstatus/{Name} [get] func GetVMStatus(c echo.Context) error { cblog.Info("call GetVMStatus()") - var req struct { - ConnectionName string - } + var req ConnectionRequest if err := c.Bind(&req); err != nil { return echo.NewHTTPError(http.StatusInternalServerError, err.Error()) @@ -398,19 +548,32 @@ func GetVMStatus(c echo.Context) error { return echo.NewHTTPError(http.StatusInternalServerError, err.Error()) } - resultInfo := StatusInfo{ + resultInfo := VMStatusResponse{ Status: string(result), } return c.JSON(http.StatusOK, &resultInfo) } +// controlVM godoc +// @ID control-vm +// @Summary Control VM +// @Description Control the state of a Virtual Machine (VM) such as suspend, resume, or reboot. +// @Tags [VM management] +// @Accept json +// @Produce json +// @Param ConnectionRequest body restruntime.ConnectionRequest true "Request body for controlling a VM" +// @Param Name path string true "The name of the VM to control" +// @Param action query string true "The action to perform on the VM (suspend, resume, reboot)" +// @Success 200 {object} VMStatusResponse "Result of the control operation" +// @Failure 400 {object} SimpleMsg "Bad Request, possibly due to invalid JSON structure or missing fields" +// @Failure 404 {object} SimpleMsg "Resource Not Found" +// @Failure 500 {object} SimpleMsg "Internal Server Error" +// @Router /controlvm/{Name} [put] func ControlVM(c echo.Context) error { cblog.Info("call ControlVM()") - var req struct { - ConnectionName string - } + var req ConnectionRequest if err := c.Bind(&req); err != nil { return echo.NewHTTPError(http.StatusInternalServerError, err.Error()) @@ -427,13 +590,22 @@ func ControlVM(c echo.Context) error { return echo.NewHTTPError(http.StatusInternalServerError, err.Error()) } - resultInfo := StatusInfo{ + resultInfo := VMStatusResponse{ Status: string(result), } return c.JSON(http.StatusOK, &resultInfo) } +// countAllVMs godoc +// @ID count-all-vms +// @Summary Count All VMs +// @Description Get the total number of Virtual Machines (VMs) across all connections. +// @Tags [VM management] +// @Produce json +// @Success 200 {object} CountResponse "Total count of VMs" +// @Failure 500 {object} SimpleMsg "Internal Server Error" +// @Router /countvm [get] func CountAllVMs(c echo.Context) error { // Call common-runtime API to get count of VMs count, err := cmrt.CountAllVMs() @@ -442,15 +614,24 @@ func CountAllVMs(c echo.Context) error { } // Prepare JSON result - var jsonResult struct { - Count int `json:"count"` + jsonResult := CountResponse{ + Count: int(count), } - jsonResult.Count = int(count) // Return JSON response return c.JSON(http.StatusOK, jsonResult) } +// countVMsByConnection godoc +// @ID count-vms-by-connection +// @Summary Count VMs by Connection +// @Description Get the total number of Virtual Machines (VMs) for a specific connection. +// @Tags [VM management] +// @Produce json +// @Param ConnectionName path string true "The name of the Connection" +// @Success 200 {object} CountResponse "Total count of VMs for the connection" +// @Failure 500 {object} SimpleMsg "Internal Server Error" +// @Router /countvm/{ConnectionName} [get] func CountVMsByConnection(c echo.Context) error { // Call common-runtime API to get count of VMs count, err := cmrt.CountVMsByConnection(c.Param("ConnectionName")) @@ -459,10 +640,9 @@ func CountVMsByConnection(c echo.Context) error { } // Prepare JSON result - var jsonResult struct { - Count int `json:"count"` + jsonResult := CountResponse{ + Count: int(count), } - jsonResult.Count = int(count) // Return JSON response return c.JSON(http.StatusOK, jsonResult) diff --git a/api-runtime/rest-runtime/VPC-SubnetRest.go b/api-runtime/rest-runtime/VPC-SubnetRest.go index 08e41c913..809183b98 100644 --- a/api-runtime/rest-runtime/VPC-SubnetRest.go +++ b/api-runtime/rest-runtime/VPC-SubnetRest.go @@ -155,11 +155,6 @@ func UnregisterSubnet(c echo.Context) error { return c.JSON(http.StatusOK, &resultInfo) } -// ConnectionRequest represents the request body for common use. -type ConnectionRequest struct { - ConnectionName string `json:"ConnectionName" validate:"required" example:"aws-connection"` -} - // unregisterVPC godoc // @ID unregister-vpc // @Summary Unregister VPC @@ -205,7 +200,7 @@ type CreateVPCRequest struct { IPv4_CIDR string `json:"IPv4_CIDR" validate:"omitempty"` // Some CSPs unsupported VPC CIDR SubnetInfoList []struct { Name string `json:"Name" validate:"required" example:"subnet-01"` - Zone string `json:"Zone,omitempty" validate:"omitempty"` + Zone string `json:"Zone,omitempty" validate:"omitempty" example:"us-east-1b"` // target zone for the subnet, if not specified, it will be created in the same zone as the Connection. IPv4_CIDR string `json:"IPv4_CIDR" validate:"required" example:"10.0.8.0/22"` TagList []cres.KeyValue `json:"TagList,omitempty" validate:"omitempty"` } `json:"SubnetInfoList" validate:"required"` @@ -355,7 +350,7 @@ type AddSubnetRequest struct { IDTransformMode string `json:"IDTransformMode,omitempty" validate:"omitempty" example:"ON"` // ON: transform CSP ID, OFF: no-transform CSP ID ReqInfo struct { Name string `json:"Name" validate:"required" example:"subnet-01"` - Zone string `json:"Zone,omitempty" validate:"omitempty" example:"us-east-1a"` + Zone string `json:"Zone,omitempty" validate:"omitempty" example:"us-east-1b"` // target zone for the subnet, if not specified, it will be created in the same zone as the Connection. IPv4_CIDR string `json:"IPv4_CIDR" validate:"required" example:"10.0.12.0/22"` TagList []cres.KeyValue `json:"TagList,omitempty" validate:"omitempty"` } `json:"ReqInfo" validate:"required"` diff --git a/api/docs.go b/api/docs.go index d7a93f506..e73a86bd0 100644 --- a/api/docs.go +++ b/api/docs.go @@ -125,6 +125,57 @@ const docTemplate = `{ } } }, + "/allvm": { + "get": { + "description": "Retrieve a list of all Virtual Machines (VMs) across all connections.", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "[VM management]" + ], + "summary": "List All VMs", + "operationId": "list-all-vm", + "parameters": [ + { + "type": "string", + "description": "The name of the Connection", + "name": "ConnectionName", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "List of all VMs with their respective lists", + "schema": { + "$ref": "#/definitions/spider.AllResourceListResponse" + } + }, + "400": { + "description": "Bad Request, possibly due to invalid JSON structure or missing fields", + "schema": { + "$ref": "#/definitions/spider.SimpleMsg" + } + }, + "404": { + "description": "Resource Not Found", + "schema": { + "$ref": "#/definitions/spider.SimpleMsg" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/spider.SimpleMsg" + } + } + } + } + }, "/allvpc": { "get": { "description": "Retrieve a list of all Virtual Private Clouds (VPCs) across all connections.", @@ -176,6 +227,73 @@ const docTemplate = `{ } } }, + "/controlvm/{Name}": { + "put": { + "description": "Control the state of a Virtual Machine (VM) such as suspend, resume, or reboot.", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "[VM management]" + ], + "summary": "Control VM", + "operationId": "control-vm", + "parameters": [ + { + "description": "Request body for controlling a VM", + "name": "ConnectionRequest", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/spider.ConnectionRequest" + } + }, + { + "type": "string", + "description": "The name of the VM to control", + "name": "Name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "The action to perform on the VM (suspend, resume, reboot)", + "name": "action", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "Result of the control operation", + "schema": { + "$ref": "#/definitions/spider.VMStatusResponse" + } + }, + "400": { + "description": "Bad Request, possibly due to invalid JSON structure or missing fields", + "schema": { + "$ref": "#/definitions/spider.SimpleMsg" + } + }, + "404": { + "description": "Resource Not Found", + "schema": { + "$ref": "#/definitions/spider.SimpleMsg" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/spider.SimpleMsg" + } + } + } + } + }, "/countkeypair": { "get": { "description": "Get the total number of KeyPairs across all connections.", @@ -365,6 +483,69 @@ const docTemplate = `{ } } }, + "/countvm": { + "get": { + "description": "Get the total number of Virtual Machines (VMs) across all connections.", + "produces": [ + "application/json" + ], + "tags": [ + "[VM management]" + ], + "summary": "Count All VMs", + "operationId": "count-all-vms", + "responses": { + "200": { + "description": "Total count of VMs", + "schema": { + "$ref": "#/definitions/spider.CountResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/spider.SimpleMsg" + } + } + } + } + }, + "/countvm/{ConnectionName}": { + "get": { + "description": "Get the total number of Virtual Machines (VMs) for a specific connection.", + "produces": [ + "application/json" + ], + "tags": [ + "[VM management]" + ], + "summary": "Count VMs by Connection", + "operationId": "count-vms-by-connection", + "parameters": [ + { + "type": "string", + "description": "The name of the Connection", + "name": "ConnectionName", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Total count of VMs for the connection", + "schema": { + "$ref": "#/definitions/spider.CountResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/spider.SimpleMsg" + } + } + } + } + }, "/countvpc": { "get": { "description": "Get the total number of VPCs across all connections.", @@ -548,9 +729,9 @@ const docTemplate = `{ } } }, - "/cspvpc/{Id}": { - "delete": { - "description": "Delete a specified CSP Virtual Private Cloud (VPC).", + "/cspvm/{Id}": { + "get": { + "description": "Retrieve details of a specific CSP Virtual Machine (VM).", "consumes": [ "application/json" ], @@ -558,23 +739,21 @@ const docTemplate = `{ "application/json" ], "tags": [ - "[VPC management]" + "[VM management]" ], - "summary": "Delete CSP VPC", - "operationId": "delete-csp-vpc", + "summary": "Get CSP VM", + "operationId": "get-csp-vm", "parameters": [ { - "description": "Request body for deleting a CSP VPC", - "name": "ConnectionRequest", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/spider.ConnectionRequest" - } + "type": "string", + "description": "The name of the Connection to get a CSP VM for", + "name": "ConnectionName", + "in": "query", + "required": true }, { "type": "string", - "description": "The CSP VPC ID to delete", + "description": "The CSP VM ID to retrieve", "name": "Id", "in": "path", "required": true @@ -582,9 +761,9 @@ const docTemplate = `{ ], "responses": { "200": { - "description": "Result of the delete operation", + "description": "Details of the CSP VM", "schema": { - "$ref": "#/definitions/spider.BooleanInfo" + "$ref": "#/definitions/spider.VMInfo" } }, "400": { @@ -606,11 +785,9 @@ const docTemplate = `{ } } } - } - }, - "/getsecuritygroupowner": { - "post": { - "description": "Retrieve the owner VPC of a specified Security Group.", + }, + "delete": { + "description": "Terminate a specified CSP Virtual Machine (VM).", "consumes": [ "application/json" ], @@ -618,26 +795,33 @@ const docTemplate = `{ "application/json" ], "tags": [ - "[VPC management]" + "[VM management]" ], - "summary": "Get Security Group Owner VPC", - "operationId": "get-sg-owner-vpc", + "summary": "Terminate CSP VM", + "operationId": "terminate-csp-vm", "parameters": [ { - "description": "Request body for getting Security Group Owner VPC", - "name": "GetSGOwnerVPCRequest", + "description": "Request body for terminating a CSP VM", + "name": "ConnectionRequest", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/spider.GetSGOwnerVPCRequest" + "$ref": "#/definitions/spider.ConnectionRequest" } + }, + { + "type": "string", + "description": "The CSP VM ID to terminate", + "name": "Id", + "in": "path", + "required": true } ], "responses": { "200": { - "description": "Details of the owner VPC", + "description": "Result of the terminate operation", "schema": { - "$ref": "#/definitions/spider.IID" + "$ref": "#/definitions/spider.StatusInfo" } }, "400": { @@ -661,9 +845,9 @@ const docTemplate = `{ } } }, - "/keypair": { - "get": { - "description": "Retrieve a list of KeyPairs associated with a specific connection.", + "/cspvpc/{Id}": { + "delete": { + "description": "Delete a specified CSP Virtual Private Cloud (VPC).", "consumes": [ "application/json" ], @@ -671,28 +855,37 @@ const docTemplate = `{ "application/json" ], "tags": [ - "[KeyPair management]" + "[VPC management]" ], - "summary": "List KeyPairs", - "operationId": "list-key", + "summary": "Delete CSP VPC", + "operationId": "delete-csp-vpc", "parameters": [ + { + "description": "Request body for deleting a CSP VPC", + "name": "ConnectionRequest", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/spider.ConnectionRequest" + } + }, { "type": "string", - "description": "The name of the Connection to list KeyPairs for", - "name": "ConnectionName", - "in": "query", + "description": "The CSP VPC ID to delete", + "name": "Id", + "in": "path", "required": true } ], "responses": { "200": { - "description": "List of KeyPairs", + "description": "Result of the delete operation", "schema": { - "$ref": "#/definitions/spider.KeyListResponse" + "$ref": "#/definitions/spider.BooleanInfo" } }, "400": { - "description": "Bad Request, possibly due to invalid query parameter", + "description": "Bad Request, possibly due to invalid JSON structure or missing fields", "schema": { "$ref": "#/definitions/spider.SimpleMsg" } @@ -710,9 +903,11 @@ const docTemplate = `{ } } } - }, + } + }, + "/getsecuritygroupowner": { "post": { - "description": "Create a new KeyPair with the specified configurations.", + "description": "Retrieve the owner VPC of a specified Security Group.", "consumes": [ "application/json" ], @@ -720,26 +915,26 @@ const docTemplate = `{ "application/json" ], "tags": [ - "[KeyPair management]" + "[VPC management]" ], - "summary": "Create KeyPair", - "operationId": "create-key", + "summary": "Get Security Group Owner VPC", + "operationId": "get-sg-owner-vpc", "parameters": [ { - "description": "Request body for creating a KeyPair", - "name": "KeyCreateRequest", + "description": "Request body for getting Security Group Owner VPC", + "name": "GetSGOwnerVPCRequest", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/spider.KeyCreateRequest" + "$ref": "#/definitions/spider.GetSGOwnerVPCRequest" } } ], "responses": { "200": { - "description": "Details of the created KeyPair", + "description": "Details of the owner VPC", "schema": { - "$ref": "#/definitions/spider.KeyPairInfo" + "$ref": "#/definitions/spider.IID" } }, "400": { @@ -763,9 +958,9 @@ const docTemplate = `{ } } }, - "/keypair/{Name}": { + "/getvmusingresources": { "get": { - "description": "Retrieve details of a specific KeyPair.", + "description": "Retrieve details of a VM using resource ID.", "consumes": [ "application/json" ], @@ -773,14 +968,174 @@ const docTemplate = `{ "application/json" ], "tags": [ - "[KeyPair management]" + "[VM management]" ], - "summary": "Get KeyPair", - "operationId": "get-key", + "summary": "Get VM Using Resource", + "operationId": "get-vm-using-rs", "parameters": [ { "type": "string", - "description": "The name of the Connection to get a KeyPair for", + "description": "Connection name for the VM", + "name": "ConnectionName", + "in": "query", + "required": true + }, + { + "type": "string", + "description": "CSP ID of the VM", + "name": "CSPId", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "Details of the VM using resource", + "schema": { + "$ref": "#/definitions/spider.VMUsingResources" + } + }, + "400": { + "description": "Bad Request, possibly due to invalid query parameters", + "schema": { + "$ref": "#/definitions/spider.SimpleMsg" + } + }, + "404": { + "description": "Resource Not Found", + "schema": { + "$ref": "#/definitions/spider.SimpleMsg" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/spider.SimpleMsg" + } + } + } + } + }, + "/keypair": { + "get": { + "description": "Retrieve a list of KeyPairs associated with a specific connection.", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "[KeyPair management]" + ], + "summary": "List KeyPairs", + "operationId": "list-key", + "parameters": [ + { + "type": "string", + "description": "The name of the Connection to list KeyPairs for", + "name": "ConnectionName", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "List of KeyPairs", + "schema": { + "$ref": "#/definitions/spider.KeyListResponse" + } + }, + "400": { + "description": "Bad Request, possibly due to invalid query parameter", + "schema": { + "$ref": "#/definitions/spider.SimpleMsg" + } + }, + "404": { + "description": "Resource Not Found", + "schema": { + "$ref": "#/definitions/spider.SimpleMsg" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/spider.SimpleMsg" + } + } + } + }, + "post": { + "description": "Create a new KeyPair with the specified configurations.", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "[KeyPair management]" + ], + "summary": "Create KeyPair", + "operationId": "create-key", + "parameters": [ + { + "description": "Request body for creating a KeyPair", + "name": "KeyCreateRequest", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/spider.KeyCreateRequest" + } + } + ], + "responses": { + "200": { + "description": "Details of the created KeyPair", + "schema": { + "$ref": "#/definitions/spider.KeyPairInfo" + } + }, + "400": { + "description": "Bad Request, possibly due to invalid JSON structure or missing fields", + "schema": { + "$ref": "#/definitions/spider.SimpleMsg" + } + }, + "404": { + "description": "Resource Not Found", + "schema": { + "$ref": "#/definitions/spider.SimpleMsg" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/spider.SimpleMsg" + } + } + } + } + }, + "/keypair/{Name}": { + "get": { + "description": "Retrieve details of a specific KeyPair.", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "[KeyPair management]" + ], + "summary": "Get KeyPair", + "operationId": "get-key", + "parameters": [ + { + "type": "string", + "description": "The name of the Connection to get a KeyPair for", "name": "ConnectionName", "in": "query", "required": true @@ -1049,11 +1404,459 @@ const docTemplate = `{ } } } - } - }, - "/regsecuritygroup/{Name}": { - "delete": { - "description": "Unregister a Security Group with the specified name.", + } + }, + "/regsecuritygroup/{Name}": { + "delete": { + "description": "Unregister a Security Group with the specified name.", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "[SecurityGroup management]" + ], + "summary": "Unregister SecurityGroup", + "operationId": "unregister-securitygroup", + "parameters": [ + { + "description": "Request body for unregistering a SecurityGroup", + "name": "ConnectionRequest", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/spider.ConnectionRequest" + } + }, + { + "type": "string", + "description": "The name of the SecurityGroup to unregister", + "name": "Name", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Result of the unregister operation", + "schema": { + "$ref": "#/definitions/spider.BooleanInfo" + } + }, + "400": { + "description": "Bad Request, possibly due to invalid JSON structure or missing fields", + "schema": { + "$ref": "#/definitions/spider.SimpleMsg" + } + }, + "404": { + "description": "Resource Not Found", + "schema": { + "$ref": "#/definitions/spider.SimpleMsg" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/spider.SimpleMsg" + } + } + } + } + }, + "/regsubnet": { + "post": { + "description": "Register a new Subnet within a specified VPC.", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "[VPC management]" + ], + "summary": "Register Subnet", + "operationId": "register-subnet", + "parameters": [ + { + "description": "Request body for registering a Subnet", + "name": "SubnetRegisterRequest", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/spider.SubnetRegisterRequest" + } + } + ], + "responses": { + "200": { + "description": "Details of the registered Subnet", + "schema": { + "$ref": "#/definitions/spider.SubnetInfo" + } + }, + "400": { + "description": "Bad Request, possibly due to invalid JSON structure or missing fields", + "schema": { + "$ref": "#/definitions/spider.SimpleMsg" + } + }, + "404": { + "description": "Resource Not Found", + "schema": { + "$ref": "#/definitions/spider.SimpleMsg" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/spider.SimpleMsg" + } + } + } + } + }, + "/regsubnet/{Name}": { + "delete": { + "description": "Unregister a Subnet from a specified VPC.", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "[VPC management]" + ], + "summary": "Unregister Subnet", + "operationId": "unregister-subnet", + "parameters": [ + { + "description": "Request body for unregistering a Subnet", + "name": "SubnetUnregisterRequest", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/spider.SubnetUnregisterRequest" + } + }, + { + "type": "string", + "description": "The name of the Subnet to unregister", + "name": "Name", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Result of the unregister operation", + "schema": { + "$ref": "#/definitions/spider.BooleanInfo" + } + }, + "400": { + "description": "Bad Request, possibly due to invalid JSON structure or missing fields", + "schema": { + "$ref": "#/definitions/spider.SimpleMsg" + } + }, + "404": { + "description": "Resource Not Found", + "schema": { + "$ref": "#/definitions/spider.SimpleMsg" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/spider.SimpleMsg" + } + } + } + } + }, + "/regvm": { + "post": { + "description": "Register a new Virtual Machine (VM) with the specified name and CSP ID.", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "[VM management]" + ], + "summary": "Register VM", + "operationId": "register-vm", + "parameters": [ + { + "description": "Request body for registering a VM", + "name": "VMRegisterRequest", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/spider.VMRegisterRequest" + } + } + ], + "responses": { + "200": { + "description": "Details of the registered VM", + "schema": { + "$ref": "#/definitions/spider.VMInfo" + } + }, + "400": { + "description": "Bad Request, possibly due to invalid JSON structure or missing fields", + "schema": { + "$ref": "#/definitions/spider.SimpleMsg" + } + }, + "404": { + "description": "Resource Not Found", + "schema": { + "$ref": "#/definitions/spider.SimpleMsg" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/spider.SimpleMsg" + } + } + } + } + }, + "/regvm/{Name}": { + "delete": { + "description": "Unregister a Virtual Machine (VM) with the specified name.", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "[VM management]" + ], + "summary": "Unregister VM", + "operationId": "unregister-vm", + "parameters": [ + { + "description": "Request body for unregistering a VM", + "name": "ConnectionRequest", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/spider.ConnectionRequest" + } + }, + { + "type": "string", + "description": "The name of the VM to unregister", + "name": "Name", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Result of the unregister operation", + "schema": { + "$ref": "#/definitions/spider.BooleanInfo" + } + }, + "400": { + "description": "Bad Request, possibly due to invalid JSON structure or missing fields", + "schema": { + "$ref": "#/definitions/spider.SimpleMsg" + } + }, + "404": { + "description": "Resource Not Found", + "schema": { + "$ref": "#/definitions/spider.SimpleMsg" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/spider.SimpleMsg" + } + } + } + } + }, + "/regvpc": { + "post": { + "description": "Register a new Virtual Private Cloud (VPC) with the specified name and CSP ID.", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "[VPC management]" + ], + "summary": "Register VPC", + "operationId": "register-vpc", + "parameters": [ + { + "description": "Request body for registering a VPC", + "name": "VPCRegisterRequest", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/spider.VPCRegisterRequest" + } + } + ], + "responses": { + "200": { + "description": "Details of the registered VPC", + "schema": { + "$ref": "#/definitions/spider.VPCInfo" + } + }, + "400": { + "description": "Bad Request, possibly due to invalid JSON structure or missing fields", + "schema": { + "$ref": "#/definitions/spider.SimpleMsg" + } + }, + "404": { + "description": "Resource Not Found", + "schema": { + "$ref": "#/definitions/spider.SimpleMsg" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/spider.SimpleMsg" + } + } + } + } + }, + "/regvpc/{Name}": { + "delete": { + "description": "Unregister a VPC with the specified name.", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "[VPC management]" + ], + "summary": "Unregister VPC", + "operationId": "unregister-vpc", + "parameters": [ + { + "description": "Request body for unregistering a VPC", + "name": "ConnectionRequest", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/spider.ConnectionRequest" + } + }, + { + "type": "string", + "description": "The name of the VPC to unregister", + "name": "Name", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Result of the unregister operation", + "schema": { + "$ref": "#/definitions/spider.BooleanInfo" + } + }, + "400": { + "description": "Bad Request, possibly due to invalid JSON structure or missing fields", + "schema": { + "$ref": "#/definitions/spider.SimpleMsg" + } + }, + "404": { + "description": "Resource Not Found", + "schema": { + "$ref": "#/definitions/spider.SimpleMsg" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/spider.SimpleMsg" + } + } + } + } + }, + "/securitygroup": { + "get": { + "description": "Retrieve a list of Security Groups associated with a specific connection.", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "[SecurityGroup management]" + ], + "summary": "List SecurityGroups", + "operationId": "list-securitygroup", + "parameters": [ + { + "type": "string", + "description": "The name of the Connection to list SecurityGroups for", + "name": "ConnectionName", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "List of SecurityGroups", + "schema": { + "$ref": "#/definitions/spider.ListSecurityResponse" + } + }, + "400": { + "description": "Bad Request, possibly due to invalid query parameter", + "schema": { + "$ref": "#/definitions/spider.SimpleMsg" + } + }, + "404": { + "description": "Resource Not Found", + "schema": { + "$ref": "#/definitions/spider.SimpleMsg" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/spider.SimpleMsg" + } + } + } + }, + "post": { + "description": "Create a new Security Group with specified rules and tags.", "consumes": [ "application/json" ], @@ -1063,31 +1866,24 @@ const docTemplate = `{ "tags": [ "[SecurityGroup management]" ], - "summary": "Unregister SecurityGroup", - "operationId": "unregister-securitygroup", + "summary": "Create SecurityGroup", + "operationId": "create-securitygroup", "parameters": [ { - "description": "Request body for unregistering a SecurityGroup", - "name": "ConnectionRequest", + "description": "Request body for creating a SecurityGroup", + "name": "SecurityGroupCreateRequest", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/spider.ConnectionRequest" + "$ref": "#/definitions/spider.SecurityGroupCreateRequest" } - }, - { - "type": "string", - "description": "The name of the SecurityGroup to unregister", - "name": "Name", - "in": "path", - "required": true } ], "responses": { "200": { - "description": "Result of the unregister operation", + "description": "Details of the created SecurityGroup", "schema": { - "$ref": "#/definitions/spider.BooleanInfo" + "$ref": "#/definitions/spider.SecurityInfo" } }, "400": { @@ -1111,9 +1907,9 @@ const docTemplate = `{ } } }, - "/regsubnet": { - "post": { - "description": "Register a new Subnet within a specified VPC.", + "/securitygroup/{Name}": { + "get": { + "description": "Retrieve details of a specific Security Group.", "consumes": [ "application/json" ], @@ -1121,26 +1917,31 @@ const docTemplate = `{ "application/json" ], "tags": [ - "[VPC management]" + "[SecurityGroup management]" ], - "summary": "Register Subnet", - "operationId": "register-subnet", + "summary": "Get SecurityGroup", + "operationId": "get-securitygroup", "parameters": [ { - "description": "Request body for registering a Subnet", - "name": "SubnetRegisterRequest", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/spider.SubnetRegisterRequest" - } + "type": "string", + "description": "The name of the Connection to get a SecurityGroup for", + "name": "ConnectionName", + "in": "query", + "required": true + }, + { + "type": "string", + "description": "The name of the SecurityGroup to retrieve", + "name": "Name", + "in": "path", + "required": true } ], "responses": { "200": { - "description": "Details of the registered Subnet", + "description": "Details of the SecurityGroup", "schema": { - "$ref": "#/definitions/spider.SubnetInfo" + "$ref": "#/definitions/spider.SecurityInfo" } }, "400": { @@ -1162,11 +1963,9 @@ const docTemplate = `{ } } } - } - }, - "/regsubnet/{Name}": { + }, "delete": { - "description": "Unregister a Subnet from a specified VPC.", + "description": "Delete a specified Security Group.", "consumes": [ "application/json" ], @@ -1174,31 +1973,37 @@ const docTemplate = `{ "application/json" ], "tags": [ - "[VPC management]" + "[SecurityGroup management]" ], - "summary": "Unregister Subnet", - "operationId": "unregister-subnet", + "summary": "Delete SecurityGroup", + "operationId": "delete-securitygroup", "parameters": [ { - "description": "Request body for unregistering a Subnet", - "name": "SubnetUnregisterRequest", + "description": "Request body for deleting a SecurityGroup", + "name": "ConnectionRequest", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/spider.SubnetUnregisterRequest" + "$ref": "#/definitions/spider.ConnectionRequest" } }, { "type": "string", - "description": "The name of the Subnet to unregister", + "description": "The name of the SecurityGroup to delete", "name": "Name", "in": "path", "required": true + }, + { + "type": "string", + "description": "Force delete the SecurityGroup", + "name": "force", + "in": "query" } ], "responses": { "200": { - "description": "Result of the unregister operation", + "description": "Result of the delete operation", "schema": { "$ref": "#/definitions/spider.BooleanInfo" } @@ -1224,9 +2029,9 @@ const docTemplate = `{ } } }, - "/regvpc": { + "/securitygroup/{SGName}/rules": { "post": { - "description": "Register a new Virtual Private Cloud (VPC) with the specified name and CSP ID.", + "description": "Add new rules to a Security Group.", "consumes": [ "application/json" ], @@ -1234,26 +2039,33 @@ const docTemplate = `{ "application/json" ], "tags": [ - "[VPC management]" + "[SecurityGroup management]" ], - "summary": "Register VPC", - "operationId": "register-vpc", + "summary": "Add Rules to SecurityGroup", + "operationId": "add-rules-securitygroup", "parameters": [ { - "description": "Request body for registering a VPC", - "name": "VPCRegisterRequest", + "type": "string", + "description": "The name of the SecurityGroup to add rules to", + "name": "SGName", + "in": "path", + "required": true + }, + { + "description": "Request body for adding rules", + "name": "RuleControlRequest", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/spider.VPCRegisterRequest" + "$ref": "#/definitions/spider.RuleControlRequest" } } ], "responses": { "200": { - "description": "Details of the registered VPC", + "description": "Details of the SecurityGroup after adding rules", "schema": { - "$ref": "#/definitions/spider.VPCInfo" + "$ref": "#/definitions/spider.SecurityInfo" } }, "400": { @@ -1275,11 +2087,9 @@ const docTemplate = `{ } } } - } - }, - "/regvpc/{Name}": { + }, "delete": { - "description": "Unregister a VPC with the specified name.", + "description": "Remove existing rules from a Security Group.", "consumes": [ "application/json" ], @@ -1287,31 +2097,31 @@ const docTemplate = `{ "application/json" ], "tags": [ - "[VPC management]" + "[SecurityGroup management]" ], - "summary": "Unregister VPC", - "operationId": "unregister-vpc", + "summary": "Remove Rules from SecurityGroup", + "operationId": "remove-rules-securitygroup", "parameters": [ { - "description": "Request body for unregistering a VPC", - "name": "ConnectionRequest", + "type": "string", + "description": "The name of the SecurityGroup to remove rules from", + "name": "SGName", + "in": "path", + "required": true + }, + { + "description": "Request body for removing rules", + "name": "RuleControlRequest", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/spider.ConnectionRequest" + "$ref": "#/definitions/spider.RuleControlRequest" } - }, - { - "type": "string", - "description": "The name of the VPC to unregister", - "name": "Name", - "in": "path", - "required": true } ], "responses": { "200": { - "description": "Result of the unregister operation", + "description": "Result of the remove operation", "schema": { "$ref": "#/definitions/spider.BooleanInfo" } @@ -1337,9 +2147,9 @@ const docTemplate = `{ } } }, - "/securitygroup": { + "/vm": { "get": { - "description": "Retrieve a list of Security Groups associated with a specific connection.", + "description": "Retrieve a list of Virtual Machines (VMs) associated with a specific connection.", "consumes": [ "application/json" ], @@ -1347,14 +2157,14 @@ const docTemplate = `{ "application/json" ], "tags": [ - "[SecurityGroup management]" + "[VM management]" ], - "summary": "List SecurityGroups", - "operationId": "list-securitygroup", + "summary": "List VMs", + "operationId": "list-vm", "parameters": [ { "type": "string", - "description": "The name of the Connection to list SecurityGroups for", + "description": "The name of the Connection to list VMs for", "name": "ConnectionName", "in": "query", "required": true @@ -1362,9 +2172,9 @@ const docTemplate = `{ ], "responses": { "200": { - "description": "List of SecurityGroups", + "description": "List of VMs", "schema": { - "$ref": "#/definitions/spider.ListSecurityResponse" + "$ref": "#/definitions/spider.VMListResponse" } }, "400": { @@ -1388,7 +2198,7 @@ const docTemplate = `{ } }, "post": { - "description": "Create a new Security Group with specified rules and tags.", + "description": "Start a new Virtual Machine (VM) with specified configurations.", "consumes": [ "application/json" ], @@ -1396,26 +2206,26 @@ const docTemplate = `{ "application/json" ], "tags": [ - "[SecurityGroup management]" + "[VM management]" ], - "summary": "Create SecurityGroup", - "operationId": "create-securitygroup", + "summary": "Start VM", + "operationId": "start-vm", "parameters": [ { - "description": "Request body for creating a SecurityGroup", - "name": "SecurityGroupCreateRequest", + "description": "Request body for starting a VM", + "name": "VMStartRequest", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/spider.SecurityGroupCreateRequest" + "$ref": "#/definitions/spider.VMStartRequest" } } ], "responses": { "200": { - "description": "Details of the created SecurityGroup", + "description": "Details of the started VM", "schema": { - "$ref": "#/definitions/spider.SecurityInfo" + "$ref": "#/definitions/spider.VMInfo" } }, "400": { @@ -1439,9 +2249,9 @@ const docTemplate = `{ } } }, - "/securitygroup/{Name}": { + "/vm/{Name}": { "get": { - "description": "Retrieve details of a specific Security Group.", + "description": "Retrieve details of a specific Virtual Machine (VM).", "consumes": [ "application/json" ], @@ -1449,21 +2259,21 @@ const docTemplate = `{ "application/json" ], "tags": [ - "[SecurityGroup management]" + "[VM management]" ], - "summary": "Get SecurityGroup", - "operationId": "get-securitygroup", + "summary": "Get VM", + "operationId": "get-vm", "parameters": [ { "type": "string", - "description": "The name of the Connection to get a SecurityGroup for", + "description": "The name of the Connection to get a VM for", "name": "ConnectionName", "in": "query", "required": true }, { "type": "string", - "description": "The name of the SecurityGroup to retrieve", + "description": "The name of the VM to retrieve", "name": "Name", "in": "path", "required": true @@ -1471,9 +2281,9 @@ const docTemplate = `{ ], "responses": { "200": { - "description": "Details of the SecurityGroup", + "description": "Details of the VM", "schema": { - "$ref": "#/definitions/spider.SecurityInfo" + "$ref": "#/definitions/spider.VMInfo" } }, "400": { @@ -1497,7 +2307,7 @@ const docTemplate = `{ } }, "delete": { - "description": "Delete a specified Security Group.", + "description": "Terminate a specified Virtual Machine (VM).", "consumes": [ "application/json" ], @@ -1505,13 +2315,13 @@ const docTemplate = `{ "application/json" ], "tags": [ - "[SecurityGroup management]" + "[VM management]" ], - "summary": "Delete SecurityGroup", - "operationId": "delete-securitygroup", + "summary": "Terminate VM", + "operationId": "terminate-vm", "parameters": [ { - "description": "Request body for deleting a SecurityGroup", + "description": "Request body for terminating a VM", "name": "ConnectionRequest", "in": "body", "required": true, @@ -1521,23 +2331,23 @@ const docTemplate = `{ }, { "type": "string", - "description": "The name of the SecurityGroup to delete", + "description": "The name of the VM to terminate", "name": "Name", "in": "path", "required": true }, { "type": "string", - "description": "Force delete the SecurityGroup", + "description": "Force terminate the VM", "name": "force", "in": "query" } ], "responses": { "200": { - "description": "Result of the delete operation", + "description": "Result of the terminate operation", "schema": { - "$ref": "#/definitions/spider.BooleanInfo" + "$ref": "#/definitions/spider.StatusInfo" } }, "400": { @@ -1561,9 +2371,9 @@ const docTemplate = `{ } } }, - "/securitygroup/{SGName}/rules": { - "post": { - "description": "Add new rules to a Security Group.", + "/vmstatus": { + "get": { + "description": "Retrieve a list of statuses for Virtual Machines (VMs) associated with a specific connection.", "consumes": [ "application/json" ], @@ -1571,37 +2381,28 @@ const docTemplate = `{ "application/json" ], "tags": [ - "[SecurityGroup management]" + "[VM management]" ], - "summary": "Add Rules to SecurityGroup", - "operationId": "add-rules-securitygroup", + "summary": "List VM Statuses", + "operationId": "list-vm-status", "parameters": [ { "type": "string", - "description": "The name of the SecurityGroup to add rules to", - "name": "SGName", - "in": "path", + "description": "The name of the Connection to list VM statuses for", + "name": "ConnectionName", + "in": "query", "required": true - }, - { - "description": "Request body for adding rules", - "name": "RuleControlRequest", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/spider.RuleControlRequest" - } } ], "responses": { "200": { - "description": "Details of the SecurityGroup after adding rules", + "description": "List of VM statuses", "schema": { - "$ref": "#/definitions/spider.SecurityInfo" + "$ref": "#/definitions/spider.VMStatusResponse" } }, "400": { - "description": "Bad Request, possibly due to invalid JSON structure or missing fields", + "description": "Bad Request, possibly due to invalid query parameter", "schema": { "$ref": "#/definitions/spider.SimpleMsg" } @@ -1619,9 +2420,11 @@ const docTemplate = `{ } } } - }, - "delete": { - "description": "Remove existing rules from a Security Group.", + } + }, + "/vmstatus/{Name}": { + "get": { + "description": "Retrieve the status of a specific Virtual Machine (VM).", "consumes": [ "application/json" ], @@ -1629,33 +2432,31 @@ const docTemplate = `{ "application/json" ], "tags": [ - "[SecurityGroup management]" + "[VM management]" ], - "summary": "Remove Rules from SecurityGroup", - "operationId": "remove-rules-securitygroup", + "summary": "Get VM Status", + "operationId": "get-vm-status", "parameters": [ { "type": "string", - "description": "The name of the SecurityGroup to remove rules from", - "name": "SGName", - "in": "path", + "description": "The name of the Connection to get a VM status for", + "name": "ConnectionName", + "in": "query", "required": true }, { - "description": "Request body for removing rules", - "name": "RuleControlRequest", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/spider.RuleControlRequest" - } + "type": "string", + "description": "The name of the VM to retrieve the status of", + "name": "Name", + "in": "path", + "required": true } ], "responses": { "200": { - "description": "Result of the remove operation", + "description": "Details of the VM status", "schema": { - "$ref": "#/definitions/spider.BooleanInfo" + "$ref": "#/definitions/spider.VMStatusResponse" } }, "400": { @@ -2116,6 +2917,17 @@ const docTemplate = `{ } } }, + "spider.ImageType": { + "type": "string", + "enum": [ + "PublicImage", + "MyImage" + ], + "x-enum-varnames": [ + "PublicImage", + "MyImage" + ] + }, "spider.KeyPairInfo": { "type": "object", "required": [ @@ -2178,7 +2990,34 @@ const docTemplate = `{ }, "Value": { "type": "string", - "example": "value1" + "example": "value1" + } + } + }, + "spider.Platform": { + "type": "string", + "enum": [ + "LINUX/UNIX", + "WINDOWS" + ], + "x-enum-varnames": [ + "LINUX_UNIX", + "WINDOWS" + ] + }, + "spider.RegionInfo": { + "type": "object", + "required": [ + "Region" + ], + "properties": { + "Region": { + "type": "string", + "example": "us-east-1" + }, + "Zone": { + "type": "string", + "example": "us-east-1a" } } }, @@ -2300,6 +3139,202 @@ const docTemplate = `{ } } }, + "spider.VMInfo": { + "type": "object", + "required": [ + "AccessPoint", + "DataDiskIIDs", + "IId", + "ImageIId", + "ImageType", + "KeyPairIId", + "NetworkInterface", + "Platform", + "PrivateIP", + "PublicIP", + "Region", + "RootDeviceName", + "RootDiskSize", + "RootDiskType", + "SecurityGroupIIds", + "StartTime", + "SubnetIID", + "VMSpecName", + "VMUserId", + "VpcIID" + ], + "properties": { + "AccessPoint": { + "description": "10.2.3.2:22, 123.456.789.123:432", + "type": "string", + "example": "1.2.3.4:22" + }, + "DataDiskIIDs": { + "description": "example:\"[{NameId: 'datadisk-01', SystemId: 'datadisk-12345678'}]\"", + "type": "array", + "items": { + "$ref": "#/definitions/spider.IID" + } + }, + "IId": { + "description": "example:\"{NameId: 'vm-01', SystemId: 'i-12345678'}\"", + "allOf": [ + { + "$ref": "#/definitions/spider.IID" + } + ] + }, + "ImageIId": { + "description": "example:\"{NameId: 'ami-12345678', SystemId: 'ami-12345678'}\"", + "allOf": [ + { + "$ref": "#/definitions/spider.IID" + } + ] + }, + "ImageType": { + "description": "PublicImage | MyImage", + "allOf": [ + { + "$ref": "#/definitions/spider.ImageType" + } + ], + "example": "PublicImage" + }, + "KeyPairIId": { + "description": "example:\"{NameId: 'keypair-01', SystemId: 'keypair-12345678'}\"", + "allOf": [ + { + "$ref": "#/definitions/spider.IID" + } + ] + }, + "KeyValueList": { + "description": "example:\"[{Key: 'Architecture', Value: 'x86_64'}]\"", + "type": "array", + "items": { + "$ref": "#/definitions/spider.KeyValue" + } + }, + "NetworkInterface": { + "type": "string", + "example": "eni-12345678" + }, + "Platform": { + "description": "LINUX | WINDOWS", + "allOf": [ + { + "$ref": "#/definitions/spider.Platform" + } + ], + "example": "LINUX" + }, + "PrivateDNS": { + "type": "string", + "example": "ip-192-168-1-1.ec2.internal" + }, + "PrivateIP": { + "type": "string", + "example": "192.168.1.1" + }, + "PublicDNS": { + "type": "string", + "example": "ec2-1-2-3-4.compute-1.amazonaws.com" + }, + "PublicIP": { + "type": "string", + "example": "1.2.3.4" + }, + "Region": { + "description": "example:\"{Region: 'us-east-1', Zone: 'us-east-1a'}\"", + "allOf": [ + { + "$ref": "#/definitions/spider.RegionInfo" + } + ] + }, + "RootDeviceName": { + "description": "\"/dev/sda1\", ...", + "type": "string", + "example": "/dev/sda1" + }, + "RootDiskSize": { + "description": "\"default\", \"50\", \"1000\" (GB)", + "type": "string", + "example": "50" + }, + "RootDiskType": { + "description": "\"gp2\", \"Premium SSD\", ...", + "type": "string", + "example": "gp2" + }, + "SSHAccessPoint": { + "description": "Deprecated", + "type": "string", + "example": "10.2.3.2:22" + }, + "SecurityGroupIIds": { + "description": "example:\"[{NameId: 'sg-01', SystemId: 'sg-12345678'}]\"", + "type": "array", + "items": { + "$ref": "#/definitions/spider.IID" + } + }, + "StartTime": { + "description": "Timezone: based on cloud-barista server location.", + "type": "string", + "example": "2024-08-27T10:00:00Z" + }, + "SubnetIID": { + "description": "example:\"{NameId: 'subnet-01', SystemId: 'subnet-12345678'}\"", + "allOf": [ + { + "$ref": "#/definitions/spider.IID" + } + ] + }, + "TagList": { + "description": "example:\"[{Key: 'Name', Value: 'MyVM'}]\"", + "type": "array", + "items": { + "$ref": "#/definitions/spider.KeyValue" + } + }, + "VMBlockDisk": { + "description": "Deprecated soon", + "type": "string", + "example": "/dev/sda2" + }, + "VMBootDisk": { + "description": "Deprecated soon", + "type": "string", + "example": "/dev/sda1" + }, + "VMSpecName": { + "description": "instance type or flavour, etc... ex) t2.micro or f1.micro", + "type": "string", + "example": "t2.micro" + }, + "VMUserId": { + "description": "cb-user or Administrator", + "type": "string", + "example": "cb-user" + }, + "VMUserPasswd": { + "description": "Only for Windows", + "type": "string", + "example": "password1234" + }, + "VpcIID": { + "description": "example:\"{NameId: 'vpc-01', SystemId: 'vpc-12345678'}\"", + "allOf": [ + { + "$ref": "#/definitions/spider.IID" + } + ] + } + } + }, "spider.VPCInfo": { "type": "object", "required": [ @@ -2378,8 +3413,9 @@ const docTemplate = `{ } }, "Zone": { + "description": "target zone for the subnet, if not specified, it will be created in the same zone as the Connection.", "type": "string", - "example": "us-east-1a" + "example": "us-east-1b" } } } @@ -2415,10 +3451,14 @@ const docTemplate = `{ }, "spider.BooleanInfo": { "type": "object", + "required": [ + "Result" + ], "properties": { - "result": { + "Result": { "description": "true or false", - "type": "string" + "type": "string", + "example": "true" } } }, @@ -2501,7 +3541,9 @@ const docTemplate = `{ } }, "Zone": { - "type": "string" + "description": "target zone for the subnet, if not specified, it will be created in the same zone as the Connection.", + "type": "string", + "example": "us-east-1b" } } } @@ -2796,6 +3838,19 @@ const docTemplate = `{ } } }, + "spider.StatusInfo": { + "type": "object", + "required": [ + "Status" + ], + "properties": { + "Status": { + "description": "\"RUNNING,SUSPENDING,SUSPENDED,REBOOTING,TERMINATING,TERMINATED,NOTEXIST,FAILED\"", + "type": "string", + "example": "RUNNING" + } + } + }, "spider.SubnetRegisterRequest": { "type": "object", "required": [ @@ -2860,6 +3915,212 @@ const docTemplate = `{ } } }, + "spider.VMListResponse": { + "type": "object", + "required": [ + "vm" + ], + "properties": { + "vm": { + "type": "array", + "items": { + "$ref": "#/definitions/spider.VMInfo" + } + } + } + }, + "spider.VMRegisterRequest": { + "type": "object", + "required": [ + "ConnectionName", + "ReqInfo" + ], + "properties": { + "ConnectionName": { + "type": "string", + "example": "aws-connection" + }, + "ReqInfo": { + "type": "object", + "required": [ + "CSPId", + "Name" + ], + "properties": { + "CSPId": { + "type": "string", + "example": "csp-vm-1234" + }, + "Name": { + "type": "string", + "example": "vm-01" + } + } + } + } + }, + "spider.VMStartRequest": { + "type": "object", + "required": [ + "ConnectionName", + "ReqInfo" + ], + "properties": { + "ConnectionName": { + "type": "string", + "example": "aws-connection" + }, + "IDTransformMode": { + "description": "ON: transform CSP ID, OFF: no-transform CSP ID", + "type": "string", + "example": "ON" + }, + "ReqInfo": { + "type": "object", + "required": [ + "ImageName", + "ImageType", + "KeyPairName", + "Name", + "SecurityGroupNames", + "SubnetName", + "VMSpecName", + "VPCName" + ], + "properties": { + "DataDiskNames": { + "description": "same zone as this VM", + "type": "array", + "items": { + "type": "string" + }, + "example": [ + "data-disk-01", + " data-disk-02" + ] + }, + "ImageName": { + "type": "string", + "example": "ami-12345678" + }, + "ImageType": { + "description": "PublicImage or MyImage", + "type": "string", + "example": "PublicImage" + }, + "KeyPairName": { + "type": "string", + "example": "keypair-01" + }, + "Name": { + "type": "string", + "example": "vm-01" + }, + "RootDiskSize": { + "description": "GB, 30 or default, if not specified, default is used", + "type": "string", + "example": "30" + }, + "RootDiskType": { + "description": "gp2 or default, if not specified, default is used", + "type": "string", + "example": "gp2" + }, + "SecurityGroupNames": { + "type": "array", + "items": { + "type": "string" + }, + "example": [ + "sg-01", + "sg-02" + ] + }, + "SubnetName": { + "type": "string", + "example": "subnet-01" + }, + "TagList": { + "type": "array", + "items": { + "$ref": "#/definitions/spider.KeyValue" + } + }, + "VMSpecName": { + "type": "string", + "example": "t2.micro" + }, + "VMUserId": { + "description": "Administrator, Windows Only", + "type": "string", + "example": "Administrator" + }, + "VMUserPasswd": { + "description": "Windows Only", + "type": "string", + "example": "password1234" + }, + "VPCName": { + "type": "string", + "example": "vpc-01" + } + } + } + } + }, + "spider.VMStatusResponse": { + "type": "object", + "required": [ + "Status" + ], + "properties": { + "Status": { + "description": "Creating,Running,Suspending,Suspended,Resuming,Rebooting,Terminating,Terminated,NotExist,Failed", + "type": "string", + "example": "Running" + } + } + }, + "spider.VMUsingResources": { + "type": "object", + "required": [ + "Resources" + ], + "properties": { + "Resources": { + "type": "object", + "required": [ + "SGList", + "VPC" + ], + "properties": { + "SGList": { + "description": "example:\"[{NameId: 'sg-01', SystemId: 'sg-12345678'}]\"", + "type": "array", + "items": { + "$ref": "#/definitions/spider.IID" + } + }, + "VMKey": { + "description": "example:\"{NameId: 'keypair-01', SystemId: 'keypair-12345678'}\"", + "allOf": [ + { + "$ref": "#/definitions/spider.IID" + } + ] + }, + "VPC": { + "description": "example:\"{NameId: 'vpc-01', SystemId: 'vpc-12345678'}\"", + "allOf": [ + { + "$ref": "#/definitions/spider.IID" + } + ] + } + } + } + } + }, "spider.VPCRegisterRequest": { "type": "object", "required": [ diff --git a/api/swagger.json b/api/swagger.json index 3b53c99ea..ba2df82b9 100644 --- a/api/swagger.json +++ b/api/swagger.json @@ -122,6 +122,57 @@ } } }, + "/allvm": { + "get": { + "description": "Retrieve a list of all Virtual Machines (VMs) across all connections.", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "[VM management]" + ], + "summary": "List All VMs", + "operationId": "list-all-vm", + "parameters": [ + { + "type": "string", + "description": "The name of the Connection", + "name": "ConnectionName", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "List of all VMs with their respective lists", + "schema": { + "$ref": "#/definitions/spider.AllResourceListResponse" + } + }, + "400": { + "description": "Bad Request, possibly due to invalid JSON structure or missing fields", + "schema": { + "$ref": "#/definitions/spider.SimpleMsg" + } + }, + "404": { + "description": "Resource Not Found", + "schema": { + "$ref": "#/definitions/spider.SimpleMsg" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/spider.SimpleMsg" + } + } + } + } + }, "/allvpc": { "get": { "description": "Retrieve a list of all Virtual Private Clouds (VPCs) across all connections.", @@ -173,6 +224,73 @@ } } }, + "/controlvm/{Name}": { + "put": { + "description": "Control the state of a Virtual Machine (VM) such as suspend, resume, or reboot.", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "[VM management]" + ], + "summary": "Control VM", + "operationId": "control-vm", + "parameters": [ + { + "description": "Request body for controlling a VM", + "name": "ConnectionRequest", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/spider.ConnectionRequest" + } + }, + { + "type": "string", + "description": "The name of the VM to control", + "name": "Name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "The action to perform on the VM (suspend, resume, reboot)", + "name": "action", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "Result of the control operation", + "schema": { + "$ref": "#/definitions/spider.VMStatusResponse" + } + }, + "400": { + "description": "Bad Request, possibly due to invalid JSON structure or missing fields", + "schema": { + "$ref": "#/definitions/spider.SimpleMsg" + } + }, + "404": { + "description": "Resource Not Found", + "schema": { + "$ref": "#/definitions/spider.SimpleMsg" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/spider.SimpleMsg" + } + } + } + } + }, "/countkeypair": { "get": { "description": "Get the total number of KeyPairs across all connections.", @@ -362,6 +480,69 @@ } } }, + "/countvm": { + "get": { + "description": "Get the total number of Virtual Machines (VMs) across all connections.", + "produces": [ + "application/json" + ], + "tags": [ + "[VM management]" + ], + "summary": "Count All VMs", + "operationId": "count-all-vms", + "responses": { + "200": { + "description": "Total count of VMs", + "schema": { + "$ref": "#/definitions/spider.CountResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/spider.SimpleMsg" + } + } + } + } + }, + "/countvm/{ConnectionName}": { + "get": { + "description": "Get the total number of Virtual Machines (VMs) for a specific connection.", + "produces": [ + "application/json" + ], + "tags": [ + "[VM management]" + ], + "summary": "Count VMs by Connection", + "operationId": "count-vms-by-connection", + "parameters": [ + { + "type": "string", + "description": "The name of the Connection", + "name": "ConnectionName", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Total count of VMs for the connection", + "schema": { + "$ref": "#/definitions/spider.CountResponse" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/spider.SimpleMsg" + } + } + } + } + }, "/countvpc": { "get": { "description": "Get the total number of VPCs across all connections.", @@ -545,9 +726,9 @@ } } }, - "/cspvpc/{Id}": { - "delete": { - "description": "Delete a specified CSP Virtual Private Cloud (VPC).", + "/cspvm/{Id}": { + "get": { + "description": "Retrieve details of a specific CSP Virtual Machine (VM).", "consumes": [ "application/json" ], @@ -555,23 +736,21 @@ "application/json" ], "tags": [ - "[VPC management]" + "[VM management]" ], - "summary": "Delete CSP VPC", - "operationId": "delete-csp-vpc", + "summary": "Get CSP VM", + "operationId": "get-csp-vm", "parameters": [ { - "description": "Request body for deleting a CSP VPC", - "name": "ConnectionRequest", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/spider.ConnectionRequest" - } + "type": "string", + "description": "The name of the Connection to get a CSP VM for", + "name": "ConnectionName", + "in": "query", + "required": true }, { "type": "string", - "description": "The CSP VPC ID to delete", + "description": "The CSP VM ID to retrieve", "name": "Id", "in": "path", "required": true @@ -579,9 +758,9 @@ ], "responses": { "200": { - "description": "Result of the delete operation", + "description": "Details of the CSP VM", "schema": { - "$ref": "#/definitions/spider.BooleanInfo" + "$ref": "#/definitions/spider.VMInfo" } }, "400": { @@ -603,11 +782,9 @@ } } } - } - }, - "/getsecuritygroupowner": { - "post": { - "description": "Retrieve the owner VPC of a specified Security Group.", + }, + "delete": { + "description": "Terminate a specified CSP Virtual Machine (VM).", "consumes": [ "application/json" ], @@ -615,26 +792,33 @@ "application/json" ], "tags": [ - "[VPC management]" + "[VM management]" ], - "summary": "Get Security Group Owner VPC", - "operationId": "get-sg-owner-vpc", + "summary": "Terminate CSP VM", + "operationId": "terminate-csp-vm", "parameters": [ { - "description": "Request body for getting Security Group Owner VPC", - "name": "GetSGOwnerVPCRequest", + "description": "Request body for terminating a CSP VM", + "name": "ConnectionRequest", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/spider.GetSGOwnerVPCRequest" + "$ref": "#/definitions/spider.ConnectionRequest" } + }, + { + "type": "string", + "description": "The CSP VM ID to terminate", + "name": "Id", + "in": "path", + "required": true } ], "responses": { "200": { - "description": "Details of the owner VPC", + "description": "Result of the terminate operation", "schema": { - "$ref": "#/definitions/spider.IID" + "$ref": "#/definitions/spider.StatusInfo" } }, "400": { @@ -658,9 +842,9 @@ } } }, - "/keypair": { - "get": { - "description": "Retrieve a list of KeyPairs associated with a specific connection.", + "/cspvpc/{Id}": { + "delete": { + "description": "Delete a specified CSP Virtual Private Cloud (VPC).", "consumes": [ "application/json" ], @@ -668,28 +852,37 @@ "application/json" ], "tags": [ - "[KeyPair management]" + "[VPC management]" ], - "summary": "List KeyPairs", - "operationId": "list-key", + "summary": "Delete CSP VPC", + "operationId": "delete-csp-vpc", "parameters": [ + { + "description": "Request body for deleting a CSP VPC", + "name": "ConnectionRequest", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/spider.ConnectionRequest" + } + }, { "type": "string", - "description": "The name of the Connection to list KeyPairs for", - "name": "ConnectionName", - "in": "query", + "description": "The CSP VPC ID to delete", + "name": "Id", + "in": "path", "required": true } ], "responses": { "200": { - "description": "List of KeyPairs", + "description": "Result of the delete operation", "schema": { - "$ref": "#/definitions/spider.KeyListResponse" + "$ref": "#/definitions/spider.BooleanInfo" } }, "400": { - "description": "Bad Request, possibly due to invalid query parameter", + "description": "Bad Request, possibly due to invalid JSON structure or missing fields", "schema": { "$ref": "#/definitions/spider.SimpleMsg" } @@ -707,9 +900,11 @@ } } } - }, + } + }, + "/getsecuritygroupowner": { "post": { - "description": "Create a new KeyPair with the specified configurations.", + "description": "Retrieve the owner VPC of a specified Security Group.", "consumes": [ "application/json" ], @@ -717,26 +912,26 @@ "application/json" ], "tags": [ - "[KeyPair management]" + "[VPC management]" ], - "summary": "Create KeyPair", - "operationId": "create-key", + "summary": "Get Security Group Owner VPC", + "operationId": "get-sg-owner-vpc", "parameters": [ { - "description": "Request body for creating a KeyPair", - "name": "KeyCreateRequest", + "description": "Request body for getting Security Group Owner VPC", + "name": "GetSGOwnerVPCRequest", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/spider.KeyCreateRequest" + "$ref": "#/definitions/spider.GetSGOwnerVPCRequest" } } ], "responses": { "200": { - "description": "Details of the created KeyPair", + "description": "Details of the owner VPC", "schema": { - "$ref": "#/definitions/spider.KeyPairInfo" + "$ref": "#/definitions/spider.IID" } }, "400": { @@ -760,9 +955,9 @@ } } }, - "/keypair/{Name}": { + "/getvmusingresources": { "get": { - "description": "Retrieve details of a specific KeyPair.", + "description": "Retrieve details of a VM using resource ID.", "consumes": [ "application/json" ], @@ -770,14 +965,174 @@ "application/json" ], "tags": [ - "[KeyPair management]" + "[VM management]" ], - "summary": "Get KeyPair", - "operationId": "get-key", + "summary": "Get VM Using Resource", + "operationId": "get-vm-using-rs", "parameters": [ { "type": "string", - "description": "The name of the Connection to get a KeyPair for", + "description": "Connection name for the VM", + "name": "ConnectionName", + "in": "query", + "required": true + }, + { + "type": "string", + "description": "CSP ID of the VM", + "name": "CSPId", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "Details of the VM using resource", + "schema": { + "$ref": "#/definitions/spider.VMUsingResources" + } + }, + "400": { + "description": "Bad Request, possibly due to invalid query parameters", + "schema": { + "$ref": "#/definitions/spider.SimpleMsg" + } + }, + "404": { + "description": "Resource Not Found", + "schema": { + "$ref": "#/definitions/spider.SimpleMsg" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/spider.SimpleMsg" + } + } + } + } + }, + "/keypair": { + "get": { + "description": "Retrieve a list of KeyPairs associated with a specific connection.", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "[KeyPair management]" + ], + "summary": "List KeyPairs", + "operationId": "list-key", + "parameters": [ + { + "type": "string", + "description": "The name of the Connection to list KeyPairs for", + "name": "ConnectionName", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "List of KeyPairs", + "schema": { + "$ref": "#/definitions/spider.KeyListResponse" + } + }, + "400": { + "description": "Bad Request, possibly due to invalid query parameter", + "schema": { + "$ref": "#/definitions/spider.SimpleMsg" + } + }, + "404": { + "description": "Resource Not Found", + "schema": { + "$ref": "#/definitions/spider.SimpleMsg" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/spider.SimpleMsg" + } + } + } + }, + "post": { + "description": "Create a new KeyPair with the specified configurations.", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "[KeyPair management]" + ], + "summary": "Create KeyPair", + "operationId": "create-key", + "parameters": [ + { + "description": "Request body for creating a KeyPair", + "name": "KeyCreateRequest", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/spider.KeyCreateRequest" + } + } + ], + "responses": { + "200": { + "description": "Details of the created KeyPair", + "schema": { + "$ref": "#/definitions/spider.KeyPairInfo" + } + }, + "400": { + "description": "Bad Request, possibly due to invalid JSON structure or missing fields", + "schema": { + "$ref": "#/definitions/spider.SimpleMsg" + } + }, + "404": { + "description": "Resource Not Found", + "schema": { + "$ref": "#/definitions/spider.SimpleMsg" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/spider.SimpleMsg" + } + } + } + } + }, + "/keypair/{Name}": { + "get": { + "description": "Retrieve details of a specific KeyPair.", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "[KeyPair management]" + ], + "summary": "Get KeyPair", + "operationId": "get-key", + "parameters": [ + { + "type": "string", + "description": "The name of the Connection to get a KeyPair for", "name": "ConnectionName", "in": "query", "required": true @@ -1046,11 +1401,459 @@ } } } - } - }, - "/regsecuritygroup/{Name}": { - "delete": { - "description": "Unregister a Security Group with the specified name.", + } + }, + "/regsecuritygroup/{Name}": { + "delete": { + "description": "Unregister a Security Group with the specified name.", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "[SecurityGroup management]" + ], + "summary": "Unregister SecurityGroup", + "operationId": "unregister-securitygroup", + "parameters": [ + { + "description": "Request body for unregistering a SecurityGroup", + "name": "ConnectionRequest", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/spider.ConnectionRequest" + } + }, + { + "type": "string", + "description": "The name of the SecurityGroup to unregister", + "name": "Name", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Result of the unregister operation", + "schema": { + "$ref": "#/definitions/spider.BooleanInfo" + } + }, + "400": { + "description": "Bad Request, possibly due to invalid JSON structure or missing fields", + "schema": { + "$ref": "#/definitions/spider.SimpleMsg" + } + }, + "404": { + "description": "Resource Not Found", + "schema": { + "$ref": "#/definitions/spider.SimpleMsg" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/spider.SimpleMsg" + } + } + } + } + }, + "/regsubnet": { + "post": { + "description": "Register a new Subnet within a specified VPC.", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "[VPC management]" + ], + "summary": "Register Subnet", + "operationId": "register-subnet", + "parameters": [ + { + "description": "Request body for registering a Subnet", + "name": "SubnetRegisterRequest", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/spider.SubnetRegisterRequest" + } + } + ], + "responses": { + "200": { + "description": "Details of the registered Subnet", + "schema": { + "$ref": "#/definitions/spider.SubnetInfo" + } + }, + "400": { + "description": "Bad Request, possibly due to invalid JSON structure or missing fields", + "schema": { + "$ref": "#/definitions/spider.SimpleMsg" + } + }, + "404": { + "description": "Resource Not Found", + "schema": { + "$ref": "#/definitions/spider.SimpleMsg" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/spider.SimpleMsg" + } + } + } + } + }, + "/regsubnet/{Name}": { + "delete": { + "description": "Unregister a Subnet from a specified VPC.", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "[VPC management]" + ], + "summary": "Unregister Subnet", + "operationId": "unregister-subnet", + "parameters": [ + { + "description": "Request body for unregistering a Subnet", + "name": "SubnetUnregisterRequest", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/spider.SubnetUnregisterRequest" + } + }, + { + "type": "string", + "description": "The name of the Subnet to unregister", + "name": "Name", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Result of the unregister operation", + "schema": { + "$ref": "#/definitions/spider.BooleanInfo" + } + }, + "400": { + "description": "Bad Request, possibly due to invalid JSON structure or missing fields", + "schema": { + "$ref": "#/definitions/spider.SimpleMsg" + } + }, + "404": { + "description": "Resource Not Found", + "schema": { + "$ref": "#/definitions/spider.SimpleMsg" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/spider.SimpleMsg" + } + } + } + } + }, + "/regvm": { + "post": { + "description": "Register a new Virtual Machine (VM) with the specified name and CSP ID.", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "[VM management]" + ], + "summary": "Register VM", + "operationId": "register-vm", + "parameters": [ + { + "description": "Request body for registering a VM", + "name": "VMRegisterRequest", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/spider.VMRegisterRequest" + } + } + ], + "responses": { + "200": { + "description": "Details of the registered VM", + "schema": { + "$ref": "#/definitions/spider.VMInfo" + } + }, + "400": { + "description": "Bad Request, possibly due to invalid JSON structure or missing fields", + "schema": { + "$ref": "#/definitions/spider.SimpleMsg" + } + }, + "404": { + "description": "Resource Not Found", + "schema": { + "$ref": "#/definitions/spider.SimpleMsg" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/spider.SimpleMsg" + } + } + } + } + }, + "/regvm/{Name}": { + "delete": { + "description": "Unregister a Virtual Machine (VM) with the specified name.", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "[VM management]" + ], + "summary": "Unregister VM", + "operationId": "unregister-vm", + "parameters": [ + { + "description": "Request body for unregistering a VM", + "name": "ConnectionRequest", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/spider.ConnectionRequest" + } + }, + { + "type": "string", + "description": "The name of the VM to unregister", + "name": "Name", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Result of the unregister operation", + "schema": { + "$ref": "#/definitions/spider.BooleanInfo" + } + }, + "400": { + "description": "Bad Request, possibly due to invalid JSON structure or missing fields", + "schema": { + "$ref": "#/definitions/spider.SimpleMsg" + } + }, + "404": { + "description": "Resource Not Found", + "schema": { + "$ref": "#/definitions/spider.SimpleMsg" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/spider.SimpleMsg" + } + } + } + } + }, + "/regvpc": { + "post": { + "description": "Register a new Virtual Private Cloud (VPC) with the specified name and CSP ID.", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "[VPC management]" + ], + "summary": "Register VPC", + "operationId": "register-vpc", + "parameters": [ + { + "description": "Request body for registering a VPC", + "name": "VPCRegisterRequest", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/spider.VPCRegisterRequest" + } + } + ], + "responses": { + "200": { + "description": "Details of the registered VPC", + "schema": { + "$ref": "#/definitions/spider.VPCInfo" + } + }, + "400": { + "description": "Bad Request, possibly due to invalid JSON structure or missing fields", + "schema": { + "$ref": "#/definitions/spider.SimpleMsg" + } + }, + "404": { + "description": "Resource Not Found", + "schema": { + "$ref": "#/definitions/spider.SimpleMsg" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/spider.SimpleMsg" + } + } + } + } + }, + "/regvpc/{Name}": { + "delete": { + "description": "Unregister a VPC with the specified name.", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "[VPC management]" + ], + "summary": "Unregister VPC", + "operationId": "unregister-vpc", + "parameters": [ + { + "description": "Request body for unregistering a VPC", + "name": "ConnectionRequest", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/spider.ConnectionRequest" + } + }, + { + "type": "string", + "description": "The name of the VPC to unregister", + "name": "Name", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Result of the unregister operation", + "schema": { + "$ref": "#/definitions/spider.BooleanInfo" + } + }, + "400": { + "description": "Bad Request, possibly due to invalid JSON structure or missing fields", + "schema": { + "$ref": "#/definitions/spider.SimpleMsg" + } + }, + "404": { + "description": "Resource Not Found", + "schema": { + "$ref": "#/definitions/spider.SimpleMsg" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/spider.SimpleMsg" + } + } + } + } + }, + "/securitygroup": { + "get": { + "description": "Retrieve a list of Security Groups associated with a specific connection.", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "[SecurityGroup management]" + ], + "summary": "List SecurityGroups", + "operationId": "list-securitygroup", + "parameters": [ + { + "type": "string", + "description": "The name of the Connection to list SecurityGroups for", + "name": "ConnectionName", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "List of SecurityGroups", + "schema": { + "$ref": "#/definitions/spider.ListSecurityResponse" + } + }, + "400": { + "description": "Bad Request, possibly due to invalid query parameter", + "schema": { + "$ref": "#/definitions/spider.SimpleMsg" + } + }, + "404": { + "description": "Resource Not Found", + "schema": { + "$ref": "#/definitions/spider.SimpleMsg" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/spider.SimpleMsg" + } + } + } + }, + "post": { + "description": "Create a new Security Group with specified rules and tags.", "consumes": [ "application/json" ], @@ -1060,31 +1863,24 @@ "tags": [ "[SecurityGroup management]" ], - "summary": "Unregister SecurityGroup", - "operationId": "unregister-securitygroup", + "summary": "Create SecurityGroup", + "operationId": "create-securitygroup", "parameters": [ { - "description": "Request body for unregistering a SecurityGroup", - "name": "ConnectionRequest", + "description": "Request body for creating a SecurityGroup", + "name": "SecurityGroupCreateRequest", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/spider.ConnectionRequest" + "$ref": "#/definitions/spider.SecurityGroupCreateRequest" } - }, - { - "type": "string", - "description": "The name of the SecurityGroup to unregister", - "name": "Name", - "in": "path", - "required": true } ], "responses": { "200": { - "description": "Result of the unregister operation", + "description": "Details of the created SecurityGroup", "schema": { - "$ref": "#/definitions/spider.BooleanInfo" + "$ref": "#/definitions/spider.SecurityInfo" } }, "400": { @@ -1108,9 +1904,9 @@ } } }, - "/regsubnet": { - "post": { - "description": "Register a new Subnet within a specified VPC.", + "/securitygroup/{Name}": { + "get": { + "description": "Retrieve details of a specific Security Group.", "consumes": [ "application/json" ], @@ -1118,26 +1914,31 @@ "application/json" ], "tags": [ - "[VPC management]" + "[SecurityGroup management]" ], - "summary": "Register Subnet", - "operationId": "register-subnet", + "summary": "Get SecurityGroup", + "operationId": "get-securitygroup", "parameters": [ { - "description": "Request body for registering a Subnet", - "name": "SubnetRegisterRequest", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/spider.SubnetRegisterRequest" - } + "type": "string", + "description": "The name of the Connection to get a SecurityGroup for", + "name": "ConnectionName", + "in": "query", + "required": true + }, + { + "type": "string", + "description": "The name of the SecurityGroup to retrieve", + "name": "Name", + "in": "path", + "required": true } ], "responses": { "200": { - "description": "Details of the registered Subnet", + "description": "Details of the SecurityGroup", "schema": { - "$ref": "#/definitions/spider.SubnetInfo" + "$ref": "#/definitions/spider.SecurityInfo" } }, "400": { @@ -1159,11 +1960,9 @@ } } } - } - }, - "/regsubnet/{Name}": { + }, "delete": { - "description": "Unregister a Subnet from a specified VPC.", + "description": "Delete a specified Security Group.", "consumes": [ "application/json" ], @@ -1171,31 +1970,37 @@ "application/json" ], "tags": [ - "[VPC management]" + "[SecurityGroup management]" ], - "summary": "Unregister Subnet", - "operationId": "unregister-subnet", + "summary": "Delete SecurityGroup", + "operationId": "delete-securitygroup", "parameters": [ { - "description": "Request body for unregistering a Subnet", - "name": "SubnetUnregisterRequest", + "description": "Request body for deleting a SecurityGroup", + "name": "ConnectionRequest", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/spider.SubnetUnregisterRequest" + "$ref": "#/definitions/spider.ConnectionRequest" } }, { "type": "string", - "description": "The name of the Subnet to unregister", + "description": "The name of the SecurityGroup to delete", "name": "Name", "in": "path", "required": true + }, + { + "type": "string", + "description": "Force delete the SecurityGroup", + "name": "force", + "in": "query" } ], "responses": { "200": { - "description": "Result of the unregister operation", + "description": "Result of the delete operation", "schema": { "$ref": "#/definitions/spider.BooleanInfo" } @@ -1221,9 +2026,9 @@ } } }, - "/regvpc": { + "/securitygroup/{SGName}/rules": { "post": { - "description": "Register a new Virtual Private Cloud (VPC) with the specified name and CSP ID.", + "description": "Add new rules to a Security Group.", "consumes": [ "application/json" ], @@ -1231,26 +2036,33 @@ "application/json" ], "tags": [ - "[VPC management]" + "[SecurityGroup management]" ], - "summary": "Register VPC", - "operationId": "register-vpc", + "summary": "Add Rules to SecurityGroup", + "operationId": "add-rules-securitygroup", "parameters": [ { - "description": "Request body for registering a VPC", - "name": "VPCRegisterRequest", + "type": "string", + "description": "The name of the SecurityGroup to add rules to", + "name": "SGName", + "in": "path", + "required": true + }, + { + "description": "Request body for adding rules", + "name": "RuleControlRequest", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/spider.VPCRegisterRequest" + "$ref": "#/definitions/spider.RuleControlRequest" } } ], "responses": { "200": { - "description": "Details of the registered VPC", + "description": "Details of the SecurityGroup after adding rules", "schema": { - "$ref": "#/definitions/spider.VPCInfo" + "$ref": "#/definitions/spider.SecurityInfo" } }, "400": { @@ -1272,11 +2084,9 @@ } } } - } - }, - "/regvpc/{Name}": { + }, "delete": { - "description": "Unregister a VPC with the specified name.", + "description": "Remove existing rules from a Security Group.", "consumes": [ "application/json" ], @@ -1284,31 +2094,31 @@ "application/json" ], "tags": [ - "[VPC management]" + "[SecurityGroup management]" ], - "summary": "Unregister VPC", - "operationId": "unregister-vpc", + "summary": "Remove Rules from SecurityGroup", + "operationId": "remove-rules-securitygroup", "parameters": [ { - "description": "Request body for unregistering a VPC", - "name": "ConnectionRequest", + "type": "string", + "description": "The name of the SecurityGroup to remove rules from", + "name": "SGName", + "in": "path", + "required": true + }, + { + "description": "Request body for removing rules", + "name": "RuleControlRequest", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/spider.ConnectionRequest" + "$ref": "#/definitions/spider.RuleControlRequest" } - }, - { - "type": "string", - "description": "The name of the VPC to unregister", - "name": "Name", - "in": "path", - "required": true } ], "responses": { "200": { - "description": "Result of the unregister operation", + "description": "Result of the remove operation", "schema": { "$ref": "#/definitions/spider.BooleanInfo" } @@ -1334,9 +2144,9 @@ } } }, - "/securitygroup": { + "/vm": { "get": { - "description": "Retrieve a list of Security Groups associated with a specific connection.", + "description": "Retrieve a list of Virtual Machines (VMs) associated with a specific connection.", "consumes": [ "application/json" ], @@ -1344,14 +2154,14 @@ "application/json" ], "tags": [ - "[SecurityGroup management]" + "[VM management]" ], - "summary": "List SecurityGroups", - "operationId": "list-securitygroup", + "summary": "List VMs", + "operationId": "list-vm", "parameters": [ { "type": "string", - "description": "The name of the Connection to list SecurityGroups for", + "description": "The name of the Connection to list VMs for", "name": "ConnectionName", "in": "query", "required": true @@ -1359,9 +2169,9 @@ ], "responses": { "200": { - "description": "List of SecurityGroups", + "description": "List of VMs", "schema": { - "$ref": "#/definitions/spider.ListSecurityResponse" + "$ref": "#/definitions/spider.VMListResponse" } }, "400": { @@ -1385,7 +2195,7 @@ } }, "post": { - "description": "Create a new Security Group with specified rules and tags.", + "description": "Start a new Virtual Machine (VM) with specified configurations.", "consumes": [ "application/json" ], @@ -1393,26 +2203,26 @@ "application/json" ], "tags": [ - "[SecurityGroup management]" + "[VM management]" ], - "summary": "Create SecurityGroup", - "operationId": "create-securitygroup", + "summary": "Start VM", + "operationId": "start-vm", "parameters": [ { - "description": "Request body for creating a SecurityGroup", - "name": "SecurityGroupCreateRequest", + "description": "Request body for starting a VM", + "name": "VMStartRequest", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/spider.SecurityGroupCreateRequest" + "$ref": "#/definitions/spider.VMStartRequest" } } ], "responses": { "200": { - "description": "Details of the created SecurityGroup", + "description": "Details of the started VM", "schema": { - "$ref": "#/definitions/spider.SecurityInfo" + "$ref": "#/definitions/spider.VMInfo" } }, "400": { @@ -1436,9 +2246,9 @@ } } }, - "/securitygroup/{Name}": { + "/vm/{Name}": { "get": { - "description": "Retrieve details of a specific Security Group.", + "description": "Retrieve details of a specific Virtual Machine (VM).", "consumes": [ "application/json" ], @@ -1446,21 +2256,21 @@ "application/json" ], "tags": [ - "[SecurityGroup management]" + "[VM management]" ], - "summary": "Get SecurityGroup", - "operationId": "get-securitygroup", + "summary": "Get VM", + "operationId": "get-vm", "parameters": [ { "type": "string", - "description": "The name of the Connection to get a SecurityGroup for", + "description": "The name of the Connection to get a VM for", "name": "ConnectionName", "in": "query", "required": true }, { "type": "string", - "description": "The name of the SecurityGroup to retrieve", + "description": "The name of the VM to retrieve", "name": "Name", "in": "path", "required": true @@ -1468,9 +2278,9 @@ ], "responses": { "200": { - "description": "Details of the SecurityGroup", + "description": "Details of the VM", "schema": { - "$ref": "#/definitions/spider.SecurityInfo" + "$ref": "#/definitions/spider.VMInfo" } }, "400": { @@ -1494,7 +2304,7 @@ } }, "delete": { - "description": "Delete a specified Security Group.", + "description": "Terminate a specified Virtual Machine (VM).", "consumes": [ "application/json" ], @@ -1502,13 +2312,13 @@ "application/json" ], "tags": [ - "[SecurityGroup management]" + "[VM management]" ], - "summary": "Delete SecurityGroup", - "operationId": "delete-securitygroup", + "summary": "Terminate VM", + "operationId": "terminate-vm", "parameters": [ { - "description": "Request body for deleting a SecurityGroup", + "description": "Request body for terminating a VM", "name": "ConnectionRequest", "in": "body", "required": true, @@ -1518,23 +2328,23 @@ }, { "type": "string", - "description": "The name of the SecurityGroup to delete", + "description": "The name of the VM to terminate", "name": "Name", "in": "path", "required": true }, { "type": "string", - "description": "Force delete the SecurityGroup", + "description": "Force terminate the VM", "name": "force", "in": "query" } ], "responses": { "200": { - "description": "Result of the delete operation", + "description": "Result of the terminate operation", "schema": { - "$ref": "#/definitions/spider.BooleanInfo" + "$ref": "#/definitions/spider.StatusInfo" } }, "400": { @@ -1558,9 +2368,9 @@ } } }, - "/securitygroup/{SGName}/rules": { - "post": { - "description": "Add new rules to a Security Group.", + "/vmstatus": { + "get": { + "description": "Retrieve a list of statuses for Virtual Machines (VMs) associated with a specific connection.", "consumes": [ "application/json" ], @@ -1568,37 +2378,28 @@ "application/json" ], "tags": [ - "[SecurityGroup management]" + "[VM management]" ], - "summary": "Add Rules to SecurityGroup", - "operationId": "add-rules-securitygroup", + "summary": "List VM Statuses", + "operationId": "list-vm-status", "parameters": [ { "type": "string", - "description": "The name of the SecurityGroup to add rules to", - "name": "SGName", - "in": "path", + "description": "The name of the Connection to list VM statuses for", + "name": "ConnectionName", + "in": "query", "required": true - }, - { - "description": "Request body for adding rules", - "name": "RuleControlRequest", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/spider.RuleControlRequest" - } } ], "responses": { "200": { - "description": "Details of the SecurityGroup after adding rules", + "description": "List of VM statuses", "schema": { - "$ref": "#/definitions/spider.SecurityInfo" + "$ref": "#/definitions/spider.VMStatusResponse" } }, "400": { - "description": "Bad Request, possibly due to invalid JSON structure or missing fields", + "description": "Bad Request, possibly due to invalid query parameter", "schema": { "$ref": "#/definitions/spider.SimpleMsg" } @@ -1616,9 +2417,11 @@ } } } - }, - "delete": { - "description": "Remove existing rules from a Security Group.", + } + }, + "/vmstatus/{Name}": { + "get": { + "description": "Retrieve the status of a specific Virtual Machine (VM).", "consumes": [ "application/json" ], @@ -1626,33 +2429,31 @@ "application/json" ], "tags": [ - "[SecurityGroup management]" + "[VM management]" ], - "summary": "Remove Rules from SecurityGroup", - "operationId": "remove-rules-securitygroup", + "summary": "Get VM Status", + "operationId": "get-vm-status", "parameters": [ { "type": "string", - "description": "The name of the SecurityGroup to remove rules from", - "name": "SGName", - "in": "path", + "description": "The name of the Connection to get a VM status for", + "name": "ConnectionName", + "in": "query", "required": true }, { - "description": "Request body for removing rules", - "name": "RuleControlRequest", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/spider.RuleControlRequest" - } + "type": "string", + "description": "The name of the VM to retrieve the status of", + "name": "Name", + "in": "path", + "required": true } ], "responses": { "200": { - "description": "Result of the remove operation", + "description": "Details of the VM status", "schema": { - "$ref": "#/definitions/spider.BooleanInfo" + "$ref": "#/definitions/spider.VMStatusResponse" } }, "400": { @@ -2113,6 +2914,17 @@ } } }, + "spider.ImageType": { + "type": "string", + "enum": [ + "PublicImage", + "MyImage" + ], + "x-enum-varnames": [ + "PublicImage", + "MyImage" + ] + }, "spider.KeyPairInfo": { "type": "object", "required": [ @@ -2175,7 +2987,34 @@ }, "Value": { "type": "string", - "example": "value1" + "example": "value1" + } + } + }, + "spider.Platform": { + "type": "string", + "enum": [ + "LINUX/UNIX", + "WINDOWS" + ], + "x-enum-varnames": [ + "LINUX_UNIX", + "WINDOWS" + ] + }, + "spider.RegionInfo": { + "type": "object", + "required": [ + "Region" + ], + "properties": { + "Region": { + "type": "string", + "example": "us-east-1" + }, + "Zone": { + "type": "string", + "example": "us-east-1a" } } }, @@ -2297,6 +3136,202 @@ } } }, + "spider.VMInfo": { + "type": "object", + "required": [ + "AccessPoint", + "DataDiskIIDs", + "IId", + "ImageIId", + "ImageType", + "KeyPairIId", + "NetworkInterface", + "Platform", + "PrivateIP", + "PublicIP", + "Region", + "RootDeviceName", + "RootDiskSize", + "RootDiskType", + "SecurityGroupIIds", + "StartTime", + "SubnetIID", + "VMSpecName", + "VMUserId", + "VpcIID" + ], + "properties": { + "AccessPoint": { + "description": "10.2.3.2:22, 123.456.789.123:432", + "type": "string", + "example": "1.2.3.4:22" + }, + "DataDiskIIDs": { + "description": "example:\"[{NameId: 'datadisk-01', SystemId: 'datadisk-12345678'}]\"", + "type": "array", + "items": { + "$ref": "#/definitions/spider.IID" + } + }, + "IId": { + "description": "example:\"{NameId: 'vm-01', SystemId: 'i-12345678'}\"", + "allOf": [ + { + "$ref": "#/definitions/spider.IID" + } + ] + }, + "ImageIId": { + "description": "example:\"{NameId: 'ami-12345678', SystemId: 'ami-12345678'}\"", + "allOf": [ + { + "$ref": "#/definitions/spider.IID" + } + ] + }, + "ImageType": { + "description": "PublicImage | MyImage", + "allOf": [ + { + "$ref": "#/definitions/spider.ImageType" + } + ], + "example": "PublicImage" + }, + "KeyPairIId": { + "description": "example:\"{NameId: 'keypair-01', SystemId: 'keypair-12345678'}\"", + "allOf": [ + { + "$ref": "#/definitions/spider.IID" + } + ] + }, + "KeyValueList": { + "description": "example:\"[{Key: 'Architecture', Value: 'x86_64'}]\"", + "type": "array", + "items": { + "$ref": "#/definitions/spider.KeyValue" + } + }, + "NetworkInterface": { + "type": "string", + "example": "eni-12345678" + }, + "Platform": { + "description": "LINUX | WINDOWS", + "allOf": [ + { + "$ref": "#/definitions/spider.Platform" + } + ], + "example": "LINUX" + }, + "PrivateDNS": { + "type": "string", + "example": "ip-192-168-1-1.ec2.internal" + }, + "PrivateIP": { + "type": "string", + "example": "192.168.1.1" + }, + "PublicDNS": { + "type": "string", + "example": "ec2-1-2-3-4.compute-1.amazonaws.com" + }, + "PublicIP": { + "type": "string", + "example": "1.2.3.4" + }, + "Region": { + "description": "example:\"{Region: 'us-east-1', Zone: 'us-east-1a'}\"", + "allOf": [ + { + "$ref": "#/definitions/spider.RegionInfo" + } + ] + }, + "RootDeviceName": { + "description": "\"/dev/sda1\", ...", + "type": "string", + "example": "/dev/sda1" + }, + "RootDiskSize": { + "description": "\"default\", \"50\", \"1000\" (GB)", + "type": "string", + "example": "50" + }, + "RootDiskType": { + "description": "\"gp2\", \"Premium SSD\", ...", + "type": "string", + "example": "gp2" + }, + "SSHAccessPoint": { + "description": "Deprecated", + "type": "string", + "example": "10.2.3.2:22" + }, + "SecurityGroupIIds": { + "description": "example:\"[{NameId: 'sg-01', SystemId: 'sg-12345678'}]\"", + "type": "array", + "items": { + "$ref": "#/definitions/spider.IID" + } + }, + "StartTime": { + "description": "Timezone: based on cloud-barista server location.", + "type": "string", + "example": "2024-08-27T10:00:00Z" + }, + "SubnetIID": { + "description": "example:\"{NameId: 'subnet-01', SystemId: 'subnet-12345678'}\"", + "allOf": [ + { + "$ref": "#/definitions/spider.IID" + } + ] + }, + "TagList": { + "description": "example:\"[{Key: 'Name', Value: 'MyVM'}]\"", + "type": "array", + "items": { + "$ref": "#/definitions/spider.KeyValue" + } + }, + "VMBlockDisk": { + "description": "Deprecated soon", + "type": "string", + "example": "/dev/sda2" + }, + "VMBootDisk": { + "description": "Deprecated soon", + "type": "string", + "example": "/dev/sda1" + }, + "VMSpecName": { + "description": "instance type or flavour, etc... ex) t2.micro or f1.micro", + "type": "string", + "example": "t2.micro" + }, + "VMUserId": { + "description": "cb-user or Administrator", + "type": "string", + "example": "cb-user" + }, + "VMUserPasswd": { + "description": "Only for Windows", + "type": "string", + "example": "password1234" + }, + "VpcIID": { + "description": "example:\"{NameId: 'vpc-01', SystemId: 'vpc-12345678'}\"", + "allOf": [ + { + "$ref": "#/definitions/spider.IID" + } + ] + } + } + }, "spider.VPCInfo": { "type": "object", "required": [ @@ -2375,8 +3410,9 @@ } }, "Zone": { + "description": "target zone for the subnet, if not specified, it will be created in the same zone as the Connection.", "type": "string", - "example": "us-east-1a" + "example": "us-east-1b" } } } @@ -2412,10 +3448,14 @@ }, "spider.BooleanInfo": { "type": "object", + "required": [ + "Result" + ], "properties": { - "result": { + "Result": { "description": "true or false", - "type": "string" + "type": "string", + "example": "true" } } }, @@ -2498,7 +3538,9 @@ } }, "Zone": { - "type": "string" + "description": "target zone for the subnet, if not specified, it will be created in the same zone as the Connection.", + "type": "string", + "example": "us-east-1b" } } } @@ -2793,6 +3835,19 @@ } } }, + "spider.StatusInfo": { + "type": "object", + "required": [ + "Status" + ], + "properties": { + "Status": { + "description": "\"RUNNING,SUSPENDING,SUSPENDED,REBOOTING,TERMINATING,TERMINATED,NOTEXIST,FAILED\"", + "type": "string", + "example": "RUNNING" + } + } + }, "spider.SubnetRegisterRequest": { "type": "object", "required": [ @@ -2857,6 +3912,212 @@ } } }, + "spider.VMListResponse": { + "type": "object", + "required": [ + "vm" + ], + "properties": { + "vm": { + "type": "array", + "items": { + "$ref": "#/definitions/spider.VMInfo" + } + } + } + }, + "spider.VMRegisterRequest": { + "type": "object", + "required": [ + "ConnectionName", + "ReqInfo" + ], + "properties": { + "ConnectionName": { + "type": "string", + "example": "aws-connection" + }, + "ReqInfo": { + "type": "object", + "required": [ + "CSPId", + "Name" + ], + "properties": { + "CSPId": { + "type": "string", + "example": "csp-vm-1234" + }, + "Name": { + "type": "string", + "example": "vm-01" + } + } + } + } + }, + "spider.VMStartRequest": { + "type": "object", + "required": [ + "ConnectionName", + "ReqInfo" + ], + "properties": { + "ConnectionName": { + "type": "string", + "example": "aws-connection" + }, + "IDTransformMode": { + "description": "ON: transform CSP ID, OFF: no-transform CSP ID", + "type": "string", + "example": "ON" + }, + "ReqInfo": { + "type": "object", + "required": [ + "ImageName", + "ImageType", + "KeyPairName", + "Name", + "SecurityGroupNames", + "SubnetName", + "VMSpecName", + "VPCName" + ], + "properties": { + "DataDiskNames": { + "description": "same zone as this VM", + "type": "array", + "items": { + "type": "string" + }, + "example": [ + "data-disk-01", + " data-disk-02" + ] + }, + "ImageName": { + "type": "string", + "example": "ami-12345678" + }, + "ImageType": { + "description": "PublicImage or MyImage", + "type": "string", + "example": "PublicImage" + }, + "KeyPairName": { + "type": "string", + "example": "keypair-01" + }, + "Name": { + "type": "string", + "example": "vm-01" + }, + "RootDiskSize": { + "description": "GB, 30 or default, if not specified, default is used", + "type": "string", + "example": "30" + }, + "RootDiskType": { + "description": "gp2 or default, if not specified, default is used", + "type": "string", + "example": "gp2" + }, + "SecurityGroupNames": { + "type": "array", + "items": { + "type": "string" + }, + "example": [ + "sg-01", + "sg-02" + ] + }, + "SubnetName": { + "type": "string", + "example": "subnet-01" + }, + "TagList": { + "type": "array", + "items": { + "$ref": "#/definitions/spider.KeyValue" + } + }, + "VMSpecName": { + "type": "string", + "example": "t2.micro" + }, + "VMUserId": { + "description": "Administrator, Windows Only", + "type": "string", + "example": "Administrator" + }, + "VMUserPasswd": { + "description": "Windows Only", + "type": "string", + "example": "password1234" + }, + "VPCName": { + "type": "string", + "example": "vpc-01" + } + } + } + } + }, + "spider.VMStatusResponse": { + "type": "object", + "required": [ + "Status" + ], + "properties": { + "Status": { + "description": "Creating,Running,Suspending,Suspended,Resuming,Rebooting,Terminating,Terminated,NotExist,Failed", + "type": "string", + "example": "Running" + } + } + }, + "spider.VMUsingResources": { + "type": "object", + "required": [ + "Resources" + ], + "properties": { + "Resources": { + "type": "object", + "required": [ + "SGList", + "VPC" + ], + "properties": { + "SGList": { + "description": "example:\"[{NameId: 'sg-01', SystemId: 'sg-12345678'}]\"", + "type": "array", + "items": { + "$ref": "#/definitions/spider.IID" + } + }, + "VMKey": { + "description": "example:\"{NameId: 'keypair-01', SystemId: 'keypair-12345678'}\"", + "allOf": [ + { + "$ref": "#/definitions/spider.IID" + } + ] + }, + "VPC": { + "description": "example:\"{NameId: 'vpc-01', SystemId: 'vpc-12345678'}\"", + "allOf": [ + { + "$ref": "#/definitions/spider.IID" + } + ] + } + } + } + } + }, "spider.VPCRegisterRequest": { "type": "object", "required": [ diff --git a/api/swagger.yaml b/api/swagger.yaml index 0eab22e90..b14e36c0c 100644 --- a/api/swagger.yaml +++ b/api/swagger.yaml @@ -12,6 +12,14 @@ definitions: - NameId - SystemId type: object + spider.ImageType: + enum: + - PublicImage + - MyImage + type: string + x-enum-varnames: + - PublicImage + - MyImage spider.KeyPairInfo: properties: Fingerprint: @@ -58,6 +66,25 @@ definitions: required: - Key type: object + spider.Platform: + enum: + - LINUX/UNIX + - WINDOWS + type: string + x-enum-varnames: + - LINUX_UNIX + - WINDOWS + spider.RegionInfo: + properties: + Region: + example: us-east-1 + type: string + Zone: + example: us-east-1a + type: string + required: + - Region + type: object spider.SecurityInfo: properties: IId: @@ -138,6 +165,143 @@ definitions: - IPv4_CIDR - Zone type: object + spider.VMInfo: + properties: + AccessPoint: + description: 10.2.3.2:22, 123.456.789.123:432 + example: 1.2.3.4:22 + type: string + DataDiskIIDs: + description: 'example:"[{NameId: ''datadisk-01'', SystemId: ''datadisk-12345678''}]"' + items: + $ref: '#/definitions/spider.IID' + type: array + IId: + allOf: + - $ref: '#/definitions/spider.IID' + description: 'example:"{NameId: ''vm-01'', SystemId: ''i-12345678''}"' + ImageIId: + allOf: + - $ref: '#/definitions/spider.IID' + description: 'example:"{NameId: ''ami-12345678'', SystemId: ''ami-12345678''}"' + ImageType: + allOf: + - $ref: '#/definitions/spider.ImageType' + description: PublicImage | MyImage + example: PublicImage + KeyPairIId: + allOf: + - $ref: '#/definitions/spider.IID' + description: 'example:"{NameId: ''keypair-01'', SystemId: ''keypair-12345678''}"' + KeyValueList: + description: 'example:"[{Key: ''Architecture'', Value: ''x86_64''}]"' + items: + $ref: '#/definitions/spider.KeyValue' + type: array + NetworkInterface: + example: eni-12345678 + type: string + Platform: + allOf: + - $ref: '#/definitions/spider.Platform' + description: LINUX | WINDOWS + example: LINUX + PrivateDNS: + example: ip-192-168-1-1.ec2.internal + type: string + PrivateIP: + example: 192.168.1.1 + type: string + PublicDNS: + example: ec2-1-2-3-4.compute-1.amazonaws.com + type: string + PublicIP: + example: 1.2.3.4 + type: string + Region: + allOf: + - $ref: '#/definitions/spider.RegionInfo' + description: 'example:"{Region: ''us-east-1'', Zone: ''us-east-1a''}"' + RootDeviceName: + description: '"/dev/sda1", ...' + example: /dev/sda1 + type: string + RootDiskSize: + description: '"default", "50", "1000" (GB)' + example: "50" + type: string + RootDiskType: + description: '"gp2", "Premium SSD", ...' + example: gp2 + type: string + SSHAccessPoint: + description: Deprecated + example: 10.2.3.2:22 + type: string + SecurityGroupIIds: + description: 'example:"[{NameId: ''sg-01'', SystemId: ''sg-12345678''}]"' + items: + $ref: '#/definitions/spider.IID' + type: array + StartTime: + description: 'Timezone: based on cloud-barista server location.' + example: "2024-08-27T10:00:00Z" + type: string + SubnetIID: + allOf: + - $ref: '#/definitions/spider.IID' + description: 'example:"{NameId: ''subnet-01'', SystemId: ''subnet-12345678''}"' + TagList: + description: 'example:"[{Key: ''Name'', Value: ''MyVM''}]"' + items: + $ref: '#/definitions/spider.KeyValue' + type: array + VMBlockDisk: + description: Deprecated soon + example: /dev/sda2 + type: string + VMBootDisk: + description: Deprecated soon + example: /dev/sda1 + type: string + VMSpecName: + description: instance type or flavour, etc... ex) t2.micro or f1.micro + example: t2.micro + type: string + VMUserId: + description: cb-user or Administrator + example: cb-user + type: string + VMUserPasswd: + description: Only for Windows + example: password1234 + type: string + VpcIID: + allOf: + - $ref: '#/definitions/spider.IID' + description: 'example:"{NameId: ''vpc-01'', SystemId: ''vpc-12345678''}"' + required: + - AccessPoint + - DataDiskIIDs + - IId + - ImageIId + - ImageType + - KeyPairIId + - NetworkInterface + - Platform + - PrivateIP + - PublicIP + - Region + - RootDeviceName + - RootDiskSize + - RootDiskType + - SecurityGroupIIds + - StartTime + - SubnetIID + - VMSpecName + - VMUserId + - VpcIID + type: object spider.VPCInfo: properties: IId: @@ -186,7 +350,9 @@ definitions: $ref: '#/definitions/spider.KeyValue' type: array Zone: - example: us-east-1a + description: target zone for the subnet, if not specified, it will be + created in the same zone as the Connection. + example: us-east-1b type: string required: - IPv4_CIDR @@ -217,9 +383,12 @@ definitions: type: object spider.BooleanInfo: properties: - result: + Result: description: true or false + example: "true" type: string + required: + - Result type: object spider.ConnectionRequest: properties: @@ -268,6 +437,9 @@ definitions: $ref: '#/definitions/spider.KeyValue' type: array Zone: + description: target zone for the subnet, if not specified, it will + be created in the same zone as the Connection. + example: us-east-1b type: string required: - IPv4_CIDR @@ -480,6 +652,15 @@ definitions: required: - message type: object + spider.StatusInfo: + properties: + Status: + description: '"RUNNING,SUSPENDING,SUSPENDED,REBOOTING,TERMINATING,TERMINATED,NOTEXIST,FAILED"' + example: RUNNING + type: string + required: + - Status + type: object spider.SubnetRegisterRequest: properties: ConnectionName: @@ -525,6 +706,151 @@ definitions: - ConnectionName - ReqInfo type: object + spider.VMListResponse: + properties: + vm: + items: + $ref: '#/definitions/spider.VMInfo' + type: array + required: + - vm + type: object + spider.VMRegisterRequest: + properties: + ConnectionName: + example: aws-connection + type: string + ReqInfo: + properties: + CSPId: + example: csp-vm-1234 + type: string + Name: + example: vm-01 + type: string + required: + - CSPId + - Name + type: object + required: + - ConnectionName + - ReqInfo + type: object + spider.VMStartRequest: + properties: + ConnectionName: + example: aws-connection + type: string + IDTransformMode: + description: 'ON: transform CSP ID, OFF: no-transform CSP ID' + example: "ON" + type: string + ReqInfo: + properties: + DataDiskNames: + description: same zone as this VM + example: + - data-disk-01 + - ' data-disk-02' + items: + type: string + type: array + ImageName: + example: ami-12345678 + type: string + ImageType: + description: PublicImage or MyImage + example: PublicImage + type: string + KeyPairName: + example: keypair-01 + type: string + Name: + example: vm-01 + type: string + RootDiskSize: + description: GB, 30 or default, if not specified, default is used + example: "30" + type: string + RootDiskType: + description: gp2 or default, if not specified, default is used + example: gp2 + type: string + SecurityGroupNames: + example: + - sg-01 + - sg-02 + items: + type: string + type: array + SubnetName: + example: subnet-01 + type: string + TagList: + items: + $ref: '#/definitions/spider.KeyValue' + type: array + VMSpecName: + example: t2.micro + type: string + VMUserId: + description: Administrator, Windows Only + example: Administrator + type: string + VMUserPasswd: + description: Windows Only + example: password1234 + type: string + VPCName: + example: vpc-01 + type: string + required: + - ImageName + - ImageType + - KeyPairName + - Name + - SecurityGroupNames + - SubnetName + - VMSpecName + - VPCName + type: object + required: + - ConnectionName + - ReqInfo + type: object + spider.VMStatusResponse: + properties: + Status: + description: Creating,Running,Suspending,Suspended,Resuming,Rebooting,Terminating,Terminated,NotExist,Failed + example: Running + type: string + required: + - Status + type: object + spider.VMUsingResources: + properties: + Resources: + properties: + SGList: + description: 'example:"[{NameId: ''sg-01'', SystemId: ''sg-12345678''}]"' + items: + $ref: '#/definitions/spider.IID' + type: array + VMKey: + allOf: + - $ref: '#/definitions/spider.IID' + description: 'example:"{NameId: ''keypair-01'', SystemId: ''keypair-12345678''}"' + VPC: + allOf: + - $ref: '#/definitions/spider.IID' + description: 'example:"{NameId: ''vpc-01'', SystemId: ''vpc-12345678''}"' + required: + - SGList + - VPC + type: object + required: + - Resources + type: object spider.VPCRegisterRequest: properties: ConnectionName: @@ -628,6 +954,41 @@ paths: summary: List All SecurityGroups tags: - '[SecurityGroup management]' + /allvm: + get: + consumes: + - application/json + description: Retrieve a list of all Virtual Machines (VMs) across all connections. + operationId: list-all-vm + parameters: + - description: The name of the Connection + in: query + name: ConnectionName + required: true + type: string + produces: + - application/json + responses: + "200": + description: List of all VMs with their respective lists + schema: + $ref: '#/definitions/spider.AllResourceListResponse' + "400": + description: Bad Request, possibly due to invalid JSON structure or missing + fields + schema: + $ref: '#/definitions/spider.SimpleMsg' + "404": + description: Resource Not Found + schema: + $ref: '#/definitions/spider.SimpleMsg' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/spider.SimpleMsg' + summary: List All VMs + tags: + - '[VM management]' /allvpc: get: consumes: @@ -664,6 +1025,53 @@ paths: summary: List All VPCs tags: - '[VPC management]' + /controlvm/{Name}: + put: + consumes: + - application/json + description: Control the state of a Virtual Machine (VM) such as suspend, resume, + or reboot. + operationId: control-vm + parameters: + - description: Request body for controlling a VM + in: body + name: ConnectionRequest + required: true + schema: + $ref: '#/definitions/spider.ConnectionRequest' + - description: The name of the VM to control + in: path + name: Name + required: true + type: string + - description: The action to perform on the VM (suspend, resume, reboot) + in: query + name: action + required: true + type: string + produces: + - application/json + responses: + "200": + description: Result of the control operation + schema: + $ref: '#/definitions/spider.VMStatusResponse' + "400": + description: Bad Request, possibly due to invalid JSON structure or missing + fields + schema: + $ref: '#/definitions/spider.SimpleMsg' + "404": + description: Resource Not Found + schema: + $ref: '#/definitions/spider.SimpleMsg' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/spider.SimpleMsg' + summary: Control VM + tags: + - '[VM management]' /countkeypair: get: description: Get the total number of KeyPairs across all connections. @@ -790,6 +1198,48 @@ paths: summary: Count Subnets by Connection tags: - '[VPC management]' + /countvm: + get: + description: Get the total number of Virtual Machines (VMs) across all connections. + operationId: count-all-vms + produces: + - application/json + responses: + "200": + description: Total count of VMs + schema: + $ref: '#/definitions/spider.CountResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/spider.SimpleMsg' + summary: Count All VMs + tags: + - '[VM management]' + /countvm/{ConnectionName}: + get: + description: Get the total number of Virtual Machines (VMs) for a specific connection. + operationId: count-vms-by-connection + parameters: + - description: The name of the Connection + in: path + name: ConnectionName + required: true + type: string + produces: + - application/json + responses: + "200": + description: Total count of VMs for the connection + schema: + $ref: '#/definitions/spider.CountResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/spider.SimpleMsg' + summary: Count VMs by Connection + tags: + - '[VM management]' /countvpc: get: description: Get the total number of VPCs across all connections. @@ -914,20 +1364,20 @@ paths: summary: Delete CSP SecurityGroup tags: - '[SecurityGroup management]' - /cspvpc/{Id}: + /cspvm/{Id}: delete: consumes: - application/json - description: Delete a specified CSP Virtual Private Cloud (VPC). - operationId: delete-csp-vpc + description: Terminate a specified CSP Virtual Machine (VM). + operationId: terminate-csp-vm parameters: - - description: Request body for deleting a CSP VPC + - description: Request body for terminating a CSP VM in: body name: ConnectionRequest required: true schema: $ref: '#/definitions/spider.ConnectionRequest' - - description: The CSP VPC ID to delete + - description: The CSP VM ID to terminate in: path name: Id required: true @@ -936,9 +1386,9 @@ paths: - application/json responses: "200": - description: Result of the delete operation + description: Result of the terminate operation schema: - $ref: '#/definitions/spider.BooleanInfo' + $ref: '#/definitions/spider.StatusInfo' "400": description: Bad Request, possibly due to invalid JSON structure or missing fields @@ -952,26 +1402,106 @@ paths: description: Internal Server Error schema: $ref: '#/definitions/spider.SimpleMsg' - summary: Delete CSP VPC + summary: Terminate CSP VM tags: - - '[VPC management]' - /getsecuritygroupowner: - post: + - '[VM management]' + get: consumes: - application/json - description: Retrieve the owner VPC of a specified Security Group. - operationId: get-sg-owner-vpc + description: Retrieve details of a specific CSP Virtual Machine (VM). + operationId: get-csp-vm parameters: - - description: Request body for getting Security Group Owner VPC - in: body - name: GetSGOwnerVPCRequest + - description: The name of the Connection to get a CSP VM for + in: query + name: ConnectionName required: true - schema: - $ref: '#/definitions/spider.GetSGOwnerVPCRequest' - produces: - - application/json - responses: - "200": + type: string + - description: The CSP VM ID to retrieve + in: path + name: Id + required: true + type: string + produces: + - application/json + responses: + "200": + description: Details of the CSP VM + schema: + $ref: '#/definitions/spider.VMInfo' + "400": + description: Bad Request, possibly due to invalid JSON structure or missing + fields + schema: + $ref: '#/definitions/spider.SimpleMsg' + "404": + description: Resource Not Found + schema: + $ref: '#/definitions/spider.SimpleMsg' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/spider.SimpleMsg' + summary: Get CSP VM + tags: + - '[VM management]' + /cspvpc/{Id}: + delete: + consumes: + - application/json + description: Delete a specified CSP Virtual Private Cloud (VPC). + operationId: delete-csp-vpc + parameters: + - description: Request body for deleting a CSP VPC + in: body + name: ConnectionRequest + required: true + schema: + $ref: '#/definitions/spider.ConnectionRequest' + - description: The CSP VPC ID to delete + in: path + name: Id + required: true + type: string + produces: + - application/json + responses: + "200": + description: Result of the delete operation + schema: + $ref: '#/definitions/spider.BooleanInfo' + "400": + description: Bad Request, possibly due to invalid JSON structure or missing + fields + schema: + $ref: '#/definitions/spider.SimpleMsg' + "404": + description: Resource Not Found + schema: + $ref: '#/definitions/spider.SimpleMsg' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/spider.SimpleMsg' + summary: Delete CSP VPC + tags: + - '[VPC management]' + /getsecuritygroupowner: + post: + consumes: + - application/json + description: Retrieve the owner VPC of a specified Security Group. + operationId: get-sg-owner-vpc + parameters: + - description: Request body for getting Security Group Owner VPC + in: body + name: GetSGOwnerVPCRequest + required: true + schema: + $ref: '#/definitions/spider.GetSGOwnerVPCRequest' + produces: + - application/json + responses: + "200": description: Details of the owner VPC schema: $ref: '#/definitions/spider.IID' @@ -991,6 +1521,45 @@ paths: summary: Get Security Group Owner VPC tags: - '[VPC management]' + /getvmusingresources: + get: + consumes: + - application/json + description: Retrieve details of a VM using resource ID. + operationId: get-vm-using-rs + parameters: + - description: Connection name for the VM + in: query + name: ConnectionName + required: true + type: string + - description: CSP ID of the VM + in: query + name: CSPId + required: true + type: string + produces: + - application/json + responses: + "200": + description: Details of the VM using resource + schema: + $ref: '#/definitions/spider.VMUsingResources' + "400": + description: Bad Request, possibly due to invalid query parameters + schema: + $ref: '#/definitions/spider.SimpleMsg' + "404": + description: Resource Not Found + schema: + $ref: '#/definitions/spider.SimpleMsg' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/spider.SimpleMsg' + summary: Get VM Using Resource + tags: + - '[VM management]' /keypair: get: consumes: @@ -1375,6 +1944,84 @@ paths: summary: Unregister Subnet tags: - '[VPC management]' + /regvm: + post: + consumes: + - application/json + description: Register a new Virtual Machine (VM) with the specified name and + CSP ID. + operationId: register-vm + parameters: + - description: Request body for registering a VM + in: body + name: VMRegisterRequest + required: true + schema: + $ref: '#/definitions/spider.VMRegisterRequest' + produces: + - application/json + responses: + "200": + description: Details of the registered VM + schema: + $ref: '#/definitions/spider.VMInfo' + "400": + description: Bad Request, possibly due to invalid JSON structure or missing + fields + schema: + $ref: '#/definitions/spider.SimpleMsg' + "404": + description: Resource Not Found + schema: + $ref: '#/definitions/spider.SimpleMsg' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/spider.SimpleMsg' + summary: Register VM + tags: + - '[VM management]' + /regvm/{Name}: + delete: + consumes: + - application/json + description: Unregister a Virtual Machine (VM) with the specified name. + operationId: unregister-vm + parameters: + - description: Request body for unregistering a VM + in: body + name: ConnectionRequest + required: true + schema: + $ref: '#/definitions/spider.ConnectionRequest' + - description: The name of the VM to unregister + in: path + name: Name + required: true + type: string + produces: + - application/json + responses: + "200": + description: Result of the unregister operation + schema: + $ref: '#/definitions/spider.BooleanInfo' + "400": + description: Bad Request, possibly due to invalid JSON structure or missing + fields + schema: + $ref: '#/definitions/spider.SimpleMsg' + "404": + description: Resource Not Found + schema: + $ref: '#/definitions/spider.SimpleMsg' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/spider.SimpleMsg' + summary: Unregister VM + tags: + - '[VM management]' /regvpc: post: consumes: @@ -1687,6 +2334,235 @@ paths: summary: Add Rules to SecurityGroup tags: - '[SecurityGroup management]' + /vm: + get: + consumes: + - application/json + description: Retrieve a list of Virtual Machines (VMs) associated with a specific + connection. + operationId: list-vm + parameters: + - description: The name of the Connection to list VMs for + in: query + name: ConnectionName + required: true + type: string + produces: + - application/json + responses: + "200": + description: List of VMs + schema: + $ref: '#/definitions/spider.VMListResponse' + "400": + description: Bad Request, possibly due to invalid query parameter + schema: + $ref: '#/definitions/spider.SimpleMsg' + "404": + description: Resource Not Found + schema: + $ref: '#/definitions/spider.SimpleMsg' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/spider.SimpleMsg' + summary: List VMs + tags: + - '[VM management]' + post: + consumes: + - application/json + description: Start a new Virtual Machine (VM) with specified configurations. + operationId: start-vm + parameters: + - description: Request body for starting a VM + in: body + name: VMStartRequest + required: true + schema: + $ref: '#/definitions/spider.VMStartRequest' + produces: + - application/json + responses: + "200": + description: Details of the started VM + schema: + $ref: '#/definitions/spider.VMInfo' + "400": + description: Bad Request, possibly due to invalid JSON structure or missing + fields + schema: + $ref: '#/definitions/spider.SimpleMsg' + "404": + description: Resource Not Found + schema: + $ref: '#/definitions/spider.SimpleMsg' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/spider.SimpleMsg' + summary: Start VM + tags: + - '[VM management]' + /vm/{Name}: + delete: + consumes: + - application/json + description: Terminate a specified Virtual Machine (VM). + operationId: terminate-vm + parameters: + - description: Request body for terminating a VM + in: body + name: ConnectionRequest + required: true + schema: + $ref: '#/definitions/spider.ConnectionRequest' + - description: The name of the VM to terminate + in: path + name: Name + required: true + type: string + - description: Force terminate the VM + in: query + name: force + type: string + produces: + - application/json + responses: + "200": + description: Result of the terminate operation + schema: + $ref: '#/definitions/spider.StatusInfo' + "400": + description: Bad Request, possibly due to invalid JSON structure or missing + fields + schema: + $ref: '#/definitions/spider.SimpleMsg' + "404": + description: Resource Not Found + schema: + $ref: '#/definitions/spider.SimpleMsg' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/spider.SimpleMsg' + summary: Terminate VM + tags: + - '[VM management]' + get: + consumes: + - application/json + description: Retrieve details of a specific Virtual Machine (VM). + operationId: get-vm + parameters: + - description: The name of the Connection to get a VM for + in: query + name: ConnectionName + required: true + type: string + - description: The name of the VM to retrieve + in: path + name: Name + required: true + type: string + produces: + - application/json + responses: + "200": + description: Details of the VM + schema: + $ref: '#/definitions/spider.VMInfo' + "400": + description: Bad Request, possibly due to invalid JSON structure or missing + fields + schema: + $ref: '#/definitions/spider.SimpleMsg' + "404": + description: Resource Not Found + schema: + $ref: '#/definitions/spider.SimpleMsg' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/spider.SimpleMsg' + summary: Get VM + tags: + - '[VM management]' + /vmstatus: + get: + consumes: + - application/json + description: Retrieve a list of statuses for Virtual Machines (VMs) associated + with a specific connection. + operationId: list-vm-status + parameters: + - description: The name of the Connection to list VM statuses for + in: query + name: ConnectionName + required: true + type: string + produces: + - application/json + responses: + "200": + description: List of VM statuses + schema: + $ref: '#/definitions/spider.VMStatusResponse' + "400": + description: Bad Request, possibly due to invalid query parameter + schema: + $ref: '#/definitions/spider.SimpleMsg' + "404": + description: Resource Not Found + schema: + $ref: '#/definitions/spider.SimpleMsg' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/spider.SimpleMsg' + summary: List VM Statuses + tags: + - '[VM management]' + /vmstatus/{Name}: + get: + consumes: + - application/json + description: Retrieve the status of a specific Virtual Machine (VM). + operationId: get-vm-status + parameters: + - description: The name of the Connection to get a VM status for + in: query + name: ConnectionName + required: true + type: string + - description: The name of the VM to retrieve the status of + in: path + name: Name + required: true + type: string + produces: + - application/json + responses: + "200": + description: Details of the VM status + schema: + $ref: '#/definitions/spider.VMStatusResponse' + "400": + description: Bad Request, possibly due to invalid JSON structure or missing + fields + schema: + $ref: '#/definitions/spider.SimpleMsg' + "404": + description: Resource Not Found + schema: + $ref: '#/definitions/spider.SimpleMsg' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/spider.SimpleMsg' + summary: Get VM Status + tags: + - '[VM management]' /vpc: get: consumes: diff --git a/cloud-control-manager/cloud-driver/interfaces/resources/VMHandler.go b/cloud-control-manager/cloud-driver/interfaces/resources/VMHandler.go index 2aa8e2c43..9d3dd8c69 100644 --- a/cloud-control-manager/cloud-driver/interfaces/resources/VMHandler.go +++ b/cloud-control-manager/cloud-driver/interfaces/resources/VMHandler.go @@ -54,8 +54,8 @@ type VMReqInfo struct { } type VMStatusInfo struct { - IId IID // {NameId, SystemId} - VmStatus VMStatus + IId IID `json:"IId" validate:"required" example:"` // {NameId: 'vm-01', SystemId: 'i-12345678'}" + VmStatus VMStatus `json:"VmStatus" validate:"required" example:"RUNNING"` // "RUNNING,SUSPENDING,SUSPENDED,REBOOTING,TERMINATING,TERMINATED,NOTEXIST,FAILED" } // GO do not support Enum. So, define like this. @@ -79,49 +79,49 @@ const ( ) type RegionInfo struct { - Region string - Zone string + Region string `json:"Region" validate:"required" example:"us-east-1"` + Zone string `json:"Zone,omitempty" validate:"omitempty" example:"us-east-1a"` } type VMInfo struct { - IId IID // {NameId, SystemId} - StartTime time.Time // Timezone: based on cloud-barista server location. + IId IID `json:"IId" validate:"required"` // example:"{NameId: 'vm-01', SystemId: 'i-12345678'}" + StartTime time.Time `json:"StartTime" validate:"required" example:"2024-08-27T10:00:00Z"` // Timezone: based on cloud-barista server location. - Region RegionInfo // ex) {us-east1, us-east1-c} or {ap-northeast-2} - ImageType ImageType // PublicImage | MyImage - ImageIId IID - VMSpecName string // instance type or flavour, etc... ex) t2.micro or f1.micro - VpcIID IID - SubnetIID IID // AWS, ex) subnet-8c4a53e4 - SecurityGroupIIds []IID // AWS, ex) sg-0b7452563e1121bb6 + Region RegionInfo `json:"Region" validate:"required"` // example:"{Region: 'us-east-1', Zone: 'us-east-1a'}" + ImageType ImageType `json:"ImageType" validate:"required" example:"PublicImage"` // PublicImage | MyImage + ImageIId IID `json:"ImageIId" validate:"required"` // example:"{NameId: 'ami-12345678', SystemId: 'ami-12345678'}" + VMSpecName string `json:"VMSpecName" validate:"required" example:"t2.micro"` // instance type or flavour, etc... ex) t2.micro or f1.micro + VpcIID IID `json:"VpcIID" validate:"required"` // example:"{NameId: 'vpc-01', SystemId: 'vpc-12345678'}" + SubnetIID IID `json:"SubnetIID" validate:"required"` // example:"{NameId: 'subnet-01', SystemId: 'subnet-12345678'}" + SecurityGroupIIds []IID `json:"SecurityGroupIIds" validate:"required"` // example:"[{NameId: 'sg-01', SystemId: 'sg-12345678'}]" - KeyPairIId IID + KeyPairIId IID `json:"KeyPairIId" validate:"required"` // example:"{NameId: 'keypair-01', SystemId: 'keypair-12345678'}" - RootDiskType string // "SSD(gp2)", "Premium SSD", ... - RootDiskSize string // "default", "50", "1000" (GB) - RootDeviceName string // "/dev/sda1", ... + RootDiskType string `json:"RootDiskType" validate:"required" example:"gp2"` // "gp2", "Premium SSD", ... + RootDiskSize string `json:"RootDiskSize" validate:"required" example:"50"` // "default", "50", "1000" (GB) + RootDeviceName string `json:"RootDeviceName" validate:"required" example:"/dev/sda1"` // "/dev/sda1", ... - DataDiskIIDs []IID + DataDiskIIDs []IID `json:"DataDiskIIDs" validate:"required"` // example:"[{NameId: 'datadisk-01', SystemId: 'datadisk-12345678'}]" - VMBootDisk string // Deprecated soon - VMBlockDisk string // Deprecated soon + VMBootDisk string `json:"VMBootDisk,omitempty" validate:"omitempty" example:"/dev/sda1"` // Deprecated soon + VMBlockDisk string `json:"VMBlockDisk,omitempty" validate:"omitempty" example:"/dev/sda2"` // Deprecated soon - VMUserId string // ex) user1 - VMUserPasswd string + VMUserId string `json:"VMUserId" validate:"required" example:"cb-user"` // cb-user or Administrator + VMUserPasswd string `json:"VMUserPasswd,omitempty" validate:"omitempty" example:"password1234"` // Only for Windows - NetworkInterface string // ex) eth0 - PublicIP string - PublicDNS string - PrivateIP string - PrivateDNS string + NetworkInterface string `json:"NetworkInterface" validate:"required" example:"eni-12345678"` + PublicIP string `json:"PublicIP" validate:"required" example:"1.2.3.4"` + PublicDNS string `json:"PublicDNS,omitempty" validate:"omitempty" example:"ec2-1-2-3-4.compute-1.amazonaws.com"` + PrivateIP string `json:"PrivateIP" validate:"required" example:"192.168.1.1"` + PrivateDNS string `json:"PrivateDNS,omitempty" validate:"omitempty" example:"ip-192-168-1-1.ec2.internal"` - Platform Platform // LINUX | WINDOWS + Platform Platform `json:"Platform" validate:"required" example:"LINUX"` // LINUX | WINDOWS - SSHAccessPoint string // ex) 10.2.3.2:22, 123.456.789.123:4321 ==> Deprecated - AccessPoint string // ex) 10.2.3.2:22, 123.456.789.123:4321 + SSHAccessPoint string `json:"SSHAccessPoint,omitempty" validate:"omitempty" example:"10.2.3.2:22"` // Deprecated + AccessPoint string `json:"AccessPoint" validate:"required" example:"1.2.3.4:22"` // 10.2.3.2:22, 123.456.789.123:432 - TagList []KeyValue - KeyValueList []KeyValue + TagList []KeyValue `json:"TagList,omitempty" validate:"omitempty"` // example:"[{Key: 'Name', Value: 'MyVM'}]" + KeyValueList []KeyValue `json:"KeyValueList,omitempty" validate:"omitempty"` // example:"[{Key: 'Architecture', Value: 'x86_64'}]" } type VMHandler interface {