mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
85 lines
2.5 KiB
Go
85 lines
2.5 KiB
Go
/*
|
|
Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
|
|
Copyright (C) ITsysCOM GmbH
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU Affero General Public License as published by
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU Affero General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Affero General Public License
|
|
along with this program. If not, see <https://www.gnu.org/licenses/>
|
|
*/
|
|
|
|
package actions
|
|
|
|
import (
|
|
"github.com/cgrates/birpc/context"
|
|
"github.com/cgrates/cgrates/config"
|
|
"github.com/cgrates/cgrates/engine"
|
|
"github.com/cgrates/cgrates/utils"
|
|
)
|
|
|
|
type actResetStat struct {
|
|
tnt string
|
|
config *config.CGRConfig
|
|
connMgr *engine.ConnManager
|
|
aCfg *utils.APAction
|
|
}
|
|
|
|
func (aL *actResetStat) id() string {
|
|
return aL.aCfg.ID
|
|
}
|
|
|
|
func (aL *actResetStat) cfg() *utils.APAction {
|
|
return aL.aCfg
|
|
}
|
|
|
|
// execute implements actioner interface
|
|
func (aL *actResetStat) execute(ctx *context.Context, data utils.MapStorage, trgID string) (err error) {
|
|
args := &utils.TenantIDWithAPIOpts{
|
|
TenantID: utils.NewTenantID(trgID),
|
|
APIOpts: data[utils.MetaOpts].(map[string]any),
|
|
}
|
|
if args.Tenant == utils.EmptyString { // in case that user pass only ID we populate the tenant from the event
|
|
args.Tenant = aL.tnt
|
|
}
|
|
var rply string
|
|
return aL.connMgr.Call(ctx, aL.config.ActionSCfg().StatSConns,
|
|
utils.StatSv1ResetStatQueue, args, &rply)
|
|
}
|
|
|
|
type actResetThreshold struct {
|
|
tnt string
|
|
config *config.CGRConfig
|
|
connMgr *engine.ConnManager
|
|
aCfg *utils.APAction
|
|
}
|
|
|
|
func (aL *actResetThreshold) id() string {
|
|
return aL.aCfg.ID
|
|
}
|
|
|
|
func (aL *actResetThreshold) cfg() *utils.APAction {
|
|
return aL.aCfg
|
|
}
|
|
|
|
// execute implements actioner interface
|
|
func (aL *actResetThreshold) execute(ctx *context.Context, data utils.MapStorage, trgID string) (err error) {
|
|
args := &utils.TenantIDWithAPIOpts{
|
|
TenantID: utils.NewTenantID(trgID),
|
|
APIOpts: data[utils.MetaOpts].(map[string]any),
|
|
}
|
|
if args.Tenant == utils.EmptyString { // in case that user pass only ID we populate the tenant from the event
|
|
args.Tenant = aL.tnt
|
|
}
|
|
var rply string
|
|
return aL.connMgr.Call(ctx, aL.config.ActionSCfg().ThresholdSConns,
|
|
utils.ThresholdSv1ResetThreshold, args, &rply)
|
|
}
|