package tree

import (
	"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/session"
	tree "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/pool/tree/service"
)

type AddRequest struct {
	body      *AddRequestBody
	signature *Signature
}

func (r *AddRequest) GetBody() *AddRequestBody {
	if r != nil {
		return r.body
	}

	return nil
}

func (r *AddRequest) SetBody(v *AddRequestBody) {
	r.body = v
}

func (r *AddRequest) GetSignature() *tree.Signature {
	return r.signature.ToGRPCMessage().(*tree.Signature)
}

func (r *AddRequest) SetSignature(signature *tree.Signature) error {
	if r.signature == nil {
		r.signature = new(Signature)
	}

	return r.signature.FromGRPCMessage(signature)
}

func (r *AddRequest) SignedDataSize() int {
	return r.body.ToGRPCMessage().(*tree.AddRequest_Body).StableSize()
}

func (r *AddRequest) ReadSignedData(buf []byte) ([]byte, error) {
	return r.body.ToGRPCMessage().(*tree.AddRequest_Body).StableMarshal(buf), nil
}

type AddRequestBody struct {
	containerID []byte
	bearerToken []byte
	treeID      string
	parentID    uint64
	meta        []*KeyValue
}

func (r *AddRequestBody) SetContainerID(v []byte) {
	r.containerID = v
}

func (r *AddRequestBody) SetBearerToken(v []byte) {
	r.bearerToken = v
}

func (r *AddRequestBody) SetTreeID(v string) {
	r.treeID = v
}

func (r *AddRequestBody) SetParentID(v uint64) {
	r.parentID = v
}

func (r *AddRequestBody) SetMeta(v []*KeyValue) {
	r.meta = v
}

type AddResponse struct {
	body      *AddResponseBody
	signature *Signature
}

func (r *AddResponse) GetBody() *AddResponseBody {
	if r != nil {
		return r.body
	}

	return nil
}

type AddResponseBody struct {
	nodeID uint64
}

func (r *AddResponseBody) GetNodeID() uint64 {
	if r != nil {
		return r.nodeID
	}

	return 0
}

type AddByPathRequest struct {
	body      *AddByPathRequestBody
	signature *Signature
}

func (r *AddByPathRequest) SetBody(v *AddByPathRequestBody) {
	r.body = v
}

func (r *AddByPathRequest) GetSignature() *tree.Signature {
	return r.signature.ToGRPCMessage().(*tree.Signature)
}

func (r *AddByPathRequest) SetSignature(signature *tree.Signature) error {
	if r.signature == nil {
		r.signature = new(Signature)
	}

	return r.signature.FromGRPCMessage(signature)
}

func (r *AddByPathRequest) SignedDataSize() int {
	return r.body.ToGRPCMessage().(*tree.AddByPathRequest_Body).StableSize()
}

func (r *AddByPathRequest) ReadSignedData(bytes []byte) ([]byte, error) {
	return r.body.ToGRPCMessage().(*tree.AddByPathRequest_Body).StableMarshal(bytes), nil
}

type AddByPathRequestBody struct {
	containerID   []byte
	treeID        string
	pathAttribute string
	path          []string
	meta          []*KeyValue
	bearerToken   []byte
}

func (r *AddByPathRequestBody) SetContainerID(v []byte) {
	r.containerID = v
}

func (r *AddByPathRequestBody) SetBearerToken(v []byte) {
	r.bearerToken = v
}

func (r *AddByPathRequestBody) SetTreeID(v string) {
	r.treeID = v
}

func (r *AddByPathRequestBody) SetPathAttribute(v string) {
	r.pathAttribute = v
}

func (r *AddByPathRequestBody) SetPath(v []string) {
	r.path = v
}

func (r *AddByPathRequestBody) SetMeta(v []*KeyValue) {
	r.meta = v
}

type AddByPathResponse struct {
	body      *AddByPathResponseBody
	signature *Signature
}

func (r *AddByPathResponse) GetBody() *AddByPathResponseBody {
	if r != nil {
		return r.body
	}

	return nil
}

func (r *AddByPathResponse) GetSignature() *Signature {
	if r != nil {
		return r.signature
	}

	return nil
}

type AddByPathResponseBody struct {
	nodes    []uint64
	parentID uint64
}

func (r *AddByPathResponseBody) GetNodes() []uint64 {
	if r != nil {
		return r.nodes
	}

	return nil
}

