From 40505a523d7f31528ef34d2abd195177e906787a Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Wed, 24 Mar 2021 08:59:37 +0300 Subject: [PATCH] [#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 --- v2/reputation/types.go | 135 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 135 insertions(+) create mode 100644 v2/reputation/types.go diff --git a/v2/reputation/types.go b/v2/reputation/types.go new file mode 100644 index 00000000..12cb3dec --- /dev/null +++ b/v2/reputation/types.go @@ -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 + } +}