-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ADMINAPI-1159] - AdminConsole branch merge to main #232
Changes from all commits
13e11e1
8af2206
a060604
9d2d2b4
485fa5d
ebbb359
1209d92
2920cee
f2ff47b
153b058
e08e7fe
cdfab41
234ceb4
5c60abe
7f4cf9b
0f8aa4a
bf6bcb3
1b1c4fd
0c38a0f
50c5513
2d5b8ad
b82792c
79286fc
6b449cf
6b17e00
48469c1
d412876
d1d5cf6
cd72a61
ab05d9b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,63 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"> | ||
<TreatWarningsAsErrors>False</TreatWarningsAsErrors> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'"> | ||
<TreatWarningsAsErrors>False</TreatWarningsAsErrors> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<Compile Remove="Mockdata\**" /> | ||
<EmbeddedResource Remove="Mockdata\**" /> | ||
<None Remove="Mockdata\**" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Asp.Versioning.Http" Version="8.1.0" /> | ||
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="8.0.1" /> | ||
<PackageReference Include="AutoMapper" Version="13.0.1" /> | ||
<PackageReference Include="FluentValidation.AspNetCore" Version="11.3.0" /> | ||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.7" /> | ||
<PackageReference Include="Microsoft.EntityFrameworkCore.Abstractions" Version="8.0.8" /> | ||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.7"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
</PackageReference> | ||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.7" /> | ||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.7"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
</PackageReference> | ||
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="9.0.0" /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is missing the Roslyn and SonarSource analyzers. As with the note above, about treating warnings as errors, we need to get those into the code very soon. But does not have to be in this pull request. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
<PackageReference Include="Microsoft.NETCore.App" Version="2.1.30" /> | ||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" /> | ||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.7.0" /> | ||
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="6.7.0" /> | ||
<PackageReference Include="Npgsql" Version="8.0.6" /> | ||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.4" /> | ||
<PackageReference Include="Rijndael256" Version="3.2.0" /> | ||
<PackageReference Include="Swashbuckle.AspNetCore" Version="7.1.0" /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this library truly required? It has not been updated since 2017. That is a bit scary. |
||
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="7.1.0" /> | ||
<PackageReference Include="Swashbuckle.AspNetCore.Filters" Version="8.0.2" /> | ||
<PackageReference Include="System.Text.Json" Version="9.0.0" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\EdFi.Ods.AdminApi.Common\EdFi.Ods.AdminApi.Common.csproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Folder Include="Mockdata\" /> | ||
<None Update="Infrastructure\DataAccess\Artifacts\Security\MsSql\SQL\AdminConsoleClaimsetUp.sql"> | ||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||
</None> | ||
<None Update="Infrastructure\DataAccess\Artifacts\Security\PgSql\SQL\AdminConsoleClaimsetUp.sql"> | ||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||
</None> | ||
</ItemGroup> | ||
|
||
</Project> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// Licensed to the Ed-Fi Alliance under one or more agreements. | ||
// The Ed-Fi Alliance licenses this file to you under the Apache License, Version 2.0. | ||
// See the LICENSE and NOTICES files in the project root for more information. | ||
|
||
using System.ComponentModel.DataAnnotations; | ||
using EdFi.Ods.AdminApi.AdminConsole.Infrastructure.Services.HealthChecks.Commands; | ||
using EdFi.Ods.AdminApi.Common.Features; | ||
using EdFi.Ods.AdminApi.Common.Infrastructure; | ||
using FluentValidation; | ||
using Microsoft.AspNetCore.Http; | ||
using Microsoft.AspNetCore.Routing; | ||
using Newtonsoft.Json; | ||
using Swashbuckle.AspNetCore.Annotations; | ||
|
||
namespace EdFi.Ods.AdminApi.AdminConsole.Features.Healthcheck; | ||
public class AddHealthCheck : IFeature | ||
{ | ||
public void MapEndpoints(IEndpointRouteBuilder endpoints) | ||
{ | ||
AdminApiEndpointBuilder.MapPost(endpoints, "/healthcheck", Execute) | ||
.WithRouteOptions(b => b.WithResponseCode(201)) | ||
.BuildForVersions(AdminApiVersions.AdminConsole); | ||
} | ||
|
||
public async Task<IResult> Execute(Validator validator, IAddHealthCheckCommand addHealthCheckCommand, AddHealthCheckRequest request) | ||
{ | ||
await validator.GuardAsync(request); | ||
var addedHealthCheck = await addHealthCheckCommand.Execute(request); | ||
return Results.Created($"/healthcheck/{addedHealthCheck.DocId}", null); | ||
} | ||
|
||
[SwaggerSchema(Title = nameof(AddHealthCheckRequest))] | ||
public class AddHealthCheckRequest : IAddHealthCheckModel | ||
{ | ||
[Required] | ||
public int DocId { get; set; } | ||
[Required] | ||
public int InstanceId { get; set; } | ||
[Required] | ||
public int EdOrgId { get; set; } | ||
[Required] | ||
public int TenantId { get; set; } | ||
[Required] | ||
public string Document { get; set; } | ||
} | ||
|
||
public class Validator : AbstractValidator<AddHealthCheckRequest> | ||
{ | ||
public Validator() | ||
{ | ||
RuleFor(m => m.InstanceId) | ||
.NotNull(); | ||
|
||
RuleFor(m => m.EdOrgId) | ||
.NotNull(); | ||
|
||
RuleFor(m => m.TenantId) | ||
.NotNull(); | ||
|
||
RuleFor(m => m.Document) | ||
.NotNull() | ||
.Must(BeValidDocument).WithMessage("Document must be a valid JSON."); | ||
} | ||
|
||
private bool BeValidDocument(string document) | ||
{ | ||
try | ||
{ | ||
Newtonsoft.Json.Linq.JToken.Parse(document); | ||
return true; | ||
} | ||
catch (Newtonsoft.Json.JsonReaderException) | ||
{ | ||
return false; | ||
} | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please change to
True
. Or, if that introduces too many warnings to fix right away in this ticket, please create a new ticket to put this to the proper setting, and then we need to prioritize addressing this soon.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll create a ticket to address the errors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ADMINAPI-1161
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you