api

package
v0.0.0-...-8122643 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	TargetSelf   = "self"
	TargetParent = "parent"
	TargetChild  = "parent"
)
View Source
const ForwardContext = "X-Forward-Context"
View Source
const ForwardOpSource = "X-Forward-Op-Source"
View Source
const ForwardSessionClient = "X-Forward-Session-Client"
View Source
const ForwardUserDisplay = "X-Forward-User-Display"
View Source
const ForwardUserId = "X-Forward-User-Id"
View Source
const ForwardUserLogin = "X-Forward-User-Login"

Variables

This section is empty.

Functions

func HateoasList

func HateoasList(response ResponseListI, parentResource Resource, resourceType string)

func InjectHateoasLinksToObject

func InjectHateoasLinksToObject(resource Resource, withLinks WithHateoasLinks)

func PrepareCollectionAndNameResource

func PrepareCollectionAndNameResource(typeName string) (serviceName string, collectionResource Resource, objectResource Resource)

Types

type DbQuery

type DbQuery struct {
	WithDbQuery
}

func NewDbQuery

func NewDbQuery(filter *db.Filter) *DbQuery

func (*DbQuery) Query

func (d *DbQuery) Query() string

func (*DbQuery) SetQuery

func (d *DbQuery) SetQuery(q string)
type HateoasLink struct {
	Target     string `json:"target,omitempty"`
	Operation  string `json:"operation,omitempty"`
	HttpMethod string `json:"http_method,omitempty"`
	Host       string `json:"host,omitempty"`
	Path       string `json:"path,omitempty"`
}
func MakeHateoasLinks(resource Resource, withTestOps ...bool) []*HateoasLink
type HateoasLinksContainer struct {
	HateoasLinks []*HateoasLink `json:"_links,omitempty" gorm:"-:all"`
}
func (h *HateoasLinksContainer) SetHateoasLinks(links []*HateoasLink)

type HateoasLinksItem

type HateoasLinksItem struct {
	common.IDBase
	HateoasLinksContainer
}

type HateoasLinksStub

type HateoasLinksStub struct {
}
func (h *HateoasLinksStub) SetHateoasLinks(links []*HateoasLink)
type ObjectWithHateoasLinks interface {
	common.WithID
	WithHateoasLinks
}

type Operation

type Operation interface {
	Name() string

	SetResource(resource Resource)
	Resource() Resource

	AccessType() access_control.AccessType
	Exec(ctx op_context.Context, handler OperationHandler) error
	ExecInTenancy(ctx multitenancy.TenancyContext, handler TenancyOperationHandler) error

	TestOnly() bool
	SetTestOnly(val bool)
}

func Add

func Add(name string) Operation

func Bind

func Bind(name string) Operation

func Check

func Check(name string) Operation

func Create

func Create(name string) Operation

func Delete

func Delete(name string) Operation

func Exists

func Exists(name string) Operation

func Find

func Find(name string) Operation

func Get

func Get(name string) Operation

func List

func List(name string) Operation

func NamedResourceOperation

func NamedResourceOperation(sampleResource Resource, resourceId string, op Operation) Operation

func NamedSubresourceOperation

func NamedSubresourceOperation(sampleResource Resource, resourceId string, subResourceName string, subResourceId string, op Operation) Operation

func OperationAsResource

func OperationAsResource(sampleResource Resource, resourceName string, resourceId string, op Operation) Operation

func Post

func Post(name string) Operation

func Read

func Read(name string) Operation

func SubresourceOperation

func SubresourceOperation(sampleResource Resource, resourceId string, subResourceName string, op Operation) Operation

func Unbind

func Unbind(name string) Operation

func Update

func Update(name string) Operation

func UpdatePartial

func UpdatePartial(name string) Operation

type OperationBase

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

func NewOperation

func NewOperation(name string, accessType access_control.AccessType, testOnly ...bool) *OperationBase

func (*OperationBase) AccessType

func (o *OperationBase) AccessType() access_control.AccessType

func (*OperationBase) Exec

func (o *OperationBase) Exec(ctx op_context.Context, handler OperationHandler) error

func (*OperationBase) ExecInTenancy

func (*OperationBase) Init

func (o *OperationBase) Init(name string, accessType access_control.AccessType, testOnly ...bool)

func (*OperationBase) Name

func (o *OperationBase) Name() string

func (*OperationBase) Resource

func (o *OperationBase) Resource() Resource

func (*OperationBase) SetResource

func (o *OperationBase) SetResource(resource Resource)

func (*OperationBase) SetTestOnly

func (o *OperationBase) SetTestOnly(val bool)

func (*OperationBase) TestOnly

func (o *OperationBase) TestOnly() bool

type OperationHandler

