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.MediaProxyCacheOperation 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, [])
17 def index_operation do
19 tags: ["Admin", "MediaProxyCache"],
20 summary: "Fetch a paginated list of all banned MediaProxy URLs in Cachex",
21 operationId: "AdminAPI.MediaProxyCacheController.index",
22 security: [%{"oAuth" => ["read:media_proxy_caches"]}],
27 %Schema{type: :integer, default: 1},
33 %Schema{type: :integer, default: 50},
34 "Number of statuses to return"
38 200 => success_response()
43 def delete_operation do
45 tags: ["Admin", "MediaProxyCache"],
46 summary: "Remove a banned MediaProxy URL from Cachex",
47 operationId: "AdminAPI.MediaProxyCacheController.delete",
48 security: [%{"oAuth" => ["write:media_proxy_caches"]}],
56 urls: %Schema{type: :array, items: %Schema{type: :string, format: :uri}}
62 200 => success_response(),
63 400 => Operation.response("Error", "application/json", ApiError)
68 def purge_operation do
70 tags: ["Admin", "MediaProxyCache"],
71 summary: "Purge and optionally ban a MediaProxy URL",
72 operationId: "AdminAPI.MediaProxyCacheController.purge",
73 security: [%{"oAuth" => ["write:media_proxy_caches"]}],
81 urls: %Schema{type: :array, items: %Schema{type: :string, format: :uri}},
82 ban: %Schema{type: :boolean, default: true}
88 200 => success_response(),
89 400 => Operation.response("Error", "application/json", ApiError)
94 defp success_response do
95 Operation.response("Array of banned MediaProxy URLs in Cachex", "application/json", %Schema{
103 description: "MediaProxy URLs"