logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma git clone https://hacktivis.me/git/pleroma.git

media_proxy_cache_operation.ex (3533B)


  1. # Pleroma: A lightweight social networking server
  2. # Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
  3. # SPDX-License-Identifier: AGPL-3.0-only
  4. defmodule Pleroma.Web.ApiSpec.Admin.MediaProxyCacheOperation do
  5. alias OpenApiSpex.Operation
  6. alias OpenApiSpex.Schema
  7. alias Pleroma.Web.ApiSpec.Schemas.ApiError
  8. import Pleroma.Web.ApiSpec.Helpers
  9. def open_api_operation(action) do
  10. operation = String.to_existing_atom("#{action}_operation")
  11. apply(__MODULE__, operation, [])
  12. end
  13. def index_operation do
  14. %Operation{
  15. tags: ["MediaProxy cache"],
  16. summary: "Retrieve a list of banned MediaProxy URLs",
  17. operationId: "AdminAPI.MediaProxyCacheController.index",
  18. security: [%{"oAuth" => ["admin:read:media_proxy_caches"]}],
  19. parameters: [
  20. Operation.parameter(
  21. :query,
  22. :query,
  23. %Schema{type: :string, default: nil},
  24. "Page"
  25. ),
  26. Operation.parameter(
  27. :page,
  28. :query,
  29. %Schema{type: :integer, default: 1},
  30. "Page"
  31. ),
  32. Operation.parameter(
  33. :page_size,
  34. :query,
  35. %Schema{type: :integer, default: 50},
  36. "Number of statuses to return"
  37. )
  38. | admin_api_params()
  39. ],
  40. responses: %{
  41. 200 =>
  42. Operation.response(
  43. "Array of MediaProxy URLs",
  44. "application/json",
  45. %Schema{
  46. type: :object,
  47. properties: %{
  48. count: %Schema{type: :integer},
  49. page_size: %Schema{type: :integer},
  50. urls: %Schema{
  51. type: :array,
  52. items: %Schema{
  53. type: :string,
  54. format: :uri,
  55. description: "MediaProxy URLs"
  56. }
  57. }
  58. }
  59. }
  60. )
  61. }
  62. }
  63. end
  64. def delete_operation do
  65. %Operation{
  66. tags: ["MediaProxy cache"],
  67. summary: "Remove a banned MediaProxy URL",
  68. operationId: "AdminAPI.MediaProxyCacheController.delete",
  69. security: [%{"oAuth" => ["admin:write:media_proxy_caches"]}],
  70. parameters: admin_api_params(),
  71. requestBody:
  72. request_body(
  73. "Parameters",
  74. %Schema{
  75. type: :object,
  76. required: [:urls],
  77. properties: %{
  78. urls: %Schema{type: :array, items: %Schema{type: :string, format: :uri}}
  79. }
  80. },
  81. required: true
  82. ),
  83. responses: %{
  84. 200 => empty_object_response(),
  85. 400 => Operation.response("Error", "application/json", ApiError)
  86. }
  87. }
  88. end
  89. def purge_operation do
  90. %Operation{
  91. tags: ["MediaProxy cache"],
  92. summary: "Purge a URL from MediaProxy cache and optionally ban it",
  93. operationId: "AdminAPI.MediaProxyCacheController.purge",
  94. security: [%{"oAuth" => ["admin:write:media_proxy_caches"]}],
  95. parameters: admin_api_params(),
  96. requestBody:
  97. request_body(
  98. "Parameters",
  99. %Schema{
  100. type: :object,
  101. required: [:urls],
  102. properties: %{
  103. urls: %Schema{type: :array, items: %Schema{type: :string, format: :uri}},
  104. ban: %Schema{type: :boolean, default: true}
  105. }
  106. },
  107. required: true
  108. ),
  109. responses: %{
  110. 200 => empty_object_response(),
  111. 400 => Operation.response("Error", "application/json", ApiError)
  112. }
  113. }
  114. end
  115. end