81 lines
No EOL
2.2 KiB
C#
81 lines
No EOL
2.2 KiB
C#
using System.Threading.Tasks;
|
|
|
|
using Frostfs.V2.Ape;
|
|
using Frostfs.V2.Apemanager;
|
|
|
|
namespace FrostFS.SDK.ClientV2;
|
|
|
|
internal class ApeManagerServiceProvider : ContextAccessor
|
|
{
|
|
private readonly APEManagerService.APEManagerServiceClient? _apeManagerServiceClient;
|
|
|
|
internal ApeManagerServiceProvider(APEManagerService.APEManagerServiceClient? apeManagerServiceClient, ClientEnvironment context)
|
|
: base (context)
|
|
{
|
|
_apeManagerServiceClient = apeManagerServiceClient;
|
|
}
|
|
|
|
internal async Task<byte[]> AddChainAsync(PrmApeChainAdd args)
|
|
{
|
|
var ctx = args.Context!;
|
|
|
|
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!;
|
|
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!;
|
|
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];
|
|
}
|
|
} |