tuple

package
v0.6.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 31, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ENTITY    = "%s:%s" // format string for entity in the form of "<type>:<id>"
	RELATION  = "#%s"   // format string for relation in the form of "#<relation>"
	REFERENCE = "%s#%s" // format string for reference in the form of "<type>#<relation>"
)
View Source
const (
	ELLIPSIS = "..." // ellipsis string
)
View Source
const (
	SEPARATOR = "." // separator string used to concatenate entity and relation
)

Variables

View Source
var (
	ErrInvalidEntity            = errors.New("invalid entity")
	ErrInvalidTuple             = errors.New("invalid tuple")
	ErrInvalidEntityAndRelation = errors.New("invalid entity and relation")
)

Functions

func AreQueryAndSubjectEqual added in v0.5.0

func AreQueryAndSubjectEqual(en *base.Entity, permission string, s2 *base.Subject) bool

AreQueryAndSubjectEqual checks if a query and a subject are equal

func AreRelationReferencesEqual added in v0.4.2

func AreRelationReferencesEqual(s1, s2 *base.RelationReference) bool

AreRelationReferencesEqual checks if two relation references are equal or not

func AreSubjectsEqual

func AreSubjectsEqual(s1, s2 *base.Subject) bool

AreSubjectsEqual checks if two subjects are equal

func E

func E(e string) (*base.Entity, error)

E function parses an Entity string and returns an Entity object.

func EAR

func EAR(ear string) (*base.EntityAndRelation, error)

EAR function parses a string to create a base.EntityAndRelation object.

func EAREqual added in v0.4.6

func EAREqual(s1, s2 *base.EntityAndRelation) bool

EAREqual checks if two subjects are equal

func EntityAndRelationToString

func EntityAndRelationToString(entity *base.Entity, relation string) string

EntityAndRelationToString converts an EntityAndRelation object to string format

func EntityToString

func EntityToString(entity *base.Entity) string

EntityToString converts an Entity object to string format

func IsDirectSubject added in v0.4.6

func IsDirectSubject(subject *base.Subject) bool

IsDirectSubject checks if the given subject is of type "user"

func IsEntityAndSubjectEquals

func IsEntityAndSubjectEquals(t *base.Tuple) bool

IsEntityAndSubjectEquals checks if the entity and subject of a Tuple object are equal

func IsRelationComputed

func IsRelationComputed(relation string) bool

IsRelationComputed checks if a relation is computed or not

func IsSubjectValid

func IsSubjectValid(subject *base.Subject) bool

IsSubjectValid checks if a subject is valid or not

func NormalizeRelation added in v0.4.6

func NormalizeRelation(relation string) string

NormalizeRelation normalizes the relation, treating ellipsis as an empty string

func ReferenceToString added in v0.4.2

func ReferenceToString(ref *base.RelationReference) string

ReferenceToString -

func RelationReference added in v0.4.2

func RelationReference(ref string) *base.RelationReference

RelationReference parses a relation reference string and returns a RelationReference object.

func SplitRelation

func SplitRelation(relation string) (a []string)

SplitRelation splits a relation string by the separator "." and returns the result as a slice

func SubjectToEAR added in v0.4.6

func SubjectToEAR(subject *base.Subject) *base.EntityAndRelation

SubjectToEAR converts a Subject object to an EntityAndRelation object

func SubjectToString

func SubjectToString(subject *base.Subject) string

SubjectToString converts a Subject object to string format.

func ToString added in v0.4.5

func ToString(tup *base.Tuple) string

ToString function converts a Tuple object to a string format.

func Tuple

func Tuple(tuple string) (*base.Tuple, error)

Tuple parses a tuple string and returns a Tuple object

func ValidateSubjectType

func ValidateSubjectType(subject *base.Subject, relationTypes []string) (err error)

ValidateSubjectType validates if the subject type and relation are present in the list of allowed relation types

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL