httpserver

package
v0.0.0-...-bd520fb Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 6, 2021 License: MIT Imports: 32 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SUCCESS_CODE = 0

	NOT_FOUND_ERROR_CODE = 10001
	UNKNOWN_ERROR_CODE   = 10002
	SERVER_ERROR_CODE    = 10003

	// Request error codes
	PARAMETER_ERROR_CODE = 20001
	AUTH_ERROR_CODE      = 20002

	// APP error codes
	APP_ERROR_CODE              = 30000
	FILETYPE_NOT_SUPPORTED_CODE = 30001
	SAVE_FILE_ERROR_CODE        = 30002
	EXTRACT_FILE_ERROR_CODE     = 30003
	REMOVE_FILE_ERROR_CODE      = 30004
	FILEPATH_NOT_EXISTS_CODE    = 30005
	FILE_OVERSIZE_CODE          = 30006
	FILEPATH_NOT_VALID_CODE     = 30007
	COMPRESS_PATH_ERROR_CODE    = 30008

	// application
	APP_STILL_HAVE_DEPLOY = 30101

	REMOTE_SERVE_ERROR_CODE = 40000
)
View Source
const (
	InvalidClusterId int64 = -1
	InvalidGroupId   int64 = -1
	InvalidUserId    int64 = -1
)

user manage

Variables

View Source
var (
	ErrInvalidClusterId = errors.New("Invalid cluster id")
	ErrInvalidGroupId   = errors.New("Invalid group id")
	ErrInvalidUserId    = errors.New("Invalid user id")
	ErrInvalidUserInfo  = errors.New("Invalid user info")
	ErrOrgNameNeeded    = errors.New("Need org name")
	ErrIDontHaveOrg     = errors.New("I don`t have this org")
)

Functions

func AddBatchNode

func AddBatchNode(c *gin.Context) error

func ApplicationHandlerRoutes

func ApplicationHandlerRoutes(r *gin.Engine)

func Auth

func Auth() gin.HandlerFunc

func ConfirmNodesBatch

func ConfirmNodesBatch(c *gin.Context) error

func CreateEdgeApp

func CreateEdgeApp(c *gin.Context) error

create edge application this interface can both create basic app and app version

func CreateEdgeNode

func CreateEdgeNode(c *gin.Context) error

@Summary create edge node @Description create edge node @Tags node @Accept json @Produce json @Param param body node.CreateEdgeNodeReq true "userId:user id, userName: user name" @Success 200 {object} APISuccessResp{data=node.CreateEdgeNodeRsp} @Failure 400 {object} APIErrorResp @Router /createNode [post]

func CreateImageOrg

func CreateImageOrg(c *gin.Context) error

create org

func CreateNodeBatch

func CreateNodeBatch(c *gin.Context) error

func DeleteEdgeApp

func DeleteEdgeApp(c *gin.Context) error

delete edge application

func DeleteEdgeAppVersion

func DeleteEdgeAppVersion(c *gin.Context) error

delete edge application version

func DeleteEdgeNode

func DeleteEdgeNode(c *gin.Context) error

delete edge node

func DeleteImage

func DeleteImage(c *gin.Context) error

delete image

func DeleteImageOrg

func DeleteImageOrg(c *gin.Context) error

delete org

func DeleteImageVersion

func DeleteImageVersion(c *gin.Context) error

delete image version

func DeleteNodeOfBatch

func DeleteNodeOfBatch(c *gin.Context) error

func DeployEdgeApp

func DeployEdgeApp(c *gin.Context) error

deploy edge application

func DescribeContainerImage

func DescribeContainerImage(c *gin.Context) error

describe image

func DescribeContainerImageVersion

func DescribeContainerImageVersion(c *gin.Context) error

describe image version

func DescribeEdgeApp

func DescribeEdgeApp(c *gin.Context) error

describe edge application

func DescribeEdgeAppVersion

func DescribeEdgeAppVersion(c *gin.Context) error

describe edge application version

func DescribeEdgeNode

func DescribeEdgeNode(c *gin.Context) error

describe edge nodes

func GetInstallScripts

func GetInstallScripts(c *gin.Context) error

func GetTempNodesBatchList

func GetTempNodesBatchList(c *gin.Context) error

func GetUserInfo

func GetUserInfo(c *gin.Context) (int64, int64, int64, error)

Get user info from context

func HandleNotFound

func HandleNotFound(c *gin.Context)

func HandleProb

func HandleProb(c *gin.Context)

func ImageHandlerRoutes

func ImageHandlerRoutes(r *gin.Engine)

