mirror of
https://github.com/bitwarden/server.git
synced 2025-07-01 16:12:49 -05:00

* Remove PolicyService.SaveAsync and use command instead * Delete feature flag definition * Add public api integration tests
27 lines
933 B
C#
27 lines
933 B
C#
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;
|
|
|
|
namespace Bit.Api.AdminConsole.Models.Request;
|
|
|
|
public class PolicyRequestModel
|
|
{
|
|
[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()
|
|
{
|
|
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))
|
|
};
|
|
}
|