api

package
v0.0.0-...-203c0f7 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Copyright 2014 lessOS.com. All rights reserved.

Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.

Index

Constants

View Source
const (
	ErrCodeBadArgument   = "BadArgument"
	ErrCodeInternalError = "InternalError"
	ErrCodeNotFound      = "NotFound"
)
View Source
const (
	TermTag      = "tag"
	TermTaxonomy = "taxonomy"
)
View Source
const (
	Version = "0.0.0.dev00"
)

Variables

View Source
var (
	NodeIdReg           = regexp.MustCompile("^[0-9a-f]{12}$")
	NodeExtNodeReferReg = regexp.MustCompile("^[0-9a-f]{12,16}$")
)
View Source
var (
	LangArray = []*LangEntry{
		{"en-US", "English"},
		{"zh-CN", "简体中文"},
		{"zh-TW", "繁體中文"},
	}
)
View Source
var (
	NodeFieldTypes = []string{
		"bool",
		"string",
		"text",
		"date",
		"datetime",
		"int8",
		"int16",
		"int32",
		"int64",
		"uint8",
		"uint16",
		"uint32",
		"uint64",
		"float",
		"decimal",
	}
)
View Source
var (
	PermalinkNameReg = regexp.MustCompile("^[0-9a-z_-]{1,100}$")
)
View Source
var (
	SrvNameReg = regexp.MustCompile("^[0-9a-z\\-_]{1,50}$")
)

Functions

func LangHit

func LangHit(ls []*LangEntry, lang string) string

func LangsStringFilter

func LangsStringFilter(str string) string

func LangsStringFilterArray

func LangsStringFilterArray(str string) types.ArrayString

func NsSysDataPull

func NsSysDataPull() []byte

func NsSysNodeSearch

func NsSysNodeSearch(bukname string) []byte

func NsTextSearchCacheNodeEntry

func NsTextSearchCacheNodeEntry(bukname, id string) []byte

func ObjPrint

func ObjPrint(name string, obj interface{})

func PermalinkNameFilter

func PermalinkNameFilter(name string) (string, error)

func SrvNameFilter

func SrvNameFilter(name string) (string, error)

Types

type Action

type Action struct {
	types.TypeMeta `json:",inline"`
	Name           string       `json:"name"`
	ModName        string       `json:"modname,omitempty"`
	Datax          []ActionData `json:"datax,omitempty"`
}

type ActionData

type ActionData struct {
	Name     string `json:"name"`
	Type     string `json:"type"`
	Pager    bool   `json:"pager,omitempty"`
	Query    Query  `json:"query,omitempty"`
	CacheTTL int64  `json:"cache_ttl,omitempty"` // cache time to live in milliseconds
}

type FieldModel

type FieldModel struct {
	Name        string        `json:"name"`
	Type        string        `json:"type"`
	Length      string        `json:"length,omitempty"`
	Extra       []string      `json:"extra,omitempty"`
	Attrs       types.KvPairs `json:"attrs,omitempty"`
	IndexType   int           `json:"indexType,omitempty"`
	Title       string        `json:"title"`
	EditDisable bool          `json:"edit_disable,omitempty"`
	Comment     string        `json:"comment,omitempty"`
}

type FsFile

type FsFile struct {
	types.TypeMeta `json:",inline"`
	SelfLink       string `json:"self_link,omitempty"`
	Path           string `json:"path,omitempty"`
	PathSet        string `json:"pathSet,omitempty"`
	Name           string `json:"name,omitempty"`
	Size           int64  `json:"size,omitempty"`
	Mime           string `json:"mime,omitempty"`
	Body           string `json:"body,omitempty"`
	SumCheck       string `json:"sumcheck,omitempty"`
	IsDir          bool   `json:"isdir,omitempty"`
	ModTime        string `json:"modtime,omitempty"`
	Encode         string `json:"encode,omitempty"`
}

type FsFileList

type FsFileList struct {
	types.TypeMeta `json:",inline"`
	Path           string   `json:"path,omitempty"`
	Items          []FsFile `json:"items,omitempty"`
}

