Documentation
¶
Index ¶
- Constants
- func Encrypt(raw string) string
- type API
- type AlertMetricsData
- type AuthDataGroup
- type AuthPermission
- type DataGroup
- type DatasourceGroup
- type Feature
- type FeatureMapping
- type I18nTranslation
- type InsertPage
- type LogTableInfo
- type MenuItem
- type Operator
- type OtherLogTable
- type Repo
- type Role
- type Router
- type RouterInsertPage
- type Team
- type Threshold
- type User
- type UserRole
- type UserTeam
Constants ¶
const ERROR_RATE = 5.0
const GLOBAL = "global"
User-configured threshold table
const LATENCY = 5.0
const LOG = 5.0
const TPS = 5.0
Variables ¶
This section is empty.
Functions ¶
Types ¶
type API ¶
type API struct { ID int `gorm:"primary_key;auto_increment"` Path string `gorm:"column:path;type:varchar(255);index:idx_path_method,unique" mapstructure:"path"` Method string `gorm:"column:method;type:varchar(10);index:idx_path_method,unique" mapstructure:"method"` Enabled bool `gorm:"column:enabled;default:true"` }
API represents an API endpoint definition
type AlertMetricsData ¶
type AlertMetricsData struct { Id int `json:"-" gorm:"primaryKey;autoIncrement"` Name string `json:"name" gorm:"not null;type:varchar(100);column:name"` PQL string `json:"pql" gorm:"not null;type:varchar(5000);column:pql"` Unit string `json:"unit" gorm:"not null;type:varchar(100);column:unit"` Group string `json:"group" gorm:"not null;type:varchar(100);column:group"` }
AlertMetricsData provide PQL corresponding to user selectable metrics
func (*AlertMetricsData) TableName ¶
func (a *AlertMetricsData) TableName() string
type AuthDataGroup ¶
type AuthDataGroup struct { ID int64 `gorm:"column:id;primary_key;auto_increment" json:"-"` SubjectID int64 `gorm:"column:subject_id;index:sub_type_id_idx,priority:1" json:"-"` SubjectType string `gorm:"column:subject_type;index:sub_type_id_idx,priority:2" json:"-"` // user or team GroupID int64 `gorm:"column:data_group_id;index:group_id_idx" json:"-"` Type string `gorm:"column:type;default:view" json:"type"` // view, edit User *User `gorm:"foreignKey:SubjectID;references:UserID" json:"user,omitempty"` Team *Team `gorm:"foreignKey:SubjectID;references:TeamID" json:"team,omitempty"` }
AuthDataGroup Records the permissions that users or teams have on specific data groups.
func (AuthDataGroup) MarshalJSON ¶
func (adg AuthDataGroup) MarshalJSON() ([]byte, error)
func (AuthDataGroup) TableName ¶
func (AuthDataGroup) TableName() string
type AuthPermission ¶
type AuthPermission struct { ID int `gorm:"primary_key;auto_increment" json:"id"` Type string `gorm:"column:type;index:idx_sub_id_type" json:"type"` // feature SubjectID int64 `gorm:"column:subject_id;index:idx_sub_id_type" json:"subjectId"` // Role ID, user ID or team ID SubjectType string `gorm:"column:subject_type;type:varchar(10)" json:"subjectType"` // role, user, team PermissionID int `gorm:"column:permission_id" json:"permissionId"` }
AuthPermission records which features are authorised to which subjects.
func (AuthPermission) TableName ¶
func (AuthPermission) TableName() string
type DataGroup ¶
type DataGroup struct { GroupID int64 `gorm:"column:group_id;primary_key;auto_increment" json:"groupId"` GroupName string `gorm:"column:group_name;type:varchar(20)" json:"groupName"` Description string `gorm:"column:description;type:varchar(50)" json:"description"` // The description of data group. DatasourceList []DatasourceGroup `gorm:"foreignKey:GroupID;references:GroupID" json:"datasourceList"` AuthType string `json:"authType,omitempty"` Source string `gorm:"-" json:"source,omitempty"` }
DataGroup is a collection of Datasource.
type DatasourceGroup ¶
type DatasourceGroup struct { GroupID int64 `gorm:"column:group_id;primary_key" json:"-"` Datasource string `gorm:"column:datasource;primary_key" json:"datasource"` Type string `gorm:"column:type" json:"type"` // service or namespace Category string `gorm:"column:category" json:"category"` // apm or normal }
DatasourceGroup is a mapping table of Datasource and DataGroup.
func (*DatasourceGroup) TableName ¶
func (dsg *DatasourceGroup) TableName() string
type Feature ¶
type Feature struct { FeatureID int `gorm:"column:feature_id;primary_key;auto_increment" json:"featureId"` FeatureName string `gorm:"column:feature_name;type:varchar(20)" json:"featureName"` ParentID *int `gorm:"column:parent_id" json:"-"` Custom bool `gorm:"column:custom;default:false" json:"-"` Children []Feature `gorm:"-" json:"children,omitempty" swaggerignore:"true"` Source string `gorm:"-" json:"source,omitempty"` }
Feature is a collection of APIs, frontend routes and menu items that represents the embodiment of access control.
type FeatureMapping ¶
type FeatureMapping struct { ID int `gorm:"column:id;primary_key"` FeatureID int `gorm:"column:feature_id;index:feature_mapped_idx"` MappedID int `gorm:"column:mapped_id;index:feature_mapped_idx"` MappedType string `gorm:"column:mapped_type"` // menu router api }
FeatureMapping maps feature to menu item, router and api.
func (*FeatureMapping) TableName ¶
func (t *FeatureMapping) TableName() string
type I18nTranslation ¶
type I18nTranslation struct { ID int `gorm:"column:id;primary_key;auto_increment" json:"-"` Language string `gorm:"column:language;type:varchar(20)" json:"-" mapstructure:"language"` // en, zh, etc. Translation string `gorm:"column:translation;type:varchar(50)" json:"translation" mapstructure:"translation"` FieldName string `gorm:"column:field_name;type:varchar(20)" json:"field_name" mapstructure:"field_name"` // which field is translated EntityID int `gorm:"column:entity_id" json:"-"` EntityType string `gorm:"column:entity_type;type:varchar(20)" json:"-" mapstructure:"entity_type"` // menu_item or feature }
func (I18nTranslation) TableName ¶
func (I18nTranslation) TableName() string
type InsertPage ¶
type InsertPage struct { PageID int `gorm:"column:page_id;primary_key;auto_increment" json:"pageId"` Url string `gorm:"column:url;type:varchar(150)" json:"url"` Type string `gorm:"column:type;type:varchar(20)" json:"type"` // For now it's grafana or jaeger. Custom bool `gorm:"column:custom" json:"-"` }
InsertPage saves embedded interface.
func (*InsertPage) TableName ¶
func (t *InsertPage) TableName() string
type LogTableInfo ¶
type LogTableInfo struct { ID uint `gorm:"primaryKey;autoIncrement"` DataBase string `gorm:"type:varchar(100);column:database"` Table string `gorm:"type:varchar(100);column:tablename"` Cluster string `gorm:"type:varchar(100)"` Fields string `gorm:"type:varchar(5000)"` // log field type ParseName string `gorm:"type:varchar(100);column:parsename"` RouteRule string `gorm:"type:varchar(1000);column:routerule"` // routing rule ParseRule string `gorm:"type:varchar(5000);column:parserule"` // parsing rules ParseInfo string `gorm:"type:varchar(100);column:parseinfo"` Service string `gorm:"type:varchar(100)"` IsStructured bool `gorm:"type:bool;column:structured"` }
func (LogTableInfo) TableName ¶
func (LogTableInfo) TableName() string
type MenuItem ¶
type MenuItem struct { ItemID int `gorm:"column:item_id;primary_key" json:"itemId"` Key string `gorm:"column:key;type:varchar(20);uniqueIndex" json:"key"` Label string `gorm:"-" json:"label"` // AKA item name. Icon string `gorm:"column:icon;type:varchar(150)" json:"icon"` ParentID *int `gorm:"column:parent_id" json:"-"` Abbreviation string `gorm:"-" json:"abbreviation,omitempty"` RouterID int `gorm:"column:router_id" json:"-"` Order int `gorm:"column:sort_order;index:sort_order_idx" json:"-"` // The order of a menu item. Children []MenuItem `gorm:"-" json:"children,omitempty" swaggerignore:"true"` Router *Router `gorm:"-" json:"router,omitempty"` // Frontend router. }
MenuItem is a menu item on the left or top menu bar.
type OtherLogTable ¶
type OtherLogTable struct { ID uint `gorm:"primaryKey;autoIncrement"` DataBase string `gorm:"type:varchar(100);column:database"` Table string `gorm:"type:varchar(100);column:tablename"` Cluster string `gorm:"type:varchar(100)"` TimeField string `gorm:"type:varchar(100);column:timefield"` LogField string `gorm:"type:varchar(100);column:logfield"` Instance string `gorm:"type:varchar(100)"` }
func (OtherLogTable) TableName ¶
func (OtherLogTable) TableName() string
type Repo ¶
type Repo interface { CreateOrUpdateThreshold(model *Threshold) error GetOrCreateThreshold(serviceName string, endPoint string, level string) (Threshold, error) DeleteThreshold(serviceName string, endPoint string) error OperateLogTableInfo(model *LogTableInfo, op Operator) error GetAllLogTable() ([]LogTableInfo, error) UpdateLogParseRule(model *LogTableInfo) error GetAllOtherLogTable() ([]OtherLogTable, error) OperatorOtherLogTable(model *OtherLogTable, op Operator) error CreateDingTalkReceiver(dingTalkConfig *amconfig.DingTalkConfig) error // GetDingTalkReceiver get the webhook URL secret corresponding to the uuid. GetDingTalkReceiver(uuid string) (amconfig.DingTalkConfig, error) GetDingTalkReceiverByAlertName(configFile string, alertName string, page, pageSize int) ([]*amconfig.DingTalkConfig, int64, error) UpdateDingTalkReceiver(dingTalkConfig *amconfig.DingTalkConfig, oldName string) error DeleteDingTalkReceiver(configFile, alertName string) error ListQuickAlertRuleMetric() ([]AlertMetricsData, error) Login(username, password string) (*User, error) CreateUser(ctx context.Context, user *User) error UpdateUserPhone(userID int64, phone string) error UpdateUserEmail(userID int64, email string) error UpdateUserPassword(userID int64, oldPassword, newPassword string) error UpdateUserInfo(ctx context.Context, userID int64, phone string, email string, corporation string) error GetUserInfo(userID int64) (User, error) GetAnonymousUser() (User, error) GetUserList(req *request.GetUserListRequest) ([]User, int64, error) RemoveUser(ctx context.Context, userID int64) error RestPassword(userID int64, newPassword string) error UserExists(userID ...int64) (bool, error) GetUserRole(userID int64) ([]UserRole, error) GetUsersRole(userIDs []int64) ([]UserRole, error) GetRoles(filter model.RoleFilter) ([]Role, error) GetFeature(featureIDs []int) ([]Feature, error) GetFeatureByName(name string) (int, error) GrantRoleWithUser(ctx context.Context, userID int64, roleIDs []int) error GrantRoleWithRole(ctx context.Context, roleID int, userIDs []int64) error RevokeRole(ctx context.Context, userID int64, roleIDs []int) error GetSubjectPermission(subID int64, subType string, typ string) ([]int, error) GetSubjectsPermission(subIDs []int64, subType string, typ string) ([]AuthPermission, error) RoleExists(roleID int) (bool, error) GrantPermission(ctx context.Context, subID int64, subType string, typ string, permissionIDs []int) error RevokePermission(ctx context.Context, subID int64, subType string, typ string, permissionIDs []int) error GetAddAndDeletePermissions(subID int64, subType, typ string, permList []int) (toAdd []int, toDelete []int, err error) RoleGranted(userID int64, roleID int) (bool, error) GetItemRouter(items *[]MenuItem) error GetRouterInsertedPage(routers []*Router) error GetFeatureTans(features *[]Feature, language string) error GetMenuItemTans(menuItems *[]MenuItem, language string) error CreateDataGroup(ctx context.Context, group *DataGroup) error DeleteDataGroup(ctx context.Context, groupID int64) error CreateDatasourceGroup(ctx context.Context, datasource []model.Datasource, dataGroupID int64) error DeleteDSGroup(ctx context.Context, groupID int64) error DataGroupExist(filter model.DataGroupFilter) (bool, error) UpdateDataGroup(ctx context.Context, groupID int64, groupName string, description string) error GetDataGroup(filter model.DataGroupFilter) ([]DataGroup, int64, error) RetrieveDataFromGroup(ctx context.Context, groupID int64, datasource []string) error GetGroupDatasource(groupID ...int64) ([]DatasourceGroup, error) GetFeatureMappingByFeature(featureIDs []int, mappedType string) ([]FeatureMapping, error) GetFeatureMappingByMapped(mappedID int, mappedType string) (FeatureMapping, error) GetMenuItems() ([]MenuItem, error) GetTeamList(req *request.GetTeamRequest) ([]Team, int64, error) DeleteTeam(ctx context.Context, teamID int64) error CreateTeam(ctx context.Context, team Team) error TeamExist(filter model.TeamFilter) (bool, error) GetTeam(teamID int64) (Team, error) UpdateTeam(ctx context.Context, team Team) error InviteUserToTeam(ctx context.Context, teamID int64, userIDs []int64) error AssignUserToTeam(ctx context.Context, userID int64, teamIDs []int64) error GetUserTeams(userID int64) ([]int64, error) GetTeamUsers(teamID int64) ([]int64, error) GetTeamUserList(teamID int64) ([]User, error) RemoveFromTeamByUser(ctx context.Context, userID int64, teamIDs []int64) error RemoveFromTeamByTeam(ctx context.Context, teamID int64, userIDs []int64) error DeleteAllUserTeam(ctx context.Context, id int64, by string) error GetAssignedTeam(userID int64) ([]Team, error) CreateRole(ctx context.Context, role *Role) error DeleteRole(ctx context.Context, roleID int) error UpdateRole(ctx context.Context, roleID int, roleName, description string) error GetAuthDataGroupBySub(subjectID int64, subjectType string) ([]AuthDataGroup, error) GetGroupAuthDataGroupByGroup(groupID int64, subjectType string) ([]AuthDataGroup, error) AssignDataGroup(ctx context.Context, authDataGroups []AuthDataGroup) error RevokeDataGroupByGroup(ctx context.Context, dataGroupIDs []int64, subjectID int64) error RevokeDataGroupBySub(ctx context.Context, subjectIDs []int64, groupID int64) error GetSubjectDataGroupList(subjectID int64, subjectType string, category string) ([]DataGroup, error) GetModifyAndDeleteDataGroup(subjectID int64, subjectType string, dgPermissions []request.DataGroupPermission) (toModify []AuthDataGroup, toDelete []int64, err error) DeleteAuthDataGroup(ctx context.Context, subjectID int64, subjectType string) error GetDataGroupUsers(groupID int64) ([]AuthDataGroup, error) GetDataGroupTeams(groupID int64) ([]AuthDataGroup, error) CheckGroupPermission(userID, groupID int64, typ string) (bool, error) GetAPIByPath(path string, method string) (*API, error) // GetContextDB Gets transaction form ctx. GetContextDB(ctx context.Context) *gorm.DB // WithTransaction Puts transaction into ctx. WithTransaction(ctx context.Context, tx *gorm.DB) context.Context // Transaction Starts a transaction and automatically commit and rollback. Transaction(ctx context.Context, funcs ...func(txCtx context.Context) error) error integration.ObservabilityInputManage }
Define the Database query interface
type Role ¶
type Role struct { RoleID int `gorm:"column:role_id;primary_key;auto_increment" json:"roleId"` RoleName string `gorm:"column:role_name;type:varchar(20);uniqueIndex" json:"roleName"` Description string `gorm:"column:description;type:varchar(50)" json:"description"` }
Role is a collection of feature permission.
type Router ¶
type Router struct { RouterID int `gorm:"column:router_id;primary_key" json:"routerId"` RouterTo string `gorm:"column:router_to;uniqueIndex;type:varchar(20)" json:"to"` Custom bool `gorm:"column:custom;default:false" json:"-"` HideTimeSelector bool `gorm:"column:hide_time_selector" json:"hideTimeSelector"` Page *InsertPage `gorm:"-" json:"page,omitempty"` }
Router front end router.
type RouterInsertPage ¶
type RouterInsertPage struct { ID int `gorm:"column:id"` RouterID int `gorm:"column:router_id;uniqueIndex"` PageID int `gorm:"column:page_id;"` }
RouterInsertPage maps router to inserted page.
func (RouterInsertPage) TableName ¶
func (RouterInsertPage) TableName() string
type Team ¶
type Team struct { TeamID int64 `gorm:"column:team_id;primary_key" json:"teamId"` TeamName string `gorm:"column:team_name;type:varchar(20)" json:"teamName"` Description string `gorm:"column:description;type:varchar(50)" json:"description"` UserList []User `` /* 132-byte string literal not displayed */ FeatureList []Feature `` /* 153-byte string literal not displayed */ }
type Threshold ¶
type Threshold struct { ID uint `gorm:"primaryKey;autoIncrement"` ServiceName string `gorm:"type:varchar(100)"` Level string `gorm:"type:varchar(100)"` EndPoint string `gorm:"type:varchar(100)"` Latency float64 `gorm:"type:decimal(10,2)"` Tps float64 `gorm:"type:decimal(10,2)"` ErrorRate float64 `gorm:"type:decimal(10,2)"` Log float64 `gorm:"type:decimal(10,2)"` }
type User ¶
type User struct { UserID int64 `gorm:"column:user_id;primary_key" json:"userId,omitempty"` Username string `gorm:"column:username;uniqueIdx;type:varchar(20)" json:"username,omitempty"` Password string `gorm:"column:password;type:varchar(200)" json:"-"` Phone string `gorm:"column:phone;type:varchar(20)" json:"phone,omitempty"` Email string `gorm:"column:email;type:varchar(50)" json:"email,omitempty"` Corporation string `gorm:"column:corporation;type:varchar(50)" json:"corporation,omitempty"` RoleList []Role `gorm:"many2many:user_role;joinForeignKey:UserID;joinReferences:RoleID" json:"roleList,omitempty"` TeamList []Team `gorm:"many2many:user_team;joinForeignKey:UserID;joinReferences:TeamID" json:"teamList,omitempty"` FeatureList []Feature `gorm:"-" json:"featureList,omitempty"` }
Source Files
¶
- alert_manager.go
- dao.go
- dao_api.go
- dao_auth_data_group.go
- dao_data_group.go
- dao_feature.go
- dao_i18n.go
- dao_init.go
- dao_insert_page.go
- dao_logtableinfo.go
- dao_menu.go
- dao_othertableinfo.go
- dao_permission.go
- dao_quick_alert_rule_metric.go
- dao_role.go
- dao_router.go
- dao_team.go
- dao_threshold.go
- dao_user.go
- init_api.go
- init_feature.go
- init_feature_mapping.go
- init_i18n.go
- init_insert_page.go
- init_menu_item.go
- init_permission.go
- init_role.go
- init_router.go
- init_router_page.go
- transaction.go