events.go 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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. RefreshKey Action = "REFRESH_KEY"
  13. RefreshAllKeys Action = "REFRESH_ALL_KEYS"
  14. SyncAll Action = "SYNC_ALL"
  15. UpgradeAll Action = "UPGRADE_ALL"
  16. Disconnect Action = "DISCONNECT"
  17. JoinHostToNet Action = "JOIN_HOST_TO_NETWORK"
  18. RemoveHostFromNet Action = "REMOVE_HOST_FROM_NETWORK"
  19. )
  20. type SubjectType string
  21. const (
  22. UserSub SubjectType = "USER"
  23. UserAccessTokenSub SubjectType = "USER_ACCESS_TOKEN"
  24. DeviceSub SubjectType = "DEVICE"
  25. NodeSub SubjectType = "NODE"
  26. GatewaySub SubjectType = "GATEWAY"
  27. SettingSub SubjectType = "SETTING"
  28. AclSub SubjectType = "ACL"
  29. TagSub SubjectType = "TAG"
  30. UserRoleSub SubjectType = "USER_ROLE"
  31. UserGroupSub SubjectType = "USER_GROUP"
  32. UserInviteSub SubjectType = "USER_INVITE"
  33. PendingUserSub SubjectType = "PENDING_USER"
  34. EgressSub SubjectType = "EGRESS"
  35. NetworkSub SubjectType = "NETWORK"
  36. DashboardSub SubjectType = "DASHBOARD"
  37. EnrollmentKeySub SubjectType = "ENROLLMENT_KEY"
  38. ClientAppSub SubjectType = "CLIENT-APP"
  39. )
  40. func (sub SubjectType) String() string {
  41. return string(sub)
  42. }
  43. type Origin string
  44. const (
  45. Dashboard Origin = "DASHBOARD"
  46. Api Origin = "API"
  47. NMCTL Origin = "NMCTL"
  48. ClientApp Origin = "CLIENT-APP"
  49. )
  50. type Subject struct {
  51. ID string `json:"id"`
  52. Name string `json:"name"`
  53. Type SubjectType `json:"subject_type"`
  54. Info interface{} `json:"info"`
  55. }
  56. type Diff struct {
  57. Old interface{}
  58. New interface{}
  59. }
  60. type Event struct {
  61. Action Action
  62. Source Subject
  63. Origin Origin
  64. Target Subject
  65. TriggeredBy string
  66. NetworkID NetworkID
  67. Diff Diff
  68. }