pbehavior

package
v0.0.0-...-7ff62be Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2024 License: AGPL-3.0 Imports: 43 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetNestedExdatesPipeline

func GetNestedExdatesPipeline(authorProvider author.Provider) []bson.M

func GetNestedObjectsPipeline

func GetNestedObjectsPipeline(authorProvider author.Provider) []bson.M

func GetNestedReasonPipeline

func GetNestedReasonPipeline(authorProvider author.Provider) []bson.M

func GetNestedTypePipeline

func GetNestedTypePipeline(authorProvider author.Provider) []bson.M

Types

type API

type API interface {
	common.BulkCrudAPI
	Patch(c *gin.Context)
	DeleteByName(c *gin.Context)
	ListByEntityID(c *gin.Context)
	CalendarByEntityID(c *gin.Context)
	ListEntities(c *gin.Context)
	BulkEntityCreate(c *gin.Context)
	BulkEntityDelete(c *gin.Context)
	BulkConnectorCreate(c *gin.Context)
	BulkConnectorDelete(c *gin.Context)
	DBExport(c *gin.Context)
}

func NewApi

func NewApi(
	store Store,
	mongoExporter dbexport.Exporter,
	computeChan chan<- rpc.PbehaviorRecomputeEvent,
	transformer common.PatternFieldsTransformer,
	logger zerolog.Logger,
) API

type AggregationEntitiesResult

type AggregationEntitiesResult struct {
	Data       []entity.Entity `bson:"data" json:"data"`
	TotalCount int64           `bson:"total_count" json:"total_count"`
}

func (*AggregationEntitiesResult) GetData

func (r *AggregationEntitiesResult) GetData() interface{}

func (*AggregationEntitiesResult) GetTotal

func (r *AggregationEntitiesResult) GetTotal() int64

type AggregationResult

type AggregationResult struct {
	Data       []Response `bson:"data" json:"data"`
	TotalCount int64      `bson:"total_count" json:"total_count"`
}

func (*AggregationResult) GetData

func (r *AggregationResult) GetData() interface{}

func (*AggregationResult) GetTotal

func (r *AggregationResult) GetTotal() int64

type BulkConnectorCreateRequestItem

type BulkConnectorCreateRequestItem struct {
	Author   string            `json:"author" swaggerignore:"true"`
	Entities []string          `json:"entities" binding:"required,notblank"`
	Origin   string            `json:"origin" binding:"required,max=255"`
	Start    *datetime.CpsTime `json:"tstart" binding:"required" swaggertype:"integer"`
	Stop     *datetime.CpsTime `json:"tstop" binding:"required" swaggertype:"integer"`
	Comment  string            `json:"comment" binding:"required"`
	Name     string            `json:"name" binding:"required,max=255"`
	Reason   string            `json:"reason" binding:"required"`
	Type     string            `json:"type" binding:"required"`
	Color    string            `json:"color" binding:"iscolororempty"`
}

type BulkConnectorDeleteRequestItem

type BulkConnectorDeleteRequestItem struct {
	Author   string            `json:"author" swaggerignore:"true"`
	Entities []string          `json:"entities" binding:"required,notblank"`
	Origin   string            `json:"origin" binding:"required"`
	Start    *datetime.CpsTime `json:"tstart" binding:"required" swaggertype:"integer"`
	Stop     *datetime.CpsTime `json:"tstop" binding:"required" swaggertype:"integer"`
	Comment  string            `json:"comment" binding:"required"`
}

type BulkDeleteRequestItem

type BulkDeleteRequestItem struct {
	ID string `json:"_id" binding:"required"`
}

type BulkEntityCreateRequestItem

type BulkEntityCreateRequestItem struct {
	Author  string            `json:"author" swaggerignore:"true"`
	Entity  string            `json:"entity" binding:"required"`
	Origin  string            `json:"origin" binding:"required,max=255"`
	Name    string            `json:"name" binding:"required,max=255"`
	Reason  string            `json:"reason" binding:"required"`
	Start   *datetime.CpsTime `json:"tstart" binding:"required" swaggertype:"integer"`
	Stop    *datetime.CpsTime `json:"tstop" swaggertype:"integer"`
	Type    string            `json:"type" binding:"required"`
	Color   string            `json:"color" binding:"iscolororempty"`
	Comment string            `json:"comment"`
}

type BulkEntityDeleteRequestItem

type BulkEntityDeleteRequestItem struct {
	Entity string `json:"entity" binding:"required"`
	Origin string `json:"origin" binding:"required"`
}

