-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.go
55 lines (46 loc) · 1.97 KB
/
config.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
//go:generate go run tools/withoutctx.go
package redash
import (
"context"
"github.com/winebarrel/redash-go/v2/internal/util"
)
type Config struct {
ClientConfig ClientConfig `json:"client_config"`
OrgSlug string `json:"org_slug"`
}
type ClientConfig struct {
AllowCustomJSVisualizations bool `json:"allowCustomJSVisualizations"`
AllowScriptsInUserInput bool `json:"allowScriptsInUserInput"`
AutoPublishNamedQueries bool `json:"autoPublishNamedQueries"`
BasePath string `json:"basePath"`
DashboardRefreshIntervals []int `json:"dashboardRefreshIntervals"`
DateFormat string `json:"dateFormat"`
DateFormatList []string `json:"dateFormatList"`
DateTimeFormat string `json:"dateTimeFormat"`
ExtendedAlertOptions bool `json:"extendedAlertOptions"`
FloatFormat string `json:"floatFormat"`
GoogleLoginEnabled bool `json:"googleLoginEnabled"`
IntegerFormat string `json:"integerFormat"`
MailSettingsMissing bool `json:"mailSettingsMissing"`
NewVersionAvailable bool `json:"newVersionAvailable"`
PageSize int `json:"pageSize"`
PageSizeOptions []int `json:"pageSizeOptions"`
QueryRefreshIntervals []int `json:"queryRefreshIntervals"`
ShowBeaconConsentMessage bool `json:"showBeaconConsentMessage"`
ShowPermissionsControl bool `json:"showPermissionsControl"`
TableCellMaxJSONSize int `json:"tableCellMaxJSONSize"`
TimeFormatList []string `json:"timeFormatList"`
Version string `json:"version"`
}
func (client *Client) GetConfig(ctx context.Context) (*Config, error) {
res, close, err := client.Get(ctx, "api/config", nil)
defer close()
if err != nil {
return nil, err
}
config := &Config{}
if err := util.UnmarshalBody(res, &config); err != nil {
return nil, err
}
return config, nil
}