1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Web.ApiSpec.Admin.ConfigOperation do
6 alias OpenApiSpex.Operation
7 alias OpenApiSpex.Schema
8 alias Pleroma.Web.ApiSpec.Schemas.ApiError
10 import Pleroma.Web.ApiSpec.Helpers
12 def open_api_operation(action) do
13 operation = String.to_existing_atom("#{action}_operation")
14 apply(__MODULE__, operation, [])
19 tags: ["Instance configuration"],
20 summary: "Retrieve instance configuration",
21 operationId: "AdminAPI.ConfigController.show",
26 %Schema{type: :boolean, default: false},
27 "Get only saved in database settings"
31 security: [%{"oAuth" => ["admin:read"]}],
33 200 => Operation.response("Config", "application/json", config_response()),
34 400 => Operation.response("Bad Request", "application/json", ApiError)
39 def update_operation do
41 tags: ["Instance configuration"],
42 summary: "Update instance configuration",
43 operationId: "AdminAPI.ConfigController.update",
44 security: [%{"oAuth" => ["admin:write"]}],
45 parameters: admin_api_params(),
47 request_body("Parameters", %Schema{
55 group: %Schema{type: :string},
56 key: %Schema{type: :string},
58 delete: %Schema{type: :boolean},
59 subkeys: %Schema{type: :array, items: %Schema{type: :string}}
66 200 => Operation.response("Config", "application/json", config_response()),
67 400 => Operation.response("Bad Request", "application/json", ApiError)
72 def descriptions_operation do
74 tags: ["Instance configuration"],
75 summary: "Retrieve config description",
76 operationId: "AdminAPI.ConfigController.descriptions",
77 security: [%{"oAuth" => ["admin:read"]}],
78 parameters: admin_api_params(),
81 Operation.response("Config Descriptions", "application/json", %Schema{
86 group: %Schema{type: :string},
87 key: %Schema{type: :string},
88 type: %Schema{oneOf: [%Schema{type: :string}, %Schema{type: :array}]},
89 description: %Schema{type: :string},
95 key: %Schema{type: :string},
96 type: %Schema{oneOf: [%Schema{type: :string}, %Schema{type: :array}]},
97 description: %Schema{type: :string},
98 suggestions: %Schema{type: :array}
105 400 => Operation.response("Bad Request", "application/json", ApiError)
113 %Schema{type: :array},
114 %Schema{type: :object},
115 %Schema{type: :string},
116 %Schema{type: :integer},
117 %Schema{type: :boolean}
122 defp config_response do
131 group: %Schema{type: :string},
132 key: %Schema{type: :string},
137 need_reboot: %Schema{
140 "If `need_reboot` is `true`, instance must be restarted, so reboot time settings can take effect"