model

package
v0.0.0-...-3e848aa Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultUserPreference = Preference{
	Collapsed: true,
	Theme:     "light",
}

DefaultUserPreference represents default preference if user not set.

Functions

This section is empty.

Types

type AddTeamMember

type AddTeamMember struct {
	UserUIDs   []string       `json:"userUids" binding:"required"`
	Permission PermissionType `json:"permission" binding:"required"`
}

AddTeamMember represents add new team member params.

type BaseModel

type BaseModel struct {
	ID        int64     `json:"-" gorm:"column:id"`
	CreatedAt time.Time `json:"createdAt,omitempty" gorm:"column:created_at"`
	UpdatedAt time.Time `json:"updatedAt,omitempty" gorm:"column:updated_at"`

	CreatedBy int64 `json:"-" gorm:"column:created_by"`
	UpdatedBy int64 `json:"-" gorm:"column:updated_by"`
}

BaseModel represents base model information.

type BootData

type BootData struct {
	Home         string        `json:"home,omitempty"`
	User         SignedUser    `json:"user"`
	NavTree      Components    `json:"navTree,omitempty"`
	Datasources  []Datasource  `json:"datasources,omitempty"`
	Integrations []Integration `json:"integrations,omitempty"`
}

BootData represents Linsight boot data.

type ChangeUserPassword

type ChangeUserPassword struct {
	OldPassword string `json:"oldPassword" binding:"required"`
	NewPassword string `json:"newPassword" binding:"required"`
}

ChangeUserPassword represents change user password params.

type Chart

type Chart struct {
	BaseModel

	OrgID int64 `json:"-" gorm:"column:org_id;index:u_idx_chart_org_title,unique"`

	UID         string `json:"uid" gorm:"column:uid;index:u_idx_chart_uid,unique"`
	Title       string `json:"title" gorm:"column:title;index:u_idx_chart_org_title,unique"`
	Desc        string `json:"description,omitempty" gorm:"column:desc"`
	Integration string `json:"integration" gorm:"column:integration"`
	Type        string `json:"type" gorm:"column:type"`
	Version     int    `json:"version,omitempty" gorm:"column:version"`

	Model datatypes.JSON `json:"model,omitempty" gorm:"column:model"`

	IsStarred bool `json:"isStarred,omitempty" gorm:"-"`
}

Chart represents chart basic information.

func (*Chart) ReadMeta

func (c *Chart) ReadMeta()

ReadMeta reads metadata from config json.

type ChartInfo

type ChartInfo struct {
	UID         string         `json:"uid"`
	Title       string         `json:"title"`
	Desc        string         `json:"description,omitempty"`
	Type        string         `json:"type"`
	Integration string         `json:"integration,omitempty"`
	Dashboards  int            `json:"dashboards"`
	Model       datatypes.JSON `json:"model,omitempty"`
}

ChartInfo represents chart basic information without config json.

type Component

type Component struct {
	BaseModel

	UID string `json:"uid" gorm:"column:uid;index:u_idx_cmp_uid,unique"`

	Label     string `json:"label" gorm:"column:label"`
	Path      string `json:"path,omitempty" gorm:"column:path"`
	Icon      string `json:"icon,omitempty" gorm:"column:icon"`
	Component string `json:"component,omitempty" gorm:"column:component"`
	// default role
	Role  accesscontrol.RoleType `json:"role" gorm:"column:role"`
	Order int                    `json:"order" gorm:"column:order"`

	ParentUID string       `json:"parentUID,omitempty" gorm:"column:parent_uid"`
	Children  []*Component `json:"children,omitempty" gorm:"-"`
}

Component represents product component.

type Components

type Components []*Component

Components represents Component slice.

func (Components) ToTree

func (cmps Components) ToTree() Components

ToTree returns tree structure.

type CreateUserRequest

type CreateUserRequest struct {
	Name     string `json:"name"`
	UserName string `json:"userName" binding:"required"`
	Email    string `json:"email" binding:"required"`
	Password string `json:"password" binding:"required"`
}

