datasource.go 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. package models
  2. import (
  3. "errors"
  4. "time"
  5. )
  6. const (
  7. DS_GRAPHITE = "graphite"
  8. DS_INFLUXDB = "influxdb"
  9. DS_ES = "elasticsearch"
  10. DS_ACCESS_DIRECT = "direct"
  11. DS_ACCESS_PROXY = "proxy"
  12. )
  13. // Typed errors
  14. var (
  15. ErrDataSourceNotFound = errors.New("Data source not found")
  16. )
  17. type DsType string
  18. type DsAccess string
  19. type DataSource struct {
  20. Id int64
  21. AccountId int64
  22. Name string
  23. Type DsType
  24. Access DsAccess
  25. Url string
  26. Password string
  27. User string
  28. Database string
  29. BasicAuth bool
  30. BasicAuthUser string
  31. BasicAuthPassword string
  32. IsDefault bool
  33. Created time.Time
  34. Updated time.Time
  35. }
  36. // ----------------------
  37. // COMMANDS
  38. // Also acts as api DTO
  39. type AddDataSourceCommand struct {
  40. AccountId int64 `json:"-"`
  41. Name string
  42. Type DsType
  43. Access DsAccess
  44. Url string
  45. Password string
  46. Database string
  47. User string
  48. IsDefault bool
  49. Result *DataSource
  50. }
  51. // Also acts as api DTO
  52. type UpdateDataSourceCommand struct {
  53. Id int64
  54. AccountId int64
  55. Name string
  56. Type DsType
  57. Access DsAccess
  58. Url string
  59. Password string
  60. User string
  61. Database string
  62. IsDefault bool
  63. }
  64. type DeleteDataSourceCommand struct {
  65. Id int64
  66. AccountId int64
  67. }
  68. // ---------------------
  69. // QUERIES
  70. type GetDataSourcesQuery struct {
  71. AccountId int64
  72. Result []*DataSource
  73. }
  74. type GetDataSourceByIdQuery struct {
  75. Id int64
  76. AccountId int64
  77. Result DataSource
  78. }
  79. // ---------------------
  80. // EVENTS
  81. type DataSourceCreatedEvent struct {
  82. }