mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Updated GetResourceProfileIDs
This commit is contained in:
committed by
Dan Christian Bogos
parent
9c379a969a
commit
ee148bf3e4
@@ -86,8 +86,11 @@ func (apierV1 *ApierV1) GetResourceProfile(arg utils.TenantID, reply *engine.Res
|
||||
}
|
||||
|
||||
// GetResourceProfileIDs returns list of resourceProfile IDs registered for a tenant
|
||||
func (apierV1 *ApierV1) GetResourceProfileIDs(tenant string, rsPrfIDs *[]string) error {
|
||||
prfx := utils.ResourceProfilesPrefix + tenant + ":"
|
||||
func (apierV1 *ApierV1) GetResourceProfileIDs(args utils.TenantArgWithPaginator, rsPrfIDs *[]string) error {
|
||||
if missing := utils.MissingStructFields(&args, []string{utils.Tenant}); len(missing) != 0 { //Params missing
|
||||
return utils.NewErrMandatoryIeMissing(missing...)
|
||||
}
|
||||
prfx := utils.ResourceProfilesPrefix + args.Tenant + ":"
|
||||
keys, err := apierV1.DataManager.DataDB().GetKeysForPrefix(prfx)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -99,7 +102,7 @@ func (apierV1 *ApierV1) GetResourceProfileIDs(tenant string, rsPrfIDs *[]string)
|
||||
for i, key := range keys {
|
||||
retIDs[i] = key[len(prfx):]
|
||||
}
|
||||
*rsPrfIDs = retIDs
|
||||
*rsPrfIDs = args.PaginateStringSlice(retIDs)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -650,7 +650,7 @@ func testV1RsSetResourceProfile(t *testing.T) {
|
||||
func testV1RsGetResourceProfileIDs(t *testing.T) {
|
||||
expected := []string{"ResGroup2", "ResGroup1", "ResGroup3", "RES_GR_TEST"}
|
||||
var result []string
|
||||
if err := rlsV1Rpc.Call("ApierV1.GetResourceProfileIDs", "cgrates.org", &result); err != nil {
|
||||
if err := rlsV1Rpc.Call(utils.ApierV1GetResourceProfileIDs, 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)
|
||||
|
||||
@@ -26,7 +26,7 @@ import (
|
||||
func init() {
|
||||
c := &CmdGetResource{
|
||||
name: "resource",
|
||||
rpcMethod: "ApierV1.GetResourceProfile",
|
||||
rpcMethod: utils.ApierV1GetResourceProfile,
|
||||
rpcParams: &utils.TenantID{},
|
||||
}
|
||||
commands[c.Name()] = c
|
||||
|
||||
65
console/resource_ids.go
Normal file
65
console/resource_ids.go
Normal 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 := &CmdGetResourceIDs{
|
||||
name: "resource_ids",
|
||||
rpcMethod: utils.ApierV1GetResourceProfileIDs,
|
||||
rpcParams: &utils.TenantArgWithPaginator{},
|
||||
}
|
||||
commands[c.Name()] = c
|
||||
c.CommandExecuter = &CommandExecuter{c}
|
||||
}
|
||||
|
||||
// Commander implementation
|
||||
type CmdGetResourceIDs struct {
|
||||
name string
|
||||
rpcMethod string
|
||||
rpcParams *utils.TenantArgWithPaginator
|
||||
*CommandExecuter
|
||||
}
|
||||
|
||||
func (self *CmdGetResourceIDs) Name() string {
|
||||
return self.name
|
||||
}
|
||||
|
||||
func (self *CmdGetResourceIDs) RpcMethod() string {
|
||||
return self.rpcMethod
|
||||
}
|
||||
|
||||
func (self *CmdGetResourceIDs) RpcParams(reset bool) interface{} {
|
||||
if reset || self.rpcParams == nil {
|
||||
self.rpcParams = &utils.TenantArgWithPaginator{}
|
||||
}
|
||||
return self.rpcParams
|
||||
}
|
||||
|
||||
func (self *CmdGetResourceIDs) PostprocessRpcParams() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *CmdGetResourceIDs) RpcResult() interface{} {
|
||||
atr := []string{}
|
||||
return &atr
|
||||
}
|
||||
@@ -23,7 +23,7 @@ import "github.com/cgrates/cgrates/utils"
|
||||
func init() {
|
||||
c := &CmdRemoveResource{
|
||||
name: "resource_remove",
|
||||
rpcMethod: "ApierV1.RemoveResourceProfile",
|
||||
rpcMethod: utils.ApierV1RemoveResourceProfile,
|
||||
rpcParams: &utils.TenantIDWithCache{},
|
||||
}
|
||||
commands[c.Name()] = c
|
||||
|
||||
@@ -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 := &CmdSetResource{
|
||||
name: "resource_set",
|
||||
rpcMethod: "ApierV1.SetResourceProfile",
|
||||
rpcMethod: utils.ApierV1SetResourceProfile,
|
||||
rpcParams: &v1.ResourceWithCache{},
|
||||
}
|
||||
commands[c.Name()] = c
|
||||
|
||||
@@ -805,6 +805,10 @@ const (
|
||||
ResourceSv1AllocateResources = "ResourceSv1.AllocateResources"
|
||||
ResourceSv1ReleaseResources = "ResourceSv1.ReleaseResources"
|
||||
ResourceSv1Ping = "ResourceSv1.Ping"
|
||||
ApierV1SetResourceProfile = "ApierV1.SetResourceProfile"
|
||||
ApierV1RemoveResourceProfile = "ApierV1.RemoveResourceProfile"
|
||||
ApierV1GetResourceProfile = "ApierV1.GetResourceProfile"
|
||||
ApierV1GetResourceProfileIDs = "ApierV1.GetResourceProfileIDs"
|
||||
)
|
||||
|
||||
// SessionS APIs
|
||||
|
||||
Reference in New Issue
Block a user