relationtuple

package
v0.8.0-alpha.0 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2022 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ActionInsert patchAction = "insert"
	ActionDelete patchAction = "delete"
)
View Source
const (
	RouteBase = "/relation-tuples"
)

Variables

View Source
var (
	ErrMalformedInput    = herodot.ErrBadRequest.WithError("malformed string input")
	ErrNilSubject        = herodot.ErrBadRequest.WithError("subject is not allowed to be nil")
	ErrDuplicateSubject  = herodot.ErrBadRequest.WithError("exactly one of subject_set or subject_id has to be provided")
	ErrDroppedSubjectKey = herodot.ErrBadRequest.WithDebug(`provide "subject_id" or "subject_set.*"; support for "subject" was dropped`)
	ErrIncompleteSubject = herodot.ErrBadRequest.WithError(`incomplete subject, provide "subject_id" or a complete "subject_set.*"`)
)

Functions

func IsolationTest

func IsolationTest(t *testing.T, m0, m1 Manager, addNamespace func(context.Context, *testing.T, string))

func ManagerTest

func ManagerTest(t *testing.T, m Manager, addNamespace func(context.Context, *testing.T, string))

func NewHandler

func NewHandler(d handlerDeps) *handler

Types

type GetResponse

type GetResponse struct {
	RelationTuples []*InternalRelationTuple `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"`
}

swagger:model getRelationTuplesResponse

type InternalRelationTuple

type InternalRelationTuple struct {
	Namespace string  `json:"namespace"`
	Object    string  `json:"object"`
	Relation  string  `json:"relation"`
	Subject   Subject `json:"subject"`
}

swagger:ignore

func (*InternalRelationTuple) Columns

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

func (*InternalRelationTuple) DeriveSubject

func (r *InternalRelationTuple) DeriveSubject() *SubjectSet

func (*InternalRelationTuple) FromDataProvider

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

func (*InternalRelationTuple) FromString

func (*InternalRelationTuple) FromURLQuery

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

func (*InternalRelationTuple) Header

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

func (*InternalRelationTuple) Interface

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

func (*InternalRelationTuple) MarshalJSON

func (r *InternalRelationTuple) MarshalJSON() ([]byte, error)

func (*InternalRelationTuple) String

func (r *InternalRelationTuple) String() string

func (*InternalRelationTuple) ToLoggerFields

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

func (*InternalRelationTuple) ToProto

func (r *InternalRelationTuple) ToProto() *acl.RelationTuple

func (*InternalRelationTuple) ToQuery

func (r *InternalRelationTuple) ToQuery() *RelationQuery

func (*InternalRelationTuple) ToURLQuery

func (r *InternalRelationTuple) ToURLQuery() (url.Values, error)

func (*InternalRelationTuple) UnmarshalJSON

func (r *InternalRelationTuple) UnmarshalJSON(raw []byte) error

type Manager

type Manager interface {
	GetRelationTuples(ctx context.Context, query *RelationQuery, options ...x.PaginationOptionSetter) ([]*InternalRelationTuple, string, error)
	WriteRelationTuples(ctx context.Context, rs ...*InternalRelationTuple) error
	DeleteRelationTuples(ctx context.Context, rs ...*InternalRelationTuple) error
	DeleteAllRelationTuples(ctx context.Context, query *RelationQuery) error
	TransactRelationTuples(ctx context.Context, insert []*InternalRelationTuple, delete []*InternalRelationTuple) error
}

type ManagerProvider

type ManagerProvider interface {
	RelationTupleManager() Manager
}

type ManagerWrapper

type ManagerWrapper struct {
	Reg            ManagerProvider
	PageOpts       []x.PaginationOptionSetter
	RequestedPages []string
}

func NewManagerWrapper

func NewManagerWrapper(_ *testing.T, reg ManagerProvider, options ...x.PaginationOptionSetter) *ManagerWrapper

func (*ManagerWrapper) DeleteAllRelationTuples

func (t *ManagerWrapper) DeleteAllRelationTuples(ctx context.Context, query *RelationQuery) error

func (*ManagerWrapper) DeleteRelationTuples

func (t *ManagerWrapper) DeleteRelationTuples(ctx context.Context, rs ...*InternalRelationTuple) error

func (*ManagerWrapper) GetRelationTuples

