// FIXME: Update this file to be null safe and then delete the line below #nullable disable using System.ComponentModel.DataAnnotations; using Bit.Api.Models.Public.Response; using Bit.Core.AdminConsole.Entities; using Bit.Core.AdminConsole.Enums; using Newtonsoft.Json; using JsonSerializer = System.Text.Json.JsonSerializer; namespace Bit.Api.AdminConsole.Public.Models.Response; /// /// A policy. /// public class PolicyResponseModel : PolicyBaseModel, IResponseModel { [JsonConstructor] public PolicyResponseModel() { } public PolicyResponseModel(Policy policy) { if (policy == null) { throw new ArgumentNullException(nameof(policy)); } Id = policy.Id; Type = policy.Type; Enabled = policy.Enabled; if (!string.IsNullOrWhiteSpace(policy.Data)) { Data = JsonSerializer.Deserialize>(policy.Data); } } /// /// String representing the object's type. Objects of the same type share the same properties. /// /// policy [Required] public string Object => "policy"; /// /// The policy's unique identifier. /// /// 539a36c5-e0d2-4cf9-979e-51ecf5cf6593 [Required] public Guid Id { get; set; } /// /// The type of policy. /// [Required] public PolicyType? Type { get; set; } }