mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-16 05:39:54 +05:00
129 lines
4.1 KiB
Go
Executable File
129 lines
4.1 KiB
Go
Executable File
/*
|
|
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 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 General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>
|
|
*/
|
|
|
|
package dispatchers
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/cgrates/cgrates/engine"
|
|
"github.com/cgrates/cgrates/utils"
|
|
)
|
|
|
|
func (dS *DispatcherService) StatSv1Ping(args *utils.CGREventWithArgDispatcher, reply *string) (err error) {
|
|
if args.ArgDispatcher == nil {
|
|
return utils.NewErrMandatoryIeMissing("ArgDispatcher")
|
|
}
|
|
if dS.attrS != nil {
|
|
if err = dS.authorize(utils.StatSv1Ping,
|
|
args.CGREvent.Tenant,
|
|
args.APIKey, args.CGREvent.Time); err != nil {
|
|
return
|
|
}
|
|
}
|
|
return dS.Dispatch(args.CGREvent, utils.MetaStats, args.RouteID,
|
|
utils.StatSv1Ping, args.CGREvent, reply)
|
|
}
|
|
|
|
func (dS *DispatcherService) StatSv1GetStatQueuesForEvent(args *engine.StatsArgsProcessEvent,
|
|
reply *[]string) (err error) {
|
|
if args.ArgDispatcher == nil {
|
|
return utils.NewErrMandatoryIeMissing("ArgDispatcher")
|
|
}
|
|
if dS.attrS != nil {
|
|
if err = dS.authorize(utils.StatSv1GetStatQueuesForEvent,
|
|
args.CGREvent.Tenant,
|
|
args.APIKey, args.CGREvent.Time); err != nil {
|
|
return
|
|
}
|
|
}
|
|
return dS.Dispatch(&args.CGREvent, utils.MetaStats, args.RouteID,
|
|
utils.StatSv1GetStatQueuesForEvent, args, reply)
|
|
}
|
|
|
|
func (dS *DispatcherService) StatSv1GetQueueStringMetrics(args *utils.TenantIDWithArgDispatcher,
|
|
reply *map[string]string) (err error) {
|
|
if args.ArgDispatcher == nil {
|
|
return utils.NewErrMandatoryIeMissing("ArgDispatcher")
|
|
}
|
|
if dS.attrS != nil {
|
|
if err = dS.authorize(utils.StatSv1GetQueueStringMetrics,
|
|
args.TenantID.Tenant,
|
|
args.APIKey, utils.TimePointer(time.Now())); err != nil {
|
|
return
|
|
}
|
|
}
|
|
return dS.Dispatch(&utils.CGREvent{
|
|
Tenant: args.Tenant,
|
|
ID: args.ID,
|
|
}, utils.MetaStats, args.RouteID, utils.StatSv1GetQueueStringMetrics,
|
|
args.TenantID, reply)
|
|
}
|
|
|
|
func (dS *DispatcherService) StatSv1ProcessEvent(args *engine.StatsArgsProcessEvent,
|
|
reply *[]string) (err error) {
|
|
if args.ArgDispatcher == nil {
|
|
return utils.NewErrMandatoryIeMissing("ArgDispatcher")
|
|
}
|
|
if dS.attrS != nil {
|
|
if err = dS.authorize(utils.StatSv1ProcessEvent,
|
|
args.CGREvent.Tenant,
|
|
args.APIKey, args.CGREvent.Time); err != nil {
|
|
return
|
|
}
|
|
}
|
|
return dS.Dispatch(&args.CGREvent, utils.MetaStats, args.RouteID,
|
|
utils.StatSv1ProcessEvent, args, reply)
|
|
}
|
|
|
|
func (dS *DispatcherService) StatSv1GetQueueFloatMetrics(args *utils.TenantIDWithArgDispatcher,
|
|
reply *map[string]float64) (err error) {
|
|
if args.ArgDispatcher == nil {
|
|
return utils.NewErrMandatoryIeMissing("ArgDispatcher")
|
|
}
|
|
if dS.attrS != nil {
|
|
if err = dS.authorize(utils.StatSv1GetQueueFloatMetrics,
|
|
args.TenantID.Tenant,
|
|
args.APIKey, utils.TimePointer(time.Now())); err != nil {
|
|
return
|
|
}
|
|
}
|
|
return dS.Dispatch(&utils.CGREvent{
|
|
Tenant: args.Tenant,
|
|
ID: args.ID,
|
|
}, utils.MetaStats, args.RouteID, utils.StatSv1GetQueueFloatMetrics,
|
|
args.TenantID, reply)
|
|
}
|
|
|
|
func (dS *DispatcherService) StatSv1GetQueueIDs(args *utils.TenantWithArgDispatcher,
|
|
reply *[]string) (err error) {
|
|
if args.ArgDispatcher == nil {
|
|
return utils.NewErrMandatoryIeMissing("ArgDispatcher")
|
|
}
|
|
if dS.attrS != nil {
|
|
if err = dS.authorize(utils.StatSv1GetQueueIDs,
|
|
args.TenantArg.Tenant,
|
|
args.APIKey, utils.TimePointer(time.Now())); err != nil {
|
|
return
|
|
}
|
|
}
|
|
return dS.Dispatch(&utils.CGREvent{Tenant: args.Tenant},
|
|
utils.MetaStats, args.RouteID, utils.StatSv1GetQueueIDs,
|
|
args.TenantArg, reply)
|
|
}
|