Removes unused file system API endpoints

This commit is contained in:
BinaryAlley committed 2025-01-02 14:56:45 +02:00
1 parent 8c579cd4bd
commit 532322eab2
35 files changed
-3111

No files matched your search

@@ -1,56 +0,0 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
using FastEndpoints;
using Lumina.Application.Common.Mapping.FileSystemManagement.Directories;
using Lumina.Contracts.Requests.FileSystemManagement.Directories;
using Lumina.Contracts.Requests.FileSystemManagement.Path;
using Lumina.Contracts.Responses.FileSystemManagement.Common;
using Lumina.Presentation.Api.Common.Routes.FileSystemManagement;
using Lumina.Presentation.Api.Core.Endpoints.Common;
using Mediator;
using Microsoft.AspNetCore.Http;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
#endregion
namespace Lumina.Presentation.Api.Core.Endpoints.FileSystemManagement.Directories.GetDirectoryTree;
/// <summary>
/// API endpoint for the <c>/directories/get-directory-tree</c> route.
/// </summary>
public class GetDirectoryTreeEndpoint : BaseEndpoint<GetDirectoryTreeRequest, IResult>
{
private readonly ISender _sender;
/// <summary>
/// Initializes a new instance of the <see cref="GetDirectoryTreeEndpoint"/> class.
/// </summary>
/// <param name="sender">Injected service for mediating commands and queries.</param>
public GetDirectoryTreeEndpoint(ISender sender)
{
_sender = sender;
}
/// <summary>
/// Configures the API endpoint.
/// </summary>
public override void Configure()
{
Verbs(Http.GET);
Routes(ApiRoutes.Directories.GET_DIRECTORY_TREE);
Version(1);
DontCatchExceptions();
}
/// <summary>
/// Gets the tree of expanded directories leading up to the path stored in <paramref name="request"/>, with the additional list of drives, and children of the last child directory.
/// </summary>
/// <param name="request">The request containing the file system path for for which to get the directory tree.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
public override async Task<IResult> ExecuteAsync(GetDirectoryTreeRequest request, CancellationToken cancellationToken)
{
ErrorOr<IEnumerable<FileSystemTreeNodeResponse>> result = await _sender.Send(request.ToQuery(), cancellationToken).ConfigureAwait(false);
return result.Match(success => TypedResults.Ok(success), Problem);
}
}
@@ -1,189 +0,0 @@
#region ========================================================================= USING =====================================================================================
using FastEndpoints;
using Lumina.Contracts.Requests.FileSystemManagement.Directories;
using Lumina.Contracts.Responses.FileSystemManagement.Common;
using Lumina.Domain.Common.Enums.FileSystem;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
#endregion
namespace Lumina.Presentation.Api.Core.Endpoints.FileSystemManagement.Directories.GetDirectoryTree;
/// <summary>
/// Class used for providing a textual description for the <see cref="GetDirectoryTreeEndpoint"/> API endpoint, for OpenAPI.
/// </summary>
[ExcludeFromCodeCoverage]
public class GetDirectoryTreeEndpointSummary : Summary<GetDirectoryTreeEndpoint, GetDirectoryTreeRequest>
{
/// <summary>
/// Initializes a new instance of the <see cref="GetDirectoryTreeEndpointSummary"/> class.
/// </summary>
public GetDirectoryTreeEndpointSummary()
{
Summary = "Retrieves the directory tree structure for a specified file system path.";
Description = "Returns a hierarchical view of the directory tree, with options to include files and hidden elements.";
ExampleRequest = new GetDirectoryTreeRequest(
Path: "/media/movies/",
IncludeFiles: true,
IncludeHiddenElements: true
);
RequestExamples.Add(new RequestExample(new GetDirectoryTreeRequest(
Path: "/media/movies/",
IncludeFiles: false,
IncludeHiddenElements: false
)));
RequestExamples.Add(new RequestExample(new GetDirectoryTreeRequest(
Path: "/media/movies/",
IncludeFiles: true,
IncludeHiddenElements: false
)));
RequestExamples.Add(new RequestExample(new GetDirectoryTreeRequest(
Path: "/media/movies/",
IncludeFiles: false,
IncludeHiddenElements: true
)));
RequestParam(r => r.Path, "The file system path for which to get the directory tree. Required.");
RequestParam(r => r.IncludeFiles, "Whether to include files along the directories or not. Optional.");
RequestParam(r => r.IncludeHiddenElements, "Whether to include hidden file system elements or not. Optional.");
Response(200, "The directory tree structure for the specified path.",
example: new FileSystemTreeNodeResponse[] {
new()
{
Path = "/",
Name = "The Lord of the Rings - The Fellowship of the Ring (2001)",
ItemType = FileSystemItemType.Root,
IsExpanded = true,
ChildrenLoaded = true,
Children =
[
new()
{
Path = "/media/",
Name = "media",
ItemType = FileSystemItemType.Directory,
IsExpanded = true,
ChildrenLoaded = true,
Children =
[
new()
{
Path = "/media/movies/",
Name = "movies",
ItemType = FileSystemItemType.Directory,
IsExpanded = true,
ChildrenLoaded = true,
Children =
[
new()
{
Path = "/media/movies/The Lord of the Rings - The Fellowship of the Ring (2001)/",
Name = "The Lord of the Rings - The Fellowship of the Ring (2001)",
ItemType = FileSystemItemType.Directory,
IsExpanded = true,
ChildrenLoaded = true,
Children =
[
new()
{
Path = "/media/movies/The Lord of the Rings - The Fellowship of the Ring (2001)/Extras/",
Name = "Extras",
ItemType = FileSystemItemType.Directory,
IsExpanded = false,
ChildrenLoaded = false,
Children = []
},
new()
{
Path = "/media/movies/The Matrix (1999)/The Matrix.mkv",
Name = "The Matrix.mkv",
ItemType = FileSystemItemType.File,
IsExpanded = false,
ChildrenLoaded = false,
Children = []
},
new()
{
Path = "/media/movies/The Matrix (1999)/The Matrix.en.srt",
Name = "The Matrix.en.srt",
ItemType = FileSystemItemType.File,
IsExpanded = false,
ChildrenLoaded = false,
Children = []
}
]
},
]
},
]
},
]
},
});
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 = "You are not authorized",
instance = "/api/v1/directories/get-directory-tree"
},
new
{
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
status = 401,
title = "Unauthorized",
detail = "Invalid token: The token expired at '01/01/2024 01:00:00'",
instance = "/api/v1/directories/get-directory-tree"
},
new
{
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
status = 401,
title = "Unauthorized",
detail = "The token is invalid",
instance = "/api/v1/directories/get-directory-tree"
}
}
);
Response(403, "The request failed because the provided path does not exist, or the current user doesn't have permission to access it.", "application/problem+json",
example: new
{
type = "https://tools.ietf.org/html/rfc9110#section-15.5.4",
title = "General.Failure",
status = 403,
detail = "UnauthorizedAccess",
instance = "/api/v1/directories/get-directory-tree",
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/directories/get-directory-tree",
errors = new Dictionary<string, string[]>
{
{
"General.Validation", new[]
{
"PathCannotBeEmpty"
}
}
},
traceId = "00-839f81e411d7eb91ed5aa91e56b00bbb-7c8bd5dfabdaf2dc-00"
}
);
}
}
@@ -1,55 +0,0 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
using FastEndpoints;
using Lumina.Application.Common.Mapping.FileSystemManagement.Directories;
using Lumina.Contracts.Requests.FileSystemManagement.Directories;
using Lumina.Contracts.Responses.FileSystemManagement.Common;
using Lumina.Presentation.Api.Common.Routes.FileSystemManagement;
using Lumina.Presentation.Api.Core.Endpoints.Common;
using Mediator;
using Microsoft.AspNetCore.Http;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
#endregion
namespace Lumina.Presentation.Api.Core.Endpoints.FileSystemManagement.Directories.GetTreeDirectories;
/// <summary>
/// API endpoint for the <c>/directories/get-tree-directories</c> route.
/// </summary>
public class GetTreeDirectoriesEndpoint : BaseEndpoint<GetTreeDirectoriesRequest, IResult>
{
private readonly ISender _sender;
/// <summary>
/// Initializes a new instance of the <see cref="GetTreeDirectoriesEndpoint"/> class.
/// </summary>
/// <param name="sender">Injected service for mediating commands and queries.</param>
public GetTreeDirectoriesEndpoint(ISender sender)
{
_sender = sender;
}
/// <summary>
/// Configures the API endpoint.
/// </summary>
public override void Configure()
{
Verbs(Http.GET);
Routes(ApiRoutes.Directories.GET_TREE_DIRECTORIES);
Version(1);
DontCatchExceptions();
}
/// <summary>
/// Gets the directories of the path stored in <paramref name="request"/>.
/// </summary>
/// <param name="request">The request containing the file system path for which to get the directories.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
public override async Task<IResult> ExecuteAsync(GetTreeDirectoriesRequest request, CancellationToken cancellationToken)
{
ErrorOr<IEnumerable<FileSystemTreeNodeResponse>> result = await _sender.Send(request.ToQuery(), cancellationToken).ConfigureAwait(false);
return result.Match(success => TypedResults.Ok(success), Problem);
}
}
@@ -1,107 +0,0 @@
#region ========================================================================= USING =====================================================================================
using FastEndpoints;
using Lumina.Contracts.Requests.FileSystemManagement.Directories;
using Lumina.Contracts.Responses.FileSystemManagement.Common;
using Lumina.Domain.Common.Enums.FileSystem;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
#endregion
namespace Lumina.Presentation.Api.Core.Endpoints.FileSystemManagement.Directories.GetTreeDirectories;
/// <summary>
/// Class used for providing a textual description for the <see cref="GetTreeDirectoriesEndpoint"/> API endpoint, for OpenAPI.
/// </summary>
[ExcludeFromCodeCoverage]
public class GetTreeDirectoriesEndpointSummary : Summary<GetTreeDirectoriesEndpoint, GetTreeDirectoriesRequest>
{
/// <summary>
/// Initializes a new instance of the <see cref="GetTreeDirectoriesEndpointSummary"/> class.
/// </summary>
public GetTreeDirectoriesEndpointSummary()
{
Summary = "Retrieves the directory tree structure for the specified file system path.";
Description = "Returns the directory tree structure, with an option to include hidden file system elements.";
ExampleRequest = new GetTreeDirectoriesRequest(
Path: "/media/movies/",
IncludeHiddenElements: true
);
RequestExamples.Add(new RequestExample(new GetTreeDirectoriesRequest(
Path: "/media/movies/",
IncludeHiddenElements: false
)));
RequestParam(r => r.Path, "The file system path for which to get the directory tree. Required.");
RequestParam(r => r.IncludeHiddenElements, "Whether to include hidden file system elements or not. Optional.");
Response(200, "The directory tree structure is returned.",
example: new FileSystemTreeNodeResponse[] {
new() { Path = "/media/movies/The Matrix (1999)/", Name = "The Matrix (1999)", ItemType = FileSystemItemType.Directory, IsExpanded = false, ChildrenLoaded = false, Children = [] },
new() { Path = "/media/movies/The Lord of the Rings - The Fellowship of the Ring (2001)/", Name = "The Lord of the Rings - The Fellowship of the Ring (2001)", ItemType = FileSystemItemType.Directory, IsExpanded = false, ChildrenLoaded = false, Children = [] },
});
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 = "You are not authorized",
instance = "/api/v1/directories/get-tree-directories"
},
new
{
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
status = 401,
title = "Unauthorized",
detail = "Invalid token: The token expired at '01/01/2024 01:00:00'",
instance = "/api/v1/directories/get-tree-directories"
},
new
{
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
status = 401,
title = "Unauthorized",
detail = "The token is invalid",
instance = "/api/v1/directories/get-tree-directories"
}
}
);
Response(403, "The request failed because the provided path does not exist, or the current user doesn't have permission to access it.", "application/problem+json",
example: new
{
type = "https://tools.ietf.org/html/rfc9110#section-15.5.4",
title = "General.Failure",
status = 403,
detail = "UnauthorizedAccess",
instance = "/api/v1/directories/get-tree-directories",
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/directories/get-tree-directories",
errors = new Dictionary<string, string[]>
{
{
"General.Validation", new[]
{
"PathCannotBeEmpty"
}
}
},
traceId = "00-839f81e411d7eb91ed5aa91e56b00bbb-7c8bd5dfabdaf2dc-00"
}
);
}
}