mirror of
https://github.com/bitwarden/server.git
synced 2025-07-01 08:02:49 -05:00
return collection associations with group response
This commit is contained in:
@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Bit.Core.Models.Api.Public
|
||||
{
|
||||
public abstract class BaseAssociationWithPermissionsModel
|
||||
{
|
||||
/// <summary>
|
||||
/// The associated object's unique identifier.
|
||||
/// </summary>
|
||||
/// <example>bfbc8338-e329-4dc0-b0c9-317c2ebf1a09</example>
|
||||
[Required]
|
||||
public Guid? Id { get; set; }
|
||||
/// <summary>
|
||||
/// When true, the read only permission will not allow the user or group to make changes to items.
|
||||
/// </summary>
|
||||
[Required]
|
||||
public bool? ReadOnly { get; set; }
|
||||
}
|
||||
}
|
@ -1,24 +1,9 @@
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Newtonsoft.Json;
|
||||
using Bit.Core.Models.Data;
|
||||
using Bit.Core.Models.Data;
|
||||
|
||||
namespace Bit.Core.Models.Api.Public
|
||||
{
|
||||
public class AssociationWithPermissionsRequestModel
|
||||
public class AssociationWithPermissionsRequestModel : BaseAssociationWithPermissionsModel
|
||||
{
|
||||
/// <summary>
|
||||
/// The associated object's unique identifier.
|
||||
/// </summary>
|
||||
/// <example>bfbc8338-e329-4dc0-b0c9-317c2ebf1a09</example>
|
||||
[Required]
|
||||
public Guid? Id { get; set; }
|
||||
/// <summary>
|
||||
/// When true, the read only permission will not allow the user or group to make changes to items.
|
||||
/// </summary>
|
||||
[Required]
|
||||
public bool? ReadOnly { get; set; }
|
||||
|
||||
public SelectionReadOnly ToSelectionReadOnly()
|
||||
{
|
||||
return new SelectionReadOnly
|
||||
|
@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using Bit.Core.Models.Data;
|
||||
|
||||
namespace Bit.Core.Models.Api.Public
|
||||
{
|
||||
public class AssociationWithPermissionsResponseModel : BaseAssociationWithPermissionsModel
|
||||
{
|
||||
public AssociationWithPermissionsResponseModel(SelectionReadOnly selection)
|
||||
{
|
||||
if(selection == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(selection));
|
||||
}
|
||||
Id = selection.Id;
|
||||
ReadOnly = selection.ReadOnly;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,5 +1,8 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using Bit.Core.Models.Data;
|
||||
using Bit.Core.Models.Table;
|
||||
|
||||
namespace Bit.Core.Models.Api.Public
|
||||
@ -9,7 +12,7 @@ namespace Bit.Core.Models.Api.Public
|
||||
/// </summary>
|
||||
public class GroupResponseModel : GroupBaseModel, IResponseModel
|
||||
{
|
||||
public GroupResponseModel(Group group)
|
||||
public GroupResponseModel(Group group, IEnumerable<SelectionReadOnly> collections)
|
||||
{
|
||||
if(group == null)
|
||||
{
|
||||
@ -20,6 +23,7 @@ namespace Bit.Core.Models.Api.Public
|
||||
Name = group.Name;
|
||||
AccessAll = group.AccessAll;
|
||||
ExternalId = group.ExternalId;
|
||||
Collections = collections?.Select(c => new AssociationWithPermissionsResponseModel(c));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -34,5 +38,9 @@ namespace Bit.Core.Models.Api.Public
|
||||
/// <example>539a36c5-e0d2-4cf9-979e-51ecf5cf6593</example>
|
||||
[Required]
|
||||
public Guid Id { get; set; }
|
||||
/// <summary>
|
||||
/// The associated collections that this group can access.
|
||||
/// </summary>
|
||||
public IEnumerable<AssociationWithPermissionsResponseModel> Collections { get; set; }
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user