From ec2a7d438b5a1fee07cae6806493b5ead30a21c0 Mon Sep 17 00:00:00 2001 From: Radu Ioan Fericean Date: Fri, 5 Feb 2016 12:35:36 +0200 Subject: [PATCH] triggers console commands (new triggers_set) --- console/trigger_add.go | 63 ++++++++++++++++++++++++++++++++++++++++++ console/trigger_set.go | 8 +++--- 2 files changed, 67 insertions(+), 4 deletions(-) create mode 100644 console/trigger_add.go diff --git a/console/trigger_add.go b/console/trigger_add.go new file mode 100644 index 000000000..bef41f910 --- /dev/null +++ b/console/trigger_add.go @@ -0,0 +1,63 @@ +/* +Rating system designed to be used in VoIP Carriers World +Copyright (C) 2012-2015 ITsysCOM + +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 +*/ + +package console + +import "github.com/cgrates/cgrates/apier/v1" + +func init() { + c := &CmdAddTriggers{ + name: "triggers_add", + rpcMethod: "ApierV1.AddAccountActionTriggers", + rpcParams: &v1.AttrAddAccountActionTriggers{}, + } + commands[c.Name()] = c + c.CommandExecuter = &CommandExecuter{c} +} + +// Commander implementation +type CmdAddTriggers struct { + name string + rpcMethod string + rpcParams *v1.AttrAddAccountActionTriggers + *CommandExecuter +} + +func (self *CmdAddTriggers) Name() string { + return self.name +} + +func (self *CmdAddTriggers) RpcMethod() string { + return self.rpcMethod +} + +func (self *CmdAddTriggers) RpcParams(reset bool) interface{} { + if reset || self.rpcParams == nil { + self.rpcParams = &v1.AttrAddAccountActionTriggers{} + } + return self.rpcParams +} + +func (self *CmdAddTriggers) PostprocessRpcParams() error { + return nil +} + +func (self *CmdAddTriggers) RpcResult() interface{} { + var s string + return &s +} diff --git a/console/trigger_set.go b/console/trigger_set.go index fa7944eb7..2e9095d95 100644 --- a/console/trigger_set.go +++ b/console/trigger_set.go @@ -23,8 +23,8 @@ import "github.com/cgrates/cgrates/apier/v1" func init() { c := &CmdSetTriggers{ name: "triggers_set", - rpcMethod: "ApierV1.AddAccountActionTriggers", - rpcParams: &v1.AttrAddAccountActionTriggers{}, + rpcMethod: "ApierV1.SetAccountActionTriggers", + rpcParams: &v1.AttrSetAccountActionTriggers{}, } commands[c.Name()] = c c.CommandExecuter = &CommandExecuter{c} @@ -34,7 +34,7 @@ func init() { type CmdSetTriggers struct { name string rpcMethod string - rpcParams *v1.AttrAddAccountActionTriggers + rpcParams *v1.AttrSetAccountActionTriggers *CommandExecuter } @@ -48,7 +48,7 @@ func (self *CmdSetTriggers) RpcMethod() string { func (self *CmdSetTriggers) RpcParams(reset bool) interface{} { if reset || self.rpcParams == nil { - self.rpcParams = &v1.AttrAddAccountActionTriggers{} + self.rpcParams = &v1.AttrSetAccountActionTriggers{} } return self.rpcParams }