[#26] All: Remove V2 from naming
Rename project, namespaces and class names Signed-off-by: Pavel Gross <p.gross@yadro.com>
This commit is contained in:
parent
c406df1a78
commit
766f61a5f7
219 changed files with 219 additions and 974 deletions
96
src/FrostFS.SDK.Client/Services/ApeManagerServiceProvider.cs
Normal file
96
src/FrostFS.SDK.Client/Services/ApeManagerServiceProvider.cs
Normal file
|
@ -0,0 +1,96 @@
|
|||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using Frostfs.V2.Ape;
|
||||
using Frostfs.V2.Apemanager;
|
||||
|
||||
namespace FrostFS.SDK.Client.Services;
|
||||
|
||||
internal sealed class ApeManagerServiceProvider : ContextAccessor
|
||||
{
|
||||
private readonly APEManagerService.APEManagerServiceClient? _apeManagerServiceClient;
|
||||
|
||||
internal ApeManagerServiceProvider(APEManagerService.APEManagerServiceClient? apeManagerServiceClient, ClientContext context)
|
||||
: base(context)
|
||||
{
|
||||
_apeManagerServiceClient = apeManagerServiceClient;
|
||||
}
|
||||
|
||||
internal async Task<byte[]> AddChainAsync(PrmApeChainAdd args)
|
||||
{
|
||||
var ctx = args.Context!;
|
||||
ctx.Key ??= ClientContext.Key?.ECDsaKey;
|
||||
|
||||
if (ctx.Key == null)
|
||||
throw new ArgumentNullException(nameof(args), "Key is null");
|
||||
|
||||
AddChainRequest request = new()
|
||||
{
|
||||
Body = new()
|
||||
{
|
||||
Chain = new() { Raw = args.Chain.GetRaw() },
|
||||
Target = args.Target.GetChainTarget()
|
||||
}
|
||||
};
|
||||
|
||||
request.AddMetaHeader(args.XHeaders);
|
||||
request.Sign(ctx.Key);
|
||||
|
||||
var response = await _apeManagerServiceClient!.AddChainAsync(request, null, ctx.Deadline, ctx.CancellationToken);
|
||||
|
||||
Verifier.CheckResponse(response);
|
||||
|
||||
return response.Body.ChainId.ToByteArray();
|
||||
}
|
||||
|
||||
internal async Task RemoveChainAsync(PrmApeChainRemove args)
|
||||
{
|
||||
var ctx = args.Context!;
|
||||
ctx.Key ??= ClientContext.Key?.ECDsaKey;
|
||||
|
||||
if (ctx.Key == null)
|
||||
throw new ArgumentNullException(nameof(args), "Key is null");
|
||||
|
||||
RemoveChainRequest request = new()
|
||||
{
|
||||
Body = new()
|
||||
{
|
||||
ChainId = args.Chain.GetRaw(),
|
||||
Target = args.Target.GetChainTarget()
|
||||
}
|
||||
};
|
||||
|
||||
request.AddMetaHeader(args.XHeaders);
|
||||
request.Sign(ctx.Key);
|
||||
|
||||
var response = await _apeManagerServiceClient!.RemoveChainAsync(request, null, ctx.Deadline, ctx.CancellationToken);
|
||||
|
||||
Verifier.CheckResponse(response);
|
||||
}
|
||||
|
||||
internal async Task<Chain[]> ListChainAsync(PrmApeChainList args)
|
||||
{
|
||||
var ctx = args.Context!;
|
||||
ctx.Key ??= ClientContext.Key?.ECDsaKey;
|
||||
|
||||
if (ctx.Key == null)
|
||||
throw new ArgumentNullException(nameof(args), "Key is null");
|
||||
|
||||
ListChainsRequest request = new()
|
||||
{
|
||||
Body = new()
|
||||
{
|
||||
Target = args.Target.GetChainTarget()
|
||||
}
|
||||
};
|
||||
|
||||
request.AddMetaHeader(args.XHeaders);
|
||||
request.Sign(ctx.Key);
|
||||
|
||||
var response = await _apeManagerServiceClient!.ListChainsAsync(request, null, ctx.Deadline, ctx.CancellationToken);
|
||||
|
||||
Verifier.CheckResponse(response);
|
||||
|
||||
return [.. response.Body.Chains];
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue