Documentation ¶
Index ¶
- Constants
- func CopyRelationTupleToRelationship(src *core.RelationTuple, dst *v1.Relationship, ...)
- func CopyRelationshipToRelationTuple[T objectReference, S subjectReference[T], C caveat](r relationship[T, S, C], dst *core.RelationTuple)
- func Create(tpl *core.RelationTuple) *core.RelationTupleUpdate
- func Delete(tpl *core.RelationTuple) *core.RelationTupleUpdate
- func FromRelationship[T objectReference, S subjectReference[T], C caveat](r relationship[T, S, C]) *core.RelationTuple
- func JoinObjectRef(namespace, objectID string) string
- func JoinRelRef(namespace, relation string) string
- func MustFromRelationship[R objectReference, S subjectReference[R], C caveat](r relationship[R, S, C]) *core.RelationTuple
- func MustFromRelationships[R objectReference, S subjectReference[R], C caveat](rels []relationship[R, S, C]) []*core.RelationTuple
- func MustParse(tpl string) *core.RelationTuple
- func MustRelString(rel *v1.Relationship) string
- func MustSplitRelRef(relRef string) (namespace, relation string)
- func MustString(tpl *core.RelationTuple) string
- func MustStringRelationship(rel *v1.Relationship) string
- func MustToFilter(tpl *core.RelationTuple) *v1.RelationshipFilter
- func MustToRelationship(tpl *core.RelationTuple) *v1.Relationship
- func MustToRelationshipMutating(source *core.RelationTuple, targetRel *v1.Relationship, ...)
- func MustWithCaveat(tpl *core.RelationTuple, caveatName string, contexts ...map[string]any) *core.RelationTuple
- func NewRelationship() *v1.Relationship
- func ObjectAndRelation(ns, oid, rel string) *core.ObjectAndRelation
- func Parse(tpl string) *core.RelationTuple
- func ParseONR(onr string) *core.ObjectAndRelation
- func ParseRel(rel string) *v1.Relationship
- func ParseSubjectONR(subjectOnr string) *core.ObjectAndRelation
- func RelToFilter(rel *v1.Relationship) *v1.RelationshipFilter
- func RelationReference(namespaceName string, relationName string) *core.RelationReference
- func String(tpl *core.RelationTuple) (string, error)
- func StringCaveat(caveat *core.ContextualizedCaveat) (string, error)
- func StringCaveatContext(context *structpb.Struct) (string, error)
- func StringCaveatRef(caveat *v1.ContextualizedCaveat) (string, error)
- func StringONR(onr *core.ObjectAndRelation) string
- func StringObjectRef(ref *v1.ObjectReference) string
- func StringRR(rr *core.RelationReference) string
- func StringRelationship(rel *v1.Relationship) (string, error)
- func StringRelationshipWithoutCaveat(rel *v1.Relationship) string
- func StringSubjectRef(ref *v1.SubjectReference) string
- func StringWithoutCaveat(tpl *core.RelationTuple) string
- func StringsONRs(onrs []*core.ObjectAndRelation) []string
- func ToFilter(tpl *core.RelationTuple) *v1.RelationshipFilter
- func ToRelationship(tpl *core.RelationTuple) *v1.Relationship
- func Touch(tpl *core.RelationTuple) *core.RelationTupleUpdate
- func UpdateFromRelationshipUpdate(update *v1.RelationshipUpdate) *core.RelationTupleUpdate
- func UpdateFromRelationshipUpdates(updates []*v1.RelationshipUpdate) []*core.RelationTupleUpdate
- func UpdateToRelationshipUpdate(update *core.RelationTupleUpdate) *v1.RelationshipUpdate
- func UpdatesToRelationshipUpdates(updates []*core.RelationTupleUpdate) []*v1.RelationshipUpdate
- func UsersetToSubjectFilter(userset *core.ObjectAndRelation) *v1.SubjectFilter
- func ValidateResourceID(objectID string) error
- func ValidateSubjectID(subjectID string) error
- func WithCaveat(tpl *core.RelationTuple, caveatName string, contexts ...map[string]any) (*core.RelationTuple, error)
- type ONRByTypeSet
- func (s *ONRByTypeSet) Add(onr *core.ObjectAndRelation)
- func (s *ONRByTypeSet) ForEachType(handler func(rr *core.RelationReference, objectIds []string))
- func (s *ONRByTypeSet) IsEmpty() bool
- func (s *ONRByTypeSet) Len() int
- func (s *ONRByTypeSet) Map(mapper func(rr *core.RelationReference) (*core.RelationReference, error)) (*ONRByTypeSet, error)
- type ONRSet
- func (ons *ONRSet) Add(onr *core.ObjectAndRelation) bool
- func (ons *ONRSet) AsSlice() []*core.ObjectAndRelation
- func (ons *ONRSet) Has(onr *core.ObjectAndRelation) bool
- func (ons *ONRSet) Intersect(otherSet *ONRSet) *ONRSet
- func (ons *ONRSet) IsEmpty() bool
- func (ons *ONRSet) Length() uint32
- func (ons *ONRSet) Subtract(otherSet *ONRSet) *ONRSet
- func (ons *ONRSet) Union(otherSet *ONRSet) *ONRSet
- func (ons *ONRSet) Update(onrs []*core.ObjectAndRelation)
- func (ons *ONRSet) UpdateFrom(otherSet *ONRSet)
- func (ons *ONRSet) With(onr *core.ObjectAndRelation) *ONRSet
Constants ¶
const ( // Ellipsis is the Ellipsis relation in v0 style subjects. Ellipsis = "..." // PublicWildcard is the wildcard value for subject object IDs that indicates public access // for the subject type. PublicWildcard = "*" )
Variables ¶
This section is empty.
Functions ¶
func CopyRelationTupleToRelationship ¶ added in v1.22.0
func CopyRelationTupleToRelationship( src *core.RelationTuple, dst *v1.Relationship, dstCaveat *v1.ContextualizedCaveat, )
CopyRelationTupleToRelationship copies a source core.RelationTuple to a destination v1.Relationship without allocating new memory. It requires that the structure for the destination be pre-allocated for the fixed parts, and an optional caveat context be provided for use when the source contains a caveat.
func CopyRelationshipToRelationTuple ¶ added in v1.22.0
func CopyRelationshipToRelationTuple[T objectReference, S subjectReference[T], C caveat](r relationship[T, S, C], dst *core.RelationTuple)
func Create ¶
func Create(tpl *core.RelationTuple) *core.RelationTupleUpdate
func Delete ¶
func Delete(tpl *core.RelationTuple) *core.RelationTupleUpdate
func FromRelationship ¶ added in v0.0.2
func FromRelationship[T objectReference, S subjectReference[T], C caveat](r relationship[T, S, C]) *core.RelationTuple
FromRelationship converts a Relationship into a RelationTuple.
func JoinObjectRef ¶ added in v1.16.1
JoinObject joins the namespace and the objectId together into the standard format.
This function assumes that the provided values have already been validated.
func JoinRelRef ¶ added in v1.16.1
JoinRelRef joins the namespace and relation together into the same format as `StringRR()`.
func MustFromRelationship ¶ added in v1.1.0
func MustFromRelationship[R objectReference, S subjectReference[R], C caveat](r relationship[R, S, C]) *core.RelationTuple
MustFromRelationship converts a Relationship into a RelationTuple.
func MustFromRelationships ¶ added in v1.15.0
func MustFromRelationships[R objectReference, S subjectReference[R], C caveat](rels []relationship[R, S, C]) []*core.RelationTuple
MustFromRelationships converts a slice of Relationship's into a slice of RelationTuple's.
func MustParse ¶ added in v1.0.0
func MustParse(tpl string) *core.RelationTuple
MustParse wraps Parse such that any failures panic rather than returning nil.
func MustRelString ¶ added in v1.1.0
func MustRelString(rel *v1.Relationship) string
MustRelString converts a relationship into a string. Will panic if the Relationship does not validate.
func MustSplitRelRef ¶ added in v1.16.1
MustSplitRelRef splits a string produced by `JoinRelRef()` and panics if it fails.
func MustString ¶ added in v1.16.0
func MustString(tpl *core.RelationTuple) string
MustString converts a tuple to a string. If the tuple is nil or empty, returns empty string.
func MustStringRelationship ¶ added in v1.16.0
func MustStringRelationship(rel *v1.Relationship) string
MustStringRelationship converts a v1.Relationship to a string.
func MustToFilter ¶ added in v1.1.0
func MustToFilter(tpl *core.RelationTuple) *v1.RelationshipFilter
MustToFilter converts a RelationTuple into a RelationshipFilter. Will panic if the RelationTuple does not validate.
func MustToRelationship ¶ added in v1.1.0
func MustToRelationship(tpl *core.RelationTuple) *v1.Relationship
MustToRelationship converts a RelationTuple into a Relationship. Will panic if the RelationTuple does not validate.
func MustToRelationshipMutating ¶ added in v1.21.0
func MustToRelationshipMutating(source *core.RelationTuple, targetRel *v1.Relationship, targetCaveat *v1.ContextualizedCaveat)
MustToRelationshipMutating sets target relationship to all the values provided in the source tuple.
func MustWithCaveat ¶ added in v1.16.0
func MustWithCaveat(tpl *core.RelationTuple, caveatName string, contexts ...map[string]any) *core.RelationTuple
MustWithCaveat adds the given caveat name to the tuple. This is for testing only.
func NewRelationship ¶ added in v1.21.0
func NewRelationship() *v1.Relationship
NewRelationship creates a new Relationship value with all its required child structures allocated
func ObjectAndRelation ¶
func ObjectAndRelation(ns, oid, rel string) *core.ObjectAndRelation
ObjectAndRelation creates an ONR from string pieces.
func Parse ¶ added in v1.0.0
func Parse(tpl string) *core.RelationTuple
Parse unmarshals the string form of a Tuple and returns nil if there is a failure.
This function treats both missing and Ellipsis relations equally.
func ParseONR ¶ added in v1.0.0
func ParseONR(onr string) *core.ObjectAndRelation
ParseONR converts a string representation of an ONR to a proto object.
func ParseRel ¶ added in v1.0.0
func ParseRel(rel string) *v1.Relationship
func ParseSubjectONR ¶ added in v1.0.0
func ParseSubjectONR(subjectOnr string) *core.ObjectAndRelation
ParseSubjectONR converts a string representation of a Subject ONR to a proto object. Unlike ParseONR, this method allows for objects without relations. If an object without a relation is given, the relation will be set to ellipsis.
func RelToFilter ¶ added in v1.3.0
func RelToFilter(rel *v1.Relationship) *v1.RelationshipFilter
RelToFilter converts a Relationship into a RelationshipFilter.
func RelationReference ¶ added in v1.13.0
func RelationReference(namespaceName string, relationName string) *core.RelationReference
RelationReference creates a RelationReference from the string pieces.
func String ¶
func String(tpl *core.RelationTuple) (string, error)
String converts a tuple to a string. If the tuple is nil or empty, returns empty string.
func StringCaveat ¶ added in v1.16.0
func StringCaveat(caveat *core.ContextualizedCaveat) (string, error)
StringCaveat converts a contextualized caveat to a string. If the caveat is nil or empty, returns empty string.
func StringCaveatContext ¶ added in v1.16.0
StringCaveatContext converts the context of a caveat to a string. If the context is nil or empty, returns an empty string.
func StringCaveatRef ¶ added in v1.16.0
func StringCaveatRef(caveat *v1.ContextualizedCaveat) (string, error)
StringCaveatRef converts a v1.ContextualizedCaveat to a string.
func StringONR ¶
func StringONR(onr *core.ObjectAndRelation) string
StringONR converts an ONR object to a string.
func StringObjectRef ¶ added in v1.0.0
func StringObjectRef(ref *v1.ObjectReference) string
StringObjectRef marshals a *v1.ObjectReference into a string.
This function assumes that the provided values have already been validated.
func StringRR ¶ added in v1.3.0
func StringRR(rr *core.RelationReference) string
StringRR converts a RR object to a string.
func StringRelationship ¶ added in v1.12.0
func StringRelationship(rel *v1.Relationship) (string, error)
StringRelationship converts a v1.Relationship to a string.
func StringRelationshipWithoutCaveat ¶ added in v1.16.0
func StringRelationshipWithoutCaveat(rel *v1.Relationship) string
StringRelationshipWithoutCaveat converts a v1.Relationship to a string, excluding any caveat.
func StringSubjectRef ¶ added in v1.0.0
func StringSubjectRef(ref *v1.SubjectReference) string
StringSubjectRef marshals a *v1.SubjectReference into a string.
This function assumes that the provided values have already been validated.
func StringWithoutCaveat ¶ added in v1.16.0
func StringWithoutCaveat(tpl *core.RelationTuple) string
StringWithoutCaveat converts a tuple to a string, without its caveat included.
func StringsONRs ¶
func StringsONRs(onrs []*core.ObjectAndRelation) []string
StringsONRs converts ONR objects to a string slice, sorted.
func ToFilter ¶ added in v0.0.2
func ToFilter(tpl *core.RelationTuple) *v1.RelationshipFilter
ToFilter converts a RelationTuple into a RelationshipFilter.
func ToRelationship ¶ added in v0.0.2
func ToRelationship(tpl *core.RelationTuple) *v1.Relationship
ToRelationship converts a RelationTuple into a Relationship.
func Touch ¶
func Touch(tpl *core.RelationTuple) *core.RelationTupleUpdate
func UpdateFromRelationshipUpdate ¶ added in v0.0.2
func UpdateFromRelationshipUpdate(update *v1.RelationshipUpdate) *core.RelationTupleUpdate
UpdateFromRelationshipUpdate converts a RelationshipUpdate into a RelationTupleUpdate.
func UpdateFromRelationshipUpdates ¶ added in v1.12.0
func UpdateFromRelationshipUpdates(updates []*v1.RelationshipUpdate) []*core.RelationTupleUpdate
func UpdateToRelationshipUpdate ¶ added in v0.0.2
func UpdateToRelationshipUpdate(update *core.RelationTupleUpdate) *v1.RelationshipUpdate
UpdateToRelationshipUpdate converts a RelationTupleUpdate into a RelationshipUpdate.
func UpdatesToRelationshipUpdates ¶ added in v1.2.0
func UpdatesToRelationshipUpdates(updates []*core.RelationTupleUpdate) []*v1.RelationshipUpdate
UpdatesToRelationshipUpdates converts a slice of RelationTupleUpdate into a slice of RelationshipUpdate.
func UsersetToSubjectFilter ¶ added in v1.3.0
func UsersetToSubjectFilter(userset *core.ObjectAndRelation) *v1.SubjectFilter
UsersetToSubjectFilter converts a userset to the equivalent exact SubjectFilter.
func ValidateResourceID ¶ added in v1.3.0
ValidateResourceID ensures that the given resource ID is valid. Returns an error if not.
func ValidateSubjectID ¶ added in v1.3.0
ValidateSubjectID ensures that the given object ID (under a subject reference) is valid. Returns an error if not.
func WithCaveat ¶ added in v1.15.0
func WithCaveat(tpl *core.RelationTuple, caveatName string, contexts ...map[string]any) (*core.RelationTuple, error)
WithCaveat adds the given caveat name to the tuple. This is for testing only.
Types ¶
type ONRByTypeSet ¶ added in v1.12.0
type ONRByTypeSet struct {
// contains filtered or unexported fields
}
ONRByTypeSet is a set of ObjectAndRelation's, grouped by namespace+relation.
func NewONRByTypeSet ¶ added in v1.12.0
func NewONRByTypeSet() *ONRByTypeSet
NewONRByTypeSet creates and returns a new ONRByTypeSet.
func (*ONRByTypeSet) Add ¶ added in v1.12.0
func (s *ONRByTypeSet) Add(onr *core.ObjectAndRelation)
Add adds the specified ObjectAndRelation to the set.
func (*ONRByTypeSet) ForEachType ¶ added in v1.12.0
func (s *ONRByTypeSet) ForEachType(handler func(rr *core.RelationReference, objectIds []string))
ForEachType invokes the handler for each type of ObjectAndRelation found in the set, along with all IDs of objects of that type.
func (*ONRByTypeSet) IsEmpty ¶ added in v1.12.0
func (s *ONRByTypeSet) IsEmpty() bool
IsEmpty returns true if the set is empty.
func (*ONRByTypeSet) Len ¶ added in v1.13.0
func (s *ONRByTypeSet) Len() int
Len returns the number of keys in the set.
func (*ONRByTypeSet) Map ¶ added in v1.12.0
func (s *ONRByTypeSet) Map(mapper func(rr *core.RelationReference) (*core.RelationReference, error)) (*ONRByTypeSet, error)
Map runs the mapper function over each type of object in the set, returning a new ONRByTypeSet with the object type replaced by that returned by the mapper function.
type ONRSet ¶
type ONRSet struct {
// contains filtered or unexported fields
}
ONRSet is a set of ObjectAndRelation's.
func NewONRSet ¶
func NewONRSet(onrs ...*core.ObjectAndRelation) *ONRSet
NewONRSet creates a new set.
func (*ONRSet) Add ¶
func (ons *ONRSet) Add(onr *core.ObjectAndRelation) bool
Add adds the given ONR to the set. Returns true if the object was not in the set before this call and false otherwise.
func (*ONRSet) AsSlice ¶
func (ons *ONRSet) AsSlice() []*core.ObjectAndRelation
AsSlice returns the ONRs found in the set as a slice.
func (*ONRSet) Has ¶
func (ons *ONRSet) Has(onr *core.ObjectAndRelation) bool
Has returns true if the set contains the given ONR.
func (*ONRSet) Intersect ¶
Intersect returns an intersection between this ONR set and the other set provided.
func (*ONRSet) Subtract ¶
Subtract returns a subtraction from this ONR set of the other set provided.
func (*ONRSet) Union ¶ added in v1.4.0
Union returns a copy of this ONR set with the other set's elements added in.
func (*ONRSet) Update ¶
func (ons *ONRSet) Update(onrs []*core.ObjectAndRelation)
Update updates the set by adding the given ONRs to it.
func (*ONRSet) UpdateFrom ¶
UpdateFrom updates the set by adding the ONRs found in the other set to it.