From 6561ba3bc33310de992e4b4f4a1ab9c89c1013d0 Mon Sep 17 00:00:00 2001 From: glax Date: Thu, 16 Oct 2025 19:13:44 +0200 Subject: [PATCH] Actions use enum --- API/Controllers/ActionsController.cs | 24 +++--- ....cs => 20251016170924_Actions.Designer.cs} | 23 +++--- ...7_Actions.cs => 20251016170924_Actions.cs} | 2 +- .../Actions/ActionsContextModelSnapshot.cs | 21 +++-- API/Schema/ActionsContext/ActionRecord.cs | 5 +- .../ActionsContext/Actions/ActionsEnum.cs | 12 +++ .../Actions/ChapterDownloadedActionRecord.cs | 6 +- .../Actions/ChaptersRetrievedActionRecord.cs | 4 +- .../Actions/CoverDownloadedActionRecord.cs | 6 +- .../Actions/DataMovedActionRecord.cs | 6 +- .../Actions/Generic/ActionWithMangaRecord.cs | 4 +- .../Actions/LibraryMovedActionRecord.cs | 6 +- .../Actions/MetadataUpdatedActionRecord.cs | 6 +- .../Actions/StartupActionRecord.cs | 6 +- API/Schema/ActionsContext/ActionsContext.cs | 14 ++-- API/openapi/API_v2.json | 79 ++++++++++++++++--- 16 files changed, 140 insertions(+), 84 deletions(-) rename API/Migrations/Actions/{20251016005257_Actions.Designer.cs => 20251016170924_Actions.Designer.cs} (86%) rename API/Migrations/Actions/{20251016005257_Actions.cs => 20251016170924_Actions.cs} (94%) create mode 100644 API/Schema/ActionsContext/Actions/ActionsEnum.cs diff --git a/API/Controllers/ActionsController.cs b/API/Controllers/ActionsController.cs index 755e360..b80a6c9 100644 --- a/API/Controllers/ActionsController.cs +++ b/API/Controllers/ActionsController.cs @@ -1,4 +1,5 @@ using API.Schema.ActionsContext; +using API.Schema.ActionsContext.Actions; using Asp.Versioning; using Microsoft.AspNetCore.Http.HttpResults; using Microsoft.AspNetCore.Mvc; @@ -13,19 +14,14 @@ namespace API.Controllers; public class ActionsController(ActionsContext context) : Controller { /// - /// Returns the available Action Types () performed by Tranga + /// Returns the available Action Types () /// - /// List of performed action-types - /// Database error + /// List of action-types [HttpGet("Types")] - [ProducesResponseType(Status200OK)] - [ProducesResponseType(Status500InternalServerError)] - public async Task>, InternalServerError>> GetAvailableActions() + [ProducesResponseType(Status200OK, "application/json")] + public Ok GetAvailableActions() { - if (await context.Actions.Select(a => a.Action).Distinct().ToListAsync(HttpContext.RequestAborted) is not - { } actions) - return TypedResults.InternalServerError(); - return TypedResults.Ok(actions); + return TypedResults.Ok(Enum.GetValues()); } public sealed record Interval(DateTime Start, DateTime End); @@ -35,7 +31,7 @@ public class ActionsController(ActionsContext context) : Controller /// List of performed actions /// Database error [HttpPost("Interval")] - [ProducesResponseType(Status200OK)] + [ProducesResponseType>(Status200OK, "application/json")] [ProducesResponseType(Status500InternalServerError)] public async Task>, InternalServerError>> GetActionsInterval([FromBody]Interval interval) { @@ -46,14 +42,14 @@ public class ActionsController(ActionsContext context) : Controller } /// - /// Returns with type + /// Returns with /// /// List of performed actions /// Database error [HttpGet("Type/{Type}")] - [ProducesResponseType(Status200OK)] + [ProducesResponseType>(Status200OK, "application/json")] [ProducesResponseType(Status500InternalServerError)] - public async Task>, InternalServerError>> GetActionsWithType(string Type) + public async Task>, InternalServerError>> GetActionsWithType(ActionsEnum Type) { if (await context.Actions.Where(a => a.Action == Type) .ToListAsync(HttpContext.RequestAborted) is not { } actions) diff --git a/API/Migrations/Actions/20251016005257_Actions.Designer.cs b/API/Migrations/Actions/20251016170924_Actions.Designer.cs similarity index 86% rename from API/Migrations/Actions/20251016005257_Actions.Designer.cs rename to API/Migrations/Actions/20251016170924_Actions.Designer.cs index 6644771..0499a95 100644 --- a/API/Migrations/Actions/20251016005257_Actions.Designer.cs +++ b/API/Migrations/Actions/20251016170924_Actions.Designer.cs @@ -12,7 +12,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; namespace API.Migrations.Actions { [DbContext(typeof(ActionsContext))] - [Migration("20251016005257_Actions")] + [Migration("20251016170924_Actions")] partial class Actions { /// @@ -31,10 +31,9 @@ namespace API.Migrations.Actions .HasMaxLength(64) .HasColumnType("character varying(64)"); - b.Property("Action") - .IsRequired() + b.Property("Action") .HasMaxLength(128) - .HasColumnType("character varying(128)"); + .HasColumnType("integer"); b.Property("PerformedAt") .HasColumnType("timestamp with time zone"); @@ -43,7 +42,7 @@ namespace API.Migrations.Actions b.ToTable("Actions"); - b.HasDiscriminator("Action").HasValue("ActionRecord"); + b.HasDiscriminator("Action"); b.UseTphMappingStrategy(); }); @@ -57,7 +56,7 @@ namespace API.Migrations.Actions .HasMaxLength(64) .HasColumnType("character varying(64)"); - b.HasDiscriminator().HasValue("Chapter.Downloaded"); + b.HasDiscriminator().HasValue(1); }); modelBuilder.Entity("API.Schema.ActionsContext.Actions.ChaptersRetrievedActionRecord", b => @@ -70,7 +69,7 @@ namespace API.Migrations.Actions .HasMaxLength(64) .HasColumnType("character varying(64)"); - b.HasDiscriminator().HasValue("Manga.ChaptersRetrieved"); + b.HasDiscriminator().HasValue(2); }); modelBuilder.Entity("API.Schema.ActionsContext.Actions.CoverDownloadedActionRecord", b => @@ -88,7 +87,7 @@ namespace API.Migrations.Actions .HasMaxLength(64) .HasColumnType("character varying(64)"); - b.HasDiscriminator().HasValue("Manga.CoverDownloaded"); + b.HasDiscriminator().HasValue(3); }); modelBuilder.Entity("API.Schema.ActionsContext.Actions.DataMovedActionRecord", b => @@ -105,7 +104,7 @@ namespace API.Migrations.Actions .HasMaxLength(2048) .HasColumnType("character varying(2048)"); - b.HasDiscriminator().HasValue("Tranga.DataMoved"); + b.HasDiscriminator().HasValue(4); }); modelBuilder.Entity("API.Schema.ActionsContext.Actions.LibraryMovedActionRecord", b => @@ -123,7 +122,7 @@ namespace API.Migrations.Actions .HasMaxLength(64) .HasColumnType("character varying(64)"); - b.HasDiscriminator().HasValue("Manga.LibraryMoved"); + b.HasDiscriminator().HasValue(5); }); modelBuilder.Entity("API.Schema.ActionsContext.Actions.MetadataUpdatedActionRecord", b => @@ -141,14 +140,14 @@ namespace API.Migrations.Actions .HasMaxLength(1024) .HasColumnType("character varying(1024)"); - b.HasDiscriminator().HasValue("Manga.MetadataUpdated"); + b.HasDiscriminator().HasValue(6); }); modelBuilder.Entity("API.Schema.ActionsContext.Actions.StartupActionRecord", b => { b.HasBaseType("API.Schema.ActionsContext.ActionRecord"); - b.HasDiscriminator().HasValue("Tranga.Started"); + b.HasDiscriminator().HasValue(0); }); #pragma warning restore 612, 618 } diff --git a/API/Migrations/Actions/20251016005257_Actions.cs b/API/Migrations/Actions/20251016170924_Actions.cs similarity index 94% rename from API/Migrations/Actions/20251016005257_Actions.cs rename to API/Migrations/Actions/20251016170924_Actions.cs index f15825b..53ad8b9 100644 --- a/API/Migrations/Actions/20251016005257_Actions.cs +++ b/API/Migrations/Actions/20251016170924_Actions.cs @@ -16,7 +16,7 @@ namespace API.Migrations.Actions columns: table => new { Key = table.Column(type: "character varying(64)", maxLength: 64, nullable: false), - Action = table.Column(type: "character varying(128)", maxLength: 128, nullable: false), + Action = table.Column(type: "integer", maxLength: 128, nullable: false), PerformedAt = table.Column(type: "timestamp with time zone", nullable: false), ChapterId = table.Column(type: "character varying(64)", maxLength: 64, nullable: true), MangaId = table.Column(type: "character varying(64)", maxLength: 64, nullable: true), diff --git a/API/Migrations/Actions/ActionsContextModelSnapshot.cs b/API/Migrations/Actions/ActionsContextModelSnapshot.cs index 1dcee0e..4997c96 100644 --- a/API/Migrations/Actions/ActionsContextModelSnapshot.cs +++ b/API/Migrations/Actions/ActionsContextModelSnapshot.cs @@ -28,10 +28,9 @@ namespace API.Migrations.Actions .HasMaxLength(64) .HasColumnType("character varying(64)"); - b.Property("Action") - .IsRequired() + b.Property("Action") .HasMaxLength(128) - .HasColumnType("character varying(128)"); + .HasColumnType("integer"); b.Property("PerformedAt") .HasColumnType("timestamp with time zone"); @@ -40,7 +39,7 @@ namespace API.Migrations.Actions b.ToTable("Actions"); - b.HasDiscriminator("Action").HasValue("ActionRecord"); + b.HasDiscriminator("Action"); b.UseTphMappingStrategy(); }); @@ -54,7 +53,7 @@ namespace API.Migrations.Actions .HasMaxLength(64) .HasColumnType("character varying(64)"); - b.HasDiscriminator().HasValue("Chapter.Downloaded"); + b.HasDiscriminator().HasValue(1); }); modelBuilder.Entity("API.Schema.ActionsContext.Actions.ChaptersRetrievedActionRecord", b => @@ -67,7 +66,7 @@ namespace API.Migrations.Actions .HasMaxLength(64) .HasColumnType("character varying(64)"); - b.HasDiscriminator().HasValue("Manga.ChaptersRetrieved"); + b.HasDiscriminator().HasValue(2); }); modelBuilder.Entity("API.Schema.ActionsContext.Actions.CoverDownloadedActionRecord", b => @@ -85,7 +84,7 @@ namespace API.Migrations.Actions .HasMaxLength(64) .HasColumnType("character varying(64)"); - b.HasDiscriminator().HasValue("Manga.CoverDownloaded"); + b.HasDiscriminator().HasValue(3); }); modelBuilder.Entity("API.Schema.ActionsContext.Actions.DataMovedActionRecord", b => @@ -102,7 +101,7 @@ namespace API.Migrations.Actions .HasMaxLength(2048) .HasColumnType("character varying(2048)"); - b.HasDiscriminator().HasValue("Tranga.DataMoved"); + b.HasDiscriminator().HasValue(4); }); modelBuilder.Entity("API.Schema.ActionsContext.Actions.LibraryMovedActionRecord", b => @@ -120,7 +119,7 @@ namespace API.Migrations.Actions .HasMaxLength(64) .HasColumnType("character varying(64)"); - b.HasDiscriminator().HasValue("Manga.LibraryMoved"); + b.HasDiscriminator().HasValue(5); }); modelBuilder.Entity("API.Schema.ActionsContext.Actions.MetadataUpdatedActionRecord", b => @@ -138,14 +137,14 @@ namespace API.Migrations.Actions .HasMaxLength(1024) .HasColumnType("character varying(1024)"); - b.HasDiscriminator().HasValue("Manga.MetadataUpdated"); + b.HasDiscriminator().HasValue(6); }); modelBuilder.Entity("API.Schema.ActionsContext.Actions.StartupActionRecord", b => { b.HasBaseType("API.Schema.ActionsContext.ActionRecord"); - b.HasDiscriminator().HasValue("Tranga.Started"); + b.HasDiscriminator().HasValue(0); }); #pragma warning restore 612, 618 } diff --git a/API/Schema/ActionsContext/ActionRecord.cs b/API/Schema/ActionsContext/ActionRecord.cs index ac448e3..d9c746c 100644 --- a/API/Schema/ActionsContext/ActionRecord.cs +++ b/API/Schema/ActionsContext/ActionRecord.cs @@ -1,16 +1,17 @@ using System.ComponentModel.DataAnnotations; +using API.Schema.ActionsContext.Actions; using Microsoft.EntityFrameworkCore; namespace API.Schema.ActionsContext; [PrimaryKey("Key")] -public abstract class ActionRecord(string action, DateTime performedAt) : Identifiable +public abstract class ActionRecord(ActionsEnum action, DateTime performedAt) : Identifiable { /// /// Constant string that describes the performed Action /// [StringLength(128)] - public string Action { get; init; } = action; + public ActionsEnum Action { get; init; } = action; /// /// UTC Time when Action was performed diff --git a/API/Schema/ActionsContext/Actions/ActionsEnum.cs b/API/Schema/ActionsContext/Actions/ActionsEnum.cs new file mode 100644 index 0000000..97cb4d2 --- /dev/null +++ b/API/Schema/ActionsContext/Actions/ActionsEnum.cs @@ -0,0 +1,12 @@ +namespace API.Schema.ActionsContext.Actions; + +public enum ActionsEnum +{ + Startup = 0, + ChapterDownloaded = 1, + ChaptersRetrieved = 2, + CoverDownloaded = 3, + DataMoved = 4, + LibraryMoved = 5, + MetadataUpdated = 6 +} \ No newline at end of file diff --git a/API/Schema/ActionsContext/Actions/ChapterDownloadedActionRecord.cs b/API/Schema/ActionsContext/Actions/ChapterDownloadedActionRecord.cs index 5b2420c..81331ec 100644 --- a/API/Schema/ActionsContext/Actions/ChapterDownloadedActionRecord.cs +++ b/API/Schema/ActionsContext/Actions/ChapterDownloadedActionRecord.cs @@ -3,15 +3,13 @@ using API.Schema.MangaContext; namespace API.Schema.ActionsContext.Actions; -public sealed class ChapterDownloadedActionRecord(string action, DateTime performedAt, string chapterId) : ActionRecord(action, performedAt) +public sealed class ChapterDownloadedActionRecord(ActionsEnum action, DateTime performedAt, string chapterId) : ActionRecord(action, performedAt) { - public ChapterDownloadedActionRecord(Chapter chapter) : this(ChapterDownloadedAction, DateTime.UtcNow, chapter.Key) { } + public ChapterDownloadedActionRecord(Chapter chapter) : this(ActionsEnum.ChapterDownloaded, DateTime.UtcNow, chapter.Key) { } /// /// Chapter that was downloaded /// [StringLength(64)] public string ChapterId { get; init; } = chapterId; - - public const string ChapterDownloadedAction = "Chapter.Downloaded"; } \ No newline at end of file diff --git a/API/Schema/ActionsContext/Actions/ChaptersRetrievedActionRecord.cs b/API/Schema/ActionsContext/Actions/ChaptersRetrievedActionRecord.cs index 0dbf854..8b70fde 100644 --- a/API/Schema/ActionsContext/Actions/ChaptersRetrievedActionRecord.cs +++ b/API/Schema/ActionsContext/Actions/ChaptersRetrievedActionRecord.cs @@ -3,10 +3,10 @@ using API.Schema.MangaContext; namespace API.Schema.ActionsContext.Actions; -public sealed class ChaptersRetrievedActionRecord(string action, DateTime performedAt, string mangaId) +public sealed class ChaptersRetrievedActionRecord(ActionsEnum action, DateTime performedAt, string mangaId) : ActionWithMangaRecord(action, performedAt, mangaId) { - public ChaptersRetrievedActionRecord(Manga manga) : this(ChaptersRetrievedAction, DateTime.UtcNow, manga.Key) { } + public ChaptersRetrievedActionRecord(Manga manga) : this(ActionsEnum.ChaptersRetrieved, DateTime.UtcNow, manga.Key) { } public const string ChaptersRetrievedAction = "Manga.ChaptersRetrieved"; } \ No newline at end of file diff --git a/API/Schema/ActionsContext/Actions/CoverDownloadedActionRecord.cs b/API/Schema/ActionsContext/Actions/CoverDownloadedActionRecord.cs index 3568c95..61c4c9c 100644 --- a/API/Schema/ActionsContext/Actions/CoverDownloadedActionRecord.cs +++ b/API/Schema/ActionsContext/Actions/CoverDownloadedActionRecord.cs @@ -4,16 +4,14 @@ using API.Schema.MangaContext; namespace API.Schema.ActionsContext.Actions; -public sealed class CoverDownloadedActionRecord(string action, DateTime performedAt, string mangaId, string filename) +public sealed class CoverDownloadedActionRecord(ActionsEnum action, DateTime performedAt, string mangaId, string filename) : ActionWithMangaRecord(action, performedAt, mangaId) { - public CoverDownloadedActionRecord(Manga manga, string filename) : this(CoverDownloadedAction, DateTime.UtcNow, manga.Key, filename) { } + public CoverDownloadedActionRecord(Manga manga, string filename) : this(ActionsEnum.CoverDownloaded, DateTime.UtcNow, manga.Key, filename) { } /// /// Filename on disk /// [StringLength(1024)] public string Filename { get; init; } = filename; - - public const string CoverDownloadedAction = "Manga.CoverDownloaded"; } \ No newline at end of file diff --git a/API/Schema/ActionsContext/Actions/DataMovedActionRecord.cs b/API/Schema/ActionsContext/Actions/DataMovedActionRecord.cs index b2618a5..11863cc 100644 --- a/API/Schema/ActionsContext/Actions/DataMovedActionRecord.cs +++ b/API/Schema/ActionsContext/Actions/DataMovedActionRecord.cs @@ -2,9 +2,9 @@ using System.ComponentModel.DataAnnotations; namespace API.Schema.ActionsContext.Actions; -public sealed class DataMovedActionRecord(string action, DateTime performedAt, string from, string to) : ActionRecord(action, performedAt) +public sealed class DataMovedActionRecord(ActionsEnum action, DateTime performedAt, string from, string to) : ActionRecord(action, performedAt) { - public DataMovedActionRecord(string from, string to) : this(DataMovedAction, DateTime.UtcNow, from, to) { } + public DataMovedActionRecord(string from, string to) : this(ActionsEnum.DataMoved, DateTime.UtcNow, from, to) { } /// /// From path @@ -17,6 +17,4 @@ public sealed class DataMovedActionRecord(string action, DateTime performedAt, s /// [StringLength(2048)] public string To { get; init; } = to; - - public const string DataMovedAction = "Tranga.DataMoved"; } \ No newline at end of file diff --git a/API/Schema/ActionsContext/Actions/Generic/ActionWithMangaRecord.cs b/API/Schema/ActionsContext/Actions/Generic/ActionWithMangaRecord.cs index ad569d8..05a8355 100644 --- a/API/Schema/ActionsContext/Actions/Generic/ActionWithMangaRecord.cs +++ b/API/Schema/ActionsContext/Actions/Generic/ActionWithMangaRecord.cs @@ -3,9 +3,9 @@ using API.Schema.MangaContext; namespace API.Schema.ActionsContext.Actions.Generic; -public abstract class ActionWithMangaRecord(string action, DateTime performedAt, string mangaId) : ActionRecord(action, performedAt) +public abstract class ActionWithMangaRecord(ActionsEnum action, DateTime performedAt, string mangaId) : ActionRecord(action, performedAt) { - protected ActionWithMangaRecord(string action, DateTime performedAt, Manga manga) : this(action, performedAt, manga.Key) { } + protected ActionWithMangaRecord(ActionsEnum action, DateTime performedAt, Manga manga) : this(action, performedAt, manga.Key) { } /// /// for which the cover was downloaded diff --git a/API/Schema/ActionsContext/Actions/LibraryMovedActionRecord.cs b/API/Schema/ActionsContext/Actions/LibraryMovedActionRecord.cs index 5230021..6499385 100644 --- a/API/Schema/ActionsContext/Actions/LibraryMovedActionRecord.cs +++ b/API/Schema/ActionsContext/Actions/LibraryMovedActionRecord.cs @@ -4,15 +4,13 @@ using API.Schema.MangaContext; namespace API.Schema.ActionsContext.Actions; -public sealed class LibraryMovedActionRecord(string action, DateTime performedAt, string mangaId, string fileLibraryId) : ActionWithMangaRecord(action, performedAt, mangaId) +public sealed class LibraryMovedActionRecord(ActionsEnum action, DateTime performedAt, string mangaId, string fileLibraryId) : ActionWithMangaRecord(action, performedAt, mangaId) { - public LibraryMovedActionRecord(Manga manga, FileLibrary library) : this(LibraryMovedAction, DateTime.UtcNow, manga.Key, library.Key) { } + public LibraryMovedActionRecord(Manga manga, FileLibrary library) : this(ActionsEnum.LibraryMoved, DateTime.UtcNow, manga.Key, library.Key) { } /// /// for which the cover was downloaded /// [StringLength(64)] public string FileLibraryId { get; init; } = fileLibraryId; - - public const string LibraryMovedAction = "Manga.LibraryMoved"; } \ No newline at end of file diff --git a/API/Schema/ActionsContext/Actions/MetadataUpdatedActionRecord.cs b/API/Schema/ActionsContext/Actions/MetadataUpdatedActionRecord.cs index af8f488..6b687d9 100644 --- a/API/Schema/ActionsContext/Actions/MetadataUpdatedActionRecord.cs +++ b/API/Schema/ActionsContext/Actions/MetadataUpdatedActionRecord.cs @@ -5,16 +5,14 @@ using API.Schema.MangaContext.MetadataFetchers; namespace API.Schema.ActionsContext.Actions; -public sealed class MetadataUpdatedActionRecord(string action, DateTime performedAt, string mangaId, string metadataFetcher) +public sealed class MetadataUpdatedActionRecord(ActionsEnum action, DateTime performedAt, string mangaId, string metadataFetcher) : ActionWithMangaRecord(action, performedAt, mangaId) { - public MetadataUpdatedActionRecord(Manga manga, MetadataFetcher fetcher) : this(MetadataUpdatedAction, DateTime.UtcNow, manga.Key, fetcher.Name) { } + public MetadataUpdatedActionRecord(Manga manga, MetadataFetcher fetcher) : this(ActionsEnum.MetadataUpdated, DateTime.UtcNow, manga.Key, fetcher.Name) { } /// /// Filename on disk /// [StringLength(1024)] public string MetadataFetcher { get; init; } = metadataFetcher; - - public const string MetadataUpdatedAction = "Manga.MetadataUpdated"; } \ No newline at end of file diff --git a/API/Schema/ActionsContext/Actions/StartupActionRecord.cs b/API/Schema/ActionsContext/Actions/StartupActionRecord.cs index 776a596..affb3a1 100644 --- a/API/Schema/ActionsContext/Actions/StartupActionRecord.cs +++ b/API/Schema/ActionsContext/Actions/StartupActionRecord.cs @@ -1,8 +1,6 @@ namespace API.Schema.ActionsContext.Actions; -public sealed class StartupActionRecord(string action, DateTime performedAt) : ActionRecord(action, performedAt) +public sealed class StartupActionRecord(ActionsEnum action, DateTime performedAt) : ActionRecord(action, performedAt) { - public StartupActionRecord() : this(StartupAction, DateTime.UtcNow) { } - - public const string StartupAction = "Tranga.Started"; + public StartupActionRecord() : this(ActionsEnum.Startup, DateTime.UtcNow) { } } \ No newline at end of file diff --git a/API/Schema/ActionsContext/ActionsContext.cs b/API/Schema/ActionsContext/ActionsContext.cs index 5456d9d..801b18e 100644 --- a/API/Schema/ActionsContext/ActionsContext.cs +++ b/API/Schema/ActionsContext/ActionsContext.cs @@ -11,12 +11,12 @@ public class ActionsContext(DbContextOptions options) : TrangaBa { modelBuilder.Entity() .HasDiscriminator(a => a.Action) - .HasValue(ChapterDownloadedActionRecord.ChapterDownloadedAction) - .HasValue(CoverDownloadedActionRecord.CoverDownloadedAction) - .HasValue(ChaptersRetrievedActionRecord.ChaptersRetrievedAction) - .HasValue(MetadataUpdatedActionRecord.MetadataUpdatedAction) - .HasValue(DataMovedActionRecord.DataMovedAction) - .HasValue(LibraryMovedActionRecord.LibraryMovedAction) - .HasValue(StartupActionRecord.StartupAction); + .HasValue(ActionsEnum.ChapterDownloaded) + .HasValue(ActionsEnum.CoverDownloaded) + .HasValue(ActionsEnum.ChaptersRetrieved) + .HasValue(ActionsEnum.MetadataUpdated) + .HasValue(ActionsEnum.DataMoved) + .HasValue(ActionsEnum.LibraryMoved) + .HasValue(ActionsEnum.Startup); } } \ No newline at end of file diff --git a/API/openapi/API_v2.json b/API/openapi/API_v2.json index c661751..c225dc1 100644 --- a/API/openapi/API_v2.json +++ b/API/openapi/API_v2.json @@ -10,13 +10,20 @@ "tags": [ "Actions" ], - "summary": "Returns the available Action Types (API.Schema.ActionsContext.ActionRecord.Action) performed by Tranga", + "summary": "Returns the available Action Types (API.Schema.ActionsContext.Actions.ActionsEnum)", "responses": { "200": { - "description": "List of performed action-types" - }, - "500": { - "description": "Database error" + "description": "List of action-types", + "content": { + "application/json; x-version=2.0": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/ActionsEnum" + } + } + } + } } } } @@ -53,7 +60,17 @@ }, "responses": { "200": { - "description": "List of performed actions" + "description": "List of performed actions", + "content": { + "application/json; x-version=2.0": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/ActionRecord" + } + } + } + } }, "500": { "description": "Database error" @@ -66,20 +83,30 @@ "tags": [ "Actions" ], - "summary": "Returns API.Schema.ActionsContext.ActionRecord with type Type", + "summary": "Returns API.Schema.ActionsContext.ActionRecord with TypeAPI.Schema.ActionsContext.Actions.ActionsEnum", "parameters": [ { "name": "Type", "in": "path", "required": true, "schema": { - "type": "string" + "$ref": "#/components/schemas/ActionsEnum" } } ], "responses": { "200": { - "description": "List of performed actions" + "description": "List of performed actions", + "content": { + "application/json; x-version=2.0": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/ActionRecord" + } + } + } + } }, "500": { "description": "Database error" @@ -3160,6 +3187,40 @@ }, "components": { "schemas": { + "ActionRecord": { + "required": [ + "key" + ], + "type": "object", + "properties": { + "action": { + "$ref": "#/components/schemas/ActionsEnum" + }, + "performedAt": { + "type": "string", + "description": "UTC Time when Action was performed", + "format": "date-time" + }, + "key": { + "maxLength": 64, + "minLength": 16, + "type": "string" + } + }, + "additionalProperties": false + }, + "ActionsEnum": { + "enum": [ + "Startup", + "ChapterDownloaded", + "ChaptersRetrieved", + "CoverDownloaded", + "DataMoved", + "LibraryMoved", + "MetadataUpdated" + ], + "type": "string" + }, "AltTitle": { "required": [ "language",