tags.go 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. package models
  2. import (
  3. "fmt"
  4. "time"
  5. )
  6. type TagID string
  7. const (
  8. OldRemoteAccessTagName = "remote-access-gws"
  9. GwTagName = "gateways"
  10. )
  11. func (id TagID) String() string {
  12. return string(id)
  13. }
  14. func (t Tag) GetIDFromName() string {
  15. return fmt.Sprintf("%s.%s", t.Network, t.TagName)
  16. }
  17. type Tag struct {
  18. ID TagID `json:"id"`
  19. TagName string `json:"tag_name"`
  20. Network NetworkID `json:"network"`
  21. ColorCode string `json:"color_code"`
  22. CreatedBy string `json:"created_by"`
  23. CreatedAt time.Time `json:"created_at"`
  24. }
  25. type CreateTagReq struct {
  26. TagName string `json:"tag_name"`
  27. Network NetworkID `json:"network"`
  28. ColorCode string `json:"color_code"`
  29. TaggedNodes []ApiNode `json:"tagged_nodes"`
  30. }
  31. type TagListResp struct {
  32. Tag
  33. UsedByCnt int `json:"used_by_count"`
  34. TaggedNodes []ApiNode `json:"tagged_nodes"`
  35. }
  36. type TagListRespNodes struct {
  37. Tag
  38. UsedByCnt int `json:"used_by_count"`
  39. TaggedNodes []ApiNode `json:"tagged_nodes"`
  40. }
  41. type UpdateTagReq struct {
  42. Tag
  43. NewName string `json:"new_name"`
  44. ColorCode string `json:"color_code"`
  45. TaggedNodes []ApiNode `json:"tagged_nodes"`
  46. }