datasource.go 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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. IsDefault bool
  31. Created time.Time
  32. Updated time.Time
  33. }
  34. // ----------------------
  35. // COMMANDS
  36. // Also acts as api DTO
  37. type AddDataSourceCommand struct {
  38. AccountId int64 `json:"-"`
  39. Name string
  40. Type DsType
  41. Access DsAccess
  42. Url string
  43. Password string
  44. Database string
  45. User string
  46. IsDefault bool
  47. Result *DataSource
  48. }
  49. // Also acts as api DTO
  50. type UpdateDataSourceCommand struct {
  51. Id int64
  52. AccountId int64
  53. Name string
  54. Type DsType
  55. Access DsAccess
  56. Url string
  57. Password string
  58. User string
  59. Database string
  60. IsDefault bool
  61. }
  62. type DeleteDataSourceCommand struct {
  63. Id int64
  64. AccountId int64
  65. }
  66. // ---------------------
  67. // QUERIES
  68. type GetDataSourcesQuery struct {
  69. AccountId int64
  70. Result []*DataSource
  71. }
  72. type GetDataSourceByIdQuery struct {
  73. Id int64
  74. AccountId int64
  75. Result DataSource
  76. }
  77. // ---------------------
  78. // EVENTS
  79. type DataSourceCreatedEvent struct {
  80. }