mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Rename *rsr_fields to *rsr
This commit is contained in:
committed by
Dan Christian Bogos
parent
8541335d39
commit
bd9e262d76
@@ -1,7 +1,7 @@
|
||||
#Tenant[0],ID[1],FilterType[2],FilterFieldName[3],FilterFieldValues[4],ActivationInterval[5]
|
||||
cgrates.org,FLTR_1,*string,Account,1001;1002,2014-07-29T15:00:00Z
|
||||
cgrates.org,FLTR_1,*string_prefix,Destination,10;20,
|
||||
cgrates.org,FLTR_1,*rsr_fields,,Subject(~^1.*1$);Destination(1002),
|
||||
cgrates.org,FLTR_1,*rsr,,Subject(~^1.*1$);Destination(1002),
|
||||
cgrates.org,FLTR_ACNT_1007,*string,Account,1007,2014-07-29T15:00:00Z
|
||||
cgrates.org,FLTR_ACNT_dan,*string,Account,dan,2014-07-29T15:00:00Z
|
||||
cgrates.org,FLTR_DST_DE,*destinations,Destination,DST_DE,2014-07-29T15:00:00Z
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
#Tenant[0],ID[1],FilterType[2],FilterFieldName[3],FilterFieldValues[4],ActivationInterval[5]
|
||||
cgrates.org,FLTR_1,*string,Account,1001;1002,2014-07-29T15:00:00Z
|
||||
cgrates.org,FLTR_1,*string_prefix,Destination,10;20,
|
||||
cgrates.org,FLTR_1,*rsr_fields,,Subject(~^1.*1$);Destination(1002),
|
||||
cgrates.org,FLTR_1,*rsr,,Subject(~^1.*1$);Destination(1002),
|
||||
cgrates.org,FLTR_ACNT_1007,*string,Account,1007,2014-07-29T15:00:00Z
|
||||
cgrates.org,FLTR_ACNT_dan,*string,Account,dan,2014-07-29T15:00:00Z
|
||||
cgrates.org,FLTR_DST_DE,*destinations,Destination,DST_DE_MOBILE,2014-07-29T15:00:00Z
|
||||
|
||||
|
@@ -33,7 +33,7 @@ const (
|
||||
MetaString = "*string"
|
||||
MetaStringPrefix = "*string_prefix"
|
||||
MetaTimings = "*timings"
|
||||
MetaRSRFields = "*rsr_fields"
|
||||
MetaRSR = "*rsr"
|
||||
MetaStatS = "*stats"
|
||||
MetaDestinations = "*destinations"
|
||||
MetaMinCapPrefix = "*min_"
|
||||
@@ -132,8 +132,8 @@ func (fS *FilterS) PassFiltersForEvent(tenant string, ev map[string]interface{},
|
||||
pass, err = fltr.passTimings(ev, "")
|
||||
case MetaDestinations:
|
||||
pass, err = fltr.passDestinations(ev, "")
|
||||
case MetaRSRFields:
|
||||
pass, err = fltr.passRSRFields(ev, "")
|
||||
case MetaRSR:
|
||||
pass, err = fltr.passRSR(ev, "")
|
||||
case MetaStatS:
|
||||
if err = fS.connStatS(); err != nil {
|
||||
return false, err
|
||||
@@ -175,7 +175,7 @@ func (f *Filter) Compile() (err error) {
|
||||
}
|
||||
|
||||
func NewRequestFilter(rfType, fieldName string, vals []string) (*RequestFilter, error) {
|
||||
if !utils.IsSliceMember([]string{MetaString, MetaStringPrefix, MetaTimings, MetaRSRFields, MetaStatS, MetaDestinations,
|
||||
if !utils.IsSliceMember([]string{MetaString, MetaStringPrefix, MetaTimings, MetaRSR, MetaStatS, MetaDestinations,
|
||||
MetaLessThan, MetaLessOrEqual, MetaGreaterThan, MetaGreaterOrEqual}, rfType) {
|
||||
return nil, fmt.Errorf("Unsupported filter Type: %s", rfType)
|
||||
}
|
||||
@@ -183,7 +183,7 @@ func NewRequestFilter(rfType, fieldName string, vals []string) (*RequestFilter,
|
||||
MetaLessThan, MetaLessOrEqual, MetaGreaterThan, MetaGreaterOrEqual}, rfType) {
|
||||
return nil, fmt.Errorf("FieldName is mandatory for Type: %s", rfType)
|
||||
}
|
||||
if len(vals) == 0 && utils.IsSliceMember([]string{MetaString, MetaStringPrefix, MetaTimings, MetaRSRFields,
|
||||
if len(vals) == 0 && utils.IsSliceMember([]string{MetaString, MetaStringPrefix, MetaTimings, MetaRSR,
|
||||
MetaDestinations, MetaDestinations, MetaLessThan, MetaLessOrEqual, MetaGreaterThan, MetaGreaterOrEqual}, rfType) {
|
||||
return nil, fmt.Errorf("Values is mandatory for Type: %s", rfType)
|
||||
}
|
||||
@@ -212,7 +212,7 @@ type RequestFilter struct {
|
||||
|
||||
// Separate method to compile RSR fields
|
||||
func (rf *RequestFilter) CompileValues() (err error) {
|
||||
if rf.Type == MetaRSRFields {
|
||||
if rf.Type == MetaRSR {
|
||||
if rf.rsrFields, err = utils.ParseRSRFieldsFromSlice(rf.Values); err != nil {
|
||||
return
|
||||
}
|
||||
@@ -251,8 +251,8 @@ func (fltr *RequestFilter) Pass(req interface{}, extraFieldsLabel string, rpcCln
|
||||
return fltr.passTimings(req, extraFieldsLabel)
|
||||
case MetaDestinations:
|
||||
return fltr.passDestinations(req, extraFieldsLabel)
|
||||
case MetaRSRFields:
|
||||
return fltr.passRSRFields(req, extraFieldsLabel)
|
||||
case MetaRSR:
|
||||
return fltr.passRSR(req, extraFieldsLabel)
|
||||
case MetaStatS:
|
||||
return fltr.passStatS(req, extraFieldsLabel, rpcClnt)
|
||||
case MetaLessThan, MetaLessOrEqual, MetaGreaterThan, MetaGreaterOrEqual:
|
||||
@@ -321,7 +321,7 @@ func (fltr *RequestFilter) passDestinations(req interface{}, extraFieldsLabel st
|
||||
return false, nil
|
||||
}
|
||||
|
||||
func (fltr *RequestFilter) passRSRFields(req interface{}, extraFieldsLabel string) (bool, error) {
|
||||
func (fltr *RequestFilter) passRSR(req interface{}, extraFieldsLabel string) (bool, error) {
|
||||
for _, rsrFld := range fltr.rsrFields {
|
||||
if strVal, err := utils.ReflectFieldAsString(req, rsrFld.Id, extraFieldsLabel); err != nil {
|
||||
if err == utils.ErrNotFound {
|
||||
|
||||
@@ -88,29 +88,29 @@ func TestReqFilterPassRSRFields(t *testing.T) {
|
||||
cd := &CallDescriptor{Direction: "*out", Category: "call", Tenant: "cgrates.org", Subject: "dan", Destination: "+4986517174963",
|
||||
TimeStart: time.Date(2013, time.October, 7, 14, 50, 0, 0, time.UTC), TimeEnd: time.Date(2013, time.October, 7, 14, 52, 12, 0, time.UTC),
|
||||
DurationIndex: 132 * time.Second, ExtraFields: map[string]string{"navigation": "off"}}
|
||||
rf, err := NewRequestFilter(MetaRSRFields, "", []string{"Tenant(~^cgr.*\\.org$)"})
|
||||
rf, err := NewRequestFilter(MetaRSR, "", []string{"Tenant(~^cgr.*\\.org$)"})
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
if passes, err := rf.passRSRFields(cd, "ExtraFields"); err != nil {
|
||||
if passes, err := rf.passRSR(cd, "ExtraFields"); err != nil {
|
||||
t.Error(err)
|
||||
} else if !passes {
|
||||
t.Error("Not passing")
|
||||
}
|
||||
rf, err = NewRequestFilter(MetaRSRFields, "", []string{"navigation(on)"})
|
||||
rf, err = NewRequestFilter(MetaRSR, "", []string{"navigation(on)"})
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
if passes, err := rf.passRSRFields(cd, "ExtraFields"); err != nil {
|
||||
if passes, err := rf.passRSR(cd, "ExtraFields"); err != nil {
|
||||
t.Error(err)
|
||||
} else if passes {
|
||||
t.Error("Passing")
|
||||
}
|
||||
rf, err = NewRequestFilter(MetaRSRFields, "", []string{"navigation(off)"})
|
||||
rf, err = NewRequestFilter(MetaRSR, "", []string{"navigation(off)"})
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
if passes, err := rf.passRSRFields(cd, "ExtraFields"); err != nil {
|
||||
if passes, err := rf.passRSR(cd, "ExtraFields"); err != nil {
|
||||
t.Error(err)
|
||||
} else if !passes {
|
||||
t.Error("Not passing")
|
||||
|
||||
@@ -285,7 +285,7 @@ cgrates.org,Threshold1,FLTR_1;FLTR_ACNT_dan,2014-07-29T15:00:00Z,true,10,1s,true
|
||||
#Tenant[0],ID[1],FilterType[2],FilterFieldName[3],FilterFieldValues[4],ActivationInterval[5]
|
||||
cgrates.org,FLTR_1,*string,Account,1001;1002,2014-07-29T15:00:00Z
|
||||
cgrates.org,FLTR_1,*string_prefix,Destination,10;20,2014-07-29T15:00:00Z
|
||||
cgrates.org,FLTR_1,*rsr_fields,,Subject(~^1.*1$);Destination(1002),
|
||||
cgrates.org,FLTR_1,*rsr,,Subject(~^1.*1$);Destination(1002),
|
||||
cgrates.org,FLTR_ACNT_dan,*string,Account,dan,2014-07-29T15:00:00Z
|
||||
cgrates.org,FLTR_DST_DE,*destinations,Destination,DST_DE,2014-07-29T15:00:00Z
|
||||
cgrates.org,FLTR_DST_NL,*destinations,Destination,DST_NL,2014-07-29T15:00:00Z
|
||||
@@ -1569,7 +1569,7 @@ func TestLoadFilters(t *testing.T) {
|
||||
},
|
||||
&utils.TPFilter{
|
||||
FieldName: "",
|
||||
Type: "*rsr_fields",
|
||||
Type: "*rsr",
|
||||
Values: []string{"Subject(~^1.*1$)", "Destination(1002)"},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -1137,7 +1137,7 @@ func testMigratorThreshold(t *testing.T) {
|
||||
Executed: false,
|
||||
LastExecutionTime: time.Now(),
|
||||
}
|
||||
x, err := engine.NewRequestFilter(engine.MetaRSRFields, "Directions", threshold.Balance.Directions.Slice())
|
||||
x, err := engine.NewRequestFilter(engine.MetaRSR, "Directions", threshold.Balance.Directions.Slice())
|
||||
if err != nil {
|
||||
t.Error("Error when creating new NewRequestFilter", err.Error())
|
||||
}
|
||||
|
||||
@@ -171,7 +171,7 @@ func (v2ATR v2ActionTrigger) AsThreshold() (thp *engine.ThresholdProfile, th *en
|
||||
var filters []*engine.RequestFilter
|
||||
if v2ATR.Balance.ID != nil && *v2ATR.Balance.ID != "" {
|
||||
if v2ATR.Balance.Directions != nil {
|
||||
x, err := engine.NewRequestFilter(engine.MetaRSRFields, "Directions", v2ATR.Balance.Directions.Slice())
|
||||
x, err := engine.NewRequestFilter(engine.MetaRSR, "Directions", v2ATR.Balance.Directions.Slice())
|
||||
if err != nil {
|
||||
return nil, nil, nil, err
|
||||
}
|
||||
@@ -289,7 +289,7 @@ func AsThreshold2(v2ATR engine.ActionTrigger) (thp *engine.ThresholdProfile, th
|
||||
var filters []*engine.RequestFilter
|
||||
if v2ATR.Balance.ID != nil && *v2ATR.Balance.ID != "" {
|
||||
if v2ATR.Balance.Directions != nil {
|
||||
x, err := engine.NewRequestFilter(engine.MetaRSRFields, "Directions", v2ATR.Balance.Directions.Slice())
|
||||
x, err := engine.NewRequestFilter(engine.MetaRSR, "Directions", v2ATR.Balance.Directions.Slice())
|
||||
if err != nil {
|
||||
return nil, nil, nil, err
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ func Testv2ActionTriggerAsThreshold(t *testing.T) {
|
||||
Executed: false,
|
||||
LastExecutionTime: time.Now(),
|
||||
}
|
||||
x, _ := engine.NewRequestFilter(engine.MetaRSRFields, "Directions", v2ATR.Balance.Directions.Slice())
|
||||
x, _ := engine.NewRequestFilter(engine.MetaRSR, "Directions", v2ATR.Balance.Directions.Slice())
|
||||
filters = append(filters, x)
|
||||
x, _ = engine.NewRequestFilter(engine.MetaDestinations, "DestinationIDs", v2ATR.Balance.DestinationIDs.Slice())
|
||||
filters = append(filters, x)
|
||||
|
||||
@@ -75,7 +75,7 @@ func (ev *CGREvent) FieldAsTime(fldName string, timezone string) (t time.Time, e
|
||||
return ParseTimeDetectLayout(s, timezone)
|
||||
}
|
||||
|
||||
// FieldAsTime returns a field as Duration instance
|
||||
// FieldAsDuration returns a field as Duration instance
|
||||
func (ev *CGREvent) FieldAsDuration(fldName string) (d time.Duration, err error) {
|
||||
iface, has := ev.Event[fldName]
|
||||
if !has {
|
||||
@@ -97,7 +97,7 @@ func (ev *CGREvent) FieldAsDuration(fldName string) (d time.Duration, err error)
|
||||
return ParseDurationWithNanosecs(s)
|
||||
}
|
||||
|
||||
// FieldAsFloat returns a field as float64 instance
|
||||
// FieldAsFloat64 returns a field as float64 instance
|
||||
func (ev *CGREvent) FieldAsFloat64(fldName string) (f float64, err error) {
|
||||
iface, has := ev.Event[fldName]
|
||||
if !has {
|
||||
|
||||
Reference in New Issue
Block a user