func InitAuth

func InitAuth(config *configs.EdgeCloudConfig) error

func ListArchType

func ListArchType(c *gin.Context) error

func ListContainerImage

func ListContainerImage(c *gin.Context) error

func ListContainerImageVersion

func ListContainerImageVersion(c *gin.Context) error

func ListEdgeAppDeploys

func ListEdgeAppDeploys(c *gin.Context) error

list edge app deploys

func ListEdgeAppVersions

func ListEdgeAppVersions(c *gin.Context) error

list edge app versions

func ListEdgeApps

func ListEdgeApps(c *gin.Context) error

list edge apps

func ListEdgeNodeType

func ListEdgeNodeType(c *gin.Context) error

func ListEdgeNodes

func ListEdgeNodes(c *gin.Context) error

@Summary list edge nodes @Description list edge nodes @Tags node @Accept json @Produce json @Param param body node.ListEdgeNodesReq true "userId:user id, userName: user name" @Success 200 {object} APISuccessResp{data=node.ListEdgeNodesRsp} "code:0, msg:OK" @Failure 400 {object} APIErrorResp "code:30000, msg:db error" @Router /listNode [post]

func ListImageOrg

func ListImageOrg(c *gin.Context) error

list org

func ListNodeCanDeploy

func ListNodeCanDeploy(c *gin.Context) error

list node can deploy

func ListNodeDeploys

func ListNodeDeploys(c *gin.Context) error

list node deploys

func NewRouter

func NewRouter() *gin.Engine

@title ApulisEdge Cloud API @version alpha @description ApulisEdge cloud server.

func NoReqSuccessResp

func NoReqSuccessResp(c *gin.Context, content interface{}) error

func NodeHandlerRoutes

func NodeHandlerRoutes(r *gin.Engine)

func OfflineEdgeAppVersion

func OfflineEdgeAppVersion(c *gin.Context) error

offline app version

func PublishEdgeAppVersion

func PublishEdgeAppVersion(c *gin.Context) error

publish app version

func StartApiServer

func StartApiServer(config *configs.EdgeCloudConfig) *http.Server

Start API server for portal

func StopApiServer

func StopApiServer(srv *http.Server)

Stop API server for portal

func SuccessResp

func SuccessResp(c *gin.Context, req *proto.Message, content interface{}) error

////////////// Success Message //////////////////

func UnDeployEdgeApp

func UnDeployEdgeApp(c *gin.Context) error

undeploy edge application

func UploadContainerImage

func UploadContainerImage(c *gin.Context) error

upload container image

func UploadNodeFile

func UploadNodeFile(c *gin.Context) error

Types

type APIErrorResp

type APIErrorResp struct {
	Code int    `json:"code"`
	Msg  string `json:"msg"`
}

func AppError

func AppError(c *gin.Context, req *proto.Message, errCode int, msg string) *APIErrorResp

func ErrorNoBodyResp

func ErrorNoBodyResp(code int, msg string) *APIErrorResp

func ErrorResp

func ErrorResp(c *gin.Context, req *proto.Message, code int, msg string) (*proto.Message, *APIErrorResp)

func NoBodyUnAuthorizedError

func NoBodyUnAuthorizedError(msg string) *APIErrorResp

func NoReqAppError

func NoReqAppError(c *gin.Context, msg string) *APIErrorResp

func NotFoundError

func NotFoundError(c *gin.Context, req *proto.Message) *APIErrorResp

func ParameterError

func ParameterError(c *gin.Context, req *proto.Message, msg string) *APIErrorResp

func PreHandler

func PreHandler(c *gin.Context, req *proto.Message, reqContent interface{}) (*proto.ApulisHeader, *APIErrorResp)

pre handler is used to handle the common logic of each comming request

func ServeError

func ServeError(c *gin.Context, req *proto.Message, errCode int, msg string) *APIErrorResp

func ServerError

func ServerError(c *gin.Context, req *proto.Message) *APIErrorResp

func UnAuthorizedError

func UnAuthorizedError(c *gin.Context, req *proto.Message, msg string) *APIErrorResp

func UnknownError

func UnknownError(c *gin.Context, req *proto.Message, msg string) *APIErrorResp

func (*APIErrorResp) Error

func (e *APIErrorResp) Error() string

////////////// Error Message //////////////////

type APISuccessResp

type APISuccessResp struct {
	Code int         `json:"code"`
	Msg  string      `json:"msg"`
	Data interface{} `json:"data"`
}

type HandlerFunc

type HandlerFunc func(c *gin.Context) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL