From 29c7d536e0c321648e697cc6c01bbcad8c20900a Mon Sep 17 00:00:00 2001 From: Binary Alley Date: Thu, 3 Sep 2026 12:49:37 -0700 Subject: [PATCH] Adds the scheduled jobs API endpoints --- .../Routes/Scheduling/ApiRoutes.Scheduling.cs | 18 +++ .../AddScheduledJobEndpoint.cs | 56 ++++++++ .../AddScheduledJobEndpointSummary.cs | 124 ++++++++++++++++++ .../FireScheduledJobEndpoint.cs | 56 ++++++++ .../FireScheduledJobEndpointSummary.cs | 111 ++++++++++++++++ .../GetScheduledJobHistoryEndpoint.cs | 57 ++++++++ .../GetScheduledJobHistoryEndpointSummary.cs | 86 ++++++++++++ .../GetScheduledJobsEndpoint.cs | 55 ++++++++ .../GetScheduledJobsEndpointSummary.cs | 84 ++++++++++++ .../RemoveScheduledJobEndpoint.cs | 55 ++++++++ .../RemoveScheduledJobEndpointSummary.cs | 85 ++++++++++++ .../StartScheduledJobEndpoint.cs | 56 ++++++++ .../StartScheduledJobEndpointSummary.cs | 111 ++++++++++++++++ .../StopScheduledJobEndpoint.cs | 56 ++++++++ .../StopScheduledJobEndpointSummary.cs | 120 +++++++++++++++++ 15 files changed, 1130 insertions(+) create mode 100644 src/Lumina.Presentation.Api/Common/Routes/Scheduling/ApiRoutes.Scheduling.cs create mode 100644 src/Lumina.Presentation.Api/Core/Endpoints/Scheduling/AddScheduledJob/AddScheduledJobEndpoint.cs create mode 100644 src/Lumina.Presentation.Api/Core/Endpoints/Scheduling/AddScheduledJob/AddScheduledJobEndpointSummary.cs create mode 100644 src/Lumina.Presentation.Api/Core/Endpoints/Scheduling/FireScheduledJob/FireScheduledJobEndpoint.cs create mode 100644 src/Lumina.Presentation.Api/Core/Endpoints/Scheduling/FireScheduledJob/FireScheduledJobEndpointSummary.cs create mode 100644 src/Lumina.Presentation.Api/Core/Endpoints/Scheduling/GetScheduledJobHistory/GetScheduledJobHistoryEndpoint.cs create mode 100644 src/Lumina.Presentation.Api/Core/Endpoints/Scheduling/GetScheduledJobHistory/GetScheduledJobHistoryEndpointSummary.cs create mode 100644 src/Lumina.Presentation.Api/Core/Endpoints/Scheduling/GetScheduledJobs/GetScheduledJobsEndpoint.cs create mode 100644 src/Lumina.Presentation.Api/Core/Endpoints/Scheduling/GetScheduledJobs/GetScheduledJobsEndpointSummary.cs create mode 100644 src/Lumina.Presentation.Api/Core/Endpoints/Scheduling/RemoveScheduledJob/RemoveScheduledJobEndpoint.cs create mode 100644 src/Lumina.Presentation.Api/Core/Endpoints/Scheduling/RemoveScheduledJob/RemoveScheduledJobEndpointSummary.cs create mode 100644 src/Lumina.Presentation.Api/Core/Endpoints/Scheduling/StartScheduledJob/StartScheduledJobEndpoint.cs create mode 100644 src/Lumina.Presentation.Api/Core/Endpoints/Scheduling/StartScheduledJob/StartScheduledJobEndpointSummary.cs create mode 100644 src/Lumina.Presentation.Api/Core/Endpoints/Scheduling/StopScheduledJob/StopScheduledJobEndpoint.cs create mode 100644 src/Lumina.Presentation.Api/Core/Endpoints/Scheduling/StopScheduledJob/StopScheduledJobEndpointSummary.cs diff --git a/src/Lumina.Presentation.Api/Common/Routes/Scheduling/ApiRoutes.Scheduling.cs b/src/Lumina.Presentation.Api/Common/Routes/Scheduling/ApiRoutes.Scheduling.cs new file mode 100644 index 00000000..cdd746cb --- /dev/null +++ b/src/Lumina.Presentation.Api/Common/Routes/Scheduling/ApiRoutes.Scheduling.cs @@ -0,0 +1,18 @@ +namespace Lumina.Presentation.Api.Common.Routes.Scheduling; + +/// +/// Class for the collection of the scheduled job routes of the API. +/// +public static partial class ApiRoutes +{ + public static class ScheduledJobs + { + public const string GET_SCHEDULED_JOBS = "/scheduled-jobs"; + public const string ADD_SCHEDULED_JOB = "/scheduled-jobs"; + public const string GET_SCHEDULED_JOB_HISTORY = "/scheduled-jobs/history"; + public const string REMOVE_SCHEDULED_JOB = "/scheduled-jobs/{scheduledJobId}"; + public const string START_SCHEDULED_JOB = "/scheduled-jobs/{scheduledJobId}/start"; + public const string STOP_SCHEDULED_JOB = "/scheduled-jobs/{scheduledJobId}/stop"; + public const string FIRE_SCHEDULED_JOB = "/scheduled-jobs/{scheduledJobId}/fire"; + } +} diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/Scheduling/AddScheduledJob/AddScheduledJobEndpoint.cs b/src/Lumina.Presentation.Api/Core/Endpoints/Scheduling/AddScheduledJob/AddScheduledJobEndpoint.cs new file mode 100644 index 00000000..226c59ba --- /dev/null +++ b/src/Lumina.Presentation.Api/Core/Endpoints/Scheduling/AddScheduledJob/AddScheduledJobEndpoint.cs @@ -0,0 +1,56 @@ +#region ========================================================================= USING ===================================================================================== +using Lumina.Application.Common.CQRS; +using Lumina.Application.Common.Mapping.Scheduling; +using Lumina.Application.Core.Scheduling.Commands.AddScheduledJob; +using Lumina.Contracts.Requests.Scheduling; +using Lumina.Contracts.Responses.Scheduling; +using Lumina.Domain.Common.Primitives; +using Lumina.Presentation.Api.Common.Routes.Scheduling; +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.Scheduling.AddScheduledJob; + +/// +/// API endpoint for the /scheduled-jobs route. +/// +public class AddScheduledJobEndpoint : BaseEndpoint +{ + private readonly ICommandHandler> _addScheduledJobCommandHandler; + + /// + /// Initializes a new instance of the class. + /// + /// Injected service for handling add scheduled job commands. + public AddScheduledJobEndpoint(ICommandHandler> addScheduledJobCommandHandler) + { + _addScheduledJobCommandHandler = addScheduledJobCommandHandler; + } + + /// + /// Configures the API endpoint. + /// + public override void Configure() + { + Verbs(FastEndpoints.Http.POST); + Routes(ApiRoutes.ScheduledJobs.ADD_SCHEDULED_JOB); + Version(1); + DontCatchExceptions(); + } + + /// + /// Adds a scheduled job. + /// + /// The request object. + /// Cancellation token that can be used to stop the execution. + public override async Task ExecuteAsync(AddScheduledJobRequest request, CancellationToken cancellationToken) + { + Result result = await _addScheduledJobCommandHandler.HandleAsync(request.ToCommand(), cancellationToken).ConfigureAwait(false); + return result.Match(success => TypedResults.Ok(success), Problem); + } +} + + diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/Scheduling/AddScheduledJob/AddScheduledJobEndpointSummary.cs b/src/Lumina.Presentation.Api/Core/Endpoints/Scheduling/AddScheduledJob/AddScheduledJobEndpointSummary.cs new file mode 100644 index 00000000..2e1c50d7 --- /dev/null +++ b/src/Lumina.Presentation.Api/Core/Endpoints/Scheduling/AddScheduledJob/AddScheduledJobEndpointSummary.cs @@ -0,0 +1,124 @@ +#region ========================================================================= USING ===================================================================================== +using FastEndpoints; +using Lumina.Contracts.Requests.Scheduling; +using Lumina.Contracts.Responses.Scheduling; +using Lumina.Domain.SharedKernel.Common.Enums.Scheduling; +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +#endregion + +namespace Lumina.Presentation.Api.Core.Endpoints.Scheduling.AddScheduledJob; + +/// +/// Class used for providing a textual description for the API endpoint, for OpenAPI. +/// +[ExcludeFromCodeCoverage] +public class AddScheduledJobEndpointSummary : Summary +{ + /// + /// Initializes a new instance of the class. + /// + public AddScheduledJobEndpointSummary() + { + Summary = "Adds a scheduled job."; + Description = "Adds a scheduled job that can run its task periodically or once. Only administrators can add scheduled jobs."; + + ExampleRequest = new AddScheduledJobRequest( + Name: "Rescan media libraries", + TaskType: ScheduledTaskType.ScanMediaLibraries, + ScheduleType: ScheduleType.DailyAtHourAndMinute, + IntervalMinutes: null, + Hour: 3, + Minute: 0 + ); + + RequestParam(request => request.Name, "The name of the scheduled job. Required."); + RequestParam(request => request.TaskType, "The type of the task executed by the scheduled job. Required."); + RequestParam(request => request.ScheduleType, "The type of the schedule of the scheduled job. Required."); + RequestParam(request => request.IntervalMinutes, "The interval in minutes of the schedule, required when the schedule type is WithIntervalInMinutes."); + RequestParam(request => request.Hour, "The hour of the schedule, required when the schedule type is DailyAtHourAndMinute."); + RequestParam(request => request.Minute, "The minute of the schedule, required when the schedule type is DailyAtHourAndMinute."); + + Response(200, "The scheduled job was successfully added.", + example: new ScheduledJobResponse( + Id: Guid.NewGuid(), + Name: "Rescan media libraries", + TaskType: ScheduledTaskType.ScanMediaLibraries, + ScheduleType: ScheduleType.DailyAtHourAndMinute, + IntervalMinutes: null, + Hour: 3, + Minute: 0, + Status: ScheduledJobStatus.Added, + LastStartedOnUtc: null, + LastCompletedOnUtc: null + )); + + 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/scheduled-jobs" + }, + 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/scheduled-jobs" + }, + new + { + type = "https://tools.ietf.org/html/rfc7235#section-3.1", + status = 401, + title = "Unauthorized", + detail = "The token is invalid", + instance = "/api/v1/scheduled-jobs" + } + } + ); + + Response(403, "The request failed because the user making the request is not an administrator.", "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/scheduled-jobs", + 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/scheduled-jobs", + errors = new Dictionary + { + { + "General.Validation", new[] + { + "ScheduledJobNameCannotBeEmpty", + "IntervalMinutesMustBePositive", + "HourMustBeBetweenZeroAndTwentyThree", + "MinuteMustBeBetweenZeroAndFiftyNine", + "InvalidScheduleType" + } + } + }, + traceId = "00-2470be4248a2a5a0c6f70579975a6954-b9c3ba9544a03500-00" + } + ); + } +} diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/Scheduling/FireScheduledJob/FireScheduledJobEndpoint.cs b/src/Lumina.Presentation.Api/Core/Endpoints/Scheduling/FireScheduledJob/FireScheduledJobEndpoint.cs new file mode 100644 index 00000000..36ee6c7f --- /dev/null +++ b/src/Lumina.Presentation.Api/Core/Endpoints/Scheduling/FireScheduledJob/FireScheduledJobEndpoint.cs @@ -0,0 +1,56 @@ +#region ========================================================================= USING ===================================================================================== +using Lumina.Application.Common.CQRS; +using Lumina.Application.Common.Mapping.Scheduling; +using Lumina.Application.Core.Scheduling.Commands.FireScheduledJob; +using Lumina.Contracts.Requests.Scheduling; +using Lumina.Contracts.Responses.Scheduling; +using Lumina.Domain.Common.Primitives; +using Lumina.Presentation.Api.Common.Routes.Scheduling; +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.Scheduling.FireScheduledJob; + +/// +/// API endpoint for the /scheduled-jobs/{scheduledJobId}/fire route. +/// +public class FireScheduledJobEndpoint : BaseEndpoint +{ + private readonly ICommandHandler> _fireScheduledJobCommandHandler; + + /// + /// Initializes a new instance of the class. + /// + /// Injected service for handling fire scheduled job commands. + public FireScheduledJobEndpoint(ICommandHandler> fireScheduledJobCommandHandler) + { + _fireScheduledJobCommandHandler = fireScheduledJobCommandHandler; + } + + /// + /// Configures the API endpoint. + /// + public override void Configure() + { + Verbs(FastEndpoints.Http.PUT); + Routes(ApiRoutes.ScheduledJobs.FIRE_SCHEDULED_JOB); + Version(1); + DontCatchExceptions(); + } + + /// + /// Fires the task of a scheduled job once, without affecting its execution cycle. + /// + /// The request object. + /// Cancellation token that can be used to stop the execution. + public override async Task ExecuteAsync(FireScheduledJobRequest request, CancellationToken cancellationToken) + { + Result result = await _fireScheduledJobCommandHandler.HandleAsync(request.ToCommand(), cancellationToken).ConfigureAwait(false); + return result.Match(success => TypedResults.Ok(success), Problem); + } +} + + diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/Scheduling/FireScheduledJob/FireScheduledJobEndpointSummary.cs b/src/Lumina.Presentation.Api/Core/Endpoints/Scheduling/FireScheduledJob/FireScheduledJobEndpointSummary.cs new file mode 100644 index 00000000..5a3d2b76 --- /dev/null +++ b/src/Lumina.Presentation.Api/Core/Endpoints/Scheduling/FireScheduledJob/FireScheduledJobEndpointSummary.cs @@ -0,0 +1,111 @@ +#region ========================================================================= USING ===================================================================================== +using FastEndpoints; +using Lumina.Contracts.Requests.Scheduling; +using Lumina.Contracts.Responses.Scheduling; +using Lumina.Domain.SharedKernel.Common.Enums.Scheduling; +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +#endregion + +namespace Lumina.Presentation.Api.Core.Endpoints.Scheduling.FireScheduledJob; + +/// +/// Class used for providing a textual description for the API endpoint, for OpenAPI. +/// +[ExcludeFromCodeCoverage] +public class FireScheduledJobEndpointSummary : Summary +{ + /// + /// Initializes a new instance of the class. + /// + public FireScheduledJobEndpointSummary() + { + Summary = "Fires the task of a scheduled job once."; + Description = "Runs the task of a scheduled job once immediately, without affecting its execution cycle. Only administrators can fire scheduled jobs."; + + ExampleRequest = new FireScheduledJobRequest(ScheduledJobId: Guid.NewGuid()); + + RequestParam(request => request.ScheduledJobId, "The unique identifier of the scheduled job whose task is fired. Required."); + + Response(200, "The task of the scheduled job was successfully fired.", + example: new ScheduledJobResponse( + Id: Guid.NewGuid(), + Name: "Clean temporary files", + TaskType: ScheduledTaskType.CleanTemporaryFiles, + ScheduleType: ScheduleType.WithIntervalInMinutes, + IntervalMinutes: 1440, + Hour: null, + Minute: null, + Status: ScheduledJobStatus.Completed, + LastStartedOnUtc: DateTime.UtcNow.AddMinutes(-1), + LastCompletedOnUtc: DateTime.UtcNow + )); + + 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/scheduled-jobs/{scheduledJobId}/fire" + }, + 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/scheduled-jobs/{scheduledJobId}/fire" + }, + new + { + type = "https://tools.ietf.org/html/rfc7235#section-3.1", + status = 401, + title = "Unauthorized", + detail = "The token is invalid", + instance = "/api/v1/scheduled-jobs/{scheduledJobId}/fire" + } + } + ); + + Response(403, "The request failed because the user making the request is not an administrator, or because the task of the scheduled job is currently running.", "application/problem+json", + example: new[] + { + new + { + type = "https://tools.ietf.org/html/rfc9110#section-15.5.4", + title = "General.Failure", + status = 403, + detail = "NotAuthorized", + instance = "/api/v1/scheduled-jobs/{scheduledJobId}/fire", + traceId = "00-a712bbf99ca8ab485f86a762ae5ae74d-b3a2eb78813b0a5d-00" + }, + new + { + type = "https://tools.ietf.org/html/rfc9110#section-15.5.4", + title = "General.Failure", + status = 403, + detail = "ScheduledJobAlreadyRunning", + instance = "/api/v1/scheduled-jobs/{scheduledJobId}/fire", + traceId = "00-a712bbf99ca8ab485f86a762ae5ae74d-b3a2eb78813b0a5d-00" + } + } + ); + + Response(404, "The request failed because the provided scheduled job 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 = "ScheduledJobNotFound", + instance = "/api/v1/scheduled-jobs/{scheduledJobId}/fire", + traceId = "00-57d15dadd702dbd4aeb5dc9b7cee68ee-9330237dbb2ce0e5-00" + } + ); + } +} diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/Scheduling/GetScheduledJobHistory/GetScheduledJobHistoryEndpoint.cs b/src/Lumina.Presentation.Api/Core/Endpoints/Scheduling/GetScheduledJobHistory/GetScheduledJobHistoryEndpoint.cs new file mode 100644 index 00000000..92fad950 --- /dev/null +++ b/src/Lumina.Presentation.Api/Core/Endpoints/Scheduling/GetScheduledJobHistory/GetScheduledJobHistoryEndpoint.cs @@ -0,0 +1,57 @@ +#region ========================================================================= USING ===================================================================================== +using Lumina.Application.Common.CQRS; +using Lumina.Application.Common.Mapping.Scheduling; +using Lumina.Application.Core.Scheduling.Queries.GetScheduledJobHistory; +using Lumina.Contracts.Requests.Scheduling; +using Lumina.Contracts.Responses.Scheduling; +using Lumina.Domain.Common.Primitives; +using Lumina.Presentation.Api.Common.Routes.Scheduling; +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.Scheduling.GetScheduledJobHistory; + +/// +/// API endpoint for the /scheduled-jobs/history route. +/// +public class GetScheduledJobHistoryEndpoint : BaseEndpoint +{ + private readonly IQueryHandler>> _getScheduledJobHistoryQueryHandler; + + /// + /// Initializes a new instance of the class. + /// + /// Injected service for handling get scheduled job history queries. + public GetScheduledJobHistoryEndpoint(IQueryHandler>> getScheduledJobHistoryQueryHandler) + { + _getScheduledJobHistoryQueryHandler = getScheduledJobHistoryQueryHandler; + } + + /// + /// Configures the API endpoint. + /// + public override void Configure() + { + Verbs(FastEndpoints.Http.GET); + Routes(ApiRoutes.ScheduledJobs.GET_SCHEDULED_JOB_HISTORY); + Version(1); + DontCatchExceptions(); + } + + /// + /// Gets the history of the executions of the tasks of scheduled jobs. + /// + /// The request object. + /// Cancellation token that can be used to stop the execution. + public override async Task ExecuteAsync(GetScheduledJobHistoryRequest request, CancellationToken cancellationToken) + { + Result> result = await _getScheduledJobHistoryQueryHandler.HandleAsync(request.ToQuery(), cancellationToken).ConfigureAwait(false); + return result.Match(success => TypedResults.Ok(success), Problem); + } +} + + diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/Scheduling/GetScheduledJobHistory/GetScheduledJobHistoryEndpointSummary.cs b/src/Lumina.Presentation.Api/Core/Endpoints/Scheduling/GetScheduledJobHistory/GetScheduledJobHistoryEndpointSummary.cs new file mode 100644 index 00000000..3b26fa7f --- /dev/null +++ b/src/Lumina.Presentation.Api/Core/Endpoints/Scheduling/GetScheduledJobHistory/GetScheduledJobHistoryEndpointSummary.cs @@ -0,0 +1,86 @@ +#region ========================================================================= USING ===================================================================================== +using FastEndpoints; +using Lumina.Contracts.Requests.Scheduling; +using Lumina.Contracts.Responses.Scheduling; +using Lumina.Domain.SharedKernel.Common.Enums.Scheduling; +using System; +using System.Diagnostics.CodeAnalysis; +#endregion + +namespace Lumina.Presentation.Api.Core.Endpoints.Scheduling.GetScheduledJobHistory; + +/// +/// Class used for providing a textual description for the API endpoint, for OpenAPI. +/// +[ExcludeFromCodeCoverage] +public class GetScheduledJobHistoryEndpointSummary : Summary +{ + /// + /// Initializes a new instance of the class. + /// + public GetScheduledJobHistoryEndpointSummary() + { + Summary = "Gets the history of the executions of the tasks of scheduled jobs."; + Description = "Gets the executions of the tasks of scheduled jobs that started in the requested time interval. Only administrators can get the history of scheduled jobs."; + + ExampleRequest = new GetScheduledJobHistoryRequest(From: DateTime.UtcNow.AddDays(-1), To: DateTime.UtcNow); + + RequestParam(request => request.From, "The inclusive lower bound of the interval for which the history is requested. Optional."); + RequestParam(request => request.To, "The inclusive upper bound of the interval for which the history is requested. Optional."); + + Response(200, "The execution history was successfully retrieved.", + example: new[] + { + new ScheduledJobExecutionResponse( + Id: Guid.NewGuid(), + ScheduledJobId: Guid.NewGuid(), + TaskType: ScheduledTaskType.CleanTemporaryFiles, + IsCycleRun: true, + StartedOnUtc: DateTime.UtcNow.AddMinutes(-10), + CompletedOnUtc: DateTime.UtcNow.AddMinutes(-9) + ) + }); + + 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/scheduled-jobs/history" + }, + 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/scheduled-jobs/history" + }, + new + { + type = "https://tools.ietf.org/html/rfc7235#section-3.1", + status = 401, + title = "Unauthorized", + detail = "The token is invalid", + instance = "/api/v1/scheduled-jobs/history" + } + } + ); + + Response(403, "The request failed because the user making the request is not an administrator.", "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/scheduled-jobs/history", + traceId = "00-a712bbf99ca8ab485f86a762ae5ae74d-b3a2eb78813b0a5d-00" + } + ); + } +} diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/Scheduling/GetScheduledJobs/GetScheduledJobsEndpoint.cs b/src/Lumina.Presentation.Api/Core/Endpoints/Scheduling/GetScheduledJobs/GetScheduledJobsEndpoint.cs new file mode 100644 index 00000000..23538803 --- /dev/null +++ b/src/Lumina.Presentation.Api/Core/Endpoints/Scheduling/GetScheduledJobs/GetScheduledJobsEndpoint.cs @@ -0,0 +1,55 @@ +#region ========================================================================= USING ===================================================================================== +using Lumina.Application.Common.CQRS; +using Lumina.Application.Core.Scheduling.Queries.GetScheduledJobs; +using Lumina.Contracts.Responses.Scheduling; +using Lumina.Domain.Common.Primitives; +using Lumina.Presentation.Api.Common.Routes.Scheduling; +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.Scheduling.GetScheduledJobs; + +/// +/// API endpoint for the /scheduled-jobs route. +/// +public class GetScheduledJobsEndpoint : BaseEndpoint +{ + private readonly IQueryHandler>> _getScheduledJobsQueryHandler; + + /// + /// Initializes a new instance of the class. + /// + /// Injected service for handling get scheduled jobs queries. + public GetScheduledJobsEndpoint(IQueryHandler>> getScheduledJobsQueryHandler) + { + _getScheduledJobsQueryHandler = getScheduledJobsQueryHandler; + } + + /// + /// Configures the API endpoint. + /// + public override void Configure() + { + Verbs(FastEndpoints.Http.GET); + Routes(ApiRoutes.ScheduledJobs.GET_SCHEDULED_JOBS); + Version(1); + DontCatchExceptions(); + } + + /// + /// Gets the list of scheduled jobs. + /// + /// The request object. + /// Cancellation token that can be used to stop the execution. + public override async Task ExecuteAsync(FastEndpoints.EmptyRequest request, CancellationToken cancellationToken) + { + Result> result = await _getScheduledJobsQueryHandler.HandleAsync(new GetScheduledJobsQuery(), cancellationToken).ConfigureAwait(false); + return result.Match(success => TypedResults.Ok(success), Problem); + } +} + + diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/Scheduling/GetScheduledJobs/GetScheduledJobsEndpointSummary.cs b/src/Lumina.Presentation.Api/Core/Endpoints/Scheduling/GetScheduledJobs/GetScheduledJobsEndpointSummary.cs new file mode 100644 index 00000000..3da4ee55 --- /dev/null +++ b/src/Lumina.Presentation.Api/Core/Endpoints/Scheduling/GetScheduledJobs/GetScheduledJobsEndpointSummary.cs @@ -0,0 +1,84 @@ +#region ========================================================================= USING ===================================================================================== +using FastEndpoints; +using Lumina.Contracts.Responses.Scheduling; +using Lumina.Domain.SharedKernel.Common.Enums.Scheduling; +using System; +using System.Diagnostics.CodeAnalysis; +#endregion + +namespace Lumina.Presentation.Api.Core.Endpoints.Scheduling.GetScheduledJobs; + +/// +/// Class used for providing a textual description for the API endpoint, for OpenAPI. +/// +[ExcludeFromCodeCoverage] +public class GetScheduledJobsEndpointSummary : Summary +{ + /// + /// Initializes a new instance of the class. + /// + public GetScheduledJobsEndpointSummary() + { + Summary = "Gets the list of scheduled jobs."; + Description = "Gets the list of scheduled jobs and their status. Only administrators can get the list of scheduled jobs."; + + Response(200, "The list of scheduled jobs was successfully retrieved.", + example: new[] + { + new ScheduledJobResponse( + Id: Guid.NewGuid(), + Name: "Rescan media libraries", + TaskType: ScheduledTaskType.ScanMediaLibraries, + ScheduleType: ScheduleType.DailyAtHourAndMinute, + IntervalMinutes: null, + Hour: 3, + Minute: 0, + Status: ScheduledJobStatus.Active, + LastStartedOnUtc: DateTime.UtcNow.AddHours(-2), + LastCompletedOnUtc: DateTime.UtcNow.AddHours(-2).AddMinutes(5) + ) + }); + + 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/scheduled-jobs" + }, + 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/scheduled-jobs" + }, + new + { + type = "https://tools.ietf.org/html/rfc7235#section-3.1", + status = 401, + title = "Unauthorized", + detail = "The token is invalid", + instance = "/api/v1/scheduled-jobs" + } + } + ); + + Response(403, "The request failed because the user making the request is not an administrator.", "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/scheduled-jobs", + traceId = "00-a712bbf99ca8ab485f86a762ae5ae74d-b3a2eb78813b0a5d-00" + } + ); + } +} diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/Scheduling/RemoveScheduledJob/RemoveScheduledJobEndpoint.cs b/src/Lumina.Presentation.Api/Core/Endpoints/Scheduling/RemoveScheduledJob/RemoveScheduledJobEndpoint.cs new file mode 100644 index 00000000..e4fee510 --- /dev/null +++ b/src/Lumina.Presentation.Api/Core/Endpoints/Scheduling/RemoveScheduledJob/RemoveScheduledJobEndpoint.cs @@ -0,0 +1,55 @@ +#region ========================================================================= USING ===================================================================================== +using Lumina.Application.Common.CQRS; +using Lumina.Application.Common.Mapping.Scheduling; +using Lumina.Application.Core.Scheduling.Commands.RemoveScheduledJob; +using Lumina.Contracts.Requests.Scheduling; +using Lumina.Domain.Common.Primitives; +using Lumina.Presentation.Api.Common.Routes.Scheduling; +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.Scheduling.RemoveScheduledJob; + +/// +/// API endpoint for the /scheduled-jobs/{scheduledJobId} route. +/// +public class RemoveScheduledJobEndpoint : BaseEndpoint +{ + private readonly ICommandHandler> _removeScheduledJobCommandHandler; + + /// + /// Initializes a new instance of the class. + /// + /// Injected service for handling remove scheduled job commands. + public RemoveScheduledJobEndpoint(ICommandHandler> removeScheduledJobCommandHandler) + { + _removeScheduledJobCommandHandler = removeScheduledJobCommandHandler; + } + + /// + /// Configures the API endpoint. + /// + public override void Configure() + { + Verbs(FastEndpoints.Http.DELETE); + Routes(ApiRoutes.ScheduledJobs.REMOVE_SCHEDULED_JOB); + Version(1); + DontCatchExceptions(); + } + + /// + /// Removes a scheduled job. + /// + /// The request object. + /// Cancellation token that can be used to stop the execution. + public override async Task ExecuteAsync(RemoveScheduledJobRequest request, CancellationToken cancellationToken) + { + Result result = await _removeScheduledJobCommandHandler.HandleAsync(request.ToCommand(), cancellationToken).ConfigureAwait(false); + return result.Match(_ => TypedResults.Ok(new { }), Problem); + } +} + + diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/Scheduling/RemoveScheduledJob/RemoveScheduledJobEndpointSummary.cs b/src/Lumina.Presentation.Api/Core/Endpoints/Scheduling/RemoveScheduledJob/RemoveScheduledJobEndpointSummary.cs new file mode 100644 index 00000000..840c9b3a --- /dev/null +++ b/src/Lumina.Presentation.Api/Core/Endpoints/Scheduling/RemoveScheduledJob/RemoveScheduledJobEndpointSummary.cs @@ -0,0 +1,85 @@ +#region ========================================================================= USING ===================================================================================== +using FastEndpoints; +using Lumina.Contracts.Requests.Scheduling; +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +#endregion + +namespace Lumina.Presentation.Api.Core.Endpoints.Scheduling.RemoveScheduledJob; + +/// +/// Class used for providing a textual description for the API endpoint, for OpenAPI. +/// +[ExcludeFromCodeCoverage] +public class RemoveScheduledJobEndpointSummary : Summary +{ + /// + /// Initializes a new instance of the class. + /// + public RemoveScheduledJobEndpointSummary() + { + Summary = "Removes a scheduled job."; + Description = "Removes a scheduled job, after stopping its execution cycle, if it has one. Only administrators can remove scheduled jobs."; + + ExampleRequest = new RemoveScheduledJobRequest(ScheduledJobId: Guid.NewGuid()); + + RequestParam(request => request.ScheduledJobId, "The unique identifier of the scheduled job to remove. Required."); + + Response(200, "The scheduled job was successfully removed."); + + 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/scheduled-jobs/{scheduledJobId}" + }, + 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/scheduled-jobs/{scheduledJobId}" + }, + new + { + type = "https://tools.ietf.org/html/rfc7235#section-3.1", + status = 401, + title = "Unauthorized", + detail = "The token is invalid", + instance = "/api/v1/scheduled-jobs/{scheduledJobId}" + } + } + ); + + Response(403, "The request failed because the user making the request is not an administrator.", "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/scheduled-jobs/{scheduledJobId}", + traceId = "00-a712bbf99ca8ab485f86a762ae5ae74d-b3a2eb78813b0a5d-00" + } + ); + + Response(404, "The request failed because the provided scheduled job 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 = "ScheduledJobNotFound", + instance = "/api/v1/scheduled-jobs/{scheduledJobId}", + traceId = "00-57d15dadd702dbd4aeb5dc9b7cee68ee-9330237dbb2ce0e5-00" + } + ); + } +} diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/Scheduling/StartScheduledJob/StartScheduledJobEndpoint.cs b/src/Lumina.Presentation.Api/Core/Endpoints/Scheduling/StartScheduledJob/StartScheduledJobEndpoint.cs new file mode 100644 index 00000000..7c89ed36 --- /dev/null +++ b/src/Lumina.Presentation.Api/Core/Endpoints/Scheduling/StartScheduledJob/StartScheduledJobEndpoint.cs @@ -0,0 +1,56 @@ +#region ========================================================================= USING ===================================================================================== +using Lumina.Application.Common.CQRS; +using Lumina.Application.Common.Mapping.Scheduling; +using Lumina.Application.Core.Scheduling.Commands.StartScheduledJob; +using Lumina.Contracts.Requests.Scheduling; +using Lumina.Contracts.Responses.Scheduling; +using Lumina.Domain.Common.Primitives; +using Lumina.Presentation.Api.Common.Routes.Scheduling; +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.Scheduling.StartScheduledJob; + +/// +/// API endpoint for the /scheduled-jobs/{scheduledJobId}/start route. +/// +public class StartScheduledJobEndpoint : BaseEndpoint +{ + private readonly ICommandHandler> _startScheduledJobCommandHandler; + + /// + /// Initializes a new instance of the class. + /// + /// Injected service for handling start scheduled job commands. + public StartScheduledJobEndpoint(ICommandHandler> startScheduledJobCommandHandler) + { + _startScheduledJobCommandHandler = startScheduledJobCommandHandler; + } + + /// + /// Configures the API endpoint. + /// + public override void Configure() + { + Verbs(FastEndpoints.Http.PUT); + Routes(ApiRoutes.ScheduledJobs.START_SCHEDULED_JOB); + Version(1); + DontCatchExceptions(); + } + + /// + /// Starts the execution cycle of a scheduled job. + /// + /// The request object. + /// Cancellation token that can be used to stop the execution. + public override async Task ExecuteAsync(StartScheduledJobRequest request, CancellationToken cancellationToken) + { + Result result = await _startScheduledJobCommandHandler.HandleAsync(request.ToCommand(), cancellationToken).ConfigureAwait(false); + return result.Match(success => TypedResults.Ok(success), Problem); + } +} + + diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/Scheduling/StartScheduledJob/StartScheduledJobEndpointSummary.cs b/src/Lumina.Presentation.Api/Core/Endpoints/Scheduling/StartScheduledJob/StartScheduledJobEndpointSummary.cs new file mode 100644 index 00000000..d8f6e779 --- /dev/null +++ b/src/Lumina.Presentation.Api/Core/Endpoints/Scheduling/StartScheduledJob/StartScheduledJobEndpointSummary.cs @@ -0,0 +1,111 @@ +#region ========================================================================= USING ===================================================================================== +using FastEndpoints; +using Lumina.Contracts.Requests.Scheduling; +using Lumina.Contracts.Responses.Scheduling; +using Lumina.Domain.SharedKernel.Common.Enums.Scheduling; +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +#endregion + +namespace Lumina.Presentation.Api.Core.Endpoints.Scheduling.StartScheduledJob; + +/// +/// Class used for providing a textual description for the API endpoint, for OpenAPI. +/// +[ExcludeFromCodeCoverage] +public class StartScheduledJobEndpointSummary : Summary +{ + /// + /// Initializes a new instance of the class. + /// + public StartScheduledJobEndpointSummary() + { + Summary = "Starts the execution cycle of a scheduled job."; + Description = "Starts the execution cycle of a scheduled job, which runs its task once immediately and then on its schedule. Only administrators can start scheduled jobs."; + + ExampleRequest = new StartScheduledJobRequest(ScheduledJobId: Guid.NewGuid()); + + RequestParam(request => request.ScheduledJobId, "The unique identifier of the scheduled job whose execution cycle is started. Required."); + + Response(200, "The execution cycle of the scheduled job was successfully started.", + example: new ScheduledJobResponse( + Id: Guid.NewGuid(), + Name: "Rescan media libraries", + TaskType: ScheduledTaskType.ScanMediaLibraries, + ScheduleType: ScheduleType.DailyAtHourAndMinute, + IntervalMinutes: null, + Hour: 3, + Minute: 0, + Status: ScheduledJobStatus.Active, + LastStartedOnUtc: DateTime.UtcNow.AddMinutes(-1), + LastCompletedOnUtc: null + )); + + 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/scheduled-jobs/{scheduledJobId}/start" + }, + 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/scheduled-jobs/{scheduledJobId}/start" + }, + new + { + type = "https://tools.ietf.org/html/rfc7235#section-3.1", + status = 401, + title = "Unauthorized", + detail = "The token is invalid", + instance = "/api/v1/scheduled-jobs/{scheduledJobId}/start" + } + } + ); + + Response(403, "The request failed because the user making the request is not an administrator, or because the execution cycle of the scheduled job is already started.", "application/problem+json", + example: new[] + { + new + { + type = "https://tools.ietf.org/html/rfc9110#section-15.5.4", + title = "General.Failure", + status = 403, + detail = "NotAuthorized", + instance = "/api/v1/scheduled-jobs/{scheduledJobId}/start", + traceId = "00-a712bbf99ca8ab485f86a762ae5ae74d-b3a2eb78813b0a5d-00" + }, + new + { + type = "https://tools.ietf.org/html/rfc9110#section-15.5.4", + title = "General.Failure", + status = 403, + detail = "ScheduledJobCycleAlreadyStarted", + instance = "/api/v1/scheduled-jobs/{scheduledJobId}/start", + traceId = "00-a712bbf99ca8ab485f86a762ae5ae74d-b3a2eb78813b0a5d-00" + } + } + ); + + Response(404, "The request failed because the provided scheduled job 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 = "ScheduledJobNotFound", + instance = "/api/v1/scheduled-jobs/{scheduledJobId}/start", + traceId = "00-57d15dadd702dbd4aeb5dc9b7cee68ee-9330237dbb2ce0e5-00" + } + ); + } +} diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/Scheduling/StopScheduledJob/StopScheduledJobEndpoint.cs b/src/Lumina.Presentation.Api/Core/Endpoints/Scheduling/StopScheduledJob/StopScheduledJobEndpoint.cs new file mode 100644 index 00000000..4b409034 --- /dev/null +++ b/src/Lumina.Presentation.Api/Core/Endpoints/Scheduling/StopScheduledJob/StopScheduledJobEndpoint.cs @@ -0,0 +1,56 @@ +#region ========================================================================= USING ===================================================================================== +using Lumina.Application.Common.CQRS; +using Lumina.Application.Common.Mapping.Scheduling; +using Lumina.Application.Core.Scheduling.Commands.StopScheduledJob; +using Lumina.Contracts.Requests.Scheduling; +using Lumina.Contracts.Responses.Scheduling; +using Lumina.Domain.Common.Primitives; +using Lumina.Presentation.Api.Common.Routes.Scheduling; +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.Scheduling.StopScheduledJob; + +/// +/// API endpoint for the /scheduled-jobs/{scheduledJobId}/stop route. +/// +public class StopScheduledJobEndpoint : BaseEndpoint +{ + private readonly ICommandHandler> _stopScheduledJobCommandHandler; + + /// + /// Initializes a new instance of the class. + /// + /// Injected service for handling stop scheduled job commands. + public StopScheduledJobEndpoint(ICommandHandler> stopScheduledJobCommandHandler) + { + _stopScheduledJobCommandHandler = stopScheduledJobCommandHandler; + } + + /// + /// Configures the API endpoint. + /// + public override void Configure() + { + Verbs(FastEndpoints.Http.PUT); + Routes(ApiRoutes.ScheduledJobs.STOP_SCHEDULED_JOB); + Version(1); + DontCatchExceptions(); + } + + /// + /// Stops the execution cycle of a scheduled job. + /// + /// The request object. + /// Cancellation token that can be used to stop the execution. + public override async Task ExecuteAsync(StopScheduledJobRequest request, CancellationToken cancellationToken) + { + Result result = await _stopScheduledJobCommandHandler.HandleAsync(request.ToCommand(), cancellationToken).ConfigureAwait(false); + return result.Match(success => TypedResults.Ok(success), Problem); + } +} + + diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/Scheduling/StopScheduledJob/StopScheduledJobEndpointSummary.cs b/src/Lumina.Presentation.Api/Core/Endpoints/Scheduling/StopScheduledJob/StopScheduledJobEndpointSummary.cs new file mode 100644 index 00000000..bd372604 --- /dev/null +++ b/src/Lumina.Presentation.Api/Core/Endpoints/Scheduling/StopScheduledJob/StopScheduledJobEndpointSummary.cs @@ -0,0 +1,120 @@ +#region ========================================================================= USING ===================================================================================== +using FastEndpoints; +using Lumina.Contracts.Requests.Scheduling; +using Lumina.Contracts.Responses.Scheduling; +using Lumina.Domain.SharedKernel.Common.Enums.Scheduling; +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +#endregion + +namespace Lumina.Presentation.Api.Core.Endpoints.Scheduling.StopScheduledJob; + +/// +/// Class used for providing a textual description for the API endpoint, for OpenAPI. +/// +[ExcludeFromCodeCoverage] +public class StopScheduledJobEndpointSummary : Summary +{ + /// + /// Initializes a new instance of the class. + /// + public StopScheduledJobEndpointSummary() + { + Summary = "Stops the execution cycle of a scheduled job."; + Description = "Stops the execution cycle of a scheduled job, without removing it. Only administrators can stop scheduled jobs."; + + ExampleRequest = new StopScheduledJobRequest(ScheduledJobId: Guid.NewGuid()); + + RequestParam(request => request.ScheduledJobId, "The unique identifier of the scheduled job whose execution cycle is stopped. Required."); + + Response(200, "The execution cycle of the scheduled job was successfully stopped.", + example: new ScheduledJobResponse( + Id: Guid.NewGuid(), + Name: "Rescan media libraries", + TaskType: ScheduledTaskType.ScanMediaLibraries, + ScheduleType: ScheduleType.DailyAtHourAndMinute, + IntervalMinutes: null, + Hour: 3, + Minute: 0, + Status: ScheduledJobStatus.Added, + LastStartedOnUtc: DateTime.UtcNow.AddMinutes(-1), + LastCompletedOnUtc: DateTime.UtcNow + )); + + 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/scheduled-jobs/{scheduledJobId}/stop" + }, + 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/scheduled-jobs/{scheduledJobId}/stop" + }, + new + { + type = "https://tools.ietf.org/html/rfc7235#section-3.1", + status = 401, + title = "Unauthorized", + detail = "The token is invalid", + instance = "/api/v1/scheduled-jobs/{scheduledJobId}/stop" + } + } + ); + + Response(403, "The request failed because the user making the request is not an administrator, or because the execution cycle of the scheduled job was not started, or its task is currently running.", "application/problem+json", + example: new[] + { + new + { + type = "https://tools.ietf.org/html/rfc9110#section-15.5.4", + title = "General.Failure", + status = 403, + detail = "NotAuthorized", + instance = "/api/v1/scheduled-jobs/{scheduledJobId}/stop", + traceId = "00-a712bbf99ca8ab485f86a762ae5ae74d-b3a2eb78813b0a5d-00" + }, + new + { + type = "https://tools.ietf.org/html/rfc9110#section-15.5.4", + title = "General.Failure", + status = 403, + detail = "ScheduledJobNotStarted", + instance = "/api/v1/scheduled-jobs/{scheduledJobId}/stop", + traceId = "00-a712bbf99ca8ab485f86a762ae5ae74d-b3a2eb78813b0a5d-00" + }, + new + { + type = "https://tools.ietf.org/html/rfc9110#section-15.5.4", + title = "General.Failure", + status = 403, + detail = "ScheduledJobAlreadyRunning", + instance = "/api/v1/scheduled-jobs/{scheduledJobId}/stop", + traceId = "00-a712bbf99ca8ab485f86a762ae5ae74d-b3a2eb78813b0a5d-00" + } + } + ); + + Response(404, "The request failed because the provided scheduled job 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 = "ScheduledJobNotFound", + instance = "/api/v1/scheduled-jobs/{scheduledJobId}/stop", + traceId = "00-57d15dadd702dbd4aeb5dc9b7cee68ee-9330237dbb2ce0e5-00" + } + ); + } +}