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

Feature/branch #121

Open
wants to merge 18 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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/Balsam/.openapi-generator/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7.1.0-SNAPSHOT
7.6.0-SNAPSHOT
24 changes: 24 additions & 0 deletions src/Balsam/Balsam.sln
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RocketChatChatProviderApiCl
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BalsamApi.Server", "src\BalsamApi.Server\BalsamApi.Server.csproj", "{CCE90D11-C8D4-4F76-9730-506B23B1CD9E}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Balsam.Application", "src\Balsam.Application\Balsam.Application.csproj", "{AAAA20E8-E584-401D-A7B4-6741E1316301}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Balsam.Domain", "src\Balsam.Domain\Balsam.Domain.csproj", "{AE263A3F-7988-4491-8339-89899DF6E08F}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Balsam.Infrastructure", "src\Balsam.Infrastructure\Balsam.Infrastructure.csproj", "{98CB6D20-3EDC-4AA5-A477-83835FCD3EC7}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Balsam.Tests", "src\Balsam.Tests\Balsam.Tests.csproj", "{FEE2F533-5550-4F4C-9FCB-A3695018307E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -69,6 +77,22 @@ Global
{CCE90D11-C8D4-4F76-9730-506B23B1CD9E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CCE90D11-C8D4-4F76-9730-506B23B1CD9E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CCE90D11-C8D4-4F76-9730-506B23B1CD9E}.Release|Any CPU.Build.0 = Release|Any CPU
{AAAA20E8-E584-401D-A7B4-6741E1316301}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AAAA20E8-E584-401D-A7B4-6741E1316301}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AAAA20E8-E584-401D-A7B4-6741E1316301}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AAAA20E8-E584-401D-A7B4-6741E1316301}.Release|Any CPU.Build.0 = Release|Any CPU
{AE263A3F-7988-4491-8339-89899DF6E08F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AE263A3F-7988-4491-8339-89899DF6E08F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AE263A3F-7988-4491-8339-89899DF6E08F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AE263A3F-7988-4491-8339-89899DF6E08F}.Release|Any CPU.Build.0 = Release|Any CPU
{98CB6D20-3EDC-4AA5-A477-83835FCD3EC7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{98CB6D20-3EDC-4AA5-A477-83835FCD3EC7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{98CB6D20-3EDC-4AA5-A477-83835FCD3EC7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{98CB6D20-3EDC-4AA5-A477-83835FCD3EC7}.Release|Any CPU.Build.0 = Release|Any CPU
{FEE2F533-5550-4F4C-9FCB-A3695018307E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FEE2F533-5550-4F4C-9FCB-A3695018307E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FEE2F533-5550-4F4C-9FCB-A3695018307E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FEE2F533-5550-4F4C-9FCB-A3695018307E}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
10 changes: 5 additions & 5 deletions src/Balsam/BalsamApi.Server.sln
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27428.2043
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BalsamApi.Server", "src\BalsamApi.Server\BalsamApi.Server.csproj", "{C7291B74-4521-4C9F-B7B4-92A1B686E169}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BalsamApi.Server", "src\BalsamApi.Server\BalsamApi.Server.csproj", "{5F5771EB-9749-4B0E-AB6C-028564A70FD6}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{C7291B74-4521-4C9F-B7B4-92A1B686E169}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C7291B74-4521-4C9F-B7B4-92A1B686E169}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C7291B74-4521-4C9F-B7B4-92A1B686E169}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C7291B74-4521-4C9F-B7B4-92A1B686E169}.Release|Any CPU.Build.0 = Release|Any CPU
{5F5771EB-9749-4B0E-AB6C-028564A70FD6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5F5771EB-9749-4B0E-AB6C-028564A70FD6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5F5771EB-9749-4B0E-AB6C-028564A70FD6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5F5771EB-9749-4B0E-AB6C-028564A70FD6}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
1 change: 1 addition & 0 deletions src/Balsam/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ This C# SDK is automatically generated by the [OpenAPI Generator](https://openap

- API version: 2.0
- SDK version: 1.0.0
- Generator version: 7.6.0-SNAPSHOT
- Build package: org.openapitools.codegen.languages.CSharpClientCodegen

