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"
39 200 => success_response()
44 def delete_operation do
46 tags: ["Admin", "MediaProxyCache"],
47 summary: "Remove a banned MediaProxy URL from Cachex",
48 operationId: "AdminAPI.MediaProxyCacheController.delete",
49 security: [%{"oAuth" => ["write:media_proxy_caches"]}],
50 parameters: admin_api_params(),
58 urls: %Schema{type: :array, items: %Schema{type: :string, format: :uri}}
64 200 => success_response(),
65 400 => Operation.response("Error", "application/json", ApiError)
70 def purge_operation do
72 tags: ["Admin", "MediaProxyCache"],
73 summary: "Purge and optionally ban a MediaProxy URL",
74 operationId: "AdminAPI.MediaProxyCacheController.purge",
75 security: [%{"oAuth" => ["write:media_proxy_caches"]}],
76 parameters: admin_api_params(),
84 urls: %Schema{type: :array, items: %Schema{type: :string, format: :uri}},
85 ban: %Schema{type: :boolean, default: true}
91 200 => success_response(),
92 400 => Operation.response("Error", "application/json", ApiError)
97 defp success_response do
98 Operation.response("Array of banned MediaProxy URLs in Cachex", "application/json", %Schema{
106 description: "MediaProxy URLs"