CreateUserRequest represents create new user request

type Dashboard

type Dashboard struct {
	BaseModel

	OrgID int64 `json:"-" gorm:"column:org_id;index:u_idx_dashboard_org_title,unique"`

	UID         string         `json:"uid,omitempty" gorm:"column:uid;index:u_idx_dashboard_uid,unique"`
	Title       string         `json:"title" gorm:"column:title;index:u_idx_dashboard_org_title"`
	Desc        string         `json:"description,omitempty" gorm:"column:desc"`
	Integration string         `json:"integration,omitempty" gorm:"column:integration"`
	Version     int            `json:"version,omitempty" gorm:"column:version"`
	Tags        datatypes.JSON `json:"tags,omitempty" gorm:"tags"`

	Config datatypes.JSON `json:"-" gorm:"column:config"`

	// FIXME: need remove
	IsStarred bool `json:"isStarred,omitempty" gorm:"-"`

	TagList []string `json:"-" gorm:"-"`
}

Dashboard represents dasshboard basic information.

func (*Dashboard) GetCharts

func (d *Dashboard) GetCharts() (chartUIDs []string, err error)

GetCharts returns chart uid list from dashboard config.

func (*Dashboard) ReadMeta

func (d *Dashboard) ReadMeta()

ReadMeta reads dashboard metadata from json data.

type DashboardMeta

type DashboardMeta struct {
	CanEdit     bool `json:"canEdit"`
	Provisioned bool `json:"provisioned"`
}

DashboardMeta represents dashboard metadata.

func NewDashboardMeta

func NewDashboardMeta() DashboardMeta

NewDashboardMeta creates a dashboard metadata.

type DashboardProvisioning

type DashboardProvisioning struct {
	BaseModel

	OrgID int64 `json:"-" gorm:"column:org_id;index:u_idx_dashboard_provision,unique"`

	DashboardUID   string `gorm:"column:dashboard_uid;index:u_idx_dashboard_provision,unique"`
	Name           string `gorm:"column:name"`
	AllowUIUpdates bool   `gorm:"column:allow_ui_updates"`
	External       string `gorm:"column:external"`
	Checksum       string `gorm:"column:check_sum"`
}

DashboardProvisioning represents dashboard provisioning information.

type Datasource

type Datasource struct {
	BaseModel

	// ord id + name => unique key
	OrgID int64 `json:"-" gorm:"column:org_id;index:u_idx_datasource_org_name,unique"`

	UID       string         `json:"uid" gorm:"column:uid;index:u_idx_datasource_uid,unique"`
	Name      string         `json:"name" gorm:"column:name;index:u_idx_datasource_org_name,unique"`
	Type      DatasourceType `json:"type" gorm:"column:type"`
	URL       string         `json:"url" gorm:"column:url"`
	TimeZone  string         `json:"timeZone" gorm:"column:time_zone"`
	Config    datatypes.JSON `json:"config" gorm:"column:config"`
	IsDefault bool           `json:"isDefault" gorm:"column:is_default"`
}

Datasource represents datasource information.

type DatasourceType

type DatasourceType = string

DatasourceType represents the type of datasource.

var (
	LinDBDatasource DatasourceType = "lindb"
	LinGoDatasource DatasourceType = "lingo"
)

Define all support datasource types.

type Integration

type Integration struct {
	BaseModel

	UID      string `json:"uid" gorm:"column:uid;index:u_idx_integrations_uid,unique"`
	Category string `json:"category" gorm:"column:category"`
	Title    string `json:"title" gorm:"column:title;index:u_idx_integrations_title,unique"`
	Desc     string `json:"desc" gorm:"column:desc"`
	Icon     string `json:"icon" gorm:"column:icon"`
	DocURL   string `json:"docUrl" gorm:"column:doc_url"`
}

Integration represents all integrations for observability of your application or infrastructure.

type IntegrationConnection

