2020-11-30 09:37:17 +00:00
|
|
|
package schema
|
|
|
|
|
|
|
|
import (
|
2021-03-15 17:46:52 +00:00
|
|
|
"entgo.io/ent"
|
|
|
|
"entgo.io/ent/schema/edge"
|
|
|
|
"entgo.io/ent/schema/field"
|
2022-01-19 13:56:05 +00:00
|
|
|
"github.com/crowdsecurity/crowdsec/pkg/types"
|
2020-11-30 09:37:17 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// Machine holds the schema definition for the Machine entity.
|
|
|
|
type Machine struct {
|
|
|
|
ent.Schema
|
|
|
|
}
|
|
|
|
|
|
|
|
// Fields of the Machine.
|
|
|
|
func (Machine) Fields() []ent.Field {
|
|
|
|
return []ent.Field{
|
|
|
|
field.Time("created_at").
|
2022-01-19 13:56:05 +00:00
|
|
|
Default(types.UtcNow).
|
|
|
|
UpdateDefault(types.UtcNow).Nillable().Optional(),
|
2020-11-30 09:37:17 +00:00
|
|
|
field.Time("updated_at").
|
2022-01-19 13:56:05 +00:00
|
|
|
Default(types.UtcNow).
|
|
|
|
UpdateDefault(types.UtcNow).Nillable().Optional(),
|
2022-01-13 15:46:16 +00:00
|
|
|
field.Time("last_push").
|
2022-01-19 13:56:05 +00:00
|
|
|
Default(types.UtcNow).
|
|
|
|
UpdateDefault(types.UtcNow).Nillable().Optional(),
|
2020-11-30 09:37:17 +00:00
|
|
|
field.String("machineId").Unique(),
|
|
|
|
field.String("password").Sensitive(),
|
|
|
|
field.String("ipAddress"),
|
|
|
|
field.String("scenarios").MaxLen(4095).Optional(),
|
|
|
|
field.String("version").Optional(),
|
|
|
|
field.Bool("isValidated").
|
|
|
|
Default(false),
|
|
|
|
field.String("status").Optional(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Edges of the Machine.
|
|
|
|
func (Machine) Edges() []ent.Edge {
|
|
|
|
return []ent.Edge{
|
|
|
|
edge.To("alerts", Alert.Type),
|
|
|
|
}
|
|
|
|
}
|