2020-08-20 10:32:02 +00:00
|
|
|
package session
|
2020-08-12 19:06:10 +00:00
|
|
|
|
|
|
|
import (
|
2020-08-14 16:00:16 +00:00
|
|
|
acl "github.com/nspcc-dev/neofs-api-go/v2/acl/grpc"
|
|
|
|
refs "github.com/nspcc-dev/neofs-api-go/v2/refs/grpc"
|
2021-11-06 10:40:15 +00:00
|
|
|
status "github.com/nspcc-dev/neofs-api-go/v2/status/grpc"
|
2020-08-12 19:06:10 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// SetKey sets key to the X-Header.
|
|
|
|
func (m *XHeader) SetKey(v string) {
|
2022-03-23 11:42:57 +00:00
|
|
|
m.Key = v
|
2020-08-12 19:06:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// SetValue sets value of the X-Header.
|
|
|
|
func (m *XHeader) SetValue(v string) {
|
2022-03-23 11:42:57 +00:00
|
|
|
m.Value = v
|
2020-08-12 19:06:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// SetExp sets epoch number of the token expiration.
|
2020-08-20 10:32:02 +00:00
|
|
|
func (m *SessionToken_Body_TokenLifetime) SetExp(v uint64) {
|
2022-03-23 11:42:57 +00:00
|
|
|
m.Exp = v
|
2020-08-12 19:06:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// SetNbf sets starting epoch number of the token.
|
2020-08-20 10:32:02 +00:00
|
|
|
func (m *SessionToken_Body_TokenLifetime) SetNbf(v uint64) {
|
2022-03-23 11:42:57 +00:00
|
|
|
m.Nbf = v
|
2020-08-12 19:06:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// SetIat sets the number of the epoch in which the token was issued.
|
2020-08-20 10:32:02 +00:00
|
|
|
func (m *SessionToken_Body_TokenLifetime) SetIat(v uint64) {
|
2022-03-23 11:42:57 +00:00
|
|
|
m.Iat = v
|
2020-08-12 19:06:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// SetId sets identifier of the session token.
|
|
|
|
func (m *SessionToken_Body) SetId(v []byte) {
|
2022-03-23 11:42:57 +00:00
|
|
|
m.Id = v
|
2020-08-12 19:06:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// SetOwnerId sets identifier of the session token owner.
|
|
|
|
func (m *SessionToken_Body) SetOwnerId(v *refs.OwnerID) {
|
2022-03-23 11:42:57 +00:00
|
|
|
m.OwnerId = v
|
2020-08-12 19:06:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// SetLifetime sets lifetime of the session token.
|
2020-08-20 10:32:02 +00:00
|
|
|
func (m *SessionToken_Body) SetLifetime(v *SessionToken_Body_TokenLifetime) {
|
2022-03-23 11:42:57 +00:00
|
|
|
m.Lifetime = v
|
2020-08-12 19:06:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// SetSessionKey sets public session key in a binary format.
|
|
|
|
func (m *SessionToken_Body) SetSessionKey(v []byte) {
|
2022-03-23 11:42:57 +00:00
|
|
|
m.SessionKey = v
|
2020-08-12 19:06:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// SetObjectAddressContext sets object context of the session token.
|
2020-08-20 10:32:02 +00:00
|
|
|
func (m *SessionToken_Body) SetObjectSessionContext(v *ObjectSessionContext) {
|
2022-03-23 11:42:57 +00:00
|
|
|
m.Context = &SessionToken_Body_Object{
|
|
|
|
Object: v,
|
2020-08-12 19:06:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-24 12:54:49 +00:00
|
|
|
// SetContainerSessionContext sets container context of the session token.
|
|
|
|
func (m *SessionToken_Body) SetContainerSessionContext(v *ContainerSessionContext) {
|
2022-03-23 11:42:57 +00:00
|
|
|
m.Context = &SessionToken_Body_Container{
|
|
|
|
Container: v,
|
2021-05-24 12:54:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-16 15:09:25 +00:00
|
|
|
// SetTarget specifies objects involved in the object session.
|
|
|
|
func (m *ObjectSessionContext) SetTarget(cnr *refs.ContainerID, objs []*refs.ObjectID) {
|
|
|
|
m.Target = &ObjectSessionContext_Target{
|
|
|
|
Container: cnr,
|
|
|
|
Objects: objs,
|
|
|
|
}
|
2020-08-17 11:30:09 +00:00
|
|
|
}
|
|
|
|
|
2021-05-24 12:50:19 +00:00
|
|
|
// SetVerb sets type of request for which the token is issued.
|
2020-08-18 12:48:39 +00:00
|
|
|
func (m *ObjectSessionContext) SetVerb(v ObjectSessionContext_Verb) {
|
2022-03-23 11:42:57 +00:00
|
|
|
m.Verb = v
|
2020-08-17 11:30:09 +00:00
|
|
|
}
|
|
|
|
|
2021-05-24 12:54:49 +00:00
|
|
|
// SetVerb sets type of request for which the token is issued.
|
|
|
|
func (x *ContainerSessionContext) SetVerb(v ContainerSessionContext_Verb) {
|
2022-03-23 11:42:57 +00:00
|
|
|
x.Verb = v
|
2021-05-24 12:54:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// SetWildcard sets wildcard flag of the container session.
|
|
|
|
func (x *ContainerSessionContext) SetWildcard(v bool) {
|
2022-03-23 11:42:57 +00:00
|
|
|
x.Wildcard = v
|
2021-05-24 12:54:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// SetContainerId sets identifier of the container related to the session.
|
|
|
|
func (x *ContainerSessionContext) SetContainerId(v *refs.ContainerID) {
|
2022-03-23 11:42:57 +00:00
|
|
|
x.ContainerId = v
|
2021-05-24 12:54:49 +00:00
|
|
|
}
|
|
|
|
|
2020-08-12 19:06:10 +00:00
|
|
|
// SetBody sets session token body.
|
|
|
|
func (m *SessionToken) SetBody(v *SessionToken_Body) {
|
2022-03-23 11:42:57 +00:00
|
|
|
m.Body = v
|
2020-08-12 19:06:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// SetSignature sets session token signature.
|
2020-08-20 10:32:02 +00:00
|
|
|
func (m *SessionToken) SetSignature(v *refs.Signature) {
|
2022-03-23 11:42:57 +00:00
|
|
|
m.Signature = v
|
2020-08-12 19:06:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// SetVersion sets client protocol version.
|
2020-08-20 10:32:02 +00:00
|
|
|
func (m *RequestMetaHeader) SetVersion(v *refs.Version) {
|
2022-03-23 11:42:57 +00:00
|
|
|
m.Version = v
|
2020-08-12 19:06:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// SetEpoch sets client local epoch.
|
|
|
|
func (m *RequestMetaHeader) SetEpoch(v uint64) {
|
2022-03-23 11:42:57 +00:00
|
|
|
m.Epoch = v
|
2020-08-12 19:06:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// SetTtl sets request TTL.
|
|
|
|
func (m *RequestMetaHeader) SetTtl(v uint32) {
|
2022-03-23 11:42:57 +00:00
|
|
|
m.Ttl = v
|
2020-08-12 19:06:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// SetXHeaders sets request X-Headers.
|
|
|
|
func (m *RequestMetaHeader) SetXHeaders(v []*XHeader) {
|
2022-03-23 11:42:57 +00:00
|
|
|
m.XHeaders = v
|
2020-08-12 19:06:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// SetSessionToken sets session token of the request.
|
|
|
|
func (m *RequestMetaHeader) SetSessionToken(v *SessionToken) {
|
2022-03-23 11:42:57 +00:00
|
|
|
m.SessionToken = v
|
2020-08-12 19:06:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// SetBearerToken sets bearer token of the request.
|
2020-08-20 10:32:02 +00:00
|
|
|
func (m *RequestMetaHeader) SetBearerToken(v *acl.BearerToken) {
|
2022-03-23 11:42:57 +00:00
|
|
|
m.BearerToken = v
|
2020-08-12 19:06:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// SetOrigin sets origin request meta header.
|
|
|
|
func (m *RequestMetaHeader) SetOrigin(v *RequestMetaHeader) {
|
2022-03-23 11:42:57 +00:00
|
|
|
m.Origin = v
|
2020-08-12 19:06:10 +00:00
|
|
|
}
|
|
|
|
|
2022-01-13 12:25:03 +00:00
|
|
|
// GetNetworkMagic returns NeoFS network magic.
|
|
|
|
func (m *RequestMetaHeader) GetNetworkMagic() uint64 {
|
|
|
|
if m != nil {
|
|
|
|
return m.MagicNumber
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetNetworkMagic sets NeoFS network magic.
|
|
|
|
func (m *RequestMetaHeader) SetNetworkMagic(v uint64) {
|
2022-03-23 11:42:57 +00:00
|
|
|
m.MagicNumber = v
|
2022-01-13 12:25:03 +00:00
|
|
|
}
|
|
|
|
|
2020-08-12 19:06:10 +00:00
|
|
|
// SetVersion sets server protocol version.
|
2020-08-20 10:32:02 +00:00
|
|
|
func (m *ResponseMetaHeader) SetVersion(v *refs.Version) {
|
2022-03-23 11:42:57 +00:00
|
|
|
m.Version = v
|
2020-08-12 19:06:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// SetEpoch sets server local epoch.
|
|
|
|
func (m *ResponseMetaHeader) SetEpoch(v uint64) {
|
2022-03-23 11:42:57 +00:00
|
|
|
m.Epoch = v
|
2020-08-12 19:06:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// SetTtl sets response TTL.
|
|
|
|
func (m *ResponseMetaHeader) SetTtl(v uint32) {
|
2022-03-23 11:42:57 +00:00
|
|
|
m.Ttl = v
|
2020-08-12 19:06:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// SetXHeaders sets response X-Headers.
|
|
|
|
func (m *ResponseMetaHeader) SetXHeaders(v []*XHeader) {
|
2022-03-23 11:42:57 +00:00
|
|
|
m.XHeaders = v
|
2020-08-12 19:06:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// SetOrigin sets origin response meta header.
|
|
|
|
func (m *ResponseMetaHeader) SetOrigin(v *ResponseMetaHeader) {
|
2022-03-23 11:42:57 +00:00
|
|
|
m.Origin = v
|
2020-08-12 19:06:10 +00:00
|
|
|
}
|
2020-08-20 10:32:02 +00:00
|
|
|
|
2021-11-06 10:40:15 +00:00
|
|
|
// SetStatus sets response status.
|
|
|
|
func (m *ResponseMetaHeader) SetStatus(v *status.Status) {
|
2022-03-23 11:42:57 +00:00
|
|
|
m.Status = v
|
2021-11-06 10:40:15 +00:00
|
|
|
}
|
|
|
|
|
2020-08-20 10:32:02 +00:00
|
|
|
// SetBodySignature sets signature of the request body.
|
|
|
|
func (m *RequestVerificationHeader) SetBodySignature(v *refs.Signature) {
|
2022-03-23 11:42:57 +00:00
|
|
|
m.BodySignature = v
|
2020-08-20 10:32:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// SetMetaSignature sets signature of the request meta.
|
|
|
|
func (m *RequestVerificationHeader) SetMetaSignature(v *refs.Signature) {
|
2022-03-23 11:42:57 +00:00
|
|
|
m.MetaSignature = v
|
2020-08-20 10:32:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// SetOriginSignature sets signature of the origin verification header of the request.
|
|
|
|
func (m *RequestVerificationHeader) SetOriginSignature(v *refs.Signature) {
|
2022-03-23 11:42:57 +00:00
|
|
|
m.OriginSignature = v
|
2020-08-20 10:32:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// SetOrigin sets origin verification header of the request.
|
|
|
|
func (m *RequestVerificationHeader) SetOrigin(v *RequestVerificationHeader) {
|
2022-03-23 11:42:57 +00:00
|
|
|
m.Origin = v
|
2020-08-20 10:32:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// SetBodySignature sets signature of the response body.
|
|
|
|
func (m *ResponseVerificationHeader) SetBodySignature(v *refs.Signature) {
|
2022-03-23 11:42:57 +00:00
|
|
|
m.BodySignature = v
|
2020-08-20 10:32:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// SetMetaSignature sets signature of the response meta.
|
|
|
|
func (m *ResponseVerificationHeader) SetMetaSignature(v *refs.Signature) {
|
2022-03-23 11:42:57 +00:00
|
|
|
m.MetaSignature = v
|
2020-08-20 10:32:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// SetOriginSignature sets signature of the origin verification header of the response.
|
|
|
|
func (m *ResponseVerificationHeader) SetOriginSignature(v *refs.Signature) {
|
2022-03-23 11:42:57 +00:00
|
|
|
m.OriginSignature = v
|
2020-08-20 10:32:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// SetOrigin sets origin verification header of the response.
|
|
|
|
func (m *ResponseVerificationHeader) SetOrigin(v *ResponseVerificationHeader) {
|
2022-03-23 11:42:57 +00:00
|
|
|
m.Origin = v
|
2020-08-20 10:32:02 +00:00
|
|
|
}
|
2021-06-18 12:27:01 +00:00
|
|
|
|
|
|
|
// FromString parses ObjectSessionContext_Verb from a string representation,
|
|
|
|
// It is a reverse action to String().
|
|
|
|
//
|
|
|
|
// Returns true if s was parsed successfully.
|
|
|
|
func (x *ObjectSessionContext_Verb) FromString(s string) bool {
|
|
|
|
i, ok := ObjectSessionContext_Verb_value[s]
|
|
|
|
if ok {
|
|
|
|
*x = ObjectSessionContext_Verb(i)
|
|
|
|
}
|
|
|
|
|
|
|
|
return ok
|
|
|
|
}
|
|
|
|
|
|
|
|
// FromString parses ContainerSessionContext_Verb from a string representation,
|
|
|
|
// It is a reverse action to String().
|
|
|
|
//
|
|
|
|
// Returns true if s was parsed successfully.
|
|
|
|
func (x *ContainerSessionContext_Verb) FromString(s string) bool {
|
|
|
|
i, ok := ContainerSessionContext_Verb_value[s]
|
|
|
|
if ok {
|
|
|
|
*x = ContainerSessionContext_Verb(i)
|
|
|
|
}
|
|
|
|
|
|
|
|
return ok
|
|
|
|
}
|