From 0bbf9a9374f5c62cfa5d1d03d7a41a1215cdea27 Mon Sep 17 00:00:00 2001 From: gouqi11 <66834753+gouqi11@users.noreply.github.com> Date: Fri, 12 Apr 2024 15:16:27 +0800 Subject: [PATCH] feat(notify): support cloudphone (#19960) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: 马鸿飞 --- pkg/apis/notify/const.go | 1 + pkg/apis/notify/event.go | 4 ++++ pkg/notify/models/event_template.go | 25 +++++++++++++++++++++++++ pkg/notify/models/topic.go | 18 ++++++++++++++++++ 4 files changed, 48 insertions(+) diff --git a/pkg/apis/notify/const.go b/pkg/apis/notify/const.go index ef94534f14..7fdfff772b 100644 --- a/pkg/apis/notify/const.go +++ b/pkg/apis/notify/const.go @@ -138,6 +138,7 @@ const ( TOPIC_RESOURCE_SERVICE = "service" TOPIC_RESOURCE_VM_INTEGRITY_CHECK = "vm_integrity" TOPIC_RESOURCE_PROJECT = "project" + TOPIC_RESOURCE_CLOUDPHONE = "cloudphone" SUBSCRIBER_TYPE_ROLE = "role" SUBSCRIBER_TYPE_ROBOT = "robot" diff --git a/pkg/apis/notify/event.go b/pkg/apis/notify/event.go index f9a3cfd29e..4365e0046f 100644 --- a/pkg/apis/notify/event.go +++ b/pkg/apis/notify/event.go @@ -66,6 +66,10 @@ var ( ActionIsolatedDeviceUpdate SAction = "isolated_device_update" ActionIsolatedDeviceDelete SAction = "isolated_device_delete" ActionStatusChanged SAction = "status_changed" + ActionStart SAction = "start" + ActionStop SAction = "stop" + ActionReset SAction = "reset" + ActionRestart SAction = "restart" ResultFailed SResult = "failed" ResultSucceed SResult = "succeed" diff --git a/pkg/notify/models/event_template.go b/pkg/notify/models/event_template.go index f505f34e21..b972e00760 100644 --- a/pkg/notify/models/event_template.go +++ b/pkg/notify/models/event_template.go @@ -309,6 +309,11 @@ func init() { "user", "用户", }, + sI18nElme{ + api.TOPIC_RESOURCE_CLOUDPHONE, + "cloudphone", + "云手机", + }, sI18nElme{ string(api.ActionCreate), "created", @@ -414,5 +419,25 @@ func init() { "add_backup_server", "添加主机备份", }, + sI18nElme{ + string(api.ActionStart), + "start", + "开机", + }, + sI18nElme{ + string(api.ActionStop), + "stop", + "关机", + }, + sI18nElme{ + string(api.ActionRestart), + "restart", + "重启", + }, + sI18nElme{ + string(api.ActionReset), + "reset", + "重置", + }, ) } diff --git a/pkg/notify/models/topic.go b/pkg/notify/models/topic.go index 01e54105f7..1330dd3913 100644 --- a/pkg/notify/models/topic.go +++ b/pkg/notify/models/topic.go @@ -277,8 +277,15 @@ func (sm *STopicManager) InitializeData() error { notify.TOPIC_RESOURCE_LOADBALANCER, notify.TOPIC_RESOURCE_DBINSTANCE, notify.TOPIC_RESOURCE_ELASTICCACHE, + notify.TOPIC_RESOURCE_CLOUDPHONE, ) t.addAction( + notify.ActionStart, + notify.ActionStop, + notify.ActionRestart, + notify.ActionReset, + notify.ActionAttach, + notify.ActionDetach, notify.ActionCreate, notify.ActionSyncStatus, notify.ActionRebuildRoot, @@ -292,8 +299,13 @@ func (sm *STopicManager) InitializeData() error { case DefaultResourceOperationSuccessed: t.addResources( notify.TOPIC_RESOURCE_SERVER, + notify.TOPIC_RESOURCE_CLOUDPHONE, ) t.addAction( + notify.ActionStart, + notify.ActionStop, + notify.ActionRestart, + notify.ActionReset, notify.ActionCreateBackupServer, ) t.Results = tristate.True @@ -505,6 +517,7 @@ func (sm *STopicManager) InitializeData() error { case DefaultAttachOrDetach: t.addResources( notify.TOPIC_RESOURCE_HOST, + notify.TOPIC_RESOURCE_CLOUDPHONE, ) t.addAction( notify.ActionAttach, @@ -839,6 +852,7 @@ func init() { notify.TOPIC_RESOURCE_SERVICE: 40, notify.TOPIC_RESOURCE_VM_INTEGRITY_CHECK: 41, notify.TOPIC_RESOURCE_PROJECT: 42, + notify.TOPIC_RESOURCE_CLOUDPHONE: 43, }, ) converter.registerAction( @@ -879,6 +893,10 @@ func init() { notify.ActionIsolatedDeviceUpdate: 33, notify.ActionIsolatedDeviceDelete: 34, notify.ActionStatusChanged: 35, + notify.ActionStart: 36, + notify.ActionStop: 37, + notify.ActionRestart: 38, + notify.ActionReset: 39, }, ) }