mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
added get action plan api + console
This commit is contained in:
@@ -252,7 +252,7 @@ func (self *ApierV1) RemoveAccount(attr utils.AttrRemoveAccount, reply *string)
|
||||
// delete without preserving order
|
||||
at.AccountIds[i] = at.AccountIds[len(at.AccountIds)-1]
|
||||
at.AccountIds = at.AccountIds[:len(at.AccountIds)-1]
|
||||
i -= 1
|
||||
i--
|
||||
changed = true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -775,6 +775,31 @@ func (self *ApierV1) SetActionPlan(attrs AttrSetActionPlan, reply *string) error
|
||||
return nil
|
||||
}
|
||||
|
||||
type AttrGetActionPlan struct {
|
||||
Id string
|
||||
}
|
||||
|
||||
func (self *ApierV1) GetActionPlan(attr AttrGetActionPlan, reply *[]engine.ActionPlans) error {
|
||||
var result []engine.ActionPlans
|
||||
if attr.Id == "" || attr.Id == "*" {
|
||||
aplsMap, err := self.RatingDb.GetAllActionPlans()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, apls := range aplsMap {
|
||||
result = append(result, apls)
|
||||
}
|
||||
} else {
|
||||
apls, err := self.RatingDb.GetActionPlans(attr.Id, false)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
result = append(result, apls)
|
||||
}
|
||||
*reply = result
|
||||
return nil
|
||||
}
|
||||
|
||||
type AttrAddActionTrigger struct {
|
||||
ActionTriggersId string
|
||||
Tenant string
|
||||
|
||||
66
console/actionplan_get.go
Normal file
66
console/actionplan_get.go
Normal file
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
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 <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
|
||||
package console
|
||||
|
||||
import (
|
||||
"github.com/cgrates/cgrates/apier/v1"
|
||||
"github.com/cgrates/cgrates/engine"
|
||||
)
|
||||
|
||||
func init() {
|
||||
c := &CmdGetActionPlan{
|
||||
name: "actionplan_get",
|
||||
rpcMethod: "ApierV1.GetActionPlan",
|
||||
rpcParams: &v1.AttrGetActionPlan{},
|
||||
}
|
||||
commands[c.Name()] = c
|
||||
c.CommandExecuter = &CommandExecuter{c}
|
||||
}
|
||||
|
||||
// Commander implementation
|
||||
type CmdGetActionPlan struct {
|
||||
name string
|
||||
rpcMethod string
|
||||
rpcParams *v1.AttrGetActionPlan
|
||||
*CommandExecuter
|
||||
}
|
||||
|
||||
func (self *CmdGetActionPlan) Name() string {
|
||||
return self.name
|
||||
}
|
||||
|
||||
func (self *CmdGetActionPlan) RpcMethod() string {
|
||||
return self.rpcMethod
|
||||
}
|
||||
|
||||
func (self *CmdGetActionPlan) RpcParams(reset bool) interface{} {
|
||||
if reset || self.rpcParams == nil {
|
||||
self.rpcParams = &v1.AttrGetActionPlan{}
|
||||
}
|
||||
return self.rpcParams
|
||||
}
|
||||
|
||||
func (self *CmdGetActionPlan) PostprocessRpcParams() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *CmdGetActionPlan) RpcResult() interface{} {
|
||||
s := make([]*engine.ActionPlans, 0)
|
||||
return &s
|
||||
}
|
||||
Reference in New Issue
Block a user