diff --git a/apier/v1/suppliers.go b/apier/v1/suppliers.go index 883bb94b0..a04da8da2 100644 --- a/apier/v1/suppliers.go +++ b/apier/v1/suppliers.go @@ -39,8 +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(tenant string, sppPrfIDs *[]string) error { - prfx := utils.SupplierProfilePrefix + tenant + ":" +func (apierV1 *ApierV1) GetSupplierProfileIDs(tenantArg *utils.TenantArg, sppPrfIDs *[]string) error { + if tenantArg.Tenant == "" { + return utils.NewErrMandatoryIeMissing(utils.Tenant) + } + prfx := utils.SupplierProfilePrefix + tenantArg.Tenant + ":" keys, err := apierV1.DataManager.DataDB().GetKeysForPrefix(prfx) if err != nil { return err diff --git a/console/supplier_get.go b/console/supplier_get.go index c1c2942b7..e4c670680 100644 --- a/console/supplier_get.go +++ b/console/supplier_get.go @@ -26,7 +26,7 @@ import ( func init() { c := &CmdGetSupplier{ name: "supplier_get", - rpcMethod: "ApierV1.GetSupplierProfile", + rpcMethod: utils.ApierV1GetSupplierProfile, rpcParams: &utils.TenantID{}, } commands[c.Name()] = c diff --git a/console/supplier_ids.go b/console/supplier_ids.go new file mode 100644 index 000000000..4702169a1 --- /dev/null +++ b/console/supplier_ids.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/engine" + "github.com/cgrates/cgrates/utils" +) + +func init() { + c := &CmdSuppliersIDs{ + name: "supplier_ids", + rpcMethod: utils.ApierV1GetSupplierProfileIDs, + rpcParams: &utils.TenantArg{}, + } + commands[c.Name()] = c + c.CommandExecuter = &CommandExecuter{c} +} + +type CmdSuppliersIDs struct { + name string + rpcMethod string + rpcParams *utils.TenantArg + *CommandExecuter +} + +func (self *CmdSuppliersIDs) Name() string { + return self.name +} + +func (self *CmdSuppliersIDs) RpcMethod() string { + return self.rpcMethod +} + +func (self *CmdSuppliersIDs) RpcParams(reset bool) interface{} { + if reset || self.rpcParams == nil { + self.rpcParams = &utils.TenantArg{} + } + return self.rpcParams +} + +func (self *CmdSuppliersIDs) PostprocessRpcParams() error { + return nil +} + +func (self *CmdSuppliersIDs) RpcResult() interface{} { + var atr *engine.SortedSuppliers + return &atr +} diff --git a/console/supplier_remove.go b/console/supplier_remove.go index f8e3f3d2d..4ac2bd193 100644 --- a/console/supplier_remove.go +++ b/console/supplier_remove.go @@ -23,7 +23,7 @@ import "github.com/cgrates/cgrates/utils" func init() { c := &CmdRemoveSupplier{ name: "supplier_remove", - rpcMethod: "ApierV1.RemoveSupplierProfile", + rpcMethod: utils.ApierV1RemoveSupplierProfile, rpcParams: &utils.TenantIDWithCache{}, } commands[c.Name()] = c diff --git a/console/supplier_set.go b/console/supplier_set.go index 81b3ec16d..090e74a8d 100644 --- a/console/supplier_set.go +++ b/console/supplier_set.go @@ -18,12 +18,15 @@ along with this program. If not, see 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 := &CmdSetSupplier{ name: "supplier_set", - rpcMethod: "ApierV1.SetSupplierProfile", + rpcMethod: utils.ApierV1SetSupplierProfile, rpcParams: &v1.SupplierWithCache{}, } commands[c.Name()] = c diff --git a/utils/consts.go b/utils/consts.go index 64fbd4179..45d190db2 100755 --- a/utils/consts.go +++ b/utils/consts.go @@ -722,6 +722,10 @@ const ( ApierV1LoadTariffPlanFromFolder = "ApierV1.LoadTariffPlanFromFolder" ApierV1GetCost = "ApierV1.GetCost" ApierV1SetBalance = "ApierV1.SetBalance" + ApierV1GetSupplierProfile = "ApierV1.GetSupplierProfile" + ApierV1GetSupplierProfileIDs = "ApierV1.GetSupplierProfileIDs" + ApierV1RemoveSupplierProfile = "ApierV1.RemoveSupplierProfile" + ApierV1SetSupplierProfile = "ApierV1.SetSupplierProfile" ) const (