<a id="frameworks-supported"></a>
Expand Down
87 changes: 87 additions & 0 deletions src/Balsam/docs/GroupApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ All URIs are relative to *http://oidc-provider.balsam-system.svc.cluster.local/a
|--------|--------------|-------------|
| [**AddUserToGroup**](GroupApi.md#addusertogroup) | **POST** /groups/{groupId}/users | |
| [**CreateGroup**](GroupApi.md#creategroup) | **POST** /groups | |
| [**DeleteGroup**](GroupApi.md#deletegroup) | **DELETE** /groups/{groupId} | |

<a id="addusertogroup"></a>
# **AddUserToGroup**
Expand Down Expand Up @@ -185,3 +186,89 @@ No authorization required

[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)

<a id="deletegroup"></a>
# **DeleteGroup**
> void DeleteGroup (string groupId)



Deletes a user group

### Example
```csharp
using System.Collections.Generic;
using System.Diagnostics;
using OidcProviderApiClient.Api;
using OidcProviderApiClient.Client;
using OidcProviderApiClient.Model;

namespace Example
{
public class DeleteGroupExample
{
public static void Main()
{
Configuration config = new Configuration();
config.BasePath = "http://oidc-provider.balsam-system.svc.cluster.local/api/v1";
var apiInstance = new GroupApi(config);
var groupId = "groupId_example"; // string | The id for the group

try
{
apiInstance.DeleteGroup(groupId);
}
catch (ApiException e)
{
Debug.Print("Exception when calling GroupApi.DeleteGroup: " + e.Message);
Debug.Print("Status Code: " + e.ErrorCode);
Debug.Print(e.StackTrace);
}
}
}
}
```

#### Using the DeleteGroupWithHttpInfo variant
This returns an ApiResponse object which contains the response data, status code and headers.

```csharp
try
{
apiInstance.DeleteGroupWithHttpInfo(groupId);
}
catch (ApiException e)
{
Debug.Print("Exception when calling GroupApi.DeleteGroupWithHttpInfo: " + e.Message);
Debug.Print("Status Code: " + e.ErrorCode);
Debug.Print(e.StackTrace);
}
```

### Parameters

| Name | Type | Description | Notes |
|------|------|-------------|-------|
| **groupId** | **string** | The id for the group | |

### Return type

void (empty response body)

### Authorization

No authorization required

### HTTP request headers

- **Content-Type**: Not defined
- **Accept**: application/problem+json


### HTTP response details
| Status code | Description | Response headers |
|-------------|-------------|------------------|
| **200** | Success | - |
| **400** | Error respsone for 400 | - |

[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)

13 changes: 4 additions & 9 deletions src/Balsam/src/Balsam.Api/Balsam.Api.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
Expand All @@ -9,22 +9,17 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Handlebars.Net" Version="2.1.4" />
<PackageReference Include="LibGit2Sharp" Version="0.26.2" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="6.0.22" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="6.0.22" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.18.1" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
<PackageReference Include="System.IO.Hashing" Version="6.0.2" />
<PackageReference Include="YamlDotNet" Version="13.7.1" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Balsam.Application\Balsam.Application.csproj" />
<ProjectReference Include="..\Balsam.Domain\Balsam.Domain.csproj" />
<ProjectReference Include="..\Balsam.Infrastructure\Balsam.Infrastructure.csproj" />
<ProjectReference Include="..\BalsamApi.Server\BalsamApi.Server.csproj" />
<ProjectReference Include="..\GitProviderApiClient\GitProviderApiClient.csproj" />
<ProjectReference Include="..\OidcProviderApiClient\OidcProviderApiClient.csproj" />
<ProjectReference Include="..\RocketChatChatProviderApiClient\RocketChatChatProviderApiClient.csproj" />
<ProjectReference Include="..\S3ProviderApiClient\S3ProviderApiClient.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,39 +1,24 @@
using Microsoft.Extensions.Options;

namespace Balsam.Api.Models
{
public class CapabilityOptions
{
public bool Enabled { get; set; }
public string? ServiceLocation { get; set; }
public string[]? Actions { get; set; }
}

public class Capabilities
{
public const string Git = "Git";
public const string S3 = "S3";
public const string Authentication = "Authentication";
public const string Chat = "Chat";
}

public class ConfigureCapabilityOptions : IConfigureNamedOptions<CapabilityOptions>
{

public ConfigureCapabilityOptions()
{

}

public void Configure(string name, CapabilityOptions options)
{
//options.ClientId = this.decrypt.Decrypt(options.ClientId);
//options.ClientSecret = this.decrypt.Decrypt(options.ClientSecret);
}

public void Configure(CapabilityOptions options)
{
Configure(Options.DefaultName, options);
}
}
}
using Microsoft.Extensions.Options;

namespace Balsam.Model
{
public class ConfigureCapabilityOptions : IConfigureNamedOptions<CapabilityOptions>
{

public ConfigureCapabilityOptions()
{

}

public void Configure(string name, CapabilityOptions options)
{
//options.ClientId = this.decrypt.Decrypt(options.ClientId);
//options.ClientSecret = this.decrypt.Decrypt(options.ClientSecret);
}

public void Configure(CapabilityOptions options)
{
Configure(Options.DefaultName, options);
}
}
}
41 changes: 21 additions & 20 deletions src/Balsam/src/Balsam.Api/Controllers/KnowledgeLibraryController.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using BalsamApi.Server.Models;
using Balsam.Api.Extensions;
using Balsam.Interfaces;
using Balsam.Model;
using BalsamApi.Server.Models;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Options;
using System.ComponentModel.DataAnnotations;

namespace Balsam.Api.Controllers
Expand All @@ -9,25 +11,25 @@ namespace Balsam.Api.Controllers
[ApiController]
public class KnowledgeLibraryController : BalsamApi.Server.Controllers.KnowledgeLibraryApiController
{
private readonly HubClient _hubClient;
private readonly ILogger<KnowledgeLibraryController> _logger;
private readonly KnowledgeLibraryClient _knowledgeLibraryClient;
private readonly IKnowledgeLibraryService _knowledgeLibraryService;

public KnowledgeLibraryController(ILogger<KnowledgeLibraryController> logger, HubClient hubClient, KnowledgeLibraryClient knowledgeLibraryClient)
public KnowledgeLibraryController(ILogger<KnowledgeLibraryController> logger, IKnowledgeLibraryService knowledgeLibraryService)
{
_hubClient = hubClient;
_logger = logger;
_knowledgeLibraryClient = knowledgeLibraryClient;
_knowledgeLibraryService = knowledgeLibraryService;
}
public async override Task<IActionResult> ListKnowledgeLibaries() //A. Implementera
{
_logger.LogInformation("calling endpoint: Listing Knowledgelibraries");
try
{
var knowledgeLibraries = await _hubClient.ListKnowledgeLibraries();
var balsamKnowledgeLibraries = await _knowledgeLibraryService.ListKnowledgeLibraries();

var knowledgeLibraries = balsamKnowledgeLibraries.Select(bkl => bkl.ToKnowledgeLibrary());
return Ok(knowledgeLibraries);
}
catch(Exception ex)
catch (Exception ex)
{
_logger.LogError(ex, "Error listing knowledgelibraries");
return BadRequest(ex);
Expand All @@ -38,13 +40,16 @@ public async override Task<IActionResult> GetKnowledgeLibraryFileContent([FromRo
{
try
{
//TODO: Pull knowledge library repo

//TODO: Move stream to knowledgeLibraryService?
string filePath = string.Empty;
filePath = _knowledgeLibraryClient.GetRepositoryFilePath(libraryId, fileId);
filePath = _knowledgeLibraryService.GetRepositoryFilePath(libraryId, fileId);

// Open the file
var stream = System.IO.File.OpenRead(filePath);


// Determine the content type
var provider = new Microsoft.AspNetCore.StaticFiles.FileExtensionContentTypeProvider();
if (!provider.TryGetContentType(fileId, out var contentType))
Expand All @@ -69,16 +74,12 @@ public async override Task<IActionResult> ListKnowledgeLibraryFiles([FromRoute(N
{
try
{
var knowledgeLibrary = (await _hubClient.ListKnowledgeLibraries()).FirstOrDefault(kb => kb.Id == libraryId);
var balsamRepofiles = await _knowledgeLibraryService.GetRepositoryFileTree(libraryId);
var repoFiles = balsamRepofiles.Select(rf => rf.ToRepoFile());

if (knowledgeLibrary is null)
{
return BadRequest(new Problem() { Status = 404, Title = "Knowledge library not found", Detail = "Knowledge library not found" });
}

var contents = _knowledgeLibraryClient.GetRepositoryContent(libraryId, knowledgeLibrary.RepositoryUrl);
return Ok(contents.ToArray());
} catch (Exception ex)
return Ok(repoFiles.ToArray());
}
catch (Exception ex)
{
_logger.LogError(ex, "Error listing knowledge library files");
return BadRequest(new Problem() { Status = 404, Title = "Error fetching knowledge libraries", Detail = "Error fetching knowledge libraries" });
Expand Down
Loading