Adding cgr-console thresholds related API threshold_process_event

This commit is contained in:
edwardro22
2017-12-13 20:36:24 +02:00
committed by Dan Christian Bogos
parent ac96f48d27
commit d105646eb3
5 changed files with 87 additions and 7 deletions

View File

@@ -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)
}

View File

@@ -63,4 +63,4 @@ func (self *CmdGetSuppliers) PostprocessRpcParams() error {
func (self *CmdGetSuppliers) RpcResult() interface{} {
atr := engine.SupplierProfile{}
return &atr
}
}

View File

@@ -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
}

View File

@@ -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
}
}

View 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
}