2015-09-10 12:47:33 -05:00
|
|
|
package setting
|
|
|
|
|
2015-09-11 10:17:10 -05:00
|
|
|
type OrgQuota struct {
|
|
|
|
User int64 `target:"org_user"`
|
|
|
|
DataSource int64 `target:"data_source"`
|
|
|
|
Dashboard int64 `target:"dashboard"`
|
|
|
|
ApiKey int64 `target:"api_key"`
|
2021-05-04 11:16:28 -05:00
|
|
|
AlertRule int64 `target:"alert_rule"`
|
2015-09-11 10:17:10 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
type UserQuota struct {
|
|
|
|
Org int64 `target:"org_user"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type GlobalQuota struct {
|
2023-03-21 15:27:25 -05:00
|
|
|
Org int64 `target:"org"`
|
|
|
|
User int64 `target:"user"`
|
|
|
|
DataSource int64 `target:"data_source"`
|
|
|
|
Dashboard int64 `target:"dashboard"`
|
|
|
|
ApiKey int64 `target:"api_key"`
|
|
|
|
Session int64 `target:"-"`
|
|
|
|
AlertRule int64 `target:"alert_rule"`
|
|
|
|
File int64 `target:"file"`
|
|
|
|
Correlations int64 `target:"correlations"`
|
2015-09-11 10:17:10 -05:00
|
|
|
}
|
|
|
|
|
2015-09-10 12:47:33 -05:00
|
|
|
type QuotaSettings struct {
|
|
|
|
Enabled bool
|
2022-11-14 13:08:10 -06:00
|
|
|
Org OrgQuota
|
|
|
|
User UserQuota
|
|
|
|
Global GlobalQuota
|
2015-09-10 12:47:33 -05:00
|
|
|
}
|
|
|
|
|
2018-04-30 09:21:04 -05:00
|
|
|
func (cfg *Cfg) readQuotaSettings() {
|
2015-09-10 12:47:33 -05:00
|
|
|
// set global defaults.
|
2018-04-30 09:21:04 -05:00
|
|
|
quota := cfg.Raw.Section("quota")
|
2022-11-14 13:08:10 -06:00
|
|
|
cfg.Quota.Enabled = quota.Key("enabled").MustBool(false)
|
2015-09-11 10:17:10 -05:00
|
|
|
|
|
|
|
// per ORG Limits
|
2022-11-14 13:08:10 -06:00
|
|
|
cfg.Quota.Org = OrgQuota{
|
2015-09-11 10:17:10 -05:00
|
|
|
User: quota.Key("org_user").MustInt64(10),
|
|
|
|
DataSource: quota.Key("org_data_source").MustInt64(10),
|
|
|
|
Dashboard: quota.Key("org_dashboard").MustInt64(10),
|
|
|
|
ApiKey: quota.Key("org_api_key").MustInt64(10),
|
2024-01-05 17:19:12 -06:00
|
|
|
AlertRule: quota.Key("org_alert_rule").MustInt64(100),
|
2015-09-11 10:17:10 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// per User limits
|
2022-11-14 13:08:10 -06:00
|
|
|
cfg.Quota.User = UserQuota{
|
2015-09-11 10:17:10 -05:00
|
|
|
Org: quota.Key("user_org").MustInt64(10),
|
|
|
|
}
|
|
|
|
|
|
|
|
// Global Limits
|
2022-11-14 13:08:10 -06:00
|
|
|
cfg.Quota.Global = GlobalQuota{
|
2023-03-21 15:27:25 -05:00
|
|
|
User: quota.Key("global_user").MustInt64(-1),
|
|
|
|
Org: quota.Key("global_org").MustInt64(-1),
|
|
|
|
DataSource: quota.Key("global_data_source").MustInt64(-1),
|
|
|
|
Dashboard: quota.Key("global_dashboard").MustInt64(-1),
|
|
|
|
ApiKey: quota.Key("global_api_key").MustInt64(-1),
|
|
|
|
Session: quota.Key("global_session").MustInt64(-1),
|
|
|
|
File: quota.Key("global_file").MustInt64(-1),
|
2024-01-05 17:19:12 -06:00
|
|
|
AlertRule: quota.Key("global_alert_rule").MustInt64(-1),
|
2023-03-21 15:27:25 -05:00
|
|
|
Correlations: quota.Key("global_correlations").MustInt64(-1),
|
2015-09-11 10:17:10 -05:00
|
|
|
}
|
2015-09-10 12:47:33 -05:00
|
|
|
}
|