2022-06-29 19:46:41 -04:00
|
|
|
|
using System.ComponentModel.DataAnnotations;
|
2021-12-21 12:10:01 -05:00
|
|
|
|
using System.Text.Json;
|
2023-11-23 07:07:37 +10:00
|
|
|
|
using Bit.Core.AdminConsole.Enums;
|
2024-12-04 11:50:47 +10:00
|
|
|
|
using Bit.Core.AdminConsole.Models.Data;
|
|
|
|
|
|
using Bit.Core.AdminConsole.OrganizationFeatures.Policies.Models;
|
|
|
|
|
|
using Bit.Core.Context;
|
2020-01-15 08:35:53 -05:00
|
|
|
|
|
2023-10-19 01:27:56 +10:00
|
|
|
|
namespace Bit.Api.AdminConsole.Models.Request;
|
2022-08-29 16:06:55 -04:00
|
|
|
|
|
2021-12-14 15:05:07 +00:00
|
|
|
|
public class PolicyRequestModel
|
2020-01-15 08:35:53 -05:00
|
|
|
|
{
|
|
|
|
|
|
[Required]
|
|
|
|
|
|
public PolicyType? Type { get; set; }
|
|
|
|
|
|
[Required]
|
|
|
|
|
|
public bool? Enabled { get; set; }
|
|
|
|
|
|
public Dictionary<string, object> Data { get; set; }
|
2022-08-29 15:53:48 -04:00
|
|
|
|
|
2024-12-04 11:50:47 +10:00
|
|
|
|
public async Task<PolicyUpdate> ToPolicyUpdateAsync(Guid organizationId, ICurrentContext currentContext) => new()
|
2022-08-29 16:06:55 -04:00
|
|
|
|
{
|
2024-12-04 11:50:47 +10:00
|
|
|
|
Type = Type!.Value,
|
|
|
|
|
|
OrganizationId = organizationId,
|
|
|
|
|
|
Data = Data != null ? JsonSerializer.Serialize(Data) : null,
|
|
|
|
|
|
Enabled = Enabled.GetValueOrDefault(),
|
|
|
|
|
|
PerformedBy = new StandardUser(currentContext.UserId!.Value, await currentContext.OrganizationOwner(organizationId))
|
|
|
|
|
|
};
|
2020-01-15 08:35:53 -05:00
|
|
|
|
}
|