diff options
author | lain <lain@soykaf.club> | 2020-11-04 11:47:41 +0100 |
---|---|---|
committer | lain <lain@soykaf.club> | 2020-11-04 11:47:41 +0100 |
commit | c7bcbfbc1d5d34463634e44979a77a2c47e35dbc (patch) | |
tree | a9d947e8f3c82b7c5cd1764d98be46cf95b7e085 /lib/pleroma/web/api_spec/operations/pleroma_backup_operation.ex | |
parent | 1cc8e945064319014300de5880a326d1100bf43e (diff) | |
parent | ba3f3a5a56d4a5ac05443fd30b5864778ad1131e (diff) | |
download | pleroma-c7bcbfbc1d5d34463634e44979a77a2c47e35dbc.tar.gz |
Merge branch 'develop' of git.pleroma.social:pleroma/pleroma into feature/local-only-scope
Diffstat (limited to 'lib/pleroma/web/api_spec/operations/pleroma_backup_operation.ex')
-rw-r--r-- | lib/pleroma/web/api_spec/operations/pleroma_backup_operation.ex | 79 |
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..6993794db --- /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" => + "https://cofe.fe:4000/media/backups/archive-foobar-20200908T164207-Yr7vuT5Wycv-sN3kSN2iJ0k-9pMo60j9qmvRCdDqIew.zip", + "file_size" => 4105, + "inserted_at" => "2020-09-08T16:42:07.000Z", + "processed" => true + } + } + end +end |