alertdashboard_panel.go 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. "context"
  17. "yunion.io/x/onecloud/pkg/cloudcommon/db"
  18. "yunion.io/x/onecloud/pkg/mcclient"
  19. )
  20. var (
  21. AlertDashBoardPanelManager *SAlertDashboardPanelManager
  22. )
  23. // +onecloud:swagger-gen-ignore
  24. type SAlertDashboardPanelManager struct {
  25. db.SJointResourceBaseManager
  26. }
  27. func init() {
  28. db.InitManager(func() {
  29. AlertDashBoardPanelManager = &SAlertDashboardPanelManager{
  30. SJointResourceBaseManager: db.NewJointResourceBaseManager(
  31. SAlertDashboardPanel{},
  32. "alertdashboardpanel_tbl",
  33. "alertdashboardpanel",
  34. "alertdashboardpanels",
  35. AlertDashBoardManager,
  36. AlertPanelManager,
  37. ),
  38. }
  39. AlertDashBoardPanelManager.SetVirtualObject(AlertDashBoardPanelManager)
  40. AlertDashBoardPanelManager.TableSpec().AddIndex(true, AlertDashBoardPanelManager.GetMasterFieldName(), AlertDashBoardPanelManager.GetSlaveFieldName())
  41. })
  42. }
  43. // +onecloud:swagger-gen-ignore
  44. type SAlertDashboardPanel struct {
  45. db.SVirtualJointResourceBase
  46. DashboardId string `width:"36" charset:"ascii" nullable:"false" list:"user" create:"required" index:"true"`
  47. PanelId string `width:"36" charset:"ascii" nullable:"false" list:"user" create:"required" index:"true"`
  48. Index int `nullable:"true" default:"0" list:"user" create:"optional"`
  49. }
  50. func (man *SAlertDashboardPanelManager) GetMasterFieldName() string {
  51. return "dashboard_id"
  52. }
  53. func (man *SAlertDashboardPanelManager) GetSlaveFieldName() string {
  54. return "panel_id"
  55. }
  56. func (joint *SAlertDashboardPanel) Detach(ctx context.Context, userCred mcclient.TokenCredential) error {
  57. return db.DetachJoint(ctx, userCred, joint)
  58. }