type BulkUpdateRequestItem

type BulkUpdateRequestItem struct {
	EditRequest
	ID string `json:"_id" binding:"required"`
}

type CalendarByEntityIDRequest

type CalendarByEntityIDRequest struct {
	ID   string           `form:"_id" json:"_id" binding:"required"`
	From datetime.CpsTime `form:"from" json:"from" binding:"required" swaggertype:"integer"`
	To   datetime.CpsTime `form:"to" json:"to" binding:"required" swaggertype:"integer"`
}

type CalendarResponse

type CalendarResponse struct {
	ID    string           `json:"_id"`
	Title string           `json:"title"`
	Color string           `json:"color"`
	From  datetime.CpsTime `json:"from" swaggertype:"integer"`
	To    datetime.CpsTime `json:"to" swaggertype:"integer"`
	Type  pbehavior.Type   `json:"type"`
}

type CreateRequest

type CreateRequest struct {
	EditRequest
	ID string `json:"_id" binding:"id"`
}

type DeleteByNameRequest

type DeleteByNameRequest struct {
	Name string `form:"name" json:"name" binding:"required"`
}

type EditRequest

type EditRequest struct {
	Author     string                             `json:"author" swaggerignore:"true"`
	Enabled    *bool                              `json:"enabled" binding:"required"`
	Name       string                             `json:"name" binding:"required,max=255"`
	Reason     string                             `json:"reason" binding:"required"`
	RRule      string                             `json:"rrule"`
	Start      *datetime.CpsTime                  `json:"tstart" binding:"required" swaggertype:"integer"`
	Stop       *datetime.CpsTime                  `json:"tstop" swaggertype:"integer"`
	Type       string                             `json:"type" binding:"required"`
	Exdates    []pbehaviorexception.ExdateRequest `json:"exdates" binding:"dive"`
	Exceptions []string                           `json:"exceptions"`
	Color      string                             `json:"color" binding:"iscolororempty"`

	common.EntityPatternFieldsRequest
}

type EntitiesListRequest

type EntitiesListRequest struct {
	pagination.FilteredQuery
	SortBy string `form:"sort_by" json:"sort_by" binding:"oneoforempty=_id name type"`
}

type FindByEntityIDRequest

type FindByEntityIDRequest struct {
	ID        string `form:"_id" binding:"required"`
	WithFlags bool   `form:"with_flags"`
}

type ListRequest

type ListRequest struct {
	pagination.FilteredQuery
	SortBy string `` /* 185-byte string literal not displayed */
}

type MongoQuery

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

func CreateMongoQuery

func CreateMongoQuery(client mongo.DbClient, authorProvider author.Provider) MongoQuery

func (*MongoQuery) CreateAggregationPipeline

func (q *MongoQuery) CreateAggregationPipeline(ctx context.Context, r ListRequest) ([]bson.M, error)

type NullableTime

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

func (*NullableTime) UnmarshalJSON

func (t *NullableTime) UnmarshalJSON(data []byte) error

type PatchRequest

type PatchRequest struct {
	ID         string                             `json:"-"`
	Author     string                             `json:"author" swaggerignore:"true"`
	Name       *string                            `json:"name"`
	Enabled    *bool                              `json:"enabled"`
	Reason     *string                            `json:"reason"`
	Type       *string                            `json:"type"`
	Start      *int64                             `json:"tstart" swaggertype:"integer"`
	Stop       NullableTime                       `json:"tstop" swaggertype:"integer"`
	RRule      *string                            `json:"rrule"`
	Exdates    []pbehaviorexception.ExdateRequest `json:"exdates" binding:"dive"`
	Exceptions []string                           `json:"exceptions"`
	Color      *string                            `json:"color"`

	EntityPattern          pattern.Entity             `json:"entity_pattern"`
	CorporateEntityPattern *string                    `json:"corporate_entity_pattern"`
	CorporatePattern       *savedpattern.SavedPattern `json:"-"`
}

type Response

