events.go 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. package models
  2. type Action string
  3. const (
  4. Create Action = "CREATE"
  5. Update Action = "UPDATE"
  6. Delete Action = "DELETE"
  7. DeleteAll Action = "DELETE_ALL"
  8. Login Action = "LOGIN"
  9. LogOut Action = "LOGOUT"
  10. Connect Action = "CONNECT"
  11. Sync Action = "SYNC"
  12. Disconnect Action = "DISCONNECT"
  13. JoinHostToNet Action = "JOIN_HOST_TO_NETWORK"
  14. RemoveHostFromNet Action = "REMOVE_HOST_FROM_NETWORK"
  15. )
  16. type SubjectType string
  17. const (
  18. UserSub SubjectType = "USER"
  19. UserAccessTokenSub SubjectType = "USER_ACCESS_TOKEN"
  20. DeviceSub SubjectType = "DEVICE"
  21. NodeSub SubjectType = "NODE"
  22. GatewaySub SubjectType = "GATEWAY"
  23. SettingSub SubjectType = "SETTING"
  24. AclSub SubjectType = "ACL"
  25. TagSub SubjectType = "TAG"
  26. UserRoleSub SubjectType = "USER_ROLE"
  27. UserGroupSub SubjectType = "USER_GROUP"
  28. UserInviteSub SubjectType = "USER_INVITE"
  29. PendingUserSub SubjectType = "PENDING_USER"
  30. EgressSub SubjectType = "EGRESS"
  31. NetworkSub SubjectType = "NETWORK"
  32. DashboardSub SubjectType = "DASHBOARD"
  33. EnrollmentKeySub SubjectType = "ENROLLMENT_KEY"
  34. ClientAppSub SubjectType = "CLIENT-APP"
  35. )
  36. func (sub SubjectType) String() string {
  37. return string(sub)
  38. }
  39. type Origin string
  40. const (
  41. Dashboard Origin = "DASHBOARD"
  42. Api Origin = "API"
  43. NMCTL Origin = "NMCTL"
  44. ClientApp Origin = "CLIENT-APP"
  45. )
  46. type Subject struct {
  47. ID string `json:"id"`
  48. Name string `json:"name"`
  49. Type SubjectType `json:"subject_type"`
  50. Info interface{} `json:"info"`
  51. }
  52. type Diff struct {
  53. Old interface{}
  54. New interface{}
  55. }
  56. type Event struct {
  57. Action Action
  58. Source Subject
  59. Origin Origin
  60. Target Subject
  61. TriggeredBy string
  62. NetworkID NetworkID
  63. Diff Diff
  64. }