mirror of
https://github.com/bitwarden/server.git
synced 2025-07-06 10:32:49 -05:00
[PM-17562] Add Dapper and EF Repositories For Ogranization Integrations and Configurations (#5589)
* [PM-17562] Add Dapper and EF Repositories For Ogranization Integrations and Configurations * Updated with changes from PR comments
This commit is contained in:
@ -0,0 +1,64 @@
|
||||
using System.Text.Json.Nodes;
|
||||
using Bit.Core.Enums;
|
||||
|
||||
#nullable enable
|
||||
|
||||
namespace Bit.Core.Models.Data.Organizations;
|
||||
|
||||
public class OrganizationIntegrationConfigurationDetails
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public Guid OrganizationIntegrationId { get; set; }
|
||||
public IntegrationType IntegrationType { get; set; }
|
||||
public EventType EventType { get; set; }
|
||||
public string? Configuration { get; set; }
|
||||
public string? IntegrationConfiguration { get; set; }
|
||||
public string? Template { get; set; }
|
||||
|
||||
public JsonObject MergedConfiguration
|
||||
{
|
||||
get
|
||||
{
|
||||
var integrationJson = IntegrationConfigurationJson;
|
||||
|
||||
foreach (var kvp in ConfigurationJson)
|
||||
{
|
||||
integrationJson[kvp.Key] = kvp.Value?.DeepClone();
|
||||
}
|
||||
|
||||
return integrationJson;
|
||||
}
|
||||
}
|
||||
|
||||
private JsonObject ConfigurationJson
|
||||
{
|
||||
get
|
||||
{
|
||||
try
|
||||
{
|
||||
var configuration = Configuration ?? string.Empty;
|
||||
return JsonNode.Parse(configuration) as JsonObject ?? new JsonObject();
|
||||
}
|
||||
catch
|
||||
{
|
||||
return new JsonObject();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private JsonObject IntegrationConfigurationJson
|
||||
{
|
||||
get
|
||||
{
|
||||
try
|
||||
{
|
||||
var integration = IntegrationConfiguration ?? string.Empty;
|
||||
return JsonNode.Parse(integration) as JsonObject ?? new JsonObject();
|
||||
}
|
||||
catch
|
||||
{
|
||||
return new JsonObject();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
using Bit.Core.AdminConsole.Entities;
|
||||
using Bit.Core.Enums;
|
||||
using Bit.Core.Models.Data.Organizations;
|
||||
|
||||
namespace Bit.Core.Repositories;
|
||||
|
||||
public interface IOrganizationIntegrationConfigurationRepository : IRepository<OrganizationIntegrationConfiguration, Guid>
|
||||
{
|
||||
Task<List<OrganizationIntegrationConfigurationDetails>> GetConfigurationDetailsAsync(
|
||||
Guid organizationId,
|
||||
IntegrationType integrationType,
|
||||
EventType eventType);
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
using Bit.Core.AdminConsole.Entities;
|
||||
|
||||
namespace Bit.Core.Repositories;
|
||||
|
||||
public interface IOrganizationIntegrationRepository : IRepository<OrganizationIntegration, Guid>
|
||||
{
|
||||
}
|
Reference in New Issue
Block a user