models

package
v4.2.1 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//ContextKeyUser is used as key to add the user data in the request context
	ContextKeyUser keyContext = iota
	//ContextKeyLoggerR is used as key to add the value of the http.Request at the CustomLogger middlewere execution
	ContextKeyLoggerR
	//UserLogin is used as key to add the userloging into the request context
	UserLogin
)

Variables

This section is empty.

Functions

func GetStringIssueState

func GetStringIssueState(issueState IssueState) string

GetStringIssueState gets the string representation of a IssueState

Types

type AbstractSituationInstance

type AbstractSituationInstance map[string]interface{}

AbstractSituationInstance wrap a standard map for evaluation

type Action

type Action struct {
	ID          int64  `json:"id"`
	Name        string `json:"name,omitempty"`
	Description string `json:"description,omitempty"`
	RootCauseID int64  `json:"rootCauseId"`
}

Action object that represents the actions to be taken for an Issue

func NewAction

func NewAction(id int64, name string, description string, rootCauseID int64) Action

NewAction returns a new action

func (*Action) IsValid

func (action *Action) IsValid() (bool, error)

IsValid checks if an action definition is valid and has no missing mandatory fields

type CaseInput

type CaseInput struct {
	Name      string    `json:"name"`
	Condition string    `json:"condition"`
	State     CaseState `json:"state"`
	Errors    []string  `json:"errors,omitempty"`
}

CaseInput : Input of a case in a rule evaluation

type CaseState

type CaseState int

CaseState state of a evaluated case (caseResult)

const (
	// OnError case on error
	OnError CaseState = iota + 1
	// NotEvaluated case not evaluated
	NotEvaluated
	// Met case evaluated and condition result equals to true
	Met
	// Unmet case evaluated and condition result equals to false
	Unmet
)

func (CaseState) MarshalJSON

func (s CaseState) MarshalJSON() ([]byte, error)

MarshalJSON marshals the enum as a quoted json string

func (CaseState) String

func (s CaseState) String() string

func (*CaseState) UnmarshalJSON

func (s *CaseState) UnmarshalJSON(b []byte) error

UnmarshalJSON unmashals a quoted json string to the enum value

type ExternalConfig added in v4.1.7

type ExternalConfig struct {
	Name string      `json:"name"`
	Data interface{} `json:"data"`
}

type FactValue

type FactValue interface {
	String() string
	SetCurrent(bool)
	GetType() string
	GetDeepness() int32
}

FactValue the current value of a fact

type FrontAction

type FrontAction struct {
	ID          int64   `json:"id"`
	Name        string  `json:"name"`
	Description string  `json:"description"`
	Selected    bool    `json:"selected"`
	Custom      bool    `json:"custom"`
	Occurrence  int64   `json:"occurrence"`
	UsageRate   float64 `json:"usageRate"`
}

FrontAction represent a single action

type FrontDraft

type FrontDraft = FrontRecommendation

FrontDraft is a type alias used for FrontRecommendation persistence It allow an easier recognition inside the different functions to distinguish User Draft and generated Recommendation

type FrontFactHistory

type FrontFactHistory struct {
	ID           int64                   `json:"id"`
	Name         string                  `json:"name"`
	Type         string                  `json:"type"`
	Deepness     int32                   `json:"deepness"`
	CurrentValue FactValue               `json:"currentValue"`
	History      map[time.Time]FactValue `json:"history"`
}

FrontFactHistory represents the current fact value and its history

type FrontRecommendation

type FrontRecommendation struct {
	ConcurrencyUUID string            `json:"uuid"`
	Tree            []*FrontRootCause `json:"tree"`
}

FrontRecommendation is the main exchange structure with the frontend It is used to display recommendations, and to process issue resolving draft and feedback

type FrontRootCause

type FrontRootCause struct {
	ID              int64          `json:"id"`
	Name            string         `json:"name"`
	Description     string         `json:"description"`
	Selected        bool           `json:"selected"`
	Custom          bool           `json:"custom"`
	Occurrence      int64          `json:"occurrence"`
	UsageRate       float64        `json:"usageRate"`
	ClusteringScore float64        `json:"clusteringScore"`
	Actions         []*FrontAction `json:"actions"`
}

