Documentation
¶
Index ¶
- Constants
- func ValidRelationType(relationType string) bool
- type ActionContext
- type ActionRuntimeSpec
- type ActionSpec
- type Attribute
- type AttributeGroup
- type Binding
- type BindingGraph
- type BindingGraphEdge
- type BindingGraphNode
- type FieldMapping
- type Filter
- type ModelGroupSpec
- type ModelRelation
- type ModelSpec
- type Plugin
- type RelationType
- type ResolveRequest
- type ResolveResult
- type ResolvedInput
- type ResolvedResource
- type ResourceAction
- type ResourceActions
- type ResourceSpec
- type RuntimeSidebarResourceSpec
- type RuntimeSidebarSpec
- type RuntimeSpec
- type Schema
Constants ¶
View Source
const ( RuntimeModeBuiltin = "builtin" RuntimeModeExternalService = "external-service" HeaderPluginID = "X-ECMDB-Plugin-ID" WellKnownPath = "/.well-known/ecmdb-plugin" )
View Source
const ( DirectionToSource = "source" DirectionToTarget = "target" )
View Source
const ( RelationTypeDefault = "default" RelationTypeGroup = "group" RelationTypeBelong = "belong" RelationTypeRun = "run" )
View Source
const ( MappingOneToOne = "one_to_one" MappingOneToMany = "one_to_many" MappingManyToMany = "many_to_many" )
View Source
const ( CardinalityOne = "one" CardinalityMany = "many" )
View Source
const PlacementResourceDetailActions = "resource.detail.actions"
Variables ¶
This section is empty.
Functions ¶
func ValidRelationType ¶
ValidRelationType 校验 relationType 是否为平台已知关联类型
Types ¶
type ActionContext ¶
type ActionContext struct {
Plugin Plugin `json:"plugin"`
Binding Binding `json:"binding"`
Action ActionSpec `json:"action"`
ResourceID int64 `json:"resource_id"`
Inputs map[string]ResolvedInput `json:"inputs"`
Params map[string]any `json:"params,omitempty"`
}
type ActionRuntimeSpec ¶
type ActionRuntimeSpec struct {
Layout string `json:"layout,omitempty" bson:"layout,omitempty"`
Title string `json:"title,omitempty" bson:"title,omitempty"`
Props map[string]any `json:"props,omitempty" bson:"props,omitempty"`
Sidebar *RuntimeSidebarSpec `json:"sidebar,omitempty" bson:"sidebar,omitempty"`
}
type ActionSpec ¶
type ActionSpec struct {
Action string `json:"action" bson:"action"`
Name string `json:"name" bson:"name"`
Icon string `json:"icon" bson:"icon"`
Placement string `json:"placement" bson:"placement"`
Permission string `json:"permission,omitempty" bson:"permission,omitempty"`
BindingUID string `json:"binding_uid,omitempty" bson:"binding_uid,omitempty"`
Runtime *ActionRuntimeSpec `json:"runtime,omitempty" bson:"runtime,omitempty"`
Meta map[string]any `json:"meta,omitempty" bson:"meta,omitempty"`
}
type Attribute ¶
type Attribute struct {
UID string `json:"uid"`
Name string `json:"name"`
Type string `json:"type"`
Option any `json:"option,omitempty"`
Required bool `json:"required,omitempty"`
Display bool `json:"display,omitempty"`
Secure bool `json:"secure,omitempty"`
Builtin bool `json:"builtin,omitempty"`
Index int64 `json:"index,omitempty"`
}
type AttributeGroup ¶
type Binding ¶
type BindingGraph ¶
type BindingGraph struct {
EntryNodeID string `json:"entry_node_id"`
Nodes []BindingGraphNode `json:"nodes"`
Edges []BindingGraphEdge `json:"edges,omitempty"`
}
type BindingGraphEdge ¶
type BindingGraphNode ¶
type FieldMapping ¶
type ModelGroupSpec ¶
type ModelGroupSpec struct {
Name string `json:"name"`
}
type ModelRelation ¶
type Plugin ¶
type Plugin struct {
ID int64 `json:"id" bson:"id"`
UID string `json:"uid" bson:"uid"`
Name string `json:"name" bson:"name"`
Type string `json:"type" bson:"type"`
Version string `json:"version" bson:"version"`
Actions []ActionSpec `json:"actions" bson:"actions"`
Meta map[string]any `json:"meta,omitempty" bson:"meta,omitempty"`
Ctime int64 `json:"ctime,omitempty" bson:"ctime,omitempty"`
Utime int64 `json:"utime,omitempty" bson:"utime,omitempty"`
}
func (Plugin) FindAction ¶
func (p Plugin) FindAction(name string) (ActionSpec, bool)
func (Plugin) ResourceActions ¶
func (p Plugin) ResourceActions() []ResourceAction
func (Plugin) Runtime ¶
func (p Plugin) Runtime() (RuntimeSpec, bool)
func (*Plugin) SetRuntime ¶
func (p *Plugin) SetRuntime(spec RuntimeSpec)
type RelationType ¶
type RelationType struct {
UID string `json:"uid"`
Name string `json:"name"`
SourceDescribe string `json:"source_describe,omitempty"`
TargetDescribe string `json:"target_describe,omitempty"`
}
func BasicRelationTypes ¶ added in v1.11.4
func BasicRelationTypes() []RelationType
BasicRelationTypes 返回 ECMDB 内置预设的基础关联类型定义
type ResolveRequest ¶
type ResolveRequest struct {
PluginID string `json:"plugin_id"`
Action string `json:"action"`
ResourceID int64 `json:"resource_id"`
Params map[string]any `json:"params,omitempty"`
}
func (ResolveRequest) Validate ¶
func (req ResolveRequest) Validate() error
type ResolveResult ¶
type ResolveResult struct {
PluginID string `json:"plugin_id"`
PluginName string `json:"plugin_name"`
PluginVersion string `json:"plugin_version,omitempty"`
ActionName string `json:"action_name"`
Action string `json:"action"`
Permission string `json:"permission,omitempty"`
BindingUID string `json:"binding_uid,omitempty"`
ModelUID string `json:"model_uid,omitempty"`
ResourceID int64 `json:"resource_id"`
Inputs map[string]ResolvedInput `json:"inputs"`
Params map[string]any `json:"params,omitempty"`
Runtime *ActionRuntimeSpec `json:"runtime,omitempty"`
Meta map[string]any `json:"meta,omitempty"`
}
type ResolvedInput ¶
type ResolvedInput struct {
Name string `json:"name"`
Cardinality string `json:"cardinality"`
Resources []ResolvedResource `json:"resources"`
}
type ResolvedResource ¶
type ResourceAction ¶
type ResourceAction struct {
PluginID string `json:"plugin_id"`
Action string `json:"action"`
Name string `json:"name"`
Icon string `json:"icon"`
Placement string `json:"placement"`
Permission string `json:"permission,omitempty"`
BindingUID string `json:"binding_uid,omitempty"`
Runtime *ActionRuntimeSpec `json:"runtime,omitempty"`
Meta map[string]any `json:"meta,omitempty"`
}
type ResourceActions ¶
type ResourceActions struct {
ResourceID int64 `json:"resource_id"`
Actions []ResourceAction `json:"actions"`
}
type ResourceSpec ¶
type ResourceSpec struct {
Name string `json:"name"` // 资源名称 (Go struct 中的字段名)
ModelUID string `json:"model_uid"` // CMDB 模型 UID
ModelName string `json:"model_name,omitempty"` // CMDB 模型中文展示名称
GroupName string `json:"group_name,omitempty"` // 所属模型分组名称
RelationType string `json:"relation_type,omitempty"` // 关联类型 UID
Direction string `json:"direction,omitempty"` // 关联查询方向:auto / source / target
Cardinality string `json:"cardinality"` // 数量基数:one / many
Required bool `json:"required"` // 是否必填/必存在
Fields map[string]string `json:"fields"` // 字段映射 [Go 属性字段名]CMDB 属性字段 UID
RequiredFields []string `json:"required_fields,omitempty"` // 必填/非空属性字段列表
Filters []Filter `json:"filters,omitempty"` // 过滤条件
Children []ResourceSpec `json:"children,omitempty"` // 子级关联资源列表
}
type RuntimeSidebarResourceSpec ¶
type RuntimeSidebarResourceSpec struct {
ModelUID string `json:"model_uid,omitempty" bson:"model_uid,omitempty"`
TitleField string `json:"title_field,omitempty" bson:"title_field,omitempty"`
SubtitleField string `json:"subtitle_field,omitempty" bson:"subtitle_field,omitempty"`
SearchFields []string `json:"search_fields,omitempty" bson:"search_fields,omitempty"`
Limit int `json:"limit,omitempty" bson:"limit,omitempty"`
}
type RuntimeSidebarSpec ¶
type RuntimeSidebarSpec struct {
Enabled *bool `json:"enabled,omitempty" bson:"enabled,omitempty"`
Mode string `json:"mode,omitempty" bson:"mode,omitempty"`
Title string `json:"title,omitempty" bson:"title,omitempty"`
SearchPlaceholder string `json:"search_placeholder,omitempty" bson:"search_placeholder,omitempty"`
EmptyText string `json:"empty_text,omitempty" bson:"empty_text,omitempty"`
Collapsible *bool `json:"collapsible,omitempty" bson:"collapsible,omitempty"`
Resource *RuntimeSidebarResourceSpec `json:"resource,omitempty" bson:"resource,omitempty"`
}
type RuntimeSpec ¶
type Schema ¶
type Schema struct {
ModelGroups []ModelGroupSpec `json:"model_groups,omitempty"`
Models []ModelSpec `json:"models,omitempty"`
RelationTypes []RelationType `json:"relation_types,omitempty"`
ModelRelations []ModelRelation `json:"model_relations,omitempty"`
}
func (*Schema) SyncModelGroups ¶ added in v1.11.4
func (s *Schema) SyncModelGroups()
SyncModelGroups 重新根据当前所有模型引用的非空 GroupName 收敛 ModelGroups,避免孤儿分组残留
func (*Schema) UpdateModelMeta ¶ added in v1.11.4
UpdateModelMeta 更新指定模型的中文展示名称与所属模型分组,并重新收敛分组列表
Click to show internal directories.
Click to hide internal directories.