tuple

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2022 License: Apache-2.0 Imports: 8 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildObject

func BuildObject(objectType, objectID string) string

func GetRelation

func GetRelation(objectRelation string) string

GetRelation returns the 'relation' portion of an object relation string, which may be empty if the input is malformed (or does not contain a relation specifier).

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 IsType

func IsType(object string) bool

IsType returns true if the given string contains just a 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 s is a valid user. A valid user contains at most one `:` and no `#` or spaces.

func NewTupleKey

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

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)

func ValidateObjectsRelations

func ValidateObjectsRelations(ctx context.Context, backend storage.TypeDefinitionReadBackend, store, modelID string, t *openfgapb.TupleKey, dbCallsCounter utils.DBCallCounter) (*openfgapb.Userset, error)

ValidateObjectsRelations returns whether a tuple's object and relations are valid

func ValidateTuple

func ValidateTuple(ctx context.Context, backend storage.TypeDefinitionReadBackend, store, authorizationModelID string, tk *openfgapb.TupleKey, dbCallsCounter utils.DBCallCounter) (*openfgapb.Userset, error)

ValidateTuple returns whether a *openfgapb.TupleKey is valid

Types

type InvalidObjectFormatError

type InvalidObjectFormatError struct {
	TupleKey *openfgapb.TupleKey
}

InvalidObjectFormatError is returned if the object is invalid

func (*InvalidObjectFormatError) Error

func (i *InvalidObjectFormatError) Error() string

type InvalidTupleError

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

InvalidTupleError is returned if the tuple is invalid

func (*InvalidTupleError) Error

func (i *InvalidTupleError) Error() string

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

type TypeNotFoundError

type TypeNotFoundError struct {
	TypeName string
}

TypeNotFoundError is returned if type is not found

func (*TypeNotFoundError) Error

func (i *TypeNotFoundError) Error() string

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