package
0.37.26
Repository: https://github.com/meta-quick/opax.git
Documentation: pkg.go.dev

# Packages

Package location defines locations in Rego source code.

# Functions

ArrayComprehensionTerm creates a new Term with an ArrayComprehension value.
ArrayTerm creates a new Term with an Array value.
As converts v into a Go native type referred to by x.
BooleanTerm creates a new Term with a Boolean value.
CallTerm returns a new Term with a Call value defined by terms.
CapabilitiesForThisVersion returns the capabilities of this version of OPA.
CheckPathConflicts returns a set of errors indicating paths that are in conflict with the result of the provided callable.
Compare returns an integer indicating whether two AST values are less than, equal to, or greater than each other.
CompileModules takes a set of Rego modules represented as strings and compiles them for evaluation.
CompileModulesWithOpt takes a set of Rego modules represented as strings and compiles them for evaluation.
ContainsClosures returns true if the Value v contains closures.
ContainsComprehensions returns true if the Value v contains comprehensions.
ContainsRefs returns true if the Value v contains refs.
Copy returns a deep copy of the AST node x.
EmptyRef returns a new, empty reference.
FloatNumberTerm creates a new Term with a floating point Number value.
InterfaceToValue converts a native Go value x to a Value.
IntNumberTerm creates a new Term with an integer Number value.
IsComprehension returns true if the supplied value is a comprehension.
IsConstant returns true if the AST value is constant.
IsError returns true if err is an AST error with code.
IsKeyword returns true if s is a language keyword.
IsScalar returns true if the AST value is a scalar.
IsUnknownValueErr returns true if the err is an UnknownValueErr.
IsValidImportPath returns an error indicating if the import path is invalid.
Item is a helper for constructing an tuple containing two Terms representing a key/value pair in an Object.
JSON returns the JSON representation of v.
JSONWithOpt returns the JSON representation of v.
LoadCapabilitiesJSON loads a JSON serialized capabilities structure from the reader r.
MustCompileModules compiles a set of Rego modules represented as strings.
MustCompileModulesWithOpts compiles a set of Rego modules represented as strings.
MustInterfaceToValue converts a native Go value x to a Value.
MustJSON returns the JSON representation of v.
MustParseBody returns a parsed body.
MustParseBodyWithOpts returns a parsed body.
MustParseExpr returns a parsed expression.
MustParseImports returns a slice of imports.
MustParseModule returns a parsed module.
MustParseModuleWithOpts returns a parsed module.
MustParsePackage returns a Package.
MustParseRef returns a parsed reference.
MustParseRule returns a parsed rule.
MustParseStatement returns exactly one statement.
MustParseStatements returns a slice of parsed statements.
MustParseTerm returns a parsed term.
NewArray creates an Array with the terms provided.
NewBeforeAfterVisitor returns a new BeforeAndAfterVisitor that will invoke the functions before and after AST nodes.
NewBody returns a new Body containing the given expressions.
NewBuiltinExpr creates a new Expr object with the supplied terms.
NewComment returns a new Comment object.
NewCompiler returns a new empty compiler.
NewError returns a new Error object.
NewExpr returns a new Expr object.
NewGenericTransformer returns a new GenericTransformer that will transform AST nodes using the function f.
NewGenericVisitor returns a new GenericVisitor that will invoke the function f on AST nodes.
NewGraph returns a new Graph based on modules.
NewGraphTraversal returns a Traversal for the dependency graph.
NewHead returns a new Head object.
NewIndexResult returns a new IndexResult object.
NewLocation returns a new Location object.
NewModuleTree returns a new ModuleTreeNode that represents the root of the module tree populated with the given modules.
NewObject creates a new Object with t.
NewParser creates and initializes a Parser.
NewQueryContext returns a new QueryContext object.
NewRuleSet returns a new RuleSet containing the given rules.
NewRuleTree returns a new TreeNode that represents the root of the rule tree populated with the given rules.
NewSchemaSet returns an empty SchemaSet.
NewSet returns a new Set containing t.
NewTerm returns a new Term object.
NewValueMap returns a new ValueMap.
NewVarSet returns a new VarSet containing the specified variables.
NewVarVisitor returns a new VarVisitor object.
NullTerm creates a new Term with a Null value.
NumberTerm creates a new Term with a Number value.
ObjectComprehensionTerm creates a new Term with an ObjectComprehension value.
ObjectTerm creates a new Term with an Object value.
OutputVarsFromBody returns all variables which are the "output" for the given body.
OutputVarsFromExpr returns all variables which are the "output" for the given expression.
ParseBody returns exactly one body.
No description provided by the author
ParseCompleteDocRuleFromAssignmentExpr returns a rule if the expression can be interpreted as a complete document definition declared with the assignment operator.
ParseCompleteDocRuleFromEqExpr returns a rule if the expression can be interpreted as a complete document definition.
ParseExpr returns exactly one expression.
ParseImports returns a slice of Import objects.
ParseModule returns a parsed Module object.
ParseModuleWithOpts returns a parsed Module object, and has an additional input ParserOptions For details on Module objects and their fields, see policy.go.
ParsePackage returns exactly one Package.
ParsePartialObjectDocRuleFromEqExpr returns a rule if the expression can be interpreted as a partial object document definition.
ParsePartialSetDocRuleFromTerm returns a rule if the term can be interpreted as a partial set document definition.
ParseRef returns exactly one reference.
ParseRule returns exactly one rule.
ParseRuleFromBody returns a rule if the body can be interpreted as a rule definition.
ParseRuleFromCallEqExpr returns a rule if the term can be interpreted as a function definition (e.g., f(x) = y => f(x) = y { true }).
ParseRuleFromCallExpr returns a rule if the terms can be interpreted as a function returning true or some value (e.g., f(x) => f(x) = true { true }).
ParseRuleFromExpr returns a rule if the expression can be interpreted as a rule definition.
ParseStatement returns exactly one statement.
ParseStatements is deprecated.
ParseStatementsWithOpts returns a slice of parsed statements.
ParseTerm returns exactly one term.
Pretty writes a pretty representation of the AST rooted at x to w.
PtrRef returns a new reference against the head for the pointer s.
RefTerm creates a new Term with a Ref value.
RegisterBuiltin adds a new built-in function to the registry.
SetComprehensionTerm creates a new Term with an SetComprehension value.
SetTerm returns a new Term representing a set containing terms t.
StringTerm creates a new Term with a String value.
Transform iterates the AST and calls the Transform function on the Transformer t for x before recursing.
TransformComprehensions calls the functio nf on all comprehensions under x.
TransformRefs calls the function f on all references under x.
TransformVars calls the function f on all vars under x.
TypeName returns a human readable name for the AST element type.
UIntNumberTerm creates a new Term with an unsigned integer Number value.
Unify returns a set of variables that will be unified when the equality expression defined by terms a and b is evaluated.
ValueFromReader returns an AST value from a JSON serialized value in the reader.
ValueToInterface returns the Go representation of an AST value.
No description provided by the author
VarTerm creates a new Term with a Variable value.
Walk iterates the AST by calling the Visit function on the Visitor v for x before recursing.
WalkBeforeAndAfter iterates the AST by calling the Visit function on the Visitor v for x before recursing.
WalkBodies calls the function f on all bodies under x.
WalkClosures calls the function f on all closures under x.
WalkExprs calls the function f on all expressions under x.
WalkNodes calls the function f on all nodes under x.
WalkRefs calls the function f on all references under x.
WalkRules calls the function f on all rules under x.
WalkTerms calls the function f on all terms under x.
WalkVars calls the function f on all vars under x.
WalkWiths calls the function f on all with modifiers under x.

