Updated GetDispatcherProfileIDs and GetDispatcherHostIDs

This commit is contained in:
Tripon Alexandru-Ionut
2019-04-17 16:39:37 +03:00
committed by Dan Christian Bogos
parent 35d675b840
commit 717a801648
4 changed files with 20 additions and 20 deletions

View File

@@ -42,9 +42,9 @@ func (apierV1 *ApierV1) GetDispatcherProfile(arg *utils.TenantID, reply *engine.
}
// GetDispatcherProfileIDs returns list of dispatcherProfile IDs registered for a tenant
func (apierV1 *ApierV1) GetDispatcherProfileIDs(tenantArg *utils.TenantArg, dPrfIDs *[]string) error {
if tenantArg.Tenant == "" {
return utils.NewErrMandatoryIeMissing(utils.Tenant)
func (apierV1 *ApierV1) GetDispatcherProfileIDs(tenantArg utils.TenantArgWithPaginator, dPrfIDs *[]string) error {
if missing := utils.MissingStructFields(&tenantArg, []string{utils.Tenant}); len(missing) != 0 { //Params missing
return utils.NewErrMandatoryIeMissing(missing...)
}
tenant := tenantArg.Tenant
prfx := utils.DispatcherProfilePrefix + tenant + ":"
@@ -59,7 +59,7 @@ func (apierV1 *ApierV1) GetDispatcherProfileIDs(tenantArg *utils.TenantArg, dPrf
for i, key := range keys {
retIDs[i] = key[len(prfx):]
}
*dPrfIDs = retIDs
*dPrfIDs = tenantArg.PaginateStringSlice(retIDs)
return nil
}
@@ -131,9 +131,9 @@ func (apierV1 *ApierV1) GetDispatcherHost(arg *utils.TenantID, reply *engine.Dis
}
// GetDispatcherHostIDs returns list of dispatcherHost IDs registered for a tenant
func (apierV1 *ApierV1) GetDispatcherHostIDs(tenantArg *utils.TenantArg, dPrfIDs *[]string) error {
if tenantArg.Tenant == "" {
return utils.NewErrMandatoryIeMissing(utils.Tenant)
func (apierV1 *ApierV1) GetDispatcherHostIDs(tenantArg utils.TenantArgWithPaginator, dPrfIDs *[]string) error {
if missing := utils.MissingStructFields(&tenantArg, []string{utils.Tenant}); len(missing) != 0 { //Params missing
return utils.NewErrMandatoryIeMissing(missing...)
}
tenant := tenantArg.Tenant
prfx := utils.DispatcherHostPrefix + tenant + ":"
@@ -148,7 +148,7 @@ func (apierV1 *ApierV1) GetDispatcherHostIDs(tenantArg *utils.TenantArg, dPrfIDs
for i, key := range keys {
retIDs[i] = key[len(prfx):]
}
*dPrfIDs = retIDs
*dPrfIDs = tenantArg.PaginateStringSlice(retIDs)
return nil
}

View File

@@ -157,13 +157,13 @@ func testDispatcherSSetDispatcherProfile(t *testing.T) {
func testDispatcherSGetDispatcherProfileIDs(t *testing.T) {
var result []string
if err := dispatcherRPC.Call("ApierV1.GetDispatcherProfileIDs",
utils.TenantArg{}, &result); err == nil {
if err := dispatcherRPC.Call(utils.ApierV1GetDispatcherProfileIDs,
utils.TenantArgWithPaginator{}, &result); err == nil {
t.Errorf("Expected: %s , received: %v", utils.NewErrMandatoryIeMissing(utils.Tenant).Error(), err)
}
expected := []string{"Dsp1"}
if err := dispatcherRPC.Call("ApierV1.GetDispatcherProfileIDs",
utils.TenantArg{Tenant: dispatcherProfile.Tenant}, &result); err != nil {
if err := dispatcherRPC.Call(utils.ApierV1GetDispatcherProfileIDs,
utils.TenantArgWithPaginator{TenantArg: utils.TenantArg{Tenant: dispatcherProfile.Tenant}}, &result); err != nil {
t.Error(err)
} else if len(result) != len(expected) {
t.Errorf("Expecting : %+v, received: %+v", expected, result)
@@ -277,13 +277,13 @@ func testDispatcherSSetDispatcherHost(t *testing.T) {
func testDispatcherSGetDispatcherHostIDs(t *testing.T) {
var result []string
if err := dispatcherRPC.Call("ApierV1.GetDispatcherHostIDs",
utils.TenantArg{}, &result); err == nil {
if err := dispatcherRPC.Call(utils.ApierV1GetDispatcherHostIDs,
utils.TenantArgWithPaginator{}, &result); err == nil {
t.Errorf("Expected: %s , received: %v", utils.NewErrMandatoryIeMissing(utils.Tenant), err)
}
expected := []string{"DspHst1"}
if err := dispatcherRPC.Call("ApierV1.GetDispatcherHostIDs",
utils.TenantArg{Tenant: dispatcherHost.Tenant}, &result); err != nil {
if err := dispatcherRPC.Call(utils.ApierV1GetDispatcherHostIDs,
utils.TenantArgWithPaginator{TenantArg: utils.TenantArg{Tenant: dispatcherHost.Tenant}}, &result); err != nil {
t.Error(err)
} else if len(result) != len(expected) {
t.Errorf("Expecting : %+v, received: %+v", expected, result)

View File

@@ -35,7 +35,7 @@ func init() {
type CmdGetDispatcherHostIDs struct {
name string
rpcMethod string
rpcParams *utils.TenantArg
rpcParams *utils.TenantArgWithPaginator
*CommandExecuter
}
@@ -49,7 +49,7 @@ func (self *CmdGetDispatcherHostIDs) RpcMethod() string {
func (self *CmdGetDispatcherHostIDs) RpcParams(reset bool) interface{} {
if reset || self.rpcParams == nil {
self.rpcParams = new(utils.TenantArg)
self.rpcParams = new(utils.TenantArgWithPaginator)
}
return self.rpcParams
}

View File

@@ -35,7 +35,7 @@ func init() {
type CmdGetDispatcherProfileIDs struct {
name string
rpcMethod string
rpcParams *utils.TenantArg
rpcParams *utils.TenantArgWithPaginator
*CommandExecuter
}
@@ -49,7 +49,7 @@ func (self *CmdGetDispatcherProfileIDs) RpcMethod() string {
func (self *CmdGetDispatcherProfileIDs) RpcParams(reset bool) interface{} {
if reset || self.rpcParams == nil {
self.rpcParams = new(utils.TenantArg)
self.rpcParams = new(utils.TenantArgWithPaginator)
}
return self.rpcParams
}