mirror of
https://github.com/bitwarden/server
synced 2025-12-17 08:43:27 +00:00
Turn on file scoped namespaces (#2225)
This commit is contained in:
@@ -4,48 +4,47 @@ using Bit.Core.Exceptions;
|
||||
using Bit.Core.Models.Data.Organizations.OrganizationConnections;
|
||||
using Bit.Core.Utilities;
|
||||
|
||||
namespace Bit.Api.Models.Request.Organizations
|
||||
namespace Bit.Api.Models.Request.Organizations;
|
||||
|
||||
public class OrganizationConnectionRequestModel
|
||||
{
|
||||
public class OrganizationConnectionRequestModel
|
||||
{
|
||||
public OrganizationConnectionType Type { get; set; }
|
||||
public Guid OrganizationId { get; set; }
|
||||
public bool Enabled { get; set; }
|
||||
public JsonDocument Config { get; set; }
|
||||
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,
|
||||
};
|
||||
}
|
||||
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,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user