base.go 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. // Copyright 2019 Yunion
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. package models
  15. import (
  16. "time"
  17. )
  18. type IResource interface {
  19. GetUpdateVersion() int
  20. GetUpdatedAt() time.Time
  21. }
  22. type IStandaloneResource interface {
  23. IResource
  24. GetId() string
  25. }
  26. type IVirtualResource interface {
  27. IStandaloneResource
  28. GetPendingDeleted() bool
  29. }
  30. type Resource struct {
  31. CreatedAt time.Time
  32. UpdatedAt time.Time
  33. UpdateVersion int
  34. DeletedAt time.Time
  35. Deleted bool
  36. }
  37. func (r *Resource) GetUpdateVersion() int {
  38. return r.UpdateVersion
  39. }
  40. func (r *Resource) GetUpdatedAt() time.Time {
  41. return r.UpdatedAt
  42. }
  43. type StandaloneResource struct {
  44. Resource
  45. Id string
  46. Name string
  47. Description string
  48. IsEmulated bool
  49. }
  50. func (r *StandaloneResource) GetId() string {
  51. return r.Id
  52. }
  53. type StatusStandaloneResource struct {
  54. StandaloneResource
  55. Status string
  56. }
  57. type EnabledStatusStandaloneResource struct {
  58. StatusStandaloneResource
  59. Enabled bool
  60. }
  61. type VirtualResource struct {
  62. StatusStandaloneResource
  63. DomainId string
  64. ProjectId string
  65. IsSystem bool
  66. PendingDeletedAt time.Time
  67. PendingDeleted bool
  68. }
  69. func (r *VirtualResource) GetPendingDeleted() bool {
  70. return r.PendingDeleted
  71. }
  72. type SharableVirtualResource struct {
  73. VirtualResource
  74. IsPublic bool
  75. }
  76. type ManagedResource struct {
  77. ManagerId string
  78. }
  79. type ExternalizedResource struct {
  80. ExternalId string
  81. }