From 717a801648a2aeae352f54424ab175131d8a13ce Mon Sep 17 00:00:00 2001 From: Tripon Alexandru-Ionut Date: Wed, 17 Apr 2019 16:39:37 +0300 Subject: [PATCH] Updated GetDispatcherProfileIDs and GetDispatcherHostIDs --- apier/v1/dispatcher.go | 16 ++++++++-------- apier/v1/dispatcher_it_test.go | 16 ++++++++-------- console/dispatcher_host_ids.go | 4 ++-- console/dispatcherprofile_ids.go | 4 ++-- 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/apier/v1/dispatcher.go b/apier/v1/dispatcher.go index 338615e2e..cfd5ae1e3 100755 --- a/apier/v1/dispatcher.go +++ b/apier/v1/dispatcher.go @@ -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 } diff --git a/apier/v1/dispatcher_it_test.go b/apier/v1/dispatcher_it_test.go index 21e2bee39..1d7452ed2 100644 --- a/apier/v1/dispatcher_it_test.go +++ b/apier/v1/dispatcher_it_test.go @@ -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) diff --git a/console/dispatcher_host_ids.go b/console/dispatcher_host_ids.go index 6e4dc653c..ba7d849b3 100644 --- a/console/dispatcher_host_ids.go +++ b/console/dispatcher_host_ids.go @@ -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 } diff --git a/console/dispatcherprofile_ids.go b/console/dispatcherprofile_ids.go index da3153ec1..60ffc6165 100644 --- a/console/dispatcherprofile_ids.go +++ b/console/dispatcherprofile_ids.go @@ -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 }