models

package
v2.1.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2015 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DS_GRAPHITE      = "graphite"
	DS_INFLUXDB      = "influxdb"
	DS_INFLUXDB_08   = "influxdb_08"
	DS_ES            = "elasticsearch"
	DS_OPENTSDB      = "opentsdb"
	DS_ACCESS_DIRECT = "direct"
	DS_ACCESS_PROXY  = "proxy"
)

Variables

View Source
var (
	ErrDashboardNotFound           = errors.New("Dashboard not found")
	ErrDashboardSnapshotNotFound   = errors.New("Dashboard snapshot not found")
	ErrDashboardWithSameNameExists = errors.New("A dashboard with the same name already exists")
	ErrDashboardVersionMismatch    = errors.New("The dashboard has been changed by someone else")
)

Typed errors

View Source
var (
	DashTypeJson     = "file"
	DashTypeDB       = "db"
	DashTypeScript   = "script"
	DashTypeSnapshot = "snapshot"
)
View Source
var (
	ErrInvalidRoleType = errors.New("Invalid role type")
	ErrLastOrgAdmin    = errors.New("Cannot remove last organization admin")
	ErrOrgUserNotFound = errors.New("Cannot find the organization user")
)

Typed errors

View Source
var ErrCommandValidationFailed = errors.New("Command missing required fields")
View Source
var (
	ErrDataSourceNotFound = errors.New("Data source not found")
)

Typed errors

View Source
var ErrInvalidApiKey = errors.New("Invalid API Key")
View Source
var ErrInvalidEmailCode = errors.New("Invalid or expired email code")
View Source
var (
	ErrOrgNotFound = errors.New("Organization not found")
)

Typed errors

View Source
var (
	ErrUserNotFound = errors.New("User not found")
)

Typed errors

Functions

This section is empty.

Types

type AddApiKeyCommand

type AddApiKeyCommand struct {
	Name  string   `json:"name" binding:"Required"`
	Role  RoleType `json:"role" binding:"Required"`
	OrgId int64    `json:"-"`
	Key   string   `json:"-"`

	Result *ApiKey `json:"-"`
}

--------------------- COMMANDS

type AddDataSourceCommand

type AddDataSourceCommand struct {
	Name              string                 `json:"name" binding:"Required"`
	Type              string                 `json:"type" binding:"Required"`
	Access            DsAccess               `json:"access" binding:"Required"`
	Url               string                 `json:"url"`
	Password          string                 `json:"password"`
	Database          string                 `json:"database"`
	User              string                 `json:"user"`
	BasicAuth         bool                   `json:"basicAuth"`
	BasicAuthUser     string                 `json:"basicAuthUser"`
	BasicAuthPassword string                 `json:"basicAuthPassword"`
	IsDefault         bool                   `json:"isDefault"`
	JsonData          map[string]interface{} `json:"jsonData"`

	OrgId int64 `json:"-"`

	Result *DataSource
}

Also acts as api DTO

type AddOrgUserCommand

type AddOrgUserCommand struct {
	LoginOrEmail string   `json:"loginOrEmail" binding:"Required"`
	Role         RoleType `json:"role" binding:"Required"`

	OrgId  int64 `json:"-"`
	UserId int64 `json:"-"`
}

type ApiKey

type ApiKey struct {
	Id      int64
	OrgId   int64
	Name    string
	Key     string
	Role    RoleType
	Created time.Time
	Updated time.Time
}

type ApiKeyDTO

type ApiKeyDTO struct {
	Id   int64    `json:"id"`
	Name string   `json:"name"`
	Role RoleType `json:"role"`
}

type ChangeUserPasswordCommand

type ChangeUserPasswordCommand struct {
	OldPassword string `json:"oldPassword"`
	NewPassword string `json:"newPassword"`

	UserId int64 `json:"-"`
}

type CreateDashboardSnapshotCommand

type CreateDashboardSnapshotCommand struct {
	Dashboard map[string]interface{} `json:"dashboard" binding:"Required"`
	Expires   int64                  `json:"expires"`

	// these are passed when storing an external snapshot ref
	External  bool   `json:"external"`
	Key       string `json:"key"`
	DeleteKey string `json:"deleteKey"`

	OrgId  int64 `json:"-"`
	UserId int64 `json:"-"`

	Result *DashboardSnapshot
}

