From 2753285b7722fdb47f0ebb2180e997cf72f65d1a Mon Sep 17 00:00:00 2001 From: Alex S Date: Sun, 29 Sep 2019 11:17:38 +0300 Subject: config editing through database --- docs/API/admin_api.md | 120 +++++++++++++++++++++++++++++++++++--------------- 1 file changed, 85 insertions(+), 35 deletions(-) (limited to 'docs/API/admin_api.md') diff --git a/docs/API/admin_api.md b/docs/API/admin_api.md index d98a78af0..851c526d6 100644 --- a/docs/API/admin_api.md +++ b/docs/API/admin_api.md @@ -669,7 +669,7 @@ Note: Available `:permission_group` is currently moderator and admin. 404 is ret ### Run mix task pleroma.config migrate_to_db -Copy settings on key `:pleroma` to DB. +Copies `pleroma` environment settings to the database. - Params: none - Response: @@ -682,7 +682,7 @@ Copy settings on key `:pleroma` to DB. ### Run mix task pleroma.config migrate_from_db -Copy all settings from DB to `config/prod.exported_from_db.secret.exs` with deletion from DB. +Copies all settings from database to `config/{env}.exported_from_db.secret.exs` with deletion from the table. Where `{env}` is the environment in which `pleroma` is running. - Params: none - Response: @@ -693,9 +693,9 @@ Copy all settings from DB to `config/prod.exported_from_db.secret.exs` with dele ## `GET /api/pleroma/admin/config` -### List config settings +### Get saved config settings -List config settings only works with `:pleroma => :instance => :dynamic_configuration` setting to `true`. +**Only works when `:dynamic_configuration` is `true`.** - Params: none - Response: @@ -704,9 +704,9 @@ List config settings only works with `:pleroma => :instance => :dynamic_configur { configs: [ { - "group": string, - "key": string or string with leading `:` for atoms, - "value": string or {} or [] or {"tuple": []} + "group": ":pleroma", + "key": "Pleroma.Upload", + "value": [] } ] } @@ -716,44 +716,61 @@ List config settings only works with `:pleroma => :instance => :dynamic_configur ### Update config settings -Updating config settings only works with `:pleroma => :instance => :dynamic_configuration` setting to `true`. -Module name can be passed as string, which starts with `Pleroma`, e.g. `"Pleroma.Upload"`. -Atom keys and values can be passed with `:` in the beginning, e.g. `":upload"`. -Tuples can be passed as `{"tuple": ["first_val", Pleroma.Module, []]}`. -`{"tuple": ["some_string", "Pleroma.Some.Module", []]}` will be converted to `{"some_string", Pleroma.Some.Module, []}`. -Keywords can be passed as lists with 2 child tuples, e.g. -`[{"tuple": ["first_val", Pleroma.Module]}, {"tuple": ["second_val", true]}]`. +**Only works when `:dynamic_configuration` is `true`.** + +Some modifications are necessary to save the config settings correctly: -If value contains list of settings `[subkey: val1, subkey2: val2, subkey3: val3]`, it's possible to remove only subkeys instead of all settings passing `subkeys` parameter. E.g.: -{"group": "pleroma", "key": "some_key", "delete": "true", "subkeys": [":subkey", ":subkey3"]}. +- strings which start with `Pleroma.`, `Phoenix.`, `Tesla.` or strings like `Oban`, `Ueberauth` will be converted to modules; +``` +"Pleroma.Upload" -> Pleroma.Upload +"Oban" -> Oban +``` +- strings starting with `:` will be converted to atoms; +``` +":pleroma" -> :pleroma +``` +- objects with `tuple` key and array value will be converted to atoms; +``` +{"tuple": ["string", "Pleroma.Upload", []]} -> {"string", Pleroma.Upload, []} +``` +- arrays with *tuple objects* and 2 childs in array will be converted to keywords; +``` +[{"tuple": [":key1", "value"]}, {"tuple": [":key2", "value"]}] -> [key1: "value", key2: "value"] +``` -Compile time settings (need instance reboot): -- all settings by this keys: +Most of the settings will be applied in `runtime`, this means that you don't need to restart the instance. But some settings are applied in `compile time` and require a reboot of the instance, such as: +- all settings inside these keys: - `:hackney_pools` - `:chat` - `Pleroma.Web.Endpoint` - - `Pleroma.Repo` -- part settings: - - `Pleroma.Captcha` -> `:seconds_valid` - - `Pleroma.Upload` -> `:proxy_remote` - - `:instance` -> `:upload_limit` +- partially settings inside these keys: + - `:seconds_valid` in `Pleroma.Captcha` + - `:proxy_remote` in `Pleroma.Upload` + - `:upload_limit` in `:instance` - Params: - - `configs` => [ - - `group` (string) - - `key` (string or string with leading `:` for atoms) - - `value` (string, [], {} or {"tuple": []}) - - `delete` = true (optional, if parameter must be deleted) - - `subkeys` [(string with leading `:` for atoms)] (optional, works only if `delete=true` parameter is passed, otherwise will be ignored) - ] + - `configs` - array of config objects + - config object params: + - `group` - string (**required**) + - `key` - string (**required**) + - `value` - string, [], {} or {"tuple": []} (**required**) + - `delete` - true (*optional*, if setting must be deleted) + - `subkeys` - array of strings (*optional*, only works when `delete=true` parameter is passed, otherwise will be ignored) + +*When a value have several nested settings, you can delete only some nested settings by passing a parameter `subkeys`, without deleting all settings by key.* +``` +[subkey: val1, subkey2: val2, subkey3: val3] \\ initial value +{"group": ":pleroma", "key": "some_key", "delete": true, "subkeys": [":subkey", ":subkey3"]} \\ passing json for deletion +[subkey2: val2] \\ value after deletion +``` -- Request (example): +- Request: ```json { configs: [ { - "group": "pleroma", + "group": ":pleroma", "key": "Pleroma.Upload", "value": [ {"tuple": [":uploader", "Pleroma.Uploaders.Local"]}, @@ -784,14 +801,47 @@ Compile time settings (need instance reboot): { configs: [ { - "group": string, - "key": string or string with leading `:` for atoms, - "value": string or {} or [] or {"tuple": []} + "group": ":pleroma", + "key": "Pleroma.Upload", + "value": [...] } ] } ``` +## ` GET /api/pleroma/admin/config/descriptions` + +### Get JSON with config descriptions. +Loads json generated from `config/descriptions.exs`. + +- Params: none +- Response: + +```json +[{ + "group": ":pleroma", // string + "key": "ModuleName", // string + "type": "group", // string or list with possible values, + "description": "Upload general settings", // string + "children": [ + { + "key": ":uploader", // string or module name `Pleroma.Upload` + "type": "module", + "description": "Module which will be used for uploads", + "suggestions": ["module1", "module2"] + }, + { + "key": ":filters", + "type": ["list", "module"], + "description": "List of filter modules for uploads", + "suggestions": [ + "module1", "module2", "module3" + ] + } + ] +}] +``` + ## `GET /api/pleroma/admin/moderation_log` ### Get moderation log -- cgit v1.2.3 From 5cacb988b99347b228a30743fbcf310c9479b3f9 Mon Sep 17 00:00:00 2001 From: Alexander Date: Fri, 6 Dec 2019 15:12:56 +0300 Subject: partially settings update --- docs/API/admin_api.md | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'docs/API/admin_api.md') diff --git a/docs/API/admin_api.md b/docs/API/admin_api.md index 851c526d6..dff12db56 100644 --- a/docs/API/admin_api.md +++ b/docs/API/admin_api.md @@ -764,6 +764,41 @@ Most of the settings will be applied in `runtime`, this means that you don't nee [subkey2: val2] \\ value after deletion ``` +*Most of the settings can be partially updated through merge old values with new values, except settings value of which is list or is not keyword.* + +Example of setting without keyword in value: +```elixir +config :tesla, :adapter, Tesla.Adapter.Hackney +``` + +List of settings which have list in value: +```elixir +@full_key_update [ + {:pleroma, :ecto_repos}, + {:quack, :meta}, + {:mime, :types}, + {:cors_plug, [:max_age, :methods, :expose, :headers]}, + {:auto_linker, :opts}, + {:swarm, :node_blacklist} + ] +``` + +*Settings without explicit key must be sended in separate config object params.* +```elixir +config :quack, + level: :debug, + meta: [:all], + ... +``` +```json +{ + configs: [ + {"group": ":quack", "key": ":level", "value": ":debug"}, + {"group": ":quack", "key": ":meta", "value": [":all"]}, + ... + ] +} +``` - Request: ```json -- cgit v1.2.3 From fea734ca703b686701b87c8c4c4969deb05d1f92 Mon Sep 17 00:00:00 2001 From: Alexander Date: Fri, 6 Dec 2019 17:50:53 +0300 Subject: errors on endpoints --- docs/API/admin_api.md | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) (limited to 'docs/API/admin_api.md') diff --git a/docs/API/admin_api.md b/docs/API/admin_api.md index dff12db56..98af8e8f3 100644 --- a/docs/API/admin_api.md +++ b/docs/API/admin_api.md @@ -665,19 +665,6 @@ Note: Available `:permission_group` is currently moderator and admin. 404 is ret - 404 Not Found `"Not found"` - On success: 200 OK `{}` -## `GET /api/pleroma/admin/config/migrate_to_db` - -### Run mix task pleroma.config migrate_to_db - -Copies `pleroma` environment settings to the database. - -- Params: none -- Response: - -```json -{} -``` - ## `GET /api/pleroma/admin/config/migrate_from_db` ### Run mix task pleroma.config migrate_from_db @@ -686,6 +673,8 @@ Copies all settings from database to `config/{env}.exported_from_db.secret.exs` - Params: none - Response: + - On failure: + - 400 Bad Request `"To use this endpoint you need to enable dynamic configuration."` ```json {} @@ -699,6 +688,9 @@ Copies all settings from database to `config/{env}.exported_from_db.secret.exs` - Params: none - Response: + - On failure: + - 400 Bad Request `"To use this endpoint you need to enable dynamic configuration."` + - 400 Bad Request `"To use dynamic configuration migrate your settings to database."` ```json { @@ -831,7 +823,8 @@ config :quack, ``` - Response: - + - On failure: + - 400 Bad Request `"To use this endpoint you need to enable dynamic configuration."` ```json { configs: [ -- cgit v1.2.3 From bb9a43c3ae7c63b21b687d018b9497f3614566bf Mon Sep 17 00:00:00 2001 From: Alexander Date: Thu, 12 Dec 2019 16:44:24 +0300 Subject: typo fix --- docs/API/admin_api.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'docs/API/admin_api.md') diff --git a/docs/API/admin_api.md b/docs/API/admin_api.md index 98af8e8f3..e0eda0841 100644 --- a/docs/API/admin_api.md +++ b/docs/API/admin_api.md @@ -807,7 +807,7 @@ config :quack, {"tuple": [":proxy_opts", [ {"tuple": [":redirect_on_failure", false]}, {"tuple": [":max_body_length", 1048576]}, - {"tuple": [":http": [ + {"tuple": [":http", [ {"tuple": [":follow_redirect", true]}, {"tuple": [":pool", ":upload"]}, ]]} -- cgit v1.2.3 From 958d0452e4e52f44301e4d9211fc965c1c184363 Mon Sep 17 00:00:00 2001 From: Alexander Strizhakov Date: Fri, 10 Jan 2020 18:18:09 +0300 Subject: fix for pleroma assets group update --- docs/API/admin_api.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'docs/API/admin_api.md') diff --git a/docs/API/admin_api.md b/docs/API/admin_api.md index e0eda0841..cd4916248 100644 --- a/docs/API/admin_api.md +++ b/docs/API/admin_api.md @@ -3,7 +3,7 @@ Authentication is required and the user must be an admin. Configuration options: - + * `[:auth, :enforce_oauth_admin_scope_usage]` — OAuth admin scope requirement toggle. If `true`, admin actions explicitly demand admin OAuth scope(s) presence in OAuth token (client app must support admin scopes). If `false` and token doesn't have admin scope(s), `is_admin` user flag grants access to admin-specific actions. @@ -763,15 +763,17 @@ Example of setting without keyword in value: config :tesla, :adapter, Tesla.Adapter.Hackney ``` -List of settings which have list in value: +List of settings which support only full update: ```elixir @full_key_update [ {:pleroma, :ecto_repos}, + {:pleroma, :assets}, {:quack, :meta}, {:mime, :types}, {:cors_plug, [:max_age, :methods, :expose, :headers]}, {:auto_linker, :opts}, - {:swarm, :node_blacklist} + {:swarm, :node_blacklist}, + {:logger, :backends} ] ``` -- cgit v1.2.3 From 7d128ca2083d83486a05d8c4456aa4090006e781 Mon Sep 17 00:00:00 2001 From: Alexander Strizhakov Date: Fri, 10 Jan 2020 19:34:19 +0300 Subject: dynamic_configuration renaming and moving it from instance settings --- docs/API/admin_api.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'docs/API/admin_api.md') diff --git a/docs/API/admin_api.md b/docs/API/admin_api.md index cd4916248..f2a0906b8 100644 --- a/docs/API/admin_api.md +++ b/docs/API/admin_api.md @@ -684,7 +684,7 @@ Copies all settings from database to `config/{env}.exported_from_db.secret.exs` ### Get saved config settings -**Only works when `:dynamic_configuration` is `true`.** +**Only works when configuration from database is enabled.** - Params: none - Response: @@ -708,7 +708,7 @@ Copies all settings from database to `config/{env}.exported_from_db.secret.exs` ### Update config settings -**Only works when `:dynamic_configuration` is `true`.** +**Only works when configuration from database is enabled.** Some modifications are necessary to save the config settings correctly: -- cgit v1.2.3 From d933fd3d61df2f9c346ab08fb2c95ddc12803858 Mon Sep 17 00:00:00 2001 From: Alexander Strizhakov Date: Fri, 10 Jan 2020 19:49:40 +0300 Subject: more renamings --- docs/API/admin_api.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'docs/API/admin_api.md') diff --git a/docs/API/admin_api.md b/docs/API/admin_api.md index f2a0906b8..37cd1910d 100644 --- a/docs/API/admin_api.md +++ b/docs/API/admin_api.md @@ -674,7 +674,7 @@ Copies all settings from database to `config/{env}.exported_from_db.secret.exs` - Params: none - Response: - On failure: - - 400 Bad Request `"To use this endpoint you need to enable dynamic configuration."` + - 400 Bad Request `"To use this endpoint you need to enable configuration from database."` ```json {} @@ -689,8 +689,8 @@ Copies all settings from database to `config/{env}.exported_from_db.secret.exs` - Params: none - Response: - On failure: - - 400 Bad Request `"To use this endpoint you need to enable dynamic configuration."` - - 400 Bad Request `"To use dynamic configuration migrate your settings to database."` + - 400 Bad Request `"To use this endpoint you need to enable configuration from database."` + - 400 Bad Request `"To use configuration from database migrate your settings to database."` ```json { @@ -826,7 +826,7 @@ config :quack, - Response: - On failure: - - 400 Bad Request `"To use this endpoint you need to enable dynamic configuration."` + - 400 Bad Request `"To use this endpoint you need to enable configuration from database."` ```json { configs: [ -- cgit v1.2.3 From a9c6f119ac8fb2124241a61b26d97bff207218d8 Mon Sep 17 00:00:00 2001 From: Alexander Strizhakov Date: Wed, 22 Jan 2020 18:08:53 +0300 Subject: docs update --- docs/API/admin_api.md | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'docs/API/admin_api.md') diff --git a/docs/API/admin_api.md b/docs/API/admin_api.md index 37cd1910d..534c49eed 100644 --- a/docs/API/admin_api.md +++ b/docs/API/admin_api.md @@ -682,11 +682,12 @@ Copies all settings from database to `config/{env}.exported_from_db.secret.exs` ## `GET /api/pleroma/admin/config` -### Get saved config settings +### Get list of merged default settings with saved in database. **Only works when configuration from database is enabled.** -- Params: none +- Params: + - `only_db`: true (*optional*, get only saved in database settings) - Response: - On failure: - 400 Bad Request `"To use this endpoint you need to enable configuration from database."` @@ -734,7 +735,6 @@ Most of the settings will be applied in `runtime`, this means that you don't nee - all settings inside these keys: - `:hackney_pools` - `:chat` - - `Pleroma.Web.Endpoint` - partially settings inside these keys: - `:seconds_valid` in `Pleroma.Captcha` - `:proxy_remote` in `Pleroma.Upload` @@ -763,11 +763,10 @@ Example of setting without keyword in value: config :tesla, :adapter, Tesla.Adapter.Hackney ``` -List of settings which support only full update: +List of settings which support only full update by key: ```elixir @full_key_update [ {:pleroma, :ecto_repos}, - {:pleroma, :assets}, {:quack, :meta}, {:mime, :types}, {:cors_plug, [:max_age, :methods, :expose, :headers]}, @@ -777,6 +776,17 @@ List of settings which support only full update: ] ``` +List of settings which support only full update by subkey: +```elixir +@full_subkey_update [ + {:pleroma, :assets, :mascots}, + {:pleroma, :emoji, :groups}, + {:pleroma, :workers, :retries}, + {:pleroma, :mrf_subchain, :match_actor}, + {:pleroma, :mrf_keyword, :replace} + ] +``` + *Settings without explicit key must be sended in separate config object params.* ```elixir config :quack, -- cgit v1.2.3 From f3e074e949ce603446728b02ea059efe2a05a841 Mon Sep 17 00:00:00 2001 From: Alexander Strizhakov Date: Wed, 22 Jan 2020 18:22:54 +0300 Subject: little fixes --- docs/API/admin_api.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'docs/API/admin_api.md') diff --git a/docs/API/admin_api.md b/docs/API/admin_api.md index 534c49eed..07aa7ec3f 100644 --- a/docs/API/admin_api.md +++ b/docs/API/admin_api.md @@ -722,11 +722,11 @@ Some modifications are necessary to save the config settings correctly: ``` ":pleroma" -> :pleroma ``` -- objects with `tuple` key and array value will be converted to atoms; +- objects with `tuple` key and array value will be converted to tuples; ``` {"tuple": ["string", "Pleroma.Upload", []]} -> {"string", Pleroma.Upload, []} ``` -- arrays with *tuple objects* and 2 childs in array will be converted to keywords; +- arrays with *tuple objects* will be converted to keywords; ``` [{"tuple": [":key1", "value"]}, {"tuple": [":key2", "value"]}] -> [key1: "value", key2: "value"] ``` -- cgit v1.2.3