diff --git a/apier/v1/tpaccountactions_it_test.go b/apier/v1/tpaccountactions_it_test.go index ce96d83d5..40c23e8a4 100644 --- a/apier/v1/tpaccountactions_it_test.go +++ b/apier/v1/tpaccountactions_it_test.go @@ -1,4 +1,4 @@ -// +build integration +// +build offline /* Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments diff --git a/apier/v1/tpactionplans_it_test.go b/apier/v1/tpactionplans_it_test.go index f95a01a8f..6160b3a47 100644 --- a/apier/v1/tpactionplans_it_test.go +++ b/apier/v1/tpactionplans_it_test.go @@ -1,4 +1,4 @@ -// +build integration +// +build offline /* Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments diff --git a/apier/v1/tpactions_it_test.go b/apier/v1/tpactions_it_test.go index e0e2d93ee..e8976353d 100644 --- a/apier/v1/tpactions_it_test.go +++ b/apier/v1/tpactions_it_test.go @@ -1,4 +1,4 @@ -// +build integration +// +build offline /* Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments diff --git a/apier/v1/tpactiontriggers_it_test.go b/apier/v1/tpactiontriggers_it_test.go index 3fed4ab0e..7edea0c34 100644 --- a/apier/v1/tpactiontriggers_it_test.go +++ b/apier/v1/tpactiontriggers_it_test.go @@ -1,4 +1,4 @@ -// +build integration +// +build offline /* Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments diff --git a/apier/v1/tpattributes_it_test.go b/apier/v1/tpattributes_it_test.go index 2f8995822..088aab866 100644 --- a/apier/v1/tpattributes_it_test.go +++ b/apier/v1/tpattributes_it_test.go @@ -1,4 +1,4 @@ -// +build integration +// +build offline /* Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments diff --git a/apier/v1/tpchargers_it_test.go b/apier/v1/tpchargers_it_test.go index 910751118..7a4e20ef7 100644 --- a/apier/v1/tpchargers_it_test.go +++ b/apier/v1/tpchargers_it_test.go @@ -1,4 +1,4 @@ -// +build integration +// +build offline /* Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments diff --git a/apier/v1/tpdestinationrates_it_test.go b/apier/v1/tpdestinationrates_it_test.go index 5c6c96bfa..aa6731798 100644 --- a/apier/v1/tpdestinationrates_it_test.go +++ b/apier/v1/tpdestinationrates_it_test.go @@ -1,4 +1,4 @@ -// +build integration +// +build offline /* Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments diff --git a/apier/v1/tpdestinations_it_test.go b/apier/v1/tpdestinations_it_test.go index 70434045b..87c1cf9ba 100644 --- a/apier/v1/tpdestinations_it_test.go +++ b/apier/v1/tpdestinations_it_test.go @@ -1,4 +1,4 @@ -// +build integration +// +build offline /* Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments diff --git a/apier/v1/tpdispatchers_it_test.go b/apier/v1/tpdispatchers_it_test.go index 38692e6fd..232aae3f8 100644 --- a/apier/v1/tpdispatchers_it_test.go +++ b/apier/v1/tpdispatchers_it_test.go @@ -1,4 +1,4 @@ -// +build integration +// +build offline /* Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments diff --git a/apier/v1/tpfilters_it_test.go b/apier/v1/tpfilters_it_test.go index cdf4548d5..34958cf3e 100644 --- a/apier/v1/tpfilters_it_test.go +++ b/apier/v1/tpfilters_it_test.go @@ -1,4 +1,4 @@ -// +build integration +// +build offline /* Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments diff --git a/apier/v1/tprates_it_test.go b/apier/v1/tprates_it_test.go index c38a376ef..26210085e 100644 --- a/apier/v1/tprates_it_test.go +++ b/apier/v1/tprates_it_test.go @@ -1,4 +1,4 @@ -// +build integration +// +build offline /* Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments diff --git a/apier/v1/tpratingplans_it_test.go b/apier/v1/tpratingplans_it_test.go index 0180e5fc4..593a44e39 100644 --- a/apier/v1/tpratingplans_it_test.go +++ b/apier/v1/tpratingplans_it_test.go @@ -1,4 +1,4 @@ -// +build integration +// +build offline /* Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments diff --git a/apier/v1/tpratingprofiles_it_test.go b/apier/v1/tpratingprofiles_it_test.go index d5ea27d1b..4c42e6a4b 100644 --- a/apier/v1/tpratingprofiles_it_test.go +++ b/apier/v1/tpratingprofiles_it_test.go @@ -1,4 +1,4 @@ -// +build integration +// +build offline /* Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments diff --git a/apier/v1/tpresources_it_test.go b/apier/v1/tpresources_it_test.go index 53e09c7d5..558ee1512 100644 --- a/apier/v1/tpresources_it_test.go +++ b/apier/v1/tpresources_it_test.go @@ -1,4 +1,4 @@ -// +build integration +// +build offline /* Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments diff --git a/apier/v1/tpsharedgroups_it_test.go b/apier/v1/tpsharedgroups_it_test.go index 4ea93dbc8..d8804e39a 100644 --- a/apier/v1/tpsharedgroups_it_test.go +++ b/apier/v1/tpsharedgroups_it_test.go @@ -1,4 +1,4 @@ -// +build integration +// +build offline /* Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments diff --git a/apier/v1/tpstats_it_test.go b/apier/v1/tpstats_it_test.go index a964f4d6c..d530addfb 100644 --- a/apier/v1/tpstats_it_test.go +++ b/apier/v1/tpstats_it_test.go @@ -1,4 +1,4 @@ -// +build integration +// +build offline /* Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments diff --git a/apier/v1/tpsuppliers_it_test.go b/apier/v1/tpsuppliers_it_test.go index c8c575536..766344a70 100644 --- a/apier/v1/tpsuppliers_it_test.go +++ b/apier/v1/tpsuppliers_it_test.go @@ -1,4 +1,4 @@ -// +build integration +// +build offline /* Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments diff --git a/apier/v1/tpthresholds_it_test.go b/apier/v1/tpthresholds_it_test.go index 4c2303fd1..c998b938c 100644 --- a/apier/v1/tpthresholds_it_test.go +++ b/apier/v1/tpthresholds_it_test.go @@ -1,4 +1,4 @@ -// +build integration +// +build offline /* Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments diff --git a/apier/v1/tptimings_it_test.go b/apier/v1/tptimings_it_test.go index 00112a364..652a70f3c 100644 --- a/apier/v1/tptimings_it_test.go +++ b/apier/v1/tptimings_it_test.go @@ -1,4 +1,4 @@ -// +build integration +// +build offline /* Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments diff --git a/config/dataprovider.go b/config/dataprovider.go index a8fd30cd1..1f62c868b 100644 --- a/config/dataprovider.go +++ b/config/dataprovider.go @@ -19,9 +19,7 @@ along with this program. If not, see package config import ( - "fmt" "net" - "strconv" "strings" "github.com/cgrates/cgrates/utils" @@ -36,7 +34,7 @@ type DataProvider interface { RemoteHost() net.Addr } -func GetDynamicInterface(dnVal string, dP DataProvider) (interface{}, error) { +func DPDynamicInterface(dnVal string, dP DataProvider) (interface{}, error) { if strings.HasPrefix(dnVal, utils.DynamicDataPrefix) { dnVal = strings.TrimPrefix(dnVal, utils.DynamicDataPrefix) return dP.FieldAsInterface(strings.Split(dnVal, utils.NestingSep)) @@ -44,174 +42,10 @@ func GetDynamicInterface(dnVal string, dP DataProvider) (interface{}, error) { return utils.StringToInterface(dnVal), nil } -func GetDynamicString(dnVal string, dP DataProvider) (string, error) { +func DPDynamicString(dnVal string, dP DataProvider) (string, error) { if strings.HasPrefix(dnVal, utils.DynamicDataPrefix) { dnVal = strings.TrimPrefix(dnVal, utils.DynamicDataPrefix) return dP.FieldAsString(strings.Split(dnVal, utils.NestingSep)) } return dnVal, nil } - -//NewObjectDP constructs a DataProvider -func NewObjectDP(obj interface{}) (dP DataProvider) { - dP = &ObjectDP{obj: obj, cache: make(map[string]interface{})} - return -} - -type ObjectDP struct { - obj interface{} - cache map[string]interface{} -} - -func (objDp *ObjectDP) setCache(path string, val interface{}) { - objDp.cache[path] = val -} - -func (objDp *ObjectDP) getCache(path string) (val interface{}, has bool) { - val, has = objDp.cache[path] - return -} - -// String is part of engine.DataProvider interface -// when called, it will display the already parsed values out of cache -func (objDP *ObjectDP) String() string { - return utils.ToJSON(objDP.obj) -} - -// FieldAsInterface is part of engine.DataProvider interface -func (objDP *ObjectDP) FieldAsInterface(fldPath []string) (data interface{}, err error) { - // []string{ BalanceMap *monetary[0] Value } - var has bool - if data, has = objDP.getCache(strings.Join(fldPath, utils.NestingSep)); has { - return - } - - var prevFld string - for _, fld := range fldPath { - var slctrStr string - if splt := strings.Split(fld, utils.IdxStart); len(splt) != 1 { // check if we have selector - fld = splt[0] - if splt[1][len(splt[1])-1:] != utils.IdxEnd { - return nil, fmt.Errorf("filter rule <%s> needs to end in ]", splt[1]) - } - slctrStr = splt[1][:len(splt[1])-1] // also strip the last ] - } - if prevFld == utils.EmptyString { - prevFld += fld - } else { - prevFld += utils.NestingSep + fld - } - - // check if we take the current path from cache - if data, has = objDP.getCache(prevFld); !has { - if data, err = utils.ReflectFieldMethodInterface(objDP.obj, fld); err != nil { // take the object the field for current path - // in case of error set nil for the current path and return err - objDP.setCache(prevFld, nil) - return nil, err - } - // add the current field in prevFld so we can set in cache the full path with it's data - objDP.setCache(prevFld, data) - } - - // change the obj to be the current data and continue the processing - objDP.obj = data - if slctrStr != utils.EmptyString { //we have selector so we need to do an aditional get - prevFld += utils.IdxStart + slctrStr + utils.IdxEnd - // check if we take the current path from cache - if data, has = objDP.getCache(prevFld); !has { - if data, err = utils.ReflectFieldMethodInterface(objDP.obj, slctrStr); err != nil { // take the object the field for current path - // in case of error set nil for the current path and return err - objDP.setCache(prevFld, nil) - return nil, err - } - // add the current field in prevFld so we can set in cache the full path with it's data - objDP.setCache(prevFld, data) - } - // change the obj to be the current data and continue the processing - objDP.obj = data - } - - } - //add in cache the initial path - objDP.setCache(strings.Join(fldPath, utils.NestingSep), data) - return -} - -// FieldAsString is part of engine.DataProvider interface -func (objDP *ObjectDP) FieldAsString(fldPath []string) (data string, err error) { - var valIface interface{} - valIface, err = objDP.FieldAsInterface(fldPath) - if err != nil { - return - } - return utils.IfaceAsString(valIface), nil -} - -// AsNavigableMap is part of engine.DataProvider interface -func (objDP *ObjectDP) AsNavigableMap([]*FCTemplate) ( - nm *NavigableMap, err error) { - return nil, utils.ErrNotImplemented -} - -// RemoteHost is part of engine.DataProvider interface -func (objDP *ObjectDP) RemoteHost() net.Addr { - return utils.LocalAddr() -} - -// NewSliceDP constructs a DataProvider -func NewSliceDP(record []string) (dP DataProvider) { - dP = &SliceDP{req: record, cache: NewNavigableMap(nil)} - return -} - -// SliceDP implements engine.DataProvider so we can pass it to filters -type SliceDP struct { - req []string - cache *NavigableMap -} - -// String is part of engine.DataProvider interface -// when called, it will display the already parsed values out of cache -func (cP *SliceDP) String() string { - return utils.ToJSON(cP) -} - -// FieldAsInterface is part of engine.DataProvider interface -func (cP *SliceDP) FieldAsInterface(fldPath []string) (data interface{}, err error) { - if len(fldPath) != 1 { - return nil, utils.ErrNotFound - } - if data, err = cP.cache.FieldAsInterface(fldPath); err == nil || - err != utils.ErrNotFound { // item found in cache - return - } - err = nil // cancel previous err - if cfgFieldIdx, err := strconv.Atoi(fldPath[0]); err != nil || len(cP.req) <= cfgFieldIdx { - return nil, fmt.Errorf("Ignoring record: %v with error : %+v", cP.req, err) - } else { - data = cP.req[cfgFieldIdx] - } - cP.cache.Set(fldPath, data, false, false) - return -} - -// FieldAsString is part of engine.DataProvider interface -func (cP *SliceDP) FieldAsString(fldPath []string) (data string, err error) { - var valIface interface{} - valIface, err = cP.FieldAsInterface(fldPath) - if err != nil { - return - } - return utils.IfaceAsString(valIface), nil -} - -// AsNavigableMap is part of engine.DataProvider interface -func (cP *SliceDP) AsNavigableMap([]*FCTemplate) ( - nm *NavigableMap, err error) { - return nil, utils.ErrNotImplemented -} - -// RemoteHost is part of engine.DataProvider interface -func (cP *SliceDP) RemoteHost() net.Addr { - return utils.LocalAddr() -} diff --git a/config/objdp.go b/config/objdp.go new file mode 100644 index 000000000..7fb4ad9b4 --- /dev/null +++ b/config/objdp.go @@ -0,0 +1,133 @@ +/* +Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments +Copyright (C) ITsysCOM GmbH + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see +*/ + +package config + +import ( + "fmt" + "net" + "strings" + + "github.com/cgrates/cgrates/utils" +) + +//NewObjectDP constructs a DataProvider +func NewObjectDP(obj interface{}) (dP DataProvider) { + dP = &ObjectDP{obj: obj, cache: make(map[string]interface{})} + return +} + +type ObjectDP struct { + obj interface{} + cache map[string]interface{} +} + +func (objDp *ObjectDP) setCache(path string, val interface{}) { + objDp.cache[path] = val +} + +func (objDp *ObjectDP) getCache(path string) (val interface{}, has bool) { + val, has = objDp.cache[path] + return +} + +// String is part of engine.DataProvider interface +// when called, it will display the already parsed values out of cache +func (objDP *ObjectDP) String() string { + return utils.ToJSON(objDP.obj) +} + +// FieldAsInterface is part of engine.DataProvider interface +func (objDP *ObjectDP) FieldAsInterface(fldPath []string) (data interface{}, err error) { + // []string{ BalanceMap *monetary[0] Value } + var has bool + if data, has = objDP.getCache(strings.Join(fldPath, utils.NestingSep)); has { + return + } + + var prevFld string + for _, fld := range fldPath { + var slctrStr string + if splt := strings.Split(fld, utils.IdxStart); len(splt) != 1 { // check if we have selector + fld = splt[0] + if splt[1][len(splt[1])-1:] != utils.IdxEnd { + return nil, fmt.Errorf("filter rule <%s> needs to end in ]", splt[1]) + } + slctrStr = splt[1][:len(splt[1])-1] // also strip the last ] + } + if prevFld == utils.EmptyString { + prevFld += fld + } else { + prevFld += utils.NestingSep + fld + } + + // check if we take the current path from cache + if data, has = objDP.getCache(prevFld); !has { + if data, err = utils.ReflectFieldMethodInterface(objDP.obj, fld); err != nil { // take the object the field for current path + // in case of error set nil for the current path and return err + objDP.setCache(prevFld, nil) + return nil, err + } + // add the current field in prevFld so we can set in cache the full path with it's data + objDP.setCache(prevFld, data) + } + + // change the obj to be the current data and continue the processing + objDP.obj = data + if slctrStr != utils.EmptyString { //we have selector so we need to do an aditional get + prevFld += utils.IdxStart + slctrStr + utils.IdxEnd + // check if we take the current path from cache + if data, has = objDP.getCache(prevFld); !has { + if data, err = utils.ReflectFieldMethodInterface(objDP.obj, slctrStr); err != nil { // take the object the field for current path + // in case of error set nil for the current path and return err + objDP.setCache(prevFld, nil) + return nil, err + } + // add the current field in prevFld so we can set in cache the full path with it's data + objDP.setCache(prevFld, data) + } + // change the obj to be the current data and continue the processing + objDP.obj = data + } + + } + //add in cache the initial path + objDP.setCache(strings.Join(fldPath, utils.NestingSep), data) + return +} + +// FieldAsString is part of engine.DataProvider interface +func (objDP *ObjectDP) FieldAsString(fldPath []string) (data string, err error) { + var valIface interface{} + valIface, err = objDP.FieldAsInterface(fldPath) + if err != nil { + return + } + return utils.IfaceAsString(valIface), nil +} + +// AsNavigableMap is part of engine.DataProvider interface +func (objDP *ObjectDP) AsNavigableMap([]*FCTemplate) ( + nm *NavigableMap, err error) { + return nil, utils.ErrNotImplemented +} + +// RemoteHost is part of engine.DataProvider interface +func (objDP *ObjectDP) RemoteHost() net.Addr { + return utils.LocalAddr() +} diff --git a/config/slicedp.go b/config/slicedp.go new file mode 100644 index 000000000..5b2f59c61 --- /dev/null +++ b/config/slicedp.go @@ -0,0 +1,85 @@ +/* +Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments +Copyright (C) ITsysCOM GmbH + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see +*/ + +package config + +import ( + "fmt" + "net" + "strconv" + + "github.com/cgrates/cgrates/utils" +) + +// NewSliceDP constructs a DataProvider +func NewSliceDP(record []string) (dP DataProvider) { + dP = &SliceDP{req: record, cache: NewNavigableMap(nil)} + return +} + +// SliceDP implements engine.DataProvider so we can pass it to filters +type SliceDP struct { + req []string + cache *NavigableMap +} + +// String is part of engine.DataProvider interface +// when called, it will display the already parsed values out of cache +func (cP *SliceDP) String() string { + return utils.ToJSON(cP) +} + +// FieldAsInterface is part of engine.DataProvider interface +func (cP *SliceDP) FieldAsInterface(fldPath []string) (data interface{}, err error) { + if len(fldPath) != 1 { + return nil, utils.ErrNotFound + } + if data, err = cP.cache.FieldAsInterface(fldPath); err == nil || + err != utils.ErrNotFound { // item found in cache + return + } + err = nil // cancel previous err + if cfgFieldIdx, err := strconv.Atoi(fldPath[0]); err != nil || len(cP.req) <= cfgFieldIdx { + return nil, fmt.Errorf("Ignoring record: %v with error : %+v", cP.req, err) + } else { + data = cP.req[cfgFieldIdx] + } + cP.cache.Set(fldPath, data, false, false) + return +} + +// FieldAsString is part of engine.DataProvider interface +func (cP *SliceDP) FieldAsString(fldPath []string) (data string, err error) { + var valIface interface{} + valIface, err = cP.FieldAsInterface(fldPath) + if err != nil { + return + } + return utils.IfaceAsString(valIface), nil +} + +// AsNavigableMap is part of engine.DataProvider interface +func (cP *SliceDP) AsNavigableMap([]*FCTemplate) ( + nm *NavigableMap, err error) { + return nil, utils.ErrNotImplemented +} + +// RemoteHost is part of engine.DataProvider interface +func (cP *SliceDP) RemoteHost() net.Addr { + return utils.LocalAddr() +} diff --git a/engine/filters.go b/engine/filters.go index b684a0761..1ef1e8078 100644 --- a/engine/filters.go +++ b/engine/filters.go @@ -332,7 +332,7 @@ func (fltr *FilterRule) Pass(fieldNameDP config.DataProvider, } func (fltr *FilterRule) passString(fielNameDP config.DataProvider, fieldValuesDP []config.DataProvider) (bool, error) { - strVal, err := config.GetDynamicString(fltr.FieldName, fielNameDP) + strVal, err := config.DPDynamicString(fltr.FieldName, fielNameDP) if err != nil { if err == utils.ErrNotFound { return false, nil @@ -340,7 +340,7 @@ func (fltr *FilterRule) passString(fielNameDP config.DataProvider, fieldValuesDP return false, err } for i, val := range fltr.Values { - sval, err := config.GetDynamicString(val, fieldValuesDP[i]) + sval, err := config.DPDynamicString(val, fieldValuesDP[i]) if err != nil { continue } @@ -352,7 +352,7 @@ func (fltr *FilterRule) passString(fielNameDP config.DataProvider, fieldValuesDP } func (fltr *FilterRule) passExists(fielNameDP config.DataProvider) (bool, error) { - _, err := config.GetDynamicInterface(fltr.FieldName, fielNameDP) + _, err := config.DPDynamicInterface(fltr.FieldName, fielNameDP) if err != nil { if err == utils.ErrNotFound { return false, nil @@ -363,7 +363,7 @@ func (fltr *FilterRule) passExists(fielNameDP config.DataProvider) (bool, error) } func (fltr *FilterRule) passEmpty(fielNameDP config.DataProvider) (bool, error) { - val, err := config.GetDynamicInterface(fltr.FieldName, fielNameDP) + val, err := config.DPDynamicInterface(fltr.FieldName, fielNameDP) if err != nil { if err == utils.ErrNotFound { return true, nil @@ -393,7 +393,7 @@ func (fltr *FilterRule) passEmpty(fielNameDP config.DataProvider) (bool, error) } func (fltr *FilterRule) passStringPrefix(fielNameDP config.DataProvider, fieldValuesDP []config.DataProvider) (bool, error) { - strVal, err := config.GetDynamicString(fltr.FieldName, fielNameDP) + strVal, err := config.DPDynamicString(fltr.FieldName, fielNameDP) if err != nil { if err == utils.ErrNotFound { return false, nil @@ -401,7 +401,7 @@ func (fltr *FilterRule) passStringPrefix(fielNameDP config.DataProvider, fieldVa return false, err } for i, prfx := range fltr.Values { - prfx, err := config.GetDynamicString(prfx, fieldValuesDP[i]) + prfx, err := config.DPDynamicString(prfx, fieldValuesDP[i]) if err != nil { continue } @@ -413,7 +413,7 @@ func (fltr *FilterRule) passStringPrefix(fielNameDP config.DataProvider, fieldVa } func (fltr *FilterRule) passStringSuffix(fielNameDP config.DataProvider, fieldValuesDP []config.DataProvider) (bool, error) { - strVal, err := config.GetDynamicString(fltr.FieldName, fielNameDP) + strVal, err := config.DPDynamicString(fltr.FieldName, fielNameDP) if err != nil { if err == utils.ErrNotFound { return false, nil @@ -421,7 +421,7 @@ func (fltr *FilterRule) passStringSuffix(fielNameDP config.DataProvider, fieldVa return false, err } for i, prfx := range fltr.Values { - prfx, err := config.GetDynamicString(prfx, fieldValuesDP[i]) + prfx, err := config.DPDynamicString(prfx, fieldValuesDP[i]) if err != nil { continue } @@ -438,7 +438,7 @@ func (fltr *FilterRule) passTimings(fielNameDP config.DataProvider, fieldValuesD } func (fltr *FilterRule) passDestinations(fielNameDP config.DataProvider, fieldValuesDP []config.DataProvider) (bool, error) { - dst, err := config.GetDynamicString(fltr.FieldName, fielNameDP) + dst, err := config.DPDynamicString(fltr.FieldName, fielNameDP) if err != nil { if err == utils.ErrNotFound { return false, nil @@ -449,7 +449,7 @@ func (fltr *FilterRule) passDestinations(fielNameDP config.DataProvider, fieldVa if destIDs, err := dm.DataDB().GetReverseDestination(p, false, utils.NonTransactional); err == nil { for _, dID := range destIDs { for i, valDstID := range fltr.Values { - valDstID, err := config.GetDynamicString(valDstID, fieldValuesDP[i]) + valDstID, err := config.DPDynamicString(valDstID, fieldValuesDP[i]) if err != nil { continue } @@ -515,7 +515,7 @@ func (fltr *FilterRule) passRSR(fieldValuesDP []config.DataProvider) (bool, erro // } func (fltr *FilterRule) passGreaterThan(fielNameDP config.DataProvider, fieldValuesDP []config.DataProvider) (bool, error) { - fldIf, err := config.GetDynamicInterface(fltr.FieldName, fielNameDP) + fldIf, err := config.DPDynamicInterface(fltr.FieldName, fielNameDP) if err != nil { if err == utils.ErrNotFound { return false, nil @@ -531,7 +531,7 @@ func (fltr *FilterRule) passGreaterThan(fielNameDP config.DataProvider, fieldVal orEqual = true } for i, val := range fltr.Values { - sval, err := config.GetDynamicInterface(val, fieldValuesDP[i]) + sval, err := config.DPDynamicInterface(val, fieldValuesDP[i]) if err != nil { continue } @@ -580,7 +580,7 @@ func (fltr *FilterRule) passGreaterThan(fielNameDP config.DataProvider, fieldVal // } func (fltr *FilterRule) passEqualTo(fielNameDP config.DataProvider, fieldValuesDP []config.DataProvider) (bool, error) { - fldIf, err := config.GetDynamicInterface(fltr.FieldName, fielNameDP) + fldIf, err := config.DPDynamicInterface(fltr.FieldName, fielNameDP) if err != nil { if err == utils.ErrNotFound { return false, nil @@ -591,7 +591,7 @@ func (fltr *FilterRule) passEqualTo(fielNameDP config.DataProvider, fieldValuesD fldIf = utils.StringToInterface(fldStr) } for i, val := range fltr.Values { - sval, err := config.GetDynamicInterface(val, fieldValuesDP[i]) + sval, err := config.DPDynamicInterface(val, fieldValuesDP[i]) if err != nil { continue } diff --git a/integration_test.sh b/integration_test.sh index 1c07d61b4..10fc89d5e 100755 --- a/integration_test.sh +++ b/integration_test.sh @@ -41,8 +41,8 @@ dis=$? echo 'go test github.com/cgrates/cgrates/loaders -tags=integration' go test github.com/cgrates/cgrates/loaders -tags=integration lds=$? -echo 'go test github.com/cgrates/cgrates/ers -tags=integration' -go test github.com/cgrates/cgrates/ers -tags=integration -ers=$? +echo 'go test github.com/cgrates/cgrates/apier/v1 -tags=offline' +go test github.com/cgrates/cgrates/apier/v1 -tags=offline +offline=$? -exit $gen && $ap1 && $ap2 && $en && $cdrc && $cfg && $utl && $gnr && $agts && $smg && $mgr && $dis && $lds && $ers +exit $gen && $ap1 && $ap2 && $en && $cdrc && $cfg && $utl && $gnr && $agts && $smg && $mgr && $dis && $lds && $ers && offline