1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Web.ApiSpec.Admin.RelayOperation do
6 alias OpenApiSpex.Operation
7 alias OpenApiSpex.Schema
9 import Pleroma.Web.ApiSpec.Helpers
11 def open_api_operation(action) do
12 operation = String.to_existing_atom("#{action}_operation")
13 apply(__MODULE__, operation, [])
16 def index_operation do
18 tags: ["Admin", "Relays"],
19 summary: "List Relays",
20 operationId: "AdminAPI.RelayController.index",
21 security: [%{"oAuth" => ["read"]}],
22 parameters: admin_api_params(),
25 Operation.response("Response", "application/json", %Schema{
38 def follow_operation do
40 tags: ["Admin", "Relays"],
41 summary: "Follow a Relay",
42 operationId: "AdminAPI.RelayController.follow",
43 security: [%{"oAuth" => ["write:follows"]}],
44 parameters: admin_api_params(),
45 requestBody: request_body("Parameters", relay_url()),
47 200 => Operation.response("Status", "application/json", relay())
52 def unfollow_operation do
54 tags: ["Admin", "Relays"],
55 summary: "Unfollow a Relay",
56 operationId: "AdminAPI.RelayController.unfollow",
57 security: [%{"oAuth" => ["write:follows"]}],
58 parameters: admin_api_params(),
59 requestBody: request_body("Parameters", relay_url()),
62 Operation.response("Status", "application/json", %Schema{
64 example: "http://mastodon.example.org/users/admin"
76 example: "https://example.com/relay"
78 followed_back: %Schema{
80 description: "Is relay followed back by this actor?"
90 relay_url: %Schema{type: :string, format: :uri}