type LangEntry

type LangEntry struct {
	Id   string `json:"id"`
	Name string `json:"name"`
}

type LangList

type LangList struct {
	types.TypeMeta `json:",inline"`
	Items          []*LangEntry `json:"items"`
}

type Node

type Node struct {
	types.TypeMeta     `json:",inline"`
	SelfLink           string       `json:"self_link,omitempty"`
	Model              *NodeModel   `json:"model,omitempty"`
	ID                 string       `json:"id,omitempty"`
	PID                string       `json:"pid,omitempty"`
	Status             int16        `json:"status,omitempty"`
	UserID             string       `json:"userid,omitempty"`
	Title              string       `json:"title,omitempty"`
	Created            uint32       `json:"created,omitempty"`
	Updated            uint32       `json:"updated,omitempty"`
	Fields             []*NodeField `json:"fields,omitempty"`
	Terms              []NodeTerm   `json:"terms,omitempty"`
	ExtAccessCounter   uint32       `json:"ext_access_counter,omitempty"`
	ExtCommentEnable   bool         `json:"ext_comment_enable,omitempty"`
	ExtCommentPerEntry bool         `json:"ext_comment_perentry,omitempty"`
	ExtPermalinkName   string       `json:"ext_permalink_name,omitempty"`
	ExtNodeRefer       string       `json:"ext_node_refer,omitempty"`
}

func (*Node) Field

func (item *Node) Field(name string) *NodeField

type NodeField

type NodeField struct {
	Name   string          `json:"name"`
	Value  string          `json:"value,omitempty"`
	Langs  *NodeFieldLangs `json:"langs,omitempty"`
	Attrs  types.KvPairs   `json:"attrs,omitempty"`
	Caches types.KvPairs   `json:"caches,omitempty"`
}

type NodeFieldLangs

type NodeFieldLangs struct {
	Items types.KvPairs `json:"items,omitempty"`
}

type NodeFieldTextRenderOptions

type NodeFieldTextRenderOptions struct {
	AbsolutePrefix string
}

type NodeFieldType

type NodeFieldType string
const (
	NodeFieldBool     NodeFieldType = "bool"
	NodeFieldString   NodeFieldType = "string"
	NodeFieldText     NodeFieldType = "text"
	NodeFieldDate     NodeFieldType = "date"
	NodeFieldDateTime NodeFieldType = "datetime"
	NodeFieldInt8     NodeFieldType = "int8"
	NodeFieldInt16    NodeFieldType = "int16"
	NodeFieldInt32    NodeFieldType = "int32"
	NodeFieldInt64    NodeFieldType = "int64"
	NodeFieldUint8    NodeFieldType = "uint8"
	NodeFieldUint16   NodeFieldType = "uint16"
	NodeFieldUint32   NodeFieldType = "uint32"
	NodeFieldUint64   NodeFieldType = "uint64"
	NodeFieldFloat    NodeFieldType = "float"
	NodeFieldDecimal  NodeFieldType = "decimal"
)

type NodeList

type NodeList struct {
	types.TypeMeta `json:",inline"`
	Meta           types.ListMeta `json:"meta,omitempty"`
	Model          *NodeModel     `json:"model,omitempty"`
	Items          []Node         `json:"items,omitempty"`
}

type NodeModel

type NodeModel struct {
	types.TypeMeta `json:",inline"`
	Meta           types.ObjectMeta `json:"meta,omitempty"`
	ModName        string           `json:"modname,omitempty"`
	SrvName        string           `json:"-"`
	Status         int16            `json:"status,omitempty"`
	Title          string           `json:"title,omitempty"`
	Comment        string           `json:"comment,omitempty"`
	Fields         []FieldModel     `json:"fields,omitempty"`
	Terms          []TermModel      `json:"terms,omitempty"`
	Extensions     SpecExtensions   `json:"extensions,omitempty"`
}

func (*NodeModel) Field

func (item *NodeModel) Field(name string) *FieldModel

type NodeModelList

