-
Notifications
You must be signed in to change notification settings - Fork 4.9k
/
setting.clj
36 lines (30 loc) · 1.05 KB
/
setting.clj
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
(ns metabase.api.setting
"/api/setting endpoints"
(:require [compojure.core :refer [GET PUT]]
[metabase.api.common :as api]
[metabase.models.setting :as setting]
[metabase.util.schema :as su]))
(api/defendpoint GET "/"
"Get all `Settings` and their values. You must be a superuser to do this."
[]
(api/check-superuser)
(setting/all))
(api/defendpoint PUT "/"
"Update multiple `Settings` values. You must be a superuser to do this."
[:as {settings :body}]
(api/check-superuser)
(setting/set-many! settings))
(api/defendpoint GET "/:key"
"Fetch a single `Setting`. You must be a superuser to do this."
[key]
{key su/NonBlankString}
(api/check-superuser)
(setting/user-facing-value key))
(api/defendpoint PUT "/:key"
"Create/update a `Setting`. You must be a superuser to do this.
This endpoint can also be used to delete Settings by passing `nil` for `:value`."
[key :as {{:keys [value]} :body}]
{key su/NonBlankString}
(api/check-superuser)
(setting/set! key value))
(api/define-routes)