mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-20 14:48:43 +05:00
Updated dynamic path
This commit is contained in:
committed by
Dan Christian Bogos
parent
e140eca3cf
commit
24cc53e94a
@@ -65,7 +65,6 @@ func NewAgentRequest(req utils.DataProvider,
|
||||
Trailer: trailer,
|
||||
Opts: opts,
|
||||
}
|
||||
ar.dynamicProvider = utils.NewDynamicDataProvider(ar)
|
||||
// populate tenant
|
||||
if tntIf, err := ar.ParseField(
|
||||
&config.FCTemplate{Type: utils.META_COMPOSED,
|
||||
@@ -81,20 +80,19 @@ func NewAgentRequest(req utils.DataProvider,
|
||||
// AgentRequest represents data related to one request towards agent
|
||||
// implements utils.DataProvider so we can pass it to filters
|
||||
type AgentRequest struct {
|
||||
Request utils.DataProvider // request
|
||||
Vars utils.NavigableMap2 // shared data
|
||||
CGRRequest *utils.OrderedNavigableMap // Used in reply to access the request that was send
|
||||
CGRReply *utils.NavigableMap2
|
||||
Reply *utils.OrderedNavigableMap
|
||||
Tenant string
|
||||
Timezone string
|
||||
filterS *engine.FilterS
|
||||
Header utils.DataProvider
|
||||
Trailer utils.DataProvider
|
||||
diamreq *utils.OrderedNavigableMap // used in case of building requests (ie. DisconnectSession)
|
||||
tmp utils.NavigableMap2 // used in case you want to store temporary items and access them later
|
||||
Opts *utils.OrderedNavigableMap
|
||||
dynamicProvider *utils.DynamicDataProvider
|
||||
Request utils.DataProvider // request
|
||||
Vars utils.NavigableMap2 // shared data
|
||||
CGRRequest *utils.OrderedNavigableMap // Used in reply to access the request that was send
|
||||
CGRReply *utils.NavigableMap2
|
||||
Reply *utils.OrderedNavigableMap
|
||||
Tenant string
|
||||
Timezone string
|
||||
filterS *engine.FilterS
|
||||
Header utils.DataProvider
|
||||
Trailer utils.DataProvider
|
||||
diamreq *utils.OrderedNavigableMap // used in case of building requests (ie. DisconnectSession)
|
||||
tmp utils.NavigableMap2 // used in case you want to store temporary items and access them later
|
||||
Opts *utils.OrderedNavigableMap
|
||||
}
|
||||
|
||||
// String implements utils.DataProvider
|
||||
@@ -185,7 +183,7 @@ func (ar *AgentRequest) SetFields(tplFlds []*config.FCTemplate) (err error) {
|
||||
ar.tmp = utils.NavigableMap2{}
|
||||
for _, tplFld := range tplFlds {
|
||||
if pass, err := ar.filterS.Pass(ar.Tenant,
|
||||
tplFld.Filters, ar.dynamicProvider); err != nil {
|
||||
tplFld.Filters, ar); err != nil {
|
||||
return err
|
||||
} else if !pass {
|
||||
continue
|
||||
|
||||
@@ -335,9 +335,9 @@ func (dP *diameterDP) FieldAsInterface(fldPath []string) (data interface{}, err
|
||||
// lastPath can contain selector inside
|
||||
lastPath := fldPath[len(fldPath)-1]
|
||||
var slctrStr string
|
||||
if splt := strings.Split(lastPath, "<"); len(splt) != 1 {
|
||||
if splt := strings.Split(lastPath, utils.IdxStart); len(splt) != 1 {
|
||||
lastPath = splt[0]
|
||||
if splt[1][len(splt[1])-1:] != ">" {
|
||||
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 ]
|
||||
|
||||
@@ -84,20 +84,20 @@ func TestDPFieldAsInterface(t *testing.T) {
|
||||
}
|
||||
eOut = interface{}("208708000003") // with filter on second group item
|
||||
if out, err := dP.FieldAsInterface([]string{"Subscription-Id",
|
||||
"Subscription-Id-Data<1>"}); err != nil { // on index
|
||||
"Subscription-Id-Data[1]"}); err != nil { // on index
|
||||
t.Error(err)
|
||||
} else if eOut != out {
|
||||
t.Errorf("Expecting: %v, received: %v", eOut, out)
|
||||
}
|
||||
if out, err := dP.FieldAsInterface([]string{"Subscription-Id",
|
||||
"Subscription-Id-Data<~Subscription-Id-Type(1)>"}); err != nil { // on filter
|
||||
"Subscription-Id-Data[~Subscription-Id-Type(1)]"}); err != nil { // on filter
|
||||
t.Error(err)
|
||||
} else if out != eOut { // can be any result since both entries are matching single filter
|
||||
t.Errorf("expecting: %v, received: %v", eOut, out)
|
||||
}
|
||||
eOut = interface{}("208708000004")
|
||||
if out, err := dP.FieldAsInterface([]string{"Subscription-Id",
|
||||
"Subscription-Id-Data<~Subscription-Id-Type(2)|~Value-Digits(20000)>"}); err != nil { // on multiple filter
|
||||
"Subscription-Id-Data[~Subscription-Id-Type(2)|~Value-Digits(20000)]"}); err != nil { // on multiple filter
|
||||
t.Error(err)
|
||||
} else if eOut != out {
|
||||
t.Errorf("Expecting: %v, received: %v", eOut, out)
|
||||
|
||||
Reference in New Issue
Block a user