mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-01-10 22:29:36 -06:00
Merge pull request #1 from owncloud/basic-service
This commit is contained in:
@@ -4,5 +4,7 @@ exclude_paths:
|
||||
- changelog/**
|
||||
- docs/**
|
||||
- pkg/proto/**
|
||||
- package.json
|
||||
- rollup.config.js
|
||||
|
||||
...
|
||||
|
||||
2
.dockerignore
Normal file
2
.dockerignore
Normal file
@@ -0,0 +1,2 @@
|
||||
*
|
||||
!bin/
|
||||
35
.drone.star
35
.drone.star
@@ -32,6 +32,17 @@ def testing(ctx):
|
||||
'arch': 'amd64',
|
||||
},
|
||||
'steps': [
|
||||
{
|
||||
'name': 'frontend',
|
||||
'image': 'webhippie/nodejs:latest',
|
||||
'pull': 'always',
|
||||
'commands': [
|
||||
'yarn install --frozen-lockfile',
|
||||
'yarn lint',
|
||||
'yarn test',
|
||||
'yarn build',
|
||||
],
|
||||
},
|
||||
{
|
||||
'name': 'generate',
|
||||
'image': 'webhippie/golang:1.13',
|
||||
@@ -62,10 +73,10 @@ def testing(ctx):
|
||||
},
|
||||
{
|
||||
'name': 'staticcheck',
|
||||
'image': 'webhippie/golang:1.13',
|
||||
'image': 'golangci/golangci-lint:latest',
|
||||
'pull': 'always',
|
||||
'commands': [
|
||||
'make staticcheck',
|
||||
'golangci-lint run',
|
||||
],
|
||||
'volumes': [
|
||||
{
|
||||
@@ -152,6 +163,17 @@ def docker(ctx, arch):
|
||||
'arch': arch,
|
||||
},
|
||||
'steps': [
|
||||
{
|
||||
'name': 'frontend',
|
||||
'image': 'webhippie/nodejs:latest',
|
||||
'pull': 'always',
|
||||
'commands': [
|
||||
'yarn install --frozen-lockfile',
|
||||
'yarn lint',
|
||||
'yarn test',
|
||||
'yarn build',
|
||||
],
|
||||
},
|
||||
{
|
||||
'name': 'generate',
|
||||
'image': 'webhippie/golang:1.13',
|
||||
@@ -290,6 +312,15 @@ def binary(ctx, name):
|
||||
'arch': 'amd64',
|
||||
},
|
||||
'steps': [
|
||||
{
|
||||
'name': 'frontend',
|
||||
'image': 'webhippie/nodejs:latest',
|
||||
'pull': 'always',
|
||||
'commands': [
|
||||
'yarn install --frozen-lockfile',
|
||||
'yarn build',
|
||||
],
|
||||
},
|
||||
{
|
||||
'name': 'generate',
|
||||
'image': 'webhippie/golang:1.13',
|
||||
|
||||
17
.eslintrc.json
Normal file
17
.eslintrc.json
Normal file
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"env": {
|
||||
"browser": true,
|
||||
"es6": true,
|
||||
"amd": true
|
||||
},
|
||||
"extends": [
|
||||
"standard",
|
||||
"plugin:vue/essential"
|
||||
],
|
||||
"parserOptions": {
|
||||
"sourceType": "module"
|
||||
},
|
||||
"rules": {
|
||||
|
||||
}
|
||||
}
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -7,3 +7,4 @@ coverage.out
|
||||
|
||||
/node_modules
|
||||
/assets
|
||||
/ocis-settings-store
|
||||
|
||||
34
.golangci.yml
Normal file
34
.golangci.yml
Normal file
@@ -0,0 +1,34 @@
|
||||
issues:
|
||||
exclude-rules:
|
||||
- path: pkg/proto/v0/settings.pb.go
|
||||
text: "SA1019:"
|
||||
linters:
|
||||
- staticcheck
|
||||
- path: pkg/store/filesystem/io.go
|
||||
text: "SA1019:"
|
||||
linters:
|
||||
- staticcheck
|
||||
linters:
|
||||
enable:
|
||||
- bodyclose
|
||||
- deadcode
|
||||
- errcheck
|
||||
- gosimple
|
||||
- govet
|
||||
- ineffassign
|
||||
- staticcheck
|
||||
- structcheck
|
||||
- typecheck
|
||||
- unused
|
||||
- varcheck
|
||||
- depguard
|
||||
- golint
|
||||
- goimports
|
||||
- unconvert
|
||||
- scopelint
|
||||
- maligned
|
||||
- misspell
|
||||
# - gocritic
|
||||
- prealloc
|
||||
#- gosec
|
||||
|
||||
68
Makefile
68
Makefile
@@ -4,6 +4,8 @@ IMPORT := github.com/owncloud/$(NAME)
|
||||
BIN := bin
|
||||
DIST := dist
|
||||
HUGO := hugo
|
||||
PROTO_VERSION := v0
|
||||
PROTO_SRC := pkg/proto/$(PROTO_VERSION)/*.proto
|
||||
|
||||
ifeq ($(OS), Windows_NT)
|
||||
EXECUTABLE := $(NAME).exe
|
||||
@@ -69,9 +71,9 @@ fmt:
|
||||
vet:
|
||||
go vet $(PACKAGES)
|
||||
|
||||
.PHONY: staticcheck
|
||||
staticcheck:
|
||||
go run honnef.co/go/tools/cmd/staticcheck -tags '$(TAGS)' $(PACKAGES)
|
||||
# .PHONY: staticcheck
|
||||
# staticcheck:
|
||||
# go run honnef.co/go/tools/cmd/staticcheck -tags '$(TAGS)' $(PACKAGES)
|
||||
|
||||
.PHONY: lint
|
||||
lint:
|
||||
@@ -155,41 +157,41 @@ docs: docs-copy docs-build
|
||||
watch:
|
||||
go run github.com/cespare/reflex -c reflex.conf
|
||||
|
||||
# $(GOPATH)/bin/protoc-gen-go:
|
||||
# GO111MODULE=off go get -v github.com/golang/protobuf/protoc-gen-go
|
||||
$(GOPATH)/bin/protoc-gen-go:
|
||||
GO111MODULE=off go get -v github.com/golang/protobuf/protoc-gen-go
|
||||
|
||||
# $(GOPATH)/bin/protoc-gen-micro:
|
||||
# GO111MODULE=off go get -v github.com/micro/protoc-gen-micro
|
||||
$(GOPATH)/bin/protoc-gen-micro:
|
||||
GO111MODULE=on go get -v github.com/micro/protoc-gen-micro/v2
|
||||
|
||||
# $(GOPATH)/bin/protoc-gen-microweb:
|
||||
# GO111MODULE=off go get -v github.com/webhippie/protoc-gen-microweb
|
||||
$(GOPATH)/bin/protoc-gen-microweb:
|
||||
GO111MODULE=off go get -v github.com/owncloud/protoc-gen-microweb
|
||||
|
||||
# $(GOPATH)/bin/protoc-gen-swagger:
|
||||
# GO111MODULE=off go get -v github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger
|
||||
$(GOPATH)/bin/protoc-gen-swagger:
|
||||
GO111MODULE=off go get -v github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger
|
||||
|
||||
# pkg/proto/v0/example.pb.go: pkg/proto/v0/example.proto
|
||||
# protoc \
|
||||
# -I=third_party/ \
|
||||
# -I=pkg/proto/v0/ \
|
||||
# --go_out=logtostderr=true:pkg/proto/v0 example.proto
|
||||
pkg/proto/v0/settings.pb.go: pkg/proto/v0/settings.proto
|
||||
protoc \
|
||||
-I=third_party/ \
|
||||
-I=pkg/proto/v0/ \
|
||||
--go_out=pkg/proto/v0 settings.proto
|
||||
|
||||
# pkg/proto/v0/example.pb.micro.go: pkg/proto/v0/example.proto
|
||||
# protoc \
|
||||
# -I=third_party/ \
|
||||
# -I=pkg/proto/v0/ \
|
||||
# --micro_out=logtostderr=true:pkg/proto/v0 example.proto
|
||||
pkg/proto/v0/settings.pb.micro.go: pkg/proto/v0/settings.proto
|
||||
protoc \
|
||||
-I=third_party/ \
|
||||
-I=pkg/proto/v0/ \
|
||||
--micro_out=pkg/proto/v0 settings.proto
|
||||
|
||||
# pkg/proto/v0/example.pb.web.go: pkg/proto/v0/example.proto
|
||||
# protoc \
|
||||
# -I=third_party/ \
|
||||
# -I=pkg/proto/v0/ \
|
||||
# --microweb_out=logtostderr=true:pkg/proto/v0 example.proto
|
||||
pkg/proto/v0/settings.pb.web.go: pkg/proto/v0/settings.proto
|
||||
protoc \
|
||||
-I=third_party/ \
|
||||
-I=pkg/proto/v0/ \
|
||||
--microweb_out=pkg/proto/v0 settings.proto
|
||||
|
||||
# pkg/proto/v0/example.swagger.json: pkg/proto/v0/example.proto
|
||||
# protoc \
|
||||
# -I=third_party/ \
|
||||
# -I=pkg/proto/v0/ \
|
||||
# --swagger_out=logtostderr=true:pkg/proto/v0 example.proto
|
||||
pkg/proto/v0/settings.swagger.json: pkg/proto/v0/settings.proto
|
||||
protoc \
|
||||
-I=third_party/ \
|
||||
-I=pkg/proto/v0/ \
|
||||
--swagger_out=pkg/proto/v0 settings.proto
|
||||
|
||||
# .PHONY: protobuf
|
||||
# protobuf: $(GOPATH)/bin/protoc-gen-go $(GOPATH)/bin/protoc-gen-micro $(GOPATH)/bin/protoc-gen-microweb $(GOPATH)/bin/protoc-gen-swagger pkg/proto/v0/example.pb.go pkg/proto/v0/example.pb.micro.go pkg/proto/v0/example.pb.web.go pkg/proto/v0/example.swagger.json
|
||||
.PHONY: protobuf
|
||||
protobuf: $(GOPATH)/bin/protoc-gen-go $(GOPATH)/bin/protoc-gen-micro $(GOPATH)/bin/protoc-gen-microweb $(GOPATH)/bin/protoc-gen-swagger pkg/proto/v0/settings.pb.go pkg/proto/v0/settings.pb.micro.go pkg/proto/v0/settings.pb.web.go pkg/proto/v0/settings.swagger.json
|
||||
|
||||
25
babel.config.js
Normal file
25
babel.config.js
Normal file
@@ -0,0 +1,25 @@
|
||||
module.exports = function (api) {
|
||||
api.cache(true)
|
||||
|
||||
const presets = [
|
||||
[
|
||||
'@babel/preset-env',
|
||||
{
|
||||
useBuiltIns: 'usage',
|
||||
corejs: '3'
|
||||
}
|
||||
]
|
||||
]
|
||||
const plugins = [
|
||||
'@babel/plugin-syntax-dynamic-import',
|
||||
'@babel/plugin-proposal-class-properties',
|
||||
'@babel/plugin-proposal-object-rest-spread',
|
||||
'@babel/plugin-transform-runtime',
|
||||
'@babel/plugin-proposal-export-default-from'
|
||||
]
|
||||
|
||||
return {
|
||||
presets,
|
||||
plugins
|
||||
}
|
||||
}
|
||||
@@ -10,4 +10,4 @@ func main() {
|
||||
if err := command.Execute(); err != nil {
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
17
go.mod
17
go.mod
@@ -8,11 +8,22 @@ require (
|
||||
contrib.go.opencensus.io/exporter/zipkin v0.1.1
|
||||
github.com/UnnoTed/fileb0x v1.1.4
|
||||
github.com/go-chi/chi v4.1.0+incompatible
|
||||
github.com/micro/cli/v2 v2.1.1
|
||||
github.com/go-chi/render v1.0.1
|
||||
github.com/golang/protobuf v1.4.0
|
||||
github.com/grpc-ecosystem/grpc-gateway v1.14.4
|
||||
github.com/micro/cli/v2 v2.1.2
|
||||
github.com/micro/go-micro/v2 v2.6.0
|
||||
github.com/oklog/run v1.0.0
|
||||
github.com/openzipkin/zipkin-go v0.2.2
|
||||
github.com/owncloud/ocis-pkg/v2 v2.2.0
|
||||
github.com/owncloud/ocis-hello v0.1.0-alpha1
|
||||
github.com/owncloud/ocis-pkg/v2 v2.0.1
|
||||
github.com/restic/calens v0.2.0
|
||||
github.com/spf13/viper v1.5.0
|
||||
github.com/spf13/viper v1.6.3
|
||||
go.opencensus.io v0.22.2
|
||||
golang.org/x/net v0.0.0-20200301022130-244492dfa37a
|
||||
google.golang.org/genproto v0.0.0-20200420144010-e5e8543f8aeb
|
||||
google.golang.org/grpc v1.27.0
|
||||
google.golang.org/protobuf v1.21.0
|
||||
)
|
||||
|
||||
replace google.golang.org/grpc => google.golang.org/grpc v1.26.0
|
||||
|
||||
67
package.json
Normal file
67
package.json
Normal file
@@ -0,0 +1,67 @@
|
||||
{
|
||||
"private": true,
|
||||
"name": "ocis-settings",
|
||||
"version": "0.0.0",
|
||||
"description": "",
|
||||
"homepage": "https://github.com/owncloud/ocis-settings#readme",
|
||||
"license": "Apache-2.0",
|
||||
"author": "ownCloud GmbH <devops@owncloud.com>",
|
||||
"repository": "https://github.com/owncloud/ocis-settings.git",
|
||||
"bugs": {
|
||||
"url": "https://github.com/owncloud/ocis-settings/issues",
|
||||
"email": "support@owncloud.com"
|
||||
},
|
||||
"scripts": {
|
||||
"lint": "eslint ui/**/*.vue ui/**/*.js --color --global requirejs --global require",
|
||||
"build": "rollup -c",
|
||||
"watch": "rollup -c -w",
|
||||
"test": "echo 'Not implemented'",
|
||||
"generate-api": "node node_modules/swagger-vue-generator/bin/generate-api.js --package-version v0 --source pkg/proto/v0/settings.swagger.json --moduleName settings --destination ui/client/settings/index.js"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.7.7",
|
||||
"@babel/plugin-proposal-class-properties": "^7.7.4",
|
||||
"@babel/plugin-proposal-export-default-from": "^7.7.4",
|
||||
"@babel/plugin-proposal-object-rest-spread": "^7.7.7",
|
||||
"@babel/plugin-syntax-dynamic-import": "^7.7.4",
|
||||
"@babel/plugin-transform-runtime": "^7.8.0",
|
||||
"@babel/preset-env": "^7.7.7",
|
||||
"@erquhart/rollup-plugin-node-builtins": "^2.1.5",
|
||||
"@rollup/plugin-commonjs": "^11.0.1",
|
||||
"@rollup/plugin-json": "^4.0.1",
|
||||
"@rollup/plugin-replace": "^2.3.0",
|
||||
"axios": "^0.19.0",
|
||||
"core-js": "3",
|
||||
"cross-env": "^6.0.3",
|
||||
"debounce": "^1.2.0",
|
||||
"easygettext": "^2.7.0",
|
||||
"eslint": "6.8.0",
|
||||
"eslint-config-standard": "^14.1.0",
|
||||
"eslint-plugin-import": "^2.17.3",
|
||||
"eslint-plugin-node": "11.0.0",
|
||||
"eslint-plugin-promise": "^4.1.1",
|
||||
"eslint-plugin-standard": "^4.0.0",
|
||||
"eslint-plugin-vue": "^6.1.2",
|
||||
"qs": "^6.9.1",
|
||||
"rimraf": "^3.0.0",
|
||||
"rollup": "^1.28.0",
|
||||
"rollup-plugin-babel": "^4.3.3",
|
||||
"rollup-plugin-eslint": "^7.0.0",
|
||||
"rollup-plugin-filesize": "^6.2.1",
|
||||
"rollup-plugin-node-globals": "^1.4.0",
|
||||
"rollup-plugin-node-resolve": "^5.2.0",
|
||||
"rollup-plugin-terser": "^5.1.3",
|
||||
"rollup-plugin-vue": "^5.1.4",
|
||||
"swagger-vue-generator": "^1.0.6",
|
||||
"vue-template-compiler": "^2.6.11"
|
||||
},
|
||||
"browserslist": [
|
||||
"> 1%",
|
||||
"not dead"
|
||||
],
|
||||
"dependencies": {
|
||||
"lodash": "^4.17.15",
|
||||
"owncloud-design-system": "^1.2.2",
|
||||
"vuex": "^3.2.0"
|
||||
}
|
||||
}
|
||||
66
pkg/assets/assets.go
Normal file
66
pkg/assets/assets.go
Normal file
@@ -0,0 +1,66 @@
|
||||
package assets
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"os"
|
||||
"path"
|
||||
|
||||
"github.com/owncloud/ocis-pkg/v2/log"
|
||||
"github.com/owncloud/ocis-settings/pkg/config"
|
||||
|
||||
// Fake the import to make the dep tree happy.
|
||||
_ "golang.org/x/net/context"
|
||||
|
||||
// Fake the import to make the dep tree happy.
|
||||
_ "golang.org/x/net/webdav"
|
||||
)
|
||||
|
||||
//go:generate go run github.com/UnnoTed/fileb0x embed.yml
|
||||
|
||||
// assets gets initialized by New and provides the handler.
|
||||
type assets struct {
|
||||
logger log.Logger
|
||||
config *config.Config
|
||||
}
|
||||
|
||||
// Open just implements the HTTP filesystem interface.
|
||||
func (a assets) Open(original string) (http.File, error) {
|
||||
if a.config.Asset.Path != "" {
|
||||
if stat, err := os.Stat(a.config.Asset.Path); err == nil && stat.IsDir() {
|
||||
custom := path.Join(
|
||||
a.config.Asset.Path,
|
||||
original,
|
||||
)
|
||||
|
||||
if _, err := os.Stat(custom); !os.IsNotExist(err) {
|
||||
f, err := os.Open(custom)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return f, nil
|
||||
}
|
||||
} else {
|
||||
a.logger.Warn().
|
||||
Str("path", a.config.Asset.Path).
|
||||
Msg("Assets directory doesn't exist")
|
||||
}
|
||||
}
|
||||
|
||||
return FS.OpenFile(
|
||||
CTX,
|
||||
original,
|
||||
os.O_RDONLY,
|
||||
0644,
|
||||
)
|
||||
}
|
||||
|
||||
// New returns a new http filesystem to serve assets.
|
||||
func New(opts ...Option) http.FileSystem {
|
||||
options := newOptions(opts...)
|
||||
|
||||
return assets{
|
||||
config: options.Config,
|
||||
}
|
||||
}
|
||||
202
pkg/assets/embed.go
Normal file
202
pkg/assets/embed.go
Normal file
File diff suppressed because one or more lines are too long
17
pkg/assets/embed.yml
Normal file
17
pkg/assets/embed.yml
Normal file
@@ -0,0 +1,17 @@
|
||||
---
|
||||
pkg: "assets"
|
||||
dest: "."
|
||||
output: "embed.go"
|
||||
fmt: true
|
||||
noprefix: true
|
||||
|
||||
compression:
|
||||
compress: true
|
||||
|
||||
custom:
|
||||
- files:
|
||||
- "../../assets/"
|
||||
base: "../../assets/"
|
||||
prefix: ""
|
||||
|
||||
...
|
||||
40
pkg/assets/option.go
Normal file
40
pkg/assets/option.go
Normal file
@@ -0,0 +1,40 @@
|
||||
package assets
|
||||
|
||||
import (
|
||||
"github.com/owncloud/ocis-pkg/v2/log"
|
||||
"github.com/owncloud/ocis-settings/pkg/config"
|
||||
)
|
||||
|
||||
// Option defines a single option function.
|
||||
type Option func(o *Options)
|
||||
|
||||
// Options defines the available options for this package.
|
||||
type Options struct {
|
||||
Logger log.Logger
|
||||
Config *config.Config
|
||||
}
|
||||
|
||||
// newOptions initializes the available default options.
|
||||
func newOptions(opts ...Option) Options {
|
||||
opt := Options{}
|
||||
|
||||
for _, o := range opts {
|
||||
o(&opt)
|
||||
}
|
||||
|
||||
return opt
|
||||
}
|
||||
|
||||
// Logger provides a function to set the logger option.
|
||||
func Logger(val log.Logger) Option {
|
||||
return func(o *Options) {
|
||||
o.Logger = val
|
||||
}
|
||||
}
|
||||
|
||||
// Config provides a function to set the config option.
|
||||
func Config(val *config.Config) Option {
|
||||
return func(o *Options) {
|
||||
o.Config = val
|
||||
}
|
||||
}
|
||||
@@ -5,10 +5,10 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/micro/cli/v2"
|
||||
"github.com/owncloud/ocis-pkg/v2/log"
|
||||
"github.com/owncloud/ocis-settings/pkg/config"
|
||||
"github.com/owncloud/ocis-settings/pkg/flagset"
|
||||
"github.com/owncloud/ocis-settings/pkg/version"
|
||||
"github.com/owncloud/ocis-pkg/v2/log"
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
|
||||
@@ -16,8 +16,8 @@ import (
|
||||
zipkinhttp "github.com/openzipkin/zipkin-go/reporter/http"
|
||||
"github.com/owncloud/ocis-settings/pkg/config"
|
||||
"github.com/owncloud/ocis-settings/pkg/flagset"
|
||||
"github.com/owncloud/ocis-settings/pkg/metrics"
|
||||
"github.com/owncloud/ocis-settings/pkg/server/debug"
|
||||
"github.com/owncloud/ocis-settings/pkg/server/grpc"
|
||||
"github.com/owncloud/ocis-settings/pkg/server/http"
|
||||
"go.opencensus.io/stats/view"
|
||||
"go.opencensus.io/trace"
|
||||
@@ -40,7 +40,6 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
},
|
||||
Action: func(c *cli.Context) error {
|
||||
logger := NewLogger(cfg)
|
||||
httpNamespace := c.String("http-namespace")
|
||||
|
||||
if cfg.Tracing.Enabled {
|
||||
switch t := cfg.Tracing.Type; t {
|
||||
@@ -129,34 +128,38 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
var (
|
||||
gr = run.Group{}
|
||||
ctx, cancel = context.WithCancel(context.Background())
|
||||
metrics = metrics.New()
|
||||
)
|
||||
|
||||
defer cancel()
|
||||
|
||||
{
|
||||
server, err := http.Server(
|
||||
server := http.Server(
|
||||
http.Name("settings"),
|
||||
http.Logger(logger),
|
||||
http.Namespace(httpNamespace),
|
||||
http.Context(ctx),
|
||||
http.Config(cfg),
|
||||
http.Metrics(metrics),
|
||||
http.Flags(flagset.RootWithConfig(config.New())),
|
||||
http.Flags(flagset.ServerWithConfig(config.New())),
|
||||
http.Flags(flagset.RootWithConfig(cfg)),
|
||||
http.Flags(flagset.ServerWithConfig(cfg)),
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
logger.Error().
|
||||
Err(err).
|
||||
gr.Add(server.Run, func(_ error) {
|
||||
logger.Info().
|
||||
Str("server", "http").
|
||||
Msg("Failed to initialize server")
|
||||
Msg("Shutting down server")
|
||||
|
||||
return err
|
||||
}
|
||||
cancel()
|
||||
})
|
||||
}
|
||||
|
||||
gr.Add(func() error {
|
||||
return server.Run()
|
||||
}, func(_ error) {
|
||||
{
|
||||
server := grpc.Server(
|
||||
grpc.Name("settings"),
|
||||
grpc.Logger(logger),
|
||||
grpc.Context(ctx),
|
||||
grpc.Config(cfg),
|
||||
)
|
||||
|
||||
gr.Add(server.Run, func(_ error) {
|
||||
logger.Info().
|
||||
Str("server", "http").
|
||||
Msg("Shutting down server")
|
||||
@@ -181,9 +184,7 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
return err
|
||||
}
|
||||
|
||||
gr.Add(func() error {
|
||||
return server.ListenAndServe()
|
||||
}, func(_ error) {
|
||||
gr.Add(server.ListenAndServe, func(_ error) {
|
||||
ctx, timeout := context.WithTimeout(ctx, 5*time.Second)
|
||||
|
||||
defer timeout()
|
||||
|
||||
@@ -22,6 +22,12 @@ type HTTP struct {
|
||||
Root string
|
||||
}
|
||||
|
||||
// GRPC defines the available grpc configuration.
|
||||
type GRPC struct {
|
||||
Addr string
|
||||
Namespace string
|
||||
}
|
||||
|
||||
// Tracing defines the available tracing configuration.
|
||||
type Tracing struct {
|
||||
Enabled bool
|
||||
@@ -31,13 +37,26 @@ type Tracing struct {
|
||||
Service string
|
||||
}
|
||||
|
||||
// Asset undocumented
|
||||
type Asset struct {
|
||||
Path string
|
||||
}
|
||||
|
||||
// Storage defines the available storage configuration.
|
||||
type Storage struct {
|
||||
RootMountPath string
|
||||
}
|
||||
|
||||
// Config combines all available configuration parts.
|
||||
type Config struct {
|
||||
File string
|
||||
Storage Storage
|
||||
Log Log
|
||||
Debug Debug
|
||||
HTTP HTTP
|
||||
GRPC GRPC
|
||||
Tracing Tracing
|
||||
Asset Asset
|
||||
}
|
||||
|
||||
// New initializes a new configuration with or without defaults.
|
||||
|
||||
@@ -136,5 +136,32 @@ func ServerWithConfig(cfg *config.Config) []cli.Flag {
|
||||
EnvVars: []string{"SETTINGS_HTTP_ROOT"},
|
||||
Destination: &cfg.HTTP.Root,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "grpc-addr",
|
||||
Value: "0.0.0.0:9191",
|
||||
Usage: "Address to bind grpc server",
|
||||
EnvVars: []string{"SETTINGS_GRPC_ADDR"},
|
||||
Destination: &cfg.GRPC.Addr,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "asset-path",
|
||||
Value: "",
|
||||
Usage: "Path to custom assets",
|
||||
EnvVars: []string{"SETTINGS_ASSET_PATH"},
|
||||
Destination: &cfg.Asset.Path,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "grpc-namespace",
|
||||
Value: "com.owncloud.api",
|
||||
Usage: "Set the base namespace for the grpc namespace",
|
||||
EnvVars: []string{"SETTINGS_GRPC_NAMESPACE"},
|
||||
Destination: &cfg.GRPC.Namespace,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "mount-path",
|
||||
Usage: "Mount path for the storage",
|
||||
EnvVars: []string{"SETTINGS_ROOT_MOUNT_PATH"},
|
||||
Destination: &cfg.Storage.RootMountPath,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
2238
pkg/proto/v0/settings.pb.go
Normal file
2238
pkg/proto/v0/settings.pb.go
Normal file
File diff suppressed because it is too large
Load Diff
308
pkg/proto/v0/settings.pb.micro.go
Normal file
308
pkg/proto/v0/settings.pb.micro.go
Normal file
@@ -0,0 +1,308 @@
|
||||
// Code generated by protoc-gen-micro. DO NOT EDIT.
|
||||
// source: settings.proto
|
||||
|
||||
package proto
|
||||
|
||||
import (
|
||||
fmt "fmt"
|
||||
proto "github.com/golang/protobuf/proto"
|
||||
_ "github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/options"
|
||||
_ "google.golang.org/genproto/googleapis/api/annotations"
|
||||
math "math"
|
||||
)
|
||||
|
||||
import (
|
||||
context "context"
|
||||
api "github.com/micro/go-micro/v2/api"
|
||||
client "github.com/micro/go-micro/v2/client"
|
||||
server "github.com/micro/go-micro/v2/server"
|
||||
)
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ = proto.Marshal
|
||||
var _ = fmt.Errorf
|
||||
var _ = math.Inf
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the proto package it is being compiled against.
|
||||
// A compilation error at this line likely means your copy of the
|
||||
// proto package needs to be updated.
|
||||
const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ api.Endpoint
|
||||
var _ context.Context
|
||||
var _ client.Option
|
||||
var _ server.Option
|
||||
|
||||
// Api Endpoints for BundleService service
|
||||
|
||||
func NewBundleServiceEndpoints() []*api.Endpoint {
|
||||
return []*api.Endpoint{
|
||||
&api.Endpoint{
|
||||
Name: "BundleService.SaveSettingsBundle",
|
||||
Path: []string{"/api/v0/settings/bundle-save"},
|
||||
Method: []string{"POST"},
|
||||
Body: "*",
|
||||
Handler: "rpc",
|
||||
},
|
||||
&api.Endpoint{
|
||||
Name: "BundleService.GetSettingsBundle",
|
||||
Path: []string{"/api/v0/settings/bundle-get"},
|
||||
Method: []string{"POST"},
|
||||
Body: "*",
|
||||
Handler: "rpc",
|
||||
},
|
||||
&api.Endpoint{
|
||||
Name: "BundleService.ListSettingsBundles",
|
||||
Path: []string{"/api/v0/settings/bundles-list"},
|
||||
Method: []string{"POST"},
|
||||
Body: "*",
|
||||
Handler: "rpc",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// Client API for BundleService service
|
||||
|
||||
type BundleService interface {
|
||||
SaveSettingsBundle(ctx context.Context, in *SaveSettingsBundleRequest, opts ...client.CallOption) (*SaveSettingsBundleResponse, error)
|
||||
GetSettingsBundle(ctx context.Context, in *GetSettingsBundleRequest, opts ...client.CallOption) (*GetSettingsBundleResponse, error)
|
||||
ListSettingsBundles(ctx context.Context, in *ListSettingsBundlesRequest, opts ...client.CallOption) (*ListSettingsBundlesResponse, error)
|
||||
}
|
||||
|
||||
type bundleService struct {
|
||||
c client.Client
|
||||
name string
|
||||
}
|
||||
|
||||
func NewBundleService(name string, c client.Client) BundleService {
|
||||
return &bundleService{
|
||||
c: c,
|
||||
name: name,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *bundleService) SaveSettingsBundle(ctx context.Context, in *SaveSettingsBundleRequest, opts ...client.CallOption) (*SaveSettingsBundleResponse, error) {
|
||||
req := c.c.NewRequest(c.name, "BundleService.SaveSettingsBundle", in)
|
||||
out := new(SaveSettingsBundleResponse)
|
||||
err := c.c.Call(ctx, req, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *bundleService) GetSettingsBundle(ctx context.Context, in *GetSettingsBundleRequest, opts ...client.CallOption) (*GetSettingsBundleResponse, error) {
|
||||
req := c.c.NewRequest(c.name, "BundleService.GetSettingsBundle", in)
|
||||
out := new(GetSettingsBundleResponse)
|
||||
err := c.c.Call(ctx, req, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *bundleService) ListSettingsBundles(ctx context.Context, in *ListSettingsBundlesRequest, opts ...client.CallOption) (*ListSettingsBundlesResponse, error) {
|
||||
req := c.c.NewRequest(c.name, "BundleService.ListSettingsBundles", in)
|
||||
out := new(ListSettingsBundlesResponse)
|
||||
err := c.c.Call(ctx, req, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// Server API for BundleService service
|
||||
|
||||
type BundleServiceHandler interface {
|
||||
SaveSettingsBundle(context.Context, *SaveSettingsBundleRequest, *SaveSettingsBundleResponse) error
|
||||
GetSettingsBundle(context.Context, *GetSettingsBundleRequest, *GetSettingsBundleResponse) error
|
||||
ListSettingsBundles(context.Context, *ListSettingsBundlesRequest, *ListSettingsBundlesResponse) error
|
||||
}
|
||||
|
||||
func RegisterBundleServiceHandler(s server.Server, hdlr BundleServiceHandler, opts ...server.HandlerOption) error {
|
||||
type bundleService interface {
|
||||
SaveSettingsBundle(ctx context.Context, in *SaveSettingsBundleRequest, out *SaveSettingsBundleResponse) error
|
||||
GetSettingsBundle(ctx context.Context, in *GetSettingsBundleRequest, out *GetSettingsBundleResponse) error
|
||||
ListSettingsBundles(ctx context.Context, in *ListSettingsBundlesRequest, out *ListSettingsBundlesResponse) error
|
||||
}
|
||||
type BundleService struct {
|
||||
bundleService
|
||||
}
|
||||
h := &bundleServiceHandler{hdlr}
|
||||
opts = append(opts, api.WithEndpoint(&api.Endpoint{
|
||||
Name: "BundleService.SaveSettingsBundle",
|
||||
Path: []string{"/api/v0/settings/bundle-save"},
|
||||
Method: []string{"POST"},
|
||||
Body: "*",
|
||||
Handler: "rpc",
|
||||
}))
|
||||
opts = append(opts, api.WithEndpoint(&api.Endpoint{
|
||||
Name: "BundleService.GetSettingsBundle",
|
||||
Path: []string{"/api/v0/settings/bundle-get"},
|
||||
Method: []string{"POST"},
|
||||
Body: "*",
|
||||
Handler: "rpc",
|
||||
}))
|
||||
opts = append(opts, api.WithEndpoint(&api.Endpoint{
|
||||
Name: "BundleService.ListSettingsBundles",
|
||||
Path: []string{"/api/v0/settings/bundles-list"},
|
||||
Method: []string{"POST"},
|
||||
Body: "*",
|
||||
Handler: "rpc",
|
||||
}))
|
||||
return s.Handle(s.NewHandler(&BundleService{h}, opts...))
|
||||
}
|
||||
|
||||
type bundleServiceHandler struct {
|
||||
BundleServiceHandler
|
||||
}
|
||||
|
||||
func (h *bundleServiceHandler) SaveSettingsBundle(ctx context.Context, in *SaveSettingsBundleRequest, out *SaveSettingsBundleResponse) error {
|
||||
return h.BundleServiceHandler.SaveSettingsBundle(ctx, in, out)
|
||||
}
|
||||
|
||||
func (h *bundleServiceHandler) GetSettingsBundle(ctx context.Context, in *GetSettingsBundleRequest, out *GetSettingsBundleResponse) error {
|
||||
return h.BundleServiceHandler.GetSettingsBundle(ctx, in, out)
|
||||
}
|
||||
|
||||
func (h *bundleServiceHandler) ListSettingsBundles(ctx context.Context, in *ListSettingsBundlesRequest, out *ListSettingsBundlesResponse) error {
|
||||
return h.BundleServiceHandler.ListSettingsBundles(ctx, in, out)
|
||||
}
|
||||
|
||||
// Api Endpoints for ValueService service
|
||||
|
||||
func NewValueServiceEndpoints() []*api.Endpoint {
|
||||
return []*api.Endpoint{
|
||||
&api.Endpoint{
|
||||
Name: "ValueService.SaveSettingsValue",
|
||||
Path: []string{"/api/v0/settings/value-save"},
|
||||
Method: []string{"POST"},
|
||||
Body: "*",
|
||||
Handler: "rpc",
|
||||
},
|
||||
&api.Endpoint{
|
||||
Name: "ValueService.GetSettingsValue",
|
||||
Path: []string{"/api/v0/settings/value-get"},
|
||||
Method: []string{"POST"},
|
||||
Body: "*",
|
||||
Handler: "rpc",
|
||||
},
|
||||
&api.Endpoint{
|
||||
Name: "ValueService.ListSettingsValues",
|
||||
Path: []string{"/api/v0/settings/values-list"},
|
||||
Method: []string{"POST"},
|
||||
Body: "*",
|
||||
Handler: "rpc",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// Client API for ValueService service
|
||||
|
||||
type ValueService interface {
|
||||
SaveSettingsValue(ctx context.Context, in *SaveSettingsValueRequest, opts ...client.CallOption) (*SaveSettingsValueResponse, error)
|
||||
GetSettingsValue(ctx context.Context, in *GetSettingsValueRequest, opts ...client.CallOption) (*GetSettingsValueResponse, error)
|
||||
ListSettingsValues(ctx context.Context, in *ListSettingsValuesRequest, opts ...client.CallOption) (*ListSettingsValuesResponse, error)
|
||||
}
|
||||
|
||||
type valueService struct {
|
||||
c client.Client
|
||||
name string
|
||||
}
|
||||
|
||||
func NewValueService(name string, c client.Client) ValueService {
|
||||
return &valueService{
|
||||
c: c,
|
||||
name: name,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *valueService) SaveSettingsValue(ctx context.Context, in *SaveSettingsValueRequest, opts ...client.CallOption) (*SaveSettingsValueResponse, error) {
|
||||
req := c.c.NewRequest(c.name, "ValueService.SaveSettingsValue", in)
|
||||
out := new(SaveSettingsValueResponse)
|
||||
err := c.c.Call(ctx, req, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *valueService) GetSettingsValue(ctx context.Context, in *GetSettingsValueRequest, opts ...client.CallOption) (*GetSettingsValueResponse, error) {
|
||||
req := c.c.NewRequest(c.name, "ValueService.GetSettingsValue", in)
|
||||
out := new(GetSettingsValueResponse)
|
||||
err := c.c.Call(ctx, req, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *valueService) ListSettingsValues(ctx context.Context, in *ListSettingsValuesRequest, opts ...client.CallOption) (*ListSettingsValuesResponse, error) {
|
||||
req := c.c.NewRequest(c.name, "ValueService.ListSettingsValues", in)
|
||||
out := new(ListSettingsValuesResponse)
|
||||
err := c.c.Call(ctx, req, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// Server API for ValueService service
|
||||
|
||||
type ValueServiceHandler interface {
|
||||
SaveSettingsValue(context.Context, *SaveSettingsValueRequest, *SaveSettingsValueResponse) error
|
||||
GetSettingsValue(context.Context, *GetSettingsValueRequest, *GetSettingsValueResponse) error
|
||||
ListSettingsValues(context.Context, *ListSettingsValuesRequest, *ListSettingsValuesResponse) error
|
||||
}
|
||||
|
||||
func RegisterValueServiceHandler(s server.Server, hdlr ValueServiceHandler, opts ...server.HandlerOption) error {
|
||||
type valueService interface {
|
||||
SaveSettingsValue(ctx context.Context, in *SaveSettingsValueRequest, out *SaveSettingsValueResponse) error
|
||||
GetSettingsValue(ctx context.Context, in *GetSettingsValueRequest, out *GetSettingsValueResponse) error
|
||||
ListSettingsValues(ctx context.Context, in *ListSettingsValuesRequest, out *ListSettingsValuesResponse) error
|
||||
}
|
||||
type ValueService struct {
|
||||
valueService
|
||||
}
|
||||
h := &valueServiceHandler{hdlr}
|
||||
opts = append(opts, api.WithEndpoint(&api.Endpoint{
|
||||
Name: "ValueService.SaveSettingsValue",
|
||||
Path: []string{"/api/v0/settings/value-save"},
|
||||
Method: []string{"POST"},
|
||||
Body: "*",
|
||||
Handler: "rpc",
|
||||
}))
|
||||
opts = append(opts, api.WithEndpoint(&api.Endpoint{
|
||||
Name: "ValueService.GetSettingsValue",
|
||||
Path: []string{"/api/v0/settings/value-get"},
|
||||
Method: []string{"POST"},
|
||||
Body: "*",
|
||||
Handler: "rpc",
|
||||
}))
|
||||
opts = append(opts, api.WithEndpoint(&api.Endpoint{
|
||||
Name: "ValueService.ListSettingsValues",
|
||||
Path: []string{"/api/v0/settings/values-list"},
|
||||
Method: []string{"POST"},
|
||||
Body: "*",
|
||||
Handler: "rpc",
|
||||
}))
|
||||
return s.Handle(s.NewHandler(&ValueService{h}, opts...))
|
||||
}
|
||||
|
||||
type valueServiceHandler struct {
|
||||
ValueServiceHandler
|
||||
}
|
||||
|
||||
func (h *valueServiceHandler) SaveSettingsValue(ctx context.Context, in *SaveSettingsValueRequest, out *SaveSettingsValueResponse) error {
|
||||
return h.ValueServiceHandler.SaveSettingsValue(ctx, in, out)
|
||||
}
|
||||
|
||||
func (h *valueServiceHandler) GetSettingsValue(ctx context.Context, in *GetSettingsValueRequest, out *GetSettingsValueResponse) error {
|
||||
return h.ValueServiceHandler.GetSettingsValue(ctx, in, out)
|
||||
}
|
||||
|
||||
func (h *valueServiceHandler) ListSettingsValues(ctx context.Context, in *ListSettingsValuesRequest, out *ListSettingsValuesResponse) error {
|
||||
return h.ValueServiceHandler.ListSettingsValues(ctx, in, out)
|
||||
}
|
||||
1099
pkg/proto/v0/settings.pb.web.go
Normal file
1099
pkg/proto/v0/settings.pb.web.go
Normal file
File diff suppressed because it is too large
Load Diff
213
pkg/proto/v0/settings.proto
Normal file
213
pkg/proto/v0/settings.proto
Normal file
@@ -0,0 +1,213 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package proto;
|
||||
option go_package = ".;proto";
|
||||
|
||||
import "google/api/annotations.proto";
|
||||
import "protoc-gen-swagger/options/annotations.proto";
|
||||
|
||||
option (grpc.gateway.protoc_gen_swagger.options.openapiv2_swagger) = {
|
||||
info: {
|
||||
title: "Settings";
|
||||
version: "1.0";
|
||||
contact: {
|
||||
name: "ownCloud GmbH";
|
||||
url: "https://github.com/owncloud/ocis-settings";
|
||||
email: "support@owncloud.com";
|
||||
};
|
||||
license: {
|
||||
name: "Apache-2.0";
|
||||
url: "https://github.com/owncloud/ocis-settings/blob/master/LICENSE";
|
||||
};
|
||||
};
|
||||
schemes: HTTP;
|
||||
schemes: HTTPS;
|
||||
consumes: "application/json";
|
||||
produces: "application/json";
|
||||
external_docs: {
|
||||
description: "Developer Manual";
|
||||
url: "http://owncloud.github.io/extensions/ocis_settings/";
|
||||
};
|
||||
};
|
||||
|
||||
service BundleService {
|
||||
rpc SaveSettingsBundle(SaveSettingsBundleRequest) returns (SaveSettingsBundleResponse) {
|
||||
option (google.api.http) = {
|
||||
post: "/api/v0/settings/bundle-save",
|
||||
body: "*"
|
||||
};
|
||||
};
|
||||
rpc GetSettingsBundle(GetSettingsBundleRequest) returns (GetSettingsBundleResponse) {
|
||||
option (google.api.http) = {
|
||||
post: "/api/v0/settings/bundle-get",
|
||||
body: "*"
|
||||
};
|
||||
};
|
||||
rpc ListSettingsBundles(ListSettingsBundlesRequest) returns (ListSettingsBundlesResponse) {
|
||||
option (google.api.http) = {
|
||||
post: "/api/v0/settings/bundles-list",
|
||||
body: "*"
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
service ValueService {
|
||||
rpc SaveSettingsValue(SaveSettingsValueRequest) returns (SaveSettingsValueResponse) {
|
||||
option (google.api.http) = {
|
||||
post: "/api/v0/settings/value-save",
|
||||
body: "*"
|
||||
};
|
||||
};
|
||||
rpc GetSettingsValue(GetSettingsValueRequest) returns (GetSettingsValueResponse) {
|
||||
option (google.api.http) = {
|
||||
post: "/api/v0/settings/value-get",
|
||||
body: "*"
|
||||
};
|
||||
};
|
||||
rpc ListSettingsValues(ListSettingsValuesRequest) returns (ListSettingsValuesResponse) {
|
||||
option (google.api.http) = {
|
||||
post: "/api/v0/settings/values-list",
|
||||
body: "*"
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
// requests and responses for settings bundles
|
||||
message SaveSettingsBundleRequest {
|
||||
SettingsBundle settings_bundle = 1;
|
||||
}
|
||||
|
||||
message SaveSettingsBundleResponse {
|
||||
SettingsBundle settings_bundle = 1;
|
||||
}
|
||||
|
||||
message GetSettingsBundleRequest {
|
||||
Identifier identifier = 1;
|
||||
}
|
||||
|
||||
message GetSettingsBundleResponse {
|
||||
SettingsBundle settings_bundle = 1;
|
||||
}
|
||||
|
||||
message ListSettingsBundlesRequest {
|
||||
Identifier identifier = 1;
|
||||
}
|
||||
|
||||
message ListSettingsBundlesResponse {
|
||||
repeated SettingsBundle settings_bundles = 1;
|
||||
}
|
||||
|
||||
// requests and responses for settings values
|
||||
message SaveSettingsValueRequest {
|
||||
SettingsValue settings_value = 1;
|
||||
}
|
||||
|
||||
message SaveSettingsValueResponse {
|
||||
SettingsValue settings_value = 1;
|
||||
}
|
||||
|
||||
message GetSettingsValueRequest {
|
||||
Identifier identifier = 1;
|
||||
}
|
||||
|
||||
message GetSettingsValueResponse {
|
||||
SettingsValue settings_value = 1;
|
||||
}
|
||||
|
||||
message ListSettingsValuesRequest {
|
||||
Identifier identifier = 1;
|
||||
}
|
||||
|
||||
message ListSettingsValuesResponse {
|
||||
repeated SettingsValue settings_values = 1;
|
||||
}
|
||||
|
||||
// generic payloads
|
||||
message Identifier {
|
||||
string extension = 1;
|
||||
string bundle_key = 2;
|
||||
string setting_key = 3;
|
||||
string account_uuid = 4;
|
||||
}
|
||||
|
||||
// payloads for settings bundles
|
||||
message SettingsBundle {
|
||||
Identifier identifier = 1;
|
||||
string display_name = 2;
|
||||
repeated Setting settings = 3;
|
||||
}
|
||||
|
||||
message Setting {
|
||||
string setting_key = 1;
|
||||
string display_name = 2;
|
||||
string description = 3;
|
||||
oneof value {
|
||||
IntSetting int_value = 4;
|
||||
StringSetting string_value = 5;
|
||||
BoolSetting bool_value = 6;
|
||||
SingleChoiceListSetting single_choice_value = 7;
|
||||
MultiChoiceListSetting multi_choice_value = 8;
|
||||
}
|
||||
}
|
||||
|
||||
message IntSetting {
|
||||
int64 default = 1;
|
||||
int64 min = 2;
|
||||
int64 max = 3;
|
||||
int64 step = 4;
|
||||
string placeholder = 5;
|
||||
}
|
||||
|
||||
message StringSetting {
|
||||
string default = 1;
|
||||
bool required = 2;
|
||||
int32 min_length = 3;
|
||||
int32 max_length = 4;
|
||||
string placeholder = 5;
|
||||
}
|
||||
|
||||
message BoolSetting {
|
||||
bool default = 1;
|
||||
string label = 2;
|
||||
}
|
||||
|
||||
message SingleChoiceListSetting {
|
||||
repeated ListOption options = 1;
|
||||
}
|
||||
|
||||
message MultiChoiceListSetting {
|
||||
repeated ListOption options = 1;
|
||||
}
|
||||
|
||||
message ListOption {
|
||||
ListOptionValue value = 1;
|
||||
bool default = 2;
|
||||
string display_value = 3;
|
||||
}
|
||||
|
||||
// payloads for settings values
|
||||
message SettingsValue {
|
||||
Identifier identifier = 1;
|
||||
oneof value {
|
||||
bool bool_value = 2;
|
||||
int64 int_value = 3;
|
||||
string string_value = 4;
|
||||
ListValue list_value = 5;
|
||||
}
|
||||
}
|
||||
|
||||
message ListValue {
|
||||
repeated ListOptionValue values = 1;
|
||||
}
|
||||
|
||||
message ListOptionValue {
|
||||
oneof option {
|
||||
string string_value = 1;
|
||||
int64 int_value = 2;
|
||||
}
|
||||
}
|
||||
|
||||
// only meant for serialization
|
||||
message SettingsValues {
|
||||
map<string, SettingsValue> values = 1;
|
||||
}
|
||||
573
pkg/proto/v0/settings.swagger.json
Normal file
573
pkg/proto/v0/settings.swagger.json
Normal file
@@ -0,0 +1,573 @@
|
||||
{
|
||||
"swagger": "2.0",
|
||||
"info": {
|
||||
"title": "Settings",
|
||||
"version": "1.0",
|
||||
"contact": {
|
||||
"name": "ownCloud GmbH",
|
||||
"url": "https://github.com/owncloud/ocis-settings",
|
||||
"email": "support@owncloud.com"
|
||||
},
|
||||
"license": {
|
||||
"name": "Apache-2.0",
|
||||
"url": "https://github.com/owncloud/ocis-settings/blob/master/LICENSE"
|
||||
}
|
||||
},
|
||||
"schemes": [
|
||||
"http",
|
||||
"https"
|
||||
],
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"paths": {
|
||||
"/api/v0/settings/bundle-get": {
|
||||
"post": {
|
||||
"operationId": "BundleService_GetSettingsBundle",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "A successful response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/protoGetSettingsBundleResponse"
|
||||
}
|
||||
},
|
||||
"default": {
|
||||
"description": "An unexpected error response",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/runtimeError"
|
||||
}
|
||||
}
|
||||
},
|
||||
"parameters": [
|
||||
{
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/protoGetSettingsBundleRequest"
|
||||
}
|
||||
}
|
||||
],
|
||||
"tags": [
|
||||
"BundleService"
|
||||
]
|
||||
}
|
||||
},
|
||||
"/api/v0/settings/bundle-save": {
|
||||
"post": {
|
||||
"operationId": "BundleService_SaveSettingsBundle",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "A successful response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/protoSaveSettingsBundleResponse"
|
||||
}
|
||||
},
|
||||
"default": {
|
||||
"description": "An unexpected error response",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/runtimeError"
|
||||
}
|
||||
}
|
||||
},
|
||||
"parameters": [
|
||||
{
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/protoSaveSettingsBundleRequest"
|
||||
}
|
||||
}
|
||||
],
|
||||
"tags": [
|
||||
"BundleService"
|
||||
]
|
||||
}
|
||||
},
|
||||
"/api/v0/settings/bundles-list": {
|
||||
"post": {
|
||||
"operationId": "BundleService_ListSettingsBundles",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "A successful response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/protoListSettingsBundlesResponse"
|
||||
}
|
||||
},
|
||||
"default": {
|
||||
"description": "An unexpected error response",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/runtimeError"
|
||||
}
|
||||
}
|
||||
},
|
||||
"parameters": [
|
||||
{
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/protoListSettingsBundlesRequest"
|
||||
}
|
||||
}
|
||||
],
|
||||
"tags": [
|
||||
"BundleService"
|
||||
]
|
||||
}
|
||||
},
|
||||
"/api/v0/settings/value-get": {
|
||||
"post": {
|
||||
"operationId": "ValueService_GetSettingsValue",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "A successful response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/protoGetSettingsValueResponse"
|
||||
}
|
||||
},
|
||||
"default": {
|
||||
"description": "An unexpected error response",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/runtimeError"
|
||||
}
|
||||
}
|
||||
},
|
||||
"parameters": [
|
||||
{
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/protoGetSettingsValueRequest"
|
||||
}
|
||||
}
|
||||
],
|
||||
"tags": [
|
||||
"ValueService"
|
||||
]
|
||||
}
|
||||
},
|
||||
"/api/v0/settings/value-save": {
|
||||
"post": {
|
||||
"operationId": "ValueService_SaveSettingsValue",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "A successful response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/protoSaveSettingsValueResponse"
|
||||
}
|
||||
},
|
||||
"default": {
|
||||
"description": "An unexpected error response",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/runtimeError"
|
||||
}
|
||||
}
|
||||
},
|
||||
"parameters": [
|
||||
{
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/protoSaveSettingsValueRequest"
|
||||
}
|
||||
}
|
||||
],
|
||||
"tags": [
|
||||
"ValueService"
|
||||
]
|
||||
}
|
||||
},
|
||||
"/api/v0/settings/values-list": {
|
||||
"post": {
|
||||
"operationId": "ValueService_ListSettingsValues",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "A successful response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/protoListSettingsValuesResponse"
|
||||
}
|
||||
},
|
||||
"default": {
|
||||
"description": "An unexpected error response",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/runtimeError"
|
||||
}
|
||||
}
|
||||
},
|
||||
"parameters": [
|
||||
{
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/protoListSettingsValuesRequest"
|
||||
}
|
||||
}
|
||||
],
|
||||
"tags": [
|
||||
"ValueService"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"definitions": {
|
||||
"protoBoolSetting": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"default": {
|
||||
"type": "boolean",
|
||||
"format": "boolean"
|
||||
},
|
||||
"label": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"protoGetSettingsBundleRequest": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"identifier": {
|
||||
"$ref": "#/definitions/protoIdentifier"
|
||||
}
|
||||
}
|
||||
},
|
||||
"protoGetSettingsBundleResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"settings_bundle": {
|
||||
"$ref": "#/definitions/protoSettingsBundle"
|
||||
}
|
||||
}
|
||||
},
|
||||
"protoGetSettingsValueRequest": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"identifier": {
|
||||
"$ref": "#/definitions/protoIdentifier"
|
||||
}
|
||||
}
|
||||
},
|
||||
"protoGetSettingsValueResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"settings_value": {
|
||||
"$ref": "#/definitions/protoSettingsValue"
|
||||
}
|
||||
}
|
||||
},
|
||||
"protoIdentifier": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"extension": {
|
||||
"type": "string"
|
||||
},
|
||||
"bundle_key": {
|
||||
"type": "string"
|
||||
},
|
||||
"setting_key": {
|
||||
"type": "string"
|
||||
},
|
||||
"account_uuid": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"title": "generic payloads"
|
||||
},
|
||||
"protoIntSetting": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"default": {
|
||||
"type": "string",
|
||||
"format": "int64"
|
||||
},
|
||||
"min": {
|
||||
"type": "string",
|
||||
"format": "int64"
|
||||
},
|
||||
"max": {
|
||||
"type": "string",
|
||||
"format": "int64"
|
||||
},
|
||||
"step": {
|
||||
"type": "string",
|
||||
"format": "int64"
|
||||
},
|
||||
"placeholder": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"protoListOption": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"value": {
|
||||
"$ref": "#/definitions/protoListOptionValue"
|
||||
},
|
||||
"default": {
|
||||
"type": "boolean",
|
||||
"format": "boolean"
|
||||
},
|
||||
"display_value": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"protoListOptionValue": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"string_value": {
|
||||
"type": "string"
|
||||
},
|
||||
"int_value": {
|
||||
"type": "string",
|
||||
"format": "int64"
|
||||
}
|
||||
}
|
||||
},
|
||||
"protoListSettingsBundlesRequest": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"identifier": {
|
||||
"$ref": "#/definitions/protoIdentifier"
|
||||
}
|
||||
}
|
||||
},
|
||||
"protoListSettingsBundlesResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"settings_bundles": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/protoSettingsBundle"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"protoListSettingsValuesRequest": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"identifier": {
|
||||
"$ref": "#/definitions/protoIdentifier"
|
||||
}
|
||||
}
|
||||
},
|
||||
"protoListSettingsValuesResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"settings_values": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/protoSettingsValue"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"protoListValue": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"values": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/protoListOptionValue"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"protoMultiChoiceListSetting": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"options": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/protoListOption"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"protoSaveSettingsBundleRequest": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"settings_bundle": {
|
||||
"$ref": "#/definitions/protoSettingsBundle"
|
||||
}
|
||||
},
|
||||
"title": "requests and responses for settings bundles"
|
||||
},
|
||||
"protoSaveSettingsBundleResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"settings_bundle": {
|
||||
"$ref": "#/definitions/protoSettingsBundle"
|
||||
}
|
||||
}
|
||||
},
|
||||
"protoSaveSettingsValueRequest": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"settings_value": {
|
||||
"$ref": "#/definitions/protoSettingsValue"
|
||||
}
|
||||
},
|
||||
"title": "requests and responses for settings values"
|
||||
},
|
||||
"protoSaveSettingsValueResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"settings_value": {
|
||||
"$ref": "#/definitions/protoSettingsValue"
|
||||
}
|
||||
}
|
||||
},
|
||||
"protoSetting": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"setting_key": {
|
||||
"type": "string"
|
||||
},
|
||||
"display_name": {
|
||||
"type": "string"
|
||||
},
|
||||
"description": {
|
||||
"type": "string"
|
||||
},
|
||||
"int_value": {
|
||||
"$ref": "#/definitions/protoIntSetting"
|
||||
},
|
||||
"string_value": {
|
||||
"$ref": "#/definitions/protoStringSetting"
|
||||
},
|
||||
"bool_value": {
|
||||
"$ref": "#/definitions/protoBoolSetting"
|
||||
},
|
||||
"single_choice_value": {
|
||||
"$ref": "#/definitions/protoSingleChoiceListSetting"
|
||||
},
|
||||
"multi_choice_value": {
|
||||
"$ref": "#/definitions/protoMultiChoiceListSetting"
|
||||
}
|
||||
}
|
||||
},
|
||||
"protoSettingsBundle": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"identifier": {
|
||||
"$ref": "#/definitions/protoIdentifier"
|
||||
},
|
||||
"display_name": {
|
||||
"type": "string"
|
||||
},
|
||||
"settings": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/protoSetting"
|
||||
}
|
||||
}
|
||||
},
|
||||
"title": "payloads for settings bundles"
|
||||
},
|
||||
"protoSettingsValue": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"identifier": {
|
||||
"$ref": "#/definitions/protoIdentifier"
|
||||
},
|
||||
"bool_value": {
|
||||
"type": "boolean",
|
||||
"format": "boolean"
|
||||
},
|
||||
"int_value": {
|
||||
"type": "string",
|
||||
"format": "int64"
|
||||
},
|
||||
"string_value": {
|
||||
"type": "string"
|
||||
},
|
||||
"list_value": {
|
||||
"$ref": "#/definitions/protoListValue"
|
||||
}
|
||||
},
|
||||
"title": "payloads for settings values"
|
||||
},
|
||||
"protoSingleChoiceListSetting": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"options": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/protoListOption"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"protoStringSetting": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"default": {
|
||||
"type": "string"
|
||||
},
|
||||
"required": {
|
||||
"type": "boolean",
|
||||
"format": "boolean"
|
||||
},
|
||||
"min_length": {
|
||||
"type": "integer",
|
||||
"format": "int32"
|
||||
},
|
||||
"max_length": {
|
||||
"type": "integer",
|
||||
"format": "int32"
|
||||
},
|
||||
"placeholder": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"protobufAny": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"type_url": {
|
||||
"type": "string",
|
||||
"description": "A URL/resource name that uniquely identifies the type of the serialized\nprotocol buffer message. The last segment of the URL's path must represent\nthe fully qualified name of the type (as in\n`path/google.protobuf.Duration`). The name should be in a canonical form\n(e.g., leading \".\" is not accepted).\n\nIn practice, teams usually precompile into the binary all types that they\nexpect it to use in the context of Any. However, for URLs which use the\nscheme `http`, `https`, or no scheme, one can optionally set up a type\nserver that maps type URLs to message definitions as follows:\n\n* If no scheme is provided, `https` is assumed.\n* An HTTP GET on the URL must yield a [google.protobuf.Type][]\n value in binary format, or produce an error.\n* Applications are allowed to cache lookup results based on the\n URL, or have them precompiled into a binary to avoid any\n lookup. Therefore, binary compatibility needs to be preserved\n on changes to types. (Use versioned type names to manage\n breaking changes.)\n\nNote: this functionality is not currently available in the official\nprotobuf release, and it is not used for type URLs beginning with\ntype.googleapis.com.\n\nSchemes other than `http`, `https` (or the empty scheme) might be\nused with implementation specific semantics."
|
||||
},
|
||||
"value": {
|
||||
"type": "string",
|
||||
"format": "byte",
|
||||
"description": "Must be a valid serialized protocol buffer of the above specified type."
|
||||
}
|
||||
},
|
||||
"description": "`Any` contains an arbitrary serialized protocol buffer message along with a\nURL that describes the type of the serialized message.\n\nProtobuf library provides support to pack/unpack Any values in the form\nof utility functions or additional generated methods of the Any type.\n\nExample 1: Pack and unpack a message in C++.\n\n Foo foo = ...;\n Any any;\n any.PackFrom(foo);\n ...\n if (any.UnpackTo(\u0026foo)) {\n ...\n }\n\nExample 2: Pack and unpack a message in Java.\n\n Foo foo = ...;\n Any any = Any.pack(foo);\n ...\n if (any.is(Foo.class)) {\n foo = any.unpack(Foo.class);\n }\n\n Example 3: Pack and unpack a message in Python.\n\n foo = Foo(...)\n any = Any()\n any.Pack(foo)\n ...\n if any.Is(Foo.DESCRIPTOR):\n any.Unpack(foo)\n ...\n\n Example 4: Pack and unpack a message in Go\n\n foo := \u0026pb.Foo{...}\n any, err := ptypes.MarshalAny(foo)\n ...\n foo := \u0026pb.Foo{}\n if err := ptypes.UnmarshalAny(any, foo); err != nil {\n ...\n }\n\nThe pack methods provided by protobuf library will by default use\n'type.googleapis.com/full.type.name' as the type URL and the unpack\nmethods only use the fully qualified type name after the last '/'\nin the type URL, for example \"foo.bar.com/x/y.z\" will yield type\nname \"y.z\".\n\n\nJSON\n====\nThe JSON representation of an `Any` value uses the regular\nrepresentation of the deserialized, embedded message, with an\nadditional field `@type` which contains the type URL. Example:\n\n package google.profile;\n message Person {\n string first_name = 1;\n string last_name = 2;\n }\n\n {\n \"@type\": \"type.googleapis.com/google.profile.Person\",\n \"firstName\": \u003cstring\u003e,\n \"lastName\": \u003cstring\u003e\n }\n\nIf the embedded message type is well-known and has a custom JSON\nrepresentation, that representation will be embedded adding a field\n`value` which holds the custom JSON in addition to the `@type`\nfield. Example (for message [google.protobuf.Duration][]):\n\n {\n \"@type\": \"type.googleapis.com/google.protobuf.Duration\",\n \"value\": \"1.212s\"\n }"
|
||||
},
|
||||
"runtimeError": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"error": {
|
||||
"type": "string"
|
||||
},
|
||||
"code": {
|
||||
"type": "integer",
|
||||
"format": "int32"
|
||||
},
|
||||
"message": {
|
||||
"type": "string"
|
||||
},
|
||||
"details": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/protobufAny"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"externalDocs": {
|
||||
"description": "Developer Manual",
|
||||
"url": "http://owncloud.github.io/extensions/ocis_settings/"
|
||||
}
|
||||
}
|
||||
@@ -3,8 +3,8 @@ package debug
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/owncloud/ocis-settings/pkg/config"
|
||||
"github.com/owncloud/ocis-pkg/v2/log"
|
||||
"github.com/owncloud/ocis-settings/pkg/config"
|
||||
)
|
||||
|
||||
// Option defines a single option function.
|
||||
|
||||
@@ -4,9 +4,9 @@ import (
|
||||
"io"
|
||||
"net/http"
|
||||
|
||||
"github.com/owncloud/ocis-pkg/v2/service/debug"
|
||||
"github.com/owncloud/ocis-settings/pkg/config"
|
||||
"github.com/owncloud/ocis-settings/pkg/version"
|
||||
"github.com/owncloud/ocis-pkg/v2/service/debug"
|
||||
)
|
||||
|
||||
// Server initializes the debug service and server.
|
||||
@@ -34,7 +34,7 @@ func health(cfg *config.Config) func(http.ResponseWriter, *http.Request) {
|
||||
|
||||
// TODO(tboerger): check if services are up and running
|
||||
|
||||
io.WriteString(w, http.StatusText(http.StatusOK))
|
||||
_, _ = io.WriteString(w, http.StatusText(http.StatusOK))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,6 +46,6 @@ func ready(cfg *config.Config) func(http.ResponseWriter, *http.Request) {
|
||||
|
||||
// TODO(tboerger): check if services are up and running
|
||||
|
||||
io.WriteString(w, http.StatusText(http.StatusOK))
|
||||
_, _ = io.WriteString(w, http.StatusText(http.StatusOK))
|
||||
}
|
||||
}
|
||||
|
||||
76
pkg/server/grpc/option.go
Normal file
76
pkg/server/grpc/option.go
Normal file
@@ -0,0 +1,76 @@
|
||||
package grpc
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/micro/cli/v2"
|
||||
"github.com/owncloud/ocis-pkg/v2/log"
|
||||
"github.com/owncloud/ocis-settings/pkg/config"
|
||||
"github.com/owncloud/ocis-settings/pkg/metrics"
|
||||
)
|
||||
|
||||
// Option defines a single option function.
|
||||
type Option func(o *Options)
|
||||
|
||||
// Options defines the available options for this package.
|
||||
type Options struct {
|
||||
Name string
|
||||
Logger log.Logger
|
||||
Context context.Context
|
||||
Config *config.Config
|
||||
Metrics *metrics.Metrics
|
||||
Flags []cli.Flag
|
||||
}
|
||||
|
||||
// newOptions initializes the available default options.
|
||||
func newOptions(opts ...Option) Options {
|
||||
opt := Options{}
|
||||
|
||||
for _, o := range opts {
|
||||
o(&opt)
|
||||
}
|
||||
|
||||
return opt
|
||||
}
|
||||
|
||||
// Logger provides a function to set the logger option.
|
||||
func Logger(val log.Logger) Option {
|
||||
return func(o *Options) {
|
||||
o.Logger = val
|
||||
}
|
||||
}
|
||||
|
||||
// Name provides a name for the service.
|
||||
func Name(val string) Option {
|
||||
return func(o *Options) {
|
||||
o.Name = val
|
||||
}
|
||||
}
|
||||
|
||||
// Context provides a function to set the context option.
|
||||
func Context(val context.Context) Option {
|
||||
return func(o *Options) {
|
||||
o.Context = val
|
||||
}
|
||||
}
|
||||
|
||||
// Config provides a function to set the config option.
|
||||
func Config(val *config.Config) Option {
|
||||
return func(o *Options) {
|
||||
o.Config = val
|
||||
}
|
||||
}
|
||||
|
||||
// Metrics provides a function to set the metrics option.
|
||||
func Metrics(val *metrics.Metrics) Option {
|
||||
return func(o *Options) {
|
||||
o.Metrics = val
|
||||
}
|
||||
}
|
||||
|
||||
// Flags provides a function to set the flags option.
|
||||
func Flags(val []cli.Flag) Option {
|
||||
return func(o *Options) {
|
||||
o.Flags = append(o.Flags, val...)
|
||||
}
|
||||
}
|
||||
34
pkg/server/grpc/server.go
Normal file
34
pkg/server/grpc/server.go
Normal file
@@ -0,0 +1,34 @@
|
||||
package grpc
|
||||
|
||||
import (
|
||||
"github.com/owncloud/ocis-pkg/v2/service/grpc"
|
||||
"github.com/owncloud/ocis-settings/pkg/proto/v0"
|
||||
svc "github.com/owncloud/ocis-settings/pkg/service/v0"
|
||||
"github.com/owncloud/ocis-settings/pkg/version"
|
||||
)
|
||||
|
||||
// Server initializes a new go-micro service ready to run
|
||||
func Server(opts ...Option) grpc.Service {
|
||||
options := newOptions(opts...)
|
||||
|
||||
service := grpc.NewService(
|
||||
grpc.Logger(options.Logger),
|
||||
grpc.Name(options.Name),
|
||||
grpc.Version(version.String),
|
||||
grpc.Address(options.Config.GRPC.Addr),
|
||||
grpc.Namespace(options.Config.GRPC.Namespace),
|
||||
grpc.Context(options.Context),
|
||||
grpc.Flags(options.Flags...),
|
||||
)
|
||||
|
||||
handle := svc.NewService(options.Config)
|
||||
if err := proto.RegisterBundleServiceHandler(service.Server(), handle); err != nil {
|
||||
options.Logger.Fatal().Err(err).Msg("could not register SettingsBundles service handler")
|
||||
}
|
||||
if err := proto.RegisterValueServiceHandler(service.Server(), handle); err != nil {
|
||||
options.Logger.Fatal().Err(err).Msg("could not register SettingsValues service handler")
|
||||
}
|
||||
|
||||
service.Init()
|
||||
return service
|
||||
}
|
||||
@@ -4,9 +4,9 @@ import (
|
||||
"context"
|
||||
|
||||
"github.com/micro/cli/v2"
|
||||
"github.com/owncloud/ocis-pkg/v2/log"
|
||||
"github.com/owncloud/ocis-settings/pkg/config"
|
||||
"github.com/owncloud/ocis-settings/pkg/metrics"
|
||||
"github.com/owncloud/ocis-pkg/v2/log"
|
||||
)
|
||||
|
||||
// Option defines a single option function.
|
||||
@@ -14,12 +14,12 @@ type Option func(o *Options)
|
||||
|
||||
// Options defines the available options for this package.
|
||||
type Options struct {
|
||||
Namespace string
|
||||
Logger log.Logger
|
||||
Context context.Context
|
||||
Config *config.Config
|
||||
Metrics *metrics.Metrics
|
||||
Flags []cli.Flag
|
||||
Name string
|
||||
Logger log.Logger
|
||||
Context context.Context
|
||||
Config *config.Config
|
||||
Metrics *metrics.Metrics
|
||||
Flags []cli.Flag
|
||||
}
|
||||
|
||||
// newOptions initializes the available default options.
|
||||
@@ -40,6 +40,13 @@ func Logger(val log.Logger) Option {
|
||||
}
|
||||
}
|
||||
|
||||
// Name provides a name for the service.
|
||||
func Name(val string) Option {
|
||||
return func(o *Options) {
|
||||
o.Name = val
|
||||
}
|
||||
}
|
||||
|
||||
// Context provides a function to set the context option.
|
||||
func Context(val context.Context) Option {
|
||||
return func(o *Options) {
|
||||
@@ -67,10 +74,3 @@ func Flags(val []cli.Flag) Option {
|
||||
o.Flags = append(o.Flags, val...)
|
||||
}
|
||||
}
|
||||
|
||||
// Namespace provides a function to set the Namespace option.
|
||||
func Namespace(val string) Option {
|
||||
return func(o *Options) {
|
||||
o.Namespace = val
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,44 +1,30 @@
|
||||
package http
|
||||
|
||||
import (
|
||||
svc "github.com/owncloud/ocis-settings/pkg/service/v0"
|
||||
"github.com/owncloud/ocis-settings/pkg/version"
|
||||
"github.com/go-chi/chi"
|
||||
"github.com/owncloud/ocis-pkg/v2/middleware"
|
||||
"github.com/owncloud/ocis-pkg/v2/service/http"
|
||||
"github.com/owncloud/ocis-settings/pkg/assets"
|
||||
"github.com/owncloud/ocis-settings/pkg/proto/v0"
|
||||
svc "github.com/owncloud/ocis-settings/pkg/service/v0"
|
||||
"github.com/owncloud/ocis-settings/pkg/version"
|
||||
)
|
||||
|
||||
// Server initializes the http service and server.
|
||||
func Server(opts ...Option) (http.Service, error) {
|
||||
func Server(opts ...Option) http.Service {
|
||||
options := newOptions(opts...)
|
||||
|
||||
service := http.NewService(
|
||||
http.Logger(options.Logger),
|
||||
http.Name("settings"),
|
||||
http.Name(options.Name),
|
||||
http.Version(version.String),
|
||||
http.Namespace(options.Config.HTTP.Namespace),
|
||||
http.Address(options.Config.HTTP.Addr),
|
||||
http.Namespace(options.Config.HTTP.Namespace),
|
||||
http.Context(options.Context),
|
||||
http.Flags(options.Flags...),
|
||||
)
|
||||
|
||||
handle := svc.NewService(
|
||||
svc.Logger(options.Logger),
|
||||
svc.Config(options.Config),
|
||||
svc.Middleware(
|
||||
middleware.RealIP,
|
||||
middleware.RequestID,
|
||||
middleware.Cache,
|
||||
middleware.Cors,
|
||||
middleware.Secure,
|
||||
middleware.Version(
|
||||
"settings",
|
||||
version.String,
|
||||
),
|
||||
middleware.Logger(
|
||||
options.Logger,
|
||||
),
|
||||
),
|
||||
)
|
||||
handle := svc.NewService(options.Config)
|
||||
|
||||
{
|
||||
handle = svc.NewInstrument(handle, options.Metrics)
|
||||
@@ -46,11 +32,43 @@ func Server(opts ...Option) (http.Service, error) {
|
||||
handle = svc.NewTracing(handle)
|
||||
}
|
||||
|
||||
mux := chi.NewMux()
|
||||
|
||||
mux.Use(middleware.RealIP)
|
||||
mux.Use(middleware.RequestID)
|
||||
mux.Use(middleware.Cache)
|
||||
mux.Use(middleware.Cors)
|
||||
mux.Use(middleware.Secure)
|
||||
|
||||
mux.Use(middleware.Version(
|
||||
"settings",
|
||||
version.String,
|
||||
))
|
||||
|
||||
mux.Use(middleware.Logger(
|
||||
options.Logger,
|
||||
))
|
||||
|
||||
mux.Use(middleware.Static(
|
||||
options.Config.HTTP.Root,
|
||||
assets.New(
|
||||
assets.Logger(options.Logger),
|
||||
assets.Config(options.Config),
|
||||
),
|
||||
))
|
||||
|
||||
mux.Route(options.Config.HTTP.Root, func(r chi.Router) {
|
||||
proto.RegisterBundleServiceWeb(r, handle)
|
||||
proto.RegisterValueServiceWeb(r, handle)
|
||||
})
|
||||
|
||||
service.Handle(
|
||||
"/",
|
||||
handle,
|
||||
mux,
|
||||
)
|
||||
|
||||
service.Init()
|
||||
return service, nil
|
||||
if err := service.Init(); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return service
|
||||
}
|
||||
|
||||
@@ -1,30 +1,13 @@
|
||||
package svc
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/owncloud/ocis-settings/pkg/metrics"
|
||||
)
|
||||
|
||||
// NewInstrument returns a service that instruments metrics.
|
||||
func NewInstrument(next Service, metrics *metrics.Metrics) Service {
|
||||
return instrument{
|
||||
next: next,
|
||||
metrics: metrics,
|
||||
return Service{
|
||||
manager: next.manager,
|
||||
config: next.config,
|
||||
}
|
||||
}
|
||||
|
||||
type instrument struct {
|
||||
next Service
|
||||
metrics *metrics.Metrics
|
||||
}
|
||||
|
||||
// ServeHTTP implements the Service interface.
|
||||
func (i instrument) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
i.next.ServeHTTP(w, r)
|
||||
}
|
||||
|
||||
// Dummy implements the Service interface.
|
||||
func (i instrument) Dummy(w http.ResponseWriter, r *http.Request) {
|
||||
i.next.Dummy(w, r)
|
||||
}
|
||||
|
||||
@@ -1,30 +1,13 @@
|
||||
package svc
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/owncloud/ocis-pkg/v2/log"
|
||||
)
|
||||
|
||||
// NewLogging returns a service that logs messages.
|
||||
func NewLogging(next Service, logger log.Logger) Service {
|
||||
return logging{
|
||||
next: next,
|
||||
logger: logger,
|
||||
return Service{
|
||||
manager: next.manager,
|
||||
config: next.config,
|
||||
}
|
||||
}
|
||||
|
||||
type logging struct {
|
||||
next Service
|
||||
logger log.Logger
|
||||
}
|
||||
|
||||
// ServeHTTP implements the Service interface.
|
||||
func (l logging) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
l.next.ServeHTTP(w, r)
|
||||
}
|
||||
|
||||
// Dummy implements the Service interface.
|
||||
func (l logging) Dummy(w http.ResponseWriter, r *http.Request) {
|
||||
l.next.Dummy(w, r)
|
||||
}
|
||||
|
||||
@@ -3,8 +3,8 @@ package svc
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/owncloud/ocis-settings/pkg/config"
|
||||
"github.com/owncloud/ocis-pkg/v2/log"
|
||||
"github.com/owncloud/ocis-settings/pkg/config"
|
||||
)
|
||||
|
||||
// Option defines a single option function.
|
||||
@@ -17,17 +17,6 @@ type Options struct {
|
||||
Middleware []func(http.Handler) http.Handler
|
||||
}
|
||||
|
||||
// newOptions initializes the available default options.
|
||||
func newOptions(opts ...Option) Options {
|
||||
opt := Options{}
|
||||
|
||||
for _, o := range opts {
|
||||
o(&opt)
|
||||
}
|
||||
|
||||
return opt
|
||||
}
|
||||
|
||||
// Logger provides a function to set the logger option.
|
||||
func Logger(val log.Logger) Option {
|
||||
return func(o *Options) {
|
||||
|
||||
@@ -1,52 +1,97 @@
|
||||
package svc
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"context"
|
||||
|
||||
"github.com/owncloud/ocis-settings/pkg/settings"
|
||||
store "github.com/owncloud/ocis-settings/pkg/store/filesystem"
|
||||
|
||||
"github.com/go-chi/chi"
|
||||
"github.com/owncloud/ocis-settings/pkg/config"
|
||||
"github.com/owncloud/ocis-settings/pkg/proto/v0"
|
||||
)
|
||||
|
||||
// Service defines the extension handlers.
|
||||
type Service interface {
|
||||
ServeHTTP(http.ResponseWriter, *http.Request)
|
||||
Dummy(http.ResponseWriter, *http.Request)
|
||||
// Service represents a service.
|
||||
type Service struct {
|
||||
config *config.Config
|
||||
manager settings.Manager
|
||||
}
|
||||
|
||||
// NewService returns a service implementation for Service.
|
||||
func NewService(opts ...Option) Service {
|
||||
options := newOptions(opts...)
|
||||
|
||||
m := chi.NewMux()
|
||||
m.Use(options.Middleware...)
|
||||
|
||||
svc := Settings{
|
||||
config: options.Config,
|
||||
mux: m,
|
||||
func NewService(cfg *config.Config) Service {
|
||||
return Service{
|
||||
config: cfg,
|
||||
manager: store.New(cfg),
|
||||
}
|
||||
|
||||
m.Route(options.Config.HTTP.Root, func(r chi.Router) {
|
||||
r.Get("/", svc.Dummy)
|
||||
})
|
||||
|
||||
return svc
|
||||
}
|
||||
|
||||
// Settings defines implements the business logic for Service.
|
||||
type Settings struct {
|
||||
config *config.Config
|
||||
mux *chi.Mux
|
||||
// SaveSettingsBundle implements the BundleServiceHandler interface
|
||||
func (g Service) SaveSettingsBundle(c context.Context, req *proto.SaveSettingsBundleRequest, res *proto.SaveSettingsBundleResponse) error {
|
||||
req.SettingsBundle.Identifier = getFailsafeIdentifier(req.SettingsBundle.Identifier)
|
||||
r, err := g.manager.WriteBundle(req.SettingsBundle)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
res.SettingsBundle = r
|
||||
return nil
|
||||
}
|
||||
|
||||
// ServeHTTP implements the Service interface.
|
||||
func (g Settings) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
g.mux.ServeHTTP(w, r)
|
||||
// GetSettingsBundle implements the BundleServiceHandler interface
|
||||
func (g Service) GetSettingsBundle(c context.Context, req *proto.GetSettingsBundleRequest, res *proto.GetSettingsBundleResponse) error {
|
||||
r, err := g.manager.ReadBundle(getFailsafeIdentifier(req.Identifier))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
res.SettingsBundle = r
|
||||
return nil
|
||||
}
|
||||
|
||||
// Dummy implements the Service interface.
|
||||
func (g Settings) Dummy(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "text/plain")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
|
||||
w.Write([]byte("Hello ocis-settings!"))
|
||||
// ListSettingsBundles implements the BundleServiceHandler interface
|
||||
func (g Service) ListSettingsBundles(c context.Context, req *proto.ListSettingsBundlesRequest, res *proto.ListSettingsBundlesResponse) error {
|
||||
r, err := g.manager.ListBundles(getFailsafeIdentifier(req.Identifier))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
res.SettingsBundles = r
|
||||
return nil
|
||||
}
|
||||
|
||||
// SaveSettingsValue implements the ValueServiceHandler interface
|
||||
func (g Service) SaveSettingsValue(c context.Context, req *proto.SaveSettingsValueRequest, res *proto.SaveSettingsValueResponse) error {
|
||||
req.SettingsValue.Identifier = getFailsafeIdentifier(req.SettingsValue.Identifier)
|
||||
r, err := g.manager.WriteValue(req.SettingsValue)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
res.SettingsValue = r
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetSettingsValue implements the ValueServiceHandler interface
|
||||
func (g Service) GetSettingsValue(c context.Context, req *proto.GetSettingsValueRequest, res *proto.GetSettingsValueResponse) error {
|
||||
r, err := g.manager.ReadValue(getFailsafeIdentifier(req.Identifier))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
res.SettingsValue = r
|
||||
return nil
|
||||
}
|
||||
|
||||
// ListSettingsValues implements the ValueServiceHandler interface
|
||||
func (g Service) ListSettingsValues(c context.Context, req *proto.ListSettingsValuesRequest, res *proto.ListSettingsValuesResponse) error {
|
||||
r, err := g.manager.ListValues(getFailsafeIdentifier(req.Identifier))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
res.SettingsValues = r
|
||||
return nil
|
||||
}
|
||||
|
||||
func getFailsafeIdentifier(identifier *proto.Identifier) *proto.Identifier {
|
||||
if identifier == nil {
|
||||
identifier = &proto.Identifier{}
|
||||
}
|
||||
if identifier.AccountUuid == "me" {
|
||||
identifier.AccountUuid = "5681371F-4A6E-43BC-8BB5-9C9237FA9C58"
|
||||
}
|
||||
return identifier
|
||||
}
|
||||
|
||||
@@ -1,26 +1,9 @@
|
||||
package svc
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// NewTracing returns a service that instruments traces.
|
||||
func NewTracing(next Service) Service {
|
||||
return tracing{
|
||||
next: next,
|
||||
return Service{
|
||||
manager: next.manager,
|
||||
config: next.config,
|
||||
}
|
||||
}
|
||||
|
||||
type tracing struct {
|
||||
next Service
|
||||
}
|
||||
|
||||
// ServeHTTP implements the Service interface.
|
||||
func (t tracing) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
t.next.ServeHTTP(w, r)
|
||||
}
|
||||
|
||||
// Dummy implements the Service interface.
|
||||
func (t tracing) Dummy(w http.ResponseWriter, r *http.Request) {
|
||||
t.next.Dummy(w, r)
|
||||
}
|
||||
|
||||
34
pkg/settings/settings.go
Normal file
34
pkg/settings/settings.go
Normal file
@@ -0,0 +1,34 @@
|
||||
package settings
|
||||
|
||||
import (
|
||||
"github.com/owncloud/ocis-settings/pkg/config"
|
||||
"github.com/owncloud/ocis-settings/pkg/proto/v0"
|
||||
)
|
||||
|
||||
var (
|
||||
// Registry uses the strategy pattern as a registry
|
||||
Registry = map[string]RegisterFunc{}
|
||||
)
|
||||
|
||||
// RegisterFunc stores store constructors
|
||||
type RegisterFunc func(*config.Config) Manager
|
||||
|
||||
// Manager combines service interfaces for abstraction of storage implementations
|
||||
type Manager interface {
|
||||
BundleManager
|
||||
ValueManager
|
||||
}
|
||||
|
||||
// BundleManager is a bundle service interface for abstraction of storage implementations
|
||||
type BundleManager interface {
|
||||
ReadBundle(identifier *proto.Identifier) (*proto.SettingsBundle, error)
|
||||
WriteBundle(bundle *proto.SettingsBundle) (*proto.SettingsBundle, error)
|
||||
ListBundles(identifier *proto.Identifier) ([]*proto.SettingsBundle, error)
|
||||
}
|
||||
|
||||
// ValueManager is a value service interface for abstraction of storage implementations
|
||||
type ValueManager interface {
|
||||
ReadValue(identifier *proto.Identifier) (*proto.SettingsValue, error)
|
||||
WriteValue(value *proto.SettingsValue) (*proto.SettingsValue, error)
|
||||
ListValues(identifier *proto.Identifier) ([]*proto.SettingsValue, error)
|
||||
}
|
||||
85
pkg/store/filesystem/bundles.go
Normal file
85
pkg/store/filesystem/bundles.go
Normal file
@@ -0,0 +1,85 @@
|
||||
// Package store implements the go-micro store interface
|
||||
package store
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"path"
|
||||
|
||||
"github.com/owncloud/ocis-settings/pkg/proto/v0"
|
||||
"google.golang.org/grpc/codes"
|
||||
gstatus "google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
// ListBundles returns all bundles in the mountPath folder belonging to the given extension
|
||||
func (s Store) ListBundles(identifier *proto.Identifier) ([]*proto.SettingsBundle, error) {
|
||||
bundlesFolder := s.buildFolderPathBundles()
|
||||
extensionFolders, err := ioutil.ReadDir(bundlesFolder)
|
||||
if err != nil {
|
||||
s.Logger.Err(err).Msgf("error reading %v", bundlesFolder)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(identifier.Extension) < 1 {
|
||||
s.Logger.Info().Msg("listing all bundles")
|
||||
} else {
|
||||
s.Logger.Info().Msgf("listing bundles by extension %v", identifier.Extension)
|
||||
}
|
||||
var records []*proto.SettingsBundle
|
||||
for _, extensionFolder := range extensionFolders {
|
||||
extensionPath := path.Join(bundlesFolder, extensionFolder.Name())
|
||||
bundleFiles, err := ioutil.ReadDir(extensionPath)
|
||||
if err == nil {
|
||||
for _, bundleFile := range bundleFiles {
|
||||
record := proto.SettingsBundle{}
|
||||
bundlePath := path.Join(extensionPath, bundleFile.Name())
|
||||
err = s.parseRecordFromFile(&record, bundlePath)
|
||||
if err != nil {
|
||||
s.Logger.Warn().Msgf("error reading %v", bundlePath)
|
||||
continue
|
||||
}
|
||||
if len(identifier.Extension) == 0 || identifier.Extension == record.Identifier.Extension {
|
||||
records = append(records, &record)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
s.Logger.Err(err).Msgf("error reading %v", extensionPath)
|
||||
}
|
||||
}
|
||||
|
||||
return records, nil
|
||||
}
|
||||
|
||||
// ReadBundle tries to find a bundle by the given identifier within the mountPath.
|
||||
// Extension and BundleKey within the identifier are required.
|
||||
func (s Store) ReadBundle(identifier *proto.Identifier) (*proto.SettingsBundle, error) {
|
||||
if len(identifier.Extension) < 1 || len(identifier.BundleKey) < 1 {
|
||||
s.Logger.Error().Msg("extension and bundleKey cannot be empty")
|
||||
return nil, gstatus.Error(codes.InvalidArgument, "Missing a required identifier attribute")
|
||||
}
|
||||
|
||||
filePath := s.buildFilePathFromBundleArgs(identifier.Extension, identifier.BundleKey)
|
||||
record := proto.SettingsBundle{}
|
||||
if err := s.parseRecordFromFile(&record, filePath); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
s.Logger.Debug().Msgf("read contents from file: %v", filePath)
|
||||
return &record, nil
|
||||
}
|
||||
|
||||
// WriteBundle writes the given record into a file within the mountPath
|
||||
// Extension and BundleKey within the record identifier are required.
|
||||
func (s Store) WriteBundle(record *proto.SettingsBundle) (*proto.SettingsBundle, error) {
|
||||
if len(record.Identifier.Extension) < 1 || len(record.Identifier.BundleKey) < 1 {
|
||||
s.Logger.Error().Msg("extension and bundleKey cannot be empty")
|
||||
return nil, gstatus.Error(codes.InvalidArgument, "Missing a required identifier attribute")
|
||||
}
|
||||
|
||||
filePath := s.buildFilePathFromBundle(record)
|
||||
if err := s.writeRecordToFile(record, filePath); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
s.Logger.Debug().Msgf("request contents written to file: %v", filePath)
|
||||
return record, nil
|
||||
}
|
||||
43
pkg/store/filesystem/io.go
Normal file
43
pkg/store/filesystem/io.go
Normal file
@@ -0,0 +1,43 @@
|
||||
package store
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/golang/protobuf/jsonpb"
|
||||
"github.com/golang/protobuf/proto"
|
||||
)
|
||||
|
||||
// Unmarshal file into record
|
||||
func (s Store) parseRecordFromFile(record proto.Message, filePath string) error {
|
||||
file, err := os.Open(filePath)
|
||||
if err != nil {
|
||||
s.Logger.Err(err).Msgf("error reading file %v: file not found", filePath)
|
||||
return err
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
decoder := jsonpb.Unmarshaler{}
|
||||
if err = decoder.Unmarshal(file, record); err != nil {
|
||||
s.Logger.Err(err).Msgf("error reading file %v: unmarshalling failed", filePath)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Marshal record into file
|
||||
func (s Store) writeRecordToFile(record proto.Message, filePath string) error {
|
||||
file, err := os.Create(filePath)
|
||||
if err != nil {
|
||||
s.Logger.Err(err).Msgf("error writing file %v: opening failed", filePath)
|
||||
return err
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
encoder := jsonpb.Marshaler{}
|
||||
if err = encoder.Marshal(file, record); err != nil {
|
||||
s.Logger.Err(err).Msgf("error writing file %v: marshalling failed", filePath)
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
59
pkg/store/filesystem/paths.go
Normal file
59
pkg/store/filesystem/paths.go
Normal file
@@ -0,0 +1,59 @@
|
||||
package store
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path"
|
||||
|
||||
"github.com/owncloud/ocis-settings/pkg/proto/v0"
|
||||
)
|
||||
|
||||
const folderNameBundles = "bundles"
|
||||
const folderNameValues = "values"
|
||||
|
||||
// Builds the folder path for storing settings bundles
|
||||
func (s Store) buildFolderPathBundles() string {
|
||||
folderPath := path.Join(s.mountPath, folderNameBundles)
|
||||
s.ensureFolderExists(folderPath)
|
||||
return folderPath
|
||||
}
|
||||
|
||||
// Builds a unique file name from the given settings bundle
|
||||
func (s Store) buildFilePathFromBundle(bundle *proto.SettingsBundle) string {
|
||||
return s.buildFilePathFromBundleArgs(bundle.Identifier.Extension, bundle.Identifier.BundleKey)
|
||||
}
|
||||
|
||||
// Builds a unique file name from the given params
|
||||
func (s Store) buildFilePathFromBundleArgs(extension string, bundleKey string) string {
|
||||
extensionFolder := path.Join(s.mountPath, folderNameBundles, extension)
|
||||
s.ensureFolderExists(extensionFolder)
|
||||
return path.Join(extensionFolder, bundleKey+".json")
|
||||
}
|
||||
|
||||
// // Builds the folder path for storing settings values
|
||||
// func (s Store) buildFolderPathValues() string {
|
||||
// folderPath := path.Join(s.mountPath, folderNameValues)
|
||||
// s.ensureFolderExists(folderPath)
|
||||
// return folderPath
|
||||
// }
|
||||
|
||||
// Builds a unique file name from the given settings value
|
||||
func (s Store) buildFilePathFromValue(value *proto.SettingsValue) string {
|
||||
return s.buildFilePathFromValueArgs(value.Identifier.AccountUuid, value.Identifier.Extension, value.Identifier.BundleKey)
|
||||
}
|
||||
|
||||
// Builds a unique file name from the given params
|
||||
func (s Store) buildFilePathFromValueArgs(accountUUID string, extension string, bundleKey string) string {
|
||||
extensionFolder := path.Join(s.mountPath, folderNameValues, accountUUID, extension)
|
||||
s.ensureFolderExists(extensionFolder)
|
||||
return path.Join(extensionFolder, bundleKey+".json")
|
||||
}
|
||||
|
||||
// Checks if the given path is an existing folder and creates one if not existing
|
||||
func (s Store) ensureFolderExists(path string) {
|
||||
if _, err := os.Stat(path); os.IsNotExist(err) {
|
||||
err = os.MkdirAll(path, 0700)
|
||||
if err != nil {
|
||||
s.Logger.Err(err).Msgf("Error creating folder %v", path)
|
||||
}
|
||||
}
|
||||
}
|
||||
44
pkg/store/filesystem/store.go
Normal file
44
pkg/store/filesystem/store.go
Normal file
@@ -0,0 +1,44 @@
|
||||
// Package store implements the go-micro store interface
|
||||
package store
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path"
|
||||
|
||||
olog "github.com/owncloud/ocis-pkg/v2/log"
|
||||
"github.com/owncloud/ocis-settings/pkg/config"
|
||||
"github.com/owncloud/ocis-settings/pkg/settings"
|
||||
)
|
||||
|
||||
var (
|
||||
// Name is the default name for the settings store
|
||||
Name = "ocis-settings-store"
|
||||
managerName = "filesystem"
|
||||
)
|
||||
|
||||
// Store interacts with the filesystem to manage settings information
|
||||
type Store struct {
|
||||
mountPath string
|
||||
Logger olog.Logger
|
||||
}
|
||||
|
||||
// New creates a new store
|
||||
func New(cfg *config.Config) settings.Manager {
|
||||
s := Store{}
|
||||
|
||||
dest := path.Join(cfg.Storage.RootMountPath, Name)
|
||||
if _, err := os.Stat(dest); err != nil {
|
||||
s.Logger.Info().Msgf("creating container on %v", dest)
|
||||
err := os.MkdirAll(dest, 0700)
|
||||
if err != nil {
|
||||
s.Logger.Err(err).Msgf("providing container on %v", dest)
|
||||
}
|
||||
}
|
||||
|
||||
s.mountPath = dest
|
||||
return &s
|
||||
}
|
||||
|
||||
func init() {
|
||||
settings.Registry[managerName] = New
|
||||
}
|
||||
125
pkg/store/filesystem/values.go
Normal file
125
pkg/store/filesystem/values.go
Normal file
@@ -0,0 +1,125 @@
|
||||
// Package store implements the go-micro store interface
|
||||
package store
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/owncloud/ocis-settings/pkg/proto/v0"
|
||||
"google.golang.org/grpc/codes"
|
||||
gstatus "google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
// ReadValue tries to find a value by the given identifier attributes within the mountPath
|
||||
// All identifier fields are required.
|
||||
func (s Store) ReadValue(identifier *proto.Identifier) (*proto.SettingsValue, error) {
|
||||
if len(identifier.AccountUuid) < 1 || len(identifier.Extension) < 1 || len(identifier.BundleKey) < 1 || len(identifier.SettingKey) < 1 {
|
||||
s.Logger.Error().Msg("account-uuid, extension, bundle and setting are required")
|
||||
return nil, gstatus.Errorf(codes.InvalidArgument, "Missing a required identifier attribute")
|
||||
}
|
||||
|
||||
filePath := s.buildFilePathFromValueArgs(identifier.AccountUuid, identifier.Extension, identifier.BundleKey)
|
||||
values, err := s.readValuesMapFromFile(filePath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if value := values.Values[identifier.SettingKey]; value != nil {
|
||||
return value, nil
|
||||
}
|
||||
// TODO: we want to return sensible defaults here, when the value was not found
|
||||
return nil, gstatus.Error(codes.NotFound, "SettingsValue not set")
|
||||
}
|
||||
|
||||
// WriteValue writes the given SettingsValue into a file within the mountPath
|
||||
// All identifier fields within the value are required.
|
||||
func (s Store) WriteValue(value *proto.SettingsValue) (*proto.SettingsValue, error) {
|
||||
if len(value.Identifier.AccountUuid) < 1 || len(value.Identifier.Extension) < 1 || len(value.Identifier.BundleKey) < 1 || len(value.Identifier.SettingKey) < 1 {
|
||||
s.Logger.Error().Msg("all identifier keys are required")
|
||||
return nil, gstatus.Errorf(codes.InvalidArgument, "Missing a required identifier attribute")
|
||||
}
|
||||
|
||||
filePath := s.buildFilePathFromValue(value)
|
||||
values, err := s.readValuesMapFromFile(filePath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
values.Values[value.Identifier.SettingKey] = value
|
||||
if err := s.writeRecordToFile(values, filePath); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return value, nil
|
||||
}
|
||||
|
||||
// ListValues reads all values within the scope of the given identifier
|
||||
// AccountUuid is required.
|
||||
func (s Store) ListValues(identifier *proto.Identifier) ([]*proto.SettingsValue, error) {
|
||||
if len(identifier.AccountUuid) < 1 {
|
||||
s.Logger.Error().Msg("account-uuid is required")
|
||||
return nil, gstatus.Errorf(codes.InvalidArgument, "Missing a required identifier attribute")
|
||||
}
|
||||
|
||||
accountFolderPath := path.Join(s.mountPath, folderNameValues, identifier.AccountUuid)
|
||||
var values []*proto.SettingsValue
|
||||
if _, err := os.Stat(accountFolderPath); err != nil {
|
||||
return values, nil
|
||||
}
|
||||
|
||||
// TODO: might be a good idea to do this non-hierarchical. i.e. allowing all fragments in the identifier being set or not.
|
||||
// depending on the set values in the identifier arg, collect all SettingValues files for the account
|
||||
var valueFilePaths []string
|
||||
if len(identifier.Extension) < 1 {
|
||||
if err := filepath.Walk(accountFolderPath, func(path string, info os.FileInfo, err error) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
valueFilePaths = append(valueFilePaths, path)
|
||||
return nil
|
||||
}); err != nil {
|
||||
s.Logger.Err(err).Msgf("error reading %v", accountFolderPath)
|
||||
return nil, err
|
||||
}
|
||||
} else if len(identifier.BundleKey) < 1 {
|
||||
extensionPath := path.Join(accountFolderPath, identifier.Extension)
|
||||
if err := filepath.Walk(extensionPath, func(path string, info os.FileInfo, err error) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
valueFilePaths = append(valueFilePaths, path)
|
||||
return nil
|
||||
}); err != nil {
|
||||
s.Logger.Err(err).Msgf("error reading %v", extensionPath)
|
||||
return nil, err
|
||||
}
|
||||
} else {
|
||||
bundlePath := path.Join(accountFolderPath, identifier.Extension, identifier.BundleKey+".json")
|
||||
valueFilePaths = append(valueFilePaths, bundlePath)
|
||||
}
|
||||
|
||||
// parse the SettingValues from the collected files
|
||||
for _, filePath := range valueFilePaths {
|
||||
bundleValues, err := s.readValuesMapFromFile(filePath)
|
||||
if err != nil {
|
||||
s.Logger.Err(err).Msgf("error reading %v", filePath)
|
||||
} else {
|
||||
for _, value := range bundleValues.Values {
|
||||
values = append(values, value)
|
||||
}
|
||||
}
|
||||
}
|
||||
return values, nil
|
||||
}
|
||||
|
||||
// Reads SettingsValues as map from the given file or returns an empty map if the file doesn't exist.
|
||||
func (s Store) readValuesMapFromFile(filePath string) (*proto.SettingsValues, error) {
|
||||
values := &proto.SettingsValues{}
|
||||
err := s.parseRecordFromFile(values, filePath)
|
||||
if err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
values.Values = map[string]*proto.SettingsValue{}
|
||||
} else {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return values, nil
|
||||
}
|
||||
6
pkg/store/registry.go
Normal file
6
pkg/store/registry.go
Normal file
@@ -0,0 +1,6 @@
|
||||
package store
|
||||
|
||||
import (
|
||||
// init filesystem store
|
||||
_ "github.com/owncloud/ocis-settings/pkg/store/filesystem"
|
||||
)
|
||||
@@ -1,2 +1,5 @@
|
||||
# backend
|
||||
-r '^(cmd|pkg)/.*\.go$' -R '^node_modules/' -s -- sh -c 'make bin/ocis-settings-debug && bin/ocis-settings-debug --log-level debug server --debug-pprof --debug-zpages'
|
||||
-r '^(cmd|pkg)/.*\.go$' -R '^node_modules/' -s -- sh -c 'make bin/ocis-settings-debug && bin/ocis-settings-debug --log-level debug server --debug-pprof --debug-zpages --asset-path assets/'
|
||||
|
||||
# frontend
|
||||
-r '^ui/.*\.(vue|js)$' -R '^node_modules/' -- sh -c 'yarn build && make generate'
|
||||
|
||||
52
rollup.config.js
Normal file
52
rollup.config.js
Normal file
@@ -0,0 +1,52 @@
|
||||
import vue from 'rollup-plugin-vue'
|
||||
import { terser } from 'rollup-plugin-terser'
|
||||
import replace from '@rollup/plugin-replace'
|
||||
import filesize from 'rollup-plugin-filesize'
|
||||
import resolve from 'rollup-plugin-node-resolve'
|
||||
import commonjs from '@rollup/plugin-commonjs'
|
||||
import babel from 'rollup-plugin-babel'
|
||||
import json from '@rollup/plugin-json'
|
||||
import builtins from '@erquhart/rollup-plugin-node-builtins'
|
||||
import globals from 'rollup-plugin-node-globals'
|
||||
|
||||
const production = !process.env.ROLLUP_WATCH
|
||||
|
||||
// We can't really do much about circular dependencies in node_modules
|
||||
function onwarn (warning) {
|
||||
if (warning.code !== 'CIRCULAR_DEPENDENCY') {
|
||||
console.error(`(!) ${warning.message}`)
|
||||
}
|
||||
}
|
||||
|
||||
export default {
|
||||
input: 'ui/app.js',
|
||||
output: {
|
||||
file: 'assets/settings.js',
|
||||
format: 'amd',
|
||||
sourcemap: !production
|
||||
},
|
||||
onwarn,
|
||||
plugins: [
|
||||
vue(),
|
||||
replace({
|
||||
'process.env.NODE_ENV': JSON.stringify('production')
|
||||
}),
|
||||
resolve({
|
||||
mainFields: ['browser', 'jsnext', 'module', 'main'],
|
||||
include: 'node_modules/**',
|
||||
preferBuiltins: true
|
||||
}),
|
||||
babel({
|
||||
exclude: 'node_modules/**',
|
||||
runtimeHelpers: true
|
||||
}),
|
||||
commonjs({
|
||||
include: 'node_modules/**'
|
||||
}),
|
||||
json(),
|
||||
globals(),
|
||||
builtins(),
|
||||
production && terser(),
|
||||
production && filesize()
|
||||
]
|
||||
}
|
||||
31
third_party/google/api/annotations.proto
vendored
Normal file
31
third_party/google/api/annotations.proto
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
// Copyright (c) 2015, Google Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
syntax = "proto3";
|
||||
|
||||
package google.api;
|
||||
|
||||
import "google/api/http.proto";
|
||||
import "google/protobuf/descriptor.proto";
|
||||
|
||||
option go_package = "google.golang.org/genproto/googleapis/api/annotations;annotations";
|
||||
option java_multiple_files = true;
|
||||
option java_outer_classname = "AnnotationsProto";
|
||||
option java_package = "com.google.api";
|
||||
option objc_class_prefix = "GAPI";
|
||||
|
||||
extend google.protobuf.MethodOptions {
|
||||
// See `HttpRule`.
|
||||
HttpRule http = 72295728;
|
||||
}
|
||||
318
third_party/google/api/http.proto
vendored
Normal file
318
third_party/google/api/http.proto
vendored
Normal file
@@ -0,0 +1,318 @@
|
||||
// Copyright 2018 Google LLC
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
syntax = "proto3";
|
||||
|
||||
package google.api;
|
||||
|
||||
option cc_enable_arenas = true;
|
||||
option go_package = "google.golang.org/genproto/googleapis/api/annotations;annotations";
|
||||
option java_multiple_files = true;
|
||||
option java_outer_classname = "HttpProto";
|
||||
option java_package = "com.google.api";
|
||||
option objc_class_prefix = "GAPI";
|
||||
|
||||
|
||||
// Defines the HTTP configuration for an API service. It contains a list of
|
||||
// [HttpRule][google.api.HttpRule], each specifying the mapping of an RPC method
|
||||
// to one or more HTTP REST API methods.
|
||||
message Http {
|
||||
// A list of HTTP configuration rules that apply to individual API methods.
|
||||
//
|
||||
// **NOTE:** All service configuration rules follow "last one wins" order.
|
||||
repeated HttpRule rules = 1;
|
||||
|
||||
// When set to true, URL path parmeters will be fully URI-decoded except in
|
||||
// cases of single segment matches in reserved expansion, where "%2F" will be
|
||||
// left encoded.
|
||||
//
|
||||
// The default behavior is to not decode RFC 6570 reserved characters in multi
|
||||
// segment matches.
|
||||
bool fully_decode_reserved_expansion = 2;
|
||||
}
|
||||
|
||||
// `HttpRule` defines the mapping of an RPC method to one or more HTTP
|
||||
// REST API methods. The mapping specifies how different portions of the RPC
|
||||
// request message are mapped to URL path, URL query parameters, and
|
||||
// HTTP request body. The mapping is typically specified as an
|
||||
// `google.api.http` annotation on the RPC method,
|
||||
// see "google/api/annotations.proto" for details.
|
||||
//
|
||||
// The mapping consists of a field specifying the path template and
|
||||
// method kind. The path template can refer to fields in the request
|
||||
// message, as in the example below which describes a REST GET
|
||||
// operation on a resource collection of messages:
|
||||
//
|
||||
//
|
||||
// service Messaging {
|
||||
// rpc GetMessage(GetMessageRequest) returns (Message) {
|
||||
// option (google.api.http).get = "/v1/messages/{message_id}/{sub.subfield}";
|
||||
// }
|
||||
// }
|
||||
// message GetMessageRequest {
|
||||
// message SubMessage {
|
||||
// string subfield = 1;
|
||||
// }
|
||||
// string message_id = 1; // mapped to the URL
|
||||
// SubMessage sub = 2; // `sub.subfield` is url-mapped
|
||||
// }
|
||||
// message Message {
|
||||
// string text = 1; // content of the resource
|
||||
// }
|
||||
//
|
||||
// The same http annotation can alternatively be expressed inside the
|
||||
// `GRPC API Configuration` YAML file.
|
||||
//
|
||||
// http:
|
||||
// rules:
|
||||
// - selector: <proto_package_name>.Messaging.GetMessage
|
||||
// get: /v1/messages/{message_id}/{sub.subfield}
|
||||
//
|
||||
// This definition enables an automatic, bidrectional mapping of HTTP
|
||||
// JSON to RPC. Example:
|
||||
//
|
||||
// HTTP | RPC
|
||||
// -----|-----
|
||||
// `GET /v1/messages/123456/foo` | `GetMessage(message_id: "123456" sub: SubMessage(subfield: "foo"))`
|
||||
//
|
||||
// In general, not only fields but also field paths can be referenced
|
||||
// from a path pattern. Fields mapped to the path pattern cannot be
|
||||
// repeated and must have a primitive (non-message) type.
|
||||
//
|
||||
// Any fields in the request message which are not bound by the path
|
||||
// pattern automatically become (optional) HTTP query
|
||||
// parameters. Assume the following definition of the request message:
|
||||
//
|
||||
//
|
||||
// service Messaging {
|
||||
// rpc GetMessage(GetMessageRequest) returns (Message) {
|
||||
// option (google.api.http).get = "/v1/messages/{message_id}";
|
||||
// }
|
||||
// }
|
||||
// message GetMessageRequest {
|
||||
// message SubMessage {
|
||||
// string subfield = 1;
|
||||
// }
|
||||
// string message_id = 1; // mapped to the URL
|
||||
// int64 revision = 2; // becomes a parameter
|
||||
// SubMessage sub = 3; // `sub.subfield` becomes a parameter
|
||||
// }
|
||||
//
|
||||
//
|
||||
// This enables a HTTP JSON to RPC mapping as below:
|
||||
//
|
||||
// HTTP | RPC
|
||||
// -----|-----
|
||||
// `GET /v1/messages/123456?revision=2&sub.subfield=foo` | `GetMessage(message_id: "123456" revision: 2 sub: SubMessage(subfield: "foo"))`
|
||||
//
|
||||
// Note that fields which are mapped to HTTP parameters must have a
|
||||
// primitive type or a repeated primitive type. Message types are not
|
||||
// allowed. In the case of a repeated type, the parameter can be
|
||||
// repeated in the URL, as in `...?param=A¶m=B`.
|
||||
//
|
||||
// For HTTP method kinds which allow a request body, the `body` field
|
||||
// specifies the mapping. Consider a REST update method on the
|
||||
// message resource collection:
|
||||
//
|
||||
//
|
||||
// service Messaging {
|
||||
// rpc UpdateMessage(UpdateMessageRequest) returns (Message) {
|
||||
// option (google.api.http) = {
|
||||
// put: "/v1/messages/{message_id}"
|
||||
// body: "message"
|
||||
// };
|
||||
// }
|
||||
// }
|
||||
// message UpdateMessageRequest {
|
||||
// string message_id = 1; // mapped to the URL
|
||||
// Message message = 2; // mapped to the body
|
||||
// }
|
||||
//
|
||||
//
|
||||
// The following HTTP JSON to RPC mapping is enabled, where the
|
||||
// representation of the JSON in the request body is determined by
|
||||
// protos JSON encoding:
|
||||
//
|
||||
// HTTP | RPC
|
||||
// -----|-----
|
||||
// `PUT /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id: "123456" message { text: "Hi!" })`
|
||||
//
|
||||
// The special name `*` can be used in the body mapping to define that
|
||||
// every field not bound by the path template should be mapped to the
|
||||
// request body. This enables the following alternative definition of
|
||||
// the update method:
|
||||
//
|
||||
// service Messaging {
|
||||
// rpc UpdateMessage(Message) returns (Message) {
|
||||
// option (google.api.http) = {
|
||||
// put: "/v1/messages/{message_id}"
|
||||
// body: "*"
|
||||
// };
|
||||
// }
|
||||
// }
|
||||
// message Message {
|
||||
// string message_id = 1;
|
||||
// string text = 2;
|
||||
// }
|
||||
//
|
||||
//
|
||||
// The following HTTP JSON to RPC mapping is enabled:
|
||||
//
|
||||
// HTTP | RPC
|
||||
// -----|-----
|
||||
// `PUT /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id: "123456" text: "Hi!")`
|
||||
//
|
||||
// Note that when using `*` in the body mapping, it is not possible to
|
||||
// have HTTP parameters, as all fields not bound by the path end in
|
||||
// the body. This makes this option more rarely used in practice of
|
||||
// defining REST APIs. The common usage of `*` is in custom methods
|
||||
// which don't use the URL at all for transferring data.
|
||||
//
|
||||
// It is possible to define multiple HTTP methods for one RPC by using
|
||||
// the `additional_bindings` option. Example:
|
||||
//
|
||||
// service Messaging {
|
||||
// rpc GetMessage(GetMessageRequest) returns (Message) {
|
||||
// option (google.api.http) = {
|
||||
// get: "/v1/messages/{message_id}"
|
||||
// additional_bindings {
|
||||
// get: "/v1/users/{user_id}/messages/{message_id}"
|
||||
// }
|
||||
// };
|
||||
// }
|
||||
// }
|
||||
// message GetMessageRequest {
|
||||
// string message_id = 1;
|
||||
// string user_id = 2;
|
||||
// }
|
||||
//
|
||||
//
|
||||
// This enables the following two alternative HTTP JSON to RPC
|
||||
// mappings:
|
||||
//
|
||||
// HTTP | RPC
|
||||
// -----|-----
|
||||
// `GET /v1/messages/123456` | `GetMessage(message_id: "123456")`
|
||||
// `GET /v1/users/me/messages/123456` | `GetMessage(user_id: "me" message_id: "123456")`
|
||||
//
|
||||
// # Rules for HTTP mapping
|
||||
//
|
||||
// The rules for mapping HTTP path, query parameters, and body fields
|
||||
// to the request message are as follows:
|
||||
//
|
||||
// 1. The `body` field specifies either `*` or a field path, or is
|
||||
// omitted. If omitted, it indicates there is no HTTP request body.
|
||||
// 2. Leaf fields (recursive expansion of nested messages in the
|
||||
// request) can be classified into three types:
|
||||
// (a) Matched in the URL template.
|
||||
// (b) Covered by body (if body is `*`, everything except (a) fields;
|
||||
// else everything under the body field)
|
||||
// (c) All other fields.
|
||||
// 3. URL query parameters found in the HTTP request are mapped to (c) fields.
|
||||
// 4. Any body sent with an HTTP request can contain only (b) fields.
|
||||
//
|
||||
// The syntax of the path template is as follows:
|
||||
//
|
||||
// Template = "/" Segments [ Verb ] ;
|
||||
// Segments = Segment { "/" Segment } ;
|
||||
// Segment = "*" | "**" | LITERAL | Variable ;
|
||||
// Variable = "{" FieldPath [ "=" Segments ] "}" ;
|
||||
// FieldPath = IDENT { "." IDENT } ;
|
||||
// Verb = ":" LITERAL ;
|
||||
//
|
||||
// The syntax `*` matches a single path segment. The syntax `**` matches zero
|
||||
// or more path segments, which must be the last part of the path except the
|
||||
// `Verb`. The syntax `LITERAL` matches literal text in the path.
|
||||
//
|
||||
// The syntax `Variable` matches part of the URL path as specified by its
|
||||
// template. A variable template must not contain other variables. If a variable
|
||||
// matches a single path segment, its template may be omitted, e.g. `{var}`
|
||||
// is equivalent to `{var=*}`.
|
||||
//
|
||||
// If a variable contains exactly one path segment, such as `"{var}"` or
|
||||
// `"{var=*}"`, when such a variable is expanded into a URL path, all characters
|
||||
// except `[-_.~0-9a-zA-Z]` are percent-encoded. Such variables show up in the
|
||||
// Discovery Document as `{var}`.
|
||||
//
|
||||
// If a variable contains one or more path segments, such as `"{var=foo/*}"`
|
||||
// or `"{var=**}"`, when such a variable is expanded into a URL path, all
|
||||
// characters except `[-_.~/0-9a-zA-Z]` are percent-encoded. Such variables
|
||||
// show up in the Discovery Document as `{+var}`.
|
||||
//
|
||||
// NOTE: While the single segment variable matches the semantics of
|
||||
// [RFC 6570](https://tools.ietf.org/html/rfc6570) Section 3.2.2
|
||||
// Simple String Expansion, the multi segment variable **does not** match
|
||||
// RFC 6570 Reserved Expansion. The reason is that the Reserved Expansion
|
||||
// does not expand special characters like `?` and `#`, which would lead
|
||||
// to invalid URLs.
|
||||
//
|
||||
// NOTE: the field paths in variables and in the `body` must not refer to
|
||||
// repeated fields or map fields.
|
||||
message HttpRule {
|
||||
// Selects methods to which this rule applies.
|
||||
//
|
||||
// Refer to [selector][google.api.DocumentationRule.selector] for syntax details.
|
||||
string selector = 1;
|
||||
|
||||
// Determines the URL pattern is matched by this rules. This pattern can be
|
||||
// used with any of the {get|put|post|delete|patch} methods. A custom method
|
||||
// can be defined using the 'custom' field.
|
||||
oneof pattern {
|
||||
// Used for listing and getting information about resources.
|
||||
string get = 2;
|
||||
|
||||
// Used for updating a resource.
|
||||
string put = 3;
|
||||
|
||||
// Used for creating a resource.
|
||||
string post = 4;
|
||||
|
||||
// Used for deleting a resource.
|
||||
string delete = 5;
|
||||
|
||||
// Used for updating a resource.
|
||||
string patch = 6;
|
||||
|
||||
// The custom pattern is used for specifying an HTTP method that is not
|
||||
// included in the `pattern` field, such as HEAD, or "*" to leave the
|
||||
// HTTP method unspecified for this rule. The wild-card rule is useful
|
||||
// for services that provide content to Web (HTML) clients.
|
||||
CustomHttpPattern custom = 8;
|
||||
}
|
||||
|
||||
// The name of the request field whose value is mapped to the HTTP body, or
|
||||
// `*` for mapping all fields not captured by the path pattern to the HTTP
|
||||
// body. NOTE: the referred field must not be a repeated field and must be
|
||||
// present at the top-level of request message type.
|
||||
string body = 7;
|
||||
|
||||
// Optional. The name of the response field whose value is mapped to the HTTP
|
||||
// body of response. Other response fields are ignored. When
|
||||
// not set, the response message will be used as HTTP body of response.
|
||||
string response_body = 12;
|
||||
|
||||
// Additional HTTP bindings for the selector. Nested bindings must
|
||||
// not contain an `additional_bindings` field themselves (that is,
|
||||
// the nesting may only be one level deep).
|
||||
repeated HttpRule additional_bindings = 11;
|
||||
}
|
||||
|
||||
// A custom pattern is used for defining custom HTTP verb.
|
||||
message CustomHttpPattern {
|
||||
// The name of this custom HTTP verb.
|
||||
string kind = 1;
|
||||
|
||||
// The path matched by this custom verb.
|
||||
string path = 2;
|
||||
}
|
||||
78
third_party/google/api/httpbody.proto
vendored
Normal file
78
third_party/google/api/httpbody.proto
vendored
Normal file
@@ -0,0 +1,78 @@
|
||||
// Copyright 2018 Google LLC.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
syntax = "proto3";
|
||||
|
||||
package google.api;
|
||||
|
||||
import "google/protobuf/any.proto";
|
||||
|
||||
option cc_enable_arenas = true;
|
||||
option go_package = "google.golang.org/genproto/googleapis/api/httpbody;httpbody";
|
||||
option java_multiple_files = true;
|
||||
option java_outer_classname = "HttpBodyProto";
|
||||
option java_package = "com.google.api";
|
||||
option objc_class_prefix = "GAPI";
|
||||
|
||||
// Message that represents an arbitrary HTTP body. It should only be used for
|
||||
// payload formats that can't be represented as JSON, such as raw binary or
|
||||
// an HTML page.
|
||||
//
|
||||
//
|
||||
// This message can be used both in streaming and non-streaming API methods in
|
||||
// the request as well as the response.
|
||||
//
|
||||
// It can be used as a top-level request field, which is convenient if one
|
||||
// wants to extract parameters from either the URL or HTTP template into the
|
||||
// request fields and also want access to the raw HTTP body.
|
||||
//
|
||||
// Example:
|
||||
//
|
||||
// message GetResourceRequest {
|
||||
// // A unique request id.
|
||||
// string request_id = 1;
|
||||
//
|
||||
// // The raw HTTP body is bound to this field.
|
||||
// google.api.HttpBody http_body = 2;
|
||||
// }
|
||||
//
|
||||
// service ResourceService {
|
||||
// rpc GetResource(GetResourceRequest) returns (google.api.HttpBody);
|
||||
// rpc UpdateResource(google.api.HttpBody) returns
|
||||
// (google.protobuf.Empty);
|
||||
// }
|
||||
//
|
||||
// Example with streaming methods:
|
||||
//
|
||||
// service CaldavService {
|
||||
// rpc GetCalendar(stream google.api.HttpBody)
|
||||
// returns (stream google.api.HttpBody);
|
||||
// rpc UpdateCalendar(stream google.api.HttpBody)
|
||||
// returns (stream google.api.HttpBody);
|
||||
// }
|
||||
//
|
||||
// Use of this type only changes how the request and response bodies are
|
||||
// handled, all other features will continue to work unchanged.
|
||||
message HttpBody {
|
||||
// The HTTP Content-Type header value specifying the content type of the body.
|
||||
string content_type = 1;
|
||||
|
||||
// The HTTP request/response body as raw binary.
|
||||
bytes data = 2;
|
||||
|
||||
// Application specific response metadata. Must be set in the first response
|
||||
// for streaming APIs.
|
||||
repeated google.protobuf.Any extensions = 3;
|
||||
}
|
||||
154
third_party/google/protobuf/any.proto
vendored
Normal file
154
third_party/google/protobuf/any.proto
vendored
Normal file
@@ -0,0 +1,154 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// https://developers.google.com/protocol-buffers/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
syntax = "proto3";
|
||||
|
||||
package google.protobuf;
|
||||
|
||||
option csharp_namespace = "Google.Protobuf.WellKnownTypes";
|
||||
option go_package = "github.com/golang/protobuf/ptypes/any";
|
||||
option java_package = "com.google.protobuf";
|
||||
option java_outer_classname = "AnyProto";
|
||||
option java_multiple_files = true;
|
||||
option objc_class_prefix = "GPB";
|
||||
|
||||
// `Any` contains an arbitrary serialized protocol buffer message along with a
|
||||
// URL that describes the type of the serialized message.
|
||||
//
|
||||
// Protobuf library provides support to pack/unpack Any values in the form
|
||||
// of utility functions or additional generated methods of the Any type.
|
||||
//
|
||||
// Example 1: Pack and unpack a message in C++.
|
||||
//
|
||||
// Foo foo = ...;
|
||||
// Any any;
|
||||
// any.PackFrom(foo);
|
||||
// ...
|
||||
// if (any.UnpackTo(&foo)) {
|
||||
// ...
|
||||
// }
|
||||
//
|
||||
// Example 2: Pack and unpack a message in Java.
|
||||
//
|
||||
// Foo foo = ...;
|
||||
// Any any = Any.pack(foo);
|
||||
// ...
|
||||
// if (any.is(Foo.class)) {
|
||||
// foo = any.unpack(Foo.class);
|
||||
// }
|
||||
//
|
||||
// Example 3: Pack and unpack a message in Python.
|
||||
//
|
||||
// foo = Foo(...)
|
||||
// any = Any()
|
||||
// any.Pack(foo)
|
||||
// ...
|
||||
// if any.Is(Foo.DESCRIPTOR):
|
||||
// any.Unpack(foo)
|
||||
// ...
|
||||
//
|
||||
// Example 4: Pack and unpack a message in Go
|
||||
//
|
||||
// foo := &pb.Foo{...}
|
||||
// any, err := ptypes.MarshalAny(foo)
|
||||
// ...
|
||||
// foo := &pb.Foo{}
|
||||
// if err := ptypes.UnmarshalAny(any, foo); err != nil {
|
||||
// ...
|
||||
// }
|
||||
//
|
||||
// The pack methods provided by protobuf library will by default use
|
||||
// 'type.googleapis.com/full.type.name' as the type URL and the unpack
|
||||
// methods only use the fully qualified type name after the last '/'
|
||||
// in the type URL, for example "foo.bar.com/x/y.z" will yield type
|
||||
// name "y.z".
|
||||
//
|
||||
//
|
||||
// JSON
|
||||
// ====
|
||||
// The JSON representation of an `Any` value uses the regular
|
||||
// representation of the deserialized, embedded message, with an
|
||||
// additional field `@type` which contains the type URL. Example:
|
||||
//
|
||||
// package google.profile;
|
||||
// message Person {
|
||||
// string first_name = 1;
|
||||
// string last_name = 2;
|
||||
// }
|
||||
//
|
||||
// {
|
||||
// "@type": "type.googleapis.com/google.profile.Person",
|
||||
// "firstName": <string>,
|
||||
// "lastName": <string>
|
||||
// }
|
||||
//
|
||||
// If the embedded message type is well-known and has a custom JSON
|
||||
// representation, that representation will be embedded adding a field
|
||||
// `value` which holds the custom JSON in addition to the `@type`
|
||||
// field. Example (for message [google.protobuf.Duration][]):
|
||||
//
|
||||
// {
|
||||
// "@type": "type.googleapis.com/google.protobuf.Duration",
|
||||
// "value": "1.212s"
|
||||
// }
|
||||
//
|
||||
message Any {
|
||||
// A URL/resource name that uniquely identifies the type of the serialized
|
||||
// protocol buffer message. The last segment of the URL's path must represent
|
||||
// the fully qualified name of the type (as in
|
||||
// `path/google.protobuf.Duration`). The name should be in a canonical form
|
||||
// (e.g., leading "." is not accepted).
|
||||
//
|
||||
// In practice, teams usually precompile into the binary all types that they
|
||||
// expect it to use in the context of Any. However, for URLs which use the
|
||||
// scheme `http`, `https`, or no scheme, one can optionally set up a type
|
||||
// server that maps type URLs to message definitions as follows:
|
||||
//
|
||||
// * If no scheme is provided, `https` is assumed.
|
||||
// * An HTTP GET on the URL must yield a [google.protobuf.Type][]
|
||||
// value in binary format, or produce an error.
|
||||
// * Applications are allowed to cache lookup results based on the
|
||||
// URL, or have them precompiled into a binary to avoid any
|
||||
// lookup. Therefore, binary compatibility needs to be preserved
|
||||
// on changes to types. (Use versioned type names to manage
|
||||
// breaking changes.)
|
||||
//
|
||||
// Note: this functionality is not currently available in the official
|
||||
// protobuf release, and it is not used for type URLs beginning with
|
||||
// type.googleapis.com.
|
||||
//
|
||||
// Schemes other than `http`, `https` (or the empty scheme) might be
|
||||
// used with implementation specific semantics.
|
||||
//
|
||||
string type_url = 1;
|
||||
|
||||
// Must be a valid serialized protocol buffer of the above specified type.
|
||||
bytes value = 2;
|
||||
}
|
||||
883
third_party/google/protobuf/descriptor.proto
vendored
Normal file
883
third_party/google/protobuf/descriptor.proto
vendored
Normal file
@@ -0,0 +1,883 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// https://developers.google.com/protocol-buffers/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// Author: kenton@google.com (Kenton Varda)
|
||||
// Based on original Protocol Buffers design by
|
||||
// Sanjay Ghemawat, Jeff Dean, and others.
|
||||
//
|
||||
// The messages in this file describe the definitions found in .proto files.
|
||||
// A valid .proto file can be translated directly to a FileDescriptorProto
|
||||
// without any other information (e.g. without reading its imports).
|
||||
|
||||
|
||||
syntax = "proto2";
|
||||
|
||||
package google.protobuf;
|
||||
option go_package = "github.com/golang/protobuf/protoc-gen-go/descriptor;descriptor";
|
||||
option java_package = "com.google.protobuf";
|
||||
option java_outer_classname = "DescriptorProtos";
|
||||
option csharp_namespace = "Google.Protobuf.Reflection";
|
||||
option objc_class_prefix = "GPB";
|
||||
option cc_enable_arenas = true;
|
||||
|
||||
// descriptor.proto must be optimized for speed because reflection-based
|
||||
// algorithms don't work during bootstrapping.
|
||||
option optimize_for = SPEED;
|
||||
|
||||
// The protocol compiler can output a FileDescriptorSet containing the .proto
|
||||
// files it parses.
|
||||
message FileDescriptorSet {
|
||||
repeated FileDescriptorProto file = 1;
|
||||
}
|
||||
|
||||
// Describes a complete .proto file.
|
||||
message FileDescriptorProto {
|
||||
optional string name = 1; // file name, relative to root of source tree
|
||||
optional string package = 2; // e.g. "foo", "foo.bar", etc.
|
||||
|
||||
// Names of files imported by this file.
|
||||
repeated string dependency = 3;
|
||||
// Indexes of the public imported files in the dependency list above.
|
||||
repeated int32 public_dependency = 10;
|
||||
// Indexes of the weak imported files in the dependency list.
|
||||
// For Google-internal migration only. Do not use.
|
||||
repeated int32 weak_dependency = 11;
|
||||
|
||||
// All top-level definitions in this file.
|
||||
repeated DescriptorProto message_type = 4;
|
||||
repeated EnumDescriptorProto enum_type = 5;
|
||||
repeated ServiceDescriptorProto service = 6;
|
||||
repeated FieldDescriptorProto extension = 7;
|
||||
|
||||
optional FileOptions options = 8;
|
||||
|
||||
// This field contains optional information about the original source code.
|
||||
// You may safely remove this entire field without harming runtime
|
||||
// functionality of the descriptors -- the information is needed only by
|
||||
// development tools.
|
||||
optional SourceCodeInfo source_code_info = 9;
|
||||
|
||||
// The syntax of the proto file.
|
||||
// The supported values are "proto2" and "proto3".
|
||||
optional string syntax = 12;
|
||||
}
|
||||
|
||||
// Describes a message type.
|
||||
message DescriptorProto {
|
||||
optional string name = 1;
|
||||
|
||||
repeated FieldDescriptorProto field = 2;
|
||||
repeated FieldDescriptorProto extension = 6;
|
||||
|
||||
repeated DescriptorProto nested_type = 3;
|
||||
repeated EnumDescriptorProto enum_type = 4;
|
||||
|
||||
message ExtensionRange {
|
||||
optional int32 start = 1;
|
||||
optional int32 end = 2;
|
||||
|
||||
optional ExtensionRangeOptions options = 3;
|
||||
}
|
||||
repeated ExtensionRange extension_range = 5;
|
||||
|
||||
repeated OneofDescriptorProto oneof_decl = 8;
|
||||
|
||||
optional MessageOptions options = 7;
|
||||
|
||||
// Range of reserved tag numbers. Reserved tag numbers may not be used by
|
||||
// fields or extension ranges in the same message. Reserved ranges may
|
||||
// not overlap.
|
||||
message ReservedRange {
|
||||
optional int32 start = 1; // Inclusive.
|
||||
optional int32 end = 2; // Exclusive.
|
||||
}
|
||||
repeated ReservedRange reserved_range = 9;
|
||||
// Reserved field names, which may not be used by fields in the same message.
|
||||
// A given name may only be reserved once.
|
||||
repeated string reserved_name = 10;
|
||||
}
|
||||
|
||||
message ExtensionRangeOptions {
|
||||
// The parser stores options it doesn't recognize here. See above.
|
||||
repeated UninterpretedOption uninterpreted_option = 999;
|
||||
|
||||
// Clients can define custom options in extensions of this message. See above.
|
||||
extensions 1000 to max;
|
||||
}
|
||||
|
||||
// Describes a field within a message.
|
||||
message FieldDescriptorProto {
|
||||
enum Type {
|
||||
// 0 is reserved for errors.
|
||||
// Order is weird for historical reasons.
|
||||
TYPE_DOUBLE = 1;
|
||||
TYPE_FLOAT = 2;
|
||||
// Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT64 if
|
||||
// negative values are likely.
|
||||
TYPE_INT64 = 3;
|
||||
TYPE_UINT64 = 4;
|
||||
// Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT32 if
|
||||
// negative values are likely.
|
||||
TYPE_INT32 = 5;
|
||||
TYPE_FIXED64 = 6;
|
||||
TYPE_FIXED32 = 7;
|
||||
TYPE_BOOL = 8;
|
||||
TYPE_STRING = 9;
|
||||
// Tag-delimited aggregate.
|
||||
// Group type is deprecated and not supported in proto3. However, Proto3
|
||||
// implementations should still be able to parse the group wire format and
|
||||
// treat group fields as unknown fields.
|
||||
TYPE_GROUP = 10;
|
||||
TYPE_MESSAGE = 11; // Length-delimited aggregate.
|
||||
|
||||
// New in version 2.
|
||||
TYPE_BYTES = 12;
|
||||
TYPE_UINT32 = 13;
|
||||
TYPE_ENUM = 14;
|
||||
TYPE_SFIXED32 = 15;
|
||||
TYPE_SFIXED64 = 16;
|
||||
TYPE_SINT32 = 17; // Uses ZigZag encoding.
|
||||
TYPE_SINT64 = 18; // Uses ZigZag encoding.
|
||||
};
|
||||
|
||||
enum Label {
|
||||
// 0 is reserved for errors
|
||||
LABEL_OPTIONAL = 1;
|
||||
LABEL_REQUIRED = 2;
|
||||
LABEL_REPEATED = 3;
|
||||
};
|
||||
|
||||
optional string name = 1;
|
||||
optional int32 number = 3;
|
||||
optional Label label = 4;
|
||||
|
||||
// If type_name is set, this need not be set. If both this and type_name
|
||||
// are set, this must be one of TYPE_ENUM, TYPE_MESSAGE or TYPE_GROUP.
|
||||
optional Type type = 5;
|
||||
|
||||
// For message and enum types, this is the name of the type. If the name
|
||||
// starts with a '.', it is fully-qualified. Otherwise, C++-like scoping
|
||||
// rules are used to find the type (i.e. first the nested types within this
|
||||
// message are searched, then within the parent, on up to the root
|
||||
// namespace).
|
||||
optional string type_name = 6;
|
||||
|
||||
// For extensions, this is the name of the type being extended. It is
|
||||
// resolved in the same manner as type_name.
|
||||
optional string extendee = 2;
|
||||
|
||||
// For numeric types, contains the original text representation of the value.
|
||||
// For booleans, "true" or "false".
|
||||
// For strings, contains the default text contents (not escaped in any way).
|
||||
// For bytes, contains the C escaped value. All bytes >= 128 are escaped.
|
||||
// TODO(kenton): Base-64 encode?
|
||||
optional string default_value = 7;
|
||||
|
||||
// If set, gives the index of a oneof in the containing type's oneof_decl
|
||||
// list. This field is a member of that oneof.
|
||||
optional int32 oneof_index = 9;
|
||||
|
||||
// JSON name of this field. The value is set by protocol compiler. If the
|
||||
// user has set a "json_name" option on this field, that option's value
|
||||
// will be used. Otherwise, it's deduced from the field's name by converting
|
||||
// it to camelCase.
|
||||
optional string json_name = 10;
|
||||
|
||||
optional FieldOptions options = 8;
|
||||
}
|
||||
|
||||
// Describes a oneof.
|
||||
message OneofDescriptorProto {
|
||||
optional string name = 1;
|
||||
optional OneofOptions options = 2;
|
||||
}
|
||||
|
||||
// Describes an enum type.
|
||||
message EnumDescriptorProto {
|
||||
optional string name = 1;
|
||||
|
||||
repeated EnumValueDescriptorProto value = 2;
|
||||
|
||||
optional EnumOptions options = 3;
|
||||
|
||||
// Range of reserved numeric values. Reserved values may not be used by
|
||||
// entries in the same enum. Reserved ranges may not overlap.
|
||||
//
|
||||
// Note that this is distinct from DescriptorProto.ReservedRange in that it
|
||||
// is inclusive such that it can appropriately represent the entire int32
|
||||
// domain.
|
||||
message EnumReservedRange {
|
||||
optional int32 start = 1; // Inclusive.
|
||||
optional int32 end = 2; // Inclusive.
|
||||
}
|
||||
|
||||
// Range of reserved numeric values. Reserved numeric values may not be used
|
||||
// by enum values in the same enum declaration. Reserved ranges may not
|
||||
// overlap.
|
||||
repeated EnumReservedRange reserved_range = 4;
|
||||
|
||||
// Reserved enum value names, which may not be reused. A given name may only
|
||||
// be reserved once.
|
||||
repeated string reserved_name = 5;
|
||||
}
|
||||
|
||||
// Describes a value within an enum.
|
||||
message EnumValueDescriptorProto {
|
||||
optional string name = 1;
|
||||
optional int32 number = 2;
|
||||
|
||||
optional EnumValueOptions options = 3;
|
||||
}
|
||||
|
||||
// Describes a service.
|
||||
message ServiceDescriptorProto {
|
||||
optional string name = 1;
|
||||
repeated MethodDescriptorProto method = 2;
|
||||
|
||||
optional ServiceOptions options = 3;
|
||||
}
|
||||
|
||||
// Describes a method of a service.
|
||||
message MethodDescriptorProto {
|
||||
optional string name = 1;
|
||||
|
||||
// Input and output type names. These are resolved in the same way as
|
||||
// FieldDescriptorProto.type_name, but must refer to a message type.
|
||||
optional string input_type = 2;
|
||||
optional string output_type = 3;
|
||||
|
||||
optional MethodOptions options = 4;
|
||||
|
||||
// Identifies if client streams multiple client messages
|
||||
optional bool client_streaming = 5 [default=false];
|
||||
// Identifies if server streams multiple server messages
|
||||
optional bool server_streaming = 6 [default=false];
|
||||
}
|
||||
|
||||
|
||||
// ===================================================================
|
||||
// Options
|
||||
|
||||
// Each of the definitions above may have "options" attached. These are
|
||||
// just annotations which may cause code to be generated slightly differently
|
||||
// or may contain hints for code that manipulates protocol messages.
|
||||
//
|
||||
// Clients may define custom options as extensions of the *Options messages.
|
||||
// These extensions may not yet be known at parsing time, so the parser cannot
|
||||
// store the values in them. Instead it stores them in a field in the *Options
|
||||
// message called uninterpreted_option. This field must have the same name
|
||||
// across all *Options messages. We then use this field to populate the
|
||||
// extensions when we build a descriptor, at which point all protos have been
|
||||
// parsed and so all extensions are known.
|
||||
//
|
||||
// Extension numbers for custom options may be chosen as follows:
|
||||
// * For options which will only be used within a single application or
|
||||
// organization, or for experimental options, use field numbers 50000
|
||||
// through 99999. It is up to you to ensure that you do not use the
|
||||
// same number for multiple options.
|
||||
// * For options which will be published and used publicly by multiple
|
||||
// independent entities, e-mail protobuf-global-extension-registry@google.com
|
||||
// to reserve extension numbers. Simply provide your project name (e.g.
|
||||
// Objective-C plugin) and your project website (if available) -- there's no
|
||||
// need to explain how you intend to use them. Usually you only need one
|
||||
// extension number. You can declare multiple options with only one extension
|
||||
// number by putting them in a sub-message. See the Custom Options section of
|
||||
// the docs for examples:
|
||||
// https://developers.google.com/protocol-buffers/docs/proto#options
|
||||
// If this turns out to be popular, a web service will be set up
|
||||
// to automatically assign option numbers.
|
||||
|
||||
|
||||
message FileOptions {
|
||||
|
||||
// Sets the Java package where classes generated from this .proto will be
|
||||
// placed. By default, the proto package is used, but this is often
|
||||
// inappropriate because proto packages do not normally start with backwards
|
||||
// domain names.
|
||||
optional string java_package = 1;
|
||||
|
||||
|
||||
// If set, all the classes from the .proto file are wrapped in a single
|
||||
// outer class with the given name. This applies to both Proto1
|
||||
// (equivalent to the old "--one_java_file" option) and Proto2 (where
|
||||
// a .proto always translates to a single class, but you may want to
|
||||
// explicitly choose the class name).
|
||||
optional string java_outer_classname = 8;
|
||||
|
||||
// If set true, then the Java code generator will generate a separate .java
|
||||
// file for each top-level message, enum, and service defined in the .proto
|
||||
// file. Thus, these types will *not* be nested inside the outer class
|
||||
// named by java_outer_classname. However, the outer class will still be
|
||||
// generated to contain the file's getDescriptor() method as well as any
|
||||
// top-level extensions defined in the file.
|
||||
optional bool java_multiple_files = 10 [default=false];
|
||||
|
||||
// This option does nothing.
|
||||
optional bool java_generate_equals_and_hash = 20 [deprecated=true];
|
||||
|
||||
// If set true, then the Java2 code generator will generate code that
|
||||
// throws an exception whenever an attempt is made to assign a non-UTF-8
|
||||
// byte sequence to a string field.
|
||||
// Message reflection will do the same.
|
||||
// However, an extension field still accepts non-UTF-8 byte sequences.
|
||||
// This option has no effect on when used with the lite runtime.
|
||||
optional bool java_string_check_utf8 = 27 [default=false];
|
||||
|
||||
|
||||
// Generated classes can be optimized for speed or code size.
|
||||
enum OptimizeMode {
|
||||
SPEED = 1; // Generate complete code for parsing, serialization,
|
||||
// etc.
|
||||
CODE_SIZE = 2; // Use ReflectionOps to implement these methods.
|
||||
LITE_RUNTIME = 3; // Generate code using MessageLite and the lite runtime.
|
||||
}
|
||||
optional OptimizeMode optimize_for = 9 [default=SPEED];
|
||||
|
||||
// Sets the Go package where structs generated from this .proto will be
|
||||
// placed. If omitted, the Go package will be derived from the following:
|
||||
// - The basename of the package import path, if provided.
|
||||
// - Otherwise, the package statement in the .proto file, if present.
|
||||
// - Otherwise, the basename of the .proto file, without extension.
|
||||
optional string go_package = 11;
|
||||
|
||||
|
||||
|
||||
// Should generic services be generated in each language? "Generic" services
|
||||
// are not specific to any particular RPC system. They are generated by the
|
||||
// main code generators in each language (without additional plugins).
|
||||
// Generic services were the only kind of service generation supported by
|
||||
// early versions of google.protobuf.
|
||||
//
|
||||
// Generic services are now considered deprecated in favor of using plugins
|
||||
// that generate code specific to your particular RPC system. Therefore,
|
||||
// these default to false. Old code which depends on generic services should
|
||||
// explicitly set them to true.
|
||||
optional bool cc_generic_services = 16 [default=false];
|
||||
optional bool java_generic_services = 17 [default=false];
|
||||
optional bool py_generic_services = 18 [default=false];
|
||||
optional bool php_generic_services = 42 [default=false];
|
||||
|
||||
// Is this file deprecated?
|
||||
// Depending on the target platform, this can emit Deprecated annotations
|
||||
// for everything in the file, or it will be completely ignored; in the very
|
||||
// least, this is a formalization for deprecating files.
|
||||
optional bool deprecated = 23 [default=false];
|
||||
|
||||
// Enables the use of arenas for the proto messages in this file. This applies
|
||||
// only to generated classes for C++.
|
||||
optional bool cc_enable_arenas = 31 [default=false];
|
||||
|
||||
|
||||
// Sets the objective c class prefix which is prepended to all objective c
|
||||
// generated classes from this .proto. There is no default.
|
||||
optional string objc_class_prefix = 36;
|
||||
|
||||
// Namespace for generated classes; defaults to the package.
|
||||
optional string csharp_namespace = 37;
|
||||
|
||||
// By default Swift generators will take the proto package and CamelCase it
|
||||
// replacing '.' with underscore and use that to prefix the types/symbols
|
||||
// defined. When this options is provided, they will use this value instead
|
||||
// to prefix the types/symbols defined.
|
||||
optional string swift_prefix = 39;
|
||||
|
||||
// Sets the php class prefix which is prepended to all php generated classes
|
||||
// from this .proto. Default is empty.
|
||||
optional string php_class_prefix = 40;
|
||||
|
||||
// Use this option to change the namespace of php generated classes. Default
|
||||
// is empty. When this option is empty, the package name will be used for
|
||||
// determining the namespace.
|
||||
optional string php_namespace = 41;
|
||||
|
||||
|
||||
// Use this option to change the namespace of php generated metadata classes.
|
||||
// Default is empty. When this option is empty, the proto file name will be used
|
||||
// for determining the namespace.
|
||||
optional string php_metadata_namespace = 44;
|
||||
|
||||
// Use this option to change the package of ruby generated classes. Default
|
||||
// is empty. When this option is not set, the package name will be used for
|
||||
// determining the ruby package.
|
||||
optional string ruby_package = 45;
|
||||
|
||||
// The parser stores options it doesn't recognize here.
|
||||
// See the documentation for the "Options" section above.
|
||||
repeated UninterpretedOption uninterpreted_option = 999;
|
||||
|
||||
// Clients can define custom options in extensions of this message.
|
||||
// See the documentation for the "Options" section above.
|
||||
extensions 1000 to max;
|
||||
|
||||
reserved 38;
|
||||
}
|
||||
|
||||
message MessageOptions {
|
||||
// Set true to use the old proto1 MessageSet wire format for extensions.
|
||||
// This is provided for backwards-compatibility with the MessageSet wire
|
||||
// format. You should not use this for any other reason: It's less
|
||||
// efficient, has fewer features, and is more complicated.
|
||||
//
|
||||
// The message must be defined exactly as follows:
|
||||
// message Foo {
|
||||
// option message_set_wire_format = true;
|
||||
// extensions 4 to max;
|
||||
// }
|
||||
// Note that the message cannot have any defined fields; MessageSets only
|
||||
// have extensions.
|
||||
//
|
||||
// All extensions of your type must be singular messages; e.g. they cannot
|
||||
// be int32s, enums, or repeated messages.
|
||||
//
|
||||
// Because this is an option, the above two restrictions are not enforced by
|
||||
// the protocol compiler.
|
||||
optional bool message_set_wire_format = 1 [default=false];
|
||||
|
||||
// Disables the generation of the standard "descriptor()" accessor, which can
|
||||
// conflict with a field of the same name. This is meant to make migration
|
||||
// from proto1 easier; new code should avoid fields named "descriptor".
|
||||
optional bool no_standard_descriptor_accessor = 2 [default=false];
|
||||
|
||||
// Is this message deprecated?
|
||||
// Depending on the target platform, this can emit Deprecated annotations
|
||||
// for the message, or it will be completely ignored; in the very least,
|
||||
// this is a formalization for deprecating messages.
|
||||
optional bool deprecated = 3 [default=false];
|
||||
|
||||
// Whether the message is an automatically generated map entry type for the
|
||||
// maps field.
|
||||
//
|
||||
// For maps fields:
|
||||
// map<KeyType, ValueType> map_field = 1;
|
||||
// The parsed descriptor looks like:
|
||||
// message MapFieldEntry {
|
||||
// option map_entry = true;
|
||||
// optional KeyType key = 1;
|
||||
// optional ValueType value = 2;
|
||||
// }
|
||||
// repeated MapFieldEntry map_field = 1;
|
||||
//
|
||||
// Implementations may choose not to generate the map_entry=true message, but
|
||||
// use a native map in the target language to hold the keys and values.
|
||||
// The reflection APIs in such implementions still need to work as
|
||||
// if the field is a repeated message field.
|
||||
//
|
||||
// NOTE: Do not set the option in .proto files. Always use the maps syntax
|
||||
// instead. The option should only be implicitly set by the proto compiler
|
||||
// parser.
|
||||
optional bool map_entry = 7;
|
||||
|
||||
reserved 8; // javalite_serializable
|
||||
reserved 9; // javanano_as_lite
|
||||
|
||||
// The parser stores options it doesn't recognize here. See above.
|
||||
repeated UninterpretedOption uninterpreted_option = 999;
|
||||
|
||||
// Clients can define custom options in extensions of this message. See above.
|
||||
extensions 1000 to max;
|
||||
}
|
||||
|
||||
message FieldOptions {
|
||||
// The ctype option instructs the C++ code generator to use a different
|
||||
// representation of the field than it normally would. See the specific
|
||||
// options below. This option is not yet implemented in the open source
|
||||
// release -- sorry, we'll try to include it in a future version!
|
||||
optional CType ctype = 1 [default = STRING];
|
||||
enum CType {
|
||||
// Default mode.
|
||||
STRING = 0;
|
||||
|
||||
CORD = 1;
|
||||
|
||||
STRING_PIECE = 2;
|
||||
}
|
||||
// The packed option can be enabled for repeated primitive fields to enable
|
||||
// a more efficient representation on the wire. Rather than repeatedly
|
||||
// writing the tag and type for each element, the entire array is encoded as
|
||||
// a single length-delimited blob. In proto3, only explicit setting it to
|
||||
// false will avoid using packed encoding.
|
||||
optional bool packed = 2;
|
||||
|
||||
// The jstype option determines the JavaScript type used for values of the
|
||||
// field. The option is permitted only for 64 bit integral and fixed types
|
||||
// (int64, uint64, sint64, fixed64, sfixed64). A field with jstype JS_STRING
|
||||
// is represented as JavaScript string, which avoids loss of precision that
|
||||
// can happen when a large value is converted to a floating point JavaScript.
|
||||
// Specifying JS_NUMBER for the jstype causes the generated JavaScript code to
|
||||
// use the JavaScript "number" type. The behavior of the default option
|
||||
// JS_NORMAL is implementation dependent.
|
||||
//
|
||||
// This option is an enum to permit additional types to be added, e.g.
|
||||
// goog.math.Integer.
|
||||
optional JSType jstype = 6 [default = JS_NORMAL];
|
||||
enum JSType {
|
||||
// Use the default type.
|
||||
JS_NORMAL = 0;
|
||||
|
||||
// Use JavaScript strings.
|
||||
JS_STRING = 1;
|
||||
|
||||
// Use JavaScript numbers.
|
||||
JS_NUMBER = 2;
|
||||
}
|
||||
|
||||
// Should this field be parsed lazily? Lazy applies only to message-type
|
||||
// fields. It means that when the outer message is initially parsed, the
|
||||
// inner message's contents will not be parsed but instead stored in encoded
|
||||
// form. The inner message will actually be parsed when it is first accessed.
|
||||
//
|
||||
// This is only a hint. Implementations are free to choose whether to use
|
||||
// eager or lazy parsing regardless of the value of this option. However,
|
||||
// setting this option true suggests that the protocol author believes that
|
||||
// using lazy parsing on this field is worth the additional bookkeeping
|
||||
// overhead typically needed to implement it.
|
||||
//
|
||||
// This option does not affect the public interface of any generated code;
|
||||
// all method signatures remain the same. Furthermore, thread-safety of the
|
||||
// interface is not affected by this option; const methods remain safe to
|
||||
// call from multiple threads concurrently, while non-const methods continue
|
||||
// to require exclusive access.
|
||||
//
|
||||
//
|
||||
// Note that implementations may choose not to check required fields within
|
||||
// a lazy sub-message. That is, calling IsInitialized() on the outer message
|
||||
// may return true even if the inner message has missing required fields.
|
||||
// This is necessary because otherwise the inner message would have to be
|
||||
// parsed in order to perform the check, defeating the purpose of lazy
|
||||
// parsing. An implementation which chooses not to check required fields
|
||||
// must be consistent about it. That is, for any particular sub-message, the
|
||||
// implementation must either *always* check its required fields, or *never*
|
||||
// check its required fields, regardless of whether or not the message has
|
||||
// been parsed.
|
||||
optional bool lazy = 5 [default=false];
|
||||
|
||||
// Is this field deprecated?
|
||||
// Depending on the target platform, this can emit Deprecated annotations
|
||||
// for accessors, or it will be completely ignored; in the very least, this
|
||||
// is a formalization for deprecating fields.
|
||||
optional bool deprecated = 3 [default=false];
|
||||
|
||||
// For Google-internal migration only. Do not use.
|
||||
optional bool weak = 10 [default=false];
|
||||
|
||||
|
||||
// The parser stores options it doesn't recognize here. See above.
|
||||
repeated UninterpretedOption uninterpreted_option = 999;
|
||||
|
||||
// Clients can define custom options in extensions of this message. See above.
|
||||
extensions 1000 to max;
|
||||
|
||||
reserved 4; // removed jtype
|
||||
}
|
||||
|
||||
message OneofOptions {
|
||||
// The parser stores options it doesn't recognize here. See above.
|
||||
repeated UninterpretedOption uninterpreted_option = 999;
|
||||
|
||||
// Clients can define custom options in extensions of this message. See above.
|
||||
extensions 1000 to max;
|
||||
}
|
||||
|
||||
message EnumOptions {
|
||||
|
||||
// Set this option to true to allow mapping different tag names to the same
|
||||
// value.
|
||||
optional bool allow_alias = 2;
|
||||
|
||||
// Is this enum deprecated?
|
||||
// Depending on the target platform, this can emit Deprecated annotations
|
||||
// for the enum, or it will be completely ignored; in the very least, this
|
||||
// is a formalization for deprecating enums.
|
||||
optional bool deprecated = 3 [default=false];
|
||||
|
||||
reserved 5; // javanano_as_lite
|
||||
|
||||
// The parser stores options it doesn't recognize here. See above.
|
||||
repeated UninterpretedOption uninterpreted_option = 999;
|
||||
|
||||
// Clients can define custom options in extensions of this message. See above.
|
||||
extensions 1000 to max;
|
||||
}
|
||||
|
||||
message EnumValueOptions {
|
||||
// Is this enum value deprecated?
|
||||
// Depending on the target platform, this can emit Deprecated annotations
|
||||
// for the enum value, or it will be completely ignored; in the very least,
|
||||
// this is a formalization for deprecating enum values.
|
||||
optional bool deprecated = 1 [default=false];
|
||||
|
||||
// The parser stores options it doesn't recognize here. See above.
|
||||
repeated UninterpretedOption uninterpreted_option = 999;
|
||||
|
||||
// Clients can define custom options in extensions of this message. See above.
|
||||
extensions 1000 to max;
|
||||
}
|
||||
|
||||
message ServiceOptions {
|
||||
|
||||
// Note: Field numbers 1 through 32 are reserved for Google's internal RPC
|
||||
// framework. We apologize for hoarding these numbers to ourselves, but
|
||||
// we were already using them long before we decided to release Protocol
|
||||
// Buffers.
|
||||
|
||||
// Is this service deprecated?
|
||||
// Depending on the target platform, this can emit Deprecated annotations
|
||||
// for the service, or it will be completely ignored; in the very least,
|
||||
// this is a formalization for deprecating services.
|
||||
optional bool deprecated = 33 [default=false];
|
||||
|
||||
// The parser stores options it doesn't recognize here. See above.
|
||||
repeated UninterpretedOption uninterpreted_option = 999;
|
||||
|
||||
// Clients can define custom options in extensions of this message. See above.
|
||||
extensions 1000 to max;
|
||||
}
|
||||
|
||||
message MethodOptions {
|
||||
|
||||
// Note: Field numbers 1 through 32 are reserved for Google's internal RPC
|
||||
// framework. We apologize for hoarding these numbers to ourselves, but
|
||||
// we were already using them long before we decided to release Protocol
|
||||
// Buffers.
|
||||
|
||||
// Is this method deprecated?
|
||||
// Depending on the target platform, this can emit Deprecated annotations
|
||||
// for the method, or it will be completely ignored; in the very least,
|
||||
// this is a formalization for deprecating methods.
|
||||
optional bool deprecated = 33 [default=false];
|
||||
|
||||
// Is this method side-effect-free (or safe in HTTP parlance), or idempotent,
|
||||
// or neither? HTTP based RPC implementation may choose GET verb for safe
|
||||
// methods, and PUT verb for idempotent methods instead of the default POST.
|
||||
enum IdempotencyLevel {
|
||||
IDEMPOTENCY_UNKNOWN = 0;
|
||||
NO_SIDE_EFFECTS = 1; // implies idempotent
|
||||
IDEMPOTENT = 2; // idempotent, but may have side effects
|
||||
}
|
||||
optional IdempotencyLevel idempotency_level =
|
||||
34 [default=IDEMPOTENCY_UNKNOWN];
|
||||
|
||||
// The parser stores options it doesn't recognize here. See above.
|
||||
repeated UninterpretedOption uninterpreted_option = 999;
|
||||
|
||||
// Clients can define custom options in extensions of this message. See above.
|
||||
extensions 1000 to max;
|
||||
}
|
||||
|
||||
|
||||
// A message representing a option the parser does not recognize. This only
|
||||
// appears in options protos created by the compiler::Parser class.
|
||||
// DescriptorPool resolves these when building Descriptor objects. Therefore,
|
||||
// options protos in descriptor objects (e.g. returned by Descriptor::options(),
|
||||
// or produced by Descriptor::CopyTo()) will never have UninterpretedOptions
|
||||
// in them.
|
||||
message UninterpretedOption {
|
||||
// The name of the uninterpreted option. Each string represents a segment in
|
||||
// a dot-separated name. is_extension is true iff a segment represents an
|
||||
// extension (denoted with parentheses in options specs in .proto files).
|
||||
// E.g.,{ ["foo", false], ["bar.baz", true], ["qux", false] } represents
|
||||
// "foo.(bar.baz).qux".
|
||||
message NamePart {
|
||||
required string name_part = 1;
|
||||
required bool is_extension = 2;
|
||||
}
|
||||
repeated NamePart name = 2;
|
||||
|
||||
// The value of the uninterpreted option, in whatever type the tokenizer
|
||||
// identified it as during parsing. Exactly one of these should be set.
|
||||
optional string identifier_value = 3;
|
||||
optional uint64 positive_int_value = 4;
|
||||
optional int64 negative_int_value = 5;
|
||||
optional double double_value = 6;
|
||||
optional bytes string_value = 7;
|
||||
optional string aggregate_value = 8;
|
||||
}
|
||||
|
||||
// ===================================================================
|
||||
// Optional source code info
|
||||
|
||||
// Encapsulates information about the original source file from which a
|
||||
// FileDescriptorProto was generated.
|
||||
message SourceCodeInfo {
|
||||
// A Location identifies a piece of source code in a .proto file which
|
||||
// corresponds to a particular definition. This information is intended
|
||||
// to be useful to IDEs, code indexers, documentation generators, and similar
|
||||
// tools.
|
||||
//
|
||||
// For example, say we have a file like:
|
||||
// message Foo {
|
||||
// optional string foo = 1;
|
||||
// }
|
||||
// Let's look at just the field definition:
|
||||
// optional string foo = 1;
|
||||
// ^ ^^ ^^ ^ ^^^
|
||||
// a bc de f ghi
|
||||
// We have the following locations:
|
||||
// span path represents
|
||||
// [a,i) [ 4, 0, 2, 0 ] The whole field definition.
|
||||
// [a,b) [ 4, 0, 2, 0, 4 ] The label (optional).
|
||||
// [c,d) [ 4, 0, 2, 0, 5 ] The type (string).
|
||||
// [e,f) [ 4, 0, 2, 0, 1 ] The name (foo).
|
||||
// [g,h) [ 4, 0, 2, 0, 3 ] The number (1).
|
||||
//
|
||||
// Notes:
|
||||
// - A location may refer to a repeated field itself (i.e. not to any
|
||||
// particular index within it). This is used whenever a set of elements are
|
||||
// logically enclosed in a single code segment. For example, an entire
|
||||
// extend block (possibly containing multiple extension definitions) will
|
||||
// have an outer location whose path refers to the "extensions" repeated
|
||||
// field without an index.
|
||||
// - Multiple locations may have the same path. This happens when a single
|
||||
// logical declaration is spread out across multiple places. The most
|
||||
// obvious example is the "extend" block again -- there may be multiple
|
||||
// extend blocks in the same scope, each of which will have the same path.
|
||||
// - A location's span is not always a subset of its parent's span. For
|
||||
// example, the "extendee" of an extension declaration appears at the
|
||||
// beginning of the "extend" block and is shared by all extensions within
|
||||
// the block.
|
||||
// - Just because a location's span is a subset of some other location's span
|
||||
// does not mean that it is a descendent. For example, a "group" defines
|
||||
// both a type and a field in a single declaration. Thus, the locations
|
||||
// corresponding to the type and field and their components will overlap.
|
||||
// - Code which tries to interpret locations should probably be designed to
|
||||
// ignore those that it doesn't understand, as more types of locations could
|
||||
// be recorded in the future.
|
||||
repeated Location location = 1;
|
||||
message Location {
|
||||
// Identifies which part of the FileDescriptorProto was defined at this
|
||||
// location.
|
||||
//
|
||||
// Each element is a field number or an index. They form a path from
|
||||
// the root FileDescriptorProto to the place where the definition. For
|
||||
// example, this path:
|
||||
// [ 4, 3, 2, 7, 1 ]
|
||||
// refers to:
|
||||
// file.message_type(3) // 4, 3
|
||||
// .field(7) // 2, 7
|
||||
// .name() // 1
|
||||
// This is because FileDescriptorProto.message_type has field number 4:
|
||||
// repeated DescriptorProto message_type = 4;
|
||||
// and DescriptorProto.field has field number 2:
|
||||
// repeated FieldDescriptorProto field = 2;
|
||||
// and FieldDescriptorProto.name has field number 1:
|
||||
// optional string name = 1;
|
||||
//
|
||||
// Thus, the above path gives the location of a field name. If we removed
|
||||
// the last element:
|
||||
// [ 4, 3, 2, 7 ]
|
||||
// this path refers to the whole field declaration (from the beginning
|
||||
// of the label to the terminating semicolon).
|
||||
repeated int32 path = 1 [packed=true];
|
||||
|
||||
// Always has exactly three or four elements: start line, start column,
|
||||
// end line (optional, otherwise assumed same as start line), end column.
|
||||
// These are packed into a single field for efficiency. Note that line
|
||||
// and column numbers are zero-based -- typically you will want to add
|
||||
// 1 to each before displaying to a user.
|
||||
repeated int32 span = 2 [packed=true];
|
||||
|
||||
// If this SourceCodeInfo represents a complete declaration, these are any
|
||||
// comments appearing before and after the declaration which appear to be
|
||||
// attached to the declaration.
|
||||
//
|
||||
// A series of line comments appearing on consecutive lines, with no other
|
||||
// tokens appearing on those lines, will be treated as a single comment.
|
||||
//
|
||||
// leading_detached_comments will keep paragraphs of comments that appear
|
||||
// before (but not connected to) the current element. Each paragraph,
|
||||
// separated by empty lines, will be one comment element in the repeated
|
||||
// field.
|
||||
//
|
||||
// Only the comment content is provided; comment markers (e.g. //) are
|
||||
// stripped out. For block comments, leading whitespace and an asterisk
|
||||
// will be stripped from the beginning of each line other than the first.
|
||||
// Newlines are included in the output.
|
||||
//
|
||||
// Examples:
|
||||
//
|
||||
// optional int32 foo = 1; // Comment attached to foo.
|
||||
// // Comment attached to bar.
|
||||
// optional int32 bar = 2;
|
||||
//
|
||||
// optional string baz = 3;
|
||||
// // Comment attached to baz.
|
||||
// // Another line attached to baz.
|
||||
//
|
||||
// // Comment attached to qux.
|
||||
// //
|
||||
// // Another line attached to qux.
|
||||
// optional double qux = 4;
|
||||
//
|
||||
// // Detached comment for corge. This is not leading or trailing comments
|
||||
// // to qux or corge because there are blank lines separating it from
|
||||
// // both.
|
||||
//
|
||||
// // Detached comment for corge paragraph 2.
|
||||
//
|
||||
// optional string corge = 5;
|
||||
// /* Block comment attached
|
||||
// * to corge. Leading asterisks
|
||||
// * will be removed. */
|
||||
// /* Block comment attached to
|
||||
// * grault. */
|
||||
// optional int32 grault = 6;
|
||||
//
|
||||
// // ignored detached comments.
|
||||
optional string leading_comments = 3;
|
||||
optional string trailing_comments = 4;
|
||||
repeated string leading_detached_comments = 6;
|
||||
}
|
||||
}
|
||||
|
||||
// Describes the relationship between generated code and its original source
|
||||
// file. A GeneratedCodeInfo message is associated with only one generated
|
||||
// source file, but may contain references to different source .proto files.
|
||||
message GeneratedCodeInfo {
|
||||
// An Annotation connects some span of text in generated code to an element
|
||||
// of its generating .proto file.
|
||||
repeated Annotation annotation = 1;
|
||||
message Annotation {
|
||||
// Identifies the element in the original source .proto file. This field
|
||||
// is formatted the same as SourceCodeInfo.Location.path.
|
||||
repeated int32 path = 1 [packed=true];
|
||||
|
||||
// Identifies the filesystem path to the original source .proto.
|
||||
optional string source_file = 2;
|
||||
|
||||
// Identifies the starting offset in bytes in the generated code
|
||||
// that relates to the identified object.
|
||||
optional int32 begin = 3;
|
||||
|
||||
// Identifies the ending offset in bytes in the generated code that
|
||||
// relates to the identified offset. The end offset should be one past
|
||||
// the last relevant byte (so the length of the text = end - begin).
|
||||
optional int32 end = 4;
|
||||
}
|
||||
}
|
||||
96
third_party/google/protobuf/struct.proto
vendored
Normal file
96
third_party/google/protobuf/struct.proto
vendored
Normal file
@@ -0,0 +1,96 @@
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// https://developers.google.com/protocol-buffers/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
syntax = "proto3";
|
||||
|
||||
package google.protobuf;
|
||||
|
||||
option csharp_namespace = "Google.Protobuf.WellKnownTypes";
|
||||
option cc_enable_arenas = true;
|
||||
option go_package = "github.com/golang/protobuf/ptypes/struct;structpb";
|
||||
option java_package = "com.google.protobuf";
|
||||
option java_outer_classname = "StructProto";
|
||||
option java_multiple_files = true;
|
||||
option objc_class_prefix = "GPB";
|
||||
|
||||
|
||||
// `Struct` represents a structured data value, consisting of fields
|
||||
// which map to dynamically typed values. In some languages, `Struct`
|
||||
// might be supported by a native representation. For example, in
|
||||
// scripting languages like JS a struct is represented as an
|
||||
// object. The details of that representation are described together
|
||||
// with the proto support for the language.
|
||||
//
|
||||
// The JSON representation for `Struct` is JSON object.
|
||||
message Struct {
|
||||
// Unordered map of dynamically typed values.
|
||||
map<string, Value> fields = 1;
|
||||
}
|
||||
|
||||
// `Value` represents a dynamically typed value which can be either
|
||||
// null, a number, a string, a boolean, a recursive struct value, or a
|
||||
// list of values. A producer of value is expected to set one of that
|
||||
// variants, absence of any variant indicates an error.
|
||||
//
|
||||
// The JSON representation for `Value` is JSON value.
|
||||
message Value {
|
||||
// The kind of value.
|
||||
oneof kind {
|
||||
// Represents a null value.
|
||||
NullValue null_value = 1;
|
||||
// Represents a double value.
|
||||
double number_value = 2;
|
||||
// Represents a string value.
|
||||
string string_value = 3;
|
||||
// Represents a boolean value.
|
||||
bool bool_value = 4;
|
||||
// Represents a structured value.
|
||||
Struct struct_value = 5;
|
||||
// Represents a repeated `Value`.
|
||||
ListValue list_value = 6;
|
||||
}
|
||||
}
|
||||
|
||||
// `NullValue` is a singleton enumeration to represent the null value for the
|
||||
// `Value` type union.
|
||||
//
|
||||
// The JSON representation for `NullValue` is JSON `null`.
|
||||
enum NullValue {
|
||||
// Null value.
|
||||
NULL_VALUE = 0;
|
||||
}
|
||||
|
||||
// `ListValue` is a wrapper around a repeated field of values.
|
||||
//
|
||||
// The JSON representation for `ListValue` is JSON array.
|
||||
message ListValue {
|
||||
// Repeated field of dynamically typed values.
|
||||
repeated Value values = 1;
|
||||
}
|
||||
186
third_party/google/rpc/code.proto
vendored
Normal file
186
third_party/google/rpc/code.proto
vendored
Normal file
@@ -0,0 +1,186 @@
|
||||
// Copyright 2017 Google Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
syntax = "proto3";
|
||||
|
||||
package google.rpc;
|
||||
|
||||
option go_package = "google.golang.org/genproto/googleapis/rpc/code;code";
|
||||
option java_multiple_files = true;
|
||||
option java_outer_classname = "CodeProto";
|
||||
option java_package = "com.google.rpc";
|
||||
option objc_class_prefix = "RPC";
|
||||
|
||||
|
||||
// The canonical error codes for Google APIs.
|
||||
//
|
||||
//
|
||||
// Sometimes multiple error codes may apply. Services should return
|
||||
// the most specific error code that applies. For example, prefer
|
||||
// `OUT_OF_RANGE` over `FAILED_PRECONDITION` if both codes apply.
|
||||
// Similarly prefer `NOT_FOUND` or `ALREADY_EXISTS` over `FAILED_PRECONDITION`.
|
||||
enum Code {
|
||||
// Not an error; returned on success
|
||||
//
|
||||
// HTTP Mapping: 200 OK
|
||||
OK = 0;
|
||||
|
||||
// The operation was cancelled, typically by the caller.
|
||||
//
|
||||
// HTTP Mapping: 499 Client Closed Request
|
||||
CANCELLED = 1;
|
||||
|
||||
// Unknown error. For example, this error may be returned when
|
||||
// a `Status` value received from another address space belongs to
|
||||
// an error space that is not known in this address space. Also
|
||||
// errors raised by APIs that do not return enough error information
|
||||
// may be converted to this error.
|
||||
//
|
||||
// HTTP Mapping: 500 Internal Server Error
|
||||
UNKNOWN = 2;
|
||||
|
||||
// The client specified an invalid argument. Note that this differs
|
||||
// from `FAILED_PRECONDITION`. `INVALID_ARGUMENT` indicates arguments
|
||||
// that are problematic regardless of the state of the system
|
||||
// (e.g., a malformed file name).
|
||||
//
|
||||
// HTTP Mapping: 400 Bad Request
|
||||
INVALID_ARGUMENT = 3;
|
||||
|
||||
// The deadline expired before the operation could complete. For operations
|
||||
// that change the state of the system, this error may be returned
|
||||
// even if the operation has completed successfully. For example, a
|
||||
// successful response from a server could have been delayed long
|
||||
// enough for the deadline to expire.
|
||||
//
|
||||
// HTTP Mapping: 504 Gateway Timeout
|
||||
DEADLINE_EXCEEDED = 4;
|
||||
|
||||
// Some requested entity (e.g., file or directory) was not found.
|
||||
//
|
||||
// Note to server developers: if a request is denied for an entire class
|
||||
// of users, such as gradual feature rollout or undocumented whitelist,
|
||||
// `NOT_FOUND` may be used. If a request is denied for some users within
|
||||
// a class of users, such as user-based access control, `PERMISSION_DENIED`
|
||||
// must be used.
|
||||
//
|
||||
// HTTP Mapping: 404 Not Found
|
||||
NOT_FOUND = 5;
|
||||
|
||||
// The entity that a client attempted to create (e.g., file or directory)
|
||||
// already exists.
|
||||
//
|
||||
// HTTP Mapping: 409 Conflict
|
||||
ALREADY_EXISTS = 6;
|
||||
|
||||
// The caller does not have permission to execute the specified
|
||||
// operation. `PERMISSION_DENIED` must not be used for rejections
|
||||
// caused by exhausting some resource (use `RESOURCE_EXHAUSTED`
|
||||
// instead for those errors). `PERMISSION_DENIED` must not be
|
||||
// used if the caller can not be identified (use `UNAUTHENTICATED`
|
||||
// instead for those errors). This error code does not imply the
|
||||
// request is valid or the requested entity exists or satisfies
|
||||
// other pre-conditions.
|
||||
//
|
||||
// HTTP Mapping: 403 Forbidden
|
||||
PERMISSION_DENIED = 7;
|
||||
|
||||
// The request does not have valid authentication credentials for the
|
||||
// operation.
|
||||
//
|
||||
// HTTP Mapping: 401 Unauthorized
|
||||
UNAUTHENTICATED = 16;
|
||||
|
||||
// Some resource has been exhausted, perhaps a per-user quota, or
|
||||
// perhaps the entire file system is out of space.
|
||||
//
|
||||
// HTTP Mapping: 429 Too Many Requests
|
||||
RESOURCE_EXHAUSTED = 8;
|
||||
|
||||
// The operation was rejected because the system is not in a state
|
||||
// required for the operation's execution. For example, the directory
|
||||
// to be deleted is non-empty, an rmdir operation is applied to
|
||||
// a non-directory, etc.
|
||||
//
|
||||
// Service implementors can use the following guidelines to decide
|
||||
// between `FAILED_PRECONDITION`, `ABORTED`, and `UNAVAILABLE`:
|
||||
// (a) Use `UNAVAILABLE` if the client can retry just the failing call.
|
||||
// (b) Use `ABORTED` if the client should retry at a higher level
|
||||
// (e.g., when a client-specified test-and-set fails, indicating the
|
||||
// client should restart a read-modify-write sequence).
|
||||
// (c) Use `FAILED_PRECONDITION` if the client should not retry until
|
||||
// the system state has been explicitly fixed. E.g., if an "rmdir"
|
||||
// fails because the directory is non-empty, `FAILED_PRECONDITION`
|
||||
// should be returned since the client should not retry unless
|
||||
// the files are deleted from the directory.
|
||||
//
|
||||
// HTTP Mapping: 400 Bad Request
|
||||
FAILED_PRECONDITION = 9;
|
||||
|
||||
// The operation was aborted, typically due to a concurrency issue such as
|
||||
// a sequencer check failure or transaction abort.
|
||||
//
|
||||
// See the guidelines above for deciding between `FAILED_PRECONDITION`,
|
||||
// `ABORTED`, and `UNAVAILABLE`.
|
||||
//
|
||||
// HTTP Mapping: 409 Conflict
|
||||
ABORTED = 10;
|
||||
|
||||
// The operation was attempted past the valid range. E.g., seeking or
|
||||
// reading past end-of-file.
|
||||
//
|
||||
// Unlike `INVALID_ARGUMENT`, this error indicates a problem that may
|
||||
// be fixed if the system state changes. For example, a 32-bit file
|
||||
// system will generate `INVALID_ARGUMENT` if asked to read at an
|
||||
// offset that is not in the range [0,2^32-1], but it will generate
|
||||
// `OUT_OF_RANGE` if asked to read from an offset past the current
|
||||
// file size.
|
||||
//
|
||||
// There is a fair bit of overlap between `FAILED_PRECONDITION` and
|
||||
// `OUT_OF_RANGE`. We recommend using `OUT_OF_RANGE` (the more specific
|
||||
// error) when it applies so that callers who are iterating through
|
||||
// a space can easily look for an `OUT_OF_RANGE` error to detect when
|
||||
// they are done.
|
||||
//
|
||||
// HTTP Mapping: 400 Bad Request
|
||||
OUT_OF_RANGE = 11;
|
||||
|
||||
// The operation is not implemented or is not supported/enabled in this
|
||||
// service.
|
||||
//
|
||||
// HTTP Mapping: 501 Not Implemented
|
||||
UNIMPLEMENTED = 12;
|
||||
|
||||
// Internal errors. This means that some invariants expected by the
|
||||
// underlying system have been broken. This error code is reserved
|
||||
// for serious errors.
|
||||
//
|
||||
// HTTP Mapping: 500 Internal Server Error
|
||||
INTERNAL = 13;
|
||||
|
||||
// The service is currently unavailable. This is most likely a
|
||||
// transient condition, which can be corrected by retrying with
|
||||
// a backoff.
|
||||
//
|
||||
// See the guidelines above for deciding between `FAILED_PRECONDITION`,
|
||||
// `ABORTED`, and `UNAVAILABLE`.
|
||||
//
|
||||
// HTTP Mapping: 503 Service Unavailable
|
||||
UNAVAILABLE = 14;
|
||||
|
||||
// Unrecoverable data loss or corruption.
|
||||
//
|
||||
// HTTP Mapping: 500 Internal Server Error
|
||||
DATA_LOSS = 15;
|
||||
}
|
||||
200
third_party/google/rpc/error_details.proto
vendored
Normal file
200
third_party/google/rpc/error_details.proto
vendored
Normal file
@@ -0,0 +1,200 @@
|
||||
// Copyright 2017 Google Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
syntax = "proto3";
|
||||
|
||||
package google.rpc;
|
||||
|
||||
import "google/protobuf/duration.proto";
|
||||
|
||||
option go_package = "google.golang.org/genproto/googleapis/rpc/errdetails;errdetails";
|
||||
option java_multiple_files = true;
|
||||
option java_outer_classname = "ErrorDetailsProto";
|
||||
option java_package = "com.google.rpc";
|
||||
option objc_class_prefix = "RPC";
|
||||
|
||||
|
||||
// Describes when the clients can retry a failed request. Clients could ignore
|
||||
// the recommendation here or retry when this information is missing from error
|
||||
// responses.
|
||||
//
|
||||
// It's always recommended that clients should use exponential backoff when
|
||||
// retrying.
|
||||
//
|
||||
// Clients should wait until `retry_delay` amount of time has passed since
|
||||
// receiving the error response before retrying. If retrying requests also
|
||||
// fail, clients should use an exponential backoff scheme to gradually increase
|
||||
// the delay between retries based on `retry_delay`, until either a maximum
|
||||
// number of retires have been reached or a maximum retry delay cap has been
|
||||
// reached.
|
||||
message RetryInfo {
|
||||
// Clients should wait at least this long between retrying the same request.
|
||||
google.protobuf.Duration retry_delay = 1;
|
||||
}
|
||||
|
||||
// Describes additional debugging info.
|
||||
message DebugInfo {
|
||||
// The stack trace entries indicating where the error occurred.
|
||||
repeated string stack_entries = 1;
|
||||
|
||||
// Additional debugging information provided by the server.
|
||||
string detail = 2;
|
||||
}
|
||||
|
||||
// Describes how a quota check failed.
|
||||
//
|
||||
// For example if a daily limit was exceeded for the calling project,
|
||||
// a service could respond with a QuotaFailure detail containing the project
|
||||
// id and the description of the quota limit that was exceeded. If the
|
||||
// calling project hasn't enabled the service in the developer console, then
|
||||
// a service could respond with the project id and set `service_disabled`
|
||||
// to true.
|
||||
//
|
||||
// Also see RetryDetail and Help types for other details about handling a
|
||||
// quota failure.
|
||||
message QuotaFailure {
|
||||
// A message type used to describe a single quota violation. For example, a
|
||||
// daily quota or a custom quota that was exceeded.
|
||||
message Violation {
|
||||
// The subject on which the quota check failed.
|
||||
// For example, "clientip:<ip address of client>" or "project:<Google
|
||||
// developer project id>".
|
||||
string subject = 1;
|
||||
|
||||
// A description of how the quota check failed. Clients can use this
|
||||
// description to find more about the quota configuration in the service's
|
||||
// public documentation, or find the relevant quota limit to adjust through
|
||||
// developer console.
|
||||
//
|
||||
// For example: "Service disabled" or "Daily Limit for read operations
|
||||
// exceeded".
|
||||
string description = 2;
|
||||
}
|
||||
|
||||
// Describes all quota violations.
|
||||
repeated Violation violations = 1;
|
||||
}
|
||||
|
||||
// Describes what preconditions have failed.
|
||||
//
|
||||
// For example, if an RPC failed because it required the Terms of Service to be
|
||||
// acknowledged, it could list the terms of service violation in the
|
||||
// PreconditionFailure message.
|
||||
message PreconditionFailure {
|
||||
// A message type used to describe a single precondition failure.
|
||||
message Violation {
|
||||
// The type of PreconditionFailure. We recommend using a service-specific
|
||||
// enum type to define the supported precondition violation types. For
|
||||
// example, "TOS" for "Terms of Service violation".
|
||||
string type = 1;
|
||||
|
||||
// The subject, relative to the type, that failed.
|
||||
// For example, "google.com/cloud" relative to the "TOS" type would
|
||||
// indicate which terms of service is being referenced.
|
||||
string subject = 2;
|
||||
|
||||
// A description of how the precondition failed. Developers can use this
|
||||
// description to understand how to fix the failure.
|
||||
//
|
||||
// For example: "Terms of service not accepted".
|
||||
string description = 3;
|
||||
}
|
||||
|
||||
// Describes all precondition violations.
|
||||
repeated Violation violations = 1;
|
||||
}
|
||||
|
||||
// Describes violations in a client request. This error type focuses on the
|
||||
// syntactic aspects of the request.
|
||||
message BadRequest {
|
||||
// A message type used to describe a single bad request field.
|
||||
message FieldViolation {
|
||||
// A path leading to a field in the request body. The value will be a
|
||||
// sequence of dot-separated identifiers that identify a protocol buffer
|
||||
// field. E.g., "field_violations.field" would identify this field.
|
||||
string field = 1;
|
||||
|
||||
// A description of why the request element is bad.
|
||||
string description = 2;
|
||||
}
|
||||
|
||||
// Describes all violations in a client request.
|
||||
repeated FieldViolation field_violations = 1;
|
||||
}
|
||||
|
||||
// Contains metadata about the request that clients can attach when filing a bug
|
||||
// or providing other forms of feedback.
|
||||
message RequestInfo {
|
||||
// An opaque string that should only be interpreted by the service generating
|
||||
// it. For example, it can be used to identify requests in the service's logs.
|
||||
string request_id = 1;
|
||||
|
||||
// Any data that was used to serve this request. For example, an encrypted
|
||||
// stack trace that can be sent back to the service provider for debugging.
|
||||
string serving_data = 2;
|
||||
}
|
||||
|
||||
// Describes the resource that is being accessed.
|
||||
message ResourceInfo {
|
||||
// A name for the type of resource being accessed, e.g. "sql table",
|
||||
// "cloud storage bucket", "file", "Google calendar"; or the type URL
|
||||
// of the resource: e.g. "type.googleapis.com/google.pubsub.v1.Topic".
|
||||
string resource_type = 1;
|
||||
|
||||
// The name of the resource being accessed. For example, a shared calendar
|
||||
// name: "example.com_4fghdhgsrgh@group.calendar.google.com", if the current
|
||||
// error is [google.rpc.Code.PERMISSION_DENIED][google.rpc.Code.PERMISSION_DENIED].
|
||||
string resource_name = 2;
|
||||
|
||||
// The owner of the resource (optional).
|
||||
// For example, "user:<owner email>" or "project:<Google developer project
|
||||
// id>".
|
||||
string owner = 3;
|
||||
|
||||
// Describes what error is encountered when accessing this resource.
|
||||
// For example, updating a cloud project may require the `writer` permission
|
||||
// on the developer console project.
|
||||
string description = 4;
|
||||
}
|
||||
|
||||
// Provides links to documentation or for performing an out of band action.
|
||||
//
|
||||
// For example, if a quota check failed with an error indicating the calling
|
||||
// project hasn't enabled the accessed service, this can contain a URL pointing
|
||||
// directly to the right place in the developer console to flip the bit.
|
||||
message Help {
|
||||
// Describes a URL link.
|
||||
message Link {
|
||||
// Describes what the link offers.
|
||||
string description = 1;
|
||||
|
||||
// The URL of the link.
|
||||
string url = 2;
|
||||
}
|
||||
|
||||
// URL(s) pointing to additional information on handling the current error.
|
||||
repeated Link links = 1;
|
||||
}
|
||||
|
||||
// Provides a localized error message that is safe to return to the user
|
||||
// which can be attached to an RPC error.
|
||||
message LocalizedMessage {
|
||||
// The locale used following the specification defined at
|
||||
// http://www.rfc-editor.org/rfc/bcp/bcp47.txt.
|
||||
// Examples are: "en-US", "fr-CH", "es-MX"
|
||||
string locale = 1;
|
||||
|
||||
// The localized error message in the above locale.
|
||||
string message = 2;
|
||||
}
|
||||
92
third_party/google/rpc/status.proto
vendored
Normal file
92
third_party/google/rpc/status.proto
vendored
Normal file
@@ -0,0 +1,92 @@
|
||||
// Copyright 2017 Google Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
syntax = "proto3";
|
||||
|
||||
package google.rpc;
|
||||
|
||||
import "google/protobuf/any.proto";
|
||||
|
||||
option go_package = "google.golang.org/genproto/googleapis/rpc/status;status";
|
||||
option java_multiple_files = true;
|
||||
option java_outer_classname = "StatusProto";
|
||||
option java_package = "com.google.rpc";
|
||||
option objc_class_prefix = "RPC";
|
||||
|
||||
|
||||
// The `Status` type defines a logical error model that is suitable for different
|
||||
// programming environments, including REST APIs and RPC APIs. It is used by
|
||||
// [gRPC](https://github.com/grpc). The error model is designed to be:
|
||||
//
|
||||
// - Simple to use and understand for most users
|
||||
// - Flexible enough to meet unexpected needs
|
||||
//
|
||||
// # Overview
|
||||
//
|
||||
// The `Status` message contains three pieces of data: error code, error message,
|
||||
// and error details. The error code should be an enum value of
|
||||
// [google.rpc.Code][google.rpc.Code], but it may accept additional error codes if needed. The
|
||||
// error message should be a developer-facing English message that helps
|
||||
// developers *understand* and *resolve* the error. If a localized user-facing
|
||||
// error message is needed, put the localized message in the error details or
|
||||
// localize it in the client. The optional error details may contain arbitrary
|
||||
// information about the error. There is a predefined set of error detail types
|
||||
// in the package `google.rpc` that can be used for common error conditions.
|
||||
//
|
||||
// # Language mapping
|
||||
//
|
||||
// The `Status` message is the logical representation of the error model, but it
|
||||
// is not necessarily the actual wire format. When the `Status` message is
|
||||
// exposed in different client libraries and different wire protocols, it can be
|
||||
// mapped differently. For example, it will likely be mapped to some exceptions
|
||||
// in Java, but more likely mapped to some error codes in C.
|
||||
//
|
||||
// # Other uses
|
||||
//
|
||||
// The error model and the `Status` message can be used in a variety of
|
||||
// environments, either with or without APIs, to provide a
|
||||
// consistent developer experience across different environments.
|
||||
//
|
||||
// Example uses of this error model include:
|
||||
//
|
||||
// - Partial errors. If a service needs to return partial errors to the client,
|
||||
// it may embed the `Status` in the normal response to indicate the partial
|
||||
// errors.
|
||||
//
|
||||
// - Workflow errors. A typical workflow has multiple steps. Each step may
|
||||
// have a `Status` message for error reporting.
|
||||
//
|
||||
// - Batch operations. If a client uses batch request and batch response, the
|
||||
// `Status` message should be used directly inside batch response, one for
|
||||
// each error sub-response.
|
||||
//
|
||||
// - Asynchronous operations. If an API call embeds asynchronous operation
|
||||
// results in its response, the status of those operations should be
|
||||
// represented directly using the `Status` message.
|
||||
//
|
||||
// - Logging. If some API errors are stored in logs, the message `Status` could
|
||||
// be used directly after any stripping needed for security/privacy reasons.
|
||||
message Status {
|
||||
// The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code].
|
||||
int32 code = 1;
|
||||
|
||||
// A developer-facing error message, which should be in English. Any
|
||||
// user-facing error message should be localized and sent in the
|
||||
// [google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client.
|
||||
string message = 2;
|
||||
|
||||
// A list of messages that carry the error details. There is a common set of
|
||||
// message types for APIs to use.
|
||||
repeated google.protobuf.Any details = 3;
|
||||
}
|
||||
44
third_party/protoc-gen-swagger/options/annotations.proto
vendored
Normal file
44
third_party/protoc-gen-swagger/options/annotations.proto
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package grpc.gateway.protoc_gen_swagger.options;
|
||||
|
||||
option go_package = "github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/options";
|
||||
|
||||
import "google/protobuf/descriptor.proto";
|
||||
import "protoc-gen-swagger/options/openapiv2.proto";
|
||||
|
||||
extend google.protobuf.FileOptions {
|
||||
// ID assigned by protobuf-global-extension-registry@google.com for grpc-gateway project.
|
||||
//
|
||||
// All IDs are the same, as assigned. It is okay that they are the same, as they extend
|
||||
// different descriptor messages.
|
||||
Swagger openapiv2_swagger = 1042;
|
||||
}
|
||||
extend google.protobuf.MethodOptions {
|
||||
// ID assigned by protobuf-global-extension-registry@google.com for grpc-gateway project.
|
||||
//
|
||||
// All IDs are the same, as assigned. It is okay that they are the same, as they extend
|
||||
// different descriptor messages.
|
||||
Operation openapiv2_operation = 1042;
|
||||
}
|
||||
extend google.protobuf.MessageOptions {
|
||||
// ID assigned by protobuf-global-extension-registry@google.com for grpc-gateway project.
|
||||
//
|
||||
// All IDs are the same, as assigned. It is okay that they are the same, as they extend
|
||||
// different descriptor messages.
|
||||
Schema openapiv2_schema = 1042;
|
||||
}
|
||||
extend google.protobuf.ServiceOptions {
|
||||
// ID assigned by protobuf-global-extension-registry@google.com for grpc-gateway project.
|
||||
//
|
||||
// All IDs are the same, as assigned. It is okay that they are the same, as they extend
|
||||
// different descriptor messages.
|
||||
Tag openapiv2_tag = 1042;
|
||||
}
|
||||
extend google.protobuf.FieldOptions {
|
||||
// ID assigned by protobuf-global-extension-registry@google.com for grpc-gateway project.
|
||||
//
|
||||
// All IDs are the same, as assigned. It is okay that they are the same, as they extend
|
||||
// different descriptor messages.
|
||||
JSONSchema openapiv2_field = 1042;
|
||||
}
|
||||
379
third_party/protoc-gen-swagger/options/openapiv2.proto
vendored
Normal file
379
third_party/protoc-gen-swagger/options/openapiv2.proto
vendored
Normal file
@@ -0,0 +1,379 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package grpc.gateway.protoc_gen_swagger.options;
|
||||
|
||||
option go_package = "github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/options";
|
||||
|
||||
import "google/protobuf/any.proto";
|
||||
import "google/protobuf/struct.proto";
|
||||
|
||||
// `Swagger` is a representation of OpenAPI v2 specification's Swagger object.
|
||||
//
|
||||
// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#swaggerObject
|
||||
//
|
||||
// TODO(ivucica): document fields
|
||||
message Swagger {
|
||||
string swagger = 1;
|
||||
Info info = 2;
|
||||
string host = 3;
|
||||
// `base_path` is the common prefix path used on all API endpoints (ie. /api, /v1, etc.). By adding this,
|
||||
// it allows you to remove this portion from the path endpoints in your Swagger file making them easier
|
||||
// to read. Note that using `base_path` does not change the endpoint paths that are generated in the resulting
|
||||
// Swagger file. If you wish to use `base_path` with relatively generated Swagger paths, the
|
||||
// `base_path` prefix must be manually removed from your `google.api.http` paths and your code changed to
|
||||
// serve the API from the `base_path`.
|
||||
string base_path = 4;
|
||||
enum SwaggerScheme {
|
||||
UNKNOWN = 0;
|
||||
HTTP = 1;
|
||||
HTTPS = 2;
|
||||
WS = 3;
|
||||
WSS = 4;
|
||||
}
|
||||
repeated SwaggerScheme schemes = 5;
|
||||
repeated string consumes = 6;
|
||||
repeated string produces = 7;
|
||||
// field 8 is reserved for 'paths'.
|
||||
reserved 8;
|
||||
// field 9 is reserved for 'definitions', which at this time are already
|
||||
// exposed as and customizable as proto messages.
|
||||
reserved 9;
|
||||
map<string, Response> responses = 10;
|
||||
SecurityDefinitions security_definitions = 11;
|
||||
repeated SecurityRequirement security = 12;
|
||||
// field 13 is reserved for 'tags', which are supposed to be exposed as and
|
||||
// customizable as proto services. TODO(ivucica): add processing of proto
|
||||
// service objects into OpenAPI v2 Tag objects.
|
||||
reserved 13;
|
||||
ExternalDocumentation external_docs = 14;
|
||||
map<string, google.protobuf.Value> extensions = 15;
|
||||
}
|
||||
|
||||
// `Operation` is a representation of OpenAPI v2 specification's Operation object.
|
||||
//
|
||||
// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#operationObject
|
||||
//
|
||||
// TODO(ivucica): document fields
|
||||
message Operation {
|
||||
repeated string tags = 1;
|
||||
string summary = 2;
|
||||
string description = 3;
|
||||
ExternalDocumentation external_docs = 4;
|
||||
string operation_id = 5;
|
||||
repeated string consumes = 6;
|
||||
repeated string produces = 7;
|
||||
// field 8 is reserved for 'parameters'.
|
||||
reserved 8;
|
||||
map<string, Response> responses = 9;
|
||||
repeated string schemes = 10;
|
||||
bool deprecated = 11;
|
||||
repeated SecurityRequirement security = 12;
|
||||
map<string, google.protobuf.Value> extensions = 13;
|
||||
}
|
||||
|
||||
// `Response` is a representation of OpenAPI v2 specification's Response object.
|
||||
//
|
||||
// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#responseObject
|
||||
//
|
||||
message Response {
|
||||
// `Description` is a short description of the response.
|
||||
// GFM syntax can be used for rich text representation.
|
||||
string description = 1;
|
||||
// `Schema` optionally defines the structure of the response.
|
||||
// If `Schema` is not provided, it means there is no content to the response.
|
||||
Schema schema = 2;
|
||||
// field 3 is reserved for 'headers'.
|
||||
reserved 3;
|
||||
// field 3 is reserved for 'example'.
|
||||
reserved 4;
|
||||
map<string, google.protobuf.Value> extensions = 5;
|
||||
}
|
||||
|
||||
// `Info` is a representation of OpenAPI v2 specification's Info object.
|
||||
//
|
||||
// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#infoObject
|
||||
//
|
||||
// TODO(ivucica): document fields
|
||||
message Info {
|
||||
string title = 1;
|
||||
string description = 2;
|
||||
string terms_of_service = 3;
|
||||
Contact contact = 4;
|
||||
License license = 5;
|
||||
string version = 6;
|
||||
map<string, google.protobuf.Value> extensions = 7;
|
||||
}
|
||||
|
||||
// `Contact` is a representation of OpenAPI v2 specification's Contact object.
|
||||
//
|
||||
// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#contactObject
|
||||
//
|
||||
// TODO(ivucica): document fields
|
||||
message Contact {
|
||||
string name = 1;
|
||||
string url = 2;
|
||||
string email = 3;
|
||||
}
|
||||
|
||||
// `License` is a representation of OpenAPI v2 specification's License object.
|
||||
//
|
||||
// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#licenseObject
|
||||
//
|
||||
message License {
|
||||
// Required. The license name used for the API.
|
||||
string name = 1;
|
||||
// A URL to the license used for the API.
|
||||
string url = 2;
|
||||
}
|
||||
|
||||
// `ExternalDocumentation` is a representation of OpenAPI v2 specification's
|
||||
// ExternalDocumentation object.
|
||||
//
|
||||
// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#externalDocumentationObject
|
||||
//
|
||||
// TODO(ivucica): document fields
|
||||
message ExternalDocumentation {
|
||||
string description = 1;
|
||||
string url = 2;
|
||||
}
|
||||
|
||||
// `Schema` is a representation of OpenAPI v2 specification's Schema object.
|
||||
//
|
||||
// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#schemaObject
|
||||
//
|
||||
// TODO(ivucica): document fields
|
||||
message Schema {
|
||||
JSONSchema json_schema = 1;
|
||||
string discriminator = 2;
|
||||
bool read_only = 3;
|
||||
// field 4 is reserved for 'xml'.
|
||||
reserved 4;
|
||||
ExternalDocumentation external_docs = 5;
|
||||
google.protobuf.Any example = 6;
|
||||
}
|
||||
|
||||
// `JSONSchema` represents properties from JSON Schema taken, and as used, in
|
||||
// the OpenAPI v2 spec.
|
||||
//
|
||||
// This includes changes made by OpenAPI v2.
|
||||
//
|
||||
// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#schemaObject
|
||||
//
|
||||
// See also: https://cswr.github.io/JsonSchema/spec/basic_types/,
|
||||
// https://github.com/json-schema-org/json-schema-spec/blob/master/schema.json
|
||||
//
|
||||
// TODO(ivucica): document fields
|
||||
message JSONSchema {
|
||||
// field 1 is reserved for '$id', omitted from OpenAPI v2.
|
||||
reserved 1;
|
||||
// field 2 is reserved for '$schema', omitted from OpenAPI v2.
|
||||
reserved 2;
|
||||
// Ref is used to define an external reference to include in the message.
|
||||
// This could be a fully qualified proto message reference, and that type must be imported
|
||||
// into the protofile. If no message is identified, the Ref will be used verbatim in
|
||||
// the output.
|
||||
// For example:
|
||||
// `ref: ".google.protobuf.Timestamp"`.
|
||||
string ref = 3;
|
||||
// field 4 is reserved for '$comment', omitted from OpenAPI v2.
|
||||
reserved 4;
|
||||
string title = 5;
|
||||
string description = 6;
|
||||
string default = 7;
|
||||
bool read_only = 8;
|
||||
// field 9 is reserved for 'examples', which is omitted from OpenAPI v2 in favor of 'example' field.
|
||||
reserved 9;
|
||||
double multiple_of = 10;
|
||||
double maximum = 11;
|
||||
bool exclusive_maximum = 12;
|
||||
double minimum = 13;
|
||||
bool exclusive_minimum = 14;
|
||||
uint64 max_length = 15;
|
||||
uint64 min_length = 16;
|
||||
string pattern = 17;
|
||||
// field 18 is reserved for 'additionalItems', omitted from OpenAPI v2.
|
||||
reserved 18;
|
||||
// field 19 is reserved for 'items', but in OpenAPI-specific way. TODO(ivucica): add 'items'?
|
||||
reserved 19;
|
||||
uint64 max_items = 20;
|
||||
uint64 min_items = 21;
|
||||
bool unique_items = 22;
|
||||
// field 23 is reserved for 'contains', omitted from OpenAPI v2.
|
||||
reserved 23;
|
||||
uint64 max_properties = 24;
|
||||
uint64 min_properties = 25;
|
||||
repeated string required = 26;
|
||||
// field 27 is reserved for 'additionalProperties', but in OpenAPI-specific way. TODO(ivucica): add 'additionalProperties'?
|
||||
reserved 27;
|
||||
// field 28 is reserved for 'definitions', omitted from OpenAPI v2.
|
||||
reserved 28;
|
||||
// field 29 is reserved for 'properties', but in OpenAPI-specific way. TODO(ivucica): add 'additionalProperties'?
|
||||
reserved 29;
|
||||
// following fields are reserved, as the properties have been omitted from OpenAPI v2:
|
||||
// patternProperties, dependencies, propertyNames, const
|
||||
reserved 30 to 33;
|
||||
// Items in 'array' must be unique.
|
||||
repeated string array = 34;
|
||||
|
||||
enum JSONSchemaSimpleTypes {
|
||||
UNKNOWN = 0;
|
||||
ARRAY = 1;
|
||||
BOOLEAN = 2;
|
||||
INTEGER = 3;
|
||||
NULL = 4;
|
||||
NUMBER = 5;
|
||||
OBJECT = 6;
|
||||
STRING = 7;
|
||||
}
|
||||
|
||||
repeated JSONSchemaSimpleTypes type = 35;
|
||||
// following fields are reserved, as the properties have been omitted from OpenAPI v2:
|
||||
// format, contentMediaType, contentEncoding, if, then, else
|
||||
reserved 36 to 41;
|
||||
// field 42 is reserved for 'allOf', but in OpenAPI-specific way. TODO(ivucica): add 'allOf'?
|
||||
reserved 42;
|
||||
// following fields are reserved, as the properties have been omitted from OpenAPI v2:
|
||||
// anyOf, oneOf, not
|
||||
reserved 43 to 45;
|
||||
}
|
||||
|
||||
// `Tag` is a representation of OpenAPI v2 specification's Tag object.
|
||||
//
|
||||
// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#tagObject
|
||||
//
|
||||
// TODO(ivucica): document fields
|
||||
message Tag {
|
||||
// field 1 is reserved for 'name'. In our generator, this is (to be) extracted
|
||||
// from the name of proto service, and thus not exposed to the user, as
|
||||
// changing tag object's name would break the link to the references to the
|
||||
// tag in individual operation specifications.
|
||||
//
|
||||
// TODO(ivucica): Add 'name' property. Use it to allow override of the name of
|
||||
// global Tag object, then use that name to reference the tag throughout the
|
||||
// Swagger file.
|
||||
reserved 1;
|
||||
// TODO(ivucica): Description should be extracted from comments on the proto
|
||||
// service object.
|
||||
string description = 2;
|
||||
ExternalDocumentation external_docs = 3;
|
||||
}
|
||||
|
||||
// `SecurityDefinitions` is a representation of OpenAPI v2 specification's
|
||||
// Security Definitions object.
|
||||
//
|
||||
// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#securityDefinitionsObject
|
||||
//
|
||||
// A declaration of the security schemes available to be used in the
|
||||
// specification. This does not enforce the security schemes on the operations
|
||||
// and only serves to provide the relevant details for each scheme.
|
||||
message SecurityDefinitions {
|
||||
// A single security scheme definition, mapping a "name" to the scheme it defines.
|
||||
map<string, SecurityScheme> security = 1;
|
||||
}
|
||||
|
||||
// `SecurityScheme` is a representation of OpenAPI v2 specification's
|
||||
// Security Scheme object.
|
||||
//
|
||||
// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#securitySchemeObject
|
||||
//
|
||||
// Allows the definition of a security scheme that can be used by the
|
||||
// operations. Supported schemes are basic authentication, an API key (either as
|
||||
// a header or as a query parameter) and OAuth2's common flows (implicit,
|
||||
// password, application and access code).
|
||||
message SecurityScheme {
|
||||
// Required. The type of the security scheme. Valid values are "basic",
|
||||
// "apiKey" or "oauth2".
|
||||
enum Type {
|
||||
TYPE_INVALID = 0;
|
||||
TYPE_BASIC = 1;
|
||||
TYPE_API_KEY = 2;
|
||||
TYPE_OAUTH2 = 3;
|
||||
}
|
||||
|
||||
// Required. The location of the API key. Valid values are "query" or "header".
|
||||
enum In {
|
||||
IN_INVALID = 0;
|
||||
IN_QUERY = 1;
|
||||
IN_HEADER = 2;
|
||||
}
|
||||
|
||||
// Required. The flow used by the OAuth2 security scheme. Valid values are
|
||||
// "implicit", "password", "application" or "accessCode".
|
||||
enum Flow {
|
||||
FLOW_INVALID = 0;
|
||||
FLOW_IMPLICIT = 1;
|
||||
FLOW_PASSWORD = 2;
|
||||
FLOW_APPLICATION = 3;
|
||||
FLOW_ACCESS_CODE = 4;
|
||||
}
|
||||
|
||||
// Required. The type of the security scheme. Valid values are "basic",
|
||||
// "apiKey" or "oauth2".
|
||||
Type type = 1;
|
||||
// A short description for security scheme.
|
||||
string description = 2;
|
||||
// Required. The name of the header or query parameter to be used.
|
||||
//
|
||||
// Valid for apiKey.
|
||||
string name = 3;
|
||||
// Required. The location of the API key. Valid values are "query" or "header".
|
||||
//
|
||||
// Valid for apiKey.
|
||||
In in = 4;
|
||||
// Required. The flow used by the OAuth2 security scheme. Valid values are
|
||||
// "implicit", "password", "application" or "accessCode".
|
||||
//
|
||||
// Valid for oauth2.
|
||||
Flow flow = 5;
|
||||
// Required. The authorization URL to be used for this flow. This SHOULD be in
|
||||
// the form of a URL.
|
||||
//
|
||||
// Valid for oauth2/implicit and oauth2/accessCode.
|
||||
string authorization_url = 6;
|
||||
// Required. The token URL to be used for this flow. This SHOULD be in the
|
||||
// form of a URL.
|
||||
//
|
||||
// Valid for oauth2/password, oauth2/application and oauth2/accessCode.
|
||||
string token_url = 7;
|
||||
// Required. The available scopes for the OAuth2 security scheme.
|
||||
//
|
||||
// Valid for oauth2.
|
||||
Scopes scopes = 8;
|
||||
map<string, google.protobuf.Value> extensions = 9;
|
||||
}
|
||||
|
||||
// `SecurityRequirement` is a representation of OpenAPI v2 specification's
|
||||
// Security Requirement object.
|
||||
//
|
||||
// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#securityRequirementObject
|
||||
//
|
||||
// Lists the required security schemes to execute this operation. The object can
|
||||
// have multiple security schemes declared in it which are all required (that
|
||||
// is, there is a logical AND between the schemes).
|
||||
//
|
||||
// The name used for each property MUST correspond to a security scheme
|
||||
// declared in the Security Definitions.
|
||||
message SecurityRequirement {
|
||||
// If the security scheme is of type "oauth2", then the value is a list of
|
||||
// scope names required for the execution. For other security scheme types,
|
||||
// the array MUST be empty.
|
||||
message SecurityRequirementValue {
|
||||
repeated string scope = 1;
|
||||
}
|
||||
// Each name must correspond to a security scheme which is declared in
|
||||
// the Security Definitions. If the security scheme is of type "oauth2",
|
||||
// then the value is a list of scope names required for the execution.
|
||||
// For other security scheme types, the array MUST be empty.
|
||||
map<string, SecurityRequirementValue> security_requirement = 1;
|
||||
}
|
||||
|
||||
// `Scopes` is a representation of OpenAPI v2 specification's Scopes object.
|
||||
//
|
||||
// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#scopesObject
|
||||
//
|
||||
// Lists the available scopes for an OAuth2 security scheme.
|
||||
message Scopes {
|
||||
// Maps between a name of a scope to a short description of it (as the value
|
||||
// of the property).
|
||||
map<string, string> scope = 1;
|
||||
}
|
||||
3
tools.go
3
tools.go
@@ -4,5 +4,8 @@ package main
|
||||
|
||||
import (
|
||||
_ "github.com/UnnoTed/fileb0x"
|
||||
_ "github.com/mitchellh/gox"
|
||||
_ "github.com/restic/calens"
|
||||
_ "golang.org/x/lint/golint"
|
||||
// _ "honnef.co/go/tools/cmd/staticcheck"
|
||||
)
|
||||
|
||||
47
ui/app.js
Normal file
47
ui/app.js
Normal file
@@ -0,0 +1,47 @@
|
||||
import 'regenerator-runtime/runtime'
|
||||
import SettingsApp from './components/SettingsApp.vue'
|
||||
import store from './store'
|
||||
|
||||
// just a dummy function to trick gettext tools
|
||||
function $gettext (msg) {
|
||||
return msg
|
||||
}
|
||||
|
||||
const appInfo = {
|
||||
name: $gettext('Settings'),
|
||||
id: 'settings',
|
||||
icon: 'application',
|
||||
isFileEditor: false,
|
||||
extensions: [],
|
||||
config: {
|
||||
url: 'https://localhost:9200'
|
||||
}
|
||||
}
|
||||
|
||||
const routes = [
|
||||
{
|
||||
name: 'settings',
|
||||
path: '/:extension?',
|
||||
components: {
|
||||
app: SettingsApp
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
const navItems = [
|
||||
{
|
||||
name: $gettext('Settings'),
|
||||
iconMaterial: appInfo.icon,
|
||||
route: {
|
||||
name: 'settings',
|
||||
path: `/${appInfo.id}/`
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
export default {
|
||||
appInfo,
|
||||
store,
|
||||
routes,
|
||||
navItems
|
||||
}
|
||||
305
ui/client/settings/index.js
Normal file
305
ui/client/settings/index.js
Normal file
@@ -0,0 +1,305 @@
|
||||
/* eslint-disable */
|
||||
import axios from 'axios'
|
||||
import qs from 'qs'
|
||||
let domain = ''
|
||||
export const getDomain = () => {
|
||||
return domain
|
||||
}
|
||||
export const setDomain = ($domain) => {
|
||||
domain = $domain
|
||||
}
|
||||
export const request = (method, url, body, queryParameters, form, config) => {
|
||||
method = method.toLowerCase()
|
||||
let keys = Object.keys(queryParameters)
|
||||
let queryUrl = url
|
||||
if (keys.length > 0) {
|
||||
queryUrl = url + '?' + qs.stringify(queryParameters)
|
||||
}
|
||||
// let queryUrl = url+(keys.length > 0 ? '?' + (keys.map(key => key + '=' + encodeURIComponent(queryParameters[key])).join('&')) : '')
|
||||
if (body) {
|
||||
return axios[method](queryUrl, body, config)
|
||||
} else if (method === 'get') {
|
||||
return axios[method](queryUrl, config)
|
||||
} else {
|
||||
return axios[method](queryUrl, qs.stringify(form), config)
|
||||
}
|
||||
}
|
||||
/*==========================================================
|
||||
*
|
||||
==========================================================*/
|
||||
/**
|
||||
*
|
||||
* request: BundleService_GetSettingsBundle
|
||||
* url: BundleService_GetSettingsBundleURL
|
||||
* method: BundleService_GetSettingsBundle_TYPE
|
||||
* raw_url: BundleService_GetSettingsBundle_RAW_URL
|
||||
* @param body -
|
||||
*/
|
||||
export const BundleService_GetSettingsBundle = function(parameters = {}) {
|
||||
const domain = parameters.$domain ? parameters.$domain : getDomain()
|
||||
const config = parameters.$config
|
||||
let path = '/api/v0/settings/bundle-get'
|
||||
let body
|
||||
let queryParameters = {}
|
||||
let form = {}
|
||||
if (parameters['body'] !== undefined) {
|
||||
body = parameters['body']
|
||||
}
|
||||
if (parameters['body'] === undefined) {
|
||||
return Promise.reject(new Error('Missing required parameter: body'))
|
||||
}
|
||||
if (parameters.$queryParameters) {
|
||||
Object.keys(parameters.$queryParameters).forEach(function(parameterName) {
|
||||
queryParameters[parameterName] = parameters.$queryParameters[parameterName]
|
||||
});
|
||||
}
|
||||
return request('post', domain + path, body, queryParameters, form, config)
|
||||
}
|
||||
export const BundleService_GetSettingsBundle_RAW_URL = function() {
|
||||
return '/api/v0/settings/bundle-get'
|
||||
}
|
||||
export const BundleService_GetSettingsBundle_TYPE = function() {
|
||||
return 'post'
|
||||
}
|
||||
export const BundleService_GetSettingsBundleURL = function(parameters = {}) {
|
||||
let queryParameters = {}
|
||||
const domain = parameters.$domain ? parameters.$domain : getDomain()
|
||||
let path = '/api/v0/settings/bundle-get'
|
||||
if (parameters.$queryParameters) {
|
||||
Object.keys(parameters.$queryParameters).forEach(function(parameterName) {
|
||||
queryParameters[parameterName] = parameters.$queryParameters[parameterName]
|
||||
})
|
||||
}
|
||||
let keys = Object.keys(queryParameters)
|
||||
return domain + path + (keys.length > 0 ? '?' + (keys.map(key => key + '=' + encodeURIComponent(queryParameters[key])).join('&')) : '')
|
||||
}
|
||||
/**
|
||||
*
|
||||
* request: BundleService_SaveSettingsBundle
|
||||
* url: BundleService_SaveSettingsBundleURL
|
||||
* method: BundleService_SaveSettingsBundle_TYPE
|
||||
* raw_url: BundleService_SaveSettingsBundle_RAW_URL
|
||||
* @param body -
|
||||
*/
|
||||
export const BundleService_SaveSettingsBundle = function(parameters = {}) {
|
||||
const domain = parameters.$domain ? parameters.$domain : getDomain()
|
||||
const config = parameters.$config
|
||||
let path = '/api/v0/settings/bundle-save'
|
||||
let body
|
||||
let queryParameters = {}
|
||||
let form = {}
|
||||
if (parameters['body'] !== undefined) {
|
||||
body = parameters['body']
|
||||
}
|
||||
if (parameters['body'] === undefined) {
|
||||
return Promise.reject(new Error('Missing required parameter: body'))
|
||||
}
|
||||
if (parameters.$queryParameters) {
|
||||
Object.keys(parameters.$queryParameters).forEach(function(parameterName) {
|
||||
queryParameters[parameterName] = parameters.$queryParameters[parameterName]
|
||||
});
|
||||
}
|
||||
return request('post', domain + path, body, queryParameters, form, config)
|
||||
}
|
||||
export const BundleService_SaveSettingsBundle_RAW_URL = function() {
|
||||
return '/api/v0/settings/bundle-save'
|
||||
}
|
||||
export const BundleService_SaveSettingsBundle_TYPE = function() {
|
||||
return 'post'
|
||||
}
|
||||
export const BundleService_SaveSettingsBundleURL = function(parameters = {}) {
|
||||
let queryParameters = {}
|
||||
const domain = parameters.$domain ? parameters.$domain : getDomain()
|
||||
let path = '/api/v0/settings/bundle-save'
|
||||
if (parameters.$queryParameters) {
|
||||
Object.keys(parameters.$queryParameters).forEach(function(parameterName) {
|
||||
queryParameters[parameterName] = parameters.$queryParameters[parameterName]
|
||||
})
|
||||
}
|
||||
let keys = Object.keys(queryParameters)
|
||||
return domain + path + (keys.length > 0 ? '?' + (keys.map(key => key + '=' + encodeURIComponent(queryParameters[key])).join('&')) : '')
|
||||
}
|
||||
/**
|
||||
*
|
||||
* request: BundleService_ListSettingsBundles
|
||||
* url: BundleService_ListSettingsBundlesURL
|
||||
* method: BundleService_ListSettingsBundles_TYPE
|
||||
* raw_url: BundleService_ListSettingsBundles_RAW_URL
|
||||
* @param body -
|
||||
*/
|
||||
export const BundleService_ListSettingsBundles = function(parameters = {}) {
|
||||
const domain = parameters.$domain ? parameters.$domain : getDomain()
|
||||
const config = parameters.$config
|
||||
let path = '/api/v0/settings/bundles-list'
|
||||
let body
|
||||
let queryParameters = {}
|
||||
let form = {}
|
||||
if (parameters['body'] !== undefined) {
|
||||
body = parameters['body']
|
||||
}
|
||||
if (parameters['body'] === undefined) {
|
||||
return Promise.reject(new Error('Missing required parameter: body'))
|
||||
}
|
||||
if (parameters.$queryParameters) {
|
||||
Object.keys(parameters.$queryParameters).forEach(function(parameterName) {
|
||||
queryParameters[parameterName] = parameters.$queryParameters[parameterName]
|
||||
});
|
||||
}
|
||||
return request('post', domain + path, body, queryParameters, form, config)
|
||||
}
|
||||
export const BundleService_ListSettingsBundles_RAW_URL = function() {
|
||||
return '/api/v0/settings/bundles-list'
|
||||
}
|
||||
export const BundleService_ListSettingsBundles_TYPE = function() {
|
||||
return 'post'
|
||||
}
|
||||
export const BundleService_ListSettingsBundlesURL = function(parameters = {}) {
|
||||
let queryParameters = {}
|
||||
const domain = parameters.$domain ? parameters.$domain : getDomain()
|
||||
let path = '/api/v0/settings/bundles-list'
|
||||
if (parameters.$queryParameters) {
|
||||
Object.keys(parameters.$queryParameters).forEach(function(parameterName) {
|
||||
queryParameters[parameterName] = parameters.$queryParameters[parameterName]
|
||||
})
|
||||
}
|
||||
let keys = Object.keys(queryParameters)
|
||||
return domain + path + (keys.length > 0 ? '?' + (keys.map(key => key + '=' + encodeURIComponent(queryParameters[key])).join('&')) : '')
|
||||
}
|
||||
/**
|
||||
*
|
||||
* request: ValueService_GetSettingsValue
|
||||
* url: ValueService_GetSettingsValueURL
|
||||
* method: ValueService_GetSettingsValue_TYPE
|
||||
* raw_url: ValueService_GetSettingsValue_RAW_URL
|
||||
* @param body -
|
||||
*/
|
||||
export const ValueService_GetSettingsValue = function(parameters = {}) {
|
||||
const domain = parameters.$domain ? parameters.$domain : getDomain()
|
||||
const config = parameters.$config
|
||||
let path = '/api/v0/settings/value-get'
|
||||
let body
|
||||
let queryParameters = {}
|
||||
let form = {}
|
||||
if (parameters['body'] !== undefined) {
|
||||
body = parameters['body']
|
||||
}
|
||||
if (parameters['body'] === undefined) {
|
||||
return Promise.reject(new Error('Missing required parameter: body'))
|
||||
}
|
||||
if (parameters.$queryParameters) {
|
||||
Object.keys(parameters.$queryParameters).forEach(function(parameterName) {
|
||||
queryParameters[parameterName] = parameters.$queryParameters[parameterName]
|
||||
});
|
||||
}
|
||||
return request('post', domain + path, body, queryParameters, form, config)
|
||||
}
|
||||
export const ValueService_GetSettingsValue_RAW_URL = function() {
|
||||
return '/api/v0/settings/value-get'
|
||||
}
|
||||
export const ValueService_GetSettingsValue_TYPE = function() {
|
||||
return 'post'
|
||||
}
|
||||
export const ValueService_GetSettingsValueURL = function(parameters = {}) {
|
||||
let queryParameters = {}
|
||||
const domain = parameters.$domain ? parameters.$domain : getDomain()
|
||||
let path = '/api/v0/settings/value-get'
|
||||
if (parameters.$queryParameters) {
|
||||
Object.keys(parameters.$queryParameters).forEach(function(parameterName) {
|
||||
queryParameters[parameterName] = parameters.$queryParameters[parameterName]
|
||||
})
|
||||
}
|
||||
let keys = Object.keys(queryParameters)
|
||||
return domain + path + (keys.length > 0 ? '?' + (keys.map(key => key + '=' + encodeURIComponent(queryParameters[key])).join('&')) : '')
|
||||
}
|
||||
/**
|
||||
*
|
||||
* request: ValueService_SaveSettingsValue
|
||||
* url: ValueService_SaveSettingsValueURL
|
||||
* method: ValueService_SaveSettingsValue_TYPE
|
||||
* raw_url: ValueService_SaveSettingsValue_RAW_URL
|
||||
* @param body -
|
||||
*/
|
||||
export const ValueService_SaveSettingsValue = function(parameters = {}) {
|
||||
const domain = parameters.$domain ? parameters.$domain : getDomain()
|
||||
const config = parameters.$config
|
||||
let path = '/api/v0/settings/value-save'
|
||||
let body
|
||||
let queryParameters = {}
|
||||
let form = {}
|
||||
if (parameters['body'] !== undefined) {
|
||||
body = parameters['body']
|
||||
}
|
||||
if (parameters['body'] === undefined) {
|
||||
return Promise.reject(new Error('Missing required parameter: body'))
|
||||
}
|
||||
if (parameters.$queryParameters) {
|
||||
Object.keys(parameters.$queryParameters).forEach(function(parameterName) {
|
||||
queryParameters[parameterName] = parameters.$queryParameters[parameterName]
|
||||
});
|
||||
}
|
||||
return request('post', domain + path, body, queryParameters, form, config)
|
||||
}
|
||||
export const ValueService_SaveSettingsValue_RAW_URL = function() {
|
||||
return '/api/v0/settings/value-save'
|
||||
}
|
||||
export const ValueService_SaveSettingsValue_TYPE = function() {
|
||||
return 'post'
|
||||
}
|
||||
export const ValueService_SaveSettingsValueURL = function(parameters = {}) {
|
||||
let queryParameters = {}
|
||||
const domain = parameters.$domain ? parameters.$domain : getDomain()
|
||||
let path = '/api/v0/settings/value-save'
|
||||
if (parameters.$queryParameters) {
|
||||
Object.keys(parameters.$queryParameters).forEach(function(parameterName) {
|
||||
queryParameters[parameterName] = parameters.$queryParameters[parameterName]
|
||||
})
|
||||
}
|
||||
let keys = Object.keys(queryParameters)
|
||||
return domain + path + (keys.length > 0 ? '?' + (keys.map(key => key + '=' + encodeURIComponent(queryParameters[key])).join('&')) : '')
|
||||
}
|
||||
/**
|
||||
*
|
||||
* request: ValueService_ListSettingsValues
|
||||
* url: ValueService_ListSettingsValuesURL
|
||||
* method: ValueService_ListSettingsValues_TYPE
|
||||
* raw_url: ValueService_ListSettingsValues_RAW_URL
|
||||
* @param body -
|
||||
*/
|
||||
export const ValueService_ListSettingsValues = function(parameters = {}) {
|
||||
const domain = parameters.$domain ? parameters.$domain : getDomain()
|
||||
const config = parameters.$config
|
||||
let path = '/api/v0/settings/values-list'
|
||||
let body
|
||||
let queryParameters = {}
|
||||
let form = {}
|
||||
if (parameters['body'] !== undefined) {
|
||||
body = parameters['body']
|
||||
}
|
||||
if (parameters['body'] === undefined) {
|
||||
return Promise.reject(new Error('Missing required parameter: body'))
|
||||
}
|
||||
if (parameters.$queryParameters) {
|
||||
Object.keys(parameters.$queryParameters).forEach(function(parameterName) {
|
||||
queryParameters[parameterName] = parameters.$queryParameters[parameterName]
|
||||
});
|
||||
}
|
||||
return request('post', domain + path, body, queryParameters, form, config)
|
||||
}
|
||||
export const ValueService_ListSettingsValues_RAW_URL = function() {
|
||||
return '/api/v0/settings/values-list'
|
||||
}
|
||||
export const ValueService_ListSettingsValues_TYPE = function() {
|
||||
return 'post'
|
||||
}
|
||||
export const ValueService_ListSettingsValuesURL = function(parameters = {}) {
|
||||
let queryParameters = {}
|
||||
const domain = parameters.$domain ? parameters.$domain : getDomain()
|
||||
let path = '/api/v0/settings/values-list'
|
||||
if (parameters.$queryParameters) {
|
||||
Object.keys(parameters.$queryParameters).forEach(function(parameterName) {
|
||||
queryParameters[parameterName] = parameters.$queryParameters[parameterName]
|
||||
})
|
||||
}
|
||||
let keys = Object.keys(queryParameters)
|
||||
return domain + path + (keys.length > 0 ? '?' + (keys.map(key => key + '=' + encodeURIComponent(queryParameters[key])).join('&')) : '')
|
||||
}
|
||||
102
ui/components/SettingsApp.vue
Normal file
102
ui/components/SettingsApp.vue
Normal file
@@ -0,0 +1,102 @@
|
||||
<template>
|
||||
<div>
|
||||
<div v-if="initialized" class="uk-width-3-4@m uk-container uk-padding">
|
||||
<oc-alert v-if="extensions.length === 0" variation="primary" no-close>
|
||||
<p class="uk-flex uk-flex-middle">
|
||||
<oc-icon name="info" class="uk-margin-xsmall-right" />
|
||||
<translate>No settings available</translate>
|
||||
</p>
|
||||
</oc-alert>
|
||||
<template v-else>
|
||||
<template v-if="selectedExtensionName">
|
||||
<div class="uk-flex uk-flex-between uk-flex-middle">
|
||||
<h1 class="oc-page-title">
|
||||
{{ selectedExtensionName }}
|
||||
</h1>
|
||||
</div>
|
||||
<hr />
|
||||
</template>
|
||||
<template v-if="settingsValuesLoaded">
|
||||
<settings-bundle
|
||||
v-for="bundle in selectedSettingsBundles"
|
||||
:key="'bundle-' + bundle.identifier.bundleKey"
|
||||
:bundle="bundle"
|
||||
class="uk-margin-top"
|
||||
/>
|
||||
</template>
|
||||
<div class="uk-margin-top" v-else>
|
||||
<oc-loader :aria-label="$gettext('Loading settings values')" />
|
||||
<oc-alert :aria-hidden="true" varition="primary" no-close>
|
||||
<p v-translate>Loading settings values...</p>
|
||||
</oc-alert>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
<oc-loader v-else />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { mapActions, mapGetters } from 'vuex'
|
||||
import SettingsBundle from './SettingsBundle.vue'
|
||||
export default {
|
||||
name: 'SettingsApp',
|
||||
components: { SettingsBundle },
|
||||
data () {
|
||||
return {
|
||||
loading: true,
|
||||
selectedExtension: undefined
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
...mapGetters(['settingsValuesLoaded']),
|
||||
...mapGetters('Settings', [
|
||||
'extensions',
|
||||
'initialized',
|
||||
'getSettingsBundlesByExtension'
|
||||
]),
|
||||
extensionRouteParam () {
|
||||
return this.$route.params.extension
|
||||
},
|
||||
selectedExtensionName () {
|
||||
// TODO: extensions need to be registered with display names, separate from the settings bundles. until then: hardcoded translation
|
||||
if (this.selectedExtension === 'ocis-accounts') {
|
||||
return 'Account'
|
||||
} else if (this.selectedExtension === 'ocis-test') {
|
||||
return 'Test'
|
||||
}
|
||||
return this.selectedExtension
|
||||
},
|
||||
selectedSettingsBundles () {
|
||||
if (this.selectedExtension) {
|
||||
return this.getSettingsBundlesByExtension(this.selectedExtension)
|
||||
}
|
||||
return []
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
...mapActions('Settings', ['initialize']),
|
||||
resetSelectedExtension () {
|
||||
if (this.extensions.length > 0) {
|
||||
if (this.extensionRouteParam && this.extensions.includes(this.extensionRouteParam)) {
|
||||
this.selectedExtension = this.extensionRouteParam
|
||||
} else {
|
||||
this.selectedExtension = this.extensions[0]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
async created () {
|
||||
await this.initialize()
|
||||
this.resetSelectedExtension()
|
||||
},
|
||||
watch: {
|
||||
initialized () {
|
||||
this.resetSelectedExtension()
|
||||
},
|
||||
extensionRouteParam () {
|
||||
this.resetSelectedExtension()
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
80
ui/components/SettingsBundle.vue
Normal file
80
ui/components/SettingsBundle.vue
Normal file
@@ -0,0 +1,80 @@
|
||||
<template>
|
||||
<div class="uk-width-1-1 uk-width-2-3@m uk-width-1-2@l">
|
||||
<div class="uk-text-bold uk-margin-small-bottom">
|
||||
<translate>{{ bundle.displayName }}</translate>
|
||||
</div>
|
||||
<oc-grid gutter="small">
|
||||
<template>
|
||||
<div class="uk-width-1-1" v-for="setting in bundle.settings" :key="getElementId(bundle, setting)">
|
||||
<label class="oc-label" :for="getElementId(bundle, setting)">{{ setting.displayName }}</label>
|
||||
<div class="uk-position-relative"
|
||||
:is="getSettingComponent(setting)"
|
||||
:id="getElementId(bundle, setting)"
|
||||
:bundle="bundle"
|
||||
:setting="setting"
|
||||
:persisted-value="getSettingsValue(bundle, setting)"
|
||||
@onSave="onSaveSettingsValue"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
</oc-grid>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { mapGetters, mapActions } from 'vuex'
|
||||
import SettingBoolean from './settings/SettingBoolean.vue'
|
||||
import SettingMultiChoice from './settings/SettingMultiChoice.vue'
|
||||
import SettingNumber from './settings/SettingNumber.vue'
|
||||
import SettingSingleChoice from './settings/SettingSingleChoice.vue'
|
||||
import SettingString from './settings/SettingString.vue'
|
||||
import SettingUnknown from './settings/SettingUnknown.vue'
|
||||
|
||||
export default {
|
||||
name: 'SettingsBundle',
|
||||
props: {
|
||||
bundle: {
|
||||
type: Object,
|
||||
required: true
|
||||
}
|
||||
},
|
||||
computed: mapGetters(['getSettingsValueByIdentifier']),
|
||||
methods: {
|
||||
...mapActions('Settings', ['saveSettingsValue']),
|
||||
getElementId (bundle, setting) {
|
||||
return `setting-${bundle.identifier.bundleKey}-${setting.settingKey}`
|
||||
},
|
||||
getSettingComponent (setting) {
|
||||
return 'Setting' + setting.type[0].toUpperCase() + setting.type.substr(1)
|
||||
},
|
||||
getSettingsValue (bundle, setting) {
|
||||
const identifier = {
|
||||
extension: bundle.identifier.extension,
|
||||
bundleKey: bundle.identifier.bundleKey,
|
||||
settingKey: setting.settingKey
|
||||
}
|
||||
return this.getSettingsValueByIdentifier(identifier)
|
||||
},
|
||||
async onSaveSettingsValue ({ bundle, setting, value }) {
|
||||
const payload = {
|
||||
identifier: {
|
||||
accountUuid: 'me',
|
||||
extension: bundle.identifier.extension,
|
||||
bundleKey: bundle.identifier.bundleKey,
|
||||
settingKey: setting.settingKey
|
||||
},
|
||||
...value
|
||||
}
|
||||
await this.saveSettingsValue(payload)
|
||||
}
|
||||
},
|
||||
components: {
|
||||
SettingBoolean,
|
||||
SettingMultiChoice,
|
||||
SettingNumber,
|
||||
SettingSingleChoice,
|
||||
SettingString,
|
||||
SettingUnknown
|
||||
}
|
||||
}
|
||||
</script>
|
||||
52
ui/components/settings/SettingBoolean.vue
Normal file
52
ui/components/settings/SettingBoolean.vue
Normal file
@@ -0,0 +1,52 @@
|
||||
<template>
|
||||
<div>
|
||||
<oc-checkbox v-model="value" :label="setting.boolValue.label" @change="applyValue" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import isNil from 'lodash/isNil'
|
||||
export default {
|
||||
name: 'SettingBoolean',
|
||||
props: {
|
||||
bundle: {
|
||||
type: Object,
|
||||
required: true
|
||||
},
|
||||
setting: {
|
||||
type: Object,
|
||||
required: true
|
||||
},
|
||||
persistedValue: {
|
||||
type: Object,
|
||||
required: false
|
||||
}
|
||||
},
|
||||
data () {
|
||||
return {
|
||||
value: null
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
async applyValue () {
|
||||
const value = {
|
||||
boolValue: this.value
|
||||
}
|
||||
await this.$emit('onSave', {
|
||||
bundle: this.bundle,
|
||||
setting: this.setting,
|
||||
value
|
||||
})
|
||||
// TODO: show a spinner while the request for saving the value is running!
|
||||
}
|
||||
},
|
||||
mounted () {
|
||||
if (!isNil(this.persistedValue)) {
|
||||
this.value = this.persistedValue.boolValue
|
||||
}
|
||||
if (isNil(this.value) && !isNil(this.setting.boolValue.default)) {
|
||||
this.value = this.setting.boolValue.default
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
136
ui/components/settings/SettingMultiChoice.vue
Normal file
136
ui/components/settings/SettingMultiChoice.vue
Normal file
@@ -0,0 +1,136 @@
|
||||
<template>
|
||||
<div>
|
||||
<oc-button :id="buttonElementId" class="uk-width-expand">
|
||||
<span v-if="selectedOptions !== null && selectedOptions.length > 0">
|
||||
{{ selectedOptionsDisplayValues }}
|
||||
</span>
|
||||
<span v-else>
|
||||
{{ setting.placeholder || $gettext('Please select') }}
|
||||
</span>
|
||||
</oc-button>
|
||||
<oc-drop
|
||||
:drop-id="dropElementId"
|
||||
:toggle="`#${buttonElementId}`"
|
||||
mode="click"
|
||||
position="bottom-justify"
|
||||
:options="{ offset: 0, delayHide: 200, flip: false }"
|
||||
>
|
||||
<ul class="uk-list">
|
||||
<li
|
||||
v-for="(option, index) in setting.multiChoiceValue.options"
|
||||
:key="getOptionElementId(index)"
|
||||
>
|
||||
<label :for="getOptionElementId(index)">
|
||||
<input
|
||||
:id="getOptionElementId(index)"
|
||||
type="checkbox"
|
||||
class="oc-checkbox"
|
||||
:value="option"
|
||||
v-model="selectedOptions"
|
||||
@change="onSelectedOption"
|
||||
/>
|
||||
{{ option.displayValue }}
|
||||
</label>
|
||||
</li>
|
||||
</ul>
|
||||
</oc-drop>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import isNil from 'lodash/isNil'
|
||||
export default {
|
||||
name: 'SettingMultiChoice',
|
||||
props: {
|
||||
bundle: {
|
||||
type: Object,
|
||||
required: true
|
||||
},
|
||||
setting: {
|
||||
type: Object,
|
||||
required: true
|
||||
},
|
||||
persistedValue: {
|
||||
type: Object,
|
||||
required: false
|
||||
}
|
||||
},
|
||||
data () {
|
||||
return {
|
||||
selectedOptions: null
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
selectedOptionsDisplayValues () {
|
||||
return Array.from(this.selectedOptions).map(option => option.displayValue).join(', ')
|
||||
},
|
||||
dropElementId () {
|
||||
return `multi-choice-drop-${this.bundle.identifier.bundleKey}-${this.setting.settingKey}`
|
||||
},
|
||||
buttonElementId () {
|
||||
return `multi-choice-toggle-${this.bundle.identifier.bundleKey}-${this.setting.settingKey}`
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
getOptionElementId (index) {
|
||||
return `${this.bundle.identifier.bundleKey}-${this.setting.settingKey}-${index}`
|
||||
},
|
||||
async onSelectedOption () {
|
||||
const values = []
|
||||
if (!isNil(this.selectedOptions)) {
|
||||
this.selectedOptions.forEach(option => {
|
||||
if (option.value.intValue) {
|
||||
values.push({ intValue: option.value.intValue })
|
||||
}
|
||||
if (option.value.stringValue) {
|
||||
values.push({ stringValue: option.value.stringValue })
|
||||
}
|
||||
})
|
||||
}
|
||||
await this.$emit('onSave', {
|
||||
bundle: this.bundle,
|
||||
setting: this.setting,
|
||||
value: {
|
||||
listValue: {
|
||||
values
|
||||
}
|
||||
}
|
||||
})
|
||||
// TODO: show a spinner while the request for saving the value is running!
|
||||
}
|
||||
},
|
||||
mounted () {
|
||||
if (!isNil(this.persistedValue) && !isNil(this.persistedValue.listValue)) {
|
||||
const selectedValues = []
|
||||
if (this.persistedValue.listValue.values) {
|
||||
this.persistedValue.listValue.values.forEach(value => {
|
||||
if (value.intValue) {
|
||||
selectedValues.push(value.intValue)
|
||||
}
|
||||
if (value.stringValue) {
|
||||
selectedValues.push(value.stringValue)
|
||||
}
|
||||
})
|
||||
}
|
||||
if (selectedValues.length === 0) {
|
||||
this.selectedOptions = []
|
||||
} else {
|
||||
this.selectedOptions = this.setting.multiChoiceValue.options.filter(option => {
|
||||
if (option.value.intValue) {
|
||||
return selectedValues.includes(option.value.intValue)
|
||||
}
|
||||
if (option.value.stringValue) {
|
||||
return selectedValues.includes(option.value.stringValue)
|
||||
}
|
||||
return false
|
||||
})
|
||||
}
|
||||
}
|
||||
// TODO: load the settings value of the authenticated user and set it in `selectedOptions`
|
||||
// if not set, yet, apply defaults from settings bundle definition
|
||||
if (this.selectedOptions === null) {
|
||||
this.selectedOptions = this.setting.multiChoiceValue.options.filter(option => option.default)
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
94
ui/components/settings/SettingNumber.vue
Normal file
94
ui/components/settings/SettingNumber.vue
Normal file
@@ -0,0 +1,94 @@
|
||||
<template>
|
||||
<oc-grid flex>
|
||||
<div class="uk-width-expand">
|
||||
<oc-text-input
|
||||
type="number"
|
||||
v-model="value"
|
||||
v-bind="inputAttributes"
|
||||
:placeholder="setting.intValue.placeholder"
|
||||
:label="setting.description"
|
||||
@keydown.enter="applyValue"
|
||||
@keydown.esc="cancel"
|
||||
/>
|
||||
</div>
|
||||
<div v-if="isChanged">
|
||||
<oc-button @click="cancel" class="uk-margin-xsmall-left">
|
||||
<translate>Cancel</translate>
|
||||
</oc-button>
|
||||
<oc-button @click="applyValue" class="uk-margin-xsmall-left" variation="primary">
|
||||
<translate>Save</translate>
|
||||
</oc-button>
|
||||
</div>
|
||||
</oc-grid>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import isNil from 'lodash/isNil'
|
||||
export default {
|
||||
name: 'SettingNumber',
|
||||
props: {
|
||||
bundle: {
|
||||
type: Object,
|
||||
required: true
|
||||
},
|
||||
setting: {
|
||||
type: Object,
|
||||
required: true
|
||||
},
|
||||
persistedValue: {
|
||||
type: Object,
|
||||
required: false
|
||||
}
|
||||
},
|
||||
data () {
|
||||
return {
|
||||
initialValue: null,
|
||||
value: null
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
isChanged () {
|
||||
return this.initialValue !== this.value
|
||||
},
|
||||
inputAttributes () {
|
||||
const attributes = {}
|
||||
if (!isNil(this.setting.intValue.min)) {
|
||||
attributes.min = this.setting.intValue.min
|
||||
}
|
||||
if (!isNil(this.setting.intValue.max)) {
|
||||
attributes.max = this.setting.intValue.max
|
||||
}
|
||||
if (!isNil(this.setting.intValue.step)) {
|
||||
attributes.step = this.setting.intValue.step
|
||||
}
|
||||
return attributes
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
cancel () {
|
||||
this.value = this.initialValue
|
||||
},
|
||||
async applyValue () {
|
||||
const value = {
|
||||
intValue: this.value
|
||||
}
|
||||
await this.$emit('onSave', {
|
||||
bundle: this.bundle,
|
||||
setting: this.setting,
|
||||
value
|
||||
})
|
||||
// TODO: show a spinner while the request for saving the value is running!
|
||||
this.initialValue = this.value
|
||||
}
|
||||
},
|
||||
mounted () {
|
||||
if (!isNil(this.persistedValue)) {
|
||||
this.value = this.persistedValue.intValue
|
||||
}
|
||||
if (isNil(this.value) && !isNil(this.setting.intValue.default)) {
|
||||
this.value = this.setting.intValue.default
|
||||
}
|
||||
this.initialValue = this.value
|
||||
}
|
||||
}
|
||||
</script>
|
||||
121
ui/components/settings/SettingSingleChoice.vue
Normal file
121
ui/components/settings/SettingSingleChoice.vue
Normal file
@@ -0,0 +1,121 @@
|
||||
<template>
|
||||
<div>
|
||||
<oc-button :id="buttonElementId" class="uk-width-expand">
|
||||
<span v-if="selectedOption">
|
||||
{{ selectedOption.displayValue }}
|
||||
</span>
|
||||
<span v-else>
|
||||
{{ setting.placeholder || $gettext('Please select') }}
|
||||
</span>
|
||||
</oc-button>
|
||||
<oc-drop
|
||||
:drop-id="dropElementId"
|
||||
:toggle="`#${buttonElementId}`"
|
||||
mode="click"
|
||||
close-on-click
|
||||
position="bottom-justify"
|
||||
:options="{ offset: 0, delayHide: 200, flip: false }"
|
||||
>
|
||||
<ul class="uk-list">
|
||||
<li
|
||||
v-for="(option, index) in setting.singleChoiceValue.options"
|
||||
:key="getOptionElementId(index)"
|
||||
>
|
||||
<label :for="getOptionElementId(index)">
|
||||
<input
|
||||
:id="getOptionElementId(index)"
|
||||
type="radio"
|
||||
class="oc-radiobutton"
|
||||
v-model="selectedOption"
|
||||
:value="option"
|
||||
@change="onSelectedOption"
|
||||
/>
|
||||
{{ option.displayValue }}
|
||||
</label>
|
||||
</li>
|
||||
</ul>
|
||||
</oc-drop>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import isNil from 'lodash/isNil'
|
||||
export default {
|
||||
name: 'SettingSingleChoice',
|
||||
props: {
|
||||
bundle: {
|
||||
type: Object,
|
||||
required: true
|
||||
},
|
||||
setting: {
|
||||
type: Object,
|
||||
required: true
|
||||
},
|
||||
persistedValue: {
|
||||
type: Object,
|
||||
required: false
|
||||
}
|
||||
},
|
||||
data () {
|
||||
return {
|
||||
selectedOption: null
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
dropElementId () {
|
||||
return `single-choice-drop-${this.bundle.identifier.bundleKey}-${this.setting.settingKey}`
|
||||
},
|
||||
buttonElementId () {
|
||||
return `single-choice-toggle-${this.bundle.identifier.bundleKey}-${this.setting.settingKey}`
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
getOptionElementId (index) {
|
||||
return `${this.bundle.identifier.bundleKey}-${this.setting.settingKey}-${index}`
|
||||
},
|
||||
async onSelectedOption () {
|
||||
const values = []
|
||||
if (!isNil(this.selectedOption)) {
|
||||
if (this.selectedOption.value.intValue) {
|
||||
values.push({ intValue: this.selectedOption.value.intValue })
|
||||
}
|
||||
if (this.selectedOption.value.stringValue) {
|
||||
values.push({ stringValue: this.selectedOption.value.stringValue })
|
||||
}
|
||||
}
|
||||
await this.$emit('onSave', {
|
||||
bundle: this.bundle,
|
||||
setting: this.setting,
|
||||
value: {
|
||||
listValue: {
|
||||
values
|
||||
}
|
||||
}
|
||||
})
|
||||
// TODO: show a spinner while the request for saving the value is running!
|
||||
}
|
||||
},
|
||||
mounted () {
|
||||
if (!isNil(this.persistedValue) && !isNil(this.persistedValue.listValue)) {
|
||||
const selected = this.persistedValue.listValue.values[0]
|
||||
const filtered = this.setting.singleChoiceValue.options.filter(option => {
|
||||
if (selected.intValue) {
|
||||
return option.value.intValue === selected.intValue
|
||||
} else {
|
||||
return option.value.stringValue === selected.stringValue
|
||||
}
|
||||
})
|
||||
if (filtered.length > 0) {
|
||||
this.selectedOption = filtered[0]
|
||||
}
|
||||
}
|
||||
// if not set, yet, apply default from settings bundle definition
|
||||
if (isNil(this.selectedOption)) {
|
||||
const defaults = this.setting.singleChoiceValue.options.filter(option => option.default)
|
||||
if (defaults.length === 1) {
|
||||
this.selectedOption = defaults[0]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
79
ui/components/settings/SettingString.vue
Normal file
79
ui/components/settings/SettingString.vue
Normal file
@@ -0,0 +1,79 @@
|
||||
<template>
|
||||
<oc-grid flex>
|
||||
<div class="uk-width-expand">
|
||||
<oc-text-input
|
||||
v-model="value"
|
||||
:placeholder="setting.stringValue.placeholder"
|
||||
:label="setting.description"
|
||||
@keydown.enter="applyValue"
|
||||
@keydown.esc="cancel"
|
||||
/>
|
||||
</div>
|
||||
<div v-if="isChanged">
|
||||
<oc-button @click="cancel" class="uk-margin-xsmall-left">
|
||||
<translate>Cancel</translate>
|
||||
</oc-button>
|
||||
<oc-button @click="applyValue" class="uk-margin-xsmall-left" variation="primary">
|
||||
<translate>Save</translate>
|
||||
</oc-button>
|
||||
</div>
|
||||
</oc-grid>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import isNil from 'lodash/isNil'
|
||||
export default {
|
||||
name: 'SettingString',
|
||||
props: {
|
||||
bundle: {
|
||||
type: Object,
|
||||
required: true
|
||||
},
|
||||
setting: {
|
||||
type: Object,
|
||||
required: true
|
||||
},
|
||||
persistedValue: {
|
||||
type: Object,
|
||||
required: false
|
||||
}
|
||||
},
|
||||
data () {
|
||||
return {
|
||||
initialValue: null,
|
||||
value: null
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
isChanged () {
|
||||
return this.initialValue !== this.value
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
async applyValue () {
|
||||
const value = {
|
||||
stringValue: this.value
|
||||
}
|
||||
await this.$emit('onSave', {
|
||||
bundle: this.bundle,
|
||||
setting: this.setting,
|
||||
value
|
||||
})
|
||||
// TODO: show a spinner while the request for saving the value is running!
|
||||
this.initialValue = this.value
|
||||
},
|
||||
cancel () {
|
||||
this.value = this.initialValue
|
||||
}
|
||||
},
|
||||
mounted () {
|
||||
if (!isNil(this.persistedValue)) {
|
||||
this.value = this.persistedValue.stringValue
|
||||
}
|
||||
if (isNil(this.value) && !isNil(this.setting.stringValue.default)) {
|
||||
this.value = this.setting.stringValue.default
|
||||
}
|
||||
this.initialValue = this.value
|
||||
}
|
||||
}
|
||||
</script>
|
||||
25
ui/components/settings/SettingUnknown.vue
Normal file
25
ui/components/settings/SettingUnknown.vue
Normal file
@@ -0,0 +1,25 @@
|
||||
<template>
|
||||
<div>
|
||||
<translate :translate-params="{ type: setting.type }">Settings type not implemented: %{type}</translate>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'SettingUnknown',
|
||||
props: {
|
||||
bundle: {
|
||||
type: Object,
|
||||
required: true
|
||||
},
|
||||
setting: {
|
||||
type: Object,
|
||||
required: true
|
||||
},
|
||||
persistedValue: {
|
||||
type: Object,
|
||||
required: false
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
140
ui/store/index.js
Normal file
140
ui/store/index.js
Normal file
@@ -0,0 +1,140 @@
|
||||
import {
|
||||
// eslint-disable-next-line camelcase
|
||||
BundleService_ListSettingsBundles,
|
||||
// eslint-disable-next-line camelcase
|
||||
ValueService_SaveSettingsValue
|
||||
} from '../client/settings'
|
||||
import axios from 'axios'
|
||||
|
||||
const state = {
|
||||
config: null,
|
||||
initialized: false,
|
||||
settingsBundles: {}
|
||||
}
|
||||
|
||||
const getters = {
|
||||
config: state => state.config,
|
||||
initialized: state => state.initialized,
|
||||
extensions: state => {
|
||||
return Array.from(state.settingsBundles.keys()).sort()
|
||||
},
|
||||
getSettingsBundlesByExtension: state => extension => {
|
||||
if (state.settingsBundles.has(extension)) {
|
||||
return Array.from(state.settingsBundles.get(extension).values()).sort((b1, b2) => {
|
||||
return b1.identifier.bundleKey.localeCompare(b2.identifier.bundleKey)
|
||||
})
|
||||
}
|
||||
return []
|
||||
}
|
||||
}
|
||||
|
||||
const mutations = {
|
||||
SET_INITIALIZED (state, value) {
|
||||
state.initialized = value
|
||||
},
|
||||
SET_SETTINGS_BUNDLES (state, settingsBundles) {
|
||||
const map = new Map()
|
||||
Array.from(settingsBundles).forEach(bundle => {
|
||||
if (!map.has(bundle.identifier.extension)) {
|
||||
map.set(bundle.identifier.extension, new Map())
|
||||
}
|
||||
map.get(bundle.identifier.extension).set(bundle.identifier.bundleKey, bundle)
|
||||
})
|
||||
state.settingsBundles = map
|
||||
},
|
||||
LOAD_CONFIG (state, config) {
|
||||
state.config = config
|
||||
}
|
||||
}
|
||||
|
||||
const actions = {
|
||||
loadConfig ({ commit }, config) {
|
||||
commit('LOAD_CONFIG', config)
|
||||
},
|
||||
|
||||
async initialize ({ commit, dispatch }) {
|
||||
await dispatch('fetchSettingsBundles')
|
||||
commit('SET_INITIALIZED', true)
|
||||
},
|
||||
|
||||
async fetchSettingsBundles ({ commit, dispatch, getters, rootGetters }) {
|
||||
injectAuthToken(rootGetters)
|
||||
const response = await BundleService_ListSettingsBundles({
|
||||
$domain: getters.config.url,
|
||||
body: {}
|
||||
})
|
||||
if (response.status === 201) {
|
||||
// the settings markup has implicit typing. inject an explicit type variable here
|
||||
const settingsBundles = response.data.settingsBundles
|
||||
if (settingsBundles) {
|
||||
settingsBundles.forEach(bundle => {
|
||||
bundle.settings.forEach(setting => {
|
||||
if (setting.intValue) {
|
||||
setting.type = 'number'
|
||||
} else if (setting.stringValue) {
|
||||
setting.type = 'string'
|
||||
} else if (setting.boolValue) {
|
||||
setting.type = 'boolean'
|
||||
} else if (setting.singleChoiceValue) {
|
||||
setting.type = 'singleChoice'
|
||||
} else if (setting.multiChoiceValue) {
|
||||
setting.type = 'multiChoice'
|
||||
} else {
|
||||
setting.type = 'unknown'
|
||||
}
|
||||
})
|
||||
})
|
||||
commit('SET_SETTINGS_BUNDLES', settingsBundles)
|
||||
} else {
|
||||
commit('SET_SETTINGS_BUNDLES', [])
|
||||
}
|
||||
} else {
|
||||
dispatch('showMessage', {
|
||||
title: 'Failed to fetch settings bundles.',
|
||||
desc: response.statusText,
|
||||
status: 'danger'
|
||||
}, { root: true })
|
||||
}
|
||||
},
|
||||
|
||||
async saveSettingsValue ({ commit, dispatch, getters, rootGetters }, payload) {
|
||||
injectAuthToken(rootGetters)
|
||||
const response = await ValueService_SaveSettingsValue({
|
||||
$domain: getters.config.url,
|
||||
body: {
|
||||
settingsValue: payload
|
||||
}
|
||||
})
|
||||
if (response.status === 201) {
|
||||
if (response.data.settingsValue) {
|
||||
commit('SET_SETTINGS_VALUE', response.data.settingsValue, { root: true })
|
||||
}
|
||||
} else {
|
||||
dispatch('showMessage', {
|
||||
title: 'Failed to save settings value.',
|
||||
desc: response.statusText,
|
||||
status: 'danger'
|
||||
}, { root: true })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state,
|
||||
getters,
|
||||
actions,
|
||||
mutations
|
||||
}
|
||||
|
||||
function injectAuthToken (rootGetters) {
|
||||
axios.interceptors.request.use(config => {
|
||||
if (typeof config.headers.Authorization === 'undefined') {
|
||||
const token = rootGetters.user.token
|
||||
if (token) {
|
||||
config.headers.Authorization = `Bearer ${token}`
|
||||
}
|
||||
}
|
||||
return config
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user