1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2021 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: ["MediaProxy cache"],
20 summary: "Retrieve a list of banned MediaProxy URLs",
21 operationId: "AdminAPI.MediaProxyCacheController.index",
22 security: [%{"oAuth" => ["admin:read:media_proxy_caches"]}],
27 %Schema{type: :string, default: nil},
33 %Schema{type: :integer, default: 1},
39 %Schema{type: :integer, default: 50},
40 "Number of statuses to return"
47 "Array of MediaProxy URLs",
52 count: %Schema{type: :integer},
53 page_size: %Schema{type: :integer},
59 description: "MediaProxy URLs"
69 def delete_operation do
71 tags: ["MediaProxy cache"],
72 summary: "Remove a banned MediaProxy URL",
73 operationId: "AdminAPI.MediaProxyCacheController.delete",
74 security: [%{"oAuth" => ["admin:write:media_proxy_caches"]}],
75 parameters: admin_api_params(),
83 urls: %Schema{type: :array, items: %Schema{type: :string, format: :uri}}
89 200 => empty_object_response(),
90 400 => Operation.response("Error", "application/json", ApiError)
95 def purge_operation do
97 tags: ["MediaProxy cache"],
98 summary: "Purge a URL from MediaProxy cache and optionally ban it",
99 operationId: "AdminAPI.MediaProxyCacheController.purge",
100 security: [%{"oAuth" => ["admin:write:media_proxy_caches"]}],
101 parameters: admin_api_params(),
109 urls: %Schema{type: :array, items: %Schema{type: :string, format: :uri}},
110 ban: %Schema{type: :boolean, default: true}
116 200 => empty_object_response(),
117 400 => Operation.response("Error", "application/json", ApiError)