diff --git a/apier/v1/scheduler.go b/apier/v1/scheduler.go index 69871f61a..247b476b3 100644 --- a/apier/v1/scheduler.go +++ b/apier/v1/scheduler.go @@ -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 { diff --git a/console/account_actionplan_get.go b/console/account_actionplan_get.go new file mode 100644 index 000000000..b478b5a62 --- /dev/null +++ b/console/account_actionplan_get.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 := &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 +} diff --git a/console/accountactions_set.go b/console/actionplan_set.go similarity index 65% rename from console/accountactions_set.go rename to console/actionplan_set.go index 69e54bd10..91fe80131 100644 --- a/console/accountactions_set.go +++ b/console/actionplan_set.go @@ -18,45 +18,46 @@ along with this program. If not, see 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 }