type IntegrationConnection struct {
	BaseModel

	OrgID int64 `json:"-" gorm:"column:org_id;index:u_idx_ic,unique"`

	IntegrationUID string       `json:"integrationUID" gorm:"column:integration_uid;index:u_idx_ic,unique"`
	SourceUID      string       `json:"sourceUID" gorm:"column:source_uid;index:u_idx_ic,unique"`
	Type           ResourceType `json:"type" gorm:"column:type;index:u_idx_ic,unique"`
}

IntegrationConnection represents connection between integration and source(dashboard/chart etc.).

type Link struct {
	BaseModel

	OrgID int64 `json:"-" gorm:"column:org_id;index:u_idx_link,unique"`

	SourceUID string   `gorm:"column:source_uid;index:u_idx_link,unique"`
	TargetUID string   `gorm:"column:target_uid;index:u_idx_link,unique"`
	Kind      LinkKind `gorm:"column:kind;index:u_idx_link,unique"`
}

Link represents a connected for two elements.

type LinkKind

type LinkKind int
const (
	DashboardLink LinkKind = iota + 1
)

type LoginUser

type LoginUser struct {
	Username string `json:"username" binding:"required"`
	Password string `json:"password" binding:"required"`
}

LoginUser represents the parameters of login request.

type MetricQuery

type MetricQuery struct {
	From    string `json:"from"`
	To      string `json:"to"`
	Queries string `json:"queries"`
}

type Org

type Org struct {
	BaseModel

	UID  string `json:"uid" gorm:"column:uid;index:u_idx_org_uid,unique"`
	Name string `json:"name" gorm:"column:name;index:u_idx_org_name,unique"`
}

Org represents organization information.

type OrgComponent

type OrgComponent struct {
	BaseModel

	OrgID       int64 `json:"-" gorm:"column:org_id;index:u_idx_org_cmp_org_cmp_id,unique"`
	ComponentID int64 `json:"-" gorm:"column:component_id;index:u_idx_org_cmp_org_cmp_id,unique"`

	// role for org. level
	Role accesscontrol.RoleType `gorm:"column:role"`
}

OrgComponent represents component item for organization.

type OrgComponentInfo

type OrgComponentInfo struct {
	ComponentUID string                 `json:"componentUid"`
	Role         accesscontrol.RoleType `json:"role" binding:"required"`
}

OrgComponentInfo represents component basic info for organization.

type OrgUser

type OrgUser struct {
	BaseModel

	UserID int64                  `gorm:"column:user_id;index:u_idx_org_user,unique"`
	OrgID  int64                  `gorm:"column:org_id;index:u_idx_org_user,unique"`
	Role   accesscontrol.RoleType `gorm:"column:role"`
}

OrgUser represents user and org related information.

type OrgUserInfo

type OrgUserInfo struct {
	UserUID  string `json:"userUid"`
	UserName string `json:"userName"`
	Name     string `json:"name"`
	Email    string `json:"email"`
}

type Ownership

type Ownership int
const (
	Any Ownership = iota
	Mine
	Shared
)

type PagingParam

type PagingParam struct {
	Offset int `form:"offset" json:"offset"`
	Limit  int `form:"limit" json:"limit"`
}

PagingParam represents pagination params.

type PermissionType

type PermissionType int
const (
	PermissionUnknown PermissionType = iota
	PermissionMember
	PermissionAdmin
)

func (PermissionType) MarshalJSON

func (p PermissionType) MarshalJSON() ([]byte, error)

func (PermissionType) String

func (p PermissionType) String() string

String returns the string value of permission type.

func (*PermissionType) UnmarshalJSON

func (p *PermissionType) UnmarshalJSON(data []byte) error

type Preference

type Preference struct {
	BaseModel

	UserID    int64  `json:"-" gorm:"column:user_id;index:u_idx_pref_user,unique"`
	HomePage  string `json:"homePage" gorm:"column:home_page"`
	Theme     string `json:"theme" gorm:"column:theme"`
	Collapsed bool   `json:"collapsed" gorm:"column:collapsed"`
}

Preference represents the preference of user.

type Query

type Query struct {
	Datasource TargetDatasource `json:"datasource" binding:"required"`
	Request    json.RawMessage  `json:"request"`
	RefID      string           `json:"refId"`
}

