datasource.go 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. package dtos
  2. import (
  3. "strings"
  4. "github.com/grafana/grafana/pkg/components/simplejson"
  5. m "github.com/grafana/grafana/pkg/models"
  6. )
  7. type DataSource struct {
  8. Id int64 `json:"id"`
  9. OrgId int64 `json:"orgId"`
  10. Name string `json:"name"`
  11. Type string `json:"type"`
  12. TypeLogoUrl string `json:"typeLogoUrl"`
  13. Access m.DsAccess `json:"access"`
  14. Url string `json:"url"`
  15. Password string `json:"password"`
  16. User string `json:"user"`
  17. Database string `json:"database"`
  18. BasicAuth bool `json:"basicAuth"`
  19. BasicAuthUser string `json:"basicAuthUser"`
  20. BasicAuthPassword string `json:"basicAuthPassword"`
  21. WithCredentials bool `json:"withCredentials"`
  22. IsDefault bool `json:"isDefault"`
  23. JsonData *simplejson.Json `json:"jsonData,omitempty"`
  24. SecureJsonFields map[string]bool `json:"secureJsonFields"`
  25. Version int `json:"version"`
  26. }
  27. type DataSourceListItemDTO struct {
  28. Id int64 `json:"id"`
  29. OrgId int64 `json:"orgId"`
  30. Name string `json:"name"`
  31. Type string `json:"type"`
  32. TypeLogoUrl string `json:"typeLogoUrl"`
  33. Access m.DsAccess `json:"access"`
  34. Url string `json:"url"`
  35. Password string `json:"password"`
  36. User string `json:"user"`
  37. Database string `json:"database"`
  38. BasicAuth bool `json:"basicAuth"`
  39. IsDefault bool `json:"isDefault"`
  40. JsonData *simplejson.Json `json:"jsonData,omitempty"`
  41. }
  42. type DataSourceList []DataSourceListItemDTO
  43. func (slice DataSourceList) Len() int {
  44. return len(slice)
  45. }
  46. func (slice DataSourceList) Less(i, j int) bool {
  47. return strings.ToLower(slice[i].Name) < strings.ToLower(slice[j].Name)
  48. }
  49. func (slice DataSourceList) Swap(i, j int) {
  50. slice[i], slice[j] = slice[j], slice[i]
  51. }