Documentation
¶
Index ¶
- Constants
- func AddAliasesVars(vars []VarResponse, aliases []AliasInfo, index int, prefix, suffix string) error
- func GetAlarmDataFromTest(ctx context.Context, collection mongo.DbCollection, testID string, ...) (types.AlarmWithEntity, error)
- func GetEventData(ctx context.Context, collection mongo.DbCollection, id string, ...) (*types.Event, error)
- func GetResponseData(ctx context.Context, collection mongo.DbCollection, idsByIndex map[int]string) (map[int]ResponseTestData, error)
- func ValidateEditDataRequest(sl validator.StructLevel)
- func ValidateEditTestRequest(sl validator.StructLevel)
- type API
- type AggregationDataResult
- type AggregationTestResult
- type AliasInfo
- type BulkDeleteRequestItem
- type DataModel
- type DataResponse
- type EditDataRequest
- type EditTestRequest
- type ListDataRequest
- type ListTestRequest
- type ResponseTestData
- type Store
- type TemplateCheckTicketStatus
- type TemplateParameters
- type TemplateRefParameters
- type TemplateWebhookDeclareTicket
- type TestModel
- type TestResponse
- type ValidateResponse
- type VarResponse
- func AddEnvVars(vars []VarResponse, tplConfigProvider config.TemplateConfigProvider) []VarResponse
- func GetAlarmCopyVars(alarmVar string) []VarResponse
- func GetAlarmVars(prefixVar, suffixVar, alarmVar string, pluralName bool) []VarResponse
- func GetEntityCopyVars(entityVar string) []VarResponse
- func GetEntityVars(prefixVar, suffixVar, entityVar string, pluralName bool) []VarResponse
- func GetEnvVars(tplConfigProvider config.TemplateConfigProvider) []VarResponse
- func GetEventCopyVars(eventVar string) []VarResponse
- func GetEventVars(prefixVar, suffixVar, eventVar string, pluralName bool) []VarResponse
Constants ¶
View Source
const ( TypeTestDataEvent = iota TypeTestDataResponse )
View Source
const ( TypeTestEventFilterRule = iota TypeTestLinkRule TypeTestActionScenario TypeTestWidget TypeTestDeclareTicketRule TypeTestDynamicInfosRule TypeTestInstruction TypeTestJob TypeTestMetaAlarmRule TypeTestWebhookTokenRule )
Variables ¶
This section is empty.
Functions ¶
func AddAliasesVars ¶
func AddAliasesVars(vars []VarResponse, aliases []AliasInfo, index int, prefix, suffix string) error
func GetAlarmDataFromTest ¶
func GetAlarmDataFromTest(ctx context.Context, collection mongo.DbCollection, testID string, ruleType int, ruleID string) (types.AlarmWithEntity, error)
func GetEventData ¶
func GetResponseData ¶
func GetResponseData(ctx context.Context, collection mongo.DbCollection, idsByIndex map[int]string) (map[int]ResponseTestData, error)
func ValidateEditDataRequest ¶
func ValidateEditDataRequest(sl validator.StructLevel)
func ValidateEditTestRequest ¶
func ValidateEditTestRequest(sl validator.StructLevel)
Types ¶
type API ¶
type API interface {
GetEnvVars(c *gin.Context)
CreateData(c *gin.Context)
ListData(c *gin.Context)
GetData(c *gin.Context)
UpdateData(c *gin.Context)
DeleteData(c *gin.Context)
CreateTest(c *gin.Context)
ListTest(c *gin.Context)
GetTest(c *gin.Context)
UpdateTest(c *gin.Context)
DeleteTest(c *gin.Context)
}
type AggregationDataResult ¶
type AggregationDataResult struct {
Data []DataResponse `json:"data" bson:"data"`
TotalCount int64 `json:"total_count" bson:"total_count"`
}
func (*AggregationDataResult) GetData ¶
func (r *AggregationDataResult) GetData() any
func (*AggregationDataResult) GetTotal ¶
func (r *AggregationDataResult) GetTotal() int64
type AggregationTestResult ¶
type AggregationTestResult struct {
Data []TestResponse `json:"data" bson:"data"`
TotalCount int64 `json:"total_count" bson:"total_count"`
}
func (*AggregationTestResult) GetData ¶
func (r *AggregationTestResult) GetData() any
func (*AggregationTestResult) GetTotal ¶
func (r *AggregationTestResult) GetTotal() int64
type AliasInfo ¶
type BulkDeleteRequestItem ¶
type BulkDeleteRequestItem struct {
ID string `json:"_id" binding:"required"`
}
type DataModel ¶
type DataModel struct {
ID string `bson:"_id,omitempty"`
Type int `bson:"type"`
Name string `bson:"name"`
Description string `bson:"description"`
Body any `bson:"body"`
Headers map[string]string `bson:"headers"`
Author string `bson:"author"`
Created *datetime.CpsTime `bson:"created,omitempty"`
Updated *datetime.CpsTime `bson:"updated"`
}
type DataResponse ¶
type DataResponse struct {
ID string `json:"_id" bson:"_id"`
Type int `json:"type" bson:"type"`
Name string `json:"name" bson:"name"`
Description string `json:"description" bson:"description"`
Body any `json:"body" bson:"body"`
Headers map[string]string `json:"headers,omitempty" bson:"headers"`
Created datetime.CpsTime `json:"created" bson:"created" swaggertype:"integer"`
Updated datetime.CpsTime `json:"updated" bson:"updated" swaggertype:"integer"`
}
type EditDataRequest ¶
type EditDataRequest struct {
ID string `json:"-"`
// Possible types:
// * `0` - Event test data
// * `1` - Response test data
Type *int `json:"type" binding:"required,oneof=0 1"`
Name string `json:"name" binding:"required,max=255"`
Description string `json:"description" binding:"max=500"`
Body any `json:"body" binding:"required"`
Headers map[string]string `json:"headers" binding:"dive,max=500"`
Author string `json:"author" swaggerignore:"true"`
}
type EditTestRequest ¶
type EditTestRequest struct {
ID string `json:"-"`
Name string `json:"name" binding:"required,max=255"`
Description string `json:"description" binding:"max=500"`
// Possible types:
// * `0` - Event filter rule
// * `1` - Link rule
// * `2` - Action scenario
// * `3` - Widget
// * `4` - Declare ticket rule
// * `5` - Dynamic-infos rule
// * `6` - Instruction
// * `7` - Job
// * `8` - Meta-alarm rule
// * `9` - Webhook token rule
Type *int `json:"type" binding:"required"`
Rule string `json:"rule" binding:"required"`
Data struct {
Event string `json:"event"`
Response string `json:"response"`
Responses map[int]string `json:"responses"`
TicketStatusResponses map[int]string `json:"ticket_status_responses"`
Alarm string `json:"alarm"`
Entity string `json:"entity"`
User string `json:"user"`
} `json:"data" binding:"required"`
Author string `json:"author" swaggerignore:"true"`
}
type ListDataRequest ¶
type ListDataRequest struct {
pagination.FilteredQuery
SortBy string `form:"sort_by" binding:"oneoforempty=_id name description type"`
// Possible types:
// * `0` - Event test data
// * `1` - Response test data
Type *int `form:"type"`
EventPattern string `form:"event_pattern"`
}
type ListTestRequest ¶
type ListTestRequest struct {
pagination.FilteredQuery
SortBy string `form:"sort_by" binding:"oneoforempty=_id name description type"`
// Possible types:
// * `0` - Event filter rule
// * `1` - Link rule
// * `2` - Action scenario
// * `3` - Widget
// * `4` - Declare ticket rule
// * `5` - Dynamic-infos rule
// * `6` - Instruction
// * `7` - Job
// * `8` - Meta-alarm rule
// * `9` - Webhook token rule
Type *int `form:"type"`
Rule string `form:"rule"`
IDs []string `form:"ids[]"`
}
type ResponseTestData ¶
type Store ¶
type Store interface {
FindData(ctx context.Context, r ListDataRequest) (AggregationDataResult, error)
GetData(ctx context.Context, id string) (DataResponse, error)
CreateData(ctx context.Context, r EditDataRequest) (DataResponse, error)
UpdateData(ctx context.Context, r EditDataRequest) (DataResponse, error)
DeleteData(ctx context.Context, id, author string) (bool, error)
FindTest(ctx context.Context, r ListTestRequest, userID string) (AggregationTestResult, error)
GetTest(ctx context.Context, id, userID string) (TestResponse, error)
CreateTest(ctx context.Context, r EditTestRequest) (TestResponse, error)
UpdateTest(ctx context.Context, r EditTestRequest) (TestResponse, error)
DeleteTest(ctx context.Context, id, author string) (bool, error)
}
type TemplateCheckTicketStatus ¶
type TemplateCheckTicketStatus struct {
Request TemplateParameters `json:"request"`
TicketStatusTpl string `json:"ticket_status_tpl"`
}
type TemplateParameters ¶
type TemplateParameters struct {
URL string `json:"url" binding:"required"`
Payload string `json:"payload"`
Headers map[string]string `json:"headers"`
}
TemplateParameters is a model with all required Parameters fields for template validation requests.
type TemplateRefParameters ¶
type TemplateRefParameters struct {
Reference string `json:"reference" binding:"required"`
Type string `json:"type" binding:"required"`
Table string `json:"table"`
Select map[string]string `json:"select"`
Regexp map[string]string `json:"regexp"`
SortBy string `json:"sort_by"`
Sort string `json:"sort" binding:"oneoforempty=asc desc"`
Optional bool `json:"optional"`
Request *TemplateParameters `json:"request"`
}
TemplateRefParameters is a model with all required RefParameters fields for template validation requests.
type TemplateWebhookDeclareTicket ¶
type TemplateWebhookDeclareTicket struct {
TicketIDTpl string `json:"ticket_id_tpl"`
TicketURLTpl string `json:"ticket_url_tpl"`
TemplateCheckTicketStatus *TemplateCheckTicketStatus `json:"check_ticket_status"`
}
TemplateWebhookDeclareTicket is a model with all required WebhookDeclareTicket fields for template validation requests.
type TestModel ¶
type TestModel struct {
ID string `bson:"_id,omitempty"`
Name string `bson:"name"`
Description string `bson:"description"`
Type int `bson:"type"`
Rule struct {
ID string `bson:"_id"`
Name string `bson:"name"`
} `bson:"rule"`
Data struct {
Event string `bson:"event,omitempty"`
Response string `bson:"response,omitempty"`
Responses map[int]string `bson:"responses,omitempty"`
TicketStatusResponses map[int]string `bson:"ticket_status_responses,omitempty"`
Alarm *types.AlarmWithEntityField `bson:"alarm,omitempty"`
Entity *types.Entity `bson:"entity,omitempty"`
User string `bson:"user,omitempty"`
} `bson:"data"`
Author string `bson:"author"`
Created *datetime.CpsTime `bson:"created,omitempty"`
Updated *datetime.CpsTime `bson:"updated"`
}
type TestResponse ¶
type TestResponse struct {
ID string `json:"_id" bson:"_id"`
Name string `json:"name" bson:"name"`
Description string `json:"description" bson:"description"`
Type int `json:"type" bson:"type"`
Rule struct {
ID string `json:"_id" bson:"_id"`
Name string `json:"name" bson:"name"`
} `json:"rule" bson:"rule"`
Data struct {
Event *struct {
ID string `json:"_id" bson:"_id"`
Name string `json:"name" bson:"name"`
} `json:"event,omitempty" bson:"event,omitempty"`
Response *struct {
ID string `json:"_id" bson:"_id"`
Name string `json:"name" bson:"name"`
} `json:"response,omitempty" bson:"response,omitempty"`
Responses map[int]struct {
ID string `json:"_id" bson:"_id"`
Name string `json:"name" bson:"name"`
} `json:"responses,omitempty" bson:"responses,omitempty"`
TicketStatusResponses map[int]struct {
ID string `json:"_id" bson:"_id"`
Name string `json:"name" bson:"name"`
} `json:"ticket_status_responses,omitempty" bson:"ticket_status_responses,omitempty"`
Alarm *alarm.RefResponse `json:"alarm,omitempty" bson:"alarm,omitempty"`
Entity *entity.RefResponse `json:"entity,omitempty" bson:"entity,omitempty"`
User *struct {
ID string `json:"_id" bson:"_id"`
DisplayName string `bson:"display_name" json:"display_name"`
} `json:"user,omitempty" bson:"user,omitempty"`
} `json:"data" bson:"data"`
Created datetime.CpsTime `json:"created" bson:"created" swaggertype:"integer"`
Updated datetime.CpsTime `json:"updated" bson:"updated" swaggertype:"integer"`
}
type ValidateResponse ¶
type ValidateResponse struct {
IsValid bool `json:"is_valid"`
Err *validator.ErrReport `json:"err"`
Result string `json:"result"`
}
func Validate ¶
func Validate(tplValidator tplvalidator.Validator, str string, data any) (ValidateResponse, error)
type VarResponse ¶
type VarResponse struct {
Name string `json:"name"`
Value any `json:"value"`
Alias bool `json:"alias,omitempty"`
}
func AddEnvVars ¶
func AddEnvVars(vars []VarResponse, tplConfigProvider config.TemplateConfigProvider) []VarResponse
func GetAlarmCopyVars ¶
func GetAlarmCopyVars(alarmVar string) []VarResponse
func GetAlarmVars ¶
func GetAlarmVars(prefixVar, suffixVar, alarmVar string, pluralName bool) []VarResponse
func GetEntityCopyVars ¶
func GetEntityCopyVars(entityVar string) []VarResponse
func GetEntityVars ¶
func GetEntityVars(prefixVar, suffixVar, entityVar string, pluralName bool) []VarResponse
func GetEnvVars ¶
func GetEnvVars(tplConfigProvider config.TemplateConfigProvider) []VarResponse
func GetEventCopyVars ¶
func GetEventCopyVars(eventVar string) []VarResponse
func GetEventVars ¶
func GetEventVars(prefixVar, suffixVar, eventVar string, pluralName bool) []VarResponse
Source Files
¶
- api.go
- helpers.go
- model.go
- store.go
- validator.go
Click to show internal directories.
Click to hide internal directories.