datasource.go 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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_OPENTSDB = "opentsdb"
  11. DS_ACCESS_DIRECT = "direct"
  12. DS_ACCESS_PROXY = "proxy"
  13. )
  14. // Typed errors
  15. var (
  16. ErrDataSourceNotFound = errors.New("Data source not found")
  17. )
  18. type DsType string
  19. type DsAccess string
  20. type DataSource struct {
  21. Id int64
  22. AccountId int64
  23. Version int
  24. Name string
  25. Type DsType
  26. Access DsAccess
  27. Url string
  28. Password string
  29. User string
  30. Database string
  31. BasicAuth bool
  32. BasicAuthUser string
  33. BasicAuthPassword string
  34. IsDefault bool
  35. Created time.Time
  36. Updated time.Time
  37. }
  38. // ----------------------
  39. // COMMANDS
  40. // Also acts as api DTO
  41. type AddDataSourceCommand struct {
  42. AccountId int64 `json:"-"`
  43. Name string
  44. Type DsType
  45. Access DsAccess
  46. Url string
  47. Password string
  48. Database string
  49. User string
  50. IsDefault bool
  51. Result *DataSource
  52. }
  53. // Also acts as api DTO
  54. type UpdateDataSourceCommand struct {
  55. Id int64
  56. AccountId int64
  57. Name string
  58. Type DsType
  59. Access DsAccess
  60. Url string
  61. Password string
  62. User string
  63. Database string
  64. IsDefault bool
  65. }
  66. type DeleteDataSourceCommand struct {
  67. Id int64
  68. AccountId int64
  69. }
  70. // ---------------------
  71. // QUERIES
  72. type GetDataSourcesQuery struct {
  73. AccountId int64
  74. Result []*DataSource
  75. }
  76. type GetDataSourceByIdQuery struct {
  77. Id int64
  78. AccountId int64
  79. Result DataSource
  80. }
  81. type GetDataSourceByNameQuery struct {
  82. Name string
  83. AccountId int64
  84. Result DataSource
  85. }
  86. // ---------------------
  87. // EVENTS
  88. type DataSourceCreatedEvent struct {
  89. }