Documentation ¶
Index ¶
- Constants
- Variables
- func GetForbiddenFieldsInAlarmPattern(collection string) []string
- func GetForbiddenFieldsInEntityPattern(collection string) []string
- func GetOnlyAbsoluteTimeCondFieldsInAlarmPattern(collection string) []string
- func GetRealFormatTime(f string) string
- func GetSearchQuery(search string, searchBy []string) bson.M
- func GetSortQuery(sortBy, sort string) bson.M
- func NewValidationErrorFastJsonValue(ar *fastjson.Arena, err error, request interface{}) *fastjson.Value
- func NewValidationErrorResponse(err error, request interface{}) interface{}
- func ValidateAlarmPattern(fl validator.FieldLevel) bool
- func ValidateColorOrEmpty(fl validator.FieldLevel) bool
- func ValidateCpsTimeType(field reflect.Value) interface{}
- func ValidateEntityPattern(fl validator.FieldLevel) bool
- func ValidateEventPattern(fl validator.FieldLevel) bool
- func ValidateFilteredQuery(sl validator.StructLevel)
- func ValidateID(fl validator.FieldLevel) bool
- func ValidateInfoValue(fl validator.FieldLevel) bool
- func ValidateOneOfOrEmpty(fl validator.FieldLevel) bool
- func ValidatePbehaviorPattern(fl validator.FieldLevel) bool
- func ValidateTimeFormat(fl validator.FieldLevel) bool
- func ValidateWeatherServicePattern(fl validator.FieldLevel) bool
- type AlarmPatternFieldsRequest
- type AlarmStep
- type BulkCrudAPI
- type CrudAPI
- type EntityPatternFieldsRequest
- type ErrorResponse
- type FieldValidator
- type PaginatedData
- type PaginatedListResponse
- type PaginatedMeta
- type PatternFieldsTransformer
- type PbehaviorPatternFieldsRequest
- type ValidationError
- type ValidationErrorResponse
- type WeatherServicePatternFieldsRequest
Constants ¶
const ( SortAsc = "asc" SortDesc = "desc" MaxIDLength = 255 )
Variables ¶
var ( ErrNotExistCorporateAlarmPattern = ValidationError{/* contains filtered or unexported fields */} ErrNotExistCorporateEntityPattern = ValidationError{/* contains filtered or unexported fields */} ErrNotExistCorporatePbehaviorPattern = ValidationError{/* contains filtered or unexported fields */} ErrNotExistCorporateWeatherServicePattern = ValidationError{/* contains filtered or unexported fields */} )
var CanopsisUnderMaintenanceResponse = ErrorResponse{Error: "canopsis is under maintenance"}
var ForbiddenResponse = ErrorResponse{Error: http.StatusText(http.StatusForbidden)}
var InternalServerErrorResponse = ErrorResponse{Error: "Internal server error"}
var MethodNotAllowedResponse = ErrorResponse{Error: http.StatusText(http.StatusMethodNotAllowed)}
var NotFoundResponse = ErrorResponse{Error: "Not found"}
var RequestTimeoutResponse = ErrorResponse{Error: http.StatusText(http.StatusRequestTimeout)}
Functions ¶
func GetForbiddenFieldsInAlarmPattern ¶
func GetForbiddenFieldsInEntityPattern ¶
func GetOnlyAbsoluteTimeCondFieldsInAlarmPattern ¶
func GetSearchQuery ¶
GetSearchQuery returns search query, it returns parsed search filter if it can be parsed or regex search filter by searchBy otherwise.
func GetSortQuery ¶
GetSortQuery returns sort query which support consistent sort : sort by "_id" is added if sortBy is not "_id".
func NewValidationErrorFastJsonValue ¶
func NewValidationErrorResponse ¶
func NewValidationErrorResponse(err error, request interface{}) interface{}
NewValidationErrorResponse creates response by validation errors. @Failure 400 {object} ValidationErrorResponse
func ValidateCpsTimeType ¶
ValidateCpsTimeType implements CustomTypeFunc and returns value to validate.
func ValidateFilteredQuery ¶
func ValidateFilteredQuery(sl validator.StructLevel)
Types ¶
type AlarmPatternFieldsRequest ¶
type AlarmPatternFieldsRequest struct { AlarmPattern pattern.Alarm `json:"alarm_pattern" binding:"alarm_pattern"` CorporateAlarmPattern string `json:"corporate_alarm_pattern"` CorporatePattern savedpattern.SavedPattern `json:"-"` }
func (AlarmPatternFieldsRequest) ToModel ¶
func (r AlarmPatternFieldsRequest) ToModel() savedpattern.AlarmPatternFields
func (AlarmPatternFieldsRequest) ToModelWithoutFields ¶
func (r AlarmPatternFieldsRequest) ToModelWithoutFields(forbiddenFields, onlyTimeAbsoluteFields []string) savedpattern.AlarmPatternFields
type AlarmStep ¶
type AlarmStep struct { Type string `bson:"_t" json:"_t"` Timestamp *datetime.CpsTime `bson:"t" json:"t" swaggertype:"integer"` Author string `bson:"a" json:"a"` UserID string `bson:"user_id,omitempty" json:"user_id"` Message string `bson:"m" json:"m"` Value types.CpsNumber `bson:"val" json:"val"` Initiator string `bson:"initiator" json:"initiator"` Execution string `bson:"exec,omitempty" json:"-"` IconName string `bson:"icon_name,omitempty" json:"icon_name,omitempty"` Color string `bson:"color,omitempty" json:"color,omitempty"` // Ticket related fields types.TicketInfo `bson:",inline"` InPbehaviorInterval bool `bson:"in_pbh,omitempty" json:"in_pbh,omitempty"` }
type BulkCrudAPI ¶
type CrudAPI ¶
type EntityPatternFieldsRequest ¶
type EntityPatternFieldsRequest struct { EntityPattern pattern.Entity `json:"entity_pattern" binding:"entity_pattern"` CorporateEntityPattern string `json:"corporate_entity_pattern"` CorporatePattern savedpattern.SavedPattern `json:"-"` }
func (EntityPatternFieldsRequest) ToModel ¶
func (r EntityPatternFieldsRequest) ToModel() savedpattern.EntityPatternFields
func (EntityPatternFieldsRequest) ToModelWithoutFields ¶
func (r EntityPatternFieldsRequest) ToModelWithoutFields(forbiddenFields []string) savedpattern.EntityPatternFields
type ErrorResponse ¶
type ErrorResponse struct {
Error string `json:"error"`
}
ErrorResponse is base failed response.
func NewErrorResponse ¶
func NewErrorResponse(err error) ErrorResponse
NewErrorResponse @Failure 500 {object} ErrorResponse
type FieldValidator ¶
type PaginatedData ¶
type PaginatedData interface { GetData() interface{} GetTotal() int64 }
PaginatedData provides access to inner data and total count
type PaginatedListResponse ¶
type PaginatedListResponse struct { Data interface{} `json:"data"` Meta PaginatedMeta `json:"meta"` }
PaginatedListResponse is response for paginated list data.
func NewPaginatedResponse ¶
func NewPaginatedResponse(q pagination.Query, d PaginatedData) (PaginatedListResponse, error)
type PaginatedMeta ¶
type PaginatedMeta struct { Page int64 `json:"page"` PerPage int64 `json:"per_page"` PageCount int64 `json:"page_count"` TotalCount int64 `json:"total_count"` }
PaginatedMeta is meta for paginated list data.
func NewPaginatedMeta ¶
func NewPaginatedMeta(q pagination.Query, total int64) (PaginatedMeta, error)
type PatternFieldsTransformer ¶
type PatternFieldsTransformer interface { TransformAlarmPatternFieldsRequest(ctx context.Context, r AlarmPatternFieldsRequest) (AlarmPatternFieldsRequest, error) TransformEntityPatternFieldsRequest(ctx context.Context, r EntityPatternFieldsRequest) (EntityPatternFieldsRequest, error) TransformPbehaviorPatternFieldsRequest(ctx context.Context, r PbehaviorPatternFieldsRequest) (PbehaviorPatternFieldsRequest, error) TransformWeatherServicePatternFieldsRequest(ctx context.Context, r WeatherServicePatternFieldsRequest) (WeatherServicePatternFieldsRequest, error) }
func NewPatternFieldsTransformer ¶
func NewPatternFieldsTransformer(client mongo.DbClient) PatternFieldsTransformer
type PbehaviorPatternFieldsRequest ¶
type PbehaviorPatternFieldsRequest struct { PbehaviorPattern pattern.PbehaviorInfo `json:"pbehavior_pattern" binding:"pbehavior_pattern"` CorporatePbehaviorPattern string `json:"corporate_pbehavior_pattern"` CorporatePattern savedpattern.SavedPattern `json:"-"` }
func (PbehaviorPatternFieldsRequest) ToModel ¶
func (r PbehaviorPatternFieldsRequest) ToModel() savedpattern.PbehaviorPatternFields
type ValidationError ¶
type ValidationError struct {
// contains filtered or unexported fields
}
func NewValidationError ¶
func NewValidationError(field, errMsg string) ValidationError
func (ValidationError) Error ¶
func (v ValidationError) Error() string
func (ValidationError) ValidationErrorResponse ¶
func (v ValidationError) ValidationErrorResponse() ValidationErrorResponse
type ValidationErrorResponse ¶
ValidationErrorResponse is response for failed validation.
func TransformValidationErrors ¶
func TransformValidationErrors(errs validator.ValidationErrors, request interface{}) ValidationErrorResponse
type WeatherServicePatternFieldsRequest ¶
type WeatherServicePatternFieldsRequest struct { WeatherServicePattern pattern.WeatherServicePattern `json:"weather_service_pattern" binding:"weather_service_pattern"` CorporateWeatherServicePattern string `json:"corporate_weather_service_pattern"` CorporatePattern savedpattern.SavedPattern `json:"-"` }
func (WeatherServicePatternFieldsRequest) ToModel ¶
func (r WeatherServicePatternFieldsRequest) ToModel() savedpattern.WeatherServicePatternFields