Merge remote-tracking branch 'upstream/develop' into linkify
[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 parameters: admin_api_params(),
23 responses: %{
24 200 =>
25 Operation.response("Response", "application/json", %Schema{
26 type: :object,
27 properties: %{
28 relays: %Schema{
29 type: :array,
30 items: %Schema{type: :string},
31 example: ["lain.com", "mstdn.io"]
32 }
33 }
34 })
35 }
36 }
37 end
38
39 def follow_operation do
40 %Operation{
41 tags: ["Admin", "Relays"],
42 summary: "Follow a Relay",
43 operationId: "AdminAPI.RelayController.follow",
44 security: [%{"oAuth" => ["write:follows"]}],
45 parameters: admin_api_params(),
46 requestBody:
47 request_body("Parameters", %Schema{
48 type: :object,
49 properties: %{
50 relay_url: %Schema{type: :string, format: :uri}
51 }
52 }),
53 responses: %{
54 200 =>
55 Operation.response("Status", "application/json", %Schema{
56 type: :string,
57 example: "http://mastodon.example.org/users/admin"
58 })
59 }
60 }
61 end
62
63 def unfollow_operation do
64 %Operation{
65 tags: ["Admin", "Relays"],
66 summary: "Unfollow a Relay",
67 operationId: "AdminAPI.RelayController.unfollow",
68 security: [%{"oAuth" => ["write:follows"]}],
69 parameters: admin_api_params(),
70 requestBody:
71 request_body("Parameters", %Schema{
72 type: :object,
73 properties: %{
74 relay_url: %Schema{type: :string, format: :uri}
75 }
76 }),
77 responses: %{
78 200 =>
79 Operation.response("Status", "application/json", %Schema{
80 type: :string,
81 example: "http://mastodon.example.org/users/admin"
82 })
83 }
84 }
85 end
86 end