Documentation ¶
Index ¶
- Constants
- func CanonicalBytes(rel Relationship) ([]byte, error)
- func CopyToV1Relationship(rel Relationship, v1rel *v1.Relationship)
- func CoreONR(namespace, objectID, relation string) *core.ObjectAndRelation
- func CoreRR(namespace, relation string) *core.RelationReference
- func CoreRelationToString(rel *core.RelationTuple) (string, error)
- func CoreRelationToStringWithoutCaveatOrExpiration(rel *core.RelationTuple) string
- func Equal(lhs, rhs Relationship) bool
- func JoinObjectRef(namespace, objectID string) string
- func JoinRelRef(namespace, relation string) string
- func MustCoreRelationToString(rel *core.RelationTuple) string
- func MustParseV1Rel(relString string) *v1.Relationship
- func MustSplitRelRef(relRef string) (namespace, relation string)
- func MustString(rel Relationship) string
- func MustStringCaveat(caveat *core.ContextualizedCaveat) string
- func MustUpdateToV1RelationshipUpdate(update RelationshipUpdate) *v1.RelationshipUpdate
- func MustV1RelString(rel *v1.Relationship) string
- func MustV1StringRelationship(rel *v1.Relationship) string
- func ONREqual(lhs, rhs ObjectAndRelation) bool
- func ONREqualOrWildcard(onr, target ObjectAndRelation) bool
- func ONRStringToCore(ns, oid, rel string) *core.ObjectAndRelation
- func ParseV1Rel(relString string) (*v1.Relationship, error)
- func RRStringToCore(namespaceName string, relationName string) *core.RelationReference
- func RelToFilter(rel *v1.Relationship) *v1.RelationshipFilter
- func String(rel Relationship) (string, error)
- func StringCaveat(caveat *core.ContextualizedCaveat) (string, error)
- func StringCaveatContext(context *structpb.Struct) (string, error)
- func StringCoreONR(onr *core.ObjectAndRelation) string
- func StringCoreRR(rr *core.RelationReference) string
- func StringExpiration(expiration *time.Time) (string, error)
- func StringONR(onr ObjectAndRelation) string
- func StringONRStrings(namespace, objectID, relation string) string
- func StringRR(rr RelationReference) string
- func StringWithoutCaveatOrExpiration(rel Relationship) string
- func StringsONRs(onrs []ObjectAndRelation) []string
- func SubjectONRToSubjectFilter(subject ObjectAndRelation) *v1.SubjectFilter
- func ToV1Filter(rel Relationship) *v1.RelationshipFilter
- func ToV1Relationship(rel Relationship) *v1.Relationship
- func UpdateToV1RelationshipUpdate(update RelationshipUpdate) (*v1.RelationshipUpdate, error)
- func UpdatesToV1RelationshipUpdates(updates []RelationshipUpdate) ([]*v1.RelationshipUpdate, error)
- func V1StringCaveatRef(caveat *v1.ContextualizedCaveat) (string, error)
- func V1StringExpiration(expiration *timestamppb.Timestamp) (string, error)
- func V1StringObjectRef(ref *v1.ObjectReference) string
- func V1StringRelationship(rel *v1.Relationship) (string, error)
- func V1StringRelationshipWithoutCaveatOrExpiration(rel *v1.Relationship) string
- func V1StringSubjectRef(ref *v1.SubjectReference) string
- func ValidateResourceID(objectID string) error
- func ValidateSubjectID(subjectID string) error
- type ObjectAndRelation
- func FromCoreObjectAndRelation(oar *core.ObjectAndRelation) ObjectAndRelation
- func MustParseONR(onr string) ObjectAndRelation
- func MustParseSubjectONR(subjectOnr string) ObjectAndRelation
- func ONR(namespace, objectID, relation string) ObjectAndRelation
- func ONRRef(namespace, objectID, relation string) *ObjectAndRelation
- func ParseONR(onr string) (ObjectAndRelation, error)
- func ParseSubjectONR(subjectOnr string) (ObjectAndRelation, error)
- func StringToONR(ns, oid, rel string) ObjectAndRelation
- type RelationReference
- type Relationship
- func FromCoreRelationTuple(rt *core.RelationTuple) Relationship
- func FromV1Relationship(rel *v1.Relationship) Relationship
- func MustParse(relString string) Relationship
- func MustWithCaveat(rel Relationship, caveatName string, contexts ...map[string]any) Relationship
- func MustWithExpiration(rel Relationship, expiration time.Time) Relationship
- func Parse(relString string) (Relationship, error)
- func WithCaveat(rel Relationship, caveatName string, contexts ...map[string]any) (Relationship, error)
- func (r Relationship) SizeVT() int
- func (r Relationship) ToCoreTuple() *core.RelationTuple
- func (r Relationship) Validate() error
- func (r Relationship) ValidateNotEmpty() bool
- func (r Relationship) WithCaveat(caveat *core.ContextualizedCaveat) Relationship
- func (r Relationship) WithoutIntegrity() Relationship
- type RelationshipReference
- type RelationshipUpdate
- func Create(rel Relationship) RelationshipUpdate
- func Delete(rel Relationship) RelationshipUpdate
- func Touch(rel Relationship) RelationshipUpdate
- func UpdateFromV1RelationshipUpdate(update *v1.RelationshipUpdate) (RelationshipUpdate, error)
- func UpdatesFromV1RelationshipUpdates(updates []*v1.RelationshipUpdate) ([]RelationshipUpdate, error)
- type UpdateOperation
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 CanonicalBytes ¶ added in v1.36.0
func CanonicalBytes(rel Relationship) ([]byte, error)
CanonicalBytes converts a tuple to a canonical set of bytes. Can be used for hashing purposes.
func CopyToV1Relationship ¶ added in v1.39.0
func CopyToV1Relationship(rel Relationship, v1rel *v1.Relationship)
CopyToV1Relationship copies a Relationship into a v1.Relationship.
func CoreONR ¶ added in v1.39.0
func CoreONR(namespace, objectID, relation string) *core.ObjectAndRelation
CoreONR creates a core ObjectAndRelation from the string pieces.
func CoreRR ¶ added in v1.39.0
func CoreRR(namespace, relation string) *core.RelationReference
CoreRR creates a core RelationReference from the string pieces.
func CoreRelationToString ¶ added in v1.39.0
func CoreRelationToString(rel *core.RelationTuple) (string, error)
CoreRelationToString creates a string from a core.RelationTuple.
func CoreRelationToStringWithoutCaveatOrExpiration ¶ added in v1.39.0
func CoreRelationToStringWithoutCaveatOrExpiration(rel *core.RelationTuple) string
CoreRelationToStringWithoutCaveatOrExpiration creates a string from a core.RelationTuple without stringifying the caveat.
func Equal ¶ added in v1.26.0
func Equal(lhs, rhs Relationship) bool
Equal returns true if the two relationships are exactly the same.
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 MustCoreRelationToString ¶ added in v1.39.0
func MustCoreRelationToString(rel *core.RelationTuple) string
MustCoreRelationToString creates a string from a core.RelationTuple and panics if it can't.
func MustParseV1Rel ¶ added in v1.39.0
func MustParseV1Rel(relString string) *v1.Relationship
Same as above, but panics if it cannot be parsed. Should only be used in tests.
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(rel Relationship) string
MustString converts a relationship to a string.
func MustStringCaveat ¶ added in v1.26.0
func MustStringCaveat(caveat *core.ContextualizedCaveat) string
func MustUpdateToV1RelationshipUpdate ¶ added in v1.39.0
func MustUpdateToV1RelationshipUpdate(update RelationshipUpdate) *v1.RelationshipUpdate
MustUpdateToV1RelationshipUpdate converts a RelationshipUpdate into a v1.RelationshipUpdate. Panics on error.
func MustV1RelString ¶ added in v1.39.0
func MustV1RelString(rel *v1.Relationship) string
MustV1RelString converts a relationship into a string. Will panic if the Relationship does not validate.
func MustV1StringRelationship ¶ added in v1.39.0
func MustV1StringRelationship(rel *v1.Relationship) string
MustV1StringRelationship converts a v1.Relationship to a string.
func ONREqual ¶ added in v1.39.0
func ONREqual(lhs, rhs ObjectAndRelation) bool
ONREqual checks if two ObjectAndRelation instances are equal.
func ONREqualOrWildcard ¶ added in v1.39.0
func ONREqualOrWildcard(onr, target ObjectAndRelation) bool
ONREqualOrWildcard checks if an ObjectAndRelation matches another ObjectAndRelation or is a wildcard.
func ONRStringToCore ¶ added in v1.39.0
func ONRStringToCore(ns, oid, rel string) *core.ObjectAndRelation
ONRStringToCore creates an ONR from string pieces.
func ParseV1Rel ¶ added in v1.39.0
func ParseV1Rel(relString string) (*v1.Relationship, error)
ParseV1Rel parses a string representation of a relationship into a v1.Relationship object.
func RRStringToCore ¶ added in v1.39.0
func RRStringToCore(namespaceName string, relationName string) *core.RelationReference
RRStringToCore creates a RelationReference from the string pieces.
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(rel Relationship) (string, error)
String converts a relationship to a 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 StringCoreONR ¶ added in v1.39.0
func StringCoreONR(onr *core.ObjectAndRelation) string
StringCoreONR converts a core ONR object to a string.
func StringCoreRR ¶ added in v1.39.0
func StringCoreRR(rr *core.RelationReference) string
func StringExpiration ¶ added in v1.39.0
func StringONR ¶
func StringONR(onr ObjectAndRelation) string
StringONR converts an ONR object to a string.
func StringONRStrings ¶ added in v1.35.0
StringONRStrings converts ONR strings to a string.
func StringRR ¶ added in v1.3.0
func StringRR(rr RelationReference) string
StringRR converts a RR object to a string.
func StringWithoutCaveatOrExpiration ¶ added in v1.39.0
func StringWithoutCaveatOrExpiration(rel Relationship) string
StringWithoutCaveatOrExpiration converts a relationship to a string, without its caveat or expiration included.
func StringsONRs ¶
func StringsONRs(onrs []ObjectAndRelation) []string
StringsONRs converts ONR objects to a string slice, sorted.
func SubjectONRToSubjectFilter ¶ added in v1.39.0
func SubjectONRToSubjectFilter(subject ObjectAndRelation) *v1.SubjectFilter
SubjectONRToSubjectFilter converts a userset to the equivalent exact SubjectFilter.
func ToV1Filter ¶ added in v1.39.0
func ToV1Filter(rel Relationship) *v1.RelationshipFilter
ToV1Filter converts a RelationTuple into a RelationshipFilter.
func ToV1Relationship ¶ added in v1.39.0
func ToV1Relationship(rel Relationship) *v1.Relationship
ToV1Relationship converts a Relationship into a v1.Relationship.
func UpdateToV1RelationshipUpdate ¶ added in v1.39.0
func UpdateToV1RelationshipUpdate(update RelationshipUpdate) (*v1.RelationshipUpdate, error)
UpdateToV1RelationshipUpdate converts a RelationshipUpdate into a v1.RelationshipUpdate.
func UpdatesToV1RelationshipUpdates ¶ added in v1.39.0
func UpdatesToV1RelationshipUpdates(updates []RelationshipUpdate) ([]*v1.RelationshipUpdate, error)
UpdatesToV1RelationshipUpdates converts a slice of RelationshipUpdate into a slice of v1.RelationshipUpdate.
func V1StringCaveatRef ¶ added in v1.39.0
func V1StringCaveatRef(caveat *v1.ContextualizedCaveat) (string, error)
V1StringCaveatRef converts a v1.ContextualizedCaveat to a string.
func V1StringExpiration ¶ added in v1.39.0
func V1StringExpiration(expiration *timestamppb.Timestamp) (string, error)
func V1StringObjectRef ¶ added in v1.39.0
func V1StringObjectRef(ref *v1.ObjectReference) string
StringObjectRef marshals a *v1.ObjectReference into a string.
This function assumes that the provided values have already been validated.
func V1StringRelationship ¶ added in v1.39.0
func V1StringRelationship(rel *v1.Relationship) (string, error)
V1StringRelationship converts a v1.Relationship to a string.
func V1StringRelationshipWithoutCaveatOrExpiration ¶ added in v1.39.0
func V1StringRelationshipWithoutCaveatOrExpiration(rel *v1.Relationship) string
V1StringRelationshipWithoutCaveatOrExpiration converts a v1.Relationship to a string, excluding any caveat.
func V1StringSubjectRef ¶ added in v1.39.0
func V1StringSubjectRef(ref *v1.SubjectReference) string
StringSubjectRef marshals a *v1.SubjectReference into a string.
This function assumes that the provided values have already been validated.
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.
Types ¶
type ObjectAndRelation ¶
ObjectAndRelation represents an object and its relation.
func FromCoreObjectAndRelation ¶ added in v1.39.0
func FromCoreObjectAndRelation(oar *core.ObjectAndRelation) ObjectAndRelation
FromCoreObjectAndRelation creates an ObjectAndRelation from a core.ObjectAndRelation.
func MustParseONR ¶ added in v1.39.0
func MustParseONR(onr string) ObjectAndRelation
MustParseONR converts a string representation of an ONR to an ObjectAndRelation object. Panics on error.
func MustParseSubjectONR ¶ added in v1.39.0
func MustParseSubjectONR(subjectOnr string) ObjectAndRelation
MustParseSubjectONR converts a string representation of a Subject ONR to an ObjectAndRelation. Panics on error.
func ONR ¶ added in v1.39.0
func ONR(namespace, objectID, relation string) ObjectAndRelation
ONR creates an ObjectAndRelation.
func ONRRef ¶ added in v1.39.0
func ONRRef(namespace, objectID, relation string) *ObjectAndRelation
ONRRef creates an ObjectAndRelation reference.
func ParseONR ¶ added in v1.0.0
func ParseONR(onr string) (ObjectAndRelation, error)
ParseONR converts a string representation of an ONR to an ObjectAndRelation object.
func ParseSubjectONR ¶ added in v1.0.0
func ParseSubjectONR(subjectOnr string) (ObjectAndRelation, error)
ParseSubjectONR converts a string representation of a Subject ONR to an ObjectAndRelation. 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 StringToONR ¶ added in v1.39.0
func StringToONR(ns, oid, rel string) ObjectAndRelation
StringToONR creates an ONR from string pieces.
func (ObjectAndRelation) RelationReference ¶ added in v1.39.0
func (onr ObjectAndRelation) RelationReference() RelationReference
RelationReference returns a RelationReference for the object and relation.
func (ObjectAndRelation) SizeVT ¶ added in v1.39.0
func (onr ObjectAndRelation) SizeVT() int
func (ObjectAndRelation) String ¶ added in v1.39.0
func (onr ObjectAndRelation) String() string
func (ObjectAndRelation) ToCoreONR ¶ added in v1.39.0
func (onr ObjectAndRelation) ToCoreONR() *core.ObjectAndRelation
ToCoreONR converts the ObjectAndRelation to a core.ObjectAndRelation.
func (ObjectAndRelation) WithRelation ¶ added in v1.39.0
func (onr ObjectAndRelation) WithRelation(relation string) ObjectAndRelation
WithRelation returns a copy of the object and relation with the given relation.
type RelationReference ¶ added in v1.13.0
RelationReference represents a reference to a relation.
func FromCoreRelationReference ¶ added in v1.39.0
func FromCoreRelationReference(rr *core.RelationReference) RelationReference
FromCoreRelationshipReference creates a RelationshipReference from a core.RelationshipReference.
func RR ¶ added in v1.39.0
func RR(namespace, relation string) RelationReference
RR creates a RelationReference.
func (RelationReference) ToCoreRR ¶ added in v1.39.0
func (rr RelationReference) ToCoreRR() *core.RelationReference
ToCoreRR converts the RelationReference to a core.RelationReference.
type Relationship ¶ added in v1.39.0
type Relationship struct { OptionalCaveat *core.ContextualizedCaveat OptionalExpiration *time.Time OptionalIntegrity *core.RelationshipIntegrity RelationshipReference }
Relationship represents a relationship between two objects.
func FromCoreRelationTuple ¶ added in v1.39.0
func FromCoreRelationTuple(rt *core.RelationTuple) Relationship
FromCoreRelationTuple creates a Relationship from a core.RelationTuple.
func FromV1Relationship ¶ added in v1.39.0
func FromV1Relationship(rel *v1.Relationship) Relationship
FromV1Relationship converts a v1.Relationship into a Relationship.
func MustParse ¶ added in v1.0.0
func MustParse(relString string) Relationship
MustParse wraps Parse such that any failures panic rather than returning an error.
func MustWithCaveat ¶ added in v1.16.0
func MustWithCaveat(rel Relationship, caveatName string, contexts ...map[string]any) Relationship
MustWithCaveat adds the given caveat name to the relationship. This is for testing only.
func MustWithExpiration ¶ added in v1.39.0
func MustWithExpiration(rel Relationship, expiration time.Time) Relationship
MustWithExpiration adds the given expiration to the relationship. This is for testing only.
func Parse ¶ added in v1.0.0
func Parse(relString string) (Relationship, error)
Parse unmarshals the string form of a Tuple and returns an error on failure,
This function treats both missing and Ellipsis relations equally.
func WithCaveat ¶ added in v1.15.0
func WithCaveat(rel Relationship, caveatName string, contexts ...map[string]any) (Relationship, error)
WithCaveat adds the given caveat name to the relationship. This is for testing only.
func (Relationship) SizeVT ¶ added in v1.39.0
func (r Relationship) SizeVT() int
func (Relationship) ToCoreTuple ¶ added in v1.39.0
func (r Relationship) ToCoreTuple() *core.RelationTuple
ToCoreTuple converts the Relationship to a core.RelationTuple.
func (Relationship) Validate ¶ added in v1.39.0
func (r Relationship) Validate() error
Validate returns an error if the relationship is invalid.
func (Relationship) ValidateNotEmpty ¶ added in v1.39.0
func (r Relationship) ValidateNotEmpty() bool
ValidateNotEmpty returns true if the relationship is not empty.
func (Relationship) WithCaveat ¶ added in v1.39.0
func (r Relationship) WithCaveat(caveat *core.ContextualizedCaveat) Relationship
WithCaveat returns a copy of the relationship with the given caveat.
func (Relationship) WithoutIntegrity ¶ added in v1.39.0
func (r Relationship) WithoutIntegrity() Relationship
WithoutIntegrity returns a copy of the relationship without its integrity.
type RelationshipReference ¶ added in v1.39.0
type RelationshipReference struct { Resource ObjectAndRelation Subject ObjectAndRelation }
RelationshipReference represents a reference to a relationship, i.e. those portions of a relationship that are not the integrity or caveat and thus form the unique identifier of the relationship.
type RelationshipUpdate ¶ added in v1.39.0
type RelationshipUpdate struct { Relationship Relationship Operation UpdateOperation }
RelationshipUpdate represents an update to a relationship.
func Create ¶
func Create(rel Relationship) RelationshipUpdate
func Delete ¶
func Delete(rel Relationship) RelationshipUpdate
func Touch ¶
func Touch(rel Relationship) RelationshipUpdate
func UpdateFromV1RelationshipUpdate ¶ added in v1.39.0
func UpdateFromV1RelationshipUpdate(update *v1.RelationshipUpdate) (RelationshipUpdate, error)
UpdateFromV1RelationshipUpdate converts a RelationshipUpdate into a RelationTupleUpdate.
func UpdatesFromV1RelationshipUpdates ¶ added in v1.39.0
func UpdatesFromV1RelationshipUpdates(updates []*v1.RelationshipUpdate) ([]RelationshipUpdate, error)
UpdatesFromV1RelationshipUpdates converts a slice of v1.RelationshipUpdate into a slice of RelationshipUpdate.
func (RelationshipUpdate) DebugString ¶ added in v1.39.0
func (ru RelationshipUpdate) DebugString() string
func (RelationshipUpdate) OperationString ¶ added in v1.39.0
func (ru RelationshipUpdate) OperationString() string
type UpdateOperation ¶ added in v1.39.0
type UpdateOperation int
UpdateOperation represents the type of update to a relationship.
const ( UpdateOperationTouch UpdateOperation = iota UpdateOperationCreate UpdateOperationDelete )