1
0
mirror of https://github.com/bitwarden/server synced 2025-12-10 05:13:48 +00:00
Files
server/src/Api/Models/Request/CollectionRequestModel.cs
2025-07-08 10:25:59 -04:00

53 lines
1.3 KiB
C#

// FIXME: Update this file to be null safe and then delete the line below
#nullable disable
using System.ComponentModel.DataAnnotations;
using Bit.Core.Entities;
using Bit.Core.Utilities;
namespace Bit.Api.Models.Request;
public class CollectionRequestModel
{
[Required]
[EncryptedString]
[EncryptedStringLength(1000)]
public string Name { get; set; }
[StringLength(300)]
public string ExternalId { get; set; }
public IEnumerable<SelectionReadOnlyRequestModel> Groups { get; set; }
public IEnumerable<SelectionReadOnlyRequestModel> Users { get; set; }
public Collection ToCollection(Guid orgId)
{
return ToCollection(new Collection
{
OrganizationId = orgId
});
}
public virtual Collection ToCollection(Collection existingCollection)
{
existingCollection.Name = Name;
existingCollection.ExternalId = ExternalId;
return existingCollection;
}
}
public class CollectionBulkDeleteRequestModel
{
[Required]
public IEnumerable<Guid> Ids { get; set; }
}
public class CollectionWithIdRequestModel : CollectionRequestModel
{
public Guid? Id { get; set; }
public override Collection ToCollection(Collection existingCollection)
{
existingCollection.Id = Id ?? Guid.Empty;
return base.ToCollection(existingCollection);
}
}