From 804cc12c9e443ce19745f18b19799fdf93b99fee Mon Sep 17 00:00:00 2001 From: andronache Date: Thu, 18 Mar 2021 13:16:09 +0200 Subject: [PATCH] Changed in multiple structs the field Opts to APIOpts --- apier/v1/accountprofiles.go | 2 +- apier/v1/accountprofiles_it_test.go | 2 +- apier/v1/accounts.go | 10 ++-- apier/v1/accounts_it_test.go | 2 +- apier/v1/actions.go | 8 +-- apier/v1/actions_it_test.go | 8 +-- apier/v1/api_interfaces.go | 34 ++++++------ apier/v1/apier.go | 24 ++++----- apier/v1/apier_it_test.go | 2 +- apier/v1/attributes.go | 2 +- apier/v1/attributes_it_test.go | 18 +++---- apier/v1/caches.go | 14 ++--- apier/v1/caches_it_test.go | 8 +-- apier/v1/caps_it_test.go | 2 +- apier/v1/config_it_test.go | 4 +- apier/v1/core.go | 2 +- apier/v1/dispatcher.go | 34 ++++++------ apier/v1/filter_indexes_it_test.go | 8 +-- apier/v1/filterindexecache_it_test.go | 6 +-- apier/v1/full_remote_it_test.go | 6 +-- apier/v1/libapier.go | 22 ++++---- apier/v1/libapier_test.go | 20 +++---- apier/v1/rateprofiles.go | 2 +- apier/v1/rateprofiles_it_test.go | 4 +- apier/v1/remote_it_test.go | 4 +- apier/v1/replicate_it_test.go | 4 +- apier/v1/replicator.go | 24 ++++----- apier/v1/sessions.go | 6 +-- apier/v1/sessionsbirpc.go | 4 +- apier/v1/stats.go | 2 +- apier/v1/stats_it_test.go | 12 ++--- apier/v1/thresholds.go | 14 ++--- apier/v1/thresholds_it_test.go | 26 ++++----- apier/v1/triggers.go | 4 +- apier/v2/accounts.go | 2 +- apier/v2/apier.go | 2 +- apier/v2/cdrs_it_test.go | 2 +- apier/v2/cdrs_offline_it_test.go | 4 +- console/cache_has_item.go | 6 +-- console/cache_item_expiry_time.go | 6 +-- console/cache_item_ids.go | 6 +-- console/cache_reload.go | 6 +-- console/cache_remove_item.go | 6 +-- console/status.go | 6 +-- console/thresholds_profile_set.go | 8 +-- cores/core.go | 2 +- cores/core_test.go | 6 +-- dispatchers/caches.go | 54 +++++++++---------- dispatchers/caches_it_test.go | 32 +++++------ dispatchers/core.go | 6 +-- dispatchers/core_it_test.go | 8 +-- dispatchers/replicator.go | 32 +++++------ dispatchers/replicator_it_test.go | 16 +++--- dispatchers/responder.go | 6 +-- dispatchers/responder_it_test.go | 18 +++---- dispatchers/sessions.go | 12 ++--- dispatchers/sessions_it_test.go | 4 +- dispatchers/stats.go | 6 +-- dispatchers/stats_it_test.go | 4 +- dispatchers/thresholds.go | 6 +-- dispatchers/thresholds_it_test.go | 4 +- dispatchers/utils.go | 6 +-- engine/actionprofile.go | 7 +-- engine/caches.go | 20 +++---- engine/datamanager.go | 16 +++--- engine/libstats.go | 4 +- engine/responder.go | 2 +- engine/thresholds.go | 12 ++--- engine/tpreader.go | 12 ++--- engine/z_actions_it_test.go | 6 +-- general_tests/accountactions_it_test.go | 8 +-- general_tests/accounts_it_test.go | 2 +- general_tests/cacherpl_it_test.go | 22 ++++---- general_tests/cdrs_it_test.go | 2 +- general_tests/cdrs_processevent_it_test.go | 2 +- general_tests/export_it_test.go | 2 +- general_tests/filtered_replication_it_test.go | 4 +- general_tests/filters_it_test.go | 10 ++-- general_tests/redis_tls_it_test.go | 2 +- general_tests/rpccaching_it_test.go | 4 +- general_tests/rpcclient_it_test.go | 46 ++++++++-------- general_tests/twoengines_it_test.go | 8 +-- loaders/loader.go | 12 ++--- registrarc/registrarc_it_test.go | 6 +-- sessions/sessions.go | 4 +- sessions/sessions_rpl_it_test.go | 4 +- utils/apitpdata.go | 22 ++++---- utils/apitpdata_test.go | 2 +- utils/coreutils.go | 6 +-- 89 files changed, 434 insertions(+), 433 deletions(-) diff --git a/apier/v1/accountprofiles.go b/apier/v1/accountprofiles.go index 2b2a9c9db..a1db781ed 100644 --- a/apier/v1/accountprofiles.go +++ b/apier/v1/accountprofiles.go @@ -70,7 +70,7 @@ func (apierSv1 *APIerSv1) GetAccountProfileIDs(args *utils.PaginatorWithTenant, // GetAccountProfileIDsCount sets in reply var the total number of AccountProfileIDs registered for a tenant // returns ErrNotFound in case of 0 AccountProfileIDs -func (apierSv1 *APIerSv1) GetAccountProfileIDsCount(args *utils.TenantWithOpts, reply *int) (err error) { +func (apierSv1 *APIerSv1) GetAccountProfileIDsCount(args *utils.TenantWithAPIOpts, reply *int) (err error) { tnt := args.Tenant if tnt == utils.EmptyString { tnt = apierSv1.Config.GeneralCfg().DefaultTenant diff --git a/apier/v1/accountprofiles_it_test.go b/apier/v1/accountprofiles_it_test.go index 0ca549cba..471047192 100644 --- a/apier/v1/accountprofiles_it_test.go +++ b/apier/v1/accountprofiles_it_test.go @@ -319,7 +319,7 @@ func testAccountSGetAccountProfileIDs(t *testing.T) { func testAccountSGetAccountProfileIDsCount(t *testing.T) { var reply int if err := accSRPC.Call(utils.APIerSv1GetAccountProfileIDsCount, - &utils.TenantWithOpts{Tenant: "cgrates.org"}, &reply); err != nil { + &utils.TenantWithAPIOpts{Tenant: "cgrates.org"}, &reply); err != nil { t.Error(err) } else if reply != 3 { t.Errorf("Expecting: 3, received: %+v", reply) diff --git a/apier/v1/accounts.go b/apier/v1/accounts.go index c571446d9..da0449699 100644 --- a/apier/v1/accounts.go +++ b/apier/v1/accounts.go @@ -144,7 +144,7 @@ func (apierSv1 *APIerSv1) RemoveActionTiming(attrs *AttrRemoveActionTiming, repl return 0, err } if err := apierSv1.ConnMgr.Call(apierSv1.Config.ApierCfg().CachesConns, nil, - utils.CacheSv1ReloadCache, utils.AttrReloadCacheWithOpts{ + utils.CacheSv1ReloadCache, utils.AttrReloadCacheWithAPIOpts{ ArgsCache: map[string][]string{utils.ActionPlanIDs: {attrs.ActionPlanId}}, }, reply); err != nil { return 0, err @@ -156,7 +156,7 @@ func (apierSv1 *APIerSv1) RemoveActionTiming(attrs *AttrRemoveActionTiming, repl } if len(remAcntAPids) != 0 { if err := apierSv1.ConnMgr.Call(apierSv1.Config.ApierCfg().CachesConns, nil, - utils.CacheSv1ReloadCache, utils.AttrReloadCacheWithOpts{ + utils.CacheSv1ReloadCache, utils.AttrReloadCacheWithAPIOpts{ ArgsCache: map[string][]string{utils.AccountActionPlanIDs: remAcntAPids}, }, reply); err != nil { return 0, err @@ -258,7 +258,7 @@ func (apierSv1 *APIerSv1) SetAccount(attr *utils.AttrSetAccount, reply *string) return 0, err } if err := apierSv1.ConnMgr.Call(apierSv1.Config.ApierCfg().CachesConns, nil, - utils.CacheSv1ReloadCache, utils.AttrReloadCacheWithOpts{ + utils.CacheSv1ReloadCache, utils.AttrReloadCacheWithAPIOpts{ ArgsCache: map[string][]string{utils.AccountActionPlanIDs: {accID}, utils.ActionPlanIDs: apIDs}, }, reply); err != nil { return 0, err @@ -358,7 +358,7 @@ func (apierSv1 *APIerSv1) RemoveAccount(attr *utils.AttrRemoveAccount, reply *st return err } if err = apierSv1.ConnMgr.Call(apierSv1.Config.ApierCfg().CachesConns, nil, - utils.CacheSv1ReloadCache, utils.AttrReloadCacheWithOpts{ + utils.CacheSv1ReloadCache, utils.AttrReloadCacheWithAPIOpts{ ArgsCache: map[string][]string{utils.AccountActionPlanIDs: {accID}}, }, reply); err != nil { return @@ -724,7 +724,7 @@ func (apierSv1 *APIerSv1) RemoveBalances(attr *utils.AttrSetBalance, reply *stri return nil } -func (apierSv1 *APIerSv1) GetAccountsCount(attr *utils.TenantWithOpts, reply *int) (err error) { +func (apierSv1 *APIerSv1) GetAccountsCount(attr *utils.TenantWithAPIOpts, reply *int) (err error) { tnt := attr.Tenant if tnt == utils.EmptyString { tnt = apierSv1.Config.GeneralCfg().DefaultTenant diff --git a/apier/v1/accounts_it_test.go b/apier/v1/accounts_it_test.go index 65e2c0c25..c19c3ce60 100644 --- a/apier/v1/accounts_it_test.go +++ b/apier/v1/accounts_it_test.go @@ -655,7 +655,7 @@ func testAccITRemoveAccountWithoutTenant(t *testing.T) { func testAccITCountAccounts(t *testing.T) { var reply int - args := &utils.TenantWithOpts{ + args := &utils.TenantWithAPIOpts{ Tenant: "cgrates.org", } if err := accRPC.Call(utils.APIerSv1GetAccountsCount, &args, &reply); err != nil { diff --git a/apier/v1/actions.go b/apier/v1/actions.go index 9182e2edf..0e9c5dc24 100644 --- a/apier/v1/actions.go +++ b/apier/v1/actions.go @@ -71,7 +71,7 @@ func (apierSv1 *APIerSv1) GetActionProfileIDs(args *utils.PaginatorWithTenant, a // GetActionProfileIDsCount sets in reply var the total number of ActionProfileIDs registered for a tenant // returns ErrNotFound in case of 0 ActionProfileIDs -func (apierSv1 *APIerSv1) GetActionProfileIDsCount(args *utils.TenantWithOpts, reply *int) (err error) { +func (apierSv1 *APIerSv1) GetActionProfileIDsCount(args *utils.TenantWithAPIOpts, reply *int) (err error) { tnt := args.Tenant if tnt == utils.EmptyString { tnt = apierSv1.Config.GeneralCfg().DefaultTenant @@ -89,7 +89,7 @@ func (apierSv1 *APIerSv1) GetActionProfileIDsCount(args *utils.TenantWithOpts, r } //SetActionProfile add/update a new Action Profile -func (apierSv1 *APIerSv1) SetActionProfile(ap *engine.ActionProfileWithOpts, reply *string) error { +func (apierSv1 *APIerSv1) SetActionProfile(ap *engine.ActionProfileWithAPIOpts, reply *string) error { if missing := utils.MissingStructFields(ap.ActionProfile, []string{utils.ID, utils.Actions}); len(missing) != 0 { return utils.NewErrMandatoryIeMissing(missing...) } @@ -104,8 +104,8 @@ func (apierSv1 *APIerSv1) SetActionProfile(ap *engine.ActionProfileWithOpts, rep if err := apierSv1.DataManager.SetLoadIDs(map[string]int64{utils.CacheActionProfiles: time.Now().UnixNano()}); err != nil { return utils.APIErrorHandler(err) } - if err := apierSv1.CallCache(utils.IfaceAsString(ap.Opts[utils.CacheOpt]), ap.Tenant, utils.CacheActionProfiles, - ap.TenantID(), &ap.FilterIDs, nil, ap.Opts); err != nil { + if err := apierSv1.CallCache(utils.IfaceAsString(ap.APIOpts[utils.CacheOpt]), ap.Tenant, utils.CacheActionProfiles, + ap.TenantID(), &ap.FilterIDs, nil, ap.APIOpts); err != nil { return utils.APIErrorHandler(err) } *reply = utils.OK diff --git a/apier/v1/actions_it_test.go b/apier/v1/actions_it_test.go index 977043673..710656531 100644 --- a/apier/v1/actions_it_test.go +++ b/apier/v1/actions_it_test.go @@ -36,7 +36,7 @@ var ( actPrfCfgPath string actPrfCfg *config.CGRConfig actSRPC *rpc.Client - actPrf *engine.ActionProfileWithOpts + actPrf *engine.ActionProfileWithAPIOpts actPrfConfigDIR string //run tests for specific configuration sTestsActPrf = []func(t *testing.T){ @@ -216,7 +216,7 @@ func testActionSPing(t *testing.T) { } func testActionSSettActionProfile(t *testing.T) { - actPrf = &engine.ActionProfileWithOpts{ + actPrf = &engine.ActionProfileWithAPIOpts{ ActionProfile: &engine.ActionProfile{ Tenant: "tenant_test", ID: "id_test", @@ -231,7 +231,7 @@ func testActionSSettActionProfile(t *testing.T) { }, }, }, - Opts: map[string]interface{}{}, + APIOpts: map[string]interface{}{}, } var result string expErr := utils.ErrNotFound.Error() @@ -282,7 +282,7 @@ func testActionSGetActionProfileIDs(t *testing.T) { func testActionSGetActionProfileIDsCount(t *testing.T) { var reply int if err := actSRPC.Call(utils.APIerSv1GetActionProfileIDsCount, - &utils.TenantWithOpts{Tenant: "tenant_test"}, &reply); err != nil { + &utils.TenantWithAPIOpts{Tenant: "tenant_test"}, &reply); err != nil { t.Error(err) } else if reply != 1 { t.Errorf("Expecting: 1, received: %+v", reply) diff --git a/apier/v1/api_interfaces.go b/apier/v1/api_interfaces.go index 8b3476eb6..b8562ffc4 100644 --- a/apier/v1/api_interfaces.go +++ b/apier/v1/api_interfaces.go @@ -30,7 +30,7 @@ import ( ) type ThresholdSv1Interface interface { - GetThresholdIDs(tenant *utils.TenantWithOpts, tIDs *[]string) error + GetThresholdIDs(tenant *utils.TenantWithAPIOpts, tIDs *[]string) error GetThresholdsForEvent(args *engine.ThresholdsArgsProcessEvent, reply *engine.Thresholds) error GetThreshold(tntID *utils.TenantIDWithAPIOpts, t *engine.Threshold) error ProcessEvent(args *engine.ThresholdsArgsProcessEvent, tIDs *[]string) error @@ -38,7 +38,7 @@ type ThresholdSv1Interface interface { } type StatSv1Interface interface { - GetQueueIDs(tenant *utils.TenantWithOpts, qIDs *[]string) error + GetQueueIDs(tenant *utils.TenantWithAPIOpts, qIDs *[]string) error ProcessEvent(args *engine.StatsArgsProcessEvent, reply *[]string) error GetStatQueuesForEvent(args *engine.StatsArgsProcessEvent, reply *[]string) (err error) GetQueueStringMetrics(args *utils.TenantIDWithAPIOpts, reply *map[string]string) (err error) @@ -81,7 +81,7 @@ type SessionSv1Interface interface { InitiateSession(args *sessions.V1InitSessionArgs, rply *sessions.V1InitSessionReply) error InitiateSessionWithDigest(args *sessions.V1InitSessionArgs, rply *sessions.V1InitReplyWithDigest) error UpdateSession(args *sessions.V1UpdateSessionArgs, rply *sessions.V1UpdateSessionReply) error - SyncSessions(args *utils.TenantWithOpts, rply *string) error + SyncSessions(args *utils.TenantWithAPIOpts, rply *string) error TerminateSession(args *sessions.V1TerminateSessionArgs, rply *string) error ProcessCDR(cgrEv *utils.CGREvent, rply *string) error ProcessMessage(args *sessions.V1ProcessMessageArgs, rply *sessions.V1ProcessMessageReply) error @@ -93,7 +93,7 @@ type SessionSv1Interface interface { GetPassiveSessions(args *utils.SessionFilter, rply *[]*sessions.ExternalSession) error GetPassiveSessionsCount(args *utils.SessionFilter, rply *int) error Ping(ign *utils.CGREvent, reply *string) error - ReplicateSessions(args *dispatchers.ArgsReplicateSessionsWithOpts, rply *string) error + ReplicateSessions(args *dispatchers.ArgsReplicateSessionsWithAPIOpts, rply *string) error SetPassiveSession(args *sessions.Session, reply *string) error ActivateSessions(args *utils.SessionIDsWithArgsDispatcher, reply *string) error DeactivateSessions(args *utils.SessionIDsWithArgsDispatcher, reply *string) error @@ -109,24 +109,24 @@ type ResponderInterface interface { RefundIncrements(arg *engine.CallDescriptorWithAPIOpts, reply *engine.Account) (err error) RefundRounding(arg *engine.CallDescriptorWithAPIOpts, reply *float64) (err error) GetMaxSessionTime(arg *engine.CallDescriptorWithAPIOpts, reply *time.Duration) (err error) - Shutdown(arg *utils.TenantWithOpts, reply *string) (err error) + Shutdown(arg *utils.TenantWithAPIOpts, reply *string) (err error) Ping(ign *utils.CGREvent, reply *string) error } type CacheSv1Interface interface { - GetItemIDs(args *utils.ArgsGetCacheItemIDsWithOpts, reply *[]string) error - HasItem(args *utils.ArgsGetCacheItemWithOpts, reply *bool) error - GetItemExpiryTime(args *utils.ArgsGetCacheItemWithOpts, reply *time.Time) error - RemoveItem(args *utils.ArgsGetCacheItemWithOpts, reply *string) error - RemoveItems(args utils.AttrReloadCacheWithOpts, reply *string) error + GetItemIDs(args *utils.ArgsGetCacheItemIDsWithAPIOpts, reply *[]string) error + HasItem(args *utils.ArgsGetCacheItemWithAPIOpts, reply *bool) error + GetItemExpiryTime(args *utils.ArgsGetCacheItemWithAPIOpts, reply *time.Time) error + RemoveItem(args *utils.ArgsGetCacheItemWithAPIOpts, reply *string) error + RemoveItems(args utils.AttrReloadCacheWithAPIOpts, reply *string) error Clear(cacheIDs *utils.AttrCacheIDsWithOpts, reply *string) error GetCacheStats(cacheIDs *utils.AttrCacheIDsWithOpts, rply *map[string]*ltcache.CacheStats) error PrecacheStatus(cacheIDs *utils.AttrCacheIDsWithOpts, rply *map[string]string) error HasGroup(args *utils.ArgsGetGroupWithOpts, rply *bool) error GetGroupItemIDs(args *utils.ArgsGetGroupWithOpts, rply *[]string) error RemoveGroup(args *utils.ArgsGetGroupWithOpts, rply *string) error - ReloadCache(attrs *utils.AttrReloadCacheWithOpts, reply *string) error - LoadCache(args *utils.AttrReloadCacheWithOpts, reply *string) error + ReloadCache(attrs *utils.AttrReloadCacheWithAPIOpts, reply *string) error + LoadCache(args *utils.AttrReloadCacheWithAPIOpts, reply *string) error ReplicateSet(args *utils.ArgCacheReplicateSet, reply *string) (err error) ReplicateRemove(args *utils.ArgCacheReplicateRemove, reply *string) (err error) Ping(ign *utils.CGREvent, reply *string) error @@ -177,7 +177,7 @@ type ConfigSv1Interface interface { } type CoreSv1Interface interface { - Status(arg *utils.TenantWithOpts, reply *map[string]interface{}) error + Status(arg *utils.TenantWithAPIOpts, reply *map[string]interface{}) error Ping(ign *utils.CGREvent, reply *string) error Sleep(arg *utils.DurationArgs, reply *string) error } @@ -219,12 +219,12 @@ type ReplicatorSv1Interface interface { GetRateProfile(tntID *utils.TenantIDWithAPIOpts, reply *engine.RateProfile) error GetDispatcherHost(tntID *utils.TenantIDWithAPIOpts, reply *engine.DispatcherHost) error GetItemLoadIDs(itemID *utils.StringWithOpts, reply *map[string]int64) error - SetThresholdProfile(th *engine.ThresholdProfileWithOpts, reply *string) error - SetThreshold(th *engine.ThresholdWithOpts, reply *string) error + SetThresholdProfile(th *engine.ThresholdProfileWithAPIOpts, reply *string) error + SetThreshold(th *engine.ThresholdWithAPIOpts, reply *string) error SetAccount(acc *engine.AccountWithOpts, reply *string) error SetDestination(dst *engine.DestinationWithOpts, reply *string) error SetReverseDestination(dst *engine.DestinationWithOpts, reply *string) error - SetStatQueue(ssq *engine.StatQueueWithOpts, reply *string) error + SetStatQueue(ssq *engine.StatQueueWithAPIOpts, reply *string) error SetFilter(fltr *engine.FilterWithOpts, reply *string) error SetStatQueueProfile(sq *engine.StatQueueProfileWithOpts, reply *string) error SetTiming(tm *utils.TPTimingWithOpts, reply *string) error @@ -277,7 +277,7 @@ type ReplicatorSv1Interface interface { RemoveAccountProfile(args *utils.TenantIDWithAPIOpts, reply *string) error GetActionProfile(tntID *utils.TenantIDWithAPIOpts, reply *engine.ActionProfile) error - SetActionProfile(args *engine.ActionProfileWithOpts, reply *string) error + SetActionProfile(args *engine.ActionProfileWithAPIOpts, reply *string) error RemoveActionProfile(args *utils.TenantIDWithAPIOpts, reply *string) error } diff --git a/apier/v1/apier.go b/apier/v1/apier.go index a0bdcfdd3..6a2956441 100644 --- a/apier/v1/apier.go +++ b/apier/v1/apier.go @@ -100,7 +100,7 @@ func (apierSv1 *APIerSv1) RemoveDestination(attr *AttrRemoveDestination, reply * return } if err = apierSv1.ConnMgr.Call(apierSv1.Config.ApierCfg().CachesConns, nil, - utils.CacheSv1ReloadCache, utils.AttrReloadCacheWithOpts{ + utils.CacheSv1ReloadCache, utils.AttrReloadCacheWithAPIOpts{ ArgsCache: map[string][]string{utils.ReverseDestinationIDs: oldDst.Prefixes, utils.DestinationIDs: {dstID}}, }, reply); err != nil { @@ -113,7 +113,7 @@ func (apierSv1 *APIerSv1) RemoveDestination(attr *AttrRemoveDestination, reply * return } if err = apierSv1.ConnMgr.Call(apierSv1.Config.ApierCfg().CachesConns, nil, - utils.CacheSv1ReloadCache, utils.AttrReloadCacheWithOpts{ + utils.CacheSv1ReloadCache, utils.AttrReloadCacheWithAPIOpts{ ArgsCache: map[string][]string{utils.ReverseDestinationIDs: oldDst.Prefixes, utils.DestinationIDs: {dstID}}, }, reply); err != nil { @@ -186,7 +186,7 @@ func (apierSv1 *APIerSv1) SetDestination(attrs *utils.AttrSetDestination, reply return } if err := apierSv1.ConnMgr.Call(apierSv1.Config.ApierCfg().CachesConns, nil, - utils.CacheSv1ReloadCache, utils.AttrReloadCacheWithOpts{ + utils.CacheSv1ReloadCache, utils.AttrReloadCacheWithAPIOpts{ ArgsCache: map[string][]string{utils.ReverseDestinationIDs: dest.Prefixes, utils.DestinationIDs: {attrs.Id}}, }, reply); err != nil { @@ -217,7 +217,7 @@ func (apierSv1 *APIerSv1) RemoveRatingPlan(ID *string, reply *string) error { return utils.NewErrServerError(err) } if err := apierSv1.ConnMgr.Call(apierSv1.Config.ApierCfg().CachesConns, nil, - utils.CacheSv1ReloadCache, utils.AttrReloadCacheWithOpts{ + utils.CacheSv1ReloadCache, utils.AttrReloadCacheWithAPIOpts{ ArgsCache: map[string][]string{utils.RatingPlanIDs: {*ID}}, }, reply); err != nil { return err @@ -272,7 +272,7 @@ func (apierSv1 *APIerSv1) LoadDestination(attrs *AttrLoadDestination, reply *str return utils.ErrNotFound } if err := apierSv1.ConnMgr.Call(apierSv1.Config.ApierCfg().CachesConns, nil, - utils.CacheSv1ReloadCache, utils.AttrReloadCacheWithOpts{ + utils.CacheSv1ReloadCache, utils.AttrReloadCacheWithAPIOpts{ ArgsCache: map[string][]string{utils.DestinationIDs: {attrs.ID}}, }, reply); err != nil { return err @@ -496,7 +496,7 @@ func (apierSv1 *APIerSv1) SetRatingProfile(attrs *utils.AttrSetRatingProfile, re } //CacheReload if err := apierSv1.ConnMgr.Call(apierSv1.Config.ApierCfg().CachesConns, nil, - utils.CacheSv1ReloadCache, utils.AttrReloadCacheWithOpts{ + utils.CacheSv1ReloadCache, utils.AttrReloadCacheWithAPIOpts{ ArgsCache: map[string][]string{utils.RatingProfileIDs: {rpfl.Id}}, }, reply); err != nil { return err @@ -647,7 +647,7 @@ func (apierSv1 *APIerSv1) SetActions(attrs *V1AttrSetActions, reply *string) (er } //CacheReload if err := apierSv1.ConnMgr.Call(apierSv1.Config.ApierCfg().CachesConns, nil, - utils.CacheSv1ReloadCache, utils.AttrReloadCacheWithOpts{ + utils.CacheSv1ReloadCache, utils.AttrReloadCacheWithAPIOpts{ ArgsCache: map[string][]string{utils.ActionIDs: {attrs.ActionsId}}, }, reply); err != nil { return err @@ -794,7 +794,7 @@ func (apierSv1 *APIerSv1) SetActionPlan(attrs *AttrSetActionPlan, reply *string) return 0, utils.NewErrServerError(err) } if err := apierSv1.ConnMgr.Call(apierSv1.Config.ApierCfg().CachesConns, nil, - utils.CacheSv1ReloadCache, utils.AttrReloadCacheWithOpts{ + utils.CacheSv1ReloadCache, utils.AttrReloadCacheWithAPIOpts{ ArgsCache: map[string][]string{utils.ActionPlanIDs: {ap.Id}}, }, reply); err != nil { return 0, err @@ -807,7 +807,7 @@ func (apierSv1 *APIerSv1) SetActionPlan(attrs *AttrSetActionPlan, reply *string) if len(prevAccountIDs) != 0 { sl := prevAccountIDs.Slice() if err := apierSv1.ConnMgr.Call(apierSv1.Config.ApierCfg().CachesConns, nil, - utils.CacheSv1ReloadCache, utils.AttrReloadCacheWithOpts{ + utils.CacheSv1ReloadCache, utils.AttrReloadCacheWithAPIOpts{ ArgsCache: map[string][]string{utils.AccountActionPlanIDs: sl}, }, reply); err != nil { return 0, err @@ -993,7 +993,7 @@ func (apierSv1 *APIerSv1) RemoveActionPlan(attr *AttrGetActionPlan, reply *strin if len(prevAccountIDs) != 0 { sl := prevAccountIDs.Slice() if err := apierSv1.ConnMgr.Call(apierSv1.Config.ApierCfg().CachesConns, nil, - utils.CacheSv1ReloadCache, utils.AttrReloadCacheWithOpts{ + utils.CacheSv1ReloadCache, utils.AttrReloadCacheWithAPIOpts{ ArgsCache: map[string][]string{utils.AccountActionPlanIDs: sl}, }, reply); err != nil { return 0, err @@ -1258,7 +1258,7 @@ func (apierSv1 *APIerSv1) RemoveRatingProfile(attr *AttrRemoveRatingProfile, rep return utils.NewErrServerError(err) } if err := apierSv1.ConnMgr.Call(apierSv1.Config.ApierCfg().CachesConns, nil, - utils.CacheSv1ReloadCache, utils.AttrReloadCacheWithOpts{ + utils.CacheSv1ReloadCache, utils.AttrReloadCacheWithAPIOpts{ ArgsCache: map[string][]string{utils.RatingProfileIDs: {attr.GetId()}}, }, reply); err != nil { return err @@ -1355,7 +1355,7 @@ func (apierSv1 *APIerSv1) RemoveActions(attr *AttrRemoveActions, reply *string) } //CacheReload if err := apierSv1.ConnMgr.Call(apierSv1.Config.ApierCfg().CachesConns, nil, - utils.CacheSv1ReloadCache, utils.AttrReloadCacheWithOpts{ + utils.CacheSv1ReloadCache, utils.AttrReloadCacheWithAPIOpts{ ArgsCache: map[string][]string{utils.ActionIDs: attr.ActionIDs}, }, reply); err != nil { return err diff --git a/apier/v1/apier_it_test.go b/apier/v1/apier_it_test.go index 6ee4737d9..31e5fb24c 100644 --- a/apier/v1/apier_it_test.go +++ b/apier/v1/apier_it_test.go @@ -1065,7 +1065,7 @@ func testApierGetActionTrigger(t *testing.T) { // Test here ReloadCache func testApierReloadCache(t *testing.T) { var reply string - arc := new(utils.AttrReloadCacheWithOpts) + arc := new(utils.AttrReloadCacheWithAPIOpts) // Simple test that command is executed without errors if err := rater.Call(utils.CacheSv1ReloadCache, arc, &reply); err != nil { t.Error("Got error on CacheSv1.ReloadCache: ", err.Error()) diff --git a/apier/v1/attributes.go b/apier/v1/attributes.go index 01d98dfbe..539f58947 100644 --- a/apier/v1/attributes.go +++ b/apier/v1/attributes.go @@ -69,7 +69,7 @@ func (apierSv1 *APIerSv1) GetAttributeProfileIDs(args *utils.PaginatorWithTenant // GetAttributeProfileIDsCount sets in reply var the total number of AttributeProfileIDs registered for a tenant // returns ErrNotFound in case of 0 AttributeProfileIDs -func (apierSv1 *APIerSv1) GetAttributeProfileIDsCount(args *utils.TenantWithOpts, reply *int) (err error) { +func (apierSv1 *APIerSv1) GetAttributeProfileIDsCount(args *utils.TenantWithAPIOpts, reply *int) (err error) { tnt := args.Tenant if tnt == utils.EmptyString { tnt = apierSv1.Config.GeneralCfg().DefaultTenant diff --git a/apier/v1/attributes_it_test.go b/apier/v1/attributes_it_test.go index 8ab7d2579..c3aa3aedd 100644 --- a/apier/v1/attributes_it_test.go +++ b/apier/v1/attributes_it_test.go @@ -1270,13 +1270,13 @@ func testAttributeSProcessWithMultipleRuns2(t *testing.T) { func testAttributeSGetAttributeProfileIDsCount(t *testing.T) { var reply int if err := attrSRPC.Call(utils.APIerSv1GetAttributeProfileIDsCount, - &utils.TenantWithOpts{}, &reply); err != nil { + &utils.TenantWithAPIOpts{}, &reply); err != nil { t.Error(err) } else if reply != 7 { t.Errorf("Expecting: 7, received: %+v", reply) } if err := attrSRPC.Call(utils.APIerSv1GetAttributeProfileIDsCount, - &utils.TenantWithOpts{Tenant: "cgrates.org"}, &reply); err != nil { + &utils.TenantWithAPIOpts{Tenant: "cgrates.org"}, &reply); err != nil { t.Error(err) } else if reply != 7 { t.Errorf("Expecting: 7, received: %+v", reply) @@ -1295,7 +1295,7 @@ func testAttributeSGetAttributeProfileIDsCount(t *testing.T) { t.Error("Unexpected reply returned", resp) } if err := attrSRPC.Call(utils.APIerSv1GetAttributeProfileIDsCount, - &utils.TenantWithOpts{Tenant: "cgrates.org"}, &reply); err != nil { + &utils.TenantWithAPIOpts{Tenant: "cgrates.org"}, &reply); err != nil { t.Error(err) } else if reply != 6 { t.Errorf("Expecting: 6, received: %+v", reply) @@ -1313,7 +1313,7 @@ func testAttributeSGetAttributeProfileIDsCount(t *testing.T) { t.Error("Unexpected reply returned", resp) } if err := attrSRPC.Call(utils.APIerSv1GetAttributeProfileIDsCount, - &utils.TenantWithOpts{Tenant: "cgrates.org"}, &reply); err != nil { + &utils.TenantWithAPIOpts{Tenant: "cgrates.org"}, &reply); err != nil { t.Error(err) } else if reply != 5 { t.Errorf("Expecting: 5, received: %+v", reply) @@ -1331,7 +1331,7 @@ func testAttributeSGetAttributeProfileIDsCount(t *testing.T) { t.Error("Unexpected reply returned", resp) } if err := attrSRPC.Call(utils.APIerSv1GetAttributeProfileIDsCount, - &utils.TenantWithOpts{Tenant: "cgrates.org"}, &reply); err != nil { + &utils.TenantWithAPIOpts{Tenant: "cgrates.org"}, &reply); err != nil { t.Error(err) } else if reply != 4 { t.Errorf("Expecting: 4, received: %+v", reply) @@ -1349,7 +1349,7 @@ func testAttributeSGetAttributeProfileIDsCount(t *testing.T) { t.Error("Unexpected reply returned", resp) } if err := attrSRPC.Call(utils.APIerSv1GetAttributeProfileIDsCount, - &utils.TenantWithOpts{Tenant: "cgrates.org"}, &reply); err != nil { + &utils.TenantWithAPIOpts{Tenant: "cgrates.org"}, &reply); err != nil { t.Error(err) } else if reply != 3 { t.Errorf("Expecting: 3, received: %+v", reply) @@ -1367,7 +1367,7 @@ func testAttributeSGetAttributeProfileIDsCount(t *testing.T) { t.Error("Unexpected reply returned", resp) } if err := attrSRPC.Call(utils.APIerSv1GetAttributeProfileIDsCount, - &utils.TenantWithOpts{Tenant: "cgrates.org"}, &reply); err != nil { + &utils.TenantWithAPIOpts{Tenant: "cgrates.org"}, &reply); err != nil { t.Error(err) } else if reply != 2 { t.Errorf("Expecting: 2, received: %+v", reply) @@ -1386,7 +1386,7 @@ func testAttributeSGetAttributeProfileIDsCount(t *testing.T) { t.Error("Unexpected reply returned", resp) } if err := attrSRPC.Call(utils.APIerSv1GetAttributeProfileIDsCount, - &utils.TenantWithOpts{Tenant: "cgrates.org"}, &reply); err != nil { + &utils.TenantWithAPIOpts{Tenant: "cgrates.org"}, &reply); err != nil { t.Error(err) } else if reply != 1 { t.Errorf("Expecting: 1, received: %+v", reply) @@ -1405,7 +1405,7 @@ func testAttributeSGetAttributeProfileIDsCount(t *testing.T) { t.Error("Unexpected reply returned", resp) } if err := attrSRPC.Call(utils.APIerSv1GetAttributeProfileIDsCount, - &utils.TenantWithOpts{Tenant: "cgrates.org"}, &reply); err == nil || err.Error() != utils.ErrNotFound.Error() { + &utils.TenantWithAPIOpts{Tenant: "cgrates.org"}, &reply); err == nil || err.Error() != utils.ErrNotFound.Error() { t.Error(err) } } diff --git a/apier/v1/caches.go b/apier/v1/caches.go index 27d66f3c9..a8c4981ad 100644 --- a/apier/v1/caches.go +++ b/apier/v1/caches.go @@ -36,31 +36,31 @@ type CacheSv1 struct { } // GetItemIDs returns the IDs for cacheID with given prefix -func (chSv1 *CacheSv1) GetItemIDs(args *utils.ArgsGetCacheItemIDsWithOpts, +func (chSv1 *CacheSv1) GetItemIDs(args *utils.ArgsGetCacheItemIDsWithAPIOpts, reply *[]string) error { return chSv1.cacheS.V1GetItemIDs(args, reply) } // HasItem verifies the existence of an Item in cache -func (chSv1 *CacheSv1) HasItem(args *utils.ArgsGetCacheItemWithOpts, +func (chSv1 *CacheSv1) HasItem(args *utils.ArgsGetCacheItemWithAPIOpts, reply *bool) error { return chSv1.cacheS.V1HasItem(args, reply) } // GetItemExpiryTime returns the expiryTime for an item -func (chSv1 *CacheSv1) GetItemExpiryTime(args *utils.ArgsGetCacheItemWithOpts, +func (chSv1 *CacheSv1) GetItemExpiryTime(args *utils.ArgsGetCacheItemWithAPIOpts, reply *time.Time) error { return chSv1.cacheS.V1GetItemExpiryTime(args, reply) } // RemoveItem removes the Item with ID from cache -func (chSv1 *CacheSv1) RemoveItem(args *utils.ArgsGetCacheItemWithOpts, +func (chSv1 *CacheSv1) RemoveItem(args *utils.ArgsGetCacheItemWithAPIOpts, reply *string) error { return chSv1.cacheS.V1RemoveItem(args, reply) } // RemoveItems removes the Items with ID from cache -func (chSv1 *CacheSv1) RemoveItems(args utils.AttrReloadCacheWithOpts, +func (chSv1 *CacheSv1) RemoveItems(args utils.AttrReloadCacheWithAPIOpts, reply *string) error { return chSv1.cacheS.V1RemoveItems(args, reply) } @@ -101,12 +101,12 @@ func (chSv1 *CacheSv1) RemoveGroup(args *utils.ArgsGetGroupWithOpts, } // ReloadCache reloads cache from DB for a prefix or completely -func (chSv1 *CacheSv1) ReloadCache(args *utils.AttrReloadCacheWithOpts, reply *string) (err error) { +func (chSv1 *CacheSv1) ReloadCache(args *utils.AttrReloadCacheWithAPIOpts, reply *string) (err error) { return chSv1.cacheS.V1ReloadCache(*args, reply) } // LoadCache loads cache from DB for a prefix or completely -func (chSv1 *CacheSv1) LoadCache(args *utils.AttrReloadCacheWithOpts, reply *string) (err error) { +func (chSv1 *CacheSv1) LoadCache(args *utils.AttrReloadCacheWithAPIOpts, reply *string) (err error) { return chSv1.cacheS.V1LoadCache(*args, reply) } diff --git a/apier/v1/caches_it_test.go b/apier/v1/caches_it_test.go index 659b7dd62..159014a88 100644 --- a/apier/v1/caches_it_test.go +++ b/apier/v1/caches_it_test.go @@ -326,7 +326,7 @@ func testCacheSGetItemExpiryTime(t *testing.T) { func testCacheSReloadCache(t *testing.T) { var reply string - if err := chcRPC.Call(utils.CacheSv1ReloadCache, new(utils.AttrReloadCacheWithOpts), &reply); err != nil { + if err := chcRPC.Call(utils.CacheSv1ReloadCache, new(utils.AttrReloadCacheWithAPIOpts), &reply); err != nil { t.Error("Got error on CacheSv1.ReloadCache: ", err.Error()) } else if reply != utils.OK { t.Error("Calling CacheSv1.ReloadCache got reply: ", reply) @@ -391,9 +391,9 @@ func testCacheSRemoveItems(t *testing.T) { t.Errorf("Expected: %v , received:%v", true, reply) } var remReply string - if err := chcRPC.Call(utils.CacheSv1RemoveItems, utils.AttrReloadCacheWithOpts{ - Opts: make(map[string]interface{}), - Tenant: "cgrates.org", + if err := chcRPC.Call(utils.CacheSv1RemoveItems, utils.AttrReloadCacheWithAPIOpts{ + APIOpts: make(map[string]interface{}), + Tenant: "cgrates.org", ArgsCache: map[string][]string{ utils.StatsQueueProfileIDs: {"cgrates.org:Stats1"}, utils.RouteProfileIDs: {"cgrates.org:ROUTE_1"}, diff --git a/apier/v1/caps_it_test.go b/apier/v1/caps_it_test.go index 75a64beec..38cdaa162 100644 --- a/apier/v1/caps_it_test.go +++ b/apier/v1/caps_it_test.go @@ -302,7 +302,7 @@ func benchmarkInit(b *testing.B, cfgDir string) { func benchmarkCall(b *testing.B) { var rply map[string]interface{} for i := 0; i < b.N; i++ { - if err := capsRPC.Call(utils.CoreSv1Status, &utils.TenantWithOpts{}, &rply); err != nil { + if err := capsRPC.Call(utils.CoreSv1Status, &utils.TenantWithAPIOpts{}, &rply); err != nil { b.Error(err) } } diff --git a/apier/v1/config_it_test.go b/apier/v1/config_it_test.go index 252b057b9..31e02396e 100644 --- a/apier/v1/config_it_test.go +++ b/apier/v1/config_it_test.go @@ -426,7 +426,7 @@ func testConfigStartEngineWithConfigs(t *testing.T) { t.Fatal(err) } var rply map[string]interface{} - if err := configRPC.Call(utils.CoreSv1Status, &utils.TenantWithOpts{}, &rply); err != nil { + if err := configRPC.Call(utils.CoreSv1Status, &utils.TenantWithAPIOpts{}, &rply); err != nil { t.Error(err) } else if rply[utils.NodeID] != "EngineWithConfigSActive" { t.Errorf("Expected %+v , received: %+v ", "EngineWithConfigSActive", rply) @@ -460,7 +460,7 @@ func testConfigStartEngineFromHTTP(t *testing.T) { } time.Sleep(100 * time.Millisecond) var rply map[string]interface{} - if err := jsonClnt.Call(utils.CoreSv1Status, &utils.TenantWithOpts{}, &rply); err != nil { + if err := jsonClnt.Call(utils.CoreSv1Status, &utils.TenantWithAPIOpts{}, &rply); err != nil { t.Error(err) } } diff --git a/apier/v1/core.go b/apier/v1/core.go index f4993e381..1c5f280ad 100644 --- a/apier/v1/core.go +++ b/apier/v1/core.go @@ -40,7 +40,7 @@ func (cS *CoreSv1) Call(serviceMethod string, return utils.APIerRPCCall(cS, serviceMethod, args, reply) } -func (cS *CoreSv1) Status(arg *utils.TenantWithOpts, reply *map[string]interface{}) error { +func (cS *CoreSv1) Status(arg *utils.TenantWithAPIOpts, reply *map[string]interface{}) error { return cS.cS.Status(arg, reply) } diff --git a/apier/v1/dispatcher.go b/apier/v1/dispatcher.go index 59f26d3c9..744857f6a 100755 --- a/apier/v1/dispatcher.go +++ b/apier/v1/dispatcher.go @@ -238,7 +238,7 @@ func (dT *DispatcherThresholdSv1) ProcessEvent(args *engine.ThresholdsArgsProces return dT.dS.ThresholdSv1ProcessEvent(args, tIDs) } -func (dT *DispatcherThresholdSv1) GetThresholdIDs(args *utils.TenantWithOpts, +func (dT *DispatcherThresholdSv1) GetThresholdIDs(args *utils.TenantWithAPIOpts, tIDs *[]string) error { return dT.dS.ThresholdSv1GetThresholdIDs(args, tIDs) } @@ -278,7 +278,7 @@ func (dSts *DispatcherStatSv1) GetQueueFloatMetrics(args *utils.TenantIDWithAPIO return dSts.dS.StatSv1GetQueueFloatMetrics(args, reply) } -func (dSts *DispatcherStatSv1) GetQueueIDs(args *utils.TenantWithOpts, +func (dSts *DispatcherStatSv1) GetQueueIDs(args *utils.TenantWithAPIOpts, reply *[]string) error { return dSts.dS.StatSv1GetQueueIDs(args, reply) } @@ -510,7 +510,7 @@ func (dS *DispatcherSessionSv1) GetPassiveSessionsCount(args *utils.SessionFilte return dS.dS.SessionSv1GetPassiveSessionsCount(args, reply) } -func (dS *DispatcherSessionSv1) ReplicateSessions(args *dispatchers.ArgsReplicateSessionsWithOpts, +func (dS *DispatcherSessionSv1) ReplicateSessions(args *dispatchers.ArgsReplicateSessionsWithAPIOpts, reply *string) (err error) { return dS.dS.SessionSv1ReplicateSessions(*args, reply) } @@ -528,7 +528,7 @@ func (dS *DispatcherSessionSv1) DeactivateSessions(args *utils.SessionIDsWithArg return dS.dS.SessionSv1DeactivateSessions(args, reply) } -func (dS *DispatcherSessionSv1) SyncSessions(args *utils.TenantWithOpts, rply *string) error { +func (dS *DispatcherSessionSv1) SyncSessions(args *utils.TenantWithAPIOpts, rply *string) error { return dS.dS.SessionSv1SyncSessions(args, rply) } @@ -572,7 +572,7 @@ func (dS *DispatcherResponder) GetMaxSessionTime(args *engine.CallDescriptorWith return dS.dS.ResponderGetMaxSessionTime(args, reply) } -func (dS *DispatcherResponder) Shutdown(args *utils.TenantWithOpts, reply *string) error { +func (dS *DispatcherResponder) Shutdown(args *utils.TenantWithAPIOpts, reply *string) error { return dS.dS.ResponderShutdown(args, reply) } @@ -591,31 +591,31 @@ type DispatcherCacheSv1 struct { } // GetItemIDs returns the IDs for cacheID with given prefix -func (dS *DispatcherCacheSv1) GetItemIDs(args *utils.ArgsGetCacheItemIDsWithOpts, +func (dS *DispatcherCacheSv1) GetItemIDs(args *utils.ArgsGetCacheItemIDsWithAPIOpts, reply *[]string) error { return dS.dS.CacheSv1GetItemIDs(args, reply) } // HasItem verifies the existence of an Item in cache -func (dS *DispatcherCacheSv1) HasItem(args *utils.ArgsGetCacheItemWithOpts, +func (dS *DispatcherCacheSv1) HasItem(args *utils.ArgsGetCacheItemWithAPIOpts, reply *bool) error { return dS.dS.CacheSv1HasItem(args, reply) } // GetItemExpiryTime returns the expiryTime for an item -func (dS *DispatcherCacheSv1) GetItemExpiryTime(args *utils.ArgsGetCacheItemWithOpts, +func (dS *DispatcherCacheSv1) GetItemExpiryTime(args *utils.ArgsGetCacheItemWithAPIOpts, reply *time.Time) error { return dS.dS.CacheSv1GetItemExpiryTime(args, reply) } // RemoveItem removes the Item with ID from cache -func (dS *DispatcherCacheSv1) RemoveItem(args *utils.ArgsGetCacheItemWithOpts, +func (dS *DispatcherCacheSv1) RemoveItem(args *utils.ArgsGetCacheItemWithAPIOpts, reply *string) error { return dS.dS.CacheSv1RemoveItem(args, reply) } // RemoveItems removes the Item with ID from cache -func (dS *DispatcherCacheSv1) RemoveItems(args utils.AttrReloadCacheWithOpts, +func (dS *DispatcherCacheSv1) RemoveItems(args utils.AttrReloadCacheWithAPIOpts, reply *string) error { return dS.dS.CacheSv1RemoveItems(args, reply) } @@ -656,12 +656,12 @@ func (dS *DispatcherCacheSv1) RemoveGroup(args *utils.ArgsGetGroupWithOpts, } // ReloadCache reloads cache from DB for a prefix or completely -func (dS *DispatcherCacheSv1) ReloadCache(args *utils.AttrReloadCacheWithOpts, reply *string) (err error) { +func (dS *DispatcherCacheSv1) ReloadCache(args *utils.AttrReloadCacheWithAPIOpts, reply *string) (err error) { return dS.dS.CacheSv1ReloadCache(*args, reply) } // LoadCache loads cache from DB for a prefix or completely -func (dS *DispatcherCacheSv1) LoadCache(args *utils.AttrReloadCacheWithOpts, reply *string) (err error) { +func (dS *DispatcherCacheSv1) LoadCache(args *utils.AttrReloadCacheWithAPIOpts, reply *string) (err error) { return dS.dS.CacheSv1LoadCache(*args, reply) } @@ -860,7 +860,7 @@ type DispatcherCoreSv1 struct { dS *dispatchers.DispatcherService } -func (dS *DispatcherCoreSv1) Status(args *utils.TenantWithOpts, reply *map[string]interface{}) error { +func (dS *DispatcherCoreSv1) Status(args *utils.TenantWithAPIOpts, reply *map[string]interface{}) error { return dS.dS.CoreSv1Status(args, reply) } @@ -1037,12 +1037,12 @@ func (dS *DispatcherReplicatorSv1) GetItemLoadIDs(itemID *utils.StringWithOpts, //finished all the above // SetThresholdProfile -func (dS *DispatcherReplicatorSv1) SetThresholdProfile(args *engine.ThresholdProfileWithOpts, reply *string) error { +func (dS *DispatcherReplicatorSv1) SetThresholdProfile(args *engine.ThresholdProfileWithAPIOpts, reply *string) error { return dS.dS.ReplicatorSv1SetThresholdProfile(args, reply) } // SetThreshold -func (dS *DispatcherReplicatorSv1) SetThreshold(args *engine.ThresholdWithOpts, reply *string) error { +func (dS *DispatcherReplicatorSv1) SetThreshold(args *engine.ThresholdWithAPIOpts, reply *string) error { return dS.dS.ReplicatorSv1SetThreshold(args, reply) } @@ -1062,7 +1062,7 @@ func (dS *DispatcherReplicatorSv1) SetReverseDestination(args *engine.Destinatio } // SetStatQueue -func (dS *DispatcherReplicatorSv1) SetStatQueue(args *engine.StatQueueWithOpts, reply *string) error { +func (dS *DispatcherReplicatorSv1) SetStatQueue(args *engine.StatQueueWithAPIOpts, reply *string) error { return dS.dS.ReplicatorSv1SetStatQueue(args, reply) } @@ -1312,7 +1312,7 @@ func (dS *DispatcherReplicatorSv1) GetActionProfile(tntID *utils.TenantIDWithAPI } // SetActionProfile . -func (dS *DispatcherReplicatorSv1) SetActionProfile(args *engine.ActionProfileWithOpts, reply *string) error { +func (dS *DispatcherReplicatorSv1) SetActionProfile(args *engine.ActionProfileWithAPIOpts, reply *string) error { return dS.dS.ReplicatorSv1SetActionProfile(args, reply) } diff --git a/apier/v1/filter_indexes_it_test.go b/apier/v1/filter_indexes_it_test.go index a19bf0d79..752d614c7 100644 --- a/apier/v1/filter_indexes_it_test.go +++ b/apier/v1/filter_indexes_it_test.go @@ -216,7 +216,7 @@ func testV1FIdxSetThresholdProfile(t *testing.T) { err.Error() != utils.ErrNotFound.Error() { t.Error(err) } - tPrfl = &engine.ThresholdProfileWithOpts{ + tPrfl = &engine.ThresholdProfileWithAPIOpts{ ThresholdProfile: &engine.ThresholdProfile{ Tenant: tenant, ID: "TEST_PROFILE1", @@ -312,7 +312,7 @@ func testV1FIdxSetSecondThresholdProfile(t *testing.T) { err.Error() != utils.ErrNotFound.Error() { t.Error(err) } - tPrfl = &engine.ThresholdProfileWithOpts{ + tPrfl = &engine.ThresholdProfileWithAPIOpts{ ThresholdProfile: &engine.ThresholdProfile{ Tenant: tenant, ID: "TEST_PROFILE2", @@ -1468,7 +1468,7 @@ func testV1FISetActionProfileIndexes(t *testing.T) { } //set an actPrf in db, so we will get it without any problems - actPrf := &engine.ActionProfileWithOpts{ + actPrf := &engine.ActionProfileWithAPIOpts{ ActionProfile: &engine.ActionProfile{ Tenant: tenant, ID: "ACT_PRF", @@ -1625,7 +1625,7 @@ func testVF1SetSecondActionProfile(t *testing.T) { } //set the second actPrf in db with our filter - actPrf := &engine.ActionProfileWithOpts{ + actPrf := &engine.ActionProfileWithAPIOpts{ ActionProfile: &engine.ActionProfile{ Tenant: tenant, ID: "ACT_PRF2", diff --git a/apier/v1/filterindexecache_it_test.go b/apier/v1/filterindexecache_it_test.go index 51adab858..a2bd14e8f 100644 --- a/apier/v1/filterindexecache_it_test.go +++ b/apier/v1/filterindexecache_it_test.go @@ -190,7 +190,7 @@ func testV1FIdxCaSetThresholdProfile(t *testing.T) { } else if result != utils.OK { t.Error("Unexpected reply returned", result) } - tPrfl = &engine.ThresholdProfileWithOpts{ + tPrfl = &engine.ThresholdProfileWithAPIOpts{ ThresholdProfile: &engine.ThresholdProfile{ Tenant: "cgrates.org", ID: "TEST_PROFILE1", @@ -295,7 +295,7 @@ func testV1FIdxCaUpdateThresholdProfile(t *testing.T) { } else if result != utils.OK { t.Error("Unexpected reply returned", result) } - tPrfl = &engine.ThresholdProfileWithOpts{ + tPrfl = &engine.ThresholdProfileWithAPIOpts{ ThresholdProfile: &engine.ThresholdProfile{ Tenant: "cgrates.org", ID: "TEST_PROFILE1", @@ -402,7 +402,7 @@ func testV1FIdxCaUpdateThresholdProfileFromTP(t *testing.T) { } reply.FilterIDs = []string{"TestFilter3"} - if err := tFIdxCaRpc.Call(utils.APIerSv1SetThresholdProfile, &engine.ThresholdProfileWithOpts{ThresholdProfile: reply}, &result); err != nil { + if err := tFIdxCaRpc.Call(utils.APIerSv1SetThresholdProfile, &engine.ThresholdProfileWithAPIOpts{ThresholdProfile: reply}, &result); err != nil { t.Error(err) } else if result != utils.OK { t.Error("Unexpected reply returned", result) diff --git a/apier/v1/full_remote_it_test.go b/apier/v1/full_remote_it_test.go index b51c101c6..16492f32a 100644 --- a/apier/v1/full_remote_it_test.go +++ b/apier/v1/full_remote_it_test.go @@ -259,7 +259,7 @@ func testFullRemoteITThreshold(t *testing.T) { } var replySet string - tPrfl := &engine.ThresholdProfileWithOpts{ + tPrfl := &engine.ThresholdProfileWithAPIOpts{ ThresholdProfile: &engine.ThresholdProfile{ Tenant: "cgrates.org", ID: "THD_Test", @@ -674,7 +674,7 @@ func testFullRemoteITAction(t *testing.T) { } var replySet string - actPrf = &engine.ActionProfileWithOpts{ + actPrf = &engine.ActionProfileWithAPIOpts{ ActionProfile: &engine.ActionProfile{ Tenant: "cgrates.org", ID: "ACT_1", @@ -689,7 +689,7 @@ func testFullRemoteITAction(t *testing.T) { }, }, }, - Opts: map[string]interface{}{}, + APIOpts: map[string]interface{}{}, } // add a threshold profile in engine1 and verify it internal if err := fullRemEngineOneRPC.Call(utils.APIerSv1SetActionProfile, actPrf, &replySet); err != nil { diff --git a/apier/v1/libapier.go b/apier/v1/libapier.go index c799d45f8..1e757c108 100644 --- a/apier/v1/libapier.go +++ b/apier/v1/libapier.go @@ -60,7 +60,7 @@ func (apierSv1 *APIerSv1) CallCache(cacheopt string, tnt, cacheID, itemID string args = &utils.AttrCacheIDsWithOpts{ Tenant: tnt, CacheIDs: cacheIDs, - Opts: opts, + APIOpts: opts, } } @@ -70,13 +70,13 @@ func (apierSv1 *APIerSv1) CallCache(cacheopt string, tnt, cacheID, itemID string // composeArgsReload add the ItemID to AttrReloadCache // for a specific CacheID -func (apierSv1 *APIerSv1) composeArgsReload(tnt, cacheID, itemID string, filterIDs *[]string, contexts []string, opts map[string]interface{}) (rpl utils.AttrReloadCacheWithOpts, err error) { - rpl = utils.AttrReloadCacheWithOpts{ +func (apierSv1 *APIerSv1) composeArgsReload(tnt, cacheID, itemID string, filterIDs *[]string, contexts []string, opts map[string]interface{}) (rpl utils.AttrReloadCacheWithAPIOpts, err error) { + rpl = utils.AttrReloadCacheWithAPIOpts{ Tenant: tnt, ArgsCache: map[string][]string{ utils.CacheInstanceToArg[cacheID]: {itemID}, }, - Opts: opts, + APIOpts: opts, } if filterIDs == nil { // in case we remove a profile we do not need to reload the indexes return @@ -148,37 +148,37 @@ func (apierSv1 *APIerSv1) callCacheMultiple(cacheopt, tnt, cacheID string, itemI return case utils.MetaReload: method = utils.CacheSv1ReloadCache - args = utils.AttrReloadCacheWithOpts{ + args = utils.AttrReloadCacheWithAPIOpts{ Tenant: tnt, ArgsCache: map[string][]string{ utils.CacheInstanceToArg[cacheID]: itemIDs, }, - Opts: opts, + APIOpts: opts, } case utils.MetaLoad: method = utils.CacheSv1LoadCache - args = utils.AttrReloadCacheWithOpts{ + args = utils.AttrReloadCacheWithAPIOpts{ Tenant: tnt, ArgsCache: map[string][]string{ utils.CacheInstanceToArg[cacheID]: itemIDs, }, - Opts: opts, + APIOpts: opts, } case utils.MetaRemove: method = utils.CacheSv1RemoveItems - args = utils.AttrReloadCacheWithOpts{ + args = utils.AttrReloadCacheWithAPIOpts{ Tenant: tnt, ArgsCache: map[string][]string{ utils.CacheInstanceToArg[cacheID]: itemIDs, }, - Opts: opts, + APIOpts: opts, } case utils.MetaClear: method = utils.CacheSv1Clear args = &utils.AttrCacheIDsWithOpts{ Tenant: tnt, CacheIDs: []string{cacheID}, - Opts: opts, + APIOpts: opts, } } return apierSv1.ConnMgr.Call(apierSv1.Config.ApierCfg().CachesConns, nil, diff --git a/apier/v1/libapier_test.go b/apier/v1/libapier_test.go index c8dcba71e..6c55ca3fb 100644 --- a/apier/v1/libapier_test.go +++ b/apier/v1/libapier_test.go @@ -30,9 +30,9 @@ import ( func TestComposeArgsReload(t *testing.T) { apv1 := &APIerSv1{} - expArgs := utils.AttrReloadCacheWithOpts{ - Opts: make(map[string]interface{}), - Tenant: "cgrates.org", + expArgs := utils.AttrReloadCacheWithAPIOpts{ + APIOpts: make(map[string]interface{}), + Tenant: "cgrates.org", ArgsCache: map[string][]string{ utils.AttributeProfileIDs: {"cgrates.org:ATTR1"}, }, @@ -66,9 +66,9 @@ func TestComposeArgsReload(t *testing.T) { t.Errorf("Expected %s ,received: %s", utils.ToJSON(expArgs), utils.ToJSON(rply)) } - expArgs = utils.AttrReloadCacheWithOpts{ - Opts: make(map[string]interface{}), - Tenant: "cgrates.org", + expArgs = utils.AttrReloadCacheWithAPIOpts{ + APIOpts: make(map[string]interface{}), + Tenant: "cgrates.org", ArgsCache: map[string][]string{ utils.StatsQueueProfileIDs: {"cgrates.org:Stat2"}, utils.StatFilterIndexIDs: { @@ -135,7 +135,7 @@ func TestCallCache(t *testing.T) { Params: &utils.AttrCacheIDsWithOpts{ Tenant: "cgrates.org", CacheIDs: []string{utils.CacheStatQueueProfiles, utils.CacheStatFilterIndexes}, - Opts: make(map[string]interface{}), + APIOpts: make(map[string]interface{}), }, } if err := apv1.CallCache(utils.MetaClear, "cgrates.org", utils.CacheStatQueueProfiles, "", nil, nil, make(map[string]interface{})); err != nil { @@ -148,9 +148,9 @@ func TestCallCache(t *testing.T) { exp = &rpcRequest{ Method: utils.CacheSv1ReloadCache, - Params: utils.AttrReloadCacheWithOpts{ - Opts: make(map[string]interface{}), - Tenant: "cgrates.org", + Params: utils.AttrReloadCacheWithAPIOpts{ + APIOpts: make(map[string]interface{}), + Tenant: "cgrates.org", ArgsCache: map[string][]string{ utils.StatsQueueProfileIDs: {"cgrates.org:Stat2"}, utils.StatFilterIndexIDs: { diff --git a/apier/v1/rateprofiles.go b/apier/v1/rateprofiles.go index b844848f9..b0fe9999b 100644 --- a/apier/v1/rateprofiles.go +++ b/apier/v1/rateprofiles.go @@ -71,7 +71,7 @@ func (apierSv1 *APIerSv1) GetRateProfileIDs(args *utils.PaginatorWithTenant, att // GetRateProfileIDsCount sets in reply var the total number of RateProfileIDs registered for a tenant // returns ErrNotFound in case of 0 RateProfileIDs -func (apierSv1 *APIerSv1) GetRateProfileIDsCount(args *utils.TenantWithOpts, reply *int) (err error) { +func (apierSv1 *APIerSv1) GetRateProfileIDsCount(args *utils.TenantWithAPIOpts, reply *int) (err error) { tnt := args.Tenant if tnt == utils.EmptyString { tnt = apierSv1.Config.GeneralCfg().DefaultTenant diff --git a/apier/v1/rateprofiles_it_test.go b/apier/v1/rateprofiles_it_test.go index 3cdb4d74a..4fdfb8293 100644 --- a/apier/v1/rateprofiles_it_test.go +++ b/apier/v1/rateprofiles_it_test.go @@ -709,14 +709,14 @@ func testV1RatePrfGetRateProfileIDs(t *testing.T) { func testV1RatePrfGetRateProfileIDsCount(t *testing.T) { var reply int if err := ratePrfRpc.Call(utils.APIerSv1GetRateProfileIDsCount, - &utils.TenantWithOpts{}, + &utils.TenantWithAPIOpts{}, &reply); err != nil { t.Error(err) } else if reply != 1 { t.Errorf("Expected 1, received %+v", reply) } if err := ratePrfRpc.Call(utils.APIerSv1GetRateProfileIDsCount, - &utils.TenantWithOpts{Tenant: "cgrates.org"}, + &utils.TenantWithAPIOpts{Tenant: "cgrates.org"}, &reply); err != nil { t.Error(err) } else if reply != 1 { diff --git a/apier/v1/remote_it_test.go b/apier/v1/remote_it_test.go index 184cb957a..958b45a62 100644 --- a/apier/v1/remote_it_test.go +++ b/apier/v1/remote_it_test.go @@ -274,7 +274,7 @@ func testInternalRemoteITGetThreshold(t *testing.T) { func testInternalRemoteITGetThresholdProfile(t *testing.T) { var reply *engine.ThresholdProfile - tPrfl = &engine.ThresholdProfileWithOpts{ + tPrfl = &engine.ThresholdProfileWithAPIOpts{ ThresholdProfile: &engine.ThresholdProfile{ Tenant: "cgrates.org", ID: "THD_ACNT_1001", @@ -789,7 +789,7 @@ func testInternalReplicationSetThreshold(t *testing.T) { expectedIDX, utils.ToJSON(indexes)) } - tPrfl := &engine.ThresholdProfileWithOpts{ + tPrfl := &engine.ThresholdProfileWithAPIOpts{ ThresholdProfile: &engine.ThresholdProfile{ Tenant: "cgrates.org", ID: "THD_Replication", diff --git a/apier/v1/replicate_it_test.go b/apier/v1/replicate_it_test.go index 52a312c29..0d8cd46af 100644 --- a/apier/v1/replicate_it_test.go +++ b/apier/v1/replicate_it_test.go @@ -1002,7 +1002,7 @@ func testInternalReplicateITThresholdProfile(t *testing.T) { } else if result != utils.OK { t.Error("Unexpected reply returned", result) } - tPrfl = &engine.ThresholdProfileWithOpts{ + tPrfl = &engine.ThresholdProfileWithAPIOpts{ ThresholdProfile: &engine.ThresholdProfile{ Tenant: tenant, ID: "TEST_PROFILE1", @@ -1231,7 +1231,7 @@ func testInternalReplicateITThreshold(t *testing.T) { } else if reply != utils.OK { t.Errorf("Calling APIerSv2.SetActions received: %s", reply) } - tPrfl := engine.ThresholdProfileWithOpts{ + tPrfl := engine.ThresholdProfileWithAPIOpts{ ThresholdProfile: &engine.ThresholdProfile{ Tenant: tenant, ID: "THD_Test", diff --git a/apier/v1/replicator.go b/apier/v1/replicator.go index b2d49ddc7..d55089bdf 100644 --- a/apier/v1/replicator.go +++ b/apier/v1/replicator.go @@ -402,12 +402,12 @@ func (rplSv1 *ReplicatorSv1) SetReverseDestination(dst *engine.DestinationWithOp } // SetThresholdProfile is the replication method coresponding to the dataDb driver method -func (rplSv1 *ReplicatorSv1) SetThresholdProfile(th *engine.ThresholdProfileWithOpts, reply *string) (err error) { +func (rplSv1 *ReplicatorSv1) SetThresholdProfile(th *engine.ThresholdProfileWithAPIOpts, reply *string) (err error) { if err = rplSv1.dm.DataDB().SetThresholdProfileDrv(th.ThresholdProfile); err != nil { return } - if err = rplSv1.v1.CallCache(utils.IfaceAsString(th.Opts[utils.CacheOpt]), - th.Tenant, utils.CacheThresholdProfiles, th.TenantID(), &th.FilterIDs, nil, th.Opts); err != nil { + if err = rplSv1.v1.CallCache(utils.IfaceAsString(th.APIOpts[utils.CacheOpt]), + th.Tenant, utils.CacheThresholdProfiles, th.TenantID(), &th.FilterIDs, nil, th.APIOpts); err != nil { return } *reply = utils.OK @@ -415,12 +415,12 @@ func (rplSv1 *ReplicatorSv1) SetThresholdProfile(th *engine.ThresholdProfileWith } // SetThreshold is the replication method coresponding to the dataDb driver method -func (rplSv1 *ReplicatorSv1) SetThreshold(th *engine.ThresholdWithOpts, reply *string) (err error) { +func (rplSv1 *ReplicatorSv1) SetThreshold(th *engine.ThresholdWithAPIOpts, reply *string) (err error) { if err = rplSv1.dm.DataDB().SetThresholdDrv(th.Threshold); err != nil { return } - if err = rplSv1.v1.CallCache(utils.IfaceAsString(th.Opts[utils.CacheOpt]), - th.Tenant, utils.CacheThresholds, th.TenantID(), nil, nil, th.Opts); err != nil { + if err = rplSv1.v1.CallCache(utils.IfaceAsString(th.APIOpts[utils.CacheOpt]), + th.Tenant, utils.CacheThresholds, th.TenantID(), nil, nil, th.APIOpts); err != nil { return } *reply = utils.OK @@ -441,12 +441,12 @@ func (rplSv1 *ReplicatorSv1) SetStatQueueProfile(sq *engine.StatQueueProfileWith } // SetStatQueue is the replication method coresponding to the dataDb driver method -func (rplSv1 *ReplicatorSv1) SetStatQueue(sq *engine.StatQueueWithOpts, reply *string) (err error) { +func (rplSv1 *ReplicatorSv1) SetStatQueue(sq *engine.StatQueueWithAPIOpts, reply *string) (err error) { if err = rplSv1.dm.DataDB().SetStatQueueDrv(nil, sq.StatQueue); err != nil { return } - if err = rplSv1.v1.CallCache(utils.IfaceAsString(sq.Opts[utils.CacheOpt]), - sq.Tenant, utils.CacheStatQueues, sq.TenantID(), nil, nil, sq.Opts); err != nil { + if err = rplSv1.v1.CallCache(utils.IfaceAsString(sq.APIOpts[utils.CacheOpt]), + sq.Tenant, utils.CacheStatQueues, sq.TenantID(), nil, nil, sq.APIOpts); err != nil { return } *reply = utils.OK @@ -675,12 +675,12 @@ func (rplSv1 *ReplicatorSv1) SetRateProfile(dpp *engine.RateProfileWithOpts, rep } // SetActionProfile is the replication method coresponding to the dataDb driver method -func (rplSv1 *ReplicatorSv1) SetActionProfile(acp *engine.ActionProfileWithOpts, reply *string) (err error) { +func (rplSv1 *ReplicatorSv1) SetActionProfile(acp *engine.ActionProfileWithAPIOpts, reply *string) (err error) { if err = rplSv1.dm.DataDB().SetActionProfileDrv(acp.ActionProfile); err != nil { return } - if err = rplSv1.v1.CallCache(utils.IfaceAsString(acp.Opts[utils.CacheOpt]), - acp.Tenant, utils.CacheActionProfiles, acp.TenantID(), &acp.FilterIDs, nil, acp.Opts); err != nil { + if err = rplSv1.v1.CallCache(utils.IfaceAsString(acp.APIOpts[utils.CacheOpt]), + acp.Tenant, utils.CacheActionProfiles, acp.TenantID(), &acp.FilterIDs, nil, acp.APIOpts); err != nil { return } *reply = utils.OK diff --git a/apier/v1/sessions.go b/apier/v1/sessions.go index 674a4d09a..ad91ae189 100644 --- a/apier/v1/sessions.go +++ b/apier/v1/sessions.go @@ -63,9 +63,9 @@ func (ssv1 *SessionSv1) UpdateSession(args *sessions.V1UpdateSessionArgs, return ssv1.sS.BiRPCv1UpdateSession(nil, args, rply) } -func (ssv1 *SessionSv1) SyncSessions(args *utils.TenantWithOpts, +func (ssv1 *SessionSv1) SyncSessions(args *utils.TenantWithAPIOpts, rply *string) error { - return ssv1.sS.BiRPCv1SyncSessions(nil, &utils.TenantWithOpts{}, rply) + return ssv1.sS.BiRPCv1SyncSessions(nil, &utils.TenantWithAPIOpts{}, rply) } func (ssv1 *SessionSv1) TerminateSession(args *sessions.V1TerminateSessionArgs, @@ -122,7 +122,7 @@ func (ssv1 *SessionSv1) Ping(ign *utils.CGREvent, reply *string) error { return nil } -func (ssv1 *SessionSv1) ReplicateSessions(args *dispatchers.ArgsReplicateSessionsWithOpts, rply *string) error { +func (ssv1 *SessionSv1) ReplicateSessions(args *dispatchers.ArgsReplicateSessionsWithAPIOpts, rply *string) error { return ssv1.sS.BiRPCv1ReplicateSessions(nil, args.ArgsReplicateSessions, rply) } diff --git a/apier/v1/sessionsbirpc.go b/apier/v1/sessionsbirpc.go index 4ebe3eb8a..fd86b2c9c 100644 --- a/apier/v1/sessionsbirpc.go +++ b/apier/v1/sessionsbirpc.go @@ -120,7 +120,7 @@ func (ssv1 *SessionSv1) BiRPCv1UpdateSession(clnt *rpc2.Client, args *sessions.V return ssv1.sS.BiRPCv1UpdateSession(clnt, args, rply) } -func (ssv1 *SessionSv1) BiRPCv1SyncSessions(clnt *rpc2.Client, args *utils.TenantWithOpts, +func (ssv1 *SessionSv1) BiRPCv1SyncSessions(clnt *rpc2.Client, args *utils.TenantWithAPIOpts, rply *string) (err error) { if ssv1.caps.IsLimited() { if err = ssv1.caps.Allocate(); err != nil { @@ -128,7 +128,7 @@ func (ssv1 *SessionSv1) BiRPCv1SyncSessions(clnt *rpc2.Client, args *utils.Tenan } defer ssv1.caps.Deallocate() } - return ssv1.sS.BiRPCv1SyncSessions(clnt, &utils.TenantWithOpts{}, rply) + return ssv1.sS.BiRPCv1SyncSessions(clnt, &utils.TenantWithAPIOpts{}, rply) } func (ssv1 *SessionSv1) BiRPCv1TerminateSession(clnt *rpc2.Client, args *sessions.V1TerminateSessionArgs, diff --git a/apier/v1/stats.go b/apier/v1/stats.go index 9f7f8e654..634c6f1e9 100644 --- a/apier/v1/stats.go +++ b/apier/v1/stats.go @@ -168,7 +168,7 @@ func (stsv1 *StatSv1) Call(serviceMethod string, args interface{}, reply interfa } // GetQueueIDs returns list of queueIDs registered for a tenant -func (stsv1 *StatSv1) GetQueueIDs(tenant *utils.TenantWithOpts, qIDs *[]string) error { +func (stsv1 *StatSv1) GetQueueIDs(tenant *utils.TenantWithAPIOpts, qIDs *[]string) error { return stsv1.sS.V1GetQueueIDs(tenant.Tenant, qIDs) } diff --git a/apier/v1/stats_it_test.go b/apier/v1/stats_it_test.go index dbcabc178..99044ba57 100644 --- a/apier/v1/stats_it_test.go +++ b/apier/v1/stats_it_test.go @@ -168,7 +168,7 @@ func testV1STSGetStats(t *testing.T) { var reply []string expectedIDs := []string{"Stats1"} if err := stsV1Rpc.Call(utils.StatSv1GetQueueIDs, - &utils.TenantWithOpts{Tenant: "cgrates.org"}, &reply); err != nil { + &utils.TenantWithAPIOpts{Tenant: "cgrates.org"}, &reply); err != nil { t.Error(err) } else if !reflect.DeepEqual(expectedIDs, reply) { t.Errorf("expecting: %+v, received reply: %s", expectedIDs, reply) @@ -197,7 +197,7 @@ func testV1STSV1StatSv1GetQueueStringMetricsWithoutTenant(t *testing.T) { var reply []string expectedIDs := []string{"CustomStatProfile", "Stats1", "StaticStatQueue", "StatWithThreshold"} if err := stsV1Rpc.Call(utils.StatSv1GetQueueIDs, - &utils.TenantWithOpts{}, &reply); err != nil { + &utils.TenantWithAPIOpts{}, &reply); err != nil { t.Error(err) } else { sort.Strings(reply) @@ -853,7 +853,7 @@ func testV1STSProcessStatWithThreshold(t *testing.T) { } else if result != utils.OK { t.Error("Unexpected reply returned", result) } - thSts := &engine.ThresholdProfileWithOpts{ + thSts := &engine.ThresholdProfileWithAPIOpts{ ThresholdProfile: &engine.ThresholdProfile{ Tenant: "cgrates.org", ID: "THD_Stat", @@ -1160,7 +1160,7 @@ func testV1STSProcessStatWithThreshold2(t *testing.T) { } else if result != utils.OK { t.Error("Unexpected reply returned", result) } - thSts := &engine.ThresholdProfileWithOpts{ + thSts := &engine.ThresholdProfileWithAPIOpts{ ThresholdProfile: &engine.ThresholdProfile{ Tenant: "cgrates.org", ID: "THD_Stat2", @@ -1317,7 +1317,7 @@ func testV1STSV1GetQueueIDs(t *testing.T) { sort.Strings(expected) var qIDs []string if err := stsV1Rpc.Call(utils.StatSv1GetQueueIDs, - &utils.TenantWithOpts{}, + &utils.TenantWithAPIOpts{}, &qIDs); err != nil { t.Error(err) } else { @@ -1326,7 +1326,7 @@ func testV1STSV1GetQueueIDs(t *testing.T) { t.Errorf("Expected %+v \n ,received %+v", expected, qIDs) } if err := stsV1Rpc.Call(utils.StatSv1GetQueueIDs, - &utils.TenantWithOpts{Tenant: "cgrates.org"}, + &utils.TenantWithAPIOpts{Tenant: "cgrates.org"}, &qIDs); err != nil { t.Error(err) } else { diff --git a/apier/v1/thresholds.go b/apier/v1/thresholds.go index 8c11926f7..189e76df0 100644 --- a/apier/v1/thresholds.go +++ b/apier/v1/thresholds.go @@ -41,7 +41,7 @@ func (tSv1 *ThresholdSv1) Call(serviceMethod string, args interface{}, reply int } // GetThresholdIDs returns list of threshold IDs registered for a tenant -func (tSv1 *ThresholdSv1) GetThresholdIDs(tenant *utils.TenantWithOpts, tIDs *[]string) error { +func (tSv1 *ThresholdSv1) GetThresholdIDs(tenant *utils.TenantWithAPIOpts, tIDs *[]string) error { return tSv1.tS.V1GetThresholdIDs(tenant.Tenant, tIDs) } @@ -106,7 +106,7 @@ func (apierSv1 *APIerSv1) GetThresholdProfileIDs(args *utils.PaginatorWithTenant // GetThresholdProfileIDsCount sets in reply var the total number of ThresholdProfileIDs registered for the received tenant // returns ErrNotFound in case of 0 ThresholdProfileIDs -func (apierSv1 *APIerSv1) GetThresholdProfileIDsCount(args *utils.TenantWithOpts, reply *int) (err error) { +func (apierSv1 *APIerSv1) GetThresholdProfileIDsCount(args *utils.TenantWithAPIOpts, reply *int) (err error) { tnt := args.Tenant if tnt == utils.EmptyString { tnt = apierSv1.Config.GeneralCfg().DefaultTenant @@ -124,7 +124,7 @@ func (apierSv1 *APIerSv1) GetThresholdProfileIDsCount(args *utils.TenantWithOpts } // SetThresholdProfile alters/creates a ThresholdProfile -func (apierSv1 *APIerSv1) SetThresholdProfile(args *engine.ThresholdProfileWithOpts, reply *string) error { +func (apierSv1 *APIerSv1) SetThresholdProfile(args *engine.ThresholdProfileWithAPIOpts, reply *string) error { if missing := utils.MissingStructFields(args.ThresholdProfile, []string{utils.ID}); len(missing) != 0 { return utils.NewErrMandatoryIeMissing(missing...) } @@ -141,16 +141,16 @@ func (apierSv1 *APIerSv1) SetThresholdProfile(args *engine.ThresholdProfileWithO return utils.APIErrorHandler(err) } //handle caching for ThresholdProfile - if err := apierSv1.CallCache(utils.IfaceAsString(args.Opts[utils.CacheOpt]), args.Tenant, utils.CacheThresholdProfiles, - args.TenantID(), &args.FilterIDs, nil, args.Opts); err != nil { + if err := apierSv1.CallCache(utils.IfaceAsString(args.APIOpts[utils.CacheOpt]), args.Tenant, utils.CacheThresholdProfiles, + args.TenantID(), &args.FilterIDs, nil, args.APIOpts); err != nil { return utils.APIErrorHandler(err) } if err := apierSv1.DataManager.SetThreshold(&engine.Threshold{Tenant: args.Tenant, ID: args.ID}, args.MinSleep, false); err != nil { return err } //handle caching for Threshold - if err := apierSv1.CallCache(utils.IfaceAsString(args.Opts[utils.CacheOpt]), args.Tenant, utils.CacheThresholds, - args.TenantID(), nil, nil, args.Opts); err != nil { + if err := apierSv1.CallCache(utils.IfaceAsString(args.APIOpts[utils.CacheOpt]), args.Tenant, utils.CacheThresholds, + args.TenantID(), nil, nil, args.APIOpts); err != nil { return utils.APIErrorHandler(err) } diff --git a/apier/v1/thresholds_it_test.go b/apier/v1/thresholds_it_test.go index ce486a5eb..b95e4163e 100644 --- a/apier/v1/thresholds_it_test.go +++ b/apier/v1/thresholds_it_test.go @@ -36,7 +36,7 @@ var ( tSv1CfgPath string tSv1Cfg *config.CGRConfig tSv1Rpc *rpc.Client - tPrfl *engine.ThresholdProfileWithOpts + tPrfl *engine.ThresholdProfileWithAPIOpts tSv1ConfDIR string //run tests for specific configuration tEvs = []*engine.ThresholdsArgsProcessEvent{ @@ -300,13 +300,13 @@ func testV1TSGetThresholds(t *testing.T) { var tIDs []string expectedIDs := []string{"THD_RES_1", "THD_STATS_2", "THD_STATS_1", "THD_ACNT_BALANCE_1", "THD_ACNT_EXPIRED", "THD_STATS_3", "THD_CDRS_1"} if err := tSv1Rpc.Call(utils.ThresholdSv1GetThresholdIDs, - &utils.TenantWithOpts{}, &tIDs); err != nil { + &utils.TenantWithAPIOpts{}, &tIDs); err != nil { t.Error(err) } else if len(expectedIDs) != len(tIDs) { t.Errorf("expecting: %+v, received reply: %s", expectedIDs, tIDs) } if err := tSv1Rpc.Call(utils.ThresholdSv1GetThresholdIDs, - &utils.TenantWithOpts{Tenant: "cgrates.org"}, &tIDs); err != nil { + &utils.TenantWithAPIOpts{Tenant: "cgrates.org"}, &tIDs); err != nil { t.Error(err) } else if len(expectedIDs) != len(tIDs) { t.Errorf("expecting: %+v, received reply: %s", expectedIDs, tIDs) @@ -381,7 +381,7 @@ func testV1TSGetThresholdsAfterProcess(t *testing.T) { var tIDs []string expectedIDs := []string{"THD_RES_1", "THD_STATS_2", "THD_STATS_1", "THD_ACNT_BALANCE_1", "THD_ACNT_EXPIRED"} if err := tSv1Rpc.Call(utils.ThresholdSv1GetThresholdIDs, - &utils.TenantWithOpts{Tenant: "cgrates.org"}, &tIDs); err != nil { + &utils.TenantWithAPIOpts{Tenant: "cgrates.org"}, &tIDs); err != nil { t.Error(err) } else if len(expectedIDs) != len(tIDs) { // THD_STATS_3 is not reccurent, so it was removed t.Errorf("expecting: %+v, received reply: %s", expectedIDs, tIDs) @@ -421,7 +421,7 @@ func testV1TSGetThresholdsAfterRestart(t *testing.T) { func testV1TSSetThresholdProfileBrokenReference(t *testing.T) { var reply *engine.ThresholdProfile var result string - tPrfl = &engine.ThresholdProfileWithOpts{ + tPrfl = &engine.ThresholdProfileWithAPIOpts{ ThresholdProfile: &engine.ThresholdProfile{ Tenant: "cgrates.org", ID: "THD_Test", @@ -472,7 +472,7 @@ func testV1TSSetThresholdProfile(t *testing.T) { err.Error() != utils.ErrNotFound.Error() { t.Error(err) } - tPrfl = &engine.ThresholdProfileWithOpts{ + tPrfl = &engine.ThresholdProfileWithAPIOpts{ ThresholdProfile: &engine.ThresholdProfile{ Tenant: "cgrates.org", ID: "THD_Test", @@ -551,7 +551,7 @@ func testV1TSMaxHits(t *testing.T) { err.Error() != utils.ErrNotFound.Error() { t.Error(err) } - tPrfl = &engine.ThresholdProfileWithOpts{ + tPrfl = &engine.ThresholdProfileWithAPIOpts{ ThresholdProfile: &engine.ThresholdProfile{ Tenant: "cgrates.org", ID: "TH3", @@ -656,7 +656,7 @@ func testV1TSUpdateSnooze(t *testing.T) { err.Error() != utils.ErrNotFound.Error() { t.Error(err) } - customTh := &engine.ThresholdProfileWithOpts{ + customTh := &engine.ThresholdProfileWithAPIOpts{ ThresholdProfile: &engine.ThresholdProfile{ Tenant: "cgrates.org", ID: "TH4", @@ -703,7 +703,7 @@ func testV1TSUpdateSnooze(t *testing.T) { t.Errorf("expecting: %+v, received: %+v", tNow.Add(10*time.Minute), td.Snooze) } - customTh2 := &engine.ThresholdProfileWithOpts{ + customTh2 := &engine.ThresholdProfileWithAPIOpts{ ThresholdProfile: &engine.ThresholdProfile{ Tenant: "cgrates.org", ID: "TH4", @@ -737,7 +737,7 @@ func testV1TSStopEngine(t *testing.T) { } func testV1TSGetThresholdProfileWithoutTenant(t *testing.T) { - tPrfl = &engine.ThresholdProfileWithOpts{ + tPrfl = &engine.ThresholdProfileWithAPIOpts{ ThresholdProfile: &engine.ThresholdProfile{ ID: "randomID", FilterIDs: []string{"*string:~*req.Account:1001"}, @@ -790,14 +790,14 @@ func testV1TSRemThresholdProfileWithoutTenant(t *testing.T) { func testv1TSGetThresholdProfileIDsCount(t *testing.T) { var reply int if err := tSv1Rpc.Call(utils.APIerSv1GetThresholdProfileIDsCount, - &utils.TenantWithOpts{}, + &utils.TenantWithAPIOpts{}, &reply); err != nil { t.Error(err) } else if reply != 7 { t.Errorf("Expected 7, received %+v", reply) } if err := tSv1Rpc.Call(utils.APIerSv1GetThresholdProfileIDsCount, - &utils.TenantWithOpts{Tenant: "cgrates.org"}, + &utils.TenantWithAPIOpts{Tenant: "cgrates.org"}, &reply); err != nil { t.Error(err) } else if reply != 7 { @@ -846,7 +846,7 @@ func testV1TSGetThresholdsWithoutTenant(t *testing.T) { func testV1TSProcessAccountUpdateEvent(t *testing.T) { var result string - thAcntUpdate := &engine.ThresholdProfileWithOpts{ + thAcntUpdate := &engine.ThresholdProfileWithAPIOpts{ ThresholdProfile: &engine.ThresholdProfile{ Tenant: "cgrates.org", ID: "TH_ACNT_UPDATE_EV", diff --git a/apier/v1/triggers.go b/apier/v1/triggers.go index 2dbdd250e..49f8b88f2 100644 --- a/apier/v1/triggers.go +++ b/apier/v1/triggers.go @@ -429,7 +429,7 @@ func (apierSv1 *APIerSv1) RemoveActionTrigger(attr *AttrRemoveActionTrigger, rep } // CacheReload if err = apierSv1.ConnMgr.Call(apierSv1.Config.ApierCfg().CachesConns, nil, - utils.CacheSv1ReloadCache, utils.AttrReloadCacheWithOpts{ + utils.CacheSv1ReloadCache, utils.AttrReloadCacheWithAPIOpts{ ArgsCache: map[string][]string{utils.ActionTriggerIDs: {attr.GroupID}}, }, reply); err != nil { return @@ -479,7 +479,7 @@ func (apierSv1 *APIerSv1) SetActionTrigger(attr *AttrSetActionTrigger, reply *st } // CacheReload if err = apierSv1.ConnMgr.Call(apierSv1.Config.ApierCfg().CachesConns, nil, - utils.CacheSv1ReloadCache, utils.AttrReloadCacheWithOpts{ + utils.CacheSv1ReloadCache, utils.AttrReloadCacheWithAPIOpts{ ArgsCache: map[string][]string{utils.ActionTriggerIDs: {attr.GroupID}}, }, reply); err != nil { return diff --git a/apier/v2/accounts.go b/apier/v2/accounts.go index fca08b897..97c1ae549 100644 --- a/apier/v2/accounts.go +++ b/apier/v2/accounts.go @@ -218,7 +218,7 @@ func (apiv2 *APIerSv2) SetAccount(attr *AttrSetAccount, reply *string) error { return 0, err } return 0, apiv2.ConnMgr.Call(apiv2.Config.ApierCfg().CachesConns, nil, - utils.CacheSv1ReloadCache, utils.AttrReloadCacheWithOpts{ + utils.CacheSv1ReloadCache, utils.AttrReloadCacheWithAPIOpts{ ArgsCache: map[string][]string{utils.AccountActionPlanIDs: {accID}, utils.ActionPlanIDs: apIDs}, }, reply) }, config.CgrConfig().GeneralCfg().LockingTimeout, utils.ActionPlanPrefix) diff --git a/apier/v2/apier.go b/apier/v2/apier.go index 46e7caa89..8a018117a 100644 --- a/apier/v2/apier.go +++ b/apier/v2/apier.go @@ -355,7 +355,7 @@ func (apiv2 *APIerSv2) SetActions(attrs *utils.AttrSetActions, reply *string) er } //CacheReload if err := apiv2.ConnMgr.Call(apiv2.Config.ApierCfg().CachesConns, nil, - utils.CacheSv1ReloadCache, utils.AttrReloadCacheWithOpts{ + utils.CacheSv1ReloadCache, utils.AttrReloadCacheWithAPIOpts{ ArgsCache: map[string][]string{utils.ActionIDs: {attrs.ActionsId}}, }, reply); err != nil { return err diff --git a/apier/v2/cdrs_it_test.go b/apier/v2/cdrs_it_test.go index d29b12f7b..db7b4d032 100644 --- a/apier/v2/cdrs_it_test.go +++ b/apier/v2/cdrs_it_test.go @@ -730,7 +730,7 @@ func testV2CDRsSetThreshold(t *testing.T) { } else if reply != utils.OK { t.Errorf("Calling APIerSv2.SetActions received: %s", reply) } - tPrfl := engine.ThresholdProfileWithOpts{ + tPrfl := engine.ThresholdProfileWithAPIOpts{ ThresholdProfile: &engine.ThresholdProfile{ Tenant: "cgrates.org", ID: "THD_Test", diff --git a/apier/v2/cdrs_offline_it_test.go b/apier/v2/cdrs_offline_it_test.go index ce2f53c6e..c05c745c3 100644 --- a/apier/v2/cdrs_offline_it_test.go +++ b/apier/v2/cdrs_offline_it_test.go @@ -160,7 +160,7 @@ func testV2CDRsOfflineBalanceUpdate(t *testing.T) { t.Error(err) } //create a threshold that match out account - tPrfl := engine.ThresholdProfileWithOpts{ + tPrfl := engine.ThresholdProfileWithAPIOpts{ ThresholdProfile: &engine.ThresholdProfile{ Tenant: "cgrates.org", ID: "THD_Test", @@ -274,7 +274,7 @@ func testV2CDRsOfflineExpiryBalance(t *testing.T) { t.Error(err) } //create a threshold that match out account - tPrfl := &engine.ThresholdProfileWithOpts{ + tPrfl := &engine.ThresholdProfileWithAPIOpts{ ThresholdProfile: &engine.ThresholdProfile{ Tenant: "cgrates.org", ID: "THD_Test2", diff --git a/console/cache_has_item.go b/console/cache_has_item.go index 2dfa6ca7b..0cc2bd700 100644 --- a/console/cache_has_item.go +++ b/console/cache_has_item.go @@ -26,7 +26,7 @@ func init() { c := &CmdCacheHasItem{ name: "cache_has_item", rpcMethod: utils.CacheSv1HasItem, - rpcParams: &utils.ArgsGetCacheItemWithOpts{}, + rpcParams: &utils.ArgsGetCacheItemWithAPIOpts{}, } commands[c.Name()] = c c.CommandExecuter = &CommandExecuter{c} @@ -36,7 +36,7 @@ func init() { type CmdCacheHasItem struct { name string rpcMethod string - rpcParams *utils.ArgsGetCacheItemWithOpts + rpcParams *utils.ArgsGetCacheItemWithAPIOpts *CommandExecuter } @@ -50,7 +50,7 @@ func (self *CmdCacheHasItem) RpcMethod() string { func (self *CmdCacheHasItem) RpcParams(reset bool) interface{} { if reset || self.rpcParams == nil { - self.rpcParams = &utils.ArgsGetCacheItemWithOpts{} + self.rpcParams = &utils.ArgsGetCacheItemWithAPIOpts{} } return self.rpcParams } diff --git a/console/cache_item_expiry_time.go b/console/cache_item_expiry_time.go index d2ceb845b..4d013421b 100644 --- a/console/cache_item_expiry_time.go +++ b/console/cache_item_expiry_time.go @@ -28,7 +28,7 @@ func init() { c := &CmdCacheGetItemExpiryTime{ name: "cache_item_expiry_time", rpcMethod: utils.CacheSv1GetItemExpiryTime, - rpcParams: &utils.ArgsGetCacheItemWithOpts{}, + rpcParams: &utils.ArgsGetCacheItemWithAPIOpts{}, } commands[c.Name()] = c c.CommandExecuter = &CommandExecuter{c} @@ -38,7 +38,7 @@ func init() { type CmdCacheGetItemExpiryTime struct { name string rpcMethod string - rpcParams *utils.ArgsGetCacheItemWithOpts + rpcParams *utils.ArgsGetCacheItemWithAPIOpts *CommandExecuter } @@ -52,7 +52,7 @@ func (self *CmdCacheGetItemExpiryTime) RpcMethod() string { func (self *CmdCacheGetItemExpiryTime) RpcParams(reset bool) interface{} { if reset || self.rpcParams == nil { - self.rpcParams = &utils.ArgsGetCacheItemWithOpts{} + self.rpcParams = &utils.ArgsGetCacheItemWithAPIOpts{} } return self.rpcParams } diff --git a/console/cache_item_ids.go b/console/cache_item_ids.go index 13d1e06a7..4922a7a65 100644 --- a/console/cache_item_ids.go +++ b/console/cache_item_ids.go @@ -26,7 +26,7 @@ func init() { c := &CmdCacheGetItemIDs{ name: "cache_item_ids", rpcMethod: utils.CacheSv1GetItemIDs, - rpcParams: &utils.ArgsGetCacheItemIDsWithOpts{}, + rpcParams: &utils.ArgsGetCacheItemIDsWithAPIOpts{}, } commands[c.Name()] = c c.CommandExecuter = &CommandExecuter{c} @@ -36,7 +36,7 @@ func init() { type CmdCacheGetItemIDs struct { name string rpcMethod string - rpcParams *utils.ArgsGetCacheItemIDsWithOpts + rpcParams *utils.ArgsGetCacheItemIDsWithAPIOpts *CommandExecuter } @@ -50,7 +50,7 @@ func (self *CmdCacheGetItemIDs) RpcMethod() string { func (self *CmdCacheGetItemIDs) RpcParams(reset bool) interface{} { if reset || self.rpcParams == nil { - self.rpcParams = &utils.ArgsGetCacheItemIDsWithOpts{} + self.rpcParams = &utils.ArgsGetCacheItemIDsWithAPIOpts{} } return self.rpcParams } diff --git a/console/cache_reload.go b/console/cache_reload.go index 2c3ddace9..d51b57f96 100644 --- a/console/cache_reload.go +++ b/console/cache_reload.go @@ -24,7 +24,7 @@ func init() { c := &CmdReloadCache{ name: "cache_reload", rpcMethod: utils.CacheSv1ReloadCache, - rpcParams: &utils.AttrReloadCacheWithOpts{}, + rpcParams: &utils.AttrReloadCacheWithAPIOpts{}, } commands[c.Name()] = c c.CommandExecuter = &CommandExecuter{c} @@ -34,7 +34,7 @@ func init() { type CmdReloadCache struct { name string rpcMethod string - rpcParams *utils.AttrReloadCacheWithOpts + rpcParams *utils.AttrReloadCacheWithAPIOpts rpcResult string *CommandExecuter } @@ -49,7 +49,7 @@ func (self *CmdReloadCache) RpcMethod() string { func (self *CmdReloadCache) RpcParams(reset bool) interface{} { if reset || self.rpcParams == nil { - self.rpcParams = &utils.AttrReloadCacheWithOpts{} + self.rpcParams = &utils.AttrReloadCacheWithAPIOpts{} } return self.rpcParams } diff --git a/console/cache_remove_item.go b/console/cache_remove_item.go index b8417c275..637fb8bf2 100644 --- a/console/cache_remove_item.go +++ b/console/cache_remove_item.go @@ -26,7 +26,7 @@ func init() { c := &CmdCacheRemoveItem{ name: "cache_remove_item", rpcMethod: utils.CacheSv1RemoveItem, - rpcParams: &utils.ArgsGetCacheItemWithOpts{}, + rpcParams: &utils.ArgsGetCacheItemWithAPIOpts{}, } commands[c.Name()] = c c.CommandExecuter = &CommandExecuter{c} @@ -36,7 +36,7 @@ func init() { type CmdCacheRemoveItem struct { name string rpcMethod string - rpcParams *utils.ArgsGetCacheItemWithOpts + rpcParams *utils.ArgsGetCacheItemWithAPIOpts *CommandExecuter } @@ -50,7 +50,7 @@ func (self *CmdCacheRemoveItem) RpcMethod() string { func (self *CmdCacheRemoveItem) RpcParams(reset bool) interface{} { if reset || self.rpcParams == nil { - self.rpcParams = &utils.ArgsGetCacheItemWithOpts{} + self.rpcParams = &utils.ArgsGetCacheItemWithAPIOpts{} } return self.rpcParams } diff --git a/console/status.go b/console/status.go index 6e7da6830..efe33a84c 100644 --- a/console/status.go +++ b/console/status.go @@ -32,7 +32,7 @@ func init() { type CmdStatus struct { name string rpcMethod string - rpcParams *utils.TenantWithOpts + rpcParams *utils.TenantWithAPIOpts *CommandExecuter } @@ -46,8 +46,8 @@ func (self *CmdStatus) RpcMethod() string { func (self *CmdStatus) RpcParams(reset bool) interface{} { if reset || self.rpcParams == nil { - self.rpcParams = &utils.TenantWithOpts{ - Opts: make(map[string]interface{}), + self.rpcParams = &utils.TenantWithAPIOpts{ + APIOpts: make(map[string]interface{}), } } return self.rpcParams diff --git a/console/thresholds_profile_set.go b/console/thresholds_profile_set.go index 31cd9a407..fec58fa1d 100644 --- a/console/thresholds_profile_set.go +++ b/console/thresholds_profile_set.go @@ -27,7 +27,7 @@ func init() { c := &CmdSetThreshold{ name: "thresholds_profile_set", rpcMethod: utils.APIerSv1SetThresholdProfile, - rpcParams: &engine.ThresholdProfileWithOpts{}, + rpcParams: &engine.ThresholdProfileWithAPIOpts{}, } commands[c.Name()] = c c.CommandExecuter = &CommandExecuter{c} @@ -37,7 +37,7 @@ func init() { type CmdSetThreshold struct { name string rpcMethod string - rpcParams *engine.ThresholdProfileWithOpts + rpcParams *engine.ThresholdProfileWithAPIOpts *CommandExecuter } @@ -51,9 +51,9 @@ func (self *CmdSetThreshold) RpcMethod() string { func (self *CmdSetThreshold) RpcParams(reset bool) interface{} { if reset || self.rpcParams == nil { - self.rpcParams = &engine.ThresholdProfileWithOpts{ + self.rpcParams = &engine.ThresholdProfileWithAPIOpts{ ThresholdProfile: new(engine.ThresholdProfile), - Opts: map[string]interface{}{}, + APIOpts: map[string]interface{}{}, } } return self.rpcParams diff --git a/cores/core.go b/cores/core.go index acc55242c..89a1fe7b6 100644 --- a/cores/core.go +++ b/cores/core.go @@ -51,7 +51,7 @@ func (cS *CoreService) Shutdown() { } // Status returns the status of the engine -func (cS *CoreService) Status(arg *utils.TenantWithOpts, reply *map[string]interface{}) (err error) { +func (cS *CoreService) Status(arg *utils.TenantWithAPIOpts, reply *map[string]interface{}) (err error) { memstats := new(runtime.MemStats) runtime.ReadMemStats(memstats) response := make(map[string]interface{}) diff --git a/cores/core_test.go b/cores/core_test.go index 2df9d1e49..1db317acd 100644 --- a/cores/core_test.go +++ b/cores/core_test.go @@ -56,9 +56,9 @@ func TestCoreServiceStatus(t *testing.T) { stopChan := make(chan struct{}, 1) cores := NewCoreService(cfgDflt, caps, stopChan) - args := &utils.TenantWithOpts{ - Tenant: "cgrates.org", - Opts: map[string]interface{}{}, + args := &utils.TenantWithAPIOpts{ + Tenant: "cgrates.org", + APIOpts: map[string]interface{}{}, } var reply map[string]interface{} diff --git a/dispatchers/caches.go b/dispatchers/caches.go index 1bdfb21e7..f95c4a19d 100644 --- a/dispatchers/caches.go +++ b/dispatchers/caches.go @@ -45,7 +45,7 @@ func (dS *DispatcherService) CacheSv1Ping(args *utils.CGREvent, } // CacheSv1GetItemIDs returns the IDs for cacheID with given prefix -func (dS *DispatcherService) CacheSv1GetItemIDs(args *utils.ArgsGetCacheItemIDsWithOpts, +func (dS *DispatcherService) CacheSv1GetItemIDs(args *utils.ArgsGetCacheItemIDsWithAPIOpts, reply *[]string) (err error) { tnt := dS.cfg.GeneralCfg().DefaultTenant if args.Tenant != utils.EmptyString { @@ -53,18 +53,18 @@ func (dS *DispatcherService) CacheSv1GetItemIDs(args *utils.ArgsGetCacheItemIDsW } if len(dS.cfg.DispatcherSCfg().AttributeSConns) != 0 { if err = dS.authorize(utils.CacheSv1GetItemIDs, tnt, - utils.IfaceAsString(args.Opts[utils.OptsAPIKey]), utils.TimePointer(time.Now())); err != nil { + utils.IfaceAsString(args.APIOpts[utils.OptsAPIKey]), utils.TimePointer(time.Now())); err != nil { return } } return dS.Dispatch(&utils.CGREvent{ Tenant: tnt, - Opts: args.Opts, + Opts: args.APIOpts, }, utils.MetaCaches, utils.CacheSv1GetItemIDs, args, reply) } // CacheSv1HasItem verifies the existence of an Item in cache -func (dS *DispatcherService) CacheSv1HasItem(args *utils.ArgsGetCacheItemWithOpts, +func (dS *DispatcherService) CacheSv1HasItem(args *utils.ArgsGetCacheItemWithAPIOpts, reply *bool) (err error) { tnt := dS.cfg.GeneralCfg().DefaultTenant if args.Tenant != utils.EmptyString { @@ -72,20 +72,20 @@ func (dS *DispatcherService) CacheSv1HasItem(args *utils.ArgsGetCacheItemWithOpt } if len(dS.cfg.DispatcherSCfg().AttributeSConns) != 0 { if err = dS.authorize(utils.CacheSv1HasItem, tnt, - utils.IfaceAsString(args.Opts[utils.OptsAPIKey]), utils.TimePointer(time.Now())); err != nil { + utils.IfaceAsString(args.APIOpts[utils.OptsAPIKey]), utils.TimePointer(time.Now())); err != nil { return } } return dS.Dispatch(&utils.CGREvent{ Tenant: tnt, - Opts: args.Opts, + Opts: args.APIOpts, }, utils.MetaCaches, utils.CacheSv1HasItem, args, reply) } // CacheSv1GetItemExpiryTime returns the expiryTime for an item -func (dS *DispatcherService) CacheSv1GetItemExpiryTime(args *utils.ArgsGetCacheItemWithOpts, +func (dS *DispatcherService) CacheSv1GetItemExpiryTime(args *utils.ArgsGetCacheItemWithAPIOpts, reply *time.Time) (err error) { tnt := dS.cfg.GeneralCfg().DefaultTenant if args.Tenant != utils.EmptyString { @@ -93,19 +93,19 @@ func (dS *DispatcherService) CacheSv1GetItemExpiryTime(args *utils.ArgsGetCacheI } if len(dS.cfg.DispatcherSCfg().AttributeSConns) != 0 { if err = dS.authorize(utils.CacheSv1GetItemExpiryTime, tnt, - utils.IfaceAsString(args.Opts[utils.OptsAPIKey]), utils.TimePointer(time.Now())); err != nil { + utils.IfaceAsString(args.APIOpts[utils.OptsAPIKey]), utils.TimePointer(time.Now())); err != nil { return } } return dS.Dispatch(&utils.CGREvent{ Tenant: tnt, - Opts: args.Opts, + Opts: args.APIOpts, }, utils.MetaCaches, utils.CacheSv1GetItemExpiryTime, args, reply) } // CacheSv1RemoveItem removes the Item with ID from cache -func (dS *DispatcherService) CacheSv1RemoveItem(args *utils.ArgsGetCacheItemWithOpts, +func (dS *DispatcherService) CacheSv1RemoveItem(args *utils.ArgsGetCacheItemWithAPIOpts, reply *string) (err error) { tnt := dS.cfg.GeneralCfg().DefaultTenant if args.Tenant != utils.EmptyString { @@ -113,18 +113,18 @@ func (dS *DispatcherService) CacheSv1RemoveItem(args *utils.ArgsGetCacheItemWith } if len(dS.cfg.DispatcherSCfg().AttributeSConns) != 0 { if err = dS.authorize(utils.CacheSv1RemoveItem, tnt, - utils.IfaceAsString(args.Opts[utils.OptsAPIKey]), utils.TimePointer(time.Now())); err != nil { + utils.IfaceAsString(args.APIOpts[utils.OptsAPIKey]), utils.TimePointer(time.Now())); err != nil { return } } return dS.Dispatch(&utils.CGREvent{ Tenant: tnt, - Opts: args.Opts, + Opts: args.APIOpts, }, utils.MetaCaches, utils.CacheSv1RemoveItem, args, reply) } // CacheSv1RemoveItems removes the Item with ID from cache -func (dS *DispatcherService) CacheSv1RemoveItems(args utils.AttrReloadCacheWithOpts, +func (dS *DispatcherService) CacheSv1RemoveItems(args utils.AttrReloadCacheWithAPIOpts, reply *string) (err error) { tnt := dS.cfg.GeneralCfg().DefaultTenant if args.Tenant != utils.EmptyString { @@ -132,13 +132,13 @@ func (dS *DispatcherService) CacheSv1RemoveItems(args utils.AttrReloadCacheWithO } if len(dS.cfg.DispatcherSCfg().AttributeSConns) != 0 { if err = dS.authorize(utils.CacheSv1RemoveItems, tnt, - utils.IfaceAsString(args.Opts[utils.OptsAPIKey]), utils.TimePointer(time.Now())); err != nil { + utils.IfaceAsString(args.APIOpts[utils.OptsAPIKey]), utils.TimePointer(time.Now())); err != nil { return } } return dS.Dispatch(&utils.CGREvent{ Tenant: tnt, - Opts: args.Opts, + Opts: args.APIOpts, }, utils.MetaCaches, utils.CacheSv1RemoveItems, args, reply) } @@ -151,13 +151,13 @@ func (dS *DispatcherService) CacheSv1Clear(args *utils.AttrCacheIDsWithOpts, } if len(dS.cfg.DispatcherSCfg().AttributeSConns) != 0 { if err = dS.authorize(utils.CacheSv1Clear, tnt, - utils.IfaceAsString(args.Opts[utils.OptsAPIKey]), utils.TimePointer(time.Now())); err != nil { + utils.IfaceAsString(args.APIOpts[utils.OptsAPIKey]), utils.TimePointer(time.Now())); err != nil { return } } return dS.Dispatch(&utils.CGREvent{ Tenant: tnt, - Opts: args.Opts, + Opts: args.APIOpts, }, utils.MetaCaches, utils.CacheSv1Clear, args, reply) } @@ -170,13 +170,13 @@ func (dS *DispatcherService) CacheSv1GetCacheStats(args *utils.AttrCacheIDsWithO } if len(dS.cfg.DispatcherSCfg().AttributeSConns) != 0 { if err = dS.authorize(utils.CacheSv1GetCacheStats, tnt, - utils.IfaceAsString(args.Opts[utils.OptsAPIKey]), utils.TimePointer(time.Now())); err != nil { + utils.IfaceAsString(args.APIOpts[utils.OptsAPIKey]), utils.TimePointer(time.Now())); err != nil { return } } return dS.Dispatch(&utils.CGREvent{ Tenant: tnt, - Opts: args.Opts, + Opts: args.APIOpts, }, utils.MetaCaches, utils.CacheSv1GetCacheStats, args, reply) } @@ -188,13 +188,13 @@ func (dS *DispatcherService) CacheSv1PrecacheStatus(args *utils.AttrCacheIDsWith } if len(dS.cfg.DispatcherSCfg().AttributeSConns) != 0 { if err = dS.authorize(utils.CacheSv1PrecacheStatus, tnt, - utils.IfaceAsString(args.Opts[utils.OptsAPIKey]), utils.TimePointer(time.Now())); err != nil { + utils.IfaceAsString(args.APIOpts[utils.OptsAPIKey]), utils.TimePointer(time.Now())); err != nil { return } } return dS.Dispatch(&utils.CGREvent{ Tenant: tnt, - Opts: args.Opts, + Opts: args.APIOpts, }, utils.MetaCaches, utils.CacheSv1PrecacheStatus, args, reply) } @@ -255,38 +255,38 @@ func (dS *DispatcherService) CacheSv1RemoveGroup(args *utils.ArgsGetGroupWithOpt } // CacheSv1ReloadCache reloads cache from DB for a prefix or completely -func (dS *DispatcherService) CacheSv1ReloadCache(args utils.AttrReloadCacheWithOpts, reply *string) (err error) { +func (dS *DispatcherService) CacheSv1ReloadCache(args utils.AttrReloadCacheWithAPIOpts, reply *string) (err error) { tnt := dS.cfg.GeneralCfg().DefaultTenant if args.Tenant != utils.EmptyString { tnt = args.Tenant } if len(dS.cfg.DispatcherSCfg().AttributeSConns) != 0 { if err = dS.authorize(utils.CacheSv1ReloadCache, tnt, - utils.IfaceAsString(args.Opts[utils.OptsAPIKey]), utils.TimePointer(time.Now())); err != nil { + utils.IfaceAsString(args.APIOpts[utils.OptsAPIKey]), utils.TimePointer(time.Now())); err != nil { return } } return dS.Dispatch(&utils.CGREvent{ Tenant: tnt, - Opts: args.Opts, + Opts: args.APIOpts, }, utils.MetaCaches, utils.CacheSv1ReloadCache, args, reply) } // CacheSv1LoadCache loads cache from DB for a prefix or completely -func (dS *DispatcherService) CacheSv1LoadCache(args utils.AttrReloadCacheWithOpts, reply *string) (err error) { +func (dS *DispatcherService) CacheSv1LoadCache(args utils.AttrReloadCacheWithAPIOpts, reply *string) (err error) { tnt := dS.cfg.GeneralCfg().DefaultTenant if args.Tenant != utils.EmptyString { tnt = args.Tenant } if len(dS.cfg.DispatcherSCfg().AttributeSConns) != 0 { if err = dS.authorize(utils.CacheSv1LoadCache, tnt, - utils.IfaceAsString(args.Opts[utils.OptsAPIKey]), utils.TimePointer(time.Now())); err != nil { + utils.IfaceAsString(args.APIOpts[utils.OptsAPIKey]), utils.TimePointer(time.Now())); err != nil { return } } return dS.Dispatch(&utils.CGREvent{ Tenant: tnt, - Opts: args.Opts, + Opts: args.APIOpts, }, utils.MetaCaches, utils.CacheSv1LoadCache, args, reply) } diff --git a/dispatchers/caches_it_test.go b/dispatchers/caches_it_test.go index 3bd34f353..397b051a5 100644 --- a/dispatchers/caches_it_test.go +++ b/dispatchers/caches_it_test.go @@ -103,7 +103,7 @@ func testDspChcLoadAfterFolder(t *testing.T) { expStats[utils.CacheLoadIDs].Items = 17 expStats[utils.CacheRPCConnections].Items = 2 args := utils.AttrCacheIDsWithOpts{ - Opts: map[string]interface{}{ + APIOpts: map[string]interface{}{ utils.OptsAPIKey: "chc12345", }, Tenant: "cgrates.org", @@ -115,8 +115,8 @@ func testDspChcLoadAfterFolder(t *testing.T) { } reply := "" // Simple test that command is executed without errors - if err := dispEngine.RPC.Call(utils.CacheSv1LoadCache, utils.AttrReloadCacheWithOpts{ - Opts: map[string]interface{}{ + if err := dispEngine.RPC.Call(utils.CacheSv1LoadCache, utils.AttrReloadCacheWithAPIOpts{ + APIOpts: map[string]interface{}{ utils.OptsAPIKey: "chc12345", }, Tenant: "cgrates.org", @@ -251,7 +251,7 @@ func testDspChcPrecacheStatus(t *testing.T) { } if err := dispEngine.RPC.Call(utils.CacheSv1PrecacheStatus, utils.AttrCacheIDsWithOpts{ - Opts: map[string]interface{}{ + APIOpts: map[string]interface{}{ utils.OptsAPIKey: "chc12345", }, Tenant: "cgrates.org", @@ -265,11 +265,11 @@ func testDspChcPrecacheStatus(t *testing.T) { func testDspChcGetItemIDs(t *testing.T) { var rcvKeys []string expKeys := []string{"cgrates.org:DEFAULT", "cgrates.org:Raw"} - argsAPI := utils.ArgsGetCacheItemIDsWithOpts{ + argsAPI := utils.ArgsGetCacheItemIDsWithAPIOpts{ ArgsGetCacheItemIDs: utils.ArgsGetCacheItemIDs{ CacheID: utils.CacheChargerProfiles, }, - Opts: map[string]interface{}{ + APIOpts: map[string]interface{}{ utils.OptsAPIKey: "chc12345", }, Tenant: "cgrates.org", @@ -286,12 +286,12 @@ func testDspChcGetItemIDs(t *testing.T) { func testDspChcHasItem(t *testing.T) { var reply bool expected := true - argsAPI := utils.ArgsGetCacheItemWithOpts{ + argsAPI := utils.ArgsGetCacheItemWithAPIOpts{ ArgsGetCacheItem: utils.ArgsGetCacheItem{ CacheID: utils.CacheChargerProfiles, ItemID: "cgrates.org:DEFAULT", }, - Opts: map[string]interface{}{ + APIOpts: map[string]interface{}{ utils.OptsAPIKey: "chc12345", }, Tenant: "cgrates.org", @@ -306,12 +306,12 @@ func testDspChcHasItem(t *testing.T) { func testDspChcGetItemExpiryTime(t *testing.T) { var reply time.Time var expected time.Time - argsAPI := utils.ArgsGetCacheItemWithOpts{ + argsAPI := utils.ArgsGetCacheItemWithAPIOpts{ ArgsGetCacheItem: utils.ArgsGetCacheItem{ CacheID: utils.CacheChargerProfiles, ItemID: "cgrates.org:DEFAULT", }, - Opts: map[string]interface{}{ + APIOpts: map[string]interface{}{ utils.OptsAPIKey: "chc12345", }, Tenant: "cgrates.org", @@ -325,8 +325,8 @@ func testDspChcGetItemExpiryTime(t *testing.T) { func testDspChcReloadCache(t *testing.T) { reply := "" - if err := dispEngine.RPC.Call(utils.CacheSv1ReloadCache, &utils.AttrReloadCacheWithOpts{ - Opts: map[string]interface{}{ + if err := dispEngine.RPC.Call(utils.CacheSv1ReloadCache, &utils.AttrReloadCacheWithAPIOpts{ + APIOpts: map[string]interface{}{ utils.OptsAPIKey: "chc12345", }, Tenant: "cgrates.org", @@ -339,12 +339,12 @@ func testDspChcReloadCache(t *testing.T) { func testDspChcRemoveItem(t *testing.T) { var reply bool - argsAPI := utils.ArgsGetCacheItemWithOpts{ + argsAPI := utils.ArgsGetCacheItemWithAPIOpts{ ArgsGetCacheItem: utils.ArgsGetCacheItem{ CacheID: utils.CacheChargerProfiles, ItemID: "cgrates.org:DEFAULT", }, - Opts: map[string]interface{}{ + APIOpts: map[string]interface{}{ utils.OptsAPIKey: "chc12345", }, Tenant: "cgrates.org", @@ -370,7 +370,7 @@ func testDspChcRemoveItem(t *testing.T) { func testDspChcClear(t *testing.T) { reply := "" if err := dispEngine.RPC.Call(utils.CacheSv1Clear, utils.AttrCacheIDsWithOpts{ - Opts: map[string]interface{}{ + APIOpts: map[string]interface{}{ utils.OptsAPIKey: "chc12345", }, Tenant: "cgrates.org", @@ -382,7 +382,7 @@ func testDspChcClear(t *testing.T) { var rcvStats map[string]*ltcache.CacheStats expStats := engine.GetDefaultEmptyCacheStats() if err := dispEngine.RPC.Call(utils.CacheSv1GetCacheStats, utils.AttrCacheIDsWithOpts{ - Opts: map[string]interface{}{ + APIOpts: map[string]interface{}{ utils.OptsAPIKey: "chc12345", }, Tenant: "cgrates.org", diff --git a/dispatchers/core.go b/dispatchers/core.go index 5cdb3fef9..9d3ea0db4 100644 --- a/dispatchers/core.go +++ b/dispatchers/core.go @@ -24,7 +24,7 @@ import ( "github.com/cgrates/cgrates/utils" ) -func (dS *DispatcherService) CoreSv1Status(args *utils.TenantWithOpts, +func (dS *DispatcherService) CoreSv1Status(args *utils.TenantWithAPIOpts, reply *map[string]interface{}) (err error) { tnt := dS.cfg.GeneralCfg().DefaultTenant if args.Tenant != utils.EmptyString { @@ -32,13 +32,13 @@ func (dS *DispatcherService) CoreSv1Status(args *utils.TenantWithOpts, } if len(dS.cfg.DispatcherSCfg().AttributeSConns) != 0 { if err = dS.authorize(utils.CoreSv1Status, tnt, - utils.IfaceAsString(args.Opts[utils.OptsAPIKey]), utils.TimePointer(time.Now())); err != nil { + utils.IfaceAsString(args.APIOpts[utils.OptsAPIKey]), utils.TimePointer(time.Now())); err != nil { return } } return dS.Dispatch(&utils.CGREvent{ Tenant: tnt, - Opts: args.Opts, + Opts: args.APIOpts, }, utils.MetaCore, utils.CoreSv1Status, args, reply) } diff --git a/dispatchers/core_it_test.go b/dispatchers/core_it_test.go index 81d1483f0..11c7d0650 100644 --- a/dispatchers/core_it_test.go +++ b/dispatchers/core_it_test.go @@ -61,9 +61,9 @@ func TestDspCoreIT(t *testing.T) { func testDspCoreLoad(t *testing.T) { var status map[string]interface{} - statusTnt := utils.TenantWithOpts{ + statusTnt := utils.TenantWithAPIOpts{ Tenant: "cgrates.org", - Opts: map[string]interface{}{ + APIOpts: map[string]interface{}{ utils.OptsAPIKey: "core12345", utils.OptsRouteID: "core1", "EventType": "LoadDispatcher", @@ -85,9 +85,9 @@ func testDspCoreLoad(t *testing.T) { }, } var rply string - statusTnt2 := utils.TenantWithOpts{ + statusTnt2 := utils.TenantWithAPIOpts{ Tenant: "cgrates.org", - Opts: map[string]interface{}{ + APIOpts: map[string]interface{}{ utils.OptsAPIKey: "core12345", "EventType": "LoadDispatcher", }, diff --git a/dispatchers/replicator.go b/dispatchers/replicator.go index 874e20a46..5a5eda3c1 100644 --- a/dispatchers/replicator.go +++ b/dispatchers/replicator.go @@ -512,37 +512,37 @@ func (dS *DispatcherService) ReplicatorSv1GetItemLoadIDs(args *utils.StringWithO }, utils.MetaReplicator, utils.ReplicatorSv1GetItemLoadIDs, args, rpl) } -func (dS *DispatcherService) ReplicatorSv1SetThresholdProfile(args *engine.ThresholdProfileWithOpts, rpl *string) (err error) { +func (dS *DispatcherService) ReplicatorSv1SetThresholdProfile(args *engine.ThresholdProfileWithAPIOpts, rpl *string) (err error) { if args == nil { - args = &engine.ThresholdProfileWithOpts{} + args = &engine.ThresholdProfileWithAPIOpts{} } args.ThresholdProfile.Tenant = utils.FirstNonEmpty(args.ThresholdProfile.Tenant, dS.cfg.GeneralCfg().DefaultTenant) if len(dS.cfg.DispatcherSCfg().AttributeSConns) != 0 { if err = dS.authorize(utils.ReplicatorSv1SetThresholdProfile, args.ThresholdProfile.Tenant, - utils.IfaceAsString(args.Opts[utils.OptsAPIKey]), utils.TimePointer(time.Now())); err != nil { + utils.IfaceAsString(args.APIOpts[utils.OptsAPIKey]), utils.TimePointer(time.Now())); err != nil { return } } return dS.Dispatch(&utils.CGREvent{ Tenant: args.ThresholdProfile.Tenant, - Opts: args.Opts, + Opts: args.APIOpts, }, utils.MetaReplicator, utils.ReplicatorSv1SetThresholdProfile, args, rpl) } -func (dS *DispatcherService) ReplicatorSv1SetThreshold(args *engine.ThresholdWithOpts, rpl *string) (err error) { +func (dS *DispatcherService) ReplicatorSv1SetThreshold(args *engine.ThresholdWithAPIOpts, rpl *string) (err error) { if args == nil { - args = &engine.ThresholdWithOpts{} + args = &engine.ThresholdWithAPIOpts{} } args.Tenant = utils.FirstNonEmpty(args.Tenant, dS.cfg.GeneralCfg().DefaultTenant) if len(dS.cfg.DispatcherSCfg().AttributeSConns) != 0 { if err = dS.authorize(utils.ReplicatorSv1SetThreshold, args.Tenant, - utils.IfaceAsString(args.Opts[utils.OptsAPIKey]), utils.TimePointer(time.Now())); err != nil { + utils.IfaceAsString(args.APIOpts[utils.OptsAPIKey]), utils.TimePointer(time.Now())); err != nil { return } } return dS.Dispatch(&utils.CGREvent{ Tenant: args.Tenant, - Opts: args.Opts, + Opts: args.APIOpts, }, utils.MetaReplicator, utils.ReplicatorSv1SetThreshold, args, rpl) } @@ -597,20 +597,20 @@ func (dS *DispatcherService) ReplicatorSv1SetReverseDestination(args *engine.Des }, utils.MetaReplicator, utils.ReplicatorSv1SetReverseDestination, args, rpl) } -func (dS *DispatcherService) ReplicatorSv1SetStatQueue(args *engine.StatQueueWithOpts, rpl *string) (err error) { +func (dS *DispatcherService) ReplicatorSv1SetStatQueue(args *engine.StatQueueWithAPIOpts, rpl *string) (err error) { if args == nil { - args = &engine.StatQueueWithOpts{} + args = &engine.StatQueueWithAPIOpts{} } args.Tenant = utils.FirstNonEmpty(args.Tenant, dS.cfg.GeneralCfg().DefaultTenant) if len(dS.cfg.DispatcherSCfg().AttributeSConns) != 0 { if err = dS.authorize(utils.ReplicatorSv1SetStatQueue, args.Tenant, - utils.IfaceAsString(args.Opts[utils.OptsAPIKey]), utils.TimePointer(time.Now())); err != nil { + utils.IfaceAsString(args.APIOpts[utils.OptsAPIKey]), utils.TimePointer(time.Now())); err != nil { return } } return dS.Dispatch(&utils.CGREvent{ Tenant: args.Tenant, - Opts: args.Opts, + Opts: args.APIOpts, }, utils.MetaReplicator, utils.ReplicatorSv1SetStatQueue, args, rpl) } @@ -869,20 +869,20 @@ func (dS *DispatcherService) ReplicatorSv1SetRateProfile(args *engine.RateProfil }, utils.MetaReplicator, utils.ReplicatorSv1SetRateProfile, args, rpl) } -func (dS *DispatcherService) ReplicatorSv1SetActionProfile(args *engine.ActionProfileWithOpts, rpl *string) (err error) { +func (dS *DispatcherService) ReplicatorSv1SetActionProfile(args *engine.ActionProfileWithAPIOpts, rpl *string) (err error) { if args == nil { - args = &engine.ActionProfileWithOpts{} + args = &engine.ActionProfileWithAPIOpts{} } args.Tenant = utils.FirstNonEmpty(args.Tenant, dS.cfg.GeneralCfg().DefaultTenant) if len(dS.cfg.DispatcherSCfg().AttributeSConns) != 0 { if err = dS.authorize(utils.ReplicatorSv1SetActionProfile, args.Tenant, - utils.IfaceAsString(args.Opts[utils.OptsAPIKey]), utils.TimePointer(time.Now())); err != nil { + utils.IfaceAsString(args.APIOpts[utils.OptsAPIKey]), utils.TimePointer(time.Now())); err != nil { return } } return dS.Dispatch(&utils.CGREvent{ Tenant: args.Tenant, - Opts: args.Opts, + Opts: args.APIOpts, }, utils.MetaReplicator, utils.ReplicatorSv1SetActionProfile, args, rpl) } diff --git a/dispatchers/replicator_it_test.go b/dispatchers/replicator_it_test.go index 8106c81cd..0240e5e4e 100644 --- a/dispatchers/replicator_it_test.go +++ b/dispatchers/replicator_it_test.go @@ -555,12 +555,12 @@ func testDspRplFilter(t *testing.T) { func testDspRplThreshold(t *testing.T) { // Set Threshold var replyStr string - setThreshold := &engine.ThresholdWithOpts{ + setThreshold := &engine.ThresholdWithAPIOpts{ Threshold: &engine.Threshold{ Tenant: "cgrates.org", ID: "ID", }, - Opts: map[string]interface{}{ + APIOpts: map[string]interface{}{ utils.OptsAPIKey: "repl12345", }, } @@ -614,12 +614,12 @@ func testDspRplThreshold(t *testing.T) { func testDspRplThresholdProfile(t *testing.T) { // Set ThresholdProfile var replyStr string - setThresholdProfile := &engine.ThresholdProfileWithOpts{ + setThresholdProfile := &engine.ThresholdProfileWithAPIOpts{ ThresholdProfile: &engine.ThresholdProfile{ Tenant: "cgrates.org", ID: "ID", }, - Opts: map[string]interface{}{ + APIOpts: map[string]interface{}{ utils.OptsAPIKey: "repl12345", }, } @@ -673,12 +673,12 @@ func testDspRplThresholdProfile(t *testing.T) { func testDspRplStatQueue(t *testing.T) { // Set StatQueue var replyStr string - setStatQueue := &engine.StatQueueWithOpts{ + setStatQueue := &engine.StatQueueWithAPIOpts{ StatQueue: &engine.StatQueue{ Tenant: "cgrates.org", ID: "ID", }, - Opts: map[string]interface{}{ + APIOpts: map[string]interface{}{ utils.OptsAPIKey: "repl12345", }, } @@ -1620,12 +1620,12 @@ func testDspRplAccountProfile(t *testing.T) { func testDspRplActionProfile(t *testing.T) { // Set RateProfile var replyStr string - rPrf := &engine.ActionProfileWithOpts{ + rPrf := &engine.ActionProfileWithAPIOpts{ ActionProfile: &engine.ActionProfile{ Tenant: "cgrates.org", ID: "RP1", }, - Opts: map[string]interface{}{ + APIOpts: map[string]interface{}{ utils.OptsAPIKey: "repl12345", }, } diff --git a/dispatchers/responder.go b/dispatchers/responder.go index 3ff8f8edc..c9a1cf1fd 100644 --- a/dispatchers/responder.go +++ b/dispatchers/responder.go @@ -107,17 +107,17 @@ func (dS *DispatcherService) ResponderGetMaxSessionTime(args *engine.CallDescrip return dS.Dispatch(args.AsCGREvent(args.APIOpts), utils.MetaResponder, utils.ResponderGetMaxSessionTime, args, reply) } -func (dS *DispatcherService) ResponderShutdown(args *utils.TenantWithOpts, +func (dS *DispatcherService) ResponderShutdown(args *utils.TenantWithAPIOpts, reply *string) (err error) { tnt := utils.FirstNonEmpty(args.Tenant, dS.cfg.GeneralCfg().DefaultTenant) if len(dS.cfg.DispatcherSCfg().AttributeSConns) != 0 { if err = dS.authorize(utils.ResponderShutdown, tnt, - utils.IfaceAsString(args.Opts[utils.OptsAPIKey]), utils.TimePointer(time.Now())); err != nil { + utils.IfaceAsString(args.APIOpts[utils.OptsAPIKey]), utils.TimePointer(time.Now())); err != nil { return } } return dS.Dispatch(&utils.CGREvent{ Tenant: tnt, - Opts: args.Opts, + Opts: args.APIOpts, }, utils.MetaResponder, utils.ResponderShutdown, args, reply) } diff --git a/dispatchers/responder_it_test.go b/dispatchers/responder_it_test.go index fbccb1efc..7d8a180ff 100644 --- a/dispatchers/responder_it_test.go +++ b/dispatchers/responder_it_test.go @@ -67,14 +67,14 @@ func TestDspResponder(t *testing.T) { func testDspResponderStatus(t *testing.T) { var reply map[string]interface{} - if err := allEngine.RPC.Call(utils.CoreSv1Status, utils.TenantWithOpts{}, &reply); err != nil { + if err := allEngine.RPC.Call(utils.CoreSv1Status, utils.TenantWithAPIOpts{}, &reply); err != nil { t.Error(err) } else if reply[utils.NodeID] != "ALL" { t.Errorf("Received: %s", reply) } - ev := utils.TenantWithOpts{ + ev := utils.TenantWithAPIOpts{ Tenant: "cgrates.org", - Opts: map[string]interface{}{ + APIOpts: map[string]interface{}{ utils.OptsAPIKey: "rsp12345", }, } @@ -106,9 +106,9 @@ func getNodeWithRoute(route string, t *testing.T) string { utils.OptsRouteID: route, }, } - ev := utils.TenantWithOpts{ + ev := utils.TenantWithAPIOpts{ Tenant: "cgrates.org", - Opts: map[string]interface{}{ + APIOpts: map[string]interface{}{ utils.OptsAPIKey: "rsp12345", utils.OptsRouteID: route, }, @@ -141,9 +141,9 @@ func testDspResponderRandom(t *testing.T) { func testDspResponderShutdown(t *testing.T) { var reply string var statusReply map[string]interface{} - ev := utils.TenantWithOpts{ + ev := utils.TenantWithAPIOpts{ Tenant: "cgrates.org", - Opts: map[string]interface{}{ + APIOpts: map[string]interface{}{ utils.OptsAPIKey: "rsp12345", }, } @@ -216,9 +216,9 @@ func testDspResponderInternal(t *testing.T) { utils.OptsRouteID: route, }, } - ev := utils.TenantWithOpts{ + ev := utils.TenantWithAPIOpts{ Tenant: "cgrates.org", - Opts: map[string]interface{}{ + APIOpts: map[string]interface{}{ utils.OptsAPIKey: "rsp12345", utils.OptsRouteID: route, }, diff --git a/dispatchers/sessions.go b/dispatchers/sessions.go index c21180756..92a5f3c70 100755 --- a/dispatchers/sessions.go +++ b/dispatchers/sessions.go @@ -96,7 +96,7 @@ func (dS *DispatcherService) SessionSv1UpdateSession(args *sessions.V1UpdateSess return dS.Dispatch(args.CGREvent, utils.MetaSessionS, utils.SessionSv1UpdateSession, args, reply) } -func (dS *DispatcherService) SessionSv1SyncSessions(args *utils.TenantWithOpts, +func (dS *DispatcherService) SessionSv1SyncSessions(args *utils.TenantWithAPIOpts, reply *string) (err error) { tnt := dS.cfg.GeneralCfg().DefaultTenant if args.Tenant != utils.EmptyString { @@ -104,13 +104,13 @@ func (dS *DispatcherService) SessionSv1SyncSessions(args *utils.TenantWithOpts, } if len(dS.cfg.DispatcherSCfg().AttributeSConns) != 0 { if err = dS.authorize(utils.SessionSv1SyncSessions, tnt, - utils.IfaceAsString(args.Opts[utils.OptsAPIKey]), utils.TimePointer(time.Now())); err != nil { + utils.IfaceAsString(args.APIOpts[utils.OptsAPIKey]), utils.TimePointer(time.Now())); err != nil { return } } return dS.Dispatch(&utils.CGREvent{ Tenant: tnt, - Opts: args.Opts, + Opts: args.APIOpts, }, utils.MetaSessionS, utils.SessionSv1SyncSessions, args, reply) } @@ -264,7 +264,7 @@ func (dS *DispatcherService) SessionSv1GetPassiveSessionsCount(args *utils.Sessi }, utils.MetaSessionS, utils.SessionSv1GetPassiveSessionsCount, args, reply) } -func (dS *DispatcherService) SessionSv1ReplicateSessions(args ArgsReplicateSessionsWithOpts, +func (dS *DispatcherService) SessionSv1ReplicateSessions(args ArgsReplicateSessionsWithAPIOpts, reply *string) (err error) { tnt := dS.cfg.GeneralCfg().DefaultTenant if args.Tenant != utils.EmptyString { @@ -272,13 +272,13 @@ func (dS *DispatcherService) SessionSv1ReplicateSessions(args ArgsReplicateSessi } if len(dS.cfg.DispatcherSCfg().AttributeSConns) != 0 { if err = dS.authorize(utils.SessionSv1ReplicateSessions, tnt, - utils.IfaceAsString(args.Opts[utils.OptsAPIKey]), utils.TimePointer(time.Now())); err != nil { + utils.IfaceAsString(args.APIOpts[utils.OptsAPIKey]), utils.TimePointer(time.Now())); err != nil { return } } return dS.Dispatch(&utils.CGREvent{ Tenant: tnt, - Opts: args.Opts, + Opts: args.APIOpts, }, utils.MetaSessionS, utils.SessionSv1ReplicateSessions, args, reply) } diff --git a/dispatchers/sessions_it_test.go b/dispatchers/sessions_it_test.go index f6bdcbfa9..174814319 100755 --- a/dispatchers/sessions_it_test.go +++ b/dispatchers/sessions_it_test.go @@ -742,8 +742,8 @@ func testDspSessionReplicate(t *testing.T) { testDspSessionAuthorize(t) testDspSessionInit(t) - if err := dispEngine.RPC.Call(utils.SessionSv1ReplicateSessions, &ArgsReplicateSessionsWithOpts{ - Opts: map[string]interface{}{ + if err := dispEngine.RPC.Call(utils.SessionSv1ReplicateSessions, &ArgsReplicateSessionsWithAPIOpts{ + APIOpts: map[string]interface{}{ utils.OptsAPIKey: "ses12345", }, Tenant: "cgrates.org", diff --git a/dispatchers/stats.go b/dispatchers/stats.go index 5df0492c9..5d2fb70b9 100755 --- a/dispatchers/stats.go +++ b/dispatchers/stats.go @@ -99,7 +99,7 @@ func (dS *DispatcherService) StatSv1GetQueueFloatMetrics(args *utils.TenantIDWit }, utils.MetaStats, utils.StatSv1GetQueueFloatMetrics, args, reply) } -func (dS *DispatcherService) StatSv1GetQueueIDs(args *utils.TenantWithOpts, +func (dS *DispatcherService) StatSv1GetQueueIDs(args *utils.TenantWithAPIOpts, reply *[]string) (err error) { tnt := dS.cfg.GeneralCfg().DefaultTenant if args.Tenant != utils.EmptyString { @@ -107,12 +107,12 @@ func (dS *DispatcherService) StatSv1GetQueueIDs(args *utils.TenantWithOpts, } if len(dS.cfg.DispatcherSCfg().AttributeSConns) != 0 { if err = dS.authorize(utils.StatSv1GetQueueIDs, tnt, - utils.IfaceAsString(args.Opts[utils.OptsAPIKey]), utils.TimePointer(time.Now())); err != nil { + utils.IfaceAsString(args.APIOpts[utils.OptsAPIKey]), utils.TimePointer(time.Now())); err != nil { return } } return dS.Dispatch(&utils.CGREvent{ Tenant: tnt, - Opts: args.Opts, + Opts: args.APIOpts, }, utils.MetaStats, utils.StatSv1GetQueueIDs, args, reply) } diff --git a/dispatchers/stats_it_test.go b/dispatchers/stats_it_test.go index 89fdcb0ac..ab1a9ced6 100755 --- a/dispatchers/stats_it_test.go +++ b/dispatchers/stats_it_test.go @@ -320,9 +320,9 @@ func testDspStsTestAuthKey3(t *testing.T) { estats := []string{"Stats2", "Stats2_1"} if err := dispEngine.RPC.Call(utils.StatSv1GetQueueIDs, - &utils.TenantWithOpts{ + &utils.TenantWithAPIOpts{ Tenant: "cgrates.org", - Opts: map[string]interface{}{ + APIOpts: map[string]interface{}{ utils.OptsAPIKey: "stat12345", }, }, &reply); err != nil { diff --git a/dispatchers/thresholds.go b/dispatchers/thresholds.go index 4fd91941c..f4f2ae818 100755 --- a/dispatchers/thresholds.go +++ b/dispatchers/thresholds.go @@ -65,20 +65,20 @@ func (dS *DispatcherService) ThresholdSv1ProcessEvent(args *engine.ThresholdsArg return dS.Dispatch(args.CGREvent, utils.MetaThresholds, utils.ThresholdSv1ProcessEvent, args, tIDs) } -func (dS *DispatcherService) ThresholdSv1GetThresholdIDs(args *utils.TenantWithOpts, tIDs *[]string) (err error) { +func (dS *DispatcherService) ThresholdSv1GetThresholdIDs(args *utils.TenantWithAPIOpts, tIDs *[]string) (err error) { tnt := dS.cfg.GeneralCfg().DefaultTenant if args.Tenant != utils.EmptyString { tnt = args.Tenant } if len(dS.cfg.DispatcherSCfg().AttributeSConns) != 0 { if err = dS.authorize(utils.ThresholdSv1GetThresholdIDs, - tnt, utils.IfaceAsString(args.Opts[utils.OptsAPIKey]), utils.TimePointer(time.Now())); err != nil { + tnt, utils.IfaceAsString(args.APIOpts[utils.OptsAPIKey]), utils.TimePointer(time.Now())); err != nil { return } } return dS.Dispatch(&utils.CGREvent{ Tenant: tnt, - Opts: args.Opts, + Opts: args.APIOpts, }, utils.MetaThresholds, utils.ThresholdSv1GetThresholdIDs, args, tIDs) } diff --git a/dispatchers/thresholds_it_test.go b/dispatchers/thresholds_it_test.go index adcf77c5c..51755805d 100755 --- a/dispatchers/thresholds_it_test.go +++ b/dispatchers/thresholds_it_test.go @@ -250,9 +250,9 @@ func testDspThTestAuthKey3(t *testing.T) { var ids []string eIDs := []string{"THD_ACNT_1002"} - if err := dispEngine.RPC.Call(utils.ThresholdSv1GetThresholdIDs, &utils.TenantWithOpts{ + if err := dispEngine.RPC.Call(utils.ThresholdSv1GetThresholdIDs, &utils.TenantWithAPIOpts{ Tenant: "cgrates.org", - Opts: map[string]interface{}{ + APIOpts: map[string]interface{}{ utils.OptsAPIKey: "thr12345", }, }, &ids); err != nil { diff --git a/dispatchers/utils.go b/dispatchers/utils.go index ed6dcd526..f0c08f31d 100755 --- a/dispatchers/utils.go +++ b/dispatchers/utils.go @@ -28,9 +28,9 @@ import ( "github.com/cgrates/cgrates/utils" ) -type ArgsReplicateSessionsWithOpts struct { - Opts map[string]interface{} - Tenant string +type ArgsReplicateSessionsWithAPIOpts struct { + APIOpts map[string]interface{} + Tenant string sessions.ArgsReplicateSessions } diff --git a/engine/actionprofile.go b/engine/actionprofile.go index c8f57f6f0..a20cc084e 100644 --- a/engine/actionprofile.go +++ b/engine/actionprofile.go @@ -80,8 +80,9 @@ func (dk *APDiktat) RSRValues(sep string) (v config.RSRParsers, err error) { return dk.valRSR, nil } -// ActionProfileWithOpts is used in API calls -type ActionProfileWithOpts struct { +// ActionProfileWithAPIOpts is used in API calls + +type ActionProfileWithAPIOpts struct { *ActionProfile - Opts map[string]interface{} + APIOpts map[string]interface{} } diff --git a/engine/caches.go b/engine/caches.go index 50f135101..f12df8a5a 100644 --- a/engine/caches.go +++ b/engine/caches.go @@ -41,8 +41,8 @@ func init() { // Threshold gob.Register(new(Threshold)) gob.Register(new(ThresholdProfile)) - gob.Register(new(ThresholdProfileWithOpts)) - gob.Register(new(ThresholdWithOpts)) + gob.Register(new(ThresholdProfileWithAPIOpts)) + gob.Register(new(ThresholdWithAPIOpts)) // Resource gob.Register(new(Resource)) gob.Register(new(ResourceProfile)) @@ -69,7 +69,7 @@ func init() { gob.Register(new(RateProfileWithOpts)) // ActionProfiles gob.Register(new(ActionProfile)) - gob.Register(new(ActionProfileWithOpts)) + gob.Register(new(ActionProfileWithAPIOpts)) // CDRs gob.Register(new(EventCost)) @@ -263,7 +263,7 @@ func (chS *CacheS) Call(serviceMethod string, args interface{}, reply interface{ return utils.RPCCall(chS, serviceMethod, args, reply) } -func (chS *CacheS) V1GetItemIDs(args *utils.ArgsGetCacheItemIDsWithOpts, +func (chS *CacheS) V1GetItemIDs(args *utils.ArgsGetCacheItemIDsWithAPIOpts, reply *[]string) (err error) { itmIDs := chS.tCache.GetItemIDs(args.CacheID, args.ItemIDPrefix) if len(itmIDs) == 0 { @@ -273,13 +273,13 @@ func (chS *CacheS) V1GetItemIDs(args *utils.ArgsGetCacheItemIDsWithOpts, return } -func (chS *CacheS) V1HasItem(args *utils.ArgsGetCacheItemWithOpts, +func (chS *CacheS) V1HasItem(args *utils.ArgsGetCacheItemWithAPIOpts, reply *bool) (err error) { *reply = chS.tCache.HasItem(args.CacheID, args.ItemID) return } -func (chS *CacheS) V1GetItemExpiryTime(args *utils.ArgsGetCacheItemWithOpts, +func (chS *CacheS) V1GetItemExpiryTime(args *utils.ArgsGetCacheItemWithAPIOpts, reply *time.Time) (err error) { expTime, has := chS.tCache.GetItemExpiryTime(args.CacheID, args.ItemID) if !has { @@ -289,14 +289,14 @@ func (chS *CacheS) V1GetItemExpiryTime(args *utils.ArgsGetCacheItemWithOpts, return } -func (chS *CacheS) V1RemoveItem(args *utils.ArgsGetCacheItemWithOpts, +func (chS *CacheS) V1RemoveItem(args *utils.ArgsGetCacheItemWithAPIOpts, reply *string) (err error) { chS.tCache.Remove(args.CacheID, args.ItemID, true, utils.NonTransactional) *reply = utils.OK return } -func (chS *CacheS) V1RemoveItems(args utils.AttrReloadCacheWithOpts, +func (chS *CacheS) V1RemoveItems(args utils.AttrReloadCacheWithAPIOpts, reply *string) (err error) { for key, ids := range args.ArgsCache { if cacheID, has := utils.ArgCacheToInstance[key]; has { @@ -365,7 +365,7 @@ func (chS *CacheS) V1RemoveGroup(args *utils.ArgsGetGroupWithOpts, return } -func (chS *CacheS) V1ReloadCache(attrs utils.AttrReloadCacheWithOpts, reply *string) (err error) { +func (chS *CacheS) V1ReloadCache(attrs utils.AttrReloadCacheWithAPIOpts, reply *string) (err error) { for key, ids := range attrs.ArgsCache { if prfx, has := utils.ArgCacheToPrefix[key]; has { if err = chS.dm.CacheDataFromDB(prfx, ids, true); err != nil { @@ -390,7 +390,7 @@ func (chS *CacheS) V1ReloadCache(attrs utils.AttrReloadCacheWithOpts, reply *str return nil } -func (chS *CacheS) V1LoadCache(attrs utils.AttrReloadCacheWithOpts, reply *string) (err error) { +func (chS *CacheS) V1LoadCache(attrs utils.AttrReloadCacheWithAPIOpts, reply *string) (err error) { args := make(map[string][]string) for key, ids := range attrs.ArgsCache { if prfx, has := utils.ArgCacheToPrefix[key]; has { diff --git a/engine/datamanager.go b/engine/datamanager.go index de4e5a523..a9ec1328d 100644 --- a/engine/datamanager.go +++ b/engine/datamanager.go @@ -794,9 +794,9 @@ func (dm *DataManager) SetStatQueue(sq *StatQueue, metrics []*MetricWithFilters, config.CgrConfig().DataDbCfg().RplFiltered, utils.StatQueuePrefix, sq.TenantID(), // this are used to get the host IDs from cache utils.ReplicatorSv1SetStatQueue, - &StatQueueWithOpts{ + &StatQueueWithAPIOpts{ StatQueue: sq, - Opts: utils.GenerateDBItemOpts(itm.APIKey, itm.RouteID, + APIOpts: utils.GenerateDBItemOpts(itm.APIKey, itm.RouteID, config.CgrConfig().DataDbCfg().RplCache, utils.EmptyString)}) } return @@ -1031,9 +1031,9 @@ func (dm *DataManager) SetThreshold(th *Threshold, snooze time.Duration, simpleS config.CgrConfig().DataDbCfg().RplFiltered, utils.ThresholdPrefix, th.TenantID(), // this are used to get the host IDs from cache utils.ReplicatorSv1SetThreshold, - &ThresholdWithOpts{ + &ThresholdWithAPIOpts{ Threshold: th, - Opts: utils.GenerateDBItemOpts(itm.APIKey, itm.RouteID, + APIOpts: utils.GenerateDBItemOpts(itm.APIKey, itm.RouteID, config.CgrConfig().DataDbCfg().RplCache, utils.EmptyString)}) } return @@ -1142,9 +1142,9 @@ func (dm *DataManager) SetThresholdProfile(th *ThresholdProfile, withIndex bool) config.CgrConfig().DataDbCfg().RplFiltered, utils.ThresholdProfilePrefix, th.TenantID(), // this are used to get the host IDs from cache utils.ReplicatorSv1SetThresholdProfile, - &ThresholdProfileWithOpts{ + &ThresholdProfileWithAPIOpts{ ThresholdProfile: th, - Opts: utils.GenerateDBItemOpts(itm.APIKey, itm.RouteID, + APIOpts: utils.GenerateDBItemOpts(itm.APIKey, itm.RouteID, config.CgrConfig().DataDbCfg().RplCache, utils.EmptyString)}) } return @@ -3389,9 +3389,9 @@ func (dm *DataManager) SetActionProfile(ap *ActionProfile, withIndex bool) (err config.CgrConfig().DataDbCfg().RplFiltered, utils.ActionProfilePrefix, ap.TenantID(), // this are used to get the host IDs from cache utils.ReplicatorSv1SetActionProfile, - &ActionProfileWithOpts{ + &ActionProfileWithAPIOpts{ ActionProfile: ap, - Opts: utils.GenerateDBItemOpts(itm.APIKey, itm.RouteID, + APIOpts: utils.GenerateDBItemOpts(itm.APIKey, itm.RouteID, config.CgrConfig().DataDbCfg().RplCache, utils.EmptyString)}) } return diff --git a/engine/libstats.go b/engine/libstats.go index 37d4aecd9..a8a7683a5 100644 --- a/engine/libstats.go +++ b/engine/libstats.go @@ -91,9 +91,9 @@ type StoredStatQueue struct { Compressed bool } -type StatQueueWithOpts struct { +type StatQueueWithAPIOpts struct { *StatQueue - Opts map[string]interface{} + APIOpts map[string]interface{} } // SqID will compose the unique identifier for the StatQueue out of Tenant and ID diff --git a/engine/responder.go b/engine/responder.go index 55a92ae83..b149669de 100644 --- a/engine/responder.go +++ b/engine/responder.go @@ -375,7 +375,7 @@ func (rs *Responder) GetMaxSessionTimeOnAccounts(arg *utils.GetMaxSessionTimeOnA return } -func (rs *Responder) Shutdown(arg *utils.TenantWithOpts, reply *string) (err error) { +func (rs *Responder) Shutdown(arg *utils.TenantWithAPIOpts, reply *string) (err error) { dm.DataDB().Close() cdrStorage.Close() defer rs.ShdChan.CloseOnce() diff --git a/engine/thresholds.go b/engine/thresholds.go index 1a6b12d42..e072415cc 100644 --- a/engine/thresholds.go +++ b/engine/thresholds.go @@ -29,10 +29,10 @@ import ( "github.com/cgrates/cgrates/utils" ) -// ThresholdProfileWithOpts is used in replicatorV1 for dispatcher -type ThresholdProfileWithOpts struct { +// ThresholdProfileWithAPIOpts is used in replicatorV1 for dispatcher +type ThresholdProfileWithAPIOpts struct { *ThresholdProfile - Opts map[string]interface{} + APIOpts map[string]interface{} } // ThresholdProfile the profile for threshold @@ -55,10 +55,10 @@ func (tp *ThresholdProfile) TenantID() string { return utils.ConcatenatedKey(tp.Tenant, tp.ID) } -// ThresholdWithOpts is used in replicatorV1 for dispatcher -type ThresholdWithOpts struct { +// ThresholdWithAPIOpts is used in replicatorV1 for dispatcher +type ThresholdWithAPIOpts struct { *Threshold - Opts map[string]interface{} + APIOpts map[string]interface{} } // Threshold is the unit matched by filters diff --git a/engine/tpreader.go b/engine/tpreader.go index 6488c133c..3e3c74ed4 100644 --- a/engine/tpreader.go +++ b/engine/tpreader.go @@ -793,7 +793,7 @@ func (tpr *TpReader) LoadAccountActionsFiltered(qriedAA *utils.TPAccountActions) } var reply string if err := connMgr.Call(tpr.cacheConns, nil, - utils.CacheSv1ReloadCache, utils.AttrReloadCacheWithOpts{ + utils.CacheSv1ReloadCache, utils.AttrReloadCacheWithAPIOpts{ ArgsCache: map[string][]string{ utils.AccountActionPlanIDs: {id}, utils.ActionPlanIDs: {accountAction.ActionPlanId}, @@ -902,7 +902,7 @@ func (tpr *TpReader) LoadAccountActionsFiltered(qriedAA *utils.TPAccountActions) } var reply string if err := connMgr.Call(tpr.cacheConns, nil, - utils.CacheSv1ReloadCache, utils.AttrReloadCacheWithOpts{ + utils.CacheSv1ReloadCache, utils.AttrReloadCacheWithAPIOpts{ ArgsCache: map[string][]string{ utils.ActionTriggerIDs: {accountAction.ActionTriggersId}, }, @@ -1020,7 +1020,7 @@ func (tpr *TpReader) LoadAccountActionsFiltered(qriedAA *utils.TPAccountActions) } var reply string if err := connMgr.Call(tpr.cacheConns, nil, - utils.CacheSv1ReloadCache, utils.AttrReloadCacheWithOpts{ + utils.CacheSv1ReloadCache, utils.AttrReloadCacheWithAPIOpts{ ArgsCache: map[string][]string{ utils.ActionIDs: {k}, }, @@ -2602,8 +2602,8 @@ func (tpr *TpReader) ReloadCache(caching string, verbose bool, opts map[string]i accountPrfIDs, _ := tpr.GetLoadedIds(utils.AccountProfilePrefix) //compose Reload Cache argument - cacheArgs := utils.AttrReloadCacheWithOpts{ - Opts: opts, + cacheArgs := utils.AttrReloadCacheWithAPIOpts{ + APIOpts: opts, ArgsCache: map[string][]string{ utils.DestinationIDs: dstIds, utils.ReverseDestinationIDs: revDstIDs, @@ -2696,7 +2696,7 @@ func (tpr *TpReader) ReloadCache(caching string, verbose bool, opts map[string]i log.Print("Clearing indexes") } clearArgs := &utils.AttrCacheIDsWithOpts{ - Opts: opts, + APIOpts: opts, CacheIDs: cacheIDs, } if err = connMgr.Call(tpr.cacheConns, nil, utils.CacheSv1Clear, clearArgs, &reply); err != nil { diff --git a/engine/z_actions_it_test.go b/engine/z_actions_it_test.go index 8e5e302f4..309e677d9 100644 --- a/engine/z_actions_it_test.go +++ b/engine/z_actions_it_test.go @@ -339,7 +339,7 @@ func testActionsitThresholdCDrLog(t *testing.T) { err.Error() != utils.ErrNotFound.Error() { t.Error(err) } - tPrfl := ThresholdProfileWithOpts{ + tPrfl := ThresholdProfileWithAPIOpts{ ThresholdProfile: &ThresholdProfile{ Tenant: "cgrates.org", ID: "THD_Test", @@ -558,7 +558,7 @@ func testActionsitThresholdCgrRpcAction(t *testing.T) { err.Error() != utils.ErrNotFound.Error() { t.Error(err) } - tPrfl := &ThresholdProfileWithOpts{ + tPrfl := &ThresholdProfileWithAPIOpts{ ThresholdProfile: &ThresholdProfile{ Tenant: "cgrates.org", ID: "TH_CGRRPC", @@ -623,7 +623,7 @@ func testActionsitThresholdPostEvent(t *testing.T) { err.Error() != utils.ErrNotFound.Error() { t.Error(err) } - tPrfl := &ThresholdProfileWithOpts{ + tPrfl := &ThresholdProfileWithAPIOpts{ ThresholdProfile: &ThresholdProfile{ Tenant: "cgrates.org", ID: "THD_PostEvent", diff --git a/general_tests/accountactions_it_test.go b/general_tests/accountactions_it_test.go index 284d09692..1245a64ef 100644 --- a/general_tests/accountactions_it_test.go +++ b/general_tests/accountactions_it_test.go @@ -114,7 +114,7 @@ func testAccActionsRPCConn(t *testing.T) { } func testAccActionsSetActionProfile(t *testing.T) { - actPrf := &engine.ActionProfileWithOpts{ + actPrf := &engine.ActionProfileWithAPIOpts{ ActionProfile: &engine.ActionProfile{ Tenant: "cgrates.org", ID: "CREATE_ACC", @@ -179,7 +179,7 @@ func testAccActionsSetActionProfile(t *testing.T) { }, }, }, - Opts: map[string]interface{}{}, + APIOpts: map[string]interface{}{}, } var reply string if err := accSRPC.Call(utils.APIerSv1SetActionProfile, actPrf, &reply); err != nil { @@ -280,7 +280,7 @@ func testAccActionsGetAccountAfterActions(t *testing.T) { } func testAccActionsSetActionProfile2(t *testing.T) { - actPrf := &engine.ActionProfileWithOpts{ + actPrf := &engine.ActionProfileWithAPIOpts{ ActionProfile: &engine.ActionProfile{ Tenant: "cgrates.org", ID: "REM_ACC", @@ -303,7 +303,7 @@ func testAccActionsSetActionProfile2(t *testing.T) { }, }, }, - Opts: map[string]interface{}{}, + APIOpts: map[string]interface{}{}, } var reply string if err := accSRPC.Call(utils.APIerSv1SetActionProfile, actPrf, &reply); err != nil { diff --git a/general_tests/accounts_it_test.go b/general_tests/accounts_it_test.go index 0071b13ba..41e59c005 100644 --- a/general_tests/accounts_it_test.go +++ b/general_tests/accounts_it_test.go @@ -249,7 +249,7 @@ func testV1AccSendToThreshold(t *testing.T) { t.Errorf("Calling APIerSv2.SetActions received: %s", reply) } - tPrfl := &engine.ThresholdProfileWithOpts{ + tPrfl := &engine.ThresholdProfileWithAPIOpts{ ThresholdProfile: &engine.ThresholdProfile{ Tenant: "cgrates.org", ID: "THD_AccDisableAndLog", diff --git a/general_tests/cacherpl_it_test.go b/general_tests/cacherpl_it_test.go index d8cb48829..744320ed2 100644 --- a/general_tests/cacherpl_it_test.go +++ b/general_tests/cacherpl_it_test.go @@ -307,9 +307,9 @@ func testCacheRplAAAddData(t *testing.T) { func testCacheRplPing(t *testing.T) { var reply map[string]interface{} - ev := utils.TenantWithOpts{ + ev := utils.TenantWithAPIOpts{ Tenant: "cgrates.org", - Opts: map[string]interface{}{ + APIOpts: map[string]interface{}{ utils.OptsRouteID: "testRoute123", }, } @@ -335,7 +335,7 @@ func testCacheRplPing(t *testing.T) { func testCacheRplCheckReplication(t *testing.T) { var reply map[string]interface{} - ev := utils.TenantWithOpts{ + ev := utils.TenantWithAPIOpts{ Tenant: "cgrates.org", } if err := dspEngine2RPC.Call(utils.CoreSv1Status, &ev, &reply); err != nil { @@ -345,7 +345,7 @@ func testCacheRplCheckReplication(t *testing.T) { } var rcvKeys []string expKeys := []string{"testRoute123:*core", "testRoute123:*attributes"} - argsAPI := utils.ArgsGetCacheItemIDsWithOpts{ + argsAPI := utils.ArgsGetCacheItemIDsWithAPIOpts{ Tenant: "cgrates.org", ArgsGetCacheItemIDs: utils.ArgsGetCacheItemIDs{ CacheID: utils.CacheDispatcherRoutes, @@ -376,7 +376,7 @@ func testCacheRplCheckReplication(t *testing.T) { func testCacheRplAACheckReplication(t *testing.T) { var rcvKeys []string - argsAPI := utils.ArgsGetCacheItemIDsWithOpts{ + argsAPI := utils.ArgsGetCacheItemIDsWithAPIOpts{ Tenant: "cgrates.org", ArgsGetCacheItemIDs: utils.ArgsGetCacheItemIDs{ CacheID: utils.CacheDispatcherRoutes, @@ -439,7 +439,7 @@ func testCacheRplAACheckReplication(t *testing.T) { func testCacheRplAACheckLoadReplication(t *testing.T) { var rcvKeys []string - argsAPI := utils.ArgsGetCacheItemIDsWithOpts{ + argsAPI := utils.ArgsGetCacheItemIDsWithAPIOpts{ Tenant: "cgrates.org", ArgsGetCacheItemIDs: utils.ArgsGetCacheItemIDs{ CacheID: utils.CacheDispatcherLoads, @@ -508,7 +508,7 @@ func testCacheRplAACheckLoadReplication(t *testing.T) { expKeys := []string{"testRouteFromDispatcher1:*attributes", "testRouteFromDispatcher1:*chargers", "testRouteFromDispatcher2:*attributes", "testRouteFromDispatcher2:*chargers"} - argsAPI = utils.ArgsGetCacheItemIDsWithOpts{ + argsAPI = utils.ArgsGetCacheItemIDsWithAPIOpts{ Tenant: "cgrates.org", ArgsGetCacheItemIDs: utils.ArgsGetCacheItemIDs{ CacheID: utils.CacheDispatcherRoutes, @@ -532,7 +532,7 @@ func testCacheRplAACheckLoadReplication(t *testing.T) { } expKeys = []string{"cgrates.org:Engine2"} - argsAPI = utils.ArgsGetCacheItemIDsWithOpts{ + argsAPI = utils.ArgsGetCacheItemIDsWithAPIOpts{ Tenant: "cgrates.org", ArgsGetCacheItemIDs: utils.ArgsGetCacheItemIDs{ CacheID: utils.CacheDispatcherLoads, @@ -558,7 +558,7 @@ func testCacheRplAACheckLoadReplication(t *testing.T) { func testCacheRplCheckLoadReplication(t *testing.T) { var rcvKeys []string - argsAPI := utils.ArgsGetCacheItemIDsWithOpts{ + argsAPI := utils.ArgsGetCacheItemIDsWithAPIOpts{ Tenant: "cgrates.org", ArgsGetCacheItemIDs: utils.ArgsGetCacheItemIDs{ CacheID: utils.CacheDispatcherLoads, @@ -596,7 +596,7 @@ func testCacheRplCheckLoadReplication(t *testing.T) { } wg.Wait() expKeys := []string{"testRoute123:*core", "testRoute123:*attributes", "testRoute123:*chargers"} - argsAPI = utils.ArgsGetCacheItemIDsWithOpts{ + argsAPI = utils.ArgsGetCacheItemIDsWithAPIOpts{ Tenant: "cgrates.org", ArgsGetCacheItemIDs: utils.ArgsGetCacheItemIDs{ CacheID: utils.CacheDispatcherRoutes, @@ -612,7 +612,7 @@ func testCacheRplCheckLoadReplication(t *testing.T) { } expKeys = []string{"cgrates.org:Engine2"} - argsAPI = utils.ArgsGetCacheItemIDsWithOpts{ + argsAPI = utils.ArgsGetCacheItemIDsWithAPIOpts{ Tenant: "cgrates.org", ArgsGetCacheItemIDs: utils.ArgsGetCacheItemIDs{ CacheID: utils.CacheDispatcherLoads, diff --git a/general_tests/cdrs_it_test.go b/general_tests/cdrs_it_test.go index 44b9d69ed..0838dec47 100644 --- a/general_tests/cdrs_it_test.go +++ b/general_tests/cdrs_it_test.go @@ -526,7 +526,7 @@ func testV2CDRsSetThresholdProfile(t *testing.T) { err.Error() != utils.ErrNotFound.Error() { t.Error(err) } - tPrfl := &engine.ThresholdProfileWithOpts{ + tPrfl := &engine.ThresholdProfileWithAPIOpts{ ThresholdProfile: &engine.ThresholdProfile{ Tenant: "cgrates.org", ID: "THD_PoccessCDR", diff --git a/general_tests/cdrs_processevent_it_test.go b/general_tests/cdrs_processevent_it_test.go index 0e466944b..c57ab3b88 100644 --- a/general_tests/cdrs_processevent_it_test.go +++ b/general_tests/cdrs_processevent_it_test.go @@ -450,7 +450,7 @@ func testV1CDRsProcessEventThreshold(t *testing.T) { } else if reply != utils.OK { t.Errorf("Calling APIerSv2.SetActions received: %s", reply) } - tPrfl := engine.ThresholdProfileWithOpts{ + tPrfl := engine.ThresholdProfileWithAPIOpts{ ThresholdProfile: &engine.ThresholdProfile{ Tenant: "cgrates.org", ID: "THD_Test", diff --git a/general_tests/export_it_test.go b/general_tests/export_it_test.go index 7c6bd1c12..c44d85022 100644 --- a/general_tests/export_it_test.go +++ b/general_tests/export_it_test.go @@ -211,7 +211,7 @@ func testExpVerifyFilters(t *testing.T) { } func testExpVerifyThresholds(t *testing.T) { - tPrfl := &engine.ThresholdProfileWithOpts{ + tPrfl := &engine.ThresholdProfileWithAPIOpts{ ThresholdProfile: &engine.ThresholdProfile{ Tenant: "cgrates.org", ID: "THD_ACNT_1001", diff --git a/general_tests/filtered_replication_it_test.go b/general_tests/filtered_replication_it_test.go index 2ca80ab6f..5275cf055 100644 --- a/general_tests/filtered_replication_it_test.go +++ b/general_tests/filtered_replication_it_test.go @@ -375,7 +375,7 @@ func testFltrRplFilters(t *testing.T) { func testFltrRplThresholdProfile(t *testing.T) { thID := "TH1" - thPrfl := &engine.ThresholdProfileWithOpts{ + thPrfl := &engine.ThresholdProfileWithAPIOpts{ ThresholdProfile: &engine.ThresholdProfile{ Tenant: "cgrates.org", ID: thID, @@ -1482,7 +1482,7 @@ func testFltrRplRateProfile(t *testing.T) { func testFltrRplActionProfile(t *testing.T) { acID := "ATTR1" - acPrf := &engine.ActionProfileWithOpts{ + acPrf := &engine.ActionProfileWithAPIOpts{ ActionProfile: &engine.ActionProfile{ Tenant: "cgrates.org", ID: acID, diff --git a/general_tests/filters_it_test.go b/general_tests/filters_it_test.go index ab0b75c76..7dd19cd15 100644 --- a/general_tests/filters_it_test.go +++ b/general_tests/filters_it_test.go @@ -293,7 +293,7 @@ func testV1FltrPopulateThreshold(t *testing.T) { } //Add a threshold with filter from above and an inline filter for Account 1010 - tPrfl := &engine.ThresholdProfileWithOpts{ + tPrfl := &engine.ThresholdProfileWithAPIOpts{ ThresholdProfile: &engine.ThresholdProfile{ Tenant: "cgrates.org", ID: "TH_Stats1", @@ -367,7 +367,7 @@ func testV1FltrGetThresholdForEvent2(t *testing.T) { } //update the threshold with new filter - tPrfl := &engine.ThresholdProfileWithOpts{ + tPrfl := &engine.ThresholdProfileWithAPIOpts{ ThresholdProfile: &engine.ThresholdProfile{ Tenant: "cgrates.org", ID: "TH_Stats1", @@ -470,7 +470,7 @@ func testV1FltrPopulateResources(t *testing.T) { t.Error("Unexpected reply returned", result) } - tPrfl := &engine.ThresholdProfileWithOpts{ + tPrfl := &engine.ThresholdProfileWithAPIOpts{ ThresholdProfile: &engine.ThresholdProfile{ Tenant: "cgrates.org", ID: "TH_ResTest", @@ -742,7 +742,7 @@ func testV1FltrAccounts(t *testing.T) { t.Errorf("Calling APIerSv2.SetActions received: %s", result) } //Add a threshold with filter from above and an inline filter for Account 1010 - tPrfl := &engine.ThresholdProfileWithOpts{ + tPrfl := &engine.ThresholdProfileWithAPIOpts{ ThresholdProfile: &engine.ThresholdProfile{ Tenant: "cgrates.org", ID: "TH_Account", @@ -830,7 +830,7 @@ func testV1FltrAccountsExistsDynamicaly(t *testing.T) { t.Error("Got error on APIerSv2.SetActions: ", err.Error()) } //Add a threshold with filter from above and an inline filter for Account 1010 - tPrfl := &engine.ThresholdProfileWithOpts{ + tPrfl := &engine.ThresholdProfileWithAPIOpts{ ThresholdProfile: &engine.ThresholdProfile{ Tenant: "cgrates.org", ID: "TH_AccountDinamic", diff --git a/general_tests/redis_tls_it_test.go b/general_tests/redis_tls_it_test.go index c334bc5a2..e0c15f9b7 100644 --- a/general_tests/redis_tls_it_test.go +++ b/general_tests/redis_tls_it_test.go @@ -106,7 +106,7 @@ func testRedisTLSRPCCon(t *testing.T) { func testRedisTLSSetGetAttribute(t *testing.T) { // status command to check if the engine starts var rply map[string]interface{} - if err := redisTLSRPC.Call(utils.CoreSv1Status, &utils.TenantWithOpts{}, &rply); err != nil { + if err := redisTLSRPC.Call(utils.CoreSv1Status, &utils.TenantWithAPIOpts{}, &rply); err != nil { t.Error(err) } } diff --git a/general_tests/rpccaching_it_test.go b/general_tests/rpccaching_it_test.go index 574fa7343..2bde3a46b 100644 --- a/general_tests/rpccaching_it_test.go +++ b/general_tests/rpccaching_it_test.go @@ -163,7 +163,7 @@ func testRPCMethodsAddData(t *testing.T) { } //Add a thresholdProfile to disable account - tPrfl := &engine.ThresholdProfileWithOpts{ + tPrfl := &engine.ThresholdProfileWithAPIOpts{ ThresholdProfile: &engine.ThresholdProfile{ Tenant: "cgrates.org", ID: "THD_AccDisableAndLog", @@ -180,7 +180,7 @@ func testRPCMethodsAddData(t *testing.T) { t.Error("Unexpected reply returned", reply) } //Add a thresholdProfile to enable account - tPrfl2 := &engine.ThresholdProfileWithOpts{ + tPrfl2 := &engine.ThresholdProfileWithAPIOpts{ ThresholdProfile: &engine.ThresholdProfile{ Tenant: "cgrates.org", ID: "THD_AccEnableAndLog", diff --git a/general_tests/rpcclient_it_test.go b/general_tests/rpcclient_it_test.go index fdaab071e..5c93d0380 100644 --- a/general_tests/rpcclient_it_test.go +++ b/general_tests/rpcclient_it_test.go @@ -135,12 +135,12 @@ func testRPCITLclRpcConnPoolFirst(t *testing.T) { // Connect rpc client to rater func testRPCITLclStatusSecondEngine(t *testing.T) { var status map[string]interface{} - if err := rpcPoolFirst.Call(utils.CoreSv1Status, utils.TenantWithOpts{}, &status); err != nil { + if err := rpcPoolFirst.Call(utils.CoreSv1Status, utils.TenantWithAPIOpts{}, &status); err != nil { t.Error(err) } else if status[utils.NodeID].(string) == "" { t.Error("Empty NodeID received") } - if err := rpcPoolFirst.Call(utils.CoreSv1Status, utils.TenantWithOpts{}, &status); err != nil { // Make sure second time we land on the same instance + if err := rpcPoolFirst.Call(utils.CoreSv1Status, utils.TenantWithAPIOpts{}, &status); err != nil { // Make sure second time we land on the same instance t.Error(err) } else if status[utils.NodeID].(string) != node2 { t.Errorf("Expecting:\n%s\nReceived:\n%s", node2, status[utils.NodeID].(string)) @@ -157,14 +157,14 @@ func testRPCITLclStartFirstEngine(t *testing.T) { // Connect rpc client to rater func testRPCITLclStatusFirstInitial(t *testing.T) { var status map[string]interface{} - if err := rpcPoolFirst.Call(utils.CoreSv1Status, utils.TenantWithOpts{}, &status); err != nil { + if err := rpcPoolFirst.Call(utils.CoreSv1Status, utils.TenantWithAPIOpts{}, &status); err != nil { t.Error(err) } else if status[utils.NodeID].(string) == "" { t.Error("Empty NodeID received") } else if status[utils.NodeID].(string) == node2 { t.Fatalf("Should receive ralID different than second one, got: %s", status[utils.NodeID].(string)) } - if err := rpcPoolFirst.Call(utils.CoreSv1Status, utils.TenantWithOpts{}, &status); err != nil { // Make sure second time we land on the same instance + if err := rpcPoolFirst.Call(utils.CoreSv1Status, utils.TenantWithAPIOpts{}, &status); err != nil { // Make sure second time we land on the same instance t.Error(err) } else if status[utils.NodeID].(string) != node1 { t.Errorf("Expecting:\n%s\nReceived:\n%s", node1, status[utils.NodeID].(string)) @@ -178,14 +178,14 @@ func testRPCITLclStatusFirstFailover(t *testing.T) { } time.Sleep(time.Duration(*waitRater) * time.Millisecond) var status map[string]interface{} - if err := rpcPoolFirst.Call(utils.CoreSv1Status, utils.TenantWithOpts{}, &status); err != nil { + if err := rpcPoolFirst.Call(utils.CoreSv1Status, utils.TenantWithAPIOpts{}, &status); err != nil { t.Error(err) } else if status[utils.NodeID].(string) == "" { t.Error("Empty NodeID received") } else if status[utils.NodeID].(string) == node1 { t.Fatalf("Should receive ralID different than first one, got: %s", status[utils.NodeID].(string)) } - if err := rpcPoolFirst.Call(utils.CoreSv1Status, utils.TenantWithOpts{}, &status); err != nil { // Make sure second time we land on the same instance + if err := rpcPoolFirst.Call(utils.CoreSv1Status, utils.TenantWithAPIOpts{}, &status); err != nil { // Make sure second time we land on the same instance t.Error(err) } else if status[utils.NodeID].(string) != node2 { t.Errorf("Expecting:\n%s\nReceived:\n%s", node2, status[utils.NodeID].(string)) @@ -197,12 +197,12 @@ func testRPCITLclStatusFirstFailback(t *testing.T) { t.Fatal(err) } var status map[string]interface{} - if err := rpcPoolFirst.Call(utils.CoreSv1Status, utils.TenantWithOpts{}, &status); err != nil { + if err := rpcPoolFirst.Call(utils.CoreSv1Status, utils.TenantWithAPIOpts{}, &status); err != nil { t.Error(err) } else if status[utils.NodeID].(string) == node2 { t.Error("Should receive new ID") } - if err := rpcPoolFirst.Call(utils.CoreSv1Status, utils.TenantWithOpts{}, &status); err != nil { // Make sure second time we land on the same instance + if err := rpcPoolFirst.Call(utils.CoreSv1Status, utils.TenantWithAPIOpts{}, &status); err != nil { // Make sure second time we land on the same instance t.Error(err) } else if status[utils.NodeID].(string) != node1 { t.Errorf("Expecting:\n%s\nReceived:\n%s", node2, status[utils.NodeID].(string)) @@ -235,12 +235,12 @@ func testRPCITLclRpcConnPoolBcast(t *testing.T) { func testRPCITLclBcastStatusInitial(t *testing.T) { var status map[string]interface{} - if err := rpcPoolBroadcast.Call(utils.CoreSv1Status, utils.TenantWithOpts{}, &status); err != nil { + if err := rpcPoolBroadcast.Call(utils.CoreSv1Status, utils.TenantWithAPIOpts{}, &status); err != nil { t.Error(err) } else if status[utils.NodeID].(string) == "" { t.Error("Empty NodeID received") } - if err := rpcPoolBroadcast.Call(utils.CoreSv1Status, utils.TenantWithOpts{}, &status); err != nil { + if err := rpcPoolBroadcast.Call(utils.CoreSv1Status, utils.TenantWithAPIOpts{}, &status); err != nil { t.Error(err) } else if status[utils.NodeID].(string) == "" { t.Error("Empty NodeID received") @@ -253,12 +253,12 @@ func testRPCITLclBcastStatusNoRals1(t *testing.T) { } time.Sleep(time.Duration(*waitRater) * time.Millisecond) var status map[string]interface{} - if err := rpcPoolBroadcast.Call(utils.CoreSv1Status, utils.TenantWithOpts{}, &status); err != nil { + if err := rpcPoolBroadcast.Call(utils.CoreSv1Status, utils.TenantWithAPIOpts{}, &status); err != nil { t.Error(err) } else if status[utils.NodeID].(string) == "" { t.Error("Empty NodeID received") } - if err := rpcPoolBroadcast.Call(utils.CoreSv1Status, utils.TenantWithOpts{}, &status); err != nil { + if err := rpcPoolBroadcast.Call(utils.CoreSv1Status, utils.TenantWithAPIOpts{}, &status); err != nil { t.Error(err) } else if status[utils.NodeID].(string) == "" { t.Error("Empty NodeID received") @@ -271,7 +271,7 @@ func testRPCITLclBcastStatusBcastNoRals(t *testing.T) { } time.Sleep(time.Duration(*waitRater) * time.Millisecond) var status map[string]interface{} - if err := rpcPoolBroadcast.Call(utils.CoreSv1Status, utils.TenantWithOpts{}, &status); err == nil { + if err := rpcPoolBroadcast.Call(utils.CoreSv1Status, utils.TenantWithAPIOpts{}, &status); err == nil { t.Error("Should get error") } } @@ -281,12 +281,12 @@ func testRPCITLclBcastStatusRALs2Up(t *testing.T) { t.Fatal(err) } var status map[string]interface{} - if err := rpcPoolBroadcast.Call(utils.CoreSv1Status, utils.TenantWithOpts{}, &status); err != nil { + if err := rpcPoolBroadcast.Call(utils.CoreSv1Status, utils.TenantWithAPIOpts{}, &status); err != nil { t.Error(err) } else if status[utils.NodeID].(string) == "" { t.Error("Empty NodeID received") } - if err := rpcPoolBroadcast.Call(utils.CoreSv1Status, utils.TenantWithOpts{}, &status); err != nil { + if err := rpcPoolBroadcast.Call(utils.CoreSv1Status, utils.TenantWithAPIOpts{}, &status); err != nil { t.Error(err) } else if status[utils.NodeID].(string) == "" { t.Error("Empty NodeID received") @@ -298,12 +298,12 @@ func testRPCITLclStatusBcastRALs1Up(t *testing.T) { t.Fatal(err) } var status map[string]interface{} - if err := rpcPoolBroadcast.Call(utils.CoreSv1Status, utils.TenantWithOpts{}, &status); err != nil { + if err := rpcPoolBroadcast.Call(utils.CoreSv1Status, utils.TenantWithAPIOpts{}, &status); err != nil { t.Error(err) } else if status[utils.NodeID].(string) == "" { t.Error("Empty InstanceID received") } - if err := rpcPoolBroadcast.Call(utils.CoreSv1Status, utils.TenantWithOpts{}, &status); err != nil { + if err := rpcPoolBroadcast.Call(utils.CoreSv1Status, utils.TenantWithAPIOpts{}, &status); err != nil { t.Error(err) } else if status[utils.NodeID].(string) == "" { t.Error("Empty InstanceID received") @@ -371,12 +371,12 @@ func TestRPCITRmtStatusFirstInitial(t *testing.T) { return } var status map[string]interface{} - if err := rpcPoolFirst.Call(utils.CoreSv1Status, utils.TenantWithOpts{}, &status); err != nil { + if err := rpcPoolFirst.Call(utils.CoreSv1Status, utils.TenantWithAPIOpts{}, &status); err != nil { t.Error(err) } else if status[utils.NodeID].(string) == "" { t.Error("Empty NodeID received") } - if err := rpcPoolFirst.Call(utils.CoreSv1Status, utils.TenantWithOpts{}, &status); err != nil { // Make sure second time we land on the same instance + if err := rpcPoolFirst.Call(utils.CoreSv1Status, utils.TenantWithAPIOpts{}, &status); err != nil { // Make sure second time we land on the same instance t.Error(err) } else if status[utils.NodeID].(string) != node1 { t.Errorf("Expecting:\n%s\nReceived:\n%s", node1, status[utils.NodeID].(string)) @@ -395,14 +395,14 @@ func TestRPCITRmtStatusFirstFailover(t *testing.T) { } fmt.Println("\n\nExecuting query ...") var status map[string]interface{} - if err := rpcPoolFirst.Call(utils.CoreSv1Status, utils.TenantWithOpts{}, &status); err != nil { + if err := rpcPoolFirst.Call(utils.CoreSv1Status, utils.TenantWithAPIOpts{}, &status); err != nil { t.Error(err) } else if status[utils.NodeID].(string) == "" { t.Error("Empty NodeID received") } else if status[utils.NodeID].(string) == node1 { t.Fatal("Did not failover") } - if err := rpcPoolFirst.Call(utils.CoreSv1Status, utils.TenantWithOpts{}, &status); err != nil { + if err := rpcPoolFirst.Call(utils.CoreSv1Status, utils.TenantWithAPIOpts{}, &status); err != nil { t.Error(err) } else if status[utils.NodeID].(string) == "" { t.Error("Empty NodeID received") @@ -423,14 +423,14 @@ func TestRPCITRmtStatusFirstFailback(t *testing.T) { } fmt.Println("\n\nExecuting query ...") var status map[string]interface{} - if err := rpcPoolFirst.Call(utils.CoreSv1Status, utils.TenantWithOpts{}, &status); err != nil { + if err := rpcPoolFirst.Call(utils.CoreSv1Status, utils.TenantWithAPIOpts{}, &status); err != nil { t.Error(err) } else if status[utils.NodeID].(string) == "" { t.Error("Empty NodeID received") } else if status[utils.NodeID].(string) == node2 { t.Fatal("Did not do failback") } - if err := rpcPoolFirst.Call(utils.CoreSv1Status, utils.TenantWithOpts{}, &status); err != nil { + if err := rpcPoolFirst.Call(utils.CoreSv1Status, utils.TenantWithAPIOpts{}, &status); err != nil { t.Error(err) } else if status[utils.NodeID].(string) == "" { t.Error("Empty NodeID received") diff --git a/general_tests/twoengines_it_test.go b/general_tests/twoengines_it_test.go index 95dacd00c..0ff737dd2 100644 --- a/general_tests/twoengines_it_test.go +++ b/general_tests/twoengines_it_test.go @@ -145,7 +145,7 @@ func testTwoEnginesSetThreshold(t *testing.T) { t.Error(err) } var result string - tPrfl := &engine.ThresholdProfileWithOpts{ + tPrfl := &engine.ThresholdProfileWithAPIOpts{ ThresholdProfile: &engine.ThresholdProfile{ Tenant: "cgrates.org", ID: "THD_TwoEnginesTest", @@ -205,7 +205,7 @@ func testTwoEnginesCheckCacheAfterSet(t *testing.T) { t.Errorf("Expected: %+v, received: %+v", expKeys, rcvKeys) } // after we verify the cache make sure it was set correctly there - tPrfl := &engine.ThresholdProfileWithOpts{ + tPrfl := &engine.ThresholdProfileWithAPIOpts{ ThresholdProfile: &engine.ThresholdProfile{ Tenant: "cgrates.org", ID: "THD_TwoEnginesTest", @@ -230,7 +230,7 @@ func testTwoEnginesCheckCacheAfterSet(t *testing.T) { func testTwoEnginesUpdateThreshold(t *testing.T) { var rplTh *engine.ThresholdProfile var result string - tPrfl := &engine.ThresholdProfileWithOpts{ + tPrfl := &engine.ThresholdProfileWithAPIOpts{ ThresholdProfile: &engine.ThresholdProfile{ Tenant: "cgrates.org", ID: "THD_TwoEnginesTest", @@ -242,7 +242,7 @@ func testTwoEnginesUpdateThreshold(t *testing.T) { ActionIDs: []string{"ACT_1.1"}, Async: true, }, - Opts: map[string]interface{}{ + APIOpts: map[string]interface{}{ utils.CacheOpt: utils.MetaReload, }, } diff --git a/loaders/loader.go b/loaders/loader.go index 64345f5f9..661c39575 100644 --- a/loaders/loader.go +++ b/loaders/loader.go @@ -680,19 +680,19 @@ func (ldr *Loader) storeLoadedData(loaderType string, return case utils.MetaReload: if err = ldr.connMgr.Call(ldr.cacheConns, nil, - utils.CacheSv1ReloadCache, utils.AttrReloadCacheWithOpts{ + utils.CacheSv1ReloadCache, utils.AttrReloadCacheWithAPIOpts{ ArgsCache: cacheArgs}, &reply); err != nil { return } case utils.MetaLoad: if err = ldr.connMgr.Call(ldr.cacheConns, nil, - utils.CacheSv1LoadCache, utils.AttrReloadCacheWithOpts{ + utils.CacheSv1LoadCache, utils.AttrReloadCacheWithAPIOpts{ ArgsCache: cacheArgs}, &reply); err != nil { return } case utils.MetaRemove: if err = ldr.connMgr.Call(ldr.cacheConns, nil, - utils.CacheSv1RemoveItems, utils.AttrReloadCacheWithOpts{ + utils.CacheSv1RemoveItems, utils.AttrReloadCacheWithAPIOpts{ ArgsCache: cacheArgs}, &reply); err != nil { return } @@ -1036,19 +1036,19 @@ func (ldr *Loader) removeLoadedData(loaderType string, lds map[string][]LoaderDa return case utils.MetaReload: if err = ldr.connMgr.Call(ldr.cacheConns, nil, - utils.CacheSv1ReloadCache, utils.AttrReloadCacheWithOpts{ + utils.CacheSv1ReloadCache, utils.AttrReloadCacheWithAPIOpts{ ArgsCache: cacheArgs}, &reply); err != nil { return } case utils.MetaLoad: if err = ldr.connMgr.Call(ldr.cacheConns, nil, - utils.CacheSv1LoadCache, utils.AttrReloadCacheWithOpts{ + utils.CacheSv1LoadCache, utils.AttrReloadCacheWithAPIOpts{ ArgsCache: cacheArgs}, &reply); err != nil { return } case utils.MetaRemove: if err = ldr.connMgr.Call(ldr.cacheConns, nil, - utils.CacheSv1RemoveItems, utils.AttrReloadCacheWithOpts{ + utils.CacheSv1RemoveItems, utils.AttrReloadCacheWithAPIOpts{ ArgsCache: cacheArgs}, &reply); err != nil { return } diff --git a/registrarc/registrarc_it_test.go b/registrarc/registrarc_it_test.go index 4f9f0a154..2dcedfefe 100644 --- a/registrarc/registrarc_it_test.go +++ b/registrarc/registrarc_it_test.go @@ -127,9 +127,9 @@ func testDsphLoadData(t *testing.T) { func testDsphGetNodeID() (id string, err error) { var status map[string]interface{} - if err = dspRPC.Call(utils.CoreSv1Status, utils.TenantWithOpts{ - Tenant: "cgrates.org", - Opts: map[string]interface{}{}, + if err = dspRPC.Call(utils.CoreSv1Status, utils.TenantWithAPIOpts{ + Tenant: "cgrates.org", + APIOpts: map[string]interface{}{}, }, &status); err != nil { return } diff --git a/sessions/sessions.go b/sessions/sessions.go index e20018520..4bdfe8a11 100644 --- a/sessions/sessions.go +++ b/sessions/sessions.go @@ -3601,7 +3601,7 @@ func (sS *SessionS) BiRPCv1GetCost(clnt rpcclient.ClientConnector, // BiRPCv1SyncSessions will sync sessions on demand func (sS *SessionS) BiRPCv1SyncSessions(clnt rpcclient.ClientConnector, - ignParam *utils.TenantWithOpts, reply *string) error { + ignParam *utils.TenantWithAPIOpts, reply *string) error { sS.syncSessions() *reply = utils.OK return nil @@ -4095,7 +4095,7 @@ func (sS *SessionS) Handlers() map[string]interface{} { utils.SessionSv1UpdateSession: func(clnt *rpc2.Client, args *V1UpdateSessionArgs, rply *V1UpdateSessionReply) (err error) { return sS.BiRPCv1UpdateSession(clnt, args, rply) }, - utils.SessionSv1SyncSessions: func(clnt *rpc2.Client, args *utils.TenantWithOpts, rply *string) (err error) { + utils.SessionSv1SyncSessions: func(clnt *rpc2.Client, args *utils.TenantWithAPIOpts, rply *string) (err error) { return sS.BiRPCv1SyncSessions(clnt, args, rply) }, utils.SessionSv1TerminateSession: func(clnt *rpc2.Client, args *V1TerminateSessionArgs, rply *string) (err error) { diff --git a/sessions/sessions_rpl_it_test.go b/sessions/sessions_rpl_it_test.go index 39bea8e7a..c064aa6a2 100644 --- a/sessions/sessions_rpl_it_test.go +++ b/sessions/sessions_rpl_it_test.go @@ -449,10 +449,10 @@ func testSessionSRplManualReplicate(t *testing.T) { t.Errorf("Failed to kill process, error: %v", err.Error()) } var status map[string]interface{} - if err := smgRplcMstrRPC.Call(utils.CoreSv1Status, utils.TenantWithOpts{}, &status); err == nil { // master should not longer be reachable + if err := smgRplcMstrRPC.Call(utils.CoreSv1Status, utils.TenantWithAPIOpts{}, &status); err == nil { // master should not longer be reachable t.Error(err, status) } - if err := smgRplcSlvRPC.Call(utils.CoreSv1Status, utils.TenantWithOpts{}, &status); err != nil { // slave should be still operational + if err := smgRplcSlvRPC.Call(utils.CoreSv1Status, utils.TenantWithAPIOpts{}, &status); err != nil { // slave should be still operational t.Error(err) } // start master diff --git a/utils/apitpdata.go b/utils/apitpdata.go index be6d62a77..6c1b09a29 100755 --- a/utils/apitpdata.go +++ b/utils/apitpdata.go @@ -1288,21 +1288,21 @@ type RPCCDRsFilterWithOpts struct { Tenant string } -type ArgsGetCacheItemIDsWithOpts struct { - Opts map[string]interface{} - Tenant string +type ArgsGetCacheItemIDsWithAPIOpts struct { + APIOpts map[string]interface{} + Tenant string ArgsGetCacheItemIDs } -type ArgsGetCacheItemWithOpts struct { - Opts map[string]interface{} - Tenant string +type ArgsGetCacheItemWithAPIOpts struct { + APIOpts map[string]interface{} + Tenant string ArgsGetCacheItem } // NewAttrReloadCacheWithOpts returns the ArgCache populated with nil -func NewAttrReloadCacheWithOpts() *AttrReloadCacheWithOpts { - return &AttrReloadCacheWithOpts{ +func NewAttrReloadCacheWithOpts() *AttrReloadCacheWithAPIOpts { + return &AttrReloadCacheWithAPIOpts{ ArgsCache: map[string][]string{ DestinationIDs: nil, ReverseDestinationIDs: nil, @@ -1341,14 +1341,14 @@ func NewAttrReloadCacheWithOpts() *AttrReloadCacheWithOpts { } } -type AttrReloadCacheWithOpts struct { - Opts map[string]interface{} +type AttrReloadCacheWithAPIOpts struct { + APIOpts map[string]interface{} Tenant string ArgsCache map[string][]string } type AttrCacheIDsWithOpts struct { - Opts map[string]interface{} + APIOpts map[string]interface{} Tenant string CacheIDs []string } diff --git a/utils/apitpdata_test.go b/utils/apitpdata_test.go index 3f3d81b45..6bb73c8e8 100644 --- a/utils/apitpdata_test.go +++ b/utils/apitpdata_test.go @@ -1012,7 +1012,7 @@ func TestCDRsFilterPrepare(t *testing.T) { } func TestNewAttrReloadCacheWithOpts(t *testing.T) { - newAttrReloadCache := &AttrReloadCacheWithOpts{ + newAttrReloadCache := &AttrReloadCacheWithAPIOpts{ ArgsCache: map[string][]string{ DestinationIDs: nil, ReverseDestinationIDs: nil, diff --git a/utils/coreutils.go b/utils/coreutils.go index fcb0236af..f5ecd535a 100644 --- a/utils/coreutils.go +++ b/utils/coreutils.go @@ -740,9 +740,9 @@ type PaginatorWithTenant struct { Paginator } -type TenantWithOpts struct { - Tenant string - Opts map[string]interface{} +type TenantWithAPIOpts struct { + Tenant string + APIOpts map[string]interface{} } type TenantID struct {