scenario

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: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewApi

func NewApi(
	store Store,
	actionLogger logger.ActionLogger,
) common.CrudAPI

func ValidateActionRequest

func ValidateActionRequest(sl validator.StructLevel)

func ValidateChangeStateParametersRequest

func ValidateChangeStateParametersRequest(sl validator.StructLevel)

func ValidateEditRequest

func ValidateEditRequest(sl validator.StructLevel)

func ValidatePbehaviorParametersRequest

func ValidatePbehaviorParametersRequest(sl validator.StructLevel)

func ValidateWebhookRequest

func ValidateWebhookRequest(sl validator.StructLevel)

Types

type Action

type Action struct {
	Type                     string                    `bson:"type" json:"type"`
	Parameters               map[string]interface{}    `bson:"parameters,omitempty" json:"parameters,omitempty"`
	AlarmPatterns            pattern.AlarmPatternList  `bson:"alarm_patterns" json:"alarm_patterns"`
	EntityPatterns           pattern.EntityPatternList `bson:"entity_patterns" json:"entity_patterns"`
	DropScenarioIfNotMatched bool                      `bson:"drop_scenario_if_not_matched" json:"drop_scenario_if_not_matched"`
	EmitTrigger              bool                      `bson:"emit_trigger" json:"emit_trigger"`
}

type ActionRequest

type ActionRequest struct {
	Type                     string                    `json:"type" binding:"required"`
	Parameters               interface{}               `json:"parameters,omitempty"`
	AlarmPatterns            pattern.AlarmPatternList  `json:"alarm_patterns"`
	EntityPatterns           pattern.EntityPatternList `json:"entity_patterns"`
	DropScenarioIfNotMatched *bool                     `json:"drop_scenario_if_not_matched" binding:"required"`
	EmitTrigger              *bool                     `json:"emit_trigger" binding:"required"`
}

func (*ActionRequest) UnmarshalJSON

func (r *ActionRequest) UnmarshalJSON(b []byte) error

type AggregationResult

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

func (AggregationResult) GetData

func (r AggregationResult) GetData() interface{}

GetData implementation PaginatedData interface

func (AggregationResult) GetTotal

func (r AggregationResult) GetTotal() int64

GetTotal implementation PaginatedData interface

type AssocTicketParametersRequest

type AssocTicketParametersRequest struct {
	Ticket string `json:"ticket" binding:"required,max=255"`
	Output string `json:"output" binding:"max=255"`
	Author string `json:"author" swaggerignore:"true"`
}

type ChangeStateParametersRequest

type ChangeStateParametersRequest struct {
	State  *types.CpsNumber `json:"state" binding:"required"`
	Output string           `json:"output" binding:"required,max=255"`
	Author string           `json:"author" swaggerignore:"true"`
}

type EditRequest

type EditRequest struct {
	ID                   string                  `json:"-"`
	Name                 string                  `json:"name" binding:"required,max=255"`
	Author               string                  `json:"author" binding:"required,max=255"`
	Enabled              *bool                   `json:"enabled" binding:"required"`
	Priority             int                     `json:"priority" binding:"required"`
	Triggers             []string                `json:"triggers" binding:"required,notblank"`
	DisableDuringPeriods []string                `json:"disable_during_periods"`
	Delay                *types.DurationWithUnit `json:"delay"`
	Actions              []ActionRequest         `json:"actions" binding:"required,notblank,dive"`
}

type FilteredQuery

type FilteredQuery struct {
	pagination.FilteredQuery
	SortBy string `json:"sort_by" form:"sort_by" binding:"oneoforempty=_id name author expected_interval created updated enabled priority delay"`
}

type ModelTransformer

type ModelTransformer interface {
	TransformEditRequestToModel(request EditRequest) libaction.Scenario
}

func NewModelTransformer

func NewModelTransformer() ModelTransformer

type ParametersRequest

