Skip to content

add validation for data origins #773

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

Merged
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@

[assembly: AssemblyFileVersion("0.0.0.0")]
[assembly: AssemblyVersion("0.0.0.0")]
[assembly: AssemblyInformationalVersion("0.0.0-development")]
[assembly: AssemblyInformationalVersion("0.0.0-development")]
14 changes: 14 additions & 0 deletions src/Monai.Deploy.WorkflowManager.sln
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Monai.Deploy.WorkflowManage
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Monai.Deploy.WorkflowManager.Common.Tests", "..\tests\UnitTests\Common.Tests\Monai.Deploy.WorkflowManager.Common.Tests.csproj", "{75A4AEDA-0386-4B2D-9DBA-BC9AE733660E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Monai.Deploy.WorkflowManager.Services", "WorkflowManager\Monai.Deploy.WorkflowManager.Services\Monai.Deploy.WorkflowManager.Services.csproj", "{526FF10C-1C7F-4C26-8E8A-D7ACD65F5467}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Monai.Deploy.WorkflowManager.Services.Tests", "..\tests\UnitTests\WorkflowManager.Services.Tests\Monai.Deploy.WorkflowManager.Services.Tests.csproj", "{0D40F7D6-3747-4280-8EB3-9F3A18AC1125}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -228,6 +232,14 @@ Global
{75A4AEDA-0386-4B2D-9DBA-BC9AE733660E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{75A4AEDA-0386-4B2D-9DBA-BC9AE733660E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{75A4AEDA-0386-4B2D-9DBA-BC9AE733660E}.Release|Any CPU.Build.0 = Release|Any CPU
{526FF10C-1C7F-4C26-8E8A-D7ACD65F5467}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{526FF10C-1C7F-4C26-8E8A-D7ACD65F5467}.Debug|Any CPU.Build.0 = Debug|Any CPU
{526FF10C-1C7F-4C26-8E8A-D7ACD65F5467}.Release|Any CPU.ActiveCfg = Release|Any CPU
{526FF10C-1C7F-4C26-8E8A-D7ACD65F5467}.Release|Any CPU.Build.0 = Release|Any CPU
{0D40F7D6-3747-4280-8EB3-9F3A18AC1125}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0D40F7D6-3747-4280-8EB3-9F3A18AC1125}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0D40F7D6-3747-4280-8EB3-9F3A18AC1125}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0D40F7D6-3747-4280-8EB3-9F3A18AC1125}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -269,6 +281,8 @@ Global
{81E3F943-B992-4C81-AA09-A17C05081236} = {37A19144-CEA5-47A2-9FFD-22C522E8B895}
{C853A9E3-C53D-4B1A-BFDA-228689A8C94C} = {71DDEE7B-E213-4E39-A7F4-4646783A27F7}
{75A4AEDA-0386-4B2D-9DBA-BC9AE733660E} = {71DDEE7B-E213-4E39-A7F4-4646783A27F7}
{526FF10C-1C7F-4C26-8E8A-D7ACD65F5467} = {AC5B198A-C3F2-4AD2-B532-E71B4630BDD5}
{0D40F7D6-3747-4280-8EB3-9F3A18AC1125} = {71DDEE7B-E213-4E39-A7F4-4646783A27F7}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {DC0D56C8-D8CB-45CE-B528-F3DCF86D63ED}
Expand Down
26 changes: 26 additions & 0 deletions src/Shared/Configuration/InformaticsGatewayConfiguration.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Copyright 2022 MONAI Consortium
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

using Microsoft.Extensions.Configuration;

namespace Monai.Deploy.WorkflowManager.Configuration
{
public class InformaticsGatewayConfiguration
{
[ConfigurationKeyName("apiHost")]
public string ApiHost { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Copyright 2022 MONAI Consortium
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

namespace Monai.Deploy.WorkflowManager.Services.InformaticsGateway
{
public interface IInformaticsGatewayService
{
/// <summary>
/// Checks if a data origin exists with the informatics gateway.
/// </summary>
/// <param name="name">Name of the source.</param>
/// <returns>bool based on success status on the informatics gateway request.</returns>
Task<bool> OriginExists(string name);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Copyright 2022 MONAI Consortium
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

using System.Net;
using Microsoft.Extensions.Options;
using Monai.Deploy.WorkflowManager.Configuration;

namespace Monai.Deploy.WorkflowManager.Services.InformaticsGateway
{
public class InformaticsGatewayService : IInformaticsGatewayService
{
public InformaticsGatewayService(
IHttpClientFactory httpClientFactory,
IOptions<InformaticsGatewayConfiguration> options
)
{
_httpClient = httpClientFactory?.CreateClient("Informatics-Gateway") ?? throw new ArgumentNullException(nameof(httpClientFactory));
_options = options ?? throw new ArgumentNullException(nameof(options));

_httpClient.BaseAddress = new Uri(_options.Value.ApiHost);
}

private readonly HttpClient _httpClient;

private readonly IOptions<InformaticsGatewayConfiguration> _options;

public async Task<bool> OriginExists(string name)
{
var response = await _httpClient.GetAsync($"/config/source/{name}");

return response.StatusCode == HttpStatusCode.OK;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<!--
~ Copyright 2022 MONAI Consortium
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->

<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
</PropertyGroup>

<ItemGroup>
<AdditionalFiles Include="..\..\..\stylecop.json" Link="stylecop.json" />
</ItemGroup>

<ItemGroup>
<AdditionalFiles Include="..\..\.sonarlint\project-monai_monai-deploy-workflow-manager\CSharp\SonarLint.xml" Link="SonarLint.xml" />
</ItemGroup>

<ItemGroup>
<Compile Include="..\..\AssemblyInfo.cs" Link="AssemblyInfo.cs" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Http" Version="3.1.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\Shared\Configuration\Monai.Deploy.WorkflowManager.Configuration.csproj" />
</ItemGroup>

<PropertyGroup>
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
<DisableImplicitNuGetFallbackFolder>true</DisableImplicitNuGetFallbackFolder>
<CodeAnalysisRuleSet>..\..\.sonarlint\project-monai_monai-deploy-workflow-managercsharp.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>

</Project>
Loading