datasource.go 1.7 KB

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