From 8b0748b139006866368cd456438dec028409f7da Mon Sep 17 00:00:00 2001 From: andronache Date: Wed, 17 Mar 2021 10:23:00 +0200 Subject: [PATCH] Changed in DispatcherWithOpts,AccountProfileWithAPIOpts and APIAccountProfileWithOpts the field Opts to APIOpts --- apier/v1/api_interfaces.go | 2 +- apier/v1/dispatcher.go | 12 ++++++------ apier/v1/dispatcher_it_test.go | 6 +++--- apier/v1/filter_indexes_it_test.go | 6 +++--- apier/v1/full_remote_it_test.go | 2 +- apier/v1/remote_it_test.go | 2 +- apier/v1/replicate_it_test.go | 2 +- apier/v1/replicator.go | 2 +- console/dispatchers_profile_set.go | 6 +++--- dispatchers/replicator.go | 4 ++-- dispatchers/replicator_it_test.go | 4 ++-- engine/datamanager.go | 4 ++-- general_tests/filtered_replication_it_test.go | 2 +- packages/debian/changelog | 3 ++- utils/accountprofile.go | 5 ++--- 15 files changed, 31 insertions(+), 31 deletions(-) diff --git a/apier/v1/api_interfaces.go b/apier/v1/api_interfaces.go index ab400aa78..328c7dfad 100644 --- a/apier/v1/api_interfaces.go +++ b/apier/v1/api_interfaces.go @@ -272,7 +272,7 @@ type ReplicatorSv1Interface interface { RemoveIndexes(args *utils.GetIndexesArg, reply *string) error GetAccountProfile(tntID *utils.TenantIDWithOpts, reply *utils.AccountProfile) error - SetAccountProfile(args *utils.AccountProfileWithOpts, reply *string) error + SetAccountProfile(args *utils.AccountProfileWithAPIOpts, reply *string) error RemoveAccountProfile(args *utils.TenantIDWithOpts, reply *string) error GetActionProfile(tntID *utils.TenantIDWithOpts, reply *engine.ActionProfile) error diff --git a/apier/v1/dispatcher.go b/apier/v1/dispatcher.go index 249dafa6f..9fab7ec12 100755 --- a/apier/v1/dispatcher.go +++ b/apier/v1/dispatcher.go @@ -68,13 +68,13 @@ func (apierSv1 *APIerSv1) GetDispatcherProfileIDs(tenantArg *utils.PaginatorWith return nil } -type DispatcherWithOpts struct { +type DispatcherWithAPIOpts struct { *engine.DispatcherProfile - Opts map[string]interface{} + APIOpts map[string]interface{} } //SetDispatcherProfile add/update a new Dispatcher Profile -func (apierSv1 *APIerSv1) SetDispatcherProfile(args *DispatcherWithOpts, reply *string) error { +func (apierSv1 *APIerSv1) SetDispatcherProfile(args *DispatcherWithAPIOpts, reply *string) error { if missing := utils.MissingStructFields(args.DispatcherProfile, []string{utils.ID}); len(missing) != 0 { return utils.NewErrMandatoryIeMissing(missing...) } @@ -89,8 +89,8 @@ func (apierSv1 *APIerSv1) SetDispatcherProfile(args *DispatcherWithOpts, reply * return utils.APIErrorHandler(err) } //handle caching for DispatcherProfile - if err := apierSv1.CallCache(utils.IfaceAsString(args.Opts[utils.CacheOpt]), args.Tenant, utils.CacheDispatcherProfiles, - args.TenantID(), &args.FilterIDs, args.Subsystems, args.Opts); err != nil { + if err := apierSv1.CallCache(utils.IfaceAsString(args.APIOpts[utils.CacheOpt]), args.Tenant, utils.CacheDispatcherProfiles, + args.TenantID(), &args.FilterIDs, args.Subsystems, args.APIOpts); err != nil { return utils.APIErrorHandler(err) } *reply = utils.OK @@ -1294,7 +1294,7 @@ func (dS *DispatcherReplicatorSv1) GetAccountProfile(tntID *utils.TenantIDWithOp } // SetAccountProfile . -func (dS *DispatcherReplicatorSv1) SetAccountProfile(args *utils.AccountProfileWithOpts, reply *string) error { +func (dS *DispatcherReplicatorSv1) SetAccountProfile(args *utils.AccountProfileWithAPIOpts, reply *string) error { return dS.dS.ReplicatorSv1SetAccountProfile(args, reply) } diff --git a/apier/v1/dispatcher_it_test.go b/apier/v1/dispatcher_it_test.go index b76129ba8..64103cb8d 100644 --- a/apier/v1/dispatcher_it_test.go +++ b/apier/v1/dispatcher_it_test.go @@ -37,7 +37,7 @@ var ( dispatcherCfgPath string dispatcherCfg *config.CGRConfig dispatcherRPC *rpc.Client - dispatcherProfile *DispatcherWithOpts + dispatcherProfile *DispatcherWithAPIOpts dispatcherHost *engine.DispatcherHostWithOpts dispatcherConfigDIR string //run tests for specific configuration @@ -129,7 +129,7 @@ func testDispatcherSRPCConn(t *testing.T) { func testDispatcherSSetDispatcherProfile(t *testing.T) { var reply string - dispatcherProfile = &DispatcherWithOpts{ + dispatcherProfile = &DispatcherWithAPIOpts{ DispatcherProfile: &engine.DispatcherProfile{ Tenant: "cgrates.org", ID: "Dsp1", @@ -375,7 +375,7 @@ func testDispatcherSKillEngine(t *testing.T) { } func testDispatcherSSetDispatcherProfileWithoutTenant(t *testing.T) { - dispatcherProfile = &DispatcherWithOpts{ + dispatcherProfile = &DispatcherWithAPIOpts{ DispatcherProfile: &engine.DispatcherProfile{ ID: "Dsp1", FilterIDs: []string{"*string:~*req.Account:1001"}, diff --git a/apier/v1/filter_indexes_it_test.go b/apier/v1/filter_indexes_it_test.go index e769cb373..405e2c346 100644 --- a/apier/v1/filter_indexes_it_test.go +++ b/apier/v1/filter_indexes_it_test.go @@ -3053,7 +3053,7 @@ func testV1FIdxGetFilterIndexes4(t *testing.T) { func testV1FIdxSetDispatcherProfile(t *testing.T) { var reply string //add a dispatcherProfile for 2 subsystems and verify if the index was created for both - dispatcherProfile = &DispatcherWithOpts{ + dispatcherProfile = &DispatcherWithAPIOpts{ DispatcherProfile: &engine.DispatcherProfile{ Tenant: "cgrates.org", ID: "DSP_Test1", @@ -3196,7 +3196,7 @@ func testV1FIdxSetDispatcherProfile2(t *testing.T) { var reply string //add a new dispatcherProfile with empty filterIDs //should create an index of type *none:*any:*any for *attributes subsystem - dispatcherProfile = &DispatcherWithOpts{ + dispatcherProfile = &DispatcherWithAPIOpts{ DispatcherProfile: &engine.DispatcherProfile{ Tenant: "cgrates.org", ID: "DSP_Test2", @@ -3215,7 +3215,7 @@ func testV1FIdxSetDispatcherProfile2(t *testing.T) { //add a new dispatcherProfile with empty filterIDs //should create an index of type *none:*any:*any for *sessions subsystem - dispatcherProfile2 := DispatcherWithOpts{ + dispatcherProfile2 := DispatcherWithAPIOpts{ DispatcherProfile: &engine.DispatcherProfile{ Tenant: "cgrates.org", ID: "DSP_Test3", diff --git a/apier/v1/full_remote_it_test.go b/apier/v1/full_remote_it_test.go index 8d18cd309..caa6338f4 100644 --- a/apier/v1/full_remote_it_test.go +++ b/apier/v1/full_remote_it_test.go @@ -546,7 +546,7 @@ func testFullRemoteITDispatcher(t *testing.T) { } var replySet string - dispatcherProfile = &DispatcherWithOpts{ + dispatcherProfile = &DispatcherWithAPIOpts{ DispatcherProfile: &engine.DispatcherProfile{ Tenant: "cgrates.org", ID: "Dsp1", diff --git a/apier/v1/remote_it_test.go b/apier/v1/remote_it_test.go index 55c1badf3..b09777a3c 100644 --- a/apier/v1/remote_it_test.go +++ b/apier/v1/remote_it_test.go @@ -599,7 +599,7 @@ func testInternalRemoteITGetDispatcherProfile(t *testing.T) { t.Error(err) } - dispatcherProfile = &DispatcherWithOpts{ + dispatcherProfile = &DispatcherWithAPIOpts{ DispatcherProfile: &engine.DispatcherProfile{ Tenant: "cgrates.org", ID: "Dsp1", diff --git a/apier/v1/replicate_it_test.go b/apier/v1/replicate_it_test.go index be3f1f90e..81f779686 100644 --- a/apier/v1/replicate_it_test.go +++ b/apier/v1/replicate_it_test.go @@ -501,7 +501,7 @@ func testInternalReplicateITDispatcherProfile(t *testing.T) { t.Error(err) } // set - dispatcherProfile = &DispatcherWithOpts{ + dispatcherProfile = &DispatcherWithAPIOpts{ DispatcherProfile: &engine.DispatcherProfile{ Tenant: "cgrates.org", ID: "Dsp1", diff --git a/apier/v1/replicator.go b/apier/v1/replicator.go index d505d786e..6c271dd63 100644 --- a/apier/v1/replicator.go +++ b/apier/v1/replicator.go @@ -688,7 +688,7 @@ func (rplSv1 *ReplicatorSv1) SetActionProfile(acp *engine.ActionProfileWithOpts, } // SetAccountProfile is the replication method coresponding to the dataDb driver method -func (rplSv1 *ReplicatorSv1) SetAccountProfile(acp *utils.AccountProfileWithOpts, reply *string) (err error) { +func (rplSv1 *ReplicatorSv1) SetAccountProfile(acp *utils.AccountProfileWithAPIOpts, reply *string) (err error) { if err = rplSv1.dm.DataDB().SetAccountProfileDrv(acp.AccountProfile); err != nil { return } diff --git a/console/dispatchers_profile_set.go b/console/dispatchers_profile_set.go index a8d0a726f..003afa072 100644 --- a/console/dispatchers_profile_set.go +++ b/console/dispatchers_profile_set.go @@ -37,7 +37,7 @@ func init() { type CmdSetDispatcherProfile struct { name string rpcMethod string - rpcParams *v1.DispatcherWithOpts + rpcParams *v1.DispatcherWithAPIOpts *CommandExecuter } @@ -51,9 +51,9 @@ func (self *CmdSetDispatcherProfile) RpcMethod() string { func (self *CmdSetDispatcherProfile) RpcParams(reset bool) interface{} { if reset || self.rpcParams == nil { - self.rpcParams = &v1.DispatcherWithOpts{ + self.rpcParams = &v1.DispatcherWithAPIOpts{ DispatcherProfile: new(engine.DispatcherProfile), - Opts: make(map[string]interface{}), + APIOpts: make(map[string]interface{}), } } return self.rpcParams diff --git a/dispatchers/replicator.go b/dispatchers/replicator.go index c17819f83..f02aa3cd9 100644 --- a/dispatchers/replicator.go +++ b/dispatchers/replicator.go @@ -1434,9 +1434,9 @@ func (dS *DispatcherService) ReplicatorSv1GetAccountProfile(args *utils.TenantID }, utils.MetaReplicator, utils.ReplicatorSv1GetAccountProfile, args, reply) } -func (dS *DispatcherService) ReplicatorSv1SetAccountProfile(args *utils.AccountProfileWithOpts, rpl *string) (err error) { +func (dS *DispatcherService) ReplicatorSv1SetAccountProfile(args *utils.AccountProfileWithAPIOpts, rpl *string) (err error) { if args == nil { - args = &utils.AccountProfileWithOpts{} + args = &utils.AccountProfileWithAPIOpts{} } args.Tenant = utils.FirstNonEmpty(args.Tenant, dS.cfg.GeneralCfg().DefaultTenant) if len(dS.cfg.DispatcherSCfg().AttributeSConns) != 0 { diff --git a/dispatchers/replicator_it_test.go b/dispatchers/replicator_it_test.go index c6f2ebc81..f1660e9a0 100644 --- a/dispatchers/replicator_it_test.go +++ b/dispatchers/replicator_it_test.go @@ -1560,12 +1560,12 @@ func testDspRplRateProfile(t *testing.T) { func testDspRplAccountProfile(t *testing.T) { // Set RateProfile var replyStr string - rPrf := &utils.AccountProfileWithOpts{ + rPrf := &utils.AccountProfileWithAPIOpts{ AccountProfile: &utils.AccountProfile{ Tenant: "cgrates.org", ID: "RP1", }, - Opts: map[string]interface{}{ + APIOpts: map[string]interface{}{ utils.OptsAPIKey: "repl12345", }, } diff --git a/engine/datamanager.go b/engine/datamanager.go index 9eaef6204..791716ccb 100644 --- a/engine/datamanager.go +++ b/engine/datamanager.go @@ -3684,9 +3684,9 @@ func (dm *DataManager) SetAccountProfile(ap *utils.AccountProfile, withIndex boo config.CgrConfig().DataDbCfg().RplFiltered, utils.AccountProfilePrefix, ap.TenantID(), // this are used to get the host IDs from cache utils.ReplicatorSv1SetAccountProfile, - &utils.AccountProfileWithOpts{ + &utils.AccountProfileWithAPIOpts{ AccountProfile: 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/general_tests/filtered_replication_it_test.go b/general_tests/filtered_replication_it_test.go index e47a61e6a..8bc86b783 100644 --- a/general_tests/filtered_replication_it_test.go +++ b/general_tests/filtered_replication_it_test.go @@ -1142,7 +1142,7 @@ func testFltrRplChargerProfile(t *testing.T) { func testFltrRplDispatcherProfile(t *testing.T) { dspID := "DSP1" - dspPrf := &v1.DispatcherWithOpts{ + dspPrf := &v1.DispatcherWithAPIOpts{ DispatcherProfile: &engine.DispatcherProfile{ Tenant: "cgrates.org", ID: dspID, diff --git a/packages/debian/changelog b/packages/debian/changelog index 8f05912b3..2b26de637 100644 --- a/packages/debian/changelog +++ b/packages/debian/changelog @@ -148,7 +148,8 @@ cgrates (0.11.0~dev) UNRELEASED; urgency=medium * [ActionS] Added *add_balance, *set_balance and *rem_balance * [RegistrarC] Renamed DispatcherH to RegistrarC * [DataDB] Added replication filtering - + * [ApierS] Moved Cache field as options + -- DanB Wed, 19 Feb 2020 13:25:52 +0200 cgrates (0.10.0) UNRELEASED; urgency=medium diff --git a/utils/accountprofile.go b/utils/accountprofile.go index 8b328d4bb..be2634b03 100644 --- a/utils/accountprofile.go +++ b/utils/accountprofile.go @@ -340,10 +340,9 @@ type APIAccountProfileWithOpts struct { APIOpts map[string]interface{} } -// AccountProfileWithOpts is used in API calls -type AccountProfileWithOpts struct { +type AccountProfileWithAPIOpts struct { *AccountProfile - Opts map[string]interface{} + APIOpts map[string]interface{} } // ArgsAccountForEvent arguments used for process event