type CreateOrgCommand

type CreateOrgCommand struct {
	Name string `json:"name" binding:"Required"`

	// initial admin user for account
	UserId int64 `json:"-"`
	Result Org   `json:"-"`
}

type CreateUserCommand

type CreateUserCommand struct {
	Email    string `json:"email" binding:"Required"`
	Login    string `json:"login"`
	Name     string `json:"name"`
	Company  string `json:"compay"`
	Password string `json:"password" binding:"Required"`
	IsAdmin  bool   `json:"-"`

	Result User `json:"-"`
}

type Dashboard

type Dashboard struct {
	Id      int64
	Slug    string
	OrgId   int64
	Version int

	Created time.Time
	Updated time.Time

	Title string
	Data  map[string]interface{}
}

Dashboard model

func NewDashboard

func NewDashboard(title string) *Dashboard

NewDashboard creates a new dashboard

func NewDashboardFromJson

func NewDashboardFromJson(data map[string]interface{}) *Dashboard

func (*Dashboard) GetString

func (dash *Dashboard) GetString(prop string) string

GetString a

func (*Dashboard) GetTags

func (dash *Dashboard) GetTags() []string

GetTags turns the tags in data json into go string array

func (*Dashboard) UpdateSlug

func (dash *Dashboard) UpdateSlug()

UpdateSlug updates the slug

type DashboardSnapshot

type DashboardSnapshot struct {
	Id          int64
	Name        string
	Key         string
	DeleteKey   string
	OrgId       int64
	UserId      int64
	External    bool
	ExternalUrl string

	Expires time.Time
	Created time.Time
	Updated time.Time

	Dashboard map[string]interface{}
}

DashboardSnapshot model

type DashboardTagCloudItem

type DashboardTagCloudItem struct {
	Term  string `json:"term"`
	Count int    `json:"count"`
}

type DataSource

type DataSource struct {
	Id      int64
	OrgId   int64
	Version int

	Name              string
	Type              string
	Access            DsAccess
	Url               string
	Password          string
	User              string
	Database          string
	BasicAuth         bool
	BasicAuthUser     string
	BasicAuthPassword string
	IsDefault         bool
	JsonData          map[string]interface{}

	Created time.Time
	Updated time.Time
}

type DataSourceCreatedEvent

type DataSourceCreatedEvent struct {
}

--------------------- EVENTS

type DeleteApiKeyCommand

type DeleteApiKeyCommand struct {
	Id    int64 `json:"id"`
	OrgId int64 `json:"-"`
}

type DeleteDashboardCommand

type DeleteDashboardCommand struct {
	Slug  string
	OrgId int64
}

type DeleteDashboardSnapshotCommand

type DeleteDashboardSnapshotCommand struct {
	DeleteKey string `json:"-"`
}

type DeleteDataSourceCommand

type DeleteDataSourceCommand struct {
	Id    int64
	OrgId int64
}

type DeleteOrgCommand

type DeleteOrgCommand struct {
	Id int64
}

type DeleteUserCommand

type DeleteUserCommand struct {
	UserId int64
}

type DsAccess

type DsAccess string

type GetApiKeyByIdQuery

type GetApiKeyByIdQuery struct {
	ApiKeyId int64
	Result   *ApiKey
}

type GetApiKeyByNameQuery

type GetApiKeyByNameQuery struct {
	KeyName string
	OrgId   int64
	Result  *ApiKey
}

type GetApiKeysQuery

type GetApiKeysQuery struct {
	OrgId  int64
	Result []*ApiKey
}

type GetDashboardQuery

type GetDashboardQuery struct {
	Slug  string
	OrgId int64

	Result *Dashboard
}

type GetDashboardSnapshotQuery

type GetDashboardSnapshotQuery struct {
	Key string

	Result *DashboardSnapshot
}

type GetDashboardTagsQuery

type GetDashboardTagsQuery struct {
	OrgId  int64
	Result []*DashboardTagCloudItem
}

type GetDataSourceByIdQuery

type GetDataSourceByIdQuery struct {
	Id     int64
	OrgId  int64
	Result DataSource
}

