diff --git a/apier/v1/apier.go b/apier/v1/apier.go index 5bfcd6dab..8ac38ef59 100644 --- a/apier/v1/apier.go +++ b/apier/v1/apier.go @@ -1233,3 +1233,21 @@ func (self *ApierV1) ComputeActionPlanIndexes(_ string, reply *string) (err erro *reply = utils.OK return nil } + +// GetActionPlanIDs returns list of attributeProfile IDs registered for a tenant +func (apierV1 *ApierV1) GetActionPlanIDs(args utils.TenantArgWithPaginator, attrPrfIDs *[]string) error { + prfx := utils.ACTION_PLAN_PREFIX + keys, err := apierV1.DataManager.DataDB().GetKeysForPrefix(utils.ACTION_PLAN_PREFIX) + if err != nil { + return err + } + if len(keys) == 0 { + return utils.ErrNotFound + } + retIDs := make([]string, len(keys)) + for i, key := range keys { + retIDs[i] = key[len(prfx):] + } + *attrPrfIDs = args.PaginateStringSlice(retIDs) + return nil +} diff --git a/apier/v1/versions_it_test.go b/apier/v1/versions_it_test.go index d872c2a27..f197510c3 100644 --- a/apier/v1/versions_it_test.go +++ b/apier/v1/versions_it_test.go @@ -108,7 +108,7 @@ func testVrsDataDB(t *testing.T) { var result engine.Versions expectedVrs := engine.Versions{"ActionTriggers": 2, "Actions": 2, "RQF": 1, "ReverseDestinations": 1, "Attributes": 4, "RatingPlan": 1, - "RatingProfile": 1, "User": 1, "Accounts": 3, "ActionPlans": 2, "Chargers": 1, + "RatingProfile": 1, "User": 1, "Accounts": 3, "ActionPlans": 3, "Chargers": 1, "Destinations": 1, "SharedGroups": 2, "Stats": 2, "Resource": 1, "Subscribers": 1, "Suppliers": 1, "Thresholds": 3, "Timing": 1} if err := vrsRPC.Call("ApierV1.GetDataDBVersions", "", &result); err != nil { @@ -148,7 +148,7 @@ func testVrsSetDataDBVrs(t *testing.T) { var result engine.Versions expectedVrs := engine.Versions{"ActionTriggers": 2, "Actions": 2, "RQF": 1, "ReverseDestinations": 1, "Attributes": 3, "RatingPlan": 1, - "RatingProfile": 1, "User": 1, "Accounts": 3, "ActionPlans": 2, "Chargers": 1, + "RatingProfile": 1, "User": 1, "Accounts": 3, "ActionPlans": 3, "Chargers": 1, "Destinations": 1, "SharedGroups": 2, "Stats": 2, "Resource": 1, "Subscribers": 1, "Suppliers": 1, "Thresholds": 3, "Timing": 1} if err := vrsRPC.Call("ApierV1.GetDataDBVersions", "", &result); err != nil { diff --git a/console/actionplan_indexes_compute.go b/console/actionplan_indexes_compute.go new file mode 100644 index 000000000..a6a1a77b6 --- /dev/null +++ b/console/actionplan_indexes_compute.go @@ -0,0 +1,65 @@ +/* +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 +*/ + +package console + +import ( + "github.com/cgrates/cgrates/utils" +) + +func init() { + c := &CmdComputeActionPlanIndexes{ + name: "actionplan_compute_indexes", + rpcMethod: utils.ApierV1ComputeActionPlanIndexes, + rpcParams: new(EmptyWrapper), + } + commands[c.Name()] = c + c.CommandExecuter = &CommandExecuter{c} +} + +// Commander implementation +type CmdComputeActionPlanIndexes struct { + name string + rpcMethod string + rpcParams *EmptyWrapper + *CommandExecuter +} + +func (self *CmdComputeActionPlanIndexes) Name() string { + return self.name +} + +func (self *CmdComputeActionPlanIndexes) RpcMethod() string { + return self.rpcMethod +} + +func (self *CmdComputeActionPlanIndexes) RpcParams(reset bool) interface{} { + if reset || self.rpcParams == nil { + self.rpcParams = new(EmptyWrapper) + } + return self.rpcParams +} + +func (self *CmdComputeActionPlanIndexes) PostprocessRpcParams() error { + return nil +} + +func (self *CmdComputeActionPlanIndexes) RpcResult() interface{} { + s := "" + return &s +} diff --git a/utils/consts.go b/utils/consts.go index 52c6e423f..2ca0af2f3 100755 --- a/utils/consts.go +++ b/utils/consts.go @@ -808,6 +808,7 @@ const ( ApierV1SetDataDBVersions = "ApierV1.SetDataDBVersions" ApierV1SetStorDBVersions = "ApierV1.SetStorDBVersions" ApierV1GetAccountActionPlan = "ApierV1.GetAccountActionPlan" + ApierV1ComputeActionPlanIndexes = "ApierV1.ComputeActionPlanIndexes" ) const (