ketoapi

package
v0.13.0-alpha.0 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NamespaceKey           = "namespace"
	ObjectKey              = "object"
	RelationKey            = "relation"
	SubjectIDKey           = "subject_id"
	SubjectSetNamespaceKey = "subject_set.namespace"
	SubjectSetObjectKey    = "subject_set.object"
	SubjectSetRelationKey  = "subject_set.relation"
)

Variables

View Source
var (
	ErrDroppedSubjectKey = herodot.ErrBadRequest.WithDebug(`provide "subject_id" or "subject_set.*"; support for "subject" was dropped`)
	ErrDuplicateSubject  = herodot.ErrBadRequest.WithError("exactly one of subject_set or subject_id has to be provided")
	ErrIncompleteSubject = herodot.ErrBadRequest.WithError(`incomplete subject, provide "subject_id" or a complete "subject_set.*"`)
	ErrNilSubject        = herodot.ErrBadRequest.WithError("subject is not allowed to be nil").WithDebug("Please provide a subject.")
	ErrIncompleteTuple   = herodot.ErrBadRequest.WithError(`incomplete tuple, provide "namespace", "object", "relation", and a subject`)
	ErrUnknownNodeType   = errors.New("unknown node type")
)
View Source
var ErrMalformedInput = herodot.ErrBadRequest.WithError("malformed string input")

Functions

This section is empty.

Types

type CheckOPLSyntaxResponse

type CheckOPLSyntaxResponse struct {
	// The list of syntax errors
	//
	// required: false
	Errors []*ParseError `json:"errors,omitempty"`
}

CheckOPLSyntaxResponse represents the response for an OPL syntax check request.

swagger:model checkOplSyntaxResult

type ExpandNodeType

type ExpandNodeType TreeNodeType

swagger:enum ExpandNodeType

type GetNamespacesResponse

type GetNamespacesResponse struct {
	Namespaces []Namespace `json:"namespaces"`
}

Relationship Namespace List

swagger:model relationshipNamespaces

type GetResponse

type GetResponse struct {
	RelationTuples []*RelationTuple `json:"relation_tuples"`
	// The opaque token to provide in a subsequent request
	// to get the next page. It is the empty string iff this is
	// the last page.
	NextPageToken string `json:"next_page_token"`
}

Paginated Relationship List

swagger:model relationships

type Namespace

type Namespace struct {
	// Name of the namespace.
	Name string `json:"name"`
}

swagger:model namespace

type ParseError

type ParseError struct {
	Message string         `json:"message"`
	Start   SourcePosition `json:"start"`
	End     SourcePosition `json:"end"`
}

type PatchAction

type PatchAction string

swagger:enum PatchAction

const (
	ActionInsert PatchAction = "insert"
	ActionDelete PatchAction = "delete"
)

type PatchDelta

type PatchDelta struct {
	Action        PatchAction    `json:"action"`
	RelationTuple *RelationTuple `json:"relation_tuple"`
}

Payload for patching a relationship

swagger:model relationshipPatch

type RelationQuery

type RelationQuery struct {
	// Namespace to query
	Namespace *string `json:"namespace"`

	// Object to query
	Object *string `json:"object"`

	// Relation to query
	Relation *string `json:"relation"`

	// SubjectID to query
	//
	// Either SubjectSet or SubjectID can be provided.
	SubjectID *string `json:"subject_id,omitempty"`
	// SubjectSet to query
	//
	// Either SubjectSet or SubjectID can be provided.
	//
	// swagger:allOf
	SubjectSet *SubjectSet `json:"subject_set,omitempty"`
}

Relation Query

swagger:model relationQuery

func (*RelationQuery) FromDataProvider

func (q *RelationQuery) FromDataProvider(d queryData) *RelationQuery

func (*RelationQuery) FromURLQuery

func (q *RelationQuery) FromURLQuery(query url.Values) (*RelationQuery, error)

func (*RelationQuery) ToProto

func (q *RelationQuery) ToProto() *rts.RelationQuery

func (*RelationQuery) ToURLQuery

func (q *RelationQuery) ToURLQuery() url.Values

type RelationTuple

type RelationTuple struct {
	// Namespace of the Relation Tuple
	//
	// required: true
	Namespace string `json:"namespace"`

	// Object of the Relation Tuple
	//
	// required: true
	Object string `json:"object"`

	// Relation of the Relation Tuple
	//
	// required: true
	Relation string `json:"relation"`

	// SubjectID of the Relation Tuple
	//
	// Either SubjectSet or SubjectID can be provided.
	SubjectID *string `json:"subject_id,omitempty"`

	// SubjectSet of the Relation Tuple
	//
	// Either SubjectSet or SubjectID can be provided.
	//
	// swagger:allOf
	SubjectSet *SubjectSet `json:"subject_set,omitempty"`
}

