| | | 1 | | using Microsoft.AspNetCore.Mvc; |
| | | 2 | | using pva.SuperV.Model.FieldProcessings; |
| | | 3 | | using pva.SuperV.Model.Services; |
| | | 4 | | using System.ComponentModel; |
| | | 5 | | |
| | | 6 | | namespace pva.SuperV.Api.Routes.Scripts |
| | | 7 | | { |
| | | 8 | | public static class ScriptEndpoints |
| | | 9 | | { |
| | | 10 | | public static WebApplication MapScriptEndpoints(this WebApplication app) |
| | 145 | 11 | | { |
| | 145 | 12 | | RouteGroupBuilder scriptsApi = app.MapGroup("/scripts"); |
| | 145 | 13 | | scriptsApi.MapGet("/{projectId}", |
| | 145 | 14 | | async (IScriptService scriptService, |
| | 145 | 15 | | [Description("ID of project")] string projectId) |
| | 2 | 16 | | => await GetScripts.Handle(scriptService, projectId)) |
| | 145 | 17 | | .WithName("GetScripts") |
| | 145 | 18 | | .WithDisplayName("GetScripts") |
| | 145 | 19 | | .WithSummary("Gets the list of available scripts from a project") |
| | 145 | 20 | | .WithDescription("Gets the list of scripts from a project") |
| | 145 | 21 | | .Produces<List<ScriptDefinitionModel>>(StatusCodes.Status200OK) |
| | 145 | 22 | | .Produces<string>(StatusCodes.Status404NotFound) |
| | 145 | 23 | | .Produces<string>(StatusCodes.Status400BadRequest); |
| | | 24 | | |
| | 145 | 25 | | scriptsApi.MapGet("/{projectId}/{scriptName}", |
| | 145 | 26 | | async (IScriptService scriptService, |
| | 145 | 27 | | [Description("ID of project")] string projectId, |
| | 145 | 28 | | [Description("Name of processing")] string scriptName) |
| | 2 | 29 | | => await GetScript.Handle(scriptService, projectId, scriptName)) |
| | 145 | 30 | | .WithName("GetScript") |
| | 145 | 31 | | .WithDisplayName("GetScript") |
| | 145 | 32 | | .WithSummary("Gets a field processing from a class of a project by its name") |
| | 145 | 33 | | .WithDescription("Gets a field processing from a class of a project by its name") |
| | 145 | 34 | | .Produces<ScriptDefinitionModel>(StatusCodes.Status200OK) |
| | 145 | 35 | | .Produces<string>(StatusCodes.Status404NotFound) |
| | 145 | 36 | | .Produces<string>(StatusCodes.Status400BadRequest); |
| | | 37 | | |
| | 145 | 38 | | scriptsApi.MapPut("/{wipProjectId}/{scriptName}", |
| | 145 | 39 | | async (IScriptService scriptService, |
| | 145 | 40 | | [Description("ID of WIP project")] string wipProjectId, |
| | 145 | 41 | | [Description("Name of field processing")] string scriptName, |
| | 145 | 42 | | [Description("Field processing update request")][FromBody] ScriptDefinitionModel createRequest) |
| | 3 | 43 | | => await UpdateScript.Handle(scriptService, wipProjectId, scriptName, createRequest)) |
| | 145 | 44 | | .WithName("UpdateScript") |
| | 145 | 45 | | .WithDisplayName("UpdateScript") |
| | 145 | 46 | | .WithSummary("Updates a field processing in a class of a WIP project") |
| | 145 | 47 | | .WithDescription("Updates a field processing in a class of a WIP project") |
| | 145 | 48 | | .Produces<ScriptDefinitionModel>(StatusCodes.Status200OK) |
| | 145 | 49 | | .Produces<string>(StatusCodes.Status404NotFound) |
| | 145 | 50 | | .Produces<string>(StatusCodes.Status400BadRequest); |
| | | 51 | | |
| | 145 | 52 | | scriptsApi.MapPost("/{wipProjectId}", |
| | 145 | 53 | | async (IScriptService scriptService, |
| | 145 | 54 | | [Description("ID of WIP project")] string wipProjectId, |
| | 145 | 55 | | [Description("Script creation request")][FromBody] ScriptDefinitionModel createRequest) |
| | 3 | 56 | | => await CreateScript.Handle(scriptService, wipProjectId, createRequest)) |
| | 145 | 57 | | .WithName("CreateScript") |
| | 145 | 58 | | .WithDisplayName("CreateScript") |
| | 145 | 59 | | .WithSummary("Creates a script in a WIP project") |
| | 145 | 60 | | .WithDescription("Creates a script in a WIP project") |
| | 145 | 61 | | .Produces<ScriptDefinitionModel>(StatusCodes.Status201Created) |
| | 145 | 62 | | .Produces<string>(StatusCodes.Status404NotFound) |
| | 145 | 63 | | .Produces<string>(StatusCodes.Status400BadRequest); |
| | | 64 | | |
| | 145 | 65 | | scriptsApi.MapDelete("/{wipProjectId}/{scriptName}", |
| | 145 | 66 | | async (IScriptService scriptService, |
| | 145 | 67 | | [Description("ID of WIP project")] string wipProjectId, |
| | 145 | 68 | | [Description("Name of script")] string scriptName) |
| | 3 | 69 | | => await DeleteScript.Handle(scriptService, wipProjectId, scriptName)) |
| | 145 | 70 | | .WithName("DeleteScript") |
| | 145 | 71 | | .WithDisplayName("DeleteScript") |
| | 145 | 72 | | .WithSummary("Deletes a script from a WIP project by its name") |
| | 145 | 73 | | .WithDescription("Deletes a script from a WIP project by its name") |
| | 145 | 74 | | .Produces(StatusCodes.Status204NoContent) |
| | 145 | 75 | | .Produces<string>(StatusCodes.Status404NotFound) |
| | 145 | 76 | | .Produces<string>(StatusCodes.Status400BadRequest); |
| | | 77 | | |
| | 145 | 78 | | return app; |
| | 145 | 79 | | } |
| | | 80 | | } |
| | | 81 | | } |