interface.go 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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 base
  15. import (
  16. "context"
  17. "net/http"
  18. "yunion.io/x/jsonutils"
  19. "yunion.io/x/onecloud/pkg/appsrv"
  20. "yunion.io/x/onecloud/pkg/cloudcommon/db/lockman"
  21. "yunion.io/x/onecloud/pkg/cloudcommon/etcd"
  22. "yunion.io/x/onecloud/pkg/mcclient"
  23. )
  24. type IEtcdModelManager interface {
  25. lockman.ILockedClass
  26. KeywordPlural() string
  27. Allocate() IEtcdModel
  28. AllJson(ctx context.Context) ([]jsonutils.JSONObject, error)
  29. GetJson(ctx context.Context, idstr string) (jsonutils.JSONObject, error)
  30. Get(ctx context.Context, idstr string, model IEtcdModel) error
  31. All(ctx context.Context, dest interface{}) error
  32. Save(ctx context.Context, model IEtcdModel) error
  33. Delete(ctx context.Context, model IEtcdModel) error
  34. Session(ctx context.Context, model IEtcdModel) error
  35. Watch(ctx context.Context, onCreate etcd.TEtcdCreateEventFunc, onModify etcd.TEtcdModifyEventFunc, onDelete etcd.TEtcdDeleteEventFunc)
  36. CustomizeHandlerInfo(handler *appsrv.SHandlerInfo)
  37. FetchCreateHeaderData(ctx context.Context, header http.Header) (jsonutils.JSONObject, error)
  38. FetchUpdateHeaderData(ctx context.Context, header http.Header) (jsonutils.JSONObject, error)
  39. }
  40. type IEtcdModel interface {
  41. lockman.ILockedObject
  42. GetModelManager() IEtcdModelManager
  43. SetModelManager(IEtcdModelManager, IEtcdModel)
  44. SetId(id string)
  45. GetExtraDetailsHeaders(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject) map[string]string
  46. }