mirror of
https://github.com/bitwarden/server
synced 2025-12-17 08:43:27 +00:00
* Revert "Add git blame entry (#2226)" This reverts commit239286737d. * Revert "Turn on file scoped namespaces (#2225)" This reverts commit34fb4cca2a.
52 lines
1.5 KiB
C#
52 lines
1.5 KiB
C#
using System.Text.Json;
|
|
using Bit.Core.Enums;
|
|
using Bit.Core.Exceptions;
|
|
using Bit.Core.Models.Data.Organizations.OrganizationConnections;
|
|
using Bit.Core.Utilities;
|
|
|
|
namespace Bit.Api.Models.Request.Organizations
|
|
{
|
|
public class OrganizationConnectionRequestModel
|
|
{
|
|
public OrganizationConnectionType Type { get; set; }
|
|
public Guid OrganizationId { get; set; }
|
|
public bool Enabled { get; set; }
|
|
public JsonDocument Config { get; set; }
|
|
|
|
public OrganizationConnectionRequestModel() { }
|
|
}
|
|
|
|
|
|
public class OrganizationConnectionRequestModel<T> : OrganizationConnectionRequestModel where T : new()
|
|
{
|
|
public T ParsedConfig { get; private set; }
|
|
|
|
public OrganizationConnectionRequestModel(OrganizationConnectionRequestModel model)
|
|
{
|
|
Type = model.Type;
|
|
OrganizationId = model.OrganizationId;
|
|
Enabled = model.Enabled;
|
|
Config = model.Config;
|
|
|
|
try
|
|
{
|
|
ParsedConfig = model.Config.ToObject<T>(JsonHelpers.IgnoreCase);
|
|
}
|
|
catch (JsonException)
|
|
{
|
|
throw new BadRequestException("Organization Connection configuration malformed");
|
|
}
|
|
}
|
|
|
|
public OrganizationConnectionData<T> ToData(Guid? id = null) =>
|
|
new()
|
|
{
|
|
Id = id,
|
|
Type = Type,
|
|
OrganizationId = OrganizationId,
|
|
Enabled = Enabled,
|
|
Config = ParsedConfig,
|
|
};
|
|
}
|
|
}
|