2022-06-29 19:46:41 -04:00
|
|
|
|
using System.Text.Json;
|
2022-01-11 10:40:51 +01:00
|
|
|
|
using Bit.Core.Entities;
|
2020-01-15 08:35:53 -05:00
|
|
|
|
using Bit.Core.Enums;
|
|
|
|
|
|
|
2023-04-17 07:35:47 -07:00
|
|
|
|
namespace Bit.Core.Models.Api.Response;
|
2022-08-29 16:06:55 -04:00
|
|
|
|
|
2020-01-15 08:35:53 -05:00
|
|
|
|
public class PolicyResponseModel : ResponseModel
|
|
|
|
|
|
{
|
|
|
|
|
|
public PolicyResponseModel(Policy policy, string obj = "policy")
|
|
|
|
|
|
: base(obj)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (policy == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new ArgumentNullException(nameof(policy));
|
|
|
|
|
|
}
|
2022-08-29 14:53:16 -04:00
|
|
|
|
|
2020-01-15 08:35:53 -05:00
|
|
|
|
Id = policy.Id.ToString();
|
|
|
|
|
|
OrganizationId = policy.OrganizationId.ToString();
|
|
|
|
|
|
Type = policy.Type;
|
|
|
|
|
|
Enabled = policy.Enabled;
|
2020-03-27 14:36:37 -04:00
|
|
|
|
if (!string.IsNullOrWhiteSpace(policy.Data))
|
2022-01-21 09:36:25 -05:00
|
|
|
|
{
|
|
|
|
|
|
Data = JsonSerializer.Deserialize<Dictionary<string, object>>(policy.Data);
|
2020-01-15 08:35:53 -05:00
|
|
|
|
}
|
2022-08-29 15:53:48 -04:00
|
|
|
|
}
|
2022-08-29 16:06:55 -04:00
|
|
|
|
|
2020-01-15 08:35:53 -05:00
|
|
|
|
public string Id { get; set; }
|
|
|
|
|
|
public string OrganizationId { get; set; }
|
|
|
|
|
|
public PolicyType Type { get; set; }
|
|
|
|
|
|
public Dictionary<string, object> Data { get; set; }
|
|
|
|
|
|
public bool Enabled { get; set; }
|
|
|
|
|
|
}
|