cloudcommon: extend interface for fetching metadata

This commit is contained in:
Yousong Zhou
2020-01-17 17:46:07 +08:00
parent 4221e214f0
commit 770a6d194d
4 changed files with 36 additions and 0 deletions
+4
View File
@@ -129,6 +129,9 @@ type IModel interface {
object.IObject
GetName() string
GetUpdateVersion() int
GetUpdatedAt() time.Time
GetDeleted() bool
KeywordPlural() string
@@ -283,6 +286,7 @@ type IVirtualModelManager interface {
type IVirtualModel interface {
IStandaloneModel
IPendingDeletable
IsOwner(userCred mcclient.TokenCredential) bool
// IsAdmin(userCred mcclient.TokenCredential) bool
+12
View File
@@ -412,6 +412,18 @@ func (model *SModelBase) GetName() string {
return ""
}
func (model *SModelBase) GetUpdatedAt() time.Time {
return time.Time{}
}
func (model *SModelBase) GetUpdateVersion() int {
return 0
}
func (model *SModelBase) GetDeleted() bool {
return false
}
func (model *SModelBase) SetModelManager(man IModelManager, virtual IModel) {
model.manager = man
model.SetVirtualObject(virtual)
+8
View File
@@ -329,6 +329,14 @@ func (opslog *SOpsLog) GetName() string {
return fmt.Sprintf("%s-%s", opslog.ObjType, opslog.Action)
}
func (opslog *SOpsLog) GetUpdatedAt() time.Time {
return opslog.OpsTime
}
func (opslog *SOpsLog) GetUpdateVersion() int {
return 1
}
func (opslog *SOpsLog) GetModelManager() IModelManager {
return OpsLog
}
+12
View File
@@ -128,3 +128,15 @@ func (manager *SResourceBaseManager) ListItemFilter(ctx context.Context, q *sqlc
}
return q, nil
}
func (model *SResourceBase) GetUpdateVersion() int {
return model.UpdateVersion
}
func (model *SResourceBase) GetUpdatedAt() time.Time {
return model.UpdatedAt
}
func (model *SResourceBase) GetDeleted() bool {
return model.Deleted
}