func (r *AddByPathResponseBody) GetParentID() uint64 {
	if r != nil {
		return r.parentID
	}

	return 0
}

type RemoveRequest struct {
	body      *RemoveRequestBody
	signature *Signature
}

func (r *RemoveRequest) SetBody(v *RemoveRequestBody) {
	r.body = v
}

func (r *RemoveRequest) GetSignature() *tree.Signature {
	return r.signature.ToGRPCMessage().(*tree.Signature)
}

func (r *RemoveRequest) SetSignature(signature *tree.Signature) error {
	if r.signature == nil {
		r.signature = new(Signature)
	}

	return r.signature.FromGRPCMessage(signature)
}

func (r *RemoveRequest) SignedDataSize() int {
	return r.body.ToGRPCMessage().(*tree.RemoveRequest_Body).StableSize()
}

func (r *RemoveRequest) ReadSignedData(bytes []byte) ([]byte, error) {
	return r.body.ToGRPCMessage().(*tree.RemoveRequest_Body).StableMarshal(bytes), nil
}

type RemoveRequestBody struct {
	containerID []byte
	treeID      string
	nodeID      uint64
	bearerToken []byte
}

func (r *RemoveRequestBody) SetContainerID(v []byte) {
	r.containerID = v
}

func (r *RemoveRequestBody) SetBearerToken(v []byte) {
	r.bearerToken = v
}

func (r *RemoveRequestBody) SetTreeID(v string) {
	r.treeID = v
}

func (r *RemoveRequestBody) SetNodeID(v uint64) {
	r.nodeID = v
}

type RemoveResponse struct {
	body      *RemoveResponseBody
	signature *Signature
}

func (r *RemoveResponse) GetBody() *RemoveResponseBody {
	if r != nil {
		return r.body
	}
	return nil
}

func (r *RemoveResponse) GetSignature() *Signature {
	if r != nil {
		return r.signature
	}
	return nil
}

type RemoveResponseBody struct{}

type MoveRequest struct {
	body      *MoveRequestBody
	signature *Signature
}

func (r *MoveRequest) SetBody(v *MoveRequestBody) {
	r.body = v
}

func (r *MoveRequest) GetSignature() *tree.Signature {
	return r.signature.ToGRPCMessage().(*tree.Signature)
}

func (r *MoveRequest) SetSignature(signature *tree.Signature) error {
	if r.signature == nil {
		r.signature = new(Signature)
	}

	return r.signature.FromGRPCMessage(signature)
}

func (r *MoveRequest) SignedDataSize() int {
	return r.body.ToGRPCMessage().(*tree.MoveRequest_Body).StableSize()
}

func (r *MoveRequest) ReadSignedData(buf []byte) ([]byte, error) {
	return r.body.ToGRPCMessage().(*tree.MoveRequest_Body).StableMarshal(buf), nil
}

type MoveRequestBody struct {
	containerID []byte
	treeID      string
	parentID    uint64
	nodeID      uint64
	meta        []*KeyValue
	bearerToken []byte
}

func (r *MoveRequestBody) SetContainerID(v []byte) {
	r.containerID = v
}

func (r *MoveRequestBody) SetBearerToken(v []byte) {
	r.bearerToken = v
}

func (r *MoveRequestBody) SetTreeID(v string) {
	r.treeID = v
}

func (r *MoveRequestBody) SetNodeID(v uint64) {
	r.nodeID = v
}

func (r *MoveRequestBody) SetMeta(v []*KeyValue) {
	r.meta = v
}

func (r *MoveRequestBody) SetParentID(v uint64) {
	r.parentID = v
}

type MoveResponse struct {
	body      *MoveResponseBody
	signature *Signature
}

func (r *MoveResponse) GetBody() *MoveResponseBody {
	if r != nil {
		return r.body
	}
	return nil
}

func (r *MoveResponse) GetSignature() *Signature {
	if r != nil {
		return r.signature
	}

	return nil
}

type MoveResponseBody struct{}

type GetNodeByPathRequest struct {
	body      *GetNodeByPathRequestBody
	signature *Signature
}

func (r *GetNodeByPathRequest) SetBody(v *GetNodeByPathRequestBody) {
	r.body = v
}

func (r *GetNodeByPathRequest) GetSignature() *tree.Signature {
	return r.signature.ToGRPCMessage().(*tree.Signature)
}

