1
0
mirror of https://github.com/bitwarden/server.git synced 2025-07-01 08:02:49 -05:00

refactor policy apis

This commit is contained in:
Kyle Spearrin
2020-01-20 08:53:09 -05:00
parent c5ae1b8283
commit f3f1ac57d2
11 changed files with 112 additions and 120 deletions

View File

@ -13,7 +13,6 @@ namespace Bit.Core.Models.Api.Public
/// <summary>
/// Data for the policy.
/// </summary>
[StringLength(300)]
public Dictionary<string, object> Data { get; set; }
}
}

View File

@ -1,23 +0,0 @@
using System;
using System.ComponentModel.DataAnnotations;
using Bit.Core.Models.Table;
namespace Bit.Core.Models.Api.Public
{
public class PolicyCreateRequestModel : PolicyUpdateRequestModel
{
/// <summary>
/// The type of policy.
/// </summary>
[Required]
public Enums.PolicyType? Type { get; set; }
public Policy ToPolicy(Guid orgId)
{
return ToPolicy(new Policy
{
OrganizationId = orgId
});
}
}
}

View File

@ -1,10 +1,19 @@
using Bit.Core.Models.Table;
using System;
using Bit.Core.Models.Table;
using Newtonsoft.Json;
namespace Bit.Core.Models.Api.Public
{
public class PolicyUpdateRequestModel : PolicyBaseModel
{
public Policy ToPolicy(Guid orgId)
{
return ToPolicy(new Policy
{
OrganizationId = orgId
});
}
public virtual Policy ToPolicy(Policy existingPolicy)
{
existingPolicy.Enabled = Enabled.GetValueOrDefault();