mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Adding cgr-console thresholds related API threshold_process_event
This commit is contained in:
committed by
Dan Christian Bogos
parent
ac96f48d27
commit
d105646eb3
@@ -59,6 +59,11 @@ func (ce *CommandExecuter) FromArgs(args string, verbose bool) error {
|
||||
}
|
||||
|
||||
func (ce *CommandExecuter) clientArgs(iface interface{}) (args []string) {
|
||||
_, ok := iface.(*map[string]interface{})
|
||||
if ok {
|
||||
args = append(args, "MapStringInterface")
|
||||
return
|
||||
}
|
||||
val := reflect.ValueOf(iface)
|
||||
if val.Kind() == reflect.Ptr {
|
||||
val = val.Elem()
|
||||
@@ -88,7 +93,6 @@ func (ce *CommandExecuter) clientArgs(iface interface{}) (args []string) {
|
||||
continue
|
||||
}
|
||||
args = append(args, ce.clientArgs(valInterf)...)
|
||||
|
||||
default:
|
||||
args = append(args, typeField.Name)
|
||||
}
|
||||
|
||||
@@ -63,4 +63,4 @@ func (self *CmdGetSuppliers) PostprocessRpcParams() error {
|
||||
func (self *CmdGetSuppliers) RpcResult() interface{} {
|
||||
atr := engine.SupplierProfile{}
|
||||
return &atr
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
package console
|
||||
|
||||
import "github.com/cgrates/cgrates/utils"
|
||||
|
||||
//rename to suppliers everything
|
||||
func init() {
|
||||
c := &CmdRemoveSuppliers{
|
||||
@@ -61,4 +62,3 @@ func (self *CmdRemoveSuppliers) RpcResult() interface{} {
|
||||
var s string
|
||||
return &s
|
||||
}
|
||||
|
||||
|
||||
@@ -35,9 +35,9 @@ func init() {
|
||||
|
||||
// Commander implementation
|
||||
type CmdSuppliersSort struct {
|
||||
name string
|
||||
rpcMethod string
|
||||
rpcParams *utils.CGREvent
|
||||
name string
|
||||
rpcMethod string
|
||||
rpcParams *utils.CGREvent
|
||||
clientArgs []string
|
||||
*CommandExecuter
|
||||
}
|
||||
@@ -64,4 +64,4 @@ func (self *CmdSuppliersSort) PostprocessRpcParams() error {
|
||||
func (self *CmdSuppliersSort) RpcResult() interface{} {
|
||||
atr := engine.SupplierProfile{}
|
||||
return &atr
|
||||
}
|
||||
}
|
||||
|
||||
76
console/threshold_process_event.go
Normal file
76
console/threshold_process_event.go
Normal file
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
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 console
|
||||
|
||||
import (
|
||||
"github.com/cgrates/cgrates/config"
|
||||
"github.com/cgrates/cgrates/utils"
|
||||
)
|
||||
|
||||
func init() {
|
||||
c := &CmdThresholdProcessEvent{
|
||||
name: "threshold_process_event",
|
||||
rpcMethod: "ThresholdSv1.ProcessEvent",
|
||||
}
|
||||
commands[c.Name()] = c
|
||||
c.CommandExecuter = &CommandExecuter{c}
|
||||
}
|
||||
|
||||
// Commander implementation
|
||||
type CmdThresholdProcessEvent struct {
|
||||
name string
|
||||
rpcMethod string
|
||||
rpcParams interface{}
|
||||
*CommandExecuter
|
||||
}
|
||||
|
||||
func (self *CmdThresholdProcessEvent) Name() string {
|
||||
return self.name
|
||||
}
|
||||
|
||||
func (self *CmdThresholdProcessEvent) RpcMethod() string {
|
||||
return self.rpcMethod
|
||||
}
|
||||
|
||||
func (self *CmdThresholdProcessEvent) RpcParams(reset bool) interface{} {
|
||||
if reset || self.rpcParams == nil {
|
||||
mp := make(map[string]interface{})
|
||||
self.rpcParams = &mp
|
||||
}
|
||||
return self.rpcParams
|
||||
}
|
||||
|
||||
func (self *CmdThresholdProcessEvent) PostprocessRpcParams() error { //utils.CGREvent
|
||||
param := self.rpcParams.(*map[string]interface{})
|
||||
cgrev := utils.CGREvent{
|
||||
Tenant: config.CgrConfig().DefaultTenant,
|
||||
ID: utils.UUIDSha1Prefix(),
|
||||
Event: *param,
|
||||
}
|
||||
if (*param)[utils.TENANT] != nil && (*param)[utils.TENANT].(string) != "" {
|
||||
cgrev.Tenant = (*param)[utils.TENANT].(string)
|
||||
}
|
||||
self.rpcParams = cgrev
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *CmdThresholdProcessEvent) RpcResult() interface{} {
|
||||
var s int
|
||||
return &s
|
||||
}
|
||||
Reference in New Issue
Block a user