api

package
v1.4.21 Latest Latest
Warning

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

Go to latest
Published: May 15, 2024 License: MIT Imports: 12 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Aggregation

type Aggregation struct {
	Items    []AggregationItem `json:"items,omitempty"`
	Grouping []GroupingItem    `json:"grouping,omitempty"`
}

type AggregationAlgorithm

type AggregationAlgorithm string
const (
	Count AggregationAlgorithm = "COUNT"
	Sum   AggregationAlgorithm = "SUM"
	Avg   AggregationAlgorithm = "AVG"
	Max   AggregationAlgorithm = "MAX"
	Min   AggregationAlgorithm = "MIN"
)

type AggregationItem

type AggregationItem struct {
	Name      string               `json:"name,omitempty"`
	Algorithm AggregationAlgorithm `json:"algorithm,omitempty"`
	Property  string               `json:"property,omitempty"`
}

type Direction

type Direction string
const (
	Asc  Direction = "ASC"
	Desc Direction = "DESC"
)

type Entity added in v1.3.81

type Entity interface {
}

type EntityListResult added in v1.3.81

type EntityListResult[T Entity] struct {
	Total   uint32 `json:"total"`
	Content []T    `json:"content"`
}

type GroupingItem

type GroupingItem struct {
	Property string `json:"property,omitempty"`
}

type Interface

Interface Api interface is a facade for all api services /*

func NewInterface

func NewInterface(container service.Container) Interface

func NewInterface2 added in v1.3.67

func NewInterface2(resourceService InterfaceResourceService, recordService InterfaceRecordService) Interface

type InterfaceRecordService added in v1.3.67

type InterfaceRecordService interface {
	Create(ctx context.Context, params service.RecordCreateParams) ([]*model.Record, error)
	Update(ctx context.Context, params service.RecordUpdateParams) ([]*model.Record, error)
	Apply(ctx context.Context, params service.RecordUpdateParams) ([]*model.Record, error)
	Delete(ctx context.Context, params service.RecordDeleteParams) error
	Load(ctx context.Context, namespace string, name string, properties map[string]*structpb.Value, listParams service.RecordLoadParams) (*model.Record, error)
	List(ctx context.Context, params service.RecordListParams) ([]*model.Record, uint32, error)
}

type InterfaceResourceService added in v1.3.67

type InterfaceResourceService interface {
	GetResourceByName(ctx context.Context, namespace, resource string) (*model.Resource, error)
	Create(ctx context.Context, resource *model.Resource, doMigration bool, forceMigration bool) (*model.Resource, error)
	Update(ctx context.Context, resource *model.Resource, doMigration bool, forceMigration bool) error
	Delete(ctx context.Context, ids []string, doMigration bool, forceMigration bool) error
	List(ctx context.Context) ([]*model.Resource, error)
}

type ListParams

type ListParams struct {
	Query             *resource_model.BooleanExpression `json:"query,omitempty"`
	Type              string                            `type:"and,omitempty"`
	Limit             uint32                            `json:"limit,omitempty"`
	Offset            uint64                            `json:"offset,omitempty"`
	UseHistory        bool                              `json:"useHistory,omitempty"`
	ResolveReferences []string                          `json:"resolveReferences,omitempty"`
	Filters           map[string]interface{}            `json:"filters,omitempty"`
	Aggregation       *Aggregation                      `json:"aggregation,omitempty"`
	Sorting           []SortingItem                     `json:"sorting,omitempty"`
}

type LoadParams

type LoadParams struct {
	UseHistory        bool     `json:"useHistory,omitempty"`
	ResolveReferences []string `json:"resolveReferences,omitempty"`
}

type Mapper added in v1.3.81

type Mapper[T Entity] interface {
	ToRecord(user T) *model.Record
	FromRecord(record *model.Record) T
	ToUnstructured(user T) unstructured.Unstructured
}

type RecordListResult

type RecordListResult struct {
	Total   uint32                      `json:"total"`
	Content []unstructured.Unstructured `json:"content"`
}

type Repository added in v1.3.81

type Repository[T Entity] interface {
	Create(ctx context.Context, entity T) (T, error)
	Update(ctx context.Context, entity T) (T, error)
	Apply(ctx context.Context, entity T) (T, error)
	Load(ctx context.Context, entity T, params LoadParams) (T, error)
	Delete(ctx context.Context, entity T) error
	List(ctx context.Context, params ListParams) (EntityListResult[T], error)
	GetResourceByType(ctx context.Context, typeName string) (*resource_model.Resource, error)
}

func NewRepository added in v1.3.81

func NewRepository[T Entity](api Interface, mapper Mapper[T]) Repository[T]

type SaveMode

type SaveMode int
const (
	Create SaveMode = iota
	Update
	Apply
)

type SortingItem

type SortingItem struct {
	Property  string    `json:"property,omitempty"`
	Direction Direction `json:"direction,omitempty"`
}

Jump to

Keyboard shortcuts

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