datasource.go 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. package models
  2. import (
  3. "errors"
  4. "time"
  5. )
  6. const (
  7. DS_GRAPHITE = "graphite"
  8. DS_INFLUXDB = "influxdb"
  9. DS_ES = "es"
  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. Created time.Time
  31. Updated time.Time
  32. }
  33. // ----------------------
  34. // COMMANDS
  35. type AddDataSourceCommand struct {
  36. AccountId int64
  37. Name string
  38. Type DsType
  39. Access DsAccess
  40. Url string
  41. Password string
  42. Database string
  43. User string
  44. Result *DataSource
  45. }
  46. type UpdateDataSourceCommand struct {
  47. Id int64
  48. AccountId int64
  49. Name string
  50. Type DsType
  51. Access DsAccess
  52. Url string
  53. Password string
  54. User string
  55. Database string
  56. }
  57. type DeleteDataSourceCommand struct {
  58. Id int64
  59. AccountId int64
  60. }
  61. // ---------------------
  62. // QUERIES
  63. type GetDataSourcesQuery struct {
  64. AccountId int64
  65. Result []*DataSource
  66. }
  67. type GetDataSourceByIdQuery struct {
  68. Id int64
  69. AccountId int64
  70. Result DataSource
  71. }
  72. // ---------------------
  73. // EVENTS
  74. type DataSourceCreatedEvent struct {
  75. }