[#265] reputation: Define structures of protobuf messages

Define Go structures of all messages from reputation package of NeoFs API.
Implement getters and setters of message fields.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2021-03-24 08:59:37 +03:00 committed by Leonard Lyubich
parent 5b33eaec36
commit 40505a523d

135
v2/reputation/types.go Normal file
View file

@ -0,0 +1,135 @@
package reputation
import (
"github.com/nspcc-dev/neofs-api-go/v2/session"
)
// Trust represents reputation.Trust message
// from NeoFS API v2.
type Trust struct {
val float64
peer []byte
}
// GetPeer returns trusted peer's ID.
func (x *Trust) GetPeer() []byte {
if x != nil {
return x.peer
}
return nil
}
// SetPeer sets trusted peer's ID.
func (x *Trust) SetPeer(v []byte) {
if x != nil {
x.peer = v
}
}
// GetValue returns trust value.
func (x *Trust) GetValue() float64 {
if x != nil {
return x.val
}
return 0
}
// SetValue sets trust value.
func (x *Trust) SetValue(v float64) {
if x != nil {
x.val = v
}
}
// SendLocalTrustRequestBody is a structure of SendLocalTrust request body.
type SendLocalTrustRequestBody struct {
epoch uint64
trusts []*Trust
}
// GetEpoch returns epoch in which the trust was assessed.
func (x *SendLocalTrustRequestBody) GetEpoch() uint64 {
if x != nil {
return x.epoch
}
return 0
}
// SetEpoch sets epoch in which the trust was assessed.
func (x *SendLocalTrustRequestBody) SetEpoch(v uint64) {
if x != nil {
x.epoch = v
}
}
// GetTrusts returns list of normalized trust values.
func (x *SendLocalTrustRequestBody) GetTrusts() []*Trust {
if x != nil {
return x.trusts
}
return nil
}
// SetTrusts sets list of normalized trust values.
func (x *SendLocalTrustRequestBody) SetTrusts(v []*Trust) {
if x != nil {
x.trusts = v
}
}
// SendLocalTrustResponseBody is a structure of SendLocalTrust response body.
type SendLocalTrustResponseBody struct{}
// SendLocalTrustRequest represents reputation.SendLocalTrustRequest
// message from NeoFS API v2.
type SendLocalTrustRequest struct {
body *SendLocalTrustRequestBody
session.RequestHeaders
}
// GetBody returns request body.
func (x *SendLocalTrustRequest) GetBody() *SendLocalTrustRequestBody {
if x != nil {
return x.body
}
return nil
}
// SetBody sets request body.
func (x *SendLocalTrustRequest) SetBody(v *SendLocalTrustRequestBody) {
if x != nil {
x.body = v
}
}
// SendLocalTrustResponse represents reputation.SendLocalTrustResponse
// message from NeoFS API v2.
type SendLocalTrustResponse struct {
body *SendLocalTrustResponseBody
session.ResponseHeaders
}
// GetBody returns response body.
func (x *SendLocalTrustResponse) GetBody() *SendLocalTrustResponseBody {
if x != nil {
return x.body
}
return nil
}
// SetBody sets response body.
func (x *SendLocalTrustResponse) SetBody(v *SendLocalTrustResponseBody) {
if x != nil {
x.body = v
}
}