Files
server/src/Api/AdminConsole/Models/Request/PolicyRequestModel.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

27 lines
933 B
C#
Raw Normal View History

using System.ComponentModel.DataAnnotations;
using System.Text.Json;
using Bit.Core.AdminConsole.Enums;
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
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; }
public async Task<PolicyUpdate> ToPolicyUpdateAsync(Guid organizationId, ICurrentContext currentContext) => new()
2022-08-29 16:06:55 -04: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
}