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/field"
|
2022-01-19 13:56:05 +00:00
|
|
|
"github.com/crowdsecurity/crowdsec/pkg/types"
|
2020-11-30 09:37:17 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// Bouncer holds the schema definition for the Bouncer entity.
|
|
|
|
type Bouncer struct {
|
|
|
|
ent.Schema
|
|
|
|
}
|
|
|
|
|
|
|
|
// Fields of the Bouncer.
|
|
|
|
func (Bouncer) Fields() []ent.Field {
|
|
|
|
return []ent.Field{
|
|
|
|
field.Time("created_at").
|
2022-01-19 13:56:05 +00:00
|
|
|
Default(types.UtcNow).
|
2024-03-12 14:29:59 +00:00
|
|
|
StructTag(`json:"created_at"`),
|
2020-11-30 09:37:17 +00:00
|
|
|
field.Time("updated_at").
|
2022-01-19 13:56:05 +00:00
|
|
|
Default(types.UtcNow).
|
2024-03-12 14:29:59 +00:00
|
|
|
UpdateDefault(types.UtcNow).StructTag(`json:"updated_at"`),
|
2022-03-16 08:40:34 +00:00
|
|
|
field.String("name").Unique().StructTag(`json:"name"`),
|
2024-03-06 13:27:05 +00:00
|
|
|
field.String("api_key").Sensitive(), // hash of api_key
|
2022-03-16 08:40:34 +00:00
|
|
|
field.Bool("revoked").StructTag(`json:"revoked"`),
|
|
|
|
field.String("ip_address").Default("").Optional().StructTag(`json:"ip_address"`),
|
|
|
|
field.String("type").Optional().StructTag(`json:"type"`),
|
|
|
|
field.String("version").Optional().StructTag(`json:"version"`),
|
|
|
|
field.Time("until").Default(types.UtcNow).Optional().StructTag(`json:"until"`),
|
2020-11-30 09:37:17 +00:00
|
|
|
field.Time("last_pull").
|
2022-03-16 08:40:34 +00:00
|
|
|
Default(types.UtcNow).StructTag(`json:"last_pull"`),
|
2022-06-08 14:05:52 +00:00
|
|
|
field.String("auth_type").StructTag(`json:"auth_type"`).Default(types.ApiKeyAuthType),
|
2024-03-12 14:29:59 +00:00
|
|
|
field.String("osname").Optional(),
|
|
|
|
field.String("osversion").Optional(),
|
|
|
|
field.String("featureflags").Optional(),
|
2020-11-30 09:37:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Edges of the Bouncer.
|
|
|
|
func (Bouncer) Edges() []ent.Edge {
|
|
|
|
return nil
|
|
|
|
}
|