tuple

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2023 License: Apache-2.0 Imports: 4 Imported by: 2

Documentation

Index

Constants

View Source
const Wildcard = "*"

Variables

This section is empty.

Functions

func BuildObject

func BuildObject(objectType, objectID string) string

func GetObjectRelationAsString added in v0.3.5

func GetObjectRelationAsString(objectRelation *openfgapb.ObjectRelation) string

GetObjectRelationAsString returns a string like "object#relation". If there is no relation it returns "object"

func GetRelation

func GetRelation(objectRelation string) string

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

func GetType(objectID string) string

GetType returns the type from a supplied Object identifier or an empty string if the object id does not contain a type.

func IsObjectRelation

func IsObjectRelation(userset string) bool

IsObjectRelation returns true if the given string specifies a valid object and relation.

func IsTypedWildcard added in v0.3.0

func IsTypedWildcard(s string) bool

IsTypedWildcard returns true if the string 's' is a typed wildcard. A typed wildcard has the form 'type:*'.

func IsValidObject

func IsValidObject(s string) bool

IsValidObject determines if a string s is a valid object. A valid object contains exactly one `:` and no `#` or spaces.

func IsValidRelation

func IsValidRelation(s string) bool

IsValidRelation determines if a string s is a valid relation. This means it does not contain any `:`, `#`, or spaces.

func IsValidUser

func IsValidUser(user string) bool

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

func IsWildcard(s string) bool

IsWildcard returns true if the string 's' could be interpreted as a typed or untyped wildcard (e.g. '*' or 'type:*')

func NewTupleKey

func NewTupleKey(object, relation, user string) *openfgapb.TupleKey

func ObjectKey added in v0.2.1

func ObjectKey(obj *openfgapb.Object) string

ObjectKey returns the canonical key for the provided Object. The ObjectKey of an object is the string 'objectType:objectId'.

func SplitObject

func SplitObject(object string) (string, string)

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

func SplitObjectRelation(objectRelation string) (string, string)

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

func ToObjectRelationString(object, relation string) string

ToObjectRelationString formats an object/relation pair as an object#relation string. This is the inverse of SplitObjectRelation.

func TupleKeyToString

func TupleKeyToString(tk *openfgapb.TupleKey) string

TupleKeyToString converts a tuple key into its string representation. It assumes the tupleKey is valid (i.e. no forbidden characters)

Types

type IndirectWriteError added in v0.2.2

type IndirectWriteError struct {
	Reason   string
	TupleKey *openfgapb.TupleKey
}

IndirectWriteError is used to categorize errors specific to write check logic

func (*IndirectWriteError) Error added in v0.2.2

func (i *IndirectWriteError) Error() string

type InvalidObjectFormatError

type InvalidObjectFormatError struct {
	TupleKey *openfgapb.TupleKey
}

InvalidObjectFormatError is returned if the object is invalid

func (*InvalidObjectFormatError) Error

func (i *InvalidObjectFormatError) Error() string

func (*InvalidObjectFormatError) Is added in v0.3.0

func (i *InvalidObjectFormatError) Is(target error) bool

type InvalidTupleError

type InvalidTupleError struct {
	Cause    error
	TupleKey *openfgapb.TupleKey
}

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

type RelationNotFoundError struct {
	TupleKey *openfgapb.TupleKey
	Relation string
	TypeName string
}

RelationNotFoundError is returned if the relation is not found

func (*RelationNotFoundError) Error

func (i *RelationNotFoundError) Error() string

func (*RelationNotFoundError) Is added in v0.3.0

func (i *RelationNotFoundError) Is(target error) bool

type TypeNotFoundError

type TypeNotFoundError struct {
	TypeName string
}

TypeNotFoundError is returned if type is not found

func (*TypeNotFoundError) Error

func (i *TypeNotFoundError) Error() string

func (*TypeNotFoundError) Is added in v0.3.0

func (i *TypeNotFoundError) Is(target error) bool

type UserType

type UserType string
const (
	User    UserType = "user"
	UserSet UserType = "userset"
)

func GetUserTypeFromUser

func GetUserTypeFromUser(user string) UserType

GetUserTypeFromUser returns the type of user (userset or user).

Jump to

Keyboard shortcuts

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