# Constants

CompileErr indicates an unclassified compile error occurred.
CompileErrorLimitDefault is the default number errors a compiler will allow before exiting.
CompleteDoc represents a document that is completely defined by the rule.
ParseErr indicates an unclassified parse error occurred.
PartialObjectDoc represents an object document that is partially defined by the rule.
PartialSetDoc represents a set document that is partially defined by the rule.
RecursionErr indicates recursion was found during compilation.
TypeErr indicates a type error was caught.
UnsafeVarErr indicates an unsafe variable was found during compilation.

# Variables

Abs returns the number without its sign.
AddDate returns the nanoseconds since epoch after adding years, months and days to nanoseconds.
All takes a list and returns true if all of the items are true.
And performs an intersection operation on sets.
Any takes a collection and returns true if any of the items is true.
ArrayConcat returns the result of concatenating two arrays together.
ArrayReverse returns a given array, reversed.
ArraySlice returns a slice of a given array.
Assign represents the assignment (":=") operator.
Base64Decode deserializes the base64 encoded input string.
Base64Encode serializes the input string into base64 encoding.
Base64IsValid verifies the input string is base64 encoded.
Base64UrlDecode deserializes the base64url encoded input string.
Base64UrlEncode serializes the input string into base64url encoding.
Base64UrlEncodeNoPad serializes the input string into base64url encoding without padding.
BitsAnd returns the bitwise "and" of two integers.
BitsNegate returns the bitwise "negation" of an integer (i.e.
BitsOr returns the bitwise "or" of two integers.
BitsShiftLeft returns a new integer with its bits shifted some value to the left.
BitsShiftRight returns a new integer with its bits shifted some value to the right.
BitsXOr returns the bitwise "exclusive-or" of two integers.
BuiltinMap provides a convenient mapping of built-in names to built-in definitions.
Builtins is the registry of built-in functions supported by OPA.
CastArray checks the underlying type of the input.
CastBoolean returns input if it is a boolean; if not returns error.
CastNull returns null if input is null; if not returns error.
CastObject returns the given object if it is null; throws an error otherwise.
CastSet checks the underlying type of the input.
CastString returns input if it is a string; if not returns error.
Ceil rounds the number up to the nearest integer.
Clock returns the [hour, minute, second] of the day for the nanoseconds since epoch.
Concat joins an array of strings with an input string.
Contains returns true if the search string is included in the base string.
Count takes a collection or string and counts the number of elements in it.
CryptoHmacMd5 returns a string representing the MD-5 HMAC of the input message using the input key Inputs are message, key.
CryptoHmacSha1 returns a string representing the SHA-1 HMAC of the input message using the input key Inputs are message, key.
CryptoHmacSha256 returns a string representing the SHA-256 HMAC of the input message using the input key Inputs are message, key.
CryptoHmacSha512 returns a string representing the SHA-512 HMAC of the input message using the input key Inputs are message, key.
CryptoMd5 returns a string representing the input string hashed with the md5 function.
CryptoSha1 returns a string representing the input string hashed with the sha1 function.
CryptoSha256 returns a string representing the input string hashed with the sha256 function.
CryptoX509ParseAndVerifyCertificates returns one or more certificates from the given string containing PEM or base64 encoded DER certificates after verifying the supplied certificates form a complete certificate chain back to a trusted root.
CryptoX509ParseCertificateRequest returns a PKCS #10 certificate signing request from the given PEM-encoded PKCS#10 certificate signing request.
CryptoX509ParseCertificates returns one or more certificates from the given base64 encoded string containing DER encoded certificates that have been concatenated.
CryptoX509ParseRSAPrivateKey returns a JWK for signing a JWT from the given PEM-encoded RSA private key.
Date returns the [year, month, day] for the nanoseconds since epoch.
DefaultBuiltins is the registry of built-in functions supported in OPA by default.
DefaultRootDocument is the default root document.
DefaultRootRef is a reference to the root of the default document.
Diff returns the difference [years, months, days, hours, minutes, seconds] between two unix timestamps in nanoseconds.
Divide divides the first number by the second number.
EndsWith returns true if the search string begins with the base string.
Equal represents the "==" comparison operator.
Equality represents the "=" operator.
Floor rounds the number down to the nearest integer.
FormatInt returns the string representation of the number in the given base after converting it to an integer value.
FunctionArgRootDocument names the document containing function arguments.
FutureRootDocument names the document containing new, to-become-default, features.
GlobMatch - not to be confused with regex.globs_match - parses and matches strings against the glob notation.
GlobQuoteMeta returns a string which represents a version of the pattern where all asterisks have been escaped.
GlobsMatch takes two strings regexp-style strings and evaluates to true if their intersection matches a non-empty set of non-empty strings.
GreaterThan represents the ">" comparison operator.
GreaterThanEq represents the ">=" comparison operator.
HexDecode deserializes the hex encoded input string.
HexEncode serializes the input string into hex encoding.
HTTPSend returns a HTTP response to the given HTTP request.
IgnoreDuringPartialEval is a set of built-in functions that should not be evaluated during partial evaluation.
IndexOf returns the index of a substring contained inside a string.
IndexOfN returns a list of all the indexes of a substring contained inside a string.
InputRootDocument names the document containing query arguments.
InputRootRef is a reference to the root of the input document.
InternalPrint represents the internal implementation of the print() function.
Intersection returns the intersection of the given input sets.
IsArray returns true if the input value is an array.
IsBoolean returns true if the input value is a boolean.
IsNull returns true if the input value is null.
IsNumber returns true if the input value is a number.
IsObject returns true if the input value is an object.
IsSet returns true if the input value is a set.
IsString returns true if the input value is a string.
JSONFilter filters the JSON object.
JSONIsValid verifies the input string is a valid JSON document.
JSONMarshal serializes the input term.
JSONPatch patches a JSON object according to RFC6902.
JSONRemove removes paths in the JSON object.
No description provided by the author
JSONUnmarshal deserializes the input string.
JWTDecode decodes a JSON Web Token and outputs it as an Object.
JWTDecodeVerify verifies a JWT signature under parameterized constraints and decodes the claims if it is valid.
JWTEncodeSign encodes and optionally sign a JSON Web Token.
JWTEncodeSignRaw encodes and optionally sign a JSON Web Token.
JWTVerifyES256 verifies if a ES256 JWT signature is valid or not.
JWTVerifyES384 verifies if a ES384 JWT signature is valid or not.
JWTVerifyES512 verifies if a ES512 JWT signature is valid or not.
JWTVerifyHS256 verifies if a HS256 (secret) JWT signature is valid or not.
JWTVerifyHS384 verifies if a HS384 (secret) JWT signature is valid or not.
JWTVerifyHS512 verifies if a HS512 (secret) JWT signature is valid or not.
JWTVerifyPS256 verifies if a PS256 JWT signature is valid or not.
JWTVerifyPS384 verifies if a PS384 JWT signature is valid or not.
JWTVerifyPS512 verifies if a PS512 JWT signature is valid or not.
JWTVerifyRS256 verifies if a RS256 JWT signature is valid or not.
JWTVerifyRS384 verifies if a RS384 JWT signature is valid or not.
JWTVerifyRS512 verifies if a RS512 JWT signature is valid or not.
Keywords contains strings that map to language keywords.
LessThan represents the "<" comparison operator.
LessThanEq represents the "<=" comparison operator.
Lower returns the input string but with all characters in lower-case.
Max returns the maximum value in a collection.
Member represents the `in` (infix) operator.
MemberWithKey represents the `in` (infix) operator when used with two terms on the lhs, i.e., `k, v in obj`.
Min returns the minimum value in a collection.
Minus subtracts the second number from the first number or computes the diff between two sets.
Multiply multiplies two numbers together.
NetCIDRContains checks if a cidr or ip is contained within another cidr and returns true or false.
NetCIDRContainsMatches checks if collections of cidrs or ips are contained within another collection of cidrs and returns matches.
NetCIDRExpand returns a set of hosts inside the specified cidr.
NetCIDRIntersects checks if a cidr intersects with another cidr and returns true or false.
NetCIDRMerge merges IP addresses and subnets into the smallest possible list of CIDRs.
NetCIDROverlap has been replaced by the `net.cidr_contains` built-in.
NetLookupIPAddr returns the set of IP addresses (as strings, both v4 and v6) that the passed-in name (string) resolves to using the standard name resolution mechanisms available.
NotEqual represents the "!=" comparison operator.
NowNanos returns the current time since epoch in nanoseconds.
NumbersRange returns an array of numbers in the given inclusive range.
ObjectFilter filters the object by keeping only specified keys.
ObjectGet returns takes an object and returns a value under its key if present, otherwise it returns the default.
ObjectRemove Removes specified keys from an object.
ObjectUnion creates a new object that is the asymmetric union of two objects.
ObjectUnionN creates a new object that is the asymmetric union of all objects merged from left to right.
OPARuntime returns an object containing OPA runtime information such as the configuration that OPA was booted with.
Or performs a union operation on sets.
ParseDurationNanos returns the duration in nanoseconds represented by a duration string.
ParseNanos returns the time in nanoseconds parsed from the string in the given format.
ParseRFC3339Nanos returns the time in nanoseconds parsed from the string in RFC3339 format.
Plus adds two numbers together.
Print is a special built-in function that writes zero or more operands to a message buffer.
Product takes an array or set of numbers and multiplies them.
RandIntn returns a random number 0 - n.
ReachableBuiltin computes the set of reachable nodes in the graph from a set of starting nodes.
ReachablePathsBuiltin computes the set of reachable paths in the graph from a set of starting nodes.
RegexFind takes two strings and a number, the pattern, the value and number of match values to return, -1 means all match values.
RegexFindAllStringSubmatch returns an array of all successive matches of the expression.
RegexIsValid returns true if the regex pattern string is valid, otherwise false.
RegexMatch takes two strings and evaluates to true if the string in the second position matches the pattern in the first position.
RegexMatchDeprecated declares `re_match` which has been deprecated.
RegexSplit splits the input string by the occurrences of the given pattern.
RegexTemplateMatch takes two strings and evaluates to true if the string in the second position matches the pattern in the first position.
RegoParseModule parses the input Rego file and returns a JSON representation of the AST.
Rem returns the remainder for x%y for y != 0.
Replace returns the given string with all instances of the second argument replaced by the third.
ReplaceN replaces a string from a list of old, new string pairs.
ReservedVars is the set of names that refer to implicitly ground vars.
RootDocumentNames contains the names of top-level documents that can be referred to in modules and queries.
RootDocumentRefs contains the prefixes of top-level documents that all non-local references start with.
Round rounds the number to the nearest integer.
SafetyCheckVisitorParams defines the AST visitor parameters to use for collecting variables during the safety check.
SchemaRootDocument names the document containing external data schemas.
SchemaRootRef is a reference to the root of the schema document.
SemVerCompare compares valid SemVer formatted version strings.
SemVerIsValid validiates a the term is a valid SemVer as a string, returns false for all other input.
SetDiff has been replaced by the minus built-in.
Sort returns a sorted array.
Split returns an array containing elements of the input string split on a delimiter.
Sprintf returns the given string, formatted.
StartsWith returns true if the search string begins with the base string.
StringReverse returns the given string, reversed.
Substring returns the portion of a string for a given start index and a length.
Sum takes an array or set of numbers and sums them.
SystemDocumentKey is the name of the top-level key that identifies the system document.
No description provided by the author
No description provided by the author
No description provided by the author
Timed Counters.
No description provided by the author
No description provided by the author
ToNumber takes a string, bool, or number value and converts it to a number.
Trace prints a note that is included in the query explanation.
Trim returns the given string with all leading or trailing instances of the second argument removed.
TrimLeft returns the given string with all leading instances of second argument removed.
TrimPrefix returns the given string without the second argument prefix string.
TrimRight returns the given string with all trailing instances of second argument removed.
TrimSpace return the given string with all leading and trailing white space removed.
TrimSuffix returns the given string without the second argument suffix string.
TypeNameBuiltin returns the type of the input.
Union returns the union of the given input sets.
UnitsParseBytes converts strings like 10GB, 5K, 4mb, and the like into an integer number of bytes.
Upper returns the input string but with all characters in upper-case.
URLQueryDecode decodes a URL encoded input string.
URLQueryDecodeObject decodes the given URL query string into an object.
URLQueryEncode encodes the input string into a URL encoded string.
URLQueryEncodeObject encodes the given JSON into a URL encoded query string.
UUIDRFC4122 returns a version 4 UUID string.
WalkBuiltin generates [path, value] tuples for all nested documents (recursively).
Weekday returns the day of the week (Monday, Tuesday, ...) for the nanoseconds since epoch.
Wildcard represents the wildcard variable as defined in the language.
WildcardPrefix is the special character that all wildcard variables are prefixed with when the statement they are contained in is parsed.
YAMLIsValid verifies the input string is a valid YAML document.
YAMLMarshal serializes the input term.
YAMLUnmarshal deserializes the input string.

# Structs

No description provided by the author
ArgErrDetail represents a generic argument error.
Array represents an array as defined by the language.
ArrayComprehension represents an array comprehension as defined in the language.
BeforeAfterVisitor provides a utility to walk over AST nodes using closures.
Builtin represents a built-in function supported by OPA.
Capabilities defines a structure containing data that describes the capablilities or features supported by a particular version of OPA.
No description provided by the author
CompileOpts defines a set of options for the compiler.
Compiler contains the state of a compilation process.
CompilerStageDefinition defines a compiler stage.
ComprehensionIndex specifies how the comprehension term can be indexed.
Error represents a single error caught during parsing, compiling, etc.
No description provided by the author
No description provided by the author
GenericTransformer implements the Transformer interface to provide a utility to transform AST nodes using a closure.
GenericVisitor provides a utility to walk over AST nodes using a closure.
Graph represents the graph of dependencies between rules.
GraphTraversal is a Traversal that understands the dependency graph.
No description provided by the author
No description provided by the author
IndexResult contains the result of an index lookup.
JSONOpt defines parameters for AST to JSON conversion.
No description provided by the author
ModuleTreeNode represents a node in the module tree.
Null represents the null value defined by JSON.
ObjectComprehension represents an object comprehension as defined in the language.
No description provided by the author
Parser is used to parse Rego statements.
ParserErrorDetail holds additional details for parser errors.
ParserOptions defines the options for parsing Rego statements.
QueryCompilerStageDefinition defines a QueryCompiler stage.
QueryContext contains contextual information for running an ad-hoc query.
RefErrInvalidDetail describes an undefined reference error where the referenced value does not support the reference operand (e.g., missing object key, invalid key type, etc.).
RefErrUnsupportedDetail describes an undefined reference error where the referenced value does not support dereferencing (e.g., scalars).
No description provided by the author
RulesOptions defines the options for retrieving rules by Ref from the compiler.
No description provided by the author
SchemaSet holds a map from a path to a schema.
SetComprehension represents a set comprehension as defined in the language.
No description provided by the author
Term is an argument to a function.
TreeNode represents a node in the rule tree.
TypeEnv contains type info for static analysis such as type checking.
UnificationErrDetail describes a type mismatch error when two values are unified (e.g., x = [1,2,y]).
UnknownValueErr indicates a ValueResolver was unable to resolve a reference because the reference refers to an unknown value.
ValueMap represents a key/value map between AST term values.
VarVisitor walks AST nodes under a given node and collects all encountered variables.
VarVisitorParams contains settings for a VarVisitor.
WasmABIVersion captures the Wasm ABI version.
No description provided by the author

# Interfaces

BeforeAndAfterVisitor wraps Visitor to provide hooks for being called before and after the AST has been visited.
ErrorDetails defines the interface for detailed error messages.
No description provided by the author
Object represents an object as defined by the language.
QueryCompiler defines the interface for compiling ad-hoc queries.
Resolver defines the interface for resolving references to native Go values.
RuleIndex defines the interface for rule indices.
Set represents a set as defined by the language.
No description provided by the author
Transformer defines the interface for transforming AST elements.
Value declares the common interface for all Term values.
ValueResolver defines the interface for resolving references to AST values.
Visitor defines the interface for iterating AST elements.

# Type aliases

No description provided by the author
No description provided by the author
Boolean represents a boolean value defined by JSON.
Call represents as function call in the language.
CompilerStage defines the interface for stages in the compiler.
DocKind represents the collection of document types that can be produced by rules.
Errors represents a series of errors encountered during parsing, compiling, etc.
Location records a position in source code.
ModuleLoader defines the interface that callers can implement to enable lazy loading of modules during compilation.
Number represents a numeric value as defined by JSON.
QueryCompilerStage defines the interface for stages in the query compiler.
QueryIterator defines the interface for querying AST documents with references.
Ref represents a reference as defined by the language.
RuleSet represents a collection of rules that produce a virtual document.
String represents a string value as defined by JSON.
Var represents a variable as defined by the language.
VarSet represents a set of variables.