The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
grafana/pkg/models/quotas.go

56 lines
1.0 KiB

package models
import (
"errors"
"github.com/grafana/grafana/pkg/setting"
"time"
)
type QuotaTarget string
const (
QUOTA_USER QuotaTarget = "user" //SQL table to query. ie. "select count(*) from user where org_id=?"
QUOTA_DATASOURCE QuotaTarget = "data_source"
QUOTA_DASHBOARD QuotaTarget = "dashboard"
)
var ErrInvalidQuotaTarget = errors.New("Invalid quota target")
func (q QuotaTarget) IsValid() bool {
_, ok := setting.Quota.Default[string(q)]
return ok
}
type Quota struct {
Id int64
OrgId int64
Target QuotaTarget
Limit int64
Created time.Time
Updated time.Time
}
type QuotaDTO struct {
OrgId int64 `json:"org_id"`
Target QuotaTarget `json:"target"`
Limit int64 `json:"limit"`
Used int64 `json:"used"`
}
type GetQuotaByTargetQuery struct {
Target QuotaTarget
OrgId int64
Result *QuotaDTO
}
type GetQuotasQuery struct {
OrgId int64
Result []*QuotaDTO
}
type UpdateQuotaCmd struct {
Target QuotaTarget `json:"target"`
Limit int64 `json:"limit"`
OrgId int64 `json:"-"`
}