serviceweather

package
v0.0.0-...-d841f61 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2021 License: AGPL-3.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StatsCollection = "entity_stats"
)

Variables

This section is empty.

Functions

func ParseFilter

func ParseFilter(filter string) (bson.M, error)

func ValidateRequest

func ValidateRequest(sl validator.StructLevel)

Types

type API

type API interface {
	List(c *gin.Context)
	EntityList(c *gin.Context)
}

func NewApi

func NewApi(store Store) API

type AggregationResult

type AggregationResult struct {
	Data       []Service `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 AlarmCounter

type AlarmCounter struct {
	Count int64              `json:"count" bson:"count"`
	Type  pbehaviortype.Type `json:"type" bson:"type"`
}

type EntitiesListRequest

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

type Entity

type Entity struct {
	ID             string                   `json:"_id" bson:"_id"`
	Name           string                   `json:"name" bson:"name"`
	Infos          map[string]Info          `json:"infos" bson:"infos"`
	Type           string                   `json:"source_type" bson:"type"`
	Category       *entitycategory.Category `json:"category" bson:"category"`
	Connector      string                   `json:"connector" bson:"connector"`
	ConnectorName  string                   `json:"connector_name" bson:"connector_name"`
	Component      string                   `json:"component" bson:"component"`
	Resource       string                   `json:"resource" bson:"resource"`
	State          alarmapi.AlarmStep       `json:"state" bson:"state"`
	Status         alarmapi.AlarmStep       `json:"status" bson:"status"`
	Snooze         *alarmapi.AlarmStep      `json:"snooze" bson:"snooze"`
	Ack            *alarmapi.AlarmStep      `json:"ack" bson:"ack"`
	Ticket         *alarmapi.AlarmTicket    `json:"ticket" bson:"ticket"`
	LastUpdateDate types.CpsTime            `json:"last_update_date" bson:"last_update_date" swaggertype:"integer"`
	CreationDate   types.CpsTime            `json:"alarm_creation_date" bson:"creation_date" swaggertype:"integer"`
	DisplayName    string                   `json:"alarm_display_name" bson:"display_name"`
	Icon           string                   `json:"icon" bson:"icon"`
	Pbehaviors     []pbehavior.PBehavior    `json:"pbehaviors" bson:"-"`
	PbehaviorInfo  types.PbehaviorInfo      `json:"-" bson:"pbehavior_info"`
	Links          []WeatherLink            `json:"linklist" bson:"-"`
	Stats          Stats                    `json:"stats" bson:"-"`
	IsGrey         bool                     `json:"is_grey"`
	ImpactLevel    int                      `json:"impact_level" bson:"impact_level"`
	ImpactState    int                      `json:"impact_state" bson:"impact_state"`
	IdleSince      *types.CpsTime           `json:"idle_since,omitempty" bson:"idle_since,omitempty" swaggertype:"integer"`
}

type EntityAggregationResult

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

func (*EntityAggregationResult) GetData

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

func (*EntityAggregationResult) GetTotal

func (r *EntityAggregationResult) GetTotal() int64

type Info

type Info struct {
	Description string      `bson:"description,omitempty" json:"description"`
	Value       interface{} `bson:"value" json:"value"`
}

type ListRequest

type ListRequest struct {
	EntitiesListRequest
	Category string `form:"category" json:"category"`
}

type Service

type Service struct {
	ID             string              `json:"_id" bson:"_id"`
	Name           string              `json:"name" bson:"name"`
	Infos          map[string]Info     `json:"infos" bson:"infos"`
	Connector      string              `json:"connector" bson:"connector"`
	ConnectorName  string              `json:"connector_name" bson:"connector_name"`
	Component      string              `json:"component" bson:"component"`
	Resource       string              `json:"resource" bson:"resource"`
	HasOpenAlarm   bool                `json:"is_action_required" bson:"has_open_alarm"`
	State          alarmapi.AlarmStep  `json:"state" bson:"state"`
	Status         alarmapi.AlarmStep  `json:"status" bson:"status"`
	Snooze         *alarmapi.AlarmStep `json:"snooze" bson:"snooze"`
	Ack            *alarmapi.AlarmStep `json:"ack" bson:"ack"`
	Icon           string              `json:"icon" bson:"icon"`
	SecondaryIcon  string              `json:"secondary_icon" bson:"secondary_icon"`
	Output         string              `json:"output" bson:"output"`
	LastUpdateDate types.CpsTime       `json:"last_update_date" bson:"last_update_date" swaggertype:"integer"`
	AlarmCounters  []AlarmCounter      `json:"alarm_counters" bson:"alarm_counters"`
	Links          []struct {
		Name  string      `json:"cat_name" bson:"cat_name"`
		Links interface{} `json:"links" bson:"links"`
	} `json:"linklist" bson:"links"`
	Pbehaviors  []pbehavior.PBehavior    `json:"pbehaviors" bson:"-"`
	PbehaviorID string                   `json:"-" bson:"pbehavior_id"`
	ImpactLevel int                      `json:"impact_level" bson:"impact_level"`
	ImpactState int                      `json:"impact_state" bson:"impact_state"`
	Category    *entitycategory.Category `json:"category" bson:"category"`
	IsGrey      bool                     `json:"is_grey" bson:"is_grey"`
	IdleSince   *types.CpsTime           `json:"idle_since,omitempty" bson:"idle_since,omitempty" swaggertype:"integer"`
}

type Stats

type Stats struct {
	FailEventsCount int            `json:"ko" bson:"ko"`
	OKEventsCount   int            `json:"ok" bson:"ok"`
	LastFailEvent   *types.CpsTime `json:"last_ko" bson:"last_ko" swaggertype:"integer"`
	LastEvent       *types.CpsTime `json:"last_event" bson:"last_event" swaggertype:"integer"`
}

type StatsStore

type StatsStore interface {
	GetStats(context.Context, string, *time.Location) (Stats, error)
	SetStats(context.Context, string, Stats, *time.Location) error
	ResetStats(context.Context, string) error
}

StatsStore to read, save and reset entity stats

func NewStatsStore

func NewStatsStore(dbClient mongo.DbClient) StatsStore

NewStatsStore instantiates a StatsStore

type Store

type Store interface {
	Find(context.Context, ListRequest) (*AggregationResult, error)
	FindEntities(ctx context.Context, id, apiKey string, query EntitiesListRequest) (*EntityAggregationResult, error)
}

func NewStore

func NewStore(
	dbClient mongo.DbClient,
	legacyURL fmt.Stringer,
	statsStore StatsStore,
	timezoneConfigProvider config.TimezoneConfigProvider,
	pbhStore redis.Store,
	pbhService pbehaviorlib.Service,
) Store
type WeatherLink struct {
	Category string      `json:"cat_name"`
	Links    interface{} `json:"links"`
}

Jump to

Keyboard shortcuts

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