2020-10-27 15:20:04 +00:00
|
|
|
# Pleroma: A lightweight social networking server
|
2021-01-13 06:49:20 +00:00
|
|
|
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
|
2020-10-27 15:20:04 +00:00
|
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
|
|
|
defmodule Pleroma.Web.ApiSpec.Admin.FrontendOperation do
|
|
|
|
alias OpenApiSpex.Operation
|
|
|
|
alias OpenApiSpex.Schema
|
|
|
|
alias Pleroma.Web.ApiSpec.Schemas.ApiError
|
|
|
|
|
|
|
|
import Pleroma.Web.ApiSpec.Helpers
|
|
|
|
|
|
|
|
def open_api_operation(action) do
|
|
|
|
operation = String.to_existing_atom("#{action}_operation")
|
|
|
|
apply(__MODULE__, operation, [])
|
|
|
|
end
|
|
|
|
|
|
|
|
def index_operation do
|
|
|
|
%Operation{
|
2021-02-03 12:38:59 +00:00
|
|
|
tags: ["Frontend managment"],
|
|
|
|
summary: "Retrieve a list of available frontends",
|
2020-10-27 15:20:04 +00:00
|
|
|
operationId: "AdminAPI.FrontendController.index",
|
2021-02-17 17:56:13 +00:00
|
|
|
security: [%{"oAuth" => ["admin:read"]}],
|
2020-10-27 15:20:04 +00:00
|
|
|
responses: %{
|
|
|
|
200 => Operation.response("Response", "application/json", list_of_frontends()),
|
|
|
|
403 => Operation.response("Forbidden", "application/json", ApiError)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
def install_operation do
|
|
|
|
%Operation{
|
2021-02-03 12:38:59 +00:00
|
|
|
tags: ["Frontend managment"],
|
2020-10-27 15:20:04 +00:00
|
|
|
summary: "Install a frontend",
|
|
|
|
operationId: "AdminAPI.FrontendController.install",
|
2021-02-17 17:56:13 +00:00
|
|
|
security: [%{"oAuth" => ["admin:read"]}],
|
2020-10-27 15:20:04 +00:00
|
|
|
requestBody: request_body("Parameters", install_request(), required: true),
|
|
|
|
responses: %{
|
|
|
|
200 => Operation.response("Response", "application/json", list_of_frontends()),
|
2020-11-17 15:43:07 +00:00
|
|
|
403 => Operation.response("Forbidden", "application/json", ApiError),
|
|
|
|
400 => Operation.response("Error", "application/json", ApiError)
|
2020-10-27 15:20:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
defp list_of_frontends do
|
|
|
|
%Schema{
|
|
|
|
type: :array,
|
|
|
|
items: %Schema{
|
|
|
|
type: :object,
|
|
|
|
properties: %{
|
|
|
|
name: %Schema{type: :string},
|
|
|
|
git: %Schema{type: :string, format: :uri, nullable: true},
|
2020-10-29 12:37:50 +00:00
|
|
|
build_url: %Schema{type: :string, format: :uri, nullable: true},
|
2020-10-27 15:20:04 +00:00
|
|
|
ref: %Schema{type: :string},
|
|
|
|
installed: %Schema{type: :boolean}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
defp install_request do
|
|
|
|
%Schema{
|
|
|
|
title: "FrontendInstallRequest",
|
|
|
|
type: :object,
|
|
|
|
required: [:name],
|
|
|
|
properties: %{
|
|
|
|
name: %Schema{
|
2020-10-29 12:37:50 +00:00
|
|
|
type: :string
|
2020-10-27 15:20:04 +00:00
|
|
|
},
|
|
|
|
ref: %Schema{
|
2020-10-29 12:37:50 +00:00
|
|
|
type: :string
|
|
|
|
},
|
|
|
|
file: %Schema{
|
|
|
|
type: :string
|
|
|
|
},
|
|
|
|
build_url: %Schema{
|
|
|
|
type: :string
|
|
|
|
},
|
|
|
|
build_dir: %Schema{
|
|
|
|
type: :string
|
2020-10-27 15:20:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|