mirror of
https://github.com/bitwarden/server.git
synced 2026-01-31 14:13:18 +08:00
* Integration test around getting and saving collection with group/user permissions * This adds groups to the collections returned. * Added new stored procedures so we don't accidentally wipe out access due to null parameters. * wrapping all calls in transaction in the event that there is an error.
52 lines
1.5 KiB
C#
52 lines
1.5 KiB
C#
// FIXME: Update this file to be null safe and then delete the line below
|
|
#nullable disable
|
|
|
|
using System.ComponentModel.DataAnnotations;
|
|
using System.Text.Json.Serialization;
|
|
using Bit.Api.AdminConsole.Public.Models.Response;
|
|
using Bit.Core.Entities;
|
|
using Bit.Core.Models.Data;
|
|
|
|
namespace Bit.Api.Models.Public.Response;
|
|
|
|
/// <summary>
|
|
/// A collection.
|
|
/// </summary>
|
|
public class CollectionResponseModel : CollectionBaseModel, IResponseModel
|
|
{
|
|
[JsonConstructor]
|
|
public CollectionResponseModel()
|
|
{
|
|
|
|
}
|
|
|
|
public CollectionResponseModel(Collection collection, IEnumerable<CollectionAccessSelection> groups)
|
|
{
|
|
if (collection == null)
|
|
{
|
|
throw new ArgumentNullException(nameof(collection));
|
|
}
|
|
|
|
Id = collection.Id;
|
|
ExternalId = collection.ExternalId;
|
|
Groups = groups?.Select(c => new AssociationWithPermissionsResponseModel(c));
|
|
}
|
|
|
|
/// <summary>
|
|
/// String representing the object's type. Objects of the same type share the same properties.
|
|
/// </summary>
|
|
/// <example>collection</example>
|
|
[Required]
|
|
public string Object => "collection";
|
|
/// <summary>
|
|
/// The collection's unique identifier.
|
|
/// </summary>
|
|
/// <example>539a36c5-e0d2-4cf9-979e-51ecf5cf6593</example>
|
|
[Required]
|
|
public Guid Id { get; set; }
|
|
/// <summary>
|
|
/// The associated groups that this collection is assigned to.
|
|
/// </summary>
|
|
public IEnumerable<AssociationWithPermissionsResponseModel> Groups { get; set; }
|
|
}
|