FrontRootCause represent a single rootcause and its actions

type InputTask

type InputTask struct {
	SituationID        int64
	TS                 time.Time
	TemplateInstanceID int64
	Rule               RuleInput
}

InputTask represents the input that the tasker generates for all tasks

type Issue

type Issue struct {
	ID                 int64      `json:"id"`
	Key                string     `json:"key"`
	Name               string     `json:"name"`
	Level              IssueLevel `json:"level"`
	SituationID        int64      `json:"situationId"`
	SituationTS        time.Time  `json:"situationDate"`
	TemplateInstanceID int64      `json:"templateInstanceId"`
	ExpirationTS       time.Time  `json:"expirationDate"`
	Rule               RuleData   `json:"rule"`
	State              IssueState `json:"state"`
	CreationTS         time.Time  `json:"createdAt,omitempty"`
	LastModificationTS time.Time  `json:"lastModified"`
	DetectionRatingAvg float64    `json:"detectionRatingAvg,omitempty"`
	AssignedAt         *time.Time `json:"assignedAt,omitempty"`
	AssignedTo         *string    `json:"assignedTo,omitempty"`
	ClosedAt           *time.Time `json:"closedAt,omitempty"`
	CloseBy            *string    `json:"closedBy,omitempty"`
	Comment            *string    `json:"comment,omitempty"`
}

Issue is created for a situation to take Root causes and Actions

type IssueLevel

type IssueLevel int

IssueLevel state of a issue

const (
	// Info information level
	Info IssueLevel = iota + 1
	// Ok stable level
	Ok
	// Warning warning level
	Warning
	// Critical critical level
	Critical
)

func ToIssueLevel

func ToIssueLevel(s string) IssueLevel

ToIssueLevel get the IssueLevel from is string representation

func (IssueLevel) MarshalJSON

func (s IssueLevel) MarshalJSON() ([]byte, error)

MarshalJSON marshals the enum as a quoted json string

func (IssueLevel) String

func (s IssueLevel) String() string

func (*IssueLevel) UnmarshalJSON

func (s *IssueLevel) UnmarshalJSON(b []byte) error

UnmarshalJSON unmashals a quoted json string to the enum value

type IssueState

type IssueState int

IssueState represents the state in which the Issue is

const (
	// Open state of issue
	Open IssueState = iota + 1
	// Draft state of issue
	Draft
	// ClosedFeedback state of issue
	ClosedFeedback
	// ClosedNoFeedback state of issue
	ClosedNoFeedback
	// ClosedTimeout state of issue
	ClosedTimeout
	// ClosedDiscard state of issue
	ClosedDiscard
)

func ToIssueState

func ToIssueState(s string) IssueState

ToIssueState get the IssueState from is string representation

func (IssueState) IsClosed

func (s IssueState) IsClosed() bool

IsClosed returns if the IssueState is a closed state

func (IssueState) MarshalJSON

func (s IssueState) MarshalJSON() ([]byte, error)

MarshalJSON marshals the enum as a quoted json string

func (IssueState) String

func (s IssueState) String() string

func (*IssueState) UnmarshalJSON

func (s *IssueState) UnmarshalJSON(b []byte) error

UnmarshalJSON unmashals a quoted json string to the enum value

type MetaData

type MetaData struct {
	Key         string      `json:"key"`
	Value       interface{} `json:"value"`
	RuleID      int64       `json:"ruleId"`
	RuleVersion int64       `json:"ruleVersion"`
	CaseName    string      `json:"caseName"`
}

MetaData struct to represent a situation metadata

type NotSupportedValue

type NotSupportedValue struct {
	IsCurrent bool
}

NotSupportedValue value for not supported history facts

func (*NotSupportedValue) GetDeepness

func (factValue *NotSupportedValue) GetDeepness() int32

GetDeepness get deepness

func (*NotSupportedValue) GetType

func (factValue *NotSupportedValue) GetType() string

GetType get fact value type

func (*NotSupportedValue) SetCurrent