func (r *GetNodeByPathRequest) SetSignature(signature *tree.Signature) error {
	if r.signature == nil {
		r.signature = new(Signature)
	}
	return r.signature.FromGRPCMessage(signature)
}

func (r *GetNodeByPathRequest) SignedDataSize() int {
	return r.body.ToGRPCMessage().(*tree.GetNodeByPathRequest_Body).StableSize()
}

func (r *GetNodeByPathRequest) ReadSignedData(buf []byte) ([]byte, error) {
	return r.body.ToGRPCMessage().(*tree.GetNodeByPathRequest_Body).StableMarshal(buf), nil
}

type GetNodeByPathRequestBody struct {
	containerID   []byte
	treeID        string
	pathAttribute string
	path          []string
	attributes    []string
	latestOnly    bool
	allAttributes bool
	bearerToken   []byte
}

func (r *GetNodeByPathRequestBody) SetContainerID(v [32]byte) {
	r.containerID = v[:]
}

func (r *GetNodeByPathRequestBody) SetBearerToken(v []byte) {
	r.bearerToken = v
}

func (r *GetNodeByPathRequestBody) SetTreeID(v string) {
	r.treeID = v
}

func (r *GetNodeByPathRequestBody) SetPathAttribute(v string) {
	r.pathAttribute = v
}

func (r *GetNodeByPathRequestBody) SetParentID(v string) {
	r.pathAttribute = v
}

func (r *GetNodeByPathRequestBody) SetPath(v []string) {
	r.path = v
}

func (r *GetNodeByPathRequestBody) SetAttributes(v []string) {
	r.attributes = v
}

func (r *GetNodeByPathRequestBody) SetAllAttributes(v bool) {
	r.allAttributes = v
}

func (r *GetNodeByPathRequestBody) SetLatestOnly(v bool) {
	r.latestOnly = v
}

type GetNodeByPathResponse struct {
	body      *GetNodeByPathResponseBody
	signature *Signature
}

func (r *GetNodeByPathResponse) GetBody() *GetNodeByPathResponseBody {
	if r != nil {
		return r.body
	}
	return nil
}

func (r *GetNodeByPathResponse) GetSignature() *Signature {
	if r != nil {
		return r.signature
	}

	return nil
}

type GetNodeByPathResponseBody struct {
	nodes []*GetNodeByPathResponseInfo
}

func (r *GetNodeByPathResponseBody) GetNodes() []*GetNodeByPathResponseInfo {
	if r != nil {
		return r.nodes
	}
	return nil
}

type GetNodeByPathResponseInfo struct {
	nodeID    uint64
	timestamp uint64
	meta      []*KeyValue
	parentID  uint64
}

func (r *GetNodeByPathResponseInfo) GetNodeID() uint64 {
	if r != nil {
		return r.nodeID
	}

	return 0
}

func (r *GetNodeByPathResponseInfo) GetTimestamp() uint64 {
	if r != nil {
		return r.timestamp
	}

	return 0
}

func (r *GetNodeByPathResponseInfo) GetParentID() uint64 {
	if r != nil {
		return r.parentID
	}

	return 0
}

func (r *GetNodeByPathResponseInfo) GetMeta() []*KeyValue {
	if r != nil {
		return r.meta
	}

	return nil
}

type ListRequest struct {
	body      *ListRequestBody
	signature *Signature
}

func (r *ListRequest) SetBody(v *ListRequestBody) {
	r.body = v
}

type ListRequestBody struct {
	containerID []byte
}

func (r *ListRequestBody) SetContainerID(v []byte) {
	r.containerID = v
}

type ListResponse struct {
	body      *ListResponseBody
	signature *Signature
}

func (r *ListResponse) GetBody() *ListResponseBody {
	if r != nil {
		return r.body
	}
	return nil
}

func (r *ListResponse) GetSignature() *Signature {
	if r != nil {
		return r.signature
	}

	return nil
}

type ListResponseBody struct {
	ids []string
}

func (r *ListResponseBody) GetIDs() []string {
	if r != nil {
		return r.ids
	}
	return nil
}

type GetSubTreeRequest struct {
	body      *GetSubTreeRequestBody
	signature *Signature
}

func (r *GetSubTreeRequest) SetBody(v *GetSubTreeRequestBody) {
	r.body = v
}

