tuple

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2021 License: Apache-2.0 Imports: 7 Imported by: 3

Documentation

Index

Constants

View Source
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 Create

func Create(tpl *v0.RelationTuple) *v0.RelationTupleUpdate

func Delete

func Delete(tpl *v0.RelationTuple) *v0.RelationTupleUpdate

func FromRelationship added in v0.0.2

func FromRelationship(r *v1.Relationship) *v0.RelationTuple

FromRelationship converts a Relationship into a RelationTuple.

func MustFromRelationship added in v1.1.0

func MustFromRelationship(r *v1.Relationship) *v0.RelationTuple

MustFromRelationship converts a Relationship into a RelationTuple.

func MustParse added in v1.0.0

func MustParse(tpl string) *v0.RelationTuple

MustParse wraps Parse such that any failures panic rather than returning nil.

func MustRelString added in v1.1.0

func MustRelString(tpl *v1.Relationship) string

MustRelString converts a relationship into a string. Will panic if the Relationship does not validate.

func MustRelToFilter added in v1.3.0

func MustRelToFilter(rel *v1.Relationship) *v1.RelationshipFilter

MustRelToFilter converts a Relationship into a RelationshipFilter. Will panic if the Relationship does not validate.

func MustToFilter added in v1.1.0

func MustToFilter(tpl *v0.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 *v0.RelationTuple) *v1.Relationship

MustToRelationship converts a RelationTuple into a Relationship. Will panic if the RelationTuple does not validate.

func ObjectAndRelation

func ObjectAndRelation(ns, oid, rel string) *v0.ObjectAndRelation

ObjectAndRelation creates an ONR from string pieces.

func Parse added in v1.0.0

func Parse(tpl string) *v0.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) *v0.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) *v0.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 RelString added in v0.0.2

func RelString(tpl *v1.Relationship) string

RelString converts a relationship into a string.

func RelToFilter added in v1.3.0

func RelToFilter(rel *v1.Relationship) *v1.RelationshipFilter

RelToFilter converts a Relationship into a RelationshipFilter.

func String

func String(tpl *v0.RelationTuple) string

String converts a tuple to a string. If the tuple is nil or empty, returns empty string.

func StringONR

func StringONR(onr *v0.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.

func StringRR added in v1.3.0

func StringRR(rr *v0.RelationReference) string

StringRR converts a RR object to a string.

func StringSubjectRef added in v1.0.0

func StringSubjectRef(ref *v1.SubjectReference) string

StringSubjectRef marshals a *v1.SubjectReference into a string.

func StringsONRs

func StringsONRs(onrs []*v0.ObjectAndRelation) []string

StringsONRs converts ONR objects to a string slice, sorted.

func ToFilter added in v0.0.2

func ToFilter(tpl *v0.RelationTuple) *v1.RelationshipFilter

ToFilter converts a RelationTuple into a RelationshipFilter.

func ToRelationship added in v0.0.2

func ToRelationship(tpl *v0.RelationTuple) *v1.Relationship

ToRelationship converts a RelationTuple into a Relationship.

func Touch

func UpdateFromRelationshipUpdate added in v0.0.2

func UpdateFromRelationshipUpdate(update *v1.RelationshipUpdate) *v0.RelationTupleUpdate

UpdateFromRelationshipUpdate converts a RelationshipUpdate into a RelationTupleUpdate.

func UpdateToRelationshipUpdate added in v0.0.2

func UpdateToRelationshipUpdate(update *v0.RelationTupleUpdate) *v1.RelationshipUpdate

UpdateToRelationshipUpdate converts a RelationTupleUpdate into a RelationshipUpdate.

func UpdatesToRelationshipUpdates added in v1.2.0

func UpdatesToRelationshipUpdates(updates []*v0.RelationTupleUpdate) []*v1.RelationshipUpdate

UpdatesToRelationshipUpdates converts a slice of RelationTupleUpdate into a slice of RelationshipUpdate.

func User

func User(userset *v0.ObjectAndRelation) *v0.User

User creates a user wrapping a userset ONR.

func UsersetToSubjectFilter added in v1.3.0

func UsersetToSubjectFilter(userset *v0.ObjectAndRelation) *v1.SubjectFilter

UsersetToSubjectFilter converts a userset to the equivalent exact SubjectFilter.

func ValidateResourceID added in v1.3.0

func ValidateResourceID(objectID string) error

ValidateResourceID ensures that the given resource ID is valid. Returns an error if not.

func ValidateSubjectID added in v1.3.0

func ValidateSubjectID(subjectID string) error

ValidateSubjectID ensures that the given object ID (under a subject reference) is valid. Returns an error if not.

Types

type ONRSet

type ONRSet struct {
	// contains filtered or unexported fields
}

ONRSet is a set of ObjectAndRelation's.

func NewONRSet

func NewONRSet(onrs ...*v0.ObjectAndRelation) *ONRSet

NewONRSet creates a new set.

func (*ONRSet) Add

func (ons *ONRSet) Add(onr *v0.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() []*v0.ObjectAndRelation

AsSlice returns the ONRs found in the set as a slice.

func (*ONRSet) Has

func (ons *ONRSet) Has(onr *v0.ObjectAndRelation) bool

Has returns true if the set contains the given ONR.

func (*ONRSet) Intersect

func (ons *ONRSet) Intersect(otherSet *ONRSet) *ONRSet

Intersect returns an intersection between this ONR set and the other set provided.

func (*ONRSet) IsEmpty

func (ons *ONRSet) IsEmpty() bool

IsEmpty returns whether the set is empty.

func (*ONRSet) Length

func (ons *ONRSet) Length() uint32

Length returns the size of the set.

func (*ONRSet) Subtract

func (ons *ONRSet) Subtract(otherSet *ONRSet) *ONRSet

Subtract returns a subtraction from this ONR set of the other set provided.

func (*ONRSet) Update

func (ons *ONRSet) Update(onrs []*v0.ObjectAndRelation)

Update updates the set by adding the given ONRs to it.

func (*ONRSet) UpdateFrom

func (ons *ONRSet) UpdateFrom(otherSet *ONRSet)

UpdateFrom updates the set by adding the ONRs found in the other set to it.

func (*ONRSet) With

func (ons *ONRSet) With(onr *v0.ObjectAndRelation) *ONRSet

With returns a copy of this ONR set with the given element added.

Jump to

Keyboard shortcuts

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