type QueryRequest

type QueryRequest struct {
	Range   TimeRange `json:"range"`
	Queries []*Query  `json:"queries"`
}

type QueryResponse

type QueryResponse struct {
	Results map[string]any `json:"results"`
}

type RemoveProvisioningDashboardRequest

type RemoveProvisioningDashboardRequest struct {
	Org      *Org
	Name     string
	External string
}

RemoveProvisioningDashboardRequest represents remove provisioning dashboard request.

type RemoveTeamMember

type RemoveTeamMember struct {
	UserUIDs []string `json:"userUids" binding:"required"`
}

RemoveTeamMember represents remove team member params.

type ResetUserPassword

type ResetUserPassword struct {
	UserUID  string `json:"userUid" binding:"required"`
	Password string `json:"password" binding:"required"`
}

ResetUserPassword represents reset user password params.

type ResourceACLParam

type ResourceACLParam struct {
	Role     accesscontrol.RoleType
	OrgID    int64
	Category accesscontrol.ResourceCategory
	Resource string
	Action   accesscontrol.ActionType
}

ResourceACLParam represents resource abac params.

func (*ResourceACLParam) ToParams

func (p *ResourceACLParam) ToParams() []any

ToParams returns casbin params.

func (*ResourceACLParam) ToStringParams

func (p *ResourceACLParam) ToStringParams() []string

ToStringParams returns casbin params.

type ResourceTag

type ResourceTag struct {
	BaseModel

	OrgID       int64        `json:"-" gorm:"column:org_id;index:u_idx_resource_tag,unique"`
	TagID       int64        `json:"-" gorm:"column:tag_id;index:u_idx_resource_tag,unique"`
	ResourceUID string       `json:"resourceUid" gorm:"column:resource_uid;index:u_idx_resource_tag,unique"`
	Type        ResourceType `json:"type" gorm:"column:type;index:u_idx_resource_tag,unique"`
}

ResourceTag represents resource's tags information.

type ResourceType

type ResourceType int
const (
	DashboardResource ResourceType = iota + 1
	ChartResource
)

type SaveProvisioningDashboardRequest

type SaveProvisioningDashboardRequest struct {
	Org          *Org
	Dashboard    *Dashboard
	Provisioning *DashboardProvisioning
}

SaveProvisioningDashboardRequest represents save provisioning dashboard request.

type SearchChartRequest

type SearchChartRequest struct {
	PagingParam
	Title     string    `form:"title" json:"title"`
	Ownership Ownership `form:"ownership" json:"ownership"`
	Tags      []string  `form:"tags" json:"tags"`
}

SearchChartRequest represents search chart request params.

type SearchDashboardRequest

type SearchDashboardRequest struct {
	PagingParam
	Title     string    `form:"title" json:"title"`
	Ownership Ownership `form:"ownership" json:"ownership"`
	Tags      []string  `form:"tags" json:"tags"`
}

SearchDashboardRequest represents search dashboard request params.

type SearchOrgRequest

type SearchOrgRequest struct {
	PagingParam
	Name string `form:"name" json:"name"`
}

SearchOrgRequest represents search organization request params.

type SearchTeamMemberRequest

type SearchTeamMemberRequest struct {
	PagingParam
	User        string           `form:"user" json:"user"`
	Permissions []PermissionType `form:"permissions" json:"permissions" binding:"required"`
}

SearchTeamMemberRequest represents search team member request params.

type SearchTeamRequest

type SearchTeamRequest struct {
	PagingParam
	Name string `form:"name" json:"name"`
}

SearchTeamRequest represents search team request params.

type SearchUserRequest

type SearchUserRequest struct {
	PagingParam

	Query string `form:"query" json:"query"`
}

SearchUserRequest represents search user request params.

type SignedUser