func (r *GetSubTreeRequest) GetSignature() *tree.Signature {
	return r.signature.ToGRPCMessage().(*tree.Signature)
}

func (r *GetSubTreeRequest) SetSignature(signature *tree.Signature) error {
	if r.signature == nil {
		r.signature = new(Signature)
	}

	return r.signature.FromGRPCMessage(signature)
}

func (r *GetSubTreeRequest) SignedDataSize() int {
	return r.body.ToGRPCMessage().(*tree.GetSubTreeRequest_Body).StableSize()
}

func (r *GetSubTreeRequest) ReadSignedData(buf []byte) ([]byte, error) {
	return r.body.ToGRPCMessage().(*tree.GetSubTreeRequest_Body).StableMarshal(buf), nil
}

type GetSubTreeRequestBody struct {
	containerID []byte
	treeID      string
	rootID      []uint64
	depth       uint32
	bearerToken []byte
	orderBy     *GetSubTreeRequestBodyOrder
}

func (r *GetSubTreeRequestBody) SetContainerID(v []byte) {
	r.containerID = v
}

func (r *GetSubTreeRequestBody) SetBearerToken(v []byte) {
	r.bearerToken = v
}

func (r *GetSubTreeRequestBody) SetTreeID(v string) {
	r.treeID = v
}

func (r *GetSubTreeRequestBody) SetRootID(v []uint64) {
	r.rootID = v
}

func (r *GetSubTreeRequestBody) SetDepth(v uint32) {
	r.depth = v
}

func (r *GetSubTreeRequestBody) SetOrderBy(v *GetSubTreeRequestBodyOrder) {
	r.orderBy = v
}

type GetSubTreeRequestBodyOrder struct {
	direction GetSubTreeRequestBodyOrderDirection
}

func (r *GetSubTreeRequestBodyOrder) SetDirection(v GetSubTreeRequestBodyOrderDirection) {
	r.direction = v
}

const (
	GetSubTreeRequestBodyOrderNone = GetSubTreeRequestBodyOrderDirection(tree.GetSubTreeRequest_Body_Order_None)
	GetSubTreeRequestBodyOrderAsc  = GetSubTreeRequestBodyOrderDirection(tree.GetSubTreeRequest_Body_Order_Asc)
)

type GetSubTreeRequestBodyOrderDirection int32

type GetSubTreeResponse struct {
	body      *GetSubTreeResponseBody
	signature *Signature
}

func (r *GetSubTreeResponse) GetBody() *GetSubTreeResponseBody {
	if r != nil {
		return r.body
	}
	return nil
}

func (r *GetSubTreeResponse) GetSignature() *Signature {
	if r != nil {
		return r.signature
	}

	return nil
}

type GetSubTreeResponseBody struct {
	nodeID    []uint64
	parentID  []uint64
	timestamp []uint64
	meta      []*KeyValue
}

func (r *GetSubTreeResponseBody) GetNodeID() []uint64 {
	if r != nil {
		return r.nodeID
	}

	return nil
}

func (r *GetSubTreeResponseBody) GetParentID() []uint64 {
	if r != nil {
		return r.parentID
	}

	return nil
}

func (r *GetSubTreeResponseBody) GetTimestamp() []uint64 {
	if r != nil {
		return r.timestamp
	}

	return nil
}

func (r *GetSubTreeResponseBody) GetMeta() []*KeyValue {
	if r != nil {
		return r.meta
	}

	return nil
}

type ApplyRequest struct {
	body      *ApplyRequestBody
	signature *Signature
}

func (r *ApplyRequest) SetBody(v *ApplyRequestBody) {
	r.body = v
}

type ApplyRequestBody struct {
	containerID []byte
	treeID      string
	operation   *LogMove
}

func (r *ApplyRequestBody) SetContainerID(v []byte) {
	r.containerID = v
}

func (r *ApplyRequestBody) SetTreeID(v string) {
	r.treeID = v
}

func (r *ApplyRequestBody) SetOperation(v *LogMove) {
	r.operation = v
}

type ApplyResponse struct {
	body      *ApplyResponseBody
	signature *Signature
}

func (r *ApplyResponse) GetBody() *ApplyResponseBody {
	if r != nil {
		return r.body
	}
	return nil
}

func (r *ApplyResponse) GetSignature() *Signature {
	if r != nil {
		return r.signature
	}

	return nil
}

