[#121] client: Make PrmSessionCreate fields public
Signed-off-by: Airat Arifullin <a.arifullin@yadro.com>
This commit is contained in:
parent
55a1f23e71
commit
55699d1480
1 changed files with 13 additions and 11 deletions
|
@ -16,30 +16,32 @@ import (
|
||||||
|
|
||||||
// PrmSessionCreate groups parameters of SessionCreate operation.
|
// PrmSessionCreate groups parameters of SessionCreate operation.
|
||||||
type PrmSessionCreate struct {
|
type PrmSessionCreate struct {
|
||||||
prmCommonMeta
|
XHeaders []string
|
||||||
|
|
||||||
exp uint64
|
Expiration uint64
|
||||||
|
|
||||||
keySet bool
|
Key *ecdsa.PrivateKey
|
||||||
key ecdsa.PrivateKey
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetExp sets number of the last NepFS epoch in the lifetime of the session after which it will be expired.
|
// SetExp sets number of the last NepFS epoch in the lifetime of the session after which it will be expired.
|
||||||
|
//
|
||||||
|
// Deprecated: Use PrmSessionCreate.Expiration instead.
|
||||||
func (x *PrmSessionCreate) SetExp(exp uint64) {
|
func (x *PrmSessionCreate) SetExp(exp uint64) {
|
||||||
x.exp = exp
|
x.Expiration = exp
|
||||||
}
|
}
|
||||||
|
|
||||||
// UseKey specifies private key to sign the requests and compute token owner.
|
// UseKey specifies private key to sign the requests and compute token owner.
|
||||||
// If key is not provided, then Client default key is used.
|
// If key is not provided, then Client default key is used.
|
||||||
|
//
|
||||||
|
// Deprecated: Use PrmSessionCreate.Key instead.
|
||||||
func (x *PrmSessionCreate) UseKey(key ecdsa.PrivateKey) {
|
func (x *PrmSessionCreate) UseKey(key ecdsa.PrivateKey) {
|
||||||
x.keySet = true
|
x.Key = &key
|
||||||
x.key = key
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *PrmSessionCreate) buildRequest(c *Client) (*v2session.CreateRequest, error) {
|
func (x *PrmSessionCreate) buildRequest(c *Client) (*v2session.CreateRequest, error) {
|
||||||
ownerKey := c.prm.key.PublicKey
|
ownerKey := c.prm.key.PublicKey
|
||||||
if x.keySet {
|
if x.Key != nil {
|
||||||
ownerKey = x.key.PublicKey
|
ownerKey = x.Key.PublicKey
|
||||||
}
|
}
|
||||||
var ownerID user.ID
|
var ownerID user.ID
|
||||||
user.IDFromKey(&ownerID, ownerKey)
|
user.IDFromKey(&ownerID, ownerKey)
|
||||||
|
@ -49,10 +51,10 @@ func (x *PrmSessionCreate) buildRequest(c *Client) (*v2session.CreateRequest, er
|
||||||
|
|
||||||
reqBody := new(v2session.CreateRequestBody)
|
reqBody := new(v2session.CreateRequestBody)
|
||||||
reqBody.SetOwnerID(&ownerIDV2)
|
reqBody.SetOwnerID(&ownerIDV2)
|
||||||
reqBody.SetExpiration(x.exp)
|
reqBody.SetExpiration(x.Expiration)
|
||||||
|
|
||||||
var meta v2session.RequestMetaHeader
|
var meta v2session.RequestMetaHeader
|
||||||
writeXHeadersToMeta(x.xHeaders, &meta)
|
writeXHeadersToMeta(x.XHeaders, &meta)
|
||||||
|
|
||||||
var req v2session.CreateRequest
|
var req v2session.CreateRequest
|
||||||
req.SetBody(reqBody)
|
req.SetBody(reqBody)
|
||||||
|
|
Loading…
Reference in a new issue