From 4d4eea8866b84dfb7e729658c79885f248a3b9d2 Mon Sep 17 00:00:00 2001 From: andronache Date: Fri, 19 Mar 2021 16:53:31 +0200 Subject: [PATCH] Changed Opts to APIOpts in some structs and fixed multiple integration tests --- apier/v1/accountsv1_it_test.go | 13 +- apier/v1/api_interfaces.go | 8 +- apier/v1/cost_bench_it_test.go | 66 ++++---- apier/v1/dispatcher.go | 8 +- apier/v1/filter_indexes_it_test.go | 142 ++++++++--------- apier/v1/filterindexecache_it_test.go | 24 +-- apier/v1/filters.go | 6 +- apier/v1/filters_it_test.go | 6 +- apier/v1/full_remote_it_test.go | 46 +++--- apier/v1/rateprofiles_it_test.go | 145 ++++++++---------- apier/v1/remote_it_test.go | 46 +++--- apier/v1/replicate_it_test.go | 4 +- apier/v1/replicator.go | 20 +-- apier/v1/stats_it_test.go | 4 +- console/filter_set.go | 6 +- dispatchers/replicator.go | 32 ++-- dispatchers/replicator_it_test.go | 20 +-- engine/account.go | 4 +- engine/caches.go | 2 +- engine/datamanager.go | 14 +- engine/destinations.go | 6 +- engine/filters.go | 4 +- general_tests/filtered_replication_it_test.go | 34 ++-- general_tests/filters_it_test.go | 12 +- 24 files changed, 321 insertions(+), 351 deletions(-) diff --git a/apier/v1/accountsv1_it_test.go b/apier/v1/accountsv1_it_test.go index b2a9b987f..6cbe91275 100644 --- a/apier/v1/accountsv1_it_test.go +++ b/apier/v1/accountsv1_it_test.go @@ -803,9 +803,8 @@ func testAccountSv1DebitWithAttributeSandRateS(t *testing.T) { } if err := acntSRPC.Call(utils.APIerSv1SetRateProfile, - &APIRateProfileWithCache{ - APIRateProfileWithOpts: &utils.APIRateProfileWithOpts{ - APIRateProfile: apiRPrf}, + &utils.APIRateProfileWithOpts{ + APIRateProfile: apiRPrf, }, &reply); err != nil { t.Fatal(err) } else if reply != utils.OK { @@ -901,7 +900,8 @@ func testAccountSv1DebitWithRateS(t *testing.T) { } if err := acntSRPC.Call(utils.APIerSv1SetRateProfile, - + &utils.APIRateProfileWithOpts{ + APIRateProfile: apiRPrf, }, &reply); err != nil { t.Fatal(err) } else if reply != utils.OK { @@ -1004,9 +1004,8 @@ func testAccountSv1DebitWithRateS2(t *testing.T) { } if err := acntSRPC.Call(utils.APIerSv1SetRateProfile, - &APIRateProfileWithCache{ - APIRateProfileWithOpts: &utils.APIRateProfileWithOpts{ - APIRateProfile: apiRPrf}, + &utils.APIRateProfileWithOpts{ + APIRateProfile: apiRPrf, }, &reply); err != nil { t.Fatal(err) } else if reply != utils.OK { diff --git a/apier/v1/api_interfaces.go b/apier/v1/api_interfaces.go index fa28f5974..72584a678 100644 --- a/apier/v1/api_interfaces.go +++ b/apier/v1/api_interfaces.go @@ -221,11 +221,11 @@ type ReplicatorSv1Interface interface { GetItemLoadIDs(itemID *utils.StringWithAPIOpts, reply *map[string]int64) 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 + SetAccount(acc *engine.AccountWithAPIOpts, reply *string) error + SetDestination(dst *engine.DestinationWithAPIOpts, reply *string) error + SetReverseDestination(dst *engine.DestinationWithAPIOpts, reply *string) error SetStatQueue(ssq *engine.StatQueueWithAPIOpts, reply *string) error - SetFilter(fltr *engine.FilterWithOpts, reply *string) error + SetFilter(fltr *engine.FilterWithAPIOpts, reply *string) error SetStatQueueProfile(sq *engine.StatQueueProfileWithOpts, reply *string) error SetTiming(tm *utils.TPTimingWithAPIOpts, reply *string) error SetResource(rs *engine.ResourceWithAPIOpts, reply *string) error diff --git a/apier/v1/cost_bench_it_test.go b/apier/v1/cost_bench_it_test.go index d45b68ed4..1b3635804 100644 --- a/apier/v1/cost_bench_it_test.go +++ b/apier/v1/cost_bench_it_test.go @@ -95,31 +95,29 @@ func testCostBenchLoadFromFolder2(b *testing.B) { } func testCostBenchSetRateProfile(b *testing.B) { - rPrf := &APIRateProfileWithCache{ - APIRateProfileWithOpts: &utils.APIRateProfileWithOpts{ - APIRateProfile: &utils.APIRateProfile{ - ID: "DefaultRate", - FilterIDs: []string{"*string:~*req.Subject:1001"}, - Weights: ";10", - Rates: map[string]*utils.APIRate{ - "RATE1": &utils.APIRate{ - ID: "RATE1", - Weights: ";0", - ActivationTimes: "* * * * *", - IntervalRates: []*utils.APIIntervalRate{ - { - IntervalStart: "0", - FixedFee: utils.Float64Pointer(0.4), - RecurrentFee: utils.Float64Pointer(0.2), - Unit: utils.Float64Pointer(60000000000), - Increment: utils.Float64Pointer(60000000000), - }, - { - IntervalStart: "1m", - RecurrentFee: utils.Float64Pointer(0.1), - Unit: utils.Float64Pointer(60000000000), - Increment: utils.Float64Pointer(1000000000), - }, + rPrf := &utils.APIRateProfileWithOpts{ + APIRateProfile: &utils.APIRateProfile{ + ID: "DefaultRate", + FilterIDs: []string{"*string:~*req.Subject:1001"}, + Weights: ";10", + Rates: map[string]*utils.APIRate{ + "RATE1": &utils.APIRate{ + ID: "RATE1", + Weights: ";0", + ActivationTimes: "* * * * *", + IntervalRates: []*utils.APIIntervalRate{ + { + IntervalStart: "0", + FixedFee: utils.Float64Pointer(0.4), + RecurrentFee: utils.Float64Pointer(0.2), + Unit: utils.Float64Pointer(60000000000), + Increment: utils.Float64Pointer(60000000000), + }, + { + IntervalStart: "1m", + RecurrentFee: utils.Float64Pointer(0.1), + Unit: utils.Float64Pointer(60000000000), + Increment: utils.Float64Pointer(1000000000), }, }, }, @@ -165,16 +163,14 @@ func testCostBenchSetRateProfile2(b *testing.B) { Increment: utils.Float64Pointer(1000000000), }}, } - rPrf := &APIRateProfileWithCache{ - APIRateProfileWithOpts: &utils.APIRateProfileWithOpts{ - APIRateProfile: &utils.APIRateProfile{ - ID: "RateChristmas", - FilterIDs: []string{"*string:~*req.Subject:1010"}, - Weights: ";50", - Rates: map[string]*utils.APIRate{ - "RATE1": rate1, - "RATE_CHRISTMAS": rtChristmas, - }, + rPrf := &utils.APIRateProfileWithOpts{ + APIRateProfile: &utils.APIRateProfile{ + ID: "RateChristmas", + FilterIDs: []string{"*string:~*req.Subject:1010"}, + Weights: ";50", + Rates: map[string]*utils.APIRate{ + "RATE1": rate1, + "RATE_CHRISTMAS": rtChristmas, }, }, } diff --git a/apier/v1/dispatcher.go b/apier/v1/dispatcher.go index 78bd953c3..d50801116 100755 --- a/apier/v1/dispatcher.go +++ b/apier/v1/dispatcher.go @@ -1047,17 +1047,17 @@ func (dS *DispatcherReplicatorSv1) SetThreshold(args *engine.ThresholdWithAPIOpt } // SetDestination -func (dS *DispatcherReplicatorSv1) SetDestination(args *engine.DestinationWithOpts, reply *string) error { +func (dS *DispatcherReplicatorSv1) SetDestination(args *engine.DestinationWithAPIOpts, reply *string) error { return dS.dS.ReplicatorSv1SetDestination(args, reply) } // SetAccount -func (dS *DispatcherReplicatorSv1) SetAccount(args *engine.AccountWithOpts, reply *string) error { +func (dS *DispatcherReplicatorSv1) SetAccount(args *engine.AccountWithAPIOpts, reply *string) error { return dS.dS.ReplicatorSv1SetAccount(args, reply) } // SetReverseDestination -func (dS *DispatcherReplicatorSv1) SetReverseDestination(args *engine.DestinationWithOpts, reply *string) error { +func (dS *DispatcherReplicatorSv1) SetReverseDestination(args *engine.DestinationWithAPIOpts, reply *string) error { return dS.dS.ReplicatorSv1SetReverseDestination(args, reply) } @@ -1067,7 +1067,7 @@ func (dS *DispatcherReplicatorSv1) SetStatQueue(args *engine.StatQueueWithAPIOpt } // SetFilter -func (dS *DispatcherReplicatorSv1) SetFilter(args *engine.FilterWithOpts, reply *string) error { +func (dS *DispatcherReplicatorSv1) SetFilter(args *engine.FilterWithAPIOpts, reply *string) error { return dS.dS.ReplicatorSv1SetFilter(args, reply) } diff --git a/apier/v1/filter_indexes_it_test.go b/apier/v1/filter_indexes_it_test.go index 822b47cc2..67a26cf4d 100644 --- a/apier/v1/filter_indexes_it_test.go +++ b/apier/v1/filter_indexes_it_test.go @@ -190,7 +190,7 @@ func testV1FIdxRpcConn(t *testing.T) { //ThresholdProfile func testV1FIdxSetThresholdProfile(t *testing.T) { var reply *engine.ThresholdProfile - filter = &engine.FilterWithOpts{ + filter = &engine.FilterWithAPIOpts{ Filter: &engine.Filter{ Tenant: tenant, ID: "TestFilter", @@ -285,7 +285,7 @@ func testV1FIdxComputeThresholdsIndexes(t *testing.T) { func testV1FIdxSetSecondThresholdProfile(t *testing.T) { var reply *engine.ThresholdProfile - filter = &engine.FilterWithOpts{ + filter = &engine.FilterWithAPIOpts{ Filter: &engine.Filter{ Tenant: tenant, ID: "TestFilter2", @@ -450,7 +450,7 @@ func testV1FIdxRemoveThresholdProfile(t *testing.T) { //StatQueueProfile func testV1FIdxSetStatQueueProfileIndexes(t *testing.T) { var reply *engine.StatQueueProfile - filter = &engine.FilterWithOpts{ + filter = &engine.FilterWithAPIOpts{ Filter: &engine.Filter{ Tenant: tenant, ID: "FLTR_1", @@ -553,7 +553,7 @@ func testV1FIdxComputeStatQueueProfileIndexes(t *testing.T) { func testV1FIdxSetSecondStatQueueProfileIndexes(t *testing.T) { var reply *engine.StatQueueProfile - filter = &engine.FilterWithOpts{ + filter = &engine.FilterWithAPIOpts{ Filter: &engine.Filter{ Tenant: tenant, ID: "FLTR_2", @@ -699,7 +699,7 @@ func testV1FIdxRemoveStatQueueProfile(t *testing.T) { //ResourceProfile func testV1FIdxSetResourceProfileIndexes(t *testing.T) { var reply *engine.ResourceProfile - filter = &engine.FilterWithOpts{ + filter = &engine.FilterWithAPIOpts{ Filter: &engine.Filter{ Tenant: tenant, ID: "FLTR_RES_RCFG1", @@ -792,7 +792,7 @@ func testV1FIdxComputeResourceProfileIndexes(t *testing.T) { func testV1FIdxSetSecondResourceProfileIndexes(t *testing.T) { var reply *engine.StatQueueProfile - filter = &engine.FilterWithOpts{ + filter = &engine.FilterWithAPIOpts{ Filter: &engine.Filter{ Tenant: tenant, ID: "FLTR_2", @@ -927,7 +927,7 @@ func testV1FIdxRemoveResourceProfile(t *testing.T) { //RouteProfile func testV1FIdxSetRouteProfileIndexes(t *testing.T) { var reply *engine.RouteProfile - filter = &engine.FilterWithOpts{ + filter = &engine.FilterWithAPIOpts{ Filter: &engine.Filter{ Tenant: tenant, ID: "FLTR_1", @@ -1027,7 +1027,7 @@ func testV1FIdxComputeRouteProfileIndexes(t *testing.T) { func testV1FIdxSetSecondRouteProfileIndexes(t *testing.T) { var reply *engine.RouteProfile - filter = &engine.FilterWithOpts{ + filter = &engine.FilterWithAPIOpts{ Filter: &engine.Filter{ Tenant: tenant, ID: "FLTR_2", @@ -1170,7 +1170,7 @@ func testV1FIdxRemoveRouteProfile(t *testing.T) { //AccountProfile func testV1FISetAccountProfileIndexes(t *testing.T) { var reply *utils.AccountProfile - filter = &engine.FilterWithOpts{ + filter = &engine.FilterWithAPIOpts{ Filter: &engine.Filter{ Tenant: tenant, ID: "ACCPRF_FLTR", @@ -1292,7 +1292,7 @@ func testV1FIComputeAccountProfileIndexes(t *testing.T) { func testV1FISetSecondFilterForAccountProfile(t *testing.T) { //new filter - filter = &engine.FilterWithOpts{ + filter = &engine.FilterWithAPIOpts{ Filter: &engine.Filter{ Tenant: tenant, ID: "ACCPRF_FLTR2", @@ -1439,7 +1439,7 @@ func testV1FIRemoveAccountProfile(t *testing.T) { //ActionProfile func testV1FISetActionProfileIndexes(t *testing.T) { //set a new filter in db - filter = &engine.FilterWithOpts{ + filter = &engine.FilterWithAPIOpts{ Filter: &engine.Filter{ Tenant: tenant, ID: "ACTION_FLTR", @@ -1604,7 +1604,7 @@ func testV1FIComputeActionProfileIndexes(t *testing.T) { func testVF1SetSecondActionProfile(t *testing.T) { //second filter in db - filter = &engine.FilterWithOpts{ + filter = &engine.FilterWithAPIOpts{ Filter: &engine.Filter{ Tenant: tenant, ID: "ACTION_FLTR2", @@ -1792,7 +1792,7 @@ func testV1FIRemoveActionProfile(t *testing.T) { //RateProfileRate Indexes func testV1FISetRateProfileRatesIndexes(t *testing.T) { //set a filter for our rates - filter = &engine.FilterWithOpts{ + filter = &engine.FilterWithAPIOpts{ Filter: &engine.Filter{ Tenant: tenant, ID: "RATE_FLTR1", @@ -1818,24 +1818,22 @@ func testV1FISetRateProfileRatesIndexes(t *testing.T) { } //set in db a ratePrf with double populated rates with our filter - ratePrfRates := &APIRateProfileWithCache{ - APIRateProfileWithOpts: &utils.APIRateProfileWithOpts{ - APIRateProfile: &utils.APIRateProfile{ - Tenant: "cgrates.org", - ID: "RP1", - FilterIDs: []string{"*string:~*req.Usage:10m"}, - MaxCostStrategy: "*free", - Rates: map[string]*utils.APIRate{ - "RT_WEEK": { - ID: "RT_WEEK", - FilterIDs: []string{"RATE_FLTR1", "*suffix:~*req.Account:1009"}, - ActivationTimes: "* * * * 1-5", - }, - "RT_MONTH": { - ID: "RT_MONTH", - FilterIDs: []string{"RATE_FLTR1"}, - ActivationTimes: "* * * * *", - }, + ratePrfRates := &utils.APIRateProfileWithOpts{ + APIRateProfile: &utils.APIRateProfile{ + Tenant: "cgrates.org", + ID: "RP1", + FilterIDs: []string{"*string:~*req.Usage:10m"}, + MaxCostStrategy: "*free", + Rates: map[string]*utils.APIRate{ + "RT_WEEK": { + ID: "RT_WEEK", + FilterIDs: []string{"RATE_FLTR1", "*suffix:~*req.Account:1009"}, + ActivationTimes: "* * * * 1-5", + }, + "RT_MONTH": { + ID: "RT_MONTH", + FilterIDs: []string{"RATE_FLTR1"}, + ActivationTimes: "* * * * *", }, }, }, @@ -1977,7 +1975,7 @@ func testV1FIComputeRateProfileRatesIndexes(t *testing.T) { func testV1FISetSecondRateProfileRate(t *testing.T) { //second filter for a new rate in the same rate profile - filter = &engine.FilterWithOpts{ + filter = &engine.FilterWithAPIOpts{ Filter: &engine.Filter{ Tenant: tenant, ID: "RTPRF_FLTR3", @@ -1998,19 +1996,17 @@ func testV1FISetSecondRateProfileRate(t *testing.T) { } //append a new rate in the same rate profile - ratePrfRates := &APIRateProfileWithCache{ - APIRateProfileWithOpts: &utils.APIRateProfileWithOpts{ - APIRateProfile: &utils.APIRateProfile{ - Tenant: "cgrates.org", - ID: "RP1", - FilterIDs: []string{"*string:~*req.Usage:10m"}, - MaxCostStrategy: "*free", - Rates: map[string]*utils.APIRate{ - "RT_YEAR": { - ID: "RT_YEAR", - FilterIDs: []string{"RTPRF_FLTR3"}, - ActivationTimes: "* * * * *", - }, + ratePrfRates := &utils.APIRateProfileWithOpts{ + APIRateProfile: &utils.APIRateProfile{ + Tenant: "cgrates.org", + ID: "RP1", + FilterIDs: []string{"*string:~*req.Usage:10m"}, + MaxCostStrategy: "*free", + Rates: map[string]*utils.APIRate{ + "RT_YEAR": { + ID: "RT_YEAR", + FilterIDs: []string{"RTPRF_FLTR3"}, + ActivationTimes: "* * * * *", }, }, }, @@ -2215,7 +2211,7 @@ func testVF1RemoveRateProfileRates(t *testing.T) { //RateProfile Indexes func testV1FISetRateProfileIndexes(t *testing.T) { //set a filter for our rates - filter = &engine.FilterWithOpts{ + filter = &engine.FilterWithAPIOpts{ Filter: &engine.Filter{ Tenant: tenant, ID: "RATEFLTR_FLTR1", @@ -2248,19 +2244,17 @@ func testV1FISetRateProfileIndexes(t *testing.T) { t.Error(err) } //set in db a ratePrf with with our filterS - ratePrfRates := &APIRateProfileWithCache{ - APIRateProfileWithOpts: &utils.APIRateProfileWithOpts{ - APIRateProfile: &utils.APIRateProfile{ - Tenant: "cgrates.org", - ID: "RP2", - FilterIDs: []string{"*string:~*req.Usage:10m", "RATEFLTR_FLTR1"}, - MaxCostStrategy: "*free", - Rates: map[string]*utils.APIRate{ - "RT_WEEK": { - ID: "RT_WEEK", - FilterIDs: []string{"*suffix:~*req.Account:1009"}, - ActivationTimes: "* * * * 1-5", - }, + ratePrfRates := &utils.APIRateProfileWithOpts{ + APIRateProfile: &utils.APIRateProfile{ + Tenant: "cgrates.org", + ID: "RP2", + FilterIDs: []string{"*string:~*req.Usage:10m", "RATEFLTR_FLTR1"}, + MaxCostStrategy: "*free", + Rates: map[string]*utils.APIRate{ + "RT_WEEK": { + ID: "RT_WEEK", + FilterIDs: []string{"*suffix:~*req.Account:1009"}, + ActivationTimes: "* * * * 1-5", }, }, }, @@ -2404,7 +2398,7 @@ func testV1FIComputeRateProfileIndexes(t *testing.T) { func testV1FISetSecondRateProfile(t *testing.T) { //second filter for a new rate profile - filter = &engine.FilterWithOpts{ + filter = &engine.FilterWithAPIOpts{ Filter: &engine.Filter{ Tenant: tenant, ID: "RTPRF_FLTR6", @@ -2425,19 +2419,17 @@ func testV1FISetSecondRateProfile(t *testing.T) { } //another rate profile - ratePrfRates := &APIRateProfileWithCache{ - APIRateProfileWithOpts: &utils.APIRateProfileWithOpts{ - APIRateProfile: &utils.APIRateProfile{ - Tenant: "cgrates.org", - ID: "RP3", - FilterIDs: []string{"RTPRF_FLTR6"}, - MaxCostStrategy: "*free", - Rates: map[string]*utils.APIRate{ - "RT_WEEK": { - ID: "RT_WEEK", - FilterIDs: []string{"*suffix:~*req.Account:1019"}, - ActivationTimes: "* * * * 1-5", - }, + ratePrfRates := &utils.APIRateProfileWithOpts{ + APIRateProfile: &utils.APIRateProfile{ + Tenant: "cgrates.org", + ID: "RP3", + FilterIDs: []string{"RTPRF_FLTR6"}, + MaxCostStrategy: "*free", + Rates: map[string]*utils.APIRate{ + "RT_WEEK": { + ID: "RT_WEEK", + FilterIDs: []string{"*suffix:~*req.Account:1019"}, + ActivationTimes: "* * * * 1-5", }, }, }, @@ -2589,7 +2581,7 @@ func testVF1RemoveRateProfile(t *testing.T) { //AttributeProfile Indexes func testV1FIdxSetAttributeProfileIndexes(t *testing.T) { var reply *engine.AttributeProfile - filter = &engine.FilterWithOpts{ + filter = &engine.FilterWithAPIOpts{ Filter: &engine.Filter{ Tenant: tenant, ID: "FLTR_1", @@ -2697,7 +2689,7 @@ func testV1FIdxComputeAttributeProfileIndexes(t *testing.T) { func testV1FIdxSetSecondAttributeProfileIndexes(t *testing.T) { var reply *engine.AttributeProfile - filter = &engine.FilterWithOpts{ + filter = &engine.FilterWithAPIOpts{ Filter: &engine.Filter{ Tenant: tenant, ID: "FLTR_2", diff --git a/apier/v1/filterindexecache_it_test.go b/apier/v1/filterindexecache_it_test.go index a2bd14e8f..82c32e582 100644 --- a/apier/v1/filterindexecache_it_test.go +++ b/apier/v1/filterindexecache_it_test.go @@ -163,7 +163,7 @@ func testV1FIdxCaProcessEventWithNotFound(t *testing.T) { } func testV1FIdxCaSetThresholdProfile(t *testing.T) { - filter = &engine.FilterWithOpts{ + filter = &engine.FilterWithAPIOpts{ Filter: &engine.Filter{ Tenant: "cgrates.org", ID: "TestFilter", @@ -269,7 +269,7 @@ func testV1FIdxCaGetThresholdFromTP(t *testing.T) { func testV1FIdxCaUpdateThresholdProfile(t *testing.T) { var result string - filter = &engine.FilterWithOpts{ + filter = &engine.FilterWithAPIOpts{ Filter: &engine.Filter{ Tenant: "cgrates.org", ID: "TestFilter2", @@ -361,7 +361,7 @@ func testV1FIdxCaUpdateThresholdProfile(t *testing.T) { func testV1FIdxCaUpdateThresholdProfileFromTP(t *testing.T) { var result string - filter = &engine.FilterWithOpts{ + filter = &engine.FilterWithAPIOpts{ Filter: &engine.Filter{ Tenant: "cgrates.org", ID: "TestFilter3", @@ -557,7 +557,7 @@ func testV1FIdxCaGetStatQueuesWithNotFound(t *testing.T) { func testV1FIdxCaSetStatQueueProfile(t *testing.T) { tenant := "cgrates.org" - filter = &engine.FilterWithOpts{ + filter = &engine.FilterWithAPIOpts{ Filter: &engine.Filter{ Tenant: tenant, ID: "FLTR_1", @@ -720,7 +720,7 @@ func testV1FIdxCaGetStatQueuesFromTP(t *testing.T) { } func testV1FIdxCaUpdateStatQueueProfile(t *testing.T) { - filter = &engine.FilterWithOpts{ + filter = &engine.FilterWithAPIOpts{ Filter: &engine.Filter{ Tenant: "cgrates.org", ID: "FLTR_2", @@ -798,7 +798,7 @@ func testV1FIdxCaUpdateStatQueueProfile(t *testing.T) { } func testV1FIdxCaUpdateStatQueueProfileFromTP(t *testing.T) { - filter = &engine.FilterWithOpts{ + filter = &engine.FilterWithAPIOpts{ Filter: &engine.Filter{ Tenant: "cgrates.org", ID: "FLTR_3", @@ -968,7 +968,7 @@ func testV1FIdxCaProcessAttributeProfileEventWithNotFound(t *testing.T) { } func testV1FIdxCaSetAttributeProfile(t *testing.T) { - filter = &engine.FilterWithOpts{ + filter = &engine.FilterWithAPIOpts{ Filter: &engine.Filter{ Tenant: "cgrates.org", ID: "TestFilter", @@ -1061,7 +1061,7 @@ func testV1FIdxCaGetAttributeProfileFromTP(t *testing.T) { } func testV1FIdxCaUpdateAttributeProfile(t *testing.T) { - filter = &engine.FilterWithOpts{ + filter = &engine.FilterWithAPIOpts{ Filter: &engine.Filter{ Tenant: "cgrates.org", ID: "TestFilter2", @@ -1134,7 +1134,7 @@ func testV1FIdxCaUpdateAttributeProfile(t *testing.T) { } func testV1FIdxCaUpdateAttributeProfileFromTP(t *testing.T) { - filter = &engine.FilterWithOpts{ + filter = &engine.FilterWithAPIOpts{ Filter: &engine.Filter{ Tenant: "cgrates.org", ID: "TestFilter3", @@ -1298,7 +1298,7 @@ func testV1FIdxCaGetResourceProfileWithNotFound(t *testing.T) { } func testV1FIdxCaSetResourceProfile(t *testing.T) { - filter = &engine.FilterWithOpts{ + filter = &engine.FilterWithAPIOpts{ Filter: &engine.Filter{ Tenant: "cgrates.org", ID: "FLTR_RES_RCFG1", @@ -1427,7 +1427,7 @@ func testV1FIdxCaGetResourceProfileFromTP(t *testing.T) { } func testV1FIdxCaUpdateResourceProfile(t *testing.T) { - filter = &engine.FilterWithOpts{ + filter = &engine.FilterWithAPIOpts{ Filter: &engine.Filter{ Tenant: "cgrates.org", ID: "FLTR_RES_RCFG2", @@ -1503,7 +1503,7 @@ func testV1FIdxCaUpdateResourceProfile(t *testing.T) { } func testV1FIdxCaUpdateResourceProfileFromTP(t *testing.T) { - filter = &engine.FilterWithOpts{ + filter = &engine.FilterWithAPIOpts{ Filter: &engine.Filter{ Tenant: "cgrates.org", ID: "FLTR_RES_RCFG3", diff --git a/apier/v1/filters.go b/apier/v1/filters.go index d07af7c58..9c36d7a35 100644 --- a/apier/v1/filters.go +++ b/apier/v1/filters.go @@ -26,7 +26,7 @@ import ( ) //SetFilter add a new Filter -func (apierSv1 *APIerSv1) SetFilter(arg *engine.FilterWithOpts, reply *string) error { +func (apierSv1 *APIerSv1) SetFilter(arg *engine.FilterWithAPIOpts, reply *string) error { if missing := utils.MissingStructFields(arg.Filter, []string{utils.ID}); len(missing) != 0 { return utils.NewErrMandatoryIeMissing(missing...) } @@ -41,8 +41,8 @@ func (apierSv1 *APIerSv1) SetFilter(arg *engine.FilterWithOpts, reply *string) e return utils.APIErrorHandler(err) } //handle caching for Filter - if err := apierSv1.CallCache(utils.IfaceAsString(arg.Opts[utils.CacheOpt]), arg.Tenant, utils.CacheFilters, - arg.TenantID(), nil, nil, arg.Opts); err != nil { + if err := apierSv1.CallCache(utils.IfaceAsString(arg.APIOpts[utils.CacheOpt]), arg.Tenant, utils.CacheFilters, + arg.TenantID(), nil, nil, arg.APIOpts); err != nil { return utils.APIErrorHandler(err) } *reply = utils.OK diff --git a/apier/v1/filters_it_test.go b/apier/v1/filters_it_test.go index e07509128..df8a4b211 100644 --- a/apier/v1/filters_it_test.go +++ b/apier/v1/filters_it_test.go @@ -36,7 +36,7 @@ var ( filterCfgPath string filterCfg *config.CGRConfig filterRPC *rpc.Client - filter *engine.FilterWithOpts + filter *engine.FilterWithAPIOpts filterConfigDIR string //run tests for specific configuration sTestsFilter = []func(t *testing.T){ @@ -118,7 +118,7 @@ func testFilterGetFilterBeforeSet(t *testing.T) { } func testFilterSetFilter(t *testing.T) { - filter = &engine.FilterWithOpts{ + filter = &engine.FilterWithAPIOpts{ Filter: &engine.Filter{ Tenant: "cgrates.org", ID: "Filter1", @@ -225,7 +225,7 @@ func testFilterKillEngine(t *testing.T) { } func testFilterSetFilterWithoutTenant(t *testing.T) { - filter = &engine.FilterWithOpts{ + filter = &engine.FilterWithAPIOpts{ Filter: &engine.Filter{ ID: "FilterWithoutTenant", Rules: []*engine.FilterRule{ diff --git a/apier/v1/full_remote_it_test.go b/apier/v1/full_remote_it_test.go index e28bfc9a8..c3c7d9890 100644 --- a/apier/v1/full_remote_it_test.go +++ b/apier/v1/full_remote_it_test.go @@ -596,30 +596,28 @@ func testFullRemoteITRate(t *testing.T) { } var replySet string - apiRPrf := &APIRateProfileWithCache{ - APIRateProfileWithOpts: &utils.APIRateProfileWithOpts{ - APIRateProfile: &utils.APIRateProfile{ - Tenant: "cgrates.org", - ID: "RP1", - FilterIDs: []string{"*string:~*req.Subject:1001"}, - Weights: ";0", - MaxCostStrategy: "*free", - Rates: map[string]*utils.APIRate{ - "RT_WEEK": { - ID: "RT_WEEK", - Weights: ";0", - ActivationTimes: "* * * * 1-5", - }, - "RT_WEEKEND": { - ID: "RT_WEEKEND", - Weights: ";10", - ActivationTimes: "* * * * 0,6", - }, - "RT_CHRISTMAS": { - ID: "RT_CHRISTMAS", - Weights: ";30", - ActivationTimes: "* * 24 12 *", - }, + apiRPrf := &utils.APIRateProfileWithOpts{ + APIRateProfile: &utils.APIRateProfile{ + Tenant: "cgrates.org", + ID: "RP1", + FilterIDs: []string{"*string:~*req.Subject:1001"}, + Weights: ";0", + MaxCostStrategy: "*free", + Rates: map[string]*utils.APIRate{ + "RT_WEEK": { + ID: "RT_WEEK", + Weights: ";0", + ActivationTimes: "* * * * 1-5", + }, + "RT_WEEKEND": { + ID: "RT_WEEKEND", + Weights: ";10", + ActivationTimes: "* * * * 0,6", + }, + "RT_CHRISTMAS": { + ID: "RT_CHRISTMAS", + Weights: ";30", + ActivationTimes: "* * 24 12 *", }, }, }, diff --git a/apier/v1/rateprofiles_it_test.go b/apier/v1/rateprofiles_it_test.go index 0584108d3..1befe1e34 100644 --- a/apier/v1/rateprofiles_it_test.go +++ b/apier/v1/rateprofiles_it_test.go @@ -297,17 +297,15 @@ func testV1RatePrfSetRateProfileRates(t *testing.T) { var reply string expErr := "SERVER_ERROR: broken reference to filter: *wrong:inline for item with ID: cgrates.org:RP1" if err := ratePrfRpc.Call(utils.APIerSv1SetRateProfile, - &APIRateProfileWithCache{ - APIRateProfileWithOpts: &utils.APIRateProfileWithOpts{ - APIRateProfile: apiRPrf}, + &utils.APIRateProfileWithOpts{ + APIRateProfile: apiRPrf, }, &reply); err == nil || err.Error() != expErr { t.Fatalf("Expected error: %q, received: %v", expErr, err) } apiRPrf.FilterIDs = []string{"*string:~*req.Subject:1001"} if err := ratePrfRpc.Call(utils.APIerSv1SetRateProfile, - &APIRateProfileWithCache{ - APIRateProfileWithOpts: &utils.APIRateProfileWithOpts{ - APIRateProfile: apiRPrf}, + &utils.APIRateProfileWithOpts{ + APIRateProfile: apiRPrf, }, &reply); err != nil { t.Fatal(err) } else if reply != utils.OK { @@ -357,18 +355,16 @@ func testV1RatePrfSetRateProfileRates(t *testing.T) { apiRPrfRates.Rates["RT_WEEK"].FilterIDs = []string{"*wrong:inline"} expErr = "SERVER_ERROR: broken reference to filter: *wrong:inline for rate with ID: RT_WEEK" if err := ratePrfRpc.Call(utils.APIerSv1SetRateProfileRates, - &APIRateProfileWithCache{ - APIRateProfileWithOpts: &utils.APIRateProfileWithOpts{ - APIRateProfile: apiRPrfRates}, + &utils.APIRateProfileWithOpts{ + APIRateProfile: apiRPrfRates, }, &reply); err == nil || err.Error() != expErr { t.Fatalf("Expected error: %q, received: %v", expErr, err) } apiRPrfRates.Rates["RT_WEEK"].FilterIDs = nil if err := ratePrfRpc.Call(utils.APIerSv1SetRateProfileRates, - &APIRateProfileWithCache{ - APIRateProfileWithOpts: &utils.APIRateProfileWithOpts{ - APIRateProfile: apiRPrfRates}, + &utils.APIRateProfileWithOpts{ + APIRateProfile: apiRPrfRates, }, &reply); err != nil { t.Fatal(err) } else if reply != utils.OK { @@ -488,9 +484,8 @@ func testV1RatePrfRemoveRateProfileRates(t *testing.T) { } var reply string if err := ratePrfRpc.Call(utils.APIerSv1SetRateProfile, - &APIRateProfileWithCache{ - APIRateProfileWithOpts: &utils.APIRateProfileWithOpts{ - APIRateProfile: apiRPrf}, + &utils.APIRateProfileWithOpts{ + APIRateProfile: apiRPrf, }, &reply); err != nil { t.Fatal(err) } else if reply != utils.OK { @@ -638,22 +633,20 @@ func testV1RateGetRemoveRateProfileWithoutTenant(t *testing.T) { if *encoding == utils.MetaGOB { rateProfile.Rates["RT_WEEK"].FilterIDs = nil } - apiRPrf := &APIRateProfileWithCache{ - APIRateProfileWithOpts: &utils.APIRateProfileWithOpts{ - APIRateProfile: &utils.APIRateProfile{ - ID: "RPWithoutTenant", - FilterIDs: []string{"*string:~*req.Subject:1001"}, - Weights: ";0", - MaxCostStrategy: "*free", - Rates: map[string]*utils.APIRate{ - "RT_WEEK": { - ID: "RT_WEEK", - Weights: ";0", - ActivationTimes: "* * * * 1-5", - IntervalRates: []*utils.APIIntervalRate{ - { - IntervalStart: "0", - }, + apiRPrf := &utils.APIRateProfileWithOpts{ + APIRateProfile: &utils.APIRateProfile{ + ID: "RPWithoutTenant", + FilterIDs: []string{"*string:~*req.Subject:1001"}, + Weights: ";0", + MaxCostStrategy: "*free", + Rates: map[string]*utils.APIRate{ + "RT_WEEK": { + ID: "RT_WEEK", + Weights: ";0", + ActivationTimes: "* * * * 1-5", + IntervalRates: []*utils.APIIntervalRate{ + { + IntervalStart: "0", }, }, }, @@ -771,29 +764,27 @@ func testV1RatePrfGetRateProfileRatesWithoutTenant(t *testing.T) { }, }, } - apiRPrf := &APIRateProfileWithCache{ - APIRateProfileWithOpts: &utils.APIRateProfileWithOpts{ - APIRateProfile: &utils.APIRateProfile{ - ID: "SpecialRate", - FilterIDs: []string{"*string:~*req.Subject:1001"}, - Weights: ";0", - MaxCostStrategy: "*free", - Rates: map[string]*utils.APIRate{ - "RT_WEEK": { - ID: "RT_WEEK", - Weights: ";0", - ActivationTimes: "* * * * 1-5", - }, - "RT_WEEKEND": { - ID: "RT_WEEKEND", - Weights: ";10", - ActivationTimes: "* * * * 0,6", - }, - "RT_CHRISTMAS": { - ID: "RT_CHRISTMAS", - Weights: ";30", - ActivationTimes: "* * 24 12 *", - }, + apiRPrf := &utils.APIRateProfileWithOpts{ + APIRateProfile: &utils.APIRateProfile{ + ID: "SpecialRate", + FilterIDs: []string{"*string:~*req.Subject:1001"}, + Weights: ";0", + MaxCostStrategy: "*free", + Rates: map[string]*utils.APIRate{ + "RT_WEEK": { + ID: "RT_WEEK", + Weights: ";0", + ActivationTimes: "* * * * 1-5", + }, + "RT_WEEKEND": { + ID: "RT_WEEKEND", + Weights: ";10", + ActivationTimes: "* * * * 0,6", + }, + "RT_CHRISTMAS": { + ID: "RT_CHRISTMAS", + Weights: ";30", + ActivationTimes: "* * 24 12 *", }, }, }, @@ -863,30 +854,28 @@ func testV1RateCostForEventWithDefault(t *testing.T) { }, }, } - rPrf := &APIRateProfileWithCache{ - APIRateProfileWithOpts: &utils.APIRateProfileWithOpts{ - APIRateProfile: &utils.APIRateProfile{ - ID: "DefaultRate", - FilterIDs: []string{"*string:~*req.Subject:1001"}, - Weights: ";10", - Rates: map[string]*utils.APIRate{ - "RATE1": &utils.APIRate{ - ID: "RATE1", - Weights: ";0", - ActivationTimes: "* * * * *", - IntervalRates: []*utils.APIIntervalRate{ - { - IntervalStart: "0", - RecurrentFee: utils.Float64Pointer(0.12), - Unit: utils.Float64Pointer(60000000000), - Increment: utils.Float64Pointer(60000000000), - }, - { - IntervalStart: "1m", - RecurrentFee: utils.Float64Pointer(0.06), - Unit: utils.Float64Pointer(60000000000), - Increment: utils.Float64Pointer(1000000000), - }, + rPrf := &utils.APIRateProfileWithOpts{ + APIRateProfile: &utils.APIRateProfile{ + ID: "DefaultRate", + FilterIDs: []string{"*string:~*req.Subject:1001"}, + Weights: ";10", + Rates: map[string]*utils.APIRate{ + "RATE1": &utils.APIRate{ + ID: "RATE1", + Weights: ";0", + ActivationTimes: "* * * * *", + IntervalRates: []*utils.APIIntervalRate{ + { + IntervalStart: "0", + RecurrentFee: utils.Float64Pointer(0.12), + Unit: utils.Float64Pointer(60000000000), + Increment: utils.Float64Pointer(60000000000), + }, + { + IntervalStart: "1m", + RecurrentFee: utils.Float64Pointer(0.06), + Unit: utils.Float64Pointer(60000000000), + Increment: utils.Float64Pointer(1000000000), }, }, }, diff --git a/apier/v1/remote_it_test.go b/apier/v1/remote_it_test.go index 06bdc1210..53fa405aa 100644 --- a/apier/v1/remote_it_test.go +++ b/apier/v1/remote_it_test.go @@ -711,30 +711,28 @@ func testInternalRemoteITGetRateProfile(t *testing.T) { }, }, } - apiRPrf := &APIRateProfileWithCache{ - APIRateProfileWithOpts: &utils.APIRateProfileWithOpts{ - APIRateProfile: &utils.APIRateProfile{ - Tenant: "cgrates.org", - ID: "RP1", - FilterIDs: []string{"*string:~*req.Subject:1001"}, - Weights: ";0", - MaxCostStrategy: "*free", - Rates: map[string]*utils.APIRate{ - "RT_WEEK": { - ID: "RT_WEEK", - Weights: ";0", - ActivationTimes: "* * * * 1-5", - }, - "RT_WEEKEND": { - ID: "RT_WEEKEND", - Weights: ";10", - ActivationTimes: "* * * * 0,6", - }, - "RT_CHRISTMAS": { - ID: "RT_CHRISTMAS", - Weights: ";30", - ActivationTimes: "* * 24 12 *", - }, + apiRPrf := &utils.APIRateProfileWithOpts{ + APIRateProfile: &utils.APIRateProfile{ + Tenant: "cgrates.org", + ID: "RP1", + FilterIDs: []string{"*string:~*req.Subject:1001"}, + Weights: ";0", + MaxCostStrategy: "*free", + Rates: map[string]*utils.APIRate{ + "RT_WEEK": { + ID: "RT_WEEK", + Weights: ";0", + ActivationTimes: "* * * * 1-5", + }, + "RT_WEEKEND": { + ID: "RT_WEEKEND", + Weights: ";10", + ActivationTimes: "* * * * 0,6", + }, + "RT_CHRISTMAS": { + ID: "RT_CHRISTMAS", + Weights: ";30", + ActivationTimes: "* * 24 12 *", }, }, }, diff --git a/apier/v1/replicate_it_test.go b/apier/v1/replicate_it_test.go index 82e1fd17d..a93b03cf0 100644 --- a/apier/v1/replicate_it_test.go +++ b/apier/v1/replicate_it_test.go @@ -698,7 +698,7 @@ func testInternalReplicateITFilter(t *testing.T) { t.Error(err) } //set - filter = &engine.FilterWithOpts{ + filter = &engine.FilterWithAPIOpts{ Filter: &engine.Filter{ Tenant: "cgrates.org", ID: "Filter1", @@ -981,7 +981,7 @@ func testInternalReplicateITThresholdProfile(t *testing.T) { t.Error(err) } // set - filter = &engine.FilterWithOpts{ + filter = &engine.FilterWithAPIOpts{ Filter: &engine.Filter{ Tenant: tenant, ID: "TestFilter", diff --git a/apier/v1/replicator.go b/apier/v1/replicator.go index 1c6ad7764..ed8679398 100644 --- a/apier/v1/replicator.go +++ b/apier/v1/replicator.go @@ -366,7 +366,7 @@ func (rplSv1 *ReplicatorSv1) GetIndexes(args *utils.GetIndexesArg, reply *map[st } // SetAccount is the replication method coresponding to the dataDb driver method -func (rplSv1 *ReplicatorSv1) SetAccount(acc *engine.AccountWithOpts, reply *string) (err error) { +func (rplSv1 *ReplicatorSv1) SetAccount(acc *engine.AccountWithAPIOpts, reply *string) (err error) { if err = rplSv1.dm.DataDB().SetAccountDrv(acc.Account); err != nil { return } @@ -376,12 +376,12 @@ func (rplSv1 *ReplicatorSv1) SetAccount(acc *engine.AccountWithOpts, reply *stri } // SetDestination is the replication method coresponding to the dataDb driver method -func (rplSv1 *ReplicatorSv1) SetDestination(dst *engine.DestinationWithOpts, reply *string) (err error) { +func (rplSv1 *ReplicatorSv1) SetDestination(dst *engine.DestinationWithAPIOpts, reply *string) (err error) { if err = rplSv1.dm.DataDB().SetDestinationDrv(dst.Destination, utils.NonTransactional); err != nil { return } - if err = rplSv1.v1.CallCache(utils.IfaceAsString(dst.Opts[utils.CacheOpt]), - dst.Tenant, utils.CacheDestinations, dst.Id, nil, nil, dst.Opts); err != nil { + if err = rplSv1.v1.CallCache(utils.IfaceAsString(dst.APIOpts[utils.CacheOpt]), + dst.Tenant, utils.CacheDestinations, dst.Id, nil, nil, dst.APIOpts); err != nil { return } *reply = utils.OK @@ -389,12 +389,12 @@ func (rplSv1 *ReplicatorSv1) SetDestination(dst *engine.DestinationWithOpts, rep } // SetReverseDestination is the replication method coresponding to the dataDb driver method -func (rplSv1 *ReplicatorSv1) SetReverseDestination(dst *engine.DestinationWithOpts, reply *string) (err error) { +func (rplSv1 *ReplicatorSv1) SetReverseDestination(dst *engine.DestinationWithAPIOpts, reply *string) (err error) { if err = rplSv1.dm.DataDB().SetReverseDestinationDrv(dst.Destination.Id, dst.Destination.Prefixes, utils.NonTransactional); err != nil { return } - if err = rplSv1.v1.callCacheMultiple(utils.IfaceAsString(dst.Opts[utils.CacheOpt]), - dst.Tenant, utils.CacheReverseDestinations, dst.Prefixes, dst.Opts); err != nil { + if err = rplSv1.v1.callCacheMultiple(utils.IfaceAsString(dst.APIOpts[utils.CacheOpt]), + dst.Tenant, utils.CacheReverseDestinations, dst.Prefixes, dst.APIOpts); err != nil { return } *reply = utils.OK @@ -454,12 +454,12 @@ func (rplSv1 *ReplicatorSv1) SetStatQueue(sq *engine.StatQueueWithAPIOpts, reply } // SetFilter is the replication method coresponding to the dataDb driver method -func (rplSv1 *ReplicatorSv1) SetFilter(fltr *engine.FilterWithOpts, reply *string) (err error) { +func (rplSv1 *ReplicatorSv1) SetFilter(fltr *engine.FilterWithAPIOpts, reply *string) (err error) { if err = rplSv1.dm.DataDB().SetFilterDrv(fltr.Filter); err != nil { return } - if err = rplSv1.v1.CallCache(utils.IfaceAsString(fltr.Opts[utils.CacheOpt]), - fltr.Tenant, utils.CacheFilters, fltr.TenantID(), nil, nil, fltr.Opts); err != nil { + if err = rplSv1.v1.CallCache(utils.IfaceAsString(fltr.APIOpts[utils.CacheOpt]), + fltr.Tenant, utils.CacheFilters, fltr.TenantID(), nil, nil, fltr.APIOpts); err != nil { return } *reply = utils.OK diff --git a/apier/v1/stats_it_test.go b/apier/v1/stats_it_test.go index 99044ba57..1c4b5a845 100644 --- a/apier/v1/stats_it_test.go +++ b/apier/v1/stats_it_test.go @@ -461,7 +461,7 @@ func testV1STSSetStatQueueProfile(t *testing.T) { t.Fatal(err) } statConfig.FilterIDs = []string{"FLTR_1"} - filter = &engine.FilterWithOpts{ + filter = &engine.FilterWithAPIOpts{ Filter: &engine.Filter{ Tenant: "cgrates.org", ID: "FLTR_1", @@ -519,7 +519,7 @@ func testV1STSGetStatQueueProfileIDs(t *testing.T) { func testV1STSUpdateStatQueueProfile(t *testing.T) { var result string - filter = &engine.FilterWithOpts{ + filter = &engine.FilterWithAPIOpts{ Filter: &engine.Filter{ Tenant: "cgrates.org", ID: "FLTR_2", diff --git a/console/filter_set.go b/console/filter_set.go index cc6030e10..488a0f99c 100644 --- a/console/filter_set.go +++ b/console/filter_set.go @@ -27,7 +27,7 @@ func init() { c := &CmdSetFilter{ name: "filter_set", rpcMethod: utils.APIerSv1SetFilter, - rpcParams: &engine.FilterWithOpts{}, + rpcParams: &engine.FilterWithAPIOpts{}, } commands[c.Name()] = c c.CommandExecuter = &CommandExecuter{c} @@ -37,7 +37,7 @@ func init() { type CmdSetFilter struct { name string rpcMethod string - rpcParams *engine.FilterWithOpts + rpcParams *engine.FilterWithAPIOpts *CommandExecuter } @@ -51,7 +51,7 @@ func (self *CmdSetFilter) RpcMethod() string { func (self *CmdSetFilter) RpcParams(reset bool) interface{} { if reset || self.rpcParams == nil { - self.rpcParams = &engine.FilterWithOpts{Filter: new(engine.Filter)} + self.rpcParams = &engine.FilterWithAPIOpts{Filter: new(engine.Filter)} } return self.rpcParams } diff --git a/dispatchers/replicator.go b/dispatchers/replicator.go index a5389d957..7a3bd5892 100644 --- a/dispatchers/replicator.go +++ b/dispatchers/replicator.go @@ -546,54 +546,54 @@ func (dS *DispatcherService) ReplicatorSv1SetThreshold(args *engine.ThresholdWit }, utils.MetaReplicator, utils.ReplicatorSv1SetThreshold, args, rpl) } -func (dS *DispatcherService) ReplicatorSv1SetDestination(args *engine.DestinationWithOpts, rpl *string) (err error) { +func (dS *DispatcherService) ReplicatorSv1SetDestination(args *engine.DestinationWithAPIOpts, rpl *string) (err error) { if args == nil { - args = &engine.DestinationWithOpts{} + args = &engine.DestinationWithAPIOpts{} } args.Tenant = utils.FirstNonEmpty(args.Tenant, dS.cfg.GeneralCfg().DefaultTenant) if len(dS.cfg.DispatcherSCfg().AttributeSConns) != 0 { if err = dS.authorize(utils.ReplicatorSv1SetDestination, 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.ReplicatorSv1SetDestination, args, rpl) } -func (dS *DispatcherService) ReplicatorSv1SetAccount(args *engine.AccountWithOpts, rpl *string) (err error) { +func (dS *DispatcherService) ReplicatorSv1SetAccount(args *engine.AccountWithAPIOpts, rpl *string) (err error) { if args == nil { - args = &engine.AccountWithOpts{} + args = &engine.AccountWithAPIOpts{} } tenant := utils.FirstNonEmpty(utils.SplitConcatenatedKey(args.ID)[0], dS.cfg.GeneralCfg().DefaultTenant) if len(dS.cfg.DispatcherSCfg().AttributeSConns) != 0 { if err = dS.authorize(utils.ReplicatorSv1SetAccount, 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: tenant, - Opts: args.Opts, + Opts: args.APIOpts, }, utils.MetaReplicator, utils.ReplicatorSv1SetAccount, args, rpl) } -func (dS *DispatcherService) ReplicatorSv1SetReverseDestination(args *engine.DestinationWithOpts, rpl *string) (err error) { +func (dS *DispatcherService) ReplicatorSv1SetReverseDestination(args *engine.DestinationWithAPIOpts, rpl *string) (err error) { if args == nil { - args = &engine.DestinationWithOpts{} + args = &engine.DestinationWithAPIOpts{} } args.Tenant = utils.FirstNonEmpty(args.Tenant, dS.cfg.GeneralCfg().DefaultTenant) if len(dS.cfg.DispatcherSCfg().AttributeSConns) != 0 { if err = dS.authorize(utils.ReplicatorSv1SetReverseDestination, 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.ReplicatorSv1SetReverseDestination, args, rpl) } @@ -614,20 +614,20 @@ func (dS *DispatcherService) ReplicatorSv1SetStatQueue(args *engine.StatQueueWit }, utils.MetaReplicator, utils.ReplicatorSv1SetStatQueue, args, rpl) } -func (dS *DispatcherService) ReplicatorSv1SetFilter(args *engine.FilterWithOpts, rpl *string) (err error) { +func (dS *DispatcherService) ReplicatorSv1SetFilter(args *engine.FilterWithAPIOpts, rpl *string) (err error) { if args == nil { - args = &engine.FilterWithOpts{} + args = &engine.FilterWithAPIOpts{} } args.Tenant = utils.FirstNonEmpty(args.Tenant, dS.cfg.GeneralCfg().DefaultTenant) if len(dS.cfg.DispatcherSCfg().AttributeSConns) != 0 { if err = dS.authorize(utils.ReplicatorSv1SetFilter, 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.ReplicatorSv1SetFilter, args, rpl) } diff --git a/dispatchers/replicator_it_test.go b/dispatchers/replicator_it_test.go index e517ba409..bcb95960b 100644 --- a/dispatchers/replicator_it_test.go +++ b/dispatchers/replicator_it_test.go @@ -136,13 +136,13 @@ func testDspRplPingFailover(t *testing.T) { func testDspRplAccount(t *testing.T) { // Set var replyStr string - attrSetAccount := &engine.AccountWithOpts{ + attrSetAccount := &engine.AccountWithAPIOpts{ Account: &engine.Account{ ID: "cgrates.org:1008", AllowNegative: true, Disabled: true, }, - Opts: map[string]interface{}{ + APIOpts: map[string]interface{}{ utils.OptsAPIKey: "repl12345", }, } @@ -496,12 +496,12 @@ func testDspRplDispatcherHost(t *testing.T) { func testDspRplFilter(t *testing.T) { // Set Filter var replyStr string - setFilter := &engine.FilterWithOpts{ + setFilter := &engine.FilterWithAPIOpts{ Filter: &engine.Filter{ Tenant: "cgrates.org", ID: "ID", }, - Opts: map[string]interface{}{ + APIOpts: map[string]interface{}{ utils.OptsAPIKey: "repl12345", }, } @@ -1372,11 +1372,11 @@ func testDspRplRatingProfile(t *testing.T) { func testDspRplDestination(t *testing.T) { // Set Destination var replyStr string - setDestination := &engine.DestinationWithOpts{ + setDestination := &engine.DestinationWithAPIOpts{ Destination: &engine.Destination{ Id: "idDestination"}, Tenant: "cgrates.org", - Opts: map[string]interface{}{ + APIOpts: map[string]interface{}{ utils.OptsAPIKey: "repl12345", }, } @@ -1473,8 +1473,8 @@ func testDspRplLoadIDs(t *testing.T) { func testDspRplRateProfile(t *testing.T) { // Set RateProfile var replyStr string - rPrf := &engine.RateProfileWithOpts{ - RateProfile: &engine.RateProfile{ + rPrf := &utils.RateProfileWithOpts{ + RateProfile: &utils.RateProfile{ Tenant: "cgrates.org", ID: "RP1", FilterIDs: []string{"*string:~*req.Subject:1001", "*string:~*req.Subject:1002"}, @@ -1484,7 +1484,7 @@ func testDspRplRateProfile(t *testing.T) { }, }, MaxCostStrategy: "*free", - Rates: map[string]*engine.Rate{ + Rates: map[string]*utils.Rate{ "FIRST_GI": { ID: "FIRST_GI", FilterIDs: []string{"*gi:~*req.Usage:0"}, @@ -1517,7 +1517,7 @@ func testDspRplRateProfile(t *testing.T) { t.Error("Unexpected reply returned", replyStr) } // Get RateProfile - var reply *engine.RateProfile + var reply *utils.RateProfile args := &utils.TenantIDWithAPIOpts{ TenantID: &utils.TenantID{ Tenant: "cgrates.org", diff --git a/engine/account.go b/engine/account.go index 6844859c6..2500eb7e5 100644 --- a/engine/account.go +++ b/engine/account.go @@ -45,9 +45,9 @@ type Account struct { executingTriggers bool } -type AccountWithOpts struct { +type AccountWithAPIOpts struct { *Account - Opts map[string]interface{} + APIOpts map[string]interface{} } // User's available minutes for the specified destination diff --git a/engine/caches.go b/engine/caches.go index c3645d8fb..d3756655c 100644 --- a/engine/caches.go +++ b/engine/caches.go @@ -59,7 +59,7 @@ func init() { gob.Register(new(RouteProfileWithOpts)) // Filters gob.Register(new(Filter)) - gob.Register(new(FilterWithOpts)) + gob.Register(new(FilterWithAPIOpts)) // Dispatcher gob.Register(new(DispatcherHost)) gob.Register(new(DispatcherHostProfile)) diff --git a/engine/datamanager.go b/engine/datamanager.go index 0e771968c..2836bb714 100644 --- a/engine/datamanager.go +++ b/engine/datamanager.go @@ -426,10 +426,10 @@ func (dm *DataManager) SetDestination(dest *Destination, transactionID string) ( config.CgrConfig().DataDbCfg().RplFiltered, utils.DestinationPrefix, dest.Id, // this are used to get the host IDs from cache utils.ReplicatorSv1SetDestination, - &DestinationWithOpts{ + &DestinationWithAPIOpts{ Destination: dest, Tenant: config.CgrConfig().GeneralCfg().DefaultTenant, - Opts: utils.GenerateDBItemOpts(itm.APIKey, itm.RouteID, + APIOpts: utils.GenerateDBItemOpts(itm.APIKey, itm.RouteID, config.CgrConfig().DataDbCfg().RplCache, utils.EmptyString)}) } return @@ -489,7 +489,7 @@ func (dm *DataManager) SetReverseDestination(destID string, prefixes []string, t config.CgrConfig().DataDbCfg().RplFiltered, utils.DestinationPrefix, destID, // this are used to get the host IDs from cache utils.ReplicatorSv1SetReverseDestination, - &DestinationWithOpts{Destination: &Destination{Id: destID, Prefixes: prefixes}}) + &DestinationWithAPIOpts{Destination: &Destination{Id: destID, Prefixes: prefixes}}) } return } @@ -629,9 +629,9 @@ func (dm *DataManager) SetAccount(acc *Account) (err error) { config.CgrConfig().DataDbCfg().RplFiltered, utils.AccountPrefix, acc.ID, // this are used to get the host IDs from cache utils.ReplicatorSv1SetAccount, - &AccountWithOpts{ + &AccountWithAPIOpts{ Account: acc, - Opts: utils.GenerateDBItemOpts(itm.APIKey, itm.RouteID, + APIOpts: utils.GenerateDBItemOpts(itm.APIKey, itm.RouteID, utils.EmptyString, utils.EmptyString)}) // the account doesn't have cache } return @@ -902,9 +902,9 @@ func (dm *DataManager) SetFilter(fltr *Filter, withIndex bool) (err error) { config.CgrConfig().DataDbCfg().RplFiltered, utils.FilterPrefix, fltr.TenantID(), // this are used to get the host IDs from cache utils.ReplicatorSv1SetFilter, - &FilterWithOpts{ + &FilterWithAPIOpts{ Filter: fltr, - 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/destinations.go b/engine/destinations.go index 2be937a54..db92601cf 100644 --- a/engine/destinations.go +++ b/engine/destinations.go @@ -37,10 +37,10 @@ type Destination struct { Prefixes []string } -type DestinationWithOpts struct { +type DestinationWithAPIOpts struct { *Destination - Tenant string - Opts map[string]interface{} + Tenant string + APIOpts map[string]interface{} } // returns prefix precision diff --git a/engine/filters.go b/engine/filters.go index b465f3247..f4b30aced 100644 --- a/engine/filters.go +++ b/engine/filters.go @@ -199,9 +199,9 @@ type Filter struct { } // FilterWithOpts the arguments for the replication -type FilterWithOpts struct { +type FilterWithAPIOpts struct { *Filter - Opts map[string]interface{} + APIOpts map[string]interface{} } // TenantID returns the tenant wit the ID diff --git a/general_tests/filtered_replication_it_test.go b/general_tests/filtered_replication_it_test.go index 631671e9b..93bacd30a 100644 --- a/general_tests/filtered_replication_it_test.go +++ b/general_tests/filtered_replication_it_test.go @@ -268,7 +268,7 @@ func testFltrRplAttributeProfile(t *testing.T) { func testFltrRplFilters(t *testing.T) { fltrID := "FLTR1" - fltr := &engine.FilterWithOpts{ + fltr := &engine.FilterWithAPIOpts{ Filter: &engine.Filter{ Tenant: "cgrates.org", ID: fltrID, @@ -1342,23 +1342,21 @@ func testFltrRplDispatcherHost(t *testing.T) { func testFltrRplRateProfile(t *testing.T) { rpID := "RP1" - rpPrf := &v1.APIRateProfileWithCache{ - APIRateProfileWithOpts: &utils.APIRateProfileWithOpts{ - APIRateProfile: &utils.APIRateProfile{ - Tenant: "cgrates.org", - ID: rpID, - FilterIDs: []string{"*string:~*req.Account:dan"}, - Weights: ";0", - MaxCostStrategy: "*free", - Rates: map[string]*utils.APIRate{ - "RT_WEEK": { - ID: "RT_WEEK", - Weights: ";0", - ActivationTimes: "* * * * 1-5", - IntervalRates: []*utils.APIIntervalRate{ - { - IntervalStart: "0", - }, + rpPrf := &utils.APIRateProfileWithOpts{ + APIRateProfile: &utils.APIRateProfile{ + Tenant: "cgrates.org", + ID: rpID, + FilterIDs: []string{"*string:~*req.Account:dan"}, + Weights: ";0", + MaxCostStrategy: "*free", + Rates: map[string]*utils.APIRate{ + "RT_WEEK": { + ID: "RT_WEEK", + Weights: ";0", + ActivationTimes: "* * * * 1-5", + IntervalRates: []*utils.APIIntervalRate{ + { + IntervalStart: "0", }, }, }, diff --git a/general_tests/filters_it_test.go b/general_tests/filters_it_test.go index 7dd19cd15..1f437754b 100644 --- a/general_tests/filters_it_test.go +++ b/general_tests/filters_it_test.go @@ -261,7 +261,7 @@ func testV1FltrAddStats(t *testing.T) { func testV1FltrPopulateThreshold(t *testing.T) { //Add a filter of type *stats and check if acd metric is minim 10 ( greater than 10) //we expect that acd from Stat_1 to be 11 so the filter should pass (11 > 10) - filter := &engine.FilterWithOpts{ + filter := &engine.FilterWithAPIOpts{ Filter: &engine.Filter{ Tenant: "cgrates.org", ID: "FLTR_TH_Stats1", @@ -345,7 +345,7 @@ func testV1FltrGetThresholdForEvent(t *testing.T) { func testV1FltrGetThresholdForEvent2(t *testing.T) { //Add a filter of type *stats and check if acd metric is maximum 10 ( lower than 10) //we expect that acd from Stat_1 to be 11 so the filter should not pass (11 > 10) - filter := &engine.FilterWithOpts{ + filter := &engine.FilterWithAPIOpts{ Filter: &engine.Filter{ Tenant: "cgrates.org", ID: "FLTR_TH_Stats1", @@ -450,7 +450,7 @@ func testV1FltrPopulateResources(t *testing.T) { //we allocate 3 units to resource and add a filter for Usages > 2 //should match (3>2) - filter := engine.FilterWithOpts{ + filter := engine.FilterWithAPIOpts{ Filter: &engine.Filter{ Tenant: "cgrates.org", ID: "FLTR_TH_Resource", @@ -596,7 +596,7 @@ func testV1FltrPopulateResourcesAvailableUnits(t *testing.T) { //as we allocate 9 units, there should be available 14 more //our filter should match for *gt or *gte - filter := engine.FilterWithOpts{ + filter := engine.FilterWithAPIOpts{ Filter: &engine.Filter{ Tenant: "cgrates.org", ID: "FLTR_ST_Resource1", @@ -664,7 +664,7 @@ func testV1FltrPopulateResourcesAvailableUnits(t *testing.T) { } //set another filter that will not match - filter = engine.FilterWithOpts{ + filter = engine.FilterWithAPIOpts{ Filter: &engine.Filter{ Tenant: "cgrates.org", ID: "FLTR_ST_Resource1", @@ -712,7 +712,7 @@ func testV1FltrAccounts(t *testing.T) { // Add a filter with fieldName taken value from account 1001 // and check if *monetary balance is minim 9 ( greater than 9) // we expect that the balance to be 10 so the filter should pass (10 > 9) - filter := engine.FilterWithOpts{ + filter := engine.FilterWithAPIOpts{ Filter: &engine.Filter{ Tenant: "cgrates.org", ID: "FLTR_TH_Accounts",