func (factValue *NotSupportedValue) SetCurrent(current bool)

SetCurrent set the IsCurrent boolean

func (*NotSupportedValue) String

func (factValue *NotSupportedValue) String() string

type ObjectValue

type ObjectValue struct {
	Attributes map[string]interface{} `json:"attributes"`
}

ObjectValue is a factValue implementation dedicated to object facts

func (*ObjectValue) GetDeepness

func (factValue *ObjectValue) GetDeepness() int32

GetDeepness get deepness

func (*ObjectValue) GetType

func (factValue *ObjectValue) GetType() string

GetType get fact value type

func (*ObjectValue) SetCurrent

func (factValue *ObjectValue) SetCurrent(current bool)

SetCurrent set the IsCurrent boolean

func (*ObjectValue) String

func (factValue *ObjectValue) String() string

type PaginatedResource

type PaginatedResource struct {
	Total int         `json:"total"`
	Items interface{} `json:"items"` // Usually a slice of struct
}

PaginatedResource wraps a list of resources with additionnal informations

type RootCause

type RootCause struct {
	ID          int64  `json:"id"`
	Name        string `json:"name,omitempty"`
	Description string `json:"description,omitempty"`
	SituationID int64  `json:"situationId"`
	RuleID      int64  `json:"ruleId"`
}

RootCause is the causes for the Issues

func NewRootCause

func NewRootCause(id int64, name string, description string, situationID int64, ruleID int64) RootCause

NewRootCause returns a new action

func (*RootCause) IsValid

func (rootcause *RootCause) IsValid() (bool, error)

IsValid checks if a rootcause definition is valid and has no missing mandatory fields

type RuleData

type RuleData struct {
	RuleID      int64  `json:"ruleId"`
	RuleVersion int64  `json:"ruleVersion"`
	CaseName    string `json:"caseName"`
}

RuleData rule identification

type RuleInput

type RuleInput struct {
	RuleID          int64       `json:"id"`
	RuleVersion     int64       `json:"version"`
	RuleTitle       string      `json:"title"`
	RuleDescription string      `json:"description"`
	CasesInput      []CaseInput `json:"cases,omitempty"`
}

RuleInput Input of one evaluation of the rule

type SearchOptions

type SearchOptions struct {
	Limit  int          `json:"limit"`
	Offset int          `json:"offset"`
	SortBy []SortOption `json:"sortBy"`
}

SearchOptions contains standard listing / search options

type SingleValue

type SingleValue struct {
	Key       string      `json:"key"`
	Value     interface{} `json:"value"`
	IsCurrent bool        `json:"isCurrent"`
}

SingleValue represents a fact with a single value

func (*SingleValue) GetDeepness

func (factValue *SingleValue) GetDeepness() int32

GetDeepness get deepness

func (*SingleValue) GetType

func (factValue *SingleValue) GetType() string

GetType get fact value type

func (*SingleValue) SetCurrent

func (factValue *SingleValue) SetCurrent(isCurrent bool)

SetCurrent set the IsCurrent boolean

func (*SingleValue) String

func (factValue *SingleValue) String() string

type SortOption

type SortOption struct {
	Field string          `json:"field"`
	Order SortOptionOrder `json:"order"`
}

SortOption contains a sort clause (field + ordering)

type SortOptionOrder

type SortOptionOrder int

SortOptionOrder indicate if the sorting is ASC or DESC

const (
	// Asc sort order
	Asc SortOptionOrder = iota + 1
	// Desc sort order
	Desc
)

func ToSortOptionOrder

func ToSortOptionOrder(s string) SortOptionOrder

ToSortOptionOrder get the SortOptionOrder from is string representation

func (SortOptionOrder) MarshalJSON

func (s SortOptionOrder) MarshalJSON() ([]byte, error)

MarshalJSON marshals the enum as a quoted json string

func (SortOptionOrder) String

func (s SortOptionOrder) String() string

func (*SortOptionOrder) UnmarshalJSON

func (s *SortOptionOrder) UnmarshalJSON(b []byte) error

UnmarshalJSON unmashals a quoted json string to the enum value

Jump to

Keyboard shortcuts

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