From 315b8048e8a15609219ac8421044c75eb863200e Mon Sep 17 00:00:00 2001 From: Tripon Alexandru-Ionut Date: Wed, 17 Apr 2019 18:12:42 +0300 Subject: [PATCH] Updated GetSupplierProfileIDs --- apier/v1/suppliers.go | 10 +++++----- apier/v1/suppliers_it_test.go | 2 +- console/supplier_ids.go | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/apier/v1/suppliers.go b/apier/v1/suppliers.go index a04da8da2..232a474db 100644 --- a/apier/v1/suppliers.go +++ b/apier/v1/suppliers.go @@ -39,11 +39,11 @@ func (apierV1 *ApierV1) GetSupplierProfile(arg utils.TenantID, reply *engine.Sup } // GetSupplierProfileIDs returns list of supplierProfile IDs registered for a tenant -func (apierV1 *ApierV1) GetSupplierProfileIDs(tenantArg *utils.TenantArg, sppPrfIDs *[]string) error { - if tenantArg.Tenant == "" { - return utils.NewErrMandatoryIeMissing(utils.Tenant) +func (apierV1 *ApierV1) GetSupplierProfileIDs(args utils.TenantArgWithPaginator, sppPrfIDs *[]string) error { + if missing := utils.MissingStructFields(&args, []string{utils.Tenant}); len(missing) != 0 { //Params missing + return utils.NewErrMandatoryIeMissing(missing...) } - prfx := utils.SupplierProfilePrefix + tenantArg.Tenant + ":" + prfx := utils.SupplierProfilePrefix + args.Tenant + ":" keys, err := apierV1.DataManager.DataDB().GetKeysForPrefix(prfx) if err != nil { return err @@ -55,7 +55,7 @@ func (apierV1 *ApierV1) GetSupplierProfileIDs(tenantArg *utils.TenantArg, sppPrf for i, key := range keys { retIDs[i] = key[len(prfx):] } - *sppPrfIDs = retIDs + *sppPrfIDs = args.PaginateStringSlice(retIDs) return nil } diff --git a/apier/v1/suppliers_it_test.go b/apier/v1/suppliers_it_test.go index def8edaaa..ad3f00fbc 100644 --- a/apier/v1/suppliers_it_test.go +++ b/apier/v1/suppliers_it_test.go @@ -778,7 +778,7 @@ func testV1SplSGetSupplierProfileIDs(t *testing.T) { expected := []string{"SPL_HIGHESTCOST_1", "SPL_QOS_1", "SPL_QOS_2", "SPL_QOS_FILTRED", "SPL_QOS_FILTRED2", "SPL_ACNT_1001", "SPL_LEASTCOST_1", "SPL_WEIGHT_2", "SPL_WEIGHT_1", "SPL_QOS_3", "TEST_PROFILE1", "SPL_LCR"} var result []string - if err := splSv1Rpc.Call("ApierV1.GetSupplierProfileIDs", "cgrates.org", &result); err != nil { + if err := splSv1Rpc.Call(utils.ApierV1GetSupplierProfileIDs, utils.TenantArgWithPaginator{TenantArg: utils.TenantArg{"cgrates.org"}}, &result); err != nil { t.Error(err) } else if len(expected) != len(result) { t.Errorf("Expecting : %+v, received: %+v", expected, result) diff --git a/console/supplier_ids.go b/console/supplier_ids.go index 4702169a1..08ade98c8 100644 --- a/console/supplier_ids.go +++ b/console/supplier_ids.go @@ -27,7 +27,7 @@ func init() { c := &CmdSuppliersIDs{ name: "supplier_ids", rpcMethod: utils.ApierV1GetSupplierProfileIDs, - rpcParams: &utils.TenantArg{}, + rpcParams: &utils.TenantArgWithPaginator{}, } commands[c.Name()] = c c.CommandExecuter = &CommandExecuter{c} @@ -36,7 +36,7 @@ func init() { type CmdSuppliersIDs struct { name string rpcMethod string - rpcParams *utils.TenantArg + rpcParams *utils.TenantArgWithPaginator *CommandExecuter } @@ -50,7 +50,7 @@ func (self *CmdSuppliersIDs) RpcMethod() string { func (self *CmdSuppliersIDs) RpcParams(reset bool) interface{} { if reset || self.rpcParams == nil { - self.rpcParams = &utils.TenantArg{} + self.rpcParams = &utils.TenantArgWithPaginator{} } return self.rpcParams }