forked from TrueCloudLab/frostfs-sdk-go
Compare commits
182 commits
feature/12
...
master
Author | SHA1 | Date | |
---|---|---|---|
87bb55f992 | |||
a262a0038f | |||
fe5b28e6bf | |||
749b4e9ab5 | |||
f70c0c9081 | |||
17177697b5 | |||
56046935b0 | |||
cee7f9de47 | |||
d77a8742bc | |||
b083bf8546 | |||
b480df99ca | |||
69b0711d12 | |||
7a37613988 | |||
d592bb931e | |||
06ef257ddc | |||
2d08fa5240 | |||
c5991fc66d | |||
f78fb6dcb0 | |||
c8d71c450a | |||
2b8329e026 | |||
ada0513504 | |||
c3f7378887 | |||
bcb5fd22d4 | |||
148a341b6f | |||
56892e48ac | |||
7bdc78f2b5 | |||
cf0bbd03ae | |||
5a35fa4353 | |||
4ecbfb0edf | |||
f08a7f0b3c | |||
8389887a34 | |||
593dd77d84 | |||
2786fadb25 | |||
37350dbb1e | |||
d195cb5104 | |||
00cebd297f | |||
761d087b93 | |||
9d7f7bd04f | |||
7c577ecaeb | |||
4b4f35bbac | |||
328d214d2d | |||
bab4d5a692 | |||
42a0fc8c13 | |||
dcd4ea334e | |||
c757365752 | |||
902f32eeab | |||
d86cf85b39 | |||
3dbae11efa | |||
c4463df8d4 | |||
852dac1476 | |||
e3026d3f4c | |||
81c423e709 | |||
f7da6ba99c | |||
0352b5b191 | |||
afdc2d8340 | |||
cb813e27a8 | |||
6980651785 | |||
43d5c8dbac | |||
56c4aaaaca | |||
afbe15086f | |||
56c357d520 | |||
5e926df3ab | |||
6ce73790ea | |||
5361f0eceb | |||
05aa3becae | |||
79f387317a | |||
3ea4741231 | |||
d7872061f8 | |||
99c5c58365 | |||
4c310ae1c7 | |||
997346ef95 | |||
7f6eda566a | |||
d00892f418 | |||
b9092aeb0c | |||
1b67ab9608 | |||
99d5bf913b | |||
e50838a33d | |||
97cf56ba41 | |||
07625e3bd1 | |||
da2f0e7532 | |||
114b4c14b5 | |||
e580ee991d | |||
6821fe6fb2 | |||
6009d089fc | |||
3e455777fd | |||
1dc3b77ac7 | |||
88c6556c37 | |||
d342c0bc16 | |||
f0c599d06d | |||
7d84d104fb | |||
812126a8ff | |||
d86223ed56 | |||
76a0cfdadb | |||
46ee543899 | |||
8f751d9dd0 | |||
3c00f4eeac | |||
f0b9493ce3 | |||
28f140bf06 | |||
9115d3f281 | |||
cf225be0df | |||
338d1ef254 | |||
6dd7be11d1 | |||
203bba65a0 | |||
98aabc45a7 | |||
908c96a94d | |||
2077b35736 | |||
92c7596157 | |||
a15b1264f5 | |||
5d58519253 | |||
93171b3319 | |||
3ba7446157 | |||
335aa18dc6 | |||
361739e860 | |||
6dd500def9 | |||
e83d6b7c6a | |||
9da46f566f | |||
fa89999d91 | |||
7e94a6adf2 | |||
ce8270568d | |||
7c06cdff2d | |||
e18b916231 | |||
c4ff8a6cda | |||
fc7c524fcb | |||
e977b8a94c | |||
6729f54c4e | |||
159a50fcf0 | |||
a69f00903c | |||
9d89f08c7b | |||
51cefd4908 | |||
560cbbd1f1 | |||
27e965007d | |||
1a5886e776 | |||
ebd8fcd168 | |||
717a7d00ef | |||
dd23c6fd2b | |||
6a52487edd | |||
c5c6272029 | |||
3de256d05e | |||
09b79d13f3 | |||
d4e6f4e125 | |||
b2ad1f3b3e | |||
32a975a20d | |||
eaf36706a2 | |||
02c936f397 | |||
99e02858af | |||
12ddefe078 | |||
20ab57bf7e | |||
3790142b10 | |||
ec0cb2169f | |||
425d48f68b | |||
6d0da3f861 | |||
1af9b6d18b | |||
bd2d350b09 | |||
e9be3e6d94 | |||
70e9e40c7f | |||
d33b54d280 | |||
6f248436a5 | |||
edd40474e8 | |||
d9ec7c1988 | |||
64b83f8220 | |||
7212f38115 | |||
8081445ff2 | |||
6a7ef9d8c3 | |||
6fe4e2541d | |||
a5fab572ff | |||
a86170f53a | |||
aa41f71dcc | |||
3a00fd51e4 | |||
65b4525b3b | |||
7efff9d53d | |||
110b7e4170 | |||
56debcfa56 | |||
157a9930e8 | |||
1c07098740 | |||
03d35dd1f3 | |||
dea8759762 | |||
3787477133 | |||
e91d40e250 | |||
ab75edd709 | |||
8999d2f080 | |||
6fbe1595cb | |||
a9237aabd2 |
448 changed files with 96337 additions and 6980 deletions
22
.forgejo/workflows/codegen.yml
Normal file
22
.forgejo/workflows/codegen.yml
Normal file
|
@ -0,0 +1,22 @@
|
|||
name: Code generation
|
||||
on: [pull_request]
|
||||
|
||||
jobs:
|
||||
wrappers:
|
||||
name: Generate proto
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version: '1.23'
|
||||
- name: Generate proto
|
||||
run: make protoc
|
||||
# The command seems to be non-deterministic.
|
||||
# However, with >20 runs I haven't been able to reproduce the issue.
|
||||
# This `git diff` is here to print diff in case we catch the behaviour again.
|
||||
- name: Print diff
|
||||
run: git diff HEAD
|
||||
- name: Check that nothing has changed
|
||||
run: git diff-index --exit-code HEAD
|
|
@ -13,9 +13,9 @@ jobs:
|
|||
- name: Setup Go
|
||||
uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version: '1.21'
|
||||
go-version: '1.23'
|
||||
|
||||
- name: Run commit format checker
|
||||
uses: https://git.frostfs.info/TrueCloudLab/dco-go@v2
|
||||
uses: https://git.frostfs.info/TrueCloudLab/dco-go@v3
|
||||
with:
|
||||
from: 'origin/${{ github.event.pull_request.base.ref }}'
|
||||
|
|
|
@ -11,7 +11,7 @@ jobs:
|
|||
- name: Set up Go
|
||||
uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version: '1.21'
|
||||
go-version: '1.23'
|
||||
cache: true
|
||||
|
||||
- name: Install linters
|
||||
|
@ -25,7 +25,7 @@ jobs:
|
|||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
go_versions: [ '1.20', '1.21' ]
|
||||
go_versions: [ '1.22', '1.23' ]
|
||||
fail-fast: false
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
|
3
.gitattributes
vendored
3
.gitattributes
vendored
|
@ -2,3 +2,6 @@
|
|||
/pkg/policy/parser/generate.go diff
|
||||
**/*.interp -diff
|
||||
**/*.tokens -diff
|
||||
/**/*.pb.go -diff -merge
|
||||
/**/*.pb.go linguist-generated=true
|
||||
/go.sum -diff
|
||||
|
|
1
.github/CODEOWNERS
vendored
1
.github/CODEOWNERS
vendored
|
@ -1 +0,0 @@
|
|||
* @TrueCloudLab/storage-core @TrueCloudLab/storage-services
|
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -23,7 +23,7 @@ coverage.txt
|
|||
coverage.html
|
||||
|
||||
# antlr tool jar
|
||||
antlr-*.jar
|
||||
antlr*.jar
|
||||
|
||||
# tempfiles
|
||||
.cache
|
||||
|
|
10
.gitlint
10
.gitlint
|
@ -1,10 +0,0 @@
|
|||
[general]
|
||||
fail-without-commits=true
|
||||
contrib=CC1
|
||||
|
||||
[title-match-regex]
|
||||
regex=^\[\#[0-9Xx]+\]\s
|
||||
|
||||
[ignore-by-title]
|
||||
regex=^Release(.*)
|
||||
ignore=title-match-regex
|
|
@ -12,7 +12,8 @@ run:
|
|||
# output configuration options
|
||||
output:
|
||||
# colored-line-number|line-number|json|tab|checkstyle|code-climate, default is "colored-line-number"
|
||||
format: tab
|
||||
formats:
|
||||
- format: tab
|
||||
|
||||
# all available settings of specific linters
|
||||
linters-settings:
|
||||
|
@ -51,7 +52,7 @@ linters:
|
|||
- bidichk
|
||||
- durationcheck
|
||||
- exhaustive
|
||||
- exportloopref
|
||||
- copyloopvar
|
||||
- gofmt
|
||||
- goimports
|
||||
- misspell
|
||||
|
@ -62,5 +63,7 @@ linters:
|
|||
- funlen
|
||||
- gocognit
|
||||
- contextcheck
|
||||
- protogetter
|
||||
- intrange
|
||||
disable-all: true
|
||||
fast: false
|
||||
|
|
|
@ -18,13 +18,19 @@ repos:
|
|||
- id: end-of-file-fixer
|
||||
exclude: "(.key|.interp|.tokens)$"
|
||||
|
||||
- repo: https://github.com/golangci/golangci-lint
|
||||
rev: v1.51.2
|
||||
- repo: local
|
||||
hooks:
|
||||
- id: golangci-lint
|
||||
- id: go-unit-tests
|
||||
name: go unit tests
|
||||
entry: make test GOFLAGS=''
|
||||
pass_filenames: false
|
||||
types: [go]
|
||||
language: system
|
||||
|
||||
- repo: https://github.com/jorisroovers/gitlint
|
||||
rev: v0.18.0
|
||||
- repo: local
|
||||
hooks:
|
||||
- id: gitlint
|
||||
stages: [commit-msg]
|
||||
- id: make-lint
|
||||
name: Run Make Lint
|
||||
entry: make lint
|
||||
language: system
|
||||
pass_filenames: false
|
||||
|
|
3
CODEOWNERS
Normal file
3
CODEOWNERS
Normal file
|
@ -0,0 +1,3 @@
|
|||
.* @TrueCloudLab/storage-core-committers @TrueCloudLab/storage-core-developers @TrueCloudLab/storage-services-committers @TrueCloudLab/storage-services-developers
|
||||
.forgejo/.* @potyarkin
|
||||
Makefile @potyarkin
|
|
@ -1,4 +1,4 @@
|
|||
FROM golang:1.21
|
||||
FROM golang:1.22
|
||||
|
||||
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install make openjdk-11-jre -y
|
||||
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install make openjdk-17-jre -y
|
||||
WORKDIR /work
|
||||
|
|
92
Makefile
92
Makefile
|
@ -1,15 +1,84 @@
|
|||
#!/usr/bin/make -f
|
||||
|
||||
ANTLR_VERSION="4.13.0"
|
||||
ANTLR_VERSION=4.13.1
|
||||
TMP_DIR := .cache
|
||||
LINT_VERSION ?= 1.55.0
|
||||
TRUECLOUDLAB_LINT_VERSION ?= 0.0.2
|
||||
LINT_VERSION ?= 1.61.0
|
||||
TRUECLOUDLAB_LINT_VERSION ?= 0.0.7
|
||||
OUTPUT_LINT_DIR ?= $(shell pwd)/bin
|
||||
LINT_DIR = $(OUTPUT_LINT_DIR)/golangci-lint-$(LINT_VERSION)-v$(TRUECLOUDLAB_LINT_VERSION)
|
||||
|
||||
PROTOC_VERSION ?= 29.2
|
||||
PROTOC_GEN_GO_VERSION ?= $(shell go list -f '{{.Version}}' -m google.golang.org/protobuf)
|
||||
PROTOC_GEN_GRPC_GO_VERSION ?= 1.5.1
|
||||
PROTOC_OS_VERSION=osx-x86_64
|
||||
ifeq ($(shell uname), Linux)
|
||||
PROTOC_OS_VERSION=linux-x86_64
|
||||
endif
|
||||
|
||||
BIN = bin
|
||||
PROTOBUF_DIR ?= $(abspath $(BIN))/protobuf
|
||||
PROTOC_DIR ?= $(PROTOBUF_DIR)/protoc-v$(PROTOC_VERSION)
|
||||
PROTOC_GEN_GO_DIR ?= $(PROTOBUF_DIR)/protoc-gen-go-$(PROTOC_GEN_GO_VERSION)
|
||||
|
||||
|
||||
.PHONY: dep imports protoc test lint help $(BIN)/protogen protoc-test
|
||||
|
||||
# Run tests
|
||||
test: GOFLAGS ?= "-cover -count=1"
|
||||
test:
|
||||
@go test ./... -cover
|
||||
@GOFLAGS=$(GOFLAGS) go test ./...
|
||||
|
||||
# Reformat imports
|
||||
imports:
|
||||
@echo "⇒ Processing goimports check"
|
||||
@for f in `find . -type f -name '*.go' -not -name '*.pb.go' -prune`; do \
|
||||
goimports -w $$f; \
|
||||
done
|
||||
|
||||
# Install protoc
|
||||
protoc-install:
|
||||
@rm -rf $(PROTOBUF_DIR)
|
||||
@mkdir -p $(PROTOBUF_DIR)
|
||||
@echo "⇒ Installing protoc... "
|
||||
@wget -q -O $(PROTOBUF_DIR)/protoc-$(PROTOC_VERSION).zip 'https://github.com/protocolbuffers/protobuf/releases/download/v$(PROTOC_VERSION)/protoc-$(PROTOC_VERSION)-$(PROTOC_OS_VERSION).zip'
|
||||
@unzip -q -o $(PROTOBUF_DIR)/protoc-$(PROTOC_VERSION).zip -d $(PROTOC_DIR)
|
||||
@rm $(PROTOBUF_DIR)/protoc-$(PROTOC_VERSION).zip
|
||||
@echo "⇒ Installing protoc-gen-go..."
|
||||
@GOBIN=$(PROTOC_GEN_GO_DIR) go install -v google.golang.org/protobuf/...@$(PROTOC_GEN_GO_VERSION)
|
||||
@echo "⇒ Installing protoc-gen-go-grpc..."
|
||||
@GOBIN=$(PROTOC_GEN_GO_DIR) go install -v google.golang.org/grpc/cmd/protoc-gen-go-grpc@v$(PROTOC_GEN_GRPC_GO_VERSION)
|
||||
|
||||
|
||||
# Regenerate code for proto files
|
||||
protoc:
|
||||
@if [ ! -d "$(PROTOC_DIR)" ] || [ ! -d "$(PROTOC_GEN_GO_DIR)" ]; then \
|
||||
make protoc-install; \
|
||||
fi
|
||||
# Protoc generate
|
||||
@for f in `find . -type f -name '*.proto' -not -path './bin/*'`; do \
|
||||
echo "⇒ Processing $$f "; \
|
||||
$(PROTOC_DIR)/bin/protoc \
|
||||
--plugin=protoc-gen-go=$(PROTOC_GEN_GO_DIR)/protoc-gen-go \
|
||||
--plugin=protoc-gen-go-grpc=$(PROTOC_GEN_GO_DIR)/protoc-gen-go-grpc \
|
||||
--go_out=. --go_opt=paths=source_relative \
|
||||
--go_opt=default_api_level=API_HYBRID \
|
||||
--go-grpc_opt=require_unimplemented_servers=false \
|
||||
--go-grpc_out=. --go-grpc_opt=paths=source_relative $$f; \
|
||||
done
|
||||
|
||||
$(BIN)/protogen:
|
||||
@go build -v -trimpath \
|
||||
-o $(BIN)/protogen \
|
||||
./api/util/protogen
|
||||
|
||||
protoc-test: protoc $(BIN)/protogen
|
||||
@$(PROTOC_DIR)/bin/protoc \
|
||||
--go_out=. --go_opt=paths=source_relative \
|
||||
--plugin=protoc-gen-go-frostfs=$(abspath $(BIN)/protogen) \
|
||||
--go-frostfs_opt=Mapi/util/proto/test/test.proto=git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/util/proto/test/custom \
|
||||
--go-frostfs_opt=module=git.frostfs.info/TrueCloudLab/frostfs-sdk-go \
|
||||
--go-frostfs_out=. --go-frostfs_opt=paths=import \
|
||||
./api/util/proto/test/test.proto
|
||||
|
||||
# Pull go dependencies
|
||||
dep:
|
||||
|
@ -52,7 +121,8 @@ format:
|
|||
|
||||
policy:
|
||||
@wget -q https://www.antlr.org/download/antlr-${ANTLR_VERSION}-complete.jar -O antlr4-tool.jar
|
||||
@java -Xmx500M -cp "`pwd`/antlr4-tool.jar" "org.antlr.v4.Tool" -o `pwd`/netmap/parser/ -Dlanguage=Go -no-listener -visitor `pwd`/netmap/parser/Query.g4 `pwd`/netmap/parser/QueryLexer.g4
|
||||
@java -Xmx500M -cp antlr4-tool.jar org.antlr.v4.Tool -Dlanguage=Go \
|
||||
-no-listener -visitor netmap/parser/Query.g4 netmap/parser/QueryLexer.g4
|
||||
|
||||
# Run `make %` in truecloudlab/frostfs-sdk-go container(Golang+Java)
|
||||
docker/%:
|
||||
|
@ -76,3 +146,15 @@ help:
|
|||
@echo ' Targets:'
|
||||
@echo ''
|
||||
@awk '/^#/{ comment = substr($$0,3) } comment && /^[a-zA-Z][a-zA-Z0-9_-]+ ?:/{ print " ", $$1, comment }' $(MAKEFILE_LIST) | column -t -s ':' | grep -v 'IGNORE' | sort -u
|
||||
|
||||
# Activate pre-commit hooks
|
||||
pre-commit:
|
||||
pre-commit install --hook-type pre-commit
|
||||
|
||||
# Deactivate pre-commit hooks
|
||||
unpre-commit:
|
||||
pre-commit uninstall --hook-type pre-commit
|
||||
|
||||
# Run pre-commit hooks
|
||||
pre-commit-run:
|
||||
@pre-commit run --all-files --hook-stage manual
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package accounting
|
||||
|
||||
import "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/accounting"
|
||||
import "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/accounting"
|
||||
|
||||
// Decimal represents decimal number for accounting operations.
|
||||
//
|
||||
// Decimal is mutually compatible with git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/accounting.Decimal
|
||||
// Decimal is mutually compatible with git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/accounting.Decimal
|
||||
// message. See ReadFromV2 / WriteToV2 methods.
|
||||
//
|
||||
// Instances can be created using built-in var declaration.
|
||||
|
|
|
@ -3,8 +3,8 @@ package accounting_test
|
|||
import (
|
||||
"testing"
|
||||
|
||||
v2accounting "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/accounting"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/accounting"
|
||||
v2accounting "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/accounting"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ Instances can be also used to process FrostFS API V2 protocol messages
|
|||
|
||||
On client side:
|
||||
|
||||
import "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/accounting"
|
||||
import "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/accounting"
|
||||
|
||||
var msg accounting.Decimal
|
||||
dec.WriteToV2(&msg)
|
||||
|
|
52
ape/chain.go
Normal file
52
ape/chain.go
Normal file
|
@ -0,0 +1,52 @@
|
|||
package ape
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
apeV2 "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/ape"
|
||||
)
|
||||
|
||||
var (
|
||||
ErrInvalidChainRepresentation = errors.New("invalid chain representation")
|
||||
)
|
||||
|
||||
// ChainID is Chain's identifier.
|
||||
type ChainID []byte
|
||||
|
||||
// Chain is an SDK representation for v2's Chain.
|
||||
//
|
||||
// Note that Chain (as well as v2's Chain) and all related entities
|
||||
// are NOT operated by Access-Policy-Engine (APE). The client is responsible
|
||||
// to convert these types to policy-engine entities.
|
||||
type Chain struct {
|
||||
// Raw is the encoded chain kind.
|
||||
// It assumes that Raw's bytes are the result of encoding provided by
|
||||
// policy-engine package.
|
||||
Raw []byte
|
||||
}
|
||||
|
||||
// ToV2 converts Chain to v2.
|
||||
func (c *Chain) ToV2() *apeV2.Chain {
|
||||
v2ct := new(apeV2.Chain)
|
||||
|
||||
if c.Raw != nil {
|
||||
v2Raw := new(apeV2.ChainRaw)
|
||||
v2Raw.SetRaw(c.Raw)
|
||||
v2ct.SetKind(v2Raw)
|
||||
}
|
||||
|
||||
return v2ct
|
||||
}
|
||||
|
||||
// ReadFromV2 fills Chain from v2.
|
||||
func (c *Chain) ReadFromV2(v2ct *apeV2.Chain) error {
|
||||
switch v := v2ct.GetKind().(type) {
|
||||
default:
|
||||
return fmt.Errorf("unsupported chain kind: %T", v)
|
||||
case *apeV2.ChainRaw:
|
||||
raw := v.GetRaw()
|
||||
c.Raw = raw
|
||||
}
|
||||
return nil
|
||||
}
|
53
ape/chain_target.go
Normal file
53
ape/chain_target.go
Normal file
|
@ -0,0 +1,53 @@
|
|||
package ape
|
||||
|
||||
import (
|
||||
apeV2 "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/ape"
|
||||
)
|
||||
|
||||
// TargetType is an SDK representation for v2's TargetType.
|
||||
type TargetType apeV2.TargetType
|
||||
|
||||
const (
|
||||
TargetTypeUndefined TargetType = iota
|
||||
TargetTypeNamespace
|
||||
TargetTypeContainer
|
||||
TargetTypeUser
|
||||
TargetTypeGroup
|
||||
)
|
||||
|
||||
// ToV2 converts TargetType to v2.
|
||||
func (targetType TargetType) ToV2() apeV2.TargetType {
|
||||
return apeV2.TargetType(targetType)
|
||||
}
|
||||
|
||||
// FromV2 reads TargetType to v2.
|
||||
func (targetType *TargetType) FromV2(v2targetType apeV2.TargetType) {
|
||||
*targetType = TargetType(v2targetType)
|
||||
}
|
||||
|
||||
// ChainTarget is an SDK representation for v2's ChainTarget.
|
||||
//
|
||||
// Note that ChainTarget (as well as v2's ChainTarget) and all related entities
|
||||
// are NOT operated by Access-Policy-Engine (APE). The client is responsible
|
||||
// to convert these types to policy-engine entities.
|
||||
type ChainTarget struct {
|
||||
TargetType TargetType
|
||||
|
||||
Name string
|
||||
}
|
||||
|
||||
// ToV2 converts ChainTarget to v2.
|
||||
func (ct *ChainTarget) ToV2() *apeV2.ChainTarget {
|
||||
v2ct := new(apeV2.ChainTarget)
|
||||
|
||||
v2ct.SetTargetType(ct.TargetType.ToV2())
|
||||
v2ct.SetName(ct.Name)
|
||||
|
||||
return v2ct
|
||||
}
|
||||
|
||||
// FromV2 reads ChainTarget frpm v2.
|
||||
func (ct *ChainTarget) FromV2(v2ct *apeV2.ChainTarget) {
|
||||
ct.TargetType.FromV2(v2ct.GetTargetType())
|
||||
ct.Name = v2ct.GetName()
|
||||
}
|
65
ape/chain_target_test.go
Normal file
65
ape/chain_target_test.go
Normal file
|
@ -0,0 +1,65 @@
|
|||
package ape_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/ape"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
apeV2 "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/ape"
|
||||
)
|
||||
|
||||
var (
|
||||
m = map[ape.TargetType]apeV2.TargetType{
|
||||
ape.TargetTypeUndefined: apeV2.TargetTypeUndefined,
|
||||
ape.TargetTypeNamespace: apeV2.TargetTypeNamespace,
|
||||
ape.TargetTypeContainer: apeV2.TargetTypeContainer,
|
||||
ape.TargetTypeUser: apeV2.TargetTypeUser,
|
||||
ape.TargetTypeGroup: apeV2.TargetTypeGroup,
|
||||
}
|
||||
)
|
||||
|
||||
func TestTargetType(t *testing.T) {
|
||||
for typesdk, typev2 := range m {
|
||||
t.Run("from sdk to v2 "+typev2.String(), func(t *testing.T) {
|
||||
v2 := typesdk.ToV2()
|
||||
require.Equal(t, v2, typev2)
|
||||
})
|
||||
|
||||
t.Run("from v2 to sdk "+typev2.String(), func(t *testing.T) {
|
||||
var typ ape.TargetType
|
||||
typ.FromV2(typev2)
|
||||
require.Equal(t, typesdk, typ)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestChainTarget(t *testing.T) {
|
||||
var (
|
||||
typ = ape.TargetTypeNamespace
|
||||
name = "namespaceXXYYZZ"
|
||||
)
|
||||
|
||||
t.Run("from sdk to v2", func(t *testing.T) {
|
||||
ct := ape.ChainTarget{
|
||||
TargetType: typ,
|
||||
Name: name,
|
||||
}
|
||||
|
||||
v2 := ct.ToV2()
|
||||
require.Equal(t, m[typ], v2.GetTargetType())
|
||||
require.Equal(t, name, v2.GetName())
|
||||
})
|
||||
|
||||
t.Run("from v2 to sdk", func(t *testing.T) {
|
||||
v2 := &apeV2.ChainTarget{}
|
||||
v2.SetTargetType(m[typ])
|
||||
v2.SetName(name)
|
||||
|
||||
var ct ape.ChainTarget
|
||||
ct.FromV2(v2)
|
||||
|
||||
require.Equal(t, typ, ct.TargetType)
|
||||
require.Equal(t, name, ct.Name)
|
||||
})
|
||||
}
|
43
ape/chain_test.go
Normal file
43
ape/chain_test.go
Normal file
|
@ -0,0 +1,43 @@
|
|||
package ape_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/ape"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
apeV2 "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/ape"
|
||||
)
|
||||
|
||||
const (
|
||||
encoded = `{"ID":"","Rules":[{"Status":"Allow","Actions":{"Inverted":false,"Names":["GetObject"]},"Resources":{"Inverted":false,"Names":["native:object/*"]},"Any":false,"Condition":[{"Op":"StringEquals","Object":"Resource","Key":"Department","Value":"HR"}]}],"MatchType":"DenyPriority"}`
|
||||
)
|
||||
|
||||
func TestChainData(t *testing.T) {
|
||||
t.Run("raw chain", func(t *testing.T) {
|
||||
var c ape.Chain
|
||||
|
||||
b := []byte(encoded)
|
||||
c.Raw = b
|
||||
|
||||
v2, ok := c.ToV2().GetKind().(*apeV2.ChainRaw)
|
||||
require.True(t, ok)
|
||||
require.Equal(t, b, v2.Raw)
|
||||
})
|
||||
}
|
||||
|
||||
func TestChainMessageV2(t *testing.T) {
|
||||
b := []byte(encoded)
|
||||
|
||||
v2Raw := &apeV2.ChainRaw{}
|
||||
v2Raw.SetRaw(b)
|
||||
|
||||
v2 := &apeV2.Chain{}
|
||||
v2.SetKind(v2Raw)
|
||||
|
||||
var c ape.Chain
|
||||
c.ReadFromV2(v2)
|
||||
|
||||
require.NotNil(t, c.Raw)
|
||||
require.Equal(t, b, c.Raw)
|
||||
}
|
424
ape/grpc/types_frostfs.pb.go
generated
Normal file
424
ape/grpc/types_frostfs.pb.go
generated
Normal file
|
@ -0,0 +1,424 @@
|
|||
// Code generated by protoc-gen-go-frostfs. DO NOT EDIT.
|
||||
|
||||
package ape
|
||||
|
||||
import (
|
||||
json "encoding/json"
|
||||
fmt "fmt"
|
||||
pool "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/util/pool"
|
||||
proto "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/util/proto"
|
||||
encoding "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/util/proto/encoding"
|
||||
easyproto "github.com/VictoriaMetrics/easyproto"
|
||||
jlexer "github.com/mailru/easyjson/jlexer"
|
||||
jwriter "github.com/mailru/easyjson/jwriter"
|
||||
strconv "strconv"
|
||||
)
|
||||
|
||||
type TargetType int32
|
||||
|
||||
const (
|
||||
TargetType_UNDEFINED TargetType = 0
|
||||
TargetType_NAMESPACE TargetType = 1
|
||||
TargetType_CONTAINER TargetType = 2
|
||||
TargetType_USER TargetType = 3
|
||||
TargetType_GROUP TargetType = 4
|
||||
)
|
||||
|
||||
var (
|
||||
TargetType_name = map[int32]string{
|
||||
0: "UNDEFINED",
|
||||
1: "NAMESPACE",
|
||||
2: "CONTAINER",
|
||||
3: "USER",
|
||||
4: "GROUP",
|
||||
}
|
||||
TargetType_value = map[string]int32{
|
||||
"UNDEFINED": 0,
|
||||
"NAMESPACE": 1,
|
||||
"CONTAINER": 2,
|
||||
"USER": 3,
|
||||
"GROUP": 4,
|
||||
}
|
||||
)
|
||||
|
||||
func (x TargetType) String() string {
|
||||
if v, ok := TargetType_name[int32(x)]; ok {
|
||||
return v
|
||||
}
|
||||
return strconv.FormatInt(int64(x), 10)
|
||||
}
|
||||
func (x *TargetType) FromString(s string) bool {
|
||||
if v, ok := TargetType_value[s]; ok {
|
||||
*x = TargetType(v)
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
type ChainTarget struct {
|
||||
Type TargetType `json:"type"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
var (
|
||||
_ encoding.ProtoMarshaler = (*ChainTarget)(nil)
|
||||
_ encoding.ProtoUnmarshaler = (*ChainTarget)(nil)
|
||||
_ json.Marshaler = (*ChainTarget)(nil)
|
||||
_ json.Unmarshaler = (*ChainTarget)(nil)
|
||||
)
|
||||
|
||||
// StableSize returns the size of x in protobuf format.
|
||||
//
|
||||
// Structures with the same field values have the same binary size.
|
||||
func (x *ChainTarget) StableSize() (size int) {
|
||||
if x == nil {
|
||||
return 0
|
||||
}
|
||||
size += proto.EnumSize(1, int32(x.Type))
|
||||
size += proto.StringSize(2, x.Name)
|
||||
return size
|
||||
}
|
||||
|
||||
// MarshalProtobuf implements the encoding.ProtoMarshaler interface.
|
||||
func (x *ChainTarget) MarshalProtobuf(dst []byte) []byte {
|
||||
m := pool.MarshalerPool.Get()
|
||||
defer pool.MarshalerPool.Put(m)
|
||||
x.EmitProtobuf(m.MessageMarshaler())
|
||||
dst = m.Marshal(dst)
|
||||
return dst
|
||||
}
|
||||
|
||||
func (x *ChainTarget) EmitProtobuf(mm *easyproto.MessageMarshaler) {
|
||||
if x == nil {
|
||||
return
|
||||
}
|
||||
if int32(x.Type) != 0 {
|
||||
mm.AppendInt32(1, int32(x.Type))
|
||||
}
|
||||
if len(x.Name) != 0 {
|
||||
mm.AppendString(2, x.Name)
|
||||
}
|
||||
}
|
||||
|
||||
// UnmarshalProtobuf implements the encoding.ProtoUnmarshaler interface.
|
||||
func (x *ChainTarget) UnmarshalProtobuf(src []byte) (err error) {
|
||||
var fc easyproto.FieldContext
|
||||
for len(src) > 0 {
|
||||
src, err = fc.NextField(src)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot read next field in %s", "ChainTarget")
|
||||
}
|
||||
switch fc.FieldNum {
|
||||
case 1: // Type
|
||||
data, ok := fc.Int32()
|
||||
if !ok {
|
||||
return fmt.Errorf("cannot unmarshal field %s", "Type")
|
||||
}
|
||||
x.Type = TargetType(data)
|
||||
case 2: // Name
|
||||
data, ok := fc.String()
|
||||
if !ok {
|
||||
return fmt.Errorf("cannot unmarshal field %s", "Name")
|
||||
}
|
||||
x.Name = data
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (x *ChainTarget) GetType() TargetType {
|
||||
if x != nil {
|
||||
return x.Type
|
||||
}
|
||||
return 0
|
||||
}
|
||||
func (x *ChainTarget) SetType(v TargetType) {
|
||||
x.Type = v
|
||||
}
|
||||
func (x *ChainTarget) GetName() string {
|
||||
if x != nil {
|
||||
return x.Name
|
||||
}
|
||||
return ""
|
||||
}
|
||||
func (x *ChainTarget) SetName(v string) {
|
||||
x.Name = v
|
||||
}
|
||||
|
||||
// MarshalJSON implements the json.Marshaler interface.
|
||||
func (x *ChainTarget) MarshalJSON() ([]byte, error) {
|
||||
w := jwriter.Writer{}
|
||||
x.MarshalEasyJSON(&w)
|
||||
return w.Buffer.BuildBytes(), w.Error
|
||||
}
|
||||
func (x *ChainTarget) MarshalEasyJSON(out *jwriter.Writer) {
|
||||
if x == nil {
|
||||
out.RawString("null")
|
||||
return
|
||||
}
|
||||
first := true
|
||||
out.RawByte('{')
|
||||
{
|
||||
if !first {
|
||||
out.RawByte(',')
|
||||
} else {
|
||||
first = false
|
||||
}
|
||||
const prefix string = "\"type\":"
|
||||
out.RawString(prefix)
|
||||
v := int32(x.Type)
|
||||
if vv, ok := TargetType_name[v]; ok {
|
||||
out.String(vv)
|
||||
} else {
|
||||
out.Int32(v)
|
||||
}
|
||||
}
|
||||
{
|
||||
if !first {
|
||||
out.RawByte(',')
|
||||
} else {
|
||||
first = false
|
||||
}
|
||||
const prefix string = "\"name\":"
|
||||
out.RawString(prefix)
|
||||
out.String(x.Name)
|
||||
}
|
||||
out.RawByte('}')
|
||||
}
|
||||
|
||||
// UnmarshalJSON implements the json.Unmarshaler interface.
|
||||
func (x *ChainTarget) UnmarshalJSON(data []byte) error {
|
||||
r := jlexer.Lexer{Data: data}
|
||||
x.UnmarshalEasyJSON(&r)
|
||||
return r.Error()
|
||||
}
|
||||
func (x *ChainTarget) UnmarshalEasyJSON(in *jlexer.Lexer) {
|
||||
isTopLevel := in.IsStart()
|
||||
if in.IsNull() {
|
||||
if isTopLevel {
|
||||
in.Consumed()
|
||||
}
|
||||
in.Skip()
|
||||
return
|
||||
}
|
||||
in.Delim('{')
|
||||
for !in.IsDelim('}') {
|
||||
key := in.UnsafeFieldName(false)
|
||||
in.WantColon()
|
||||
if in.IsNull() {
|
||||
in.Skip()
|
||||
in.WantComma()
|
||||
continue
|
||||
}
|
||||
switch key {
|
||||
case "type":
|
||||
{
|
||||
var f TargetType
|
||||
var parsedValue TargetType
|
||||
switch v := in.Interface().(type) {
|
||||
case string:
|
||||
if vv, ok := TargetType_value[v]; ok {
|
||||
parsedValue = TargetType(vv)
|
||||
break
|
||||
}
|
||||
vv, err := strconv.ParseInt(v, 10, 32)
|
||||
if err != nil {
|
||||
in.AddError(err)
|
||||
return
|
||||
}
|
||||
parsedValue = TargetType(vv)
|
||||
case float64:
|
||||
parsedValue = TargetType(v)
|
||||
}
|
||||
f = parsedValue
|
||||
x.Type = f
|
||||
}
|
||||
case "name":
|
||||
{
|
||||
var f string
|
||||
f = in.String()
|
||||
x.Name = f
|
||||
}
|
||||
}
|
||||
in.WantComma()
|
||||
}
|
||||
in.Delim('}')
|
||||
if isTopLevel {
|
||||
in.Consumed()
|
||||
}
|
||||
}
|
||||
|
||||
type Chain struct {
|
||||
Kind isChain_Kind
|
||||
}
|
||||
|
||||
var (
|
||||
_ encoding.ProtoMarshaler = (*Chain)(nil)
|
||||
_ encoding.ProtoUnmarshaler = (*Chain)(nil)
|
||||
_ json.Marshaler = (*Chain)(nil)
|
||||
_ json.Unmarshaler = (*Chain)(nil)
|
||||
)
|
||||
|
||||
// StableSize returns the size of x in protobuf format.
|
||||
//
|
||||
// Structures with the same field values have the same binary size.
|
||||
func (x *Chain) StableSize() (size int) {
|
||||
if x == nil {
|
||||
return 0
|
||||
}
|
||||
if inner, ok := x.Kind.(*Chain_Raw); ok {
|
||||
size += proto.BytesSize(1, inner.Raw)
|
||||
}
|
||||
return size
|
||||
}
|
||||
|
||||
// MarshalProtobuf implements the encoding.ProtoMarshaler interface.
|
||||
func (x *Chain) MarshalProtobuf(dst []byte) []byte {
|
||||
m := pool.MarshalerPool.Get()
|
||||
defer pool.MarshalerPool.Put(m)
|
||||
x.EmitProtobuf(m.MessageMarshaler())
|
||||
dst = m.Marshal(dst)
|
||||
return dst
|
||||
}
|
||||
|
||||
func (x *Chain) EmitProtobuf(mm *easyproto.MessageMarshaler) {
|
||||
if x == nil {
|
||||
return
|
||||
}
|
||||
if inner, ok := x.Kind.(*Chain_Raw); ok {
|
||||
if len(inner.Raw) != 0 {
|
||||
mm.AppendBytes(1, inner.Raw)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// UnmarshalProtobuf implements the encoding.ProtoUnmarshaler interface.
|
||||
func (x *Chain) UnmarshalProtobuf(src []byte) (err error) {
|
||||
var fc easyproto.FieldContext
|
||||
for len(src) > 0 {
|
||||
src, err = fc.NextField(src)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot read next field in %s", "Chain")
|
||||
}
|
||||
switch fc.FieldNum {
|
||||
case 1: // Raw
|
||||
data, ok := fc.Bytes()
|
||||
if !ok {
|
||||
return fmt.Errorf("cannot unmarshal field %s", "Raw")
|
||||
}
|
||||
x.Kind = &Chain_Raw{Raw: data}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (x *Chain) GetKind() isChain_Kind {
|
||||
if x != nil {
|
||||
return x.Kind
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (x *Chain) SetKind(v isChain_Kind) {
|
||||
x.Kind = v
|
||||
}
|
||||
func (x *Chain) GetRaw() []byte {
|
||||
if xx, ok := x.GetKind().(*Chain_Raw); ok {
|
||||
return xx.Raw
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (x *Chain) SetRaw(v *Chain_Raw) {
|
||||
x.Kind = v
|
||||
}
|
||||
func (x *Chain_Raw) GetRaw() []byte {
|
||||
if x != nil {
|
||||
return x.Raw
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (x *Chain_Raw) SetRaw(v []byte) {
|
||||
x.Raw = v
|
||||
}
|
||||
|
||||
// MarshalJSON implements the json.Marshaler interface.
|
||||
func (x *Chain) MarshalJSON() ([]byte, error) {
|
||||
w := jwriter.Writer{}
|
||||
x.MarshalEasyJSON(&w)
|
||||
return w.Buffer.BuildBytes(), w.Error
|
||||
}
|
||||
func (x *Chain) MarshalEasyJSON(out *jwriter.Writer) {
|
||||
if x == nil {
|
||||
out.RawString("null")
|
||||
return
|
||||
}
|
||||
first := true
|
||||
out.RawByte('{')
|
||||
switch xx := x.Kind.(type) {
|
||||
case *Chain_Raw:
|
||||
{
|
||||
if !first {
|
||||
out.RawByte(',')
|
||||
} else {
|
||||
first = false
|
||||
}
|
||||
const prefix string = "\"raw\":"
|
||||
out.RawString(prefix)
|
||||
if xx.Raw != nil {
|
||||
out.Base64Bytes(xx.Raw)
|
||||
} else {
|
||||
out.String("")
|
||||
}
|
||||
}
|
||||
}
|
||||
out.RawByte('}')
|
||||
}
|
||||
|
||||
// UnmarshalJSON implements the json.Unmarshaler interface.
|
||||
func (x *Chain) UnmarshalJSON(data []byte) error {
|
||||
r := jlexer.Lexer{Data: data}
|
||||
x.UnmarshalEasyJSON(&r)
|
||||
return r.Error()
|
||||
}
|
||||
func (x *Chain) UnmarshalEasyJSON(in *jlexer.Lexer) {
|
||||
isTopLevel := in.IsStart()
|
||||
if in.IsNull() {
|
||||
if isTopLevel {
|
||||
in.Consumed()
|
||||
}
|
||||
in.Skip()
|
||||
return
|
||||
}
|
||||
in.Delim('{')
|
||||
for !in.IsDelim('}') {
|
||||
key := in.UnsafeFieldName(false)
|
||||
in.WantColon()
|
||||
if in.IsNull() {
|
||||
in.Skip()
|
||||
in.WantComma()
|
||||
continue
|
||||
}
|
||||
switch key {
|
||||
case "raw":
|
||||
xx := new(Chain_Raw)
|
||||
x.Kind = xx
|
||||
{
|
||||
var f []byte
|
||||
f = in.Bytes()
|
||||
xx.Raw = f
|
||||
}
|
||||
}
|
||||
in.WantComma()
|
||||
}
|
||||
in.Delim('}')
|
||||
if isTopLevel {
|
||||
in.Consumed()
|
||||
}
|
||||
}
|
||||
|
||||
type isChain_Kind interface {
|
||||
isChain_Kind()
|
||||
}
|
||||
|
||||
type Chain_Raw struct {
|
||||
Raw []byte
|
||||
}
|
||||
|
||||
func (*Chain_Raw) isChain_Kind() {}
|
45
ape/grpc/types_frostfs_fuzz.go
Normal file
45
ape/grpc/types_frostfs_fuzz.go
Normal file
|
@ -0,0 +1,45 @@
|
|||
//go:build gofuzz
|
||||
// +build gofuzz
|
||||
|
||||
// Code generated by protoc-gen-go-frostfs. DO NOT EDIT.
|
||||
|
||||
package ape
|
||||
|
||||
func DoFuzzProtoChainTarget(data []byte) int {
|
||||
msg := new(ChainTarget)
|
||||
if err := msg.UnmarshalProtobuf(data); err != nil {
|
||||
return 0
|
||||
}
|
||||
_ = msg.MarshalProtobuf(nil)
|
||||
return 1
|
||||
}
|
||||
func DoFuzzJSONChainTarget(data []byte) int {
|
||||
msg := new(ChainTarget)
|
||||
if err := msg.UnmarshalJSON(data); err != nil {
|
||||
return 0
|
||||
}
|
||||
_, err := msg.MarshalJSON()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return 1
|
||||
}
|
||||
func DoFuzzProtoChain(data []byte) int {
|
||||
msg := new(Chain)
|
||||
if err := msg.UnmarshalProtobuf(data); err != nil {
|
||||
return 0
|
||||
}
|
||||
_ = msg.MarshalProtobuf(nil)
|
||||
return 1
|
||||
}
|
||||
func DoFuzzJSONChain(data []byte) int {
|
||||
msg := new(Chain)
|
||||
if err := msg.UnmarshalJSON(data); err != nil {
|
||||
return 0
|
||||
}
|
||||
_, err := msg.MarshalJSON()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return 1
|
||||
}
|
31
ape/grpc/types_frostfs_test.go
Normal file
31
ape/grpc/types_frostfs_test.go
Normal file
|
@ -0,0 +1,31 @@
|
|||
//go:build gofuzz
|
||||
// +build gofuzz
|
||||
|
||||
// Code generated by protoc-gen-go-frostfs. DO NOT EDIT.
|
||||
|
||||
package ape
|
||||
|
||||
import (
|
||||
testing "testing"
|
||||
)
|
||||
|
||||
func FuzzProtoChainTarget(f *testing.F) {
|
||||
f.Fuzz(func(t *testing.T, data []byte) {
|
||||
DoFuzzProtoChainTarget(data)
|
||||
})
|
||||
}
|
||||
func FuzzJSONChainTarget(f *testing.F) {
|
||||
f.Fuzz(func(t *testing.T, data []byte) {
|
||||
DoFuzzJSONChainTarget(data)
|
||||
})
|
||||
}
|
||||
func FuzzProtoChain(f *testing.F) {
|
||||
f.Fuzz(func(t *testing.T, data []byte) {
|
||||
DoFuzzProtoChain(data)
|
||||
})
|
||||
}
|
||||
func FuzzJSONChain(f *testing.F) {
|
||||
f.Fuzz(func(t *testing.T, data []byte) {
|
||||
DoFuzzJSONChain(data)
|
||||
})
|
||||
}
|
104
api/accounting/accounting.go
Normal file
104
api/accounting/accounting.go
Normal file
|
@ -0,0 +1,104 @@
|
|||
package accounting
|
||||
|
||||
import (
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/refs"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/session"
|
||||
)
|
||||
|
||||
type BalanceRequestBody struct {
|
||||
ownerID *refs.OwnerID
|
||||
}
|
||||
|
||||
type BalanceResponseBody struct {
|
||||
bal *Decimal
|
||||
}
|
||||
|
||||
type Decimal struct {
|
||||
val int64
|
||||
|
||||
prec uint32
|
||||
}
|
||||
|
||||
type BalanceRequest struct {
|
||||
body *BalanceRequestBody
|
||||
|
||||
session.RequestHeaders
|
||||
}
|
||||
|
||||
type BalanceResponse struct {
|
||||
body *BalanceResponseBody
|
||||
|
||||
session.ResponseHeaders
|
||||
}
|
||||
|
||||
func (b *BalanceRequestBody) GetOwnerID() *refs.OwnerID {
|
||||
if b != nil {
|
||||
return b.ownerID
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (b *BalanceRequestBody) SetOwnerID(v *refs.OwnerID) {
|
||||
b.ownerID = v
|
||||
}
|
||||
|
||||
func (b *BalanceRequest) GetBody() *BalanceRequestBody {
|
||||
if b != nil {
|
||||
return b.body
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (b *BalanceRequest) SetBody(v *BalanceRequestBody) {
|
||||
b.body = v
|
||||
}
|
||||
|
||||
func (d *Decimal) GetValue() int64 {
|
||||
if d != nil {
|
||||
return d.val
|
||||
}
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
func (d *Decimal) SetValue(v int64) {
|
||||
d.val = v
|
||||
}
|
||||
|
||||
func (d *Decimal) GetPrecision() uint32 {
|
||||
if d != nil {
|
||||
return d.prec
|
||||
}
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
func (d *Decimal) SetPrecision(v uint32) {
|
||||
d.prec = v
|
||||
}
|
||||
|
||||
func (br *BalanceResponseBody) GetBalance() *Decimal {
|
||||
if br != nil {
|
||||
return br.bal
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (br *BalanceResponseBody) SetBalance(v *Decimal) {
|
||||
br.bal = v
|
||||
}
|
||||
|
||||
func (br *BalanceResponse) GetBody() *BalanceResponseBody {
|
||||
if br != nil {
|
||||
return br.body
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (br *BalanceResponse) SetBody(v *BalanceResponseBody) {
|
||||
br.body = v
|
||||
}
|
178
api/accounting/convert.go
Normal file
178
api/accounting/convert.go
Normal file
|
@ -0,0 +1,178 @@
|
|||
package accounting
|
||||
|
||||
import (
|
||||
accounting "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/accounting/grpc"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/refs"
|
||||
refsGRPC "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/refs/grpc"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/rpc/grpc"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/rpc/message"
|
||||
)
|
||||
|
||||
func (b *BalanceRequestBody) ToGRPCMessage() grpc.Message {
|
||||
var m *accounting.BalanceRequest_Body
|
||||
|
||||
if b != nil {
|
||||
m = new(accounting.BalanceRequest_Body)
|
||||
|
||||
m.SetOwnerId(b.ownerID.ToGRPCMessage().(*refsGRPC.OwnerID))
|
||||
}
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
func (b *BalanceRequestBody) FromGRPCMessage(m grpc.Message) error {
|
||||
v, ok := m.(*accounting.BalanceRequest_Body)
|
||||
if !ok {
|
||||
return message.NewUnexpectedMessageType(m, v)
|
||||
}
|
||||
|
||||
var err error
|
||||
|
||||
ownerID := v.GetOwnerId()
|
||||
if ownerID == nil {
|
||||
b.ownerID = nil
|
||||
} else {
|
||||
if b.ownerID == nil {
|
||||
b.ownerID = new(refs.OwnerID)
|
||||
}
|
||||
|
||||
err = b.ownerID.FromGRPCMessage(ownerID)
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
func (b *BalanceRequest) ToGRPCMessage() grpc.Message {
|
||||
var m *accounting.BalanceRequest
|
||||
|
||||
if b != nil {
|
||||
m = new(accounting.BalanceRequest)
|
||||
|
||||
m.SetBody(b.body.ToGRPCMessage().(*accounting.BalanceRequest_Body))
|
||||
b.RequestHeaders.ToMessage(m)
|
||||
}
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
func (b *BalanceRequest) FromGRPCMessage(m grpc.Message) error {
|
||||
v, ok := m.(*accounting.BalanceRequest)
|
||||
if !ok {
|
||||
return message.NewUnexpectedMessageType(m, v)
|
||||
}
|
||||
|
||||
var err error
|
||||
|
||||
body := v.GetBody()
|
||||
if body == nil {
|
||||
b.body = nil
|
||||
} else {
|
||||
if b.body == nil {
|
||||
b.body = new(BalanceRequestBody)
|
||||
}
|
||||
|
||||
err = b.body.FromGRPCMessage(body)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return b.RequestHeaders.FromMessage(v)
|
||||
}
|
||||
|
||||
func (d *Decimal) ToGRPCMessage() grpc.Message {
|
||||
var m *accounting.Decimal
|
||||
|
||||
if d != nil {
|
||||
m = new(accounting.Decimal)
|
||||
|
||||
m.SetValue(d.val)
|
||||
m.SetPrecision(d.prec)
|
||||
}
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
func (d *Decimal) FromGRPCMessage(m grpc.Message) error {
|
||||
v, ok := m.(*accounting.Decimal)
|
||||
if !ok {
|
||||
return message.NewUnexpectedMessageType(m, v)
|
||||
}
|
||||
|
||||
d.val = v.GetValue()
|
||||
d.prec = v.GetPrecision()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (br *BalanceResponseBody) ToGRPCMessage() grpc.Message {
|
||||
var m *accounting.BalanceResponse_Body
|
||||
|
||||
if br != nil {
|
||||
m = new(accounting.BalanceResponse_Body)
|
||||
|
||||
m.SetBalance(br.bal.ToGRPCMessage().(*accounting.Decimal))
|
||||
}
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
func (br *BalanceResponseBody) FromGRPCMessage(m grpc.Message) error {
|
||||
v, ok := m.(*accounting.BalanceResponse_Body)
|
||||
if !ok {
|
||||
return message.NewUnexpectedMessageType(m, v)
|
||||
}
|
||||
|
||||
var err error
|
||||
|
||||
bal := v.GetBalance()
|
||||
if bal == nil {
|
||||
br.bal = nil
|
||||
} else {
|
||||
if br.bal == nil {
|
||||
br.bal = new(Decimal)
|
||||
}
|
||||
|
||||
err = br.bal.FromGRPCMessage(bal)
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
func (br *BalanceResponse) ToGRPCMessage() grpc.Message {
|
||||
var m *accounting.BalanceResponse
|
||||
|
||||
if br != nil {
|
||||
m = new(accounting.BalanceResponse)
|
||||
|
||||
m.SetBody(br.body.ToGRPCMessage().(*accounting.BalanceResponse_Body))
|
||||
br.ResponseHeaders.ToMessage(m)
|
||||
}
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
func (br *BalanceResponse) FromGRPCMessage(m grpc.Message) error {
|
||||
v, ok := m.(*accounting.BalanceResponse)
|
||||
if !ok {
|
||||
return message.NewUnexpectedMessageType(m, v)
|
||||
}
|
||||
|
||||
var err error
|
||||
|
||||
body := v.GetBody()
|
||||
if body == nil {
|
||||
br.body = nil
|
||||
} else {
|
||||
if br.body == nil {
|
||||
br.body = new(BalanceResponseBody)
|
||||
}
|
||||
|
||||
err = br.body.FromGRPCMessage(body)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return br.ResponseHeaders.FromMessage(v)
|
||||
}
|
559
api/accounting/grpc/service.pb.go
generated
Normal file
559
api/accounting/grpc/service.pb.go
generated
Normal file
|
@ -0,0 +1,559 @@
|
|||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.36.1
|
||||
// protoc v5.29.2
|
||||
// source: api/accounting/grpc/service.proto
|
||||
|
||||
//go:build !protoopaque
|
||||
|
||||
package accounting
|
||||
|
||||
import (
|
||||
grpc1 "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/refs/grpc"
|
||||
grpc "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/session/grpc"
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
reflect "reflect"
|
||||
)
|
||||
|
||||
const (
|
||||
// Verify that this generated code is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
||||
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||
)
|
||||
|
||||
// BalanceRequest message
|
||||
type BalanceRequest struct {
|
||||
state protoimpl.MessageState `protogen:"hybrid.v1"`
|
||||
// Body of the balance request message.
|
||||
Body *BalanceRequest_Body `protobuf:"bytes,1,opt,name=body" json:"body,omitempty"`
|
||||
// Carries request meta information. Header data is used only to regulate
|
||||
// message transport and does not affect request execution.
|
||||
MetaHeader *grpc.RequestMetaHeader `protobuf:"bytes,2,opt,name=meta_header,json=metaHeader" json:"meta_header,omitempty"`
|
||||
// Carries request verification information. This header is used to
|
||||
// authenticate the nodes of the message route and check the correctness of
|
||||
// transmission.
|
||||
VerifyHeader *grpc.RequestVerificationHeader `protobuf:"bytes,3,opt,name=verify_header,json=verifyHeader" json:"verify_header,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *BalanceRequest) Reset() {
|
||||
*x = BalanceRequest{}
|
||||
mi := &file_api_accounting_grpc_service_proto_msgTypes[0]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *BalanceRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*BalanceRequest) ProtoMessage() {}
|
||||
|
||||
func (x *BalanceRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_accounting_grpc_service_proto_msgTypes[0]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
func (x *BalanceRequest) GetBody() *BalanceRequest_Body {
|
||||
if x != nil {
|
||||
return x.Body
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *BalanceRequest) GetMetaHeader() *grpc.RequestMetaHeader {
|
||||
if x != nil {
|
||||
return x.MetaHeader
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *BalanceRequest) GetVerifyHeader() *grpc.RequestVerificationHeader {
|
||||
if x != nil {
|
||||
return x.VerifyHeader
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *BalanceRequest) SetBody(v *BalanceRequest_Body) {
|
||||
x.Body = v
|
||||
}
|
||||
|
||||
func (x *BalanceRequest) SetMetaHeader(v *grpc.RequestMetaHeader) {
|
||||
x.MetaHeader = v
|
||||
}
|
||||
|
||||
func (x *BalanceRequest) SetVerifyHeader(v *grpc.RequestVerificationHeader) {
|
||||
x.VerifyHeader = v
|
||||
}
|
||||
|
||||
func (x *BalanceRequest) HasBody() bool {
|
||||
if x == nil {
|
||||
return false
|
||||
}
|
||||
return x.Body != nil
|
||||
}
|
||||
|
||||
func (x *BalanceRequest) HasMetaHeader() bool {
|
||||
if x == nil {
|
||||
return false
|
||||
}
|
||||
return x.MetaHeader != nil
|
||||
}
|
||||
|
||||
func (x *BalanceRequest) HasVerifyHeader() bool {
|
||||
if x == nil {
|
||||
return false
|
||||
}
|
||||
return x.VerifyHeader != nil
|
||||
}
|
||||
|
||||
func (x *BalanceRequest) ClearBody() {
|
||||
x.Body = nil
|
||||
}
|
||||
|
||||
func (x *BalanceRequest) ClearMetaHeader() {
|
||||
x.MetaHeader = nil
|
||||
}
|
||||
|
||||
func (x *BalanceRequest) ClearVerifyHeader() {
|
||||
x.VerifyHeader = nil
|
||||
}
|
||||
|
||||
type BalanceRequest_builder struct {
|
||||
_ [0]func() // Prevents comparability and use of unkeyed literals for the builder.
|
||||
|
||||
// Body of the balance request message.
|
||||
Body *BalanceRequest_Body
|
||||
// Carries request meta information. Header data is used only to regulate
|
||||
// message transport and does not affect request execution.
|
||||
MetaHeader *grpc.RequestMetaHeader
|
||||
// Carries request verification information. This header is used to
|
||||
// authenticate the nodes of the message route and check the correctness of
|
||||
// transmission.
|
||||
VerifyHeader *grpc.RequestVerificationHeader
|
||||
}
|
||||
|
||||
func (b0 BalanceRequest_builder) Build() *BalanceRequest {
|
||||
m0 := &BalanceRequest{}
|
||||
b, x := &b0, m0
|
||||
_, _ = b, x
|
||||
x.Body = b.Body
|
||||
x.MetaHeader = b.MetaHeader
|
||||
x.VerifyHeader = b.VerifyHeader
|
||||
return m0
|
||||
}
|
||||
|
||||
// BalanceResponse message
|
||||
type BalanceResponse struct {
|
||||
state protoimpl.MessageState `protogen:"hybrid.v1"`
|
||||
// Body of the balance response message.
|
||||
Body *BalanceResponse_Body `protobuf:"bytes,1,opt,name=body" json:"body,omitempty"`
|
||||
// Carries response meta information. Header data is used only to regulate
|
||||
// message transport and does not affect request execution.
|
||||
MetaHeader *grpc.ResponseMetaHeader `protobuf:"bytes,2,opt,name=meta_header,json=metaHeader" json:"meta_header,omitempty"`
|
||||
// Carries response verification information. This header is used to
|
||||
// authenticate the nodes of the message route and check the correctness of
|
||||
// transmission.
|
||||
VerifyHeader *grpc.ResponseVerificationHeader `protobuf:"bytes,3,opt,name=verify_header,json=verifyHeader" json:"verify_header,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *BalanceResponse) Reset() {
|
||||
*x = BalanceResponse{}
|
||||
mi := &file_api_accounting_grpc_service_proto_msgTypes[1]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *BalanceResponse) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*BalanceResponse) ProtoMessage() {}
|
||||
|
||||
func (x *BalanceResponse) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_accounting_grpc_service_proto_msgTypes[1]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
func (x *BalanceResponse) GetBody() *BalanceResponse_Body {
|
||||
if x != nil {
|
||||
return x.Body
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *BalanceResponse) GetMetaHeader() *grpc.ResponseMetaHeader {
|
||||
if x != nil {
|
||||
return x.MetaHeader
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *BalanceResponse) GetVerifyHeader() *grpc.ResponseVerificationHeader {
|
||||
if x != nil {
|
||||
return x.VerifyHeader
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *BalanceResponse) SetBody(v *BalanceResponse_Body) {
|
||||
x.Body = v
|
||||
}
|
||||
|
||||
func (x *BalanceResponse) SetMetaHeader(v *grpc.ResponseMetaHeader) {
|
||||
x.MetaHeader = v
|
||||
}
|
||||
|
||||
func (x *BalanceResponse) SetVerifyHeader(v *grpc.ResponseVerificationHeader) {
|
||||
x.VerifyHeader = v
|
||||
}
|
||||
|
||||
func (x *BalanceResponse) HasBody() bool {
|
||||
if x == nil {
|
||||
return false
|
||||
}
|
||||
return x.Body != nil
|
||||
}
|
||||
|
||||
func (x *BalanceResponse) HasMetaHeader() bool {
|
||||
if x == nil {
|
||||
return false
|
||||
}
|
||||
return x.MetaHeader != nil
|
||||
}
|
||||
|
||||
func (x *BalanceResponse) HasVerifyHeader() bool {
|
||||
if x == nil {
|
||||
return false
|
||||
}
|
||||
return x.VerifyHeader != nil
|
||||
}
|
||||
|
||||
func (x *BalanceResponse) ClearBody() {
|
||||
x.Body = nil
|
||||
}
|
||||
|
||||
func (x *BalanceResponse) ClearMetaHeader() {
|
||||
x.MetaHeader = nil
|
||||
}
|
||||
|
||||
func (x *BalanceResponse) ClearVerifyHeader() {
|
||||
x.VerifyHeader = nil
|
||||
}
|
||||
|
||||
type BalanceResponse_builder struct {
|
||||
_ [0]func() // Prevents comparability and use of unkeyed literals for the builder.
|
||||
|
||||
// Body of the balance response message.
|
||||
Body *BalanceResponse_Body
|
||||
// Carries response meta information. Header data is used only to regulate
|
||||
// message transport and does not affect request execution.
|
||||
MetaHeader *grpc.ResponseMetaHeader
|
||||
// Carries response verification information. This header is used to
|
||||
// authenticate the nodes of the message route and check the correctness of
|
||||
// transmission.
|
||||
VerifyHeader *grpc.ResponseVerificationHeader
|
||||
}
|
||||
|
||||
func (b0 BalanceResponse_builder) Build() *BalanceResponse {
|
||||
m0 := &BalanceResponse{}
|
||||
b, x := &b0, m0
|
||||
_, _ = b, x
|
||||
x.Body = b.Body
|
||||
x.MetaHeader = b.MetaHeader
|
||||
x.VerifyHeader = b.VerifyHeader
|
||||
return m0
|
||||
}
|
||||
|
||||
// To indicate the account for which the balance is requested, its identifier
|
||||
// is used. It can be any existing account in FrostFS sidechain `Balance`
|
||||
// smart contract. If omitted, client implementation MUST set it to the
|
||||
// request's signer `OwnerID`.
|
||||
type BalanceRequest_Body struct {
|
||||
state protoimpl.MessageState `protogen:"hybrid.v1"`
|
||||
// Valid user identifier in `OwnerID` format for which the balance is
|
||||
// requested. Required field.
|
||||
OwnerId *grpc1.OwnerID `protobuf:"bytes,1,opt,name=owner_id,json=ownerId" json:"owner_id,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *BalanceRequest_Body) Reset() {
|
||||
*x = BalanceRequest_Body{}
|
||||
mi := &file_api_accounting_grpc_service_proto_msgTypes[2]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *BalanceRequest_Body) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*BalanceRequest_Body) ProtoMessage() {}
|
||||
|
||||
func (x *BalanceRequest_Body) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_accounting_grpc_service_proto_msgTypes[2]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
func (x *BalanceRequest_Body) GetOwnerId() *grpc1.OwnerID {
|
||||
if x != nil {
|
||||
return x.OwnerId
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *BalanceRequest_Body) SetOwnerId(v *grpc1.OwnerID) {
|
||||
x.OwnerId = v
|
||||
}
|
||||
|
||||
func (x *BalanceRequest_Body) HasOwnerId() bool {
|
||||
if x == nil {
|
||||
return false
|
||||
}
|
||||
return x.OwnerId != nil
|
||||
}
|
||||
|
||||
func (x *BalanceRequest_Body) ClearOwnerId() {
|
||||
x.OwnerId = nil
|
||||
}
|
||||
|
||||
type BalanceRequest_Body_builder struct {
|
||||
_ [0]func() // Prevents comparability and use of unkeyed literals for the builder.
|
||||
|
||||
// Valid user identifier in `OwnerID` format for which the balance is
|
||||
// requested. Required field.
|
||||
OwnerId *grpc1.OwnerID
|
||||
}
|
||||
|
||||
func (b0 BalanceRequest_Body_builder) Build() *BalanceRequest_Body {
|
||||
m0 := &BalanceRequest_Body{}
|
||||
b, x := &b0, m0
|
||||
_, _ = b, x
|
||||
x.OwnerId = b.OwnerId
|
||||
return m0
|
||||
}
|
||||
|
||||
// The amount of funds in GAS token for the `OwnerID`'s account requested.
|
||||
// Balance is given in the `Decimal` format to avoid precision issues with
|
||||
// rounding.
|
||||
type BalanceResponse_Body struct {
|
||||
state protoimpl.MessageState `protogen:"hybrid.v1"`
|
||||
// Amount of funds in GAS token for the requested account.
|
||||
Balance *Decimal `protobuf:"bytes,1,opt,name=balance" json:"balance,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *BalanceResponse_Body) Reset() {
|
||||
*x = BalanceResponse_Body{}
|
||||
mi := &file_api_accounting_grpc_service_proto_msgTypes[3]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *BalanceResponse_Body) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*BalanceResponse_Body) ProtoMessage() {}
|
||||
|
||||
func (x *BalanceResponse_Body) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_accounting_grpc_service_proto_msgTypes[3]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
func (x *BalanceResponse_Body) GetBalance() *Decimal {
|
||||
if x != nil {
|
||||
return x.Balance
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *BalanceResponse_Body) SetBalance(v *Decimal) {
|
||||
x.Balance = v
|
||||
}
|
||||
|
||||
func (x *BalanceResponse_Body) HasBalance() bool {
|
||||
if x == nil {
|
||||
return false
|
||||
}
|
||||
return x.Balance != nil
|
||||
}
|
||||
|
||||
func (x *BalanceResponse_Body) ClearBalance() {
|
||||
x.Balance = nil
|
||||
}
|
||||
|
||||
type BalanceResponse_Body_builder struct {
|
||||
_ [0]func() // Prevents comparability and use of unkeyed literals for the builder.
|
||||
|
||||
// Amount of funds in GAS token for the requested account.
|
||||
Balance *Decimal
|
||||
}
|
||||
|
||||
func (b0 BalanceResponse_Body_builder) Build() *BalanceResponse_Body {
|
||||
m0 := &BalanceResponse_Body{}
|
||||
b, x := &b0, m0
|
||||
_, _ = b, x
|
||||
x.Balance = b.Balance
|
||||
return m0
|
||||
}
|
||||
|
||||
var File_api_accounting_grpc_service_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_api_accounting_grpc_service_proto_rawDesc = []byte{
|
||||
0x0a, 0x21, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x69, 0x6e, 0x67,
|
||||
0x2f, 0x67, 0x72, 0x70, 0x63, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x70, 0x72,
|
||||
0x6f, 0x74, 0x6f, 0x12, 0x14, 0x6e, 0x65, 0x6f, 0x2e, 0x66, 0x73, 0x2e, 0x76, 0x32, 0x2e, 0x61,
|
||||
0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x69, 0x6e, 0x67, 0x1a, 0x1f, 0x61, 0x70, 0x69, 0x2f, 0x61,
|
||||
0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x69, 0x6e, 0x67, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2f, 0x74,
|
||||
0x79, 0x70, 0x65, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x19, 0x61, 0x70, 0x69, 0x2f,
|
||||
0x72, 0x65, 0x66, 0x73, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e,
|
||||
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1c, 0x61, 0x70, 0x69, 0x2f, 0x73, 0x65, 0x73, 0x73, 0x69,
|
||||
0x6f, 0x6e, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x70, 0x72,
|
||||
0x6f, 0x74, 0x6f, 0x22, 0xa5, 0x02, 0x0a, 0x0e, 0x42, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x52,
|
||||
0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x3d, 0x0a, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x18, 0x01,
|
||||
0x20, 0x01, 0x28, 0x0b, 0x32, 0x29, 0x2e, 0x6e, 0x65, 0x6f, 0x2e, 0x66, 0x73, 0x2e, 0x76, 0x32,
|
||||
0x2e, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x69, 0x6e, 0x67, 0x2e, 0x42, 0x61, 0x6c, 0x61,
|
||||
0x6e, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x2e, 0x42, 0x6f, 0x64, 0x79, 0x52,
|
||||
0x04, 0x62, 0x6f, 0x64, 0x79, 0x12, 0x45, 0x0a, 0x0b, 0x6d, 0x65, 0x74, 0x61, 0x5f, 0x68, 0x65,
|
||||
0x61, 0x64, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x6e, 0x65, 0x6f,
|
||||
0x2e, 0x66, 0x73, 0x2e, 0x76, 0x32, 0x2e, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2e, 0x52,
|
||||
0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x4d, 0x65, 0x74, 0x61, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72,
|
||||
0x52, 0x0a, 0x6d, 0x65, 0x74, 0x61, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x51, 0x0a, 0x0d,
|
||||
0x76, 0x65, 0x72, 0x69, 0x66, 0x79, 0x5f, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0x03, 0x20,
|
||||
0x01, 0x28, 0x0b, 0x32, 0x2c, 0x2e, 0x6e, 0x65, 0x6f, 0x2e, 0x66, 0x73, 0x2e, 0x76, 0x32, 0x2e,
|
||||
0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x56,
|
||||
0x65, 0x72, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x48, 0x65, 0x61, 0x64, 0x65,
|
||||
0x72, 0x52, 0x0c, 0x76, 0x65, 0x72, 0x69, 0x66, 0x79, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x1a,
|
||||
0x3a, 0x0a, 0x04, 0x42, 0x6f, 0x64, 0x79, 0x12, 0x32, 0x0a, 0x08, 0x6f, 0x77, 0x6e, 0x65, 0x72,
|
||||
0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x6e, 0x65, 0x6f, 0x2e,
|
||||
0x66, 0x73, 0x2e, 0x76, 0x32, 0x2e, 0x72, 0x65, 0x66, 0x73, 0x2e, 0x4f, 0x77, 0x6e, 0x65, 0x72,
|
||||
0x49, 0x44, 0x52, 0x07, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x49, 0x64, 0x22, 0xae, 0x02, 0x0a, 0x0f,
|
||||
0x42, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12,
|
||||
0x3e, 0x0a, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2a, 0x2e,
|
||||
0x6e, 0x65, 0x6f, 0x2e, 0x66, 0x73, 0x2e, 0x76, 0x32, 0x2e, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e,
|
||||
0x74, 0x69, 0x6e, 0x67, 0x2e, 0x42, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70,
|
||||
0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x42, 0x6f, 0x64, 0x79, 0x52, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x12,
|
||||
0x46, 0x0a, 0x0b, 0x6d, 0x65, 0x74, 0x61, 0x5f, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0x02,
|
||||
0x20, 0x01, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x6e, 0x65, 0x6f, 0x2e, 0x66, 0x73, 0x2e, 0x76, 0x32,
|
||||
0x2e, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73,
|
||||
0x65, 0x4d, 0x65, 0x74, 0x61, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x52, 0x0a, 0x6d, 0x65, 0x74,
|
||||
0x61, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x52, 0x0a, 0x0d, 0x76, 0x65, 0x72, 0x69, 0x66,
|
||||
0x79, 0x5f, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2d,
|
||||
0x2e, 0x6e, 0x65, 0x6f, 0x2e, 0x66, 0x73, 0x2e, 0x76, 0x32, 0x2e, 0x73, 0x65, 0x73, 0x73, 0x69,
|
||||
0x6f, 0x6e, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x56, 0x65, 0x72, 0x69, 0x66,
|
||||
0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x52, 0x0c, 0x76,
|
||||
0x65, 0x72, 0x69, 0x66, 0x79, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x1a, 0x3f, 0x0a, 0x04, 0x42,
|
||||
0x6f, 0x64, 0x79, 0x12, 0x37, 0x0a, 0x07, 0x62, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x18, 0x01,
|
||||
0x20, 0x01, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x6e, 0x65, 0x6f, 0x2e, 0x66, 0x73, 0x2e, 0x76, 0x32,
|
||||
0x2e, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x69, 0x6e, 0x67, 0x2e, 0x44, 0x65, 0x63, 0x69,
|
||||
0x6d, 0x61, 0x6c, 0x52, 0x07, 0x62, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x32, 0x6b, 0x0a, 0x11,
|
||||
0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x69, 0x6e, 0x67, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63,
|
||||
0x65, 0x12, 0x56, 0x0a, 0x07, 0x42, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x12, 0x24, 0x2e, 0x6e,
|
||||
0x65, 0x6f, 0x2e, 0x66, 0x73, 0x2e, 0x76, 0x32, 0x2e, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74,
|
||||
0x69, 0x6e, 0x67, 0x2e, 0x42, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65,
|
||||
0x73, 0x74, 0x1a, 0x25, 0x2e, 0x6e, 0x65, 0x6f, 0x2e, 0x66, 0x73, 0x2e, 0x76, 0x32, 0x2e, 0x61,
|
||||
0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x69, 0x6e, 0x67, 0x2e, 0x42, 0x61, 0x6c, 0x61, 0x6e, 0x63,
|
||||
0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x6e, 0x5a, 0x4b, 0x67, 0x69, 0x74,
|
||||
0x2e, 0x66, 0x72, 0x6f, 0x73, 0x74, 0x66, 0x73, 0x2e, 0x69, 0x6e, 0x66, 0x6f, 0x2f, 0x54, 0x72,
|
||||
0x75, 0x65, 0x43, 0x6c, 0x6f, 0x75, 0x64, 0x4c, 0x61, 0x62, 0x2f, 0x66, 0x72, 0x6f, 0x73, 0x74,
|
||||
0x66, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2d, 0x67, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x63,
|
||||
0x63, 0x6f, 0x75, 0x6e, 0x74, 0x69, 0x6e, 0x67, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x3b, 0x61, 0x63,
|
||||
0x63, 0x6f, 0x75, 0x6e, 0x74, 0x69, 0x6e, 0x67, 0xaa, 0x02, 0x1e, 0x4e, 0x65, 0x6f, 0x2e, 0x46,
|
||||
0x69, 0x6c, 0x65, 0x53, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x2e, 0x41, 0x50, 0x49, 0x2e, 0x41,
|
||||
0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x69, 0x6e, 0x67, 0x62, 0x08, 0x65, 0x64, 0x69, 0x74, 0x69,
|
||||
0x6f, 0x6e, 0x73, 0x70, 0xe8, 0x07,
|
||||
}
|
||||
|
||||
var file_api_accounting_grpc_service_proto_msgTypes = make([]protoimpl.MessageInfo, 4)
|
||||
var file_api_accounting_grpc_service_proto_goTypes = []any{
|
||||
(*BalanceRequest)(nil), // 0: neo.fs.v2.accounting.BalanceRequest
|
||||
(*BalanceResponse)(nil), // 1: neo.fs.v2.accounting.BalanceResponse
|
||||
(*BalanceRequest_Body)(nil), // 2: neo.fs.v2.accounting.BalanceRequest.Body
|
||||
(*BalanceResponse_Body)(nil), // 3: neo.fs.v2.accounting.BalanceResponse.Body
|
||||
(*grpc.RequestMetaHeader)(nil), // 4: neo.fs.v2.session.RequestMetaHeader
|
||||
(*grpc.RequestVerificationHeader)(nil), // 5: neo.fs.v2.session.RequestVerificationHeader
|
||||
(*grpc.ResponseMetaHeader)(nil), // 6: neo.fs.v2.session.ResponseMetaHeader
|
||||
(*grpc.ResponseVerificationHeader)(nil), // 7: neo.fs.v2.session.ResponseVerificationHeader
|
||||
(*grpc1.OwnerID)(nil), // 8: neo.fs.v2.refs.OwnerID
|
||||
(*Decimal)(nil), // 9: neo.fs.v2.accounting.Decimal
|
||||
}
|
||||
var file_api_accounting_grpc_service_proto_depIdxs = []int32{
|
||||
2, // 0: neo.fs.v2.accounting.BalanceRequest.body:type_name -> neo.fs.v2.accounting.BalanceRequest.Body
|
||||
4, // 1: neo.fs.v2.accounting.BalanceRequest.meta_header:type_name -> neo.fs.v2.session.RequestMetaHeader
|
||||
5, // 2: neo.fs.v2.accounting.BalanceRequest.verify_header:type_name -> neo.fs.v2.session.RequestVerificationHeader
|
||||
3, // 3: neo.fs.v2.accounting.BalanceResponse.body:type_name -> neo.fs.v2.accounting.BalanceResponse.Body
|
||||
6, // 4: neo.fs.v2.accounting.BalanceResponse.meta_header:type_name -> neo.fs.v2.session.ResponseMetaHeader
|
||||
7, // 5: neo.fs.v2.accounting.BalanceResponse.verify_header:type_name -> neo.fs.v2.session.ResponseVerificationHeader
|
||||
8, // 6: neo.fs.v2.accounting.BalanceRequest.Body.owner_id:type_name -> neo.fs.v2.refs.OwnerID
|
||||
9, // 7: neo.fs.v2.accounting.BalanceResponse.Body.balance:type_name -> neo.fs.v2.accounting.Decimal
|
||||
0, // 8: neo.fs.v2.accounting.AccountingService.Balance:input_type -> neo.fs.v2.accounting.BalanceRequest
|
||||
1, // 9: neo.fs.v2.accounting.AccountingService.Balance:output_type -> neo.fs.v2.accounting.BalanceResponse
|
||||
9, // [9:10] is the sub-list for method output_type
|
||||
8, // [8:9] is the sub-list for method input_type
|
||||
8, // [8:8] is the sub-list for extension type_name
|
||||
8, // [8:8] is the sub-list for extension extendee
|
||||
0, // [0:8] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_api_accounting_grpc_service_proto_init() }
|
||||
func file_api_accounting_grpc_service_proto_init() {
|
||||
if File_api_accounting_grpc_service_proto != nil {
|
||||
return
|
||||
}
|
||||
file_api_accounting_grpc_types_proto_init()
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_api_accounting_grpc_service_proto_rawDesc,
|
||||
NumEnums: 0,
|
||||
NumMessages: 4,
|
||||
NumExtensions: 0,
|
||||
NumServices: 1,
|
||||
},
|
||||
GoTypes: file_api_accounting_grpc_service_proto_goTypes,
|
||||
DependencyIndexes: file_api_accounting_grpc_service_proto_depIdxs,
|
||||
MessageInfos: file_api_accounting_grpc_service_proto_msgTypes,
|
||||
}.Build()
|
||||
File_api_accounting_grpc_service_proto = out.File
|
||||
file_api_accounting_grpc_service_proto_rawDesc = nil
|
||||
file_api_accounting_grpc_service_proto_goTypes = nil
|
||||
file_api_accounting_grpc_service_proto_depIdxs = nil
|
||||
}
|
143
api/accounting/grpc/service_grpc.pb.go
generated
Normal file
143
api/accounting/grpc/service_grpc.pb.go
generated
Normal file
|
@ -0,0 +1,143 @@
|
|||
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
||||
// versions:
|
||||
// - protoc-gen-go-grpc v1.5.1
|
||||
// - protoc v5.29.2
|
||||
// source: api/accounting/grpc/service.proto
|
||||
|
||||
package accounting
|
||||
|
||||
import (
|
||||
context "context"
|
||||
grpc "google.golang.org/grpc"
|
||||
codes "google.golang.org/grpc/codes"
|
||||
status "google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the grpc package it is being compiled against.
|
||||
// Requires gRPC-Go v1.64.0 or later.
|
||||
const _ = grpc.SupportPackageIsVersion9
|
||||
|
||||
const (
|
||||
AccountingService_Balance_FullMethodName = "/neo.fs.v2.accounting.AccountingService/Balance"
|
||||
)
|
||||
|
||||
// AccountingServiceClient is the client API for AccountingService service.
|
||||
//
|
||||
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
|
||||
//
|
||||
// Accounting service provides methods for interaction with FrostFS sidechain
|
||||
// via other FrostFS nodes to get information about the account balance. Deposit
|
||||
// and Withdraw operations can't be implemented here, as they require Mainnet
|
||||
// FrostFS smart contract invocation. Transfer operations between internal
|
||||
// FrostFS accounts are possible if both use the same token type.
|
||||
type AccountingServiceClient interface {
|
||||
// Returns the amount of funds in GAS token for the requested FrostFS account.
|
||||
//
|
||||
// Statuses:
|
||||
// - **OK** (0, SECTION_SUCCESS):
|
||||
// balance has been successfully read;
|
||||
// - Common failures (SECTION_FAILURE_COMMON).
|
||||
Balance(ctx context.Context, in *BalanceRequest, opts ...grpc.CallOption) (*BalanceResponse, error)
|
||||
}
|
||||
|
||||
type accountingServiceClient struct {
|
||||
cc grpc.ClientConnInterface
|
||||
}
|
||||
|
||||
func NewAccountingServiceClient(cc grpc.ClientConnInterface) AccountingServiceClient {
|
||||
return &accountingServiceClient{cc}
|
||||
}
|
||||
|
||||
func (c *accountingServiceClient) Balance(ctx context.Context, in *BalanceRequest, opts ...grpc.CallOption) (*BalanceResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(BalanceResponse)
|
||||
err := c.cc.Invoke(ctx, AccountingService_Balance_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// AccountingServiceServer is the server API for AccountingService service.
|
||||
// All implementations should embed UnimplementedAccountingServiceServer
|
||||
// for forward compatibility.
|
||||
//
|
||||
// Accounting service provides methods for interaction with FrostFS sidechain
|
||||
// via other FrostFS nodes to get information about the account balance. Deposit
|
||||
// and Withdraw operations can't be implemented here, as they require Mainnet
|
||||
// FrostFS smart contract invocation. Transfer operations between internal
|
||||
// FrostFS accounts are possible if both use the same token type.
|
||||
type AccountingServiceServer interface {
|
||||
// Returns the amount of funds in GAS token for the requested FrostFS account.
|
||||
//
|
||||
// Statuses:
|
||||
// - **OK** (0, SECTION_SUCCESS):
|
||||
// balance has been successfully read;
|
||||
// - Common failures (SECTION_FAILURE_COMMON).
|
||||
Balance(context.Context, *BalanceRequest) (*BalanceResponse, error)
|
||||
}
|
||||
|
||||
// UnimplementedAccountingServiceServer should be embedded to have
|
||||
// forward compatible implementations.
|
||||
//
|
||||
// NOTE: this should be embedded by value instead of pointer to avoid a nil
|
||||
// pointer dereference when methods are called.
|
||||
type UnimplementedAccountingServiceServer struct{}
|
||||
|
||||
func (UnimplementedAccountingServiceServer) Balance(context.Context, *BalanceRequest) (*BalanceResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method Balance not implemented")
|
||||
}
|
||||
func (UnimplementedAccountingServiceServer) testEmbeddedByValue() {}
|
||||
|
||||
// UnsafeAccountingServiceServer may be embedded to opt out of forward compatibility for this service.
|
||||
// Use of this interface is not recommended, as added methods to AccountingServiceServer will
|
||||
// result in compilation errors.
|
||||
type UnsafeAccountingServiceServer interface {
|
||||
mustEmbedUnimplementedAccountingServiceServer()
|
||||
}
|
||||
|
||||
func RegisterAccountingServiceServer(s grpc.ServiceRegistrar, srv AccountingServiceServer) {
|
||||
// If the following call pancis, it indicates UnimplementedAccountingServiceServer was
|
||||
// embedded by pointer and is nil. This will cause panics if an
|
||||
// unimplemented method is ever invoked, so we test this at initialization
|
||||
// time to prevent it from happening at runtime later due to I/O.
|
||||
if t, ok := srv.(interface{ testEmbeddedByValue() }); ok {
|
||||
t.testEmbeddedByValue()
|
||||
}
|
||||
s.RegisterService(&AccountingService_ServiceDesc, srv)
|
||||
}
|
||||
|
||||
func _AccountingService_Balance_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(BalanceRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(AccountingServiceServer).Balance(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: AccountingService_Balance_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(AccountingServiceServer).Balance(ctx, req.(*BalanceRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
// AccountingService_ServiceDesc is the grpc.ServiceDesc for AccountingService service.
|
||||
// It's only intended for direct use with grpc.RegisterService,
|
||||
// and not to be introspected or modified (even as a copy)
|
||||
var AccountingService_ServiceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "neo.fs.v2.accounting.AccountingService",
|
||||
HandlerType: (*AccountingServiceServer)(nil),
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "Balance",
|
||||
Handler: _AccountingService_Balance_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "api/accounting/grpc/service.proto",
|
||||
}
|
544
api/accounting/grpc/service_protoopaque.pb.go
generated
Normal file
544
api/accounting/grpc/service_protoopaque.pb.go
generated
Normal file
|
@ -0,0 +1,544 @@
|
|||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.36.1
|
||||
// protoc v5.29.2
|
||||
// source: api/accounting/grpc/service.proto
|
||||
|
||||
//go:build protoopaque
|
||||
|
||||
package accounting
|
||||
|
||||
import (
|
||||
grpc1 "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/refs/grpc"
|
||||
grpc "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/session/grpc"
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
reflect "reflect"
|
||||
)
|
||||
|
||||
const (
|
||||
// Verify that this generated code is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
||||
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||
)
|
||||
|
||||
// BalanceRequest message
|
||||
type BalanceRequest struct {
|
||||
state protoimpl.MessageState `protogen:"opaque.v1"`
|
||||
xxx_hidden_Body *BalanceRequest_Body `protobuf:"bytes,1,opt,name=body" json:"body,omitempty"`
|
||||
xxx_hidden_MetaHeader *grpc.RequestMetaHeader `protobuf:"bytes,2,opt,name=meta_header,json=metaHeader" json:"meta_header,omitempty"`
|
||||
xxx_hidden_VerifyHeader *grpc.RequestVerificationHeader `protobuf:"bytes,3,opt,name=verify_header,json=verifyHeader" json:"verify_header,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *BalanceRequest) Reset() {
|
||||
*x = BalanceRequest{}
|
||||
mi := &file_api_accounting_grpc_service_proto_msgTypes[0]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *BalanceRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*BalanceRequest) ProtoMessage() {}
|
||||
|
||||
func (x *BalanceRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_accounting_grpc_service_proto_msgTypes[0]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
func (x *BalanceRequest) GetBody() *BalanceRequest_Body {
|
||||
if x != nil {
|
||||
return x.xxx_hidden_Body
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *BalanceRequest) GetMetaHeader() *grpc.RequestMetaHeader {
|
||||
if x != nil {
|
||||
return x.xxx_hidden_MetaHeader
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *BalanceRequest) GetVerifyHeader() *grpc.RequestVerificationHeader {
|
||||
if x != nil {
|
||||
return x.xxx_hidden_VerifyHeader
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *BalanceRequest) SetBody(v *BalanceRequest_Body) {
|
||||
x.xxx_hidden_Body = v
|
||||
}
|
||||
|
||||
func (x *BalanceRequest) SetMetaHeader(v *grpc.RequestMetaHeader) {
|
||||
x.xxx_hidden_MetaHeader = v
|
||||
}
|
||||
|
||||
func (x *BalanceRequest) SetVerifyHeader(v *grpc.RequestVerificationHeader) {
|
||||
x.xxx_hidden_VerifyHeader = v
|
||||
}
|
||||
|
||||
func (x *BalanceRequest) HasBody() bool {
|
||||
if x == nil {
|
||||
return false
|
||||
}
|
||||
return x.xxx_hidden_Body != nil
|
||||
}
|
||||
|
||||
func (x *BalanceRequest) HasMetaHeader() bool {
|
||||
if x == nil {
|
||||
return false
|
||||
}
|
||||
return x.xxx_hidden_MetaHeader != nil
|
||||
}
|
||||
|
||||
func (x *BalanceRequest) HasVerifyHeader() bool {
|
||||
if x == nil {
|
||||
return false
|
||||
}
|
||||
return x.xxx_hidden_VerifyHeader != nil
|
||||
}
|
||||
|
||||
func (x *BalanceRequest) ClearBody() {
|
||||
x.xxx_hidden_Body = nil
|
||||
}
|
||||
|
||||
func (x *BalanceRequest) ClearMetaHeader() {
|
||||
x.xxx_hidden_MetaHeader = nil
|
||||
}
|
||||
|
||||
func (x *BalanceRequest) ClearVerifyHeader() {
|
||||
x.xxx_hidden_VerifyHeader = nil
|
||||
}
|
||||
|
||||
type BalanceRequest_builder struct {
|
||||
_ [0]func() // Prevents comparability and use of unkeyed literals for the builder.
|
||||
|
||||
// Body of the balance request message.
|
||||
Body *BalanceRequest_Body
|
||||
// Carries request meta information. Header data is used only to regulate
|
||||
// message transport and does not affect request execution.
|
||||
MetaHeader *grpc.RequestMetaHeader
|
||||
// Carries request verification information. This header is used to
|
||||
// authenticate the nodes of the message route and check the correctness of
|
||||
// transmission.
|
||||
VerifyHeader *grpc.RequestVerificationHeader
|
||||
}
|
||||
|
||||
func (b0 BalanceRequest_builder) Build() *BalanceRequest {
|
||||
m0 := &BalanceRequest{}
|
||||
b, x := &b0, m0
|
||||
_, _ = b, x
|
||||
x.xxx_hidden_Body = b.Body
|
||||
x.xxx_hidden_MetaHeader = b.MetaHeader
|
||||
x.xxx_hidden_VerifyHeader = b.VerifyHeader
|
||||
return m0
|
||||
}
|
||||
|
||||
// BalanceResponse message
|
||||
type BalanceResponse struct {
|
||||
state protoimpl.MessageState `protogen:"opaque.v1"`
|
||||
xxx_hidden_Body *BalanceResponse_Body `protobuf:"bytes,1,opt,name=body" json:"body,omitempty"`
|
||||
xxx_hidden_MetaHeader *grpc.ResponseMetaHeader `protobuf:"bytes,2,opt,name=meta_header,json=metaHeader" json:"meta_header,omitempty"`
|
||||
xxx_hidden_VerifyHeader *grpc.ResponseVerificationHeader `protobuf:"bytes,3,opt,name=verify_header,json=verifyHeader" json:"verify_header,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *BalanceResponse) Reset() {
|
||||
*x = BalanceResponse{}
|
||||
mi := &file_api_accounting_grpc_service_proto_msgTypes[1]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *BalanceResponse) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*BalanceResponse) ProtoMessage() {}
|
||||
|
||||
func (x *BalanceResponse) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_accounting_grpc_service_proto_msgTypes[1]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
func (x *BalanceResponse) GetBody() *BalanceResponse_Body {
|
||||
if x != nil {
|
||||
return x.xxx_hidden_Body
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *BalanceResponse) GetMetaHeader() *grpc.ResponseMetaHeader {
|
||||
if x != nil {
|
||||
return x.xxx_hidden_MetaHeader
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *BalanceResponse) GetVerifyHeader() *grpc.ResponseVerificationHeader {
|
||||
if x != nil {
|
||||
return x.xxx_hidden_VerifyHeader
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *BalanceResponse) SetBody(v *BalanceResponse_Body) {
|
||||
x.xxx_hidden_Body = v
|
||||
}
|
||||
|
||||
func (x *BalanceResponse) SetMetaHeader(v *grpc.ResponseMetaHeader) {
|
||||
x.xxx_hidden_MetaHeader = v
|
||||
}
|
||||
|
||||
func (x *BalanceResponse) SetVerifyHeader(v *grpc.ResponseVerificationHeader) {
|
||||
x.xxx_hidden_VerifyHeader = v
|
||||
}
|
||||
|
||||
func (x *BalanceResponse) HasBody() bool {
|
||||
if x == nil {
|
||||
return false
|
||||
}
|
||||
return x.xxx_hidden_Body != nil
|
||||
}
|
||||
|
||||
func (x *BalanceResponse) HasMetaHeader() bool {
|
||||
if x == nil {
|
||||
return false
|
||||
}
|
||||
return x.xxx_hidden_MetaHeader != nil
|
||||
}
|
||||
|
||||
func (x *BalanceResponse) HasVerifyHeader() bool {
|
||||
if x == nil {
|
||||
return false
|
||||
}
|
||||
return x.xxx_hidden_VerifyHeader != nil
|
||||
}
|
||||
|
||||
func (x *BalanceResponse) ClearBody() {
|
||||
x.xxx_hidden_Body = nil
|
||||
}
|
||||
|
||||
func (x *BalanceResponse) ClearMetaHeader() {
|
||||
x.xxx_hidden_MetaHeader = nil
|
||||
}
|
||||
|
||||
func (x *BalanceResponse) ClearVerifyHeader() {
|
||||
x.xxx_hidden_VerifyHeader = nil
|
||||
}
|
||||
|
||||
type BalanceResponse_builder struct {
|
||||
_ [0]func() // Prevents comparability and use of unkeyed literals for the builder.
|
||||
|
||||
// Body of the balance response message.
|
||||
Body *BalanceResponse_Body
|
||||
// Carries response meta information. Header data is used only to regulate
|
||||
// message transport and does not affect request execution.
|
||||
MetaHeader *grpc.ResponseMetaHeader
|
||||
// Carries response verification information. This header is used to
|
||||
// authenticate the nodes of the message route and check the correctness of
|
||||
// transmission.
|
||||
VerifyHeader *grpc.ResponseVerificationHeader
|
||||
}
|
||||
|
||||
func (b0 BalanceResponse_builder) Build() *BalanceResponse {
|
||||
m0 := &BalanceResponse{}
|
||||
b, x := &b0, m0
|
||||
_, _ = b, x
|
||||
x.xxx_hidden_Body = b.Body
|
||||
x.xxx_hidden_MetaHeader = b.MetaHeader
|
||||
x.xxx_hidden_VerifyHeader = b.VerifyHeader
|
||||
return m0
|
||||
}
|
||||
|
||||
// To indicate the account for which the balance is requested, its identifier
|
||||
// is used. It can be any existing account in FrostFS sidechain `Balance`
|
||||
// smart contract. If omitted, client implementation MUST set it to the
|
||||
// request's signer `OwnerID`.
|
||||
type BalanceRequest_Body struct {
|
||||
state protoimpl.MessageState `protogen:"opaque.v1"`
|
||||
xxx_hidden_OwnerId *grpc1.OwnerID `protobuf:"bytes,1,opt,name=owner_id,json=ownerId" json:"owner_id,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *BalanceRequest_Body) Reset() {
|
||||
*x = BalanceRequest_Body{}
|
||||
mi := &file_api_accounting_grpc_service_proto_msgTypes[2]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *BalanceRequest_Body) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*BalanceRequest_Body) ProtoMessage() {}
|
||||
|
||||
func (x *BalanceRequest_Body) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_accounting_grpc_service_proto_msgTypes[2]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
func (x *BalanceRequest_Body) GetOwnerId() *grpc1.OwnerID {
|
||||
if x != nil {
|
||||
return x.xxx_hidden_OwnerId
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *BalanceRequest_Body) SetOwnerId(v *grpc1.OwnerID) {
|
||||
x.xxx_hidden_OwnerId = v
|
||||
}
|
||||
|
||||
func (x *BalanceRequest_Body) HasOwnerId() bool {
|
||||
if x == nil {
|
||||
return false
|
||||
}
|
||||
return x.xxx_hidden_OwnerId != nil
|
||||
}
|
||||
|
||||
func (x *BalanceRequest_Body) ClearOwnerId() {
|
||||
x.xxx_hidden_OwnerId = nil
|
||||
}
|
||||
|
||||
type BalanceRequest_Body_builder struct {
|
||||
_ [0]func() // Prevents comparability and use of unkeyed literals for the builder.
|
||||
|
||||
// Valid user identifier in `OwnerID` format for which the balance is
|
||||
// requested. Required field.
|
||||
OwnerId *grpc1.OwnerID
|
||||
}
|
||||
|
||||
func (b0 BalanceRequest_Body_builder) Build() *BalanceRequest_Body {
|
||||
m0 := &BalanceRequest_Body{}
|
||||
b, x := &b0, m0
|
||||
_, _ = b, x
|
||||
x.xxx_hidden_OwnerId = b.OwnerId
|
||||
return m0
|
||||
}
|
||||
|
||||
// The amount of funds in GAS token for the `OwnerID`'s account requested.
|
||||
// Balance is given in the `Decimal` format to avoid precision issues with
|
||||
// rounding.
|
||||
type BalanceResponse_Body struct {
|
||||
state protoimpl.MessageState `protogen:"opaque.v1"`
|
||||
xxx_hidden_Balance *Decimal `protobuf:"bytes,1,opt,name=balance" json:"balance,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *BalanceResponse_Body) Reset() {
|
||||
*x = BalanceResponse_Body{}
|
||||
mi := &file_api_accounting_grpc_service_proto_msgTypes[3]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *BalanceResponse_Body) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*BalanceResponse_Body) ProtoMessage() {}
|
||||
|
||||
func (x *BalanceResponse_Body) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_accounting_grpc_service_proto_msgTypes[3]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
func (x *BalanceResponse_Body) GetBalance() *Decimal {
|
||||
if x != nil {
|
||||
return x.xxx_hidden_Balance
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *BalanceResponse_Body) SetBalance(v *Decimal) {
|
||||
x.xxx_hidden_Balance = v
|
||||
}
|
||||
|
||||
func (x *BalanceResponse_Body) HasBalance() bool {
|
||||
if x == nil {
|
||||
return false
|
||||
}
|
||||
return x.xxx_hidden_Balance != nil
|
||||
}
|
||||
|
||||
func (x *BalanceResponse_Body) ClearBalance() {
|
||||
x.xxx_hidden_Balance = nil
|
||||
}
|
||||
|
||||
type BalanceResponse_Body_builder struct {
|
||||
_ [0]func() // Prevents comparability and use of unkeyed literals for the builder.
|
||||
|
||||
// Amount of funds in GAS token for the requested account.
|
||||
Balance *Decimal
|
||||
}
|
||||
|
||||
func (b0 BalanceResponse_Body_builder) Build() *BalanceResponse_Body {
|
||||
m0 := &BalanceResponse_Body{}
|
||||
b, x := &b0, m0
|
||||
_, _ = b, x
|
||||
x.xxx_hidden_Balance = b.Balance
|
||||
return m0
|
||||
}
|
||||
|
||||
var File_api_accounting_grpc_service_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_api_accounting_grpc_service_proto_rawDesc = []byte{
|
||||
0x0a, 0x21, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x69, 0x6e, 0x67,
|
||||
0x2f, 0x67, 0x72, 0x70, 0x63, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x70, 0x72,
|
||||
0x6f, 0x74, 0x6f, 0x12, 0x14, 0x6e, 0x65, 0x6f, 0x2e, 0x66, 0x73, 0x2e, 0x76, 0x32, 0x2e, 0x61,
|
||||
0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x69, 0x6e, 0x67, 0x1a, 0x1f, 0x61, 0x70, 0x69, 0x2f, 0x61,
|
||||
0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x69, 0x6e, 0x67, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2f, 0x74,
|
||||
0x79, 0x70, 0x65, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x19, 0x61, 0x70, 0x69, 0x2f,
|
||||
0x72, 0x65, 0x66, 0x73, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e,
|
||||
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1c, 0x61, 0x70, 0x69, 0x2f, 0x73, 0x65, 0x73, 0x73, 0x69,
|
||||
0x6f, 0x6e, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x70, 0x72,
|
||||
0x6f, 0x74, 0x6f, 0x22, 0xa5, 0x02, 0x0a, 0x0e, 0x42, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x52,
|
||||
0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x3d, 0x0a, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x18, 0x01,
|
||||
0x20, 0x01, 0x28, 0x0b, 0x32, 0x29, 0x2e, 0x6e, 0x65, 0x6f, 0x2e, 0x66, 0x73, 0x2e, 0x76, 0x32,
|
||||
0x2e, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x69, 0x6e, 0x67, 0x2e, 0x42, 0x61, 0x6c, 0x61,
|
||||
0x6e, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x2e, 0x42, 0x6f, 0x64, 0x79, 0x52,
|
||||
0x04, 0x62, 0x6f, 0x64, 0x79, 0x12, 0x45, 0x0a, 0x0b, 0x6d, 0x65, 0x74, 0x61, 0x5f, 0x68, 0x65,
|
||||
0x61, 0x64, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x6e, 0x65, 0x6f,
|
||||
0x2e, 0x66, 0x73, 0x2e, 0x76, 0x32, 0x2e, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2e, 0x52,
|
||||
0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x4d, 0x65, 0x74, 0x61, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72,
|
||||
0x52, 0x0a, 0x6d, 0x65, 0x74, 0x61, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x51, 0x0a, 0x0d,
|
||||
0x76, 0x65, 0x72, 0x69, 0x66, 0x79, 0x5f, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0x03, 0x20,
|
||||
0x01, 0x28, 0x0b, 0x32, 0x2c, 0x2e, 0x6e, 0x65, 0x6f, 0x2e, 0x66, 0x73, 0x2e, 0x76, 0x32, 0x2e,
|
||||
0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x56,
|
||||
0x65, 0x72, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x48, 0x65, 0x61, 0x64, 0x65,
|
||||
0x72, 0x52, 0x0c, 0x76, 0x65, 0x72, 0x69, 0x66, 0x79, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x1a,
|
||||
0x3a, 0x0a, 0x04, 0x42, 0x6f, 0x64, 0x79, 0x12, 0x32, 0x0a, 0x08, 0x6f, 0x77, 0x6e, 0x65, 0x72,
|
||||
0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x6e, 0x65, 0x6f, 0x2e,
|
||||
0x66, 0x73, 0x2e, 0x76, 0x32, 0x2e, 0x72, 0x65, 0x66, 0x73, 0x2e, 0x4f, 0x77, 0x6e, 0x65, 0x72,
|
||||
0x49, 0x44, 0x52, 0x07, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x49, 0x64, 0x22, 0xae, 0x02, 0x0a, 0x0f,
|
||||
0x42, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12,
|
||||
0x3e, 0x0a, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2a, 0x2e,
|
||||
0x6e, 0x65, 0x6f, 0x2e, 0x66, 0x73, 0x2e, 0x76, 0x32, 0x2e, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e,
|
||||
0x74, 0x69, 0x6e, 0x67, 0x2e, 0x42, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70,
|
||||
0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x42, 0x6f, 0x64, 0x79, 0x52, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x12,
|
||||
0x46, 0x0a, 0x0b, 0x6d, 0x65, 0x74, 0x61, 0x5f, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0x02,
|
||||
0x20, 0x01, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x6e, 0x65, 0x6f, 0x2e, 0x66, 0x73, 0x2e, 0x76, 0x32,
|
||||
0x2e, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73,
|
||||
0x65, 0x4d, 0x65, 0x74, 0x61, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x52, 0x0a, 0x6d, 0x65, 0x74,
|
||||
0x61, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x52, 0x0a, 0x0d, 0x76, 0x65, 0x72, 0x69, 0x66,
|
||||
0x79, 0x5f, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2d,
|
||||
0x2e, 0x6e, 0x65, 0x6f, 0x2e, 0x66, 0x73, 0x2e, 0x76, 0x32, 0x2e, 0x73, 0x65, 0x73, 0x73, 0x69,
|
||||
0x6f, 0x6e, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x56, 0x65, 0x72, 0x69, 0x66,
|
||||
0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x52, 0x0c, 0x76,
|
||||
0x65, 0x72, 0x69, 0x66, 0x79, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x1a, 0x3f, 0x0a, 0x04, 0x42,
|
||||
0x6f, 0x64, 0x79, 0x12, 0x37, 0x0a, 0x07, 0x62, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x18, 0x01,
|
||||
0x20, 0x01, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x6e, 0x65, 0x6f, 0x2e, 0x66, 0x73, 0x2e, 0x76, 0x32,
|
||||
0x2e, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x69, 0x6e, 0x67, 0x2e, 0x44, 0x65, 0x63, 0x69,
|
||||
0x6d, 0x61, 0x6c, 0x52, 0x07, 0x62, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x32, 0x6b, 0x0a, 0x11,
|
||||
0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x69, 0x6e, 0x67, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63,
|
||||
0x65, 0x12, 0x56, 0x0a, 0x07, 0x42, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x12, 0x24, 0x2e, 0x6e,
|
||||
0x65, 0x6f, 0x2e, 0x66, 0x73, 0x2e, 0x76, 0x32, 0x2e, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74,
|
||||
0x69, 0x6e, 0x67, 0x2e, 0x42, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65,
|
||||
0x73, 0x74, 0x1a, 0x25, 0x2e, 0x6e, 0x65, 0x6f, 0x2e, 0x66, 0x73, 0x2e, 0x76, 0x32, 0x2e, 0x61,
|
||||
0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x69, 0x6e, 0x67, 0x2e, 0x42, 0x61, 0x6c, 0x61, 0x6e, 0x63,
|
||||
0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x6e, 0x5a, 0x4b, 0x67, 0x69, 0x74,
|
||||
0x2e, 0x66, 0x72, 0x6f, 0x73, 0x74, 0x66, 0x73, 0x2e, 0x69, 0x6e, 0x66, 0x6f, 0x2f, 0x54, 0x72,
|
||||
0x75, 0x65, 0x43, 0x6c, 0x6f, 0x75, 0x64, 0x4c, 0x61, 0x62, 0x2f, 0x66, 0x72, 0x6f, 0x73, 0x74,
|
||||
0x66, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2d, 0x67, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x63,
|
||||
0x63, 0x6f, 0x75, 0x6e, 0x74, 0x69, 0x6e, 0x67, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x3b, 0x61, 0x63,
|
||||
0x63, 0x6f, 0x75, 0x6e, 0x74, 0x69, 0x6e, 0x67, 0xaa, 0x02, 0x1e, 0x4e, 0x65, 0x6f, 0x2e, 0x46,
|
||||
0x69, 0x6c, 0x65, 0x53, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x2e, 0x41, 0x50, 0x49, 0x2e, 0x41,
|
||||
0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x69, 0x6e, 0x67, 0x62, 0x08, 0x65, 0x64, 0x69, 0x74, 0x69,
|
||||
0x6f, 0x6e, 0x73, 0x70, 0xe8, 0x07,
|
||||
}
|
||||
|
||||
var file_api_accounting_grpc_service_proto_msgTypes = make([]protoimpl.MessageInfo, 4)
|
||||
var file_api_accounting_grpc_service_proto_goTypes = []any{
|
||||
(*BalanceRequest)(nil), // 0: neo.fs.v2.accounting.BalanceRequest
|
||||
(*BalanceResponse)(nil), // 1: neo.fs.v2.accounting.BalanceResponse
|
||||
(*BalanceRequest_Body)(nil), // 2: neo.fs.v2.accounting.BalanceRequest.Body
|
||||
(*BalanceResponse_Body)(nil), // 3: neo.fs.v2.accounting.BalanceResponse.Body
|
||||
(*grpc.RequestMetaHeader)(nil), // 4: neo.fs.v2.session.RequestMetaHeader
|
||||
(*grpc.RequestVerificationHeader)(nil), // 5: neo.fs.v2.session.RequestVerificationHeader
|
||||
(*grpc.ResponseMetaHeader)(nil), // 6: neo.fs.v2.session.ResponseMetaHeader
|
||||
(*grpc.ResponseVerificationHeader)(nil), // 7: neo.fs.v2.session.ResponseVerificationHeader
|
||||
(*grpc1.OwnerID)(nil), // 8: neo.fs.v2.refs.OwnerID
|
||||
(*Decimal)(nil), // 9: neo.fs.v2.accounting.Decimal
|
||||
}
|
||||
var file_api_accounting_grpc_service_proto_depIdxs = []int32{
|
||||
2, // 0: neo.fs.v2.accounting.BalanceRequest.body:type_name -> neo.fs.v2.accounting.BalanceRequest.Body
|
||||
4, // 1: neo.fs.v2.accounting.BalanceRequest.meta_header:type_name -> neo.fs.v2.session.RequestMetaHeader
|
||||
5, // 2: neo.fs.v2.accounting.BalanceRequest.verify_header:type_name -> neo.fs.v2.session.RequestVerificationHeader
|
||||
3, // 3: neo.fs.v2.accounting.BalanceResponse.body:type_name -> neo.fs.v2.accounting.BalanceResponse.Body
|
||||
6, // 4: neo.fs.v2.accounting.BalanceResponse.meta_header:type_name -> neo.fs.v2.session.ResponseMetaHeader
|
||||
7, // 5: neo.fs.v2.accounting.BalanceResponse.verify_header:type_name -> neo.fs.v2.session.ResponseVerificationHeader
|
||||
8, // 6: neo.fs.v2.accounting.BalanceRequest.Body.owner_id:type_name -> neo.fs.v2.refs.OwnerID
|
||||
9, // 7: neo.fs.v2.accounting.BalanceResponse.Body.balance:type_name -> neo.fs.v2.accounting.Decimal
|
||||
0, // 8: neo.fs.v2.accounting.AccountingService.Balance:input_type -> neo.fs.v2.accounting.BalanceRequest
|
||||
1, // 9: neo.fs.v2.accounting.AccountingService.Balance:output_type -> neo.fs.v2.accounting.BalanceResponse
|
||||
9, // [9:10] is the sub-list for method output_type
|
||||
8, // [8:9] is the sub-list for method input_type
|
||||
8, // [8:8] is the sub-list for extension type_name
|
||||
8, // [8:8] is the sub-list for extension extendee
|
||||
0, // [0:8] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_api_accounting_grpc_service_proto_init() }
|
||||
func file_api_accounting_grpc_service_proto_init() {
|
||||
if File_api_accounting_grpc_service_proto != nil {
|
||||
return
|
||||
}
|
||||
file_api_accounting_grpc_types_proto_init()
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_api_accounting_grpc_service_proto_rawDesc,
|
||||
NumEnums: 0,
|
||||
NumMessages: 4,
|
||||
NumExtensions: 0,
|
||||
NumServices: 1,
|
||||
},
|
||||
GoTypes: file_api_accounting_grpc_service_proto_goTypes,
|
||||
DependencyIndexes: file_api_accounting_grpc_service_proto_depIdxs,
|
||||
MessageInfos: file_api_accounting_grpc_service_proto_msgTypes,
|
||||
}.Build()
|
||||
File_api_accounting_grpc_service_proto = out.File
|
||||
file_api_accounting_grpc_service_proto_rawDesc = nil
|
||||
file_api_accounting_grpc_service_proto_goTypes = nil
|
||||
file_api_accounting_grpc_service_proto_depIdxs = nil
|
||||
}
|
186
api/accounting/grpc/types.pb.go
generated
Normal file
186
api/accounting/grpc/types.pb.go
generated
Normal file
|
@ -0,0 +1,186 @@
|
|||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.36.1
|
||||
// protoc v5.29.2
|
||||
// source: api/accounting/grpc/types.proto
|
||||
|
||||
//go:build !protoopaque
|
||||
|
||||
package accounting
|
||||
|
||||
import (
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
reflect "reflect"
|
||||
)
|
||||
|
||||
const (
|
||||
// Verify that this generated code is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
||||
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||
)
|
||||
|
||||
// Standard floating point data type can't be used in FrostFS due to inexactness
|
||||
// of the result when doing lots of small number operations. To solve the lost
|
||||
// precision issue, special `Decimal` format is used for monetary computations.
|
||||
//
|
||||
// Please see [The General Decimal Arithmetic
|
||||
// Specification](http://speleotrove.com/decimal/) for detailed problem
|
||||
// description.
|
||||
type Decimal struct {
|
||||
state protoimpl.MessageState `protogen:"hybrid.v1"`
|
||||
// Number in the smallest Token fractions.
|
||||
Value *int64 `protobuf:"varint,1,opt,name=value" json:"value,omitempty"`
|
||||
// Precision value indicating how many smallest fractions can be in one
|
||||
// integer.
|
||||
Precision *uint32 `protobuf:"varint,2,opt,name=precision" json:"precision,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *Decimal) Reset() {
|
||||
*x = Decimal{}
|
||||
mi := &file_api_accounting_grpc_types_proto_msgTypes[0]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *Decimal) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*Decimal) ProtoMessage() {}
|
||||
|
||||
func (x *Decimal) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_accounting_grpc_types_proto_msgTypes[0]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
func (x *Decimal) GetValue() int64 {
|
||||
if x != nil && x.Value != nil {
|
||||
return *x.Value
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *Decimal) GetPrecision() uint32 {
|
||||
if x != nil && x.Precision != nil {
|
||||
return *x.Precision
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *Decimal) SetValue(v int64) {
|
||||
x.Value = &v
|
||||
}
|
||||
|
||||
func (x *Decimal) SetPrecision(v uint32) {
|
||||
x.Precision = &v
|
||||
}
|
||||
|
||||
func (x *Decimal) HasValue() bool {
|
||||
if x == nil {
|
||||
return false
|
||||
}
|
||||
return x.Value != nil
|
||||
}
|
||||
|
||||
func (x *Decimal) HasPrecision() bool {
|
||||
if x == nil {
|
||||
return false
|
||||
}
|
||||
return x.Precision != nil
|
||||
}
|
||||
|
||||
func (x *Decimal) ClearValue() {
|
||||
x.Value = nil
|
||||
}
|
||||
|
||||
func (x *Decimal) ClearPrecision() {
|
||||
x.Precision = nil
|
||||
}
|
||||
|
||||
type Decimal_builder struct {
|
||||
_ [0]func() // Prevents comparability and use of unkeyed literals for the builder.
|
||||
|
||||
// Number in the smallest Token fractions.
|
||||
Value *int64
|
||||
// Precision value indicating how many smallest fractions can be in one
|
||||
// integer.
|
||||
Precision *uint32
|
||||
}
|
||||
|
||||
func (b0 Decimal_builder) Build() *Decimal {
|
||||
m0 := &Decimal{}
|
||||
b, x := &b0, m0
|
||||
_, _ = b, x
|
||||
x.Value = b.Value
|
||||
x.Precision = b.Precision
|
||||
return m0
|
||||
}
|
||||
|
||||
var File_api_accounting_grpc_types_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_api_accounting_grpc_types_proto_rawDesc = []byte{
|
||||
0x0a, 0x1f, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x69, 0x6e, 0x67,
|
||||
0x2f, 0x67, 0x72, 0x70, 0x63, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74,
|
||||
0x6f, 0x12, 0x14, 0x6e, 0x65, 0x6f, 0x2e, 0x66, 0x73, 0x2e, 0x76, 0x32, 0x2e, 0x61, 0x63, 0x63,
|
||||
0x6f, 0x75, 0x6e, 0x74, 0x69, 0x6e, 0x67, 0x22, 0x3d, 0x0a, 0x07, 0x44, 0x65, 0x63, 0x69, 0x6d,
|
||||
0x61, 0x6c, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28,
|
||||
0x03, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x70, 0x72, 0x65, 0x63,
|
||||
0x69, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x09, 0x70, 0x72, 0x65,
|
||||
0x63, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x42, 0x6e, 0x5a, 0x4b, 0x67, 0x69, 0x74, 0x2e, 0x66, 0x72,
|
||||
0x6f, 0x73, 0x74, 0x66, 0x73, 0x2e, 0x69, 0x6e, 0x66, 0x6f, 0x2f, 0x54, 0x72, 0x75, 0x65, 0x43,
|
||||
0x6c, 0x6f, 0x75, 0x64, 0x4c, 0x61, 0x62, 0x2f, 0x66, 0x72, 0x6f, 0x73, 0x74, 0x66, 0x73, 0x2d,
|
||||
0x73, 0x64, 0x6b, 0x2d, 0x67, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x63, 0x63, 0x6f, 0x75,
|
||||
0x6e, 0x74, 0x69, 0x6e, 0x67, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x3b, 0x61, 0x63, 0x63, 0x6f, 0x75,
|
||||
0x6e, 0x74, 0x69, 0x6e, 0x67, 0xaa, 0x02, 0x1e, 0x4e, 0x65, 0x6f, 0x2e, 0x46, 0x69, 0x6c, 0x65,
|
||||
0x53, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x2e, 0x41, 0x50, 0x49, 0x2e, 0x41, 0x63, 0x63, 0x6f,
|
||||
0x75, 0x6e, 0x74, 0x69, 0x6e, 0x67, 0x62, 0x08, 0x65, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73,
|
||||
0x70, 0xe8, 0x07,
|
||||
}
|
||||
|
||||
var file_api_accounting_grpc_types_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
|
||||
var file_api_accounting_grpc_types_proto_goTypes = []any{
|
||||
(*Decimal)(nil), // 0: neo.fs.v2.accounting.Decimal
|
||||
}
|
||||
var file_api_accounting_grpc_types_proto_depIdxs = []int32{
|
||||
0, // [0:0] is the sub-list for method output_type
|
||||
0, // [0:0] is the sub-list for method input_type
|
||||
0, // [0:0] is the sub-list for extension type_name
|
||||
0, // [0:0] is the sub-list for extension extendee
|
||||
0, // [0:0] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_api_accounting_grpc_types_proto_init() }
|
||||
func file_api_accounting_grpc_types_proto_init() {
|
||||
if File_api_accounting_grpc_types_proto != nil {
|
||||
return
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_api_accounting_grpc_types_proto_rawDesc,
|
||||
NumEnums: 0,
|
||||
NumMessages: 1,
|
||||
NumExtensions: 0,
|
||||
NumServices: 0,
|
||||
},
|
||||
GoTypes: file_api_accounting_grpc_types_proto_goTypes,
|
||||
DependencyIndexes: file_api_accounting_grpc_types_proto_depIdxs,
|
||||
MessageInfos: file_api_accounting_grpc_types_proto_msgTypes,
|
||||
}.Build()
|
||||
File_api_accounting_grpc_types_proto = out.File
|
||||
file_api_accounting_grpc_types_proto_rawDesc = nil
|
||||
file_api_accounting_grpc_types_proto_goTypes = nil
|
||||
file_api_accounting_grpc_types_proto_depIdxs = nil
|
||||
}
|
195
api/accounting/grpc/types_protoopaque.pb.go
generated
Normal file
195
api/accounting/grpc/types_protoopaque.pb.go
generated
Normal file
|
@ -0,0 +1,195 @@
|
|||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.36.1
|
||||
// protoc v5.29.2
|
||||
// source: api/accounting/grpc/types.proto
|
||||
|
||||
//go:build protoopaque
|
||||
|
||||
package accounting
|
||||
|
||||
import (
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
reflect "reflect"
|
||||
)
|
||||
|
||||
const (
|
||||
// Verify that this generated code is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
||||
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||
)
|
||||
|
||||
// Standard floating point data type can't be used in FrostFS due to inexactness
|
||||
// of the result when doing lots of small number operations. To solve the lost
|
||||
// precision issue, special `Decimal` format is used for monetary computations.
|
||||
//
|
||||
// Please see [The General Decimal Arithmetic
|
||||
// Specification](http://speleotrove.com/decimal/) for detailed problem
|
||||
// description.
|
||||
type Decimal struct {
|
||||
state protoimpl.MessageState `protogen:"opaque.v1"`
|
||||
xxx_hidden_Value int64 `protobuf:"varint,1,opt,name=value" json:"value,omitempty"`
|
||||
xxx_hidden_Precision uint32 `protobuf:"varint,2,opt,name=precision" json:"precision,omitempty"`
|
||||
XXX_raceDetectHookData protoimpl.RaceDetectHookData
|
||||
XXX_presence [1]uint32
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *Decimal) Reset() {
|
||||
*x = Decimal{}
|
||||
mi := &file_api_accounting_grpc_types_proto_msgTypes[0]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *Decimal) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*Decimal) ProtoMessage() {}
|
||||
|
||||
func (x *Decimal) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_accounting_grpc_types_proto_msgTypes[0]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
func (x *Decimal) GetValue() int64 {
|
||||
if x != nil {
|
||||
return x.xxx_hidden_Value
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *Decimal) GetPrecision() uint32 {
|
||||
if x != nil {
|
||||
return x.xxx_hidden_Precision
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *Decimal) SetValue(v int64) {
|
||||
x.xxx_hidden_Value = v
|
||||
protoimpl.X.SetPresent(&(x.XXX_presence[0]), 0, 2)
|
||||
}
|
||||
|
||||
func (x *Decimal) SetPrecision(v uint32) {
|
||||
x.xxx_hidden_Precision = v
|
||||
protoimpl.X.SetPresent(&(x.XXX_presence[0]), 1, 2)
|
||||
}
|
||||
|
||||
func (x *Decimal) HasValue() bool {
|
||||
if x == nil {
|
||||
return false
|
||||
}
|
||||
return protoimpl.X.Present(&(x.XXX_presence[0]), 0)
|
||||
}
|
||||
|
||||
func (x *Decimal) HasPrecision() bool {
|
||||
if x == nil {
|
||||
return false
|
||||
}
|
||||
return protoimpl.X.Present(&(x.XXX_presence[0]), 1)
|
||||
}
|
||||
|
||||
func (x *Decimal) ClearValue() {
|
||||
protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 0)
|
||||
x.xxx_hidden_Value = 0
|
||||
}
|
||||
|
||||
func (x *Decimal) ClearPrecision() {
|
||||
protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 1)
|
||||
x.xxx_hidden_Precision = 0
|
||||
}
|
||||
|
||||
type Decimal_builder struct {
|
||||
_ [0]func() // Prevents comparability and use of unkeyed literals for the builder.
|
||||
|
||||
// Number in the smallest Token fractions.
|
||||
Value *int64
|
||||
// Precision value indicating how many smallest fractions can be in one
|
||||
// integer.
|
||||
Precision *uint32
|
||||
}
|
||||
|
||||
func (b0 Decimal_builder) Build() *Decimal {
|
||||
m0 := &Decimal{}
|
||||
b, x := &b0, m0
|
||||
_, _ = b, x
|
||||
if b.Value != nil {
|
||||
protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 0, 2)
|
||||
x.xxx_hidden_Value = *b.Value
|
||||
}
|
||||
if b.Precision != nil {
|
||||
protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 1, 2)
|
||||
x.xxx_hidden_Precision = *b.Precision
|
||||
}
|
||||
return m0
|
||||
}
|
||||
|
||||
var File_api_accounting_grpc_types_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_api_accounting_grpc_types_proto_rawDesc = []byte{
|
||||
0x0a, 0x1f, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x69, 0x6e, 0x67,
|
||||
0x2f, 0x67, 0x72, 0x70, 0x63, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74,
|
||||
0x6f, 0x12, 0x14, 0x6e, 0x65, 0x6f, 0x2e, 0x66, 0x73, 0x2e, 0x76, 0x32, 0x2e, 0x61, 0x63, 0x63,
|
||||
0x6f, 0x75, 0x6e, 0x74, 0x69, 0x6e, 0x67, 0x22, 0x3d, 0x0a, 0x07, 0x44, 0x65, 0x63, 0x69, 0x6d,
|
||||
0x61, 0x6c, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28,
|
||||
0x03, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x70, 0x72, 0x65, 0x63,
|
||||
0x69, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x09, 0x70, 0x72, 0x65,
|
||||
0x63, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x42, 0x6e, 0x5a, 0x4b, 0x67, 0x69, 0x74, 0x2e, 0x66, 0x72,
|
||||
0x6f, 0x73, 0x74, 0x66, 0x73, 0x2e, 0x69, 0x6e, 0x66, 0x6f, 0x2f, 0x54, 0x72, 0x75, 0x65, 0x43,
|
||||
0x6c, 0x6f, 0x75, 0x64, 0x4c, 0x61, 0x62, 0x2f, 0x66, 0x72, 0x6f, 0x73, 0x74, 0x66, 0x73, 0x2d,
|
||||
0x73, 0x64, 0x6b, 0x2d, 0x67, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x63, 0x63, 0x6f, 0x75,
|
||||
0x6e, 0x74, 0x69, 0x6e, 0x67, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x3b, 0x61, 0x63, 0x63, 0x6f, 0x75,
|
||||
0x6e, 0x74, 0x69, 0x6e, 0x67, 0xaa, 0x02, 0x1e, 0x4e, 0x65, 0x6f, 0x2e, 0x46, 0x69, 0x6c, 0x65,
|
||||
0x53, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x2e, 0x41, 0x50, 0x49, 0x2e, 0x41, 0x63, 0x63, 0x6f,
|
||||
0x75, 0x6e, 0x74, 0x69, 0x6e, 0x67, 0x62, 0x08, 0x65, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73,
|
||||
0x70, 0xe8, 0x07,
|
||||
}
|
||||
|
||||
var file_api_accounting_grpc_types_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
|
||||
var file_api_accounting_grpc_types_proto_goTypes = []any{
|
||||
(*Decimal)(nil), // 0: neo.fs.v2.accounting.Decimal
|
||||
}
|
||||
var file_api_accounting_grpc_types_proto_depIdxs = []int32{
|
||||
0, // [0:0] is the sub-list for method output_type
|
||||
0, // [0:0] is the sub-list for method input_type
|
||||
0, // [0:0] is the sub-list for extension type_name
|
||||
0, // [0:0] is the sub-list for extension extendee
|
||||
0, // [0:0] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_api_accounting_grpc_types_proto_init() }
|
||||
func file_api_accounting_grpc_types_proto_init() {
|
||||
if File_api_accounting_grpc_types_proto != nil {
|
||||
return
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_api_accounting_grpc_types_proto_rawDesc,
|
||||
NumEnums: 0,
|
||||
NumMessages: 1,
|
||||
NumExtensions: 0,
|
||||
NumServices: 0,
|
||||
},
|
||||
GoTypes: file_api_accounting_grpc_types_proto_goTypes,
|
||||
DependencyIndexes: file_api_accounting_grpc_types_proto_depIdxs,
|
||||
MessageInfos: file_api_accounting_grpc_types_proto_msgTypes,
|
||||
}.Build()
|
||||
File_api_accounting_grpc_types_proto = out.File
|
||||
file_api_accounting_grpc_types_proto_rawDesc = nil
|
||||
file_api_accounting_grpc_types_proto_goTypes = nil
|
||||
file_api_accounting_grpc_types_proto_depIdxs = nil
|
||||
}
|
14
api/accounting/json.go
Normal file
14
api/accounting/json.go
Normal file
|
@ -0,0 +1,14 @@
|
|||
package accounting
|
||||
|
||||
import (
|
||||
accounting "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/accounting/grpc"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/rpc/message"
|
||||
)
|
||||
|
||||
func (d *Decimal) MarshalJSON() ([]byte, error) {
|
||||
return message.MarshalJSON(d)
|
||||
}
|
||||
|
||||
func (d *Decimal) UnmarshalJSON(data []byte) error {
|
||||
return message.UnmarshalJSON(d, data, new(accounting.Decimal))
|
||||
}
|
104
api/accounting/marshal.go
Normal file
104
api/accounting/marshal.go
Normal file
|
@ -0,0 +1,104 @@
|
|||
package accounting
|
||||
|
||||
import (
|
||||
accounting "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/accounting/grpc"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/rpc/message"
|
||||
protoutil "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/util/proto"
|
||||
)
|
||||
|
||||
const (
|
||||
decimalValueField = 1
|
||||
decimalPrecisionField = 2
|
||||
|
||||
balanceReqBodyOwnerField = 1
|
||||
|
||||
balanceRespBodyDecimalField = 1
|
||||
)
|
||||
|
||||
func (d *Decimal) StableMarshal(buf []byte) []byte {
|
||||
if d == nil {
|
||||
return []byte{}
|
||||
}
|
||||
|
||||
if buf == nil {
|
||||
buf = make([]byte, d.StableSize())
|
||||
}
|
||||
|
||||
var offset int
|
||||
|
||||
offset += protoutil.Int64Marshal(decimalValueField, buf[offset:], d.val)
|
||||
protoutil.UInt32Marshal(decimalPrecisionField, buf[offset:], d.prec)
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
func (d *Decimal) StableSize() (size int) {
|
||||
if d == nil {
|
||||
return 0
|
||||
}
|
||||
|
||||
size += protoutil.Int64Size(decimalValueField, d.val)
|
||||
size += protoutil.UInt32Size(decimalPrecisionField, d.prec)
|
||||
|
||||
return size
|
||||
}
|
||||
|
||||
func (d *Decimal) Unmarshal(data []byte) error {
|
||||
return message.Unmarshal(d, data, new(accounting.Decimal))
|
||||
}
|
||||
|
||||
func (b *BalanceRequestBody) StableMarshal(buf []byte) []byte {
|
||||
if b == nil {
|
||||
return []byte{}
|
||||
}
|
||||
|
||||
if buf == nil {
|
||||
buf = make([]byte, b.StableSize())
|
||||
}
|
||||
|
||||
protoutil.NestedStructureMarshal(balanceReqBodyOwnerField, buf, b.ownerID)
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
func (b *BalanceRequestBody) StableSize() (size int) {
|
||||
if b == nil {
|
||||
return 0
|
||||
}
|
||||
|
||||
size = protoutil.NestedStructureSize(balanceReqBodyOwnerField, b.ownerID)
|
||||
|
||||
return size
|
||||
}
|
||||
|
||||
func (b *BalanceRequestBody) Unmarshal(data []byte) error {
|
||||
return message.Unmarshal(b, data, new(accounting.BalanceRequest_Body))
|
||||
}
|
||||
|
||||
func (br *BalanceResponseBody) StableMarshal(buf []byte) []byte {
|
||||
if br == nil {
|
||||
return []byte{}
|
||||
}
|
||||
|
||||
if buf == nil {
|
||||
buf = make([]byte, br.StableSize())
|
||||
}
|
||||
|
||||
protoutil.NestedStructureMarshal(balanceRespBodyDecimalField, buf, br.bal)
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
func (br *BalanceResponseBody) StableSize() (size int) {
|
||||
if br == nil {
|
||||
return 0
|
||||
}
|
||||
|
||||
size = protoutil.NestedStructureSize(balanceRespBodyDecimalField, br.bal)
|
||||
|
||||
return size
|
||||
}
|
||||
|
||||
func (br *BalanceResponseBody) Unmarshal(data []byte) error {
|
||||
return message.Unmarshal(br, data, new(accounting.BalanceResponse_Body))
|
||||
}
|
19
api/accounting/message_test.go
Normal file
19
api/accounting/message_test.go
Normal file
|
@ -0,0 +1,19 @@
|
|||
package accounting_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
accountingtest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/accounting/test"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/rpc/message"
|
||||
messagetest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/rpc/message/test"
|
||||
)
|
||||
|
||||
func TestMessage(t *testing.T) {
|
||||
messagetest.TestRPCMessage(t,
|
||||
func(empty bool) message.Message { return accountingtest.GenerateDecimal(empty) },
|
||||
func(empty bool) message.Message { return accountingtest.GenerateBalanceRequestBody(empty) },
|
||||
func(empty bool) message.Message { return accountingtest.GenerateBalanceRequest(empty) },
|
||||
func(empty bool) message.Message { return accountingtest.GenerateBalanceResponseBody(empty) },
|
||||
func(empty bool) message.Message { return accountingtest.GenerateBalanceResponse(empty) },
|
||||
)
|
||||
}
|
64
api/accounting/test/generate.go
Normal file
64
api/accounting/test/generate.go
Normal file
|
@ -0,0 +1,64 @@
|
|||
package accountingtest
|
||||
|
||||
import (
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/accounting"
|
||||
accountingtest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/refs/test"
|
||||
sessiontest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/session/test"
|
||||
)
|
||||
|
||||
func GenerateBalanceRequest(empty bool) *accounting.BalanceRequest {
|
||||
m := new(accounting.BalanceRequest)
|
||||
|
||||
if !empty {
|
||||
m.SetBody(GenerateBalanceRequestBody(false))
|
||||
}
|
||||
|
||||
m.SetMetaHeader(sessiontest.GenerateRequestMetaHeader(empty))
|
||||
m.SetVerificationHeader(sessiontest.GenerateRequestVerificationHeader(empty))
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
func GenerateBalanceRequestBody(empty bool) *accounting.BalanceRequestBody {
|
||||
m := new(accounting.BalanceRequestBody)
|
||||
|
||||
if !empty {
|
||||
m.SetOwnerID(accountingtest.GenerateOwnerID(false))
|
||||
}
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
func GenerateBalanceResponse(empty bool) *accounting.BalanceResponse {
|
||||
m := new(accounting.BalanceResponse)
|
||||
|
||||
if !empty {
|
||||
m.SetBody(GenerateBalanceResponseBody(false))
|
||||
}
|
||||
|
||||
m.SetMetaHeader(sessiontest.GenerateResponseMetaHeader(empty))
|
||||
m.SetVerificationHeader(sessiontest.GenerateResponseVerificationHeader(empty))
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
func GenerateBalanceResponseBody(empty bool) *accounting.BalanceResponseBody {
|
||||
m := new(accounting.BalanceResponseBody)
|
||||
|
||||
if !empty {
|
||||
m.SetBalance(GenerateDecimal(false))
|
||||
}
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
func GenerateDecimal(empty bool) *accounting.Decimal {
|
||||
m := new(accounting.Decimal)
|
||||
|
||||
if !empty {
|
||||
m.SetValue(1)
|
||||
m.SetPrecision(2)
|
||||
}
|
||||
|
||||
return m
|
||||
}
|
51
api/acl/bench_test.go
Normal file
51
api/acl/bench_test.go
Normal file
|
@ -0,0 +1,51 @@
|
|||
package acl_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/acl"
|
||||
aclGrpc "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/acl/grpc"
|
||||
acltest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/acl/test"
|
||||
)
|
||||
|
||||
func BenchmarkTable_ToGRPCMessage(b *testing.B) {
|
||||
const size = 4
|
||||
|
||||
tb := new(acl.Table)
|
||||
rs := make([]acl.Record, size)
|
||||
for i := range rs {
|
||||
fs := make([]acl.HeaderFilter, size)
|
||||
for j := range fs {
|
||||
fs[j] = *acltest.GenerateFilter(false)
|
||||
}
|
||||
ts := make([]acl.Target, size)
|
||||
for j := range ts {
|
||||
ts[j] = *acltest.GenerateTarget(false)
|
||||
}
|
||||
|
||||
rs[i].SetFilters(fs)
|
||||
rs[i].SetTargets(ts)
|
||||
}
|
||||
tb.SetRecords(rs)
|
||||
|
||||
raw := tb.ToGRPCMessage()
|
||||
|
||||
b.Run("to grpc message", func(b *testing.B) {
|
||||
b.ReportAllocs()
|
||||
for range b.N {
|
||||
raw := tb.ToGRPCMessage()
|
||||
if len(tb.GetRecords()) != len(raw.(*aclGrpc.EACLTable).Records) {
|
||||
b.FailNow()
|
||||
}
|
||||
}
|
||||
})
|
||||
b.Run("from grpc message", func(b *testing.B) {
|
||||
b.ReportAllocs()
|
||||
for range b.N {
|
||||
tb := new(acl.Table)
|
||||
if tb.FromGRPCMessage(raw) != nil {
|
||||
b.FailNow()
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
592
api/acl/convert.go
Normal file
592
api/acl/convert.go
Normal file
|
@ -0,0 +1,592 @@
|
|||
package acl
|
||||
|
||||
import (
|
||||
acl "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/acl/grpc"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/ape"
|
||||
apeGRPC "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/ape/grpc"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/refs"
|
||||
refsGRPC "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/refs/grpc"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/rpc/grpc"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/rpc/message"
|
||||
)
|
||||
|
||||
// RoleToGRPCField converts unified role enum into grpc enum.
|
||||
func RoleToGRPCField(t Role) acl.Role {
|
||||
switch t {
|
||||
case RoleUser:
|
||||
return acl.Role_USER
|
||||
case RoleSystem:
|
||||
return acl.Role_SYSTEM
|
||||
case RoleOthers:
|
||||
return acl.Role_OTHERS
|
||||
default:
|
||||
return acl.Role_ROLE_UNSPECIFIED
|
||||
}
|
||||
}
|
||||
|
||||
// RoleFromGRPCField converts grpc enum into unified role enum.
|
||||
func RoleFromGRPCField(t acl.Role) Role {
|
||||
switch t {
|
||||
case acl.Role_USER:
|
||||
return RoleUser
|
||||
case acl.Role_SYSTEM:
|
||||
return RoleSystem
|
||||
case acl.Role_OTHERS:
|
||||
return RoleOthers
|
||||
default:
|
||||
return RoleUnknown
|
||||
}
|
||||
}
|
||||
|
||||
// OperationToGRPCField converts unified operation enum into grpc enum.
|
||||
func OperationToGRPCField(t Operation) acl.Operation {
|
||||
switch t {
|
||||
case OperationPut:
|
||||
return acl.Operation_PUT
|
||||
case OperationDelete:
|
||||
return acl.Operation_DELETE
|
||||
case OperationGet:
|
||||
return acl.Operation_GET
|
||||
case OperationHead:
|
||||
return acl.Operation_HEAD
|
||||
case OperationSearch:
|
||||
return acl.Operation_SEARCH
|
||||
case OperationRange:
|
||||
return acl.Operation_GETRANGE
|
||||
case OperationRangeHash:
|
||||
return acl.Operation_GETRANGEHASH
|
||||
default:
|
||||
return acl.Operation_OPERATION_UNSPECIFIED
|
||||
}
|
||||
}
|
||||
|
||||
// OperationFromGRPCField converts grpc enum into unified operation enum.
|
||||
func OperationFromGRPCField(t acl.Operation) Operation {
|
||||
switch t {
|
||||
case acl.Operation_PUT:
|
||||
return OperationPut
|
||||
case acl.Operation_DELETE:
|
||||
return OperationDelete
|
||||
case acl.Operation_GET:
|
||||
return OperationGet
|
||||
case acl.Operation_HEAD:
|
||||
return OperationHead
|
||||
case acl.Operation_SEARCH:
|
||||
return OperationSearch
|
||||
case acl.Operation_GETRANGE:
|
||||
return OperationRange
|
||||
case acl.Operation_GETRANGEHASH:
|
||||
return OperationRangeHash
|
||||
default:
|
||||
return OperationUnknown
|
||||
}
|
||||
}
|
||||
|
||||
// ActionToGRPCField converts unified action enum into grpc enum.
|
||||
func ActionToGRPCField(t Action) acl.Action {
|
||||
switch t {
|
||||
case ActionDeny:
|
||||
return acl.Action_DENY
|
||||
case ActionAllow:
|
||||
return acl.Action_ALLOW
|
||||
default:
|
||||
return acl.Action_ACTION_UNSPECIFIED
|
||||
}
|
||||
}
|
||||
|
||||
// ActionFromGRPCField converts grpc enum into unified action enum.
|
||||
func ActionFromGRPCField(t acl.Action) Action {
|
||||
switch t {
|
||||
case acl.Action_DENY:
|
||||
return ActionDeny
|
||||
case acl.Action_ALLOW:
|
||||
return ActionAllow
|
||||
default:
|
||||
return ActionUnknown
|
||||
}
|
||||
}
|
||||
|
||||
// HeaderTypeToGRPCField converts unified header type enum into grpc enum.
|
||||
func HeaderTypeToGRPCField(t HeaderType) acl.HeaderType {
|
||||
switch t {
|
||||
case HeaderTypeRequest:
|
||||
return acl.HeaderType_REQUEST
|
||||
case HeaderTypeObject:
|
||||
return acl.HeaderType_OBJECT
|
||||
case HeaderTypeService:
|
||||
return acl.HeaderType_SERVICE
|
||||
default:
|
||||
return acl.HeaderType_HEADER_UNSPECIFIED
|
||||
}
|
||||
}
|
||||
|
||||
// HeaderTypeFromGRPCField converts grpc enum into unified header type enum.
|
||||
func HeaderTypeFromGRPCField(t acl.HeaderType) HeaderType {
|
||||
switch t {
|
||||
case acl.HeaderType_REQUEST:
|
||||
return HeaderTypeRequest
|
||||
case acl.HeaderType_OBJECT:
|
||||
return HeaderTypeObject
|
||||
case acl.HeaderType_SERVICE:
|
||||
return HeaderTypeService
|
||||
default:
|
||||
return HeaderTypeUnknown
|
||||
}
|
||||
}
|
||||
|
||||
// MatchTypeToGRPCField converts unified match type enum into grpc enum.
|
||||
func MatchTypeToGRPCField(t MatchType) acl.MatchType {
|
||||
switch t {
|
||||
case MatchTypeStringEqual:
|
||||
return acl.MatchType_STRING_EQUAL
|
||||
case MatchTypeStringNotEqual:
|
||||
return acl.MatchType_STRING_NOT_EQUAL
|
||||
default:
|
||||
return acl.MatchType_MATCH_TYPE_UNSPECIFIED
|
||||
}
|
||||
}
|
||||
|
||||
// MatchTypeFromGRPCField converts grpc enum into unified match type enum.
|
||||
func MatchTypeFromGRPCField(t acl.MatchType) MatchType {
|
||||
switch t {
|
||||
case acl.MatchType_STRING_EQUAL:
|
||||
return MatchTypeStringEqual
|
||||
case acl.MatchType_STRING_NOT_EQUAL:
|
||||
return MatchTypeStringNotEqual
|
||||
default:
|
||||
return MatchTypeUnknown
|
||||
}
|
||||
}
|
||||
|
||||
func (f *HeaderFilter) ToGRPCMessage() grpc.Message {
|
||||
var m *acl.EACLRecord_Filter
|
||||
|
||||
if f != nil {
|
||||
m = new(acl.EACLRecord_Filter)
|
||||
|
||||
m.SetKey(f.key)
|
||||
m.SetValue(f.value)
|
||||
m.SetHeaderType(HeaderTypeToGRPCField(f.hdrType))
|
||||
m.SetMatchType(MatchTypeToGRPCField(f.matchType))
|
||||
}
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
func (f *HeaderFilter) FromGRPCMessage(m grpc.Message) error {
|
||||
v, ok := m.(*acl.EACLRecord_Filter)
|
||||
if !ok {
|
||||
return message.NewUnexpectedMessageType(m, v)
|
||||
}
|
||||
|
||||
f.key = v.GetKey()
|
||||
f.value = v.GetValue()
|
||||
f.hdrType = HeaderTypeFromGRPCField(v.GetHeaderType())
|
||||
f.matchType = MatchTypeFromGRPCField(v.GetMatchType())
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func HeaderFiltersToGRPC(fs []HeaderFilter) (res []*acl.EACLRecord_Filter) {
|
||||
if fs != nil {
|
||||
res = make([]*acl.EACLRecord_Filter, 0, len(fs))
|
||||
|
||||
for i := range fs {
|
||||
res = append(res, fs[i].ToGRPCMessage().(*acl.EACLRecord_Filter))
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func HeaderFiltersFromGRPC(fs []*acl.EACLRecord_Filter) (res []HeaderFilter, err error) {
|
||||
if fs != nil {
|
||||
res = make([]HeaderFilter, len(fs))
|
||||
|
||||
for i := range fs {
|
||||
err = res[i].FromGRPCMessage(fs[i])
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func (t *Target) ToGRPCMessage() grpc.Message {
|
||||
var m *acl.EACLRecord_Target
|
||||
|
||||
if t != nil {
|
||||
m = new(acl.EACLRecord_Target)
|
||||
|
||||
m.SetRole(RoleToGRPCField(t.role))
|
||||
m.SetKeys(t.keys)
|
||||
}
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
func (t *Target) FromGRPCMessage(m grpc.Message) error {
|
||||
v, ok := m.(*acl.EACLRecord_Target)
|
||||
if !ok {
|
||||
return message.NewUnexpectedMessageType(m, v)
|
||||
}
|
||||
|
||||
t.role = RoleFromGRPCField(v.GetRole())
|
||||
t.keys = v.GetKeys()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func TargetsToGRPC(ts []Target) (res []*acl.EACLRecord_Target) {
|
||||
if ts != nil {
|
||||
res = make([]*acl.EACLRecord_Target, 0, len(ts))
|
||||
|
||||
for i := range ts {
|
||||
res = append(res, ts[i].ToGRPCMessage().(*acl.EACLRecord_Target))
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func TargetsFromGRPC(fs []*acl.EACLRecord_Target) (res []Target, err error) {
|
||||
if fs != nil {
|
||||
res = make([]Target, len(fs))
|
||||
|
||||
for i := range fs {
|
||||
err = res[i].FromGRPCMessage(fs[i])
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func (r *Record) ToGRPCMessage() grpc.Message {
|
||||
var m *acl.EACLRecord
|
||||
|
||||
if r != nil {
|
||||
m = new(acl.EACLRecord)
|
||||
|
||||
m.SetOperation(OperationToGRPCField(r.op))
|
||||
m.SetAction(ActionToGRPCField(r.action))
|
||||
m.SetFilters(HeaderFiltersToGRPC(r.filters))
|
||||
m.SetTargets(TargetsToGRPC(r.targets))
|
||||
}
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
func (r *Record) FromGRPCMessage(m grpc.Message) error {
|
||||
v, ok := m.(*acl.EACLRecord)
|
||||
if !ok {
|
||||
return message.NewUnexpectedMessageType(m, v)
|
||||
}
|
||||
|
||||
var err error
|
||||
|
||||
r.filters, err = HeaderFiltersFromGRPC(v.GetFilters())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
r.targets, err = TargetsFromGRPC(v.GetTargets())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
r.op = OperationFromGRPCField(v.GetOperation())
|
||||
r.action = ActionFromGRPCField(v.GetAction())
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func RecordsToGRPC(ts []Record) (res []*acl.EACLRecord) {
|
||||
if ts != nil {
|
||||
res = make([]*acl.EACLRecord, 0, len(ts))
|
||||
|
||||
for i := range ts {
|
||||
res = append(res, ts[i].ToGRPCMessage().(*acl.EACLRecord))
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func RecordsFromGRPC(fs []*acl.EACLRecord) (res []Record, err error) {
|
||||
if fs != nil {
|
||||
res = make([]Record, len(fs))
|
||||
|
||||
for i := range fs {
|
||||
err = res[i].FromGRPCMessage(fs[i])
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func (t *Table) ToGRPCMessage() grpc.Message {
|
||||
var m *acl.EACLTable
|
||||
|
||||
if t != nil {
|
||||
m = new(acl.EACLTable)
|
||||
|
||||
m.SetVersion(t.version.ToGRPCMessage().(*refsGRPC.Version))
|
||||
m.SetContainerId(t.cid.ToGRPCMessage().(*refsGRPC.ContainerID))
|
||||
m.SetRecords(RecordsToGRPC(t.records))
|
||||
}
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
func (t *Table) FromGRPCMessage(m grpc.Message) error {
|
||||
v, ok := m.(*acl.EACLTable)
|
||||
if !ok {
|
||||
return message.NewUnexpectedMessageType(m, v)
|
||||
}
|
||||
|
||||
var err error
|
||||
|
||||
cid := v.GetContainerId()
|
||||
if cid == nil {
|
||||
t.cid = nil
|
||||
} else {
|
||||
if t.cid == nil {
|
||||
t.cid = new(refs.ContainerID)
|
||||
}
|
||||
|
||||
err = t.cid.FromGRPCMessage(cid)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
version := v.GetVersion()
|
||||
if version == nil {
|
||||
t.version = nil
|
||||
} else {
|
||||
if t.version == nil {
|
||||
t.version = new(refs.Version)
|
||||
}
|
||||
|
||||
err = t.version.FromGRPCMessage(version)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
t.records, err = RecordsFromGRPC(v.GetRecords())
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
func (l *TokenLifetime) ToGRPCMessage() grpc.Message {
|
||||
var m *acl.BearerToken_Body_TokenLifetime
|
||||
|
||||
if l != nil {
|
||||
m = new(acl.BearerToken_Body_TokenLifetime)
|
||||
|
||||
m.SetExp(l.exp)
|
||||
m.SetIat(l.iat)
|
||||
m.SetNbf(l.nbf)
|
||||
}
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
func (l *TokenLifetime) FromGRPCMessage(m grpc.Message) error {
|
||||
v, ok := m.(*acl.BearerToken_Body_TokenLifetime)
|
||||
if !ok {
|
||||
return message.NewUnexpectedMessageType(m, v)
|
||||
}
|
||||
|
||||
l.exp = v.GetExp()
|
||||
l.iat = v.GetIat()
|
||||
l.nbf = v.GetNbf()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *APEOverride) ToGRPCMessage() grpc.Message {
|
||||
var m *acl.BearerToken_Body_APEOverride
|
||||
|
||||
if c != nil {
|
||||
m = new(acl.BearerToken_Body_APEOverride)
|
||||
|
||||
m.SetTarget(c.target.ToGRPCMessage().(*apeGRPC.ChainTarget))
|
||||
|
||||
if len(c.chains) > 0 {
|
||||
apeChains := make([]*apeGRPC.Chain, len(c.chains))
|
||||
for i := range c.chains {
|
||||
apeChains[i] = c.chains[i].ToGRPCMessage().(*apeGRPC.Chain)
|
||||
}
|
||||
m.SetChains(apeChains)
|
||||
}
|
||||
}
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
func (c *APEOverride) FromGRPCMessage(m grpc.Message) error {
|
||||
v, ok := m.(*acl.BearerToken_Body_APEOverride)
|
||||
if !ok {
|
||||
return message.NewUnexpectedMessageType(m, v)
|
||||
}
|
||||
|
||||
if targetGRPC := v.GetTarget(); targetGRPC != nil {
|
||||
if c.target == nil {
|
||||
c.target = new(ape.ChainTarget)
|
||||
}
|
||||
if err := c.target.FromGRPCMessage(v.GetTarget()); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if apeChains := v.GetChains(); len(apeChains) > 0 {
|
||||
c.chains = make([]*ape.Chain, len(apeChains))
|
||||
for i := range apeChains {
|
||||
c.chains[i] = new(ape.Chain)
|
||||
if err := c.chains[i].FromGRPCMessage(apeChains[i]); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (bt *BearerTokenBody) ToGRPCMessage() grpc.Message {
|
||||
var m *acl.BearerToken_Body
|
||||
|
||||
if bt != nil {
|
||||
m = new(acl.BearerToken_Body)
|
||||
|
||||
m.SetOwnerId(bt.ownerID.ToGRPCMessage().(*refsGRPC.OwnerID))
|
||||
m.SetLifetime(bt.lifetime.ToGRPCMessage().(*acl.BearerToken_Body_TokenLifetime))
|
||||
m.SetEaclTable(bt.eacl.ToGRPCMessage().(*acl.EACLTable))
|
||||
m.SetAllowImpersonate(bt.impersonate)
|
||||
m.SetApeOverride(bt.apeOverride.ToGRPCMessage().(*acl.BearerToken_Body_APEOverride))
|
||||
}
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
func (bt *BearerTokenBody) FromGRPCMessage(m grpc.Message) error {
|
||||
v, ok := m.(*acl.BearerToken_Body)
|
||||
if !ok {
|
||||
return message.NewUnexpectedMessageType(m, v)
|
||||
}
|
||||
|
||||
var err error
|
||||
|
||||
ownerID := v.GetOwnerId()
|
||||
if ownerID == nil {
|
||||
bt.ownerID = nil
|
||||
} else {
|
||||
if bt.ownerID == nil {
|
||||
bt.ownerID = new(refs.OwnerID)
|
||||
}
|
||||
|
||||
err = bt.ownerID.FromGRPCMessage(ownerID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
lifetime := v.GetLifetime()
|
||||
if lifetime == nil {
|
||||
bt.lifetime = nil
|
||||
} else {
|
||||
if bt.lifetime == nil {
|
||||
bt.lifetime = new(TokenLifetime)
|
||||
}
|
||||
|
||||
err = bt.lifetime.FromGRPCMessage(lifetime)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
eacl := v.GetEaclTable()
|
||||
if eacl == nil {
|
||||
bt.eacl = nil
|
||||
} else {
|
||||
if bt.eacl == nil {
|
||||
bt.eacl = new(Table)
|
||||
}
|
||||
|
||||
if err = bt.eacl.FromGRPCMessage(eacl); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if apeOverrideGRPC := v.GetApeOverride(); apeOverrideGRPC != nil {
|
||||
if bt.apeOverride == nil {
|
||||
bt.apeOverride = new(APEOverride)
|
||||
}
|
||||
err = bt.apeOverride.FromGRPCMessage(apeOverrideGRPC)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
bt.impersonate = v.GetAllowImpersonate()
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
func (bt *BearerToken) ToGRPCMessage() grpc.Message {
|
||||
var m *acl.BearerToken
|
||||
|
||||
if bt != nil {
|
||||
m = new(acl.BearerToken)
|
||||
|
||||
m.SetBody(bt.body.ToGRPCMessage().(*acl.BearerToken_Body))
|
||||
m.SetSignature(bt.sig.ToGRPCMessage().(*refsGRPC.Signature))
|
||||
}
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
func (bt *BearerToken) FromGRPCMessage(m grpc.Message) error {
|
||||
v, ok := m.(*acl.BearerToken)
|
||||
if !ok {
|
||||
return message.NewUnexpectedMessageType(m, v)
|
||||
}
|
||||
|
||||
var err error
|
||||
|
||||
body := v.GetBody()
|
||||
if body == nil {
|
||||
bt.body = nil
|
||||
} else {
|
||||
if bt.body == nil {
|
||||
bt.body = new(BearerTokenBody)
|
||||
}
|
||||
|
||||
err = bt.body.FromGRPCMessage(body)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
sig := v.GetSignature()
|
||||
if sig == nil {
|
||||
bt.sig = nil
|
||||
} else {
|
||||
if bt.sig == nil {
|
||||
bt.sig = new(refs.Signature)
|
||||
}
|
||||
|
||||
err = bt.sig.FromGRPCMessage(sig)
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
33
api/acl/filters.go
Normal file
33
api/acl/filters.go
Normal file
|
@ -0,0 +1,33 @@
|
|||
package acl
|
||||
|
||||
// ObjectFilterPrefix is a prefix of key to object header value or property.
|
||||
const ObjectFilterPrefix = "$Object:"
|
||||
|
||||
const (
|
||||
// FilterObjectVersion is a filter key to "version" field of the object header.
|
||||
FilterObjectVersion = ObjectFilterPrefix + "version"
|
||||
|
||||
// FilterObjectID is a filter key to "object_id" field of the object.
|
||||
FilterObjectID = ObjectFilterPrefix + "objectID"
|
||||
|
||||
// FilterObjectContainerID is a filter key to "container_id" field of the object header.
|
||||
FilterObjectContainerID = ObjectFilterPrefix + "containerID"
|
||||
|
||||
// FilterObjectOwnerID is a filter key to "owner_id" field of the object header.
|
||||
FilterObjectOwnerID = ObjectFilterPrefix + "ownerID"
|
||||
|
||||
// FilterObjectCreationEpoch is a filter key to "creation_epoch" field of the object header.
|
||||
FilterObjectCreationEpoch = ObjectFilterPrefix + "creationEpoch"
|
||||
|
||||
// FilterObjectPayloadLength is a filter key to "payload_length" field of the object header.
|
||||
FilterObjectPayloadLength = ObjectFilterPrefix + "payloadLength"
|
||||
|
||||
// FilterObjectPayloadHash is a filter key to "payload_hash" field of the object header.
|
||||
FilterObjectPayloadHash = ObjectFilterPrefix + "payloadHash"
|
||||
|
||||
// FilterObjectType is a filter key to "object_type" field of the object header.
|
||||
FilterObjectType = ObjectFilterPrefix + "objectType"
|
||||
|
||||
// FilterObjectHomomorphicHash is a filter key to "homomorphic_hash" field of the object header.
|
||||
FilterObjectHomomorphicHash = ObjectFilterPrefix + "homomorphicHash"
|
||||
)
|
1534
api/acl/grpc/types.pb.go
generated
Normal file
1534
api/acl/grpc/types.pb.go
generated
Normal file
File diff suppressed because it is too large
Load diff
1589
api/acl/grpc/types_protoopaque.pb.go
generated
Normal file
1589
api/acl/grpc/types_protoopaque.pb.go
generated
Normal file
File diff suppressed because it is too large
Load diff
70
api/acl/json.go
Normal file
70
api/acl/json.go
Normal file
|
@ -0,0 +1,70 @@
|
|||
package acl
|
||||
|
||||
import (
|
||||
acl "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/acl/grpc"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/rpc/message"
|
||||
)
|
||||
|
||||
func (f *HeaderFilter) MarshalJSON() ([]byte, error) {
|
||||
return message.MarshalJSON(f)
|
||||
}
|
||||
|
||||
func (f *HeaderFilter) UnmarshalJSON(data []byte) error {
|
||||
return message.UnmarshalJSON(f, data, new(acl.EACLRecord_Filter))
|
||||
}
|
||||
|
||||
func (t *Target) MarshalJSON() ([]byte, error) {
|
||||
return message.MarshalJSON(t)
|
||||
}
|
||||
|
||||
func (t *Target) UnmarshalJSON(data []byte) error {
|
||||
return message.UnmarshalJSON(t, data, new(acl.EACLRecord_Target))
|
||||
}
|
||||
|
||||
func (a *APEOverride) MarshalJSON() ([]byte, error) {
|
||||
return message.MarshalJSON(a)
|
||||
}
|
||||
|
||||
func (a *APEOverride) UnmarshalJSON(data []byte) error {
|
||||
return message.UnmarshalJSON(a, data, new(acl.BearerToken_Body_APEOverride))
|
||||
}
|
||||
|
||||
func (r *Record) MarshalJSON() ([]byte, error) {
|
||||
return message.MarshalJSON(r)
|
||||
}
|
||||
|
||||
func (r *Record) UnmarshalJSON(data []byte) error {
|
||||
return message.UnmarshalJSON(r, data, new(acl.EACLRecord))
|
||||
}
|
||||
|
||||
func (t *Table) MarshalJSON() ([]byte, error) {
|
||||
return message.MarshalJSON(t)
|
||||
}
|
||||
|
||||
func (t *Table) UnmarshalJSON(data []byte) error {
|
||||
return message.UnmarshalJSON(t, data, new(acl.EACLTable))
|
||||
}
|
||||
|
||||
func (l *TokenLifetime) MarshalJSON() ([]byte, error) {
|
||||
return message.MarshalJSON(l)
|
||||
}
|
||||
|
||||
func (l *TokenLifetime) UnmarshalJSON(data []byte) error {
|
||||
return message.UnmarshalJSON(l, data, new(acl.BearerToken_Body_TokenLifetime))
|
||||
}
|
||||
|
||||
func (bt *BearerTokenBody) MarshalJSON() ([]byte, error) {
|
||||
return message.MarshalJSON(bt)
|
||||
}
|
||||
|
||||
func (bt *BearerTokenBody) UnmarshalJSON(data []byte) error {
|
||||
return message.UnmarshalJSON(bt, data, new(acl.BearerToken_Body))
|
||||
}
|
||||
|
||||
func (bt *BearerToken) MarshalJSON() ([]byte, error) {
|
||||
return message.MarshalJSON(bt)
|
||||
}
|
||||
|
||||
func (bt *BearerToken) UnmarshalJSON(data []byte) error {
|
||||
return message.UnmarshalJSON(bt, data, new(acl.BearerToken))
|
||||
}
|
350
api/acl/marshal.go
Normal file
350
api/acl/marshal.go
Normal file
|
@ -0,0 +1,350 @@
|
|||
package acl
|
||||
|
||||
import (
|
||||
acl "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/acl/grpc"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/rpc/message"
|
||||
protoutil "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/util/proto"
|
||||
)
|
||||
|
||||
const (
|
||||
filterHeaderTypeField = 1
|
||||
filterMatchTypeField = 2
|
||||
filterNameField = 3
|
||||
filterValueField = 4
|
||||
|
||||
targetTypeField = 1
|
||||
targetKeysField = 2
|
||||
|
||||
recordOperationField = 1
|
||||
recordActionField = 2
|
||||
recordFiltersField = 3
|
||||
recordTargetsField = 4
|
||||
|
||||
tableVersionField = 1
|
||||
tableContainerIDField = 2
|
||||
tableRecordsField = 3
|
||||
|
||||
lifetimeExpirationField = 1
|
||||
lifetimeNotValidBeforeField = 2
|
||||
lifetimeIssuedAtField = 3
|
||||
|
||||
tokenAPEChainsTargetField = 1
|
||||
tokenAPEChainsChainsField = 2
|
||||
|
||||
bearerTokenBodyACLField = 1
|
||||
bearerTokenBodyOwnerField = 2
|
||||
bearerTokenBodyLifetimeField = 3
|
||||
bearerTokenBodyImpersonate = 4
|
||||
bearerTokenTokenAPEChainsField = 5
|
||||
|
||||
bearerTokenBodyField = 1
|
||||
bearerTokenSignatureField = 2
|
||||
)
|
||||
|
||||
// StableMarshal marshals unified acl table structure in a protobuf
|
||||
// compatible way without field order shuffle.
|
||||
func (t *Table) StableMarshal(buf []byte) []byte {
|
||||
if t == nil {
|
||||
return []byte{}
|
||||
}
|
||||
|
||||
if buf == nil {
|
||||
buf = make([]byte, t.StableSize())
|
||||
}
|
||||
|
||||
var offset int
|
||||
|
||||
offset += protoutil.NestedStructureMarshal(tableVersionField, buf[offset:], t.version)
|
||||
offset += protoutil.NestedStructureMarshal(tableContainerIDField, buf[offset:], t.cid)
|
||||
|
||||
for i := range t.records {
|
||||
offset += protoutil.NestedStructureMarshal(tableRecordsField, buf[offset:], &t.records[i])
|
||||
}
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// StableSize of acl table structure marshalled by StableMarshal function.
|
||||
func (t *Table) StableSize() (size int) {
|
||||
if t == nil {
|
||||
return 0
|
||||
}
|
||||
|
||||
size += protoutil.NestedStructureSize(tableVersionField, t.version)
|
||||
size += protoutil.NestedStructureSize(tableContainerIDField, t.cid)
|
||||
|
||||
for i := range t.records {
|
||||
size += protoutil.NestedStructureSize(tableRecordsField, &t.records[i])
|
||||
}
|
||||
|
||||
return size
|
||||
}
|
||||
|
||||
func (t *Table) Unmarshal(data []byte) error {
|
||||
return message.Unmarshal(t, data, new(acl.EACLTable))
|
||||
}
|
||||
|
||||
// StableMarshal marshals unified acl record structure in a protobuf
|
||||
// compatible way without field order shuffle.
|
||||
func (r *Record) StableMarshal(buf []byte) []byte {
|
||||
if r == nil {
|
||||
return []byte{}
|
||||
}
|
||||
|
||||
if buf == nil {
|
||||
buf = make([]byte, r.StableSize())
|
||||
}
|
||||
|
||||
var offset int
|
||||
|
||||
offset += protoutil.EnumMarshal(recordOperationField, buf[offset:], int32(r.op))
|
||||
offset += protoutil.EnumMarshal(recordActionField, buf[offset:], int32(r.action))
|
||||
|
||||
for i := range r.filters {
|
||||
offset += protoutil.NestedStructureMarshal(recordFiltersField, buf[offset:], &r.filters[i])
|
||||
}
|
||||
|
||||
for i := range r.targets {
|
||||
offset += protoutil.NestedStructureMarshal(recordTargetsField, buf[offset:], &r.targets[i])
|
||||
}
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// StableSize of acl record structure marshalled by StableMarshal function.
|
||||
func (r *Record) StableSize() (size int) {
|
||||
if r == nil {
|
||||
return 0
|
||||
}
|
||||
|
||||
size += protoutil.EnumSize(recordOperationField, int32(r.op))
|
||||
size += protoutil.EnumSize(recordActionField, int32(r.action))
|
||||
|
||||
for i := range r.filters {
|
||||
size += protoutil.NestedStructureSize(recordFiltersField, &r.filters[i])
|
||||
}
|
||||
|
||||
for i := range r.targets {
|
||||
size += protoutil.NestedStructureSize(recordTargetsField, &r.targets[i])
|
||||
}
|
||||
|
||||
return size
|
||||
}
|
||||
|
||||
func (r *Record) Unmarshal(data []byte) error {
|
||||
return message.Unmarshal(r, data, new(acl.EACLRecord))
|
||||
}
|
||||
|
||||
// StableMarshal marshals unified header filter structure in a protobuf
|
||||
// compatible way without field order shuffle.
|
||||
func (f *HeaderFilter) StableMarshal(buf []byte) []byte {
|
||||
if f == nil {
|
||||
return []byte{}
|
||||
}
|
||||
|
||||
if buf == nil {
|
||||
buf = make([]byte, f.StableSize())
|
||||
}
|
||||
|
||||
var offset int
|
||||
|
||||
offset += protoutil.EnumMarshal(filterHeaderTypeField, buf[offset:], int32(f.hdrType))
|
||||
offset += protoutil.EnumMarshal(filterMatchTypeField, buf[offset:], int32(f.matchType))
|
||||
offset += protoutil.StringMarshal(filterNameField, buf[offset:], f.key)
|
||||
protoutil.StringMarshal(filterValueField, buf[offset:], f.value)
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// StableSize of header filter structure marshalled by StableMarshal function.
|
||||
func (f *HeaderFilter) StableSize() (size int) {
|
||||
if f == nil {
|
||||
return 0
|
||||
}
|
||||
|
||||
size += protoutil.EnumSize(filterHeaderTypeField, int32(f.hdrType))
|
||||
size += protoutil.EnumSize(filterMatchTypeField, int32(f.matchType))
|
||||
size += protoutil.StringSize(filterNameField, f.key)
|
||||
size += protoutil.StringSize(filterValueField, f.value)
|
||||
|
||||
return size
|
||||
}
|
||||
|
||||
func (f *HeaderFilter) Unmarshal(data []byte) error {
|
||||
return message.Unmarshal(f, data, new(acl.EACLRecord_Filter))
|
||||
}
|
||||
|
||||
// StableMarshal marshals unified role info structure in a protobuf
|
||||
// compatible way without field order shuffle.
|
||||
func (t *Target) StableMarshal(buf []byte) []byte {
|
||||
if t == nil {
|
||||
return []byte{}
|
||||
}
|
||||
|
||||
if buf == nil {
|
||||
buf = make([]byte, t.StableSize())
|
||||
}
|
||||
|
||||
var offset int
|
||||
|
||||
offset += protoutil.EnumMarshal(targetTypeField, buf[offset:], int32(t.role))
|
||||
protoutil.RepeatedBytesMarshal(targetKeysField, buf[offset:], t.keys)
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// StableSize of role info structure marshalled by StableMarshal function.
|
||||
func (t *Target) StableSize() (size int) {
|
||||
if t == nil {
|
||||
return 0
|
||||
}
|
||||
|
||||
size += protoutil.EnumSize(targetTypeField, int32(t.role))
|
||||
size += protoutil.RepeatedBytesSize(targetKeysField, t.keys)
|
||||
|
||||
return size
|
||||
}
|
||||
|
||||
func (t *Target) Unmarshal(data []byte) error {
|
||||
return message.Unmarshal(t, data, new(acl.EACLRecord_Target))
|
||||
}
|
||||
|
||||
func (l *TokenLifetime) StableMarshal(buf []byte) []byte {
|
||||
if l == nil {
|
||||
return []byte{}
|
||||
}
|
||||
|
||||
if buf == nil {
|
||||
buf = make([]byte, l.StableSize())
|
||||
}
|
||||
|
||||
var offset int
|
||||
|
||||
offset += protoutil.UInt64Marshal(lifetimeExpirationField, buf[offset:], l.exp)
|
||||
offset += protoutil.UInt64Marshal(lifetimeNotValidBeforeField, buf[offset:], l.nbf)
|
||||
protoutil.UInt64Marshal(lifetimeIssuedAtField, buf[offset:], l.iat)
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
func (l *TokenLifetime) StableSize() (size int) {
|
||||
if l == nil {
|
||||
return 0
|
||||
}
|
||||
|
||||
size += protoutil.UInt64Size(lifetimeExpirationField, l.exp)
|
||||
size += protoutil.UInt64Size(lifetimeNotValidBeforeField, l.nbf)
|
||||
size += protoutil.UInt64Size(lifetimeIssuedAtField, l.iat)
|
||||
|
||||
return size
|
||||
}
|
||||
|
||||
func (l *TokenLifetime) Unmarshal(data []byte) error {
|
||||
return message.Unmarshal(l, data, new(acl.BearerToken_Body_TokenLifetime))
|
||||
}
|
||||
|
||||
func (c *APEOverride) StableMarshal(buf []byte) []byte {
|
||||
if c == nil {
|
||||
return []byte{}
|
||||
}
|
||||
|
||||
if buf == nil {
|
||||
buf = make([]byte, c.StableSize())
|
||||
}
|
||||
|
||||
var offset int
|
||||
|
||||
offset += protoutil.NestedStructureMarshal(tokenAPEChainsTargetField, buf[offset:], c.target)
|
||||
for i := range c.chains {
|
||||
offset += protoutil.NestedStructureMarshal(tokenAPEChainsChainsField, buf[offset:], c.chains[i])
|
||||
}
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
func (c *APEOverride) StableSize() (size int) {
|
||||
if c == nil {
|
||||
return 0
|
||||
}
|
||||
|
||||
size += protoutil.NestedStructureSize(tokenAPEChainsTargetField, c.target)
|
||||
for i := range c.chains {
|
||||
size += protoutil.NestedStructureSize(tokenAPEChainsChainsField, c.chains[i])
|
||||
}
|
||||
|
||||
return size
|
||||
}
|
||||
|
||||
func (c *APEOverride) Unmarshal(data []byte) error {
|
||||
return message.Unmarshal(c, data, new(acl.BearerToken_Body_APEOverride))
|
||||
}
|
||||
|
||||
func (bt *BearerTokenBody) StableMarshal(buf []byte) []byte {
|
||||
if bt == nil {
|
||||
return []byte{}
|
||||
}
|
||||
|
||||
if buf == nil {
|
||||
buf = make([]byte, bt.StableSize())
|
||||
}
|
||||
|
||||
var offset int
|
||||
|
||||
offset += protoutil.NestedStructureMarshal(bearerTokenBodyACLField, buf[offset:], bt.eacl)
|
||||
offset += protoutil.NestedStructureMarshal(bearerTokenBodyOwnerField, buf[offset:], bt.ownerID)
|
||||
offset += protoutil.NestedStructureMarshal(bearerTokenBodyLifetimeField, buf[offset:], bt.lifetime)
|
||||
offset += protoutil.BoolMarshal(bearerTokenBodyImpersonate, buf[offset:], bt.impersonate)
|
||||
protoutil.NestedStructureMarshal(bearerTokenTokenAPEChainsField, buf[offset:], bt.apeOverride)
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
func (bt *BearerTokenBody) StableSize() (size int) {
|
||||
if bt == nil {
|
||||
return 0
|
||||
}
|
||||
|
||||
size += protoutil.NestedStructureSize(bearerTokenBodyACLField, bt.eacl)
|
||||
size += protoutil.NestedStructureSize(bearerTokenBodyOwnerField, bt.ownerID)
|
||||
size += protoutil.NestedStructureSize(bearerTokenBodyLifetimeField, bt.lifetime)
|
||||
size += protoutil.BoolSize(bearerTokenBodyImpersonate, bt.impersonate)
|
||||
size += protoutil.NestedStructureSize(bearerTokenTokenAPEChainsField, bt.apeOverride)
|
||||
|
||||
return size
|
||||
}
|
||||
|
||||
func (bt *BearerTokenBody) Unmarshal(data []byte) error {
|
||||
return message.Unmarshal(bt, data, new(acl.BearerToken_Body))
|
||||
}
|
||||
|
||||
func (bt *BearerToken) StableMarshal(buf []byte) []byte {
|
||||
if bt == nil {
|
||||
return []byte{}
|
||||
}
|
||||
|
||||
if buf == nil {
|
||||
buf = make([]byte, bt.StableSize())
|
||||
}
|
||||
|
||||
var offset int
|
||||
|
||||
offset += protoutil.NestedStructureMarshal(bearerTokenBodyField, buf[offset:], bt.body)
|
||||
protoutil.NestedStructureMarshal(bearerTokenSignatureField, buf[offset:], bt.sig)
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
func (bt *BearerToken) StableSize() (size int) {
|
||||
if bt == nil {
|
||||
return 0
|
||||
}
|
||||
|
||||
size += protoutil.NestedStructureSize(bearerTokenBodyField, bt.body)
|
||||
size += protoutil.NestedStructureSize(bearerTokenSignatureField, bt.sig)
|
||||
|
||||
return size
|
||||
}
|
||||
|
||||
func (bt *BearerToken) Unmarshal(data []byte) error {
|
||||
return message.Unmarshal(bt, data, new(acl.BearerToken))
|
||||
}
|
21
api/acl/message_test.go
Normal file
21
api/acl/message_test.go
Normal file
|
@ -0,0 +1,21 @@
|
|||
package acl_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
acltest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/acl/test"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/rpc/message"
|
||||
messagetest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/rpc/message/test"
|
||||
)
|
||||
|
||||
func TestMessageConvert(t *testing.T) {
|
||||
messagetest.TestRPCMessage(t,
|
||||
func(empty bool) message.Message { return acltest.GenerateFilter(empty) },
|
||||
func(empty bool) message.Message { return acltest.GenerateTarget(empty) },
|
||||
func(empty bool) message.Message { return acltest.GenerateRecord(empty) },
|
||||
func(empty bool) message.Message { return acltest.GenerateTable(empty) },
|
||||
func(empty bool) message.Message { return acltest.GenerateTokenLifetime(empty) },
|
||||
func(empty bool) message.Message { return acltest.GenerateBearerTokenBody(empty) },
|
||||
func(empty bool) message.Message { return acltest.GenerateBearerToken(empty) },
|
||||
)
|
||||
}
|
98
api/acl/string.go
Normal file
98
api/acl/string.go
Normal file
|
@ -0,0 +1,98 @@
|
|||
package acl
|
||||
|
||||
import (
|
||||
acl "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/acl/grpc"
|
||||
)
|
||||
|
||||
// String returns string representation of Action.
|
||||
func (x Action) String() string {
|
||||
return ActionToGRPCField(x).String()
|
||||
}
|
||||
|
||||
// FromString parses Action from a string representation.
|
||||
// It is a reverse action to String().
|
||||
//
|
||||
// Returns true if s was parsed successfully.
|
||||
func (x *Action) FromString(s string) bool {
|
||||
g, ok := acl.Action_value[s]
|
||||
if ok {
|
||||
*x = ActionFromGRPCField(acl.Action(g))
|
||||
}
|
||||
|
||||
return ok
|
||||
}
|
||||
|
||||
// String returns string representation of Role.
|
||||
func (x Role) String() string {
|
||||
return RoleToGRPCField(x).String()
|
||||
}
|
||||
|
||||
// FromString parses Role from a string representation.
|
||||
// It is a reverse action to String().
|
||||
//
|
||||
// Returns true if s was parsed successfully.
|
||||
func (x *Role) FromString(s string) bool {
|
||||
g, ok := acl.Role_value[s]
|
||||
|
||||
if ok {
|
||||
*x = RoleFromGRPCField(acl.Role(g))
|
||||
}
|
||||
|
||||
return ok
|
||||
}
|
||||
|
||||
// String returns string representation of Operation.
|
||||
func (x Operation) String() string {
|
||||
return OperationToGRPCField(x).String()
|
||||
}
|
||||
|
||||
// FromString parses Operation from a string representation.
|
||||
// It is a reverse action to String().
|
||||
//
|
||||
// Returns true if s was parsed successfully.
|
||||
func (x *Operation) FromString(s string) bool {
|
||||
g, ok := acl.Operation_value[s]
|
||||
if ok {
|
||||
*x = OperationFromGRPCField(acl.Operation(g))
|
||||
}
|
||||
|
||||
return ok
|
||||
}
|
||||
|
||||
// String returns string representation of MatchType.
|
||||
func (x MatchType) String() string {
|
||||
return MatchTypeToGRPCField(x).String()
|
||||
}
|
||||
|
||||
// FromString parses MatchType from a string representation.
|
||||
// It is a reverse action to String().
|
||||
//
|
||||
// Returns true if s was parsed successfully.
|
||||
func (x *MatchType) FromString(s string) bool {
|
||||
g, ok := acl.MatchType_value[s]
|
||||
|
||||
if ok {
|
||||
*x = MatchTypeFromGRPCField(acl.MatchType(g))
|
||||
}
|
||||
|
||||
return ok
|
||||
}
|
||||
|
||||
// String returns string representation of HeaderType.
|
||||
func (x HeaderType) String() string {
|
||||
return HeaderTypeToGRPCField(x).String()
|
||||
}
|
||||
|
||||
// FromString parses HeaderType from a string representation.
|
||||
// It is a reverse action to String().
|
||||
//
|
||||
// Returns true if s was parsed successfully.
|
||||
func (x *HeaderType) FromString(s string) bool {
|
||||
g, ok := acl.HeaderType_value[s]
|
||||
|
||||
if ok {
|
||||
*x = HeaderTypeFromGRPCField(acl.HeaderType(g))
|
||||
}
|
||||
|
||||
return ok
|
||||
}
|
144
api/acl/test/generate.go
Normal file
144
api/acl/test/generate.go
Normal file
|
@ -0,0 +1,144 @@
|
|||
package acltest
|
||||
|
||||
import (
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/acl"
|
||||
apetest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/ape/test"
|
||||
accountingtest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/refs/test"
|
||||
)
|
||||
|
||||
func GenerateBearerToken(empty bool) *acl.BearerToken {
|
||||
m := new(acl.BearerToken)
|
||||
|
||||
if !empty {
|
||||
m.SetBody(GenerateBearerTokenBody(false))
|
||||
}
|
||||
|
||||
m.SetSignature(accountingtest.GenerateSignature(empty))
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
func GenerateBearerTokenBody(empty bool) *acl.BearerTokenBody {
|
||||
m := new(acl.BearerTokenBody)
|
||||
|
||||
if !empty {
|
||||
m.SetOwnerID(accountingtest.GenerateOwnerID(false))
|
||||
m.SetLifetime(GenerateTokenLifetime(false))
|
||||
m.SetAPEOverride(GenerateAPEOverride(empty))
|
||||
}
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
func GenerateAPEOverride(empty bool) *acl.APEOverride {
|
||||
var m *acl.APEOverride
|
||||
|
||||
if !empty {
|
||||
m = new(acl.APEOverride)
|
||||
m.SetTarget(apetest.GenerateChainTarget(empty))
|
||||
m.SetChains(apetest.GenerateRawChains(false, 3))
|
||||
}
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
func GenerateTable(empty bool) *acl.Table {
|
||||
m := new(acl.Table)
|
||||
|
||||
if !empty {
|
||||
m.SetRecords(GenerateRecords(false))
|
||||
m.SetContainerID(accountingtest.GenerateContainerID(false))
|
||||
}
|
||||
|
||||
m.SetVersion(accountingtest.GenerateVersion(empty))
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
func GenerateRecords(empty bool) []acl.Record {
|
||||
var rs []acl.Record
|
||||
|
||||
if !empty {
|
||||
rs = append(rs,
|
||||
*GenerateRecord(false),
|
||||
*GenerateRecord(false),
|
||||
)
|
||||
}
|
||||
|
||||
return rs
|
||||
}
|
||||
|
||||
func GenerateRecord(empty bool) *acl.Record {
|
||||
m := new(acl.Record)
|
||||
|
||||
if !empty {
|
||||
m.SetAction(acl.ActionAllow)
|
||||
m.SetOperation(acl.OperationGet)
|
||||
m.SetFilters(GenerateFilters(false))
|
||||
m.SetTargets(GenerateTargets(false))
|
||||
}
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
func GenerateFilters(empty bool) []acl.HeaderFilter {
|
||||
var fs []acl.HeaderFilter
|
||||
|
||||
if !empty {
|
||||
fs = append(fs,
|
||||
*GenerateFilter(false),
|
||||
*GenerateFilter(false),
|
||||
)
|
||||
}
|
||||
|
||||
return fs
|
||||
}
|
||||
|
||||
func GenerateFilter(empty bool) *acl.HeaderFilter {
|
||||
m := new(acl.HeaderFilter)
|
||||
|
||||
if !empty {
|
||||
m.SetKey("key")
|
||||
m.SetValue("val")
|
||||
m.SetHeaderType(acl.HeaderTypeRequest)
|
||||
m.SetMatchType(acl.MatchTypeStringEqual)
|
||||
}
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
func GenerateTargets(empty bool) []acl.Target {
|
||||
var ts []acl.Target
|
||||
|
||||
if !empty {
|
||||
ts = append(ts,
|
||||
*GenerateTarget(false),
|
||||
*GenerateTarget(false),
|
||||
)
|
||||
}
|
||||
|
||||
return ts
|
||||
}
|
||||
|
||||
func GenerateTarget(empty bool) *acl.Target {
|
||||
m := new(acl.Target)
|
||||
|
||||
if !empty {
|
||||
m.SetRole(acl.RoleSystem)
|
||||
m.SetKeys([][]byte{{1}, {2}})
|
||||
}
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
func GenerateTokenLifetime(empty bool) *acl.TokenLifetime {
|
||||
m := new(acl.TokenLifetime)
|
||||
|
||||
if !empty {
|
||||
m.SetExp(1)
|
||||
m.SetIat(2)
|
||||
m.SetExp(3)
|
||||
}
|
||||
|
||||
return m
|
||||
}
|
426
api/acl/types.go
Normal file
426
api/acl/types.go
Normal file
|
@ -0,0 +1,426 @@
|
|||
package acl
|
||||
|
||||
import (
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/ape"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/refs"
|
||||
)
|
||||
|
||||
// HeaderFilter is a unified structure of FilterInfo
|
||||
// message from proto definition.
|
||||
type HeaderFilter struct {
|
||||
hdrType HeaderType
|
||||
|
||||
matchType MatchType
|
||||
|
||||
key, value string
|
||||
}
|
||||
|
||||
// Target is a unified structure of Target
|
||||
// message from proto definition.
|
||||
type Target struct {
|
||||
role Role
|
||||
|
||||
keys [][]byte
|
||||
}
|
||||
|
||||
// Record is a unified structure of EACLRecord
|
||||
// message from proto definition.
|
||||
type Record struct {
|
||||
op Operation
|
||||
|
||||
action Action
|
||||
|
||||
filters []HeaderFilter
|
||||
|
||||
targets []Target
|
||||
}
|
||||
|
||||
// Table is a unified structure of EACLTable
|
||||
// message from proto definition.
|
||||
type Table struct {
|
||||
version *refs.Version
|
||||
|
||||
cid *refs.ContainerID
|
||||
|
||||
records []Record
|
||||
}
|
||||
|
||||
type TokenLifetime struct {
|
||||
exp, nbf, iat uint64
|
||||
}
|
||||
|
||||
type APEOverride struct {
|
||||
target *ape.ChainTarget
|
||||
|
||||
chains []*ape.Chain
|
||||
}
|
||||
|
||||
type BearerTokenBody struct {
|
||||
eacl *Table
|
||||
|
||||
ownerID *refs.OwnerID
|
||||
|
||||
lifetime *TokenLifetime
|
||||
|
||||
apeOverride *APEOverride
|
||||
|
||||
impersonate bool
|
||||
}
|
||||
|
||||
type BearerToken struct {
|
||||
body *BearerTokenBody
|
||||
|
||||
sig *refs.Signature
|
||||
}
|
||||
|
||||
// Target is a unified enum of MatchType enum from proto definition.
|
||||
type MatchType uint32
|
||||
|
||||
// HeaderType is a unified enum of HeaderType enum from proto definition.
|
||||
type HeaderType uint32
|
||||
|
||||
// Action is a unified enum of Action enum from proto definition.
|
||||
type Action uint32
|
||||
|
||||
// Operation is a unified enum of Operation enum from proto definition.
|
||||
type Operation uint32
|
||||
|
||||
// Role is a unified enum of Role enum from proto definition.
|
||||
type Role uint32
|
||||
|
||||
const (
|
||||
MatchTypeUnknown MatchType = iota
|
||||
MatchTypeStringEqual
|
||||
MatchTypeStringNotEqual
|
||||
)
|
||||
|
||||
const (
|
||||
HeaderTypeUnknown HeaderType = iota
|
||||
HeaderTypeRequest
|
||||
HeaderTypeObject
|
||||
HeaderTypeService
|
||||
)
|
||||
|
||||
const (
|
||||
ActionUnknown Action = iota
|
||||
ActionAllow
|
||||
ActionDeny
|
||||
)
|
||||
|
||||
const (
|
||||
OperationUnknown Operation = iota
|
||||
OperationGet
|
||||
OperationHead
|
||||
OperationPut
|
||||
OperationDelete
|
||||
OperationSearch
|
||||
OperationRange
|
||||
OperationRangeHash
|
||||
)
|
||||
|
||||
const (
|
||||
RoleUnknown Role = iota
|
||||
RoleUser
|
||||
RoleSystem
|
||||
RoleOthers
|
||||
)
|
||||
|
||||
func (f *HeaderFilter) GetHeaderType() HeaderType {
|
||||
if f != nil {
|
||||
return f.hdrType
|
||||
}
|
||||
|
||||
return HeaderTypeUnknown
|
||||
}
|
||||
|
||||
func (f *HeaderFilter) SetHeaderType(v HeaderType) {
|
||||
f.hdrType = v
|
||||
}
|
||||
|
||||
func (f *HeaderFilter) GetMatchType() MatchType {
|
||||
if f != nil {
|
||||
return f.matchType
|
||||
}
|
||||
|
||||
return MatchTypeUnknown
|
||||
}
|
||||
|
||||
func (f *HeaderFilter) SetMatchType(v MatchType) {
|
||||
f.matchType = v
|
||||
}
|
||||
|
||||
func (f *HeaderFilter) GetKey() string {
|
||||
if f != nil {
|
||||
return f.key
|
||||
}
|
||||
|
||||
return ""
|
||||
}
|
||||
|
||||
func (f *HeaderFilter) SetKey(v string) {
|
||||
f.key = v
|
||||
}
|
||||
|
||||
func (f *HeaderFilter) GetValue() string {
|
||||
if f != nil {
|
||||
return f.value
|
||||
}
|
||||
|
||||
return ""
|
||||
}
|
||||
|
||||
func (f *HeaderFilter) SetValue(v string) {
|
||||
f.value = v
|
||||
}
|
||||
|
||||
func (t *Target) GetRole() Role {
|
||||
if t != nil {
|
||||
return t.role
|
||||
}
|
||||
|
||||
return RoleUnknown
|
||||
}
|
||||
|
||||
func (t *Target) SetRole(v Role) {
|
||||
t.role = v
|
||||
}
|
||||
|
||||
func (t *Target) GetKeys() [][]byte {
|
||||
if t != nil {
|
||||
return t.keys
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (t *Target) SetKeys(v [][]byte) {
|
||||
t.keys = v
|
||||
}
|
||||
|
||||
func (r *Record) GetOperation() Operation {
|
||||
if r != nil {
|
||||
return r.op
|
||||
}
|
||||
|
||||
return OperationUnknown
|
||||
}
|
||||
|
||||
func (r *Record) SetOperation(v Operation) {
|
||||
r.op = v
|
||||
}
|
||||
|
||||
func (r *Record) GetAction() Action {
|
||||
if r != nil {
|
||||
return r.action
|
||||
}
|
||||
|
||||
return ActionUnknown
|
||||
}
|
||||
|
||||
func (r *Record) SetAction(v Action) {
|
||||
r.action = v
|
||||
}
|
||||
|
||||
func (r *Record) GetFilters() []HeaderFilter {
|
||||
if r != nil {
|
||||
return r.filters
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *Record) SetFilters(v []HeaderFilter) {
|
||||
r.filters = v
|
||||
}
|
||||
|
||||
func (r *Record) GetTargets() []Target {
|
||||
if r != nil {
|
||||
return r.targets
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *Record) SetTargets(v []Target) {
|
||||
r.targets = v
|
||||
}
|
||||
|
||||
func (t *Table) GetVersion() *refs.Version {
|
||||
if t != nil {
|
||||
return t.version
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (t *Table) SetVersion(v *refs.Version) {
|
||||
t.version = v
|
||||
}
|
||||
|
||||
func (t *Table) GetContainerID() *refs.ContainerID {
|
||||
if t != nil {
|
||||
return t.cid
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (t *Table) SetContainerID(v *refs.ContainerID) {
|
||||
t.cid = v
|
||||
}
|
||||
|
||||
func (t *Table) GetRecords() []Record {
|
||||
if t != nil {
|
||||
return t.records
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (t *Table) SetRecords(v []Record) {
|
||||
t.records = v
|
||||
}
|
||||
|
||||
func (l *TokenLifetime) GetExp() uint64 {
|
||||
if l != nil {
|
||||
return l.exp
|
||||
}
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
func (l *TokenLifetime) SetExp(v uint64) {
|
||||
l.exp = v
|
||||
}
|
||||
|
||||
func (l *TokenLifetime) GetNbf() uint64 {
|
||||
if l != nil {
|
||||
return l.nbf
|
||||
}
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
func (l *TokenLifetime) SetNbf(v uint64) {
|
||||
l.nbf = v
|
||||
}
|
||||
|
||||
func (l *TokenLifetime) GetIat() uint64 {
|
||||
if l != nil {
|
||||
return l.iat
|
||||
}
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
func (l *TokenLifetime) SetIat(v uint64) {
|
||||
l.iat = v
|
||||
}
|
||||
|
||||
func (bt *BearerTokenBody) GetEACL() *Table {
|
||||
if bt != nil {
|
||||
return bt.eacl
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (bt *BearerTokenBody) SetEACL(v *Table) {
|
||||
bt.eacl = v
|
||||
}
|
||||
|
||||
func (t *APEOverride) GetTarget() *ape.ChainTarget {
|
||||
if t == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
return t.target
|
||||
}
|
||||
|
||||
func (t *APEOverride) GetChains() []*ape.Chain {
|
||||
if t == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
return t.chains
|
||||
}
|
||||
|
||||
func (t *APEOverride) SetTarget(v *ape.ChainTarget) {
|
||||
t.target = v
|
||||
}
|
||||
|
||||
func (t *APEOverride) SetChains(v []*ape.Chain) {
|
||||
t.chains = v
|
||||
}
|
||||
|
||||
func (bt *BearerTokenBody) GetAPEOverride() *APEOverride {
|
||||
if bt != nil {
|
||||
return bt.apeOverride
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (bt *BearerTokenBody) SetAPEOverride(v *APEOverride) {
|
||||
bt.apeOverride = v
|
||||
}
|
||||
|
||||
func (bt *BearerTokenBody) GetOwnerID() *refs.OwnerID {
|
||||
if bt != nil {
|
||||
return bt.ownerID
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (bt *BearerTokenBody) SetOwnerID(v *refs.OwnerID) {
|
||||
bt.ownerID = v
|
||||
}
|
||||
|
||||
func (bt *BearerTokenBody) GetLifetime() *TokenLifetime {
|
||||
if bt != nil {
|
||||
return bt.lifetime
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (bt *BearerTokenBody) SetLifetime(v *TokenLifetime) {
|
||||
bt.lifetime = v
|
||||
}
|
||||
|
||||
func (bt *BearerTokenBody) GetImpersonate() bool {
|
||||
if bt != nil {
|
||||
return bt.impersonate
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (bt *BearerTokenBody) SetImpersonate(v bool) {
|
||||
bt.impersonate = v
|
||||
}
|
||||
|
||||
func (bt *BearerToken) GetBody() *BearerTokenBody {
|
||||
if bt != nil {
|
||||
return bt.body
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (bt *BearerToken) SetBody(v *BearerTokenBody) {
|
||||
bt.body = v
|
||||
}
|
||||
|
||||
func (bt *BearerToken) GetSignature() *refs.Signature {
|
||||
if bt != nil {
|
||||
return bt.sig
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (bt *BearerToken) SetSignature(v *refs.Signature) {
|
||||
bt.sig = v
|
||||
}
|
131
api/ape/convert.go
Normal file
131
api/ape/convert.go
Normal file
|
@ -0,0 +1,131 @@
|
|||
package ape
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
ape "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/ape/grpc"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/rpc/grpc"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/rpc/message"
|
||||
)
|
||||
|
||||
func TargetTypeToGRPCField(typ TargetType) ape.TargetType {
|
||||
switch typ {
|
||||
case TargetTypeNamespace:
|
||||
return ape.TargetType_NAMESPACE
|
||||
case TargetTypeContainer:
|
||||
return ape.TargetType_CONTAINER
|
||||
case TargetTypeUser:
|
||||
return ape.TargetType_USER
|
||||
case TargetTypeGroup:
|
||||
return ape.TargetType_GROUP
|
||||
default:
|
||||
return ape.TargetType_UNDEFINED
|
||||
}
|
||||
}
|
||||
|
||||
func TargetTypeFromGRPCField(typ ape.TargetType) TargetType {
|
||||
switch typ {
|
||||
case ape.TargetType_NAMESPACE:
|
||||
return TargetTypeNamespace
|
||||
case ape.TargetType_CONTAINER:
|
||||
return TargetTypeContainer
|
||||
case ape.TargetType_USER:
|
||||
return TargetTypeUser
|
||||
case ape.TargetType_GROUP:
|
||||
return TargetTypeGroup
|
||||
default:
|
||||
return TargetTypeUndefined
|
||||
}
|
||||
}
|
||||
|
||||
func TargetTypeToGRPC(typ TargetType) ape.TargetType {
|
||||
return ape.TargetType(typ)
|
||||
}
|
||||
|
||||
func TargetTypeFromGRPC(typ ape.TargetType) TargetType {
|
||||
return TargetType(typ)
|
||||
}
|
||||
|
||||
func (v2 *ChainTarget) ToGRPCMessage() grpc.Message {
|
||||
var mgrpc *ape.ChainTarget
|
||||
|
||||
if v2 != nil {
|
||||
mgrpc = new(ape.ChainTarget)
|
||||
|
||||
mgrpc.SetType(TargetTypeToGRPC(v2.GetTargetType()))
|
||||
mgrpc.SetName(v2.GetName())
|
||||
}
|
||||
|
||||
return mgrpc
|
||||
}
|
||||
|
||||
func (v2 *ChainTarget) FromGRPCMessage(m grpc.Message) error {
|
||||
mgrpc, ok := m.(*ape.ChainTarget)
|
||||
if !ok {
|
||||
return message.NewUnexpectedMessageType(m, mgrpc)
|
||||
}
|
||||
|
||||
v2.SetTargetType(TargetTypeFromGRPC(mgrpc.GetType()))
|
||||
v2.SetName(mgrpc.GetName())
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (v2 *ChainRaw) ToGRPCMessage() grpc.Message {
|
||||
var mgrpc *ape.Chain_Raw
|
||||
|
||||
if v2 != nil {
|
||||
mgrpc = new(ape.Chain_Raw)
|
||||
mgrpc.Raw = v2.GetRaw()
|
||||
}
|
||||
|
||||
return mgrpc
|
||||
}
|
||||
|
||||
func (v2 *ChainRaw) FromGRPCMessage(m grpc.Message) error {
|
||||
mgrpc, ok := m.(*ape.Chain_Raw)
|
||||
if !ok {
|
||||
return message.NewUnexpectedMessageType(m, mgrpc)
|
||||
}
|
||||
|
||||
v2.SetRaw(mgrpc.Raw)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (v2 *Chain) ToGRPCMessage() grpc.Message {
|
||||
var mgrpc *ape.Chain
|
||||
|
||||
if v2 != nil {
|
||||
mgrpc = new(ape.Chain)
|
||||
|
||||
switch chainKind := v2.GetKind().(type) {
|
||||
default:
|
||||
panic(fmt.Sprintf("unsupported chain kind: %T", chainKind))
|
||||
case *ChainRaw:
|
||||
mgrpc.SetRaw(chainKind.GetRaw())
|
||||
}
|
||||
}
|
||||
|
||||
return mgrpc
|
||||
}
|
||||
|
||||
func (v2 *Chain) FromGRPCMessage(m grpc.Message) error {
|
||||
mgrpc, ok := m.(*ape.Chain)
|
||||
if !ok {
|
||||
return message.NewUnexpectedMessageType(m, mgrpc)
|
||||
}
|
||||
|
||||
switch chainKind := mgrpc.GetKind().(type) {
|
||||
default:
|
||||
return fmt.Errorf("unsupported chain kind: %T", chainKind)
|
||||
case *ape.Chain_Raw:
|
||||
chainRaw := new(ChainRaw)
|
||||
if err := chainRaw.FromGRPCMessage(chainKind); err != nil {
|
||||
return err
|
||||
}
|
||||
v2.SetKind(chainRaw)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
376
api/ape/grpc/types.pb.go
generated
Normal file
376
api/ape/grpc/types.pb.go
generated
Normal file
|
@ -0,0 +1,376 @@
|
|||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.36.1
|
||||
// protoc v5.29.2
|
||||
// source: api/ape/grpc/types.proto
|
||||
|
||||
//go:build !protoopaque
|
||||
|
||||
package ape
|
||||
|
||||
import (
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
reflect "reflect"
|
||||
)
|
||||
|
||||
const (
|
||||
// Verify that this generated code is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
||||
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||
)
|
||||
|
||||
// TargetType is a type target to which a rule chain is defined.
|
||||
type TargetType int32
|
||||
|
||||
const (
|
||||
TargetType_UNDEFINED TargetType = 0
|
||||
TargetType_NAMESPACE TargetType = 1
|
||||
TargetType_CONTAINER TargetType = 2
|
||||
TargetType_USER TargetType = 3
|
||||
TargetType_GROUP TargetType = 4
|
||||
)
|
||||
|
||||
// Enum value maps for TargetType.
|
||||
var (
|
||||
TargetType_name = map[int32]string{
|
||||
0: "UNDEFINED",
|
||||
1: "NAMESPACE",
|
||||
2: "CONTAINER",
|
||||
3: "USER",
|
||||
4: "GROUP",
|
||||
}
|
||||
TargetType_value = map[string]int32{
|
||||
"UNDEFINED": 0,
|
||||
"NAMESPACE": 1,
|
||||
"CONTAINER": 2,
|
||||
"USER": 3,
|
||||
"GROUP": 4,
|
||||
}
|
||||
)
|
||||
|
||||
func (x TargetType) Enum() *TargetType {
|
||||
p := new(TargetType)
|
||||
*p = x
|
||||
return p
|
||||
}
|
||||
|
||||
func (x TargetType) String() string {
|
||||
return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
|
||||
}
|
||||
|
||||
func (TargetType) Descriptor() protoreflect.EnumDescriptor {
|
||||
return file_api_ape_grpc_types_proto_enumTypes[0].Descriptor()
|
||||
}
|
||||
|
||||
func (TargetType) Type() protoreflect.EnumType {
|
||||
return &file_api_ape_grpc_types_proto_enumTypes[0]
|
||||
}
|
||||
|
||||
func (x TargetType) Number() protoreflect.EnumNumber {
|
||||
return protoreflect.EnumNumber(x)
|
||||
}
|
||||
|
||||
// ChainTarget is an object to which a rule chain is defined.
|
||||
type ChainTarget struct {
|
||||
state protoimpl.MessageState `protogen:"hybrid.v1"`
|
||||
Type *TargetType `protobuf:"varint,1,opt,name=type,enum=frostfs.v2.ape.TargetType" json:"type,omitempty"`
|
||||
Name *string `protobuf:"bytes,2,opt,name=name" json:"name,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *ChainTarget) Reset() {
|
||||
*x = ChainTarget{}
|
||||
mi := &file_api_ape_grpc_types_proto_msgTypes[0]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *ChainTarget) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*ChainTarget) ProtoMessage() {}
|
||||
|
||||
func (x *ChainTarget) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_ape_grpc_types_proto_msgTypes[0]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
func (x *ChainTarget) GetType() TargetType {
|
||||
if x != nil && x.Type != nil {
|
||||
return *x.Type
|
||||
}
|
||||
return TargetType_UNDEFINED
|
||||
}
|
||||
|
||||
func (x *ChainTarget) GetName() string {
|
||||
if x != nil && x.Name != nil {
|
||||
return *x.Name
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *ChainTarget) SetType(v TargetType) {
|
||||
x.Type = &v
|
||||
}
|
||||
|
||||
func (x *ChainTarget) SetName(v string) {
|
||||
x.Name = &v
|
||||
}
|
||||
|
||||
func (x *ChainTarget) HasType() bool {
|
||||
if x == nil {
|
||||
return false
|
||||
}
|
||||
return x.Type != nil
|
||||
}
|
||||
|
||||
func (x *ChainTarget) HasName() bool {
|
||||
if x == nil {
|
||||
return false
|
||||
}
|
||||
return x.Name != nil
|
||||
}
|
||||
|
||||
func (x *ChainTarget) ClearType() {
|
||||
x.Type = nil
|
||||
}
|
||||
|
||||
func (x *ChainTarget) ClearName() {
|
||||
x.Name = nil
|
||||
}
|
||||
|
||||
type ChainTarget_builder struct {
|
||||
_ [0]func() // Prevents comparability and use of unkeyed literals for the builder.
|
||||
|
||||
Type *TargetType
|
||||
Name *string
|
||||
}
|
||||
|
||||
func (b0 ChainTarget_builder) Build() *ChainTarget {
|
||||
m0 := &ChainTarget{}
|
||||
b, x := &b0, m0
|
||||
_, _ = b, x
|
||||
x.Type = b.Type
|
||||
x.Name = b.Name
|
||||
return m0
|
||||
}
|
||||
|
||||
// Chain is a chain of rules defined for a specific target.
|
||||
type Chain struct {
|
||||
state protoimpl.MessageState `protogen:"hybrid.v1"`
|
||||
// Types that are valid to be assigned to Kind:
|
||||
//
|
||||
// *Chain_Raw
|
||||
Kind isChain_Kind `protobuf_oneof:"kind"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *Chain) Reset() {
|
||||
*x = Chain{}
|
||||
mi := &file_api_ape_grpc_types_proto_msgTypes[1]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *Chain) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*Chain) ProtoMessage() {}
|
||||
|
||||
func (x *Chain) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_ape_grpc_types_proto_msgTypes[1]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
func (x *Chain) GetKind() isChain_Kind {
|
||||
if x != nil {
|
||||
return x.Kind
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *Chain) GetRaw() []byte {
|
||||
if x != nil {
|
||||
if x, ok := x.Kind.(*Chain_Raw); ok {
|
||||
return x.Raw
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *Chain) SetRaw(v []byte) {
|
||||
if v == nil {
|
||||
v = []byte{}
|
||||
}
|
||||
x.Kind = &Chain_Raw{v}
|
||||
}
|
||||
|
||||
func (x *Chain) HasKind() bool {
|
||||
if x == nil {
|
||||
return false
|
||||
}
|
||||
return x.Kind != nil
|
||||
}
|
||||
|
||||
func (x *Chain) HasRaw() bool {
|
||||
if x == nil {
|
||||
return false
|
||||
}
|
||||
_, ok := x.Kind.(*Chain_Raw)
|
||||
return ok
|
||||
}
|
||||
|
||||
func (x *Chain) ClearKind() {
|
||||
x.Kind = nil
|
||||
}
|
||||
|
||||
func (x *Chain) ClearRaw() {
|
||||
if _, ok := x.Kind.(*Chain_Raw); ok {
|
||||
x.Kind = nil
|
||||
}
|
||||
}
|
||||
|
||||
const Chain_Kind_not_set_case case_Chain_Kind = 0
|
||||
const Chain_Raw_case case_Chain_Kind = 1
|
||||
|
||||
func (x *Chain) WhichKind() case_Chain_Kind {
|
||||
if x == nil {
|
||||
return Chain_Kind_not_set_case
|
||||
}
|
||||
switch x.Kind.(type) {
|
||||
case *Chain_Raw:
|
||||
return Chain_Raw_case
|
||||
default:
|
||||
return Chain_Kind_not_set_case
|
||||
}
|
||||
}
|
||||
|
||||
type Chain_builder struct {
|
||||
_ [0]func() // Prevents comparability and use of unkeyed literals for the builder.
|
||||
|
||||
// Fields of oneof Kind:
|
||||
// Raw representation of a serizalized rule chain.
|
||||
Raw []byte
|
||||
// -- end of Kind
|
||||
}
|
||||
|
||||
func (b0 Chain_builder) Build() *Chain {
|
||||
m0 := &Chain{}
|
||||
b, x := &b0, m0
|
||||
_, _ = b, x
|
||||
if b.Raw != nil {
|
||||
x.Kind = &Chain_Raw{b.Raw}
|
||||
}
|
||||
return m0
|
||||
}
|
||||
|
||||
type case_Chain_Kind protoreflect.FieldNumber
|
||||
|
||||
func (x case_Chain_Kind) String() string {
|
||||
md := file_api_ape_grpc_types_proto_msgTypes[1].Descriptor()
|
||||
if x == 0 {
|
||||
return "not set"
|
||||
}
|
||||
return protoimpl.X.MessageFieldStringOf(md, protoreflect.FieldNumber(x))
|
||||
}
|
||||
|
||||
type isChain_Kind interface {
|
||||
isChain_Kind()
|
||||
}
|
||||
|
||||
type Chain_Raw struct {
|
||||
// Raw representation of a serizalized rule chain.
|
||||
Raw []byte `protobuf:"bytes,1,opt,name=raw,oneof"`
|
||||
}
|
||||
|
||||
func (*Chain_Raw) isChain_Kind() {}
|
||||
|
||||
var File_api_ape_grpc_types_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_api_ape_grpc_types_proto_rawDesc = []byte{
|
||||
0x0a, 0x18, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x70, 0x65, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2f, 0x74,
|
||||
0x79, 0x70, 0x65, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0e, 0x66, 0x72, 0x6f, 0x73,
|
||||
0x74, 0x66, 0x73, 0x2e, 0x76, 0x32, 0x2e, 0x61, 0x70, 0x65, 0x22, 0x51, 0x0a, 0x0b, 0x43, 0x68,
|
||||
0x61, 0x69, 0x6e, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x12, 0x2e, 0x0a, 0x04, 0x74, 0x79, 0x70,
|
||||
0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1a, 0x2e, 0x66, 0x72, 0x6f, 0x73, 0x74, 0x66,
|
||||
0x73, 0x2e, 0x76, 0x32, 0x2e, 0x61, 0x70, 0x65, 0x2e, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x54,
|
||||
0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d,
|
||||
0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x23, 0x0a,
|
||||
0x05, 0x43, 0x68, 0x61, 0x69, 0x6e, 0x12, 0x12, 0x0a, 0x03, 0x72, 0x61, 0x77, 0x18, 0x01, 0x20,
|
||||
0x01, 0x28, 0x0c, 0x48, 0x00, 0x52, 0x03, 0x72, 0x61, 0x77, 0x42, 0x06, 0x0a, 0x04, 0x6b, 0x69,
|
||||
0x6e, 0x64, 0x2a, 0x4e, 0x0a, 0x0a, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x54, 0x79, 0x70, 0x65,
|
||||
0x12, 0x0d, 0x0a, 0x09, 0x55, 0x4e, 0x44, 0x45, 0x46, 0x49, 0x4e, 0x45, 0x44, 0x10, 0x00, 0x12,
|
||||
0x0d, 0x0a, 0x09, 0x4e, 0x41, 0x4d, 0x45, 0x53, 0x50, 0x41, 0x43, 0x45, 0x10, 0x01, 0x12, 0x0d,
|
||||
0x0a, 0x09, 0x43, 0x4f, 0x4e, 0x54, 0x41, 0x49, 0x4e, 0x45, 0x52, 0x10, 0x02, 0x12, 0x08, 0x0a,
|
||||
0x04, 0x55, 0x53, 0x45, 0x52, 0x10, 0x03, 0x12, 0x09, 0x0a, 0x05, 0x47, 0x52, 0x4f, 0x55, 0x50,
|
||||
0x10, 0x04, 0x42, 0x3f, 0x5a, 0x3d, 0x67, 0x69, 0x74, 0x2e, 0x66, 0x72, 0x6f, 0x73, 0x74, 0x66,
|
||||
0x73, 0x2e, 0x69, 0x6e, 0x66, 0x6f, 0x2f, 0x54, 0x72, 0x75, 0x65, 0x43, 0x6c, 0x6f, 0x75, 0x64,
|
||||
0x4c, 0x61, 0x62, 0x2f, 0x66, 0x72, 0x6f, 0x73, 0x74, 0x66, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2d,
|
||||
0x67, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x70, 0x65, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x3b,
|
||||
0x61, 0x70, 0x65, 0x62, 0x08, 0x65, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x70, 0xe8, 0x07,
|
||||
}
|
||||
|
||||
var file_api_ape_grpc_types_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
|
||||
var file_api_ape_grpc_types_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
|
||||
var file_api_ape_grpc_types_proto_goTypes = []any{
|
||||
(TargetType)(0), // 0: frostfs.v2.ape.TargetType
|
||||
(*ChainTarget)(nil), // 1: frostfs.v2.ape.ChainTarget
|
||||
(*Chain)(nil), // 2: frostfs.v2.ape.Chain
|
||||
}
|
||||
var file_api_ape_grpc_types_proto_depIdxs = []int32{
|
||||
0, // 0: frostfs.v2.ape.ChainTarget.type:type_name -> frostfs.v2.ape.TargetType
|
||||
1, // [1:1] is the sub-list for method output_type
|
||||
1, // [1:1] is the sub-list for method input_type
|
||||
1, // [1:1] is the sub-list for extension type_name
|
||||
1, // [1:1] is the sub-list for extension extendee
|
||||
0, // [0:1] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_api_ape_grpc_types_proto_init() }
|
||||
func file_api_ape_grpc_types_proto_init() {
|
||||
if File_api_ape_grpc_types_proto != nil {
|
||||
return
|
||||
}
|
||||
file_api_ape_grpc_types_proto_msgTypes[1].OneofWrappers = []any{
|
||||
(*Chain_Raw)(nil),
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_api_ape_grpc_types_proto_rawDesc,
|
||||
NumEnums: 1,
|
||||
NumMessages: 2,
|
||||
NumExtensions: 0,
|
||||
NumServices: 0,
|
||||
},
|
||||
GoTypes: file_api_ape_grpc_types_proto_goTypes,
|
||||
DependencyIndexes: file_api_ape_grpc_types_proto_depIdxs,
|
||||
EnumInfos: file_api_ape_grpc_types_proto_enumTypes,
|
||||
MessageInfos: file_api_ape_grpc_types_proto_msgTypes,
|
||||
}.Build()
|
||||
File_api_ape_grpc_types_proto = out.File
|
||||
file_api_ape_grpc_types_proto_rawDesc = nil
|
||||
file_api_ape_grpc_types_proto_goTypes = nil
|
||||
file_api_ape_grpc_types_proto_depIdxs = nil
|
||||
}
|
383
api/ape/grpc/types_protoopaque.pb.go
generated
Normal file
383
api/ape/grpc/types_protoopaque.pb.go
generated
Normal file
|
@ -0,0 +1,383 @@
|
|||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.36.1
|
||||
// protoc v5.29.2
|
||||
// source: api/ape/grpc/types.proto
|
||||
|
||||
//go:build protoopaque
|
||||
|
||||
package ape
|
||||
|
||||
import (
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
reflect "reflect"
|
||||
)
|
||||
|
||||
const (
|
||||
// Verify that this generated code is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
||||
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||
)
|
||||
|
||||
// TargetType is a type target to which a rule chain is defined.
|
||||
type TargetType int32
|
||||
|
||||
const (
|
||||
TargetType_UNDEFINED TargetType = 0
|
||||
TargetType_NAMESPACE TargetType = 1
|
||||
TargetType_CONTAINER TargetType = 2
|
||||
TargetType_USER TargetType = 3
|
||||
TargetType_GROUP TargetType = 4
|
||||
)
|
||||
|
||||
// Enum value maps for TargetType.
|
||||
var (
|
||||
TargetType_name = map[int32]string{
|
||||
0: "UNDEFINED",
|
||||
1: "NAMESPACE",
|
||||
2: "CONTAINER",
|
||||
3: "USER",
|
||||
4: "GROUP",
|
||||
}
|
||||
TargetType_value = map[string]int32{
|
||||
"UNDEFINED": 0,
|
||||
"NAMESPACE": 1,
|
||||
"CONTAINER": 2,
|
||||
"USER": 3,
|
||||
"GROUP": 4,
|
||||
}
|
||||
)
|
||||
|
||||
func (x TargetType) Enum() *TargetType {
|
||||
p := new(TargetType)
|
||||
*p = x
|
||||
return p
|
||||
}
|
||||
|
||||
func (x TargetType) String() string {
|
||||
return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
|
||||
}
|
||||
|
||||
func (TargetType) Descriptor() protoreflect.EnumDescriptor {
|
||||
return file_api_ape_grpc_types_proto_enumTypes[0].Descriptor()
|
||||
}
|
||||
|
||||
func (TargetType) Type() protoreflect.EnumType {
|
||||
return &file_api_ape_grpc_types_proto_enumTypes[0]
|
||||
}
|
||||
|
||||
func (x TargetType) Number() protoreflect.EnumNumber {
|
||||
return protoreflect.EnumNumber(x)
|
||||
}
|
||||
|
||||
// ChainTarget is an object to which a rule chain is defined.
|
||||
type ChainTarget struct {
|
||||
state protoimpl.MessageState `protogen:"opaque.v1"`
|
||||
xxx_hidden_Type TargetType `protobuf:"varint,1,opt,name=type,enum=frostfs.v2.ape.TargetType" json:"type,omitempty"`
|
||||
xxx_hidden_Name *string `protobuf:"bytes,2,opt,name=name" json:"name,omitempty"`
|
||||
XXX_raceDetectHookData protoimpl.RaceDetectHookData
|
||||
XXX_presence [1]uint32
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *ChainTarget) Reset() {
|
||||
*x = ChainTarget{}
|
||||
mi := &file_api_ape_grpc_types_proto_msgTypes[0]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *ChainTarget) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*ChainTarget) ProtoMessage() {}
|
||||
|
||||
func (x *ChainTarget) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_ape_grpc_types_proto_msgTypes[0]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
func (x *ChainTarget) GetType() TargetType {
|
||||
if x != nil {
|
||||
if protoimpl.X.Present(&(x.XXX_presence[0]), 0) {
|
||||
return x.xxx_hidden_Type
|
||||
}
|
||||
}
|
||||
return TargetType_UNDEFINED
|
||||
}
|
||||
|
||||
func (x *ChainTarget) GetName() string {
|
||||
if x != nil {
|
||||
if x.xxx_hidden_Name != nil {
|
||||
return *x.xxx_hidden_Name
|
||||
}
|
||||
return ""
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *ChainTarget) SetType(v TargetType) {
|
||||
x.xxx_hidden_Type = v
|
||||
protoimpl.X.SetPresent(&(x.XXX_presence[0]), 0, 2)
|
||||
}
|
||||
|
||||
func (x *ChainTarget) SetName(v string) {
|
||||
x.xxx_hidden_Name = &v
|
||||
protoimpl.X.SetPresent(&(x.XXX_presence[0]), 1, 2)
|
||||
}
|
||||
|
||||
func (x *ChainTarget) HasType() bool {
|
||||
if x == nil {
|
||||
return false
|
||||
}
|
||||
return protoimpl.X.Present(&(x.XXX_presence[0]), 0)
|
||||
}
|
||||
|
||||
func (x *ChainTarget) HasName() bool {
|
||||
if x == nil {
|
||||
return false
|
||||
}
|
||||
return protoimpl.X.Present(&(x.XXX_presence[0]), 1)
|
||||
}
|
||||
|
||||
func (x *ChainTarget) ClearType() {
|
||||
protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 0)
|
||||
x.xxx_hidden_Type = TargetType_UNDEFINED
|
||||
}
|
||||
|
||||
func (x *ChainTarget) ClearName() {
|
||||
protoimpl.X.ClearPresent(&(x.XXX_presence[0]), 1)
|
||||
x.xxx_hidden_Name = nil
|
||||
}
|
||||
|
||||
type ChainTarget_builder struct {
|
||||
_ [0]func() // Prevents comparability and use of unkeyed literals for the builder.
|
||||
|
||||
Type *TargetType
|
||||
Name *string
|
||||
}
|
||||
|
||||
func (b0 ChainTarget_builder) Build() *ChainTarget {
|
||||
m0 := &ChainTarget{}
|
||||
b, x := &b0, m0
|
||||
_, _ = b, x
|
||||
if b.Type != nil {
|
||||
protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 0, 2)
|
||||
x.xxx_hidden_Type = *b.Type
|
||||
}
|
||||
if b.Name != nil {
|
||||
protoimpl.X.SetPresentNonAtomic(&(x.XXX_presence[0]), 1, 2)
|
||||
x.xxx_hidden_Name = b.Name
|
||||
}
|
||||
return m0
|
||||
}
|
||||
|
||||
// Chain is a chain of rules defined for a specific target.
|
||||
type Chain struct {
|
||||
state protoimpl.MessageState `protogen:"opaque.v1"`
|
||||
xxx_hidden_Kind isChain_Kind `protobuf_oneof:"kind"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *Chain) Reset() {
|
||||
*x = Chain{}
|
||||
mi := &file_api_ape_grpc_types_proto_msgTypes[1]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *Chain) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*Chain) ProtoMessage() {}
|
||||
|
||||
func (x *Chain) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_ape_grpc_types_proto_msgTypes[1]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
func (x *Chain) GetRaw() []byte {
|
||||
if x != nil {
|
||||
if x, ok := x.xxx_hidden_Kind.(*chain_Raw); ok {
|
||||
return x.Raw
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *Chain) SetRaw(v []byte) {
|
||||
if v == nil {
|
||||
v = []byte{}
|
||||
}
|
||||
x.xxx_hidden_Kind = &chain_Raw{v}
|
||||
}
|
||||
|
||||
func (x *Chain) HasKind() bool {
|
||||
if x == nil {
|
||||
return false
|
||||
}
|
||||
return x.xxx_hidden_Kind != nil
|
||||
}
|
||||
|
||||
func (x *Chain) HasRaw() bool {
|
||||
if x == nil {
|
||||
return false
|
||||
}
|
||||
_, ok := x.xxx_hidden_Kind.(*chain_Raw)
|
||||
return ok
|
||||
}
|
||||
|
||||
func (x *Chain) ClearKind() {
|
||||
x.xxx_hidden_Kind = nil
|
||||
}
|
||||
|
||||
func (x *Chain) ClearRaw() {
|
||||
if _, ok := x.xxx_hidden_Kind.(*chain_Raw); ok {
|
||||
x.xxx_hidden_Kind = nil
|
||||
}
|
||||
}
|
||||
|
||||
const Chain_Kind_not_set_case case_Chain_Kind = 0
|
||||
const Chain_Raw_case case_Chain_Kind = 1
|
||||
|
||||
func (x *Chain) WhichKind() case_Chain_Kind {
|
||||
if x == nil {
|
||||
return Chain_Kind_not_set_case
|
||||
}
|
||||
switch x.xxx_hidden_Kind.(type) {
|
||||
case *chain_Raw:
|
||||
return Chain_Raw_case
|
||||
default:
|
||||
return Chain_Kind_not_set_case
|
||||
}
|
||||
}
|
||||
|
||||
type Chain_builder struct {
|
||||
_ [0]func() // Prevents comparability and use of unkeyed literals for the builder.
|
||||
|
||||
// Fields of oneof xxx_hidden_Kind:
|
||||
// Raw representation of a serizalized rule chain.
|
||||
Raw []byte
|
||||
// -- end of xxx_hidden_Kind
|
||||
}
|
||||
|
||||
func (b0 Chain_builder) Build() *Chain {
|
||||
m0 := &Chain{}
|
||||
b, x := &b0, m0
|
||||
_, _ = b, x
|
||||
if b.Raw != nil {
|
||||
x.xxx_hidden_Kind = &chain_Raw{b.Raw}
|
||||
}
|
||||
return m0
|
||||
}
|
||||
|
||||
type case_Chain_Kind protoreflect.FieldNumber
|
||||
|
||||
func (x case_Chain_Kind) String() string {
|
||||
md := file_api_ape_grpc_types_proto_msgTypes[1].Descriptor()
|
||||
if x == 0 {
|
||||
return "not set"
|
||||
}
|
||||
return protoimpl.X.MessageFieldStringOf(md, protoreflect.FieldNumber(x))
|
||||
}
|
||||
|
||||
type isChain_Kind interface {
|
||||
isChain_Kind()
|
||||
}
|
||||
|
||||
type chain_Raw struct {
|
||||
// Raw representation of a serizalized rule chain.
|
||||
Raw []byte `protobuf:"bytes,1,opt,name=raw,oneof"`
|
||||
}
|
||||
|
||||
func (*chain_Raw) isChain_Kind() {}
|
||||
|
||||
var File_api_ape_grpc_types_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_api_ape_grpc_types_proto_rawDesc = []byte{
|
||||
0x0a, 0x18, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x70, 0x65, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2f, 0x74,
|
||||
0x79, 0x70, 0x65, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0e, 0x66, 0x72, 0x6f, 0x73,
|
||||
0x74, 0x66, 0x73, 0x2e, 0x76, 0x32, 0x2e, 0x61, 0x70, 0x65, 0x22, 0x51, 0x0a, 0x0b, 0x43, 0x68,
|
||||
0x61, 0x69, 0x6e, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x12, 0x2e, 0x0a, 0x04, 0x74, 0x79, 0x70,
|
||||
0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1a, 0x2e, 0x66, 0x72, 0x6f, 0x73, 0x74, 0x66,
|
||||
0x73, 0x2e, 0x76, 0x32, 0x2e, 0x61, 0x70, 0x65, 0x2e, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x54,
|
||||
0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d,
|
||||
0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x23, 0x0a,
|
||||
0x05, 0x43, 0x68, 0x61, 0x69, 0x6e, 0x12, 0x12, 0x0a, 0x03, 0x72, 0x61, 0x77, 0x18, 0x01, 0x20,
|
||||
0x01, 0x28, 0x0c, 0x48, 0x00, 0x52, 0x03, 0x72, 0x61, 0x77, 0x42, 0x06, 0x0a, 0x04, 0x6b, 0x69,
|
||||
0x6e, 0x64, 0x2a, 0x4e, 0x0a, 0x0a, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x54, 0x79, 0x70, 0x65,
|
||||
0x12, 0x0d, 0x0a, 0x09, 0x55, 0x4e, 0x44, 0x45, 0x46, 0x49, 0x4e, 0x45, 0x44, 0x10, 0x00, 0x12,
|
||||
0x0d, 0x0a, 0x09, 0x4e, 0x41, 0x4d, 0x45, 0x53, 0x50, 0x41, 0x43, 0x45, 0x10, 0x01, 0x12, 0x0d,
|
||||
0x0a, 0x09, 0x43, 0x4f, 0x4e, 0x54, 0x41, 0x49, 0x4e, 0x45, 0x52, 0x10, 0x02, 0x12, 0x08, 0x0a,
|
||||
0x04, 0x55, 0x53, 0x45, 0x52, 0x10, 0x03, 0x12, 0x09, 0x0a, 0x05, 0x47, 0x52, 0x4f, 0x55, 0x50,
|
||||
0x10, 0x04, 0x42, 0x3f, 0x5a, 0x3d, 0x67, 0x69, 0x74, 0x2e, 0x66, 0x72, 0x6f, 0x73, 0x74, 0x66,
|
||||
0x73, 0x2e, 0x69, 0x6e, 0x66, 0x6f, 0x2f, 0x54, 0x72, 0x75, 0x65, 0x43, 0x6c, 0x6f, 0x75, 0x64,
|
||||
0x4c, 0x61, 0x62, 0x2f, 0x66, 0x72, 0x6f, 0x73, 0x74, 0x66, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2d,
|
||||
0x67, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x70, 0x65, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x3b,
|
||||
0x61, 0x70, 0x65, 0x62, 0x08, 0x65, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x70, 0xe8, 0x07,
|
||||
}
|
||||
|
||||
var file_api_ape_grpc_types_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
|
||||
var file_api_ape_grpc_types_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
|
||||
var file_api_ape_grpc_types_proto_goTypes = []any{
|
||||
(TargetType)(0), // 0: frostfs.v2.ape.TargetType
|
||||
(*ChainTarget)(nil), // 1: frostfs.v2.ape.ChainTarget
|
||||
(*Chain)(nil), // 2: frostfs.v2.ape.Chain
|
||||
}
|
||||
var file_api_ape_grpc_types_proto_depIdxs = []int32{
|
||||
0, // 0: frostfs.v2.ape.ChainTarget.type:type_name -> frostfs.v2.ape.TargetType
|
||||
1, // [1:1] is the sub-list for method output_type
|
||||
1, // [1:1] is the sub-list for method input_type
|
||||
1, // [1:1] is the sub-list for extension type_name
|
||||
1, // [1:1] is the sub-list for extension extendee
|
||||
0, // [0:1] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_api_ape_grpc_types_proto_init() }
|
||||
func file_api_ape_grpc_types_proto_init() {
|
||||
if File_api_ape_grpc_types_proto != nil {
|
||||
return
|
||||
}
|
||||
file_api_ape_grpc_types_proto_msgTypes[1].OneofWrappers = []any{
|
||||
(*chain_Raw)(nil),
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_api_ape_grpc_types_proto_rawDesc,
|
||||
NumEnums: 1,
|
||||
NumMessages: 2,
|
||||
NumExtensions: 0,
|
||||
NumServices: 0,
|
||||
},
|
||||
GoTypes: file_api_ape_grpc_types_proto_goTypes,
|
||||
DependencyIndexes: file_api_ape_grpc_types_proto_depIdxs,
|
||||
EnumInfos: file_api_ape_grpc_types_proto_enumTypes,
|
||||
MessageInfos: file_api_ape_grpc_types_proto_msgTypes,
|
||||
}.Build()
|
||||
File_api_ape_grpc_types_proto = out.File
|
||||
file_api_ape_grpc_types_proto_rawDesc = nil
|
||||
file_api_ape_grpc_types_proto_goTypes = nil
|
||||
file_api_ape_grpc_types_proto_depIdxs = nil
|
||||
}
|
14
api/ape/json.go
Normal file
14
api/ape/json.go
Normal file
|
@ -0,0 +1,14 @@
|
|||
package ape
|
||||
|
||||
import (
|
||||
ape "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/ape/grpc"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/rpc/message"
|
||||
)
|
||||
|
||||
func (t *ChainTarget) MarshalJSON() ([]byte, error) {
|
||||
return message.MarshalJSON(t)
|
||||
}
|
||||
|
||||
func (t *ChainTarget) UnmarshalJSON(data []byte) error {
|
||||
return message.UnmarshalJSON(t, data, new(ape.ChainTarget))
|
||||
}
|
92
api/ape/marshal.go
Normal file
92
api/ape/marshal.go
Normal file
|
@ -0,0 +1,92 @@
|
|||
package ape
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
ape "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/ape/grpc"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/rpc/message"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/util/proto"
|
||||
)
|
||||
|
||||
const (
|
||||
chainTargetTargetTypeField = 1
|
||||
chainTargetNameField = 2
|
||||
|
||||
chainRawField = 1
|
||||
)
|
||||
|
||||
func (t *ChainTarget) StableSize() (size int) {
|
||||
if t == nil {
|
||||
return 0
|
||||
}
|
||||
|
||||
size += proto.EnumSize(chainTargetTargetTypeField, int32(t.targeType))
|
||||
size += proto.StringSize(chainTargetNameField, t.name)
|
||||
|
||||
return size
|
||||
}
|
||||
|
||||
func (t *ChainTarget) StableMarshal(buf []byte) []byte {
|
||||
if t == nil {
|
||||
return []byte{}
|
||||
}
|
||||
|
||||
if buf == nil {
|
||||
buf = make([]byte, t.StableSize())
|
||||
}
|
||||
|
||||
var offset int
|
||||
|
||||
offset += proto.EnumMarshal(chainTargetTargetTypeField, buf[offset:], int32(t.targeType))
|
||||
proto.StringMarshal(chainTargetNameField, buf[offset:], t.name)
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
func (t *ChainTarget) Unmarshal(data []byte) error {
|
||||
return message.Unmarshal(t, data, new(ape.ChainTarget))
|
||||
}
|
||||
|
||||
func (c *Chain) StableSize() (size int) {
|
||||
if c == nil {
|
||||
return 0
|
||||
}
|
||||
|
||||
switch v := c.GetKind().(type) {
|
||||
case *ChainRaw:
|
||||
if v != nil {
|
||||
size += proto.BytesSize(chainRawField, v.GetRaw())
|
||||
}
|
||||
default:
|
||||
panic(fmt.Sprintf("unsupported chain kind: %T", v))
|
||||
}
|
||||
|
||||
return size
|
||||
}
|
||||
|
||||
func (c *Chain) StableMarshal(buf []byte) []byte {
|
||||
if c == nil {
|
||||
return []byte{}
|
||||
}
|
||||
|
||||
if buf == nil {
|
||||
buf = make([]byte, c.StableSize())
|
||||
}
|
||||
|
||||
var offset int
|
||||
|
||||
switch v := c.GetKind().(type) {
|
||||
case *ChainRaw:
|
||||
if v != nil {
|
||||
proto.BytesMarshal(chainRawField, buf[offset:], v.GetRaw())
|
||||
}
|
||||
default:
|
||||
panic(fmt.Sprintf("unsupported chain kind: %T", v))
|
||||
}
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
func (c *Chain) Unmarshal(data []byte) error {
|
||||
return message.Unmarshal(c, data, new(ape.Chain))
|
||||
}
|
15
api/ape/message_test.go
Normal file
15
api/ape/message_test.go
Normal file
|
@ -0,0 +1,15 @@
|
|||
package ape_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
apetest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/ape/test"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/rpc/message"
|
||||
messagetest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/rpc/message/test"
|
||||
)
|
||||
|
||||
func TestMessageConvert(t *testing.T) {
|
||||
messagetest.TestRPCMessage(t,
|
||||
func(empty bool) message.Message { return apetest.GenerateChainTarget(empty) },
|
||||
)
|
||||
}
|
18
api/ape/string.go
Normal file
18
api/ape/string.go
Normal file
|
@ -0,0 +1,18 @@
|
|||
package ape
|
||||
|
||||
import (
|
||||
apegrpc "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/ape/grpc"
|
||||
)
|
||||
|
||||
func (tt TargetType) String() string {
|
||||
return TargetTypeToGRPCField(tt).String()
|
||||
}
|
||||
|
||||
func (tt *TargetType) FromString(s string) bool {
|
||||
i, ok := apegrpc.TargetType_value[s]
|
||||
if ok {
|
||||
*tt = TargetType(i)
|
||||
}
|
||||
|
||||
return ok
|
||||
}
|
71
api/ape/test/generate.go
Normal file
71
api/ape/test/generate.go
Normal file
|
@ -0,0 +1,71 @@
|
|||
package test
|
||||
|
||||
import (
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/ape"
|
||||
)
|
||||
|
||||
func GenerateRawChains(empty bool, n int) []*ape.Chain {
|
||||
if empty {
|
||||
return []*ape.Chain{}
|
||||
}
|
||||
|
||||
res := make([]*ape.Chain, n)
|
||||
for i := range res {
|
||||
res[i] = GenerateRawChain(empty)
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
func GenerateRawChain(empty bool) *ape.Chain {
|
||||
chRaw := new(ape.ChainRaw)
|
||||
|
||||
if empty {
|
||||
chRaw.SetRaw([]byte("{}"))
|
||||
} else {
|
||||
chRaw.SetRaw([]byte(`{
|
||||
"ID": "",
|
||||
"Rules": [
|
||||
{
|
||||
"Status": "Allow",
|
||||
"Actions": {
|
||||
"Inverted": false,
|
||||
"Names": [
|
||||
"GetObject"
|
||||
]
|
||||
},
|
||||
"Resources": {
|
||||
"Inverted": false,
|
||||
"Names": [
|
||||
"native:object/*"
|
||||
]
|
||||
},
|
||||
"Any": false,
|
||||
"Condition": [
|
||||
{
|
||||
"Op": "StringEquals",
|
||||
"Object": "Resource",
|
||||
"Key": "Department",
|
||||
"Value": "HR"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"MatchType": "DenyPriority"
|
||||
}`))
|
||||
}
|
||||
|
||||
ch := new(ape.Chain)
|
||||
ch.SetKind(chRaw)
|
||||
return ch
|
||||
}
|
||||
|
||||
func GenerateChainTarget(empty bool) *ape.ChainTarget {
|
||||
m := new(ape.ChainTarget)
|
||||
|
||||
if !empty {
|
||||
m.SetTargetType(ape.TargetTypeContainer)
|
||||
m.SetName("BzQw5HH3feoxFDD5tCT87Y1726qzgLfxEE7wgtoRzB3R")
|
||||
}
|
||||
|
||||
return m
|
||||
}
|
79
api/ape/types.go
Normal file
79
api/ape/types.go
Normal file
|
@ -0,0 +1,79 @@
|
|||
package ape
|
||||
|
||||
type TargetType uint32
|
||||
|
||||
const (
|
||||
TargetTypeUndefined TargetType = iota
|
||||
TargetTypeNamespace
|
||||
TargetTypeContainer
|
||||
TargetTypeUser
|
||||
TargetTypeGroup
|
||||
)
|
||||
|
||||
type ChainTarget struct {
|
||||
targeType TargetType
|
||||
|
||||
name string
|
||||
}
|
||||
|
||||
func (ct *ChainTarget) SetTargetType(targeType TargetType) {
|
||||
ct.targeType = targeType
|
||||
}
|
||||
|
||||
func (ct *ChainTarget) SetName(name string) {
|
||||
ct.name = name
|
||||
}
|
||||
|
||||
func (ct *ChainTarget) GetTargetType() TargetType {
|
||||
if ct != nil {
|
||||
return ct.targeType
|
||||
}
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
func (ct *ChainTarget) GetName() string {
|
||||
if ct != nil {
|
||||
return ct.name
|
||||
}
|
||||
|
||||
return ""
|
||||
}
|
||||
|
||||
type chainKind interface {
|
||||
isChainKind()
|
||||
}
|
||||
|
||||
type Chain struct {
|
||||
kind chainKind
|
||||
}
|
||||
|
||||
func (c *Chain) SetKind(kind chainKind) {
|
||||
c.kind = kind
|
||||
}
|
||||
|
||||
func (c *Chain) GetKind() chainKind {
|
||||
if c == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
return c.kind
|
||||
}
|
||||
|
||||
type ChainRaw struct {
|
||||
Raw []byte
|
||||
}
|
||||
|
||||
func (*ChainRaw) isChainKind() {}
|
||||
|
||||
func (c *ChainRaw) SetRaw(raw []byte) {
|
||||
c.Raw = raw
|
||||
}
|
||||
|
||||
func (c *ChainRaw) GetRaw() []byte {
|
||||
if c == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
return c.Raw
|
||||
}
|
358
api/apemanager/convert.go
Normal file
358
api/apemanager/convert.go
Normal file
|
@ -0,0 +1,358 @@
|
|||
package apemanager
|
||||
|
||||
import (
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/ape"
|
||||
apeGRPC "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/ape/grpc"
|
||||
apemanager "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/apemanager/grpc"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/rpc/grpc"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/rpc/message"
|
||||
)
|
||||
|
||||
func (reqBody *AddChainRequestBody) ToGRPCMessage() grpc.Message {
|
||||
var reqBodygrpc *apemanager.AddChainRequest_Body
|
||||
|
||||
if reqBody != nil {
|
||||
reqBodygrpc = new(apemanager.AddChainRequest_Body)
|
||||
|
||||
reqBodygrpc.SetTarget(reqBody.GetTarget().ToGRPCMessage().(*apeGRPC.ChainTarget))
|
||||
reqBodygrpc.SetChain(reqBody.GetChain().ToGRPCMessage().(*apeGRPC.Chain))
|
||||
}
|
||||
|
||||
return reqBodygrpc
|
||||
}
|
||||
|
||||
func (reqBody *AddChainRequestBody) FromGRPCMessage(m grpc.Message) error {
|
||||
reqBodygrpc, ok := m.(*apemanager.AddChainRequest_Body)
|
||||
if !ok {
|
||||
return message.NewUnexpectedMessageType(m, reqBodygrpc)
|
||||
}
|
||||
|
||||
if targetgrpc := reqBodygrpc.GetTarget(); targetgrpc != nil {
|
||||
reqBody.target = new(ape.ChainTarget)
|
||||
if err := reqBody.target.FromGRPCMessage(targetgrpc); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if chaingrpc := reqBodygrpc.GetChain(); chaingrpc != nil {
|
||||
reqBody.chain = new(ape.Chain)
|
||||
if err := reqBody.GetChain().FromGRPCMessage(chaingrpc); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (req *AddChainRequest) ToGRPCMessage() grpc.Message {
|
||||
var reqgrpc *apemanager.AddChainRequest
|
||||
|
||||
if req != nil {
|
||||
reqgrpc = new(apemanager.AddChainRequest)
|
||||
|
||||
reqgrpc.SetBody(req.GetBody().ToGRPCMessage().(*apemanager.AddChainRequest_Body))
|
||||
req.RequestHeaders.ToMessage(reqgrpc)
|
||||
}
|
||||
|
||||
return reqgrpc
|
||||
}
|
||||
|
||||
func (req *AddChainRequest) FromGRPCMessage(m grpc.Message) error {
|
||||
reqgrpc, ok := m.(*apemanager.AddChainRequest)
|
||||
if !ok {
|
||||
return message.NewUnexpectedMessageType(m, reqgrpc)
|
||||
}
|
||||
|
||||
if reqBodygrpc := reqgrpc.GetBody(); reqBodygrpc != nil {
|
||||
req.body = new(AddChainRequestBody)
|
||||
if err := req.body.FromGRPCMessage(reqBodygrpc); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return req.RequestHeaders.FromMessage(reqgrpc)
|
||||
}
|
||||
|
||||
func (respBody *AddChainResponseBody) ToGRPCMessage() grpc.Message {
|
||||
var respBodygrpc *apemanager.AddChainResponse_Body
|
||||
|
||||
if respBody != nil {
|
||||
respBodygrpc = new(apemanager.AddChainResponse_Body)
|
||||
|
||||
respBodygrpc.SetChainId(respBody.GetChainID())
|
||||
}
|
||||
|
||||
return respBodygrpc
|
||||
}
|
||||
|
||||
func (respBody *AddChainResponseBody) FromGRPCMessage(m grpc.Message) error {
|
||||
respBodygrpc, ok := m.(*apemanager.AddChainResponse_Body)
|
||||
if !ok {
|
||||
return message.NewUnexpectedMessageType(m, respBodygrpc)
|
||||
}
|
||||
|
||||
respBody.SetChainID(respBodygrpc.GetChainId())
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (resp *AddChainResponse) ToGRPCMessage() grpc.Message {
|
||||
var respgrpc *apemanager.AddChainResponse
|
||||
|
||||
if resp != nil {
|
||||
respgrpc = new(apemanager.AddChainResponse)
|
||||
|
||||
respgrpc.SetBody(resp.body.ToGRPCMessage().(*apemanager.AddChainResponse_Body))
|
||||
resp.ResponseHeaders.ToMessage(respgrpc)
|
||||
}
|
||||
|
||||
return respgrpc
|
||||
}
|
||||
|
||||
func (resp *AddChainResponse) FromGRPCMessage(m grpc.Message) error {
|
||||
respgrpc, ok := m.(*apemanager.AddChainResponse)
|
||||
if !ok {
|
||||
return message.NewUnexpectedMessageType(m, respgrpc)
|
||||
}
|
||||
|
||||
if respBodygrpc := respgrpc.GetBody(); respBodygrpc != nil {
|
||||
resp.body = new(AddChainResponseBody)
|
||||
if err := resp.body.FromGRPCMessage(respBodygrpc); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return resp.ResponseHeaders.FromMessage(respgrpc)
|
||||
}
|
||||
|
||||
func (reqBody *RemoveChainRequestBody) ToGRPCMessage() grpc.Message {
|
||||
var reqBodygrpc *apemanager.RemoveChainRequest_Body
|
||||
|
||||
if reqBody != nil {
|
||||
reqBodygrpc = new(apemanager.RemoveChainRequest_Body)
|
||||
|
||||
reqBodygrpc.SetTarget(reqBody.target.ToGRPCMessage().(*apeGRPC.ChainTarget))
|
||||
reqBodygrpc.SetChainId(reqBody.GetChainID())
|
||||
}
|
||||
|
||||
return reqBodygrpc
|
||||
}
|
||||
|
||||
func (reqBody *RemoveChainRequestBody) FromGRPCMessage(m grpc.Message) error {
|
||||
reqBodygrpc, ok := m.(*apemanager.RemoveChainRequest_Body)
|
||||
if !ok {
|
||||
return message.NewUnexpectedMessageType(m, reqBodygrpc)
|
||||
}
|
||||
|
||||
if targetgrpc := reqBodygrpc.GetTarget(); targetgrpc != nil {
|
||||
reqBody.target = new(ape.ChainTarget)
|
||||
if err := reqBody.target.FromGRPCMessage(targetgrpc); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
reqBody.SetChainID(reqBodygrpc.GetChainId())
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (req *RemoveChainRequest) ToGRPCMessage() grpc.Message {
|
||||
var reqgrpc *apemanager.RemoveChainRequest
|
||||
|
||||
if req != nil {
|
||||
reqgrpc = new(apemanager.RemoveChainRequest)
|
||||
|
||||
reqgrpc.SetBody(req.body.ToGRPCMessage().(*apemanager.RemoveChainRequest_Body))
|
||||
req.RequestHeaders.ToMessage(reqgrpc)
|
||||
}
|
||||
|
||||
return reqgrpc
|
||||
}
|
||||
|
||||
func (req *RemoveChainRequest) FromGRPCMessage(m grpc.Message) error {
|
||||
reqgrpc, ok := m.(*apemanager.RemoveChainRequest)
|
||||
if !ok {
|
||||
return message.NewUnexpectedMessageType(m, reqgrpc)
|
||||
}
|
||||
|
||||
if reqBodygrpc := reqgrpc.GetBody(); reqBodygrpc != nil {
|
||||
req.body = new(RemoveChainRequestBody)
|
||||
if err := req.body.FromGRPCMessage(reqBodygrpc); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return req.RequestHeaders.FromMessage(reqgrpc)
|
||||
}
|
||||
|
||||
func (respBody *RemoveChainResponseBody) ToGRPCMessage() grpc.Message {
|
||||
var respBodygrpc *apemanager.RemoveChainResponse_Body
|
||||
|
||||
if respBody != nil {
|
||||
respBodygrpc = new(apemanager.RemoveChainResponse_Body)
|
||||
}
|
||||
|
||||
return respBodygrpc
|
||||
}
|
||||
|
||||
func (respBody *RemoveChainResponseBody) FromGRPCMessage(m grpc.Message) error {
|
||||
respBodygrpc, ok := m.(*apemanager.RemoveChainResponse_Body)
|
||||
if !ok {
|
||||
return message.NewUnexpectedMessageType(m, respBodygrpc)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (resp *RemoveChainResponse) ToGRPCMessage() grpc.Message {
|
||||
var respgrpc *apemanager.RemoveChainResponse
|
||||
|
||||
if resp != nil {
|
||||
respgrpc = new(apemanager.RemoveChainResponse)
|
||||
|
||||
respgrpc.SetBody(resp.body.ToGRPCMessage().(*apemanager.RemoveChainResponse_Body))
|
||||
resp.ResponseHeaders.ToMessage(respgrpc)
|
||||
}
|
||||
|
||||
return respgrpc
|
||||
}
|
||||
|
||||
func (resp *RemoveChainResponse) FromGRPCMessage(m grpc.Message) error {
|
||||
respgrpc, ok := m.(*apemanager.RemoveChainResponse)
|
||||
if !ok {
|
||||
return message.NewUnexpectedMessageType(m, respgrpc)
|
||||
}
|
||||
|
||||
if respBodygrpc := respgrpc.GetBody(); respBodygrpc != nil {
|
||||
resp.body = new(RemoveChainResponseBody)
|
||||
if err := resp.body.FromGRPCMessage(respBodygrpc); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return resp.ResponseHeaders.FromMessage(respgrpc)
|
||||
}
|
||||
|
||||
func (reqBody *ListChainsRequestBody) ToGRPCMessage() grpc.Message {
|
||||
var reqBodygrpc *apemanager.ListChainsRequest_Body
|
||||
|
||||
if reqBody != nil {
|
||||
reqBodygrpc = new(apemanager.ListChainsRequest_Body)
|
||||
|
||||
reqBodygrpc.SetTarget(reqBody.target.ToGRPCMessage().(*apeGRPC.ChainTarget))
|
||||
}
|
||||
|
||||
return reqBodygrpc
|
||||
}
|
||||
|
||||
func (reqBody *ListChainsRequestBody) FromGRPCMessage(m grpc.Message) error {
|
||||
reqBodygrpc, ok := m.(*apemanager.ListChainsRequest_Body)
|
||||
if !ok {
|
||||
return message.NewUnexpectedMessageType(m, reqBodygrpc)
|
||||
}
|
||||
|
||||
if targetgrpc := reqBodygrpc.GetTarget(); targetgrpc != nil {
|
||||
reqBody.target = new(ape.ChainTarget)
|
||||
if err := reqBody.target.FromGRPCMessage(targetgrpc); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (req *ListChainsRequest) ToGRPCMessage() grpc.Message {
|
||||
var reqgrpc *apemanager.ListChainsRequest
|
||||
|
||||
if req != nil {
|
||||
reqgrpc = new(apemanager.ListChainsRequest)
|
||||
|
||||
reqgrpc.SetBody(req.body.ToGRPCMessage().(*apemanager.ListChainsRequest_Body))
|
||||
req.RequestHeaders.ToMessage(reqgrpc)
|
||||
}
|
||||
|
||||
return reqgrpc
|
||||
}
|
||||
|
||||
func (req *ListChainsRequest) FromGRPCMessage(m grpc.Message) error {
|
||||
reqgrpc, ok := m.(*apemanager.ListChainsRequest)
|
||||
if !ok {
|
||||
return message.NewUnexpectedMessageType(m, reqgrpc)
|
||||
}
|
||||
|
||||
if reqBodygrpc := reqgrpc.GetBody(); reqBodygrpc != nil {
|
||||
req.body = new(ListChainsRequestBody)
|
||||
if err := req.body.FromGRPCMessage(reqBodygrpc); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return req.RequestHeaders.FromMessage(reqgrpc)
|
||||
}
|
||||
|
||||
func (respBody *ListChainsResponseBody) ToGRPCMessage() grpc.Message {
|
||||
var respBodygrpc *apemanager.ListChainsResponse_Body
|
||||
|
||||
if respBody != nil {
|
||||
respBodygrpc = new(apemanager.ListChainsResponse_Body)
|
||||
|
||||
chainsgrpc := make([]*apeGRPC.Chain, 0, len(respBody.GetChains()))
|
||||
for _, chain := range respBody.GetChains() {
|
||||
chainsgrpc = append(chainsgrpc, chain.ToGRPCMessage().(*apeGRPC.Chain))
|
||||
}
|
||||
|
||||
respBodygrpc.SetChains(chainsgrpc)
|
||||
}
|
||||
|
||||
return respBodygrpc
|
||||
}
|
||||
|
||||
func (respBody *ListChainsResponseBody) FromGRPCMessage(m grpc.Message) error {
|
||||
respBodygrpc, ok := m.(*apemanager.ListChainsResponse_Body)
|
||||
if !ok {
|
||||
return message.NewUnexpectedMessageType(m, respBodygrpc)
|
||||
}
|
||||
|
||||
chains := make([]*ape.Chain, 0, len(respBodygrpc.GetChains()))
|
||||
|
||||
for _, chaingrpc := range respBodygrpc.GetChains() {
|
||||
chain := new(ape.Chain)
|
||||
if err := chain.FromGRPCMessage(chaingrpc); err != nil {
|
||||
return err
|
||||
}
|
||||
chains = append(chains, chain)
|
||||
}
|
||||
|
||||
respBody.SetChains(chains)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (resp *ListChainsResponse) ToGRPCMessage() grpc.Message {
|
||||
var respgrpc *apemanager.ListChainsResponse
|
||||
|
||||
if resp != nil {
|
||||
respgrpc = new(apemanager.ListChainsResponse)
|
||||
|
||||
respgrpc.SetBody(resp.body.ToGRPCMessage().(*apemanager.ListChainsResponse_Body))
|
||||
resp.ResponseHeaders.ToMessage(respgrpc)
|
||||
}
|
||||
|
||||
return respgrpc
|
||||
}
|
||||
|
||||
func (resp *ListChainsResponse) FromGRPCMessage(m grpc.Message) error {
|
||||
respgrpc, ok := m.(*apemanager.ListChainsResponse)
|
||||
if !ok {
|
||||
return message.NewUnexpectedMessageType(m, respgrpc)
|
||||
}
|
||||
|
||||
if respBodygrpc := respgrpc.GetBody(); respBodygrpc != nil {
|
||||
resp.body = new(ListChainsResponseBody)
|
||||
if err := resp.body.FromGRPCMessage(respBodygrpc); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return resp.ResponseHeaders.FromMessage(respgrpc)
|
||||
}
|
1487
api/apemanager/grpc/service.pb.go
generated
Normal file
1487
api/apemanager/grpc/service.pb.go
generated
Normal file
File diff suppressed because it is too large
Load diff
265
api/apemanager/grpc/service_grpc.pb.go
generated
Normal file
265
api/apemanager/grpc/service_grpc.pb.go
generated
Normal file
|
@ -0,0 +1,265 @@
|
|||
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
||||
// versions:
|
||||
// - protoc-gen-go-grpc v1.5.1
|
||||
// - protoc v5.29.2
|
||||
// source: api/apemanager/grpc/service.proto
|
||||
|
||||
package apemanager
|
||||
|
||||
import (
|
||||
context "context"
|
||||
grpc "google.golang.org/grpc"
|
||||
codes "google.golang.org/grpc/codes"
|
||||
status "google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the grpc package it is being compiled against.
|
||||
// Requires gRPC-Go v1.64.0 or later.
|
||||
const _ = grpc.SupportPackageIsVersion9
|
||||
|
||||
const (
|
||||
APEManagerService_AddChain_FullMethodName = "/frostfs.v2.apemanager.APEManagerService/AddChain"
|
||||
APEManagerService_RemoveChain_FullMethodName = "/frostfs.v2.apemanager.APEManagerService/RemoveChain"
|
||||
APEManagerService_ListChains_FullMethodName = "/frostfs.v2.apemanager.APEManagerService/ListChains"
|
||||
)
|
||||
|
||||
// APEManagerServiceClient is the client API for APEManagerService service.
|
||||
//
|
||||
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
|
||||
//
|
||||
// `APEManagerService` provides API to manage rule chains within sidechain's
|
||||
// `Policy` smart contract.
|
||||
type APEManagerServiceClient interface {
|
||||
// Add a rule chain for a specific target to `Policy` smart contract.
|
||||
//
|
||||
// Statuses:
|
||||
// - **OK** (0, SECTION_SUCCESS): \
|
||||
// the chain has been successfully added;
|
||||
// - Common failures (SECTION_FAILURE_COMMON);
|
||||
// - **CONTAINER_NOT_FOUND** (3072, SECTION_CONTAINER): \
|
||||
// container (as target) not found;
|
||||
// - **APE_MANAGER_ACCESS_DENIED** (5120, SECTION_APE_MANAGER): \
|
||||
// the operation is denied by the service.
|
||||
AddChain(ctx context.Context, in *AddChainRequest, opts ...grpc.CallOption) (*AddChainResponse, error)
|
||||
// Remove a rule chain for a specific target from `Policy` smart contract.
|
||||
// RemoveChain is an idempotent operation: removal of non-existing rule chain
|
||||
// also means success.
|
||||
//
|
||||
// Statuses:
|
||||
// - **OK** (0, SECTION_SUCCESS): \
|
||||
// the chain has been successfully removed;
|
||||
// - Common failures (SECTION_FAILURE_COMMON);
|
||||
// - **CONTAINER_NOT_FOUND** (3072, SECTION_CONTAINER): \
|
||||
// container (as target) not found;
|
||||
// - **APE_MANAGER_ACCESS_DENIED** (5120, SECTION_APE_MANAGER): \
|
||||
// the operation is denied by the service.
|
||||
RemoveChain(ctx context.Context, in *RemoveChainRequest, opts ...grpc.CallOption) (*RemoveChainResponse, error)
|
||||
// List chains defined for a specific target from `Policy` smart contract.
|
||||
//
|
||||
// Statuses:
|
||||
// - **OK** (0, SECTION_SUCCESS): \
|
||||
// chains have been successfully listed;
|
||||
// - Common failures (SECTION_FAILURE_COMMON);
|
||||
// - **CONTAINER_NOT_FOUND** (3072, SECTION_CONTAINER): \
|
||||
// container (as target) not found;
|
||||
// - **APE_MANAGER_ACCESS_DENIED** (5120, SECTION_APE_MANAGER): \
|
||||
// the operation is denied by the service.
|
||||
ListChains(ctx context.Context, in *ListChainsRequest, opts ...grpc.CallOption) (*ListChainsResponse, error)
|
||||
}
|
||||
|
||||
type aPEManagerServiceClient struct {
|
||||
cc grpc.ClientConnInterface
|
||||
}
|
||||
|
||||
func NewAPEManagerServiceClient(cc grpc.ClientConnInterface) APEManagerServiceClient {
|
||||
return &aPEManagerServiceClient{cc}
|
||||
}
|
||||
|
||||
func (c *aPEManagerServiceClient) AddChain(ctx context.Context, in *AddChainRequest, opts ...grpc.CallOption) (*AddChainResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(AddChainResponse)
|
||||
err := c.cc.Invoke(ctx, APEManagerService_AddChain_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *aPEManagerServiceClient) RemoveChain(ctx context.Context, in *RemoveChainRequest, opts ...grpc.CallOption) (*RemoveChainResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(RemoveChainResponse)
|
||||
err := c.cc.Invoke(ctx, APEManagerService_RemoveChain_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||