1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
|
package schema
import (
"entgo.io/ent"
"entgo.io/ent/dialect"
"entgo.io/ent/schema/edge"
"entgo.io/ent/schema/field"
"entgo.io/ent/schema/index"
"github.com/crowdsecurity/crowdsec/pkg/types"
)
// Decision holds the schema definition for the Decision entity.
type Decision struct {
ent.Schema
}
// Fields of the Decision.
func (Decision) Fields() []ent.Field {
return []ent.Field{
field.Time("created_at").
Default(types.UtcNow).
UpdateDefault(types.UtcNow).Nillable().Optional(),
field.Time("updated_at").
Default(types.UtcNow).
UpdateDefault(types.UtcNow).Nillable().Optional(),
field.Time("until").Nillable().Optional().SchemaType(map[string]string{
dialect.MySQL: "datetime",
}),
field.String("scenario"),
field.String("type"),
field.Int64("start_ip").Optional(),
field.Int64("end_ip").Optional(),
field.Int64("start_suffix").Optional(),
field.Int64("end_suffix").Optional(),
field.Int64("ip_size").Optional(),
field.String("scope"),
field.String("value"),
field.String("origin"),
field.Bool("simulated").Default(false),
}
}
// Edges of the Decision.
func (Decision) Edges() []ent.Edge {
return []ent.Edge{
edge.From("owner", Alert.Type).
Ref("decisions").
Unique(),
}
}
func (Decision) Indexes() []ent.Index {
return []ent.Index{
index.Fields("start_ip", "end_ip"),
index.Fields("value"),
index.Fields("until"),
}
}
|