forked from TrueCloudLab/frostfs-node
[#971] morph/audit: Add optional parameters
Add optional parameters to the client call signature. Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
parent
ed4810a020
commit
8a2f5c980b
2 changed files with 19 additions and 2 deletions
|
@ -10,6 +10,8 @@ import (
|
||||||
// of "put audit result" invocation call.
|
// of "put audit result" invocation call.
|
||||||
type PutAuditResultArgs struct {
|
type PutAuditResultArgs struct {
|
||||||
rawResult []byte // audit result in NeoFS API-compatible binary representation
|
rawResult []byte // audit result in NeoFS API-compatible binary representation
|
||||||
|
|
||||||
|
client.InvokePrmOptional
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetRawResult sets audit result structure
|
// SetRawResult sets audit result structure
|
||||||
|
@ -25,6 +27,7 @@ func (c *Client) PutAuditResult(args PutAuditResultArgs) error {
|
||||||
|
|
||||||
prm.SetMethod(c.putResultMethod)
|
prm.SetMethod(c.putResultMethod)
|
||||||
prm.SetArgs(args.rawResult)
|
prm.SetArgs(args.rawResult)
|
||||||
|
prm.InvokePrmOptional = args.InvokePrmOptional
|
||||||
|
|
||||||
err := c.client.Invoke(prm)
|
err := c.client.Invoke(prm)
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/nspcc-dev/neofs-node/pkg/morph/client"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/morph/client/audit"
|
"github.com/nspcc-dev/neofs-node/pkg/morph/client/audit"
|
||||||
auditAPI "github.com/nspcc-dev/neofs-sdk-go/audit"
|
auditAPI "github.com/nspcc-dev/neofs-sdk-go/audit"
|
||||||
cid "github.com/nspcc-dev/neofs-sdk-go/container/id"
|
cid "github.com/nspcc-dev/neofs-sdk-go/container/id"
|
||||||
|
@ -14,18 +15,31 @@ type ResultID []byte
|
||||||
|
|
||||||
var errUnsupported = errors.New("unsupported structure version")
|
var errUnsupported = errors.New("unsupported structure version")
|
||||||
|
|
||||||
|
// PutPrm groups parameters of PutAuditResult operation.
|
||||||
|
type PutPrm struct {
|
||||||
|
result *auditAPI.Result
|
||||||
|
|
||||||
|
client.InvokePrmOptional
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetResult sets audit result.
|
||||||
|
func (p *PutPrm) SetResult(result *auditAPI.Result) {
|
||||||
|
p.result = result
|
||||||
|
}
|
||||||
|
|
||||||
// PutAuditResult saves passed audit result structure in NeoFS system
|
// PutAuditResult saves passed audit result structure in NeoFS system
|
||||||
// through Audit contract call.
|
// through Audit contract call.
|
||||||
//
|
//
|
||||||
// Returns encountered error that caused the saving to interrupt.
|
// Returns encountered error that caused the saving to interrupt.
|
||||||
func (w *ClientWrapper) PutAuditResult(result *auditAPI.Result) error {
|
func (w *ClientWrapper) PutAuditResult(prm PutPrm) error {
|
||||||
rawResult, err := result.Marshal()
|
rawResult, err := prm.result.Marshal()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("could not marshal audit result: %w", err)
|
return fmt.Errorf("could not marshal audit result: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
args := audit.PutAuditResultArgs{}
|
args := audit.PutAuditResultArgs{}
|
||||||
args.SetRawResult(rawResult)
|
args.SetRawResult(rawResult)
|
||||||
|
args.InvokePrmOptional = prm.InvokePrmOptional
|
||||||
|
|
||||||
return w.client.
|
return w.client.
|
||||||
PutAuditResult(args)
|
PutAuditResult(args)
|
||||||
|
|
Loading…
Reference in a new issue