aboutsummaryrefslogtreecommitdiff
path: root/lib/pleroma/web/api_spec
diff options
context:
space:
mode:
authorEgor Kislitsyn <egor@kislitsyn.com>2020-09-09 01:04:00 +0400
committerEgor Kislitsyn <egor@kislitsyn.com>2020-10-07 18:34:29 +0400
commit2c73bfe1227065fa203b0b78c9eb12cf86ab3948 (patch)
tree4e21f5cfc51dfe5f38806e3617f69a41d84fccdf /lib/pleroma/web/api_spec
parentabdffc6b8c2eec8f81ffe89f943f11d1f90d7074 (diff)
downloadpleroma-2c73bfe1227065fa203b0b78c9eb12cf86ab3948.tar.gz
Add API endpoints for Backups
Diffstat (limited to 'lib/pleroma/web/api_spec')
-rw-r--r--lib/pleroma/web/api_spec/operations/pleroma_backup_operation.ex79
1 files changed, 79 insertions, 0 deletions
diff --git a/lib/pleroma/web/api_spec/operations/pleroma_backup_operation.ex b/lib/pleroma/web/api_spec/operations/pleroma_backup_operation.ex
new file mode 100644
index 000000000..f877ca31b
--- /dev/null
+++ b/lib/pleroma/web/api_spec/operations/pleroma_backup_operation.ex
@@ -0,0 +1,79 @@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
+# SPDX-License-Identifier: AGPL-3.0-only
+
+defmodule Pleroma.Web.ApiSpec.PleromaBackupOperation do
+ alias OpenApiSpex.Operation
+ alias OpenApiSpex.Schema
+ alias Pleroma.Web.ApiSpec.Schemas.ApiError
+
+ def open_api_operation(action) do
+ operation = String.to_existing_atom("#{action}_operation")
+ apply(__MODULE__, operation, [])
+ end
+
+ def index_operation do
+ %Operation{
+ tags: ["Backups"],
+ summary: "List backups",
+ security: [%{"oAuth" => ["read:account"]}],
+ operationId: "PleromaAPI.BackupController.index",
+ responses: %{
+ 200 =>
+ Operation.response(
+ "An array of backups",
+ "application/json",
+ %Schema{
+ type: :array,
+ items: backup()
+ }
+ ),
+ 400 => Operation.response("Bad Request", "application/json", ApiError)
+ }
+ }
+ end
+
+ def create_operation do
+ %Operation{
+ tags: ["Backups"],
+ summary: "Create a backup",
+ security: [%{"oAuth" => ["read:account"]}],
+ operationId: "PleromaAPI.BackupController.create",
+ responses: %{
+ 200 =>
+ Operation.response(
+ "An array of backups",
+ "application/json",
+ %Schema{
+ type: :array,
+ items: backup()
+ }
+ ),
+ 400 => Operation.response("Bad Request", "application/json", ApiError)
+ }
+ }
+ end
+
+ defp backup do
+ %Schema{
+ title: "Backup",
+ description: "Response schema for a backup",
+ type: :object,
+ properties: %{
+ inserted_at: %Schema{type: :string, format: :"date-time"},
+ content_type: %Schema{type: :string},
+ file_name: %Schema{type: :string},
+ file_size: %Schema{type: :integer},
+ processed: %Schema{type: :boolean}
+ },
+ example: %{
+ "content_type" => "application/zip",
+ "file_name" =>
+ "archive-cofe-20200908T195819-1lWrJyJqpsj8-KuHFr7N03lfsYYa5nf2NL-7A9-ddFU.zip",
+ "file_size" => 1024,
+ "inserted_at" => "2020-09-08T19:58:20",
+ "processed" => true
+ }
+ }
+ end
+end