[#1] Add presentation layer
Signed-off-by: Ivan Pchelintsev <i.pchelintsev@yadro.com>
This commit is contained in:
parent
2800fff041
commit
bb6e187b61
22 changed files with 778 additions and 79 deletions
|
@ -1,21 +1,13 @@
|
|||
using FrostFS.Container;
|
||||
using FrostFS.Netmap;
|
||||
using FrostFS.Refs;
|
||||
using FrostFS.SDK.Cryptography;
|
||||
using FrostFS.SDK.ModelsV2;
|
||||
using Google.Protobuf;
|
||||
using Version = FrostFS.Refs.Version;
|
||||
using FrostFS.SDK.ClientV2.Mappers.GRPC;
|
||||
|
||||
namespace FrostFS.SDK.ClientV2;
|
||||
|
||||
public partial class Client
|
||||
{
|
||||
public async Task<GetResponse> GetContainerAsync(ContainerId containerId)
|
||||
public async Task<GetResponse> GetContainerAsync(ContainerID cid)
|
||||
{
|
||||
var cid = new ContainerID
|
||||
{
|
||||
Value = ByteString.CopyFrom(containerId.ToHash())
|
||||
};
|
||||
var request = new GetRequest
|
||||
{
|
||||
Body = new GetRequest.Types.Body
|
||||
|
@ -34,10 +26,7 @@ public partial class Client
|
|||
{
|
||||
Body = new ListRequest.Types.Body
|
||||
{
|
||||
OwnerId = new OwnerID
|
||||
{
|
||||
Value = ByteString.CopyFrom(OwnerId.FromKey(_key).ToHash())
|
||||
}
|
||||
OwnerId = _owner.ToGrpcMessage()
|
||||
}
|
||||
};
|
||||
request.AddMetaHeader();
|
||||
|
@ -45,36 +34,11 @@ public partial class Client
|
|||
return await _containerServiceClient.ListAsync(request);
|
||||
}
|
||||
|
||||
public async Task<PutResponse> CreateContainerAsync(ModelsV2.Netmap.PlacementPolicy placementPolicy)
|
||||
public async Task<PutResponse> CreateContainerAsync(Container.Container container)
|
||||
{
|
||||
var container = new Container.Container
|
||||
{
|
||||
Version = new Version
|
||||
{
|
||||
Major = 2,
|
||||
Minor = 13
|
||||
},
|
||||
OwnerId = new OwnerID
|
||||
{
|
||||
Value = ByteString.CopyFrom(OwnerId.FromKey(_key).ToHash())
|
||||
},
|
||||
PlacementPolicy = new PlacementPolicy
|
||||
{
|
||||
Filters = { },
|
||||
Selectors = { },
|
||||
Replicas = { }
|
||||
},
|
||||
Nonce = ByteString.CopyFrom(Guid.NewGuid().ToBytes())
|
||||
};
|
||||
foreach (var replica in placementPolicy.Replicas)
|
||||
{
|
||||
container.PlacementPolicy.Replicas.Add(new Replica
|
||||
{
|
||||
Count = (uint)replica.Count,
|
||||
Selector = replica.Selector
|
||||
}
|
||||
);
|
||||
}
|
||||
container.BasicAcl = 0x1FBFBFFF;
|
||||
container.OwnerId = _owner.ToGrpcMessage();
|
||||
container.Version = Version.ToGrpcMessage();
|
||||
var request = new PutRequest
|
||||
{
|
||||
Body = new PutRequest.Types.Body
|
||||
|
@ -88,12 +52,8 @@ public partial class Client
|
|||
return await _containerServiceClient.PutAsync(request);
|
||||
}
|
||||
|
||||
public async Task<DeleteResponse> DeleteContainerAsync(ContainerId containerId)
|
||||
public async Task<DeleteResponse> DeleteContainerAsync(ContainerID cid)
|
||||
{
|
||||
var cid = new ContainerID
|
||||
{
|
||||
Value = ByteString.CopyFrom(containerId.ToHash())
|
||||
};
|
||||
var request = new DeleteRequest
|
||||
{
|
||||
Body = new DeleteRequest.Types.Body
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue