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-1117] - Admin API should provide default auth strategy for resource claims #218

Closed
wants to merge 63 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
b0a520b
[ADMINAPI-1077] Add Get/Post endpoints for healthchecks (#177)
dfernandez-gap Nov 5, 2024
f2a3d5f
[ADMINAPI-1060] - Admin Console - Instances endpoint (/adminconsole/I…
DavidJGapCR Nov 6, 2024
b80950b
[ADMINAPI-1065] Add tenants endpoints (#179)
ricardogamboagap Nov 7, 2024
66351ca
[ADMINAPI-1061] Admin Console - Permissions endpoints (/adminconsole/…
jleiva-gap Nov 11, 2024
17e0083
[ADMINAPI-1061] Admin Console - Permissions endpoints (/adminconsole/…
jleiva-gap Nov 12, 2024
da7ed2a
[ADMINAPI-1066] Add UserProfile GET/POST endpoints (#186)
dfernandez-gap Nov 13, 2024
0e3a43d
[ADMINAPI-1063] - Admin Console - Steps endpoint (/adminconsole/steps…
jleiva-gap Nov 15, 2024
250e8ba
[ADMINAPI-1088] Add on-pr-dockerfile-ac workflow (#184)
ricardogamboagap Nov 19, 2024
230e194
[ADMINAPI-1090] Multitenant in the Adminconsole endpoints (#188)
jagudelo-gap Nov 21, 2024
94b013c
[ADMINAPI-1088] change admin console section name (#189)
ricardogamboagap Nov 21, 2024
7335cb8
Fix CORS configuration for Admin Console (#191)
jagudelo-gap Nov 25, 2024
6b37068
[ADMINAPI-1091] Open API documentation version 2.3.0 (#190)
github-actions[bot] Nov 26, 2024
47c1856
Fixes to include the adminconsole endpoints (#196)
jagudelo-gap Nov 26, 2024
1e3ea49
[ADMINAPI-1085]: Create a shared library code for Admin API (#194)
jleiva-gap Nov 28, 2024
3950a01
[ADMINAPI-1081] - Change content type message on error and add e2e te…
ricardogamboagap Dec 3, 2024
4bc5235
[ADMINAPI-1096] Implementation for adminconsole/tenants (#199)
jagudelo-gap Dec 10, 2024
81c022f
[ADMINAPI-1098] - Create Instances (#202)
jagudelo-gap Dec 17, 2024
28d024e
[ADMINAPI-1100] - Finalize adminconsole/instances endpoints (#201)
dfernandez-gap Dec 17, 2024
36daf24
Fix merge conflict (#203)
jagudelo-gap Dec 17, 2024
541697a
[ADMINAPI-1100] - fix (#205)
jagudelo-gap Dec 18, 2024
5ede5aa
[AC-113] - Creates Admin Console ClaimSet. (#204)
DavidJGapCR Dec 23, 2024
7b82de1
[ADMINAPI-1107] Update Admin API Admin Console endpoints to have sam…
ricardogamboagap Dec 23, 2024
2b76b24
[ADMIN-API 1107] Add OIDC config to authentication sectio (#207)
ricardogamboagap Dec 31, 2024
fef9c1a
[AC-113] - Creates Admin Console ClaimSet - Multitenant fix (#208)
DavidJGapCR Dec 31, 2024
24102c5
[AC-116] Create Health Check Credentials for Instances on Startup (#216)
jleiva-gap Jan 23, 2025
ae730b8
AC-116 Create Health Check Credentials for Instances on Startup (FIX)…
jleiva-gap Jan 24, 2025
48eb441
AC-116 Create Health Check Credentials for Instances on Startup (#220)
jleiva-gap Jan 24, 2025
132a9b0
Add features
dfernandez-gap Jan 20, 2025
0b58e85
Add ResourceClaimActions and ResourceClaimActionAuthStrategies endpoints
dfernandez-gap Jan 24, 2025
8478cab
Fix appsettings
dfernandez-gap Jan 24, 2025
bc3b5e9
Add Integration Tests
dfernandez-gap Jan 24, 2025
11f8519
[ADMINAPI-1077] Add Get/Post endpoints for healthchecks (#177)
dfernandez-gap Nov 5, 2024
644d360
[ADMINAPI-1060] - Admin Console - Instances endpoint (/adminconsole/I…
DavidJGapCR Nov 6, 2024
7b46971
[ADMINAPI-1065] Add tenants endpoints (#179)
ricardogamboagap Nov 7, 2024
1bb1d18
[ADMINAPI-1061] Admin Console - Permissions endpoints (/adminconsole/…
jleiva-gap Nov 11, 2024
36d370e
[ADMINAPI-1061] Admin Console - Permissions endpoints (/adminconsole/…
jleiva-gap Nov 12, 2024
cdd866c
[ADMINAPI-1066] Add UserProfile GET/POST endpoints (#186)
dfernandez-gap Nov 13, 2024
e12425b
[ADMINAPI-1063] - Admin Console - Steps endpoint (/adminconsole/steps…
jleiva-gap Nov 15, 2024
02fb19d
[ADMINAPI-1088] Add on-pr-dockerfile-ac workflow (#184)
ricardogamboagap Nov 19, 2024
15292d6
[ADMINAPI-1090] Multitenant in the Adminconsole endpoints (#188)
jagudelo-gap Nov 21, 2024
9f7fe9a
[ADMINAPI-1088] change admin console section name (#189)
ricardogamboagap Nov 21, 2024
aa342cf
Fix CORS configuration for Admin Console (#191)
jagudelo-gap Nov 25, 2024
7c7743f
[ADMINAPI-1091] Open API documentation version 2.3.0 (#190)
github-actions[bot] Nov 26, 2024
ff3225d
Fixes to include the adminconsole endpoints (#196)
jagudelo-gap Nov 26, 2024
9889bf1
[ADMINAPI-1085]: Create a shared library code for Admin API (#194)
jleiva-gap Nov 28, 2024
3434e95
[ADMINAPI-1081] - Change content type message on error and add e2e te…
ricardogamboagap Dec 3, 2024
a9eac5d
[ADMINAPI-1096] Implementation for adminconsole/tenants (#199)
jagudelo-gap Dec 10, 2024
17fa066
[ADMINAPI-1098] - Create Instances (#202)
jagudelo-gap Dec 17, 2024
5a1cefa
[ADMINAPI-1100] - Finalize adminconsole/instances endpoints (#201)
dfernandez-gap Dec 17, 2024
b33651f
Fix merge conflict (#203)
jagudelo-gap Dec 17, 2024
2064983
[ADMINAPI-1100] - fix (#205)
jagudelo-gap Dec 18, 2024
86da1a8
[AC-113] - Creates Admin Console ClaimSet. (#204)
DavidJGapCR Dec 23, 2024
a96bbe6
[ADMINAPI-1107] Update Admin API Admin Console endpoints to have sam…
ricardogamboagap Dec 23, 2024
fcbe84c
[ADMIN-API 1107] Add OIDC config to authentication sectio (#207)
ricardogamboagap Dec 31, 2024
2be08b2
[AC-113] - Creates Admin Console ClaimSet - Multitenant fix (#208)
DavidJGapCR Dec 31, 2024
3fb80c6
[AC-116] Create Health Check Credentials for Instances on Startup (#216)
jleiva-gap Jan 23, 2025
8890b8e
AC-116 Create Health Check Credentials for Instances on Startup (FIX)…
jleiva-gap Jan 24, 2025
3dc4b1e
AC-116 Create Health Check Credentials for Instances on Startup (#220)
jleiva-gap Jan 24, 2025
599bfba
Add features
dfernandez-gap Jan 20, 2025
b8f2711
Add ResourceClaimActions and ResourceClaimActionAuthStrategies endpoints
dfernandez-gap Jan 24, 2025
afa1a9d
Fix appsettings
dfernandez-gap Jan 24, 2025
1aaf981
Add Integration Tests
dfernandez-gap Jan 24, 2025
12bb844
Merge branch 'ADMINAPI-1117' of https://github.com/Ed-Fi-Alliance-OSS…
dfernandez-gap Jan 27, 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

Choose a reason for hiding this comment

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

This is fine for a short term solution, but you don't need it anymore. The Dockerfile now has a capability for introducing context in a different directory. NO NEED TO CHANGE IN THIS PULL REQUEST 😄 .

Take a look at the DMS dockerfile, lines 18-20. They allow copying files from a different context, other than the current directory.

You provide the additional context at the command line:

&docker buildx build -t $dockerTagDMS -f Dockerfile . --build-context parentdir=../

Or in a docker-compose file:

services:
  dms:
    build:
      context: ../../src/dms/
      additional_contexts:
        parentdir: ../../src/


- 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
95 changes: 95 additions & 0 deletions .github/workflows/on-pullrequest-dockerfile-ac.yml

Choose a reason for hiding this comment

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

What is different about this workflow compared to on-pullrequest-dockerfile.yml?

Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# 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.

name: On Pull Request - Dockerfile - Admin Console

on:
push:
branches:
- adminapi23-rc.*

Choose a reason for hiding this comment

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

Should this change to main?

Should there be an on-pullrequest trigger?

workflow_dispatch:

env:
DOCKER_USERNAME: ${{ vars.DOCKER_USERNAME }}
DOCKER_HUB_TOKEN: ${{ secrets.DOCKER_HUB_TOKEN }}
IMAGE_NAME: ${{ vars.IMAGE_NAME }}

permissions: read-all

jobs:
docker-analysis:
runs-on: ubuntu-latest
permissions:
security-events: write
pull-requests: write
strategy:
fail-fast: false
matrix:
dockerfile:
[
{ name: "development", path: "Docker/dev.pgsql.Dockerfile", type: "local" }
]
steps:
- name: Checkout code
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: Set IMAGE_TAG
id: set-image-tag
run: |
if [ "${{ github.event_name }}" == "pull_request" ]; then
echo "IMAGE_TAG=${{ github.base_ref }}" >> $GITHUB_ENV
else
echo "IMAGE_TAG=${{ github.ref_name }}" >> $GITHUB_ENV
fi

- name: Copy application folder to docker context
if: ${{ matrix.dockerfile.type == 'local' }}
run: |
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

- uses: hadolint/hadolint-action@54c9adbab1582c2ef04b2016b760714a4bfde3cf # v3.1.0
name: Run Linter on ${{ matrix.dockerfile.name }} Dockerfile
with:
dockerfile: ${{ matrix.dockerfile.path }}
failure-threshold: error

- name: Log in to Docker Hub
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
with:
username: ${{ env.DOCKER_USERNAME }}
password: ${{ env.DOCKER_HUB_TOKEN }}

- name: Build
run: |
path=${{matrix.dockerfile.path}}
folder=${path%/*}
cd $folder
dockerfile=$(echo ${{matrix.dockerfile.path}} | awk -F"/" '{print $NF}')

docker build -f $dockerfile -t ${{ matrix.dockerfile.name }} --build-arg="VERSION=${{ env.IMAGE_TAG }}" .

- name: Analyze
uses: docker/scout-action@67eb1afe777307506aaecb9acd9a0e0389cb99ae # v1.5.0
with:
command: cves
image: local://${{ matrix.dockerfile.name }}
sarif-file: sarif-${{ matrix.dockerfile.name }}.output.json
summary: true

- name: Push Image on Docker Hub
run: |
docker image tag ${{ matrix.dockerfile.name }} ${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }}
docker push ${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }}

- name: Upload SARIF result
id: upload-sarif
if: ${{ github.event_name != 'pull_request_target' }}
uses: github/codeql-action/upload-sarif@cf7e9f23492505046de9a37830c3711dd0f25bb3 #codeql-bundle-v2.16.2
with:
sarif_file: sarif-${{ matrix.dockerfile.name }}.output.json
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>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
</PropertyGroup>

<ItemGroup>
<Compile Remove="Mockdata\**" />
<EmbeddedResource Remove="Mockdata\**" />
<None Remove="Mockdata\**" />
</ItemGroup>

Choose a reason for hiding this comment

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

Good call - thank you for excluding the mock data.

I wonder if we should simply delete the files before merging to main?

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

Choose a reason for hiding this comment

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

Is this actually going to be GET /adminconsole/healthcheck? Or will it be GET /healthcheck?

.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;
}
}
}
}
Loading
Loading