more console commands

This commit is contained in:
Radu Ioan Fericean
2015-12-07 23:24:41 +02:00
parent 068a331693
commit ab316dbca0
3 changed files with 90 additions and 19 deletions

View File

@@ -129,18 +129,23 @@ func (self *ApierV1) GetScheduledActions(attrs AttrsGetScheduledActions, reply *
if !attrs.TimeEnd.IsZero() && (sas.NextRunTime.After(attrs.TimeEnd) || sas.NextRunTime.Equal(attrs.TimeEnd)) {
continue
}
// add the accounts
for _, accID := range qActions.AccountIds {
split := strings.Split(accID, utils.CONCATENATED_KEY_SEP)
if len(split) != 2 {
continue // malformed account id
}
sas.Accounts = append(sas.Accounts, &utils.TenantAccount{Tenant: split[0], Account: split[1]})
}
// filter on account
if attrs.Tenant != "" || attrs.Account != "" {
found := false
for _, accID := range qActions.AccountIds {
split := strings.Split(accID, utils.CONCATENATED_KEY_SEP)
if len(split) != 2 {
continue // malformed account id
}
if attrs.Tenant != "" && attrs.Tenant != split[0] {
for _, accPair := range sas.Accounts {
if attrs.Tenant != "" && attrs.Tenant != accPair.Tenant {
continue
}
if attrs.Account != "" && attrs.Account != split[1] {
if attrs.Account != "" && attrs.Account != accPair.Account {
continue
}
found = true
@@ -150,7 +155,9 @@ func (self *ApierV1) GetScheduledActions(attrs AttrsGetScheduledActions, reply *
continue
}
}
// we have a winner
schedActions = append(schedActions, sas)
}
if attrs.Paginator.Offset != nil {

View File

@@ -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 <http://www.gnu.org/licenses/>
*/
package console
import "github.com/cgrates/cgrates/apier/v1"
func init() {
c := &CmdGetAccountActionPlan{
name: "account_actionplan_get",
rpcMethod: "ApierV1.GetAccountActionPlan",
rpcParams: &v1.AttrAcntAction{},
}
commands[c.Name()] = c
c.CommandExecuter = &CommandExecuter{c}
}
// Commander implementation
type CmdGetAccountActionPlan struct {
name string
rpcMethod string
rpcParams *v1.AttrAcntAction
*CommandExecuter
}
func (self *CmdGetAccountActionPlan) Name() string {
return self.name
}
func (self *CmdGetAccountActionPlan) RpcMethod() string {
return self.rpcMethod
}
func (self *CmdGetAccountActionPlan) RpcParams(reset bool) interface{} {
if reset || self.rpcParams == nil {
self.rpcParams = &v1.AttrAcntAction{}
}
return self.rpcParams
}
func (self *CmdGetAccountActionPlan) PostprocessRpcParams() error {
return nil
}
func (self *CmdGetAccountActionPlan) RpcResult() interface{} {
s := make([]*v1.AccountActionTiming, 0)
return &s
}

View File

@@ -18,45 +18,46 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
package console
import "github.com/cgrates/cgrates/utils"
import "github.com/cgrates/cgrates/apier/v1"
func init() {
c := &CmdSetAccountActions{
name: "accountactions_set",
rpcMethod: "ApierV1.SetAccountActions",
c := &CmdSetActionPlan{
name: "actionplan_set",
rpcMethod: "ApierV1.SetActionPlan",
rpcParams: &v1.AttrSetActionPlan{},
}
commands[c.Name()] = c
c.CommandExecuter = &CommandExecuter{c}
}
// Commander implementation
type CmdSetAccountActions struct {
type CmdSetActionPlan struct {
name string
rpcMethod string
rpcParams *utils.TPAccountActions
rpcParams *v1.AttrSetActionPlan
*CommandExecuter
}
func (self *CmdSetAccountActions) Name() string {
func (self *CmdSetActionPlan) Name() string {
return self.name
}
func (self *CmdSetAccountActions) RpcMethod() string {
func (self *CmdSetActionPlan) RpcMethod() string {
return self.rpcMethod
}
func (self *CmdSetAccountActions) RpcParams(reset bool) interface{} {
func (self *CmdSetActionPlan) RpcParams(reset bool) interface{} {
if reset || self.rpcParams == nil {
self.rpcParams = &utils.TPAccountActions{}
self.rpcParams = &v1.AttrSetActionPlan{}
}
return self.rpcParams
}
func (self *CmdSetAccountActions) PostprocessRpcParams() error {
func (self *CmdSetActionPlan) PostprocessRpcParams() error {
return nil
}
func (self *CmdSetAccountActions) RpcResult() interface{} {
func (self *CmdSetActionPlan) RpcResult() interface{} {
var s string
return &s
}