mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 11:11:10 +00:00
Refactors the artist slice across the stack
This commit is contained in:
1 parent
c112c64c25
commit
aa097ecc98
55 files changed
+3219
-278
No files matched your search
+23
-10
@@ -775,15 +775,27 @@ public class AddArtistEndpointSummary : Summary<AddArtistEndpoint, AddArtistRequ
|
||||
}
|
||||
);
|
||||
|
||||
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
|
||||
Response(403, "The request failed because the user making the request is not an Admin or the owner of the media library, or because the artist would be created without any albums.", "application/problem+json",
|
||||
example: new[]
|
||||
{
|
||||
type = "https://tools.ietf.org/html/rfc9110#section-15.5.4",
|
||||
title = "General.Unauthorized",
|
||||
status = 403,
|
||||
detail = "NotAuthorized",
|
||||
instance = $"/api/v1/libraries/{Guid.NewGuid()}/artists",
|
||||
traceId = "00-a712bbf99ca8ab485f86a762ae5ae74d-b3a2eb78813b0a5d-00"
|
||||
new
|
||||
{
|
||||
type = "https://tools.ietf.org/html/rfc9110#section-15.5.4",
|
||||
title = "General.Unauthorized",
|
||||
status = 403,
|
||||
detail = "NotAuthorized",
|
||||
instance = $"/api/v1/libraries/{Guid.NewGuid()}/artists",
|
||||
traceId = "00-a712bbf99ca8ab485f86a762ae5ae74d-b3a2eb78813b0a5d-00"
|
||||
},
|
||||
new
|
||||
{
|
||||
type = "https://tools.ietf.org/html/rfc9110#section-15.5.4",
|
||||
title = "General.Forbidden",
|
||||
status = 403,
|
||||
detail = "ArtistMustHaveAtLeastOneAlbum",
|
||||
instance = $"/api/v1/libraries/{Guid.NewGuid()}/artists",
|
||||
traceId = "00-a712bbf99ca8ab485f86a762ae5ae74d-b3a2eb78813b0a5d-00"
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
@@ -889,6 +901,8 @@ public class AddArtistEndpointSummary : Summary<AddArtistEndpoint, AddArtistRequ
|
||||
"LanguageNativeNameMustBeMaximum50CharactersLong",
|
||||
"UnknownMusicMediaFormat",
|
||||
"CatalogNumberMustBeMaximum50CharactersLong",
|
||||
"BarcodeValueCannotBeEmpty",
|
||||
"InvalidFormatForBarcode",
|
||||
"RatingsListCannotBeNull",
|
||||
"RatingValueMustBePositive",
|
||||
"RatingValueCannotBeGreaterThanMaxValue",
|
||||
@@ -905,8 +919,7 @@ public class AddArtistEndpointSummary : Summary<AddArtistEndpoint, AddArtistRequ
|
||||
"WorkMustBeMaximum255CharactersLong",
|
||||
"MoodNameCannotBeEmpty",
|
||||
"IsrcValueCannotBeEmpty",
|
||||
"TrackPathMustBeWithinLibraryContentLocations",
|
||||
"ArtistMustHaveAtLeastOneAlbum"
|
||||
"TrackPathMustBeWithinLibraryContentLocations"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@ using System.Threading.Tasks;
|
||||
namespace Lumina.Presentation.Api.Core.Endpoints.Library.AudioLibrary.MusicLibrary.Artists.DeleteArtist;
|
||||
|
||||
/// <summary>
|
||||
/// API endpoint for the <c>/{libraryId}/artists/{artistId}</c> route.
|
||||
/// API endpoint for the <c>/libraries/{libraryId}/artists/{artistId}</c> route.
|
||||
/// </summary>
|
||||
public class DeleteArtistEndpoint : BaseEndpoint<FastEndpoints.EmptyRequest, IResult>
|
||||
{
|
||||
|
||||
+8
-6
@@ -1,9 +1,7 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Application.Common.CQRS;
|
||||
using Lumina.Application.Common.Mapping.MediaLibrary.AudioLibrary.MusicLibrary.Artists;
|
||||
using Lumina.Application.Core.MediaLibrary.AudioLibrary.MusicLibrary.Artists.Queries.GetArtist;
|
||||
using Lumina.Contracts.Requests.MediaLibrary.AudioLibrary.MusicLibrary.Artists;
|
||||
using Lumina.Contracts.Responses.MediaLibrary.AudioLibrary.MusicLibrary.Artists;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Presentation.Api.Common.Routes.Library.AudioLibrary.MusicLibrary;
|
||||
@@ -18,7 +16,7 @@ namespace Lumina.Presentation.Api.Core.Endpoints.Library.AudioLibrary.MusicLibra
|
||||
/// <summary>
|
||||
/// API endpoint for the <c>/artists/{artistId}</c> route.
|
||||
/// </summary>
|
||||
public class GetArtistEndpoint : BaseEndpoint<GetArtistRequest, IResult>
|
||||
public class GetArtistEndpoint : BaseEndpoint<FastEndpoints.EmptyRequest, IResult>
|
||||
{
|
||||
private readonly IQueryHandler<GetArtistQuery, Result<ArtistResponse>> _getArtistQueryHandler;
|
||||
|
||||
@@ -45,11 +43,15 @@ public class GetArtistEndpoint : BaseEndpoint<GetArtistRequest, IResult>
|
||||
/// <summary>
|
||||
/// Gets an artist by Id.
|
||||
/// </summary>
|
||||
/// <param name="request">The request containing the id of the artist to be retrieved.</param>
|
||||
/// <param name="request">The request object.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
public override async Task<IResult> ExecuteAsync(GetArtistRequest request, CancellationToken cancellationToken)
|
||||
public override async Task<IResult> ExecuteAsync(FastEndpoints.EmptyRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
Result<ArtistResponse> result = await _getArtistQueryHandler.HandleAsync(request.ToQuery(), cancellationToken).ConfigureAwait(false);
|
||||
// Take unique identifiers from the route.
|
||||
string? libraryId = HttpContext.Request.RouteValues["libraryId"]?.ToString();
|
||||
string? artistId = HttpContext.Request.RouteValues["artistId"]?.ToString();
|
||||
GetArtistQuery query = new(libraryId, artistId);
|
||||
Result<ArtistResponse> result = await _getArtistQueryHandler.HandleAsync(query, cancellationToken).ConfigureAwait(false);
|
||||
return result.Match(success => TypedResults.Ok(success), Problem);
|
||||
}
|
||||
}
|
||||
+8
-15
@@ -1,6 +1,5 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Contracts.Requests.MediaLibrary.AudioLibrary.MusicLibrary.Artists;
|
||||
using Lumina.Contracts.Responses.MediaLibrary.AudioLibrary.MusicLibrary.Artists;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaContributors;
|
||||
using System;
|
||||
@@ -14,7 +13,7 @@ namespace Lumina.Presentation.Api.Core.Endpoints.Library.AudioLibrary.MusicLibra
|
||||
/// Class used for providing a textual description for the <see cref="GetArtistEndpoint"/> API endpoint, for OpenAPI.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GetArtistEndpointSummary : Summary<GetArtistEndpoint, GetArtistRequest>
|
||||
public class GetArtistEndpointSummary : Summary<GetArtistEndpoint, EmptyRequest>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GetArtistEndpointSummary"/> class.
|
||||
@@ -22,13 +21,7 @@ public class GetArtistEndpointSummary : Summary<GetArtistEndpoint, GetArtistRequ
|
||||
public GetArtistEndpointSummary()
|
||||
{
|
||||
Summary = "Gets an artist by its Id.";
|
||||
Description = "Returns the full details of the artist identified by the request. The artist is returned to an Admin, who can see the artists of all libraries, or to the owner of the library of the artist.";
|
||||
|
||||
ExampleRequest = new GetArtistRequest(
|
||||
ArtistId: Guid.NewGuid()
|
||||
);
|
||||
|
||||
RequestParam(r => r.ArtistId, "The Id of the artist to get. Required.");
|
||||
Description = "Returns the full details of the artist identified by the route. The artist is returned to an Admin, who can see the artists of all libraries, or to the owner of the library of the artist.";
|
||||
|
||||
ResponseParam<ArtistResponse>(r => r.Id, "The Id of the artist.");
|
||||
ResponseParam<ArtistResponse>(r => r.LibraryId, "The Id of the media library this artist belongs to.");
|
||||
@@ -67,7 +60,7 @@ public class GetArtistEndpointSummary : Summary<GetArtistEndpoint, GetArtistRequ
|
||||
status = 401,
|
||||
title = "Unauthorized",
|
||||
detail = "You are not authorized",
|
||||
instance = "/api/v1/libraries/{libraryId}/artists/{artistId}"
|
||||
instance = $"/api/v1/libraries/{Guid.NewGuid()}/artists/{Guid.NewGuid()}"
|
||||
},
|
||||
new
|
||||
{
|
||||
@@ -75,7 +68,7 @@ public class GetArtistEndpointSummary : Summary<GetArtistEndpoint, GetArtistRequ
|
||||
status = 401,
|
||||
title = "Unauthorized",
|
||||
detail = "Invalid token: The token expired at '01/01/2024 01:00:00'",
|
||||
instance = "/api/v1/libraries/{libraryId}/artists/{artistId}"
|
||||
instance = $"/api/v1/libraries/{Guid.NewGuid()}/artists/{Guid.NewGuid()}"
|
||||
},
|
||||
new
|
||||
{
|
||||
@@ -83,7 +76,7 @@ public class GetArtistEndpointSummary : Summary<GetArtistEndpoint, GetArtistRequ
|
||||
status = 401,
|
||||
title = "Unauthorized",
|
||||
detail = "The token is invalid",
|
||||
instance = "/api/v1/libraries/{libraryId}/artists/{artistId}"
|
||||
instance = $"/api/v1/libraries/{Guid.NewGuid()}/artists/{Guid.NewGuid()}"
|
||||
}
|
||||
}
|
||||
);
|
||||
@@ -95,7 +88,7 @@ public class GetArtistEndpointSummary : Summary<GetArtistEndpoint, GetArtistRequ
|
||||
title = "General.Unauthorized",
|
||||
status = 403,
|
||||
detail = "NotAuthorized",
|
||||
instance = "/api/v1/libraries/{libraryId}/artists/{artistId}",
|
||||
instance = $"/api/v1/libraries/{Guid.NewGuid()}/artists/{Guid.NewGuid()}",
|
||||
traceId = "00-a712bbf99ca8ab485f86a762ae5ae74d-b3a2eb78813b0a5d-00"
|
||||
}
|
||||
);
|
||||
@@ -107,7 +100,7 @@ public class GetArtistEndpointSummary : Summary<GetArtistEndpoint, GetArtistRequ
|
||||
title = "General.NotFound",
|
||||
status = 404,
|
||||
detail = "ArtistNotFound",
|
||||
instance = "/api/v1/libraries/{libraryId}/artists/{artistId}",
|
||||
instance = $"/api/v1/libraries/{Guid.NewGuid()}/artists/{Guid.NewGuid()}",
|
||||
traceId = "00-57d15dadd702dbd4aeb5dc9b7cee68ee-9330237dbb2ce0e5-00"
|
||||
}
|
||||
);
|
||||
@@ -119,7 +112,7 @@ public class GetArtistEndpointSummary : Summary<GetArtistEndpoint, GetArtistRequ
|
||||
title = "General.Validation",
|
||||
status = 422,
|
||||
detail = "OneOrMoreValidationErrorsOccurred",
|
||||
instance = "/api/v1/libraries/{libraryId}/artists/{artistId}",
|
||||
instance = $"/api/v1/libraries/{Guid.NewGuid()}/artists/{Guid.NewGuid()}",
|
||||
errors = new Dictionary<string, string[]>
|
||||
{
|
||||
{
|
||||
|
||||
+9
-7
@@ -1,9 +1,7 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Application.Common.CQRS;
|
||||
using Lumina.Application.Common.Mapping.MediaLibrary.AudioLibrary.MusicLibrary.Artists;
|
||||
using Lumina.Application.Core.MediaLibrary.AudioLibrary.MusicLibrary.Artists.Queries.GetArtistAlbums;
|
||||
using Lumina.Contracts.Requests.MediaLibrary.AudioLibrary.MusicLibrary.Artists;
|
||||
using Lumina.Contracts.Responses.MediaLibrary.AudioLibrary.MusicLibrary.Albums;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Presentation.Api.Common.Routes.Library.AudioLibrary.MusicLibrary;
|
||||
@@ -19,7 +17,7 @@ namespace Lumina.Presentation.Api.Core.Endpoints.Library.AudioLibrary.MusicLibra
|
||||
/// <summary>
|
||||
/// API endpoint for the <c>/artists/{artistId}/albums</c> route.
|
||||
/// </summary>
|
||||
public class GetArtistAlbumsEndpoint : BaseEndpoint<GetArtistAlbumsRequest, IResult>
|
||||
public class GetArtistAlbumsEndpoint : BaseEndpoint<FastEndpoints.EmptyRequest, IResult>
|
||||
{
|
||||
private readonly IQueryHandler<GetArtistAlbumsQuery, Result<IReadOnlyList<AlbumResponse>>> _getArtistAlbumsQueryHandler;
|
||||
|
||||
@@ -44,13 +42,17 @@ public class GetArtistAlbumsEndpoint : BaseEndpoint<GetArtistAlbumsRequest, IRes
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the list of all the albums of the artist identified by <paramref name="request"/>.
|
||||
/// Gets the list of all the albums of the artist identified by the route.
|
||||
/// </summary>
|
||||
/// <param name="request">The request containing the id of the artist whose albums are retrieved.</param>
|
||||
/// <param name="request">The request object.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
public override async Task<IResult> ExecuteAsync(GetArtistAlbumsRequest request, CancellationToken cancellationToken)
|
||||
public override async Task<IResult> ExecuteAsync(FastEndpoints.EmptyRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
Result<IReadOnlyList<AlbumResponse>> result = await _getArtistAlbumsQueryHandler.HandleAsync(request.ToQuery(), cancellationToken).ConfigureAwait(false);
|
||||
// Take unique identifiers from the route.
|
||||
string? libraryId = HttpContext.Request.RouteValues["libraryId"]?.ToString();
|
||||
string? artistId = HttpContext.Request.RouteValues["artistId"]?.ToString();
|
||||
GetArtistAlbumsQuery query = new(libraryId, artistId);
|
||||
Result<IReadOnlyList<AlbumResponse>> result = await _getArtistAlbumsQueryHandler.HandleAsync(query, cancellationToken).ConfigureAwait(false);
|
||||
return result.Match(success => TypedResults.Ok(success), Problem);
|
||||
}
|
||||
}
|
||||
+8
-15
@@ -4,7 +4,6 @@ using Lumina.Contracts.DTO.Common;
|
||||
using Lumina.Contracts.DTO.MediaContributors;
|
||||
using Lumina.Contracts.DTO.MediaLibrary.AudioLibrary;
|
||||
using Lumina.Contracts.DTO.MediaLibrary.AudioLibrary.MusicLibrary;
|
||||
using Lumina.Contracts.Requests.MediaLibrary.AudioLibrary.MusicLibrary.Artists;
|
||||
using Lumina.Contracts.Responses.MediaLibrary.AudioLibrary.MusicLibrary.Albums;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.AudioLibrary;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.Common;
|
||||
@@ -20,7 +19,7 @@ namespace Lumina.Presentation.Api.Core.Endpoints.Library.AudioLibrary.MusicLibra
|
||||
/// Class used for providing a textual description for the <see cref="GetArtistAlbumsEndpoint"/> API endpoint, for OpenAPI.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GetArtistAlbumsEndpointSummary : Summary<GetArtistAlbumsEndpoint, GetArtistAlbumsRequest>
|
||||
public class GetArtistAlbumsEndpointSummary : Summary<GetArtistAlbumsEndpoint, EmptyRequest>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GetArtistAlbumsEndpointSummary"/> class.
|
||||
@@ -28,13 +27,7 @@ public class GetArtistAlbumsEndpointSummary : Summary<GetArtistAlbumsEndpoint, G
|
||||
public GetArtistAlbumsEndpointSummary()
|
||||
{
|
||||
Summary = "Retrieves the list of albums of an artist.";
|
||||
Description = "Returns the full details of the albums of the artist identified by the request, with the full details of each album. The list is returned to an Admin, who can see the albums of the artists of all libraries, or to the owner of the library of the artist.";
|
||||
|
||||
ExampleRequest = new GetArtistAlbumsRequest(
|
||||
ArtistId: Guid.NewGuid()
|
||||
);
|
||||
|
||||
RequestParam(r => r.ArtistId, "The Id of the artist whose albums are retrieved, taken from the route. Required.");
|
||||
Description = "Returns the full details of the albums of the artist identified by the route, with the full details of each album. The list is returned to an Admin, who can see the albums of the artists of all libraries, or to the owner of the library of the artist.";
|
||||
|
||||
ResponseParam<AlbumResponse>(r => r.Id, "The Id of the album.");
|
||||
ResponseParam<AlbumResponse>(r => r.ArtistId, "The Id of the artist the album belongs to.");
|
||||
@@ -233,7 +226,7 @@ public class GetArtistAlbumsEndpointSummary : Summary<GetArtistAlbumsEndpoint, G
|
||||
status = 401,
|
||||
title = "Unauthorized",
|
||||
detail = "You are not authorized",
|
||||
instance = "/api/v1/libraries/{libraryId}/artists/{artistId}/albums"
|
||||
instance = $"/api/v1/libraries/{Guid.NewGuid()}/artists/{Guid.NewGuid()}/albums"
|
||||
},
|
||||
new
|
||||
{
|
||||
@@ -241,7 +234,7 @@ public class GetArtistAlbumsEndpointSummary : Summary<GetArtistAlbumsEndpoint, G
|
||||
status = 401,
|
||||
title = "Unauthorized",
|
||||
detail = "Invalid token: The token expired at '01/01/2024 01:00:00'",
|
||||
instance = "/api/v1/libraries/{libraryId}/artists/{artistId}/albums"
|
||||
instance = $"/api/v1/libraries/{Guid.NewGuid()}/artists/{Guid.NewGuid()}/albums"
|
||||
},
|
||||
new
|
||||
{
|
||||
@@ -249,7 +242,7 @@ public class GetArtistAlbumsEndpointSummary : Summary<GetArtistAlbumsEndpoint, G
|
||||
status = 401,
|
||||
title = "Unauthorized",
|
||||
detail = "The token is invalid",
|
||||
instance = "/api/v1/libraries/{libraryId}/artists/{artistId}/albums"
|
||||
instance = $"/api/v1/libraries/{Guid.NewGuid()}/artists/{Guid.NewGuid()}/albums"
|
||||
}
|
||||
}
|
||||
);
|
||||
@@ -261,7 +254,7 @@ public class GetArtistAlbumsEndpointSummary : Summary<GetArtistAlbumsEndpoint, G
|
||||
title = "General.Unauthorized",
|
||||
status = 403,
|
||||
detail = "NotAuthorized",
|
||||
instance = "/api/v1/libraries/{libraryId}/artists/{artistId}/albums",
|
||||
instance = $"/api/v1/libraries/{Guid.NewGuid()}/artists/{Guid.NewGuid()}/albums",
|
||||
traceId = "00-a712bbf99ca8ab485f86a762ae5ae74d-b3a2eb78813b0a5d-00"
|
||||
}
|
||||
);
|
||||
@@ -273,7 +266,7 @@ public class GetArtistAlbumsEndpointSummary : Summary<GetArtistAlbumsEndpoint, G
|
||||
title = "General.NotFound",
|
||||
status = 404,
|
||||
detail = "ArtistNotFound",
|
||||
instance = "/api/v1/libraries/{libraryId}/artists/{artistId}/albums",
|
||||
instance = $"/api/v1/libraries/{Guid.NewGuid()}/artists/{Guid.NewGuid()}/albums",
|
||||
traceId = "00-57d15dadd702dbd4aeb5dc9b7cee68ee-9330237dbb2ce0e5-00"
|
||||
}
|
||||
);
|
||||
@@ -285,7 +278,7 @@ public class GetArtistAlbumsEndpointSummary : Summary<GetArtistAlbumsEndpoint, G
|
||||
title = "General.Validation",
|
||||
status = 422,
|
||||
detail = "OneOrMoreValidationErrorsOccurred",
|
||||
instance = "/api/v1/libraries/{libraryId}/artists/{artistId}/albums",
|
||||
instance = $"/api/v1/libraries/{Guid.NewGuid()}/artists/{Guid.NewGuid()}/albums",
|
||||
errors = new Dictionary<string, string[]>
|
||||
{
|
||||
{
|
||||
|
||||
+6
-3
@@ -44,13 +44,16 @@ public class GetArtistAlbumsLiteEndpoint : BaseEndpoint<GetArtistAlbumsLiteReque
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the lightweight read models of all the albums of the artist identified by <paramref name="request"/>.
|
||||
/// Gets the lightweight read models of all the albums of the artist identified by the route.
|
||||
/// </summary>
|
||||
/// <param name="request">The request containing the id of the artist whose albums are retrieved.</param>
|
||||
/// <param name="request">The request containing the pagination options of the albums to be retrieved.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
public override async Task<IResult> ExecuteAsync(GetArtistAlbumsLiteRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
Result<PaginatedResponse<AlbumLiteResponse>> result = await _getArtistAlbumsLiteQueryHandler.HandleAsync(request.ToQuery(), cancellationToken).ConfigureAwait(false);
|
||||
// Take unique identifiers from the route.
|
||||
string? libraryId = HttpContext.Request.RouteValues["libraryId"]?.ToString();
|
||||
string? artistId = HttpContext.Request.RouteValues["artistId"]?.ToString();
|
||||
Result<PaginatedResponse<AlbumLiteResponse>> result = await _getArtistAlbumsLiteQueryHandler.HandleAsync(request.ToQuery(libraryId, artistId), cancellationToken).ConfigureAwait(false);
|
||||
return result.Match(success => TypedResults.Ok(success), Problem);
|
||||
}
|
||||
}
|
||||
+6
-8
@@ -25,12 +25,10 @@ public class GetArtistAlbumsLiteEndpointSummary : Summary<GetArtistAlbumsLiteEnd
|
||||
Description = "Returns the lightweight read models of the albums of the artist identified by its Id, projecting only the fields needed to display the albums in a card-based grid, without loading the full album entities and their related data. The page is returned to an Admin, who can see the albums of the artists of all libraries, or to the owner of the library of the artist.";
|
||||
|
||||
ExampleRequest = new GetArtistAlbumsLiteRequest(
|
||||
ArtistId: Guid.NewGuid(),
|
||||
CurrentPage: 1,
|
||||
PerPage: 48
|
||||
);
|
||||
|
||||
RequestParam(r => r.ArtistId, "The Id of the artist whose albums are retrieved. Required.");
|
||||
RequestParam(r => r.CurrentPage, "The page of results to retrieve. Optional.");
|
||||
RequestParam(r => r.PerPage, "The maximum number of albums to retrieve per page. Optional.");
|
||||
|
||||
@@ -70,7 +68,7 @@ public class GetArtistAlbumsLiteEndpointSummary : Summary<GetArtistAlbumsLiteEnd
|
||||
status = 401,
|
||||
title = "Unauthorized",
|
||||
detail = "You are not authorized",
|
||||
instance = "/api/v1/libraries/{libraryId}/artists/{artistId}/albums/lite"
|
||||
instance = $"/api/v1/libraries/{Guid.NewGuid()}/artists/{Guid.NewGuid()}/albums/lite"
|
||||
},
|
||||
new
|
||||
{
|
||||
@@ -78,7 +76,7 @@ public class GetArtistAlbumsLiteEndpointSummary : Summary<GetArtistAlbumsLiteEnd
|
||||
status = 401,
|
||||
title = "Unauthorized",
|
||||
detail = "Invalid token: The token expired at '01/01/2024 01:00:00'",
|
||||
instance = "/api/v1/libraries/{libraryId}/artists/{artistId}/albums/lite"
|
||||
instance = $"/api/v1/libraries/{Guid.NewGuid()}/artists/{Guid.NewGuid()}/albums/lite"
|
||||
},
|
||||
new
|
||||
{
|
||||
@@ -86,7 +84,7 @@ public class GetArtistAlbumsLiteEndpointSummary : Summary<GetArtistAlbumsLiteEnd
|
||||
status = 401,
|
||||
title = "Unauthorized",
|
||||
detail = "The token is invalid",
|
||||
instance = "/api/v1/libraries/{libraryId}/artists/{artistId}/albums/lite"
|
||||
instance = $"/api/v1/libraries/{Guid.NewGuid()}/artists/{Guid.NewGuid()}/albums/lite"
|
||||
}
|
||||
}
|
||||
);
|
||||
@@ -98,7 +96,7 @@ public class GetArtistAlbumsLiteEndpointSummary : Summary<GetArtistAlbumsLiteEnd
|
||||
title = "General.Unauthorized",
|
||||
status = 403,
|
||||
detail = "NotAuthorized",
|
||||
instance = "/api/v1/libraries/{libraryId}/artists/{artistId}/albums/lite",
|
||||
instance = $"/api/v1/libraries/{Guid.NewGuid()}/artists/{Guid.NewGuid()}/albums/lite",
|
||||
traceId = "00-a712bbf99ca8ab485f86a762ae5ae74d-b3a2eb78813b0a5d-00"
|
||||
}
|
||||
);
|
||||
@@ -110,7 +108,7 @@ public class GetArtistAlbumsLiteEndpointSummary : Summary<GetArtistAlbumsLiteEnd
|
||||
title = "General.NotFound",
|
||||
status = 404,
|
||||
detail = "ArtistNotFound",
|
||||
instance = "/api/v1/libraries/{libraryId}/artists/{artistId}/albums/lite",
|
||||
instance = $"/api/v1/libraries/{Guid.NewGuid()}/artists/{Guid.NewGuid()}/albums/lite",
|
||||
traceId = "00-57d15dadd702dbd4aeb5dc9b7cee68ee-9330237dbb2ce0e5-00"
|
||||
}
|
||||
);
|
||||
@@ -122,7 +120,7 @@ public class GetArtistAlbumsLiteEndpointSummary : Summary<GetArtistAlbumsLiteEnd
|
||||
title = "General.Validation",
|
||||
status = 422,
|
||||
detail = "OneOrMoreValidationErrorsOccurred",
|
||||
instance = "/api/v1/libraries/{libraryId}/artists/{artistId}/albums/lite",
|
||||
instance = $"/api/v1/libraries/{Guid.NewGuid()}/artists/{Guid.NewGuid()}/albums/lite",
|
||||
errors = new Dictionary<string, string[]>
|
||||
{
|
||||
{
|
||||
|
||||
+5
-3
@@ -44,13 +44,15 @@ public class GetArtistsEndpoint : BaseEndpoint<GetArtistsRequest, IResult>
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the list of all the artists of the media library identified by <paramref name="request"/>.
|
||||
/// Gets the list of all the artists of the media library identified by the route.
|
||||
/// </summary>
|
||||
/// <param name="request">The request containing the Id of the media library whose artists are retrieved.</param>
|
||||
/// <param name="request">The request containing the pagination and filtering options of the artists to be retrieved.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
public override async Task<IResult> ExecuteAsync(GetArtistsRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
Result<PaginatedResponse<ArtistResponse>> result = await _getArtistsQueryHandler.HandleAsync(request.ToQuery(), cancellationToken).ConfigureAwait(false);
|
||||
// Take unique identifiers from the route.
|
||||
string? libraryId = HttpContext.Request.RouteValues["libraryId"]?.ToString();
|
||||
Result<PaginatedResponse<ArtistResponse>> result = await _getArtistsQueryHandler.HandleAsync(request.ToQuery(libraryId), cancellationToken).ConfigureAwait(false);
|
||||
return result.Match(success => TypedResults.Ok(success), Problem);
|
||||
}
|
||||
}
|
||||
+5
-7
@@ -25,13 +25,11 @@ public class GetArtistsEndpointSummary : Summary<GetArtistsEndpoint, GetArtistsR
|
||||
Description = "Returns the paginated list of the artists of the media library identified by the request, with the full details of each artist. The page is returned to an Admin, who can see the artists of all libraries, or to the owner of the library.";
|
||||
|
||||
ExampleRequest = new GetArtistsRequest(
|
||||
LibraryId: Guid.NewGuid(),
|
||||
CurrentPage: 1,
|
||||
PerPage: 48,
|
||||
SearchTerm: "queen"
|
||||
);
|
||||
|
||||
RequestParam(r => r.LibraryId, "The Id of the media library whose artists are retrieved. Required.");
|
||||
RequestParam(r => r.CurrentPage, "The page of results to retrieve. Optional.");
|
||||
RequestParam(r => r.PerPage, "The maximum number of artists to retrieve per page. Optional.");
|
||||
RequestParam(r => r.SearchTerm, "The search term used to filter the artists by name. Optional.");
|
||||
@@ -90,7 +88,7 @@ public class GetArtistsEndpointSummary : Summary<GetArtistsEndpoint, GetArtistsR
|
||||
status = 401,
|
||||
title = "Unauthorized",
|
||||
detail = "You are not authorized",
|
||||
instance = "/api/v1/libraries/{libraryId}/artists"
|
||||
instance = $"/api/v1/libraries/{Guid.NewGuid()}/artists"
|
||||
},
|
||||
new
|
||||
{
|
||||
@@ -98,7 +96,7 @@ public class GetArtistsEndpointSummary : Summary<GetArtistsEndpoint, GetArtistsR
|
||||
status = 401,
|
||||
title = "Unauthorized",
|
||||
detail = "Invalid token: The token expired at '01/01/2024 01:00:00'",
|
||||
instance = "/api/v1/libraries/{libraryId}/artists"
|
||||
instance = $"/api/v1/libraries/{Guid.NewGuid()}/artists"
|
||||
},
|
||||
new
|
||||
{
|
||||
@@ -106,7 +104,7 @@ public class GetArtistsEndpointSummary : Summary<GetArtistsEndpoint, GetArtistsR
|
||||
status = 401,
|
||||
title = "Unauthorized",
|
||||
detail = "The token is invalid",
|
||||
instance = "/api/v1/libraries/{libraryId}/artists"
|
||||
instance = $"/api/v1/libraries/{Guid.NewGuid()}/artists"
|
||||
}
|
||||
}
|
||||
);
|
||||
@@ -118,7 +116,7 @@ public class GetArtistsEndpointSummary : Summary<GetArtistsEndpoint, GetArtistsR
|
||||
title = "General.Unauthorized",
|
||||
status = 403,
|
||||
detail = "NotAuthorized",
|
||||
instance = "/api/v1/libraries/{libraryId}/artists",
|
||||
instance = $"/api/v1/libraries/{Guid.NewGuid()}/artists",
|
||||
traceId = "00-a712bbf99ca8ab485f86a762ae5ae74d-b3a2eb78813b0a5d-00"
|
||||
}
|
||||
);
|
||||
@@ -130,7 +128,7 @@ public class GetArtistsEndpointSummary : Summary<GetArtistsEndpoint, GetArtistsR
|
||||
title = "General.Validation",
|
||||
status = 422,
|
||||
detail = "OneOrMoreValidationErrorsOccurred",
|
||||
instance = "/api/v1/libraries/{libraryId}/artists",
|
||||
instance = $"/api/v1/libraries/{Guid.NewGuid()}/artists",
|
||||
errors = new Dictionary<string, string[]>
|
||||
{
|
||||
{
|
||||
|
||||
+5
-3
@@ -44,13 +44,15 @@ public class GetArtistsLiteEndpoint : BaseEndpoint<GetArtistsLiteRequest, IResul
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the lightweight read models of all the artists of the media library identified by <paramref name="request"/>.
|
||||
/// Gets the lightweight read models of all the artists of the media library identified by the route.
|
||||
/// </summary>
|
||||
/// <param name="request">The request containing the Id of the media library whose artists are retrieved.</param>
|
||||
/// <param name="request">The request containing the pagination and filtering options of the artists to be retrieved.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
public override async Task<IResult> ExecuteAsync(GetArtistsLiteRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
Result<PaginatedResponse<ArtistLiteResponse>> result = await _getArtistsLiteQueryHandler.HandleAsync(request.ToQuery(), cancellationToken).ConfigureAwait(false);
|
||||
// Take unique identifiers from the route.
|
||||
string? libraryId = HttpContext.Request.RouteValues["libraryId"]?.ToString();
|
||||
Result<PaginatedResponse<ArtistLiteResponse>> result = await _getArtistsLiteQueryHandler.HandleAsync(request.ToQuery(libraryId), cancellationToken).ConfigureAwait(false);
|
||||
return result.Match(success => TypedResults.Ok(success), Problem);
|
||||
}
|
||||
}
|
||||
+5
-7
@@ -25,13 +25,11 @@ public class GetArtistsLiteEndpointSummary : Summary<GetArtistsLiteEndpoint, Get
|
||||
Description = "Returns the lightweight read models of the artists of a media library, projecting only the fields needed to display the artists in a card-based grid, without loading the full artist entities and their related data. The page is returned to an Admin, who can see the artists of all libraries, or to the owner of the library.";
|
||||
|
||||
ExampleRequest = new GetArtistsLiteRequest(
|
||||
LibraryId: Guid.NewGuid(),
|
||||
CurrentPage: 1,
|
||||
PerPage: 48,
|
||||
SearchTerm: "queen"
|
||||
);
|
||||
|
||||
RequestParam(r => r.LibraryId, "The Id of the media library whose artists are retrieved. Required.");
|
||||
RequestParam(r => r.CurrentPage, "The page of results to retrieve. Optional.");
|
||||
RequestParam(r => r.PerPage, "The maximum number of artists to retrieve per page. Optional.");
|
||||
RequestParam(r => r.SearchTerm, "The search term used to filter the artists by name. Optional.");
|
||||
@@ -69,7 +67,7 @@ public class GetArtistsLiteEndpointSummary : Summary<GetArtistsLiteEndpoint, Get
|
||||
status = 401,
|
||||
title = "Unauthorized",
|
||||
detail = "You are not authorized",
|
||||
instance = "/api/v1/libraries/{libraryId}/artists/lite"
|
||||
instance = $"/api/v1/libraries/{Guid.NewGuid()}/artists/lite"
|
||||
},
|
||||
new
|
||||
{
|
||||
@@ -77,7 +75,7 @@ public class GetArtistsLiteEndpointSummary : Summary<GetArtistsLiteEndpoint, Get
|
||||
status = 401,
|
||||
title = "Unauthorized",
|
||||
detail = "Invalid token: The token expired at '01/01/2024 01:00:00'",
|
||||
instance = "/api/v1/libraries/{libraryId}/artists/lite"
|
||||
instance = $"/api/v1/libraries/{Guid.NewGuid()}/artists/lite"
|
||||
},
|
||||
new
|
||||
{
|
||||
@@ -85,7 +83,7 @@ public class GetArtistsLiteEndpointSummary : Summary<GetArtistsLiteEndpoint, Get
|
||||
status = 401,
|
||||
title = "Unauthorized",
|
||||
detail = "The token is invalid",
|
||||
instance = "/api/v1/libraries/{libraryId}/artists/lite"
|
||||
instance = $"/api/v1/libraries/{Guid.NewGuid()}/artists/lite"
|
||||
}
|
||||
}
|
||||
);
|
||||
@@ -97,7 +95,7 @@ public class GetArtistsLiteEndpointSummary : Summary<GetArtistsLiteEndpoint, Get
|
||||
title = "General.Unauthorized",
|
||||
status = 403,
|
||||
detail = "NotAuthorized",
|
||||
instance = "/api/v1/libraries/{libraryId}/artists/lite",
|
||||
instance = $"/api/v1/libraries/{Guid.NewGuid()}/artists/lite",
|
||||
traceId = "00-a712bbf99ca8ab485f86a762ae5ae74d-b3a2eb78813b0a5d-00"
|
||||
}
|
||||
);
|
||||
@@ -109,7 +107,7 @@ public class GetArtistsLiteEndpointSummary : Summary<GetArtistsLiteEndpoint, Get
|
||||
title = "General.Validation",
|
||||
status = 422,
|
||||
detail = "OneOrMoreValidationErrorsOccurred",
|
||||
instance = "/api/v1/libraries/{libraryId}/artists/lite",
|
||||
instance = $"/api/v1/libraries/{Guid.NewGuid()}/artists/lite",
|
||||
errors = new Dictionary<string, string[]>
|
||||
{
|
||||
{
|
||||
|
||||
+33
-15
@@ -4,9 +4,7 @@ using Lumina.Contracts.DTO.Common;
|
||||
using Lumina.Contracts.DTO.MediaContributors;
|
||||
using Lumina.Contracts.DTO.MediaLibrary.AudioLibrary;
|
||||
using Lumina.Contracts.DTO.MediaLibrary.AudioLibrary.MusicLibrary;
|
||||
using Lumina.Contracts.Requests.MediaLibrary.AudioLibrary.MusicLibrary.Albums;
|
||||
using Lumina.Contracts.Requests.MediaLibrary.AudioLibrary.MusicLibrary.Artists;
|
||||
using Lumina.Contracts.Requests.MediaLibrary.AudioLibrary.MusicLibrary.Tracks;
|
||||
using Lumina.Contracts.Responses.MediaLibrary.AudioLibrary.MusicLibrary.Albums;
|
||||
using Lumina.Contracts.Responses.MediaLibrary.AudioLibrary.MusicLibrary.Tracks;
|
||||
using Lumina.Contracts.Responses.MediaLibrary.AudioLibrary.MusicLibrary.Artists;
|
||||
@@ -39,6 +37,7 @@ public class UpdateArtistEndpointSummary : Summary<UpdateArtistEndpoint, UpdateA
|
||||
RequestParam(r => r.MusicBrainzArtistId, "The MusicBrainz identifier of the artist. Optional.");
|
||||
RequestParam(r => r.Contributors, "The list of media contributors that make up the artist. Required.");
|
||||
RequestParam(r => r.Albums, "The list of albums of the artist, each with its own list of tracks. Required.");
|
||||
RequestParam(r => r.Albums![0].AlbumId, "The Id of the album, when the album already exists. Optional.");
|
||||
RequestParam(r => r.Albums![0].Metadata, "The album metadata of the album. Required.");
|
||||
RequestParam(r => r.Albums![0].Metadata!.Title, "The title of the album. Required.");
|
||||
RequestParam(r => r.Albums![0].Metadata!.OriginalTitle, "The original title of the album, if different from the current title. Optional.");
|
||||
@@ -73,6 +72,7 @@ public class UpdateArtistEndpointSummary : Summary<UpdateArtistEndpoint, UpdateA
|
||||
RequestParam(r => r.Albums![0].Contributors, "The list of media contributors that performed on the album. Required.");
|
||||
RequestParam(r => r.Albums![0].Ratings, "The list of ratings for this album. Required.");
|
||||
RequestParam(r => r.Albums![0].Tracks, "The list of tracks of the album. Required.");
|
||||
RequestParam(r => r.Albums![0].Tracks![0].TrackId, "The Id of the track, when the track already exists. Optional.");
|
||||
RequestParam(r => r.Albums![0].Tracks![0].Path, "The file system path of the track. It must be inside one of the content locations of the media library that owns it. Required.");
|
||||
RequestParam(r => r.Albums![0].Tracks![0].Metadata, "The audio metadata of the track. Required.");
|
||||
RequestParam(r => r.Albums![0].Tracks![0].Metadata!.Title, "The title of the track. Required.");
|
||||
@@ -131,7 +131,8 @@ public class UpdateArtistEndpointSummary : Summary<UpdateArtistEndpoint, UpdateA
|
||||
)
|
||||
],
|
||||
Albums: [
|
||||
new AddAlbumRequest(
|
||||
new UpdateArtistAlbumRequest(
|
||||
AlbumId: Guid.NewGuid(),
|
||||
Metadata: new AlbumMetadataDto(
|
||||
Title: "A Night at the Opera",
|
||||
OriginalTitle: "A Night at the Opera",
|
||||
@@ -199,7 +200,8 @@ public class UpdateArtistEndpointSummary : Summary<UpdateArtistEndpoint, UpdateA
|
||||
)
|
||||
],
|
||||
Tracks: [
|
||||
new AddTrackRequest(
|
||||
new UpdateArtistTrackRequest(
|
||||
TrackId: Guid.NewGuid(),
|
||||
Path: "/music/queen/a-night-at-the-opera/01-bohemian-rhapsody.flac",
|
||||
Metadata: new AudioMetadataDto(
|
||||
Title: "Bohemian Rhapsody",
|
||||
@@ -280,7 +282,8 @@ public class UpdateArtistEndpointSummary : Summary<UpdateArtistEndpoint, UpdateA
|
||||
)
|
||||
]
|
||||
),
|
||||
new AddTrackRequest(
|
||||
new UpdateArtistTrackRequest(
|
||||
TrackId: Guid.NewGuid(),
|
||||
Path: "/music/queen/a-night-at-the-opera/07-youre-my-best-friend.flac",
|
||||
Metadata: new AudioMetadataDto(
|
||||
Title: "You're My Best Friend",
|
||||
@@ -776,15 +779,27 @@ public class UpdateArtistEndpointSummary : Summary<UpdateArtistEndpoint, UpdateA
|
||||
}
|
||||
);
|
||||
|
||||
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
|
||||
Response(403, "The request failed because the user making the request is not an Admin or the owner of the media library, or because the update would leave the artist without any albums.", "application/problem+json",
|
||||
example: new[]
|
||||
{
|
||||
type = "https://tools.ietf.org/html/rfc9110#section-15.5.4",
|
||||
title = "General.Unauthorized",
|
||||
status = 403,
|
||||
detail = "NotAuthorized",
|
||||
instance = $"/api/v1/libraries/{Guid.NewGuid()}/artists/{Guid.NewGuid()}",
|
||||
traceId = "00-a712bbf99ca8ab485f86a762ae5ae74d-b3a2eb78813b0a5d-00"
|
||||
new
|
||||
{
|
||||
type = "https://tools.ietf.org/html/rfc9110#section-15.5.4",
|
||||
title = "General.Unauthorized",
|
||||
status = 403,
|
||||
detail = "NotAuthorized",
|
||||
instance = $"/api/v1/libraries/{Guid.NewGuid()}/artists/{Guid.NewGuid()}",
|
||||
traceId = "00-a712bbf99ca8ab485f86a762ae5ae74d-b3a2eb78813b0a5d-00"
|
||||
},
|
||||
new
|
||||
{
|
||||
type = "https://tools.ietf.org/html/rfc9110#section-15.5.4",
|
||||
title = "General.Forbidden",
|
||||
status = 403,
|
||||
detail = "ArtistMustHaveAtLeastOneAlbum",
|
||||
instance = $"/api/v1/libraries/{Guid.NewGuid()}/artists/{Guid.NewGuid()}",
|
||||
traceId = "00-a712bbf99ca8ab485f86a762ae5ae74d-b3a2eb78813b0a5d-00"
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
@@ -844,6 +859,7 @@ public class UpdateArtistEndpointSummary : Summary<UpdateArtistEndpoint, UpdateA
|
||||
"MediaContributorIdCannotBeEmpty",
|
||||
"UnknownMediaContributorRole",
|
||||
"AlbumsListCannotBeNull",
|
||||
"AlbumIdCannotBeEmpty",
|
||||
"MetadataCannotBeNull",
|
||||
"AlbumTitleCannotBeEmpty",
|
||||
"AlbumTitleMustBeMaximum255CharactersLong",
|
||||
@@ -876,12 +892,15 @@ public class UpdateArtistEndpointSummary : Summary<UpdateArtistEndpoint, UpdateA
|
||||
"LanguageNativeNameMustBeMaximum50CharactersLong",
|
||||
"UnknownMusicMediaFormat",
|
||||
"CatalogNumberMustBeMaximum50CharactersLong",
|
||||
"BarcodeValueCannotBeEmpty",
|
||||
"InvalidFormatForBarcode",
|
||||
"RatingsListCannotBeNull",
|
||||
"RatingValueMustBePositive",
|
||||
"RatingValueCannotBeGreaterThanMaxValue",
|
||||
"RatingMaxValueMustBePositive",
|
||||
"RatingVoteCountMustBePositive",
|
||||
"TracksListCannotBeNull",
|
||||
"TrackIdCannotBeEmpty",
|
||||
"TrackPathCannotBeEmpty",
|
||||
"TrackPathMustBeMaximum2048CharactersLong",
|
||||
"TrackNumberMustBeGreaterThanZero",
|
||||
@@ -891,8 +910,7 @@ public class UpdateArtistEndpointSummary : Summary<UpdateArtistEndpoint, UpdateA
|
||||
"BpmMustBeGreaterThanZero",
|
||||
"WorkMustBeMaximum255CharactersLong",
|
||||
"MoodNameCannotBeEmpty",
|
||||
"IsrcValueCannotBeEmpty",
|
||||
"ArtistMustHaveAtLeastOneAlbum"
|
||||
"IsrcValueCannotBeEmpty"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user