type OperationHandler = func(ctx op_context.Context, operation Operation) error

type Query

type Query interface {
	Query() string
	SetQuery(q string)
}

type QueryWithGroupBy

type QueryWithGroupBy struct {
	*DbQuery
	WithGroupBy
}

type Resource

type Resource interface {
	Host() string
	SetHost(val string)

	Type() string
	Id() string
	SetId(val string, rebuild ...bool)

	HasId() bool
	SetHasId(val bool)

	IsService() bool
	SetSetvice(val bool)
	IsServicePart() bool
	ServiceResource() Resource

	IsTenancy() bool
	IsInTenancy() bool
	TenancyResourceInPath() Resource

	SetParent(parent Resource, rebuild ...bool)
	Parent() Resource
	AddChild(resource Resource, rebuild ...bool)
	AddChildren(resources ...Resource)
	Children() []Resource

	AddOperation(operation Operation, getter ...bool)
	AddOperations(operations ...Operation)
	Operations() []Operation
	Getter() Operation
	EachOperation(handler func(operation Operation) error, recursive ...bool) error
	RemoveOperations(accessType access_control.AccessType)
	RemoveOperation(name string)
	ReplaceOperation(op Operation)

	PathPrototype() string
	ParameterSubstitution() string
	ActualPath() string
	FullPathPrototype() string
	FullActualPath() string
	FullActualTenancyPath(tenancyId string) string
	ServicePathPrototype() string
	ServiceActualPath() string
	BuildActualPath(actualResourceIds map[string]string, service ...bool) string
	FillActualPaths(actualResourceIds map[string]string)
	ResetIds()

	RebuildPaths()

	Chain() []Resource
	ChainResourceId(resourceType string) string
	ChainHasResourceType(resourceType string) bool

	Clone(withOperations bool) Resource
	CloneChain(withOperations bool) Resource
}

func AddChildResource

func AddChildResource(resource Resource, childName string) Resource

func GroupResource

func GroupResource(resourceType string) Resource

func NamedResource

func NamedResource(resourceType string) Resource

func NamedSubresource

func NamedSubresource(sampleResource Resource, resourceId string, subResourceName string, subResourceId string) Resource

func NewResourceWithNamedSubresource

func NewResourceWithNamedSubresource(resourceName string, subResourceName string, op ...Operation) Resource

func NewResourceWithOp

func NewResourceWithOp(resourceName string, op Operation) Resource

func Subresource

func Subresource(sampleResource Resource, resourceId string, subResourceName string) Resource

type ResourceBase

type ResourceBase struct {
	ResourceConfig
	// contains filtered or unexported fields
}

func NewResource

func NewResource(resourceType string, config ...ResourceConfig) *ResourceBase

func NewTenancyResource

func NewTenancyResource(tenancyResourceName ...string) *ResourceBase

func (*ResourceBase) ActualPath

func (r *ResourceBase) ActualPath() string

func (*ResourceBase) AddChild

func (r *ResourceBase) AddChild(child Resource, rebuild ...bool)

func (*ResourceBase) AddChildren

func (r *ResourceBase) AddChildren(resources ...Resource)

func (*ResourceBase) AddOperation

func (r *ResourceBase) AddOperation(operation Operation, getter ...bool)

func (*ResourceBase) AddOperations

func (r *ResourceBase) AddOperations(operations ...Operation)

func (*ResourceBase) BuildActualPath

func (r *ResourceBase) BuildActualPath(actualResourceIds map[string]string, service ...bool) string

func (*ResourceBase) Chain

func (r *ResourceBase) Chain() []Resource

func (*ResourceBase) ChainHasResourceType

func (r *ResourceBase) ChainHasResourceType(resourceType string) bool

func (*ResourceBase) ChainResourceId

func (r *ResourceBase) ChainResourceId(resourceType string) string

func (*ResourceBase) Children

func (r *ResourceBase) Children() []Resource

func (*ResourceBase) Clone

func (r *ResourceBase) Clone(withOperations bool) Resource

func (*ResourceBase) CloneChain

func (r *ResourceBase) CloneChain(withOperations bool) Resource

func (*ResourceBase) EachOperation

func (r *ResourceBase) EachOperation(handler func(operation Operation) error, recursive ...bool) error

func (*ResourceBase) FillActualPaths

func (r *ResourceBase) FillActualPaths(actualResourceIds map[string]string)

func (*ResourceBase) FullActualPath

func (r *ResourceBase) FullActualPath() string

func (*ResourceBase) FullActualTenancyPath

func (r *ResourceBase) FullActualTenancyPath(tenancyPath string) string

func (*ResourceBase) FullPathPrototype

func (r *ResourceBase) FullPathPrototype() string

