Updated GetStatQueueProfileIDs

This commit is contained in:
Tripon Alexandru-Ionut
2019-04-17 18:06:18 +03:00
committed by Dan Christian Bogos
parent c831f5749a
commit f1e11cdd59
7 changed files with 89 additions and 14 deletions

View File

@@ -40,8 +40,11 @@ func (apierV1 *ApierV1) GetStatQueueProfile(arg *utils.TenantID, reply *engine.S
}
// GetStatQueueProfileIDs returns list of statQueueProfile IDs registered for a tenant
func (apierV1 *ApierV1) GetStatQueueProfileIDs(tenant string, stsPrfIDs *[]string) error {
prfx := utils.StatQueueProfilePrefix + tenant + ":"
func (apierV1 *ApierV1) GetStatQueueProfileIDs(args utils.TenantArgWithPaginator, stsPrfIDs *[]string) error {
if missing := utils.MissingStructFields(&args, []string{utils.Tenant}); len(missing) != 0 { //Params missing
return utils.NewErrMandatoryIeMissing(missing...)
}
prfx := utils.StatQueueProfilePrefix + args.Tenant + ":"
keys, err := apierV1.DataManager.DataDB().GetKeysForPrefix(prfx)
if err != nil {
return err
@@ -53,7 +56,7 @@ func (apierV1 *ApierV1) GetStatQueueProfileIDs(tenant string, stsPrfIDs *[]strin
for i, key := range keys {
retIDs[i] = key[len(prfx):]
}
*stsPrfIDs = retIDs
*stsPrfIDs = args.PaginateStringSlice(retIDs)
return nil
}

View File

@@ -390,7 +390,7 @@ func testV1STSSetStatQueueProfile(t *testing.T) {
func testV1STSGetStatQueueProfileIDs(t *testing.T) {
expected := []string{"Stats1", "TEST_PROFILE1"}
var result []string
if err := stsV1Rpc.Call("ApierV1.GetStatQueueProfileIDs", "cgrates.org", &result); err != nil {
if err := stsV1Rpc.Call(utils.ApierV1GetStatQueueProfileIDs, utils.TenantArgWithPaginator{TenantArg: utils.TenantArg{Tenant: "cgrates.org"}}, &result); err != nil {
t.Error(err)
} else if len(expected) != len(result) {
t.Errorf("Expecting : %+v, received: %+v", expected, result)

View File

@@ -26,7 +26,7 @@ import (
func init() {
c := &CmdGetStatQueue{
name: "statqueue",
rpcMethod: "ApierV1.GetStatQueueProfile",
rpcMethod: utils.ApierV1GetStatQueueProfile,
rpcParams: &utils.TenantID{},
}
commands[c.Name()] = c

65
console/statqueue_ids.go Normal file
View File

@@ -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 <http://www.gnu.org/licenses/>
*/
package console
import (
"github.com/cgrates/cgrates/utils"
)
func init() {
c := &CmdGetStatQueueIDs{
name: "statqueue_ids",
rpcMethod: utils.ApierV1GetStatQueueProfileIDs,
rpcParams: &utils.TenantArgWithPaginator{},
}
commands[c.Name()] = c
c.CommandExecuter = &CommandExecuter{c}
}
// Commander implementation
type CmdGetStatQueueIDs struct {
name string
rpcMethod string
rpcParams *utils.TenantArgWithPaginator
*CommandExecuter
}
func (self *CmdGetStatQueueIDs) Name() string {
return self.name
}
func (self *CmdGetStatQueueIDs) RpcMethod() string {
return self.rpcMethod
}
func (self *CmdGetStatQueueIDs) RpcParams(reset bool) interface{} {
if reset || self.rpcParams == nil {
self.rpcParams = &utils.TenantArgWithPaginator{}
}
return self.rpcParams
}
func (self *CmdGetStatQueueIDs) PostprocessRpcParams() error {
return nil
}
func (self *CmdGetStatQueueIDs) RpcResult() interface{} {
atr := []string{}
return &atr
}

View File

@@ -23,7 +23,7 @@ import "github.com/cgrates/cgrates/utils"
func init() {
c := &CmdRemoveStatQueue{
name: "statqueue_remove",
rpcMethod: "ApierV1.RemoveStatQueueProfile",
rpcMethod: utils.ApierV1RemoveStatQueueProfile,
rpcParams: &utils.TenantIDWithCache{},
}
commands[c.Name()] = c

View File

@@ -18,12 +18,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
package console
import v1 "github.com/cgrates/cgrates/apier/v1"
import (
v1 "github.com/cgrates/cgrates/apier/v1"
"github.com/cgrates/cgrates/utils"
)
func init() {
c := &CmdSetStatQueue{
name: "statqueue_set",
rpcMethod: "ApierV1.SetStatQueueProfile",
rpcMethod: utils.ApierV1SetStatQueueProfile,
rpcParams: &v1.StatQueueWithCache{},
}
commands[c.Name()] = c

View File

@@ -794,12 +794,16 @@ const (
// StatS APIs
const (
StatSv1ProcessEvent = "StatSv1.ProcessEvent"
StatSv1GetQueueIDs = "StatSv1.GetQueueIDs"
StatSv1GetQueueStringMetrics = "StatSv1.GetQueueStringMetrics"
StatSv1GetQueueFloatMetrics = "StatSv1.GetQueueFloatMetrics"
StatSv1Ping = "StatSv1.Ping"
StatSv1GetStatQueuesForEvent = "StatSv1.GetStatQueuesForEvent"
StatSv1ProcessEvent = "StatSv1.ProcessEvent"
StatSv1GetQueueIDs = "StatSv1.GetQueueIDs"
StatSv1GetQueueStringMetrics = "StatSv1.GetQueueStringMetrics"
StatSv1GetQueueFloatMetrics = "StatSv1.GetQueueFloatMetrics"
StatSv1Ping = "StatSv1.Ping"
StatSv1GetStatQueuesForEvent = "StatSv1.GetStatQueuesForEvent"
ApierV1GetStatQueueProfile = "ApierV1.GetStatQueueProfile"
ApierV1RemoveStatQueueProfile = "ApierV1.RemoveStatQueueProfile"
ApierV1SetStatQueueProfile = "ApierV1.SetStatQueueProfile"
ApierV1GetStatQueueProfileIDs = "ApierV1.GetStatQueueProfileIDs"
)
// ResourceS APIs