grafana/pkg/models/apikey.go

71 lines
1.1 KiB
Go
Raw Normal View History

2015-01-27 01:26:11 -06:00
package models
import (
"errors"
"time"
)
var ErrInvalidApiKey = errors.New("Invalid API Key")
type ApiKey struct {
Id int64
OrgId int64
Name string
Key string
Role RoleType
Created time.Time
Updated time.Time
2015-01-27 01:26:11 -06:00
}
// ---------------------
// COMMANDS
type AddApiKeyCommand struct {
Name string `json:"name" binding:"Required"`
Role RoleType `json:"role" binding:"Required"`
OrgId int64 `json:"-"`
Key string `json:"-"`
2015-01-27 01:26:11 -06:00
Result *ApiKey `json:"-"`
}
type UpdateApiKeyCommand struct {
Id int64 `json:"id"`
Name string `json:"name"`
Role RoleType `json:"role"`
OrgId int64 `json:"-"`
2015-01-27 01:26:11 -06:00
}
type DeleteApiKeyCommand struct {
Id int64 `json:"id"`
OrgId int64 `json:"-"`
2015-01-27 01:26:11 -06:00
}
// ----------------------
// QUERIES
type GetApiKeysQuery struct {
OrgId int64
Result []*ApiKey
2015-01-27 01:26:11 -06:00
}
type GetApiKeyByNameQuery struct {
KeyName string
OrgId int64
Result *ApiKey
2015-01-27 01:26:11 -06:00
}
type GetApiKeyByIdQuery struct {
ApiKeyId int64
Result *ApiKey
}
2015-01-27 01:26:11 -06:00
// ------------------------
// DTO & Projections
type ApiKeyDTO struct {
Id int64 `json:"id"`
Name string `json:"name"`
Role RoleType `json:"role"`
}