resource

package
v0.0.0-...-8f66fda Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const SourceValue = "$_source_value"

Variables

View Source
var DefaultIdFieldTool = NewIdTool(structs.StructTagDirectiveProvider{"id"})

IdTool contains the configured tool to copy ids. It's initialized to id.DefaultIdFieldTool, but can be replaced if preferred.

Functions

func Id

func Id(sv reflect.Value) (string, gomerr.Gomerr)

func NewIdTool

func NewIdTool(dp structs.DirectiveProvider) *structs.Tool

NewIdTool produces a structs.Applier that will take each of the defined id fields and propagate them to another struct value. Todo:p3 specify that should be ordered in decreasing specificity.

func Register

func Register(instance Instance, collection Collection, actions map[interface{}]func() Action, dataStore data.Store, parentMetadata Metadata) (md *metadata, ge gomerr.Gomerr)

func RegisterIdGeneratorFieldFunction

func RegisterIdGeneratorFieldFunction(idGenerator id.Generator)

func SaveInstance

func SaveInstance(i Instance) gomerr.Gomerr

Types

type Action

type Action interface {
	Name() string
	AppliesToCategory() Category
	FieldAccessPermissions() auth.AccessPermissions
	Pre(Resource) gomerr.Gomerr
	Do(Resource) gomerr.Gomerr
	OnDoSuccess(Resource) (Resource, gomerr.Gomerr)
	OnDoFailure(Resource, gomerr.Gomerr) gomerr.Gomerr
}

func CreateAction

func CreateAction() Action

func DeleteAction

func DeleteAction() Action

func ListAction

func ListAction() Action

func ReadAction

func ReadAction() Action

func UpdateAction

func UpdateAction() Action

type BaseCollection

type BaseCollection struct {
	BaseResource
}

func (BaseCollection) MaximumPageSize

func (BaseCollection) MaximumPageSize() int

func (BaseCollection) PostList

func (BaseCollection) PostList() gomerr.Gomerr

func (BaseCollection) PreList

func (BaseCollection) PreList() gomerr.Gomerr

func (BaseCollection) TypeNames

func (c BaseCollection) TypeNames() []string

func (BaseCollection) TypeOf

func (c BaseCollection) TypeOf(interface{}) string

type BaseInstance

type BaseInstance struct {
	BaseResource
}

func (BaseInstance) Id

func (i BaseInstance) Id() string

func (BaseInstance) NewQueryable

func (i BaseInstance) NewQueryable() data.Queryable

func (BaseInstance) PostCreate

func (BaseInstance) PostCreate() gomerr.Gomerr

func (BaseInstance) PostDelete

func (BaseInstance) PostDelete() gomerr.Gomerr

func (BaseInstance) PostRead

func (BaseInstance) PostRead() gomerr.Gomerr

func (BaseInstance) PostUpdate

func (BaseInstance) PostUpdate(Resource) gomerr.Gomerr

func (BaseInstance) PreCreate

func (BaseInstance) PreCreate() gomerr.Gomerr

func (BaseInstance) PreDelete

func (BaseInstance) PreDelete() gomerr.Gomerr

func (BaseInstance) PreRead

func (BaseInstance) PreRead() gomerr.Gomerr

func (BaseInstance) PreUpdate

func (BaseInstance) PreUpdate(Resource) gomerr.Gomerr

func (BaseInstance) TypeName

func (i BaseInstance) TypeName() string

type BaseResource

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

func (*BaseResource) DoAction

func (b *BaseResource) DoAction(action Action) (Resource, gomerr.Gomerr)

func (*BaseResource) Metadata

func (b *BaseResource) Metadata() Metadata

func (*BaseResource) Subject

func (b *BaseResource) Subject() auth.Subject

type Category

type Category string
const (
	InstanceCategory   Category = "Instance"
	CollectionCategory Category = "Collection"
)

type Collectible

type Collectible interface {
	OnCollect(Resource) gomerr.Gomerr
}

type Collection

type Collection interface {
	Resource
	data.Queryable
}

type Creatable

type Creatable interface {
	Instance
	PreCreate() gomerr.Gomerr
	PostCreate() gomerr.Gomerr
}

type Deletable

type Deletable interface {
	Instance
	PreDelete() gomerr.Gomerr
	PostDelete() gomerr.Gomerr
}

type Instance

type Instance interface {
	Resource
	data.Persistable
	Id() string
}

type Listable

type Listable interface {
	Collection
	PreList() gomerr.Gomerr
	PostList() gomerr.Gomerr
}

type Metadata

type Metadata interface {
	ResourceType(Category) reflect.Type
	Actions() map[interface{}]func() Action
	// Parent() Metadata
	Children() []Metadata
}

type NoOpAction

type NoOpAction struct{}

func (NoOpAction) Do

func (NoOpAction) FieldAccessPermissions

func (NoOpAction) FieldAccessPermissions() auth.AccessPermissions

func (NoOpAction) Name

func (NoOpAction) Name() string

func (NoOpAction) OnDoFailure

func (NoOpAction) OnDoFailure(_ Resource, ge gomerr.Gomerr) gomerr.Gomerr

func (NoOpAction) OnDoSuccess

func (NoOpAction) OnDoSuccess(r Resource) (Resource, gomerr.Gomerr)

func (NoOpAction) Pre

type OnCreateFailer

type OnCreateFailer interface {
	OnCreateFailure(gomerr.Gomerr) gomerr.Gomerr
}

type OnDeleteFailer

type OnDeleteFailer interface {
	OnDeleteFailure(gomerr.Gomerr) gomerr.Gomerr
}

type OnListFailer

type OnListFailer interface {
	OnListFailure(gomerr.Gomerr) gomerr.Gomerr
}

type OnReadFailer

type OnReadFailer interface {
	OnReadFailure(gomerr.Gomerr) gomerr.Gomerr
}

type OnUpdateFailer

type OnUpdateFailer interface {
	OnUpdateFailure(gomerr.Gomerr) gomerr.Gomerr
}

type Readable

type Readable interface {
	Instance
	PreRead() gomerr.Gomerr
	PostRead() gomerr.Gomerr
}

type Resource

type Resource interface {
	Metadata() Metadata
	Subject() auth.Subject
	DoAction(Action) (Resource, gomerr.Gomerr)
	// contains filtered or unexported methods
}

func New

func New(resourceType reflect.Type, subject auth.Subject) (Resource, gomerr.Gomerr)

type Updatable

type Updatable interface {
	Instance
	PreUpdate(update Resource) gomerr.Gomerr
	PostUpdate(update Resource) gomerr.Gomerr
}

Jump to

Keyboard shortcuts

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