type SignedUser struct {
	User       *User                  `json:"-"`
	UID        string                 `json:"uid"`
	UserName   string                 `json:"userName"`
	Name       string                 `json:"name"`
	Email      string                 `json:"email"`
	IsDisabled bool                   `json:"isDisabled"`
	Org        *Org                   `json:"org"`
	Role       accesscontrol.RoleType `json:"role"`
	Preference *Preference            `json:"preference,omitempty"`
}

SignedUser represents the signed user information.

type Star

type Star struct {
	BaseModel

	OrgID        int64        `json:"-" gorm:"column:org_id"`
	UserID       int64        `json:"-" gorm:"column:user_id"`
	ResourceUID  string       `json:"resourceUid" gorm:"column:resource_uid"`
	ResourceType ResourceType `json:"resourceType" gorm:"column:resource_type"`
}

type Tag

type Tag struct {
	BaseModel

	OrgID int64  `json:"-" gorm:"column:org_id;index:u_idx_tags,unique"`
	Term  string `gorm:"column:term;index:u_idx_tags,unique"`
}

Tag represents term of tags.

type TargetDatasource

type TargetDatasource struct {
	UID string `json:"uid" binding:"required"`
}

type Team

type Team struct {
	BaseModel

	// current selected org.
	OrgID int64 `json:"-" gorm:"column:org_id"`

	UID   string `json:"uid" gorm:"column:uid;index:u_idx_team_uid,unique"`
	Name  string `json:"name" gorm:"column:name;index:u_idx_team_name,unique"`
	Email string `json:"email" gorm:"column:email"`
}

Team represents the team inforamtion.

type TeamMember

type TeamMember struct {
	BaseModel

	OrgID  int64 `json:"-" gorm:"column:org_id;index:u_idx_team_member,unique"`
	TeamID int64 `json:"-" gorm:"column:team_id;index:u_idx_team_member,unique"`
	UserID int64 `json:"-" gorm:"column:user_id;index:u_idx_team_member,unique"`

	Permission PermissionType `json:"-" gorm:"permission"`
}

TeamMember represents the team's member inforamtion.

type TeamMemberInfo

type TeamMemberInfo struct {
	UserUID    string         `json:"userUid"`
	Name       string         `json:"name"`
	UserName   string         `json:"userName"`
	Permission PermissionType `json:"permission"`
}

TeamMemberInfo represents team member info.

type TimeRange

type TimeRange struct {
	From int64 `json:"from"`
	To   int64 `json:"to"`
}

TimeRange represents data query time range.

type UpdateTeamMember

type UpdateTeamMember struct {
	UserUID    string         `json:"userUid" binding:"required"`
	Permission PermissionType `json:"permission" binding:"required"`
}

UpdateTeamMember represents update team member params.

type User

type User struct {
	BaseModel

	// current selected org.
	OrgID int64 `json:"-" gorm:"column:org_id"`

	UID        string `json:"uid" gorm:"column:uid;index:u_idx_user_uid,unique"`
	Name       string `json:"name" gorm:"column:name"`
	UserName   string `json:"userName" gorm:"column:user_name;index:u_idx_user_uname,unique"`
	Email      string `json:"email" gorm:"column:email;index:u_idx_user_email,unique"`
	Password   string `json:"-" gorm:"column:password"`
	Salt       string `json:"-" gorm:"column:salt"`
	IsDisabled bool   `json:"isDisabled" gorm:"column:is_disabled"`
}

User represents the user basic information.

type UserOrgInfo

type UserOrgInfo struct {
	UserUID string                 `json:"userUid"`
	OrgUID  string                 `json:"orgUid"`
	OrgName string                 `json:"orgName"`
	Role    accesscontrol.RoleType `json:"role"`
}

UserOrgInfo represents user's org info.

type UserToken

type UserToken struct {
	BaseModel

	UserID int64 `json:"-" gorm:"column:user_id"`

	Token     string `json:"token" gorm:"column:token;index:u_idx_user_token,unique"`
	UserAgent string `json:"userAgent" gorm:"column:user_agent"`
	ClientIP  string `json:"clientIp" gorm:"column:client_ip"`
}

UserToken represents user's login token and history.

Jump to

Keyboard shortcuts

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