type ParametersRequest struct {
	Output string `json:"output" binding:"max=255"`
	Author string `json:"author" swaggerignore:"true"`
}

type PbehaviorParametersRequest

type PbehaviorParametersRequest struct {
	Name           string                  `json:"name" binding:"required,max=255"`
	Author         string                  `json:"author" swaggerignore:"true"`
	Reason         string                  `json:"reason" binding:"required"`
	Type           string                  `json:"type" binding:"required"`
	RRule          string                  `json:"rrule"`
	Tstart         *int                    `json:"tstart" binding:"required_with=Tstop"`
	Tstop          *int                    `json:"tstop" binding:"required_with=Tstart"`
	StartOnTrigger *bool                   `json:"start_on_trigger" binding:"required_with=Duration" mapstructure:"start_on_trigger"`
	Duration       *types.DurationWithUnit `json:"duration" binding:"required_with=StartOnTrigger"`
}

type Scenario

type Scenario struct {
	ID                   string                  `bson:"_id" json:"_id"`
	Name                 string                  `bson:"name" json:"name"`
	Author               string                  `bson:"author" json:"author"`
	Enabled              bool                    `bson:"enabled" json:"enabled"`
	DisableDuringPeriods []string                `bson:"disable_during_periods" json:"disable_during_periods"`
	Triggers             []string                `bson:"triggers" json:"triggers"`
	Actions              []Action                `bson:"actions" json:"actions"`
	Priority             int                     `bson:"priority" json:"priority"`
	Delay                *types.DurationWithUnit `bson:"delay" json:"delay"`
	Created              types.CpsTime           `bson:"created,omitempty" json:"created,omitempty" swaggertype:"integer"`
	Updated              types.CpsTime           `bson:"updated,omitempty" json:"updated,omitempty" swaggertype:"integer"`
}

type SnoozeParametersRequest

type SnoozeParametersRequest struct {
	Duration *types.DurationWithUnit `json:"duration" binding:"required"`
	Output   string                  `json:"output" binding:"max=255"`
	Author   string                  `json:"author" swaggerignore:"true"`
}

type Store

type Store interface {
	Insert(EditRequest) (*Scenario, error)
	Find(FilteredQuery) (*AggregationResult, error)
	GetOneBy(id string) (*Scenario, error)
	Update(EditRequest) (*Scenario, error)
	Delete(id string) (bool, error)
}

Store is an interface for scenarios storage

func NewStore

func NewStore(db mongo.DbClient) Store

NewStore instantiates scenario store.

type WebhookDeclareTicket

type WebhookDeclareTicket struct {
	EmptyResponse bool              `mapstructure:"empty_response"`
	IsRegexp      bool              `mapstructure:"is_regexp"`
	Fields        map[string]string `mapstructure:",remain"`
}

func (WebhookDeclareTicket) MarshalJSON

func (t WebhookDeclareTicket) MarshalJSON() ([]byte, error)

type WebhookParameterRequest

type WebhookParameterRequest struct {
	Request       WebhookRequest          `json:"request" binding:"required"`
	DeclareTicket *WebhookDeclareTicket   `json:"declare_ticket" mapstructure:"declare_ticket"`
	RetryCount    int64                   `json:"retry_count" mapstructure:"retry_count" binding:"min=0"`
	RetryDelay    *types.DurationWithUnit `json:"retry_delay" mapstructure:"retry_delay"`
}

type WebhookRequest

type WebhookRequest struct {
	URL    string `json:"url" binding:"required,url"`
	Method string `json:"method" binding:"required"`
	Auth   *struct {
		Username string `json:"username" binding:"required"`
		Password string `json:"password" binding:"required"`
	} `json:"auth"`
	Headers    map[string]string `json:"headers"`
	Payload    string            `json:"payload"`
	SkipVerify *bool             `json:"skip_verify" mapstructure:"skip_verify"`
}

Jump to

Keyboard shortcuts

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