< 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_22190969454
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)
 14513        {
 14514            RouteGroupBuilder instancesApi = app.MapGroup("/instances");
 14515            instancesApi.MapGet("/{runnableProjectId}",
 14516                (IInstanceService instanceService,
 14517                [Description("ID of runnable project")] string runnableProjectId)
 218                    => GetInstances.Handle(instanceService, runnableProjectId))
 14519                .WithName("GetInstances")
 14520                .WithDisplayName("GetInstances")
 14521                .WithSummary("Gets the list of instances from a project")
 14522                .WithDescription("Gets the list of instances from a project")
 14523                .Produces<List<FieldDefinitionModel>>(StatusCodes.Status200OK)
 14524                .Produces<string>(StatusCodes.Status404NotFound)
 14525                .Produces<string>(StatusCodes.Status400BadRequest);
 26
 14527            instancesApi.MapPost("/{runnableProjectId}/search",
 14528                (IInstanceService instanceService,
 14529                [Description("ID of runnable project")] string runnableProjectId,
 14530                [FromBody] InstancePagedSearchRequest search)
 131                    => SearchInstances.Handle(instanceService, runnableProjectId, search))
 14532                .WithName("SearchInstances")
 14533                .WithDisplayName("SearchInstances")
 14534                .WithSummary("Searches the list of instances from a project")
 14535                .WithDescription("Searches the list of instances from a project")
 14536                .Produces<PagedSearchResult<FieldDefinitionModel>>(StatusCodes.Status200OK)
 14537                .Produces<string>(StatusCodes.Status404NotFound)
 14538                .Produces<string>(StatusCodes.Status400BadRequest);
 39
 14540            instancesApi.MapGet("/{runnableProjectId}/{instanceName}",
 14541                (IInstanceService instanceService,
 14542                [Description("ID of runnable project")] string runnableProjectId,
 14543                [Description("Name of instance")] string instanceName)
 244                    => GetInstance.Handle(instanceService, runnableProjectId, instanceName))
 14545                .WithName("GetInstance")
 14546                .WithDisplayName("GetInstance")
 14547                .WithSummary("Gets an instance of a project by its name")
 14548                .WithDescription("Gets an instance of a project by its name")
 14549                .Produces<FieldDefinitionModel>(StatusCodes.Status200OK)
 14550                .Produces<string>(StatusCodes.Status404NotFound)
 14551                .Produces<string>(StatusCodes.Status400BadRequest);
 52
 14553            instancesApi.MapPost("/{runnableProjectId}",
 14554                (IInstanceService instanceService,
 14555                [Description("ID of runnable project")] string runnableProjectId,
 14556                [Description("Instance creation request")][FromBody] InstanceModel createRequest,
 14557                [FromQuery] bool addToRunningInstances = true)
 558                    => CreateInstance.Handle(instanceService, runnableProjectId, createRequest, addToRunningInstances))
 14559                .WithName("CreateInstance")
 14560                .WithDisplayName("CreateInstance")
 14561                .WithSummary("Creates an instance with a class of a project")
 14562                .WithDescription("Creates an instance with a class of a project")
 14563                .Produces<FieldDefinitionModel>(StatusCodes.Status201Created)
 14564                .Produces<string>(StatusCodes.Status404NotFound)
 14565                .Produces<string>(StatusCodes.Status400BadRequest);
 66
 14567            instancesApi.MapDelete("/{runnableProjectId}/{instanceName}",
 14568                (IInstanceService instanceService,
 14569                [Description("ID of runnable project")] string runnableProjectId,
 14570                [Description("Name of instance")] string instanceName)
 371                    => DeleteInstance.Handle(instanceService, runnableProjectId, instanceName))
 14572                .WithName("DeleteInstance")
 14573                .WithDisplayName("DeleteInstance")
 14574                .WithSummary("Deletes an instance from a project by its name")
 14575                .WithDescription("Deletes an instance from a project by its name")
 14576                .Produces(StatusCodes.Status204NoContent)
 14577                .Produces<string>(StatusCodes.Status404NotFound)
 14578                .Produces<string>(StatusCodes.Status400BadRequest);
 79
 14580            instancesApi.MapGet("/{runnableProjectId}/{instanceName}/{fieldName}/value",
 14581                async (IFieldValueService fieldValueService,
 14582                [Description("ID of runnable project")] string runnableProjectId,
 14583                [Description("Name of instance")] string instanceName,
 14584                [Description("Name of field")] string fieldName)
 3185                    => await GetInstanceField.Handle(fieldValueService, runnableProjectId, instanceName, fieldName))
 14586                .WithName("GetField")
 14587                .WithDisplayName("GetField")
 14588                .WithSummary("Gets the field of an instance from a project by its name")
 14589                .WithDescription("Gets the field of an instance from a project by its name")
 14590                .Produces<FieldModel>(StatusCodes.Status200OK)
 14591                .Produces<string>(StatusCodes.Status404NotFound)
 14592                .Produces<string>(StatusCodes.Status400BadRequest);
 93
 14594            instancesApi.MapPut("/{runnableProjectId}/{instanceName}/{fieldName}/value",
 14595                async (IFieldValueService fieldValueService,
 14596                [Description("ID of runnable project")] string runnableProjectId,
 14597                [Description("Name of instance")] string instanceName,
 14598                [Description("Name of field")] string fieldName,
 14599                [Description("Value of field")][FromBody] FieldValueModel value)
 80100                    => await UpdateInstanceFieldValue.Handle(fieldValueService, runnableProjectId, instanceName, fieldNa
 145101                .WithName("UpdateFieldValue")
 145102                .WithDisplayName("UpdateFieldValue")
 145103                .WithSummary("Updates the value of a field of an instance from a project by its name")
 145104                .WithDescription("Updates the value of a field of an instance from a project by its name")
 145105                .Produces<FieldValueModel>(StatusCodes.Status200OK)
 145106                .Produces<string>(StatusCodes.Status404NotFound)
 145107                .Produces<string>(StatusCodes.Status400BadRequest);
 108
 145109            return app;
 145110        }
 111    }
 112}