type NodeModelList struct {
	types.TypeMeta `json:",inline"`
	Items          []NodeModel `json:"items,omitempty"`
}

type NodeTerm

type NodeTerm struct {
	Name  string `json:"name"`
	Value string `json:"value,omitempty"`
	Type  string `json:"type,omitempty"`
	Items []Term `json:"items,omitempty"`
}

type Query

type Query struct {
	Spec   string   `json:"spec,omitempty"`
	Table  string   `json:"table,omitempty"`
	Fields string   `json:"fields,omitempty"`
	Order  string   `json:"order,omitempty"`
	Limit  int64    `json:"limit,omitempty"`
	Offset int64    `json:"offset,omitempty"`
	Filter []string `json:"filter,omitempty"`
}

type Route

type Route struct {
	types.TypeMeta `json:",inline"`
	Path           string            `json:"path"` // e.g. /app/:id
	DataAction     string            `json:"dataAction,omitempty"`
	Template       string            `json:"template,omitempty"` // e.g. index.tpl
	Params         map[string]string `json:"params,omitempty"`
	Tree           []string          `json:"-"`
	ModName        string            `json:"modname,omitempty"`
	Default        bool              `json:"default,omitempty"`
}

type Router

type Router struct {
	Routes []Route `json:"routes,omitempty"`
}

type Spec

type Spec struct {
	types.TypeMeta `json:",inline"`
	Meta           types.InnerObjectMeta `json:"meta,omitempty"`
	SrvName        string                `json:"srvname"`
	Status         int16                 `json:"status,omitempty"`
	Title          string                `json:"title"`
	Comment        string                `json:"comment,omitempty"`
	NodeModels     []*NodeModel          `json:"nodeModels,omitempty"`
	TermModels     []TermModel           `json:"termModels,omitempty"`
	Actions        []Action              `json:"actions,omitempty"`
	Views          []View                `json:"views,omitempty"`
	Router         Router                `json:"router,omitempty"`
	ThemeConfig    string                `json:"theme_config,omitempty"`
}

func (*Spec) NodeModelGet

func (it *Spec) NodeModelGet(name string) *NodeModel

type SpecExtensions

type SpecExtensions struct {
	AccessCounter   bool   `json:"access_counter,omitempty"`
	CommentEnable   bool   `json:"comment_enable,omitempty"`
	CommentPerEntry bool   `json:"comment_perentry,omitempty"`
	Permalink       string `json:"permalink,omitempty"`
	NodeRefer       string `json:"node_refer,omitempty"`
	NodeSubRefer    string `json:"node_sub_refer,omitempty"`
	TextSearch      bool   `json:"text_search,omitempty"`
}

type SpecList

type SpecList struct {
	types.TypeMeta `json:",inline"`
	Items          []Spec `json:"items,omitempty"`
}

type SpecUploadCommit

type SpecUploadCommit struct {
	types.TypeMeta `json:",inline"`
	Size           int64  `json:"size"`
	Name           string `json:"name"`
	Data           string `json:"data"`
}

type SpecVersion

type SpecVersion string

func NewSpecVersion

func NewSpecVersion(vstr string) *SpecVersion

func (*SpecVersion) Add

func (v *SpecVersion) Add(major, minor, patch int32) *SpecVersion

func (*SpecVersion) Compare

func (v *SpecVersion) Compare(other *SpecVersion) int

Compare compares this version to another version. This returns -1, 0, or 1 if this version is smaller, equal, or larger than the compared version, respectively.

func (*SpecVersion) String

func (v *SpecVersion) String() string

func (*SpecVersion) Valid

func (v *SpecVersion) Valid() bool

type SysConfig

type SysConfig struct {
	Key     string `json:"key"`
	Value   string `json:"value"`
	Comment string `json:"comment,omitempty"`
	Type    string `json:"type,omitempty"`
}

type SysConfigList

type SysConfigList struct {
	types.TypeMeta `json:",inline"`
	Items          []SysConfig `json:"items,omitempty"`
}

func (*SysConfigList) Fetch

func (ls *SysConfigList) Fetch(key string) *SysConfig

