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.ScheduledActivityOperation do
6 alias OpenApiSpex.Operation
7 alias OpenApiSpex.Schema
8 alias Pleroma.Web.ApiSpec.Schemas.ApiError
9 alias Pleroma.Web.ApiSpec.Schemas.FlakeID
10 alias Pleroma.Web.ApiSpec.Schemas.ScheduledStatus
12 import Pleroma.Web.ApiSpec.Helpers
14 def open_api_operation(action) do
15 operation = String.to_existing_atom("#{action}_operation")
16 apply(__MODULE__, operation, [])
19 def index_operation do
21 tags: ["Scheduled statuses"],
22 summary: "View scheduled statuses",
23 security: [%{"oAuth" => ["read:statuses"]}],
24 parameters: pagination_params(),
25 operationId: "ScheduledActivity.index",
28 Operation.response("Array of ScheduledStatus", "application/json", %Schema{
30 items: ScheduledStatus
38 tags: ["Scheduled statuses"],
39 summary: "View a single scheduled status",
40 security: [%{"oAuth" => ["read:statuses"]}],
41 parameters: [id_param()],
42 operationId: "ScheduledActivity.show",
44 200 => Operation.response("Scheduled Status", "application/json", ScheduledStatus),
45 404 => Operation.response("Error", "application/json", ApiError)
50 def update_operation do
52 tags: ["Scheduled statuses"],
53 summary: "Schedule a status",
54 operationId: "ScheduledActivity.update",
55 security: [%{"oAuth" => ["write:statuses"]}],
56 parameters: [id_param()],
58 request_body("Parameters", %Schema{
61 scheduled_at: %Schema{
65 "ISO 8601 Datetime at which the status will be published. Must be at least 5 minutes into the future."
70 200 => Operation.response("Scheduled Status", "application/json", ScheduledStatus),
71 404 => Operation.response("Error", "application/json", ApiError)
76 def delete_operation do
78 tags: ["Scheduled statuses"],
79 summary: "Cancel a scheduled status",
80 security: [%{"oAuth" => ["write:statuses"]}],
81 parameters: [id_param()],
82 operationId: "ScheduledActivity.delete",
84 200 => Operation.response("Empty object", "application/json", %Schema{type: :object}),
85 404 => Operation.response("Error", "application/json", ApiError)
91 Operation.parameter(:id, :path, FlakeID.schema(), "Poll ID",