Documentation ¶
Overview ¶
Package tuple contains code to manipulate tuples and errors related to tuples.
Index ¶
- Constants
- func BuildObject(objectType, objectID string) string
- func ConvertCheckRequestTupleKeyToTupleKey(tk *openfgav1.CheckRequestTupleKey) *openfgav1.TupleKey
- func ConvertReadRequestTupleKeyToTupleKey(tk *openfgav1.ReadRequestTupleKey) *openfgav1.TupleKey
- func GetObjectRelationAsString(objectRelation *openfgav1.ObjectRelation) string
- func GetRelation(objectRelation string) string
- func GetType(objectID string) string
- func IsObjectRelation(userset string) bool
- func IsTypedWildcard(s string) bool
- func IsValidObject(s string) bool
- func IsValidRelation(s string) bool
- func IsValidUser(user string) bool
- func IsWildcard(s string) bool
- func NewCheckRequestTupleKey(object, relation, user string) *openfgav1.CheckRequestTupleKey
- func NewExpandRequestTupleKey(object, relation string) *openfgav1.ExpandRequestTupleKey
- func NewRelationshipCondition(name string, context *structpb.Struct) *openfgav1.RelationshipCondition
- func NewTupleKey(object, relation, user string) *openfgav1.TupleKey
- func NewTupleKeyWithCondition(object, relation, user, conditionName string, context *structpb.Struct) *openfgav1.TupleKey
- func ObjectKey(obj *openfgav1.Object) string
- func SplitObject(object string) (string, string)
- func SplitObjectRelation(objectRelation string) (string, string)
- func ToObjectRelationString(object, relation string) string
- func TupleKeyToString(tk TupleWithoutCondition) string
- func TupleKeyToTupleKeyWithoutCondition(tk *openfgav1.TupleKey) *openfgav1.TupleKeyWithoutCondition
- func TupleKeyWithConditionToString(tk TupleWithCondition) string
- func TupleKeyWithoutConditionToTupleKey(tk *openfgav1.TupleKeyWithoutCondition) *openfgav1.TupleKey
- func TupleKeysWithoutConditionToTupleKeys(tks ...*openfgav1.TupleKeyWithoutCondition) []*openfgav1.TupleKey
- type InvalidConditionalTupleError
- type InvalidTupleError
- type RelationNotFoundError
- type TupleWithCondition
- type TupleWithoutCondition
- type TypeNotFoundError
- type UserType
Constants ¶
const Wildcard = "*"
Variables ¶
This section is empty.
Functions ¶
func BuildObject ¶
func ConvertCheckRequestTupleKeyToTupleKey ¶ added in v1.3.8
func ConvertCheckRequestTupleKeyToTupleKey(tk *openfgav1.CheckRequestTupleKey) *openfgav1.TupleKey
func ConvertReadRequestTupleKeyToTupleKey ¶ added in v1.3.8
func ConvertReadRequestTupleKeyToTupleKey(tk *openfgav1.ReadRequestTupleKey) *openfgav1.TupleKey
func GetObjectRelationAsString ¶ added in v0.3.5
func GetObjectRelationAsString(objectRelation *openfgav1.ObjectRelation) string
GetObjectRelationAsString returns a string like "object#relation". If there is no relation it returns "object"
func GetRelation ¶
GetRelation returns the 'relation' portion of an object relation string (e.g. `object#relation`), which may be empty if the input is malformed (or does not contain a relation).
func GetType ¶
GetType returns the type from a supplied Object identifier or an empty string if the object id does not contain a type.
func IsObjectRelation ¶
IsObjectRelation returns true if the given string specifies a valid object and relation.
func IsTypedWildcard ¶ added in v0.3.0
IsTypedWildcard returns true if the string 's' is a typed wildcard. A typed wildcard has the form 'type:*'.
func IsValidObject ¶
IsValidObject determines if a string s is a valid object. A valid object contains exactly one `:` and no `#` or spaces.
func IsValidRelation ¶
IsValidRelation determines if a string s is a valid relation. This means it does not contain any `:`, `#`, or spaces.
func IsValidUser ¶
IsValidUser determines if a string is a valid user. A valid user contains at most one `:`, at most one `#` and no spaces.
func IsWildcard ¶ added in v0.3.0
IsWildcard returns true if the string 's' could be interpreted as a typed or untyped wildcard (e.g. '*' or 'type:*')
func NewCheckRequestTupleKey ¶ added in v1.3.8
func NewCheckRequestTupleKey(object, relation, user string) *openfgav1.CheckRequestTupleKey
func NewExpandRequestTupleKey ¶ added in v1.3.8
func NewExpandRequestTupleKey(object, relation string) *openfgav1.ExpandRequestTupleKey
func NewRelationshipCondition ¶ added in v1.3.8
func NewRelationshipCondition(name string, context *structpb.Struct) *openfgav1.RelationshipCondition
func NewTupleKey ¶
func NewTupleKeyWithCondition ¶ added in v1.3.8
func ObjectKey ¶ added in v0.2.1
ObjectKey returns the canonical key for the provided Object. The ObjectKey of an object is the string 'objectType:objectId'.
func SplitObject ¶
SplitObject splits an object into an objectType and an objectID. If no type is present, it returns the empty string and the original object.
func SplitObjectRelation ¶
SplitObjectRelation splits an object relation string into an object ID and relation name. If no relation is present, it returns the original string and an empty relation.
func ToObjectRelationString ¶
ToObjectRelationString formats an object/relation pair as an object#relation string. This is the inverse of SplitObjectRelation.
func TupleKeyToString ¶
func TupleKeyToString(tk TupleWithoutCondition) string
TupleKeyToString converts a tuple key into its string representation. It assumes the tupleKey is valid (i.e. no forbidden characters)
func TupleKeyToTupleKeyWithoutCondition ¶ added in v1.3.8
func TupleKeyToTupleKeyWithoutCondition(tk *openfgav1.TupleKey) *openfgav1.TupleKeyWithoutCondition
func TupleKeyWithConditionToString ¶ added in v1.3.8
func TupleKeyWithConditionToString(tk TupleWithCondition) string
TupleKeyWithConditionToString converts a tuple key with condition into its string representation. It assumes the tupleKey is valid (i.e. no forbidden characters)
func TupleKeyWithoutConditionToTupleKey ¶ added in v1.3.8
func TupleKeyWithoutConditionToTupleKey(tk *openfgav1.TupleKeyWithoutCondition) *openfgav1.TupleKey
func TupleKeysWithoutConditionToTupleKeys ¶ added in v1.3.8
func TupleKeysWithoutConditionToTupleKeys(tks ...*openfgav1.TupleKeyWithoutCondition) []*openfgav1.TupleKey
Types ¶
type InvalidConditionalTupleError ¶ added in v1.3.8
type InvalidConditionalTupleError struct { Cause error TupleKey TupleWithCondition }
InvalidConditionalTupleError is returned if the tuple's condition is invalid
func (*InvalidConditionalTupleError) Error ¶ added in v1.3.8
func (i *InvalidConditionalTupleError) Error() string
func (*InvalidConditionalTupleError) Is ¶ added in v1.3.8
func (i *InvalidConditionalTupleError) Is(target error) bool
type InvalidTupleError ¶
type InvalidTupleError struct { Cause error TupleKey TupleWithoutCondition }
InvalidTupleError is returned if the tuple is invalid
func (*InvalidTupleError) Error ¶
func (i *InvalidTupleError) Error() string
func (*InvalidTupleError) Is ¶ added in v0.3.0
func (i *InvalidTupleError) Is(target error) bool
type RelationNotFoundError ¶
func (*RelationNotFoundError) Error ¶
func (i *RelationNotFoundError) Error() string
func (*RelationNotFoundError) Is ¶ added in v0.3.0
func (i *RelationNotFoundError) Is(target error) bool
type TupleWithCondition ¶ added in v1.3.8
type TupleWithCondition interface { TupleWithoutCondition GetCondition() *openfgav1.RelationshipCondition }
type TupleWithoutCondition ¶ added in v1.3.8
type TypeNotFoundError ¶
type TypeNotFoundError struct {
TypeName string
}
func (*TypeNotFoundError) Error ¶
func (i *TypeNotFoundError) Error() string
func (*TypeNotFoundError) Is ¶ added in v0.3.0
func (i *TypeNotFoundError) Is(target error) bool