mirror of
https://github.com/bitwarden/server.git
synced 2025-07-01 08:02:49 -05:00
Subvault APIs
This commit is contained in:
35
src/Api/Models/Request/SubvaultRequestModel.cs
Normal file
35
src/Api/Models/Request/SubvaultRequestModel.cs
Normal file
@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Bit.Api.Utilities;
|
||||
using Bit.Core.Domains;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Bit.Api.Models
|
||||
{
|
||||
public class SubvaultCreateRequestModel : SubvaultUpdateRequestModel
|
||||
{
|
||||
public string OrganizationId { get; set; }
|
||||
|
||||
public Subvault ToSubvault()
|
||||
{
|
||||
return ToSubvault(new Subvault
|
||||
{
|
||||
OrganizationId = new Guid(OrganizationId)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public class SubvaultUpdateRequestModel
|
||||
{
|
||||
[Required]
|
||||
[EncryptedString]
|
||||
[StringLength(300)]
|
||||
public string Name { get; set; }
|
||||
|
||||
public Subvault ToSubvault(Subvault existingSubvault)
|
||||
{
|
||||
existingSubvault.Name = Name;
|
||||
return existingSubvault;
|
||||
}
|
||||
}
|
||||
}
|
25
src/Api/Models/Response/SubvaultResponseModel.cs
Normal file
25
src/Api/Models/Response/SubvaultResponseModel.cs
Normal file
@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using Bit.Core.Domains;
|
||||
|
||||
namespace Bit.Api.Models
|
||||
{
|
||||
public class SubvaultResponseModel : ResponseModel
|
||||
{
|
||||
public SubvaultResponseModel(Subvault subvault)
|
||||
: base("subvault")
|
||||
{
|
||||
if(subvault == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(subvault));
|
||||
}
|
||||
|
||||
Id = subvault.Id.ToString();
|
||||
OrganizationId = subvault.OrganizationId.ToString();
|
||||
Name = subvault.Name;
|
||||
}
|
||||
|
||||
public string Id { get; set; }
|
||||
public string OrganizationId { get; set; }
|
||||
public string Name { get; set; }
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user