tags.go 1.1 KB

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