[#17] Client: Add extra parameter
API methods' parameters types with optional session, polling settings, xHeaders etc. and corresponding handlers have been added Signed-off-by: Pavel Gross <p.gross@yadro.com>
This commit is contained in:
parent
00a1e9412f
commit
7b9c19f37c
42 changed files with 1054 additions and 386 deletions
|
@ -1,6 +1,6 @@
|
|||
using System.Threading.Tasks;
|
||||
|
||||
using FrostFS.SDK.ClientV2.Mappers.GRPC;
|
||||
using FrostFS.SDK.ClientV2.Parameters;
|
||||
using FrostFS.Session;
|
||||
|
||||
namespace FrostFS.SDK.ClientV2;
|
||||
|
@ -15,41 +15,41 @@ internal class SessionServiceProvider : ContextAccessor
|
|||
_sessionServiceClient = sessionServiceClient;
|
||||
}
|
||||
|
||||
internal async Task<SessionToken> CreateSessionAsync(ulong expiration, Context ctx)
|
||||
internal async Task<SessionToken> CreateSessionAsync(PrmCreateSession args)
|
||||
{
|
||||
var request = new CreateRequest
|
||||
{
|
||||
Body = new CreateRequest.Types.Body
|
||||
{
|
||||
OwnerId = Context.Owner.ToGrpcMessage(),
|
||||
Expiration = expiration
|
||||
Expiration = args.Expiration
|
||||
}
|
||||
};
|
||||
|
||||
request.AddMetaHeader();
|
||||
request.AddMetaHeader(args.XHeaders);
|
||||
request.Sign(Context.Key);
|
||||
|
||||
var token = await CreateSession(request, ctx);
|
||||
|
||||
return token;
|
||||
return await CreateSession(request, args.Context!);
|
||||
}
|
||||
|
||||
internal async Task<SessionToken> CreateSession(CreateRequest request, Context ctx)
|
||||
{
|
||||
var resp = await _sessionServiceClient!.CreateAsync(request, null, ctx.Deadline, ctx.CancellationToken);
|
||||
var response = await _sessionServiceClient!.CreateAsync(request, null, ctx.Deadline, ctx.CancellationToken);
|
||||
|
||||
Verifier.CheckResponse(response);
|
||||
|
||||
return new SessionToken
|
||||
{
|
||||
Body = new SessionToken.Types.Body
|
||||
{
|
||||
Id = resp.Body.Id,
|
||||
SessionKey = resp.Body.SessionKey,
|
||||
Id = response.Body.Id,
|
||||
SessionKey = response.Body.SessionKey,
|
||||
OwnerId = request.Body.OwnerId,
|
||||
Lifetime = new SessionToken.Types.Body.Types.TokenLifetime
|
||||
{
|
||||
Exp = request.Body.Expiration,
|
||||
Iat = resp.MetaHeader.Epoch,
|
||||
Nbf = resp.MetaHeader.Epoch,
|
||||
Iat = response.MetaHeader.Epoch,
|
||||
Nbf = response.MetaHeader.Epoch,
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue