1
0
mirror of https://github.com/bitwarden/server.git synced 2025-07-01 08:02:49 -05:00

collection externalId

This commit is contained in:
Kyle Spearrin
2019-03-07 15:18:27 -05:00
parent 2684de0fff
commit 75f01a5774
14 changed files with 232 additions and 9 deletions

View File

@ -0,0 +1,14 @@
using System.ComponentModel.DataAnnotations;
namespace Bit.Core.Models.Api.Public
{
public abstract class CollectionBaseModel
{
/// <summary>
/// External identifier for reference or linking this collection to another system.
/// </summary>
/// <example>external_id_123456</example>
[StringLength(300)]
public string ExternalId { get; set; }
}
}

View File

@ -18,7 +18,7 @@ namespace Bit.Core.Models.Api.Public
[Required]
public bool? AccessAll { get; set; }
/// <summary>
/// External identifier linking this group to another system, such as a user directory.
/// External identifier for reference or linking this group to another system, such as a user directory.
/// </summary>
/// <example>external_id_123456</example>
[StringLength(300)]

View File

@ -46,7 +46,7 @@ namespace Bit.Core.Models.Api.Public
[Required]
public bool? AccessAll { get; set; }
/// <summary>
/// External identifier linking this member to another system, such as a user directory.
/// External identifier for reference or linking this member to another system, such as a user directory.
/// </summary>
/// <example>external_id_123456</example>
[StringLength(300)]

View File

@ -3,7 +3,7 @@ using Bit.Core.Models.Table;
namespace Bit.Core.Models.Api.Public
{
public class CollectionUpdateRequestModel
public class CollectionUpdateRequestModel : CollectionBaseModel
{
/// <summary>
/// The associated groups that this collection is assigned to.
@ -12,8 +12,7 @@ namespace Bit.Core.Models.Api.Public
public Collection ToCollection(Collection existingCollection)
{
// TODO
// existingCollection.ExternalId = ExternalId;
existingCollection.ExternalId = ExternalId;
return existingCollection;
}
}

View File

@ -10,7 +10,7 @@ namespace Bit.Core.Models.Api.Public
/// <summary>
/// A collection.
/// </summary>
public class CollectionResponseModel : IResponseModel
public class CollectionResponseModel : CollectionBaseModel, IResponseModel
{
public CollectionResponseModel(Collection collection, IEnumerable<SelectionReadOnly> groups)
{
@ -20,7 +20,7 @@ namespace Bit.Core.Models.Api.Public
}
Id = collection.Id;
// ExternalId = group.ExternalId; TODO: Add external is for referencing purposes
ExternalId = collection.ExternalId;
Groups = groups?.Select(c => new AssociationWithPermissionsResponseModel(c));
}

View File

@ -13,6 +13,8 @@ namespace Bit.Core.Models.Api
[EncryptedString]
[EncryptedStringLength(1000)]
public string Name { get; set; }
[StringLength(300)]
public string ExternalId { get; set; }
public IEnumerable<SelectionReadOnlyRequestModel> Groups { get; set; }
public Collection ToCollection(Guid orgId)
@ -26,6 +28,7 @@ namespace Bit.Core.Models.Api
public Collection ToCollection(Collection existingCollection)
{
existingCollection.Name = Name;
existingCollection.ExternalId = ExternalId;
return existingCollection;
}
}

View File

@ -19,11 +19,13 @@ namespace Bit.Core.Models.Api
Id = collection.Id.ToString();
OrganizationId = collection.OrganizationId.ToString();
Name = collection.Name;
ExternalId = collection.ExternalId;
}
public string Id { get; set; }
public string OrganizationId { get; set; }
public string Name { get; set; }
public string ExternalId { get; set; }
}
public class CollectionDetailsResponseModel : CollectionResponseModel

View File

@ -8,6 +8,7 @@ namespace Bit.Core.Models.Table
public Guid Id { get; set; }
public Guid OrganizationId { get; set; }
public string Name { get; set; }
public string ExternalId { get; set; }
public DateTime CreationDate { get; internal set; } = DateTime.UtcNow;
public DateTime RevisionDate { get; internal set; } = DateTime.UtcNow;