@@ -2486,3 +2486,58 @@ func (me *MonitorService) DescribeMonitorStatisticDataByFilter(ctx context.Conte
24862486
24872487 return
24882488}
2489+
2490+ func (me * MonitorService ) DescribeMonitorTmpAlertGroupById (ctx context.Context , instanceId , groupId string ) (tmpAlertGroup * monitor.PrometheusAlertGroupSet , errRet error ) {
2491+ logId := tccommon .GetLogId (ctx )
2492+
2493+ request := monitor .NewDescribePrometheusAlertGroupsRequest ()
2494+ request .InstanceId = & instanceId
2495+ request .GroupId = & groupId
2496+
2497+ defer func () {
2498+ if errRet != nil {
2499+ log .Printf ("[CRITAL]%s api[%s] fail, request body [%s], reason[%s]\n " , logId , request .GetAction (), request .ToJsonString (), errRet .Error ())
2500+ }
2501+ }()
2502+
2503+ ratelimit .Check (request .GetAction ())
2504+
2505+ response , err := me .client .UseMonitorClient ().DescribePrometheusAlertGroups (request )
2506+ if err != nil {
2507+ errRet = err
2508+ return
2509+ }
2510+ log .Printf ("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n " , logId , request .GetAction (), request .ToJsonString (), response .ToJsonString ())
2511+
2512+ if response == nil || len (response .Response .AlertGroupSet ) < 1 {
2513+ return
2514+ }
2515+
2516+ tmpAlertGroup = response .Response .AlertGroupSet [0 ]
2517+ return
2518+ }
2519+
2520+ func (me * MonitorService ) DeleteMonitorTmpAlertGroupById (ctx context.Context , instanceId , groupId string ) (errRet error ) {
2521+ logId := tccommon .GetLogId (ctx )
2522+
2523+ request := monitor .NewDeletePrometheusAlertGroupsRequest ()
2524+ request .InstanceId = & instanceId
2525+ request .GroupIds = []* string {& groupId }
2526+
2527+ defer func () {
2528+ if errRet != nil {
2529+ log .Printf ("[CRITAL]%s api[%s] fail, request body [%s], reason[%s]\n " , logId , request .GetAction (), request .ToJsonString (), errRet .Error ())
2530+ }
2531+ }()
2532+
2533+ ratelimit .Check (request .GetAction ())
2534+
2535+ response , err := me .client .UseMonitorClient ().DeletePrometheusAlertGroups (request )
2536+ if err != nil {
2537+ errRet = err
2538+ return
2539+ }
2540+ log .Printf ("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n " , logId , request .GetAction (), request .ToJsonString (), response .ToJsonString ())
2541+
2542+ return
2543+ }
0 commit comments