type ApplyResponseBody struct{}

type GetOpLogRequest struct {
	body      *GetOpLogRequestBody
	signature *Signature
}

func (r *GetOpLogRequest) SetBody(v *GetOpLogRequestBody) {
	r.body = v
}

func (r *GetOpLogRequest) GetSignature() *tree.Signature {
	return r.signature.ToGRPCMessage().(*tree.Signature)
}

func (r *GetOpLogRequest) SetSignature(signature *tree.Signature) error {
	if r.signature == nil {
		r.signature = new(Signature)
	}

	return r.signature.FromGRPCMessage(signature)
}

func (r *GetOpLogRequest) SignedDataSize() int {
	return r.body.ToGRPCMessage().(*tree.GetSubTreeRequest_Body).StableSize()
}

func (r *GetOpLogRequest) ReadSignedData(buf []byte) ([]byte, error) {
	return r.body.ToGRPCMessage().(*tree.GetSubTreeRequest_Body).StableMarshal(buf), nil
}

type GetOpLogRequestBody struct {
	containerID []byte
	treeID      string
	height      uint64
	count       uint64
}

func (r *GetOpLogRequestBody) SetTreeID(v string) {
	r.treeID = v
}

func (r *GetOpLogRequestBody) SetContainerID(v []byte) {
	r.containerID = v
}

func (r *GetOpLogRequestBody) SetHeight(v uint64) {
	r.height = v
}

func (r *GetOpLogRequestBody) SetCount(v uint64) {
	r.count = v
}

type GetOpLogResponse struct {
	body      *GetOpLogResponseBody
	signature *Signature
}

func (r *GetOpLogResponse) GetBody() *GetOpLogResponseBody {
	if r != nil {
		return r.body
	}
	return nil
}

func (r *GetOpLogResponse) GetSignature() *Signature {
	if r != nil {
		return r.signature
	}

	return nil
}

type GetOpLogResponseBody struct {
	operation *LogMove
}

func (r *GetOpLogResponseBody) GetOperation() *LogMove {
	if r != nil {
		return r.operation
	}

	return nil
}

type HealthcheckRequest struct {
	body      *HealthcheckRequestBody
	signature *Signature

	session.RequestHeaders
}

func (r *HealthcheckRequest) SetBody(v *HealthcheckRequestBody) {
	r.body = v
}

type HealthcheckRequestBody struct{}

type HealthcheckResponse struct {
	body      *HealthcheckResponseBody
	signature *Signature
}

func (r *HealthcheckResponse) GetBody() *HealthcheckResponseBody {
	if r != nil {
		return r.body
	}
	return nil
}

func (r *HealthcheckResponse) GetSignature() *Signature {
	if r != nil {
		return r.signature
	}

	return nil
}

type HealthcheckResponseBody struct{}

type LogMove struct {
	parentID uint64
	meta     []byte
	childID  uint64
}

func (g *LogMove) GetParentID() uint64 {
	if g != nil {
		return g.parentID
	}

	return 0
}

func (g *LogMove) SetParentID(v uint64) {
	g.parentID = v
}

func (g *LogMove) GetMeta() []byte {
	if g != nil {
		return g.meta
	}

	return nil
}

func (g *LogMove) SetMeta(v []byte) {
	g.meta = v
}

func (g *LogMove) GetChildID() []byte {
	if g != nil {
		return g.meta
	}

	return nil
}

func (g *LogMove) SetChildID(v []byte) {
	g.meta = v
}

type Signature struct {
	key  []byte
	sign []byte
}

func (s *Signature) GetKey() []byte {
	if s != nil {
		return s.key
	}

	return nil
}

func (s *Signature) SetKey(v []byte) {
	s.key = v
}

func (s *Signature) GetSign() []byte {
	if s != nil {
		return s.sign
	}

	return nil
}

func (s *Signature) SetSign(v []byte) {
	s.sign = v
}

type KeyValue struct {
	key   string
	value []byte
}

func (k *KeyValue) GetKey() string {
	if k != nil {
		return k.key
	}

	return ""
}

func (k *KeyValue) SetKey(v string) {
	k.key = v
}

func (k *KeyValue) GetValue() []byte {
	if k != nil {
		return k.value
	}
	return nil
}

func (k *KeyValue) SetValue(v []byte) {
	k.value = v
}