func (t *ManagerWrapper) GetRelationTuples(ctx context.Context, query *RelationQuery, options ...x.PaginationOptionSetter) ([]*InternalRelationTuple, string, error)

func (*ManagerWrapper) RelationTupleManager

func (t *ManagerWrapper) RelationTupleManager() Manager

func (*ManagerWrapper) TransactRelationTuples

func (t *ManagerWrapper) TransactRelationTuples(ctx context.Context, insert []*InternalRelationTuple, delete []*InternalRelationTuple) error

func (*ManagerWrapper) WriteRelationTuples

func (t *ManagerWrapper) WriteRelationTuples(ctx context.Context, rs ...*InternalRelationTuple) error

type PatchDelta

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

type RelationCollection

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

func NewProtoRelationCollection

func NewProtoRelationCollection(rels []*acl.RelationTuple) *RelationCollection

func NewRelationCollection

func NewRelationCollection(rels []*InternalRelationTuple) *RelationCollection

func (*RelationCollection) Header

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

func (*RelationCollection) IDs

func (r *RelationCollection) IDs() []string

func (*RelationCollection) Interface

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

func (*RelationCollection) Len

func (r *RelationCollection) Len() int

func (*RelationCollection) MarshalJSON

func (r *RelationCollection) MarshalJSON() ([]byte, error)

func (*RelationCollection) Table

func (r *RelationCollection) Table() [][]string

func (*RelationCollection) ToInternal

func (r *RelationCollection) ToInternal() ([]*InternalRelationTuple, error)

func (*RelationCollection) UnmarshalJSON

func (r *RelationCollection) UnmarshalJSON(raw []byte) error

type RelationQuery

type RelationQuery struct {
	// Namespace of the Relation Tuple
	Namespace string `json:"namespace"`

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

	// Relation of the Relation Tuple
	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"`
}

func (*RelationQuery) FromProto

func (q *RelationQuery) FromProto(query TupleData) (*RelationQuery, error)

func (*RelationQuery) FromURLQuery

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

func (*RelationQuery) String

func (q *RelationQuery) String() string

func (*RelationQuery) Subject

func (q *RelationQuery) Subject() Subject

func (*RelationQuery) ToURLQuery

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

type Subject

type Subject interface {
	// swagger:ignore
	String() string
	// swagger:ignore
	FromString(string) (Subject, error)
	// swagger:ignore
	Equals(interface{}) bool
	// swagger:ignore
	SubjectID() *string
	// swagger:ignore
	SubjectSet() *SubjectSet

	// swagger:ignore
	ToProto() *acl.Subject
}

swagger:model subject

func SubjectFromProto

func SubjectFromProto(gs *acl.Subject) (Subject, error)

swagger:ignore

func SubjectFromString

func SubjectFromString(s string) (Subject, error)

type SubjectID

type SubjectID struct {
	ID string `json:"id"`
}

func (*SubjectID) Equals

func (s *SubjectID) Equals(v interface{}) bool

func (*SubjectID) FromString

func (s *SubjectID) FromString(str string) (Subject, error)

func (SubjectID) MarshalJSON

func (s SubjectID) MarshalJSON() ([]byte, error)

func (*SubjectID) String

func (s *SubjectID) String() string

func (*SubjectID) SubjectID

func (s *SubjectID) SubjectID() *string

func (*SubjectID) SubjectSet

func (s *SubjectID) SubjectSet() *SubjectSet

func (*SubjectID) ToProto

func (s *SubjectID) ToProto() *acl.Subject

swagger:ignore

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:parameters getExpand

func (*SubjectSet) Equals

func (s *SubjectSet) Equals(v interface{}) bool

func (*SubjectSet) FromString

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

func (*SubjectSet) FromURLQuery

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

func (*SubjectSet) String

func (s *SubjectSet) String() string

func (*SubjectSet) SubjectID

func (s *SubjectSet) SubjectID() *string

func (*SubjectSet) SubjectSet

func (s *SubjectSet) SubjectSet() *SubjectSet

func (*SubjectSet) ToProto

func (s *SubjectSet) ToProto() *acl.Subject

swagger:ignore

func (*SubjectSet) ToURLQuery

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

type TupleData

type TupleData interface {
	// swagger:ignore
	GetSubject() *acl.Subject
	GetObject() string
	GetNamespace() string
	GetRelation() string
}

swagger:ignore

Jump to

Keyboard shortcuts

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