diff options
Diffstat (limited to 'vendor/github.com/authzed/spicedb/pkg')
184 files changed, 76766 insertions, 0 deletions
diff --git a/vendor/github.com/authzed/spicedb/pkg/caveats/compile.go b/vendor/github.com/authzed/spicedb/pkg/caveats/compile.go new file mode 100644 index 0000000..312a701 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/caveats/compile.go @@ -0,0 +1,226 @@ +package caveats + +import ( + "fmt" + "strings" + + "github.com/authzed/cel-go/cel" + "github.com/authzed/cel-go/common" + "google.golang.org/protobuf/proto" + + "github.com/authzed/spicedb/pkg/caveats/replacer" + "github.com/authzed/spicedb/pkg/caveats/types" + "github.com/authzed/spicedb/pkg/genutil/mapz" + impl "github.com/authzed/spicedb/pkg/proto/impl/v1" +) + +const anonymousCaveat = "" + +const maxCaveatExpressionSize = 100_000 // characters + +// CompiledCaveat is a compiled form of a caveat. +type CompiledCaveat struct { + // env is the environment under which the CEL program was compiled. + celEnv *cel.Env + + // ast is the AST form of the CEL program. + ast *cel.Ast + + // name of the caveat + name string +} + +// Name represents a user-friendly reference to a caveat +func (cc CompiledCaveat) Name() string { + return cc.name +} + +// ExprString returns the string-form of the caveat. +func (cc CompiledCaveat) ExprString() (string, error) { + return cel.AstToString(cc.ast) +} + +// RewriteVariable replaces the use of a variable with another variable in the compiled caveat. +func (cc CompiledCaveat) RewriteVariable(oldName, newName string) (CompiledCaveat, error) { + // Find the existing parameter name and get its type. + oldExpr, issues := cc.celEnv.Compile(oldName) + if issues.Err() != nil { + return CompiledCaveat{}, fmt.Errorf("failed to parse old variable name: %w", issues.Err()) + } + + oldType := oldExpr.OutputType() + + // Ensure the new variable name is not used. + _, niss := cc.celEnv.Compile(newName) + if niss.Err() == nil { + return CompiledCaveat{}, fmt.Errorf("variable name '%s' is already used", newName) + } + + // Extend the environment with the new variable name. + extended, err := cc.celEnv.Extend(cel.Variable(newName, oldType)) + if err != nil { + return CompiledCaveat{}, fmt.Errorf("failed to extend environment: %w", err) + } + + // Replace the variable in the AST. + updatedAst, err := replacer.ReplaceVariable(extended, cc.ast, oldName, newName) + if err != nil { + return CompiledCaveat{}, fmt.Errorf("failed to rewrite variable: %w", err) + } + + return CompiledCaveat{extended, updatedAst, cc.name}, nil +} + +// Serialize serializes the compiled caveat into a byte string for storage. +func (cc CompiledCaveat) Serialize() ([]byte, error) { + cexpr, err := cel.AstToCheckedExpr(cc.ast) + if err != nil { + return nil, err + } + + caveat := &impl.DecodedCaveat{ + KindOneof: &impl.DecodedCaveat_Cel{ + Cel: cexpr, + }, + Name: cc.name, + } + + // TODO(jschorr): change back to MarshalVT once stable is supported. + // See: https://github.com/planetscale/vtprotobuf/pull/133 + return proto.MarshalOptions{Deterministic: true}.Marshal(caveat) +} + +// ReferencedParameters returns the names of the parameters referenced in the expression. +func (cc CompiledCaveat) ReferencedParameters(parameters []string) (*mapz.Set[string], error) { + referencedParams := mapz.NewSet[string]() + definedParameters := mapz.NewSet[string]() + definedParameters.Extend(parameters) + + checked, err := cel.AstToCheckedExpr(cc.ast) + if err != nil { + return nil, err + } + + referencedParameters(definedParameters, checked.Expr, referencedParams) + return referencedParams, nil +} + +// CompileCaveatWithName compiles a caveat string into a compiled caveat with a given name, +// or returns the compilation errors. +func CompileCaveatWithName(env *Environment, exprString, name string) (*CompiledCaveat, error) { + c, err := CompileCaveatWithSource(env, name, common.NewStringSource(exprString, name), nil) + if err != nil { + return nil, err + } + c.name = name + return c, nil +} + +// CompileCaveatWithSource compiles a caveat source into a compiled caveat, or returns the compilation errors. +func CompileCaveatWithSource(env *Environment, name string, source common.Source, startPosition SourcePosition) (*CompiledCaveat, error) { + celEnv, err := env.asCelEnvironment() + if err != nil { + return nil, err + } + + if len(strings.TrimSpace(source.Content())) > maxCaveatExpressionSize { + return nil, fmt.Errorf("caveat expression provided exceeds maximum allowed size of %d characters", maxCaveatExpressionSize) + } + + ast, issues := celEnv.CompileSource(source) + if issues != nil && issues.Err() != nil { + if startPosition == nil { + return nil, MultipleCompilationError{issues.Err(), issues} + } + + // Construct errors with the source location adjusted based on the starting source position + // in the parent schema (if any). This ensures that the errors coming out of CEL show the correct + // *overall* location information.. + line, col, err := startPosition.LineAndColumn() + if err != nil { + return nil, err + } + + adjustedErrors := common.NewErrors(source) + for _, existingErr := range issues.Errors() { + location := existingErr.Location + + // NOTE: Our locations are zero-indexed while CEL is 1-indexed, so we need to adjust the line/column values accordingly. + if location.Line() == 1 { + location = common.NewLocation(line+location.Line(), col+location.Column()) + } else { + location = common.NewLocation(line+location.Line(), location.Column()) + } + + adjustedError := &common.Error{ + Message: existingErr.Message, + ExprID: existingErr.ExprID, + Location: location, + } + + adjustedErrors = adjustedErrors.Append([]*common.Error{ + adjustedError, + }) + } + + adjustedIssues := cel.NewIssues(adjustedErrors) + return nil, MultipleCompilationError{adjustedIssues.Err(), adjustedIssues} + } + + if ast.OutputType() != cel.BoolType { + return nil, MultipleCompilationError{fmt.Errorf("caveat expression must result in a boolean value: found `%s`", ast.OutputType().String()), nil} + } + + compiled := &CompiledCaveat{celEnv, ast, anonymousCaveat} + compiled.name = name + return compiled, nil +} + +// compileCaveat compiles a caveat string into a compiled caveat, or returns the compilation errors. +func compileCaveat(env *Environment, exprString string) (*CompiledCaveat, error) { + s := common.NewStringSource(exprString, "caveat") + return CompileCaveatWithSource(env, "caveat", s, nil) +} + +// DeserializeCaveat deserializes a byte-serialized caveat back into a CompiledCaveat. +func DeserializeCaveat(serialized []byte, parameterTypes map[string]types.VariableType) (*CompiledCaveat, error) { + env, err := EnvForVariables(parameterTypes) + if err != nil { + return nil, err + } + + return DeserializeCaveatWithEnviroment(env, serialized) +} + +// DeserializeCaveatWithTypeSet deserializes a byte-serialized caveat back into a CompiledCaveat. +func DeserializeCaveatWithTypeSet(ts *types.TypeSet, serialized []byte, parameterTypes map[string]types.VariableType) (*CompiledCaveat, error) { + env, err := EnvForVariablesWithTypeSet(ts, parameterTypes) + if err != nil { + return nil, err + } + + return DeserializeCaveatWithEnviroment(env, serialized) +} + +// DeserializeCaveatWithEnviroment deserializes a byte-serialized caveat back into a CompiledCaveat, +// using the provided environment. It is the responsibility of the caller to ensure that the environment +// has the parameters defined as variables. +func DeserializeCaveatWithEnviroment(env *Environment, serialized []byte) (*CompiledCaveat, error) { + if len(serialized) == 0 { + return nil, fmt.Errorf("given empty serialized") + } + + caveat := &impl.DecodedCaveat{} + err := caveat.UnmarshalVT(serialized) + if err != nil { + return nil, err + } + + celEnv, err := env.asCelEnvironment() + if err != nil { + return nil, err + } + + ast := cel.CheckedExprToAst(caveat.GetCel()) + return &CompiledCaveat{celEnv, ast, caveat.Name}, nil +} diff --git a/vendor/github.com/authzed/spicedb/pkg/caveats/context.go b/vendor/github.com/authzed/spicedb/pkg/caveats/context.go new file mode 100644 index 0000000..5580eb4 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/caveats/context.go @@ -0,0 +1,45 @@ +package caveats + +import ( + "maps" + "time" + + "google.golang.org/protobuf/types/known/structpb" + + "github.com/authzed/spicedb/pkg/caveats/types" +) + +// ConvertContextToStruct converts the given context values into a context struct. +func ConvertContextToStruct(contextValues map[string]any) (*structpb.Struct, error) { + cloned := maps.Clone(contextValues) + cloned = convertCustomValues(cloned).(map[string]any) + return structpb.NewStruct(cloned) +} + +func convertCustomValues(value any) any { + switch v := value.(type) { + case map[string]any: + for key, value := range v { + v[key] = convertCustomValues(value) + } + return v + + case []any: + for index, current := range v { + v[index] = convertCustomValues(current) + } + return v + + case time.Time: + return v.Format(time.RFC3339) + + case time.Duration: + return v.String() + + case types.CustomType: + return v.SerializedString() + + default: + return v + } +} diff --git a/vendor/github.com/authzed/spicedb/pkg/caveats/context_hash.go b/vendor/github.com/authzed/spicedb/pkg/caveats/context_hash.go new file mode 100644 index 0000000..658b492 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/caveats/context_hash.go @@ -0,0 +1,90 @@ +package caveats + +import ( + "bytes" + "fmt" + "net/url" + "sort" + "strconv" + + "golang.org/x/exp/maps" + "google.golang.org/protobuf/types/known/structpb" +) + +// HasherInterface is an interface for writing context to be hashed. +type HasherInterface interface { + WriteString(value string) +} + +// StableContextStringForHashing returns a stable string version of the context, for use in hashing. +func StableContextStringForHashing(context *structpb.Struct) string { + b := bytes.NewBufferString("") + hc := HashableContext{context} + hc.AppendToHash(wrappedBuffer{b}) + return b.String() +} + +type wrappedBuffer struct{ *bytes.Buffer } + +func (wb wrappedBuffer) WriteString(value string) { + wb.Buffer.WriteString(value) +} + +// HashableContext is a wrapper around a context Struct that provides hashing. +type HashableContext struct{ *structpb.Struct } + +func (hc HashableContext) AppendToHash(hasher HasherInterface) { + // NOTE: the order of keys in the Struct and its resulting JSON output are *unspecified*, + // as the go runtime randomizes iterator order to ensure that if relied upon, a sort is used. + // Therefore, we sort the keys here before adding them to the hash. + if hc.Struct == nil { + return + } + + fields := hc.Struct.Fields + keys := maps.Keys(fields) + sort.Strings(keys) + + for _, key := range keys { + hasher.WriteString("`") + hasher.WriteString(key) + hasher.WriteString("`:") + hashableStructValue{fields[key]}.AppendToHash(hasher) + hasher.WriteString(",\n") + } +} + +type hashableStructValue struct{ *structpb.Value } + +func (hsv hashableStructValue) AppendToHash(hasher HasherInterface) { + switch t := hsv.Kind.(type) { + case *structpb.Value_BoolValue: + hasher.WriteString(strconv.FormatBool(t.BoolValue)) + + case *structpb.Value_ListValue: + for _, value := range t.ListValue.Values { + hashableStructValue{value}.AppendToHash(hasher) + hasher.WriteString(",") + } + + case *structpb.Value_NullValue: + hasher.WriteString("null") + + case *structpb.Value_NumberValue: + // AFAICT, this is how Sprintf-style formats float64s + hasher.WriteString(strconv.FormatFloat(t.NumberValue, 'f', 6, 64)) + + case *structpb.Value_StringValue: + // NOTE: we escape the string value here to prevent accidental overlap in keys for string + // values that may themselves contain backticks. + hasher.WriteString("`" + url.PathEscape(t.StringValue) + "`") + + case *structpb.Value_StructValue: + hasher.WriteString("{") + HashableContext{t.StructValue}.AppendToHash(hasher) + hasher.WriteString("}") + + default: + panic(fmt.Sprintf("unknown struct value type: %T", t)) + } +} diff --git a/vendor/github.com/authzed/spicedb/pkg/caveats/doc.go b/vendor/github.com/authzed/spicedb/pkg/caveats/doc.go new file mode 100644 index 0000000..cb1d885 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/caveats/doc.go @@ -0,0 +1,2 @@ +// Package caveats contains code to compile caveats and to evaluate a caveat with a given context. +package caveats diff --git a/vendor/github.com/authzed/spicedb/pkg/caveats/env.go b/vendor/github.com/authzed/spicedb/pkg/caveats/env.go new file mode 100644 index 0000000..7e33183 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/caveats/env.go @@ -0,0 +1,111 @@ +package caveats + +import ( + "fmt" + + "github.com/authzed/cel-go/cel" + + "github.com/authzed/spicedb/pkg/caveats/types" + core "github.com/authzed/spicedb/pkg/proto/core/v1" +) + +// Environment defines the evaluation environment for a caveat. +type Environment struct { + ts *types.TypeSet + variables map[string]types.VariableType +} + +// NewEnvironment creates and returns a new environment for compiling a caveat. +func NewEnvironment() *Environment { + return &Environment{ + ts: types.Default.TypeSet, + variables: map[string]types.VariableType{}, + } +} + +// NewEnvironmentWithTypeSet creates and returns a new environment for compiling a caveat +// with the given TypeSet. +func NewEnvironmentWithTypeSet(ts *types.TypeSet) *Environment { + return &Environment{ + ts: ts, + variables: map[string]types.VariableType{}, + } +} + +// EnvForVariables returns a new environment constructed for the given variables. +func EnvForVariables(vars map[string]types.VariableType) (*Environment, error) { + return EnvForVariablesWithTypeSet(types.Default.TypeSet, vars) +} + +// EnvForVariablesWithTypeSet returns a new environment constructed for the given variables. +func EnvForVariablesWithTypeSet(ts *types.TypeSet, vars map[string]types.VariableType) (*Environment, error) { + e := NewEnvironmentWithTypeSet(ts) + for varName, varType := range vars { + err := e.AddVariable(varName, varType) + if err != nil { + return nil, err + } + } + return e, nil +} + +// MustEnvForVariables returns a new environment constructed for the given variables +// or panics. +func MustEnvForVariables(vars map[string]types.VariableType) *Environment { + env, err := EnvForVariables(vars) + if err != nil { + panic(err) + } + return env +} + +// AddVariable adds a variable with the given type to the environment. +func (e *Environment) AddVariable(name string, varType types.VariableType) error { + if _, ok := e.variables[name]; ok { + return fmt.Errorf("variable `%s` already exists", name) + } + + e.variables[name] = varType + return nil +} + +// EncodedParametersTypes returns the map of encoded parameters for the environment. +func (e *Environment) EncodedParametersTypes() map[string]*core.CaveatTypeReference { + return types.EncodeParameterTypes(e.variables) +} + +// asCelEnvironment converts the exported Environment into an internal CEL environment. +func (e *Environment) asCelEnvironment(extraOptions ...cel.EnvOption) (*cel.Env, error) { + tsOptions, err := e.ts.EnvOptions() + if err != nil { + return nil, err + } + + opts := make([]cel.EnvOption, 0, len(extraOptions)+len(e.variables)+len(tsOptions)+2) + opts = append(opts, extraOptions...) + opts = append(opts, tsOptions...) + + // Set options. + // DefaultUTCTimeZone: ensure all timestamps are evaluated at UTC + opts = append(opts, cel.DefaultUTCTimeZone(true)) + + // OptionalTypes: enable optional typing syntax, e.g. `sometype?.foo` + // See: https://github.com/google/cel-spec/wiki/proposal-246 + opts = append(opts, cel.OptionalTypes(cel.OptionalTypesVersion(0))) + + // EnableMacroCallTracking: enables tracking of call macros so when we call AstToString we get + // back out the expected expressions. + // See: https://github.com/authzed/cel-go/issues/474 + opts = append(opts, cel.EnableMacroCallTracking()) + + // ParserExpressionSizeLimit: disable the size limit for codepoints in expressions. + // This has to be disabled due to us padding out the whitespace in expression parsing based on + // schema size. We instead do our own expression size check in the Compile method. + // TODO(jschorr): Remove this once the whitespace hack is removed. + opts = append(opts, cel.ParserExpressionSizeLimit(-1)) + + for name, varType := range e.variables { + opts = append(opts, cel.Variable(name, varType.CelType())) + } + return cel.NewEnv(opts...) +} diff --git a/vendor/github.com/authzed/spicedb/pkg/caveats/errors.go b/vendor/github.com/authzed/spicedb/pkg/caveats/errors.go new file mode 100644 index 0000000..9c49609 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/caveats/errors.go @@ -0,0 +1,76 @@ +package caveats + +import ( + "strconv" + + "github.com/authzed/cel-go/cel" + "github.com/rs/zerolog" +) + +// EvaluationError is an error in evaluation of a caveat expression. +type EvaluationError struct { + error +} + +// MarshalZerologObject implements zerolog.LogObjectMarshaler +func (err EvaluationError) MarshalZerologObject(e *zerolog.Event) { + e.Err(err.error) +} + +// DetailsMetadata returns the metadata for details for this error. +func (err EvaluationError) DetailsMetadata() map[string]string { + return map[string]string{} +} + +// ParameterConversionError is an error in type conversion of a supplied parameter. +type ParameterConversionError struct { + error + parameterName string +} + +// MarshalZerologObject implements zerolog.LogObjectMarshaler +func (err ParameterConversionError) MarshalZerologObject(e *zerolog.Event) { + e.Err(err.error).Str("parameterName", err.parameterName) +} + +// DetailsMetadata returns the metadata for details for this error. +func (err ParameterConversionError) DetailsMetadata() map[string]string { + return map[string]string{ + "parameter_name": err.parameterName, + } +} + +// ParameterName is the name of the parameter. +func (err ParameterConversionError) ParameterName() string { + return err.parameterName +} + +// MultipleCompilationError is a wrapping error for containing compilation errors for a Caveat. +type MultipleCompilationError struct { + error + + issues *cel.Issues +} + +// LineNumber is the 0-indexed line number for compilation error. +func (err MultipleCompilationError) LineNumber() int { + return err.issues.Errors()[0].Location.Line() - 1 +} + +// ColumnPositionis the 0-indexed column position for compilation error. +func (err MultipleCompilationError) ColumnPosition() int { + return err.issues.Errors()[0].Location.Column() - 1 +} + +// MarshalZerologObject implements zerolog.LogObjectMarshaler +func (err MultipleCompilationError) MarshalZerologObject(e *zerolog.Event) { + e.Err(err.error).Int("lineNumber", err.LineNumber()).Int("columnPosition", err.ColumnPosition()) +} + +// DetailsMetadata returns the metadata for details for this error. +func (err MultipleCompilationError) DetailsMetadata() map[string]string { + return map[string]string{ + "line_number": strconv.Itoa(err.LineNumber()), + "column_position": strconv.Itoa(err.ColumnPosition()), + } +} diff --git a/vendor/github.com/authzed/spicedb/pkg/caveats/eval.go b/vendor/github.com/authzed/spicedb/pkg/caveats/eval.go new file mode 100644 index 0000000..cef9a4b --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/caveats/eval.go @@ -0,0 +1,156 @@ +package caveats + +import ( + "fmt" + + "google.golang.org/protobuf/types/known/structpb" + + "github.com/authzed/cel-go/cel" + "github.com/authzed/cel-go/common/types" + "github.com/authzed/cel-go/common/types/ref" +) + +// EvaluationConfig is configuration given to an EvaluateCaveatWithConfig call. +type EvaluationConfig struct { + // MaxCost is the max cost of the caveat to be executed. + MaxCost uint64 +} + +// CaveatResult holds the result of evaluating a caveat. +type CaveatResult struct { + val ref.Val + details *cel.EvalDetails + parentCaveat *CompiledCaveat + contextValues map[string]any + missingVarNames []string + isPartial bool +} + +// Value returns the computed value for the result. +func (cr CaveatResult) Value() bool { + if cr.isPartial { + return false + } + + return cr.val.Value().(bool) +} + +// IsPartial returns true if the caveat was only partially evaluated. +func (cr CaveatResult) IsPartial() bool { + return cr.isPartial +} + +// PartialValue returns the partially evaluated caveat. Only applies if IsPartial is true. +func (cr CaveatResult) PartialValue() (*CompiledCaveat, error) { + if !cr.isPartial { + return nil, fmt.Errorf("result is fully evaluated") + } + + ast, err := cr.parentCaveat.celEnv.ResidualAst(cr.parentCaveat.ast, cr.details) + if err != nil { + return nil, err + } + + return &CompiledCaveat{cr.parentCaveat.celEnv, ast, cr.parentCaveat.name}, nil +} + +// ContextValues returns the context values used when computing this result. +func (cr CaveatResult) ContextValues() map[string]any { + return cr.contextValues +} + +// ContextStruct returns the context values used when computing this result as +// a structpb. +func (cr CaveatResult) ContextStruct() (*structpb.Struct, error) { + return ConvertContextToStruct(cr.contextValues) +} + +// ExpressionString returns the human-readable expression string for the evaluated expression. +func (cr CaveatResult) ExpressionString() (string, error) { + return cr.parentCaveat.ExprString() +} + +// ParentCaveat returns the caveat that was evaluated to produce this result. +func (cr CaveatResult) ParentCaveat() *CompiledCaveat { + return cr.parentCaveat +} + +// MissingVarNames returns the name(s) of the missing variables. +func (cr CaveatResult) MissingVarNames() ([]string, error) { + if !cr.isPartial { + return nil, fmt.Errorf("result is fully evaluated") + } + + return cr.missingVarNames, nil +} + +// EvaluateCaveat evaluates the compiled caveat with the specified values, and returns +// the result or an error. +func EvaluateCaveat(caveat *CompiledCaveat, contextValues map[string]any) (*CaveatResult, error) { + return EvaluateCaveatWithConfig(caveat, contextValues, nil) +} + +// EvaluateCaveatWithConfig evaluates the compiled caveat with the specified values, and returns +// the result or an error. +func EvaluateCaveatWithConfig(caveat *CompiledCaveat, contextValues map[string]any, config *EvaluationConfig) (*CaveatResult, error) { + env := caveat.celEnv + celopts := make([]cel.ProgramOption, 0, 3) + + // Option: enables partial evaluation and state tracking for partial evaluation. + celopts = append(celopts, cel.EvalOptions(cel.OptTrackState)) + celopts = append(celopts, cel.EvalOptions(cel.OptPartialEval)) + + // Option: Cost limit on the evaluation. + if config != nil && config.MaxCost > 0 { + celopts = append(celopts, cel.CostLimit(config.MaxCost)) + } + + prg, err := env.Program(caveat.ast, celopts...) + if err != nil { + return nil, err + } + + // Mark any unspecified variables as unknown, to ensure that partial application + // will result in producing a type of Unknown. + activation, err := env.PartialVars(contextValues) + if err != nil { + return nil, err + } + + val, details, err := prg.Eval(activation) + if err != nil { + return nil, EvaluationError{err} + } + + // If the value produced has Unknown type, then it means required context was missing. + if types.IsUnknown(val) { + unknownVal := val.(*types.Unknown) + missingVarNames := make([]string, 0, len(unknownVal.IDs())) + for _, id := range unknownVal.IDs() { + trails, ok := unknownVal.GetAttributeTrails(id) + if ok { + for _, attributeTrail := range trails { + missingVarNames = append(missingVarNames, attributeTrail.String()) + } + } + } + + return &CaveatResult{ + val: val, + details: details, + parentCaveat: caveat, + contextValues: contextValues, + missingVarNames: missingVarNames, + isPartial: true, + }, nil + } + + return &CaveatResult{ + val: val, + details: details, + parentCaveat: caveat, + contextValues: contextValues, + missingVarNames: nil, + isPartial: false, + }, nil +} diff --git a/vendor/github.com/authzed/spicedb/pkg/caveats/parameters.go b/vendor/github.com/authzed/spicedb/pkg/caveats/parameters.go new file mode 100644 index 0000000..cd3ef67 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/caveats/parameters.go @@ -0,0 +1,82 @@ +package caveats + +import ( + "fmt" + "strings" + + "github.com/authzed/spicedb/pkg/caveats/types" + core "github.com/authzed/spicedb/pkg/proto/core/v1" +) + +// UnknownParameterOption is the option to ConvertContextToParameters around handling +// of unknown parameters. +type UnknownParameterOption int + +const ( + // SkipUnknownParameters indicates that unknown parameters should be skipped in conversion. + SkipUnknownParameters UnknownParameterOption = 0 + + // ErrorForUnknownParameters indicates that unknown parameters should return an error. + ErrorForUnknownParameters UnknownParameterOption = 1 +) + +// ConvertContextToParameters converts the given context into parameters of the types specified. +// Returns a type error if type conversion failed. +func ConvertContextToParameters( + ts *types.TypeSet, + contextMap map[string]any, + parameterTypes map[string]*core.CaveatTypeReference, + unknownParametersOption UnknownParameterOption, +) (map[string]any, error) { + if len(contextMap) == 0 { + return nil, nil + } + + if len(parameterTypes) == 0 { + return nil, fmt.Errorf("missing parameters for caveat") + } + + converted := make(map[string]any, len(contextMap)) + + for key, value := range contextMap { + paramType, ok := parameterTypes[key] + if !ok { + if unknownParametersOption == ErrorForUnknownParameters { + return nil, fmt.Errorf("unknown parameter `%s`", key) + } + + continue + } + + varType, err := types.DecodeParameterType(ts, paramType) + if err != nil { + return nil, err + } + + convertedParam, err := varType.ConvertValue(value) + if err != nil { + return nil, ParameterConversionError{fmt.Errorf("could not convert context parameter `%s`: %w", key, err), key} + } + + converted[key] = convertedParam + } + return converted, nil +} + +// ParameterTypeString returns the string form of the type reference. +func ParameterTypeString(typeRef *core.CaveatTypeReference) string { + var sb strings.Builder + sb.WriteString(typeRef.TypeName) + if len(typeRef.ChildTypes) > 0 { + sb.WriteString("<") + for idx, childType := range typeRef.ChildTypes { + if idx > 0 { + sb.WriteString(", ") + } + sb.WriteString(ParameterTypeString(childType)) + } + sb.WriteString(">") + } + + return sb.String() +} diff --git a/vendor/github.com/authzed/spicedb/pkg/caveats/replacer/inlining.go b/vendor/github.com/authzed/spicedb/pkg/caveats/replacer/inlining.go new file mode 100644 index 0000000..33d8b77 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/caveats/replacer/inlining.go @@ -0,0 +1,171 @@ +// Modified version of https://github.com/authzed/cel-go/blob/b707d132d96bb5450df92d138860126bf03f805f/cel/inlining.go +// which changes it so variable replacement is always done without cel.bind calls. See +// the "CHANGED" below. +// +// Original Copyright notice: +// Copyright 2023 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. + +package replacer + +import ( + "github.com/authzed/cel-go/cel" + "github.com/authzed/cel-go/common/ast" + "github.com/authzed/cel-go/common/containers" + "github.com/authzed/cel-go/common/operators" + "github.com/authzed/cel-go/common/overloads" + "github.com/authzed/cel-go/common/types" + "github.com/authzed/cel-go/common/types/traits" +) + +// InlineVariable holds a variable name to be matched and an AST representing +// the expression graph which should be used to replace it. +type InlineVariable struct { + name string + alias string + def *ast.AST +} + +// Name returns the qualified variable or field selection to replace. +func (v *InlineVariable) Name() string { + return v.name +} + +// Alias returns the alias to use when performing cel.bind() calls during inlining. +func (v *InlineVariable) Alias() string { + return v.alias +} + +// Expr returns the inlined expression value. +func (v *InlineVariable) Expr() ast.Expr { + return v.def.Expr() +} + +// Type indicates the inlined expression type. +func (v *InlineVariable) Type() *cel.Type { + return v.def.GetType(v.def.Expr().ID()) +} + +// newInlineVariable declares a variable name to be replaced by a checked expression. +func newInlineVariable(name string, definition *cel.Ast) *InlineVariable { + return newInlineVariableWithAlias(name, name, definition) +} + +// newInlineVariableWithAlias declares a variable name to be replaced by a checked expression. +// If the variable occurs more than once, the provided alias will be used to replace the expressions +// where the variable name occurs. +func newInlineVariableWithAlias(name, alias string, definition *cel.Ast) *InlineVariable { + return &InlineVariable{name: name, alias: alias, def: definition.NativeRep()} +} + +// newModifiedInliningOptimizer creates and optimizer which replaces variables with expression definitions. +func newModifiedInliningOptimizer(inlineVars ...*InlineVariable) cel.ASTOptimizer { + return &inliningOptimizer{variables: inlineVars} +} + +type inliningOptimizer struct { + variables []*InlineVariable +} + +func (opt *inliningOptimizer) Optimize(ctx *cel.OptimizerContext, a *ast.AST) *ast.AST { + root := ast.NavigateAST(a) + for _, inlineVar := range opt.variables { + matches := ast.MatchDescendants(root, opt.matchVariable(inlineVar.Name())) + // Skip cases where the variable isn't in the expression graph + if len(matches) == 0 { + continue + } + + // CHANGED: *ALWAYS* do a direct replacement of the expression sub-graph. + for _, match := range matches { + // Copy the inlined AST expr and source info. + copyExpr := ctx.CopyASTAndMetadata(inlineVar.def) + opt.inlineExpr(ctx, match, copyExpr, inlineVar.Type()) + } + } + return a +} + +// inlineExpr replaces the current expression with the inlined one, unless the location of the inlining +// happens within a presence test, e.g. has(a.b.c) -> inline alpha for a.b.c in which case an attempt is +// made to determine whether the inlined value can be presence or existence tested. +func (opt *inliningOptimizer) inlineExpr(ctx *cel.OptimizerContext, prev ast.NavigableExpr, inlined ast.Expr, inlinedType *cel.Type) { + switch prev.Kind() { + case ast.SelectKind: + sel := prev.AsSelect() + if !sel.IsTestOnly() { + ctx.UpdateExpr(prev, inlined) + return + } + opt.rewritePresenceExpr(ctx, prev, inlined, inlinedType) + default: + ctx.UpdateExpr(prev, inlined) + } +} + +// rewritePresenceExpr converts the inlined expression, when it occurs within a has() macro, to type-safe +// expression appropriate for the inlined type, if possible. +// +// If the rewrite is not possible an error is reported at the inline expression site. +func (opt *inliningOptimizer) rewritePresenceExpr(ctx *cel.OptimizerContext, prev, inlined ast.Expr, inlinedType *cel.Type) { + // If the input inlined expression is not a select expression it won't work with the has() + // macro. Attempt to rewrite the presence test in terms of the typed input, otherwise error. + if inlined.Kind() == ast.SelectKind { + presenceTest, hasMacro := ctx.NewHasMacro(prev.ID(), inlined) + ctx.UpdateExpr(prev, presenceTest) + ctx.SetMacroCall(prev.ID(), hasMacro) + return + } + + ctx.ClearMacroCall(prev.ID()) + if inlinedType.IsAssignableType(cel.NullType) { + ctx.UpdateExpr(prev, + ctx.NewCall(operators.NotEquals, + inlined, + ctx.NewLiteral(types.NullValue), + )) + return + } + if inlinedType.HasTrait(traits.SizerType) { + ctx.UpdateExpr(prev, + ctx.NewCall(operators.NotEquals, + ctx.NewMemberCall(overloads.Size, inlined), + ctx.NewLiteral(types.IntZero), + )) + return + } + ctx.ReportErrorAtID(prev.ID(), "unable to inline expression type %v into presence test", inlinedType) +} + +// matchVariable matches simple identifiers, select expressions, and presence test expressions +// which match the (potentially) qualified variable name provided as input. +// +// Note, this function does not support inlining against select expressions which includes optional +// field selection. This may be a future refinement. +func (opt *inliningOptimizer) matchVariable(varName string) ast.ExprMatcher { + return func(e ast.NavigableExpr) bool { + if e.Kind() == ast.IdentKind && e.AsIdent() == varName { + return true + } + if e.Kind() == ast.SelectKind { + sel := e.AsSelect() + // While the `ToQualifiedName` call could take the select directly, this + // would skip presence tests from possible matches, which we would like + // to include. + qualName, found := containers.ToQualifiedName(sel.Operand()) + return found && qualName+"."+sel.FieldName() == varName + } + return false + } +} diff --git a/vendor/github.com/authzed/spicedb/pkg/caveats/replacer/replacer.go b/vendor/github.com/authzed/spicedb/pkg/caveats/replacer/replacer.go new file mode 100644 index 0000000..d57f40a --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/caveats/replacer/replacer.go @@ -0,0 +1,25 @@ +package replacer + +import ( + "fmt" + + "github.com/authzed/cel-go/cel" +) + +func ReplaceVariable(e *cel.Env, existingAst *cel.Ast, oldVarName string, newVarName string) (*cel.Ast, error) { + newExpr, iss := e.Compile(newVarName) + if iss.Err() != nil { + return nil, fmt.Errorf("failed to compile new variable name: %w", iss.Err()) + } + + inlinedVars := []*InlineVariable{} + inlinedVars = append(inlinedVars, newInlineVariable(oldVarName, newExpr)) + + opt := cel.NewStaticOptimizer(newModifiedInliningOptimizer(inlinedVars...)) + optimized, iss := opt.Optimize(e, existingAst) + if iss.Err() != nil { + return nil, fmt.Errorf("failed to optimize: %w", iss.Err()) + } + + return optimized, nil +} diff --git a/vendor/github.com/authzed/spicedb/pkg/caveats/source.go b/vendor/github.com/authzed/spicedb/pkg/caveats/source.go new file mode 100644 index 0000000..8550f03 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/caveats/source.go @@ -0,0 +1,19 @@ +package caveats + +import ( + "github.com/authzed/cel-go/common" +) + +// SourcePosition is an incoming source position. +type SourcePosition interface { + // LineAndColumn returns the 0-indexed line number and column position in the source file. + LineAndColumn() (int, int, error) + + // RunePosition returns the 0-indexed rune position in the source file. + RunePosition() (int, error) +} + +// NewSource creates a new source for compilation into a caveat. +func NewSource(expressionString string, name string) (common.Source, error) { + return common.NewStringSource(expressionString, name), nil +} diff --git a/vendor/github.com/authzed/spicedb/pkg/caveats/structure.go b/vendor/github.com/authzed/spicedb/pkg/caveats/structure.go new file mode 100644 index 0000000..d27602a --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/caveats/structure.go @@ -0,0 +1,56 @@ +package caveats + +import ( + "fmt" + + exprpb "google.golang.org/genproto/googleapis/api/expr/v1alpha1" + + "github.com/authzed/spicedb/pkg/genutil/mapz" +) + +// referencedParameters traverses the expression given and finds all parameters which are referenced +// in the expression for the purpose of usage tracking. +func referencedParameters(definedParameters *mapz.Set[string], expr *exprpb.Expr, referencedParams *mapz.Set[string]) { + if expr == nil { + return + } + + switch t := expr.ExprKind.(type) { + case *exprpb.Expr_ConstExpr: + // nothing to do + + case *exprpb.Expr_IdentExpr: + if definedParameters.Has(t.IdentExpr.Name) { + referencedParams.Add(t.IdentExpr.Name) + } + + case *exprpb.Expr_SelectExpr: + referencedParameters(definedParameters, t.SelectExpr.Operand, referencedParams) + + case *exprpb.Expr_CallExpr: + referencedParameters(definedParameters, t.CallExpr.Target, referencedParams) + for _, arg := range t.CallExpr.Args { + referencedParameters(definedParameters, arg, referencedParams) + } + + case *exprpb.Expr_ListExpr: + for _, elem := range t.ListExpr.Elements { + referencedParameters(definedParameters, elem, referencedParams) + } + + case *exprpb.Expr_StructExpr: + for _, entry := range t.StructExpr.Entries { + referencedParameters(definedParameters, entry.Value, referencedParams) + } + + case *exprpb.Expr_ComprehensionExpr: + referencedParameters(definedParameters, t.ComprehensionExpr.AccuInit, referencedParams) + referencedParameters(definedParameters, t.ComprehensionExpr.IterRange, referencedParams) + referencedParameters(definedParameters, t.ComprehensionExpr.LoopCondition, referencedParams) + referencedParameters(definedParameters, t.ComprehensionExpr.LoopStep, referencedParams) + referencedParameters(definedParameters, t.ComprehensionExpr.Result, referencedParams) + + default: + panic(fmt.Sprintf("unknown CEL expression kind: %T", t)) + } +} diff --git a/vendor/github.com/authzed/spicedb/pkg/caveats/types/basic.go b/vendor/github.com/authzed/spicedb/pkg/caveats/types/basic.go new file mode 100644 index 0000000..688fc34 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/caveats/types/basic.go @@ -0,0 +1,262 @@ +package types + +import ( + "encoding/base64" + "fmt" + "math/big" + "time" + + "github.com/authzed/cel-go/cel" + "github.com/authzed/cel-go/common/types" + "github.com/authzed/cel-go/common/types/ref" + + "github.com/authzed/spicedb/pkg/spiceerrors" +) + +// RegisterBasicTypes registers the basic types with the given keyword, CEL type, and converter. +func RegisterBasicTypes(sts *StandardTypeSet) error { + ts := sts.TypeSet + + // Register "any" type + anyType, err := RegisterBasicType(ts, "any", cel.DynType, func(value any) (any, error) { return value, nil }) + if err != nil { + return err + } + sts.AnyType = anyType + + // Register "bool" type + boolType, err := RegisterBasicType(ts, "bool", cel.BoolType, requireType[bool]) + if err != nil { + return err + } + sts.BooleanType = boolType + + // Register "string" type + stringType, err := RegisterBasicType(ts, "string", cel.StringType, requireType[string]) + if err != nil { + return err + } + sts.StringType = stringType + + // Register "int" type + intType, err := RegisterBasicType(ts, "int", cel.IntType, convertNumericType[int64]) + if err != nil { + return err + } + sts.IntType = intType + + // Register "uint" type + uintType, err := RegisterBasicType(ts, "uint", cel.IntType, convertNumericType[uint64]) + if err != nil { + return err + } + sts.UIntType = uintType + + // Register "double" type + doubleType, err := RegisterBasicType(ts, "double", cel.DoubleType, convertNumericType[float64]) + if err != nil { + return err + } + sts.DoubleType = doubleType + + // Register "bytes" type + bytesType, err := RegisterBasicType(ts, "bytes", cel.BytesType, func(value any) (any, error) { + vle, ok := value.(string) + if !ok { + return nil, fmt.Errorf("bytes requires a base64 unicode string, found: %T `%v`", value, value) + } + + decoded, err := base64.StdEncoding.DecodeString(vle) + if err != nil { + return nil, fmt.Errorf("bytes requires a base64 encoded string: %w", err) + } + + return decoded, nil + }) + if err != nil { + return err + } + sts.BytesType = bytesType + + // Register "duration" type + durationType, err := RegisterBasicType(ts, "duration", cel.DurationType, func(value any) (any, error) { + vle, ok := value.(string) + if !ok { + return nil, fmt.Errorf("durations requires a duration string, found: %T", value) + } + + d, err := time.ParseDuration(vle) + if err != nil { + return nil, fmt.Errorf("could not parse duration string `%s`: %w", vle, err) + } + + return d, nil + }) + if err != nil { + return err + } + sts.DurationType = durationType + + // Register "timestamp" type + timestampType, err := RegisterBasicType(ts, "timestamp", cel.TimestampType, func(value any) (any, error) { + vle, ok := value.(string) + if !ok { + return nil, fmt.Errorf("timestamps requires a RFC 3339 formatted timestamp string, found: %T `%v`", value, value) + } + + d, err := time.Parse(time.RFC3339, vle) + if err != nil { + return nil, fmt.Errorf("could not parse RFC 3339 formatted timestamp string `%s`: %w", vle, err) + } + + return d, nil + }) + if err != nil { + return err + } + sts.TimestampType = timestampType + + listTypeBuilder, err := RegisterGenericType(ts, "list", 1, + func(childTypes []VariableType) VariableType { + return VariableType{ + localName: "list", + celType: cel.ListType(childTypes[0].celType), + childTypes: childTypes, + converter: func(value any) (any, error) { + vle, ok := value.([]any) + if !ok { + return nil, fmt.Errorf("list requires a list, found: %T", value) + } + + converted := make([]any, 0, len(vle)) + for index, item := range vle { + convertedItem, err := childTypes[0].ConvertValue(item) + if err != nil { + return nil, fmt.Errorf("found an invalid value for item at index %d: %w", index, err) + } + converted = append(converted, convertedItem) + } + + return converted, nil + }, + } + }) + if err != nil { + return err + } + sts.listTypeBuilder = listTypeBuilder + + mapTypeBuilder, err := RegisterGenericType(ts, "map", 1, + func(childTypes []VariableType) VariableType { + return VariableType{ + localName: "map", + celType: cel.MapType(cel.StringType, childTypes[0].celType), + childTypes: childTypes, + converter: func(value any) (any, error) { + vle, ok := value.(map[string]any) + if !ok { + return nil, fmt.Errorf("map requires a map, found: %T", value) + } + + converted := make(map[string]any, len(vle)) + for key, item := range vle { + convertedItem, err := childTypes[0].ConvertValue(item) + if err != nil { + return nil, fmt.Errorf("found an invalid value for key `%s`: %w", key, err) + } + + converted[key] = convertedItem + } + + return converted, nil + }, + } + }, + ) + if err != nil { + return err + } + sts.mapTypeBuilder = mapTypeBuilder + + if err := RegisterMethodOnDefinedType(ts, cel.MapType(cel.StringType, cel.DynType), + "isSubtreeOf", + []*cel.Type{cel.MapType(cel.StringType, cel.DynType)}, + cel.BoolType, + func(arg ...ref.Val) ref.Val { + map0 := arg[0].Value().(map[string]any) + map1 := arg[1].Value().(map[string]any) + return types.Bool(subtree(map0, map1)) + }, + ); err != nil { + return err + } + + ipAddressType, err := RegisterIPAddressType(ts) + if err != nil { + return err + } + sts.IPAddressType = ipAddressType + + return nil +} + +func requireType[T any](value any) (any, error) { + vle, ok := value.(T) + if !ok { + return nil, fmt.Errorf("a %T value is required, but found %T `%v`", *new(T), value, value) + } + return vle, nil +} + +func convertNumericType[T int64 | uint64 | float64](value any) (any, error) { + directValue, ok := value.(T) + if ok { + return directValue, nil + } + + floatValue, ok := value.(float64) + bigFloat := big.NewFloat(floatValue) + if !ok { + stringValue, ok := value.(string) + if !ok { + return nil, fmt.Errorf("a %T value is required, but found %T `%v`", *new(T), value, value) + } + + f, _, err := big.ParseFloat(stringValue, 10, 64, 0) + if err != nil { + return nil, fmt.Errorf("a %T value is required, but found invalid string value `%v`", *new(T), value) + } + + bigFloat = f + } + + // Convert the float to the int or uint if necessary. + n := *new(T) + switch any(n).(type) { + case int64: + if !bigFloat.IsInt() { + return nil, fmt.Errorf("a int value is required, but found numeric value `%s`", bigFloat.String()) + } + + numericValue, _ := bigFloat.Int64() + return numericValue, nil + + case uint64: + if !bigFloat.IsInt() { + return nil, fmt.Errorf("a uint value is required, but found numeric value `%s`", bigFloat.String()) + } + + numericValue, _ := bigFloat.Int64() + if numericValue < 0 { + return nil, fmt.Errorf("a uint value is required, but found int64 value `%s`", bigFloat.String()) + } + return uint64(numericValue), nil + + case float64: + numericValue, _ := bigFloat.Float64() + return numericValue, nil + + default: + return nil, spiceerrors.MustBugf("unsupported numeric type in caveat number type conversion: %T", n) + } +} diff --git a/vendor/github.com/authzed/spicedb/pkg/caveats/types/custom.go b/vendor/github.com/authzed/spicedb/pkg/caveats/types/custom.go new file mode 100644 index 0000000..08c18f1 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/caveats/types/custom.go @@ -0,0 +1,8 @@ +package types + +// CustomType is the interface for custom-defined types. +type CustomType interface { + // SerializedString returns the serialized string form of the data within + // this instance of the type. + SerializedString() string +} diff --git a/vendor/github.com/authzed/spicedb/pkg/caveats/types/encoding.go b/vendor/github.com/authzed/spicedb/pkg/caveats/types/encoding.go new file mode 100644 index 0000000..5d088c1 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/caveats/types/encoding.go @@ -0,0 +1,72 @@ +package types + +import ( + "fmt" + + core "github.com/authzed/spicedb/pkg/proto/core/v1" +) + +// EncodeParameterTypes converts the map of internal caveat types into a map of types for storing +// the caveat in the core. +func EncodeParameterTypes(parametersAndTypes map[string]VariableType) map[string]*core.CaveatTypeReference { + encoded := make(map[string]*core.CaveatTypeReference, len(parametersAndTypes)) + for name, varType := range parametersAndTypes { + encoded[name] = EncodeParameterType(varType) + } + return encoded +} + +// EncodeParameterType converts an internal caveat type into a storable core type. +func EncodeParameterType(varType VariableType) *core.CaveatTypeReference { + childTypes := make([]*core.CaveatTypeReference, 0, len(varType.childTypes)) + for _, childType := range varType.childTypes { + childTypes = append(childTypes, EncodeParameterType(childType)) + } + + return &core.CaveatTypeReference{ + TypeName: varType.localName, + ChildTypes: childTypes, + } +} + +// DecodeParameterType decodes the core caveat parameter type into an internal caveat type. +func DecodeParameterType(ts *TypeSet, parameterType *core.CaveatTypeReference) (*VariableType, error) { + typeDef, ok := ts.definitions[parameterType.TypeName] + if !ok { + return nil, fmt.Errorf("unknown caveat parameter type `%s`", parameterType.TypeName) + } + + if len(parameterType.ChildTypes) != int(typeDef.childTypeCount) { + return nil, fmt.Errorf( + "caveat parameter type `%s` requires %d child types; found %d", + parameterType.TypeName, + len(parameterType.ChildTypes), + typeDef.childTypeCount, + ) + } + + childTypes := make([]VariableType, 0, typeDef.childTypeCount) + for _, encodedChildType := range parameterType.ChildTypes { + childType, err := DecodeParameterType(ts, encodedChildType) + if err != nil { + return nil, err + } + childTypes = append(childTypes, *childType) + } + + return typeDef.asVariableType(childTypes) +} + +// DecodeParameterTypes decodes the core caveat parameter types into internal caveat types. +func DecodeParameterTypes(ts *TypeSet, parameters map[string]*core.CaveatTypeReference) (map[string]VariableType, error) { + parameterTypes := make(map[string]VariableType, len(parameters)) + for paramName, paramType := range parameters { + decodedType, err := DecodeParameterType(ts, paramType) + if err != nil { + return nil, err + } + + parameterTypes[paramName] = *decodedType + } + return parameterTypes, nil +} diff --git a/vendor/github.com/authzed/spicedb/pkg/caveats/types/ipaddress.go b/vendor/github.com/authzed/spicedb/pkg/caveats/types/ipaddress.go new file mode 100644 index 0000000..2a92697 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/caveats/types/ipaddress.go @@ -0,0 +1,114 @@ +package types + +import ( + "fmt" + "net/netip" + "reflect" + + "github.com/authzed/cel-go/cel" + "github.com/authzed/cel-go/common/types" + "github.com/authzed/cel-go/common/types/ref" +) + +// ParseIPAddress parses the string form of an IP Address into an IPAddress object type. +func ParseIPAddress(ip string) (IPAddress, error) { + parsed, err := netip.ParseAddr(ip) + return IPAddress{parsed}, err +} + +// MustParseIPAddress parses the string form of an IP Address into an IPAddress object type. +func MustParseIPAddress(ip string) IPAddress { + ipAddress, err := ParseIPAddress(ip) + if err != nil { + panic(err) + } + return ipAddress +} + +var ipaddressCelType = cel.OpaqueType("IPAddress") + +// IPAddress defines a custom type for representing an IP Address in caveats. +type IPAddress struct { + ip netip.Addr +} + +func (ipa IPAddress) SerializedString() string { + return ipa.ip.String() +} + +func (ipa IPAddress) ConvertToNative(typeDesc reflect.Type) (interface{}, error) { + switch typeDesc { + case reflect.TypeOf(""): + return ipa.ip.String(), nil + } + return nil, fmt.Errorf("type conversion error from 'IPAddress' to '%v'", typeDesc) +} + +func (ipa IPAddress) ConvertToType(typeVal ref.Type) ref.Val { + switch typeVal { + case types.StringType: + return types.String(ipa.ip.String()) + case types.TypeType: + return ipaddressCelType + } + return types.NewErr("type conversion error from '%s' to '%s'", ipaddressCelType, typeVal) +} + +func (ipa IPAddress) Equal(other ref.Val) ref.Val { + o2, ok := other.(IPAddress) + if !ok { + return types.ValOrErr(other, "no such overload") + } + return types.Bool(ipa == o2) +} + +func (ipa IPAddress) Type() ref.Type { + return ipaddressCelType +} + +func (ipa IPAddress) Value() interface{} { + return ipa +} + +func RegisterIPAddressType(ts *TypeSet) (VariableType, error) { + return RegisterCustomType[IPAddress](ts, + "ipaddress", + cel.ObjectType("IPAddress"), + func(value any) (any, error) { + ipvalue, ok := value.(IPAddress) + if ok { + return ipvalue, nil + } + + vle, ok := value.(string) + if !ok { + return nil, fmt.Errorf("ipaddress requires an ipaddress string, found: %T `%v`", value, value) + } + + d, err := ParseIPAddress(vle) + if err != nil { + return nil, fmt.Errorf("could not parse ip address string `%s`: %w", vle, err) + } + + return d, nil + }, + cel.Function("in_cidr", + cel.MemberOverload("ipaddress_in_cidr_string", + []*cel.Type{cel.ObjectType("IPAddress"), cel.StringType}, + cel.BoolType, + cel.BinaryBinding(func(lhs, rhs ref.Val) ref.Val { + cidr, ok := rhs.Value().(string) + if !ok { + return types.NewErr("expected CIDR string") + } + + network, err := netip.ParsePrefix(cidr) + if err != nil { + return types.NewErr("invalid CIDR string: `%s`", cidr) + } + + return types.Bool(network.Contains(lhs.(IPAddress).ip)) + }), + ), + )) +} diff --git a/vendor/github.com/authzed/spicedb/pkg/caveats/types/map.go b/vendor/github.com/authzed/spicedb/pkg/caveats/types/map.go new file mode 100644 index 0000000..3d949cd --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/caveats/types/map.go @@ -0,0 +1,26 @@ +package types + +func subtree(map0 map[string]any, map1 map[string]any) bool { + for k, v := range map0 { + val, ok := map1[k] + if !ok { + return false + } + nestedMap0, ok := v.(map[string]any) + if ok { + nestedMap1, ok := val.(map[string]any) + if !ok { + return false + } + nestedResult := subtree(nestedMap0, nestedMap1) + if !nestedResult { + return false + } + } else { + if v != val { + return false + } + } + } + return true +} diff --git a/vendor/github.com/authzed/spicedb/pkg/caveats/types/registration.go b/vendor/github.com/authzed/spicedb/pkg/caveats/types/registration.go new file mode 100644 index 0000000..96663b1 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/caveats/types/registration.go @@ -0,0 +1,145 @@ +package types + +import ( + "fmt" + + "github.com/authzed/cel-go/cel" + "github.com/authzed/cel-go/common/types/ref" + + "github.com/authzed/spicedb/pkg/genutil" +) + +type ( + typedValueConverter func(value any) (any, error) +) + +type typeDefinition struct { + // localName is the localized name/keyword for the type. + localName string + + // childTypeCount is the number of generics on the type, if any. + childTypeCount uint8 + + // asVariableType converts the type definition into a VariableType. + asVariableType func(childTypes []VariableType) (*VariableType, error) +} + +// RegisterBasicType registers a basic type with the given keyword, CEL type, and converter. +func RegisterBasicType(ts *TypeSet, keyword string, celType *cel.Type, converter typedValueConverter) (VariableType, error) { + if ts.isFrozen { + return VariableType{}, fmt.Errorf("cannot register new types after the TypeSet is frozen") + } + + varType := VariableType{ + localName: keyword, + celType: celType, + childTypes: nil, + converter: converter, + } + + ts.definitions[keyword] = typeDefinition{ + localName: keyword, + childTypeCount: 0, + asVariableType: func(childTypes []VariableType) (*VariableType, error) { + return &varType, nil + }, + } + return varType, nil +} + +func MustRegisterBasicType(ts *TypeSet, keyword string, celType *cel.Type, converter typedValueConverter) VariableType { + varType, err := RegisterBasicType(ts, keyword, celType, converter) + if err != nil { + panic(fmt.Sprintf("failed to register basic type %s: %v", keyword, err)) + } + return varType +} + +type GenericTypeBuilder func(childTypes ...VariableType) (VariableType, error) + +// RegisterGenericType registers a type with at least one generic. +func RegisterGenericType( + ts *TypeSet, + keyword string, + childTypeCount uint8, + asVariableType func(childTypes []VariableType) VariableType, +) (GenericTypeBuilder, error) { + if ts.isFrozen { + return nil, fmt.Errorf("cannot register new types after the TypeSet is frozen") + } + + ts.definitions[keyword] = typeDefinition{ + localName: keyword, + childTypeCount: childTypeCount, + asVariableType: func(childTypes []VariableType) (*VariableType, error) { + childTypeLength, err := genutil.EnsureUInt8(len(childTypes)) + if err != nil { + return nil, err + } + + if childTypeLength != childTypeCount { + return nil, fmt.Errorf("type `%s` requires %d generic types; found %d", keyword, childTypeCount, len(childTypes)) + } + + built := asVariableType(childTypes) + return &built, nil + }, + } + return func(childTypes ...VariableType) (VariableType, error) { + childTypeLength, err := genutil.EnsureUInt8(len(childTypes)) + if err != nil { + return VariableType{}, err + } + + if childTypeLength != childTypeCount { + return VariableType{}, fmt.Errorf("invalid number of parameters given to type constructor. expected: %d, found: %d", childTypeCount, len(childTypes)) + } + + return asVariableType(childTypes), nil + }, nil +} + +func MustRegisterGenericType( + ts *TypeSet, + keyword string, + childTypeCount uint8, + asVariableType func(childTypes []VariableType) VariableType, +) GenericTypeBuilder { + genericTypeBuilder, err := RegisterGenericType(ts, keyword, childTypeCount, asVariableType) + if err != nil { + panic(fmt.Sprintf("failed to register generic type %s: %v", keyword, err)) + } + return genericTypeBuilder +} + +// RegisterCustomType registers a custom type that wraps a base CEL type. +func RegisterCustomType[T CustomType](ts *TypeSet, keyword string, baseCelType *cel.Type, converter typedValueConverter, opts ...cel.EnvOption) (VariableType, error) { + if ts.isFrozen { + return VariableType{}, fmt.Errorf("cannot register new types after the TypeSet is frozen") + } + + if err := RegisterCustomCELOptions(ts, opts...); err != nil { + return VariableType{}, err + } + + return RegisterBasicType(ts, keyword, baseCelType, converter) +} + +// RegisterCustomTypeWithName registers a custom type with a specific name. +func RegisterMethodOnDefinedType(ts *TypeSet, baseType *cel.Type, name string, args []*cel.Type, returnType *cel.Type, binding func(arg ...ref.Val) ref.Val) error { + finalArgs := make([]*cel.Type, 0, len(args)+1) + finalArgs = append(finalArgs, baseType) + finalArgs = append(finalArgs, args...) + method := cel.Function(name, cel.MemberOverload(name, finalArgs, returnType, cel.FunctionBinding(binding))) + + return RegisterCustomCELOptions(ts, method) +} + +// RegisterCustomOptions registers custom CEL environment options for the TypeSet. +func RegisterCustomCELOptions(ts *TypeSet, opts ...cel.EnvOption) error { + if ts.isFrozen { + return fmt.Errorf("cannot register new options after the TypeSet is frozen") + } + ts.customOptions = append(ts.customOptions, opts...) + return nil +} diff --git a/vendor/github.com/authzed/spicedb/pkg/caveats/types/standard.go b/vendor/github.com/authzed/spicedb/pkg/caveats/types/standard.go new file mode 100644 index 0000000..b5adf6a --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/caveats/types/standard.go @@ -0,0 +1,84 @@ +package types + +// Default is the default set of types to be used in caveats, coming with all +// the standard types pre-registered. This set is frozen and cannot be modified. +var Default *StandardTypeSet + +func init() { + Default = MustNewStandardTypeSet() + Default.Freeze() +} + +// TypeSetOrDefault returns the provided TypeSet if it is not nil, otherwise it +// returns the default TypeSet. This is useful for functions that accept a +// TypeSet parameter but want to use the default if none is provided. +func TypeSetOrDefault(ts *TypeSet) *TypeSet { + if ts == nil { + return Default.TypeSet + } + return ts +} + +func MustNewStandardTypeSet() *StandardTypeSet { + sts, err := NewStandardTypeSet() + if err != nil { + panic(err) + } + return sts +} + +// NewStandardTypeSet creates a new TypeSet with all the standard types pre-registered. +func NewStandardTypeSet() (*StandardTypeSet, error) { + sts := &StandardTypeSet{ + TypeSet: NewTypeSet(), + } + + if err := RegisterBasicTypes(sts); err != nil { + return nil, err + } + return sts, nil +} + +// StandardTypeSet is a TypeSet that contains all the standard types and provides nice accessors +// for each. +type StandardTypeSet struct { + *TypeSet + + AnyType VariableType + BooleanType VariableType + StringType VariableType + IntType VariableType + UIntType VariableType + DoubleType VariableType + BytesType VariableType + DurationType VariableType + TimestampType VariableType + IPAddressType VariableType + + listTypeBuilder GenericTypeBuilder + mapTypeBuilder GenericTypeBuilder +} + +func (sts *StandardTypeSet) ListType(childTypes ...VariableType) (VariableType, error) { + return sts.listTypeBuilder(childTypes...) +} + +func (sts *StandardTypeSet) MapType(childTypes ...VariableType) (VariableType, error) { + return sts.mapTypeBuilder(childTypes...) +} + +func (sts *StandardTypeSet) MustListType(childTypes ...VariableType) VariableType { + v, err := sts.ListType(childTypes...) + if err != nil { + panic(err) + } + return v +} + +func (sts *StandardTypeSet) MustMapType(childTypes ...VariableType) VariableType { + v, err := sts.MapType(childTypes...) + if err != nil { + panic(err) + } + return v +} diff --git a/vendor/github.com/authzed/spicedb/pkg/caveats/types/types.go b/vendor/github.com/authzed/spicedb/pkg/caveats/types/types.go new file mode 100644 index 0000000..14fa081 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/caveats/types/types.go @@ -0,0 +1,44 @@ +package types + +import ( + "fmt" + "strings" + + "github.com/authzed/cel-go/cel" +) + +// VariableType defines the supported types of variables in caveats. +type VariableType struct { + localName string + celType *cel.Type + childTypes []VariableType + converter typedValueConverter +} + +// CelType returns the underlying CEL type for the variable type. +func (vt VariableType) CelType() *cel.Type { + return vt.celType +} + +func (vt VariableType) String() string { + if len(vt.childTypes) > 0 { + childTypeStrings := make([]string, 0, len(vt.childTypes)) + for _, childType := range vt.childTypes { + childTypeStrings = append(childTypeStrings, childType.String()) + } + + return vt.localName + "<" + strings.Join(childTypeStrings, ", ") + ">" + } + + return vt.localName +} + +// ConvertValue converts the given value into one expected by this variable type. +func (vt VariableType) ConvertValue(value any) (any, error) { + converted, err := vt.converter(value) + if err != nil { + return nil, fmt.Errorf("for %s: %w", vt.String(), err) + } + + return converted, nil +} diff --git a/vendor/github.com/authzed/spicedb/pkg/caveats/types/typeset.go b/vendor/github.com/authzed/spicedb/pkg/caveats/types/typeset.go new file mode 100644 index 0000000..99b8bfe --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/caveats/types/typeset.go @@ -0,0 +1,59 @@ +package types + +import ( + "fmt" + + "github.com/authzed/cel-go/cel" +) + +// TypeSet defines a set of types that can be used in caveats. It is used to register custom types +// and methods that can be used in caveats. The types are registered by calling the RegisterType +// function. The types are then used to build the CEL environment for the caveat. +type TypeSet struct { + // definitions holds the set of all types defined and exported by this package, by name. + definitions map[string]typeDefinition + + // customOptions holds a set of custom options that can be used to create a CEL environment + // for the caveat. + customOptions []cel.EnvOption + + // isFrozen indicates whether the TypeSet is frozen. A frozen TypeSet cannot be modified. + isFrozen bool +} + +// Freeze marks the TypeSet as frozen. A frozen TypeSet cannot be modified. +func (ts *TypeSet) Freeze() { + ts.isFrozen = true +} + +// EnvOptions returns the set of environment options that can be used to create a CEL environment +// for the caveat. This includes the custom types and methods defined in the TypeSet. +func (ts *TypeSet) EnvOptions() ([]cel.EnvOption, error) { + if !ts.isFrozen { + return nil, fmt.Errorf("cannot get env options from a non-frozen TypeSet") + } + return ts.customOptions, nil +} + +// BuildType builds a variable type from its name and child types. +func (ts *TypeSet) BuildType(name string, childTypes []VariableType) (*VariableType, error) { + if !ts.isFrozen { + return nil, fmt.Errorf("cannot build types from a non-frozen TypeSet") + } + + typeDef, ok := ts.definitions[name] + if !ok { + return nil, fmt.Errorf("unknown type `%s`", name) + } + + return typeDef.asVariableType(childTypes) +} + +// NewTypeSet creates a new TypeSet. The TypeSet is not frozen and can be modified. +func NewTypeSet() *TypeSet { + return &TypeSet{ + definitions: map[string]typeDefinition{}, + customOptions: []cel.EnvOption{}, + isFrozen: false, + } +} diff --git a/vendor/github.com/authzed/spicedb/pkg/composableschemadsl/compiler/compiler.go b/vendor/github.com/authzed/spicedb/pkg/composableschemadsl/compiler/compiler.go new file mode 100644 index 0000000..9d61795 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/composableschemadsl/compiler/compiler.go @@ -0,0 +1,234 @@ +package compiler + +import ( + "errors" + "fmt" + + "google.golang.org/protobuf/proto" + "k8s.io/utils/strings/slices" + + caveattypes "github.com/authzed/spicedb/pkg/caveats/types" + "github.com/authzed/spicedb/pkg/composableschemadsl/dslshape" + "github.com/authzed/spicedb/pkg/composableschemadsl/input" + "github.com/authzed/spicedb/pkg/composableschemadsl/parser" + "github.com/authzed/spicedb/pkg/genutil/mapz" + core "github.com/authzed/spicedb/pkg/proto/core/v1" +) + +// InputSchema defines the input for a Compile. +type InputSchema struct { + // Source is the source of the schema being compiled. + Source input.Source + + // Schema is the contents being compiled. + SchemaString string +} + +// SchemaDefinition represents an object or caveat definition in a schema. +type SchemaDefinition interface { + proto.Message + + GetName() string +} + +// CompiledSchema is the result of compiling a schema when there are no errors. +type CompiledSchema struct { + // ObjectDefinitions holds the object definitions in the schema. + ObjectDefinitions []*core.NamespaceDefinition + + // CaveatDefinitions holds the caveat definitions in the schema. + CaveatDefinitions []*core.CaveatDefinition + + // OrderedDefinitions holds the object and caveat definitions in the schema, in the + // order in which they were found. + OrderedDefinitions []SchemaDefinition + + rootNode *dslNode + mapper input.PositionMapper +} + +// SourcePositionToRunePosition converts a source position to a rune position. +func (cs CompiledSchema) SourcePositionToRunePosition(source input.Source, position input.Position) (int, error) { + return cs.mapper.LineAndColToRunePosition(position.LineNumber, position.ColumnPosition, source) +} + +type config struct { + skipValidation bool + objectTypePrefix *string + allowedFlags []string + caveatTypeSet *caveattypes.TypeSet + + // In an import context, this is the folder containing + // the importing schema (as opposed to imported schemas) + sourceFolder string +} + +func SkipValidation() Option { return func(cfg *config) { cfg.skipValidation = true } } + +// Config for the prefix attached to all definitions, such as in Serverless +// where it's `someorganization/` in front of each definition. +func ObjectTypePrefix(prefix string) ObjectPrefixOption { + return func(cfg *config) { cfg.objectTypePrefix = &prefix } +} + +// Config that does not supply the prefix but requires the prefix on all objects. +func RequirePrefixedObjectType() ObjectPrefixOption { + return func(cfg *config) { cfg.objectTypePrefix = nil } +} + +// Config that allows for no prefix. This is the "normal" default. +func AllowUnprefixedObjectType() ObjectPrefixOption { + return func(cfg *config) { cfg.objectTypePrefix = new(string) } +} + +// WithCaveatTypeSet sets the caveat type set to use for the compilation. +func WithCaveatTypeSet(caveatTypeSet *caveattypes.TypeSet) Option { + return func(cfg *config) { cfg.caveatTypeSet = caveatTypeSet } +} + +const expirationFlag = "expiration" + +func DisallowExpirationFlag() Option { + return func(cfg *config) { + cfg.allowedFlags = slices.Filter([]string{}, cfg.allowedFlags, func(s string) bool { + return s != expirationFlag + }) + } +} + +// Config that supplies the root source folder for compilation. Required +// for relative import syntax to work properly. +func SourceFolder(sourceFolder string) Option { + return func(cfg *config) { cfg.sourceFolder = sourceFolder } +} + +type Option func(*config) + +type ObjectPrefixOption func(*config) + +// Compile compilers the input schema into a set of namespace definition protos. +func Compile(schema InputSchema, prefix ObjectPrefixOption, opts ...Option) (*CompiledSchema, error) { + cfg := &config{ + allowedFlags: make([]string, 0, 1), + } + + // Enable `expiration` flag by default. + cfg.allowedFlags = append(cfg.allowedFlags, expirationFlag) + + prefix(cfg) // required option + + for _, fn := range opts { + fn(cfg) + } + + root, mapper, err := parseSchema(schema) + if err != nil { + return nil, err + } + + // NOTE: import translation is done separately so that partial references + // and definitions defined in separate files can correctly resolve. + err = translateImports(importResolutionContext{ + globallyVisitedFiles: mapz.NewSet[string](), + locallyVisitedFiles: mapz.NewSet[string](), + sourceFolder: cfg.sourceFolder, + mapper: mapper, + }, root) + if err != nil { + return nil, err + } + + initialCompiledPartials := make(map[string][]*core.Relation) + caveatTypeSet := caveattypes.TypeSetOrDefault(cfg.caveatTypeSet) + compiled, err := translate(&translationContext{ + objectTypePrefix: cfg.objectTypePrefix, + mapper: mapper, + schemaString: schema.SchemaString, + skipValidate: cfg.skipValidation, + allowedFlags: cfg.allowedFlags, + existingNames: mapz.NewSet[string](), + compiledPartials: initialCompiledPartials, + unresolvedPartials: mapz.NewMultiMap[string, *dslNode](), + caveatTypeSet: caveatTypeSet, + }, root) + if err != nil { + var withNodeError withNodeError + if errors.As(err, &withNodeError) { + err = toContextError(withNodeError.error.Error(), withNodeError.errorSourceCode, withNodeError.node, mapper) + } + + return nil, err + } + + return compiled, nil +} + +func parseSchema(schema InputSchema) (*dslNode, input.PositionMapper, error) { + mapper := newPositionMapper(schema) + root := parser.Parse(createAstNode, schema.Source, schema.SchemaString).(*dslNode) + errs := root.FindAll(dslshape.NodeTypeError) + if len(errs) > 0 { + err := errorNodeToError(errs[0], mapper) + return nil, nil, err + } + return root, mapper, nil +} + +func errorNodeToError(node *dslNode, mapper input.PositionMapper) error { + if node.GetType() != dslshape.NodeTypeError { + return fmt.Errorf("given none error node") + } + + errMessage, err := node.GetString(dslshape.NodePredicateErrorMessage) + if err != nil { + return fmt.Errorf("could not get error message for error node: %w", err) + } + + errorSourceCode := "" + if node.Has(dslshape.NodePredicateErrorSource) { + es, err := node.GetString(dslshape.NodePredicateErrorSource) + if err != nil { + return fmt.Errorf("could not get error source for error node: %w", err) + } + + errorSourceCode = es + } + + return toContextError(errMessage, errorSourceCode, node, mapper) +} + +func toContextError(errMessage string, errorSourceCode string, node *dslNode, mapper input.PositionMapper) error { + sourceRange, err := node.Range(mapper) + if err != nil { + return fmt.Errorf("could not get range for error node: %w", err) + } + + formattedRange, err := formatRange(sourceRange) + if err != nil { + return err + } + + source, err := node.GetString(dslshape.NodePredicateSource) + if err != nil { + return fmt.Errorf("missing source for node: %w", err) + } + + return WithContextError{ + BaseCompilerError: BaseCompilerError{ + error: fmt.Errorf("parse error in %s: %s", formattedRange, errMessage), + BaseMessage: errMessage, + }, + SourceRange: sourceRange, + Source: input.Source(source), + ErrorSourceCode: errorSourceCode, + } +} + +func formatRange(rnge input.SourceRange) (string, error) { + startLine, startCol, err := rnge.Start().LineAndColumn() + if err != nil { + return "", err + } + + return fmt.Sprintf("`%s`, line %v, column %v", rnge.Source(), startLine+1, startCol+1), nil +} diff --git a/vendor/github.com/authzed/spicedb/pkg/composableschemadsl/compiler/development.go b/vendor/github.com/authzed/spicedb/pkg/composableschemadsl/compiler/development.go new file mode 100644 index 0000000..e18c0f5 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/composableschemadsl/compiler/development.go @@ -0,0 +1,142 @@ +package compiler + +import ( + "github.com/authzed/spicedb/pkg/composableschemadsl/dslshape" + "github.com/authzed/spicedb/pkg/composableschemadsl/input" +) + +// DSLNode is a node in the DSL AST. +type DSLNode interface { + GetType() dslshape.NodeType + GetString(predicateName string) (string, error) + GetInt(predicateName string) (int, error) + Lookup(predicateName string) (DSLNode, error) +} + +// NodeChain is a chain of nodes in the DSL AST. +type NodeChain struct { + nodes []DSLNode + runePosition int +} + +// Head returns the head node of the chain. +func (nc *NodeChain) Head() DSLNode { + return nc.nodes[0] +} + +// HasHeadType returns true if the head node of the chain is of the given type. +func (nc *NodeChain) HasHeadType(nodeType dslshape.NodeType) bool { + return nc.nodes[0].GetType() == nodeType +} + +// ForRunePosition returns the rune position of the chain. +func (nc *NodeChain) ForRunePosition() int { + return nc.runePosition +} + +// FindNodeOfType returns the first node of the given type in the chain, if any. +func (nc *NodeChain) FindNodeOfType(nodeType dslshape.NodeType) DSLNode { + for _, node := range nc.nodes { + if node.GetType() == nodeType { + return node + } + } + + return nil +} + +func (nc *NodeChain) String() string { + var out string + for _, node := range nc.nodes { + out += node.GetType().String() + " " + } + return out +} + +// PositionToAstNodeChain returns the AST node, and its parents (if any), found at the given position in the source, if any. +func PositionToAstNodeChain(schema *CompiledSchema, source input.Source, position input.Position) (*NodeChain, error) { + rootSource, err := schema.rootNode.GetString(dslshape.NodePredicateSource) + if err != nil { + return nil, err + } + + if rootSource != string(source) { + return nil, nil + } + + // Map the position to a file rune. + runePosition, err := schema.mapper.LineAndColToRunePosition(position.LineNumber, position.ColumnPosition, source) + if err != nil { + return nil, err + } + + // Find the node at the rune position. + found, err := runePositionToAstNodeChain(schema.rootNode, runePosition) + if err != nil { + return nil, err + } + + if found == nil { + return nil, nil + } + + return &NodeChain{nodes: found, runePosition: runePosition}, nil +} + +func runePositionToAstNodeChain(node *dslNode, runePosition int) ([]DSLNode, error) { + if !node.Has(dslshape.NodePredicateStartRune) { + return nil, nil + } + + startRune, err := node.GetInt(dslshape.NodePredicateStartRune) + if err != nil { + return nil, err + } + + endRune, err := node.GetInt(dslshape.NodePredicateEndRune) + if err != nil { + return nil, err + } + + if runePosition < startRune || runePosition > endRune { + return nil, nil + } + + for _, child := range node.AllSubNodes() { + childChain, err := runePositionToAstNodeChain(child, runePosition) + if err != nil { + return nil, err + } + + if childChain != nil { + return append(childChain, wrapper{node}), nil + } + } + + return []DSLNode{wrapper{node}}, nil +} + +type wrapper struct { + node *dslNode +} + +func (w wrapper) GetType() dslshape.NodeType { + return w.node.GetType() +} + +func (w wrapper) GetString(predicateName string) (string, error) { + return w.node.GetString(predicateName) +} + +func (w wrapper) GetInt(predicateName string) (int, error) { + return w.node.GetInt(predicateName) +} + +func (w wrapper) Lookup(predicateName string) (DSLNode, error) { + found, err := w.node.Lookup(predicateName) + if err != nil { + return nil, err + } + + return wrapper{found}, nil +} diff --git a/vendor/github.com/authzed/spicedb/pkg/composableschemadsl/compiler/errors.go b/vendor/github.com/authzed/spicedb/pkg/composableschemadsl/compiler/errors.go new file mode 100644 index 0000000..9b63002 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/composableschemadsl/compiler/errors.go @@ -0,0 +1,53 @@ +package compiler + +import ( + "strconv" + + "github.com/authzed/spicedb/pkg/composableschemadsl/input" +) + +// BaseCompilerError defines an error with contains the base message of the issue +// that occurred. +type BaseCompilerError struct { + error + BaseMessage string +} + +type withNodeError struct { + error + node *dslNode + errorSourceCode string +} + +// WithContextError defines an error which contains contextual information. +type WithContextError struct { + BaseCompilerError + SourceRange input.SourceRange + Source input.Source + ErrorSourceCode string +} + +func (ewc WithContextError) Unwrap() error { + return ewc.BaseCompilerError +} + +// DetailsMetadata returns the metadata for details for this error. +func (ewc WithContextError) DetailsMetadata() map[string]string { + startLine, startCol, err := ewc.SourceRange.Start().LineAndColumn() + if err != nil { + return map[string]string{} + } + + endLine, endCol, err := ewc.SourceRange.End().LineAndColumn() + if err != nil { + return map[string]string{} + } + + return map[string]string{ + "start_line_number": strconv.Itoa(startLine), + "start_column_position": strconv.Itoa(startCol), + "end_line_number": strconv.Itoa(endLine), + "end_column_position": strconv.Itoa(endCol), + "source_code": ewc.ErrorSourceCode, + } +} diff --git a/vendor/github.com/authzed/spicedb/pkg/composableschemadsl/compiler/importer.go b/vendor/github.com/authzed/spicedb/pkg/composableschemadsl/compiler/importer.go new file mode 100644 index 0000000..e156fdc --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/composableschemadsl/compiler/importer.go @@ -0,0 +1,47 @@ +package compiler + +import ( + "fmt" + "os" + "path/filepath" + "strings" + + "github.com/rs/zerolog/log" + + "github.com/authzed/spicedb/pkg/composableschemadsl/input" +) + +type CircularImportError struct { + error + filePath string +} + +func importFile(filePath string) (*dslNode, error) { + schemaBytes, err := os.ReadFile(filePath) + if err != nil { + return nil, fmt.Errorf("failed to read import in schema file: %w", err) + } + log.Trace().Str("schema", string(schemaBytes)).Str("file", filePath).Msg("read schema from file") + + parsedSchema, _, err := parseSchema(InputSchema{ + Source: input.Source(filePath), + SchemaString: string(schemaBytes), + }) + return parsedSchema, err +} + +// Take a filepath and ensure that it's local to the current context. +func validateFilepath(path string) error { + if strings.Contains(path, "..") { + return fmt.Errorf("path %s contains '..'; paths must stay within their directory and this is likely an error", path) + } + // NOTE: This is slightly overly restrictive; it should theoretically be possible + // to take a given filepath and figure out whether it's local to the context where + // the compiler is being invoked, rather than whether it's local to the source + // folder of the current context. The assumption is that that won't matter + // right now, and we can fix it if we need to. + if !filepath.IsLocal(path) { + return fmt.Errorf("import path %s does not stay within its folder", path) + } + return nil +} diff --git a/vendor/github.com/authzed/spicedb/pkg/composableschemadsl/compiler/node.go b/vendor/github.com/authzed/spicedb/pkg/composableschemadsl/compiler/node.go new file mode 100644 index 0000000..62ea566 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/composableschemadsl/compiler/node.go @@ -0,0 +1,189 @@ +package compiler + +import ( + "container/list" + "fmt" + + "github.com/authzed/spicedb/pkg/composableschemadsl/dslshape" + "github.com/authzed/spicedb/pkg/composableschemadsl/input" + "github.com/authzed/spicedb/pkg/composableschemadsl/parser" +) + +type dslNode struct { + nodeType dslshape.NodeType + properties map[string]interface{} + children map[string]*list.List +} + +func createAstNode(_ input.Source, kind dslshape.NodeType) parser.AstNode { + return &dslNode{ + nodeType: kind, + properties: make(map[string]interface{}), + children: make(map[string]*list.List), + } +} + +func (tn *dslNode) GetType() dslshape.NodeType { + return tn.nodeType +} + +func (tn *dslNode) Connect(predicate string, other parser.AstNode) { + if tn.children[predicate] == nil { + tn.children[predicate] = list.New() + } + + tn.children[predicate].PushBack(other) +} + +// Used to preserve import order when doing import operations on AST +func (tn *dslNode) ConnectAndHoistMany(predicate string, other *list.List) { + if tn.children[predicate] == nil { + tn.children[predicate] = list.New() + } + + tn.children[predicate].PushFrontList(other) +} + +func (tn *dslNode) MustDecorate(property string, value string) parser.AstNode { + if _, ok := tn.properties[property]; ok { + panic(fmt.Sprintf("Existing key for property %s\n\tNode: %v", property, tn.properties)) + } + + tn.properties[property] = value + return tn +} + +func (tn *dslNode) MustDecorateWithInt(property string, value int) parser.AstNode { + if _, ok := tn.properties[property]; ok { + panic(fmt.Sprintf("Existing key for property %s\n\tNode: %v", property, tn.properties)) + } + + tn.properties[property] = value + return tn +} + +func (tn *dslNode) Range(mapper input.PositionMapper) (input.SourceRange, error) { + sourceStr, err := tn.GetString(dslshape.NodePredicateSource) + if err != nil { + return nil, err + } + + source := input.Source(sourceStr) + + startRune, err := tn.GetInt(dslshape.NodePredicateStartRune) + if err != nil { + return nil, err + } + + endRune, err := tn.GetInt(dslshape.NodePredicateEndRune) + if err != nil { + return nil, err + } + + return source.RangeForRunePositions(startRune, endRune, mapper), nil +} + +func (tn *dslNode) Has(predicateName string) bool { + _, ok := tn.properties[predicateName] + return ok +} + +func (tn *dslNode) GetInt(predicateName string) (int, error) { + predicate, ok := tn.properties[predicateName] + if !ok { + return 0, fmt.Errorf("unknown predicate %s", predicateName) + } + + value, ok := predicate.(int) + if !ok { + return 0, fmt.Errorf("predicate %s is not an int", predicateName) + } + + return value, nil +} + +func (tn *dslNode) GetString(predicateName string) (string, error) { + predicate, ok := tn.properties[predicateName] + if !ok { + return "", fmt.Errorf("unknown predicate %s", predicateName) + } + + value, ok := predicate.(string) + if !ok { + return "", fmt.Errorf("predicate %s is not a string", predicateName) + } + + return value, nil +} + +func (tn *dslNode) AllSubNodes() []*dslNode { + nodes := []*dslNode{} + for _, childList := range tn.children { + for e := childList.Front(); e != nil; e = e.Next() { + nodes = append(nodes, e.Value.(*dslNode)) + } + } + return nodes +} + +func (tn *dslNode) GetChildren() []*dslNode { + return tn.List(dslshape.NodePredicateChild) +} + +func (tn *dslNode) FindAll(nodeType dslshape.NodeType) []*dslNode { + found := []*dslNode{} + if tn.nodeType == dslshape.NodeTypeError { + found = append(found, tn) + } + + for _, childList := range tn.children { + for e := childList.Front(); e != nil; e = e.Next() { + childFound := e.Value.(*dslNode).FindAll(nodeType) + found = append(found, childFound...) + } + } + return found +} + +func (tn *dslNode) List(predicateName string) []*dslNode { + children := []*dslNode{} + childList, ok := tn.children[predicateName] + if !ok { + return children + } + + for e := childList.Front(); e != nil; e = e.Next() { + children = append(children, e.Value.(*dslNode)) + } + + return children +} + +func (tn *dslNode) Lookup(predicateName string) (*dslNode, error) { + childList, ok := tn.children[predicateName] + if !ok { + return nil, fmt.Errorf("unknown predicate %s", predicateName) + } + + for e := childList.Front(); e != nil; e = e.Next() { + return e.Value.(*dslNode), nil + } + + return nil, fmt.Errorf("nothing in predicate %s", predicateName) +} + +func (tn *dslNode) Errorf(message string, args ...interface{}) error { + return withNodeError{ + error: fmt.Errorf(message, args...), + errorSourceCode: "", + node: tn, + } +} + +func (tn *dslNode) WithSourceErrorf(sourceCode string, message string, args ...interface{}) error { + return withNodeError{ + error: fmt.Errorf(message, args...), + errorSourceCode: sourceCode, + node: tn, + } +} diff --git a/vendor/github.com/authzed/spicedb/pkg/composableschemadsl/compiler/positionmapper.go b/vendor/github.com/authzed/spicedb/pkg/composableschemadsl/compiler/positionmapper.go new file mode 100644 index 0000000..b066c3b --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/composableschemadsl/compiler/positionmapper.go @@ -0,0 +1,32 @@ +package compiler + +import ( + "strings" + + "github.com/authzed/spicedb/pkg/composableschemadsl/input" +) + +type positionMapper struct { + schema InputSchema + mapper input.SourcePositionMapper +} + +func newPositionMapper(schema InputSchema) input.PositionMapper { + return &positionMapper{ + schema: schema, + mapper: input.CreateSourcePositionMapper([]byte(schema.SchemaString)), + } +} + +func (pm *positionMapper) RunePositionToLineAndCol(runePosition int, _ input.Source) (int, int, error) { + return pm.mapper.RunePositionToLineAndCol(runePosition) +} + +func (pm *positionMapper) LineAndColToRunePosition(lineNumber int, colPosition int, _ input.Source) (int, error) { + return pm.mapper.LineAndColToRunePosition(lineNumber, colPosition) +} + +func (pm *positionMapper) TextForLine(lineNumber int, _ input.Source) (string, error) { + lines := strings.Split(pm.schema.SchemaString, "\n") + return lines[lineNumber], nil +} diff --git a/vendor/github.com/authzed/spicedb/pkg/composableschemadsl/compiler/translator.go b/vendor/github.com/authzed/spicedb/pkg/composableschemadsl/compiler/translator.go new file mode 100644 index 0000000..48145d9 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/composableschemadsl/compiler/translator.go @@ -0,0 +1,948 @@ +package compiler + +import ( + "bufio" + "container/list" + "fmt" + "path/filepath" + "slices" + "strings" + + "github.com/ccoveille/go-safecast" + "github.com/jzelinskie/stringz" + "github.com/rs/zerolog/log" + + "github.com/authzed/spicedb/pkg/caveats" + caveattypes "github.com/authzed/spicedb/pkg/caveats/types" + "github.com/authzed/spicedb/pkg/composableschemadsl/dslshape" + "github.com/authzed/spicedb/pkg/composableschemadsl/input" + "github.com/authzed/spicedb/pkg/genutil/mapz" + "github.com/authzed/spicedb/pkg/namespace" + core "github.com/authzed/spicedb/pkg/proto/core/v1" +) + +type translationContext struct { + objectTypePrefix *string + mapper input.PositionMapper + schemaString string + skipValidate bool + allowedFlags []string + enabledFlags []string + existingNames *mapz.Set[string] + caveatTypeSet *caveattypes.TypeSet + + // The mapping of partial name -> relations represented by the partial + compiledPartials map[string][]*core.Relation + + // A mapping of partial name -> partial DSL nodes whose resolution depends on + // the resolution of the named partial + unresolvedPartials *mapz.MultiMap[string, *dslNode] +} + +func (tctx *translationContext) prefixedPath(definitionName string) (string, error) { + var prefix, name string + if err := stringz.SplitInto(definitionName, "/", &prefix, &name); err != nil { + if tctx.objectTypePrefix == nil { + return "", fmt.Errorf("found reference `%s` without prefix", definitionName) + } + prefix = *tctx.objectTypePrefix + name = definitionName + } + + if prefix == "" { + return name, nil + } + + return stringz.Join("/", prefix, name), nil +} + +const Ellipsis = "..." + +func translate(tctx *translationContext, root *dslNode) (*CompiledSchema, error) { + orderedDefinitions := make([]SchemaDefinition, 0, len(root.GetChildren())) + var objectDefinitions []*core.NamespaceDefinition + var caveatDefinitions []*core.CaveatDefinition + + // Copy the name set so that we're not mutating the parent's context + // as we do our walk + names := tctx.existingNames.Copy() + + // Do an initial pass to translate partials and add them to the + // translation context. This ensures that they're available for + // subsequent reference in definition compilation. + err := collectPartials(tctx, root) + if err != nil { + return nil, err + } + + for _, topLevelNode := range root.GetChildren() { + switch topLevelNode.GetType() { + case dslshape.NodeTypeUseFlag: + err := translateUseFlag(tctx, topLevelNode) + if err != nil { + return nil, err + } + + case dslshape.NodeTypeCaveatDefinition: + log.Trace().Msg("adding caveat definition") + // TODO: Maybe refactor these in terms of a generic function? + def, err := translateCaveatDefinition(tctx, topLevelNode) + if err != nil { + return nil, err + } + + caveatDefinitions = append(caveatDefinitions, def) + + name := def.GetName() + if !names.Add(name) { + return nil, topLevelNode.WithSourceErrorf(name, "found name reused between multiple definitions and/or caveats: %s", name) + } + + if _, found := tctx.compiledPartials[name]; found { + return nil, topLevelNode.WithSourceErrorf(name, "found caveat with same name as existing partial: %s", name) + } + + orderedDefinitions = append(orderedDefinitions, def) + + case dslshape.NodeTypeDefinition: + log.Trace().Msg("adding object definition") + def, err := translateObjectDefinition(tctx, topLevelNode) + if err != nil { + return nil, err + } + + objectDefinitions = append(objectDefinitions, def) + + name := def.GetName() + if !names.Add(name) { + return nil, topLevelNode.WithSourceErrorf(name, "found name reused between multiple definitions and/or caveats: %s", name) + } + + if _, found := tctx.compiledPartials[name]; found { + return nil, topLevelNode.WithSourceErrorf(name, "found definition with same name as existing partial: %s", name) + } + + orderedDefinitions = append(orderedDefinitions, def) + } + } + + return &CompiledSchema{ + CaveatDefinitions: caveatDefinitions, + ObjectDefinitions: objectDefinitions, + OrderedDefinitions: orderedDefinitions, + rootNode: root, + mapper: tctx.mapper, + }, nil +} + +func translateCaveatDefinition(tctx *translationContext, defNode *dslNode) (*core.CaveatDefinition, error) { + definitionName, err := defNode.GetString(dslshape.NodeCaveatDefinitionPredicateName) + if err != nil { + return nil, defNode.WithSourceErrorf(definitionName, "invalid definition name: %w", err) + } + + // parameters + paramNodes := defNode.List(dslshape.NodeCaveatDefinitionPredicateParameters) + if len(paramNodes) == 0 { + return nil, defNode.WithSourceErrorf(definitionName, "caveat `%s` must have at least one parameter defined", definitionName) + } + + env := caveats.NewEnvironment() + parameters := make(map[string]caveattypes.VariableType, len(paramNodes)) + for _, paramNode := range paramNodes { + paramName, err := paramNode.GetString(dslshape.NodeCaveatParameterPredicateName) + if err != nil { + return nil, paramNode.WithSourceErrorf(paramName, "invalid parameter name: %w", err) + } + + if _, ok := parameters[paramName]; ok { + return nil, paramNode.WithSourceErrorf(paramName, "duplicate parameter `%s` defined on caveat `%s`", paramName, definitionName) + } + + typeRefNode, err := paramNode.Lookup(dslshape.NodeCaveatParameterPredicateType) + if err != nil { + return nil, paramNode.WithSourceErrorf(paramName, "invalid type for parameter: %w", err) + } + + translatedType, err := translateCaveatTypeReference(tctx, typeRefNode) + if err != nil { + return nil, paramNode.WithSourceErrorf(paramName, "invalid type for caveat parameter `%s` on caveat `%s`: %w", paramName, definitionName, err) + } + + parameters[paramName] = *translatedType + err = env.AddVariable(paramName, *translatedType) + if err != nil { + return nil, paramNode.WithSourceErrorf(paramName, "invalid type for caveat parameter `%s` on caveat `%s`: %w", paramName, definitionName, err) + } + } + + caveatPath, err := tctx.prefixedPath(definitionName) + if err != nil { + return nil, defNode.Errorf("%w", err) + } + + // caveat expression. + expressionStringNode, err := defNode.Lookup(dslshape.NodeCaveatDefinitionPredicateExpession) + if err != nil { + return nil, defNode.WithSourceErrorf(definitionName, "invalid expression: %w", err) + } + + expressionString, err := expressionStringNode.GetString(dslshape.NodeCaveatExpressionPredicateExpression) + if err != nil { + return nil, defNode.WithSourceErrorf(expressionString, "invalid expression: %w", err) + } + + rnge, err := expressionStringNode.Range(tctx.mapper) + if err != nil { + return nil, defNode.WithSourceErrorf(expressionString, "invalid expression: %w", err) + } + + source, err := caveats.NewSource(expressionString, caveatPath) + if err != nil { + return nil, defNode.WithSourceErrorf(expressionString, "invalid expression: %w", err) + } + + compiled, err := caveats.CompileCaveatWithSource(env, caveatPath, source, rnge.Start()) + if err != nil { + return nil, expressionStringNode.WithSourceErrorf(expressionString, "invalid expression for caveat `%s`: %w", definitionName, err) + } + + def, err := namespace.CompiledCaveatDefinition(env, caveatPath, compiled) + if err != nil { + return nil, err + } + + def.Metadata = addComments(def.Metadata, defNode) + def.SourcePosition = getSourcePosition(defNode, tctx.mapper) + return def, nil +} + +func translateCaveatTypeReference(tctx *translationContext, typeRefNode *dslNode) (*caveattypes.VariableType, error) { + typeName, err := typeRefNode.GetString(dslshape.NodeCaveatTypeReferencePredicateType) + if err != nil { + return nil, typeRefNode.WithSourceErrorf(typeName, "invalid type name: %w", err) + } + + childTypeNodes := typeRefNode.List(dslshape.NodeCaveatTypeReferencePredicateChildTypes) + childTypes := make([]caveattypes.VariableType, 0, len(childTypeNodes)) + for _, childTypeNode := range childTypeNodes { + translated, err := translateCaveatTypeReference(tctx, childTypeNode) + if err != nil { + return nil, err + } + childTypes = append(childTypes, *translated) + } + + constructedType, err := tctx.caveatTypeSet.BuildType(typeName, childTypes) + if err != nil { + return nil, typeRefNode.WithSourceErrorf(typeName, "%w", err) + } + + return constructedType, nil +} + +func translateObjectDefinition(tctx *translationContext, defNode *dslNode) (*core.NamespaceDefinition, error) { + definitionName, err := defNode.GetString(dslshape.NodeDefinitionPredicateName) + if err != nil { + return nil, defNode.WithSourceErrorf(definitionName, "invalid definition name: %w", err) + } + + errorOnMissingReference := true + relationsAndPermissions, _, err := translateRelationsAndPermissions(tctx, defNode, errorOnMissingReference) + if err != nil { + return nil, err + } + + nspath, err := tctx.prefixedPath(definitionName) + if err != nil { + return nil, defNode.Errorf("%w", err) + } + + if len(relationsAndPermissions) == 0 { + ns := namespace.Namespace(nspath) + ns.Metadata = addComments(ns.Metadata, defNode) + ns.SourcePosition = getSourcePosition(defNode, tctx.mapper) + + if !tctx.skipValidate { + if err = ns.Validate(); err != nil { + return nil, defNode.Errorf("error in object definition %s: %w", nspath, err) + } + } + + return ns, nil + } + + ns := namespace.Namespace(nspath, relationsAndPermissions...) + ns.Metadata = addComments(ns.Metadata, defNode) + ns.SourcePosition = getSourcePosition(defNode, tctx.mapper) + + if !tctx.skipValidate { + if err := ns.Validate(); err != nil { + return nil, defNode.Errorf("error in object definition %s: %w", nspath, err) + } + } + + return ns, nil +} + +// NOTE: This function behaves differently based on an errorOnMissingReference flag. +// A value of true treats that as an error state, since all partials should be resolved when translating definitions, +// where the false value returns the name of the partial for collection for future processing +// when translating partials. +func translateRelationsAndPermissions(tctx *translationContext, astNode *dslNode, errorOnMissingReference bool) ([]*core.Relation, string, error) { + relationsAndPermissions := []*core.Relation{} + for _, definitionChildNode := range astNode.GetChildren() { + if definitionChildNode.GetType() == dslshape.NodeTypeComment { + continue + } + + if definitionChildNode.GetType() == dslshape.NodeTypePartialReference { + partialContents, unresolvedPartial, err := translatePartialReference(tctx, definitionChildNode, errorOnMissingReference) + if err != nil { + return nil, "", err + } + if unresolvedPartial != "" { + return nil, unresolvedPartial, nil + } + relationsAndPermissions = append(relationsAndPermissions, partialContents...) + continue + } + + relationOrPermission, err := translateRelationOrPermission(tctx, definitionChildNode) + if err != nil { + return nil, "", err + } + + relationsAndPermissions = append(relationsAndPermissions, relationOrPermission) + } + return relationsAndPermissions, "", nil +} + +func getSourcePosition(dslNode *dslNode, mapper input.PositionMapper) *core.SourcePosition { + if !dslNode.Has(dslshape.NodePredicateStartRune) { + return nil + } + + sourceRange, err := dslNode.Range(mapper) + if err != nil { + return nil + } + + line, col, err := sourceRange.Start().LineAndColumn() + if err != nil { + return nil + } + + // We're okay with these being zero if the cast fails. + uintLine, _ := safecast.ToUint64(line) + uintCol, _ := safecast.ToUint64(col) + + return &core.SourcePosition{ + ZeroIndexedLineNumber: uintLine, + ZeroIndexedColumnPosition: uintCol, + } +} + +func addComments(mdmsg *core.Metadata, dslNode *dslNode) *core.Metadata { + for _, child := range dslNode.GetChildren() { + if child.GetType() == dslshape.NodeTypeComment { + value, err := child.GetString(dslshape.NodeCommentPredicateValue) + if err == nil { + mdmsg, _ = namespace.AddComment(mdmsg, normalizeComment(value)) + } + } + } + return mdmsg +} + +func normalizeComment(value string) string { + var lines []string + scanner := bufio.NewScanner(strings.NewReader(value)) + for scanner.Scan() { + trimmed := strings.TrimSpace(scanner.Text()) + lines = append(lines, trimmed) + } + return strings.Join(lines, "\n") +} + +func translateRelationOrPermission(tctx *translationContext, relOrPermNode *dslNode) (*core.Relation, error) { + switch relOrPermNode.GetType() { + case dslshape.NodeTypeRelation: + rel, err := translateRelation(tctx, relOrPermNode) + if err != nil { + return nil, err + } + rel.Metadata = addComments(rel.Metadata, relOrPermNode) + rel.SourcePosition = getSourcePosition(relOrPermNode, tctx.mapper) + return rel, err + + case dslshape.NodeTypePermission: + rel, err := translatePermission(tctx, relOrPermNode) + if err != nil { + return nil, err + } + rel.Metadata = addComments(rel.Metadata, relOrPermNode) + rel.SourcePosition = getSourcePosition(relOrPermNode, tctx.mapper) + return rel, err + + default: + return nil, relOrPermNode.Errorf("unknown definition top-level node type %s", relOrPermNode.GetType()) + } +} + +func translateRelation(tctx *translationContext, relationNode *dslNode) (*core.Relation, error) { + relationName, err := relationNode.GetString(dslshape.NodePredicateName) + if err != nil { + return nil, relationNode.Errorf("invalid relation name: %w", err) + } + + allowedDirectTypes := []*core.AllowedRelation{} + for _, typeRef := range relationNode.List(dslshape.NodeRelationPredicateAllowedTypes) { + allowedRelations, err := translateAllowedRelations(tctx, typeRef) + if err != nil { + return nil, err + } + + allowedDirectTypes = append(allowedDirectTypes, allowedRelations...) + } + + relation, err := namespace.Relation(relationName, nil, allowedDirectTypes...) + if err != nil { + return nil, err + } + + if !tctx.skipValidate { + if err := relation.Validate(); err != nil { + return nil, relationNode.Errorf("error in relation %s: %w", relationName, err) + } + } + + return relation, nil +} + +func translatePermission(tctx *translationContext, permissionNode *dslNode) (*core.Relation, error) { + permissionName, err := permissionNode.GetString(dslshape.NodePredicateName) + if err != nil { + return nil, permissionNode.Errorf("invalid permission name: %w", err) + } + + expressionNode, err := permissionNode.Lookup(dslshape.NodePermissionPredicateComputeExpression) + if err != nil { + return nil, permissionNode.Errorf("invalid permission expression: %w", err) + } + + rewrite, err := translateExpression(tctx, expressionNode) + if err != nil { + return nil, err + } + + permission, err := namespace.Relation(permissionName, rewrite) + if err != nil { + return nil, err + } + + if !tctx.skipValidate { + if err := permission.Validate(); err != nil { + return nil, permissionNode.Errorf("error in permission %s: %w", permissionName, err) + } + } + + return permission, nil +} + +func translateBinary(tctx *translationContext, expressionNode *dslNode) (*core.SetOperation_Child, *core.SetOperation_Child, error) { + leftChild, err := expressionNode.Lookup(dslshape.NodeExpressionPredicateLeftExpr) + if err != nil { + return nil, nil, err + } + + rightChild, err := expressionNode.Lookup(dslshape.NodeExpressionPredicateRightExpr) + if err != nil { + return nil, nil, err + } + + leftOperation, err := translateExpressionOperation(tctx, leftChild) + if err != nil { + return nil, nil, err + } + + rightOperation, err := translateExpressionOperation(tctx, rightChild) + if err != nil { + return nil, nil, err + } + + return leftOperation, rightOperation, nil +} + +func translateExpression(tctx *translationContext, expressionNode *dslNode) (*core.UsersetRewrite, error) { + translated, err := translateExpressionDirect(tctx, expressionNode) + if err != nil { + return translated, err + } + + translated.SourcePosition = getSourcePosition(expressionNode, tctx.mapper) + return translated, nil +} + +func collapseOps(op *core.SetOperation_Child, handler func(rewrite *core.UsersetRewrite) *core.SetOperation) []*core.SetOperation_Child { + if op.GetUsersetRewrite() == nil { + return []*core.SetOperation_Child{op} + } + + usersetRewrite := op.GetUsersetRewrite() + operation := handler(usersetRewrite) + if operation == nil { + return []*core.SetOperation_Child{op} + } + + collapsed := make([]*core.SetOperation_Child, 0, len(operation.Child)) + for _, child := range operation.Child { + collapsed = append(collapsed, collapseOps(child, handler)...) + } + return collapsed +} + +func translateExpressionDirect(tctx *translationContext, expressionNode *dslNode) (*core.UsersetRewrite, error) { + // For union and intersection, we collapse a tree of binary operations into a flat list containing child + // operations of the *same* type. + translate := func( + builder func(firstChild *core.SetOperation_Child, rest ...*core.SetOperation_Child) *core.UsersetRewrite, + lookup func(rewrite *core.UsersetRewrite) *core.SetOperation, + ) (*core.UsersetRewrite, error) { + leftOperation, rightOperation, err := translateBinary(tctx, expressionNode) + if err != nil { + return nil, err + } + leftOps := collapseOps(leftOperation, lookup) + rightOps := collapseOps(rightOperation, lookup) + ops := append(leftOps, rightOps...) + return builder(ops[0], ops[1:]...), nil + } + + switch expressionNode.GetType() { + case dslshape.NodeTypeUnionExpression: + return translate(namespace.Union, func(rewrite *core.UsersetRewrite) *core.SetOperation { + return rewrite.GetUnion() + }) + + case dslshape.NodeTypeIntersectExpression: + return translate(namespace.Intersection, func(rewrite *core.UsersetRewrite) *core.SetOperation { + return rewrite.GetIntersection() + }) + + case dslshape.NodeTypeExclusionExpression: + // Order matters for exclusions, so do not perform the optimization. + leftOperation, rightOperation, err := translateBinary(tctx, expressionNode) + if err != nil { + return nil, err + } + return namespace.Exclusion(leftOperation, rightOperation), nil + + default: + op, err := translateExpressionOperation(tctx, expressionNode) + if err != nil { + return nil, err + } + + return namespace.Union(op), nil + } +} + +func translateExpressionOperation(tctx *translationContext, expressionOpNode *dslNode) (*core.SetOperation_Child, error) { + translated, err := translateExpressionOperationDirect(tctx, expressionOpNode) + if err != nil { + return translated, err + } + + translated.SourcePosition = getSourcePosition(expressionOpNode, tctx.mapper) + return translated, nil +} + +func translateExpressionOperationDirect(tctx *translationContext, expressionOpNode *dslNode) (*core.SetOperation_Child, error) { + switch expressionOpNode.GetType() { + case dslshape.NodeTypeIdentifier: + referencedRelationName, err := expressionOpNode.GetString(dslshape.NodeIdentiferPredicateValue) + if err != nil { + return nil, err + } + + return namespace.ComputedUserset(referencedRelationName), nil + + case dslshape.NodeTypeNilExpression: + return namespace.Nil(), nil + + case dslshape.NodeTypeArrowExpression: + leftChild, err := expressionOpNode.Lookup(dslshape.NodeExpressionPredicateLeftExpr) + if err != nil { + return nil, err + } + + rightChild, err := expressionOpNode.Lookup(dslshape.NodeExpressionPredicateRightExpr) + if err != nil { + return nil, err + } + + if leftChild.GetType() != dslshape.NodeTypeIdentifier { + return nil, leftChild.Errorf("Nested arrows not yet supported") + } + + tuplesetRelation, err := leftChild.GetString(dslshape.NodeIdentiferPredicateValue) + if err != nil { + return nil, err + } + + usersetRelation, err := rightChild.GetString(dslshape.NodeIdentiferPredicateValue) + if err != nil { + return nil, err + } + + if expressionOpNode.Has(dslshape.NodeArrowExpressionFunctionName) { + functionName, err := expressionOpNode.GetString(dslshape.NodeArrowExpressionFunctionName) + if err != nil { + return nil, err + } + + return namespace.MustFunctionedTupleToUserset(tuplesetRelation, functionName, usersetRelation), nil + } + + return namespace.TupleToUserset(tuplesetRelation, usersetRelation), nil + + case dslshape.NodeTypeUnionExpression: + fallthrough + + case dslshape.NodeTypeIntersectExpression: + fallthrough + + case dslshape.NodeTypeExclusionExpression: + rewrite, err := translateExpression(tctx, expressionOpNode) + if err != nil { + return nil, err + } + return namespace.Rewrite(rewrite), nil + + default: + return nil, expressionOpNode.Errorf("unknown expression node type %s", expressionOpNode.GetType()) + } +} + +func translateAllowedRelations(tctx *translationContext, typeRefNode *dslNode) ([]*core.AllowedRelation, error) { + switch typeRefNode.GetType() { + case dslshape.NodeTypeTypeReference: + references := []*core.AllowedRelation{} + for _, subRefNode := range typeRefNode.List(dslshape.NodeTypeReferencePredicateType) { + subReferences, err := translateAllowedRelations(tctx, subRefNode) + if err != nil { + return []*core.AllowedRelation{}, err + } + + references = append(references, subReferences...) + } + return references, nil + + case dslshape.NodeTypeSpecificTypeReference: + ref, err := translateSpecificTypeReference(tctx, typeRefNode) + if err != nil { + return []*core.AllowedRelation{}, err + } + return []*core.AllowedRelation{ref}, nil + + default: + return nil, typeRefNode.Errorf("unknown type ref node type %s", typeRefNode.GetType()) + } +} + +func translateSpecificTypeReference(tctx *translationContext, typeRefNode *dslNode) (*core.AllowedRelation, error) { + typePath, err := typeRefNode.GetString(dslshape.NodeSpecificReferencePredicateType) + if err != nil { + return nil, typeRefNode.Errorf("invalid type name: %w", err) + } + + nspath, err := tctx.prefixedPath(typePath) + if err != nil { + return nil, typeRefNode.Errorf("%w", err) + } + + if typeRefNode.Has(dslshape.NodeSpecificReferencePredicateWildcard) { + ref := &core.AllowedRelation{ + Namespace: nspath, + RelationOrWildcard: &core.AllowedRelation_PublicWildcard_{ + PublicWildcard: &core.AllowedRelation_PublicWildcard{}, + }, + } + + err = addWithCaveats(tctx, typeRefNode, ref) + if err != nil { + return nil, typeRefNode.Errorf("invalid caveat: %w", err) + } + + if !tctx.skipValidate { + if err := ref.Validate(); err != nil { + return nil, typeRefNode.Errorf("invalid type relation: %w", err) + } + } + + ref.SourcePosition = getSourcePosition(typeRefNode, tctx.mapper) + return ref, nil + } + + relationName := Ellipsis + if typeRefNode.Has(dslshape.NodeSpecificReferencePredicateRelation) { + relationName, err = typeRefNode.GetString(dslshape.NodeSpecificReferencePredicateRelation) + if err != nil { + return nil, typeRefNode.Errorf("invalid type relation: %w", err) + } + } + + ref := &core.AllowedRelation{ + Namespace: nspath, + RelationOrWildcard: &core.AllowedRelation_Relation{ + Relation: relationName, + }, + } + + // Add the caveat(s), if any. + err = addWithCaveats(tctx, typeRefNode, ref) + if err != nil { + return nil, typeRefNode.Errorf("invalid caveat: %w", err) + } + + // Add the expiration trait, if any. + if traitNode, err := typeRefNode.Lookup(dslshape.NodeSpecificReferencePredicateTrait); err == nil { + traitName, err := traitNode.GetString(dslshape.NodeTraitPredicateTrait) + if err != nil { + return nil, typeRefNode.Errorf("invalid trait: %w", err) + } + + if traitName != "expiration" { + return nil, typeRefNode.Errorf("invalid trait: %s", traitName) + } + + if !slices.Contains(tctx.allowedFlags, "expiration") { + return nil, typeRefNode.Errorf("expiration trait is not allowed") + } + + if !slices.Contains(tctx.enabledFlags, "expiration") { + return nil, typeRefNode.Errorf("expiration flag is not enabled; add `use expiration` to top of file") + } + + ref.RequiredExpiration = &core.ExpirationTrait{} + } + + if !tctx.skipValidate { + if err := ref.Validate(); err != nil { + return nil, typeRefNode.Errorf("invalid type relation: %w", err) + } + } + + ref.SourcePosition = getSourcePosition(typeRefNode, tctx.mapper) + return ref, nil +} + +func addWithCaveats(tctx *translationContext, typeRefNode *dslNode, ref *core.AllowedRelation) error { + caveats := typeRefNode.List(dslshape.NodeSpecificReferencePredicateCaveat) + if len(caveats) == 0 { + return nil + } + + if len(caveats) != 1 { + return fmt.Errorf("only one caveat is currently allowed per type reference") + } + + name, err := caveats[0].GetString(dslshape.NodeCaveatPredicateCaveat) + if err != nil { + return err + } + + nspath, err := tctx.prefixedPath(name) + if err != nil { + return err + } + + ref.RequiredCaveat = &core.AllowedCaveat{ + CaveatName: nspath, + } + return nil +} + +type importResolutionContext struct { + // The global set of files we've visited in the import process. + // If these collide we short circuit, preventing duplicate imports. + globallyVisitedFiles *mapz.Set[string] + // The set of files that we've visited on a particular leg of the recursion. + // This allows for detection of circular imports. + // NOTE: This depends on an assumption that a depth-first search will always + // find a cycle, even if we're otherwise marking globally visited nodes. + locallyVisitedFiles *mapz.Set[string] + sourceFolder string + mapper input.PositionMapper +} + +// Takes a parsed schema and recursively translates import syntax and replaces +// import nodes with parsed nodes from the target files +func translateImports(itctx importResolutionContext, root *dslNode) error { + // We create a new list so that we can maintain the order + // of imported nodes + importedDefinitionNodes := list.New() + + for _, topLevelNode := range root.GetChildren() { + // Process import nodes; ignore the others + if topLevelNode.GetType() == dslshape.NodeTypeImport { + // Do the handling of recursive imports etc here + importPath, err := topLevelNode.GetString(dslshape.NodeImportPredicatePath) + if err != nil { + return err + } + + if err := validateFilepath(importPath); err != nil { + return err + } + filePath := filepath.Join(itctx.sourceFolder, importPath) + + newSourceFolder := filepath.Dir(filePath) + + currentLocallyVisitedFiles := itctx.locallyVisitedFiles.Copy() + + if ok := currentLocallyVisitedFiles.Add(filePath); !ok { + // If we've already visited the file on this particular branch walk, it's + // a circular import issue. + return &CircularImportError{ + error: fmt.Errorf("circular import detected: %s has been visited on this branch", filePath), + filePath: filePath, + } + } + + if ok := itctx.globallyVisitedFiles.Add(filePath); !ok { + // If the file has already been visited, we short-circuit the import process + // by not reading the schema file in and compiling a schema with an empty string. + // This prevents duplicate definitions from ending up in the output, as well + // as preventing circular imports. + log.Debug().Str("filepath", filePath).Msg("file %s has already been visited in another part of the walk") + return nil + } + + // Do the actual import here + // This is a new node provided by the translateImport + parsedImportRoot, err := importFile(filePath) + if err != nil { + return toContextError("failed to read import in schema file", "", topLevelNode, itctx.mapper) + } + + // We recurse on that node to resolve any further imports + err = translateImports(importResolutionContext{ + sourceFolder: newSourceFolder, + locallyVisitedFiles: currentLocallyVisitedFiles, + globallyVisitedFiles: itctx.globallyVisitedFiles, + mapper: itctx.mapper, + }, parsedImportRoot) + if err != nil { + return err + } + + // And then append the definition to the list of definitions to be added + for _, importedNode := range parsedImportRoot.GetChildren() { + if importedNode.GetType() != dslshape.NodeTypeImport { + importedDefinitionNodes.PushBack(importedNode) + } + } + } + } + + // finally, take the list of definitions to add and prepend them + // (effectively hoists definitions) + root.ConnectAndHoistMany(dslshape.NodePredicateChild, importedDefinitionNodes) + + return nil +} + +func collectPartials(tctx *translationContext, rootNode *dslNode) error { + for _, topLevelNode := range rootNode.GetChildren() { + if topLevelNode.GetType() == dslshape.NodeTypePartial { + err := translatePartial(tctx, topLevelNode) + if err != nil { + return err + } + } + } + if tctx.unresolvedPartials.Len() != 0 { + return fmt.Errorf("could not resolve partials: [%s]. this may indicate a circular reference", strings.Join(tctx.unresolvedPartials.Keys(), ", ")) + } + return nil +} + +// This function modifies the translation context, so we don't need to return anything from it. +func translatePartial(tctx *translationContext, partialNode *dslNode) error { + partialName, err := partialNode.GetString(dslshape.NodePartialPredicateName) + if err != nil { + return err + } + // Use the prefixed path to align with namespace and definition compilation + partialPath, err := tctx.prefixedPath(partialName) + if err != nil { + return err + } + // This needs to return the unresolved name. + errorOnMissingReference := false + relationsAndPermissions, unresolvedPartial, err := translateRelationsAndPermissions(tctx, partialNode, errorOnMissingReference) + if err != nil { + return err + } + if unresolvedPartial != "" { + tctx.unresolvedPartials.Add(unresolvedPartial, partialNode) + return nil + } + + tctx.compiledPartials[partialPath] = relationsAndPermissions + + // Since we've successfully compiled a partial, check the unresolved partials to see if any other partial was + // waiting on this partial + // NOTE: we're making an assumption here that a partial can't end up back in the same + // list of unresolved partials - if it hangs again in a different spot, it will end up in a different + // list of unresolved partials. + waitingPartials, _ := tctx.unresolvedPartials.Get(partialPath) + for _, waitingPartialNode := range waitingPartials { + err := translatePartial(tctx, waitingPartialNode) + if err != nil { + return err + } + } + // Clear out this partial's key from the unresolved partials if it's not already empty. + tctx.unresolvedPartials.RemoveKey(partialPath) + return nil +} + +// NOTE: we treat partial references in definitions and partials differently because a missing partial +// reference in definition compilation is an error state, where a missing partial reference in a +// partial definition is an indeterminate state. +func translatePartialReference(tctx *translationContext, partialReferenceNode *dslNode, errorOnMissingReference bool) ([]*core.Relation, string, error) { + name, err := partialReferenceNode.GetString(dslshape.NodePartialReferencePredicateName) + if err != nil { + return nil, "", err + } + path, err := tctx.prefixedPath(name) + if err != nil { + return nil, "", err + } + relationsAndPermissions, ok := tctx.compiledPartials[path] + if !ok { + if errorOnMissingReference { + return nil, "", partialReferenceNode.Errorf("could not find partial reference with name %s", path) + } + // If the partial isn't present and we're not throwing an error, we return the name of the missing partial + // This behavior supports partial collection + return nil, path, nil + } + return relationsAndPermissions, "", nil +} + +// Translate use node and add flag to list of enabled flags +func translateUseFlag(tctx *translationContext, useFlagNode *dslNode) error { + flagName, err := useFlagNode.GetString(dslshape.NodeUseFlagPredicateName) + if err != nil { + return err + } + if slices.Contains(tctx.enabledFlags, flagName) { + return useFlagNode.Errorf("found duplicate use flag: %s", flagName) + } + tctx.enabledFlags = append(tctx.enabledFlags, flagName) + return nil +} diff --git a/vendor/github.com/authzed/spicedb/pkg/composableschemadsl/dslshape/doc.go b/vendor/github.com/authzed/spicedb/pkg/composableschemadsl/dslshape/doc.go new file mode 100644 index 0000000..457bd0b --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/composableschemadsl/dslshape/doc.go @@ -0,0 +1,2 @@ +// Package dslshape defines the types representing the structure of schema DSL. +package dslshape diff --git a/vendor/github.com/authzed/spicedb/pkg/composableschemadsl/dslshape/dslshape.go b/vendor/github.com/authzed/spicedb/pkg/composableschemadsl/dslshape/dslshape.go new file mode 100644 index 0000000..e130c80 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/composableschemadsl/dslshape/dslshape.go @@ -0,0 +1,228 @@ +//go:generate go run golang.org/x/tools/cmd/stringer -type=NodeType -output zz_generated.nodetype_string.go + +package dslshape + +// NodeType identifies the type of AST node. +type NodeType int + +const ( + // Top-level + NodeTypeError NodeType = iota // error occurred; value is text of error + NodeTypeFile // The file root node + NodeTypeComment // A single or multiline comment + NodeTypeUseFlag // A use flag + + NodeTypeDefinition // A definition. + NodeTypeCaveatDefinition // A caveat definition. + + NodeTypeCaveatParameter // A caveat parameter. + NodeTypeCaveatExpression // A caveat expression. + + NodeTypeRelation // A relation + NodeTypePermission // A permission + + NodeTypeTypeReference // A type reference + NodeTypeSpecificTypeReference // A reference to a specific type. + NodeTypeCaveatReference // A caveat reference under a type. + NodeTypeTraitReference // A trait reference under a typr. + + NodeTypeUnionExpression + NodeTypeIntersectExpression + NodeTypeExclusionExpression + + NodeTypeArrowExpression // A TTU in arrow form. + + NodeTypeIdentifier // An identifier under an expression. + NodeTypeNilExpression // A nil keyword + + NodeTypeCaveatTypeReference // A type reference for a caveat parameter. + + NodeTypeImport + NodeTypePartial + NodeTypePartialReference // A location where a partial is referenced +) + +const ( + // + // All nodes + // + // The source of this node. + NodePredicateSource = "input-source" + + // The rune position in the input string at which this node begins. + NodePredicateStartRune = "start-rune" + + // The rune position in the input string at which this node ends. + NodePredicateEndRune = "end-rune" + + // A direct child of this node. Implementations should handle the ordering + // automatically for this predicate. + NodePredicateChild = "child-node" + + // + // NodeTypeError + // + + // The message for the parsing error. + NodePredicateErrorMessage = "error-message" + + // The (optional) source to highlight for the parsing error. + NodePredicateErrorSource = "error-source" + + // + // NodeTypeComment + // + + // The value of the comment, including its delimeter(s) + NodeCommentPredicateValue = "comment-value" + + // + // NodeTypeUseFlag + // + + // The name of the use flag. + NodeUseFlagPredicateName = "use-flag-name" + + // + // NodeTypeDefinition + // + + // The name of the definition + NodeDefinitionPredicateName = "definition-name" + + // + // NodeTypeCaveatDefinition + // + + // The name of the definition + NodeCaveatDefinitionPredicateName = "caveat-definition-name" + + // The parameters for the definition. + NodeCaveatDefinitionPredicateParameters = "parameters" + + // The link to the expression for the definition. + NodeCaveatDefinitionPredicateExpession = "caveat-definition-expression" + + // + // NodeTypeCaveatExpression + // + + // The raw CEL expression, in string form. + NodeCaveatExpressionPredicateExpression = "caveat-expression-expressionstr" + + // + // NodeTypeCaveatParameter + // + + // The name of the parameter + NodeCaveatParameterPredicateName = "caveat-parameter-name" + + // The defined type of the caveat parameter. + NodeCaveatParameterPredicateType = "caveat-parameter-type" + + // + // NodeTypeCaveatTypeReference + // + + // The type for the caveat type reference. + NodeCaveatTypeReferencePredicateType = "type-name" + + // The child type(s) for the type reference. + NodeCaveatTypeReferencePredicateChildTypes = "child-types" + + // + // NodeTypeRelation + NodeTypePermission + // + + // The name of the relation/permission + NodePredicateName = "relation-name" + + // + // NodeTypeRelation + // + + // The allowed types for the relation. + NodeRelationPredicateAllowedTypes = "allowed-types" + + // + // NodeTypeTypeReference + // + + // A type under a type reference. + NodeTypeReferencePredicateType = "type-ref-type" + + // + // NodeTypeSpecificTypeReference + // + + // A type under a type reference. + NodeSpecificReferencePredicateType = "type-name" + + // A relation under a type reference. + NodeSpecificReferencePredicateRelation = "relation-name" + + // A wildcard under a type reference. + NodeSpecificReferencePredicateWildcard = "type-wildcard" + + // A caveat under a type reference. + NodeSpecificReferencePredicateCaveat = "caveat" + + // A trait under a type reference. + NodeSpecificReferencePredicateTrait = "trait" + + // + // NodeTypeCaveatReference + // + + // The caveat name under the caveat. + NodeCaveatPredicateCaveat = "caveat-name" + + // + // NodeTypeTraitReference + // + + // The trait name under the trait. + NodeTraitPredicateTrait = "trait-name" + + // + // NodeTypePermission + // + + // The expression to compute the permission. + NodePermissionPredicateComputeExpression = "compute-expression" + + // + // NodeTypeArrowExpression + // + + // The name of the function in the arrow expression. + NodeArrowExpressionFunctionName = "function-name" + + // + // NodeTypeIdentifer + // + + // The value of the identifier. + NodeIdentiferPredicateValue = "identifier-value" + + // + // NodeTypeUnionExpression + NodeTypeIntersectExpression + NodeTypeExclusionExpression + NodeTypeArrowExpression + // + NodeExpressionPredicateLeftExpr = "left-expr" + NodeExpressionPredicateRightExpr = "right-expr" + + // + // NodeTypeImport + // + NodeImportPredicatePath = "import-path" + + // + // NodeTypePartial + // + NodePartialPredicateName = "partial-name" + + // + // NodeTypePartialReference + // + NodePartialReferencePredicateName = "partial-reference-name" +) diff --git a/vendor/github.com/authzed/spicedb/pkg/composableschemadsl/dslshape/zz_generated.nodetype_string.go b/vendor/github.com/authzed/spicedb/pkg/composableschemadsl/dslshape/zz_generated.nodetype_string.go new file mode 100644 index 0000000..c42de6d --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/composableschemadsl/dslshape/zz_generated.nodetype_string.go @@ -0,0 +1,46 @@ +// Code generated by "stringer -type=NodeType -output zz_generated.nodetype_string.go"; DO NOT EDIT. + +package dslshape + +import "strconv" + +func _() { + // An "invalid array index" compiler error signifies that the constant values have changed. + // Re-run the stringer command to generate them again. + var x [1]struct{} + _ = x[NodeTypeError-0] + _ = x[NodeTypeFile-1] + _ = x[NodeTypeComment-2] + _ = x[NodeTypeUseFlag-3] + _ = x[NodeTypeDefinition-4] + _ = x[NodeTypeCaveatDefinition-5] + _ = x[NodeTypeCaveatParameter-6] + _ = x[NodeTypeCaveatExpression-7] + _ = x[NodeTypeRelation-8] + _ = x[NodeTypePermission-9] + _ = x[NodeTypeTypeReference-10] + _ = x[NodeTypeSpecificTypeReference-11] + _ = x[NodeTypeCaveatReference-12] + _ = x[NodeTypeTraitReference-13] + _ = x[NodeTypeUnionExpression-14] + _ = x[NodeTypeIntersectExpression-15] + _ = x[NodeTypeExclusionExpression-16] + _ = x[NodeTypeArrowExpression-17] + _ = x[NodeTypeIdentifier-18] + _ = x[NodeTypeNilExpression-19] + _ = x[NodeTypeCaveatTypeReference-20] + _ = x[NodeTypeImport-21] + _ = x[NodeTypePartial-22] + _ = x[NodeTypePartialReference-23] +} + +const _NodeType_name = "NodeTypeErrorNodeTypeFileNodeTypeCommentNodeTypeUseFlagNodeTypeDefinitionNodeTypeCaveatDefinitionNodeTypeCaveatParameterNodeTypeCaveatExpressionNodeTypeRelationNodeTypePermissionNodeTypeTypeReferenceNodeTypeSpecificTypeReferenceNodeTypeCaveatReferenceNodeTypeTraitReferenceNodeTypeUnionExpressionNodeTypeIntersectExpressionNodeTypeExclusionExpressionNodeTypeArrowExpressionNodeTypeIdentifierNodeTypeNilExpressionNodeTypeCaveatTypeReferenceNodeTypeImportNodeTypePartialNodeTypePartialReference" + +var _NodeType_index = [...]uint16{0, 13, 25, 40, 55, 73, 97, 120, 144, 160, 178, 199, 228, 251, 273, 296, 323, 350, 373, 391, 412, 439, 453, 468, 492} + +func (i NodeType) String() string { + if i < 0 || i >= NodeType(len(_NodeType_index)-1) { + return "NodeType(" + strconv.FormatInt(int64(i), 10) + ")" + } + return _NodeType_name[_NodeType_index[i]:_NodeType_index[i+1]] +} diff --git a/vendor/github.com/authzed/spicedb/pkg/composableschemadsl/generator/generator.go b/vendor/github.com/authzed/spicedb/pkg/composableschemadsl/generator/generator.go new file mode 100644 index 0000000..74b6488 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/composableschemadsl/generator/generator.go @@ -0,0 +1,430 @@ +package generator + +import ( + "bufio" + "fmt" + "sort" + "strings" + + "golang.org/x/exp/maps" + + "github.com/authzed/spicedb/pkg/caveats" + caveattypes "github.com/authzed/spicedb/pkg/caveats/types" + "github.com/authzed/spicedb/pkg/composableschemadsl/compiler" + "github.com/authzed/spicedb/pkg/genutil/mapz" + "github.com/authzed/spicedb/pkg/graph" + "github.com/authzed/spicedb/pkg/namespace" + core "github.com/authzed/spicedb/pkg/proto/core/v1" + "github.com/authzed/spicedb/pkg/spiceerrors" +) + +// Ellipsis is the relation name for terminal subjects. +const Ellipsis = "..." + +// MaxSingleLineCommentLength sets the maximum length for a comment to made single line. +const MaxSingleLineCommentLength = 70 // 80 - the comment parts and some padding + +// GenerateSchema generates a DSL view of the given schema. +func GenerateSchema(definitions []compiler.SchemaDefinition) (string, bool, error) { + return GenerateSchemaWithCaveatTypeSet(definitions, caveattypes.Default.TypeSet) +} + +func GenerateSchemaWithCaveatTypeSet(definitions []compiler.SchemaDefinition, caveatTypeSet *caveattypes.TypeSet) (string, bool, error) { + generated := make([]string, 0, len(definitions)) + flags := mapz.NewSet[string]() + + result := true + for _, definition := range definitions { + switch def := definition.(type) { + case *core.CaveatDefinition: + generatedCaveat, ok, err := GenerateCaveatSource(def, caveatTypeSet) + if err != nil { + return "", false, err + } + + result = result && ok + generated = append(generated, generatedCaveat) + + case *core.NamespaceDefinition: + generatedSchema, defFlags, ok, err := generateDefinitionSource(def, caveatTypeSet) + if err != nil { + return "", false, err + } + + result = result && ok + generated = append(generated, generatedSchema) + flags.Extend(defFlags) + + default: + return "", false, spiceerrors.MustBugf("unknown type of definition %T in GenerateSchema", def) + } + } + + if !flags.IsEmpty() { + flagsSlice := flags.AsSlice() + sort.Strings(flagsSlice) + + for _, flag := range flagsSlice { + generated = append([]string{"use " + flag}, generated...) + } + } + + return strings.Join(generated, "\n\n"), result, nil +} + +// GenerateCaveatSource generates a DSL view of the given caveat definition. +func GenerateCaveatSource(caveat *core.CaveatDefinition, caveatTypeSet *caveattypes.TypeSet) (string, bool, error) { + generator := &sourceGenerator{ + indentationLevel: 0, + hasNewline: true, + hasBlankline: true, + hasNewScope: true, + caveatTypeSet: caveatTypeSet, + } + + err := generator.emitCaveat(caveat) + if err != nil { + return "", false, err + } + + return generator.buf.String(), !generator.hasIssue, nil +} + +// GenerateSource generates a DSL view of the given namespace definition. +func GenerateSource(namespace *core.NamespaceDefinition, caveatTypeSet *caveattypes.TypeSet) (string, bool, error) { + source, _, ok, err := generateDefinitionSource(namespace, caveatTypeSet) + return source, ok, err +} + +func generateDefinitionSource(namespace *core.NamespaceDefinition, caveatTypeSet *caveattypes.TypeSet) (string, []string, bool, error) { + generator := &sourceGenerator{ + indentationLevel: 0, + hasNewline: true, + hasBlankline: true, + hasNewScope: true, + flags: mapz.NewSet[string](), + caveatTypeSet: caveatTypeSet, + } + + err := generator.emitNamespace(namespace) + if err != nil { + return "", nil, false, err + } + + return generator.buf.String(), generator.flags.AsSlice(), !generator.hasIssue, nil +} + +// GenerateRelationSource generates a DSL view of the given relation definition. +func GenerateRelationSource(relation *core.Relation, caveatTypeSet *caveattypes.TypeSet) (string, error) { + generator := &sourceGenerator{ + indentationLevel: 0, + hasNewline: true, + hasBlankline: true, + hasNewScope: true, + caveatTypeSet: caveatTypeSet, + } + + err := generator.emitRelation(relation) + if err != nil { + return "", err + } + + return generator.buf.String(), nil +} + +func (sg *sourceGenerator) emitCaveat(caveat *core.CaveatDefinition) error { + sg.emitComments(caveat.Metadata) + sg.append("caveat ") + sg.append(caveat.Name) + sg.append("(") + + parameterNames := maps.Keys(caveat.ParameterTypes) + sort.Strings(parameterNames) + + for index, paramName := range parameterNames { + if index > 0 { + sg.append(", ") + } + + decoded, err := caveattypes.DecodeParameterType(sg.caveatTypeSet, caveat.ParameterTypes[paramName]) + if err != nil { + return fmt.Errorf("invalid parameter type on caveat: %w", err) + } + + sg.append(paramName) + sg.append(" ") + sg.append(decoded.String()) + } + + sg.append(")") + + sg.append(" {") + sg.appendLine() + sg.indent() + sg.markNewScope() + + parameterTypes, err := caveattypes.DecodeParameterTypes(sg.caveatTypeSet, caveat.ParameterTypes) + if err != nil { + return fmt.Errorf("invalid caveat parameters: %w", err) + } + + deserializedExpression, err := caveats.DeserializeCaveatWithTypeSet(sg.caveatTypeSet, caveat.SerializedExpression, parameterTypes) + if err != nil { + return fmt.Errorf("invalid caveat expression bytes: %w", err) + } + + exprString, err := deserializedExpression.ExprString() + if err != nil { + return fmt.Errorf("invalid caveat expression: %w", err) + } + + sg.append(strings.TrimSpace(exprString)) + sg.appendLine() + + sg.dedent() + sg.append("}") + return nil +} + +func (sg *sourceGenerator) emitNamespace(namespace *core.NamespaceDefinition) error { + sg.emitComments(namespace.Metadata) + sg.append("definition ") + sg.append(namespace.Name) + + if len(namespace.Relation) == 0 { + sg.append(" {}") + return nil + } + + sg.append(" {") + sg.appendLine() + sg.indent() + sg.markNewScope() + + for _, relation := range namespace.Relation { + err := sg.emitRelation(relation) + if err != nil { + return err + } + } + + sg.dedent() + sg.append("}") + return nil +} + +func (sg *sourceGenerator) emitRelation(relation *core.Relation) error { + hasThis, err := graph.HasThis(relation.UsersetRewrite) + if err != nil { + return err + } + + isPermission := relation.UsersetRewrite != nil && !hasThis + + sg.emitComments(relation.Metadata) + if isPermission { + sg.append("permission ") + } else { + sg.append("relation ") + } + + sg.append(relation.Name) + + if !isPermission { + sg.append(": ") + if relation.TypeInformation == nil || relation.TypeInformation.AllowedDirectRelations == nil || len(relation.TypeInformation.AllowedDirectRelations) == 0 { + sg.appendIssue("missing allowed types") + } else { + for index, allowedRelation := range relation.TypeInformation.AllowedDirectRelations { + if index > 0 { + sg.append(" | ") + } + + sg.emitAllowedRelation(allowedRelation) + } + } + } + + if relation.UsersetRewrite != nil { + sg.append(" = ") + sg.mustEmitRewrite(relation.UsersetRewrite) + } + + sg.appendLine() + return nil +} + +func (sg *sourceGenerator) emitAllowedRelation(allowedRelation *core.AllowedRelation) { + sg.append(allowedRelation.Namespace) + if allowedRelation.GetRelation() != "" && allowedRelation.GetRelation() != Ellipsis { + sg.append("#") + sg.append(allowedRelation.GetRelation()) + } + if allowedRelation.GetPublicWildcard() != nil { + sg.append(":*") + } + + hasExpirationTrait := allowedRelation.GetRequiredExpiration() != nil + hasCaveat := allowedRelation.GetRequiredCaveat() != nil + + if hasExpirationTrait || hasCaveat { + sg.append(" with ") + if hasCaveat { + sg.append(allowedRelation.RequiredCaveat.CaveatName) + } + + if hasExpirationTrait { + sg.flags.Add("expiration") + + if hasCaveat { + sg.append(" and ") + } + + sg.append("expiration") + } + } +} + +func (sg *sourceGenerator) mustEmitRewrite(rewrite *core.UsersetRewrite) { + switch rw := rewrite.RewriteOperation.(type) { + case *core.UsersetRewrite_Union: + sg.emitRewriteOps(rw.Union, "+") + case *core.UsersetRewrite_Intersection: + sg.emitRewriteOps(rw.Intersection, "&") + case *core.UsersetRewrite_Exclusion: + sg.emitRewriteOps(rw.Exclusion, "-") + default: + panic(spiceerrors.MustBugf("unknown rewrite operation %T", rw)) + } +} + +func (sg *sourceGenerator) emitRewriteOps(setOp *core.SetOperation, op string) { + for index, child := range setOp.Child { + if index > 0 { + sg.append(" " + op + " ") + } + + sg.mustEmitSetOpChild(child) + } +} + +func (sg *sourceGenerator) isAllUnion(rewrite *core.UsersetRewrite) bool { + switch rw := rewrite.RewriteOperation.(type) { + case *core.UsersetRewrite_Union: + for _, setOpChild := range rw.Union.Child { + switch child := setOpChild.ChildType.(type) { + case *core.SetOperation_Child_UsersetRewrite: + if !sg.isAllUnion(child.UsersetRewrite) { + return false + } + default: + continue + } + } + return true + default: + return false + } +} + +func (sg *sourceGenerator) mustEmitSetOpChild(setOpChild *core.SetOperation_Child) { + switch child := setOpChild.ChildType.(type) { + case *core.SetOperation_Child_UsersetRewrite: + if sg.isAllUnion(child.UsersetRewrite) { + sg.mustEmitRewrite(child.UsersetRewrite) + break + } + + sg.append("(") + sg.mustEmitRewrite(child.UsersetRewrite) + sg.append(")") + + case *core.SetOperation_Child_XThis: + sg.appendIssue("_this unsupported here. Please rewrite into a relation and permission") + + case *core.SetOperation_Child_XNil: + sg.append("nil") + + case *core.SetOperation_Child_ComputedUserset: + sg.append(child.ComputedUserset.Relation) + + case *core.SetOperation_Child_TupleToUserset: + sg.append(child.TupleToUserset.Tupleset.Relation) + sg.append("->") + sg.append(child.TupleToUserset.ComputedUserset.Relation) + + case *core.SetOperation_Child_FunctionedTupleToUserset: + sg.append(child.FunctionedTupleToUserset.Tupleset.Relation) + sg.append(".") + + switch child.FunctionedTupleToUserset.Function { + case core.FunctionedTupleToUserset_FUNCTION_ALL: + sg.append("all") + + case core.FunctionedTupleToUserset_FUNCTION_ANY: + sg.append("any") + + default: + panic(spiceerrors.MustBugf("unknown function %v", child.FunctionedTupleToUserset.Function)) + } + + sg.append("(") + sg.append(child.FunctionedTupleToUserset.ComputedUserset.Relation) + sg.append(")") + + default: + panic(spiceerrors.MustBugf("unknown child type %T", child)) + } +} + +func (sg *sourceGenerator) emitComments(metadata *core.Metadata) { + if len(namespace.GetComments(metadata)) > 0 { + sg.ensureBlankLineOrNewScope() + } + + for _, comment := range namespace.GetComments(metadata) { + sg.appendComment(comment) + } +} + +func (sg *sourceGenerator) appendComment(comment string) { + switch { + case strings.HasPrefix(comment, "/*"): + stripped := strings.TrimSpace(comment) + + if strings.HasPrefix(stripped, "/**") { + stripped = strings.TrimPrefix(stripped, "/**") + sg.append("/**") + } else { + stripped = strings.TrimPrefix(stripped, "/*") + sg.append("/*") + } + + stripped = strings.TrimSuffix(stripped, "*/") + stripped = strings.TrimSpace(stripped) + + requireMultiline := len(stripped) > MaxSingleLineCommentLength || strings.ContainsRune(stripped, '\n') + + if requireMultiline { + sg.appendLine() + scanner := bufio.NewScanner(strings.NewReader(stripped)) + for scanner.Scan() { + sg.append(" * ") + sg.append(strings.TrimSpace(strings.TrimPrefix(strings.TrimSpace(scanner.Text()), "*"))) + sg.appendLine() + } + sg.append(" */") + sg.appendLine() + } else { + sg.append(" ") + sg.append(strings.TrimSpace(strings.TrimPrefix(strings.TrimSpace(stripped), "*"))) + sg.append(" */") + sg.appendLine() + } + + case strings.HasPrefix(comment, "//"): + sg.append("// ") + sg.append(strings.TrimSpace(strings.TrimPrefix(strings.TrimSpace(comment), "//"))) + sg.appendLine() + } +} diff --git a/vendor/github.com/authzed/spicedb/pkg/composableschemadsl/generator/generator_impl.go b/vendor/github.com/authzed/spicedb/pkg/composableschemadsl/generator/generator_impl.go new file mode 100644 index 0000000..a23524c --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/composableschemadsl/generator/generator_impl.go @@ -0,0 +1,83 @@ +package generator + +import ( + "strings" + + caveattypes "github.com/authzed/spicedb/pkg/caveats/types" + "github.com/authzed/spicedb/pkg/genutil/mapz" +) + +type sourceGenerator struct { + buf strings.Builder // The buffer for the new source code. + indentationLevel int // The current indentation level. + hasNewline bool // Whether there is a newline at the end of the buffer. + hasBlankline bool // Whether there is a blank line at the end of the buffer. + hasIssue bool // Whether there is a translation issue. + hasNewScope bool // Whether there is a new scope at the end of the buffer. + existingLineLength int // Length of the existing line. + flags *mapz.Set[string] // The flags added while generating. + caveatTypeSet *caveattypes.TypeSet // The caveat type set used for generating. +} + +// ensureBlankLineOrNewScope ensures that there is a blank line or new scope at the tail of the buffer. If not, +// a new line is added. +func (sg *sourceGenerator) ensureBlankLineOrNewScope() { + if !sg.hasBlankline && !sg.hasNewScope { + sg.appendLine() + } +} + +// indent increases the current indentation. +func (sg *sourceGenerator) indent() { + sg.indentationLevel = sg.indentationLevel + 1 +} + +// dedent decreases the current indentation. +func (sg *sourceGenerator) dedent() { + sg.indentationLevel = sg.indentationLevel - 1 +} + +// appendIssue adds an issue found in generation. +func (sg *sourceGenerator) appendIssue(description string) { + sg.append("/* ") + sg.append(description) + sg.append(" */") + sg.hasIssue = true +} + +// append adds the given value to the buffer, indenting as necessary. +func (sg *sourceGenerator) append(value string) { + for _, currentRune := range value { + if currentRune == '\n' { + if sg.hasNewline { + sg.hasBlankline = true + } + + sg.buf.WriteRune('\n') + sg.hasNewline = true + sg.existingLineLength = 0 + continue + } + + sg.hasBlankline = false + sg.hasNewScope = false + + if sg.hasNewline { + sg.buf.WriteString(strings.Repeat("\t", sg.indentationLevel)) + sg.hasNewline = false + sg.existingLineLength += sg.indentationLevel + } + + sg.existingLineLength++ + sg.buf.WriteRune(currentRune) + } +} + +// appendLine adds a newline. +func (sg *sourceGenerator) appendLine() { + sg.append("\n") +} + +func (sg *sourceGenerator) markNewScope() { + sg.hasNewScope = true +} diff --git a/vendor/github.com/authzed/spicedb/pkg/composableschemadsl/input/inputsource.go b/vendor/github.com/authzed/spicedb/pkg/composableschemadsl/input/inputsource.go new file mode 100644 index 0000000..3bd0437 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/composableschemadsl/input/inputsource.go @@ -0,0 +1,224 @@ +package input + +import ( + "fmt" +) + +// BytePosition represents the byte position in a piece of code. +type BytePosition int + +// Position represents a position in an arbitrary source file. +type Position struct { + // LineNumber is the 0-indexed line number. + LineNumber int + + // ColumnPosition is the 0-indexed column position on the line. + ColumnPosition int +} + +// Source represents the path of a source file. +type Source string + +// RangeForRunePosition returns a source range over this source file. +func (is Source) RangeForRunePosition(runePosition int, mapper PositionMapper) SourceRange { + return is.RangeForRunePositions(runePosition, runePosition, mapper) +} + +// PositionForRunePosition returns a source position over this source file. +func (is Source) PositionForRunePosition(runePosition int, mapper PositionMapper) SourcePosition { + return runeIndexedPosition{is, mapper, runePosition} +} + +// PositionFromLineAndColumn returns a source position at the given line and column in this source file. +func (is Source) PositionFromLineAndColumn(lineNumber int, columnPosition int, mapper PositionMapper) SourcePosition { + return lcIndexedPosition{is, mapper, Position{lineNumber, columnPosition}} +} + +// RangeForRunePositions returns a source range over this source file. +func (is Source) RangeForRunePositions(startRune int, endRune int, mapper PositionMapper) SourceRange { + return sourceRange{is, runeIndexedPosition{is, mapper, startRune}, runeIndexedPosition{is, mapper, endRune}} +} + +// RangeForLineAndColPositions returns a source range over this source file. +func (is Source) RangeForLineAndColPositions(start Position, end Position, mapper PositionMapper) SourceRange { + return sourceRange{is, lcIndexedPosition{is, mapper, start}, lcIndexedPosition{is, mapper, end}} +} + +// PositionMapper defines an interface for converting rune position <-> line+col position +// under source files. +type PositionMapper interface { + // RunePositionToLineAndCol converts the given 0-indexed rune position under the given source file + // into a 0-indexed line number and column position. + RunePositionToLineAndCol(runePosition int, path Source) (int, int, error) + + // LineAndColToRunePosition converts the given 0-indexed line number and column position under the + // given source file into a 0-indexed rune position. + LineAndColToRunePosition(lineNumber int, colPosition int, path Source) (int, error) + + // TextForLine returns the text for the specified line number. + TextForLine(lineNumber int, path Source) (string, error) +} + +// SourceRange represents a range inside a source file. +type SourceRange interface { + // Source is the input source for this range. + Source() Source + + // Start is the starting position of the source range. + Start() SourcePosition + + // End is the ending position (inclusive) of the source range. If the same as the Start, + // this range represents a single position. + End() SourcePosition + + // ContainsPosition returns true if the given range contains the given position. + ContainsPosition(position SourcePosition) (bool, error) + + // AtStartPosition returns a SourceRange located only at the starting position of this range. + AtStartPosition() SourceRange + + // String returns a (somewhat) human-readable form of the range. + String() string +} + +// SourcePosition represents a single position in a source file. +type SourcePosition interface { + // Source is the input source for this position. + Source() Source + + // RunePosition returns the 0-indexed rune position in the source file. + RunePosition() (int, error) + + // LineAndColumn returns the 0-indexed line number and column position in the source file. + LineAndColumn() (int, int, error) + + // LineText returns the text of the line for this position. + LineText() (string, error) + + // String returns a (somewhat) human-readable form of the position. + String() string +} + +// sourceRange implements the SourceRange interface. +type sourceRange struct { + source Source + start SourcePosition + end SourcePosition +} + +func (sr sourceRange) Source() Source { + return sr.source +} + +func (sr sourceRange) Start() SourcePosition { + return sr.start +} + +func (sr sourceRange) End() SourcePosition { + return sr.end +} + +func (sr sourceRange) AtStartPosition() SourceRange { + return sourceRange{sr.source, sr.start, sr.end} +} + +func (sr sourceRange) ContainsPosition(position SourcePosition) (bool, error) { + if position.Source() != sr.source { + return false, nil + } + + startRune, err := sr.start.RunePosition() + if err != nil { + return false, err + } + + endRune, err := sr.end.RunePosition() + if err != nil { + return false, err + } + + positionRune, err := position.RunePosition() + if err != nil { + return false, err + } + + return positionRune >= startRune && positionRune <= endRune, nil +} + +func (sr sourceRange) String() string { + return fmt.Sprintf("%v -> %v", sr.start, sr.end) +} + +// runeIndexedPosition implements the SourcePosition interface over a rune position. +type runeIndexedPosition struct { + source Source + mapper PositionMapper + runePosition int +} + +func (ris runeIndexedPosition) Source() Source { + return ris.source +} + +func (ris runeIndexedPosition) RunePosition() (int, error) { + return ris.runePosition, nil +} + +func (ris runeIndexedPosition) LineAndColumn() (int, int, error) { + if ris.runePosition == 0 { + return 0, 0, nil + } + if ris.mapper == nil { + return -1, -1, fmt.Errorf("nil mapper") + } + return ris.mapper.RunePositionToLineAndCol(ris.runePosition, ris.source) +} + +func (ris runeIndexedPosition) String() string { + return fmt.Sprintf("%s@%v (rune)", ris.source, ris.runePosition) +} + +func (ris runeIndexedPosition) LineText() (string, error) { + lineNumber, _, err := ris.LineAndColumn() + if err != nil { + return "", err + } + + return ris.mapper.TextForLine(lineNumber, ris.source) +} + +// lcIndexedPosition implements the SourcePosition interface over a line and colu,n position. +type lcIndexedPosition struct { + source Source + mapper PositionMapper + lcPosition Position +} + +func (lcip lcIndexedPosition) Source() Source { + return lcip.source +} + +func (lcip lcIndexedPosition) String() string { + return fmt.Sprintf("%s@%v:%v (line/col)", lcip.source, lcip.lcPosition.LineNumber, lcip.lcPosition.ColumnPosition) +} + +func (lcip lcIndexedPosition) RunePosition() (int, error) { + if lcip.lcPosition.LineNumber == 0 && lcip.lcPosition.ColumnPosition == 0 { + return 0, nil + } + if lcip.mapper == nil { + return -1, fmt.Errorf("nil mapper") + } + return lcip.mapper.LineAndColToRunePosition(lcip.lcPosition.LineNumber, lcip.lcPosition.ColumnPosition, lcip.source) +} + +func (lcip lcIndexedPosition) LineAndColumn() (int, int, error) { + return lcip.lcPosition.LineNumber, lcip.lcPosition.ColumnPosition, nil +} + +func (lcip lcIndexedPosition) LineText() (string, error) { + if lcip.mapper == nil { + return "", fmt.Errorf("nil mapper") + } + return lcip.mapper.TextForLine(lcip.lcPosition.LineNumber, lcip.source) +} diff --git a/vendor/github.com/authzed/spicedb/pkg/composableschemadsl/input/sourcepositionmapper.go b/vendor/github.com/authzed/spicedb/pkg/composableschemadsl/input/sourcepositionmapper.go new file mode 100644 index 0000000..1bca03c --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/composableschemadsl/input/sourcepositionmapper.go @@ -0,0 +1,95 @@ +package input + +import ( + "fmt" + "strings" + + "github.com/emirpasic/gods/trees/redblacktree" +) + +// SourcePositionMapper defines a helper struct for cached, faster lookup of rune position <-> +// (line, column) for a specific source file. +type SourcePositionMapper struct { + // rangeTree holds a tree that maps from rune position to a line and start position. + rangeTree *redblacktree.Tree + + // lineMap holds a map from line number to rune positions for that line. + lineMap map[int]inclusiveRange +} + +// EmptySourcePositionMapper returns an empty source position mapper. +func EmptySourcePositionMapper() SourcePositionMapper { + rangeTree := redblacktree.NewWith(inclusiveComparator) + return SourcePositionMapper{rangeTree, map[int]inclusiveRange{}} +} + +// CreateSourcePositionMapper returns a source position mapper for the contents of a source file. +func CreateSourcePositionMapper(contents []byte) SourcePositionMapper { + lines := strings.Split(string(contents), "\n") + rangeTree := redblacktree.NewWith(inclusiveComparator) + lineMap := map[int]inclusiveRange{} + + currentStart := int(0) + for index, line := range lines { + lineEnd := currentStart + len(line) + rangeTree.Put(inclusiveRange{currentStart, lineEnd}, lineAndStart{index, currentStart}) + lineMap[index] = inclusiveRange{currentStart, lineEnd} + currentStart = lineEnd + 1 + } + + return SourcePositionMapper{rangeTree, lineMap} +} + +type inclusiveRange struct { + start int + end int +} + +type lineAndStart struct { + lineNumber int + startPosition int +} + +func inclusiveComparator(a, b interface{}) int { + i1 := a.(inclusiveRange) + i2 := b.(inclusiveRange) + + if i1.start >= i2.start && i1.end <= i2.end { + return 0 + } + + diff := int64(i1.start) - int64(i2.start) + + if diff < 0 { + return -1 + } + if diff > 0 { + return 1 + } + return 0 +} + +// RunePositionToLineAndCol returns the line number and column position of the rune position in source. +func (spm SourcePositionMapper) RunePositionToLineAndCol(runePosition int) (int, int, error) { + ls, found := spm.rangeTree.Get(inclusiveRange{runePosition, runePosition}) + if !found { + return 0, 0, fmt.Errorf("unknown rune position %v in source file", runePosition) + } + + las := ls.(lineAndStart) + return las.lineNumber, runePosition - las.startPosition, nil +} + +// LineAndColToRunePosition returns the rune position of the line number and column position in source. +func (spm SourcePositionMapper) LineAndColToRunePosition(lineNumber int, colPosition int) (int, error) { + lineRuneInfo, hasLine := spm.lineMap[lineNumber] + if !hasLine { + return 0, fmt.Errorf("unknown line %v in source file", lineNumber) + } + + if colPosition > lineRuneInfo.end-lineRuneInfo.start { + return 0, fmt.Errorf("column position %v not found on line %v in source file", colPosition, lineNumber) + } + + return lineRuneInfo.start + colPosition, nil +} diff --git a/vendor/github.com/authzed/spicedb/pkg/composableschemadsl/lexer/flaggablelexer.go b/vendor/github.com/authzed/spicedb/pkg/composableschemadsl/lexer/flaggablelexer.go new file mode 100644 index 0000000..1ae99af --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/composableschemadsl/lexer/flaggablelexer.go @@ -0,0 +1,59 @@ +package lexer + +// FlaggableLexer wraps a lexer, automatically translating tokens based on flags, if any. +type FlaggableLexer struct { + lex *Lexer // a reference to the lexer used for tokenization + enabledFlags map[string]transformer // flags that are enabled + seenDefinition bool + afterUseIdentifier bool +} + +// NewFlaggableLexer returns a new FlaggableLexer for the given lexer. +func NewFlaggableLexer(lex *Lexer) *FlaggableLexer { + return &FlaggableLexer{ + lex: lex, + enabledFlags: map[string]transformer{}, + } +} + +// Close stops the lexer from running. +func (l *FlaggableLexer) Close() { + l.lex.Close() +} + +// NextToken returns the next token found in the lexer. +func (l *FlaggableLexer) NextToken() Lexeme { + nextToken := l.lex.nextToken() + + // Look for `use somefeature` + if nextToken.Kind == TokenTypeIdentifier { + // Only allowed until we've seen a definition of some kind. + if !l.seenDefinition { + if l.afterUseIdentifier { + if transformer, ok := Flags[nextToken.Value]; ok { + l.enabledFlags[nextToken.Value] = transformer + } + + l.afterUseIdentifier = false + } else { + l.afterUseIdentifier = nextToken.Value == "use" + } + } + } + + if nextToken.Kind == TokenTypeKeyword && nextToken.Value == "definition" { + l.seenDefinition = true + } + if nextToken.Kind == TokenTypeKeyword && nextToken.Value == "caveat" { + l.seenDefinition = true + } + + for _, handler := range l.enabledFlags { + updated, ok := handler(nextToken) + if ok { + return updated + } + } + + return nextToken +} diff --git a/vendor/github.com/authzed/spicedb/pkg/composableschemadsl/lexer/flags.go b/vendor/github.com/authzed/spicedb/pkg/composableschemadsl/lexer/flags.go new file mode 100644 index 0000000..3bfbbde --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/composableschemadsl/lexer/flags.go @@ -0,0 +1,26 @@ +package lexer + +// FlagExpiration indicates that `expiration` is supported as a first-class +// feature in the schema. +const FlagExpiration = "expiration" + +type transformer func(lexeme Lexeme) (Lexeme, bool) + +// Flags is a map of flag names to their corresponding transformers. +var Flags = map[string]transformer{ + FlagExpiration: func(lexeme Lexeme) (Lexeme, bool) { + // `expiration` becomes a keyword. + if lexeme.Kind == TokenTypeIdentifier && lexeme.Value == "expiration" { + lexeme.Kind = TokenTypeKeyword + return lexeme, true + } + + // `and` becomes a keyword. + if lexeme.Kind == TokenTypeIdentifier && lexeme.Value == "and" { + lexeme.Kind = TokenTypeKeyword + return lexeme, true + } + + return lexeme, false + }, +} diff --git a/vendor/github.com/authzed/spicedb/pkg/composableschemadsl/lexer/lex.go b/vendor/github.com/authzed/spicedb/pkg/composableschemadsl/lexer/lex.go new file mode 100644 index 0000000..e45b666 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/composableschemadsl/lexer/lex.go @@ -0,0 +1,230 @@ +// Based on design first introduced in: http://blog.golang.org/two-go-talks-lexical-scanning-in-go-and +// Portions copied and modified from: https://github.com/golang/go/blob/master/src/text/template/parse/lex.go + +package lexer + +import ( + "fmt" + "strings" + "sync" + "unicode/utf8" + + "github.com/authzed/spicedb/pkg/composableschemadsl/input" +) + +const EOFRUNE = -1 + +// createLexer creates a new scanner for the input string. +func createLexer(source input.Source, input string) *Lexer { + l := &Lexer{ + source: source, + input: input, + tokens: make(chan Lexeme), + closed: make(chan struct{}), + } + go l.run() + return l +} + +// run runs the state machine for the lexer. +func (l *Lexer) run() { + defer func() { + close(l.tokens) + }() + l.withLock(func() { + l.state = lexSource + }) + var state stateFn + for { + l.withRLock(func() { + state = l.state + }) + if state == nil { + break + } + next := state(l) + l.withLock(func() { + l.state = next + }) + } +} + +// Close stops the lexer from running. +func (l *Lexer) Close() { + close(l.closed) + l.withLock(func() { + l.state = nil + }) +} + +// withLock runs f protected by l's lock +func (l *Lexer) withLock(f func()) { + l.Lock() + defer l.Unlock() + f() +} + +// withRLock runs f protected by l's read lock +func (l *Lexer) withRLock(f func()) { + l.RLock() + defer l.RUnlock() + f() +} + +// Lexeme represents a token returned from scanning the contents of a file. +type Lexeme struct { + Kind TokenType // The type of this lexeme. + Position input.BytePosition // The starting position of this token in the input string. + Value string // The textual value of this token. + Error string // The error associated with the lexeme, if any. +} + +// stateFn represents the state of the scanner as a function that returns the next state. +type stateFn func(*Lexer) stateFn + +// Lexer holds the state of the scanner. +type Lexer struct { + sync.RWMutex + source input.Source // the name of the input; used only for error reports + input string // the string being scanned. + state stateFn // the next lexing function to enter. GUARDED_BY(RWMutex) + pos input.BytePosition // current position in the input + start input.BytePosition // start position of this token + width input.BytePosition // width of last rune read from input + lastPos input.BytePosition // position of most recent token returned by nextToken + tokens chan Lexeme // channel of scanned lexemes + currentToken Lexeme // The current token if any + lastNonIgnoredToken Lexeme // The last token returned that is non-whitespace and non-comment + closed chan struct{} // Holds the closed channel +} + +// nextToken returns the next token from the input. +func (l *Lexer) nextToken() Lexeme { + token := <-l.tokens + l.lastPos = token.Position + return token +} + +// next returns the next rune in the input. +func (l *Lexer) next() rune { + if int(l.pos) >= len(l.input) { + l.width = 0 + return EOFRUNE + } + r, w := utf8.DecodeRuneInString(l.input[l.pos:]) + l.width = input.BytePosition(w) + l.pos += l.width + return r +} + +// peek returns but does not consume the next rune in the input. +func (l *Lexer) peek() rune { + r := l.next() + l.backup() + return r +} + +// backup steps back one rune. Can only be called once per call of next. +func (l *Lexer) backup() { + l.pos -= l.width +} + +// value returns the current value of the token in the lexer. +func (l *Lexer) value() string { + return l.input[l.start:l.pos] +} + +// emit passes an token back to the client. +func (l *Lexer) emit(t TokenType) { + currentToken := Lexeme{t, l.start, l.value(), ""} + + if t != TokenTypeWhitespace && t != TokenTypeMultilineComment && t != TokenTypeSinglelineComment { + l.lastNonIgnoredToken = currentToken + } + + select { + case l.tokens <- currentToken: + l.currentToken = currentToken + l.start = l.pos + + case <-l.closed: + return + } +} + +// errorf returns an error token and terminates the scan by passing +// back a nil pointer that will be the next state, terminating l.nexttoken. +func (l *Lexer) errorf(currentRune rune, format string, args ...interface{}) stateFn { + l.tokens <- Lexeme{TokenTypeError, l.start, string(currentRune), fmt.Sprintf(format, args...)} + return nil +} + +// peekValue looks forward for the given value string. If found, returns true. +func (l *Lexer) peekValue(value string) bool { + for index, runeValue := range value { + r := l.next() + if r != runeValue { + for j := 0; j <= index; j++ { + l.backup() + } + return false + } + } + + for i := 0; i < len(value); i++ { + l.backup() + } + + return true +} + +// accept consumes the next rune if it's from the valid set. +func (l *Lexer) accept(valid string) bool { + if nextRune := l.next(); strings.ContainsRune(valid, nextRune) { + return true + } + l.backup() + return false +} + +// acceptString consumes the full given string, if the next tokens in the stream. +func (l *Lexer) acceptString(value string) bool { + for index, runeValue := range value { + if l.next() != runeValue { + for i := 0; i <= index; i++ { + l.backup() + } + + return false + } + } + + return true +} + +// lexSource scans until EOFRUNE +func lexSource(l *Lexer) stateFn { + return lexerEntrypoint(l) +} + +// checkFn returns whether a rune matches for continue looping. +type checkFn func(r rune) (bool, error) + +func buildLexUntil(findType TokenType, checker checkFn) stateFn { + return func(l *Lexer) stateFn { + for { + r := l.next() + isValid, err := checker(r) + if err != nil { + return l.errorf(r, "%v", err) + } + if !isValid { + l.backup() + break + } + } + + l.emit(findType) + return lexSource + } +} diff --git a/vendor/github.com/authzed/spicedb/pkg/composableschemadsl/lexer/lex_def.go b/vendor/github.com/authzed/spicedb/pkg/composableschemadsl/lexer/lex_def.go new file mode 100644 index 0000000..1e9448a --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/composableschemadsl/lexer/lex_def.go @@ -0,0 +1,367 @@ +//go:generate go run golang.org/x/tools/cmd/stringer -type=TokenType + +package lexer + +import ( + "unicode" + + "github.com/authzed/spicedb/pkg/composableschemadsl/input" +) + +// Lex creates a new scanner for the input string. +func Lex(source input.Source, input string) *Lexer { + return createLexer(source, input) +} + +// TokenType identifies the type of lexer lexemes. +type TokenType int + +const ( + TokenTypeError TokenType = iota // error occurred; value is text of error + + // Synthetic semicolon + TokenTypeSyntheticSemicolon + + TokenTypeEOF + TokenTypeWhitespace + TokenTypeSinglelineComment + TokenTypeMultilineComment + TokenTypeNewline + + TokenTypeKeyword // interface + TokenTypeIdentifier // helloworld + TokenTypeNumber // 123 + + TokenTypeLeftBrace // { + TokenTypeRightBrace // } + TokenTypeLeftParen // ( + TokenTypeRightParen // ) + + TokenTypePipe // | + TokenTypePlus // + + TokenTypeMinus // - + TokenTypeAnd // & + TokenTypeDiv // / + + TokenTypeEquals // = + TokenTypeColon // : + TokenTypeSemicolon // ; + TokenTypeRightArrow // -> + TokenTypeHash // # + TokenTypeEllipsis // ... + TokenTypeStar // * + + // Additional tokens for CEL: https://github.com/google/cel-spec/blob/master/doc/langdef.md#syntax + TokenTypeQuestionMark // ? + TokenTypeConditionalOr // || + TokenTypeConditionalAnd // && + TokenTypeExclamationPoint // ! + TokenTypeLeftBracket // [ + TokenTypeRightBracket // ] + TokenTypePeriod // . + TokenTypeComma // , + TokenTypePercent // % + TokenTypeLessThan // < + TokenTypeGreaterThan // > + TokenTypeLessThanOrEqual // <= + TokenTypeGreaterThanOrEqual // >= + TokenTypeEqualEqual // == + TokenTypeNotEqual // != + TokenTypeString // "...", '...', """...""", '''...''' +) + +// keywords contains the full set of keywords supported. +var keywords = map[string]struct{}{ + "definition": {}, + "caveat": {}, + "relation": {}, + "permission": {}, + "nil": {}, + "with": {}, + "import": {}, + "all": {}, + "any": {}, + "partial": {}, + "use": {}, + "expiration": {}, + // Parking lot for future keywords + "and": {}, + "or": {}, + "not": {}, + "under": {}, + "static": {}, + "if": {}, + "where": {}, + "private": {}, + "public": {}, +} + +// IsKeyword returns whether the specified input string is a reserved keyword. +func IsKeyword(candidate string) bool { + _, ok := keywords[candidate] + return ok +} + +// syntheticPredecessors contains the full set of token types after which, if a newline is found, +// we emit a synthetic semicolon rather than a normal newline token. +var syntheticPredecessors = map[TokenType]bool{ + TokenTypeIdentifier: true, + TokenTypeKeyword: true, + + TokenTypeRightBrace: true, + TokenTypeRightParen: true, + + TokenTypeStar: true, +} + +// lexerEntrypoint scans until EOFRUNE +func lexerEntrypoint(l *Lexer) stateFn { +Loop: + for { + switch r := l.next(); { + case r == EOFRUNE: + break Loop + + case r == '{': + l.emit(TokenTypeLeftBrace) + + case r == '}': + l.emit(TokenTypeRightBrace) + + case r == '(': + l.emit(TokenTypeLeftParen) + + case r == ')': + l.emit(TokenTypeRightParen) + + case r == '+': + l.emit(TokenTypePlus) + + case r == '|': + if l.acceptString("|") { + l.emit(TokenTypeConditionalOr) + } else { + l.emit(TokenTypePipe) + } + + case r == '&': + if l.acceptString("&") { + l.emit(TokenTypeConditionalAnd) + } else { + l.emit(TokenTypeAnd) + } + + case r == '?': + l.emit(TokenTypeQuestionMark) + + case r == '!': + if l.acceptString("=") { + l.emit(TokenTypeNotEqual) + } else { + l.emit(TokenTypeExclamationPoint) + } + + case r == '[': + l.emit(TokenTypeLeftBracket) + + case r == ']': + l.emit(TokenTypeRightBracket) + + case r == '%': + l.emit(TokenTypePercent) + + case r == '<': + if l.acceptString("=") { + l.emit(TokenTypeLessThanOrEqual) + } else { + l.emit(TokenTypeLessThan) + } + + case r == '>': + if l.acceptString("=") { + l.emit(TokenTypeGreaterThanOrEqual) + } else { + l.emit(TokenTypeGreaterThan) + } + + case r == ',': + l.emit(TokenTypeComma) + + case r == '=': + if l.acceptString("=") { + l.emit(TokenTypeEqualEqual) + } else { + l.emit(TokenTypeEquals) + } + + case r == ':': + l.emit(TokenTypeColon) + + case r == ';': + l.emit(TokenTypeSemicolon) + + case r == '#': + l.emit(TokenTypeHash) + + case r == '*': + l.emit(TokenTypeStar) + + case r == '.': + if l.acceptString("..") { + l.emit(TokenTypeEllipsis) + } else { + l.emit(TokenTypePeriod) + } + + case r == '-': + if l.accept(">") { + l.emit(TokenTypeRightArrow) + } else { + l.emit(TokenTypeMinus) + } + + case isSpace(r): + l.emit(TokenTypeWhitespace) + + case isNewline(r): + // If the previous token matches the synthetic semicolon list, + // we emit a synthetic semicolon instead of a simple newline. + if _, ok := syntheticPredecessors[l.lastNonIgnoredToken.Kind]; ok { + l.emit(TokenTypeSyntheticSemicolon) + } else { + l.emit(TokenTypeNewline) + } + + case isAlphaNumeric(r): + l.backup() + return lexIdentifierOrKeyword + + case r == '\'' || r == '"': + l.backup() + return lexStringLiteral + + case r == '/': + // Check for comments. + if l.peekValue("/") { + l.backup() + return lexSinglelineComment + } + + if l.peekValue("*") { + l.backup() + return lexMultilineComment + } + + l.emit(TokenTypeDiv) + default: + return l.errorf(r, "unrecognized character at this location: %#U", r) + } + } + + l.emit(TokenTypeEOF) + return nil +} + +// lexStringLiteral scan until the close of the string literal or EOFRUNE +func lexStringLiteral(l *Lexer) stateFn { + allowNewlines := false + terminator := "" + + if l.acceptString(`"""`) { + terminator = `"""` + allowNewlines = true + } else if l.acceptString(`'''`) { + terminator = `"""` + allowNewlines = true + } else if l.acceptString(`"`) { + terminator = `"` + } else if l.acceptString(`'`) { + terminator = `'` + } + + for { + if l.peekValue(terminator) { + l.acceptString(terminator) + l.emit(TokenTypeString) + return lexSource + } + + // Otherwise, consume until we hit EOFRUNE. + r := l.next() + if !allowNewlines && isNewline(r) { + return l.errorf(r, "Unterminated string") + } + + if r == EOFRUNE { + return l.errorf(r, "Unterminated string") + } + } +} + +// lexSinglelineComment scans until newline or EOFRUNE +func lexSinglelineComment(l *Lexer) stateFn { + checker := func(r rune) (bool, error) { + result := r == EOFRUNE || isNewline(r) + return !result, nil + } + + l.acceptString("//") + return buildLexUntil(TokenTypeSinglelineComment, checker) +} + +// lexMultilineComment scans until the close of the multiline comment or EOFRUNE +func lexMultilineComment(l *Lexer) stateFn { + l.acceptString("/*") + for { + // Check for the end of the multiline comment. + if l.peekValue("*/") { + l.acceptString("*/") + l.emit(TokenTypeMultilineComment) + return lexSource + } + + // Otherwise, consume until we hit EOFRUNE. + r := l.next() + if r == EOFRUNE { + return l.errorf(r, "Unterminated multiline comment") + } + } +} + +// lexIdentifierOrKeyword searches for a keyword or literal identifier. +func lexIdentifierOrKeyword(l *Lexer) stateFn { + for { + if !isAlphaNumeric(l.peek()) { + break + } + + l.next() + } + + _, isKeyword := keywords[l.value()] + + switch { + case isKeyword: + l.emit(TokenTypeKeyword) + + default: + l.emit(TokenTypeIdentifier) + } + + return lexSource +} + +// isSpace reports whether r is a space character. +func isSpace(r rune) bool { + return r == ' ' || r == '\t' +} + +// isNewline reports whether r is a newline character. +func isNewline(r rune) bool { + return r == '\r' || r == '\n' +} + +// isAlphaNumeric reports whether r is an alphabetic, digit, or underscore. +func isAlphaNumeric(r rune) bool { + return r == '_' || unicode.IsLetter(r) || unicode.IsDigit(r) +} diff --git a/vendor/github.com/authzed/spicedb/pkg/composableschemadsl/lexer/tokentype_string.go b/vendor/github.com/authzed/spicedb/pkg/composableschemadsl/lexer/tokentype_string.go new file mode 100644 index 0000000..79f3585 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/composableschemadsl/lexer/tokentype_string.go @@ -0,0 +1,64 @@ +// Code generated by "stringer -type=TokenType"; DO NOT EDIT. + +package lexer + +import "strconv" + +func _() { + // An "invalid array index" compiler error signifies that the constant values have changed. + // Re-run the stringer command to generate them again. + var x [1]struct{} + _ = x[TokenTypeError-0] + _ = x[TokenTypeSyntheticSemicolon-1] + _ = x[TokenTypeEOF-2] + _ = x[TokenTypeWhitespace-3] + _ = x[TokenTypeSinglelineComment-4] + _ = x[TokenTypeMultilineComment-5] + _ = x[TokenTypeNewline-6] + _ = x[TokenTypeKeyword-7] + _ = x[TokenTypeIdentifier-8] + _ = x[TokenTypeNumber-9] + _ = x[TokenTypeLeftBrace-10] + _ = x[TokenTypeRightBrace-11] + _ = x[TokenTypeLeftParen-12] + _ = x[TokenTypeRightParen-13] + _ = x[TokenTypePipe-14] + _ = x[TokenTypePlus-15] + _ = x[TokenTypeMinus-16] + _ = x[TokenTypeAnd-17] + _ = x[TokenTypeDiv-18] + _ = x[TokenTypeEquals-19] + _ = x[TokenTypeColon-20] + _ = x[TokenTypeSemicolon-21] + _ = x[TokenTypeRightArrow-22] + _ = x[TokenTypeHash-23] + _ = x[TokenTypeEllipsis-24] + _ = x[TokenTypeStar-25] + _ = x[TokenTypeQuestionMark-26] + _ = x[TokenTypeConditionalOr-27] + _ = x[TokenTypeConditionalAnd-28] + _ = x[TokenTypeExclamationPoint-29] + _ = x[TokenTypeLeftBracket-30] + _ = x[TokenTypeRightBracket-31] + _ = x[TokenTypePeriod-32] + _ = x[TokenTypeComma-33] + _ = x[TokenTypePercent-34] + _ = x[TokenTypeLessThan-35] + _ = x[TokenTypeGreaterThan-36] + _ = x[TokenTypeLessThanOrEqual-37] + _ = x[TokenTypeGreaterThanOrEqual-38] + _ = x[TokenTypeEqualEqual-39] + _ = x[TokenTypeNotEqual-40] + _ = x[TokenTypeString-41] +} + +const _TokenType_name = "TokenTypeErrorTokenTypeSyntheticSemicolonTokenTypeEOFTokenTypeWhitespaceTokenTypeSinglelineCommentTokenTypeMultilineCommentTokenTypeNewlineTokenTypeKeywordTokenTypeIdentifierTokenTypeNumberTokenTypeLeftBraceTokenTypeRightBraceTokenTypeLeftParenTokenTypeRightParenTokenTypePipeTokenTypePlusTokenTypeMinusTokenTypeAndTokenTypeDivTokenTypeEqualsTokenTypeColonTokenTypeSemicolonTokenTypeRightArrowTokenTypeHashTokenTypeEllipsisTokenTypeStarTokenTypeQuestionMarkTokenTypeConditionalOrTokenTypeConditionalAndTokenTypeExclamationPointTokenTypeLeftBracketTokenTypeRightBracketTokenTypePeriodTokenTypeCommaTokenTypePercentTokenTypeLessThanTokenTypeGreaterThanTokenTypeLessThanOrEqualTokenTypeGreaterThanOrEqualTokenTypeEqualEqualTokenTypeNotEqualTokenTypeString" + +var _TokenType_index = [...]uint16{0, 14, 41, 53, 72, 98, 123, 139, 155, 174, 189, 207, 226, 244, 263, 276, 289, 303, 315, 327, 342, 356, 374, 393, 406, 423, 436, 457, 479, 502, 527, 547, 568, 583, 597, 613, 630, 650, 674, 701, 720, 737, 752} + +func (i TokenType) String() string { + if i < 0 || i >= TokenType(len(_TokenType_index)-1) { + return "TokenType(" + strconv.FormatInt(int64(i), 10) + ")" + } + return _TokenType_name[_TokenType_index[i]:_TokenType_index[i+1]] +} diff --git a/vendor/github.com/authzed/spicedb/pkg/composableschemadsl/parser/nodestack.go b/vendor/github.com/authzed/spicedb/pkg/composableschemadsl/parser/nodestack.go new file mode 100644 index 0000000..0d49e09 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/composableschemadsl/parser/nodestack.go @@ -0,0 +1,35 @@ +package parser + +type nodeStack struct { + top *element + size int +} + +type element struct { + value AstNode + next *element +} + +func (s *nodeStack) topValue() AstNode { + if s.size == 0 { + return nil + } + + return s.top.value +} + +// Push pushes a node onto the stack. +func (s *nodeStack) push(value AstNode) { + s.top = &element{value, s.top} + s.size++ +} + +// Pop removes the node from the stack and returns it. +func (s *nodeStack) pop() (value AstNode) { + if s.size > 0 { + value, s.top = s.top.value, s.top.next + s.size-- + return + } + return nil +} diff --git a/vendor/github.com/authzed/spicedb/pkg/composableschemadsl/parser/parser.go b/vendor/github.com/authzed/spicedb/pkg/composableschemadsl/parser/parser.go new file mode 100644 index 0000000..08eedc8 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/composableschemadsl/parser/parser.go @@ -0,0 +1,739 @@ +// parser package defines the parser for the Authzed Schema DSL. +package parser + +import ( + "strings" + + "golang.org/x/exp/maps" + + "github.com/authzed/spicedb/pkg/composableschemadsl/dslshape" + "github.com/authzed/spicedb/pkg/composableschemadsl/input" + "github.com/authzed/spicedb/pkg/composableschemadsl/lexer" +) + +// Parse parses the given Schema DSL source into a parse tree. +func Parse(builder NodeBuilder, source input.Source, input string) AstNode { + lx := lexer.Lex(source, input) + parser := buildParser(lx, builder, source, input) + defer parser.close() + return parser.consumeTopLevel() +} + +// ignoredTokenTypes are those tokens ignored when parsing. +var ignoredTokenTypes = map[lexer.TokenType]bool{ + lexer.TokenTypeWhitespace: true, + lexer.TokenTypeNewline: true, + lexer.TokenTypeSinglelineComment: true, + lexer.TokenTypeMultilineComment: true, +} + +// consumeTopLevel attempts to consume the top-level definitions. +func (p *sourceParser) consumeTopLevel() AstNode { + rootNode := p.startNode(dslshape.NodeTypeFile) + defer p.mustFinishNode() + + // Start at the first token. + p.consumeToken() + + if p.currentToken.Kind == lexer.TokenTypeError { + p.emitErrorf("%s", p.currentToken.Value) + return rootNode + } + + hasSeenDefinition := false + +Loop: + for { + if p.isToken(lexer.TokenTypeEOF) { + break Loop + } + + // Consume a statement terminator if one was found. + p.tryConsumeStatementTerminator() + + if p.isToken(lexer.TokenTypeEOF) { + break Loop + } + + // The top level of the DSL is a set of definitions and caveats: + // definition foobar { ... } + // caveat somecaveat (...) { ... } + + switch { + case p.isKeyword("use"): + rootNode.Connect(dslshape.NodePredicateChild, p.consumeUseFlag(hasSeenDefinition)) + + case p.isKeyword("definition"): + hasSeenDefinition = true + rootNode.Connect(dslshape.NodePredicateChild, p.consumeDefinition()) + + case p.isKeyword("caveat"): + hasSeenDefinition = true + rootNode.Connect(dslshape.NodePredicateChild, p.consumeCaveat()) + + case p.isKeyword("import"): + rootNode.Connect(dslshape.NodePredicateChild, p.consumeImport()) + + case p.isKeyword("partial"): + rootNode.Connect(dslshape.NodePredicateChild, p.consumePartial()) + + default: + p.emitErrorf("Unexpected token at root level: %v", p.currentToken.Kind) + break Loop + } + } + + return rootNode +} + +// consumeCaveat attempts to consume a single caveat definition. +// ```caveat somecaveat(param1 type, param2 type) { ... }``` +func (p *sourceParser) consumeCaveat() AstNode { + defNode := p.startNode(dslshape.NodeTypeCaveatDefinition) + defer p.mustFinishNode() + + // caveat ... + p.consumeKeyword("caveat") + caveatName, ok := p.consumeTypePath() + if !ok { + return defNode + } + + defNode.MustDecorate(dslshape.NodeCaveatDefinitionPredicateName, caveatName) + + // Parameters: + // ( + _, ok = p.consume(lexer.TokenTypeLeftParen) + if !ok { + return defNode + } + + for { + paramNode, ok := p.consumeCaveatParameter() + if !ok { + return defNode + } + + defNode.Connect(dslshape.NodeCaveatDefinitionPredicateParameters, paramNode) + if _, ok := p.tryConsume(lexer.TokenTypeComma); !ok { + break + } + } + + // ) + _, ok = p.consume(lexer.TokenTypeRightParen) + if !ok { + return defNode + } + + // { + _, ok = p.consume(lexer.TokenTypeLeftBrace) + if !ok { + return defNode + } + + exprNode, ok := p.consumeCaveatExpression() + if !ok { + return defNode + } + + defNode.Connect(dslshape.NodeCaveatDefinitionPredicateExpession, exprNode) + + // } + _, ok = p.consume(lexer.TokenTypeRightBrace) + if !ok { + return defNode + } + + return defNode +} + +func (p *sourceParser) consumeCaveatExpression() (AstNode, bool) { + exprNode := p.startNode(dslshape.NodeTypeCaveatExpression) + defer p.mustFinishNode() + + // Special Logic Note: Since CEL is its own language, we consume here until we have a matching + // close brace, and then pass ALL the found tokens to CEL's own parser to attach the expression + // here. + braceDepth := 1 // Starting at 1 from the open brace above + var startToken *commentedLexeme + var endToken *commentedLexeme +consumer: + for { + currentToken := p.currentToken + + switch currentToken.Kind { + case lexer.TokenTypeLeftBrace: + braceDepth++ + + case lexer.TokenTypeRightBrace: + if braceDepth == 1 { + break consumer + } + + braceDepth-- + + case lexer.TokenTypeError: + break consumer + + case lexer.TokenTypeEOF: + break consumer + } + + if startToken == nil { + startToken = ¤tToken + } + + endToken = ¤tToken + p.consumeToken() + } + + if startToken == nil { + p.emitErrorf("missing caveat expression") + return exprNode, false + } + + caveatExpression := p.input[startToken.Position : int(endToken.Position)+len(endToken.Value)] + exprNode.MustDecorate(dslshape.NodeCaveatExpressionPredicateExpression, caveatExpression) + return exprNode, true +} + +// consumeCaveatParameter attempts to consume a caveat parameter. +// ```(paramName paramtype)``` +func (p *sourceParser) consumeCaveatParameter() (AstNode, bool) { + paramNode := p.startNode(dslshape.NodeTypeCaveatParameter) + defer p.mustFinishNode() + + name, ok := p.consumeIdentifier() + if !ok { + return paramNode, false + } + + paramNode.MustDecorate(dslshape.NodeCaveatParameterPredicateName, name) + paramNode.Connect(dslshape.NodeCaveatParameterPredicateType, p.consumeCaveatTypeReference()) + return paramNode, true +} + +// consumeCaveatTypeReference attempts to consume a caveat type reference. +// ```typeName<childType>``` +func (p *sourceParser) consumeCaveatTypeReference() AstNode { + typeRefNode := p.startNode(dslshape.NodeTypeCaveatTypeReference) + defer p.mustFinishNode() + + name, ok := p.consumeCaveatTypeIdentifier() + if !ok { + return typeRefNode + } + + typeRefNode.MustDecorate(dslshape.NodeCaveatTypeReferencePredicateType, name) + + // Check for child type(s). + // < + if _, ok := p.tryConsume(lexer.TokenTypeLessThan); !ok { + return typeRefNode + } + + for { + childTypeRef := p.consumeCaveatTypeReference() + typeRefNode.Connect(dslshape.NodeCaveatTypeReferencePredicateChildTypes, childTypeRef) + if _, ok := p.tryConsume(lexer.TokenTypeComma); !ok { + break + } + } + + // > + p.consume(lexer.TokenTypeGreaterThan) + return typeRefNode +} + +// consumeUseFlag attempts to consume a use flag. +// ``` use flagname ``` +func (p *sourceParser) consumeUseFlag(afterDefinition bool) AstNode { + useNode := p.startNode(dslshape.NodeTypeUseFlag) + defer p.mustFinishNode() + + // consume the `use` + p.consumeKeyword("use") + + var useFlag string + if p.isToken(lexer.TokenTypeIdentifier) { + useFlag, _ = p.consumeIdentifier() + } else { + useName, ok := p.consumeVariableKeyword() + if !ok { + return useNode + } + useFlag = useName + } + + if _, ok := lexer.Flags[useFlag]; !ok { + p.emitErrorf("Unknown use flag: `%s`. Options are: %s", useFlag, strings.Join(maps.Keys(lexer.Flags), ", ")) + return useNode + } + + useNode.MustDecorate(dslshape.NodeUseFlagPredicateName, useFlag) + + // NOTE: we conduct this check in `consumeFlag` rather than at + // the callsite to keep the callsite clean. + // We also do the check after consumption to ensure that the parser continues + // moving past the use expression. + if afterDefinition { + p.emitErrorf("`use` expressions must be declared before any definition") + return useNode + } + + return useNode +} + +// "any" is both a keyword and a valid caveat type, so a caveat type identifier +// can either be a keyword or an identifier. This wraps around that. +func (p *sourceParser) consumeCaveatTypeIdentifier() (string, bool) { + if ok := p.tryConsumeKeyword("any"); ok { + return "any", true + } + + identifier, ok := p.tryConsume(lexer.TokenTypeIdentifier) + if !ok { + p.emitErrorf("Expected keyword \"any\" or a valid identifier, found token %v", p.currentToken.Kind) + return "", false + } + return identifier.Value, true +} + +// consumeDefinition attempts to consume a single schema definition. +// ```definition somedef { ... }``` +func (p *sourceParser) consumeDefinition() AstNode { + defNode := p.startNode(dslshape.NodeTypeDefinition) + defer p.mustFinishNode() + + // definition ... + p.consumeKeyword("definition") + definitionName, ok := p.consumeTypePath() + if !ok { + return defNode + } + + defNode.MustDecorate(dslshape.NodeDefinitionPredicateName, definitionName) + + p.consumeDefinitionOrPartialImpl(defNode) + + return defNode +} + +// consumePartial attempts to consume a single schema partial. +// ```partial somepartial { ... }``` +func (p *sourceParser) consumePartial() AstNode { + partialNode := p.startNode(dslshape.NodeTypePartial) + defer p.mustFinishNode() + + // partial ... + p.consumeKeyword("partial") + definitionName, ok := p.consumeTypePath() + if !ok { + return partialNode + } + + partialNode.MustDecorate(dslshape.NodePartialPredicateName, definitionName) + + p.consumeDefinitionOrPartialImpl(partialNode) + + return partialNode +} + +// consumeDefinitionOrPartialImpl does the work of parsing and consuming +// the internals of a given definition or partial. +// Definitions and partials have the same set of allowable internals. +func (p *sourceParser) consumeDefinitionOrPartialImpl(node AstNode) AstNode { + // { + _, ok := p.consume(lexer.TokenTypeLeftBrace) + if !ok { + return node + } + + // Relations and permissions. + for { + // } + if _, ok := p.tryConsume(lexer.TokenTypeRightBrace); ok { + break + } + + // relation ... + // permission ... + switch { + case p.isKeyword("relation"): + node.Connect(dslshape.NodePredicateChild, p.consumeRelation()) + + case p.isKeyword("permission"): + node.Connect(dslshape.NodePredicateChild, p.consumePermission()) + + case p.isToken(lexer.TokenTypeEllipsis): + node.Connect(dslshape.NodePredicateChild, p.consumePartialReference()) + } + + ok := p.consumeStatementTerminator() + if !ok { + break + } + } + + return node +} + +// consumeRelation consumes a relation. +// ```relation foo: sometype``` +func (p *sourceParser) consumeRelation() AstNode { + relNode := p.startNode(dslshape.NodeTypeRelation) + defer p.mustFinishNode() + + // relation ... + p.consumeKeyword("relation") + relationName, ok := p.consumeIdentifier() + if !ok { + return relNode + } + + relNode.MustDecorate(dslshape.NodePredicateName, relationName) + + // : + _, ok = p.consume(lexer.TokenTypeColon) + if !ok { + return relNode + } + + // Relation allowed type(s). + relNode.Connect(dslshape.NodeRelationPredicateAllowedTypes, p.consumeTypeReference()) + + return relNode +} + +// consumeTypeReference consumes a reference to a type or types of relations. +// ```sometype | anothertype | anothertype:* ``` +func (p *sourceParser) consumeTypeReference() AstNode { + refNode := p.startNode(dslshape.NodeTypeTypeReference) + defer p.mustFinishNode() + + for { + refNode.Connect(dslshape.NodeTypeReferencePredicateType, p.consumeSpecificTypeWithCaveat()) + if _, ok := p.tryConsume(lexer.TokenTypePipe); !ok { + break + } + } + + return refNode +} + +// tryConsumeWithCaveat tries to consume a caveat `with` expression. +func (p *sourceParser) tryConsumeWithCaveat() (AstNode, bool) { + caveatNode := p.startNode(dslshape.NodeTypeCaveatReference) + defer p.mustFinishNode() + + consumed, ok := p.consumeTypePath() + if !ok { + return caveatNode, true + } + + caveatNode.MustDecorate(dslshape.NodeCaveatPredicateCaveat, consumed) + return caveatNode, true +} + +// consumeSpecificTypeWithCaveat consumes an identifier as a specific type reference, with optional caveat. +func (p *sourceParser) consumeSpecificTypeWithCaveat() AstNode { + specificNode := p.consumeSpecificTypeWithoutFinish() + defer p.mustFinishNode() + + // Check for a caveat and/or supported trait. + if !p.isKeyword("with") { + return specificNode + } + + p.consumeKeyword("with") + + if !p.isKeyword("expiration") { + caveatNode, ok := p.tryConsumeWithCaveat() + if ok { + specificNode.Connect(dslshape.NodeSpecificReferencePredicateCaveat, caveatNode) + } + + if !p.tryConsumeKeyword("and") { + return specificNode + } + } + + if p.isKeyword("expiration") { + // Check for expiration trait. + traitNode := p.consumeExpirationTrait() + + // Decorate with the expiration trait. + specificNode.Connect(dslshape.NodeSpecificReferencePredicateTrait, traitNode) + } + + return specificNode +} + +// consumeExpirationTrait consumes an expiration trait. +func (p *sourceParser) consumeExpirationTrait() AstNode { + expirationTraitNode := p.startNode(dslshape.NodeTypeTraitReference) + p.consumeKeyword("expiration") + + expirationTraitNode.MustDecorate(dslshape.NodeTraitPredicateTrait, "expiration") + defer p.mustFinishNode() + + return expirationTraitNode +} + +// consumeSpecificTypeOpen consumes an identifier as a specific type reference. +func (p *sourceParser) consumeSpecificTypeWithoutFinish() AstNode { + specificNode := p.startNode(dslshape.NodeTypeSpecificTypeReference) + + typeName, ok := p.consumeTypePath() + if !ok { + return specificNode + } + + specificNode.MustDecorate(dslshape.NodeSpecificReferencePredicateType, typeName) + + // Check for a wildcard + if _, ok := p.tryConsume(lexer.TokenTypeColon); ok { + _, ok := p.consume(lexer.TokenTypeStar) + if !ok { + return specificNode + } + + specificNode.MustDecorate(dslshape.NodeSpecificReferencePredicateWildcard, "true") + return specificNode + } + + // Check for a relation specified. + if _, ok := p.tryConsume(lexer.TokenTypeHash); !ok { + return specificNode + } + + // Consume an identifier or an ellipsis. + consumed, ok := p.consume(lexer.TokenTypeIdentifier, lexer.TokenTypeEllipsis) + if !ok { + return specificNode + } + + specificNode.MustDecorate(dslshape.NodeSpecificReferencePredicateRelation, consumed.Value) + return specificNode +} + +func (p *sourceParser) consumeTypePath() (string, bool) { + var segments []string + + for { + segment, ok := p.consumeIdentifier() + if !ok { + return "", false + } + + segments = append(segments, segment) + + _, ok = p.tryConsume(lexer.TokenTypeDiv) + if !ok { + break + } + } + + return strings.Join(segments, "/"), true +} + +// consumePermission consumes a permission. +// ```permission foo = bar + baz``` +func (p *sourceParser) consumePermission() AstNode { + permNode := p.startNode(dslshape.NodeTypePermission) + defer p.mustFinishNode() + + // permission ... + p.consumeKeyword("permission") + permissionName, ok := p.consumeIdentifier() + if !ok { + return permNode + } + + permNode.MustDecorate(dslshape.NodePredicateName, permissionName) + + // = + _, ok = p.consume(lexer.TokenTypeEquals) + if !ok { + return permNode + } + + permNode.Connect(dslshape.NodePermissionPredicateComputeExpression, p.consumeComputeExpression()) + return permNode +} + +// ComputeExpressionOperators defines the binary operators in precedence order. +var ComputeExpressionOperators = []binaryOpDefinition{ + {lexer.TokenTypeMinus, dslshape.NodeTypeExclusionExpression}, + {lexer.TokenTypeAnd, dslshape.NodeTypeIntersectExpression}, + {lexer.TokenTypePlus, dslshape.NodeTypeUnionExpression}, +} + +// consumeComputeExpression consumes an expression for computing a permission. +func (p *sourceParser) consumeComputeExpression() AstNode { + // Compute expressions consist of a set of binary operators, so build a tree with proper + // precedence. + binaryParser := p.buildBinaryOperatorExpressionFnTree(ComputeExpressionOperators) + found, ok := binaryParser() + if !ok { + return p.createErrorNodef("Expected compute expression for permission") + } + return found +} + +// tryConsumeComputeExpression attempts to consume a nested compute expression. +func (p *sourceParser) tryConsumeComputeExpression(subTryExprFn tryParserFn, binaryTokenType lexer.TokenType, nodeType dslshape.NodeType) (AstNode, bool) { + rightNodeBuilder := func(leftNode AstNode, operatorToken lexer.Lexeme) (AstNode, bool) { + rightNode, ok := subTryExprFn() + if !ok { + return nil, false + } + + // Create the expression node representing the binary expression. + exprNode := p.createNode(nodeType) + exprNode.Connect(dslshape.NodeExpressionPredicateLeftExpr, leftNode) + exprNode.Connect(dslshape.NodeExpressionPredicateRightExpr, rightNode) + return exprNode, true + } + return p.performLeftRecursiveParsing(subTryExprFn, rightNodeBuilder, nil, binaryTokenType) +} + +// tryConsumeArrowExpression attempts to consume an arrow expression. +// ```foo->bar->baz->meh``` +func (p *sourceParser) tryConsumeArrowExpression() (AstNode, bool) { + rightNodeBuilder := func(leftNode AstNode, operatorToken lexer.Lexeme) (AstNode, bool) { + // Check for an arrow function. + if operatorToken.Kind == lexer.TokenTypePeriod { + functionName, ok := p.consumeKeywords("any", "all") + if !ok { + return nil, false + } + + if _, ok := p.consume(lexer.TokenTypeLeftParen); !ok { + return nil, false + } + + rightNode, ok := p.tryConsumeIdentifierLiteral() + if !ok { + return nil, false + } + + if _, ok := p.consume(lexer.TokenTypeRightParen); !ok { + return nil, false + } + + exprNode := p.createNode(dslshape.NodeTypeArrowExpression) + exprNode.Connect(dslshape.NodeExpressionPredicateLeftExpr, leftNode) + exprNode.Connect(dslshape.NodeExpressionPredicateRightExpr, rightNode) + exprNode.MustDecorate(dslshape.NodeArrowExpressionFunctionName, functionName) + return exprNode, true + } + + rightNode, ok := p.tryConsumeIdentifierLiteral() + if !ok { + return nil, false + } + + // Create the expression node representing the binary expression. + exprNode := p.createNode(dslshape.NodeTypeArrowExpression) + exprNode.Connect(dslshape.NodeExpressionPredicateLeftExpr, leftNode) + exprNode.Connect(dslshape.NodeExpressionPredicateRightExpr, rightNode) + return exprNode, true + } + return p.performLeftRecursiveParsing(p.tryConsumeIdentifierLiteral, rightNodeBuilder, nil, lexer.TokenTypeRightArrow, lexer.TokenTypePeriod) +} + +// tryConsumeBaseExpression attempts to consume base compute expressions (identifiers, parenthesis). +// ```(foo + bar)``` +// ```(foo)``` +// ```foo``` +// ```nil``` +func (p *sourceParser) tryConsumeBaseExpression() (AstNode, bool) { + switch { + // Nested expression. + case p.isToken(lexer.TokenTypeLeftParen): + comments := p.currentToken.comments + + p.consume(lexer.TokenTypeLeftParen) + exprNode := p.consumeComputeExpression() + p.consume(lexer.TokenTypeRightParen) + + // Attach any comments found to the consumed expression. + p.decorateComments(exprNode, comments) + + return exprNode, true + + // Nil expression. + case p.isKeyword("nil"): + return p.tryConsumeNilExpression() + + // Identifier. + case p.isToken(lexer.TokenTypeIdentifier): + return p.tryConsumeIdentifierLiteral() + } + + return nil, false +} + +// tryConsumeIdentifierLiteral attempts to consume an identifier as a literal +// expression. +// +// ```foo``` +func (p *sourceParser) tryConsumeIdentifierLiteral() (AstNode, bool) { + if !p.isToken(lexer.TokenTypeIdentifier) { + return nil, false + } + + identNode := p.startNode(dslshape.NodeTypeIdentifier) + defer p.mustFinishNode() + + identifier, _ := p.consumeIdentifier() + identNode.MustDecorate(dslshape.NodeIdentiferPredicateValue, identifier) + return identNode, true +} + +func (p *sourceParser) tryConsumeNilExpression() (AstNode, bool) { + if !p.isKeyword("nil") { + return nil, false + } + + node := p.startNode(dslshape.NodeTypeNilExpression) + p.consumeKeyword("nil") + defer p.mustFinishNode() + return node, true +} + +func (p *sourceParser) consumePartialReference() AstNode { + partialReferenceNode := p.startNode(dslshape.NodeTypePartialReference) + defer p.mustFinishNode() + + p.consume(lexer.TokenTypeEllipsis) + identifier, ok := p.consumeIdentifier() + if !ok { + return partialReferenceNode + } + + partialReferenceNode.MustDecorate(dslshape.NodePartialReferencePredicateName, identifier) + + return partialReferenceNode +} + +func (p *sourceParser) consumeImport() AstNode { + importNode := p.startNode(dslshape.NodeTypeImport) + defer p.mustFinishNode() + + // import ... + // NOTE: error handling isn't necessary here because this function is only + // invoked if the `import` keyword is found in the function above. + p.consumeKeyword("import") + + importPath, ok := p.consumeStringLiteral() + if !ok { + return importNode + } + + importNode.MustDecorate(dslshape.NodeImportPredicatePath, importPath) + + return importNode +} diff --git a/vendor/github.com/authzed/spicedb/pkg/composableschemadsl/parser/parser_impl.go b/vendor/github.com/authzed/spicedb/pkg/composableschemadsl/parser/parser_impl.go new file mode 100644 index 0000000..b5f13aa --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/composableschemadsl/parser/parser_impl.go @@ -0,0 +1,417 @@ +package parser + +import ( + "fmt" + "strings" + + "github.com/authzed/spicedb/pkg/composableschemadsl/dslshape" + "github.com/authzed/spicedb/pkg/composableschemadsl/input" + "github.com/authzed/spicedb/pkg/composableschemadsl/lexer" +) + +// AstNode defines an interface for working with nodes created by this parser. +type AstNode interface { + // Connect connects this AstNode to another AstNode with the given predicate. + Connect(predicate string, other AstNode) + + // MustDecorate decorates this AstNode with the given property and string value, returning + // the same node. + MustDecorate(property string, value string) AstNode + + // MustDecorateWithInt decorates this AstNode with the given property and int value, returning + // the same node. + MustDecorateWithInt(property string, value int) AstNode +} + +// NodeBuilder is a function for building AST nodes. +type NodeBuilder func(source input.Source, kind dslshape.NodeType) AstNode + +// tryParserFn is a function that attempts to build an AST node. +type tryParserFn func() (AstNode, bool) + +// lookaheadParserFn is a function that performs lookahead. +type lookaheadParserFn func(currentToken lexer.Lexeme) bool + +// rightNodeConstructor is a function which takes in a left expr node and the +// token consumed for a left-recursive operator, and returns a newly constructed +// operator expression if a right expression could be found. +type rightNodeConstructor func(AstNode, lexer.Lexeme) (AstNode, bool) + +// commentedLexeme is a lexer.Lexeme with comments attached. +type commentedLexeme struct { + lexer.Lexeme + comments []string +} + +// sourceParser holds the state of the parser. +type sourceParser struct { + source input.Source // the name of the input; used only for error reports + input string // the input string itself + lex *lexer.FlaggableLexer // a reference to the lexer used for tokenization + builder NodeBuilder // the builder function for creating AstNode instances + nodes *nodeStack // the stack of the current nodes + currentToken commentedLexeme // the current token + previousToken commentedLexeme // the previous token +} + +// buildParser returns a new sourceParser instance. +func buildParser(lx *lexer.Lexer, builder NodeBuilder, source input.Source, input string) *sourceParser { + l := lexer.NewFlaggableLexer(lx) + return &sourceParser{ + source: source, + input: input, + lex: l, + builder: builder, + nodes: &nodeStack{}, + currentToken: commentedLexeme{lexer.Lexeme{Kind: lexer.TokenTypeEOF}, make([]string, 0)}, + previousToken: commentedLexeme{lexer.Lexeme{Kind: lexer.TokenTypeEOF}, make([]string, 0)}, + } +} + +func (p *sourceParser) close() { + p.lex.Close() +} + +// createNode creates a new AstNode and returns it. +func (p *sourceParser) createNode(kind dslshape.NodeType) AstNode { + return p.builder(p.source, kind) +} + +// createErrorNodef creates a new error node and returns it. +func (p *sourceParser) createErrorNodef(format string, args ...interface{}) AstNode { + message := fmt.Sprintf(format, args...) + node := p.startNode(dslshape.NodeTypeError).MustDecorate(dslshape.NodePredicateErrorMessage, message) + p.mustFinishNode() + return node +} + +// startNode creates a new node of the given type, decorates it with the current token's +// position as its start position, and pushes it onto the nodes stack. +func (p *sourceParser) startNode(kind dslshape.NodeType) AstNode { + node := p.createNode(kind) + p.decorateStartRuneAndComments(node, p.currentToken) + p.nodes.push(node) + return node +} + +// decorateStartRuneAndComments decorates the given node with the location of the given token as its +// starting rune, as well as any comments attached to the token. +func (p *sourceParser) decorateStartRuneAndComments(node AstNode, token commentedLexeme) { + node.MustDecorate(dslshape.NodePredicateSource, string(p.source)) + node.MustDecorateWithInt(dslshape.NodePredicateStartRune, int(token.Position)) + p.decorateComments(node, token.comments) +} + +// decorateComments decorates the given node with the specified comments. +func (p *sourceParser) decorateComments(node AstNode, comments []string) { + for _, comment := range comments { + commentNode := p.createNode(dslshape.NodeTypeComment) + commentNode.MustDecorate(dslshape.NodeCommentPredicateValue, comment) + node.Connect(dslshape.NodePredicateChild, commentNode) + } +} + +// decorateEndRune decorates the given node with the location of the given token as its +// ending rune. +func (p *sourceParser) decorateEndRune(node AstNode, token commentedLexeme) { + position := int(token.Position) + len(token.Value) - 1 + node.MustDecorateWithInt(dslshape.NodePredicateEndRune, position) +} + +// currentNode returns the node at the top of the stack. +func (p *sourceParser) currentNode() AstNode { + return p.nodes.topValue() +} + +// mustFinishNode pops the current node from the top of the stack and decorates it with +// the current token's end position as its end position. +func (p *sourceParser) mustFinishNode() { + if p.currentNode() == nil { + panic(fmt.Sprintf("No current node on stack. Token: %s", p.currentToken.Value)) + } + + p.decorateEndRune(p.currentNode(), p.previousToken) + p.nodes.pop() +} + +// consumeToken advances the lexer forward, returning the next token. +func (p *sourceParser) consumeToken() commentedLexeme { + comments := make([]string, 0) + + for { + token := p.lex.NextToken() + + if token.Kind == lexer.TokenTypeSinglelineComment || token.Kind == lexer.TokenTypeMultilineComment { + comments = append(comments, token.Value) + } + + if _, ok := ignoredTokenTypes[token.Kind]; !ok { + p.previousToken = p.currentToken + p.currentToken = commentedLexeme{token, comments} + return p.currentToken + } + } +} + +// isToken returns true if the current token matches one of the types given. +func (p *sourceParser) isToken(types ...lexer.TokenType) bool { + for _, kind := range types { + if p.currentToken.Kind == kind { + return true + } + } + + return false +} + +// isKeyword returns true if the current token is a keyword matching that given. +func (p *sourceParser) isKeyword(keyword string) bool { + return p.isToken(lexer.TokenTypeKeyword) && p.currentToken.Value == keyword +} + +// emitErrorf creates a new error node and attachs it as a child of the current +// node. +func (p *sourceParser) emitErrorf(format string, args ...interface{}) { + errorNode := p.createErrorNodef(format, args...) + if len(p.currentToken.Value) > 0 { + errorNode.MustDecorate(dslshape.NodePredicateErrorSource, p.currentToken.Value) + } + p.currentNode().Connect(dslshape.NodePredicateChild, errorNode) +} + +// consumeVariableKeyword consumes an expected keyword token or adds an error node. +// This is useful when you want a keyword but don't want to enumerate the possibile keywords +// (e.g. in use statements) +func (p *sourceParser) consumeVariableKeyword() (string, bool) { + if !p.isToken(lexer.TokenTypeKeyword) { + p.emitErrorf("Expected keyword, found token %v", p.currentToken.Kind) + return "", false + } + + token := p.currentToken + p.consumeToken() + return token.Value, true +} + +// consumeKeyword consumes an expected keyword token or adds an error node. +func (p *sourceParser) consumeKeyword(keyword string) bool { + if !p.tryConsumeKeyword(keyword) { + p.emitErrorf("Expected keyword %s, found token %v", keyword, p.currentToken.Kind) + return false + } + return true +} + +// tryConsumeKeyword attempts to consume an expected keyword token. +func (p *sourceParser) tryConsumeKeyword(keyword string) bool { + if !p.isKeyword(keyword) { + return false + } + + p.consumeToken() + return true +} + +// consumeString consumes a string token and returns the unwrapped string or adds an error node. +func (p *sourceParser) consumeStringLiteral() (string, bool) { + consumedString, ok := p.tryConsumeStringLiteral() + if !ok { + p.emitErrorf("Expected quote-delimited string, found token %v", p.currentToken.Kind) + return "", false + } + return consumedString, true +} + +// tryConsumeString attempts to consume an expected string token and return the unwrapped string. +func (p *sourceParser) tryConsumeStringLiteral() (string, bool) { + wrappedStringToken, ok := p.tryConsume(lexer.TokenTypeString) + if !ok { + return "", false + } + wrappedString := wrappedStringToken.Value + + // NOTE: We can't just trim here, because a user may use a combination of + // single and double quotes to escape. + // If we have a string wrapped in singlequotes (singular or plural), + // strip those specifically. + if strings.Index(wrappedString, `'`) == 0 { + return strings.Trim(wrappedString, `'`), true + } + + // Else strip doublequotes, because the set of string delimiters is limited + // by the lexer. + return strings.Trim(wrappedString, `"`), true +} + +// consumeKeywords consumes any of a set of keywords or adds an error node +func (p *sourceParser) consumeKeywords(keywords ...string) (string, bool) { + keyword, ok := p.tryConsumeKeywords(keywords...) + if !ok { + p.emitErrorf("Expected one of keywords %s; found token %v", strings.Join(keywords, ", "), p.currentToken.Kind) + return "", false + } + return keyword, true +} + +// tryConsumeKeyword attempts to consume one of a set of expected keyword tokens. +func (p *sourceParser) tryConsumeKeywords(keywords ...string) (string, bool) { + for _, keyword := range keywords { + if p.isKeyword(keyword) { + p.consumeToken() + return keyword, true + } + } + return "", false +} + +// cosumeIdentifier consumes an expected identifier token or adds an error node. +func (p *sourceParser) consumeIdentifier() (string, bool) { + token, ok := p.tryConsume(lexer.TokenTypeIdentifier) + if !ok { + p.emitErrorf("Expected identifier, found token %v", p.currentToken.Kind) + return "", false + } + return token.Value, true +} + +// consume performs consumption of the next token if it matches any of the given +// types and returns it. If no matching type is found, adds an error node. +func (p *sourceParser) consume(types ...lexer.TokenType) (lexer.Lexeme, bool) { + token, ok := p.tryConsume(types...) + if !ok { + p.emitErrorf("Expected one of: %v, found: %v", types, p.currentToken.Kind) + } + return token, ok +} + +// tryConsume performs consumption of the next token if it matches any of the given +// types and returns it. +func (p *sourceParser) tryConsume(types ...lexer.TokenType) (lexer.Lexeme, bool) { + token, found := p.tryConsumeWithComments(types...) + return token.Lexeme, found +} + +// tryConsume performs consumption of the next token if it matches any of the given +// types and returns it. +func (p *sourceParser) tryConsumeWithComments(types ...lexer.TokenType) (commentedLexeme, bool) { + if p.isToken(types...) { + token := p.currentToken + p.consumeToken() + return token, true + } + + return commentedLexeme{lexer.Lexeme{ + Kind: lexer.TokenTypeError, + }, make([]string, 0)}, false +} + +// performLeftRecursiveParsing performs left-recursive parsing of a set of operators. This method +// first performs the parsing via the subTryExprFn and then checks for one of the left-recursive +// operator token types found. If none found, the left expression is returned. Otherwise, the +// rightNodeBuilder is called to attempt to construct an operator expression. This method also +// properly handles decoration of the nodes with their proper start and end run locations and +// comments. +func (p *sourceParser) performLeftRecursiveParsing(subTryExprFn tryParserFn, rightNodeBuilder rightNodeConstructor, rightTokenTester lookaheadParserFn, operatorTokens ...lexer.TokenType) (AstNode, bool) { + leftMostToken := p.currentToken + + // Consume the left side of the expression. + leftNode, ok := subTryExprFn() + if !ok { + return nil, false + } + + // Check for an operator token. If none found, then we've found just the left side of the + // expression and so we return that node. + if !p.isToken(operatorTokens...) { + return leftNode, true + } + + // Keep consuming pairs of operators and child expressions until such + // time as no more can be consumed. We use this loop+custom build rather than recursion + // because these operators are *left* recursive, not right. + var currentLeftNode AstNode + currentLeftNode = leftNode + + for { + // Check for an operator. + if !p.isToken(operatorTokens...) { + break + } + + // If a lookahead function is defined, check the lookahead for the matched token. + if rightTokenTester != nil && !rightTokenTester(p.currentToken.Lexeme) { + break + } + + // Consume the operator. + operatorToken, ok := p.tryConsumeWithComments(operatorTokens...) + if !ok { + break + } + + // Consume the right hand expression and build an expression node (if applicable). + exprNode, ok := rightNodeBuilder(currentLeftNode, operatorToken.Lexeme) + if !ok { + p.emitErrorf("Expected right hand expression, found: %v", p.currentToken.Kind) + return currentLeftNode, true + } + + p.decorateStartRuneAndComments(exprNode, leftMostToken) + p.decorateEndRune(exprNode, p.previousToken) + + currentLeftNode = exprNode + } + + return currentLeftNode, true +} + +// tryConsumeStatementTerminator tries to consume a statement terminator. +func (p *sourceParser) tryConsumeStatementTerminator() (lexer.Lexeme, bool) { + return p.tryConsume(lexer.TokenTypeSyntheticSemicolon, lexer.TokenTypeSemicolon, lexer.TokenTypeEOF) +} + +// consumeStatementTerminator consume a statement terminator. +func (p *sourceParser) consumeStatementTerminator() bool { + _, ok := p.tryConsumeStatementTerminator() + if ok { + return true + } + + p.emitErrorf("Expected end of statement or definition, found: %s", p.currentToken.Kind) + return false +} + +// binaryOpDefinition represents information a binary operator token and its associated node type. +type binaryOpDefinition struct { + // The token representing the binary expression's operator. + BinaryOperatorToken lexer.TokenType + + // The type of node to create for this expression. + BinaryExpressionNodeType dslshape.NodeType +} + +// buildBinaryOperatorExpressionFnTree builds a tree of functions to try to consume a set of binary +// operator expressions. +func (p *sourceParser) buildBinaryOperatorExpressionFnTree(ops []binaryOpDefinition) tryParserFn { + // Start with a base expression function. + var currentParseFn tryParserFn + currentParseFn = func() (AstNode, bool) { + arrowExpr, ok := p.tryConsumeArrowExpression() + if !ok { + return p.tryConsumeBaseExpression() + } + + return arrowExpr, true + } + + for i := range ops { + // Note: We have to reverse this to ensure we have proper precedence. + currentParseFn = func(operatorInfo binaryOpDefinition, currentFn tryParserFn) tryParserFn { + return (func() (AstNode, bool) { + return p.tryConsumeComputeExpression(currentFn, operatorInfo.BinaryOperatorToken, operatorInfo.BinaryExpressionNodeType) + }) + }(ops[len(ops)-i-1], currentParseFn) + } + + return currentParseFn +} diff --git a/vendor/github.com/authzed/spicedb/pkg/cursor/cursor.go b/vendor/github.com/authzed/spicedb/pkg/cursor/cursor.go new file mode 100644 index 0000000..4233efa --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/cursor/cursor.go @@ -0,0 +1,133 @@ +package cursor + +import ( + "encoding/base64" + "errors" + "fmt" + + v1 "github.com/authzed/authzed-go/proto/authzed/api/v1" + + "github.com/authzed/spicedb/pkg/datastore" + dispatch "github.com/authzed/spicedb/pkg/proto/dispatch/v1" + impl "github.com/authzed/spicedb/pkg/proto/impl/v1" + "github.com/authzed/spicedb/pkg/spiceerrors" +) + +// Encode converts a decoded cursor to its opaque version. +func Encode(decoded *impl.DecodedCursor) (*v1.Cursor, error) { + marshalled, err := decoded.MarshalVT() + if err != nil { + return nil, NewInvalidCursorErr(fmt.Errorf(errEncodeError, err)) + } + + return &v1.Cursor{ + Token: base64.StdEncoding.EncodeToString(marshalled), + }, nil +} + +// Decode converts an encoded cursor to its decoded version. +func Decode(encoded *v1.Cursor) (*impl.DecodedCursor, error) { + if encoded == nil { + return nil, NewInvalidCursorErr(errors.New("cursor pointer was nil")) + } + + decodedBytes, err := base64.StdEncoding.DecodeString(encoded.Token) + if err != nil { + return nil, NewInvalidCursorErr(fmt.Errorf(errDecodeError, err)) + } + + decoded := &impl.DecodedCursor{} + if err := decoded.UnmarshalVT(decodedBytes); err != nil { + return nil, NewInvalidCursorErr(fmt.Errorf(errDecodeError, err)) + } + + return decoded, nil +} + +// EncodeFromDispatchCursor encodes an internal dispatching cursor into a V1 cursor for external +// consumption, including the provided call context to ensure the API cursor reflects the calling +// API method. The call hash should contain all the parameters of the calling API function, +// as well as its revision and name. +func EncodeFromDispatchCursor(dispatchCursor *dispatch.Cursor, callAndParameterHash string, revision datastore.Revision, flags map[string]string) (*v1.Cursor, error) { + if dispatchCursor == nil { + return nil, spiceerrors.MustBugf("got nil dispatch cursor") + } + + return Encode(&impl.DecodedCursor{ + VersionOneof: &impl.DecodedCursor_V1{ + V1: &impl.V1Cursor{ + Revision: revision.String(), + DispatchVersion: dispatchCursor.DispatchVersion, + Sections: dispatchCursor.Sections, + CallAndParametersHash: callAndParameterHash, + Flags: flags, + }, + }, + }) +} + +// GetCursorFlag retrieves a flag from an encoded API cursor, if any. +func GetCursorFlag(encoded *v1.Cursor, flagName string) (string, bool, error) { + decoded, err := Decode(encoded) + if err != nil { + return "", false, err + } + + v1decoded := decoded.GetV1() + if v1decoded == nil { + return "", false, NewInvalidCursorErr(ErrNilCursor) + } + + value, ok := v1decoded.Flags[flagName] + return value, ok, nil +} + +// DecodeToDispatchCursor decodes an encoded API cursor into an internal dispatching cursor, +// ensuring that the provided call context matches that encoded into the API cursor. The call +// hash should contain all the parameters of the calling API function, as well as its revision +// and name. +func DecodeToDispatchCursor(encoded *v1.Cursor, callAndParameterHash string) (*dispatch.Cursor, map[string]string, error) { + decoded, err := Decode(encoded) + if err != nil { + return nil, nil, err + } + + v1decoded := decoded.GetV1() + if v1decoded == nil { + return nil, nil, NewInvalidCursorErr(ErrNilCursor) + } + + if v1decoded.CallAndParametersHash != callAndParameterHash { + return nil, nil, NewInvalidCursorErr(ErrHashMismatch) + } + + return &dispatch.Cursor{ + DispatchVersion: v1decoded.DispatchVersion, + Sections: v1decoded.Sections, + }, v1decoded.Flags, nil +} + +// DecodeToDispatchRevision decodes an encoded API cursor into an internal dispatch revision. +// NOTE: this method does *not* verify the caller's method signature. +func DecodeToDispatchRevision(encoded *v1.Cursor, ds revisionDecoder) (datastore.Revision, error) { + decoded, err := Decode(encoded) + if err != nil { + return nil, err + } + + v1decoded := decoded.GetV1() + if v1decoded == nil { + return nil, ErrNilCursor + } + + parsed, err := ds.RevisionFromString(v1decoded.Revision) + if err != nil { + return datastore.NoRevision, fmt.Errorf(errDecodeError, err) + } + + return parsed, nil +} + +type revisionDecoder interface { + RevisionFromString(string) (datastore.Revision, error) +} diff --git a/vendor/github.com/authzed/spicedb/pkg/cursor/doc.go b/vendor/github.com/authzed/spicedb/pkg/cursor/doc.go new file mode 100644 index 0000000..bddf5cd --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/cursor/doc.go @@ -0,0 +1,2 @@ +// Package cursor implements encoding and decoding of cursors used in various APIs. +package cursor diff --git a/vendor/github.com/authzed/spicedb/pkg/cursor/errors.go b/vendor/github.com/authzed/spicedb/pkg/cursor/errors.go new file mode 100644 index 0000000..941df70 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/cursor/errors.go @@ -0,0 +1,46 @@ +package cursor + +import ( + "errors" + + v1 "github.com/authzed/authzed-go/proto/authzed/api/v1" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + + "github.com/authzed/spicedb/pkg/spiceerrors" +) + +// Public facing errors +const ( + errEncodeError = "error encoding cursor: %w" + errDecodeError = "error decoding cursor: %w" +) + +// ErrNilCursor is returned as the base error when nil is provided as the +// cursor argument to Decode +var ErrNilCursor = errors.New("cursor pointer was nil") + +// ErrHashMismatch is returned as the base error when a mismatching hash was given to the decoder. +var ErrHashMismatch = errors.New("the cursor provided does not have the same arguments as the original API call; please ensure you are making the same API call, with the exact same parameters (besides the cursor)") + +// InvalidCursorError occurs when a cursor could not be decoded. +type InvalidCursorError struct { + error +} + +// GRPCStatus implements retrieving the gRPC status for the error. +func (err InvalidCursorError) GRPCStatus() *status.Status { + return spiceerrors.WithCodeAndDetails( + err, + codes.InvalidArgument, + spiceerrors.ForReason( + v1.ErrorReason_ERROR_REASON_INVALID_CURSOR, + nil, + ), + ) +} + +// NewInvalidCursorErr creates and returns a new invalid cursor error. +func NewInvalidCursorErr(err error) error { + return InvalidCursorError{err} +} diff --git a/vendor/github.com/authzed/spicedb/pkg/datastore/caveat.go b/vendor/github.com/authzed/spicedb/pkg/datastore/caveat.go new file mode 100644 index 0000000..85dc7b4 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/datastore/caveat.go @@ -0,0 +1,35 @@ +package datastore + +import ( + "context" + + core "github.com/authzed/spicedb/pkg/proto/core/v1" +) + +// RevisionedCaveat is a revisioned version of a caveat definition. +type RevisionedCaveat = RevisionedDefinition[*core.CaveatDefinition] + +// CaveatReader offers read operations for caveats +type CaveatReader interface { + // ReadCaveatByName returns a caveat with the provided name. + // It returns an instance of CaveatNotFoundError if not found. + ReadCaveatByName(ctx context.Context, name string) (caveat *core.CaveatDefinition, lastWritten Revision, err error) + + // ListAllCaveats returns all caveats stored in the system. + ListAllCaveats(ctx context.Context) ([]RevisionedCaveat, error) + + // LookupCaveatsWithNames finds all caveats with the matching names. + LookupCaveatsWithNames(ctx context.Context, names []string) ([]RevisionedCaveat, error) +} + +// CaveatStorer offers both read and write operations for Caveats +type CaveatStorer interface { + CaveatReader + + // WriteCaveats stores the provided caveats, and returns the assigned IDs + // Each element of the returning slice corresponds by position to the input slice + WriteCaveats(context.Context, []*core.CaveatDefinition) error + + // DeleteCaveats deletes the provided caveats by name + DeleteCaveats(ctx context.Context, names []string) error +} diff --git a/vendor/github.com/authzed/spicedb/pkg/datastore/context.go b/vendor/github.com/authzed/spicedb/pkg/datastore/context.go new file mode 100644 index 0000000..1ea451e --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/datastore/context.go @@ -0,0 +1 @@ +package datastore diff --git a/vendor/github.com/authzed/spicedb/pkg/datastore/counters.go b/vendor/github.com/authzed/spicedb/pkg/datastore/counters.go new file mode 100644 index 0000000..9b90ea4 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/datastore/counters.go @@ -0,0 +1,47 @@ +package datastore + +import ( + "context" + + core "github.com/authzed/spicedb/pkg/proto/core/v1" +) + +// RelationshipCounter is a struct that represents a count of relationships that match a filter. +type RelationshipCounter struct { + // Name is the name of the counter. + Name string + + // Filter is the filter that the count represents. + Filter *core.RelationshipFilter + + // Count is the count of relationships that match the filter. + Count int + + // ComputedAtRevision is the revision at which the count was last computed. If NoRevision, + // the count has never been computed. + ComputedAtRevision Revision +} + +// CounterRegisterer is an interface for registering and unregistering counts. +type CounterRegisterer interface { + // RegisterCounter registers a count with the provided filter. If the counter already exists, + // returns an error. + RegisterCounter(ctx context.Context, name string, filter *core.RelationshipFilter) error + + // UnregisterCounter unregisters a counter. If the counter did not exist, returns an error. + UnregisterCounter(ctx context.Context, name string) error + + // StoreCounterValue stores a count for the counter with the given name, at the given revision. + // If the counter does not exist, returns an error. + StoreCounterValue(ctx context.Context, name string, value int, computedAtRevision Revision) error +} + +// CounterReader is an interface for reading counts. +type CounterReader interface { + // CountRelationships returns the count of relationships that match the provided counter. If the counter is not + // registered, returns an error. + CountRelationships(ctx context.Context, name string) (int, error) + + // LookupCounters returns all registered counters. + LookupCounters(ctx context.Context) ([]RelationshipCounter, error) +} diff --git a/vendor/github.com/authzed/spicedb/pkg/datastore/credentials.go b/vendor/github.com/authzed/spicedb/pkg/datastore/credentials.go new file mode 100644 index 0000000..9c4a093 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/datastore/credentials.go @@ -0,0 +1,94 @@ +package datastore + +import ( + "context" + "fmt" + "sort" + "strings" + + "github.com/aws/aws-sdk-go-v2/aws" + awsconfig "github.com/aws/aws-sdk-go-v2/config" + rdsauth "github.com/aws/aws-sdk-go-v2/feature/rds/auth" + "golang.org/x/exp/maps" + + log "github.com/authzed/spicedb/internal/logging" +) + +// CredentialsProvider allows datastore credentials to be retrieved dynamically +type CredentialsProvider interface { + // Name returns the name of the provider + Name() string + // IsCleartextToken returns true if the token returned represents a token (rather than a password) that must be sent in cleartext to the datastore, or false otherwise. + // This may be used to configure the datastore options to avoid sending a hash of the token instead of its value. + // Note that it is always recommended that communication channel be encrypted. + IsCleartextToken() bool + // Get returns the username and password to use when connecting to the underlying datastore + Get(ctx context.Context, dbEndpoint string, dbUser string) (string, string, error) +} + +var NoCredentialsProvider CredentialsProvider = nil + +type credentialsProviderBuilderFunc func(ctx context.Context) (CredentialsProvider, error) + +const ( + // AWSIAMCredentialProvider generates AWS IAM tokens for authenticating with the datastore (i.e. RDS) + AWSIAMCredentialProvider = "aws-iam" +) + +var BuilderForCredentialProvider = map[string]credentialsProviderBuilderFunc{ + AWSIAMCredentialProvider: newAWSIAMCredentialsProvider, +} + +// CredentialsProviderOptions returns the full set of credential provider names, sorted and quoted into a string. +func CredentialsProviderOptions() string { + ids := maps.Keys(BuilderForCredentialProvider) + sort.Strings(ids) + quoted := make([]string, 0, len(ids)) + for _, id := range ids { + quoted = append(quoted, `"`+id+`"`) + } + return strings.Join(quoted, ", ") +} + +// NewCredentialsProvider create a new CredentialsProvider for the given name +// returns an error if no match is found, of if there is a problem creating the given CredentialsProvider +func NewCredentialsProvider(ctx context.Context, name string) (CredentialsProvider, error) { + builder, ok := BuilderForCredentialProvider[name] + if !ok { + return nil, fmt.Errorf("unknown credentials provider: %s", name) + } + return builder(ctx) +} + +// AWS IAM provider + +func newAWSIAMCredentialsProvider(ctx context.Context) (CredentialsProvider, error) { + awsSdkConfig, err := awsconfig.LoadDefaultConfig(ctx) + if err != nil { + return nil, err + } + return &awsIamCredentialsProvider{awsSdkConfig: awsSdkConfig}, nil +} + +type awsIamCredentialsProvider struct { + awsSdkConfig aws.Config +} + +func (d awsIamCredentialsProvider) Name() string { + return AWSIAMCredentialProvider +} + +func (d awsIamCredentialsProvider) IsCleartextToken() bool { + // The AWS IAM token can be of an arbitrary length and must not be hashed or truncated by the datastore driver + // See https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/UsingWithRDS.IAMDBAuth.html + return true +} + +func (d awsIamCredentialsProvider) Get(ctx context.Context, dbEndpoint string, dbUser string) (string, string, error) { + authToken, err := rdsauth.BuildAuthToken(ctx, dbEndpoint, d.awsSdkConfig.Region, dbUser, d.awsSdkConfig.Credentials) + if err != nil { + return "", "", err + } + log.Ctx(ctx).Trace().Str("region", d.awsSdkConfig.Region).Str("endpoint", dbEndpoint).Str("user", dbUser).Msg("successfully retrieved IAM auth token for DB") + return dbUser, authToken, nil +} diff --git a/vendor/github.com/authzed/spicedb/pkg/datastore/datastore.go b/vendor/github.com/authzed/spicedb/pkg/datastore/datastore.go new file mode 100644 index 0000000..24cd25f --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/datastore/datastore.go @@ -0,0 +1,992 @@ +package datastore + +import ( + "context" + "fmt" + "iter" + "slices" + "sort" + "strings" + "time" + + "github.com/rs/zerolog" + "google.golang.org/protobuf/types/known/structpb" + + "github.com/authzed/spicedb/pkg/tuple" + + v1 "github.com/authzed/authzed-go/proto/authzed/api/v1" + + "github.com/authzed/spicedb/pkg/datastore/options" + core "github.com/authzed/spicedb/pkg/proto/core/v1" +) + +var Engines []string + +// SortedEngineIDs returns the full set of engine IDs, sorted. +func SortedEngineIDs() []string { + engines := append([]string{}, Engines...) + sort.Strings(engines) + return engines +} + +// EngineOptions returns the full set of engine IDs, sorted and quoted into a string. +func EngineOptions() string { + ids := SortedEngineIDs() + quoted := make([]string, 0, len(ids)) + for _, id := range ids { + quoted = append(quoted, `"`+id+`"`) + } + return strings.Join(quoted, ", ") +} + +// Ellipsis is a special relation that is assumed to be valid on the right +// hand side of a tuple. +const Ellipsis = "..." + +// RevisionChanges represents the changes in a single transaction. +type RevisionChanges struct { + Revision Revision + + // RelationshipChanges are any relationships that were changed at this revision. + RelationshipChanges []tuple.RelationshipUpdate + + // ChangedDefinitions are any definitions that were added or changed at this revision. + ChangedDefinitions []SchemaDefinition + + // DeletedNamespaces are any namespaces that were deleted. + DeletedNamespaces []string + + // DeletedCaveats are any caveats that were deleted. + DeletedCaveats []string + + // IsCheckpoint, if true, indicates that the datastore has reported all changes + // up until and including the Revision and that no additional schema updates can + // have occurred before this point. + IsCheckpoint bool + + // Metadata is the metadata associated with the revision, if any. + Metadata *structpb.Struct +} + +func (rc RevisionChanges) DebugString() string { + if rc.IsCheckpoint { + return "[checkpoint]" + } + + debugString := "" + + for _, relChange := range rc.RelationshipChanges { + debugString += relChange.DebugString() + "\n" + } + + for _, def := range rc.ChangedDefinitions { + debugString += fmt.Sprintf("Definition: %T:%s\n", def, def.GetName()) + } + + for _, ns := range rc.DeletedNamespaces { + debugString += fmt.Sprintf("DeletedNamespace: %s\n", ns) + } + + for _, caveat := range rc.DeletedCaveats { + debugString += fmt.Sprintf("DeletedCaveat: %s\n", caveat) + } + + return debugString +} + +func (rc RevisionChanges) MarshalZerologObject(e *zerolog.Event) { + e.Str("revision", rc.Revision.String()) + e.Bool("is-checkpoint", rc.IsCheckpoint) + e.Array("deleted-namespaces", strArray(rc.DeletedNamespaces)) + e.Array("deleted-caveats", strArray(rc.DeletedCaveats)) + + changedNames := make([]string, 0, len(rc.ChangedDefinitions)) + for _, cd := range rc.ChangedDefinitions { + changedNames = append(changedNames, fmt.Sprintf("%T:%s", cd, cd.GetName())) + } + + e.Array("changed-definitions", strArray(changedNames)) + e.Int("num-changed-relationships", len(rc.RelationshipChanges)) +} + +// ExpirationFilterOption is the filter option for the expiration field on relationships. +type ExpirationFilterOption int + +const ( + // ExpirationFilterOptionNone indicates that the expiration filter should not be used: + // relationships both with and without expiration will be returned. + ExpirationFilterOptionNone ExpirationFilterOption = iota + + // ExpirationFilterOptionHasExpiration indicates that the expiration filter should only + // return relationships with an expiration. + ExpirationFilterOptionHasExpiration + + // ExpirationFilterOptionNoExpiration indicates that the expiration filter should only + // return relationships without an expiration. + ExpirationFilterOptionNoExpiration +) + +// CaveatFilterOption is the filter option for the caveat name field on relationships. +type CaveatFilterOption int + +const ( + // CaveatFilterOptionNone indicates that the caveat filter should not be used: + // relationships both with and without caveats will be returned. + CaveatFilterOptionNone CaveatFilterOption = iota + + // CaveatFilterOptionHasMatchingCaveat indicates that the caveat filter should only + // return relationships with the matching caveat. + CaveatFilterOptionHasMatchingCaveat + + // CaveatFilterOptionNoCaveat indicates that the caveat filter should only + // return relationships without a caveat. + CaveatFilterOptionNoCaveat +) + +// RelationshipsFilter is a filter for relationships. +type RelationshipsFilter struct { + // OptionalResourceType is the namespace/type for the resources to be found. + OptionalResourceType string + + // OptionalResourceIds are the IDs of the resources to find. If nil empty, any resource ID will be allowed. + // Cannot be used with OptionalResourceIDPrefix. + OptionalResourceIds []string + + // OptionalResourceIDPrefix is the prefix to use for resource IDs. If empty, any prefix is allowed. + // Cannot be used with OptionalResourceIds. + OptionalResourceIDPrefix string + + // OptionalResourceRelation is the relation of the resource to find. If empty, any relation is allowed. + OptionalResourceRelation string + + // OptionalSubjectsSelectors is the selectors to use for subjects of the relationship. If nil, all subjects are allowed. + // If specified, relationships matching *any* selector will be returned. + OptionalSubjectsSelectors []SubjectsSelector + + // OptionalCaveatNameFilter is the filter to use for caveated relationships, filtering by a specific caveat name. + // By default, no caveat filtered is done (one direction or the other). + OptionalCaveatNameFilter CaveatNameFilter + + // OptionalExpirationOption is the filter to use for relationships with or without an expiration. + OptionalExpirationOption ExpirationFilterOption +} + +// Test returns true iff the given relationship is matched by this filter. +func (rf RelationshipsFilter) Test(relationship tuple.Relationship) bool { + if rf.OptionalResourceType != "" && rf.OptionalResourceType != relationship.Resource.ObjectType { + return false + } + + if len(rf.OptionalResourceIds) > 0 && !slices.Contains(rf.OptionalResourceIds, relationship.Resource.ObjectID) { + return false + } + + if rf.OptionalResourceIDPrefix != "" && !strings.HasPrefix(relationship.Resource.ObjectID, rf.OptionalResourceIDPrefix) { + return false + } + + if rf.OptionalResourceRelation != "" && rf.OptionalResourceRelation != relationship.Resource.Relation { + return false + } + + if len(rf.OptionalSubjectsSelectors) > 0 { + for _, selector := range rf.OptionalSubjectsSelectors { + if selector.Test(relationship.Subject) { + return true + } + } + return false + } + + switch rf.OptionalCaveatNameFilter.Option { + case CaveatFilterOptionNone: + // No caveat filter, so no need to check. + + case CaveatFilterOptionHasMatchingCaveat: + if relationship.OptionalCaveat == nil || relationship.OptionalCaveat.CaveatName != rf.OptionalCaveatNameFilter.CaveatName { + return false + } + + case CaveatFilterOptionNoCaveat: + if relationship.OptionalCaveat != nil && relationship.OptionalCaveat.CaveatName != "" { + return false + } + } + + if rf.OptionalExpirationOption == ExpirationFilterOptionHasExpiration && relationship.OptionalExpiration == nil { + return false + } + + if rf.OptionalExpirationOption == ExpirationFilterOptionNoExpiration && relationship.OptionalExpiration != nil { + return false + } + + return true +} + +// CaveatNameFilter is a filter for caveat names. +type CaveatNameFilter struct { + // Option is the filter option to use for the caveat name. + Option CaveatFilterOption + + // CaveatName is the name of the caveat to filter by. Must be specified if option is + // CaveatFilterOptionHasCaveat. + CaveatName string +} + +func WithCaveatName(caveatName string) CaveatNameFilter { + return CaveatNameFilter{ + Option: CaveatFilterOptionHasMatchingCaveat, + CaveatName: caveatName, + } +} + +func WithNoCaveat() CaveatNameFilter { + return CaveatNameFilter{ + Option: CaveatFilterOptionNoCaveat, + } +} + +// CoreFilterFromRelationshipFilter constructs a core RelationshipFilter from a V1 RelationshipsFilter. +func CoreFilterFromRelationshipFilter(filter *v1.RelationshipFilter) *core.RelationshipFilter { + return &core.RelationshipFilter{ + ResourceType: filter.ResourceType, + OptionalResourceId: filter.OptionalResourceId, + OptionalResourceIdPrefix: filter.OptionalResourceIdPrefix, + OptionalRelation: filter.OptionalRelation, + OptionalSubjectFilter: coreFilterFromSubjectsFilter(filter.OptionalSubjectFilter), + } +} + +func coreFilterFromSubjectsFilter(filter *v1.SubjectFilter) *core.SubjectFilter { + if filter == nil { + return nil + } + + return &core.SubjectFilter{ + SubjectType: filter.SubjectType, + OptionalSubjectId: filter.OptionalSubjectId, + OptionalRelation: coreFilterFromSubjectRelationFilter(filter.OptionalRelation), + } +} + +func coreFilterFromSubjectRelationFilter(filter *v1.SubjectFilter_RelationFilter) *core.SubjectFilter_RelationFilter { + if filter == nil { + return nil + } + + return &core.SubjectFilter_RelationFilter{ + Relation: filter.Relation, + } +} + +// RelationshipsFilterFromCoreFilter constructs a datastore RelationshipsFilter from a core RelationshipFilter. +func RelationshipsFilterFromCoreFilter(filter *core.RelationshipFilter) (RelationshipsFilter, error) { + var resourceIds []string + if filter.OptionalResourceId != "" { + resourceIds = []string{filter.OptionalResourceId} + } + + var subjectsSelectors []SubjectsSelector + if filter.OptionalSubjectFilter != nil { + var subjectIds []string + if filter.OptionalSubjectFilter.OptionalSubjectId != "" { + subjectIds = []string{filter.OptionalSubjectFilter.OptionalSubjectId} + } + + relationFilter := SubjectRelationFilter{} + + if filter.OptionalSubjectFilter.OptionalRelation != nil { + relation := filter.OptionalSubjectFilter.OptionalRelation.GetRelation() + if relation != "" { + relationFilter = relationFilter.WithNonEllipsisRelation(relation) + } else { + relationFilter = relationFilter.WithEllipsisRelation() + } + } + + subjectsSelectors = append(subjectsSelectors, SubjectsSelector{ + OptionalSubjectType: filter.OptionalSubjectFilter.SubjectType, + OptionalSubjectIds: subjectIds, + RelationFilter: relationFilter, + }) + } + + if filter.OptionalResourceId != "" && filter.OptionalResourceIdPrefix != "" { + return RelationshipsFilter{}, fmt.Errorf("cannot specify both OptionalResourceId and OptionalResourceIDPrefix") + } + + if filter.ResourceType == "" && filter.OptionalRelation == "" && len(resourceIds) == 0 && filter.OptionalResourceIdPrefix == "" && len(subjectsSelectors) == 0 { + return RelationshipsFilter{}, fmt.Errorf("at least one filter field must be set") + } + + return RelationshipsFilter{ + OptionalResourceType: filter.ResourceType, + OptionalResourceIds: resourceIds, + OptionalResourceIDPrefix: filter.OptionalResourceIdPrefix, + OptionalResourceRelation: filter.OptionalRelation, + OptionalSubjectsSelectors: subjectsSelectors, + }, nil +} + +// RelationshipsFilterFromPublicFilter constructs a datastore RelationshipsFilter from an API-defined RelationshipFilter. +func RelationshipsFilterFromPublicFilter(filter *v1.RelationshipFilter) (RelationshipsFilter, error) { + var resourceIds []string + if filter.OptionalResourceId != "" { + resourceIds = []string{filter.OptionalResourceId} + } + + var subjectsSelectors []SubjectsSelector + if filter.OptionalSubjectFilter != nil { + var subjectIds []string + if filter.OptionalSubjectFilter.OptionalSubjectId != "" { + subjectIds = []string{filter.OptionalSubjectFilter.OptionalSubjectId} + } + + relationFilter := SubjectRelationFilter{} + + if filter.OptionalSubjectFilter.OptionalRelation != nil { + relation := filter.OptionalSubjectFilter.OptionalRelation.GetRelation() + if relation != "" { + relationFilter = relationFilter.WithNonEllipsisRelation(relation) + } else { + relationFilter = relationFilter.WithEllipsisRelation() + } + } + + subjectsSelectors = append(subjectsSelectors, SubjectsSelector{ + OptionalSubjectType: filter.OptionalSubjectFilter.SubjectType, + OptionalSubjectIds: subjectIds, + RelationFilter: relationFilter, + }) + } + + if filter.OptionalResourceId != "" && filter.OptionalResourceIdPrefix != "" { + return RelationshipsFilter{}, fmt.Errorf("cannot specify both OptionalResourceId and OptionalResourceIDPrefix") + } + + if filter.ResourceType == "" && filter.OptionalRelation == "" && len(resourceIds) == 0 && filter.OptionalResourceIdPrefix == "" && len(subjectsSelectors) == 0 { + return RelationshipsFilter{}, fmt.Errorf("at least one filter field must be set") + } + + return RelationshipsFilter{ + OptionalResourceType: filter.ResourceType, + OptionalResourceIds: resourceIds, + OptionalResourceIDPrefix: filter.OptionalResourceIdPrefix, + OptionalResourceRelation: filter.OptionalRelation, + OptionalSubjectsSelectors: subjectsSelectors, + }, nil +} + +// SubjectsSelector is a selector for subjects. +type SubjectsSelector struct { + // OptionalSubjectType is the namespace/type for the subjects to be found, if any. + OptionalSubjectType string + + // OptionalSubjectIds are the IDs of the subjects to find. If nil or empty, any subject ID will be allowed. + OptionalSubjectIds []string + + // RelationFilter is the filter to use for the relation(s) of the subjects. If neither field + // is set, any relation is allowed. + RelationFilter SubjectRelationFilter +} + +// Test returns true iff the given subject is matched by this filter. +func (ss SubjectsSelector) Test(subject tuple.ObjectAndRelation) bool { + if ss.OptionalSubjectType != "" && ss.OptionalSubjectType != subject.ObjectType { + return false + } + + if len(ss.OptionalSubjectIds) > 0 && !slices.Contains(ss.OptionalSubjectIds, subject.ObjectID) { + return false + } + + if !ss.RelationFilter.IsEmpty() { + if ss.RelationFilter.IncludeEllipsisRelation && subject.Relation == tuple.Ellipsis { + return true + } + + if ss.RelationFilter.NonEllipsisRelation != "" && ss.RelationFilter.NonEllipsisRelation != subject.Relation { + return false + } + + if ss.RelationFilter.OnlyNonEllipsisRelations && subject.Relation == tuple.Ellipsis { + return false + } + } + + return true +} + +// SubjectRelationFilter is the filter to use for relation(s) of subjects being queried. +type SubjectRelationFilter struct { + // NonEllipsisRelation is the relation of the subject type to find. If empty, + // IncludeEllipsisRelation must be true. + NonEllipsisRelation string + + // IncludeEllipsisRelation, if true, indicates that the ellipsis relation + // should be included as an option. + IncludeEllipsisRelation bool + + // OnlyNonEllipsisRelations, if true, indicates that only non-ellipsis relations + // should be included. + OnlyNonEllipsisRelations bool +} + +// WithOnlyNonEllipsisRelations indicates that only non-ellipsis relations should be included. +func (sf SubjectRelationFilter) WithOnlyNonEllipsisRelations() SubjectRelationFilter { + sf.OnlyNonEllipsisRelations = true + sf.NonEllipsisRelation = "" + sf.IncludeEllipsisRelation = false + return sf +} + +// WithEllipsisRelation indicates that the subject filter should include the ellipsis relation +// as an option for the subjects' relation. +func (sf SubjectRelationFilter) WithEllipsisRelation() SubjectRelationFilter { + sf.IncludeEllipsisRelation = true + sf.OnlyNonEllipsisRelations = false + return sf +} + +// WithNonEllipsisRelation indicates that the specified non-ellipsis relation should be included as an +// option for the subjects' relation. +func (sf SubjectRelationFilter) WithNonEllipsisRelation(relation string) SubjectRelationFilter { + sf.NonEllipsisRelation = relation + sf.OnlyNonEllipsisRelations = false + return sf +} + +// WithRelation indicates that the specified relation should be included as an +// option for the subjects' relation. +func (sf SubjectRelationFilter) WithRelation(relation string) SubjectRelationFilter { + if relation == tuple.Ellipsis { + return sf.WithEllipsisRelation() + } + return sf.WithNonEllipsisRelation(relation) +} + +// IsEmpty returns true if the subject relation filter is empty. +func (sf SubjectRelationFilter) IsEmpty() bool { + return !sf.IncludeEllipsisRelation && sf.NonEllipsisRelation == "" && !sf.OnlyNonEllipsisRelations +} + +// SubjectsFilter is a filter for subjects. +type SubjectsFilter struct { + // SubjectType is the namespace/type for the subjects to be found. + SubjectType string + + // OptionalSubjectIds are the IDs of the subjects to find. If nil or empty, any subject ID will be allowed. + OptionalSubjectIds []string + + // RelationFilter is the filter to use for the relation(s) of the subjects. If neither field + // is set, any relation is allowed. + RelationFilter SubjectRelationFilter +} + +func (sf SubjectsFilter) AsSelector() SubjectsSelector { + return SubjectsSelector{ + OptionalSubjectType: sf.SubjectType, + OptionalSubjectIds: sf.OptionalSubjectIds, + RelationFilter: sf.RelationFilter, + } +} + +// SchemaDefinition represents a namespace or caveat definition under a schema. +type SchemaDefinition interface { + GetName() string + SizeVT() int +} + +// RevisionedDefinition holds a schema definition and its last updated revision. +type RevisionedDefinition[T SchemaDefinition] struct { + // Definition is the namespace or caveat definition. + Definition T + + // LastWrittenRevision is the revision at which the namespace or caveat was last updated. + LastWrittenRevision Revision +} + +func (rd RevisionedDefinition[T]) GetLastWrittenRevision() Revision { + return rd.LastWrittenRevision +} + +// RevisionedNamespace is a revisioned version of a namespace definition. +type RevisionedNamespace = RevisionedDefinition[*core.NamespaceDefinition] + +// Reader is an interface for reading relationships from the datastore. +type Reader interface { + CaveatReader + CounterReader + + // QueryRelationships reads relationships, starting from the resource side. + QueryRelationships( + ctx context.Context, + filter RelationshipsFilter, + options ...options.QueryOptionsOption, + ) (RelationshipIterator, error) + + // ReverseQueryRelationships reads relationships, starting from the subject. + ReverseQueryRelationships( + ctx context.Context, + subjectsFilter SubjectsFilter, + options ...options.ReverseQueryOptionsOption, + ) (RelationshipIterator, error) + + // ReadNamespaceByName reads a namespace definition and the revision at which it was created or + // last written. It returns an instance of NamespaceNotFoundError if not found. + ReadNamespaceByName(ctx context.Context, nsName string) (ns *core.NamespaceDefinition, lastWritten Revision, err error) + + // ListAllNamespaces lists all namespaces defined. + ListAllNamespaces(ctx context.Context) ([]RevisionedNamespace, error) + + // LookupNamespacesWithNames finds all namespaces with the matching names. + LookupNamespacesWithNames(ctx context.Context, nsNames []string) ([]RevisionedNamespace, error) +} + +type ReadWriteTransaction interface { + Reader + CaveatStorer + CounterRegisterer + + // WriteRelationships takes a list of tuple mutations and applies them to the datastore. + WriteRelationships(ctx context.Context, mutations []tuple.RelationshipUpdate) error + + // DeleteRelationships deletes relationships that match the provided filter, with + // the optional limit. Returns the number of deleted relationships. If a limit + // is provided and reached, the method will return true as the second return value. + // Otherwise, the boolean can be ignored. + DeleteRelationships(ctx context.Context, filter *v1.RelationshipFilter, + options ...options.DeleteOptionsOption, + ) (uint64, bool, error) + + // WriteNamespaces takes proto namespace definitions and persists them. + WriteNamespaces(ctx context.Context, newConfigs ...*core.NamespaceDefinition) error + + // DeleteNamespaces deletes namespaces including associated relationships. + DeleteNamespaces(ctx context.Context, nsNames ...string) error + + // BulkLoad takes a relationship source iterator, and writes all of the + // relationships to the backing datastore in an optimized fashion. This + // method can and will omit checks and otherwise cut corners in the + // interest of performance, and should not be relied upon for OLTP-style + // workloads. + BulkLoad(ctx context.Context, iter BulkWriteRelationshipSource) (uint64, error) +} + +// TxUserFunc is a type for the function that users supply when they invoke a read-write transaction. +type TxUserFunc func(context.Context, ReadWriteTransaction) error + +// ReadyState represents the ready state of the datastore. +type ReadyState struct { + // Message is a human-readable status message for the current state. + Message string + + // IsReady indicates whether the datastore is ready. + IsReady bool +} + +// BulkWriteRelationshipSource is an interface for transferring relationships +// to a backing datastore with a zero-copy methodology. +type BulkWriteRelationshipSource interface { + // Next Returns a pointer to a relation tuple if one is available, or nil if + // there are no more or there was an error. + // + // Note: sources may re-use the same memory address for every tuple, data + // may change on every call to next even if the pointer has not changed. + Next(ctx context.Context) (*tuple.Relationship, error) +} + +type WatchContent int + +const ( + WatchRelationships WatchContent = 1 << 0 + WatchSchema WatchContent = 1 << 1 + WatchCheckpoints WatchContent = 1 << 2 +) + +// WatchOptions are options for a Watch call. +type WatchOptions struct { + // Content is the content to watch. + Content WatchContent + + // CheckpointInterval is the interval to use for checkpointing in the watch. + // If given the zero value, the datastore's default will be used. If smaller + // than the datastore's minimum, the minimum will be used. + CheckpointInterval time.Duration + + // WatchBufferLength is the length of the buffer for the watch channel. If + // given the zero value, the datastore's default will be used. + WatchBufferLength uint16 + + // WatchBufferWriteTimeout is the timeout for writing to the watch channel. + // If given the zero value, the datastore's default will be used. + WatchBufferWriteTimeout time.Duration + + // WatchConnectTimeout is the timeout for connecting to the watch channel. + // If given the zero value, the datastore's default will be used. + // May not be supported by the datastore. + WatchConnectTimeout time.Duration + + // MaximumBufferedChangesByteSize is the maximum byte size of the buffered changes struct. + // If unspecified, no maximum will be enforced. If the maximum is reached before + // the changes can be sent, the watch will be closed with an error. + MaximumBufferedChangesByteSize uint64 + + // EmissionStrategy defines when are changes streamed to the client. If unspecified, changes will be buffered until + // they can be checkpointed, which is the default behavior. + EmissionStrategy EmissionStrategy +} + +// EmissionStrategy describes when changes are emitted to the client. +type EmissionStrategy int + +const ( + // EmitWhenCheckpointedStrategy will buffer changes until a checkpoint is reached. This also means that + // changes will be deduplicated and revisions will be sorted before emission as soon as they can be checkpointed. + EmitWhenCheckpointedStrategy = iota + + // EmitImmediatelyStrategy emits changes as soon as they are available. This means changes will not be buffered, + // and thus will be emitted as soon as they are available, but clients are responsible for buffering, deduplication, + // and sorting revisions. In practical terms that can only happens if Checkpoints have been requested, so enabling + // EmitImmediatelyStrategy without Checkpoints will return an error. + EmitImmediatelyStrategy +) + +// WatchJustRelationships returns watch options for just relationships. +func WatchJustRelationships() WatchOptions { + return WatchOptions{ + Content: WatchRelationships, + } +} + +// WatchJustSchema returns watch options for just schema. +func WatchJustSchema() WatchOptions { + return WatchOptions{ + Content: WatchSchema, + } +} + +// WithCheckpointInterval sets the checkpoint interval on a watch options, returning +// an updated options struct. +func (wo WatchOptions) WithCheckpointInterval(interval time.Duration) WatchOptions { + return WatchOptions{ + Content: wo.Content, + CheckpointInterval: interval, + } +} + +// ReadOnlyDatastore is an interface for reading relationships from the datastore. +type ReadOnlyDatastore interface { + // MetricsID returns an identifier for the datastore for use in metrics. + // This identifier is typically the hostname of the datastore (where applicable) + // and may not be unique; callers should not rely on uniqueness. + MetricsID() (string, error) + + // SnapshotReader creates a read-only handle that reads the datastore at the specified revision. + // Any errors establishing the reader will be returned by subsequent calls. + SnapshotReader(Revision) Reader + + // OptimizedRevision gets a revision that will likely already be replicated + // and will likely be shared amongst many queries. + OptimizedRevision(ctx context.Context) (Revision, error) + + // HeadRevision gets a revision that is guaranteed to be at least as fresh as + // right now. + HeadRevision(ctx context.Context) (Revision, error) + + // CheckRevision checks the specified revision to make sure it's valid and + // hasn't been garbage collected. + CheckRevision(ctx context.Context, revision Revision) error + + // RevisionFromString will parse the revision text and return the specific type of Revision + // used by the specific datastore implementation. + RevisionFromString(serialized string) (Revision, error) + + // Watch notifies the caller about changes to the datastore, based on the specified options. + // + // All events following afterRevision will be sent to the caller. + // + // Errors returned will fall into a few classes: + // - WatchDisconnectedError - the watch has fallen too far behind and has been disconnected. + // - WatchCanceledError - the watch was canceled by the caller. + // - WatchDisabledError - the watch is disabled by being unsupported by the datastore. + // - WatchRetryableError - the watch is retryable, and the caller may retry after some backoff time. + // - InvalidRevisionError - the revision specified has passed the datastore's watch history window and + // the watch cannot be retried. + // - Other errors - the watch should not be retried due to a fatal error. + Watch(ctx context.Context, afterRevision Revision, options WatchOptions) (<-chan RevisionChanges, <-chan error) + + // ReadyState returns a state indicating whether the datastore is ready to accept data. + // Datastores that require database schema creation will return not-ready until the migrations + // have been run to create the necessary tables. + ReadyState(ctx context.Context) (ReadyState, error) + + // Features returns an object representing what features this + // datastore can support. Can make calls to the database, so should + // only be used when a connection is allowed. + Features(ctx context.Context) (*Features, error) + + // OfflineFeatures returns an object representing what features this + // datastore supports code-wise, without making any calls to the database. + OfflineFeatures() (*Features, error) + + // Statistics returns relevant values about the data contained in this cluster. + Statistics(ctx context.Context) (Stats, error) + + // Close closes the data store. + Close() error +} + +// Datastore represents tuple access for a single namespace. +type Datastore interface { + ReadOnlyDatastore + + // ReadWriteTx starts a read/write transaction, which will be committed if no error is + // returned and rolled back if an error is returned. + ReadWriteTx(context.Context, TxUserFunc, ...options.RWTOptionsOption) (Revision, error) +} + +// ParsedExplain represents the parsed output of an EXPLAIN statement. +type ParsedExplain struct { + // IndexesUsed is the list of indexes used in the query. + IndexesUsed []string +} + +// Explainable is an interface for datastores that support EXPLAIN statements. +type Explainable interface { + // BuildExplainQuery builds an EXPLAIN statement for the given SQL and arguments. + BuildExplainQuery(sql string, args []any) (string, []any, error) + + // ParseExplain parses the output of an EXPLAIN statement. + ParseExplain(explain string) (ParsedExplain, error) + + // PreExplainStatements returns any statements that should be run before the EXPLAIN statement. + PreExplainStatements() []string +} + +// SQLDatastore is an interface for datastores that support SQL-based operations. +type SQLDatastore interface { + Datastore + Explainable +} + +// StrictReadDatastore is an interface for datastores that support strict read mode. +type StrictReadDatastore interface { + Datastore + + // IsStrictReadModeEnabled returns whether the datastore is in strict read mode. + IsStrictReadModeEnabled() bool +} + +type strArray []string + +// MarshalZerologArray implements zerolog array marshalling. +func (strs strArray) MarshalZerologArray(a *zerolog.Array) { + for _, val := range strs { + a.Str(val) + } +} + +// StartableDatastore is an optional extension to the datastore interface that, when implemented, +// provides the ability for callers to start background operations on the datastore. +type StartableDatastore interface { + Datastore + + // Start starts any background operations on the datastore. The context provided, if canceled, will + // also cancel the background operation(s) on the datastore. + Start(ctx context.Context) error +} + +// RepairOperation represents a single kind of repair operation that can be run in a repairable +// datastore. +type RepairOperation struct { + // Name is the command-line name for the repair operation. + Name string + + // Description is the human-readable description for the repair operation. + Description string +} + +// RepairableDatastore is an optional extension to the datastore interface that, when implemented, +// provides the ability for callers to repair the datastore's data in some fashion. +type RepairableDatastore interface { + Datastore + + // Repair runs the repair operation on the datastore. + Repair(ctx context.Context, operationName string, outputProgress bool) error + + // RepairOperations returns the available repair operations for the datastore. + RepairOperations() []RepairOperation +} + +// UnwrappableDatastore represents a datastore that can be unwrapped into the underlying +// datastore. +type UnwrappableDatastore interface { + // Unwrap returns the wrapped datastore. + Unwrap() Datastore +} + +// UnwrapAs recursively attempts to unwrap the datastore into the specified type +// In none of the layers of the datastore implement the specified type, nil is returned. +func UnwrapAs[T any](datastore Datastore) T { + var ds T + uwds := datastore + + for { + var ok bool + ds, ok = uwds.(T) + if ok { + break + } + + wds, ok := uwds.(UnwrappableDatastore) + if !ok { + break + } + + uwds = wds.Unwrap() + } + + return ds +} + +// FeatureStatus are the possible statuses for a feature in the datastore. +type FeatureStatus int + +const ( + // FeatureStatusUnknown indicates that the status of the feature is unknown. + // This can be returned, for example, when a call is made to OfflineFeatures + // but the feature requires a call to the database to determine its status. + FeatureStatusUnknown FeatureStatus = iota + + // FeatureSupported indicates that the feature is supported by the datastore. + FeatureSupported + + // FeatureUnsupported indicates that the feature is not supported by the datastore. + FeatureUnsupported +) + +// Feature represents a capability that a datastore can support, plus an +// optional message explaining the feature is available (or not). +type Feature struct { + Status FeatureStatus + Reason string +} + +// Features holds values that represent what features a database can support. +type Features struct { + // Watch is enabled if the underlying datastore can support the Watch api. + Watch Feature + + // ContinuousCheckpointing is enabled if the underlying datastore supports continuous checkpointing + // via the Watch API. If not supported, clients of the Watch API may expect checkpoints only when + // new transactions are committed. + ContinuousCheckpointing Feature + + // WatchEmitsImmediately indicates if the datastore supports the EmitImmediatelyStrategy EmissionStrategy. + // If not supported, clients of the Watch API will receive an error when calling Watch API with + // EmitImmediatelyStrategy option. + WatchEmitsImmediately Feature + + // IntegrityData is enabled if the underlying datastore supports retrieving and storing + // integrity information. + IntegrityData Feature +} + +// ObjectTypeStat represents statistics for a single object type (namespace). +type ObjectTypeStat struct { + // NumRelations is the number of relations defined in a single object type. + NumRelations uint32 + + // NumPermissions is the number of permissions defined in a single object type. + NumPermissions uint32 +} + +// Stats represents statistics for the entire datastore. +type Stats struct { + // UniqueID is a unique string for a single datastore. + UniqueID string + + // EstimatedRelationshipCount is a best-guess estimate of the number of relationships + // in the datastore. Computing it should use a lightweight method such as reading + // table statistics. + EstimatedRelationshipCount uint64 + + // ObjectTypeStatistics returns a slice element for each object type (namespace) + // stored in the datastore. + ObjectTypeStatistics []ObjectTypeStat +} + +// RelationshipIterator is an iterator over matched tuples. It is a single use +// iterator. +type RelationshipIterator iter.Seq2[tuple.Relationship, error] + +func IteratorToSlice(iter RelationshipIterator) ([]tuple.Relationship, error) { + results := make([]tuple.Relationship, 0) + for rel, err := range iter { + if err != nil { + return nil, err + } + results = append(results, rel) + } + return results, nil +} + +// FirstRelationshipIn returns the first relationship found via the iterator, if any. +func FirstRelationshipIn(iter RelationshipIterator) (tuple.Relationship, bool, error) { + for rel, err := range iter { + if err != nil { + return tuple.Relationship{}, false, err + } + + return rel, true, nil + } + + return tuple.Relationship{}, false, nil +} + +// Revision is an interface for a comparable revision type that can be different for +// each datastore implementation. +type Revision interface { + fmt.Stringer + + // Equal returns whether the revisions should be considered equal. + Equal(Revision) bool + + // GreaterThan returns whether the receiver is probably greater than the right hand side. + GreaterThan(Revision) bool + + // LessThan returns whether the receiver is probably less than the right hand side. + LessThan(Revision) bool + + // ByteSortable returns true if the string representation of the Revision is byte sortable, false otherwise. + ByteSortable() bool +} + +type nilRevision struct{} + +func (nilRevision) ByteSortable() bool { + return false +} + +func (nilRevision) Equal(rhs Revision) bool { + return rhs == NoRevision +} + +func (nilRevision) GreaterThan(_ Revision) bool { + return false +} + +func (nilRevision) LessThan(_ Revision) bool { + return true +} + +func (nilRevision) String() string { + return "nil" +} + +// NoRevision is a zero type for the revision that will make changing the +// revision type in the future a bit easier if necessary. Implementations +// should use any time they want to signal an empty/error revision. +var NoRevision Revision = nilRevision{} diff --git a/vendor/github.com/authzed/spicedb/pkg/datastore/doc.go b/vendor/github.com/authzed/spicedb/pkg/datastore/doc.go new file mode 100644 index 0000000..2ffd9e6 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/datastore/doc.go @@ -0,0 +1,2 @@ +// Package datastore contains interfaces and code common to all datastores. +package datastore diff --git a/vendor/github.com/authzed/spicedb/pkg/datastore/errors.go b/vendor/github.com/authzed/spicedb/pkg/datastore/errors.go new file mode 100644 index 0000000..84057d5 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/datastore/errors.go @@ -0,0 +1,281 @@ +package datastore + +import ( + "errors" + "fmt" + + "github.com/rs/zerolog" + + core "github.com/authzed/spicedb/pkg/proto/core/v1" +) + +// ErrNotFound is a shared interface for not found errors. +type ErrNotFound interface { + IsNotFoundError() bool +} + +// NamespaceNotFoundError occurs when a namespace was not found. +type NamespaceNotFoundError struct { + error + namespaceName string +} + +var _ ErrNotFound = NamespaceNotFoundError{} + +func (err NamespaceNotFoundError) IsNotFoundError() bool { + return true +} + +// NotFoundNamespaceName is the name of the namespace not found. +func (err NamespaceNotFoundError) NotFoundNamespaceName() string { + return err.namespaceName +} + +// MarshalZerologObject implements zerolog object marshalling. +func (err NamespaceNotFoundError) MarshalZerologObject(e *zerolog.Event) { + e.Err(err.error).Str("namespace", err.namespaceName) +} + +// DetailsMetadata returns the metadata for details for this error. +func (err NamespaceNotFoundError) DetailsMetadata() map[string]string { + return map[string]string{ + "definition_name": err.namespaceName, + } +} + +// WatchDisconnectedError occurs when a watch has fallen too far behind and was forcibly disconnected +// as a result. +type WatchDisconnectedError struct{ error } + +// WatchCanceledError occurs when a watch was canceled by the caller. +type WatchCanceledError struct{ error } + +// WatchDisabledError occurs when watch is disabled by being unsupported by the datastore. +type WatchDisabledError struct{ error } + +// ReadOnlyError is returned when the operation cannot be completed because the datastore is in +// read-only mode. +type ReadOnlyError struct{ error } + +// WatchRetryableError is returned when a transient/temporary error occurred in watch and indicates that +// the caller *may* retry the watch after some backoff time. +type WatchRetryableError struct{ error } + +// InvalidRevisionReason is the reason the revision could not be used. +type InvalidRevisionReason int + +const ( + // RevisionStale is the reason returned when a revision is outside the window of + // validity by being too old. + RevisionStale InvalidRevisionReason = iota + + // CouldNotDetermineRevision is the reason returned when a revision for a + // request could not be determined. + CouldNotDetermineRevision +) + +// InvalidRevisionError occurs when a revision specified to a call was invalid. +type InvalidRevisionError struct { + error + revision Revision + reason InvalidRevisionReason +} + +// InvalidRevision is the revision that failed. +func (err InvalidRevisionError) InvalidRevision() Revision { + return err.revision +} + +// Reason is the reason the revision failed. +func (err InvalidRevisionError) Reason() InvalidRevisionReason { + return err.reason +} + +// MarshalZerologObject implements zerolog object marshalling. +func (err InvalidRevisionError) MarshalZerologObject(e *zerolog.Event) { + switch err.reason { + case RevisionStale: + e.Err(err.error).Str("reason", "stale") + case CouldNotDetermineRevision: + e.Err(err.error).Str("reason", "indeterminate") + default: + e.Err(err.error).Str("reason", "unknown") + } +} + +// NewNamespaceNotFoundErr constructs a new namespace not found error. +func NewNamespaceNotFoundErr(nsName string) error { + return NamespaceNotFoundError{ + error: fmt.Errorf("object definition `%s` not found", nsName), + namespaceName: nsName, + } +} + +// NewWatchDisconnectedErr constructs a new watch was disconnected error. +func NewWatchDisconnectedErr() error { + return WatchDisconnectedError{ + error: fmt.Errorf("watch fell too far behind and was disconnected; consider increasing watch buffer size via the flag --datastore-watch-buffer-length"), + } +} + +// NewWatchCanceledErr constructs a new watch was canceled error. +func NewWatchCanceledErr() error { + return WatchCanceledError{ + error: fmt.Errorf("watch was canceled by the caller"), + } +} + +// NewWatchDisabledErr constructs a new watch is disabled error. +func NewWatchDisabledErr(reason string) error { + return WatchDisabledError{ + error: fmt.Errorf("watch is currently disabled: %s", reason), + } +} + +// NewWatchTemporaryErr wraps another error in watch, indicating that the error is likely +// a temporary condition and clients may consider retrying by calling watch again (vs a fatal error). +func NewWatchTemporaryErr(wrapped error) error { + return WatchRetryableError{ + error: fmt.Errorf("watch has failed with a temporary condition: %w. please retry the watch", wrapped), + } +} + +// NewReadonlyErr constructs an error for when a request has failed because +// the datastore has been configured to be read-only. +func NewReadonlyErr() error { + return ReadOnlyError{ + error: fmt.Errorf("datastore is in read-only mode"), + } +} + +// NewInvalidRevisionErr constructs a new invalid revision error. +func NewInvalidRevisionErr(revision Revision, reason InvalidRevisionReason) error { + switch reason { + case RevisionStale: + return InvalidRevisionError{ + error: fmt.Errorf("revision has expired"), + revision: revision, + reason: reason, + } + + default: + return InvalidRevisionError{ + error: fmt.Errorf("revision was invalid"), + revision: revision, + reason: reason, + } + } +} + +// CaveatNameNotFoundError is the error returned when a caveat is not found by its name +type CaveatNameNotFoundError struct { + error + name string +} + +var _ ErrNotFound = CaveatNameNotFoundError{} + +func (err CaveatNameNotFoundError) IsNotFoundError() bool { + return true +} + +// CaveatName returns the name of the caveat that couldn't be found +func (err CaveatNameNotFoundError) CaveatName() string { + return err.name +} + +// NewCaveatNameNotFoundErr constructs a new caveat name not found error. +func NewCaveatNameNotFoundErr(name string) error { + return CaveatNameNotFoundError{ + error: fmt.Errorf("caveat with name `%s` not found", name), + name: name, + } +} + +// DetailsMetadata returns the metadata for details for this error. +func (err CaveatNameNotFoundError) DetailsMetadata() map[string]string { + return map[string]string{ + "caveat_name": err.name, + } +} + +// CounterNotRegisteredError indicates that a counter was not registered. +type CounterNotRegisteredError struct { + error + counterName string +} + +// NewCounterNotRegisteredErr constructs a new counter not registered error. +func NewCounterNotRegisteredErr(counterName string) error { + return CounterNotRegisteredError{ + error: fmt.Errorf("counter with name `%s` not found", counterName), + counterName: counterName, + } +} + +// DetailsMetadata returns the metadata for details for this error. +func (err CounterNotRegisteredError) DetailsMetadata() map[string]string { + return map[string]string{ + "counter_name": err.counterName, + } +} + +// CounterAlreadyRegisteredError indicates that a counter was already registered. +type CounterAlreadyRegisteredError struct { + error + + counterName string + filter *core.RelationshipFilter +} + +// NewCounterAlreadyRegisteredErr constructs a new filter not registered error. +func NewCounterAlreadyRegisteredErr(counterName string, filter *core.RelationshipFilter) error { + return CounterAlreadyRegisteredError{ + error: fmt.Errorf("counter with name `%s` already registered", counterName), + counterName: counterName, + filter: filter, + } +} + +// DetailsMetadata returns the metadata for details for this error. +func (err CounterAlreadyRegisteredError) DetailsMetadata() map[string]string { + subjectType := "" + subjectID := "" + subjectRelation := "" + if err.filter.OptionalSubjectFilter != nil { + subjectType = err.filter.OptionalSubjectFilter.SubjectType + subjectID = err.filter.OptionalSubjectFilter.OptionalSubjectId + + if err.filter.OptionalSubjectFilter.GetOptionalRelation() != nil { + subjectRelation = err.filter.OptionalSubjectFilter.GetOptionalRelation().Relation + } + } + + return map[string]string{ + "counter_name": err.counterName, + "new_filter_resource_type": err.filter.ResourceType, + "new_filter_resource_id": err.filter.OptionalResourceId, + "new_filter_resource_id_prefix": err.filter.OptionalResourceIdPrefix, + "new_filter_relation": err.filter.OptionalRelation, + "new_filter_subject_type": subjectType, + "new_filter_subject_id": subjectID, + "new_filter_subject_relation": subjectRelation, + } +} + +// MaximumChangesSizeExceededError is returned when the maximum size of changes is exceeded. +type MaximumChangesSizeExceededError struct { + error + maxSize uint64 +} + +// NewMaximumChangesSizeExceededError creates a new MaximumChangesSizeExceededError. +func NewMaximumChangesSizeExceededError(maxSize uint64) error { + return MaximumChangesSizeExceededError{fmt.Errorf("maximum changes byte size of %d exceeded", maxSize), maxSize} +} + +var ( + ErrClosedIterator = errors.New("unable to iterate: iterator closed") + ErrCursorsWithoutSorting = errors.New("cursors are disabled on unsorted results") + ErrCursorEmpty = errors.New("cursors are only available after the first result") +) diff --git a/vendor/github.com/authzed/spicedb/pkg/datastore/options/options.go b/vendor/github.com/authzed/spicedb/pkg/datastore/options/options.go new file mode 100644 index 0000000..18477f8 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/datastore/options/options.go @@ -0,0 +1,123 @@ +package options + +import ( + "context" + + "google.golang.org/protobuf/types/known/structpb" + + "github.com/authzed/spicedb/pkg/datastore/queryshape" + "github.com/authzed/spicedb/pkg/spiceerrors" + "github.com/authzed/spicedb/pkg/tuple" +) + +//go:generate go run github.com/ecordell/optgen -output zz_generated.query_options.go . QueryOptions ReverseQueryOptions RWTOptions +//go:generate go run github.com/ecordell/optgen -output zz_generated.delete_options.go . DeleteOptions + +// SortOrder is an enum which represents the order in which the caller would like +// the data returned. +type SortOrder int8 + +const ( + // Unsorted lets the underlying datastore choose the order, or no order at all + Unsorted SortOrder = iota + + // ByResource sorts the relationships by the resource component first + ByResource + + // BySubject sorts the relationships by the subject component first. Note that + // BySubject might be quite a bit slower than ByResource, as relationships are + // indexed by resource. + BySubject +) + +type Cursor *tuple.Relationship + +func ToCursor(r tuple.Relationship) Cursor { + spiceerrors.DebugAssert(r.ValidateNotEmpty, "cannot create cursor from empty relationship") + return Cursor(&r) +} + +func ToRelationship(c Cursor) *tuple.Relationship { + if c == nil { + return nil + } + return (*tuple.Relationship)(c) +} + +// SQLCheckAssertionForTest is a function that can be used to assert a condition on the SQL query string. +// Assertions will only be run during testing and only apply in datastores that support SQL. +type SQLCheckAssertionForTest func(sql string) + +// SQLIndexInformation holds the expected index names for a SQL query. +type SQLIndexInformation struct { + // ExpectedIndexNames are the name(s) of the index(es) that are expected to be used by this + // SQL query. + ExpectedIndexNames []string +} + +// SQLExplainCallbackForTest is a callback invoked with the explain plan of the SQL query string. +type SQLExplainCallbackForTest func(ctx context.Context, sql string, args []any, shape queryshape.Shape, explain string, expectedIndexes SQLIndexInformation) error + +// QueryOptions are the options that can affect the results of a normal forward query. +type QueryOptions struct { + Limit *uint64 `debugmap:"visible"` + Sort SortOrder `debugmap:"visible"` + After Cursor `debugmap:"visible"` + SkipCaveats bool `debugmap:"visible"` + SkipExpiration bool `debugmap:"visible"` + + // SQLCheckAssertionForTest is a function that can be used to assert a condition on the SQL query string. + // For testing and validation only. + SQLCheckAssertionForTest SQLCheckAssertionForTest `debugmap:"visible"` + + // SQLExplainCallbackForTest is a callback invoked with the explain plan of the SQL query string. + // For testing and validation only. + SQLExplainCallbackForTest SQLExplainCallbackForTest `debugmap:"visible"` + + // QueryShape is the marked shape of the query. + // For testing and validation only. + QueryShape queryshape.Shape `debugmap:"visible"` +} + +// ReverseQueryOptions are the options that can affect the results of a reverse query. +type ReverseQueryOptions struct { + ResRelation *ResourceRelation `debugmap:"visible"` + + LimitForReverse *uint64 `debugmap:"visible"` + SortForReverse SortOrder `debugmap:"visible"` + AfterForReverse Cursor `debugmap:"visible"` + + // SQLExplainCallbackForTestForReverse is a callback invoked with the explain plan of the SQL query string. + // For testing and validation only. + SQLExplainCallbackForTestForReverse SQLExplainCallbackForTest `debugmap:"visible"` + + // QueryShapeForReverse is the marked shape of the reverse query. + // For testing and validation only. + QueryShapeForReverse queryshape.Shape `debugmap:"visible"` +} + +// ResourceRelation combines a resource object type and relation. +type ResourceRelation struct { + Namespace string + Relation string +} + +// RWTOptions are options that can affect the way a read-write transaction is +// executed. +type RWTOptions struct { + DisableRetries bool `debugmap:"visible"` + Metadata *structpb.Struct `debugmap:"visible"` +} + +// DeleteOptions are the options that can affect the results of a delete relationships +// operation. +type DeleteOptions struct { + DeleteLimit *uint64 `debugmap:"visible"` +} + +var ( + one = uint64(1) + + // LimitOne is a constant *uint64 that can be used with WithLimit requests. + LimitOne = &one +) diff --git a/vendor/github.com/authzed/spicedb/pkg/datastore/options/zz_generated.delete_options.go b/vendor/github.com/authzed/spicedb/pkg/datastore/options/zz_generated.delete_options.go new file mode 100644 index 0000000..839c9ad --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/datastore/options/zz_generated.delete_options.go @@ -0,0 +1,65 @@ +// Code generated by github.com/ecordell/optgen. DO NOT EDIT. +package options + +import ( + defaults "github.com/creasty/defaults" + helpers "github.com/ecordell/optgen/helpers" +) + +type DeleteOptionsOption func(d *DeleteOptions) + +// NewDeleteOptionsWithOptions creates a new DeleteOptions with the passed in options set +func NewDeleteOptionsWithOptions(opts ...DeleteOptionsOption) *DeleteOptions { + d := &DeleteOptions{} + for _, o := range opts { + o(d) + } + return d +} + +// NewDeleteOptionsWithOptionsAndDefaults creates a new DeleteOptions with the passed in options set starting from the defaults +func NewDeleteOptionsWithOptionsAndDefaults(opts ...DeleteOptionsOption) *DeleteOptions { + d := &DeleteOptions{} + defaults.MustSet(d) + for _, o := range opts { + o(d) + } + return d +} + +// ToOption returns a new DeleteOptionsOption that sets the values from the passed in DeleteOptions +func (d *DeleteOptions) ToOption() DeleteOptionsOption { + return func(to *DeleteOptions) { + to.DeleteLimit = d.DeleteLimit + } +} + +// DebugMap returns a map form of DeleteOptions for debugging +func (d DeleteOptions) DebugMap() map[string]any { + debugMap := map[string]any{} + debugMap["DeleteLimit"] = helpers.DebugValue(d.DeleteLimit, false) + return debugMap +} + +// DeleteOptionsWithOptions configures an existing DeleteOptions with the passed in options set +func DeleteOptionsWithOptions(d *DeleteOptions, opts ...DeleteOptionsOption) *DeleteOptions { + for _, o := range opts { + o(d) + } + return d +} + +// WithOptions configures the receiver DeleteOptions with the passed in options set +func (d *DeleteOptions) WithOptions(opts ...DeleteOptionsOption) *DeleteOptions { + for _, o := range opts { + o(d) + } + return d +} + +// WithDeleteLimit returns an option that can set DeleteLimit on a DeleteOptions +func WithDeleteLimit(deleteLimit *uint64) DeleteOptionsOption { + return func(d *DeleteOptions) { + d.DeleteLimit = deleteLimit + } +} diff --git a/vendor/github.com/authzed/spicedb/pkg/datastore/options/zz_generated.query_options.go b/vendor/github.com/authzed/spicedb/pkg/datastore/options/zz_generated.query_options.go new file mode 100644 index 0000000..518db5c --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/datastore/options/zz_generated.query_options.go @@ -0,0 +1,300 @@ +// Code generated by github.com/ecordell/optgen. DO NOT EDIT. +package options + +import ( + queryshape "github.com/authzed/spicedb/pkg/datastore/queryshape" + defaults "github.com/creasty/defaults" + helpers "github.com/ecordell/optgen/helpers" + structpb "google.golang.org/protobuf/types/known/structpb" +) + +type QueryOptionsOption func(q *QueryOptions) + +// NewQueryOptionsWithOptions creates a new QueryOptions with the passed in options set +func NewQueryOptionsWithOptions(opts ...QueryOptionsOption) *QueryOptions { + q := &QueryOptions{} + for _, o := range opts { + o(q) + } + return q +} + +// NewQueryOptionsWithOptionsAndDefaults creates a new QueryOptions with the passed in options set starting from the defaults +func NewQueryOptionsWithOptionsAndDefaults(opts ...QueryOptionsOption) *QueryOptions { + q := &QueryOptions{} + defaults.MustSet(q) + for _, o := range opts { + o(q) + } + return q +} + +// ToOption returns a new QueryOptionsOption that sets the values from the passed in QueryOptions +func (q *QueryOptions) ToOption() QueryOptionsOption { + return func(to *QueryOptions) { + to.Limit = q.Limit + to.Sort = q.Sort + to.After = q.After + to.SkipCaveats = q.SkipCaveats + to.SkipExpiration = q.SkipExpiration + to.SQLCheckAssertionForTest = q.SQLCheckAssertionForTest + to.SQLExplainCallbackForTest = q.SQLExplainCallbackForTest + to.QueryShape = q.QueryShape + } +} + +// DebugMap returns a map form of QueryOptions for debugging +func (q QueryOptions) DebugMap() map[string]any { + debugMap := map[string]any{} + debugMap["Limit"] = helpers.DebugValue(q.Limit, false) + debugMap["Sort"] = helpers.DebugValue(q.Sort, false) + debugMap["After"] = helpers.DebugValue(q.After, false) + debugMap["SkipCaveats"] = helpers.DebugValue(q.SkipCaveats, false) + debugMap["SkipExpiration"] = helpers.DebugValue(q.SkipExpiration, false) + debugMap["SQLCheckAssertionForTest"] = helpers.DebugValue(q.SQLCheckAssertionForTest, false) + debugMap["SQLExplainCallbackForTest"] = helpers.DebugValue(q.SQLExplainCallbackForTest, false) + debugMap["QueryShape"] = helpers.DebugValue(q.QueryShape, false) + return debugMap +} + +// QueryOptionsWithOptions configures an existing QueryOptions with the passed in options set +func QueryOptionsWithOptions(q *QueryOptions, opts ...QueryOptionsOption) *QueryOptions { + for _, o := range opts { + o(q) + } + return q +} + +// WithOptions configures the receiver QueryOptions with the passed in options set +func (q *QueryOptions) WithOptions(opts ...QueryOptionsOption) *QueryOptions { + for _, o := range opts { + o(q) + } + return q +} + +// WithLimit returns an option that can set Limit on a QueryOptions +func WithLimit(limit *uint64) QueryOptionsOption { + return func(q *QueryOptions) { + q.Limit = limit + } +} + +// WithSort returns an option that can set Sort on a QueryOptions +func WithSort(sort SortOrder) QueryOptionsOption { + return func(q *QueryOptions) { + q.Sort = sort + } +} + +// WithAfter returns an option that can set After on a QueryOptions +func WithAfter(after Cursor) QueryOptionsOption { + return func(q *QueryOptions) { + q.After = after + } +} + +// WithSkipCaveats returns an option that can set SkipCaveats on a QueryOptions +func WithSkipCaveats(skipCaveats bool) QueryOptionsOption { + return func(q *QueryOptions) { + q.SkipCaveats = skipCaveats + } +} + +// WithSkipExpiration returns an option that can set SkipExpiration on a QueryOptions +func WithSkipExpiration(skipExpiration bool) QueryOptionsOption { + return func(q *QueryOptions) { + q.SkipExpiration = skipExpiration + } +} + +// WithSQLCheckAssertionForTest returns an option that can set SQLCheckAssertionForTest on a QueryOptions +func WithSQLCheckAssertionForTest(sQLCheckAssertionForTest SQLCheckAssertionForTest) QueryOptionsOption { + return func(q *QueryOptions) { + q.SQLCheckAssertionForTest = sQLCheckAssertionForTest + } +} + +// WithSQLExplainCallbackForTest returns an option that can set SQLExplainCallbackForTest on a QueryOptions +func WithSQLExplainCallbackForTest(sQLExplainCallbackForTest SQLExplainCallbackForTest) QueryOptionsOption { + return func(q *QueryOptions) { + q.SQLExplainCallbackForTest = sQLExplainCallbackForTest + } +} + +// WithQueryShape returns an option that can set QueryShape on a QueryOptions +func WithQueryShape(queryShape queryshape.Shape) QueryOptionsOption { + return func(q *QueryOptions) { + q.QueryShape = queryShape + } +} + +type ReverseQueryOptionsOption func(r *ReverseQueryOptions) + +// NewReverseQueryOptionsWithOptions creates a new ReverseQueryOptions with the passed in options set +func NewReverseQueryOptionsWithOptions(opts ...ReverseQueryOptionsOption) *ReverseQueryOptions { + r := &ReverseQueryOptions{} + for _, o := range opts { + o(r) + } + return r +} + +// NewReverseQueryOptionsWithOptionsAndDefaults creates a new ReverseQueryOptions with the passed in options set starting from the defaults +func NewReverseQueryOptionsWithOptionsAndDefaults(opts ...ReverseQueryOptionsOption) *ReverseQueryOptions { + r := &ReverseQueryOptions{} + defaults.MustSet(r) + for _, o := range opts { + o(r) + } + return r +} + +// ToOption returns a new ReverseQueryOptionsOption that sets the values from the passed in ReverseQueryOptions +func (r *ReverseQueryOptions) ToOption() ReverseQueryOptionsOption { + return func(to *ReverseQueryOptions) { + to.ResRelation = r.ResRelation + to.LimitForReverse = r.LimitForReverse + to.SortForReverse = r.SortForReverse + to.AfterForReverse = r.AfterForReverse + to.SQLExplainCallbackForTestForReverse = r.SQLExplainCallbackForTestForReverse + to.QueryShapeForReverse = r.QueryShapeForReverse + } +} + +// DebugMap returns a map form of ReverseQueryOptions for debugging +func (r ReverseQueryOptions) DebugMap() map[string]any { + debugMap := map[string]any{} + debugMap["ResRelation"] = helpers.DebugValue(r.ResRelation, false) + debugMap["LimitForReverse"] = helpers.DebugValue(r.LimitForReverse, false) + debugMap["SortForReverse"] = helpers.DebugValue(r.SortForReverse, false) + debugMap["AfterForReverse"] = helpers.DebugValue(r.AfterForReverse, false) + debugMap["SQLExplainCallbackForTestForReverse"] = helpers.DebugValue(r.SQLExplainCallbackForTestForReverse, false) + debugMap["QueryShapeForReverse"] = helpers.DebugValue(r.QueryShapeForReverse, false) + return debugMap +} + +// ReverseQueryOptionsWithOptions configures an existing ReverseQueryOptions with the passed in options set +func ReverseQueryOptionsWithOptions(r *ReverseQueryOptions, opts ...ReverseQueryOptionsOption) *ReverseQueryOptions { + for _, o := range opts { + o(r) + } + return r +} + +// WithOptions configures the receiver ReverseQueryOptions with the passed in options set +func (r *ReverseQueryOptions) WithOptions(opts ...ReverseQueryOptionsOption) *ReverseQueryOptions { + for _, o := range opts { + o(r) + } + return r +} + +// WithResRelation returns an option that can set ResRelation on a ReverseQueryOptions +func WithResRelation(resRelation *ResourceRelation) ReverseQueryOptionsOption { + return func(r *ReverseQueryOptions) { + r.ResRelation = resRelation + } +} + +// WithLimitForReverse returns an option that can set LimitForReverse on a ReverseQueryOptions +func WithLimitForReverse(limitForReverse *uint64) ReverseQueryOptionsOption { + return func(r *ReverseQueryOptions) { + r.LimitForReverse = limitForReverse + } +} + +// WithSortForReverse returns an option that can set SortForReverse on a ReverseQueryOptions +func WithSortForReverse(sortForReverse SortOrder) ReverseQueryOptionsOption { + return func(r *ReverseQueryOptions) { + r.SortForReverse = sortForReverse + } +} + +// WithAfterForReverse returns an option that can set AfterForReverse on a ReverseQueryOptions +func WithAfterForReverse(afterForReverse Cursor) ReverseQueryOptionsOption { + return func(r *ReverseQueryOptions) { + r.AfterForReverse = afterForReverse + } +} + +// WithSQLExplainCallbackForTestForReverse returns an option that can set SQLExplainCallbackForTestForReverse on a ReverseQueryOptions +func WithSQLExplainCallbackForTestForReverse(sQLExplainCallbackForTestForReverse SQLExplainCallbackForTest) ReverseQueryOptionsOption { + return func(r *ReverseQueryOptions) { + r.SQLExplainCallbackForTestForReverse = sQLExplainCallbackForTestForReverse + } +} + +// WithQueryShapeForReverse returns an option that can set QueryShapeForReverse on a ReverseQueryOptions +func WithQueryShapeForReverse(queryShapeForReverse queryshape.Shape) ReverseQueryOptionsOption { + return func(r *ReverseQueryOptions) { + r.QueryShapeForReverse = queryShapeForReverse + } +} + +type RWTOptionsOption func(r *RWTOptions) + +// NewRWTOptionsWithOptions creates a new RWTOptions with the passed in options set +func NewRWTOptionsWithOptions(opts ...RWTOptionsOption) *RWTOptions { + r := &RWTOptions{} + for _, o := range opts { + o(r) + } + return r +} + +// NewRWTOptionsWithOptionsAndDefaults creates a new RWTOptions with the passed in options set starting from the defaults +func NewRWTOptionsWithOptionsAndDefaults(opts ...RWTOptionsOption) *RWTOptions { + r := &RWTOptions{} + defaults.MustSet(r) + for _, o := range opts { + o(r) + } + return r +} + +// ToOption returns a new RWTOptionsOption that sets the values from the passed in RWTOptions +func (r *RWTOptions) ToOption() RWTOptionsOption { + return func(to *RWTOptions) { + to.DisableRetries = r.DisableRetries + to.Metadata = r.Metadata + } +} + +// DebugMap returns a map form of RWTOptions for debugging +func (r RWTOptions) DebugMap() map[string]any { + debugMap := map[string]any{} + debugMap["DisableRetries"] = helpers.DebugValue(r.DisableRetries, false) + debugMap["Metadata"] = helpers.DebugValue(r.Metadata, false) + return debugMap +} + +// RWTOptionsWithOptions configures an existing RWTOptions with the passed in options set +func RWTOptionsWithOptions(r *RWTOptions, opts ...RWTOptionsOption) *RWTOptions { + for _, o := range opts { + o(r) + } + return r +} + +// WithOptions configures the receiver RWTOptions with the passed in options set +func (r *RWTOptions) WithOptions(opts ...RWTOptionsOption) *RWTOptions { + for _, o := range opts { + o(r) + } + return r +} + +// WithDisableRetries returns an option that can set DisableRetries on a RWTOptions +func WithDisableRetries(disableRetries bool) RWTOptionsOption { + return func(r *RWTOptions) { + r.DisableRetries = disableRetries + } +} + +// WithMetadata returns an option that can set Metadata on a RWTOptions +func WithMetadata(metadata *structpb.Struct) RWTOptionsOption { + return func(r *RWTOptions) { + r.Metadata = metadata + } +} diff --git a/vendor/github.com/authzed/spicedb/pkg/datastore/pagination/iterator.go b/vendor/github.com/authzed/spicedb/pkg/datastore/pagination/iterator.go new file mode 100644 index 0000000..524e52e --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/datastore/pagination/iterator.go @@ -0,0 +1,70 @@ +package pagination + +import ( + "context" + + "github.com/authzed/spicedb/pkg/datastore" + "github.com/authzed/spicedb/pkg/datastore/options" + "github.com/authzed/spicedb/pkg/datastore/queryshape" + "github.com/authzed/spicedb/pkg/tuple" +) + +// NewPaginatedIterator creates an implementation of the datastore.Iterator +// interface that internally paginates over datastore results. +func NewPaginatedIterator( + ctx context.Context, + reader datastore.Reader, + filter datastore.RelationshipsFilter, + pageSize uint64, + order options.SortOrder, + startCursor options.Cursor, + queryShape queryshape.Shape, +) (datastore.RelationshipIterator, error) { + iter, err := reader.QueryRelationships( + ctx, + filter, + options.WithSort(order), + options.WithLimit(&pageSize), + options.WithAfter(startCursor), + options.WithQueryShape(queryShape), + ) + if err != nil { + return nil, err + } + + return func(yield func(tuple.Relationship, error) bool) { + cursor := startCursor + for { + var counter uint64 + for rel, err := range iter { + if !yield(rel, err) { + return + } + + cursor = options.ToCursor(rel) + counter++ + + if counter >= pageSize { + break + } + } + + if counter < pageSize { + return + } + + iter, err = reader.QueryRelationships( + ctx, + filter, + options.WithSort(order), + options.WithLimit(&pageSize), + options.WithAfter(cursor), + options.WithQueryShape(queryShape), + ) + if err != nil { + yield(tuple.Relationship{}, err) + return + } + } + }, nil +} diff --git a/vendor/github.com/authzed/spicedb/pkg/datastore/queryshape/queryshape.go b/vendor/github.com/authzed/spicedb/pkg/datastore/queryshape/queryshape.go new file mode 100644 index 0000000..4ff1e0f --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/datastore/queryshape/queryshape.go @@ -0,0 +1,109 @@ +package queryshape + +// Shape represents the different ways a query can be shaped. +type Shape string + +// Symbol guide: +// *️⃣ - optional +// ✅ - required +// 🆔 - has some sort of filter +// 🅿️ - possibly specified + +const ( + // Unspecified indicates that the shape is not specified. + Unspecified Shape = "unspecified" + + // Varying indicates that the shape can vary. This is used + // for queries whose shape is not known ahead of time. + // + // *️⃣ resource_type, *️⃣ resource_id, *️⃣ resource_relation, *️⃣ subject_type, *️⃣ subject_id, *️⃣ subject_relation, *️⃣ caveat, *️⃣ expiration + Varying = "varying" + + // CheckPermissionSelectDirectSubjects indicates that the query is a permission check + // that selects direct subjects. + // + // The query shape selects a specific relationship based on filling in *all* of it + // relationship fields (except the caveat name, context and expiration). + // + // ✅ resource_type, ✅ resource_id, ✅ resource_relation, ✅ subject_type, ✅ subject_id, ✅ subject_relation, *️⃣ caveat, *️⃣ expiration + CheckPermissionSelectDirectSubjects = "check-permission-select-direct-subjects" + + // CheckPermissionSelectIndirectSubjects indicates that the query is a permission check + // that selects indirect subjects. + // + // The query shape selects a specific relationship based on filling in all fields + // on the resource (except the caveat name, context and expiration) and the relation + // name. The subject type nor ID is filled in and the optional subject relation is + // set to match non-`...`. + // + // ✅ resource_type, ✅ resource_id, ✅ resource_relation, *️⃣ subject_type, *️⃣ subject_id, 🆔 subject_relation, *️⃣ caveat, *️⃣ expiration + CheckPermissionSelectIndirectSubjects = "check-permission-select-indirect-subjects" + + // AllSubjectsForResources indicates that the query is selecting all subjects for a + // given set of resources. + // + // The query shape selects all subjects for a given set of resources, which are fully + // specified by providing the resource type, the resource ID(s) and the relation. + // + // ✅ resource_type, ✅ resource_id, ✅ resource_relation, *️⃣ subject_type, *️⃣ subject_id, *️⃣ subject_relation, *️⃣ caveat, *️⃣ expiration + AllSubjectsForResources = "all-subjects-for-resources" + + // MatchingResourcesForSubject indicates that the query is selecting all resources that + // match a given subject. + // + // The query shape selects all resources that match a given subject, which is specified + // by providing the subject type, the subject ID and (optionally) the subject relation. + // The resource type and relation are filled in, but the resource ID is never specified. + // + // ✅ resource_type, *️⃣ resource_id, ✅ resource_relation, ✅ subject_type, ✅ subject_id, 🅿️ subject_relation, *️⃣ caveat, *️⃣ expiration + MatchingResourcesForSubject = "matching-resources-for-subject" + + // FindResourceOfType indicates that the query is selecting a resource of + // a given type. + // + // The query shape selects a resource of a given type, which is specified by + // providing the resource type. The other fields are never specified. + // + // ✅ resource_type, *️⃣ resource_id, *️⃣ resource_relation, *️⃣ subject_type, *️⃣ subject_id, *️⃣ subject_relation, *️⃣ caveat, *️⃣ expiration + FindResourceOfType = "find-resource-of-type" + + // FindSubjectOfType indicates that the query is selecting a subject of + // a given type. + // + // The query shape selects a subject of a given type, which is specified by + // providing the subject type. The other fields are never specified. + // + // *️⃣ resource_type, *️⃣ resource_id, *️⃣ resource_relation, ✅ subject_type, *️⃣ subject_id, *️⃣ subject_relation, *️⃣ caveat, *️⃣ expiration + FindSubjectOfType = "find-subject-of-type" + + // FindResourceOfTypeAndRelation indicates that the query is selecting a single + // resource of a given type and relation. + // + // The query shape selects a resource of a given type and relation, which are + // specified by providing the resource type and relation. The other fields are never + // specified. + // + // ✅ resource_type, *️⃣ resource_id, ✅ resource_relation, *️⃣ subject_type, *️⃣ subject_id, *️⃣ subject_relation, *️⃣ caveat, *️⃣ expiration + FindResourceOfTypeAndRelation = "find-resource-of-type-and-relation" + + // FindSubjectOfTypeAndRelation indicates that the query is selecting a single + // subject of a given type and relation. + // + // The query shape selects a subject of a given type and relation, which are + // specified by providing the subject type and relation. The other fields are never + // specified. + // + // *️⃣ resource_type, *️⃣ resource_id, *️⃣ resource_relation, ✅ subject_type, *️⃣ subject_id, ✅ subject_relation, *️⃣ caveat, *️⃣ expiration + FindSubjectOfTypeAndRelation = "find-subject-of-type-and-relation" + + // FindResourceRelationForSubjectRelation indicates that the query is selecting a single + // relationship type that matches a given relation type, i.e. `user` or + // `group#member with somecaveat and expiration`. + // + // The query shape selects an allowed subject type for a specific relation on a specific + // resource type. All fields except resource ID are specified here, with subject ID only + // specified if a wildcard. + // + // ✅ resource_type, *️⃣ resource_id, ✅ resource_relation, ✅ subject_type, 🅿️ subject_id, ✅ subject_relation, *️⃣ caveat, *️⃣ expiration + FindResourceRelationForSubjectRelation = "find-resource-relation-for-subject-relation" +) diff --git a/vendor/github.com/authzed/spicedb/pkg/datastore/relationshipquerytree.go b/vendor/github.com/authzed/spicedb/pkg/datastore/relationshipquerytree.go new file mode 100644 index 0000000..2163f07 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/datastore/relationshipquerytree.go @@ -0,0 +1,23 @@ +package datastore + +type RelationshipQueryOperation int + +const ( + RelationshipQueryNone RelationshipQueryOperation = 0 + RelationshipQueryOr RelationshipQueryOperation = 1 + RelationshipQueryAnd RelationshipQueryOperation = 2 +) + +type RelationshipsQueryTree struct { + op RelationshipQueryOperation + filter RelationshipsFilter + children []RelationshipsQueryTree +} + +func NewRelationshipQueryTree(filter RelationshipsFilter) RelationshipsQueryTree { + return RelationshipsQueryTree{ + op: RelationshipQueryNone, + filter: filter, + children: nil, + } +} diff --git a/vendor/github.com/authzed/spicedb/pkg/datastore/stats.go b/vendor/github.com/authzed/spicedb/pkg/datastore/stats.go new file mode 100644 index 0000000..f98c405 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/datastore/stats.go @@ -0,0 +1,31 @@ +package datastore + +import ( + "github.com/authzed/spicedb/pkg/namespace" + iv1 "github.com/authzed/spicedb/pkg/proto/impl/v1" +) + +// ComputeObjectTypeStats creates a list of object type stats from an input list of +// parsed object types. +func ComputeObjectTypeStats(objTypes []RevisionedNamespace) []ObjectTypeStat { + stats := make([]ObjectTypeStat, 0, len(objTypes)) + + for _, objType := range objTypes { + var relations, permissions uint32 + + for _, rel := range objType.Definition.Relation { + if namespace.GetRelationKind(rel) == iv1.RelationMetadata_PERMISSION { + permissions++ + } else { + relations++ + } + } + + stats = append(stats, ObjectTypeStat{ + NumRelations: relations, + NumPermissions: permissions, + }) + } + + return stats +} diff --git a/vendor/github.com/authzed/spicedb/pkg/datastore/util.go b/vendor/github.com/authzed/spicedb/pkg/datastore/util.go new file mode 100644 index 0000000..55bb8f2 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/datastore/util.go @@ -0,0 +1,63 @@ +package datastore + +import ( + "context" + + v1 "github.com/authzed/authzed-go/proto/authzed/api/v1" +) + +// DefinitionsOf returns just the schema definitions found in the list of revisioned +// definitions. +func DefinitionsOf[T SchemaDefinition](revisionedDefinitions []RevisionedDefinition[T]) []T { + definitions := make([]T, 0, len(revisionedDefinitions)) + for _, revDef := range revisionedDefinitions { + definitions = append(definitions, revDef.Definition) + } + return definitions +} + +// DeleteAllData deletes all data from the datastore. Should only be used when explicitly requested. +// The data is transactionally deleted, which means it may time out. +func DeleteAllData(ctx context.Context, ds Datastore) error { + _, err := ds.ReadWriteTx(ctx, func(ctx context.Context, rwt ReadWriteTransaction) error { + nsDefs, err := rwt.ListAllNamespaces(ctx) + if err != nil { + return err + } + + // Delete all relationships. + namespaceNames := make([]string, 0, len(nsDefs)) + for _, nsDef := range nsDefs { + _, _, err = rwt.DeleteRelationships(ctx, &v1.RelationshipFilter{ + ResourceType: nsDef.Definition.Name, + }) + if err != nil { + return err + } + namespaceNames = append(namespaceNames, nsDef.Definition.Name) + } + + // Delete all caveats. + caveatDefs, err := rwt.ListAllCaveats(ctx) + if err != nil { + return err + } + + caveatNames := make([]string, 0, len(caveatDefs)) + for _, caveatDef := range caveatDefs { + caveatNames = append(caveatNames, caveatDef.Definition.Name) + } + + if err := rwt.DeleteCaveats(ctx, caveatNames); err != nil { + return err + } + + // Delete all namespaces. + if err := rwt.DeleteNamespaces(ctx, namespaceNames...); err != nil { + return err + } + + return nil + }) + return err +} diff --git a/vendor/github.com/authzed/spicedb/pkg/development/assertions.go b/vendor/github.com/authzed/spicedb/pkg/development/assertions.go new file mode 100644 index 0000000..7b08e6b --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/development/assertions.go @@ -0,0 +1,97 @@ +package development + +import ( + "fmt" + + "github.com/ccoveille/go-safecast" + + log "github.com/authzed/spicedb/internal/logging" + devinterface "github.com/authzed/spicedb/pkg/proto/developer/v1" + v1 "github.com/authzed/spicedb/pkg/proto/dispatch/v1" + "github.com/authzed/spicedb/pkg/validationfile/blocks" +) + +const maxDispatchDepth = 25 + +// RunAllAssertions runs all assertions found in the given assertions block against the +// developer context, returning whether any errors occurred. +func RunAllAssertions(devContext *DevContext, assertions *blocks.Assertions) ([]*devinterface.DeveloperError, error) { + trueFailures, err := runAssertions(devContext, assertions.AssertTrue, v1.ResourceCheckResult_MEMBER, "Expected relation or permission %s to exist") + if err != nil { + return nil, err + } + + caveatedFailures, err := runAssertions(devContext, assertions.AssertCaveated, v1.ResourceCheckResult_CAVEATED_MEMBER, "Expected relation or permission %s to be caveated") + if err != nil { + return nil, err + } + + falseFailures, err := runAssertions(devContext, assertions.AssertFalse, v1.ResourceCheckResult_NOT_MEMBER, "Expected relation or permission %s to not exist") + if err != nil { + return nil, err + } + + failures := append(trueFailures, caveatedFailures...) + failures = append(failures, falseFailures...) + return failures, nil +} + +func runAssertions(devContext *DevContext, assertions []blocks.Assertion, expected v1.ResourceCheckResult_Membership, fmtString string) ([]*devinterface.DeveloperError, error) { + var failures []*devinterface.DeveloperError + + for _, assertion := range assertions { + // NOTE: zeroes are fine here to mean "unknown" + lineNumber, err := safecast.ToUint32(assertion.SourcePosition.LineNumber) + if err != nil { + log.Err(err).Msg("could not cast lineNumber to uint32") + } + columnPosition, err := safecast.ToUint32(assertion.SourcePosition.ColumnPosition) + if err != nil { + log.Err(err).Msg("could not cast columnPosition to uint32") + } + + rel := assertion.Relationship + if rel.OptionalCaveat != nil { + failures = append(failures, &devinterface.DeveloperError{ + Message: fmt.Sprintf("cannot specify a caveat on an assertion: `%s`", assertion.RelationshipWithContextString), + Source: devinterface.DeveloperError_ASSERTION, + Kind: devinterface.DeveloperError_UNKNOWN_RELATION, + Context: assertion.RelationshipWithContextString, + Line: lineNumber, + Column: columnPosition, + }) + continue + } + + cr, err := RunCheck(devContext, rel.Resource, rel.Subject, assertion.CaveatContext) + if err != nil { + devErr, wireErr := DistinguishGraphError( + devContext, + err, + devinterface.DeveloperError_ASSERTION, + lineNumber, + columnPosition, + assertion.RelationshipWithContextString, + ) + if wireErr != nil { + return nil, wireErr + } + if devErr != nil { + failures = append(failures, devErr) + } + } else if cr.Permissionship != expected { + failures = append(failures, &devinterface.DeveloperError{ + Message: fmt.Sprintf(fmtString, assertion.RelationshipWithContextString), + Source: devinterface.DeveloperError_ASSERTION, + Kind: devinterface.DeveloperError_ASSERTION_FAILED, + Context: assertion.RelationshipWithContextString, + Line: lineNumber, + Column: columnPosition, + CheckDebugInformation: cr.DispatchDebugInfo, + CheckResolvedDebugInformation: cr.V1DebugInfo, + }) + } + } + + return failures, nil +} diff --git a/vendor/github.com/authzed/spicedb/pkg/development/check.go b/vendor/github.com/authzed/spicedb/pkg/development/check.go new file mode 100644 index 0000000..292a1ea --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/development/check.go @@ -0,0 +1,53 @@ +package development + +import ( + v1api "github.com/authzed/authzed-go/proto/authzed/api/v1" + + "github.com/authzed/spicedb/internal/graph/computed" + v1 "github.com/authzed/spicedb/internal/services/v1" + caveattypes "github.com/authzed/spicedb/pkg/caveats/types" + v1dispatch "github.com/authzed/spicedb/pkg/proto/dispatch/v1" + "github.com/authzed/spicedb/pkg/tuple" +) + +const defaultWasmDispatchChunkSize = 100 + +// CheckResult is the result of a RunCheck operation. +type CheckResult struct { + Permissionship v1dispatch.ResourceCheckResult_Membership + MissingCaveatFields []string + DispatchDebugInfo *v1dispatch.DebugInformation + V1DebugInfo *v1api.DebugInformation +} + +// RunCheck performs a check against the data in the development context. +// +// Note that it is up to the caller to call DistinguishGraphError on the error +// if they want to distinguish between user errors and internal errors. +func RunCheck(devContext *DevContext, resource tuple.ObjectAndRelation, subject tuple.ObjectAndRelation, caveatContext map[string]any) (CheckResult, error) { + ctx := devContext.Ctx + cr, meta, err := computed.ComputeCheck(ctx, devContext.Dispatcher, + caveattypes.Default.TypeSet, + computed.CheckParameters{ + ResourceType: resource.RelationReference(), + Subject: subject, + CaveatContext: caveatContext, + AtRevision: devContext.Revision, + MaximumDepth: maxDispatchDepth, + DebugOption: computed.TraceDebuggingEnabled, + }, + resource.ObjectID, + defaultWasmDispatchChunkSize, + ) + if err != nil { + return CheckResult{v1dispatch.ResourceCheckResult_NOT_MEMBER, nil, nil, nil}, err + } + + reader := devContext.Datastore.SnapshotReader(devContext.Revision) + converted, err := v1.ConvertCheckDispatchDebugInformation(ctx, caveattypes.Default.TypeSet, caveatContext, meta.DebugInfo, reader) + if err != nil { + return CheckResult{v1dispatch.ResourceCheckResult_NOT_MEMBER, nil, nil, nil}, err + } + + return CheckResult{cr.Membership, cr.MissingExprFields, meta.DebugInfo, converted}, nil +} diff --git a/vendor/github.com/authzed/spicedb/pkg/development/devcontext.go b/vendor/github.com/authzed/spicedb/pkg/development/devcontext.go new file mode 100644 index 0000000..f0f2e38 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/development/devcontext.go @@ -0,0 +1,470 @@ +package development + +import ( + "context" + "errors" + "net" + "time" + + v1 "github.com/authzed/authzed-go/proto/authzed/api/v1" + "github.com/ccoveille/go-safecast" + humanize "github.com/dustin/go-humanize" + "google.golang.org/genproto/googleapis/rpc/errdetails" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/credentials/insecure" + "google.golang.org/grpc/status" + "google.golang.org/grpc/test/bufconn" + + "github.com/authzed/spicedb/internal/datastore/memdb" + "github.com/authzed/spicedb/internal/dispatch" + "github.com/authzed/spicedb/internal/dispatch/graph" + maingraph "github.com/authzed/spicedb/internal/graph" + "github.com/authzed/spicedb/internal/grpchelpers" + log "github.com/authzed/spicedb/internal/logging" + datastoremw "github.com/authzed/spicedb/internal/middleware/datastore" + "github.com/authzed/spicedb/internal/namespace" + "github.com/authzed/spicedb/internal/relationships" + v1svc "github.com/authzed/spicedb/internal/services/v1" + "github.com/authzed/spicedb/internal/sharederrors" + caveattypes "github.com/authzed/spicedb/pkg/caveats/types" + "github.com/authzed/spicedb/pkg/datastore" + "github.com/authzed/spicedb/pkg/middleware/consistency" + core "github.com/authzed/spicedb/pkg/proto/core/v1" + devinterface "github.com/authzed/spicedb/pkg/proto/developer/v1" + "github.com/authzed/spicedb/pkg/schema" + "github.com/authzed/spicedb/pkg/schemadsl/compiler" + "github.com/authzed/spicedb/pkg/spiceerrors" + "github.com/authzed/spicedb/pkg/tuple" +) + +const defaultConnBufferSize = humanize.MiByte + +// DevContext holds the various helper types for running the developer calls. +type DevContext struct { + Ctx context.Context + Datastore datastore.Datastore + Revision datastore.Revision + CompiledSchema *compiler.CompiledSchema + Dispatcher dispatch.Dispatcher +} + +// NewDevContext creates a new DevContext from the specified request context, parsing and populating +// the datastore as needed. +func NewDevContext(ctx context.Context, requestContext *devinterface.RequestContext) (*DevContext, *devinterface.DeveloperErrors, error) { + ds, err := memdb.NewMemdbDatastore(0, 0*time.Second, memdb.DisableGC) + if err != nil { + return nil, nil, err + } + ctx = datastoremw.ContextWithDatastore(ctx, ds) + + dctx, devErrs, nerr := newDevContextWithDatastore(ctx, requestContext, ds) + if nerr != nil || devErrs != nil { + // If any form of error occurred, immediately close the datastore + derr := ds.Close() + if derr != nil { + return nil, nil, derr + } + + return dctx, devErrs, nerr + } + + return dctx, nil, nil +} + +func newDevContextWithDatastore(ctx context.Context, requestContext *devinterface.RequestContext, ds datastore.Datastore) (*DevContext, *devinterface.DeveloperErrors, error) { + // Compile the schema and load its caveats and namespaces into the datastore. + compiled, devError, err := CompileSchema(requestContext.Schema) + if err != nil { + return nil, nil, err + } + + if devError != nil { + return nil, &devinterface.DeveloperErrors{InputErrors: []*devinterface.DeveloperError{devError}}, nil + } + + var inputErrors []*devinterface.DeveloperError + currentRevision, err := ds.ReadWriteTx(ctx, func(ctx context.Context, rwt datastore.ReadWriteTransaction) error { + inputErrors, err = loadCompiled(ctx, compiled, rwt) + if err != nil || len(inputErrors) > 0 { + return err + } + + // Load the test relationships into the datastore. + relationships := make([]tuple.Relationship, 0, len(requestContext.Relationships)) + for _, rel := range requestContext.Relationships { + if err := rel.Validate(); err != nil { + inputErrors = append(inputErrors, &devinterface.DeveloperError{ + Message: err.Error(), + Source: devinterface.DeveloperError_RELATIONSHIP, + Kind: devinterface.DeveloperError_PARSE_ERROR, + Context: tuple.CoreRelationToStringWithoutCaveatOrExpiration(rel), + }) + } + + convertedRel := tuple.FromCoreRelationTuple(rel) + if err := convertedRel.Validate(); err != nil { + tplString, serr := tuple.String(convertedRel) + if serr != nil { + return serr + } + + inputErrors = append(inputErrors, &devinterface.DeveloperError{ + Message: err.Error(), + Source: devinterface.DeveloperError_RELATIONSHIP, + Kind: devinterface.DeveloperError_PARSE_ERROR, + Context: tplString, + }) + } + + relationships = append(relationships, convertedRel) + } + + ie, lerr := loadsRels(ctx, relationships, rwt) + if len(ie) > 0 { + inputErrors = append(inputErrors, ie...) + } + + return lerr + }) + + if err != nil || len(inputErrors) > 0 { + return nil, &devinterface.DeveloperErrors{InputErrors: inputErrors}, err + } + + // Sanity check: Make sure the request context for the developer is fully valid. We do this after + // the loading to ensure that any user-created errors are reported as developer errors, + // rather than internal errors. + verr := requestContext.Validate() + if verr != nil { + return nil, nil, verr + } + + return &DevContext{ + Ctx: ctx, + Datastore: ds, + CompiledSchema: compiled, + Revision: currentRevision, + Dispatcher: graph.NewLocalOnlyDispatcher(caveattypes.Default.TypeSet, 10, 100), + }, nil, nil +} + +// RunV1InMemoryService runs a V1 server in-memory on a buffconn over the given +// development context and returns a client connection and a function to shutdown +// the server. It is the responsibility of the caller to call the function to close +// the server. +func (dc *DevContext) RunV1InMemoryService() (*grpc.ClientConn, func(), error) { + listener := bufconn.Listen(defaultConnBufferSize) + + s := grpc.NewServer( + grpc.ChainUnaryInterceptor( + datastoremw.UnaryServerInterceptor(dc.Datastore), + consistency.UnaryServerInterceptor("development"), + ), + grpc.ChainStreamInterceptor( + datastoremw.StreamServerInterceptor(dc.Datastore), + consistency.StreamServerInterceptor("development"), + ), + ) + ps := v1svc.NewPermissionsServer(dc.Dispatcher, v1svc.PermissionsServerConfig{ + MaxUpdatesPerWrite: 50, + MaxPreconditionsCount: 50, + MaximumAPIDepth: 50, + MaxCaveatContextSize: 0, + ExpiringRelationshipsEnabled: true, + CaveatTypeSet: caveattypes.Default.TypeSet, + }) + ss := v1svc.NewSchemaServer(caveattypes.Default.TypeSet, false, true) + + v1.RegisterPermissionsServiceServer(s, ps) + v1.RegisterSchemaServiceServer(s, ss) + + go func() { + if err := s.Serve(listener); err != nil { + log.Err(err).Msg("error when serving in-memory server") + } + }() + + conn, err := grpchelpers.DialAndWait( + context.Background(), + "", + grpc.WithContextDialer(func(context.Context, string) (net.Conn, error) { + return listener.Dial() + }), + grpc.WithTransportCredentials(insecure.NewCredentials()), + ) + return conn, func() { + conn.Close() + listener.Close() + s.Stop() + }, err +} + +// Dispose disposes of the DevContext and its underlying datastore. +func (dc *DevContext) Dispose() { + if dc.Dispatcher == nil { + return + } + if err := dc.Dispatcher.Close(); err != nil { + log.Ctx(dc.Ctx).Err(err).Msg("error when disposing of dispatcher in devcontext") + } + + if dc.Datastore == nil { + return + } + + if err := dc.Datastore.Close(); err != nil { + log.Ctx(dc.Ctx).Err(err).Msg("error when disposing of datastore in devcontext") + } +} + +func loadsRels(ctx context.Context, rels []tuple.Relationship, rwt datastore.ReadWriteTransaction) ([]*devinterface.DeveloperError, error) { + devErrors := make([]*devinterface.DeveloperError, 0, len(rels)) + updates := make([]tuple.RelationshipUpdate, 0, len(rels)) + for _, rel := range rels { + if err := relationships.ValidateRelationshipsForCreateOrTouch(ctx, rwt, caveattypes.Default.TypeSet, rel); err != nil { + relString, serr := tuple.String(rel) + if serr != nil { + return nil, serr + } + + devErr, wireErr := distinguishGraphError(ctx, err, devinterface.DeveloperError_RELATIONSHIP, 0, 0, relString) + if wireErr != nil { + return devErrors, wireErr + } + + if devErr != nil { + devErrors = append(devErrors, devErr) + } + } + + updates = append(updates, tuple.Touch(rel)) + } + + err := rwt.WriteRelationships(ctx, updates) + return devErrors, err +} + +func loadCompiled( + ctx context.Context, + compiled *compiler.CompiledSchema, + rwt datastore.ReadWriteTransaction, +) ([]*devinterface.DeveloperError, error) { + errors := make([]*devinterface.DeveloperError, 0, len(compiled.OrderedDefinitions)) + ts := schema.NewTypeSystem(schema.ResolverForCompiledSchema(*compiled)) + + for _, caveatDef := range compiled.CaveatDefinitions { + cverr := namespace.ValidateCaveatDefinition(caveattypes.Default.TypeSet, caveatDef) + if cverr == nil { + if err := rwt.WriteCaveats(ctx, []*core.CaveatDefinition{caveatDef}); err != nil { + return errors, err + } + continue + } + + errWithSource, ok := spiceerrors.AsWithSourceError(cverr) + if ok { + // NOTE: zeroes are fine here to mean "unknown" + lineNumber, err := safecast.ToUint32(errWithSource.LineNumber) + if err != nil { + log.Err(err).Msg("could not cast lineNumber to uint32") + } + columnPosition, err := safecast.ToUint32(errWithSource.ColumnPosition) + if err != nil { + log.Err(err).Msg("could not cast columnPosition to uint32") + } + errors = append(errors, &devinterface.DeveloperError{ + Message: cverr.Error(), + Kind: devinterface.DeveloperError_SCHEMA_ISSUE, + Source: devinterface.DeveloperError_SCHEMA, + Context: errWithSource.SourceCodeString, + Line: lineNumber, + Column: columnPosition, + }) + } else { + errors = append(errors, &devinterface.DeveloperError{ + Message: cverr.Error(), + Kind: devinterface.DeveloperError_SCHEMA_ISSUE, + Source: devinterface.DeveloperError_SCHEMA, + Context: caveatDef.Name, + }) + } + } + + for _, nsDef := range compiled.ObjectDefinitions { + def, terr := schema.NewDefinition(ts, nsDef) + if terr != nil { + errWithSource, ok := spiceerrors.AsWithSourceError(terr) + // NOTE: zeroes are fine here to mean "unknown" + lineNumber, err := safecast.ToUint32(errWithSource.LineNumber) + if err != nil { + log.Err(err).Msg("could not cast lineNumber to uint32") + } + columnPosition, err := safecast.ToUint32(errWithSource.ColumnPosition) + if err != nil { + log.Err(err).Msg("could not cast columnPosition to uint32") + } + if ok { + errors = append(errors, &devinterface.DeveloperError{ + Message: terr.Error(), + Kind: devinterface.DeveloperError_SCHEMA_ISSUE, + Source: devinterface.DeveloperError_SCHEMA, + Context: errWithSource.SourceCodeString, + Line: lineNumber, + Column: columnPosition, + }) + continue + } + + errors = append(errors, &devinterface.DeveloperError{ + Message: terr.Error(), + Kind: devinterface.DeveloperError_SCHEMA_ISSUE, + Source: devinterface.DeveloperError_SCHEMA, + Context: nsDef.Name, + }) + continue + } + + _, tverr := def.Validate(ctx) + if tverr == nil { + if err := rwt.WriteNamespaces(ctx, nsDef); err != nil { + return errors, err + } + continue + } + + errWithSource, ok := spiceerrors.AsWithSourceError(tverr) + if ok { + // NOTE: zeroes are fine here to mean "unknown" + lineNumber, err := safecast.ToUint32(errWithSource.LineNumber) + if err != nil { + log.Err(err).Msg("could not cast lineNumber to uint32") + } + columnPosition, err := safecast.ToUint32(errWithSource.ColumnPosition) + if err != nil { + log.Err(err).Msg("could not cast columnPosition to uint32") + } + errors = append(errors, &devinterface.DeveloperError{ + Message: tverr.Error(), + Kind: devinterface.DeveloperError_SCHEMA_ISSUE, + Source: devinterface.DeveloperError_SCHEMA, + Context: errWithSource.SourceCodeString, + Line: lineNumber, + Column: columnPosition, + }) + } else { + errors = append(errors, &devinterface.DeveloperError{ + Message: tverr.Error(), + Kind: devinterface.DeveloperError_SCHEMA_ISSUE, + Source: devinterface.DeveloperError_SCHEMA, + Context: nsDef.Name, + }) + } + } + + return errors, nil +} + +// DistinguishGraphError turns an error from a dispatch call into either a user-facing +// DeveloperError or an internal error, based on the error raised by the dispatcher. +func DistinguishGraphError(devContext *DevContext, dispatchError error, source devinterface.DeveloperError_Source, line uint32, column uint32, context string) (*devinterface.DeveloperError, error) { + return distinguishGraphError(devContext.Ctx, dispatchError, source, line, column, context) +} + +func distinguishGraphError(ctx context.Context, dispatchError error, source devinterface.DeveloperError_Source, line uint32, column uint32, context string) (*devinterface.DeveloperError, error) { + var nsNotFoundError sharederrors.UnknownNamespaceError + var relNotFoundError sharederrors.UnknownRelationError + var invalidRelError relationships.InvalidSubjectTypeError + var maxDepthErr dispatch.MaxDepthExceededError + + if errors.As(dispatchError, &maxDepthErr) { + return &devinterface.DeveloperError{ + Message: dispatchError.Error(), + Source: source, + Kind: devinterface.DeveloperError_MAXIMUM_RECURSION, + Line: line, + Column: column, + Context: context, + }, nil + } + + details, ok := spiceerrors.GetDetails[*errdetails.ErrorInfo](dispatchError) + if ok && details.Reason == "ERROR_REASON_MAXIMUM_DEPTH_EXCEEDED" { + status, _ := status.FromError(dispatchError) + return &devinterface.DeveloperError{ + Message: status.Message(), + Source: source, + Kind: devinterface.DeveloperError_MAXIMUM_RECURSION, + Line: line, + Column: column, + Context: context, + }, nil + } + + if errors.As(dispatchError, &invalidRelError) { + return &devinterface.DeveloperError{ + Message: dispatchError.Error(), + Source: source, + Kind: devinterface.DeveloperError_INVALID_SUBJECT_TYPE, + Line: line, + Column: column, + Context: context, + }, nil + } + + if errors.As(dispatchError, &nsNotFoundError) { + return &devinterface.DeveloperError{ + Message: dispatchError.Error(), + Source: source, + Kind: devinterface.DeveloperError_UNKNOWN_OBJECT_TYPE, + Line: line, + Column: column, + Context: context, + }, nil + } + + if errors.As(dispatchError, &relNotFoundError) { + return &devinterface.DeveloperError{ + Message: dispatchError.Error(), + Source: source, + Kind: devinterface.DeveloperError_UNKNOWN_RELATION, + Line: line, + Column: column, + Context: context, + }, nil + } + + return nil, rewriteACLError(ctx, dispatchError) +} + +func rewriteACLError(ctx context.Context, err error) error { + var nsNotFoundError sharederrors.UnknownNamespaceError + var relNotFoundError sharederrors.UnknownRelationError + + switch { + case errors.As(err, &nsNotFoundError): + fallthrough + case errors.As(err, &relNotFoundError): + fallthrough + + case errors.As(err, &datastore.InvalidRevisionError{}): + return status.Errorf(codes.OutOfRange, "invalid zookie: %s", err) + + case errors.As(err, &maingraph.RelationMissingTypeInfoError{}): + return status.Errorf(codes.FailedPrecondition, "failed precondition: %s", err) + + case errors.As(err, &maingraph.AlwaysFailError{}): + log.Ctx(ctx).Err(err).Msg("internal graph error in devcontext") + return status.Errorf(codes.Internal, "internal error: %s", err) + + case errors.Is(err, context.DeadlineExceeded): + return status.Errorf(codes.DeadlineExceeded, "%s", err) + + case errors.Is(err, context.Canceled): + return status.Errorf(codes.Canceled, "%s", err) + + default: + log.Ctx(ctx).Err(err).Msg("unexpected graph error in devcontext") + return err + } +} diff --git a/vendor/github.com/authzed/spicedb/pkg/development/doc.go b/vendor/github.com/authzed/spicedb/pkg/development/doc.go new file mode 100644 index 0000000..a4c106a --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/development/doc.go @@ -0,0 +1,2 @@ +// Package development contains code that runs in the Playground. +package development diff --git a/vendor/github.com/authzed/spicedb/pkg/development/parsing.go b/vendor/github.com/authzed/spicedb/pkg/development/parsing.go new file mode 100644 index 0000000..75e27c8 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/development/parsing.go @@ -0,0 +1,69 @@ +package development + +import ( + "github.com/ccoveille/go-safecast" + + log "github.com/authzed/spicedb/internal/logging" + devinterface "github.com/authzed/spicedb/pkg/proto/developer/v1" + "github.com/authzed/spicedb/pkg/spiceerrors" + "github.com/authzed/spicedb/pkg/validationfile" + "github.com/authzed/spicedb/pkg/validationfile/blocks" +) + +// ParseAssertionsYAML parses the YAML form of an assertions block. +func ParseAssertionsYAML(assertionsYaml string) (*blocks.Assertions, *devinterface.DeveloperError) { + assertions, err := validationfile.ParseAssertionsBlock([]byte(assertionsYaml)) + if err != nil { + serr, ok := spiceerrors.AsWithSourceError(err) + if ok { + return nil, convertSourceError(devinterface.DeveloperError_ASSERTION, serr) + } + } + + return assertions, convertError(devinterface.DeveloperError_ASSERTION, err) +} + +// ParseExpectedRelationsYAML parses the YAML form of an expected relations block. +func ParseExpectedRelationsYAML(expectedRelationsYaml string) (*blocks.ParsedExpectedRelations, *devinterface.DeveloperError) { + block, err := validationfile.ParseExpectedRelationsBlock([]byte(expectedRelationsYaml)) + if err != nil { + serr, ok := spiceerrors.AsWithSourceError(err) + if ok { + return nil, convertSourceError(devinterface.DeveloperError_VALIDATION_YAML, serr) + } + } + return block, convertError(devinterface.DeveloperError_VALIDATION_YAML, err) +} + +func convertError(source devinterface.DeveloperError_Source, err error) *devinterface.DeveloperError { + if err == nil { + return nil + } + + return &devinterface.DeveloperError{ + Message: err.Error(), + Kind: devinterface.DeveloperError_PARSE_ERROR, + Source: source, + Line: 0, + } +} + +func convertSourceError(source devinterface.DeveloperError_Source, err *spiceerrors.WithSourceError) *devinterface.DeveloperError { + // NOTE: zeroes are fine here to mean "unknown" + lineNumber, castErr := safecast.ToUint32(err.LineNumber) + if castErr != nil { + log.Err(castErr).Msg("could not cast lineNumber to uint32") + } + columnPosition, castErr := safecast.ToUint32(err.ColumnPosition) + if castErr != nil { + log.Err(castErr).Msg("could not cast columnPosition to uint32") + } + return &devinterface.DeveloperError{ + Message: err.Error(), + Kind: devinterface.DeveloperError_PARSE_ERROR, + Source: source, + Line: lineNumber, + Column: columnPosition, + Context: err.SourceCodeString, + } +} diff --git a/vendor/github.com/authzed/spicedb/pkg/development/resolver.go b/vendor/github.com/authzed/spicedb/pkg/development/resolver.go new file mode 100644 index 0000000..ddb8a67 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/development/resolver.go @@ -0,0 +1,426 @@ +package development + +import ( + "context" + "fmt" + "strings" + + "github.com/ccoveille/go-safecast" + + log "github.com/authzed/spicedb/internal/logging" + "github.com/authzed/spicedb/pkg/caveats" + caveattypes "github.com/authzed/spicedb/pkg/caveats/types" + "github.com/authzed/spicedb/pkg/namespace" + core "github.com/authzed/spicedb/pkg/proto/core/v1" + "github.com/authzed/spicedb/pkg/schema" + "github.com/authzed/spicedb/pkg/schemadsl/compiler" + "github.com/authzed/spicedb/pkg/schemadsl/dslshape" + "github.com/authzed/spicedb/pkg/schemadsl/generator" + "github.com/authzed/spicedb/pkg/schemadsl/input" +) + +// ReferenceType is the type of reference. +type ReferenceType int + +const ( + ReferenceTypeUnknown ReferenceType = iota + ReferenceTypeDefinition + ReferenceTypeCaveat + ReferenceTypeRelation + ReferenceTypePermission + ReferenceTypeCaveatParameter +) + +// SchemaReference represents a reference to a schema node. +type SchemaReference struct { + // Source is the source of the reference. + Source input.Source + + // Position is the position of the reference in the source. + Position input.Position + + // Text is the text of the reference. + Text string + + // ReferenceType is the type of reference. + ReferenceType ReferenceType + + // ReferenceMarkdown is the markdown representation of the reference. + ReferenceMarkdown string + + // TargetSource is the source of the target node, if any. + TargetSource *input.Source + + // TargetPosition is the position of the target node, if any. + TargetPosition *input.Position + + // TargetSourceCode is the source code representation of the target, if any. + TargetSourceCode string + + // TargetNamePositionOffset is the offset from the target position from where the + // *name* of the target is found. + TargetNamePositionOffset int +} + +// Resolver resolves references to schema nodes from source positions. +type Resolver struct { + schema *compiler.CompiledSchema + typeSystem *schema.TypeSystem +} + +// NewResolver creates a new resolver for the given schema. +func NewResolver(compiledSchema *compiler.CompiledSchema) (*Resolver, error) { + resolver := schema.ResolverForCompiledSchema(*compiledSchema) + ts := schema.NewTypeSystem(resolver) + return &Resolver{schema: compiledSchema, typeSystem: ts}, nil +} + +// ReferenceAtPosition returns the reference to the schema node at the given position in the source, if any. +func (r *Resolver) ReferenceAtPosition(source input.Source, position input.Position) (*SchemaReference, error) { + nodeChain, err := compiler.PositionToAstNodeChain(r.schema, source, position) + if err != nil { + return nil, err + } + + if nodeChain == nil { + return nil, nil + } + + relationReference := func(relation *core.Relation, def *schema.Definition) (*SchemaReference, error) { + // NOTE: zeroes are fine here to mean "unknown" + lineNumber, err := safecast.ToInt(relation.SourcePosition.ZeroIndexedLineNumber) + if err != nil { + log.Err(err).Msg("could not cast lineNumber to uint32") + } + columnPosition, err := safecast.ToInt(relation.SourcePosition.ZeroIndexedColumnPosition) + if err != nil { + log.Err(err).Msg("could not cast columnPosition to uint32") + } + relationPosition := input.Position{ + LineNumber: lineNumber, + ColumnPosition: columnPosition, + } + + targetSourceCode, err := generator.GenerateRelationSource(relation, caveattypes.Default.TypeSet) + if err != nil { + return nil, err + } + + if def.IsPermission(relation.Name) { + return &SchemaReference{ + Source: source, + Position: position, + Text: relation.Name, + + ReferenceType: ReferenceTypePermission, + ReferenceMarkdown: fmt.Sprintf("permission %s", relation.Name), + + TargetSource: &source, + TargetPosition: &relationPosition, + TargetSourceCode: targetSourceCode, + TargetNamePositionOffset: len("permission "), + }, nil + } + + return &SchemaReference{ + Source: source, + Position: position, + Text: relation.Name, + + ReferenceType: ReferenceTypeRelation, + ReferenceMarkdown: fmt.Sprintf("relation %s", relation.Name), + + TargetSource: &source, + TargetPosition: &relationPosition, + TargetSourceCode: targetSourceCode, + TargetNamePositionOffset: len("relation "), + }, nil + } + + // Type reference. + if ts, relation, ok := r.typeReferenceChain(nodeChain); ok { + if relation != nil { + return relationReference(relation, ts) + } + + def := ts.Namespace() + + // NOTE: zeroes are fine here to mean "unknown" + lineNumber, err := safecast.ToInt(def.SourcePosition.ZeroIndexedLineNumber) + if err != nil { + log.Err(err).Msg("could not cast lineNumber to uint32") + } + columnPosition, err := safecast.ToInt(def.SourcePosition.ZeroIndexedColumnPosition) + if err != nil { + log.Err(err).Msg("could not cast columnPosition to uint32") + } + + defPosition := input.Position{ + LineNumber: lineNumber, + ColumnPosition: columnPosition, + } + + docComment := "" + comments := namespace.GetComments(def.Metadata) + if len(comments) > 0 { + docComment = strings.Join(comments, "\n") + "\n" + } + + targetSourceCode := fmt.Sprintf("%sdefinition %s {\n\t// ...\n}", docComment, def.Name) + if len(def.Relation) == 0 { + targetSourceCode = fmt.Sprintf("%sdefinition %s {}", docComment, def.Name) + } + + return &SchemaReference{ + Source: source, + Position: position, + Text: def.Name, + + ReferenceType: ReferenceTypeDefinition, + ReferenceMarkdown: fmt.Sprintf("definition %s", def.Name), + + TargetSource: &source, + TargetPosition: &defPosition, + TargetSourceCode: targetSourceCode, + TargetNamePositionOffset: len("definition "), + }, nil + } + + // Caveat Type reference. + if caveatDef, ok := r.caveatTypeReferenceChain(nodeChain); ok { + // NOTE: zeroes are fine here to mean "unknown" + lineNumber, err := safecast.ToInt(caveatDef.SourcePosition.ZeroIndexedLineNumber) + if err != nil { + log.Err(err).Msg("could not cast lineNumber to uint32") + } + columnPosition, err := safecast.ToInt(caveatDef.SourcePosition.ZeroIndexedColumnPosition) + if err != nil { + log.Err(err).Msg("could not cast columnPosition to uint32") + } + + defPosition := input.Position{ + LineNumber: lineNumber, + ColumnPosition: columnPosition, + } + + var caveatSourceCode strings.Builder + caveatSourceCode.WriteString(fmt.Sprintf("caveat %s(", caveatDef.Name)) + index := 0 + for paramName, paramType := range caveatDef.ParameterTypes { + if index > 0 { + caveatSourceCode.WriteString(", ") + } + + caveatSourceCode.WriteString(fmt.Sprintf("%s %s", paramName, caveats.ParameterTypeString(paramType))) + index++ + } + caveatSourceCode.WriteString(") {\n\t// ...\n}") + + return &SchemaReference{ + Source: source, + Position: position, + Text: caveatDef.Name, + + ReferenceType: ReferenceTypeCaveat, + ReferenceMarkdown: fmt.Sprintf("caveat %s", caveatDef.Name), + + TargetSource: &source, + TargetPosition: &defPosition, + TargetSourceCode: caveatSourceCode.String(), + TargetNamePositionOffset: len("caveat "), + }, nil + } + + // Relation reference. + if relation, ts, ok := r.relationReferenceChain(nodeChain); ok { + return relationReference(relation, ts) + } + + // Caveat parameter used in expression. + if caveatParamName, caveatDef, ok := r.caveatParamChain(nodeChain, source, position); ok { + targetSourceCode := fmt.Sprintf("%s %s", caveatParamName, caveats.ParameterTypeString(caveatDef.ParameterTypes[caveatParamName])) + + return &SchemaReference{ + Source: source, + Position: position, + Text: caveatParamName, + + ReferenceType: ReferenceTypeCaveatParameter, + ReferenceMarkdown: targetSourceCode, + + TargetSource: &source, + TargetSourceCode: targetSourceCode, + }, nil + } + + return nil, nil +} + +func (r *Resolver) lookupCaveat(caveatName string) (*core.CaveatDefinition, bool) { + for _, caveatDef := range r.schema.CaveatDefinitions { + if caveatDef.Name == caveatName { + return caveatDef, true + } + } + + return nil, false +} + +func (r *Resolver) lookupRelation(defName, relationName string) (*core.Relation, *schema.Definition, bool) { + ts, err := r.typeSystem.GetDefinition(context.Background(), defName) + if err != nil { + return nil, nil, false + } + + rel, ok := ts.GetRelation(relationName) + if !ok { + return nil, nil, false + } + + return rel, ts, true +} + +func (r *Resolver) caveatParamChain(nodeChain *compiler.NodeChain, source input.Source, position input.Position) (string, *core.CaveatDefinition, bool) { + if !nodeChain.HasHeadType(dslshape.NodeTypeCaveatExpression) { + return "", nil, false + } + + caveatDefNode := nodeChain.FindNodeOfType(dslshape.NodeTypeCaveatDefinition) + if caveatDefNode == nil { + return "", nil, false + } + + caveatName, err := caveatDefNode.GetString(dslshape.NodeCaveatDefinitionPredicateName) + if err != nil { + return "", nil, false + } + + caveatDef, ok := r.lookupCaveat(caveatName) + if !ok { + return "", nil, false + } + + runePosition, err := r.schema.SourcePositionToRunePosition(source, position) + if err != nil { + return "", nil, false + } + + exprRunePosition, err := nodeChain.Head().GetInt(dslshape.NodePredicateStartRune) + if err != nil { + return "", nil, false + } + + if exprRunePosition > runePosition { + return "", nil, false + } + + relationRunePosition := runePosition - exprRunePosition + + caveatExpr, err := nodeChain.Head().GetString(dslshape.NodeCaveatExpressionPredicateExpression) + if err != nil { + return "", nil, false + } + + // Split the expression into tokens and find the associated token. + tokens := strings.FieldsFunc(caveatExpr, splitCELToken) + currentIndex := 0 + for _, token := range tokens { + if currentIndex <= relationRunePosition && currentIndex+len(token) >= relationRunePosition { + if _, ok := caveatDef.ParameterTypes[token]; ok { + return token, caveatDef, true + } + } + } + + return "", caveatDef, true +} + +func splitCELToken(r rune) bool { + return r == ' ' || r == '(' || r == ')' || r == '.' || r == ',' || r == '[' || r == ']' || r == '{' || r == '}' || r == ':' || r == '=' +} + +func (r *Resolver) caveatTypeReferenceChain(nodeChain *compiler.NodeChain) (*core.CaveatDefinition, bool) { + if !nodeChain.HasHeadType(dslshape.NodeTypeCaveatReference) { + return nil, false + } + + caveatName, err := nodeChain.Head().GetString(dslshape.NodeCaveatPredicateCaveat) + if err != nil { + return nil, false + } + + return r.lookupCaveat(caveatName) +} + +func (r *Resolver) typeReferenceChain(nodeChain *compiler.NodeChain) (*schema.Definition, *core.Relation, bool) { + if !nodeChain.HasHeadType(dslshape.NodeTypeSpecificTypeReference) { + return nil, nil, false + } + + defName, err := nodeChain.Head().GetString(dslshape.NodeSpecificReferencePredicateType) + if err != nil { + return nil, nil, false + } + + def, err := r.typeSystem.GetDefinition(context.Background(), defName) + if err != nil { + return nil, nil, false + } + + relationName, err := nodeChain.Head().GetString(dslshape.NodeSpecificReferencePredicateRelation) + if err != nil { + return def, nil, true + } + + startingRune, err := nodeChain.Head().GetInt(dslshape.NodePredicateStartRune) + if err != nil { + return def, nil, true + } + + // If hover over the definition name, return the definition. + if nodeChain.ForRunePosition() < startingRune+len(defName) { + return def, nil, true + } + + relation, ok := def.GetRelation(relationName) + if !ok { + return nil, nil, false + } + + return def, relation, true +} + +func (r *Resolver) relationReferenceChain(nodeChain *compiler.NodeChain) (*core.Relation, *schema.Definition, bool) { + if !nodeChain.HasHeadType(dslshape.NodeTypeIdentifier) { + return nil, nil, false + } + + if arrowExpr := nodeChain.FindNodeOfType(dslshape.NodeTypeArrowExpression); arrowExpr != nil { + // Ensure this on the left side of the arrow. + rightExpr, err := arrowExpr.Lookup(dslshape.NodeExpressionPredicateRightExpr) + if err != nil { + return nil, nil, false + } + + if rightExpr == nodeChain.Head() { + return nil, nil, false + } + } + + relationName, err := nodeChain.Head().GetString(dslshape.NodeIdentiferPredicateValue) + if err != nil { + return nil, nil, false + } + + parentDefNode := nodeChain.FindNodeOfType(dslshape.NodeTypeDefinition) + if parentDefNode == nil { + return nil, nil, false + } + + defName, err := parentDefNode.GetString(dslshape.NodeDefinitionPredicateName) + if err != nil { + return nil, nil, false + } + + return r.lookupRelation(defName, relationName) +} diff --git a/vendor/github.com/authzed/spicedb/pkg/development/schema.go b/vendor/github.com/authzed/spicedb/pkg/development/schema.go new file mode 100644 index 0000000..0e50451 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/development/schema.go @@ -0,0 +1,54 @@ +package development + +import ( + "errors" + + "github.com/ccoveille/go-safecast" + + log "github.com/authzed/spicedb/internal/logging" + devinterface "github.com/authzed/spicedb/pkg/proto/developer/v1" + "github.com/authzed/spicedb/pkg/schemadsl/compiler" + "github.com/authzed/spicedb/pkg/schemadsl/input" +) + +// CompileSchema compiles a schema into its caveat and namespace definition(s), returning a developer +// error if the schema could not be compiled. The non-developer error is returned only if an +// internal errors occurred. +func CompileSchema(schema string) (*compiler.CompiledSchema, *devinterface.DeveloperError, error) { + compiled, err := compiler.Compile(compiler.InputSchema{ + Source: input.Source("schema"), + SchemaString: schema, + }, compiler.AllowUnprefixedObjectType()) + + var contextError compiler.WithContextError + if errors.As(err, &contextError) { + line, col, lerr := contextError.SourceRange.Start().LineAndColumn() + if lerr != nil { + return nil, nil, lerr + } + + // NOTE: zeroes are fine here on failure. + uintLine, err := safecast.ToUint32(line) + if err != nil { + log.Err(err).Msg("could not cast lineNumber to uint32") + } + uintColumn, err := safecast.ToUint32(col) + if err != nil { + log.Err(err).Msg("could not cast columnPosition to uint32") + } + return nil, &devinterface.DeveloperError{ + Message: contextError.BaseCompilerError.BaseMessage, + Kind: devinterface.DeveloperError_SCHEMA_ISSUE, + Source: devinterface.DeveloperError_SCHEMA, + Line: uintLine + 1, // 0-indexed in parser. + Column: uintColumn + 1, // 0-indexed in parser. + Context: contextError.ErrorSourceCode, + }, nil + } + + if err != nil { + return nil, nil, err + } + + return compiled, nil, nil +} diff --git a/vendor/github.com/authzed/spicedb/pkg/development/validation.go b/vendor/github.com/authzed/spicedb/pkg/development/validation.go new file mode 100644 index 0000000..b3da6cf --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/development/validation.go @@ -0,0 +1,286 @@ +package development + +import ( + "fmt" + "sort" + "strings" + + "github.com/ccoveille/go-safecast" + "github.com/google/go-cmp/cmp" + yaml "gopkg.in/yaml.v2" + + "github.com/authzed/spicedb/internal/developmentmembership" + log "github.com/authzed/spicedb/internal/logging" + devinterface "github.com/authzed/spicedb/pkg/proto/developer/v1" + v1 "github.com/authzed/spicedb/pkg/proto/dispatch/v1" + "github.com/authzed/spicedb/pkg/tuple" + "github.com/authzed/spicedb/pkg/validationfile/blocks" +) + +// RunValidation runs the parsed validation block against the data in the dev context. +func RunValidation(devContext *DevContext, validation *blocks.ParsedExpectedRelations) (*developmentmembership.Set, []*devinterface.DeveloperError, error) { + var failures []*devinterface.DeveloperError + membershipSet := developmentmembership.NewMembershipSet() + ctx := devContext.Ctx + + for onrKey, expectedSubjects := range validation.ValidationMap { + // Run a full recursive expansion over the ONR. + er, derr := devContext.Dispatcher.DispatchExpand(ctx, &v1.DispatchExpandRequest{ + ResourceAndRelation: onrKey.ObjectAndRelation.ToCoreONR(), + Metadata: &v1.ResolverMeta{ + AtRevision: devContext.Revision.String(), + DepthRemaining: maxDispatchDepth, + TraversalBloom: v1.MustNewTraversalBloomFilter(uint(maxDispatchDepth)), + }, + ExpansionMode: v1.DispatchExpandRequest_RECURSIVE, + }) + if derr != nil { + devErr, wireErr := DistinguishGraphError(devContext, derr, devinterface.DeveloperError_VALIDATION_YAML, 0, 0, onrKey.ObjectRelationString) + if wireErr != nil { + return nil, nil, wireErr + } + + failures = append(failures, devErr) + continue + } + + // Add the ONR and its expansion to the membership set. + foundSubjects, _, aerr := membershipSet.AddExpansion(onrKey.ObjectAndRelation, er.TreeNode) + if aerr != nil { + devErr, wireErr := DistinguishGraphError(devContext, aerr, devinterface.DeveloperError_VALIDATION_YAML, 0, 0, onrKey.ObjectRelationString) + if wireErr != nil { + return nil, nil, wireErr + } + + failures = append(failures, devErr) + continue + } + + // Compare the terminal subjects found to those specified. + errs := validateSubjects(onrKey, foundSubjects, expectedSubjects) + failures = append(failures, errs...) + } + + if len(failures) > 0 { + return membershipSet, failures, nil + } + + return membershipSet, nil, nil +} + +func wrapResources(onrStrings []string) []string { + wrapped := make([]string, 0, len(onrStrings)) + for _, str := range onrStrings { + wrapped = append(wrapped, "<"+str+">") + } + + // Sort to ensure stability. + sort.Strings(wrapped) + return wrapped +} + +func validateSubjects(onrKey blocks.ObjectRelation, fs developmentmembership.FoundSubjects, expectedSubjects []blocks.ExpectedSubject) []*devinterface.DeveloperError { + onr := onrKey.ObjectAndRelation + + var failures []*devinterface.DeveloperError + + // Verify that every referenced subject is found in the membership. + encounteredSubjects := map[string]struct{}{} + for _, expectedSubject := range expectedSubjects { + subjectWithExceptions := expectedSubject.SubjectWithExceptions + // NOTE: zeroes are fine here on failure. + lineNumber, err := safecast.ToUint32(expectedSubject.SourcePosition.LineNumber) + if err != nil { + log.Err(err).Msg("could not cast lineNumber to uint32") + } + columnPosition, err := safecast.ToUint32(expectedSubject.SourcePosition.ColumnPosition) + if err != nil { + log.Err(err).Msg("could not cast columnPosition to uint32") + } + if subjectWithExceptions == nil { + failures = append(failures, &devinterface.DeveloperError{ + Message: fmt.Sprintf("For object and permission/relation `%s`, no expected subject specified in `%s`", tuple.StringONR(onr), expectedSubject.ValidationString), + Source: devinterface.DeveloperError_VALIDATION_YAML, + Kind: devinterface.DeveloperError_MISSING_EXPECTED_RELATIONSHIP, + Context: string(expectedSubject.ValidationString), + Line: lineNumber, + Column: columnPosition, + }) + continue + } + + encounteredSubjects[tuple.StringONR(subjectWithExceptions.Subject.Subject)] = struct{}{} + + subject, ok := fs.LookupSubject(subjectWithExceptions.Subject.Subject) + if !ok { + failures = append(failures, &devinterface.DeveloperError{ + Message: fmt.Sprintf("For object and permission/relation `%s`, missing expected subject `%s`", tuple.StringONR(onr), tuple.StringONR(subjectWithExceptions.Subject.Subject)), + Source: devinterface.DeveloperError_VALIDATION_YAML, + Kind: devinterface.DeveloperError_MISSING_EXPECTED_RELATIONSHIP, + Context: string(expectedSubject.ValidationString), + Line: lineNumber, + Column: columnPosition, + }) + continue + } + + // Verify that the relationships are the same. + foundParentResources := subject.ParentResources() + expectedONRStrings := tuple.StringsONRs(expectedSubject.Resources) + foundONRStrings := tuple.StringsONRs(foundParentResources) + if !cmp.Equal(expectedONRStrings, foundONRStrings) { + failures = append(failures, &devinterface.DeveloperError{ + Message: fmt.Sprintf("For object and permission/relation `%s`, found different relationships for subject `%s`: Specified: `%s`, Computed: `%s`", + tuple.StringONR(onr), + tuple.StringONR(subjectWithExceptions.Subject.Subject), + strings.Join(wrapResources(expectedONRStrings), "/"), + strings.Join(wrapResources(foundONRStrings), "/"), + ), + Source: devinterface.DeveloperError_VALIDATION_YAML, + Kind: devinterface.DeveloperError_MISSING_EXPECTED_RELATIONSHIP, + Context: string(expectedSubject.ValidationString), + Line: lineNumber, + Column: columnPosition, + }) + } + + // Verify exclusions are the same, if any. + foundExcludedSubjects, isWildcard := subject.ExcludedSubjectsFromWildcard() + expectedExcludedSubjects := subjectWithExceptions.Exceptions + if isWildcard { + expectedExcludedStrings := toExpectedRelationshipsStrings(expectedExcludedSubjects) + foundExcludedONRStrings := toFoundRelationshipsStrings(foundExcludedSubjects) + + sort.Strings(expectedExcludedStrings) + sort.Strings(foundExcludedONRStrings) + + if !cmp.Equal(expectedExcludedStrings, foundExcludedONRStrings) { + failures = append(failures, &devinterface.DeveloperError{ + Message: fmt.Sprintf("For object and permission/relation `%s`, found different excluded subjects for subject `%s`: Specified: `%s`, Computed: `%s`", + tuple.StringONR(onr), + tuple.StringONR(subjectWithExceptions.Subject.Subject), + strings.Join(wrapResources(expectedExcludedStrings), ", "), + strings.Join(wrapResources(foundExcludedONRStrings), ", "), + ), + Source: devinterface.DeveloperError_VALIDATION_YAML, + Kind: devinterface.DeveloperError_MISSING_EXPECTED_RELATIONSHIP, + Context: string(expectedSubject.ValidationString), + Line: lineNumber, + Column: columnPosition, + }) + } + } else { + if len(expectedExcludedSubjects) > 0 { + failures = append(failures, &devinterface.DeveloperError{ + Message: fmt.Sprintf("For object and permission/relation `%s`, found unexpected excluded subjects", + tuple.StringONR(onr), + ), + Source: devinterface.DeveloperError_VALIDATION_YAML, + Kind: devinterface.DeveloperError_EXTRA_RELATIONSHIP_FOUND, + Context: string(expectedSubject.ValidationString), + Line: lineNumber, + Column: columnPosition, + }) + } + } + + // Verify caveats. + if (subject.GetCaveatExpression() != nil) != subjectWithExceptions.Subject.IsCaveated { + failures = append(failures, &devinterface.DeveloperError{ + Message: fmt.Sprintf("For object and permission/relation `%s`, found caveat mismatch", + tuple.StringONR(onr), + ), + Source: devinterface.DeveloperError_VALIDATION_YAML, + Kind: devinterface.DeveloperError_MISSING_EXPECTED_RELATIONSHIP, + Context: string(expectedSubject.ValidationString), + Line: lineNumber, + Column: columnPosition, + }) + } + } + + // Verify that every subject found was referenced. + for _, foundSubject := range fs.ListFound() { + _, ok := encounteredSubjects[tuple.StringONR(foundSubject.Subject())] + if !ok { + onrLineNumber, err := safecast.ToUint32(onrKey.SourcePosition.LineNumber) + if err != nil { + log.Err(err).Msg("could not cast lineNumber to uint32") + } + onrColumnPosition, err := safecast.ToUint32(onrKey.SourcePosition.ColumnPosition) + if err != nil { + log.Err(err).Msg("could not cast columnPosition to uint32") + } + failures = append(failures, &devinterface.DeveloperError{ + Message: fmt.Sprintf("For object and permission/relation `%s`, subject `%s` found but not listed in expected subjects", + tuple.StringONR(onr), + tuple.StringONR(foundSubject.Subject()), + ), + Source: devinterface.DeveloperError_VALIDATION_YAML, + Kind: devinterface.DeveloperError_EXTRA_RELATIONSHIP_FOUND, + Context: tuple.StringONR(onr), + Line: onrLineNumber, + Column: onrColumnPosition, + }) + } + } + + return failures +} + +// GenerateValidation generates the validation block based on a membership set. +func GenerateValidation(membershipSet *developmentmembership.Set) (string, error) { + validationMap := map[string][]string{} + subjectsByONR := membershipSet.SubjectsByONR() + + onrStrings := make([]string, 0, len(subjectsByONR)) + for onrString := range subjectsByONR { + onrStrings = append(onrStrings, onrString) + } + + // Sort to ensure stability of output. + sort.Strings(onrStrings) + + for _, onrString := range onrStrings { + foundSubjects := subjectsByONR[onrString] + var strs []string + for _, fs := range foundSubjects.ListFound() { + strs = append(strs, + fmt.Sprintf("[%s] is %s", + fs.ToValidationString(), + strings.Join(wrapResources(tuple.StringsONRs(fs.ParentResources())), "/"), + )) + } + + // Sort to ensure stability of output. + sort.Strings(strs) + validationMap[onrString] = strs + } + + contents, err := yaml.Marshal(validationMap) + if err != nil { + return "", err + } + + return string(contents), nil +} + +func toExpectedRelationshipsStrings(subs []blocks.SubjectAndCaveat) []string { + mapped := make([]string, 0, len(subs)) + for _, sub := range subs { + if sub.IsCaveated { + mapped = append(mapped, tuple.StringONR(sub.Subject)+"[...]") + } else { + mapped = append(mapped, tuple.StringONR(sub.Subject)) + } + } + return mapped +} + +func toFoundRelationshipsStrings(subs []developmentmembership.FoundSubject) []string { + mapped := make([]string, 0, len(subs)) + for _, sub := range subs { + mapped = append(mapped, sub.ToValidationString()) + } + return mapped +} diff --git a/vendor/github.com/authzed/spicedb/pkg/development/warningdefs.go b/vendor/github.com/authzed/spicedb/pkg/development/warningdefs.go new file mode 100644 index 0000000..b995933 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/development/warningdefs.go @@ -0,0 +1,232 @@ +package development + +import ( + "context" + "fmt" + "strings" + + corev1 "github.com/authzed/spicedb/pkg/proto/core/v1" + devinterface "github.com/authzed/spicedb/pkg/proto/developer/v1" + "github.com/authzed/spicedb/pkg/schema" + "github.com/authzed/spicedb/pkg/tuple" +) + +var lintRelationReferencesParentType = relationCheck{ + "relation-name-references-parent", + func( + ctx context.Context, + relation *corev1.Relation, + def *schema.Definition, + ) (*devinterface.DeveloperWarning, error) { + parentDef := def.Namespace() + if strings.HasSuffix(relation.Name, parentDef.Name) { + if def.IsPermission(relation.Name) { + return warningForMetadata( + "relation-name-references-parent", + fmt.Sprintf("Permission %q references parent type %q in its name; it is recommended to drop the suffix", relation.Name, parentDef.Name), + relation.Name, + relation, + ), nil + } + + return warningForMetadata( + "relation-name-references-parent", + fmt.Sprintf("Relation %q references parent type %q in its name; it is recommended to drop the suffix", relation.Name, parentDef.Name), + relation.Name, + relation, + ), nil + } + + return nil, nil + }, +} + +var lintPermissionReferencingItself = computedUsersetCheck{ + "permission-references-itself", + func( + ctx context.Context, + computedUserset *corev1.ComputedUserset, + sourcePosition *corev1.SourcePosition, + def *schema.Definition, + ) (*devinterface.DeveloperWarning, error) { + parentRelation := ctx.Value(relationKey).(*corev1.Relation) + permName := parentRelation.Name + if computedUserset.GetRelation() == permName { + return warningForPosition( + "permission-references-itself", + fmt.Sprintf("Permission %q references itself, which will cause an error to be raised due to infinite recursion", permName), + permName, + sourcePosition, + ), nil + } + + return nil, nil + }, +} + +var lintArrowReferencingUnreachable = ttuCheck{ + "arrow-references-unreachable-relation", + func( + ctx context.Context, + ttu ttu, + sourcePosition *corev1.SourcePosition, + def *schema.Definition, + ) (*devinterface.DeveloperWarning, error) { + parentRelation := ctx.Value(relationKey).(*corev1.Relation) + + referencedRelation, ok := def.GetRelation(ttu.GetTupleset().GetRelation()) + if !ok { + return nil, nil + } + + allowedSubjectTypes, err := def.AllowedSubjectRelations(referencedRelation.Name) + if err != nil { + return nil, err + } + + wasFound := false + for _, subjectType := range allowedSubjectTypes { + nts, err := def.TypeSystem().GetDefinition(ctx, subjectType.Namespace) + if err != nil { + return nil, err + } + + _, ok := nts.GetRelation(ttu.GetComputedUserset().GetRelation()) + if ok { + wasFound = true + } + } + + if !wasFound { + arrowString, err := ttu.GetArrowString() + if err != nil { + return nil, err + } + + return warningForPosition( + "arrow-references-unreachable-relation", + fmt.Sprintf( + "Arrow `%s` under permission %q references relation/permission %q that does not exist on any subject types of relation %q", + arrowString, + parentRelation.Name, + ttu.GetComputedUserset().GetRelation(), + ttu.GetTupleset().GetRelation(), + ), + arrowString, + sourcePosition, + ), nil + } + + return nil, nil + }, +} + +var lintArrowOverSubRelation = ttuCheck{ + "arrow-walks-subject-relation", + func( + ctx context.Context, + ttu ttu, + sourcePosition *corev1.SourcePosition, + def *schema.Definition, + ) (*devinterface.DeveloperWarning, error) { + parentRelation := ctx.Value(relationKey).(*corev1.Relation) + + referencedRelation, ok := def.GetRelation(ttu.GetTupleset().GetRelation()) + if !ok { + return nil, nil + } + + allowedSubjectTypes, err := def.AllowedSubjectRelations(referencedRelation.Name) + if err != nil { + return nil, err + } + + arrowString, err := ttu.GetArrowString() + if err != nil { + return nil, err + } + + for _, subjectType := range allowedSubjectTypes { + if subjectType.GetRelation() != tuple.Ellipsis { + return warningForPosition( + "arrow-walks-subject-relation", + fmt.Sprintf( + "Arrow `%s` under permission %q references relation %q that has relation %q on subject %q: *the subject relation will be ignored for the arrow*", + arrowString, + parentRelation.Name, + ttu.GetTupleset().GetRelation(), + subjectType.GetRelation(), + subjectType.Namespace, + ), + arrowString, + sourcePosition, + ), nil + } + } + + return nil, nil + }, +} + +var lintArrowReferencingRelation = ttuCheck{ + "arrow-references-relation", + func( + ctx context.Context, + ttu ttu, + sourcePosition *corev1.SourcePosition, + def *schema.Definition, + ) (*devinterface.DeveloperWarning, error) { + parentRelation := ctx.Value(relationKey).(*corev1.Relation) + + referencedRelation, ok := def.GetRelation(ttu.GetTupleset().GetRelation()) + if !ok { + return nil, nil + } + + // For each subject type of the referenced relation, check if the referenced permission + // is, in fact, a relation. + allowedSubjectTypes, err := def.AllowedSubjectRelations(referencedRelation.Name) + if err != nil { + return nil, err + } + + arrowString, err := ttu.GetArrowString() + if err != nil { + return nil, err + } + + for _, subjectType := range allowedSubjectTypes { + // Skip for arrow referencing relations in the same namespace. + if subjectType.Namespace == def.Namespace().Name { + continue + } + + nts, err := def.TypeSystem().GetDefinition(ctx, subjectType.Namespace) + if err != nil { + return nil, err + } + + targetRelation, ok := nts.GetRelation(ttu.GetComputedUserset().GetRelation()) + if !ok { + continue + } + + if !nts.IsPermission(targetRelation.Name) { + return warningForPosition( + "arrow-references-relation", + fmt.Sprintf( + "Arrow `%s` under permission %q references relation %q on definition %q; it is recommended to point to a permission", + arrowString, + parentRelation.Name, + targetRelation.Name, + subjectType.Namespace, + ), + arrowString, + sourcePosition, + ), nil + } + } + + return nil, nil + }, +} diff --git a/vendor/github.com/authzed/spicedb/pkg/development/warnings.go b/vendor/github.com/authzed/spicedb/pkg/development/warnings.go new file mode 100644 index 0000000..6be9a1c --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/development/warnings.go @@ -0,0 +1,309 @@ +package development + +import ( + "context" + "fmt" + + "github.com/ccoveille/go-safecast" + + log "github.com/authzed/spicedb/internal/logging" + "github.com/authzed/spicedb/pkg/namespace" + corev1 "github.com/authzed/spicedb/pkg/proto/core/v1" + devinterface "github.com/authzed/spicedb/pkg/proto/developer/v1" + "github.com/authzed/spicedb/pkg/schema" + "github.com/authzed/spicedb/pkg/spiceerrors" +) + +var allChecks = checks{ + relationChecks: []relationCheck{ + lintRelationReferencesParentType, + }, + computedUsersetChecks: []computedUsersetCheck{ + lintPermissionReferencingItself, + }, + ttuChecks: []ttuCheck{ + lintArrowReferencingRelation, + lintArrowReferencingUnreachable, + lintArrowOverSubRelation, + }, +} + +func warningForMetadata(warningName string, message string, sourceCode string, metadata namespace.WithSourcePosition) *devinterface.DeveloperWarning { + return warningForPosition(warningName, message, sourceCode, metadata.GetSourcePosition()) +} + +func warningForPosition(warningName string, message string, sourceCode string, sourcePosition *corev1.SourcePosition) *devinterface.DeveloperWarning { + if sourcePosition == nil { + return &devinterface.DeveloperWarning{ + Message: message, + SourceCode: sourceCode, + } + } + + // NOTE: zeroes on failure are fine here. + lineNumber, err := safecast.ToUint32(sourcePosition.ZeroIndexedLineNumber) + if err != nil { + log.Err(err).Msg("could not cast lineNumber to uint32") + } + columnNumber, err := safecast.ToUint32(sourcePosition.ZeroIndexedColumnPosition) + if err != nil { + log.Err(err).Msg("could not cast columnPosition to uint32") + } + + return &devinterface.DeveloperWarning{ + Message: message + " (" + warningName + ")", + Line: lineNumber + 1, + Column: columnNumber + 1, + SourceCode: sourceCode, + } +} + +// GetWarnings returns a list of warnings for the given developer context. +func GetWarnings(ctx context.Context, devCtx *DevContext) ([]*devinterface.DeveloperWarning, error) { + warnings := []*devinterface.DeveloperWarning{} + res := schema.ResolverForCompiledSchema(*devCtx.CompiledSchema) + ts := schema.NewTypeSystem(res) + + for _, def := range devCtx.CompiledSchema.ObjectDefinitions { + found, err := addDefinitionWarnings(ctx, def, ts) + if err != nil { + return nil, err + } + warnings = append(warnings, found...) + } + + return warnings, nil +} + +type contextKey string + +var relationKey = contextKey("relation") + +func addDefinitionWarnings(ctx context.Context, nsDef *corev1.NamespaceDefinition, ts *schema.TypeSystem) ([]*devinterface.DeveloperWarning, error) { + def, err := schema.NewDefinition(ts, nsDef) + if err != nil { + return nil, err + } + + warnings := []*devinterface.DeveloperWarning{} + for _, rel := range nsDef.Relation { + ctx = context.WithValue(ctx, relationKey, rel) + + for _, check := range allChecks.relationChecks { + if shouldSkipCheck(rel.Metadata, check.name) { + continue + } + + checkerWarning, err := check.fn(ctx, rel, def) + if err != nil { + return nil, err + } + + if checkerWarning != nil { + warnings = append(warnings, checkerWarning) + } + } + + if def.IsPermission(rel.Name) { + found, err := walkUsersetRewrite(ctx, rel.UsersetRewrite, rel, allChecks, def) + if err != nil { + return nil, err + } + + warnings = append(warnings, found...) + } + } + + return warnings, nil +} + +func shouldSkipCheck(metadata *corev1.Metadata, name string) bool { + if metadata == nil { + return false + } + + comments := namespace.GetComments(metadata) + for _, comment := range comments { + if comment == "// spicedb-ignore-warning: "+name { + return true + } + } + + return false +} + +type tupleset interface { + GetRelation() string +} + +type ttu interface { + GetTupleset() tupleset + GetComputedUserset() *corev1.ComputedUserset + GetArrowString() (string, error) +} + +type ( + relationChecker func(ctx context.Context, relation *corev1.Relation, def *schema.Definition) (*devinterface.DeveloperWarning, error) + computedUsersetChecker func(ctx context.Context, computedUserset *corev1.ComputedUserset, sourcePosition *corev1.SourcePosition, def *schema.Definition) (*devinterface.DeveloperWarning, error) + ttuChecker func(ctx context.Context, ttu ttu, sourcePosition *corev1.SourcePosition, def *schema.Definition) (*devinterface.DeveloperWarning, error) +) + +type relationCheck struct { + name string + fn relationChecker +} + +type computedUsersetCheck struct { + name string + fn computedUsersetChecker +} + +type ttuCheck struct { + name string + fn ttuChecker +} + +type checks struct { + relationChecks []relationCheck + computedUsersetChecks []computedUsersetCheck + ttuChecks []ttuCheck +} + +func walkUsersetRewrite(ctx context.Context, rewrite *corev1.UsersetRewrite, relation *corev1.Relation, checks checks, def *schema.Definition) ([]*devinterface.DeveloperWarning, error) { + if rewrite == nil { + return nil, nil + } + + switch t := (rewrite.RewriteOperation).(type) { + case *corev1.UsersetRewrite_Union: + return walkUsersetOperations(ctx, t.Union.Child, relation, checks, def) + + case *corev1.UsersetRewrite_Intersection: + return walkUsersetOperations(ctx, t.Intersection.Child, relation, checks, def) + + case *corev1.UsersetRewrite_Exclusion: + return walkUsersetOperations(ctx, t.Exclusion.Child, relation, checks, def) + + default: + return nil, spiceerrors.MustBugf("unexpected rewrite operation type %T", t) + } +} + +func walkUsersetOperations(ctx context.Context, ops []*corev1.SetOperation_Child, relation *corev1.Relation, checks checks, def *schema.Definition) ([]*devinterface.DeveloperWarning, error) { + warnings := []*devinterface.DeveloperWarning{} + for _, op := range ops { + switch t := op.ChildType.(type) { + case *corev1.SetOperation_Child_XThis: + continue + + case *corev1.SetOperation_Child_ComputedUserset: + for _, check := range checks.computedUsersetChecks { + if shouldSkipCheck(relation.Metadata, check.name) { + continue + } + + checkerWarning, err := check.fn(ctx, t.ComputedUserset, op.SourcePosition, def) + if err != nil { + return nil, err + } + + if checkerWarning != nil { + warnings = append(warnings, checkerWarning) + } + } + + case *corev1.SetOperation_Child_UsersetRewrite: + found, err := walkUsersetRewrite(ctx, t.UsersetRewrite, relation, checks, def) + if err != nil { + return nil, err + } + + warnings = append(warnings, found...) + + case *corev1.SetOperation_Child_FunctionedTupleToUserset: + for _, check := range checks.ttuChecks { + if shouldSkipCheck(relation.Metadata, check.name) { + continue + } + + checkerWarning, err := check.fn(ctx, wrappedFunctionedTTU{t.FunctionedTupleToUserset}, op.SourcePosition, def) + if err != nil { + return nil, err + } + + if checkerWarning != nil { + warnings = append(warnings, checkerWarning) + } + } + + case *corev1.SetOperation_Child_TupleToUserset: + for _, check := range checks.ttuChecks { + if shouldSkipCheck(relation.Metadata, check.name) { + continue + } + + checkerWarning, err := check.fn(ctx, wrappedTTU{t.TupleToUserset}, op.SourcePosition, def) + if err != nil { + return nil, err + } + + if checkerWarning != nil { + warnings = append(warnings, checkerWarning) + } + } + + case *corev1.SetOperation_Child_XNil: + continue + + default: + return nil, spiceerrors.MustBugf("unexpected set operation type %T", t) + } + } + + return warnings, nil +} + +type wrappedFunctionedTTU struct { + *corev1.FunctionedTupleToUserset +} + +func (wfttu wrappedFunctionedTTU) GetTupleset() tupleset { + return wfttu.FunctionedTupleToUserset.GetTupleset() +} + +func (wfttu wrappedFunctionedTTU) GetComputedUserset() *corev1.ComputedUserset { + return wfttu.FunctionedTupleToUserset.GetComputedUserset() +} + +func (wfttu wrappedFunctionedTTU) GetArrowString() (string, error) { + var functionName string + switch wfttu.Function { + case corev1.FunctionedTupleToUserset_FUNCTION_ANY: + functionName = "any" + + case corev1.FunctionedTupleToUserset_FUNCTION_ALL: + functionName = "all" + + default: + return "", spiceerrors.MustBugf("unknown function type %T", wfttu.Function) + } + + return fmt.Sprintf("%s.%s(%s)", wfttu.GetTupleset().GetRelation(), functionName, wfttu.GetComputedUserset().GetRelation()), nil +} + +type wrappedTTU struct { + *corev1.TupleToUserset +} + +func (wtu wrappedTTU) GetTupleset() tupleset { + return wtu.TupleToUserset.GetTupleset() +} + +func (wtu wrappedTTU) GetComputedUserset() *corev1.ComputedUserset { + return wtu.TupleToUserset.GetComputedUserset() +} + +func (wtu wrappedTTU) GetArrowString() (string, error) { + arrowString := fmt.Sprintf("%s->%s", wtu.GetTupleset().GetRelation(), wtu.GetComputedUserset().GetRelation()) + return arrowString, nil +} diff --git a/vendor/github.com/authzed/spicedb/pkg/diff/caveats/diff.go b/vendor/github.com/authzed/spicedb/pkg/diff/caveats/diff.go new file mode 100644 index 0000000..74e196b --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/diff/caveats/diff.go @@ -0,0 +1,164 @@ +package caveats + +import ( + "bytes" + + "golang.org/x/exp/maps" + "golang.org/x/exp/slices" + + caveattypes "github.com/authzed/spicedb/pkg/caveats/types" + "github.com/authzed/spicedb/pkg/genutil/mapz" + nspkg "github.com/authzed/spicedb/pkg/namespace" + core "github.com/authzed/spicedb/pkg/proto/core/v1" +) + +// DeltaType defines the type of caveat deltas. +type DeltaType string + +const ( + // CaveatAdded indicates that the caveat was newly added/created. + CaveatAdded DeltaType = "caveat-added" + + // CaveatRemoved indicates that the caveat was removed. + CaveatRemoved DeltaType = "caveat-removed" + + // CaveatCommentsChanged indicates that the comment(s) on the caveat were changed. + CaveatCommentsChanged DeltaType = "caveat-comments-changed" + + // AddedParameter indicates that the parameter was added to the caveat. + AddedParameter DeltaType = "added-parameter" + + // RemovedParameter indicates that the parameter was removed from the caveat. + RemovedParameter DeltaType = "removed-parameter" + + // ParameterTypeChanged indicates that the type of the parameter was changed. + ParameterTypeChanged DeltaType = "parameter-type-changed" + + // CaveatExpressionChanged indicates that the expression of the caveat has changed. + CaveatExpressionChanged DeltaType = "expression-has-changed" +) + +// Diff holds the diff between two caveats. +type Diff struct { + existing *core.CaveatDefinition + updated *core.CaveatDefinition + deltas []Delta +} + +// Deltas returns the deltas between the two caveats. +func (cd Diff) Deltas() []Delta { + return cd.deltas +} + +// Delta holds a single change of a caveat. +type Delta struct { + // Type is the type of this delta. + Type DeltaType + + // ParameterName is the name of the parameter to which this delta applies, if any. + ParameterName string + + // PreviousType is the previous type of the parameter changed, if any. + PreviousType *core.CaveatTypeReference + + // CurrentType is the current type of the parameter changed, if any. + CurrentType *core.CaveatTypeReference +} + +// DiffCaveats performs a diff between two caveat definitions. One or both of the definitions +// can be `nil`, which will be treated as an add/remove as applicable. +func DiffCaveats(existing *core.CaveatDefinition, updated *core.CaveatDefinition, caveatTypeSet *caveattypes.TypeSet) (*Diff, error) { + // Check for the caveats themselves. + if existing == nil && updated == nil { + return &Diff{existing, updated, []Delta{}}, nil + } + + if existing != nil && updated == nil { + return &Diff{ + existing: existing, + updated: updated, + deltas: []Delta{ + { + Type: CaveatRemoved, + }, + }, + }, nil + } + + if existing == nil && updated != nil { + return &Diff{ + existing: existing, + updated: updated, + deltas: []Delta{ + { + Type: CaveatAdded, + }, + }, + }, nil + } + + deltas := make([]Delta, 0, len(existing.ParameterTypes)+len(updated.ParameterTypes)) + + // Check the caveats's comments. + existingComments := nspkg.GetComments(existing.Metadata) + updatedComments := nspkg.GetComments(updated.Metadata) + if !slices.Equal(existingComments, updatedComments) { + deltas = append(deltas, Delta{ + Type: CaveatCommentsChanged, + }) + } + + existingParameterNames := mapz.NewSet(maps.Keys(existing.ParameterTypes)...) + updatedParameterNames := mapz.NewSet(maps.Keys(updated.ParameterTypes)...) + + for _, removed := range existingParameterNames.Subtract(updatedParameterNames).AsSlice() { + deltas = append(deltas, Delta{ + Type: RemovedParameter, + ParameterName: removed, + }) + } + + for _, added := range updatedParameterNames.Subtract(existingParameterNames).AsSlice() { + deltas = append(deltas, Delta{ + Type: AddedParameter, + ParameterName: added, + }) + } + + for _, shared := range existingParameterNames.Intersect(updatedParameterNames).AsSlice() { + existingParamType := existing.ParameterTypes[shared] + updatedParamType := updated.ParameterTypes[shared] + + existingType, err := caveattypes.DecodeParameterType(caveatTypeSet, existingParamType) + if err != nil { + return nil, err + } + + updatedType, err := caveattypes.DecodeParameterType(caveatTypeSet, updatedParamType) + if err != nil { + return nil, err + } + + // Compare types. + if existingType.String() != updatedType.String() { + deltas = append(deltas, Delta{ + Type: ParameterTypeChanged, + ParameterName: shared, + PreviousType: existingParamType, + CurrentType: updatedParamType, + }) + } + } + + if !bytes.Equal(existing.SerializedExpression, updated.SerializedExpression) { + deltas = append(deltas, Delta{ + Type: CaveatExpressionChanged, + }) + } + + return &Diff{ + existing: existing, + updated: updated, + deltas: deltas, + }, nil +} diff --git a/vendor/github.com/authzed/spicedb/pkg/diff/diff.go b/vendor/github.com/authzed/spicedb/pkg/diff/diff.go new file mode 100644 index 0000000..34aa927 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/diff/diff.go @@ -0,0 +1,170 @@ +package diff + +import ( + caveattypes "github.com/authzed/spicedb/pkg/caveats/types" + "github.com/authzed/spicedb/pkg/diff/caveats" + "github.com/authzed/spicedb/pkg/diff/namespace" + "github.com/authzed/spicedb/pkg/genutil/mapz" + core "github.com/authzed/spicedb/pkg/proto/core/v1" + "github.com/authzed/spicedb/pkg/schemadsl/compiler" +) + +// DiffableSchema is a schema that can be diffed. +type DiffableSchema struct { + // ObjectDefinitions holds the object definitions in the schema. + ObjectDefinitions []*core.NamespaceDefinition + + // CaveatDefinitions holds the caveat definitions in the schema. + CaveatDefinitions []*core.CaveatDefinition +} + +func (ds *DiffableSchema) GetNamespace(namespaceName string) (*core.NamespaceDefinition, bool) { + for _, ns := range ds.ObjectDefinitions { + if ns.Name == namespaceName { + return ns, true + } + } + + return nil, false +} + +func (ds *DiffableSchema) GetRelation(nsName string, relationName string) (*core.Relation, bool) { + ns, ok := ds.GetNamespace(nsName) + if !ok { + return nil, false + } + + for _, relation := range ns.Relation { + if relation.Name == relationName { + return relation, true + } + } + + return nil, false +} + +func (ds *DiffableSchema) GetCaveat(caveatName string) (*core.CaveatDefinition, bool) { + for _, caveat := range ds.CaveatDefinitions { + if caveat.Name == caveatName { + return caveat, true + } + } + + return nil, false +} + +// NewDiffableSchemaFromCompiledSchema creates a new DiffableSchema from a CompiledSchema. +func NewDiffableSchemaFromCompiledSchema(compiled *compiler.CompiledSchema) DiffableSchema { + return DiffableSchema{ + ObjectDefinitions: compiled.ObjectDefinitions, + CaveatDefinitions: compiled.CaveatDefinitions, + } +} + +// SchemaDiff holds the diff between two schemas. +type SchemaDiff struct { + // AddedNamespaces are the namespaces that were added. + AddedNamespaces []string + + // RemovedNamespaces are the namespaces that were removed. + RemovedNamespaces []string + + // AddedCaveats are the caveats that were added. + AddedCaveats []string + + // RemovedCaveats are the caveats that were removed. + RemovedCaveats []string + + // ChangedNamespaces are the namespaces that were changed. + ChangedNamespaces map[string]namespace.Diff + + // ChangedCaveats are the caveats that were changed. + ChangedCaveats map[string]caveats.Diff +} + +// DiffSchemas compares two schemas and returns the diff. +func DiffSchemas(existing DiffableSchema, comparison DiffableSchema, caveatTypeSet *caveattypes.TypeSet) (*SchemaDiff, error) { + existingNamespacesByName := make(map[string]*core.NamespaceDefinition, len(existing.ObjectDefinitions)) + existingNamespaceNames := mapz.NewSet[string]() + for _, nsDef := range existing.ObjectDefinitions { + existingNamespacesByName[nsDef.Name] = nsDef + existingNamespaceNames.Add(nsDef.Name) + } + + existingCaveatsByName := make(map[string]*core.CaveatDefinition, len(existing.CaveatDefinitions)) + existingCaveatsByNames := mapz.NewSet[string]() + for _, caveatDef := range existing.CaveatDefinitions { + existingCaveatsByName[caveatDef.Name] = caveatDef + existingCaveatsByNames.Add(caveatDef.Name) + } + + comparisonNamespacesByName := make(map[string]*core.NamespaceDefinition, len(comparison.ObjectDefinitions)) + comparisonNamespaceNames := mapz.NewSet[string]() + for _, nsDef := range comparison.ObjectDefinitions { + comparisonNamespacesByName[nsDef.Name] = nsDef + comparisonNamespaceNames.Add(nsDef.Name) + } + + comparisonCaveatsByName := make(map[string]*core.CaveatDefinition, len(comparison.CaveatDefinitions)) + comparisonCaveatsByNames := mapz.NewSet[string]() + for _, caveatDef := range comparison.CaveatDefinitions { + comparisonCaveatsByName[caveatDef.Name] = caveatDef + comparisonCaveatsByNames.Add(caveatDef.Name) + } + + changedNamespaces := make(map[string]namespace.Diff, 0) + commonNamespaceNames := existingNamespaceNames.Intersect(comparisonNamespaceNames) + if err := commonNamespaceNames.ForEach(func(name string) error { + existingNamespace := existingNamespacesByName[name] + comparisonNamespace := comparisonNamespacesByName[name] + + diff, err := namespace.DiffNamespaces(existingNamespace, comparisonNamespace) + if err != nil { + return err + } + + if len(diff.Deltas()) > 0 { + changedNamespaces[name] = *diff + } + + return nil + }); err != nil { + return nil, err + } + + commonCaveatNames := existingCaveatsByNames.Intersect(comparisonCaveatsByNames) + changedCaveats := make(map[string]caveats.Diff, 0) + if err := commonCaveatNames.ForEach(func(name string) error { + existingCaveat := existingCaveatsByName[name] + comparisonCaveat := comparisonCaveatsByName[name] + + diff, err := caveats.DiffCaveats(existingCaveat, comparisonCaveat, caveatTypeSet) + if err != nil { + return err + } + + if len(diff.Deltas()) > 0 { + changedCaveats[name] = *diff + } + + return nil + }); err != nil { + return nil, err + } + + if len(changedNamespaces) == 0 { + changedNamespaces = nil + } + if len(changedCaveats) == 0 { + changedCaveats = nil + } + + return &SchemaDiff{ + AddedNamespaces: comparisonNamespaceNames.Subtract(existingNamespaceNames).AsSlice(), + RemovedNamespaces: existingNamespaceNames.Subtract(comparisonNamespaceNames).AsSlice(), + AddedCaveats: comparisonCaveatsByNames.Subtract(existingCaveatsByNames).AsSlice(), + RemovedCaveats: existingCaveatsByNames.Subtract(comparisonCaveatsByNames).AsSlice(), + ChangedNamespaces: changedNamespaces, + ChangedCaveats: changedCaveats, + }, nil +} diff --git a/vendor/github.com/authzed/spicedb/pkg/diff/doc.go b/vendor/github.com/authzed/spicedb/pkg/diff/doc.go new file mode 100644 index 0000000..ff3e1d0 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/diff/doc.go @@ -0,0 +1,2 @@ +// Package diff contains code for things that can be diffed (e.g. namespaces and caveats). +package diff diff --git a/vendor/github.com/authzed/spicedb/pkg/diff/namespace/diff.go b/vendor/github.com/authzed/spicedb/pkg/diff/namespace/diff.go new file mode 100644 index 0000000..af50f0f --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/diff/namespace/diff.go @@ -0,0 +1,321 @@ +package namespace + +import ( + "github.com/google/go-cmp/cmp" + "golang.org/x/exp/slices" + "google.golang.org/protobuf/testing/protocmp" + + nsinternal "github.com/authzed/spicedb/internal/namespace" + "github.com/authzed/spicedb/pkg/genutil/mapz" + nspkg "github.com/authzed/spicedb/pkg/namespace" + core "github.com/authzed/spicedb/pkg/proto/core/v1" + iv1 "github.com/authzed/spicedb/pkg/proto/impl/v1" + "github.com/authzed/spicedb/pkg/schema" +) + +// DeltaType defines the type of namespace deltas. +type DeltaType string + +const ( + // NamespaceAdded indicates that the namespace was newly added/created. + NamespaceAdded DeltaType = "namespace-added" + + // NamespaceRemoved indicates that the namespace was removed. + NamespaceRemoved DeltaType = "namespace-removed" + + // NamespaceCommentsChanged indicates that the comment(s) on the namespace were changed. + NamespaceCommentsChanged DeltaType = "namespace-comments-changed" + + // AddedRelation indicates that the relation was added to the namespace. + AddedRelation DeltaType = "added-relation" + + // RemovedRelation indicates that the relation was removed from the namespace. + RemovedRelation DeltaType = "removed-relation" + + // AddedPermission indicates that the permission was added to the namespace. + AddedPermission DeltaType = "added-permission" + + // RemovedPermission indicates that the permission was removed from the namespace. + RemovedPermission DeltaType = "removed-permission" + + // ChangedPermissionImpl indicates that the implementation of the permission has changed in some + // way. + ChangedPermissionImpl DeltaType = "changed-permission-implementation" + + // ChangedPermissionComment indicates that the comment of the permission has changed in some way. + ChangedPermissionComment DeltaType = "changed-permission-comment" + + // LegacyChangedRelationImpl indicates that the implementation of the relation has changed in some + // way. This is for legacy checks and should not apply to any modern namespaces created + // via schema. + LegacyChangedRelationImpl DeltaType = "legacy-changed-relation-implementation" + + // RelationAllowedTypeAdded indicates that an allowed relation type has been added to + // the relation. + RelationAllowedTypeAdded DeltaType = "relation-allowed-type-added" + + // RelationAllowedTypeRemoved indicates that an allowed relation type has been removed from + // the relation. + RelationAllowedTypeRemoved DeltaType = "relation-allowed-type-removed" + + // ChangedRelationComment indicates that the comment of the relation has changed in some way. + ChangedRelationComment DeltaType = "changed-relation-comment" +) + +// Diff holds the diff between two namespaces. +type Diff struct { + existing *core.NamespaceDefinition + updated *core.NamespaceDefinition + deltas []Delta +} + +// Deltas returns the deltas between the two namespaces. +func (nd Diff) Deltas() []Delta { + return nd.deltas +} + +// Delta holds a single change of a namespace. +type Delta struct { + // Type is the type of this delta. + Type DeltaType + + // RelationName is the name of the relation to which this delta applies, if any. + RelationName string + + // AllowedType is the allowed relation type added or removed, if any. + AllowedType *core.AllowedRelation +} + +// DiffNamespaces performs a diff between two namespace definitions. One or both of the definitions +// can be `nil`, which will be treated as an add/remove as applicable. +func DiffNamespaces(existing *core.NamespaceDefinition, updated *core.NamespaceDefinition) (*Diff, error) { + // Check for the namespaces themselves. + if existing == nil && updated == nil { + return &Diff{existing, updated, []Delta{}}, nil + } + + if existing != nil && updated == nil { + return &Diff{ + existing: existing, + updated: updated, + deltas: []Delta{ + { + Type: NamespaceRemoved, + }, + }, + }, nil + } + + if existing == nil && updated != nil { + return &Diff{ + existing: existing, + updated: updated, + deltas: []Delta{ + { + Type: NamespaceAdded, + }, + }, + }, nil + } + + deltas := []Delta{} + + // Check the namespace's comments. + existingComments := nspkg.GetComments(existing.Metadata) + updatedComments := nspkg.GetComments(updated.Metadata) + if !slices.Equal(existingComments, updatedComments) { + deltas = append(deltas, Delta{ + Type: NamespaceCommentsChanged, + }) + } + + // Collect up relations and check. + existingRels := map[string]*core.Relation{} + existingRelNames := mapz.NewSet[string]() + + existingPerms := map[string]*core.Relation{} + existingPermNames := mapz.NewSet[string]() + + updatedRels := map[string]*core.Relation{} + updatedRelNames := mapz.NewSet[string]() + + updatedPerms := map[string]*core.Relation{} + updatedPermNames := mapz.NewSet[string]() + + for _, relation := range existing.Relation { + _, ok := existingRels[relation.Name] + if ok { + return nil, nsinternal.NewDuplicateRelationError(existing.Name, relation.Name) + } + + if isPermission(relation) { + existingPerms[relation.Name] = relation + existingPermNames.Add(relation.Name) + } else { + existingRels[relation.Name] = relation + existingRelNames.Add(relation.Name) + } + } + + for _, relation := range updated.Relation { + _, ok := updatedRels[relation.Name] + if ok { + return nil, nsinternal.NewDuplicateRelationError(updated.Name, relation.Name) + } + + if isPermission(relation) { + updatedPerms[relation.Name] = relation + updatedPermNames.Add(relation.Name) + } else { + updatedRels[relation.Name] = relation + updatedRelNames.Add(relation.Name) + } + } + + _ = existingRelNames.Subtract(updatedRelNames).ForEach(func(removed string) error { + deltas = append(deltas, Delta{ + Type: RemovedRelation, + RelationName: removed, + }) + return nil + }) + + _ = updatedRelNames.Subtract(existingRelNames).ForEach(func(added string) error { + deltas = append(deltas, Delta{ + Type: AddedRelation, + RelationName: added, + }) + return nil + }) + + _ = existingPermNames.Subtract(updatedPermNames).ForEach(func(removed string) error { + deltas = append(deltas, Delta{ + Type: RemovedPermission, + RelationName: removed, + }) + return nil + }) + + _ = updatedPermNames.Subtract(existingPermNames).ForEach(func(added string) error { + deltas = append(deltas, Delta{ + Type: AddedPermission, + RelationName: added, + }) + return nil + }) + + _ = existingPermNames.Intersect(updatedPermNames).ForEach(func(shared string) error { + existingPerm := existingPerms[shared] + updatedPerm := updatedPerms[shared] + + // Compare implementations. + if areDifferentExpressions(existingPerm.UsersetRewrite, updatedPerm.UsersetRewrite) { + deltas = append(deltas, Delta{ + Type: ChangedPermissionImpl, + RelationName: shared, + }) + } + + // Compare comments. + existingComments := nspkg.GetComments(existingPerm.Metadata) + updatedComments := nspkg.GetComments(updatedPerm.Metadata) + if !slices.Equal(existingComments, updatedComments) { + deltas = append(deltas, Delta{ + Type: ChangedPermissionComment, + RelationName: shared, + }) + } + return nil + }) + + _ = existingRelNames.Intersect(updatedRelNames).ForEach(func(shared string) error { + existingRel := existingRels[shared] + updatedRel := updatedRels[shared] + + // Compare implementations (legacy). + if areDifferentExpressions(existingRel.UsersetRewrite, updatedRel.UsersetRewrite) { + deltas = append(deltas, Delta{ + Type: LegacyChangedRelationImpl, + RelationName: shared, + }) + } + + // Compare comments. + existingComments := nspkg.GetComments(existingRel.Metadata) + updatedComments := nspkg.GetComments(updatedRel.Metadata) + if !slices.Equal(existingComments, updatedComments) { + deltas = append(deltas, Delta{ + Type: ChangedRelationComment, + RelationName: shared, + }) + } + + // Compare type information. + existingTypeInfo := existingRel.TypeInformation + if existingTypeInfo == nil { + existingTypeInfo = &core.TypeInformation{} + } + + updatedTypeInfo := updatedRel.TypeInformation + if updatedTypeInfo == nil { + updatedTypeInfo = &core.TypeInformation{} + } + + existingAllowedRels := mapz.NewSet[string]() + updatedAllowedRels := mapz.NewSet[string]() + allowedRelsBySource := map[string]*core.AllowedRelation{} + + for _, existingAllowed := range existingTypeInfo.AllowedDirectRelations { + source := schema.SourceForAllowedRelation(existingAllowed) + allowedRelsBySource[source] = existingAllowed + existingAllowedRels.Add(source) + } + + for _, updatedAllowed := range updatedTypeInfo.AllowedDirectRelations { + source := schema.SourceForAllowedRelation(updatedAllowed) + allowedRelsBySource[source] = updatedAllowed + updatedAllowedRels.Add(source) + } + + _ = existingAllowedRels.Subtract(updatedAllowedRels).ForEach(func(removed string) error { + deltas = append(deltas, Delta{ + Type: RelationAllowedTypeRemoved, + RelationName: shared, + AllowedType: allowedRelsBySource[removed], + }) + return nil + }) + + _ = updatedAllowedRels.Subtract(existingAllowedRels).ForEach(func(added string) error { + deltas = append(deltas, Delta{ + Type: RelationAllowedTypeAdded, + RelationName: shared, + AllowedType: allowedRelsBySource[added], + }) + return nil + }) + + return nil + }) + + return &Diff{ + existing: existing, + updated: updated, + deltas: deltas, + }, nil +} + +func isPermission(relation *core.Relation) bool { + return nspkg.GetRelationKind(relation) == iv1.RelationMetadata_PERMISSION +} + +func areDifferentExpressions(existing *core.UsersetRewrite, updated *core.UsersetRewrite) bool { + // Return whether the rewrites are different, ignoring the SourcePosition message type. + delta := cmp.Diff( + existing, + updated, + protocmp.Transform(), + protocmp.IgnoreMessages(&core.SourcePosition{}), + ) + return delta != "" +} diff --git a/vendor/github.com/authzed/spicedb/pkg/diff/namespace/diffexpr.go b/vendor/github.com/authzed/spicedb/pkg/diff/namespace/diffexpr.go new file mode 100644 index 0000000..359728c --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/diff/namespace/diffexpr.go @@ -0,0 +1,386 @@ +package namespace + +import ( + core "github.com/authzed/spicedb/pkg/proto/core/v1" + "github.com/authzed/spicedb/pkg/spiceerrors" +) + +// ExpressionChangeType defines the type of expression changes. +type ExpressionChangeType string + +const ( + // ExpressionUnchanged indicates that the expression was unchanged. + ExpressionUnchanged ExpressionChangeType = "expression-unchanged" + + // ExpressionOperationChanged indicates that the operation type of the expression was changed. + ExpressionOperationChanged ExpressionChangeType = "operation-changed" + + // ExpressionChildrenChanged indicates that the children of the expression were changed. + ExpressionChildrenChanged ExpressionChangeType = "children-changed" + + // ExpressionOperationExpanded indicates that the operation type of the expression was expanded + // from a union of a single child to multiple children under a union, intersection or another + // operation. + ExpressionOperationExpanded ExpressionChangeType = "operation-expanded" +) + +// ExpressionDiff holds the diff between two expressions. +type ExpressionDiff struct { + existing *core.UsersetRewrite + updated *core.UsersetRewrite + change ExpressionChangeType + + childDiffs []*OperationDiff +} + +// Existing returns the existing expression, if any. +func (ed *ExpressionDiff) Existing() *core.UsersetRewrite { + return ed.existing +} + +// Updated returns the updated expression, if any. +func (ed *ExpressionDiff) Updated() *core.UsersetRewrite { + return ed.updated +} + +// Change returns the type of change that occurred. +func (ed *ExpressionDiff) Change() ExpressionChangeType { + return ed.change +} + +// ChildDiffs returns the child diffs, if any. +func (ed *ExpressionDiff) ChildDiffs() []*OperationDiff { + return ed.childDiffs +} + +// SetOperationChangeType defines the type of set operation changes. +type SetOperationChangeType string + +const ( + // OperationUnchanged indicates that the set operation was unchanged. + OperationUnchanged SetOperationChangeType = "operation-changed" + + // OperationAdded indicates that a set operation was added. + OperationAdded SetOperationChangeType = "operation-added" + + // OperationRemoved indicates that a set operation was removed. + OperationRemoved SetOperationChangeType = "operation-removed" + + // OperationTypeChanged indicates that the type of set operation was changed. + OperationTypeChanged SetOperationChangeType = "operation-type-changed" + + // OperationComputedUsersetChanged indicates that the computed userset of the operation was changed. + OperationComputedUsersetChanged SetOperationChangeType = "operation-computed-userset-changed" + + // OperationTuplesetChanged indicates that the tupleset of the operation was changed. + OperationTuplesetChanged SetOperationChangeType = "operation-tupleset-changed" + + // OperationChildExpressionChanged indicates that the child expression of the operation was changed. + OperationChildExpressionChanged SetOperationChangeType = "operation-child-expression-changed" +) + +// OperationDiff holds the diff between two set operations. +type OperationDiff struct { + existing *core.SetOperation_Child + updated *core.SetOperation_Child + change SetOperationChangeType + childExprDiff *ExpressionDiff +} + +// Existing returns the existing set operation, if any. +func (od *OperationDiff) Existing() *core.SetOperation_Child { + return od.existing +} + +// Updated returns the updated set operation, if any. +func (od *OperationDiff) Updated() *core.SetOperation_Child { + return od.updated +} + +// Change returns the type of change that occurred. +func (od *OperationDiff) Change() SetOperationChangeType { + return od.change +} + +// ChildExpressionDiff returns the child expression diff, if any. +func (od *OperationDiff) ChildExpressionDiff() *ExpressionDiff { + return od.childExprDiff +} + +// DiffExpressions diffs two expressions. +func DiffExpressions(existing *core.UsersetRewrite, updated *core.UsersetRewrite) (*ExpressionDiff, error) { + // Check for a difference in the operation type. + var existingType string + var existingOperation *core.SetOperation + var updatedType string + var updatedOperation *core.SetOperation + + switch t := existing.RewriteOperation.(type) { + case *core.UsersetRewrite_Union: + existingType = "union" + existingOperation = t.Union + + case *core.UsersetRewrite_Intersection: + existingType = "intersection" + existingOperation = t.Intersection + + case *core.UsersetRewrite_Exclusion: + existingType = "exclusion" + existingOperation = t.Exclusion + + default: + return nil, spiceerrors.MustBugf("unknown operation type %T", existing.RewriteOperation) + } + + switch t := updated.RewriteOperation.(type) { + case *core.UsersetRewrite_Union: + updatedType = "union" + updatedOperation = t.Union + + case *core.UsersetRewrite_Intersection: + updatedType = "intersection" + updatedOperation = t.Intersection + + case *core.UsersetRewrite_Exclusion: + updatedType = "exclusion" + updatedOperation = t.Exclusion + + default: + return nil, spiceerrors.MustBugf("unknown operation type %T", updated.RewriteOperation) + } + + childChangeKind := ExpressionChildrenChanged + if existingType != updatedType { + // If the expression has changed from a union with a single child, then + // treat this as a special case, since there wasn't really an operation + // before. + if existingType != "union" || len(existingOperation.Child) != 1 { + return &ExpressionDiff{ + existing: existing, + updated: updated, + change: ExpressionOperationChanged, + }, nil + } + + childChangeKind = ExpressionOperationExpanded + } + + childDiffs := make([]*OperationDiff, 0, abs(len(updatedOperation.Child)-len(existingOperation.Child))) + if len(existingOperation.Child) < len(updatedOperation.Child) { + for _, updatedChild := range updatedOperation.Child[len(existingOperation.Child):] { + childDiffs = append(childDiffs, &OperationDiff{ + change: OperationAdded, + updated: updatedChild, + }) + } + } + + if len(existingOperation.Child) > len(updatedOperation.Child) { + for _, existingChild := range existingOperation.Child[len(updatedOperation.Child):] { + childDiffs = append(childDiffs, &OperationDiff{ + change: OperationRemoved, + existing: existingChild, + }) + } + } + + for i := 0; i < len(existingOperation.Child) && i < len(updatedOperation.Child); i++ { + childDiff, err := compareChildren(existingOperation.Child[i], updatedOperation.Child[i]) + if err != nil { + return nil, err + } + + if childDiff.change != OperationUnchanged { + childDiffs = append(childDiffs, childDiff) + } + } + + if len(childDiffs) > 0 { + return &ExpressionDiff{ + existing: existing, + updated: updated, + change: childChangeKind, + childDiffs: childDiffs, + }, nil + } + + return &ExpressionDiff{ + existing: existing, + updated: updated, + change: ExpressionUnchanged, + }, nil +} + +func abs(i int) int { + if i < 0 { + return -i + } + return i +} + +func compareChildren(existing *core.SetOperation_Child, updated *core.SetOperation_Child) (*OperationDiff, error) { + existingType, err := typeOfSetOperationChild(existing) + if err != nil { + return nil, err + } + + updatedType, err := typeOfSetOperationChild(updated) + if err != nil { + return nil, err + } + + if existingType != updatedType { + return &OperationDiff{ + existing: existing, + updated: updated, + change: OperationTypeChanged, + }, nil + } + + switch existingType { + case "usersetrewrite": + childDiff, err := DiffExpressions(existing.GetUsersetRewrite(), updated.GetUsersetRewrite()) + if err != nil { + return nil, err + } + + if childDiff.change != ExpressionUnchanged { + return &OperationDiff{ + existing: existing, + updated: updated, + change: OperationChildExpressionChanged, + childExprDiff: childDiff, + }, nil + } + + return &OperationDiff{ + existing: existing, + updated: updated, + change: OperationUnchanged, + }, nil + + case "computed": + if existing.GetComputedUserset().Relation != updated.GetComputedUserset().Relation { + return &OperationDiff{ + existing: existing, + updated: updated, + change: OperationComputedUsersetChanged, + }, nil + } + + return &OperationDiff{ + existing: existing, + updated: updated, + change: OperationUnchanged, + }, nil + + case "_this": + return &OperationDiff{ + existing: existing, + updated: updated, + change: OperationUnchanged, + }, nil + + case "nil": + return &OperationDiff{ + existing: existing, + updated: updated, + change: OperationUnchanged, + }, nil + + case "ttu": + existingTTU := existing.GetTupleToUserset() + updatedTTU := updated.GetTupleToUserset() + + if existingTTU.GetComputedUserset().Relation != updatedTTU.GetComputedUserset().Relation { + return &OperationDiff{ + existing: existing, + updated: updated, + change: OperationComputedUsersetChanged, + }, nil + } + + if existingTTU.Tupleset.Relation != updatedTTU.Tupleset.Relation { + return &OperationDiff{ + existing: existing, + updated: updated, + change: OperationTuplesetChanged, + }, nil + } + + return &OperationDiff{ + existing: existing, + updated: updated, + change: OperationUnchanged, + }, nil + + case "anyttu": + fallthrough + + case "intersectionttu": + existingTTU := existing.GetFunctionedTupleToUserset() + updatedTTU := updated.GetFunctionedTupleToUserset() + + if existingTTU.GetComputedUserset().Relation != updatedTTU.GetComputedUserset().Relation { + return &OperationDiff{ + existing: existing, + updated: updated, + change: OperationComputedUsersetChanged, + }, nil + } + + if existingTTU.Tupleset.Relation != updatedTTU.Tupleset.Relation { + return &OperationDiff{ + existing: existing, + updated: updated, + change: OperationTuplesetChanged, + }, nil + } + + return &OperationDiff{ + existing: existing, + updated: updated, + change: OperationUnchanged, + }, nil + + default: + return nil, spiceerrors.MustBugf("unknown child type %s", existingType) + } +} + +func typeOfSetOperationChild(child *core.SetOperation_Child) (string, error) { + switch t := child.ChildType.(type) { + case *core.SetOperation_Child_XThis: + return "_this", nil + + case *core.SetOperation_Child_ComputedUserset: + return "computed", nil + + case *core.SetOperation_Child_UsersetRewrite: + return "usersetrewrite", nil + + case *core.SetOperation_Child_TupleToUserset: + return "ttu", nil + + case *core.SetOperation_Child_FunctionedTupleToUserset: + switch t.FunctionedTupleToUserset.Function { + case core.FunctionedTupleToUserset_FUNCTION_UNSPECIFIED: + return "", spiceerrors.MustBugf("function type unspecified") + + case core.FunctionedTupleToUserset_FUNCTION_ANY: + return "anyttu", nil + + case core.FunctionedTupleToUserset_FUNCTION_ALL: + return "intersectionttu", nil + + default: + return "", spiceerrors.MustBugf("unknown function type %v", t.FunctionedTupleToUserset.Function) + } + + case *core.SetOperation_Child_XNil: + return "nil", nil + + default: + return "", spiceerrors.MustBugf("unknown child type %T", t) + } +} diff --git a/vendor/github.com/authzed/spicedb/pkg/genutil/doc.go b/vendor/github.com/authzed/spicedb/pkg/genutil/doc.go new file mode 100644 index 0000000..eb91f91 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/genutil/doc.go @@ -0,0 +1,2 @@ +// Package genutil contains helper functions to deal with generic data (e.g. maps and sets). +package genutil diff --git a/vendor/github.com/authzed/spicedb/pkg/genutil/ensure.go b/vendor/github.com/authzed/spicedb/pkg/genutil/ensure.go new file mode 100644 index 0000000..56467ba --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/genutil/ensure.go @@ -0,0 +1,34 @@ +package genutil + +import ( + "github.com/ccoveille/go-safecast" + + "github.com/authzed/spicedb/pkg/spiceerrors" +) + +// MustEnsureUInt32 is a helper function that calls EnsureUInt32 and panics on error. +func MustEnsureUInt32(value int) uint32 { + ret, err := EnsureUInt32(value) + if err != nil { + panic(err) + } + return ret +} + +// EnsureUInt32 ensures that the specified value can be represented as a uint32. +func EnsureUInt32(value int) (uint32, error) { + uint32Value, err := safecast.ToUint32(value) + if err != nil { + return 0, spiceerrors.MustBugf("specified value could not be cast to a uint32") + } + return uint32Value, nil +} + +// EnsureUInt8 ensures that the specified value can be represented as a uint8. +func EnsureUInt8(value int) (uint8, error) { + uint8Value, err := safecast.ToUint8(value) + if err != nil { + return 0, spiceerrors.MustBugf("specified value could not be cast to a uint8") + } + return uint8Value, nil +} diff --git a/vendor/github.com/authzed/spicedb/pkg/genutil/mapz/countingmap.go b/vendor/github.com/authzed/spicedb/pkg/genutil/mapz/countingmap.go new file mode 100644 index 0000000..e367fce --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/genutil/mapz/countingmap.go @@ -0,0 +1,50 @@ +package mapz + +import "sync" + +// CountingMultiMap is a multimap that counts the number of distinct values for each +// key, removing the key from the map when the count reaches zero. Safe for concurrent +// use. +type CountingMultiMap[T comparable, Q comparable] struct { + valuesByKey map[T]*Set[Q] // GUARDED_BY(lock) + lock sync.Mutex +} + +// NewCountingMultiMap constructs a new counting multimap. +func NewCountingMultiMap[T comparable, Q comparable]() *CountingMultiMap[T, Q] { + return &CountingMultiMap[T, Q]{ + valuesByKey: map[T]*Set[Q]{}, + lock: sync.Mutex{}, + } +} + +// Add adds the given value to the map at the given key. Returns true if the value +// already existed in the map for the given key. +func (cmm *CountingMultiMap[T, Q]) Add(key T, value Q) bool { + cmm.lock.Lock() + defer cmm.lock.Unlock() + + values, ok := cmm.valuesByKey[key] + if !ok { + values = NewSet[Q]() + cmm.valuesByKey[key] = values + } + return !values.Add(value) +} + +// Remove removes the given value for the given key from the map. If, after this removal, +// the key has no additional values, it is removed entirely from the map. +func (cmm *CountingMultiMap[T, Q]) Remove(key T, value Q) { + cmm.lock.Lock() + defer cmm.lock.Unlock() + + values, ok := cmm.valuesByKey[key] + if !ok { + return + } + + values.Delete(value) + if values.IsEmpty() { + delete(cmm.valuesByKey, key) + } +} diff --git a/vendor/github.com/authzed/spicedb/pkg/genutil/mapz/multimap.go b/vendor/github.com/authzed/spicedb/pkg/genutil/mapz/multimap.go new file mode 100644 index 0000000..bc85f32 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/genutil/mapz/multimap.go @@ -0,0 +1,181 @@ +package mapz + +import ( + "golang.org/x/exp/maps" +) + +// ReadOnlyMultimap is a read-only multimap. +type ReadOnlyMultimap[T comparable, Q any] interface { + // Has returns true if the key is found in the map. + Has(key T) bool + + // Get returns the values for the given key in the map and whether the key + // existed. + // If the key does not exist, an empty slice is returned. + Get(key T) ([]Q, bool) + + // IsEmpty returns true if the map is currently empty. + IsEmpty() bool + + // Len returns the length of the map, e.g. the number of *keys* present. + Len() int + + // Keys returns the keys of the map. + Keys() []T + + // Values returns all values in the map. + Values() []Q +} + +// NewMultiMap initializes a new MultiMap. +func NewMultiMap[T comparable, Q any]() *MultiMap[T, Q] { + return &MultiMap[T, Q]{items: map[T][]Q{}} +} + +// NewMultiMapWithCap initializes with the provided capacity for the top-level +// map. +func NewMultiMapWithCap[T comparable, Q any](capacity uint32) *MultiMap[T, Q] { + return &MultiMap[T, Q]{items: make(map[T][]Q, capacity)} +} + +// MultiMap represents a map that can contain 1 or more values for each key. +type MultiMap[T comparable, Q any] struct { + items map[T][]Q +} + +// Clear clears all entries in the map. +func (mm *MultiMap[T, Q]) Clear() { + mm.items = map[T][]Q{} +} + +// Add inserts the value into the map at the given key. +// +// If there exists an existing value, then this value is appended +// *without comparison*. Put another way, a value can be added twice, if this +// method is called twice for the same value. +func (mm *MultiMap[T, Q]) Add(key T, item Q) { + if _, ok := mm.items[key]; !ok { + mm.items[key] = []Q{} + } + + mm.items[key] = append(mm.items[key], item) +} + +// RemoveKey removes the given key from the map. +func (mm *MultiMap[T, Q]) RemoveKey(key T) { + delete(mm.items, key) +} + +// Has returns true if the key is found in the map. +func (mm *MultiMap[T, Q]) Has(key T) bool { + _, ok := mm.items[key] + return ok +} + +// Get returns the values stored in the map for the provided key and whether +// the key existed. +// +// If the key does not exist, an empty slice is returned. +func (mm *MultiMap[T, Q]) Get(key T) ([]Q, bool) { + found, ok := mm.items[key] + if !ok { + return []Q{}, false + } + + return found, true +} + +// Sets sets the values in the multimap to those provided. +func (mm *MultiMap[T, Q]) Set(key T, values []Q) { + mm.items[key] = values +} + +// IsEmpty returns true if the map is currently empty. +func (mm *MultiMap[T, Q]) IsEmpty() bool { return len(mm.items) == 0 } + +// Len returns the length of the map, e.g. the number of *keys* present. +func (mm *MultiMap[T, Q]) Len() int { return len(mm.items) } + +// Keys returns the keys of the map. +func (mm *MultiMap[T, Q]) Keys() []T { return maps.Keys(mm.items) } + +// Values returns all values in the map. +func (mm MultiMap[T, Q]) Values() []Q { + values := make([]Q, 0, len(mm.items)*2) + for _, valueSlice := range maps.Values(mm.items) { + values = append(values, valueSlice...) + } + return values +} + +// Clone returns a clone of the map. +func (mm *MultiMap[T, Q]) Clone() *MultiMap[T, Q] { + return &MultiMap[T, Q]{maps.Clone(mm.items)} +} + +// CountOf returns the number of values stored for the given key. +func (mm *MultiMap[T, Q]) CountOf(key T) int { + return len(mm.items[key]) +} + +// IndexOfValueInMultimap returns the index of the value in the map for the given key. +func IndexOfValueInMultimap[T comparable, Q comparable](mm *MultiMap[T, Q], key T, value Q) int { + values, ok := mm.items[key] + if !ok { + return -1 + } + + for i, v := range values { + if v == value { + return i + } + } + + return -1 +} + +// AsReadOnly returns a read-only *copy* of the mulitmap. +func (mm *MultiMap[T, Q]) AsReadOnly() ReadOnlyMultimap[T, Q] { + return readOnlyMultimap[T, Q]{ + maps.Clone(mm.items), + } +} + +type readOnlyMultimap[T comparable, Q any] struct { + items map[T][]Q +} + +// Has returns true if the key is found in the map. +func (mm readOnlyMultimap[T, Q]) Has(key T) bool { + _, ok := mm.items[key] + return ok +} + +// Get returns the values for the given key in the map and whether the key existed. If the key +// does not exist, an empty slice is returned. +func (mm readOnlyMultimap[T, Q]) Get(key T) ([]Q, bool) { + found, ok := mm.items[key] + if !ok { + return []Q{}, false + } + + return found, true +} + +// IsEmpty returns true if the map is currently empty. +func (mm readOnlyMultimap[T, Q]) IsEmpty() bool { return len(mm.items) == 0 } + +// Len returns the length of the map, e.g. the number of *keys* present. +func (mm readOnlyMultimap[T, Q]) Len() int { return len(mm.items) } + +// Keys returns the keys of the map. +func (mm readOnlyMultimap[T, Q]) Keys() []T { return maps.Keys(mm.items) } + +// Values returns all values in the map. +func (mm readOnlyMultimap[T, Q]) Values() []Q { + values := make([]Q, 0, len(mm.items)*2) + for _, valueSlice := range maps.Values(mm.items) { + values = append(values, valueSlice...) + } + return values +} diff --git a/vendor/github.com/authzed/spicedb/pkg/genutil/mapz/set.go b/vendor/github.com/authzed/spicedb/pkg/genutil/mapz/set.go new file mode 100644 index 0000000..13fb55a --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/genutil/mapz/set.go @@ -0,0 +1,163 @@ +package mapz + +import ( + "maps" + + "github.com/rs/zerolog" + + expmaps "golang.org/x/exp/maps" +) + +// Set implements a very basic generic set. +type Set[T comparable] struct { + values map[T]struct{} +} + +// NewSet returns a new set. +func NewSet[T comparable](items ...T) *Set[T] { + s := &Set[T]{ + values: map[T]struct{}{}, + } + for _, item := range items { + s.values[item] = struct{}{} + } + return s +} + +// Has returns true if the set contains the given value. +func (s *Set[T]) Has(value T) bool { + _, exists := s.values[value] + return exists +} + +// Add adds the given value to the set and returns true. If +// the value is already present, returns false. +func (s *Set[T]) Add(value T) bool { + if s.Has(value) { + return false + } + + s.values[value] = struct{}{} + return true +} + +// Insert adds the given value to the set. +func (s *Set[T]) Insert(value T) { + s.values[value] = struct{}{} +} + +// Delete removes the value from the set, returning nothing. +func (s *Set[T]) Delete(value T) { + delete(s.values, value) +} + +// Extend adds all the values to the set. +func (s *Set[T]) Extend(values []T) { + for _, value := range values { + s.values[value] = struct{}{} + } +} + +// Merge adds all the values from the other set to this set. +func (s *Set[T]) Merge(other *Set[T]) { + for value := range other.values { + s.values[value] = struct{}{} + } +} + +// Union adds all the values from the other set to this set, +// returning a new set. +func (s *Set[T]) Union(other *Set[T]) *Set[T] { + cpy := s.Copy() + for value := range other.values { + cpy.values[value] = struct{}{} + } + return cpy +} + +// IntersectionDifference removes any values from this set that +// are not shared with the other set. Returns the same set. +func (s *Set[T]) IntersectionDifference(other *Set[T]) *Set[T] { + for value := range s.values { + if !other.Has(value) { + delete(s.values, value) + } + } + return s +} + +// RemoveAll removes all values from this set found in the other set. +func (s *Set[T]) RemoveAll(other *Set[T]) { + for value := range other.values { + delete(s.values, value) + } +} + +// Subtract subtracts the other set from this set, returning a new set. +func (s *Set[T]) Subtract(other *Set[T]) *Set[T] { + cpy := s.Copy() + cpy.RemoveAll(other) + return cpy +} + +// Copy returns a copy of this set. +func (s *Set[T]) Copy() *Set[T] { + return &Set[T]{ + values: maps.Clone(s.values), + } +} + +// Intersect removes any values from this set that +// are not shared with the other set, returning a new set. +func (s *Set[T]) Intersect(other *Set[T]) *Set[T] { + cpy := s.Copy() + for value := range cpy.values { + if !other.Has(value) { + delete(cpy.values, value) + } + } + return cpy +} + +// Equal returns true if both sets have the same elements +func (s *Set[T]) Equal(other *Set[T]) bool { + return maps.Equal(s.values, other.values) +} + +// IsEmpty returns true if the set is empty. +func (s *Set[T]) IsEmpty() bool { + return len(s.values) == 0 +} + +// AsSlice returns the set as a slice of values. +func (s *Set[T]) AsSlice() []T { + if len(s.values) == 0 { + return nil + } + + return expmaps.Keys(s.values) +} + +// Len returns the length of the set. +func (s *Set[T]) Len() int { + return len(s.values) +} + +// ForEach executes the callback for each item in the set until an error is encountered. +func (s *Set[T]) ForEach(callback func(value T) error) error { + for value := range s.values { + if err := callback(value); err != nil { + return err + } + } + + return nil +} + +func (s *Set[T]) MarshalZerologObject(e *zerolog.Event) { + xs := zerolog.Arr() + for _, value := range s.values { + xs.Interface(value) + } + e.Array("values", xs) +} diff --git a/vendor/github.com/authzed/spicedb/pkg/genutil/slicez/chunking.go b/vendor/github.com/authzed/spicedb/pkg/genutil/slicez/chunking.go new file mode 100644 index 0000000..bdff41c --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/genutil/slicez/chunking.go @@ -0,0 +1,44 @@ +package slicez + +import ( + "github.com/authzed/spicedb/internal/logging" +) + +// ForEachChunk executes the given handler for each chunk of items in the slice. +func ForEachChunk[T any](data []T, chunkSize uint16, handler func(items []T)) { + _, _ = ForEachChunkUntil(data, chunkSize, func(items []T) (bool, error) { + handler(items) + return true, nil + }) +} + +func ForEachChunkUntil[T any](data []T, chunkSize uint16, handler func(items []T) (bool, error)) (bool, error) { + if chunkSize == 0 { + logging.Warn().Int("invalid-chunk-size", int(chunkSize)).Msg("ForEachChunk got an invalid chunk size; defaulting to 100") + chunkSize = 100 + } + + dataLength := uint64(len(data)) + chunkSize64 := uint64(chunkSize) + chunkCount := (dataLength / chunkSize64) + 1 + for chunkIndex := uint64(0); chunkIndex < chunkCount; chunkIndex++ { + chunkStart := chunkIndex * chunkSize64 + chunkEnd := (chunkIndex + 1) * chunkSize64 + if chunkEnd > dataLength { + chunkEnd = dataLength + } + + chunk := data[chunkStart:chunkEnd] + if len(chunk) > 0 { + ok, err := handler(chunk) + if err != nil { + return false, err + } + if !ok { + return ok, nil + } + } + } + + return true, nil +} diff --git a/vendor/github.com/authzed/spicedb/pkg/graph/doc.go b/vendor/github.com/authzed/spicedb/pkg/graph/doc.go new file mode 100644 index 0000000..d632bc5 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/graph/doc.go @@ -0,0 +1,2 @@ +// Package graph contains helper code to traverse a schema. +package graph diff --git a/vendor/github.com/authzed/spicedb/pkg/graph/tree.go b/vendor/github.com/authzed/spicedb/pkg/graph/tree.go new file mode 100644 index 0000000..f8fae34 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/graph/tree.go @@ -0,0 +1,61 @@ +package graph + +import ( + core "github.com/authzed/spicedb/pkg/proto/core/v1" + "github.com/authzed/spicedb/pkg/tuple" +) + +// Leaf constructs a RelationTupleTreeNode leaf. +func Leaf(start *tuple.ObjectAndRelation, subjects ...*core.DirectSubject) *core.RelationTupleTreeNode { + var startONR *core.ObjectAndRelation + if start != nil { + startONR = start.ToCoreONR() + } + + return &core.RelationTupleTreeNode{ + NodeType: &core.RelationTupleTreeNode_LeafNode{ + LeafNode: &core.DirectSubjects{ + Subjects: subjects, + }, + }, + Expanded: startONR, + CaveatExpression: nil, // Set by caller if necessary + } +} + +func setResult( + op core.SetOperationUserset_Operation, + start *tuple.ObjectAndRelation, + children []*core.RelationTupleTreeNode, +) *core.RelationTupleTreeNode { + var startONR *core.ObjectAndRelation + if start != nil { + startONR = start.ToCoreONR() + } + + return &core.RelationTupleTreeNode{ + NodeType: &core.RelationTupleTreeNode_IntermediateNode{ + IntermediateNode: &core.SetOperationUserset{ + Operation: op, + ChildNodes: children, + }, + }, + Expanded: startONR, + CaveatExpression: nil, // Set by caller if necessary + } +} + +// Union constructs a RelationTupleTreeNode union operation. +func Union(start *tuple.ObjectAndRelation, children ...*core.RelationTupleTreeNode) *core.RelationTupleTreeNode { + return setResult(core.SetOperationUserset_UNION, start, children) +} + +// Intersection constructs a RelationTupleTreeNode intersection operation. +func Intersection(start *tuple.ObjectAndRelation, children ...*core.RelationTupleTreeNode) *core.RelationTupleTreeNode { + return setResult(core.SetOperationUserset_INTERSECTION, start, children) +} + +// Exclusion constructs a RelationTupleTreeNode exclusion operation. +func Exclusion(start *tuple.ObjectAndRelation, children ...*core.RelationTupleTreeNode) *core.RelationTupleTreeNode { + return setResult(core.SetOperationUserset_EXCLUSION, start, children) +} diff --git a/vendor/github.com/authzed/spicedb/pkg/graph/walker.go b/vendor/github.com/authzed/spicedb/pkg/graph/walker.go new file mode 100644 index 0000000..3ae8b6b --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/graph/walker.go @@ -0,0 +1,71 @@ +package graph + +import ( + core "github.com/authzed/spicedb/pkg/proto/core/v1" + "github.com/authzed/spicedb/pkg/spiceerrors" +) + +// WalkHandler is a function invoked for each node in the rewrite tree. If it returns non-nil, +// that value is returned from the walk. Otherwise, the walk continues. +type WalkHandler func(childOneof *core.SetOperation_Child) (interface{}, error) + +// WalkRewrite walks a userset rewrite tree, invoking the handler found on each node of the tree +// until the handler returns a non-nil value, which is in turn returned from this function. Returns +// nil if no valid value was found. If the rewrite is nil, returns nil. +func WalkRewrite(rewrite *core.UsersetRewrite, handler WalkHandler) (interface{}, error) { + if rewrite == nil { + return nil, nil + } + + switch rw := rewrite.RewriteOperation.(type) { + case *core.UsersetRewrite_Union: + return walkRewriteChildren(rw.Union, handler) + case *core.UsersetRewrite_Intersection: + return walkRewriteChildren(rw.Intersection, handler) + case *core.UsersetRewrite_Exclusion: + return walkRewriteChildren(rw.Exclusion, handler) + default: + return nil, spiceerrors.MustBugf("unknown type of rewrite operation in walker: %T", rw) + } +} + +// HasThis returns true if there exists a `_this` node anywhere within the given rewrite. If +// the rewrite is nil, returns false. +func HasThis(rewrite *core.UsersetRewrite) (bool, error) { + result, err := WalkRewrite(rewrite, func(childOneof *core.SetOperation_Child) (interface{}, error) { + switch childOneof.ChildType.(type) { + case *core.SetOperation_Child_XThis: + return true, nil + default: + return nil, nil + } + }) + return result != nil && result.(bool), err +} + +func walkRewriteChildren(so *core.SetOperation, handler WalkHandler) (interface{}, error) { + for _, childOneof := range so.Child { + vle, err := handler(childOneof) + if err != nil { + return nil, err + } + + if vle != nil { + return vle, nil + } + + switch child := childOneof.ChildType.(type) { + case *core.SetOperation_Child_UsersetRewrite: + rvle, err := WalkRewrite(child.UsersetRewrite, handler) + if err != nil { + return nil, err + } + + if rvle != nil { + return rvle, nil + } + } + } + + return nil, nil +} diff --git a/vendor/github.com/authzed/spicedb/pkg/middleware/consistency/consistency.go b/vendor/github.com/authzed/spicedb/pkg/middleware/consistency/consistency.go new file mode 100644 index 0000000..8f75a19 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/middleware/consistency/consistency.go @@ -0,0 +1,280 @@ +package consistency + +import ( + "context" + "errors" + "fmt" + "strings" + + v1 "github.com/authzed/authzed-go/proto/authzed/api/v1" + "github.com/prometheus/client_golang/prometheus" + "github.com/prometheus/client_golang/prometheus/promauto" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + + log "github.com/authzed/spicedb/internal/logging" + datastoremw "github.com/authzed/spicedb/internal/middleware/datastore" + "github.com/authzed/spicedb/internal/services/shared" + "github.com/authzed/spicedb/pkg/cursor" + "github.com/authzed/spicedb/pkg/datastore" + "github.com/authzed/spicedb/pkg/zedtoken" +) + +var ConsistencyCounter = promauto.NewCounterVec(prometheus.CounterOpts{ + Namespace: "spicedb", + Subsystem: "middleware", + Name: "consistency_assigned_total", + Help: "Count of the consistencies used per request", +}, []string{"method", "source", "service"}) + +type hasConsistency interface{ GetConsistency() *v1.Consistency } + +type hasOptionalCursor interface{ GetOptionalCursor() *v1.Cursor } + +type ctxKeyType struct{} + +var revisionKey ctxKeyType = struct{}{} + +var errInvalidZedToken = errors.New("invalid revision requested") + +type revisionHandle struct { + revision datastore.Revision +} + +// ContextWithHandle adds a placeholder to a context that will later be +// filled by the revision +func ContextWithHandle(ctx context.Context) context.Context { + return context.WithValue(ctx, revisionKey, &revisionHandle{}) +} + +// RevisionFromContext reads the selected revision out of a context.Context, computes a zedtoken +// from it, and returns an error if it has not been set on the context. +func RevisionFromContext(ctx context.Context) (datastore.Revision, *v1.ZedToken, error) { + if c := ctx.Value(revisionKey); c != nil { + handle := c.(*revisionHandle) + rev := handle.revision + if rev != nil { + return rev, zedtoken.MustNewFromRevision(rev), nil + } + } + + return nil, nil, fmt.Errorf("consistency middleware did not inject revision") +} + +// AddRevisionToContext adds a revision to the given context, based on the consistency block found +// in the given request (if applicable). +func AddRevisionToContext(ctx context.Context, req interface{}, ds datastore.Datastore, serviceLabel string) error { + switch req := req.(type) { + case hasConsistency: + return addRevisionToContextFromConsistency(ctx, req, ds, serviceLabel) + default: + return nil + } +} + +// addRevisionToContextFromConsistency adds a revision to the given context, based on the consistency block found +// in the given request (if applicable). +func addRevisionToContextFromConsistency(ctx context.Context, req hasConsistency, ds datastore.Datastore, serviceLabel string) error { + handle := ctx.Value(revisionKey) + if handle == nil { + return nil + } + + var revision datastore.Revision + consistency := req.GetConsistency() + + withOptionalCursor, hasOptionalCursor := req.(hasOptionalCursor) + + switch { + case hasOptionalCursor && withOptionalCursor.GetOptionalCursor() != nil: + // Always use the revision encoded in the cursor. + if serviceLabel != "" { + ConsistencyCounter.WithLabelValues("snapshot", "cursor", serviceLabel).Inc() + } + + requestedRev, err := cursor.DecodeToDispatchRevision(withOptionalCursor.GetOptionalCursor(), ds) + if err != nil { + return rewriteDatastoreError(ctx, err) + } + + err = ds.CheckRevision(ctx, requestedRev) + if err != nil { + return rewriteDatastoreError(ctx, err) + } + + revision = requestedRev + + case consistency == nil || consistency.GetMinimizeLatency(): + // Minimize Latency: Use the datastore's current revision, whatever it may be. + source := "request" + if consistency == nil { + source = "server" + } + + if serviceLabel != "" { + ConsistencyCounter.WithLabelValues("minlatency", source, serviceLabel).Inc() + } + + databaseRev, err := ds.OptimizedRevision(ctx) + if err != nil { + return rewriteDatastoreError(ctx, err) + } + revision = databaseRev + + case consistency.GetFullyConsistent(): + // Fully Consistent: Use the datastore's synchronized revision. + if serviceLabel != "" { + ConsistencyCounter.WithLabelValues("full", "request", serviceLabel).Inc() + } + + databaseRev, err := ds.HeadRevision(ctx) + if err != nil { + return rewriteDatastoreError(ctx, err) + } + revision = databaseRev + + case consistency.GetAtLeastAsFresh() != nil: + // At least as fresh as: Pick one of the datastore's revision and that specified, which + // ever is later. + picked, pickedRequest, err := pickBestRevision(ctx, consistency.GetAtLeastAsFresh(), ds) + if err != nil { + return rewriteDatastoreError(ctx, err) + } + + source := "server" + if pickedRequest { + source = "request" + } + + if serviceLabel != "" { + ConsistencyCounter.WithLabelValues("atleast", source, serviceLabel).Inc() + } + + revision = picked + + case consistency.GetAtExactSnapshot() != nil: + // Exact snapshot: Use the revision as encoded in the zed token. + if serviceLabel != "" { + ConsistencyCounter.WithLabelValues("snapshot", "request", serviceLabel).Inc() + } + + requestedRev, err := zedtoken.DecodeRevision(consistency.GetAtExactSnapshot(), ds) + if err != nil { + return errInvalidZedToken + } + + err = ds.CheckRevision(ctx, requestedRev) + if err != nil { + return rewriteDatastoreError(ctx, err) + } + + revision = requestedRev + + default: + return fmt.Errorf("missing handling of consistency case in %v", consistency) + } + + handle.(*revisionHandle).revision = revision + return nil +} + +var bypassServiceWhitelist = map[string]struct{}{ + "/grpc.reflection.v1alpha.ServerReflection/": {}, + "/grpc.reflection.v1.ServerReflection/": {}, + "/grpc.health.v1.Health/": {}, +} + +// UnaryServerInterceptor returns a new unary server interceptor that performs per-request exchange of +// the specified consistency configuration for the revision at which to perform the request. +func UnaryServerInterceptor(serviceLabel string) grpc.UnaryServerInterceptor { + return func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) { + for bypass := range bypassServiceWhitelist { + if strings.HasPrefix(info.FullMethod, bypass) { + return handler(ctx, req) + } + } + ds := datastoremw.MustFromContext(ctx) + newCtx := ContextWithHandle(ctx) + if err := AddRevisionToContext(newCtx, req, ds, serviceLabel); err != nil { + return nil, err + } + + return handler(newCtx, req) + } +} + +// StreamServerInterceptor returns a new stream server interceptor that performs per-request exchange of +// the specified consistency configuration for the revision at which to perform the request. +func StreamServerInterceptor(serviceLabel string) grpc.StreamServerInterceptor { + return func(srv interface{}, stream grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error { + for bypass := range bypassServiceWhitelist { + if strings.HasPrefix(info.FullMethod, bypass) { + return handler(srv, stream) + } + } + wrapper := &recvWrapper{stream, ContextWithHandle(stream.Context()), serviceLabel, AddRevisionToContext} + return handler(srv, wrapper) + } +} + +type recvWrapper struct { + grpc.ServerStream + ctx context.Context + serviceLabel string + handler func(ctx context.Context, req interface{}, ds datastore.Datastore, serviceLabel string) error +} + +func (s *recvWrapper) Context() context.Context { return s.ctx } + +func (s *recvWrapper) RecvMsg(m interface{}) error { + if err := s.ServerStream.RecvMsg(m); err != nil { + return err + } + ds := datastoremw.MustFromContext(s.ctx) + return s.handler(s.ctx, m, ds, s.serviceLabel) +} + +// pickBestRevision compares the provided ZedToken with the optimized revision of the datastore, and returns the most +// recent one. The boolean return value will be true if the provided ZedToken is the most recent, false otherwise. +func pickBestRevision(ctx context.Context, requested *v1.ZedToken, ds datastore.Datastore) (datastore.Revision, bool, error) { + // Calculate a revision as we see fit + databaseRev, err := ds.OptimizedRevision(ctx) + if err != nil { + return datastore.NoRevision, false, err + } + + if requested != nil { + requestedRev, err := zedtoken.DecodeRevision(requested, ds) + if err != nil { + return datastore.NoRevision, false, errInvalidZedToken + } + + if databaseRev.GreaterThan(requestedRev) { + return databaseRev, false, nil + } + + return requestedRev, true, nil + } + + return databaseRev, false, nil +} + +func rewriteDatastoreError(ctx context.Context, err error) error { + // Check if the error can be directly used. + if _, ok := status.FromError(err); ok { + return err + } + + switch { + case errors.As(err, &datastore.InvalidRevisionError{}): + return status.Errorf(codes.OutOfRange, "invalid revision: %s", err) + + case errors.As(err, &datastore.ReadOnlyError{}): + return shared.ErrServiceReadOnly + + default: + log.Ctx(ctx).Err(err).Msg("unexpected consistency middleware error") + return err + } +} diff --git a/vendor/github.com/authzed/spicedb/pkg/middleware/consistency/doc.go b/vendor/github.com/authzed/spicedb/pkg/middleware/consistency/doc.go new file mode 100644 index 0000000..593ec0a --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/middleware/consistency/doc.go @@ -0,0 +1,2 @@ +// Package consistency defines middleware to set, based on the request's consistency level, the right datastore revision to use. +package consistency diff --git a/vendor/github.com/authzed/spicedb/pkg/middleware/consistency/forcefull.go b/vendor/github.com/authzed/spicedb/pkg/middleware/consistency/forcefull.go new file mode 100644 index 0000000..0ec88f7 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/middleware/consistency/forcefull.go @@ -0,0 +1,66 @@ +package consistency + +import ( + "context" + "strings" + + "google.golang.org/grpc" + + datastoremw "github.com/authzed/spicedb/internal/middleware/datastore" + "github.com/authzed/spicedb/pkg/datastore" +) + +// ForceFullConsistencyUnaryServerInterceptor returns a new unary server interceptor that enforces full consistency +// for all requests, except for those in the bypassServiceWhitelist. +func ForceFullConsistencyUnaryServerInterceptor(serviceLabel string) grpc.UnaryServerInterceptor { + return func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) { + for bypass := range bypassServiceWhitelist { + if strings.HasPrefix(info.FullMethod, bypass) { + return handler(ctx, req) + } + } + ds := datastoremw.MustFromContext(ctx) + newCtx := ContextWithHandle(ctx) + if err := setFullConsistencyRevisionToContext(newCtx, req, ds, serviceLabel); err != nil { + return nil, err + } + + return handler(newCtx, req) + } +} + +// ForceFullConsistencyStreamServerInterceptor returns a new stream server interceptor that enforces full consistency +// for all requests, except for those in the bypassServiceWhitelist. +func ForceFullConsistencyStreamServerInterceptor(serviceLabel string) grpc.StreamServerInterceptor { + return func(srv interface{}, stream grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error { + for bypass := range bypassServiceWhitelist { + if strings.HasPrefix(info.FullMethod, bypass) { + return handler(srv, stream) + } + } + wrapper := &recvWrapper{stream, ContextWithHandle(stream.Context()), serviceLabel, setFullConsistencyRevisionToContext} + return handler(srv, wrapper) + } +} + +func setFullConsistencyRevisionToContext(ctx context.Context, req interface{}, ds datastore.Datastore, serviceLabel string) error { + handle := ctx.Value(revisionKey) + if handle == nil { + return nil + } + + switch req.(type) { + case hasConsistency: + if serviceLabel != "" { + ConsistencyCounter.WithLabelValues("full", "request", serviceLabel).Inc() + } + + databaseRev, err := ds.HeadRevision(ctx) + if err != nil { + return rewriteDatastoreError(ctx, err) + } + handle.(*revisionHandle).revision = databaseRev + } + + return nil +} diff --git a/vendor/github.com/authzed/spicedb/pkg/middleware/nodeid/doc.go b/vendor/github.com/authzed/spicedb/pkg/middleware/nodeid/doc.go new file mode 100644 index 0000000..571288c --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/middleware/nodeid/doc.go @@ -0,0 +1,2 @@ +// Package nodeid defines middleware to update the context with the Id of the SpiceDB node running the request. +package nodeid diff --git a/vendor/github.com/authzed/spicedb/pkg/middleware/nodeid/nodeid.go b/vendor/github.com/authzed/spicedb/pkg/middleware/nodeid/nodeid.go new file mode 100644 index 0000000..3885036 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/middleware/nodeid/nodeid.go @@ -0,0 +1,102 @@ +package nodeid + +import ( + "context" + "fmt" + "os" + + "github.com/cespare/xxhash/v2" + middleware "github.com/grpc-ecosystem/go-grpc-middleware/v2" + "github.com/rs/zerolog/log" + "google.golang.org/grpc" +) + +const spiceDBPrefix = "spicedb:" + +type ctxKeyType struct{} + +var nodeIDKey ctxKeyType = struct{}{} + +type nodeIDHandle struct { + nodeID string +} + +var defaultNodeID string + +func init() { + hostname, err := os.Hostname() + if err != nil { + log.Warn().Err(err).Msg("failed to get hostname, using an empty node ID") + return + } + + // Hash the hostname to get the final default node ID. + hasher := xxhash.New() + if _, err := hasher.WriteString(hostname); err != nil { + log.Warn().Err(err).Msg("failed to hash hostname, using an empty node ID") + return + } + + defaultNodeID = spiceDBPrefix + fmt.Sprintf("%x", hasher.Sum(nil)) +} + +// ContextWithHandle adds a placeholder to a context that will later be +// filled by the Node ID. +func ContextWithHandle(ctx context.Context) context.Context { + return context.WithValue(ctx, nodeIDKey, &nodeIDHandle{}) +} + +// FromContext reads the node's ID out of a context.Context. +func FromContext(ctx context.Context) (string, error) { + if c := ctx.Value(nodeIDKey); c != nil { + handle := c.(*nodeIDHandle) + if handle.nodeID != "" { + return handle.nodeID, nil + } + } + + if err := setInContext(ctx, defaultNodeID); err != nil { + return "", err + } + + return defaultNodeID, nil +} + +// setInContext adds a node ID to the given context +func setInContext(ctx context.Context, nodeID string) error { + handle := ctx.Value(nodeIDKey) + if handle == nil { + return nil + } + handle.(*nodeIDHandle).nodeID = nodeID + return nil +} + +// UnaryServerInterceptor returns a new unary server interceptor that adds the +// node ID to the context. If empty, spicedb:$hostname is used. +func UnaryServerInterceptor(nodeID string) grpc.UnaryServerInterceptor { + return func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) { + newCtx := ContextWithHandle(ctx) + if nodeID != "" { + if err := setInContext(newCtx, nodeID); err != nil { + return nil, err + } + } + return handler(newCtx, req) + } +} + +// StreamServerInterceptor returns a new stream server interceptor that adds the +// node ID to the context. If empty, spicedb:$hostname is used. +func StreamServerInterceptor(nodeID string) grpc.StreamServerInterceptor { + return func(srv interface{}, stream grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error { + wrapped := middleware.WrapServerStream(stream) + wrapped.WrappedContext = ContextWithHandle(wrapped.WrappedContext) + if nodeID != "" { + if err := setInContext(wrapped.WrappedContext, nodeID); err != nil { + return err + } + } + return handler(srv, wrapped) + } +} diff --git a/vendor/github.com/authzed/spicedb/pkg/middleware/requestid/doc.go b/vendor/github.com/authzed/spicedb/pkg/middleware/requestid/doc.go new file mode 100644 index 0000000..2f47d2f --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/middleware/requestid/doc.go @@ -0,0 +1,2 @@ +// Package requestid defines middleware to set a request or response header with a request ID. +package requestid diff --git a/vendor/github.com/authzed/spicedb/pkg/middleware/requestid/requestid.go b/vendor/github.com/authzed/spicedb/pkg/middleware/requestid/requestid.go new file mode 100644 index 0000000..7a0904a --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/middleware/requestid/requestid.go @@ -0,0 +1,162 @@ +package requestid + +import ( + "context" + + log "github.com/authzed/spicedb/internal/logging" + + "github.com/authzed/authzed-go/pkg/requestmeta" + "github.com/authzed/authzed-go/pkg/responsemeta" + "github.com/grpc-ecosystem/go-grpc-middleware/v2/interceptors" + "github.com/rs/xid" + "google.golang.org/grpc" + "google.golang.org/grpc/metadata" +) + +const metadataKey = string(requestmeta.RequestIDKey) + +// Option instances control how the middleware is initialized. +type Option func(*handleRequestID) + +// GenerateIfMissing will instruct the middleware to create a request ID if one +// isn't already on the incoming request. +// +// default: false +func GenerateIfMissing(enable bool) Option { + return func(reporter *handleRequestID) { + reporter.generateIfMissing = enable + } +} + +// IDGenerator functions are used to generate request IDs if a new one is needed. +type IDGenerator func() string + +// GenerateRequestID generates a new request ID. +func GenerateRequestID() string { + return xid.New().String() +} + +type handleRequestID struct { + generateIfMissing bool + requestIDGenerator IDGenerator +} + +func (r *handleRequestID) ClientReporter(ctx context.Context, meta interceptors.CallMeta) (interceptors.Reporter, context.Context) { + haveRequestID, requestID, ctx := r.fromContextOrGenerate(ctx) + + if haveRequestID { + ctx = requestmeta.SetRequestHeaders(ctx, map[requestmeta.RequestMetadataHeaderKey]string{ + requestmeta.RequestIDKey: requestID, + }) + } + + return interceptors.NoopReporter{}, ctx +} + +func (r *handleRequestID) ServerReporter(ctx context.Context, _ interceptors.CallMeta) (interceptors.Reporter, context.Context) { + haveRequestID, requestID, ctx := r.fromContextOrGenerate(ctx) + + if haveRequestID { + err := responsemeta.SetResponseHeaderMetadata(ctx, map[responsemeta.ResponseMetadataHeaderKey]string{ + responsemeta.RequestID: requestID, + }) + // if context is cancelled, the stream will be closed, and gRPC will return ErrIllegalHeaderWrite + // this prevents logging unnecessary error messages + if ctx.Err() != nil { + return interceptors.NoopReporter{}, ctx + } + if err != nil { + log.Ctx(ctx).Warn().Err(err).Msg("requestid: could not report metadata") + } + } + + return interceptors.NoopReporter{}, ctx +} + +func (r *handleRequestID) fromContextOrGenerate(ctx context.Context) (bool, string, context.Context) { + haveRequestID, requestID, md := fromContext(ctx) + + if !haveRequestID && r.generateIfMissing { + requestID = r.requestIDGenerator() + haveRequestID = true + + // Inject the newly generated request ID into the metadata + if md == nil { + md = metadata.New(nil) + } + + md.Set(metadataKey, requestID) + ctx = metadata.NewIncomingContext(ctx, md) + } + + return haveRequestID, requestID, ctx +} + +func fromContext(ctx context.Context) (bool, string, metadata.MD) { + var requestID string + var haveRequestID bool + md, ok := metadata.FromIncomingContext(ctx) + if ok { + var requestIDs []string + requestIDs, haveRequestID = md[metadataKey] + if haveRequestID { + requestID = requestIDs[0] + } + } + + return haveRequestID, requestID, md +} + +// PropagateIfExists copies the request ID from the source context to the target context if it exists. +// The updated target context is returned. +func PropagateIfExists(source, target context.Context) context.Context { + exists, requestID, _ := fromContext(source) + + if exists { + targetMD, _ := metadata.FromIncomingContext(target) + if targetMD == nil { + targetMD = metadata.New(nil) + } + + targetMD.Set(metadataKey, requestID) + return metadata.NewIncomingContext(target, targetMD) + } + + return target +} + +// UnaryServerInterceptor returns a new interceptor which handles server request IDs according +// to the provided options. +func UnaryServerInterceptor(opts ...Option) grpc.UnaryServerInterceptor { + return interceptors.UnaryServerInterceptor(createReporter(opts)) +} + +// StreamServerInterceptor returns a new interceptor which handles server request IDs according +// to the provided options. +func StreamServerInterceptor(opts ...Option) grpc.StreamServerInterceptor { + return interceptors.StreamServerInterceptor(createReporter(opts)) +} + +// UnaryClientInterceptor returns a new interceptor which handles client request IDs according +// to the provided options. +func UnaryClientInterceptor(opts ...Option) grpc.UnaryClientInterceptor { + return interceptors.UnaryClientInterceptor(createReporter(opts)) +} + +// StreamClientInterceptor returns a new interceptor which handles client requestIDs according +// to the provided options. +func StreamClientInterceptor(opts ...Option) grpc.StreamClientInterceptor { + return interceptors.StreamClientInterceptor(createReporter(opts)) +} + +func createReporter(opts []Option) *handleRequestID { + reporter := &handleRequestID{ + requestIDGenerator: GenerateRequestID, + } + + for _, opt := range opts { + opt(reporter) + } + + return reporter +} diff --git a/vendor/github.com/authzed/spicedb/pkg/namespace/builder.go b/vendor/github.com/authzed/spicedb/pkg/namespace/builder.go new file mode 100644 index 0000000..cf4c745 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/namespace/builder.go @@ -0,0 +1,340 @@ +package namespace + +import ( + "github.com/authzed/spicedb/pkg/caveats" + core "github.com/authzed/spicedb/pkg/proto/core/v1" + iv1 "github.com/authzed/spicedb/pkg/proto/impl/v1" + "github.com/authzed/spicedb/pkg/spiceerrors" +) + +// Namespace creates a namespace definition with one or more defined relations. +func Namespace(name string, relations ...*core.Relation) *core.NamespaceDefinition { + return &core.NamespaceDefinition{ + Name: name, + Relation: relations, + } +} + +// WithComment creates a namespace definition with one or more defined relations. +func WithComment(name string, comment string, relations ...*core.Relation) *core.NamespaceDefinition { + nd := Namespace(name, relations...) + nd.Metadata, _ = AddComment(nd.Metadata, comment) + return nd +} + +// MustRelation creates a relation definition with an optional rewrite definition. +func MustRelation(name string, rewrite *core.UsersetRewrite, allowedDirectRelations ...*core.AllowedRelation) *core.Relation { + r, err := Relation(name, rewrite, allowedDirectRelations...) + if err != nil { + panic(err) + } + return r +} + +// Relation creates a relation definition with an optional rewrite definition. +func Relation(name string, rewrite *core.UsersetRewrite, allowedDirectRelations ...*core.AllowedRelation) (*core.Relation, error) { + var typeInfo *core.TypeInformation + if len(allowedDirectRelations) > 0 { + typeInfo = &core.TypeInformation{ + AllowedDirectRelations: allowedDirectRelations, + } + } + + rel := &core.Relation{ + Name: name, + UsersetRewrite: rewrite, + TypeInformation: typeInfo, + } + + switch { + case rewrite != nil && len(allowedDirectRelations) == 0: + if err := SetRelationKind(rel, iv1.RelationMetadata_PERMISSION); err != nil { + return nil, spiceerrors.MustBugf("failed to set relation kind: %s", err.Error()) + } + + case rewrite == nil && len(allowedDirectRelations) > 0: + if err := SetRelationKind(rel, iv1.RelationMetadata_RELATION); err != nil { + return nil, spiceerrors.MustBugf("failed to set relation kind: %s", err.Error()) + } + + default: + // By default we do not set a relation kind on the relation. Relations without any + // information, or relations with both rewrites and types are legacy relations from + // before the DSL schema and, as such, do not have a defined "kind". + } + + return rel, nil +} + +// MustRelationWithComment creates a relation definition with an optional rewrite definition. +func MustRelationWithComment(name string, comment string, rewrite *core.UsersetRewrite, allowedDirectRelations ...*core.AllowedRelation) *core.Relation { + rel := MustRelation(name, rewrite, allowedDirectRelations...) + rel.Metadata, _ = AddComment(rel.Metadata, comment) + return rel +} + +// AllowedRelation creates a relation reference to an allowed relation. +func AllowedRelation(namespaceName string, relationName string) *core.AllowedRelation { + return &core.AllowedRelation{ + Namespace: namespaceName, + RelationOrWildcard: &core.AllowedRelation_Relation{ + Relation: relationName, + }, + } +} + +// AllowedRelationWithCaveat creates a relation reference to an allowed relation. +func AllowedRelationWithCaveat(namespaceName string, relationName string, withCaveat *core.AllowedCaveat) *core.AllowedRelation { + return &core.AllowedRelation{ + Namespace: namespaceName, + RelationOrWildcard: &core.AllowedRelation_Relation{ + Relation: relationName, + }, + RequiredCaveat: withCaveat, + } +} + +// WithExpiration adds the expiration trait to the allowed relation. +func WithExpiration(allowedRelation *core.AllowedRelation) *core.AllowedRelation { + return &core.AllowedRelation{ + Namespace: allowedRelation.Namespace, + RelationOrWildcard: allowedRelation.RelationOrWildcard, + RequiredCaveat: allowedRelation.RequiredCaveat, + RequiredExpiration: &core.ExpirationTrait{}, + } +} + +// AllowedRelationWithExpiration creates a relation reference to an allowed relation. +func AllowedRelationWithExpiration(namespaceName string, relationName string) *core.AllowedRelation { + return &core.AllowedRelation{ + Namespace: namespaceName, + RelationOrWildcard: &core.AllowedRelation_Relation{ + Relation: relationName, + }, + RequiredExpiration: &core.ExpirationTrait{}, + } +} + +// AllowedRelationWithCaveatAndExpiration creates a relation reference to an allowed relation. +func AllowedRelationWithCaveatAndExpiration(namespaceName string, relationName string, withCaveat *core.AllowedCaveat) *core.AllowedRelation { + return &core.AllowedRelation{ + Namespace: namespaceName, + RelationOrWildcard: &core.AllowedRelation_Relation{ + Relation: relationName, + }, + RequiredExpiration: &core.ExpirationTrait{}, + RequiredCaveat: withCaveat, + } +} + +// AllowedPublicNamespace creates a relation reference to an allowed public namespace. +func AllowedPublicNamespace(namespaceName string) *core.AllowedRelation { + return &core.AllowedRelation{ + Namespace: namespaceName, + RelationOrWildcard: &core.AllowedRelation_PublicWildcard_{ + PublicWildcard: &core.AllowedRelation_PublicWildcard{}, + }, + } +} + +// AllowedCaveat creates a caveat reference. +func AllowedCaveat(name string) *core.AllowedCaveat { + return &core.AllowedCaveat{ + CaveatName: name, + } +} + +// CaveatDefinition returns a new caveat definition. +func CaveatDefinition(env *caveats.Environment, name string, expr string) (*core.CaveatDefinition, error) { + compiled, err := caveats.CompileCaveatWithName(env, expr, name) + if err != nil { + return nil, err + } + return CompiledCaveatDefinition(env, name, compiled) +} + +// CompiledCaveatDefinition returns a new caveat definition. +func CompiledCaveatDefinition(env *caveats.Environment, name string, compiled *caveats.CompiledCaveat) (*core.CaveatDefinition, error) { + if compiled == nil { + return nil, spiceerrors.MustBugf("compiled caveat is nil") + } + + serialized, err := compiled.Serialize() + if err != nil { + return nil, err + } + return &core.CaveatDefinition{ + Name: name, + SerializedExpression: serialized, + ParameterTypes: env.EncodedParametersTypes(), + }, nil +} + +// MustCaveatDefinition returns a new caveat definition. +func MustCaveatDefinition(env *caveats.Environment, name string, expr string) *core.CaveatDefinition { + cd, err := CaveatDefinition(env, name, expr) + if err != nil { + panic(err) + } + return cd +} + +// MustCaveatDefinitionWithComment returns a new caveat definition. +func MustCaveatDefinitionWithComment(env *caveats.Environment, name string, comment string, expr string) *core.CaveatDefinition { + cd, err := CaveatDefinition(env, name, expr) + if err != nil { + panic(err) + } + cd.Metadata, _ = AddComment(cd.Metadata, comment) + return cd +} + +// AllowedPublicNamespaceWithCaveat creates a relation reference to an allowed public namespace. +func AllowedPublicNamespaceWithCaveat(namespaceName string, withCaveat *core.AllowedCaveat) *core.AllowedRelation { + return &core.AllowedRelation{ + Namespace: namespaceName, + RelationOrWildcard: &core.AllowedRelation_PublicWildcard_{ + PublicWildcard: &core.AllowedRelation_PublicWildcard{}, + }, + RequiredCaveat: withCaveat, + } +} + +// RelationReference creates a relation reference. +func RelationReference(namespaceName string, relationName string) *core.RelationReference { + return &core.RelationReference{ + Namespace: namespaceName, + Relation: relationName, + } +} + +// Union creates a rewrite definition that combines/considers usersets in all children. +func Union(firstChild *core.SetOperation_Child, rest ...*core.SetOperation_Child) *core.UsersetRewrite { + return &core.UsersetRewrite{ + RewriteOperation: &core.UsersetRewrite_Union{ + Union: setOperation(firstChild, rest), + }, + } +} + +// Intersection creates a rewrite definition that returns/considers only usersets present in all children. +func Intersection(firstChild *core.SetOperation_Child, rest ...*core.SetOperation_Child) *core.UsersetRewrite { + return &core.UsersetRewrite{ + RewriteOperation: &core.UsersetRewrite_Intersection{ + Intersection: setOperation(firstChild, rest), + }, + } +} + +// Exclusion creates a rewrite definition that starts with the usersets of the first child +// and iteratively removes usersets that appear in the remaining children. +func Exclusion(firstChild *core.SetOperation_Child, rest ...*core.SetOperation_Child) *core.UsersetRewrite { + return &core.UsersetRewrite{ + RewriteOperation: &core.UsersetRewrite_Exclusion{ + Exclusion: setOperation(firstChild, rest), + }, + } +} + +func setOperation(firstChild *core.SetOperation_Child, rest []*core.SetOperation_Child) *core.SetOperation { + children := append([]*core.SetOperation_Child{firstChild}, rest...) + return &core.SetOperation{ + Child: children, + } +} + +// Nil creates a child for a set operation that references the empty set. +func Nil() *core.SetOperation_Child { + return &core.SetOperation_Child{ + ChildType: &core.SetOperation_Child_XNil{}, + } +} + +// ComputesUserset creates a child for a set operation that follows a relation on the given starting object. +func ComputedUserset(relation string) *core.SetOperation_Child { + return &core.SetOperation_Child{ + ChildType: &core.SetOperation_Child_ComputedUserset{ + ComputedUserset: &core.ComputedUserset{ + Relation: relation, + }, + }, + } +} + +// MustComputesUsersetWithSourcePosition creates a child for a set operation that follows a relation on the given starting object. +func MustComputesUsersetWithSourcePosition(relation string, lineNumber uint64) *core.SetOperation_Child { + cu := &core.ComputedUserset{ + Relation: relation, + } + cu.SourcePosition = &core.SourcePosition{ + ZeroIndexedLineNumber: lineNumber, + ZeroIndexedColumnPosition: 0, + } + + return &core.SetOperation_Child{ + ChildType: &core.SetOperation_Child_ComputedUserset{ + ComputedUserset: cu, + }, + } +} + +// TupleToUserset creates a child which first loads all tuples with the specific relation, +// and then unions all children on the usersets found by following a relation on those loaded +// tuples. +func TupleToUserset(tuplesetRelation, usersetRelation string) *core.SetOperation_Child { + return &core.SetOperation_Child{ + ChildType: &core.SetOperation_Child_TupleToUserset{ + TupleToUserset: &core.TupleToUserset{ + Tupleset: &core.TupleToUserset_Tupleset{ + Relation: tuplesetRelation, + }, + ComputedUserset: &core.ComputedUserset{ + Relation: usersetRelation, + Object: core.ComputedUserset_TUPLE_USERSET_OBJECT, + }, + }, + }, + } +} + +// MustFunctionedTupleToUserset creates a child which first loads all tuples with the specific relation, +// and then applies the function to all children on the usersets found by following a relation on those loaded +// tuples. +func MustFunctionedTupleToUserset(tuplesetRelation, functionName, usersetRelation string) *core.SetOperation_Child { + function := core.FunctionedTupleToUserset_FUNCTION_ANY + + switch functionName { + case "any": + // already set to any + + case "all": + function = core.FunctionedTupleToUserset_FUNCTION_ALL + + default: + panic(spiceerrors.MustBugf("unknown function name: %s", functionName)) + } + + return &core.SetOperation_Child{ + ChildType: &core.SetOperation_Child_FunctionedTupleToUserset{ + FunctionedTupleToUserset: &core.FunctionedTupleToUserset{ + Function: function, + Tupleset: &core.FunctionedTupleToUserset_Tupleset{ + Relation: tuplesetRelation, + }, + ComputedUserset: &core.ComputedUserset{ + Relation: usersetRelation, + Object: core.ComputedUserset_TUPLE_USERSET_OBJECT, + }, + }, + }, + } +} + +// Rewrite wraps a rewrite as a set operation child of another rewrite. +func Rewrite(rewrite *core.UsersetRewrite) *core.SetOperation_Child { + return &core.SetOperation_Child{ + ChildType: &core.SetOperation_Child_UsersetRewrite{ + UsersetRewrite: rewrite, + }, + } +} diff --git a/vendor/github.com/authzed/spicedb/pkg/namespace/doc.go b/vendor/github.com/authzed/spicedb/pkg/namespace/doc.go new file mode 100644 index 0000000..ab77e95 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/namespace/doc.go @@ -0,0 +1,2 @@ +// Package namespace contains helper functions to create namespaces in a schema. +package namespace diff --git a/vendor/github.com/authzed/spicedb/pkg/namespace/mapper.go b/vendor/github.com/authzed/spicedb/pkg/namespace/mapper.go new file mode 100644 index 0000000..148ca8e --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/namespace/mapper.go @@ -0,0 +1,27 @@ +package namespace + +// Mapper provides an interface for creating synthetic namespace names from +// user provided namespace names. +type Mapper interface { + // Encode translates a given namespace name to an encoded namespace identifier. + Encode(name string) (string, error) + + // Reverse translates a given namespace identifier to the user supplied namespace name. + Reverse(id string) (string, error) +} + +type passthrough struct{} + +// Encode implements Mapper +func (p passthrough) Encode(name string) (string, error) { + return name, nil +} + +// Reverse implements Mapper +func (p passthrough) Reverse(id string) (string, error) { + return id, nil +} + +// PassthroughMapper is a mapper implementation which passes through the original namespace +// names unmodified. +var PassthroughMapper Mapper = passthrough{} diff --git a/vendor/github.com/authzed/spicedb/pkg/namespace/metadata.go b/vendor/github.com/authzed/spicedb/pkg/namespace/metadata.go new file mode 100644 index 0000000..5544a5c --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/namespace/metadata.go @@ -0,0 +1,110 @@ +package namespace + +import ( + "google.golang.org/protobuf/types/known/anypb" + + core "github.com/authzed/spicedb/pkg/proto/core/v1" + + iv1 "github.com/authzed/spicedb/pkg/proto/impl/v1" +) + +// WithSourcePosition defines an interface for proto messages in core with SourcePosition information attached. +type WithSourcePosition interface { + GetSourcePosition() *core.SourcePosition +} + +// userDefinedMetadataTypeUrls are the type URLs of any user-defined metadata found +// in the namespace proto. If placed here, FilterUserDefinedMetadataInPlace will remove the +// metadata when called on the namespace. +var userDefinedMetadataTypeUrls = map[string]struct{}{ + "type.googleapis.com/impl.v1.DocComment": {}, +} + +// FilterUserDefinedMetadataInPlace removes user-defined metadata (e.g. comments) from the given namespace +// *in place*. +func FilterUserDefinedMetadataInPlace(nsconfig *core.NamespaceDefinition) { + nsconfig.Metadata = nil + for _, relation := range nsconfig.Relation { + if relation.Metadata != nil { + var filteredMessages []*anypb.Any + for _, msg := range relation.Metadata.MetadataMessage { + if _, ok := userDefinedMetadataTypeUrls[msg.TypeUrl]; !ok { + filteredMessages = append(filteredMessages, msg) + } + } + relation.Metadata.MetadataMessage = filteredMessages + } + } +} + +// GetComments returns the comment metadata found within the given metadata message. +func GetComments(metadata *core.Metadata) []string { + if metadata == nil { + return []string{} + } + + comments := []string{} + for _, msg := range metadata.MetadataMessage { + var dc iv1.DocComment + if err := msg.UnmarshalTo(&dc); err == nil { + comments = append(comments, dc.Comment) + } + } + + return comments +} + +// AddComment adds a comment to the given metadata message. +func AddComment(metadata *core.Metadata, comment string) (*core.Metadata, error) { + if metadata == nil { + metadata = &core.Metadata{} + } + + var dc iv1.DocComment + dc.Comment = comment + + encoded, err := anypb.New(&dc) + if err != nil { + return metadata, err + } + + metadata.MetadataMessage = append(metadata.MetadataMessage, encoded) + return metadata, nil +} + +// GetRelationKind returns the kind of the relation. +func GetRelationKind(relation *core.Relation) iv1.RelationMetadata_RelationKind { + metadata := relation.Metadata + if metadata == nil { + return iv1.RelationMetadata_UNKNOWN_KIND + } + + for _, msg := range metadata.MetadataMessage { + var rm iv1.RelationMetadata + if err := msg.UnmarshalTo(&rm); err == nil { + return rm.Kind + } + } + + return iv1.RelationMetadata_UNKNOWN_KIND +} + +// SetRelationKind sets the kind of relation. +func SetRelationKind(relation *core.Relation, kind iv1.RelationMetadata_RelationKind) error { + metadata := relation.Metadata + if metadata == nil { + metadata = &core.Metadata{} + relation.Metadata = metadata + } + + var rm iv1.RelationMetadata + rm.Kind = kind + + encoded, err := anypb.New(&rm) + if err != nil { + return err + } + + metadata.MetadataMessage = append(metadata.MetadataMessage, encoded) + return nil +} diff --git a/vendor/github.com/authzed/spicedb/pkg/promutil/promutil.go b/vendor/github.com/authzed/spicedb/pkg/promutil/promutil.go new file mode 100644 index 0000000..57592a8 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/promutil/promutil.go @@ -0,0 +1,15 @@ +package promutil + +import "github.com/prometheus/client_golang/prometheus" + +var _ prometheus.Collector = (CollectorFunc)(nil) + +// CollectorFunc is a convenient way to implement a Prometheus Collector +// without interface boilerplate. +// +// This implementation relies on prometheus.DescribeByCollect; familiarize +// yourself with that documentation before using. +type CollectorFunc func(ch chan<- prometheus.Metric) + +func (c CollectorFunc) Collect(ch chan<- prometheus.Metric) { c(ch) } +func (c CollectorFunc) Describe(ch chan<- *prometheus.Desc) { prometheus.DescribeByCollect(c, ch) } diff --git a/vendor/github.com/authzed/spicedb/pkg/proto/core/v1/core.pb.go b/vendor/github.com/authzed/spicedb/pkg/proto/core/v1/core.pb.go new file mode 100644 index 0000000..56ce0f7 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/proto/core/v1/core.pb.go @@ -0,0 +1,4356 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.34.2 +// protoc (unknown) +// source: core/v1/core.proto + +package corev1 + +import ( + _ "github.com/envoyproxy/protoc-gen-validate/validate" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + anypb "google.golang.org/protobuf/types/known/anypb" + structpb "google.golang.org/protobuf/types/known/structpb" + timestamppb "google.golang.org/protobuf/types/known/timestamppb" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type RelationTupleUpdate_Operation int32 + +const ( + RelationTupleUpdate_UNKNOWN RelationTupleUpdate_Operation = 0 + RelationTupleUpdate_CREATE RelationTupleUpdate_Operation = 1 + RelationTupleUpdate_TOUCH RelationTupleUpdate_Operation = 2 + RelationTupleUpdate_DELETE RelationTupleUpdate_Operation = 3 +) + +// Enum value maps for RelationTupleUpdate_Operation. +var ( + RelationTupleUpdate_Operation_name = map[int32]string{ + 0: "UNKNOWN", + 1: "CREATE", + 2: "TOUCH", + 3: "DELETE", + } + RelationTupleUpdate_Operation_value = map[string]int32{ + "UNKNOWN": 0, + "CREATE": 1, + "TOUCH": 2, + "DELETE": 3, + } +) + +func (x RelationTupleUpdate_Operation) Enum() *RelationTupleUpdate_Operation { + p := new(RelationTupleUpdate_Operation) + *p = x + return p +} + +func (x RelationTupleUpdate_Operation) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (RelationTupleUpdate_Operation) Descriptor() protoreflect.EnumDescriptor { + return file_core_v1_core_proto_enumTypes[0].Descriptor() +} + +func (RelationTupleUpdate_Operation) Type() protoreflect.EnumType { + return &file_core_v1_core_proto_enumTypes[0] +} + +func (x RelationTupleUpdate_Operation) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use RelationTupleUpdate_Operation.Descriptor instead. +func (RelationTupleUpdate_Operation) EnumDescriptor() ([]byte, []int) { + return file_core_v1_core_proto_rawDescGZIP(), []int{8, 0} +} + +type SetOperationUserset_Operation int32 + +const ( + SetOperationUserset_INVALID SetOperationUserset_Operation = 0 + SetOperationUserset_UNION SetOperationUserset_Operation = 1 + SetOperationUserset_INTERSECTION SetOperationUserset_Operation = 2 + SetOperationUserset_EXCLUSION SetOperationUserset_Operation = 3 +) + +// Enum value maps for SetOperationUserset_Operation. +var ( + SetOperationUserset_Operation_name = map[int32]string{ + 0: "INVALID", + 1: "UNION", + 2: "INTERSECTION", + 3: "EXCLUSION", + } + SetOperationUserset_Operation_value = map[string]int32{ + "INVALID": 0, + "UNION": 1, + "INTERSECTION": 2, + "EXCLUSION": 3, + } +) + +func (x SetOperationUserset_Operation) Enum() *SetOperationUserset_Operation { + p := new(SetOperationUserset_Operation) + *p = x + return p +} + +func (x SetOperationUserset_Operation) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (SetOperationUserset_Operation) Descriptor() protoreflect.EnumDescriptor { + return file_core_v1_core_proto_enumTypes[1].Descriptor() +} + +func (SetOperationUserset_Operation) Type() protoreflect.EnumType { + return &file_core_v1_core_proto_enumTypes[1] +} + +func (x SetOperationUserset_Operation) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use SetOperationUserset_Operation.Descriptor instead. +func (SetOperationUserset_Operation) EnumDescriptor() ([]byte, []int) { + return file_core_v1_core_proto_rawDescGZIP(), []int{10, 0} +} + +type ReachabilityEntrypoint_ReachabilityEntrypointKind int32 + +const ( + // * + // RELATION_ENTRYPOINT indicates an entrypoint where the subject object can be directly + // found for a relationship. + ReachabilityEntrypoint_RELATION_ENTRYPOINT ReachabilityEntrypoint_ReachabilityEntrypointKind = 0 + // * + // COMPUTED_USERSET_ENTRYPOINT indicates an entrypoint where the subject's relation is + // "rewritten" via a `computed_userset` to the target permission's operation node. + ReachabilityEntrypoint_COMPUTED_USERSET_ENTRYPOINT ReachabilityEntrypoint_ReachabilityEntrypointKind = 1 + // * + // TUPLESET_TO_USERSET_ENTRYPOINT indicates an entrypoint where the subject's relation is + // walked via a `tupleset_to_userset` in the target permission's operation node. + ReachabilityEntrypoint_TUPLESET_TO_USERSET_ENTRYPOINT ReachabilityEntrypoint_ReachabilityEntrypointKind = 2 +) + +// Enum value maps for ReachabilityEntrypoint_ReachabilityEntrypointKind. +var ( + ReachabilityEntrypoint_ReachabilityEntrypointKind_name = map[int32]string{ + 0: "RELATION_ENTRYPOINT", + 1: "COMPUTED_USERSET_ENTRYPOINT", + 2: "TUPLESET_TO_USERSET_ENTRYPOINT", + } + ReachabilityEntrypoint_ReachabilityEntrypointKind_value = map[string]int32{ + "RELATION_ENTRYPOINT": 0, + "COMPUTED_USERSET_ENTRYPOINT": 1, + "TUPLESET_TO_USERSET_ENTRYPOINT": 2, + } +) + +func (x ReachabilityEntrypoint_ReachabilityEntrypointKind) Enum() *ReachabilityEntrypoint_ReachabilityEntrypointKind { + p := new(ReachabilityEntrypoint_ReachabilityEntrypointKind) + *p = x + return p +} + +func (x ReachabilityEntrypoint_ReachabilityEntrypointKind) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (ReachabilityEntrypoint_ReachabilityEntrypointKind) Descriptor() protoreflect.EnumDescriptor { + return file_core_v1_core_proto_enumTypes[2].Descriptor() +} + +func (ReachabilityEntrypoint_ReachabilityEntrypointKind) Type() protoreflect.EnumType { + return &file_core_v1_core_proto_enumTypes[2] +} + +func (x ReachabilityEntrypoint_ReachabilityEntrypointKind) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use ReachabilityEntrypoint_ReachabilityEntrypointKind.Descriptor instead. +func (ReachabilityEntrypoint_ReachabilityEntrypointKind) EnumDescriptor() ([]byte, []int) { + return file_core_v1_core_proto_rawDescGZIP(), []int{18, 0} +} + +type ReachabilityEntrypoint_EntrypointResultStatus int32 + +const ( + // * + // REACHABLE_CONDITIONAL_RESULT indicates that the entrypoint is under one or more intersections + // or exclusion operations, indicating that any reachable object *may* be a result, conditional + // on the parent non-union operation(s). + ReachabilityEntrypoint_REACHABLE_CONDITIONAL_RESULT ReachabilityEntrypoint_EntrypointResultStatus = 0 + // * + // DIRECT_OPERATION_RESULT indicates that the entrypoint exists solely under zero or more + // union operations, making any reachable object also a *result* of the relation or permission. + ReachabilityEntrypoint_DIRECT_OPERATION_RESULT ReachabilityEntrypoint_EntrypointResultStatus = 1 +) + +// Enum value maps for ReachabilityEntrypoint_EntrypointResultStatus. +var ( + ReachabilityEntrypoint_EntrypointResultStatus_name = map[int32]string{ + 0: "REACHABLE_CONDITIONAL_RESULT", + 1: "DIRECT_OPERATION_RESULT", + } + ReachabilityEntrypoint_EntrypointResultStatus_value = map[string]int32{ + "REACHABLE_CONDITIONAL_RESULT": 0, + "DIRECT_OPERATION_RESULT": 1, + } +) + +func (x ReachabilityEntrypoint_EntrypointResultStatus) Enum() *ReachabilityEntrypoint_EntrypointResultStatus { + p := new(ReachabilityEntrypoint_EntrypointResultStatus) + *p = x + return p +} + +func (x ReachabilityEntrypoint_EntrypointResultStatus) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (ReachabilityEntrypoint_EntrypointResultStatus) Descriptor() protoreflect.EnumDescriptor { + return file_core_v1_core_proto_enumTypes[3].Descriptor() +} + +func (ReachabilityEntrypoint_EntrypointResultStatus) Type() protoreflect.EnumType { + return &file_core_v1_core_proto_enumTypes[3] +} + +func (x ReachabilityEntrypoint_EntrypointResultStatus) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use ReachabilityEntrypoint_EntrypointResultStatus.Descriptor instead. +func (ReachabilityEntrypoint_EntrypointResultStatus) EnumDescriptor() ([]byte, []int) { + return file_core_v1_core_proto_rawDescGZIP(), []int{18, 1} +} + +type FunctionedTupleToUserset_Function int32 + +const ( + FunctionedTupleToUserset_FUNCTION_UNSPECIFIED FunctionedTupleToUserset_Function = 0 + FunctionedTupleToUserset_FUNCTION_ANY FunctionedTupleToUserset_Function = 1 + FunctionedTupleToUserset_FUNCTION_ALL FunctionedTupleToUserset_Function = 2 +) + +// Enum value maps for FunctionedTupleToUserset_Function. +var ( + FunctionedTupleToUserset_Function_name = map[int32]string{ + 0: "FUNCTION_UNSPECIFIED", + 1: "FUNCTION_ANY", + 2: "FUNCTION_ALL", + } + FunctionedTupleToUserset_Function_value = map[string]int32{ + "FUNCTION_UNSPECIFIED": 0, + "FUNCTION_ANY": 1, + "FUNCTION_ALL": 2, + } +) + +func (x FunctionedTupleToUserset_Function) Enum() *FunctionedTupleToUserset_Function { + p := new(FunctionedTupleToUserset_Function) + *p = x + return p +} + +func (x FunctionedTupleToUserset_Function) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (FunctionedTupleToUserset_Function) Descriptor() protoreflect.EnumDescriptor { + return file_core_v1_core_proto_enumTypes[4].Descriptor() +} + +func (FunctionedTupleToUserset_Function) Type() protoreflect.EnumType { + return &file_core_v1_core_proto_enumTypes[4] +} + +func (x FunctionedTupleToUserset_Function) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use FunctionedTupleToUserset_Function.Descriptor instead. +func (FunctionedTupleToUserset_Function) EnumDescriptor() ([]byte, []int) { + return file_core_v1_core_proto_rawDescGZIP(), []int{26, 0} +} + +type ComputedUserset_Object int32 + +const ( + ComputedUserset_TUPLE_OBJECT ComputedUserset_Object = 0 + ComputedUserset_TUPLE_USERSET_OBJECT ComputedUserset_Object = 1 +) + +// Enum value maps for ComputedUserset_Object. +var ( + ComputedUserset_Object_name = map[int32]string{ + 0: "TUPLE_OBJECT", + 1: "TUPLE_USERSET_OBJECT", + } + ComputedUserset_Object_value = map[string]int32{ + "TUPLE_OBJECT": 0, + "TUPLE_USERSET_OBJECT": 1, + } +) + +func (x ComputedUserset_Object) Enum() *ComputedUserset_Object { + p := new(ComputedUserset_Object) + *p = x + return p +} + +func (x ComputedUserset_Object) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (ComputedUserset_Object) Descriptor() protoreflect.EnumDescriptor { + return file_core_v1_core_proto_enumTypes[5].Descriptor() +} + +func (ComputedUserset_Object) Type() protoreflect.EnumType { + return &file_core_v1_core_proto_enumTypes[5] +} + +func (x ComputedUserset_Object) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use ComputedUserset_Object.Descriptor instead. +func (ComputedUserset_Object) EnumDescriptor() ([]byte, []int) { + return file_core_v1_core_proto_rawDescGZIP(), []int{27, 0} +} + +type CaveatOperation_Operation int32 + +const ( + CaveatOperation_UNKNOWN CaveatOperation_Operation = 0 + CaveatOperation_OR CaveatOperation_Operation = 1 + CaveatOperation_AND CaveatOperation_Operation = 2 + CaveatOperation_NOT CaveatOperation_Operation = 3 +) + +// Enum value maps for CaveatOperation_Operation. +var ( + CaveatOperation_Operation_name = map[int32]string{ + 0: "UNKNOWN", + 1: "OR", + 2: "AND", + 3: "NOT", + } + CaveatOperation_Operation_value = map[string]int32{ + "UNKNOWN": 0, + "OR": 1, + "AND": 2, + "NOT": 3, + } +) + +func (x CaveatOperation_Operation) Enum() *CaveatOperation_Operation { + p := new(CaveatOperation_Operation) + *p = x + return p +} + +func (x CaveatOperation_Operation) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (CaveatOperation_Operation) Descriptor() protoreflect.EnumDescriptor { + return file_core_v1_core_proto_enumTypes[6].Descriptor() +} + +func (CaveatOperation_Operation) Type() protoreflect.EnumType { + return &file_core_v1_core_proto_enumTypes[6] +} + +func (x CaveatOperation_Operation) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use CaveatOperation_Operation.Descriptor instead. +func (CaveatOperation_Operation) EnumDescriptor() ([]byte, []int) { + return file_core_v1_core_proto_rawDescGZIP(), []int{30, 0} +} + +type RelationTuple struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // * resource_and_relation is the resource for the tuple + ResourceAndRelation *ObjectAndRelation `protobuf:"bytes,1,opt,name=resource_and_relation,json=resourceAndRelation,proto3" json:"resource_and_relation,omitempty"` + // * subject is the subject for the tuple + Subject *ObjectAndRelation `protobuf:"bytes,2,opt,name=subject,proto3" json:"subject,omitempty"` + // * caveat is a reference to a the caveat that must be enforced over the tuple * + Caveat *ContextualizedCaveat `protobuf:"bytes,3,opt,name=caveat,proto3" json:"caveat,omitempty"` + // * integrity holds (optional) information about the integrity of the tuple + Integrity *RelationshipIntegrity `protobuf:"bytes,4,opt,name=integrity,proto3" json:"integrity,omitempty"` + // * optional_expiration_time is the (optional) time at which the tuple expires + OptionalExpirationTime *timestamppb.Timestamp `protobuf:"bytes,5,opt,name=optional_expiration_time,json=optionalExpirationTime,proto3" json:"optional_expiration_time,omitempty"` +} + +func (x *RelationTuple) Reset() { + *x = RelationTuple{} + if protoimpl.UnsafeEnabled { + mi := &file_core_v1_core_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *RelationTuple) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RelationTuple) ProtoMessage() {} + +func (x *RelationTuple) ProtoReflect() protoreflect.Message { + mi := &file_core_v1_core_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use RelationTuple.ProtoReflect.Descriptor instead. +func (*RelationTuple) Descriptor() ([]byte, []int) { + return file_core_v1_core_proto_rawDescGZIP(), []int{0} +} + +func (x *RelationTuple) GetResourceAndRelation() *ObjectAndRelation { + if x != nil { + return x.ResourceAndRelation + } + return nil +} + +func (x *RelationTuple) GetSubject() *ObjectAndRelation { + if x != nil { + return x.Subject + } + return nil +} + +func (x *RelationTuple) GetCaveat() *ContextualizedCaveat { + if x != nil { + return x.Caveat + } + return nil +} + +func (x *RelationTuple) GetIntegrity() *RelationshipIntegrity { + if x != nil { + return x.Integrity + } + return nil +} + +func (x *RelationTuple) GetOptionalExpirationTime() *timestamppb.Timestamp { + if x != nil { + return x.OptionalExpirationTime + } + return nil +} + +type RelationshipIntegrity struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // * key_id is the key ID used to hash the tuple + KeyId string `protobuf:"bytes,1,opt,name=key_id,json=keyId,proto3" json:"key_id,omitempty"` + // * hash is the hash of the tuple + Hash []byte `protobuf:"bytes,2,opt,name=hash,proto3" json:"hash,omitempty"` + // * hashed_at is the timestamp when the tuple was hashed + HashedAt *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=hashed_at,json=hashedAt,proto3" json:"hashed_at,omitempty"` +} + +func (x *RelationshipIntegrity) Reset() { + *x = RelationshipIntegrity{} + if protoimpl.UnsafeEnabled { + mi := &file_core_v1_core_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *RelationshipIntegrity) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RelationshipIntegrity) ProtoMessage() {} + +func (x *RelationshipIntegrity) ProtoReflect() protoreflect.Message { + mi := &file_core_v1_core_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use RelationshipIntegrity.ProtoReflect.Descriptor instead. +func (*RelationshipIntegrity) Descriptor() ([]byte, []int) { + return file_core_v1_core_proto_rawDescGZIP(), []int{1} +} + +func (x *RelationshipIntegrity) GetKeyId() string { + if x != nil { + return x.KeyId + } + return "" +} + +func (x *RelationshipIntegrity) GetHash() []byte { + if x != nil { + return x.Hash + } + return nil +} + +func (x *RelationshipIntegrity) GetHashedAt() *timestamppb.Timestamp { + if x != nil { + return x.HashedAt + } + return nil +} + +// * +// ContextualizedCaveat represents a reference to a caveat used to by caveated tuples. +// The context are key-value pairs that will be injected at evaluation time. +type ContextualizedCaveat struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // * caveat_name is the name used in the schema for a stored caveat * + CaveatName string `protobuf:"bytes,1,opt,name=caveat_name,json=caveatName,proto3" json:"caveat_name,omitempty"` + // * context are arguments used as input during caveat evaluation with a predefined value * + Context *structpb.Struct `protobuf:"bytes,2,opt,name=context,proto3" json:"context,omitempty"` +} + +func (x *ContextualizedCaveat) Reset() { + *x = ContextualizedCaveat{} + if protoimpl.UnsafeEnabled { + mi := &file_core_v1_core_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ContextualizedCaveat) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ContextualizedCaveat) ProtoMessage() {} + +func (x *ContextualizedCaveat) ProtoReflect() protoreflect.Message { + mi := &file_core_v1_core_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ContextualizedCaveat.ProtoReflect.Descriptor instead. +func (*ContextualizedCaveat) Descriptor() ([]byte, []int) { + return file_core_v1_core_proto_rawDescGZIP(), []int{2} +} + +func (x *ContextualizedCaveat) GetCaveatName() string { + if x != nil { + return x.CaveatName + } + return "" +} + +func (x *ContextualizedCaveat) GetContext() *structpb.Struct { + if x != nil { + return x.Context + } + return nil +} + +type CaveatDefinition struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // * name represents the globally-unique identifier of the caveat * + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + // * serialized_expression is the byte representation of a caveat's logic + SerializedExpression []byte `protobuf:"bytes,2,opt,name=serialized_expression,json=serializedExpression,proto3" json:"serialized_expression,omitempty"` + // * parameters_and_types is a map from parameter name to its type + ParameterTypes map[string]*CaveatTypeReference `protobuf:"bytes,3,rep,name=parameter_types,json=parameterTypes,proto3" json:"parameter_types,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + // * metadata contains compiler metadata from schemas compiled into caveats + Metadata *Metadata `protobuf:"bytes,4,opt,name=metadata,proto3" json:"metadata,omitempty"` + // * source_position contains the position of the caveat in the source schema, if any + SourcePosition *SourcePosition `protobuf:"bytes,5,opt,name=source_position,json=sourcePosition,proto3" json:"source_position,omitempty"` +} + +func (x *CaveatDefinition) Reset() { + *x = CaveatDefinition{} + if protoimpl.UnsafeEnabled { + mi := &file_core_v1_core_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CaveatDefinition) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CaveatDefinition) ProtoMessage() {} + +func (x *CaveatDefinition) ProtoReflect() protoreflect.Message { + mi := &file_core_v1_core_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use CaveatDefinition.ProtoReflect.Descriptor instead. +func (*CaveatDefinition) Descriptor() ([]byte, []int) { + return file_core_v1_core_proto_rawDescGZIP(), []int{3} +} + +func (x *CaveatDefinition) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *CaveatDefinition) GetSerializedExpression() []byte { + if x != nil { + return x.SerializedExpression + } + return nil +} + +func (x *CaveatDefinition) GetParameterTypes() map[string]*CaveatTypeReference { + if x != nil { + return x.ParameterTypes + } + return nil +} + +func (x *CaveatDefinition) GetMetadata() *Metadata { + if x != nil { + return x.Metadata + } + return nil +} + +func (x *CaveatDefinition) GetSourcePosition() *SourcePosition { + if x != nil { + return x.SourcePosition + } + return nil +} + +type CaveatTypeReference struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + TypeName string `protobuf:"bytes,1,opt,name=type_name,json=typeName,proto3" json:"type_name,omitempty"` + ChildTypes []*CaveatTypeReference `protobuf:"bytes,2,rep,name=child_types,json=childTypes,proto3" json:"child_types,omitempty"` +} + +func (x *CaveatTypeReference) Reset() { + *x = CaveatTypeReference{} + if protoimpl.UnsafeEnabled { + mi := &file_core_v1_core_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CaveatTypeReference) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CaveatTypeReference) ProtoMessage() {} + +func (x *CaveatTypeReference) ProtoReflect() protoreflect.Message { + mi := &file_core_v1_core_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use CaveatTypeReference.ProtoReflect.Descriptor instead. +func (*CaveatTypeReference) Descriptor() ([]byte, []int) { + return file_core_v1_core_proto_rawDescGZIP(), []int{4} +} + +func (x *CaveatTypeReference) GetTypeName() string { + if x != nil { + return x.TypeName + } + return "" +} + +func (x *CaveatTypeReference) GetChildTypes() []*CaveatTypeReference { + if x != nil { + return x.ChildTypes + } + return nil +} + +type ObjectAndRelation struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // * namespace is the full namespace path for the referenced object + Namespace string `protobuf:"bytes,1,opt,name=namespace,proto3" json:"namespace,omitempty"` + // * object_id is the unique ID for the object within the namespace + ObjectId string `protobuf:"bytes,2,opt,name=object_id,json=objectId,proto3" json:"object_id,omitempty"` + // * relation is the name of the referenced relation or permission under the namespace + Relation string `protobuf:"bytes,3,opt,name=relation,proto3" json:"relation,omitempty"` +} + +func (x *ObjectAndRelation) Reset() { + *x = ObjectAndRelation{} + if protoimpl.UnsafeEnabled { + mi := &file_core_v1_core_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ObjectAndRelation) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ObjectAndRelation) ProtoMessage() {} + +func (x *ObjectAndRelation) ProtoReflect() protoreflect.Message { + mi := &file_core_v1_core_proto_msgTypes[5] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ObjectAndRelation.ProtoReflect.Descriptor instead. +func (*ObjectAndRelation) Descriptor() ([]byte, []int) { + return file_core_v1_core_proto_rawDescGZIP(), []int{5} +} + +func (x *ObjectAndRelation) GetNamespace() string { + if x != nil { + return x.Namespace + } + return "" +} + +func (x *ObjectAndRelation) GetObjectId() string { + if x != nil { + return x.ObjectId + } + return "" +} + +func (x *ObjectAndRelation) GetRelation() string { + if x != nil { + return x.Relation + } + return "" +} + +type RelationReference struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // * namespace is the full namespace path + Namespace string `protobuf:"bytes,1,opt,name=namespace,proto3" json:"namespace,omitempty"` + // * relation is the name of the referenced relation or permission under the namespace + Relation string `protobuf:"bytes,3,opt,name=relation,proto3" json:"relation,omitempty"` +} + +func (x *RelationReference) Reset() { + *x = RelationReference{} + if protoimpl.UnsafeEnabled { + mi := &file_core_v1_core_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *RelationReference) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RelationReference) ProtoMessage() {} + +func (x *RelationReference) ProtoReflect() protoreflect.Message { + mi := &file_core_v1_core_proto_msgTypes[6] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use RelationReference.ProtoReflect.Descriptor instead. +func (*RelationReference) Descriptor() ([]byte, []int) { + return file_core_v1_core_proto_rawDescGZIP(), []int{6} +} + +func (x *RelationReference) GetNamespace() string { + if x != nil { + return x.Namespace + } + return "" +} + +func (x *RelationReference) GetRelation() string { + if x != nil { + return x.Relation + } + return "" +} + +type Zookie struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Token string `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"` +} + +func (x *Zookie) Reset() { + *x = Zookie{} + if protoimpl.UnsafeEnabled { + mi := &file_core_v1_core_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Zookie) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Zookie) ProtoMessage() {} + +func (x *Zookie) ProtoReflect() protoreflect.Message { + mi := &file_core_v1_core_proto_msgTypes[7] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Zookie.ProtoReflect.Descriptor instead. +func (*Zookie) Descriptor() ([]byte, []int) { + return file_core_v1_core_proto_rawDescGZIP(), []int{7} +} + +func (x *Zookie) GetToken() string { + if x != nil { + return x.Token + } + return "" +} + +type RelationTupleUpdate struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Operation RelationTupleUpdate_Operation `protobuf:"varint,1,opt,name=operation,proto3,enum=core.v1.RelationTupleUpdate_Operation" json:"operation,omitempty"` + Tuple *RelationTuple `protobuf:"bytes,2,opt,name=tuple,proto3" json:"tuple,omitempty"` +} + +func (x *RelationTupleUpdate) Reset() { + *x = RelationTupleUpdate{} + if protoimpl.UnsafeEnabled { + mi := &file_core_v1_core_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *RelationTupleUpdate) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RelationTupleUpdate) ProtoMessage() {} + +func (x *RelationTupleUpdate) ProtoReflect() protoreflect.Message { + mi := &file_core_v1_core_proto_msgTypes[8] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use RelationTupleUpdate.ProtoReflect.Descriptor instead. +func (*RelationTupleUpdate) Descriptor() ([]byte, []int) { + return file_core_v1_core_proto_rawDescGZIP(), []int{8} +} + +func (x *RelationTupleUpdate) GetOperation() RelationTupleUpdate_Operation { + if x != nil { + return x.Operation + } + return RelationTupleUpdate_UNKNOWN +} + +func (x *RelationTupleUpdate) GetTuple() *RelationTuple { + if x != nil { + return x.Tuple + } + return nil +} + +type RelationTupleTreeNode struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Types that are assignable to NodeType: + // + // *RelationTupleTreeNode_IntermediateNode + // *RelationTupleTreeNode_LeafNode + NodeType isRelationTupleTreeNode_NodeType `protobuf_oneof:"node_type"` + Expanded *ObjectAndRelation `protobuf:"bytes,3,opt,name=expanded,proto3" json:"expanded,omitempty"` + CaveatExpression *CaveatExpression `protobuf:"bytes,4,opt,name=caveat_expression,json=caveatExpression,proto3" json:"caveat_expression,omitempty"` +} + +func (x *RelationTupleTreeNode) Reset() { + *x = RelationTupleTreeNode{} + if protoimpl.UnsafeEnabled { + mi := &file_core_v1_core_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *RelationTupleTreeNode) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RelationTupleTreeNode) ProtoMessage() {} + +func (x *RelationTupleTreeNode) ProtoReflect() protoreflect.Message { + mi := &file_core_v1_core_proto_msgTypes[9] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use RelationTupleTreeNode.ProtoReflect.Descriptor instead. +func (*RelationTupleTreeNode) Descriptor() ([]byte, []int) { + return file_core_v1_core_proto_rawDescGZIP(), []int{9} +} + +func (m *RelationTupleTreeNode) GetNodeType() isRelationTupleTreeNode_NodeType { + if m != nil { + return m.NodeType + } + return nil +} + +func (x *RelationTupleTreeNode) GetIntermediateNode() *SetOperationUserset { + if x, ok := x.GetNodeType().(*RelationTupleTreeNode_IntermediateNode); ok { + return x.IntermediateNode + } + return nil +} + +func (x *RelationTupleTreeNode) GetLeafNode() *DirectSubjects { + if x, ok := x.GetNodeType().(*RelationTupleTreeNode_LeafNode); ok { + return x.LeafNode + } + return nil +} + +func (x *RelationTupleTreeNode) GetExpanded() *ObjectAndRelation { + if x != nil { + return x.Expanded + } + return nil +} + +func (x *RelationTupleTreeNode) GetCaveatExpression() *CaveatExpression { + if x != nil { + return x.CaveatExpression + } + return nil +} + +type isRelationTupleTreeNode_NodeType interface { + isRelationTupleTreeNode_NodeType() +} + +type RelationTupleTreeNode_IntermediateNode struct { + IntermediateNode *SetOperationUserset `protobuf:"bytes,1,opt,name=intermediate_node,json=intermediateNode,proto3,oneof"` +} + +type RelationTupleTreeNode_LeafNode struct { + LeafNode *DirectSubjects `protobuf:"bytes,2,opt,name=leaf_node,json=leafNode,proto3,oneof"` +} + +func (*RelationTupleTreeNode_IntermediateNode) isRelationTupleTreeNode_NodeType() {} + +func (*RelationTupleTreeNode_LeafNode) isRelationTupleTreeNode_NodeType() {} + +type SetOperationUserset struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Operation SetOperationUserset_Operation `protobuf:"varint,1,opt,name=operation,proto3,enum=core.v1.SetOperationUserset_Operation" json:"operation,omitempty"` + ChildNodes []*RelationTupleTreeNode `protobuf:"bytes,2,rep,name=child_nodes,json=childNodes,proto3" json:"child_nodes,omitempty"` +} + +func (x *SetOperationUserset) Reset() { + *x = SetOperationUserset{} + if protoimpl.UnsafeEnabled { + mi := &file_core_v1_core_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *SetOperationUserset) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SetOperationUserset) ProtoMessage() {} + +func (x *SetOperationUserset) ProtoReflect() protoreflect.Message { + mi := &file_core_v1_core_proto_msgTypes[10] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SetOperationUserset.ProtoReflect.Descriptor instead. +func (*SetOperationUserset) Descriptor() ([]byte, []int) { + return file_core_v1_core_proto_rawDescGZIP(), []int{10} +} + +func (x *SetOperationUserset) GetOperation() SetOperationUserset_Operation { + if x != nil { + return x.Operation + } + return SetOperationUserset_INVALID +} + +func (x *SetOperationUserset) GetChildNodes() []*RelationTupleTreeNode { + if x != nil { + return x.ChildNodes + } + return nil +} + +type DirectSubject struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Subject *ObjectAndRelation `protobuf:"bytes,1,opt,name=subject,proto3" json:"subject,omitempty"` + CaveatExpression *CaveatExpression `protobuf:"bytes,2,opt,name=caveat_expression,json=caveatExpression,proto3" json:"caveat_expression,omitempty"` +} + +func (x *DirectSubject) Reset() { + *x = DirectSubject{} + if protoimpl.UnsafeEnabled { + mi := &file_core_v1_core_proto_msgTypes[11] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DirectSubject) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DirectSubject) ProtoMessage() {} + +func (x *DirectSubject) ProtoReflect() protoreflect.Message { + mi := &file_core_v1_core_proto_msgTypes[11] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DirectSubject.ProtoReflect.Descriptor instead. +func (*DirectSubject) Descriptor() ([]byte, []int) { + return file_core_v1_core_proto_rawDescGZIP(), []int{11} +} + +func (x *DirectSubject) GetSubject() *ObjectAndRelation { + if x != nil { + return x.Subject + } + return nil +} + +func (x *DirectSubject) GetCaveatExpression() *CaveatExpression { + if x != nil { + return x.CaveatExpression + } + return nil +} + +type DirectSubjects struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Subjects []*DirectSubject `protobuf:"bytes,1,rep,name=subjects,proto3" json:"subjects,omitempty"` +} + +func (x *DirectSubjects) Reset() { + *x = DirectSubjects{} + if protoimpl.UnsafeEnabled { + mi := &file_core_v1_core_proto_msgTypes[12] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DirectSubjects) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DirectSubjects) ProtoMessage() {} + +func (x *DirectSubjects) ProtoReflect() protoreflect.Message { + mi := &file_core_v1_core_proto_msgTypes[12] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DirectSubjects.ProtoReflect.Descriptor instead. +func (*DirectSubjects) Descriptor() ([]byte, []int) { + return file_core_v1_core_proto_rawDescGZIP(), []int{12} +} + +func (x *DirectSubjects) GetSubjects() []*DirectSubject { + if x != nil { + return x.Subjects + } + return nil +} + +// * +// Metadata is compiler metadata added to namespace definitions, such as doc comments and +// relation kinds. +type Metadata struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + MetadataMessage []*anypb.Any `protobuf:"bytes,1,rep,name=metadata_message,json=metadataMessage,proto3" json:"metadata_message,omitempty"` +} + +func (x *Metadata) Reset() { + *x = Metadata{} + if protoimpl.UnsafeEnabled { + mi := &file_core_v1_core_proto_msgTypes[13] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Metadata) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Metadata) ProtoMessage() {} + +func (x *Metadata) ProtoReflect() protoreflect.Message { + mi := &file_core_v1_core_proto_msgTypes[13] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Metadata.ProtoReflect.Descriptor instead. +func (*Metadata) Descriptor() ([]byte, []int) { + return file_core_v1_core_proto_rawDescGZIP(), []int{13} +} + +func (x *Metadata) GetMetadataMessage() []*anypb.Any { + if x != nil { + return x.MetadataMessage + } + return nil +} + +// * +// NamespaceDefinition represents a single definition of an object type +type NamespaceDefinition struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // * name is the unique for the namespace, including prefixes (which are optional) + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + // * relation contains the relations and permissions defined in the namespace + Relation []*Relation `protobuf:"bytes,2,rep,name=relation,proto3" json:"relation,omitempty"` + // * metadata contains compiler metadata from schemas compiled into namespaces + Metadata *Metadata `protobuf:"bytes,3,opt,name=metadata,proto3" json:"metadata,omitempty"` + // * source_position contains the position of the namespace in the source schema, if any + SourcePosition *SourcePosition `protobuf:"bytes,4,opt,name=source_position,json=sourcePosition,proto3" json:"source_position,omitempty"` +} + +func (x *NamespaceDefinition) Reset() { + *x = NamespaceDefinition{} + if protoimpl.UnsafeEnabled { + mi := &file_core_v1_core_proto_msgTypes[14] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *NamespaceDefinition) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*NamespaceDefinition) ProtoMessage() {} + +func (x *NamespaceDefinition) ProtoReflect() protoreflect.Message { + mi := &file_core_v1_core_proto_msgTypes[14] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use NamespaceDefinition.ProtoReflect.Descriptor instead. +func (*NamespaceDefinition) Descriptor() ([]byte, []int) { + return file_core_v1_core_proto_rawDescGZIP(), []int{14} +} + +func (x *NamespaceDefinition) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *NamespaceDefinition) GetRelation() []*Relation { + if x != nil { + return x.Relation + } + return nil +} + +func (x *NamespaceDefinition) GetMetadata() *Metadata { + if x != nil { + return x.Metadata + } + return nil +} + +func (x *NamespaceDefinition) GetSourcePosition() *SourcePosition { + if x != nil { + return x.SourcePosition + } + return nil +} + +// * +// Relation represents the definition of a relation or permission under a namespace. +type Relation struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // * name is the full name for the relation or permission + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + // * userset_rewrite, if specified, is the rewrite for computing the value of the permission. + UsersetRewrite *UsersetRewrite `protobuf:"bytes,2,opt,name=userset_rewrite,json=usersetRewrite,proto3" json:"userset_rewrite,omitempty"` + // * + // type_information, if specified, is the list of allowed object types that can appear in this + // relation + TypeInformation *TypeInformation `protobuf:"bytes,3,opt,name=type_information,json=typeInformation,proto3" json:"type_information,omitempty"` + // * metadata contains compiler metadata from schemas compiled into namespaces + Metadata *Metadata `protobuf:"bytes,4,opt,name=metadata,proto3" json:"metadata,omitempty"` + // * source_position contains the position of the relation in the source schema, if any + SourcePosition *SourcePosition `protobuf:"bytes,5,opt,name=source_position,json=sourcePosition,proto3" json:"source_position,omitempty"` + AliasingRelation string `protobuf:"bytes,6,opt,name=aliasing_relation,json=aliasingRelation,proto3" json:"aliasing_relation,omitempty"` + CanonicalCacheKey string `protobuf:"bytes,7,opt,name=canonical_cache_key,json=canonicalCacheKey,proto3" json:"canonical_cache_key,omitempty"` +} + +func (x *Relation) Reset() { + *x = Relation{} + if protoimpl.UnsafeEnabled { + mi := &file_core_v1_core_proto_msgTypes[15] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Relation) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Relation) ProtoMessage() {} + +func (x *Relation) ProtoReflect() protoreflect.Message { + mi := &file_core_v1_core_proto_msgTypes[15] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Relation.ProtoReflect.Descriptor instead. +func (*Relation) Descriptor() ([]byte, []int) { + return file_core_v1_core_proto_rawDescGZIP(), []int{15} +} + +func (x *Relation) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *Relation) GetUsersetRewrite() *UsersetRewrite { + if x != nil { + return x.UsersetRewrite + } + return nil +} + +func (x *Relation) GetTypeInformation() *TypeInformation { + if x != nil { + return x.TypeInformation + } + return nil +} + +func (x *Relation) GetMetadata() *Metadata { + if x != nil { + return x.Metadata + } + return nil +} + +func (x *Relation) GetSourcePosition() *SourcePosition { + if x != nil { + return x.SourcePosition + } + return nil +} + +func (x *Relation) GetAliasingRelation() string { + if x != nil { + return x.AliasingRelation + } + return "" +} + +func (x *Relation) GetCanonicalCacheKey() string { + if x != nil { + return x.CanonicalCacheKey + } + return "" +} + +// * +// ReachabilityGraph is a serialized form of a reachability graph, representing how a relation can +// be reached from one or more subject types. +// +// It defines a "reverse" data flow graph, starting at a subject type, and providing all the +// entrypoints where that subject type can be found leading to the decorated relation. +// +// For example, given the schema: +// ``` +// +// definition user {} +// +// definition organization { +// relation admin: user +// } +// +// definition resource { +// relation org: organization +// relation viewer: user +// relation owner: user +// permission view = viewer + owner + org->admin +// } +// +// ``` +// +// The reachability graph for `viewer` and the other relations will have entrypoints for each +// subject type found for those relations. +// +// The full reachability graph for the `view` relation will have three entrypoints, representing: +// 1. resource#viewer (computed_userset) +// 2. resource#owner (computed_userset) +// 3. organization#admin (tupleset_to_userset) +type ReachabilityGraph struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // * + // entrypoints_by_subject_type provides all entrypoints by subject *type*, representing wildcards. + // The keys of the map are the full path(s) for the namespace(s) referenced by reachable wildcards + EntrypointsBySubjectType map[string]*ReachabilityEntrypoints `protobuf:"bytes,1,rep,name=entrypoints_by_subject_type,json=entrypointsBySubjectType,proto3" json:"entrypoints_by_subject_type,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + // * + // entrypoints_by_subject_relation provides all entrypoints by subject type+relation. + // The keys of the map are of the form `namespace_path#relation_name` + EntrypointsBySubjectRelation map[string]*ReachabilityEntrypoints `protobuf:"bytes,2,rep,name=entrypoints_by_subject_relation,json=entrypointsBySubjectRelation,proto3" json:"entrypoints_by_subject_relation,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` +} + +func (x *ReachabilityGraph) Reset() { + *x = ReachabilityGraph{} + if protoimpl.UnsafeEnabled { + mi := &file_core_v1_core_proto_msgTypes[16] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ReachabilityGraph) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ReachabilityGraph) ProtoMessage() {} + +func (x *ReachabilityGraph) ProtoReflect() protoreflect.Message { + mi := &file_core_v1_core_proto_msgTypes[16] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ReachabilityGraph.ProtoReflect.Descriptor instead. +func (*ReachabilityGraph) Descriptor() ([]byte, []int) { + return file_core_v1_core_proto_rawDescGZIP(), []int{16} +} + +func (x *ReachabilityGraph) GetEntrypointsBySubjectType() map[string]*ReachabilityEntrypoints { + if x != nil { + return x.EntrypointsBySubjectType + } + return nil +} + +func (x *ReachabilityGraph) GetEntrypointsBySubjectRelation() map[string]*ReachabilityEntrypoints { + if x != nil { + return x.EntrypointsBySubjectRelation + } + return nil +} + +// * +// ReachabilityEntrypoints represents all the entrypoints for a specific subject type or subject +// relation into the reachability graph for a particular target relation. +type ReachabilityEntrypoints struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // * + // entrypoints are the entrypoints found. + Entrypoints []*ReachabilityEntrypoint `protobuf:"bytes,1,rep,name=entrypoints,proto3" json:"entrypoints,omitempty"` + // * + // subject_type, if specified, is the type of subjects to which the entrypoint(s) apply. A + // subject type is only set for wildcards. + SubjectType string `protobuf:"bytes,2,opt,name=subject_type,json=subjectType,proto3" json:"subject_type,omitempty"` + // * + // subject_relation, if specified, is the type and relation of subjects to which the + // entrypoint(s) apply. + SubjectRelation *RelationReference `protobuf:"bytes,3,opt,name=subject_relation,json=subjectRelation,proto3" json:"subject_relation,omitempty"` +} + +func (x *ReachabilityEntrypoints) Reset() { + *x = ReachabilityEntrypoints{} + if protoimpl.UnsafeEnabled { + mi := &file_core_v1_core_proto_msgTypes[17] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ReachabilityEntrypoints) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ReachabilityEntrypoints) ProtoMessage() {} + +func (x *ReachabilityEntrypoints) ProtoReflect() protoreflect.Message { + mi := &file_core_v1_core_proto_msgTypes[17] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ReachabilityEntrypoints.ProtoReflect.Descriptor instead. +func (*ReachabilityEntrypoints) Descriptor() ([]byte, []int) { + return file_core_v1_core_proto_rawDescGZIP(), []int{17} +} + +func (x *ReachabilityEntrypoints) GetEntrypoints() []*ReachabilityEntrypoint { + if x != nil { + return x.Entrypoints + } + return nil +} + +func (x *ReachabilityEntrypoints) GetSubjectType() string { + if x != nil { + return x.SubjectType + } + return "" +} + +func (x *ReachabilityEntrypoints) GetSubjectRelation() *RelationReference { + if x != nil { + return x.SubjectRelation + } + return nil +} + +// * +// ReachabilityEntrypoint represents a single entrypoint for a specific subject type or subject +// relation into the reachability graph for a particular target relation. +type ReachabilityEntrypoint struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // * + // kind is the kind of the entrypoint. + Kind ReachabilityEntrypoint_ReachabilityEntrypointKind `protobuf:"varint,1,opt,name=kind,proto3,enum=core.v1.ReachabilityEntrypoint_ReachabilityEntrypointKind" json:"kind,omitempty"` + // * + // target_relation is the relation on which the entrypoint exists. + TargetRelation *RelationReference `protobuf:"bytes,2,opt,name=target_relation,json=targetRelation,proto3" json:"target_relation,omitempty"` + // * + // result_status contains the status of objects found for this entrypoint as direct results for + // the parent relation/permission. + ResultStatus ReachabilityEntrypoint_EntrypointResultStatus `protobuf:"varint,4,opt,name=result_status,json=resultStatus,proto3,enum=core.v1.ReachabilityEntrypoint_EntrypointResultStatus" json:"result_status,omitempty"` + // * + // tupleset_relation is the name of the tupleset relation on the TupleToUserset this entrypoint + // represents, if applicable. + TuplesetRelation string `protobuf:"bytes,5,opt,name=tupleset_relation,json=tuplesetRelation,proto3" json:"tupleset_relation,omitempty"` + // * + // computed_userset_relation is the name of the computed userset relation on the ComputedUserset + // this entrypoint represents, if applicable. + ComputedUsersetRelation string `protobuf:"bytes,6,opt,name=computed_userset_relation,json=computedUsersetRelation,proto3" json:"computed_userset_relation,omitempty"` +} + +func (x *ReachabilityEntrypoint) Reset() { + *x = ReachabilityEntrypoint{} + if protoimpl.UnsafeEnabled { + mi := &file_core_v1_core_proto_msgTypes[18] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ReachabilityEntrypoint) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ReachabilityEntrypoint) ProtoMessage() {} + +func (x *ReachabilityEntrypoint) ProtoReflect() protoreflect.Message { + mi := &file_core_v1_core_proto_msgTypes[18] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ReachabilityEntrypoint.ProtoReflect.Descriptor instead. +func (*ReachabilityEntrypoint) Descriptor() ([]byte, []int) { + return file_core_v1_core_proto_rawDescGZIP(), []int{18} +} + +func (x *ReachabilityEntrypoint) GetKind() ReachabilityEntrypoint_ReachabilityEntrypointKind { + if x != nil { + return x.Kind + } + return ReachabilityEntrypoint_RELATION_ENTRYPOINT +} + +func (x *ReachabilityEntrypoint) GetTargetRelation() *RelationReference { + if x != nil { + return x.TargetRelation + } + return nil +} + +func (x *ReachabilityEntrypoint) GetResultStatus() ReachabilityEntrypoint_EntrypointResultStatus { + if x != nil { + return x.ResultStatus + } + return ReachabilityEntrypoint_REACHABLE_CONDITIONAL_RESULT +} + +func (x *ReachabilityEntrypoint) GetTuplesetRelation() string { + if x != nil { + return x.TuplesetRelation + } + return "" +} + +func (x *ReachabilityEntrypoint) GetComputedUsersetRelation() string { + if x != nil { + return x.ComputedUsersetRelation + } + return "" +} + +// * +// TypeInformation defines the allowed types for a relation. +type TypeInformation struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // * + // allowed_direct_relations are those relation types allowed to be placed into a relation, + // e.g. the types of subjects allowed when a relationship is written to the relation + AllowedDirectRelations []*AllowedRelation `protobuf:"bytes,1,rep,name=allowed_direct_relations,json=allowedDirectRelations,proto3" json:"allowed_direct_relations,omitempty"` +} + +func (x *TypeInformation) Reset() { + *x = TypeInformation{} + if protoimpl.UnsafeEnabled { + mi := &file_core_v1_core_proto_msgTypes[19] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *TypeInformation) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*TypeInformation) ProtoMessage() {} + +func (x *TypeInformation) ProtoReflect() protoreflect.Message { + mi := &file_core_v1_core_proto_msgTypes[19] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use TypeInformation.ProtoReflect.Descriptor instead. +func (*TypeInformation) Descriptor() ([]byte, []int) { + return file_core_v1_core_proto_rawDescGZIP(), []int{19} +} + +func (x *TypeInformation) GetAllowedDirectRelations() []*AllowedRelation { + if x != nil { + return x.AllowedDirectRelations + } + return nil +} + +// * +// AllowedRelation is an allowed type of a relation when used as a subject. +type AllowedRelation struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // * namespace is the full namespace path of the allowed object type + Namespace string `protobuf:"bytes,1,opt,name=namespace,proto3" json:"namespace,omitempty"` + // * + // relation_or_wildcard indicates the relation for the objects, or a wildcard. + // + // Types that are assignable to RelationOrWildcard: + // + // *AllowedRelation_Relation + // *AllowedRelation_PublicWildcard_ + RelationOrWildcard isAllowedRelation_RelationOrWildcard `protobuf_oneof:"relation_or_wildcard"` + // * source_position contains the position of the type in the source schema, if any + SourcePosition *SourcePosition `protobuf:"bytes,5,opt,name=source_position,json=sourcePosition,proto3" json:"source_position,omitempty"` + // * + // required_caveat defines the required caveat on this relation. + RequiredCaveat *AllowedCaveat `protobuf:"bytes,6,opt,name=required_caveat,json=requiredCaveat,proto3" json:"required_caveat,omitempty"` + // * + // required_expiration defines the required expiration on this relation. + RequiredExpiration *ExpirationTrait `protobuf:"bytes,7,opt,name=required_expiration,json=requiredExpiration,proto3" json:"required_expiration,omitempty"` +} + +func (x *AllowedRelation) Reset() { + *x = AllowedRelation{} + if protoimpl.UnsafeEnabled { + mi := &file_core_v1_core_proto_msgTypes[20] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *AllowedRelation) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*AllowedRelation) ProtoMessage() {} + +func (x *AllowedRelation) ProtoReflect() protoreflect.Message { + mi := &file_core_v1_core_proto_msgTypes[20] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use AllowedRelation.ProtoReflect.Descriptor instead. +func (*AllowedRelation) Descriptor() ([]byte, []int) { + return file_core_v1_core_proto_rawDescGZIP(), []int{20} +} + +func (x *AllowedRelation) GetNamespace() string { + if x != nil { + return x.Namespace + } + return "" +} + +func (m *AllowedRelation) GetRelationOrWildcard() isAllowedRelation_RelationOrWildcard { + if m != nil { + return m.RelationOrWildcard + } + return nil +} + +func (x *AllowedRelation) GetRelation() string { + if x, ok := x.GetRelationOrWildcard().(*AllowedRelation_Relation); ok { + return x.Relation + } + return "" +} + +func (x *AllowedRelation) GetPublicWildcard() *AllowedRelation_PublicWildcard { + if x, ok := x.GetRelationOrWildcard().(*AllowedRelation_PublicWildcard_); ok { + return x.PublicWildcard + } + return nil +} + +func (x *AllowedRelation) GetSourcePosition() *SourcePosition { + if x != nil { + return x.SourcePosition + } + return nil +} + +func (x *AllowedRelation) GetRequiredCaveat() *AllowedCaveat { + if x != nil { + return x.RequiredCaveat + } + return nil +} + +func (x *AllowedRelation) GetRequiredExpiration() *ExpirationTrait { + if x != nil { + return x.RequiredExpiration + } + return nil +} + +type isAllowedRelation_RelationOrWildcard interface { + isAllowedRelation_RelationOrWildcard() +} + +type AllowedRelation_Relation struct { + Relation string `protobuf:"bytes,3,opt,name=relation,proto3,oneof"` +} + +type AllowedRelation_PublicWildcard_ struct { + PublicWildcard *AllowedRelation_PublicWildcard `protobuf:"bytes,4,opt,name=public_wildcard,json=publicWildcard,proto3,oneof"` +} + +func (*AllowedRelation_Relation) isAllowedRelation_RelationOrWildcard() {} + +func (*AllowedRelation_PublicWildcard_) isAllowedRelation_RelationOrWildcard() {} + +// * +// ExpirationTrait is an expiration trait of a relation. +type ExpirationTrait struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *ExpirationTrait) Reset() { + *x = ExpirationTrait{} + if protoimpl.UnsafeEnabled { + mi := &file_core_v1_core_proto_msgTypes[21] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ExpirationTrait) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ExpirationTrait) ProtoMessage() {} + +func (x *ExpirationTrait) ProtoReflect() protoreflect.Message { + mi := &file_core_v1_core_proto_msgTypes[21] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ExpirationTrait.ProtoReflect.Descriptor instead. +func (*ExpirationTrait) Descriptor() ([]byte, []int) { + return file_core_v1_core_proto_rawDescGZIP(), []int{21} +} + +// * +// AllowedCaveat is an allowed caveat of a relation. +type AllowedCaveat struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // * + // caveat_name is the name of the allowed caveat. + CaveatName string `protobuf:"bytes,1,opt,name=caveat_name,json=caveatName,proto3" json:"caveat_name,omitempty"` +} + +func (x *AllowedCaveat) Reset() { + *x = AllowedCaveat{} + if protoimpl.UnsafeEnabled { + mi := &file_core_v1_core_proto_msgTypes[22] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *AllowedCaveat) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*AllowedCaveat) ProtoMessage() {} + +func (x *AllowedCaveat) ProtoReflect() protoreflect.Message { + mi := &file_core_v1_core_proto_msgTypes[22] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use AllowedCaveat.ProtoReflect.Descriptor instead. +func (*AllowedCaveat) Descriptor() ([]byte, []int) { + return file_core_v1_core_proto_rawDescGZIP(), []int{22} +} + +func (x *AllowedCaveat) GetCaveatName() string { + if x != nil { + return x.CaveatName + } + return "" +} + +type UsersetRewrite struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Types that are assignable to RewriteOperation: + // + // *UsersetRewrite_Union + // *UsersetRewrite_Intersection + // *UsersetRewrite_Exclusion + RewriteOperation isUsersetRewrite_RewriteOperation `protobuf_oneof:"rewrite_operation"` + SourcePosition *SourcePosition `protobuf:"bytes,4,opt,name=source_position,json=sourcePosition,proto3" json:"source_position,omitempty"` +} + +func (x *UsersetRewrite) Reset() { + *x = UsersetRewrite{} + if protoimpl.UnsafeEnabled { + mi := &file_core_v1_core_proto_msgTypes[23] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *UsersetRewrite) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UsersetRewrite) ProtoMessage() {} + +func (x *UsersetRewrite) ProtoReflect() protoreflect.Message { + mi := &file_core_v1_core_proto_msgTypes[23] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use UsersetRewrite.ProtoReflect.Descriptor instead. +func (*UsersetRewrite) Descriptor() ([]byte, []int) { + return file_core_v1_core_proto_rawDescGZIP(), []int{23} +} + +func (m *UsersetRewrite) GetRewriteOperation() isUsersetRewrite_RewriteOperation { + if m != nil { + return m.RewriteOperation + } + return nil +} + +func (x *UsersetRewrite) GetUnion() *SetOperation { + if x, ok := x.GetRewriteOperation().(*UsersetRewrite_Union); ok { + return x.Union + } + return nil +} + +func (x *UsersetRewrite) GetIntersection() *SetOperation { + if x, ok := x.GetRewriteOperation().(*UsersetRewrite_Intersection); ok { + return x.Intersection + } + return nil +} + +func (x *UsersetRewrite) GetExclusion() *SetOperation { + if x, ok := x.GetRewriteOperation().(*UsersetRewrite_Exclusion); ok { + return x.Exclusion + } + return nil +} + +func (x *UsersetRewrite) GetSourcePosition() *SourcePosition { + if x != nil { + return x.SourcePosition + } + return nil +} + +type isUsersetRewrite_RewriteOperation interface { + isUsersetRewrite_RewriteOperation() +} + +type UsersetRewrite_Union struct { + Union *SetOperation `protobuf:"bytes,1,opt,name=union,proto3,oneof"` +} + +type UsersetRewrite_Intersection struct { + Intersection *SetOperation `protobuf:"bytes,2,opt,name=intersection,proto3,oneof"` +} + +type UsersetRewrite_Exclusion struct { + Exclusion *SetOperation `protobuf:"bytes,3,opt,name=exclusion,proto3,oneof"` +} + +func (*UsersetRewrite_Union) isUsersetRewrite_RewriteOperation() {} + +func (*UsersetRewrite_Intersection) isUsersetRewrite_RewriteOperation() {} + +func (*UsersetRewrite_Exclusion) isUsersetRewrite_RewriteOperation() {} + +type SetOperation struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Child []*SetOperation_Child `protobuf:"bytes,1,rep,name=child,proto3" json:"child,omitempty"` +} + +func (x *SetOperation) Reset() { + *x = SetOperation{} + if protoimpl.UnsafeEnabled { + mi := &file_core_v1_core_proto_msgTypes[24] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *SetOperation) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SetOperation) ProtoMessage() {} + +func (x *SetOperation) ProtoReflect() protoreflect.Message { + mi := &file_core_v1_core_proto_msgTypes[24] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SetOperation.ProtoReflect.Descriptor instead. +func (*SetOperation) Descriptor() ([]byte, []int) { + return file_core_v1_core_proto_rawDescGZIP(), []int{24} +} + +func (x *SetOperation) GetChild() []*SetOperation_Child { + if x != nil { + return x.Child + } + return nil +} + +type TupleToUserset struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Tupleset *TupleToUserset_Tupleset `protobuf:"bytes,1,opt,name=tupleset,proto3" json:"tupleset,omitempty"` + ComputedUserset *ComputedUserset `protobuf:"bytes,2,opt,name=computed_userset,json=computedUserset,proto3" json:"computed_userset,omitempty"` + SourcePosition *SourcePosition `protobuf:"bytes,3,opt,name=source_position,json=sourcePosition,proto3" json:"source_position,omitempty"` +} + +func (x *TupleToUserset) Reset() { + *x = TupleToUserset{} + if protoimpl.UnsafeEnabled { + mi := &file_core_v1_core_proto_msgTypes[25] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *TupleToUserset) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*TupleToUserset) ProtoMessage() {} + +func (x *TupleToUserset) ProtoReflect() protoreflect.Message { + mi := &file_core_v1_core_proto_msgTypes[25] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use TupleToUserset.ProtoReflect.Descriptor instead. +func (*TupleToUserset) Descriptor() ([]byte, []int) { + return file_core_v1_core_proto_rawDescGZIP(), []int{25} +} + +func (x *TupleToUserset) GetTupleset() *TupleToUserset_Tupleset { + if x != nil { + return x.Tupleset + } + return nil +} + +func (x *TupleToUserset) GetComputedUserset() *ComputedUserset { + if x != nil { + return x.ComputedUserset + } + return nil +} + +func (x *TupleToUserset) GetSourcePosition() *SourcePosition { + if x != nil { + return x.SourcePosition + } + return nil +} + +type FunctionedTupleToUserset struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Function FunctionedTupleToUserset_Function `protobuf:"varint,1,opt,name=function,proto3,enum=core.v1.FunctionedTupleToUserset_Function" json:"function,omitempty"` + Tupleset *FunctionedTupleToUserset_Tupleset `protobuf:"bytes,2,opt,name=tupleset,proto3" json:"tupleset,omitempty"` + ComputedUserset *ComputedUserset `protobuf:"bytes,3,opt,name=computed_userset,json=computedUserset,proto3" json:"computed_userset,omitempty"` + SourcePosition *SourcePosition `protobuf:"bytes,4,opt,name=source_position,json=sourcePosition,proto3" json:"source_position,omitempty"` +} + +func (x *FunctionedTupleToUserset) Reset() { + *x = FunctionedTupleToUserset{} + if protoimpl.UnsafeEnabled { + mi := &file_core_v1_core_proto_msgTypes[26] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *FunctionedTupleToUserset) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*FunctionedTupleToUserset) ProtoMessage() {} + +func (x *FunctionedTupleToUserset) ProtoReflect() protoreflect.Message { + mi := &file_core_v1_core_proto_msgTypes[26] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use FunctionedTupleToUserset.ProtoReflect.Descriptor instead. +func (*FunctionedTupleToUserset) Descriptor() ([]byte, []int) { + return file_core_v1_core_proto_rawDescGZIP(), []int{26} +} + +func (x *FunctionedTupleToUserset) GetFunction() FunctionedTupleToUserset_Function { + if x != nil { + return x.Function + } + return FunctionedTupleToUserset_FUNCTION_UNSPECIFIED +} + +func (x *FunctionedTupleToUserset) GetTupleset() *FunctionedTupleToUserset_Tupleset { + if x != nil { + return x.Tupleset + } + return nil +} + +func (x *FunctionedTupleToUserset) GetComputedUserset() *ComputedUserset { + if x != nil { + return x.ComputedUserset + } + return nil +} + +func (x *FunctionedTupleToUserset) GetSourcePosition() *SourcePosition { + if x != nil { + return x.SourcePosition + } + return nil +} + +type ComputedUserset struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Object ComputedUserset_Object `protobuf:"varint,1,opt,name=object,proto3,enum=core.v1.ComputedUserset_Object" json:"object,omitempty"` + Relation string `protobuf:"bytes,2,opt,name=relation,proto3" json:"relation,omitempty"` + SourcePosition *SourcePosition `protobuf:"bytes,3,opt,name=source_position,json=sourcePosition,proto3" json:"source_position,omitempty"` +} + +func (x *ComputedUserset) Reset() { + *x = ComputedUserset{} + if protoimpl.UnsafeEnabled { + mi := &file_core_v1_core_proto_msgTypes[27] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ComputedUserset) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ComputedUserset) ProtoMessage() {} + +func (x *ComputedUserset) ProtoReflect() protoreflect.Message { + mi := &file_core_v1_core_proto_msgTypes[27] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ComputedUserset.ProtoReflect.Descriptor instead. +func (*ComputedUserset) Descriptor() ([]byte, []int) { + return file_core_v1_core_proto_rawDescGZIP(), []int{27} +} + +func (x *ComputedUserset) GetObject() ComputedUserset_Object { + if x != nil { + return x.Object + } + return ComputedUserset_TUPLE_OBJECT +} + +func (x *ComputedUserset) GetRelation() string { + if x != nil { + return x.Relation + } + return "" +} + +func (x *ComputedUserset) GetSourcePosition() *SourcePosition { + if x != nil { + return x.SourcePosition + } + return nil +} + +type SourcePosition struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + ZeroIndexedLineNumber uint64 `protobuf:"varint,1,opt,name=zero_indexed_line_number,json=zeroIndexedLineNumber,proto3" json:"zero_indexed_line_number,omitempty"` + ZeroIndexedColumnPosition uint64 `protobuf:"varint,2,opt,name=zero_indexed_column_position,json=zeroIndexedColumnPosition,proto3" json:"zero_indexed_column_position,omitempty"` +} + +func (x *SourcePosition) Reset() { + *x = SourcePosition{} + if protoimpl.UnsafeEnabled { + mi := &file_core_v1_core_proto_msgTypes[28] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *SourcePosition) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SourcePosition) ProtoMessage() {} + +func (x *SourcePosition) ProtoReflect() protoreflect.Message { + mi := &file_core_v1_core_proto_msgTypes[28] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SourcePosition.ProtoReflect.Descriptor instead. +func (*SourcePosition) Descriptor() ([]byte, []int) { + return file_core_v1_core_proto_rawDescGZIP(), []int{28} +} + +func (x *SourcePosition) GetZeroIndexedLineNumber() uint64 { + if x != nil { + return x.ZeroIndexedLineNumber + } + return 0 +} + +func (x *SourcePosition) GetZeroIndexedColumnPosition() uint64 { + if x != nil { + return x.ZeroIndexedColumnPosition + } + return 0 +} + +type CaveatExpression struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Types that are assignable to OperationOrCaveat: + // + // *CaveatExpression_Operation + // *CaveatExpression_Caveat + OperationOrCaveat isCaveatExpression_OperationOrCaveat `protobuf_oneof:"operation_or_caveat"` +} + +func (x *CaveatExpression) Reset() { + *x = CaveatExpression{} + if protoimpl.UnsafeEnabled { + mi := &file_core_v1_core_proto_msgTypes[29] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CaveatExpression) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CaveatExpression) ProtoMessage() {} + +func (x *CaveatExpression) ProtoReflect() protoreflect.Message { + mi := &file_core_v1_core_proto_msgTypes[29] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use CaveatExpression.ProtoReflect.Descriptor instead. +func (*CaveatExpression) Descriptor() ([]byte, []int) { + return file_core_v1_core_proto_rawDescGZIP(), []int{29} +} + +func (m *CaveatExpression) GetOperationOrCaveat() isCaveatExpression_OperationOrCaveat { + if m != nil { + return m.OperationOrCaveat + } + return nil +} + +func (x *CaveatExpression) GetOperation() *CaveatOperation { + if x, ok := x.GetOperationOrCaveat().(*CaveatExpression_Operation); ok { + return x.Operation + } + return nil +} + +func (x *CaveatExpression) GetCaveat() *ContextualizedCaveat { + if x, ok := x.GetOperationOrCaveat().(*CaveatExpression_Caveat); ok { + return x.Caveat + } + return nil +} + +type isCaveatExpression_OperationOrCaveat interface { + isCaveatExpression_OperationOrCaveat() +} + +type CaveatExpression_Operation struct { + Operation *CaveatOperation `protobuf:"bytes,1,opt,name=operation,proto3,oneof"` +} + +type CaveatExpression_Caveat struct { + Caveat *ContextualizedCaveat `protobuf:"bytes,2,opt,name=caveat,proto3,oneof"` +} + +func (*CaveatExpression_Operation) isCaveatExpression_OperationOrCaveat() {} + +func (*CaveatExpression_Caveat) isCaveatExpression_OperationOrCaveat() {} + +type CaveatOperation struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Op CaveatOperation_Operation `protobuf:"varint,1,opt,name=op,proto3,enum=core.v1.CaveatOperation_Operation" json:"op,omitempty"` + Children []*CaveatExpression `protobuf:"bytes,2,rep,name=children,proto3" json:"children,omitempty"` +} + +func (x *CaveatOperation) Reset() { + *x = CaveatOperation{} + if protoimpl.UnsafeEnabled { + mi := &file_core_v1_core_proto_msgTypes[30] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CaveatOperation) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CaveatOperation) ProtoMessage() {} + +func (x *CaveatOperation) ProtoReflect() protoreflect.Message { + mi := &file_core_v1_core_proto_msgTypes[30] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use CaveatOperation.ProtoReflect.Descriptor instead. +func (*CaveatOperation) Descriptor() ([]byte, []int) { + return file_core_v1_core_proto_rawDescGZIP(), []int{30} +} + +func (x *CaveatOperation) GetOp() CaveatOperation_Operation { + if x != nil { + return x.Op + } + return CaveatOperation_UNKNOWN +} + +func (x *CaveatOperation) GetChildren() []*CaveatExpression { + if x != nil { + return x.Children + } + return nil +} + +type RelationshipFilter struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // resource_type is the *optional* resource type of the relationship. + // NOTE: It is not prefixed with "optional_" for legacy compatibility. + ResourceType string `protobuf:"bytes,1,opt,name=resource_type,json=resourceType,proto3" json:"resource_type,omitempty"` + // optional_resource_id is the *optional* resource ID of the relationship. + // If specified, optional_resource_id_prefix cannot be specified. + OptionalResourceId string `protobuf:"bytes,2,opt,name=optional_resource_id,json=optionalResourceId,proto3" json:"optional_resource_id,omitempty"` + // optional_resource_id_prefix is the *optional* prefix for the resource ID of the relationship. + // If specified, optional_resource_id cannot be specified. + OptionalResourceIdPrefix string `protobuf:"bytes,5,opt,name=optional_resource_id_prefix,json=optionalResourceIdPrefix,proto3" json:"optional_resource_id_prefix,omitempty"` + // relation is the *optional* relation of the relationship. + OptionalRelation string `protobuf:"bytes,3,opt,name=optional_relation,json=optionalRelation,proto3" json:"optional_relation,omitempty"` + // optional_subject_filter is the optional filter for the subjects of the relationships. + OptionalSubjectFilter *SubjectFilter `protobuf:"bytes,4,opt,name=optional_subject_filter,json=optionalSubjectFilter,proto3" json:"optional_subject_filter,omitempty"` +} + +func (x *RelationshipFilter) Reset() { + *x = RelationshipFilter{} + if protoimpl.UnsafeEnabled { + mi := &file_core_v1_core_proto_msgTypes[31] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *RelationshipFilter) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RelationshipFilter) ProtoMessage() {} + +func (x *RelationshipFilter) ProtoReflect() protoreflect.Message { + mi := &file_core_v1_core_proto_msgTypes[31] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use RelationshipFilter.ProtoReflect.Descriptor instead. +func (*RelationshipFilter) Descriptor() ([]byte, []int) { + return file_core_v1_core_proto_rawDescGZIP(), []int{31} +} + +func (x *RelationshipFilter) GetResourceType() string { + if x != nil { + return x.ResourceType + } + return "" +} + +func (x *RelationshipFilter) GetOptionalResourceId() string { + if x != nil { + return x.OptionalResourceId + } + return "" +} + +func (x *RelationshipFilter) GetOptionalResourceIdPrefix() string { + if x != nil { + return x.OptionalResourceIdPrefix + } + return "" +} + +func (x *RelationshipFilter) GetOptionalRelation() string { + if x != nil { + return x.OptionalRelation + } + return "" +} + +func (x *RelationshipFilter) GetOptionalSubjectFilter() *SubjectFilter { + if x != nil { + return x.OptionalSubjectFilter + } + return nil +} + +// SubjectFilter specifies a filter on the subject of a relationship. +// +// subject_type is required and all other fields are optional, and will not +// impose any additional requirements if left unspecified. +type SubjectFilter struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + SubjectType string `protobuf:"bytes,1,opt,name=subject_type,json=subjectType,proto3" json:"subject_type,omitempty"` + OptionalSubjectId string `protobuf:"bytes,2,opt,name=optional_subject_id,json=optionalSubjectId,proto3" json:"optional_subject_id,omitempty"` + OptionalRelation *SubjectFilter_RelationFilter `protobuf:"bytes,3,opt,name=optional_relation,json=optionalRelation,proto3" json:"optional_relation,omitempty"` +} + +func (x *SubjectFilter) Reset() { + *x = SubjectFilter{} + if protoimpl.UnsafeEnabled { + mi := &file_core_v1_core_proto_msgTypes[32] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *SubjectFilter) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SubjectFilter) ProtoMessage() {} + +func (x *SubjectFilter) ProtoReflect() protoreflect.Message { + mi := &file_core_v1_core_proto_msgTypes[32] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SubjectFilter.ProtoReflect.Descriptor instead. +func (*SubjectFilter) Descriptor() ([]byte, []int) { + return file_core_v1_core_proto_rawDescGZIP(), []int{32} +} + +func (x *SubjectFilter) GetSubjectType() string { + if x != nil { + return x.SubjectType + } + return "" +} + +func (x *SubjectFilter) GetOptionalSubjectId() string { + if x != nil { + return x.OptionalSubjectId + } + return "" +} + +func (x *SubjectFilter) GetOptionalRelation() *SubjectFilter_RelationFilter { + if x != nil { + return x.OptionalRelation + } + return nil +} + +type AllowedRelation_PublicWildcard struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *AllowedRelation_PublicWildcard) Reset() { + *x = AllowedRelation_PublicWildcard{} + if protoimpl.UnsafeEnabled { + mi := &file_core_v1_core_proto_msgTypes[36] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *AllowedRelation_PublicWildcard) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*AllowedRelation_PublicWildcard) ProtoMessage() {} + +func (x *AllowedRelation_PublicWildcard) ProtoReflect() protoreflect.Message { + mi := &file_core_v1_core_proto_msgTypes[36] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use AllowedRelation_PublicWildcard.ProtoReflect.Descriptor instead. +func (*AllowedRelation_PublicWildcard) Descriptor() ([]byte, []int) { + return file_core_v1_core_proto_rawDescGZIP(), []int{20, 0} +} + +type SetOperation_Child struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Types that are assignable to ChildType: + // + // *SetOperation_Child_XThis + // *SetOperation_Child_ComputedUserset + // *SetOperation_Child_TupleToUserset + // *SetOperation_Child_UsersetRewrite + // *SetOperation_Child_FunctionedTupleToUserset + // *SetOperation_Child_XNil + ChildType isSetOperation_Child_ChildType `protobuf_oneof:"child_type"` + SourcePosition *SourcePosition `protobuf:"bytes,5,opt,name=source_position,json=sourcePosition,proto3" json:"source_position,omitempty"` + // * + // operation_path (if specified) is the *unique* ID for the set operation in the permission + // definition. It is a heirarchy representing the position of the operation under its parent + // operation. For example, the operation path of an operation which is the third child of the + // fourth top-level operation, will be `3,2`. + OperationPath []uint32 `protobuf:"varint,7,rep,packed,name=operation_path,json=operationPath,proto3" json:"operation_path,omitempty"` +} + +func (x *SetOperation_Child) Reset() { + *x = SetOperation_Child{} + if protoimpl.UnsafeEnabled { + mi := &file_core_v1_core_proto_msgTypes[37] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *SetOperation_Child) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SetOperation_Child) ProtoMessage() {} + +func (x *SetOperation_Child) ProtoReflect() protoreflect.Message { + mi := &file_core_v1_core_proto_msgTypes[37] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SetOperation_Child.ProtoReflect.Descriptor instead. +func (*SetOperation_Child) Descriptor() ([]byte, []int) { + return file_core_v1_core_proto_rawDescGZIP(), []int{24, 0} +} + +func (m *SetOperation_Child) GetChildType() isSetOperation_Child_ChildType { + if m != nil { + return m.ChildType + } + return nil +} + +func (x *SetOperation_Child) GetXThis() *SetOperation_Child_This { + if x, ok := x.GetChildType().(*SetOperation_Child_XThis); ok { + return x.XThis + } + return nil +} + +func (x *SetOperation_Child) GetComputedUserset() *ComputedUserset { + if x, ok := x.GetChildType().(*SetOperation_Child_ComputedUserset); ok { + return x.ComputedUserset + } + return nil +} + +func (x *SetOperation_Child) GetTupleToUserset() *TupleToUserset { + if x, ok := x.GetChildType().(*SetOperation_Child_TupleToUserset); ok { + return x.TupleToUserset + } + return nil +} + +func (x *SetOperation_Child) GetUsersetRewrite() *UsersetRewrite { + if x, ok := x.GetChildType().(*SetOperation_Child_UsersetRewrite); ok { + return x.UsersetRewrite + } + return nil +} + +func (x *SetOperation_Child) GetFunctionedTupleToUserset() *FunctionedTupleToUserset { + if x, ok := x.GetChildType().(*SetOperation_Child_FunctionedTupleToUserset); ok { + return x.FunctionedTupleToUserset + } + return nil +} + +func (x *SetOperation_Child) GetXNil() *SetOperation_Child_Nil { + if x, ok := x.GetChildType().(*SetOperation_Child_XNil); ok { + return x.XNil + } + return nil +} + +func (x *SetOperation_Child) GetSourcePosition() *SourcePosition { + if x != nil { + return x.SourcePosition + } + return nil +} + +func (x *SetOperation_Child) GetOperationPath() []uint32 { + if x != nil { + return x.OperationPath + } + return nil +} + +type isSetOperation_Child_ChildType interface { + isSetOperation_Child_ChildType() +} + +type SetOperation_Child_XThis struct { + XThis *SetOperation_Child_This `protobuf:"bytes,1,opt,name=_this,json=This,proto3,oneof"` +} + +type SetOperation_Child_ComputedUserset struct { + ComputedUserset *ComputedUserset `protobuf:"bytes,2,opt,name=computed_userset,json=computedUserset,proto3,oneof"` +} + +type SetOperation_Child_TupleToUserset struct { + TupleToUserset *TupleToUserset `protobuf:"bytes,3,opt,name=tuple_to_userset,json=tupleToUserset,proto3,oneof"` +} + +type SetOperation_Child_UsersetRewrite struct { + UsersetRewrite *UsersetRewrite `protobuf:"bytes,4,opt,name=userset_rewrite,json=usersetRewrite,proto3,oneof"` +} + +type SetOperation_Child_FunctionedTupleToUserset struct { + FunctionedTupleToUserset *FunctionedTupleToUserset `protobuf:"bytes,8,opt,name=functioned_tuple_to_userset,json=functionedTupleToUserset,proto3,oneof"` +} + +type SetOperation_Child_XNil struct { + XNil *SetOperation_Child_Nil `protobuf:"bytes,6,opt,name=_nil,json=Nil,proto3,oneof"` +} + +func (*SetOperation_Child_XThis) isSetOperation_Child_ChildType() {} + +func (*SetOperation_Child_ComputedUserset) isSetOperation_Child_ChildType() {} + +func (*SetOperation_Child_TupleToUserset) isSetOperation_Child_ChildType() {} + +func (*SetOperation_Child_UsersetRewrite) isSetOperation_Child_ChildType() {} + +func (*SetOperation_Child_FunctionedTupleToUserset) isSetOperation_Child_ChildType() {} + +func (*SetOperation_Child_XNil) isSetOperation_Child_ChildType() {} + +type SetOperation_Child_This struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *SetOperation_Child_This) Reset() { + *x = SetOperation_Child_This{} + if protoimpl.UnsafeEnabled { + mi := &file_core_v1_core_proto_msgTypes[38] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *SetOperation_Child_This) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SetOperation_Child_This) ProtoMessage() {} + +func (x *SetOperation_Child_This) ProtoReflect() protoreflect.Message { + mi := &file_core_v1_core_proto_msgTypes[38] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SetOperation_Child_This.ProtoReflect.Descriptor instead. +func (*SetOperation_Child_This) Descriptor() ([]byte, []int) { + return file_core_v1_core_proto_rawDescGZIP(), []int{24, 0, 0} +} + +type SetOperation_Child_Nil struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *SetOperation_Child_Nil) Reset() { + *x = SetOperation_Child_Nil{} + if protoimpl.UnsafeEnabled { + mi := &file_core_v1_core_proto_msgTypes[39] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *SetOperation_Child_Nil) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SetOperation_Child_Nil) ProtoMessage() {} + +func (x *SetOperation_Child_Nil) ProtoReflect() protoreflect.Message { + mi := &file_core_v1_core_proto_msgTypes[39] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SetOperation_Child_Nil.ProtoReflect.Descriptor instead. +func (*SetOperation_Child_Nil) Descriptor() ([]byte, []int) { + return file_core_v1_core_proto_rawDescGZIP(), []int{24, 0, 1} +} + +type TupleToUserset_Tupleset struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Relation string `protobuf:"bytes,1,opt,name=relation,proto3" json:"relation,omitempty"` +} + +func (x *TupleToUserset_Tupleset) Reset() { + *x = TupleToUserset_Tupleset{} + if protoimpl.UnsafeEnabled { + mi := &file_core_v1_core_proto_msgTypes[40] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *TupleToUserset_Tupleset) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*TupleToUserset_Tupleset) ProtoMessage() {} + +func (x *TupleToUserset_Tupleset) ProtoReflect() protoreflect.Message { + mi := &file_core_v1_core_proto_msgTypes[40] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use TupleToUserset_Tupleset.ProtoReflect.Descriptor instead. +func (*TupleToUserset_Tupleset) Descriptor() ([]byte, []int) { + return file_core_v1_core_proto_rawDescGZIP(), []int{25, 0} +} + +func (x *TupleToUserset_Tupleset) GetRelation() string { + if x != nil { + return x.Relation + } + return "" +} + +type FunctionedTupleToUserset_Tupleset struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Relation string `protobuf:"bytes,1,opt,name=relation,proto3" json:"relation,omitempty"` +} + +func (x *FunctionedTupleToUserset_Tupleset) Reset() { + *x = FunctionedTupleToUserset_Tupleset{} + if protoimpl.UnsafeEnabled { + mi := &file_core_v1_core_proto_msgTypes[41] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *FunctionedTupleToUserset_Tupleset) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*FunctionedTupleToUserset_Tupleset) ProtoMessage() {} + +func (x *FunctionedTupleToUserset_Tupleset) ProtoReflect() protoreflect.Message { + mi := &file_core_v1_core_proto_msgTypes[41] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use FunctionedTupleToUserset_Tupleset.ProtoReflect.Descriptor instead. +func (*FunctionedTupleToUserset_Tupleset) Descriptor() ([]byte, []int) { + return file_core_v1_core_proto_rawDescGZIP(), []int{26, 0} +} + +func (x *FunctionedTupleToUserset_Tupleset) GetRelation() string { + if x != nil { + return x.Relation + } + return "" +} + +type SubjectFilter_RelationFilter struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Relation string `protobuf:"bytes,1,opt,name=relation,proto3" json:"relation,omitempty"` +} + +func (x *SubjectFilter_RelationFilter) Reset() { + *x = SubjectFilter_RelationFilter{} + if protoimpl.UnsafeEnabled { + mi := &file_core_v1_core_proto_msgTypes[42] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *SubjectFilter_RelationFilter) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SubjectFilter_RelationFilter) ProtoMessage() {} + +func (x *SubjectFilter_RelationFilter) ProtoReflect() protoreflect.Message { + mi := &file_core_v1_core_proto_msgTypes[42] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SubjectFilter_RelationFilter.ProtoReflect.Descriptor instead. +func (*SubjectFilter_RelationFilter) Descriptor() ([]byte, []int) { + return file_core_v1_core_proto_rawDescGZIP(), []int{32, 0} +} + +func (x *SubjectFilter_RelationFilter) GetRelation() string { + if x != nil { + return x.Relation + } + return "" +} + +var File_core_v1_core_proto protoreflect.FileDescriptor + +var file_core_v1_core_proto_rawDesc = []byte{ + 0x0a, 0x12, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x76, 0x31, 0x2f, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x07, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x1a, 0x19, 0x67, + 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x61, + 0x6e, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, + 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, + 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x17, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, + 0x65, 0x2f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x22, 0x88, 0x03, 0x0a, 0x0d, 0x52, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x54, 0x75, 0x70, + 0x6c, 0x65, 0x12, 0x58, 0x0a, 0x15, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x61, + 0x6e, 0x64, 0x5f, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x1a, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4f, 0x62, 0x6a, 0x65, + 0x63, 0x74, 0x41, 0x6e, 0x64, 0x52, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x08, 0xfa, + 0x42, 0x05, 0x8a, 0x01, 0x02, 0x10, 0x01, 0x52, 0x13, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, + 0x65, 0x41, 0x6e, 0x64, 0x52, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x3e, 0x0a, 0x07, + 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, + 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x41, 0x6e, + 0x64, 0x52, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x08, 0xfa, 0x42, 0x05, 0x8a, 0x01, + 0x02, 0x10, 0x01, 0x52, 0x07, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x3f, 0x0a, 0x06, + 0x63, 0x61, 0x76, 0x65, 0x61, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x63, + 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x75, 0x61, + 0x6c, 0x69, 0x7a, 0x65, 0x64, 0x43, 0x61, 0x76, 0x65, 0x61, 0x74, 0x42, 0x08, 0xfa, 0x42, 0x05, + 0x8a, 0x01, 0x02, 0x10, 0x00, 0x52, 0x06, 0x63, 0x61, 0x76, 0x65, 0x61, 0x74, 0x12, 0x46, 0x0a, + 0x09, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x1e, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x52, 0x65, 0x6c, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x73, 0x68, 0x69, 0x70, 0x49, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x69, 0x74, 0x79, + 0x42, 0x08, 0xfa, 0x42, 0x05, 0x8a, 0x01, 0x02, 0x10, 0x00, 0x52, 0x09, 0x69, 0x6e, 0x74, 0x65, + 0x67, 0x72, 0x69, 0x74, 0x79, 0x12, 0x54, 0x0a, 0x18, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x61, + 0x6c, 0x5f, 0x65, 0x78, 0x70, 0x69, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x74, 0x69, 0x6d, + 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, + 0x61, 0x6d, 0x70, 0x52, 0x16, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x45, 0x78, 0x70, + 0x69, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x54, 0x69, 0x6d, 0x65, 0x22, 0x7b, 0x0a, 0x15, 0x52, + 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x68, 0x69, 0x70, 0x49, 0x6e, 0x74, 0x65, 0x67, + 0x72, 0x69, 0x74, 0x79, 0x12, 0x15, 0x0a, 0x06, 0x6b, 0x65, 0x79, 0x5f, 0x69, 0x64, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6b, 0x65, 0x79, 0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x68, + 0x61, 0x73, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x68, 0x61, 0x73, 0x68, 0x12, + 0x37, 0x0a, 0x09, 0x68, 0x61, 0x73, 0x68, 0x65, 0x64, 0x5f, 0x61, 0x74, 0x18, 0x03, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x08, + 0x68, 0x61, 0x73, 0x68, 0x65, 0x64, 0x41, 0x74, 0x22, 0xab, 0x01, 0x0a, 0x14, 0x43, 0x6f, 0x6e, + 0x74, 0x65, 0x78, 0x74, 0x75, 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x64, 0x43, 0x61, 0x76, 0x65, 0x61, + 0x74, 0x12, 0x56, 0x0a, 0x0b, 0x63, 0x61, 0x76, 0x65, 0x61, 0x74, 0x5f, 0x6e, 0x61, 0x6d, 0x65, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x35, 0xfa, 0x42, 0x32, 0x72, 0x30, 0x28, 0x80, 0x01, + 0x32, 0x2b, 0x5e, 0x28, 0x28, 0x5b, 0x61, 0x2d, 0x7a, 0x41, 0x2d, 0x5a, 0x30, 0x2d, 0x39, 0x5f, + 0x5d, 0x5b, 0x61, 0x2d, 0x7a, 0x41, 0x2d, 0x5a, 0x30, 0x2d, 0x39, 0x2f, 0x5f, 0x7c, 0x2d, 0x5d, + 0x7b, 0x30, 0x2c, 0x31, 0x32, 0x37, 0x7d, 0x29, 0x7c, 0x5c, 0x2a, 0x29, 0x24, 0x52, 0x0a, 0x63, + 0x61, 0x76, 0x65, 0x61, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x3b, 0x0a, 0x07, 0x63, 0x6f, 0x6e, + 0x74, 0x65, 0x78, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x67, 0x6f, 0x6f, + 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, + 0x75, 0x63, 0x74, 0x42, 0x08, 0xfa, 0x42, 0x05, 0x8a, 0x01, 0x02, 0x10, 0x00, 0x52, 0x07, 0x63, + 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x22, 0xd4, 0x03, 0x0a, 0x10, 0x43, 0x61, 0x76, 0x65, 0x61, + 0x74, 0x44, 0x65, 0x66, 0x69, 0x6e, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x49, 0x0a, 0x04, 0x6e, + 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x35, 0xfa, 0x42, 0x32, 0x72, 0x30, + 0x28, 0x80, 0x01, 0x32, 0x2b, 0x5e, 0x28, 0x28, 0x5b, 0x61, 0x2d, 0x7a, 0x41, 0x2d, 0x5a, 0x30, + 0x2d, 0x39, 0x5f, 0x5d, 0x5b, 0x61, 0x2d, 0x7a, 0x41, 0x2d, 0x5a, 0x30, 0x2d, 0x39, 0x2f, 0x5f, + 0x7c, 0x2d, 0x5d, 0x7b, 0x30, 0x2c, 0x31, 0x32, 0x37, 0x7d, 0x29, 0x7c, 0x5c, 0x2a, 0x29, 0x24, + 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x3f, 0x0a, 0x15, 0x73, 0x65, 0x72, 0x69, 0x61, 0x6c, + 0x69, 0x7a, 0x65, 0x64, 0x5f, 0x65, 0x78, 0x70, 0x72, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x0a, 0xfa, 0x42, 0x07, 0x7a, 0x05, 0x10, 0x00, 0x18, 0x80, + 0x20, 0x52, 0x14, 0x73, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x64, 0x45, 0x78, 0x70, + 0x72, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x62, 0x0a, 0x0f, 0x70, 0x61, 0x72, 0x61, 0x6d, + 0x65, 0x74, 0x65, 0x72, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, + 0x32, 0x2d, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x61, 0x76, 0x65, 0x61, + 0x74, 0x44, 0x65, 0x66, 0x69, 0x6e, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x50, 0x61, 0x72, 0x61, + 0x6d, 0x65, 0x74, 0x65, 0x72, 0x54, 0x79, 0x70, 0x65, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x42, + 0x0a, 0xfa, 0x42, 0x07, 0x9a, 0x01, 0x04, 0x08, 0x01, 0x10, 0x14, 0x52, 0x0e, 0x70, 0x61, 0x72, + 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x54, 0x79, 0x70, 0x65, 0x73, 0x12, 0x2d, 0x0a, 0x08, 0x6d, + 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x11, 0x2e, + 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, + 0x52, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, 0x40, 0x0a, 0x0f, 0x73, 0x6f, + 0x75, 0x72, 0x63, 0x65, 0x5f, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x05, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x6f, + 0x75, 0x72, 0x63, 0x65, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0e, 0x73, 0x6f, + 0x75, 0x72, 0x63, 0x65, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x1a, 0x5f, 0x0a, 0x13, + 0x50, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x54, 0x79, 0x70, 0x65, 0x73, 0x45, 0x6e, + 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x32, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x43, + 0x61, 0x76, 0x65, 0x61, 0x74, 0x54, 0x79, 0x70, 0x65, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, + 0x63, 0x65, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x7d, 0x0a, + 0x13, 0x43, 0x61, 0x76, 0x65, 0x61, 0x74, 0x54, 0x79, 0x70, 0x65, 0x52, 0x65, 0x66, 0x65, 0x72, + 0x65, 0x6e, 0x63, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x74, 0x79, 0x70, 0x65, 0x5f, 0x6e, 0x61, 0x6d, + 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x74, 0x79, 0x70, 0x65, 0x4e, 0x61, 0x6d, + 0x65, 0x12, 0x49, 0x0a, 0x0b, 0x63, 0x68, 0x69, 0x6c, 0x64, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x73, + 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, + 0x2e, 0x43, 0x61, 0x76, 0x65, 0x61, 0x74, 0x54, 0x79, 0x70, 0x65, 0x52, 0x65, 0x66, 0x65, 0x72, + 0x65, 0x6e, 0x63, 0x65, 0x42, 0x0a, 0xfa, 0x42, 0x07, 0x92, 0x01, 0x04, 0x08, 0x00, 0x10, 0x01, + 0x52, 0x0a, 0x63, 0x68, 0x69, 0x6c, 0x64, 0x54, 0x79, 0x70, 0x65, 0x73, 0x22, 0x91, 0x02, 0x0a, + 0x11, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x41, 0x6e, 0x64, 0x52, 0x65, 0x6c, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x12, 0x66, 0x0a, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x48, 0xfa, 0x42, 0x45, 0x72, 0x43, 0x28, 0x80, 0x01, 0x32, + 0x3e, 0x5e, 0x28, 0x5b, 0x61, 0x2d, 0x7a, 0x5d, 0x5b, 0x61, 0x2d, 0x7a, 0x30, 0x2d, 0x39, 0x5f, + 0x5d, 0x7b, 0x31, 0x2c, 0x36, 0x31, 0x7d, 0x5b, 0x61, 0x2d, 0x7a, 0x30, 0x2d, 0x39, 0x5d, 0x2f, + 0x29, 0x2a, 0x5b, 0x61, 0x2d, 0x7a, 0x5d, 0x5b, 0x61, 0x2d, 0x7a, 0x30, 0x2d, 0x39, 0x5f, 0x5d, + 0x7b, 0x31, 0x2c, 0x36, 0x32, 0x7d, 0x5b, 0x61, 0x2d, 0x7a, 0x30, 0x2d, 0x39, 0x5d, 0x24, 0x52, + 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x12, 0x46, 0x0a, 0x09, 0x6f, 0x62, + 0x6a, 0x65, 0x63, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, 0x29, 0xfa, + 0x42, 0x26, 0x72, 0x24, 0x28, 0x80, 0x08, 0x32, 0x1f, 0x5e, 0x28, 0x28, 0x5b, 0x61, 0x2d, 0x7a, + 0x41, 0x2d, 0x5a, 0x30, 0x2d, 0x39, 0x2f, 0x5f, 0x7c, 0x5c, 0x2d, 0x3d, 0x2b, 0x5d, 0x7b, 0x31, + 0x2c, 0x7d, 0x29, 0x7c, 0x5c, 0x2a, 0x29, 0x24, 0x52, 0x08, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, + 0x49, 0x64, 0x12, 0x4c, 0x0a, 0x08, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x09, 0x42, 0x30, 0xfa, 0x42, 0x2d, 0x72, 0x2b, 0x28, 0x40, 0x32, 0x27, 0x5e, + 0x28, 0x5c, 0x2e, 0x5c, 0x2e, 0x5c, 0x2e, 0x7c, 0x5b, 0x61, 0x2d, 0x7a, 0x5d, 0x5b, 0x61, 0x2d, + 0x7a, 0x30, 0x2d, 0x39, 0x5f, 0x5d, 0x7b, 0x31, 0x2c, 0x36, 0x32, 0x7d, 0x5b, 0x61, 0x2d, 0x7a, + 0x30, 0x2d, 0x39, 0x5d, 0x29, 0x24, 0x52, 0x08, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x22, 0xc9, 0x01, 0x0a, 0x11, 0x52, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x66, + 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x12, 0x66, 0x0a, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, + 0x61, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x48, 0xfa, 0x42, 0x45, 0x72, 0x43, + 0x28, 0x80, 0x01, 0x32, 0x3e, 0x5e, 0x28, 0x5b, 0x61, 0x2d, 0x7a, 0x5d, 0x5b, 0x61, 0x2d, 0x7a, + 0x30, 0x2d, 0x39, 0x5f, 0x5d, 0x7b, 0x31, 0x2c, 0x36, 0x31, 0x7d, 0x5b, 0x61, 0x2d, 0x7a, 0x30, + 0x2d, 0x39, 0x5d, 0x2f, 0x29, 0x2a, 0x5b, 0x61, 0x2d, 0x7a, 0x5d, 0x5b, 0x61, 0x2d, 0x7a, 0x30, + 0x2d, 0x39, 0x5f, 0x5d, 0x7b, 0x31, 0x2c, 0x36, 0x32, 0x7d, 0x5b, 0x61, 0x2d, 0x7a, 0x30, 0x2d, + 0x39, 0x5d, 0x24, 0x52, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x12, 0x4c, + 0x0a, 0x08, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, + 0x42, 0x30, 0xfa, 0x42, 0x2d, 0x72, 0x2b, 0x28, 0x40, 0x32, 0x27, 0x5e, 0x28, 0x5c, 0x2e, 0x5c, + 0x2e, 0x5c, 0x2e, 0x7c, 0x5b, 0x61, 0x2d, 0x7a, 0x5d, 0x5b, 0x61, 0x2d, 0x7a, 0x30, 0x2d, 0x39, + 0x5f, 0x5d, 0x7b, 0x31, 0x2c, 0x36, 0x32, 0x7d, 0x5b, 0x61, 0x2d, 0x7a, 0x30, 0x2d, 0x39, 0x5d, + 0x29, 0x24, 0x52, 0x08, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x27, 0x0a, 0x06, + 0x5a, 0x6f, 0x6f, 0x6b, 0x69, 0x65, 0x12, 0x1d, 0x0a, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x07, 0xfa, 0x42, 0x04, 0x72, 0x02, 0x20, 0x01, 0x52, 0x05, + 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0xda, 0x01, 0x0a, 0x13, 0x52, 0x65, 0x6c, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x54, 0x75, 0x70, 0x6c, 0x65, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x12, 0x4e, 0x0a, + 0x09, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, + 0x32, 0x26, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x52, 0x65, 0x6c, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x54, 0x75, 0x70, 0x6c, 0x65, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x2e, 0x4f, + 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x08, 0xfa, 0x42, 0x05, 0x82, 0x01, 0x02, + 0x10, 0x01, 0x52, 0x09, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x36, 0x0a, + 0x05, 0x74, 0x75, 0x70, 0x6c, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x63, + 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x52, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x54, + 0x75, 0x70, 0x6c, 0x65, 0x42, 0x08, 0xfa, 0x42, 0x05, 0x8a, 0x01, 0x02, 0x10, 0x01, 0x52, 0x05, + 0x74, 0x75, 0x70, 0x6c, 0x65, 0x22, 0x3b, 0x0a, 0x09, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, + 0x0a, 0x0a, 0x06, 0x43, 0x52, 0x45, 0x41, 0x54, 0x45, 0x10, 0x01, 0x12, 0x09, 0x0a, 0x05, 0x54, + 0x4f, 0x55, 0x43, 0x48, 0x10, 0x02, 0x12, 0x0a, 0x0a, 0x06, 0x44, 0x45, 0x4c, 0x45, 0x54, 0x45, + 0x10, 0x03, 0x22, 0xa9, 0x02, 0x0a, 0x15, 0x52, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x54, + 0x75, 0x70, 0x6c, 0x65, 0x54, 0x72, 0x65, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x12, 0x4b, 0x0a, 0x11, + 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6d, 0x65, 0x64, 0x69, 0x61, 0x74, 0x65, 0x5f, 0x6e, 0x6f, 0x64, + 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x76, + 0x31, 0x2e, 0x53, 0x65, 0x74, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x55, 0x73, + 0x65, 0x72, 0x73, 0x65, 0x74, 0x48, 0x00, 0x52, 0x10, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6d, 0x65, + 0x64, 0x69, 0x61, 0x74, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x12, 0x36, 0x0a, 0x09, 0x6c, 0x65, 0x61, + 0x66, 0x5f, 0x6e, 0x6f, 0x64, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x63, + 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x69, 0x72, 0x65, 0x63, 0x74, 0x53, 0x75, 0x62, + 0x6a, 0x65, 0x63, 0x74, 0x73, 0x48, 0x00, 0x52, 0x08, 0x6c, 0x65, 0x61, 0x66, 0x4e, 0x6f, 0x64, + 0x65, 0x12, 0x36, 0x0a, 0x08, 0x65, 0x78, 0x70, 0x61, 0x6e, 0x64, 0x65, 0x64, 0x18, 0x03, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4f, 0x62, + 0x6a, 0x65, 0x63, 0x74, 0x41, 0x6e, 0x64, 0x52, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, + 0x08, 0x65, 0x78, 0x70, 0x61, 0x6e, 0x64, 0x65, 0x64, 0x12, 0x46, 0x0a, 0x11, 0x63, 0x61, 0x76, + 0x65, 0x61, 0x74, 0x5f, 0x65, 0x78, 0x70, 0x72, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x04, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x43, + 0x61, 0x76, 0x65, 0x61, 0x74, 0x45, 0x78, 0x70, 0x72, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, + 0x10, 0x63, 0x61, 0x76, 0x65, 0x61, 0x74, 0x45, 0x78, 0x70, 0x72, 0x65, 0x73, 0x73, 0x69, 0x6f, + 0x6e, 0x42, 0x0b, 0x0a, 0x09, 0x6e, 0x6f, 0x64, 0x65, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x22, 0xe2, + 0x01, 0x0a, 0x13, 0x53, 0x65, 0x74, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x55, + 0x73, 0x65, 0x72, 0x73, 0x65, 0x74, 0x12, 0x44, 0x0a, 0x09, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x26, 0x2e, 0x63, 0x6f, 0x72, 0x65, + 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65, 0x74, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x55, 0x73, 0x65, 0x72, 0x73, 0x65, 0x74, 0x2e, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, + 0x6e, 0x52, 0x09, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x3f, 0x0a, 0x0b, + 0x63, 0x68, 0x69, 0x6c, 0x64, 0x5f, 0x6e, 0x6f, 0x64, 0x65, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, + 0x0b, 0x32, 0x1e, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x52, 0x65, 0x6c, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x54, 0x75, 0x70, 0x6c, 0x65, 0x54, 0x72, 0x65, 0x65, 0x4e, 0x6f, 0x64, + 0x65, 0x52, 0x0a, 0x63, 0x68, 0x69, 0x6c, 0x64, 0x4e, 0x6f, 0x64, 0x65, 0x73, 0x22, 0x44, 0x0a, + 0x09, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x0b, 0x0a, 0x07, 0x49, 0x4e, + 0x56, 0x41, 0x4c, 0x49, 0x44, 0x10, 0x00, 0x12, 0x09, 0x0a, 0x05, 0x55, 0x4e, 0x49, 0x4f, 0x4e, + 0x10, 0x01, 0x12, 0x10, 0x0a, 0x0c, 0x49, 0x4e, 0x54, 0x45, 0x52, 0x53, 0x45, 0x43, 0x54, 0x49, + 0x4f, 0x4e, 0x10, 0x02, 0x12, 0x0d, 0x0a, 0x09, 0x45, 0x58, 0x43, 0x4c, 0x55, 0x53, 0x49, 0x4f, + 0x4e, 0x10, 0x03, 0x22, 0x8d, 0x01, 0x0a, 0x0d, 0x44, 0x69, 0x72, 0x65, 0x63, 0x74, 0x53, 0x75, + 0x62, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x34, 0x0a, 0x07, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, + 0x2e, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x41, 0x6e, 0x64, 0x52, 0x65, 0x6c, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x52, 0x07, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x46, 0x0a, 0x11, 0x63, + 0x61, 0x76, 0x65, 0x61, 0x74, 0x5f, 0x65, 0x78, 0x70, 0x72, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, + 0x2e, 0x43, 0x61, 0x76, 0x65, 0x61, 0x74, 0x45, 0x78, 0x70, 0x72, 0x65, 0x73, 0x73, 0x69, 0x6f, + 0x6e, 0x52, 0x10, 0x63, 0x61, 0x76, 0x65, 0x61, 0x74, 0x45, 0x78, 0x70, 0x72, 0x65, 0x73, 0x73, + 0x69, 0x6f, 0x6e, 0x22, 0x44, 0x0a, 0x0e, 0x44, 0x69, 0x72, 0x65, 0x63, 0x74, 0x53, 0x75, 0x62, + 0x6a, 0x65, 0x63, 0x74, 0x73, 0x12, 0x32, 0x0a, 0x08, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, + 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x76, + 0x31, 0x2e, 0x44, 0x69, 0x72, 0x65, 0x63, 0x74, 0x53, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x52, + 0x08, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x22, 0xb8, 0x01, 0x0a, 0x08, 0x4d, 0x65, + 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, 0xab, 0x01, 0x0a, 0x10, 0x6d, 0x65, 0x74, 0x61, 0x64, + 0x61, 0x74, 0x61, 0x5f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x01, 0x20, 0x03, 0x28, + 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x42, 0x6a, 0xfa, 0x42, 0x67, 0x92, 0x01, 0x64, 0x08, + 0x01, 0x22, 0x60, 0x8a, 0x01, 0x02, 0x10, 0x01, 0xa2, 0x01, 0x58, 0x08, 0x01, 0x12, 0x26, 0x74, + 0x79, 0x70, 0x65, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x61, 0x70, 0x69, 0x73, 0x2e, 0x63, + 0x6f, 0x6d, 0x2f, 0x69, 0x6d, 0x70, 0x6c, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x6f, 0x63, 0x43, 0x6f, + 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x2c, 0x74, 0x79, 0x70, 0x65, 0x2e, 0x67, 0x6f, 0x6f, 0x67, + 0x6c, 0x65, 0x61, 0x70, 0x69, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x69, 0x6d, 0x70, 0x6c, 0x2e, + 0x76, 0x31, 0x2e, 0x52, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4d, 0x65, 0x74, 0x61, 0x64, + 0x61, 0x74, 0x61, 0x52, 0x0f, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x4d, 0x65, 0x73, + 0x73, 0x61, 0x67, 0x65, 0x22, 0x93, 0x02, 0x0a, 0x13, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, + 0x63, 0x65, 0x44, 0x65, 0x66, 0x69, 0x6e, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x5c, 0x0a, 0x04, + 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x48, 0xfa, 0x42, 0x45, 0x72, + 0x43, 0x28, 0x80, 0x01, 0x32, 0x3e, 0x5e, 0x28, 0x5b, 0x61, 0x2d, 0x7a, 0x5d, 0x5b, 0x61, 0x2d, + 0x7a, 0x30, 0x2d, 0x39, 0x5f, 0x5d, 0x7b, 0x31, 0x2c, 0x36, 0x32, 0x7d, 0x5b, 0x61, 0x2d, 0x7a, + 0x30, 0x2d, 0x39, 0x5d, 0x2f, 0x29, 0x2a, 0x5b, 0x61, 0x2d, 0x7a, 0x5d, 0x5b, 0x61, 0x2d, 0x7a, + 0x30, 0x2d, 0x39, 0x5f, 0x5d, 0x7b, 0x31, 0x2c, 0x36, 0x32, 0x7d, 0x5b, 0x61, 0x2d, 0x7a, 0x30, + 0x2d, 0x39, 0x5d, 0x24, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x2d, 0x0a, 0x08, 0x72, 0x65, + 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x63, + 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x52, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, + 0x08, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x2d, 0x0a, 0x08, 0x6d, 0x65, 0x74, + 0x61, 0x64, 0x61, 0x74, 0x61, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x63, 0x6f, + 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x52, 0x08, + 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, 0x40, 0x0a, 0x0f, 0x73, 0x6f, 0x75, 0x72, + 0x63, 0x65, 0x5f, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x17, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x6f, 0x75, 0x72, + 0x63, 0x65, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0e, 0x73, 0x6f, 0x75, 0x72, + 0x63, 0x65, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x9c, 0x03, 0x0a, 0x08, 0x52, + 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x3b, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x27, 0xfa, 0x42, 0x24, 0x72, 0x22, 0x28, 0x40, 0x32, 0x1e, + 0x5e, 0x5b, 0x61, 0x2d, 0x7a, 0x5d, 0x5b, 0x61, 0x2d, 0x7a, 0x30, 0x2d, 0x39, 0x5f, 0x5d, 0x7b, + 0x31, 0x2c, 0x36, 0x32, 0x7d, 0x5b, 0x61, 0x2d, 0x7a, 0x30, 0x2d, 0x39, 0x5d, 0x24, 0x52, 0x04, + 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x40, 0x0a, 0x0f, 0x75, 0x73, 0x65, 0x72, 0x73, 0x65, 0x74, 0x5f, + 0x72, 0x65, 0x77, 0x72, 0x69, 0x74, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, + 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x73, 0x65, 0x74, 0x52, + 0x65, 0x77, 0x72, 0x69, 0x74, 0x65, 0x52, 0x0e, 0x75, 0x73, 0x65, 0x72, 0x73, 0x65, 0x74, 0x52, + 0x65, 0x77, 0x72, 0x69, 0x74, 0x65, 0x12, 0x43, 0x0a, 0x10, 0x74, 0x79, 0x70, 0x65, 0x5f, 0x69, + 0x6e, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x18, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x79, 0x70, 0x65, 0x49, + 0x6e, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0f, 0x74, 0x79, 0x70, 0x65, + 0x49, 0x6e, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x2d, 0x0a, 0x08, 0x6d, + 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x11, 0x2e, + 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, + 0x52, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, 0x40, 0x0a, 0x0f, 0x73, 0x6f, + 0x75, 0x72, 0x63, 0x65, 0x5f, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x05, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x6f, + 0x75, 0x72, 0x63, 0x65, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0e, 0x73, 0x6f, + 0x75, 0x72, 0x63, 0x65, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x2b, 0x0a, 0x11, + 0x61, 0x6c, 0x69, 0x61, 0x73, 0x69, 0x6e, 0x67, 0x5f, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, + 0x6e, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x10, 0x61, 0x6c, 0x69, 0x61, 0x73, 0x69, 0x6e, + 0x67, 0x52, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x2e, 0x0a, 0x13, 0x63, 0x61, 0x6e, + 0x6f, 0x6e, 0x69, 0x63, 0x61, 0x6c, 0x5f, 0x63, 0x61, 0x63, 0x68, 0x65, 0x5f, 0x6b, 0x65, 0x79, + 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x11, 0x63, 0x61, 0x6e, 0x6f, 0x6e, 0x69, 0x63, 0x61, + 0x6c, 0x43, 0x61, 0x63, 0x68, 0x65, 0x4b, 0x65, 0x79, 0x22, 0xf4, 0x03, 0x0a, 0x11, 0x52, 0x65, + 0x61, 0x63, 0x68, 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x47, 0x72, 0x61, 0x70, 0x68, 0x12, + 0x77, 0x0a, 0x1b, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x73, 0x5f, 0x62, + 0x79, 0x5f, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, + 0x20, 0x03, 0x28, 0x0b, 0x32, 0x38, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x52, + 0x65, 0x61, 0x63, 0x68, 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x47, 0x72, 0x61, 0x70, 0x68, + 0x2e, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x73, 0x42, 0x79, 0x53, 0x75, + 0x62, 0x6a, 0x65, 0x63, 0x74, 0x54, 0x79, 0x70, 0x65, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x18, + 0x65, 0x6e, 0x74, 0x72, 0x79, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x73, 0x42, 0x79, 0x53, 0x75, 0x62, + 0x6a, 0x65, 0x63, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x83, 0x01, 0x0a, 0x1f, 0x65, 0x6e, 0x74, + 0x72, 0x79, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x73, 0x5f, 0x62, 0x79, 0x5f, 0x73, 0x75, 0x62, 0x6a, + 0x65, 0x63, 0x74, 0x5f, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x03, + 0x28, 0x0b, 0x32, 0x3c, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x52, 0x65, 0x61, + 0x63, 0x68, 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x47, 0x72, 0x61, 0x70, 0x68, 0x2e, 0x45, + 0x6e, 0x74, 0x72, 0x79, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x73, 0x42, 0x79, 0x53, 0x75, 0x62, 0x6a, + 0x65, 0x63, 0x74, 0x52, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x45, 0x6e, 0x74, 0x72, 0x79, + 0x52, 0x1c, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x73, 0x42, 0x79, 0x53, + 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x1a, 0x6d, + 0x0a, 0x1d, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x73, 0x42, 0x79, 0x53, + 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x54, 0x79, 0x70, 0x65, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, + 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, + 0x79, 0x12, 0x36, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x20, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x52, 0x65, 0x61, 0x63, 0x68, + 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x70, 0x6f, 0x69, 0x6e, + 0x74, 0x73, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x71, 0x0a, + 0x21, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x73, 0x42, 0x79, 0x53, 0x75, + 0x62, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x45, 0x6e, 0x74, + 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x03, 0x6b, 0x65, 0x79, 0x12, 0x36, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x52, 0x65, + 0x61, 0x63, 0x68, 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x70, + 0x6f, 0x69, 0x6e, 0x74, 0x73, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, + 0x22, 0xc6, 0x01, 0x0a, 0x17, 0x52, 0x65, 0x61, 0x63, 0x68, 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, + 0x79, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x73, 0x12, 0x41, 0x0a, 0x0b, + 0x65, 0x6e, 0x74, 0x72, 0x79, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, + 0x0b, 0x32, 0x1f, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x52, 0x65, 0x61, 0x63, + 0x68, 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x70, 0x6f, 0x69, + 0x6e, 0x74, 0x52, 0x0b, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x73, 0x12, + 0x21, 0x0a, 0x0c, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x54, 0x79, + 0x70, 0x65, 0x12, 0x45, 0x0a, 0x10, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x5f, 0x72, 0x65, + 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x63, + 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x52, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, + 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x0f, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, + 0x74, 0x52, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0xce, 0x04, 0x0a, 0x16, 0x52, 0x65, + 0x61, 0x63, 0x68, 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x70, + 0x6f, 0x69, 0x6e, 0x74, 0x12, 0x4e, 0x0a, 0x04, 0x6b, 0x69, 0x6e, 0x64, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x0e, 0x32, 0x3a, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x52, 0x65, 0x61, + 0x63, 0x68, 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x70, 0x6f, + 0x69, 0x6e, 0x74, 0x2e, 0x52, 0x65, 0x61, 0x63, 0x68, 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, + 0x45, 0x6e, 0x74, 0x72, 0x79, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x4b, 0x69, 0x6e, 0x64, 0x52, 0x04, + 0x6b, 0x69, 0x6e, 0x64, 0x12, 0x43, 0x0a, 0x0f, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x5f, 0x72, + 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, + 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x52, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x0e, 0x74, 0x61, 0x72, 0x67, 0x65, + 0x74, 0x52, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x5b, 0x0a, 0x0d, 0x72, 0x65, 0x73, + 0x75, 0x6c, 0x74, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0e, + 0x32, 0x36, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x52, 0x65, 0x61, 0x63, 0x68, + 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x70, 0x6f, 0x69, 0x6e, + 0x74, 0x2e, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x75, + 0x6c, 0x74, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x0c, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, + 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x2b, 0x0a, 0x11, 0x74, 0x75, 0x70, 0x6c, 0x65, 0x73, + 0x65, 0x74, 0x5f, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x10, 0x74, 0x75, 0x70, 0x6c, 0x65, 0x73, 0x65, 0x74, 0x52, 0x65, 0x6c, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x12, 0x3a, 0x0a, 0x19, 0x63, 0x6f, 0x6d, 0x70, 0x75, 0x74, 0x65, 0x64, 0x5f, + 0x75, 0x73, 0x65, 0x72, 0x73, 0x65, 0x74, 0x5f, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x17, 0x63, 0x6f, 0x6d, 0x70, 0x75, 0x74, 0x65, 0x64, + 0x55, 0x73, 0x65, 0x72, 0x73, 0x65, 0x74, 0x52, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x22, + 0x7a, 0x0a, 0x1a, 0x52, 0x65, 0x61, 0x63, 0x68, 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x45, + 0x6e, 0x74, 0x72, 0x79, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x4b, 0x69, 0x6e, 0x64, 0x12, 0x17, 0x0a, + 0x13, 0x52, 0x45, 0x4c, 0x41, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x45, 0x4e, 0x54, 0x52, 0x59, 0x50, + 0x4f, 0x49, 0x4e, 0x54, 0x10, 0x00, 0x12, 0x1f, 0x0a, 0x1b, 0x43, 0x4f, 0x4d, 0x50, 0x55, 0x54, + 0x45, 0x44, 0x5f, 0x55, 0x53, 0x45, 0x52, 0x53, 0x45, 0x54, 0x5f, 0x45, 0x4e, 0x54, 0x52, 0x59, + 0x50, 0x4f, 0x49, 0x4e, 0x54, 0x10, 0x01, 0x12, 0x22, 0x0a, 0x1e, 0x54, 0x55, 0x50, 0x4c, 0x45, + 0x53, 0x45, 0x54, 0x5f, 0x54, 0x4f, 0x5f, 0x55, 0x53, 0x45, 0x52, 0x53, 0x45, 0x54, 0x5f, 0x45, + 0x4e, 0x54, 0x52, 0x59, 0x50, 0x4f, 0x49, 0x4e, 0x54, 0x10, 0x02, 0x22, 0x57, 0x0a, 0x16, 0x45, + 0x6e, 0x74, 0x72, 0x79, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x53, + 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x20, 0x0a, 0x1c, 0x52, 0x45, 0x41, 0x43, 0x48, 0x41, 0x42, + 0x4c, 0x45, 0x5f, 0x43, 0x4f, 0x4e, 0x44, 0x49, 0x54, 0x49, 0x4f, 0x4e, 0x41, 0x4c, 0x5f, 0x52, + 0x45, 0x53, 0x55, 0x4c, 0x54, 0x10, 0x00, 0x12, 0x1b, 0x0a, 0x17, 0x44, 0x49, 0x52, 0x45, 0x43, + 0x54, 0x5f, 0x4f, 0x50, 0x45, 0x52, 0x41, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x52, 0x45, 0x53, 0x55, + 0x4c, 0x54, 0x10, 0x01, 0x4a, 0x04, 0x08, 0x03, 0x10, 0x04, 0x22, 0x65, 0x0a, 0x0f, 0x54, 0x79, + 0x70, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x52, 0x0a, + 0x18, 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x65, 0x64, 0x5f, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x5f, + 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, + 0x18, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x41, 0x6c, 0x6c, 0x6f, 0x77, 0x65, + 0x64, 0x52, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x16, 0x61, 0x6c, 0x6c, 0x6f, 0x77, + 0x65, 0x64, 0x44, 0x69, 0x72, 0x65, 0x63, 0x74, 0x52, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x73, 0x22, 0x95, 0x04, 0x0a, 0x0f, 0x41, 0x6c, 0x6c, 0x6f, 0x77, 0x65, 0x64, 0x52, 0x65, 0x6c, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x66, 0x0a, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, + 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x48, 0xfa, 0x42, 0x45, 0x72, 0x43, 0x28, + 0x80, 0x01, 0x32, 0x3e, 0x5e, 0x28, 0x5b, 0x61, 0x2d, 0x7a, 0x5d, 0x5b, 0x61, 0x2d, 0x7a, 0x30, + 0x2d, 0x39, 0x5f, 0x5d, 0x7b, 0x31, 0x2c, 0x36, 0x31, 0x7d, 0x5b, 0x61, 0x2d, 0x7a, 0x30, 0x2d, + 0x39, 0x5d, 0x2f, 0x29, 0x2a, 0x5b, 0x61, 0x2d, 0x7a, 0x5d, 0x5b, 0x61, 0x2d, 0x7a, 0x30, 0x2d, + 0x39, 0x5f, 0x5d, 0x7b, 0x31, 0x2c, 0x36, 0x32, 0x7d, 0x5b, 0x61, 0x2d, 0x7a, 0x30, 0x2d, 0x39, + 0x5d, 0x24, 0x52, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x12, 0x4e, 0x0a, + 0x08, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x42, + 0x30, 0xfa, 0x42, 0x2d, 0x72, 0x2b, 0x28, 0x40, 0x32, 0x27, 0x5e, 0x28, 0x5c, 0x2e, 0x5c, 0x2e, + 0x5c, 0x2e, 0x7c, 0x5b, 0x61, 0x2d, 0x7a, 0x5d, 0x5b, 0x61, 0x2d, 0x7a, 0x30, 0x2d, 0x39, 0x5f, + 0x5d, 0x7b, 0x31, 0x2c, 0x36, 0x32, 0x7d, 0x5b, 0x61, 0x2d, 0x7a, 0x30, 0x2d, 0x39, 0x5d, 0x29, + 0x24, 0x48, 0x00, 0x52, 0x08, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x52, 0x0a, + 0x0f, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x5f, 0x77, 0x69, 0x6c, 0x64, 0x63, 0x61, 0x72, 0x64, + 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x27, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, + 0x2e, 0x41, 0x6c, 0x6c, 0x6f, 0x77, 0x65, 0x64, 0x52, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x2e, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x57, 0x69, 0x6c, 0x64, 0x63, 0x61, 0x72, 0x64, 0x48, + 0x00, 0x52, 0x0e, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x57, 0x69, 0x6c, 0x64, 0x63, 0x61, 0x72, + 0x64, 0x12, 0x40, 0x0a, 0x0f, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x70, 0x6f, 0x73, 0x69, + 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x63, 0x6f, 0x72, + 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x50, 0x6f, 0x73, 0x69, 0x74, + 0x69, 0x6f, 0x6e, 0x52, 0x0e, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x50, 0x6f, 0x73, 0x69, 0x74, + 0x69, 0x6f, 0x6e, 0x12, 0x3f, 0x0a, 0x0f, 0x72, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x5f, + 0x63, 0x61, 0x76, 0x65, 0x61, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x63, + 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x41, 0x6c, 0x6c, 0x6f, 0x77, 0x65, 0x64, 0x43, 0x61, + 0x76, 0x65, 0x61, 0x74, 0x52, 0x0e, 0x72, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x43, 0x61, + 0x76, 0x65, 0x61, 0x74, 0x12, 0x49, 0x0a, 0x13, 0x72, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, + 0x5f, 0x65, 0x78, 0x70, 0x69, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x07, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x18, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x45, 0x78, 0x70, 0x69, + 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x54, 0x72, 0x61, 0x69, 0x74, 0x52, 0x12, 0x72, 0x65, 0x71, + 0x75, 0x69, 0x72, 0x65, 0x64, 0x45, 0x78, 0x70, 0x69, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x1a, + 0x10, 0x0a, 0x0e, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x57, 0x69, 0x6c, 0x64, 0x63, 0x61, 0x72, + 0x64, 0x42, 0x16, 0x0a, 0x14, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x6f, 0x72, + 0x5f, 0x77, 0x69, 0x6c, 0x64, 0x63, 0x61, 0x72, 0x64, 0x22, 0x11, 0x0a, 0x0f, 0x45, 0x78, 0x70, + 0x69, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x54, 0x72, 0x61, 0x69, 0x74, 0x22, 0x30, 0x0a, 0x0d, + 0x41, 0x6c, 0x6c, 0x6f, 0x77, 0x65, 0x64, 0x43, 0x61, 0x76, 0x65, 0x61, 0x74, 0x12, 0x1f, 0x0a, + 0x0b, 0x63, 0x61, 0x76, 0x65, 0x61, 0x74, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x0a, 0x63, 0x61, 0x76, 0x65, 0x61, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x22, 0xad, + 0x02, 0x0a, 0x0e, 0x55, 0x73, 0x65, 0x72, 0x73, 0x65, 0x74, 0x52, 0x65, 0x77, 0x72, 0x69, 0x74, + 0x65, 0x12, 0x37, 0x0a, 0x05, 0x75, 0x6e, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x15, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65, 0x74, 0x4f, 0x70, + 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x08, 0xfa, 0x42, 0x05, 0x8a, 0x01, 0x02, 0x10, + 0x01, 0x48, 0x00, 0x52, 0x05, 0x75, 0x6e, 0x69, 0x6f, 0x6e, 0x12, 0x45, 0x0a, 0x0c, 0x69, 0x6e, + 0x74, 0x65, 0x72, 0x73, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x15, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65, 0x74, 0x4f, 0x70, + 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x08, 0xfa, 0x42, 0x05, 0x8a, 0x01, 0x02, 0x10, + 0x01, 0x48, 0x00, 0x52, 0x0c, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x73, 0x65, 0x63, 0x74, 0x69, 0x6f, + 0x6e, 0x12, 0x3f, 0x0a, 0x09, 0x65, 0x78, 0x63, 0x6c, 0x75, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x53, + 0x65, 0x74, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x08, 0xfa, 0x42, 0x05, + 0x8a, 0x01, 0x02, 0x10, 0x01, 0x48, 0x00, 0x52, 0x09, 0x65, 0x78, 0x63, 0x6c, 0x75, 0x73, 0x69, + 0x6f, 0x6e, 0x12, 0x40, 0x0a, 0x0f, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x70, 0x6f, 0x73, + 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x63, 0x6f, + 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x50, 0x6f, 0x73, 0x69, + 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0e, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x50, 0x6f, 0x73, 0x69, + 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x18, 0x0a, 0x11, 0x72, 0x65, 0x77, 0x72, 0x69, 0x74, 0x65, 0x5f, + 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x03, 0xf8, 0x42, 0x01, 0x22, 0xb2, + 0x05, 0x0a, 0x0c, 0x53, 0x65, 0x74, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, + 0x42, 0x0a, 0x05, 0x63, 0x68, 0x69, 0x6c, 0x64, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1b, + 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65, 0x74, 0x4f, 0x70, 0x65, 0x72, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x43, 0x68, 0x69, 0x6c, 0x64, 0x42, 0x0f, 0xfa, 0x42, 0x0c, + 0x92, 0x01, 0x09, 0x08, 0x01, 0x22, 0x05, 0x8a, 0x01, 0x02, 0x10, 0x01, 0x52, 0x05, 0x63, 0x68, + 0x69, 0x6c, 0x64, 0x1a, 0xdd, 0x04, 0x0a, 0x05, 0x43, 0x68, 0x69, 0x6c, 0x64, 0x12, 0x37, 0x0a, + 0x05, 0x5f, 0x74, 0x68, 0x69, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x63, + 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65, 0x74, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x2e, 0x43, 0x68, 0x69, 0x6c, 0x64, 0x2e, 0x54, 0x68, 0x69, 0x73, 0x48, 0x00, + 0x52, 0x04, 0x54, 0x68, 0x69, 0x73, 0x12, 0x4f, 0x0a, 0x10, 0x63, 0x6f, 0x6d, 0x70, 0x75, 0x74, + 0x65, 0x64, 0x5f, 0x75, 0x73, 0x65, 0x72, 0x73, 0x65, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x18, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x75, + 0x74, 0x65, 0x64, 0x55, 0x73, 0x65, 0x72, 0x73, 0x65, 0x74, 0x42, 0x08, 0xfa, 0x42, 0x05, 0x8a, + 0x01, 0x02, 0x10, 0x01, 0x48, 0x00, 0x52, 0x0f, 0x63, 0x6f, 0x6d, 0x70, 0x75, 0x74, 0x65, 0x64, + 0x55, 0x73, 0x65, 0x72, 0x73, 0x65, 0x74, 0x12, 0x4d, 0x0a, 0x10, 0x74, 0x75, 0x70, 0x6c, 0x65, + 0x5f, 0x74, 0x6f, 0x5f, 0x75, 0x73, 0x65, 0x72, 0x73, 0x65, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x17, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x75, 0x70, 0x6c, + 0x65, 0x54, 0x6f, 0x55, 0x73, 0x65, 0x72, 0x73, 0x65, 0x74, 0x42, 0x08, 0xfa, 0x42, 0x05, 0x8a, + 0x01, 0x02, 0x10, 0x01, 0x48, 0x00, 0x52, 0x0e, 0x74, 0x75, 0x70, 0x6c, 0x65, 0x54, 0x6f, 0x55, + 0x73, 0x65, 0x72, 0x73, 0x65, 0x74, 0x12, 0x4c, 0x0a, 0x0f, 0x75, 0x73, 0x65, 0x72, 0x73, 0x65, + 0x74, 0x5f, 0x72, 0x65, 0x77, 0x72, 0x69, 0x74, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x17, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x73, 0x65, + 0x74, 0x52, 0x65, 0x77, 0x72, 0x69, 0x74, 0x65, 0x42, 0x08, 0xfa, 0x42, 0x05, 0x8a, 0x01, 0x02, + 0x10, 0x01, 0x48, 0x00, 0x52, 0x0e, 0x75, 0x73, 0x65, 0x72, 0x73, 0x65, 0x74, 0x52, 0x65, 0x77, + 0x72, 0x69, 0x74, 0x65, 0x12, 0x6c, 0x0a, 0x1b, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, + 0x65, 0x64, 0x5f, 0x74, 0x75, 0x70, 0x6c, 0x65, 0x5f, 0x74, 0x6f, 0x5f, 0x75, 0x73, 0x65, 0x72, + 0x73, 0x65, 0x74, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x63, 0x6f, 0x72, 0x65, + 0x2e, 0x76, 0x31, 0x2e, 0x46, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x65, 0x64, 0x54, 0x75, + 0x70, 0x6c, 0x65, 0x54, 0x6f, 0x55, 0x73, 0x65, 0x72, 0x73, 0x65, 0x74, 0x42, 0x08, 0xfa, 0x42, + 0x05, 0x8a, 0x01, 0x02, 0x10, 0x01, 0x48, 0x00, 0x52, 0x18, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, + 0x6f, 0x6e, 0x65, 0x64, 0x54, 0x75, 0x70, 0x6c, 0x65, 0x54, 0x6f, 0x55, 0x73, 0x65, 0x72, 0x73, + 0x65, 0x74, 0x12, 0x34, 0x0a, 0x04, 0x5f, 0x6e, 0x69, 0x6c, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x1f, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65, 0x74, 0x4f, 0x70, + 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x43, 0x68, 0x69, 0x6c, 0x64, 0x2e, 0x4e, 0x69, + 0x6c, 0x48, 0x00, 0x52, 0x03, 0x4e, 0x69, 0x6c, 0x12, 0x40, 0x0a, 0x0f, 0x73, 0x6f, 0x75, 0x72, + 0x63, 0x65, 0x5f, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x17, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x6f, 0x75, 0x72, + 0x63, 0x65, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0e, 0x73, 0x6f, 0x75, 0x72, + 0x63, 0x65, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x25, 0x0a, 0x0e, 0x6f, 0x70, + 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x70, 0x61, 0x74, 0x68, 0x18, 0x07, 0x20, 0x03, + 0x28, 0x0d, 0x52, 0x0d, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x61, 0x74, + 0x68, 0x1a, 0x06, 0x0a, 0x04, 0x54, 0x68, 0x69, 0x73, 0x1a, 0x05, 0x0a, 0x03, 0x4e, 0x69, 0x6c, + 0x42, 0x11, 0x0a, 0x0a, 0x63, 0x68, 0x69, 0x6c, 0x64, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x12, 0x03, + 0xf8, 0x42, 0x01, 0x22, 0xba, 0x02, 0x0a, 0x0e, 0x54, 0x75, 0x70, 0x6c, 0x65, 0x54, 0x6f, 0x55, + 0x73, 0x65, 0x72, 0x73, 0x65, 0x74, 0x12, 0x46, 0x0a, 0x08, 0x74, 0x75, 0x70, 0x6c, 0x65, 0x73, + 0x65, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, + 0x76, 0x31, 0x2e, 0x54, 0x75, 0x70, 0x6c, 0x65, 0x54, 0x6f, 0x55, 0x73, 0x65, 0x72, 0x73, 0x65, + 0x74, 0x2e, 0x54, 0x75, 0x70, 0x6c, 0x65, 0x73, 0x65, 0x74, 0x42, 0x08, 0xfa, 0x42, 0x05, 0x8a, + 0x01, 0x02, 0x10, 0x01, 0x52, 0x08, 0x74, 0x75, 0x70, 0x6c, 0x65, 0x73, 0x65, 0x74, 0x12, 0x4d, + 0x0a, 0x10, 0x63, 0x6f, 0x6d, 0x70, 0x75, 0x74, 0x65, 0x64, 0x5f, 0x75, 0x73, 0x65, 0x72, 0x73, + 0x65, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, + 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x75, 0x74, 0x65, 0x64, 0x55, 0x73, 0x65, 0x72, 0x73, + 0x65, 0x74, 0x42, 0x08, 0xfa, 0x42, 0x05, 0x8a, 0x01, 0x02, 0x10, 0x01, 0x52, 0x0f, 0x63, 0x6f, + 0x6d, 0x70, 0x75, 0x74, 0x65, 0x64, 0x55, 0x73, 0x65, 0x72, 0x73, 0x65, 0x74, 0x12, 0x40, 0x0a, + 0x0f, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, + 0x2e, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x52, + 0x0e, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x1a, + 0x4f, 0x0a, 0x08, 0x54, 0x75, 0x70, 0x6c, 0x65, 0x73, 0x65, 0x74, 0x12, 0x43, 0x0a, 0x08, 0x72, + 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x27, 0xfa, + 0x42, 0x24, 0x72, 0x22, 0x28, 0x40, 0x32, 0x1e, 0x5e, 0x5b, 0x61, 0x2d, 0x7a, 0x5d, 0x5b, 0x61, + 0x2d, 0x7a, 0x30, 0x2d, 0x39, 0x5f, 0x5d, 0x7b, 0x31, 0x2c, 0x36, 0x32, 0x7d, 0x5b, 0x61, 0x2d, + 0x7a, 0x30, 0x2d, 0x39, 0x5d, 0x24, 0x52, 0x08, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x22, 0xec, 0x03, 0x0a, 0x18, 0x46, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x65, 0x64, 0x54, + 0x75, 0x70, 0x6c, 0x65, 0x54, 0x6f, 0x55, 0x73, 0x65, 0x72, 0x73, 0x65, 0x74, 0x12, 0x52, 0x0a, + 0x08, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, + 0x2a, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x46, 0x75, 0x6e, 0x63, 0x74, 0x69, + 0x6f, 0x6e, 0x65, 0x64, 0x54, 0x75, 0x70, 0x6c, 0x65, 0x54, 0x6f, 0x55, 0x73, 0x65, 0x72, 0x73, + 0x65, 0x74, 0x2e, 0x46, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x0a, 0xfa, 0x42, 0x07, + 0x82, 0x01, 0x04, 0x10, 0x01, 0x20, 0x00, 0x52, 0x08, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, + 0x6e, 0x12, 0x50, 0x0a, 0x08, 0x74, 0x75, 0x70, 0x6c, 0x65, 0x73, 0x65, 0x74, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x2a, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x46, 0x75, + 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x65, 0x64, 0x54, 0x75, 0x70, 0x6c, 0x65, 0x54, 0x6f, 0x55, + 0x73, 0x65, 0x72, 0x73, 0x65, 0x74, 0x2e, 0x54, 0x75, 0x70, 0x6c, 0x65, 0x73, 0x65, 0x74, 0x42, + 0x08, 0xfa, 0x42, 0x05, 0x8a, 0x01, 0x02, 0x10, 0x01, 0x52, 0x08, 0x74, 0x75, 0x70, 0x6c, 0x65, + 0x73, 0x65, 0x74, 0x12, 0x4d, 0x0a, 0x10, 0x63, 0x6f, 0x6d, 0x70, 0x75, 0x74, 0x65, 0x64, 0x5f, + 0x75, 0x73, 0x65, 0x72, 0x73, 0x65, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, + 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x75, 0x74, 0x65, 0x64, + 0x55, 0x73, 0x65, 0x72, 0x73, 0x65, 0x74, 0x42, 0x08, 0xfa, 0x42, 0x05, 0x8a, 0x01, 0x02, 0x10, + 0x01, 0x52, 0x0f, 0x63, 0x6f, 0x6d, 0x70, 0x75, 0x74, 0x65, 0x64, 0x55, 0x73, 0x65, 0x72, 0x73, + 0x65, 0x74, 0x12, 0x40, 0x0a, 0x0f, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x70, 0x6f, 0x73, + 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x63, 0x6f, + 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x50, 0x6f, 0x73, 0x69, + 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0e, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x50, 0x6f, 0x73, 0x69, + 0x74, 0x69, 0x6f, 0x6e, 0x1a, 0x4f, 0x0a, 0x08, 0x54, 0x75, 0x70, 0x6c, 0x65, 0x73, 0x65, 0x74, + 0x12, 0x43, 0x0a, 0x08, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x42, 0x27, 0xfa, 0x42, 0x24, 0x72, 0x22, 0x28, 0x40, 0x32, 0x1e, 0x5e, 0x5b, 0x61, + 0x2d, 0x7a, 0x5d, 0x5b, 0x61, 0x2d, 0x7a, 0x30, 0x2d, 0x39, 0x5f, 0x5d, 0x7b, 0x31, 0x2c, 0x36, + 0x32, 0x7d, 0x5b, 0x61, 0x2d, 0x7a, 0x30, 0x2d, 0x39, 0x5d, 0x24, 0x52, 0x08, 0x72, 0x65, 0x6c, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x48, 0x0a, 0x08, 0x46, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, + 0x6e, 0x12, 0x18, 0x0a, 0x14, 0x46, 0x55, 0x4e, 0x43, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x55, 0x4e, + 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x10, 0x0a, 0x0c, 0x46, + 0x55, 0x4e, 0x43, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x41, 0x4e, 0x59, 0x10, 0x01, 0x12, 0x10, 0x0a, + 0x0c, 0x46, 0x55, 0x4e, 0x43, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x41, 0x4c, 0x4c, 0x10, 0x02, 0x22, + 0x91, 0x02, 0x0a, 0x0f, 0x43, 0x6f, 0x6d, 0x70, 0x75, 0x74, 0x65, 0x64, 0x55, 0x73, 0x65, 0x72, + 0x73, 0x65, 0x74, 0x12, 0x41, 0x0a, 0x06, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x0e, 0x32, 0x1f, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f, + 0x6d, 0x70, 0x75, 0x74, 0x65, 0x64, 0x55, 0x73, 0x65, 0x72, 0x73, 0x65, 0x74, 0x2e, 0x4f, 0x62, + 0x6a, 0x65, 0x63, 0x74, 0x42, 0x08, 0xfa, 0x42, 0x05, 0x82, 0x01, 0x02, 0x10, 0x01, 0x52, 0x06, + 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x43, 0x0a, 0x08, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, 0x27, 0xfa, 0x42, 0x24, 0x72, 0x22, 0x28, + 0x40, 0x32, 0x1e, 0x5e, 0x5b, 0x61, 0x2d, 0x7a, 0x5d, 0x5b, 0x61, 0x2d, 0x7a, 0x30, 0x2d, 0x39, + 0x5f, 0x5d, 0x7b, 0x31, 0x2c, 0x36, 0x32, 0x7d, 0x5b, 0x61, 0x2d, 0x7a, 0x30, 0x2d, 0x39, 0x5d, + 0x24, 0x52, 0x08, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x40, 0x0a, 0x0f, 0x73, + 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x53, + 0x6f, 0x75, 0x72, 0x63, 0x65, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0e, 0x73, + 0x6f, 0x75, 0x72, 0x63, 0x65, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x34, 0x0a, + 0x06, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x10, 0x0a, 0x0c, 0x54, 0x55, 0x50, 0x4c, 0x45, + 0x5f, 0x4f, 0x42, 0x4a, 0x45, 0x43, 0x54, 0x10, 0x00, 0x12, 0x18, 0x0a, 0x14, 0x54, 0x55, 0x50, + 0x4c, 0x45, 0x5f, 0x55, 0x53, 0x45, 0x52, 0x53, 0x45, 0x54, 0x5f, 0x4f, 0x42, 0x4a, 0x45, 0x43, + 0x54, 0x10, 0x01, 0x22, 0x8a, 0x01, 0x0a, 0x0e, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x50, 0x6f, + 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x37, 0x0a, 0x18, 0x7a, 0x65, 0x72, 0x6f, 0x5f, 0x69, + 0x6e, 0x64, 0x65, 0x78, 0x65, 0x64, 0x5f, 0x6c, 0x69, 0x6e, 0x65, 0x5f, 0x6e, 0x75, 0x6d, 0x62, + 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x15, 0x7a, 0x65, 0x72, 0x6f, 0x49, 0x6e, + 0x64, 0x65, 0x78, 0x65, 0x64, 0x4c, 0x69, 0x6e, 0x65, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, + 0x3f, 0x0a, 0x1c, 0x7a, 0x65, 0x72, 0x6f, 0x5f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x65, 0x64, 0x5f, + 0x63, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x5f, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x19, 0x7a, 0x65, 0x72, 0x6f, 0x49, 0x6e, 0x64, 0x65, 0x78, + 0x65, 0x64, 0x43, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, + 0x22, 0x9c, 0x01, 0x0a, 0x10, 0x43, 0x61, 0x76, 0x65, 0x61, 0x74, 0x45, 0x78, 0x70, 0x72, 0x65, + 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x38, 0x0a, 0x09, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, + 0x76, 0x31, 0x2e, 0x43, 0x61, 0x76, 0x65, 0x61, 0x74, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x48, 0x00, 0x52, 0x09, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, + 0x37, 0x0a, 0x06, 0x63, 0x61, 0x76, 0x65, 0x61, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x1d, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, + 0x74, 0x75, 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x64, 0x43, 0x61, 0x76, 0x65, 0x61, 0x74, 0x48, 0x00, + 0x52, 0x06, 0x63, 0x61, 0x76, 0x65, 0x61, 0x74, 0x42, 0x15, 0x0a, 0x13, 0x6f, 0x70, 0x65, 0x72, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x6f, 0x72, 0x5f, 0x63, 0x61, 0x76, 0x65, 0x61, 0x74, 0x22, + 0xb0, 0x01, 0x0a, 0x0f, 0x43, 0x61, 0x76, 0x65, 0x61, 0x74, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x12, 0x32, 0x0a, 0x02, 0x6f, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, + 0x22, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x61, 0x76, 0x65, 0x61, 0x74, + 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x52, 0x02, 0x6f, 0x70, 0x12, 0x35, 0x0a, 0x08, 0x63, 0x68, 0x69, 0x6c, 0x64, + 0x72, 0x65, 0x6e, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x63, 0x6f, 0x72, 0x65, + 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x61, 0x76, 0x65, 0x61, 0x74, 0x45, 0x78, 0x70, 0x72, 0x65, 0x73, + 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x08, 0x63, 0x68, 0x69, 0x6c, 0x64, 0x72, 0x65, 0x6e, 0x22, 0x32, + 0x0a, 0x09, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x0b, 0x0a, 0x07, 0x55, + 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x06, 0x0a, 0x02, 0x4f, 0x52, 0x10, 0x01, + 0x12, 0x07, 0x0a, 0x03, 0x41, 0x4e, 0x44, 0x10, 0x02, 0x12, 0x07, 0x0a, 0x03, 0x4e, 0x4f, 0x54, + 0x10, 0x03, 0x22, 0xee, 0x03, 0x0a, 0x12, 0x52, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, + 0x68, 0x69, 0x70, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x12, 0x70, 0x0a, 0x0d, 0x72, 0x65, 0x73, + 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x42, 0x4b, 0xfa, 0x42, 0x48, 0x72, 0x46, 0x28, 0x80, 0x01, 0x32, 0x41, 0x5e, 0x28, 0x28, 0x5b, + 0x61, 0x2d, 0x7a, 0x5d, 0x5b, 0x61, 0x2d, 0x7a, 0x30, 0x2d, 0x39, 0x5f, 0x5d, 0x7b, 0x31, 0x2c, + 0x36, 0x31, 0x7d, 0x5b, 0x61, 0x2d, 0x7a, 0x30, 0x2d, 0x39, 0x5d, 0x2f, 0x29, 0x2a, 0x5b, 0x61, + 0x2d, 0x7a, 0x5d, 0x5b, 0x61, 0x2d, 0x7a, 0x30, 0x2d, 0x39, 0x5f, 0x5d, 0x7b, 0x31, 0x2c, 0x36, + 0x32, 0x7d, 0x5b, 0x61, 0x2d, 0x7a, 0x30, 0x2d, 0x39, 0x5d, 0x29, 0x3f, 0x24, 0x52, 0x0c, 0x72, + 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, 0x57, 0x0a, 0x14, 0x6f, + 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x5f, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, + 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, 0x25, 0xfa, 0x42, 0x22, 0x72, 0x20, + 0x28, 0x80, 0x08, 0x32, 0x1b, 0x5e, 0x28, 0x5b, 0x61, 0x2d, 0x7a, 0x41, 0x2d, 0x5a, 0x30, 0x2d, + 0x39, 0x2f, 0x5f, 0x7c, 0x5c, 0x2d, 0x3d, 0x2b, 0x5d, 0x7b, 0x31, 0x2c, 0x7d, 0x29, 0x3f, 0x24, + 0x52, 0x12, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, + 0x63, 0x65, 0x49, 0x64, 0x12, 0x64, 0x0a, 0x1b, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, + 0x5f, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x69, 0x64, 0x5f, 0x70, 0x72, 0x65, + 0x66, 0x69, 0x78, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x42, 0x25, 0xfa, 0x42, 0x22, 0x72, 0x20, + 0x28, 0x80, 0x08, 0x32, 0x1b, 0x5e, 0x28, 0x5b, 0x61, 0x2d, 0x7a, 0x41, 0x2d, 0x5a, 0x30, 0x2d, + 0x39, 0x2f, 0x5f, 0x7c, 0x5c, 0x2d, 0x3d, 0x2b, 0x5d, 0x7b, 0x31, 0x2c, 0x7d, 0x29, 0x3f, 0x24, + 0x52, 0x18, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, + 0x63, 0x65, 0x49, 0x64, 0x50, 0x72, 0x65, 0x66, 0x69, 0x78, 0x12, 0x57, 0x0a, 0x11, 0x6f, 0x70, + 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x5f, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, + 0x03, 0x20, 0x01, 0x28, 0x09, 0x42, 0x2a, 0xfa, 0x42, 0x27, 0x72, 0x25, 0x28, 0x40, 0x32, 0x21, + 0x5e, 0x28, 0x5b, 0x61, 0x2d, 0x7a, 0x5d, 0x5b, 0x61, 0x2d, 0x7a, 0x30, 0x2d, 0x39, 0x5f, 0x5d, + 0x7b, 0x31, 0x2c, 0x36, 0x32, 0x7d, 0x5b, 0x61, 0x2d, 0x7a, 0x30, 0x2d, 0x39, 0x5d, 0x29, 0x3f, + 0x24, 0x52, 0x10, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x52, 0x65, 0x6c, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x12, 0x4e, 0x0a, 0x17, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x5f, + 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x5f, 0x66, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x18, 0x04, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x53, + 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x52, 0x15, 0x6f, 0x70, + 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x53, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x46, 0x69, 0x6c, + 0x74, 0x65, 0x72, 0x22, 0x86, 0x03, 0x0a, 0x0d, 0x53, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x46, + 0x69, 0x6c, 0x74, 0x65, 0x72, 0x12, 0x6b, 0x0a, 0x0c, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, + 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x48, 0xfa, 0x42, 0x45, + 0x72, 0x43, 0x28, 0x80, 0x01, 0x32, 0x3e, 0x5e, 0x28, 0x5b, 0x61, 0x2d, 0x7a, 0x5d, 0x5b, 0x61, + 0x2d, 0x7a, 0x30, 0x2d, 0x39, 0x5f, 0x5d, 0x7b, 0x31, 0x2c, 0x36, 0x31, 0x7d, 0x5b, 0x61, 0x2d, + 0x7a, 0x30, 0x2d, 0x39, 0x5d, 0x2f, 0x29, 0x2a, 0x5b, 0x61, 0x2d, 0x7a, 0x5d, 0x5b, 0x61, 0x2d, + 0x7a, 0x30, 0x2d, 0x39, 0x5f, 0x5d, 0x7b, 0x31, 0x2c, 0x36, 0x32, 0x7d, 0x5b, 0x61, 0x2d, 0x7a, + 0x30, 0x2d, 0x39, 0x5d, 0x24, 0x52, 0x0b, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x54, 0x79, + 0x70, 0x65, 0x12, 0x5a, 0x0a, 0x13, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x5f, 0x73, + 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, + 0x2a, 0xfa, 0x42, 0x27, 0x72, 0x25, 0x28, 0x80, 0x08, 0x32, 0x20, 0x5e, 0x28, 0x28, 0x5b, 0x61, + 0x2d, 0x7a, 0x41, 0x2d, 0x5a, 0x30, 0x2d, 0x39, 0x2f, 0x5f, 0x7c, 0x5c, 0x2d, 0x3d, 0x2b, 0x5d, + 0x7b, 0x31, 0x2c, 0x7d, 0x29, 0x7c, 0x5c, 0x2a, 0x29, 0x3f, 0x24, 0x52, 0x11, 0x6f, 0x70, 0x74, + 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x53, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x49, 0x64, 0x12, 0x52, + 0x0a, 0x11, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x5f, 0x72, 0x65, 0x6c, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x63, 0x6f, 0x72, 0x65, + 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x46, 0x69, 0x6c, 0x74, 0x65, + 0x72, 0x2e, 0x52, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, + 0x52, 0x10, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x52, 0x65, 0x6c, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x1a, 0x58, 0x0a, 0x0e, 0x52, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x46, 0x69, + 0x6c, 0x74, 0x65, 0x72, 0x12, 0x46, 0x0a, 0x08, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x2a, 0xfa, 0x42, 0x27, 0x72, 0x25, 0x28, 0x40, 0x32, + 0x21, 0x5e, 0x28, 0x5b, 0x61, 0x2d, 0x7a, 0x5d, 0x5b, 0x61, 0x2d, 0x7a, 0x30, 0x2d, 0x39, 0x5f, + 0x5d, 0x7b, 0x31, 0x2c, 0x36, 0x32, 0x7d, 0x5b, 0x61, 0x2d, 0x7a, 0x30, 0x2d, 0x39, 0x5d, 0x29, + 0x3f, 0x24, 0x52, 0x08, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x8a, 0x01, 0x0a, + 0x0b, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x42, 0x09, 0x43, 0x6f, + 0x72, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x33, 0x67, 0x69, 0x74, 0x68, 0x75, + 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x61, 0x75, 0x74, 0x68, 0x7a, 0x65, 0x64, 0x2f, 0x73, 0x70, + 0x69, 0x63, 0x65, 0x64, 0x62, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, + 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x76, 0x31, 0x3b, 0x63, 0x6f, 0x72, 0x65, 0x76, 0x31, 0xa2, 0x02, + 0x03, 0x43, 0x58, 0x58, 0xaa, 0x02, 0x07, 0x43, 0x6f, 0x72, 0x65, 0x2e, 0x56, 0x31, 0xca, 0x02, + 0x07, 0x43, 0x6f, 0x72, 0x65, 0x5c, 0x56, 0x31, 0xe2, 0x02, 0x13, 0x43, 0x6f, 0x72, 0x65, 0x5c, + 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, + 0x08, 0x43, 0x6f, 0x72, 0x65, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x33, +} + +var ( + file_core_v1_core_proto_rawDescOnce sync.Once + file_core_v1_core_proto_rawDescData = file_core_v1_core_proto_rawDesc +) + +func file_core_v1_core_proto_rawDescGZIP() []byte { + file_core_v1_core_proto_rawDescOnce.Do(func() { + file_core_v1_core_proto_rawDescData = protoimpl.X.CompressGZIP(file_core_v1_core_proto_rawDescData) + }) + return file_core_v1_core_proto_rawDescData +} + +var file_core_v1_core_proto_enumTypes = make([]protoimpl.EnumInfo, 7) +var file_core_v1_core_proto_msgTypes = make([]protoimpl.MessageInfo, 43) +var file_core_v1_core_proto_goTypes = []any{ + (RelationTupleUpdate_Operation)(0), // 0: core.v1.RelationTupleUpdate.Operation + (SetOperationUserset_Operation)(0), // 1: core.v1.SetOperationUserset.Operation + (ReachabilityEntrypoint_ReachabilityEntrypointKind)(0), // 2: core.v1.ReachabilityEntrypoint.ReachabilityEntrypointKind + (ReachabilityEntrypoint_EntrypointResultStatus)(0), // 3: core.v1.ReachabilityEntrypoint.EntrypointResultStatus + (FunctionedTupleToUserset_Function)(0), // 4: core.v1.FunctionedTupleToUserset.Function + (ComputedUserset_Object)(0), // 5: core.v1.ComputedUserset.Object + (CaveatOperation_Operation)(0), // 6: core.v1.CaveatOperation.Operation + (*RelationTuple)(nil), // 7: core.v1.RelationTuple + (*RelationshipIntegrity)(nil), // 8: core.v1.RelationshipIntegrity + (*ContextualizedCaveat)(nil), // 9: core.v1.ContextualizedCaveat + (*CaveatDefinition)(nil), // 10: core.v1.CaveatDefinition + (*CaveatTypeReference)(nil), // 11: core.v1.CaveatTypeReference + (*ObjectAndRelation)(nil), // 12: core.v1.ObjectAndRelation + (*RelationReference)(nil), // 13: core.v1.RelationReference + (*Zookie)(nil), // 14: core.v1.Zookie + (*RelationTupleUpdate)(nil), // 15: core.v1.RelationTupleUpdate + (*RelationTupleTreeNode)(nil), // 16: core.v1.RelationTupleTreeNode + (*SetOperationUserset)(nil), // 17: core.v1.SetOperationUserset + (*DirectSubject)(nil), // 18: core.v1.DirectSubject + (*DirectSubjects)(nil), // 19: core.v1.DirectSubjects + (*Metadata)(nil), // 20: core.v1.Metadata + (*NamespaceDefinition)(nil), // 21: core.v1.NamespaceDefinition + (*Relation)(nil), // 22: core.v1.Relation + (*ReachabilityGraph)(nil), // 23: core.v1.ReachabilityGraph + (*ReachabilityEntrypoints)(nil), // 24: core.v1.ReachabilityEntrypoints + (*ReachabilityEntrypoint)(nil), // 25: core.v1.ReachabilityEntrypoint + (*TypeInformation)(nil), // 26: core.v1.TypeInformation + (*AllowedRelation)(nil), // 27: core.v1.AllowedRelation + (*ExpirationTrait)(nil), // 28: core.v1.ExpirationTrait + (*AllowedCaveat)(nil), // 29: core.v1.AllowedCaveat + (*UsersetRewrite)(nil), // 30: core.v1.UsersetRewrite + (*SetOperation)(nil), // 31: core.v1.SetOperation + (*TupleToUserset)(nil), // 32: core.v1.TupleToUserset + (*FunctionedTupleToUserset)(nil), // 33: core.v1.FunctionedTupleToUserset + (*ComputedUserset)(nil), // 34: core.v1.ComputedUserset + (*SourcePosition)(nil), // 35: core.v1.SourcePosition + (*CaveatExpression)(nil), // 36: core.v1.CaveatExpression + (*CaveatOperation)(nil), // 37: core.v1.CaveatOperation + (*RelationshipFilter)(nil), // 38: core.v1.RelationshipFilter + (*SubjectFilter)(nil), // 39: core.v1.SubjectFilter + nil, // 40: core.v1.CaveatDefinition.ParameterTypesEntry + nil, // 41: core.v1.ReachabilityGraph.EntrypointsBySubjectTypeEntry + nil, // 42: core.v1.ReachabilityGraph.EntrypointsBySubjectRelationEntry + (*AllowedRelation_PublicWildcard)(nil), // 43: core.v1.AllowedRelation.PublicWildcard + (*SetOperation_Child)(nil), // 44: core.v1.SetOperation.Child + (*SetOperation_Child_This)(nil), // 45: core.v1.SetOperation.Child.This + (*SetOperation_Child_Nil)(nil), // 46: core.v1.SetOperation.Child.Nil + (*TupleToUserset_Tupleset)(nil), // 47: core.v1.TupleToUserset.Tupleset + (*FunctionedTupleToUserset_Tupleset)(nil), // 48: core.v1.FunctionedTupleToUserset.Tupleset + (*SubjectFilter_RelationFilter)(nil), // 49: core.v1.SubjectFilter.RelationFilter + (*timestamppb.Timestamp)(nil), // 50: google.protobuf.Timestamp + (*structpb.Struct)(nil), // 51: google.protobuf.Struct + (*anypb.Any)(nil), // 52: google.protobuf.Any +} +var file_core_v1_core_proto_depIdxs = []int32{ + 12, // 0: core.v1.RelationTuple.resource_and_relation:type_name -> core.v1.ObjectAndRelation + 12, // 1: core.v1.RelationTuple.subject:type_name -> core.v1.ObjectAndRelation + 9, // 2: core.v1.RelationTuple.caveat:type_name -> core.v1.ContextualizedCaveat + 8, // 3: core.v1.RelationTuple.integrity:type_name -> core.v1.RelationshipIntegrity + 50, // 4: core.v1.RelationTuple.optional_expiration_time:type_name -> google.protobuf.Timestamp + 50, // 5: core.v1.RelationshipIntegrity.hashed_at:type_name -> google.protobuf.Timestamp + 51, // 6: core.v1.ContextualizedCaveat.context:type_name -> google.protobuf.Struct + 40, // 7: core.v1.CaveatDefinition.parameter_types:type_name -> core.v1.CaveatDefinition.ParameterTypesEntry + 20, // 8: core.v1.CaveatDefinition.metadata:type_name -> core.v1.Metadata + 35, // 9: core.v1.CaveatDefinition.source_position:type_name -> core.v1.SourcePosition + 11, // 10: core.v1.CaveatTypeReference.child_types:type_name -> core.v1.CaveatTypeReference + 0, // 11: core.v1.RelationTupleUpdate.operation:type_name -> core.v1.RelationTupleUpdate.Operation + 7, // 12: core.v1.RelationTupleUpdate.tuple:type_name -> core.v1.RelationTuple + 17, // 13: core.v1.RelationTupleTreeNode.intermediate_node:type_name -> core.v1.SetOperationUserset + 19, // 14: core.v1.RelationTupleTreeNode.leaf_node:type_name -> core.v1.DirectSubjects + 12, // 15: core.v1.RelationTupleTreeNode.expanded:type_name -> core.v1.ObjectAndRelation + 36, // 16: core.v1.RelationTupleTreeNode.caveat_expression:type_name -> core.v1.CaveatExpression + 1, // 17: core.v1.SetOperationUserset.operation:type_name -> core.v1.SetOperationUserset.Operation + 16, // 18: core.v1.SetOperationUserset.child_nodes:type_name -> core.v1.RelationTupleTreeNode + 12, // 19: core.v1.DirectSubject.subject:type_name -> core.v1.ObjectAndRelation + 36, // 20: core.v1.DirectSubject.caveat_expression:type_name -> core.v1.CaveatExpression + 18, // 21: core.v1.DirectSubjects.subjects:type_name -> core.v1.DirectSubject + 52, // 22: core.v1.Metadata.metadata_message:type_name -> google.protobuf.Any + 22, // 23: core.v1.NamespaceDefinition.relation:type_name -> core.v1.Relation + 20, // 24: core.v1.NamespaceDefinition.metadata:type_name -> core.v1.Metadata + 35, // 25: core.v1.NamespaceDefinition.source_position:type_name -> core.v1.SourcePosition + 30, // 26: core.v1.Relation.userset_rewrite:type_name -> core.v1.UsersetRewrite + 26, // 27: core.v1.Relation.type_information:type_name -> core.v1.TypeInformation + 20, // 28: core.v1.Relation.metadata:type_name -> core.v1.Metadata + 35, // 29: core.v1.Relation.source_position:type_name -> core.v1.SourcePosition + 41, // 30: core.v1.ReachabilityGraph.entrypoints_by_subject_type:type_name -> core.v1.ReachabilityGraph.EntrypointsBySubjectTypeEntry + 42, // 31: core.v1.ReachabilityGraph.entrypoints_by_subject_relation:type_name -> core.v1.ReachabilityGraph.EntrypointsBySubjectRelationEntry + 25, // 32: core.v1.ReachabilityEntrypoints.entrypoints:type_name -> core.v1.ReachabilityEntrypoint + 13, // 33: core.v1.ReachabilityEntrypoints.subject_relation:type_name -> core.v1.RelationReference + 2, // 34: core.v1.ReachabilityEntrypoint.kind:type_name -> core.v1.ReachabilityEntrypoint.ReachabilityEntrypointKind + 13, // 35: core.v1.ReachabilityEntrypoint.target_relation:type_name -> core.v1.RelationReference + 3, // 36: core.v1.ReachabilityEntrypoint.result_status:type_name -> core.v1.ReachabilityEntrypoint.EntrypointResultStatus + 27, // 37: core.v1.TypeInformation.allowed_direct_relations:type_name -> core.v1.AllowedRelation + 43, // 38: core.v1.AllowedRelation.public_wildcard:type_name -> core.v1.AllowedRelation.PublicWildcard + 35, // 39: core.v1.AllowedRelation.source_position:type_name -> core.v1.SourcePosition + 29, // 40: core.v1.AllowedRelation.required_caveat:type_name -> core.v1.AllowedCaveat + 28, // 41: core.v1.AllowedRelation.required_expiration:type_name -> core.v1.ExpirationTrait + 31, // 42: core.v1.UsersetRewrite.union:type_name -> core.v1.SetOperation + 31, // 43: core.v1.UsersetRewrite.intersection:type_name -> core.v1.SetOperation + 31, // 44: core.v1.UsersetRewrite.exclusion:type_name -> core.v1.SetOperation + 35, // 45: core.v1.UsersetRewrite.source_position:type_name -> core.v1.SourcePosition + 44, // 46: core.v1.SetOperation.child:type_name -> core.v1.SetOperation.Child + 47, // 47: core.v1.TupleToUserset.tupleset:type_name -> core.v1.TupleToUserset.Tupleset + 34, // 48: core.v1.TupleToUserset.computed_userset:type_name -> core.v1.ComputedUserset + 35, // 49: core.v1.TupleToUserset.source_position:type_name -> core.v1.SourcePosition + 4, // 50: core.v1.FunctionedTupleToUserset.function:type_name -> core.v1.FunctionedTupleToUserset.Function + 48, // 51: core.v1.FunctionedTupleToUserset.tupleset:type_name -> core.v1.FunctionedTupleToUserset.Tupleset + 34, // 52: core.v1.FunctionedTupleToUserset.computed_userset:type_name -> core.v1.ComputedUserset + 35, // 53: core.v1.FunctionedTupleToUserset.source_position:type_name -> core.v1.SourcePosition + 5, // 54: core.v1.ComputedUserset.object:type_name -> core.v1.ComputedUserset.Object + 35, // 55: core.v1.ComputedUserset.source_position:type_name -> core.v1.SourcePosition + 37, // 56: core.v1.CaveatExpression.operation:type_name -> core.v1.CaveatOperation + 9, // 57: core.v1.CaveatExpression.caveat:type_name -> core.v1.ContextualizedCaveat + 6, // 58: core.v1.CaveatOperation.op:type_name -> core.v1.CaveatOperation.Operation + 36, // 59: core.v1.CaveatOperation.children:type_name -> core.v1.CaveatExpression + 39, // 60: core.v1.RelationshipFilter.optional_subject_filter:type_name -> core.v1.SubjectFilter + 49, // 61: core.v1.SubjectFilter.optional_relation:type_name -> core.v1.SubjectFilter.RelationFilter + 11, // 62: core.v1.CaveatDefinition.ParameterTypesEntry.value:type_name -> core.v1.CaveatTypeReference + 24, // 63: core.v1.ReachabilityGraph.EntrypointsBySubjectTypeEntry.value:type_name -> core.v1.ReachabilityEntrypoints + 24, // 64: core.v1.ReachabilityGraph.EntrypointsBySubjectRelationEntry.value:type_name -> core.v1.ReachabilityEntrypoints + 45, // 65: core.v1.SetOperation.Child._this:type_name -> core.v1.SetOperation.Child.This + 34, // 66: core.v1.SetOperation.Child.computed_userset:type_name -> core.v1.ComputedUserset + 32, // 67: core.v1.SetOperation.Child.tuple_to_userset:type_name -> core.v1.TupleToUserset + 30, // 68: core.v1.SetOperation.Child.userset_rewrite:type_name -> core.v1.UsersetRewrite + 33, // 69: core.v1.SetOperation.Child.functioned_tuple_to_userset:type_name -> core.v1.FunctionedTupleToUserset + 46, // 70: core.v1.SetOperation.Child._nil:type_name -> core.v1.SetOperation.Child.Nil + 35, // 71: core.v1.SetOperation.Child.source_position:type_name -> core.v1.SourcePosition + 72, // [72:72] is the sub-list for method output_type + 72, // [72:72] is the sub-list for method input_type + 72, // [72:72] is the sub-list for extension type_name + 72, // [72:72] is the sub-list for extension extendee + 0, // [0:72] is the sub-list for field type_name +} + +func init() { file_core_v1_core_proto_init() } +func file_core_v1_core_proto_init() { + if File_core_v1_core_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_core_v1_core_proto_msgTypes[0].Exporter = func(v any, i int) any { + switch v := v.(*RelationTuple); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_core_v1_core_proto_msgTypes[1].Exporter = func(v any, i int) any { + switch v := v.(*RelationshipIntegrity); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_core_v1_core_proto_msgTypes[2].Exporter = func(v any, i int) any { + switch v := v.(*ContextualizedCaveat); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_core_v1_core_proto_msgTypes[3].Exporter = func(v any, i int) any { + switch v := v.(*CaveatDefinition); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_core_v1_core_proto_msgTypes[4].Exporter = func(v any, i int) any { + switch v := v.(*CaveatTypeReference); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_core_v1_core_proto_msgTypes[5].Exporter = func(v any, i int) any { + switch v := v.(*ObjectAndRelation); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_core_v1_core_proto_msgTypes[6].Exporter = func(v any, i int) any { + switch v := v.(*RelationReference); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_core_v1_core_proto_msgTypes[7].Exporter = func(v any, i int) any { + switch v := v.(*Zookie); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_core_v1_core_proto_msgTypes[8].Exporter = func(v any, i int) any { + switch v := v.(*RelationTupleUpdate); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_core_v1_core_proto_msgTypes[9].Exporter = func(v any, i int) any { + switch v := v.(*RelationTupleTreeNode); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_core_v1_core_proto_msgTypes[10].Exporter = func(v any, i int) any { + switch v := v.(*SetOperationUserset); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_core_v1_core_proto_msgTypes[11].Exporter = func(v any, i int) any { + switch v := v.(*DirectSubject); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_core_v1_core_proto_msgTypes[12].Exporter = func(v any, i int) any { + switch v := v.(*DirectSubjects); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_core_v1_core_proto_msgTypes[13].Exporter = func(v any, i int) any { + switch v := v.(*Metadata); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_core_v1_core_proto_msgTypes[14].Exporter = func(v any, i int) any { + switch v := v.(*NamespaceDefinition); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_core_v1_core_proto_msgTypes[15].Exporter = func(v any, i int) any { + switch v := v.(*Relation); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_core_v1_core_proto_msgTypes[16].Exporter = func(v any, i int) any { + switch v := v.(*ReachabilityGraph); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_core_v1_core_proto_msgTypes[17].Exporter = func(v any, i int) any { + switch v := v.(*ReachabilityEntrypoints); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_core_v1_core_proto_msgTypes[18].Exporter = func(v any, i int) any { + switch v := v.(*ReachabilityEntrypoint); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_core_v1_core_proto_msgTypes[19].Exporter = func(v any, i int) any { + switch v := v.(*TypeInformation); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_core_v1_core_proto_msgTypes[20].Exporter = func(v any, i int) any { + switch v := v.(*AllowedRelation); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_core_v1_core_proto_msgTypes[21].Exporter = func(v any, i int) any { + switch v := v.(*ExpirationTrait); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_core_v1_core_proto_msgTypes[22].Exporter = func(v any, i int) any { + switch v := v.(*AllowedCaveat); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_core_v1_core_proto_msgTypes[23].Exporter = func(v any, i int) any { + switch v := v.(*UsersetRewrite); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_core_v1_core_proto_msgTypes[24].Exporter = func(v any, i int) any { + switch v := v.(*SetOperation); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_core_v1_core_proto_msgTypes[25].Exporter = func(v any, i int) any { + switch v := v.(*TupleToUserset); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_core_v1_core_proto_msgTypes[26].Exporter = func(v any, i int) any { + switch v := v.(*FunctionedTupleToUserset); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_core_v1_core_proto_msgTypes[27].Exporter = func(v any, i int) any { + switch v := v.(*ComputedUserset); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_core_v1_core_proto_msgTypes[28].Exporter = func(v any, i int) any { + switch v := v.(*SourcePosition); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_core_v1_core_proto_msgTypes[29].Exporter = func(v any, i int) any { + switch v := v.(*CaveatExpression); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_core_v1_core_proto_msgTypes[30].Exporter = func(v any, i int) any { + switch v := v.(*CaveatOperation); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_core_v1_core_proto_msgTypes[31].Exporter = func(v any, i int) any { + switch v := v.(*RelationshipFilter); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_core_v1_core_proto_msgTypes[32].Exporter = func(v any, i int) any { + switch v := v.(*SubjectFilter); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_core_v1_core_proto_msgTypes[36].Exporter = func(v any, i int) any { + switch v := v.(*AllowedRelation_PublicWildcard); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_core_v1_core_proto_msgTypes[37].Exporter = func(v any, i int) any { + switch v := v.(*SetOperation_Child); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_core_v1_core_proto_msgTypes[38].Exporter = func(v any, i int) any { + switch v := v.(*SetOperation_Child_This); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_core_v1_core_proto_msgTypes[39].Exporter = func(v any, i int) any { + switch v := v.(*SetOperation_Child_Nil); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_core_v1_core_proto_msgTypes[40].Exporter = func(v any, i int) any { + switch v := v.(*TupleToUserset_Tupleset); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_core_v1_core_proto_msgTypes[41].Exporter = func(v any, i int) any { + switch v := v.(*FunctionedTupleToUserset_Tupleset); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_core_v1_core_proto_msgTypes[42].Exporter = func(v any, i int) any { + switch v := v.(*SubjectFilter_RelationFilter); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + file_core_v1_core_proto_msgTypes[9].OneofWrappers = []any{ + (*RelationTupleTreeNode_IntermediateNode)(nil), + (*RelationTupleTreeNode_LeafNode)(nil), + } + file_core_v1_core_proto_msgTypes[20].OneofWrappers = []any{ + (*AllowedRelation_Relation)(nil), + (*AllowedRelation_PublicWildcard_)(nil), + } + file_core_v1_core_proto_msgTypes[23].OneofWrappers = []any{ + (*UsersetRewrite_Union)(nil), + (*UsersetRewrite_Intersection)(nil), + (*UsersetRewrite_Exclusion)(nil), + } + file_core_v1_core_proto_msgTypes[29].OneofWrappers = []any{ + (*CaveatExpression_Operation)(nil), + (*CaveatExpression_Caveat)(nil), + } + file_core_v1_core_proto_msgTypes[37].OneofWrappers = []any{ + (*SetOperation_Child_XThis)(nil), + (*SetOperation_Child_ComputedUserset)(nil), + (*SetOperation_Child_TupleToUserset)(nil), + (*SetOperation_Child_UsersetRewrite)(nil), + (*SetOperation_Child_FunctionedTupleToUserset)(nil), + (*SetOperation_Child_XNil)(nil), + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_core_v1_core_proto_rawDesc, + NumEnums: 7, + NumMessages: 43, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_core_v1_core_proto_goTypes, + DependencyIndexes: file_core_v1_core_proto_depIdxs, + EnumInfos: file_core_v1_core_proto_enumTypes, + MessageInfos: file_core_v1_core_proto_msgTypes, + }.Build() + File_core_v1_core_proto = out.File + file_core_v1_core_proto_rawDesc = nil + file_core_v1_core_proto_goTypes = nil + file_core_v1_core_proto_depIdxs = nil +} diff --git a/vendor/github.com/authzed/spicedb/pkg/proto/core/v1/core.pb.validate.go b/vendor/github.com/authzed/spicedb/pkg/proto/core/v1/core.pb.validate.go new file mode 100644 index 0000000..f8a01af --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/proto/core/v1/core.pb.validate.go @@ -0,0 +1,7023 @@ +// Code generated by protoc-gen-validate. DO NOT EDIT. +// source: core/v1/core.proto + +package corev1 + +import ( + "bytes" + "errors" + "fmt" + "net" + "net/mail" + "net/url" + "regexp" + "sort" + "strings" + "time" + "unicode/utf8" + + "google.golang.org/protobuf/types/known/anypb" +) + +// ensure the imports are used +var ( + _ = bytes.MinRead + _ = errors.New("") + _ = fmt.Print + _ = utf8.UTFMax + _ = (*regexp.Regexp)(nil) + _ = (*strings.Reader)(nil) + _ = net.IPv4len + _ = time.Duration(0) + _ = (*url.URL)(nil) + _ = (*mail.Address)(nil) + _ = anypb.Any{} + _ = sort.Sort +) + +// Validate checks the field values on RelationTuple with the rules defined in +// the proto definition for this message. If any rules are violated, the first +// error encountered is returned, or nil if there are no violations. +func (m *RelationTuple) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on RelationTuple with the rules defined +// in the proto definition for this message. If any rules are violated, the +// result is a list of violation errors wrapped in RelationTupleMultiError, or +// nil if none found. +func (m *RelationTuple) ValidateAll() error { + return m.validate(true) +} + +func (m *RelationTuple) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if m.GetResourceAndRelation() == nil { + err := RelationTupleValidationError{ + field: "ResourceAndRelation", + reason: "value is required", + } + if !all { + return err + } + errors = append(errors, err) + } + + if all { + switch v := interface{}(m.GetResourceAndRelation()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, RelationTupleValidationError{ + field: "ResourceAndRelation", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, RelationTupleValidationError{ + field: "ResourceAndRelation", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetResourceAndRelation()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return RelationTupleValidationError{ + field: "ResourceAndRelation", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if m.GetSubject() == nil { + err := RelationTupleValidationError{ + field: "Subject", + reason: "value is required", + } + if !all { + return err + } + errors = append(errors, err) + } + + if all { + switch v := interface{}(m.GetSubject()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, RelationTupleValidationError{ + field: "Subject", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, RelationTupleValidationError{ + field: "Subject", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetSubject()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return RelationTupleValidationError{ + field: "Subject", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if all { + switch v := interface{}(m.GetCaveat()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, RelationTupleValidationError{ + field: "Caveat", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, RelationTupleValidationError{ + field: "Caveat", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetCaveat()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return RelationTupleValidationError{ + field: "Caveat", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if all { + switch v := interface{}(m.GetIntegrity()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, RelationTupleValidationError{ + field: "Integrity", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, RelationTupleValidationError{ + field: "Integrity", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetIntegrity()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return RelationTupleValidationError{ + field: "Integrity", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if all { + switch v := interface{}(m.GetOptionalExpirationTime()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, RelationTupleValidationError{ + field: "OptionalExpirationTime", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, RelationTupleValidationError{ + field: "OptionalExpirationTime", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetOptionalExpirationTime()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return RelationTupleValidationError{ + field: "OptionalExpirationTime", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return RelationTupleMultiError(errors) + } + + return nil +} + +// RelationTupleMultiError is an error wrapping multiple validation errors +// returned by RelationTuple.ValidateAll() if the designated constraints +// aren't met. +type RelationTupleMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m RelationTupleMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m RelationTupleMultiError) AllErrors() []error { return m } + +// RelationTupleValidationError is the validation error returned by +// RelationTuple.Validate if the designated constraints aren't met. +type RelationTupleValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e RelationTupleValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e RelationTupleValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e RelationTupleValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e RelationTupleValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e RelationTupleValidationError) ErrorName() string { return "RelationTupleValidationError" } + +// Error satisfies the builtin error interface +func (e RelationTupleValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sRelationTuple.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = RelationTupleValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = RelationTupleValidationError{} + +// Validate checks the field values on RelationshipIntegrity with the rules +// defined in the proto definition for this message. If any rules are +// violated, the first error encountered is returned, or nil if there are no violations. +func (m *RelationshipIntegrity) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on RelationshipIntegrity with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// RelationshipIntegrityMultiError, or nil if none found. +func (m *RelationshipIntegrity) ValidateAll() error { + return m.validate(true) +} + +func (m *RelationshipIntegrity) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for KeyId + + // no validation rules for Hash + + if all { + switch v := interface{}(m.GetHashedAt()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, RelationshipIntegrityValidationError{ + field: "HashedAt", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, RelationshipIntegrityValidationError{ + field: "HashedAt", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetHashedAt()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return RelationshipIntegrityValidationError{ + field: "HashedAt", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return RelationshipIntegrityMultiError(errors) + } + + return nil +} + +// RelationshipIntegrityMultiError is an error wrapping multiple validation +// errors returned by RelationshipIntegrity.ValidateAll() if the designated +// constraints aren't met. +type RelationshipIntegrityMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m RelationshipIntegrityMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m RelationshipIntegrityMultiError) AllErrors() []error { return m } + +// RelationshipIntegrityValidationError is the validation error returned by +// RelationshipIntegrity.Validate if the designated constraints aren't met. +type RelationshipIntegrityValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e RelationshipIntegrityValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e RelationshipIntegrityValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e RelationshipIntegrityValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e RelationshipIntegrityValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e RelationshipIntegrityValidationError) ErrorName() string { + return "RelationshipIntegrityValidationError" +} + +// Error satisfies the builtin error interface +func (e RelationshipIntegrityValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sRelationshipIntegrity.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = RelationshipIntegrityValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = RelationshipIntegrityValidationError{} + +// Validate checks the field values on ContextualizedCaveat with the rules +// defined in the proto definition for this message. If any rules are +// violated, the first error encountered is returned, or nil if there are no violations. +func (m *ContextualizedCaveat) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on ContextualizedCaveat with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// ContextualizedCaveatMultiError, or nil if none found. +func (m *ContextualizedCaveat) ValidateAll() error { + return m.validate(true) +} + +func (m *ContextualizedCaveat) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if len(m.GetCaveatName()) > 128 { + err := ContextualizedCaveatValidationError{ + field: "CaveatName", + reason: "value length must be at most 128 bytes", + } + if !all { + return err + } + errors = append(errors, err) + } + + if !_ContextualizedCaveat_CaveatName_Pattern.MatchString(m.GetCaveatName()) { + err := ContextualizedCaveatValidationError{ + field: "CaveatName", + reason: "value does not match regex pattern \"^(([a-zA-Z0-9_][a-zA-Z0-9/_|-]{0,127})|\\\\*)$\"", + } + if !all { + return err + } + errors = append(errors, err) + } + + if all { + switch v := interface{}(m.GetContext()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, ContextualizedCaveatValidationError{ + field: "Context", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, ContextualizedCaveatValidationError{ + field: "Context", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetContext()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return ContextualizedCaveatValidationError{ + field: "Context", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return ContextualizedCaveatMultiError(errors) + } + + return nil +} + +// ContextualizedCaveatMultiError is an error wrapping multiple validation +// errors returned by ContextualizedCaveat.ValidateAll() if the designated +// constraints aren't met. +type ContextualizedCaveatMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ContextualizedCaveatMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m ContextualizedCaveatMultiError) AllErrors() []error { return m } + +// ContextualizedCaveatValidationError is the validation error returned by +// ContextualizedCaveat.Validate if the designated constraints aren't met. +type ContextualizedCaveatValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e ContextualizedCaveatValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e ContextualizedCaveatValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e ContextualizedCaveatValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e ContextualizedCaveatValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e ContextualizedCaveatValidationError) ErrorName() string { + return "ContextualizedCaveatValidationError" +} + +// Error satisfies the builtin error interface +func (e ContextualizedCaveatValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sContextualizedCaveat.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = ContextualizedCaveatValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = ContextualizedCaveatValidationError{} + +var _ContextualizedCaveat_CaveatName_Pattern = regexp.MustCompile("^(([a-zA-Z0-9_][a-zA-Z0-9/_|-]{0,127})|\\*)$") + +// Validate checks the field values on CaveatDefinition with the rules defined +// in the proto definition for this message. If any rules are violated, the +// first error encountered is returned, or nil if there are no violations. +func (m *CaveatDefinition) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on CaveatDefinition with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// CaveatDefinitionMultiError, or nil if none found. +func (m *CaveatDefinition) ValidateAll() error { + return m.validate(true) +} + +func (m *CaveatDefinition) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if len(m.GetName()) > 128 { + err := CaveatDefinitionValidationError{ + field: "Name", + reason: "value length must be at most 128 bytes", + } + if !all { + return err + } + errors = append(errors, err) + } + + if !_CaveatDefinition_Name_Pattern.MatchString(m.GetName()) { + err := CaveatDefinitionValidationError{ + field: "Name", + reason: "value does not match regex pattern \"^(([a-zA-Z0-9_][a-zA-Z0-9/_|-]{0,127})|\\\\*)$\"", + } + if !all { + return err + } + errors = append(errors, err) + } + + if l := len(m.GetSerializedExpression()); l < 0 || l > 4096 { + err := CaveatDefinitionValidationError{ + field: "SerializedExpression", + reason: "value length must be between 0 and 4096 bytes, inclusive", + } + if !all { + return err + } + errors = append(errors, err) + } + + if l := len(m.GetParameterTypes()); l < 1 || l > 20 { + err := CaveatDefinitionValidationError{ + field: "ParameterTypes", + reason: "value must contain between 1 and 20 pairs, inclusive", + } + if !all { + return err + } + errors = append(errors, err) + } + + { + sorted_keys := make([]string, len(m.GetParameterTypes())) + i := 0 + for key := range m.GetParameterTypes() { + sorted_keys[i] = key + i++ + } + sort.Slice(sorted_keys, func(i, j int) bool { return sorted_keys[i] < sorted_keys[j] }) + for _, key := range sorted_keys { + val := m.GetParameterTypes()[key] + _ = val + + // no validation rules for ParameterTypes[key] + + if all { + switch v := interface{}(val).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, CaveatDefinitionValidationError{ + field: fmt.Sprintf("ParameterTypes[%v]", key), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, CaveatDefinitionValidationError{ + field: fmt.Sprintf("ParameterTypes[%v]", key), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(val).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return CaveatDefinitionValidationError{ + field: fmt.Sprintf("ParameterTypes[%v]", key), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + } + + if all { + switch v := interface{}(m.GetMetadata()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, CaveatDefinitionValidationError{ + field: "Metadata", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, CaveatDefinitionValidationError{ + field: "Metadata", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetMetadata()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return CaveatDefinitionValidationError{ + field: "Metadata", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if all { + switch v := interface{}(m.GetSourcePosition()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, CaveatDefinitionValidationError{ + field: "SourcePosition", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, CaveatDefinitionValidationError{ + field: "SourcePosition", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetSourcePosition()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return CaveatDefinitionValidationError{ + field: "SourcePosition", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return CaveatDefinitionMultiError(errors) + } + + return nil +} + +// CaveatDefinitionMultiError is an error wrapping multiple validation errors +// returned by CaveatDefinition.ValidateAll() if the designated constraints +// aren't met. +type CaveatDefinitionMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m CaveatDefinitionMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m CaveatDefinitionMultiError) AllErrors() []error { return m } + +// CaveatDefinitionValidationError is the validation error returned by +// CaveatDefinition.Validate if the designated constraints aren't met. +type CaveatDefinitionValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e CaveatDefinitionValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e CaveatDefinitionValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e CaveatDefinitionValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e CaveatDefinitionValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e CaveatDefinitionValidationError) ErrorName() string { return "CaveatDefinitionValidationError" } + +// Error satisfies the builtin error interface +func (e CaveatDefinitionValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sCaveatDefinition.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = CaveatDefinitionValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = CaveatDefinitionValidationError{} + +var _CaveatDefinition_Name_Pattern = regexp.MustCompile("^(([a-zA-Z0-9_][a-zA-Z0-9/_|-]{0,127})|\\*)$") + +// Validate checks the field values on CaveatTypeReference with the rules +// defined in the proto definition for this message. If any rules are +// violated, the first error encountered is returned, or nil if there are no violations. +func (m *CaveatTypeReference) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on CaveatTypeReference with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// CaveatTypeReferenceMultiError, or nil if none found. +func (m *CaveatTypeReference) ValidateAll() error { + return m.validate(true) +} + +func (m *CaveatTypeReference) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for TypeName + + if len(m.GetChildTypes()) > 1 { + err := CaveatTypeReferenceValidationError{ + field: "ChildTypes", + reason: "value must contain no more than 1 item(s)", + } + if !all { + return err + } + errors = append(errors, err) + } + + for idx, item := range m.GetChildTypes() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, CaveatTypeReferenceValidationError{ + field: fmt.Sprintf("ChildTypes[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, CaveatTypeReferenceValidationError{ + field: fmt.Sprintf("ChildTypes[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return CaveatTypeReferenceValidationError{ + field: fmt.Sprintf("ChildTypes[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + if len(errors) > 0 { + return CaveatTypeReferenceMultiError(errors) + } + + return nil +} + +// CaveatTypeReferenceMultiError is an error wrapping multiple validation +// errors returned by CaveatTypeReference.ValidateAll() if the designated +// constraints aren't met. +type CaveatTypeReferenceMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m CaveatTypeReferenceMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m CaveatTypeReferenceMultiError) AllErrors() []error { return m } + +// CaveatTypeReferenceValidationError is the validation error returned by +// CaveatTypeReference.Validate if the designated constraints aren't met. +type CaveatTypeReferenceValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e CaveatTypeReferenceValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e CaveatTypeReferenceValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e CaveatTypeReferenceValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e CaveatTypeReferenceValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e CaveatTypeReferenceValidationError) ErrorName() string { + return "CaveatTypeReferenceValidationError" +} + +// Error satisfies the builtin error interface +func (e CaveatTypeReferenceValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sCaveatTypeReference.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = CaveatTypeReferenceValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = CaveatTypeReferenceValidationError{} + +// Validate checks the field values on ObjectAndRelation with the rules defined +// in the proto definition for this message. If any rules are violated, the +// first error encountered is returned, or nil if there are no violations. +func (m *ObjectAndRelation) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on ObjectAndRelation with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// ObjectAndRelationMultiError, or nil if none found. +func (m *ObjectAndRelation) ValidateAll() error { + return m.validate(true) +} + +func (m *ObjectAndRelation) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if len(m.GetNamespace()) > 128 { + err := ObjectAndRelationValidationError{ + field: "Namespace", + reason: "value length must be at most 128 bytes", + } + if !all { + return err + } + errors = append(errors, err) + } + + if !_ObjectAndRelation_Namespace_Pattern.MatchString(m.GetNamespace()) { + err := ObjectAndRelationValidationError{ + field: "Namespace", + reason: "value does not match regex pattern \"^([a-z][a-z0-9_]{1,61}[a-z0-9]/)*[a-z][a-z0-9_]{1,62}[a-z0-9]$\"", + } + if !all { + return err + } + errors = append(errors, err) + } + + if len(m.GetObjectId()) > 1024 { + err := ObjectAndRelationValidationError{ + field: "ObjectId", + reason: "value length must be at most 1024 bytes", + } + if !all { + return err + } + errors = append(errors, err) + } + + if !_ObjectAndRelation_ObjectId_Pattern.MatchString(m.GetObjectId()) { + err := ObjectAndRelationValidationError{ + field: "ObjectId", + reason: "value does not match regex pattern \"^(([a-zA-Z0-9/_|\\\\-=+]{1,})|\\\\*)$\"", + } + if !all { + return err + } + errors = append(errors, err) + } + + if len(m.GetRelation()) > 64 { + err := ObjectAndRelationValidationError{ + field: "Relation", + reason: "value length must be at most 64 bytes", + } + if !all { + return err + } + errors = append(errors, err) + } + + if !_ObjectAndRelation_Relation_Pattern.MatchString(m.GetRelation()) { + err := ObjectAndRelationValidationError{ + field: "Relation", + reason: "value does not match regex pattern \"^(\\\\.\\\\.\\\\.|[a-z][a-z0-9_]{1,62}[a-z0-9])$\"", + } + if !all { + return err + } + errors = append(errors, err) + } + + if len(errors) > 0 { + return ObjectAndRelationMultiError(errors) + } + + return nil +} + +// ObjectAndRelationMultiError is an error wrapping multiple validation errors +// returned by ObjectAndRelation.ValidateAll() if the designated constraints +// aren't met. +type ObjectAndRelationMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ObjectAndRelationMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m ObjectAndRelationMultiError) AllErrors() []error { return m } + +// ObjectAndRelationValidationError is the validation error returned by +// ObjectAndRelation.Validate if the designated constraints aren't met. +type ObjectAndRelationValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e ObjectAndRelationValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e ObjectAndRelationValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e ObjectAndRelationValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e ObjectAndRelationValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e ObjectAndRelationValidationError) ErrorName() string { + return "ObjectAndRelationValidationError" +} + +// Error satisfies the builtin error interface +func (e ObjectAndRelationValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sObjectAndRelation.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = ObjectAndRelationValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = ObjectAndRelationValidationError{} + +var _ObjectAndRelation_Namespace_Pattern = regexp.MustCompile("^([a-z][a-z0-9_]{1,61}[a-z0-9]/)*[a-z][a-z0-9_]{1,62}[a-z0-9]$") + +var _ObjectAndRelation_ObjectId_Pattern = regexp.MustCompile("^(([a-zA-Z0-9/_|\\-=+]{1,})|\\*)$") + +var _ObjectAndRelation_Relation_Pattern = regexp.MustCompile("^(\\.\\.\\.|[a-z][a-z0-9_]{1,62}[a-z0-9])$") + +// Validate checks the field values on RelationReference with the rules defined +// in the proto definition for this message. If any rules are violated, the +// first error encountered is returned, or nil if there are no violations. +func (m *RelationReference) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on RelationReference with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// RelationReferenceMultiError, or nil if none found. +func (m *RelationReference) ValidateAll() error { + return m.validate(true) +} + +func (m *RelationReference) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if len(m.GetNamespace()) > 128 { + err := RelationReferenceValidationError{ + field: "Namespace", + reason: "value length must be at most 128 bytes", + } + if !all { + return err + } + errors = append(errors, err) + } + + if !_RelationReference_Namespace_Pattern.MatchString(m.GetNamespace()) { + err := RelationReferenceValidationError{ + field: "Namespace", + reason: "value does not match regex pattern \"^([a-z][a-z0-9_]{1,61}[a-z0-9]/)*[a-z][a-z0-9_]{1,62}[a-z0-9]$\"", + } + if !all { + return err + } + errors = append(errors, err) + } + + if len(m.GetRelation()) > 64 { + err := RelationReferenceValidationError{ + field: "Relation", + reason: "value length must be at most 64 bytes", + } + if !all { + return err + } + errors = append(errors, err) + } + + if !_RelationReference_Relation_Pattern.MatchString(m.GetRelation()) { + err := RelationReferenceValidationError{ + field: "Relation", + reason: "value does not match regex pattern \"^(\\\\.\\\\.\\\\.|[a-z][a-z0-9_]{1,62}[a-z0-9])$\"", + } + if !all { + return err + } + errors = append(errors, err) + } + + if len(errors) > 0 { + return RelationReferenceMultiError(errors) + } + + return nil +} + +// RelationReferenceMultiError is an error wrapping multiple validation errors +// returned by RelationReference.ValidateAll() if the designated constraints +// aren't met. +type RelationReferenceMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m RelationReferenceMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m RelationReferenceMultiError) AllErrors() []error { return m } + +// RelationReferenceValidationError is the validation error returned by +// RelationReference.Validate if the designated constraints aren't met. +type RelationReferenceValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e RelationReferenceValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e RelationReferenceValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e RelationReferenceValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e RelationReferenceValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e RelationReferenceValidationError) ErrorName() string { + return "RelationReferenceValidationError" +} + +// Error satisfies the builtin error interface +func (e RelationReferenceValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sRelationReference.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = RelationReferenceValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = RelationReferenceValidationError{} + +var _RelationReference_Namespace_Pattern = regexp.MustCompile("^([a-z][a-z0-9_]{1,61}[a-z0-9]/)*[a-z][a-z0-9_]{1,62}[a-z0-9]$") + +var _RelationReference_Relation_Pattern = regexp.MustCompile("^(\\.\\.\\.|[a-z][a-z0-9_]{1,62}[a-z0-9])$") + +// Validate checks the field values on Zookie with the rules defined in the +// proto definition for this message. If any rules are violated, the first +// error encountered is returned, or nil if there are no violations. +func (m *Zookie) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on Zookie with the rules defined in the +// proto definition for this message. If any rules are violated, the result is +// a list of violation errors wrapped in ZookieMultiError, or nil if none found. +func (m *Zookie) ValidateAll() error { + return m.validate(true) +} + +func (m *Zookie) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if len(m.GetToken()) < 1 { + err := ZookieValidationError{ + field: "Token", + reason: "value length must be at least 1 bytes", + } + if !all { + return err + } + errors = append(errors, err) + } + + if len(errors) > 0 { + return ZookieMultiError(errors) + } + + return nil +} + +// ZookieMultiError is an error wrapping multiple validation errors returned by +// Zookie.ValidateAll() if the designated constraints aren't met. +type ZookieMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ZookieMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m ZookieMultiError) AllErrors() []error { return m } + +// ZookieValidationError is the validation error returned by Zookie.Validate if +// the designated constraints aren't met. +type ZookieValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e ZookieValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e ZookieValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e ZookieValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e ZookieValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e ZookieValidationError) ErrorName() string { return "ZookieValidationError" } + +// Error satisfies the builtin error interface +func (e ZookieValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sZookie.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = ZookieValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = ZookieValidationError{} + +// Validate checks the field values on RelationTupleUpdate with the rules +// defined in the proto definition for this message. If any rules are +// violated, the first error encountered is returned, or nil if there are no violations. +func (m *RelationTupleUpdate) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on RelationTupleUpdate with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// RelationTupleUpdateMultiError, or nil if none found. +func (m *RelationTupleUpdate) ValidateAll() error { + return m.validate(true) +} + +func (m *RelationTupleUpdate) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if _, ok := RelationTupleUpdate_Operation_name[int32(m.GetOperation())]; !ok { + err := RelationTupleUpdateValidationError{ + field: "Operation", + reason: "value must be one of the defined enum values", + } + if !all { + return err + } + errors = append(errors, err) + } + + if m.GetTuple() == nil { + err := RelationTupleUpdateValidationError{ + field: "Tuple", + reason: "value is required", + } + if !all { + return err + } + errors = append(errors, err) + } + + if all { + switch v := interface{}(m.GetTuple()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, RelationTupleUpdateValidationError{ + field: "Tuple", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, RelationTupleUpdateValidationError{ + field: "Tuple", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetTuple()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return RelationTupleUpdateValidationError{ + field: "Tuple", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return RelationTupleUpdateMultiError(errors) + } + + return nil +} + +// RelationTupleUpdateMultiError is an error wrapping multiple validation +// errors returned by RelationTupleUpdate.ValidateAll() if the designated +// constraints aren't met. +type RelationTupleUpdateMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m RelationTupleUpdateMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m RelationTupleUpdateMultiError) AllErrors() []error { return m } + +// RelationTupleUpdateValidationError is the validation error returned by +// RelationTupleUpdate.Validate if the designated constraints aren't met. +type RelationTupleUpdateValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e RelationTupleUpdateValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e RelationTupleUpdateValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e RelationTupleUpdateValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e RelationTupleUpdateValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e RelationTupleUpdateValidationError) ErrorName() string { + return "RelationTupleUpdateValidationError" +} + +// Error satisfies the builtin error interface +func (e RelationTupleUpdateValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sRelationTupleUpdate.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = RelationTupleUpdateValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = RelationTupleUpdateValidationError{} + +// Validate checks the field values on RelationTupleTreeNode with the rules +// defined in the proto definition for this message. If any rules are +// violated, the first error encountered is returned, or nil if there are no violations. +func (m *RelationTupleTreeNode) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on RelationTupleTreeNode with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// RelationTupleTreeNodeMultiError, or nil if none found. +func (m *RelationTupleTreeNode) ValidateAll() error { + return m.validate(true) +} + +func (m *RelationTupleTreeNode) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetExpanded()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, RelationTupleTreeNodeValidationError{ + field: "Expanded", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, RelationTupleTreeNodeValidationError{ + field: "Expanded", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetExpanded()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return RelationTupleTreeNodeValidationError{ + field: "Expanded", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if all { + switch v := interface{}(m.GetCaveatExpression()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, RelationTupleTreeNodeValidationError{ + field: "CaveatExpression", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, RelationTupleTreeNodeValidationError{ + field: "CaveatExpression", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetCaveatExpression()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return RelationTupleTreeNodeValidationError{ + field: "CaveatExpression", + reason: "embedded message failed validation", + cause: err, + } + } + } + + switch v := m.NodeType.(type) { + case *RelationTupleTreeNode_IntermediateNode: + if v == nil { + err := RelationTupleTreeNodeValidationError{ + field: "NodeType", + reason: "oneof value cannot be a typed-nil", + } + if !all { + return err + } + errors = append(errors, err) + } + + if all { + switch v := interface{}(m.GetIntermediateNode()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, RelationTupleTreeNodeValidationError{ + field: "IntermediateNode", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, RelationTupleTreeNodeValidationError{ + field: "IntermediateNode", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetIntermediateNode()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return RelationTupleTreeNodeValidationError{ + field: "IntermediateNode", + reason: "embedded message failed validation", + cause: err, + } + } + } + + case *RelationTupleTreeNode_LeafNode: + if v == nil { + err := RelationTupleTreeNodeValidationError{ + field: "NodeType", + reason: "oneof value cannot be a typed-nil", + } + if !all { + return err + } + errors = append(errors, err) + } + + if all { + switch v := interface{}(m.GetLeafNode()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, RelationTupleTreeNodeValidationError{ + field: "LeafNode", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, RelationTupleTreeNodeValidationError{ + field: "LeafNode", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetLeafNode()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return RelationTupleTreeNodeValidationError{ + field: "LeafNode", + reason: "embedded message failed validation", + cause: err, + } + } + } + + default: + _ = v // ensures v is used + } + + if len(errors) > 0 { + return RelationTupleTreeNodeMultiError(errors) + } + + return nil +} + +// RelationTupleTreeNodeMultiError is an error wrapping multiple validation +// errors returned by RelationTupleTreeNode.ValidateAll() if the designated +// constraints aren't met. +type RelationTupleTreeNodeMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m RelationTupleTreeNodeMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m RelationTupleTreeNodeMultiError) AllErrors() []error { return m } + +// RelationTupleTreeNodeValidationError is the validation error returned by +// RelationTupleTreeNode.Validate if the designated constraints aren't met. +type RelationTupleTreeNodeValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e RelationTupleTreeNodeValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e RelationTupleTreeNodeValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e RelationTupleTreeNodeValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e RelationTupleTreeNodeValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e RelationTupleTreeNodeValidationError) ErrorName() string { + return "RelationTupleTreeNodeValidationError" +} + +// Error satisfies the builtin error interface +func (e RelationTupleTreeNodeValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sRelationTupleTreeNode.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = RelationTupleTreeNodeValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = RelationTupleTreeNodeValidationError{} + +// Validate checks the field values on SetOperationUserset with the rules +// defined in the proto definition for this message. If any rules are +// violated, the first error encountered is returned, or nil if there are no violations. +func (m *SetOperationUserset) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on SetOperationUserset with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// SetOperationUsersetMultiError, or nil if none found. +func (m *SetOperationUserset) ValidateAll() error { + return m.validate(true) +} + +func (m *SetOperationUserset) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Operation + + for idx, item := range m.GetChildNodes() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, SetOperationUsersetValidationError{ + field: fmt.Sprintf("ChildNodes[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, SetOperationUsersetValidationError{ + field: fmt.Sprintf("ChildNodes[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return SetOperationUsersetValidationError{ + field: fmt.Sprintf("ChildNodes[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + if len(errors) > 0 { + return SetOperationUsersetMultiError(errors) + } + + return nil +} + +// SetOperationUsersetMultiError is an error wrapping multiple validation +// errors returned by SetOperationUserset.ValidateAll() if the designated +// constraints aren't met. +type SetOperationUsersetMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m SetOperationUsersetMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m SetOperationUsersetMultiError) AllErrors() []error { return m } + +// SetOperationUsersetValidationError is the validation error returned by +// SetOperationUserset.Validate if the designated constraints aren't met. +type SetOperationUsersetValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e SetOperationUsersetValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e SetOperationUsersetValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e SetOperationUsersetValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e SetOperationUsersetValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e SetOperationUsersetValidationError) ErrorName() string { + return "SetOperationUsersetValidationError" +} + +// Error satisfies the builtin error interface +func (e SetOperationUsersetValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sSetOperationUserset.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = SetOperationUsersetValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = SetOperationUsersetValidationError{} + +// Validate checks the field values on DirectSubject with the rules defined in +// the proto definition for this message. If any rules are violated, the first +// error encountered is returned, or nil if there are no violations. +func (m *DirectSubject) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on DirectSubject with the rules defined +// in the proto definition for this message. If any rules are violated, the +// result is a list of violation errors wrapped in DirectSubjectMultiError, or +// nil if none found. +func (m *DirectSubject) ValidateAll() error { + return m.validate(true) +} + +func (m *DirectSubject) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetSubject()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, DirectSubjectValidationError{ + field: "Subject", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, DirectSubjectValidationError{ + field: "Subject", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetSubject()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return DirectSubjectValidationError{ + field: "Subject", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if all { + switch v := interface{}(m.GetCaveatExpression()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, DirectSubjectValidationError{ + field: "CaveatExpression", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, DirectSubjectValidationError{ + field: "CaveatExpression", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetCaveatExpression()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return DirectSubjectValidationError{ + field: "CaveatExpression", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return DirectSubjectMultiError(errors) + } + + return nil +} + +// DirectSubjectMultiError is an error wrapping multiple validation errors +// returned by DirectSubject.ValidateAll() if the designated constraints +// aren't met. +type DirectSubjectMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m DirectSubjectMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m DirectSubjectMultiError) AllErrors() []error { return m } + +// DirectSubjectValidationError is the validation error returned by +// DirectSubject.Validate if the designated constraints aren't met. +type DirectSubjectValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e DirectSubjectValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e DirectSubjectValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e DirectSubjectValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e DirectSubjectValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e DirectSubjectValidationError) ErrorName() string { return "DirectSubjectValidationError" } + +// Error satisfies the builtin error interface +func (e DirectSubjectValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sDirectSubject.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = DirectSubjectValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = DirectSubjectValidationError{} + +// Validate checks the field values on DirectSubjects with the rules defined in +// the proto definition for this message. If any rules are violated, the first +// error encountered is returned, or nil if there are no violations. +func (m *DirectSubjects) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on DirectSubjects with the rules defined +// in the proto definition for this message. If any rules are violated, the +// result is a list of violation errors wrapped in DirectSubjectsMultiError, +// or nil if none found. +func (m *DirectSubjects) ValidateAll() error { + return m.validate(true) +} + +func (m *DirectSubjects) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + for idx, item := range m.GetSubjects() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, DirectSubjectsValidationError{ + field: fmt.Sprintf("Subjects[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, DirectSubjectsValidationError{ + field: fmt.Sprintf("Subjects[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return DirectSubjectsValidationError{ + field: fmt.Sprintf("Subjects[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + if len(errors) > 0 { + return DirectSubjectsMultiError(errors) + } + + return nil +} + +// DirectSubjectsMultiError is an error wrapping multiple validation errors +// returned by DirectSubjects.ValidateAll() if the designated constraints +// aren't met. +type DirectSubjectsMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m DirectSubjectsMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m DirectSubjectsMultiError) AllErrors() []error { return m } + +// DirectSubjectsValidationError is the validation error returned by +// DirectSubjects.Validate if the designated constraints aren't met. +type DirectSubjectsValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e DirectSubjectsValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e DirectSubjectsValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e DirectSubjectsValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e DirectSubjectsValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e DirectSubjectsValidationError) ErrorName() string { return "DirectSubjectsValidationError" } + +// Error satisfies the builtin error interface +func (e DirectSubjectsValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sDirectSubjects.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = DirectSubjectsValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = DirectSubjectsValidationError{} + +// Validate checks the field values on Metadata with the rules defined in the +// proto definition for this message. If any rules are violated, the first +// error encountered is returned, or nil if there are no violations. +func (m *Metadata) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on Metadata with the rules defined in +// the proto definition for this message. If any rules are violated, the +// result is a list of violation errors wrapped in MetadataMultiError, or nil +// if none found. +func (m *Metadata) ValidateAll() error { + return m.validate(true) +} + +func (m *Metadata) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if len(m.GetMetadataMessage()) < 1 { + err := MetadataValidationError{ + field: "MetadataMessage", + reason: "value must contain at least 1 item(s)", + } + if !all { + return err + } + errors = append(errors, err) + } + + for idx, item := range m.GetMetadataMessage() { + _, _ = idx, item + + if item == nil { + err := MetadataValidationError{ + field: fmt.Sprintf("MetadataMessage[%v]", idx), + reason: "value is required", + } + if !all { + return err + } + errors = append(errors, err) + } + + if a := item; a != nil { + + if _, ok := _Metadata_MetadataMessage_InLookup[a.GetTypeUrl()]; !ok { + err := MetadataValidationError{ + field: fmt.Sprintf("MetadataMessage[%v]", idx), + reason: "type URL must be in list [type.googleapis.com/impl.v1.DocComment type.googleapis.com/impl.v1.RelationMetadata]", + } + if !all { + return err + } + errors = append(errors, err) + } + + } + + } + + if len(errors) > 0 { + return MetadataMultiError(errors) + } + + return nil +} + +// MetadataMultiError is an error wrapping multiple validation errors returned +// by Metadata.ValidateAll() if the designated constraints aren't met. +type MetadataMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m MetadataMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m MetadataMultiError) AllErrors() []error { return m } + +// MetadataValidationError is the validation error returned by +// Metadata.Validate if the designated constraints aren't met. +type MetadataValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e MetadataValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e MetadataValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e MetadataValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e MetadataValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e MetadataValidationError) ErrorName() string { return "MetadataValidationError" } + +// Error satisfies the builtin error interface +func (e MetadataValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sMetadata.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = MetadataValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = MetadataValidationError{} + +var _Metadata_MetadataMessage_InLookup = map[string]struct{}{ + "type.googleapis.com/impl.v1.DocComment": {}, + "type.googleapis.com/impl.v1.RelationMetadata": {}, +} + +// Validate checks the field values on NamespaceDefinition with the rules +// defined in the proto definition for this message. If any rules are +// violated, the first error encountered is returned, or nil if there are no violations. +func (m *NamespaceDefinition) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on NamespaceDefinition with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// NamespaceDefinitionMultiError, or nil if none found. +func (m *NamespaceDefinition) ValidateAll() error { + return m.validate(true) +} + +func (m *NamespaceDefinition) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if len(m.GetName()) > 128 { + err := NamespaceDefinitionValidationError{ + field: "Name", + reason: "value length must be at most 128 bytes", + } + if !all { + return err + } + errors = append(errors, err) + } + + if !_NamespaceDefinition_Name_Pattern.MatchString(m.GetName()) { + err := NamespaceDefinitionValidationError{ + field: "Name", + reason: "value does not match regex pattern \"^([a-z][a-z0-9_]{1,62}[a-z0-9]/)*[a-z][a-z0-9_]{1,62}[a-z0-9]$\"", + } + if !all { + return err + } + errors = append(errors, err) + } + + for idx, item := range m.GetRelation() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, NamespaceDefinitionValidationError{ + field: fmt.Sprintf("Relation[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, NamespaceDefinitionValidationError{ + field: fmt.Sprintf("Relation[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return NamespaceDefinitionValidationError{ + field: fmt.Sprintf("Relation[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + if all { + switch v := interface{}(m.GetMetadata()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, NamespaceDefinitionValidationError{ + field: "Metadata", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, NamespaceDefinitionValidationError{ + field: "Metadata", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetMetadata()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return NamespaceDefinitionValidationError{ + field: "Metadata", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if all { + switch v := interface{}(m.GetSourcePosition()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, NamespaceDefinitionValidationError{ + field: "SourcePosition", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, NamespaceDefinitionValidationError{ + field: "SourcePosition", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetSourcePosition()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return NamespaceDefinitionValidationError{ + field: "SourcePosition", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return NamespaceDefinitionMultiError(errors) + } + + return nil +} + +// NamespaceDefinitionMultiError is an error wrapping multiple validation +// errors returned by NamespaceDefinition.ValidateAll() if the designated +// constraints aren't met. +type NamespaceDefinitionMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m NamespaceDefinitionMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m NamespaceDefinitionMultiError) AllErrors() []error { return m } + +// NamespaceDefinitionValidationError is the validation error returned by +// NamespaceDefinition.Validate if the designated constraints aren't met. +type NamespaceDefinitionValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e NamespaceDefinitionValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e NamespaceDefinitionValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e NamespaceDefinitionValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e NamespaceDefinitionValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e NamespaceDefinitionValidationError) ErrorName() string { + return "NamespaceDefinitionValidationError" +} + +// Error satisfies the builtin error interface +func (e NamespaceDefinitionValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sNamespaceDefinition.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = NamespaceDefinitionValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = NamespaceDefinitionValidationError{} + +var _NamespaceDefinition_Name_Pattern = regexp.MustCompile("^([a-z][a-z0-9_]{1,62}[a-z0-9]/)*[a-z][a-z0-9_]{1,62}[a-z0-9]$") + +// Validate checks the field values on Relation with the rules defined in the +// proto definition for this message. If any rules are violated, the first +// error encountered is returned, or nil if there are no violations. +func (m *Relation) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on Relation with the rules defined in +// the proto definition for this message. If any rules are violated, the +// result is a list of violation errors wrapped in RelationMultiError, or nil +// if none found. +func (m *Relation) ValidateAll() error { + return m.validate(true) +} + +func (m *Relation) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if len(m.GetName()) > 64 { + err := RelationValidationError{ + field: "Name", + reason: "value length must be at most 64 bytes", + } + if !all { + return err + } + errors = append(errors, err) + } + + if !_Relation_Name_Pattern.MatchString(m.GetName()) { + err := RelationValidationError{ + field: "Name", + reason: "value does not match regex pattern \"^[a-z][a-z0-9_]{1,62}[a-z0-9]$\"", + } + if !all { + return err + } + errors = append(errors, err) + } + + if all { + switch v := interface{}(m.GetUsersetRewrite()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, RelationValidationError{ + field: "UsersetRewrite", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, RelationValidationError{ + field: "UsersetRewrite", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetUsersetRewrite()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return RelationValidationError{ + field: "UsersetRewrite", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if all { + switch v := interface{}(m.GetTypeInformation()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, RelationValidationError{ + field: "TypeInformation", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, RelationValidationError{ + field: "TypeInformation", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetTypeInformation()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return RelationValidationError{ + field: "TypeInformation", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if all { + switch v := interface{}(m.GetMetadata()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, RelationValidationError{ + field: "Metadata", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, RelationValidationError{ + field: "Metadata", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetMetadata()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return RelationValidationError{ + field: "Metadata", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if all { + switch v := interface{}(m.GetSourcePosition()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, RelationValidationError{ + field: "SourcePosition", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, RelationValidationError{ + field: "SourcePosition", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetSourcePosition()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return RelationValidationError{ + field: "SourcePosition", + reason: "embedded message failed validation", + cause: err, + } + } + } + + // no validation rules for AliasingRelation + + // no validation rules for CanonicalCacheKey + + if len(errors) > 0 { + return RelationMultiError(errors) + } + + return nil +} + +// RelationMultiError is an error wrapping multiple validation errors returned +// by Relation.ValidateAll() if the designated constraints aren't met. +type RelationMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m RelationMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m RelationMultiError) AllErrors() []error { return m } + +// RelationValidationError is the validation error returned by +// Relation.Validate if the designated constraints aren't met. +type RelationValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e RelationValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e RelationValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e RelationValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e RelationValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e RelationValidationError) ErrorName() string { return "RelationValidationError" } + +// Error satisfies the builtin error interface +func (e RelationValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sRelation.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = RelationValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = RelationValidationError{} + +var _Relation_Name_Pattern = regexp.MustCompile("^[a-z][a-z0-9_]{1,62}[a-z0-9]$") + +// Validate checks the field values on ReachabilityGraph with the rules defined +// in the proto definition for this message. If any rules are violated, the +// first error encountered is returned, or nil if there are no violations. +func (m *ReachabilityGraph) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on ReachabilityGraph with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// ReachabilityGraphMultiError, or nil if none found. +func (m *ReachabilityGraph) ValidateAll() error { + return m.validate(true) +} + +func (m *ReachabilityGraph) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + { + sorted_keys := make([]string, len(m.GetEntrypointsBySubjectType())) + i := 0 + for key := range m.GetEntrypointsBySubjectType() { + sorted_keys[i] = key + i++ + } + sort.Slice(sorted_keys, func(i, j int) bool { return sorted_keys[i] < sorted_keys[j] }) + for _, key := range sorted_keys { + val := m.GetEntrypointsBySubjectType()[key] + _ = val + + // no validation rules for EntrypointsBySubjectType[key] + + if all { + switch v := interface{}(val).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, ReachabilityGraphValidationError{ + field: fmt.Sprintf("EntrypointsBySubjectType[%v]", key), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, ReachabilityGraphValidationError{ + field: fmt.Sprintf("EntrypointsBySubjectType[%v]", key), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(val).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return ReachabilityGraphValidationError{ + field: fmt.Sprintf("EntrypointsBySubjectType[%v]", key), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + } + + { + sorted_keys := make([]string, len(m.GetEntrypointsBySubjectRelation())) + i := 0 + for key := range m.GetEntrypointsBySubjectRelation() { + sorted_keys[i] = key + i++ + } + sort.Slice(sorted_keys, func(i, j int) bool { return sorted_keys[i] < sorted_keys[j] }) + for _, key := range sorted_keys { + val := m.GetEntrypointsBySubjectRelation()[key] + _ = val + + // no validation rules for EntrypointsBySubjectRelation[key] + + if all { + switch v := interface{}(val).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, ReachabilityGraphValidationError{ + field: fmt.Sprintf("EntrypointsBySubjectRelation[%v]", key), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, ReachabilityGraphValidationError{ + field: fmt.Sprintf("EntrypointsBySubjectRelation[%v]", key), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(val).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return ReachabilityGraphValidationError{ + field: fmt.Sprintf("EntrypointsBySubjectRelation[%v]", key), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + } + + if len(errors) > 0 { + return ReachabilityGraphMultiError(errors) + } + + return nil +} + +// ReachabilityGraphMultiError is an error wrapping multiple validation errors +// returned by ReachabilityGraph.ValidateAll() if the designated constraints +// aren't met. +type ReachabilityGraphMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ReachabilityGraphMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m ReachabilityGraphMultiError) AllErrors() []error { return m } + +// ReachabilityGraphValidationError is the validation error returned by +// ReachabilityGraph.Validate if the designated constraints aren't met. +type ReachabilityGraphValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e ReachabilityGraphValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e ReachabilityGraphValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e ReachabilityGraphValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e ReachabilityGraphValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e ReachabilityGraphValidationError) ErrorName() string { + return "ReachabilityGraphValidationError" +} + +// Error satisfies the builtin error interface +func (e ReachabilityGraphValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sReachabilityGraph.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = ReachabilityGraphValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = ReachabilityGraphValidationError{} + +// Validate checks the field values on ReachabilityEntrypoints with the rules +// defined in the proto definition for this message. If any rules are +// violated, the first error encountered is returned, or nil if there are no violations. +func (m *ReachabilityEntrypoints) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on ReachabilityEntrypoints with the +// rules defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// ReachabilityEntrypointsMultiError, or nil if none found. +func (m *ReachabilityEntrypoints) ValidateAll() error { + return m.validate(true) +} + +func (m *ReachabilityEntrypoints) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + for idx, item := range m.GetEntrypoints() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, ReachabilityEntrypointsValidationError{ + field: fmt.Sprintf("Entrypoints[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, ReachabilityEntrypointsValidationError{ + field: fmt.Sprintf("Entrypoints[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return ReachabilityEntrypointsValidationError{ + field: fmt.Sprintf("Entrypoints[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + // no validation rules for SubjectType + + if all { + switch v := interface{}(m.GetSubjectRelation()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, ReachabilityEntrypointsValidationError{ + field: "SubjectRelation", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, ReachabilityEntrypointsValidationError{ + field: "SubjectRelation", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetSubjectRelation()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return ReachabilityEntrypointsValidationError{ + field: "SubjectRelation", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return ReachabilityEntrypointsMultiError(errors) + } + + return nil +} + +// ReachabilityEntrypointsMultiError is an error wrapping multiple validation +// errors returned by ReachabilityEntrypoints.ValidateAll() if the designated +// constraints aren't met. +type ReachabilityEntrypointsMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ReachabilityEntrypointsMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m ReachabilityEntrypointsMultiError) AllErrors() []error { return m } + +// ReachabilityEntrypointsValidationError is the validation error returned by +// ReachabilityEntrypoints.Validate if the designated constraints aren't met. +type ReachabilityEntrypointsValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e ReachabilityEntrypointsValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e ReachabilityEntrypointsValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e ReachabilityEntrypointsValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e ReachabilityEntrypointsValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e ReachabilityEntrypointsValidationError) ErrorName() string { + return "ReachabilityEntrypointsValidationError" +} + +// Error satisfies the builtin error interface +func (e ReachabilityEntrypointsValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sReachabilityEntrypoints.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = ReachabilityEntrypointsValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = ReachabilityEntrypointsValidationError{} + +// Validate checks the field values on ReachabilityEntrypoint with the rules +// defined in the proto definition for this message. If any rules are +// violated, the first error encountered is returned, or nil if there are no violations. +func (m *ReachabilityEntrypoint) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on ReachabilityEntrypoint with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// ReachabilityEntrypointMultiError, or nil if none found. +func (m *ReachabilityEntrypoint) ValidateAll() error { + return m.validate(true) +} + +func (m *ReachabilityEntrypoint) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Kind + + if all { + switch v := interface{}(m.GetTargetRelation()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, ReachabilityEntrypointValidationError{ + field: "TargetRelation", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, ReachabilityEntrypointValidationError{ + field: "TargetRelation", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetTargetRelation()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return ReachabilityEntrypointValidationError{ + field: "TargetRelation", + reason: "embedded message failed validation", + cause: err, + } + } + } + + // no validation rules for ResultStatus + + // no validation rules for TuplesetRelation + + // no validation rules for ComputedUsersetRelation + + if len(errors) > 0 { + return ReachabilityEntrypointMultiError(errors) + } + + return nil +} + +// ReachabilityEntrypointMultiError is an error wrapping multiple validation +// errors returned by ReachabilityEntrypoint.ValidateAll() if the designated +// constraints aren't met. +type ReachabilityEntrypointMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ReachabilityEntrypointMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m ReachabilityEntrypointMultiError) AllErrors() []error { return m } + +// ReachabilityEntrypointValidationError is the validation error returned by +// ReachabilityEntrypoint.Validate if the designated constraints aren't met. +type ReachabilityEntrypointValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e ReachabilityEntrypointValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e ReachabilityEntrypointValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e ReachabilityEntrypointValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e ReachabilityEntrypointValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e ReachabilityEntrypointValidationError) ErrorName() string { + return "ReachabilityEntrypointValidationError" +} + +// Error satisfies the builtin error interface +func (e ReachabilityEntrypointValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sReachabilityEntrypoint.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = ReachabilityEntrypointValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = ReachabilityEntrypointValidationError{} + +// Validate checks the field values on TypeInformation with the rules defined +// in the proto definition for this message. If any rules are violated, the +// first error encountered is returned, or nil if there are no violations. +func (m *TypeInformation) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on TypeInformation with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// TypeInformationMultiError, or nil if none found. +func (m *TypeInformation) ValidateAll() error { + return m.validate(true) +} + +func (m *TypeInformation) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + for idx, item := range m.GetAllowedDirectRelations() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, TypeInformationValidationError{ + field: fmt.Sprintf("AllowedDirectRelations[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, TypeInformationValidationError{ + field: fmt.Sprintf("AllowedDirectRelations[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return TypeInformationValidationError{ + field: fmt.Sprintf("AllowedDirectRelations[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + if len(errors) > 0 { + return TypeInformationMultiError(errors) + } + + return nil +} + +// TypeInformationMultiError is an error wrapping multiple validation errors +// returned by TypeInformation.ValidateAll() if the designated constraints +// aren't met. +type TypeInformationMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m TypeInformationMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m TypeInformationMultiError) AllErrors() []error { return m } + +// TypeInformationValidationError is the validation error returned by +// TypeInformation.Validate if the designated constraints aren't met. +type TypeInformationValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e TypeInformationValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e TypeInformationValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e TypeInformationValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e TypeInformationValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e TypeInformationValidationError) ErrorName() string { return "TypeInformationValidationError" } + +// Error satisfies the builtin error interface +func (e TypeInformationValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sTypeInformation.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = TypeInformationValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = TypeInformationValidationError{} + +// Validate checks the field values on AllowedRelation with the rules defined +// in the proto definition for this message. If any rules are violated, the +// first error encountered is returned, or nil if there are no violations. +func (m *AllowedRelation) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on AllowedRelation with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// AllowedRelationMultiError, or nil if none found. +func (m *AllowedRelation) ValidateAll() error { + return m.validate(true) +} + +func (m *AllowedRelation) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if len(m.GetNamespace()) > 128 { + err := AllowedRelationValidationError{ + field: "Namespace", + reason: "value length must be at most 128 bytes", + } + if !all { + return err + } + errors = append(errors, err) + } + + if !_AllowedRelation_Namespace_Pattern.MatchString(m.GetNamespace()) { + err := AllowedRelationValidationError{ + field: "Namespace", + reason: "value does not match regex pattern \"^([a-z][a-z0-9_]{1,61}[a-z0-9]/)*[a-z][a-z0-9_]{1,62}[a-z0-9]$\"", + } + if !all { + return err + } + errors = append(errors, err) + } + + if all { + switch v := interface{}(m.GetSourcePosition()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, AllowedRelationValidationError{ + field: "SourcePosition", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, AllowedRelationValidationError{ + field: "SourcePosition", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetSourcePosition()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return AllowedRelationValidationError{ + field: "SourcePosition", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if all { + switch v := interface{}(m.GetRequiredCaveat()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, AllowedRelationValidationError{ + field: "RequiredCaveat", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, AllowedRelationValidationError{ + field: "RequiredCaveat", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetRequiredCaveat()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return AllowedRelationValidationError{ + field: "RequiredCaveat", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if all { + switch v := interface{}(m.GetRequiredExpiration()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, AllowedRelationValidationError{ + field: "RequiredExpiration", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, AllowedRelationValidationError{ + field: "RequiredExpiration", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetRequiredExpiration()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return AllowedRelationValidationError{ + field: "RequiredExpiration", + reason: "embedded message failed validation", + cause: err, + } + } + } + + switch v := m.RelationOrWildcard.(type) { + case *AllowedRelation_Relation: + if v == nil { + err := AllowedRelationValidationError{ + field: "RelationOrWildcard", + reason: "oneof value cannot be a typed-nil", + } + if !all { + return err + } + errors = append(errors, err) + } + + if len(m.GetRelation()) > 64 { + err := AllowedRelationValidationError{ + field: "Relation", + reason: "value length must be at most 64 bytes", + } + if !all { + return err + } + errors = append(errors, err) + } + + if !_AllowedRelation_Relation_Pattern.MatchString(m.GetRelation()) { + err := AllowedRelationValidationError{ + field: "Relation", + reason: "value does not match regex pattern \"^(\\\\.\\\\.\\\\.|[a-z][a-z0-9_]{1,62}[a-z0-9])$\"", + } + if !all { + return err + } + errors = append(errors, err) + } + + case *AllowedRelation_PublicWildcard_: + if v == nil { + err := AllowedRelationValidationError{ + field: "RelationOrWildcard", + reason: "oneof value cannot be a typed-nil", + } + if !all { + return err + } + errors = append(errors, err) + } + + if all { + switch v := interface{}(m.GetPublicWildcard()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, AllowedRelationValidationError{ + field: "PublicWildcard", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, AllowedRelationValidationError{ + field: "PublicWildcard", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetPublicWildcard()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return AllowedRelationValidationError{ + field: "PublicWildcard", + reason: "embedded message failed validation", + cause: err, + } + } + } + + default: + _ = v // ensures v is used + } + + if len(errors) > 0 { + return AllowedRelationMultiError(errors) + } + + return nil +} + +// AllowedRelationMultiError is an error wrapping multiple validation errors +// returned by AllowedRelation.ValidateAll() if the designated constraints +// aren't met. +type AllowedRelationMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m AllowedRelationMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m AllowedRelationMultiError) AllErrors() []error { return m } + +// AllowedRelationValidationError is the validation error returned by +// AllowedRelation.Validate if the designated constraints aren't met. +type AllowedRelationValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e AllowedRelationValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e AllowedRelationValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e AllowedRelationValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e AllowedRelationValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e AllowedRelationValidationError) ErrorName() string { return "AllowedRelationValidationError" } + +// Error satisfies the builtin error interface +func (e AllowedRelationValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sAllowedRelation.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = AllowedRelationValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = AllowedRelationValidationError{} + +var _AllowedRelation_Namespace_Pattern = regexp.MustCompile("^([a-z][a-z0-9_]{1,61}[a-z0-9]/)*[a-z][a-z0-9_]{1,62}[a-z0-9]$") + +var _AllowedRelation_Relation_Pattern = regexp.MustCompile("^(\\.\\.\\.|[a-z][a-z0-9_]{1,62}[a-z0-9])$") + +// Validate checks the field values on ExpirationTrait with the rules defined +// in the proto definition for this message. If any rules are violated, the +// first error encountered is returned, or nil if there are no violations. +func (m *ExpirationTrait) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on ExpirationTrait with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// ExpirationTraitMultiError, or nil if none found. +func (m *ExpirationTrait) ValidateAll() error { + return m.validate(true) +} + +func (m *ExpirationTrait) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if len(errors) > 0 { + return ExpirationTraitMultiError(errors) + } + + return nil +} + +// ExpirationTraitMultiError is an error wrapping multiple validation errors +// returned by ExpirationTrait.ValidateAll() if the designated constraints +// aren't met. +type ExpirationTraitMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ExpirationTraitMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m ExpirationTraitMultiError) AllErrors() []error { return m } + +// ExpirationTraitValidationError is the validation error returned by +// ExpirationTrait.Validate if the designated constraints aren't met. +type ExpirationTraitValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e ExpirationTraitValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e ExpirationTraitValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e ExpirationTraitValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e ExpirationTraitValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e ExpirationTraitValidationError) ErrorName() string { return "ExpirationTraitValidationError" } + +// Error satisfies the builtin error interface +func (e ExpirationTraitValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sExpirationTrait.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = ExpirationTraitValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = ExpirationTraitValidationError{} + +// Validate checks the field values on AllowedCaveat with the rules defined in +// the proto definition for this message. If any rules are violated, the first +// error encountered is returned, or nil if there are no violations. +func (m *AllowedCaveat) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on AllowedCaveat with the rules defined +// in the proto definition for this message. If any rules are violated, the +// result is a list of violation errors wrapped in AllowedCaveatMultiError, or +// nil if none found. +func (m *AllowedCaveat) ValidateAll() error { + return m.validate(true) +} + +func (m *AllowedCaveat) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for CaveatName + + if len(errors) > 0 { + return AllowedCaveatMultiError(errors) + } + + return nil +} + +// AllowedCaveatMultiError is an error wrapping multiple validation errors +// returned by AllowedCaveat.ValidateAll() if the designated constraints +// aren't met. +type AllowedCaveatMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m AllowedCaveatMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m AllowedCaveatMultiError) AllErrors() []error { return m } + +// AllowedCaveatValidationError is the validation error returned by +// AllowedCaveat.Validate if the designated constraints aren't met. +type AllowedCaveatValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e AllowedCaveatValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e AllowedCaveatValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e AllowedCaveatValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e AllowedCaveatValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e AllowedCaveatValidationError) ErrorName() string { return "AllowedCaveatValidationError" } + +// Error satisfies the builtin error interface +func (e AllowedCaveatValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sAllowedCaveat.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = AllowedCaveatValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = AllowedCaveatValidationError{} + +// Validate checks the field values on UsersetRewrite with the rules defined in +// the proto definition for this message. If any rules are violated, the first +// error encountered is returned, or nil if there are no violations. +func (m *UsersetRewrite) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on UsersetRewrite with the rules defined +// in the proto definition for this message. If any rules are violated, the +// result is a list of violation errors wrapped in UsersetRewriteMultiError, +// or nil if none found. +func (m *UsersetRewrite) ValidateAll() error { + return m.validate(true) +} + +func (m *UsersetRewrite) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetSourcePosition()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UsersetRewriteValidationError{ + field: "SourcePosition", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UsersetRewriteValidationError{ + field: "SourcePosition", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetSourcePosition()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return UsersetRewriteValidationError{ + field: "SourcePosition", + reason: "embedded message failed validation", + cause: err, + } + } + } + + oneofRewriteOperationPresent := false + switch v := m.RewriteOperation.(type) { + case *UsersetRewrite_Union: + if v == nil { + err := UsersetRewriteValidationError{ + field: "RewriteOperation", + reason: "oneof value cannot be a typed-nil", + } + if !all { + return err + } + errors = append(errors, err) + } + oneofRewriteOperationPresent = true + + if m.GetUnion() == nil { + err := UsersetRewriteValidationError{ + field: "Union", + reason: "value is required", + } + if !all { + return err + } + errors = append(errors, err) + } + + if all { + switch v := interface{}(m.GetUnion()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UsersetRewriteValidationError{ + field: "Union", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UsersetRewriteValidationError{ + field: "Union", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetUnion()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return UsersetRewriteValidationError{ + field: "Union", + reason: "embedded message failed validation", + cause: err, + } + } + } + + case *UsersetRewrite_Intersection: + if v == nil { + err := UsersetRewriteValidationError{ + field: "RewriteOperation", + reason: "oneof value cannot be a typed-nil", + } + if !all { + return err + } + errors = append(errors, err) + } + oneofRewriteOperationPresent = true + + if m.GetIntersection() == nil { + err := UsersetRewriteValidationError{ + field: "Intersection", + reason: "value is required", + } + if !all { + return err + } + errors = append(errors, err) + } + + if all { + switch v := interface{}(m.GetIntersection()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UsersetRewriteValidationError{ + field: "Intersection", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UsersetRewriteValidationError{ + field: "Intersection", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetIntersection()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return UsersetRewriteValidationError{ + field: "Intersection", + reason: "embedded message failed validation", + cause: err, + } + } + } + + case *UsersetRewrite_Exclusion: + if v == nil { + err := UsersetRewriteValidationError{ + field: "RewriteOperation", + reason: "oneof value cannot be a typed-nil", + } + if !all { + return err + } + errors = append(errors, err) + } + oneofRewriteOperationPresent = true + + if m.GetExclusion() == nil { + err := UsersetRewriteValidationError{ + field: "Exclusion", + reason: "value is required", + } + if !all { + return err + } + errors = append(errors, err) + } + + if all { + switch v := interface{}(m.GetExclusion()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UsersetRewriteValidationError{ + field: "Exclusion", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UsersetRewriteValidationError{ + field: "Exclusion", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetExclusion()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return UsersetRewriteValidationError{ + field: "Exclusion", + reason: "embedded message failed validation", + cause: err, + } + } + } + + default: + _ = v // ensures v is used + } + if !oneofRewriteOperationPresent { + err := UsersetRewriteValidationError{ + field: "RewriteOperation", + reason: "value is required", + } + if !all { + return err + } + errors = append(errors, err) + } + + if len(errors) > 0 { + return UsersetRewriteMultiError(errors) + } + + return nil +} + +// UsersetRewriteMultiError is an error wrapping multiple validation errors +// returned by UsersetRewrite.ValidateAll() if the designated constraints +// aren't met. +type UsersetRewriteMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m UsersetRewriteMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m UsersetRewriteMultiError) AllErrors() []error { return m } + +// UsersetRewriteValidationError is the validation error returned by +// UsersetRewrite.Validate if the designated constraints aren't met. +type UsersetRewriteValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e UsersetRewriteValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e UsersetRewriteValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e UsersetRewriteValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e UsersetRewriteValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e UsersetRewriteValidationError) ErrorName() string { return "UsersetRewriteValidationError" } + +// Error satisfies the builtin error interface +func (e UsersetRewriteValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sUsersetRewrite.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = UsersetRewriteValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = UsersetRewriteValidationError{} + +// Validate checks the field values on SetOperation with the rules defined in +// the proto definition for this message. If any rules are violated, the first +// error encountered is returned, or nil if there are no violations. +func (m *SetOperation) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on SetOperation with the rules defined +// in the proto definition for this message. If any rules are violated, the +// result is a list of violation errors wrapped in SetOperationMultiError, or +// nil if none found. +func (m *SetOperation) ValidateAll() error { + return m.validate(true) +} + +func (m *SetOperation) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if len(m.GetChild()) < 1 { + err := SetOperationValidationError{ + field: "Child", + reason: "value must contain at least 1 item(s)", + } + if !all { + return err + } + errors = append(errors, err) + } + + for idx, item := range m.GetChild() { + _, _ = idx, item + + if item == nil { + err := SetOperationValidationError{ + field: fmt.Sprintf("Child[%v]", idx), + reason: "value is required", + } + if !all { + return err + } + errors = append(errors, err) + } + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, SetOperationValidationError{ + field: fmt.Sprintf("Child[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, SetOperationValidationError{ + field: fmt.Sprintf("Child[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return SetOperationValidationError{ + field: fmt.Sprintf("Child[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + if len(errors) > 0 { + return SetOperationMultiError(errors) + } + + return nil +} + +// SetOperationMultiError is an error wrapping multiple validation errors +// returned by SetOperation.ValidateAll() if the designated constraints aren't met. +type SetOperationMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m SetOperationMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m SetOperationMultiError) AllErrors() []error { return m } + +// SetOperationValidationError is the validation error returned by +// SetOperation.Validate if the designated constraints aren't met. +type SetOperationValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e SetOperationValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e SetOperationValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e SetOperationValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e SetOperationValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e SetOperationValidationError) ErrorName() string { return "SetOperationValidationError" } + +// Error satisfies the builtin error interface +func (e SetOperationValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sSetOperation.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = SetOperationValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = SetOperationValidationError{} + +// Validate checks the field values on TupleToUserset with the rules defined in +// the proto definition for this message. If any rules are violated, the first +// error encountered is returned, or nil if there are no violations. +func (m *TupleToUserset) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on TupleToUserset with the rules defined +// in the proto definition for this message. If any rules are violated, the +// result is a list of violation errors wrapped in TupleToUsersetMultiError, +// or nil if none found. +func (m *TupleToUserset) ValidateAll() error { + return m.validate(true) +} + +func (m *TupleToUserset) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if m.GetTupleset() == nil { + err := TupleToUsersetValidationError{ + field: "Tupleset", + reason: "value is required", + } + if !all { + return err + } + errors = append(errors, err) + } + + if all { + switch v := interface{}(m.GetTupleset()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, TupleToUsersetValidationError{ + field: "Tupleset", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, TupleToUsersetValidationError{ + field: "Tupleset", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetTupleset()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return TupleToUsersetValidationError{ + field: "Tupleset", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if m.GetComputedUserset() == nil { + err := TupleToUsersetValidationError{ + field: "ComputedUserset", + reason: "value is required", + } + if !all { + return err + } + errors = append(errors, err) + } + + if all { + switch v := interface{}(m.GetComputedUserset()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, TupleToUsersetValidationError{ + field: "ComputedUserset", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, TupleToUsersetValidationError{ + field: "ComputedUserset", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetComputedUserset()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return TupleToUsersetValidationError{ + field: "ComputedUserset", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if all { + switch v := interface{}(m.GetSourcePosition()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, TupleToUsersetValidationError{ + field: "SourcePosition", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, TupleToUsersetValidationError{ + field: "SourcePosition", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetSourcePosition()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return TupleToUsersetValidationError{ + field: "SourcePosition", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return TupleToUsersetMultiError(errors) + } + + return nil +} + +// TupleToUsersetMultiError is an error wrapping multiple validation errors +// returned by TupleToUserset.ValidateAll() if the designated constraints +// aren't met. +type TupleToUsersetMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m TupleToUsersetMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m TupleToUsersetMultiError) AllErrors() []error { return m } + +// TupleToUsersetValidationError is the validation error returned by +// TupleToUserset.Validate if the designated constraints aren't met. +type TupleToUsersetValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e TupleToUsersetValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e TupleToUsersetValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e TupleToUsersetValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e TupleToUsersetValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e TupleToUsersetValidationError) ErrorName() string { return "TupleToUsersetValidationError" } + +// Error satisfies the builtin error interface +func (e TupleToUsersetValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sTupleToUserset.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = TupleToUsersetValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = TupleToUsersetValidationError{} + +// Validate checks the field values on FunctionedTupleToUserset with the rules +// defined in the proto definition for this message. If any rules are +// violated, the first error encountered is returned, or nil if there are no violations. +func (m *FunctionedTupleToUserset) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on FunctionedTupleToUserset with the +// rules defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// FunctionedTupleToUsersetMultiError, or nil if none found. +func (m *FunctionedTupleToUserset) ValidateAll() error { + return m.validate(true) +} + +func (m *FunctionedTupleToUserset) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if _, ok := _FunctionedTupleToUserset_Function_NotInLookup[m.GetFunction()]; ok { + err := FunctionedTupleToUsersetValidationError{ + field: "Function", + reason: "value must not be in list [FUNCTION_UNSPECIFIED]", + } + if !all { + return err + } + errors = append(errors, err) + } + + if _, ok := FunctionedTupleToUserset_Function_name[int32(m.GetFunction())]; !ok { + err := FunctionedTupleToUsersetValidationError{ + field: "Function", + reason: "value must be one of the defined enum values", + } + if !all { + return err + } + errors = append(errors, err) + } + + if m.GetTupleset() == nil { + err := FunctionedTupleToUsersetValidationError{ + field: "Tupleset", + reason: "value is required", + } + if !all { + return err + } + errors = append(errors, err) + } + + if all { + switch v := interface{}(m.GetTupleset()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, FunctionedTupleToUsersetValidationError{ + field: "Tupleset", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, FunctionedTupleToUsersetValidationError{ + field: "Tupleset", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetTupleset()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return FunctionedTupleToUsersetValidationError{ + field: "Tupleset", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if m.GetComputedUserset() == nil { + err := FunctionedTupleToUsersetValidationError{ + field: "ComputedUserset", + reason: "value is required", + } + if !all { + return err + } + errors = append(errors, err) + } + + if all { + switch v := interface{}(m.GetComputedUserset()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, FunctionedTupleToUsersetValidationError{ + field: "ComputedUserset", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, FunctionedTupleToUsersetValidationError{ + field: "ComputedUserset", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetComputedUserset()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return FunctionedTupleToUsersetValidationError{ + field: "ComputedUserset", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if all { + switch v := interface{}(m.GetSourcePosition()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, FunctionedTupleToUsersetValidationError{ + field: "SourcePosition", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, FunctionedTupleToUsersetValidationError{ + field: "SourcePosition", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetSourcePosition()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return FunctionedTupleToUsersetValidationError{ + field: "SourcePosition", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return FunctionedTupleToUsersetMultiError(errors) + } + + return nil +} + +// FunctionedTupleToUsersetMultiError is an error wrapping multiple validation +// errors returned by FunctionedTupleToUserset.ValidateAll() if the designated +// constraints aren't met. +type FunctionedTupleToUsersetMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m FunctionedTupleToUsersetMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m FunctionedTupleToUsersetMultiError) AllErrors() []error { return m } + +// FunctionedTupleToUsersetValidationError is the validation error returned by +// FunctionedTupleToUserset.Validate if the designated constraints aren't met. +type FunctionedTupleToUsersetValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e FunctionedTupleToUsersetValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e FunctionedTupleToUsersetValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e FunctionedTupleToUsersetValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e FunctionedTupleToUsersetValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e FunctionedTupleToUsersetValidationError) ErrorName() string { + return "FunctionedTupleToUsersetValidationError" +} + +// Error satisfies the builtin error interface +func (e FunctionedTupleToUsersetValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sFunctionedTupleToUserset.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = FunctionedTupleToUsersetValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = FunctionedTupleToUsersetValidationError{} + +var _FunctionedTupleToUserset_Function_NotInLookup = map[FunctionedTupleToUserset_Function]struct{}{ + 0: {}, +} + +// Validate checks the field values on ComputedUserset with the rules defined +// in the proto definition for this message. If any rules are violated, the +// first error encountered is returned, or nil if there are no violations. +func (m *ComputedUserset) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on ComputedUserset with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// ComputedUsersetMultiError, or nil if none found. +func (m *ComputedUserset) ValidateAll() error { + return m.validate(true) +} + +func (m *ComputedUserset) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if _, ok := ComputedUserset_Object_name[int32(m.GetObject())]; !ok { + err := ComputedUsersetValidationError{ + field: "Object", + reason: "value must be one of the defined enum values", + } + if !all { + return err + } + errors = append(errors, err) + } + + if len(m.GetRelation()) > 64 { + err := ComputedUsersetValidationError{ + field: "Relation", + reason: "value length must be at most 64 bytes", + } + if !all { + return err + } + errors = append(errors, err) + } + + if !_ComputedUserset_Relation_Pattern.MatchString(m.GetRelation()) { + err := ComputedUsersetValidationError{ + field: "Relation", + reason: "value does not match regex pattern \"^[a-z][a-z0-9_]{1,62}[a-z0-9]$\"", + } + if !all { + return err + } + errors = append(errors, err) + } + + if all { + switch v := interface{}(m.GetSourcePosition()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, ComputedUsersetValidationError{ + field: "SourcePosition", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, ComputedUsersetValidationError{ + field: "SourcePosition", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetSourcePosition()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return ComputedUsersetValidationError{ + field: "SourcePosition", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return ComputedUsersetMultiError(errors) + } + + return nil +} + +// ComputedUsersetMultiError is an error wrapping multiple validation errors +// returned by ComputedUserset.ValidateAll() if the designated constraints +// aren't met. +type ComputedUsersetMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ComputedUsersetMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m ComputedUsersetMultiError) AllErrors() []error { return m } + +// ComputedUsersetValidationError is the validation error returned by +// ComputedUserset.Validate if the designated constraints aren't met. +type ComputedUsersetValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e ComputedUsersetValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e ComputedUsersetValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e ComputedUsersetValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e ComputedUsersetValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e ComputedUsersetValidationError) ErrorName() string { return "ComputedUsersetValidationError" } + +// Error satisfies the builtin error interface +func (e ComputedUsersetValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sComputedUserset.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = ComputedUsersetValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = ComputedUsersetValidationError{} + +var _ComputedUserset_Relation_Pattern = regexp.MustCompile("^[a-z][a-z0-9_]{1,62}[a-z0-9]$") + +// Validate checks the field values on SourcePosition with the rules defined in +// the proto definition for this message. If any rules are violated, the first +// error encountered is returned, or nil if there are no violations. +func (m *SourcePosition) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on SourcePosition with the rules defined +// in the proto definition for this message. If any rules are violated, the +// result is a list of violation errors wrapped in SourcePositionMultiError, +// or nil if none found. +func (m *SourcePosition) ValidateAll() error { + return m.validate(true) +} + +func (m *SourcePosition) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for ZeroIndexedLineNumber + + // no validation rules for ZeroIndexedColumnPosition + + if len(errors) > 0 { + return SourcePositionMultiError(errors) + } + + return nil +} + +// SourcePositionMultiError is an error wrapping multiple validation errors +// returned by SourcePosition.ValidateAll() if the designated constraints +// aren't met. +type SourcePositionMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m SourcePositionMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m SourcePositionMultiError) AllErrors() []error { return m } + +// SourcePositionValidationError is the validation error returned by +// SourcePosition.Validate if the designated constraints aren't met. +type SourcePositionValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e SourcePositionValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e SourcePositionValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e SourcePositionValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e SourcePositionValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e SourcePositionValidationError) ErrorName() string { return "SourcePositionValidationError" } + +// Error satisfies the builtin error interface +func (e SourcePositionValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sSourcePosition.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = SourcePositionValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = SourcePositionValidationError{} + +// Validate checks the field values on CaveatExpression with the rules defined +// in the proto definition for this message. If any rules are violated, the +// first error encountered is returned, or nil if there are no violations. +func (m *CaveatExpression) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on CaveatExpression with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// CaveatExpressionMultiError, or nil if none found. +func (m *CaveatExpression) ValidateAll() error { + return m.validate(true) +} + +func (m *CaveatExpression) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + switch v := m.OperationOrCaveat.(type) { + case *CaveatExpression_Operation: + if v == nil { + err := CaveatExpressionValidationError{ + field: "OperationOrCaveat", + reason: "oneof value cannot be a typed-nil", + } + if !all { + return err + } + errors = append(errors, err) + } + + if all { + switch v := interface{}(m.GetOperation()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, CaveatExpressionValidationError{ + field: "Operation", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, CaveatExpressionValidationError{ + field: "Operation", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetOperation()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return CaveatExpressionValidationError{ + field: "Operation", + reason: "embedded message failed validation", + cause: err, + } + } + } + + case *CaveatExpression_Caveat: + if v == nil { + err := CaveatExpressionValidationError{ + field: "OperationOrCaveat", + reason: "oneof value cannot be a typed-nil", + } + if !all { + return err + } + errors = append(errors, err) + } + + if all { + switch v := interface{}(m.GetCaveat()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, CaveatExpressionValidationError{ + field: "Caveat", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, CaveatExpressionValidationError{ + field: "Caveat", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetCaveat()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return CaveatExpressionValidationError{ + field: "Caveat", + reason: "embedded message failed validation", + cause: err, + } + } + } + + default: + _ = v // ensures v is used + } + + if len(errors) > 0 { + return CaveatExpressionMultiError(errors) + } + + return nil +} + +// CaveatExpressionMultiError is an error wrapping multiple validation errors +// returned by CaveatExpression.ValidateAll() if the designated constraints +// aren't met. +type CaveatExpressionMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m CaveatExpressionMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m CaveatExpressionMultiError) AllErrors() []error { return m } + +// CaveatExpressionValidationError is the validation error returned by +// CaveatExpression.Validate if the designated constraints aren't met. +type CaveatExpressionValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e CaveatExpressionValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e CaveatExpressionValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e CaveatExpressionValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e CaveatExpressionValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e CaveatExpressionValidationError) ErrorName() string { return "CaveatExpressionValidationError" } + +// Error satisfies the builtin error interface +func (e CaveatExpressionValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sCaveatExpression.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = CaveatExpressionValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = CaveatExpressionValidationError{} + +// Validate checks the field values on CaveatOperation with the rules defined +// in the proto definition for this message. If any rules are violated, the +// first error encountered is returned, or nil if there are no violations. +func (m *CaveatOperation) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on CaveatOperation with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// CaveatOperationMultiError, or nil if none found. +func (m *CaveatOperation) ValidateAll() error { + return m.validate(true) +} + +func (m *CaveatOperation) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Op + + for idx, item := range m.GetChildren() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, CaveatOperationValidationError{ + field: fmt.Sprintf("Children[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, CaveatOperationValidationError{ + field: fmt.Sprintf("Children[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return CaveatOperationValidationError{ + field: fmt.Sprintf("Children[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + if len(errors) > 0 { + return CaveatOperationMultiError(errors) + } + + return nil +} + +// CaveatOperationMultiError is an error wrapping multiple validation errors +// returned by CaveatOperation.ValidateAll() if the designated constraints +// aren't met. +type CaveatOperationMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m CaveatOperationMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m CaveatOperationMultiError) AllErrors() []error { return m } + +// CaveatOperationValidationError is the validation error returned by +// CaveatOperation.Validate if the designated constraints aren't met. +type CaveatOperationValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e CaveatOperationValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e CaveatOperationValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e CaveatOperationValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e CaveatOperationValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e CaveatOperationValidationError) ErrorName() string { return "CaveatOperationValidationError" } + +// Error satisfies the builtin error interface +func (e CaveatOperationValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sCaveatOperation.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = CaveatOperationValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = CaveatOperationValidationError{} + +// Validate checks the field values on RelationshipFilter with the rules +// defined in the proto definition for this message. If any rules are +// violated, the first error encountered is returned, or nil if there are no violations. +func (m *RelationshipFilter) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on RelationshipFilter with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// RelationshipFilterMultiError, or nil if none found. +func (m *RelationshipFilter) ValidateAll() error { + return m.validate(true) +} + +func (m *RelationshipFilter) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if len(m.GetResourceType()) > 128 { + err := RelationshipFilterValidationError{ + field: "ResourceType", + reason: "value length must be at most 128 bytes", + } + if !all { + return err + } + errors = append(errors, err) + } + + if !_RelationshipFilter_ResourceType_Pattern.MatchString(m.GetResourceType()) { + err := RelationshipFilterValidationError{ + field: "ResourceType", + reason: "value does not match regex pattern \"^(([a-z][a-z0-9_]{1,61}[a-z0-9]/)*[a-z][a-z0-9_]{1,62}[a-z0-9])?$\"", + } + if !all { + return err + } + errors = append(errors, err) + } + + if len(m.GetOptionalResourceId()) > 1024 { + err := RelationshipFilterValidationError{ + field: "OptionalResourceId", + reason: "value length must be at most 1024 bytes", + } + if !all { + return err + } + errors = append(errors, err) + } + + if !_RelationshipFilter_OptionalResourceId_Pattern.MatchString(m.GetOptionalResourceId()) { + err := RelationshipFilterValidationError{ + field: "OptionalResourceId", + reason: "value does not match regex pattern \"^([a-zA-Z0-9/_|\\\\-=+]{1,})?$\"", + } + if !all { + return err + } + errors = append(errors, err) + } + + if len(m.GetOptionalResourceIdPrefix()) > 1024 { + err := RelationshipFilterValidationError{ + field: "OptionalResourceIdPrefix", + reason: "value length must be at most 1024 bytes", + } + if !all { + return err + } + errors = append(errors, err) + } + + if !_RelationshipFilter_OptionalResourceIdPrefix_Pattern.MatchString(m.GetOptionalResourceIdPrefix()) { + err := RelationshipFilterValidationError{ + field: "OptionalResourceIdPrefix", + reason: "value does not match regex pattern \"^([a-zA-Z0-9/_|\\\\-=+]{1,})?$\"", + } + if !all { + return err + } + errors = append(errors, err) + } + + if len(m.GetOptionalRelation()) > 64 { + err := RelationshipFilterValidationError{ + field: "OptionalRelation", + reason: "value length must be at most 64 bytes", + } + if !all { + return err + } + errors = append(errors, err) + } + + if !_RelationshipFilter_OptionalRelation_Pattern.MatchString(m.GetOptionalRelation()) { + err := RelationshipFilterValidationError{ + field: "OptionalRelation", + reason: "value does not match regex pattern \"^([a-z][a-z0-9_]{1,62}[a-z0-9])?$\"", + } + if !all { + return err + } + errors = append(errors, err) + } + + if all { + switch v := interface{}(m.GetOptionalSubjectFilter()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, RelationshipFilterValidationError{ + field: "OptionalSubjectFilter", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, RelationshipFilterValidationError{ + field: "OptionalSubjectFilter", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetOptionalSubjectFilter()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return RelationshipFilterValidationError{ + field: "OptionalSubjectFilter", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return RelationshipFilterMultiError(errors) + } + + return nil +} + +// RelationshipFilterMultiError is an error wrapping multiple validation errors +// returned by RelationshipFilter.ValidateAll() if the designated constraints +// aren't met. +type RelationshipFilterMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m RelationshipFilterMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m RelationshipFilterMultiError) AllErrors() []error { return m } + +// RelationshipFilterValidationError is the validation error returned by +// RelationshipFilter.Validate if the designated constraints aren't met. +type RelationshipFilterValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e RelationshipFilterValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e RelationshipFilterValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e RelationshipFilterValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e RelationshipFilterValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e RelationshipFilterValidationError) ErrorName() string { + return "RelationshipFilterValidationError" +} + +// Error satisfies the builtin error interface +func (e RelationshipFilterValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sRelationshipFilter.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = RelationshipFilterValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = RelationshipFilterValidationError{} + +var _RelationshipFilter_ResourceType_Pattern = regexp.MustCompile("^(([a-z][a-z0-9_]{1,61}[a-z0-9]/)*[a-z][a-z0-9_]{1,62}[a-z0-9])?$") + +var _RelationshipFilter_OptionalResourceId_Pattern = regexp.MustCompile("^([a-zA-Z0-9/_|\\-=+]{1,})?$") + +var _RelationshipFilter_OptionalResourceIdPrefix_Pattern = regexp.MustCompile("^([a-zA-Z0-9/_|\\-=+]{1,})?$") + +var _RelationshipFilter_OptionalRelation_Pattern = regexp.MustCompile("^([a-z][a-z0-9_]{1,62}[a-z0-9])?$") + +// Validate checks the field values on SubjectFilter with the rules defined in +// the proto definition for this message. If any rules are violated, the first +// error encountered is returned, or nil if there are no violations. +func (m *SubjectFilter) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on SubjectFilter with the rules defined +// in the proto definition for this message. If any rules are violated, the +// result is a list of violation errors wrapped in SubjectFilterMultiError, or +// nil if none found. +func (m *SubjectFilter) ValidateAll() error { + return m.validate(true) +} + +func (m *SubjectFilter) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if len(m.GetSubjectType()) > 128 { + err := SubjectFilterValidationError{ + field: "SubjectType", + reason: "value length must be at most 128 bytes", + } + if !all { + return err + } + errors = append(errors, err) + } + + if !_SubjectFilter_SubjectType_Pattern.MatchString(m.GetSubjectType()) { + err := SubjectFilterValidationError{ + field: "SubjectType", + reason: "value does not match regex pattern \"^([a-z][a-z0-9_]{1,61}[a-z0-9]/)*[a-z][a-z0-9_]{1,62}[a-z0-9]$\"", + } + if !all { + return err + } + errors = append(errors, err) + } + + if len(m.GetOptionalSubjectId()) > 1024 { + err := SubjectFilterValidationError{ + field: "OptionalSubjectId", + reason: "value length must be at most 1024 bytes", + } + if !all { + return err + } + errors = append(errors, err) + } + + if !_SubjectFilter_OptionalSubjectId_Pattern.MatchString(m.GetOptionalSubjectId()) { + err := SubjectFilterValidationError{ + field: "OptionalSubjectId", + reason: "value does not match regex pattern \"^(([a-zA-Z0-9/_|\\\\-=+]{1,})|\\\\*)?$\"", + } + if !all { + return err + } + errors = append(errors, err) + } + + if all { + switch v := interface{}(m.GetOptionalRelation()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, SubjectFilterValidationError{ + field: "OptionalRelation", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, SubjectFilterValidationError{ + field: "OptionalRelation", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetOptionalRelation()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return SubjectFilterValidationError{ + field: "OptionalRelation", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return SubjectFilterMultiError(errors) + } + + return nil +} + +// SubjectFilterMultiError is an error wrapping multiple validation errors +// returned by SubjectFilter.ValidateAll() if the designated constraints +// aren't met. +type SubjectFilterMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m SubjectFilterMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m SubjectFilterMultiError) AllErrors() []error { return m } + +// SubjectFilterValidationError is the validation error returned by +// SubjectFilter.Validate if the designated constraints aren't met. +type SubjectFilterValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e SubjectFilterValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e SubjectFilterValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e SubjectFilterValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e SubjectFilterValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e SubjectFilterValidationError) ErrorName() string { return "SubjectFilterValidationError" } + +// Error satisfies the builtin error interface +func (e SubjectFilterValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sSubjectFilter.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = SubjectFilterValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = SubjectFilterValidationError{} + +var _SubjectFilter_SubjectType_Pattern = regexp.MustCompile("^([a-z][a-z0-9_]{1,61}[a-z0-9]/)*[a-z][a-z0-9_]{1,62}[a-z0-9]$") + +var _SubjectFilter_OptionalSubjectId_Pattern = regexp.MustCompile("^(([a-zA-Z0-9/_|\\-=+]{1,})|\\*)?$") + +// Validate checks the field values on AllowedRelation_PublicWildcard with the +// rules defined in the proto definition for this message. If any rules are +// violated, the first error encountered is returned, or nil if there are no violations. +func (m *AllowedRelation_PublicWildcard) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on AllowedRelation_PublicWildcard with +// the rules defined in the proto definition for this message. If any rules +// are violated, the result is a list of violation errors wrapped in +// AllowedRelation_PublicWildcardMultiError, or nil if none found. +func (m *AllowedRelation_PublicWildcard) ValidateAll() error { + return m.validate(true) +} + +func (m *AllowedRelation_PublicWildcard) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if len(errors) > 0 { + return AllowedRelation_PublicWildcardMultiError(errors) + } + + return nil +} + +// AllowedRelation_PublicWildcardMultiError is an error wrapping multiple +// validation errors returned by AllowedRelation_PublicWildcard.ValidateAll() +// if the designated constraints aren't met. +type AllowedRelation_PublicWildcardMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m AllowedRelation_PublicWildcardMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m AllowedRelation_PublicWildcardMultiError) AllErrors() []error { return m } + +// AllowedRelation_PublicWildcardValidationError is the validation error +// returned by AllowedRelation_PublicWildcard.Validate if the designated +// constraints aren't met. +type AllowedRelation_PublicWildcardValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e AllowedRelation_PublicWildcardValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e AllowedRelation_PublicWildcardValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e AllowedRelation_PublicWildcardValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e AllowedRelation_PublicWildcardValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e AllowedRelation_PublicWildcardValidationError) ErrorName() string { + return "AllowedRelation_PublicWildcardValidationError" +} + +// Error satisfies the builtin error interface +func (e AllowedRelation_PublicWildcardValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sAllowedRelation_PublicWildcard.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = AllowedRelation_PublicWildcardValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = AllowedRelation_PublicWildcardValidationError{} + +// Validate checks the field values on SetOperation_Child with the rules +// defined in the proto definition for this message. If any rules are +// violated, the first error encountered is returned, or nil if there are no violations. +func (m *SetOperation_Child) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on SetOperation_Child with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// SetOperation_ChildMultiError, or nil if none found. +func (m *SetOperation_Child) ValidateAll() error { + return m.validate(true) +} + +func (m *SetOperation_Child) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetSourcePosition()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, SetOperation_ChildValidationError{ + field: "SourcePosition", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, SetOperation_ChildValidationError{ + field: "SourcePosition", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetSourcePosition()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return SetOperation_ChildValidationError{ + field: "SourcePosition", + reason: "embedded message failed validation", + cause: err, + } + } + } + + oneofChildTypePresent := false + switch v := m.ChildType.(type) { + case *SetOperation_Child_XThis: + if v == nil { + err := SetOperation_ChildValidationError{ + field: "ChildType", + reason: "oneof value cannot be a typed-nil", + } + if !all { + return err + } + errors = append(errors, err) + } + oneofChildTypePresent = true + + if all { + switch v := interface{}(m.GetXThis()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, SetOperation_ChildValidationError{ + field: "XThis", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, SetOperation_ChildValidationError{ + field: "XThis", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetXThis()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return SetOperation_ChildValidationError{ + field: "XThis", + reason: "embedded message failed validation", + cause: err, + } + } + } + + case *SetOperation_Child_ComputedUserset: + if v == nil { + err := SetOperation_ChildValidationError{ + field: "ChildType", + reason: "oneof value cannot be a typed-nil", + } + if !all { + return err + } + errors = append(errors, err) + } + oneofChildTypePresent = true + + if m.GetComputedUserset() == nil { + err := SetOperation_ChildValidationError{ + field: "ComputedUserset", + reason: "value is required", + } + if !all { + return err + } + errors = append(errors, err) + } + + if all { + switch v := interface{}(m.GetComputedUserset()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, SetOperation_ChildValidationError{ + field: "ComputedUserset", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, SetOperation_ChildValidationError{ + field: "ComputedUserset", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetComputedUserset()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return SetOperation_ChildValidationError{ + field: "ComputedUserset", + reason: "embedded message failed validation", + cause: err, + } + } + } + + case *SetOperation_Child_TupleToUserset: + if v == nil { + err := SetOperation_ChildValidationError{ + field: "ChildType", + reason: "oneof value cannot be a typed-nil", + } + if !all { + return err + } + errors = append(errors, err) + } + oneofChildTypePresent = true + + if m.GetTupleToUserset() == nil { + err := SetOperation_ChildValidationError{ + field: "TupleToUserset", + reason: "value is required", + } + if !all { + return err + } + errors = append(errors, err) + } + + if all { + switch v := interface{}(m.GetTupleToUserset()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, SetOperation_ChildValidationError{ + field: "TupleToUserset", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, SetOperation_ChildValidationError{ + field: "TupleToUserset", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetTupleToUserset()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return SetOperation_ChildValidationError{ + field: "TupleToUserset", + reason: "embedded message failed validation", + cause: err, + } + } + } + + case *SetOperation_Child_UsersetRewrite: + if v == nil { + err := SetOperation_ChildValidationError{ + field: "ChildType", + reason: "oneof value cannot be a typed-nil", + } + if !all { + return err + } + errors = append(errors, err) + } + oneofChildTypePresent = true + + if m.GetUsersetRewrite() == nil { + err := SetOperation_ChildValidationError{ + field: "UsersetRewrite", + reason: "value is required", + } + if !all { + return err + } + errors = append(errors, err) + } + + if all { + switch v := interface{}(m.GetUsersetRewrite()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, SetOperation_ChildValidationError{ + field: "UsersetRewrite", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, SetOperation_ChildValidationError{ + field: "UsersetRewrite", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetUsersetRewrite()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return SetOperation_ChildValidationError{ + field: "UsersetRewrite", + reason: "embedded message failed validation", + cause: err, + } + } + } + + case *SetOperation_Child_FunctionedTupleToUserset: + if v == nil { + err := SetOperation_ChildValidationError{ + field: "ChildType", + reason: "oneof value cannot be a typed-nil", + } + if !all { + return err + } + errors = append(errors, err) + } + oneofChildTypePresent = true + + if m.GetFunctionedTupleToUserset() == nil { + err := SetOperation_ChildValidationError{ + field: "FunctionedTupleToUserset", + reason: "value is required", + } + if !all { + return err + } + errors = append(errors, err) + } + + if all { + switch v := interface{}(m.GetFunctionedTupleToUserset()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, SetOperation_ChildValidationError{ + field: "FunctionedTupleToUserset", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, SetOperation_ChildValidationError{ + field: "FunctionedTupleToUserset", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetFunctionedTupleToUserset()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return SetOperation_ChildValidationError{ + field: "FunctionedTupleToUserset", + reason: "embedded message failed validation", + cause: err, + } + } + } + + case *SetOperation_Child_XNil: + if v == nil { + err := SetOperation_ChildValidationError{ + field: "ChildType", + reason: "oneof value cannot be a typed-nil", + } + if !all { + return err + } + errors = append(errors, err) + } + oneofChildTypePresent = true + + if all { + switch v := interface{}(m.GetXNil()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, SetOperation_ChildValidationError{ + field: "XNil", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, SetOperation_ChildValidationError{ + field: "XNil", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetXNil()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return SetOperation_ChildValidationError{ + field: "XNil", + reason: "embedded message failed validation", + cause: err, + } + } + } + + default: + _ = v // ensures v is used + } + if !oneofChildTypePresent { + err := SetOperation_ChildValidationError{ + field: "ChildType", + reason: "value is required", + } + if !all { + return err + } + errors = append(errors, err) + } + + if len(errors) > 0 { + return SetOperation_ChildMultiError(errors) + } + + return nil +} + +// SetOperation_ChildMultiError is an error wrapping multiple validation errors +// returned by SetOperation_Child.ValidateAll() if the designated constraints +// aren't met. +type SetOperation_ChildMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m SetOperation_ChildMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m SetOperation_ChildMultiError) AllErrors() []error { return m } + +// SetOperation_ChildValidationError is the validation error returned by +// SetOperation_Child.Validate if the designated constraints aren't met. +type SetOperation_ChildValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e SetOperation_ChildValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e SetOperation_ChildValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e SetOperation_ChildValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e SetOperation_ChildValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e SetOperation_ChildValidationError) ErrorName() string { + return "SetOperation_ChildValidationError" +} + +// Error satisfies the builtin error interface +func (e SetOperation_ChildValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sSetOperation_Child.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = SetOperation_ChildValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = SetOperation_ChildValidationError{} + +// Validate checks the field values on SetOperation_Child_This with the rules +// defined in the proto definition for this message. If any rules are +// violated, the first error encountered is returned, or nil if there are no violations. +func (m *SetOperation_Child_This) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on SetOperation_Child_This with the +// rules defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// SetOperation_Child_ThisMultiError, or nil if none found. +func (m *SetOperation_Child_This) ValidateAll() error { + return m.validate(true) +} + +func (m *SetOperation_Child_This) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if len(errors) > 0 { + return SetOperation_Child_ThisMultiError(errors) + } + + return nil +} + +// SetOperation_Child_ThisMultiError is an error wrapping multiple validation +// errors returned by SetOperation_Child_This.ValidateAll() if the designated +// constraints aren't met. +type SetOperation_Child_ThisMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m SetOperation_Child_ThisMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m SetOperation_Child_ThisMultiError) AllErrors() []error { return m } + +// SetOperation_Child_ThisValidationError is the validation error returned by +// SetOperation_Child_This.Validate if the designated constraints aren't met. +type SetOperation_Child_ThisValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e SetOperation_Child_ThisValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e SetOperation_Child_ThisValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e SetOperation_Child_ThisValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e SetOperation_Child_ThisValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e SetOperation_Child_ThisValidationError) ErrorName() string { + return "SetOperation_Child_ThisValidationError" +} + +// Error satisfies the builtin error interface +func (e SetOperation_Child_ThisValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sSetOperation_Child_This.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = SetOperation_Child_ThisValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = SetOperation_Child_ThisValidationError{} + +// Validate checks the field values on SetOperation_Child_Nil with the rules +// defined in the proto definition for this message. If any rules are +// violated, the first error encountered is returned, or nil if there are no violations. +func (m *SetOperation_Child_Nil) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on SetOperation_Child_Nil with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// SetOperation_Child_NilMultiError, or nil if none found. +func (m *SetOperation_Child_Nil) ValidateAll() error { + return m.validate(true) +} + +func (m *SetOperation_Child_Nil) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if len(errors) > 0 { + return SetOperation_Child_NilMultiError(errors) + } + + return nil +} + +// SetOperation_Child_NilMultiError is an error wrapping multiple validation +// errors returned by SetOperation_Child_Nil.ValidateAll() if the designated +// constraints aren't met. +type SetOperation_Child_NilMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m SetOperation_Child_NilMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m SetOperation_Child_NilMultiError) AllErrors() []error { return m } + +// SetOperation_Child_NilValidationError is the validation error returned by +// SetOperation_Child_Nil.Validate if the designated constraints aren't met. +type SetOperation_Child_NilValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e SetOperation_Child_NilValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e SetOperation_Child_NilValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e SetOperation_Child_NilValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e SetOperation_Child_NilValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e SetOperation_Child_NilValidationError) ErrorName() string { + return "SetOperation_Child_NilValidationError" +} + +// Error satisfies the builtin error interface +func (e SetOperation_Child_NilValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sSetOperation_Child_Nil.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = SetOperation_Child_NilValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = SetOperation_Child_NilValidationError{} + +// Validate checks the field values on TupleToUserset_Tupleset with the rules +// defined in the proto definition for this message. If any rules are +// violated, the first error encountered is returned, or nil if there are no violations. +func (m *TupleToUserset_Tupleset) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on TupleToUserset_Tupleset with the +// rules defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// TupleToUserset_TuplesetMultiError, or nil if none found. +func (m *TupleToUserset_Tupleset) ValidateAll() error { + return m.validate(true) +} + +func (m *TupleToUserset_Tupleset) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if len(m.GetRelation()) > 64 { + err := TupleToUserset_TuplesetValidationError{ + field: "Relation", + reason: "value length must be at most 64 bytes", + } + if !all { + return err + } + errors = append(errors, err) + } + + if !_TupleToUserset_Tupleset_Relation_Pattern.MatchString(m.GetRelation()) { + err := TupleToUserset_TuplesetValidationError{ + field: "Relation", + reason: "value does not match regex pattern \"^[a-z][a-z0-9_]{1,62}[a-z0-9]$\"", + } + if !all { + return err + } + errors = append(errors, err) + } + + if len(errors) > 0 { + return TupleToUserset_TuplesetMultiError(errors) + } + + return nil +} + +// TupleToUserset_TuplesetMultiError is an error wrapping multiple validation +// errors returned by TupleToUserset_Tupleset.ValidateAll() if the designated +// constraints aren't met. +type TupleToUserset_TuplesetMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m TupleToUserset_TuplesetMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m TupleToUserset_TuplesetMultiError) AllErrors() []error { return m } + +// TupleToUserset_TuplesetValidationError is the validation error returned by +// TupleToUserset_Tupleset.Validate if the designated constraints aren't met. +type TupleToUserset_TuplesetValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e TupleToUserset_TuplesetValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e TupleToUserset_TuplesetValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e TupleToUserset_TuplesetValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e TupleToUserset_TuplesetValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e TupleToUserset_TuplesetValidationError) ErrorName() string { + return "TupleToUserset_TuplesetValidationError" +} + +// Error satisfies the builtin error interface +func (e TupleToUserset_TuplesetValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sTupleToUserset_Tupleset.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = TupleToUserset_TuplesetValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = TupleToUserset_TuplesetValidationError{} + +var _TupleToUserset_Tupleset_Relation_Pattern = regexp.MustCompile("^[a-z][a-z0-9_]{1,62}[a-z0-9]$") + +// Validate checks the field values on FunctionedTupleToUserset_Tupleset with +// the rules defined in the proto definition for this message. If any rules +// are violated, the first error encountered is returned, or nil if there are +// no violations. +func (m *FunctionedTupleToUserset_Tupleset) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on FunctionedTupleToUserset_Tupleset +// with the rules defined in the proto definition for this message. If any +// rules are violated, the result is a list of violation errors wrapped in +// FunctionedTupleToUserset_TuplesetMultiError, or nil if none found. +func (m *FunctionedTupleToUserset_Tupleset) ValidateAll() error { + return m.validate(true) +} + +func (m *FunctionedTupleToUserset_Tupleset) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if len(m.GetRelation()) > 64 { + err := FunctionedTupleToUserset_TuplesetValidationError{ + field: "Relation", + reason: "value length must be at most 64 bytes", + } + if !all { + return err + } + errors = append(errors, err) + } + + if !_FunctionedTupleToUserset_Tupleset_Relation_Pattern.MatchString(m.GetRelation()) { + err := FunctionedTupleToUserset_TuplesetValidationError{ + field: "Relation", + reason: "value does not match regex pattern \"^[a-z][a-z0-9_]{1,62}[a-z0-9]$\"", + } + if !all { + return err + } + errors = append(errors, err) + } + + if len(errors) > 0 { + return FunctionedTupleToUserset_TuplesetMultiError(errors) + } + + return nil +} + +// FunctionedTupleToUserset_TuplesetMultiError is an error wrapping multiple +// validation errors returned by +// FunctionedTupleToUserset_Tupleset.ValidateAll() if the designated +// constraints aren't met. +type FunctionedTupleToUserset_TuplesetMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m FunctionedTupleToUserset_TuplesetMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m FunctionedTupleToUserset_TuplesetMultiError) AllErrors() []error { return m } + +// FunctionedTupleToUserset_TuplesetValidationError is the validation error +// returned by FunctionedTupleToUserset_Tupleset.Validate if the designated +// constraints aren't met. +type FunctionedTupleToUserset_TuplesetValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e FunctionedTupleToUserset_TuplesetValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e FunctionedTupleToUserset_TuplesetValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e FunctionedTupleToUserset_TuplesetValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e FunctionedTupleToUserset_TuplesetValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e FunctionedTupleToUserset_TuplesetValidationError) ErrorName() string { + return "FunctionedTupleToUserset_TuplesetValidationError" +} + +// Error satisfies the builtin error interface +func (e FunctionedTupleToUserset_TuplesetValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sFunctionedTupleToUserset_Tupleset.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = FunctionedTupleToUserset_TuplesetValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = FunctionedTupleToUserset_TuplesetValidationError{} + +var _FunctionedTupleToUserset_Tupleset_Relation_Pattern = regexp.MustCompile("^[a-z][a-z0-9_]{1,62}[a-z0-9]$") + +// Validate checks the field values on SubjectFilter_RelationFilter with the +// rules defined in the proto definition for this message. If any rules are +// violated, the first error encountered is returned, or nil if there are no violations. +func (m *SubjectFilter_RelationFilter) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on SubjectFilter_RelationFilter with the +// rules defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// SubjectFilter_RelationFilterMultiError, or nil if none found. +func (m *SubjectFilter_RelationFilter) ValidateAll() error { + return m.validate(true) +} + +func (m *SubjectFilter_RelationFilter) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if len(m.GetRelation()) > 64 { + err := SubjectFilter_RelationFilterValidationError{ + field: "Relation", + reason: "value length must be at most 64 bytes", + } + if !all { + return err + } + errors = append(errors, err) + } + + if !_SubjectFilter_RelationFilter_Relation_Pattern.MatchString(m.GetRelation()) { + err := SubjectFilter_RelationFilterValidationError{ + field: "Relation", + reason: "value does not match regex pattern \"^([a-z][a-z0-9_]{1,62}[a-z0-9])?$\"", + } + if !all { + return err + } + errors = append(errors, err) + } + + if len(errors) > 0 { + return SubjectFilter_RelationFilterMultiError(errors) + } + + return nil +} + +// SubjectFilter_RelationFilterMultiError is an error wrapping multiple +// validation errors returned by SubjectFilter_RelationFilter.ValidateAll() if +// the designated constraints aren't met. +type SubjectFilter_RelationFilterMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m SubjectFilter_RelationFilterMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m SubjectFilter_RelationFilterMultiError) AllErrors() []error { return m } + +// SubjectFilter_RelationFilterValidationError is the validation error returned +// by SubjectFilter_RelationFilter.Validate if the designated constraints +// aren't met. +type SubjectFilter_RelationFilterValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e SubjectFilter_RelationFilterValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e SubjectFilter_RelationFilterValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e SubjectFilter_RelationFilterValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e SubjectFilter_RelationFilterValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e SubjectFilter_RelationFilterValidationError) ErrorName() string { + return "SubjectFilter_RelationFilterValidationError" +} + +// Error satisfies the builtin error interface +func (e SubjectFilter_RelationFilterValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sSubjectFilter_RelationFilter.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = SubjectFilter_RelationFilterValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = SubjectFilter_RelationFilterValidationError{} + +var _SubjectFilter_RelationFilter_Relation_Pattern = regexp.MustCompile("^([a-z][a-z0-9_]{1,62}[a-z0-9])?$") diff --git a/vendor/github.com/authzed/spicedb/pkg/proto/core/v1/core_vtproto.pb.go b/vendor/github.com/authzed/spicedb/pkg/proto/core/v1/core_vtproto.pb.go new file mode 100644 index 0000000..160a1d9 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/proto/core/v1/core_vtproto.pb.go @@ -0,0 +1,11928 @@ +// Code generated by protoc-gen-go-vtproto. DO NOT EDIT. +// protoc-gen-go-vtproto version: v0.6.1-0.20240409071808-615f978279ca +// source: core/v1/core.proto + +package corev1 + +import ( + fmt "fmt" + protohelpers "github.com/planetscale/vtprotobuf/protohelpers" + anypb1 "github.com/planetscale/vtprotobuf/types/known/anypb" + structpb1 "github.com/planetscale/vtprotobuf/types/known/structpb" + timestamppb1 "github.com/planetscale/vtprotobuf/types/known/timestamppb" + proto "google.golang.org/protobuf/proto" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + anypb "google.golang.org/protobuf/types/known/anypb" + structpb "google.golang.org/protobuf/types/known/structpb" + timestamppb "google.golang.org/protobuf/types/known/timestamppb" + io "io" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +func (m *RelationTuple) CloneVT() *RelationTuple { + if m == nil { + return (*RelationTuple)(nil) + } + r := new(RelationTuple) + r.ResourceAndRelation = m.ResourceAndRelation.CloneVT() + r.Subject = m.Subject.CloneVT() + r.Caveat = m.Caveat.CloneVT() + r.Integrity = m.Integrity.CloneVT() + r.OptionalExpirationTime = (*timestamppb.Timestamp)((*timestamppb1.Timestamp)(m.OptionalExpirationTime).CloneVT()) + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *RelationTuple) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *RelationshipIntegrity) CloneVT() *RelationshipIntegrity { + if m == nil { + return (*RelationshipIntegrity)(nil) + } + r := new(RelationshipIntegrity) + r.KeyId = m.KeyId + r.HashedAt = (*timestamppb.Timestamp)((*timestamppb1.Timestamp)(m.HashedAt).CloneVT()) + if rhs := m.Hash; rhs != nil { + tmpBytes := make([]byte, len(rhs)) + copy(tmpBytes, rhs) + r.Hash = tmpBytes + } + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *RelationshipIntegrity) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *ContextualizedCaveat) CloneVT() *ContextualizedCaveat { + if m == nil { + return (*ContextualizedCaveat)(nil) + } + r := new(ContextualizedCaveat) + r.CaveatName = m.CaveatName + r.Context = (*structpb.Struct)((*structpb1.Struct)(m.Context).CloneVT()) + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *ContextualizedCaveat) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *CaveatDefinition) CloneVT() *CaveatDefinition { + if m == nil { + return (*CaveatDefinition)(nil) + } + r := new(CaveatDefinition) + r.Name = m.Name + r.Metadata = m.Metadata.CloneVT() + r.SourcePosition = m.SourcePosition.CloneVT() + if rhs := m.SerializedExpression; rhs != nil { + tmpBytes := make([]byte, len(rhs)) + copy(tmpBytes, rhs) + r.SerializedExpression = tmpBytes + } + if rhs := m.ParameterTypes; rhs != nil { + tmpContainer := make(map[string]*CaveatTypeReference, len(rhs)) + for k, v := range rhs { + tmpContainer[k] = v.CloneVT() + } + r.ParameterTypes = tmpContainer + } + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *CaveatDefinition) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *CaveatTypeReference) CloneVT() *CaveatTypeReference { + if m == nil { + return (*CaveatTypeReference)(nil) + } + r := new(CaveatTypeReference) + r.TypeName = m.TypeName + if rhs := m.ChildTypes; rhs != nil { + tmpContainer := make([]*CaveatTypeReference, len(rhs)) + for k, v := range rhs { + tmpContainer[k] = v.CloneVT() + } + r.ChildTypes = tmpContainer + } + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *CaveatTypeReference) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *ObjectAndRelation) CloneVT() *ObjectAndRelation { + if m == nil { + return (*ObjectAndRelation)(nil) + } + r := new(ObjectAndRelation) + r.Namespace = m.Namespace + r.ObjectId = m.ObjectId + r.Relation = m.Relation + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *ObjectAndRelation) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *RelationReference) CloneVT() *RelationReference { + if m == nil { + return (*RelationReference)(nil) + } + r := new(RelationReference) + r.Namespace = m.Namespace + r.Relation = m.Relation + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *RelationReference) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *Zookie) CloneVT() *Zookie { + if m == nil { + return (*Zookie)(nil) + } + r := new(Zookie) + r.Token = m.Token + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *Zookie) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *RelationTupleUpdate) CloneVT() *RelationTupleUpdate { + if m == nil { + return (*RelationTupleUpdate)(nil) + } + r := new(RelationTupleUpdate) + r.Operation = m.Operation + r.Tuple = m.Tuple.CloneVT() + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *RelationTupleUpdate) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *RelationTupleTreeNode) CloneVT() *RelationTupleTreeNode { + if m == nil { + return (*RelationTupleTreeNode)(nil) + } + r := new(RelationTupleTreeNode) + r.Expanded = m.Expanded.CloneVT() + r.CaveatExpression = m.CaveatExpression.CloneVT() + if m.NodeType != nil { + r.NodeType = m.NodeType.(interface { + CloneVT() isRelationTupleTreeNode_NodeType + }).CloneVT() + } + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *RelationTupleTreeNode) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *RelationTupleTreeNode_IntermediateNode) CloneVT() isRelationTupleTreeNode_NodeType { + if m == nil { + return (*RelationTupleTreeNode_IntermediateNode)(nil) + } + r := new(RelationTupleTreeNode_IntermediateNode) + r.IntermediateNode = m.IntermediateNode.CloneVT() + return r +} + +func (m *RelationTupleTreeNode_LeafNode) CloneVT() isRelationTupleTreeNode_NodeType { + if m == nil { + return (*RelationTupleTreeNode_LeafNode)(nil) + } + r := new(RelationTupleTreeNode_LeafNode) + r.LeafNode = m.LeafNode.CloneVT() + return r +} + +func (m *SetOperationUserset) CloneVT() *SetOperationUserset { + if m == nil { + return (*SetOperationUserset)(nil) + } + r := new(SetOperationUserset) + r.Operation = m.Operation + if rhs := m.ChildNodes; rhs != nil { + tmpContainer := make([]*RelationTupleTreeNode, len(rhs)) + for k, v := range rhs { + tmpContainer[k] = v.CloneVT() + } + r.ChildNodes = tmpContainer + } + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *SetOperationUserset) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *DirectSubject) CloneVT() *DirectSubject { + if m == nil { + return (*DirectSubject)(nil) + } + r := new(DirectSubject) + r.Subject = m.Subject.CloneVT() + r.CaveatExpression = m.CaveatExpression.CloneVT() + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *DirectSubject) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *DirectSubjects) CloneVT() *DirectSubjects { + if m == nil { + return (*DirectSubjects)(nil) + } + r := new(DirectSubjects) + if rhs := m.Subjects; rhs != nil { + tmpContainer := make([]*DirectSubject, len(rhs)) + for k, v := range rhs { + tmpContainer[k] = v.CloneVT() + } + r.Subjects = tmpContainer + } + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *DirectSubjects) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *Metadata) CloneVT() *Metadata { + if m == nil { + return (*Metadata)(nil) + } + r := new(Metadata) + if rhs := m.MetadataMessage; rhs != nil { + tmpContainer := make([]*anypb.Any, len(rhs)) + for k, v := range rhs { + tmpContainer[k] = (*anypb.Any)((*anypb1.Any)(v).CloneVT()) + } + r.MetadataMessage = tmpContainer + } + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *Metadata) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *NamespaceDefinition) CloneVT() *NamespaceDefinition { + if m == nil { + return (*NamespaceDefinition)(nil) + } + r := new(NamespaceDefinition) + r.Name = m.Name + r.Metadata = m.Metadata.CloneVT() + r.SourcePosition = m.SourcePosition.CloneVT() + if rhs := m.Relation; rhs != nil { + tmpContainer := make([]*Relation, len(rhs)) + for k, v := range rhs { + tmpContainer[k] = v.CloneVT() + } + r.Relation = tmpContainer + } + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *NamespaceDefinition) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *Relation) CloneVT() *Relation { + if m == nil { + return (*Relation)(nil) + } + r := new(Relation) + r.Name = m.Name + r.UsersetRewrite = m.UsersetRewrite.CloneVT() + r.TypeInformation = m.TypeInformation.CloneVT() + r.Metadata = m.Metadata.CloneVT() + r.SourcePosition = m.SourcePosition.CloneVT() + r.AliasingRelation = m.AliasingRelation + r.CanonicalCacheKey = m.CanonicalCacheKey + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *Relation) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *ReachabilityGraph) CloneVT() *ReachabilityGraph { + if m == nil { + return (*ReachabilityGraph)(nil) + } + r := new(ReachabilityGraph) + if rhs := m.EntrypointsBySubjectType; rhs != nil { + tmpContainer := make(map[string]*ReachabilityEntrypoints, len(rhs)) + for k, v := range rhs { + tmpContainer[k] = v.CloneVT() + } + r.EntrypointsBySubjectType = tmpContainer + } + if rhs := m.EntrypointsBySubjectRelation; rhs != nil { + tmpContainer := make(map[string]*ReachabilityEntrypoints, len(rhs)) + for k, v := range rhs { + tmpContainer[k] = v.CloneVT() + } + r.EntrypointsBySubjectRelation = tmpContainer + } + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *ReachabilityGraph) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *ReachabilityEntrypoints) CloneVT() *ReachabilityEntrypoints { + if m == nil { + return (*ReachabilityEntrypoints)(nil) + } + r := new(ReachabilityEntrypoints) + r.SubjectType = m.SubjectType + r.SubjectRelation = m.SubjectRelation.CloneVT() + if rhs := m.Entrypoints; rhs != nil { + tmpContainer := make([]*ReachabilityEntrypoint, len(rhs)) + for k, v := range rhs { + tmpContainer[k] = v.CloneVT() + } + r.Entrypoints = tmpContainer + } + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *ReachabilityEntrypoints) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *ReachabilityEntrypoint) CloneVT() *ReachabilityEntrypoint { + if m == nil { + return (*ReachabilityEntrypoint)(nil) + } + r := new(ReachabilityEntrypoint) + r.Kind = m.Kind + r.TargetRelation = m.TargetRelation.CloneVT() + r.ResultStatus = m.ResultStatus + r.TuplesetRelation = m.TuplesetRelation + r.ComputedUsersetRelation = m.ComputedUsersetRelation + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *ReachabilityEntrypoint) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *TypeInformation) CloneVT() *TypeInformation { + if m == nil { + return (*TypeInformation)(nil) + } + r := new(TypeInformation) + if rhs := m.AllowedDirectRelations; rhs != nil { + tmpContainer := make([]*AllowedRelation, len(rhs)) + for k, v := range rhs { + tmpContainer[k] = v.CloneVT() + } + r.AllowedDirectRelations = tmpContainer + } + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *TypeInformation) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *AllowedRelation_PublicWildcard) CloneVT() *AllowedRelation_PublicWildcard { + if m == nil { + return (*AllowedRelation_PublicWildcard)(nil) + } + r := new(AllowedRelation_PublicWildcard) + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *AllowedRelation_PublicWildcard) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *AllowedRelation) CloneVT() *AllowedRelation { + if m == nil { + return (*AllowedRelation)(nil) + } + r := new(AllowedRelation) + r.Namespace = m.Namespace + r.SourcePosition = m.SourcePosition.CloneVT() + r.RequiredCaveat = m.RequiredCaveat.CloneVT() + r.RequiredExpiration = m.RequiredExpiration.CloneVT() + if m.RelationOrWildcard != nil { + r.RelationOrWildcard = m.RelationOrWildcard.(interface { + CloneVT() isAllowedRelation_RelationOrWildcard + }).CloneVT() + } + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *AllowedRelation) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *AllowedRelation_Relation) CloneVT() isAllowedRelation_RelationOrWildcard { + if m == nil { + return (*AllowedRelation_Relation)(nil) + } + r := new(AllowedRelation_Relation) + r.Relation = m.Relation + return r +} + +func (m *AllowedRelation_PublicWildcard_) CloneVT() isAllowedRelation_RelationOrWildcard { + if m == nil { + return (*AllowedRelation_PublicWildcard_)(nil) + } + r := new(AllowedRelation_PublicWildcard_) + r.PublicWildcard = m.PublicWildcard.CloneVT() + return r +} + +func (m *ExpirationTrait) CloneVT() *ExpirationTrait { + if m == nil { + return (*ExpirationTrait)(nil) + } + r := new(ExpirationTrait) + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *ExpirationTrait) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *AllowedCaveat) CloneVT() *AllowedCaveat { + if m == nil { + return (*AllowedCaveat)(nil) + } + r := new(AllowedCaveat) + r.CaveatName = m.CaveatName + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *AllowedCaveat) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *UsersetRewrite) CloneVT() *UsersetRewrite { + if m == nil { + return (*UsersetRewrite)(nil) + } + r := new(UsersetRewrite) + r.SourcePosition = m.SourcePosition.CloneVT() + if m.RewriteOperation != nil { + r.RewriteOperation = m.RewriteOperation.(interface { + CloneVT() isUsersetRewrite_RewriteOperation + }).CloneVT() + } + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *UsersetRewrite) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *UsersetRewrite_Union) CloneVT() isUsersetRewrite_RewriteOperation { + if m == nil { + return (*UsersetRewrite_Union)(nil) + } + r := new(UsersetRewrite_Union) + r.Union = m.Union.CloneVT() + return r +} + +func (m *UsersetRewrite_Intersection) CloneVT() isUsersetRewrite_RewriteOperation { + if m == nil { + return (*UsersetRewrite_Intersection)(nil) + } + r := new(UsersetRewrite_Intersection) + r.Intersection = m.Intersection.CloneVT() + return r +} + +func (m *UsersetRewrite_Exclusion) CloneVT() isUsersetRewrite_RewriteOperation { + if m == nil { + return (*UsersetRewrite_Exclusion)(nil) + } + r := new(UsersetRewrite_Exclusion) + r.Exclusion = m.Exclusion.CloneVT() + return r +} + +func (m *SetOperation_Child_This) CloneVT() *SetOperation_Child_This { + if m == nil { + return (*SetOperation_Child_This)(nil) + } + r := new(SetOperation_Child_This) + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *SetOperation_Child_This) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *SetOperation_Child_Nil) CloneVT() *SetOperation_Child_Nil { + if m == nil { + return (*SetOperation_Child_Nil)(nil) + } + r := new(SetOperation_Child_Nil) + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *SetOperation_Child_Nil) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *SetOperation_Child) CloneVT() *SetOperation_Child { + if m == nil { + return (*SetOperation_Child)(nil) + } + r := new(SetOperation_Child) + r.SourcePosition = m.SourcePosition.CloneVT() + if m.ChildType != nil { + r.ChildType = m.ChildType.(interface { + CloneVT() isSetOperation_Child_ChildType + }).CloneVT() + } + if rhs := m.OperationPath; rhs != nil { + tmpContainer := make([]uint32, len(rhs)) + copy(tmpContainer, rhs) + r.OperationPath = tmpContainer + } + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *SetOperation_Child) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *SetOperation_Child_XThis) CloneVT() isSetOperation_Child_ChildType { + if m == nil { + return (*SetOperation_Child_XThis)(nil) + } + r := new(SetOperation_Child_XThis) + r.XThis = m.XThis.CloneVT() + return r +} + +func (m *SetOperation_Child_ComputedUserset) CloneVT() isSetOperation_Child_ChildType { + if m == nil { + return (*SetOperation_Child_ComputedUserset)(nil) + } + r := new(SetOperation_Child_ComputedUserset) + r.ComputedUserset = m.ComputedUserset.CloneVT() + return r +} + +func (m *SetOperation_Child_TupleToUserset) CloneVT() isSetOperation_Child_ChildType { + if m == nil { + return (*SetOperation_Child_TupleToUserset)(nil) + } + r := new(SetOperation_Child_TupleToUserset) + r.TupleToUserset = m.TupleToUserset.CloneVT() + return r +} + +func (m *SetOperation_Child_UsersetRewrite) CloneVT() isSetOperation_Child_ChildType { + if m == nil { + return (*SetOperation_Child_UsersetRewrite)(nil) + } + r := new(SetOperation_Child_UsersetRewrite) + r.UsersetRewrite = m.UsersetRewrite.CloneVT() + return r +} + +func (m *SetOperation_Child_FunctionedTupleToUserset) CloneVT() isSetOperation_Child_ChildType { + if m == nil { + return (*SetOperation_Child_FunctionedTupleToUserset)(nil) + } + r := new(SetOperation_Child_FunctionedTupleToUserset) + r.FunctionedTupleToUserset = m.FunctionedTupleToUserset.CloneVT() + return r +} + +func (m *SetOperation_Child_XNil) CloneVT() isSetOperation_Child_ChildType { + if m == nil { + return (*SetOperation_Child_XNil)(nil) + } + r := new(SetOperation_Child_XNil) + r.XNil = m.XNil.CloneVT() + return r +} + +func (m *SetOperation) CloneVT() *SetOperation { + if m == nil { + return (*SetOperation)(nil) + } + r := new(SetOperation) + if rhs := m.Child; rhs != nil { + tmpContainer := make([]*SetOperation_Child, len(rhs)) + for k, v := range rhs { + tmpContainer[k] = v.CloneVT() + } + r.Child = tmpContainer + } + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *SetOperation) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *TupleToUserset_Tupleset) CloneVT() *TupleToUserset_Tupleset { + if m == nil { + return (*TupleToUserset_Tupleset)(nil) + } + r := new(TupleToUserset_Tupleset) + r.Relation = m.Relation + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *TupleToUserset_Tupleset) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *TupleToUserset) CloneVT() *TupleToUserset { + if m == nil { + return (*TupleToUserset)(nil) + } + r := new(TupleToUserset) + r.Tupleset = m.Tupleset.CloneVT() + r.ComputedUserset = m.ComputedUserset.CloneVT() + r.SourcePosition = m.SourcePosition.CloneVT() + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *TupleToUserset) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *FunctionedTupleToUserset_Tupleset) CloneVT() *FunctionedTupleToUserset_Tupleset { + if m == nil { + return (*FunctionedTupleToUserset_Tupleset)(nil) + } + r := new(FunctionedTupleToUserset_Tupleset) + r.Relation = m.Relation + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *FunctionedTupleToUserset_Tupleset) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *FunctionedTupleToUserset) CloneVT() *FunctionedTupleToUserset { + if m == nil { + return (*FunctionedTupleToUserset)(nil) + } + r := new(FunctionedTupleToUserset) + r.Function = m.Function + r.Tupleset = m.Tupleset.CloneVT() + r.ComputedUserset = m.ComputedUserset.CloneVT() + r.SourcePosition = m.SourcePosition.CloneVT() + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *FunctionedTupleToUserset) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *ComputedUserset) CloneVT() *ComputedUserset { + if m == nil { + return (*ComputedUserset)(nil) + } + r := new(ComputedUserset) + r.Object = m.Object + r.Relation = m.Relation + r.SourcePosition = m.SourcePosition.CloneVT() + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *ComputedUserset) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *SourcePosition) CloneVT() *SourcePosition { + if m == nil { + return (*SourcePosition)(nil) + } + r := new(SourcePosition) + r.ZeroIndexedLineNumber = m.ZeroIndexedLineNumber + r.ZeroIndexedColumnPosition = m.ZeroIndexedColumnPosition + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *SourcePosition) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *CaveatExpression) CloneVT() *CaveatExpression { + if m == nil { + return (*CaveatExpression)(nil) + } + r := new(CaveatExpression) + if m.OperationOrCaveat != nil { + r.OperationOrCaveat = m.OperationOrCaveat.(interface { + CloneVT() isCaveatExpression_OperationOrCaveat + }).CloneVT() + } + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *CaveatExpression) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *CaveatExpression_Operation) CloneVT() isCaveatExpression_OperationOrCaveat { + if m == nil { + return (*CaveatExpression_Operation)(nil) + } + r := new(CaveatExpression_Operation) + r.Operation = m.Operation.CloneVT() + return r +} + +func (m *CaveatExpression_Caveat) CloneVT() isCaveatExpression_OperationOrCaveat { + if m == nil { + return (*CaveatExpression_Caveat)(nil) + } + r := new(CaveatExpression_Caveat) + r.Caveat = m.Caveat.CloneVT() + return r +} + +func (m *CaveatOperation) CloneVT() *CaveatOperation { + if m == nil { + return (*CaveatOperation)(nil) + } + r := new(CaveatOperation) + r.Op = m.Op + if rhs := m.Children; rhs != nil { + tmpContainer := make([]*CaveatExpression, len(rhs)) + for k, v := range rhs { + tmpContainer[k] = v.CloneVT() + } + r.Children = tmpContainer + } + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *CaveatOperation) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *RelationshipFilter) CloneVT() *RelationshipFilter { + if m == nil { + return (*RelationshipFilter)(nil) + } + r := new(RelationshipFilter) + r.ResourceType = m.ResourceType + r.OptionalResourceId = m.OptionalResourceId + r.OptionalResourceIdPrefix = m.OptionalResourceIdPrefix + r.OptionalRelation = m.OptionalRelation + r.OptionalSubjectFilter = m.OptionalSubjectFilter.CloneVT() + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *RelationshipFilter) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *SubjectFilter_RelationFilter) CloneVT() *SubjectFilter_RelationFilter { + if m == nil { + return (*SubjectFilter_RelationFilter)(nil) + } + r := new(SubjectFilter_RelationFilter) + r.Relation = m.Relation + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *SubjectFilter_RelationFilter) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *SubjectFilter) CloneVT() *SubjectFilter { + if m == nil { + return (*SubjectFilter)(nil) + } + r := new(SubjectFilter) + r.SubjectType = m.SubjectType + r.OptionalSubjectId = m.OptionalSubjectId + r.OptionalRelation = m.OptionalRelation.CloneVT() + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *SubjectFilter) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (this *RelationTuple) EqualVT(that *RelationTuple) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if !this.ResourceAndRelation.EqualVT(that.ResourceAndRelation) { + return false + } + if !this.Subject.EqualVT(that.Subject) { + return false + } + if !this.Caveat.EqualVT(that.Caveat) { + return false + } + if !this.Integrity.EqualVT(that.Integrity) { + return false + } + if !(*timestamppb1.Timestamp)(this.OptionalExpirationTime).EqualVT((*timestamppb1.Timestamp)(that.OptionalExpirationTime)) { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *RelationTuple) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*RelationTuple) + if !ok { + return false + } + return this.EqualVT(that) +} +func (this *RelationshipIntegrity) EqualVT(that *RelationshipIntegrity) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if this.KeyId != that.KeyId { + return false + } + if string(this.Hash) != string(that.Hash) { + return false + } + if !(*timestamppb1.Timestamp)(this.HashedAt).EqualVT((*timestamppb1.Timestamp)(that.HashedAt)) { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *RelationshipIntegrity) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*RelationshipIntegrity) + if !ok { + return false + } + return this.EqualVT(that) +} +func (this *ContextualizedCaveat) EqualVT(that *ContextualizedCaveat) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if this.CaveatName != that.CaveatName { + return false + } + if !(*structpb1.Struct)(this.Context).EqualVT((*structpb1.Struct)(that.Context)) { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *ContextualizedCaveat) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*ContextualizedCaveat) + if !ok { + return false + } + return this.EqualVT(that) +} +func (this *CaveatDefinition) EqualVT(that *CaveatDefinition) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if this.Name != that.Name { + return false + } + if string(this.SerializedExpression) != string(that.SerializedExpression) { + return false + } + if len(this.ParameterTypes) != len(that.ParameterTypes) { + return false + } + for i, vx := range this.ParameterTypes { + vy, ok := that.ParameterTypes[i] + if !ok { + return false + } + if p, q := vx, vy; p != q { + if p == nil { + p = &CaveatTypeReference{} + } + if q == nil { + q = &CaveatTypeReference{} + } + if !p.EqualVT(q) { + return false + } + } + } + if !this.Metadata.EqualVT(that.Metadata) { + return false + } + if !this.SourcePosition.EqualVT(that.SourcePosition) { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *CaveatDefinition) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*CaveatDefinition) + if !ok { + return false + } + return this.EqualVT(that) +} +func (this *CaveatTypeReference) EqualVT(that *CaveatTypeReference) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if this.TypeName != that.TypeName { + return false + } + if len(this.ChildTypes) != len(that.ChildTypes) { + return false + } + for i, vx := range this.ChildTypes { + vy := that.ChildTypes[i] + if p, q := vx, vy; p != q { + if p == nil { + p = &CaveatTypeReference{} + } + if q == nil { + q = &CaveatTypeReference{} + } + if !p.EqualVT(q) { + return false + } + } + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *CaveatTypeReference) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*CaveatTypeReference) + if !ok { + return false + } + return this.EqualVT(that) +} +func (this *ObjectAndRelation) EqualVT(that *ObjectAndRelation) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if this.Namespace != that.Namespace { + return false + } + if this.ObjectId != that.ObjectId { + return false + } + if this.Relation != that.Relation { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *ObjectAndRelation) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*ObjectAndRelation) + if !ok { + return false + } + return this.EqualVT(that) +} +func (this *RelationReference) EqualVT(that *RelationReference) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if this.Namespace != that.Namespace { + return false + } + if this.Relation != that.Relation { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *RelationReference) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*RelationReference) + if !ok { + return false + } + return this.EqualVT(that) +} +func (this *Zookie) EqualVT(that *Zookie) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if this.Token != that.Token { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *Zookie) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*Zookie) + if !ok { + return false + } + return this.EqualVT(that) +} +func (this *RelationTupleUpdate) EqualVT(that *RelationTupleUpdate) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if this.Operation != that.Operation { + return false + } + if !this.Tuple.EqualVT(that.Tuple) { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *RelationTupleUpdate) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*RelationTupleUpdate) + if !ok { + return false + } + return this.EqualVT(that) +} +func (this *RelationTupleTreeNode) EqualVT(that *RelationTupleTreeNode) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if this.NodeType == nil && that.NodeType != nil { + return false + } else if this.NodeType != nil { + if that.NodeType == nil { + return false + } + if !this.NodeType.(interface { + EqualVT(isRelationTupleTreeNode_NodeType) bool + }).EqualVT(that.NodeType) { + return false + } + } + if !this.Expanded.EqualVT(that.Expanded) { + return false + } + if !this.CaveatExpression.EqualVT(that.CaveatExpression) { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *RelationTupleTreeNode) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*RelationTupleTreeNode) + if !ok { + return false + } + return this.EqualVT(that) +} +func (this *RelationTupleTreeNode_IntermediateNode) EqualVT(thatIface isRelationTupleTreeNode_NodeType) bool { + that, ok := thatIface.(*RelationTupleTreeNode_IntermediateNode) + if !ok { + return false + } + if this == that { + return true + } + if this == nil && that != nil || this != nil && that == nil { + return false + } + if p, q := this.IntermediateNode, that.IntermediateNode; p != q { + if p == nil { + p = &SetOperationUserset{} + } + if q == nil { + q = &SetOperationUserset{} + } + if !p.EqualVT(q) { + return false + } + } + return true +} + +func (this *RelationTupleTreeNode_LeafNode) EqualVT(thatIface isRelationTupleTreeNode_NodeType) bool { + that, ok := thatIface.(*RelationTupleTreeNode_LeafNode) + if !ok { + return false + } + if this == that { + return true + } + if this == nil && that != nil || this != nil && that == nil { + return false + } + if p, q := this.LeafNode, that.LeafNode; p != q { + if p == nil { + p = &DirectSubjects{} + } + if q == nil { + q = &DirectSubjects{} + } + if !p.EqualVT(q) { + return false + } + } + return true +} + +func (this *SetOperationUserset) EqualVT(that *SetOperationUserset) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if this.Operation != that.Operation { + return false + } + if len(this.ChildNodes) != len(that.ChildNodes) { + return false + } + for i, vx := range this.ChildNodes { + vy := that.ChildNodes[i] + if p, q := vx, vy; p != q { + if p == nil { + p = &RelationTupleTreeNode{} + } + if q == nil { + q = &RelationTupleTreeNode{} + } + if !p.EqualVT(q) { + return false + } + } + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *SetOperationUserset) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*SetOperationUserset) + if !ok { + return false + } + return this.EqualVT(that) +} +func (this *DirectSubject) EqualVT(that *DirectSubject) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if !this.Subject.EqualVT(that.Subject) { + return false + } + if !this.CaveatExpression.EqualVT(that.CaveatExpression) { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *DirectSubject) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*DirectSubject) + if !ok { + return false + } + return this.EqualVT(that) +} +func (this *DirectSubjects) EqualVT(that *DirectSubjects) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if len(this.Subjects) != len(that.Subjects) { + return false + } + for i, vx := range this.Subjects { + vy := that.Subjects[i] + if p, q := vx, vy; p != q { + if p == nil { + p = &DirectSubject{} + } + if q == nil { + q = &DirectSubject{} + } + if !p.EqualVT(q) { + return false + } + } + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *DirectSubjects) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*DirectSubjects) + if !ok { + return false + } + return this.EqualVT(that) +} +func (this *Metadata) EqualVT(that *Metadata) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if len(this.MetadataMessage) != len(that.MetadataMessage) { + return false + } + for i, vx := range this.MetadataMessage { + vy := that.MetadataMessage[i] + if p, q := vx, vy; p != q { + if p == nil { + p = &anypb.Any{} + } + if q == nil { + q = &anypb.Any{} + } + if !(*anypb1.Any)(p).EqualVT((*anypb1.Any)(q)) { + return false + } + } + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *Metadata) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*Metadata) + if !ok { + return false + } + return this.EqualVT(that) +} +func (this *NamespaceDefinition) EqualVT(that *NamespaceDefinition) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if this.Name != that.Name { + return false + } + if len(this.Relation) != len(that.Relation) { + return false + } + for i, vx := range this.Relation { + vy := that.Relation[i] + if p, q := vx, vy; p != q { + if p == nil { + p = &Relation{} + } + if q == nil { + q = &Relation{} + } + if !p.EqualVT(q) { + return false + } + } + } + if !this.Metadata.EqualVT(that.Metadata) { + return false + } + if !this.SourcePosition.EqualVT(that.SourcePosition) { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *NamespaceDefinition) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*NamespaceDefinition) + if !ok { + return false + } + return this.EqualVT(that) +} +func (this *Relation) EqualVT(that *Relation) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if this.Name != that.Name { + return false + } + if !this.UsersetRewrite.EqualVT(that.UsersetRewrite) { + return false + } + if !this.TypeInformation.EqualVT(that.TypeInformation) { + return false + } + if !this.Metadata.EqualVT(that.Metadata) { + return false + } + if !this.SourcePosition.EqualVT(that.SourcePosition) { + return false + } + if this.AliasingRelation != that.AliasingRelation { + return false + } + if this.CanonicalCacheKey != that.CanonicalCacheKey { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *Relation) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*Relation) + if !ok { + return false + } + return this.EqualVT(that) +} +func (this *ReachabilityGraph) EqualVT(that *ReachabilityGraph) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if len(this.EntrypointsBySubjectType) != len(that.EntrypointsBySubjectType) { + return false + } + for i, vx := range this.EntrypointsBySubjectType { + vy, ok := that.EntrypointsBySubjectType[i] + if !ok { + return false + } + if p, q := vx, vy; p != q { + if p == nil { + p = &ReachabilityEntrypoints{} + } + if q == nil { + q = &ReachabilityEntrypoints{} + } + if !p.EqualVT(q) { + return false + } + } + } + if len(this.EntrypointsBySubjectRelation) != len(that.EntrypointsBySubjectRelation) { + return false + } + for i, vx := range this.EntrypointsBySubjectRelation { + vy, ok := that.EntrypointsBySubjectRelation[i] + if !ok { + return false + } + if p, q := vx, vy; p != q { + if p == nil { + p = &ReachabilityEntrypoints{} + } + if q == nil { + q = &ReachabilityEntrypoints{} + } + if !p.EqualVT(q) { + return false + } + } + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *ReachabilityGraph) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*ReachabilityGraph) + if !ok { + return false + } + return this.EqualVT(that) +} +func (this *ReachabilityEntrypoints) EqualVT(that *ReachabilityEntrypoints) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if len(this.Entrypoints) != len(that.Entrypoints) { + return false + } + for i, vx := range this.Entrypoints { + vy := that.Entrypoints[i] + if p, q := vx, vy; p != q { + if p == nil { + p = &ReachabilityEntrypoint{} + } + if q == nil { + q = &ReachabilityEntrypoint{} + } + if !p.EqualVT(q) { + return false + } + } + } + if this.SubjectType != that.SubjectType { + return false + } + if !this.SubjectRelation.EqualVT(that.SubjectRelation) { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *ReachabilityEntrypoints) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*ReachabilityEntrypoints) + if !ok { + return false + } + return this.EqualVT(that) +} +func (this *ReachabilityEntrypoint) EqualVT(that *ReachabilityEntrypoint) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if this.Kind != that.Kind { + return false + } + if !this.TargetRelation.EqualVT(that.TargetRelation) { + return false + } + if this.ResultStatus != that.ResultStatus { + return false + } + if this.TuplesetRelation != that.TuplesetRelation { + return false + } + if this.ComputedUsersetRelation != that.ComputedUsersetRelation { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *ReachabilityEntrypoint) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*ReachabilityEntrypoint) + if !ok { + return false + } + return this.EqualVT(that) +} +func (this *TypeInformation) EqualVT(that *TypeInformation) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if len(this.AllowedDirectRelations) != len(that.AllowedDirectRelations) { + return false + } + for i, vx := range this.AllowedDirectRelations { + vy := that.AllowedDirectRelations[i] + if p, q := vx, vy; p != q { + if p == nil { + p = &AllowedRelation{} + } + if q == nil { + q = &AllowedRelation{} + } + if !p.EqualVT(q) { + return false + } + } + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *TypeInformation) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*TypeInformation) + if !ok { + return false + } + return this.EqualVT(that) +} +func (this *AllowedRelation_PublicWildcard) EqualVT(that *AllowedRelation_PublicWildcard) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *AllowedRelation_PublicWildcard) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*AllowedRelation_PublicWildcard) + if !ok { + return false + } + return this.EqualVT(that) +} +func (this *AllowedRelation) EqualVT(that *AllowedRelation) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if this.RelationOrWildcard == nil && that.RelationOrWildcard != nil { + return false + } else if this.RelationOrWildcard != nil { + if that.RelationOrWildcard == nil { + return false + } + if !this.RelationOrWildcard.(interface { + EqualVT(isAllowedRelation_RelationOrWildcard) bool + }).EqualVT(that.RelationOrWildcard) { + return false + } + } + if this.Namespace != that.Namespace { + return false + } + if !this.SourcePosition.EqualVT(that.SourcePosition) { + return false + } + if !this.RequiredCaveat.EqualVT(that.RequiredCaveat) { + return false + } + if !this.RequiredExpiration.EqualVT(that.RequiredExpiration) { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *AllowedRelation) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*AllowedRelation) + if !ok { + return false + } + return this.EqualVT(that) +} +func (this *AllowedRelation_Relation) EqualVT(thatIface isAllowedRelation_RelationOrWildcard) bool { + that, ok := thatIface.(*AllowedRelation_Relation) + if !ok { + return false + } + if this == that { + return true + } + if this == nil && that != nil || this != nil && that == nil { + return false + } + if this.Relation != that.Relation { + return false + } + return true +} + +func (this *AllowedRelation_PublicWildcard_) EqualVT(thatIface isAllowedRelation_RelationOrWildcard) bool { + that, ok := thatIface.(*AllowedRelation_PublicWildcard_) + if !ok { + return false + } + if this == that { + return true + } + if this == nil && that != nil || this != nil && that == nil { + return false + } + if p, q := this.PublicWildcard, that.PublicWildcard; p != q { + if p == nil { + p = &AllowedRelation_PublicWildcard{} + } + if q == nil { + q = &AllowedRelation_PublicWildcard{} + } + if !p.EqualVT(q) { + return false + } + } + return true +} + +func (this *ExpirationTrait) EqualVT(that *ExpirationTrait) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *ExpirationTrait) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*ExpirationTrait) + if !ok { + return false + } + return this.EqualVT(that) +} +func (this *AllowedCaveat) EqualVT(that *AllowedCaveat) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if this.CaveatName != that.CaveatName { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *AllowedCaveat) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*AllowedCaveat) + if !ok { + return false + } + return this.EqualVT(that) +} +func (this *UsersetRewrite) EqualVT(that *UsersetRewrite) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if this.RewriteOperation == nil && that.RewriteOperation != nil { + return false + } else if this.RewriteOperation != nil { + if that.RewriteOperation == nil { + return false + } + if !this.RewriteOperation.(interface { + EqualVT(isUsersetRewrite_RewriteOperation) bool + }).EqualVT(that.RewriteOperation) { + return false + } + } + if !this.SourcePosition.EqualVT(that.SourcePosition) { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *UsersetRewrite) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*UsersetRewrite) + if !ok { + return false + } + return this.EqualVT(that) +} +func (this *UsersetRewrite_Union) EqualVT(thatIface isUsersetRewrite_RewriteOperation) bool { + that, ok := thatIface.(*UsersetRewrite_Union) + if !ok { + return false + } + if this == that { + return true + } + if this == nil && that != nil || this != nil && that == nil { + return false + } + if p, q := this.Union, that.Union; p != q { + if p == nil { + p = &SetOperation{} + } + if q == nil { + q = &SetOperation{} + } + if !p.EqualVT(q) { + return false + } + } + return true +} + +func (this *UsersetRewrite_Intersection) EqualVT(thatIface isUsersetRewrite_RewriteOperation) bool { + that, ok := thatIface.(*UsersetRewrite_Intersection) + if !ok { + return false + } + if this == that { + return true + } + if this == nil && that != nil || this != nil && that == nil { + return false + } + if p, q := this.Intersection, that.Intersection; p != q { + if p == nil { + p = &SetOperation{} + } + if q == nil { + q = &SetOperation{} + } + if !p.EqualVT(q) { + return false + } + } + return true +} + +func (this *UsersetRewrite_Exclusion) EqualVT(thatIface isUsersetRewrite_RewriteOperation) bool { + that, ok := thatIface.(*UsersetRewrite_Exclusion) + if !ok { + return false + } + if this == that { + return true + } + if this == nil && that != nil || this != nil && that == nil { + return false + } + if p, q := this.Exclusion, that.Exclusion; p != q { + if p == nil { + p = &SetOperation{} + } + if q == nil { + q = &SetOperation{} + } + if !p.EqualVT(q) { + return false + } + } + return true +} + +func (this *SetOperation_Child_This) EqualVT(that *SetOperation_Child_This) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *SetOperation_Child_This) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*SetOperation_Child_This) + if !ok { + return false + } + return this.EqualVT(that) +} +func (this *SetOperation_Child_Nil) EqualVT(that *SetOperation_Child_Nil) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *SetOperation_Child_Nil) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*SetOperation_Child_Nil) + if !ok { + return false + } + return this.EqualVT(that) +} +func (this *SetOperation_Child) EqualVT(that *SetOperation_Child) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if this.ChildType == nil && that.ChildType != nil { + return false + } else if this.ChildType != nil { + if that.ChildType == nil { + return false + } + if !this.ChildType.(interface { + EqualVT(isSetOperation_Child_ChildType) bool + }).EqualVT(that.ChildType) { + return false + } + } + if !this.SourcePosition.EqualVT(that.SourcePosition) { + return false + } + if len(this.OperationPath) != len(that.OperationPath) { + return false + } + for i, vx := range this.OperationPath { + vy := that.OperationPath[i] + if vx != vy { + return false + } + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *SetOperation_Child) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*SetOperation_Child) + if !ok { + return false + } + return this.EqualVT(that) +} +func (this *SetOperation_Child_XThis) EqualVT(thatIface isSetOperation_Child_ChildType) bool { + that, ok := thatIface.(*SetOperation_Child_XThis) + if !ok { + return false + } + if this == that { + return true + } + if this == nil && that != nil || this != nil && that == nil { + return false + } + if p, q := this.XThis, that.XThis; p != q { + if p == nil { + p = &SetOperation_Child_This{} + } + if q == nil { + q = &SetOperation_Child_This{} + } + if !p.EqualVT(q) { + return false + } + } + return true +} + +func (this *SetOperation_Child_ComputedUserset) EqualVT(thatIface isSetOperation_Child_ChildType) bool { + that, ok := thatIface.(*SetOperation_Child_ComputedUserset) + if !ok { + return false + } + if this == that { + return true + } + if this == nil && that != nil || this != nil && that == nil { + return false + } + if p, q := this.ComputedUserset, that.ComputedUserset; p != q { + if p == nil { + p = &ComputedUserset{} + } + if q == nil { + q = &ComputedUserset{} + } + if !p.EqualVT(q) { + return false + } + } + return true +} + +func (this *SetOperation_Child_TupleToUserset) EqualVT(thatIface isSetOperation_Child_ChildType) bool { + that, ok := thatIface.(*SetOperation_Child_TupleToUserset) + if !ok { + return false + } + if this == that { + return true + } + if this == nil && that != nil || this != nil && that == nil { + return false + } + if p, q := this.TupleToUserset, that.TupleToUserset; p != q { + if p == nil { + p = &TupleToUserset{} + } + if q == nil { + q = &TupleToUserset{} + } + if !p.EqualVT(q) { + return false + } + } + return true +} + +func (this *SetOperation_Child_UsersetRewrite) EqualVT(thatIface isSetOperation_Child_ChildType) bool { + that, ok := thatIface.(*SetOperation_Child_UsersetRewrite) + if !ok { + return false + } + if this == that { + return true + } + if this == nil && that != nil || this != nil && that == nil { + return false + } + if p, q := this.UsersetRewrite, that.UsersetRewrite; p != q { + if p == nil { + p = &UsersetRewrite{} + } + if q == nil { + q = &UsersetRewrite{} + } + if !p.EqualVT(q) { + return false + } + } + return true +} + +func (this *SetOperation_Child_XNil) EqualVT(thatIface isSetOperation_Child_ChildType) bool { + that, ok := thatIface.(*SetOperation_Child_XNil) + if !ok { + return false + } + if this == that { + return true + } + if this == nil && that != nil || this != nil && that == nil { + return false + } + if p, q := this.XNil, that.XNil; p != q { + if p == nil { + p = &SetOperation_Child_Nil{} + } + if q == nil { + q = &SetOperation_Child_Nil{} + } + if !p.EqualVT(q) { + return false + } + } + return true +} + +func (this *SetOperation_Child_FunctionedTupleToUserset) EqualVT(thatIface isSetOperation_Child_ChildType) bool { + that, ok := thatIface.(*SetOperation_Child_FunctionedTupleToUserset) + if !ok { + return false + } + if this == that { + return true + } + if this == nil && that != nil || this != nil && that == nil { + return false + } + if p, q := this.FunctionedTupleToUserset, that.FunctionedTupleToUserset; p != q { + if p == nil { + p = &FunctionedTupleToUserset{} + } + if q == nil { + q = &FunctionedTupleToUserset{} + } + if !p.EqualVT(q) { + return false + } + } + return true +} + +func (this *SetOperation) EqualVT(that *SetOperation) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if len(this.Child) != len(that.Child) { + return false + } + for i, vx := range this.Child { + vy := that.Child[i] + if p, q := vx, vy; p != q { + if p == nil { + p = &SetOperation_Child{} + } + if q == nil { + q = &SetOperation_Child{} + } + if !p.EqualVT(q) { + return false + } + } + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *SetOperation) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*SetOperation) + if !ok { + return false + } + return this.EqualVT(that) +} +func (this *TupleToUserset_Tupleset) EqualVT(that *TupleToUserset_Tupleset) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if this.Relation != that.Relation { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *TupleToUserset_Tupleset) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*TupleToUserset_Tupleset) + if !ok { + return false + } + return this.EqualVT(that) +} +func (this *TupleToUserset) EqualVT(that *TupleToUserset) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if !this.Tupleset.EqualVT(that.Tupleset) { + return false + } + if !this.ComputedUserset.EqualVT(that.ComputedUserset) { + return false + } + if !this.SourcePosition.EqualVT(that.SourcePosition) { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *TupleToUserset) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*TupleToUserset) + if !ok { + return false + } + return this.EqualVT(that) +} +func (this *FunctionedTupleToUserset_Tupleset) EqualVT(that *FunctionedTupleToUserset_Tupleset) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if this.Relation != that.Relation { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *FunctionedTupleToUserset_Tupleset) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*FunctionedTupleToUserset_Tupleset) + if !ok { + return false + } + return this.EqualVT(that) +} +func (this *FunctionedTupleToUserset) EqualVT(that *FunctionedTupleToUserset) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if this.Function != that.Function { + return false + } + if !this.Tupleset.EqualVT(that.Tupleset) { + return false + } + if !this.ComputedUserset.EqualVT(that.ComputedUserset) { + return false + } + if !this.SourcePosition.EqualVT(that.SourcePosition) { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *FunctionedTupleToUserset) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*FunctionedTupleToUserset) + if !ok { + return false + } + return this.EqualVT(that) +} +func (this *ComputedUserset) EqualVT(that *ComputedUserset) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if this.Object != that.Object { + return false + } + if this.Relation != that.Relation { + return false + } + if !this.SourcePosition.EqualVT(that.SourcePosition) { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *ComputedUserset) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*ComputedUserset) + if !ok { + return false + } + return this.EqualVT(that) +} +func (this *SourcePosition) EqualVT(that *SourcePosition) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if this.ZeroIndexedLineNumber != that.ZeroIndexedLineNumber { + return false + } + if this.ZeroIndexedColumnPosition != that.ZeroIndexedColumnPosition { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *SourcePosition) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*SourcePosition) + if !ok { + return false + } + return this.EqualVT(that) +} +func (this *CaveatExpression) EqualVT(that *CaveatExpression) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if this.OperationOrCaveat == nil && that.OperationOrCaveat != nil { + return false + } else if this.OperationOrCaveat != nil { + if that.OperationOrCaveat == nil { + return false + } + if !this.OperationOrCaveat.(interface { + EqualVT(isCaveatExpression_OperationOrCaveat) bool + }).EqualVT(that.OperationOrCaveat) { + return false + } + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *CaveatExpression) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*CaveatExpression) + if !ok { + return false + } + return this.EqualVT(that) +} +func (this *CaveatExpression_Operation) EqualVT(thatIface isCaveatExpression_OperationOrCaveat) bool { + that, ok := thatIface.(*CaveatExpression_Operation) + if !ok { + return false + } + if this == that { + return true + } + if this == nil && that != nil || this != nil && that == nil { + return false + } + if p, q := this.Operation, that.Operation; p != q { + if p == nil { + p = &CaveatOperation{} + } + if q == nil { + q = &CaveatOperation{} + } + if !p.EqualVT(q) { + return false + } + } + return true +} + +func (this *CaveatExpression_Caveat) EqualVT(thatIface isCaveatExpression_OperationOrCaveat) bool { + that, ok := thatIface.(*CaveatExpression_Caveat) + if !ok { + return false + } + if this == that { + return true + } + if this == nil && that != nil || this != nil && that == nil { + return false + } + if p, q := this.Caveat, that.Caveat; p != q { + if p == nil { + p = &ContextualizedCaveat{} + } + if q == nil { + q = &ContextualizedCaveat{} + } + if !p.EqualVT(q) { + return false + } + } + return true +} + +func (this *CaveatOperation) EqualVT(that *CaveatOperation) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if this.Op != that.Op { + return false + } + if len(this.Children) != len(that.Children) { + return false + } + for i, vx := range this.Children { + vy := that.Children[i] + if p, q := vx, vy; p != q { + if p == nil { + p = &CaveatExpression{} + } + if q == nil { + q = &CaveatExpression{} + } + if !p.EqualVT(q) { + return false + } + } + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *CaveatOperation) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*CaveatOperation) + if !ok { + return false + } + return this.EqualVT(that) +} +func (this *RelationshipFilter) EqualVT(that *RelationshipFilter) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if this.ResourceType != that.ResourceType { + return false + } + if this.OptionalResourceId != that.OptionalResourceId { + return false + } + if this.OptionalRelation != that.OptionalRelation { + return false + } + if !this.OptionalSubjectFilter.EqualVT(that.OptionalSubjectFilter) { + return false + } + if this.OptionalResourceIdPrefix != that.OptionalResourceIdPrefix { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *RelationshipFilter) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*RelationshipFilter) + if !ok { + return false + } + return this.EqualVT(that) +} +func (this *SubjectFilter_RelationFilter) EqualVT(that *SubjectFilter_RelationFilter) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if this.Relation != that.Relation { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *SubjectFilter_RelationFilter) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*SubjectFilter_RelationFilter) + if !ok { + return false + } + return this.EqualVT(that) +} +func (this *SubjectFilter) EqualVT(that *SubjectFilter) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if this.SubjectType != that.SubjectType { + return false + } + if this.OptionalSubjectId != that.OptionalSubjectId { + return false + } + if !this.OptionalRelation.EqualVT(that.OptionalRelation) { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *SubjectFilter) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*SubjectFilter) + if !ok { + return false + } + return this.EqualVT(that) +} +func (m *RelationTuple) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *RelationTuple) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *RelationTuple) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if m.OptionalExpirationTime != nil { + size, err := (*timestamppb1.Timestamp)(m.OptionalExpirationTime).MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x2a + } + if m.Integrity != nil { + size, err := m.Integrity.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x22 + } + if m.Caveat != nil { + size, err := m.Caveat.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x1a + } + if m.Subject != nil { + size, err := m.Subject.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x12 + } + if m.ResourceAndRelation != nil { + size, err := m.ResourceAndRelation.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *RelationshipIntegrity) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *RelationshipIntegrity) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *RelationshipIntegrity) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if m.HashedAt != nil { + size, err := (*timestamppb1.Timestamp)(m.HashedAt).MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x1a + } + if len(m.Hash) > 0 { + i -= len(m.Hash) + copy(dAtA[i:], m.Hash) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Hash))) + i-- + dAtA[i] = 0x12 + } + if len(m.KeyId) > 0 { + i -= len(m.KeyId) + copy(dAtA[i:], m.KeyId) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.KeyId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *ContextualizedCaveat) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ContextualizedCaveat) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *ContextualizedCaveat) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if m.Context != nil { + size, err := (*structpb1.Struct)(m.Context).MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x12 + } + if len(m.CaveatName) > 0 { + i -= len(m.CaveatName) + copy(dAtA[i:], m.CaveatName) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.CaveatName))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *CaveatDefinition) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *CaveatDefinition) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *CaveatDefinition) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if m.SourcePosition != nil { + size, err := m.SourcePosition.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x2a + } + if m.Metadata != nil { + size, err := m.Metadata.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x22 + } + if len(m.ParameterTypes) > 0 { + for k := range m.ParameterTypes { + v := m.ParameterTypes[k] + baseI := i + size, err := v.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x12 + i -= len(k) + copy(dAtA[i:], k) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(k))) + i-- + dAtA[i] = 0xa + i = protohelpers.EncodeVarint(dAtA, i, uint64(baseI-i)) + i-- + dAtA[i] = 0x1a + } + } + if len(m.SerializedExpression) > 0 { + i -= len(m.SerializedExpression) + copy(dAtA[i:], m.SerializedExpression) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.SerializedExpression))) + i-- + dAtA[i] = 0x12 + } + if len(m.Name) > 0 { + i -= len(m.Name) + copy(dAtA[i:], m.Name) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Name))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *CaveatTypeReference) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *CaveatTypeReference) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *CaveatTypeReference) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if len(m.ChildTypes) > 0 { + for iNdEx := len(m.ChildTypes) - 1; iNdEx >= 0; iNdEx-- { + size, err := m.ChildTypes[iNdEx].MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x12 + } + } + if len(m.TypeName) > 0 { + i -= len(m.TypeName) + copy(dAtA[i:], m.TypeName) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.TypeName))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *ObjectAndRelation) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ObjectAndRelation) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *ObjectAndRelation) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if len(m.Relation) > 0 { + i -= len(m.Relation) + copy(dAtA[i:], m.Relation) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Relation))) + i-- + dAtA[i] = 0x1a + } + if len(m.ObjectId) > 0 { + i -= len(m.ObjectId) + copy(dAtA[i:], m.ObjectId) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.ObjectId))) + i-- + dAtA[i] = 0x12 + } + if len(m.Namespace) > 0 { + i -= len(m.Namespace) + copy(dAtA[i:], m.Namespace) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Namespace))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *RelationReference) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *RelationReference) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *RelationReference) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if len(m.Relation) > 0 { + i -= len(m.Relation) + copy(dAtA[i:], m.Relation) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Relation))) + i-- + dAtA[i] = 0x1a + } + if len(m.Namespace) > 0 { + i -= len(m.Namespace) + copy(dAtA[i:], m.Namespace) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Namespace))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *Zookie) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Zookie) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *Zookie) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if len(m.Token) > 0 { + i -= len(m.Token) + copy(dAtA[i:], m.Token) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Token))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *RelationTupleUpdate) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *RelationTupleUpdate) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *RelationTupleUpdate) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if m.Tuple != nil { + size, err := m.Tuple.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x12 + } + if m.Operation != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.Operation)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *RelationTupleTreeNode) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *RelationTupleTreeNode) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *RelationTupleTreeNode) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if vtmsg, ok := m.NodeType.(interface { + MarshalToSizedBufferVT([]byte) (int, error) + }); ok { + size, err := vtmsg.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + } + if m.CaveatExpression != nil { + size, err := m.CaveatExpression.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x22 + } + if m.Expanded != nil { + size, err := m.Expanded.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x1a + } + return len(dAtA) - i, nil +} + +func (m *RelationTupleTreeNode_IntermediateNode) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *RelationTupleTreeNode_IntermediateNode) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + i := len(dAtA) + if m.IntermediateNode != nil { + size, err := m.IntermediateNode.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0xa + } else { + i = protohelpers.EncodeVarint(dAtA, i, 0) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} +func (m *RelationTupleTreeNode_LeafNode) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *RelationTupleTreeNode_LeafNode) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + i := len(dAtA) + if m.LeafNode != nil { + size, err := m.LeafNode.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x12 + } else { + i = protohelpers.EncodeVarint(dAtA, i, 0) + i-- + dAtA[i] = 0x12 + } + return len(dAtA) - i, nil +} +func (m *SetOperationUserset) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *SetOperationUserset) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *SetOperationUserset) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if len(m.ChildNodes) > 0 { + for iNdEx := len(m.ChildNodes) - 1; iNdEx >= 0; iNdEx-- { + size, err := m.ChildNodes[iNdEx].MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x12 + } + } + if m.Operation != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.Operation)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *DirectSubject) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *DirectSubject) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *DirectSubject) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if m.CaveatExpression != nil { + size, err := m.CaveatExpression.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x12 + } + if m.Subject != nil { + size, err := m.Subject.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *DirectSubjects) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *DirectSubjects) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *DirectSubjects) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if len(m.Subjects) > 0 { + for iNdEx := len(m.Subjects) - 1; iNdEx >= 0; iNdEx-- { + size, err := m.Subjects[iNdEx].MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *Metadata) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Metadata) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *Metadata) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if len(m.MetadataMessage) > 0 { + for iNdEx := len(m.MetadataMessage) - 1; iNdEx >= 0; iNdEx-- { + size, err := (*anypb1.Any)(m.MetadataMessage[iNdEx]).MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *NamespaceDefinition) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *NamespaceDefinition) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *NamespaceDefinition) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if m.SourcePosition != nil { + size, err := m.SourcePosition.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x22 + } + if m.Metadata != nil { + size, err := m.Metadata.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x1a + } + if len(m.Relation) > 0 { + for iNdEx := len(m.Relation) - 1; iNdEx >= 0; iNdEx-- { + size, err := m.Relation[iNdEx].MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x12 + } + } + if len(m.Name) > 0 { + i -= len(m.Name) + copy(dAtA[i:], m.Name) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Name))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *Relation) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Relation) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *Relation) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if len(m.CanonicalCacheKey) > 0 { + i -= len(m.CanonicalCacheKey) + copy(dAtA[i:], m.CanonicalCacheKey) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.CanonicalCacheKey))) + i-- + dAtA[i] = 0x3a + } + if len(m.AliasingRelation) > 0 { + i -= len(m.AliasingRelation) + copy(dAtA[i:], m.AliasingRelation) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.AliasingRelation))) + i-- + dAtA[i] = 0x32 + } + if m.SourcePosition != nil { + size, err := m.SourcePosition.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x2a + } + if m.Metadata != nil { + size, err := m.Metadata.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x22 + } + if m.TypeInformation != nil { + size, err := m.TypeInformation.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x1a + } + if m.UsersetRewrite != nil { + size, err := m.UsersetRewrite.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x12 + } + if len(m.Name) > 0 { + i -= len(m.Name) + copy(dAtA[i:], m.Name) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Name))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *ReachabilityGraph) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ReachabilityGraph) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *ReachabilityGraph) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if len(m.EntrypointsBySubjectRelation) > 0 { + for k := range m.EntrypointsBySubjectRelation { + v := m.EntrypointsBySubjectRelation[k] + baseI := i + size, err := v.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x12 + i -= len(k) + copy(dAtA[i:], k) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(k))) + i-- + dAtA[i] = 0xa + i = protohelpers.EncodeVarint(dAtA, i, uint64(baseI-i)) + i-- + dAtA[i] = 0x12 + } + } + if len(m.EntrypointsBySubjectType) > 0 { + for k := range m.EntrypointsBySubjectType { + v := m.EntrypointsBySubjectType[k] + baseI := i + size, err := v.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x12 + i -= len(k) + copy(dAtA[i:], k) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(k))) + i-- + dAtA[i] = 0xa + i = protohelpers.EncodeVarint(dAtA, i, uint64(baseI-i)) + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *ReachabilityEntrypoints) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ReachabilityEntrypoints) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *ReachabilityEntrypoints) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if m.SubjectRelation != nil { + size, err := m.SubjectRelation.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x1a + } + if len(m.SubjectType) > 0 { + i -= len(m.SubjectType) + copy(dAtA[i:], m.SubjectType) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.SubjectType))) + i-- + dAtA[i] = 0x12 + } + if len(m.Entrypoints) > 0 { + for iNdEx := len(m.Entrypoints) - 1; iNdEx >= 0; iNdEx-- { + size, err := m.Entrypoints[iNdEx].MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *ReachabilityEntrypoint) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ReachabilityEntrypoint) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *ReachabilityEntrypoint) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if len(m.ComputedUsersetRelation) > 0 { + i -= len(m.ComputedUsersetRelation) + copy(dAtA[i:], m.ComputedUsersetRelation) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.ComputedUsersetRelation))) + i-- + dAtA[i] = 0x32 + } + if len(m.TuplesetRelation) > 0 { + i -= len(m.TuplesetRelation) + copy(dAtA[i:], m.TuplesetRelation) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.TuplesetRelation))) + i-- + dAtA[i] = 0x2a + } + if m.ResultStatus != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.ResultStatus)) + i-- + dAtA[i] = 0x20 + } + if m.TargetRelation != nil { + size, err := m.TargetRelation.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x12 + } + if m.Kind != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.Kind)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *TypeInformation) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *TypeInformation) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *TypeInformation) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if len(m.AllowedDirectRelations) > 0 { + for iNdEx := len(m.AllowedDirectRelations) - 1; iNdEx >= 0; iNdEx-- { + size, err := m.AllowedDirectRelations[iNdEx].MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *AllowedRelation_PublicWildcard) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *AllowedRelation_PublicWildcard) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *AllowedRelation_PublicWildcard) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + return len(dAtA) - i, nil +} + +func (m *AllowedRelation) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *AllowedRelation) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *AllowedRelation) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if vtmsg, ok := m.RelationOrWildcard.(interface { + MarshalToSizedBufferVT([]byte) (int, error) + }); ok { + size, err := vtmsg.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + } + if m.RequiredExpiration != nil { + size, err := m.RequiredExpiration.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x3a + } + if m.RequiredCaveat != nil { + size, err := m.RequiredCaveat.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x32 + } + if m.SourcePosition != nil { + size, err := m.SourcePosition.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x2a + } + if len(m.Namespace) > 0 { + i -= len(m.Namespace) + copy(dAtA[i:], m.Namespace) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Namespace))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *AllowedRelation_Relation) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *AllowedRelation_Relation) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + i := len(dAtA) + i -= len(m.Relation) + copy(dAtA[i:], m.Relation) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Relation))) + i-- + dAtA[i] = 0x1a + return len(dAtA) - i, nil +} +func (m *AllowedRelation_PublicWildcard_) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *AllowedRelation_PublicWildcard_) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + i := len(dAtA) + if m.PublicWildcard != nil { + size, err := m.PublicWildcard.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x22 + } else { + i = protohelpers.EncodeVarint(dAtA, i, 0) + i-- + dAtA[i] = 0x22 + } + return len(dAtA) - i, nil +} +func (m *ExpirationTrait) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ExpirationTrait) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *ExpirationTrait) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + return len(dAtA) - i, nil +} + +func (m *AllowedCaveat) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *AllowedCaveat) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *AllowedCaveat) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if len(m.CaveatName) > 0 { + i -= len(m.CaveatName) + copy(dAtA[i:], m.CaveatName) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.CaveatName))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *UsersetRewrite) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *UsersetRewrite) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *UsersetRewrite) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if vtmsg, ok := m.RewriteOperation.(interface { + MarshalToSizedBufferVT([]byte) (int, error) + }); ok { + size, err := vtmsg.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + } + if m.SourcePosition != nil { + size, err := m.SourcePosition.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x22 + } + return len(dAtA) - i, nil +} + +func (m *UsersetRewrite_Union) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *UsersetRewrite_Union) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + i := len(dAtA) + if m.Union != nil { + size, err := m.Union.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0xa + } else { + i = protohelpers.EncodeVarint(dAtA, i, 0) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} +func (m *UsersetRewrite_Intersection) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *UsersetRewrite_Intersection) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + i := len(dAtA) + if m.Intersection != nil { + size, err := m.Intersection.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x12 + } else { + i = protohelpers.EncodeVarint(dAtA, i, 0) + i-- + dAtA[i] = 0x12 + } + return len(dAtA) - i, nil +} +func (m *UsersetRewrite_Exclusion) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *UsersetRewrite_Exclusion) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + i := len(dAtA) + if m.Exclusion != nil { + size, err := m.Exclusion.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x1a + } else { + i = protohelpers.EncodeVarint(dAtA, i, 0) + i-- + dAtA[i] = 0x1a + } + return len(dAtA) - i, nil +} +func (m *SetOperation_Child_This) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *SetOperation_Child_This) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *SetOperation_Child_This) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + return len(dAtA) - i, nil +} + +func (m *SetOperation_Child_Nil) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *SetOperation_Child_Nil) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *SetOperation_Child_Nil) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + return len(dAtA) - i, nil +} + +func (m *SetOperation_Child) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *SetOperation_Child) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *SetOperation_Child) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if vtmsg, ok := m.ChildType.(interface { + MarshalToSizedBufferVT([]byte) (int, error) + }); ok { + size, err := vtmsg.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + } + if len(m.OperationPath) > 0 { + var pksize2 int + for _, num := range m.OperationPath { + pksize2 += protohelpers.SizeOfVarint(uint64(num)) + } + i -= pksize2 + j1 := i + for _, num := range m.OperationPath { + for num >= 1<<7 { + dAtA[j1] = uint8(uint64(num)&0x7f | 0x80) + num >>= 7 + j1++ + } + dAtA[j1] = uint8(num) + j1++ + } + i = protohelpers.EncodeVarint(dAtA, i, uint64(pksize2)) + i-- + dAtA[i] = 0x3a + } + if m.SourcePosition != nil { + size, err := m.SourcePosition.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x2a + } + return len(dAtA) - i, nil +} + +func (m *SetOperation_Child_XThis) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *SetOperation_Child_XThis) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + i := len(dAtA) + if m.XThis != nil { + size, err := m.XThis.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0xa + } else { + i = protohelpers.EncodeVarint(dAtA, i, 0) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} +func (m *SetOperation_Child_ComputedUserset) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *SetOperation_Child_ComputedUserset) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + i := len(dAtA) + if m.ComputedUserset != nil { + size, err := m.ComputedUserset.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x12 + } else { + i = protohelpers.EncodeVarint(dAtA, i, 0) + i-- + dAtA[i] = 0x12 + } + return len(dAtA) - i, nil +} +func (m *SetOperation_Child_TupleToUserset) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *SetOperation_Child_TupleToUserset) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + i := len(dAtA) + if m.TupleToUserset != nil { + size, err := m.TupleToUserset.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x1a + } else { + i = protohelpers.EncodeVarint(dAtA, i, 0) + i-- + dAtA[i] = 0x1a + } + return len(dAtA) - i, nil +} +func (m *SetOperation_Child_UsersetRewrite) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *SetOperation_Child_UsersetRewrite) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + i := len(dAtA) + if m.UsersetRewrite != nil { + size, err := m.UsersetRewrite.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x22 + } else { + i = protohelpers.EncodeVarint(dAtA, i, 0) + i-- + dAtA[i] = 0x22 + } + return len(dAtA) - i, nil +} +func (m *SetOperation_Child_XNil) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *SetOperation_Child_XNil) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + i := len(dAtA) + if m.XNil != nil { + size, err := m.XNil.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x32 + } else { + i = protohelpers.EncodeVarint(dAtA, i, 0) + i-- + dAtA[i] = 0x32 + } + return len(dAtA) - i, nil +} +func (m *SetOperation_Child_FunctionedTupleToUserset) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *SetOperation_Child_FunctionedTupleToUserset) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + i := len(dAtA) + if m.FunctionedTupleToUserset != nil { + size, err := m.FunctionedTupleToUserset.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x42 + } else { + i = protohelpers.EncodeVarint(dAtA, i, 0) + i-- + dAtA[i] = 0x42 + } + return len(dAtA) - i, nil +} +func (m *SetOperation) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *SetOperation) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *SetOperation) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if len(m.Child) > 0 { + for iNdEx := len(m.Child) - 1; iNdEx >= 0; iNdEx-- { + size, err := m.Child[iNdEx].MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *TupleToUserset_Tupleset) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *TupleToUserset_Tupleset) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *TupleToUserset_Tupleset) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if len(m.Relation) > 0 { + i -= len(m.Relation) + copy(dAtA[i:], m.Relation) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Relation))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *TupleToUserset) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *TupleToUserset) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *TupleToUserset) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if m.SourcePosition != nil { + size, err := m.SourcePosition.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x1a + } + if m.ComputedUserset != nil { + size, err := m.ComputedUserset.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x12 + } + if m.Tupleset != nil { + size, err := m.Tupleset.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *FunctionedTupleToUserset_Tupleset) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *FunctionedTupleToUserset_Tupleset) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *FunctionedTupleToUserset_Tupleset) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if len(m.Relation) > 0 { + i -= len(m.Relation) + copy(dAtA[i:], m.Relation) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Relation))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *FunctionedTupleToUserset) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *FunctionedTupleToUserset) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *FunctionedTupleToUserset) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if m.SourcePosition != nil { + size, err := m.SourcePosition.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x22 + } + if m.ComputedUserset != nil { + size, err := m.ComputedUserset.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x1a + } + if m.Tupleset != nil { + size, err := m.Tupleset.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x12 + } + if m.Function != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.Function)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *ComputedUserset) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ComputedUserset) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *ComputedUserset) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if m.SourcePosition != nil { + size, err := m.SourcePosition.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x1a + } + if len(m.Relation) > 0 { + i -= len(m.Relation) + copy(dAtA[i:], m.Relation) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Relation))) + i-- + dAtA[i] = 0x12 + } + if m.Object != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.Object)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *SourcePosition) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *SourcePosition) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *SourcePosition) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if m.ZeroIndexedColumnPosition != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.ZeroIndexedColumnPosition)) + i-- + dAtA[i] = 0x10 + } + if m.ZeroIndexedLineNumber != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.ZeroIndexedLineNumber)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *CaveatExpression) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *CaveatExpression) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *CaveatExpression) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if vtmsg, ok := m.OperationOrCaveat.(interface { + MarshalToSizedBufferVT([]byte) (int, error) + }); ok { + size, err := vtmsg.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + } + return len(dAtA) - i, nil +} + +func (m *CaveatExpression_Operation) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *CaveatExpression_Operation) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + i := len(dAtA) + if m.Operation != nil { + size, err := m.Operation.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0xa + } else { + i = protohelpers.EncodeVarint(dAtA, i, 0) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} +func (m *CaveatExpression_Caveat) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *CaveatExpression_Caveat) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + i := len(dAtA) + if m.Caveat != nil { + size, err := m.Caveat.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x12 + } else { + i = protohelpers.EncodeVarint(dAtA, i, 0) + i-- + dAtA[i] = 0x12 + } + return len(dAtA) - i, nil +} +func (m *CaveatOperation) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *CaveatOperation) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *CaveatOperation) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if len(m.Children) > 0 { + for iNdEx := len(m.Children) - 1; iNdEx >= 0; iNdEx-- { + size, err := m.Children[iNdEx].MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x12 + } + } + if m.Op != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.Op)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *RelationshipFilter) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *RelationshipFilter) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *RelationshipFilter) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if len(m.OptionalResourceIdPrefix) > 0 { + i -= len(m.OptionalResourceIdPrefix) + copy(dAtA[i:], m.OptionalResourceIdPrefix) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.OptionalResourceIdPrefix))) + i-- + dAtA[i] = 0x2a + } + if m.OptionalSubjectFilter != nil { + size, err := m.OptionalSubjectFilter.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x22 + } + if len(m.OptionalRelation) > 0 { + i -= len(m.OptionalRelation) + copy(dAtA[i:], m.OptionalRelation) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.OptionalRelation))) + i-- + dAtA[i] = 0x1a + } + if len(m.OptionalResourceId) > 0 { + i -= len(m.OptionalResourceId) + copy(dAtA[i:], m.OptionalResourceId) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.OptionalResourceId))) + i-- + dAtA[i] = 0x12 + } + if len(m.ResourceType) > 0 { + i -= len(m.ResourceType) + copy(dAtA[i:], m.ResourceType) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.ResourceType))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *SubjectFilter_RelationFilter) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *SubjectFilter_RelationFilter) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *SubjectFilter_RelationFilter) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if len(m.Relation) > 0 { + i -= len(m.Relation) + copy(dAtA[i:], m.Relation) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Relation))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *SubjectFilter) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *SubjectFilter) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *SubjectFilter) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if m.OptionalRelation != nil { + size, err := m.OptionalRelation.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x1a + } + if len(m.OptionalSubjectId) > 0 { + i -= len(m.OptionalSubjectId) + copy(dAtA[i:], m.OptionalSubjectId) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.OptionalSubjectId))) + i-- + dAtA[i] = 0x12 + } + if len(m.SubjectType) > 0 { + i -= len(m.SubjectType) + copy(dAtA[i:], m.SubjectType) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.SubjectType))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *RelationTuple) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.ResourceAndRelation != nil { + l = m.ResourceAndRelation.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if m.Subject != nil { + l = m.Subject.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if m.Caveat != nil { + l = m.Caveat.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if m.Integrity != nil { + l = m.Integrity.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if m.OptionalExpirationTime != nil { + l = (*timestamppb1.Timestamp)(m.OptionalExpirationTime).SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + n += len(m.unknownFields) + return n +} + +func (m *RelationshipIntegrity) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.KeyId) + if l > 0 { + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + l = len(m.Hash) + if l > 0 { + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if m.HashedAt != nil { + l = (*timestamppb1.Timestamp)(m.HashedAt).SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + n += len(m.unknownFields) + return n +} + +func (m *ContextualizedCaveat) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.CaveatName) + if l > 0 { + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if m.Context != nil { + l = (*structpb1.Struct)(m.Context).SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + n += len(m.unknownFields) + return n +} + +func (m *CaveatDefinition) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Name) + if l > 0 { + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + l = len(m.SerializedExpression) + if l > 0 { + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if len(m.ParameterTypes) > 0 { + for k, v := range m.ParameterTypes { + _ = k + _ = v + l = 0 + if v != nil { + l = v.SizeVT() + } + l += 1 + protohelpers.SizeOfVarint(uint64(l)) + mapEntrySize := 1 + len(k) + protohelpers.SizeOfVarint(uint64(len(k))) + l + n += mapEntrySize + 1 + protohelpers.SizeOfVarint(uint64(mapEntrySize)) + } + } + if m.Metadata != nil { + l = m.Metadata.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if m.SourcePosition != nil { + l = m.SourcePosition.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + n += len(m.unknownFields) + return n +} + +func (m *CaveatTypeReference) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.TypeName) + if l > 0 { + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if len(m.ChildTypes) > 0 { + for _, e := range m.ChildTypes { + l = e.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + } + n += len(m.unknownFields) + return n +} + +func (m *ObjectAndRelation) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Namespace) + if l > 0 { + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + l = len(m.ObjectId) + if l > 0 { + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + l = len(m.Relation) + if l > 0 { + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + n += len(m.unknownFields) + return n +} + +func (m *RelationReference) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Namespace) + if l > 0 { + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + l = len(m.Relation) + if l > 0 { + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + n += len(m.unknownFields) + return n +} + +func (m *Zookie) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Token) + if l > 0 { + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + n += len(m.unknownFields) + return n +} + +func (m *RelationTupleUpdate) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Operation != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.Operation)) + } + if m.Tuple != nil { + l = m.Tuple.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + n += len(m.unknownFields) + return n +} + +func (m *RelationTupleTreeNode) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if vtmsg, ok := m.NodeType.(interface{ SizeVT() int }); ok { + n += vtmsg.SizeVT() + } + if m.Expanded != nil { + l = m.Expanded.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if m.CaveatExpression != nil { + l = m.CaveatExpression.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + n += len(m.unknownFields) + return n +} + +func (m *RelationTupleTreeNode_IntermediateNode) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.IntermediateNode != nil { + l = m.IntermediateNode.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } else { + n += 2 + } + return n +} +func (m *RelationTupleTreeNode_LeafNode) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.LeafNode != nil { + l = m.LeafNode.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } else { + n += 2 + } + return n +} +func (m *SetOperationUserset) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Operation != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.Operation)) + } + if len(m.ChildNodes) > 0 { + for _, e := range m.ChildNodes { + l = e.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + } + n += len(m.unknownFields) + return n +} + +func (m *DirectSubject) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Subject != nil { + l = m.Subject.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if m.CaveatExpression != nil { + l = m.CaveatExpression.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + n += len(m.unknownFields) + return n +} + +func (m *DirectSubjects) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Subjects) > 0 { + for _, e := range m.Subjects { + l = e.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + } + n += len(m.unknownFields) + return n +} + +func (m *Metadata) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.MetadataMessage) > 0 { + for _, e := range m.MetadataMessage { + l = (*anypb1.Any)(e).SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + } + n += len(m.unknownFields) + return n +} + +func (m *NamespaceDefinition) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Name) + if l > 0 { + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if len(m.Relation) > 0 { + for _, e := range m.Relation { + l = e.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + } + if m.Metadata != nil { + l = m.Metadata.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if m.SourcePosition != nil { + l = m.SourcePosition.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + n += len(m.unknownFields) + return n +} + +func (m *Relation) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Name) + if l > 0 { + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if m.UsersetRewrite != nil { + l = m.UsersetRewrite.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if m.TypeInformation != nil { + l = m.TypeInformation.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if m.Metadata != nil { + l = m.Metadata.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if m.SourcePosition != nil { + l = m.SourcePosition.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + l = len(m.AliasingRelation) + if l > 0 { + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + l = len(m.CanonicalCacheKey) + if l > 0 { + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + n += len(m.unknownFields) + return n +} + +func (m *ReachabilityGraph) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.EntrypointsBySubjectType) > 0 { + for k, v := range m.EntrypointsBySubjectType { + _ = k + _ = v + l = 0 + if v != nil { + l = v.SizeVT() + } + l += 1 + protohelpers.SizeOfVarint(uint64(l)) + mapEntrySize := 1 + len(k) + protohelpers.SizeOfVarint(uint64(len(k))) + l + n += mapEntrySize + 1 + protohelpers.SizeOfVarint(uint64(mapEntrySize)) + } + } + if len(m.EntrypointsBySubjectRelation) > 0 { + for k, v := range m.EntrypointsBySubjectRelation { + _ = k + _ = v + l = 0 + if v != nil { + l = v.SizeVT() + } + l += 1 + protohelpers.SizeOfVarint(uint64(l)) + mapEntrySize := 1 + len(k) + protohelpers.SizeOfVarint(uint64(len(k))) + l + n += mapEntrySize + 1 + protohelpers.SizeOfVarint(uint64(mapEntrySize)) + } + } + n += len(m.unknownFields) + return n +} + +func (m *ReachabilityEntrypoints) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Entrypoints) > 0 { + for _, e := range m.Entrypoints { + l = e.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + } + l = len(m.SubjectType) + if l > 0 { + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if m.SubjectRelation != nil { + l = m.SubjectRelation.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + n += len(m.unknownFields) + return n +} + +func (m *ReachabilityEntrypoint) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Kind != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.Kind)) + } + if m.TargetRelation != nil { + l = m.TargetRelation.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if m.ResultStatus != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.ResultStatus)) + } + l = len(m.TuplesetRelation) + if l > 0 { + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + l = len(m.ComputedUsersetRelation) + if l > 0 { + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + n += len(m.unknownFields) + return n +} + +func (m *TypeInformation) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.AllowedDirectRelations) > 0 { + for _, e := range m.AllowedDirectRelations { + l = e.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + } + n += len(m.unknownFields) + return n +} + +func (m *AllowedRelation_PublicWildcard) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + n += len(m.unknownFields) + return n +} + +func (m *AllowedRelation) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Namespace) + if l > 0 { + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if vtmsg, ok := m.RelationOrWildcard.(interface{ SizeVT() int }); ok { + n += vtmsg.SizeVT() + } + if m.SourcePosition != nil { + l = m.SourcePosition.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if m.RequiredCaveat != nil { + l = m.RequiredCaveat.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if m.RequiredExpiration != nil { + l = m.RequiredExpiration.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + n += len(m.unknownFields) + return n +} + +func (m *AllowedRelation_Relation) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Relation) + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + return n +} +func (m *AllowedRelation_PublicWildcard_) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.PublicWildcard != nil { + l = m.PublicWildcard.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } else { + n += 2 + } + return n +} +func (m *ExpirationTrait) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + n += len(m.unknownFields) + return n +} + +func (m *AllowedCaveat) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.CaveatName) + if l > 0 { + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + n += len(m.unknownFields) + return n +} + +func (m *UsersetRewrite) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if vtmsg, ok := m.RewriteOperation.(interface{ SizeVT() int }); ok { + n += vtmsg.SizeVT() + } + if m.SourcePosition != nil { + l = m.SourcePosition.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + n += len(m.unknownFields) + return n +} + +func (m *UsersetRewrite_Union) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Union != nil { + l = m.Union.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } else { + n += 2 + } + return n +} +func (m *UsersetRewrite_Intersection) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Intersection != nil { + l = m.Intersection.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } else { + n += 2 + } + return n +} +func (m *UsersetRewrite_Exclusion) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Exclusion != nil { + l = m.Exclusion.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } else { + n += 2 + } + return n +} +func (m *SetOperation_Child_This) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + n += len(m.unknownFields) + return n +} + +func (m *SetOperation_Child_Nil) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + n += len(m.unknownFields) + return n +} + +func (m *SetOperation_Child) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if vtmsg, ok := m.ChildType.(interface{ SizeVT() int }); ok { + n += vtmsg.SizeVT() + } + if m.SourcePosition != nil { + l = m.SourcePosition.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if len(m.OperationPath) > 0 { + l = 0 + for _, e := range m.OperationPath { + l += protohelpers.SizeOfVarint(uint64(e)) + } + n += 1 + protohelpers.SizeOfVarint(uint64(l)) + l + } + n += len(m.unknownFields) + return n +} + +func (m *SetOperation_Child_XThis) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.XThis != nil { + l = m.XThis.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } else { + n += 2 + } + return n +} +func (m *SetOperation_Child_ComputedUserset) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.ComputedUserset != nil { + l = m.ComputedUserset.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } else { + n += 2 + } + return n +} +func (m *SetOperation_Child_TupleToUserset) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.TupleToUserset != nil { + l = m.TupleToUserset.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } else { + n += 2 + } + return n +} +func (m *SetOperation_Child_UsersetRewrite) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.UsersetRewrite != nil { + l = m.UsersetRewrite.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } else { + n += 2 + } + return n +} +func (m *SetOperation_Child_XNil) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.XNil != nil { + l = m.XNil.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } else { + n += 2 + } + return n +} +func (m *SetOperation_Child_FunctionedTupleToUserset) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.FunctionedTupleToUserset != nil { + l = m.FunctionedTupleToUserset.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } else { + n += 2 + } + return n +} +func (m *SetOperation) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Child) > 0 { + for _, e := range m.Child { + l = e.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + } + n += len(m.unknownFields) + return n +} + +func (m *TupleToUserset_Tupleset) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Relation) + if l > 0 { + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + n += len(m.unknownFields) + return n +} + +func (m *TupleToUserset) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Tupleset != nil { + l = m.Tupleset.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if m.ComputedUserset != nil { + l = m.ComputedUserset.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if m.SourcePosition != nil { + l = m.SourcePosition.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + n += len(m.unknownFields) + return n +} + +func (m *FunctionedTupleToUserset_Tupleset) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Relation) + if l > 0 { + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + n += len(m.unknownFields) + return n +} + +func (m *FunctionedTupleToUserset) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Function != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.Function)) + } + if m.Tupleset != nil { + l = m.Tupleset.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if m.ComputedUserset != nil { + l = m.ComputedUserset.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if m.SourcePosition != nil { + l = m.SourcePosition.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + n += len(m.unknownFields) + return n +} + +func (m *ComputedUserset) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Object != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.Object)) + } + l = len(m.Relation) + if l > 0 { + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if m.SourcePosition != nil { + l = m.SourcePosition.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + n += len(m.unknownFields) + return n +} + +func (m *SourcePosition) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.ZeroIndexedLineNumber != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.ZeroIndexedLineNumber)) + } + if m.ZeroIndexedColumnPosition != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.ZeroIndexedColumnPosition)) + } + n += len(m.unknownFields) + return n +} + +func (m *CaveatExpression) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if vtmsg, ok := m.OperationOrCaveat.(interface{ SizeVT() int }); ok { + n += vtmsg.SizeVT() + } + n += len(m.unknownFields) + return n +} + +func (m *CaveatExpression_Operation) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Operation != nil { + l = m.Operation.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } else { + n += 2 + } + return n +} +func (m *CaveatExpression_Caveat) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Caveat != nil { + l = m.Caveat.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } else { + n += 2 + } + return n +} +func (m *CaveatOperation) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Op != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.Op)) + } + if len(m.Children) > 0 { + for _, e := range m.Children { + l = e.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + } + n += len(m.unknownFields) + return n +} + +func (m *RelationshipFilter) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ResourceType) + if l > 0 { + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + l = len(m.OptionalResourceId) + if l > 0 { + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + l = len(m.OptionalRelation) + if l > 0 { + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if m.OptionalSubjectFilter != nil { + l = m.OptionalSubjectFilter.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + l = len(m.OptionalResourceIdPrefix) + if l > 0 { + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + n += len(m.unknownFields) + return n +} + +func (m *SubjectFilter_RelationFilter) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Relation) + if l > 0 { + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + n += len(m.unknownFields) + return n +} + +func (m *SubjectFilter) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.SubjectType) + if l > 0 { + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + l = len(m.OptionalSubjectId) + if l > 0 { + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if m.OptionalRelation != nil { + l = m.OptionalRelation.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + n += len(m.unknownFields) + return n +} + +func (m *RelationTuple) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: RelationTuple: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: RelationTuple: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ResourceAndRelation", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.ResourceAndRelation == nil { + m.ResourceAndRelation = &ObjectAndRelation{} + } + if err := m.ResourceAndRelation.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Subject", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Subject == nil { + m.Subject = &ObjectAndRelation{} + } + if err := m.Subject.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Caveat", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Caveat == nil { + m.Caveat = &ContextualizedCaveat{} + } + if err := m.Caveat.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Integrity", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Integrity == nil { + m.Integrity = &RelationshipIntegrity{} + } + if err := m.Integrity.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field OptionalExpirationTime", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.OptionalExpirationTime == nil { + m.OptionalExpirationTime = ×tamppb.Timestamp{} + } + if err := (*timestamppb1.Timestamp)(m.OptionalExpirationTime).UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *RelationshipIntegrity) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: RelationshipIntegrity: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: RelationshipIntegrity: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field KeyId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.KeyId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Hash", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Hash = append(m.Hash[:0], dAtA[iNdEx:postIndex]...) + if m.Hash == nil { + m.Hash = []byte{} + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field HashedAt", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.HashedAt == nil { + m.HashedAt = ×tamppb.Timestamp{} + } + if err := (*timestamppb1.Timestamp)(m.HashedAt).UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ContextualizedCaveat) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ContextualizedCaveat: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ContextualizedCaveat: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CaveatName", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.CaveatName = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Context", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Context == nil { + m.Context = &structpb.Struct{} + } + if err := (*structpb1.Struct)(m.Context).UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *CaveatDefinition) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: CaveatDefinition: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: CaveatDefinition: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Name = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SerializedExpression", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.SerializedExpression = append(m.SerializedExpression[:0], dAtA[iNdEx:postIndex]...) + if m.SerializedExpression == nil { + m.SerializedExpression = []byte{} + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ParameterTypes", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.ParameterTypes == nil { + m.ParameterTypes = make(map[string]*CaveatTypeReference) + } + var mapkey string + var mapvalue *CaveatTypeReference + for iNdEx < postIndex { + entryPreIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + if fieldNum == 1 { + var stringLenmapkey uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLenmapkey |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLenmapkey := int(stringLenmapkey) + if intStringLenmapkey < 0 { + return protohelpers.ErrInvalidLength + } + postStringIndexmapkey := iNdEx + intStringLenmapkey + if postStringIndexmapkey < 0 { + return protohelpers.ErrInvalidLength + } + if postStringIndexmapkey > l { + return io.ErrUnexpectedEOF + } + mapkey = string(dAtA[iNdEx:postStringIndexmapkey]) + iNdEx = postStringIndexmapkey + } else if fieldNum == 2 { + var mapmsglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + mapmsglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if mapmsglen < 0 { + return protohelpers.ErrInvalidLength + } + postmsgIndex := iNdEx + mapmsglen + if postmsgIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postmsgIndex > l { + return io.ErrUnexpectedEOF + } + mapvalue = &CaveatTypeReference{} + if err := mapvalue.UnmarshalVT(dAtA[iNdEx:postmsgIndex]); err != nil { + return err + } + iNdEx = postmsgIndex + } else { + iNdEx = entryPreIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > postIndex { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + m.ParameterTypes[mapkey] = mapvalue + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Metadata", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Metadata == nil { + m.Metadata = &Metadata{} + } + if err := m.Metadata.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SourcePosition", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.SourcePosition == nil { + m.SourcePosition = &SourcePosition{} + } + if err := m.SourcePosition.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *CaveatTypeReference) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: CaveatTypeReference: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: CaveatTypeReference: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TypeName", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.TypeName = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ChildTypes", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ChildTypes = append(m.ChildTypes, &CaveatTypeReference{}) + if err := m.ChildTypes[len(m.ChildTypes)-1].UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ObjectAndRelation) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ObjectAndRelation: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ObjectAndRelation: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Namespace", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Namespace = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ObjectId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ObjectId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Relation", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Relation = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *RelationReference) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: RelationReference: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: RelationReference: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Namespace", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Namespace = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Relation", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Relation = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Zookie) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Zookie: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Zookie: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Token", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Token = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *RelationTupleUpdate) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: RelationTupleUpdate: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: RelationTupleUpdate: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Operation", wireType) + } + m.Operation = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Operation |= RelationTupleUpdate_Operation(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Tuple", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Tuple == nil { + m.Tuple = &RelationTuple{} + } + if err := m.Tuple.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *RelationTupleTreeNode) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: RelationTupleTreeNode: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: RelationTupleTreeNode: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field IntermediateNode", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if oneof, ok := m.NodeType.(*RelationTupleTreeNode_IntermediateNode); ok { + if err := oneof.IntermediateNode.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + } else { + v := &SetOperationUserset{} + if err := v.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.NodeType = &RelationTupleTreeNode_IntermediateNode{IntermediateNode: v} + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field LeafNode", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if oneof, ok := m.NodeType.(*RelationTupleTreeNode_LeafNode); ok { + if err := oneof.LeafNode.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + } else { + v := &DirectSubjects{} + if err := v.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.NodeType = &RelationTupleTreeNode_LeafNode{LeafNode: v} + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Expanded", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Expanded == nil { + m.Expanded = &ObjectAndRelation{} + } + if err := m.Expanded.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CaveatExpression", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.CaveatExpression == nil { + m.CaveatExpression = &CaveatExpression{} + } + if err := m.CaveatExpression.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *SetOperationUserset) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: SetOperationUserset: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: SetOperationUserset: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Operation", wireType) + } + m.Operation = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Operation |= SetOperationUserset_Operation(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ChildNodes", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ChildNodes = append(m.ChildNodes, &RelationTupleTreeNode{}) + if err := m.ChildNodes[len(m.ChildNodes)-1].UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *DirectSubject) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: DirectSubject: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: DirectSubject: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Subject", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Subject == nil { + m.Subject = &ObjectAndRelation{} + } + if err := m.Subject.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CaveatExpression", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.CaveatExpression == nil { + m.CaveatExpression = &CaveatExpression{} + } + if err := m.CaveatExpression.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *DirectSubjects) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: DirectSubjects: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: DirectSubjects: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Subjects", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Subjects = append(m.Subjects, &DirectSubject{}) + if err := m.Subjects[len(m.Subjects)-1].UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Metadata) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Metadata: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Metadata: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MetadataMessage", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.MetadataMessage = append(m.MetadataMessage, &anypb.Any{}) + if err := (*anypb1.Any)(m.MetadataMessage[len(m.MetadataMessage)-1]).UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *NamespaceDefinition) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: NamespaceDefinition: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: NamespaceDefinition: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Name = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Relation", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Relation = append(m.Relation, &Relation{}) + if err := m.Relation[len(m.Relation)-1].UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Metadata", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Metadata == nil { + m.Metadata = &Metadata{} + } + if err := m.Metadata.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SourcePosition", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.SourcePosition == nil { + m.SourcePosition = &SourcePosition{} + } + if err := m.SourcePosition.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Relation) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Relation: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Relation: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Name = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field UsersetRewrite", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.UsersetRewrite == nil { + m.UsersetRewrite = &UsersetRewrite{} + } + if err := m.UsersetRewrite.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TypeInformation", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.TypeInformation == nil { + m.TypeInformation = &TypeInformation{} + } + if err := m.TypeInformation.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Metadata", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Metadata == nil { + m.Metadata = &Metadata{} + } + if err := m.Metadata.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SourcePosition", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.SourcePosition == nil { + m.SourcePosition = &SourcePosition{} + } + if err := m.SourcePosition.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AliasingRelation", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.AliasingRelation = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CanonicalCacheKey", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.CanonicalCacheKey = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ReachabilityGraph) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ReachabilityGraph: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ReachabilityGraph: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field EntrypointsBySubjectType", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.EntrypointsBySubjectType == nil { + m.EntrypointsBySubjectType = make(map[string]*ReachabilityEntrypoints) + } + var mapkey string + var mapvalue *ReachabilityEntrypoints + for iNdEx < postIndex { + entryPreIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + if fieldNum == 1 { + var stringLenmapkey uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLenmapkey |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLenmapkey := int(stringLenmapkey) + if intStringLenmapkey < 0 { + return protohelpers.ErrInvalidLength + } + postStringIndexmapkey := iNdEx + intStringLenmapkey + if postStringIndexmapkey < 0 { + return protohelpers.ErrInvalidLength + } + if postStringIndexmapkey > l { + return io.ErrUnexpectedEOF + } + mapkey = string(dAtA[iNdEx:postStringIndexmapkey]) + iNdEx = postStringIndexmapkey + } else if fieldNum == 2 { + var mapmsglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + mapmsglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if mapmsglen < 0 { + return protohelpers.ErrInvalidLength + } + postmsgIndex := iNdEx + mapmsglen + if postmsgIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postmsgIndex > l { + return io.ErrUnexpectedEOF + } + mapvalue = &ReachabilityEntrypoints{} + if err := mapvalue.UnmarshalVT(dAtA[iNdEx:postmsgIndex]); err != nil { + return err + } + iNdEx = postmsgIndex + } else { + iNdEx = entryPreIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > postIndex { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + m.EntrypointsBySubjectType[mapkey] = mapvalue + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field EntrypointsBySubjectRelation", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.EntrypointsBySubjectRelation == nil { + m.EntrypointsBySubjectRelation = make(map[string]*ReachabilityEntrypoints) + } + var mapkey string + var mapvalue *ReachabilityEntrypoints + for iNdEx < postIndex { + entryPreIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + if fieldNum == 1 { + var stringLenmapkey uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLenmapkey |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLenmapkey := int(stringLenmapkey) + if intStringLenmapkey < 0 { + return protohelpers.ErrInvalidLength + } + postStringIndexmapkey := iNdEx + intStringLenmapkey + if postStringIndexmapkey < 0 { + return protohelpers.ErrInvalidLength + } + if postStringIndexmapkey > l { + return io.ErrUnexpectedEOF + } + mapkey = string(dAtA[iNdEx:postStringIndexmapkey]) + iNdEx = postStringIndexmapkey + } else if fieldNum == 2 { + var mapmsglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + mapmsglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if mapmsglen < 0 { + return protohelpers.ErrInvalidLength + } + postmsgIndex := iNdEx + mapmsglen + if postmsgIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postmsgIndex > l { + return io.ErrUnexpectedEOF + } + mapvalue = &ReachabilityEntrypoints{} + if err := mapvalue.UnmarshalVT(dAtA[iNdEx:postmsgIndex]); err != nil { + return err + } + iNdEx = postmsgIndex + } else { + iNdEx = entryPreIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > postIndex { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + m.EntrypointsBySubjectRelation[mapkey] = mapvalue + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ReachabilityEntrypoints) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ReachabilityEntrypoints: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ReachabilityEntrypoints: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Entrypoints", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Entrypoints = append(m.Entrypoints, &ReachabilityEntrypoint{}) + if err := m.Entrypoints[len(m.Entrypoints)-1].UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SubjectType", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.SubjectType = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SubjectRelation", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.SubjectRelation == nil { + m.SubjectRelation = &RelationReference{} + } + if err := m.SubjectRelation.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ReachabilityEntrypoint) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ReachabilityEntrypoint: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ReachabilityEntrypoint: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Kind", wireType) + } + m.Kind = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Kind |= ReachabilityEntrypoint_ReachabilityEntrypointKind(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TargetRelation", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.TargetRelation == nil { + m.TargetRelation = &RelationReference{} + } + if err := m.TargetRelation.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ResultStatus", wireType) + } + m.ResultStatus = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ResultStatus |= ReachabilityEntrypoint_EntrypointResultStatus(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TuplesetRelation", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.TuplesetRelation = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ComputedUsersetRelation", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ComputedUsersetRelation = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *TypeInformation) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: TypeInformation: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: TypeInformation: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AllowedDirectRelations", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.AllowedDirectRelations = append(m.AllowedDirectRelations, &AllowedRelation{}) + if err := m.AllowedDirectRelations[len(m.AllowedDirectRelations)-1].UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *AllowedRelation_PublicWildcard) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: AllowedRelation_PublicWildcard: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: AllowedRelation_PublicWildcard: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *AllowedRelation) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: AllowedRelation: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: AllowedRelation: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Namespace", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Namespace = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Relation", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.RelationOrWildcard = &AllowedRelation_Relation{Relation: string(dAtA[iNdEx:postIndex])} + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PublicWildcard", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if oneof, ok := m.RelationOrWildcard.(*AllowedRelation_PublicWildcard_); ok { + if err := oneof.PublicWildcard.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + } else { + v := &AllowedRelation_PublicWildcard{} + if err := v.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.RelationOrWildcard = &AllowedRelation_PublicWildcard_{PublicWildcard: v} + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SourcePosition", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.SourcePosition == nil { + m.SourcePosition = &SourcePosition{} + } + if err := m.SourcePosition.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RequiredCaveat", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.RequiredCaveat == nil { + m.RequiredCaveat = &AllowedCaveat{} + } + if err := m.RequiredCaveat.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RequiredExpiration", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.RequiredExpiration == nil { + m.RequiredExpiration = &ExpirationTrait{} + } + if err := m.RequiredExpiration.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ExpirationTrait) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ExpirationTrait: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ExpirationTrait: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *AllowedCaveat) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: AllowedCaveat: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: AllowedCaveat: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CaveatName", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.CaveatName = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *UsersetRewrite) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: UsersetRewrite: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: UsersetRewrite: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Union", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if oneof, ok := m.RewriteOperation.(*UsersetRewrite_Union); ok { + if err := oneof.Union.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + } else { + v := &SetOperation{} + if err := v.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.RewriteOperation = &UsersetRewrite_Union{Union: v} + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Intersection", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if oneof, ok := m.RewriteOperation.(*UsersetRewrite_Intersection); ok { + if err := oneof.Intersection.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + } else { + v := &SetOperation{} + if err := v.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.RewriteOperation = &UsersetRewrite_Intersection{Intersection: v} + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Exclusion", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if oneof, ok := m.RewriteOperation.(*UsersetRewrite_Exclusion); ok { + if err := oneof.Exclusion.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + } else { + v := &SetOperation{} + if err := v.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.RewriteOperation = &UsersetRewrite_Exclusion{Exclusion: v} + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SourcePosition", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.SourcePosition == nil { + m.SourcePosition = &SourcePosition{} + } + if err := m.SourcePosition.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *SetOperation_Child_This) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: SetOperation_Child_This: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: SetOperation_Child_This: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *SetOperation_Child_Nil) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: SetOperation_Child_Nil: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: SetOperation_Child_Nil: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *SetOperation_Child) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: SetOperation_Child: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: SetOperation_Child: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field XThis", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if oneof, ok := m.ChildType.(*SetOperation_Child_XThis); ok { + if err := oneof.XThis.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + } else { + v := &SetOperation_Child_This{} + if err := v.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.ChildType = &SetOperation_Child_XThis{XThis: v} + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ComputedUserset", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if oneof, ok := m.ChildType.(*SetOperation_Child_ComputedUserset); ok { + if err := oneof.ComputedUserset.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + } else { + v := &ComputedUserset{} + if err := v.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.ChildType = &SetOperation_Child_ComputedUserset{ComputedUserset: v} + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TupleToUserset", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if oneof, ok := m.ChildType.(*SetOperation_Child_TupleToUserset); ok { + if err := oneof.TupleToUserset.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + } else { + v := &TupleToUserset{} + if err := v.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.ChildType = &SetOperation_Child_TupleToUserset{TupleToUserset: v} + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field UsersetRewrite", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if oneof, ok := m.ChildType.(*SetOperation_Child_UsersetRewrite); ok { + if err := oneof.UsersetRewrite.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + } else { + v := &UsersetRewrite{} + if err := v.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.ChildType = &SetOperation_Child_UsersetRewrite{UsersetRewrite: v} + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SourcePosition", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.SourcePosition == nil { + m.SourcePosition = &SourcePosition{} + } + if err := m.SourcePosition.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field XNil", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if oneof, ok := m.ChildType.(*SetOperation_Child_XNil); ok { + if err := oneof.XNil.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + } else { + v := &SetOperation_Child_Nil{} + if err := v.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.ChildType = &SetOperation_Child_XNil{XNil: v} + } + iNdEx = postIndex + case 7: + if wireType == 0 { + var v uint32 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.OperationPath = append(m.OperationPath, v) + } else if wireType == 2 { + var packedLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + packedLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if packedLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + packedLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var elementCount int + var count int + for _, integer := range dAtA[iNdEx:postIndex] { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.OperationPath) == 0 { + m.OperationPath = make([]uint32, 0, elementCount) + } + for iNdEx < postIndex { + var v uint32 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.OperationPath = append(m.OperationPath, v) + } + } else { + return fmt.Errorf("proto: wrong wireType = %d for field OperationPath", wireType) + } + case 8: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field FunctionedTupleToUserset", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if oneof, ok := m.ChildType.(*SetOperation_Child_FunctionedTupleToUserset); ok { + if err := oneof.FunctionedTupleToUserset.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + } else { + v := &FunctionedTupleToUserset{} + if err := v.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.ChildType = &SetOperation_Child_FunctionedTupleToUserset{FunctionedTupleToUserset: v} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *SetOperation) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: SetOperation: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: SetOperation: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Child", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Child = append(m.Child, &SetOperation_Child{}) + if err := m.Child[len(m.Child)-1].UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *TupleToUserset_Tupleset) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: TupleToUserset_Tupleset: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: TupleToUserset_Tupleset: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Relation", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Relation = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *TupleToUserset) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: TupleToUserset: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: TupleToUserset: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Tupleset", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Tupleset == nil { + m.Tupleset = &TupleToUserset_Tupleset{} + } + if err := m.Tupleset.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ComputedUserset", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.ComputedUserset == nil { + m.ComputedUserset = &ComputedUserset{} + } + if err := m.ComputedUserset.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SourcePosition", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.SourcePosition == nil { + m.SourcePosition = &SourcePosition{} + } + if err := m.SourcePosition.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *FunctionedTupleToUserset_Tupleset) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: FunctionedTupleToUserset_Tupleset: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: FunctionedTupleToUserset_Tupleset: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Relation", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Relation = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *FunctionedTupleToUserset) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: FunctionedTupleToUserset: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: FunctionedTupleToUserset: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Function", wireType) + } + m.Function = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Function |= FunctionedTupleToUserset_Function(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Tupleset", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Tupleset == nil { + m.Tupleset = &FunctionedTupleToUserset_Tupleset{} + } + if err := m.Tupleset.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ComputedUserset", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.ComputedUserset == nil { + m.ComputedUserset = &ComputedUserset{} + } + if err := m.ComputedUserset.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SourcePosition", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.SourcePosition == nil { + m.SourcePosition = &SourcePosition{} + } + if err := m.SourcePosition.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ComputedUserset) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ComputedUserset: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ComputedUserset: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Object", wireType) + } + m.Object = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Object |= ComputedUserset_Object(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Relation", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Relation = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SourcePosition", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.SourcePosition == nil { + m.SourcePosition = &SourcePosition{} + } + if err := m.SourcePosition.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *SourcePosition) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: SourcePosition: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: SourcePosition: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ZeroIndexedLineNumber", wireType) + } + m.ZeroIndexedLineNumber = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ZeroIndexedLineNumber |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ZeroIndexedColumnPosition", wireType) + } + m.ZeroIndexedColumnPosition = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ZeroIndexedColumnPosition |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *CaveatExpression) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: CaveatExpression: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: CaveatExpression: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Operation", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if oneof, ok := m.OperationOrCaveat.(*CaveatExpression_Operation); ok { + if err := oneof.Operation.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + } else { + v := &CaveatOperation{} + if err := v.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.OperationOrCaveat = &CaveatExpression_Operation{Operation: v} + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Caveat", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if oneof, ok := m.OperationOrCaveat.(*CaveatExpression_Caveat); ok { + if err := oneof.Caveat.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + } else { + v := &ContextualizedCaveat{} + if err := v.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.OperationOrCaveat = &CaveatExpression_Caveat{Caveat: v} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *CaveatOperation) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: CaveatOperation: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: CaveatOperation: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Op", wireType) + } + m.Op = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Op |= CaveatOperation_Operation(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Children", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Children = append(m.Children, &CaveatExpression{}) + if err := m.Children[len(m.Children)-1].UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *RelationshipFilter) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: RelationshipFilter: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: RelationshipFilter: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ResourceType", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ResourceType = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field OptionalResourceId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.OptionalResourceId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field OptionalRelation", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.OptionalRelation = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field OptionalSubjectFilter", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.OptionalSubjectFilter == nil { + m.OptionalSubjectFilter = &SubjectFilter{} + } + if err := m.OptionalSubjectFilter.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field OptionalResourceIdPrefix", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.OptionalResourceIdPrefix = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *SubjectFilter_RelationFilter) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: SubjectFilter_RelationFilter: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: SubjectFilter_RelationFilter: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Relation", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Relation = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *SubjectFilter) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: SubjectFilter: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: SubjectFilter: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SubjectType", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.SubjectType = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field OptionalSubjectId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.OptionalSubjectId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field OptionalRelation", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.OptionalRelation == nil { + m.OptionalRelation = &SubjectFilter_RelationFilter{} + } + if err := m.OptionalRelation.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} diff --git a/vendor/github.com/authzed/spicedb/pkg/proto/developer/v1/developer.pb.go b/vendor/github.com/authzed/spicedb/pkg/proto/developer/v1/developer.pb.go new file mode 100644 index 0000000..f553c60 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/proto/developer/v1/developer.pb.go @@ -0,0 +1,2088 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.34.2 +// protoc (unknown) +// source: developer/v1/developer.proto + +package developerv1 + +import ( + v12 "github.com/authzed/authzed-go/proto/authzed/api/v1" + v1 "github.com/authzed/spicedb/pkg/proto/core/v1" + v11 "github.com/authzed/spicedb/pkg/proto/dispatch/v1" + _ "github.com/envoyproxy/protoc-gen-validate/validate" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + structpb "google.golang.org/protobuf/types/known/structpb" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type DeveloperError_Source int32 + +const ( + DeveloperError_UNKNOWN_SOURCE DeveloperError_Source = 0 + DeveloperError_SCHEMA DeveloperError_Source = 1 + DeveloperError_RELATIONSHIP DeveloperError_Source = 2 + DeveloperError_VALIDATION_YAML DeveloperError_Source = 3 + DeveloperError_CHECK_WATCH DeveloperError_Source = 4 + DeveloperError_ASSERTION DeveloperError_Source = 5 +) + +// Enum value maps for DeveloperError_Source. +var ( + DeveloperError_Source_name = map[int32]string{ + 0: "UNKNOWN_SOURCE", + 1: "SCHEMA", + 2: "RELATIONSHIP", + 3: "VALIDATION_YAML", + 4: "CHECK_WATCH", + 5: "ASSERTION", + } + DeveloperError_Source_value = map[string]int32{ + "UNKNOWN_SOURCE": 0, + "SCHEMA": 1, + "RELATIONSHIP": 2, + "VALIDATION_YAML": 3, + "CHECK_WATCH": 4, + "ASSERTION": 5, + } +) + +func (x DeveloperError_Source) Enum() *DeveloperError_Source { + p := new(DeveloperError_Source) + *p = x + return p +} + +func (x DeveloperError_Source) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (DeveloperError_Source) Descriptor() protoreflect.EnumDescriptor { + return file_developer_v1_developer_proto_enumTypes[0].Descriptor() +} + +func (DeveloperError_Source) Type() protoreflect.EnumType { + return &file_developer_v1_developer_proto_enumTypes[0] +} + +func (x DeveloperError_Source) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use DeveloperError_Source.Descriptor instead. +func (DeveloperError_Source) EnumDescriptor() ([]byte, []int) { + return file_developer_v1_developer_proto_rawDescGZIP(), []int{7, 0} +} + +type DeveloperError_ErrorKind int32 + +const ( + DeveloperError_UNKNOWN_KIND DeveloperError_ErrorKind = 0 + DeveloperError_PARSE_ERROR DeveloperError_ErrorKind = 1 + DeveloperError_SCHEMA_ISSUE DeveloperError_ErrorKind = 2 + DeveloperError_DUPLICATE_RELATIONSHIP DeveloperError_ErrorKind = 3 + DeveloperError_MISSING_EXPECTED_RELATIONSHIP DeveloperError_ErrorKind = 4 + DeveloperError_EXTRA_RELATIONSHIP_FOUND DeveloperError_ErrorKind = 5 + DeveloperError_UNKNOWN_OBJECT_TYPE DeveloperError_ErrorKind = 6 + DeveloperError_UNKNOWN_RELATION DeveloperError_ErrorKind = 7 + DeveloperError_MAXIMUM_RECURSION DeveloperError_ErrorKind = 8 + DeveloperError_ASSERTION_FAILED DeveloperError_ErrorKind = 9 + DeveloperError_INVALID_SUBJECT_TYPE DeveloperError_ErrorKind = 10 +) + +// Enum value maps for DeveloperError_ErrorKind. +var ( + DeveloperError_ErrorKind_name = map[int32]string{ + 0: "UNKNOWN_KIND", + 1: "PARSE_ERROR", + 2: "SCHEMA_ISSUE", + 3: "DUPLICATE_RELATIONSHIP", + 4: "MISSING_EXPECTED_RELATIONSHIP", + 5: "EXTRA_RELATIONSHIP_FOUND", + 6: "UNKNOWN_OBJECT_TYPE", + 7: "UNKNOWN_RELATION", + 8: "MAXIMUM_RECURSION", + 9: "ASSERTION_FAILED", + 10: "INVALID_SUBJECT_TYPE", + } + DeveloperError_ErrorKind_value = map[string]int32{ + "UNKNOWN_KIND": 0, + "PARSE_ERROR": 1, + "SCHEMA_ISSUE": 2, + "DUPLICATE_RELATIONSHIP": 3, + "MISSING_EXPECTED_RELATIONSHIP": 4, + "EXTRA_RELATIONSHIP_FOUND": 5, + "UNKNOWN_OBJECT_TYPE": 6, + "UNKNOWN_RELATION": 7, + "MAXIMUM_RECURSION": 8, + "ASSERTION_FAILED": 9, + "INVALID_SUBJECT_TYPE": 10, + } +) + +func (x DeveloperError_ErrorKind) Enum() *DeveloperError_ErrorKind { + p := new(DeveloperError_ErrorKind) + *p = x + return p +} + +func (x DeveloperError_ErrorKind) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (DeveloperError_ErrorKind) Descriptor() protoreflect.EnumDescriptor { + return file_developer_v1_developer_proto_enumTypes[1].Descriptor() +} + +func (DeveloperError_ErrorKind) Type() protoreflect.EnumType { + return &file_developer_v1_developer_proto_enumTypes[1] +} + +func (x DeveloperError_ErrorKind) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use DeveloperError_ErrorKind.Descriptor instead. +func (DeveloperError_ErrorKind) EnumDescriptor() ([]byte, []int) { + return file_developer_v1_developer_proto_rawDescGZIP(), []int{7, 1} +} + +type CheckOperationsResult_Membership int32 + +const ( + CheckOperationsResult_UNKNOWN CheckOperationsResult_Membership = 0 + CheckOperationsResult_NOT_MEMBER CheckOperationsResult_Membership = 1 + CheckOperationsResult_MEMBER CheckOperationsResult_Membership = 2 + CheckOperationsResult_CAVEATED_MEMBER CheckOperationsResult_Membership = 3 +) + +// Enum value maps for CheckOperationsResult_Membership. +var ( + CheckOperationsResult_Membership_name = map[int32]string{ + 0: "UNKNOWN", + 1: "NOT_MEMBER", + 2: "MEMBER", + 3: "CAVEATED_MEMBER", + } + CheckOperationsResult_Membership_value = map[string]int32{ + "UNKNOWN": 0, + "NOT_MEMBER": 1, + "MEMBER": 2, + "CAVEATED_MEMBER": 3, + } +) + +func (x CheckOperationsResult_Membership) Enum() *CheckOperationsResult_Membership { + p := new(CheckOperationsResult_Membership) + *p = x + return p +} + +func (x CheckOperationsResult_Membership) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (CheckOperationsResult_Membership) Descriptor() protoreflect.EnumDescriptor { + return file_developer_v1_developer_proto_enumTypes[2].Descriptor() +} + +func (CheckOperationsResult_Membership) Type() protoreflect.EnumType { + return &file_developer_v1_developer_proto_enumTypes[2] +} + +func (x CheckOperationsResult_Membership) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use CheckOperationsResult_Membership.Descriptor instead. +func (CheckOperationsResult_Membership) EnumDescriptor() ([]byte, []int) { + return file_developer_v1_developer_proto_rawDescGZIP(), []int{10, 0} +} + +// DeveloperRequest is a single request made to the developer platform, containing zero or more +// operations to run. +type DeveloperRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // context is the context for the developer request. + Context *RequestContext `protobuf:"bytes,1,opt,name=context,proto3" json:"context,omitempty"` + // operations are the operations to be run as part of the developer request. + Operations []*Operation `protobuf:"bytes,2,rep,name=operations,proto3" json:"operations,omitempty"` +} + +func (x *DeveloperRequest) Reset() { + *x = DeveloperRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_developer_v1_developer_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DeveloperRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DeveloperRequest) ProtoMessage() {} + +func (x *DeveloperRequest) ProtoReflect() protoreflect.Message { + mi := &file_developer_v1_developer_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DeveloperRequest.ProtoReflect.Descriptor instead. +func (*DeveloperRequest) Descriptor() ([]byte, []int) { + return file_developer_v1_developer_proto_rawDescGZIP(), []int{0} +} + +func (x *DeveloperRequest) GetContext() *RequestContext { + if x != nil { + return x.Context + } + return nil +} + +func (x *DeveloperRequest) GetOperations() []*Operation { + if x != nil { + return x.Operations + } + return nil +} + +// DeveloperResponse is the response to a single request made to the developer platform. +type DeveloperResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // internal_error is the internal error that occurred when attempting to run this operation, if any. + InternalError string `protobuf:"bytes,1,opt,name=internal_error,json=internalError,proto3" json:"internal_error,omitempty"` + // developer_errors are the developer error(s) returned in the operation, if any. + DeveloperErrors *DeveloperErrors `protobuf:"bytes,2,opt,name=developer_errors,json=developerErrors,proto3" json:"developer_errors,omitempty"` + // operations_results holds the results of the operations, if any and no errors. + OperationsResults *OperationsResults `protobuf:"bytes,3,opt,name=operations_results,json=operationsResults,proto3" json:"operations_results,omitempty"` +} + +func (x *DeveloperResponse) Reset() { + *x = DeveloperResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_developer_v1_developer_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DeveloperResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DeveloperResponse) ProtoMessage() {} + +func (x *DeveloperResponse) ProtoReflect() protoreflect.Message { + mi := &file_developer_v1_developer_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DeveloperResponse.ProtoReflect.Descriptor instead. +func (*DeveloperResponse) Descriptor() ([]byte, []int) { + return file_developer_v1_developer_proto_rawDescGZIP(), []int{1} +} + +func (x *DeveloperResponse) GetInternalError() string { + if x != nil { + return x.InternalError + } + return "" +} + +func (x *DeveloperResponse) GetDeveloperErrors() *DeveloperErrors { + if x != nil { + return x.DeveloperErrors + } + return nil +} + +func (x *DeveloperResponse) GetOperationsResults() *OperationsResults { + if x != nil { + return x.OperationsResults + } + return nil +} + +// RequestContext is the context for setting up a development package environment for one or more +// operations. +type RequestContext struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // schema is the schema on which to run the developer request. + Schema string `protobuf:"bytes,1,opt,name=schema,proto3" json:"schema,omitempty"` + // relationships are the test data relationships for the developer request. + Relationships []*v1.RelationTuple `protobuf:"bytes,2,rep,name=relationships,proto3" json:"relationships,omitempty"` +} + +func (x *RequestContext) Reset() { + *x = RequestContext{} + if protoimpl.UnsafeEnabled { + mi := &file_developer_v1_developer_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *RequestContext) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RequestContext) ProtoMessage() {} + +func (x *RequestContext) ProtoReflect() protoreflect.Message { + mi := &file_developer_v1_developer_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use RequestContext.ProtoReflect.Descriptor instead. +func (*RequestContext) Descriptor() ([]byte, []int) { + return file_developer_v1_developer_proto_rawDescGZIP(), []int{2} +} + +func (x *RequestContext) GetSchema() string { + if x != nil { + return x.Schema + } + return "" +} + +func (x *RequestContext) GetRelationships() []*v1.RelationTuple { + if x != nil { + return x.Relationships + } + return nil +} + +// Operation is a single operation to be processed by the development package. +type Operation struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + CheckParameters *CheckOperationParameters `protobuf:"bytes,1,opt,name=check_parameters,json=checkParameters,proto3" json:"check_parameters,omitempty"` + AssertionsParameters *RunAssertionsParameters `protobuf:"bytes,2,opt,name=assertions_parameters,json=assertionsParameters,proto3" json:"assertions_parameters,omitempty"` + ValidationParameters *RunValidationParameters `protobuf:"bytes,3,opt,name=validation_parameters,json=validationParameters,proto3" json:"validation_parameters,omitempty"` + FormatSchemaParameters *FormatSchemaParameters `protobuf:"bytes,4,opt,name=format_schema_parameters,json=formatSchemaParameters,proto3" json:"format_schema_parameters,omitempty"` + SchemaWarningsParameters *SchemaWarningsParameters `protobuf:"bytes,5,opt,name=schema_warnings_parameters,json=schemaWarningsParameters,proto3" json:"schema_warnings_parameters,omitempty"` +} + +func (x *Operation) Reset() { + *x = Operation{} + if protoimpl.UnsafeEnabled { + mi := &file_developer_v1_developer_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Operation) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Operation) ProtoMessage() {} + +func (x *Operation) ProtoReflect() protoreflect.Message { + mi := &file_developer_v1_developer_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Operation.ProtoReflect.Descriptor instead. +func (*Operation) Descriptor() ([]byte, []int) { + return file_developer_v1_developer_proto_rawDescGZIP(), []int{3} +} + +func (x *Operation) GetCheckParameters() *CheckOperationParameters { + if x != nil { + return x.CheckParameters + } + return nil +} + +func (x *Operation) GetAssertionsParameters() *RunAssertionsParameters { + if x != nil { + return x.AssertionsParameters + } + return nil +} + +func (x *Operation) GetValidationParameters() *RunValidationParameters { + if x != nil { + return x.ValidationParameters + } + return nil +} + +func (x *Operation) GetFormatSchemaParameters() *FormatSchemaParameters { + if x != nil { + return x.FormatSchemaParameters + } + return nil +} + +func (x *Operation) GetSchemaWarningsParameters() *SchemaWarningsParameters { + if x != nil { + return x.SchemaWarningsParameters + } + return nil +} + +// OperationsResults holds the results for the operations, indexed by the operation. +type OperationsResults struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Results map[uint64]*OperationResult `protobuf:"bytes,1,rep,name=results,proto3" json:"results,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` +} + +func (x *OperationsResults) Reset() { + *x = OperationsResults{} + if protoimpl.UnsafeEnabled { + mi := &file_developer_v1_developer_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *OperationsResults) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*OperationsResults) ProtoMessage() {} + +func (x *OperationsResults) ProtoReflect() protoreflect.Message { + mi := &file_developer_v1_developer_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use OperationsResults.ProtoReflect.Descriptor instead. +func (*OperationsResults) Descriptor() ([]byte, []int) { + return file_developer_v1_developer_proto_rawDescGZIP(), []int{4} +} + +func (x *OperationsResults) GetResults() map[uint64]*OperationResult { + if x != nil { + return x.Results + } + return nil +} + +// OperationResult contains the result data given to the callback for an operation. +type OperationResult struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + CheckResult *CheckOperationsResult `protobuf:"bytes,1,opt,name=check_result,json=checkResult,proto3" json:"check_result,omitempty"` + AssertionsResult *RunAssertionsResult `protobuf:"bytes,2,opt,name=assertions_result,json=assertionsResult,proto3" json:"assertions_result,omitempty"` + ValidationResult *RunValidationResult `protobuf:"bytes,3,opt,name=validation_result,json=validationResult,proto3" json:"validation_result,omitempty"` + FormatSchemaResult *FormatSchemaResult `protobuf:"bytes,4,opt,name=format_schema_result,json=formatSchemaResult,proto3" json:"format_schema_result,omitempty"` + SchemaWarningsResult *SchemaWarningsResult `protobuf:"bytes,5,opt,name=schema_warnings_result,json=schemaWarningsResult,proto3" json:"schema_warnings_result,omitempty"` +} + +func (x *OperationResult) Reset() { + *x = OperationResult{} + if protoimpl.UnsafeEnabled { + mi := &file_developer_v1_developer_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *OperationResult) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*OperationResult) ProtoMessage() {} + +func (x *OperationResult) ProtoReflect() protoreflect.Message { + mi := &file_developer_v1_developer_proto_msgTypes[5] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use OperationResult.ProtoReflect.Descriptor instead. +func (*OperationResult) Descriptor() ([]byte, []int) { + return file_developer_v1_developer_proto_rawDescGZIP(), []int{5} +} + +func (x *OperationResult) GetCheckResult() *CheckOperationsResult { + if x != nil { + return x.CheckResult + } + return nil +} + +func (x *OperationResult) GetAssertionsResult() *RunAssertionsResult { + if x != nil { + return x.AssertionsResult + } + return nil +} + +func (x *OperationResult) GetValidationResult() *RunValidationResult { + if x != nil { + return x.ValidationResult + } + return nil +} + +func (x *OperationResult) GetFormatSchemaResult() *FormatSchemaResult { + if x != nil { + return x.FormatSchemaResult + } + return nil +} + +func (x *OperationResult) GetSchemaWarningsResult() *SchemaWarningsResult { + if x != nil { + return x.SchemaWarningsResult + } + return nil +} + +// DeveloperWarning represents a single warning raised by the development package. +type DeveloperWarning struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // message is the message for the developer warning. + Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"` + // line is the 1-indexed line for the developer warning. + Line uint32 `protobuf:"varint,2,opt,name=line,proto3" json:"line,omitempty"` + // column is the 1-indexed column on the line for the developer warning. + Column uint32 `protobuf:"varint,3,opt,name=column,proto3" json:"column,omitempty"` + // source_code is the source code for the developer warning, if any. + SourceCode string `protobuf:"bytes,4,opt,name=source_code,json=sourceCode,proto3" json:"source_code,omitempty"` +} + +func (x *DeveloperWarning) Reset() { + *x = DeveloperWarning{} + if protoimpl.UnsafeEnabled { + mi := &file_developer_v1_developer_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DeveloperWarning) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DeveloperWarning) ProtoMessage() {} + +func (x *DeveloperWarning) ProtoReflect() protoreflect.Message { + mi := &file_developer_v1_developer_proto_msgTypes[6] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DeveloperWarning.ProtoReflect.Descriptor instead. +func (*DeveloperWarning) Descriptor() ([]byte, []int) { + return file_developer_v1_developer_proto_rawDescGZIP(), []int{6} +} + +func (x *DeveloperWarning) GetMessage() string { + if x != nil { + return x.Message + } + return "" +} + +func (x *DeveloperWarning) GetLine() uint32 { + if x != nil { + return x.Line + } + return 0 +} + +func (x *DeveloperWarning) GetColumn() uint32 { + if x != nil { + return x.Column + } + return 0 +} + +func (x *DeveloperWarning) GetSourceCode() string { + if x != nil { + return x.SourceCode + } + return "" +} + +// DeveloperError represents a single error raised by the development package. Unlike an internal +// error, it represents an issue with the entered information by the calling developer. +type DeveloperError struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"` + // line is the 1-indexed line for the developer error. + Line uint32 `protobuf:"varint,2,opt,name=line,proto3" json:"line,omitempty"` + // column is the 1-indexed column on the line for the developer error. + Column uint32 `protobuf:"varint,3,opt,name=column,proto3" json:"column,omitempty"` + // source is the source location of the error. + Source DeveloperError_Source `protobuf:"varint,4,opt,name=source,proto3,enum=developer.v1.DeveloperError_Source" json:"source,omitempty"` + Kind DeveloperError_ErrorKind `protobuf:"varint,5,opt,name=kind,proto3,enum=developer.v1.DeveloperError_ErrorKind" json:"kind,omitempty"` + Path []string `protobuf:"bytes,6,rep,name=path,proto3" json:"path,omitempty"` + // context holds the context for the error. For schema issues, this will be the + // name of the object type. For relationship issues, the full relationship string. + Context string `protobuf:"bytes,7,opt,name=context,proto3" json:"context,omitempty"` + // debug_information is the debug information for the dispatched check, if this error was raised + // due to an assertion failure. + CheckDebugInformation *v11.DebugInformation `protobuf:"bytes,8,opt,name=check_debug_information,json=checkDebugInformation,proto3" json:"check_debug_information,omitempty"` + // resolved_debug_information is the V1 API debug information for the check, if this error was raised + // due to an assertion failure. + CheckResolvedDebugInformation *v12.DebugInformation `protobuf:"bytes,9,opt,name=check_resolved_debug_information,json=checkResolvedDebugInformation,proto3" json:"check_resolved_debug_information,omitempty"` +} + +func (x *DeveloperError) Reset() { + *x = DeveloperError{} + if protoimpl.UnsafeEnabled { + mi := &file_developer_v1_developer_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DeveloperError) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DeveloperError) ProtoMessage() {} + +func (x *DeveloperError) ProtoReflect() protoreflect.Message { + mi := &file_developer_v1_developer_proto_msgTypes[7] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DeveloperError.ProtoReflect.Descriptor instead. +func (*DeveloperError) Descriptor() ([]byte, []int) { + return file_developer_v1_developer_proto_rawDescGZIP(), []int{7} +} + +func (x *DeveloperError) GetMessage() string { + if x != nil { + return x.Message + } + return "" +} + +func (x *DeveloperError) GetLine() uint32 { + if x != nil { + return x.Line + } + return 0 +} + +func (x *DeveloperError) GetColumn() uint32 { + if x != nil { + return x.Column + } + return 0 +} + +func (x *DeveloperError) GetSource() DeveloperError_Source { + if x != nil { + return x.Source + } + return DeveloperError_UNKNOWN_SOURCE +} + +func (x *DeveloperError) GetKind() DeveloperError_ErrorKind { + if x != nil { + return x.Kind + } + return DeveloperError_UNKNOWN_KIND +} + +func (x *DeveloperError) GetPath() []string { + if x != nil { + return x.Path + } + return nil +} + +func (x *DeveloperError) GetContext() string { + if x != nil { + return x.Context + } + return "" +} + +func (x *DeveloperError) GetCheckDebugInformation() *v11.DebugInformation { + if x != nil { + return x.CheckDebugInformation + } + return nil +} + +func (x *DeveloperError) GetCheckResolvedDebugInformation() *v12.DebugInformation { + if x != nil { + return x.CheckResolvedDebugInformation + } + return nil +} + +// DeveloperErrors represents the developer error(s) found after the run has completed. +type DeveloperErrors struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // input_errors are those error(s) in the schema, relationships, or assertions inputted by the developer. + InputErrors []*DeveloperError `protobuf:"bytes,1,rep,name=input_errors,json=inputErrors,proto3" json:"input_errors,omitempty"` +} + +func (x *DeveloperErrors) Reset() { + *x = DeveloperErrors{} + if protoimpl.UnsafeEnabled { + mi := &file_developer_v1_developer_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DeveloperErrors) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DeveloperErrors) ProtoMessage() {} + +func (x *DeveloperErrors) ProtoReflect() protoreflect.Message { + mi := &file_developer_v1_developer_proto_msgTypes[8] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DeveloperErrors.ProtoReflect.Descriptor instead. +func (*DeveloperErrors) Descriptor() ([]byte, []int) { + return file_developer_v1_developer_proto_rawDescGZIP(), []int{8} +} + +func (x *DeveloperErrors) GetInputErrors() []*DeveloperError { + if x != nil { + return x.InputErrors + } + return nil +} + +// CheckOperationParameters are the parameters for a `check` operation. +type CheckOperationParameters struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Resource *v1.ObjectAndRelation `protobuf:"bytes,1,opt,name=resource,proto3" json:"resource,omitempty"` + Subject *v1.ObjectAndRelation `protobuf:"bytes,2,opt,name=subject,proto3" json:"subject,omitempty"` + // * caveat_context consists of any named values that are defined at write time for the caveat expression * + CaveatContext *structpb.Struct `protobuf:"bytes,3,opt,name=caveat_context,json=caveatContext,proto3" json:"caveat_context,omitempty"` +} + +func (x *CheckOperationParameters) Reset() { + *x = CheckOperationParameters{} + if protoimpl.UnsafeEnabled { + mi := &file_developer_v1_developer_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CheckOperationParameters) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CheckOperationParameters) ProtoMessage() {} + +func (x *CheckOperationParameters) ProtoReflect() protoreflect.Message { + mi := &file_developer_v1_developer_proto_msgTypes[9] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use CheckOperationParameters.ProtoReflect.Descriptor instead. +func (*CheckOperationParameters) Descriptor() ([]byte, []int) { + return file_developer_v1_developer_proto_rawDescGZIP(), []int{9} +} + +func (x *CheckOperationParameters) GetResource() *v1.ObjectAndRelation { + if x != nil { + return x.Resource + } + return nil +} + +func (x *CheckOperationParameters) GetSubject() *v1.ObjectAndRelation { + if x != nil { + return x.Subject + } + return nil +} + +func (x *CheckOperationParameters) GetCaveatContext() *structpb.Struct { + if x != nil { + return x.CaveatContext + } + return nil +} + +// CheckOperationsResult is the result for a `check` operation. +type CheckOperationsResult struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Membership CheckOperationsResult_Membership `protobuf:"varint,1,opt,name=membership,proto3,enum=developer.v1.CheckOperationsResult_Membership" json:"membership,omitempty"` + // check_error is the error raised by the check, if any. + CheckError *DeveloperError `protobuf:"bytes,2,opt,name=check_error,json=checkError,proto3" json:"check_error,omitempty"` + // debug_information is the debug information for the check. + DebugInformation *v11.DebugInformation `protobuf:"bytes,3,opt,name=debug_information,json=debugInformation,proto3" json:"debug_information,omitempty"` + // partial_caveat_info holds information a partial evaluation of a caveat. + PartialCaveatInfo *PartialCaveatInfo `protobuf:"bytes,4,opt,name=partial_caveat_info,json=partialCaveatInfo,proto3" json:"partial_caveat_info,omitempty"` + // resolved_debug_information is the V1 API debug information for the check. + ResolvedDebugInformation *v12.DebugInformation `protobuf:"bytes,5,opt,name=resolved_debug_information,json=resolvedDebugInformation,proto3" json:"resolved_debug_information,omitempty"` +} + +func (x *CheckOperationsResult) Reset() { + *x = CheckOperationsResult{} + if protoimpl.UnsafeEnabled { + mi := &file_developer_v1_developer_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CheckOperationsResult) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CheckOperationsResult) ProtoMessage() {} + +func (x *CheckOperationsResult) ProtoReflect() protoreflect.Message { + mi := &file_developer_v1_developer_proto_msgTypes[10] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use CheckOperationsResult.ProtoReflect.Descriptor instead. +func (*CheckOperationsResult) Descriptor() ([]byte, []int) { + return file_developer_v1_developer_proto_rawDescGZIP(), []int{10} +} + +func (x *CheckOperationsResult) GetMembership() CheckOperationsResult_Membership { + if x != nil { + return x.Membership + } + return CheckOperationsResult_UNKNOWN +} + +func (x *CheckOperationsResult) GetCheckError() *DeveloperError { + if x != nil { + return x.CheckError + } + return nil +} + +func (x *CheckOperationsResult) GetDebugInformation() *v11.DebugInformation { + if x != nil { + return x.DebugInformation + } + return nil +} + +func (x *CheckOperationsResult) GetPartialCaveatInfo() *PartialCaveatInfo { + if x != nil { + return x.PartialCaveatInfo + } + return nil +} + +func (x *CheckOperationsResult) GetResolvedDebugInformation() *v12.DebugInformation { + if x != nil { + return x.ResolvedDebugInformation + } + return nil +} + +// PartialCaveatInfo carries information necessary for the client to take action +// in the event a response contains a partially evaluated caveat +type PartialCaveatInfo struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // missing_required_context is a list of one or more fields that were missing and prevented caveats + // from being fully evaluated + MissingRequiredContext []string `protobuf:"bytes,1,rep,name=missing_required_context,json=missingRequiredContext,proto3" json:"missing_required_context,omitempty"` +} + +func (x *PartialCaveatInfo) Reset() { + *x = PartialCaveatInfo{} + if protoimpl.UnsafeEnabled { + mi := &file_developer_v1_developer_proto_msgTypes[11] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *PartialCaveatInfo) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PartialCaveatInfo) ProtoMessage() {} + +func (x *PartialCaveatInfo) ProtoReflect() protoreflect.Message { + mi := &file_developer_v1_developer_proto_msgTypes[11] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use PartialCaveatInfo.ProtoReflect.Descriptor instead. +func (*PartialCaveatInfo) Descriptor() ([]byte, []int) { + return file_developer_v1_developer_proto_rawDescGZIP(), []int{11} +} + +func (x *PartialCaveatInfo) GetMissingRequiredContext() []string { + if x != nil { + return x.MissingRequiredContext + } + return nil +} + +// RunAssertionsParameters are the parameters for a `runAssertions` operation. +type RunAssertionsParameters struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // assertions_yaml are the assertions, in YAML form, to be run. + AssertionsYaml string `protobuf:"bytes,1,opt,name=assertions_yaml,json=assertionsYaml,proto3" json:"assertions_yaml,omitempty"` +} + +func (x *RunAssertionsParameters) Reset() { + *x = RunAssertionsParameters{} + if protoimpl.UnsafeEnabled { + mi := &file_developer_v1_developer_proto_msgTypes[12] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *RunAssertionsParameters) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RunAssertionsParameters) ProtoMessage() {} + +func (x *RunAssertionsParameters) ProtoReflect() protoreflect.Message { + mi := &file_developer_v1_developer_proto_msgTypes[12] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use RunAssertionsParameters.ProtoReflect.Descriptor instead. +func (*RunAssertionsParameters) Descriptor() ([]byte, []int) { + return file_developer_v1_developer_proto_rawDescGZIP(), []int{12} +} + +func (x *RunAssertionsParameters) GetAssertionsYaml() string { + if x != nil { + return x.AssertionsYaml + } + return "" +} + +// RunAssertionsResult is the result for a `runAssertions` operation. +type RunAssertionsResult struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // input_error is an error in the given YAML. + InputError *DeveloperError `protobuf:"bytes,1,opt,name=input_error,json=inputError,proto3" json:"input_error,omitempty"` + // validation_errors are the validation errors which occurred, if any. + ValidationErrors []*DeveloperError `protobuf:"bytes,2,rep,name=validation_errors,json=validationErrors,proto3" json:"validation_errors,omitempty"` +} + +func (x *RunAssertionsResult) Reset() { + *x = RunAssertionsResult{} + if protoimpl.UnsafeEnabled { + mi := &file_developer_v1_developer_proto_msgTypes[13] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *RunAssertionsResult) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RunAssertionsResult) ProtoMessage() {} + +func (x *RunAssertionsResult) ProtoReflect() protoreflect.Message { + mi := &file_developer_v1_developer_proto_msgTypes[13] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use RunAssertionsResult.ProtoReflect.Descriptor instead. +func (*RunAssertionsResult) Descriptor() ([]byte, []int) { + return file_developer_v1_developer_proto_rawDescGZIP(), []int{13} +} + +func (x *RunAssertionsResult) GetInputError() *DeveloperError { + if x != nil { + return x.InputError + } + return nil +} + +func (x *RunAssertionsResult) GetValidationErrors() []*DeveloperError { + if x != nil { + return x.ValidationErrors + } + return nil +} + +// RunValidationParameters are the parameters for a `runValidation` operation. +type RunValidationParameters struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // validation_yaml is the expected relations validation, in YAML form, to be run. + ValidationYaml string `protobuf:"bytes,1,opt,name=validation_yaml,json=validationYaml,proto3" json:"validation_yaml,omitempty"` +} + +func (x *RunValidationParameters) Reset() { + *x = RunValidationParameters{} + if protoimpl.UnsafeEnabled { + mi := &file_developer_v1_developer_proto_msgTypes[14] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *RunValidationParameters) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RunValidationParameters) ProtoMessage() {} + +func (x *RunValidationParameters) ProtoReflect() protoreflect.Message { + mi := &file_developer_v1_developer_proto_msgTypes[14] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use RunValidationParameters.ProtoReflect.Descriptor instead. +func (*RunValidationParameters) Descriptor() ([]byte, []int) { + return file_developer_v1_developer_proto_rawDescGZIP(), []int{14} +} + +func (x *RunValidationParameters) GetValidationYaml() string { + if x != nil { + return x.ValidationYaml + } + return "" +} + +// RunValidationResult is the result for a `runValidation` operation. +type RunValidationResult struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // input_error is an error in the given YAML. + InputError *DeveloperError `protobuf:"bytes,1,opt,name=input_error,json=inputError,proto3" json:"input_error,omitempty"` + // updated_validation_yaml contains the generated and updated validation YAML for the expected + // relations tab. + UpdatedValidationYaml string `protobuf:"bytes,2,opt,name=updated_validation_yaml,json=updatedValidationYaml,proto3" json:"updated_validation_yaml,omitempty"` + // validation_errors are the validation errors which occurred, if any. + ValidationErrors []*DeveloperError `protobuf:"bytes,3,rep,name=validation_errors,json=validationErrors,proto3" json:"validation_errors,omitempty"` +} + +func (x *RunValidationResult) Reset() { + *x = RunValidationResult{} + if protoimpl.UnsafeEnabled { + mi := &file_developer_v1_developer_proto_msgTypes[15] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *RunValidationResult) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RunValidationResult) ProtoMessage() {} + +func (x *RunValidationResult) ProtoReflect() protoreflect.Message { + mi := &file_developer_v1_developer_proto_msgTypes[15] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use RunValidationResult.ProtoReflect.Descriptor instead. +func (*RunValidationResult) Descriptor() ([]byte, []int) { + return file_developer_v1_developer_proto_rawDescGZIP(), []int{15} +} + +func (x *RunValidationResult) GetInputError() *DeveloperError { + if x != nil { + return x.InputError + } + return nil +} + +func (x *RunValidationResult) GetUpdatedValidationYaml() string { + if x != nil { + return x.UpdatedValidationYaml + } + return "" +} + +func (x *RunValidationResult) GetValidationErrors() []*DeveloperError { + if x != nil { + return x.ValidationErrors + } + return nil +} + +// FormatSchemaParameters are the parameters for a `formatSchema` operation. +type FormatSchemaParameters struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *FormatSchemaParameters) Reset() { + *x = FormatSchemaParameters{} + if protoimpl.UnsafeEnabled { + mi := &file_developer_v1_developer_proto_msgTypes[16] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *FormatSchemaParameters) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*FormatSchemaParameters) ProtoMessage() {} + +func (x *FormatSchemaParameters) ProtoReflect() protoreflect.Message { + mi := &file_developer_v1_developer_proto_msgTypes[16] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use FormatSchemaParameters.ProtoReflect.Descriptor instead. +func (*FormatSchemaParameters) Descriptor() ([]byte, []int) { + return file_developer_v1_developer_proto_rawDescGZIP(), []int{16} +} + +// FormatSchemaResult is the result of the `formatSchema` operation. +type FormatSchemaResult struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + FormattedSchema string `protobuf:"bytes,1,opt,name=formatted_schema,json=formattedSchema,proto3" json:"formatted_schema,omitempty"` +} + +func (x *FormatSchemaResult) Reset() { + *x = FormatSchemaResult{} + if protoimpl.UnsafeEnabled { + mi := &file_developer_v1_developer_proto_msgTypes[17] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *FormatSchemaResult) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*FormatSchemaResult) ProtoMessage() {} + +func (x *FormatSchemaResult) ProtoReflect() protoreflect.Message { + mi := &file_developer_v1_developer_proto_msgTypes[17] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use FormatSchemaResult.ProtoReflect.Descriptor instead. +func (*FormatSchemaResult) Descriptor() ([]byte, []int) { + return file_developer_v1_developer_proto_rawDescGZIP(), []int{17} +} + +func (x *FormatSchemaResult) GetFormattedSchema() string { + if x != nil { + return x.FormattedSchema + } + return "" +} + +// SchemaWarningsParameters are the parameters for a `schemaWarnings` operation. +type SchemaWarningsParameters struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *SchemaWarningsParameters) Reset() { + *x = SchemaWarningsParameters{} + if protoimpl.UnsafeEnabled { + mi := &file_developer_v1_developer_proto_msgTypes[18] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *SchemaWarningsParameters) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SchemaWarningsParameters) ProtoMessage() {} + +func (x *SchemaWarningsParameters) ProtoReflect() protoreflect.Message { + mi := &file_developer_v1_developer_proto_msgTypes[18] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SchemaWarningsParameters.ProtoReflect.Descriptor instead. +func (*SchemaWarningsParameters) Descriptor() ([]byte, []int) { + return file_developer_v1_developer_proto_rawDescGZIP(), []int{18} +} + +// SchemaWarningsResult is the result of the `schemaWarnings` operation. +type SchemaWarningsResult struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Warnings []*DeveloperWarning `protobuf:"bytes,1,rep,name=warnings,proto3" json:"warnings,omitempty"` +} + +func (x *SchemaWarningsResult) Reset() { + *x = SchemaWarningsResult{} + if protoimpl.UnsafeEnabled { + mi := &file_developer_v1_developer_proto_msgTypes[19] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *SchemaWarningsResult) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SchemaWarningsResult) ProtoMessage() {} + +func (x *SchemaWarningsResult) ProtoReflect() protoreflect.Message { + mi := &file_developer_v1_developer_proto_msgTypes[19] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SchemaWarningsResult.ProtoReflect.Descriptor instead. +func (*SchemaWarningsResult) Descriptor() ([]byte, []int) { + return file_developer_v1_developer_proto_rawDescGZIP(), []int{19} +} + +func (x *SchemaWarningsResult) GetWarnings() []*DeveloperWarning { + if x != nil { + return x.Warnings + } + return nil +} + +var File_developer_v1_developer_proto protoreflect.FileDescriptor + +var file_developer_v1_developer_proto_rawDesc = []byte{ + 0x0a, 0x1c, 0x64, 0x65, 0x76, 0x65, 0x6c, 0x6f, 0x70, 0x65, 0x72, 0x2f, 0x76, 0x31, 0x2f, 0x64, + 0x65, 0x76, 0x65, 0x6c, 0x6f, 0x70, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0c, + 0x64, 0x65, 0x76, 0x65, 0x6c, 0x6f, 0x70, 0x65, 0x72, 0x2e, 0x76, 0x31, 0x1a, 0x1a, 0x61, 0x75, + 0x74, 0x68, 0x7a, 0x65, 0x64, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76, 0x31, 0x2f, 0x64, 0x65, 0x62, + 0x75, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x12, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x76, + 0x31, 0x2f, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1a, 0x64, 0x69, + 0x73, 0x70, 0x61, 0x74, 0x63, 0x68, 0x2f, 0x76, 0x31, 0x2f, 0x64, 0x69, 0x73, 0x70, 0x61, 0x74, + 0x63, 0x68, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, + 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x17, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, + 0x2f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, + 0x83, 0x01, 0x0a, 0x10, 0x44, 0x65, 0x76, 0x65, 0x6c, 0x6f, 0x70, 0x65, 0x72, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x12, 0x36, 0x0a, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x64, 0x65, 0x76, 0x65, 0x6c, 0x6f, 0x70, 0x65, + 0x72, 0x2e, 0x76, 0x31, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x43, 0x6f, 0x6e, 0x74, + 0x65, 0x78, 0x74, 0x52, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x12, 0x37, 0x0a, 0x0a, + 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, + 0x32, 0x17, 0x2e, 0x64, 0x65, 0x76, 0x65, 0x6c, 0x6f, 0x70, 0x65, 0x72, 0x2e, 0x76, 0x31, 0x2e, + 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0a, 0x6f, 0x70, 0x65, 0x72, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x22, 0xd4, 0x01, 0x0a, 0x11, 0x44, 0x65, 0x76, 0x65, 0x6c, 0x6f, + 0x70, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x25, 0x0a, 0x0e, 0x69, + 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x5f, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x0d, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x45, 0x72, 0x72, + 0x6f, 0x72, 0x12, 0x48, 0x0a, 0x10, 0x64, 0x65, 0x76, 0x65, 0x6c, 0x6f, 0x70, 0x65, 0x72, 0x5f, + 0x65, 0x72, 0x72, 0x6f, 0x72, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x64, + 0x65, 0x76, 0x65, 0x6c, 0x6f, 0x70, 0x65, 0x72, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x65, 0x76, 0x65, + 0x6c, 0x6f, 0x70, 0x65, 0x72, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x73, 0x52, 0x0f, 0x64, 0x65, 0x76, + 0x65, 0x6c, 0x6f, 0x70, 0x65, 0x72, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x73, 0x12, 0x4e, 0x0a, 0x12, + 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x5f, 0x72, 0x65, 0x73, 0x75, 0x6c, + 0x74, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x64, 0x65, 0x76, 0x65, 0x6c, + 0x6f, 0x70, 0x65, 0x72, 0x2e, 0x76, 0x31, 0x2e, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, + 0x6e, 0x73, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x73, 0x52, 0x11, 0x6f, 0x70, 0x65, 0x72, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x73, 0x22, 0x66, 0x0a, 0x0e, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x12, 0x16, + 0x0a, 0x06, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, + 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x12, 0x3c, 0x0a, 0x0d, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x73, 0x68, 0x69, 0x70, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x16, 0x2e, + 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x52, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x54, 0x75, 0x70, 0x6c, 0x65, 0x52, 0x0d, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, + 0x68, 0x69, 0x70, 0x73, 0x22, 0xdc, 0x03, 0x0a, 0x09, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x12, 0x51, 0x0a, 0x10, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x5f, 0x70, 0x61, 0x72, 0x61, + 0x6d, 0x65, 0x74, 0x65, 0x72, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x64, + 0x65, 0x76, 0x65, 0x6c, 0x6f, 0x70, 0x65, 0x72, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x68, 0x65, 0x63, + 0x6b, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x65, + 0x74, 0x65, 0x72, 0x73, 0x52, 0x0f, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x50, 0x61, 0x72, 0x61, 0x6d, + 0x65, 0x74, 0x65, 0x72, 0x73, 0x12, 0x5a, 0x0a, 0x15, 0x61, 0x73, 0x73, 0x65, 0x72, 0x74, 0x69, + 0x6f, 0x6e, 0x73, 0x5f, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x73, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x64, 0x65, 0x76, 0x65, 0x6c, 0x6f, 0x70, 0x65, 0x72, + 0x2e, 0x76, 0x31, 0x2e, 0x52, 0x75, 0x6e, 0x41, 0x73, 0x73, 0x65, 0x72, 0x74, 0x69, 0x6f, 0x6e, + 0x73, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x73, 0x52, 0x14, 0x61, 0x73, 0x73, + 0x65, 0x72, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, + 0x73, 0x12, 0x5a, 0x0a, 0x15, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, + 0x70, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x25, 0x2e, 0x64, 0x65, 0x76, 0x65, 0x6c, 0x6f, 0x70, 0x65, 0x72, 0x2e, 0x76, 0x31, 0x2e, + 0x52, 0x75, 0x6e, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x61, 0x72, + 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x73, 0x52, 0x14, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x73, 0x12, 0x5e, 0x0a, + 0x18, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x5f, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x5f, 0x70, + 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x24, 0x2e, 0x64, 0x65, 0x76, 0x65, 0x6c, 0x6f, 0x70, 0x65, 0x72, 0x2e, 0x76, 0x31, 0x2e, 0x46, + 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x50, 0x61, 0x72, 0x61, 0x6d, + 0x65, 0x74, 0x65, 0x72, 0x73, 0x52, 0x16, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x53, 0x63, 0x68, + 0x65, 0x6d, 0x61, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x73, 0x12, 0x64, 0x0a, + 0x1a, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x5f, 0x77, 0x61, 0x72, 0x6e, 0x69, 0x6e, 0x67, 0x73, + 0x5f, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x73, 0x18, 0x05, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x26, 0x2e, 0x64, 0x65, 0x76, 0x65, 0x6c, 0x6f, 0x70, 0x65, 0x72, 0x2e, 0x76, 0x31, + 0x2e, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x57, 0x61, 0x72, 0x6e, 0x69, 0x6e, 0x67, 0x73, 0x50, + 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x73, 0x52, 0x18, 0x73, 0x63, 0x68, 0x65, 0x6d, + 0x61, 0x57, 0x61, 0x72, 0x6e, 0x69, 0x6e, 0x67, 0x73, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, + 0x65, 0x72, 0x73, 0x22, 0xb6, 0x01, 0x0a, 0x11, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, + 0x6e, 0x73, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x73, 0x12, 0x46, 0x0a, 0x07, 0x72, 0x65, 0x73, + 0x75, 0x6c, 0x74, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2c, 0x2e, 0x64, 0x65, 0x76, + 0x65, 0x6c, 0x6f, 0x70, 0x65, 0x72, 0x2e, 0x76, 0x31, 0x2e, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x73, 0x2e, 0x52, 0x65, 0x73, 0x75, + 0x6c, 0x74, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x07, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, + 0x73, 0x1a, 0x59, 0x0a, 0x0c, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x73, 0x45, 0x6e, 0x74, 0x72, + 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x03, + 0x6b, 0x65, 0x79, 0x12, 0x33, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x64, 0x65, 0x76, 0x65, 0x6c, 0x6f, 0x70, 0x65, 0x72, 0x2e, 0x76, + 0x31, 0x2e, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x75, 0x6c, + 0x74, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0xa7, 0x03, 0x0a, + 0x0f, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, + 0x12, 0x46, 0x0a, 0x0c, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x5f, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x64, 0x65, 0x76, 0x65, 0x6c, 0x6f, 0x70, + 0x65, 0x72, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x4f, 0x70, 0x65, 0x72, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x52, 0x0b, 0x63, 0x68, 0x65, + 0x63, 0x6b, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x4e, 0x0a, 0x11, 0x61, 0x73, 0x73, 0x65, + 0x72, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x5f, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x64, 0x65, 0x76, 0x65, 0x6c, 0x6f, 0x70, 0x65, 0x72, 0x2e, + 0x76, 0x31, 0x2e, 0x52, 0x75, 0x6e, 0x41, 0x73, 0x73, 0x65, 0x72, 0x74, 0x69, 0x6f, 0x6e, 0x73, + 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x52, 0x10, 0x61, 0x73, 0x73, 0x65, 0x72, 0x74, 0x69, 0x6f, + 0x6e, 0x73, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x4e, 0x0a, 0x11, 0x76, 0x61, 0x6c, 0x69, + 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x18, 0x03, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x64, 0x65, 0x76, 0x65, 0x6c, 0x6f, 0x70, 0x65, 0x72, 0x2e, + 0x76, 0x31, 0x2e, 0x52, 0x75, 0x6e, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x52, 0x10, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x52, 0x0a, 0x14, 0x66, 0x6f, 0x72, 0x6d, + 0x61, 0x74, 0x5f, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x5f, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, + 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x64, 0x65, 0x76, 0x65, 0x6c, 0x6f, 0x70, + 0x65, 0x72, 0x2e, 0x76, 0x31, 0x2e, 0x46, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x53, 0x63, 0x68, 0x65, + 0x6d, 0x61, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x52, 0x12, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, + 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x58, 0x0a, 0x16, + 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x5f, 0x77, 0x61, 0x72, 0x6e, 0x69, 0x6e, 0x67, 0x73, 0x5f, + 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x64, + 0x65, 0x76, 0x65, 0x6c, 0x6f, 0x70, 0x65, 0x72, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x63, 0x68, 0x65, + 0x6d, 0x61, 0x57, 0x61, 0x72, 0x6e, 0x69, 0x6e, 0x67, 0x73, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, + 0x52, 0x14, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x57, 0x61, 0x72, 0x6e, 0x69, 0x6e, 0x67, 0x73, + 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x22, 0x79, 0x0a, 0x10, 0x44, 0x65, 0x76, 0x65, 0x6c, 0x6f, + 0x70, 0x65, 0x72, 0x57, 0x61, 0x72, 0x6e, 0x69, 0x6e, 0x67, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, + 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, + 0x73, 0x61, 0x67, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6c, 0x69, 0x6e, 0x65, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x0d, 0x52, 0x04, 0x6c, 0x69, 0x6e, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x63, 0x6f, 0x6c, 0x75, + 0x6d, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x63, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, + 0x12, 0x1f, 0x0a, 0x0b, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, + 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x43, 0x6f, 0x64, + 0x65, 0x22, 0xc6, 0x06, 0x0a, 0x0e, 0x44, 0x65, 0x76, 0x65, 0x6c, 0x6f, 0x70, 0x65, 0x72, 0x45, + 0x72, 0x72, 0x6f, 0x72, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x12, + 0x0a, 0x04, 0x6c, 0x69, 0x6e, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x04, 0x6c, 0x69, + 0x6e, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x63, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x18, 0x03, 0x20, 0x01, + 0x28, 0x0d, 0x52, 0x06, 0x63, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x12, 0x3b, 0x0a, 0x06, 0x73, 0x6f, + 0x75, 0x72, 0x63, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x23, 0x2e, 0x64, 0x65, 0x76, + 0x65, 0x6c, 0x6f, 0x70, 0x65, 0x72, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x65, 0x76, 0x65, 0x6c, 0x6f, + 0x70, 0x65, 0x72, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x2e, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, + 0x06, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x12, 0x3a, 0x0a, 0x04, 0x6b, 0x69, 0x6e, 0x64, 0x18, + 0x05, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x26, 0x2e, 0x64, 0x65, 0x76, 0x65, 0x6c, 0x6f, 0x70, 0x65, + 0x72, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x65, 0x76, 0x65, 0x6c, 0x6f, 0x70, 0x65, 0x72, 0x45, 0x72, + 0x72, 0x6f, 0x72, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x4b, 0x69, 0x6e, 0x64, 0x52, 0x04, 0x6b, + 0x69, 0x6e, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0x06, 0x20, 0x03, 0x28, + 0x09, 0x52, 0x04, 0x70, 0x61, 0x74, 0x68, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, + 0x78, 0x74, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, + 0x74, 0x12, 0x55, 0x0a, 0x17, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x5f, 0x64, 0x65, 0x62, 0x75, 0x67, + 0x5f, 0x69, 0x6e, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x08, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x64, 0x69, 0x73, 0x70, 0x61, 0x74, 0x63, 0x68, 0x2e, 0x76, 0x31, + 0x2e, 0x44, 0x65, 0x62, 0x75, 0x67, 0x49, 0x6e, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x69, 0x6f, + 0x6e, 0x52, 0x15, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x44, 0x65, 0x62, 0x75, 0x67, 0x49, 0x6e, 0x66, + 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x69, 0x0a, 0x20, 0x63, 0x68, 0x65, 0x63, + 0x6b, 0x5f, 0x72, 0x65, 0x73, 0x6f, 0x6c, 0x76, 0x65, 0x64, 0x5f, 0x64, 0x65, 0x62, 0x75, 0x67, + 0x5f, 0x69, 0x6e, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x09, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x61, 0x75, 0x74, 0x68, 0x7a, 0x65, 0x64, 0x2e, 0x61, 0x70, 0x69, + 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x65, 0x62, 0x75, 0x67, 0x49, 0x6e, 0x66, 0x6f, 0x72, 0x6d, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x1d, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x6f, 0x6c, + 0x76, 0x65, 0x64, 0x44, 0x65, 0x62, 0x75, 0x67, 0x49, 0x6e, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x22, 0x6f, 0x0a, 0x06, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x12, 0x12, 0x0a, + 0x0e, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x5f, 0x53, 0x4f, 0x55, 0x52, 0x43, 0x45, 0x10, + 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x53, 0x43, 0x48, 0x45, 0x4d, 0x41, 0x10, 0x01, 0x12, 0x10, 0x0a, + 0x0c, 0x52, 0x45, 0x4c, 0x41, 0x54, 0x49, 0x4f, 0x4e, 0x53, 0x48, 0x49, 0x50, 0x10, 0x02, 0x12, + 0x13, 0x0a, 0x0f, 0x56, 0x41, 0x4c, 0x49, 0x44, 0x41, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x59, 0x41, + 0x4d, 0x4c, 0x10, 0x03, 0x12, 0x0f, 0x0a, 0x0b, 0x43, 0x48, 0x45, 0x43, 0x4b, 0x5f, 0x57, 0x41, + 0x54, 0x43, 0x48, 0x10, 0x04, 0x12, 0x0d, 0x0a, 0x09, 0x41, 0x53, 0x53, 0x45, 0x52, 0x54, 0x49, + 0x4f, 0x4e, 0x10, 0x05, 0x22, 0x93, 0x02, 0x0a, 0x09, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x4b, 0x69, + 0x6e, 0x64, 0x12, 0x10, 0x0a, 0x0c, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x5f, 0x4b, 0x49, + 0x4e, 0x44, 0x10, 0x00, 0x12, 0x0f, 0x0a, 0x0b, 0x50, 0x41, 0x52, 0x53, 0x45, 0x5f, 0x45, 0x52, + 0x52, 0x4f, 0x52, 0x10, 0x01, 0x12, 0x10, 0x0a, 0x0c, 0x53, 0x43, 0x48, 0x45, 0x4d, 0x41, 0x5f, + 0x49, 0x53, 0x53, 0x55, 0x45, 0x10, 0x02, 0x12, 0x1a, 0x0a, 0x16, 0x44, 0x55, 0x50, 0x4c, 0x49, + 0x43, 0x41, 0x54, 0x45, 0x5f, 0x52, 0x45, 0x4c, 0x41, 0x54, 0x49, 0x4f, 0x4e, 0x53, 0x48, 0x49, + 0x50, 0x10, 0x03, 0x12, 0x21, 0x0a, 0x1d, 0x4d, 0x49, 0x53, 0x53, 0x49, 0x4e, 0x47, 0x5f, 0x45, + 0x58, 0x50, 0x45, 0x43, 0x54, 0x45, 0x44, 0x5f, 0x52, 0x45, 0x4c, 0x41, 0x54, 0x49, 0x4f, 0x4e, + 0x53, 0x48, 0x49, 0x50, 0x10, 0x04, 0x12, 0x1c, 0x0a, 0x18, 0x45, 0x58, 0x54, 0x52, 0x41, 0x5f, + 0x52, 0x45, 0x4c, 0x41, 0x54, 0x49, 0x4f, 0x4e, 0x53, 0x48, 0x49, 0x50, 0x5f, 0x46, 0x4f, 0x55, + 0x4e, 0x44, 0x10, 0x05, 0x12, 0x17, 0x0a, 0x13, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x5f, + 0x4f, 0x42, 0x4a, 0x45, 0x43, 0x54, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x10, 0x06, 0x12, 0x14, 0x0a, + 0x10, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x5f, 0x52, 0x45, 0x4c, 0x41, 0x54, 0x49, 0x4f, + 0x4e, 0x10, 0x07, 0x12, 0x15, 0x0a, 0x11, 0x4d, 0x41, 0x58, 0x49, 0x4d, 0x55, 0x4d, 0x5f, 0x52, + 0x45, 0x43, 0x55, 0x52, 0x53, 0x49, 0x4f, 0x4e, 0x10, 0x08, 0x12, 0x14, 0x0a, 0x10, 0x41, 0x53, + 0x53, 0x45, 0x52, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x46, 0x41, 0x49, 0x4c, 0x45, 0x44, 0x10, 0x09, + 0x12, 0x18, 0x0a, 0x14, 0x49, 0x4e, 0x56, 0x41, 0x4c, 0x49, 0x44, 0x5f, 0x53, 0x55, 0x42, 0x4a, + 0x45, 0x43, 0x54, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x10, 0x0a, 0x22, 0x52, 0x0a, 0x0f, 0x44, 0x65, + 0x76, 0x65, 0x6c, 0x6f, 0x70, 0x65, 0x72, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x73, 0x12, 0x3f, 0x0a, + 0x0c, 0x69, 0x6e, 0x70, 0x75, 0x74, 0x5f, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x73, 0x18, 0x01, 0x20, + 0x03, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x64, 0x65, 0x76, 0x65, 0x6c, 0x6f, 0x70, 0x65, 0x72, 0x2e, + 0x76, 0x31, 0x2e, 0x44, 0x65, 0x76, 0x65, 0x6c, 0x6f, 0x70, 0x65, 0x72, 0x45, 0x72, 0x72, 0x6f, + 0x72, 0x52, 0x0b, 0x69, 0x6e, 0x70, 0x75, 0x74, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x73, 0x22, 0xd2, + 0x01, 0x0a, 0x18, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, + 0x6e, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x73, 0x12, 0x36, 0x0a, 0x08, 0x72, + 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, + 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x41, 0x6e, + 0x64, 0x52, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x08, 0x72, 0x65, 0x73, 0x6f, 0x75, + 0x72, 0x63, 0x65, 0x12, 0x34, 0x0a, 0x07, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4f, + 0x62, 0x6a, 0x65, 0x63, 0x74, 0x41, 0x6e, 0x64, 0x52, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x52, 0x07, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x48, 0x0a, 0x0e, 0x63, 0x61, 0x76, + 0x65, 0x61, 0x74, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x17, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x75, 0x63, 0x74, 0x42, 0x08, 0xfa, 0x42, 0x05, 0x8a, + 0x01, 0x02, 0x10, 0x00, 0x52, 0x0d, 0x63, 0x61, 0x76, 0x65, 0x61, 0x74, 0x43, 0x6f, 0x6e, 0x74, + 0x65, 0x78, 0x74, 0x22, 0xef, 0x03, 0x0a, 0x15, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x4f, 0x70, 0x65, + 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x4e, 0x0a, + 0x0a, 0x6d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x68, 0x69, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x0e, 0x32, 0x2e, 0x2e, 0x64, 0x65, 0x76, 0x65, 0x6c, 0x6f, 0x70, 0x65, 0x72, 0x2e, 0x76, 0x31, + 0x2e, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, + 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x2e, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x68, 0x69, + 0x70, 0x52, 0x0a, 0x6d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x68, 0x69, 0x70, 0x12, 0x3d, 0x0a, + 0x0b, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x5f, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x64, 0x65, 0x76, 0x65, 0x6c, 0x6f, 0x70, 0x65, 0x72, 0x2e, 0x76, + 0x31, 0x2e, 0x44, 0x65, 0x76, 0x65, 0x6c, 0x6f, 0x70, 0x65, 0x72, 0x45, 0x72, 0x72, 0x6f, 0x72, + 0x52, 0x0a, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x12, 0x4a, 0x0a, 0x11, + 0x64, 0x65, 0x62, 0x75, 0x67, 0x5f, 0x69, 0x6e, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x69, 0x6f, + 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x64, 0x69, 0x73, 0x70, 0x61, 0x74, + 0x63, 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x65, 0x62, 0x75, 0x67, 0x49, 0x6e, 0x66, 0x6f, 0x72, + 0x6d, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x10, 0x64, 0x65, 0x62, 0x75, 0x67, 0x49, 0x6e, 0x66, + 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x4f, 0x0a, 0x13, 0x70, 0x61, 0x72, 0x74, + 0x69, 0x61, 0x6c, 0x5f, 0x63, 0x61, 0x76, 0x65, 0x61, 0x74, 0x5f, 0x69, 0x6e, 0x66, 0x6f, 0x18, + 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x64, 0x65, 0x76, 0x65, 0x6c, 0x6f, 0x70, 0x65, + 0x72, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x61, 0x72, 0x74, 0x69, 0x61, 0x6c, 0x43, 0x61, 0x76, 0x65, + 0x61, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x11, 0x70, 0x61, 0x72, 0x74, 0x69, 0x61, 0x6c, 0x43, + 0x61, 0x76, 0x65, 0x61, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x5e, 0x0a, 0x1a, 0x72, 0x65, 0x73, + 0x6f, 0x6c, 0x76, 0x65, 0x64, 0x5f, 0x64, 0x65, 0x62, 0x75, 0x67, 0x5f, 0x69, 0x6e, 0x66, 0x6f, + 0x72, 0x6d, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x20, 0x2e, + 0x61, 0x75, 0x74, 0x68, 0x7a, 0x65, 0x64, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x44, + 0x65, 0x62, 0x75, 0x67, 0x49, 0x6e, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, + 0x18, 0x72, 0x65, 0x73, 0x6f, 0x6c, 0x76, 0x65, 0x64, 0x44, 0x65, 0x62, 0x75, 0x67, 0x49, 0x6e, + 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x4a, 0x0a, 0x0a, 0x4d, 0x65, 0x6d, + 0x62, 0x65, 0x72, 0x73, 0x68, 0x69, 0x70, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, + 0x57, 0x4e, 0x10, 0x00, 0x12, 0x0e, 0x0a, 0x0a, 0x4e, 0x4f, 0x54, 0x5f, 0x4d, 0x45, 0x4d, 0x42, + 0x45, 0x52, 0x10, 0x01, 0x12, 0x0a, 0x0a, 0x06, 0x4d, 0x45, 0x4d, 0x42, 0x45, 0x52, 0x10, 0x02, + 0x12, 0x13, 0x0a, 0x0f, 0x43, 0x41, 0x56, 0x45, 0x41, 0x54, 0x45, 0x44, 0x5f, 0x4d, 0x45, 0x4d, + 0x42, 0x45, 0x52, 0x10, 0x03, 0x22, 0x57, 0x0a, 0x11, 0x50, 0x61, 0x72, 0x74, 0x69, 0x61, 0x6c, + 0x43, 0x61, 0x76, 0x65, 0x61, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x42, 0x0a, 0x18, 0x6d, 0x69, + 0x73, 0x73, 0x69, 0x6e, 0x67, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x5f, 0x63, + 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x42, 0x08, 0xfa, 0x42, + 0x05, 0x92, 0x01, 0x02, 0x08, 0x01, 0x52, 0x16, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6e, 0x67, 0x52, + 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x22, 0x42, + 0x0a, 0x17, 0x52, 0x75, 0x6e, 0x41, 0x73, 0x73, 0x65, 0x72, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x50, + 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x73, 0x12, 0x27, 0x0a, 0x0f, 0x61, 0x73, 0x73, + 0x65, 0x72, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x5f, 0x79, 0x61, 0x6d, 0x6c, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x0e, 0x61, 0x73, 0x73, 0x65, 0x72, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x59, 0x61, + 0x6d, 0x6c, 0x22, 0x9f, 0x01, 0x0a, 0x13, 0x52, 0x75, 0x6e, 0x41, 0x73, 0x73, 0x65, 0x72, 0x74, + 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x3d, 0x0a, 0x0b, 0x69, 0x6e, + 0x70, 0x75, 0x74, 0x5f, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x1c, 0x2e, 0x64, 0x65, 0x76, 0x65, 0x6c, 0x6f, 0x70, 0x65, 0x72, 0x2e, 0x76, 0x31, 0x2e, 0x44, + 0x65, 0x76, 0x65, 0x6c, 0x6f, 0x70, 0x65, 0x72, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x52, 0x0a, 0x69, + 0x6e, 0x70, 0x75, 0x74, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x12, 0x49, 0x0a, 0x11, 0x76, 0x61, 0x6c, + 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x73, 0x18, 0x02, + 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x64, 0x65, 0x76, 0x65, 0x6c, 0x6f, 0x70, 0x65, 0x72, + 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x65, 0x76, 0x65, 0x6c, 0x6f, 0x70, 0x65, 0x72, 0x45, 0x72, 0x72, + 0x6f, 0x72, 0x52, 0x10, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x45, 0x72, + 0x72, 0x6f, 0x72, 0x73, 0x22, 0x42, 0x0a, 0x17, 0x52, 0x75, 0x6e, 0x56, 0x61, 0x6c, 0x69, 0x64, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x73, 0x12, + 0x27, 0x0a, 0x0f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x79, 0x61, + 0x6d, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x59, 0x61, 0x6d, 0x6c, 0x22, 0xd7, 0x01, 0x0a, 0x13, 0x52, 0x75, 0x6e, + 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, + 0x12, 0x3d, 0x0a, 0x0b, 0x69, 0x6e, 0x70, 0x75, 0x74, 0x5f, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x64, 0x65, 0x76, 0x65, 0x6c, 0x6f, 0x70, 0x65, + 0x72, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x65, 0x76, 0x65, 0x6c, 0x6f, 0x70, 0x65, 0x72, 0x45, 0x72, + 0x72, 0x6f, 0x72, 0x52, 0x0a, 0x69, 0x6e, 0x70, 0x75, 0x74, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x12, + 0x36, 0x0a, 0x17, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x76, 0x61, 0x6c, 0x69, 0x64, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x79, 0x61, 0x6d, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x15, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x59, 0x61, 0x6d, 0x6c, 0x12, 0x49, 0x0a, 0x11, 0x76, 0x61, 0x6c, 0x69, 0x64, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x73, 0x18, 0x03, 0x20, 0x03, + 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x64, 0x65, 0x76, 0x65, 0x6c, 0x6f, 0x70, 0x65, 0x72, 0x2e, 0x76, + 0x31, 0x2e, 0x44, 0x65, 0x76, 0x65, 0x6c, 0x6f, 0x70, 0x65, 0x72, 0x45, 0x72, 0x72, 0x6f, 0x72, + 0x52, 0x10, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x45, 0x72, 0x72, 0x6f, + 0x72, 0x73, 0x22, 0x18, 0x0a, 0x16, 0x46, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x53, 0x63, 0x68, 0x65, + 0x6d, 0x61, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x73, 0x22, 0x3f, 0x0a, 0x12, + 0x46, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x52, 0x65, 0x73, 0x75, + 0x6c, 0x74, 0x12, 0x29, 0x0a, 0x10, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x74, 0x65, 0x64, 0x5f, + 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x66, 0x6f, + 0x72, 0x6d, 0x61, 0x74, 0x74, 0x65, 0x64, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x22, 0x1a, 0x0a, + 0x18, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x57, 0x61, 0x72, 0x6e, 0x69, 0x6e, 0x67, 0x73, 0x50, + 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x73, 0x22, 0x52, 0x0a, 0x14, 0x53, 0x63, 0x68, + 0x65, 0x6d, 0x61, 0x57, 0x61, 0x72, 0x6e, 0x69, 0x6e, 0x67, 0x73, 0x52, 0x65, 0x73, 0x75, 0x6c, + 0x74, 0x12, 0x3a, 0x0a, 0x08, 0x77, 0x61, 0x72, 0x6e, 0x69, 0x6e, 0x67, 0x73, 0x18, 0x01, 0x20, + 0x03, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x64, 0x65, 0x76, 0x65, 0x6c, 0x6f, 0x70, 0x65, 0x72, 0x2e, + 0x76, 0x31, 0x2e, 0x44, 0x65, 0x76, 0x65, 0x6c, 0x6f, 0x70, 0x65, 0x72, 0x57, 0x61, 0x72, 0x6e, + 0x69, 0x6e, 0x67, 0x52, 0x08, 0x77, 0x61, 0x72, 0x6e, 0x69, 0x6e, 0x67, 0x73, 0x42, 0xb2, 0x01, + 0x0a, 0x10, 0x63, 0x6f, 0x6d, 0x2e, 0x64, 0x65, 0x76, 0x65, 0x6c, 0x6f, 0x70, 0x65, 0x72, 0x2e, + 0x76, 0x31, 0x42, 0x0e, 0x44, 0x65, 0x76, 0x65, 0x6c, 0x6f, 0x70, 0x65, 0x72, 0x50, 0x72, 0x6f, + 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x3d, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, + 0x2f, 0x61, 0x75, 0x74, 0x68, 0x7a, 0x65, 0x64, 0x2f, 0x73, 0x70, 0x69, 0x63, 0x65, 0x64, 0x62, + 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x64, 0x65, 0x76, 0x65, 0x6c, + 0x6f, 0x70, 0x65, 0x72, 0x2f, 0x76, 0x31, 0x3b, 0x64, 0x65, 0x76, 0x65, 0x6c, 0x6f, 0x70, 0x65, + 0x72, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x44, 0x58, 0x58, 0xaa, 0x02, 0x0c, 0x44, 0x65, 0x76, 0x65, + 0x6c, 0x6f, 0x70, 0x65, 0x72, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x0c, 0x44, 0x65, 0x76, 0x65, 0x6c, + 0x6f, 0x70, 0x65, 0x72, 0x5c, 0x56, 0x31, 0xe2, 0x02, 0x18, 0x44, 0x65, 0x76, 0x65, 0x6c, 0x6f, + 0x70, 0x65, 0x72, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, + 0x74, 0x61, 0xea, 0x02, 0x0d, 0x44, 0x65, 0x76, 0x65, 0x6c, 0x6f, 0x70, 0x65, 0x72, 0x3a, 0x3a, + 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_developer_v1_developer_proto_rawDescOnce sync.Once + file_developer_v1_developer_proto_rawDescData = file_developer_v1_developer_proto_rawDesc +) + +func file_developer_v1_developer_proto_rawDescGZIP() []byte { + file_developer_v1_developer_proto_rawDescOnce.Do(func() { + file_developer_v1_developer_proto_rawDescData = protoimpl.X.CompressGZIP(file_developer_v1_developer_proto_rawDescData) + }) + return file_developer_v1_developer_proto_rawDescData +} + +var file_developer_v1_developer_proto_enumTypes = make([]protoimpl.EnumInfo, 3) +var file_developer_v1_developer_proto_msgTypes = make([]protoimpl.MessageInfo, 21) +var file_developer_v1_developer_proto_goTypes = []any{ + (DeveloperError_Source)(0), // 0: developer.v1.DeveloperError.Source + (DeveloperError_ErrorKind)(0), // 1: developer.v1.DeveloperError.ErrorKind + (CheckOperationsResult_Membership)(0), // 2: developer.v1.CheckOperationsResult.Membership + (*DeveloperRequest)(nil), // 3: developer.v1.DeveloperRequest + (*DeveloperResponse)(nil), // 4: developer.v1.DeveloperResponse + (*RequestContext)(nil), // 5: developer.v1.RequestContext + (*Operation)(nil), // 6: developer.v1.Operation + (*OperationsResults)(nil), // 7: developer.v1.OperationsResults + (*OperationResult)(nil), // 8: developer.v1.OperationResult + (*DeveloperWarning)(nil), // 9: developer.v1.DeveloperWarning + (*DeveloperError)(nil), // 10: developer.v1.DeveloperError + (*DeveloperErrors)(nil), // 11: developer.v1.DeveloperErrors + (*CheckOperationParameters)(nil), // 12: developer.v1.CheckOperationParameters + (*CheckOperationsResult)(nil), // 13: developer.v1.CheckOperationsResult + (*PartialCaveatInfo)(nil), // 14: developer.v1.PartialCaveatInfo + (*RunAssertionsParameters)(nil), // 15: developer.v1.RunAssertionsParameters + (*RunAssertionsResult)(nil), // 16: developer.v1.RunAssertionsResult + (*RunValidationParameters)(nil), // 17: developer.v1.RunValidationParameters + (*RunValidationResult)(nil), // 18: developer.v1.RunValidationResult + (*FormatSchemaParameters)(nil), // 19: developer.v1.FormatSchemaParameters + (*FormatSchemaResult)(nil), // 20: developer.v1.FormatSchemaResult + (*SchemaWarningsParameters)(nil), // 21: developer.v1.SchemaWarningsParameters + (*SchemaWarningsResult)(nil), // 22: developer.v1.SchemaWarningsResult + nil, // 23: developer.v1.OperationsResults.ResultsEntry + (*v1.RelationTuple)(nil), // 24: core.v1.RelationTuple + (*v11.DebugInformation)(nil), // 25: dispatch.v1.DebugInformation + (*v12.DebugInformation)(nil), // 26: authzed.api.v1.DebugInformation + (*v1.ObjectAndRelation)(nil), // 27: core.v1.ObjectAndRelation + (*structpb.Struct)(nil), // 28: google.protobuf.Struct +} +var file_developer_v1_developer_proto_depIdxs = []int32{ + 5, // 0: developer.v1.DeveloperRequest.context:type_name -> developer.v1.RequestContext + 6, // 1: developer.v1.DeveloperRequest.operations:type_name -> developer.v1.Operation + 11, // 2: developer.v1.DeveloperResponse.developer_errors:type_name -> developer.v1.DeveloperErrors + 7, // 3: developer.v1.DeveloperResponse.operations_results:type_name -> developer.v1.OperationsResults + 24, // 4: developer.v1.RequestContext.relationships:type_name -> core.v1.RelationTuple + 12, // 5: developer.v1.Operation.check_parameters:type_name -> developer.v1.CheckOperationParameters + 15, // 6: developer.v1.Operation.assertions_parameters:type_name -> developer.v1.RunAssertionsParameters + 17, // 7: developer.v1.Operation.validation_parameters:type_name -> developer.v1.RunValidationParameters + 19, // 8: developer.v1.Operation.format_schema_parameters:type_name -> developer.v1.FormatSchemaParameters + 21, // 9: developer.v1.Operation.schema_warnings_parameters:type_name -> developer.v1.SchemaWarningsParameters + 23, // 10: developer.v1.OperationsResults.results:type_name -> developer.v1.OperationsResults.ResultsEntry + 13, // 11: developer.v1.OperationResult.check_result:type_name -> developer.v1.CheckOperationsResult + 16, // 12: developer.v1.OperationResult.assertions_result:type_name -> developer.v1.RunAssertionsResult + 18, // 13: developer.v1.OperationResult.validation_result:type_name -> developer.v1.RunValidationResult + 20, // 14: developer.v1.OperationResult.format_schema_result:type_name -> developer.v1.FormatSchemaResult + 22, // 15: developer.v1.OperationResult.schema_warnings_result:type_name -> developer.v1.SchemaWarningsResult + 0, // 16: developer.v1.DeveloperError.source:type_name -> developer.v1.DeveloperError.Source + 1, // 17: developer.v1.DeveloperError.kind:type_name -> developer.v1.DeveloperError.ErrorKind + 25, // 18: developer.v1.DeveloperError.check_debug_information:type_name -> dispatch.v1.DebugInformation + 26, // 19: developer.v1.DeveloperError.check_resolved_debug_information:type_name -> authzed.api.v1.DebugInformation + 10, // 20: developer.v1.DeveloperErrors.input_errors:type_name -> developer.v1.DeveloperError + 27, // 21: developer.v1.CheckOperationParameters.resource:type_name -> core.v1.ObjectAndRelation + 27, // 22: developer.v1.CheckOperationParameters.subject:type_name -> core.v1.ObjectAndRelation + 28, // 23: developer.v1.CheckOperationParameters.caveat_context:type_name -> google.protobuf.Struct + 2, // 24: developer.v1.CheckOperationsResult.membership:type_name -> developer.v1.CheckOperationsResult.Membership + 10, // 25: developer.v1.CheckOperationsResult.check_error:type_name -> developer.v1.DeveloperError + 25, // 26: developer.v1.CheckOperationsResult.debug_information:type_name -> dispatch.v1.DebugInformation + 14, // 27: developer.v1.CheckOperationsResult.partial_caveat_info:type_name -> developer.v1.PartialCaveatInfo + 26, // 28: developer.v1.CheckOperationsResult.resolved_debug_information:type_name -> authzed.api.v1.DebugInformation + 10, // 29: developer.v1.RunAssertionsResult.input_error:type_name -> developer.v1.DeveloperError + 10, // 30: developer.v1.RunAssertionsResult.validation_errors:type_name -> developer.v1.DeveloperError + 10, // 31: developer.v1.RunValidationResult.input_error:type_name -> developer.v1.DeveloperError + 10, // 32: developer.v1.RunValidationResult.validation_errors:type_name -> developer.v1.DeveloperError + 9, // 33: developer.v1.SchemaWarningsResult.warnings:type_name -> developer.v1.DeveloperWarning + 8, // 34: developer.v1.OperationsResults.ResultsEntry.value:type_name -> developer.v1.OperationResult + 35, // [35:35] is the sub-list for method output_type + 35, // [35:35] is the sub-list for method input_type + 35, // [35:35] is the sub-list for extension type_name + 35, // [35:35] is the sub-list for extension extendee + 0, // [0:35] is the sub-list for field type_name +} + +func init() { file_developer_v1_developer_proto_init() } +func file_developer_v1_developer_proto_init() { + if File_developer_v1_developer_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_developer_v1_developer_proto_msgTypes[0].Exporter = func(v any, i int) any { + switch v := v.(*DeveloperRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_developer_v1_developer_proto_msgTypes[1].Exporter = func(v any, i int) any { + switch v := v.(*DeveloperResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_developer_v1_developer_proto_msgTypes[2].Exporter = func(v any, i int) any { + switch v := v.(*RequestContext); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_developer_v1_developer_proto_msgTypes[3].Exporter = func(v any, i int) any { + switch v := v.(*Operation); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_developer_v1_developer_proto_msgTypes[4].Exporter = func(v any, i int) any { + switch v := v.(*OperationsResults); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_developer_v1_developer_proto_msgTypes[5].Exporter = func(v any, i int) any { + switch v := v.(*OperationResult); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_developer_v1_developer_proto_msgTypes[6].Exporter = func(v any, i int) any { + switch v := v.(*DeveloperWarning); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_developer_v1_developer_proto_msgTypes[7].Exporter = func(v any, i int) any { + switch v := v.(*DeveloperError); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_developer_v1_developer_proto_msgTypes[8].Exporter = func(v any, i int) any { + switch v := v.(*DeveloperErrors); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_developer_v1_developer_proto_msgTypes[9].Exporter = func(v any, i int) any { + switch v := v.(*CheckOperationParameters); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_developer_v1_developer_proto_msgTypes[10].Exporter = func(v any, i int) any { + switch v := v.(*CheckOperationsResult); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_developer_v1_developer_proto_msgTypes[11].Exporter = func(v any, i int) any { + switch v := v.(*PartialCaveatInfo); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_developer_v1_developer_proto_msgTypes[12].Exporter = func(v any, i int) any { + switch v := v.(*RunAssertionsParameters); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_developer_v1_developer_proto_msgTypes[13].Exporter = func(v any, i int) any { + switch v := v.(*RunAssertionsResult); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_developer_v1_developer_proto_msgTypes[14].Exporter = func(v any, i int) any { + switch v := v.(*RunValidationParameters); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_developer_v1_developer_proto_msgTypes[15].Exporter = func(v any, i int) any { + switch v := v.(*RunValidationResult); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_developer_v1_developer_proto_msgTypes[16].Exporter = func(v any, i int) any { + switch v := v.(*FormatSchemaParameters); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_developer_v1_developer_proto_msgTypes[17].Exporter = func(v any, i int) any { + switch v := v.(*FormatSchemaResult); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_developer_v1_developer_proto_msgTypes[18].Exporter = func(v any, i int) any { + switch v := v.(*SchemaWarningsParameters); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_developer_v1_developer_proto_msgTypes[19].Exporter = func(v any, i int) any { + switch v := v.(*SchemaWarningsResult); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_developer_v1_developer_proto_rawDesc, + NumEnums: 3, + NumMessages: 21, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_developer_v1_developer_proto_goTypes, + DependencyIndexes: file_developer_v1_developer_proto_depIdxs, + EnumInfos: file_developer_v1_developer_proto_enumTypes, + MessageInfos: file_developer_v1_developer_proto_msgTypes, + }.Build() + File_developer_v1_developer_proto = out.File + file_developer_v1_developer_proto_rawDesc = nil + file_developer_v1_developer_proto_goTypes = nil + file_developer_v1_developer_proto_depIdxs = nil +} diff --git a/vendor/github.com/authzed/spicedb/pkg/proto/developer/v1/developer.pb.validate.go b/vendor/github.com/authzed/spicedb/pkg/proto/developer/v1/developer.pb.validate.go new file mode 100644 index 0000000..1767bf4 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/proto/developer/v1/developer.pb.validate.go @@ -0,0 +1,3052 @@ +// Code generated by protoc-gen-validate. DO NOT EDIT. +// source: developer/v1/developer.proto + +package developerv1 + +import ( + "bytes" + "errors" + "fmt" + "net" + "net/mail" + "net/url" + "regexp" + "sort" + "strings" + "time" + "unicode/utf8" + + "google.golang.org/protobuf/types/known/anypb" +) + +// ensure the imports are used +var ( + _ = bytes.MinRead + _ = errors.New("") + _ = fmt.Print + _ = utf8.UTFMax + _ = (*regexp.Regexp)(nil) + _ = (*strings.Reader)(nil) + _ = net.IPv4len + _ = time.Duration(0) + _ = (*url.URL)(nil) + _ = (*mail.Address)(nil) + _ = anypb.Any{} + _ = sort.Sort +) + +// Validate checks the field values on DeveloperRequest with the rules defined +// in the proto definition for this message. If any rules are violated, the +// first error encountered is returned, or nil if there are no violations. +func (m *DeveloperRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on DeveloperRequest with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// DeveloperRequestMultiError, or nil if none found. +func (m *DeveloperRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *DeveloperRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetContext()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, DeveloperRequestValidationError{ + field: "Context", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, DeveloperRequestValidationError{ + field: "Context", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetContext()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return DeveloperRequestValidationError{ + field: "Context", + reason: "embedded message failed validation", + cause: err, + } + } + } + + for idx, item := range m.GetOperations() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, DeveloperRequestValidationError{ + field: fmt.Sprintf("Operations[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, DeveloperRequestValidationError{ + field: fmt.Sprintf("Operations[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return DeveloperRequestValidationError{ + field: fmt.Sprintf("Operations[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + if len(errors) > 0 { + return DeveloperRequestMultiError(errors) + } + + return nil +} + +// DeveloperRequestMultiError is an error wrapping multiple validation errors +// returned by DeveloperRequest.ValidateAll() if the designated constraints +// aren't met. +type DeveloperRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m DeveloperRequestMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m DeveloperRequestMultiError) AllErrors() []error { return m } + +// DeveloperRequestValidationError is the validation error returned by +// DeveloperRequest.Validate if the designated constraints aren't met. +type DeveloperRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e DeveloperRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e DeveloperRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e DeveloperRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e DeveloperRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e DeveloperRequestValidationError) ErrorName() string { return "DeveloperRequestValidationError" } + +// Error satisfies the builtin error interface +func (e DeveloperRequestValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sDeveloperRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = DeveloperRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = DeveloperRequestValidationError{} + +// Validate checks the field values on DeveloperResponse with the rules defined +// in the proto definition for this message. If any rules are violated, the +// first error encountered is returned, or nil if there are no violations. +func (m *DeveloperResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on DeveloperResponse with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// DeveloperResponseMultiError, or nil if none found. +func (m *DeveloperResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *DeveloperResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for InternalError + + if all { + switch v := interface{}(m.GetDeveloperErrors()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, DeveloperResponseValidationError{ + field: "DeveloperErrors", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, DeveloperResponseValidationError{ + field: "DeveloperErrors", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetDeveloperErrors()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return DeveloperResponseValidationError{ + field: "DeveloperErrors", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if all { + switch v := interface{}(m.GetOperationsResults()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, DeveloperResponseValidationError{ + field: "OperationsResults", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, DeveloperResponseValidationError{ + field: "OperationsResults", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetOperationsResults()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return DeveloperResponseValidationError{ + field: "OperationsResults", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return DeveloperResponseMultiError(errors) + } + + return nil +} + +// DeveloperResponseMultiError is an error wrapping multiple validation errors +// returned by DeveloperResponse.ValidateAll() if the designated constraints +// aren't met. +type DeveloperResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m DeveloperResponseMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m DeveloperResponseMultiError) AllErrors() []error { return m } + +// DeveloperResponseValidationError is the validation error returned by +// DeveloperResponse.Validate if the designated constraints aren't met. +type DeveloperResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e DeveloperResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e DeveloperResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e DeveloperResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e DeveloperResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e DeveloperResponseValidationError) ErrorName() string { + return "DeveloperResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e DeveloperResponseValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sDeveloperResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = DeveloperResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = DeveloperResponseValidationError{} + +// Validate checks the field values on RequestContext with the rules defined in +// the proto definition for this message. If any rules are violated, the first +// error encountered is returned, or nil if there are no violations. +func (m *RequestContext) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on RequestContext with the rules defined +// in the proto definition for this message. If any rules are violated, the +// result is a list of violation errors wrapped in RequestContextMultiError, +// or nil if none found. +func (m *RequestContext) ValidateAll() error { + return m.validate(true) +} + +func (m *RequestContext) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Schema + + for idx, item := range m.GetRelationships() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, RequestContextValidationError{ + field: fmt.Sprintf("Relationships[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, RequestContextValidationError{ + field: fmt.Sprintf("Relationships[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return RequestContextValidationError{ + field: fmt.Sprintf("Relationships[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + if len(errors) > 0 { + return RequestContextMultiError(errors) + } + + return nil +} + +// RequestContextMultiError is an error wrapping multiple validation errors +// returned by RequestContext.ValidateAll() if the designated constraints +// aren't met. +type RequestContextMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m RequestContextMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m RequestContextMultiError) AllErrors() []error { return m } + +// RequestContextValidationError is the validation error returned by +// RequestContext.Validate if the designated constraints aren't met. +type RequestContextValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e RequestContextValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e RequestContextValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e RequestContextValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e RequestContextValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e RequestContextValidationError) ErrorName() string { return "RequestContextValidationError" } + +// Error satisfies the builtin error interface +func (e RequestContextValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sRequestContext.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = RequestContextValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = RequestContextValidationError{} + +// Validate checks the field values on Operation with the rules defined in the +// proto definition for this message. If any rules are violated, the first +// error encountered is returned, or nil if there are no violations. +func (m *Operation) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on Operation with the rules defined in +// the proto definition for this message. If any rules are violated, the +// result is a list of violation errors wrapped in OperationMultiError, or nil +// if none found. +func (m *Operation) ValidateAll() error { + return m.validate(true) +} + +func (m *Operation) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetCheckParameters()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, OperationValidationError{ + field: "CheckParameters", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, OperationValidationError{ + field: "CheckParameters", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetCheckParameters()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return OperationValidationError{ + field: "CheckParameters", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if all { + switch v := interface{}(m.GetAssertionsParameters()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, OperationValidationError{ + field: "AssertionsParameters", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, OperationValidationError{ + field: "AssertionsParameters", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetAssertionsParameters()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return OperationValidationError{ + field: "AssertionsParameters", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if all { + switch v := interface{}(m.GetValidationParameters()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, OperationValidationError{ + field: "ValidationParameters", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, OperationValidationError{ + field: "ValidationParameters", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetValidationParameters()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return OperationValidationError{ + field: "ValidationParameters", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if all { + switch v := interface{}(m.GetFormatSchemaParameters()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, OperationValidationError{ + field: "FormatSchemaParameters", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, OperationValidationError{ + field: "FormatSchemaParameters", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetFormatSchemaParameters()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return OperationValidationError{ + field: "FormatSchemaParameters", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if all { + switch v := interface{}(m.GetSchemaWarningsParameters()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, OperationValidationError{ + field: "SchemaWarningsParameters", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, OperationValidationError{ + field: "SchemaWarningsParameters", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetSchemaWarningsParameters()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return OperationValidationError{ + field: "SchemaWarningsParameters", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return OperationMultiError(errors) + } + + return nil +} + +// OperationMultiError is an error wrapping multiple validation errors returned +// by Operation.ValidateAll() if the designated constraints aren't met. +type OperationMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m OperationMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m OperationMultiError) AllErrors() []error { return m } + +// OperationValidationError is the validation error returned by +// Operation.Validate if the designated constraints aren't met. +type OperationValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e OperationValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e OperationValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e OperationValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e OperationValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e OperationValidationError) ErrorName() string { return "OperationValidationError" } + +// Error satisfies the builtin error interface +func (e OperationValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sOperation.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = OperationValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = OperationValidationError{} + +// Validate checks the field values on OperationsResults with the rules defined +// in the proto definition for this message. If any rules are violated, the +// first error encountered is returned, or nil if there are no violations. +func (m *OperationsResults) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on OperationsResults with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// OperationsResultsMultiError, or nil if none found. +func (m *OperationsResults) ValidateAll() error { + return m.validate(true) +} + +func (m *OperationsResults) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + { + sorted_keys := make([]uint64, len(m.GetResults())) + i := 0 + for key := range m.GetResults() { + sorted_keys[i] = key + i++ + } + sort.Slice(sorted_keys, func(i, j int) bool { return sorted_keys[i] < sorted_keys[j] }) + for _, key := range sorted_keys { + val := m.GetResults()[key] + _ = val + + // no validation rules for Results[key] + + if all { + switch v := interface{}(val).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, OperationsResultsValidationError{ + field: fmt.Sprintf("Results[%v]", key), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, OperationsResultsValidationError{ + field: fmt.Sprintf("Results[%v]", key), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(val).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return OperationsResultsValidationError{ + field: fmt.Sprintf("Results[%v]", key), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + } + + if len(errors) > 0 { + return OperationsResultsMultiError(errors) + } + + return nil +} + +// OperationsResultsMultiError is an error wrapping multiple validation errors +// returned by OperationsResults.ValidateAll() if the designated constraints +// aren't met. +type OperationsResultsMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m OperationsResultsMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m OperationsResultsMultiError) AllErrors() []error { return m } + +// OperationsResultsValidationError is the validation error returned by +// OperationsResults.Validate if the designated constraints aren't met. +type OperationsResultsValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e OperationsResultsValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e OperationsResultsValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e OperationsResultsValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e OperationsResultsValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e OperationsResultsValidationError) ErrorName() string { + return "OperationsResultsValidationError" +} + +// Error satisfies the builtin error interface +func (e OperationsResultsValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sOperationsResults.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = OperationsResultsValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = OperationsResultsValidationError{} + +// Validate checks the field values on OperationResult with the rules defined +// in the proto definition for this message. If any rules are violated, the +// first error encountered is returned, or nil if there are no violations. +func (m *OperationResult) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on OperationResult with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// OperationResultMultiError, or nil if none found. +func (m *OperationResult) ValidateAll() error { + return m.validate(true) +} + +func (m *OperationResult) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetCheckResult()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, OperationResultValidationError{ + field: "CheckResult", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, OperationResultValidationError{ + field: "CheckResult", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetCheckResult()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return OperationResultValidationError{ + field: "CheckResult", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if all { + switch v := interface{}(m.GetAssertionsResult()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, OperationResultValidationError{ + field: "AssertionsResult", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, OperationResultValidationError{ + field: "AssertionsResult", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetAssertionsResult()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return OperationResultValidationError{ + field: "AssertionsResult", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if all { + switch v := interface{}(m.GetValidationResult()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, OperationResultValidationError{ + field: "ValidationResult", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, OperationResultValidationError{ + field: "ValidationResult", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetValidationResult()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return OperationResultValidationError{ + field: "ValidationResult", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if all { + switch v := interface{}(m.GetFormatSchemaResult()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, OperationResultValidationError{ + field: "FormatSchemaResult", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, OperationResultValidationError{ + field: "FormatSchemaResult", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetFormatSchemaResult()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return OperationResultValidationError{ + field: "FormatSchemaResult", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if all { + switch v := interface{}(m.GetSchemaWarningsResult()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, OperationResultValidationError{ + field: "SchemaWarningsResult", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, OperationResultValidationError{ + field: "SchemaWarningsResult", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetSchemaWarningsResult()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return OperationResultValidationError{ + field: "SchemaWarningsResult", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return OperationResultMultiError(errors) + } + + return nil +} + +// OperationResultMultiError is an error wrapping multiple validation errors +// returned by OperationResult.ValidateAll() if the designated constraints +// aren't met. +type OperationResultMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m OperationResultMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m OperationResultMultiError) AllErrors() []error { return m } + +// OperationResultValidationError is the validation error returned by +// OperationResult.Validate if the designated constraints aren't met. +type OperationResultValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e OperationResultValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e OperationResultValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e OperationResultValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e OperationResultValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e OperationResultValidationError) ErrorName() string { return "OperationResultValidationError" } + +// Error satisfies the builtin error interface +func (e OperationResultValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sOperationResult.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = OperationResultValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = OperationResultValidationError{} + +// Validate checks the field values on DeveloperWarning with the rules defined +// in the proto definition for this message. If any rules are violated, the +// first error encountered is returned, or nil if there are no violations. +func (m *DeveloperWarning) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on DeveloperWarning with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// DeveloperWarningMultiError, or nil if none found. +func (m *DeveloperWarning) ValidateAll() error { + return m.validate(true) +} + +func (m *DeveloperWarning) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Message + + // no validation rules for Line + + // no validation rules for Column + + // no validation rules for SourceCode + + if len(errors) > 0 { + return DeveloperWarningMultiError(errors) + } + + return nil +} + +// DeveloperWarningMultiError is an error wrapping multiple validation errors +// returned by DeveloperWarning.ValidateAll() if the designated constraints +// aren't met. +type DeveloperWarningMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m DeveloperWarningMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m DeveloperWarningMultiError) AllErrors() []error { return m } + +// DeveloperWarningValidationError is the validation error returned by +// DeveloperWarning.Validate if the designated constraints aren't met. +type DeveloperWarningValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e DeveloperWarningValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e DeveloperWarningValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e DeveloperWarningValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e DeveloperWarningValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e DeveloperWarningValidationError) ErrorName() string { return "DeveloperWarningValidationError" } + +// Error satisfies the builtin error interface +func (e DeveloperWarningValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sDeveloperWarning.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = DeveloperWarningValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = DeveloperWarningValidationError{} + +// Validate checks the field values on DeveloperError with the rules defined in +// the proto definition for this message. If any rules are violated, the first +// error encountered is returned, or nil if there are no violations. +func (m *DeveloperError) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on DeveloperError with the rules defined +// in the proto definition for this message. If any rules are violated, the +// result is a list of violation errors wrapped in DeveloperErrorMultiError, +// or nil if none found. +func (m *DeveloperError) ValidateAll() error { + return m.validate(true) +} + +func (m *DeveloperError) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Message + + // no validation rules for Line + + // no validation rules for Column + + // no validation rules for Source + + // no validation rules for Kind + + // no validation rules for Context + + if all { + switch v := interface{}(m.GetCheckDebugInformation()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, DeveloperErrorValidationError{ + field: "CheckDebugInformation", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, DeveloperErrorValidationError{ + field: "CheckDebugInformation", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetCheckDebugInformation()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return DeveloperErrorValidationError{ + field: "CheckDebugInformation", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if all { + switch v := interface{}(m.GetCheckResolvedDebugInformation()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, DeveloperErrorValidationError{ + field: "CheckResolvedDebugInformation", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, DeveloperErrorValidationError{ + field: "CheckResolvedDebugInformation", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetCheckResolvedDebugInformation()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return DeveloperErrorValidationError{ + field: "CheckResolvedDebugInformation", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return DeveloperErrorMultiError(errors) + } + + return nil +} + +// DeveloperErrorMultiError is an error wrapping multiple validation errors +// returned by DeveloperError.ValidateAll() if the designated constraints +// aren't met. +type DeveloperErrorMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m DeveloperErrorMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m DeveloperErrorMultiError) AllErrors() []error { return m } + +// DeveloperErrorValidationError is the validation error returned by +// DeveloperError.Validate if the designated constraints aren't met. +type DeveloperErrorValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e DeveloperErrorValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e DeveloperErrorValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e DeveloperErrorValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e DeveloperErrorValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e DeveloperErrorValidationError) ErrorName() string { return "DeveloperErrorValidationError" } + +// Error satisfies the builtin error interface +func (e DeveloperErrorValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sDeveloperError.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = DeveloperErrorValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = DeveloperErrorValidationError{} + +// Validate checks the field values on DeveloperErrors with the rules defined +// in the proto definition for this message. If any rules are violated, the +// first error encountered is returned, or nil if there are no violations. +func (m *DeveloperErrors) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on DeveloperErrors with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// DeveloperErrorsMultiError, or nil if none found. +func (m *DeveloperErrors) ValidateAll() error { + return m.validate(true) +} + +func (m *DeveloperErrors) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + for idx, item := range m.GetInputErrors() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, DeveloperErrorsValidationError{ + field: fmt.Sprintf("InputErrors[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, DeveloperErrorsValidationError{ + field: fmt.Sprintf("InputErrors[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return DeveloperErrorsValidationError{ + field: fmt.Sprintf("InputErrors[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + if len(errors) > 0 { + return DeveloperErrorsMultiError(errors) + } + + return nil +} + +// DeveloperErrorsMultiError is an error wrapping multiple validation errors +// returned by DeveloperErrors.ValidateAll() if the designated constraints +// aren't met. +type DeveloperErrorsMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m DeveloperErrorsMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m DeveloperErrorsMultiError) AllErrors() []error { return m } + +// DeveloperErrorsValidationError is the validation error returned by +// DeveloperErrors.Validate if the designated constraints aren't met. +type DeveloperErrorsValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e DeveloperErrorsValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e DeveloperErrorsValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e DeveloperErrorsValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e DeveloperErrorsValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e DeveloperErrorsValidationError) ErrorName() string { return "DeveloperErrorsValidationError" } + +// Error satisfies the builtin error interface +func (e DeveloperErrorsValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sDeveloperErrors.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = DeveloperErrorsValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = DeveloperErrorsValidationError{} + +// Validate checks the field values on CheckOperationParameters with the rules +// defined in the proto definition for this message. If any rules are +// violated, the first error encountered is returned, or nil if there are no violations. +func (m *CheckOperationParameters) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on CheckOperationParameters with the +// rules defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// CheckOperationParametersMultiError, or nil if none found. +func (m *CheckOperationParameters) ValidateAll() error { + return m.validate(true) +} + +func (m *CheckOperationParameters) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetResource()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, CheckOperationParametersValidationError{ + field: "Resource", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, CheckOperationParametersValidationError{ + field: "Resource", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetResource()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return CheckOperationParametersValidationError{ + field: "Resource", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if all { + switch v := interface{}(m.GetSubject()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, CheckOperationParametersValidationError{ + field: "Subject", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, CheckOperationParametersValidationError{ + field: "Subject", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetSubject()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return CheckOperationParametersValidationError{ + field: "Subject", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if all { + switch v := interface{}(m.GetCaveatContext()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, CheckOperationParametersValidationError{ + field: "CaveatContext", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, CheckOperationParametersValidationError{ + field: "CaveatContext", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetCaveatContext()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return CheckOperationParametersValidationError{ + field: "CaveatContext", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return CheckOperationParametersMultiError(errors) + } + + return nil +} + +// CheckOperationParametersMultiError is an error wrapping multiple validation +// errors returned by CheckOperationParameters.ValidateAll() if the designated +// constraints aren't met. +type CheckOperationParametersMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m CheckOperationParametersMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m CheckOperationParametersMultiError) AllErrors() []error { return m } + +// CheckOperationParametersValidationError is the validation error returned by +// CheckOperationParameters.Validate if the designated constraints aren't met. +type CheckOperationParametersValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e CheckOperationParametersValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e CheckOperationParametersValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e CheckOperationParametersValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e CheckOperationParametersValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e CheckOperationParametersValidationError) ErrorName() string { + return "CheckOperationParametersValidationError" +} + +// Error satisfies the builtin error interface +func (e CheckOperationParametersValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sCheckOperationParameters.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = CheckOperationParametersValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = CheckOperationParametersValidationError{} + +// Validate checks the field values on CheckOperationsResult with the rules +// defined in the proto definition for this message. If any rules are +// violated, the first error encountered is returned, or nil if there are no violations. +func (m *CheckOperationsResult) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on CheckOperationsResult with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// CheckOperationsResultMultiError, or nil if none found. +func (m *CheckOperationsResult) ValidateAll() error { + return m.validate(true) +} + +func (m *CheckOperationsResult) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Membership + + if all { + switch v := interface{}(m.GetCheckError()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, CheckOperationsResultValidationError{ + field: "CheckError", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, CheckOperationsResultValidationError{ + field: "CheckError", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetCheckError()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return CheckOperationsResultValidationError{ + field: "CheckError", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if all { + switch v := interface{}(m.GetDebugInformation()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, CheckOperationsResultValidationError{ + field: "DebugInformation", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, CheckOperationsResultValidationError{ + field: "DebugInformation", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetDebugInformation()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return CheckOperationsResultValidationError{ + field: "DebugInformation", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if all { + switch v := interface{}(m.GetPartialCaveatInfo()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, CheckOperationsResultValidationError{ + field: "PartialCaveatInfo", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, CheckOperationsResultValidationError{ + field: "PartialCaveatInfo", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetPartialCaveatInfo()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return CheckOperationsResultValidationError{ + field: "PartialCaveatInfo", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if all { + switch v := interface{}(m.GetResolvedDebugInformation()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, CheckOperationsResultValidationError{ + field: "ResolvedDebugInformation", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, CheckOperationsResultValidationError{ + field: "ResolvedDebugInformation", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetResolvedDebugInformation()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return CheckOperationsResultValidationError{ + field: "ResolvedDebugInformation", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return CheckOperationsResultMultiError(errors) + } + + return nil +} + +// CheckOperationsResultMultiError is an error wrapping multiple validation +// errors returned by CheckOperationsResult.ValidateAll() if the designated +// constraints aren't met. +type CheckOperationsResultMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m CheckOperationsResultMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m CheckOperationsResultMultiError) AllErrors() []error { return m } + +// CheckOperationsResultValidationError is the validation error returned by +// CheckOperationsResult.Validate if the designated constraints aren't met. +type CheckOperationsResultValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e CheckOperationsResultValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e CheckOperationsResultValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e CheckOperationsResultValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e CheckOperationsResultValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e CheckOperationsResultValidationError) ErrorName() string { + return "CheckOperationsResultValidationError" +} + +// Error satisfies the builtin error interface +func (e CheckOperationsResultValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sCheckOperationsResult.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = CheckOperationsResultValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = CheckOperationsResultValidationError{} + +// Validate checks the field values on PartialCaveatInfo with the rules defined +// in the proto definition for this message. If any rules are violated, the +// first error encountered is returned, or nil if there are no violations. +func (m *PartialCaveatInfo) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on PartialCaveatInfo with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// PartialCaveatInfoMultiError, or nil if none found. +func (m *PartialCaveatInfo) ValidateAll() error { + return m.validate(true) +} + +func (m *PartialCaveatInfo) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if len(m.GetMissingRequiredContext()) < 1 { + err := PartialCaveatInfoValidationError{ + field: "MissingRequiredContext", + reason: "value must contain at least 1 item(s)", + } + if !all { + return err + } + errors = append(errors, err) + } + + if len(errors) > 0 { + return PartialCaveatInfoMultiError(errors) + } + + return nil +} + +// PartialCaveatInfoMultiError is an error wrapping multiple validation errors +// returned by PartialCaveatInfo.ValidateAll() if the designated constraints +// aren't met. +type PartialCaveatInfoMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m PartialCaveatInfoMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m PartialCaveatInfoMultiError) AllErrors() []error { return m } + +// PartialCaveatInfoValidationError is the validation error returned by +// PartialCaveatInfo.Validate if the designated constraints aren't met. +type PartialCaveatInfoValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e PartialCaveatInfoValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e PartialCaveatInfoValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e PartialCaveatInfoValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e PartialCaveatInfoValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e PartialCaveatInfoValidationError) ErrorName() string { + return "PartialCaveatInfoValidationError" +} + +// Error satisfies the builtin error interface +func (e PartialCaveatInfoValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sPartialCaveatInfo.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = PartialCaveatInfoValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = PartialCaveatInfoValidationError{} + +// Validate checks the field values on RunAssertionsParameters with the rules +// defined in the proto definition for this message. If any rules are +// violated, the first error encountered is returned, or nil if there are no violations. +func (m *RunAssertionsParameters) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on RunAssertionsParameters with the +// rules defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// RunAssertionsParametersMultiError, or nil if none found. +func (m *RunAssertionsParameters) ValidateAll() error { + return m.validate(true) +} + +func (m *RunAssertionsParameters) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for AssertionsYaml + + if len(errors) > 0 { + return RunAssertionsParametersMultiError(errors) + } + + return nil +} + +// RunAssertionsParametersMultiError is an error wrapping multiple validation +// errors returned by RunAssertionsParameters.ValidateAll() if the designated +// constraints aren't met. +type RunAssertionsParametersMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m RunAssertionsParametersMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m RunAssertionsParametersMultiError) AllErrors() []error { return m } + +// RunAssertionsParametersValidationError is the validation error returned by +// RunAssertionsParameters.Validate if the designated constraints aren't met. +type RunAssertionsParametersValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e RunAssertionsParametersValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e RunAssertionsParametersValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e RunAssertionsParametersValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e RunAssertionsParametersValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e RunAssertionsParametersValidationError) ErrorName() string { + return "RunAssertionsParametersValidationError" +} + +// Error satisfies the builtin error interface +func (e RunAssertionsParametersValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sRunAssertionsParameters.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = RunAssertionsParametersValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = RunAssertionsParametersValidationError{} + +// Validate checks the field values on RunAssertionsResult with the rules +// defined in the proto definition for this message. If any rules are +// violated, the first error encountered is returned, or nil if there are no violations. +func (m *RunAssertionsResult) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on RunAssertionsResult with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// RunAssertionsResultMultiError, or nil if none found. +func (m *RunAssertionsResult) ValidateAll() error { + return m.validate(true) +} + +func (m *RunAssertionsResult) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetInputError()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, RunAssertionsResultValidationError{ + field: "InputError", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, RunAssertionsResultValidationError{ + field: "InputError", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetInputError()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return RunAssertionsResultValidationError{ + field: "InputError", + reason: "embedded message failed validation", + cause: err, + } + } + } + + for idx, item := range m.GetValidationErrors() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, RunAssertionsResultValidationError{ + field: fmt.Sprintf("ValidationErrors[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, RunAssertionsResultValidationError{ + field: fmt.Sprintf("ValidationErrors[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return RunAssertionsResultValidationError{ + field: fmt.Sprintf("ValidationErrors[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + if len(errors) > 0 { + return RunAssertionsResultMultiError(errors) + } + + return nil +} + +// RunAssertionsResultMultiError is an error wrapping multiple validation +// errors returned by RunAssertionsResult.ValidateAll() if the designated +// constraints aren't met. +type RunAssertionsResultMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m RunAssertionsResultMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m RunAssertionsResultMultiError) AllErrors() []error { return m } + +// RunAssertionsResultValidationError is the validation error returned by +// RunAssertionsResult.Validate if the designated constraints aren't met. +type RunAssertionsResultValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e RunAssertionsResultValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e RunAssertionsResultValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e RunAssertionsResultValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e RunAssertionsResultValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e RunAssertionsResultValidationError) ErrorName() string { + return "RunAssertionsResultValidationError" +} + +// Error satisfies the builtin error interface +func (e RunAssertionsResultValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sRunAssertionsResult.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = RunAssertionsResultValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = RunAssertionsResultValidationError{} + +// Validate checks the field values on RunValidationParameters with the rules +// defined in the proto definition for this message. If any rules are +// violated, the first error encountered is returned, or nil if there are no violations. +func (m *RunValidationParameters) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on RunValidationParameters with the +// rules defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// RunValidationParametersMultiError, or nil if none found. +func (m *RunValidationParameters) ValidateAll() error { + return m.validate(true) +} + +func (m *RunValidationParameters) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for ValidationYaml + + if len(errors) > 0 { + return RunValidationParametersMultiError(errors) + } + + return nil +} + +// RunValidationParametersMultiError is an error wrapping multiple validation +// errors returned by RunValidationParameters.ValidateAll() if the designated +// constraints aren't met. +type RunValidationParametersMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m RunValidationParametersMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m RunValidationParametersMultiError) AllErrors() []error { return m } + +// RunValidationParametersValidationError is the validation error returned by +// RunValidationParameters.Validate if the designated constraints aren't met. +type RunValidationParametersValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e RunValidationParametersValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e RunValidationParametersValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e RunValidationParametersValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e RunValidationParametersValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e RunValidationParametersValidationError) ErrorName() string { + return "RunValidationParametersValidationError" +} + +// Error satisfies the builtin error interface +func (e RunValidationParametersValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sRunValidationParameters.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = RunValidationParametersValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = RunValidationParametersValidationError{} + +// Validate checks the field values on RunValidationResult with the rules +// defined in the proto definition for this message. If any rules are +// violated, the first error encountered is returned, or nil if there are no violations. +func (m *RunValidationResult) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on RunValidationResult with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// RunValidationResultMultiError, or nil if none found. +func (m *RunValidationResult) ValidateAll() error { + return m.validate(true) +} + +func (m *RunValidationResult) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetInputError()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, RunValidationResultValidationError{ + field: "InputError", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, RunValidationResultValidationError{ + field: "InputError", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetInputError()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return RunValidationResultValidationError{ + field: "InputError", + reason: "embedded message failed validation", + cause: err, + } + } + } + + // no validation rules for UpdatedValidationYaml + + for idx, item := range m.GetValidationErrors() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, RunValidationResultValidationError{ + field: fmt.Sprintf("ValidationErrors[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, RunValidationResultValidationError{ + field: fmt.Sprintf("ValidationErrors[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return RunValidationResultValidationError{ + field: fmt.Sprintf("ValidationErrors[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + if len(errors) > 0 { + return RunValidationResultMultiError(errors) + } + + return nil +} + +// RunValidationResultMultiError is an error wrapping multiple validation +// errors returned by RunValidationResult.ValidateAll() if the designated +// constraints aren't met. +type RunValidationResultMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m RunValidationResultMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m RunValidationResultMultiError) AllErrors() []error { return m } + +// RunValidationResultValidationError is the validation error returned by +// RunValidationResult.Validate if the designated constraints aren't met. +type RunValidationResultValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e RunValidationResultValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e RunValidationResultValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e RunValidationResultValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e RunValidationResultValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e RunValidationResultValidationError) ErrorName() string { + return "RunValidationResultValidationError" +} + +// Error satisfies the builtin error interface +func (e RunValidationResultValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sRunValidationResult.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = RunValidationResultValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = RunValidationResultValidationError{} + +// Validate checks the field values on FormatSchemaParameters with the rules +// defined in the proto definition for this message. If any rules are +// violated, the first error encountered is returned, or nil if there are no violations. +func (m *FormatSchemaParameters) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on FormatSchemaParameters with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// FormatSchemaParametersMultiError, or nil if none found. +func (m *FormatSchemaParameters) ValidateAll() error { + return m.validate(true) +} + +func (m *FormatSchemaParameters) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if len(errors) > 0 { + return FormatSchemaParametersMultiError(errors) + } + + return nil +} + +// FormatSchemaParametersMultiError is an error wrapping multiple validation +// errors returned by FormatSchemaParameters.ValidateAll() if the designated +// constraints aren't met. +type FormatSchemaParametersMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m FormatSchemaParametersMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m FormatSchemaParametersMultiError) AllErrors() []error { return m } + +// FormatSchemaParametersValidationError is the validation error returned by +// FormatSchemaParameters.Validate if the designated constraints aren't met. +type FormatSchemaParametersValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e FormatSchemaParametersValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e FormatSchemaParametersValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e FormatSchemaParametersValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e FormatSchemaParametersValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e FormatSchemaParametersValidationError) ErrorName() string { + return "FormatSchemaParametersValidationError" +} + +// Error satisfies the builtin error interface +func (e FormatSchemaParametersValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sFormatSchemaParameters.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = FormatSchemaParametersValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = FormatSchemaParametersValidationError{} + +// Validate checks the field values on FormatSchemaResult with the rules +// defined in the proto definition for this message. If any rules are +// violated, the first error encountered is returned, or nil if there are no violations. +func (m *FormatSchemaResult) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on FormatSchemaResult with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// FormatSchemaResultMultiError, or nil if none found. +func (m *FormatSchemaResult) ValidateAll() error { + return m.validate(true) +} + +func (m *FormatSchemaResult) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for FormattedSchema + + if len(errors) > 0 { + return FormatSchemaResultMultiError(errors) + } + + return nil +} + +// FormatSchemaResultMultiError is an error wrapping multiple validation errors +// returned by FormatSchemaResult.ValidateAll() if the designated constraints +// aren't met. +type FormatSchemaResultMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m FormatSchemaResultMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m FormatSchemaResultMultiError) AllErrors() []error { return m } + +// FormatSchemaResultValidationError is the validation error returned by +// FormatSchemaResult.Validate if the designated constraints aren't met. +type FormatSchemaResultValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e FormatSchemaResultValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e FormatSchemaResultValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e FormatSchemaResultValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e FormatSchemaResultValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e FormatSchemaResultValidationError) ErrorName() string { + return "FormatSchemaResultValidationError" +} + +// Error satisfies the builtin error interface +func (e FormatSchemaResultValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sFormatSchemaResult.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = FormatSchemaResultValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = FormatSchemaResultValidationError{} + +// Validate checks the field values on SchemaWarningsParameters with the rules +// defined in the proto definition for this message. If any rules are +// violated, the first error encountered is returned, or nil if there are no violations. +func (m *SchemaWarningsParameters) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on SchemaWarningsParameters with the +// rules defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// SchemaWarningsParametersMultiError, or nil if none found. +func (m *SchemaWarningsParameters) ValidateAll() error { + return m.validate(true) +} + +func (m *SchemaWarningsParameters) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if len(errors) > 0 { + return SchemaWarningsParametersMultiError(errors) + } + + return nil +} + +// SchemaWarningsParametersMultiError is an error wrapping multiple validation +// errors returned by SchemaWarningsParameters.ValidateAll() if the designated +// constraints aren't met. +type SchemaWarningsParametersMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m SchemaWarningsParametersMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m SchemaWarningsParametersMultiError) AllErrors() []error { return m } + +// SchemaWarningsParametersValidationError is the validation error returned by +// SchemaWarningsParameters.Validate if the designated constraints aren't met. +type SchemaWarningsParametersValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e SchemaWarningsParametersValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e SchemaWarningsParametersValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e SchemaWarningsParametersValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e SchemaWarningsParametersValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e SchemaWarningsParametersValidationError) ErrorName() string { + return "SchemaWarningsParametersValidationError" +} + +// Error satisfies the builtin error interface +func (e SchemaWarningsParametersValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sSchemaWarningsParameters.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = SchemaWarningsParametersValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = SchemaWarningsParametersValidationError{} + +// Validate checks the field values on SchemaWarningsResult with the rules +// defined in the proto definition for this message. If any rules are +// violated, the first error encountered is returned, or nil if there are no violations. +func (m *SchemaWarningsResult) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on SchemaWarningsResult with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// SchemaWarningsResultMultiError, or nil if none found. +func (m *SchemaWarningsResult) ValidateAll() error { + return m.validate(true) +} + +func (m *SchemaWarningsResult) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + for idx, item := range m.GetWarnings() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, SchemaWarningsResultValidationError{ + field: fmt.Sprintf("Warnings[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, SchemaWarningsResultValidationError{ + field: fmt.Sprintf("Warnings[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return SchemaWarningsResultValidationError{ + field: fmt.Sprintf("Warnings[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + if len(errors) > 0 { + return SchemaWarningsResultMultiError(errors) + } + + return nil +} + +// SchemaWarningsResultMultiError is an error wrapping multiple validation +// errors returned by SchemaWarningsResult.ValidateAll() if the designated +// constraints aren't met. +type SchemaWarningsResultMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m SchemaWarningsResultMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m SchemaWarningsResultMultiError) AllErrors() []error { return m } + +// SchemaWarningsResultValidationError is the validation error returned by +// SchemaWarningsResult.Validate if the designated constraints aren't met. +type SchemaWarningsResultValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e SchemaWarningsResultValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e SchemaWarningsResultValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e SchemaWarningsResultValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e SchemaWarningsResultValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e SchemaWarningsResultValidationError) ErrorName() string { + return "SchemaWarningsResultValidationError" +} + +// Error satisfies the builtin error interface +func (e SchemaWarningsResultValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sSchemaWarningsResult.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = SchemaWarningsResultValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = SchemaWarningsResultValidationError{} diff --git a/vendor/github.com/authzed/spicedb/pkg/proto/developer/v1/developer_vtproto.pb.go b/vendor/github.com/authzed/spicedb/pkg/proto/developer/v1/developer_vtproto.pb.go new file mode 100644 index 0000000..8f53dc6 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/proto/developer/v1/developer_vtproto.pb.go @@ -0,0 +1,5544 @@ +// Code generated by protoc-gen-go-vtproto. DO NOT EDIT. +// protoc-gen-go-vtproto version: v0.6.1-0.20240409071808-615f978279ca +// source: developer/v1/developer.proto + +package developerv1 + +import ( + fmt "fmt" + v12 "github.com/authzed/authzed-go/proto/authzed/api/v1" + v1 "github.com/authzed/spicedb/pkg/proto/core/v1" + v11 "github.com/authzed/spicedb/pkg/proto/dispatch/v1" + protohelpers "github.com/planetscale/vtprotobuf/protohelpers" + structpb1 "github.com/planetscale/vtprotobuf/types/known/structpb" + proto "google.golang.org/protobuf/proto" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + structpb "google.golang.org/protobuf/types/known/structpb" + io "io" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +func (m *DeveloperRequest) CloneVT() *DeveloperRequest { + if m == nil { + return (*DeveloperRequest)(nil) + } + r := new(DeveloperRequest) + r.Context = m.Context.CloneVT() + if rhs := m.Operations; rhs != nil { + tmpContainer := make([]*Operation, len(rhs)) + for k, v := range rhs { + tmpContainer[k] = v.CloneVT() + } + r.Operations = tmpContainer + } + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *DeveloperRequest) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *DeveloperResponse) CloneVT() *DeveloperResponse { + if m == nil { + return (*DeveloperResponse)(nil) + } + r := new(DeveloperResponse) + r.InternalError = m.InternalError + r.DeveloperErrors = m.DeveloperErrors.CloneVT() + r.OperationsResults = m.OperationsResults.CloneVT() + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *DeveloperResponse) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *RequestContext) CloneVT() *RequestContext { + if m == nil { + return (*RequestContext)(nil) + } + r := new(RequestContext) + r.Schema = m.Schema + if rhs := m.Relationships; rhs != nil { + tmpContainer := make([]*v1.RelationTuple, len(rhs)) + for k, v := range rhs { + if vtpb, ok := interface{}(v).(interface{ CloneVT() *v1.RelationTuple }); ok { + tmpContainer[k] = vtpb.CloneVT() + } else { + tmpContainer[k] = proto.Clone(v).(*v1.RelationTuple) + } + } + r.Relationships = tmpContainer + } + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *RequestContext) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *Operation) CloneVT() *Operation { + if m == nil { + return (*Operation)(nil) + } + r := new(Operation) + r.CheckParameters = m.CheckParameters.CloneVT() + r.AssertionsParameters = m.AssertionsParameters.CloneVT() + r.ValidationParameters = m.ValidationParameters.CloneVT() + r.FormatSchemaParameters = m.FormatSchemaParameters.CloneVT() + r.SchemaWarningsParameters = m.SchemaWarningsParameters.CloneVT() + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *Operation) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *OperationsResults) CloneVT() *OperationsResults { + if m == nil { + return (*OperationsResults)(nil) + } + r := new(OperationsResults) + if rhs := m.Results; rhs != nil { + tmpContainer := make(map[uint64]*OperationResult, len(rhs)) + for k, v := range rhs { + tmpContainer[k] = v.CloneVT() + } + r.Results = tmpContainer + } + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *OperationsResults) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *OperationResult) CloneVT() *OperationResult { + if m == nil { + return (*OperationResult)(nil) + } + r := new(OperationResult) + r.CheckResult = m.CheckResult.CloneVT() + r.AssertionsResult = m.AssertionsResult.CloneVT() + r.ValidationResult = m.ValidationResult.CloneVT() + r.FormatSchemaResult = m.FormatSchemaResult.CloneVT() + r.SchemaWarningsResult = m.SchemaWarningsResult.CloneVT() + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *OperationResult) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *DeveloperWarning) CloneVT() *DeveloperWarning { + if m == nil { + return (*DeveloperWarning)(nil) + } + r := new(DeveloperWarning) + r.Message = m.Message + r.Line = m.Line + r.Column = m.Column + r.SourceCode = m.SourceCode + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *DeveloperWarning) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *DeveloperError) CloneVT() *DeveloperError { + if m == nil { + return (*DeveloperError)(nil) + } + r := new(DeveloperError) + r.Message = m.Message + r.Line = m.Line + r.Column = m.Column + r.Source = m.Source + r.Kind = m.Kind + r.Context = m.Context + if rhs := m.Path; rhs != nil { + tmpContainer := make([]string, len(rhs)) + copy(tmpContainer, rhs) + r.Path = tmpContainer + } + if rhs := m.CheckDebugInformation; rhs != nil { + if vtpb, ok := interface{}(rhs).(interface{ CloneVT() *v11.DebugInformation }); ok { + r.CheckDebugInformation = vtpb.CloneVT() + } else { + r.CheckDebugInformation = proto.Clone(rhs).(*v11.DebugInformation) + } + } + if rhs := m.CheckResolvedDebugInformation; rhs != nil { + if vtpb, ok := interface{}(rhs).(interface{ CloneVT() *v12.DebugInformation }); ok { + r.CheckResolvedDebugInformation = vtpb.CloneVT() + } else { + r.CheckResolvedDebugInformation = proto.Clone(rhs).(*v12.DebugInformation) + } + } + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *DeveloperError) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *DeveloperErrors) CloneVT() *DeveloperErrors { + if m == nil { + return (*DeveloperErrors)(nil) + } + r := new(DeveloperErrors) + if rhs := m.InputErrors; rhs != nil { + tmpContainer := make([]*DeveloperError, len(rhs)) + for k, v := range rhs { + tmpContainer[k] = v.CloneVT() + } + r.InputErrors = tmpContainer + } + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *DeveloperErrors) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *CheckOperationParameters) CloneVT() *CheckOperationParameters { + if m == nil { + return (*CheckOperationParameters)(nil) + } + r := new(CheckOperationParameters) + r.CaveatContext = (*structpb.Struct)((*structpb1.Struct)(m.CaveatContext).CloneVT()) + if rhs := m.Resource; rhs != nil { + if vtpb, ok := interface{}(rhs).(interface{ CloneVT() *v1.ObjectAndRelation }); ok { + r.Resource = vtpb.CloneVT() + } else { + r.Resource = proto.Clone(rhs).(*v1.ObjectAndRelation) + } + } + if rhs := m.Subject; rhs != nil { + if vtpb, ok := interface{}(rhs).(interface{ CloneVT() *v1.ObjectAndRelation }); ok { + r.Subject = vtpb.CloneVT() + } else { + r.Subject = proto.Clone(rhs).(*v1.ObjectAndRelation) + } + } + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *CheckOperationParameters) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *CheckOperationsResult) CloneVT() *CheckOperationsResult { + if m == nil { + return (*CheckOperationsResult)(nil) + } + r := new(CheckOperationsResult) + r.Membership = m.Membership + r.CheckError = m.CheckError.CloneVT() + r.PartialCaveatInfo = m.PartialCaveatInfo.CloneVT() + if rhs := m.DebugInformation; rhs != nil { + if vtpb, ok := interface{}(rhs).(interface{ CloneVT() *v11.DebugInformation }); ok { + r.DebugInformation = vtpb.CloneVT() + } else { + r.DebugInformation = proto.Clone(rhs).(*v11.DebugInformation) + } + } + if rhs := m.ResolvedDebugInformation; rhs != nil { + if vtpb, ok := interface{}(rhs).(interface{ CloneVT() *v12.DebugInformation }); ok { + r.ResolvedDebugInformation = vtpb.CloneVT() + } else { + r.ResolvedDebugInformation = proto.Clone(rhs).(*v12.DebugInformation) + } + } + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *CheckOperationsResult) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *PartialCaveatInfo) CloneVT() *PartialCaveatInfo { + if m == nil { + return (*PartialCaveatInfo)(nil) + } + r := new(PartialCaveatInfo) + if rhs := m.MissingRequiredContext; rhs != nil { + tmpContainer := make([]string, len(rhs)) + copy(tmpContainer, rhs) + r.MissingRequiredContext = tmpContainer + } + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *PartialCaveatInfo) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *RunAssertionsParameters) CloneVT() *RunAssertionsParameters { + if m == nil { + return (*RunAssertionsParameters)(nil) + } + r := new(RunAssertionsParameters) + r.AssertionsYaml = m.AssertionsYaml + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *RunAssertionsParameters) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *RunAssertionsResult) CloneVT() *RunAssertionsResult { + if m == nil { + return (*RunAssertionsResult)(nil) + } + r := new(RunAssertionsResult) + r.InputError = m.InputError.CloneVT() + if rhs := m.ValidationErrors; rhs != nil { + tmpContainer := make([]*DeveloperError, len(rhs)) + for k, v := range rhs { + tmpContainer[k] = v.CloneVT() + } + r.ValidationErrors = tmpContainer + } + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *RunAssertionsResult) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *RunValidationParameters) CloneVT() *RunValidationParameters { + if m == nil { + return (*RunValidationParameters)(nil) + } + r := new(RunValidationParameters) + r.ValidationYaml = m.ValidationYaml + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *RunValidationParameters) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *RunValidationResult) CloneVT() *RunValidationResult { + if m == nil { + return (*RunValidationResult)(nil) + } + r := new(RunValidationResult) + r.InputError = m.InputError.CloneVT() + r.UpdatedValidationYaml = m.UpdatedValidationYaml + if rhs := m.ValidationErrors; rhs != nil { + tmpContainer := make([]*DeveloperError, len(rhs)) + for k, v := range rhs { + tmpContainer[k] = v.CloneVT() + } + r.ValidationErrors = tmpContainer + } + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *RunValidationResult) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *FormatSchemaParameters) CloneVT() *FormatSchemaParameters { + if m == nil { + return (*FormatSchemaParameters)(nil) + } + r := new(FormatSchemaParameters) + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *FormatSchemaParameters) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *FormatSchemaResult) CloneVT() *FormatSchemaResult { + if m == nil { + return (*FormatSchemaResult)(nil) + } + r := new(FormatSchemaResult) + r.FormattedSchema = m.FormattedSchema + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *FormatSchemaResult) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *SchemaWarningsParameters) CloneVT() *SchemaWarningsParameters { + if m == nil { + return (*SchemaWarningsParameters)(nil) + } + r := new(SchemaWarningsParameters) + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *SchemaWarningsParameters) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *SchemaWarningsResult) CloneVT() *SchemaWarningsResult { + if m == nil { + return (*SchemaWarningsResult)(nil) + } + r := new(SchemaWarningsResult) + if rhs := m.Warnings; rhs != nil { + tmpContainer := make([]*DeveloperWarning, len(rhs)) + for k, v := range rhs { + tmpContainer[k] = v.CloneVT() + } + r.Warnings = tmpContainer + } + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *SchemaWarningsResult) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (this *DeveloperRequest) EqualVT(that *DeveloperRequest) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if !this.Context.EqualVT(that.Context) { + return false + } + if len(this.Operations) != len(that.Operations) { + return false + } + for i, vx := range this.Operations { + vy := that.Operations[i] + if p, q := vx, vy; p != q { + if p == nil { + p = &Operation{} + } + if q == nil { + q = &Operation{} + } + if !p.EqualVT(q) { + return false + } + } + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *DeveloperRequest) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*DeveloperRequest) + if !ok { + return false + } + return this.EqualVT(that) +} +func (this *DeveloperResponse) EqualVT(that *DeveloperResponse) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if this.InternalError != that.InternalError { + return false + } + if !this.DeveloperErrors.EqualVT(that.DeveloperErrors) { + return false + } + if !this.OperationsResults.EqualVT(that.OperationsResults) { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *DeveloperResponse) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*DeveloperResponse) + if !ok { + return false + } + return this.EqualVT(that) +} +func (this *RequestContext) EqualVT(that *RequestContext) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if this.Schema != that.Schema { + return false + } + if len(this.Relationships) != len(that.Relationships) { + return false + } + for i, vx := range this.Relationships { + vy := that.Relationships[i] + if p, q := vx, vy; p != q { + if p == nil { + p = &v1.RelationTuple{} + } + if q == nil { + q = &v1.RelationTuple{} + } + if equal, ok := interface{}(p).(interface{ EqualVT(*v1.RelationTuple) bool }); ok { + if !equal.EqualVT(q) { + return false + } + } else if !proto.Equal(p, q) { + return false + } + } + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *RequestContext) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*RequestContext) + if !ok { + return false + } + return this.EqualVT(that) +} +func (this *Operation) EqualVT(that *Operation) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if !this.CheckParameters.EqualVT(that.CheckParameters) { + return false + } + if !this.AssertionsParameters.EqualVT(that.AssertionsParameters) { + return false + } + if !this.ValidationParameters.EqualVT(that.ValidationParameters) { + return false + } + if !this.FormatSchemaParameters.EqualVT(that.FormatSchemaParameters) { + return false + } + if !this.SchemaWarningsParameters.EqualVT(that.SchemaWarningsParameters) { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *Operation) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*Operation) + if !ok { + return false + } + return this.EqualVT(that) +} +func (this *OperationsResults) EqualVT(that *OperationsResults) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if len(this.Results) != len(that.Results) { + return false + } + for i, vx := range this.Results { + vy, ok := that.Results[i] + if !ok { + return false + } + if p, q := vx, vy; p != q { + if p == nil { + p = &OperationResult{} + } + if q == nil { + q = &OperationResult{} + } + if !p.EqualVT(q) { + return false + } + } + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *OperationsResults) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*OperationsResults) + if !ok { + return false + } + return this.EqualVT(that) +} +func (this *OperationResult) EqualVT(that *OperationResult) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if !this.CheckResult.EqualVT(that.CheckResult) { + return false + } + if !this.AssertionsResult.EqualVT(that.AssertionsResult) { + return false + } + if !this.ValidationResult.EqualVT(that.ValidationResult) { + return false + } + if !this.FormatSchemaResult.EqualVT(that.FormatSchemaResult) { + return false + } + if !this.SchemaWarningsResult.EqualVT(that.SchemaWarningsResult) { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *OperationResult) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*OperationResult) + if !ok { + return false + } + return this.EqualVT(that) +} +func (this *DeveloperWarning) EqualVT(that *DeveloperWarning) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if this.Message != that.Message { + return false + } + if this.Line != that.Line { + return false + } + if this.Column != that.Column { + return false + } + if this.SourceCode != that.SourceCode { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *DeveloperWarning) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*DeveloperWarning) + if !ok { + return false + } + return this.EqualVT(that) +} +func (this *DeveloperError) EqualVT(that *DeveloperError) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if this.Message != that.Message { + return false + } + if this.Line != that.Line { + return false + } + if this.Column != that.Column { + return false + } + if this.Source != that.Source { + return false + } + if this.Kind != that.Kind { + return false + } + if len(this.Path) != len(that.Path) { + return false + } + for i, vx := range this.Path { + vy := that.Path[i] + if vx != vy { + return false + } + } + if this.Context != that.Context { + return false + } + if equal, ok := interface{}(this.CheckDebugInformation).(interface { + EqualVT(*v11.DebugInformation) bool + }); ok { + if !equal.EqualVT(that.CheckDebugInformation) { + return false + } + } else if !proto.Equal(this.CheckDebugInformation, that.CheckDebugInformation) { + return false + } + if equal, ok := interface{}(this.CheckResolvedDebugInformation).(interface { + EqualVT(*v12.DebugInformation) bool + }); ok { + if !equal.EqualVT(that.CheckResolvedDebugInformation) { + return false + } + } else if !proto.Equal(this.CheckResolvedDebugInformation, that.CheckResolvedDebugInformation) { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *DeveloperError) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*DeveloperError) + if !ok { + return false + } + return this.EqualVT(that) +} +func (this *DeveloperErrors) EqualVT(that *DeveloperErrors) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if len(this.InputErrors) != len(that.InputErrors) { + return false + } + for i, vx := range this.InputErrors { + vy := that.InputErrors[i] + if p, q := vx, vy; p != q { + if p == nil { + p = &DeveloperError{} + } + if q == nil { + q = &DeveloperError{} + } + if !p.EqualVT(q) { + return false + } + } + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *DeveloperErrors) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*DeveloperErrors) + if !ok { + return false + } + return this.EqualVT(that) +} +func (this *CheckOperationParameters) EqualVT(that *CheckOperationParameters) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if equal, ok := interface{}(this.Resource).(interface { + EqualVT(*v1.ObjectAndRelation) bool + }); ok { + if !equal.EqualVT(that.Resource) { + return false + } + } else if !proto.Equal(this.Resource, that.Resource) { + return false + } + if equal, ok := interface{}(this.Subject).(interface { + EqualVT(*v1.ObjectAndRelation) bool + }); ok { + if !equal.EqualVT(that.Subject) { + return false + } + } else if !proto.Equal(this.Subject, that.Subject) { + return false + } + if !(*structpb1.Struct)(this.CaveatContext).EqualVT((*structpb1.Struct)(that.CaveatContext)) { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *CheckOperationParameters) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*CheckOperationParameters) + if !ok { + return false + } + return this.EqualVT(that) +} +func (this *CheckOperationsResult) EqualVT(that *CheckOperationsResult) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if this.Membership != that.Membership { + return false + } + if !this.CheckError.EqualVT(that.CheckError) { + return false + } + if equal, ok := interface{}(this.DebugInformation).(interface { + EqualVT(*v11.DebugInformation) bool + }); ok { + if !equal.EqualVT(that.DebugInformation) { + return false + } + } else if !proto.Equal(this.DebugInformation, that.DebugInformation) { + return false + } + if !this.PartialCaveatInfo.EqualVT(that.PartialCaveatInfo) { + return false + } + if equal, ok := interface{}(this.ResolvedDebugInformation).(interface { + EqualVT(*v12.DebugInformation) bool + }); ok { + if !equal.EqualVT(that.ResolvedDebugInformation) { + return false + } + } else if !proto.Equal(this.ResolvedDebugInformation, that.ResolvedDebugInformation) { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *CheckOperationsResult) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*CheckOperationsResult) + if !ok { + return false + } + return this.EqualVT(that) +} +func (this *PartialCaveatInfo) EqualVT(that *PartialCaveatInfo) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if len(this.MissingRequiredContext) != len(that.MissingRequiredContext) { + return false + } + for i, vx := range this.MissingRequiredContext { + vy := that.MissingRequiredContext[i] + if vx != vy { + return false + } + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *PartialCaveatInfo) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*PartialCaveatInfo) + if !ok { + return false + } + return this.EqualVT(that) +} +func (this *RunAssertionsParameters) EqualVT(that *RunAssertionsParameters) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if this.AssertionsYaml != that.AssertionsYaml { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *RunAssertionsParameters) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*RunAssertionsParameters) + if !ok { + return false + } + return this.EqualVT(that) +} +func (this *RunAssertionsResult) EqualVT(that *RunAssertionsResult) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if !this.InputError.EqualVT(that.InputError) { + return false + } + if len(this.ValidationErrors) != len(that.ValidationErrors) { + return false + } + for i, vx := range this.ValidationErrors { + vy := that.ValidationErrors[i] + if p, q := vx, vy; p != q { + if p == nil { + p = &DeveloperError{} + } + if q == nil { + q = &DeveloperError{} + } + if !p.EqualVT(q) { + return false + } + } + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *RunAssertionsResult) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*RunAssertionsResult) + if !ok { + return false + } + return this.EqualVT(that) +} +func (this *RunValidationParameters) EqualVT(that *RunValidationParameters) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if this.ValidationYaml != that.ValidationYaml { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *RunValidationParameters) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*RunValidationParameters) + if !ok { + return false + } + return this.EqualVT(that) +} +func (this *RunValidationResult) EqualVT(that *RunValidationResult) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if !this.InputError.EqualVT(that.InputError) { + return false + } + if this.UpdatedValidationYaml != that.UpdatedValidationYaml { + return false + } + if len(this.ValidationErrors) != len(that.ValidationErrors) { + return false + } + for i, vx := range this.ValidationErrors { + vy := that.ValidationErrors[i] + if p, q := vx, vy; p != q { + if p == nil { + p = &DeveloperError{} + } + if q == nil { + q = &DeveloperError{} + } + if !p.EqualVT(q) { + return false + } + } + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *RunValidationResult) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*RunValidationResult) + if !ok { + return false + } + return this.EqualVT(that) +} +func (this *FormatSchemaParameters) EqualVT(that *FormatSchemaParameters) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *FormatSchemaParameters) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*FormatSchemaParameters) + if !ok { + return false + } + return this.EqualVT(that) +} +func (this *FormatSchemaResult) EqualVT(that *FormatSchemaResult) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if this.FormattedSchema != that.FormattedSchema { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *FormatSchemaResult) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*FormatSchemaResult) + if !ok { + return false + } + return this.EqualVT(that) +} +func (this *SchemaWarningsParameters) EqualVT(that *SchemaWarningsParameters) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *SchemaWarningsParameters) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*SchemaWarningsParameters) + if !ok { + return false + } + return this.EqualVT(that) +} +func (this *SchemaWarningsResult) EqualVT(that *SchemaWarningsResult) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if len(this.Warnings) != len(that.Warnings) { + return false + } + for i, vx := range this.Warnings { + vy := that.Warnings[i] + if p, q := vx, vy; p != q { + if p == nil { + p = &DeveloperWarning{} + } + if q == nil { + q = &DeveloperWarning{} + } + if !p.EqualVT(q) { + return false + } + } + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *SchemaWarningsResult) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*SchemaWarningsResult) + if !ok { + return false + } + return this.EqualVT(that) +} +func (m *DeveloperRequest) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *DeveloperRequest) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *DeveloperRequest) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if len(m.Operations) > 0 { + for iNdEx := len(m.Operations) - 1; iNdEx >= 0; iNdEx-- { + size, err := m.Operations[iNdEx].MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x12 + } + } + if m.Context != nil { + size, err := m.Context.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *DeveloperResponse) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *DeveloperResponse) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *DeveloperResponse) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if m.OperationsResults != nil { + size, err := m.OperationsResults.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x1a + } + if m.DeveloperErrors != nil { + size, err := m.DeveloperErrors.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x12 + } + if len(m.InternalError) > 0 { + i -= len(m.InternalError) + copy(dAtA[i:], m.InternalError) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.InternalError))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *RequestContext) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *RequestContext) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *RequestContext) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if len(m.Relationships) > 0 { + for iNdEx := len(m.Relationships) - 1; iNdEx >= 0; iNdEx-- { + if vtmsg, ok := interface{}(m.Relationships[iNdEx]).(interface { + MarshalToSizedBufferVT([]byte) (int, error) + }); ok { + size, err := vtmsg.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + } else { + encoded, err := proto.Marshal(m.Relationships[iNdEx]) + if err != nil { + return 0, err + } + i -= len(encoded) + copy(dAtA[i:], encoded) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(encoded))) + } + i-- + dAtA[i] = 0x12 + } + } + if len(m.Schema) > 0 { + i -= len(m.Schema) + copy(dAtA[i:], m.Schema) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Schema))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *Operation) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Operation) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *Operation) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if m.SchemaWarningsParameters != nil { + size, err := m.SchemaWarningsParameters.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x2a + } + if m.FormatSchemaParameters != nil { + size, err := m.FormatSchemaParameters.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x22 + } + if m.ValidationParameters != nil { + size, err := m.ValidationParameters.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x1a + } + if m.AssertionsParameters != nil { + size, err := m.AssertionsParameters.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x12 + } + if m.CheckParameters != nil { + size, err := m.CheckParameters.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *OperationsResults) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *OperationsResults) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *OperationsResults) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if len(m.Results) > 0 { + for k := range m.Results { + v := m.Results[k] + baseI := i + size, err := v.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x12 + i = protohelpers.EncodeVarint(dAtA, i, uint64(k)) + i-- + dAtA[i] = 0x8 + i = protohelpers.EncodeVarint(dAtA, i, uint64(baseI-i)) + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *OperationResult) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *OperationResult) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *OperationResult) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if m.SchemaWarningsResult != nil { + size, err := m.SchemaWarningsResult.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x2a + } + if m.FormatSchemaResult != nil { + size, err := m.FormatSchemaResult.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x22 + } + if m.ValidationResult != nil { + size, err := m.ValidationResult.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x1a + } + if m.AssertionsResult != nil { + size, err := m.AssertionsResult.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x12 + } + if m.CheckResult != nil { + size, err := m.CheckResult.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *DeveloperWarning) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *DeveloperWarning) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *DeveloperWarning) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if len(m.SourceCode) > 0 { + i -= len(m.SourceCode) + copy(dAtA[i:], m.SourceCode) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.SourceCode))) + i-- + dAtA[i] = 0x22 + } + if m.Column != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.Column)) + i-- + dAtA[i] = 0x18 + } + if m.Line != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.Line)) + i-- + dAtA[i] = 0x10 + } + if len(m.Message) > 0 { + i -= len(m.Message) + copy(dAtA[i:], m.Message) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Message))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *DeveloperError) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *DeveloperError) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *DeveloperError) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if m.CheckResolvedDebugInformation != nil { + if vtmsg, ok := interface{}(m.CheckResolvedDebugInformation).(interface { + MarshalToSizedBufferVT([]byte) (int, error) + }); ok { + size, err := vtmsg.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + } else { + encoded, err := proto.Marshal(m.CheckResolvedDebugInformation) + if err != nil { + return 0, err + } + i -= len(encoded) + copy(dAtA[i:], encoded) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(encoded))) + } + i-- + dAtA[i] = 0x4a + } + if m.CheckDebugInformation != nil { + if vtmsg, ok := interface{}(m.CheckDebugInformation).(interface { + MarshalToSizedBufferVT([]byte) (int, error) + }); ok { + size, err := vtmsg.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + } else { + encoded, err := proto.Marshal(m.CheckDebugInformation) + if err != nil { + return 0, err + } + i -= len(encoded) + copy(dAtA[i:], encoded) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(encoded))) + } + i-- + dAtA[i] = 0x42 + } + if len(m.Context) > 0 { + i -= len(m.Context) + copy(dAtA[i:], m.Context) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Context))) + i-- + dAtA[i] = 0x3a + } + if len(m.Path) > 0 { + for iNdEx := len(m.Path) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Path[iNdEx]) + copy(dAtA[i:], m.Path[iNdEx]) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Path[iNdEx]))) + i-- + dAtA[i] = 0x32 + } + } + if m.Kind != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.Kind)) + i-- + dAtA[i] = 0x28 + } + if m.Source != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.Source)) + i-- + dAtA[i] = 0x20 + } + if m.Column != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.Column)) + i-- + dAtA[i] = 0x18 + } + if m.Line != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.Line)) + i-- + dAtA[i] = 0x10 + } + if len(m.Message) > 0 { + i -= len(m.Message) + copy(dAtA[i:], m.Message) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Message))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *DeveloperErrors) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *DeveloperErrors) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *DeveloperErrors) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if len(m.InputErrors) > 0 { + for iNdEx := len(m.InputErrors) - 1; iNdEx >= 0; iNdEx-- { + size, err := m.InputErrors[iNdEx].MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *CheckOperationParameters) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *CheckOperationParameters) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *CheckOperationParameters) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if m.CaveatContext != nil { + size, err := (*structpb1.Struct)(m.CaveatContext).MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x1a + } + if m.Subject != nil { + if vtmsg, ok := interface{}(m.Subject).(interface { + MarshalToSizedBufferVT([]byte) (int, error) + }); ok { + size, err := vtmsg.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + } else { + encoded, err := proto.Marshal(m.Subject) + if err != nil { + return 0, err + } + i -= len(encoded) + copy(dAtA[i:], encoded) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(encoded))) + } + i-- + dAtA[i] = 0x12 + } + if m.Resource != nil { + if vtmsg, ok := interface{}(m.Resource).(interface { + MarshalToSizedBufferVT([]byte) (int, error) + }); ok { + size, err := vtmsg.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + } else { + encoded, err := proto.Marshal(m.Resource) + if err != nil { + return 0, err + } + i -= len(encoded) + copy(dAtA[i:], encoded) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(encoded))) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *CheckOperationsResult) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *CheckOperationsResult) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *CheckOperationsResult) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if m.ResolvedDebugInformation != nil { + if vtmsg, ok := interface{}(m.ResolvedDebugInformation).(interface { + MarshalToSizedBufferVT([]byte) (int, error) + }); ok { + size, err := vtmsg.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + } else { + encoded, err := proto.Marshal(m.ResolvedDebugInformation) + if err != nil { + return 0, err + } + i -= len(encoded) + copy(dAtA[i:], encoded) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(encoded))) + } + i-- + dAtA[i] = 0x2a + } + if m.PartialCaveatInfo != nil { + size, err := m.PartialCaveatInfo.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x22 + } + if m.DebugInformation != nil { + if vtmsg, ok := interface{}(m.DebugInformation).(interface { + MarshalToSizedBufferVT([]byte) (int, error) + }); ok { + size, err := vtmsg.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + } else { + encoded, err := proto.Marshal(m.DebugInformation) + if err != nil { + return 0, err + } + i -= len(encoded) + copy(dAtA[i:], encoded) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(encoded))) + } + i-- + dAtA[i] = 0x1a + } + if m.CheckError != nil { + size, err := m.CheckError.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x12 + } + if m.Membership != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.Membership)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *PartialCaveatInfo) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *PartialCaveatInfo) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *PartialCaveatInfo) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if len(m.MissingRequiredContext) > 0 { + for iNdEx := len(m.MissingRequiredContext) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.MissingRequiredContext[iNdEx]) + copy(dAtA[i:], m.MissingRequiredContext[iNdEx]) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.MissingRequiredContext[iNdEx]))) + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *RunAssertionsParameters) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *RunAssertionsParameters) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *RunAssertionsParameters) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if len(m.AssertionsYaml) > 0 { + i -= len(m.AssertionsYaml) + copy(dAtA[i:], m.AssertionsYaml) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.AssertionsYaml))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *RunAssertionsResult) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *RunAssertionsResult) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *RunAssertionsResult) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if len(m.ValidationErrors) > 0 { + for iNdEx := len(m.ValidationErrors) - 1; iNdEx >= 0; iNdEx-- { + size, err := m.ValidationErrors[iNdEx].MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x12 + } + } + if m.InputError != nil { + size, err := m.InputError.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *RunValidationParameters) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *RunValidationParameters) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *RunValidationParameters) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if len(m.ValidationYaml) > 0 { + i -= len(m.ValidationYaml) + copy(dAtA[i:], m.ValidationYaml) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.ValidationYaml))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *RunValidationResult) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *RunValidationResult) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *RunValidationResult) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if len(m.ValidationErrors) > 0 { + for iNdEx := len(m.ValidationErrors) - 1; iNdEx >= 0; iNdEx-- { + size, err := m.ValidationErrors[iNdEx].MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x1a + } + } + if len(m.UpdatedValidationYaml) > 0 { + i -= len(m.UpdatedValidationYaml) + copy(dAtA[i:], m.UpdatedValidationYaml) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.UpdatedValidationYaml))) + i-- + dAtA[i] = 0x12 + } + if m.InputError != nil { + size, err := m.InputError.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *FormatSchemaParameters) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *FormatSchemaParameters) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *FormatSchemaParameters) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + return len(dAtA) - i, nil +} + +func (m *FormatSchemaResult) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *FormatSchemaResult) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *FormatSchemaResult) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if len(m.FormattedSchema) > 0 { + i -= len(m.FormattedSchema) + copy(dAtA[i:], m.FormattedSchema) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.FormattedSchema))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *SchemaWarningsParameters) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *SchemaWarningsParameters) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *SchemaWarningsParameters) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + return len(dAtA) - i, nil +} + +func (m *SchemaWarningsResult) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *SchemaWarningsResult) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *SchemaWarningsResult) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if len(m.Warnings) > 0 { + for iNdEx := len(m.Warnings) - 1; iNdEx >= 0; iNdEx-- { + size, err := m.Warnings[iNdEx].MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *DeveloperRequest) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Context != nil { + l = m.Context.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if len(m.Operations) > 0 { + for _, e := range m.Operations { + l = e.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + } + n += len(m.unknownFields) + return n +} + +func (m *DeveloperResponse) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.InternalError) + if l > 0 { + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if m.DeveloperErrors != nil { + l = m.DeveloperErrors.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if m.OperationsResults != nil { + l = m.OperationsResults.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + n += len(m.unknownFields) + return n +} + +func (m *RequestContext) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Schema) + if l > 0 { + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if len(m.Relationships) > 0 { + for _, e := range m.Relationships { + if size, ok := interface{}(e).(interface { + SizeVT() int + }); ok { + l = size.SizeVT() + } else { + l = proto.Size(e) + } + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + } + n += len(m.unknownFields) + return n +} + +func (m *Operation) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.CheckParameters != nil { + l = m.CheckParameters.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if m.AssertionsParameters != nil { + l = m.AssertionsParameters.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if m.ValidationParameters != nil { + l = m.ValidationParameters.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if m.FormatSchemaParameters != nil { + l = m.FormatSchemaParameters.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if m.SchemaWarningsParameters != nil { + l = m.SchemaWarningsParameters.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + n += len(m.unknownFields) + return n +} + +func (m *OperationsResults) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Results) > 0 { + for k, v := range m.Results { + _ = k + _ = v + l = 0 + if v != nil { + l = v.SizeVT() + } + l += 1 + protohelpers.SizeOfVarint(uint64(l)) + mapEntrySize := 1 + protohelpers.SizeOfVarint(uint64(k)) + l + n += mapEntrySize + 1 + protohelpers.SizeOfVarint(uint64(mapEntrySize)) + } + } + n += len(m.unknownFields) + return n +} + +func (m *OperationResult) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.CheckResult != nil { + l = m.CheckResult.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if m.AssertionsResult != nil { + l = m.AssertionsResult.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if m.ValidationResult != nil { + l = m.ValidationResult.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if m.FormatSchemaResult != nil { + l = m.FormatSchemaResult.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if m.SchemaWarningsResult != nil { + l = m.SchemaWarningsResult.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + n += len(m.unknownFields) + return n +} + +func (m *DeveloperWarning) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Message) + if l > 0 { + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if m.Line != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.Line)) + } + if m.Column != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.Column)) + } + l = len(m.SourceCode) + if l > 0 { + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + n += len(m.unknownFields) + return n +} + +func (m *DeveloperError) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Message) + if l > 0 { + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if m.Line != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.Line)) + } + if m.Column != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.Column)) + } + if m.Source != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.Source)) + } + if m.Kind != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.Kind)) + } + if len(m.Path) > 0 { + for _, s := range m.Path { + l = len(s) + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + } + l = len(m.Context) + if l > 0 { + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if m.CheckDebugInformation != nil { + if size, ok := interface{}(m.CheckDebugInformation).(interface { + SizeVT() int + }); ok { + l = size.SizeVT() + } else { + l = proto.Size(m.CheckDebugInformation) + } + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if m.CheckResolvedDebugInformation != nil { + if size, ok := interface{}(m.CheckResolvedDebugInformation).(interface { + SizeVT() int + }); ok { + l = size.SizeVT() + } else { + l = proto.Size(m.CheckResolvedDebugInformation) + } + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + n += len(m.unknownFields) + return n +} + +func (m *DeveloperErrors) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.InputErrors) > 0 { + for _, e := range m.InputErrors { + l = e.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + } + n += len(m.unknownFields) + return n +} + +func (m *CheckOperationParameters) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Resource != nil { + if size, ok := interface{}(m.Resource).(interface { + SizeVT() int + }); ok { + l = size.SizeVT() + } else { + l = proto.Size(m.Resource) + } + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if m.Subject != nil { + if size, ok := interface{}(m.Subject).(interface { + SizeVT() int + }); ok { + l = size.SizeVT() + } else { + l = proto.Size(m.Subject) + } + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if m.CaveatContext != nil { + l = (*structpb1.Struct)(m.CaveatContext).SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + n += len(m.unknownFields) + return n +} + +func (m *CheckOperationsResult) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Membership != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.Membership)) + } + if m.CheckError != nil { + l = m.CheckError.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if m.DebugInformation != nil { + if size, ok := interface{}(m.DebugInformation).(interface { + SizeVT() int + }); ok { + l = size.SizeVT() + } else { + l = proto.Size(m.DebugInformation) + } + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if m.PartialCaveatInfo != nil { + l = m.PartialCaveatInfo.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if m.ResolvedDebugInformation != nil { + if size, ok := interface{}(m.ResolvedDebugInformation).(interface { + SizeVT() int + }); ok { + l = size.SizeVT() + } else { + l = proto.Size(m.ResolvedDebugInformation) + } + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + n += len(m.unknownFields) + return n +} + +func (m *PartialCaveatInfo) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.MissingRequiredContext) > 0 { + for _, s := range m.MissingRequiredContext { + l = len(s) + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + } + n += len(m.unknownFields) + return n +} + +func (m *RunAssertionsParameters) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.AssertionsYaml) + if l > 0 { + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + n += len(m.unknownFields) + return n +} + +func (m *RunAssertionsResult) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.InputError != nil { + l = m.InputError.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if len(m.ValidationErrors) > 0 { + for _, e := range m.ValidationErrors { + l = e.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + } + n += len(m.unknownFields) + return n +} + +func (m *RunValidationParameters) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ValidationYaml) + if l > 0 { + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + n += len(m.unknownFields) + return n +} + +func (m *RunValidationResult) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.InputError != nil { + l = m.InputError.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + l = len(m.UpdatedValidationYaml) + if l > 0 { + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if len(m.ValidationErrors) > 0 { + for _, e := range m.ValidationErrors { + l = e.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + } + n += len(m.unknownFields) + return n +} + +func (m *FormatSchemaParameters) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + n += len(m.unknownFields) + return n +} + +func (m *FormatSchemaResult) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.FormattedSchema) + if l > 0 { + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + n += len(m.unknownFields) + return n +} + +func (m *SchemaWarningsParameters) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + n += len(m.unknownFields) + return n +} + +func (m *SchemaWarningsResult) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Warnings) > 0 { + for _, e := range m.Warnings { + l = e.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + } + n += len(m.unknownFields) + return n +} + +func (m *DeveloperRequest) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: DeveloperRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: DeveloperRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Context", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Context == nil { + m.Context = &RequestContext{} + } + if err := m.Context.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Operations", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Operations = append(m.Operations, &Operation{}) + if err := m.Operations[len(m.Operations)-1].UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *DeveloperResponse) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: DeveloperResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: DeveloperResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field InternalError", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.InternalError = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DeveloperErrors", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.DeveloperErrors == nil { + m.DeveloperErrors = &DeveloperErrors{} + } + if err := m.DeveloperErrors.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field OperationsResults", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.OperationsResults == nil { + m.OperationsResults = &OperationsResults{} + } + if err := m.OperationsResults.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *RequestContext) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: RequestContext: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: RequestContext: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Schema", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Schema = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Relationships", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Relationships = append(m.Relationships, &v1.RelationTuple{}) + if unmarshal, ok := interface{}(m.Relationships[len(m.Relationships)-1]).(interface { + UnmarshalVT([]byte) error + }); ok { + if err := unmarshal.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + } else { + if err := proto.Unmarshal(dAtA[iNdEx:postIndex], m.Relationships[len(m.Relationships)-1]); err != nil { + return err + } + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Operation) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Operation: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Operation: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CheckParameters", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.CheckParameters == nil { + m.CheckParameters = &CheckOperationParameters{} + } + if err := m.CheckParameters.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AssertionsParameters", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.AssertionsParameters == nil { + m.AssertionsParameters = &RunAssertionsParameters{} + } + if err := m.AssertionsParameters.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ValidationParameters", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.ValidationParameters == nil { + m.ValidationParameters = &RunValidationParameters{} + } + if err := m.ValidationParameters.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field FormatSchemaParameters", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.FormatSchemaParameters == nil { + m.FormatSchemaParameters = &FormatSchemaParameters{} + } + if err := m.FormatSchemaParameters.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SchemaWarningsParameters", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.SchemaWarningsParameters == nil { + m.SchemaWarningsParameters = &SchemaWarningsParameters{} + } + if err := m.SchemaWarningsParameters.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *OperationsResults) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: OperationsResults: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: OperationsResults: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Results", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Results == nil { + m.Results = make(map[uint64]*OperationResult) + } + var mapkey uint64 + var mapvalue *OperationResult + for iNdEx < postIndex { + entryPreIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + if fieldNum == 1 { + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + mapkey |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + } else if fieldNum == 2 { + var mapmsglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + mapmsglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if mapmsglen < 0 { + return protohelpers.ErrInvalidLength + } + postmsgIndex := iNdEx + mapmsglen + if postmsgIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postmsgIndex > l { + return io.ErrUnexpectedEOF + } + mapvalue = &OperationResult{} + if err := mapvalue.UnmarshalVT(dAtA[iNdEx:postmsgIndex]); err != nil { + return err + } + iNdEx = postmsgIndex + } else { + iNdEx = entryPreIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > postIndex { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + m.Results[mapkey] = mapvalue + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *OperationResult) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: OperationResult: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: OperationResult: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CheckResult", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.CheckResult == nil { + m.CheckResult = &CheckOperationsResult{} + } + if err := m.CheckResult.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AssertionsResult", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.AssertionsResult == nil { + m.AssertionsResult = &RunAssertionsResult{} + } + if err := m.AssertionsResult.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ValidationResult", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.ValidationResult == nil { + m.ValidationResult = &RunValidationResult{} + } + if err := m.ValidationResult.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field FormatSchemaResult", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.FormatSchemaResult == nil { + m.FormatSchemaResult = &FormatSchemaResult{} + } + if err := m.FormatSchemaResult.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SchemaWarningsResult", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.SchemaWarningsResult == nil { + m.SchemaWarningsResult = &SchemaWarningsResult{} + } + if err := m.SchemaWarningsResult.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *DeveloperWarning) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: DeveloperWarning: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: DeveloperWarning: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Message", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Message = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Line", wireType) + } + m.Line = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Line |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Column", wireType) + } + m.Column = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Column |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SourceCode", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.SourceCode = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *DeveloperError) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: DeveloperError: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: DeveloperError: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Message", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Message = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Line", wireType) + } + m.Line = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Line |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Column", wireType) + } + m.Column = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Column |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Source", wireType) + } + m.Source = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Source |= DeveloperError_Source(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Kind", wireType) + } + m.Kind = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Kind |= DeveloperError_ErrorKind(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Path", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Path = append(m.Path, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Context", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Context = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 8: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CheckDebugInformation", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.CheckDebugInformation == nil { + m.CheckDebugInformation = &v11.DebugInformation{} + } + if unmarshal, ok := interface{}(m.CheckDebugInformation).(interface { + UnmarshalVT([]byte) error + }); ok { + if err := unmarshal.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + } else { + if err := proto.Unmarshal(dAtA[iNdEx:postIndex], m.CheckDebugInformation); err != nil { + return err + } + } + iNdEx = postIndex + case 9: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CheckResolvedDebugInformation", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.CheckResolvedDebugInformation == nil { + m.CheckResolvedDebugInformation = &v12.DebugInformation{} + } + if unmarshal, ok := interface{}(m.CheckResolvedDebugInformation).(interface { + UnmarshalVT([]byte) error + }); ok { + if err := unmarshal.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + } else { + if err := proto.Unmarshal(dAtA[iNdEx:postIndex], m.CheckResolvedDebugInformation); err != nil { + return err + } + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *DeveloperErrors) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: DeveloperErrors: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: DeveloperErrors: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field InputErrors", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.InputErrors = append(m.InputErrors, &DeveloperError{}) + if err := m.InputErrors[len(m.InputErrors)-1].UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *CheckOperationParameters) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: CheckOperationParameters: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: CheckOperationParameters: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Resource", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Resource == nil { + m.Resource = &v1.ObjectAndRelation{} + } + if unmarshal, ok := interface{}(m.Resource).(interface { + UnmarshalVT([]byte) error + }); ok { + if err := unmarshal.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + } else { + if err := proto.Unmarshal(dAtA[iNdEx:postIndex], m.Resource); err != nil { + return err + } + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Subject", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Subject == nil { + m.Subject = &v1.ObjectAndRelation{} + } + if unmarshal, ok := interface{}(m.Subject).(interface { + UnmarshalVT([]byte) error + }); ok { + if err := unmarshal.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + } else { + if err := proto.Unmarshal(dAtA[iNdEx:postIndex], m.Subject); err != nil { + return err + } + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CaveatContext", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.CaveatContext == nil { + m.CaveatContext = &structpb.Struct{} + } + if err := (*structpb1.Struct)(m.CaveatContext).UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *CheckOperationsResult) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: CheckOperationsResult: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: CheckOperationsResult: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Membership", wireType) + } + m.Membership = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Membership |= CheckOperationsResult_Membership(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CheckError", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.CheckError == nil { + m.CheckError = &DeveloperError{} + } + if err := m.CheckError.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DebugInformation", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.DebugInformation == nil { + m.DebugInformation = &v11.DebugInformation{} + } + if unmarshal, ok := interface{}(m.DebugInformation).(interface { + UnmarshalVT([]byte) error + }); ok { + if err := unmarshal.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + } else { + if err := proto.Unmarshal(dAtA[iNdEx:postIndex], m.DebugInformation); err != nil { + return err + } + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PartialCaveatInfo", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.PartialCaveatInfo == nil { + m.PartialCaveatInfo = &PartialCaveatInfo{} + } + if err := m.PartialCaveatInfo.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ResolvedDebugInformation", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.ResolvedDebugInformation == nil { + m.ResolvedDebugInformation = &v12.DebugInformation{} + } + if unmarshal, ok := interface{}(m.ResolvedDebugInformation).(interface { + UnmarshalVT([]byte) error + }); ok { + if err := unmarshal.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + } else { + if err := proto.Unmarshal(dAtA[iNdEx:postIndex], m.ResolvedDebugInformation); err != nil { + return err + } + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *PartialCaveatInfo) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: PartialCaveatInfo: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: PartialCaveatInfo: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MissingRequiredContext", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.MissingRequiredContext = append(m.MissingRequiredContext, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *RunAssertionsParameters) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: RunAssertionsParameters: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: RunAssertionsParameters: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AssertionsYaml", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.AssertionsYaml = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *RunAssertionsResult) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: RunAssertionsResult: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: RunAssertionsResult: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field InputError", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.InputError == nil { + m.InputError = &DeveloperError{} + } + if err := m.InputError.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ValidationErrors", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ValidationErrors = append(m.ValidationErrors, &DeveloperError{}) + if err := m.ValidationErrors[len(m.ValidationErrors)-1].UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *RunValidationParameters) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: RunValidationParameters: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: RunValidationParameters: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ValidationYaml", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ValidationYaml = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *RunValidationResult) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: RunValidationResult: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: RunValidationResult: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field InputError", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.InputError == nil { + m.InputError = &DeveloperError{} + } + if err := m.InputError.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field UpdatedValidationYaml", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.UpdatedValidationYaml = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ValidationErrors", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ValidationErrors = append(m.ValidationErrors, &DeveloperError{}) + if err := m.ValidationErrors[len(m.ValidationErrors)-1].UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *FormatSchemaParameters) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: FormatSchemaParameters: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: FormatSchemaParameters: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *FormatSchemaResult) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: FormatSchemaResult: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: FormatSchemaResult: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field FormattedSchema", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.FormattedSchema = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *SchemaWarningsParameters) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: SchemaWarningsParameters: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: SchemaWarningsParameters: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *SchemaWarningsResult) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: SchemaWarningsResult: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: SchemaWarningsResult: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Warnings", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Warnings = append(m.Warnings, &DeveloperWarning{}) + if err := m.Warnings[len(m.Warnings)-1].UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} diff --git a/vendor/github.com/authzed/spicedb/pkg/proto/dispatch/v1/00_zerolog.go b/vendor/github.com/authzed/spicedb/pkg/proto/dispatch/v1/00_zerolog.go new file mode 100644 index 0000000..3ae21c6 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/proto/dispatch/v1/00_zerolog.go @@ -0,0 +1,84 @@ +package dispatchv1 + +import ( + "github.com/rs/zerolog" + + "github.com/authzed/spicedb/pkg/tuple" +) + +// MarshalZerologObject implements zerolog object marshalling. +func (cr *DispatchCheckRequest) MarshalZerologObject(e *zerolog.Event) { + e.Object("metadata", cr.Metadata) + e.Str("resource-type", tuple.StringCoreRR(cr.ResourceRelation)) + e.Str("subject", tuple.StringCoreONR(cr.Subject)) + e.Array("resource-ids", strArray(cr.ResourceIds)) +} + +// MarshalZerologObject implements zerolog object marshalling. +func (cr *DispatchCheckResponse) MarshalZerologObject(e *zerolog.Event) { + e.Object("metadata", cr.Metadata) + + results := zerolog.Dict() + for resourceID, result := range cr.ResultsByResourceId { + results.Str(resourceID, ResourceCheckResult_Membership_name[int32(result.Membership)]) + } + e.Dict("results", results) +} + +// MarshalZerologObject implements zerolog object marshalling. +func (er *DispatchExpandRequest) MarshalZerologObject(e *zerolog.Event) { + e.Object("metadata", er.Metadata) + e.Str("expand", tuple.StringCoreONR(er.ResourceAndRelation)) + e.Stringer("mode", er.ExpansionMode) +} + +// MarshalZerologObject implements zerolog object marshalling. +func (cr *DispatchExpandResponse) MarshalZerologObject(e *zerolog.Event) { + e.Object("metadata", cr.Metadata) +} + +// MarshalZerologObject implements zerolog object marshalling. +func (lr *DispatchLookupResources2Request) MarshalZerologObject(e *zerolog.Event) { + e.Object("metadata", lr.Metadata) + e.Str("resource", tuple.StringCoreRR(lr.ResourceRelation)) + e.Str("subject", tuple.StringCoreRR(lr.SubjectRelation)) + e.Array("subject-ids", strArray(lr.SubjectIds)) + e.Interface("context", lr.Context) +} + +// MarshalZerologObject implements zerolog object marshalling. +func (ls *DispatchLookupSubjectsRequest) MarshalZerologObject(e *zerolog.Event) { + e.Object("metadata", ls.Metadata) + e.Str("resource-type", tuple.StringCoreRR(ls.ResourceRelation)) + e.Str("subject-type", tuple.StringCoreRR(ls.SubjectRelation)) + e.Array("resource-ids", strArray(ls.ResourceIds)) +} + +type strArray []string + +// MarshalZerologArray implements zerolog array marshalling. +func (strs strArray) MarshalZerologArray(a *zerolog.Array) { + for _, val := range strs { + a.Str(val) + } +} + +// MarshalZerologObject implements zerolog object marshalling. +func (cs *DispatchLookupSubjectsResponse) MarshalZerologObject(e *zerolog.Event) { + if cs == nil { + e.Interface("response", nil) + } else { + e.Object("metadata", cs.Metadata) + } +} + +// MarshalZerologObject implements zerolog object marshalling. +func (x *ResolverMeta) MarshalZerologObject(e *zerolog.Event) { + e.Str("revision", x.AtRevision) + e.Uint32("depth", x.DepthRemaining) +} + +// MarshalZerologObject implements zerolog object marshalling. +func (cr *ResponseMeta) MarshalZerologObject(e *zerolog.Event) { + e.Uint32("count", cr.DispatchCount) +} diff --git a/vendor/github.com/authzed/spicedb/pkg/proto/dispatch/v1/01_codec.go b/vendor/github.com/authzed/spicedb/pkg/proto/dispatch/v1/01_codec.go new file mode 100644 index 0000000..d72e4e4 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/proto/dispatch/v1/01_codec.go @@ -0,0 +1,71 @@ +// This file registers a gRPC codec that replaces the default gRPC proto codec +// with one that attempts to use protobuf codecs in the following order: +// - vtprotobuf +// - google.golang.org/encoding/proto + +package dispatchv1 + +import ( + "google.golang.org/grpc/encoding" + "google.golang.org/grpc/mem" + + // Guarantee that the built-in proto is called registered before this one + // so that it can be replaced. + _ "google.golang.org/grpc/encoding/proto" +) + +// Name is the name registered for the proto compressor. +const Name = "proto" + +type vtprotoMessage interface { + MarshalToSizedBufferVT(data []byte) (int, error) + UnmarshalVT([]byte) error + SizeVT() int +} + +type vtprotoCodec struct { + fallback encoding.CodecV2 +} + +func (vtprotoCodec) Name() string { return Name } + +func (c *vtprotoCodec) Marshal(v any) (mem.BufferSlice, error) { + if m, ok := v.(vtprotoMessage); ok { + size := m.SizeVT() + if mem.IsBelowBufferPoolingThreshold(size) { + buf := make([]byte, size) + n, err := m.MarshalToSizedBufferVT(buf) + if err != nil { + return nil, err + } + return mem.BufferSlice{mem.SliceBuffer(buf[:n])}, nil + } + pool := mem.DefaultBufferPool() + buf := pool.Get(size) + n, err := m.MarshalToSizedBufferVT(*buf) + if err != nil { + pool.Put(buf) + return nil, err + } + *buf = (*buf)[:n] + return mem.BufferSlice{mem.NewBuffer(buf, pool)}, nil + } + + return c.fallback.Marshal(v) +} + +func (c *vtprotoCodec) Unmarshal(data mem.BufferSlice, v any) error { + if m, ok := v.(vtprotoMessage); ok { + buf := data.MaterializeToBuffer(mem.DefaultBufferPool()) + defer buf.Free() + return m.UnmarshalVT(buf.ReadOnlyData()) + } + + return c.fallback.Unmarshal(data, v) +} + +func init() { + encoding.RegisterCodecV2(&vtprotoCodec{ + fallback: encoding.GetCodecV2("proto"), + }) +} diff --git a/vendor/github.com/authzed/spicedb/pkg/proto/dispatch/v1/02_resolvermeta.go b/vendor/github.com/authzed/spicedb/pkg/proto/dispatch/v1/02_resolvermeta.go new file mode 100644 index 0000000..93742e0 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/proto/dispatch/v1/02_resolvermeta.go @@ -0,0 +1,63 @@ +package dispatchv1 + +import ( + "fmt" + + "github.com/authzed/spicedb/pkg/spiceerrors" + + "github.com/bits-and-blooms/bloom/v3" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +func (x *ResolverMeta) RecordTraversal(key string) (possiblyLoop bool, err error) { + if key == "" { + return false, spiceerrors.MustBugf("missing key to be recorded in traversal") + } + + if x == nil || len(x.TraversalBloom) == 0 { + return false, status.Error(codes.Internal, fmt.Errorf("required traversal bloom filter is missing").Error()) + } + + bf := &bloom.BloomFilter{} + if err := bf.UnmarshalBinary(x.TraversalBloom); err != nil { + return false, status.Error(codes.Internal, fmt.Errorf("unable to unmarshall traversal bloom filter: %w", err).Error()) + } + + if bf.TestString(key) { + return true, nil + } + + x.TraversalBloom, err = bf.AddString(key).MarshalBinary() + if err != nil { + return false, err + } + + return false, nil +} + +const defaultFalsePositiveRate = 0.001 + +// NewTraversalBloomFilter creates a new bloom filter sized to the provided number of elements and +// with a predefined false-positive ratio of 0.1%. +func NewTraversalBloomFilter(numElements uint) ([]byte, error) { + bf := bloom.NewWithEstimates(numElements, defaultFalsePositiveRate) + + emptyBloomFilter, err := bf.MarshalBinary() + if err != nil { + return nil, spiceerrors.MustBugf("unexpected error while serializing empty bloom filter: %s", err.Error()) + } + + return emptyBloomFilter, nil +} + +// MustNewTraversalBloomFilter creates a new bloom filter sized to the provided number of elements and +// with a predefined false-positive ratio of 0.1%. +func MustNewTraversalBloomFilter(numElements uint) []byte { + bf, err := NewTraversalBloomFilter(numElements) + if err != nil { + panic(err) + } + + return bf +} diff --git a/vendor/github.com/authzed/spicedb/pkg/proto/dispatch/v1/dispatch.pb.go b/vendor/github.com/authzed/spicedb/pkg/proto/dispatch/v1/dispatch.pb.go new file mode 100644 index 0000000..9cea4c6 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/proto/dispatch/v1/dispatch.pb.go @@ -0,0 +1,2204 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.34.2 +// protoc (unknown) +// source: dispatch/v1/dispatch.proto + +package dispatchv1 + +import ( + v1 "github.com/authzed/spicedb/pkg/proto/core/v1" + _ "github.com/envoyproxy/protoc-gen-validate/validate" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + durationpb "google.golang.org/protobuf/types/known/durationpb" + structpb "google.golang.org/protobuf/types/known/structpb" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type DispatchCheckRequest_DebugSetting int32 + +const ( + DispatchCheckRequest_NO_DEBUG DispatchCheckRequest_DebugSetting = 0 + DispatchCheckRequest_ENABLE_BASIC_DEBUGGING DispatchCheckRequest_DebugSetting = 1 + DispatchCheckRequest_ENABLE_TRACE_DEBUGGING DispatchCheckRequest_DebugSetting = 2 +) + +// Enum value maps for DispatchCheckRequest_DebugSetting. +var ( + DispatchCheckRequest_DebugSetting_name = map[int32]string{ + 0: "NO_DEBUG", + 1: "ENABLE_BASIC_DEBUGGING", + 2: "ENABLE_TRACE_DEBUGGING", + } + DispatchCheckRequest_DebugSetting_value = map[string]int32{ + "NO_DEBUG": 0, + "ENABLE_BASIC_DEBUGGING": 1, + "ENABLE_TRACE_DEBUGGING": 2, + } +) + +func (x DispatchCheckRequest_DebugSetting) Enum() *DispatchCheckRequest_DebugSetting { + p := new(DispatchCheckRequest_DebugSetting) + *p = x + return p +} + +func (x DispatchCheckRequest_DebugSetting) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (DispatchCheckRequest_DebugSetting) Descriptor() protoreflect.EnumDescriptor { + return file_dispatch_v1_dispatch_proto_enumTypes[0].Descriptor() +} + +func (DispatchCheckRequest_DebugSetting) Type() protoreflect.EnumType { + return &file_dispatch_v1_dispatch_proto_enumTypes[0] +} + +func (x DispatchCheckRequest_DebugSetting) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use DispatchCheckRequest_DebugSetting.Descriptor instead. +func (DispatchCheckRequest_DebugSetting) EnumDescriptor() ([]byte, []int) { + return file_dispatch_v1_dispatch_proto_rawDescGZIP(), []int{0, 0} +} + +type DispatchCheckRequest_ResultsSetting int32 + +const ( + DispatchCheckRequest_REQUIRE_ALL_RESULTS DispatchCheckRequest_ResultsSetting = 0 + DispatchCheckRequest_ALLOW_SINGLE_RESULT DispatchCheckRequest_ResultsSetting = 1 +) + +// Enum value maps for DispatchCheckRequest_ResultsSetting. +var ( + DispatchCheckRequest_ResultsSetting_name = map[int32]string{ + 0: "REQUIRE_ALL_RESULTS", + 1: "ALLOW_SINGLE_RESULT", + } + DispatchCheckRequest_ResultsSetting_value = map[string]int32{ + "REQUIRE_ALL_RESULTS": 0, + "ALLOW_SINGLE_RESULT": 1, + } +) + +func (x DispatchCheckRequest_ResultsSetting) Enum() *DispatchCheckRequest_ResultsSetting { + p := new(DispatchCheckRequest_ResultsSetting) + *p = x + return p +} + +func (x DispatchCheckRequest_ResultsSetting) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (DispatchCheckRequest_ResultsSetting) Descriptor() protoreflect.EnumDescriptor { + return file_dispatch_v1_dispatch_proto_enumTypes[1].Descriptor() +} + +func (DispatchCheckRequest_ResultsSetting) Type() protoreflect.EnumType { + return &file_dispatch_v1_dispatch_proto_enumTypes[1] +} + +func (x DispatchCheckRequest_ResultsSetting) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use DispatchCheckRequest_ResultsSetting.Descriptor instead. +func (DispatchCheckRequest_ResultsSetting) EnumDescriptor() ([]byte, []int) { + return file_dispatch_v1_dispatch_proto_rawDescGZIP(), []int{0, 1} +} + +type ResourceCheckResult_Membership int32 + +const ( + ResourceCheckResult_UNKNOWN ResourceCheckResult_Membership = 0 + ResourceCheckResult_NOT_MEMBER ResourceCheckResult_Membership = 1 + ResourceCheckResult_MEMBER ResourceCheckResult_Membership = 2 + ResourceCheckResult_CAVEATED_MEMBER ResourceCheckResult_Membership = 3 +) + +// Enum value maps for ResourceCheckResult_Membership. +var ( + ResourceCheckResult_Membership_name = map[int32]string{ + 0: "UNKNOWN", + 1: "NOT_MEMBER", + 2: "MEMBER", + 3: "CAVEATED_MEMBER", + } + ResourceCheckResult_Membership_value = map[string]int32{ + "UNKNOWN": 0, + "NOT_MEMBER": 1, + "MEMBER": 2, + "CAVEATED_MEMBER": 3, + } +) + +func (x ResourceCheckResult_Membership) Enum() *ResourceCheckResult_Membership { + p := new(ResourceCheckResult_Membership) + *p = x + return p +} + +func (x ResourceCheckResult_Membership) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (ResourceCheckResult_Membership) Descriptor() protoreflect.EnumDescriptor { + return file_dispatch_v1_dispatch_proto_enumTypes[2].Descriptor() +} + +func (ResourceCheckResult_Membership) Type() protoreflect.EnumType { + return &file_dispatch_v1_dispatch_proto_enumTypes[2] +} + +func (x ResourceCheckResult_Membership) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use ResourceCheckResult_Membership.Descriptor instead. +func (ResourceCheckResult_Membership) EnumDescriptor() ([]byte, []int) { + return file_dispatch_v1_dispatch_proto_rawDescGZIP(), []int{3, 0} +} + +type DispatchExpandRequest_ExpansionMode int32 + +const ( + DispatchExpandRequest_SHALLOW DispatchExpandRequest_ExpansionMode = 0 + DispatchExpandRequest_RECURSIVE DispatchExpandRequest_ExpansionMode = 1 +) + +// Enum value maps for DispatchExpandRequest_ExpansionMode. +var ( + DispatchExpandRequest_ExpansionMode_name = map[int32]string{ + 0: "SHALLOW", + 1: "RECURSIVE", + } + DispatchExpandRequest_ExpansionMode_value = map[string]int32{ + "SHALLOW": 0, + "RECURSIVE": 1, + } +) + +func (x DispatchExpandRequest_ExpansionMode) Enum() *DispatchExpandRequest_ExpansionMode { + p := new(DispatchExpandRequest_ExpansionMode) + *p = x + return p +} + +func (x DispatchExpandRequest_ExpansionMode) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (DispatchExpandRequest_ExpansionMode) Descriptor() protoreflect.EnumDescriptor { + return file_dispatch_v1_dispatch_proto_enumTypes[3].Descriptor() +} + +func (DispatchExpandRequest_ExpansionMode) Type() protoreflect.EnumType { + return &file_dispatch_v1_dispatch_proto_enumTypes[3] +} + +func (x DispatchExpandRequest_ExpansionMode) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use DispatchExpandRequest_ExpansionMode.Descriptor instead. +func (DispatchExpandRequest_ExpansionMode) EnumDescriptor() ([]byte, []int) { + return file_dispatch_v1_dispatch_proto_rawDescGZIP(), []int{4, 0} +} + +type CheckDebugTrace_RelationType int32 + +const ( + CheckDebugTrace_UNKNOWN CheckDebugTrace_RelationType = 0 + CheckDebugTrace_RELATION CheckDebugTrace_RelationType = 1 + CheckDebugTrace_PERMISSION CheckDebugTrace_RelationType = 2 +) + +// Enum value maps for CheckDebugTrace_RelationType. +var ( + CheckDebugTrace_RelationType_name = map[int32]string{ + 0: "UNKNOWN", + 1: "RELATION", + 2: "PERMISSION", + } + CheckDebugTrace_RelationType_value = map[string]int32{ + "UNKNOWN": 0, + "RELATION": 1, + "PERMISSION": 2, + } +) + +func (x CheckDebugTrace_RelationType) Enum() *CheckDebugTrace_RelationType { + p := new(CheckDebugTrace_RelationType) + *p = x + return p +} + +func (x CheckDebugTrace_RelationType) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (CheckDebugTrace_RelationType) Descriptor() protoreflect.EnumDescriptor { + return file_dispatch_v1_dispatch_proto_enumTypes[4].Descriptor() +} + +func (CheckDebugTrace_RelationType) Type() protoreflect.EnumType { + return &file_dispatch_v1_dispatch_proto_enumTypes[4] +} + +func (x CheckDebugTrace_RelationType) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use CheckDebugTrace_RelationType.Descriptor instead. +func (CheckDebugTrace_RelationType) EnumDescriptor() ([]byte, []int) { + return file_dispatch_v1_dispatch_proto_rawDescGZIP(), []int{17, 0} +} + +type DispatchCheckRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Metadata *ResolverMeta `protobuf:"bytes,1,opt,name=metadata,proto3" json:"metadata,omitempty"` + ResourceRelation *v1.RelationReference `protobuf:"bytes,2,opt,name=resource_relation,json=resourceRelation,proto3" json:"resource_relation,omitempty"` + ResourceIds []string `protobuf:"bytes,3,rep,name=resource_ids,json=resourceIds,proto3" json:"resource_ids,omitempty"` + Subject *v1.ObjectAndRelation `protobuf:"bytes,4,opt,name=subject,proto3" json:"subject,omitempty"` + ResultsSetting DispatchCheckRequest_ResultsSetting `protobuf:"varint,5,opt,name=results_setting,json=resultsSetting,proto3,enum=dispatch.v1.DispatchCheckRequest_ResultsSetting" json:"results_setting,omitempty"` + Debug DispatchCheckRequest_DebugSetting `protobuf:"varint,6,opt,name=debug,proto3,enum=dispatch.v1.DispatchCheckRequest_DebugSetting" json:"debug,omitempty"` + // * + // check_hints are hints provided to the check call to help the resolver optimize the check + // by skipping calculations for the provided checks. The string key is the fully qualified + // "relationtuple"-string for the problem, e.g. `document:example#relation@user:someuser`. + // It is up to the caller to *ensure* that the hints provided are correct; if incorrect, + // the resolver may return incorrect results which will in turn be cached. + CheckHints []*CheckHint `protobuf:"bytes,7,rep,name=check_hints,json=checkHints,proto3" json:"check_hints,omitempty"` +} + +func (x *DispatchCheckRequest) Reset() { + *x = DispatchCheckRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_dispatch_v1_dispatch_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DispatchCheckRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DispatchCheckRequest) ProtoMessage() {} + +func (x *DispatchCheckRequest) ProtoReflect() protoreflect.Message { + mi := &file_dispatch_v1_dispatch_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DispatchCheckRequest.ProtoReflect.Descriptor instead. +func (*DispatchCheckRequest) Descriptor() ([]byte, []int) { + return file_dispatch_v1_dispatch_proto_rawDescGZIP(), []int{0} +} + +func (x *DispatchCheckRequest) GetMetadata() *ResolverMeta { + if x != nil { + return x.Metadata + } + return nil +} + +func (x *DispatchCheckRequest) GetResourceRelation() *v1.RelationReference { + if x != nil { + return x.ResourceRelation + } + return nil +} + +func (x *DispatchCheckRequest) GetResourceIds() []string { + if x != nil { + return x.ResourceIds + } + return nil +} + +func (x *DispatchCheckRequest) GetSubject() *v1.ObjectAndRelation { + if x != nil { + return x.Subject + } + return nil +} + +func (x *DispatchCheckRequest) GetResultsSetting() DispatchCheckRequest_ResultsSetting { + if x != nil { + return x.ResultsSetting + } + return DispatchCheckRequest_REQUIRE_ALL_RESULTS +} + +func (x *DispatchCheckRequest) GetDebug() DispatchCheckRequest_DebugSetting { + if x != nil { + return x.Debug + } + return DispatchCheckRequest_NO_DEBUG +} + +func (x *DispatchCheckRequest) GetCheckHints() []*CheckHint { + if x != nil { + return x.CheckHints + } + return nil +} + +type CheckHint struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Resource *v1.ObjectAndRelation `protobuf:"bytes,1,opt,name=resource,proto3" json:"resource,omitempty"` + Subject *v1.ObjectAndRelation `protobuf:"bytes,2,opt,name=subject,proto3" json:"subject,omitempty"` + TtuComputedUsersetRelation string `protobuf:"bytes,3,opt,name=ttu_computed_userset_relation,json=ttuComputedUsersetRelation,proto3" json:"ttu_computed_userset_relation,omitempty"` + Result *ResourceCheckResult `protobuf:"bytes,4,opt,name=result,proto3" json:"result,omitempty"` +} + +func (x *CheckHint) Reset() { + *x = CheckHint{} + if protoimpl.UnsafeEnabled { + mi := &file_dispatch_v1_dispatch_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CheckHint) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CheckHint) ProtoMessage() {} + +func (x *CheckHint) ProtoReflect() protoreflect.Message { + mi := &file_dispatch_v1_dispatch_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use CheckHint.ProtoReflect.Descriptor instead. +func (*CheckHint) Descriptor() ([]byte, []int) { + return file_dispatch_v1_dispatch_proto_rawDescGZIP(), []int{1} +} + +func (x *CheckHint) GetResource() *v1.ObjectAndRelation { + if x != nil { + return x.Resource + } + return nil +} + +func (x *CheckHint) GetSubject() *v1.ObjectAndRelation { + if x != nil { + return x.Subject + } + return nil +} + +func (x *CheckHint) GetTtuComputedUsersetRelation() string { + if x != nil { + return x.TtuComputedUsersetRelation + } + return "" +} + +func (x *CheckHint) GetResult() *ResourceCheckResult { + if x != nil { + return x.Result + } + return nil +} + +type DispatchCheckResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Metadata *ResponseMeta `protobuf:"bytes,1,opt,name=metadata,proto3" json:"metadata,omitempty"` + ResultsByResourceId map[string]*ResourceCheckResult `protobuf:"bytes,2,rep,name=results_by_resource_id,json=resultsByResourceId,proto3" json:"results_by_resource_id,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` +} + +func (x *DispatchCheckResponse) Reset() { + *x = DispatchCheckResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_dispatch_v1_dispatch_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DispatchCheckResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DispatchCheckResponse) ProtoMessage() {} + +func (x *DispatchCheckResponse) ProtoReflect() protoreflect.Message { + mi := &file_dispatch_v1_dispatch_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DispatchCheckResponse.ProtoReflect.Descriptor instead. +func (*DispatchCheckResponse) Descriptor() ([]byte, []int) { + return file_dispatch_v1_dispatch_proto_rawDescGZIP(), []int{2} +} + +func (x *DispatchCheckResponse) GetMetadata() *ResponseMeta { + if x != nil { + return x.Metadata + } + return nil +} + +func (x *DispatchCheckResponse) GetResultsByResourceId() map[string]*ResourceCheckResult { + if x != nil { + return x.ResultsByResourceId + } + return nil +} + +type ResourceCheckResult struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Membership ResourceCheckResult_Membership `protobuf:"varint,1,opt,name=membership,proto3,enum=dispatch.v1.ResourceCheckResult_Membership" json:"membership,omitempty"` + Expression *v1.CaveatExpression `protobuf:"bytes,2,opt,name=expression,proto3" json:"expression,omitempty"` + MissingExprFields []string `protobuf:"bytes,3,rep,name=missing_expr_fields,json=missingExprFields,proto3" json:"missing_expr_fields,omitempty"` +} + +func (x *ResourceCheckResult) Reset() { + *x = ResourceCheckResult{} + if protoimpl.UnsafeEnabled { + mi := &file_dispatch_v1_dispatch_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ResourceCheckResult) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ResourceCheckResult) ProtoMessage() {} + +func (x *ResourceCheckResult) ProtoReflect() protoreflect.Message { + mi := &file_dispatch_v1_dispatch_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ResourceCheckResult.ProtoReflect.Descriptor instead. +func (*ResourceCheckResult) Descriptor() ([]byte, []int) { + return file_dispatch_v1_dispatch_proto_rawDescGZIP(), []int{3} +} + +func (x *ResourceCheckResult) GetMembership() ResourceCheckResult_Membership { + if x != nil { + return x.Membership + } + return ResourceCheckResult_UNKNOWN +} + +func (x *ResourceCheckResult) GetExpression() *v1.CaveatExpression { + if x != nil { + return x.Expression + } + return nil +} + +func (x *ResourceCheckResult) GetMissingExprFields() []string { + if x != nil { + return x.MissingExprFields + } + return nil +} + +type DispatchExpandRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Metadata *ResolverMeta `protobuf:"bytes,1,opt,name=metadata,proto3" json:"metadata,omitempty"` + ResourceAndRelation *v1.ObjectAndRelation `protobuf:"bytes,2,opt,name=resource_and_relation,json=resourceAndRelation,proto3" json:"resource_and_relation,omitempty"` + ExpansionMode DispatchExpandRequest_ExpansionMode `protobuf:"varint,3,opt,name=expansion_mode,json=expansionMode,proto3,enum=dispatch.v1.DispatchExpandRequest_ExpansionMode" json:"expansion_mode,omitempty"` +} + +func (x *DispatchExpandRequest) Reset() { + *x = DispatchExpandRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_dispatch_v1_dispatch_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DispatchExpandRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DispatchExpandRequest) ProtoMessage() {} + +func (x *DispatchExpandRequest) ProtoReflect() protoreflect.Message { + mi := &file_dispatch_v1_dispatch_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DispatchExpandRequest.ProtoReflect.Descriptor instead. +func (*DispatchExpandRequest) Descriptor() ([]byte, []int) { + return file_dispatch_v1_dispatch_proto_rawDescGZIP(), []int{4} +} + +func (x *DispatchExpandRequest) GetMetadata() *ResolverMeta { + if x != nil { + return x.Metadata + } + return nil +} + +func (x *DispatchExpandRequest) GetResourceAndRelation() *v1.ObjectAndRelation { + if x != nil { + return x.ResourceAndRelation + } + return nil +} + +func (x *DispatchExpandRequest) GetExpansionMode() DispatchExpandRequest_ExpansionMode { + if x != nil { + return x.ExpansionMode + } + return DispatchExpandRequest_SHALLOW +} + +type DispatchExpandResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Metadata *ResponseMeta `protobuf:"bytes,1,opt,name=metadata,proto3" json:"metadata,omitempty"` + TreeNode *v1.RelationTupleTreeNode `protobuf:"bytes,2,opt,name=tree_node,json=treeNode,proto3" json:"tree_node,omitempty"` +} + +func (x *DispatchExpandResponse) Reset() { + *x = DispatchExpandResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_dispatch_v1_dispatch_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DispatchExpandResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DispatchExpandResponse) ProtoMessage() {} + +func (x *DispatchExpandResponse) ProtoReflect() protoreflect.Message { + mi := &file_dispatch_v1_dispatch_proto_msgTypes[5] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DispatchExpandResponse.ProtoReflect.Descriptor instead. +func (*DispatchExpandResponse) Descriptor() ([]byte, []int) { + return file_dispatch_v1_dispatch_proto_rawDescGZIP(), []int{5} +} + +func (x *DispatchExpandResponse) GetMetadata() *ResponseMeta { + if x != nil { + return x.Metadata + } + return nil +} + +func (x *DispatchExpandResponse) GetTreeNode() *v1.RelationTupleTreeNode { + if x != nil { + return x.TreeNode + } + return nil +} + +type Cursor struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Sections []string `protobuf:"bytes,2,rep,name=sections,proto3" json:"sections,omitempty"` + DispatchVersion uint32 `protobuf:"varint,3,opt,name=dispatch_version,json=dispatchVersion,proto3" json:"dispatch_version,omitempty"` +} + +func (x *Cursor) Reset() { + *x = Cursor{} + if protoimpl.UnsafeEnabled { + mi := &file_dispatch_v1_dispatch_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Cursor) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Cursor) ProtoMessage() {} + +func (x *Cursor) ProtoReflect() protoreflect.Message { + mi := &file_dispatch_v1_dispatch_proto_msgTypes[6] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Cursor.ProtoReflect.Descriptor instead. +func (*Cursor) Descriptor() ([]byte, []int) { + return file_dispatch_v1_dispatch_proto_rawDescGZIP(), []int{6} +} + +func (x *Cursor) GetSections() []string { + if x != nil { + return x.Sections + } + return nil +} + +func (x *Cursor) GetDispatchVersion() uint32 { + if x != nil { + return x.DispatchVersion + } + return 0 +} + +type DispatchLookupResources2Request struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Metadata *ResolverMeta `protobuf:"bytes,1,opt,name=metadata,proto3" json:"metadata,omitempty"` + ResourceRelation *v1.RelationReference `protobuf:"bytes,2,opt,name=resource_relation,json=resourceRelation,proto3" json:"resource_relation,omitempty"` + SubjectRelation *v1.RelationReference `protobuf:"bytes,3,opt,name=subject_relation,json=subjectRelation,proto3" json:"subject_relation,omitempty"` + SubjectIds []string `protobuf:"bytes,4,rep,name=subject_ids,json=subjectIds,proto3" json:"subject_ids,omitempty"` + TerminalSubject *v1.ObjectAndRelation `protobuf:"bytes,5,opt,name=terminal_subject,json=terminalSubject,proto3" json:"terminal_subject,omitempty"` + Context *structpb.Struct `protobuf:"bytes,6,opt,name=context,proto3" json:"context,omitempty"` + OptionalCursor *Cursor `protobuf:"bytes,7,opt,name=optional_cursor,json=optionalCursor,proto3" json:"optional_cursor,omitempty"` + OptionalLimit uint32 `protobuf:"varint,8,opt,name=optional_limit,json=optionalLimit,proto3" json:"optional_limit,omitempty"` +} + +func (x *DispatchLookupResources2Request) Reset() { + *x = DispatchLookupResources2Request{} + if protoimpl.UnsafeEnabled { + mi := &file_dispatch_v1_dispatch_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DispatchLookupResources2Request) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DispatchLookupResources2Request) ProtoMessage() {} + +func (x *DispatchLookupResources2Request) ProtoReflect() protoreflect.Message { + mi := &file_dispatch_v1_dispatch_proto_msgTypes[7] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DispatchLookupResources2Request.ProtoReflect.Descriptor instead. +func (*DispatchLookupResources2Request) Descriptor() ([]byte, []int) { + return file_dispatch_v1_dispatch_proto_rawDescGZIP(), []int{7} +} + +func (x *DispatchLookupResources2Request) GetMetadata() *ResolverMeta { + if x != nil { + return x.Metadata + } + return nil +} + +func (x *DispatchLookupResources2Request) GetResourceRelation() *v1.RelationReference { + if x != nil { + return x.ResourceRelation + } + return nil +} + +func (x *DispatchLookupResources2Request) GetSubjectRelation() *v1.RelationReference { + if x != nil { + return x.SubjectRelation + } + return nil +} + +func (x *DispatchLookupResources2Request) GetSubjectIds() []string { + if x != nil { + return x.SubjectIds + } + return nil +} + +func (x *DispatchLookupResources2Request) GetTerminalSubject() *v1.ObjectAndRelation { + if x != nil { + return x.TerminalSubject + } + return nil +} + +func (x *DispatchLookupResources2Request) GetContext() *structpb.Struct { + if x != nil { + return x.Context + } + return nil +} + +func (x *DispatchLookupResources2Request) GetOptionalCursor() *Cursor { + if x != nil { + return x.OptionalCursor + } + return nil +} + +func (x *DispatchLookupResources2Request) GetOptionalLimit() uint32 { + if x != nil { + return x.OptionalLimit + } + return 0 +} + +type PossibleResource struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + ResourceId string `protobuf:"bytes,1,opt,name=resource_id,json=resourceId,proto3" json:"resource_id,omitempty"` + ForSubjectIds []string `protobuf:"bytes,2,rep,name=for_subject_ids,json=forSubjectIds,proto3" json:"for_subject_ids,omitempty"` + MissingContextParams []string `protobuf:"bytes,3,rep,name=missing_context_params,json=missingContextParams,proto3" json:"missing_context_params,omitempty"` +} + +func (x *PossibleResource) Reset() { + *x = PossibleResource{} + if protoimpl.UnsafeEnabled { + mi := &file_dispatch_v1_dispatch_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *PossibleResource) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PossibleResource) ProtoMessage() {} + +func (x *PossibleResource) ProtoReflect() protoreflect.Message { + mi := &file_dispatch_v1_dispatch_proto_msgTypes[8] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use PossibleResource.ProtoReflect.Descriptor instead. +func (*PossibleResource) Descriptor() ([]byte, []int) { + return file_dispatch_v1_dispatch_proto_rawDescGZIP(), []int{8} +} + +func (x *PossibleResource) GetResourceId() string { + if x != nil { + return x.ResourceId + } + return "" +} + +func (x *PossibleResource) GetForSubjectIds() []string { + if x != nil { + return x.ForSubjectIds + } + return nil +} + +func (x *PossibleResource) GetMissingContextParams() []string { + if x != nil { + return x.MissingContextParams + } + return nil +} + +type DispatchLookupResources2Response struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Resource *PossibleResource `protobuf:"bytes,1,opt,name=resource,proto3" json:"resource,omitempty"` + Metadata *ResponseMeta `protobuf:"bytes,2,opt,name=metadata,proto3" json:"metadata,omitempty"` + AfterResponseCursor *Cursor `protobuf:"bytes,3,opt,name=after_response_cursor,json=afterResponseCursor,proto3" json:"after_response_cursor,omitempty"` +} + +func (x *DispatchLookupResources2Response) Reset() { + *x = DispatchLookupResources2Response{} + if protoimpl.UnsafeEnabled { + mi := &file_dispatch_v1_dispatch_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DispatchLookupResources2Response) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DispatchLookupResources2Response) ProtoMessage() {} + +func (x *DispatchLookupResources2Response) ProtoReflect() protoreflect.Message { + mi := &file_dispatch_v1_dispatch_proto_msgTypes[9] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DispatchLookupResources2Response.ProtoReflect.Descriptor instead. +func (*DispatchLookupResources2Response) Descriptor() ([]byte, []int) { + return file_dispatch_v1_dispatch_proto_rawDescGZIP(), []int{9} +} + +func (x *DispatchLookupResources2Response) GetResource() *PossibleResource { + if x != nil { + return x.Resource + } + return nil +} + +func (x *DispatchLookupResources2Response) GetMetadata() *ResponseMeta { + if x != nil { + return x.Metadata + } + return nil +} + +func (x *DispatchLookupResources2Response) GetAfterResponseCursor() *Cursor { + if x != nil { + return x.AfterResponseCursor + } + return nil +} + +type DispatchLookupSubjectsRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Metadata *ResolverMeta `protobuf:"bytes,1,opt,name=metadata,proto3" json:"metadata,omitempty"` + ResourceRelation *v1.RelationReference `protobuf:"bytes,2,opt,name=resource_relation,json=resourceRelation,proto3" json:"resource_relation,omitempty"` + ResourceIds []string `protobuf:"bytes,3,rep,name=resource_ids,json=resourceIds,proto3" json:"resource_ids,omitempty"` + SubjectRelation *v1.RelationReference `protobuf:"bytes,4,opt,name=subject_relation,json=subjectRelation,proto3" json:"subject_relation,omitempty"` +} + +func (x *DispatchLookupSubjectsRequest) Reset() { + *x = DispatchLookupSubjectsRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_dispatch_v1_dispatch_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DispatchLookupSubjectsRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DispatchLookupSubjectsRequest) ProtoMessage() {} + +func (x *DispatchLookupSubjectsRequest) ProtoReflect() protoreflect.Message { + mi := &file_dispatch_v1_dispatch_proto_msgTypes[10] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DispatchLookupSubjectsRequest.ProtoReflect.Descriptor instead. +func (*DispatchLookupSubjectsRequest) Descriptor() ([]byte, []int) { + return file_dispatch_v1_dispatch_proto_rawDescGZIP(), []int{10} +} + +func (x *DispatchLookupSubjectsRequest) GetMetadata() *ResolverMeta { + if x != nil { + return x.Metadata + } + return nil +} + +func (x *DispatchLookupSubjectsRequest) GetResourceRelation() *v1.RelationReference { + if x != nil { + return x.ResourceRelation + } + return nil +} + +func (x *DispatchLookupSubjectsRequest) GetResourceIds() []string { + if x != nil { + return x.ResourceIds + } + return nil +} + +func (x *DispatchLookupSubjectsRequest) GetSubjectRelation() *v1.RelationReference { + if x != nil { + return x.SubjectRelation + } + return nil +} + +type FoundSubject struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + SubjectId string `protobuf:"bytes,1,opt,name=subject_id,json=subjectId,proto3" json:"subject_id,omitempty"` + CaveatExpression *v1.CaveatExpression `protobuf:"bytes,2,opt,name=caveat_expression,json=caveatExpression,proto3" json:"caveat_expression,omitempty"` + ExcludedSubjects []*FoundSubject `protobuf:"bytes,3,rep,name=excluded_subjects,json=excludedSubjects,proto3" json:"excluded_subjects,omitempty"` +} + +func (x *FoundSubject) Reset() { + *x = FoundSubject{} + if protoimpl.UnsafeEnabled { + mi := &file_dispatch_v1_dispatch_proto_msgTypes[11] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *FoundSubject) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*FoundSubject) ProtoMessage() {} + +func (x *FoundSubject) ProtoReflect() protoreflect.Message { + mi := &file_dispatch_v1_dispatch_proto_msgTypes[11] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use FoundSubject.ProtoReflect.Descriptor instead. +func (*FoundSubject) Descriptor() ([]byte, []int) { + return file_dispatch_v1_dispatch_proto_rawDescGZIP(), []int{11} +} + +func (x *FoundSubject) GetSubjectId() string { + if x != nil { + return x.SubjectId + } + return "" +} + +func (x *FoundSubject) GetCaveatExpression() *v1.CaveatExpression { + if x != nil { + return x.CaveatExpression + } + return nil +} + +func (x *FoundSubject) GetExcludedSubjects() []*FoundSubject { + if x != nil { + return x.ExcludedSubjects + } + return nil +} + +type FoundSubjects struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + FoundSubjects []*FoundSubject `protobuf:"bytes,1,rep,name=found_subjects,json=foundSubjects,proto3" json:"found_subjects,omitempty"` +} + +func (x *FoundSubjects) Reset() { + *x = FoundSubjects{} + if protoimpl.UnsafeEnabled { + mi := &file_dispatch_v1_dispatch_proto_msgTypes[12] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *FoundSubjects) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*FoundSubjects) ProtoMessage() {} + +func (x *FoundSubjects) ProtoReflect() protoreflect.Message { + mi := &file_dispatch_v1_dispatch_proto_msgTypes[12] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use FoundSubjects.ProtoReflect.Descriptor instead. +func (*FoundSubjects) Descriptor() ([]byte, []int) { + return file_dispatch_v1_dispatch_proto_rawDescGZIP(), []int{12} +} + +func (x *FoundSubjects) GetFoundSubjects() []*FoundSubject { + if x != nil { + return x.FoundSubjects + } + return nil +} + +type DispatchLookupSubjectsResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + FoundSubjectsByResourceId map[string]*FoundSubjects `protobuf:"bytes,1,rep,name=found_subjects_by_resource_id,json=foundSubjectsByResourceId,proto3" json:"found_subjects_by_resource_id,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + Metadata *ResponseMeta `protobuf:"bytes,2,opt,name=metadata,proto3" json:"metadata,omitempty"` +} + +func (x *DispatchLookupSubjectsResponse) Reset() { + *x = DispatchLookupSubjectsResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_dispatch_v1_dispatch_proto_msgTypes[13] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DispatchLookupSubjectsResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DispatchLookupSubjectsResponse) ProtoMessage() {} + +func (x *DispatchLookupSubjectsResponse) ProtoReflect() protoreflect.Message { + mi := &file_dispatch_v1_dispatch_proto_msgTypes[13] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DispatchLookupSubjectsResponse.ProtoReflect.Descriptor instead. +func (*DispatchLookupSubjectsResponse) Descriptor() ([]byte, []int) { + return file_dispatch_v1_dispatch_proto_rawDescGZIP(), []int{13} +} + +func (x *DispatchLookupSubjectsResponse) GetFoundSubjectsByResourceId() map[string]*FoundSubjects { + if x != nil { + return x.FoundSubjectsByResourceId + } + return nil +} + +func (x *DispatchLookupSubjectsResponse) GetMetadata() *ResponseMeta { + if x != nil { + return x.Metadata + } + return nil +} + +type ResolverMeta struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + AtRevision string `protobuf:"bytes,1,opt,name=at_revision,json=atRevision,proto3" json:"at_revision,omitempty"` + DepthRemaining uint32 `protobuf:"varint,2,opt,name=depth_remaining,json=depthRemaining,proto3" json:"depth_remaining,omitempty"` + // Deprecated: Marked as deprecated in dispatch/v1/dispatch.proto. + RequestId string `protobuf:"bytes,3,opt,name=request_id,json=requestId,proto3" json:"request_id,omitempty"` + TraversalBloom []byte `protobuf:"bytes,4,opt,name=traversal_bloom,json=traversalBloom,proto3" json:"traversal_bloom,omitempty"` +} + +func (x *ResolverMeta) Reset() { + *x = ResolverMeta{} + if protoimpl.UnsafeEnabled { + mi := &file_dispatch_v1_dispatch_proto_msgTypes[14] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ResolverMeta) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ResolverMeta) ProtoMessage() {} + +func (x *ResolverMeta) ProtoReflect() protoreflect.Message { + mi := &file_dispatch_v1_dispatch_proto_msgTypes[14] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ResolverMeta.ProtoReflect.Descriptor instead. +func (*ResolverMeta) Descriptor() ([]byte, []int) { + return file_dispatch_v1_dispatch_proto_rawDescGZIP(), []int{14} +} + +func (x *ResolverMeta) GetAtRevision() string { + if x != nil { + return x.AtRevision + } + return "" +} + +func (x *ResolverMeta) GetDepthRemaining() uint32 { + if x != nil { + return x.DepthRemaining + } + return 0 +} + +// Deprecated: Marked as deprecated in dispatch/v1/dispatch.proto. +func (x *ResolverMeta) GetRequestId() string { + if x != nil { + return x.RequestId + } + return "" +} + +func (x *ResolverMeta) GetTraversalBloom() []byte { + if x != nil { + return x.TraversalBloom + } + return nil +} + +type ResponseMeta struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + DispatchCount uint32 `protobuf:"varint,1,opt,name=dispatch_count,json=dispatchCount,proto3" json:"dispatch_count,omitempty"` + DepthRequired uint32 `protobuf:"varint,2,opt,name=depth_required,json=depthRequired,proto3" json:"depth_required,omitempty"` + CachedDispatchCount uint32 `protobuf:"varint,3,opt,name=cached_dispatch_count,json=cachedDispatchCount,proto3" json:"cached_dispatch_count,omitempty"` + DebugInfo *DebugInformation `protobuf:"bytes,6,opt,name=debug_info,json=debugInfo,proto3" json:"debug_info,omitempty"` +} + +func (x *ResponseMeta) Reset() { + *x = ResponseMeta{} + if protoimpl.UnsafeEnabled { + mi := &file_dispatch_v1_dispatch_proto_msgTypes[15] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ResponseMeta) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ResponseMeta) ProtoMessage() {} + +func (x *ResponseMeta) ProtoReflect() protoreflect.Message { + mi := &file_dispatch_v1_dispatch_proto_msgTypes[15] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ResponseMeta.ProtoReflect.Descriptor instead. +func (*ResponseMeta) Descriptor() ([]byte, []int) { + return file_dispatch_v1_dispatch_proto_rawDescGZIP(), []int{15} +} + +func (x *ResponseMeta) GetDispatchCount() uint32 { + if x != nil { + return x.DispatchCount + } + return 0 +} + +func (x *ResponseMeta) GetDepthRequired() uint32 { + if x != nil { + return x.DepthRequired + } + return 0 +} + +func (x *ResponseMeta) GetCachedDispatchCount() uint32 { + if x != nil { + return x.CachedDispatchCount + } + return 0 +} + +func (x *ResponseMeta) GetDebugInfo() *DebugInformation { + if x != nil { + return x.DebugInfo + } + return nil +} + +type DebugInformation struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Check *CheckDebugTrace `protobuf:"bytes,1,opt,name=check,proto3" json:"check,omitempty"` +} + +func (x *DebugInformation) Reset() { + *x = DebugInformation{} + if protoimpl.UnsafeEnabled { + mi := &file_dispatch_v1_dispatch_proto_msgTypes[16] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DebugInformation) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DebugInformation) ProtoMessage() {} + +func (x *DebugInformation) ProtoReflect() protoreflect.Message { + mi := &file_dispatch_v1_dispatch_proto_msgTypes[16] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DebugInformation.ProtoReflect.Descriptor instead. +func (*DebugInformation) Descriptor() ([]byte, []int) { + return file_dispatch_v1_dispatch_proto_rawDescGZIP(), []int{16} +} + +func (x *DebugInformation) GetCheck() *CheckDebugTrace { + if x != nil { + return x.Check + } + return nil +} + +type CheckDebugTrace struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Request *DispatchCheckRequest `protobuf:"bytes,1,opt,name=request,proto3" json:"request,omitempty"` + ResourceRelationType CheckDebugTrace_RelationType `protobuf:"varint,2,opt,name=resource_relation_type,json=resourceRelationType,proto3,enum=dispatch.v1.CheckDebugTrace_RelationType" json:"resource_relation_type,omitempty"` + Results map[string]*ResourceCheckResult `protobuf:"bytes,3,rep,name=results,proto3" json:"results,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + IsCachedResult bool `protobuf:"varint,4,opt,name=is_cached_result,json=isCachedResult,proto3" json:"is_cached_result,omitempty"` + SubProblems []*CheckDebugTrace `protobuf:"bytes,5,rep,name=sub_problems,json=subProblems,proto3" json:"sub_problems,omitempty"` + Duration *durationpb.Duration `protobuf:"bytes,6,opt,name=duration,proto3" json:"duration,omitempty"` + TraceId string `protobuf:"bytes,7,opt,name=trace_id,json=traceId,proto3" json:"trace_id,omitempty"` + SourceId string `protobuf:"bytes,8,opt,name=source_id,json=sourceId,proto3" json:"source_id,omitempty"` +} + +func (x *CheckDebugTrace) Reset() { + *x = CheckDebugTrace{} + if protoimpl.UnsafeEnabled { + mi := &file_dispatch_v1_dispatch_proto_msgTypes[17] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CheckDebugTrace) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CheckDebugTrace) ProtoMessage() {} + +func (x *CheckDebugTrace) ProtoReflect() protoreflect.Message { + mi := &file_dispatch_v1_dispatch_proto_msgTypes[17] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use CheckDebugTrace.ProtoReflect.Descriptor instead. +func (*CheckDebugTrace) Descriptor() ([]byte, []int) { + return file_dispatch_v1_dispatch_proto_rawDescGZIP(), []int{17} +} + +func (x *CheckDebugTrace) GetRequest() *DispatchCheckRequest { + if x != nil { + return x.Request + } + return nil +} + +func (x *CheckDebugTrace) GetResourceRelationType() CheckDebugTrace_RelationType { + if x != nil { + return x.ResourceRelationType + } + return CheckDebugTrace_UNKNOWN +} + +func (x *CheckDebugTrace) GetResults() map[string]*ResourceCheckResult { + if x != nil { + return x.Results + } + return nil +} + +func (x *CheckDebugTrace) GetIsCachedResult() bool { + if x != nil { + return x.IsCachedResult + } + return false +} + +func (x *CheckDebugTrace) GetSubProblems() []*CheckDebugTrace { + if x != nil { + return x.SubProblems + } + return nil +} + +func (x *CheckDebugTrace) GetDuration() *durationpb.Duration { + if x != nil { + return x.Duration + } + return nil +} + +func (x *CheckDebugTrace) GetTraceId() string { + if x != nil { + return x.TraceId + } + return "" +} + +func (x *CheckDebugTrace) GetSourceId() string { + if x != nil { + return x.SourceId + } + return "" +} + +var File_dispatch_v1_dispatch_proto protoreflect.FileDescriptor + +var file_dispatch_v1_dispatch_proto_rawDesc = []byte{ + 0x0a, 0x1a, 0x64, 0x69, 0x73, 0x70, 0x61, 0x74, 0x63, 0x68, 0x2f, 0x76, 0x31, 0x2f, 0x64, 0x69, + 0x73, 0x70, 0x61, 0x74, 0x63, 0x68, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0b, 0x64, 0x69, + 0x73, 0x70, 0x61, 0x74, 0x63, 0x68, 0x2e, 0x76, 0x31, 0x1a, 0x12, 0x63, 0x6f, 0x72, 0x65, 0x2f, + 0x76, 0x31, 0x2f, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1e, 0x67, + 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x64, + 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1c, 0x67, + 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x73, + 0x74, 0x72, 0x75, 0x63, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x17, 0x76, 0x61, 0x6c, + 0x69, 0x64, 0x61, 0x74, 0x65, 0x2f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x81, 0x05, 0x0a, 0x14, 0x44, 0x69, 0x73, 0x70, 0x61, 0x74, 0x63, + 0x68, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x3f, 0x0a, + 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x19, 0x2e, 0x64, 0x69, 0x73, 0x70, 0x61, 0x74, 0x63, 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x52, 0x65, + 0x73, 0x6f, 0x6c, 0x76, 0x65, 0x72, 0x4d, 0x65, 0x74, 0x61, 0x42, 0x08, 0xfa, 0x42, 0x05, 0x8a, + 0x01, 0x02, 0x10, 0x01, 0x52, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, 0x51, + 0x0a, 0x11, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x72, 0x65, 0x6c, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x63, 0x6f, 0x72, 0x65, + 0x2e, 0x76, 0x31, 0x2e, 0x52, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x66, 0x65, + 0x72, 0x65, 0x6e, 0x63, 0x65, 0x42, 0x08, 0xfa, 0x42, 0x05, 0x8a, 0x01, 0x02, 0x10, 0x01, 0x52, + 0x10, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, + 0x6e, 0x12, 0x21, 0x0a, 0x0c, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x69, 0x64, + 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0b, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, + 0x65, 0x49, 0x64, 0x73, 0x12, 0x3e, 0x0a, 0x07, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x18, + 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, + 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x41, 0x6e, 0x64, 0x52, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, + 0x6e, 0x42, 0x08, 0xfa, 0x42, 0x05, 0x8a, 0x01, 0x02, 0x10, 0x01, 0x52, 0x07, 0x73, 0x75, 0x62, + 0x6a, 0x65, 0x63, 0x74, 0x12, 0x59, 0x0a, 0x0f, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x73, 0x5f, + 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x30, 0x2e, + 0x64, 0x69, 0x73, 0x70, 0x61, 0x74, 0x63, 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x69, 0x73, 0x70, + 0x61, 0x74, 0x63, 0x68, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x2e, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x73, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x52, + 0x0e, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x73, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x12, + 0x44, 0x0a, 0x05, 0x64, 0x65, 0x62, 0x75, 0x67, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x2e, + 0x2e, 0x64, 0x69, 0x73, 0x70, 0x61, 0x74, 0x63, 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x69, 0x73, + 0x70, 0x61, 0x74, 0x63, 0x68, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x2e, 0x44, 0x65, 0x62, 0x75, 0x67, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x52, 0x05, + 0x64, 0x65, 0x62, 0x75, 0x67, 0x12, 0x37, 0x0a, 0x0b, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x5f, 0x68, + 0x69, 0x6e, 0x74, 0x73, 0x18, 0x07, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x64, 0x69, 0x73, + 0x70, 0x61, 0x74, 0x63, 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x48, 0x69, + 0x6e, 0x74, 0x52, 0x0a, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x48, 0x69, 0x6e, 0x74, 0x73, 0x22, 0x54, + 0x0a, 0x0c, 0x44, 0x65, 0x62, 0x75, 0x67, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x12, 0x0c, + 0x0a, 0x08, 0x4e, 0x4f, 0x5f, 0x44, 0x45, 0x42, 0x55, 0x47, 0x10, 0x00, 0x12, 0x1a, 0x0a, 0x16, + 0x45, 0x4e, 0x41, 0x42, 0x4c, 0x45, 0x5f, 0x42, 0x41, 0x53, 0x49, 0x43, 0x5f, 0x44, 0x45, 0x42, + 0x55, 0x47, 0x47, 0x49, 0x4e, 0x47, 0x10, 0x01, 0x12, 0x1a, 0x0a, 0x16, 0x45, 0x4e, 0x41, 0x42, + 0x4c, 0x45, 0x5f, 0x54, 0x52, 0x41, 0x43, 0x45, 0x5f, 0x44, 0x45, 0x42, 0x55, 0x47, 0x47, 0x49, + 0x4e, 0x47, 0x10, 0x02, 0x22, 0x42, 0x0a, 0x0e, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x73, 0x53, + 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x12, 0x17, 0x0a, 0x13, 0x52, 0x45, 0x51, 0x55, 0x49, 0x52, + 0x45, 0x5f, 0x41, 0x4c, 0x4c, 0x5f, 0x52, 0x45, 0x53, 0x55, 0x4c, 0x54, 0x53, 0x10, 0x00, 0x12, + 0x17, 0x0a, 0x13, 0x41, 0x4c, 0x4c, 0x4f, 0x57, 0x5f, 0x53, 0x49, 0x4e, 0x47, 0x4c, 0x45, 0x5f, + 0x52, 0x45, 0x53, 0x55, 0x4c, 0x54, 0x10, 0x01, 0x22, 0xf6, 0x01, 0x0a, 0x09, 0x43, 0x68, 0x65, + 0x63, 0x6b, 0x48, 0x69, 0x6e, 0x74, 0x12, 0x36, 0x0a, 0x08, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, + 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, + 0x76, 0x31, 0x2e, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x41, 0x6e, 0x64, 0x52, 0x65, 0x6c, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x08, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x12, 0x34, + 0x0a, 0x07, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x1a, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, + 0x41, 0x6e, 0x64, 0x52, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x07, 0x73, 0x75, 0x62, + 0x6a, 0x65, 0x63, 0x74, 0x12, 0x41, 0x0a, 0x1d, 0x74, 0x74, 0x75, 0x5f, 0x63, 0x6f, 0x6d, 0x70, + 0x75, 0x74, 0x65, 0x64, 0x5f, 0x75, 0x73, 0x65, 0x72, 0x73, 0x65, 0x74, 0x5f, 0x72, 0x65, 0x6c, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x1a, 0x74, 0x74, 0x75, + 0x43, 0x6f, 0x6d, 0x70, 0x75, 0x74, 0x65, 0x64, 0x55, 0x73, 0x65, 0x72, 0x73, 0x65, 0x74, 0x52, + 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x38, 0x0a, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, + 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x64, 0x69, 0x73, 0x70, 0x61, 0x74, + 0x63, 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x43, 0x68, + 0x65, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x52, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, + 0x74, 0x22, 0xaa, 0x02, 0x0a, 0x15, 0x44, 0x69, 0x73, 0x70, 0x61, 0x74, 0x63, 0x68, 0x43, 0x68, + 0x65, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x35, 0x0a, 0x08, 0x6d, + 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, + 0x64, 0x69, 0x73, 0x70, 0x61, 0x74, 0x63, 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x4d, 0x65, 0x74, 0x61, 0x52, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, + 0x74, 0x61, 0x12, 0x70, 0x0a, 0x16, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x73, 0x5f, 0x62, 0x79, + 0x5f, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x03, + 0x28, 0x0b, 0x32, 0x3b, 0x2e, 0x64, 0x69, 0x73, 0x70, 0x61, 0x74, 0x63, 0x68, 0x2e, 0x76, 0x31, + 0x2e, 0x44, 0x69, 0x73, 0x70, 0x61, 0x74, 0x63, 0x68, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x73, 0x42, 0x79, + 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x49, 0x64, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, + 0x13, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x73, 0x42, 0x79, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, + 0x63, 0x65, 0x49, 0x64, 0x1a, 0x68, 0x0a, 0x18, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x73, 0x42, + 0x79, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x49, 0x64, 0x45, 0x6e, 0x74, 0x72, 0x79, + 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, + 0x65, 0x79, 0x12, 0x36, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x20, 0x2e, 0x64, 0x69, 0x73, 0x70, 0x61, 0x74, 0x63, 0x68, 0x2e, 0x76, 0x31, 0x2e, + 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x52, 0x65, 0x73, + 0x75, 0x6c, 0x74, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x99, + 0x02, 0x0a, 0x13, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x43, 0x68, 0x65, 0x63, 0x6b, + 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x4b, 0x0a, 0x0a, 0x6d, 0x65, 0x6d, 0x62, 0x65, 0x72, + 0x73, 0x68, 0x69, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x2b, 0x2e, 0x64, 0x69, 0x73, + 0x70, 0x61, 0x74, 0x63, 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, + 0x65, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x2e, 0x4d, 0x65, 0x6d, + 0x62, 0x65, 0x72, 0x73, 0x68, 0x69, 0x70, 0x52, 0x0a, 0x6d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, + 0x68, 0x69, 0x70, 0x12, 0x39, 0x0a, 0x0a, 0x65, 0x78, 0x70, 0x72, 0x65, 0x73, 0x73, 0x69, 0x6f, + 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x76, + 0x31, 0x2e, 0x43, 0x61, 0x76, 0x65, 0x61, 0x74, 0x45, 0x78, 0x70, 0x72, 0x65, 0x73, 0x73, 0x69, + 0x6f, 0x6e, 0x52, 0x0a, 0x65, 0x78, 0x70, 0x72, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x2e, + 0x0a, 0x13, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6e, 0x67, 0x5f, 0x65, 0x78, 0x70, 0x72, 0x5f, 0x66, + 0x69, 0x65, 0x6c, 0x64, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x11, 0x6d, 0x69, 0x73, + 0x73, 0x69, 0x6e, 0x67, 0x45, 0x78, 0x70, 0x72, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x73, 0x22, 0x4a, + 0x0a, 0x0a, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x68, 0x69, 0x70, 0x12, 0x0b, 0x0a, 0x07, + 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x0e, 0x0a, 0x0a, 0x4e, 0x4f, 0x54, + 0x5f, 0x4d, 0x45, 0x4d, 0x42, 0x45, 0x52, 0x10, 0x01, 0x12, 0x0a, 0x0a, 0x06, 0x4d, 0x45, 0x4d, + 0x42, 0x45, 0x52, 0x10, 0x02, 0x12, 0x13, 0x0a, 0x0f, 0x43, 0x41, 0x56, 0x45, 0x41, 0x54, 0x45, + 0x44, 0x5f, 0x4d, 0x45, 0x4d, 0x42, 0x45, 0x52, 0x10, 0x03, 0x22, 0xb8, 0x02, 0x0a, 0x15, 0x44, + 0x69, 0x73, 0x70, 0x61, 0x74, 0x63, 0x68, 0x45, 0x78, 0x70, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x12, 0x3f, 0x0a, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x64, 0x69, 0x73, 0x70, 0x61, 0x74, 0x63, + 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x6c, 0x76, 0x65, 0x72, 0x4d, 0x65, 0x74, + 0x61, 0x42, 0x08, 0xfa, 0x42, 0x05, 0x8a, 0x01, 0x02, 0x10, 0x01, 0x52, 0x08, 0x6d, 0x65, 0x74, + 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, 0x58, 0x0a, 0x15, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, + 0x65, 0x5f, 0x61, 0x6e, 0x64, 0x5f, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4f, + 0x62, 0x6a, 0x65, 0x63, 0x74, 0x41, 0x6e, 0x64, 0x52, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x42, 0x08, 0xfa, 0x42, 0x05, 0x8a, 0x01, 0x02, 0x10, 0x01, 0x52, 0x13, 0x72, 0x65, 0x73, 0x6f, + 0x75, 0x72, 0x63, 0x65, 0x41, 0x6e, 0x64, 0x52, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, + 0x57, 0x0a, 0x0e, 0x65, 0x78, 0x70, 0x61, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x5f, 0x6d, 0x6f, 0x64, + 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x30, 0x2e, 0x64, 0x69, 0x73, 0x70, 0x61, 0x74, + 0x63, 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x69, 0x73, 0x70, 0x61, 0x74, 0x63, 0x68, 0x45, 0x78, + 0x70, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x2e, 0x45, 0x78, 0x70, 0x61, + 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x4d, 0x6f, 0x64, 0x65, 0x52, 0x0d, 0x65, 0x78, 0x70, 0x61, 0x6e, + 0x73, 0x69, 0x6f, 0x6e, 0x4d, 0x6f, 0x64, 0x65, 0x22, 0x2b, 0x0a, 0x0d, 0x45, 0x78, 0x70, 0x61, + 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x4d, 0x6f, 0x64, 0x65, 0x12, 0x0b, 0x0a, 0x07, 0x53, 0x48, 0x41, + 0x4c, 0x4c, 0x4f, 0x57, 0x10, 0x00, 0x12, 0x0d, 0x0a, 0x09, 0x52, 0x45, 0x43, 0x55, 0x52, 0x53, + 0x49, 0x56, 0x45, 0x10, 0x01, 0x22, 0x8c, 0x01, 0x0a, 0x16, 0x44, 0x69, 0x73, 0x70, 0x61, 0x74, + 0x63, 0x68, 0x45, 0x78, 0x70, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x12, 0x35, 0x0a, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x64, 0x69, 0x73, 0x70, 0x61, 0x74, 0x63, 0x68, 0x2e, 0x76, 0x31, + 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x4d, 0x65, 0x74, 0x61, 0x52, 0x08, 0x6d, + 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, 0x3b, 0x0a, 0x09, 0x74, 0x72, 0x65, 0x65, 0x5f, + 0x6e, 0x6f, 0x64, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x63, 0x6f, 0x72, + 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x52, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x54, 0x75, 0x70, + 0x6c, 0x65, 0x54, 0x72, 0x65, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x52, 0x08, 0x74, 0x72, 0x65, 0x65, + 0x4e, 0x6f, 0x64, 0x65, 0x22, 0x55, 0x0a, 0x06, 0x43, 0x75, 0x72, 0x73, 0x6f, 0x72, 0x12, 0x1a, + 0x0a, 0x08, 0x73, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, + 0x52, 0x08, 0x73, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x29, 0x0a, 0x10, 0x64, 0x69, + 0x73, 0x70, 0x61, 0x74, 0x63, 0x68, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0f, 0x64, 0x69, 0x73, 0x70, 0x61, 0x74, 0x63, 0x68, 0x56, 0x65, + 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x4a, 0x04, 0x08, 0x01, 0x10, 0x02, 0x22, 0x90, 0x04, 0x0a, 0x1f, + 0x44, 0x69, 0x73, 0x70, 0x61, 0x74, 0x63, 0x68, 0x4c, 0x6f, 0x6f, 0x6b, 0x75, 0x70, 0x52, 0x65, + 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x32, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, + 0x3f, 0x0a, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x19, 0x2e, 0x64, 0x69, 0x73, 0x70, 0x61, 0x74, 0x63, 0x68, 0x2e, 0x76, 0x31, 0x2e, + 0x52, 0x65, 0x73, 0x6f, 0x6c, 0x76, 0x65, 0x72, 0x4d, 0x65, 0x74, 0x61, 0x42, 0x08, 0xfa, 0x42, + 0x05, 0x8a, 0x01, 0x02, 0x10, 0x01, 0x52, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, + 0x12, 0x51, 0x0a, 0x11, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x72, 0x65, 0x6c, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x63, 0x6f, + 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x52, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, + 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x42, 0x08, 0xfa, 0x42, 0x05, 0x8a, 0x01, 0x02, 0x10, + 0x01, 0x52, 0x10, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x65, 0x6c, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x12, 0x4f, 0x0a, 0x10, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x5f, 0x72, + 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, + 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x52, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x42, 0x08, 0xfa, 0x42, 0x05, 0x8a, 0x01, + 0x02, 0x10, 0x01, 0x52, 0x0f, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x65, 0x6c, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1f, 0x0a, 0x0b, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x5f, + 0x69, 0x64, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0a, 0x73, 0x75, 0x62, 0x6a, 0x65, + 0x63, 0x74, 0x49, 0x64, 0x73, 0x12, 0x4f, 0x0a, 0x10, 0x74, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x61, + 0x6c, 0x5f, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x1a, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, + 0x41, 0x6e, 0x64, 0x52, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x08, 0xfa, 0x42, 0x05, + 0x8a, 0x01, 0x02, 0x10, 0x01, 0x52, 0x0f, 0x74, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x61, 0x6c, 0x53, + 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x31, 0x0a, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, + 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x75, 0x63, 0x74, + 0x52, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x12, 0x3c, 0x0a, 0x0f, 0x6f, 0x70, 0x74, + 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x5f, 0x63, 0x75, 0x72, 0x73, 0x6f, 0x72, 0x18, 0x07, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x64, 0x69, 0x73, 0x70, 0x61, 0x74, 0x63, 0x68, 0x2e, 0x76, 0x31, + 0x2e, 0x43, 0x75, 0x72, 0x73, 0x6f, 0x72, 0x52, 0x0e, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x61, + 0x6c, 0x43, 0x75, 0x72, 0x73, 0x6f, 0x72, 0x12, 0x25, 0x0a, 0x0e, 0x6f, 0x70, 0x74, 0x69, 0x6f, + 0x6e, 0x61, 0x6c, 0x5f, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0d, 0x52, + 0x0d, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x4c, 0x69, 0x6d, 0x69, 0x74, 0x22, 0x91, + 0x01, 0x0a, 0x10, 0x50, 0x6f, 0x73, 0x73, 0x69, 0x62, 0x6c, 0x65, 0x52, 0x65, 0x73, 0x6f, 0x75, + 0x72, 0x63, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, + 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, + 0x63, 0x65, 0x49, 0x64, 0x12, 0x26, 0x0a, 0x0f, 0x66, 0x6f, 0x72, 0x5f, 0x73, 0x75, 0x62, 0x6a, + 0x65, 0x63, 0x74, 0x5f, 0x69, 0x64, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0d, 0x66, + 0x6f, 0x72, 0x53, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x49, 0x64, 0x73, 0x12, 0x34, 0x0a, 0x16, + 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6e, 0x67, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x5f, + 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x14, 0x6d, 0x69, + 0x73, 0x73, 0x69, 0x6e, 0x67, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x50, 0x61, 0x72, 0x61, + 0x6d, 0x73, 0x22, 0xdd, 0x01, 0x0a, 0x20, 0x44, 0x69, 0x73, 0x70, 0x61, 0x74, 0x63, 0x68, 0x4c, + 0x6f, 0x6f, 0x6b, 0x75, 0x70, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x32, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x39, 0x0a, 0x08, 0x72, 0x65, 0x73, 0x6f, 0x75, + 0x72, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x64, 0x69, 0x73, 0x70, + 0x61, 0x74, 0x63, 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x6f, 0x73, 0x73, 0x69, 0x62, 0x6c, 0x65, + 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x08, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, + 0x63, 0x65, 0x12, 0x35, 0x0a, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x64, 0x69, 0x73, 0x70, 0x61, 0x74, 0x63, 0x68, 0x2e, + 0x76, 0x31, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x4d, 0x65, 0x74, 0x61, 0x52, + 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, 0x47, 0x0a, 0x15, 0x61, 0x66, 0x74, + 0x65, 0x72, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x5f, 0x63, 0x75, 0x72, 0x73, + 0x6f, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x64, 0x69, 0x73, 0x70, 0x61, + 0x74, 0x63, 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x75, 0x72, 0x73, 0x6f, 0x72, 0x52, 0x13, 0x61, + 0x66, 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x43, 0x75, 0x72, 0x73, + 0x6f, 0x72, 0x22, 0xa7, 0x02, 0x0a, 0x1d, 0x44, 0x69, 0x73, 0x70, 0x61, 0x74, 0x63, 0x68, 0x4c, + 0x6f, 0x6f, 0x6b, 0x75, 0x70, 0x53, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x12, 0x3f, 0x0a, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x64, 0x69, 0x73, 0x70, 0x61, 0x74, 0x63, + 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x6c, 0x76, 0x65, 0x72, 0x4d, 0x65, 0x74, + 0x61, 0x42, 0x08, 0xfa, 0x42, 0x05, 0x8a, 0x01, 0x02, 0x10, 0x01, 0x52, 0x08, 0x6d, 0x65, 0x74, + 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, 0x51, 0x0a, 0x11, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, + 0x65, 0x5f, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x1a, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x52, 0x65, 0x6c, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x42, 0x08, 0xfa, 0x42, + 0x05, 0x8a, 0x01, 0x02, 0x10, 0x01, 0x52, 0x10, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, + 0x52, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x21, 0x0a, 0x0c, 0x72, 0x65, 0x73, 0x6f, + 0x75, 0x72, 0x63, 0x65, 0x5f, 0x69, 0x64, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0b, + 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x49, 0x64, 0x73, 0x12, 0x4f, 0x0a, 0x10, 0x73, + 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x5f, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, + 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, + 0x52, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, + 0x65, 0x42, 0x08, 0xfa, 0x42, 0x05, 0x8a, 0x01, 0x02, 0x10, 0x01, 0x52, 0x0f, 0x73, 0x75, 0x62, + 0x6a, 0x65, 0x63, 0x74, 0x52, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0xbd, 0x01, 0x0a, + 0x0c, 0x46, 0x6f, 0x75, 0x6e, 0x64, 0x53, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x1d, 0x0a, + 0x0a, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x09, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x49, 0x64, 0x12, 0x46, 0x0a, 0x11, + 0x63, 0x61, 0x76, 0x65, 0x61, 0x74, 0x5f, 0x65, 0x78, 0x70, 0x72, 0x65, 0x73, 0x73, 0x69, 0x6f, + 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x76, + 0x31, 0x2e, 0x43, 0x61, 0x76, 0x65, 0x61, 0x74, 0x45, 0x78, 0x70, 0x72, 0x65, 0x73, 0x73, 0x69, + 0x6f, 0x6e, 0x52, 0x10, 0x63, 0x61, 0x76, 0x65, 0x61, 0x74, 0x45, 0x78, 0x70, 0x72, 0x65, 0x73, + 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x46, 0x0a, 0x11, 0x65, 0x78, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x64, + 0x5f, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, + 0x19, 0x2e, 0x64, 0x69, 0x73, 0x70, 0x61, 0x74, 0x63, 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x46, 0x6f, + 0x75, 0x6e, 0x64, 0x53, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x10, 0x65, 0x78, 0x63, 0x6c, + 0x75, 0x64, 0x65, 0x64, 0x53, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x22, 0x51, 0x0a, 0x0d, + 0x46, 0x6f, 0x75, 0x6e, 0x64, 0x53, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x12, 0x40, 0x0a, + 0x0e, 0x66, 0x6f, 0x75, 0x6e, 0x64, 0x5f, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x18, + 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x64, 0x69, 0x73, 0x70, 0x61, 0x74, 0x63, 0x68, + 0x2e, 0x76, 0x31, 0x2e, 0x46, 0x6f, 0x75, 0x6e, 0x64, 0x53, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, + 0x52, 0x0d, 0x66, 0x6f, 0x75, 0x6e, 0x64, 0x53, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x22, + 0xd0, 0x02, 0x0a, 0x1e, 0x44, 0x69, 0x73, 0x70, 0x61, 0x74, 0x63, 0x68, 0x4c, 0x6f, 0x6f, 0x6b, + 0x75, 0x70, 0x53, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x12, 0x8c, 0x01, 0x0a, 0x1d, 0x66, 0x6f, 0x75, 0x6e, 0x64, 0x5f, 0x73, 0x75, 0x62, + 0x6a, 0x65, 0x63, 0x74, 0x73, 0x5f, 0x62, 0x79, 0x5f, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, + 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x4a, 0x2e, 0x64, 0x69, 0x73, + 0x70, 0x61, 0x74, 0x63, 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x69, 0x73, 0x70, 0x61, 0x74, 0x63, + 0x68, 0x4c, 0x6f, 0x6f, 0x6b, 0x75, 0x70, 0x53, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x46, 0x6f, 0x75, 0x6e, 0x64, 0x53, 0x75, 0x62, + 0x6a, 0x65, 0x63, 0x74, 0x73, 0x42, 0x79, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x49, + 0x64, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x19, 0x66, 0x6f, 0x75, 0x6e, 0x64, 0x53, 0x75, 0x62, + 0x6a, 0x65, 0x63, 0x74, 0x73, 0x42, 0x79, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x49, + 0x64, 0x12, 0x35, 0x0a, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x64, 0x69, 0x73, 0x70, 0x61, 0x74, 0x63, 0x68, 0x2e, 0x76, + 0x31, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x4d, 0x65, 0x74, 0x61, 0x52, 0x08, + 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x1a, 0x68, 0x0a, 0x1e, 0x46, 0x6f, 0x75, 0x6e, + 0x64, 0x53, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x42, 0x79, 0x52, 0x65, 0x73, 0x6f, 0x75, + 0x72, 0x63, 0x65, 0x49, 0x64, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, + 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x30, 0x0a, 0x05, + 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x64, 0x69, + 0x73, 0x70, 0x61, 0x74, 0x63, 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x46, 0x6f, 0x75, 0x6e, 0x64, 0x53, + 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, + 0x38, 0x01, 0x22, 0xb7, 0x01, 0x0a, 0x0c, 0x52, 0x65, 0x73, 0x6f, 0x6c, 0x76, 0x65, 0x72, 0x4d, + 0x65, 0x74, 0x61, 0x12, 0x1f, 0x0a, 0x0b, 0x61, 0x74, 0x5f, 0x72, 0x65, 0x76, 0x69, 0x73, 0x69, + 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x61, 0x74, 0x52, 0x65, 0x76, 0x69, + 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x30, 0x0a, 0x0f, 0x64, 0x65, 0x70, 0x74, 0x68, 0x5f, 0x72, 0x65, + 0x6d, 0x61, 0x69, 0x6e, 0x69, 0x6e, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x42, 0x07, 0xfa, + 0x42, 0x04, 0x2a, 0x02, 0x20, 0x00, 0x52, 0x0e, 0x64, 0x65, 0x70, 0x74, 0x68, 0x52, 0x65, 0x6d, + 0x61, 0x69, 0x6e, 0x69, 0x6e, 0x67, 0x12, 0x21, 0x0a, 0x0a, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x42, 0x02, 0x18, 0x01, 0x52, 0x09, + 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x49, 0x64, 0x12, 0x31, 0x0a, 0x0f, 0x74, 0x72, 0x61, + 0x76, 0x65, 0x72, 0x73, 0x61, 0x6c, 0x5f, 0x62, 0x6c, 0x6f, 0x6f, 0x6d, 0x18, 0x04, 0x20, 0x01, + 0x28, 0x0c, 0x42, 0x08, 0xfa, 0x42, 0x05, 0x7a, 0x03, 0x18, 0x80, 0x08, 0x52, 0x0e, 0x74, 0x72, + 0x61, 0x76, 0x65, 0x72, 0x73, 0x61, 0x6c, 0x42, 0x6c, 0x6f, 0x6f, 0x6d, 0x22, 0xda, 0x01, 0x0a, + 0x0c, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x4d, 0x65, 0x74, 0x61, 0x12, 0x25, 0x0a, + 0x0e, 0x64, 0x69, 0x73, 0x70, 0x61, 0x74, 0x63, 0x68, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0d, 0x64, 0x69, 0x73, 0x70, 0x61, 0x74, 0x63, 0x68, 0x43, + 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x25, 0x0a, 0x0e, 0x64, 0x65, 0x70, 0x74, 0x68, 0x5f, 0x72, 0x65, + 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0d, 0x64, 0x65, + 0x70, 0x74, 0x68, 0x52, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x12, 0x32, 0x0a, 0x15, 0x63, + 0x61, 0x63, 0x68, 0x65, 0x64, 0x5f, 0x64, 0x69, 0x73, 0x70, 0x61, 0x74, 0x63, 0x68, 0x5f, 0x63, + 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x13, 0x63, 0x61, 0x63, 0x68, + 0x65, 0x64, 0x44, 0x69, 0x73, 0x70, 0x61, 0x74, 0x63, 0x68, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, + 0x3c, 0x0a, 0x0a, 0x64, 0x65, 0x62, 0x75, 0x67, 0x5f, 0x69, 0x6e, 0x66, 0x6f, 0x18, 0x06, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x64, 0x69, 0x73, 0x70, 0x61, 0x74, 0x63, 0x68, 0x2e, 0x76, + 0x31, 0x2e, 0x44, 0x65, 0x62, 0x75, 0x67, 0x49, 0x6e, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x52, 0x09, 0x64, 0x65, 0x62, 0x75, 0x67, 0x49, 0x6e, 0x66, 0x6f, 0x4a, 0x04, 0x08, + 0x04, 0x10, 0x05, 0x4a, 0x04, 0x08, 0x05, 0x10, 0x06, 0x22, 0x46, 0x0a, 0x10, 0x44, 0x65, 0x62, + 0x75, 0x67, 0x49, 0x6e, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x32, 0x0a, + 0x05, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x64, + 0x69, 0x73, 0x70, 0x61, 0x74, 0x63, 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x68, 0x65, 0x63, 0x6b, + 0x44, 0x65, 0x62, 0x75, 0x67, 0x54, 0x72, 0x61, 0x63, 0x65, 0x52, 0x05, 0x63, 0x68, 0x65, 0x63, + 0x6b, 0x22, 0xe7, 0x04, 0x0a, 0x0f, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x44, 0x65, 0x62, 0x75, 0x67, + 0x54, 0x72, 0x61, 0x63, 0x65, 0x12, 0x3b, 0x0a, 0x07, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x64, 0x69, 0x73, 0x70, 0x61, 0x74, 0x63, + 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x69, 0x73, 0x70, 0x61, 0x74, 0x63, 0x68, 0x43, 0x68, 0x65, + 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x52, 0x07, 0x72, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x12, 0x5f, 0x0a, 0x16, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x72, + 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x0e, 0x32, 0x29, 0x2e, 0x64, 0x69, 0x73, 0x70, 0x61, 0x74, 0x63, 0x68, 0x2e, 0x76, 0x31, + 0x2e, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x44, 0x65, 0x62, 0x75, 0x67, 0x54, 0x72, 0x61, 0x63, 0x65, + 0x2e, 0x52, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x52, 0x14, 0x72, + 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x54, + 0x79, 0x70, 0x65, 0x12, 0x43, 0x0a, 0x07, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x73, 0x18, 0x03, + 0x20, 0x03, 0x28, 0x0b, 0x32, 0x29, 0x2e, 0x64, 0x69, 0x73, 0x70, 0x61, 0x74, 0x63, 0x68, 0x2e, + 0x76, 0x31, 0x2e, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x44, 0x65, 0x62, 0x75, 0x67, 0x54, 0x72, 0x61, + 0x63, 0x65, 0x2e, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, + 0x07, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x73, 0x12, 0x28, 0x0a, 0x10, 0x69, 0x73, 0x5f, 0x63, + 0x61, 0x63, 0x68, 0x65, 0x64, 0x5f, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x18, 0x04, 0x20, 0x01, + 0x28, 0x08, 0x52, 0x0e, 0x69, 0x73, 0x43, 0x61, 0x63, 0x68, 0x65, 0x64, 0x52, 0x65, 0x73, 0x75, + 0x6c, 0x74, 0x12, 0x3f, 0x0a, 0x0c, 0x73, 0x75, 0x62, 0x5f, 0x70, 0x72, 0x6f, 0x62, 0x6c, 0x65, + 0x6d, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x64, 0x69, 0x73, 0x70, 0x61, + 0x74, 0x63, 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x44, 0x65, 0x62, 0x75, + 0x67, 0x54, 0x72, 0x61, 0x63, 0x65, 0x52, 0x0b, 0x73, 0x75, 0x62, 0x50, 0x72, 0x6f, 0x62, 0x6c, + 0x65, 0x6d, 0x73, 0x12, 0x35, 0x0a, 0x08, 0x64, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, + 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x52, 0x08, 0x64, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x19, 0x0a, 0x08, 0x74, 0x72, + 0x61, 0x63, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x74, 0x72, + 0x61, 0x63, 0x65, 0x49, 0x64, 0x12, 0x1b, 0x0a, 0x09, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, + 0x69, 0x64, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, + 0x49, 0x64, 0x1a, 0x5c, 0x0a, 0x0c, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x73, 0x45, 0x6e, 0x74, + 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x03, 0x6b, 0x65, 0x79, 0x12, 0x36, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x64, 0x69, 0x73, 0x70, 0x61, 0x74, 0x63, 0x68, 0x2e, 0x76, + 0x31, 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x52, + 0x65, 0x73, 0x75, 0x6c, 0x74, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, + 0x22, 0x39, 0x0a, 0x0c, 0x52, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x54, 0x79, 0x70, 0x65, + 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x0c, 0x0a, + 0x08, 0x52, 0x45, 0x4c, 0x41, 0x54, 0x49, 0x4f, 0x4e, 0x10, 0x01, 0x12, 0x0e, 0x0a, 0x0a, 0x50, + 0x45, 0x52, 0x4d, 0x49, 0x53, 0x53, 0x49, 0x4f, 0x4e, 0x10, 0x02, 0x32, 0xbc, 0x03, 0x0a, 0x0f, + 0x44, 0x69, 0x73, 0x70, 0x61, 0x74, 0x63, 0x68, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, + 0x58, 0x0a, 0x0d, 0x44, 0x69, 0x73, 0x70, 0x61, 0x74, 0x63, 0x68, 0x43, 0x68, 0x65, 0x63, 0x6b, + 0x12, 0x21, 0x2e, 0x64, 0x69, 0x73, 0x70, 0x61, 0x74, 0x63, 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x44, + 0x69, 0x73, 0x70, 0x61, 0x74, 0x63, 0x68, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x1a, 0x22, 0x2e, 0x64, 0x69, 0x73, 0x70, 0x61, 0x74, 0x63, 0x68, 0x2e, 0x76, + 0x31, 0x2e, 0x44, 0x69, 0x73, 0x70, 0x61, 0x74, 0x63, 0x68, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x5b, 0x0a, 0x0e, 0x44, 0x69, 0x73, + 0x70, 0x61, 0x74, 0x63, 0x68, 0x45, 0x78, 0x70, 0x61, 0x6e, 0x64, 0x12, 0x22, 0x2e, 0x64, 0x69, + 0x73, 0x70, 0x61, 0x74, 0x63, 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x69, 0x73, 0x70, 0x61, 0x74, + 0x63, 0x68, 0x45, 0x78, 0x70, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, + 0x23, 0x2e, 0x64, 0x69, 0x73, 0x70, 0x61, 0x74, 0x63, 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x69, + 0x73, 0x70, 0x61, 0x74, 0x63, 0x68, 0x45, 0x78, 0x70, 0x61, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x75, 0x0a, 0x16, 0x44, 0x69, 0x73, 0x70, 0x61, 0x74, + 0x63, 0x68, 0x4c, 0x6f, 0x6f, 0x6b, 0x75, 0x70, 0x53, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, + 0x12, 0x2a, 0x2e, 0x64, 0x69, 0x73, 0x70, 0x61, 0x74, 0x63, 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x44, + 0x69, 0x73, 0x70, 0x61, 0x74, 0x63, 0x68, 0x4c, 0x6f, 0x6f, 0x6b, 0x75, 0x70, 0x53, 0x75, 0x62, + 0x6a, 0x65, 0x63, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2b, 0x2e, 0x64, + 0x69, 0x73, 0x70, 0x61, 0x74, 0x63, 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x69, 0x73, 0x70, 0x61, + 0x74, 0x63, 0x68, 0x4c, 0x6f, 0x6f, 0x6b, 0x75, 0x70, 0x53, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, + 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x30, 0x01, 0x12, 0x7b, 0x0a, + 0x18, 0x44, 0x69, 0x73, 0x70, 0x61, 0x74, 0x63, 0x68, 0x4c, 0x6f, 0x6f, 0x6b, 0x75, 0x70, 0x52, + 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x32, 0x12, 0x2c, 0x2e, 0x64, 0x69, 0x73, 0x70, + 0x61, 0x74, 0x63, 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x69, 0x73, 0x70, 0x61, 0x74, 0x63, 0x68, + 0x4c, 0x6f, 0x6f, 0x6b, 0x75, 0x70, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x32, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2d, 0x2e, 0x64, 0x69, 0x73, 0x70, 0x61, 0x74, + 0x63, 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x69, 0x73, 0x70, 0x61, 0x74, 0x63, 0x68, 0x4c, 0x6f, + 0x6f, 0x6b, 0x75, 0x70, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x32, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x30, 0x01, 0x42, 0xaa, 0x01, 0x0a, 0x0f, 0x63, + 0x6f, 0x6d, 0x2e, 0x64, 0x69, 0x73, 0x70, 0x61, 0x74, 0x63, 0x68, 0x2e, 0x76, 0x31, 0x42, 0x0d, + 0x44, 0x69, 0x73, 0x70, 0x61, 0x74, 0x63, 0x68, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, + 0x3b, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x61, 0x75, 0x74, 0x68, + 0x7a, 0x65, 0x64, 0x2f, 0x73, 0x70, 0x69, 0x63, 0x65, 0x64, 0x62, 0x2f, 0x70, 0x6b, 0x67, 0x2f, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x64, 0x69, 0x73, 0x70, 0x61, 0x74, 0x63, 0x68, 0x2f, 0x76, + 0x31, 0x3b, 0x64, 0x69, 0x73, 0x70, 0x61, 0x74, 0x63, 0x68, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x44, + 0x58, 0x58, 0xaa, 0x02, 0x0b, 0x44, 0x69, 0x73, 0x70, 0x61, 0x74, 0x63, 0x68, 0x2e, 0x56, 0x31, + 0xca, 0x02, 0x0b, 0x44, 0x69, 0x73, 0x70, 0x61, 0x74, 0x63, 0x68, 0x5c, 0x56, 0x31, 0xe2, 0x02, + 0x17, 0x44, 0x69, 0x73, 0x70, 0x61, 0x74, 0x63, 0x68, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, + 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x0c, 0x44, 0x69, 0x73, 0x70, 0x61, + 0x74, 0x63, 0x68, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_dispatch_v1_dispatch_proto_rawDescOnce sync.Once + file_dispatch_v1_dispatch_proto_rawDescData = file_dispatch_v1_dispatch_proto_rawDesc +) + +func file_dispatch_v1_dispatch_proto_rawDescGZIP() []byte { + file_dispatch_v1_dispatch_proto_rawDescOnce.Do(func() { + file_dispatch_v1_dispatch_proto_rawDescData = protoimpl.X.CompressGZIP(file_dispatch_v1_dispatch_proto_rawDescData) + }) + return file_dispatch_v1_dispatch_proto_rawDescData +} + +var file_dispatch_v1_dispatch_proto_enumTypes = make([]protoimpl.EnumInfo, 5) +var file_dispatch_v1_dispatch_proto_msgTypes = make([]protoimpl.MessageInfo, 21) +var file_dispatch_v1_dispatch_proto_goTypes = []any{ + (DispatchCheckRequest_DebugSetting)(0), // 0: dispatch.v1.DispatchCheckRequest.DebugSetting + (DispatchCheckRequest_ResultsSetting)(0), // 1: dispatch.v1.DispatchCheckRequest.ResultsSetting + (ResourceCheckResult_Membership)(0), // 2: dispatch.v1.ResourceCheckResult.Membership + (DispatchExpandRequest_ExpansionMode)(0), // 3: dispatch.v1.DispatchExpandRequest.ExpansionMode + (CheckDebugTrace_RelationType)(0), // 4: dispatch.v1.CheckDebugTrace.RelationType + (*DispatchCheckRequest)(nil), // 5: dispatch.v1.DispatchCheckRequest + (*CheckHint)(nil), // 6: dispatch.v1.CheckHint + (*DispatchCheckResponse)(nil), // 7: dispatch.v1.DispatchCheckResponse + (*ResourceCheckResult)(nil), // 8: dispatch.v1.ResourceCheckResult + (*DispatchExpandRequest)(nil), // 9: dispatch.v1.DispatchExpandRequest + (*DispatchExpandResponse)(nil), // 10: dispatch.v1.DispatchExpandResponse + (*Cursor)(nil), // 11: dispatch.v1.Cursor + (*DispatchLookupResources2Request)(nil), // 12: dispatch.v1.DispatchLookupResources2Request + (*PossibleResource)(nil), // 13: dispatch.v1.PossibleResource + (*DispatchLookupResources2Response)(nil), // 14: dispatch.v1.DispatchLookupResources2Response + (*DispatchLookupSubjectsRequest)(nil), // 15: dispatch.v1.DispatchLookupSubjectsRequest + (*FoundSubject)(nil), // 16: dispatch.v1.FoundSubject + (*FoundSubjects)(nil), // 17: dispatch.v1.FoundSubjects + (*DispatchLookupSubjectsResponse)(nil), // 18: dispatch.v1.DispatchLookupSubjectsResponse + (*ResolverMeta)(nil), // 19: dispatch.v1.ResolverMeta + (*ResponseMeta)(nil), // 20: dispatch.v1.ResponseMeta + (*DebugInformation)(nil), // 21: dispatch.v1.DebugInformation + (*CheckDebugTrace)(nil), // 22: dispatch.v1.CheckDebugTrace + nil, // 23: dispatch.v1.DispatchCheckResponse.ResultsByResourceIdEntry + nil, // 24: dispatch.v1.DispatchLookupSubjectsResponse.FoundSubjectsByResourceIdEntry + nil, // 25: dispatch.v1.CheckDebugTrace.ResultsEntry + (*v1.RelationReference)(nil), // 26: core.v1.RelationReference + (*v1.ObjectAndRelation)(nil), // 27: core.v1.ObjectAndRelation + (*v1.CaveatExpression)(nil), // 28: core.v1.CaveatExpression + (*v1.RelationTupleTreeNode)(nil), // 29: core.v1.RelationTupleTreeNode + (*structpb.Struct)(nil), // 30: google.protobuf.Struct + (*durationpb.Duration)(nil), // 31: google.protobuf.Duration +} +var file_dispatch_v1_dispatch_proto_depIdxs = []int32{ + 19, // 0: dispatch.v1.DispatchCheckRequest.metadata:type_name -> dispatch.v1.ResolverMeta + 26, // 1: dispatch.v1.DispatchCheckRequest.resource_relation:type_name -> core.v1.RelationReference + 27, // 2: dispatch.v1.DispatchCheckRequest.subject:type_name -> core.v1.ObjectAndRelation + 1, // 3: dispatch.v1.DispatchCheckRequest.results_setting:type_name -> dispatch.v1.DispatchCheckRequest.ResultsSetting + 0, // 4: dispatch.v1.DispatchCheckRequest.debug:type_name -> dispatch.v1.DispatchCheckRequest.DebugSetting + 6, // 5: dispatch.v1.DispatchCheckRequest.check_hints:type_name -> dispatch.v1.CheckHint + 27, // 6: dispatch.v1.CheckHint.resource:type_name -> core.v1.ObjectAndRelation + 27, // 7: dispatch.v1.CheckHint.subject:type_name -> core.v1.ObjectAndRelation + 8, // 8: dispatch.v1.CheckHint.result:type_name -> dispatch.v1.ResourceCheckResult + 20, // 9: dispatch.v1.DispatchCheckResponse.metadata:type_name -> dispatch.v1.ResponseMeta + 23, // 10: dispatch.v1.DispatchCheckResponse.results_by_resource_id:type_name -> dispatch.v1.DispatchCheckResponse.ResultsByResourceIdEntry + 2, // 11: dispatch.v1.ResourceCheckResult.membership:type_name -> dispatch.v1.ResourceCheckResult.Membership + 28, // 12: dispatch.v1.ResourceCheckResult.expression:type_name -> core.v1.CaveatExpression + 19, // 13: dispatch.v1.DispatchExpandRequest.metadata:type_name -> dispatch.v1.ResolverMeta + 27, // 14: dispatch.v1.DispatchExpandRequest.resource_and_relation:type_name -> core.v1.ObjectAndRelation + 3, // 15: dispatch.v1.DispatchExpandRequest.expansion_mode:type_name -> dispatch.v1.DispatchExpandRequest.ExpansionMode + 20, // 16: dispatch.v1.DispatchExpandResponse.metadata:type_name -> dispatch.v1.ResponseMeta + 29, // 17: dispatch.v1.DispatchExpandResponse.tree_node:type_name -> core.v1.RelationTupleTreeNode + 19, // 18: dispatch.v1.DispatchLookupResources2Request.metadata:type_name -> dispatch.v1.ResolverMeta + 26, // 19: dispatch.v1.DispatchLookupResources2Request.resource_relation:type_name -> core.v1.RelationReference + 26, // 20: dispatch.v1.DispatchLookupResources2Request.subject_relation:type_name -> core.v1.RelationReference + 27, // 21: dispatch.v1.DispatchLookupResources2Request.terminal_subject:type_name -> core.v1.ObjectAndRelation + 30, // 22: dispatch.v1.DispatchLookupResources2Request.context:type_name -> google.protobuf.Struct + 11, // 23: dispatch.v1.DispatchLookupResources2Request.optional_cursor:type_name -> dispatch.v1.Cursor + 13, // 24: dispatch.v1.DispatchLookupResources2Response.resource:type_name -> dispatch.v1.PossibleResource + 20, // 25: dispatch.v1.DispatchLookupResources2Response.metadata:type_name -> dispatch.v1.ResponseMeta + 11, // 26: dispatch.v1.DispatchLookupResources2Response.after_response_cursor:type_name -> dispatch.v1.Cursor + 19, // 27: dispatch.v1.DispatchLookupSubjectsRequest.metadata:type_name -> dispatch.v1.ResolverMeta + 26, // 28: dispatch.v1.DispatchLookupSubjectsRequest.resource_relation:type_name -> core.v1.RelationReference + 26, // 29: dispatch.v1.DispatchLookupSubjectsRequest.subject_relation:type_name -> core.v1.RelationReference + 28, // 30: dispatch.v1.FoundSubject.caveat_expression:type_name -> core.v1.CaveatExpression + 16, // 31: dispatch.v1.FoundSubject.excluded_subjects:type_name -> dispatch.v1.FoundSubject + 16, // 32: dispatch.v1.FoundSubjects.found_subjects:type_name -> dispatch.v1.FoundSubject + 24, // 33: dispatch.v1.DispatchLookupSubjectsResponse.found_subjects_by_resource_id:type_name -> dispatch.v1.DispatchLookupSubjectsResponse.FoundSubjectsByResourceIdEntry + 20, // 34: dispatch.v1.DispatchLookupSubjectsResponse.metadata:type_name -> dispatch.v1.ResponseMeta + 21, // 35: dispatch.v1.ResponseMeta.debug_info:type_name -> dispatch.v1.DebugInformation + 22, // 36: dispatch.v1.DebugInformation.check:type_name -> dispatch.v1.CheckDebugTrace + 5, // 37: dispatch.v1.CheckDebugTrace.request:type_name -> dispatch.v1.DispatchCheckRequest + 4, // 38: dispatch.v1.CheckDebugTrace.resource_relation_type:type_name -> dispatch.v1.CheckDebugTrace.RelationType + 25, // 39: dispatch.v1.CheckDebugTrace.results:type_name -> dispatch.v1.CheckDebugTrace.ResultsEntry + 22, // 40: dispatch.v1.CheckDebugTrace.sub_problems:type_name -> dispatch.v1.CheckDebugTrace + 31, // 41: dispatch.v1.CheckDebugTrace.duration:type_name -> google.protobuf.Duration + 8, // 42: dispatch.v1.DispatchCheckResponse.ResultsByResourceIdEntry.value:type_name -> dispatch.v1.ResourceCheckResult + 17, // 43: dispatch.v1.DispatchLookupSubjectsResponse.FoundSubjectsByResourceIdEntry.value:type_name -> dispatch.v1.FoundSubjects + 8, // 44: dispatch.v1.CheckDebugTrace.ResultsEntry.value:type_name -> dispatch.v1.ResourceCheckResult + 5, // 45: dispatch.v1.DispatchService.DispatchCheck:input_type -> dispatch.v1.DispatchCheckRequest + 9, // 46: dispatch.v1.DispatchService.DispatchExpand:input_type -> dispatch.v1.DispatchExpandRequest + 15, // 47: dispatch.v1.DispatchService.DispatchLookupSubjects:input_type -> dispatch.v1.DispatchLookupSubjectsRequest + 12, // 48: dispatch.v1.DispatchService.DispatchLookupResources2:input_type -> dispatch.v1.DispatchLookupResources2Request + 7, // 49: dispatch.v1.DispatchService.DispatchCheck:output_type -> dispatch.v1.DispatchCheckResponse + 10, // 50: dispatch.v1.DispatchService.DispatchExpand:output_type -> dispatch.v1.DispatchExpandResponse + 18, // 51: dispatch.v1.DispatchService.DispatchLookupSubjects:output_type -> dispatch.v1.DispatchLookupSubjectsResponse + 14, // 52: dispatch.v1.DispatchService.DispatchLookupResources2:output_type -> dispatch.v1.DispatchLookupResources2Response + 49, // [49:53] is the sub-list for method output_type + 45, // [45:49] is the sub-list for method input_type + 45, // [45:45] is the sub-list for extension type_name + 45, // [45:45] is the sub-list for extension extendee + 0, // [0:45] is the sub-list for field type_name +} + +func init() { file_dispatch_v1_dispatch_proto_init() } +func file_dispatch_v1_dispatch_proto_init() { + if File_dispatch_v1_dispatch_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_dispatch_v1_dispatch_proto_msgTypes[0].Exporter = func(v any, i int) any { + switch v := v.(*DispatchCheckRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_dispatch_v1_dispatch_proto_msgTypes[1].Exporter = func(v any, i int) any { + switch v := v.(*CheckHint); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_dispatch_v1_dispatch_proto_msgTypes[2].Exporter = func(v any, i int) any { + switch v := v.(*DispatchCheckResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_dispatch_v1_dispatch_proto_msgTypes[3].Exporter = func(v any, i int) any { + switch v := v.(*ResourceCheckResult); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_dispatch_v1_dispatch_proto_msgTypes[4].Exporter = func(v any, i int) any { + switch v := v.(*DispatchExpandRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_dispatch_v1_dispatch_proto_msgTypes[5].Exporter = func(v any, i int) any { + switch v := v.(*DispatchExpandResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_dispatch_v1_dispatch_proto_msgTypes[6].Exporter = func(v any, i int) any { + switch v := v.(*Cursor); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_dispatch_v1_dispatch_proto_msgTypes[7].Exporter = func(v any, i int) any { + switch v := v.(*DispatchLookupResources2Request); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_dispatch_v1_dispatch_proto_msgTypes[8].Exporter = func(v any, i int) any { + switch v := v.(*PossibleResource); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_dispatch_v1_dispatch_proto_msgTypes[9].Exporter = func(v any, i int) any { + switch v := v.(*DispatchLookupResources2Response); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_dispatch_v1_dispatch_proto_msgTypes[10].Exporter = func(v any, i int) any { + switch v := v.(*DispatchLookupSubjectsRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_dispatch_v1_dispatch_proto_msgTypes[11].Exporter = func(v any, i int) any { + switch v := v.(*FoundSubject); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_dispatch_v1_dispatch_proto_msgTypes[12].Exporter = func(v any, i int) any { + switch v := v.(*FoundSubjects); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_dispatch_v1_dispatch_proto_msgTypes[13].Exporter = func(v any, i int) any { + switch v := v.(*DispatchLookupSubjectsResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_dispatch_v1_dispatch_proto_msgTypes[14].Exporter = func(v any, i int) any { + switch v := v.(*ResolverMeta); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_dispatch_v1_dispatch_proto_msgTypes[15].Exporter = func(v any, i int) any { + switch v := v.(*ResponseMeta); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_dispatch_v1_dispatch_proto_msgTypes[16].Exporter = func(v any, i int) any { + switch v := v.(*DebugInformation); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_dispatch_v1_dispatch_proto_msgTypes[17].Exporter = func(v any, i int) any { + switch v := v.(*CheckDebugTrace); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_dispatch_v1_dispatch_proto_rawDesc, + NumEnums: 5, + NumMessages: 21, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_dispatch_v1_dispatch_proto_goTypes, + DependencyIndexes: file_dispatch_v1_dispatch_proto_depIdxs, + EnumInfos: file_dispatch_v1_dispatch_proto_enumTypes, + MessageInfos: file_dispatch_v1_dispatch_proto_msgTypes, + }.Build() + File_dispatch_v1_dispatch_proto = out.File + file_dispatch_v1_dispatch_proto_rawDesc = nil + file_dispatch_v1_dispatch_proto_goTypes = nil + file_dispatch_v1_dispatch_proto_depIdxs = nil +} diff --git a/vendor/github.com/authzed/spicedb/pkg/proto/dispatch/v1/dispatch.pb.validate.go b/vendor/github.com/authzed/spicedb/pkg/proto/dispatch/v1/dispatch.pb.validate.go new file mode 100644 index 0000000..46f2330 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/proto/dispatch/v1/dispatch.pb.validate.go @@ -0,0 +1,3188 @@ +// Code generated by protoc-gen-validate. DO NOT EDIT. +// source: dispatch/v1/dispatch.proto + +package dispatchv1 + +import ( + "bytes" + "errors" + "fmt" + "net" + "net/mail" + "net/url" + "regexp" + "sort" + "strings" + "time" + "unicode/utf8" + + "google.golang.org/protobuf/types/known/anypb" +) + +// ensure the imports are used +var ( + _ = bytes.MinRead + _ = errors.New("") + _ = fmt.Print + _ = utf8.UTFMax + _ = (*regexp.Regexp)(nil) + _ = (*strings.Reader)(nil) + _ = net.IPv4len + _ = time.Duration(0) + _ = (*url.URL)(nil) + _ = (*mail.Address)(nil) + _ = anypb.Any{} + _ = sort.Sort +) + +// Validate checks the field values on DispatchCheckRequest with the rules +// defined in the proto definition for this message. If any rules are +// violated, the first error encountered is returned, or nil if there are no violations. +func (m *DispatchCheckRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on DispatchCheckRequest with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// DispatchCheckRequestMultiError, or nil if none found. +func (m *DispatchCheckRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *DispatchCheckRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if m.GetMetadata() == nil { + err := DispatchCheckRequestValidationError{ + field: "Metadata", + reason: "value is required", + } + if !all { + return err + } + errors = append(errors, err) + } + + if all { + switch v := interface{}(m.GetMetadata()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, DispatchCheckRequestValidationError{ + field: "Metadata", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, DispatchCheckRequestValidationError{ + field: "Metadata", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetMetadata()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return DispatchCheckRequestValidationError{ + field: "Metadata", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if m.GetResourceRelation() == nil { + err := DispatchCheckRequestValidationError{ + field: "ResourceRelation", + reason: "value is required", + } + if !all { + return err + } + errors = append(errors, err) + } + + if all { + switch v := interface{}(m.GetResourceRelation()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, DispatchCheckRequestValidationError{ + field: "ResourceRelation", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, DispatchCheckRequestValidationError{ + field: "ResourceRelation", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetResourceRelation()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return DispatchCheckRequestValidationError{ + field: "ResourceRelation", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if m.GetSubject() == nil { + err := DispatchCheckRequestValidationError{ + field: "Subject", + reason: "value is required", + } + if !all { + return err + } + errors = append(errors, err) + } + + if all { + switch v := interface{}(m.GetSubject()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, DispatchCheckRequestValidationError{ + field: "Subject", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, DispatchCheckRequestValidationError{ + field: "Subject", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetSubject()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return DispatchCheckRequestValidationError{ + field: "Subject", + reason: "embedded message failed validation", + cause: err, + } + } + } + + // no validation rules for ResultsSetting + + // no validation rules for Debug + + for idx, item := range m.GetCheckHints() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, DispatchCheckRequestValidationError{ + field: fmt.Sprintf("CheckHints[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, DispatchCheckRequestValidationError{ + field: fmt.Sprintf("CheckHints[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return DispatchCheckRequestValidationError{ + field: fmt.Sprintf("CheckHints[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + if len(errors) > 0 { + return DispatchCheckRequestMultiError(errors) + } + + return nil +} + +// DispatchCheckRequestMultiError is an error wrapping multiple validation +// errors returned by DispatchCheckRequest.ValidateAll() if the designated +// constraints aren't met. +type DispatchCheckRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m DispatchCheckRequestMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m DispatchCheckRequestMultiError) AllErrors() []error { return m } + +// DispatchCheckRequestValidationError is the validation error returned by +// DispatchCheckRequest.Validate if the designated constraints aren't met. +type DispatchCheckRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e DispatchCheckRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e DispatchCheckRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e DispatchCheckRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e DispatchCheckRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e DispatchCheckRequestValidationError) ErrorName() string { + return "DispatchCheckRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e DispatchCheckRequestValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sDispatchCheckRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = DispatchCheckRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = DispatchCheckRequestValidationError{} + +// Validate checks the field values on CheckHint with the rules defined in the +// proto definition for this message. If any rules are violated, the first +// error encountered is returned, or nil if there are no violations. +func (m *CheckHint) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on CheckHint with the rules defined in +// the proto definition for this message. If any rules are violated, the +// result is a list of violation errors wrapped in CheckHintMultiError, or nil +// if none found. +func (m *CheckHint) ValidateAll() error { + return m.validate(true) +} + +func (m *CheckHint) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetResource()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, CheckHintValidationError{ + field: "Resource", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, CheckHintValidationError{ + field: "Resource", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetResource()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return CheckHintValidationError{ + field: "Resource", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if all { + switch v := interface{}(m.GetSubject()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, CheckHintValidationError{ + field: "Subject", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, CheckHintValidationError{ + field: "Subject", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetSubject()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return CheckHintValidationError{ + field: "Subject", + reason: "embedded message failed validation", + cause: err, + } + } + } + + // no validation rules for TtuComputedUsersetRelation + + if all { + switch v := interface{}(m.GetResult()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, CheckHintValidationError{ + field: "Result", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, CheckHintValidationError{ + field: "Result", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetResult()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return CheckHintValidationError{ + field: "Result", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return CheckHintMultiError(errors) + } + + return nil +} + +// CheckHintMultiError is an error wrapping multiple validation errors returned +// by CheckHint.ValidateAll() if the designated constraints aren't met. +type CheckHintMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m CheckHintMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m CheckHintMultiError) AllErrors() []error { return m } + +// CheckHintValidationError is the validation error returned by +// CheckHint.Validate if the designated constraints aren't met. +type CheckHintValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e CheckHintValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e CheckHintValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e CheckHintValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e CheckHintValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e CheckHintValidationError) ErrorName() string { return "CheckHintValidationError" } + +// Error satisfies the builtin error interface +func (e CheckHintValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sCheckHint.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = CheckHintValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = CheckHintValidationError{} + +// Validate checks the field values on DispatchCheckResponse with the rules +// defined in the proto definition for this message. If any rules are +// violated, the first error encountered is returned, or nil if there are no violations. +func (m *DispatchCheckResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on DispatchCheckResponse with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// DispatchCheckResponseMultiError, or nil if none found. +func (m *DispatchCheckResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *DispatchCheckResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetMetadata()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, DispatchCheckResponseValidationError{ + field: "Metadata", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, DispatchCheckResponseValidationError{ + field: "Metadata", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetMetadata()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return DispatchCheckResponseValidationError{ + field: "Metadata", + reason: "embedded message failed validation", + cause: err, + } + } + } + + { + sorted_keys := make([]string, len(m.GetResultsByResourceId())) + i := 0 + for key := range m.GetResultsByResourceId() { + sorted_keys[i] = key + i++ + } + sort.Slice(sorted_keys, func(i, j int) bool { return sorted_keys[i] < sorted_keys[j] }) + for _, key := range sorted_keys { + val := m.GetResultsByResourceId()[key] + _ = val + + // no validation rules for ResultsByResourceId[key] + + if all { + switch v := interface{}(val).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, DispatchCheckResponseValidationError{ + field: fmt.Sprintf("ResultsByResourceId[%v]", key), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, DispatchCheckResponseValidationError{ + field: fmt.Sprintf("ResultsByResourceId[%v]", key), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(val).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return DispatchCheckResponseValidationError{ + field: fmt.Sprintf("ResultsByResourceId[%v]", key), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + } + + if len(errors) > 0 { + return DispatchCheckResponseMultiError(errors) + } + + return nil +} + +// DispatchCheckResponseMultiError is an error wrapping multiple validation +// errors returned by DispatchCheckResponse.ValidateAll() if the designated +// constraints aren't met. +type DispatchCheckResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m DispatchCheckResponseMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m DispatchCheckResponseMultiError) AllErrors() []error { return m } + +// DispatchCheckResponseValidationError is the validation error returned by +// DispatchCheckResponse.Validate if the designated constraints aren't met. +type DispatchCheckResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e DispatchCheckResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e DispatchCheckResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e DispatchCheckResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e DispatchCheckResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e DispatchCheckResponseValidationError) ErrorName() string { + return "DispatchCheckResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e DispatchCheckResponseValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sDispatchCheckResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = DispatchCheckResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = DispatchCheckResponseValidationError{} + +// Validate checks the field values on ResourceCheckResult with the rules +// defined in the proto definition for this message. If any rules are +// violated, the first error encountered is returned, or nil if there are no violations. +func (m *ResourceCheckResult) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on ResourceCheckResult with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// ResourceCheckResultMultiError, or nil if none found. +func (m *ResourceCheckResult) ValidateAll() error { + return m.validate(true) +} + +func (m *ResourceCheckResult) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Membership + + if all { + switch v := interface{}(m.GetExpression()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, ResourceCheckResultValidationError{ + field: "Expression", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, ResourceCheckResultValidationError{ + field: "Expression", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetExpression()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return ResourceCheckResultValidationError{ + field: "Expression", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return ResourceCheckResultMultiError(errors) + } + + return nil +} + +// ResourceCheckResultMultiError is an error wrapping multiple validation +// errors returned by ResourceCheckResult.ValidateAll() if the designated +// constraints aren't met. +type ResourceCheckResultMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ResourceCheckResultMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m ResourceCheckResultMultiError) AllErrors() []error { return m } + +// ResourceCheckResultValidationError is the validation error returned by +// ResourceCheckResult.Validate if the designated constraints aren't met. +type ResourceCheckResultValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e ResourceCheckResultValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e ResourceCheckResultValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e ResourceCheckResultValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e ResourceCheckResultValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e ResourceCheckResultValidationError) ErrorName() string { + return "ResourceCheckResultValidationError" +} + +// Error satisfies the builtin error interface +func (e ResourceCheckResultValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sResourceCheckResult.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = ResourceCheckResultValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = ResourceCheckResultValidationError{} + +// Validate checks the field values on DispatchExpandRequest with the rules +// defined in the proto definition for this message. If any rules are +// violated, the first error encountered is returned, or nil if there are no violations. +func (m *DispatchExpandRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on DispatchExpandRequest with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// DispatchExpandRequestMultiError, or nil if none found. +func (m *DispatchExpandRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *DispatchExpandRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if m.GetMetadata() == nil { + err := DispatchExpandRequestValidationError{ + field: "Metadata", + reason: "value is required", + } + if !all { + return err + } + errors = append(errors, err) + } + + if all { + switch v := interface{}(m.GetMetadata()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, DispatchExpandRequestValidationError{ + field: "Metadata", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, DispatchExpandRequestValidationError{ + field: "Metadata", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetMetadata()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return DispatchExpandRequestValidationError{ + field: "Metadata", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if m.GetResourceAndRelation() == nil { + err := DispatchExpandRequestValidationError{ + field: "ResourceAndRelation", + reason: "value is required", + } + if !all { + return err + } + errors = append(errors, err) + } + + if all { + switch v := interface{}(m.GetResourceAndRelation()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, DispatchExpandRequestValidationError{ + field: "ResourceAndRelation", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, DispatchExpandRequestValidationError{ + field: "ResourceAndRelation", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetResourceAndRelation()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return DispatchExpandRequestValidationError{ + field: "ResourceAndRelation", + reason: "embedded message failed validation", + cause: err, + } + } + } + + // no validation rules for ExpansionMode + + if len(errors) > 0 { + return DispatchExpandRequestMultiError(errors) + } + + return nil +} + +// DispatchExpandRequestMultiError is an error wrapping multiple validation +// errors returned by DispatchExpandRequest.ValidateAll() if the designated +// constraints aren't met. +type DispatchExpandRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m DispatchExpandRequestMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m DispatchExpandRequestMultiError) AllErrors() []error { return m } + +// DispatchExpandRequestValidationError is the validation error returned by +// DispatchExpandRequest.Validate if the designated constraints aren't met. +type DispatchExpandRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e DispatchExpandRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e DispatchExpandRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e DispatchExpandRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e DispatchExpandRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e DispatchExpandRequestValidationError) ErrorName() string { + return "DispatchExpandRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e DispatchExpandRequestValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sDispatchExpandRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = DispatchExpandRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = DispatchExpandRequestValidationError{} + +// Validate checks the field values on DispatchExpandResponse with the rules +// defined in the proto definition for this message. If any rules are +// violated, the first error encountered is returned, or nil if there are no violations. +func (m *DispatchExpandResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on DispatchExpandResponse with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// DispatchExpandResponseMultiError, or nil if none found. +func (m *DispatchExpandResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *DispatchExpandResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetMetadata()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, DispatchExpandResponseValidationError{ + field: "Metadata", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, DispatchExpandResponseValidationError{ + field: "Metadata", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetMetadata()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return DispatchExpandResponseValidationError{ + field: "Metadata", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if all { + switch v := interface{}(m.GetTreeNode()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, DispatchExpandResponseValidationError{ + field: "TreeNode", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, DispatchExpandResponseValidationError{ + field: "TreeNode", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetTreeNode()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return DispatchExpandResponseValidationError{ + field: "TreeNode", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return DispatchExpandResponseMultiError(errors) + } + + return nil +} + +// DispatchExpandResponseMultiError is an error wrapping multiple validation +// errors returned by DispatchExpandResponse.ValidateAll() if the designated +// constraints aren't met. +type DispatchExpandResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m DispatchExpandResponseMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m DispatchExpandResponseMultiError) AllErrors() []error { return m } + +// DispatchExpandResponseValidationError is the validation error returned by +// DispatchExpandResponse.Validate if the designated constraints aren't met. +type DispatchExpandResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e DispatchExpandResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e DispatchExpandResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e DispatchExpandResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e DispatchExpandResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e DispatchExpandResponseValidationError) ErrorName() string { + return "DispatchExpandResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e DispatchExpandResponseValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sDispatchExpandResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = DispatchExpandResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = DispatchExpandResponseValidationError{} + +// Validate checks the field values on Cursor with the rules defined in the +// proto definition for this message. If any rules are violated, the first +// error encountered is returned, or nil if there are no violations. +func (m *Cursor) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on Cursor with the rules defined in the +// proto definition for this message. If any rules are violated, the result is +// a list of violation errors wrapped in CursorMultiError, or nil if none found. +func (m *Cursor) ValidateAll() error { + return m.validate(true) +} + +func (m *Cursor) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for DispatchVersion + + if len(errors) > 0 { + return CursorMultiError(errors) + } + + return nil +} + +// CursorMultiError is an error wrapping multiple validation errors returned by +// Cursor.ValidateAll() if the designated constraints aren't met. +type CursorMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m CursorMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m CursorMultiError) AllErrors() []error { return m } + +// CursorValidationError is the validation error returned by Cursor.Validate if +// the designated constraints aren't met. +type CursorValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e CursorValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e CursorValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e CursorValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e CursorValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e CursorValidationError) ErrorName() string { return "CursorValidationError" } + +// Error satisfies the builtin error interface +func (e CursorValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sCursor.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = CursorValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = CursorValidationError{} + +// Validate checks the field values on DispatchLookupResources2Request with the +// rules defined in the proto definition for this message. If any rules are +// violated, the first error encountered is returned, or nil if there are no violations. +func (m *DispatchLookupResources2Request) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on DispatchLookupResources2Request with +// the rules defined in the proto definition for this message. If any rules +// are violated, the result is a list of violation errors wrapped in +// DispatchLookupResources2RequestMultiError, or nil if none found. +func (m *DispatchLookupResources2Request) ValidateAll() error { + return m.validate(true) +} + +func (m *DispatchLookupResources2Request) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if m.GetMetadata() == nil { + err := DispatchLookupResources2RequestValidationError{ + field: "Metadata", + reason: "value is required", + } + if !all { + return err + } + errors = append(errors, err) + } + + if all { + switch v := interface{}(m.GetMetadata()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, DispatchLookupResources2RequestValidationError{ + field: "Metadata", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, DispatchLookupResources2RequestValidationError{ + field: "Metadata", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetMetadata()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return DispatchLookupResources2RequestValidationError{ + field: "Metadata", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if m.GetResourceRelation() == nil { + err := DispatchLookupResources2RequestValidationError{ + field: "ResourceRelation", + reason: "value is required", + } + if !all { + return err + } + errors = append(errors, err) + } + + if all { + switch v := interface{}(m.GetResourceRelation()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, DispatchLookupResources2RequestValidationError{ + field: "ResourceRelation", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, DispatchLookupResources2RequestValidationError{ + field: "ResourceRelation", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetResourceRelation()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return DispatchLookupResources2RequestValidationError{ + field: "ResourceRelation", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if m.GetSubjectRelation() == nil { + err := DispatchLookupResources2RequestValidationError{ + field: "SubjectRelation", + reason: "value is required", + } + if !all { + return err + } + errors = append(errors, err) + } + + if all { + switch v := interface{}(m.GetSubjectRelation()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, DispatchLookupResources2RequestValidationError{ + field: "SubjectRelation", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, DispatchLookupResources2RequestValidationError{ + field: "SubjectRelation", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetSubjectRelation()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return DispatchLookupResources2RequestValidationError{ + field: "SubjectRelation", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if m.GetTerminalSubject() == nil { + err := DispatchLookupResources2RequestValidationError{ + field: "TerminalSubject", + reason: "value is required", + } + if !all { + return err + } + errors = append(errors, err) + } + + if all { + switch v := interface{}(m.GetTerminalSubject()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, DispatchLookupResources2RequestValidationError{ + field: "TerminalSubject", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, DispatchLookupResources2RequestValidationError{ + field: "TerminalSubject", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetTerminalSubject()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return DispatchLookupResources2RequestValidationError{ + field: "TerminalSubject", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if all { + switch v := interface{}(m.GetContext()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, DispatchLookupResources2RequestValidationError{ + field: "Context", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, DispatchLookupResources2RequestValidationError{ + field: "Context", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetContext()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return DispatchLookupResources2RequestValidationError{ + field: "Context", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if all { + switch v := interface{}(m.GetOptionalCursor()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, DispatchLookupResources2RequestValidationError{ + field: "OptionalCursor", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, DispatchLookupResources2RequestValidationError{ + field: "OptionalCursor", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetOptionalCursor()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return DispatchLookupResources2RequestValidationError{ + field: "OptionalCursor", + reason: "embedded message failed validation", + cause: err, + } + } + } + + // no validation rules for OptionalLimit + + if len(errors) > 0 { + return DispatchLookupResources2RequestMultiError(errors) + } + + return nil +} + +// DispatchLookupResources2RequestMultiError is an error wrapping multiple +// validation errors returned by DispatchLookupResources2Request.ValidateAll() +// if the designated constraints aren't met. +type DispatchLookupResources2RequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m DispatchLookupResources2RequestMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m DispatchLookupResources2RequestMultiError) AllErrors() []error { return m } + +// DispatchLookupResources2RequestValidationError is the validation error +// returned by DispatchLookupResources2Request.Validate if the designated +// constraints aren't met. +type DispatchLookupResources2RequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e DispatchLookupResources2RequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e DispatchLookupResources2RequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e DispatchLookupResources2RequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e DispatchLookupResources2RequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e DispatchLookupResources2RequestValidationError) ErrorName() string { + return "DispatchLookupResources2RequestValidationError" +} + +// Error satisfies the builtin error interface +func (e DispatchLookupResources2RequestValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sDispatchLookupResources2Request.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = DispatchLookupResources2RequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = DispatchLookupResources2RequestValidationError{} + +// Validate checks the field values on PossibleResource with the rules defined +// in the proto definition for this message. If any rules are violated, the +// first error encountered is returned, or nil if there are no violations. +func (m *PossibleResource) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on PossibleResource with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// PossibleResourceMultiError, or nil if none found. +func (m *PossibleResource) ValidateAll() error { + return m.validate(true) +} + +func (m *PossibleResource) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for ResourceId + + if len(errors) > 0 { + return PossibleResourceMultiError(errors) + } + + return nil +} + +// PossibleResourceMultiError is an error wrapping multiple validation errors +// returned by PossibleResource.ValidateAll() if the designated constraints +// aren't met. +type PossibleResourceMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m PossibleResourceMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m PossibleResourceMultiError) AllErrors() []error { return m } + +// PossibleResourceValidationError is the validation error returned by +// PossibleResource.Validate if the designated constraints aren't met. +type PossibleResourceValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e PossibleResourceValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e PossibleResourceValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e PossibleResourceValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e PossibleResourceValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e PossibleResourceValidationError) ErrorName() string { return "PossibleResourceValidationError" } + +// Error satisfies the builtin error interface +func (e PossibleResourceValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sPossibleResource.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = PossibleResourceValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = PossibleResourceValidationError{} + +// Validate checks the field values on DispatchLookupResources2Response with +// the rules defined in the proto definition for this message. If any rules +// are violated, the first error encountered is returned, or nil if there are +// no violations. +func (m *DispatchLookupResources2Response) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on DispatchLookupResources2Response with +// the rules defined in the proto definition for this message. If any rules +// are violated, the result is a list of violation errors wrapped in +// DispatchLookupResources2ResponseMultiError, or nil if none found. +func (m *DispatchLookupResources2Response) ValidateAll() error { + return m.validate(true) +} + +func (m *DispatchLookupResources2Response) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetResource()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, DispatchLookupResources2ResponseValidationError{ + field: "Resource", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, DispatchLookupResources2ResponseValidationError{ + field: "Resource", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetResource()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return DispatchLookupResources2ResponseValidationError{ + field: "Resource", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if all { + switch v := interface{}(m.GetMetadata()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, DispatchLookupResources2ResponseValidationError{ + field: "Metadata", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, DispatchLookupResources2ResponseValidationError{ + field: "Metadata", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetMetadata()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return DispatchLookupResources2ResponseValidationError{ + field: "Metadata", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if all { + switch v := interface{}(m.GetAfterResponseCursor()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, DispatchLookupResources2ResponseValidationError{ + field: "AfterResponseCursor", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, DispatchLookupResources2ResponseValidationError{ + field: "AfterResponseCursor", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetAfterResponseCursor()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return DispatchLookupResources2ResponseValidationError{ + field: "AfterResponseCursor", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return DispatchLookupResources2ResponseMultiError(errors) + } + + return nil +} + +// DispatchLookupResources2ResponseMultiError is an error wrapping multiple +// validation errors returned by +// DispatchLookupResources2Response.ValidateAll() if the designated +// constraints aren't met. +type DispatchLookupResources2ResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m DispatchLookupResources2ResponseMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m DispatchLookupResources2ResponseMultiError) AllErrors() []error { return m } + +// DispatchLookupResources2ResponseValidationError is the validation error +// returned by DispatchLookupResources2Response.Validate if the designated +// constraints aren't met. +type DispatchLookupResources2ResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e DispatchLookupResources2ResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e DispatchLookupResources2ResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e DispatchLookupResources2ResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e DispatchLookupResources2ResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e DispatchLookupResources2ResponseValidationError) ErrorName() string { + return "DispatchLookupResources2ResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e DispatchLookupResources2ResponseValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sDispatchLookupResources2Response.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = DispatchLookupResources2ResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = DispatchLookupResources2ResponseValidationError{} + +// Validate checks the field values on DispatchLookupSubjectsRequest with the +// rules defined in the proto definition for this message. If any rules are +// violated, the first error encountered is returned, or nil if there are no violations. +func (m *DispatchLookupSubjectsRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on DispatchLookupSubjectsRequest with +// the rules defined in the proto definition for this message. If any rules +// are violated, the result is a list of violation errors wrapped in +// DispatchLookupSubjectsRequestMultiError, or nil if none found. +func (m *DispatchLookupSubjectsRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *DispatchLookupSubjectsRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if m.GetMetadata() == nil { + err := DispatchLookupSubjectsRequestValidationError{ + field: "Metadata", + reason: "value is required", + } + if !all { + return err + } + errors = append(errors, err) + } + + if all { + switch v := interface{}(m.GetMetadata()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, DispatchLookupSubjectsRequestValidationError{ + field: "Metadata", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, DispatchLookupSubjectsRequestValidationError{ + field: "Metadata", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetMetadata()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return DispatchLookupSubjectsRequestValidationError{ + field: "Metadata", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if m.GetResourceRelation() == nil { + err := DispatchLookupSubjectsRequestValidationError{ + field: "ResourceRelation", + reason: "value is required", + } + if !all { + return err + } + errors = append(errors, err) + } + + if all { + switch v := interface{}(m.GetResourceRelation()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, DispatchLookupSubjectsRequestValidationError{ + field: "ResourceRelation", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, DispatchLookupSubjectsRequestValidationError{ + field: "ResourceRelation", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetResourceRelation()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return DispatchLookupSubjectsRequestValidationError{ + field: "ResourceRelation", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if m.GetSubjectRelation() == nil { + err := DispatchLookupSubjectsRequestValidationError{ + field: "SubjectRelation", + reason: "value is required", + } + if !all { + return err + } + errors = append(errors, err) + } + + if all { + switch v := interface{}(m.GetSubjectRelation()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, DispatchLookupSubjectsRequestValidationError{ + field: "SubjectRelation", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, DispatchLookupSubjectsRequestValidationError{ + field: "SubjectRelation", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetSubjectRelation()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return DispatchLookupSubjectsRequestValidationError{ + field: "SubjectRelation", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return DispatchLookupSubjectsRequestMultiError(errors) + } + + return nil +} + +// DispatchLookupSubjectsRequestMultiError is an error wrapping multiple +// validation errors returned by DispatchLookupSubjectsRequest.ValidateAll() +// if the designated constraints aren't met. +type DispatchLookupSubjectsRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m DispatchLookupSubjectsRequestMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m DispatchLookupSubjectsRequestMultiError) AllErrors() []error { return m } + +// DispatchLookupSubjectsRequestValidationError is the validation error +// returned by DispatchLookupSubjectsRequest.Validate if the designated +// constraints aren't met. +type DispatchLookupSubjectsRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e DispatchLookupSubjectsRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e DispatchLookupSubjectsRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e DispatchLookupSubjectsRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e DispatchLookupSubjectsRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e DispatchLookupSubjectsRequestValidationError) ErrorName() string { + return "DispatchLookupSubjectsRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e DispatchLookupSubjectsRequestValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sDispatchLookupSubjectsRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = DispatchLookupSubjectsRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = DispatchLookupSubjectsRequestValidationError{} + +// Validate checks the field values on FoundSubject with the rules defined in +// the proto definition for this message. If any rules are violated, the first +// error encountered is returned, or nil if there are no violations. +func (m *FoundSubject) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on FoundSubject with the rules defined +// in the proto definition for this message. If any rules are violated, the +// result is a list of violation errors wrapped in FoundSubjectMultiError, or +// nil if none found. +func (m *FoundSubject) ValidateAll() error { + return m.validate(true) +} + +func (m *FoundSubject) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for SubjectId + + if all { + switch v := interface{}(m.GetCaveatExpression()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, FoundSubjectValidationError{ + field: "CaveatExpression", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, FoundSubjectValidationError{ + field: "CaveatExpression", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetCaveatExpression()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return FoundSubjectValidationError{ + field: "CaveatExpression", + reason: "embedded message failed validation", + cause: err, + } + } + } + + for idx, item := range m.GetExcludedSubjects() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, FoundSubjectValidationError{ + field: fmt.Sprintf("ExcludedSubjects[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, FoundSubjectValidationError{ + field: fmt.Sprintf("ExcludedSubjects[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return FoundSubjectValidationError{ + field: fmt.Sprintf("ExcludedSubjects[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + if len(errors) > 0 { + return FoundSubjectMultiError(errors) + } + + return nil +} + +// FoundSubjectMultiError is an error wrapping multiple validation errors +// returned by FoundSubject.ValidateAll() if the designated constraints aren't met. +type FoundSubjectMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m FoundSubjectMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m FoundSubjectMultiError) AllErrors() []error { return m } + +// FoundSubjectValidationError is the validation error returned by +// FoundSubject.Validate if the designated constraints aren't met. +type FoundSubjectValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e FoundSubjectValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e FoundSubjectValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e FoundSubjectValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e FoundSubjectValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e FoundSubjectValidationError) ErrorName() string { return "FoundSubjectValidationError" } + +// Error satisfies the builtin error interface +func (e FoundSubjectValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sFoundSubject.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = FoundSubjectValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = FoundSubjectValidationError{} + +// Validate checks the field values on FoundSubjects with the rules defined in +// the proto definition for this message. If any rules are violated, the first +// error encountered is returned, or nil if there are no violations. +func (m *FoundSubjects) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on FoundSubjects with the rules defined +// in the proto definition for this message. If any rules are violated, the +// result is a list of violation errors wrapped in FoundSubjectsMultiError, or +// nil if none found. +func (m *FoundSubjects) ValidateAll() error { + return m.validate(true) +} + +func (m *FoundSubjects) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + for idx, item := range m.GetFoundSubjects() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, FoundSubjectsValidationError{ + field: fmt.Sprintf("FoundSubjects[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, FoundSubjectsValidationError{ + field: fmt.Sprintf("FoundSubjects[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return FoundSubjectsValidationError{ + field: fmt.Sprintf("FoundSubjects[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + if len(errors) > 0 { + return FoundSubjectsMultiError(errors) + } + + return nil +} + +// FoundSubjectsMultiError is an error wrapping multiple validation errors +// returned by FoundSubjects.ValidateAll() if the designated constraints +// aren't met. +type FoundSubjectsMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m FoundSubjectsMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m FoundSubjectsMultiError) AllErrors() []error { return m } + +// FoundSubjectsValidationError is the validation error returned by +// FoundSubjects.Validate if the designated constraints aren't met. +type FoundSubjectsValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e FoundSubjectsValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e FoundSubjectsValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e FoundSubjectsValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e FoundSubjectsValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e FoundSubjectsValidationError) ErrorName() string { return "FoundSubjectsValidationError" } + +// Error satisfies the builtin error interface +func (e FoundSubjectsValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sFoundSubjects.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = FoundSubjectsValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = FoundSubjectsValidationError{} + +// Validate checks the field values on DispatchLookupSubjectsResponse with the +// rules defined in the proto definition for this message. If any rules are +// violated, the first error encountered is returned, or nil if there are no violations. +func (m *DispatchLookupSubjectsResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on DispatchLookupSubjectsResponse with +// the rules defined in the proto definition for this message. If any rules +// are violated, the result is a list of violation errors wrapped in +// DispatchLookupSubjectsResponseMultiError, or nil if none found. +func (m *DispatchLookupSubjectsResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *DispatchLookupSubjectsResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + { + sorted_keys := make([]string, len(m.GetFoundSubjectsByResourceId())) + i := 0 + for key := range m.GetFoundSubjectsByResourceId() { + sorted_keys[i] = key + i++ + } + sort.Slice(sorted_keys, func(i, j int) bool { return sorted_keys[i] < sorted_keys[j] }) + for _, key := range sorted_keys { + val := m.GetFoundSubjectsByResourceId()[key] + _ = val + + // no validation rules for FoundSubjectsByResourceId[key] + + if all { + switch v := interface{}(val).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, DispatchLookupSubjectsResponseValidationError{ + field: fmt.Sprintf("FoundSubjectsByResourceId[%v]", key), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, DispatchLookupSubjectsResponseValidationError{ + field: fmt.Sprintf("FoundSubjectsByResourceId[%v]", key), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(val).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return DispatchLookupSubjectsResponseValidationError{ + field: fmt.Sprintf("FoundSubjectsByResourceId[%v]", key), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + } + + if all { + switch v := interface{}(m.GetMetadata()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, DispatchLookupSubjectsResponseValidationError{ + field: "Metadata", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, DispatchLookupSubjectsResponseValidationError{ + field: "Metadata", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetMetadata()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return DispatchLookupSubjectsResponseValidationError{ + field: "Metadata", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return DispatchLookupSubjectsResponseMultiError(errors) + } + + return nil +} + +// DispatchLookupSubjectsResponseMultiError is an error wrapping multiple +// validation errors returned by DispatchLookupSubjectsResponse.ValidateAll() +// if the designated constraints aren't met. +type DispatchLookupSubjectsResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m DispatchLookupSubjectsResponseMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m DispatchLookupSubjectsResponseMultiError) AllErrors() []error { return m } + +// DispatchLookupSubjectsResponseValidationError is the validation error +// returned by DispatchLookupSubjectsResponse.Validate if the designated +// constraints aren't met. +type DispatchLookupSubjectsResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e DispatchLookupSubjectsResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e DispatchLookupSubjectsResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e DispatchLookupSubjectsResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e DispatchLookupSubjectsResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e DispatchLookupSubjectsResponseValidationError) ErrorName() string { + return "DispatchLookupSubjectsResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e DispatchLookupSubjectsResponseValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sDispatchLookupSubjectsResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = DispatchLookupSubjectsResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = DispatchLookupSubjectsResponseValidationError{} + +// Validate checks the field values on ResolverMeta with the rules defined in +// the proto definition for this message. If any rules are violated, the first +// error encountered is returned, or nil if there are no violations. +func (m *ResolverMeta) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on ResolverMeta with the rules defined +// in the proto definition for this message. If any rules are violated, the +// result is a list of violation errors wrapped in ResolverMetaMultiError, or +// nil if none found. +func (m *ResolverMeta) ValidateAll() error { + return m.validate(true) +} + +func (m *ResolverMeta) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for AtRevision + + if m.GetDepthRemaining() <= 0 { + err := ResolverMetaValidationError{ + field: "DepthRemaining", + reason: "value must be greater than 0", + } + if !all { + return err + } + errors = append(errors, err) + } + + // no validation rules for RequestId + + if len(m.GetTraversalBloom()) > 1024 { + err := ResolverMetaValidationError{ + field: "TraversalBloom", + reason: "value length must be at most 1024 bytes", + } + if !all { + return err + } + errors = append(errors, err) + } + + if len(errors) > 0 { + return ResolverMetaMultiError(errors) + } + + return nil +} + +// ResolverMetaMultiError is an error wrapping multiple validation errors +// returned by ResolverMeta.ValidateAll() if the designated constraints aren't met. +type ResolverMetaMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ResolverMetaMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m ResolverMetaMultiError) AllErrors() []error { return m } + +// ResolverMetaValidationError is the validation error returned by +// ResolverMeta.Validate if the designated constraints aren't met. +type ResolverMetaValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e ResolverMetaValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e ResolverMetaValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e ResolverMetaValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e ResolverMetaValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e ResolverMetaValidationError) ErrorName() string { return "ResolverMetaValidationError" } + +// Error satisfies the builtin error interface +func (e ResolverMetaValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sResolverMeta.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = ResolverMetaValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = ResolverMetaValidationError{} + +// Validate checks the field values on ResponseMeta with the rules defined in +// the proto definition for this message. If any rules are violated, the first +// error encountered is returned, or nil if there are no violations. +func (m *ResponseMeta) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on ResponseMeta with the rules defined +// in the proto definition for this message. If any rules are violated, the +// result is a list of violation errors wrapped in ResponseMetaMultiError, or +// nil if none found. +func (m *ResponseMeta) ValidateAll() error { + return m.validate(true) +} + +func (m *ResponseMeta) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for DispatchCount + + // no validation rules for DepthRequired + + // no validation rules for CachedDispatchCount + + if all { + switch v := interface{}(m.GetDebugInfo()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, ResponseMetaValidationError{ + field: "DebugInfo", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, ResponseMetaValidationError{ + field: "DebugInfo", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetDebugInfo()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return ResponseMetaValidationError{ + field: "DebugInfo", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return ResponseMetaMultiError(errors) + } + + return nil +} + +// ResponseMetaMultiError is an error wrapping multiple validation errors +// returned by ResponseMeta.ValidateAll() if the designated constraints aren't met. +type ResponseMetaMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ResponseMetaMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m ResponseMetaMultiError) AllErrors() []error { return m } + +// ResponseMetaValidationError is the validation error returned by +// ResponseMeta.Validate if the designated constraints aren't met. +type ResponseMetaValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e ResponseMetaValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e ResponseMetaValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e ResponseMetaValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e ResponseMetaValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e ResponseMetaValidationError) ErrorName() string { return "ResponseMetaValidationError" } + +// Error satisfies the builtin error interface +func (e ResponseMetaValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sResponseMeta.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = ResponseMetaValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = ResponseMetaValidationError{} + +// Validate checks the field values on DebugInformation with the rules defined +// in the proto definition for this message. If any rules are violated, the +// first error encountered is returned, or nil if there are no violations. +func (m *DebugInformation) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on DebugInformation with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// DebugInformationMultiError, or nil if none found. +func (m *DebugInformation) ValidateAll() error { + return m.validate(true) +} + +func (m *DebugInformation) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetCheck()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, DebugInformationValidationError{ + field: "Check", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, DebugInformationValidationError{ + field: "Check", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetCheck()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return DebugInformationValidationError{ + field: "Check", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return DebugInformationMultiError(errors) + } + + return nil +} + +// DebugInformationMultiError is an error wrapping multiple validation errors +// returned by DebugInformation.ValidateAll() if the designated constraints +// aren't met. +type DebugInformationMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m DebugInformationMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m DebugInformationMultiError) AllErrors() []error { return m } + +// DebugInformationValidationError is the validation error returned by +// DebugInformation.Validate if the designated constraints aren't met. +type DebugInformationValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e DebugInformationValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e DebugInformationValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e DebugInformationValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e DebugInformationValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e DebugInformationValidationError) ErrorName() string { return "DebugInformationValidationError" } + +// Error satisfies the builtin error interface +func (e DebugInformationValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sDebugInformation.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = DebugInformationValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = DebugInformationValidationError{} + +// Validate checks the field values on CheckDebugTrace with the rules defined +// in the proto definition for this message. If any rules are violated, the +// first error encountered is returned, or nil if there are no violations. +func (m *CheckDebugTrace) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on CheckDebugTrace with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// CheckDebugTraceMultiError, or nil if none found. +func (m *CheckDebugTrace) ValidateAll() error { + return m.validate(true) +} + +func (m *CheckDebugTrace) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetRequest()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, CheckDebugTraceValidationError{ + field: "Request", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, CheckDebugTraceValidationError{ + field: "Request", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetRequest()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return CheckDebugTraceValidationError{ + field: "Request", + reason: "embedded message failed validation", + cause: err, + } + } + } + + // no validation rules for ResourceRelationType + + { + sorted_keys := make([]string, len(m.GetResults())) + i := 0 + for key := range m.GetResults() { + sorted_keys[i] = key + i++ + } + sort.Slice(sorted_keys, func(i, j int) bool { return sorted_keys[i] < sorted_keys[j] }) + for _, key := range sorted_keys { + val := m.GetResults()[key] + _ = val + + // no validation rules for Results[key] + + if all { + switch v := interface{}(val).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, CheckDebugTraceValidationError{ + field: fmt.Sprintf("Results[%v]", key), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, CheckDebugTraceValidationError{ + field: fmt.Sprintf("Results[%v]", key), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(val).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return CheckDebugTraceValidationError{ + field: fmt.Sprintf("Results[%v]", key), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + } + + // no validation rules for IsCachedResult + + for idx, item := range m.GetSubProblems() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, CheckDebugTraceValidationError{ + field: fmt.Sprintf("SubProblems[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, CheckDebugTraceValidationError{ + field: fmt.Sprintf("SubProblems[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return CheckDebugTraceValidationError{ + field: fmt.Sprintf("SubProblems[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + if all { + switch v := interface{}(m.GetDuration()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, CheckDebugTraceValidationError{ + field: "Duration", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, CheckDebugTraceValidationError{ + field: "Duration", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetDuration()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return CheckDebugTraceValidationError{ + field: "Duration", + reason: "embedded message failed validation", + cause: err, + } + } + } + + // no validation rules for TraceId + + // no validation rules for SourceId + + if len(errors) > 0 { + return CheckDebugTraceMultiError(errors) + } + + return nil +} + +// CheckDebugTraceMultiError is an error wrapping multiple validation errors +// returned by CheckDebugTrace.ValidateAll() if the designated constraints +// aren't met. +type CheckDebugTraceMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m CheckDebugTraceMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m CheckDebugTraceMultiError) AllErrors() []error { return m } + +// CheckDebugTraceValidationError is the validation error returned by +// CheckDebugTrace.Validate if the designated constraints aren't met. +type CheckDebugTraceValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e CheckDebugTraceValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e CheckDebugTraceValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e CheckDebugTraceValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e CheckDebugTraceValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e CheckDebugTraceValidationError) ErrorName() string { return "CheckDebugTraceValidationError" } + +// Error satisfies the builtin error interface +func (e CheckDebugTraceValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sCheckDebugTrace.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = CheckDebugTraceValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = CheckDebugTraceValidationError{} diff --git a/vendor/github.com/authzed/spicedb/pkg/proto/dispatch/v1/dispatch_grpc.pb.go b/vendor/github.com/authzed/spicedb/pkg/proto/dispatch/v1/dispatch_grpc.pb.go new file mode 100644 index 0000000..70e30cf --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/proto/dispatch/v1/dispatch_grpc.pb.go @@ -0,0 +1,275 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.3.0 +// - protoc (unknown) +// source: dispatch/v1/dispatch.proto + +package dispatchv1 + +import ( + context "context" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.32.0 or later. +const _ = grpc.SupportPackageIsVersion7 + +const ( + DispatchService_DispatchCheck_FullMethodName = "/dispatch.v1.DispatchService/DispatchCheck" + DispatchService_DispatchExpand_FullMethodName = "/dispatch.v1.DispatchService/DispatchExpand" + DispatchService_DispatchLookupSubjects_FullMethodName = "/dispatch.v1.DispatchService/DispatchLookupSubjects" + DispatchService_DispatchLookupResources2_FullMethodName = "/dispatch.v1.DispatchService/DispatchLookupResources2" +) + +// DispatchServiceClient is the client API for DispatchService service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +type DispatchServiceClient interface { + DispatchCheck(ctx context.Context, in *DispatchCheckRequest, opts ...grpc.CallOption) (*DispatchCheckResponse, error) + DispatchExpand(ctx context.Context, in *DispatchExpandRequest, opts ...grpc.CallOption) (*DispatchExpandResponse, error) + DispatchLookupSubjects(ctx context.Context, in *DispatchLookupSubjectsRequest, opts ...grpc.CallOption) (DispatchService_DispatchLookupSubjectsClient, error) + DispatchLookupResources2(ctx context.Context, in *DispatchLookupResources2Request, opts ...grpc.CallOption) (DispatchService_DispatchLookupResources2Client, error) +} + +type dispatchServiceClient struct { + cc grpc.ClientConnInterface +} + +func NewDispatchServiceClient(cc grpc.ClientConnInterface) DispatchServiceClient { + return &dispatchServiceClient{cc} +} + +func (c *dispatchServiceClient) DispatchCheck(ctx context.Context, in *DispatchCheckRequest, opts ...grpc.CallOption) (*DispatchCheckResponse, error) { + out := new(DispatchCheckResponse) + err := c.cc.Invoke(ctx, DispatchService_DispatchCheck_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *dispatchServiceClient) DispatchExpand(ctx context.Context, in *DispatchExpandRequest, opts ...grpc.CallOption) (*DispatchExpandResponse, error) { + out := new(DispatchExpandResponse) + err := c.cc.Invoke(ctx, DispatchService_DispatchExpand_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *dispatchServiceClient) DispatchLookupSubjects(ctx context.Context, in *DispatchLookupSubjectsRequest, opts ...grpc.CallOption) (DispatchService_DispatchLookupSubjectsClient, error) { + stream, err := c.cc.NewStream(ctx, &DispatchService_ServiceDesc.Streams[0], DispatchService_DispatchLookupSubjects_FullMethodName, opts...) + if err != nil { + return nil, err + } + x := &dispatchServiceDispatchLookupSubjectsClient{stream} + if err := x.ClientStream.SendMsg(in); err != nil { + return nil, err + } + if err := x.ClientStream.CloseSend(); err != nil { + return nil, err + } + return x, nil +} + +type DispatchService_DispatchLookupSubjectsClient interface { + Recv() (*DispatchLookupSubjectsResponse, error) + grpc.ClientStream +} + +type dispatchServiceDispatchLookupSubjectsClient struct { + grpc.ClientStream +} + +func (x *dispatchServiceDispatchLookupSubjectsClient) Recv() (*DispatchLookupSubjectsResponse, error) { + m := new(DispatchLookupSubjectsResponse) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +func (c *dispatchServiceClient) DispatchLookupResources2(ctx context.Context, in *DispatchLookupResources2Request, opts ...grpc.CallOption) (DispatchService_DispatchLookupResources2Client, error) { + stream, err := c.cc.NewStream(ctx, &DispatchService_ServiceDesc.Streams[1], DispatchService_DispatchLookupResources2_FullMethodName, opts...) + if err != nil { + return nil, err + } + x := &dispatchServiceDispatchLookupResources2Client{stream} + if err := x.ClientStream.SendMsg(in); err != nil { + return nil, err + } + if err := x.ClientStream.CloseSend(); err != nil { + return nil, err + } + return x, nil +} + +type DispatchService_DispatchLookupResources2Client interface { + Recv() (*DispatchLookupResources2Response, error) + grpc.ClientStream +} + +type dispatchServiceDispatchLookupResources2Client struct { + grpc.ClientStream +} + +func (x *dispatchServiceDispatchLookupResources2Client) Recv() (*DispatchLookupResources2Response, error) { + m := new(DispatchLookupResources2Response) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +// DispatchServiceServer is the server API for DispatchService service. +// All implementations must embed UnimplementedDispatchServiceServer +// for forward compatibility +type DispatchServiceServer interface { + DispatchCheck(context.Context, *DispatchCheckRequest) (*DispatchCheckResponse, error) + DispatchExpand(context.Context, *DispatchExpandRequest) (*DispatchExpandResponse, error) + DispatchLookupSubjects(*DispatchLookupSubjectsRequest, DispatchService_DispatchLookupSubjectsServer) error + DispatchLookupResources2(*DispatchLookupResources2Request, DispatchService_DispatchLookupResources2Server) error + mustEmbedUnimplementedDispatchServiceServer() +} + +// UnimplementedDispatchServiceServer must be embedded to have forward compatible implementations. +type UnimplementedDispatchServiceServer struct { +} + +func (UnimplementedDispatchServiceServer) DispatchCheck(context.Context, *DispatchCheckRequest) (*DispatchCheckResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method DispatchCheck not implemented") +} +func (UnimplementedDispatchServiceServer) DispatchExpand(context.Context, *DispatchExpandRequest) (*DispatchExpandResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method DispatchExpand not implemented") +} +func (UnimplementedDispatchServiceServer) DispatchLookupSubjects(*DispatchLookupSubjectsRequest, DispatchService_DispatchLookupSubjectsServer) error { + return status.Errorf(codes.Unimplemented, "method DispatchLookupSubjects not implemented") +} +func (UnimplementedDispatchServiceServer) DispatchLookupResources2(*DispatchLookupResources2Request, DispatchService_DispatchLookupResources2Server) error { + return status.Errorf(codes.Unimplemented, "method DispatchLookupResources2 not implemented") +} +func (UnimplementedDispatchServiceServer) mustEmbedUnimplementedDispatchServiceServer() {} + +// UnsafeDispatchServiceServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to DispatchServiceServer will +// result in compilation errors. +type UnsafeDispatchServiceServer interface { + mustEmbedUnimplementedDispatchServiceServer() +} + +func RegisterDispatchServiceServer(s grpc.ServiceRegistrar, srv DispatchServiceServer) { + s.RegisterService(&DispatchService_ServiceDesc, srv) +} + +func _DispatchService_DispatchCheck_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(DispatchCheckRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(DispatchServiceServer).DispatchCheck(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: DispatchService_DispatchCheck_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(DispatchServiceServer).DispatchCheck(ctx, req.(*DispatchCheckRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _DispatchService_DispatchExpand_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(DispatchExpandRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(DispatchServiceServer).DispatchExpand(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: DispatchService_DispatchExpand_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(DispatchServiceServer).DispatchExpand(ctx, req.(*DispatchExpandRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _DispatchService_DispatchLookupSubjects_Handler(srv interface{}, stream grpc.ServerStream) error { + m := new(DispatchLookupSubjectsRequest) + if err := stream.RecvMsg(m); err != nil { + return err + } + return srv.(DispatchServiceServer).DispatchLookupSubjects(m, &dispatchServiceDispatchLookupSubjectsServer{stream}) +} + +type DispatchService_DispatchLookupSubjectsServer interface { + Send(*DispatchLookupSubjectsResponse) error + grpc.ServerStream +} + +type dispatchServiceDispatchLookupSubjectsServer struct { + grpc.ServerStream +} + +func (x *dispatchServiceDispatchLookupSubjectsServer) Send(m *DispatchLookupSubjectsResponse) error { + return x.ServerStream.SendMsg(m) +} + +func _DispatchService_DispatchLookupResources2_Handler(srv interface{}, stream grpc.ServerStream) error { + m := new(DispatchLookupResources2Request) + if err := stream.RecvMsg(m); err != nil { + return err + } + return srv.(DispatchServiceServer).DispatchLookupResources2(m, &dispatchServiceDispatchLookupResources2Server{stream}) +} + +type DispatchService_DispatchLookupResources2Server interface { + Send(*DispatchLookupResources2Response) error + grpc.ServerStream +} + +type dispatchServiceDispatchLookupResources2Server struct { + grpc.ServerStream +} + +func (x *dispatchServiceDispatchLookupResources2Server) Send(m *DispatchLookupResources2Response) error { + return x.ServerStream.SendMsg(m) +} + +// DispatchService_ServiceDesc is the grpc.ServiceDesc for DispatchService service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var DispatchService_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "dispatch.v1.DispatchService", + HandlerType: (*DispatchServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "DispatchCheck", + Handler: _DispatchService_DispatchCheck_Handler, + }, + { + MethodName: "DispatchExpand", + Handler: _DispatchService_DispatchExpand_Handler, + }, + }, + Streams: []grpc.StreamDesc{ + { + StreamName: "DispatchLookupSubjects", + Handler: _DispatchService_DispatchLookupSubjects_Handler, + ServerStreams: true, + }, + { + StreamName: "DispatchLookupResources2", + Handler: _DispatchService_DispatchLookupResources2_Handler, + ServerStreams: true, + }, + }, + Metadata: "dispatch/v1/dispatch.proto", +} diff --git a/vendor/github.com/authzed/spicedb/pkg/proto/dispatch/v1/dispatch_vtproto.pb.go b/vendor/github.com/authzed/spicedb/pkg/proto/dispatch/v1/dispatch_vtproto.pb.go new file mode 100644 index 0000000..5a2cdac --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/proto/dispatch/v1/dispatch_vtproto.pb.go @@ -0,0 +1,6474 @@ +// Code generated by protoc-gen-go-vtproto. DO NOT EDIT. +// protoc-gen-go-vtproto version: v0.6.1-0.20240409071808-615f978279ca +// source: dispatch/v1/dispatch.proto + +package dispatchv1 + +import ( + fmt "fmt" + v1 "github.com/authzed/spicedb/pkg/proto/core/v1" + protohelpers "github.com/planetscale/vtprotobuf/protohelpers" + durationpb1 "github.com/planetscale/vtprotobuf/types/known/durationpb" + structpb1 "github.com/planetscale/vtprotobuf/types/known/structpb" + proto "google.golang.org/protobuf/proto" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + durationpb "google.golang.org/protobuf/types/known/durationpb" + structpb "google.golang.org/protobuf/types/known/structpb" + io "io" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +func (m *DispatchCheckRequest) CloneVT() *DispatchCheckRequest { + if m == nil { + return (*DispatchCheckRequest)(nil) + } + r := new(DispatchCheckRequest) + r.Metadata = m.Metadata.CloneVT() + r.ResultsSetting = m.ResultsSetting + r.Debug = m.Debug + if rhs := m.ResourceRelation; rhs != nil { + if vtpb, ok := interface{}(rhs).(interface{ CloneVT() *v1.RelationReference }); ok { + r.ResourceRelation = vtpb.CloneVT() + } else { + r.ResourceRelation = proto.Clone(rhs).(*v1.RelationReference) + } + } + if rhs := m.ResourceIds; rhs != nil { + tmpContainer := make([]string, len(rhs)) + copy(tmpContainer, rhs) + r.ResourceIds = tmpContainer + } + if rhs := m.Subject; rhs != nil { + if vtpb, ok := interface{}(rhs).(interface{ CloneVT() *v1.ObjectAndRelation }); ok { + r.Subject = vtpb.CloneVT() + } else { + r.Subject = proto.Clone(rhs).(*v1.ObjectAndRelation) + } + } + if rhs := m.CheckHints; rhs != nil { + tmpContainer := make([]*CheckHint, len(rhs)) + for k, v := range rhs { + tmpContainer[k] = v.CloneVT() + } + r.CheckHints = tmpContainer + } + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *DispatchCheckRequest) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *CheckHint) CloneVT() *CheckHint { + if m == nil { + return (*CheckHint)(nil) + } + r := new(CheckHint) + r.TtuComputedUsersetRelation = m.TtuComputedUsersetRelation + r.Result = m.Result.CloneVT() + if rhs := m.Resource; rhs != nil { + if vtpb, ok := interface{}(rhs).(interface{ CloneVT() *v1.ObjectAndRelation }); ok { + r.Resource = vtpb.CloneVT() + } else { + r.Resource = proto.Clone(rhs).(*v1.ObjectAndRelation) + } + } + if rhs := m.Subject; rhs != nil { + if vtpb, ok := interface{}(rhs).(interface{ CloneVT() *v1.ObjectAndRelation }); ok { + r.Subject = vtpb.CloneVT() + } else { + r.Subject = proto.Clone(rhs).(*v1.ObjectAndRelation) + } + } + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *CheckHint) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *DispatchCheckResponse) CloneVT() *DispatchCheckResponse { + if m == nil { + return (*DispatchCheckResponse)(nil) + } + r := new(DispatchCheckResponse) + r.Metadata = m.Metadata.CloneVT() + if rhs := m.ResultsByResourceId; rhs != nil { + tmpContainer := make(map[string]*ResourceCheckResult, len(rhs)) + for k, v := range rhs { + tmpContainer[k] = v.CloneVT() + } + r.ResultsByResourceId = tmpContainer + } + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *DispatchCheckResponse) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *ResourceCheckResult) CloneVT() *ResourceCheckResult { + if m == nil { + return (*ResourceCheckResult)(nil) + } + r := new(ResourceCheckResult) + r.Membership = m.Membership + if rhs := m.Expression; rhs != nil { + if vtpb, ok := interface{}(rhs).(interface{ CloneVT() *v1.CaveatExpression }); ok { + r.Expression = vtpb.CloneVT() + } else { + r.Expression = proto.Clone(rhs).(*v1.CaveatExpression) + } + } + if rhs := m.MissingExprFields; rhs != nil { + tmpContainer := make([]string, len(rhs)) + copy(tmpContainer, rhs) + r.MissingExprFields = tmpContainer + } + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *ResourceCheckResult) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *DispatchExpandRequest) CloneVT() *DispatchExpandRequest { + if m == nil { + return (*DispatchExpandRequest)(nil) + } + r := new(DispatchExpandRequest) + r.Metadata = m.Metadata.CloneVT() + r.ExpansionMode = m.ExpansionMode + if rhs := m.ResourceAndRelation; rhs != nil { + if vtpb, ok := interface{}(rhs).(interface{ CloneVT() *v1.ObjectAndRelation }); ok { + r.ResourceAndRelation = vtpb.CloneVT() + } else { + r.ResourceAndRelation = proto.Clone(rhs).(*v1.ObjectAndRelation) + } + } + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *DispatchExpandRequest) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *DispatchExpandResponse) CloneVT() *DispatchExpandResponse { + if m == nil { + return (*DispatchExpandResponse)(nil) + } + r := new(DispatchExpandResponse) + r.Metadata = m.Metadata.CloneVT() + if rhs := m.TreeNode; rhs != nil { + if vtpb, ok := interface{}(rhs).(interface { + CloneVT() *v1.RelationTupleTreeNode + }); ok { + r.TreeNode = vtpb.CloneVT() + } else { + r.TreeNode = proto.Clone(rhs).(*v1.RelationTupleTreeNode) + } + } + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *DispatchExpandResponse) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *Cursor) CloneVT() *Cursor { + if m == nil { + return (*Cursor)(nil) + } + r := new(Cursor) + r.DispatchVersion = m.DispatchVersion + if rhs := m.Sections; rhs != nil { + tmpContainer := make([]string, len(rhs)) + copy(tmpContainer, rhs) + r.Sections = tmpContainer + } + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *Cursor) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *DispatchLookupResources2Request) CloneVT() *DispatchLookupResources2Request { + if m == nil { + return (*DispatchLookupResources2Request)(nil) + } + r := new(DispatchLookupResources2Request) + r.Metadata = m.Metadata.CloneVT() + r.Context = (*structpb.Struct)((*structpb1.Struct)(m.Context).CloneVT()) + r.OptionalCursor = m.OptionalCursor.CloneVT() + r.OptionalLimit = m.OptionalLimit + if rhs := m.ResourceRelation; rhs != nil { + if vtpb, ok := interface{}(rhs).(interface{ CloneVT() *v1.RelationReference }); ok { + r.ResourceRelation = vtpb.CloneVT() + } else { + r.ResourceRelation = proto.Clone(rhs).(*v1.RelationReference) + } + } + if rhs := m.SubjectRelation; rhs != nil { + if vtpb, ok := interface{}(rhs).(interface{ CloneVT() *v1.RelationReference }); ok { + r.SubjectRelation = vtpb.CloneVT() + } else { + r.SubjectRelation = proto.Clone(rhs).(*v1.RelationReference) + } + } + if rhs := m.SubjectIds; rhs != nil { + tmpContainer := make([]string, len(rhs)) + copy(tmpContainer, rhs) + r.SubjectIds = tmpContainer + } + if rhs := m.TerminalSubject; rhs != nil { + if vtpb, ok := interface{}(rhs).(interface{ CloneVT() *v1.ObjectAndRelation }); ok { + r.TerminalSubject = vtpb.CloneVT() + } else { + r.TerminalSubject = proto.Clone(rhs).(*v1.ObjectAndRelation) + } + } + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *DispatchLookupResources2Request) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *PossibleResource) CloneVT() *PossibleResource { + if m == nil { + return (*PossibleResource)(nil) + } + r := new(PossibleResource) + r.ResourceId = m.ResourceId + if rhs := m.ForSubjectIds; rhs != nil { + tmpContainer := make([]string, len(rhs)) + copy(tmpContainer, rhs) + r.ForSubjectIds = tmpContainer + } + if rhs := m.MissingContextParams; rhs != nil { + tmpContainer := make([]string, len(rhs)) + copy(tmpContainer, rhs) + r.MissingContextParams = tmpContainer + } + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *PossibleResource) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *DispatchLookupResources2Response) CloneVT() *DispatchLookupResources2Response { + if m == nil { + return (*DispatchLookupResources2Response)(nil) + } + r := new(DispatchLookupResources2Response) + r.Resource = m.Resource.CloneVT() + r.Metadata = m.Metadata.CloneVT() + r.AfterResponseCursor = m.AfterResponseCursor.CloneVT() + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *DispatchLookupResources2Response) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *DispatchLookupSubjectsRequest) CloneVT() *DispatchLookupSubjectsRequest { + if m == nil { + return (*DispatchLookupSubjectsRequest)(nil) + } + r := new(DispatchLookupSubjectsRequest) + r.Metadata = m.Metadata.CloneVT() + if rhs := m.ResourceRelation; rhs != nil { + if vtpb, ok := interface{}(rhs).(interface{ CloneVT() *v1.RelationReference }); ok { + r.ResourceRelation = vtpb.CloneVT() + } else { + r.ResourceRelation = proto.Clone(rhs).(*v1.RelationReference) + } + } + if rhs := m.ResourceIds; rhs != nil { + tmpContainer := make([]string, len(rhs)) + copy(tmpContainer, rhs) + r.ResourceIds = tmpContainer + } + if rhs := m.SubjectRelation; rhs != nil { + if vtpb, ok := interface{}(rhs).(interface{ CloneVT() *v1.RelationReference }); ok { + r.SubjectRelation = vtpb.CloneVT() + } else { + r.SubjectRelation = proto.Clone(rhs).(*v1.RelationReference) + } + } + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *DispatchLookupSubjectsRequest) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *FoundSubject) CloneVT() *FoundSubject { + if m == nil { + return (*FoundSubject)(nil) + } + r := new(FoundSubject) + r.SubjectId = m.SubjectId + if rhs := m.CaveatExpression; rhs != nil { + if vtpb, ok := interface{}(rhs).(interface{ CloneVT() *v1.CaveatExpression }); ok { + r.CaveatExpression = vtpb.CloneVT() + } else { + r.CaveatExpression = proto.Clone(rhs).(*v1.CaveatExpression) + } + } + if rhs := m.ExcludedSubjects; rhs != nil { + tmpContainer := make([]*FoundSubject, len(rhs)) + for k, v := range rhs { + tmpContainer[k] = v.CloneVT() + } + r.ExcludedSubjects = tmpContainer + } + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *FoundSubject) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *FoundSubjects) CloneVT() *FoundSubjects { + if m == nil { + return (*FoundSubjects)(nil) + } + r := new(FoundSubjects) + if rhs := m.FoundSubjects; rhs != nil { + tmpContainer := make([]*FoundSubject, len(rhs)) + for k, v := range rhs { + tmpContainer[k] = v.CloneVT() + } + r.FoundSubjects = tmpContainer + } + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *FoundSubjects) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *DispatchLookupSubjectsResponse) CloneVT() *DispatchLookupSubjectsResponse { + if m == nil { + return (*DispatchLookupSubjectsResponse)(nil) + } + r := new(DispatchLookupSubjectsResponse) + r.Metadata = m.Metadata.CloneVT() + if rhs := m.FoundSubjectsByResourceId; rhs != nil { + tmpContainer := make(map[string]*FoundSubjects, len(rhs)) + for k, v := range rhs { + tmpContainer[k] = v.CloneVT() + } + r.FoundSubjectsByResourceId = tmpContainer + } + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *DispatchLookupSubjectsResponse) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *ResolverMeta) CloneVT() *ResolverMeta { + if m == nil { + return (*ResolverMeta)(nil) + } + r := new(ResolverMeta) + r.AtRevision = m.AtRevision + r.DepthRemaining = m.DepthRemaining + r.RequestId = m.RequestId + if rhs := m.TraversalBloom; rhs != nil { + tmpBytes := make([]byte, len(rhs)) + copy(tmpBytes, rhs) + r.TraversalBloom = tmpBytes + } + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *ResolverMeta) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *ResponseMeta) CloneVT() *ResponseMeta { + if m == nil { + return (*ResponseMeta)(nil) + } + r := new(ResponseMeta) + r.DispatchCount = m.DispatchCount + r.DepthRequired = m.DepthRequired + r.CachedDispatchCount = m.CachedDispatchCount + r.DebugInfo = m.DebugInfo.CloneVT() + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *ResponseMeta) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *DebugInformation) CloneVT() *DebugInformation { + if m == nil { + return (*DebugInformation)(nil) + } + r := new(DebugInformation) + r.Check = m.Check.CloneVT() + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *DebugInformation) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *CheckDebugTrace) CloneVT() *CheckDebugTrace { + if m == nil { + return (*CheckDebugTrace)(nil) + } + r := new(CheckDebugTrace) + r.Request = m.Request.CloneVT() + r.ResourceRelationType = m.ResourceRelationType + r.IsCachedResult = m.IsCachedResult + r.Duration = (*durationpb.Duration)((*durationpb1.Duration)(m.Duration).CloneVT()) + r.TraceId = m.TraceId + r.SourceId = m.SourceId + if rhs := m.Results; rhs != nil { + tmpContainer := make(map[string]*ResourceCheckResult, len(rhs)) + for k, v := range rhs { + tmpContainer[k] = v.CloneVT() + } + r.Results = tmpContainer + } + if rhs := m.SubProblems; rhs != nil { + tmpContainer := make([]*CheckDebugTrace, len(rhs)) + for k, v := range rhs { + tmpContainer[k] = v.CloneVT() + } + r.SubProblems = tmpContainer + } + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *CheckDebugTrace) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (this *DispatchCheckRequest) EqualVT(that *DispatchCheckRequest) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if !this.Metadata.EqualVT(that.Metadata) { + return false + } + if equal, ok := interface{}(this.ResourceRelation).(interface { + EqualVT(*v1.RelationReference) bool + }); ok { + if !equal.EqualVT(that.ResourceRelation) { + return false + } + } else if !proto.Equal(this.ResourceRelation, that.ResourceRelation) { + return false + } + if len(this.ResourceIds) != len(that.ResourceIds) { + return false + } + for i, vx := range this.ResourceIds { + vy := that.ResourceIds[i] + if vx != vy { + return false + } + } + if equal, ok := interface{}(this.Subject).(interface { + EqualVT(*v1.ObjectAndRelation) bool + }); ok { + if !equal.EqualVT(that.Subject) { + return false + } + } else if !proto.Equal(this.Subject, that.Subject) { + return false + } + if this.ResultsSetting != that.ResultsSetting { + return false + } + if this.Debug != that.Debug { + return false + } + if len(this.CheckHints) != len(that.CheckHints) { + return false + } + for i, vx := range this.CheckHints { + vy := that.CheckHints[i] + if p, q := vx, vy; p != q { + if p == nil { + p = &CheckHint{} + } + if q == nil { + q = &CheckHint{} + } + if !p.EqualVT(q) { + return false + } + } + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *DispatchCheckRequest) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*DispatchCheckRequest) + if !ok { + return false + } + return this.EqualVT(that) +} +func (this *CheckHint) EqualVT(that *CheckHint) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if equal, ok := interface{}(this.Resource).(interface { + EqualVT(*v1.ObjectAndRelation) bool + }); ok { + if !equal.EqualVT(that.Resource) { + return false + } + } else if !proto.Equal(this.Resource, that.Resource) { + return false + } + if equal, ok := interface{}(this.Subject).(interface { + EqualVT(*v1.ObjectAndRelation) bool + }); ok { + if !equal.EqualVT(that.Subject) { + return false + } + } else if !proto.Equal(this.Subject, that.Subject) { + return false + } + if this.TtuComputedUsersetRelation != that.TtuComputedUsersetRelation { + return false + } + if !this.Result.EqualVT(that.Result) { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *CheckHint) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*CheckHint) + if !ok { + return false + } + return this.EqualVT(that) +} +func (this *DispatchCheckResponse) EqualVT(that *DispatchCheckResponse) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if !this.Metadata.EqualVT(that.Metadata) { + return false + } + if len(this.ResultsByResourceId) != len(that.ResultsByResourceId) { + return false + } + for i, vx := range this.ResultsByResourceId { + vy, ok := that.ResultsByResourceId[i] + if !ok { + return false + } + if p, q := vx, vy; p != q { + if p == nil { + p = &ResourceCheckResult{} + } + if q == nil { + q = &ResourceCheckResult{} + } + if !p.EqualVT(q) { + return false + } + } + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *DispatchCheckResponse) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*DispatchCheckResponse) + if !ok { + return false + } + return this.EqualVT(that) +} +func (this *ResourceCheckResult) EqualVT(that *ResourceCheckResult) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if this.Membership != that.Membership { + return false + } + if equal, ok := interface{}(this.Expression).(interface { + EqualVT(*v1.CaveatExpression) bool + }); ok { + if !equal.EqualVT(that.Expression) { + return false + } + } else if !proto.Equal(this.Expression, that.Expression) { + return false + } + if len(this.MissingExprFields) != len(that.MissingExprFields) { + return false + } + for i, vx := range this.MissingExprFields { + vy := that.MissingExprFields[i] + if vx != vy { + return false + } + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *ResourceCheckResult) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*ResourceCheckResult) + if !ok { + return false + } + return this.EqualVT(that) +} +func (this *DispatchExpandRequest) EqualVT(that *DispatchExpandRequest) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if !this.Metadata.EqualVT(that.Metadata) { + return false + } + if equal, ok := interface{}(this.ResourceAndRelation).(interface { + EqualVT(*v1.ObjectAndRelation) bool + }); ok { + if !equal.EqualVT(that.ResourceAndRelation) { + return false + } + } else if !proto.Equal(this.ResourceAndRelation, that.ResourceAndRelation) { + return false + } + if this.ExpansionMode != that.ExpansionMode { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *DispatchExpandRequest) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*DispatchExpandRequest) + if !ok { + return false + } + return this.EqualVT(that) +} +func (this *DispatchExpandResponse) EqualVT(that *DispatchExpandResponse) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if !this.Metadata.EqualVT(that.Metadata) { + return false + } + if equal, ok := interface{}(this.TreeNode).(interface { + EqualVT(*v1.RelationTupleTreeNode) bool + }); ok { + if !equal.EqualVT(that.TreeNode) { + return false + } + } else if !proto.Equal(this.TreeNode, that.TreeNode) { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *DispatchExpandResponse) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*DispatchExpandResponse) + if !ok { + return false + } + return this.EqualVT(that) +} +func (this *Cursor) EqualVT(that *Cursor) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if len(this.Sections) != len(that.Sections) { + return false + } + for i, vx := range this.Sections { + vy := that.Sections[i] + if vx != vy { + return false + } + } + if this.DispatchVersion != that.DispatchVersion { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *Cursor) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*Cursor) + if !ok { + return false + } + return this.EqualVT(that) +} +func (this *DispatchLookupResources2Request) EqualVT(that *DispatchLookupResources2Request) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if !this.Metadata.EqualVT(that.Metadata) { + return false + } + if equal, ok := interface{}(this.ResourceRelation).(interface { + EqualVT(*v1.RelationReference) bool + }); ok { + if !equal.EqualVT(that.ResourceRelation) { + return false + } + } else if !proto.Equal(this.ResourceRelation, that.ResourceRelation) { + return false + } + if equal, ok := interface{}(this.SubjectRelation).(interface { + EqualVT(*v1.RelationReference) bool + }); ok { + if !equal.EqualVT(that.SubjectRelation) { + return false + } + } else if !proto.Equal(this.SubjectRelation, that.SubjectRelation) { + return false + } + if len(this.SubjectIds) != len(that.SubjectIds) { + return false + } + for i, vx := range this.SubjectIds { + vy := that.SubjectIds[i] + if vx != vy { + return false + } + } + if equal, ok := interface{}(this.TerminalSubject).(interface { + EqualVT(*v1.ObjectAndRelation) bool + }); ok { + if !equal.EqualVT(that.TerminalSubject) { + return false + } + } else if !proto.Equal(this.TerminalSubject, that.TerminalSubject) { + return false + } + if !(*structpb1.Struct)(this.Context).EqualVT((*structpb1.Struct)(that.Context)) { + return false + } + if !this.OptionalCursor.EqualVT(that.OptionalCursor) { + return false + } + if this.OptionalLimit != that.OptionalLimit { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *DispatchLookupResources2Request) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*DispatchLookupResources2Request) + if !ok { + return false + } + return this.EqualVT(that) +} +func (this *PossibleResource) EqualVT(that *PossibleResource) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if this.ResourceId != that.ResourceId { + return false + } + if len(this.ForSubjectIds) != len(that.ForSubjectIds) { + return false + } + for i, vx := range this.ForSubjectIds { + vy := that.ForSubjectIds[i] + if vx != vy { + return false + } + } + if len(this.MissingContextParams) != len(that.MissingContextParams) { + return false + } + for i, vx := range this.MissingContextParams { + vy := that.MissingContextParams[i] + if vx != vy { + return false + } + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *PossibleResource) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*PossibleResource) + if !ok { + return false + } + return this.EqualVT(that) +} +func (this *DispatchLookupResources2Response) EqualVT(that *DispatchLookupResources2Response) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if !this.Resource.EqualVT(that.Resource) { + return false + } + if !this.Metadata.EqualVT(that.Metadata) { + return false + } + if !this.AfterResponseCursor.EqualVT(that.AfterResponseCursor) { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *DispatchLookupResources2Response) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*DispatchLookupResources2Response) + if !ok { + return false + } + return this.EqualVT(that) +} +func (this *DispatchLookupSubjectsRequest) EqualVT(that *DispatchLookupSubjectsRequest) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if !this.Metadata.EqualVT(that.Metadata) { + return false + } + if equal, ok := interface{}(this.ResourceRelation).(interface { + EqualVT(*v1.RelationReference) bool + }); ok { + if !equal.EqualVT(that.ResourceRelation) { + return false + } + } else if !proto.Equal(this.ResourceRelation, that.ResourceRelation) { + return false + } + if len(this.ResourceIds) != len(that.ResourceIds) { + return false + } + for i, vx := range this.ResourceIds { + vy := that.ResourceIds[i] + if vx != vy { + return false + } + } + if equal, ok := interface{}(this.SubjectRelation).(interface { + EqualVT(*v1.RelationReference) bool + }); ok { + if !equal.EqualVT(that.SubjectRelation) { + return false + } + } else if !proto.Equal(this.SubjectRelation, that.SubjectRelation) { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *DispatchLookupSubjectsRequest) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*DispatchLookupSubjectsRequest) + if !ok { + return false + } + return this.EqualVT(that) +} +func (this *FoundSubject) EqualVT(that *FoundSubject) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if this.SubjectId != that.SubjectId { + return false + } + if equal, ok := interface{}(this.CaveatExpression).(interface { + EqualVT(*v1.CaveatExpression) bool + }); ok { + if !equal.EqualVT(that.CaveatExpression) { + return false + } + } else if !proto.Equal(this.CaveatExpression, that.CaveatExpression) { + return false + } + if len(this.ExcludedSubjects) != len(that.ExcludedSubjects) { + return false + } + for i, vx := range this.ExcludedSubjects { + vy := that.ExcludedSubjects[i] + if p, q := vx, vy; p != q { + if p == nil { + p = &FoundSubject{} + } + if q == nil { + q = &FoundSubject{} + } + if !p.EqualVT(q) { + return false + } + } + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *FoundSubject) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*FoundSubject) + if !ok { + return false + } + return this.EqualVT(that) +} +func (this *FoundSubjects) EqualVT(that *FoundSubjects) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if len(this.FoundSubjects) != len(that.FoundSubjects) { + return false + } + for i, vx := range this.FoundSubjects { + vy := that.FoundSubjects[i] + if p, q := vx, vy; p != q { + if p == nil { + p = &FoundSubject{} + } + if q == nil { + q = &FoundSubject{} + } + if !p.EqualVT(q) { + return false + } + } + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *FoundSubjects) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*FoundSubjects) + if !ok { + return false + } + return this.EqualVT(that) +} +func (this *DispatchLookupSubjectsResponse) EqualVT(that *DispatchLookupSubjectsResponse) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if len(this.FoundSubjectsByResourceId) != len(that.FoundSubjectsByResourceId) { + return false + } + for i, vx := range this.FoundSubjectsByResourceId { + vy, ok := that.FoundSubjectsByResourceId[i] + if !ok { + return false + } + if p, q := vx, vy; p != q { + if p == nil { + p = &FoundSubjects{} + } + if q == nil { + q = &FoundSubjects{} + } + if !p.EqualVT(q) { + return false + } + } + } + if !this.Metadata.EqualVT(that.Metadata) { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *DispatchLookupSubjectsResponse) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*DispatchLookupSubjectsResponse) + if !ok { + return false + } + return this.EqualVT(that) +} +func (this *ResolverMeta) EqualVT(that *ResolverMeta) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if this.AtRevision != that.AtRevision { + return false + } + if this.DepthRemaining != that.DepthRemaining { + return false + } + if this.RequestId != that.RequestId { + return false + } + if string(this.TraversalBloom) != string(that.TraversalBloom) { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *ResolverMeta) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*ResolverMeta) + if !ok { + return false + } + return this.EqualVT(that) +} +func (this *ResponseMeta) EqualVT(that *ResponseMeta) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if this.DispatchCount != that.DispatchCount { + return false + } + if this.DepthRequired != that.DepthRequired { + return false + } + if this.CachedDispatchCount != that.CachedDispatchCount { + return false + } + if !this.DebugInfo.EqualVT(that.DebugInfo) { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *ResponseMeta) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*ResponseMeta) + if !ok { + return false + } + return this.EqualVT(that) +} +func (this *DebugInformation) EqualVT(that *DebugInformation) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if !this.Check.EqualVT(that.Check) { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *DebugInformation) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*DebugInformation) + if !ok { + return false + } + return this.EqualVT(that) +} +func (this *CheckDebugTrace) EqualVT(that *CheckDebugTrace) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if !this.Request.EqualVT(that.Request) { + return false + } + if this.ResourceRelationType != that.ResourceRelationType { + return false + } + if len(this.Results) != len(that.Results) { + return false + } + for i, vx := range this.Results { + vy, ok := that.Results[i] + if !ok { + return false + } + if p, q := vx, vy; p != q { + if p == nil { + p = &ResourceCheckResult{} + } + if q == nil { + q = &ResourceCheckResult{} + } + if !p.EqualVT(q) { + return false + } + } + } + if this.IsCachedResult != that.IsCachedResult { + return false + } + if len(this.SubProblems) != len(that.SubProblems) { + return false + } + for i, vx := range this.SubProblems { + vy := that.SubProblems[i] + if p, q := vx, vy; p != q { + if p == nil { + p = &CheckDebugTrace{} + } + if q == nil { + q = &CheckDebugTrace{} + } + if !p.EqualVT(q) { + return false + } + } + } + if !(*durationpb1.Duration)(this.Duration).EqualVT((*durationpb1.Duration)(that.Duration)) { + return false + } + if this.TraceId != that.TraceId { + return false + } + if this.SourceId != that.SourceId { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *CheckDebugTrace) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*CheckDebugTrace) + if !ok { + return false + } + return this.EqualVT(that) +} +func (m *DispatchCheckRequest) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *DispatchCheckRequest) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *DispatchCheckRequest) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if len(m.CheckHints) > 0 { + for iNdEx := len(m.CheckHints) - 1; iNdEx >= 0; iNdEx-- { + size, err := m.CheckHints[iNdEx].MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x3a + } + } + if m.Debug != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.Debug)) + i-- + dAtA[i] = 0x30 + } + if m.ResultsSetting != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.ResultsSetting)) + i-- + dAtA[i] = 0x28 + } + if m.Subject != nil { + if vtmsg, ok := interface{}(m.Subject).(interface { + MarshalToSizedBufferVT([]byte) (int, error) + }); ok { + size, err := vtmsg.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + } else { + encoded, err := proto.Marshal(m.Subject) + if err != nil { + return 0, err + } + i -= len(encoded) + copy(dAtA[i:], encoded) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(encoded))) + } + i-- + dAtA[i] = 0x22 + } + if len(m.ResourceIds) > 0 { + for iNdEx := len(m.ResourceIds) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.ResourceIds[iNdEx]) + copy(dAtA[i:], m.ResourceIds[iNdEx]) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.ResourceIds[iNdEx]))) + i-- + dAtA[i] = 0x1a + } + } + if m.ResourceRelation != nil { + if vtmsg, ok := interface{}(m.ResourceRelation).(interface { + MarshalToSizedBufferVT([]byte) (int, error) + }); ok { + size, err := vtmsg.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + } else { + encoded, err := proto.Marshal(m.ResourceRelation) + if err != nil { + return 0, err + } + i -= len(encoded) + copy(dAtA[i:], encoded) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(encoded))) + } + i-- + dAtA[i] = 0x12 + } + if m.Metadata != nil { + size, err := m.Metadata.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *CheckHint) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *CheckHint) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *CheckHint) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if m.Result != nil { + size, err := m.Result.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x22 + } + if len(m.TtuComputedUsersetRelation) > 0 { + i -= len(m.TtuComputedUsersetRelation) + copy(dAtA[i:], m.TtuComputedUsersetRelation) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.TtuComputedUsersetRelation))) + i-- + dAtA[i] = 0x1a + } + if m.Subject != nil { + if vtmsg, ok := interface{}(m.Subject).(interface { + MarshalToSizedBufferVT([]byte) (int, error) + }); ok { + size, err := vtmsg.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + } else { + encoded, err := proto.Marshal(m.Subject) + if err != nil { + return 0, err + } + i -= len(encoded) + copy(dAtA[i:], encoded) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(encoded))) + } + i-- + dAtA[i] = 0x12 + } + if m.Resource != nil { + if vtmsg, ok := interface{}(m.Resource).(interface { + MarshalToSizedBufferVT([]byte) (int, error) + }); ok { + size, err := vtmsg.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + } else { + encoded, err := proto.Marshal(m.Resource) + if err != nil { + return 0, err + } + i -= len(encoded) + copy(dAtA[i:], encoded) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(encoded))) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *DispatchCheckResponse) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *DispatchCheckResponse) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *DispatchCheckResponse) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if len(m.ResultsByResourceId) > 0 { + for k := range m.ResultsByResourceId { + v := m.ResultsByResourceId[k] + baseI := i + size, err := v.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x12 + i -= len(k) + copy(dAtA[i:], k) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(k))) + i-- + dAtA[i] = 0xa + i = protohelpers.EncodeVarint(dAtA, i, uint64(baseI-i)) + i-- + dAtA[i] = 0x12 + } + } + if m.Metadata != nil { + size, err := m.Metadata.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *ResourceCheckResult) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ResourceCheckResult) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *ResourceCheckResult) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if len(m.MissingExprFields) > 0 { + for iNdEx := len(m.MissingExprFields) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.MissingExprFields[iNdEx]) + copy(dAtA[i:], m.MissingExprFields[iNdEx]) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.MissingExprFields[iNdEx]))) + i-- + dAtA[i] = 0x1a + } + } + if m.Expression != nil { + if vtmsg, ok := interface{}(m.Expression).(interface { + MarshalToSizedBufferVT([]byte) (int, error) + }); ok { + size, err := vtmsg.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + } else { + encoded, err := proto.Marshal(m.Expression) + if err != nil { + return 0, err + } + i -= len(encoded) + copy(dAtA[i:], encoded) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(encoded))) + } + i-- + dAtA[i] = 0x12 + } + if m.Membership != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.Membership)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *DispatchExpandRequest) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *DispatchExpandRequest) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *DispatchExpandRequest) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if m.ExpansionMode != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.ExpansionMode)) + i-- + dAtA[i] = 0x18 + } + if m.ResourceAndRelation != nil { + if vtmsg, ok := interface{}(m.ResourceAndRelation).(interface { + MarshalToSizedBufferVT([]byte) (int, error) + }); ok { + size, err := vtmsg.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + } else { + encoded, err := proto.Marshal(m.ResourceAndRelation) + if err != nil { + return 0, err + } + i -= len(encoded) + copy(dAtA[i:], encoded) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(encoded))) + } + i-- + dAtA[i] = 0x12 + } + if m.Metadata != nil { + size, err := m.Metadata.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *DispatchExpandResponse) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *DispatchExpandResponse) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *DispatchExpandResponse) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if m.TreeNode != nil { + if vtmsg, ok := interface{}(m.TreeNode).(interface { + MarshalToSizedBufferVT([]byte) (int, error) + }); ok { + size, err := vtmsg.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + } else { + encoded, err := proto.Marshal(m.TreeNode) + if err != nil { + return 0, err + } + i -= len(encoded) + copy(dAtA[i:], encoded) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(encoded))) + } + i-- + dAtA[i] = 0x12 + } + if m.Metadata != nil { + size, err := m.Metadata.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *Cursor) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Cursor) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *Cursor) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if m.DispatchVersion != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.DispatchVersion)) + i-- + dAtA[i] = 0x18 + } + if len(m.Sections) > 0 { + for iNdEx := len(m.Sections) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Sections[iNdEx]) + copy(dAtA[i:], m.Sections[iNdEx]) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Sections[iNdEx]))) + i-- + dAtA[i] = 0x12 + } + } + return len(dAtA) - i, nil +} + +func (m *DispatchLookupResources2Request) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *DispatchLookupResources2Request) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *DispatchLookupResources2Request) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if m.OptionalLimit != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.OptionalLimit)) + i-- + dAtA[i] = 0x40 + } + if m.OptionalCursor != nil { + size, err := m.OptionalCursor.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x3a + } + if m.Context != nil { + size, err := (*structpb1.Struct)(m.Context).MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x32 + } + if m.TerminalSubject != nil { + if vtmsg, ok := interface{}(m.TerminalSubject).(interface { + MarshalToSizedBufferVT([]byte) (int, error) + }); ok { + size, err := vtmsg.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + } else { + encoded, err := proto.Marshal(m.TerminalSubject) + if err != nil { + return 0, err + } + i -= len(encoded) + copy(dAtA[i:], encoded) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(encoded))) + } + i-- + dAtA[i] = 0x2a + } + if len(m.SubjectIds) > 0 { + for iNdEx := len(m.SubjectIds) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.SubjectIds[iNdEx]) + copy(dAtA[i:], m.SubjectIds[iNdEx]) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.SubjectIds[iNdEx]))) + i-- + dAtA[i] = 0x22 + } + } + if m.SubjectRelation != nil { + if vtmsg, ok := interface{}(m.SubjectRelation).(interface { + MarshalToSizedBufferVT([]byte) (int, error) + }); ok { + size, err := vtmsg.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + } else { + encoded, err := proto.Marshal(m.SubjectRelation) + if err != nil { + return 0, err + } + i -= len(encoded) + copy(dAtA[i:], encoded) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(encoded))) + } + i-- + dAtA[i] = 0x1a + } + if m.ResourceRelation != nil { + if vtmsg, ok := interface{}(m.ResourceRelation).(interface { + MarshalToSizedBufferVT([]byte) (int, error) + }); ok { + size, err := vtmsg.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + } else { + encoded, err := proto.Marshal(m.ResourceRelation) + if err != nil { + return 0, err + } + i -= len(encoded) + copy(dAtA[i:], encoded) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(encoded))) + } + i-- + dAtA[i] = 0x12 + } + if m.Metadata != nil { + size, err := m.Metadata.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *PossibleResource) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *PossibleResource) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *PossibleResource) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if len(m.MissingContextParams) > 0 { + for iNdEx := len(m.MissingContextParams) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.MissingContextParams[iNdEx]) + copy(dAtA[i:], m.MissingContextParams[iNdEx]) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.MissingContextParams[iNdEx]))) + i-- + dAtA[i] = 0x1a + } + } + if len(m.ForSubjectIds) > 0 { + for iNdEx := len(m.ForSubjectIds) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.ForSubjectIds[iNdEx]) + copy(dAtA[i:], m.ForSubjectIds[iNdEx]) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.ForSubjectIds[iNdEx]))) + i-- + dAtA[i] = 0x12 + } + } + if len(m.ResourceId) > 0 { + i -= len(m.ResourceId) + copy(dAtA[i:], m.ResourceId) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.ResourceId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *DispatchLookupResources2Response) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *DispatchLookupResources2Response) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *DispatchLookupResources2Response) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if m.AfterResponseCursor != nil { + size, err := m.AfterResponseCursor.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x1a + } + if m.Metadata != nil { + size, err := m.Metadata.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x12 + } + if m.Resource != nil { + size, err := m.Resource.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *DispatchLookupSubjectsRequest) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *DispatchLookupSubjectsRequest) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *DispatchLookupSubjectsRequest) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if m.SubjectRelation != nil { + if vtmsg, ok := interface{}(m.SubjectRelation).(interface { + MarshalToSizedBufferVT([]byte) (int, error) + }); ok { + size, err := vtmsg.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + } else { + encoded, err := proto.Marshal(m.SubjectRelation) + if err != nil { + return 0, err + } + i -= len(encoded) + copy(dAtA[i:], encoded) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(encoded))) + } + i-- + dAtA[i] = 0x22 + } + if len(m.ResourceIds) > 0 { + for iNdEx := len(m.ResourceIds) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.ResourceIds[iNdEx]) + copy(dAtA[i:], m.ResourceIds[iNdEx]) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.ResourceIds[iNdEx]))) + i-- + dAtA[i] = 0x1a + } + } + if m.ResourceRelation != nil { + if vtmsg, ok := interface{}(m.ResourceRelation).(interface { + MarshalToSizedBufferVT([]byte) (int, error) + }); ok { + size, err := vtmsg.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + } else { + encoded, err := proto.Marshal(m.ResourceRelation) + if err != nil { + return 0, err + } + i -= len(encoded) + copy(dAtA[i:], encoded) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(encoded))) + } + i-- + dAtA[i] = 0x12 + } + if m.Metadata != nil { + size, err := m.Metadata.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *FoundSubject) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *FoundSubject) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *FoundSubject) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if len(m.ExcludedSubjects) > 0 { + for iNdEx := len(m.ExcludedSubjects) - 1; iNdEx >= 0; iNdEx-- { + size, err := m.ExcludedSubjects[iNdEx].MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x1a + } + } + if m.CaveatExpression != nil { + if vtmsg, ok := interface{}(m.CaveatExpression).(interface { + MarshalToSizedBufferVT([]byte) (int, error) + }); ok { + size, err := vtmsg.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + } else { + encoded, err := proto.Marshal(m.CaveatExpression) + if err != nil { + return 0, err + } + i -= len(encoded) + copy(dAtA[i:], encoded) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(encoded))) + } + i-- + dAtA[i] = 0x12 + } + if len(m.SubjectId) > 0 { + i -= len(m.SubjectId) + copy(dAtA[i:], m.SubjectId) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.SubjectId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *FoundSubjects) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *FoundSubjects) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *FoundSubjects) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if len(m.FoundSubjects) > 0 { + for iNdEx := len(m.FoundSubjects) - 1; iNdEx >= 0; iNdEx-- { + size, err := m.FoundSubjects[iNdEx].MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *DispatchLookupSubjectsResponse) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *DispatchLookupSubjectsResponse) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *DispatchLookupSubjectsResponse) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if m.Metadata != nil { + size, err := m.Metadata.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x12 + } + if len(m.FoundSubjectsByResourceId) > 0 { + for k := range m.FoundSubjectsByResourceId { + v := m.FoundSubjectsByResourceId[k] + baseI := i + size, err := v.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x12 + i -= len(k) + copy(dAtA[i:], k) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(k))) + i-- + dAtA[i] = 0xa + i = protohelpers.EncodeVarint(dAtA, i, uint64(baseI-i)) + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *ResolverMeta) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ResolverMeta) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *ResolverMeta) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if len(m.TraversalBloom) > 0 { + i -= len(m.TraversalBloom) + copy(dAtA[i:], m.TraversalBloom) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.TraversalBloom))) + i-- + dAtA[i] = 0x22 + } + if len(m.RequestId) > 0 { + i -= len(m.RequestId) + copy(dAtA[i:], m.RequestId) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.RequestId))) + i-- + dAtA[i] = 0x1a + } + if m.DepthRemaining != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.DepthRemaining)) + i-- + dAtA[i] = 0x10 + } + if len(m.AtRevision) > 0 { + i -= len(m.AtRevision) + copy(dAtA[i:], m.AtRevision) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.AtRevision))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *ResponseMeta) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ResponseMeta) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *ResponseMeta) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if m.DebugInfo != nil { + size, err := m.DebugInfo.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x32 + } + if m.CachedDispatchCount != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.CachedDispatchCount)) + i-- + dAtA[i] = 0x18 + } + if m.DepthRequired != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.DepthRequired)) + i-- + dAtA[i] = 0x10 + } + if m.DispatchCount != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.DispatchCount)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *DebugInformation) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *DebugInformation) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *DebugInformation) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if m.Check != nil { + size, err := m.Check.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *CheckDebugTrace) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *CheckDebugTrace) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *CheckDebugTrace) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if len(m.SourceId) > 0 { + i -= len(m.SourceId) + copy(dAtA[i:], m.SourceId) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.SourceId))) + i-- + dAtA[i] = 0x42 + } + if len(m.TraceId) > 0 { + i -= len(m.TraceId) + copy(dAtA[i:], m.TraceId) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.TraceId))) + i-- + dAtA[i] = 0x3a + } + if m.Duration != nil { + size, err := (*durationpb1.Duration)(m.Duration).MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x32 + } + if len(m.SubProblems) > 0 { + for iNdEx := len(m.SubProblems) - 1; iNdEx >= 0; iNdEx-- { + size, err := m.SubProblems[iNdEx].MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x2a + } + } + if m.IsCachedResult { + i-- + if m.IsCachedResult { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x20 + } + if len(m.Results) > 0 { + for k := range m.Results { + v := m.Results[k] + baseI := i + size, err := v.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x12 + i -= len(k) + copy(dAtA[i:], k) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(k))) + i-- + dAtA[i] = 0xa + i = protohelpers.EncodeVarint(dAtA, i, uint64(baseI-i)) + i-- + dAtA[i] = 0x1a + } + } + if m.ResourceRelationType != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.ResourceRelationType)) + i-- + dAtA[i] = 0x10 + } + if m.Request != nil { + size, err := m.Request.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *DispatchCheckRequest) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Metadata != nil { + l = m.Metadata.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if m.ResourceRelation != nil { + if size, ok := interface{}(m.ResourceRelation).(interface { + SizeVT() int + }); ok { + l = size.SizeVT() + } else { + l = proto.Size(m.ResourceRelation) + } + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if len(m.ResourceIds) > 0 { + for _, s := range m.ResourceIds { + l = len(s) + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + } + if m.Subject != nil { + if size, ok := interface{}(m.Subject).(interface { + SizeVT() int + }); ok { + l = size.SizeVT() + } else { + l = proto.Size(m.Subject) + } + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if m.ResultsSetting != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.ResultsSetting)) + } + if m.Debug != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.Debug)) + } + if len(m.CheckHints) > 0 { + for _, e := range m.CheckHints { + l = e.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + } + n += len(m.unknownFields) + return n +} + +func (m *CheckHint) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Resource != nil { + if size, ok := interface{}(m.Resource).(interface { + SizeVT() int + }); ok { + l = size.SizeVT() + } else { + l = proto.Size(m.Resource) + } + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if m.Subject != nil { + if size, ok := interface{}(m.Subject).(interface { + SizeVT() int + }); ok { + l = size.SizeVT() + } else { + l = proto.Size(m.Subject) + } + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + l = len(m.TtuComputedUsersetRelation) + if l > 0 { + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if m.Result != nil { + l = m.Result.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + n += len(m.unknownFields) + return n +} + +func (m *DispatchCheckResponse) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Metadata != nil { + l = m.Metadata.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if len(m.ResultsByResourceId) > 0 { + for k, v := range m.ResultsByResourceId { + _ = k + _ = v + l = 0 + if v != nil { + l = v.SizeVT() + } + l += 1 + protohelpers.SizeOfVarint(uint64(l)) + mapEntrySize := 1 + len(k) + protohelpers.SizeOfVarint(uint64(len(k))) + l + n += mapEntrySize + 1 + protohelpers.SizeOfVarint(uint64(mapEntrySize)) + } + } + n += len(m.unknownFields) + return n +} + +func (m *ResourceCheckResult) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Membership != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.Membership)) + } + if m.Expression != nil { + if size, ok := interface{}(m.Expression).(interface { + SizeVT() int + }); ok { + l = size.SizeVT() + } else { + l = proto.Size(m.Expression) + } + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if len(m.MissingExprFields) > 0 { + for _, s := range m.MissingExprFields { + l = len(s) + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + } + n += len(m.unknownFields) + return n +} + +func (m *DispatchExpandRequest) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Metadata != nil { + l = m.Metadata.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if m.ResourceAndRelation != nil { + if size, ok := interface{}(m.ResourceAndRelation).(interface { + SizeVT() int + }); ok { + l = size.SizeVT() + } else { + l = proto.Size(m.ResourceAndRelation) + } + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if m.ExpansionMode != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.ExpansionMode)) + } + n += len(m.unknownFields) + return n +} + +func (m *DispatchExpandResponse) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Metadata != nil { + l = m.Metadata.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if m.TreeNode != nil { + if size, ok := interface{}(m.TreeNode).(interface { + SizeVT() int + }); ok { + l = size.SizeVT() + } else { + l = proto.Size(m.TreeNode) + } + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + n += len(m.unknownFields) + return n +} + +func (m *Cursor) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Sections) > 0 { + for _, s := range m.Sections { + l = len(s) + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + } + if m.DispatchVersion != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.DispatchVersion)) + } + n += len(m.unknownFields) + return n +} + +func (m *DispatchLookupResources2Request) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Metadata != nil { + l = m.Metadata.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if m.ResourceRelation != nil { + if size, ok := interface{}(m.ResourceRelation).(interface { + SizeVT() int + }); ok { + l = size.SizeVT() + } else { + l = proto.Size(m.ResourceRelation) + } + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if m.SubjectRelation != nil { + if size, ok := interface{}(m.SubjectRelation).(interface { + SizeVT() int + }); ok { + l = size.SizeVT() + } else { + l = proto.Size(m.SubjectRelation) + } + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if len(m.SubjectIds) > 0 { + for _, s := range m.SubjectIds { + l = len(s) + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + } + if m.TerminalSubject != nil { + if size, ok := interface{}(m.TerminalSubject).(interface { + SizeVT() int + }); ok { + l = size.SizeVT() + } else { + l = proto.Size(m.TerminalSubject) + } + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if m.Context != nil { + l = (*structpb1.Struct)(m.Context).SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if m.OptionalCursor != nil { + l = m.OptionalCursor.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if m.OptionalLimit != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.OptionalLimit)) + } + n += len(m.unknownFields) + return n +} + +func (m *PossibleResource) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ResourceId) + if l > 0 { + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if len(m.ForSubjectIds) > 0 { + for _, s := range m.ForSubjectIds { + l = len(s) + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + } + if len(m.MissingContextParams) > 0 { + for _, s := range m.MissingContextParams { + l = len(s) + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + } + n += len(m.unknownFields) + return n +} + +func (m *DispatchLookupResources2Response) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Resource != nil { + l = m.Resource.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if m.Metadata != nil { + l = m.Metadata.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if m.AfterResponseCursor != nil { + l = m.AfterResponseCursor.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + n += len(m.unknownFields) + return n +} + +func (m *DispatchLookupSubjectsRequest) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Metadata != nil { + l = m.Metadata.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if m.ResourceRelation != nil { + if size, ok := interface{}(m.ResourceRelation).(interface { + SizeVT() int + }); ok { + l = size.SizeVT() + } else { + l = proto.Size(m.ResourceRelation) + } + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if len(m.ResourceIds) > 0 { + for _, s := range m.ResourceIds { + l = len(s) + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + } + if m.SubjectRelation != nil { + if size, ok := interface{}(m.SubjectRelation).(interface { + SizeVT() int + }); ok { + l = size.SizeVT() + } else { + l = proto.Size(m.SubjectRelation) + } + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + n += len(m.unknownFields) + return n +} + +func (m *FoundSubject) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.SubjectId) + if l > 0 { + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if m.CaveatExpression != nil { + if size, ok := interface{}(m.CaveatExpression).(interface { + SizeVT() int + }); ok { + l = size.SizeVT() + } else { + l = proto.Size(m.CaveatExpression) + } + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if len(m.ExcludedSubjects) > 0 { + for _, e := range m.ExcludedSubjects { + l = e.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + } + n += len(m.unknownFields) + return n +} + +func (m *FoundSubjects) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.FoundSubjects) > 0 { + for _, e := range m.FoundSubjects { + l = e.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + } + n += len(m.unknownFields) + return n +} + +func (m *DispatchLookupSubjectsResponse) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.FoundSubjectsByResourceId) > 0 { + for k, v := range m.FoundSubjectsByResourceId { + _ = k + _ = v + l = 0 + if v != nil { + l = v.SizeVT() + } + l += 1 + protohelpers.SizeOfVarint(uint64(l)) + mapEntrySize := 1 + len(k) + protohelpers.SizeOfVarint(uint64(len(k))) + l + n += mapEntrySize + 1 + protohelpers.SizeOfVarint(uint64(mapEntrySize)) + } + } + if m.Metadata != nil { + l = m.Metadata.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + n += len(m.unknownFields) + return n +} + +func (m *ResolverMeta) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.AtRevision) + if l > 0 { + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if m.DepthRemaining != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.DepthRemaining)) + } + l = len(m.RequestId) + if l > 0 { + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + l = len(m.TraversalBloom) + if l > 0 { + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + n += len(m.unknownFields) + return n +} + +func (m *ResponseMeta) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.DispatchCount != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.DispatchCount)) + } + if m.DepthRequired != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.DepthRequired)) + } + if m.CachedDispatchCount != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.CachedDispatchCount)) + } + if m.DebugInfo != nil { + l = m.DebugInfo.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + n += len(m.unknownFields) + return n +} + +func (m *DebugInformation) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Check != nil { + l = m.Check.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + n += len(m.unknownFields) + return n +} + +func (m *CheckDebugTrace) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Request != nil { + l = m.Request.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if m.ResourceRelationType != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.ResourceRelationType)) + } + if len(m.Results) > 0 { + for k, v := range m.Results { + _ = k + _ = v + l = 0 + if v != nil { + l = v.SizeVT() + } + l += 1 + protohelpers.SizeOfVarint(uint64(l)) + mapEntrySize := 1 + len(k) + protohelpers.SizeOfVarint(uint64(len(k))) + l + n += mapEntrySize + 1 + protohelpers.SizeOfVarint(uint64(mapEntrySize)) + } + } + if m.IsCachedResult { + n += 2 + } + if len(m.SubProblems) > 0 { + for _, e := range m.SubProblems { + l = e.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + } + if m.Duration != nil { + l = (*durationpb1.Duration)(m.Duration).SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + l = len(m.TraceId) + if l > 0 { + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + l = len(m.SourceId) + if l > 0 { + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + n += len(m.unknownFields) + return n +} + +func (m *DispatchCheckRequest) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: DispatchCheckRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: DispatchCheckRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Metadata", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Metadata == nil { + m.Metadata = &ResolverMeta{} + } + if err := m.Metadata.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ResourceRelation", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.ResourceRelation == nil { + m.ResourceRelation = &v1.RelationReference{} + } + if unmarshal, ok := interface{}(m.ResourceRelation).(interface { + UnmarshalVT([]byte) error + }); ok { + if err := unmarshal.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + } else { + if err := proto.Unmarshal(dAtA[iNdEx:postIndex], m.ResourceRelation); err != nil { + return err + } + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ResourceIds", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ResourceIds = append(m.ResourceIds, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Subject", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Subject == nil { + m.Subject = &v1.ObjectAndRelation{} + } + if unmarshal, ok := interface{}(m.Subject).(interface { + UnmarshalVT([]byte) error + }); ok { + if err := unmarshal.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + } else { + if err := proto.Unmarshal(dAtA[iNdEx:postIndex], m.Subject); err != nil { + return err + } + } + iNdEx = postIndex + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ResultsSetting", wireType) + } + m.ResultsSetting = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ResultsSetting |= DispatchCheckRequest_ResultsSetting(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Debug", wireType) + } + m.Debug = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Debug |= DispatchCheckRequest_DebugSetting(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CheckHints", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.CheckHints = append(m.CheckHints, &CheckHint{}) + if err := m.CheckHints[len(m.CheckHints)-1].UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *CheckHint) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: CheckHint: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: CheckHint: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Resource", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Resource == nil { + m.Resource = &v1.ObjectAndRelation{} + } + if unmarshal, ok := interface{}(m.Resource).(interface { + UnmarshalVT([]byte) error + }); ok { + if err := unmarshal.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + } else { + if err := proto.Unmarshal(dAtA[iNdEx:postIndex], m.Resource); err != nil { + return err + } + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Subject", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Subject == nil { + m.Subject = &v1.ObjectAndRelation{} + } + if unmarshal, ok := interface{}(m.Subject).(interface { + UnmarshalVT([]byte) error + }); ok { + if err := unmarshal.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + } else { + if err := proto.Unmarshal(dAtA[iNdEx:postIndex], m.Subject); err != nil { + return err + } + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TtuComputedUsersetRelation", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.TtuComputedUsersetRelation = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Result", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Result == nil { + m.Result = &ResourceCheckResult{} + } + if err := m.Result.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *DispatchCheckResponse) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: DispatchCheckResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: DispatchCheckResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Metadata", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Metadata == nil { + m.Metadata = &ResponseMeta{} + } + if err := m.Metadata.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ResultsByResourceId", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.ResultsByResourceId == nil { + m.ResultsByResourceId = make(map[string]*ResourceCheckResult) + } + var mapkey string + var mapvalue *ResourceCheckResult + for iNdEx < postIndex { + entryPreIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + if fieldNum == 1 { + var stringLenmapkey uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLenmapkey |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLenmapkey := int(stringLenmapkey) + if intStringLenmapkey < 0 { + return protohelpers.ErrInvalidLength + } + postStringIndexmapkey := iNdEx + intStringLenmapkey + if postStringIndexmapkey < 0 { + return protohelpers.ErrInvalidLength + } + if postStringIndexmapkey > l { + return io.ErrUnexpectedEOF + } + mapkey = string(dAtA[iNdEx:postStringIndexmapkey]) + iNdEx = postStringIndexmapkey + } else if fieldNum == 2 { + var mapmsglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + mapmsglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if mapmsglen < 0 { + return protohelpers.ErrInvalidLength + } + postmsgIndex := iNdEx + mapmsglen + if postmsgIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postmsgIndex > l { + return io.ErrUnexpectedEOF + } + mapvalue = &ResourceCheckResult{} + if err := mapvalue.UnmarshalVT(dAtA[iNdEx:postmsgIndex]); err != nil { + return err + } + iNdEx = postmsgIndex + } else { + iNdEx = entryPreIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > postIndex { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + m.ResultsByResourceId[mapkey] = mapvalue + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ResourceCheckResult) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ResourceCheckResult: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ResourceCheckResult: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Membership", wireType) + } + m.Membership = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Membership |= ResourceCheckResult_Membership(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Expression", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Expression == nil { + m.Expression = &v1.CaveatExpression{} + } + if unmarshal, ok := interface{}(m.Expression).(interface { + UnmarshalVT([]byte) error + }); ok { + if err := unmarshal.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + } else { + if err := proto.Unmarshal(dAtA[iNdEx:postIndex], m.Expression); err != nil { + return err + } + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MissingExprFields", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.MissingExprFields = append(m.MissingExprFields, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *DispatchExpandRequest) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: DispatchExpandRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: DispatchExpandRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Metadata", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Metadata == nil { + m.Metadata = &ResolverMeta{} + } + if err := m.Metadata.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ResourceAndRelation", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.ResourceAndRelation == nil { + m.ResourceAndRelation = &v1.ObjectAndRelation{} + } + if unmarshal, ok := interface{}(m.ResourceAndRelation).(interface { + UnmarshalVT([]byte) error + }); ok { + if err := unmarshal.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + } else { + if err := proto.Unmarshal(dAtA[iNdEx:postIndex], m.ResourceAndRelation); err != nil { + return err + } + } + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ExpansionMode", wireType) + } + m.ExpansionMode = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ExpansionMode |= DispatchExpandRequest_ExpansionMode(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *DispatchExpandResponse) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: DispatchExpandResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: DispatchExpandResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Metadata", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Metadata == nil { + m.Metadata = &ResponseMeta{} + } + if err := m.Metadata.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TreeNode", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.TreeNode == nil { + m.TreeNode = &v1.RelationTupleTreeNode{} + } + if unmarshal, ok := interface{}(m.TreeNode).(interface { + UnmarshalVT([]byte) error + }); ok { + if err := unmarshal.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + } else { + if err := proto.Unmarshal(dAtA[iNdEx:postIndex], m.TreeNode); err != nil { + return err + } + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Cursor) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Cursor: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Cursor: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Sections", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Sections = append(m.Sections, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field DispatchVersion", wireType) + } + m.DispatchVersion = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.DispatchVersion |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *DispatchLookupResources2Request) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: DispatchLookupResources2Request: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: DispatchLookupResources2Request: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Metadata", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Metadata == nil { + m.Metadata = &ResolverMeta{} + } + if err := m.Metadata.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ResourceRelation", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.ResourceRelation == nil { + m.ResourceRelation = &v1.RelationReference{} + } + if unmarshal, ok := interface{}(m.ResourceRelation).(interface { + UnmarshalVT([]byte) error + }); ok { + if err := unmarshal.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + } else { + if err := proto.Unmarshal(dAtA[iNdEx:postIndex], m.ResourceRelation); err != nil { + return err + } + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SubjectRelation", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.SubjectRelation == nil { + m.SubjectRelation = &v1.RelationReference{} + } + if unmarshal, ok := interface{}(m.SubjectRelation).(interface { + UnmarshalVT([]byte) error + }); ok { + if err := unmarshal.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + } else { + if err := proto.Unmarshal(dAtA[iNdEx:postIndex], m.SubjectRelation); err != nil { + return err + } + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SubjectIds", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.SubjectIds = append(m.SubjectIds, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TerminalSubject", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.TerminalSubject == nil { + m.TerminalSubject = &v1.ObjectAndRelation{} + } + if unmarshal, ok := interface{}(m.TerminalSubject).(interface { + UnmarshalVT([]byte) error + }); ok { + if err := unmarshal.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + } else { + if err := proto.Unmarshal(dAtA[iNdEx:postIndex], m.TerminalSubject); err != nil { + return err + } + } + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Context", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Context == nil { + m.Context = &structpb.Struct{} + } + if err := (*structpb1.Struct)(m.Context).UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field OptionalCursor", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.OptionalCursor == nil { + m.OptionalCursor = &Cursor{} + } + if err := m.OptionalCursor.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 8: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field OptionalLimit", wireType) + } + m.OptionalLimit = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.OptionalLimit |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *PossibleResource) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: PossibleResource: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: PossibleResource: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ResourceId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ResourceId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ForSubjectIds", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ForSubjectIds = append(m.ForSubjectIds, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MissingContextParams", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.MissingContextParams = append(m.MissingContextParams, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *DispatchLookupResources2Response) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: DispatchLookupResources2Response: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: DispatchLookupResources2Response: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Resource", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Resource == nil { + m.Resource = &PossibleResource{} + } + if err := m.Resource.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Metadata", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Metadata == nil { + m.Metadata = &ResponseMeta{} + } + if err := m.Metadata.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AfterResponseCursor", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.AfterResponseCursor == nil { + m.AfterResponseCursor = &Cursor{} + } + if err := m.AfterResponseCursor.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *DispatchLookupSubjectsRequest) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: DispatchLookupSubjectsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: DispatchLookupSubjectsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Metadata", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Metadata == nil { + m.Metadata = &ResolverMeta{} + } + if err := m.Metadata.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ResourceRelation", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.ResourceRelation == nil { + m.ResourceRelation = &v1.RelationReference{} + } + if unmarshal, ok := interface{}(m.ResourceRelation).(interface { + UnmarshalVT([]byte) error + }); ok { + if err := unmarshal.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + } else { + if err := proto.Unmarshal(dAtA[iNdEx:postIndex], m.ResourceRelation); err != nil { + return err + } + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ResourceIds", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ResourceIds = append(m.ResourceIds, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SubjectRelation", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.SubjectRelation == nil { + m.SubjectRelation = &v1.RelationReference{} + } + if unmarshal, ok := interface{}(m.SubjectRelation).(interface { + UnmarshalVT([]byte) error + }); ok { + if err := unmarshal.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + } else { + if err := proto.Unmarshal(dAtA[iNdEx:postIndex], m.SubjectRelation); err != nil { + return err + } + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *FoundSubject) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: FoundSubject: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: FoundSubject: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SubjectId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.SubjectId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CaveatExpression", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.CaveatExpression == nil { + m.CaveatExpression = &v1.CaveatExpression{} + } + if unmarshal, ok := interface{}(m.CaveatExpression).(interface { + UnmarshalVT([]byte) error + }); ok { + if err := unmarshal.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + } else { + if err := proto.Unmarshal(dAtA[iNdEx:postIndex], m.CaveatExpression); err != nil { + return err + } + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ExcludedSubjects", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ExcludedSubjects = append(m.ExcludedSubjects, &FoundSubject{}) + if err := m.ExcludedSubjects[len(m.ExcludedSubjects)-1].UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *FoundSubjects) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: FoundSubjects: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: FoundSubjects: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field FoundSubjects", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.FoundSubjects = append(m.FoundSubjects, &FoundSubject{}) + if err := m.FoundSubjects[len(m.FoundSubjects)-1].UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *DispatchLookupSubjectsResponse) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: DispatchLookupSubjectsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: DispatchLookupSubjectsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field FoundSubjectsByResourceId", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.FoundSubjectsByResourceId == nil { + m.FoundSubjectsByResourceId = make(map[string]*FoundSubjects) + } + var mapkey string + var mapvalue *FoundSubjects + for iNdEx < postIndex { + entryPreIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + if fieldNum == 1 { + var stringLenmapkey uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLenmapkey |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLenmapkey := int(stringLenmapkey) + if intStringLenmapkey < 0 { + return protohelpers.ErrInvalidLength + } + postStringIndexmapkey := iNdEx + intStringLenmapkey + if postStringIndexmapkey < 0 { + return protohelpers.ErrInvalidLength + } + if postStringIndexmapkey > l { + return io.ErrUnexpectedEOF + } + mapkey = string(dAtA[iNdEx:postStringIndexmapkey]) + iNdEx = postStringIndexmapkey + } else if fieldNum == 2 { + var mapmsglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + mapmsglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if mapmsglen < 0 { + return protohelpers.ErrInvalidLength + } + postmsgIndex := iNdEx + mapmsglen + if postmsgIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postmsgIndex > l { + return io.ErrUnexpectedEOF + } + mapvalue = &FoundSubjects{} + if err := mapvalue.UnmarshalVT(dAtA[iNdEx:postmsgIndex]); err != nil { + return err + } + iNdEx = postmsgIndex + } else { + iNdEx = entryPreIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > postIndex { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + m.FoundSubjectsByResourceId[mapkey] = mapvalue + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Metadata", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Metadata == nil { + m.Metadata = &ResponseMeta{} + } + if err := m.Metadata.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ResolverMeta) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ResolverMeta: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ResolverMeta: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AtRevision", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.AtRevision = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field DepthRemaining", wireType) + } + m.DepthRemaining = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.DepthRemaining |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RequestId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.RequestId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TraversalBloom", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.TraversalBloom = append(m.TraversalBloom[:0], dAtA[iNdEx:postIndex]...) + if m.TraversalBloom == nil { + m.TraversalBloom = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ResponseMeta) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ResponseMeta: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ResponseMeta: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field DispatchCount", wireType) + } + m.DispatchCount = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.DispatchCount |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field DepthRequired", wireType) + } + m.DepthRequired = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.DepthRequired |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field CachedDispatchCount", wireType) + } + m.CachedDispatchCount = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.CachedDispatchCount |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DebugInfo", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.DebugInfo == nil { + m.DebugInfo = &DebugInformation{} + } + if err := m.DebugInfo.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *DebugInformation) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: DebugInformation: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: DebugInformation: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Check", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Check == nil { + m.Check = &CheckDebugTrace{} + } + if err := m.Check.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *CheckDebugTrace) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: CheckDebugTrace: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: CheckDebugTrace: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Request", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Request == nil { + m.Request = &DispatchCheckRequest{} + } + if err := m.Request.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ResourceRelationType", wireType) + } + m.ResourceRelationType = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ResourceRelationType |= CheckDebugTrace_RelationType(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Results", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Results == nil { + m.Results = make(map[string]*ResourceCheckResult) + } + var mapkey string + var mapvalue *ResourceCheckResult + for iNdEx < postIndex { + entryPreIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + if fieldNum == 1 { + var stringLenmapkey uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLenmapkey |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLenmapkey := int(stringLenmapkey) + if intStringLenmapkey < 0 { + return protohelpers.ErrInvalidLength + } + postStringIndexmapkey := iNdEx + intStringLenmapkey + if postStringIndexmapkey < 0 { + return protohelpers.ErrInvalidLength + } + if postStringIndexmapkey > l { + return io.ErrUnexpectedEOF + } + mapkey = string(dAtA[iNdEx:postStringIndexmapkey]) + iNdEx = postStringIndexmapkey + } else if fieldNum == 2 { + var mapmsglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + mapmsglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if mapmsglen < 0 { + return protohelpers.ErrInvalidLength + } + postmsgIndex := iNdEx + mapmsglen + if postmsgIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postmsgIndex > l { + return io.ErrUnexpectedEOF + } + mapvalue = &ResourceCheckResult{} + if err := mapvalue.UnmarshalVT(dAtA[iNdEx:postmsgIndex]); err != nil { + return err + } + iNdEx = postmsgIndex + } else { + iNdEx = entryPreIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > postIndex { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + m.Results[mapkey] = mapvalue + iNdEx = postIndex + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field IsCachedResult", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.IsCachedResult = bool(v != 0) + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SubProblems", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.SubProblems = append(m.SubProblems, &CheckDebugTrace{}) + if err := m.SubProblems[len(m.SubProblems)-1].UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Duration", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Duration == nil { + m.Duration = &durationpb.Duration{} + } + if err := (*durationpb1.Duration)(m.Duration).UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TraceId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.TraceId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 8: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SourceId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.SourceId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} diff --git a/vendor/github.com/authzed/spicedb/pkg/proto/impl/v1/impl.pb.go b/vendor/github.com/authzed/spicedb/pkg/proto/impl/v1/impl.pb.go new file mode 100644 index 0000000..67ee033 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/proto/impl/v1/impl.pb.go @@ -0,0 +1,1205 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.34.2 +// protoc (unknown) +// source: impl/v1/impl.proto + +package implv1 + +import ( + v1alpha1 "google.golang.org/genproto/googleapis/api/expr/v1alpha1" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type RelationMetadata_RelationKind int32 + +const ( + RelationMetadata_UNKNOWN_KIND RelationMetadata_RelationKind = 0 + RelationMetadata_RELATION RelationMetadata_RelationKind = 1 + RelationMetadata_PERMISSION RelationMetadata_RelationKind = 2 +) + +// Enum value maps for RelationMetadata_RelationKind. +var ( + RelationMetadata_RelationKind_name = map[int32]string{ + 0: "UNKNOWN_KIND", + 1: "RELATION", + 2: "PERMISSION", + } + RelationMetadata_RelationKind_value = map[string]int32{ + "UNKNOWN_KIND": 0, + "RELATION": 1, + "PERMISSION": 2, + } +) + +func (x RelationMetadata_RelationKind) Enum() *RelationMetadata_RelationKind { + p := new(RelationMetadata_RelationKind) + *p = x + return p +} + +func (x RelationMetadata_RelationKind) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (RelationMetadata_RelationKind) Descriptor() protoreflect.EnumDescriptor { + return file_impl_v1_impl_proto_enumTypes[0].Descriptor() +} + +func (RelationMetadata_RelationKind) Type() protoreflect.EnumType { + return &file_impl_v1_impl_proto_enumTypes[0] +} + +func (x RelationMetadata_RelationKind) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use RelationMetadata_RelationKind.Descriptor instead. +func (RelationMetadata_RelationKind) EnumDescriptor() ([]byte, []int) { + return file_impl_v1_impl_proto_rawDescGZIP(), []int{6, 0} +} + +type DecodedCaveat struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // we do kind_oneof in case we decide to have non-CEL expressions + // + // Types that are assignable to KindOneof: + // + // *DecodedCaveat_Cel + KindOneof isDecodedCaveat_KindOneof `protobuf_oneof:"kind_oneof"` + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` +} + +func (x *DecodedCaveat) Reset() { + *x = DecodedCaveat{} + if protoimpl.UnsafeEnabled { + mi := &file_impl_v1_impl_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DecodedCaveat) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DecodedCaveat) ProtoMessage() {} + +func (x *DecodedCaveat) ProtoReflect() protoreflect.Message { + mi := &file_impl_v1_impl_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DecodedCaveat.ProtoReflect.Descriptor instead. +func (*DecodedCaveat) Descriptor() ([]byte, []int) { + return file_impl_v1_impl_proto_rawDescGZIP(), []int{0} +} + +func (m *DecodedCaveat) GetKindOneof() isDecodedCaveat_KindOneof { + if m != nil { + return m.KindOneof + } + return nil +} + +func (x *DecodedCaveat) GetCel() *v1alpha1.CheckedExpr { + if x, ok := x.GetKindOneof().(*DecodedCaveat_Cel); ok { + return x.Cel + } + return nil +} + +func (x *DecodedCaveat) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +type isDecodedCaveat_KindOneof interface { + isDecodedCaveat_KindOneof() +} + +type DecodedCaveat_Cel struct { + Cel *v1alpha1.CheckedExpr `protobuf:"bytes,1,opt,name=cel,proto3,oneof"` +} + +func (*DecodedCaveat_Cel) isDecodedCaveat_KindOneof() {} + +type DecodedZookie struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Version uint32 `protobuf:"varint,1,opt,name=version,proto3" json:"version,omitempty"` + // Types that are assignable to VersionOneof: + // + // *DecodedZookie_V1 + // *DecodedZookie_V2 + VersionOneof isDecodedZookie_VersionOneof `protobuf_oneof:"version_oneof"` +} + +func (x *DecodedZookie) Reset() { + *x = DecodedZookie{} + if protoimpl.UnsafeEnabled { + mi := &file_impl_v1_impl_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DecodedZookie) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DecodedZookie) ProtoMessage() {} + +func (x *DecodedZookie) ProtoReflect() protoreflect.Message { + mi := &file_impl_v1_impl_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DecodedZookie.ProtoReflect.Descriptor instead. +func (*DecodedZookie) Descriptor() ([]byte, []int) { + return file_impl_v1_impl_proto_rawDescGZIP(), []int{1} +} + +func (x *DecodedZookie) GetVersion() uint32 { + if x != nil { + return x.Version + } + return 0 +} + +func (m *DecodedZookie) GetVersionOneof() isDecodedZookie_VersionOneof { + if m != nil { + return m.VersionOneof + } + return nil +} + +func (x *DecodedZookie) GetV1() *DecodedZookie_V1Zookie { + if x, ok := x.GetVersionOneof().(*DecodedZookie_V1); ok { + return x.V1 + } + return nil +} + +func (x *DecodedZookie) GetV2() *DecodedZookie_V2Zookie { + if x, ok := x.GetVersionOneof().(*DecodedZookie_V2); ok { + return x.V2 + } + return nil +} + +type isDecodedZookie_VersionOneof interface { + isDecodedZookie_VersionOneof() +} + +type DecodedZookie_V1 struct { + V1 *DecodedZookie_V1Zookie `protobuf:"bytes,2,opt,name=v1,proto3,oneof"` +} + +type DecodedZookie_V2 struct { + V2 *DecodedZookie_V2Zookie `protobuf:"bytes,3,opt,name=v2,proto3,oneof"` +} + +func (*DecodedZookie_V1) isDecodedZookie_VersionOneof() {} + +func (*DecodedZookie_V2) isDecodedZookie_VersionOneof() {} + +type DecodedZedToken struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Types that are assignable to VersionOneof: + // + // *DecodedZedToken_DeprecatedV1Zookie + // *DecodedZedToken_V1 + VersionOneof isDecodedZedToken_VersionOneof `protobuf_oneof:"version_oneof"` +} + +func (x *DecodedZedToken) Reset() { + *x = DecodedZedToken{} + if protoimpl.UnsafeEnabled { + mi := &file_impl_v1_impl_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DecodedZedToken) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DecodedZedToken) ProtoMessage() {} + +func (x *DecodedZedToken) ProtoReflect() protoreflect.Message { + mi := &file_impl_v1_impl_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DecodedZedToken.ProtoReflect.Descriptor instead. +func (*DecodedZedToken) Descriptor() ([]byte, []int) { + return file_impl_v1_impl_proto_rawDescGZIP(), []int{2} +} + +func (m *DecodedZedToken) GetVersionOneof() isDecodedZedToken_VersionOneof { + if m != nil { + return m.VersionOneof + } + return nil +} + +func (x *DecodedZedToken) GetDeprecatedV1Zookie() *DecodedZedToken_V1Zookie { + if x, ok := x.GetVersionOneof().(*DecodedZedToken_DeprecatedV1Zookie); ok { + return x.DeprecatedV1Zookie + } + return nil +} + +func (x *DecodedZedToken) GetV1() *DecodedZedToken_V1ZedToken { + if x, ok := x.GetVersionOneof().(*DecodedZedToken_V1); ok { + return x.V1 + } + return nil +} + +type isDecodedZedToken_VersionOneof interface { + isDecodedZedToken_VersionOneof() +} + +type DecodedZedToken_DeprecatedV1Zookie struct { + DeprecatedV1Zookie *DecodedZedToken_V1Zookie `protobuf:"bytes,2,opt,name=deprecated_v1_zookie,json=deprecatedV1Zookie,proto3,oneof"` +} + +type DecodedZedToken_V1 struct { + V1 *DecodedZedToken_V1ZedToken `protobuf:"bytes,3,opt,name=v1,proto3,oneof"` +} + +func (*DecodedZedToken_DeprecatedV1Zookie) isDecodedZedToken_VersionOneof() {} + +func (*DecodedZedToken_V1) isDecodedZedToken_VersionOneof() {} + +type DecodedCursor struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // we do version_oneof in case we decide to add a new version. + // + // Types that are assignable to VersionOneof: + // + // *DecodedCursor_V1 + VersionOneof isDecodedCursor_VersionOneof `protobuf_oneof:"version_oneof"` +} + +func (x *DecodedCursor) Reset() { + *x = DecodedCursor{} + if protoimpl.UnsafeEnabled { + mi := &file_impl_v1_impl_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DecodedCursor) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DecodedCursor) ProtoMessage() {} + +func (x *DecodedCursor) ProtoReflect() protoreflect.Message { + mi := &file_impl_v1_impl_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DecodedCursor.ProtoReflect.Descriptor instead. +func (*DecodedCursor) Descriptor() ([]byte, []int) { + return file_impl_v1_impl_proto_rawDescGZIP(), []int{3} +} + +func (m *DecodedCursor) GetVersionOneof() isDecodedCursor_VersionOneof { + if m != nil { + return m.VersionOneof + } + return nil +} + +func (x *DecodedCursor) GetV1() *V1Cursor { + if x, ok := x.GetVersionOneof().(*DecodedCursor_V1); ok { + return x.V1 + } + return nil +} + +type isDecodedCursor_VersionOneof interface { + isDecodedCursor_VersionOneof() +} + +type DecodedCursor_V1 struct { + V1 *V1Cursor `protobuf:"bytes,1,opt,name=v1,proto3,oneof"` +} + +func (*DecodedCursor_V1) isDecodedCursor_VersionOneof() {} + +type V1Cursor struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // revision is the string form of the revision for the cursor. + Revision string `protobuf:"bytes,1,opt,name=revision,proto3" json:"revision,omitempty"` + // sections are the sections of the dispatching cursor. + Sections []string `protobuf:"bytes,2,rep,name=sections,proto3" json:"sections,omitempty"` + // call_and_parameters_hash is a hash of the call that manufactured this cursor and all its + // parameters, including limits and zedtoken, to ensure no inputs changed when using this cursor. + CallAndParametersHash string `protobuf:"bytes,3,opt,name=call_and_parameters_hash,json=callAndParametersHash,proto3" json:"call_and_parameters_hash,omitempty"` + // dispatch_version is the version of the dispatcher which created the cursor. + DispatchVersion uint32 `protobuf:"varint,4,opt,name=dispatch_version,json=dispatchVersion,proto3" json:"dispatch_version,omitempty"` + // flags are flags set by the API caller. + Flags map[string]string `protobuf:"bytes,5,rep,name=flags,proto3" json:"flags,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` +} + +func (x *V1Cursor) Reset() { + *x = V1Cursor{} + if protoimpl.UnsafeEnabled { + mi := &file_impl_v1_impl_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *V1Cursor) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*V1Cursor) ProtoMessage() {} + +func (x *V1Cursor) ProtoReflect() protoreflect.Message { + mi := &file_impl_v1_impl_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use V1Cursor.ProtoReflect.Descriptor instead. +func (*V1Cursor) Descriptor() ([]byte, []int) { + return file_impl_v1_impl_proto_rawDescGZIP(), []int{4} +} + +func (x *V1Cursor) GetRevision() string { + if x != nil { + return x.Revision + } + return "" +} + +func (x *V1Cursor) GetSections() []string { + if x != nil { + return x.Sections + } + return nil +} + +func (x *V1Cursor) GetCallAndParametersHash() string { + if x != nil { + return x.CallAndParametersHash + } + return "" +} + +func (x *V1Cursor) GetDispatchVersion() uint32 { + if x != nil { + return x.DispatchVersion + } + return 0 +} + +func (x *V1Cursor) GetFlags() map[string]string { + if x != nil { + return x.Flags + } + return nil +} + +type DocComment struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Comment string `protobuf:"bytes,1,opt,name=comment,proto3" json:"comment,omitempty"` +} + +func (x *DocComment) Reset() { + *x = DocComment{} + if protoimpl.UnsafeEnabled { + mi := &file_impl_v1_impl_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DocComment) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DocComment) ProtoMessage() {} + +func (x *DocComment) ProtoReflect() protoreflect.Message { + mi := &file_impl_v1_impl_proto_msgTypes[5] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DocComment.ProtoReflect.Descriptor instead. +func (*DocComment) Descriptor() ([]byte, []int) { + return file_impl_v1_impl_proto_rawDescGZIP(), []int{5} +} + +func (x *DocComment) GetComment() string { + if x != nil { + return x.Comment + } + return "" +} + +type RelationMetadata struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Kind RelationMetadata_RelationKind `protobuf:"varint,1,opt,name=kind,proto3,enum=impl.v1.RelationMetadata_RelationKind" json:"kind,omitempty"` +} + +func (x *RelationMetadata) Reset() { + *x = RelationMetadata{} + if protoimpl.UnsafeEnabled { + mi := &file_impl_v1_impl_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *RelationMetadata) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RelationMetadata) ProtoMessage() {} + +func (x *RelationMetadata) ProtoReflect() protoreflect.Message { + mi := &file_impl_v1_impl_proto_msgTypes[6] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use RelationMetadata.ProtoReflect.Descriptor instead. +func (*RelationMetadata) Descriptor() ([]byte, []int) { + return file_impl_v1_impl_proto_rawDescGZIP(), []int{6} +} + +func (x *RelationMetadata) GetKind() RelationMetadata_RelationKind { + if x != nil { + return x.Kind + } + return RelationMetadata_UNKNOWN_KIND +} + +type NamespaceAndRevision struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + NamespaceName string `protobuf:"bytes,1,opt,name=namespace_name,json=namespaceName,proto3" json:"namespace_name,omitempty"` + Revision string `protobuf:"bytes,2,opt,name=revision,proto3" json:"revision,omitempty"` +} + +func (x *NamespaceAndRevision) Reset() { + *x = NamespaceAndRevision{} + if protoimpl.UnsafeEnabled { + mi := &file_impl_v1_impl_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *NamespaceAndRevision) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*NamespaceAndRevision) ProtoMessage() {} + +func (x *NamespaceAndRevision) ProtoReflect() protoreflect.Message { + mi := &file_impl_v1_impl_proto_msgTypes[7] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use NamespaceAndRevision.ProtoReflect.Descriptor instead. +func (*NamespaceAndRevision) Descriptor() ([]byte, []int) { + return file_impl_v1_impl_proto_rawDescGZIP(), []int{7} +} + +func (x *NamespaceAndRevision) GetNamespaceName() string { + if x != nil { + return x.NamespaceName + } + return "" +} + +func (x *NamespaceAndRevision) GetRevision() string { + if x != nil { + return x.Revision + } + return "" +} + +type V1Alpha1Revision struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + NsRevisions []*NamespaceAndRevision `protobuf:"bytes,1,rep,name=ns_revisions,json=nsRevisions,proto3" json:"ns_revisions,omitempty"` +} + +func (x *V1Alpha1Revision) Reset() { + *x = V1Alpha1Revision{} + if protoimpl.UnsafeEnabled { + mi := &file_impl_v1_impl_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *V1Alpha1Revision) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*V1Alpha1Revision) ProtoMessage() {} + +func (x *V1Alpha1Revision) ProtoReflect() protoreflect.Message { + mi := &file_impl_v1_impl_proto_msgTypes[8] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use V1Alpha1Revision.ProtoReflect.Descriptor instead. +func (*V1Alpha1Revision) Descriptor() ([]byte, []int) { + return file_impl_v1_impl_proto_rawDescGZIP(), []int{8} +} + +func (x *V1Alpha1Revision) GetNsRevisions() []*NamespaceAndRevision { + if x != nil { + return x.NsRevisions + } + return nil +} + +type DecodedZookie_V1Zookie struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Revision uint64 `protobuf:"varint,1,opt,name=revision,proto3" json:"revision,omitempty"` +} + +func (x *DecodedZookie_V1Zookie) Reset() { + *x = DecodedZookie_V1Zookie{} + if protoimpl.UnsafeEnabled { + mi := &file_impl_v1_impl_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DecodedZookie_V1Zookie) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DecodedZookie_V1Zookie) ProtoMessage() {} + +func (x *DecodedZookie_V1Zookie) ProtoReflect() protoreflect.Message { + mi := &file_impl_v1_impl_proto_msgTypes[9] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DecodedZookie_V1Zookie.ProtoReflect.Descriptor instead. +func (*DecodedZookie_V1Zookie) Descriptor() ([]byte, []int) { + return file_impl_v1_impl_proto_rawDescGZIP(), []int{1, 0} +} + +func (x *DecodedZookie_V1Zookie) GetRevision() uint64 { + if x != nil { + return x.Revision + } + return 0 +} + +type DecodedZookie_V2Zookie struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Revision string `protobuf:"bytes,1,opt,name=revision,proto3" json:"revision,omitempty"` +} + +func (x *DecodedZookie_V2Zookie) Reset() { + *x = DecodedZookie_V2Zookie{} + if protoimpl.UnsafeEnabled { + mi := &file_impl_v1_impl_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DecodedZookie_V2Zookie) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DecodedZookie_V2Zookie) ProtoMessage() {} + +func (x *DecodedZookie_V2Zookie) ProtoReflect() protoreflect.Message { + mi := &file_impl_v1_impl_proto_msgTypes[10] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DecodedZookie_V2Zookie.ProtoReflect.Descriptor instead. +func (*DecodedZookie_V2Zookie) Descriptor() ([]byte, []int) { + return file_impl_v1_impl_proto_rawDescGZIP(), []int{1, 1} +} + +func (x *DecodedZookie_V2Zookie) GetRevision() string { + if x != nil { + return x.Revision + } + return "" +} + +type DecodedZedToken_V1Zookie struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Revision uint64 `protobuf:"varint,1,opt,name=revision,proto3" json:"revision,omitempty"` +} + +func (x *DecodedZedToken_V1Zookie) Reset() { + *x = DecodedZedToken_V1Zookie{} + if protoimpl.UnsafeEnabled { + mi := &file_impl_v1_impl_proto_msgTypes[11] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DecodedZedToken_V1Zookie) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DecodedZedToken_V1Zookie) ProtoMessage() {} + +func (x *DecodedZedToken_V1Zookie) ProtoReflect() protoreflect.Message { + mi := &file_impl_v1_impl_proto_msgTypes[11] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DecodedZedToken_V1Zookie.ProtoReflect.Descriptor instead. +func (*DecodedZedToken_V1Zookie) Descriptor() ([]byte, []int) { + return file_impl_v1_impl_proto_rawDescGZIP(), []int{2, 0} +} + +func (x *DecodedZedToken_V1Zookie) GetRevision() uint64 { + if x != nil { + return x.Revision + } + return 0 +} + +type DecodedZedToken_V1ZedToken struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Revision string `protobuf:"bytes,1,opt,name=revision,proto3" json:"revision,omitempty"` +} + +func (x *DecodedZedToken_V1ZedToken) Reset() { + *x = DecodedZedToken_V1ZedToken{} + if protoimpl.UnsafeEnabled { + mi := &file_impl_v1_impl_proto_msgTypes[12] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DecodedZedToken_V1ZedToken) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DecodedZedToken_V1ZedToken) ProtoMessage() {} + +func (x *DecodedZedToken_V1ZedToken) ProtoReflect() protoreflect.Message { + mi := &file_impl_v1_impl_proto_msgTypes[12] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DecodedZedToken_V1ZedToken.ProtoReflect.Descriptor instead. +func (*DecodedZedToken_V1ZedToken) Descriptor() ([]byte, []int) { + return file_impl_v1_impl_proto_rawDescGZIP(), []int{2, 1} +} + +func (x *DecodedZedToken_V1ZedToken) GetRevision() string { + if x != nil { + return x.Revision + } + return "" +} + +var File_impl_v1_impl_proto protoreflect.FileDescriptor + +var file_impl_v1_impl_proto_rawDesc = []byte{ + 0x0a, 0x12, 0x69, 0x6d, 0x70, 0x6c, 0x2f, 0x76, 0x31, 0x2f, 0x69, 0x6d, 0x70, 0x6c, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x07, 0x69, 0x6d, 0x70, 0x6c, 0x2e, 0x76, 0x31, 0x1a, 0x26, 0x67, + 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x65, 0x78, 0x70, 0x72, 0x2f, 0x76, + 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2f, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x65, 0x64, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x6c, 0x0a, 0x0d, 0x44, 0x65, 0x63, 0x6f, 0x64, 0x65, 0x64, + 0x43, 0x61, 0x76, 0x65, 0x61, 0x74, 0x12, 0x39, 0x0a, 0x03, 0x63, 0x65, 0x6c, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x61, 0x70, 0x69, + 0x2e, 0x65, 0x78, 0x70, 0x72, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x43, + 0x68, 0x65, 0x63, 0x6b, 0x65, 0x64, 0x45, 0x78, 0x70, 0x72, 0x48, 0x00, 0x52, 0x03, 0x63, 0x65, + 0x6c, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x42, 0x0c, 0x0a, 0x0a, 0x6b, 0x69, 0x6e, 0x64, 0x5f, 0x6f, 0x6e, + 0x65, 0x6f, 0x66, 0x22, 0xf0, 0x01, 0x0a, 0x0d, 0x44, 0x65, 0x63, 0x6f, 0x64, 0x65, 0x64, 0x5a, + 0x6f, 0x6f, 0x6b, 0x69, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, + 0x31, 0x0a, 0x02, 0x76, 0x31, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x69, 0x6d, + 0x70, 0x6c, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x65, 0x63, 0x6f, 0x64, 0x65, 0x64, 0x5a, 0x6f, 0x6f, + 0x6b, 0x69, 0x65, 0x2e, 0x56, 0x31, 0x5a, 0x6f, 0x6f, 0x6b, 0x69, 0x65, 0x48, 0x00, 0x52, 0x02, + 0x76, 0x31, 0x12, 0x31, 0x0a, 0x02, 0x76, 0x32, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1f, + 0x2e, 0x69, 0x6d, 0x70, 0x6c, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x65, 0x63, 0x6f, 0x64, 0x65, 0x64, + 0x5a, 0x6f, 0x6f, 0x6b, 0x69, 0x65, 0x2e, 0x56, 0x32, 0x5a, 0x6f, 0x6f, 0x6b, 0x69, 0x65, 0x48, + 0x00, 0x52, 0x02, 0x76, 0x32, 0x1a, 0x26, 0x0a, 0x08, 0x56, 0x31, 0x5a, 0x6f, 0x6f, 0x6b, 0x69, + 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x65, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x04, 0x52, 0x08, 0x72, 0x65, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x1a, 0x26, 0x0a, + 0x08, 0x56, 0x32, 0x5a, 0x6f, 0x6f, 0x6b, 0x69, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x65, 0x76, + 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x72, 0x65, 0x76, + 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x42, 0x0f, 0x0a, 0x0d, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, + 0x5f, 0x6f, 0x6e, 0x65, 0x6f, 0x66, 0x22, 0x82, 0x02, 0x0a, 0x0f, 0x44, 0x65, 0x63, 0x6f, 0x64, + 0x65, 0x64, 0x5a, 0x65, 0x64, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x55, 0x0a, 0x14, 0x64, 0x65, + 0x70, 0x72, 0x65, 0x63, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x76, 0x31, 0x5f, 0x7a, 0x6f, 0x6f, 0x6b, + 0x69, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x69, 0x6d, 0x70, 0x6c, 0x2e, + 0x76, 0x31, 0x2e, 0x44, 0x65, 0x63, 0x6f, 0x64, 0x65, 0x64, 0x5a, 0x65, 0x64, 0x54, 0x6f, 0x6b, + 0x65, 0x6e, 0x2e, 0x56, 0x31, 0x5a, 0x6f, 0x6f, 0x6b, 0x69, 0x65, 0x48, 0x00, 0x52, 0x12, 0x64, + 0x65, 0x70, 0x72, 0x65, 0x63, 0x61, 0x74, 0x65, 0x64, 0x56, 0x31, 0x5a, 0x6f, 0x6f, 0x6b, 0x69, + 0x65, 0x12, 0x35, 0x0a, 0x02, 0x76, 0x31, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x23, 0x2e, + 0x69, 0x6d, 0x70, 0x6c, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x65, 0x63, 0x6f, 0x64, 0x65, 0x64, 0x5a, + 0x65, 0x64, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x2e, 0x56, 0x31, 0x5a, 0x65, 0x64, 0x54, 0x6f, 0x6b, + 0x65, 0x6e, 0x48, 0x00, 0x52, 0x02, 0x76, 0x31, 0x1a, 0x26, 0x0a, 0x08, 0x56, 0x31, 0x5a, 0x6f, + 0x6f, 0x6b, 0x69, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x65, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x08, 0x72, 0x65, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, + 0x1a, 0x28, 0x0a, 0x0a, 0x56, 0x31, 0x5a, 0x65, 0x64, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x1a, + 0x0a, 0x08, 0x72, 0x65, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x08, 0x72, 0x65, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x42, 0x0f, 0x0a, 0x0d, 0x76, 0x65, + 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x5f, 0x6f, 0x6e, 0x65, 0x6f, 0x66, 0x22, 0x45, 0x0a, 0x0d, 0x44, + 0x65, 0x63, 0x6f, 0x64, 0x65, 0x64, 0x43, 0x75, 0x72, 0x73, 0x6f, 0x72, 0x12, 0x23, 0x0a, 0x02, + 0x76, 0x31, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x69, 0x6d, 0x70, 0x6c, 0x2e, + 0x76, 0x31, 0x2e, 0x56, 0x31, 0x43, 0x75, 0x72, 0x73, 0x6f, 0x72, 0x48, 0x00, 0x52, 0x02, 0x76, + 0x31, 0x42, 0x0f, 0x0a, 0x0d, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x5f, 0x6f, 0x6e, 0x65, + 0x6f, 0x66, 0x22, 0x94, 0x02, 0x0a, 0x08, 0x56, 0x31, 0x43, 0x75, 0x72, 0x73, 0x6f, 0x72, 0x12, + 0x1a, 0x0a, 0x08, 0x72, 0x65, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x08, 0x72, 0x65, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x1a, 0x0a, 0x08, 0x73, + 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x08, 0x73, + 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x37, 0x0a, 0x18, 0x63, 0x61, 0x6c, 0x6c, 0x5f, + 0x61, 0x6e, 0x64, 0x5f, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x73, 0x5f, 0x68, + 0x61, 0x73, 0x68, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x15, 0x63, 0x61, 0x6c, 0x6c, 0x41, + 0x6e, 0x64, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x73, 0x48, 0x61, 0x73, 0x68, + 0x12, 0x29, 0x0a, 0x10, 0x64, 0x69, 0x73, 0x70, 0x61, 0x74, 0x63, 0x68, 0x5f, 0x76, 0x65, 0x72, + 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0f, 0x64, 0x69, 0x73, 0x70, + 0x61, 0x74, 0x63, 0x68, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x32, 0x0a, 0x05, 0x66, + 0x6c, 0x61, 0x67, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x69, 0x6d, 0x70, + 0x6c, 0x2e, 0x76, 0x31, 0x2e, 0x56, 0x31, 0x43, 0x75, 0x72, 0x73, 0x6f, 0x72, 0x2e, 0x46, 0x6c, + 0x61, 0x67, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x05, 0x66, 0x6c, 0x61, 0x67, 0x73, 0x1a, + 0x38, 0x0a, 0x0a, 0x46, 0x6c, 0x61, 0x67, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, + 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, + 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, + 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x26, 0x0a, 0x0a, 0x44, 0x6f, 0x63, + 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x65, + 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, + 0x74, 0x22, 0x8e, 0x01, 0x0a, 0x10, 0x52, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4d, 0x65, + 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, 0x3a, 0x0a, 0x04, 0x6b, 0x69, 0x6e, 0x64, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x0e, 0x32, 0x26, 0x2e, 0x69, 0x6d, 0x70, 0x6c, 0x2e, 0x76, 0x31, 0x2e, 0x52, + 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x2e, + 0x52, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4b, 0x69, 0x6e, 0x64, 0x52, 0x04, 0x6b, 0x69, + 0x6e, 0x64, 0x22, 0x3e, 0x0a, 0x0c, 0x52, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4b, 0x69, + 0x6e, 0x64, 0x12, 0x10, 0x0a, 0x0c, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x5f, 0x4b, 0x49, + 0x4e, 0x44, 0x10, 0x00, 0x12, 0x0c, 0x0a, 0x08, 0x52, 0x45, 0x4c, 0x41, 0x54, 0x49, 0x4f, 0x4e, + 0x10, 0x01, 0x12, 0x0e, 0x0a, 0x0a, 0x50, 0x45, 0x52, 0x4d, 0x49, 0x53, 0x53, 0x49, 0x4f, 0x4e, + 0x10, 0x02, 0x22, 0x59, 0x0a, 0x14, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x41, + 0x6e, 0x64, 0x52, 0x65, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x25, 0x0a, 0x0e, 0x6e, 0x61, + 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x0d, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x4e, 0x61, 0x6d, + 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x65, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x08, 0x72, 0x65, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x54, 0x0a, + 0x10, 0x56, 0x31, 0x41, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x52, 0x65, 0x76, 0x69, 0x73, 0x69, 0x6f, + 0x6e, 0x12, 0x40, 0x0a, 0x0c, 0x6e, 0x73, 0x5f, 0x72, 0x65, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, + 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x69, 0x6d, 0x70, 0x6c, 0x2e, 0x76, + 0x31, 0x2e, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x41, 0x6e, 0x64, 0x52, 0x65, + 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x0b, 0x6e, 0x73, 0x52, 0x65, 0x76, 0x69, 0x73, 0x69, + 0x6f, 0x6e, 0x73, 0x42, 0x8a, 0x01, 0x0a, 0x0b, 0x63, 0x6f, 0x6d, 0x2e, 0x69, 0x6d, 0x70, 0x6c, + 0x2e, 0x76, 0x31, 0x42, 0x09, 0x49, 0x6d, 0x70, 0x6c, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, + 0x5a, 0x33, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x61, 0x75, 0x74, + 0x68, 0x7a, 0x65, 0x64, 0x2f, 0x73, 0x70, 0x69, 0x63, 0x65, 0x64, 0x62, 0x2f, 0x70, 0x6b, 0x67, + 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x69, 0x6d, 0x70, 0x6c, 0x2f, 0x76, 0x31, 0x3b, 0x69, + 0x6d, 0x70, 0x6c, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x49, 0x58, 0x58, 0xaa, 0x02, 0x07, 0x49, 0x6d, + 0x70, 0x6c, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x07, 0x49, 0x6d, 0x70, 0x6c, 0x5c, 0x56, 0x31, 0xe2, + 0x02, 0x13, 0x49, 0x6d, 0x70, 0x6c, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, + 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x08, 0x49, 0x6d, 0x70, 0x6c, 0x3a, 0x3a, 0x56, 0x31, + 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_impl_v1_impl_proto_rawDescOnce sync.Once + file_impl_v1_impl_proto_rawDescData = file_impl_v1_impl_proto_rawDesc +) + +func file_impl_v1_impl_proto_rawDescGZIP() []byte { + file_impl_v1_impl_proto_rawDescOnce.Do(func() { + file_impl_v1_impl_proto_rawDescData = protoimpl.X.CompressGZIP(file_impl_v1_impl_proto_rawDescData) + }) + return file_impl_v1_impl_proto_rawDescData +} + +var file_impl_v1_impl_proto_enumTypes = make([]protoimpl.EnumInfo, 1) +var file_impl_v1_impl_proto_msgTypes = make([]protoimpl.MessageInfo, 14) +var file_impl_v1_impl_proto_goTypes = []any{ + (RelationMetadata_RelationKind)(0), // 0: impl.v1.RelationMetadata.RelationKind + (*DecodedCaveat)(nil), // 1: impl.v1.DecodedCaveat + (*DecodedZookie)(nil), // 2: impl.v1.DecodedZookie + (*DecodedZedToken)(nil), // 3: impl.v1.DecodedZedToken + (*DecodedCursor)(nil), // 4: impl.v1.DecodedCursor + (*V1Cursor)(nil), // 5: impl.v1.V1Cursor + (*DocComment)(nil), // 6: impl.v1.DocComment + (*RelationMetadata)(nil), // 7: impl.v1.RelationMetadata + (*NamespaceAndRevision)(nil), // 8: impl.v1.NamespaceAndRevision + (*V1Alpha1Revision)(nil), // 9: impl.v1.V1Alpha1Revision + (*DecodedZookie_V1Zookie)(nil), // 10: impl.v1.DecodedZookie.V1Zookie + (*DecodedZookie_V2Zookie)(nil), // 11: impl.v1.DecodedZookie.V2Zookie + (*DecodedZedToken_V1Zookie)(nil), // 12: impl.v1.DecodedZedToken.V1Zookie + (*DecodedZedToken_V1ZedToken)(nil), // 13: impl.v1.DecodedZedToken.V1ZedToken + nil, // 14: impl.v1.V1Cursor.FlagsEntry + (*v1alpha1.CheckedExpr)(nil), // 15: google.api.expr.v1alpha1.CheckedExpr +} +var file_impl_v1_impl_proto_depIdxs = []int32{ + 15, // 0: impl.v1.DecodedCaveat.cel:type_name -> google.api.expr.v1alpha1.CheckedExpr + 10, // 1: impl.v1.DecodedZookie.v1:type_name -> impl.v1.DecodedZookie.V1Zookie + 11, // 2: impl.v1.DecodedZookie.v2:type_name -> impl.v1.DecodedZookie.V2Zookie + 12, // 3: impl.v1.DecodedZedToken.deprecated_v1_zookie:type_name -> impl.v1.DecodedZedToken.V1Zookie + 13, // 4: impl.v1.DecodedZedToken.v1:type_name -> impl.v1.DecodedZedToken.V1ZedToken + 5, // 5: impl.v1.DecodedCursor.v1:type_name -> impl.v1.V1Cursor + 14, // 6: impl.v1.V1Cursor.flags:type_name -> impl.v1.V1Cursor.FlagsEntry + 0, // 7: impl.v1.RelationMetadata.kind:type_name -> impl.v1.RelationMetadata.RelationKind + 8, // 8: impl.v1.V1Alpha1Revision.ns_revisions:type_name -> impl.v1.NamespaceAndRevision + 9, // [9:9] is the sub-list for method output_type + 9, // [9:9] is the sub-list for method input_type + 9, // [9:9] is the sub-list for extension type_name + 9, // [9:9] is the sub-list for extension extendee + 0, // [0:9] is the sub-list for field type_name +} + +func init() { file_impl_v1_impl_proto_init() } +func file_impl_v1_impl_proto_init() { + if File_impl_v1_impl_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_impl_v1_impl_proto_msgTypes[0].Exporter = func(v any, i int) any { + switch v := v.(*DecodedCaveat); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_impl_v1_impl_proto_msgTypes[1].Exporter = func(v any, i int) any { + switch v := v.(*DecodedZookie); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_impl_v1_impl_proto_msgTypes[2].Exporter = func(v any, i int) any { + switch v := v.(*DecodedZedToken); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_impl_v1_impl_proto_msgTypes[3].Exporter = func(v any, i int) any { + switch v := v.(*DecodedCursor); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_impl_v1_impl_proto_msgTypes[4].Exporter = func(v any, i int) any { + switch v := v.(*V1Cursor); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_impl_v1_impl_proto_msgTypes[5].Exporter = func(v any, i int) any { + switch v := v.(*DocComment); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_impl_v1_impl_proto_msgTypes[6].Exporter = func(v any, i int) any { + switch v := v.(*RelationMetadata); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_impl_v1_impl_proto_msgTypes[7].Exporter = func(v any, i int) any { + switch v := v.(*NamespaceAndRevision); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_impl_v1_impl_proto_msgTypes[8].Exporter = func(v any, i int) any { + switch v := v.(*V1Alpha1Revision); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_impl_v1_impl_proto_msgTypes[9].Exporter = func(v any, i int) any { + switch v := v.(*DecodedZookie_V1Zookie); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_impl_v1_impl_proto_msgTypes[10].Exporter = func(v any, i int) any { + switch v := v.(*DecodedZookie_V2Zookie); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_impl_v1_impl_proto_msgTypes[11].Exporter = func(v any, i int) any { + switch v := v.(*DecodedZedToken_V1Zookie); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_impl_v1_impl_proto_msgTypes[12].Exporter = func(v any, i int) any { + switch v := v.(*DecodedZedToken_V1ZedToken); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + file_impl_v1_impl_proto_msgTypes[0].OneofWrappers = []any{ + (*DecodedCaveat_Cel)(nil), + } + file_impl_v1_impl_proto_msgTypes[1].OneofWrappers = []any{ + (*DecodedZookie_V1)(nil), + (*DecodedZookie_V2)(nil), + } + file_impl_v1_impl_proto_msgTypes[2].OneofWrappers = []any{ + (*DecodedZedToken_DeprecatedV1Zookie)(nil), + (*DecodedZedToken_V1)(nil), + } + file_impl_v1_impl_proto_msgTypes[3].OneofWrappers = []any{ + (*DecodedCursor_V1)(nil), + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_impl_v1_impl_proto_rawDesc, + NumEnums: 1, + NumMessages: 14, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_impl_v1_impl_proto_goTypes, + DependencyIndexes: file_impl_v1_impl_proto_depIdxs, + EnumInfos: file_impl_v1_impl_proto_enumTypes, + MessageInfos: file_impl_v1_impl_proto_msgTypes, + }.Build() + File_impl_v1_impl_proto = out.File + file_impl_v1_impl_proto_rawDesc = nil + file_impl_v1_impl_proto_goTypes = nil + file_impl_v1_impl_proto_depIdxs = nil +} diff --git a/vendor/github.com/authzed/spicedb/pkg/proto/impl/v1/impl.pb.validate.go b/vendor/github.com/authzed/spicedb/pkg/proto/impl/v1/impl.pb.validate.go new file mode 100644 index 0000000..dea8479 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/proto/impl/v1/impl.pb.validate.go @@ -0,0 +1,1672 @@ +// Code generated by protoc-gen-validate. DO NOT EDIT. +// source: impl/v1/impl.proto + +package implv1 + +import ( + "bytes" + "errors" + "fmt" + "net" + "net/mail" + "net/url" + "regexp" + "sort" + "strings" + "time" + "unicode/utf8" + + "google.golang.org/protobuf/types/known/anypb" +) + +// ensure the imports are used +var ( + _ = bytes.MinRead + _ = errors.New("") + _ = fmt.Print + _ = utf8.UTFMax + _ = (*regexp.Regexp)(nil) + _ = (*strings.Reader)(nil) + _ = net.IPv4len + _ = time.Duration(0) + _ = (*url.URL)(nil) + _ = (*mail.Address)(nil) + _ = anypb.Any{} + _ = sort.Sort +) + +// Validate checks the field values on DecodedCaveat with the rules defined in +// the proto definition for this message. If any rules are violated, the first +// error encountered is returned, or nil if there are no violations. +func (m *DecodedCaveat) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on DecodedCaveat with the rules defined +// in the proto definition for this message. If any rules are violated, the +// result is a list of violation errors wrapped in DecodedCaveatMultiError, or +// nil if none found. +func (m *DecodedCaveat) ValidateAll() error { + return m.validate(true) +} + +func (m *DecodedCaveat) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Name + + switch v := m.KindOneof.(type) { + case *DecodedCaveat_Cel: + if v == nil { + err := DecodedCaveatValidationError{ + field: "KindOneof", + reason: "oneof value cannot be a typed-nil", + } + if !all { + return err + } + errors = append(errors, err) + } + + if all { + switch v := interface{}(m.GetCel()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, DecodedCaveatValidationError{ + field: "Cel", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, DecodedCaveatValidationError{ + field: "Cel", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetCel()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return DecodedCaveatValidationError{ + field: "Cel", + reason: "embedded message failed validation", + cause: err, + } + } + } + + default: + _ = v // ensures v is used + } + + if len(errors) > 0 { + return DecodedCaveatMultiError(errors) + } + + return nil +} + +// DecodedCaveatMultiError is an error wrapping multiple validation errors +// returned by DecodedCaveat.ValidateAll() if the designated constraints +// aren't met. +type DecodedCaveatMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m DecodedCaveatMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m DecodedCaveatMultiError) AllErrors() []error { return m } + +// DecodedCaveatValidationError is the validation error returned by +// DecodedCaveat.Validate if the designated constraints aren't met. +type DecodedCaveatValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e DecodedCaveatValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e DecodedCaveatValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e DecodedCaveatValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e DecodedCaveatValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e DecodedCaveatValidationError) ErrorName() string { return "DecodedCaveatValidationError" } + +// Error satisfies the builtin error interface +func (e DecodedCaveatValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sDecodedCaveat.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = DecodedCaveatValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = DecodedCaveatValidationError{} + +// Validate checks the field values on DecodedZookie with the rules defined in +// the proto definition for this message. If any rules are violated, the first +// error encountered is returned, or nil if there are no violations. +func (m *DecodedZookie) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on DecodedZookie with the rules defined +// in the proto definition for this message. If any rules are violated, the +// result is a list of violation errors wrapped in DecodedZookieMultiError, or +// nil if none found. +func (m *DecodedZookie) ValidateAll() error { + return m.validate(true) +} + +func (m *DecodedZookie) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Version + + switch v := m.VersionOneof.(type) { + case *DecodedZookie_V1: + if v == nil { + err := DecodedZookieValidationError{ + field: "VersionOneof", + reason: "oneof value cannot be a typed-nil", + } + if !all { + return err + } + errors = append(errors, err) + } + + if all { + switch v := interface{}(m.GetV1()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, DecodedZookieValidationError{ + field: "V1", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, DecodedZookieValidationError{ + field: "V1", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetV1()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return DecodedZookieValidationError{ + field: "V1", + reason: "embedded message failed validation", + cause: err, + } + } + } + + case *DecodedZookie_V2: + if v == nil { + err := DecodedZookieValidationError{ + field: "VersionOneof", + reason: "oneof value cannot be a typed-nil", + } + if !all { + return err + } + errors = append(errors, err) + } + + if all { + switch v := interface{}(m.GetV2()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, DecodedZookieValidationError{ + field: "V2", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, DecodedZookieValidationError{ + field: "V2", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetV2()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return DecodedZookieValidationError{ + field: "V2", + reason: "embedded message failed validation", + cause: err, + } + } + } + + default: + _ = v // ensures v is used + } + + if len(errors) > 0 { + return DecodedZookieMultiError(errors) + } + + return nil +} + +// DecodedZookieMultiError is an error wrapping multiple validation errors +// returned by DecodedZookie.ValidateAll() if the designated constraints +// aren't met. +type DecodedZookieMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m DecodedZookieMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m DecodedZookieMultiError) AllErrors() []error { return m } + +// DecodedZookieValidationError is the validation error returned by +// DecodedZookie.Validate if the designated constraints aren't met. +type DecodedZookieValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e DecodedZookieValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e DecodedZookieValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e DecodedZookieValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e DecodedZookieValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e DecodedZookieValidationError) ErrorName() string { return "DecodedZookieValidationError" } + +// Error satisfies the builtin error interface +func (e DecodedZookieValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sDecodedZookie.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = DecodedZookieValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = DecodedZookieValidationError{} + +// Validate checks the field values on DecodedZedToken with the rules defined +// in the proto definition for this message. If any rules are violated, the +// first error encountered is returned, or nil if there are no violations. +func (m *DecodedZedToken) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on DecodedZedToken with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// DecodedZedTokenMultiError, or nil if none found. +func (m *DecodedZedToken) ValidateAll() error { + return m.validate(true) +} + +func (m *DecodedZedToken) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + switch v := m.VersionOneof.(type) { + case *DecodedZedToken_DeprecatedV1Zookie: + if v == nil { + err := DecodedZedTokenValidationError{ + field: "VersionOneof", + reason: "oneof value cannot be a typed-nil", + } + if !all { + return err + } + errors = append(errors, err) + } + + if all { + switch v := interface{}(m.GetDeprecatedV1Zookie()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, DecodedZedTokenValidationError{ + field: "DeprecatedV1Zookie", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, DecodedZedTokenValidationError{ + field: "DeprecatedV1Zookie", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetDeprecatedV1Zookie()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return DecodedZedTokenValidationError{ + field: "DeprecatedV1Zookie", + reason: "embedded message failed validation", + cause: err, + } + } + } + + case *DecodedZedToken_V1: + if v == nil { + err := DecodedZedTokenValidationError{ + field: "VersionOneof", + reason: "oneof value cannot be a typed-nil", + } + if !all { + return err + } + errors = append(errors, err) + } + + if all { + switch v := interface{}(m.GetV1()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, DecodedZedTokenValidationError{ + field: "V1", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, DecodedZedTokenValidationError{ + field: "V1", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetV1()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return DecodedZedTokenValidationError{ + field: "V1", + reason: "embedded message failed validation", + cause: err, + } + } + } + + default: + _ = v // ensures v is used + } + + if len(errors) > 0 { + return DecodedZedTokenMultiError(errors) + } + + return nil +} + +// DecodedZedTokenMultiError is an error wrapping multiple validation errors +// returned by DecodedZedToken.ValidateAll() if the designated constraints +// aren't met. +type DecodedZedTokenMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m DecodedZedTokenMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m DecodedZedTokenMultiError) AllErrors() []error { return m } + +// DecodedZedTokenValidationError is the validation error returned by +// DecodedZedToken.Validate if the designated constraints aren't met. +type DecodedZedTokenValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e DecodedZedTokenValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e DecodedZedTokenValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e DecodedZedTokenValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e DecodedZedTokenValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e DecodedZedTokenValidationError) ErrorName() string { return "DecodedZedTokenValidationError" } + +// Error satisfies the builtin error interface +func (e DecodedZedTokenValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sDecodedZedToken.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = DecodedZedTokenValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = DecodedZedTokenValidationError{} + +// Validate checks the field values on DecodedCursor with the rules defined in +// the proto definition for this message. If any rules are violated, the first +// error encountered is returned, or nil if there are no violations. +func (m *DecodedCursor) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on DecodedCursor with the rules defined +// in the proto definition for this message. If any rules are violated, the +// result is a list of violation errors wrapped in DecodedCursorMultiError, or +// nil if none found. +func (m *DecodedCursor) ValidateAll() error { + return m.validate(true) +} + +func (m *DecodedCursor) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + switch v := m.VersionOneof.(type) { + case *DecodedCursor_V1: + if v == nil { + err := DecodedCursorValidationError{ + field: "VersionOneof", + reason: "oneof value cannot be a typed-nil", + } + if !all { + return err + } + errors = append(errors, err) + } + + if all { + switch v := interface{}(m.GetV1()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, DecodedCursorValidationError{ + field: "V1", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, DecodedCursorValidationError{ + field: "V1", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetV1()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return DecodedCursorValidationError{ + field: "V1", + reason: "embedded message failed validation", + cause: err, + } + } + } + + default: + _ = v // ensures v is used + } + + if len(errors) > 0 { + return DecodedCursorMultiError(errors) + } + + return nil +} + +// DecodedCursorMultiError is an error wrapping multiple validation errors +// returned by DecodedCursor.ValidateAll() if the designated constraints +// aren't met. +type DecodedCursorMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m DecodedCursorMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m DecodedCursorMultiError) AllErrors() []error { return m } + +// DecodedCursorValidationError is the validation error returned by +// DecodedCursor.Validate if the designated constraints aren't met. +type DecodedCursorValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e DecodedCursorValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e DecodedCursorValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e DecodedCursorValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e DecodedCursorValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e DecodedCursorValidationError) ErrorName() string { return "DecodedCursorValidationError" } + +// Error satisfies the builtin error interface +func (e DecodedCursorValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sDecodedCursor.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = DecodedCursorValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = DecodedCursorValidationError{} + +// Validate checks the field values on V1Cursor with the rules defined in the +// proto definition for this message. If any rules are violated, the first +// error encountered is returned, or nil if there are no violations. +func (m *V1Cursor) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on V1Cursor with the rules defined in +// the proto definition for this message. If any rules are violated, the +// result is a list of violation errors wrapped in V1CursorMultiError, or nil +// if none found. +func (m *V1Cursor) ValidateAll() error { + return m.validate(true) +} + +func (m *V1Cursor) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Revision + + // no validation rules for CallAndParametersHash + + // no validation rules for DispatchVersion + + // no validation rules for Flags + + if len(errors) > 0 { + return V1CursorMultiError(errors) + } + + return nil +} + +// V1CursorMultiError is an error wrapping multiple validation errors returned +// by V1Cursor.ValidateAll() if the designated constraints aren't met. +type V1CursorMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m V1CursorMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m V1CursorMultiError) AllErrors() []error { return m } + +// V1CursorValidationError is the validation error returned by +// V1Cursor.Validate if the designated constraints aren't met. +type V1CursorValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e V1CursorValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e V1CursorValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e V1CursorValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e V1CursorValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e V1CursorValidationError) ErrorName() string { return "V1CursorValidationError" } + +// Error satisfies the builtin error interface +func (e V1CursorValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sV1Cursor.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = V1CursorValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = V1CursorValidationError{} + +// Validate checks the field values on DocComment with the rules defined in the +// proto definition for this message. If any rules are violated, the first +// error encountered is returned, or nil if there are no violations. +func (m *DocComment) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on DocComment with the rules defined in +// the proto definition for this message. If any rules are violated, the +// result is a list of violation errors wrapped in DocCommentMultiError, or +// nil if none found. +func (m *DocComment) ValidateAll() error { + return m.validate(true) +} + +func (m *DocComment) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Comment + + if len(errors) > 0 { + return DocCommentMultiError(errors) + } + + return nil +} + +// DocCommentMultiError is an error wrapping multiple validation errors +// returned by DocComment.ValidateAll() if the designated constraints aren't met. +type DocCommentMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m DocCommentMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m DocCommentMultiError) AllErrors() []error { return m } + +// DocCommentValidationError is the validation error returned by +// DocComment.Validate if the designated constraints aren't met. +type DocCommentValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e DocCommentValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e DocCommentValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e DocCommentValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e DocCommentValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e DocCommentValidationError) ErrorName() string { return "DocCommentValidationError" } + +// Error satisfies the builtin error interface +func (e DocCommentValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sDocComment.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = DocCommentValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = DocCommentValidationError{} + +// Validate checks the field values on RelationMetadata with the rules defined +// in the proto definition for this message. If any rules are violated, the +// first error encountered is returned, or nil if there are no violations. +func (m *RelationMetadata) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on RelationMetadata with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// RelationMetadataMultiError, or nil if none found. +func (m *RelationMetadata) ValidateAll() error { + return m.validate(true) +} + +func (m *RelationMetadata) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Kind + + if len(errors) > 0 { + return RelationMetadataMultiError(errors) + } + + return nil +} + +// RelationMetadataMultiError is an error wrapping multiple validation errors +// returned by RelationMetadata.ValidateAll() if the designated constraints +// aren't met. +type RelationMetadataMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m RelationMetadataMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m RelationMetadataMultiError) AllErrors() []error { return m } + +// RelationMetadataValidationError is the validation error returned by +// RelationMetadata.Validate if the designated constraints aren't met. +type RelationMetadataValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e RelationMetadataValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e RelationMetadataValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e RelationMetadataValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e RelationMetadataValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e RelationMetadataValidationError) ErrorName() string { return "RelationMetadataValidationError" } + +// Error satisfies the builtin error interface +func (e RelationMetadataValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sRelationMetadata.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = RelationMetadataValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = RelationMetadataValidationError{} + +// Validate checks the field values on NamespaceAndRevision with the rules +// defined in the proto definition for this message. If any rules are +// violated, the first error encountered is returned, or nil if there are no violations. +func (m *NamespaceAndRevision) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on NamespaceAndRevision with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// NamespaceAndRevisionMultiError, or nil if none found. +func (m *NamespaceAndRevision) ValidateAll() error { + return m.validate(true) +} + +func (m *NamespaceAndRevision) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for NamespaceName + + // no validation rules for Revision + + if len(errors) > 0 { + return NamespaceAndRevisionMultiError(errors) + } + + return nil +} + +// NamespaceAndRevisionMultiError is an error wrapping multiple validation +// errors returned by NamespaceAndRevision.ValidateAll() if the designated +// constraints aren't met. +type NamespaceAndRevisionMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m NamespaceAndRevisionMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m NamespaceAndRevisionMultiError) AllErrors() []error { return m } + +// NamespaceAndRevisionValidationError is the validation error returned by +// NamespaceAndRevision.Validate if the designated constraints aren't met. +type NamespaceAndRevisionValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e NamespaceAndRevisionValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e NamespaceAndRevisionValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e NamespaceAndRevisionValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e NamespaceAndRevisionValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e NamespaceAndRevisionValidationError) ErrorName() string { + return "NamespaceAndRevisionValidationError" +} + +// Error satisfies the builtin error interface +func (e NamespaceAndRevisionValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sNamespaceAndRevision.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = NamespaceAndRevisionValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = NamespaceAndRevisionValidationError{} + +// Validate checks the field values on V1Alpha1Revision with the rules defined +// in the proto definition for this message. If any rules are violated, the +// first error encountered is returned, or nil if there are no violations. +func (m *V1Alpha1Revision) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on V1Alpha1Revision with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// V1Alpha1RevisionMultiError, or nil if none found. +func (m *V1Alpha1Revision) ValidateAll() error { + return m.validate(true) +} + +func (m *V1Alpha1Revision) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + for idx, item := range m.GetNsRevisions() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, V1Alpha1RevisionValidationError{ + field: fmt.Sprintf("NsRevisions[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, V1Alpha1RevisionValidationError{ + field: fmt.Sprintf("NsRevisions[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return V1Alpha1RevisionValidationError{ + field: fmt.Sprintf("NsRevisions[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + if len(errors) > 0 { + return V1Alpha1RevisionMultiError(errors) + } + + return nil +} + +// V1Alpha1RevisionMultiError is an error wrapping multiple validation errors +// returned by V1Alpha1Revision.ValidateAll() if the designated constraints +// aren't met. +type V1Alpha1RevisionMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m V1Alpha1RevisionMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m V1Alpha1RevisionMultiError) AllErrors() []error { return m } + +// V1Alpha1RevisionValidationError is the validation error returned by +// V1Alpha1Revision.Validate if the designated constraints aren't met. +type V1Alpha1RevisionValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e V1Alpha1RevisionValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e V1Alpha1RevisionValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e V1Alpha1RevisionValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e V1Alpha1RevisionValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e V1Alpha1RevisionValidationError) ErrorName() string { return "V1Alpha1RevisionValidationError" } + +// Error satisfies the builtin error interface +func (e V1Alpha1RevisionValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sV1Alpha1Revision.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = V1Alpha1RevisionValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = V1Alpha1RevisionValidationError{} + +// Validate checks the field values on DecodedZookie_V1Zookie with the rules +// defined in the proto definition for this message. If any rules are +// violated, the first error encountered is returned, or nil if there are no violations. +func (m *DecodedZookie_V1Zookie) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on DecodedZookie_V1Zookie with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// DecodedZookie_V1ZookieMultiError, or nil if none found. +func (m *DecodedZookie_V1Zookie) ValidateAll() error { + return m.validate(true) +} + +func (m *DecodedZookie_V1Zookie) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Revision + + if len(errors) > 0 { + return DecodedZookie_V1ZookieMultiError(errors) + } + + return nil +} + +// DecodedZookie_V1ZookieMultiError is an error wrapping multiple validation +// errors returned by DecodedZookie_V1Zookie.ValidateAll() if the designated +// constraints aren't met. +type DecodedZookie_V1ZookieMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m DecodedZookie_V1ZookieMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m DecodedZookie_V1ZookieMultiError) AllErrors() []error { return m } + +// DecodedZookie_V1ZookieValidationError is the validation error returned by +// DecodedZookie_V1Zookie.Validate if the designated constraints aren't met. +type DecodedZookie_V1ZookieValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e DecodedZookie_V1ZookieValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e DecodedZookie_V1ZookieValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e DecodedZookie_V1ZookieValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e DecodedZookie_V1ZookieValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e DecodedZookie_V1ZookieValidationError) ErrorName() string { + return "DecodedZookie_V1ZookieValidationError" +} + +// Error satisfies the builtin error interface +func (e DecodedZookie_V1ZookieValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sDecodedZookie_V1Zookie.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = DecodedZookie_V1ZookieValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = DecodedZookie_V1ZookieValidationError{} + +// Validate checks the field values on DecodedZookie_V2Zookie with the rules +// defined in the proto definition for this message. If any rules are +// violated, the first error encountered is returned, or nil if there are no violations. +func (m *DecodedZookie_V2Zookie) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on DecodedZookie_V2Zookie with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// DecodedZookie_V2ZookieMultiError, or nil if none found. +func (m *DecodedZookie_V2Zookie) ValidateAll() error { + return m.validate(true) +} + +func (m *DecodedZookie_V2Zookie) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Revision + + if len(errors) > 0 { + return DecodedZookie_V2ZookieMultiError(errors) + } + + return nil +} + +// DecodedZookie_V2ZookieMultiError is an error wrapping multiple validation +// errors returned by DecodedZookie_V2Zookie.ValidateAll() if the designated +// constraints aren't met. +type DecodedZookie_V2ZookieMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m DecodedZookie_V2ZookieMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m DecodedZookie_V2ZookieMultiError) AllErrors() []error { return m } + +// DecodedZookie_V2ZookieValidationError is the validation error returned by +// DecodedZookie_V2Zookie.Validate if the designated constraints aren't met. +type DecodedZookie_V2ZookieValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e DecodedZookie_V2ZookieValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e DecodedZookie_V2ZookieValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e DecodedZookie_V2ZookieValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e DecodedZookie_V2ZookieValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e DecodedZookie_V2ZookieValidationError) ErrorName() string { + return "DecodedZookie_V2ZookieValidationError" +} + +// Error satisfies the builtin error interface +func (e DecodedZookie_V2ZookieValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sDecodedZookie_V2Zookie.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = DecodedZookie_V2ZookieValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = DecodedZookie_V2ZookieValidationError{} + +// Validate checks the field values on DecodedZedToken_V1Zookie with the rules +// defined in the proto definition for this message. If any rules are +// violated, the first error encountered is returned, or nil if there are no violations. +func (m *DecodedZedToken_V1Zookie) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on DecodedZedToken_V1Zookie with the +// rules defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// DecodedZedToken_V1ZookieMultiError, or nil if none found. +func (m *DecodedZedToken_V1Zookie) ValidateAll() error { + return m.validate(true) +} + +func (m *DecodedZedToken_V1Zookie) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Revision + + if len(errors) > 0 { + return DecodedZedToken_V1ZookieMultiError(errors) + } + + return nil +} + +// DecodedZedToken_V1ZookieMultiError is an error wrapping multiple validation +// errors returned by DecodedZedToken_V1Zookie.ValidateAll() if the designated +// constraints aren't met. +type DecodedZedToken_V1ZookieMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m DecodedZedToken_V1ZookieMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m DecodedZedToken_V1ZookieMultiError) AllErrors() []error { return m } + +// DecodedZedToken_V1ZookieValidationError is the validation error returned by +// DecodedZedToken_V1Zookie.Validate if the designated constraints aren't met. +type DecodedZedToken_V1ZookieValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e DecodedZedToken_V1ZookieValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e DecodedZedToken_V1ZookieValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e DecodedZedToken_V1ZookieValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e DecodedZedToken_V1ZookieValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e DecodedZedToken_V1ZookieValidationError) ErrorName() string { + return "DecodedZedToken_V1ZookieValidationError" +} + +// Error satisfies the builtin error interface +func (e DecodedZedToken_V1ZookieValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sDecodedZedToken_V1Zookie.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = DecodedZedToken_V1ZookieValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = DecodedZedToken_V1ZookieValidationError{} + +// Validate checks the field values on DecodedZedToken_V1ZedToken with the +// rules defined in the proto definition for this message. If any rules are +// violated, the first error encountered is returned, or nil if there are no violations. +func (m *DecodedZedToken_V1ZedToken) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on DecodedZedToken_V1ZedToken with the +// rules defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// DecodedZedToken_V1ZedTokenMultiError, or nil if none found. +func (m *DecodedZedToken_V1ZedToken) ValidateAll() error { + return m.validate(true) +} + +func (m *DecodedZedToken_V1ZedToken) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Revision + + if len(errors) > 0 { + return DecodedZedToken_V1ZedTokenMultiError(errors) + } + + return nil +} + +// DecodedZedToken_V1ZedTokenMultiError is an error wrapping multiple +// validation errors returned by DecodedZedToken_V1ZedToken.ValidateAll() if +// the designated constraints aren't met. +type DecodedZedToken_V1ZedTokenMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m DecodedZedToken_V1ZedTokenMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m DecodedZedToken_V1ZedTokenMultiError) AllErrors() []error { return m } + +// DecodedZedToken_V1ZedTokenValidationError is the validation error returned +// by DecodedZedToken_V1ZedToken.Validate if the designated constraints aren't met. +type DecodedZedToken_V1ZedTokenValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e DecodedZedToken_V1ZedTokenValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e DecodedZedToken_V1ZedTokenValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e DecodedZedToken_V1ZedTokenValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e DecodedZedToken_V1ZedTokenValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e DecodedZedToken_V1ZedTokenValidationError) ErrorName() string { + return "DecodedZedToken_V1ZedTokenValidationError" +} + +// Error satisfies the builtin error interface +func (e DecodedZedToken_V1ZedTokenValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sDecodedZedToken_V1ZedToken.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = DecodedZedToken_V1ZedTokenValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = DecodedZedToken_V1ZedTokenValidationError{} diff --git a/vendor/github.com/authzed/spicedb/pkg/proto/impl/v1/impl_vtproto.pb.go b/vendor/github.com/authzed/spicedb/pkg/proto/impl/v1/impl_vtproto.pb.go new file mode 100644 index 0000000..95e3685 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/proto/impl/v1/impl_vtproto.pb.go @@ -0,0 +1,3335 @@ +// Code generated by protoc-gen-go-vtproto. DO NOT EDIT. +// protoc-gen-go-vtproto version: v0.6.1-0.20240409071808-615f978279ca +// source: impl/v1/impl.proto + +package implv1 + +import ( + fmt "fmt" + protohelpers "github.com/planetscale/vtprotobuf/protohelpers" + v1alpha1 "google.golang.org/genproto/googleapis/api/expr/v1alpha1" + proto "google.golang.org/protobuf/proto" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + io "io" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +func (m *DecodedCaveat) CloneVT() *DecodedCaveat { + if m == nil { + return (*DecodedCaveat)(nil) + } + r := new(DecodedCaveat) + r.Name = m.Name + if m.KindOneof != nil { + r.KindOneof = m.KindOneof.(interface { + CloneVT() isDecodedCaveat_KindOneof + }).CloneVT() + } + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *DecodedCaveat) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *DecodedCaveat_Cel) CloneVT() isDecodedCaveat_KindOneof { + if m == nil { + return (*DecodedCaveat_Cel)(nil) + } + r := new(DecodedCaveat_Cel) + if rhs := m.Cel; rhs != nil { + if vtpb, ok := interface{}(rhs).(interface{ CloneVT() *v1alpha1.CheckedExpr }); ok { + r.Cel = vtpb.CloneVT() + } else { + r.Cel = proto.Clone(rhs).(*v1alpha1.CheckedExpr) + } + } + return r +} + +func (m *DecodedZookie_V1Zookie) CloneVT() *DecodedZookie_V1Zookie { + if m == nil { + return (*DecodedZookie_V1Zookie)(nil) + } + r := new(DecodedZookie_V1Zookie) + r.Revision = m.Revision + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *DecodedZookie_V1Zookie) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *DecodedZookie_V2Zookie) CloneVT() *DecodedZookie_V2Zookie { + if m == nil { + return (*DecodedZookie_V2Zookie)(nil) + } + r := new(DecodedZookie_V2Zookie) + r.Revision = m.Revision + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *DecodedZookie_V2Zookie) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *DecodedZookie) CloneVT() *DecodedZookie { + if m == nil { + return (*DecodedZookie)(nil) + } + r := new(DecodedZookie) + r.Version = m.Version + if m.VersionOneof != nil { + r.VersionOneof = m.VersionOneof.(interface { + CloneVT() isDecodedZookie_VersionOneof + }).CloneVT() + } + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *DecodedZookie) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *DecodedZookie_V1) CloneVT() isDecodedZookie_VersionOneof { + if m == nil { + return (*DecodedZookie_V1)(nil) + } + r := new(DecodedZookie_V1) + r.V1 = m.V1.CloneVT() + return r +} + +func (m *DecodedZookie_V2) CloneVT() isDecodedZookie_VersionOneof { + if m == nil { + return (*DecodedZookie_V2)(nil) + } + r := new(DecodedZookie_V2) + r.V2 = m.V2.CloneVT() + return r +} + +func (m *DecodedZedToken_V1Zookie) CloneVT() *DecodedZedToken_V1Zookie { + if m == nil { + return (*DecodedZedToken_V1Zookie)(nil) + } + r := new(DecodedZedToken_V1Zookie) + r.Revision = m.Revision + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *DecodedZedToken_V1Zookie) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *DecodedZedToken_V1ZedToken) CloneVT() *DecodedZedToken_V1ZedToken { + if m == nil { + return (*DecodedZedToken_V1ZedToken)(nil) + } + r := new(DecodedZedToken_V1ZedToken) + r.Revision = m.Revision + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *DecodedZedToken_V1ZedToken) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *DecodedZedToken) CloneVT() *DecodedZedToken { + if m == nil { + return (*DecodedZedToken)(nil) + } + r := new(DecodedZedToken) + if m.VersionOneof != nil { + r.VersionOneof = m.VersionOneof.(interface { + CloneVT() isDecodedZedToken_VersionOneof + }).CloneVT() + } + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *DecodedZedToken) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *DecodedZedToken_DeprecatedV1Zookie) CloneVT() isDecodedZedToken_VersionOneof { + if m == nil { + return (*DecodedZedToken_DeprecatedV1Zookie)(nil) + } + r := new(DecodedZedToken_DeprecatedV1Zookie) + r.DeprecatedV1Zookie = m.DeprecatedV1Zookie.CloneVT() + return r +} + +func (m *DecodedZedToken_V1) CloneVT() isDecodedZedToken_VersionOneof { + if m == nil { + return (*DecodedZedToken_V1)(nil) + } + r := new(DecodedZedToken_V1) + r.V1 = m.V1.CloneVT() + return r +} + +func (m *DecodedCursor) CloneVT() *DecodedCursor { + if m == nil { + return (*DecodedCursor)(nil) + } + r := new(DecodedCursor) + if m.VersionOneof != nil { + r.VersionOneof = m.VersionOneof.(interface { + CloneVT() isDecodedCursor_VersionOneof + }).CloneVT() + } + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *DecodedCursor) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *DecodedCursor_V1) CloneVT() isDecodedCursor_VersionOneof { + if m == nil { + return (*DecodedCursor_V1)(nil) + } + r := new(DecodedCursor_V1) + r.V1 = m.V1.CloneVT() + return r +} + +func (m *V1Cursor) CloneVT() *V1Cursor { + if m == nil { + return (*V1Cursor)(nil) + } + r := new(V1Cursor) + r.Revision = m.Revision + r.CallAndParametersHash = m.CallAndParametersHash + r.DispatchVersion = m.DispatchVersion + if rhs := m.Sections; rhs != nil { + tmpContainer := make([]string, len(rhs)) + copy(tmpContainer, rhs) + r.Sections = tmpContainer + } + if rhs := m.Flags; rhs != nil { + tmpContainer := make(map[string]string, len(rhs)) + for k, v := range rhs { + tmpContainer[k] = v + } + r.Flags = tmpContainer + } + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *V1Cursor) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *DocComment) CloneVT() *DocComment { + if m == nil { + return (*DocComment)(nil) + } + r := new(DocComment) + r.Comment = m.Comment + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *DocComment) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *RelationMetadata) CloneVT() *RelationMetadata { + if m == nil { + return (*RelationMetadata)(nil) + } + r := new(RelationMetadata) + r.Kind = m.Kind + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *RelationMetadata) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *NamespaceAndRevision) CloneVT() *NamespaceAndRevision { + if m == nil { + return (*NamespaceAndRevision)(nil) + } + r := new(NamespaceAndRevision) + r.NamespaceName = m.NamespaceName + r.Revision = m.Revision + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *NamespaceAndRevision) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (m *V1Alpha1Revision) CloneVT() *V1Alpha1Revision { + if m == nil { + return (*V1Alpha1Revision)(nil) + } + r := new(V1Alpha1Revision) + if rhs := m.NsRevisions; rhs != nil { + tmpContainer := make([]*NamespaceAndRevision, len(rhs)) + for k, v := range rhs { + tmpContainer[k] = v.CloneVT() + } + r.NsRevisions = tmpContainer + } + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *V1Alpha1Revision) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (this *DecodedCaveat) EqualVT(that *DecodedCaveat) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if this.KindOneof == nil && that.KindOneof != nil { + return false + } else if this.KindOneof != nil { + if that.KindOneof == nil { + return false + } + if !this.KindOneof.(interface { + EqualVT(isDecodedCaveat_KindOneof) bool + }).EqualVT(that.KindOneof) { + return false + } + } + if this.Name != that.Name { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *DecodedCaveat) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*DecodedCaveat) + if !ok { + return false + } + return this.EqualVT(that) +} +func (this *DecodedCaveat_Cel) EqualVT(thatIface isDecodedCaveat_KindOneof) bool { + that, ok := thatIface.(*DecodedCaveat_Cel) + if !ok { + return false + } + if this == that { + return true + } + if this == nil && that != nil || this != nil && that == nil { + return false + } + if p, q := this.Cel, that.Cel; p != q { + if p == nil { + p = &v1alpha1.CheckedExpr{} + } + if q == nil { + q = &v1alpha1.CheckedExpr{} + } + if equal, ok := interface{}(p).(interface { + EqualVT(*v1alpha1.CheckedExpr) bool + }); ok { + if !equal.EqualVT(q) { + return false + } + } else if !proto.Equal(p, q) { + return false + } + } + return true +} + +func (this *DecodedZookie_V1Zookie) EqualVT(that *DecodedZookie_V1Zookie) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if this.Revision != that.Revision { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *DecodedZookie_V1Zookie) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*DecodedZookie_V1Zookie) + if !ok { + return false + } + return this.EqualVT(that) +} +func (this *DecodedZookie_V2Zookie) EqualVT(that *DecodedZookie_V2Zookie) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if this.Revision != that.Revision { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *DecodedZookie_V2Zookie) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*DecodedZookie_V2Zookie) + if !ok { + return false + } + return this.EqualVT(that) +} +func (this *DecodedZookie) EqualVT(that *DecodedZookie) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if this.VersionOneof == nil && that.VersionOneof != nil { + return false + } else if this.VersionOneof != nil { + if that.VersionOneof == nil { + return false + } + if !this.VersionOneof.(interface { + EqualVT(isDecodedZookie_VersionOneof) bool + }).EqualVT(that.VersionOneof) { + return false + } + } + if this.Version != that.Version { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *DecodedZookie) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*DecodedZookie) + if !ok { + return false + } + return this.EqualVT(that) +} +func (this *DecodedZookie_V1) EqualVT(thatIface isDecodedZookie_VersionOneof) bool { + that, ok := thatIface.(*DecodedZookie_V1) + if !ok { + return false + } + if this == that { + return true + } + if this == nil && that != nil || this != nil && that == nil { + return false + } + if p, q := this.V1, that.V1; p != q { + if p == nil { + p = &DecodedZookie_V1Zookie{} + } + if q == nil { + q = &DecodedZookie_V1Zookie{} + } + if !p.EqualVT(q) { + return false + } + } + return true +} + +func (this *DecodedZookie_V2) EqualVT(thatIface isDecodedZookie_VersionOneof) bool { + that, ok := thatIface.(*DecodedZookie_V2) + if !ok { + return false + } + if this == that { + return true + } + if this == nil && that != nil || this != nil && that == nil { + return false + } + if p, q := this.V2, that.V2; p != q { + if p == nil { + p = &DecodedZookie_V2Zookie{} + } + if q == nil { + q = &DecodedZookie_V2Zookie{} + } + if !p.EqualVT(q) { + return false + } + } + return true +} + +func (this *DecodedZedToken_V1Zookie) EqualVT(that *DecodedZedToken_V1Zookie) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if this.Revision != that.Revision { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *DecodedZedToken_V1Zookie) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*DecodedZedToken_V1Zookie) + if !ok { + return false + } + return this.EqualVT(that) +} +func (this *DecodedZedToken_V1ZedToken) EqualVT(that *DecodedZedToken_V1ZedToken) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if this.Revision != that.Revision { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *DecodedZedToken_V1ZedToken) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*DecodedZedToken_V1ZedToken) + if !ok { + return false + } + return this.EqualVT(that) +} +func (this *DecodedZedToken) EqualVT(that *DecodedZedToken) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if this.VersionOneof == nil && that.VersionOneof != nil { + return false + } else if this.VersionOneof != nil { + if that.VersionOneof == nil { + return false + } + if !this.VersionOneof.(interface { + EqualVT(isDecodedZedToken_VersionOneof) bool + }).EqualVT(that.VersionOneof) { + return false + } + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *DecodedZedToken) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*DecodedZedToken) + if !ok { + return false + } + return this.EqualVT(that) +} +func (this *DecodedZedToken_DeprecatedV1Zookie) EqualVT(thatIface isDecodedZedToken_VersionOneof) bool { + that, ok := thatIface.(*DecodedZedToken_DeprecatedV1Zookie) + if !ok { + return false + } + if this == that { + return true + } + if this == nil && that != nil || this != nil && that == nil { + return false + } + if p, q := this.DeprecatedV1Zookie, that.DeprecatedV1Zookie; p != q { + if p == nil { + p = &DecodedZedToken_V1Zookie{} + } + if q == nil { + q = &DecodedZedToken_V1Zookie{} + } + if !p.EqualVT(q) { + return false + } + } + return true +} + +func (this *DecodedZedToken_V1) EqualVT(thatIface isDecodedZedToken_VersionOneof) bool { + that, ok := thatIface.(*DecodedZedToken_V1) + if !ok { + return false + } + if this == that { + return true + } + if this == nil && that != nil || this != nil && that == nil { + return false + } + if p, q := this.V1, that.V1; p != q { + if p == nil { + p = &DecodedZedToken_V1ZedToken{} + } + if q == nil { + q = &DecodedZedToken_V1ZedToken{} + } + if !p.EqualVT(q) { + return false + } + } + return true +} + +func (this *DecodedCursor) EqualVT(that *DecodedCursor) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if this.VersionOneof == nil && that.VersionOneof != nil { + return false + } else if this.VersionOneof != nil { + if that.VersionOneof == nil { + return false + } + if !this.VersionOneof.(interface { + EqualVT(isDecodedCursor_VersionOneof) bool + }).EqualVT(that.VersionOneof) { + return false + } + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *DecodedCursor) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*DecodedCursor) + if !ok { + return false + } + return this.EqualVT(that) +} +func (this *DecodedCursor_V1) EqualVT(thatIface isDecodedCursor_VersionOneof) bool { + that, ok := thatIface.(*DecodedCursor_V1) + if !ok { + return false + } + if this == that { + return true + } + if this == nil && that != nil || this != nil && that == nil { + return false + } + if p, q := this.V1, that.V1; p != q { + if p == nil { + p = &V1Cursor{} + } + if q == nil { + q = &V1Cursor{} + } + if !p.EqualVT(q) { + return false + } + } + return true +} + +func (this *V1Cursor) EqualVT(that *V1Cursor) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if this.Revision != that.Revision { + return false + } + if len(this.Sections) != len(that.Sections) { + return false + } + for i, vx := range this.Sections { + vy := that.Sections[i] + if vx != vy { + return false + } + } + if this.CallAndParametersHash != that.CallAndParametersHash { + return false + } + if this.DispatchVersion != that.DispatchVersion { + return false + } + if len(this.Flags) != len(that.Flags) { + return false + } + for i, vx := range this.Flags { + vy, ok := that.Flags[i] + if !ok { + return false + } + if vx != vy { + return false + } + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *V1Cursor) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*V1Cursor) + if !ok { + return false + } + return this.EqualVT(that) +} +func (this *DocComment) EqualVT(that *DocComment) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if this.Comment != that.Comment { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *DocComment) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*DocComment) + if !ok { + return false + } + return this.EqualVT(that) +} +func (this *RelationMetadata) EqualVT(that *RelationMetadata) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if this.Kind != that.Kind { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *RelationMetadata) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*RelationMetadata) + if !ok { + return false + } + return this.EqualVT(that) +} +func (this *NamespaceAndRevision) EqualVT(that *NamespaceAndRevision) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if this.NamespaceName != that.NamespaceName { + return false + } + if this.Revision != that.Revision { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *NamespaceAndRevision) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*NamespaceAndRevision) + if !ok { + return false + } + return this.EqualVT(that) +} +func (this *V1Alpha1Revision) EqualVT(that *V1Alpha1Revision) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if len(this.NsRevisions) != len(that.NsRevisions) { + return false + } + for i, vx := range this.NsRevisions { + vy := that.NsRevisions[i] + if p, q := vx, vy; p != q { + if p == nil { + p = &NamespaceAndRevision{} + } + if q == nil { + q = &NamespaceAndRevision{} + } + if !p.EqualVT(q) { + return false + } + } + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *V1Alpha1Revision) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*V1Alpha1Revision) + if !ok { + return false + } + return this.EqualVT(that) +} +func (m *DecodedCaveat) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *DecodedCaveat) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *DecodedCaveat) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if vtmsg, ok := m.KindOneof.(interface { + MarshalToSizedBufferVT([]byte) (int, error) + }); ok { + size, err := vtmsg.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + } + if len(m.Name) > 0 { + i -= len(m.Name) + copy(dAtA[i:], m.Name) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Name))) + i-- + dAtA[i] = 0x12 + } + return len(dAtA) - i, nil +} + +func (m *DecodedCaveat_Cel) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *DecodedCaveat_Cel) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + i := len(dAtA) + if m.Cel != nil { + if vtmsg, ok := interface{}(m.Cel).(interface { + MarshalToSizedBufferVT([]byte) (int, error) + }); ok { + size, err := vtmsg.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + } else { + encoded, err := proto.Marshal(m.Cel) + if err != nil { + return 0, err + } + i -= len(encoded) + copy(dAtA[i:], encoded) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(encoded))) + } + i-- + dAtA[i] = 0xa + } else { + i = protohelpers.EncodeVarint(dAtA, i, 0) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} +func (m *DecodedZookie_V1Zookie) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *DecodedZookie_V1Zookie) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *DecodedZookie_V1Zookie) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if m.Revision != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.Revision)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *DecodedZookie_V2Zookie) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *DecodedZookie_V2Zookie) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *DecodedZookie_V2Zookie) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if len(m.Revision) > 0 { + i -= len(m.Revision) + copy(dAtA[i:], m.Revision) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Revision))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *DecodedZookie) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *DecodedZookie) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *DecodedZookie) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if vtmsg, ok := m.VersionOneof.(interface { + MarshalToSizedBufferVT([]byte) (int, error) + }); ok { + size, err := vtmsg.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + } + if m.Version != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.Version)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *DecodedZookie_V1) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *DecodedZookie_V1) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + i := len(dAtA) + if m.V1 != nil { + size, err := m.V1.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x12 + } else { + i = protohelpers.EncodeVarint(dAtA, i, 0) + i-- + dAtA[i] = 0x12 + } + return len(dAtA) - i, nil +} +func (m *DecodedZookie_V2) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *DecodedZookie_V2) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + i := len(dAtA) + if m.V2 != nil { + size, err := m.V2.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x1a + } else { + i = protohelpers.EncodeVarint(dAtA, i, 0) + i-- + dAtA[i] = 0x1a + } + return len(dAtA) - i, nil +} +func (m *DecodedZedToken_V1Zookie) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *DecodedZedToken_V1Zookie) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *DecodedZedToken_V1Zookie) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if m.Revision != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.Revision)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *DecodedZedToken_V1ZedToken) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *DecodedZedToken_V1ZedToken) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *DecodedZedToken_V1ZedToken) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if len(m.Revision) > 0 { + i -= len(m.Revision) + copy(dAtA[i:], m.Revision) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Revision))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *DecodedZedToken) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *DecodedZedToken) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *DecodedZedToken) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if vtmsg, ok := m.VersionOneof.(interface { + MarshalToSizedBufferVT([]byte) (int, error) + }); ok { + size, err := vtmsg.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + } + return len(dAtA) - i, nil +} + +func (m *DecodedZedToken_DeprecatedV1Zookie) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *DecodedZedToken_DeprecatedV1Zookie) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + i := len(dAtA) + if m.DeprecatedV1Zookie != nil { + size, err := m.DeprecatedV1Zookie.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x12 + } else { + i = protohelpers.EncodeVarint(dAtA, i, 0) + i-- + dAtA[i] = 0x12 + } + return len(dAtA) - i, nil +} +func (m *DecodedZedToken_V1) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *DecodedZedToken_V1) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + i := len(dAtA) + if m.V1 != nil { + size, err := m.V1.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x1a + } else { + i = protohelpers.EncodeVarint(dAtA, i, 0) + i-- + dAtA[i] = 0x1a + } + return len(dAtA) - i, nil +} +func (m *DecodedCursor) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *DecodedCursor) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *DecodedCursor) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if vtmsg, ok := m.VersionOneof.(interface { + MarshalToSizedBufferVT([]byte) (int, error) + }); ok { + size, err := vtmsg.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + } + return len(dAtA) - i, nil +} + +func (m *DecodedCursor_V1) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *DecodedCursor_V1) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + i := len(dAtA) + if m.V1 != nil { + size, err := m.V1.MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0xa + } else { + i = protohelpers.EncodeVarint(dAtA, i, 0) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} +func (m *V1Cursor) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *V1Cursor) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *V1Cursor) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if len(m.Flags) > 0 { + for k := range m.Flags { + v := m.Flags[k] + baseI := i + i -= len(v) + copy(dAtA[i:], v) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(v))) + i-- + dAtA[i] = 0x12 + i -= len(k) + copy(dAtA[i:], k) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(k))) + i-- + dAtA[i] = 0xa + i = protohelpers.EncodeVarint(dAtA, i, uint64(baseI-i)) + i-- + dAtA[i] = 0x2a + } + } + if m.DispatchVersion != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.DispatchVersion)) + i-- + dAtA[i] = 0x20 + } + if len(m.CallAndParametersHash) > 0 { + i -= len(m.CallAndParametersHash) + copy(dAtA[i:], m.CallAndParametersHash) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.CallAndParametersHash))) + i-- + dAtA[i] = 0x1a + } + if len(m.Sections) > 0 { + for iNdEx := len(m.Sections) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Sections[iNdEx]) + copy(dAtA[i:], m.Sections[iNdEx]) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Sections[iNdEx]))) + i-- + dAtA[i] = 0x12 + } + } + if len(m.Revision) > 0 { + i -= len(m.Revision) + copy(dAtA[i:], m.Revision) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Revision))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *DocComment) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *DocComment) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *DocComment) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if len(m.Comment) > 0 { + i -= len(m.Comment) + copy(dAtA[i:], m.Comment) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Comment))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *RelationMetadata) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *RelationMetadata) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *RelationMetadata) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if m.Kind != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.Kind)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *NamespaceAndRevision) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *NamespaceAndRevision) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *NamespaceAndRevision) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if len(m.Revision) > 0 { + i -= len(m.Revision) + copy(dAtA[i:], m.Revision) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Revision))) + i-- + dAtA[i] = 0x12 + } + if len(m.NamespaceName) > 0 { + i -= len(m.NamespaceName) + copy(dAtA[i:], m.NamespaceName) + i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.NamespaceName))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *V1Alpha1Revision) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *V1Alpha1Revision) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *V1Alpha1Revision) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if len(m.NsRevisions) > 0 { + for iNdEx := len(m.NsRevisions) - 1; iNdEx >= 0; iNdEx-- { + size, err := m.NsRevisions[iNdEx].MarshalToSizedBufferVT(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = protohelpers.EncodeVarint(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *DecodedCaveat) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if vtmsg, ok := m.KindOneof.(interface{ SizeVT() int }); ok { + n += vtmsg.SizeVT() + } + l = len(m.Name) + if l > 0 { + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + n += len(m.unknownFields) + return n +} + +func (m *DecodedCaveat_Cel) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Cel != nil { + if size, ok := interface{}(m.Cel).(interface { + SizeVT() int + }); ok { + l = size.SizeVT() + } else { + l = proto.Size(m.Cel) + } + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } else { + n += 2 + } + return n +} +func (m *DecodedZookie_V1Zookie) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Revision != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.Revision)) + } + n += len(m.unknownFields) + return n +} + +func (m *DecodedZookie_V2Zookie) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Revision) + if l > 0 { + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + n += len(m.unknownFields) + return n +} + +func (m *DecodedZookie) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Version != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.Version)) + } + if vtmsg, ok := m.VersionOneof.(interface{ SizeVT() int }); ok { + n += vtmsg.SizeVT() + } + n += len(m.unknownFields) + return n +} + +func (m *DecodedZookie_V1) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.V1 != nil { + l = m.V1.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } else { + n += 2 + } + return n +} +func (m *DecodedZookie_V2) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.V2 != nil { + l = m.V2.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } else { + n += 2 + } + return n +} +func (m *DecodedZedToken_V1Zookie) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Revision != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.Revision)) + } + n += len(m.unknownFields) + return n +} + +func (m *DecodedZedToken_V1ZedToken) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Revision) + if l > 0 { + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + n += len(m.unknownFields) + return n +} + +func (m *DecodedZedToken) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if vtmsg, ok := m.VersionOneof.(interface{ SizeVT() int }); ok { + n += vtmsg.SizeVT() + } + n += len(m.unknownFields) + return n +} + +func (m *DecodedZedToken_DeprecatedV1Zookie) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.DeprecatedV1Zookie != nil { + l = m.DeprecatedV1Zookie.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } else { + n += 2 + } + return n +} +func (m *DecodedZedToken_V1) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.V1 != nil { + l = m.V1.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } else { + n += 2 + } + return n +} +func (m *DecodedCursor) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if vtmsg, ok := m.VersionOneof.(interface{ SizeVT() int }); ok { + n += vtmsg.SizeVT() + } + n += len(m.unknownFields) + return n +} + +func (m *DecodedCursor_V1) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.V1 != nil { + l = m.V1.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } else { + n += 2 + } + return n +} +func (m *V1Cursor) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Revision) + if l > 0 { + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if len(m.Sections) > 0 { + for _, s := range m.Sections { + l = len(s) + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + } + l = len(m.CallAndParametersHash) + if l > 0 { + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + if m.DispatchVersion != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.DispatchVersion)) + } + if len(m.Flags) > 0 { + for k, v := range m.Flags { + _ = k + _ = v + mapEntrySize := 1 + len(k) + protohelpers.SizeOfVarint(uint64(len(k))) + 1 + len(v) + protohelpers.SizeOfVarint(uint64(len(v))) + n += mapEntrySize + 1 + protohelpers.SizeOfVarint(uint64(mapEntrySize)) + } + } + n += len(m.unknownFields) + return n +} + +func (m *DocComment) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Comment) + if l > 0 { + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + n += len(m.unknownFields) + return n +} + +func (m *RelationMetadata) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Kind != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.Kind)) + } + n += len(m.unknownFields) + return n +} + +func (m *NamespaceAndRevision) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.NamespaceName) + if l > 0 { + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + l = len(m.Revision) + if l > 0 { + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + n += len(m.unknownFields) + return n +} + +func (m *V1Alpha1Revision) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.NsRevisions) > 0 { + for _, e := range m.NsRevisions { + l = e.SizeVT() + n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) + } + } + n += len(m.unknownFields) + return n +} + +func (m *DecodedCaveat) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: DecodedCaveat: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: DecodedCaveat: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Cel", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if oneof, ok := m.KindOneof.(*DecodedCaveat_Cel); ok { + if unmarshal, ok := interface{}(oneof.Cel).(interface { + UnmarshalVT([]byte) error + }); ok { + if err := unmarshal.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + } else { + if err := proto.Unmarshal(dAtA[iNdEx:postIndex], oneof.Cel); err != nil { + return err + } + } + } else { + v := &v1alpha1.CheckedExpr{} + if unmarshal, ok := interface{}(v).(interface { + UnmarshalVT([]byte) error + }); ok { + if err := unmarshal.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + } else { + if err := proto.Unmarshal(dAtA[iNdEx:postIndex], v); err != nil { + return err + } + } + m.KindOneof = &DecodedCaveat_Cel{Cel: v} + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Name = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *DecodedZookie_V1Zookie) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: DecodedZookie_V1Zookie: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: DecodedZookie_V1Zookie: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Revision", wireType) + } + m.Revision = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Revision |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *DecodedZookie_V2Zookie) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: DecodedZookie_V2Zookie: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: DecodedZookie_V2Zookie: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Revision", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Revision = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *DecodedZookie) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: DecodedZookie: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: DecodedZookie: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Version", wireType) + } + m.Version = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Version |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field V1", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if oneof, ok := m.VersionOneof.(*DecodedZookie_V1); ok { + if err := oneof.V1.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + } else { + v := &DecodedZookie_V1Zookie{} + if err := v.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.VersionOneof = &DecodedZookie_V1{V1: v} + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field V2", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if oneof, ok := m.VersionOneof.(*DecodedZookie_V2); ok { + if err := oneof.V2.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + } else { + v := &DecodedZookie_V2Zookie{} + if err := v.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.VersionOneof = &DecodedZookie_V2{V2: v} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *DecodedZedToken_V1Zookie) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: DecodedZedToken_V1Zookie: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: DecodedZedToken_V1Zookie: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Revision", wireType) + } + m.Revision = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Revision |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *DecodedZedToken_V1ZedToken) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: DecodedZedToken_V1ZedToken: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: DecodedZedToken_V1ZedToken: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Revision", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Revision = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *DecodedZedToken) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: DecodedZedToken: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: DecodedZedToken: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DeprecatedV1Zookie", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if oneof, ok := m.VersionOneof.(*DecodedZedToken_DeprecatedV1Zookie); ok { + if err := oneof.DeprecatedV1Zookie.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + } else { + v := &DecodedZedToken_V1Zookie{} + if err := v.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.VersionOneof = &DecodedZedToken_DeprecatedV1Zookie{DeprecatedV1Zookie: v} + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field V1", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if oneof, ok := m.VersionOneof.(*DecodedZedToken_V1); ok { + if err := oneof.V1.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + } else { + v := &DecodedZedToken_V1ZedToken{} + if err := v.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.VersionOneof = &DecodedZedToken_V1{V1: v} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *DecodedCursor) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: DecodedCursor: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: DecodedCursor: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field V1", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if oneof, ok := m.VersionOneof.(*DecodedCursor_V1); ok { + if err := oneof.V1.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + } else { + v := &V1Cursor{} + if err := v.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.VersionOneof = &DecodedCursor_V1{V1: v} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *V1Cursor) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: V1Cursor: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: V1Cursor: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Revision", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Revision = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Sections", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Sections = append(m.Sections, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CallAndParametersHash", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.CallAndParametersHash = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field DispatchVersion", wireType) + } + m.DispatchVersion = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.DispatchVersion |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Flags", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Flags == nil { + m.Flags = make(map[string]string) + } + var mapkey string + var mapvalue string + for iNdEx < postIndex { + entryPreIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + if fieldNum == 1 { + var stringLenmapkey uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLenmapkey |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLenmapkey := int(stringLenmapkey) + if intStringLenmapkey < 0 { + return protohelpers.ErrInvalidLength + } + postStringIndexmapkey := iNdEx + intStringLenmapkey + if postStringIndexmapkey < 0 { + return protohelpers.ErrInvalidLength + } + if postStringIndexmapkey > l { + return io.ErrUnexpectedEOF + } + mapkey = string(dAtA[iNdEx:postStringIndexmapkey]) + iNdEx = postStringIndexmapkey + } else if fieldNum == 2 { + var stringLenmapvalue uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLenmapvalue |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLenmapvalue := int(stringLenmapvalue) + if intStringLenmapvalue < 0 { + return protohelpers.ErrInvalidLength + } + postStringIndexmapvalue := iNdEx + intStringLenmapvalue + if postStringIndexmapvalue < 0 { + return protohelpers.ErrInvalidLength + } + if postStringIndexmapvalue > l { + return io.ErrUnexpectedEOF + } + mapvalue = string(dAtA[iNdEx:postStringIndexmapvalue]) + iNdEx = postStringIndexmapvalue + } else { + iNdEx = entryPreIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > postIndex { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + m.Flags[mapkey] = mapvalue + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *DocComment) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: DocComment: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: DocComment: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Comment", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Comment = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *RelationMetadata) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: RelationMetadata: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: RelationMetadata: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Kind", wireType) + } + m.Kind = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Kind |= RelationMetadata_RelationKind(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *NamespaceAndRevision) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: NamespaceAndRevision: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: NamespaceAndRevision: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field NamespaceName", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.NamespaceName = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Revision", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Revision = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *V1Alpha1Revision) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: V1Alpha1Revision: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: V1Alpha1Revision: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field NsRevisions", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.NsRevisions = append(m.NsRevisions, &NamespaceAndRevision{}) + if err := m.NsRevisions[len(m.NsRevisions)-1].UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} diff --git a/vendor/github.com/authzed/spicedb/pkg/proto/impl/v1/pgrevision.pb.go b/vendor/github.com/authzed/spicedb/pkg/proto/impl/v1/pgrevision.pb.go new file mode 100644 index 0000000..71525dc --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/proto/impl/v1/pgrevision.pb.go @@ -0,0 +1,204 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.34.2 +// protoc (unknown) +// source: impl/v1/pgrevision.proto + +package implv1 + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +// * +// PostgresRevision is a compact binary encoding of a postgres snapshot as +// described in the offial documentation here: +// https://www.postgresql.org/docs/current/functions-info.html#FUNCTIONS-PG-SNAPSHOT-PARTS +// +// We use relative offsets for xmax and the xips to reduce the number of bytes +// required for binary encoding using the protobuf varint datatype: +// https://protobuf.dev/programming-guides/encoding/#varints +type PostgresRevision struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Xmin uint64 `protobuf:"varint,1,opt,name=xmin,proto3" json:"xmin,omitempty"` + RelativeXmax int64 `protobuf:"varint,2,opt,name=relative_xmax,json=relativeXmax,proto3" json:"relative_xmax,omitempty"` + RelativeXips []int64 `protobuf:"varint,3,rep,packed,name=relative_xips,json=relativeXips,proto3" json:"relative_xips,omitempty"` + // these are optional fields that are only present in strategic places that + // need the information, but otherwise is omitted to reduce the overhead + // of loading it from the DB and keeping it around in memory + OptionalTxid uint64 `protobuf:"varint,4,opt,name=optional_txid,json=optionalTxid,proto3" json:"optional_txid,omitempty"` + OptionalTimestamp uint64 `protobuf:"varint,5,opt,name=optional_timestamp,json=optionalTimestamp,proto3" json:"optional_timestamp,omitempty"` +} + +func (x *PostgresRevision) Reset() { + *x = PostgresRevision{} + if protoimpl.UnsafeEnabled { + mi := &file_impl_v1_pgrevision_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *PostgresRevision) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PostgresRevision) ProtoMessage() {} + +func (x *PostgresRevision) ProtoReflect() protoreflect.Message { + mi := &file_impl_v1_pgrevision_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use PostgresRevision.ProtoReflect.Descriptor instead. +func (*PostgresRevision) Descriptor() ([]byte, []int) { + return file_impl_v1_pgrevision_proto_rawDescGZIP(), []int{0} +} + +func (x *PostgresRevision) GetXmin() uint64 { + if x != nil { + return x.Xmin + } + return 0 +} + +func (x *PostgresRevision) GetRelativeXmax() int64 { + if x != nil { + return x.RelativeXmax + } + return 0 +} + +func (x *PostgresRevision) GetRelativeXips() []int64 { + if x != nil { + return x.RelativeXips + } + return nil +} + +func (x *PostgresRevision) GetOptionalTxid() uint64 { + if x != nil { + return x.OptionalTxid + } + return 0 +} + +func (x *PostgresRevision) GetOptionalTimestamp() uint64 { + if x != nil { + return x.OptionalTimestamp + } + return 0 +} + +var File_impl_v1_pgrevision_proto protoreflect.FileDescriptor + +var file_impl_v1_pgrevision_proto_rawDesc = []byte{ + 0x0a, 0x18, 0x69, 0x6d, 0x70, 0x6c, 0x2f, 0x76, 0x31, 0x2f, 0x70, 0x67, 0x72, 0x65, 0x76, 0x69, + 0x73, 0x69, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x07, 0x69, 0x6d, 0x70, 0x6c, + 0x2e, 0x76, 0x31, 0x22, 0xc4, 0x01, 0x0a, 0x10, 0x50, 0x6f, 0x73, 0x74, 0x67, 0x72, 0x65, 0x73, + 0x52, 0x65, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x78, 0x6d, 0x69, 0x6e, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x04, 0x78, 0x6d, 0x69, 0x6e, 0x12, 0x23, 0x0a, 0x0d, + 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x76, 0x65, 0x5f, 0x78, 0x6d, 0x61, 0x78, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x03, 0x52, 0x0c, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x76, 0x65, 0x58, 0x6d, 0x61, + 0x78, 0x12, 0x23, 0x0a, 0x0d, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x76, 0x65, 0x5f, 0x78, 0x69, + 0x70, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x03, 0x52, 0x0c, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, + 0x76, 0x65, 0x58, 0x69, 0x70, 0x73, 0x12, 0x23, 0x0a, 0x0d, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, + 0x61, 0x6c, 0x5f, 0x74, 0x78, 0x69, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0c, 0x6f, + 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x54, 0x78, 0x69, 0x64, 0x12, 0x2d, 0x0a, 0x12, 0x6f, + 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, + 0x70, 0x18, 0x05, 0x20, 0x01, 0x28, 0x04, 0x52, 0x11, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x61, + 0x6c, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x42, 0x90, 0x01, 0x0a, 0x0b, 0x63, + 0x6f, 0x6d, 0x2e, 0x69, 0x6d, 0x70, 0x6c, 0x2e, 0x76, 0x31, 0x42, 0x0f, 0x50, 0x67, 0x72, 0x65, + 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x33, 0x67, + 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x61, 0x75, 0x74, 0x68, 0x7a, 0x65, + 0x64, 0x2f, 0x73, 0x70, 0x69, 0x63, 0x65, 0x64, 0x62, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x2f, 0x69, 0x6d, 0x70, 0x6c, 0x2f, 0x76, 0x31, 0x3b, 0x69, 0x6d, 0x70, 0x6c, + 0x76, 0x31, 0xa2, 0x02, 0x03, 0x49, 0x58, 0x58, 0xaa, 0x02, 0x07, 0x49, 0x6d, 0x70, 0x6c, 0x2e, + 0x56, 0x31, 0xca, 0x02, 0x07, 0x49, 0x6d, 0x70, 0x6c, 0x5c, 0x56, 0x31, 0xe2, 0x02, 0x13, 0x49, + 0x6d, 0x70, 0x6c, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, + 0x74, 0x61, 0xea, 0x02, 0x08, 0x49, 0x6d, 0x70, 0x6c, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_impl_v1_pgrevision_proto_rawDescOnce sync.Once + file_impl_v1_pgrevision_proto_rawDescData = file_impl_v1_pgrevision_proto_rawDesc +) + +func file_impl_v1_pgrevision_proto_rawDescGZIP() []byte { + file_impl_v1_pgrevision_proto_rawDescOnce.Do(func() { + file_impl_v1_pgrevision_proto_rawDescData = protoimpl.X.CompressGZIP(file_impl_v1_pgrevision_proto_rawDescData) + }) + return file_impl_v1_pgrevision_proto_rawDescData +} + +var file_impl_v1_pgrevision_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_impl_v1_pgrevision_proto_goTypes = []any{ + (*PostgresRevision)(nil), // 0: impl.v1.PostgresRevision +} +var file_impl_v1_pgrevision_proto_depIdxs = []int32{ + 0, // [0:0] is the sub-list for method output_type + 0, // [0:0] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_impl_v1_pgrevision_proto_init() } +func file_impl_v1_pgrevision_proto_init() { + if File_impl_v1_pgrevision_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_impl_v1_pgrevision_proto_msgTypes[0].Exporter = func(v any, i int) any { + switch v := v.(*PostgresRevision); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_impl_v1_pgrevision_proto_rawDesc, + NumEnums: 0, + NumMessages: 1, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_impl_v1_pgrevision_proto_goTypes, + DependencyIndexes: file_impl_v1_pgrevision_proto_depIdxs, + MessageInfos: file_impl_v1_pgrevision_proto_msgTypes, + }.Build() + File_impl_v1_pgrevision_proto = out.File + file_impl_v1_pgrevision_proto_rawDesc = nil + file_impl_v1_pgrevision_proto_goTypes = nil + file_impl_v1_pgrevision_proto_depIdxs = nil +} diff --git a/vendor/github.com/authzed/spicedb/pkg/proto/impl/v1/pgrevision.pb.validate.go b/vendor/github.com/authzed/spicedb/pkg/proto/impl/v1/pgrevision.pb.validate.go new file mode 100644 index 0000000..db12ba4 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/proto/impl/v1/pgrevision.pb.validate.go @@ -0,0 +1,144 @@ +// Code generated by protoc-gen-validate. DO NOT EDIT. +// source: impl/v1/pgrevision.proto + +package implv1 + +import ( + "bytes" + "errors" + "fmt" + "net" + "net/mail" + "net/url" + "regexp" + "sort" + "strings" + "time" + "unicode/utf8" + + "google.golang.org/protobuf/types/known/anypb" +) + +// ensure the imports are used +var ( + _ = bytes.MinRead + _ = errors.New("") + _ = fmt.Print + _ = utf8.UTFMax + _ = (*regexp.Regexp)(nil) + _ = (*strings.Reader)(nil) + _ = net.IPv4len + _ = time.Duration(0) + _ = (*url.URL)(nil) + _ = (*mail.Address)(nil) + _ = anypb.Any{} + _ = sort.Sort +) + +// Validate checks the field values on PostgresRevision with the rules defined +// in the proto definition for this message. If any rules are violated, the +// first error encountered is returned, or nil if there are no violations. +func (m *PostgresRevision) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on PostgresRevision with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// PostgresRevisionMultiError, or nil if none found. +func (m *PostgresRevision) ValidateAll() error { + return m.validate(true) +} + +func (m *PostgresRevision) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Xmin + + // no validation rules for RelativeXmax + + // no validation rules for OptionalTxid + + // no validation rules for OptionalTimestamp + + if len(errors) > 0 { + return PostgresRevisionMultiError(errors) + } + + return nil +} + +// PostgresRevisionMultiError is an error wrapping multiple validation errors +// returned by PostgresRevision.ValidateAll() if the designated constraints +// aren't met. +type PostgresRevisionMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m PostgresRevisionMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m PostgresRevisionMultiError) AllErrors() []error { return m } + +// PostgresRevisionValidationError is the validation error returned by +// PostgresRevision.Validate if the designated constraints aren't met. +type PostgresRevisionValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e PostgresRevisionValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e PostgresRevisionValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e PostgresRevisionValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e PostgresRevisionValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e PostgresRevisionValidationError) ErrorName() string { return "PostgresRevisionValidationError" } + +// Error satisfies the builtin error interface +func (e PostgresRevisionValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sPostgresRevision.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = PostgresRevisionValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = PostgresRevisionValidationError{} diff --git a/vendor/github.com/authzed/spicedb/pkg/proto/impl/v1/pgrevision_vtproto.pb.go b/vendor/github.com/authzed/spicedb/pkg/proto/impl/v1/pgrevision_vtproto.pb.go new file mode 100644 index 0000000..c7a9dff --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/proto/impl/v1/pgrevision_vtproto.pb.go @@ -0,0 +1,389 @@ +// Code generated by protoc-gen-go-vtproto. DO NOT EDIT. +// protoc-gen-go-vtproto version: v0.6.1-0.20240409071808-615f978279ca +// source: impl/v1/pgrevision.proto + +package implv1 + +import ( + fmt "fmt" + protohelpers "github.com/planetscale/vtprotobuf/protohelpers" + proto "google.golang.org/protobuf/proto" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + io "io" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +func (m *PostgresRevision) CloneVT() *PostgresRevision { + if m == nil { + return (*PostgresRevision)(nil) + } + r := new(PostgresRevision) + r.Xmin = m.Xmin + r.RelativeXmax = m.RelativeXmax + r.OptionalTxid = m.OptionalTxid + r.OptionalTimestamp = m.OptionalTimestamp + if rhs := m.RelativeXips; rhs != nil { + tmpContainer := make([]int64, len(rhs)) + copy(tmpContainer, rhs) + r.RelativeXips = tmpContainer + } + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} + +func (m *PostgresRevision) CloneMessageVT() proto.Message { + return m.CloneVT() +} + +func (this *PostgresRevision) EqualVT(that *PostgresRevision) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if this.Xmin != that.Xmin { + return false + } + if this.RelativeXmax != that.RelativeXmax { + return false + } + if len(this.RelativeXips) != len(that.RelativeXips) { + return false + } + for i, vx := range this.RelativeXips { + vy := that.RelativeXips[i] + if vx != vy { + return false + } + } + if this.OptionalTxid != that.OptionalTxid { + return false + } + if this.OptionalTimestamp != that.OptionalTimestamp { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} + +func (this *PostgresRevision) EqualMessageVT(thatMsg proto.Message) bool { + that, ok := thatMsg.(*PostgresRevision) + if !ok { + return false + } + return this.EqualVT(that) +} +func (m *PostgresRevision) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *PostgresRevision) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *PostgresRevision) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if m.OptionalTimestamp != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.OptionalTimestamp)) + i-- + dAtA[i] = 0x28 + } + if m.OptionalTxid != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.OptionalTxid)) + i-- + dAtA[i] = 0x20 + } + if len(m.RelativeXips) > 0 { + var pksize2 int + for _, num := range m.RelativeXips { + pksize2 += protohelpers.SizeOfVarint(uint64(num)) + } + i -= pksize2 + j1 := i + for _, num1 := range m.RelativeXips { + num := uint64(num1) + for num >= 1<<7 { + dAtA[j1] = uint8(uint64(num)&0x7f | 0x80) + num >>= 7 + j1++ + } + dAtA[j1] = uint8(num) + j1++ + } + i = protohelpers.EncodeVarint(dAtA, i, uint64(pksize2)) + i-- + dAtA[i] = 0x1a + } + if m.RelativeXmax != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.RelativeXmax)) + i-- + dAtA[i] = 0x10 + } + if m.Xmin != 0 { + i = protohelpers.EncodeVarint(dAtA, i, uint64(m.Xmin)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *PostgresRevision) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Xmin != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.Xmin)) + } + if m.RelativeXmax != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.RelativeXmax)) + } + if len(m.RelativeXips) > 0 { + l = 0 + for _, e := range m.RelativeXips { + l += protohelpers.SizeOfVarint(uint64(e)) + } + n += 1 + protohelpers.SizeOfVarint(uint64(l)) + l + } + if m.OptionalTxid != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.OptionalTxid)) + } + if m.OptionalTimestamp != 0 { + n += 1 + protohelpers.SizeOfVarint(uint64(m.OptionalTimestamp)) + } + n += len(m.unknownFields) + return n +} + +func (m *PostgresRevision) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: PostgresRevision: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: PostgresRevision: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Xmin", wireType) + } + m.Xmin = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Xmin |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field RelativeXmax", wireType) + } + m.RelativeXmax = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.RelativeXmax |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType == 0 { + var v int64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.RelativeXips = append(m.RelativeXips, v) + } else if wireType == 2 { + var packedLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + packedLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if packedLen < 0 { + return protohelpers.ErrInvalidLength + } + postIndex := iNdEx + packedLen + if postIndex < 0 { + return protohelpers.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var elementCount int + var count int + for _, integer := range dAtA[iNdEx:postIndex] { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.RelativeXips) == 0 { + m.RelativeXips = make([]int64, 0, elementCount) + } + for iNdEx < postIndex { + var v int64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.RelativeXips = append(m.RelativeXips, v) + } + } else { + return fmt.Errorf("proto: wrong wireType = %d for field RelativeXips", wireType) + } + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field OptionalTxid", wireType) + } + m.OptionalTxid = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.OptionalTxid |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field OptionalTimestamp", wireType) + } + m.OptionalTimestamp = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protohelpers.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.OptionalTimestamp |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := protohelpers.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protohelpers.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} diff --git a/vendor/github.com/authzed/spicedb/pkg/releases/cli.go b/vendor/github.com/authzed/spicedb/pkg/releases/cli.go new file mode 100644 index 0000000..df55171 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/releases/cli.go @@ -0,0 +1,73 @@ +package releases + +import ( + "context" + "time" + + log "github.com/authzed/spicedb/internal/logging" + + "github.com/jzelinskie/cobrautil/v2" + "github.com/spf13/cobra" + flag "github.com/spf13/pflag" +) + +// RegisterFlags registers the flags for the CheckAndLogRunE function. +func RegisterFlags(flagset *flag.FlagSet) { + flagset.Bool("skip-release-check", false, "if true, skips checking for new SpiceDB releases") +} + +// CheckAndLogRunE is a run function that checks if the current version of SpiceDB is the latest +// and, if not, logs a warning. This check is disabled by setting --skip-release-check=false. +func CheckAndLogRunE() cobrautil.CobraRunFunc { + return func(cmd *cobra.Command, args []string) error { + skipReleaseCheck := cobrautil.MustGetBool(cmd, "skip-release-check") + if skipReleaseCheck { + return nil + } + + ctx, cancel := context.WithTimeout(context.Background(), time.Second*2) + defer cancel() + + state, currentVersion, release, err := CheckIsLatestVersion(ctx, CurrentVersion, GetLatestRelease) + if err != nil { + log.Ctx(ctx).Warn().Str("this-version", currentVersion).Err(err).Msg("could not perform version checking; if this problem persists or to skip this check, add --skip-release-check=true") + return nil + } + + switch state { + case UnreleasedVersion: + log.Ctx(ctx).Warn().Str("version", currentVersion).Msg("not running a released version of SpiceDB") + return nil + + case UpdateAvailable: + if release == nil { + log.Ctx(ctx).Warn().Msg("unable to check for or load the new SpiceDB version") + return nil + } + + log.Ctx(ctx).Warn().Str("this-version", currentVersion).Str("latest-released-version", release.Version).Msgf("this version of SpiceDB is out of date. See: %s", release.ViewURL) + return nil + + case UpToDate: + if release == nil { + log.Ctx(ctx).Warn().Msg("unable to check for or load the new SpiceDB version") + return nil + } + + log.Ctx(ctx).Info().Str("latest-released-version", release.Version).Msg("this is the latest released version of SpiceDB") + return nil + + case Unknown: + if release == nil { + log.Ctx(ctx).Warn().Msg("unable to check for or load the new SpiceDB version") + return nil + } + + log.Ctx(ctx).Warn().Str("unknown-released-version", release.Version).Msg("unable to check for a new SpiceDB version") + return nil + + default: + panic("Unknown state for CheckAndLogRunE") + } + } +} diff --git a/vendor/github.com/authzed/spicedb/pkg/releases/doc.go b/vendor/github.com/authzed/spicedb/pkg/releases/doc.go new file mode 100644 index 0000000..a80ac09 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/releases/doc.go @@ -0,0 +1,2 @@ +// Package releases contains helper functions to determine the current and latest version of spiceDB. +package releases diff --git a/vendor/github.com/authzed/spicedb/pkg/releases/releases.go b/vendor/github.com/authzed/spicedb/pkg/releases/releases.go new file mode 100644 index 0000000..62451fd --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/releases/releases.go @@ -0,0 +1,50 @@ +package releases + +import ( + "context" + "fmt" + "time" + + "github.com/google/go-github/v43/github" +) + +const ( + githubNamespace = "authzed" + githubRepository = "spicedb" +) + +// GetSourceRepository returns the source repository path for SpiceDB. +func GetSourceRepository() string { + return fmt.Sprintf("github.com/%s/%s", githubNamespace, githubRepository) +} + +// Release represents a release of SpiceDB. +type Release struct { + // Version is the version of the release. + Version string + + // PublishedAt is when the release was published, in UTC. + PublishedAt time.Time + + // ViewURL is the URL at which the release can be viewed. + ViewURL string +} + +// GetLatestRelease returns the latest release of SpiceDB, as reported by the GitHub API. +func GetLatestRelease(ctx context.Context) (*Release, error) { + client := github.NewClient(nil) + release, _, err := client.Repositories.GetLatestRelease(ctx, githubNamespace, githubRepository) + if err != nil { + return nil, err + } + + if release == nil { + return nil, fmt.Errorf("latest release not found") + } + + return &Release{ + Version: *release.Name, + PublishedAt: (*release.PublishedAt).UTC(), + ViewURL: *release.HTMLURL, + }, nil +} diff --git a/vendor/github.com/authzed/spicedb/pkg/releases/versions.go b/vendor/github.com/authzed/spicedb/pkg/releases/versions.go new file mode 100644 index 0000000..b29b79b --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/releases/versions.go @@ -0,0 +1,72 @@ +package releases + +import ( + "context" + "fmt" + "runtime" + "runtime/debug" + + "github.com/jzelinskie/cobrautil/v2" + "github.com/rs/zerolog/log" + "golang.org/x/mod/semver" +) + +// CurrentVersion returns the current version of the binary. +func CurrentVersion() (string, error) { + bi, ok := debug.ReadBuildInfo() + if !ok { + return "", fmt.Errorf("failed to read BuildInfo because the program was compiled with Go %s", runtime.Version()) + } + + return cobrautil.VersionWithFallbacks(bi), nil +} + +// SoftwareUpdateState is the state of this software relative to whether updates are available. +type SoftwareUpdateState int + +const ( + // Unknown indicates an unknown state. + Unknown SoftwareUpdateState = iota + + // UnreleasedVersion indicates that the current software version running is an unreleased version. + UnreleasedVersion + + // UpdateAvailable indicates an update is available. + UpdateAvailable + + // UpToDate indicates that the software is fully up-to-date. + UpToDate +) + +// CheckIsLatestVersion returns whether the current version of the software is the latest released. +// Returns the state, as well as the latest release. +func CheckIsLatestVersion( + ctx context.Context, + getCurrentVersion func() (string, error), + getLatestRelease func(context.Context) (*Release, error), +) (SoftwareUpdateState, string, *Release, error) { + currentVersion, err := getCurrentVersion() + if err != nil { + return Unknown, currentVersion, nil, err + } + + if currentVersion == "" || !semver.IsValid(currentVersion) { + return UnreleasedVersion, currentVersion, nil, nil + } + + release, err := getLatestRelease(ctx) + if err != nil { + return Unknown, currentVersion, nil, err + } + + if !semver.IsValid(release.Version) { + log.Warn().Str("version", release.Version).Msg("invalid version") + return Unknown, currentVersion, nil, err + } + + if semver.Compare(currentVersion, release.Version) < 0 { + return UpdateAvailable, currentVersion, release, nil + } + + return UpToDate, currentVersion, release, nil +} diff --git a/vendor/github.com/authzed/spicedb/pkg/schema/arrows.go b/vendor/github.com/authzed/spicedb/pkg/schema/arrows.go new file mode 100644 index 0000000..021f282 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/schema/arrows.go @@ -0,0 +1,157 @@ +package schema + +import ( + "context" + "errors" + "fmt" + "strconv" + + "github.com/authzed/spicedb/pkg/genutil/mapz" + core "github.com/authzed/spicedb/pkg/proto/core/v1" +) + +// ArrowInformation holds information about an arrow (TupleToUserset) in the schema. +type ArrowInformation struct { + Arrow *core.TupleToUserset + Path string + ParentRelationName string +} + +// ArrowSet represents a set of all the arrows (TupleToUserset's) found in the schema. +type ArrowSet struct { + res FullSchemaResolver + ts *TypeSystem + arrowsByFullTuplesetRelation *mapz.MultiMap[string, ArrowInformation] + arrowsByComputedUsersetNamespaceAndRelation *mapz.MultiMap[string, ArrowInformation] + reachableComputedUsersetRelationsByTuplesetRelation *mapz.MultiMap[string, string] +} + +// buildArrowSet builds a new set of all arrows found in the given schema. +func buildArrowSet(ctx context.Context, res FullSchemaResolver) (*ArrowSet, error) { + arrowSet := &ArrowSet{ + res: res, + ts: NewTypeSystem(res), + arrowsByFullTuplesetRelation: mapz.NewMultiMap[string, ArrowInformation](), + arrowsByComputedUsersetNamespaceAndRelation: mapz.NewMultiMap[string, ArrowInformation](), + reachableComputedUsersetRelationsByTuplesetRelation: mapz.NewMultiMap[string, string](), + } + if err := arrowSet.compute(ctx); err != nil { + return nil, err + } + return arrowSet, nil +} + +// AllReachableRelations returns all relations reachable through arrows, including tupleset relations +// and computed userset relations. +func (as *ArrowSet) AllReachableRelations() *mapz.Set[string] { + c := mapz.NewSet(as.reachableComputedUsersetRelationsByTuplesetRelation.Values()...) + c.Extend(as.arrowsByFullTuplesetRelation.Keys()) + return c +} + +// HasPossibleArrowWithComputedUserset returns true if there is a *possible* arrow with the given relation name +// as the arrow's computed userset/for a subject type that has the given namespace. +func (as *ArrowSet) HasPossibleArrowWithComputedUserset(namespaceName string, relationName string) bool { + return as.arrowsByComputedUsersetNamespaceAndRelation.Has(namespaceName + "#" + relationName) +} + +// LookupTuplesetArrows finds all arrows with the given namespace and relation name as the arrows' tupleset. +func (as *ArrowSet) LookupTuplesetArrows(namespaceName string, relationName string) []ArrowInformation { + key := namespaceName + "#" + relationName + found, _ := as.arrowsByFullTuplesetRelation.Get(key) + return found +} + +func (as *ArrowSet) compute(ctx context.Context) error { + for _, name := range as.res.AllDefinitionNames() { + def, err := as.ts.GetValidatedDefinition(ctx, name) + if err != nil { + return err + } + for _, relation := range def.nsDef.Relation { + if err := as.collectArrowInformationForRelation(ctx, def, relation.Name); err != nil { + return err + } + } + } + return nil +} + +func (as *ArrowSet) add(ttu *core.TupleToUserset, path string, namespaceName string, relationName string) { + tsKey := namespaceName + "#" + ttu.Tupleset.Relation + as.arrowsByFullTuplesetRelation.Add(tsKey, ArrowInformation{Path: path, Arrow: ttu, ParentRelationName: relationName}) +} + +func (as *ArrowSet) collectArrowInformationForRelation(ctx context.Context, def *ValidatedDefinition, relationName string) error { + if !def.IsPermission(relationName) { + return nil + } + + relation, ok := def.GetRelation(relationName) + if !ok { + return asTypeError(NewRelationNotFoundErr(def.Namespace().GetName(), relationName)) + } + return as.collectArrowInformationForRewrite(ctx, relation.UsersetRewrite, def, relation, relationName) +} + +func (as *ArrowSet) collectArrowInformationForRewrite(ctx context.Context, rewrite *core.UsersetRewrite, def *ValidatedDefinition, relation *core.Relation, path string) error { + switch rw := rewrite.RewriteOperation.(type) { + case *core.UsersetRewrite_Union: + return as.collectArrowInformationForSetOperation(ctx, rw.Union, def, relation, path) + case *core.UsersetRewrite_Intersection: + return as.collectArrowInformationForSetOperation(ctx, rw.Intersection, def, relation, path) + case *core.UsersetRewrite_Exclusion: + return as.collectArrowInformationForSetOperation(ctx, rw.Exclusion, def, relation, path) + default: + return errors.New("userset rewrite operation not implemented in addArrowRelationsForRewrite") + } +} + +func (as *ArrowSet) collectArrowInformationForSetOperation(ctx context.Context, so *core.SetOperation, def *ValidatedDefinition, relation *core.Relation, path string) error { + for index, childOneof := range so.Child { + updatedPath := path + "." + strconv.Itoa(index) + switch child := childOneof.ChildType.(type) { + case *core.SetOperation_Child_ComputedUserset: + // Nothing to do + + case *core.SetOperation_Child_UsersetRewrite: + err := as.collectArrowInformationForRewrite(ctx, child.UsersetRewrite, def, relation, updatedPath) + if err != nil { + return err + } + + case *core.SetOperation_Child_TupleToUserset: + as.add(child.TupleToUserset, updatedPath, def.Namespace().Name, relation.Name) + + allowedSubjectTypes, err := def.AllowedSubjectRelations(child.TupleToUserset.Tupleset.Relation) + if err != nil { + return err + } + + for _, ast := range allowedSubjectTypes { + def, err := as.ts.GetValidatedDefinition(ctx, ast.Namespace) + if err != nil { + return err + } + + // NOTE: this is explicitly added to the arrowsByComputedUsersetNamespaceAndRelation without + // checking if the relation/permission exists, because its needed for schema diff tracking. + as.arrowsByComputedUsersetNamespaceAndRelation.Add(ast.Namespace+"#"+child.TupleToUserset.ComputedUserset.Relation, ArrowInformation{Path: path, Arrow: child.TupleToUserset, ParentRelationName: relation.Name}) + if def.HasRelation(child.TupleToUserset.ComputedUserset.Relation) { + as.reachableComputedUsersetRelationsByTuplesetRelation.Add(ast.Namespace+"#"+child.TupleToUserset.Tupleset.Relation, ast.Namespace+"#"+child.TupleToUserset.ComputedUserset.Relation) + } + } + + case *core.SetOperation_Child_XThis: + // Nothing to do + + case *core.SetOperation_Child_XNil: + // Nothing to do + + default: + return fmt.Errorf("unknown set operation child `%T` in addArrowRelationsInSetOperation", child) + } + } + + return nil +} diff --git a/vendor/github.com/authzed/spicedb/pkg/schema/compiled_schema_resolver.go b/vendor/github.com/authzed/spicedb/pkg/schema/compiled_schema_resolver.go new file mode 100644 index 0000000..1bf40cc --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/schema/compiled_schema_resolver.go @@ -0,0 +1,60 @@ +package schema + +import ( + "context" + + core "github.com/authzed/spicedb/pkg/proto/core/v1" + "github.com/authzed/spicedb/pkg/schemadsl/compiler" +) + +// FullSchemaResolver is a superset of a resolver that knows how to retrieve all definitions +// from its source by name (by having a complete list of names). +type FullSchemaResolver interface { + Resolver + AllDefinitionNames() []string +} + +// CompiledSchemaResolver is a resolver for a fully compiled schema. It implements FullSchemaResolver, +// as it has the full context of the schema. +type CompiledSchemaResolver struct { + schema compiler.CompiledSchema +} + +// ResolverForCompiledSchema builds a resolver from a compiled schema. +func ResolverForCompiledSchema(schema compiler.CompiledSchema) *CompiledSchemaResolver { + return &CompiledSchemaResolver{ + schema: schema, + } +} + +var _ FullSchemaResolver = &CompiledSchemaResolver{} + +// LookupDefinition lookups up a namespace, also returning whether it was pre-validated. +func (c CompiledSchemaResolver) LookupDefinition(ctx context.Context, name string) (*core.NamespaceDefinition, bool, error) { + for _, o := range c.schema.ObjectDefinitions { + if o.GetName() == name { + return o, false, nil + } + } + return nil, false, asTypeError(NewDefinitionNotFoundErr(name)) +} + +// LookupCaveat lookups up a caveat. +func (c CompiledSchemaResolver) LookupCaveat(ctx context.Context, name string) (*Caveat, error) { + for _, v := range c.schema.CaveatDefinitions { + if v.GetName() == name { + return v, nil + } + } + return nil, asTypeError(NewCaveatNotFoundErr(name)) +} + +// AllDefinitionNames returns a list of all the names of defined namespaces for this resolved schema. +// Every definition is a valid parameter for LookupDefinition +func (c CompiledSchemaResolver) AllDefinitionNames() []string { + out := make([]string, len(c.schema.ObjectDefinitions)) + for i, o := range c.schema.ObjectDefinitions { + out[i] = o.GetName() + } + return out +} diff --git a/vendor/github.com/authzed/spicedb/pkg/schema/definition.go b/vendor/github.com/authzed/spicedb/pkg/schema/definition.go new file mode 100644 index 0000000..83ad73d --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/schema/definition.go @@ -0,0 +1,386 @@ +package schema + +import ( + "fmt" + + "github.com/authzed/spicedb/pkg/genutil/mapz" + nspkg "github.com/authzed/spicedb/pkg/namespace" + core "github.com/authzed/spicedb/pkg/proto/core/v1" + iv1 "github.com/authzed/spicedb/pkg/proto/impl/v1" + "github.com/authzed/spicedb/pkg/spiceerrors" + "github.com/authzed/spicedb/pkg/tuple" +) + +// AllowedDirectRelation indicates whether a relation is allowed on the right side of another relation. +type AllowedDirectRelation int + +const ( + // UnknownIfRelationAllowed indicates that no type information is defined for + // this relation. + UnknownIfRelationAllowed AllowedDirectRelation = iota + + // DirectRelationValid indicates that the specified subject relation is valid as + // part of a *direct* tuple on the relation. + DirectRelationValid + + // DirectRelationNotValid indicates that the specified subject relation is not + // valid as part of a *direct* tuple on the relation. + DirectRelationNotValid +) + +// AllowedPublicSubject indicates whether a public subject of a particular kind is allowed on the right side of another relation. +type AllowedPublicSubject int + +const ( + // UnknownIfPublicAllowed indicates that no type information is defined for + // this relation. + UnknownIfPublicAllowed AllowedPublicSubject = iota + + // PublicSubjectAllowed indicates that the specified subject wildcard is valid as + // part of a *direct* tuple on the relation. + PublicSubjectAllowed + + // PublicSubjectNotAllowed indicates that the specified subject wildcard is not + // valid as part of a *direct* tuple on the relation. + PublicSubjectNotAllowed +) + +// AllowedRelationOption indicates whether an allowed relation of a particular kind is allowed on the right side of another relation. +type AllowedRelationOption int + +const ( + // UnknownIfAllowed indicates that no type information is defined for + // this relation. + UnknownIfAllowed AllowedRelationOption = iota + + // AllowedRelationValid indicates that the specified subject relation is valid. + AllowedRelationValid + + // AllowedRelationNotValid indicates that the specified subject relation is not valid. + AllowedRelationNotValid +) + +// AllowedDefinitionOption indicates whether an allowed definition of a particular kind is allowed on the right side of another relation. +type AllowedDefinitionOption int + +const ( + // UnknownIfAllowedDefinition indicates that no type information is defined for + // this relation. + UnknownIfAllowedDefinition AllowedDefinitionOption = iota + + // AllowedDefinitionValid indicates that the specified subject definition is valid. + AllowedDefinitionValid + + // AllowedDefinitionNotValid indicates that the specified subject definition is not valid. + AllowedDefinitionNotValid +) + +// NewDefinition returns a new type definition for the given definition proto. +func NewDefinition(ts *TypeSystem, nsDef *core.NamespaceDefinition) (*Definition, error) { + relationMap := make(map[string]*core.Relation, len(nsDef.GetRelation())) + for _, relation := range nsDef.GetRelation() { + _, existing := relationMap[relation.Name] + if existing { + return nil, NewTypeWithSourceError( + NewDuplicateRelationError(nsDef.Name, relation.Name), + relation, + relation.Name, + ) + } + + relationMap[relation.Name] = relation + } + + return &Definition{ + ts: ts, + nsDef: nsDef, + relationMap: relationMap, + }, nil +} + +// Definition represents typing information found in a definition. +// It also provides better ergonomic accessors to the defintion's type information. +type Definition struct { + ts *TypeSystem + nsDef *core.NamespaceDefinition + relationMap map[string]*core.Relation +} + +// Namespace is the NamespaceDefinition for which the type system was constructed. +func (def *Definition) Namespace() *core.NamespaceDefinition { + return def.nsDef +} + +// TypeSystem returns the typesystem for this definition +func (def *Definition) TypeSystem() *TypeSystem { + return def.ts +} + +// HasTypeInformation returns true if the relation with the given name exists and has type +// information defined. +func (def *Definition) HasTypeInformation(relationName string) bool { + rel, ok := def.relationMap[relationName] + return ok && rel.GetTypeInformation() != nil +} + +// HasRelation returns true if the definition has the given relation defined. +func (def *Definition) HasRelation(relationName string) bool { + _, ok := def.relationMap[relationName] + return ok +} + +// GetRelation returns the relation that's defined with the give name in the type system or returns false. +func (def *Definition) GetRelation(relationName string) (*core.Relation, bool) { + rel, ok := def.relationMap[relationName] + return rel, ok +} + +// IsPermission returns true if the definition has the given relation defined and it is +// a permission. +func (def *Definition) IsPermission(relationName string) bool { + found, ok := def.relationMap[relationName] + if !ok { + return false + } + + return nspkg.GetRelationKind(found) == iv1.RelationMetadata_PERMISSION +} + +// GetAllowedDirectNamespaceSubjectRelations returns the subject relations for the target definition, if it is defined as appearing +// somewhere on the right side of a relation (except wildcards). Returns nil if there is no type information or it is not allowed. +func (def *Definition) GetAllowedDirectNamespaceSubjectRelations(sourceRelationName string, targetNamespaceName string) (*mapz.Set[string], error) { + found, ok := def.relationMap[sourceRelationName] + if !ok { + return nil, asTypeError(NewRelationNotFoundErr(def.nsDef.Name, sourceRelationName)) + } + + typeInfo := found.GetTypeInformation() + if typeInfo == nil { + return nil, nil + } + + allowedRelations := typeInfo.GetAllowedDirectRelations() + allowedSubjectRelations := mapz.NewSet[string]() + for _, allowedRelation := range allowedRelations { + if allowedRelation.GetNamespace() == targetNamespaceName && allowedRelation.GetPublicWildcard() == nil { + allowedSubjectRelations.Add(allowedRelation.GetRelation()) + } + } + + return allowedSubjectRelations, nil +} + +// IsAllowedDirectNamespace returns whether the target definition is defined as appearing somewhere on the +// right side of a relation (except public). +func (def *Definition) IsAllowedDirectNamespace(sourceRelationName string, targetNamespaceName string) (AllowedDefinitionOption, error) { + found, ok := def.relationMap[sourceRelationName] + if !ok { + return UnknownIfAllowedDefinition, asTypeError(NewRelationNotFoundErr(def.nsDef.Name, sourceRelationName)) + } + + typeInfo := found.GetTypeInformation() + if typeInfo == nil { + return UnknownIfAllowedDefinition, nil + } + + allowedRelations := typeInfo.GetAllowedDirectRelations() + for _, allowedRelation := range allowedRelations { + if allowedRelation.GetNamespace() == targetNamespaceName && allowedRelation.GetPublicWildcard() == nil { + return AllowedDefinitionValid, nil + } + } + + return AllowedDefinitionNotValid, nil +} + +// IsAllowedPublicNamespace returns whether the target definition is defined as public on the source relation. +func (def *Definition) IsAllowedPublicNamespace(sourceRelationName string, targetNamespaceName string) (AllowedPublicSubject, error) { + found, ok := def.relationMap[sourceRelationName] + if !ok { + return UnknownIfPublicAllowed, asTypeError(NewRelationNotFoundErr(def.nsDef.Name, sourceRelationName)) + } + + typeInfo := found.GetTypeInformation() + if typeInfo == nil { + return UnknownIfPublicAllowed, nil + } + + allowedRelations := typeInfo.GetAllowedDirectRelations() + for _, allowedRelation := range allowedRelations { + if allowedRelation.GetNamespace() == targetNamespaceName && allowedRelation.GetPublicWildcard() != nil { + return PublicSubjectAllowed, nil + } + } + + return PublicSubjectNotAllowed, nil +} + +// IsAllowedDirectRelation returns whether the subject relation is allowed to appear on the right +// hand side of a tuple placed in the source relation with the given name. +func (def *Definition) IsAllowedDirectRelation(sourceRelationName string, targetNamespaceName string, targetRelationName string) (AllowedDirectRelation, error) { + found, ok := def.relationMap[sourceRelationName] + if !ok { + return UnknownIfRelationAllowed, asTypeError(NewRelationNotFoundErr(def.nsDef.Name, sourceRelationName)) + } + + typeInfo := found.GetTypeInformation() + if typeInfo == nil { + return UnknownIfRelationAllowed, nil + } + + allowedRelations := typeInfo.GetAllowedDirectRelations() + for _, allowedRelation := range allowedRelations { + if allowedRelation.GetNamespace() == targetNamespaceName && allowedRelation.GetRelation() == targetRelationName { + return DirectRelationValid, nil + } + } + + return DirectRelationNotValid, nil +} + +// HasAllowedRelation returns whether the source relation has the given allowed relation. +func (def *Definition) HasAllowedRelation(sourceRelationName string, toCheck *core.AllowedRelation) (AllowedRelationOption, error) { + found, ok := def.relationMap[sourceRelationName] + if !ok { + return UnknownIfAllowed, asTypeError(NewRelationNotFoundErr(def.nsDef.Name, sourceRelationName)) + } + + typeInfo := found.GetTypeInformation() + if typeInfo == nil { + return UnknownIfAllowed, nil + } + + allowedRelations := typeInfo.GetAllowedDirectRelations() + for _, allowedRelation := range allowedRelations { + if SourceForAllowedRelation(allowedRelation) == SourceForAllowedRelation(toCheck) { + return AllowedRelationValid, nil + } + } + + return AllowedRelationNotValid, nil +} + +// AllowedDirectRelationsAndWildcards returns the allowed subject relations for a source relation. +// Note that this function will return wildcards. +func (def *Definition) AllowedDirectRelationsAndWildcards(sourceRelationName string) ([]*core.AllowedRelation, error) { + found, ok := def.relationMap[sourceRelationName] + if !ok { + return []*core.AllowedRelation{}, asTypeError(NewRelationNotFoundErr(def.nsDef.Name, sourceRelationName)) + } + + typeInfo := found.GetTypeInformation() + if typeInfo == nil { + return []*core.AllowedRelation{}, nil + } + + return typeInfo.GetAllowedDirectRelations(), nil +} + +// AllowedSubjectRelations returns the allowed subject relations for a source relation. Note that this function will *not* +// return wildcards, and returns without the marked caveats and expiration. +func (def *Definition) AllowedSubjectRelations(sourceRelationName string) ([]*core.RelationReference, error) { + allowedDirect, err := def.AllowedDirectRelationsAndWildcards(sourceRelationName) + if err != nil { + return []*core.RelationReference{}, asTypeError(err) + } + + filtered := make([]*core.RelationReference, 0, len(allowedDirect)) + for _, allowed := range allowedDirect { + if allowed.GetPublicWildcard() != nil { + continue + } + + if allowed.GetRelation() == "" { + return nil, spiceerrors.MustBugf("got an empty relation for a non-wildcard type definition under namespace") + } + + filtered = append(filtered, &core.RelationReference{ + Namespace: allowed.GetNamespace(), + Relation: allowed.GetRelation(), + }) + } + return filtered, nil +} + +// WildcardTypeReference represents a relation that references a wildcard type. +type WildcardTypeReference struct { + // ReferencingRelation is the relation referencing the wildcard type. + ReferencingRelation *core.RelationReference + + // WildcardType is the wildcard type referenced. + WildcardType *core.AllowedRelation +} + +// SourceForAllowedRelation returns the source code representation of an allowed relation. +func SourceForAllowedRelation(allowedRelation *core.AllowedRelation) string { + caveatAndTraitsStr := "" + + hasCaveat := allowedRelation.GetRequiredCaveat() != nil + hasExpirationTrait := allowedRelation.GetRequiredExpiration() != nil + hasTraits := hasCaveat || hasExpirationTrait + + if hasTraits { + caveatAndTraitsStr = " with " + if hasCaveat { + caveatAndTraitsStr += allowedRelation.RequiredCaveat.CaveatName + } + + if hasCaveat && hasExpirationTrait { + caveatAndTraitsStr += " and " + } + + if hasExpirationTrait { + caveatAndTraitsStr += "expiration" + } + } + + if allowedRelation.GetPublicWildcard() != nil { + return tuple.JoinObjectRef(allowedRelation.Namespace, "*") + caveatAndTraitsStr + } + + if rel := allowedRelation.GetRelation(); rel != tuple.Ellipsis { + return tuple.JoinRelRef(allowedRelation.Namespace, rel) + caveatAndTraitsStr + } + + return allowedRelation.Namespace + caveatAndTraitsStr +} + +// RelationDoesNotAllowCaveatsOrTraitsForSubject returns true if and only if it can be conclusively determined that +// the given subject type does not accept any caveats or traits on the given relation. If the relation does not have type information, +// returns an error. +func (def *Definition) RelationDoesNotAllowCaveatsOrTraitsForSubject(relationName string, subjectTypeName string) (bool, error) { + relation, ok := def.relationMap[relationName] + if !ok { + return false, NewRelationNotFoundErr(def.nsDef.Name, relationName) + } + + typeInfo := relation.GetTypeInformation() + if typeInfo == nil { + return false, NewTypeWithSourceError( + fmt.Errorf("relation `%s` does not have type information", relationName), + relation, relationName, + ) + } + + foundSubjectType := false + for _, allowedRelation := range typeInfo.GetAllowedDirectRelations() { + if allowedRelation.GetNamespace() == subjectTypeName { + foundSubjectType = true + if allowedRelation.GetRequiredCaveat() != nil && allowedRelation.GetRequiredCaveat().CaveatName != "" { + return false, nil + } + if allowedRelation.GetRequiredExpiration() != nil { + return false, nil + } + } + } + + if !foundSubjectType { + return false, NewTypeWithSourceError( + fmt.Errorf("relation `%s` does not allow subject type `%s`", relationName, subjectTypeName), + relation, relationName, + ) + } + + return true, nil +} diff --git a/vendor/github.com/authzed/spicedb/pkg/schema/doc.go b/vendor/github.com/authzed/spicedb/pkg/schema/doc.go new file mode 100644 index 0000000..b2cdb65 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/schema/doc.go @@ -0,0 +1,2 @@ +// Package schema contains code that manipulates a schema and knows how to traverse it. +package schema diff --git a/vendor/github.com/authzed/spicedb/pkg/schema/errors.go b/vendor/github.com/authzed/spicedb/pkg/schema/errors.go new file mode 100644 index 0000000..e81f315 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/schema/errors.go @@ -0,0 +1,406 @@ +package schema + +import ( + "errors" + "fmt" + "strings" + + "github.com/rs/zerolog" + + "github.com/authzed/spicedb/internal/sharederrors" + nspkg "github.com/authzed/spicedb/pkg/namespace" + "github.com/authzed/spicedb/pkg/spiceerrors" +) + +// DefinitionNotFoundError occurs when a definition was not found. +type DefinitionNotFoundError struct { + error + definitionName string +} + +// NotFoundNamespaceName is the name of the definition not found. +func (err DefinitionNotFoundError) NotFoundNamespaceName() string { + return err.definitionName +} + +// MarshalZerologObject implements zerolog object marshalling. +func (err DefinitionNotFoundError) MarshalZerologObject(e *zerolog.Event) { + e.Err(err.error).Str("definition", err.definitionName) +} + +// DetailsMetadata returns the metadata for details for this error. +func (err DefinitionNotFoundError) DetailsMetadata() map[string]string { + return map[string]string{ + "definition_name": err.definitionName, + } +} + +// RelationNotFoundError occurs when a relation was not found under a definition. +type RelationNotFoundError struct { + error + definitionName string + relationName string +} + +// NamespaceName returns the name of the definition in which the relation was not found. +func (err RelationNotFoundError) NamespaceName() string { + return err.definitionName +} + +// NotFoundRelationName returns the name of the relation not found. +func (err RelationNotFoundError) NotFoundRelationName() string { + return err.relationName +} + +// MarshalZerologObject implements zerolog object marshalling. +func (err RelationNotFoundError) MarshalZerologObject(e *zerolog.Event) { + e.Err(err.error).Str("definition", err.definitionName).Str("relation", err.relationName) +} + +// DetailsMetadata returns the metadata for details for this error. +func (err RelationNotFoundError) DetailsMetadata() map[string]string { + return map[string]string{ + "definition_name": err.definitionName, + "relation_or_permission_name": err.relationName, + } +} + +// CaveatNotFoundError occurs when a caveat was not found. +type CaveatNotFoundError struct { + error + caveatName string +} + +// CaveatName returns the name of the caveat not found. +func (err CaveatNotFoundError) CaveatName() string { + return err.caveatName +} + +// MarshalZerologObject implements zerolog object marshalling. +func (err CaveatNotFoundError) MarshalZerologObject(e *zerolog.Event) { + e.Err(err.error).Str("caveat", err.caveatName) +} + +// DetailsMetadata returns the metadata for details for this error. +func (err CaveatNotFoundError) DetailsMetadata() map[string]string { + return map[string]string{ + "caveat_name": err.caveatName, + } +} + +// DuplicateRelationError occurs when a duplicate relation was found inside a definition. +type DuplicateRelationError struct { + error + definitionName string + relationName string +} + +// MarshalZerologObject implements zerolog object marshalling. +func (err DuplicateRelationError) MarshalZerologObject(e *zerolog.Event) { + e.Err(err.error).Str("definition", err.definitionName).Str("relation", err.relationName) +} + +// DetailsMetadata returns the metadata for details for this error. +func (err DuplicateRelationError) DetailsMetadata() map[string]string { + return map[string]string{ + "definition_name": err.definitionName, + "relation_or_permission_name": err.relationName, + } +} + +// PermissionUsedOnLeftOfArrowError occurs when a permission is used on the left side of an arrow +// expression. +type PermissionUsedOnLeftOfArrowError struct { + error + definitionName string + parentPermissionName string + foundPermissionName string +} + +// MarshalZerologObject implements zerolog object marshalling. +func (err PermissionUsedOnLeftOfArrowError) MarshalZerologObject(e *zerolog.Event) { + e.Err(err.error).Str("definition", err.definitionName).Str("permission", err.parentPermissionName).Str("usedPermission", err.foundPermissionName) +} + +// DetailsMetadata returns the metadata for details for this error. +func (err PermissionUsedOnLeftOfArrowError) DetailsMetadata() map[string]string { + return map[string]string{ + "definition_name": err.definitionName, + "permission_name": err.parentPermissionName, + "used_permission_name": err.foundPermissionName, + } +} + +// WildcardUsedInArrowError occurs when an arrow operates over a relation that contains a wildcard. +type WildcardUsedInArrowError struct { + error + definitionName string + parentPermissionName string + accessedRelationName string +} + +// MarshalZerologObject implements zerolog object marshalling. +func (err WildcardUsedInArrowError) MarshalZerologObject(e *zerolog.Event) { + e.Err(err.error).Str("definition", err.definitionName).Str("parentPermissionName", err.parentPermissionName).Str("accessedRelationName", err.accessedRelationName) +} + +// DetailsMetadata returns the metadata for details for this error. +func (err WildcardUsedInArrowError) DetailsMetadata() map[string]string { + return map[string]string{ + "definition_name": err.definitionName, + "permission_name": err.parentPermissionName, + "accessed_relation_name": err.accessedRelationName, + } +} + +// MissingAllowedRelationsError occurs when a relation is defined without any type information. +type MissingAllowedRelationsError struct { + error + definitionName string + relationName string +} + +// MarshalZerologObject implements zerolog object marshalling. +func (err MissingAllowedRelationsError) MarshalZerologObject(e *zerolog.Event) { + e.Err(err.error).Str("definition", err.definitionName).Str("relation", err.relationName) +} + +// DetailsMetadata returns the metadata for details for this error. +func (err MissingAllowedRelationsError) DetailsMetadata() map[string]string { + return map[string]string{ + "definition_name": err.definitionName, + "relation_name": err.relationName, + } +} + +// TransitiveWildcardError occurs when a wildcard relation in turn references another wildcard +// relation. +type TransitiveWildcardError struct { + error + definitionName string + relationName string +} + +// MarshalZerologObject implements zerolog object marshalling. +func (err TransitiveWildcardError) MarshalZerologObject(e *zerolog.Event) { + e.Err(err.error).Str("definition", err.definitionName).Str("relation", err.relationName) +} + +// DetailsMetadata returns the metadata for details for this error. +func (err TransitiveWildcardError) DetailsMetadata() map[string]string { + return map[string]string{ + "definition_name": err.definitionName, + "relation_name": err.relationName, + } +} + +// PermissionsCycleError occurs when a cycle exists within permissions. +type PermissionsCycleError struct { + error + definitionName string + permissionNames []string +} + +// MarshalZerologObject implements zerolog object marshalling. +func (err PermissionsCycleError) MarshalZerologObject(e *zerolog.Event) { + e.Err(err.error).Str("definition", err.definitionName).Str("permissions", strings.Join(err.permissionNames, ", ")) +} + +// DetailsMetadata returns the metadata for details for this error. +func (err PermissionsCycleError) DetailsMetadata() map[string]string { + return map[string]string{ + "definition_name": err.definitionName, + "permission_names": strings.Join(err.permissionNames, ","), + } +} + +// DuplicateAllowedRelationError indicates that an allowed relation was redefined on a relation. +type DuplicateAllowedRelationError struct { + error + definitionName string + relationName string + allowedRelationSource string +} + +// MarshalZerologObject implements zerolog object marshalling. +func (err DuplicateAllowedRelationError) MarshalZerologObject(e *zerolog.Event) { + e.Err(err.error).Str("definition", err.definitionName).Str("relation", err.relationName).Str("allowed-relation", err.allowedRelationSource) +} + +// DetailsMetadata returns the metadata for details for this error. +func (err DuplicateAllowedRelationError) DetailsMetadata() map[string]string { + return map[string]string{ + "definition_name": err.definitionName, + "relation_name": err.relationName, + "allowed_relation": err.allowedRelationSource, + } +} + +// UnusedCaveatParameterError indicates that a caveat parameter is unused in the caveat expression. +type UnusedCaveatParameterError struct { + error + caveatName string + paramName string +} + +// MarshalZerologObject implements zerolog object marshalling. +func (err UnusedCaveatParameterError) MarshalZerologObject(e *zerolog.Event) { + e.Err(err.error).Str("caveat", err.caveatName).Str("param", err.paramName) +} + +// DetailsMetadata returns the metadata for details for this error. +func (err UnusedCaveatParameterError) DetailsMetadata() map[string]string { + return map[string]string{ + "caveat_name": err.caveatName, + "parameter_name": err.paramName, + } +} + +// NewDefinitionNotFoundErr constructs a new definition not found error. +func NewDefinitionNotFoundErr(nsName string) error { + return DefinitionNotFoundError{ + error: fmt.Errorf("object definition `%s` not found", nsName), + definitionName: nsName, + } +} + +// NewRelationNotFoundErr constructs a new relation not found error. +func NewRelationNotFoundErr(nsName string, relationName string) error { + return RelationNotFoundError{ + error: fmt.Errorf("relation/permission `%s` not found under definition `%s`", relationName, nsName), + definitionName: nsName, + relationName: relationName, + } +} + +// NewCaveatNotFoundErr constructs a new caveat not found error. +func NewCaveatNotFoundErr(caveatName string) error { + return CaveatNotFoundError{ + error: fmt.Errorf("caveat `%s` not found", caveatName), + caveatName: caveatName, + } +} + +// NewDuplicateRelationError constructs an error indicating that a relation was defined more than once in a definition. +func NewDuplicateRelationError(nsName string, relationName string) error { + return DuplicateRelationError{ + error: fmt.Errorf("found duplicate relation/permission name `%s` under definition `%s`", relationName, nsName), + definitionName: nsName, + relationName: relationName, + } +} + +// NewDuplicateAllowedRelationErr constructs an error indicating that an allowed relation was defined more than once for a relation. +func NewDuplicateAllowedRelationErr(nsName string, relationName string, allowedRelationSource string) error { + return DuplicateAllowedRelationError{ + error: fmt.Errorf("found duplicate allowed subject type `%s` on relation `%s` under definition `%s`", allowedRelationSource, relationName, nsName), + definitionName: nsName, + relationName: relationName, + allowedRelationSource: allowedRelationSource, + } +} + +// NewPermissionUsedOnLeftOfArrowErr constructs an error indicating that a permission was used on the left side of an arrow. +func NewPermissionUsedOnLeftOfArrowErr(nsName string, parentPermissionName string, foundPermissionName string) error { + return PermissionUsedOnLeftOfArrowError{ + error: fmt.Errorf("under permission `%s` under definition `%s`: permissions cannot be used on the left hand side of an arrow (found `%s`)", parentPermissionName, nsName, foundPermissionName), + definitionName: nsName, + parentPermissionName: parentPermissionName, + foundPermissionName: foundPermissionName, + } +} + +// NewWildcardUsedInArrowErr constructs an error indicating that an arrow operated over a relation with a wildcard type. +func NewWildcardUsedInArrowErr(nsName string, parentPermissionName string, foundRelationName string, wildcardTypeName string, wildcardRelationName string) error { + return WildcardUsedInArrowError{ + error: fmt.Errorf("for arrow under permission `%s`: relation `%s#%s` includes wildcard type `%s` via relation `%s`: wildcard relations cannot be used on the left side of arrows", parentPermissionName, nsName, foundRelationName, wildcardTypeName, wildcardRelationName), + definitionName: nsName, + parentPermissionName: parentPermissionName, + accessedRelationName: foundRelationName, + } +} + +// NewMissingAllowedRelationsErr constructs an error indicating that type information is missing for a relation. +func NewMissingAllowedRelationsErr(nsName string, relationName string) error { + return MissingAllowedRelationsError{ + error: fmt.Errorf("at least one allowed relation/permission is required to be defined for relation `%s`", relationName), + definitionName: nsName, + relationName: relationName, + } +} + +// NewTransitiveWildcardErr constructs an error indicating that a transitive wildcard exists. +func NewTransitiveWildcardErr(nsName string, relationName string, foundRelationNamespace string, foundRelationName string, wildcardTypeName string, wildcardRelationReference string) error { + return TransitiveWildcardError{ + error: fmt.Errorf("for relation `%s`: relation/permission `%s#%s` includes wildcard type `%s` via relation `%s`: wildcard relations cannot be transitively included", relationName, foundRelationNamespace, foundRelationName, wildcardTypeName, wildcardRelationReference), + definitionName: nsName, + relationName: relationName, + } +} + +// NewPermissionsCycleErr constructs an error indicating that a cycle exists amongst permissions. +func NewPermissionsCycleErr(nsName string, permissionNames []string) error { + return PermissionsCycleError{ + error: fmt.Errorf("under definition `%s`, there exists a cycle in permissions: %s", nsName, strings.Join(permissionNames, ", ")), + definitionName: nsName, + permissionNames: permissionNames, + } +} + +// NewUnusedCaveatParameterErr constructs indicating that a parameter was unused in a caveat expression. +func NewUnusedCaveatParameterErr(caveatName string, paramName string) error { + return UnusedCaveatParameterError{ + error: fmt.Errorf("parameter `%s` for caveat `%s` is unused", paramName, caveatName), + caveatName: caveatName, + paramName: paramName, + } +} + +// asTypeError wraps another error in a type error. +func asTypeError(wrapped error) error { + if wrapped == nil { + return nil + } + + var te TypeError + if errors.As(wrapped, &te) { + return wrapped + } + + return TypeError{wrapped} +} + +// TypeError wraps another error as a type error. +type TypeError struct { + error +} + +func (err TypeError) Unwrap() error { + return err.error +} + +var ( + _ sharederrors.UnknownNamespaceError = DefinitionNotFoundError{} + _ sharederrors.UnknownRelationError = RelationNotFoundError{} +) + +// NewTypeWithSourceError creates a new type error at the specific position and with source code, wrapping the underlying +// error. +func NewTypeWithSourceError(wrapped error, withSource nspkg.WithSourcePosition, sourceCodeString string) error { + sourcePosition := withSource.GetSourcePosition() + if sourcePosition != nil { + return asTypeError(spiceerrors.NewWithSourceError( + wrapped, + sourceCodeString, + sourcePosition.ZeroIndexedLineNumber+1, // +1 to make 1-indexed + sourcePosition.ZeroIndexedColumnPosition+1, // +1 to make 1-indexed + )) + } + + return asTypeError(spiceerrors.NewWithSourceError( + wrapped, + sourceCodeString, + 0, + 0, + )) +} diff --git a/vendor/github.com/authzed/spicedb/pkg/schema/full_reachability.go b/vendor/github.com/authzed/spicedb/pkg/schema/full_reachability.go new file mode 100644 index 0000000..a6143b5 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/schema/full_reachability.go @@ -0,0 +1,226 @@ +package schema + +import ( + "context" + "errors" + "fmt" + "slices" + "strings" + + core "github.com/authzed/spicedb/pkg/proto/core/v1" +) + +// Graph is a struct holding reachability information. +type Graph struct { + arrowSet *ArrowSet + ts *TypeSystem + referenceInfoMap map[nsAndRel][]RelationReferenceInfo +} + +// BuildGraph builds the graph of all reachable information in the schema. +func BuildGraph(ctx context.Context, r *CompiledSchemaResolver) (*Graph, error) { + arrowSet, err := buildArrowSet(ctx, r) + if err != nil { + return nil, err + } + + ts := NewTypeSystem(r) + referenceInfoMap, err := preComputeRelationReferenceInfo(ctx, arrowSet, r, ts) + if err != nil { + return nil, err + } + + return &Graph{ + ts: ts, + arrowSet: arrowSet, + referenceInfoMap: referenceInfoMap, + }, nil +} + +// Arrows returns the set of arrows found in the reachability graph. +func (g *Graph) Arrows() *ArrowSet { + return g.arrowSet +} + +// RelationsReferencing returns all relations/permissions in the schema that reference the specified +// relation in some manner. +func (g *Graph) RelationsReferencing(namespaceName string, relationName string) []RelationReferenceInfo { + return g.referenceInfoMap[nsAndRel{ + Namespace: namespaceName, + Relation: relationName, + }] +} + +// ReferenceType is an enum describing what kind of relation reference we hold in a RelationReferenceInfo. +type ReferenceType int + +const ( + RelationInExpression ReferenceType = iota + RelationIsSubjectType + RelationIsTuplesetForArrow + RelationIsComputedUsersetForArrow +) + +// RelationReferenceInfo holds the relation and metadata for a relation found in the full reachability graph. +type RelationReferenceInfo struct { + Relation *core.RelationReference + Type ReferenceType + Arrow *ArrowInformation +} + +func relationsReferencing(ctx context.Context, arrowSet *ArrowSet, res FullSchemaResolver, ts *TypeSystem, namespaceName string, relationName string) ([]RelationReferenceInfo, error) { + foundReferences := make([]RelationReferenceInfo, 0) + + for _, name := range res.AllDefinitionNames() { + def, err := ts.GetValidatedDefinition(ctx, name) + if err != nil { + return nil, err + } + for _, relation := range def.Namespace().Relation { + // Check for the use of the relation directly as part of any permissions in the same namespace. + if def.IsPermission(relation.Name) && name == namespaceName { + hasReference, err := expressionReferencesRelation(ctx, relation.GetUsersetRewrite(), relationName) + if err != nil { + return nil, err + } + + if hasReference { + foundReferences = append(foundReferences, RelationReferenceInfo{ + Relation: &core.RelationReference{ + Namespace: name, + Relation: relation.Name, + }, + Type: RelationInExpression, + }) + } + continue + } + + // Check for the use of the relation as a subject type on any relation in the entire schema. + isAllowed, err := def.IsAllowedDirectRelation(relation.Name, namespaceName, relationName) + if err != nil { + return nil, err + } + + if isAllowed == DirectRelationValid { + foundReferences = append(foundReferences, RelationReferenceInfo{ + Relation: &core.RelationReference{ + Namespace: name, + Relation: relation.Name, + }, + Type: RelationIsSubjectType, + }) + } + } + } + + // Add any arrow references. + key := namespaceName + "#" + relationName + foundArrows, _ := arrowSet.arrowsByFullTuplesetRelation.Get(key) + for _, arrow := range foundArrows { + arrow := arrow + foundReferences = append(foundReferences, RelationReferenceInfo{ + Relation: &core.RelationReference{ + Namespace: namespaceName, + Relation: arrow.ParentRelationName, + }, + Type: RelationIsTuplesetForArrow, + Arrow: &arrow, + }) + } + + for _, tuplesetRelationKey := range arrowSet.reachableComputedUsersetRelationsByTuplesetRelation.Keys() { + values, ok := arrowSet.reachableComputedUsersetRelationsByTuplesetRelation.Get(tuplesetRelationKey) + if !ok { + continue + } + + if slices.Contains(values, key) { + pieces := strings.Split(tuplesetRelationKey, "#") + foundReferences = append(foundReferences, RelationReferenceInfo{ + Relation: &core.RelationReference{ + Namespace: pieces[0], + Relation: pieces[1], + }, + Type: RelationIsComputedUsersetForArrow, + }) + } + } + + return foundReferences, nil +} + +type nsAndRel struct { + Namespace string + Relation string +} + +func preComputeRelationReferenceInfo(ctx context.Context, arrowSet *ArrowSet, res FullSchemaResolver, ts *TypeSystem) (map[nsAndRel][]RelationReferenceInfo, error) { + nsAndRelToInfo := make(map[nsAndRel][]RelationReferenceInfo) + + for _, namespaceName := range res.AllDefinitionNames() { + outerTS, err := ts.GetValidatedDefinition(ctx, namespaceName) + if err != nil { + return nil, err + } + for _, outerRelation := range outerTS.Namespace().Relation { + referenceInfos, err := relationsReferencing(ctx, arrowSet, res, ts, namespaceName, outerRelation.Name) + if err != nil { + return nil, err + } + + nsAndRel := nsAndRel{ + Namespace: namespaceName, + Relation: outerRelation.Name, + } + nsAndRelToInfo[nsAndRel] = referenceInfos + } + } + + return nsAndRelToInfo, nil +} + +func expressionReferencesRelation(ctx context.Context, rewrite *core.UsersetRewrite, relationName string) (bool, error) { + // TODO(jschorr): Precompute this and maybe create a visitor pattern to stop repeating this everywhere + switch rw := rewrite.RewriteOperation.(type) { + case *core.UsersetRewrite_Union: + return setOperationReferencesRelation(ctx, rw.Union, relationName) + case *core.UsersetRewrite_Intersection: + return setOperationReferencesRelation(ctx, rw.Intersection, relationName) + case *core.UsersetRewrite_Exclusion: + return setOperationReferencesRelation(ctx, rw.Exclusion, relationName) + default: + return false, errors.New("userset rewrite operation not implemented in expressionReferencesRelation") + } +} + +func setOperationReferencesRelation(ctx context.Context, so *core.SetOperation, relationName string) (bool, error) { + for _, childOneof := range so.Child { + switch child := childOneof.ChildType.(type) { + case *core.SetOperation_Child_ComputedUserset: + if child.ComputedUserset.Relation == relationName { + return true, nil + } + + case *core.SetOperation_Child_UsersetRewrite: + result, err := expressionReferencesRelation(ctx, child.UsersetRewrite, relationName) + if result || err != nil { + return result, err + } + + case *core.SetOperation_Child_TupleToUserset: + // Nothing to do, handled above via arrow set + + case *core.SetOperation_Child_XThis: + // Nothing to do + + case *core.SetOperation_Child_XNil: + // Nothing to do + + default: + return false, fmt.Errorf("unknown set operation child `%T` in setOperationReferencesRelation", child) + } + } + + return false, nil +} diff --git a/vendor/github.com/authzed/spicedb/pkg/schema/reachabilitygraph.go b/vendor/github.com/authzed/spicedb/pkg/schema/reachabilitygraph.go new file mode 100644 index 0000000..dd252e2 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/schema/reachabilitygraph.go @@ -0,0 +1,452 @@ +package schema + +import ( + "context" + "fmt" + "sort" + "strconv" + "sync" + + "github.com/cespare/xxhash/v2" + "golang.org/x/exp/maps" + + "github.com/authzed/spicedb/pkg/genutil/mapz" + core "github.com/authzed/spicedb/pkg/proto/core/v1" + "github.com/authzed/spicedb/pkg/spiceerrors" + "github.com/authzed/spicedb/pkg/tuple" +) + +// DefinitionReachability is a helper struct that provides an easy way to determine all entrypoints +// for a subject of a particular type into a schema, for the purpose of walking from the subject +// to a specific resource relation. +type DefinitionReachability struct { + def *Definition + cachedGraphs sync.Map + hasOptimizedEntrypointCache sync.Map +} + +// Reachability returns a reachability graph for the given namespace. +func (def *Definition) Reachability() *DefinitionReachability { + return &DefinitionReachability{def, sync.Map{}, sync.Map{}} +} + +// RelationsEncounteredForResource returns all relations that are encountered when walking outward from a resource+relation. +func (rg *DefinitionReachability) RelationsEncounteredForResource( + ctx context.Context, + resourceType *core.RelationReference, +) ([]*core.RelationReference, error) { + _, relationNames, err := rg.computeEntrypoints(ctx, resourceType, nil /* include all entrypoints */, reachabilityFull, entrypointLookupFindAll) + if err != nil { + return nil, err + } + + relationRefs := make([]*core.RelationReference, 0, len(relationNames)) + for _, relationName := range relationNames { + namespace, relation := tuple.MustSplitRelRef(relationName) + relationRefs = append(relationRefs, &core.RelationReference{ + Namespace: namespace, + Relation: relation, + }) + } + return relationRefs, nil +} + +// RelationsEncounteredForSubject returns all relations that are encountered when walking outward from a subject+relation. +func (rg *DefinitionReachability) RelationsEncounteredForSubject( + ctx context.Context, + allDefinitions []*core.NamespaceDefinition, + startingSubjectType *core.RelationReference, +) ([]*core.RelationReference, error) { + if startingSubjectType.Namespace != rg.def.nsDef.Name { + return nil, spiceerrors.MustBugf("gave mismatching namespace name for subject type to reachability graph") + } + + allRelationNames := mapz.NewSet[string]() + + subjectTypesToCheck := []*core.RelationReference{startingSubjectType} + + // TODO(jschorr): optimize this to not require walking over all types recursively. + added := mapz.NewSet[string]() + for { + if len(subjectTypesToCheck) == 0 { + break + } + + collected := &[]ReachabilityEntrypoint{} + for _, nsDef := range allDefinitions { + nts, err := rg.def.ts.GetDefinition(ctx, nsDef.Name) + if err != nil { + return nil, err + } + + nrg := nts.Reachability() + + for _, relation := range nsDef.Relation { + for _, subjectType := range subjectTypesToCheck { + if subjectType.Namespace == nsDef.Name && subjectType.Relation == relation.Name { + continue + } + + encounteredRelations := map[string]struct{}{} + err := nrg.collectEntrypoints(ctx, &core.RelationReference{ + Namespace: nsDef.Name, + Relation: relation.Name, + }, subjectType, collected, encounteredRelations, reachabilityFull, entrypointLookupFindAll) + if err != nil { + return nil, err + } + } + } + } + + subjectTypesToCheck = make([]*core.RelationReference, 0, len(*collected)) + + for _, entrypoint := range *collected { + st := tuple.JoinRelRef(entrypoint.re.TargetRelation.Namespace, entrypoint.re.TargetRelation.Relation) + if !added.Add(st) { + continue + } + + allRelationNames.Add(st) + subjectTypesToCheck = append(subjectTypesToCheck, entrypoint.re.TargetRelation) + } + } + + relationRefs := make([]*core.RelationReference, 0, allRelationNames.Len()) + for _, relationName := range allRelationNames.AsSlice() { + namespace, relation := tuple.MustSplitRelRef(relationName) + relationRefs = append(relationRefs, &core.RelationReference{ + Namespace: namespace, + Relation: relation, + }) + } + return relationRefs, nil +} + +// AllEntrypointsForSubjectToResource returns the entrypoints into the reachability graph, starting +// at the given subject type and walking to the given resource type. +func (rg *DefinitionReachability) AllEntrypointsForSubjectToResource( + ctx context.Context, + subjectType *core.RelationReference, + resourceType *core.RelationReference, +) ([]ReachabilityEntrypoint, error) { + entrypoints, _, err := rg.computeEntrypoints(ctx, resourceType, subjectType, reachabilityFull, entrypointLookupFindAll) + return entrypoints, err +} + +// FirstEntrypointsForSubjectToResource returns the *optimized* set of entrypoints into the +// reachability graph, starting at the given subject type and walking to the given resource type. +// +// It does this by limiting the number of entrypoints (and checking the alternatives) and so simply returns the first entrypoint in an +// intersection or exclusion branch. +func (rg *DefinitionReachability) FirstEntrypointsForSubjectToResource( + ctx context.Context, + subjectType *core.RelationReference, + resourceType *core.RelationReference, +) ([]ReachabilityEntrypoint, error) { + entrypoints, _, err := rg.computeEntrypoints(ctx, resourceType, subjectType, reachabilityFirst, entrypointLookupFindAll) + return entrypoints, err +} + +// HasOptimizedEntrypointsForSubjectToResource returns whether there exists any *optimized* +// entrypoints into the reachability graph, starting at the given subject type and walking +// to the given resource type. +// +// The optimized set will skip branches on intersections and exclusions in an attempt to minimize +// the number of entrypoints. +func (rg *DefinitionReachability) HasOptimizedEntrypointsForSubjectToResource( + ctx context.Context, + subjectType *core.RelationReference, + resourceType *core.RelationReference, +) (bool, error) { + // TODO(jschorr): Change this to be indexed by a struct + cacheKey := tuple.StringCoreRR(subjectType) + "=>" + tuple.StringCoreRR(resourceType) + if result, ok := rg.hasOptimizedEntrypointCache.Load(cacheKey); ok { + return result.(bool), nil + } + + // TODO(jzelinskie): measure to see if it's worth singleflighting this + found, _, err := rg.computeEntrypoints(ctx, resourceType, subjectType, reachabilityFirst, entrypointLookupFindOne) + if err != nil { + return false, err + } + + result := len(found) > 0 + rg.hasOptimizedEntrypointCache.Store(cacheKey, result) + return result, nil +} + +type entrypointLookupOption int + +const ( + entrypointLookupFindAll entrypointLookupOption = iota + entrypointLookupFindOne +) + +func (rg *DefinitionReachability) computeEntrypoints( + ctx context.Context, + resourceType *core.RelationReference, + optionalSubjectType *core.RelationReference, + reachabilityOption reachabilityOption, + entrypointLookupOption entrypointLookupOption, +) ([]ReachabilityEntrypoint, []string, error) { + if resourceType.Namespace != rg.def.nsDef.Name { + return nil, nil, fmt.Errorf("gave mismatching namespace name for resource type to reachability graph") + } + + collected := &[]ReachabilityEntrypoint{} + encounteredRelations := map[string]struct{}{} + err := rg.collectEntrypoints(ctx, resourceType, optionalSubjectType, collected, encounteredRelations, reachabilityOption, entrypointLookupOption) + if err != nil { + return nil, maps.Keys(encounteredRelations), err + } + + collectedEntrypoints := *collected + + // Deduplicate any entrypoints found. An example that can cause a duplicate is a relation which references + // the same subject type multiple times due to caveats: + // + // relation somerel: user | user with somecaveat + // + // This will produce two entrypoints (one per user reference), but as entrypoints themselves are not caveated, + // one is spurious. + entrypointMap := make(map[uint64]ReachabilityEntrypoint, len(collectedEntrypoints)) + uniqueEntrypoints := make([]ReachabilityEntrypoint, 0, len(collectedEntrypoints)) + for _, entrypoint := range collectedEntrypoints { + hash, err := entrypoint.Hash() + if err != nil { + return nil, maps.Keys(encounteredRelations), err + } + + if _, ok := entrypointMap[hash]; !ok { + entrypointMap[hash] = entrypoint + uniqueEntrypoints = append(uniqueEntrypoints, entrypoint) + } + } + + return uniqueEntrypoints, maps.Keys(encounteredRelations), nil +} + +func (rg *DefinitionReachability) getOrBuildGraph(ctx context.Context, resourceType *core.RelationReference, reachabilityOption reachabilityOption) (*core.ReachabilityGraph, error) { + // Check the cache. + // TODO(jschorr): Change to be indexed by a struct. + cacheKey := tuple.StringCoreRR(resourceType) + "-" + strconv.Itoa(int(reachabilityOption)) + if cached, ok := rg.cachedGraphs.Load(cacheKey); ok { + return cached.(*core.ReachabilityGraph), nil + } + + // Load the type system for the target resource relation. + tdef, err := rg.def.ts.GetDefinition(ctx, resourceType.Namespace) + if err != nil { + return nil, err + } + + rrg, err := computeReachability(ctx, tdef, resourceType.Relation, reachabilityOption) + if err != nil { + return nil, err + } + + rg.cachedGraphs.Store(cacheKey, rrg) + return rrg, err +} + +func (rg *DefinitionReachability) collectEntrypoints( + ctx context.Context, + resourceType *core.RelationReference, + optionalSubjectType *core.RelationReference, + collected *[]ReachabilityEntrypoint, + encounteredRelations map[string]struct{}, + reachabilityOption reachabilityOption, + entrypointLookupOption entrypointLookupOption, +) error { + // Ensure that we only process each relation once. + key := tuple.JoinRelRef(resourceType.Namespace, resourceType.Relation) + if _, ok := encounteredRelations[key]; ok { + return nil + } + + encounteredRelations[key] = struct{}{} + + rrg, err := rg.getOrBuildGraph(ctx, resourceType, reachabilityOption) + if err != nil { + return err + } + + if optionalSubjectType != nil { + // Add subject type entrypoints. + subjectTypeEntrypoints, ok := rrg.EntrypointsBySubjectType[optionalSubjectType.Namespace] + if ok { + addEntrypoints(subjectTypeEntrypoints, resourceType, collected, encounteredRelations) + } + + if entrypointLookupOption == entrypointLookupFindOne && len(*collected) > 0 { + return nil + } + + // Add subject relation entrypoints. + subjectRelationEntrypoints, ok := rrg.EntrypointsBySubjectRelation[tuple.JoinRelRef(optionalSubjectType.Namespace, optionalSubjectType.Relation)] + if ok { + addEntrypoints(subjectRelationEntrypoints, resourceType, collected, encounteredRelations) + } + + if entrypointLookupOption == entrypointLookupFindOne && len(*collected) > 0 { + return nil + } + } else { + // Add all entrypoints. + for _, entrypoints := range rrg.EntrypointsBySubjectType { + addEntrypoints(entrypoints, resourceType, collected, encounteredRelations) + } + + for _, entrypoints := range rrg.EntrypointsBySubjectRelation { + addEntrypoints(entrypoints, resourceType, collected, encounteredRelations) + } + } + + // Sort the keys to ensure a stable graph is produced. + keys := maps.Keys(rrg.EntrypointsBySubjectRelation) + sort.Strings(keys) + + // Recursively collect over any reachability graphs for subjects with non-ellipsis relations. + for _, entrypointSetKey := range keys { + entrypointSet := rrg.EntrypointsBySubjectRelation[entrypointSetKey] + if entrypointSet.SubjectRelation != nil && entrypointSet.SubjectRelation.Relation != tuple.Ellipsis { + err := rg.collectEntrypoints(ctx, entrypointSet.SubjectRelation, optionalSubjectType, collected, encounteredRelations, reachabilityOption, entrypointLookupOption) + if err != nil { + return err + } + + if entrypointLookupOption == entrypointLookupFindOne && len(*collected) > 0 { + return nil + } + } + } + + return nil +} + +func addEntrypoints(entrypoints *core.ReachabilityEntrypoints, parentRelation *core.RelationReference, collected *[]ReachabilityEntrypoint, encounteredRelations map[string]struct{}) { + for _, entrypoint := range entrypoints.Entrypoints { + if entrypoint.TuplesetRelation != "" { + key := tuple.JoinRelRef(entrypoint.TargetRelation.Namespace, entrypoint.TuplesetRelation) + encounteredRelations[key] = struct{}{} + } + + *collected = append(*collected, ReachabilityEntrypoint{entrypoint, parentRelation}) + } +} + +// ReachabilityEntrypoint is an entrypoint into the reachability graph for a subject of particular +// type. +type ReachabilityEntrypoint struct { + re *core.ReachabilityEntrypoint + parentRelation *core.RelationReference +} + +// Hash returns a hash representing the data in the entrypoint, for comparison to other entrypoints. +// This is ONLY stable within a single version of SpiceDB and should NEVER be stored for later +// comparison outside of the process. +func (re ReachabilityEntrypoint) Hash() (uint64, error) { + size := re.re.SizeVT() + if re.parentRelation != nil { + size += re.parentRelation.SizeVT() + } + + hashData := make([]byte, 0, size) + + data, err := re.re.MarshalVT() + if err != nil { + return 0, err + } + + hashData = append(hashData, data...) + + if re.parentRelation != nil { + data, err := re.parentRelation.MarshalVT() + if err != nil { + return 0, err + } + + hashData = append(hashData, data...) + } + + return xxhash.Sum64(hashData), nil +} + +// EntrypointKind is the kind of the entrypoint. +func (re ReachabilityEntrypoint) EntrypointKind() core.ReachabilityEntrypoint_ReachabilityEntrypointKind { + return re.re.Kind +} + +// ComputedUsersetRelation returns the tupleset relation of the computed userset, if any. +func (re ReachabilityEntrypoint) ComputedUsersetRelation() (string, error) { + if re.EntrypointKind() == core.ReachabilityEntrypoint_RELATION_ENTRYPOINT { + return "", fmt.Errorf("cannot call ComputedUsersetRelation for kind %v", re.EntrypointKind()) + } + return re.re.ComputedUsersetRelation, nil +} + +// TuplesetRelation returns the tupleset relation of the TTU, if a TUPLESET_TO_USERSET_ENTRYPOINT. +func (re ReachabilityEntrypoint) TuplesetRelation() (string, error) { + if re.EntrypointKind() != core.ReachabilityEntrypoint_TUPLESET_TO_USERSET_ENTRYPOINT { + return "", fmt.Errorf("cannot call TupleToUserset for kind %v", re.EntrypointKind()) + } + + return re.re.TuplesetRelation, nil +} + +// DirectRelation is the relation that this entrypoint represents, if a RELATION_ENTRYPOINT. +func (re ReachabilityEntrypoint) DirectRelation() (*core.RelationReference, error) { + if re.EntrypointKind() != core.ReachabilityEntrypoint_RELATION_ENTRYPOINT { + return nil, fmt.Errorf("cannot call DirectRelation for kind %v", re.EntrypointKind()) + } + + return re.re.TargetRelation, nil +} + +// TargetNamespace returns the namespace for the entrypoint's target relation. +func (re ReachabilityEntrypoint) TargetNamespace() string { + return re.re.TargetRelation.Namespace +} + +// ContainingRelationOrPermission is the relation or permission containing this entrypoint. +func (re ReachabilityEntrypoint) ContainingRelationOrPermission() *core.RelationReference { + return re.parentRelation +} + +// IsDirectResult returns whether the entrypoint, when evaluated, becomes a direct result of +// the parent relation/permission. A direct result only exists if the entrypoint is not contained +// under an intersection or exclusion, which makes the entrypoint's object merely conditionally +// reachable. +func (re ReachabilityEntrypoint) IsDirectResult() bool { + return re.re.ResultStatus == core.ReachabilityEntrypoint_DIRECT_OPERATION_RESULT +} + +func (re ReachabilityEntrypoint) String() string { + return re.MustDebugString() +} + +func (re ReachabilityEntrypoint) MustDebugString() string { + ds, err := re.DebugString() + if err != nil { + panic(err) + } + + return ds +} + +func (re ReachabilityEntrypoint) DebugString() (string, error) { + switch re.EntrypointKind() { + case core.ReachabilityEntrypoint_RELATION_ENTRYPOINT: + return "relation-entrypoint: " + re.re.TargetRelation.Namespace + "#" + re.re.TargetRelation.Relation, nil + + case core.ReachabilityEntrypoint_TUPLESET_TO_USERSET_ENTRYPOINT: + return "ttu-entrypoint: " + re.re.TuplesetRelation + " -> " + re.re.TargetRelation.Namespace + "#" + re.re.TargetRelation.Relation, nil + + case core.ReachabilityEntrypoint_COMPUTED_USERSET_ENTRYPOINT: + return "computed-userset-entrypoint: " + re.re.TargetRelation.Namespace + "#" + re.re.TargetRelation.Relation, nil + + default: + return "", fmt.Errorf("unknown entrypoint kind %v", re.EntrypointKind()) + } +} diff --git a/vendor/github.com/authzed/spicedb/pkg/schema/reachabilitygraphbuilder.go b/vendor/github.com/authzed/spicedb/pkg/schema/reachabilitygraphbuilder.go new file mode 100644 index 0000000..e8f8608 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/schema/reachabilitygraphbuilder.go @@ -0,0 +1,275 @@ +package schema + +import ( + "context" + "fmt" + + "github.com/authzed/spicedb/pkg/spiceerrors" + "github.com/authzed/spicedb/pkg/tuple" + + core "github.com/authzed/spicedb/pkg/proto/core/v1" +) + +type reachabilityOption int + +const ( + reachabilityFull reachabilityOption = iota + reachabilityFirst +) + +func computeReachability(ctx context.Context, def *Definition, relationName string, option reachabilityOption) (*core.ReachabilityGraph, error) { + targetRelation, ok := def.relationMap[relationName] + if !ok { + return nil, fmt.Errorf("relation `%s` not found under type `%s` missing when computing reachability", relationName, def.nsDef.Name) + } + + if !def.HasTypeInformation(relationName) && targetRelation.GetUsersetRewrite() == nil { + return nil, fmt.Errorf("relation `%s` missing type information when computing reachability for namespace `%s`", relationName, def.nsDef.Name) + } + + graph := &core.ReachabilityGraph{ + EntrypointsBySubjectType: map[string]*core.ReachabilityEntrypoints{}, + EntrypointsBySubjectRelation: map[string]*core.ReachabilityEntrypoints{}, + } + + usersetRewrite := targetRelation.GetUsersetRewrite() + if usersetRewrite != nil { + return graph, computeRewriteReachability(ctx, graph, usersetRewrite, core.ReachabilityEntrypoint_DIRECT_OPERATION_RESULT, targetRelation, def, option) + } + + // If there is no userRewrite, then we have a relation and its entrypoints will all be + // relation entrypoints. + return graph, addSubjectLinks(graph, core.ReachabilityEntrypoint_DIRECT_OPERATION_RESULT, targetRelation, def) +} + +func computeRewriteReachability(ctx context.Context, graph *core.ReachabilityGraph, rewrite *core.UsersetRewrite, operationResultState core.ReachabilityEntrypoint_EntrypointResultStatus, targetRelation *core.Relation, def *Definition, option reachabilityOption) error { + switch rw := rewrite.RewriteOperation.(type) { + case *core.UsersetRewrite_Union: + return computeRewriteOpReachability(ctx, rw.Union.Child, operationResultState, graph, targetRelation, def, option) + + case *core.UsersetRewrite_Intersection: + // If optimized mode is set, only return the first child of the intersection. + if option == reachabilityFirst { + return computeRewriteOpReachability(ctx, rw.Intersection.Child[0:1], core.ReachabilityEntrypoint_REACHABLE_CONDITIONAL_RESULT, graph, targetRelation, def, option) + } + + return computeRewriteOpReachability(ctx, rw.Intersection.Child, core.ReachabilityEntrypoint_REACHABLE_CONDITIONAL_RESULT, graph, targetRelation, def, option) + + case *core.UsersetRewrite_Exclusion: + // If optimized mode is set, only return the first child of the exclusion. + if option == reachabilityFirst { + return computeRewriteOpReachability(ctx, rw.Exclusion.Child[0:1], core.ReachabilityEntrypoint_REACHABLE_CONDITIONAL_RESULT, graph, targetRelation, def, option) + } + + return computeRewriteOpReachability(ctx, rw.Exclusion.Child, core.ReachabilityEntrypoint_REACHABLE_CONDITIONAL_RESULT, graph, targetRelation, def, option) + + default: + return fmt.Errorf("unknown kind of userset rewrite in reachability computation: %T", rw) + } +} + +func computeRewriteOpReachability(ctx context.Context, children []*core.SetOperation_Child, operationResultState core.ReachabilityEntrypoint_EntrypointResultStatus, graph *core.ReachabilityGraph, targetRelation *core.Relation, def *Definition, option reachabilityOption) error { + rr := &core.RelationReference{ + Namespace: def.nsDef.Name, + Relation: targetRelation.Name, + } + + for _, childOneof := range children { + switch child := childOneof.ChildType.(type) { + case *core.SetOperation_Child_XThis: + return fmt.Errorf("use of _this is unsupported; please rewrite your schema") + + case *core.SetOperation_Child_ComputedUserset: + // A computed userset adds an entrypoint indicating that the relation is rewritten. + err := addSubjectEntrypoint(graph, def.nsDef.Name, child.ComputedUserset.Relation, &core.ReachabilityEntrypoint{ + Kind: core.ReachabilityEntrypoint_COMPUTED_USERSET_ENTRYPOINT, + TargetRelation: rr, + ComputedUsersetRelation: child.ComputedUserset.Relation, + ResultStatus: operationResultState, + }) + if err != nil { + return err + } + + case *core.SetOperation_Child_UsersetRewrite: + err := computeRewriteReachability(ctx, graph, child.UsersetRewrite, operationResultState, targetRelation, def, option) + if err != nil { + return err + } + + case *core.SetOperation_Child_TupleToUserset: + tuplesetRelation := child.TupleToUserset.Tupleset.Relation + computedUsersetRelation := child.TupleToUserset.ComputedUserset.Relation + if err := computeTTUReachability(ctx, graph, tuplesetRelation, computedUsersetRelation, operationResultState, rr, def); err != nil { + return err + } + + case *core.SetOperation_Child_FunctionedTupleToUserset: + tuplesetRelation := child.FunctionedTupleToUserset.Tupleset.Relation + computedUsersetRelation := child.FunctionedTupleToUserset.ComputedUserset.Relation + + switch child.FunctionedTupleToUserset.Function { + case core.FunctionedTupleToUserset_FUNCTION_ANY: + // Nothing to change. + + case core.FunctionedTupleToUserset_FUNCTION_ALL: + // Mark as a conditional result. + operationResultState = core.ReachabilityEntrypoint_REACHABLE_CONDITIONAL_RESULT + + default: + return spiceerrors.MustBugf("unknown function type `%T` in reachability graph building", child.FunctionedTupleToUserset.Function) + } + + if err := computeTTUReachability(ctx, graph, tuplesetRelation, computedUsersetRelation, operationResultState, rr, def); err != nil { + return err + } + + case *core.SetOperation_Child_XNil: + // nil has no entrypoints. + return nil + + default: + return spiceerrors.MustBugf("unknown set operation child `%T` in reachability graph building", child) + } + } + + return nil +} + +func computeTTUReachability( + ctx context.Context, + graph *core.ReachabilityGraph, + tuplesetRelation string, + computedUsersetRelation string, + operationResultState core.ReachabilityEntrypoint_EntrypointResultStatus, + rr *core.RelationReference, + def *Definition, +) error { + directRelationTypes, err := def.AllowedDirectRelationsAndWildcards(tuplesetRelation) + if err != nil { + return err + } + + for _, allowedRelationType := range directRelationTypes { + // For each namespace allowed to be found on the right hand side of the + // tupleset relation, include the *computed userset* relation as an entrypoint. + // + // For example, given a schema: + // + // ``` + // definition user {} + // + // definition parent1 { + // relation somerel: user + // } + // + // definition parent2 { + // relation somerel: user + // } + // + // definition child { + // relation parent: parent1 | parent2 + // permission someperm = parent->somerel + // } + // ``` + // + // We will add an entrypoint for the arrow itself, keyed to the relation type + // included from the computed userset. + // + // Using the above example, this will add entrypoints for `parent1#somerel` + // and `parent2#somerel`, which are the subjects reached after resolving the + // right side of the arrow. + + // Check if the relation does exist on the allowed type, and only add the entrypoint if present. + relDef, err := def.ts.GetDefinition(ctx, allowedRelationType.Namespace) + if err != nil { + return err + } + + if relDef.HasRelation(computedUsersetRelation) { + err := addSubjectEntrypoint(graph, allowedRelationType.Namespace, computedUsersetRelation, &core.ReachabilityEntrypoint{ + Kind: core.ReachabilityEntrypoint_TUPLESET_TO_USERSET_ENTRYPOINT, + TargetRelation: rr, + ResultStatus: operationResultState, + ComputedUsersetRelation: computedUsersetRelation, + TuplesetRelation: tuplesetRelation, + }) + if err != nil { + return err + } + } + } + + return nil +} + +func addSubjectEntrypoint(graph *core.ReachabilityGraph, namespaceName string, relationName string, entrypoint *core.ReachabilityEntrypoint) error { + key := tuple.JoinRelRef(namespaceName, relationName) + if relationName == "" { + return spiceerrors.MustBugf("found empty relation name for subject entrypoint") + } + + if graph.EntrypointsBySubjectRelation[key] == nil { + graph.EntrypointsBySubjectRelation[key] = &core.ReachabilityEntrypoints{ + Entrypoints: []*core.ReachabilityEntrypoint{}, + SubjectRelation: &core.RelationReference{ + Namespace: namespaceName, + Relation: relationName, + }, + } + } + + graph.EntrypointsBySubjectRelation[key].Entrypoints = append( + graph.EntrypointsBySubjectRelation[key].Entrypoints, + entrypoint, + ) + + return nil +} + +func addSubjectLinks(graph *core.ReachabilityGraph, operationResultState core.ReachabilityEntrypoint_EntrypointResultStatus, relation *core.Relation, def *Definition) error { + typeInfo := relation.GetTypeInformation() + if typeInfo == nil { + return fmt.Errorf("missing type information for relation %s#%s", def.nsDef.Name, relation.Name) + } + + rr := &core.RelationReference{ + Namespace: def.nsDef.Name, + Relation: relation.Name, + } + + allowedDirectRelations := typeInfo.GetAllowedDirectRelations() + for _, directRelation := range allowedDirectRelations { + // If the allowed relation is a wildcard, add it as a subject *type* entrypoint, rather than + // a subject relation. + if directRelation.GetPublicWildcard() != nil { + if graph.EntrypointsBySubjectType[directRelation.Namespace] == nil { + graph.EntrypointsBySubjectType[directRelation.Namespace] = &core.ReachabilityEntrypoints{ + Entrypoints: []*core.ReachabilityEntrypoint{}, + SubjectType: directRelation.Namespace, + } + } + + graph.EntrypointsBySubjectType[directRelation.Namespace].Entrypoints = append( + graph.EntrypointsBySubjectType[directRelation.Namespace].Entrypoints, + &core.ReachabilityEntrypoint{ + Kind: core.ReachabilityEntrypoint_RELATION_ENTRYPOINT, + TargetRelation: rr, + ResultStatus: operationResultState, + }, + ) + continue + } + + err := addSubjectEntrypoint(graph, directRelation.Namespace, directRelation.GetRelation(), &core.ReachabilityEntrypoint{ + Kind: core.ReachabilityEntrypoint_RELATION_ENTRYPOINT, + TargetRelation: rr, + ResultStatus: operationResultState, + }) + if err != nil { + return err + } + } + + return nil +} diff --git a/vendor/github.com/authzed/spicedb/pkg/schema/resolver.go b/vendor/github.com/authzed/spicedb/pkg/schema/resolver.go new file mode 100644 index 0000000..4610886 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/schema/resolver.go @@ -0,0 +1,114 @@ +package schema + +import ( + "context" + "fmt" + "slices" + + "github.com/authzed/spicedb/pkg/datastore" + core "github.com/authzed/spicedb/pkg/proto/core/v1" + "github.com/authzed/spicedb/pkg/schemadsl/compiler" +) + +// Resolver is an interface defined for resolving referenced namespaces and caveats when constructing +// and validating a type system. +type Resolver interface { + // LookupDefinition lookups up a namespace definition, also returning whether it was pre-validated. + LookupDefinition(ctx context.Context, name string) (*core.NamespaceDefinition, bool, error) + + // LookupCaveat lookups up a caveat. + LookupCaveat(ctx context.Context, name string) (*Caveat, error) +} + +// ResolverForDatastoreReader returns a Resolver for a datastore reader. +func ResolverForDatastoreReader(ds datastore.Reader) *DatastoreResolver { + return &DatastoreResolver{ + ds: ds, + } +} + +// PredefinedElements are predefined namespaces and/or caveats to give to a resolver. +type PredefinedElements struct { + Definitions []*core.NamespaceDefinition + Caveats []*Caveat +} + +func (pe PredefinedElements) combineWith(other PredefinedElements) PredefinedElements { + return PredefinedElements{ + Definitions: append(slices.Clone(pe.Definitions), other.Definitions...), + Caveats: append(slices.Clone(pe.Caveats), other.Caveats...), + } +} + +// ResolverForPredefinedDefinitions returns a resolver for predefined namespaces and caveats. +func ResolverForPredefinedDefinitions(predefined PredefinedElements) Resolver { + return &DatastoreResolver{ + predefined: predefined, + } +} + +// ResolverForSchema returns a resolver for a schema. +func ResolverForSchema(schema compiler.CompiledSchema) Resolver { + return ResolverForPredefinedDefinitions( + PredefinedElements{ + Definitions: schema.ObjectDefinitions, + Caveats: schema.CaveatDefinitions, + }, + ) +} + +// DatastoreResolver is a resolver implementation for a datastore, to look up schema stored in the underlying storage. +type DatastoreResolver struct { + ds datastore.Reader + predefined PredefinedElements +} + +// LookupDefinition lookups up a namespace definition, also returning whether it was pre-validated. +func (r *DatastoreResolver) LookupDefinition(ctx context.Context, name string) (*core.NamespaceDefinition, bool, error) { + if len(r.predefined.Definitions) > 0 { + for _, def := range r.predefined.Definitions { + if def.Name == name { + return def, false, nil + } + } + } + + if r.ds == nil { + return nil, false, asTypeError(NewDefinitionNotFoundErr(name)) + } + + ns, _, err := r.ds.ReadNamespaceByName(ctx, name) + return ns, true, err +} + +// WithPredefinedElements adds elements (definitions and caveats) that will be used as a local overlay +// for the datastore, often for validation. +func (r *DatastoreResolver) WithPredefinedElements(predefined PredefinedElements) Resolver { + return &DatastoreResolver{ + ds: r.ds, + predefined: predefined.combineWith(r.predefined), + } +} + +// LookupCaveat lookups up a caveat. +func (r *DatastoreResolver) LookupCaveat(ctx context.Context, name string) (*Caveat, error) { + if len(r.predefined.Caveats) > 0 { + for _, caveat := range r.predefined.Caveats { + if caveat.Name == name { + return caveat, nil + } + } + } + + if r.ds == nil { + return nil, asTypeError(NewCaveatNotFoundErr(name)) + } + + cr, ok := r.ds.(datastore.CaveatReader) + if !ok { + return nil, fmt.Errorf("caveats are not supported on this datastore type") + } + + caveatDef, _, err := cr.ReadCaveatByName(ctx, name) + return caveatDef, err +} diff --git a/vendor/github.com/authzed/spicedb/pkg/schema/typesystem.go b/vendor/github.com/authzed/spicedb/pkg/schema/typesystem.go new file mode 100644 index 0000000..cc989e9 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/schema/typesystem.go @@ -0,0 +1,66 @@ +package schema + +import ( + "context" + "sync" + + core "github.com/authzed/spicedb/pkg/proto/core/v1" +) + +type ( + // Caveat is an alias for a core.CaveatDefinition proto + Caveat = core.CaveatDefinition + // Relation is an alias for a core.Relation proto + Relation = core.Relation +) + +// TypeSystem is a cache and view into an entire combined schema of type definitions and caveats. +// It also provides accessors to build reachability graphs for the underlying types. +type TypeSystem struct { + sync.Mutex + validatedDefinitions map[string]*ValidatedDefinition // GUARDED_BY(Mutex) + resolver Resolver + wildcardCheckCache map[string]*WildcardTypeReference +} + +// NewTypeSystem builds a TypeSystem object from a resolver, which can look up the definitions. +func NewTypeSystem(resolver Resolver) *TypeSystem { + return &TypeSystem{ + validatedDefinitions: make(map[string]*ValidatedDefinition), + resolver: resolver, + wildcardCheckCache: nil, + } +} + +// GetDefinition looks up and returns a definition struct. +func (ts *TypeSystem) GetDefinition(ctx context.Context, definition string) (*Definition, error) { + v, _, err := ts.getDefinition(ctx, definition) + return v, err +} + +// getDefinition is an internal helper for GetDefinition and GetValidatedDefinition +func (ts *TypeSystem) getDefinition(ctx context.Context, definition string) (*Definition, bool, error) { + ts.Lock() + v, ok := ts.validatedDefinitions[definition] + ts.Unlock() + if ok { + return v.Definition, true, nil + } + + ns, prevalidated, err := ts.resolver.LookupDefinition(ctx, definition) + if err != nil { + return nil, false, err + } + d, err := NewDefinition(ts, ns) + if err != nil { + return nil, false, err + } + if prevalidated { + ts.Lock() + if _, ok := ts.validatedDefinitions[definition]; !ok { + ts.validatedDefinitions[definition] = &ValidatedDefinition{Definition: d} + } + ts.Unlock() + } + return d, prevalidated, nil +} diff --git a/vendor/github.com/authzed/spicedb/pkg/schema/typesystem_validation.go b/vendor/github.com/authzed/spicedb/pkg/schema/typesystem_validation.go new file mode 100644 index 0000000..fa9315e --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/schema/typesystem_validation.go @@ -0,0 +1,361 @@ +package schema + +import ( + "context" + "fmt" + + "github.com/authzed/spicedb/pkg/genutil/mapz" + "github.com/authzed/spicedb/pkg/graph" + nspkg "github.com/authzed/spicedb/pkg/namespace" + core "github.com/authzed/spicedb/pkg/proto/core/v1" + iv1 "github.com/authzed/spicedb/pkg/proto/impl/v1" + "github.com/authzed/spicedb/pkg/tuple" +) + +// GetValidatedDefinition runs validation on the type system for the definition to ensure it is consistent. +func (ts *TypeSystem) GetValidatedDefinition(ctx context.Context, definition string) (*ValidatedDefinition, error) { + def, validated, err := ts.getDefinition(ctx, definition) + if err != nil { + return nil, err + } + if validated { + return &ValidatedDefinition{Definition: def}, nil + } + vdef, err := def.Validate(ctx) + if err != nil { + return nil, err + } + ts.Lock() + defer ts.Unlock() + if _, ok := ts.validatedDefinitions[definition]; !ok { + ts.validatedDefinitions[definition] = vdef + } + return vdef, nil +} + +func (def *Definition) Validate(ctx context.Context) (*ValidatedDefinition, error) { + for _, relation := range def.relationMap { + relation := relation + + // Validate the usersets's. + usersetRewrite := relation.GetUsersetRewrite() + rerr, err := graph.WalkRewrite(usersetRewrite, func(childOneof *core.SetOperation_Child) (any, error) { + switch child := childOneof.ChildType.(type) { + case *core.SetOperation_Child_ComputedUserset: + relationName := child.ComputedUserset.GetRelation() + _, ok := def.relationMap[relationName] + if !ok { + return NewTypeWithSourceError( + NewRelationNotFoundErr(def.nsDef.Name, relationName), + childOneof, + relationName, + ), nil + } + + case *core.SetOperation_Child_TupleToUserset: + ttu := child.TupleToUserset + if ttu == nil { + return nil, nil + } + + tupleset := ttu.GetTupleset() + if tupleset == nil { + return nil, nil + } + + relationName := tupleset.GetRelation() + found, ok := def.relationMap[relationName] + if !ok { + return NewTypeWithSourceError( + NewRelationNotFoundErr(def.nsDef.Name, relationName), + childOneof, + relationName, + ), nil + } + + if nspkg.GetRelationKind(found) == iv1.RelationMetadata_PERMISSION { + return NewTypeWithSourceError( + NewPermissionUsedOnLeftOfArrowErr(def.nsDef.Name, relation.Name, relationName), + childOneof, relationName), nil + } + + // Ensure the tupleset relation doesn't itself import wildcard. + referencedWildcard, err := def.TypeSystem().referencesWildcardType(ctx, def, relationName) + if err != nil { + return err, nil + } + + if referencedWildcard != nil { + return NewTypeWithSourceError( + NewWildcardUsedInArrowErr( + def.nsDef.Name, + relation.Name, + relationName, + referencedWildcard.WildcardType.GetNamespace(), + tuple.StringCoreRR(referencedWildcard.ReferencingRelation), + ), + childOneof, relationName, + ), nil + } + + case *core.SetOperation_Child_FunctionedTupleToUserset: + ttu := child.FunctionedTupleToUserset + if ttu == nil { + return nil, nil + } + + tupleset := ttu.GetTupleset() + if tupleset == nil { + return nil, nil + } + + relationName := tupleset.GetRelation() + found, ok := def.relationMap[relationName] + if !ok { + return NewTypeWithSourceError( + NewRelationNotFoundErr(def.nsDef.Name, relationName), + childOneof, + relationName, + ), nil + } + + if nspkg.GetRelationKind(found) == iv1.RelationMetadata_PERMISSION { + return NewTypeWithSourceError( + NewPermissionUsedOnLeftOfArrowErr(def.nsDef.Name, relation.Name, relationName), + childOneof, relationName), nil + } + + // Ensure the tupleset relation doesn't itself import wildcard. + referencedWildcard, err := def.TypeSystem().referencesWildcardType(ctx, def, relationName) + if err != nil { + return err, nil + } + + if referencedWildcard != nil { + return NewTypeWithSourceError( + NewWildcardUsedInArrowErr( + def.nsDef.Name, + relation.Name, + relationName, + referencedWildcard.WildcardType.GetNamespace(), + tuple.StringCoreRR(referencedWildcard.ReferencingRelation), + ), + childOneof, relationName, + ), nil + } + } + return nil, nil + }) + if rerr != nil { + return nil, asTypeError(rerr.(error)) + } + if err != nil { + return nil, err + } + + // Validate type information. + typeInfo := relation.TypeInformation + if typeInfo == nil { + continue + } + + allowedDirectRelations := typeInfo.GetAllowedDirectRelations() + + // Check for a _this or the lack of a userset_rewrite. If either is found, + // then the allowed list must have at least one type. + hasThis, err := graph.HasThis(usersetRewrite) + if err != nil { + return nil, err + } + + if usersetRewrite == nil || hasThis { + if len(allowedDirectRelations) == 0 { + return nil, NewTypeWithSourceError( + NewMissingAllowedRelationsErr(def.nsDef.Name, relation.Name), + relation, relation.Name, + ) + } + } else { + if len(allowedDirectRelations) != 0 { + // NOTE: This is a legacy error and should never really occur with schema. + return nil, NewTypeWithSourceError( + fmt.Errorf("direct relations are not allowed under relation `%s`", relation.Name), + relation, relation.Name) + } + } + + // Allowed relations verification: + // 1) that all allowed relations are not this very relation + // 2) that they exist within the referenced namespace + // 3) that they are not duplicated in any way + // 4) that if they have a caveat reference, the caveat is valid + encountered := mapz.NewSet[string]() + + for _, allowedRelation := range allowedDirectRelations { + source := SourceForAllowedRelation(allowedRelation) + if !encountered.Add(source) { + return nil, NewTypeWithSourceError( + NewDuplicateAllowedRelationErr(def.nsDef.Name, relation.Name, source), + allowedRelation, + source, + ) + } + + // Check the namespace. + if allowedRelation.GetNamespace() == def.nsDef.Name { + if allowedRelation.GetPublicWildcard() == nil && allowedRelation.GetRelation() != tuple.Ellipsis { + _, ok := def.relationMap[allowedRelation.GetRelation()] + if !ok { + return nil, NewTypeWithSourceError( + NewRelationNotFoundErr(allowedRelation.GetNamespace(), allowedRelation.GetRelation()), + allowedRelation, + allowedRelation.GetRelation(), + ) + } + } + } else { + subjectTS, err := def.TypeSystem().GetDefinition(ctx, allowedRelation.GetNamespace()) + if err != nil { + return nil, NewTypeWithSourceError( + fmt.Errorf("could not lookup definition `%s` for relation `%s`: %w", allowedRelation.GetNamespace(), relation.Name, err), + allowedRelation, + allowedRelation.GetNamespace(), + ) + } + + // Check for relations. + if allowedRelation.GetPublicWildcard() == nil && allowedRelation.GetRelation() != tuple.Ellipsis { + // Ensure the relation exists. + ok := subjectTS.HasRelation(allowedRelation.GetRelation()) + if !ok { + return nil, NewTypeWithSourceError( + NewRelationNotFoundErr(allowedRelation.GetNamespace(), allowedRelation.GetRelation()), + allowedRelation, + allowedRelation.GetRelation(), + ) + } + + // Ensure the relation doesn't itself import wildcard. + referencedWildcard, err := def.TypeSystem().referencesWildcardType(ctx, subjectTS, allowedRelation.GetRelation()) + if err != nil { + return nil, err + } + + if referencedWildcard != nil { + return nil, NewTypeWithSourceError( + NewTransitiveWildcardErr( + def.nsDef.Name, + relation.GetName(), + allowedRelation.Namespace, + allowedRelation.GetRelation(), + referencedWildcard.WildcardType.GetNamespace(), + tuple.StringCoreRR(referencedWildcard.ReferencingRelation), + ), + allowedRelation, + tuple.JoinRelRef(allowedRelation.GetNamespace(), allowedRelation.GetRelation()), + ) + } + } + } + + // Check the caveat, if any. + if allowedRelation.GetRequiredCaveat() != nil { + _, err := def.TypeSystem().resolver.LookupCaveat(ctx, allowedRelation.GetRequiredCaveat().CaveatName) + if err != nil { + return nil, NewTypeWithSourceError( + fmt.Errorf("could not lookup caveat `%s` for relation `%s`: %w", allowedRelation.GetRequiredCaveat().CaveatName, relation.Name, err), + allowedRelation, + source, + ) + } + } + } + } + + return &ValidatedDefinition{def}, nil +} + +// referencesWildcardType returns true if the relation references a wildcard type, either directly or via +// another relation. +func (ts *TypeSystem) referencesWildcardType(ctx context.Context, def *Definition, relationName string) (*WildcardTypeReference, error) { + return ts.referencesWildcardTypeWithEncountered(ctx, def, relationName, map[string]bool{}) +} + +func (ts *TypeSystem) referencesWildcardTypeWithEncountered(ctx context.Context, def *Definition, relationName string, encountered map[string]bool) (*WildcardTypeReference, error) { + if ts.wildcardCheckCache == nil { + ts.wildcardCheckCache = make(map[string]*WildcardTypeReference, 1) + } + + cached, isCached := ts.wildcardCheckCache[relationName] + if isCached { + return cached, nil + } + + computed, err := ts.computeReferencesWildcardType(ctx, def, relationName, encountered) + if err != nil { + return nil, err + } + + ts.wildcardCheckCache[relationName] = computed + return computed, nil +} + +func (ts *TypeSystem) computeReferencesWildcardType(ctx context.Context, def *Definition, relationName string, encountered map[string]bool) (*WildcardTypeReference, error) { + relString := tuple.JoinRelRef(def.nsDef.Name, relationName) + if _, ok := encountered[relString]; ok { + return nil, nil + } + encountered[relString] = true + + allowedRels, err := def.AllowedDirectRelationsAndWildcards(relationName) + if err != nil { + return nil, asTypeError(err) + } + + for _, allowedRelation := range allowedRels { + if allowedRelation.GetPublicWildcard() != nil { + return &WildcardTypeReference{ + ReferencingRelation: &core.RelationReference{ + Namespace: def.nsDef.Name, + Relation: relationName, + }, + WildcardType: allowedRelation, + }, nil + } + + if allowedRelation.GetRelation() != tuple.Ellipsis { + if allowedRelation.GetNamespace() == def.nsDef.Name { + found, err := ts.referencesWildcardTypeWithEncountered(ctx, def, allowedRelation.GetRelation(), encountered) + if err != nil { + return nil, asTypeError(err) + } + + if found != nil { + return found, nil + } + continue + } + + subjectTS, err := ts.GetDefinition(ctx, allowedRelation.GetNamespace()) + if err != nil { + return nil, asTypeError(err) + } + + found, err := ts.referencesWildcardTypeWithEncountered(ctx, subjectTS, allowedRelation.GetRelation(), encountered) + if err != nil { + return nil, asTypeError(err) + } + + if found != nil { + return found, nil + } + } + } + + return nil, nil +} + +// ValidatedDefinition is a typesafe reference to a definition that has been validated. +type ValidatedDefinition struct { + *Definition +} diff --git a/vendor/github.com/authzed/spicedb/pkg/schemadsl/compiler/compiler.go b/vendor/github.com/authzed/spicedb/pkg/schemadsl/compiler/compiler.go new file mode 100644 index 0000000..d1e96ec --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/schemadsl/compiler/compiler.go @@ -0,0 +1,194 @@ +package compiler + +import ( + "errors" + "fmt" + + "google.golang.org/protobuf/proto" + "k8s.io/utils/strings/slices" + + caveattypes "github.com/authzed/spicedb/pkg/caveats/types" + core "github.com/authzed/spicedb/pkg/proto/core/v1" + "github.com/authzed/spicedb/pkg/schemadsl/dslshape" + "github.com/authzed/spicedb/pkg/schemadsl/input" + "github.com/authzed/spicedb/pkg/schemadsl/parser" +) + +// InputSchema defines the input for a Compile. +type InputSchema struct { + // Source is the source of the schema being compiled. + Source input.Source + + // Schema is the contents being compiled. + SchemaString string +} + +// SchemaDefinition represents an object or caveat definition in a schema. +type SchemaDefinition interface { + proto.Message + + GetName() string +} + +// CompiledSchema is the result of compiling a schema when there are no errors. +type CompiledSchema struct { + // ObjectDefinitions holds the object definitions in the schema. + ObjectDefinitions []*core.NamespaceDefinition + + // CaveatDefinitions holds the caveat definitions in the schema. + CaveatDefinitions []*core.CaveatDefinition + + // OrderedDefinitions holds the object and caveat definitions in the schema, in the + // order in which they were found. + OrderedDefinitions []SchemaDefinition + + rootNode *dslNode + mapper input.PositionMapper +} + +// SourcePositionToRunePosition converts a source position to a rune position. +func (cs CompiledSchema) SourcePositionToRunePosition(source input.Source, position input.Position) (int, error) { + return cs.mapper.LineAndColToRunePosition(position.LineNumber, position.ColumnPosition, source) +} + +type config struct { + skipValidation bool + objectTypePrefix *string + allowedFlags []string + caveatTypeSet *caveattypes.TypeSet +} + +func SkipValidation() Option { return func(cfg *config) { cfg.skipValidation = true } } + +func ObjectTypePrefix(prefix string) ObjectPrefixOption { + return func(cfg *config) { cfg.objectTypePrefix = &prefix } +} + +func RequirePrefixedObjectType() ObjectPrefixOption { + return func(cfg *config) { cfg.objectTypePrefix = nil } +} + +func AllowUnprefixedObjectType() ObjectPrefixOption { + return func(cfg *config) { cfg.objectTypePrefix = new(string) } +} + +func CaveatTypeSet(cts *caveattypes.TypeSet) Option { + return func(cfg *config) { cfg.caveatTypeSet = cts } +} + +const expirationFlag = "expiration" + +func DisallowExpirationFlag() Option { + return func(cfg *config) { + cfg.allowedFlags = slices.Filter([]string{}, cfg.allowedFlags, func(s string) bool { + return s != expirationFlag + }) + } +} + +type Option func(*config) + +type ObjectPrefixOption func(*config) + +// Compile compilers the input schema into a set of namespace definition protos. +func Compile(schema InputSchema, prefix ObjectPrefixOption, opts ...Option) (*CompiledSchema, error) { + cfg := &config{ + allowedFlags: make([]string, 0, 1), + } + + // Enable `expiration` flag by default. + cfg.allowedFlags = append(cfg.allowedFlags, expirationFlag) + + prefix(cfg) // required option + + for _, fn := range opts { + fn(cfg) + } + + mapper := newPositionMapper(schema) + root := parser.Parse(createAstNode, schema.Source, schema.SchemaString).(*dslNode) + errs := root.FindAll(dslshape.NodeTypeError) + if len(errs) > 0 { + err := errorNodeToError(errs[0], mapper) + return nil, err + } + + cts := caveattypes.TypeSetOrDefault(cfg.caveatTypeSet) + compiled, err := translate(&translationContext{ + objectTypePrefix: cfg.objectTypePrefix, + mapper: mapper, + schemaString: schema.SchemaString, + skipValidate: cfg.skipValidation, + allowedFlags: cfg.allowedFlags, + caveatTypeSet: cts, + }, root) + if err != nil { + var withNodeError withNodeError + if errors.As(err, &withNodeError) { + err = toContextError(withNodeError.error.Error(), withNodeError.errorSourceCode, withNodeError.node, mapper) + } + + return nil, err + } + + return compiled, nil +} + +func errorNodeToError(node *dslNode, mapper input.PositionMapper) error { + if node.GetType() != dslshape.NodeTypeError { + return fmt.Errorf("given none error node") + } + + errMessage, err := node.GetString(dslshape.NodePredicateErrorMessage) + if err != nil { + return fmt.Errorf("could not get error message for error node: %w", err) + } + + errorSourceCode := "" + if node.Has(dslshape.NodePredicateErrorSource) { + es, err := node.GetString(dslshape.NodePredicateErrorSource) + if err != nil { + return fmt.Errorf("could not get error source for error node: %w", err) + } + + errorSourceCode = es + } + + return toContextError(errMessage, errorSourceCode, node, mapper) +} + +func toContextError(errMessage string, errorSourceCode string, node *dslNode, mapper input.PositionMapper) error { + sourceRange, err := node.Range(mapper) + if err != nil { + return fmt.Errorf("could not get range for error node: %w", err) + } + + formattedRange, err := formatRange(sourceRange) + if err != nil { + return err + } + + source, err := node.GetString(dslshape.NodePredicateSource) + if err != nil { + return fmt.Errorf("missing source for node: %w", err) + } + + return WithContextError{ + BaseCompilerError: BaseCompilerError{ + error: fmt.Errorf("parse error in %s: %s", formattedRange, errMessage), + BaseMessage: errMessage, + }, + SourceRange: sourceRange, + Source: input.Source(source), + ErrorSourceCode: errorSourceCode, + } +} + +func formatRange(rnge input.SourceRange) (string, error) { + startLine, startCol, err := rnge.Start().LineAndColumn() + if err != nil { + return "", err + } + + return fmt.Sprintf("`%s`, line %v, column %v", rnge.Source(), startLine+1, startCol+1), nil +} diff --git a/vendor/github.com/authzed/spicedb/pkg/schemadsl/compiler/development.go b/vendor/github.com/authzed/spicedb/pkg/schemadsl/compiler/development.go new file mode 100644 index 0000000..7c8e7c7 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/schemadsl/compiler/development.go @@ -0,0 +1,142 @@ +package compiler + +import ( + "github.com/authzed/spicedb/pkg/schemadsl/dslshape" + "github.com/authzed/spicedb/pkg/schemadsl/input" +) + +// DSLNode is a node in the DSL AST. +type DSLNode interface { + GetType() dslshape.NodeType + GetString(predicateName string) (string, error) + GetInt(predicateName string) (int, error) + Lookup(predicateName string) (DSLNode, error) +} + +// NodeChain is a chain of nodes in the DSL AST. +type NodeChain struct { + nodes []DSLNode + runePosition int +} + +// Head returns the head node of the chain. +func (nc *NodeChain) Head() DSLNode { + return nc.nodes[0] +} + +// HasHeadType returns true if the head node of the chain is of the given type. +func (nc *NodeChain) HasHeadType(nodeType dslshape.NodeType) bool { + return nc.nodes[0].GetType() == nodeType +} + +// ForRunePosition returns the rune position of the chain. +func (nc *NodeChain) ForRunePosition() int { + return nc.runePosition +} + +// FindNodeOfType returns the first node of the given type in the chain, if any. +func (nc *NodeChain) FindNodeOfType(nodeType dslshape.NodeType) DSLNode { + for _, node := range nc.nodes { + if node.GetType() == nodeType { + return node + } + } + + return nil +} + +func (nc *NodeChain) String() string { + var out string + for _, node := range nc.nodes { + out += node.GetType().String() + " " + } + return out +} + +// PositionToAstNodeChain returns the AST node, and its parents (if any), found at the given position in the source, if any. +func PositionToAstNodeChain(schema *CompiledSchema, source input.Source, position input.Position) (*NodeChain, error) { + rootSource, err := schema.rootNode.GetString(dslshape.NodePredicateSource) + if err != nil { + return nil, err + } + + if rootSource != string(source) { + return nil, nil + } + + // Map the position to a file rune. + runePosition, err := schema.mapper.LineAndColToRunePosition(position.LineNumber, position.ColumnPosition, source) + if err != nil { + return nil, err + } + + // Find the node at the rune position. + found, err := runePositionToAstNodeChain(schema.rootNode, runePosition) + if err != nil { + return nil, err + } + + if found == nil { + return nil, nil + } + + return &NodeChain{nodes: found, runePosition: runePosition}, nil +} + +func runePositionToAstNodeChain(node *dslNode, runePosition int) ([]DSLNode, error) { + if !node.Has(dslshape.NodePredicateStartRune) { + return nil, nil + } + + startRune, err := node.GetInt(dslshape.NodePredicateStartRune) + if err != nil { + return nil, err + } + + endRune, err := node.GetInt(dslshape.NodePredicateEndRune) + if err != nil { + return nil, err + } + + if runePosition < startRune || runePosition > endRune { + return nil, nil + } + + for _, child := range node.AllSubNodes() { + childChain, err := runePositionToAstNodeChain(child, runePosition) + if err != nil { + return nil, err + } + + if childChain != nil { + return append(childChain, wrapper{node}), nil + } + } + + return []DSLNode{wrapper{node}}, nil +} + +type wrapper struct { + node *dslNode +} + +func (w wrapper) GetType() dslshape.NodeType { + return w.node.GetType() +} + +func (w wrapper) GetString(predicateName string) (string, error) { + return w.node.GetString(predicateName) +} + +func (w wrapper) GetInt(predicateName string) (int, error) { + return w.node.GetInt(predicateName) +} + +func (w wrapper) Lookup(predicateName string) (DSLNode, error) { + found, err := w.node.Lookup(predicateName) + if err != nil { + return nil, err + } + + return wrapper{found}, nil +} diff --git a/vendor/github.com/authzed/spicedb/pkg/schemadsl/compiler/doc.go b/vendor/github.com/authzed/spicedb/pkg/schemadsl/compiler/doc.go new file mode 100644 index 0000000..fdc1735 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/schemadsl/compiler/doc.go @@ -0,0 +1,2 @@ +// Package compiler knows how to build the Go representation of a SpiceDB schema text. +package compiler diff --git a/vendor/github.com/authzed/spicedb/pkg/schemadsl/compiler/errors.go b/vendor/github.com/authzed/spicedb/pkg/schemadsl/compiler/errors.go new file mode 100644 index 0000000..2c33ba8 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/schemadsl/compiler/errors.go @@ -0,0 +1,53 @@ +package compiler + +import ( + "strconv" + + "github.com/authzed/spicedb/pkg/schemadsl/input" +) + +// BaseCompilerError defines an error with contains the base message of the issue +// that occurred. +type BaseCompilerError struct { + error + BaseMessage string +} + +type withNodeError struct { + error + node *dslNode + errorSourceCode string +} + +// WithContextError defines an error which contains contextual information. +type WithContextError struct { + BaseCompilerError + SourceRange input.SourceRange + Source input.Source + ErrorSourceCode string +} + +func (ewc WithContextError) Unwrap() error { + return ewc.BaseCompilerError +} + +// DetailsMetadata returns the metadata for details for this error. +func (ewc WithContextError) DetailsMetadata() map[string]string { + startLine, startCol, err := ewc.SourceRange.Start().LineAndColumn() + if err != nil { + return map[string]string{} + } + + endLine, endCol, err := ewc.SourceRange.End().LineAndColumn() + if err != nil { + return map[string]string{} + } + + return map[string]string{ + "start_line_number": strconv.Itoa(startLine), + "start_column_position": strconv.Itoa(startCol), + "end_line_number": strconv.Itoa(endLine), + "end_column_position": strconv.Itoa(endCol), + "source_code": ewc.ErrorSourceCode, + } +} diff --git a/vendor/github.com/authzed/spicedb/pkg/schemadsl/compiler/node.go b/vendor/github.com/authzed/spicedb/pkg/schemadsl/compiler/node.go new file mode 100644 index 0000000..b7e2a70 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/schemadsl/compiler/node.go @@ -0,0 +1,180 @@ +package compiler + +import ( + "container/list" + "fmt" + + "github.com/authzed/spicedb/pkg/schemadsl/dslshape" + "github.com/authzed/spicedb/pkg/schemadsl/input" + "github.com/authzed/spicedb/pkg/schemadsl/parser" +) + +type dslNode struct { + nodeType dslshape.NodeType + properties map[string]interface{} + children map[string]*list.List +} + +func createAstNode(_ input.Source, kind dslshape.NodeType) parser.AstNode { + return &dslNode{ + nodeType: kind, + properties: make(map[string]interface{}), + children: make(map[string]*list.List), + } +} + +func (tn *dslNode) GetType() dslshape.NodeType { + return tn.nodeType +} + +func (tn *dslNode) Connect(predicate string, other parser.AstNode) { + if tn.children[predicate] == nil { + tn.children[predicate] = list.New() + } + + tn.children[predicate].PushBack(other) +} + +func (tn *dslNode) MustDecorate(property string, value string) parser.AstNode { + if _, ok := tn.properties[property]; ok { + panic(fmt.Sprintf("Existing key for property %s\n\tNode: %v", property, tn.properties)) + } + + tn.properties[property] = value + return tn +} + +func (tn *dslNode) MustDecorateWithInt(property string, value int) parser.AstNode { + if _, ok := tn.properties[property]; ok { + panic(fmt.Sprintf("Existing key for property %s\n\tNode: %v", property, tn.properties)) + } + + tn.properties[property] = value + return tn +} + +func (tn *dslNode) Range(mapper input.PositionMapper) (input.SourceRange, error) { + sourceStr, err := tn.GetString(dslshape.NodePredicateSource) + if err != nil { + return nil, err + } + + source := input.Source(sourceStr) + + startRune, err := tn.GetInt(dslshape.NodePredicateStartRune) + if err != nil { + return nil, err + } + + endRune, err := tn.GetInt(dslshape.NodePredicateEndRune) + if err != nil { + return nil, err + } + + return source.RangeForRunePositions(startRune, endRune, mapper), nil +} + +func (tn *dslNode) Has(predicateName string) bool { + _, ok := tn.properties[predicateName] + return ok +} + +func (tn *dslNode) GetInt(predicateName string) (int, error) { + predicate, ok := tn.properties[predicateName] + if !ok { + return 0, fmt.Errorf("unknown predicate %s", predicateName) + } + + value, ok := predicate.(int) + if !ok { + return 0, fmt.Errorf("predicate %s is not an int", predicateName) + } + + return value, nil +} + +func (tn *dslNode) GetString(predicateName string) (string, error) { + predicate, ok := tn.properties[predicateName] + if !ok { + return "", fmt.Errorf("unknown predicate %s", predicateName) + } + + value, ok := predicate.(string) + if !ok { + return "", fmt.Errorf("predicate %s is not a string", predicateName) + } + + return value, nil +} + +func (tn *dslNode) AllSubNodes() []*dslNode { + nodes := []*dslNode{} + for _, childList := range tn.children { + for e := childList.Front(); e != nil; e = e.Next() { + nodes = append(nodes, e.Value.(*dslNode)) + } + } + return nodes +} + +func (tn *dslNode) GetChildren() []*dslNode { + return tn.List(dslshape.NodePredicateChild) +} + +func (tn *dslNode) FindAll(nodeType dslshape.NodeType) []*dslNode { + found := []*dslNode{} + if tn.nodeType == dslshape.NodeTypeError { + found = append(found, tn) + } + + for _, childList := range tn.children { + for e := childList.Front(); e != nil; e = e.Next() { + childFound := e.Value.(*dslNode).FindAll(nodeType) + found = append(found, childFound...) + } + } + return found +} + +func (tn *dslNode) List(predicateName string) []*dslNode { + children := []*dslNode{} + childList, ok := tn.children[predicateName] + if !ok { + return children + } + + for e := childList.Front(); e != nil; e = e.Next() { + children = append(children, e.Value.(*dslNode)) + } + + return children +} + +func (tn *dslNode) Lookup(predicateName string) (*dslNode, error) { + childList, ok := tn.children[predicateName] + if !ok { + return nil, fmt.Errorf("unknown predicate %s", predicateName) + } + + for e := childList.Front(); e != nil; e = e.Next() { + return e.Value.(*dslNode), nil + } + + return nil, fmt.Errorf("nothing in predicate %s", predicateName) +} + +func (tn *dslNode) Errorf(message string, args ...interface{}) error { + return withNodeError{ + error: fmt.Errorf(message, args...), + errorSourceCode: "", + node: tn, + } +} + +func (tn *dslNode) WithSourceErrorf(sourceCode string, message string, args ...interface{}) error { + return withNodeError{ + error: fmt.Errorf(message, args...), + errorSourceCode: sourceCode, + node: tn, + } +} diff --git a/vendor/github.com/authzed/spicedb/pkg/schemadsl/compiler/positionmapper.go b/vendor/github.com/authzed/spicedb/pkg/schemadsl/compiler/positionmapper.go new file mode 100644 index 0000000..aa33c43 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/schemadsl/compiler/positionmapper.go @@ -0,0 +1,32 @@ +package compiler + +import ( + "strings" + + "github.com/authzed/spicedb/pkg/schemadsl/input" +) + +type positionMapper struct { + schema InputSchema + mapper input.SourcePositionMapper +} + +func newPositionMapper(schema InputSchema) input.PositionMapper { + return &positionMapper{ + schema: schema, + mapper: input.CreateSourcePositionMapper([]byte(schema.SchemaString)), + } +} + +func (pm *positionMapper) RunePositionToLineAndCol(runePosition int, _ input.Source) (int, int, error) { + return pm.mapper.RunePositionToLineAndCol(runePosition) +} + +func (pm *positionMapper) LineAndColToRunePosition(lineNumber int, colPosition int, _ input.Source) (int, error) { + return pm.mapper.LineAndColToRunePosition(lineNumber, colPosition) +} + +func (pm *positionMapper) TextForLine(lineNumber int, _ input.Source) (string, error) { + lines := strings.Split(pm.schema.SchemaString, "\n") + return lines[lineNumber], nil +} diff --git a/vendor/github.com/authzed/spicedb/pkg/schemadsl/compiler/translator.go b/vendor/github.com/authzed/spicedb/pkg/schemadsl/compiler/translator.go new file mode 100644 index 0000000..77877b0 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/schemadsl/compiler/translator.go @@ -0,0 +1,714 @@ +package compiler + +import ( + "bufio" + "fmt" + "slices" + "strings" + + "github.com/ccoveille/go-safecast" + "github.com/jzelinskie/stringz" + + "github.com/authzed/spicedb/pkg/caveats" + caveattypes "github.com/authzed/spicedb/pkg/caveats/types" + "github.com/authzed/spicedb/pkg/genutil/mapz" + "github.com/authzed/spicedb/pkg/namespace" + core "github.com/authzed/spicedb/pkg/proto/core/v1" + "github.com/authzed/spicedb/pkg/schemadsl/dslshape" + "github.com/authzed/spicedb/pkg/schemadsl/input" +) + +type translationContext struct { + objectTypePrefix *string + mapper input.PositionMapper + schemaString string + skipValidate bool + allowedFlags []string + enabledFlags []string + caveatTypeSet *caveattypes.TypeSet +} + +func (tctx *translationContext) prefixedPath(definitionName string) (string, error) { + var prefix, name string + if err := stringz.SplitInto(definitionName, "/", &prefix, &name); err != nil { + if tctx.objectTypePrefix == nil { + return "", fmt.Errorf("found reference `%s` without prefix", definitionName) + } + prefix = *tctx.objectTypePrefix + name = definitionName + } + + if prefix == "" { + return name, nil + } + + return stringz.Join("/", prefix, name), nil +} + +const Ellipsis = "..." + +func translate(tctx *translationContext, root *dslNode) (*CompiledSchema, error) { + orderedDefinitions := make([]SchemaDefinition, 0, len(root.GetChildren())) + var objectDefinitions []*core.NamespaceDefinition + var caveatDefinitions []*core.CaveatDefinition + + names := mapz.NewSet[string]() + + for _, definitionNode := range root.GetChildren() { + var definition SchemaDefinition + + switch definitionNode.GetType() { + case dslshape.NodeTypeUseFlag: + err := translateUseFlag(tctx, definitionNode) + if err != nil { + return nil, err + } + continue + + case dslshape.NodeTypeCaveatDefinition: + def, err := translateCaveatDefinition(tctx, definitionNode) + if err != nil { + return nil, err + } + + definition = def + caveatDefinitions = append(caveatDefinitions, def) + + case dslshape.NodeTypeDefinition: + def, err := translateObjectDefinition(tctx, definitionNode) + if err != nil { + return nil, err + } + + definition = def + objectDefinitions = append(objectDefinitions, def) + } + + if !names.Add(definition.GetName()) { + return nil, definitionNode.WithSourceErrorf(definition.GetName(), "found name reused between multiple definitions and/or caveats: %s", definition.GetName()) + } + + orderedDefinitions = append(orderedDefinitions, definition) + } + + return &CompiledSchema{ + CaveatDefinitions: caveatDefinitions, + ObjectDefinitions: objectDefinitions, + OrderedDefinitions: orderedDefinitions, + rootNode: root, + mapper: tctx.mapper, + }, nil +} + +func translateCaveatDefinition(tctx *translationContext, defNode *dslNode) (*core.CaveatDefinition, error) { + definitionName, err := defNode.GetString(dslshape.NodeCaveatDefinitionPredicateName) + if err != nil { + return nil, defNode.WithSourceErrorf(definitionName, "invalid definition name: %w", err) + } + + // parameters + paramNodes := defNode.List(dslshape.NodeCaveatDefinitionPredicateParameters) + if len(paramNodes) == 0 { + return nil, defNode.WithSourceErrorf(definitionName, "caveat `%s` must have at least one parameter defined", definitionName) + } + + env := caveats.NewEnvironment() + parameters := make(map[string]caveattypes.VariableType, len(paramNodes)) + for _, paramNode := range paramNodes { + paramName, err := paramNode.GetString(dslshape.NodeCaveatParameterPredicateName) + if err != nil { + return nil, paramNode.WithSourceErrorf(paramName, "invalid parameter name: %w", err) + } + + if _, ok := parameters[paramName]; ok { + return nil, paramNode.WithSourceErrorf(paramName, "duplicate parameter `%s` defined on caveat `%s`", paramName, definitionName) + } + + typeRefNode, err := paramNode.Lookup(dslshape.NodeCaveatParameterPredicateType) + if err != nil { + return nil, paramNode.WithSourceErrorf(paramName, "invalid type for parameter: %w", err) + } + + translatedType, err := translateCaveatTypeReference(tctx, typeRefNode) + if err != nil { + return nil, paramNode.WithSourceErrorf(paramName, "invalid type for caveat parameter `%s` on caveat `%s`: %w", paramName, definitionName, err) + } + + parameters[paramName] = *translatedType + err = env.AddVariable(paramName, *translatedType) + if err != nil { + return nil, paramNode.WithSourceErrorf(paramName, "invalid type for caveat parameter `%s` on caveat `%s`: %w", paramName, definitionName, err) + } + } + + caveatPath, err := tctx.prefixedPath(definitionName) + if err != nil { + return nil, defNode.Errorf("%w", err) + } + + // caveat expression. + expressionStringNode, err := defNode.Lookup(dslshape.NodeCaveatDefinitionPredicateExpession) + if err != nil { + return nil, defNode.WithSourceErrorf(definitionName, "invalid expression: %w", err) + } + + expressionString, err := expressionStringNode.GetString(dslshape.NodeCaveatExpressionPredicateExpression) + if err != nil { + return nil, defNode.WithSourceErrorf(expressionString, "invalid expression: %w", err) + } + + rnge, err := expressionStringNode.Range(tctx.mapper) + if err != nil { + return nil, defNode.WithSourceErrorf(expressionString, "invalid expression: %w", err) + } + + source, err := caveats.NewSource(expressionString, caveatPath) + if err != nil { + return nil, defNode.WithSourceErrorf(expressionString, "invalid expression: %w", err) + } + + compiled, err := caveats.CompileCaveatWithSource(env, caveatPath, source, rnge.Start()) + if err != nil { + return nil, expressionStringNode.WithSourceErrorf(expressionString, "invalid expression for caveat `%s`: %w", definitionName, err) + } + + def, err := namespace.CompiledCaveatDefinition(env, caveatPath, compiled) + if err != nil { + return nil, err + } + + def.Metadata = addComments(def.Metadata, defNode) + def.SourcePosition = getSourcePosition(defNode, tctx.mapper) + return def, nil +} + +func translateCaveatTypeReference(tctx *translationContext, typeRefNode *dslNode) (*caveattypes.VariableType, error) { + typeName, err := typeRefNode.GetString(dslshape.NodeCaveatTypeReferencePredicateType) + if err != nil { + return nil, typeRefNode.WithSourceErrorf(typeName, "invalid type name: %w", err) + } + + childTypeNodes := typeRefNode.List(dslshape.NodeCaveatTypeReferencePredicateChildTypes) + childTypes := make([]caveattypes.VariableType, 0, len(childTypeNodes)) + for _, childTypeNode := range childTypeNodes { + translated, err := translateCaveatTypeReference(tctx, childTypeNode) + if err != nil { + return nil, err + } + childTypes = append(childTypes, *translated) + } + + constructedType, err := tctx.caveatTypeSet.BuildType(typeName, childTypes) + if err != nil { + return nil, typeRefNode.WithSourceErrorf(typeName, "%w", err) + } + + return constructedType, nil +} + +func translateObjectDefinition(tctx *translationContext, defNode *dslNode) (*core.NamespaceDefinition, error) { + definitionName, err := defNode.GetString(dslshape.NodeDefinitionPredicateName) + if err != nil { + return nil, defNode.WithSourceErrorf(definitionName, "invalid definition name: %w", err) + } + + relationsAndPermissions := []*core.Relation{} + for _, relationOrPermissionNode := range defNode.GetChildren() { + if relationOrPermissionNode.GetType() == dslshape.NodeTypeComment { + continue + } + + relationOrPermission, err := translateRelationOrPermission(tctx, relationOrPermissionNode) + if err != nil { + return nil, err + } + + relationsAndPermissions = append(relationsAndPermissions, relationOrPermission) + } + + nspath, err := tctx.prefixedPath(definitionName) + if err != nil { + return nil, defNode.Errorf("%w", err) + } + + if len(relationsAndPermissions) == 0 { + ns := namespace.Namespace(nspath) + ns.Metadata = addComments(ns.Metadata, defNode) + ns.SourcePosition = getSourcePosition(defNode, tctx.mapper) + + if !tctx.skipValidate { + if err = ns.Validate(); err != nil { + return nil, defNode.Errorf("error in object definition %s: %w", nspath, err) + } + } + + return ns, nil + } + + ns := namespace.Namespace(nspath, relationsAndPermissions...) + ns.Metadata = addComments(ns.Metadata, defNode) + ns.SourcePosition = getSourcePosition(defNode, tctx.mapper) + + if !tctx.skipValidate { + if err := ns.Validate(); err != nil { + return nil, defNode.Errorf("error in object definition %s: %w", nspath, err) + } + } + + return ns, nil +} + +func getSourcePosition(dslNode *dslNode, mapper input.PositionMapper) *core.SourcePosition { + if !dslNode.Has(dslshape.NodePredicateStartRune) { + return nil + } + + sourceRange, err := dslNode.Range(mapper) + if err != nil { + return nil + } + + line, col, err := sourceRange.Start().LineAndColumn() + if err != nil { + return nil + } + + // We're okay with these being zero if the cast fails. + uintLine, _ := safecast.ToUint64(line) + uintCol, _ := safecast.ToUint64(col) + + return &core.SourcePosition{ + ZeroIndexedLineNumber: uintLine, + ZeroIndexedColumnPosition: uintCol, + } +} + +func addComments(mdmsg *core.Metadata, dslNode *dslNode) *core.Metadata { + for _, child := range dslNode.GetChildren() { + if child.GetType() == dslshape.NodeTypeComment { + value, err := child.GetString(dslshape.NodeCommentPredicateValue) + if err == nil { + mdmsg, _ = namespace.AddComment(mdmsg, normalizeComment(value)) + } + } + } + return mdmsg +} + +func normalizeComment(value string) string { + var lines []string + scanner := bufio.NewScanner(strings.NewReader(value)) + for scanner.Scan() { + trimmed := strings.TrimSpace(scanner.Text()) + lines = append(lines, trimmed) + } + return strings.Join(lines, "\n") +} + +func translateRelationOrPermission(tctx *translationContext, relOrPermNode *dslNode) (*core.Relation, error) { + switch relOrPermNode.GetType() { + case dslshape.NodeTypeRelation: + rel, err := translateRelation(tctx, relOrPermNode) + if err != nil { + return nil, err + } + rel.Metadata = addComments(rel.Metadata, relOrPermNode) + rel.SourcePosition = getSourcePosition(relOrPermNode, tctx.mapper) + return rel, err + + case dslshape.NodeTypePermission: + rel, err := translatePermission(tctx, relOrPermNode) + if err != nil { + return nil, err + } + rel.Metadata = addComments(rel.Metadata, relOrPermNode) + rel.SourcePosition = getSourcePosition(relOrPermNode, tctx.mapper) + return rel, err + + default: + return nil, relOrPermNode.Errorf("unknown definition top-level node type %s", relOrPermNode.GetType()) + } +} + +func translateRelation(tctx *translationContext, relationNode *dslNode) (*core.Relation, error) { + relationName, err := relationNode.GetString(dslshape.NodePredicateName) + if err != nil { + return nil, relationNode.Errorf("invalid relation name: %w", err) + } + + allowedDirectTypes := []*core.AllowedRelation{} + for _, typeRef := range relationNode.List(dslshape.NodeRelationPredicateAllowedTypes) { + allowedRelations, err := translateAllowedRelations(tctx, typeRef) + if err != nil { + return nil, err + } + + allowedDirectTypes = append(allowedDirectTypes, allowedRelations...) + } + + relation, err := namespace.Relation(relationName, nil, allowedDirectTypes...) + if err != nil { + return nil, err + } + + if !tctx.skipValidate { + if err := relation.Validate(); err != nil { + return nil, relationNode.Errorf("error in relation %s: %w", relationName, err) + } + } + + return relation, nil +} + +func translatePermission(tctx *translationContext, permissionNode *dslNode) (*core.Relation, error) { + permissionName, err := permissionNode.GetString(dslshape.NodePredicateName) + if err != nil { + return nil, permissionNode.Errorf("invalid permission name: %w", err) + } + + expressionNode, err := permissionNode.Lookup(dslshape.NodePermissionPredicateComputeExpression) + if err != nil { + return nil, permissionNode.Errorf("invalid permission expression: %w", err) + } + + rewrite, err := translateExpression(tctx, expressionNode) + if err != nil { + return nil, err + } + + permission, err := namespace.Relation(permissionName, rewrite) + if err != nil { + return nil, err + } + + if !tctx.skipValidate { + if err := permission.Validate(); err != nil { + return nil, permissionNode.Errorf("error in permission %s: %w", permissionName, err) + } + } + + return permission, nil +} + +func translateBinary(tctx *translationContext, expressionNode *dslNode) (*core.SetOperation_Child, *core.SetOperation_Child, error) { + leftChild, err := expressionNode.Lookup(dslshape.NodeExpressionPredicateLeftExpr) + if err != nil { + return nil, nil, err + } + + rightChild, err := expressionNode.Lookup(dslshape.NodeExpressionPredicateRightExpr) + if err != nil { + return nil, nil, err + } + + leftOperation, err := translateExpressionOperation(tctx, leftChild) + if err != nil { + return nil, nil, err + } + + rightOperation, err := translateExpressionOperation(tctx, rightChild) + if err != nil { + return nil, nil, err + } + + return leftOperation, rightOperation, nil +} + +func translateExpression(tctx *translationContext, expressionNode *dslNode) (*core.UsersetRewrite, error) { + translated, err := translateExpressionDirect(tctx, expressionNode) + if err != nil { + return translated, err + } + + translated.SourcePosition = getSourcePosition(expressionNode, tctx.mapper) + return translated, nil +} + +func collapseOps(op *core.SetOperation_Child, handler func(rewrite *core.UsersetRewrite) *core.SetOperation) []*core.SetOperation_Child { + if op.GetUsersetRewrite() == nil { + return []*core.SetOperation_Child{op} + } + + usersetRewrite := op.GetUsersetRewrite() + operation := handler(usersetRewrite) + if operation == nil { + return []*core.SetOperation_Child{op} + } + + collapsed := make([]*core.SetOperation_Child, 0, len(operation.Child)) + for _, child := range operation.Child { + collapsed = append(collapsed, collapseOps(child, handler)...) + } + return collapsed +} + +func translateExpressionDirect(tctx *translationContext, expressionNode *dslNode) (*core.UsersetRewrite, error) { + // For union and intersection, we collapse a tree of binary operations into a flat list containing child + // operations of the *same* type. + translate := func( + builder func(firstChild *core.SetOperation_Child, rest ...*core.SetOperation_Child) *core.UsersetRewrite, + lookup func(rewrite *core.UsersetRewrite) *core.SetOperation, + ) (*core.UsersetRewrite, error) { + leftOperation, rightOperation, err := translateBinary(tctx, expressionNode) + if err != nil { + return nil, err + } + leftOps := collapseOps(leftOperation, lookup) + rightOps := collapseOps(rightOperation, lookup) + ops := append(leftOps, rightOps...) + return builder(ops[0], ops[1:]...), nil + } + + switch expressionNode.GetType() { + case dslshape.NodeTypeUnionExpression: + return translate(namespace.Union, func(rewrite *core.UsersetRewrite) *core.SetOperation { + return rewrite.GetUnion() + }) + + case dslshape.NodeTypeIntersectExpression: + return translate(namespace.Intersection, func(rewrite *core.UsersetRewrite) *core.SetOperation { + return rewrite.GetIntersection() + }) + + case dslshape.NodeTypeExclusionExpression: + // Order matters for exclusions, so do not perform the optimization. + leftOperation, rightOperation, err := translateBinary(tctx, expressionNode) + if err != nil { + return nil, err + } + return namespace.Exclusion(leftOperation, rightOperation), nil + + default: + op, err := translateExpressionOperation(tctx, expressionNode) + if err != nil { + return nil, err + } + + return namespace.Union(op), nil + } +} + +func translateExpressionOperation(tctx *translationContext, expressionOpNode *dslNode) (*core.SetOperation_Child, error) { + translated, err := translateExpressionOperationDirect(tctx, expressionOpNode) + if err != nil { + return translated, err + } + + translated.SourcePosition = getSourcePosition(expressionOpNode, tctx.mapper) + return translated, nil +} + +func translateExpressionOperationDirect(tctx *translationContext, expressionOpNode *dslNode) (*core.SetOperation_Child, error) { + switch expressionOpNode.GetType() { + case dslshape.NodeTypeIdentifier: + referencedRelationName, err := expressionOpNode.GetString(dslshape.NodeIdentiferPredicateValue) + if err != nil { + return nil, err + } + + return namespace.ComputedUserset(referencedRelationName), nil + + case dslshape.NodeTypeNilExpression: + return namespace.Nil(), nil + + case dslshape.NodeTypeArrowExpression: + leftChild, err := expressionOpNode.Lookup(dslshape.NodeExpressionPredicateLeftExpr) + if err != nil { + return nil, err + } + + rightChild, err := expressionOpNode.Lookup(dslshape.NodeExpressionPredicateRightExpr) + if err != nil { + return nil, err + } + + if leftChild.GetType() != dslshape.NodeTypeIdentifier { + return nil, leftChild.Errorf("Nested arrows not yet supported") + } + + tuplesetRelation, err := leftChild.GetString(dslshape.NodeIdentiferPredicateValue) + if err != nil { + return nil, err + } + + usersetRelation, err := rightChild.GetString(dslshape.NodeIdentiferPredicateValue) + if err != nil { + return nil, err + } + + if expressionOpNode.Has(dslshape.NodeArrowExpressionFunctionName) { + functionName, err := expressionOpNode.GetString(dslshape.NodeArrowExpressionFunctionName) + if err != nil { + return nil, err + } + + return namespace.MustFunctionedTupleToUserset(tuplesetRelation, functionName, usersetRelation), nil + } + + return namespace.TupleToUserset(tuplesetRelation, usersetRelation), nil + + case dslshape.NodeTypeUnionExpression: + fallthrough + + case dslshape.NodeTypeIntersectExpression: + fallthrough + + case dslshape.NodeTypeExclusionExpression: + rewrite, err := translateExpression(tctx, expressionOpNode) + if err != nil { + return nil, err + } + return namespace.Rewrite(rewrite), nil + + default: + return nil, expressionOpNode.Errorf("unknown expression node type %s", expressionOpNode.GetType()) + } +} + +func translateAllowedRelations(tctx *translationContext, typeRefNode *dslNode) ([]*core.AllowedRelation, error) { + switch typeRefNode.GetType() { + case dslshape.NodeTypeTypeReference: + references := []*core.AllowedRelation{} + for _, subRefNode := range typeRefNode.List(dslshape.NodeTypeReferencePredicateType) { + subReferences, err := translateAllowedRelations(tctx, subRefNode) + if err != nil { + return []*core.AllowedRelation{}, err + } + + references = append(references, subReferences...) + } + return references, nil + + case dslshape.NodeTypeSpecificTypeReference: + ref, err := translateSpecificTypeReference(tctx, typeRefNode) + if err != nil { + return []*core.AllowedRelation{}, err + } + return []*core.AllowedRelation{ref}, nil + + default: + return nil, typeRefNode.Errorf("unknown type ref node type %s", typeRefNode.GetType()) + } +} + +func translateSpecificTypeReference(tctx *translationContext, typeRefNode *dslNode) (*core.AllowedRelation, error) { + typePath, err := typeRefNode.GetString(dslshape.NodeSpecificReferencePredicateType) + if err != nil { + return nil, typeRefNode.Errorf("invalid type name: %w", err) + } + + nspath, err := tctx.prefixedPath(typePath) + if err != nil { + return nil, typeRefNode.Errorf("%w", err) + } + + if typeRefNode.Has(dslshape.NodeSpecificReferencePredicateWildcard) { + ref := &core.AllowedRelation{ + Namespace: nspath, + RelationOrWildcard: &core.AllowedRelation_PublicWildcard_{ + PublicWildcard: &core.AllowedRelation_PublicWildcard{}, + }, + } + + err = addWithCaveats(tctx, typeRefNode, ref) + if err != nil { + return nil, typeRefNode.Errorf("invalid caveat: %w", err) + } + + if !tctx.skipValidate { + if err := ref.Validate(); err != nil { + return nil, typeRefNode.Errorf("invalid type relation: %w", err) + } + } + + ref.SourcePosition = getSourcePosition(typeRefNode, tctx.mapper) + return ref, nil + } + + relationName := Ellipsis + if typeRefNode.Has(dslshape.NodeSpecificReferencePredicateRelation) { + relationName, err = typeRefNode.GetString(dslshape.NodeSpecificReferencePredicateRelation) + if err != nil { + return nil, typeRefNode.Errorf("invalid type relation: %w", err) + } + } + + ref := &core.AllowedRelation{ + Namespace: nspath, + RelationOrWildcard: &core.AllowedRelation_Relation{ + Relation: relationName, + }, + } + + // Add the caveat(s), if any. + err = addWithCaveats(tctx, typeRefNode, ref) + if err != nil { + return nil, typeRefNode.Errorf("invalid caveat: %w", err) + } + + // Add the expiration trait, if any. + if traitNode, err := typeRefNode.Lookup(dslshape.NodeSpecificReferencePredicateTrait); err == nil { + traitName, err := traitNode.GetString(dslshape.NodeTraitPredicateTrait) + if err != nil { + return nil, typeRefNode.Errorf("invalid trait: %w", err) + } + + if traitName != "expiration" { + return nil, typeRefNode.Errorf("invalid trait: %s", traitName) + } + + if !slices.Contains(tctx.allowedFlags, "expiration") { + return nil, typeRefNode.Errorf("expiration trait is not allowed") + } + + ref.RequiredExpiration = &core.ExpirationTrait{} + } + + if !tctx.skipValidate { + if err := ref.Validate(); err != nil { + return nil, typeRefNode.Errorf("invalid type relation: %w", err) + } + } + + ref.SourcePosition = getSourcePosition(typeRefNode, tctx.mapper) + return ref, nil +} + +func addWithCaveats(tctx *translationContext, typeRefNode *dslNode, ref *core.AllowedRelation) error { + caveats := typeRefNode.List(dslshape.NodeSpecificReferencePredicateCaveat) + if len(caveats) == 0 { + return nil + } + + if len(caveats) != 1 { + return fmt.Errorf("only one caveat is currently allowed per type reference") + } + + name, err := caveats[0].GetString(dslshape.NodeCaveatPredicateCaveat) + if err != nil { + return err + } + + nspath, err := tctx.prefixedPath(name) + if err != nil { + return err + } + + ref.RequiredCaveat = &core.AllowedCaveat{ + CaveatName: nspath, + } + return nil +} + +// Translate use node and add flag to list of enabled flags +func translateUseFlag(tctx *translationContext, useFlagNode *dslNode) error { + flagName, err := useFlagNode.GetString(dslshape.NodeUseFlagPredicateName) + if err != nil { + return err + } + if slices.Contains(tctx.enabledFlags, flagName) { + return useFlagNode.Errorf("found duplicate use flag: %s", flagName) + } + tctx.enabledFlags = append(tctx.enabledFlags, flagName) + return nil +} diff --git a/vendor/github.com/authzed/spicedb/pkg/schemadsl/dslshape/doc.go b/vendor/github.com/authzed/spicedb/pkg/schemadsl/dslshape/doc.go new file mode 100644 index 0000000..457bd0b --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/schemadsl/dslshape/doc.go @@ -0,0 +1,2 @@ +// Package dslshape defines the types representing the structure of schema DSL. +package dslshape diff --git a/vendor/github.com/authzed/spicedb/pkg/schemadsl/dslshape/dslshape.go b/vendor/github.com/authzed/spicedb/pkg/schemadsl/dslshape/dslshape.go new file mode 100644 index 0000000..c3a599f --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/schemadsl/dslshape/dslshape.go @@ -0,0 +1,209 @@ +//go:generate go run golang.org/x/tools/cmd/stringer -type=NodeType -output zz_generated.nodetype_string.go + +package dslshape + +// NodeType identifies the type of AST node. +type NodeType int + +const ( + // Top-level + NodeTypeError NodeType = iota // error occurred; value is text of error + NodeTypeFile // The file root node + NodeTypeComment // A single or multiline comment + NodeTypeUseFlag // A use flag + + NodeTypeDefinition // A definition. + NodeTypeCaveatDefinition // A caveat definition. + + NodeTypeCaveatParameter // A caveat parameter. + NodeTypeCaveatExpression // A caveat expression. + + NodeTypeRelation // A relation + NodeTypePermission // A permission + + NodeTypeTypeReference // A type reference + NodeTypeSpecificTypeReference // A reference to a specific type. + NodeTypeCaveatReference // A caveat reference under a type. + NodeTypeTraitReference // A trait reference under a typr. + + NodeTypeUnionExpression + NodeTypeIntersectExpression + NodeTypeExclusionExpression + + NodeTypeArrowExpression // A TTU in arrow form. + + NodeTypeIdentifier // An identifier under an expression. + NodeTypeNilExpression // A nil keyword + + NodeTypeCaveatTypeReference // A type reference for a caveat parameter. +) + +const ( + // + // All nodes + // + // The source of this node. + NodePredicateSource = "input-source" + + // The rune position in the input string at which this node begins. + NodePredicateStartRune = "start-rune" + + // The rune position in the input string at which this node ends. + NodePredicateEndRune = "end-rune" + + // A direct child of this node. Implementations should handle the ordering + // automatically for this predicate. + NodePredicateChild = "child-node" + + // + // NodeTypeError + // + + // The message for the parsing error. + NodePredicateErrorMessage = "error-message" + + // The (optional) source to highlight for the parsing error. + NodePredicateErrorSource = "error-source" + + // + // NodeTypeComment + // + + // The value of the comment, including its delimeter(s) + NodeCommentPredicateValue = "comment-value" + + // + // NodeTypeUseFlag + // + + // The name of the use flag. + NodeUseFlagPredicateName = "use-flag-name" + + // + // NodeTypeDefinition + // + + // The name of the definition + NodeDefinitionPredicateName = "definition-name" + + // + // NodeTypeCaveatDefinition + // + + // The name of the definition + NodeCaveatDefinitionPredicateName = "caveat-definition-name" + + // The parameters for the definition. + NodeCaveatDefinitionPredicateParameters = "parameters" + + // The link to the expression for the definition. + NodeCaveatDefinitionPredicateExpession = "caveat-definition-expression" + + // + // NodeTypeCaveatExpression + // + + // The raw CEL expression, in string form. + NodeCaveatExpressionPredicateExpression = "caveat-expression-expressionstr" + + // + // NodeTypeCaveatParameter + // + + // The name of the parameter + NodeCaveatParameterPredicateName = "caveat-parameter-name" + + // The defined type of the caveat parameter. + NodeCaveatParameterPredicateType = "caveat-parameter-type" + + // + // NodeTypeCaveatTypeReference + // + + // The type for the caveat type reference. + NodeCaveatTypeReferencePredicateType = "type-name" + + // The child type(s) for the type reference. + NodeCaveatTypeReferencePredicateChildTypes = "child-types" + + // + // NodeTypeRelation + NodeTypePermission + // + + // The name of the relation/permission + NodePredicateName = "relation-name" + + // + // NodeTypeRelation + // + + // The allowed types for the relation. + NodeRelationPredicateAllowedTypes = "allowed-types" + + // + // NodeTypeTypeReference + // + + // A type under a type reference. + NodeTypeReferencePredicateType = "type-ref-type" + + // + // NodeTypeSpecificTypeReference + // + + // A type under a type reference. + NodeSpecificReferencePredicateType = "type-name" + + // A relation under a type reference. + NodeSpecificReferencePredicateRelation = "relation-name" + + // A wildcard under a type reference. + NodeSpecificReferencePredicateWildcard = "type-wildcard" + + // A caveat under a type reference. + NodeSpecificReferencePredicateCaveat = "caveat" + + // A trait under a type reference. + NodeSpecificReferencePredicateTrait = "trait" + + // + // NodeTypeCaveatReference + // + + // The caveat name under the caveat. + NodeCaveatPredicateCaveat = "caveat-name" + + // + // NodeTypeTraitReference + // + + // The trait name under the trait. + NodeTraitPredicateTrait = "trait-name" + + // + // NodeTypePermission + // + + // The expression to compute the permission. + NodePermissionPredicateComputeExpression = "compute-expression" + + // + // NodeTypeArrowExpression + // + + // The name of the function in the arrow expression. + NodeArrowExpressionFunctionName = "function-name" + + // + // NodeTypeIdentifer + // + + // The value of the identifier. + NodeIdentiferPredicateValue = "identifier-value" + + // + // NodeTypeUnionExpression + NodeTypeIntersectExpression + NodeTypeExclusionExpression + NodeTypeArrowExpression + // + NodeExpressionPredicateLeftExpr = "left-expr" + NodeExpressionPredicateRightExpr = "right-expr" +) diff --git a/vendor/github.com/authzed/spicedb/pkg/schemadsl/dslshape/zz_generated.nodetype_string.go b/vendor/github.com/authzed/spicedb/pkg/schemadsl/dslshape/zz_generated.nodetype_string.go new file mode 100644 index 0000000..4ef1e06 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/schemadsl/dslshape/zz_generated.nodetype_string.go @@ -0,0 +1,43 @@ +// Code generated by "stringer -type=NodeType -output zz_generated.nodetype_string.go"; DO NOT EDIT. + +package dslshape + +import "strconv" + +func _() { + // An "invalid array index" compiler error signifies that the constant values have changed. + // Re-run the stringer command to generate them again. + var x [1]struct{} + _ = x[NodeTypeError-0] + _ = x[NodeTypeFile-1] + _ = x[NodeTypeComment-2] + _ = x[NodeTypeUseFlag-3] + _ = x[NodeTypeDefinition-4] + _ = x[NodeTypeCaveatDefinition-5] + _ = x[NodeTypeCaveatParameter-6] + _ = x[NodeTypeCaveatExpression-7] + _ = x[NodeTypeRelation-8] + _ = x[NodeTypePermission-9] + _ = x[NodeTypeTypeReference-10] + _ = x[NodeTypeSpecificTypeReference-11] + _ = x[NodeTypeCaveatReference-12] + _ = x[NodeTypeTraitReference-13] + _ = x[NodeTypeUnionExpression-14] + _ = x[NodeTypeIntersectExpression-15] + _ = x[NodeTypeExclusionExpression-16] + _ = x[NodeTypeArrowExpression-17] + _ = x[NodeTypeIdentifier-18] + _ = x[NodeTypeNilExpression-19] + _ = x[NodeTypeCaveatTypeReference-20] +} + +const _NodeType_name = "NodeTypeErrorNodeTypeFileNodeTypeCommentNodeTypeUseFlagNodeTypeDefinitionNodeTypeCaveatDefinitionNodeTypeCaveatParameterNodeTypeCaveatExpressionNodeTypeRelationNodeTypePermissionNodeTypeTypeReferenceNodeTypeSpecificTypeReferenceNodeTypeCaveatReferenceNodeTypeTraitReferenceNodeTypeUnionExpressionNodeTypeIntersectExpressionNodeTypeExclusionExpressionNodeTypeArrowExpressionNodeTypeIdentifierNodeTypeNilExpressionNodeTypeCaveatTypeReference" + +var _NodeType_index = [...]uint16{0, 13, 25, 40, 55, 73, 97, 120, 144, 160, 178, 199, 228, 251, 273, 296, 323, 350, 373, 391, 412, 439} + +func (i NodeType) String() string { + if i < 0 || i >= NodeType(len(_NodeType_index)-1) { + return "NodeType(" + strconv.FormatInt(int64(i), 10) + ")" + } + return _NodeType_name[_NodeType_index[i]:_NodeType_index[i+1]] +} diff --git a/vendor/github.com/authzed/spicedb/pkg/schemadsl/generator/generator.go b/vendor/github.com/authzed/spicedb/pkg/schemadsl/generator/generator.go new file mode 100644 index 0000000..3c8fdd9 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/schemadsl/generator/generator.go @@ -0,0 +1,430 @@ +package generator + +import ( + "bufio" + "fmt" + "sort" + "strings" + + "golang.org/x/exp/maps" + + "github.com/authzed/spicedb/pkg/caveats" + caveattypes "github.com/authzed/spicedb/pkg/caveats/types" + "github.com/authzed/spicedb/pkg/genutil/mapz" + "github.com/authzed/spicedb/pkg/graph" + "github.com/authzed/spicedb/pkg/namespace" + core "github.com/authzed/spicedb/pkg/proto/core/v1" + "github.com/authzed/spicedb/pkg/schemadsl/compiler" + "github.com/authzed/spicedb/pkg/spiceerrors" +) + +// Ellipsis is the relation name for terminal subjects. +const Ellipsis = "..." + +// MaxSingleLineCommentLength sets the maximum length for a comment to made single line. +const MaxSingleLineCommentLength = 70 // 80 - the comment parts and some padding + +func GenerateSchema(definitions []compiler.SchemaDefinition) (string, bool, error) { + return GenerateSchemaWithCaveatTypeSet(definitions, caveattypes.Default.TypeSet) +} + +// GenerateSchemaWithCaveatTypeSet generates a DSL view of the given schema. +func GenerateSchemaWithCaveatTypeSet(definitions []compiler.SchemaDefinition, caveatTypeSet *caveattypes.TypeSet) (string, bool, error) { + generated := make([]string, 0, len(definitions)) + flags := mapz.NewSet[string]() + + result := true + for _, definition := range definitions { + switch def := definition.(type) { + case *core.CaveatDefinition: + generatedCaveat, ok, err := GenerateCaveatSource(def, caveatTypeSet) + if err != nil { + return "", false, err + } + + result = result && ok + generated = append(generated, generatedCaveat) + + case *core.NamespaceDefinition: + generatedSchema, defFlags, ok, err := generateDefinitionSource(def, caveatTypeSet) + if err != nil { + return "", false, err + } + + result = result && ok + generated = append(generated, generatedSchema) + flags.Extend(defFlags) + + default: + return "", false, spiceerrors.MustBugf("unknown type of definition %T in GenerateSchema", def) + } + } + + if !flags.IsEmpty() { + flagsSlice := flags.AsSlice() + sort.Strings(flagsSlice) + + for _, flag := range flagsSlice { + generated = append([]string{"use " + flag}, generated...) + } + } + + return strings.Join(generated, "\n\n"), result, nil +} + +// GenerateCaveatSource generates a DSL view of the given caveat definition. +func GenerateCaveatSource(caveat *core.CaveatDefinition, caveatTypeSet *caveattypes.TypeSet) (string, bool, error) { + generator := &sourceGenerator{ + indentationLevel: 0, + hasNewline: true, + hasBlankline: true, + hasNewScope: true, + caveatTypeSet: caveatTypeSet, + } + + err := generator.emitCaveat(caveat) + if err != nil { + return "", false, err + } + + return generator.buf.String(), !generator.hasIssue, nil +} + +// GenerateSource generates a DSL view of the given namespace definition. +func GenerateSource(namespace *core.NamespaceDefinition, caveatTypeSet *caveattypes.TypeSet) (string, bool, error) { + source, _, ok, err := generateDefinitionSource(namespace, caveatTypeSet) + return source, ok, err +} + +func generateDefinitionSource(namespace *core.NamespaceDefinition, caveatTypeSet *caveattypes.TypeSet) (string, []string, bool, error) { + generator := &sourceGenerator{ + indentationLevel: 0, + hasNewline: true, + hasBlankline: true, + hasNewScope: true, + flags: mapz.NewSet[string](), + caveatTypeSet: caveatTypeSet, + } + + err := generator.emitNamespace(namespace) + if err != nil { + return "", nil, false, err + } + + return generator.buf.String(), generator.flags.AsSlice(), !generator.hasIssue, nil +} + +// GenerateRelationSource generates a DSL view of the given relation definition. +func GenerateRelationSource(relation *core.Relation, caveatTypeSet *caveattypes.TypeSet) (string, error) { + generator := &sourceGenerator{ + indentationLevel: 0, + hasNewline: true, + hasBlankline: true, + hasNewScope: true, + caveatTypeSet: caveatTypeSet, + } + + err := generator.emitRelation(relation) + if err != nil { + return "", err + } + + return generator.buf.String(), nil +} + +func (sg *sourceGenerator) emitCaveat(caveat *core.CaveatDefinition) error { + sg.emitComments(caveat.Metadata) + sg.append("caveat ") + sg.append(caveat.Name) + sg.append("(") + + parameterNames := maps.Keys(caveat.ParameterTypes) + sort.Strings(parameterNames) + + for index, paramName := range parameterNames { + if index > 0 { + sg.append(", ") + } + + decoded, err := caveattypes.DecodeParameterType(sg.caveatTypeSet, caveat.ParameterTypes[paramName]) + if err != nil { + return fmt.Errorf("invalid parameter type on caveat: %w", err) + } + + sg.append(paramName) + sg.append(" ") + sg.append(decoded.String()) + } + + sg.append(")") + + sg.append(" {") + sg.appendLine() + sg.indent() + sg.markNewScope() + + parameterTypes, err := caveattypes.DecodeParameterTypes(sg.caveatTypeSet, caveat.ParameterTypes) + if err != nil { + return fmt.Errorf("invalid caveat parameters: %w", err) + } + + deserializedExpression, err := caveats.DeserializeCaveatWithTypeSet(sg.caveatTypeSet, caveat.SerializedExpression, parameterTypes) + if err != nil { + return fmt.Errorf("invalid caveat expression bytes: %w", err) + } + + exprString, err := deserializedExpression.ExprString() + if err != nil { + return fmt.Errorf("invalid caveat expression: %w", err) + } + + sg.append(strings.TrimSpace(exprString)) + sg.appendLine() + + sg.dedent() + sg.append("}") + return nil +} + +func (sg *sourceGenerator) emitNamespace(namespace *core.NamespaceDefinition) error { + sg.emitComments(namespace.Metadata) + sg.append("definition ") + sg.append(namespace.Name) + + if len(namespace.Relation) == 0 { + sg.append(" {}") + return nil + } + + sg.append(" {") + sg.appendLine() + sg.indent() + sg.markNewScope() + + for _, relation := range namespace.Relation { + err := sg.emitRelation(relation) + if err != nil { + return err + } + } + + sg.dedent() + sg.append("}") + return nil +} + +func (sg *sourceGenerator) emitRelation(relation *core.Relation) error { + hasThis, err := graph.HasThis(relation.UsersetRewrite) + if err != nil { + return err + } + + isPermission := relation.UsersetRewrite != nil && !hasThis + + sg.emitComments(relation.Metadata) + if isPermission { + sg.append("permission ") + } else { + sg.append("relation ") + } + + sg.append(relation.Name) + + if !isPermission { + sg.append(": ") + if relation.TypeInformation == nil || relation.TypeInformation.AllowedDirectRelations == nil || len(relation.TypeInformation.AllowedDirectRelations) == 0 { + sg.appendIssue("missing allowed types") + } else { + for index, allowedRelation := range relation.TypeInformation.AllowedDirectRelations { + if index > 0 { + sg.append(" | ") + } + + sg.emitAllowedRelation(allowedRelation) + } + } + } + + if relation.UsersetRewrite != nil { + sg.append(" = ") + sg.mustEmitRewrite(relation.UsersetRewrite) + } + + sg.appendLine() + return nil +} + +func (sg *sourceGenerator) emitAllowedRelation(allowedRelation *core.AllowedRelation) { + sg.append(allowedRelation.Namespace) + if allowedRelation.GetRelation() != "" && allowedRelation.GetRelation() != Ellipsis { + sg.append("#") + sg.append(allowedRelation.GetRelation()) + } + if allowedRelation.GetPublicWildcard() != nil { + sg.append(":*") + } + + hasExpirationTrait := allowedRelation.GetRequiredExpiration() != nil + hasCaveat := allowedRelation.GetRequiredCaveat() != nil + + if hasExpirationTrait || hasCaveat { + sg.append(" with ") + if hasCaveat { + sg.append(allowedRelation.RequiredCaveat.CaveatName) + } + + if hasExpirationTrait { + sg.flags.Add("expiration") + + if hasCaveat { + sg.append(" and ") + } + + sg.append("expiration") + } + } +} + +func (sg *sourceGenerator) mustEmitRewrite(rewrite *core.UsersetRewrite) { + switch rw := rewrite.RewriteOperation.(type) { + case *core.UsersetRewrite_Union: + sg.emitRewriteOps(rw.Union, "+") + case *core.UsersetRewrite_Intersection: + sg.emitRewriteOps(rw.Intersection, "&") + case *core.UsersetRewrite_Exclusion: + sg.emitRewriteOps(rw.Exclusion, "-") + default: + panic(spiceerrors.MustBugf("unknown rewrite operation %T", rw)) + } +} + +func (sg *sourceGenerator) emitRewriteOps(setOp *core.SetOperation, op string) { + for index, child := range setOp.Child { + if index > 0 { + sg.append(" " + op + " ") + } + + sg.mustEmitSetOpChild(child) + } +} + +func (sg *sourceGenerator) isAllUnion(rewrite *core.UsersetRewrite) bool { + switch rw := rewrite.RewriteOperation.(type) { + case *core.UsersetRewrite_Union: + for _, setOpChild := range rw.Union.Child { + switch child := setOpChild.ChildType.(type) { + case *core.SetOperation_Child_UsersetRewrite: + if !sg.isAllUnion(child.UsersetRewrite) { + return false + } + default: + continue + } + } + return true + default: + return false + } +} + +func (sg *sourceGenerator) mustEmitSetOpChild(setOpChild *core.SetOperation_Child) { + switch child := setOpChild.ChildType.(type) { + case *core.SetOperation_Child_UsersetRewrite: + if sg.isAllUnion(child.UsersetRewrite) { + sg.mustEmitRewrite(child.UsersetRewrite) + break + } + + sg.append("(") + sg.mustEmitRewrite(child.UsersetRewrite) + sg.append(")") + + case *core.SetOperation_Child_XThis: + sg.appendIssue("_this unsupported here. Please rewrite into a relation and permission") + + case *core.SetOperation_Child_XNil: + sg.append("nil") + + case *core.SetOperation_Child_ComputedUserset: + sg.append(child.ComputedUserset.Relation) + + case *core.SetOperation_Child_TupleToUserset: + sg.append(child.TupleToUserset.Tupleset.Relation) + sg.append("->") + sg.append(child.TupleToUserset.ComputedUserset.Relation) + + case *core.SetOperation_Child_FunctionedTupleToUserset: + sg.append(child.FunctionedTupleToUserset.Tupleset.Relation) + sg.append(".") + + switch child.FunctionedTupleToUserset.Function { + case core.FunctionedTupleToUserset_FUNCTION_ALL: + sg.append("all") + + case core.FunctionedTupleToUserset_FUNCTION_ANY: + sg.append("any") + + default: + panic(spiceerrors.MustBugf("unknown function %v", child.FunctionedTupleToUserset.Function)) + } + + sg.append("(") + sg.append(child.FunctionedTupleToUserset.ComputedUserset.Relation) + sg.append(")") + + default: + panic(spiceerrors.MustBugf("unknown child type %T", child)) + } +} + +func (sg *sourceGenerator) emitComments(metadata *core.Metadata) { + if len(namespace.GetComments(metadata)) > 0 { + sg.ensureBlankLineOrNewScope() + } + + for _, comment := range namespace.GetComments(metadata) { + sg.appendComment(comment) + } +} + +func (sg *sourceGenerator) appendComment(comment string) { + switch { + case strings.HasPrefix(comment, "/*"): + stripped := strings.TrimSpace(comment) + + if strings.HasPrefix(stripped, "/**") { + stripped = strings.TrimPrefix(stripped, "/**") + sg.append("/**") + } else { + stripped = strings.TrimPrefix(stripped, "/*") + sg.append("/*") + } + + stripped = strings.TrimSuffix(stripped, "*/") + stripped = strings.TrimSpace(stripped) + + requireMultiline := len(stripped) > MaxSingleLineCommentLength || strings.ContainsRune(stripped, '\n') + + if requireMultiline { + sg.appendLine() + scanner := bufio.NewScanner(strings.NewReader(stripped)) + for scanner.Scan() { + sg.append(" * ") + sg.append(strings.TrimSpace(strings.TrimPrefix(strings.TrimSpace(scanner.Text()), "*"))) + sg.appendLine() + } + sg.append(" */") + sg.appendLine() + } else { + sg.append(" ") + sg.append(strings.TrimSpace(strings.TrimPrefix(strings.TrimSpace(stripped), "*"))) + sg.append(" */") + sg.appendLine() + } + + case strings.HasPrefix(comment, "//"): + sg.append("// ") + sg.append(strings.TrimSpace(strings.TrimPrefix(strings.TrimSpace(comment), "//"))) + sg.appendLine() + } +} diff --git a/vendor/github.com/authzed/spicedb/pkg/schemadsl/generator/generator_impl.go b/vendor/github.com/authzed/spicedb/pkg/schemadsl/generator/generator_impl.go new file mode 100644 index 0000000..6251712 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/schemadsl/generator/generator_impl.go @@ -0,0 +1,83 @@ +package generator + +import ( + "strings" + + caveattypes "github.com/authzed/spicedb/pkg/caveats/types" + "github.com/authzed/spicedb/pkg/genutil/mapz" +) + +type sourceGenerator struct { + buf strings.Builder // The buffer for the new source code. + indentationLevel int // The current indentation level. + hasNewline bool // Whether there is a newline at the end of the buffer. + hasBlankline bool // Whether there is a blank line at the end of the buffer. + hasIssue bool // Whether there is a translation issue. + hasNewScope bool // Whether there is a new scope at the end of the buffer. + existingLineLength int // Length of the existing line. + flags *mapz.Set[string] // The flags added while generating. + caveatTypeSet *caveattypes.TypeSet +} + +// ensureBlankLineOrNewScope ensures that there is a blank line or new scope at the tail of the buffer. If not, +// a new line is added. +func (sg *sourceGenerator) ensureBlankLineOrNewScope() { + if !sg.hasBlankline && !sg.hasNewScope { + sg.appendLine() + } +} + +// indent increases the current indentation. +func (sg *sourceGenerator) indent() { + sg.indentationLevel = sg.indentationLevel + 1 +} + +// dedent decreases the current indentation. +func (sg *sourceGenerator) dedent() { + sg.indentationLevel = sg.indentationLevel - 1 +} + +// appendIssue adds an issue found in generation. +func (sg *sourceGenerator) appendIssue(description string) { + sg.append("/* ") + sg.append(description) + sg.append(" */") + sg.hasIssue = true +} + +// append adds the given value to the buffer, indenting as necessary. +func (sg *sourceGenerator) append(value string) { + for _, currentRune := range value { + if currentRune == '\n' { + if sg.hasNewline { + sg.hasBlankline = true + } + + sg.buf.WriteRune('\n') + sg.hasNewline = true + sg.existingLineLength = 0 + continue + } + + sg.hasBlankline = false + sg.hasNewScope = false + + if sg.hasNewline { + sg.buf.WriteString(strings.Repeat("\t", sg.indentationLevel)) + sg.hasNewline = false + sg.existingLineLength += sg.indentationLevel + } + + sg.existingLineLength++ + sg.buf.WriteRune(currentRune) + } +} + +// appendLine adds a newline. +func (sg *sourceGenerator) appendLine() { + sg.append("\n") +} + +func (sg *sourceGenerator) markNewScope() { + sg.hasNewScope = true +} diff --git a/vendor/github.com/authzed/spicedb/pkg/schemadsl/input/inputsource.go b/vendor/github.com/authzed/spicedb/pkg/schemadsl/input/inputsource.go new file mode 100644 index 0000000..3bd0437 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/schemadsl/input/inputsource.go @@ -0,0 +1,224 @@ +package input + +import ( + "fmt" +) + +// BytePosition represents the byte position in a piece of code. +type BytePosition int + +// Position represents a position in an arbitrary source file. +type Position struct { + // LineNumber is the 0-indexed line number. + LineNumber int + + // ColumnPosition is the 0-indexed column position on the line. + ColumnPosition int +} + +// Source represents the path of a source file. +type Source string + +// RangeForRunePosition returns a source range over this source file. +func (is Source) RangeForRunePosition(runePosition int, mapper PositionMapper) SourceRange { + return is.RangeForRunePositions(runePosition, runePosition, mapper) +} + +// PositionForRunePosition returns a source position over this source file. +func (is Source) PositionForRunePosition(runePosition int, mapper PositionMapper) SourcePosition { + return runeIndexedPosition{is, mapper, runePosition} +} + +// PositionFromLineAndColumn returns a source position at the given line and column in this source file. +func (is Source) PositionFromLineAndColumn(lineNumber int, columnPosition int, mapper PositionMapper) SourcePosition { + return lcIndexedPosition{is, mapper, Position{lineNumber, columnPosition}} +} + +// RangeForRunePositions returns a source range over this source file. +func (is Source) RangeForRunePositions(startRune int, endRune int, mapper PositionMapper) SourceRange { + return sourceRange{is, runeIndexedPosition{is, mapper, startRune}, runeIndexedPosition{is, mapper, endRune}} +} + +// RangeForLineAndColPositions returns a source range over this source file. +func (is Source) RangeForLineAndColPositions(start Position, end Position, mapper PositionMapper) SourceRange { + return sourceRange{is, lcIndexedPosition{is, mapper, start}, lcIndexedPosition{is, mapper, end}} +} + +// PositionMapper defines an interface for converting rune position <-> line+col position +// under source files. +type PositionMapper interface { + // RunePositionToLineAndCol converts the given 0-indexed rune position under the given source file + // into a 0-indexed line number and column position. + RunePositionToLineAndCol(runePosition int, path Source) (int, int, error) + + // LineAndColToRunePosition converts the given 0-indexed line number and column position under the + // given source file into a 0-indexed rune position. + LineAndColToRunePosition(lineNumber int, colPosition int, path Source) (int, error) + + // TextForLine returns the text for the specified line number. + TextForLine(lineNumber int, path Source) (string, error) +} + +// SourceRange represents a range inside a source file. +type SourceRange interface { + // Source is the input source for this range. + Source() Source + + // Start is the starting position of the source range. + Start() SourcePosition + + // End is the ending position (inclusive) of the source range. If the same as the Start, + // this range represents a single position. + End() SourcePosition + + // ContainsPosition returns true if the given range contains the given position. + ContainsPosition(position SourcePosition) (bool, error) + + // AtStartPosition returns a SourceRange located only at the starting position of this range. + AtStartPosition() SourceRange + + // String returns a (somewhat) human-readable form of the range. + String() string +} + +// SourcePosition represents a single position in a source file. +type SourcePosition interface { + // Source is the input source for this position. + Source() Source + + // RunePosition returns the 0-indexed rune position in the source file. + RunePosition() (int, error) + + // LineAndColumn returns the 0-indexed line number and column position in the source file. + LineAndColumn() (int, int, error) + + // LineText returns the text of the line for this position. + LineText() (string, error) + + // String returns a (somewhat) human-readable form of the position. + String() string +} + +// sourceRange implements the SourceRange interface. +type sourceRange struct { + source Source + start SourcePosition + end SourcePosition +} + +func (sr sourceRange) Source() Source { + return sr.source +} + +func (sr sourceRange) Start() SourcePosition { + return sr.start +} + +func (sr sourceRange) End() SourcePosition { + return sr.end +} + +func (sr sourceRange) AtStartPosition() SourceRange { + return sourceRange{sr.source, sr.start, sr.end} +} + +func (sr sourceRange) ContainsPosition(position SourcePosition) (bool, error) { + if position.Source() != sr.source { + return false, nil + } + + startRune, err := sr.start.RunePosition() + if err != nil { + return false, err + } + + endRune, err := sr.end.RunePosition() + if err != nil { + return false, err + } + + positionRune, err := position.RunePosition() + if err != nil { + return false, err + } + + return positionRune >= startRune && positionRune <= endRune, nil +} + +func (sr sourceRange) String() string { + return fmt.Sprintf("%v -> %v", sr.start, sr.end) +} + +// runeIndexedPosition implements the SourcePosition interface over a rune position. +type runeIndexedPosition struct { + source Source + mapper PositionMapper + runePosition int +} + +func (ris runeIndexedPosition) Source() Source { + return ris.source +} + +func (ris runeIndexedPosition) RunePosition() (int, error) { + return ris.runePosition, nil +} + +func (ris runeIndexedPosition) LineAndColumn() (int, int, error) { + if ris.runePosition == 0 { + return 0, 0, nil + } + if ris.mapper == nil { + return -1, -1, fmt.Errorf("nil mapper") + } + return ris.mapper.RunePositionToLineAndCol(ris.runePosition, ris.source) +} + +func (ris runeIndexedPosition) String() string { + return fmt.Sprintf("%s@%v (rune)", ris.source, ris.runePosition) +} + +func (ris runeIndexedPosition) LineText() (string, error) { + lineNumber, _, err := ris.LineAndColumn() + if err != nil { + return "", err + } + + return ris.mapper.TextForLine(lineNumber, ris.source) +} + +// lcIndexedPosition implements the SourcePosition interface over a line and colu,n position. +type lcIndexedPosition struct { + source Source + mapper PositionMapper + lcPosition Position +} + +func (lcip lcIndexedPosition) Source() Source { + return lcip.source +} + +func (lcip lcIndexedPosition) String() string { + return fmt.Sprintf("%s@%v:%v (line/col)", lcip.source, lcip.lcPosition.LineNumber, lcip.lcPosition.ColumnPosition) +} + +func (lcip lcIndexedPosition) RunePosition() (int, error) { + if lcip.lcPosition.LineNumber == 0 && lcip.lcPosition.ColumnPosition == 0 { + return 0, nil + } + if lcip.mapper == nil { + return -1, fmt.Errorf("nil mapper") + } + return lcip.mapper.LineAndColToRunePosition(lcip.lcPosition.LineNumber, lcip.lcPosition.ColumnPosition, lcip.source) +} + +func (lcip lcIndexedPosition) LineAndColumn() (int, int, error) { + return lcip.lcPosition.LineNumber, lcip.lcPosition.ColumnPosition, nil +} + +func (lcip lcIndexedPosition) LineText() (string, error) { + if lcip.mapper == nil { + return "", fmt.Errorf("nil mapper") + } + return lcip.mapper.TextForLine(lcip.lcPosition.LineNumber, lcip.source) +} diff --git a/vendor/github.com/authzed/spicedb/pkg/schemadsl/input/sourcepositionmapper.go b/vendor/github.com/authzed/spicedb/pkg/schemadsl/input/sourcepositionmapper.go new file mode 100644 index 0000000..1bca03c --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/schemadsl/input/sourcepositionmapper.go @@ -0,0 +1,95 @@ +package input + +import ( + "fmt" + "strings" + + "github.com/emirpasic/gods/trees/redblacktree" +) + +// SourcePositionMapper defines a helper struct for cached, faster lookup of rune position <-> +// (line, column) for a specific source file. +type SourcePositionMapper struct { + // rangeTree holds a tree that maps from rune position to a line and start position. + rangeTree *redblacktree.Tree + + // lineMap holds a map from line number to rune positions for that line. + lineMap map[int]inclusiveRange +} + +// EmptySourcePositionMapper returns an empty source position mapper. +func EmptySourcePositionMapper() SourcePositionMapper { + rangeTree := redblacktree.NewWith(inclusiveComparator) + return SourcePositionMapper{rangeTree, map[int]inclusiveRange{}} +} + +// CreateSourcePositionMapper returns a source position mapper for the contents of a source file. +func CreateSourcePositionMapper(contents []byte) SourcePositionMapper { + lines := strings.Split(string(contents), "\n") + rangeTree := redblacktree.NewWith(inclusiveComparator) + lineMap := map[int]inclusiveRange{} + + currentStart := int(0) + for index, line := range lines { + lineEnd := currentStart + len(line) + rangeTree.Put(inclusiveRange{currentStart, lineEnd}, lineAndStart{index, currentStart}) + lineMap[index] = inclusiveRange{currentStart, lineEnd} + currentStart = lineEnd + 1 + } + + return SourcePositionMapper{rangeTree, lineMap} +} + +type inclusiveRange struct { + start int + end int +} + +type lineAndStart struct { + lineNumber int + startPosition int +} + +func inclusiveComparator(a, b interface{}) int { + i1 := a.(inclusiveRange) + i2 := b.(inclusiveRange) + + if i1.start >= i2.start && i1.end <= i2.end { + return 0 + } + + diff := int64(i1.start) - int64(i2.start) + + if diff < 0 { + return -1 + } + if diff > 0 { + return 1 + } + return 0 +} + +// RunePositionToLineAndCol returns the line number and column position of the rune position in source. +func (spm SourcePositionMapper) RunePositionToLineAndCol(runePosition int) (int, int, error) { + ls, found := spm.rangeTree.Get(inclusiveRange{runePosition, runePosition}) + if !found { + return 0, 0, fmt.Errorf("unknown rune position %v in source file", runePosition) + } + + las := ls.(lineAndStart) + return las.lineNumber, runePosition - las.startPosition, nil +} + +// LineAndColToRunePosition returns the rune position of the line number and column position in source. +func (spm SourcePositionMapper) LineAndColToRunePosition(lineNumber int, colPosition int) (int, error) { + lineRuneInfo, hasLine := spm.lineMap[lineNumber] + if !hasLine { + return 0, fmt.Errorf("unknown line %v in source file", lineNumber) + } + + if colPosition > lineRuneInfo.end-lineRuneInfo.start { + return 0, fmt.Errorf("column position %v not found on line %v in source file", colPosition, lineNumber) + } + + return lineRuneInfo.start + colPosition, nil +} diff --git a/vendor/github.com/authzed/spicedb/pkg/schemadsl/lexer/flaggablelexer.go b/vendor/github.com/authzed/spicedb/pkg/schemadsl/lexer/flaggablelexer.go new file mode 100644 index 0000000..1ae99af --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/schemadsl/lexer/flaggablelexer.go @@ -0,0 +1,59 @@ +package lexer + +// FlaggableLexer wraps a lexer, automatically translating tokens based on flags, if any. +type FlaggableLexer struct { + lex *Lexer // a reference to the lexer used for tokenization + enabledFlags map[string]transformer // flags that are enabled + seenDefinition bool + afterUseIdentifier bool +} + +// NewFlaggableLexer returns a new FlaggableLexer for the given lexer. +func NewFlaggableLexer(lex *Lexer) *FlaggableLexer { + return &FlaggableLexer{ + lex: lex, + enabledFlags: map[string]transformer{}, + } +} + +// Close stops the lexer from running. +func (l *FlaggableLexer) Close() { + l.lex.Close() +} + +// NextToken returns the next token found in the lexer. +func (l *FlaggableLexer) NextToken() Lexeme { + nextToken := l.lex.nextToken() + + // Look for `use somefeature` + if nextToken.Kind == TokenTypeIdentifier { + // Only allowed until we've seen a definition of some kind. + if !l.seenDefinition { + if l.afterUseIdentifier { + if transformer, ok := Flags[nextToken.Value]; ok { + l.enabledFlags[nextToken.Value] = transformer + } + + l.afterUseIdentifier = false + } else { + l.afterUseIdentifier = nextToken.Value == "use" + } + } + } + + if nextToken.Kind == TokenTypeKeyword && nextToken.Value == "definition" { + l.seenDefinition = true + } + if nextToken.Kind == TokenTypeKeyword && nextToken.Value == "caveat" { + l.seenDefinition = true + } + + for _, handler := range l.enabledFlags { + updated, ok := handler(nextToken) + if ok { + return updated + } + } + + return nextToken +} diff --git a/vendor/github.com/authzed/spicedb/pkg/schemadsl/lexer/flags.go b/vendor/github.com/authzed/spicedb/pkg/schemadsl/lexer/flags.go new file mode 100644 index 0000000..3bfbbde --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/schemadsl/lexer/flags.go @@ -0,0 +1,26 @@ +package lexer + +// FlagExpiration indicates that `expiration` is supported as a first-class +// feature in the schema. +const FlagExpiration = "expiration" + +type transformer func(lexeme Lexeme) (Lexeme, bool) + +// Flags is a map of flag names to their corresponding transformers. +var Flags = map[string]transformer{ + FlagExpiration: func(lexeme Lexeme) (Lexeme, bool) { + // `expiration` becomes a keyword. + if lexeme.Kind == TokenTypeIdentifier && lexeme.Value == "expiration" { + lexeme.Kind = TokenTypeKeyword + return lexeme, true + } + + // `and` becomes a keyword. + if lexeme.Kind == TokenTypeIdentifier && lexeme.Value == "and" { + lexeme.Kind = TokenTypeKeyword + return lexeme, true + } + + return lexeme, false + }, +} diff --git a/vendor/github.com/authzed/spicedb/pkg/schemadsl/lexer/lex.go b/vendor/github.com/authzed/spicedb/pkg/schemadsl/lexer/lex.go new file mode 100644 index 0000000..a09df50 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/schemadsl/lexer/lex.go @@ -0,0 +1,231 @@ +// Based on design first introduced in: http://blog.golang.org/two-go-talks-lexical-scanning-in-go-and +// Portions copied and modified from: https://github.com/golang/go/blob/master/src/text/template/parse/lex.go + +package lexer + +import ( + "fmt" + "strings" + "sync" + "unicode/utf8" + + "github.com/authzed/spicedb/pkg/schemadsl/input" +) + +const EOFRUNE = -1 + +// createLexer creates a new scanner for the input string. +func createLexer(source input.Source, input string) *Lexer { + l := &Lexer{ + source: source, + input: input, + tokens: make(chan Lexeme), + closed: make(chan struct{}), + } + go l.run() + return l +} + +// run runs the state machine for the lexer. +func (l *Lexer) run() { + defer func() { + close(l.tokens) + }() + l.withLock(func() { + l.state = lexSource + }) + var state stateFn + for { + l.withRLock(func() { + state = l.state + }) + if state == nil { + break + } + next := state(l) + l.withLock(func() { + l.state = next + }) + } +} + +// Close stops the lexer from running. +func (l *Lexer) Close() { + close(l.closed) + l.withLock(func() { + l.state = nil + }) +} + +// withLock runs f protected by l's lock +func (l *Lexer) withLock(f func()) { + l.Lock() + defer l.Unlock() + f() +} + +// withRLock runs f protected by l's read lock +func (l *Lexer) withRLock(f func()) { + l.RLock() + defer l.RUnlock() + f() +} + +// Lexeme represents a token returned from scanning the contents of a file. +type Lexeme struct { + Kind TokenType // The type of this lexeme. + Position input.BytePosition // The starting position of this token in the input string. + Value string // The textual value of this token. + Error string // The error associated with the lexeme, if any. +} + +// stateFn represents the state of the scanner as a function that returns the next state. +type stateFn func(*Lexer) stateFn + +// Lexer holds the state of the scanner. +type Lexer struct { + sync.RWMutex + state stateFn // the next lexing function to enter. GUARDED_BY(RWMutex) + + source input.Source // the name of the input; used only for error reports + input string // the string being scanned + pos input.BytePosition // current position in the input + start input.BytePosition // start position of this token + width input.BytePosition // width of last rune read from input + lastPos input.BytePosition // position of most recent token returned by nextToken + tokens chan Lexeme // channel of scanned lexemes + currentToken Lexeme // The current token if any + lastNonIgnoredToken Lexeme // The last token returned that is non-whitespace and non-comment + closed chan struct{} // Holds the closed channel +} + +// nextToken returns the next token from the input. +func (l *Lexer) nextToken() Lexeme { + token := <-l.tokens + l.lastPos = token.Position + return token +} + +// next returns the next rune in the input. +func (l *Lexer) next() rune { + if int(l.pos) >= len(l.input) { + l.width = 0 + return EOFRUNE + } + r, w := utf8.DecodeRuneInString(l.input[l.pos:]) + l.width = input.BytePosition(w) + l.pos += l.width + return r +} + +// peek returns but does not consume the next rune in the input. +func (l *Lexer) peek() rune { + r := l.next() + l.backup() + return r +} + +// backup steps back one rune. Can only be called once per call of next. +func (l *Lexer) backup() { + l.pos -= l.width +} + +// value returns the current value of the token in the lexer. +func (l *Lexer) value() string { + return l.input[l.start:l.pos] +} + +// emit passes an token back to the client. +func (l *Lexer) emit(t TokenType) { + currentToken := Lexeme{t, l.start, l.value(), ""} + + if t != TokenTypeWhitespace && t != TokenTypeMultilineComment && t != TokenTypeSinglelineComment { + l.lastNonIgnoredToken = currentToken + } + + select { + case l.tokens <- currentToken: + l.currentToken = currentToken + l.start = l.pos + + case <-l.closed: + return + } +} + +// errorf returns an error token and terminates the scan by passing +// back a nil pointer that will be the next state, terminating l.nexttoken. +func (l *Lexer) errorf(currentRune rune, format string, args ...interface{}) stateFn { + l.tokens <- Lexeme{TokenTypeError, l.start, string(currentRune), fmt.Sprintf(format, args...)} + return nil +} + +// peekValue looks forward for the given value string. If found, returns true. +func (l *Lexer) peekValue(value string) bool { + for index, runeValue := range value { + r := l.next() + if r != runeValue { + for j := 0; j <= index; j++ { + l.backup() + } + return false + } + } + + for i := 0; i < len(value); i++ { + l.backup() + } + + return true +} + +// accept consumes the next rune if it's from the valid set. +func (l *Lexer) accept(valid string) bool { + if nextRune := l.next(); strings.ContainsRune(valid, nextRune) { + return true + } + l.backup() + return false +} + +// acceptString consumes the full given string, if the next tokens in the stream. +func (l *Lexer) acceptString(value string) bool { + for index, runeValue := range value { + if l.next() != runeValue { + for i := 0; i <= index; i++ { + l.backup() + } + + return false + } + } + + return true +} + +// lexSource scans until EOFRUNE +func lexSource(l *Lexer) stateFn { + return lexerEntrypoint(l) +} + +// checkFn returns whether a rune matches for continue looping. +type checkFn func(r rune) (bool, error) + +func buildLexUntil(findType TokenType, checker checkFn) stateFn { + return func(l *Lexer) stateFn { + for { + r := l.next() + isValid, err := checker(r) + if err != nil { + return l.errorf(r, "%v", err) + } + if !isValid { + l.backup() + break + } + } + + l.emit(findType) + return lexSource + } +} diff --git a/vendor/github.com/authzed/spicedb/pkg/schemadsl/lexer/lex_def.go b/vendor/github.com/authzed/spicedb/pkg/schemadsl/lexer/lex_def.go new file mode 100644 index 0000000..d8cbe8c --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/schemadsl/lexer/lex_def.go @@ -0,0 +1,351 @@ +//go:generate go run golang.org/x/tools/cmd/stringer -type=TokenType + +package lexer + +import ( + "unicode" + + "github.com/authzed/spicedb/pkg/schemadsl/input" +) + +// Lex creates a new scanner for the input string. +func Lex(source input.Source, input string) *Lexer { + return createLexer(source, input) +} + +// TokenType identifies the type of lexer lexemes. +type TokenType int + +const ( + TokenTypeError TokenType = iota // error occurred; value is text of error + + // Synthetic semicolon + TokenTypeSyntheticSemicolon + + TokenTypeEOF + TokenTypeWhitespace + TokenTypeSinglelineComment + TokenTypeMultilineComment + TokenTypeNewline + + TokenTypeKeyword // interface + TokenTypeIdentifier // helloworld + TokenTypeNumber // 123 + + TokenTypeLeftBrace // { + TokenTypeRightBrace // } + TokenTypeLeftParen // ( + TokenTypeRightParen // ) + + TokenTypePipe // | + TokenTypePlus // + + TokenTypeMinus // - + TokenTypeAnd // & + TokenTypeDiv // / + + TokenTypeEquals // = + TokenTypeColon // : + TokenTypeSemicolon // ; + TokenTypeRightArrow // -> + TokenTypeHash // # + TokenTypeEllipsis // ... + TokenTypeStar // * + + // Additional tokens for CEL: https://github.com/google/cel-spec/blob/master/doc/langdef.md#syntax + TokenTypeQuestionMark // ? + TokenTypeConditionalOr // || + TokenTypeConditionalAnd // && + TokenTypeExclamationPoint // ! + TokenTypeLeftBracket // [ + TokenTypeRightBracket // ] + TokenTypePeriod // . + TokenTypeComma // , + TokenTypePercent // % + TokenTypeLessThan // < + TokenTypeGreaterThan // > + TokenTypeLessThanOrEqual // <= + TokenTypeGreaterThanOrEqual // >= + TokenTypeEqualEqual // == + TokenTypeNotEqual // != + TokenTypeString // "...", '...', """...""", '''...''' +) + +// keywords contains the full set of keywords supported. +var keywords = map[string]struct{}{ + "definition": {}, + "caveat": {}, + "relation": {}, + "permission": {}, + "nil": {}, + "with": {}, +} + +// IsKeyword returns whether the specified input string is a reserved keyword. +func IsKeyword(candidate string) bool { + _, ok := keywords[candidate] + return ok +} + +// syntheticPredecessors contains the full set of token types after which, if a newline is found, +// we emit a synthetic semicolon rather than a normal newline token. +var syntheticPredecessors = map[TokenType]bool{ + TokenTypeIdentifier: true, + TokenTypeKeyword: true, + + TokenTypeRightBrace: true, + TokenTypeRightParen: true, + + TokenTypeStar: true, +} + +// lexerEntrypoint scans until EOFRUNE +func lexerEntrypoint(l *Lexer) stateFn { +Loop: + for { + switch r := l.next(); { + case r == EOFRUNE: + break Loop + + case r == '{': + l.emit(TokenTypeLeftBrace) + + case r == '}': + l.emit(TokenTypeRightBrace) + + case r == '(': + l.emit(TokenTypeLeftParen) + + case r == ')': + l.emit(TokenTypeRightParen) + + case r == '+': + l.emit(TokenTypePlus) + + case r == '|': + if l.acceptString("|") { + l.emit(TokenTypeConditionalOr) + } else { + l.emit(TokenTypePipe) + } + + case r == '&': + if l.acceptString("&") { + l.emit(TokenTypeConditionalAnd) + } else { + l.emit(TokenTypeAnd) + } + + case r == '?': + l.emit(TokenTypeQuestionMark) + + case r == '!': + if l.acceptString("=") { + l.emit(TokenTypeNotEqual) + } else { + l.emit(TokenTypeExclamationPoint) + } + + case r == '[': + l.emit(TokenTypeLeftBracket) + + case r == ']': + l.emit(TokenTypeRightBracket) + + case r == '%': + l.emit(TokenTypePercent) + + case r == '<': + if l.acceptString("=") { + l.emit(TokenTypeLessThanOrEqual) + } else { + l.emit(TokenTypeLessThan) + } + + case r == '>': + if l.acceptString("=") { + l.emit(TokenTypeGreaterThanOrEqual) + } else { + l.emit(TokenTypeGreaterThan) + } + + case r == ',': + l.emit(TokenTypeComma) + + case r == '=': + if l.acceptString("=") { + l.emit(TokenTypeEqualEqual) + } else { + l.emit(TokenTypeEquals) + } + + case r == ':': + l.emit(TokenTypeColon) + + case r == ';': + l.emit(TokenTypeSemicolon) + + case r == '#': + l.emit(TokenTypeHash) + + case r == '*': + l.emit(TokenTypeStar) + + case r == '.': + if l.acceptString("..") { + l.emit(TokenTypeEllipsis) + } else { + l.emit(TokenTypePeriod) + } + + case r == '-': + if l.accept(">") { + l.emit(TokenTypeRightArrow) + } else { + l.emit(TokenTypeMinus) + } + + case isSpace(r): + l.emit(TokenTypeWhitespace) + + case isNewline(r): + // If the previous token matches the synthetic semicolon list, + // we emit a synthetic semicolon instead of a simple newline. + if _, ok := syntheticPredecessors[l.lastNonIgnoredToken.Kind]; ok { + l.emit(TokenTypeSyntheticSemicolon) + } else { + l.emit(TokenTypeNewline) + } + + case isAlphaNumeric(r): + l.backup() + return lexIdentifierOrKeyword + + case r == '\'' || r == '"': + l.backup() + return lexStringLiteral + + case r == '/': + // Check for comments. + if l.peekValue("/") { + l.backup() + return lexSinglelineComment + } + + if l.peekValue("*") { + l.backup() + return lexMultilineComment + } + + l.emit(TokenTypeDiv) + default: + return l.errorf(r, "unrecognized character at this location: %#U", r) + } + } + + l.emit(TokenTypeEOF) + return nil +} + +// lexStringLiteral scan until the close of the string literal or EOFRUNE +func lexStringLiteral(l *Lexer) stateFn { + allowNewlines := false + terminator := "" + + if l.acceptString(`"""`) { + terminator = `"""` + allowNewlines = true + } else if l.acceptString(`'''`) { + terminator = `"""` + allowNewlines = true + } else if l.acceptString(`"`) { + terminator = `"` + } else if l.acceptString(`'`) { + terminator = `'` + } + + for { + if l.peekValue(terminator) { + l.acceptString(terminator) + l.emit(TokenTypeString) + return lexSource + } + + // Otherwise, consume until we hit EOFRUNE. + r := l.next() + if !allowNewlines && isNewline(r) { + return l.errorf(r, "Unterminated string") + } + + if r == EOFRUNE { + return l.errorf(r, "Unterminated string") + } + } +} + +// lexSinglelineComment scans until newline or EOFRUNE +func lexSinglelineComment(l *Lexer) stateFn { + checker := func(r rune) (bool, error) { + result := r == EOFRUNE || isNewline(r) + return !result, nil + } + + l.acceptString("//") + return buildLexUntil(TokenTypeSinglelineComment, checker) +} + +// lexMultilineComment scans until the close of the multiline comment or EOFRUNE +func lexMultilineComment(l *Lexer) stateFn { + l.acceptString("/*") + for { + // Check for the end of the multiline comment. + if l.peekValue("*/") { + l.acceptString("*/") + l.emit(TokenTypeMultilineComment) + return lexSource + } + + // Otherwise, consume until we hit EOFRUNE. + r := l.next() + if r == EOFRUNE { + return l.errorf(r, "Unterminated multiline comment") + } + } +} + +// lexIdentifierOrKeyword searches for a keyword or literal identifier. +func lexIdentifierOrKeyword(l *Lexer) stateFn { + for { + if !isAlphaNumeric(l.peek()) { + break + } + + l.next() + } + + _, isKeyword := keywords[l.value()] + + switch { + case isKeyword: + l.emit(TokenTypeKeyword) + + default: + l.emit(TokenTypeIdentifier) + } + + return lexSource +} + +// isSpace reports whether r is a space character. +func isSpace(r rune) bool { + return r == ' ' || r == '\t' +} + +// isNewline reports whether r is a newline character. +func isNewline(r rune) bool { + return r == '\r' || r == '\n' +} + +// isAlphaNumeric reports whether r is an alphabetic, digit, or underscore. +func isAlphaNumeric(r rune) bool { + return r == '_' || unicode.IsLetter(r) || unicode.IsDigit(r) +} diff --git a/vendor/github.com/authzed/spicedb/pkg/schemadsl/lexer/tokentype_string.go b/vendor/github.com/authzed/spicedb/pkg/schemadsl/lexer/tokentype_string.go new file mode 100644 index 0000000..79f3585 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/schemadsl/lexer/tokentype_string.go @@ -0,0 +1,64 @@ +// Code generated by "stringer -type=TokenType"; DO NOT EDIT. + +package lexer + +import "strconv" + +func _() { + // An "invalid array index" compiler error signifies that the constant values have changed. + // Re-run the stringer command to generate them again. + var x [1]struct{} + _ = x[TokenTypeError-0] + _ = x[TokenTypeSyntheticSemicolon-1] + _ = x[TokenTypeEOF-2] + _ = x[TokenTypeWhitespace-3] + _ = x[TokenTypeSinglelineComment-4] + _ = x[TokenTypeMultilineComment-5] + _ = x[TokenTypeNewline-6] + _ = x[TokenTypeKeyword-7] + _ = x[TokenTypeIdentifier-8] + _ = x[TokenTypeNumber-9] + _ = x[TokenTypeLeftBrace-10] + _ = x[TokenTypeRightBrace-11] + _ = x[TokenTypeLeftParen-12] + _ = x[TokenTypeRightParen-13] + _ = x[TokenTypePipe-14] + _ = x[TokenTypePlus-15] + _ = x[TokenTypeMinus-16] + _ = x[TokenTypeAnd-17] + _ = x[TokenTypeDiv-18] + _ = x[TokenTypeEquals-19] + _ = x[TokenTypeColon-20] + _ = x[TokenTypeSemicolon-21] + _ = x[TokenTypeRightArrow-22] + _ = x[TokenTypeHash-23] + _ = x[TokenTypeEllipsis-24] + _ = x[TokenTypeStar-25] + _ = x[TokenTypeQuestionMark-26] + _ = x[TokenTypeConditionalOr-27] + _ = x[TokenTypeConditionalAnd-28] + _ = x[TokenTypeExclamationPoint-29] + _ = x[TokenTypeLeftBracket-30] + _ = x[TokenTypeRightBracket-31] + _ = x[TokenTypePeriod-32] + _ = x[TokenTypeComma-33] + _ = x[TokenTypePercent-34] + _ = x[TokenTypeLessThan-35] + _ = x[TokenTypeGreaterThan-36] + _ = x[TokenTypeLessThanOrEqual-37] + _ = x[TokenTypeGreaterThanOrEqual-38] + _ = x[TokenTypeEqualEqual-39] + _ = x[TokenTypeNotEqual-40] + _ = x[TokenTypeString-41] +} + +const _TokenType_name = "TokenTypeErrorTokenTypeSyntheticSemicolonTokenTypeEOFTokenTypeWhitespaceTokenTypeSinglelineCommentTokenTypeMultilineCommentTokenTypeNewlineTokenTypeKeywordTokenTypeIdentifierTokenTypeNumberTokenTypeLeftBraceTokenTypeRightBraceTokenTypeLeftParenTokenTypeRightParenTokenTypePipeTokenTypePlusTokenTypeMinusTokenTypeAndTokenTypeDivTokenTypeEqualsTokenTypeColonTokenTypeSemicolonTokenTypeRightArrowTokenTypeHashTokenTypeEllipsisTokenTypeStarTokenTypeQuestionMarkTokenTypeConditionalOrTokenTypeConditionalAndTokenTypeExclamationPointTokenTypeLeftBracketTokenTypeRightBracketTokenTypePeriodTokenTypeCommaTokenTypePercentTokenTypeLessThanTokenTypeGreaterThanTokenTypeLessThanOrEqualTokenTypeGreaterThanOrEqualTokenTypeEqualEqualTokenTypeNotEqualTokenTypeString" + +var _TokenType_index = [...]uint16{0, 14, 41, 53, 72, 98, 123, 139, 155, 174, 189, 207, 226, 244, 263, 276, 289, 303, 315, 327, 342, 356, 374, 393, 406, 423, 436, 457, 479, 502, 527, 547, 568, 583, 597, 613, 630, 650, 674, 701, 720, 737, 752} + +func (i TokenType) String() string { + if i < 0 || i >= TokenType(len(_TokenType_index)-1) { + return "TokenType(" + strconv.FormatInt(int64(i), 10) + ")" + } + return _TokenType_name[_TokenType_index[i]:_TokenType_index[i+1]] +} diff --git a/vendor/github.com/authzed/spicedb/pkg/schemadsl/parser/nodestack.go b/vendor/github.com/authzed/spicedb/pkg/schemadsl/parser/nodestack.go new file mode 100644 index 0000000..0d49e09 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/schemadsl/parser/nodestack.go @@ -0,0 +1,35 @@ +package parser + +type nodeStack struct { + top *element + size int +} + +type element struct { + value AstNode + next *element +} + +func (s *nodeStack) topValue() AstNode { + if s.size == 0 { + return nil + } + + return s.top.value +} + +// Push pushes a node onto the stack. +func (s *nodeStack) push(value AstNode) { + s.top = &element{value, s.top} + s.size++ +} + +// Pop removes the node from the stack and returns it. +func (s *nodeStack) pop() (value AstNode) { + if s.size > 0 { + value, s.top = s.top.value, s.top.next + s.size-- + return + } + return nil +} diff --git a/vendor/github.com/authzed/spicedb/pkg/schemadsl/parser/parser.go b/vendor/github.com/authzed/spicedb/pkg/schemadsl/parser/parser.go new file mode 100644 index 0000000..100ad9b --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/schemadsl/parser/parser.go @@ -0,0 +1,658 @@ +// parser package defines the parser for the Authzed Schema DSL. +package parser + +import ( + "strings" + + "golang.org/x/exp/maps" + + "github.com/authzed/spicedb/pkg/schemadsl/dslshape" + "github.com/authzed/spicedb/pkg/schemadsl/input" + "github.com/authzed/spicedb/pkg/schemadsl/lexer" +) + +// Parse parses the given Schema DSL source into a parse tree. +func Parse(builder NodeBuilder, source input.Source, input string) AstNode { + lx := lexer.Lex(source, input) + parser := buildParser(lx, builder, source, input) + defer parser.close() + return parser.consumeTopLevel() +} + +// ignoredTokenTypes are those tokens ignored when parsing. +var ignoredTokenTypes = map[lexer.TokenType]bool{ + lexer.TokenTypeWhitespace: true, + lexer.TokenTypeNewline: true, + lexer.TokenTypeSinglelineComment: true, + lexer.TokenTypeMultilineComment: true, +} + +// consumeTopLevel attempts to consume the top-level definitions. +func (p *sourceParser) consumeTopLevel() AstNode { + rootNode := p.startNode(dslshape.NodeTypeFile) + defer p.mustFinishNode() + + // Start at the first token. + p.consumeToken() + + if p.currentToken.Kind == lexer.TokenTypeError { + p.emitErrorf("%s", p.currentToken.Value) + return rootNode + } + + hasSeenDefinition := false + +Loop: + for { + if p.isToken(lexer.TokenTypeEOF) { + break Loop + } + + // Consume a statement terminator if one was found. + p.tryConsumeStatementTerminator() + + if p.isToken(lexer.TokenTypeEOF) { + break Loop + } + + // The top level of the DSL is a set of definitions and caveats: + // definition foobar { ... } + // caveat somecaveat (...) { ... } + + switch { + case p.isIdentifier("use"): + rootNode.Connect(dslshape.NodePredicateChild, p.consumeUseFlag(hasSeenDefinition)) + + case p.isKeyword("definition"): + hasSeenDefinition = true + rootNode.Connect(dslshape.NodePredicateChild, p.consumeDefinition()) + + case p.isKeyword("caveat"): + hasSeenDefinition = true + rootNode.Connect(dslshape.NodePredicateChild, p.consumeCaveat()) + + default: + p.emitErrorf("Unexpected token at root level: %v", p.currentToken.Kind) + break Loop + } + } + + return rootNode +} + +// consumeCaveat attempts to consume a single caveat definition. +// ```caveat somecaveat(param1 type, param2 type) { ... }``` +func (p *sourceParser) consumeCaveat() AstNode { + defNode := p.startNode(dslshape.NodeTypeCaveatDefinition) + defer p.mustFinishNode() + + // caveat ... + p.consumeKeyword("caveat") + caveatName, ok := p.consumeTypePath() + if !ok { + return defNode + } + + defNode.MustDecorate(dslshape.NodeCaveatDefinitionPredicateName, caveatName) + + // Parameters: + // ( + _, ok = p.consume(lexer.TokenTypeLeftParen) + if !ok { + return defNode + } + + for { + paramNode, ok := p.consumeCaveatParameter() + if !ok { + return defNode + } + + defNode.Connect(dslshape.NodeCaveatDefinitionPredicateParameters, paramNode) + if _, ok := p.tryConsume(lexer.TokenTypeComma); !ok { + break + } + } + + // ) + _, ok = p.consume(lexer.TokenTypeRightParen) + if !ok { + return defNode + } + + // { + _, ok = p.consume(lexer.TokenTypeLeftBrace) + if !ok { + return defNode + } + + exprNode, ok := p.consumeCaveatExpression() + if !ok { + return defNode + } + + defNode.Connect(dslshape.NodeCaveatDefinitionPredicateExpession, exprNode) + + // } + _, ok = p.consume(lexer.TokenTypeRightBrace) + if !ok { + return defNode + } + + return defNode +} + +func (p *sourceParser) consumeCaveatExpression() (AstNode, bool) { + exprNode := p.startNode(dslshape.NodeTypeCaveatExpression) + defer p.mustFinishNode() + + // Special Logic Note: Since CEL is its own language, we consume here until we have a matching + // close brace, and then pass ALL the found tokens to CEL's own parser to attach the expression + // here. + braceDepth := 1 // Starting at 1 from the open brace above + var startToken *commentedLexeme + var endToken *commentedLexeme +consumer: + for { + currentToken := p.currentToken + + switch currentToken.Kind { + case lexer.TokenTypeLeftBrace: + braceDepth++ + + case lexer.TokenTypeRightBrace: + if braceDepth == 1 { + break consumer + } + + braceDepth-- + + case lexer.TokenTypeError: + break consumer + + case lexer.TokenTypeEOF: + break consumer + } + + if startToken == nil { + startToken = ¤tToken + } + + endToken = ¤tToken + p.consumeToken() + } + + if startToken == nil { + p.emitErrorf("missing caveat expression") + return exprNode, false + } + + caveatExpression := p.input[startToken.Position : int(endToken.Position)+len(endToken.Value)] + exprNode.MustDecorate(dslshape.NodeCaveatExpressionPredicateExpression, caveatExpression) + return exprNode, true +} + +// consumeCaveatParameter attempts to consume a caveat parameter. +// ```(paramName paramtype)``` +func (p *sourceParser) consumeCaveatParameter() (AstNode, bool) { + paramNode := p.startNode(dslshape.NodeTypeCaveatParameter) + defer p.mustFinishNode() + + name, ok := p.consumeIdentifier() + if !ok { + return paramNode, false + } + + paramNode.MustDecorate(dslshape.NodeCaveatParameterPredicateName, name) + paramNode.Connect(dslshape.NodeCaveatParameterPredicateType, p.consumeCaveatTypeReference()) + return paramNode, true +} + +// consumeCaveatTypeReference attempts to consume a caveat type reference. +// ```typeName<childType>``` +func (p *sourceParser) consumeCaveatTypeReference() AstNode { + typeRefNode := p.startNode(dslshape.NodeTypeCaveatTypeReference) + defer p.mustFinishNode() + + name, ok := p.consumeIdentifier() + if !ok { + return typeRefNode + } + + typeRefNode.MustDecorate(dslshape.NodeCaveatTypeReferencePredicateType, name) + + // Check for child type(s). + // < + if _, ok := p.tryConsume(lexer.TokenTypeLessThan); !ok { + return typeRefNode + } + + for { + childTypeRef := p.consumeCaveatTypeReference() + typeRefNode.Connect(dslshape.NodeCaveatTypeReferencePredicateChildTypes, childTypeRef) + if _, ok := p.tryConsume(lexer.TokenTypeComma); !ok { + break + } + } + + // > + p.consume(lexer.TokenTypeGreaterThan) + return typeRefNode +} + +// consumeUseFlag attempts to consume a use flag. +// ``` use flagname ``` +func (p *sourceParser) consumeUseFlag(afterDefinition bool) AstNode { + useNode := p.startNode(dslshape.NodeTypeUseFlag) + defer p.mustFinishNode() + + // consume the `use` + p.consumeIdentifier() + + var useFlag string + if p.isToken(lexer.TokenTypeIdentifier) { + useFlag, _ = p.consumeIdentifier() + } else { + useName, ok := p.consumeVariableKeyword() + if !ok { + return useNode + } + useFlag = useName + } + + if _, ok := lexer.Flags[useFlag]; !ok { + p.emitErrorf("Unknown use flag: `%s`. Options are: %s", useFlag, strings.Join(maps.Keys(lexer.Flags), ", ")) + return useNode + } + + useNode.MustDecorate(dslshape.NodeUseFlagPredicateName, useFlag) + + // NOTE: we conduct this check in `consumeFlag` rather than at + // the callsite to keep the callsite clean. + // We also do the check after consumption to ensure that the parser continues + // moving past the use expression. + if afterDefinition { + p.emitErrorf("`use` expressions must be declared before any definition") + return useNode + } + + return useNode +} + +// consumeDefinition attempts to consume a single schema definition. +// ```definition somedef { ... }``` +func (p *sourceParser) consumeDefinition() AstNode { + defNode := p.startNode(dslshape.NodeTypeDefinition) + defer p.mustFinishNode() + + // definition ... + p.consumeKeyword("definition") + definitionName, ok := p.consumeTypePath() + if !ok { + return defNode + } + + defNode.MustDecorate(dslshape.NodeDefinitionPredicateName, definitionName) + + // { + _, ok = p.consume(lexer.TokenTypeLeftBrace) + if !ok { + return defNode + } + + // Relations and permissions. + for { + // } + if _, ok := p.tryConsume(lexer.TokenTypeRightBrace); ok { + break + } + + // relation ... + // permission ... + switch { + case p.isKeyword("relation"): + defNode.Connect(dslshape.NodePredicateChild, p.consumeRelation()) + + case p.isKeyword("permission"): + defNode.Connect(dslshape.NodePredicateChild, p.consumePermission()) + } + + ok := p.consumeStatementTerminator() + if !ok { + break + } + } + + return defNode +} + +// consumeRelation consumes a relation. +// ```relation foo: sometype``` +func (p *sourceParser) consumeRelation() AstNode { + relNode := p.startNode(dslshape.NodeTypeRelation) + defer p.mustFinishNode() + + // relation ... + p.consumeKeyword("relation") + relationName, ok := p.consumeIdentifier() + if !ok { + return relNode + } + + relNode.MustDecorate(dslshape.NodePredicateName, relationName) + + // : + _, ok = p.consume(lexer.TokenTypeColon) + if !ok { + return relNode + } + + // Relation allowed type(s). + relNode.Connect(dslshape.NodeRelationPredicateAllowedTypes, p.consumeTypeReference()) + + return relNode +} + +// consumeTypeReference consumes a reference to a type or types of relations. +// ```sometype | anothertype | anothertype:* ``` +func (p *sourceParser) consumeTypeReference() AstNode { + refNode := p.startNode(dslshape.NodeTypeTypeReference) + defer p.mustFinishNode() + + for { + refNode.Connect(dslshape.NodeTypeReferencePredicateType, p.consumeSpecificTypeWithCaveat()) + if _, ok := p.tryConsume(lexer.TokenTypePipe); !ok { + break + } + } + + return refNode +} + +// tryConsumeWithCaveat tries to consume a caveat `with` expression. +func (p *sourceParser) tryConsumeWithCaveat() (AstNode, bool) { + caveatNode := p.startNode(dslshape.NodeTypeCaveatReference) + defer p.mustFinishNode() + + consumed, ok := p.consumeTypePath() + if !ok { + return caveatNode, true + } + + caveatNode.MustDecorate(dslshape.NodeCaveatPredicateCaveat, consumed) + return caveatNode, true +} + +// consumeSpecificTypeWithCaveat consumes an identifier as a specific type reference, with optional caveat. +func (p *sourceParser) consumeSpecificTypeWithCaveat() AstNode { + specificNode := p.consumeSpecificTypeWithoutFinish() + defer p.mustFinishNode() + + // Check for a caveat and/or supported trait. + if !p.isKeyword("with") { + return specificNode + } + + p.consumeKeyword("with") + + if !p.isKeyword("expiration") { + caveatNode, ok := p.tryConsumeWithCaveat() + if ok { + specificNode.Connect(dslshape.NodeSpecificReferencePredicateCaveat, caveatNode) + } + + if !p.tryConsumeKeyword("and") { + return specificNode + } + } + + if p.isKeyword("expiration") { + // Check for expiration trait. + traitNode := p.consumeExpirationTrait() + + // Decorate with the expiration trait. + specificNode.Connect(dslshape.NodeSpecificReferencePredicateTrait, traitNode) + } + + return specificNode +} + +// consumeExpirationTrait consumes an expiration trait. +func (p *sourceParser) consumeExpirationTrait() AstNode { + expirationTraitNode := p.startNode(dslshape.NodeTypeTraitReference) + p.consumeKeyword("expiration") + + expirationTraitNode.MustDecorate(dslshape.NodeTraitPredicateTrait, "expiration") + defer p.mustFinishNode() + + return expirationTraitNode +} + +// consumeSpecificTypeOpen consumes an identifier as a specific type reference. +func (p *sourceParser) consumeSpecificTypeWithoutFinish() AstNode { + specificNode := p.startNode(dslshape.NodeTypeSpecificTypeReference) + + typeName, ok := p.consumeTypePath() + if !ok { + return specificNode + } + + specificNode.MustDecorate(dslshape.NodeSpecificReferencePredicateType, typeName) + + // Check for a wildcard + if _, ok := p.tryConsume(lexer.TokenTypeColon); ok { + _, ok := p.consume(lexer.TokenTypeStar) + if !ok { + return specificNode + } + + specificNode.MustDecorate(dslshape.NodeSpecificReferencePredicateWildcard, "true") + return specificNode + } + + // Check for a relation specified. + if _, ok := p.tryConsume(lexer.TokenTypeHash); !ok { + return specificNode + } + + // Consume an identifier or an ellipsis. + consumed, ok := p.consume(lexer.TokenTypeIdentifier, lexer.TokenTypeEllipsis) + if !ok { + return specificNode + } + + specificNode.MustDecorate(dslshape.NodeSpecificReferencePredicateRelation, consumed.Value) + return specificNode +} + +func (p *sourceParser) consumeTypePath() (string, bool) { + var segments []string + + for { + segment, ok := p.consumeIdentifier() + if !ok { + return "", false + } + + segments = append(segments, segment) + + _, ok = p.tryConsume(lexer.TokenTypeDiv) + if !ok { + break + } + } + + return strings.Join(segments, "/"), true +} + +// consumePermission consumes a permission. +// ```permission foo = bar + baz``` +func (p *sourceParser) consumePermission() AstNode { + permNode := p.startNode(dslshape.NodeTypePermission) + defer p.mustFinishNode() + + // permission ... + p.consumeKeyword("permission") + permissionName, ok := p.consumeIdentifier() + if !ok { + return permNode + } + + permNode.MustDecorate(dslshape.NodePredicateName, permissionName) + + // = + _, ok = p.consume(lexer.TokenTypeEquals) + if !ok { + return permNode + } + + permNode.Connect(dslshape.NodePermissionPredicateComputeExpression, p.consumeComputeExpression()) + return permNode +} + +// ComputeExpressionOperators defines the binary operators in precedence order. +var ComputeExpressionOperators = []binaryOpDefinition{ + {lexer.TokenTypeMinus, dslshape.NodeTypeExclusionExpression}, + {lexer.TokenTypeAnd, dslshape.NodeTypeIntersectExpression}, + {lexer.TokenTypePlus, dslshape.NodeTypeUnionExpression}, +} + +// consumeComputeExpression consumes an expression for computing a permission. +func (p *sourceParser) consumeComputeExpression() AstNode { + // Compute expressions consist of a set of binary operators, so build a tree with proper + // precedence. + binaryParser := p.buildBinaryOperatorExpressionFnTree(ComputeExpressionOperators) + found, ok := binaryParser() + if !ok { + return p.createErrorNodef("Expected compute expression for permission") + } + return found +} + +// tryConsumeComputeExpression attempts to consume a nested compute expression. +func (p *sourceParser) tryConsumeComputeExpression(subTryExprFn tryParserFn, binaryTokenType lexer.TokenType, nodeType dslshape.NodeType) (AstNode, bool) { + rightNodeBuilder := func(leftNode AstNode, operatorToken lexer.Lexeme) (AstNode, bool) { + rightNode, ok := subTryExprFn() + if !ok { + return nil, false + } + + // Create the expression node representing the binary expression. + exprNode := p.createNode(nodeType) + exprNode.Connect(dslshape.NodeExpressionPredicateLeftExpr, leftNode) + exprNode.Connect(dslshape.NodeExpressionPredicateRightExpr, rightNode) + return exprNode, true + } + return p.performLeftRecursiveParsing(subTryExprFn, rightNodeBuilder, nil, binaryTokenType) +} + +// tryConsumeArrowExpression attempts to consume an arrow expression. +// ```foo->bar->baz->meh``` +func (p *sourceParser) tryConsumeArrowExpression() (AstNode, bool) { + rightNodeBuilder := func(leftNode AstNode, operatorToken lexer.Lexeme) (AstNode, bool) { + // Check for an arrow function. + if operatorToken.Kind == lexer.TokenTypePeriod { + functionName, ok := p.consumeIdentifier() + if !ok { + return nil, false + } + + // TODO(jschorr): Change to keywords in schema v2. + if functionName != "any" && functionName != "all" { + p.emitErrorf("Expected 'any' or 'all' for arrow function, found: %s", functionName) + return nil, false + } + + if _, ok := p.consume(lexer.TokenTypeLeftParen); !ok { + return nil, false + } + + rightNode, ok := p.tryConsumeIdentifierLiteral() + if !ok { + return nil, false + } + + if _, ok := p.consume(lexer.TokenTypeRightParen); !ok { + return nil, false + } + + exprNode := p.createNode(dslshape.NodeTypeArrowExpression) + exprNode.Connect(dslshape.NodeExpressionPredicateLeftExpr, leftNode) + exprNode.Connect(dslshape.NodeExpressionPredicateRightExpr, rightNode) + exprNode.MustDecorate(dslshape.NodeArrowExpressionFunctionName, functionName) + return exprNode, true + } + + rightNode, ok := p.tryConsumeIdentifierLiteral() + if !ok { + return nil, false + } + + // Create the expression node representing the binary expression. + exprNode := p.createNode(dslshape.NodeTypeArrowExpression) + exprNode.Connect(dslshape.NodeExpressionPredicateLeftExpr, leftNode) + exprNode.Connect(dslshape.NodeExpressionPredicateRightExpr, rightNode) + return exprNode, true + } + return p.performLeftRecursiveParsing(p.tryConsumeIdentifierLiteral, rightNodeBuilder, nil, lexer.TokenTypeRightArrow, lexer.TokenTypePeriod) +} + +// tryConsumeBaseExpression attempts to consume base compute expressions (identifiers, parenthesis). +// ```(foo + bar)``` +// ```(foo)``` +// ```foo``` +// ```nil``` +func (p *sourceParser) tryConsumeBaseExpression() (AstNode, bool) { + switch { + // Nested expression. + case p.isToken(lexer.TokenTypeLeftParen): + comments := p.currentToken.comments + + p.consume(lexer.TokenTypeLeftParen) + exprNode := p.consumeComputeExpression() + p.consume(lexer.TokenTypeRightParen) + + // Attach any comments found to the consumed expression. + p.decorateComments(exprNode, comments) + + return exprNode, true + + // Nil expression. + case p.isKeyword("nil"): + return p.tryConsumeNilExpression() + + // Identifier. + case p.isToken(lexer.TokenTypeIdentifier): + return p.tryConsumeIdentifierLiteral() + } + + return nil, false +} + +// tryConsumeIdentifierLiteral attempts to consume an identifier as a literal +// expression. +// +// ```foo``` +func (p *sourceParser) tryConsumeIdentifierLiteral() (AstNode, bool) { + if !p.isToken(lexer.TokenTypeIdentifier) { + return nil, false + } + + identNode := p.startNode(dslshape.NodeTypeIdentifier) + defer p.mustFinishNode() + + identifier, _ := p.consumeIdentifier() + identNode.MustDecorate(dslshape.NodeIdentiferPredicateValue, identifier) + return identNode, true +} + +func (p *sourceParser) tryConsumeNilExpression() (AstNode, bool) { + if !p.isKeyword("nil") { + return nil, false + } + + node := p.startNode(dslshape.NodeTypeNilExpression) + p.consumeKeyword("nil") + defer p.mustFinishNode() + return node, true +} diff --git a/vendor/github.com/authzed/spicedb/pkg/schemadsl/parser/parser_impl.go b/vendor/github.com/authzed/spicedb/pkg/schemadsl/parser/parser_impl.go new file mode 100644 index 0000000..1009b6b --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/schemadsl/parser/parser_impl.go @@ -0,0 +1,367 @@ +package parser + +import ( + "fmt" + + "github.com/authzed/spicedb/pkg/schemadsl/dslshape" + "github.com/authzed/spicedb/pkg/schemadsl/input" + "github.com/authzed/spicedb/pkg/schemadsl/lexer" +) + +// AstNode defines an interface for working with nodes created by this parser. +type AstNode interface { + // Connect connects this AstNode to another AstNode with the given predicate. + Connect(predicate string, other AstNode) + + // MustDecorate decorates this AstNode with the given property and string value, returning + // the same node. + MustDecorate(property string, value string) AstNode + + // MustDecorateWithInt decorates this AstNode with the given property and int value, returning + // the same node. + MustDecorateWithInt(property string, value int) AstNode +} + +// NodeBuilder is a function for building AST nodes. +type NodeBuilder func(source input.Source, kind dslshape.NodeType) AstNode + +// tryParserFn is a function that attempts to build an AST node. +type tryParserFn func() (AstNode, bool) + +// lookaheadParserFn is a function that performs lookahead. +type lookaheadParserFn func(currentToken lexer.Lexeme) bool + +// rightNodeConstructor is a function which takes in a left expr node and the +// token consumed for a left-recursive operator, and returns a newly constructed +// operator expression if a right expression could be found. +type rightNodeConstructor func(AstNode, lexer.Lexeme) (AstNode, bool) + +// commentedLexeme is a lexer.Lexeme with comments attached. +type commentedLexeme struct { + lexer.Lexeme + comments []string +} + +// sourceParser holds the state of the parser. +type sourceParser struct { + source input.Source // the name of the input; used only for error reports + input string // the input string itself + lex *lexer.FlaggableLexer // a reference to the lexer used for tokenization + builder NodeBuilder // the builder function for creating AstNode instances + nodes *nodeStack // the stack of the current nodes + currentToken commentedLexeme // the current token + previousToken commentedLexeme // the previous token +} + +// buildParser returns a new sourceParser instance. +func buildParser(lx *lexer.Lexer, builder NodeBuilder, source input.Source, input string) *sourceParser { + l := lexer.NewFlaggableLexer(lx) + return &sourceParser{ + source: source, + input: input, + lex: l, + builder: builder, + nodes: &nodeStack{}, + currentToken: commentedLexeme{lexer.Lexeme{Kind: lexer.TokenTypeEOF}, make([]string, 0)}, + previousToken: commentedLexeme{lexer.Lexeme{Kind: lexer.TokenTypeEOF}, make([]string, 0)}, + } +} + +func (p *sourceParser) close() { + p.lex.Close() +} + +// createNode creates a new AstNode and returns it. +func (p *sourceParser) createNode(kind dslshape.NodeType) AstNode { + return p.builder(p.source, kind) +} + +// createErrorNodef creates a new error node and returns it. +func (p *sourceParser) createErrorNodef(format string, args ...interface{}) AstNode { + message := fmt.Sprintf(format, args...) + node := p.startNode(dslshape.NodeTypeError).MustDecorate(dslshape.NodePredicateErrorMessage, message) + p.mustFinishNode() + return node +} + +// startNode creates a new node of the given type, decorates it with the current token's +// position as its start position, and pushes it onto the nodes stack. +func (p *sourceParser) startNode(kind dslshape.NodeType) AstNode { + node := p.createNode(kind) + p.decorateStartRuneAndComments(node, p.currentToken) + p.nodes.push(node) + return node +} + +// decorateStartRuneAndComments decorates the given node with the location of the given token as its +// starting rune, as well as any comments attached to the token. +func (p *sourceParser) decorateStartRuneAndComments(node AstNode, token commentedLexeme) { + node.MustDecorate(dslshape.NodePredicateSource, string(p.source)) + node.MustDecorateWithInt(dslshape.NodePredicateStartRune, int(token.Position)) + p.decorateComments(node, token.comments) +} + +// decorateComments decorates the given node with the specified comments. +func (p *sourceParser) decorateComments(node AstNode, comments []string) { + for _, comment := range comments { + commentNode := p.createNode(dslshape.NodeTypeComment) + commentNode.MustDecorate(dslshape.NodeCommentPredicateValue, comment) + node.Connect(dslshape.NodePredicateChild, commentNode) + } +} + +// decorateEndRune decorates the given node with the location of the given token as its +// ending rune. +func (p *sourceParser) decorateEndRune(node AstNode, token commentedLexeme) { + position := int(token.Position) + len(token.Value) - 1 + node.MustDecorateWithInt(dslshape.NodePredicateEndRune, position) +} + +// currentNode returns the node at the top of the stack. +func (p *sourceParser) currentNode() AstNode { + return p.nodes.topValue() +} + +// mustFinishNode pops the current node from the top of the stack and decorates it with +// the current token's end position as its end position. +func (p *sourceParser) mustFinishNode() { + if p.currentNode() == nil { + panic(fmt.Sprintf("No current node on stack. Token: %s", p.currentToken.Value)) + } + + p.decorateEndRune(p.currentNode(), p.previousToken) + p.nodes.pop() +} + +// consumeToken advances the lexer forward, returning the next token. +func (p *sourceParser) consumeToken() commentedLexeme { + comments := make([]string, 0) + + for { + token := p.lex.NextToken() + + if token.Kind == lexer.TokenTypeSinglelineComment || token.Kind == lexer.TokenTypeMultilineComment { + comments = append(comments, token.Value) + } + + if _, ok := ignoredTokenTypes[token.Kind]; !ok { + p.previousToken = p.currentToken + p.currentToken = commentedLexeme{token, comments} + return p.currentToken + } + } +} + +// isToken returns true if the current token matches one of the types given. +func (p *sourceParser) isToken(types ...lexer.TokenType) bool { + for _, kind := range types { + if p.currentToken.Kind == kind { + return true + } + } + + return false +} + +// isIdentifier returns true if the current token is an identifier matching that given. +func (p *sourceParser) isIdentifier(identifier string) bool { + return p.isToken(lexer.TokenTypeIdentifier) && p.currentToken.Value == identifier +} + +// isKeyword returns true if the current token is a keyword matching that given. +func (p *sourceParser) isKeyword(keyword string) bool { + return p.isToken(lexer.TokenTypeKeyword) && p.currentToken.Value == keyword +} + +// emitErrorf creates a new error node and attachs it as a child of the current +// node. +func (p *sourceParser) emitErrorf(format string, args ...interface{}) { + errorNode := p.createErrorNodef(format, args...) + if len(p.currentToken.Value) > 0 { + errorNode.MustDecorate(dslshape.NodePredicateErrorSource, p.currentToken.Value) + } + p.currentNode().Connect(dslshape.NodePredicateChild, errorNode) +} + +// consumeVariableKeyword consumes an expected keyword token or adds an error node. +func (p *sourceParser) consumeVariableKeyword() (string, bool) { + if !p.isToken(lexer.TokenTypeKeyword) { + p.emitErrorf("Expected keyword, found token %v", p.currentToken.Kind) + return "", false + } + + token := p.currentToken + p.consumeToken() + return token.Value, true +} + +// consumeKeyword consumes an expected keyword token or adds an error node. +func (p *sourceParser) consumeKeyword(keyword string) bool { + if !p.tryConsumeKeyword(keyword) { + p.emitErrorf("Expected keyword %s, found token %v", keyword, p.currentToken.Kind) + return false + } + return true +} + +// tryConsumeKeyword attempts to consume an expected keyword token. +func (p *sourceParser) tryConsumeKeyword(keyword string) bool { + if !p.isKeyword(keyword) { + return false + } + + p.consumeToken() + return true +} + +// cosumeIdentifier consumes an expected identifier token or adds an error node. +func (p *sourceParser) consumeIdentifier() (string, bool) { + token, ok := p.tryConsume(lexer.TokenTypeIdentifier) + if !ok { + p.emitErrorf("Expected identifier, found token %v", p.currentToken.Kind) + return "", false + } + return token.Value, true +} + +// consume performs consumption of the next token if it matches any of the given +// types and returns it. If no matching type is found, adds an error node. +func (p *sourceParser) consume(types ...lexer.TokenType) (lexer.Lexeme, bool) { + token, ok := p.tryConsume(types...) + if !ok { + p.emitErrorf("Expected one of: %v, found: %v", types, p.currentToken.Kind) + } + return token, ok +} + +// tryConsume performs consumption of the next token if it matches any of the given +// types and returns it. +func (p *sourceParser) tryConsume(types ...lexer.TokenType) (lexer.Lexeme, bool) { + token, found := p.tryConsumeWithComments(types...) + return token.Lexeme, found +} + +// tryConsume performs consumption of the next token if it matches any of the given +// types and returns it. +func (p *sourceParser) tryConsumeWithComments(types ...lexer.TokenType) (commentedLexeme, bool) { + if p.isToken(types...) { + token := p.currentToken + p.consumeToken() + return token, true + } + + return commentedLexeme{lexer.Lexeme{ + Kind: lexer.TokenTypeError, + }, make([]string, 0)}, false +} + +// performLeftRecursiveParsing performs left-recursive parsing of a set of operators. This method +// first performs the parsing via the subTryExprFn and then checks for one of the left-recursive +// operator token types found. If none found, the left expression is returned. Otherwise, the +// rightNodeBuilder is called to attempt to construct an operator expression. This method also +// properly handles decoration of the nodes with their proper start and end run locations and +// comments. +func (p *sourceParser) performLeftRecursiveParsing(subTryExprFn tryParserFn, rightNodeBuilder rightNodeConstructor, rightTokenTester lookaheadParserFn, operatorTokens ...lexer.TokenType) (AstNode, bool) { + leftMostToken := p.currentToken + + // Consume the left side of the expression. + leftNode, ok := subTryExprFn() + if !ok { + return nil, false + } + + // Check for an operator token. If none found, then we've found just the left side of the + // expression and so we return that node. + if !p.isToken(operatorTokens...) { + return leftNode, true + } + + // Keep consuming pairs of operators and child expressions until such + // time as no more can be consumed. We use this loop+custom build rather than recursion + // because these operators are *left* recursive, not right. + var currentLeftNode AstNode + currentLeftNode = leftNode + + for { + // Check for an operator. + if !p.isToken(operatorTokens...) { + break + } + + // If a lookahead function is defined, check the lookahead for the matched token. + if rightTokenTester != nil && !rightTokenTester(p.currentToken.Lexeme) { + break + } + + // Consume the operator. + operatorToken, ok := p.tryConsumeWithComments(operatorTokens...) + if !ok { + break + } + + // Consume the right hand expression and build an expression node (if applicable). + exprNode, ok := rightNodeBuilder(currentLeftNode, operatorToken.Lexeme) + if !ok { + p.emitErrorf("Expected right hand expression, found: %v", p.currentToken.Kind) + return currentLeftNode, true + } + + p.decorateStartRuneAndComments(exprNode, leftMostToken) + p.decorateEndRune(exprNode, p.previousToken) + + currentLeftNode = exprNode + } + + return currentLeftNode, true +} + +// tryConsumeStatementTerminator tries to consume a statement terminator. +func (p *sourceParser) tryConsumeStatementTerminator() (lexer.Lexeme, bool) { + return p.tryConsume(lexer.TokenTypeSyntheticSemicolon, lexer.TokenTypeSemicolon, lexer.TokenTypeEOF) +} + +// consumeStatementTerminator consume a statement terminator. +func (p *sourceParser) consumeStatementTerminator() bool { + _, ok := p.tryConsumeStatementTerminator() + if ok { + return true + } + + p.emitErrorf("Expected end of statement or definition, found: %s", p.currentToken.Kind) + return false +} + +// binaryOpDefinition represents information a binary operator token and its associated node type. +type binaryOpDefinition struct { + // The token representing the binary expression's operator. + BinaryOperatorToken lexer.TokenType + + // The type of node to create for this expression. + BinaryExpressionNodeType dslshape.NodeType +} + +// buildBinaryOperatorExpressionFnTree builds a tree of functions to try to consume a set of binary +// operator expressions. +func (p *sourceParser) buildBinaryOperatorExpressionFnTree(ops []binaryOpDefinition) tryParserFn { + // Start with a base expression function. + var currentParseFn tryParserFn + currentParseFn = func() (AstNode, bool) { + arrowExpr, ok := p.tryConsumeArrowExpression() + if !ok { + return p.tryConsumeBaseExpression() + } + + return arrowExpr, true + } + + for i := range ops { + // Note: We have to reverse this to ensure we have proper precedence. + currentParseFn = func(operatorInfo binaryOpDefinition, currentFn tryParserFn) tryParserFn { + return (func() (AstNode, bool) { + return p.tryConsumeComputeExpression(currentFn, operatorInfo.BinaryOperatorToken, operatorInfo.BinaryExpressionNodeType) + }) + }(ops[len(ops)-i-1], currentParseFn) + } + + return currentParseFn +} diff --git a/vendor/github.com/authzed/spicedb/pkg/spiceerrors/assert_off.go b/vendor/github.com/authzed/spicedb/pkg/spiceerrors/assert_off.go new file mode 100644 index 0000000..20ac7ef --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/spiceerrors/assert_off.go @@ -0,0 +1,21 @@ +//go:build !ci +// +build !ci + +package spiceerrors + +const DebugAssertionsEnabled = false + +// DebugAssert is a no-op in non-CI builds +func DebugAssert(condition func() bool, format string, args ...any) { + // Do nothing on purpose +} + +// DebugAssertNotNil is a no-op in non-CI builds +func DebugAssertNotNil(obj any, format string, args ...any) { + // Do nothing on purpose +} + +// SetFinalizerForDebugging is a no-op in non-CI builds +func SetFinalizerForDebugging[T any](obj interface{}, finalizer func(obj T)) { + // Do nothing on purpose +} diff --git a/vendor/github.com/authzed/spicedb/pkg/spiceerrors/assert_on.go b/vendor/github.com/authzed/spicedb/pkg/spiceerrors/assert_on.go new file mode 100644 index 0000000..a214147 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/spiceerrors/assert_on.go @@ -0,0 +1,31 @@ +//go:build ci +// +build ci + +package spiceerrors + +import ( + "fmt" + "runtime" +) + +const DebugAssertionsEnabled = true + +// DebugAssert panics if the condition is false in CI builds. +func DebugAssert(condition func() bool, format string, args ...any) { + if !condition() { + panic(fmt.Sprintf(format, args...)) + } +} + +// DebugAssertNotNil panics if the object is nil in CI builds. +func DebugAssertNotNil(obj any, format string, args ...any) { + if obj == nil { + panic(fmt.Sprintf(format, args...)) + } +} + +// SetFinalizerForDebugging sets a finalizer on the object for debugging purposes +// in CI builds. +func SetFinalizerForDebugging[T any](obj interface{}, finalizer func(obj T)) { + runtime.SetFinalizer(obj, finalizer) +} diff --git a/vendor/github.com/authzed/spicedb/pkg/spiceerrors/bug.go b/vendor/github.com/authzed/spicedb/pkg/spiceerrors/bug.go new file mode 100644 index 0000000..7680c33 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/spiceerrors/bug.go @@ -0,0 +1,35 @@ +package spiceerrors + +import ( + "fmt" + "os" + "strings" + + "github.com/go-errors/errors" +) + +// IsInTests returns true if go test is running +// Based on: https://stackoverflow.com/a/58945030 +func IsInTests() bool { + for _, arg := range os.Args { + if strings.HasPrefix(arg, "-test.") { + return true + } + } + return false +} + +// MustPanic is a special function for panicing when necessary to violate the linter. +func MustPanic(format string, args ...any) { + panic(fmt.Sprintf(format, args...)) +} + +// MustBugf returns an error representing a bug in the system. Will panic if run under testing. +func MustBugf(format string, args ...any) error { + if IsInTests() { + panic(fmt.Sprintf(format, args...)) + } + + e := errors.Errorf(format, args...) + return fmt.Errorf("BUG: %s", e.ErrorStack()) +} diff --git a/vendor/github.com/authzed/spicedb/pkg/spiceerrors/common.go b/vendor/github.com/authzed/spicedb/pkg/spiceerrors/common.go new file mode 100644 index 0000000..625faef --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/spiceerrors/common.go @@ -0,0 +1,88 @@ +package spiceerrors + +import ( + "errors" + "maps" +) + +// SourcePosition is a position in the input source. +type SourcePosition struct { + // LineNumber is the 1-indexed line number in the input source. + LineNumber int + + // ColumnPosition is the 1-indexed column position in the input source. + ColumnPosition int +} + +// WithSourceError is an error that includes the source text and position +// information. +type WithSourceError struct { + error + + // SourceCodeString is the input source code string for the error. + SourceCodeString string + + // LineNumber is the (1-indexed) line number of the error, or 0 if unknown. + LineNumber uint64 + + // ColumnPosition is the (1-indexed) column position of the error, or 0 if + // unknown. + ColumnPosition uint64 +} + +// HasMetadata indicates that the error has metadata defined. +type HasMetadata interface { + // DetailsMetadata returns the metadata for details for this error. + DetailsMetadata() map[string]string +} + +// Unwrap returns the inner, wrapped error. +func (err *WithSourceError) Unwrap() error { + return err.error +} + +// NewWithSourceError creates and returns a new WithSourceError. +func NewWithSourceError(err error, sourceCodeString string, oneIndexedLineNumber uint64, oneIndexedColumnPosition uint64) *WithSourceError { + return &WithSourceError{err, sourceCodeString, oneIndexedLineNumber, oneIndexedColumnPosition} +} + +// AsWithSourceError returns the error as an WithSourceError, if applicable. +func AsWithSourceError(err error) (*WithSourceError, bool) { + var serr *WithSourceError + if errors.As(err, &serr) { + return serr, true + } + return nil, false +} + +// WithAdditionalDetailsError is an error that includes additional details. +type WithAdditionalDetailsError struct { + error + + // AdditionalDetails is a map of additional details for the error. + AdditionalDetails map[string]string +} + +func NewWithAdditionalDetailsError(err error) *WithAdditionalDetailsError { + return &WithAdditionalDetailsError{err, nil} +} + +// Unwrap returns the inner, wrapped error. +func (err *WithAdditionalDetailsError) Unwrap() error { + return err.error +} + +func (err *WithAdditionalDetailsError) WithAdditionalDetails(key string, value string) { + if err.AdditionalDetails == nil { + err.AdditionalDetails = make(map[string]string) + } + err.AdditionalDetails[key] = value +} + +func (err *WithAdditionalDetailsError) AddToDetails(details map[string]string) map[string]string { + if err.AdditionalDetails != nil { + maps.Copy(details, err.AdditionalDetails) + } + + return details +} diff --git a/vendor/github.com/authzed/spicedb/pkg/spiceerrors/details_metadata.go b/vendor/github.com/authzed/spicedb/pkg/spiceerrors/details_metadata.go new file mode 100644 index 0000000..20d7795 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/spiceerrors/details_metadata.go @@ -0,0 +1,112 @@ +package spiceerrors + +import ( + "fmt" + + "google.golang.org/genproto/googleapis/rpc/errdetails" + "google.golang.org/grpc/status" + "google.golang.org/protobuf/runtime/protoiface" +) + +// MetadataKey is the type used to represent the keys of the metadata map in +// the error details. +type MetadataKey string + +// DebugTraceErrorDetailsKey is the key used to store the debug trace in the error details. +// The value is expected to be a string containing the proto text of a DebugInformation message. +const DebugTraceErrorDetailsKey MetadataKey = "debug_trace_proto_text" + +// AppendDetailsMetadata appends the key-value pair to the error details metadata. +// If the error is nil or is not a status error, it is returned as is. +func AppendDetailsMetadata(err error, key MetadataKey, value string) error { + if err == nil { + return nil + } + + s, ok := status.FromError(err) + if !ok { + return err + } + + var foundErrDetails *errdetails.ErrorInfo + var otherDetails []protoiface.MessageV1 + for _, details := range s.Details() { + if errInfo, ok := details.(*errdetails.ErrorInfo); ok { + foundErrDetails = errInfo + } else if cast, ok := details.(protoiface.MessageV1); ok { + otherDetails = append(otherDetails, cast) + } + } + + if foundErrDetails != nil { + if foundErrDetails.Metadata == nil { + foundErrDetails.Metadata = make(map[string]string, 1) + } + + foundErrDetails.Metadata[string(key)] = value + } + + return WithCodeAndDetailsAsError( + fmt.Errorf("%s", s.Message()), + s.Code(), + append(otherDetails, foundErrDetails)..., + ) +} + +// WithReplacedDetails replaces the details of the error with the provided details. +// If the error is nil or is not a status error, it is returned as is. +// If the error does not have the details to replace, the provided details are appended. +func WithReplacedDetails[T protoiface.MessageV1](err error, toReplace T) error { + if err == nil { + return nil + } + + s, ok := status.FromError(err) + if !ok { + return err + } + + details := make([]protoiface.MessageV1, 0, len(s.Details())) + wasReplaced := false + for _, current := range s.Details() { + if _, ok := current.(T); ok { + details = append(details, toReplace) + wasReplaced = true + continue + } + + if cast, ok := current.(protoiface.MessageV1); ok { + details = append(details, cast) + } + } + + if !wasReplaced { + details = append(details, toReplace) + } + + return WithCodeAndDetailsAsError( + fmt.Errorf("%s", s.Message()), + s.Code(), + details..., + ) +} + +// GetDetails returns the details of the error if they are of the provided type, if any. +func GetDetails[T protoiface.MessageV1](err error) (T, bool) { + if err == nil { + return *new(T), false + } + + s, ok := status.FromError(err) + if !ok { + return *new(T), false + } + + for _, details := range s.Details() { + if cast, ok := details.(T); ok { + return cast, true + } + } + + return *new(T), false +} diff --git a/vendor/github.com/authzed/spicedb/pkg/spiceerrors/termination.go b/vendor/github.com/authzed/spicedb/pkg/spiceerrors/termination.go new file mode 100644 index 0000000..58360eb --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/spiceerrors/termination.go @@ -0,0 +1,66 @@ +package spiceerrors + +import "time" + +// TerminationError represents an error that captures contextual information to make +// available on process termination. The error will be marshalled as JSON and +// serialized into a file-path specified via CLI arguments +type TerminationError struct { + error + Component string `json:"component"` + Timestamp time.Time `json:"timestamp"` + ErrorString string `json:"error"` + Metadata map[string]string `json:"metadata"` + exitCode int +} + +// ExitCode returns the exit code to be returned on process termination +func (e TerminationError) ExitCode() int { + return e.exitCode +} + +// ErrorBuilder is a fluent-style builder for TerminationError +type ErrorBuilder struct { + terminationErr TerminationError +} + +// TerminationError returns the built termination TerminationError +func (eb *ErrorBuilder) Error() TerminationError { + return eb.terminationErr +} + +// Component specifies the component in SpiceDB that +func (eb *ErrorBuilder) Component(component string) *ErrorBuilder { + eb.terminationErr.Component = component + return eb +} + +// Metadata adds a new key-value pair of metadata to the termination TerminationError being built +func (eb *ErrorBuilder) Metadata(key, value string) *ErrorBuilder { + eb.terminationErr.Metadata[key] = value + return eb +} + +// ExitCode defines the ExitCode to be used upon process termination. Defaults to 1 if not specified. +func (eb *ErrorBuilder) ExitCode(exitCode int) *ErrorBuilder { + eb.terminationErr.exitCode = exitCode + return eb +} + +// Timestamp defines the time of the error. Defaults to time.Now().UTC() if not specified. +func (eb *ErrorBuilder) Timestamp(timestamp time.Time) *ErrorBuilder { + eb.terminationErr.Timestamp = timestamp + return eb +} + +// NewTerminationErrorBuilder returns a new ErrorBuilder for a termination.TerminationError. +func NewTerminationErrorBuilder(err error) *ErrorBuilder { + return &ErrorBuilder{terminationErr: TerminationError{ + error: err, + Component: "unspecified", + Timestamp: time.Now().UTC(), + ErrorString: err.Error(), + Metadata: make(map[string]string, 0), + exitCode: 1, + }} +} diff --git a/vendor/github.com/authzed/spicedb/pkg/spiceerrors/testutil.go b/vendor/github.com/authzed/spicedb/pkg/spiceerrors/testutil.go new file mode 100644 index 0000000..db71540 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/spiceerrors/testutil.go @@ -0,0 +1,28 @@ +package spiceerrors + +import ( + "testing" + + "github.com/stretchr/testify/require" + "google.golang.org/genproto/googleapis/rpc/errdetails" + "google.golang.org/grpc/status" + + v1 "github.com/authzed/authzed-go/proto/authzed/api/v1" +) + +// RequireReason asserts that an error is a gRPC error and returns the expected +// reason in the ErrorInfo. +// TODO(jschorr): Move into grpcutil. +func RequireReason(t testing.TB, reason v1.ErrorReason, err error, expectedMetadataKeys ...string) { + require.Error(t, err) + withStatus, ok := status.FromError(err) + require.True(t, ok) + require.True(t, len(withStatus.Details()) > 0) + + info := withStatus.Details()[0].(*errdetails.ErrorInfo) + require.Equal(t, v1.ErrorReason_name[int32(reason)], info.GetReason()) + + for _, expectedKey := range expectedMetadataKeys { + require.Contains(t, info.Metadata, expectedKey) + } +} diff --git a/vendor/github.com/authzed/spicedb/pkg/spiceerrors/util.go b/vendor/github.com/authzed/spicedb/pkg/spiceerrors/util.go new file mode 100644 index 0000000..744e41b --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/spiceerrors/util.go @@ -0,0 +1,18 @@ +package spiceerrors + +import ( + "maps" +) + +type WithMetadata interface { + DetailsMetadata() map[string]string +} + +// CombineMetadata combines the metadata found on an existing error with that given. +func CombineMetadata(withMetadata WithMetadata, metadata map[string]string) map[string]string { + clone := maps.Clone(withMetadata.DetailsMetadata()) + for key, value := range metadata { + clone[key] = value + } + return clone +} diff --git a/vendor/github.com/authzed/spicedb/pkg/spiceerrors/withstatus.go b/vendor/github.com/authzed/spicedb/pkg/spiceerrors/withstatus.go new file mode 100644 index 0000000..1ee6e0a --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/spiceerrors/withstatus.go @@ -0,0 +1,82 @@ +package spiceerrors + +import ( + "errors" + + log "github.com/authzed/spicedb/internal/logging" + + "google.golang.org/genproto/googleapis/rpc/errdetails" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + "google.golang.org/protobuf/runtime/protoiface" + + v1 "github.com/authzed/authzed-go/proto/authzed/api/v1" +) + +// Domain is the domain used for all errors. +const Domain = "authzed.com" + +// WithCodeAndDetails returns a gRPC status message containing the error's message, the given +// status code and any supplied details. +func WithCodeAndDetails(err error, code codes.Code, details ...protoiface.MessageV1) *status.Status { + created := status.New(code, err.Error()) + created, derr := created.WithDetails(details...) + if derr != nil { + log.Err(derr).Str("provided-error", err.Error()).Msg("could not add details to provided error") + } + return created +} + +// WithCodeAndDetailsAsError returns an error containing the error's message, the given +// status code and any supplied details. +func WithCodeAndDetailsAsError(err error, code codes.Code, details ...protoiface.MessageV1) error { + status := WithCodeAndDetails(err, code, details...) + return withStatusError{err, status} +} + +// ForReason returns an ErrorInfo block for a specific error reason as defined in the V1 API. +func ForReason(reason v1.ErrorReason, metadata map[string]string) *errdetails.ErrorInfo { + return &errdetails.ErrorInfo{ + Reason: v1.ErrorReason_name[int32(reason)], + Domain: Domain, + Metadata: metadata, + } +} + +// WithCodeAndReason returns a new error which wraps the existing error with a gRPC code and +// a reason block. +func WithCodeAndReason(err error, code codes.Code, reason v1.ErrorReason) error { + metadata := map[string]string{} + + var hasMetadata HasMetadata + if ok := errors.As(err, &hasMetadata); ok { + metadata = hasMetadata.DetailsMetadata() + } + + status := WithCodeAndDetails(err, code, ForReason(reason, metadata)) + return withStatusError{err, status} +} + +type SupportsAdditionalMetadata interface { + WithAdditionalDetails(key MetadataKey, value string) +} + +// WithAdditionalDetails adds an additional details field to the error if it is possible. +func WithAdditionalDetails(err error, key MetadataKey, value string) bool { + var supportsAdditionalDetails SupportsAdditionalMetadata + if ok := errors.As(err, &supportsAdditionalDetails); ok { + supportsAdditionalDetails.WithAdditionalDetails(key, value) + return true + } + + return false +} + +type withStatusError struct { + error + status *status.Status +} + +func (err withStatusError) GRPCStatus() *status.Status { + return err.status +} diff --git a/vendor/github.com/authzed/spicedb/pkg/tuple/comparison.go b/vendor/github.com/authzed/spicedb/pkg/tuple/comparison.go new file mode 100644 index 0000000..159edd9 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/tuple/comparison.go @@ -0,0 +1,48 @@ +package tuple + +import ( + "time" + + "google.golang.org/protobuf/proto" + + core "github.com/authzed/spicedb/pkg/proto/core/v1" +) + +// ONREqual checks if two ObjectAndRelation instances are equal. +func ONREqual(lhs, rhs ObjectAndRelation) bool { + return lhs == rhs +} + +// ONREqualOrWildcard checks if an ObjectAndRelation matches another ObjectAndRelation or is a wildcard. +func ONREqualOrWildcard(onr, target ObjectAndRelation) bool { + return ONREqual(onr, target) || (onr.ObjectID == PublicWildcard && onr.ObjectType == target.ObjectType) +} + +// Equal returns true if the two relationships are exactly the same. +func Equal(lhs, rhs Relationship) bool { + return ONREqual(lhs.Resource, rhs.Resource) && ONREqual(lhs.Subject, rhs.Subject) && caveatEqual(lhs.OptionalCaveat, rhs.OptionalCaveat) && expirationEqual(lhs.OptionalExpiration, rhs.OptionalExpiration) +} + +func expirationEqual(lhs, rhs *time.Time) bool { + if lhs == nil && rhs == nil { + return true + } + + if lhs == nil || rhs == nil { + return false + } + + return lhs.Equal(*rhs) +} + +func caveatEqual(lhs, rhs *core.ContextualizedCaveat) bool { + if lhs == nil && rhs == nil { + return true + } + + if lhs == nil || rhs == nil { + return false + } + + return lhs.CaveatName == rhs.CaveatName && proto.Equal(lhs.Context, rhs.Context) +} diff --git a/vendor/github.com/authzed/spicedb/pkg/tuple/core.go b/vendor/github.com/authzed/spicedb/pkg/tuple/core.go new file mode 100644 index 0000000..d71a016 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/tuple/core.go @@ -0,0 +1,132 @@ +package tuple + +import ( + "time" + + core "github.com/authzed/spicedb/pkg/proto/core/v1" + "github.com/authzed/spicedb/pkg/spiceerrors" +) + +// ONRStringToCore creates an ONR from string pieces. +func ONRStringToCore(ns, oid, rel string) *core.ObjectAndRelation { + spiceerrors.DebugAssert(func() bool { + return ns != "" && oid != "" && rel != "" + }, "namespace, object ID, and relation must not be empty") + + return &core.ObjectAndRelation{ + Namespace: ns, + ObjectId: oid, + Relation: rel, + } +} + +// CoreRelationToStringWithoutCaveatOrExpiration creates a string from a core.RelationTuple without stringifying the caveat. +func CoreRelationToStringWithoutCaveatOrExpiration(rel *core.RelationTuple) string { + if rel.Subject.Relation == Ellipsis { + return rel.ResourceAndRelation.Namespace + ":" + rel.ResourceAndRelation.ObjectId + "@" + rel.Subject.Namespace + ":" + rel.Subject.ObjectId + } + + return rel.ResourceAndRelation.Namespace + ":" + rel.ResourceAndRelation.ObjectId + "@" + rel.Subject.Namespace + ":" + rel.Subject.ObjectId + "#" + rel.ResourceAndRelation.Relation +} + +// CoreRelationToString creates a string from a core.RelationTuple. +func CoreRelationToString(rel *core.RelationTuple) (string, error) { + return String(FromCoreRelationTuple(rel)) +} + +// MustCoreRelationToString creates a string from a core.RelationTuple and panics if it can't. +func MustCoreRelationToString(rel *core.RelationTuple) string { + return MustString(FromCoreRelationTuple(rel)) +} + +// RRStringToCore creates a RelationReference from the string pieces. +func RRStringToCore(namespaceName string, relationName string) *core.RelationReference { + spiceerrors.DebugAssert(func() bool { + return namespaceName != "" && relationName != "" + }, "namespace and relation must not be empty") + + return &core.RelationReference{ + Namespace: namespaceName, + Relation: relationName, + } +} + +// FromCoreRelationTuple creates a Relationship from a core.RelationTuple. +func FromCoreRelationTuple(rt *core.RelationTuple) Relationship { + spiceerrors.DebugAssert(func() bool { + return rt.Validate() == nil + }, "relation tuple must be valid") + + var expiration *time.Time + if rt.OptionalExpirationTime != nil { + t := rt.OptionalExpirationTime.AsTime() + expiration = &t + } + + return Relationship{ + RelationshipReference: RelationshipReference{ + Resource: ObjectAndRelation{ + ObjectType: rt.ResourceAndRelation.Namespace, + ObjectID: rt.ResourceAndRelation.ObjectId, + Relation: rt.ResourceAndRelation.Relation, + }, + Subject: ObjectAndRelation{ + ObjectType: rt.Subject.Namespace, + ObjectID: rt.Subject.ObjectId, + Relation: rt.Subject.Relation, + }, + }, + OptionalCaveat: rt.Caveat, + OptionalExpiration: expiration, + } +} + +// FromCoreObjectAndRelation creates an ObjectAndRelation from a core.ObjectAndRelation. +func FromCoreObjectAndRelation(oar *core.ObjectAndRelation) ObjectAndRelation { + spiceerrors.DebugAssert(func() bool { + return oar.Validate() == nil + }, "object and relation must be valid") + + return ObjectAndRelation{ + ObjectType: oar.Namespace, + ObjectID: oar.ObjectId, + Relation: oar.Relation, + } +} + +// CoreONR creates a core ObjectAndRelation from the string pieces. +func CoreONR(namespace, objectID, relation string) *core.ObjectAndRelation { + spiceerrors.DebugAssert(func() bool { + return namespace != "" && objectID != "" && relation != "" + }, "namespace, object ID, and relation must not be empty") + + return &core.ObjectAndRelation{ + Namespace: namespace, + ObjectId: objectID, + Relation: relation, + } +} + +// CoreRR creates a core RelationReference from the string pieces. +func CoreRR(namespace, relation string) *core.RelationReference { + spiceerrors.DebugAssert(func() bool { + return namespace != "" && relation != "" + }, "namespace and relation must not be empty") + + return &core.RelationReference{ + Namespace: namespace, + Relation: relation, + } +} + +// FromCoreRelationReference creates a RelationReference from a core.RelationReference. +func FromCoreRelationReference(rr *core.RelationReference) RelationReference { + spiceerrors.DebugAssert(func() bool { + return rr.Validate() == nil + }, "relation reference must be valid") + + return RelationReference{ + ObjectType: rr.Namespace, + Relation: rr.Relation, + } +} diff --git a/vendor/github.com/authzed/spicedb/pkg/tuple/doc.go b/vendor/github.com/authzed/spicedb/pkg/tuple/doc.go new file mode 100644 index 0000000..b86f0d2 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/tuple/doc.go @@ -0,0 +1,2 @@ +// Package tuple provides ways to convert to and from proto structs to Go structs that can extend the core functionality. +package tuple diff --git a/vendor/github.com/authzed/spicedb/pkg/tuple/hashing.go b/vendor/github.com/authzed/spicedb/pkg/tuple/hashing.go new file mode 100644 index 0000000..1f733d4 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/tuple/hashing.go @@ -0,0 +1,108 @@ +package tuple + +import ( + "bytes" + "fmt" + "sort" + "time" + + "google.golang.org/protobuf/types/known/structpb" + + "github.com/authzed/spicedb/pkg/spiceerrors" +) + +// CanonicalBytes converts a tuple to a canonical set of bytes. +// Can be used for hashing purposes. +func CanonicalBytes(rel Relationship) ([]byte, error) { + spiceerrors.DebugAssert(rel.ValidateNotEmpty, "relationship must not be empty") + + var sb bytes.Buffer + sb.WriteString(rel.Resource.ObjectType) + sb.WriteString(":") + sb.WriteString(rel.Resource.ObjectID) + sb.WriteString("#") + sb.WriteString(rel.Resource.Relation) + sb.WriteString("@") + sb.WriteString(rel.Subject.ObjectType) + sb.WriteString(":") + sb.WriteString(rel.Subject.ObjectID) + sb.WriteString("#") + sb.WriteString(rel.Subject.Relation) + + if rel.OptionalCaveat != nil && rel.OptionalCaveat.CaveatName != "" { + sb.WriteString(" with ") + sb.WriteString(rel.OptionalCaveat.CaveatName) + + if rel.OptionalCaveat.Context != nil && len(rel.OptionalCaveat.Context.Fields) > 0 { + sb.WriteString(":") + if err := writeCanonicalContext(&sb, rel.OptionalCaveat.Context); err != nil { + return nil, err + } + } + } + + if rel.OptionalExpiration != nil { + sb.WriteString(" with $expiration:") + truncated := rel.OptionalExpiration.UTC().Truncate(time.Second) + sb.WriteString(truncated.Format(expirationFormat)) + } + + return sb.Bytes(), nil +} + +func writeCanonicalContext(sb *bytes.Buffer, context *structpb.Struct) error { + sb.WriteString("{") + for i, key := range sortedContextKeys(context.Fields) { + if i > 0 { + sb.WriteString(",") + } + sb.WriteString(key) + sb.WriteString(":") + if err := writeCanonicalContextValue(sb, context.Fields[key]); err != nil { + return err + } + } + sb.WriteString("}") + return nil +} + +func writeCanonicalContextValue(sb *bytes.Buffer, value *structpb.Value) error { + switch value.Kind.(type) { + case *structpb.Value_NullValue: + sb.WriteString("null") + case *structpb.Value_NumberValue: + sb.WriteString(fmt.Sprintf("%f", value.GetNumberValue())) + case *structpb.Value_StringValue: + sb.WriteString(value.GetStringValue()) + case *structpb.Value_BoolValue: + sb.WriteString(fmt.Sprintf("%t", value.GetBoolValue())) + case *structpb.Value_StructValue: + if err := writeCanonicalContext(sb, value.GetStructValue()); err != nil { + return err + } + case *structpb.Value_ListValue: + sb.WriteString("[") + for i, elem := range value.GetListValue().Values { + if i > 0 { + sb.WriteString(",") + } + if err := writeCanonicalContextValue(sb, elem); err != nil { + return err + } + } + sb.WriteString("]") + default: + return spiceerrors.MustBugf("unknown structpb.Value type: %T", value.Kind) + } + + return nil +} + +func sortedContextKeys(fields map[string]*structpb.Value) []string { + keys := make([]string, 0, len(fields)) + for key := range fields { + keys = append(keys, key) + } + sort.Strings(keys) + return keys +} diff --git a/vendor/github.com/authzed/spicedb/pkg/tuple/onr.go b/vendor/github.com/authzed/spicedb/pkg/tuple/onr.go new file mode 100644 index 0000000..83ad512 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/tuple/onr.go @@ -0,0 +1,75 @@ +package tuple + +import ( + "fmt" + "regexp" + "slices" +) + +var ( + onrRegex = regexp.MustCompile(fmt.Sprintf("^%s$", onrExpr)) + subjectRegex = regexp.MustCompile(fmt.Sprintf("^%s$", subjectExpr)) +) + +var ( + onrSubjectRelIndex = slices.Index(subjectRegex.SubexpNames(), "subjectRel") + onrSubjectTypeIndex = slices.Index(subjectRegex.SubexpNames(), "subjectType") + onrSubjectIDIndex = slices.Index(subjectRegex.SubexpNames(), "subjectID") + onrResourceTypeIndex = slices.Index(onrRegex.SubexpNames(), "resourceType") + onrResourceIDIndex = slices.Index(onrRegex.SubexpNames(), "resourceID") + onrResourceRelIndex = slices.Index(onrRegex.SubexpNames(), "resourceRel") +) + +// ParseSubjectONR converts a string representation of a Subject ONR to an ObjectAndRelation. Unlike +// ParseONR, this method allows for objects without relations. If an object without a relation +// is given, the relation will be set to ellipsis. +func ParseSubjectONR(subjectOnr string) (ObjectAndRelation, error) { + groups := subjectRegex.FindStringSubmatch(subjectOnr) + if len(groups) == 0 { + return ObjectAndRelation{}, fmt.Errorf("invalid subject ONR: %s", subjectOnr) + } + + relation := Ellipsis + if len(groups[onrSubjectRelIndex]) > 0 { + relation = groups[onrSubjectRelIndex] + } + + return ObjectAndRelation{ + ObjectType: groups[onrSubjectTypeIndex], + ObjectID: groups[onrSubjectIDIndex], + Relation: relation, + }, nil +} + +// MustParseSubjectONR converts a string representation of a Subject ONR to an ObjectAndRelation. +// Panics on error. +func MustParseSubjectONR(subjectOnr string) ObjectAndRelation { + parsed, err := ParseSubjectONR(subjectOnr) + if err != nil { + panic(err) + } + return parsed +} + +// ParseONR converts a string representation of an ONR to an ObjectAndRelation object. +func ParseONR(onr string) (ObjectAndRelation, error) { + groups := onrRegex.FindStringSubmatch(onr) + if len(groups) == 0 { + return ObjectAndRelation{}, fmt.Errorf("invalid ONR: %s", onr) + } + + return ObjectAndRelation{ + ObjectType: groups[onrResourceTypeIndex], + ObjectID: groups[onrResourceIDIndex], + Relation: groups[onrResourceRelIndex], + }, nil +} + +// MustParseONR converts a string representation of an ONR to an ObjectAndRelation object. Panics on error. +func MustParseONR(onr string) ObjectAndRelation { + parsed, err := ParseONR(onr) + if err != nil { + panic(err) + } + return parsed +} diff --git a/vendor/github.com/authzed/spicedb/pkg/tuple/parsing.go b/vendor/github.com/authzed/spicedb/pkg/tuple/parsing.go new file mode 100644 index 0000000..f2ed7d2 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/tuple/parsing.go @@ -0,0 +1,228 @@ +package tuple + +import ( + "encoding/json" + "fmt" + "maps" + "regexp" + "slices" + "time" + + "google.golang.org/protobuf/types/known/structpb" + + "github.com/jzelinskie/stringz" + + core "github.com/authzed/spicedb/pkg/proto/core/v1" +) + +const ( + namespaceNameExpr = "([a-z][a-z0-9_]{1,61}[a-z0-9]/)*[a-z][a-z0-9_]{1,62}[a-z0-9]" + resourceIDExpr = "([a-zA-Z0-9/_|\\-=+]{1,})" + subjectIDExpr = "([a-zA-Z0-9/_|\\-=+]{1,})|\\*" + relationExpr = "[a-z][a-z0-9_]{1,62}[a-z0-9]" + caveatNameExpr = "([a-z][a-z0-9_]{1,61}[a-z0-9]/)*[a-z][a-z0-9_]{1,62}[a-z0-9]" +) + +var onrExpr = fmt.Sprintf( + `(?P<resourceType>(%s)):(?P<resourceID>%s)#(?P<resourceRel>%s)`, + namespaceNameExpr, + resourceIDExpr, + relationExpr, +) + +var subjectExpr = fmt.Sprintf( + `(?P<subjectType>(%s)):(?P<subjectID>%s)(#(?P<subjectRel>%s|\.\.\.))?`, + namespaceNameExpr, + subjectIDExpr, + relationExpr, +) + +var ( + caveatExpr = fmt.Sprintf(`\[(?P<caveatName>(%s))(:(?P<caveatContext>(\{(.+)\})))?\]`, caveatNameExpr) + expirationExpr = `\[expiration:(?P<expirationDateTime>([\d\-\.:TZ]+))\]` +) + +var ( + resourceIDRegex = regexp.MustCompile(fmt.Sprintf("^%s$", resourceIDExpr)) + subjectIDRegex = regexp.MustCompile(fmt.Sprintf("^%s$", subjectIDExpr)) +) + +var parserRegex = regexp.MustCompile( + fmt.Sprintf( + `^%s@%s(%s)?(%s)?$`, + onrExpr, + subjectExpr, + caveatExpr, + expirationExpr, + ), +) + +// ValidateResourceID ensures that the given resource ID is valid. Returns an error if not. +func ValidateResourceID(objectID string) error { + if !resourceIDRegex.MatchString(objectID) { + return fmt.Errorf("invalid resource id; must match %s", resourceIDExpr) + } + if len(objectID) > 1024 { + return fmt.Errorf("invalid resource id; must be <= 1024 characters") + } + + return nil +} + +// ValidateSubjectID ensures that the given object ID (under a subject reference) is valid. Returns an error if not. +func ValidateSubjectID(subjectID string) error { + if !subjectIDRegex.MatchString(subjectID) { + return fmt.Errorf("invalid subject id; must be alphanumeric and between 1 and 127 characters or a star for public") + } + if len(subjectID) > 1024 { + return fmt.Errorf("invalid resource id; must be <= 1024 characters") + } + + return nil +} + +// MustParse wraps Parse such that any failures panic rather than returning an error. +func MustParse(relString string) Relationship { + parsed, err := Parse(relString) + if err != nil { + panic(err) + } + return parsed +} + +var ( + subjectRelIndex = slices.Index(parserRegex.SubexpNames(), "subjectRel") + caveatNameIndex = slices.Index(parserRegex.SubexpNames(), "caveatName") + caveatContextIndex = slices.Index(parserRegex.SubexpNames(), "caveatContext") + resourceIDIndex = slices.Index(parserRegex.SubexpNames(), "resourceID") + subjectIDIndex = slices.Index(parserRegex.SubexpNames(), "subjectID") + resourceTypeIndex = slices.Index(parserRegex.SubexpNames(), "resourceType") + resourceRelIndex = slices.Index(parserRegex.SubexpNames(), "resourceRel") + subjectTypeIndex = slices.Index(parserRegex.SubexpNames(), "subjectType") + expirationDateTimeIndex = slices.Index(parserRegex.SubexpNames(), "expirationDateTime") +) + +// Parse unmarshals the string form of a Tuple and returns an error on failure, +// +// This function treats both missing and Ellipsis relations equally. +func Parse(relString string) (Relationship, error) { + groups := parserRegex.FindStringSubmatch(relString) + if len(groups) == 0 { + return Relationship{}, fmt.Errorf("invalid relationship string") + } + + subjectRelation := Ellipsis + if len(groups[subjectRelIndex]) > 0 { + subjectRelation = stringz.DefaultEmpty(groups[subjectRelIndex], Ellipsis) + } + + caveatName := groups[caveatNameIndex] + var optionalCaveat *core.ContextualizedCaveat + if caveatName != "" { + optionalCaveat = &core.ContextualizedCaveat{ + CaveatName: caveatName, + } + + caveatContextString := groups[caveatContextIndex] + if len(caveatContextString) > 0 { + contextMap := make(map[string]any, 1) + err := json.Unmarshal([]byte(caveatContextString), &contextMap) + if err != nil { + return Relationship{}, fmt.Errorf("invalid caveat context JSON: %w", err) + } + + caveatContext, err := structpb.NewStruct(contextMap) + if err != nil { + return Relationship{}, fmt.Errorf("invalid caveat context: %w", err) + } + + optionalCaveat.Context = caveatContext + } + } + + expirationTimeStr := groups[expirationDateTimeIndex] + var optionalExpiration *time.Time + if len(expirationTimeStr) > 0 { + expirationTime, err := time.Parse(expirationFormat, expirationTimeStr) + if err != nil { + return Relationship{}, fmt.Errorf("invalid expiration time: %w", err) + } + + optionalExpiration = &expirationTime + } + + resourceID := groups[resourceIDIndex] + if err := ValidateResourceID(resourceID); err != nil { + return Relationship{}, fmt.Errorf("invalid resource id: %w", err) + } + + subjectID := groups[subjectIDIndex] + if err := ValidateSubjectID(subjectID); err != nil { + return Relationship{}, fmt.Errorf("invalid subject id: %w", err) + } + + return Relationship{ + RelationshipReference: RelationshipReference{ + Resource: ObjectAndRelation{ + ObjectType: groups[resourceTypeIndex], + ObjectID: resourceID, + Relation: groups[resourceRelIndex], + }, + Subject: ObjectAndRelation{ + ObjectType: groups[subjectTypeIndex], + ObjectID: subjectID, + Relation: subjectRelation, + }, + }, + OptionalCaveat: optionalCaveat, + OptionalExpiration: optionalExpiration, + }, nil +} + +// MustWithExpiration adds the given expiration to the relationship. This is for testing only. +func MustWithExpiration(rel Relationship, expiration time.Time) Relationship { + rel.OptionalExpiration = &expiration + return rel +} + +// MustWithCaveat adds the given caveat name to the relationship. This is for testing only. +func MustWithCaveat(rel Relationship, caveatName string, contexts ...map[string]any) Relationship { + wc, err := WithCaveat(rel, caveatName, contexts...) + if err != nil { + panic(err) + } + return wc +} + +// WithCaveat adds the given caveat name to the relationship. This is for testing only. +func WithCaveat(rel Relationship, caveatName string, contexts ...map[string]any) (Relationship, error) { + var context *structpb.Struct + + if len(contexts) > 0 { + combined := map[string]any{} + for _, current := range contexts { + maps.Copy(combined, current) + } + + contextStruct, err := structpb.NewStruct(combined) + if err != nil { + return Relationship{}, err + } + context = contextStruct + } + + rel.OptionalCaveat = &core.ContextualizedCaveat{ + CaveatName: caveatName, + Context: context, + } + return rel, nil +} + +// StringToONR creates an ONR from string pieces. +func StringToONR(ns, oid, rel string) ObjectAndRelation { + return ObjectAndRelation{ + ObjectType: ns, + ObjectID: oid, + Relation: rel, + } +} diff --git a/vendor/github.com/authzed/spicedb/pkg/tuple/strings.go b/vendor/github.com/authzed/spicedb/pkg/tuple/strings.go new file mode 100644 index 0000000..7b5a378 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/tuple/strings.go @@ -0,0 +1,165 @@ +package tuple + +import ( + "sort" + "strings" + "time" + + "google.golang.org/protobuf/encoding/protojson" + "google.golang.org/protobuf/types/known/structpb" + + core "github.com/authzed/spicedb/pkg/proto/core/v1" + "github.com/authzed/spicedb/pkg/spiceerrors" +) + +var expirationFormat = time.RFC3339Nano + +// JoinRelRef joins the namespace and relation together into the same +// format as `StringRR()`. +func JoinRelRef(namespace, relation string) string { return namespace + "#" + relation } + +// MustSplitRelRef splits a string produced by `JoinRelRef()` and panics if +// it fails. +func MustSplitRelRef(relRef string) (namespace, relation string) { + var ok bool + namespace, relation, ok = strings.Cut(relRef, "#") + if !ok { + panic("improperly formatted relation reference") + } + return +} + +// StringRR converts a RR object to a string. +func StringRR(rr RelationReference) string { + return JoinRelRef(rr.ObjectType, rr.Relation) +} + +// StringONR converts an ONR object to a string. +func StringONR(onr ObjectAndRelation) string { + return StringONRStrings(onr.ObjectType, onr.ObjectID, onr.Relation) +} + +func StringCoreRR(rr *core.RelationReference) string { + if rr == nil { + return "" + } + + return JoinRelRef(rr.Namespace, rr.Relation) +} + +// StringCoreONR converts a core ONR object to a string. +func StringCoreONR(onr *core.ObjectAndRelation) string { + if onr == nil { + return "" + } + + return StringONRStrings(onr.Namespace, onr.ObjectId, onr.Relation) +} + +// StringONRStrings converts ONR strings to a string. +func StringONRStrings(namespace, objectID, relation string) string { + if relation == Ellipsis { + return JoinObjectRef(namespace, objectID) + } + return JoinRelRef(JoinObjectRef(namespace, objectID), relation) +} + +// StringsONRs converts ONR objects to a string slice, sorted. +func StringsONRs(onrs []ObjectAndRelation) []string { + onrstrings := make([]string, 0, len(onrs)) + for _, onr := range onrs { + onrstrings = append(onrstrings, StringONR(onr)) + } + + sort.Strings(onrstrings) + return onrstrings +} + +// MustString converts a relationship to a string. +func MustString(rel Relationship) string { + tplString, err := String(rel) + if err != nil { + panic(err) + } + return tplString +} + +// String converts a relationship to a string. +func String(rel Relationship) (string, error) { + spiceerrors.DebugAssert(rel.ValidateNotEmpty, "relationship must not be empty") + + caveatString, err := StringCaveat(rel.OptionalCaveat) + if err != nil { + return "", err + } + + expirationString, err := StringExpiration(rel.OptionalExpiration) + if err != nil { + return "", err + } + + return StringONR(rel.Resource) + "@" + StringONR(rel.Subject) + caveatString + expirationString, nil +} + +func StringExpiration(expiration *time.Time) (string, error) { + if expiration == nil { + return "", nil + } + + return "[expiration:" + expiration.Format(expirationFormat) + "]", nil +} + +// StringWithoutCaveatOrExpiration converts a relationship to a string, without its caveat or expiration included. +func StringWithoutCaveatOrExpiration(rel Relationship) string { + spiceerrors.DebugAssert(rel.ValidateNotEmpty, "relationship must not be empty") + + return StringONR(rel.Resource) + "@" + StringONR(rel.Subject) +} + +func MustStringCaveat(caveat *core.ContextualizedCaveat) string { + caveatString, err := StringCaveat(caveat) + if err != nil { + panic(err) + } + return caveatString +} + +// StringCaveat converts a contextualized caveat to a string. If the caveat is nil or empty, returns empty string. +func StringCaveat(caveat *core.ContextualizedCaveat) (string, error) { + if caveat == nil || caveat.CaveatName == "" { + return "", nil + } + + contextString, err := StringCaveatContext(caveat.Context) + if err != nil { + return "", err + } + + if len(contextString) > 0 { + contextString = ":" + contextString + } + + return "[" + caveat.CaveatName + contextString + "]", nil +} + +// StringCaveatContext converts the context of a caveat to a string. If the context is nil or empty, returns an empty string. +func StringCaveatContext(context *structpb.Struct) (string, error) { + if context == nil || len(context.Fields) == 0 { + return "", nil + } + + contextBytes, err := protojson.MarshalOptions{ + Multiline: false, + Indent: "", + }.Marshal(context) + if err != nil { + return "", err + } + return string(contextBytes), nil +} + +// JoinObjectRef joins the namespace and the objectId together into the standard +// format. +// +// This function assumes that the provided values have already been validated. +func JoinObjectRef(namespace, objectID string) string { return namespace + ":" + objectID } diff --git a/vendor/github.com/authzed/spicedb/pkg/tuple/structs.go b/vendor/github.com/authzed/spicedb/pkg/tuple/structs.go new file mode 100644 index 0000000..e6cd256 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/tuple/structs.go @@ -0,0 +1,219 @@ +package tuple + +import ( + "errors" + "fmt" + "time" + + "google.golang.org/protobuf/types/known/timestamppb" + + core "github.com/authzed/spicedb/pkg/proto/core/v1" + "github.com/authzed/spicedb/pkg/spiceerrors" +) + +const ( + // Ellipsis is the Ellipsis relation in v0 style subjects. + Ellipsis = "..." + + // PublicWildcard is the wildcard value for subject object IDs that indicates public access + // for the subject type. + PublicWildcard = "*" +) + +// ObjectAndRelation represents an object and its relation. +type ObjectAndRelation struct { + ObjectID string + ObjectType string + Relation string +} + +const onrStructSize = 48 /* size of the struct itself */ + +func (onr ObjectAndRelation) SizeVT() int { + return len(onr.ObjectID) + len(onr.ObjectType) + len(onr.Relation) + onrStructSize +} + +// WithRelation returns a copy of the object and relation with the given relation. +func (onr ObjectAndRelation) WithRelation(relation string) ObjectAndRelation { + onr.Relation = relation + return onr +} + +// RelationReference returns a RelationReference for the object and relation. +func (onr ObjectAndRelation) RelationReference() RelationReference { + return RelationReference{ + ObjectType: onr.ObjectType, + Relation: onr.Relation, + } +} + +// ToCoreONR converts the ObjectAndRelation to a core.ObjectAndRelation. +func (onr ObjectAndRelation) ToCoreONR() *core.ObjectAndRelation { + return &core.ObjectAndRelation{ + Namespace: onr.ObjectType, + ObjectId: onr.ObjectID, + Relation: onr.Relation, + } +} + +func (onr ObjectAndRelation) String() string { + return fmt.Sprintf("%s:%s#%s", onr.ObjectType, onr.ObjectID, onr.Relation) +} + +// RelationshipReference represents a reference to a relationship, i.e. those portions +// of a relationship that are not the integrity or caveat and thus form the unique +// identifier of the relationship. +type RelationshipReference struct { + Resource ObjectAndRelation + Subject ObjectAndRelation +} + +// Relationship represents a relationship between two objects. +type Relationship struct { + OptionalCaveat *core.ContextualizedCaveat + OptionalExpiration *time.Time + OptionalIntegrity *core.RelationshipIntegrity + + RelationshipReference +} + +// ToCoreTuple converts the Relationship to a core.RelationTuple. +func (r Relationship) ToCoreTuple() *core.RelationTuple { + var expirationTime *timestamppb.Timestamp + if r.OptionalExpiration != nil { + expirationTime = timestamppb.New(*r.OptionalExpiration) + } + + return &core.RelationTuple{ + ResourceAndRelation: r.Resource.ToCoreONR(), + Subject: r.Subject.ToCoreONR(), + Caveat: r.OptionalCaveat, + Integrity: r.OptionalIntegrity, + OptionalExpirationTime: expirationTime, + } +} + +const relStructSize = 120 /* size of the struct itself */ + +func (r Relationship) SizeVT() int { + size := r.Resource.SizeVT() + r.Subject.SizeVT() + relStructSize + if r.OptionalCaveat != nil { + size += r.OptionalCaveat.SizeVT() + } + return size +} + +// ValidateNotEmpty returns true if the relationship is not empty. +func (r Relationship) ValidateNotEmpty() bool { + return r.Resource.ObjectType != "" && r.Resource.ObjectID != "" && r.Subject.ObjectType != "" && r.Subject.ObjectID != "" && r.Resource.Relation != "" && r.Subject.Relation != "" +} + +// Validate returns an error if the relationship is invalid. +func (r Relationship) Validate() error { + if !r.ValidateNotEmpty() { + return errors.New("object and relation must not be empty") + } + + if r.RelationshipReference.Resource.ObjectID == PublicWildcard { + return errors.New("invalid resource id") + } + + return nil +} + +// WithoutIntegrity returns a copy of the relationship without its integrity. +func (r Relationship) WithoutIntegrity() Relationship { + r.OptionalIntegrity = nil + return r +} + +// WithCaveat returns a copy of the relationship with the given caveat. +func (r Relationship) WithCaveat(caveat *core.ContextualizedCaveat) Relationship { + r.OptionalCaveat = caveat + return r +} + +// UpdateOperation represents the type of update to a relationship. +type UpdateOperation int + +const ( + UpdateOperationTouch UpdateOperation = iota + UpdateOperationCreate + UpdateOperationDelete +) + +// RelationshipUpdate represents an update to a relationship. +type RelationshipUpdate struct { + Relationship Relationship + Operation UpdateOperation +} + +func (ru RelationshipUpdate) OperationString() string { + switch ru.Operation { + case UpdateOperationTouch: + return "TOUCH" + case UpdateOperationCreate: + return "CREATE" + case UpdateOperationDelete: + return "DELETE" + default: + return "unknown" + } +} + +func (ru RelationshipUpdate) DebugString() string { + return fmt.Sprintf("%s(%s)", ru.OperationString(), StringWithoutCaveatOrExpiration(ru.Relationship)) +} + +// RelationReference represents a reference to a relation. +type RelationReference struct { + ObjectType string + Relation string +} + +// ToCoreRR converts the RelationReference to a core.RelationReference. +func (rr RelationReference) ToCoreRR() *core.RelationReference { + return &core.RelationReference{ + Namespace: rr.ObjectType, + Relation: rr.Relation, + } +} + +func (rr RelationReference) RefString() string { + return JoinRelRef(rr.ObjectType, rr.Relation) +} + +func (rr RelationReference) String() string { + return rr.RefString() +} + +// ONR creates an ObjectAndRelation. +func ONR(namespace, objectID, relation string) ObjectAndRelation { + spiceerrors.DebugAssert(func() bool { + return namespace != "" && objectID != "" && relation != "" + }, "invalid ONR: %s %s %s", namespace, objectID, relation) + + return ObjectAndRelation{ + ObjectType: namespace, + ObjectID: objectID, + Relation: relation, + } +} + +// ONRRef creates an ObjectAndRelation reference. +func ONRRef(namespace, objectID, relation string) *ObjectAndRelation { + onr := ONR(namespace, objectID, relation) + return &onr +} + +// RR creates a RelationReference. +func RR(namespace, relation string) RelationReference { + spiceerrors.DebugAssert(func() bool { + return namespace != "" && relation != "" + }, "invalid RR: %s %s", namespace, relation) + + return RelationReference{ + ObjectType: namespace, + Relation: relation, + } +} diff --git a/vendor/github.com/authzed/spicedb/pkg/tuple/updates.go b/vendor/github.com/authzed/spicedb/pkg/tuple/updates.go new file mode 100644 index 0000000..73eafe9 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/tuple/updates.go @@ -0,0 +1,22 @@ +package tuple + +func Create(rel Relationship) RelationshipUpdate { + return RelationshipUpdate{ + Operation: UpdateOperationCreate, + Relationship: rel, + } +} + +func Touch(rel Relationship) RelationshipUpdate { + return RelationshipUpdate{ + Operation: UpdateOperationTouch, + Relationship: rel, + } +} + +func Delete(rel Relationship) RelationshipUpdate { + return RelationshipUpdate{ + Operation: UpdateOperationDelete, + Relationship: rel, + } +} diff --git a/vendor/github.com/authzed/spicedb/pkg/tuple/v1.go b/vendor/github.com/authzed/spicedb/pkg/tuple/v1.go new file mode 100644 index 0000000..5a3705f --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/tuple/v1.go @@ -0,0 +1,340 @@ +package tuple + +import ( + "fmt" + "time" + + v1 "github.com/authzed/authzed-go/proto/authzed/api/v1" + "github.com/jzelinskie/stringz" + "google.golang.org/protobuf/types/known/timestamppb" + + core "github.com/authzed/spicedb/pkg/proto/core/v1" + "github.com/authzed/spicedb/pkg/spiceerrors" +) + +// ParseV1Rel parses a string representation of a relationship into a v1.Relationship object. +func ParseV1Rel(relString string) (*v1.Relationship, error) { + parsed, err := Parse(relString) + if err != nil { + return nil, err + } + + return ToV1Relationship(parsed), nil +} + +// Same as above, but panics if it cannot be parsed. Should only be used in tests. +func MustParseV1Rel(relString string) *v1.Relationship { + parsed, err := Parse(relString) + if err != nil { + panic(fmt.Sprintf("could not parse relationship string: %s %s", relString, err)) + } + + return ToV1Relationship(parsed) +} + +// MustV1RelString converts a relationship into a string. Will panic if +// the Relationship does not validate. +func MustV1RelString(rel *v1.Relationship) string { + if err := rel.Validate(); err != nil { + panic(fmt.Sprintf("invalid relationship: %#v %s", rel, err)) + } + return MustV1StringRelationship(rel) +} + +// StringObjectRef marshals a *v1.ObjectReference into a string. +// +// This function assumes that the provided values have already been validated. +func V1StringObjectRef(ref *v1.ObjectReference) string { + return JoinObjectRef(ref.ObjectType, ref.ObjectId) +} + +// StringSubjectRef marshals a *v1.SubjectReference into a string. +// +// This function assumes that the provided values have already been validated. +func V1StringSubjectRef(ref *v1.SubjectReference) string { + if ref.OptionalRelation == "" { + return V1StringObjectRef(ref.Object) + } + return JoinRelRef(V1StringObjectRef(ref.Object), ref.OptionalRelation) +} + +// MustV1StringRelationship converts a v1.Relationship to a string. +func MustV1StringRelationship(rel *v1.Relationship) string { + relString, err := V1StringRelationship(rel) + if err != nil { + panic(err) + } + return relString +} + +// V1StringRelationship converts a v1.Relationship to a string. +func V1StringRelationship(rel *v1.Relationship) (string, error) { + if rel == nil || rel.Resource == nil || rel.Subject == nil { + return "", nil + } + + caveatString, err := V1StringCaveatRef(rel.OptionalCaveat) + if err != nil { + return "", err + } + + expirationString, err := V1StringExpiration(rel.OptionalExpiresAt) + if err != nil { + return "", err + } + + return V1StringRelationshipWithoutCaveatOrExpiration(rel) + caveatString + expirationString, nil +} + +func V1StringExpiration(expiration *timestamppb.Timestamp) (string, error) { + if expiration == nil { + return "", nil + } + + return "[expiration:" + expiration.AsTime().Format(expirationFormat) + "]", nil +} + +// V1StringRelationshipWithoutCaveatOrExpiration converts a v1.Relationship to a string, excluding any caveat. +func V1StringRelationshipWithoutCaveatOrExpiration(rel *v1.Relationship) string { + if rel == nil || rel.Resource == nil || rel.Subject == nil { + return "" + } + + return V1StringObjectRef(rel.Resource) + "#" + rel.Relation + "@" + V1StringSubjectRef(rel.Subject) +} + +// V1StringCaveatRef converts a v1.ContextualizedCaveat to a string. +func V1StringCaveatRef(caveat *v1.ContextualizedCaveat) (string, error) { + if caveat == nil || caveat.CaveatName == "" { + return "", nil + } + + contextString, err := StringCaveatContext(caveat.Context) + if err != nil { + return "", err + } + + if len(contextString) > 0 { + contextString = ":" + contextString + } + + return "[" + caveat.CaveatName + contextString + "]", nil +} + +// UpdateToV1RelationshipUpdate converts a RelationshipUpdate into a +// v1.RelationshipUpdate. +func UpdateToV1RelationshipUpdate(update RelationshipUpdate) (*v1.RelationshipUpdate, error) { + var op v1.RelationshipUpdate_Operation + switch update.Operation { + case UpdateOperationCreate: + op = v1.RelationshipUpdate_OPERATION_CREATE + case UpdateOperationDelete: + op = v1.RelationshipUpdate_OPERATION_DELETE + case UpdateOperationTouch: + op = v1.RelationshipUpdate_OPERATION_TOUCH + default: + return nil, spiceerrors.MustBugf("unknown update operation: %v", update.Operation) + } + + return &v1.RelationshipUpdate{ + Operation: op, + Relationship: ToV1Relationship(update.Relationship), + }, nil +} + +// MustUpdateToV1RelationshipUpdate converts a RelationshipUpdate into a +// v1.RelationshipUpdate. Panics on error. +func MustUpdateToV1RelationshipUpdate(update RelationshipUpdate) *v1.RelationshipUpdate { + v1rel, err := UpdateToV1RelationshipUpdate(update) + if err != nil { + panic(err) + } + + return v1rel +} + +// UpdateFromV1RelationshipUpdate converts a RelationshipUpdate into a +// RelationTupleUpdate. +func UpdateFromV1RelationshipUpdate(update *v1.RelationshipUpdate) (RelationshipUpdate, error) { + var op UpdateOperation + switch update.Operation { + case v1.RelationshipUpdate_OPERATION_CREATE: + op = UpdateOperationCreate + case v1.RelationshipUpdate_OPERATION_DELETE: + op = UpdateOperationDelete + case v1.RelationshipUpdate_OPERATION_TOUCH: + op = UpdateOperationTouch + default: + return RelationshipUpdate{}, spiceerrors.MustBugf("unknown update operation: %v", update.Operation) + } + + return RelationshipUpdate{ + Operation: op, + Relationship: FromV1Relationship(update.Relationship), + }, nil +} + +// FromV1Relationship converts a v1.Relationship into a Relationship. +func FromV1Relationship(rel *v1.Relationship) Relationship { + var caveat *core.ContextualizedCaveat + if rel.OptionalCaveat != nil { + caveat = &core.ContextualizedCaveat{ + CaveatName: rel.OptionalCaveat.CaveatName, + Context: rel.OptionalCaveat.Context, + } + } + + var expiration *time.Time + if rel.OptionalExpiresAt != nil { + t := rel.OptionalExpiresAt.AsTime() + expiration = &t + } + + return Relationship{ + RelationshipReference: RelationshipReference{ + Resource: ObjectAndRelation{ + ObjectID: rel.Resource.ObjectId, + ObjectType: rel.Resource.ObjectType, + Relation: rel.Relation, + }, + Subject: ObjectAndRelation{ + ObjectID: rel.Subject.Object.ObjectId, + ObjectType: rel.Subject.Object.ObjectType, + Relation: stringz.Default(rel.Subject.OptionalRelation, Ellipsis, ""), + }, + }, + OptionalCaveat: caveat, + OptionalExpiration: expiration, + } +} + +// ToV1Relationship converts a Relationship into a v1.Relationship. +func ToV1Relationship(rel Relationship) *v1.Relationship { + var caveat *v1.ContextualizedCaveat + if rel.OptionalCaveat != nil { + caveat = &v1.ContextualizedCaveat{ + CaveatName: rel.OptionalCaveat.CaveatName, + Context: rel.OptionalCaveat.Context, + } + } + + var expiration *timestamppb.Timestamp + if rel.OptionalExpiration != nil { + expiration = timestamppb.New(*rel.OptionalExpiration) + } + + return &v1.Relationship{ + Resource: &v1.ObjectReference{ + ObjectType: rel.Resource.ObjectType, + ObjectId: rel.Resource.ObjectID, + }, + Relation: rel.Resource.Relation, + Subject: &v1.SubjectReference{ + Object: &v1.ObjectReference{ + ObjectType: rel.Subject.ObjectType, + ObjectId: rel.Subject.ObjectID, + }, + OptionalRelation: stringz.Default(rel.Subject.Relation, "", Ellipsis), + }, + OptionalCaveat: caveat, + OptionalExpiresAt: expiration, + } +} + +// CopyToV1Relationship copies a Relationship into a v1.Relationship. +func CopyToV1Relationship(rel Relationship, v1rel *v1.Relationship) { + v1rel.Resource.ObjectType = rel.Resource.ObjectType + v1rel.Resource.ObjectId = rel.Resource.ObjectID + v1rel.Relation = rel.Resource.Relation + v1rel.Subject.Object.ObjectType = rel.Subject.ObjectType + v1rel.Subject.Object.ObjectId = rel.Subject.ObjectID + v1rel.Subject.OptionalRelation = stringz.Default(rel.Subject.Relation, "", Ellipsis) + + if rel.OptionalCaveat != nil { + if v1rel.OptionalCaveat == nil { + v1rel.OptionalCaveat = &v1.ContextualizedCaveat{} + } + + v1rel.OptionalCaveat.CaveatName = rel.OptionalCaveat.CaveatName + v1rel.OptionalCaveat.Context = rel.OptionalCaveat.Context + } else { + v1rel.OptionalCaveat = nil + } + + if rel.OptionalExpiration != nil { + v1rel.OptionalExpiresAt = timestamppb.New(*rel.OptionalExpiration) + } else { + v1rel.OptionalExpiresAt = nil + } +} + +// UpdatesToV1RelationshipUpdates converts a slice of RelationshipUpdate into a +// slice of v1.RelationshipUpdate. +func UpdatesToV1RelationshipUpdates(updates []RelationshipUpdate) ([]*v1.RelationshipUpdate, error) { + relationshipUpdates := make([]*v1.RelationshipUpdate, 0, len(updates)) + + for _, update := range updates { + converted, err := UpdateToV1RelationshipUpdate(update) + if err != nil { + return nil, err + } + + relationshipUpdates = append(relationshipUpdates, converted) + } + + return relationshipUpdates, nil +} + +// UpdatesFromV1RelationshipUpdates converts a slice of v1.RelationshipUpdate into a +// slice of RelationshipUpdate. +func UpdatesFromV1RelationshipUpdates(updates []*v1.RelationshipUpdate) ([]RelationshipUpdate, error) { + relationshipUpdates := make([]RelationshipUpdate, 0, len(updates)) + + for _, update := range updates { + converted, err := UpdateFromV1RelationshipUpdate(update) + if err != nil { + return nil, err + } + + relationshipUpdates = append(relationshipUpdates, converted) + } + + return relationshipUpdates, nil +} + +// ToV1Filter converts a RelationTuple into a RelationshipFilter. +func ToV1Filter(rel Relationship) *v1.RelationshipFilter { + return &v1.RelationshipFilter{ + ResourceType: rel.Resource.ObjectType, + OptionalResourceId: rel.Resource.ObjectID, + OptionalRelation: rel.Resource.Relation, + OptionalSubjectFilter: SubjectONRToSubjectFilter(rel.Subject), + } +} + +// SubjectONRToSubjectFilter converts a userset to the equivalent exact SubjectFilter. +func SubjectONRToSubjectFilter(subject ObjectAndRelation) *v1.SubjectFilter { + return &v1.SubjectFilter{ + SubjectType: subject.ObjectType, + OptionalSubjectId: subject.ObjectID, + OptionalRelation: &v1.SubjectFilter_RelationFilter{ + Relation: stringz.Default(subject.Relation, "", Ellipsis), + }, + } +} + +// RelToFilter converts a Relationship into a RelationshipFilter. +func RelToFilter(rel *v1.Relationship) *v1.RelationshipFilter { + return &v1.RelationshipFilter{ + ResourceType: rel.Resource.ObjectType, + OptionalResourceId: rel.Resource.ObjectId, + OptionalRelation: rel.Relation, + OptionalSubjectFilter: &v1.SubjectFilter{ + SubjectType: rel.Subject.Object.ObjectType, + OptionalSubjectId: rel.Subject.Object.ObjectId, + OptionalRelation: &v1.SubjectFilter_RelationFilter{ + Relation: rel.Subject.OptionalRelation, + }, + }, + } +} diff --git a/vendor/github.com/authzed/spicedb/pkg/validationfile/blocks/assertions.go b/vendor/github.com/authzed/spicedb/pkg/validationfile/blocks/assertions.go new file mode 100644 index 0000000..56c4e6c --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/validationfile/blocks/assertions.go @@ -0,0 +1,147 @@ +package blocks + +import ( + "encoding/json" + "fmt" + "strings" + + "github.com/ccoveille/go-safecast" + yamlv3 "gopkg.in/yaml.v3" + + "github.com/authzed/spicedb/pkg/spiceerrors" + "github.com/authzed/spicedb/pkg/tuple" +) + +// Assertions represents assertions defined in the validation file. +type Assertions struct { + // AssertTrue is the set of relationships to assert true. + AssertTrue []Assertion `yaml:"assertTrue"` + + // AssertCaveated is the set of relationships to assert that are caveated. + AssertCaveated []Assertion `yaml:"assertCaveated"` + + // AssertFalse is the set of relationships to assert false. + AssertFalse []Assertion `yaml:"assertFalse"` + + // SourcePosition is the position of the assertions in the file. + SourcePosition spiceerrors.SourcePosition +} + +// Assertion is a parsed assertion. +type Assertion struct { + // RelationshipWithContextString is the string form of the assertion, including optional context. + // Forms: + // `document:firstdoc#view@user:tom` + // `document:seconddoc#view@user:sarah with {"some":"contexthere"}` + RelationshipWithContextString string + + // Relationship is the parsed relationship on which the assertion is being + // run. + Relationship tuple.Relationship + + // CaveatContext is the caveat context for the assertion, if any. + CaveatContext map[string]any + + // SourcePosition is the position of the assertion in the file. + SourcePosition spiceerrors.SourcePosition +} + +type internalAssertions struct { + // AssertTrue is the set of relationships to assert true. + AssertTrue []Assertion `yaml:"assertTrue"` + + // AssertCaveated is the set of relationships to assert that are caveated. + AssertCaveated []Assertion `yaml:"assertCaveated"` + + // AssertFalse is the set of relationships to assert false. + AssertFalse []Assertion `yaml:"assertFalse"` +} + +// UnmarshalYAML is a custom unmarshaller. +func (a *Assertions) UnmarshalYAML(node *yamlv3.Node) error { + ia := internalAssertions{} + if err := node.Decode(&ia); err != nil { + return convertYamlError(err) + } + + a.AssertTrue = ia.AssertTrue + a.AssertFalse = ia.AssertFalse + a.AssertCaveated = ia.AssertCaveated + a.SourcePosition = spiceerrors.SourcePosition{LineNumber: node.Line, ColumnPosition: node.Column} + return nil +} + +// UnmarshalYAML is a custom unmarshaller. +func (a *Assertion) UnmarshalYAML(node *yamlv3.Node) error { + relationshipWithContextString := "" + + if err := node.Decode(&relationshipWithContextString); err != nil { + return convertYamlError(err) + } + + trimmed := strings.TrimSpace(relationshipWithContextString) + + line, err := safecast.ToUint64(node.Line) + if err != nil { + return err + } + column, err := safecast.ToUint64(node.Column) + if err != nil { + return err + } + + // Check for caveat context. + parts := strings.SplitN(trimmed, " with ", 2) + if len(parts) == 0 { + return spiceerrors.NewWithSourceError( + fmt.Errorf("error parsing assertion `%s`", trimmed), + trimmed, + line, + column, + ) + } + + relationship, err := tuple.Parse(strings.TrimSpace(parts[0])) + if err != nil { + return spiceerrors.NewWithSourceError( + fmt.Errorf("error parsing relationship in assertion `%s`: %w", trimmed, err), + trimmed, + line, + column, + ) + } + + a.Relationship = relationship + + if len(parts) == 2 { + caveatContextMap := make(map[string]any, 0) + err := json.Unmarshal([]byte(parts[1]), &caveatContextMap) + if err != nil { + return spiceerrors.NewWithSourceError( + fmt.Errorf("error parsing caveat context in assertion `%s`: %w", trimmed, err), + trimmed, + line, + column, + ) + } + + a.CaveatContext = caveatContextMap + } + + a.RelationshipWithContextString = relationshipWithContextString + a.SourcePosition = spiceerrors.SourcePosition{LineNumber: node.Line, ColumnPosition: node.Column} + return nil +} + +// ParseAssertionsBlock parses the given contents as an assertions block. +func ParseAssertionsBlock(contents []byte) (*Assertions, error) { + a := internalAssertions{} + if err := yamlv3.Unmarshal(contents, &a); err != nil { + return nil, convertYamlError(err) + } + return &Assertions{ + AssertTrue: a.AssertTrue, + AssertCaveated: a.AssertCaveated, + AssertFalse: a.AssertFalse, + }, nil +} diff --git a/vendor/github.com/authzed/spicedb/pkg/validationfile/blocks/errors.go b/vendor/github.com/authzed/spicedb/pkg/validationfile/blocks/errors.go new file mode 100644 index 0000000..b30ef7a --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/validationfile/blocks/errors.go @@ -0,0 +1,47 @@ +package blocks + +import ( + "errors" + "fmt" + "regexp" + "strconv" + "strings" + + "github.com/authzed/spicedb/pkg/spiceerrors" +) + +var ( + yamlLineRegex = regexp.MustCompile(`line ([0-9]+): (.+)`) + yamlUnmarshalRegex = regexp.MustCompile("cannot unmarshal !!str `([^`]+)...`") +) + +func convertYamlError(err error) error { + linePieces := yamlLineRegex.FindStringSubmatch(err.Error()) + if len(linePieces) == 3 { + lineNumber, parseErr := strconv.ParseUint(linePieces[1], 10, 32) + if parseErr != nil { + lineNumber = 0 + } + + message := linePieces[2] + source := "" + unmarshalPieces := yamlUnmarshalRegex.FindStringSubmatch(message) + if len(unmarshalPieces) == 2 { + source = unmarshalPieces[1] + if strings.Contains(source, " ") { + source, _, _ = strings.Cut(source, " ") + } + + message = fmt.Sprintf("unexpected value `%s`", source) + } + + return spiceerrors.NewWithSourceError( + errors.New(message), + source, + lineNumber, + 0, + ) + } + + return err +} diff --git a/vendor/github.com/authzed/spicedb/pkg/validationfile/blocks/expectedrelations.go b/vendor/github.com/authzed/spicedb/pkg/validationfile/blocks/expectedrelations.go new file mode 100644 index 0000000..44f3b88 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/validationfile/blocks/expectedrelations.go @@ -0,0 +1,264 @@ +package blocks + +import ( + "fmt" + "regexp" + "slices" + "strings" + + yamlv3 "gopkg.in/yaml.v3" + + "github.com/ccoveille/go-safecast" + + "github.com/authzed/spicedb/pkg/spiceerrors" + "github.com/authzed/spicedb/pkg/tuple" +) + +// ParsedExpectedRelations represents the expected relations defined in the validation +// file. +type ParsedExpectedRelations struct { + // ValidationMap is the parsed expected relations validation map. + ValidationMap ValidationMap + + // SourcePosition is the position of the expected relations in the file. + SourcePosition spiceerrors.SourcePosition +} + +// UnmarshalYAML is a custom unmarshaller. +func (per *ParsedExpectedRelations) UnmarshalYAML(node *yamlv3.Node) error { + err := node.Decode(&per.ValidationMap) + if err != nil { + return convertYamlError(err) + } + + per.SourcePosition = spiceerrors.SourcePosition{LineNumber: node.Line, ColumnPosition: node.Column} + return nil +} + +// ValidationMap is a map from an Object Relation (as a Relationship) to the +// validation strings containing the Subjects for that Object Relation. +type ValidationMap map[ObjectRelation][]ExpectedSubject + +// ObjectRelation represents an ONR defined as a string in the key for +// the ValidationMap. +type ObjectRelation struct { + // ObjectRelationString is the string form of the object relation. + ObjectRelationString string + + // ObjectAndRelation is the parsed object and relation. + ObjectAndRelation tuple.ObjectAndRelation + + // SourcePosition is the position of the expected relations in the file. + SourcePosition spiceerrors.SourcePosition +} + +// UnmarshalYAML is a custom unmarshaller. +func (ors *ObjectRelation) UnmarshalYAML(node *yamlv3.Node) error { + err := node.Decode(&ors.ObjectRelationString) + if err != nil { + return convertYamlError(err) + } + + line, err := safecast.ToUint64(node.Line) + if err != nil { + return err + } + column, err := safecast.ToUint64(node.Column) + if err != nil { + return err + } + + parsed, err := tuple.ParseONR(ors.ObjectRelationString) + if err != nil { + return spiceerrors.NewWithSourceError( + fmt.Errorf("could not parse %s: %w", ors.ObjectRelationString, err), + ors.ObjectRelationString, + line, + column, + ) + } + + ors.ObjectAndRelation = parsed + ors.SourcePosition = spiceerrors.SourcePosition{LineNumber: node.Line, ColumnPosition: node.Column} + return nil +} + +var ( + vsSubjectRegex = regexp.MustCompile(`(.*?)\[(?P<user_str>.*)](.*?)`) + vsObjectAndRelationRegex = regexp.MustCompile(`(.*?)<(?P<onr_str>[^>]+)>(.*?)`) + vsSubjectWithExceptionsOrCaveatRegex = regexp.MustCompile(`^(?P<subject_onr>[^]\s]+)(?P<caveat>\[\.\.\.])?(\s+-\s+\{(?P<exceptions>[^}]+)})?$`) +) + +// ExpectedSubject is a subject expected for the ObjectAndRelation. +type ExpectedSubject struct { + // ValidationString holds a validation string containing a Subject and one or + // more Relations to the parent Object. + // Example: `[tenant/user:someuser#...] is <tenant/document:example#viewer>` + ValidationString ValidationString + + // Subject is the subject expected. May be nil if not defined in the line. + SubjectWithExceptions *SubjectWithExceptions + + // Resources are the resources under which the subject is found. + Resources []tuple.ObjectAndRelation + + // SourcePosition is the position of the expected subject in the file. + SourcePosition spiceerrors.SourcePosition +} + +// SubjectAndCaveat returns a subject and whether it is caveated. +type SubjectAndCaveat struct { + // Subject is the subject found. + Subject tuple.ObjectAndRelation + + // IsCaveated indicates whether the subject is caveated. + IsCaveated bool +} + +// SubjectWithExceptions returns the subject found in a validation string, along with any exceptions. +type SubjectWithExceptions struct { + // Subject is the subject found. + Subject SubjectAndCaveat + + // Exceptions are those subjects removed from the subject, if it is a wildcard. + Exceptions []SubjectAndCaveat +} + +// UnmarshalYAML is a custom unmarshaller. +func (es *ExpectedSubject) UnmarshalYAML(node *yamlv3.Node) error { + err := node.Decode(&es.ValidationString) + if err != nil { + return convertYamlError(err) + } + + line, err := safecast.ToUint64(node.Line) + if err != nil { + return err + } + column, err := safecast.ToUint64(node.Column) + if err != nil { + return err + } + + subjectWithExceptions, subErr := es.ValidationString.Subject() + if subErr != nil { + return spiceerrors.NewWithSourceError( + subErr, + subErr.SourceCodeString, + line+subErr.LineNumber, + column+subErr.ColumnPosition, + ) + } + + onrs, onrErr := es.ValidationString.ONRS() + if onrErr != nil { + return spiceerrors.NewWithSourceError( + onrErr, + onrErr.SourceCodeString, + line+onrErr.LineNumber, + column+onrErr.ColumnPosition, + ) + } + + es.SubjectWithExceptions = subjectWithExceptions + es.SourcePosition = spiceerrors.SourcePosition{LineNumber: node.Line, ColumnPosition: node.Column} + es.Resources = onrs + return nil +} + +// ValidationString holds a validation string containing a Subject and one or +// more Relations to the parent Object. +// Example: `[tenant/user:someuser#...] is <tenant/document:example#viewer>` +type ValidationString string + +// SubjectString returns the subject contained in the ValidationString, if any. +func (vs ValidationString) SubjectString() (string, bool) { + result := vsSubjectRegex.FindStringSubmatch(string(vs)) + if len(result) != 4 { + return "", false + } + + return result[2], true +} + +// Subject returns the subject contained in the ValidationString, if any. If +// none, returns nil. +func (vs ValidationString) Subject() (*SubjectWithExceptions, *spiceerrors.WithSourceError) { + subjectStr, ok := vs.SubjectString() + if !ok { + return nil, nil + } + + subjectStr = strings.TrimSpace(subjectStr) + groups := vsSubjectWithExceptionsOrCaveatRegex.FindStringSubmatch(subjectStr) + if len(groups) == 0 { + bracketedSubjectString := "[" + subjectStr + "]" + return nil, spiceerrors.NewWithSourceError(fmt.Errorf("invalid subject: `%s`", subjectStr), bracketedSubjectString, 0, 0) + } + + subjectONRString := groups[slices.Index(vsSubjectWithExceptionsOrCaveatRegex.SubexpNames(), "subject_onr")] + subjectONR, err := tuple.ParseSubjectONR(subjectONRString) + if err != nil { + return nil, spiceerrors.NewWithSourceError(fmt.Errorf("invalid subject: `%s`: %w", subjectONRString, err), subjectONRString, 0, 0) + } + + exceptionsString := strings.TrimSpace(groups[slices.Index(vsSubjectWithExceptionsOrCaveatRegex.SubexpNames(), "exceptions")]) + var exceptions []SubjectAndCaveat + + if len(exceptionsString) > 0 { + exceptionsStringsSlice := strings.Split(exceptionsString, ",") + exceptions = make([]SubjectAndCaveat, 0, len(exceptionsStringsSlice)) + for _, exceptionString := range exceptionsStringsSlice { + isCaveated := false + if strings.HasSuffix(exceptionString, "[...]") { + exceptionString = strings.TrimSuffix(exceptionString, "[...]") + isCaveated = true + } + + exceptionONR, err := tuple.ParseSubjectONR(strings.TrimSpace(exceptionString)) + if err != nil { + return nil, spiceerrors.NewWithSourceError(fmt.Errorf("invalid subject: `%s`: %w", exceptionString, err), exceptionString, 0, 0) + } + + exceptions = append(exceptions, SubjectAndCaveat{exceptionONR, isCaveated}) + } + } + + isCaveated := len(strings.TrimSpace(groups[slices.Index(vsSubjectWithExceptionsOrCaveatRegex.SubexpNames(), "caveat")])) > 0 + return &SubjectWithExceptions{SubjectAndCaveat{subjectONR, isCaveated}, exceptions}, nil +} + +// ONRStrings returns the ONRs contained in the ValidationString, if any. +func (vs ValidationString) ONRStrings() []string { + results := vsObjectAndRelationRegex.FindAllStringSubmatch(string(vs), -1) + onrStrings := []string{} + for _, result := range results { + onrStrings = append(onrStrings, result[2]) + } + return onrStrings +} + +// ONRS returns the subject ONRs in the ValidationString, if any. +func (vs ValidationString) ONRS() ([]tuple.ObjectAndRelation, *spiceerrors.WithSourceError) { + onrStrings := vs.ONRStrings() + onrs := []tuple.ObjectAndRelation{} + for _, onrString := range onrStrings { + found, err := tuple.ParseONR(onrString) + if err != nil { + return nil, spiceerrors.NewWithSourceError(fmt.Errorf("invalid resource and relation: `%s`: %w", onrString, err), onrString, 0, 0) + } + + onrs = append(onrs, found) + } + return onrs, nil +} + +// ParseExpectedRelationsBlock parses the given contents as an expected relations block. +func ParseExpectedRelationsBlock(contents []byte) (*ParsedExpectedRelations, error) { + per := ParsedExpectedRelations{} + err := yamlv3.Unmarshal(contents, &per) + if err != nil { + return nil, convertYamlError(err) + } + return &per, nil +} diff --git a/vendor/github.com/authzed/spicedb/pkg/validationfile/blocks/relationships.go b/vendor/github.com/authzed/spicedb/pkg/validationfile/blocks/relationships.go new file mode 100644 index 0000000..278c7a8 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/validationfile/blocks/relationships.go @@ -0,0 +1,83 @@ +package blocks + +import ( + "fmt" + "strings" + + "github.com/ccoveille/go-safecast" + yamlv3 "gopkg.in/yaml.v3" + + "github.com/authzed/spicedb/pkg/spiceerrors" + "github.com/authzed/spicedb/pkg/tuple" +) + +// ParsedRelationships is the parsed relationships in a validationfile. +type ParsedRelationships struct { + // RelationshipsString is the found string of newline-separated relationships. + RelationshipsString string + + // SourcePosition is the position of the schema in the file. + SourcePosition spiceerrors.SourcePosition + + // Relationships are the fully parsed relationships. + Relationships []tuple.Relationship +} + +// UnmarshalYAML is a custom unmarshaller. +func (pr *ParsedRelationships) UnmarshalYAML(node *yamlv3.Node) error { + err := node.Decode(&pr.RelationshipsString) + if err != nil { + return convertYamlError(err) + } + + relationshipsString := pr.RelationshipsString + if relationshipsString == "" { + return nil + } + + seenTuples := map[string]bool{} + lines := strings.Split(relationshipsString, "\n") + relationships := make([]tuple.Relationship, 0, len(lines)) + for index, line := range lines { + trimmed := strings.TrimSpace(line) + if len(trimmed) == 0 || strings.HasPrefix(trimmed, "//") { + continue + } + + // +1 for the key, and *2 for newlines in YAML + errorLine, err := safecast.ToUint64(node.Line + 1 + (index * 2)) + if err != nil { + return err + } + column, err := safecast.ToUint64(node.Column) + if err != nil { + return err + } + + rel, err := tuple.Parse(trimmed) + if err != nil { + return spiceerrors.NewWithSourceError( + fmt.Errorf("error parsing relationship `%s`: %w", trimmed, err), + trimmed, + errorLine, + column, + ) + } + + _, ok := seenTuples[tuple.StringWithoutCaveatOrExpiration(rel)] + if ok { + return spiceerrors.NewWithSourceError( + fmt.Errorf("found repeated relationship `%s`", trimmed), + trimmed, + errorLine, + column, + ) + } + seenTuples[tuple.StringWithoutCaveatOrExpiration(rel)] = true + relationships = append(relationships, rel) + } + + pr.Relationships = relationships + pr.SourcePosition = spiceerrors.SourcePosition{LineNumber: node.Line, ColumnPosition: node.Column} + return nil +} diff --git a/vendor/github.com/authzed/spicedb/pkg/validationfile/blocks/schema.go b/vendor/github.com/authzed/spicedb/pkg/validationfile/blocks/schema.go new file mode 100644 index 0000000..814eebc --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/validationfile/blocks/schema.go @@ -0,0 +1,70 @@ +package blocks + +import ( + "errors" + "fmt" + + yamlv3 "gopkg.in/yaml.v3" + + "github.com/ccoveille/go-safecast" + + "github.com/authzed/spicedb/pkg/schemadsl/compiler" + "github.com/authzed/spicedb/pkg/schemadsl/input" + "github.com/authzed/spicedb/pkg/spiceerrors" +) + +// ParsedSchema is the parsed schema in a validationfile. +type ParsedSchema struct { + // Schema is the schema found. + Schema string + + // SourcePosition is the position of the schema in the file. + SourcePosition spiceerrors.SourcePosition + + // CompiledSchema is the compiled schema. + CompiledSchema *compiler.CompiledSchema +} + +// UnmarshalYAML is a custom unmarshaller. +func (ps *ParsedSchema) UnmarshalYAML(node *yamlv3.Node) error { + err := node.Decode(&ps.Schema) + if err != nil { + return convertYamlError(err) + } + + compiled, err := compiler.Compile(compiler.InputSchema{ + Source: input.Source("schema"), + SchemaString: ps.Schema, + }, compiler.AllowUnprefixedObjectType()) + if err != nil { + var errWithContext compiler.WithContextError + if errors.As(err, &errWithContext) { + line, col, lerr := errWithContext.SourceRange.Start().LineAndColumn() + if lerr != nil { + return lerr + } + + uintLine, err := safecast.ToUint64(line) + if err != nil { + return err + } + uintCol, err := safecast.ToUint64(col) + if err != nil { + return err + } + + return spiceerrors.NewWithSourceError( + fmt.Errorf("error when parsing schema: %s", errWithContext.BaseMessage), + errWithContext.ErrorSourceCode, + uintLine+1, // source line is 0-indexed + uintCol+1, // source col is 0-indexed + ) + } + + return fmt.Errorf("error when parsing schema: %w", err) + } + + ps.CompiledSchema = compiled + ps.SourcePosition = spiceerrors.SourcePosition{LineNumber: node.Line, ColumnPosition: node.Column} + return nil +} diff --git a/vendor/github.com/authzed/spicedb/pkg/validationfile/doc.go b/vendor/github.com/authzed/spicedb/pkg/validationfile/doc.go new file mode 100644 index 0000000..eee5323 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/validationfile/doc.go @@ -0,0 +1,2 @@ +// Package validationfile contains code to manipulate files accepted by the `zed validate` CLI. +package validationfile diff --git a/vendor/github.com/authzed/spicedb/pkg/validationfile/fileformat.go b/vendor/github.com/authzed/spicedb/pkg/validationfile/fileformat.go new file mode 100644 index 0000000..8f965a2 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/validationfile/fileformat.go @@ -0,0 +1,55 @@ +package validationfile + +import ( + yamlv3 "gopkg.in/yaml.v3" + + "github.com/authzed/spicedb/pkg/validationfile/blocks" +) + +// DecodeValidationFile decodes the validation file as found in the contents bytes +// and returns it. +func DecodeValidationFile(contents []byte) (*ValidationFile, error) { + p := ValidationFile{} + err := yamlv3.Unmarshal(contents, &p) + if err != nil { + return nil, err + } + return &p, nil +} + +// ValidationFile is a structural representation of the validation file format. +type ValidationFile struct { + // Schema is the schema. + Schema blocks.ParsedSchema `yaml:"schema"` + + // Relationships are the relationships specified in the validation file. + Relationships blocks.ParsedRelationships `yaml:"relationships"` + + // Assertions are the assertions defined in the validation file. May be nil + // if no assertions are defined. + Assertions blocks.Assertions `yaml:"assertions"` + + // ExpectedRelations is the map of expected relations. + ExpectedRelations blocks.ParsedExpectedRelations `yaml:"validation"` + + // NamespaceConfigs are the namespace configuration protos, in text format. + // Deprecated: only for internal use. Use `schema`. + NamespaceConfigs []string `yaml:"namespace_configs"` + + // ValidationTuples are the validation tuples, in tuple string syntax. + // Deprecated: only for internal use. Use `relationships`. + ValidationTuples []string `yaml:"validation_tuples"` + + // Schema file represents the path specified for the schema file + SchemaFile string `yaml:"schemaFile"` +} + +// ParseAssertionsBlock parses the given contents as an assertions block. +func ParseAssertionsBlock(contents []byte) (*blocks.Assertions, error) { + return blocks.ParseAssertionsBlock(contents) +} + +// ParseExpectedRelationsBlock parses the given contents as an expected relations block. +func ParseExpectedRelationsBlock(contents []byte) (*blocks.ParsedExpectedRelations, error) { + return blocks.ParseExpectedRelationsBlock(contents) +} diff --git a/vendor/github.com/authzed/spicedb/pkg/validationfile/loader.go b/vendor/github.com/authzed/spicedb/pkg/validationfile/loader.go new file mode 100644 index 0000000..d3322b6 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/validationfile/loader.go @@ -0,0 +1,172 @@ +package validationfile + +import ( + "context" + "fmt" + "os" + + log "github.com/authzed/spicedb/internal/logging" + dsctx "github.com/authzed/spicedb/internal/middleware/datastore" + "github.com/authzed/spicedb/internal/namespace" + "github.com/authzed/spicedb/internal/relationships" + caveattypes "github.com/authzed/spicedb/pkg/caveats/types" + "github.com/authzed/spicedb/pkg/datastore" + "github.com/authzed/spicedb/pkg/genutil/slicez" + core "github.com/authzed/spicedb/pkg/proto/core/v1" + "github.com/authzed/spicedb/pkg/schema" + "github.com/authzed/spicedb/pkg/tuple" +) + +// PopulatedValidationFile contains the fully parsed information from a validation file. +type PopulatedValidationFile struct { + // Schema is the entered schema text, if any. + Schema string + + // NamespaceDefinitions are the namespaces defined in the validation file, in either + // direct or compiled from schema form. + NamespaceDefinitions []*core.NamespaceDefinition + + // CaveatDefinitions are the caveats defined in the validation file, in either + // direct or compiled from schema form. + CaveatDefinitions []*core.CaveatDefinition + + // Relationships are the relationships defined in the validation file, either directly + // or in the relationships block. + Relationships []tuple.Relationship + + // ParsedFiles are the underlying parsed validation files. + ParsedFiles []ValidationFile +} + +// PopulateFromFiles populates the given datastore with the namespaces and tuples found in +// the validation file(s) specified. +func PopulateFromFiles(ctx context.Context, ds datastore.Datastore, caveatTypeSet *caveattypes.TypeSet, filePaths []string) (*PopulatedValidationFile, datastore.Revision, error) { + contents := map[string][]byte{} + + for _, filePath := range filePaths { + fileContents, err := os.ReadFile(filePath) + if err != nil { + return nil, datastore.NoRevision, err + } + + contents[filePath] = fileContents + } + + return PopulateFromFilesContents(ctx, ds, caveatTypeSet, contents) +} + +// PopulateFromFilesContents populates the given datastore with the namespaces and tuples found in +// the validation file(s) contents specified. +func PopulateFromFilesContents(ctx context.Context, ds datastore.Datastore, caveatTypeSet *caveattypes.TypeSet, filesContents map[string][]byte) (*PopulatedValidationFile, datastore.Revision, error) { + var schemaStr string + var objectDefs []*core.NamespaceDefinition + var caveatDefs []*core.CaveatDefinition + var rels []tuple.Relationship + var updates []tuple.RelationshipUpdate + + var revision datastore.Revision + + files := make([]ValidationFile, 0, len(filesContents)) + + // Parse each file into definitions and relationship updates. + for filePath, fileContents := range filesContents { + // Decode the validation file. + parsed, err := DecodeValidationFile(fileContents) + if err != nil { + return nil, datastore.NoRevision, fmt.Errorf("error when parsing config file %s: %w", filePath, err) + } + + files = append(files, *parsed) + + // Disallow legacy sections. + if len(parsed.NamespaceConfigs) > 0 { + return nil, revision, fmt.Errorf("definitions must be specified in `schema`") + } + + if len(parsed.ValidationTuples) > 0 { + return nil, revision, fmt.Errorf("relationships must be specified in `relationships`") + } + + // Add schema definitions. + if parsed.Schema.CompiledSchema != nil { + defs := parsed.Schema.CompiledSchema.ObjectDefinitions + if len(defs) > 0 { + schemaStr += parsed.Schema.Schema + "\n\n" + } + + log.Ctx(ctx).Info().Str("filePath", filePath). + Int("definitionCount", len(defs)). + Int("caveatDefinitionCount", len(parsed.Schema.CompiledSchema.CaveatDefinitions)). + Int("schemaDefinitionCount", len(parsed.Schema.CompiledSchema.OrderedDefinitions)). + Msg("adding schema definitions") + + objectDefs = append(objectDefs, defs...) + caveatDefs = append(caveatDefs, parsed.Schema.CompiledSchema.CaveatDefinitions...) + } + + // Parse relationships for updates. + for _, rel := range parsed.Relationships.Relationships { + updates = append(updates, tuple.Touch(rel)) + rels = append(rels, rel) + } + } + + // Load the definitions and relationships into the datastore. + revision, err := ds.ReadWriteTx(ctx, func(ctx context.Context, rwt datastore.ReadWriteTransaction) error { + // Write the caveat definitions. + err := rwt.WriteCaveats(ctx, caveatDefs) + if err != nil { + return err + } + + res := schema.ResolverForDatastoreReader(rwt).WithPredefinedElements(schema.PredefinedElements{ + Definitions: objectDefs, + Caveats: caveatDefs, + }) + ts := schema.NewTypeSystem(res) + // Validate and write the object definitions. + for _, objectDef := range objectDefs { + ctx := dsctx.ContextWithDatastore(ctx, ds) + vts, terr := ts.GetValidatedDefinition(ctx, objectDef.GetName()) + if terr != nil { + return terr + } + + aerr := namespace.AnnotateNamespace(vts) + if aerr != nil { + return aerr + } + + if err := rwt.WriteNamespaces(ctx, objectDef); err != nil { + return fmt.Errorf("error when loading object definition %s: %w", objectDef.Name, err) + } + } + + return err + }) + + slicez.ForEachChunk(updates, 500, func(chunked []tuple.RelationshipUpdate) { + if err != nil { + return + } + + chunkedRels := make([]tuple.Relationship, 0, len(chunked)) + for _, update := range chunked { + chunkedRels = append(chunkedRels, update.Relationship) + } + revision, err = ds.ReadWriteTx(ctx, func(ctx context.Context, rwt datastore.ReadWriteTransaction) error { + err = relationships.ValidateRelationshipsForCreateOrTouch(ctx, rwt, caveatTypeSet, chunkedRels...) + if err != nil { + return err + } + + return rwt.WriteRelationships(ctx, chunked) + }) + }) + + if err != nil { + return nil, nil, err + } + + return &PopulatedValidationFile{schemaStr, objectDefs, caveatDefs, rels, files}, revision, err +} diff --git a/vendor/github.com/authzed/spicedb/pkg/x509util/doc.go b/vendor/github.com/authzed/spicedb/pkg/x509util/doc.go new file mode 100644 index 0000000..fe15c75 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/x509util/doc.go @@ -0,0 +1,2 @@ +// Package x509util contains helper functions to deal with certificates. +package x509util diff --git a/vendor/github.com/authzed/spicedb/pkg/x509util/x509util.go b/vendor/github.com/authzed/spicedb/pkg/x509util/x509util.go new file mode 100644 index 0000000..01be836 --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/x509util/x509util.go @@ -0,0 +1,61 @@ +package x509util + +import ( + "crypto/x509" + "errors" + "io/fs" + "os" +) + +// CustomCertPool creates a x509.CertPool from a filepath string. +// +// If the path is a directory, it walks the directory and adds all files to the +// pool. +func CustomCertPool(caPath string) (*x509.CertPool, error) { + fi, err := os.Stat(caPath) + if err != nil { + return nil, err + } + + var caFiles [][]byte + if fi.IsDir() { + caFiles, err = dirContents(caPath) + if err != nil { + return nil, err + } + } else { + contents, err := os.ReadFile(caPath) + if err != nil { + return nil, err + } + caFiles = append(caFiles, contents) + } + + certPool := x509.NewCertPool() + for _, caBytes := range caFiles { + if ok := certPool.AppendCertsFromPEM(caBytes); !ok { + return nil, errors.New("failed to append certs from CA PEM") + } + } + + return certPool, nil +} + +func dirContents(dirPath string) ([][]byte, error) { + var allContents [][]byte + dirFS := os.DirFS(dirPath) + if err := fs.WalkDir(dirFS, ".", func(path string, d fs.DirEntry, err error) error { + if !d.IsDir() { + contents, err := fs.ReadFile(dirFS, d.Name()) + if err != nil { + return err + } + allContents = append(allContents, contents) + } + return nil + }); err != nil { + return nil, err + } + + return allContents, nil +} diff --git a/vendor/github.com/authzed/spicedb/pkg/zedtoken/doc.go b/vendor/github.com/authzed/spicedb/pkg/zedtoken/doc.go new file mode 100644 index 0000000..2143b0c --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/zedtoken/doc.go @@ -0,0 +1,2 @@ +// Package zedtoken contains helper functions to handle zedtokens. +package zedtoken diff --git a/vendor/github.com/authzed/spicedb/pkg/zedtoken/zedtoken.go b/vendor/github.com/authzed/spicedb/pkg/zedtoken/zedtoken.go new file mode 100644 index 0000000..7cefa1b --- /dev/null +++ b/vendor/github.com/authzed/spicedb/pkg/zedtoken/zedtoken.go @@ -0,0 +1,107 @@ +package zedtoken + +import ( + "encoding/base64" + "errors" + "fmt" + + v1 "github.com/authzed/authzed-go/proto/authzed/api/v1" + + "github.com/authzed/spicedb/pkg/datastore" + zedtoken "github.com/authzed/spicedb/pkg/proto/impl/v1" +) + +// Public facing errors +const ( + errEncodeError = "error encoding zedtoken: %w" + errDecodeError = "error decoding zedtoken: %w" +) + +// ErrNilZedToken is returned as the base error when nil is provided as the +// zedtoken argument to Decode +var ErrNilZedToken = errors.New("zedtoken pointer was nil") + +// MustNewFromRevision generates an encoded zedtoken from an integral revision. +func MustNewFromRevision(revision datastore.Revision) *v1.ZedToken { + encoded, err := NewFromRevision(revision) + if err != nil { + panic(err) + } + return encoded +} + +// NewFromRevision generates an encoded zedtoken from an integral revision. +func NewFromRevision(revision datastore.Revision) (*v1.ZedToken, error) { + toEncode := &zedtoken.DecodedZedToken{ + VersionOneof: &zedtoken.DecodedZedToken_V1{ + V1: &zedtoken.DecodedZedToken_V1ZedToken{ + Revision: revision.String(), + }, + }, + } + encoded, err := Encode(toEncode) + if err != nil { + return nil, fmt.Errorf(errEncodeError, err) + } + + return encoded, nil +} + +// Encode converts a decoded zedtoken to its opaque version. +func Encode(decoded *zedtoken.DecodedZedToken) (*v1.ZedToken, error) { + marshalled, err := decoded.MarshalVT() + if err != nil { + return nil, fmt.Errorf(errEncodeError, err) + } + return &v1.ZedToken{ + Token: base64.StdEncoding.EncodeToString(marshalled), + }, nil +} + +// Decode converts an encoded zedtoken to its decoded version. +func Decode(encoded *v1.ZedToken) (*zedtoken.DecodedZedToken, error) { + if encoded == nil { + return nil, fmt.Errorf(errDecodeError, ErrNilZedToken) + } + + decodedBytes, err := base64.StdEncoding.DecodeString(encoded.Token) + if err != nil { + return nil, fmt.Errorf(errDecodeError, err) + } + decoded := &zedtoken.DecodedZedToken{} + if err := decoded.UnmarshalVT(decodedBytes); err != nil { + return nil, fmt.Errorf(errDecodeError, err) + } + return decoded, nil +} + +// DecodeRevision converts and extracts the revision from a zedtoken or legacy zookie. +func DecodeRevision(encoded *v1.ZedToken, ds revisionDecoder) (datastore.Revision, error) { + decoded, err := Decode(encoded) + if err != nil { + return datastore.NoRevision, err + } + + switch ver := decoded.VersionOneof.(type) { + case *zedtoken.DecodedZedToken_DeprecatedV1Zookie: + revString := fmt.Sprintf("%d", ver.DeprecatedV1Zookie.Revision) + parsed, err := ds.RevisionFromString(revString) + if err != nil { + return datastore.NoRevision, fmt.Errorf(errDecodeError, err) + } + return parsed, nil + + case *zedtoken.DecodedZedToken_V1: + parsed, err := ds.RevisionFromString(ver.V1.Revision) + if err != nil { + return datastore.NoRevision, fmt.Errorf(errDecodeError, err) + } + return parsed, nil + default: + return datastore.NoRevision, fmt.Errorf(errDecodeError, fmt.Errorf("unknown zookie version: %T", decoded.VersionOneof)) + } +} + +type revisionDecoder interface { + RevisionFromString(string) (datastore.Revision, error) +} |