type GetDataSourceByNameQuery

type GetDataSourceByNameQuery struct {
	Name   string
	OrgId  int64
	Result DataSource
}

type GetDataSourcesQuery

type GetDataSourcesQuery struct {
	OrgId  int64
	Result []*DataSource
}

type GetOrgByIdQuery

type GetOrgByIdQuery struct {
	Id     int64
	Result *Org
}

type GetOrgByNameQuery

type GetOrgByNameQuery struct {
	Name   string
	Result *Org
}

type GetOrgUsersQuery

type GetOrgUsersQuery struct {
	OrgId  int64
	Result []*OrgUserDTO
}

type GetSignedInUserQuery

type GetSignedInUserQuery struct {
	UserId int64
	Login  string
	Email  string
	Result *SignedInUser
}

type GetSystemStatsQuery

type GetSystemStatsQuery struct {
	Result *SystemStats
}

type GetUserByIdQuery

type GetUserByIdQuery struct {
	Id     int64
	Result *User
}

type GetUserByLoginQuery

type GetUserByLoginQuery struct {
	LoginOrEmail string
	Result       *User
}

type GetUserOrgListQuery

type GetUserOrgListQuery struct {
	UserId int64
	Result []*UserOrgDTO
}

type GetUserProfileQuery

type GetUserProfileQuery struct {
	UserId int64
	Result UserProfileDTO
}

type GetUserStarsQuery

type GetUserStarsQuery struct {
	UserId int64

	Result map[int64]bool // dashboard ids
}

type HomeDashboard

type HomeDashboard struct {
	Id        int64
	UserId    int64
	AccountId int64

	Created time.Time
	Updated time.Time

	Data map[string]interface{}
}

type IsStarredByUserQuery

type IsStarredByUserQuery struct {
	UserId      int64
	DashboardId int64

	Result bool
}

type OAuthType

type OAuthType int
const (
	GITHUB OAuthType = iota + 1
	GOOGLE
	TWITTER
)

type Org

type Org struct {
	Id      int64
	Version int
	Name    string
	Created time.Time
	Updated time.Time
}

type OrgDTO

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

type OrgUser

type OrgUser struct {
	Id      int64
	OrgId   int64
	UserId  int64
	Role    RoleType
	Created time.Time
	Updated time.Time
}

type OrgUserDTO

type OrgUserDTO struct {
	OrgId  int64  `json:"orgId"`
	UserId int64  `json:"userId"`
	Email  string `json:"email"`
	Login  string `json:"login"`
	Role   string `json:"role"`
}

type RemoveOrgUserCommand

type RemoveOrgUserCommand struct {
	UserId int64
	OrgId  int64
}

type RoleType

type RoleType string
const (
	ROLE_VIEWER           RoleType = "Viewer"
	ROLE_EDITOR           RoleType = "Editor"
	ROLE_READ_ONLY_EDITOR RoleType = "Read Only Editor"
	ROLE_ADMIN            RoleType = "Admin"
)

func (RoleType) IsValid

func (r RoleType) IsValid() bool

type SaveDashboardCommand

type SaveDashboardCommand struct {
	Dashboard map[string]interface{} `json:"dashboard" binding:"Required"`
	Overwrite bool                   `json:"overwrite"`
	OrgId     int64                  `json:"-"`

	Result *Dashboard
}

func (*SaveDashboardCommand) GetDashboardModel

func (cmd *SaveDashboardCommand) GetDashboardModel() *Dashboard

GetDashboardModel turns the command into the savable model

type SearchHit

type SearchHit struct {
	Id        int64    `json:"id"`
	Title     string   `json:"title"`
	Uri       string   `json:"uri"`
	Type      string   `json:"type"`
	Tags      []string `json:"tags"`
	IsStarred bool     `json:"isStarred"`
}

type SearchOrgsQuery

type SearchOrgsQuery struct {
	Query string
	Name  string
	Limit int
	Page  int

	Result []*OrgDTO
}

type SearchUsersQuery

type SearchUsersQuery struct {
	Query string
	Page  int
	Limit int

	Result []*UserSearchHitDTO
}

type SendEmailCommand