type Response struct {
	ID            string                        `bson:"_id" json:"_id"`
	Author        *author.Author                `bson:"author" json:"author"`
	Comments      []pbehaviorcomment.Response   `bson:"comments" json:"comments"`
	Enabled       bool                          `bson:"enabled" json:"enabled"`
	Name          string                        `bson:"name" json:"name"`
	Reason        *pbehaviorreason.Response     `bson:"reason" json:"reason"`
	RRule         string                        `bson:"rrule" json:"rrule"`
	RRuleEnd      *datetime.CpsTime             `bson:"rrule_end" json:"rrule_end" swaggertype:"integer"`
	Start         *datetime.CpsTime             `bson:"tstart" json:"tstart" swaggertype:"integer"`
	Stop          *datetime.CpsTime             `bson:"tstop" json:"tstop" swaggertype:"integer"`
	Created       *datetime.CpsTime             `bson:"created" json:"created" swaggertype:"integer"`
	Updated       *datetime.CpsTime             `bson:"updated" json:"updated" swaggertype:"integer"`
	Type          *pbehaviortype.Response       `bson:"type" json:"type"`
	Color         string                        `bson:"color" json:"color"`
	Exdates       []pbehaviorexception.Exdate   `bson:"exdates" json:"exdates"`
	Exceptions    []pbehaviorexception.Response `bson:"exceptions" json:"exceptions"`
	LastAlarmDate *datetime.CpsTime             `bson:"last_alarm_date,omitempty" json:"last_alarm_date" swaggertype:"integer"`
	AlarmCount    int64                         `bson:"alarm_count" json:"alarm_count"`
	// IsActiveStatus represents if pbehavior is in action for current time.
	IsActiveStatus *bool `bson:"-" json:"is_active_status,omitempty"`

	Origin   string `bson:"origin" json:"origin"`
	Editable *bool  `bson:"editable,omitempty" json:"editable,omitempty"`

	savedpattern.EntityPatternFields `bson:",inline"`

	RRuleComputedStart *datetime.CpsTime `bson:"rrule_cstart" json:"-"`
}

type Store

type Store interface {
	Insert(ctx context.Context, r CreateRequest) (*Response, error)
	Find(ctx context.Context, r ListRequest) (*AggregationResult, error)
	FindByEntityID(ctx context.Context, entity libtypes.Entity, r FindByEntityIDRequest) ([]Response, error)
	CalendarByEntityID(ctx context.Context, entity libtypes.Entity, r CalendarByEntityIDRequest) ([]CalendarResponse, error)
	GetOneBy(ctx context.Context, id string) (*Response, error)
	FindEntities(ctx context.Context, pbhID string, request EntitiesListRequest) (*AggregationEntitiesResult, error)
	Update(ctx context.Context, r UpdateRequest) (*Response, error)
	UpdateByPatch(ctx context.Context, r PatchRequest) (*Response, error)
	Delete(ctx context.Context, id, userID string) (bool, error)
	DeleteByName(ctx context.Context, name, userID string) (string, error)
	FindEntity(ctx context.Context, entityId string) (*libtypes.Entity, error)
	EntityInsert(ctx context.Context, r BulkEntityCreateRequestItem) (*Response, error)
	EntityDelete(ctx context.Context, r BulkEntityDeleteRequestItem) (string, error)
	ConnectorCreate(ctx context.Context, r BulkConnectorCreateRequestItem) (*Response, error)
	ConnectorDelete(ctx context.Context, r BulkConnectorDeleteRequestItem) (string, error)
}

func NewStore

func NewStore(
	dbClient mongo.DbClient,
	entityTypeResolver pbehavior.EntityTypeResolver,
	pbhTypeComputer pbehavior.TypeComputer,
	timezoneConfigProvider config.TimezoneConfigProvider,
	authorProvider author.Provider,
) Store

type UpdateRequest

type UpdateRequest struct {
	EditRequest
	ID string `json:"-"`
}

type Validator

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

func NewValidator

func NewValidator(client mongo.DbClient) *Validator

func (*Validator) ValidateCalendarRequest

func (v *Validator) ValidateCalendarRequest(sl validator.StructLevel)

func (*Validator) ValidateConnectorCreateRequest

func (v *Validator) ValidateConnectorCreateRequest(ctx context.Context, sl validator.StructLevel)

func (*Validator) ValidateCreateRequest

func (v *Validator) ValidateCreateRequest(sl validator.StructLevel)

func (*Validator) ValidateEditRequest

func (v *Validator) ValidateEditRequest(ctx context.Context, sl validator.StructLevel)

func (*Validator) ValidateEntityCreateRequest

func (v *Validator) ValidateEntityCreateRequest(ctx context.Context, sl validator.StructLevel)

func (*Validator) ValidatePatchRequest

func (v *Validator) ValidatePatchRequest(ctx context.Context, sl validator.StructLevel)

func (*Validator) ValidateUpdateRequest

func (v *Validator) ValidateUpdateRequest(sl validator.StructLevel)

Jump to

Keyboard shortcuts

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