Skip to content
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

Merged
merged 30 commits into from
Feb 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
13e11e1
[ADMINAPI-1077] Add Get/Post endpoints for healthchecks (#177)
dfernandez-gap Nov 5, 2024
8af2206
[ADMINAPI-1060] - Admin Console - Instances endpoint (/adminconsole/I…
DavidJGapCR Nov 6, 2024
a060604
[ADMINAPI-1065] Add tenants endpoints (#179)
ricardogamboagap Nov 7, 2024
9d2d2b4
[ADMINAPI-1061] Admin Console - Permissions endpoints (/adminconsole/…
jleiva-gap Nov 11, 2024
485fa5d
[ADMINAPI-1061] Admin Console - Permissions endpoints (/adminconsole/…
jleiva-gap Nov 12, 2024
ebbb359
[ADMINAPI-1066] Add UserProfile GET/POST endpoints (#186)
dfernandez-gap Nov 13, 2024
1209d92
[ADMINAPI-1063] - Admin Console - Steps endpoint (/adminconsole/steps…
jleiva-gap Nov 15, 2024
2920cee
[ADMINAPI-1088] Add on-pr-dockerfile-ac workflow (#184)
ricardogamboagap Nov 19, 2024
f2ff47b
[ADMINAPI-1090] Multitenant in the Adminconsole endpoints (#188)
jagudelo-gap Nov 21, 2024
153b058
[ADMINAPI-1088] change admin console section name (#189)
ricardogamboagap Nov 21, 2024
e08e7fe
Fix CORS configuration for Admin Console (#191)
jagudelo-gap Nov 25, 2024
cdfab41
[ADMINAPI-1091] Open API documentation version 2.3.0 (#190)
github-actions[bot] Nov 26, 2024
234ceb4
Fixes to include the adminconsole endpoints (#196)
jagudelo-gap Nov 26, 2024
5c60abe
[ADMINAPI-1085]: Create a shared library code for Admin API (#194)
jleiva-gap Nov 28, 2024
7f4cf9b
[ADMINAPI-1081] - Change content type message on error and add e2e te…
ricardogamboagap Dec 3, 2024
0f8aa4a
[ADMINAPI-1096] Implementation for adminconsole/tenants (#199)
jagudelo-gap Dec 10, 2024
bf6bcb3
[ADMINAPI-1098] - Create Instances (#202)
jagudelo-gap Dec 17, 2024
1b1c4fd
[ADMINAPI-1100] - Finalize adminconsole/instances endpoints (#201)
dfernandez-gap Dec 17, 2024
0c38a0f
Fix merge conflict (#203)
jagudelo-gap Dec 17, 2024
50c5513
[ADMINAPI-1100] - fix (#205)
jagudelo-gap Dec 18, 2024
2d5b8ad
[AC-113] - Creates Admin Console ClaimSet. (#204)
DavidJGapCR Dec 23, 2024
b82792c
[ADMINAPI-1107] Update Admin API Admin Console endpoints to have sam…
ricardogamboagap Dec 23, 2024
79286fc
[ADMIN-API 1107] Add OIDC config to authentication sectio (#207)
ricardogamboagap Dec 31, 2024
6b449cf
[AC-113] - Creates Admin Console ClaimSet - Multitenant fix (#208)
DavidJGapCR Dec 31, 2024
6b17e00
[AC-116] Create Health Check Credentials for Instances on Startup (#216)
jleiva-gap Jan 23, 2025
48469c1
AC-116 Create Health Check Credentials for Instances on Startup (FIX)…
jleiva-gap Jan 24, 2025
d412876
AC-116 Create Health Check Credentials for Instances on Startup (#220)
jleiva-gap Jan 24, 2025
d1d5cf6
[ADMIN-API 1122] Encrypt connection string in EdFi_Admin database (#217)
ricardogamboagap Jan 31, 2025
cd72a61
Docker Appsettings EncryptionKey (#224)
ricardogamboagap Feb 4, 2025
ab05d9b
Fixes after rebase
DavidJGapCR Feb 18, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 3 additions & 0 deletions .github/workflows/api-e2e-mssql-multitenant.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ jobs:
- name: Copy admin console folder to docker context
run: cp -r ../EdFi.Ods.AdminApi.AdminConsole ../../Docker/Application

- name: Copy admin api common folder to docker context
run: cp -r ../EdFi.Ods.AdminApi.Common ../../Docker/Application

- name: Copy nuget config to docker context
run: cp ../NuGet.Config ../../Docker/Application

Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/api-e2e-mssql-singletenant.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ jobs:
- name: Copy admin console folder to docker context
run: cp -r ../EdFi.Ods.AdminApi.AdminConsole ../../Docker/Application

- name: Copy admin api common folder to docker context
run: cp -r ../EdFi.Ods.AdminApi.Common ../../Docker/Application

- name: Copy nuget config to docker context
run: cp ../NuGet.Config ../../Docker/Application

Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/api-e2e-pgsql-multitenant.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ jobs:
- name: Copy admin console folder to docker context
run: cp -r ../EdFi.Ods.AdminApi.AdminConsole ../../Docker/Application

- name: Copy admin api common folder to docker context
run: cp -r ../EdFi.Ods.AdminApi.Common ../../Docker/Application

- name: Copy nuget config to docker context
run: cp ../NuGet.Config ../../Docker/Application

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/api-e2e-pgsql-singletenant.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ jobs:
mkdir ../../Docker/Application
cp -r ../EdFi.Ods.AdminApi ../../Docker/Application
cp -r ../EdFi.Ods.AdminApi.AdminConsole ../../Docker/Application
cp -r ../EdFi.Ods.AdminApi.Common ../../Docker/Application

- name: Copy nuget config to docker context
run: cp ../NuGet.Config ../../Docker/Application
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/on-pullrequest-dockerfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ jobs:
mkdir Docker/Application
cp -r ./Application/EdFi.Ods.AdminApi ./Docker/Application
cp -r ./Application/EdFi.Ods.AdminApi.AdminConsole ./Docker/Application
cp -r ./Application/EdFi.Ods.AdminApi.Common ./Docker/Application
cp ./Application/NuGet.Config ./Docker/Application

- name: Set Version Numbers
Expand Down
23 changes: 22 additions & 1 deletion Application/Ed-Fi-ODS-AdminApi.sln
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "IntegrationTests", "Integra
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EdFi.Ods.AdminApi.DBTests", "EdFi.Ods.AdminApi.DBTests\EdFi.Ods.AdminApi.DBTests.csproj", "{73259EC2-4AA0-40C2-9C60-8AB1BF369CF5}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EdFi.Ods.AdminApi.AdminConsole", "EdFi.Ods.AdminApi.AdminConsole\EdFi.Ods.AdminApi.AdminConsole.csproj", "{0F34C4F6-F7A2-442A-9E54-FCBD9A00F914}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EdFi.Ods.AdminApi.AdminConsole", "EdFi.Ods.AdminApi.AdminConsole\EdFi.Ods.AdminApi.AdminConsole.csproj", "{0F34C4F6-F7A2-442A-9E54-FCBD9A00F914}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EdFi.Ods.AdminConsole.DBTests", "EdFi.Ods.AdminConsole.DBTests\EdFi.Ods.AdminConsole.DBTests.csproj", "{A2DC17AC-66C2-4119-BB47-4266E8ACB055}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EdFi.Ods.AdminApi.Common", "EdFi.Ods.AdminApi.Common\EdFi.Ods.AdminApi.Common.csproj", "{C9C86866-562B-4EA3-9AAC-F3297F0754D6}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -61,13 +65,30 @@ Global
{0F34C4F6-F7A2-442A-9E54-FCBD9A00F914}.Release|Any CPU.Build.0 = Release|Any CPU
{0F34C4F6-F7A2-442A-9E54-FCBD9A00F914}.Release|x64.ActiveCfg = Release|Any CPU
{0F34C4F6-F7A2-442A-9E54-FCBD9A00F914}.Release|x64.Build.0 = Release|Any CPU
{A2DC17AC-66C2-4119-BB47-4266E8ACB055}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A2DC17AC-66C2-4119-BB47-4266E8ACB055}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A2DC17AC-66C2-4119-BB47-4266E8ACB055}.Debug|x64.ActiveCfg = Debug|Any CPU
{A2DC17AC-66C2-4119-BB47-4266E8ACB055}.Debug|x64.Build.0 = Debug|Any CPU
{A2DC17AC-66C2-4119-BB47-4266E8ACB055}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A2DC17AC-66C2-4119-BB47-4266E8ACB055}.Release|Any CPU.Build.0 = Release|Any CPU
{A2DC17AC-66C2-4119-BB47-4266E8ACB055}.Release|x64.ActiveCfg = Release|Any CPU
{A2DC17AC-66C2-4119-BB47-4266E8ACB055}.Release|x64.Build.0 = Release|Any CPU
{C9C86866-562B-4EA3-9AAC-F3297F0754D6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C9C86866-562B-4EA3-9AAC-F3297F0754D6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C9C86866-562B-4EA3-9AAC-F3297F0754D6}.Debug|x64.ActiveCfg = Debug|Any CPU
{C9C86866-562B-4EA3-9AAC-F3297F0754D6}.Debug|x64.Build.0 = Debug|Any CPU
{C9C86866-562B-4EA3-9AAC-F3297F0754D6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C9C86866-562B-4EA3-9AAC-F3297F0754D6}.Release|Any CPU.Build.0 = Release|Any CPU
{C9C86866-562B-4EA3-9AAC-F3297F0754D6}.Release|x64.ActiveCfg = Release|Any CPU
{C9C86866-562B-4EA3-9AAC-F3297F0754D6}.Release|x64.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{F62C9CF6-A632-4894-B61A-674198DAB86E} = {9A9D18B4-718D-4681-BAFE-A1C42E18A7CC}
{73259EC2-4AA0-40C2-9C60-8AB1BF369CF5} = {D8A26B59-6DAD-4046-9DDE-00D2CFDAE9B6}
{A2DC17AC-66C2-4119-BB47-4266E8ACB055} = {D8A26B59-6DAD-4046-9DDE-00D2CFDAE9B6}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {30CF2BE4-58CA-4598-9B59-D334FC971A0F}
Expand Down
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>

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.

Copy link
Author

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.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link

@stephenfuqua stephenfuqua Feb 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you


<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" />

Choose a reason for hiding this comment

The 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.

Copy link
Author

Choose a reason for hiding this comment

The 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" />

Choose a reason for hiding this comment

The 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;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,51 +4,52 @@
// See the LICENSE and NOTICES files in the project root for more information.

using Newtonsoft.Json;
using Swashbuckle.AspNetCore.Annotations;

namespace EdFi.Ods.AdminApi.AdminConsole.Features.Healthcheck
namespace EdFi.Ods.AdminApi.AdminConsole.Features.Healthcheck;

[SwaggerSchema(Title = "HealthCheck")]
public class HealthCheckModel
{
public class HealthcheckModel
{
[JsonProperty("localEducationAgencyId")]
public long LocalEducationAgencyId { get; set; }
[JsonProperty("localEducationAgencyId")]
public long LocalEducationAgencyId { get; set; }

[JsonProperty("studentSpecialEducationProgramAssociations")]
public long StudentSpecialEducationProgramAssociations { get; set; }
[JsonProperty("studentSpecialEducationProgramAssociations")]
public long StudentSpecialEducationProgramAssociations { get; set; }

[JsonProperty("studentDisciplineIncidentBehaviorAssociations")]
public long StudentDisciplineIncidentBehaviorAssociations { get; set; }
[JsonProperty("studentDisciplineIncidentBehaviorAssociations")]
public long StudentDisciplineIncidentBehaviorAssociations { get; set; }

[JsonProperty("studentSchoolAssociations")]
public long StudentSchoolAssociations { get; set; }
[JsonProperty("studentSchoolAssociations")]
public long StudentSchoolAssociations { get; set; }

[JsonProperty("studentSchoolAttendanceEvents")]
public long StudentSchoolAttendanceEvents { get; set; }
[JsonProperty("studentSchoolAttendanceEvents")]
public long StudentSchoolAttendanceEvents { get; set; }

[JsonProperty("studentSectionAssociations")]
public long StudentSectionAssociations { get; set; }
[JsonProperty("studentSectionAssociations")]
public long StudentSectionAssociations { get; set; }

[JsonProperty("staffEducationOrganizationAssignmentAssociations")]
public long StaffEducationOrganizationAssignmentAssociations { get; set; }
[JsonProperty("staffEducationOrganizationAssignmentAssociations")]
public long StaffEducationOrganizationAssignmentAssociations { get; set; }

[JsonProperty("staffEducationOrganizationEmploymentAssociations")]
public long StaffEducationOrganizationEmploymentAssociations { get; set; }
[JsonProperty("staffEducationOrganizationEmploymentAssociations")]
public long StaffEducationOrganizationEmploymentAssociations { get; set; }

[JsonProperty("staffSectionAssociations")]
public long StaffSectionAssociations { get; set; }
[JsonProperty("staffSectionAssociations")]
public long StaffSectionAssociations { get; set; }

[JsonProperty("courseTranscripts")]
public long CourseTranscripts { get; set; }
[JsonProperty("courseTranscripts")]
public long CourseTranscripts { get; set; }

[JsonProperty("basicReportingPeriodAttendances")]
public long BasicReportingPeriodAttendances { get; set; }
[JsonProperty("basicReportingPeriodAttendances")]
public long BasicReportingPeriodAttendances { get; set; }

[JsonProperty("sections")]
public long Sections { get; set; }
[JsonProperty("sections")]
public long Sections { get; set; }

[JsonProperty("reportingPeriodExts")]
public long ReportingPeriodExts { get; set; }
[JsonProperty("reportingPeriodExts")]
public long ReportingPeriodExts { get; set; }

[JsonProperty("healthy")]
public bool Healthy { get; set; }
}
[JsonProperty("healthy")]
public bool Healthy { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,41 @@
// 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 EdFi.Ods.AdminApi.AdminConsole.Features.UserProfiles;
using System.Text.Json;
using AutoMapper;
using EdFi.Ods.AdminApi.AdminConsole.Infrastructure.DataAccess.Models;
using EdFi.Ods.AdminApi.AdminConsole.Infrastructure.Services.HealthChecks.Queries;
using EdFi.Ods.AdminApi.Common.Features;
using EdFi.Ods.AdminApi.Common.Infrastructure;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Routing;
using Newtonsoft.Json;

namespace EdFi.Ods.AdminApi.AdminConsole.Features.Healthcheck
namespace EdFi.Ods.AdminApi.AdminConsole.Features.Healthcheck;

public class ReadHealthcheck : IFeature
{
public class ReadHealthcheck : IFeature
public void MapEndpoints(IEndpointRouteBuilder endpoints)
{
public void MapEndpoints(IEndpointRouteBuilder endpoints)
{
AdminApiAdminConsoleEndpointBuilder.MapGet(endpoints, "/healthcheck", GetHealthcheck)
.BuildForVersions();
}
AdminApiEndpointBuilder.MapGet(endpoints, "/healthcheck", GetHealthchecks)
.BuildForVersions(AdminApiVersions.AdminConsole);

AdminApiEndpointBuilder.MapGet(endpoints, "/healthcheck/{tenantId}", GetHealthcheck)
.BuildForVersions(AdminApiVersions.AdminConsole);
}

internal Task<IResult> GetHealthcheck()
internal async Task<IResult> GetHealthcheck(IMapper mapper, IGetHealthCheckQuery getHealthCheckQuery, int tenantId)
{
var healthChecks = await getHealthCheckQuery.Execute(tenantId);
if(healthChecks != null)
{
using (StreamReader r = new StreamReader("Mockdata/data-healthcheck.json"))
{
string json = r.ReadToEnd();
HealthcheckModel? result = JsonConvert.DeserializeObject<HealthcheckModel>(json);
return Task.FromResult(Results.Ok(result));
}
return Results.Ok(healthChecks);
}
return Results.NotFound();
}

internal async Task<IResult> GetHealthchecks(IMapper mapper, IGetHealthChecksQuery getHealthChecksQuery)
{
var healthChecks = await getHealthChecksQuery.Execute();
return Results.Ok(healthChecks);
}
}
Loading
Loading