func (*ResourceBase) Getter

func (r *ResourceBase) Getter() Operation

func (*ResourceBase) HasId

func (r *ResourceBase) HasId() bool

func (*ResourceBase) Host

func (r *ResourceBase) Host() string

func (*ResourceBase) Id

func (r *ResourceBase) Id() string

func (*ResourceBase) Init

func (r *ResourceBase) Init(resourceType string, config ...ResourceConfig)

func (*ResourceBase) IsInTenancy

func (r *ResourceBase) IsInTenancy() bool

func (*ResourceBase) IsService

func (r *ResourceBase) IsService() bool

func (*ResourceBase) IsServicePart

func (r *ResourceBase) IsServicePart() bool

func (*ResourceBase) IsTenancy

func (r *ResourceBase) IsTenancy() bool

func (*ResourceBase) Operations

func (r *ResourceBase) Operations() []Operation

func (*ResourceBase) ParameterSubstitution

func (r *ResourceBase) ParameterSubstitution() string

func (*ResourceBase) Parent

func (r *ResourceBase) Parent() Resource

func (*ResourceBase) PathPrototype

func (r *ResourceBase) PathPrototype() string

func (*ResourceBase) RebuildPaths

func (r *ResourceBase) RebuildPaths()

func (*ResourceBase) RemoveOperation

func (r *ResourceBase) RemoveOperation(name string)

func (*ResourceBase) RemoveOperations

func (r *ResourceBase) RemoveOperations(accessType access_control.AccessType)

func (*ResourceBase) ReplaceOperation

func (r *ResourceBase) ReplaceOperation(op Operation)

func (*ResourceBase) ResetIds

func (r *ResourceBase) ResetIds()

func (*ResourceBase) ServiceActualPath

func (r *ResourceBase) ServiceActualPath() string

func (*ResourceBase) ServicePathPrototype

func (r *ResourceBase) ServicePathPrototype() string

func (*ResourceBase) ServiceResource

func (r *ResourceBase) ServiceResource() Resource

func (*ResourceBase) SetHasId

func (r *ResourceBase) SetHasId(val bool)

func (*ResourceBase) SetHost

func (r *ResourceBase) SetHost(val string)

func (*ResourceBase) SetId

func (r *ResourceBase) SetId(val string, rebuild ...bool)

func (*ResourceBase) SetParent

func (r *ResourceBase) SetParent(parent Resource, rebuild ...bool)

func (*ResourceBase) SetSetvice

func (r *ResourceBase) SetSetvice(val bool)

func (*ResourceBase) TenancyResourceInPath

func (r *ResourceBase) TenancyResourceInPath() Resource

func (*ResourceBase) Type

func (r *ResourceBase) Type() string

type ResourceConfig

type ResourceConfig struct {
	Host    string
	HasId   bool
	Service bool
	Id      string
	Tenancy bool
}

type Response

type Response interface {
	WithHateoasLinks
}

type ResponseBase

type ResponseBase struct {
	HateoasLinksContainer
}

type ResponseCount

type ResponseCount struct {
	Count int64 `json:"count,omitempty"`
}

type ResponseExists

type ResponseExists struct {
	ResponseStub
	Exists bool `json:"exists"`
}

type ResponseList

type ResponseList[T common.WithID] struct {
	ResponseCount
	Items []T `json:"items"`

	ResponseBase
	ItemLinks []*HateoasLinksItem `json:"_item_links,omitempty"`
}

func (*ResponseList[T]) ItemCount

func (r *ResponseList[T]) ItemCount() int

func (*ResponseList[T]) ItemId

func (r *ResponseList[T]) ItemId(index int) string
func (r *ResponseList[T]) MakeItemLinks()
func (r *ResponseList[T]) SetItemLink(index int, link *HateoasLinksItem)

type ResponseListI

type ResponseListI interface {
	Response
	ItemCount() int
	ItemId(index int) string
	MakeItemLinks()
	SetItemLink(index int, link *HateoasLinksItem)
}

type ResponseStub

type ResponseStub struct {
	HateoasLinksStub
}

type TenancyOperationHandler

type TenancyOperationHandler = func(ctx multitenancy.TenancyContext, operation Operation) error

type UpdateCmd

type UpdateCmd struct {
	Fields map[string]interface{} `json:"field"`
}

type WithDbQuery

type WithDbQuery struct {
	Query string `json:"query"`
}

type WithGroupBy

type WithGroupBy struct {
	GroupBy []string `json:"group_by"`
}

func (*WithGroupBy) Groups

func (w *WithGroupBy) Groups() []string
type WithHateoasLinks interface {
	SetHateoasLinks([]*HateoasLink)
}

Jump to

Keyboard shortcuts

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