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.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
19 summary: "Retrieve a list of relays",
20 operationId: "AdminAPI.RelayController.index",
21 security: [%{"oAuth" => ["admin:read"]}],
22 parameters: admin_api_params(),
25 Operation.response("Response", "application/json", %Schema{
38 def follow_operation do
41 summary: "Follow a relay",
42 operationId: "AdminAPI.RelayController.follow",
43 security: [%{"oAuth" => ["admin: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
55 summary: "Unfollow a relay",
56 operationId: "AdminAPI.RelayController.unfollow",
57 security: [%{"oAuth" => ["admin:write:follows"]}],
58 parameters: admin_api_params(),
59 requestBody: request_body("Parameters", relay_unfollow()),
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}
95 defp relay_unfollow do
99 relay_url: %Schema{type: :string, format: :uri},
100 force: %Schema{type: :boolean, default: false}