bouncer.go 941 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. package schema
  2. import (
  3. "entgo.io/ent"
  4. "entgo.io/ent/schema/field"
  5. "github.com/crowdsecurity/crowdsec/pkg/types"
  6. )
  7. // Bouncer holds the schema definition for the Bouncer entity.
  8. type Bouncer struct {
  9. ent.Schema
  10. }
  11. // Fields of the Bouncer.
  12. func (Bouncer) Fields() []ent.Field {
  13. return []ent.Field{
  14. field.Time("created_at").
  15. Default(types.UtcNow).
  16. UpdateDefault(types.UtcNow).Nillable().Optional(),
  17. field.Time("updated_at").
  18. Default(types.UtcNow).
  19. UpdateDefault(types.UtcNow).Nillable().Optional(),
  20. field.String("name").Unique(),
  21. field.String("api_key"), // hash of api_key
  22. field.Bool("revoked"),
  23. field.String("ip_address").Default("").Optional(),
  24. field.String("type").Optional(),
  25. field.String("version").Optional(),
  26. field.Time("until").Default(types.UtcNow).Optional(),
  27. field.Time("last_pull").
  28. Default(types.UtcNow),
  29. }
  30. }
  31. // Edges of the Bouncer.
  32. func (Bouncer) Edges() []ent.Edge {
  33. return nil
  34. }