type SendEmailCommand struct {
	To       []string
	Template string
	Data     map[string]interface{}
	Massive  bool
	Info     string
}

type SendResetPasswordEmailCommand

type SendResetPasswordEmailCommand struct {
	User *User
}

type SetUsingOrgCommand

type SetUsingOrgCommand struct {
	UserId int64
	OrgId  int64
}

type SignedInUser

type SignedInUser struct {
	UserId         int64
	OrgId          int64
	OrgName        string
	OrgRole        RoleType
	Login          string
	Name           string
	Email          string
	Theme          string
	ApiKeyId       int64
	IsGrafanaAdmin bool
}

type Star

type Star struct {
	Id          int64
	UserId      int64
	DashboardId int64
}

type StarDashboardCommand

type StarDashboardCommand struct {
	UserId      int64
	DashboardId int64
}

type SystemStats

type SystemStats struct {
	DashboardCount int
	UserCount      int
	OrgCount       int
}

type UnstarDashboardCommand

type UnstarDashboardCommand struct {
	UserId      int64
	DashboardId int64
}

type UpdateApiKeyCommand

type UpdateApiKeyCommand struct {
	Id   int64    `json:"id"`
	Name string   `json:"name"`
	Role RoleType `json:"role"`

	OrgId int64 `json:"-"`
}

type UpdateDataSourceCommand

type UpdateDataSourceCommand struct {
	Name              string                 `json:"name" binding:"Required"`
	Type              string                 `json:"type" binding:"Required"`
	Access            DsAccess               `json:"access" binding:"Required"`
	Url               string                 `json:"url"`
	Password          string                 `json:"password"`
	User              string                 `json:"user"`
	Database          string                 `json:"database"`
	BasicAuth         bool                   `json:"basicAuth"`
	BasicAuthUser     string                 `json:"basicAuthUser"`
	BasicAuthPassword string                 `json:"basicAuthPassword"`
	IsDefault         bool                   `json:"isDefault"`
	JsonData          map[string]interface{} `json:"jsonData"`

	OrgId int64 `json:"-"`
	Id    int64 `json:"-"`
}

Also acts as api DTO

type UpdateOrgCommand

type UpdateOrgCommand struct {
	Name  string `json:"name" binding:"Required"`
	OrgId int64  `json:"-"`
}

type UpdateOrgUserCommand

type UpdateOrgUserCommand struct {
	Role RoleType `json:"role" binding:"Required"`

	OrgId  int64 `json:"-"`
	UserId int64 `json:"-"`
}

type UpdateUserCommand

type UpdateUserCommand struct {
	Name  string `json:"name"`
	Email string `json:"email"`
	Login string `json:"login"`
	Theme string `json:"theme"`

	UserId int64 `json:"-"`
}

type UpdateUserPermissionsCommand

type UpdateUserPermissionsCommand struct {
	IsGrafanaAdmin bool
	UserId         int64 `json:"-"`
}

type User

type User struct {
	Id            int64
	Version       int
	Email         string
	Name          string
	Login         string
	Password      string
	Salt          string
	Rands         string
	Company       string
	EmailVerified bool
	Theme         string

	IsAdmin bool
	OrgId   int64

	Created time.Time
	Updated time.Time
}

func (*User) NameOrFallback

func (u *User) NameOrFallback() string

type UserOrgDTO

type UserOrgDTO struct {
	OrgId int64    `json:"orgId"`
	Name  string   `json:"name"`
	Role  RoleType `json:"role"`
}

type UserProfileDTO

type UserProfileDTO struct {
	Email          string `json:"email"`
	Name           string `json:"name"`
	Login          string `json:"login"`
	Theme          string `json:"theme"`
	OrgId          int64  `json:"orgId"`
	IsGrafanaAdmin bool   `json:"isGrafanaAdmin"`
}

type UserSearchHitDTO

type UserSearchHitDTO struct {
	Id      int64  `json:"id"`
	Name    string `json:"name"`
	Login   string `json:"login"`
	Email   string `json:"email"`
	IsAdmin bool   `json:"isAdmin"`
}

type ValidateResetPasswordCodeQuery

type ValidateResetPasswordCodeQuery struct {
	Code   string
	Result *User
}

Jump to

Keyboard shortcuts

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