2015-12-03 01:52:37 -06:00
|
|
|
package models
|
|
|
|
|
2016-01-20 21:41:02 -06:00
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
"time"
|
2016-01-22 16:17:22 -06:00
|
|
|
|
2016-11-12 16:26:33 -06:00
|
|
|
"github.com/grafana/grafana/pkg/components/securejsondata"
|
2016-01-20 21:41:02 -06:00
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
2020-11-05 06:07:06 -06:00
|
|
|
ErrPluginSettingNotFound = errors.New("plugin setting not found")
|
2016-01-20 21:41:02 -06:00
|
|
|
)
|
2015-12-03 09:43:55 -06:00
|
|
|
|
2016-02-25 07:55:31 -06:00
|
|
|
type PluginSetting struct {
|
2016-01-22 16:17:22 -06:00
|
|
|
Id int64
|
2016-02-25 07:55:31 -06:00
|
|
|
PluginId string
|
2016-01-22 16:17:22 -06:00
|
|
|
OrgId int64
|
|
|
|
Enabled bool
|
|
|
|
Pinned bool
|
|
|
|
JsonData map[string]interface{}
|
2016-11-12 16:26:33 -06:00
|
|
|
SecureJsonData securejsondata.SecureJsonData
|
2016-07-07 11:11:03 -05:00
|
|
|
PluginVersion string
|
2015-12-03 09:43:55 -06:00
|
|
|
|
|
|
|
Created time.Time
|
|
|
|
Updated time.Time
|
|
|
|
}
|
|
|
|
|
|
|
|
// ----------------------
|
|
|
|
// COMMANDS
|
|
|
|
|
|
|
|
// Also acts as api DTO
|
2016-02-25 07:55:31 -06:00
|
|
|
type UpdatePluginSettingCmd struct {
|
2016-01-22 16:17:22 -06:00
|
|
|
Enabled bool `json:"enabled"`
|
|
|
|
Pinned bool `json:"pinned"`
|
|
|
|
JsonData map[string]interface{} `json:"jsonData"`
|
|
|
|
SecureJsonData map[string]string `json:"secureJsonData"`
|
2016-07-07 11:11:03 -05:00
|
|
|
PluginVersion string `json:"version"`
|
2015-12-03 09:43:55 -06:00
|
|
|
|
2016-02-25 07:55:31 -06:00
|
|
|
PluginId string `json:"-"`
|
|
|
|
OrgId int64 `json:"-"`
|
2015-12-03 09:43:55 -06:00
|
|
|
}
|
|
|
|
|
2016-07-07 11:11:03 -05:00
|
|
|
// specific command, will only update version
|
|
|
|
type UpdatePluginSettingVersionCmd struct {
|
|
|
|
PluginVersion string
|
|
|
|
PluginId string `json:"-"`
|
|
|
|
OrgId int64 `json:"-"`
|
|
|
|
}
|
|
|
|
|
2016-11-12 16:26:33 -06:00
|
|
|
func (cmd *UpdatePluginSettingCmd) GetEncryptedJsonData() securejsondata.SecureJsonData {
|
|
|
|
return securejsondata.GetEncryptedJsonData(cmd.SecureJsonData)
|
2016-02-10 09:43:35 -06:00
|
|
|
}
|
|
|
|
|
2015-12-03 09:43:55 -06:00
|
|
|
// ---------------------
|
|
|
|
// QUERIES
|
2016-03-08 11:17:47 -06:00
|
|
|
|
|
|
|
type PluginSettingInfoDTO struct {
|
2016-07-07 11:11:03 -05:00
|
|
|
OrgId int64
|
|
|
|
PluginId string
|
|
|
|
Enabled bool
|
|
|
|
Pinned bool
|
|
|
|
PluginVersion string
|
2015-12-03 01:52:37 -06:00
|
|
|
}
|
2016-01-20 21:41:02 -06:00
|
|
|
|
2016-02-25 07:55:31 -06:00
|
|
|
type GetPluginSettingByIdQuery struct {
|
|
|
|
PluginId string
|
|
|
|
OrgId int64
|
|
|
|
Result *PluginSetting
|
2016-01-20 21:41:02 -06:00
|
|
|
}
|
2016-07-08 05:26:51 -05:00
|
|
|
|
|
|
|
type PluginStateChangedEvent struct {
|
|
|
|
PluginId string
|
|
|
|
OrgId int64
|
|
|
|
Enabled bool
|
|
|
|
}
|