Use Logger.info for {:reject, reason}
[akkoma] / lib / pleroma / web / api_spec / operations / admin / relay_operation.ex
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
5 defmodule Pleroma.Web.ApiSpec.Admin.RelayOperation do
6 alias OpenApiSpex.Operation
7 alias OpenApiSpex.Schema
8
9 import Pleroma.Web.ApiSpec.Helpers
10
11 def open_api_operation(action) do
12 operation = String.to_existing_atom("#{action}_operation")
13 apply(__MODULE__, operation, [])
14 end
15
16 def index_operation do
17 %Operation{
18 tags: ["Admin", "Relays"],
19 summary: "List Relays",
20 operationId: "AdminAPI.RelayController.index",
21 security: [%{"oAuth" => ["read"]}],
22 responses: %{
23 200 =>
24 Operation.response("Response", "application/json", %Schema{
25 type: :object,
26 properties: %{
27 relays: %Schema{
28 type: :array,
29 items: %Schema{type: :string},
30 example: ["lain.com", "mstdn.io"]
31 }
32 }
33 })
34 }
35 }
36 end
37
38 def follow_operation do
39 %Operation{
40 tags: ["Admin", "Relays"],
41 summary: "Follow a Relay",
42 operationId: "AdminAPI.RelayController.follow",
43 security: [%{"oAuth" => ["write:follows"]}],
44 requestBody:
45 request_body("Parameters", %Schema{
46 type: :object,
47 properties: %{
48 relay_url: %Schema{type: :string, format: :uri}
49 }
50 }),
51 responses: %{
52 200 =>
53 Operation.response("Status", "application/json", %Schema{
54 type: :string,
55 example: "http://mastodon.example.org/users/admin"
56 })
57 }
58 }
59 end
60
61 def unfollow_operation do
62 %Operation{
63 tags: ["Admin", "Relays"],
64 summary: "Unfollow a Relay",
65 operationId: "AdminAPI.RelayController.unfollow",
66 security: [%{"oAuth" => ["write:follows"]}],
67 requestBody:
68 request_body("Parameters", %Schema{
69 type: :object,
70 properties: %{
71 relay_url: %Schema{type: :string, format: :uri}
72 }
73 }),
74 responses: %{
75 200 =>
76 Operation.response("Status", "application/json", %Schema{
77 type: :string,
78 example: "http://mastodon.example.org/users/admin"
79 })
80 }
81 }
82 end
83 end