mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 17:11:10 +00:00
Adds provider configuration to media library saves
Moves metadata provider, artwork provider, and book reader choices into the add and update library requests, adds the library type lookups, removes the per-provider enable and reorder endpoints, and reconciles the stored configurations in one provider store call. Tightens library update and delete authorization to require ownership and the manage permission, and cleans up enum validation, comments, resource diacritics, and Razor imports.
This commit is contained in:
1 parent
2e7563199a
commit
48ad8692af
148 files changed
+6305
-2936
No files matched your search
@@ -23,13 +23,11 @@ public static partial class ApiRoutes
|
||||
public const string CANCEL_LIBRARIES_SCAN = "/libraries/scans/cancel";
|
||||
public const string CANCEL_LIBRARY_SCAN = "/libraries/{libraryId}/scans/{scanId}/cancel";
|
||||
public const string GET_LIBRARY_METADATA_PROVIDERS = "/libraries/{libraryId}/metadata-providers";
|
||||
public const string SET_LIBRARY_METADATA_PROVIDER_ENABLED = "/libraries/{libraryId}/metadata-providers/{pluginId}/enabled";
|
||||
public const string REORDER_LIBRARY_METADATA_PROVIDERS = "/libraries/{libraryId}/metadata-providers/reorder";
|
||||
public const string GET_LIBRARY_ARTWORK_PROVIDERS = "/libraries/{libraryId}/artwork-providers";
|
||||
public const string SET_LIBRARY_ARTWORK_PROVIDER_ENABLED = "/libraries/{libraryId}/artwork-providers/{pluginId}/enabled";
|
||||
public const string REORDER_LIBRARY_ARTWORK_PROVIDERS = "/libraries/{libraryId}/artwork-providers/reorder";
|
||||
public const string GET_LIBRARY_PATH_TEMPLATE_PARTS = "/libraries/path-template-parts/{libraryType}";
|
||||
public const string GET_LIBRARY_BOOK_READERS = "/libraries/{libraryId}/book-readers";
|
||||
public const string SET_LIBRARY_BOOK_READER_ENABLED = "/libraries/{libraryId}/book-readers/{pluginId}/enabled";
|
||||
public const string GET_LIBRARY_TYPE_METADATA_PROVIDERS = "/libraries/metadata-providers/{libraryType}";
|
||||
public const string GET_LIBRARY_TYPE_ARTWORK_PROVIDERS = "/libraries/artwork-providers/{libraryType}";
|
||||
public const string GET_LIBRARY_TYPE_BOOK_READERS = "/libraries/book-readers/{libraryType}";
|
||||
}
|
||||
}
|
||||
+11
-2
@@ -40,7 +40,10 @@ public class AddLibraryEndpointSummary : Summary<AddLibraryEndpoint, AddLibraryR
|
||||
IsContentOnSsd: false,
|
||||
ShouldTrackConsumptionProgress: true,
|
||||
CompletionThresholdPercentage: 90,
|
||||
PathTemplateParts: null
|
||||
PathTemplateParts: null,
|
||||
MetadataProviders: [new LibraryProviderSelectionRequest(PluginId: Guid.NewGuid(), IsEnabled: true)],
|
||||
ArtworkProviders: [new LibraryProviderSelectionRequest(PluginId: Guid.NewGuid(), IsEnabled: true)],
|
||||
BookReaders: null
|
||||
);
|
||||
|
||||
RequestParam(r => r.Title, "The title of the media library. Required.");
|
||||
@@ -56,6 +59,9 @@ public class AddLibraryEndpointSummary : Summary<AddLibraryEndpoint, AddLibraryR
|
||||
RequestParam(r => r.ShouldTrackConsumptionProgress, "Whether the consumption progress of the media library items should be tracked, or not. Optional, the default of the library type is used when absent.");
|
||||
RequestParam(r => r.CompletionThresholdPercentage, "The percentage of a media library item that must be consumed for its session to be considered completed. Optional, the default of the library type is used when absent.");
|
||||
RequestParam(r => r.PathTemplateParts, "The ordered parts of the template describing the structure of the media library on disk. Optional, the ideal structure of the library type is used when absent.");
|
||||
RequestParam(r => r.MetadataProviders, "The metadata providers of the media library, in the order in which they are tried, and whether each one is enabled. Optional, every provider supported by the library type is added disabled when absent.");
|
||||
RequestParam(r => r.ArtworkProviders, "The artwork providers of the media library, in the order in which they are tried, and whether each one is enabled. Optional, every provider supported by the library type is added disabled when absent.");
|
||||
RequestParam(r => r.BookReaders, "The book readers of the media library, and whether each one is enabled. Optional, every reader supported by the library type is added disabled when absent.");
|
||||
|
||||
ResponseParam<LibraryResponse>(r => r.Id, "The unique identifier of the entity.");
|
||||
ResponseParam<LibraryResponse>(r => r.UserId, "The unique identifier of the user owning the media library.");
|
||||
@@ -172,7 +178,10 @@ public class AddLibraryEndpointSummary : Summary<AddLibraryEndpoint, AddLibraryR
|
||||
"TitleMustBeMaximum255CharactersLong",
|
||||
"CompletionThresholdPercentageMustBeNullWhenProgressTrackingIsOff",
|
||||
"CompletionThresholdPercentageMustBeBetweenZeroAndOneHundred",
|
||||
"CoverFileMustBeAnImage"
|
||||
"CoverFileMustBeAnImage",
|
||||
"PluginIdCannotBeEmpty",
|
||||
"PluginIdsMustBeUnique",
|
||||
"PluginNotSupportedForLibraryType"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
+2
-2
@@ -22,7 +22,7 @@ public class DeleteLibraryEndpointSummary : Summary<DeleteLibraryEndpoint, Delet
|
||||
public DeleteLibraryEndpointSummary()
|
||||
{
|
||||
Summary = "Deletes an existing media library.";
|
||||
Description = "Deletes a media library, if the user making the request is an Admin, or the owner of the library.";
|
||||
Description = "Deletes a media library, if the user making the request is an Admin, or the owner of the library holding the permission to create libraries.";
|
||||
|
||||
ExampleRequest = new DeleteLibraryRequest(
|
||||
Id: Guid.NewGuid()
|
||||
@@ -62,7 +62,7 @@ public class DeleteLibraryEndpointSummary : Summary<DeleteLibraryEndpoint, Delet
|
||||
}
|
||||
);
|
||||
|
||||
Response(403, "The request failed because the user making the request is not an Admin, or the owner of the media library.", "application/problem+json",
|
||||
Response(403, "The request failed because the user making the request is neither an Admin, nor the owner of the media library holding the permission to create libraries.", "application/problem+json",
|
||||
example: new
|
||||
{
|
||||
type = "https://tools.ietf.org/html/rfc9110#section-15.5.4",
|
||||
|
||||
+13
-7
@@ -22,11 +22,10 @@ public class UpdateLibraryEndpointSummary : Summary<UpdateLibraryEndpoint, Updat
|
||||
public UpdateLibraryEndpointSummary()
|
||||
{
|
||||
Summary = "Updates an existing media library.";
|
||||
Description = "Updates a media library and returns its details, if the user making the request is an Admin, or the owner of the library.";
|
||||
Description = "Updates a media library and returns its details, if the user making the request is an Admin, or the owner of the library holding the permission to create libraries. The owner of the library is never changed by an update.";
|
||||
|
||||
ExampleRequest = new UpdateLibraryRequest(
|
||||
Id: Guid.NewGuid(),
|
||||
UserId: Guid.NewGuid(),
|
||||
Title: "TV Shows",
|
||||
LibraryType: "TvShow",
|
||||
ContentLocations: [
|
||||
@@ -42,11 +41,13 @@ public class UpdateLibraryEndpointSummary : Summary<UpdateLibraryEndpoint, Updat
|
||||
IsContentOnSsd: false,
|
||||
ShouldTrackConsumptionProgress: true,
|
||||
CompletionThresholdPercentage: 90,
|
||||
PathTemplateParts: null
|
||||
PathTemplateParts: null,
|
||||
MetadataProviders: [new LibraryProviderSelectionRequest(PluginId: Guid.NewGuid(), IsEnabled: true)],
|
||||
ArtworkProviders: [new LibraryProviderSelectionRequest(PluginId: Guid.NewGuid(), IsEnabled: true)],
|
||||
BookReaders: null
|
||||
);
|
||||
|
||||
RequestParam(r => r.Id, "The unique identifier of the media library. Required.");
|
||||
RequestParam(r => r.UserId, "The unique identifier of the user owning the media library. Required.");
|
||||
RequestParam(r => r.Title, "The title of the media library. Required.");
|
||||
RequestParam(r => r.LibraryType, "The type of the media library. Required.");
|
||||
RequestParam(r => r.ContentLocations, ">The file system paths of the directories where the media library elements are located. Required.");
|
||||
@@ -60,6 +61,9 @@ public class UpdateLibraryEndpointSummary : Summary<UpdateLibraryEndpoint, Updat
|
||||
RequestParam(r => r.ShouldTrackConsumptionProgress, "Whether the consumption progress of the media library items should be tracked, or not. Optional, the stored value is kept when absent.");
|
||||
RequestParam(r => r.CompletionThresholdPercentage, "The percentage of a media library item that must be consumed for its session to be considered completed. Optional, the stored value is kept when absent.");
|
||||
RequestParam(r => r.PathTemplateParts, "The ordered parts of the template describing the structure of the media library on disk. Optional, the ideal structure of the library type is used when absent.");
|
||||
RequestParam(r => r.MetadataProviders, "The metadata providers of the media library, in the order in which they are tried, and whether each one is enabled. Optional, the stored configurations are kept, or reconciled with the library type when it changes when absent.");
|
||||
RequestParam(r => r.ArtworkProviders, "The artwork providers of the media library, in the order in which they are tried, and whether each one is enabled. Optional, the stored configurations are kept, or reconciled with the library type when it changes when absent.");
|
||||
RequestParam(r => r.BookReaders, "The book readers of the media library, and whether each one is enabled. Optional, the stored configurations are kept, or reconciled with the library type when it changes when absent.");
|
||||
|
||||
ResponseParam<LibraryResponse>(r => r.Id, "The unique identifier of the entity.");
|
||||
ResponseParam<LibraryResponse>(r => r.UserId, "The unique identifier of the user owning the media library.");
|
||||
@@ -130,7 +134,7 @@ public class UpdateLibraryEndpointSummary : Summary<UpdateLibraryEndpoint, Updat
|
||||
}
|
||||
);
|
||||
|
||||
Response(403, "The request failed because the authenticated user is not allowed to manage the media library, or because the request carried an unsupported library type.", "application/problem+json",
|
||||
Response(403, "The request failed because the authenticated user is neither an Admin, nor the owner of the media library holding the permission to create libraries, or because the request carried an unsupported library type.", "application/problem+json",
|
||||
example: new[]
|
||||
{
|
||||
new
|
||||
@@ -180,7 +184,6 @@ public class UpdateLibraryEndpointSummary : Summary<UpdateLibraryEndpoint, Updat
|
||||
"General.Validation", new[]
|
||||
{
|
||||
"LibraryIdCannotBeEmpty",
|
||||
"UserIdCannotBeEmpty",
|
||||
"LibraryTypeCannotBeNull",
|
||||
"PathsListCannotBeNull",
|
||||
"PathsListCannotBeEmpty",
|
||||
@@ -189,7 +192,10 @@ public class UpdateLibraryEndpointSummary : Summary<UpdateLibraryEndpoint, Updat
|
||||
"TitleCannotBeEmpty",
|
||||
"TitleMustBeMaximum255CharactersLong",
|
||||
"CompletionThresholdPercentageMustBeNullWhenProgressTrackingIsOff",
|
||||
"CompletionThresholdPercentageMustBeBetweenZeroAndOneHundred"
|
||||
"CompletionThresholdPercentageMustBeBetweenZeroAndOneHundred",
|
||||
"PluginIdCannotBeEmpty",
|
||||
"PluginIdsMustBeUnique",
|
||||
"PluginNotSupportedForLibraryType"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Application.Common.CQRS;
|
||||
using Lumina.Application.Common.Mapping.Plugins;
|
||||
using Lumina.Application.Core.Plugins.Queries.GetLibraryTypeArtworkProviders;
|
||||
using Lumina.Contracts.Requests.Plugins;
|
||||
using Lumina.Contracts.Responses.Plugins;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Presentation.Api.Common.Routes.Library.Management;
|
||||
using Lumina.Presentation.Api.Core.Endpoints.Common;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Api.Core.Endpoints.Plugins.GetLibraryTypeArtworkProviders;
|
||||
|
||||
/// <summary>
|
||||
/// API endpoint for the <c>/libraries/artwork-providers/{libraryType}</c> route.
|
||||
/// </summary>
|
||||
public class GetLibraryTypeArtworkProvidersEndpoint : BaseEndpoint<GetLibraryTypeArtworkProvidersRequest, IResult>
|
||||
{
|
||||
private readonly IQueryHandler<GetLibraryTypeArtworkProvidersQuery, Result<IReadOnlyList<LibraryArtworkProviderResponse>>> _getLibraryTypeArtworkProvidersQueryHandler;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GetLibraryTypeArtworkProvidersEndpoint"/> class.
|
||||
/// </summary>
|
||||
/// <param name="getLibraryTypeArtworkProvidersQueryHandler">Injected service for handling get library type artwork providers queries.</param>
|
||||
public GetLibraryTypeArtworkProvidersEndpoint(IQueryHandler<GetLibraryTypeArtworkProvidersQuery, Result<IReadOnlyList<LibraryArtworkProviderResponse>>> getLibraryTypeArtworkProvidersQueryHandler)
|
||||
{
|
||||
_getLibraryTypeArtworkProvidersQueryHandler = getLibraryTypeArtworkProvidersQueryHandler;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Configures the API endpoint.
|
||||
/// </summary>
|
||||
public override void Configure()
|
||||
{
|
||||
Verbs(Http.GET);
|
||||
Routes(ApiRoutes.Libraries.GET_LIBRARY_TYPE_ARTWORK_PROVIDERS);
|
||||
Version(1);
|
||||
DontCatchExceptions();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the artwork providers available for the media library type provided in <paramref name="request"/>.
|
||||
/// </summary>
|
||||
/// <param name="request">The request containing the media library type whose available artwork providers are retrieved.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
public override async Task<IResult> ExecuteAsync(GetLibraryTypeArtworkProvidersRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
Result<IReadOnlyList<LibraryArtworkProviderResponse>> result = await _getLibraryTypeArtworkProvidersQueryHandler.HandleAsync(request.ToQuery(), cancellationToken).ConfigureAwait(false);
|
||||
return result.Match(success => TypedResults.Ok(success), Problem);
|
||||
}
|
||||
}
|
||||
+118
@@ -0,0 +1,118 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Contracts.Requests.Plugins;
|
||||
using Lumina.Contracts.Responses.Plugins;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Api.Core.Endpoints.Plugins.GetLibraryTypeArtworkProviders;
|
||||
|
||||
/// <summary>
|
||||
/// Class used for providing a textual description for the <see cref="GetLibraryTypeArtworkProvidersEndpoint"/> API endpoint, for OpenAPI.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GetLibraryTypeArtworkProvidersEndpointSummary : Summary<GetLibraryTypeArtworkProvidersEndpoint, GetLibraryTypeArtworkProvidersRequest>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GetLibraryTypeArtworkProvidersEndpointSummary"/> class.
|
||||
/// </summary>
|
||||
public GetLibraryTypeArtworkProvidersEndpointSummary()
|
||||
{
|
||||
Summary = "Retrieves the artwork providers available for a media library type.";
|
||||
Description = "Retrieves the artwork providers of the loaded plugins that support a media library type, in the state a new media library of that type starts with: disabled, and ranked in alphabetical order.";
|
||||
|
||||
ExampleRequest = new GetLibraryTypeArtworkProvidersRequest(
|
||||
LibraryType: "Book"
|
||||
);
|
||||
|
||||
RequestParam(r => r.LibraryType, "The media library type whose available artwork providers are retrieved. Required.");
|
||||
|
||||
ResponseParam<LibraryArtworkProviderResponse>(r => r.PluginId, "The unique identifier of the plugin providing the artwork.");
|
||||
ResponseParam<LibraryArtworkProviderResponse>(r => r.Name, "The display name of the artwork provider.");
|
||||
ResponseParam<LibraryArtworkProviderResponse>(r => r.IsEnabled, "Whether the artwork provider is enabled. Always false, since no media library is involved.");
|
||||
ResponseParam<LibraryArtworkProviderResponse>(r => r.Rank, "The rank of the artwork provider, determining the order in which providers are tried.");
|
||||
|
||||
Response(200, "The artwork providers available for the media library type are returned.",
|
||||
example: new LibraryArtworkProviderResponse[] {
|
||||
new(
|
||||
PluginId: Guid.NewGuid(),
|
||||
Name: "Goodreads",
|
||||
IsEnabled: false,
|
||||
Rank: 1
|
||||
),
|
||||
new(
|
||||
PluginId: Guid.NewGuid(),
|
||||
Name: "OpenLibrary",
|
||||
IsEnabled: false,
|
||||
Rank: 2
|
||||
)
|
||||
}
|
||||
);
|
||||
|
||||
Response(401, "Authentication required.", "application/problem+json",
|
||||
example: new[]
|
||||
{
|
||||
new
|
||||
{
|
||||
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
|
||||
status = 401,
|
||||
title = "Unauthorized",
|
||||
detail = "Authentication failed",
|
||||
instance = "/api/v1/libraries/artwork-providers/{libraryType}"
|
||||
},
|
||||
new
|
||||
{
|
||||
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
|
||||
status = 401,
|
||||
title = "Unauthorized",
|
||||
detail = "The token has expired",
|
||||
instance = "/api/v1/libraries/artwork-providers/{libraryType}"
|
||||
},
|
||||
new
|
||||
{
|
||||
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
|
||||
status = 401,
|
||||
title = "Unauthorized",
|
||||
detail = "The token is invalid",
|
||||
instance = "/api/v1/libraries/artwork-providers/{libraryType}"
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
Response(403, "The request failed because the request carries no user identity.", "application/problem+json",
|
||||
example: new
|
||||
{
|
||||
type = "https://tools.ietf.org/html/rfc9110#section-15.5.4",
|
||||
title = "General.Failure",
|
||||
status = 403,
|
||||
detail = "NotAuthorized",
|
||||
instance = "/api/v1/libraries/artwork-providers/{libraryType}",
|
||||
traceId = "00-a712bbf99ca8ab485f86a762ae5ae74d-b3a2eb78813b0a5d-00"
|
||||
}
|
||||
);
|
||||
|
||||
Response(422, "The request did not pass validation checks.", "application/problem+json",
|
||||
example: new
|
||||
{
|
||||
type = "https://tools.ietf.org/html/rfc4918#section-11.2",
|
||||
title = "General.Validation",
|
||||
status = 422,
|
||||
detail = "OneOrMoreValidationErrorsOccurred",
|
||||
instance = "/api/v1/libraries/artwork-providers/{libraryType}",
|
||||
errors = new Dictionary<string, string[]>
|
||||
{
|
||||
{
|
||||
"General.Validation", new[]
|
||||
{
|
||||
"LibraryTypeCannotBeNull",
|
||||
"UnknownLibraryType"
|
||||
}
|
||||
}
|
||||
},
|
||||
traceId = "00-2470be4248a2a5a0c6f70579975a6954-b9c3ba9544a03500-00"
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Application.Common.CQRS;
|
||||
using Lumina.Application.Common.Mapping.Plugins;
|
||||
using Lumina.Application.Core.Plugins.Queries.GetLibraryTypeBookReaders;
|
||||
using Lumina.Contracts.Requests.Plugins;
|
||||
using Lumina.Contracts.Responses.Plugins;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Presentation.Api.Common.Routes.Library.Management;
|
||||
using Lumina.Presentation.Api.Core.Endpoints.Common;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Api.Core.Endpoints.Plugins.GetLibraryTypeBookReaders;
|
||||
|
||||
/// <summary>
|
||||
/// API endpoint for the <c>/libraries/book-readers/{libraryType}</c> route.
|
||||
/// </summary>
|
||||
public class GetLibraryTypeBookReadersEndpoint : BaseEndpoint<GetLibraryTypeBookReadersRequest, IResult>
|
||||
{
|
||||
private readonly IQueryHandler<GetLibraryTypeBookReadersQuery, Result<IReadOnlyList<LibraryBookReaderResponse>>> _getLibraryTypeBookReadersQueryHandler;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GetLibraryTypeBookReadersEndpoint"/> class.
|
||||
/// </summary>
|
||||
/// <param name="getLibraryTypeBookReadersQueryHandler">Injected service for handling get library type book readers queries.</param>
|
||||
public GetLibraryTypeBookReadersEndpoint(IQueryHandler<GetLibraryTypeBookReadersQuery, Result<IReadOnlyList<LibraryBookReaderResponse>>> getLibraryTypeBookReadersQueryHandler)
|
||||
{
|
||||
_getLibraryTypeBookReadersQueryHandler = getLibraryTypeBookReadersQueryHandler;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Configures the API endpoint.
|
||||
/// </summary>
|
||||
public override void Configure()
|
||||
{
|
||||
Verbs(Http.GET);
|
||||
Routes(ApiRoutes.Libraries.GET_LIBRARY_TYPE_BOOK_READERS);
|
||||
Version(1);
|
||||
DontCatchExceptions();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the book readers available for the media library type provided in <paramref name="request"/>.
|
||||
/// </summary>
|
||||
/// <param name="request">The request containing the media library type whose available book readers are retrieved.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
public override async Task<IResult> ExecuteAsync(GetLibraryTypeBookReadersRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
Result<IReadOnlyList<LibraryBookReaderResponse>> result = await _getLibraryTypeBookReadersQueryHandler.HandleAsync(request.ToQuery(), cancellationToken).ConfigureAwait(false);
|
||||
return result.Match(success => TypedResults.Ok(success), Problem);
|
||||
}
|
||||
}
|
||||
+118
@@ -0,0 +1,118 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Contracts.Requests.Plugins;
|
||||
using Lumina.Contracts.Responses.Plugins;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Api.Core.Endpoints.Plugins.GetLibraryTypeBookReaders;
|
||||
|
||||
/// <summary>
|
||||
/// Class used for providing a textual description for the <see cref="GetLibraryTypeBookReadersEndpoint"/> API endpoint, for OpenAPI.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GetLibraryTypeBookReadersEndpointSummary : Summary<GetLibraryTypeBookReadersEndpoint, GetLibraryTypeBookReadersRequest>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GetLibraryTypeBookReadersEndpointSummary"/> class.
|
||||
/// </summary>
|
||||
public GetLibraryTypeBookReadersEndpointSummary()
|
||||
{
|
||||
Summary = "Retrieves the book readers available for a media library type.";
|
||||
Description = "Retrieves the book readers of the loaded plugins that support a media library type, with their supported file extensions, in the state a new media library of that type starts with: disabled, in alphabetical order.";
|
||||
|
||||
ExampleRequest = new GetLibraryTypeBookReadersRequest(
|
||||
LibraryType: "Book"
|
||||
);
|
||||
|
||||
RequestParam(r => r.LibraryType, "The media library type whose available book readers are retrieved. Required.");
|
||||
|
||||
ResponseParam<LibraryBookReaderResponse>(r => r.PluginId, "The unique identifier of the plugin providing the book reader.");
|
||||
ResponseParam<LibraryBookReaderResponse>(r => r.Name, "The display name of the book reader.");
|
||||
ResponseParam<LibraryBookReaderResponse>(r => r.SupportedExtensions, "The file extensions supported by the book reader.");
|
||||
ResponseParam<LibraryBookReaderResponse>(r => r.IsEnabled, "Whether the book reader is enabled. Always false, since no media library is involved.");
|
||||
|
||||
Response(200, "The book readers available for the media library type are returned.",
|
||||
example: new LibraryBookReaderResponse[] {
|
||||
new(
|
||||
PluginId: Guid.NewGuid(),
|
||||
Name: "EPUB Reader",
|
||||
SupportedExtensions: [".epub"],
|
||||
IsEnabled: false
|
||||
),
|
||||
new(
|
||||
PluginId: Guid.NewGuid(),
|
||||
Name: "PDF Reader",
|
||||
SupportedExtensions: [".pdf"],
|
||||
IsEnabled: false
|
||||
)
|
||||
}
|
||||
);
|
||||
|
||||
Response(401, "Authentication required.", "application/problem+json",
|
||||
example: new[]
|
||||
{
|
||||
new
|
||||
{
|
||||
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
|
||||
status = 401,
|
||||
title = "Unauthorized",
|
||||
detail = "Authentication failed",
|
||||
instance = "/api/v1/libraries/book-readers/{libraryType}"
|
||||
},
|
||||
new
|
||||
{
|
||||
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
|
||||
status = 401,
|
||||
title = "Unauthorized",
|
||||
detail = "The token has expired",
|
||||
instance = "/api/v1/libraries/book-readers/{libraryType}"
|
||||
},
|
||||
new
|
||||
{
|
||||
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
|
||||
status = 401,
|
||||
title = "Unauthorized",
|
||||
detail = "The token is invalid",
|
||||
instance = "/api/v1/libraries/book-readers/{libraryType}"
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
Response(403, "The request failed because the request carries no user identity.", "application/problem+json",
|
||||
example: new
|
||||
{
|
||||
type = "https://tools.ietf.org/html/rfc9110#section-15.5.4",
|
||||
title = "General.Failure",
|
||||
status = 403,
|
||||
detail = "NotAuthorized",
|
||||
instance = "/api/v1/libraries/book-readers/{libraryType}",
|
||||
traceId = "00-a712bbf99ca8ab485f86a762ae5ae74d-b3a2eb78813b0a5d-00"
|
||||
}
|
||||
);
|
||||
|
||||
Response(422, "The request did not pass validation checks.", "application/problem+json",
|
||||
example: new
|
||||
{
|
||||
type = "https://tools.ietf.org/html/rfc4918#section-11.2",
|
||||
title = "General.Validation",
|
||||
status = 422,
|
||||
detail = "OneOrMoreValidationErrorsOccurred",
|
||||
instance = "/api/v1/libraries/book-readers/{libraryType}",
|
||||
errors = new Dictionary<string, string[]>
|
||||
{
|
||||
{
|
||||
"General.Validation", new[]
|
||||
{
|
||||
"LibraryTypeCannotBeNull",
|
||||
"UnknownLibraryType"
|
||||
}
|
||||
}
|
||||
},
|
||||
traceId = "00-2470be4248a2a5a0c6f70579975a6954-b9c3ba9544a03500-00"
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Application.Common.CQRS;
|
||||
using Lumina.Application.Common.Mapping.Plugins;
|
||||
using Lumina.Application.Core.Plugins.Queries.GetLibraryTypeMetadataProviders;
|
||||
using Lumina.Contracts.Requests.Plugins;
|
||||
using Lumina.Contracts.Responses.Plugins;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Presentation.Api.Common.Routes.Library.Management;
|
||||
using Lumina.Presentation.Api.Core.Endpoints.Common;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Api.Core.Endpoints.Plugins.GetLibraryTypeMetadataProviders;
|
||||
|
||||
/// <summary>
|
||||
/// API endpoint for the <c>/libraries/metadata-providers/{libraryType}</c> route.
|
||||
/// </summary>
|
||||
public class GetLibraryTypeMetadataProvidersEndpoint : BaseEndpoint<GetLibraryTypeMetadataProvidersRequest, IResult>
|
||||
{
|
||||
private readonly IQueryHandler<GetLibraryTypeMetadataProvidersQuery, Result<IReadOnlyList<LibraryMetadataProviderResponse>>> _getLibraryTypeMetadataProvidersQueryHandler;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GetLibraryTypeMetadataProvidersEndpoint"/> class.
|
||||
/// </summary>
|
||||
/// <param name="getLibraryTypeMetadataProvidersQueryHandler">Injected service for handling get library type metadata providers queries.</param>
|
||||
public GetLibraryTypeMetadataProvidersEndpoint(IQueryHandler<GetLibraryTypeMetadataProvidersQuery, Result<IReadOnlyList<LibraryMetadataProviderResponse>>> getLibraryTypeMetadataProvidersQueryHandler)
|
||||
{
|
||||
_getLibraryTypeMetadataProvidersQueryHandler = getLibraryTypeMetadataProvidersQueryHandler;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Configures the API endpoint.
|
||||
/// </summary>
|
||||
public override void Configure()
|
||||
{
|
||||
Verbs(Http.GET);
|
||||
Routes(ApiRoutes.Libraries.GET_LIBRARY_TYPE_METADATA_PROVIDERS);
|
||||
Version(1);
|
||||
DontCatchExceptions();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the metadata providers available for the media library type provided in <paramref name="request"/>.
|
||||
/// </summary>
|
||||
/// <param name="request">The request containing the media library type whose available metadata providers are retrieved.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
public override async Task<IResult> ExecuteAsync(GetLibraryTypeMetadataProvidersRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
Result<IReadOnlyList<LibraryMetadataProviderResponse>> result = await _getLibraryTypeMetadataProvidersQueryHandler.HandleAsync(request.ToQuery(), cancellationToken).ConfigureAwait(false);
|
||||
return result.Match(success => TypedResults.Ok(success), Problem);
|
||||
}
|
||||
}
|
||||
+118
@@ -0,0 +1,118 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Contracts.Requests.Plugins;
|
||||
using Lumina.Contracts.Responses.Plugins;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Api.Core.Endpoints.Plugins.GetLibraryTypeMetadataProviders;
|
||||
|
||||
/// <summary>
|
||||
/// Class used for providing a textual description for the <see cref="GetLibraryTypeMetadataProvidersEndpoint"/> API endpoint, for OpenAPI.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GetLibraryTypeMetadataProvidersEndpointSummary : Summary<GetLibraryTypeMetadataProvidersEndpoint, GetLibraryTypeMetadataProvidersRequest>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GetLibraryTypeMetadataProvidersEndpointSummary"/> class.
|
||||
/// </summary>
|
||||
public GetLibraryTypeMetadataProvidersEndpointSummary()
|
||||
{
|
||||
Summary = "Retrieves the metadata providers available for a media library type.";
|
||||
Description = "Retrieves the metadata providers of the loaded plugins that support a media library type, in the state a new media library of that type starts with: disabled, and ranked in alphabetical order.";
|
||||
|
||||
ExampleRequest = new GetLibraryTypeMetadataProvidersRequest(
|
||||
LibraryType: "Book"
|
||||
);
|
||||
|
||||
RequestParam(r => r.LibraryType, "The media library type whose available metadata providers are retrieved. Required.");
|
||||
|
||||
ResponseParam<LibraryMetadataProviderResponse>(r => r.PluginId, "The unique identifier of the plugin providing the metadata.");
|
||||
ResponseParam<LibraryMetadataProviderResponse>(r => r.Name, "The display name of the metadata provider.");
|
||||
ResponseParam<LibraryMetadataProviderResponse>(r => r.IsEnabled, "Whether the metadata provider is enabled. Always false, since no media library is involved.");
|
||||
ResponseParam<LibraryMetadataProviderResponse>(r => r.Rank, "The rank of the metadata provider, determining the order in which providers are tried.");
|
||||
|
||||
Response(200, "The metadata providers available for the media library type are returned.",
|
||||
example: new LibraryMetadataProviderResponse[] {
|
||||
new(
|
||||
PluginId: Guid.NewGuid(),
|
||||
Name: "Goodreads",
|
||||
IsEnabled: false,
|
||||
Rank: 1
|
||||
),
|
||||
new(
|
||||
PluginId: Guid.NewGuid(),
|
||||
Name: "OpenLibrary",
|
||||
IsEnabled: false,
|
||||
Rank: 2
|
||||
)
|
||||
}
|
||||
);
|
||||
|
||||
Response(401, "Authentication required.", "application/problem+json",
|
||||
example: new[]
|
||||
{
|
||||
new
|
||||
{
|
||||
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
|
||||
status = 401,
|
||||
title = "Unauthorized",
|
||||
detail = "Authentication failed",
|
||||
instance = "/api/v1/libraries/metadata-providers/{libraryType}"
|
||||
},
|
||||
new
|
||||
{
|
||||
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
|
||||
status = 401,
|
||||
title = "Unauthorized",
|
||||
detail = "The token has expired",
|
||||
instance = "/api/v1/libraries/metadata-providers/{libraryType}"
|
||||
},
|
||||
new
|
||||
{
|
||||
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
|
||||
status = 401,
|
||||
title = "Unauthorized",
|
||||
detail = "The token is invalid",
|
||||
instance = "/api/v1/libraries/metadata-providers/{libraryType}"
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
Response(403, "The request failed because the request carries no user identity.", "application/problem+json",
|
||||
example: new
|
||||
{
|
||||
type = "https://tools.ietf.org/html/rfc9110#section-15.5.4",
|
||||
title = "General.Failure",
|
||||
status = 403,
|
||||
detail = "NotAuthorized",
|
||||
instance = "/api/v1/libraries/metadata-providers/{libraryType}",
|
||||
traceId = "00-a712bbf99ca8ab485f86a762ae5ae74d-b3a2eb78813b0a5d-00"
|
||||
}
|
||||
);
|
||||
|
||||
Response(422, "The request did not pass validation checks.", "application/problem+json",
|
||||
example: new
|
||||
{
|
||||
type = "https://tools.ietf.org/html/rfc4918#section-11.2",
|
||||
title = "General.Validation",
|
||||
status = 422,
|
||||
detail = "OneOrMoreValidationErrorsOccurred",
|
||||
instance = "/api/v1/libraries/metadata-providers/{libraryType}",
|
||||
errors = new Dictionary<string, string[]>
|
||||
{
|
||||
{
|
||||
"General.Validation", new[]
|
||||
{
|
||||
"LibraryTypeCannotBeNull",
|
||||
"UnknownLibraryType"
|
||||
}
|
||||
}
|
||||
},
|
||||
traceId = "00-2470be4248a2a5a0c6f70579975a6954-b9c3ba9544a03500-00"
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
-53
@@ -1,53 +0,0 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.CQRS;
|
||||
using Lumina.Application.Common.Mapping.Plugins;
|
||||
using Lumina.Application.Core.Plugins.Commands.ReorderLibraryArtworkProviders;
|
||||
using Lumina.Contracts.Requests.Plugins;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Presentation.Api.Common.Routes.Library.Management;
|
||||
using Lumina.Presentation.Api.Core.Endpoints.Common;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Api.Core.Endpoints.Plugins.ReorderLibraryArtworkProviders;
|
||||
|
||||
/// <summary>
|
||||
/// API endpoint for the <c>/libraries/{libraryId}/artwork-providers/reorder</c> route.
|
||||
/// </summary>
|
||||
public class ReorderLibraryArtworkProvidersEndpoint : BaseEndpoint<ReorderLibraryArtworkProvidersRequest, IResult>
|
||||
{
|
||||
private readonly ICommandHandler<ReorderLibraryArtworkProvidersCommand, Result<Success>> _reorderLibraryArtworkProvidersCommandHandler;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ReorderLibraryArtworkProvidersEndpoint"/> class.
|
||||
/// </summary>
|
||||
/// <param name="reorderLibraryArtworkProvidersCommandHandler">Injected service for handling reorder library artwork providers commands.</param>
|
||||
public ReorderLibraryArtworkProvidersEndpoint(ICommandHandler<ReorderLibraryArtworkProvidersCommand, Result<Success>> reorderLibraryArtworkProvidersCommandHandler)
|
||||
{
|
||||
_reorderLibraryArtworkProvidersCommandHandler = reorderLibraryArtworkProvidersCommandHandler;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Configures the API endpoint.
|
||||
/// </summary>
|
||||
public override void Configure()
|
||||
{
|
||||
Verbs(FastEndpoints.Http.PUT);
|
||||
Routes(ApiRoutes.Libraries.REORDER_LIBRARY_ARTWORK_PROVIDERS);
|
||||
Version(1);
|
||||
DontCatchExceptions();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reorders the artwork providers of the media library identified by <paramref name="request"/>.
|
||||
/// </summary>
|
||||
/// <param name="request">The request containing the Id of the media library and the plugin Ids in the new order.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
public override async Task<IResult> ExecuteAsync(ReorderLibraryArtworkProvidersRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
Result<Success> result = await _reorderLibraryArtworkProvidersCommandHandler.HandleAsync(request.ToCommand(), cancellationToken).ConfigureAwait(false);
|
||||
return result.Match(success => TypedResults.Ok(success), Problem);
|
||||
}
|
||||
}
|
||||
-116
@@ -1,116 +0,0 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Contracts.Requests.Plugins;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Api.Core.Endpoints.Plugins.ReorderLibraryArtworkProviders;
|
||||
|
||||
/// <summary>
|
||||
/// Class used for providing a textual description for the <see cref="ReorderLibraryArtworkProvidersEndpoint"/> API endpoint, for OpenAPI.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ReorderLibraryArtworkProvidersEndpointSummary : Summary<ReorderLibraryArtworkProvidersEndpoint, ReorderLibraryArtworkProvidersRequest>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ReorderLibraryArtworkProvidersEndpointSummary"/> class.
|
||||
/// </summary>
|
||||
public ReorderLibraryArtworkProvidersEndpointSummary()
|
||||
{
|
||||
Summary = "Reorders the artwork providers of a media library.";
|
||||
Description = "Reorders the artwork providers of a media library, determining the order in which the providers are tried during the artwork enrichment of the library scans.";
|
||||
|
||||
ExampleRequest = new ReorderLibraryArtworkProvidersRequest(
|
||||
LibraryId: Guid.NewGuid(),
|
||||
PluginIds:
|
||||
[
|
||||
Guid.NewGuid(),
|
||||
Guid.NewGuid()
|
||||
]
|
||||
);
|
||||
|
||||
RequestParam(r => r.LibraryId, "The Id of the media library whose artwork providers are reordered. Required.");
|
||||
RequestParam(r => r.PluginIds, "The plugin Ids in the new order, from highest to lowest rank. Required.");
|
||||
|
||||
Response(200, "The artwork providers of the media library were successfully reordered.");
|
||||
|
||||
Response(401, "Authentication required.", "application/problem+json",
|
||||
example: new[]
|
||||
{
|
||||
new
|
||||
{
|
||||
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
|
||||
status = 401,
|
||||
title = "Unauthorized",
|
||||
detail = "Authentication failed",
|
||||
instance = "/api/v1/libraries/{libraryId}/artwork-providers/reorder"
|
||||
},
|
||||
new
|
||||
{
|
||||
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
|
||||
status = 401,
|
||||
title = "Unauthorized",
|
||||
detail = "The token has expired",
|
||||
instance = "/api/v1/libraries/{libraryId}/artwork-providers/reorder"
|
||||
},
|
||||
new
|
||||
{
|
||||
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
|
||||
status = 401,
|
||||
title = "Unauthorized",
|
||||
detail = "The token is invalid",
|
||||
instance = "/api/v1/libraries/{libraryId}/artwork-providers/reorder"
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
Response(403, "The request failed because the user making the request is not an Admin, or the owner of the media library.", "application/problem+json",
|
||||
example: new
|
||||
{
|
||||
type = "https://tools.ietf.org/html/rfc9110#section-15.5.4",
|
||||
title = "General.Failure",
|
||||
status = 403,
|
||||
detail = "NotAuthorized",
|
||||
instance = "/api/v1/libraries/{libraryId}/artwork-providers/reorder",
|
||||
traceId = "00-a712bbf99ca8ab485f86a762ae5ae74d-b3a2eb78813b0a5d-00"
|
||||
}
|
||||
);
|
||||
|
||||
Response(404, "The request failed because the requested media library does not exist.", "application/problem+json",
|
||||
example: new
|
||||
{
|
||||
type = "https://tools.ietf.org/html/rfc9110#section-15.5.5",
|
||||
title = "General.NotFound",
|
||||
status = 404,
|
||||
detail = "LibraryNotFound",
|
||||
instance = "/api/v1/libraries/{libraryId}/artwork-providers/reorder",
|
||||
traceId = "00-57d15dadd702dbd4aeb5dc9b7cee68ee-9330237dbb2ce0e5-00"
|
||||
}
|
||||
);
|
||||
|
||||
Response(422, "The request did not pass validation checks.", "application/problem+json",
|
||||
example: new
|
||||
{
|
||||
type = "https://tools.ietf.org/html/rfc4918#section-11.2",
|
||||
title = "General.Validation",
|
||||
status = 422,
|
||||
detail = "OneOrMoreValidationErrorsOccurred",
|
||||
instance = "/api/v1/libraries/{libraryId}/artwork-providers/reorder",
|
||||
errors = new Dictionary<string, string[]>
|
||||
{
|
||||
{
|
||||
"General.Validation", new[]
|
||||
{
|
||||
"LibraryIdCannotBeEmpty",
|
||||
"PluginIdsListCannotBeNull",
|
||||
"PluginIdsListCannotBeEmpty"
|
||||
}
|
||||
}
|
||||
},
|
||||
traceId = "00-2470be4248a2a5a0c6f70579975a6954-b9c3ba9544a03500-00"
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
-53
@@ -1,53 +0,0 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.CQRS;
|
||||
using Lumina.Application.Common.Mapping.Plugins;
|
||||
using Lumina.Application.Core.Plugins.Commands.ReorderLibraryMetadataProviders;
|
||||
using Lumina.Contracts.Requests.Plugins;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Presentation.Api.Common.Routes.Library.Management;
|
||||
using Lumina.Presentation.Api.Core.Endpoints.Common;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Api.Core.Endpoints.Plugins.ReorderLibraryMetadataProviders;
|
||||
|
||||
/// <summary>
|
||||
/// API endpoint for the <c>/libraries/{libraryId}/metadata-providers/reorder</c> route.
|
||||
/// </summary>
|
||||
public class ReorderLibraryMetadataProvidersEndpoint : BaseEndpoint<ReorderLibraryMetadataProvidersRequest, IResult>
|
||||
{
|
||||
private readonly ICommandHandler<ReorderLibraryMetadataProvidersCommand, Result<Success>> _reorderLibraryMetadataProvidersCommandHandler;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ReorderLibraryMetadataProvidersEndpoint"/> class.
|
||||
/// </summary>
|
||||
/// <param name="reorderLibraryMetadataProvidersCommandHandler">Injected service for handling reorder library metadata providers commands.</param>
|
||||
public ReorderLibraryMetadataProvidersEndpoint(ICommandHandler<ReorderLibraryMetadataProvidersCommand, Result<Success>> reorderLibraryMetadataProvidersCommandHandler)
|
||||
{
|
||||
_reorderLibraryMetadataProvidersCommandHandler = reorderLibraryMetadataProvidersCommandHandler;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Configures the API endpoint.
|
||||
/// </summary>
|
||||
public override void Configure()
|
||||
{
|
||||
Verbs(FastEndpoints.Http.PUT);
|
||||
Routes(ApiRoutes.Libraries.REORDER_LIBRARY_METADATA_PROVIDERS);
|
||||
Version(1);
|
||||
DontCatchExceptions();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reorders the metadata providers of the media library identified by <paramref name="request"/>.
|
||||
/// </summary>
|
||||
/// <param name="request">The request containing the Id of the media library and the plugin Ids in the new order.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
public override async Task<IResult> ExecuteAsync(ReorderLibraryMetadataProvidersRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
Result<Success> result = await _reorderLibraryMetadataProvidersCommandHandler.HandleAsync(request.ToCommand(), cancellationToken).ConfigureAwait(false);
|
||||
return result.Match(success => TypedResults.Ok(success), Problem);
|
||||
}
|
||||
}
|
||||
-116
@@ -1,116 +0,0 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Contracts.Requests.Plugins;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Api.Core.Endpoints.Plugins.ReorderLibraryMetadataProviders;
|
||||
|
||||
/// <summary>
|
||||
/// Class used for providing a textual description for the <see cref="ReorderLibraryMetadataProvidersEndpoint"/> API endpoint, for OpenAPI.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ReorderLibraryMetadataProvidersEndpointSummary : Summary<ReorderLibraryMetadataProvidersEndpoint, ReorderLibraryMetadataProvidersRequest>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ReorderLibraryMetadataProvidersEndpointSummary"/> class.
|
||||
/// </summary>
|
||||
public ReorderLibraryMetadataProvidersEndpointSummary()
|
||||
{
|
||||
Summary = "Reorders the metadata providers of a media library.";
|
||||
Description = "Reorders the metadata providers of a media library, determining the order in which the providers are tried during the metadata enrichment of the library scans.";
|
||||
|
||||
ExampleRequest = new ReorderLibraryMetadataProvidersRequest(
|
||||
LibraryId: Guid.NewGuid(),
|
||||
PluginIds:
|
||||
[
|
||||
Guid.NewGuid(),
|
||||
Guid.NewGuid()
|
||||
]
|
||||
);
|
||||
|
||||
RequestParam(r => r.LibraryId, "The Id of the media library whose metadata providers are reordered. Required.");
|
||||
RequestParam(r => r.PluginIds, "The plugin Ids in the new order, from highest to lowest rank. Required.");
|
||||
|
||||
Response(200, "The metadata providers of the media library were successfully reordered.");
|
||||
|
||||
Response(401, "Authentication required.", "application/problem+json",
|
||||
example: new[]
|
||||
{
|
||||
new
|
||||
{
|
||||
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
|
||||
status = 401,
|
||||
title = "Unauthorized",
|
||||
detail = "Authentication failed",
|
||||
instance = "/api/v1/libraries/{libraryId}/metadata-providers/reorder"
|
||||
},
|
||||
new
|
||||
{
|
||||
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
|
||||
status = 401,
|
||||
title = "Unauthorized",
|
||||
detail = "The token has expired",
|
||||
instance = "/api/v1/libraries/{libraryId}/metadata-providers/reorder"
|
||||
},
|
||||
new
|
||||
{
|
||||
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
|
||||
status = 401,
|
||||
title = "Unauthorized",
|
||||
detail = "The token is invalid",
|
||||
instance = "/api/v1/libraries/{libraryId}/metadata-providers/reorder"
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
Response(403, "The request failed because the user making the request is not an Admin, or the owner of the media library.", "application/problem+json",
|
||||
example: new
|
||||
{
|
||||
type = "https://tools.ietf.org/html/rfc9110#section-15.5.4",
|
||||
title = "General.Failure",
|
||||
status = 403,
|
||||
detail = "NotAuthorized",
|
||||
instance = "/api/v1/libraries/{libraryId}/metadata-providers/reorder",
|
||||
traceId = "00-a712bbf99ca8ab485f86a762ae5ae74d-b3a2eb78813b0a5d-00"
|
||||
}
|
||||
);
|
||||
|
||||
Response(404, "The request failed because the requested media library does not exist.", "application/problem+json",
|
||||
example: new
|
||||
{
|
||||
type = "https://tools.ietf.org/html/rfc9110#section-15.5.5",
|
||||
title = "General.NotFound",
|
||||
status = 404,
|
||||
detail = "LibraryNotFound",
|
||||
instance = "/api/v1/libraries/{libraryId}/metadata-providers/reorder",
|
||||
traceId = "00-57d15dadd702dbd4aeb5dc9b7cee68ee-9330237dbb2ce0e5-00"
|
||||
}
|
||||
);
|
||||
|
||||
Response(422, "The request did not pass validation checks.", "application/problem+json",
|
||||
example: new
|
||||
{
|
||||
type = "https://tools.ietf.org/html/rfc4918#section-11.2",
|
||||
title = "General.Validation",
|
||||
status = 422,
|
||||
detail = "OneOrMoreValidationErrorsOccurred",
|
||||
instance = "/api/v1/libraries/{libraryId}/metadata-providers/reorder",
|
||||
errors = new Dictionary<string, string[]>
|
||||
{
|
||||
{
|
||||
"General.Validation", new[]
|
||||
{
|
||||
"LibraryIdCannotBeEmpty",
|
||||
"PluginIdsListCannotBeNull",
|
||||
"PluginIdsListCannotBeEmpty"
|
||||
}
|
||||
}
|
||||
},
|
||||
traceId = "00-2470be4248a2a5a0c6f70579975a6954-b9c3ba9544a03500-00"
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
-53
@@ -1,53 +0,0 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.CQRS;
|
||||
using Lumina.Application.Common.Mapping.Plugins;
|
||||
using Lumina.Application.Core.Plugins.Commands.SetLibraryArtworkProviderEnabled;
|
||||
using Lumina.Contracts.Requests.Plugins;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Presentation.Api.Common.Routes.Library.Management;
|
||||
using Lumina.Presentation.Api.Core.Endpoints.Common;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Api.Core.Endpoints.Plugins.SetLibraryArtworkProviderEnabled;
|
||||
|
||||
/// <summary>
|
||||
/// API endpoint for the <c>/libraries/{libraryId}/artwork-providers/{pluginId}/enabled</c> route.
|
||||
/// </summary>
|
||||
public class SetLibraryArtworkProviderEnabledEndpoint : BaseEndpoint<SetLibraryArtworkProviderEnabledRequest, IResult>
|
||||
{
|
||||
private readonly ICommandHandler<SetLibraryArtworkProviderEnabledCommand, Result<Success>> _setLibraryArtworkProviderEnabledCommandHandler;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="SetLibraryArtworkProviderEnabledEndpoint"/> class.
|
||||
/// </summary>
|
||||
/// <param name="setLibraryArtworkProviderEnabledCommandHandler">Injected service for handling set library artwork provider enabled commands.</param>
|
||||
public SetLibraryArtworkProviderEnabledEndpoint(ICommandHandler<SetLibraryArtworkProviderEnabledCommand, Result<Success>> setLibraryArtworkProviderEnabledCommandHandler)
|
||||
{
|
||||
_setLibraryArtworkProviderEnabledCommandHandler = setLibraryArtworkProviderEnabledCommandHandler;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Configures the API endpoint.
|
||||
/// </summary>
|
||||
public override void Configure()
|
||||
{
|
||||
Verbs(FastEndpoints.Http.PUT);
|
||||
Routes(ApiRoutes.Libraries.SET_LIBRARY_ARTWORK_PROVIDER_ENABLED);
|
||||
Version(1);
|
||||
DontCatchExceptions();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enables or disables the artwork provider identified by <paramref name="request"/> for the media library.
|
||||
/// </summary>
|
||||
/// <param name="request">The request containing the Ids of the media library and of the artwork provider.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
public override async Task<IResult> ExecuteAsync(SetLibraryArtworkProviderEnabledRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
Result<Success> result = await _setLibraryArtworkProviderEnabledCommandHandler.HandleAsync(request.ToCommand(), cancellationToken).ConfigureAwait(false);
|
||||
return result.Match(success => TypedResults.Ok(success), Problem);
|
||||
}
|
||||
}
|
||||
-113
@@ -1,113 +0,0 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Contracts.Requests.Plugins;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Api.Core.Endpoints.Plugins.SetLibraryArtworkProviderEnabled;
|
||||
|
||||
/// <summary>
|
||||
/// Class used for providing a textual description for the <see cref="SetLibraryArtworkProviderEnabledEndpoint"/> API endpoint, for OpenAPI.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class SetLibraryArtworkProviderEnabledEndpointSummary : Summary<SetLibraryArtworkProviderEnabledEndpoint, SetLibraryArtworkProviderEnabledRequest>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="SetLibraryArtworkProviderEnabledEndpointSummary"/> class.
|
||||
/// </summary>
|
||||
public SetLibraryArtworkProviderEnabledEndpointSummary()
|
||||
{
|
||||
Summary = "Enables or disables an artwork provider for a media library.";
|
||||
Description = "Enables or disables the artwork provider for the media library, so that it is included or excluded from the artwork enrichment of the library scans.";
|
||||
|
||||
ExampleRequest = new SetLibraryArtworkProviderEnabledRequest(
|
||||
LibraryId: Guid.NewGuid(),
|
||||
PluginId: Guid.NewGuid(),
|
||||
IsEnabled: true
|
||||
);
|
||||
|
||||
RequestParam(r => r.LibraryId, "The Id of the media library whose artwork provider is enabled or disabled. Required.");
|
||||
RequestParam(r => r.PluginId, "The unique identifier of the plugin providing the artwork. Required.");
|
||||
RequestParam(r => r.IsEnabled, "Whether the artwork provider should be enabled for the media library. Required.");
|
||||
|
||||
Response(200, "The artwork provider was successfully enabled or disabled for the media library.");
|
||||
|
||||
Response(401, "Authentication required.", "application/problem+json",
|
||||
example: new[]
|
||||
{
|
||||
new
|
||||
{
|
||||
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
|
||||
status = 401,
|
||||
title = "Unauthorized",
|
||||
detail = "Authentication failed",
|
||||
instance = "/api/v1/libraries/{libraryId}/artwork-providers/{pluginId}/enabled"
|
||||
},
|
||||
new
|
||||
{
|
||||
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
|
||||
status = 401,
|
||||
title = "Unauthorized",
|
||||
detail = "The token has expired",
|
||||
instance = "/api/v1/libraries/{libraryId}/artwork-providers/{pluginId}/enabled"
|
||||
},
|
||||
new
|
||||
{
|
||||
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
|
||||
status = 401,
|
||||
title = "Unauthorized",
|
||||
detail = "The token is invalid",
|
||||
instance = "/api/v1/libraries/{libraryId}/artwork-providers/{pluginId}/enabled"
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
Response(403, "The request failed because the user making the request is not an Admin, or the owner of the media library.", "application/problem+json",
|
||||
example: new
|
||||
{
|
||||
type = "https://tools.ietf.org/html/rfc9110#section-15.5.4",
|
||||
title = "General.Failure",
|
||||
status = 403,
|
||||
detail = "NotAuthorized",
|
||||
instance = "/api/v1/libraries/{libraryId}/artwork-providers/{pluginId}/enabled",
|
||||
traceId = "00-a712bbf99ca8ab485f86a762ae5ae74d-b3a2eb78813b0a5d-00"
|
||||
}
|
||||
);
|
||||
|
||||
Response(404, "The request failed because the requested media library does not exist.", "application/problem+json",
|
||||
example: new
|
||||
{
|
||||
type = "https://tools.ietf.org/html/rfc9110#section-15.5.5",
|
||||
title = "General.NotFound",
|
||||
status = 404,
|
||||
detail = "LibraryNotFound",
|
||||
instance = "/api/v1/libraries/{libraryId}/artwork-providers/{pluginId}/enabled",
|
||||
traceId = "00-57d15dadd702dbd4aeb5dc9b7cee68ee-9330237dbb2ce0e5-00"
|
||||
}
|
||||
);
|
||||
|
||||
Response(422, "The request did not pass validation checks.", "application/problem+json",
|
||||
example: new
|
||||
{
|
||||
type = "https://tools.ietf.org/html/rfc4918#section-11.2",
|
||||
title = "General.Validation",
|
||||
status = 422,
|
||||
detail = "OneOrMoreValidationErrorsOccurred",
|
||||
instance = "/api/v1/libraries/{libraryId}/artwork-providers/{pluginId}/enabled",
|
||||
errors = new Dictionary<string, string[]>
|
||||
{
|
||||
{
|
||||
"General.Validation", new[]
|
||||
{
|
||||
"LibraryIdCannotBeEmpty",
|
||||
"PluginIdCannotBeEmpty"
|
||||
}
|
||||
}
|
||||
},
|
||||
traceId = "00-2470be4248a2a5a0c6f70579975a6954-b9c3ba9544a03500-00"
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
-53
@@ -1,53 +0,0 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.CQRS;
|
||||
using Lumina.Application.Common.Mapping.Plugins;
|
||||
using Lumina.Application.Core.Plugins.Commands.SetLibraryBookReaderEnabled;
|
||||
using Lumina.Contracts.Requests.Plugins;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Presentation.Api.Common.Routes.Library.Management;
|
||||
using Lumina.Presentation.Api.Core.Endpoints.Common;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Api.Core.Endpoints.Plugins.SetLibraryBookReaderEnabled;
|
||||
|
||||
/// <summary>
|
||||
/// API endpoint for the <c>/libraries/{libraryId}/book-readers/{pluginId}/enabled</c> route.
|
||||
/// </summary>
|
||||
public class SetLibraryBookReaderEnabledEndpoint : BaseEndpoint<SetLibraryBookReaderEnabledRequest, IResult>
|
||||
{
|
||||
private readonly ICommandHandler<SetLibraryBookReaderEnabledCommand, Result<Success>> _setLibraryBookReaderEnabledCommandHandler;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="SetLibraryBookReaderEnabledEndpoint"/> class.
|
||||
/// </summary>
|
||||
/// <param name="setLibraryBookReaderEnabledCommandHandler">Injected service for handling set library book reader enabled commands.</param>
|
||||
public SetLibraryBookReaderEnabledEndpoint(ICommandHandler<SetLibraryBookReaderEnabledCommand, Result<Success>> setLibraryBookReaderEnabledCommandHandler)
|
||||
{
|
||||
_setLibraryBookReaderEnabledCommandHandler = setLibraryBookReaderEnabledCommandHandler;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Configures the API endpoint.
|
||||
/// </summary>
|
||||
public override void Configure()
|
||||
{
|
||||
Verbs(FastEndpoints.Http.PUT);
|
||||
Routes(ApiRoutes.Libraries.SET_LIBRARY_BOOK_READER_ENABLED);
|
||||
Version(1);
|
||||
DontCatchExceptions();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enables or disables the book reader identified by <paramref name="request"/> for the media library.
|
||||
/// </summary>
|
||||
/// <param name="request">The request containing the Ids of the media library and of the book reader.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
public override async Task<IResult> ExecuteAsync(SetLibraryBookReaderEnabledRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
Result<Success> result = await _setLibraryBookReaderEnabledCommandHandler.HandleAsync(request.ToCommand(), cancellationToken).ConfigureAwait(false);
|
||||
return result.Match(success => TypedResults.Ok(success), Problem);
|
||||
}
|
||||
}
|
||||
-118
@@ -1,118 +0,0 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Contracts.Requests.Plugins;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Api.Core.Endpoints.Plugins.SetLibraryBookReaderEnabled;
|
||||
|
||||
/// <summary>
|
||||
/// Class used for providing a textual description for the <see cref="SetLibraryBookReaderEnabledEndpoint"/> API endpoint, for OpenAPI.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class SetLibraryBookReaderEnabledEndpointSummary : Summary<SetLibraryBookReaderEnabledEndpoint, SetLibraryBookReaderEnabledRequest>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="SetLibraryBookReaderEnabledEndpointSummary"/> class.
|
||||
/// </summary>
|
||||
public SetLibraryBookReaderEnabledEndpointSummary()
|
||||
{
|
||||
Summary = "Enables or disables a book reader for a media library.";
|
||||
Description = "Enables or disables the book reader of the media library identified by the request.";
|
||||
|
||||
ExampleRequest = new SetLibraryBookReaderEnabledRequest(
|
||||
LibraryId: Guid.NewGuid(),
|
||||
PluginId: Guid.NewGuid(),
|
||||
IsEnabled: true
|
||||
);
|
||||
|
||||
RequestParam(r => r.LibraryId, "The Id of the media library whose book reader is enabled or disabled. Required.");
|
||||
RequestParam(r => r.PluginId, "The unique identifier of the plugin providing the book reader. Required.");
|
||||
RequestParam(r => r.IsEnabled, "Whether the book reader should be enabled for the media library. Required.");
|
||||
|
||||
Response(200, "The book reader of the media library is enabled or disabled.",
|
||||
example: new
|
||||
{
|
||||
success = true
|
||||
}
|
||||
);
|
||||
|
||||
Response(401, "Authentication required.", "application/problem+json",
|
||||
example: new[]
|
||||
{
|
||||
new
|
||||
{
|
||||
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
|
||||
status = 401,
|
||||
title = "Unauthorized",
|
||||
detail = "Authentication failed",
|
||||
instance = "/api/v1/libraries/{libraryId}/book-readers/{pluginId}/enabled"
|
||||
},
|
||||
new
|
||||
{
|
||||
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
|
||||
status = 401,
|
||||
title = "Unauthorized",
|
||||
detail = "The token has expired",
|
||||
instance = "/api/v1/libraries/{libraryId}/book-readers/{pluginId}/enabled"
|
||||
},
|
||||
new
|
||||
{
|
||||
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
|
||||
status = 401,
|
||||
title = "Unauthorized",
|
||||
detail = "The token is invalid",
|
||||
instance = "/api/v1/libraries/{libraryId}/book-readers/{pluginId}/enabled"
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
Response(403, "The request failed because the user making the request is not an Admin, or the owner of the media library.", "application/problem+json",
|
||||
example: new
|
||||
{
|
||||
type = "https://tools.ietf.org/html/rfc9110#section-15.5.4",
|
||||
title = "General.Failure",
|
||||
status = 403,
|
||||
detail = "NotAuthorized",
|
||||
instance = "/api/v1/libraries/{libraryId}/book-readers/{pluginId}/enabled",
|
||||
traceId = "00-a712bbf99ca8ab485f86a762ae5ae74d-b3a2eb78813b0a5d-00"
|
||||
}
|
||||
);
|
||||
|
||||
Response(404, "The request failed because the requested media library does not exist.", "application/problem+json",
|
||||
example: new
|
||||
{
|
||||
type = "https://tools.ietf.org/html/rfc9110#section-15.5.5",
|
||||
title = "General.NotFound",
|
||||
status = 404,
|
||||
detail = "LibraryNotFound",
|
||||
instance = "/api/v1/libraries/{libraryId}/book-readers/{pluginId}/enabled",
|
||||
traceId = "00-57d15dadd702dbd4aeb5dc9b7cee68ee-9330237dbb2ce0e5-00"
|
||||
}
|
||||
);
|
||||
|
||||
Response(422, "The request did not pass validation checks.", "application/problem+json",
|
||||
example: new
|
||||
{
|
||||
type = "https://tools.ietf.org/html/rfc4918#section-11.2",
|
||||
title = "General.Validation",
|
||||
status = 422,
|
||||
detail = "OneOrMoreValidationErrorsOccurred",
|
||||
instance = "/api/v1/libraries/{libraryId}/book-readers/{pluginId}/enabled",
|
||||
errors = new Dictionary<string, string[]>
|
||||
{
|
||||
{
|
||||
"General.Validation", new[]
|
||||
{
|
||||
"LibraryIdCannotBeEmpty",
|
||||
"PluginIdCannotBeEmpty"
|
||||
}
|
||||
}
|
||||
},
|
||||
traceId = "00-2470be4248a2a5a0c6f70579975a6954-b9c3ba9544a03500-00"
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
-53
@@ -1,53 +0,0 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.CQRS;
|
||||
using Lumina.Application.Common.Mapping.Plugins;
|
||||
using Lumina.Application.Core.Plugins.Commands.SetLibraryMetadataProviderEnabled;
|
||||
using Lumina.Contracts.Requests.Plugins;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Presentation.Api.Common.Routes.Library.Management;
|
||||
using Lumina.Presentation.Api.Core.Endpoints.Common;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Api.Core.Endpoints.Plugins.SetLibraryMetadataProviderEnabled;
|
||||
|
||||
/// <summary>
|
||||
/// API endpoint for the <c>/libraries/{libraryId}/metadata-providers/{pluginId}/enabled</c> route.
|
||||
/// </summary>
|
||||
public class SetLibraryMetadataProviderEnabledEndpoint : BaseEndpoint<SetLibraryMetadataProviderEnabledRequest, IResult>
|
||||
{
|
||||
private readonly ICommandHandler<SetLibraryMetadataProviderEnabledCommand, Result<Success>> _setLibraryMetadataProviderEnabledCommandHandler;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="SetLibraryMetadataProviderEnabledEndpoint"/> class.
|
||||
/// </summary>
|
||||
/// <param name="setLibraryMetadataProviderEnabledCommandHandler">Injected service for handling set library metadata provider enabled commands.</param>
|
||||
public SetLibraryMetadataProviderEnabledEndpoint(ICommandHandler<SetLibraryMetadataProviderEnabledCommand, Result<Success>> setLibraryMetadataProviderEnabledCommandHandler)
|
||||
{
|
||||
_setLibraryMetadataProviderEnabledCommandHandler = setLibraryMetadataProviderEnabledCommandHandler;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Configures the API endpoint.
|
||||
/// </summary>
|
||||
public override void Configure()
|
||||
{
|
||||
Verbs(FastEndpoints.Http.PUT);
|
||||
Routes(ApiRoutes.Libraries.SET_LIBRARY_METADATA_PROVIDER_ENABLED);
|
||||
Version(1);
|
||||
DontCatchExceptions();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enables or disables the metadata provider identified by <paramref name="request"/> for the media library.
|
||||
/// </summary>
|
||||
/// <param name="request">The request containing the Ids of the media library and of the metadata provider.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
public override async Task<IResult> ExecuteAsync(SetLibraryMetadataProviderEnabledRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
Result<Success> result = await _setLibraryMetadataProviderEnabledCommandHandler.HandleAsync(request.ToCommand(), cancellationToken).ConfigureAwait(false);
|
||||
return result.Match(success => TypedResults.Ok(success), Problem);
|
||||
}
|
||||
}
|
||||
-113
@@ -1,113 +0,0 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Contracts.Requests.Plugins;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Api.Core.Endpoints.Plugins.SetLibraryMetadataProviderEnabled;
|
||||
|
||||
/// <summary>
|
||||
/// Class used for providing a textual description for the <see cref="SetLibraryMetadataProviderEnabledEndpoint"/> API endpoint, for OpenAPI.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class SetLibraryMetadataProviderEnabledEndpointSummary : Summary<SetLibraryMetadataProviderEnabledEndpoint, SetLibraryMetadataProviderEnabledRequest>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="SetLibraryMetadataProviderEnabledEndpointSummary"/> class.
|
||||
/// </summary>
|
||||
public SetLibraryMetadataProviderEnabledEndpointSummary()
|
||||
{
|
||||
Summary = "Enables or disables a metadata provider for a media library.";
|
||||
Description = "Enables or disables the metadata provider for the media library, so that it is included or excluded from the metadata enrichment of the library scans.";
|
||||
|
||||
ExampleRequest = new SetLibraryMetadataProviderEnabledRequest(
|
||||
LibraryId: Guid.NewGuid(),
|
||||
PluginId: Guid.NewGuid(),
|
||||
IsEnabled: true
|
||||
);
|
||||
|
||||
RequestParam(r => r.LibraryId, "The Id of the media library whose metadata provider is enabled or disabled. Required.");
|
||||
RequestParam(r => r.PluginId, "The unique identifier of the plugin providing the metadata. Required.");
|
||||
RequestParam(r => r.IsEnabled, "Whether the metadata provider should be enabled for the media library. Required.");
|
||||
|
||||
Response(200, "The metadata provider was successfully enabled or disabled for the media library.");
|
||||
|
||||
Response(401, "Authentication required.", "application/problem+json",
|
||||
example: new[]
|
||||
{
|
||||
new
|
||||
{
|
||||
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
|
||||
status = 401,
|
||||
title = "Unauthorized",
|
||||
detail = "Authentication failed",
|
||||
instance = "/api/v1/libraries/{libraryId}/metadata-providers/{pluginId}/enabled"
|
||||
},
|
||||
new
|
||||
{
|
||||
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
|
||||
status = 401,
|
||||
title = "Unauthorized",
|
||||
detail = "The token has expired",
|
||||
instance = "/api/v1/libraries/{libraryId}/metadata-providers/{pluginId}/enabled"
|
||||
},
|
||||
new
|
||||
{
|
||||
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
|
||||
status = 401,
|
||||
title = "Unauthorized",
|
||||
detail = "The token is invalid",
|
||||
instance = "/api/v1/libraries/{libraryId}/metadata-providers/{pluginId}/enabled"
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
Response(403, "The request failed because the user making the request is not an Admin, or the owner of the media library.", "application/problem+json",
|
||||
example: new
|
||||
{
|
||||
type = "https://tools.ietf.org/html/rfc9110#section-15.5.4",
|
||||
title = "General.Failure",
|
||||
status = 403,
|
||||
detail = "NotAuthorized",
|
||||
instance = "/api/v1/libraries/{libraryId}/metadata-providers/{pluginId}/enabled",
|
||||
traceId = "00-a712bbf99ca8ab485f86a762ae5ae74d-b3a2eb78813b0a5d-00"
|
||||
}
|
||||
);
|
||||
|
||||
Response(404, "The request failed because the requested media library does not exist.", "application/problem+json",
|
||||
example: new
|
||||
{
|
||||
type = "https://tools.ietf.org/html/rfc9110#section-15.5.5",
|
||||
title = "General.NotFound",
|
||||
status = 404,
|
||||
detail = "LibraryNotFound",
|
||||
instance = "/api/v1/libraries/{libraryId}/metadata-providers/{pluginId}/enabled",
|
||||
traceId = "00-57d15dadd702dbd4aeb5dc9b7cee68ee-9330237dbb2ce0e5-00"
|
||||
}
|
||||
);
|
||||
|
||||
Response(422, "The request did not pass validation checks.", "application/problem+json",
|
||||
example: new
|
||||
{
|
||||
type = "https://tools.ietf.org/html/rfc4918#section-11.2",
|
||||
title = "General.Validation",
|
||||
status = 422,
|
||||
detail = "OneOrMoreValidationErrorsOccurred",
|
||||
instance = "/api/v1/libraries/{libraryId}/metadata-providers/{pluginId}/enabled",
|
||||
errors = new Dictionary<string, string[]>
|
||||
{
|
||||
{
|
||||
"General.Validation", new[]
|
||||
{
|
||||
"LibraryIdCannotBeEmpty",
|
||||
"PluginIdCannotBeEmpty"
|
||||
}
|
||||
}
|
||||
},
|
||||
traceId = "00-2470be4248a2a5a0c6f70579975a6954-b9c3ba9544a03500-00"
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user