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.PleromaBackupOperation do
6 alias OpenApiSpex.Operation
7 alias OpenApiSpex.Schema
8 alias Pleroma.Web.ApiSpec.Schemas.ApiError
10 def open_api_operation(action) do
11 operation = String.to_existing_atom("#{action}_operation")
12 apply(__MODULE__, operation, [])
15 def index_operation do
18 summary: "List backups",
19 security: [%{"oAuth" => ["read:backups"]}],
20 operationId: "PleromaAPI.BackupController.index",
24 "An array of backups",
31 400 => Operation.response("Bad Request", "application/json", ApiError)
36 def create_operation do
39 summary: "Create a backup",
40 security: [%{"oAuth" => ["read:backups"]}],
41 operationId: "PleromaAPI.BackupController.create",
45 "An array of backups",
52 400 => Operation.response("Bad Request", "application/json", ApiError)
60 description: "Response schema for a backup",
63 inserted_at: %Schema{type: :string, format: :"date-time"},
64 content_type: %Schema{type: :string},
65 file_name: %Schema{type: :string},
66 file_size: %Schema{type: :integer},
67 processed: %Schema{type: :boolean, description: "whether this backup has succeeded"},
70 description: "the state of the backup",
71 enum: ["pending", "running", "complete", "failed"]
73 processed_number: %Schema{type: :integer, description: "the number of records processed"}
76 "content_type" => "application/zip",
78 "https://cofe.fe:4000/media/backups/archive-foobar-20200908T164207-Yr7vuT5Wycv-sN3kSN2iJ0k-9pMo60j9qmvRCdDqIew.zip",
80 "inserted_at" => "2020-09-08T16:42:07.000Z",
82 "state" => "complete",
83 "processed_number" => 20