Relationship

swagger:model relationship

func (*RelationTuple) Columns

func (r *RelationTuple) Columns() []string

func (*RelationTuple) FromDataProvider

func (r *RelationTuple) FromDataProvider(d TupleData) (*RelationTuple, error)

func (*RelationTuple) FromProto

func (r *RelationTuple) FromProto(proto *rts.RelationTuple) *RelationTuple

func (*RelationTuple) FromString

func (r *RelationTuple) FromString(s string) (*RelationTuple, error)

func (*RelationTuple) FromURLQuery

func (r *RelationTuple) FromURLQuery(query url.Values) (*RelationTuple, error)

func (*RelationTuple) Header

func (r *RelationTuple) Header() []string

func (*RelationTuple) Interface

func (r *RelationTuple) Interface() interface{}

func (*RelationTuple) String

func (r *RelationTuple) String() string

func (*RelationTuple) ToLoggerFields

func (r *RelationTuple) ToLoggerFields() logrus.Fields

func (*RelationTuple) ToProto

func (r *RelationTuple) ToProto() *rts.RelationTuple

func (*RelationTuple) ToURLQuery

func (r *RelationTuple) ToURLQuery() url.Values

func (*RelationTuple) Validate

func (r *RelationTuple) Validate() error

type SourcePosition

type SourcePosition struct {
	Line int `json:"Line"`
	Col  int `json:"column"`
}

type SubjectSet

type SubjectSet struct {
	// Namespace of the Subject Set
	//
	// required: true
	Namespace string `json:"namespace"`

	// Object of the Subject Set
	//
	// required: true
	Object string `json:"object"`

	// Relation of the Subject Set
	//
	// required: true
	Relation string `json:"relation"`
}

swagger:model subjectSet

func (*SubjectSet) FromString

func (s *SubjectSet) FromString(str string) (*SubjectSet, error)

func (*SubjectSet) FromURLQuery

func (s *SubjectSet) FromURLQuery(values url.Values) *SubjectSet

func (*SubjectSet) String

func (s *SubjectSet) String() string

func (*SubjectSet) ToURLQuery

func (s *SubjectSet) ToURLQuery() url.Values

type Tree

type Tree[T tuple[T]] struct {
	// Propagate all struct changes to `swaggerOnlyExpandTree` as well.
	// The type of the node.
	//
	// required: true
	Type TreeNodeType `json:"type"`

	// The children of the node, possibly none.
	Children []*Tree[T] `json:"children,omitempty"`

	// The relation tuple the node represents.
	Tuple T `json:"tuple"`
}

Tree is a generic tree of either internal relationships (with UUIDs for objects, etc.) or API relationships (with strings for objects, etc.).

func TreeFromProto

func TreeFromProto[T tuple[T]](pt *rts.SubjectTree) *Tree[T]

func (*Tree[NodeT]) Label

func (t *Tree[NodeT]) Label() string

func (*Tree[NodeT]) String

func (t *Tree[NodeT]) String() string

func (*Tree[NodeT]) ToProto

func (t *Tree[NodeT]) ToProto() *rts.SubjectTree

type TreeNodeType

type TreeNodeType string

swagger:enum TreeNodeType

const (
	TreeNodeUnion              TreeNodeType = "union"
	TreeNodeExclusion          TreeNodeType = "exclusion"
	TreeNodeIntersection       TreeNodeType = "intersection"
	TreeNodeLeaf               TreeNodeType = "leaf"
	TreeNodeTupleToSubjectSet  TreeNodeType = "tuple_to_subject_set"
	TreeNodeComputedSubjectSet TreeNodeType = "computed_subject_set"
	TreeNodeNot                TreeNodeType = "not"
	TreeNodeUnspecified        TreeNodeType = "unspecified"
)

func (TreeNodeType) FromProto

func (TreeNodeType) FromProto(pt rts.NodeType) TreeNodeType

func (TreeNodeType) String

func (t TreeNodeType) String() string

func (TreeNodeType) ToProto

func (t TreeNodeType) ToProto() rts.NodeType

func (*TreeNodeType) UnmarshalJSON

func (t *TreeNodeType) UnmarshalJSON(v []byte) error

type TupleData

type TupleData interface {
	GetSubject() *rts.Subject
	GetObject() string
	GetNamespace() string
	GetRelation() string
}

Jump to

Keyboard shortcuts

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