func (*SysConfigList) FetchString

func (ls *SysConfigList) FetchString(key string) string

func (*SysConfigList) Insert

func (ls *SysConfigList) Insert(entry SysConfig)

func (*SysConfigList) Remove

func (ls *SysConfigList) Remove(key string)

type SysIamStatus

type SysIamStatus struct {
	types.TypeMeta     `json:",inline"`
	ServiceUrl         string             `json:"service_url"`
	ServiceUrlFrontend string             `json:"service_url_frontend"`
	InstanceSelf       iamapi.AppInstance `json:"instance_self"`
	InstanceRegistered iamapi.AppInstance `json:"instance_registered"`
}

type SysMemStats

type SysMemStats struct {
	//
	Alloc      uint64 `json:"alloc"`
	TotalAlloc uint64 `json:"total_alloc"`
	Sys        uint64 `json:"sys"`
	//
	NextGC       uint64 `json:"next_gc"`
	LastGC       uint64 `json:"last_gc"`
	PauseTotalNs uint64 `json:"pause_total_ns"`
	NumGC        uint32 `json:"num_gc"`
}

type SysStatus

type SysStatus struct {
	types.TypeMeta  `json:",inline"`
	Meta            types.ObjectMeta `json:"meta,omitempty"`
	InstanceID      string           `json:"instance_id,omitempty"`
	AppVersion      string           `json:"app_version,omitempty"`
	AppRelease      string           `json:"app_release,omitempty"`
	RuntimeVersion  string           `json:"runtime_version,omitempty"`
	Uptime          string           `json:"uptime,omitempty"`
	CoroutineNumber int              `json:"coroutine_number,omitempty"`
	Info            SysStatusInfo    `json:"info"`
	MemStats        SysMemStats      `json:"memstats"`
}

type SysStatusInfo

type SysStatusInfo struct {
	CpuNum    int       `json:"cpu_num"`
	Uptime    int64     `json:"uptime"`
	Loads     [3]uint64 `json:"loads"`
	MemTotal  uint64    `json:"mem_total"`
	MemFree   uint64    `json:"mem_free"`
	MemShared uint64    `json:"mem_shared"`
	MemBuffer uint64    `json:"mem_buffer"`
	MemUsed   uint64    `json:"mem_used"`
	SwapTotal uint64    `json:"swap_total"`
	SwapFree  uint64    `json:"swap_free"`
	Procs     uint16    `json:"procs"`
}

type Term

type Term struct {
	types.TypeMeta `json:",inline"`
	Model          *TermModel `json:"model,omitempty"`
	ID             uint32     `json:"id,omitempty"`
	PID            uint32     `json:"pid,omitempty"`
	UID            string     `json:"uid,omitempty"`
	Status         int16      `json:"status,omitempty"`
	UserID         string     `json:"userid,omitempty"`
	Title          string     `json:"title"`
	Weight         int32      `json:"weight,omitempty"`
	Created        uint32     `json:"created,omitempty"`
	Updated        uint32     `json:"updated,omitempty"`
}

type TermList

type TermList struct {
	types.TypeMeta `json:",inline"`
	Meta           types.ListMeta `json:"meta,omitempty"`
	Model          *TermModel     `json:"model,omitempty"`
	Items          []Term         `json:"items"`
}

type TermModel

type TermModel struct {
	types.TypeMeta `json:",inline"`
	Meta           types.ObjectMeta `json:"meta,omitempty"`
	ModName        string           `json:"modname,omitempty"`
	Status         int16            `json:"status,omitempty"`
	Type           string           `json:"type,omitempty"`
	Title          string           `json:"title,omitempty"`
	Comment        string           `json:"comment,omitempty"`
}

type TermModelList

type TermModelList struct {
	types.TypeMeta `json:",inline"`
	Items          []TermModel `json:"items,omitempty"`
}

type View

type View struct {
	Path string `json:"path"`
}

type ViewList

type ViewList struct {
	types.TypeMeta `json:",inline"`
	Items          []View `json:"items,omitempty"`
}

Jump to

Keyboard shortcuts

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