api

package
v1.5.38 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2022 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// multiSeparator is used for split keys from string
	MultiSeparator = ","

	QueryTaskIDKey          = "task_id"
	QueryProjectIDKey       = "project_id"
	QueryBuildIDKey         = "build_id"
	QueryStatusKey          = "status"
	QueryPriorityKey        = "priority"
	QueryCreateTimeLeftKey  = "create_time_left"
	QueryCreateTimeRightKey = "create_time_right"
	QueryCreateTimeKey      = "create_time"
	QueryStartTimeLeftKey   = "start_time_left"
	QueryStartTimeRightKey  = "start_time_right"
	QueryStartTimeKey       = "start_time"
	QueryEndTimeLeftKey     = "end_time_left"
	QueryEndTimeRightKey    = "end_time_right"
	QueryEndTimeKey         = "end_time"
	QueryProjectNameKey     = "project_name"
	QueryIPKey              = "ip"
	QueryStageTimeout       = "stage_timeout"
	QueryReleased           = "released"

	QueryOffsetKey   = "offset"
	QueryLimitKey    = "limit"
	QuerySelectorKey = "selector"
	QueryOrderKey    = "order"
)
View Source
const (

	// PathV1 describe the prefix of version 1 http action.
	PathV1 = prefix + versionV1
)

Variables

View Source
var (
	// GroupListTaskInKey implements the keys that can be filtered with "In" during task list
	GroupListTaskInKey = map[string]bool{
		QueryTaskIDKey:    true,
		QueryProjectIDKey: true,
		QueryBuildIDKey:   true,
		QueryStatusKey:    true,
		QueryPriorityKey:  true,
		QueryReleased:     true,
	}

	// GroupListTaskGtKey implements the keys that can be filtered with "Gt" during task list
	GroupListTaskGtKey = map[string]bool{
		QueryCreateTimeLeftKey: true,
		QueryStartTimeLeftKey:  true,
		QueryEndTimeLeftKey:    true,
	}

	// GroupListTaskLtKey implements the keys that can be filtered with "Lt" during task list
	GroupListTaskLtKey = map[string]bool{
		QueryStartTimeRightKey:  true,
		QueryCreateTimeRightKey: true,
		QueryEndTimeRightKey:    true,
	}

	// GroupListProjectInKey implements the keys that can be filtered with "In" during project list
	GroupListProjectInKey = map[string]bool{
		QueryProjectIDKey:   true,
		QueryProjectNameKey: true,
		QueryPriorityKey:    true,
		QueryStageTimeout:   true,
	}

	// GroupListWhitelistInKey implements the keys that can be filtered with "In" during whitelist list
	GroupListWhitelistInKey = map[string]bool{
		QueryProjectIDKey: true,
		QueryIPKey:        true,
	}

	// GroupIntKey implements the int keys
	GroupIntKey = map[string]bool{
		QueryPriorityKey:  true,
		QueryStageTimeout: true,
	}

	// GroupInt64Key implements the int64 keys
	GroupInt64Key = map[string]bool{
		QueryCreateTimeLeftKey:  true,
		QueryStartTimeLeftKey:   true,
		QueryEndTimeLeftKey:     true,
		QueryStartTimeRightKey:  true,
		QueryCreateTimeRightKey: true,
		QueryEndTimeRightKey:    true,
	}

	// GroupBoolKey implements the bool keys
	GroupBoolKey = map[string]bool{
		QueryReleased: true,
	}

	// GroupFloat64Key implements the float64 keys
	GroupFloat64Key = map[string]bool{}

	// OriginKey implements the lt and gt origin key
	OriginKey = map[string]string{
		QueryCreateTimeLeftKey:  QueryCreateTimeKey,
		QueryCreateTimeRightKey: QueryCreateTimeKey,
		QueryStartTimeLeftKey:   QueryStartTimeKey,
		QueryStartTimeRightKey:  QueryStartTimeKey,
		QueryEndTimeLeftKey:     QueryEndTimeKey,
		QueryEndTimeRightKey:    QueryEndTimeKey,
	}
)
View Source
var Rd register_discover.RegisterDiscover

Functions

func GetAPIV1Action

func GetAPIV1Action() []*httpserver.Action

GetAPIV1Action get V1 actions

func InitActionsFunc

func InitActionsFunc() error

InitActionsFunc will call all the functions in initFunc

func MasterRequired

func MasterRequired(f restful.RouteFunction) func(req *restful.Request, resp *restful.Response)

MasterRequired wrap the api handler and make it only available for master node.

func NoLimit

func NoLimit(f restful.RouteFunction) func(req *restful.Request, resp *restful.Response)

NoLimit wrap the api handler and will process all requests.

func RegisterInitFunc

func RegisterInitFunc(f func() error)

RegisterInitFunc called by actions for registering some daemon functions and these functions will be called after flag-init and server-start

func RegisterV1Action

func RegisterV1Action(action Action)

RegisterV1Action register a handler into v1 actions means all the URL of these handlers are start with PathV1

func ReturnRest

func ReturnRest(resp *RestResponse)

ReturnRest do the return work according to a RestResponse

func WithBasicGroup

func WithBasicGroup(basic map[string]bool, extra map[string]bool) map[string]bool

WithBasicGroup combine the basic keys and the extra keys. Return a new key groups.

Types

type Action

type Action httpserver.Action

Action describe the http handler action.

type DistCCServerAPIResource

type DistCCServerAPIResource struct {
	ActionsV1 []*httpserver.Action
	MySQL     distcc.MySQL
	Conf      *config.GatewayConfig
}

DistCCServerAPIResource describe all the server api resources

func GetDistCCServerAPIResource

func GetDistCCServerAPIResource() *DistCCServerAPIResource

func (*DistCCServerAPIResource) InitActions

func (a *DistCCServerAPIResource) InitActions()

type DistTaskServerAPIResource

type DistTaskServerAPIResource struct {
	ActionsV1 []*httpserver.Action
	MySQL     disttask.MySQL
	Conf      *config.GatewayConfig
}

func GetDistTaskServerAPIResource

func GetDistTaskServerAPIResource() *DistTaskServerAPIResource

func (*DistTaskServerAPIResource) InitActions

func (a *DistTaskServerAPIResource) InitActions()

type FBServerAPIResource

type FBServerAPIResource struct {
	ActionsV1 []*httpserver.Action
	MySQL     fastbuild.MySQL
	Conf      *config.GatewayConfig
}

func GetFBServerAPIResource

func GetFBServerAPIResource() *FBServerAPIResource

func (*FBServerAPIResource) InitActions

func (a *FBServerAPIResource) InitActions()

type ProcessType

type ProcessType string
const (
	ProcessMasterOnly ProcessType = "master_only"
	ProcessNoLimit    ProcessType = "no_limit"
)

type RestResponse

type RestResponse struct {
	Resp     *restful.Response
	HTTPCode int

	Data    interface{}
	ErrCode commonTypes.ServerErrCode
	Message string
	Extra   map[string]interface{}

	WrapFunc func([]byte) []byte
}

RestResponse contains all response information need by a http handler

type XNAPISServerAPIResource

type XNAPISServerAPIResource struct {
	ActionsV1 []*httpserver.Action
	MySQL     apisjob.MySQL
	Conf      *config.GatewayConfig
}

func GetXNAPISServerAPIResource

func GetXNAPISServerAPIResource() *XNAPISServerAPIResource

func (*XNAPISServerAPIResource) InitActions

func (a *XNAPISServerAPIResource) InitActions()

Directories

Path Synopsis
v1

Jump to

Keyboard shortcuts

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