< Summary - pva.SuperV

Information
Class: pva.SuperV.Api.Routes.Instances.InstancesEndpoints
Assembly: pva.SuperV.Api
File(s): /home/runner/work/pva.SuperV/pva.SuperV/pva.SuperV.Api/Routes/Instances/InstancesEndpoints.cs
Tag: dotnet-ubuntu_18869653307
Line coverage
100%
Covered lines: 91
Uncovered lines: 0
Coverable lines: 91
Total lines: 112
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
MapInstancesEndpoints(...)100%11100%

File(s)

/home/runner/work/pva.SuperV/pva.SuperV/pva.SuperV.Api/Routes/Instances/InstancesEndpoints.cs

#LineLine coverage
 1using Microsoft.AspNetCore.Mvc;
 2using pva.SuperV.Model;
 3using pva.SuperV.Model.FieldDefinitions;
 4using pva.SuperV.Model.Instances;
 5using pva.SuperV.Model.Services;
 6using System.ComponentModel;
 7
 8namespace pva.SuperV.Api.Routes.Instances
 9{
 10    public static class InstancesEndpoints
 11    {
 12        public static WebApplication MapInstancesEndpoints(this WebApplication app)
 13113        {
 13114            RouteGroupBuilder instancesApi = app.MapGroup("/instances");
 13115            instancesApi.MapGet("/{runnableProjectId}",
 13116                (IInstanceService instanceService,
 13117                [Description("ID of runnable project")] string runnableProjectId)
 218                    => GetInstances.Handle(instanceService, runnableProjectId))
 13119                .WithName("GetInstances")
 13120                .WithDisplayName("GetInstances")
 13121                .WithSummary("Gets the list of instances from a project")
 13122                .WithDescription("Gets the list of instances from a project")
 13123                .Produces<List<FieldDefinitionModel>>(StatusCodes.Status200OK)
 13124                .Produces<string>(StatusCodes.Status404NotFound)
 13125                .Produces<string>(StatusCodes.Status400BadRequest);
 26
 13127            instancesApi.MapPost("/{runnableProjectId}/search",
 13128                (IInstanceService instanceService,
 13129                [Description("ID of runnable project")] string runnableProjectId,
 13130                [FromBody] InstancePagedSearchRequest search)
 131                    => SearchInstances.Handle(instanceService, runnableProjectId, search))
 13132                .WithName("SearchInstances")
 13133                .WithDisplayName("SearchInstances")
 13134                .WithSummary("Searches the list of instances from a project")
 13135                .WithDescription("Searches the list of instances from a project")
 13136                .Produces<PagedSearchResult<FieldDefinitionModel>>(StatusCodes.Status200OK)
 13137                .Produces<string>(StatusCodes.Status404NotFound)
 13138                .Produces<string>(StatusCodes.Status400BadRequest);
 39
 13140            instancesApi.MapGet("/{runnableProjectId}/{instanceName}",
 13141                (IInstanceService instanceService,
 13142                [Description("ID of runnable project")] string runnableProjectId,
 13143                [Description("Name of instance")] string instanceName)
 244                    => GetInstance.Handle(instanceService, runnableProjectId, instanceName))
 13145                .WithName("GetInstance")
 13146                .WithDisplayName("GetInstance")
 13147                .WithSummary("Gets an instance of a project by its name")
 13148                .WithDescription("Gets an instance of a project by its name")
 13149                .Produces<FieldDefinitionModel>(StatusCodes.Status200OK)
 13150                .Produces<string>(StatusCodes.Status404NotFound)
 13151                .Produces<string>(StatusCodes.Status400BadRequest);
 52
 13153            instancesApi.MapPost("/{runnableProjectId}",
 13154                (IInstanceService instanceService,
 13155                [Description("ID of runnable project")] string runnableProjectId,
 13156                [Description("Instance creation request")][FromBody] InstanceModel createRequest,
 13157                [FromQuery] bool addToRunningInstances = true)
 558                    => CreateInstance.Handle(instanceService, runnableProjectId, createRequest, addToRunningInstances))
 13159                .WithName("CreateInstance")
 13160                .WithDisplayName("CreateInstance")
 13161                .WithSummary("Creates an instance with a class of a project")
 13162                .WithDescription("Creates an instance with a class of a project")
 13163                .Produces<FieldDefinitionModel>(StatusCodes.Status201Created)
 13164                .Produces<string>(StatusCodes.Status404NotFound)
 13165                .Produces<string>(StatusCodes.Status400BadRequest);
 66
 13167            instancesApi.MapDelete("/{runnableProjectId}/{instanceName}",
 13168                (IInstanceService instanceService,
 13169                [Description("ID of runnable project")] string runnableProjectId,
 13170                [Description("Name of instance")] string instanceName)
 371                    => DeleteInstance.Handle(instanceService, runnableProjectId, instanceName))
 13172                .WithName("DeleteInstance")
 13173                .WithDisplayName("DeleteInstance")
 13174                .WithSummary("Deletes an instance from a project by its name")
 13175                .WithDescription("Deletes an instance from a project by its name")
 13176                .Produces(StatusCodes.Status204NoContent)
 13177                .Produces<string>(StatusCodes.Status404NotFound)
 13178                .Produces<string>(StatusCodes.Status400BadRequest);
 79
 13180            instancesApi.MapGet("/{runnableProjectId}/{instanceName}/{fieldName}/value",
 13181                async (IFieldValueService fieldValueService,
 13182                [Description("ID of runnable project")] string runnableProjectId,
 13183                [Description("Name of instance")] string instanceName,
 13184                [Description("Name of field")] string fieldName)
 1885                    => await GetInstanceField.Handle(fieldValueService, runnableProjectId, instanceName, fieldName))
 13186                .WithName("GetField")
 13187                .WithDisplayName("GetField")
 13188                .WithSummary("Gets the field of an instance from a project by its name")
 13189                .WithDescription("Gets the field of an instance from a project by its name")
 13190                .Produces<FieldModel>(StatusCodes.Status200OK)
 13191                .Produces<string>(StatusCodes.Status404NotFound)
 13192                .Produces<string>(StatusCodes.Status400BadRequest);
 93
 13194            instancesApi.MapPut("/{runnableProjectId}/{instanceName}/{fieldName}/value",
 13195                async (IFieldValueService fieldValueService,
 13196                [Description("ID of runnable project")] string runnableProjectId,
 13197                [Description("Name of instance")] string instanceName,
 13198                [Description("Name of field")] string fieldName,
 13199                [Description("Value of field")][FromBody] FieldValueModel value)
 70100                    => await UpdateInstanceFieldValue.Handle(fieldValueService, runnableProjectId, instanceName, fieldNa
 131101                .WithName("UpdateFieldValue")
 131102                .WithDisplayName("UpdateFieldValue")
 131103                .WithSummary("Updates the value of a field of an instance from a project by its name")
 131104                .WithDescription("Updates the value of a field of an instance from a project by its name")
 131105                .Produces<FieldValueModel>(StatusCodes.Status200OK)
 131106                .Produces<string>(StatusCodes.Status404NotFound)
 131107                .Produces<string>(StatusCodes.Status400BadRequest);
 108
 131109            return app;
 131110        }
 111    }
 112}