models

package
v2.6.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2015 License: Apache-2.0 Imports: 5 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_CLOUDWATCH    = "cloudwatch"
	DS_KAIROSDB      = "kairosdb"
	DS_PROMETHEUS    = "prometheus"
	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 (
	ErrOrgNotFound  = errors.New("Organization not found")
	ErrOrgNameTaken = errors.New("Organization name is taken")
)

Typed errors

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")
	ErrOrgUserAlreadyAdded = errors.New("User is already added to organization")
)

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 ErrInvalidQuotaTarget = errors.New("Invalid quota target")
View Source
var (
	ErrTempUserNotFound = errors.New("User not found")
)

Typed errors

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

Typed errors

Functions

func IsKnownDataSourcePlugin

func IsKnownDataSourcePlugin(dsType string) bool

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"`
	WithCredentials   bool                   `json:"withCredentials"`
	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 Address

type Address struct {
	Address1 string `json:"address1"`
	Address2 string `json:"address2"`
	City     string `json:"city"`
	ZipCode  string `json:"zipCode"`
	State    string `json:"state"`
	Country  string `json:"country"`
}

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 CreateTempUserCommand

type CreateTempUserCommand struct {
	Email           string
	Name            string
	OrgId           int64
	InvitedByUserId int64
	Status          TempUserStatus
	Code            string
	Role            RoleType
	RemoteAddr      string

	Result *TempUser
}

type CreateUserCommand

type CreateUserCommand struct {
	Email         string
	Login         string
	Name          string
	Company       string
	OrgName       string
	Password      string
	EmailVerified bool
	IsAdmin       bool
	SkipOrgSetup  bool

	Result User
}

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
	WithCredentials   bool
	IsDefault         bool
	JsonData          map[string]interface{}

	Created time.Time
	Updated time.Time
}

type DataSourceCreatedEvent

type DataSourceCreatedEvent struct {
}

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

type DataSourceStats

type DataSourceStats struct {
	Count int
	Type  string
}

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 GetDataSourceStatsQuery

type GetDataSourceStatsQuery struct {
	Result []*DataSourceStats
}

type GetDataSourcesQuery

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

type GetGlobalQuotaByTargetQuery

type GetGlobalQuotaByTargetQuery struct {
	Target  string
	Default int64
	Result  *GlobalQuotaDTO
}

type GetOrgByIdQuery

type GetOrgByIdQuery struct {
	Id     int64
	Result *Org
}

type GetOrgByNameQuery

type GetOrgByNameQuery struct {
	Name   string
	Result *Org
}

type GetOrgQuotaByTargetQuery

type GetOrgQuotaByTargetQuery struct {
	Target  string
	OrgId   int64
	Default int64
	Result  *OrgQuotaDTO
}

type GetOrgQuotasQuery

type GetOrgQuotasQuery struct {
	OrgId  int64
	Result []*OrgQuotaDTO
}

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 GetTempUserByCodeQuery

type GetTempUserByCodeQuery struct {
	Code string

	Result *TempUserDTO
}

type GetTempUsersQuery

type GetTempUsersQuery struct {
	OrgId  int64
	Email  string
	Status TempUserStatus

	Result []*TempUserDTO
}

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 GetUserQuotaByTargetQuery

type GetUserQuotaByTargetQuery struct {
	Target  string
	UserId  int64
	Default int64
	Result  *UserQuotaDTO
}

type GetUserQuotasQuery

type GetUserQuotasQuery struct {
	UserId int64
	Result []*UserQuotaDTO
}

type GetUserStarsQuery

type GetUserStarsQuery struct {
	UserId int64

	Result map[int64]bool // dashboard ids
}

type GlobalQuotaDTO

type GlobalQuotaDTO struct {
	Target string `json:"target"`
	Limit  int64  `json:"limit"`
	Used   int64  `json:"used"`
}

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

	Address1 string
	Address2 string
	City     string
	ZipCode  string
	State    string
	Country  string

	Created time.Time
	Updated time.Time
}

type OrgDTO

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

type OrgDetailsDTO

type OrgDetailsDTO struct {
	Id      int64   `json:"id"`
	Name    string  `json:"name"`
	Address Address `json:"address"`
}

type OrgQuotaDTO

type OrgQuotaDTO struct {
	OrgId  int64  `json:"org_id"`
	Target string `json:"target"`
	Limit  int64  `json:"limit"`
	Used   int64  `json:"used"`
}

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 Quota

type Quota struct {
	Id      int64
	OrgId   int64
	UserId  int64
	Target  string
	Limit   int64
	Created time.Time
	Updated time.Time
}

type QuotaScope

type QuotaScope struct {
	Name         string
	Target       string
	DefaultLimit int64
}

func GetQuotaScopes

func GetQuotaScopes(target string) ([]QuotaScope, error)

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 TempUser

type TempUser struct {
	Id              int64
	OrgId           int64
	Version         int
	Email           string
	Name            string
	Role            RoleType
	InvitedByUserId int64
	Status          TempUserStatus

	EmailSent   bool
	EmailSentOn time.Time
	Code        string
	RemoteAddr  string

	Created time.Time
	Updated time.Time
}

TempUser holds data for org invites and unconfirmed sign ups

type TempUserDTO

type TempUserDTO struct {
	Id             int64          `json:"id"`
	OrgId          int64          `json:"orgId"`
	Name           string         `json:"name"`
	Email          string         `json:"email"`
	Role           RoleType       `json:"role"`
	InvitedByLogin string         `json:"invitedByLogin"`
	InvitedByEmail string         `json:"invitedByEmail"`
	InvitedByName  string         `json:"invitedByName"`
	Code           string         `json:"code"`
	Status         TempUserStatus `json:"status"`
	Url            string         `json:"url"`
	EmailSent      bool           `json:"emailSent"`
	EmailSentOn    time.Time      `json:"emailSentOn"`
	Created        time.Time      `json:"createdOn"`
}

type TempUserStatus

type TempUserStatus string
const (
	TmpUserSignUpStarted TempUserStatus = "SignUpStarted"
	TmpUserInvitePending TempUserStatus = "InvitePending"
	TmpUserCompleted     TempUserStatus = "Completed"
	TmpUserRevoked       TempUserStatus = "Revoked"
)

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"`
	WithCredentials   bool                   `json:"withCredentials"`
	IsDefault         bool                   `json:"isDefault"`
	JsonData          map[string]interface{} `json:"jsonData"`

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

Also acts as api DTO

type UpdateOrgAddressCommand

type UpdateOrgAddressCommand struct {
	OrgId int64
	Address
}

type UpdateOrgCommand

type UpdateOrgCommand struct {
	Name  string
	OrgId int64
}

type UpdateOrgQuotaCmd

type UpdateOrgQuotaCmd struct {
	Target string `json:"target"`
	Limit  int64  `json:"limit"`
	OrgId  int64  `json:"-"`
}

type UpdateOrgUserCommand

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

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

type UpdateTempUserStatusCommand

type UpdateTempUserStatusCommand struct {
	Code   string
	Status TempUserStatus
}

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 UpdateUserQuotaCmd

type UpdateUserQuotaCmd struct {
	Target string `json:"target"`
	Limit  int64  `json:"limit"`
	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 UserIdDTO

type UserIdDTO struct {
	Id      int64  `json:"id"`
	Message string `json:"message"`
}

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 UserQuotaDTO

type UserQuotaDTO struct {
	UserId int64  `json:"user_id"`
	Target string `json:"target"`
	Limit  int64  `json:"limit"`
	Used   int64  `json:"used"`
}

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