datasource.go 1.7 KB

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