[#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
45
sdk/src/FrostFS.SDK.Service/Service.cs
Normal file
45
sdk/src/FrostFS.SDK.Service/Service.cs
Normal file
|
@ -0,0 +1,45 @@
|
|||
using FrostFS.SDK.ClientV2;
|
||||
using FrostFS.SDK.ClientV2.Mappers.GRPC;
|
||||
using FrostFS.SDK.ModelsV2;
|
||||
using Google.Protobuf;
|
||||
|
||||
namespace FrostFS.SDK.Service;
|
||||
|
||||
public class FrostFsService
|
||||
{
|
||||
private readonly IFrostFSClient _client;
|
||||
|
||||
public FrostFsService(IFrostFSClient client)
|
||||
{
|
||||
_client = client;
|
||||
}
|
||||
|
||||
public async Task<ContainerId[]> ListContainersAsync()
|
||||
{
|
||||
var containersIds = new List<ContainerId>();
|
||||
var listContainersResponse = await _client.ListContainersAsync();
|
||||
foreach (var cid in listContainersResponse.Body.ContainerIds)
|
||||
{
|
||||
containersIds.Add(ContainerId.FromHash(cid.Value.ToByteArray()));
|
||||
}
|
||||
|
||||
return containersIds.ToArray();
|
||||
}
|
||||
|
||||
public async Task<ContainerId> CreateContainerAsync(ModelsV2.Container container)
|
||||
{
|
||||
var createContainerResponse = await _client.CreateContainerAsync(container.ToGrpcMessage());
|
||||
return ContainerId.FromHash(createContainerResponse.Body.ContainerId.Value.ToByteArray());
|
||||
}
|
||||
|
||||
public async Task<ModelsV2.Container> GetContainerAsync(ContainerId containerId)
|
||||
{
|
||||
var getContainerResponse = await _client.GetContainerAsync(containerId.ToGrpcMessage());
|
||||
return getContainerResponse.Body.Container.ToModel();
|
||||
}
|
||||
|
||||
public async Task DeleteContainerAsync(ContainerId containerId)
|
||||
{
|
||||
var deleteContainerResponse = await _client.DeleteContainerAsync(containerId.ToGrpcMessage());
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue