[#1] Define SDK structure
TODO: Вынести маппинг модель -> grpc в отдельный слой Signed-off-by: Ivan Pchelintsev <i.pchelintsev@yadro.com>
This commit is contained in:
parent
905f683bf1
commit
2800fff041
57 changed files with 5760 additions and 0 deletions
47
sdk/src/FrostFS.SDK.ClientV2/Services/Session.cs
Normal file
47
sdk/src/FrostFS.SDK.ClientV2/Services/Session.cs
Normal file
|
@ -0,0 +1,47 @@
|
|||
using FrostFS.Refs;
|
||||
using FrostFS.SDK.ModelsV2;
|
||||
using FrostFS.Session;
|
||||
using Google.Protobuf;
|
||||
|
||||
namespace FrostFS.SDK.ClientV2;
|
||||
|
||||
public partial class Client
|
||||
{
|
||||
public async Task<SessionToken> CreateSessionAsync(ulong expiration)
|
||||
{
|
||||
var request = new CreateRequest
|
||||
{
|
||||
Body = new CreateRequest.Types.Body
|
||||
{
|
||||
OwnerId = new OwnerID
|
||||
{
|
||||
Value = ByteString.CopyFrom(OwnerId.FromKey(_key).ToHash())
|
||||
},
|
||||
Expiration = expiration,
|
||||
}
|
||||
};
|
||||
request.AddMetaHeader();
|
||||
request.Sign(_key);
|
||||
return await CreateSession(request);
|
||||
}
|
||||
|
||||
public async Task<SessionToken> CreateSession(CreateRequest request)
|
||||
{
|
||||
var resp = await _sessionServiceClient.CreateAsync(request);
|
||||
return new SessionToken
|
||||
{
|
||||
Body = new SessionToken.Types.Body
|
||||
{
|
||||
Id = resp.Body.Id,
|
||||
SessionKey = resp.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,
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue