Updated dynamic path

This commit is contained in:
Trial97
2020-07-10 16:42:56 +03:00
committed by Dan Christian Bogos
parent e140eca3cf
commit 24cc53e94a
51 changed files with 398 additions and 629 deletions

View File

@@ -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

View File

@@ -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 ]

View File

@@ -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)

View File

@@ -32,14 +32,14 @@ var (
)
func NewRSRParsers(parsersRules string, rsrSeparator string) (prsrs RSRParsers, err error) {
if parsersRules == "" {
if parsersRules == utils.EmptyString {
return
}
if count := strings.Count(parsersRules, "`"); count%2 != 0 { // check if we have matching `
if count := strings.Count(parsersRules, utils.RSRConstSep); count%2 != 0 { // check if we have matching `
return nil, fmt.Errorf("Unclosed unspilit syntax")
} else if count != 0 {
var splitedRule []string
for idx := strings.IndexByte(parsersRules, '`'); idx != -1; idx = strings.IndexByte(parsersRules, '`') {
for idx := strings.IndexByte(parsersRules, utils.RSRConstChar); idx != -1; idx = strings.IndexByte(parsersRules, utils.RSRConstChar) {
insideARulePrefix := !strings.HasSuffix(parsersRules[:idx], utils.INFIELD_SEP) // if doesn't have ; we need to concatenate it with last rule
if insideARulePrefix {
splitedRule = append(splitedRule, strings.Split(parsersRules[:idx], utils.INFIELD_SEP)...)
@@ -47,7 +47,7 @@ func NewRSRParsers(parsersRules string, rsrSeparator string) (prsrs RSRParsers,
splitedRule = append(splitedRule, strings.Split(parsersRules[:idx-1], utils.INFIELD_SEP)...)
}
parsersRules = parsersRules[idx+1:]
idx = strings.IndexByte(parsersRules, '`')
idx = strings.IndexByte(parsersRules, utils.RSRConstChar)
if insideARulePrefix {
splitedRule[len(splitedRule)-1] += parsersRules[:idx]
} else {
@@ -60,7 +60,7 @@ func NewRSRParsers(parsersRules string, rsrSeparator string) (prsrs RSRParsers,
}
insideARuleSufix := !strings.HasPrefix(parsersRules, utils.INFIELD_SEP) // if doesn't have ; we need to concatenate it with last rule
if insideARuleSufix {
idx = strings.IndexByte(parsersRules, ';')
idx = strings.IndexByte(parsersRules, utils.FALLBACK_SEP) // ';'
if idx == -1 {
idx = len(parsersRules)
splitedRule[len(splitedRule)-1] += parsersRules[:idx]
@@ -81,8 +81,8 @@ func NewRSRParsers(parsersRules string, rsrSeparator string) (prsrs RSRParsers,
}
return NewRSRParsersFromSlice(splitedRule)
}
if dynIdxStart := strings.IndexByte(parsersRules, '<'); dynIdxStart != -1 {
if dynIdxEnd := strings.IndexByte(parsersRules[dynIdxStart:], '>'); dynIdxEnd != -1 {
if dynIdxStart := strings.IndexByte(parsersRules, utils.RSRDynStartChar); dynIdxStart != -1 {
if dynIdxEnd := strings.IndexByte(parsersRules[dynIdxStart:], utils.RSRDynEndChar); dynIdxEnd != -1 {
return NewDynRSRParser(parsersRules, rsrSeparator, dynIdxStart, dynIdxStart+dynIdxEnd)
}
}
@@ -137,7 +137,7 @@ func (prsrs RSRParsers) ParseValue(value interface{}) (out string, err error) {
for _, prsr := range prsrs {
var outPrsr string
if outPrsr, err = prsr.ParseValue(value); err != nil {
return "", err
return utils.EmptyString, err
}
out += outPrsr
}
@@ -148,7 +148,7 @@ func (prsrs RSRParsers) ParseDataProvider(dP utils.DataProvider) (out string, er
for _, prsr := range prsrs {
var outPrsr string
if outPrsr, err = prsr.ParseDataProvider(dP); err != nil {
return "", err
return utils.EmptyString, err
}
out += outPrsr
}
@@ -159,7 +159,7 @@ func (prsrs RSRParsers) ParseDataProviderWithInterfaces(dP utils.DataProvider) (
for _, prsr := range prsrs {
var outPrsr string
if outPrsr, err = prsr.ParseDataProviderWithInterfaces(dP); err != nil {
return "", err
return utils.EmptyString, err
}
out += outPrsr
}
@@ -206,8 +206,8 @@ func (prsr *RSRParser) AttrName() string {
// Compile parses Rules string and repopulates other fields
func (prsr *RSRParser) Compile() (err error) {
parserRules := prsr.Rules
if dynIdxStart := strings.IndexByte(parserRules, '<'); dynIdxStart != -1 {
if dynIdxEnd := strings.IndexByte(parserRules[dynIdxStart:], '>'); dynIdxEnd != -1 {
if dynIdxStart := strings.IndexByte(parserRules, utils.RSRDynStartChar); dynIdxStart != -1 {
if dynIdxEnd := strings.IndexByte(parserRules[dynIdxStart:], utils.RSRDynEndChar); dynIdxEnd != -1 {
var dynrules RSRParsers
if dynrules, err = NewRSRParsers(parserRules[dynIdxStart+1:dynIdxStart+dynIdxEnd],
CgrConfig().GeneralCfg().RSRSep); err != nil {
@@ -220,8 +220,8 @@ func (prsr *RSRParser) Compile() (err error) {
}
}
if idxConverters := strings.Index(parserRules, "{*"); idxConverters != -1 { // converters in the string
if !strings.HasSuffix(parserRules, "}") {
if idxConverters := strings.Index(parserRules, utils.RSRDataConverterPrefix); idxConverters != -1 { // converters in the string
if !strings.HasSuffix(parserRules, utils.RSRDataConverterSufix) {
return fmt.Errorf("invalid converter terminator in rule: <%s>",
parserRules)
}
@@ -368,8 +368,8 @@ func NewDynRSRParser(parsersRules string, sep string, idxStart, idxEnd int) (prs
return
}
lastRules := parsersRules[sepIdx+1:]
if dynIdxStart := strings.IndexByte(lastRules, '<'); dynIdxStart != -1 {
if dynIdxEnd := strings.IndexByte(lastRules[dynIdxStart:], '>'); dynIdxEnd != -1 {
if dynIdxStart := strings.IndexByte(lastRules, utils.RSRDynStartChar); dynIdxStart != -1 {
if dynIdxEnd := strings.IndexByte(lastRules[dynIdxStart:], utils.RSRDynEndChar); dynIdxEnd != -1 {
var lastrsr RSRParsers
if lastrsr, err = NewDynRSRParser(lastRules, sep,
dynIdxStart, dynIdxStart+dynIdxEnd); err != nil {

View File

@@ -34,7 +34,7 @@
{
"tag": "Account", "path": "*cgreq.Account",
"type": "*variable", "mandatory": true,
"value": "~*req.Subscription-Id.Subscription-Id-Data<~Subscription-Id-Type(1)>"
"value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(1)]"
},
{
"tag": "Destination", "path": "*cgreq.Destination",
@@ -93,7 +93,7 @@
{
"tag": "Account", "path": "Account",
"type": "*variable", "mandatory": true,
"value": "~*req.Subscription-Id.Subscription-Id-Data<~Subscription-Id-Type(0)>"
"value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]"
},
{
"tag": "Usage", "path": "Usage",
@@ -101,7 +101,7 @@
},
{
"tag": "LastUsed", "path": "LastUsed", "type": "*sum",
"value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Input-Octets<~Rating-Group(1)>;~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Output-Octets<~Rating-Group(1)>"
"value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Input-Octets[~Rating-Group(1)>;~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Output-Octets[~Rating-Group(1)]"
},
],
"reply_fields": [
@@ -119,7 +119,7 @@
"id": "data_update_grp2",
"filters": [
"*string:~*vars.*cmd:CCR", "*string:~*req.CC-Request-Type:2",
"*string:~*req.Multiple-Services-Credit-Control.Rating-Group<1>:2",
"*string:~*req.Multiple-Services-Credit-Control.Rating-Group[1]:2",
"*prefix:~*req.Service-Context-Id:gprs"
],
"flags": ["*update", "*accounts"],
@@ -148,7 +148,7 @@
{
"tag": "Account", "path": "Account",
"type": "*variable", "mandatory": true,
"value": "~*req.Subscription-Id.Subscription-Id-Data<~Subscription-Id-Type(0)>"
"value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]"
},
{
"tag": "Destination", "path": "Destination",
@@ -170,7 +170,7 @@
},
{
"tag": "LastUsed", "path": "LastUsed", "type": "*sum",
"value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Input-Octets<~Rating-Group(2)>;~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Output-Octets<~Rating-Group(2)>"
"value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Input-Octets[~Rating-Group(2)>;~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Output-Octets[~Rating-Group(2)]"
},
],
"reply_fields": [

View File

@@ -41,7 +41,7 @@
{
"tag": "Account", "path": "*cgreq.Account",
"type": "*variable", "mandatory": true,
"value": "~*req.Subscription-Id.Subscription-Id-Data<~Subscription-Id-Type(0)>"
"value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]"
},
{
"tag": "Destination", "path": "*cgreq.Destination",

View File

@@ -33,7 +33,7 @@
{
"tag": "Account", "path": "*cgreq.Account",
"type": "*variable", "mandatory": true,
"value": "~*req.Service-Information.IMS-Information.Calling-Party-Address<0>:s/tel:\\+(\\d+)/${1}/"
"value": "~*req.Service-Information.IMS-Information.Calling-Party-Address[0]:s/tel:\\+(\\d+)/${1}/"
},
{
"tag": "Account", "path": "*cgreq.Account",
@@ -125,7 +125,7 @@
{
"tag": "Account", "path": "*cgreq.Account",
"type": "*variable", "mandatory": true,
"value": "~*req.Service-Information.IMS-Information.Calling-Party-Address<0>:s/tel:\\+(\\d+)/${1}/"
"value": "~*req.Service-Information.IMS-Information.Calling-Party-Address[0]:s/tel:\\+(\\d+)/${1}/"
},
{
"tag": "Account", "path": "*cgreq.Account",

View File

@@ -38,7 +38,7 @@
"tag": "Account",
"path": "*cgreq.Account",
"type": "*variable",
"value": "~*req.Subscription-Id.Subscription-Id-Data<~Subscription-Id-Type(1)>",
"value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(1)]",
"mandatory": true
},
{
@@ -137,7 +137,7 @@
"tag": "Account",
"path": "*cgreq.Account",
"type": "*variable",
"value": "~*req.Subscription-Id.Subscription-Id-Data<~Subscription-Id-Type(0)>"
"value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]"
},
{
"tag": "Destination",
@@ -169,7 +169,7 @@
"tag": "LastUsed",
"path": "*cgreq.LastUsed",
"type": "*sum",
"value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Input-Octets<~Rating-Group(1)>;~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Output-Octets<~Rating-Group(1)>"
"value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Input-Octets[~Rating-Group(1)];~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Output-Octets[~Rating-Group(1)]"
},
],
"reply_fields": [
@@ -194,7 +194,7 @@
"filters": [
"*string:~*vars.*cmd:CCR",
"*string:~*req.CC-Request-Type:2",
"*string:~*req.Multiple-Services-Credit-Control.Rating-Group<1>:2",
"*string:~*req.Multiple-Services-Credit-Control.Rating-Group[1]:2",
"*prefix:~*req.Service-Context-Id:gprs"
],
"flags": ["*update", "*accounts"],
@@ -242,7 +242,7 @@
"path": "*cgreq.Account",
"type": "*variable",
"mandatory": true,
"value": "~*req.Subscription-Id.Subscription-Id-Data<~Subscription-Id-Type(0)>"
"value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]"
},
{
"tag": "Destination",
@@ -274,7 +274,7 @@
"tag": "LastUsed",
"path": "*cgreq.LastUsed",
"type": "*sum",
"value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Input-Octets<~Rating-Group(2)>;~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Output-Octets<~Rating-Group(2)>"
"value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Input-Octets[~Rating-Group(2)];~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Output-Octets[~Rating-Group(2)]"
},
],
"reply_fields": [
@@ -340,7 +340,7 @@
"path": "*cgreq.Account",
"type": "*variable",
"mandatory": true,
"value": "~*req.Subscription-Id.Subscription-Id-Data<~Subscription-Id-Type(0)>"
"value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]"
},
{
"tag": "Destination",

View File

@@ -65,14 +65,14 @@
"path": "*cgreq.UsedUnits1",
"type": "*variable",
"mandatory": true,
"value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets<~Rating-Group(1)>"
"value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets[~Rating-Group(1)]"
},
{
"tag": "UsedUnits2",
"path": "*cgreq.UsedUnits2",
"type": "*variable",
"mandatory": true,
"value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets<~Rating-Group(2)>"
"value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets[~Rating-Group(2)]"
},
],
@@ -167,14 +167,14 @@
"path": "*cgreq.UsedUnits1",
"type": "*variable",
"mandatory": true,
"value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets<~Rating-Group(1)>"
"value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets[~Rating-Group(1)]"
},
{
"tag": "UsedUnits2",
"path": "*cgreq.UsedUnits2",
"type": "*variable",
"mandatory": true,
"value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets<~Rating-Group(2)>"
"value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets[~Rating-Group(2)]"
},
],
"reply_fields":[

View File

@@ -42,7 +42,7 @@
"path": "*cgreq.Account",
"type": "*variable",
"mandatory": true,
"value": "~*req.Subscription-Id.Subscription-Id-Data<~Subscription-Id-Type(0)>"
"value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]"
},
{
"tag": "Destination",

View File

@@ -42,7 +42,7 @@
"path": "*cgreq.Account",
"type": "*variable",
"mandatory": true,
"value": "~*req.Subscription-Id.Subscription-Id-Data<~Subscription-Id-Type(0)>"
"value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]"
},
{
"tag": "Destination",

View File

@@ -42,7 +42,7 @@
"path": "*cgreq.Account",
"type": "*variable",
"mandatory": true,
"value": "~*req.Subscription-Id.Subscription-Id-Data<~Subscription-Id-Type(0)>"
"value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]"
},
{
"tag": "AnswerTime",

View File

@@ -43,7 +43,7 @@
"path": "*cgreq.Account",
"type": "*variable",
"mandatory": true,
"value": "~*req.Subscription-Id.Subscription-Id-Data<~Subscription-Id-Type(0)>"
"value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]"
},
{
"tag": "Destination",

View File

@@ -38,7 +38,7 @@
"tag": "Account",
"path": "*cgreq.Account",
"type": "*variable",
"value": "~*req.Subscription-Id.Subscription-Id-Data<~Subscription-Id-Type(1)>",
"value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(1)]",
"mandatory": true
},
{
@@ -137,7 +137,7 @@
"tag": "Account",
"path": "*cgreq.Account",
"type": "*variable",
"value": "~*req.Subscription-Id.Subscription-Id-Data<~Subscription-Id-Type(0)>"
"value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]"
},
{
"tag": "Destination",
@@ -169,7 +169,7 @@
"tag": "LastUsed",
"path": "*cgreq.LastUsed",
"type": "*sum",
"value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Input-Octets<~Rating-Group(1)>;~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Output-Octets<~Rating-Group(1)>"
"value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Input-Octets[~Rating-Group(1)];~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Output-Octets[~Rating-Group(1)]"
},
],
"reply_fields": [
@@ -194,7 +194,7 @@
"filters": [
"*string:~*vars.*cmd:CCR",
"*string:~*req.CC-Request-Type:2",
"*string:~*req.Multiple-Services-Credit-Control.Rating-Group<1>:2",
"*string:~*req.Multiple-Services-Credit-Control.Rating-Group[1]:2",
"*prefix:~*req.Service-Context-Id:gprs"
],
"flags": ["*update", "*accounts"],
@@ -242,7 +242,7 @@
"path": "*cgreq.Account",
"type": "*variable",
"mandatory": true,
"value": "~*req.Subscription-Id.Subscription-Id-Data<~Subscription-Id-Type(0)>"
"value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]"
},
{
"tag": "Destination",
@@ -274,7 +274,7 @@
"tag": "LastUsed",
"path": "*cgreq.LastUsed",
"type": "*sum",
"value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Input-Octets<~Rating-Group(2)>;~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Output-Octets<~Rating-Group(2)>"
"value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Input-Octets[~Rating-Group(2)];~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Output-Octets[~Rating-Group(2)]"
},
],
"reply_fields": [
@@ -340,7 +340,7 @@
"path": "*cgreq.Account",
"type": "*variable",
"mandatory": true,
"value": "~*req.Subscription-Id.Subscription-Id-Data<~Subscription-Id-Type(0)>"
"value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]"
},
{
"tag": "Destination",

View File

@@ -65,14 +65,14 @@
"path": "*cgreq.UsedUnits1",
"type": "*variable",
"mandatory": true,
"value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets<~Rating-Group(1)>"
"value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets[~Rating-Group(1)]"
},
{
"tag": "UsedUnits2",
"path": "*cgreq.UsedUnits2",
"type": "*variable",
"mandatory": true,
"value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets<~Rating-Group(2)>"
"value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets[~Rating-Group(2)]"
},
],
@@ -167,14 +167,14 @@
"path": "*cgreq.UsedUnits1",
"type": "*variable",
"mandatory": true,
"value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets<~Rating-Group(1)>"
"value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets[~Rating-Group(1)]"
},
{
"tag": "UsedUnits2",
"path": "*cgreq.UsedUnits2",
"type": "*variable",
"mandatory": true,
"value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets<~Rating-Group(2)>"
"value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets[~Rating-Group(2)]"
},
],
"reply_fields":[

View File

@@ -42,7 +42,7 @@
"path": "*cgreq.Account",
"type": "*variable",
"mandatory": true,
"value": "~*req.Subscription-Id.Subscription-Id-Data<~Subscription-Id-Type(0)>"
"value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]"
},
{
"tag": "Destination",

View File

@@ -42,7 +42,7 @@
"path": "*cgreq.Account",
"type": "*variable",
"mandatory": true,
"value": "~*req.Subscription-Id.Subscription-Id-Data<~Subscription-Id-Type(0)>"
"value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]"
},
{
"tag": "Destination",

View File

@@ -42,7 +42,7 @@
"path": "*cgreq.Account",
"type": "*variable",
"mandatory": true,
"value": "~*req.Subscription-Id.Subscription-Id-Data<~Subscription-Id-Type(0)>"
"value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]"
},
{
"tag": "AnswerTime",

View File

@@ -43,7 +43,7 @@
"path": "*cgreq.Account",
"type": "*variable",
"mandatory": true,
"value": "~*req.Subscription-Id.Subscription-Id-Data<~Subscription-Id-Type(0)>"
"value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]"
},
{
"tag": "Destination",

View File

@@ -38,7 +38,7 @@
"tag": "Account",
"path": "*cgreq.Account",
"type": "*variable",
"value": "~*req.Subscription-Id.Subscription-Id-Data<~Subscription-Id-Type(1)>",
"value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(1)]",
"mandatory": true
},
{
@@ -137,7 +137,7 @@
"tag": "Account",
"path": "*cgreq.Account",
"type": "*variable",
"value": "~*req.Subscription-Id.Subscription-Id-Data<~Subscription-Id-Type(0)>"
"value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]"
},
{
"tag": "Destination",
@@ -169,7 +169,7 @@
"tag": "LastUsed",
"path": "*cgreq.LastUsed",
"type": "*sum",
"value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Input-Octets<~Rating-Group(1)>;~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Output-Octets<~Rating-Group(1)>"
"value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Input-Octets[~Rating-Group(1)];~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Output-Octets[~Rating-Group(1)]"
},
],
"reply_fields": [
@@ -194,7 +194,7 @@
"filters": [
"*string:~*vars.*cmd:CCR",
"*string:~*req.CC-Request-Type:2",
"*string:~*req.Multiple-Services-Credit-Control.Rating-Group<1>:2",
"*string:~*req.Multiple-Services-Credit-Control.Rating-Group[1]:2",
"*prefix:~*req.Service-Context-Id:gprs"
],
"flags": ["*update", "*accounts"],
@@ -242,7 +242,7 @@
"path": "*cgreq.Account",
"type": "*variable",
"mandatory": true,
"value": "~*req.Subscription-Id.Subscription-Id-Data<~Subscription-Id-Type(0)>"
"value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]"
},
{
"tag": "Destination",
@@ -274,7 +274,7 @@
"tag": "LastUsed",
"path": "*cgreq.LastUsed",
"type": "*sum",
"value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Input-Octets<~Rating-Group(2)>;~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Output-Octets<~Rating-Group(2)>"
"value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Input-Octets[~Rating-Group(2)];~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Output-Octets[~Rating-Group(2)]"
},
],
"reply_fields": [
@@ -340,7 +340,7 @@
"path": "*cgreq.Account",
"type": "*variable",
"mandatory": true,
"value": "~*req.Subscription-Id.Subscription-Id-Data<~Subscription-Id-Type(0)>"
"value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]"
},
{
"tag": "Destination",

View File

@@ -65,14 +65,14 @@
"path": "*cgreq.UsedUnits1",
"type": "*variable",
"mandatory": true,
"value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets<~Rating-Group(1)>"
"value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets[~Rating-Group(1)]"
},
{
"tag": "UsedUnits2",
"path": "*cgreq.UsedUnits2",
"type": "*variable",
"mandatory": true,
"value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets<~Rating-Group(2)>"
"value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets[~Rating-Group(2)]"
},
],
@@ -167,14 +167,14 @@
"path": "*cgreq.UsedUnits1",
"type": "*variable",
"mandatory": true,
"value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets<~Rating-Group(1)>"
"value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets[~Rating-Group(1)]"
},
{
"tag": "UsedUnits2",
"path": "*cgreq.UsedUnits2",
"type": "*variable",
"mandatory": true,
"value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets<~Rating-Group(2)>"
"value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets[~Rating-Group(2)]"
},
],
"reply_fields":[

View File

@@ -42,7 +42,7 @@
"path": "*cgreq.Account",
"type": "*variable",
"mandatory": true,
"value": "~*req.Subscription-Id.Subscription-Id-Data<~Subscription-Id-Type(0)>"
"value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]"
},
{
"tag": "Destination",

View File

@@ -42,7 +42,7 @@
"path": "*cgreq.Account",
"type": "*variable",
"mandatory": true,
"value": "~*req.Subscription-Id.Subscription-Id-Data<~Subscription-Id-Type(0)>"
"value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]"
},
{
"tag": "Destination",

View File

@@ -42,7 +42,7 @@
"path": "*cgreq.Account",
"type": "*variable",
"mandatory": true,
"value": "~*req.Subscription-Id.Subscription-Id-Data<~Subscription-Id-Type(0)>"
"value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]"
},
{
"tag": "AnswerTime",

View File

@@ -43,7 +43,7 @@
"path": "*cgreq.Account",
"type": "*variable",
"mandatory": true,
"value": "~*req.Subscription-Id.Subscription-Id-Data<~Subscription-Id-Type(0)>"
"value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]"
},
{
"tag": "Destination",

View File

@@ -15,7 +15,7 @@
{"tag": "RequestType", "path": "*cgreq.RequestType", "type": "*constant", "value": "*prepaid"},
{"tag": "Category", "path": "*cgreq.Category", "type": "*constant", "value": "generic"},
{"tag": "Account", "path": "*cgreq.Account", "type": "*variable",
"value": "~*req.Subscription-Id.Subscription-Id-Data<~Subscription-Id-Type(1)>", "mandatory": true},
"value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(1)]", "mandatory": true},
{"tag": "Destination", "path": "*cgreq.Destination", "type": "*constant", "value": "data"},
{"tag": "SetupTime", "path": "*cgreq.SetupTime", "type": "*variable",
"value": "~*req.Event-Timestamp", "mandatory": true},
@@ -45,7 +45,7 @@
{"tag": "RequestType", "path": "*cgreq.RequestType", "type": "*constant", "value": "*prepaid"},
{"tag": "Category", "path": "*cgreq.Category", "type": "*contant", "value": "generic"},
{"tag": "Account", "path": "*cgreq.Account", "type": "*variable",
"value": "~*req.Subscription-Id.Subscription-Id-Data<~Subscription-Id-Type(0)>"},
"value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]"},
{"tag": "Destination", "path": "*cgreq.Destination", "type": "*constant", "value": "data"},
{"tag": "SetupTime", "path": "*cgreq.SetupTime", "type": "*variable",
"value": "~*req.Event-Timestamp", "mandatory": true},
@@ -53,7 +53,7 @@
"value": "~*req.Event-Timestamp", "mandatory": true},
{"tag": "Usage", "path": "*cgreq.Usage", "type": "*constant", "value": "2048"},
{"tag": "LastUsed", "path": "*cgreq.LastUsed", "type": "*sum",
"value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Input-Octets<~Rating-Group(1)>;~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Output-Octets<~Rating-Group(1)>"},
"value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Input-Octets[~Rating-Group(1)];~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Output-Octets[~Rating-Group(1)]"},
],
"reply_fields": [
{"tag": "CCATemplate", "type": "*template", "value": "*cca"},
@@ -65,7 +65,7 @@
{
"id": "data_update_grp2",
"filters": ["*string:~*vars.*cmd:CCR", "*string:~*req.CC-Request-Type:2",
"*string:~*req.Multiple-Services-Credit-Control.Rating-Group<1>:2", "*prefix:~*req.Service-Context-Id:gprs"],
"*string:~*req.Multiple-Services-Credit-Control.Rating-Group[1]:2", "*prefix:~*req.Service-Context-Id:gprs"],
"flags": ["*update", "*accounts"],
"request_fields":[
{"tag": "ToR", "path": "*cgreq.ToR", "type": "*constant", "value": "*data"},
@@ -77,7 +77,7 @@
{"tag": "RequestType", "path": "*cgreq.RequestType", "type": "*constant", "value": "*prepaid"},
{"tag": "Category", "path": "*cgreq.Category", "type": "*constant", "value": "generic"},
{"tag": "Account", "path": "*cgreq.Account", "type": "*variable", "mandatory": true,
"value": "~*req.Subscription-Id.Subscription-Id-Data<~Subscription-Id-Type(0)>"},
"value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]"},
{"tag": "Destination", "path": "*cgreq.Destination", "type": "*constant", "value": "data"},
{"tag": "SetupTime", "path": "*cgreq.SetupTime", "type": "*variable",
"value": "~*req.Event-Timestamp", "mandatory": true},
@@ -85,7 +85,7 @@
"value": "~*req.Event-Timestamp", "mandatory": true},
{"tag": "Usage", "path": "*cgreq.Usage", "type": "*constant", "value": "2048"},
{"tag": "LastUsed", "path": "*cgreq.LastUsed", "type": "*sum",
"value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Input-Octets<~Rating-Group(2)>;~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Output-Octets<~Rating-Group(2)>"},
"value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Input-Octets[~Rating-Group(2)];~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Output-Octets[~Rating-Group(2)]"},
],
"reply_fields": [
{"tag": "CCATemplate", "type": "*template", "value": "*cca"},
@@ -108,7 +108,7 @@
{"tag": "RequestType", "path": "*cgreq.RequestType", "type": "*constant", "value": "*prepaid"},
{"tag": "Category", "path": "*cgreq.Category", "type": "*constant", "value": "generic"},
{"tag": "Account", "path": "*cgreq.Account", "type": "*variable", "mandatory": true,
"value": "~*req.Subscription-Id.Subscription-Id-Data<~Subscription-Id-Type(0)>"},
"value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]"},
{"tag": "Destination", "path": "*cgreq.Destination", "type": "*constant", "value": "data"},
{"tag": "SetupTime", "path": "*cgreq.SetupTime", "type": "*variable",
"value": "~*req.Event-Timestamp", "mandatory": true},

View File

@@ -20,9 +20,9 @@
{"tag": "SetupTime", "path": "*cgreq.SetupTime", "type": "*variable",
"value": "~*req.Event-Timestamp", "mandatory": true},
{"tag": "UsedUnits1", "path": "*cgreq.UsedUnits1", "type": "*variable", "mandatory": true,
"value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets<~Rating-Group(1)>"},
"value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets[~Rating-Group(1)]"},
{"tag": "UsedUnits2", "path": "*cgreq.UsedUnits2", "type": "*variable", "mandatory": true,
"value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets<~Rating-Group(2)>"},
"value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets[~Rating-Group(2)]"},
],
"reply_fields":[
@@ -54,9 +54,9 @@
{"tag": "SetupTime", "path": "*cgreq.SetupTime", "type": "*variable",
"value": "~*req.Event-Timestamp", "mandatory": true},
{"tag": "UsedUnits1", "path": "*cgreq.UsedUnits1", "type": "*variable", "mandatory": true,
"value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets<~Rating-Group(1)>"},
"value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets[~Rating-Group(1)]"},
{"tag": "UsedUnits2", "path": "*cgreq.UsedUnits2", "type": "*variable", "mandatory": true,
"value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets<~Rating-Group(2)>"},
"value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets[~Rating-Group(2)]"},
],
"reply_fields":[

View File

@@ -15,7 +15,7 @@
{"tag": "Category", "path": "*cgreq.Category", "type": "*constant", "value": "sms"},
{"tag": "RequestType", "path": "*cgreq.RequestType", "type": "*constant", "value": "*prepaid"},
{"tag": "Account", "path": "*cgreq.Account", "type": "*variable", "mandatory": true,
"value": "~*req.Subscription-Id.Subscription-Id-Data<~Subscription-Id-Type(0)>"},
"value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]"},
{"tag": "Destination", "path": "*cgreq.Destination", "type": "*variable", "mandatory": true,
"value": "~*req.Service-Information.SMS-Information.Recipient-Address.Address-Data"},
{"tag": "SetupTime", "path": "*cgreq.SetupTime", "type": "*variable",

View File

@@ -42,7 +42,7 @@
"path": "*cgreq.Account",
"type": "*variable",
"mandatory": true,
"value": "~*req.Subscription-Id.Subscription-Id-Data<~Subscription-Id-Type(0)>"
"value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]"
},
{
"tag": "Destination",

View File

@@ -15,7 +15,7 @@
{"tag": "RequestType", "path": "*cgreq.RequestType", "type": "*constant", "value": "*prepaid"},
{"tag": "Category", "path": "*cgreq.Category", "type": "*constant", "value": "generic"},
{"tag": "Account", "path": "*cgreq.Account", "type": "*variable", "mandatory": true,
"value": "~*req.Subscription-Id.Subscription-Id-Data<~Subscription-Id-Type(0)>"},
"value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]"},
{"tag": "AnswerTime", "path": "*cgreq.AnswerTime", "type": "*variable",
"value": "~*req.Event-Timestamp", "mandatory": true},
{"tag": "Usage", "path": "*cgreq.Usage", "type": "*value_exponent", "mandatory": true,

View File

@@ -15,7 +15,7 @@
{"tag": "RequestType", "path": "*cgreq.RequestType", "type": "*constant", "value": "*prepaid"},
{"tag": "Category", "path": "*cgreq.Category", "type": "*constant", "value": "generic"},
{"tag": "Account", "path": "*cgreq.Account", "type": "*variable",
"value": "~*req.Subscription-Id.Subscription-Id-Data<~Subscription-Id-Type(1)>", "mandatory": true},
"value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(1)]", "mandatory": true},
{"tag": "Destination", "path": "*cgreq.Destination", "type": "*constant", "value": "data"},
{"tag": "SetupTime", "path": "*cgreq.SetupTime", "type": "*variable",
"value": "~*req.Event-Timestamp", "mandatory": true},
@@ -45,7 +45,7 @@
{"tag": "RequestType", "path": "*cgreq.RequestType", "type": "*constant", "value": "*prepaid"},
{"tag": "Category", "path": "*cgreq.Category", "type": "*contant", "value": "generic"},
{"tag": "Account", "path": "*cgreq.Account", "type": "*variable",
"value": "~*req.Subscription-Id.Subscription-Id-Data<~Subscription-Id-Type(0)>"},
"value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]"},
{"tag": "Destination", "path": "*cgreq.Destination", "type": "*constant", "value": "data"},
{"tag": "SetupTime", "path": "*cgreq.SetupTime", "type": "*variable",
"value": "~*req.Event-Timestamp", "mandatory": true},
@@ -53,7 +53,7 @@
"value": "~*req.Event-Timestamp", "mandatory": true},
{"tag": "Usage", "path": "*cgreq.Usage", "type": "*constant", "value": "2048"},
{"tag": "LastUsed", "path": "*cgreq.LastUsed", "type": "*sum",
"value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Input-Octets<~Rating-Group(1)>;~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Output-Octets<~Rating-Group(1)>"},
"value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Input-Octets[~Rating-Group(1)];~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Output-Octets[~Rating-Group(1)]"},
],
"reply_fields": [
{"tag": "CCATemplate", "type": "*template", "value": "*cca"},
@@ -65,7 +65,7 @@
{
"id": "data_update_grp2",
"filters": ["*string:~*vars.*cmd:CCR", "*string:~*req.CC-Request-Type:2",
"*string:~*req.Multiple-Services-Credit-Control.Rating-Group<1>:2", "*prefix:~*req.Service-Context-Id:gprs"],
"*string:~*req.Multiple-Services-Credit-Control.Rating-Group[1]:2", "*prefix:~*req.Service-Context-Id:gprs"],
"flags": ["*update", "*accounts"],
"request_fields":[
{"tag": "ToR", "path": "*cgreq.ToR", "type": "*constant", "value": "*data"},
@@ -77,7 +77,7 @@
{"tag": "RequestType", "path": "*cgreq.RequestType", "type": "*constant", "value": "*prepaid"},
{"tag": "Category", "path": "*cgreq.Category", "type": "*constant", "value": "generic"},
{"tag": "Account", "path": "*cgreq.Account", "type": "*variable", "mandatory": true,
"value": "~*req.Subscription-Id.Subscription-Id-Data<~Subscription-Id-Type(0)>"},
"value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]"},
{"tag": "Destination", "path": "*cgreq.Destination", "type": "*constant", "value": "data"},
{"tag": "SetupTime", "path": "*cgreq.SetupTime", "type": "*variable",
"value": "~*req.Event-Timestamp", "mandatory": true},
@@ -85,7 +85,7 @@
"value": "~*req.Event-Timestamp", "mandatory": true},
{"tag": "Usage", "path": "*cgreq.Usage", "type": "*constant", "value": "2048"},
{"tag": "LastUsed", "path": "*cgreq.LastUsed", "type": "*sum",
"value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Input-Octets<~Rating-Group(2)>;~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Output-Octets<~Rating-Group(2)>"},
"value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Input-Octets[~Rating-Group(2)];~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Output-Octets[~Rating-Group(2)]"},
],
"reply_fields": [
{"tag": "CCATemplate", "type": "*template", "value": "*cca"},
@@ -108,7 +108,7 @@
{"tag": "RequestType", "path": "*cgreq.RequestType", "type": "*constant", "value": "*prepaid"},
{"tag": "Category", "path": "*cgreq.Category", "type": "*constant", "value": "generic"},
{"tag": "Account", "path": "*cgreq.Account", "type": "*variable", "mandatory": true,
"value": "~*req.Subscription-Id.Subscription-Id-Data<~Subscription-Id-Type(0)>"},
"value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]"},
{"tag": "Destination", "path": "*cgreq.Destination", "type": "*constant", "value": "data"},
{"tag": "SetupTime", "path": "*cgreq.SetupTime", "type": "*variable",
"value": "~*req.Event-Timestamp", "mandatory": true},

View File

@@ -20,9 +20,9 @@
{"tag": "SetupTime", "path": "*cgreq.SetupTime", "type": "*variable",
"value": "~*req.Event-Timestamp", "mandatory": true},
{"tag": "UsedUnits1", "path": "*cgreq.UsedUnits1", "type": "*variable", "mandatory": true,
"value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets<~Rating-Group(1)>"},
"value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets[~Rating-Group(1)]"},
{"tag": "UsedUnits2", "path": "*cgreq.UsedUnits2", "type": "*variable", "mandatory": true,
"value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets<~Rating-Group(2)>"},
"value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets[~Rating-Group(2)]"},
],
"reply_fields":[
@@ -54,9 +54,9 @@
{"tag": "SetupTime", "path": "*cgreq.SetupTime", "type": "*variable",
"value": "~*req.Event-Timestamp", "mandatory": true},
{"tag": "UsedUnits1", "path": "*cgreq.UsedUnits1", "type": "*variable", "mandatory": true,
"value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets<~Rating-Group(1)>"},
"value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets[~Rating-Group(1)]"},
{"tag": "UsedUnits2", "path": "*cgreq.UsedUnits2", "type": "*variable", "mandatory": true,
"value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets<~Rating-Group(2)>"},
"value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets[~Rating-Group(2)]"},
],
"reply_fields":[

View File

@@ -15,7 +15,7 @@
{"tag": "Category", "path": "*cgreq.Category", "type": "*constant", "value": "sms"},
{"tag": "RequestType", "path": "*cgreq.RequestType", "type": "*constant", "value": "*prepaid"},
{"tag": "Account", "path": "*cgreq.Account", "type": "*variable", "mandatory": true,
"value": "~*req.Subscription-Id.Subscription-Id-Data<~Subscription-Id-Type(0)>"},
"value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]"},
{"tag": "Destination", "path": "*cgreq.Destination", "type": "*variable", "mandatory": true,
"value": "~*req.Service-Information.SMS-Information.Recipient-Address.Address-Data"},
{"tag": "SetupTime", "path": "*cgreq.SetupTime", "type": "*variable",

View File

@@ -42,7 +42,7 @@
"path": "*cgreq.Account",
"type": "*variable",
"mandatory": true,
"value": "~*req.Subscription-Id.Subscription-Id-Data<~Subscription-Id-Type(0)>"
"value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]"
},
{
"tag": "Destination",

View File

@@ -15,7 +15,7 @@
{"tag": "RequestType", "path": "*cgreq.RequestType", "type": "*constant", "value": "*prepaid"},
{"tag": "Category", "path": "*cgreq.Category", "type": "*constant", "value": "generic"},
{"tag": "Account", "path": "*cgreq.Account", "type": "*variable", "mandatory": true,
"value": "~*req.Subscription-Id.Subscription-Id-Data<~Subscription-Id-Type(0)>"},
"value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]"},
{"tag": "AnswerTime", "path": "*cgreq.AnswerTime", "type": "*variable",
"value": "~*req.Event-Timestamp", "mandatory": true},
{"tag": "Usage", "path": "*cgreq.Usage", "type": "*value_exponent", "mandatory": true,

View File

@@ -15,7 +15,7 @@
{"tag": "RequestType", "path": "*cgreq.RequestType", "type": "*constant", "value": "*prepaid"},
{"tag": "Category", "path": "*cgreq.Category", "type": "*constant", "value": "generic"},
{"tag": "Account", "path": "*cgreq.Account", "type": "*variable",
"value": "~*req.Subscription-Id.Subscription-Id-Data<~Subscription-Id-Type(1)>", "mandatory": true},
"value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(1)]", "mandatory": true},
{"tag": "Destination", "path": "*cgreq.Destination", "type": "*constant", "value": "data"},
{"tag": "SetupTime", "path": "*cgreq.SetupTime", "type": "*variable",
"value": "~*req.Event-Timestamp", "mandatory": true},
@@ -45,7 +45,7 @@
{"tag": "RequestType", "path": "*cgreq.RequestType", "type": "*constant", "value": "*prepaid"},
{"tag": "Category", "path": "*cgreq.Category", "type": "*contant", "value": "generic"},
{"tag": "Account", "path": "*cgreq.Account", "type": "*variable",
"value": "~*req.Subscription-Id.Subscription-Id-Data<~Subscription-Id-Type(0)>"},
"value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]"},
{"tag": "Destination", "path": "*cgreq.Destination", "type": "*constant", "value": "data"},
{"tag": "SetupTime", "path": "*cgreq.SetupTime", "type": "*variable",
"value": "~*req.Event-Timestamp", "mandatory": true},
@@ -53,7 +53,7 @@
"value": "~*req.Event-Timestamp", "mandatory": true},
{"tag": "Usage", "path": "*cgreq.Usage", "type": "*constant", "value": "2048"},
{"tag": "LastUsed", "path": "*cgreq.LastUsed", "type": "*sum",
"value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Input-Octets<~Rating-Group(1)>;~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Output-Octets<~Rating-Group(1)>"},
"value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Input-Octets[~Rating-Group(1)];~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Output-Octets[~Rating-Group(1)]"},
],
"reply_fields": [
{"tag": "CCATemplate", "type": "*template", "value": "*cca"},
@@ -65,7 +65,7 @@
{
"id": "data_update_grp2",
"filters": ["*string:~*vars.*cmd:CCR", "*string:~*req.CC-Request-Type:2",
"*string:~*req.Multiple-Services-Credit-Control.Rating-Group<1>:2", "*prefix:~*req.Service-Context-Id:gprs"],
"*string:~*req.Multiple-Services-Credit-Control.Rating-Group[1]:2", "*prefix:~*req.Service-Context-Id:gprs"],
"flags": ["*update", "*accounts"],
"request_fields":[
{"tag": "ToR", "path": "*cgreq.ToR", "type": "*constant", "value": "*data"},
@@ -77,7 +77,7 @@
{"tag": "RequestType", "path": "*cgreq.RequestType", "type": "*constant", "value": "*prepaid"},
{"tag": "Category", "path": "*cgreq.Category", "type": "*constant", "value": "generic"},
{"tag": "Account", "path": "*cgreq.Account", "type": "*variable", "mandatory": true,
"value": "~*req.Subscription-Id.Subscription-Id-Data<~Subscription-Id-Type(0)>"},
"value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]"},
{"tag": "Destination", "path": "*cgreq.Destination", "type": "*constant", "value": "data"},
{"tag": "SetupTime", "path": "*cgreq.SetupTime", "type": "*variable",
"value": "~*req.Event-Timestamp", "mandatory": true},
@@ -85,7 +85,7 @@
"value": "~*req.Event-Timestamp", "mandatory": true},
{"tag": "Usage", "path": "*cgreq.Usage", "type": "*constant", "value": "2048"},
{"tag": "LastUsed", "path": "*cgreq.LastUsed", "type": "*sum",
"value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Input-Octets<~Rating-Group(2)>;~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Output-Octets<~Rating-Group(2)>"},
"value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Input-Octets[~Rating-Group(2)];~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Output-Octets[~Rating-Group(2)]"},
],
"reply_fields": [
{"tag": "CCATemplate", "type": "*template", "value": "*cca"},
@@ -108,7 +108,7 @@
{"tag": "RequestType", "path": "*cgreq.RequestType", "type": "*constant", "value": "*prepaid"},
{"tag": "Category", "path": "*cgreq.Category", "type": "*constant", "value": "generic"},
{"tag": "Account", "path": "*cgreq.Account", "type": "*variable", "mandatory": true,
"value": "~*req.Subscription-Id.Subscription-Id-Data<~Subscription-Id-Type(0)>"},
"value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]"},
{"tag": "Destination", "path": "*cgreq.Destination", "type": "*constant", "value": "data"},
{"tag": "SetupTime", "path": "*cgreq.SetupTime", "type": "*variable",
"value": "~*req.Event-Timestamp", "mandatory": true},

View File

@@ -20,9 +20,9 @@
{"tag": "SetupTime", "path": "*cgreq.SetupTime", "type": "*variable",
"value": "~*req.Event-Timestamp", "mandatory": true},
{"tag": "UsedUnits1", "path": "*cgreq.UsedUnits1", "type": "*variable", "mandatory": true,
"value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets<~Rating-Group(1)>"},
"value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets[~Rating-Group(1)]"},
{"tag": "UsedUnits2", "path": "*cgreq.UsedUnits2", "type": "*variable", "mandatory": true,
"value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets<~Rating-Group(2)>"},
"value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets[~Rating-Group(2)]"},
],
"reply_fields":[
@@ -54,9 +54,9 @@
{"tag": "SetupTime", "path": "*cgreq.SetupTime", "type": "*variable",
"value": "~*req.Event-Timestamp", "mandatory": true},
{"tag": "UsedUnits1", "path": "*cgreq.UsedUnits1", "type": "*variable", "mandatory": true,
"value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets<~Rating-Group(1)>"},
"value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets[~Rating-Group(1)]"},
{"tag": "UsedUnits2", "path": "*cgreq.UsedUnits2", "type": "*variable", "mandatory": true,
"value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets<~Rating-Group(2)>"},
"value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets[~Rating-Group(2)]"},
],
"reply_fields":[

View File

@@ -15,7 +15,7 @@
{"tag": "Category", "path": "*cgreq.Category", "type": "*constant", "value": "sms"},
{"tag": "RequestType", "path": "*cgreq.RequestType", "type": "*constant", "value": "*prepaid"},
{"tag": "Account", "path": "*cgreq.Account", "type": "*variable", "mandatory": true,
"value": "~*req.Subscription-Id.Subscription-Id-Data<~Subscription-Id-Type(0)>"},
"value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]"},
{"tag": "Destination", "path": "*cgreq.Destination", "type": "*variable", "mandatory": true,
"value": "~*req.Service-Information.SMS-Information.Recipient-Address.Address-Data"},
{"tag": "SetupTime", "path": "*cgreq.SetupTime", "type": "*variable",

View File

@@ -42,7 +42,7 @@
"path": "*cgreq.Account",
"type": "*variable",
"mandatory": true,
"value": "~*req.Subscription-Id.Subscription-Id-Data<~Subscription-Id-Type(0)>"
"value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]"
},
{
"tag": "Destination",

View File

@@ -15,7 +15,7 @@
{"tag": "RequestType", "path": "*cgreq.RequestType", "type": "*constant", "value": "*prepaid"},
{"tag": "Category", "path": "*cgreq.Category", "type": "*constant", "value": "generic"},
{"tag": "Account", "path": "*cgreq.Account", "type": "*variable", "mandatory": true,
"value": "~*req.Subscription-Id.Subscription-Id-Data<~Subscription-Id-Type(0)>"},
"value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]"},
{"tag": "AnswerTime", "path": "*cgreq.AnswerTime", "type": "*variable",
"value": "~*req.Event-Timestamp", "mandatory": true},
{"tag": "Usage", "path": "*cgreq.Usage", "type": "*value_exponent", "mandatory": true,

View File

@@ -16,7 +16,7 @@
{"tag": "RequestType", "path": "*cgreq.RequestType", "type": "*constant", "value": "*prepaid"},
{"tag": "Category", "path": "*cgreq.Category", "type": "*constant", "value": "generic"},
{"tag": "Account", "path": "*cgreq.Account", "type": "*variable",
"value": "~*req.Subscription-Id.Subscription-Id-Data<~Subscription-Id-Type(1)>", "mandatory": true},
"value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(1)]", "mandatory": true},
{"tag": "Destination", "path": "*cgreq.Destination", "type": "*constant", "value": "data"},
{"tag": "SetupTime", "path": "*cgreq.SetupTime", "type": "*variable",
"value": "~*req.Event-Timestamp", "mandatory": true},
@@ -47,7 +47,7 @@
{"tag": "RequestType", "path": "*cgreq.RequestType", "type": "*constant", "value": "*prepaid"},
{"tag": "Category", "path": "*cgreq.Category", "type": "*contant", "value": "generic"},
{"tag": "Account", "path": "*cgreq.Account", "type": "*variable",
"value": "~*req.Subscription-Id.Subscription-Id-Data<~Subscription-Id-Type(0)>"},
"value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]"},
{"tag": "Destination", "path": "*cgreq.Destination", "type": "*constant", "value": "data"},
{"tag": "SetupTime", "path": "*cgreq.SetupTime", "type": "*variable",
"value": "~*req.Event-Timestamp", "mandatory": true},
@@ -55,7 +55,7 @@
"value": "~*req.Event-Timestamp", "mandatory": true},
{"tag": "Usage", "path": "*cgreq.Usage", "type": "*constant", "value": "2048"},
{"tag": "LastUsed", "path": "*cgreq.LastUsed", "type": "*sum",
"value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Input-Octets<~Rating-Group(1)>;~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Output-Octets<~Rating-Group(1)>"},
"value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Input-Octets[~Rating-Group(1)];~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Output-Octets[~Rating-Group(1)]"},
],
"reply_fields": [
{"tag": "CCATemplate", "type": "*template", "value": "*cca"},
@@ -67,7 +67,7 @@
{
"id": "data_update_grp2",
"filters": ["*string:~*vars.*cmd:CCR", "*string:~*req.CC-Request-Type:2",
"*string:~*req.Multiple-Services-Credit-Control.Rating-Group<1>:2", "*prefix:~*req.Service-Context-Id:gprs"],
"*string:~*req.Multiple-Services-Credit-Control.Rating-Group[1]:2", "*prefix:~*req.Service-Context-Id:gprs"],
"flags": ["*update", "*accounts"],
"request_fields":[
{"tag": "ToR", "path": "*cgreq.ToR", "type": "*constant", "value": "*data"},
@@ -80,7 +80,7 @@
{"tag": "RequestType", "path": "*cgreq.RequestType", "type": "*constant", "value": "*prepaid"},
{"tag": "Category", "path": "*cgreq.Category", "type": "*constant", "value": "generic"},
{"tag": "Account", "path": "*cgreq.Account", "type": "*variable", "mandatory": true,
"value": "~*req.Subscription-Id.Subscription-Id-Data<~Subscription-Id-Type(0)>"},
"value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]"},
{"tag": "Destination", "path": "*cgreq.Destination", "type": "*constant", "value": "data"},
{"tag": "SetupTime", "path": "*cgreq.SetupTime", "type": "*variable",
"value": "~*req.Event-Timestamp", "mandatory": true},
@@ -88,7 +88,7 @@
"value": "~*req.Event-Timestamp", "mandatory": true},
{"tag": "Usage", "path": "*cgreq.Usage", "type": "*constant", "value": "2048"},
{"tag": "LastUsed", "path": "*cgreq.LastUsed", "type": "*sum",
"value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Input-Octets<~Rating-Group(2)>;~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Output-Octets<~Rating-Group(2)>"},
"value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Input-Octets[~Rating-Group(2)];~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Output-Octets[~Rating-Group(2)]"},
],
"reply_fields": [
{"tag": "CCATemplate", "type": "*template", "value": "*cca"},
@@ -112,7 +112,7 @@
{"tag": "RequestType", "path": "*cgreq.RequestType", "type": "*constant", "value": "*prepaid"},
{"tag": "Category", "path": "*cgreq.Category", "type": "*constant", "value": "generic"},
{"tag": "Account", "path": "*cgreq.Account", "type": "*variable", "mandatory": true,
"value": "~*req.Subscription-Id.Subscription-Id-Data<~Subscription-Id-Type(0)>"},
"value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]"},
{"tag": "Destination", "path": "*cgreq.Destination", "type": "*constant", "value": "data"},
{"tag": "SetupTime", "path": "*cgreq.SetupTime", "type": "*variable",
"value": "~*req.Event-Timestamp", "mandatory": true},

View File

@@ -21,9 +21,9 @@
{"tag": "SetupTime", "path": "*cgreq.SetupTime", "type": "*variable",
"value": "~*req.Event-Timestamp", "mandatory": true},
{"tag": "UsedUnits1", "path": "*cgreq.UsedUnits1", "type": "*variable", "mandatory": true,
"value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets<~Rating-Group(1)>"},
"value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets[~Rating-Group(1)]"},
{"tag": "UsedUnits2", "path": "*cgreq.UsedUnits2", "type": "*variable", "mandatory": true,
"value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets<~Rating-Group(2)>"},
"value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets[~Rating-Group(2)]"},
],
"reply_fields":[
@@ -56,9 +56,9 @@
{"tag": "SetupTime", "path": "*cgreq.SetupTime", "type": "*variable",
"value": "~*req.Event-Timestamp", "mandatory": true},
{"tag": "UsedUnits1", "path": "*cgreq.UsedUnits1", "type": "*variable", "mandatory": true,
"value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets<~Rating-Group(1)>"},
"value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets[~Rating-Group(1)]"},
{"tag": "UsedUnits2", "path": "*cgreq.UsedUnits2", "type": "*variable", "mandatory": true,
"value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets<~Rating-Group(2)>"},
"value": "~*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets[~Rating-Group(2)]"},
],
"reply_fields":[

View File

@@ -16,7 +16,7 @@
{"tag": "Category", "path": "*cgreq.Category", "type": "*constant", "value": "sms"},
{"tag": "RequestType", "path": "*cgreq.RequestType", "type": "*constant", "value": "*prepaid"},
{"tag": "Account", "path": "*cgreq.Account", "type": "*variable", "mandatory": true,
"value": "~*req.Subscription-Id.Subscription-Id-Data<~Subscription-Id-Type(0)>"},
"value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]"},
{"tag": "Destination", "path": "*cgreq.Destination", "type": "*variable", "mandatory": true,
"value": "~*req.Service-Information.SMS-Information.Recipient-Address.Address-Data"},
{"tag": "SetupTime", "path": "*cgreq.SetupTime", "type": "*variable",

View File

@@ -47,7 +47,7 @@
"path": "*cgreq.Account",
"type": "*variable",
"mandatory": true,
"value": "~*req.Subscription-Id.Subscription-Id-Data<~Subscription-Id-Type(0)>"
"value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]"
},
{
"tag": "Destination",

View File

@@ -16,7 +16,7 @@
{"tag": "RequestType", "path": "*cgreq.RequestType", "type": "*constant", "value": "*prepaid"},
{"tag": "Category", "path": "*cgreq.Category", "type": "*constant", "value": "generic"},
{"tag": "Account", "path": "*cgreq.Account", "type": "*variable", "mandatory": true,
"value": "~*req.Subscription-Id.Subscription-Id-Data<~Subscription-Id-Type(0)>"},
"value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]"},
{"tag": "AnswerTime", "path": "*cgreq.AnswerTime", "type": "*variable",
"value": "~*req.Event-Timestamp", "mandatory": true},
{"tag": "Usage", "path": "*cgreq.Usage", "type": "*value_exponent", "mandatory": true,

View File

@@ -44,7 +44,6 @@ func NewEventExporterRequest(req utils.DataProvider, dc utils.MapStorage,
trl: utils.NewOrderedNavigableMap(),
dc: dc,
}
eeR.dynamicProvider = utils.NewDynamicDataProvider(eeR)
return
}
@@ -60,8 +59,7 @@ type EventExporterRequest struct {
trl *utils.OrderedNavigableMap // Used in reply to access the request that was send
dc utils.MapStorage
filterS *engine.FilterS
dynamicProvider *utils.DynamicDataProvider
filterS *engine.FilterS
}
// String implements utils.DataProvider
@@ -127,7 +125,7 @@ func (eeR *EventExporterRequest) FieldAsString(fldPath []string) (val string, er
func (eeR *EventExporterRequest) SetFields(tplFlds []*config.FCTemplate) (err error) {
for _, tplFld := range tplFlds {
if pass, err := eeR.filterS.Pass(eeR.tnt,
tplFld.Filters, eeR.dynamicProvider); err != nil {
tplFld.Filters, eeR); err != nil {
return err
} else if !pass {
continue
@@ -147,7 +145,7 @@ func (eeR *EventExporterRequest) SetFields(tplFlds []*config.FCTemplate) (err er
}
var fullPath *utils.FullPath
var itmPath []string
if fullPath, err = eeR.dynamicProvider.GetFullFieldPath(tplFld.Path); err != nil {
if fullPath, err = utils.GetFullFieldPath(tplFld.Path, eeR); err != nil {
return
} else if fullPath == nil { // no dynamic path
fullPath = &utils.FullPath{
@@ -222,18 +220,18 @@ func (eeR *EventExporterRequest) ParseField(
out = eeR.RemoteHost().String()
isString = true
case utils.MetaVariable, utils.META_COMPOSED, utils.MetaGroup:
out, err = cfgFld.Value.ParseDataProvider(eeR.dynamicProvider)
out, err = cfgFld.Value.ParseDataProvider(eeR)
isString = true
case utils.META_USAGE_DIFFERENCE:
if len(cfgFld.Value) != 2 {
return nil, fmt.Errorf("invalid arguments <%s> to %s",
utils.ToJSON(cfgFld.Value), utils.META_USAGE_DIFFERENCE)
}
strVal1, err := cfgFld.Value[0].ParseDataProvider(eeR.dynamicProvider)
strVal1, err := cfgFld.Value[0].ParseDataProvider(eeR)
if err != nil {
return "", err
}
strVal2, err := cfgFld.Value[1].ParseDataProvider(eeR.dynamicProvider)
strVal2, err := cfgFld.Value[1].ParseDataProvider(eeR)
if err != nil {
return "", err
}
@@ -252,7 +250,7 @@ func (eeR *EventExporterRequest) ParseField(
return nil, fmt.Errorf("invalid arguments <%s> to %s",
utils.ToJSON(cfgFld.Value), utils.MetaCCUsage)
}
strVal1, err := cfgFld.Value[0].ParseDataProvider(eeR.dynamicProvider) // ReqNr
strVal1, err := cfgFld.Value[0].ParseDataProvider(eeR) // ReqNr
if err != nil {
return "", err
}
@@ -261,7 +259,7 @@ func (eeR *EventExporterRequest) ParseField(
return "", fmt.Errorf("invalid requestNumber <%s> to %s",
strVal1, utils.MetaCCUsage)
}
strVal2, err := cfgFld.Value[1].ParseDataProvider(eeR.dynamicProvider) // TotalUsage
strVal2, err := cfgFld.Value[1].ParseDataProvider(eeR) // TotalUsage
if err != nil {
return "", err
}
@@ -270,7 +268,7 @@ func (eeR *EventExporterRequest) ParseField(
return "", fmt.Errorf("invalid usedCCTime <%s> to %s",
strVal2, utils.MetaCCUsage)
}
strVal3, err := cfgFld.Value[2].ParseDataProvider(eeR.dynamicProvider) // DebitInterval
strVal3, err := cfgFld.Value[2].ParseDataProvider(eeR) // DebitInterval
if err != nil {
return "", err
}
@@ -287,7 +285,7 @@ func (eeR *EventExporterRequest) ParseField(
case utils.MetaSum:
iFaceVals := make([]interface{}, len(cfgFld.Value))
for i, val := range cfgFld.Value {
strVal, err := val.ParseDataProvider(eeR.dynamicProvider)
strVal, err := val.ParseDataProvider(eeR)
if err != nil {
return "", err
}
@@ -297,7 +295,7 @@ func (eeR *EventExporterRequest) ParseField(
case utils.MetaDifference:
iFaceVals := make([]interface{}, len(cfgFld.Value))
for i, val := range cfgFld.Value {
strVal, err := val.ParseDataProvider(eeR.dynamicProvider)
strVal, err := val.ParseDataProvider(eeR)
if err != nil {
return "", err
}
@@ -307,7 +305,7 @@ func (eeR *EventExporterRequest) ParseField(
case utils.MetaMultiply:
iFaceVals := make([]interface{}, len(cfgFld.Value))
for i, val := range cfgFld.Value {
strVal, err := val.ParseDataProvider(eeR.dynamicProvider)
strVal, err := val.ParseDataProvider(eeR)
if err != nil {
return "", err
}
@@ -317,7 +315,7 @@ func (eeR *EventExporterRequest) ParseField(
case utils.MetaDivide:
iFaceVals := make([]interface{}, len(cfgFld.Value))
for i, val := range cfgFld.Value {
strVal, err := val.ParseDataProvider(eeR.dynamicProvider)
strVal, err := val.ParseDataProvider(eeR)
if err != nil {
return "", err
}
@@ -329,7 +327,7 @@ func (eeR *EventExporterRequest) ParseField(
return nil, fmt.Errorf("invalid arguments <%s> to %s",
utils.ToJSON(cfgFld.Value), utils.MetaValueExponent)
}
strVal1, err := cfgFld.Value[0].ParseDataProvider(eeR.dynamicProvider) // String Value
strVal1, err := cfgFld.Value[0].ParseDataProvider(eeR) // String Value
if err != nil {
return "", err
}
@@ -338,7 +336,7 @@ func (eeR *EventExporterRequest) ParseField(
return "", fmt.Errorf("invalid value <%s> to %s",
strVal1, utils.MetaValueExponent)
}
strVal2, err := cfgFld.Value[1].ParseDataProvider(eeR.dynamicProvider) // String Exponent
strVal2, err := cfgFld.Value[1].ParseDataProvider(eeR) // String Exponent
if err != nil {
return "", err
}
@@ -349,7 +347,7 @@ func (eeR *EventExporterRequest) ParseField(
out = strconv.FormatFloat(utils.Round(val*math.Pow10(exp),
config.CgrConfig().GeneralCfg().RoundingDecimals, utils.ROUNDING_MIDDLE), 'f', -1, 64)
case utils.MetaUnixTimestamp:
val, err := cfgFld.Value.ParseDataProvider(eeR.dynamicProvider)
val, err := cfgFld.Value.ParseDataProvider(eeR)
if err != nil {
return nil, err
}

View File

@@ -642,6 +642,12 @@ const (
AttrValueSep = "="
ANDSep = "&"
PipeSep = "|"
RSRConstSep = "`"
RSRConstChar = '`'
RSRDataConverterPrefix = "{*"
RSRDataConverterSufix = "}"
RSRDynStartChar = '<'
RSRDynEndChar = '>'
MetaApp = "*app"
MetaAppID = "*appid"
MetaCmd = "*cmd"

View File

@@ -1,210 +0,0 @@
/*
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 <http://www.gnu.org/licenses/>
*/
package utils
import (
"strings"
)
// NewDynamicDataProvider constructs a dynamic data provider
func NewDynamicDataProvider(dp DataProvider) *DynamicDataProvider {
return &DynamicDataProvider{
DataProvider: dp,
cache: make(map[string]interface{}),
}
}
// DynamicDataProvider is a data source from multiple formats
type DynamicDataProvider struct {
DataProvider
cache map[string]interface{}
}
// FieldAsInterface to overwrite the FieldAsInterface function from the given DataProvider
func (ddp *DynamicDataProvider) FieldAsInterface(fldPath []string) (out interface{}, err error) {
path := strings.Join(fldPath, NestingSep) // join the path so we can check it in cache and parse it more easy
if val, has := ddp.cache[path]; has { // check if we have the path in cache
return val, nil
}
var newPath string
if newPath, err = ddp.processFieldPath(path); err != nil { // process the path
return
}
if newPath == EmptyString { // no new path means no dynamic path so just take the value from the data provider
return ddp.DataProvider.FieldAsInterface(fldPath)
}
// split the new path and get that field
if out, err = ddp.DataProvider.FieldAsInterface(strings.Split(newPath, NestingSep)); err != nil {
return
}
// if no error save in cache the path
ddp.cache[path] = out
return
}
// GetFullFieldPath returns the full path for the
func (ddp *DynamicDataProvider) GetFullFieldPath(fldPath string) (fpath *FullPath, err error) {
var newPath string
if newPath, err = ddp.processFieldPathForSet(fldPath); err != nil || newPath == EmptyString {
return
}
fpath = &FullPath{
PathItems: NewPathItems(strings.Split(newPath, NestingSep)),
Path: newPath,
}
return
}
// FieldAsString returns the value from path as string
func (ddp DynamicDataProvider) FieldAsString(fldPath []string) (str string, err error) {
var val interface{}
if val, err = ddp.FieldAsInterface(fldPath); err != nil {
return
}
return IfaceAsString(val), nil
}
// does the same thing as ... but replaces [ with . if the value between [] is dynamic
func (ddp *DynamicDataProvider) processFieldPathForSet(fldPath string) (newPath string, err error) {
idx := strings.Index(fldPath, IdxStart)
if idx == -1 {
return // no proccessing requred
}
var hasDyn bool // to be able to determine if the path has selector
newPath = fldPath[:idx] // add the first path of the path without the "["
for idx != -1 { // stop when we do not find any "["
fldPath = fldPath[idx+1:] // move the path to the begining of the index
nextBeginIdx := strings.Index(fldPath, IdxStart) // get the next "[" if any
nextEndIdx := strings.Index(fldPath, IdxEnd) // get the next "]" if any
if nextEndIdx == -1 { // no end index found so return error
err = ErrWrongPath
newPath = EmptyString
return
}
// parse the rest of the field path until we match the [ ]
bIdx, eIdx := nextBeginIdx, nextEndIdx
for nextBeginIdx != -1 && nextBeginIdx < nextEndIdx { // do this until no new [ is found or the next begining [ is after the end ]
nextBeginIdx = strings.Index(fldPath[bIdx+1:], IdxStart) // get the next "[" if any
nextEndIdx = strings.Index(fldPath[eIdx+1:], IdxEnd) // get the next "]" if any
if nextEndIdx == -1 { // no end index found so return error
err = ErrWrongPath
newPath = EmptyString
return
}
if nextBeginIdx == -1 { // if no index found do not increment but replace it
bIdx = -1
} else {
bIdx += nextBeginIdx + 1
}
// increment the indexes
eIdx += nextEndIdx + 1
}
var val string
var isDyn bool
for _, path := range strings.Split(fldPath[:eIdx], PipeSep) { // proccess the found path
var iface interface{}
if strings.HasPrefix(path, DynamicDataPrefix) {
isDyn = true
path2 := strings.TrimPrefix(path, DynamicDataPrefix)
if iface, err = ddp.FieldAsInterface(strings.Split(path2, NestingSep)); err != nil {
newPath = EmptyString
return
}
val += IfaceAsString(iface) // compose the value
} else {
val += IfaceAsString(path) // compose the value
}
}
if isDyn {
hasDyn = true
val = NestingSep + val
} else {
val = IdxStart + val + IdxEnd
}
if bIdx == -1 { // if is the last ocurence add the rest of the path and exit
newPath += val + fldPath[eIdx+1:]
} else {
// else just add until the next [
newPath += val + fldPath[eIdx+1:bIdx]
}
idx = bIdx
}
if !hasDyn { // the path doesn't have dynamic selector
newPath = EmptyString
}
return
}
func (ddp *DynamicDataProvider) processFieldPath(fldPath string) (newPath string, err error) {
idx := strings.Index(fldPath, IdxStart)
if idx == -1 {
return // no proccessing requred
}
newPath = fldPath[:idx+1] // add the first path of the path with the "[" included
for idx != -1 { // stop when we do not find any "["
fldPath = fldPath[idx+1:] // move the path to the begining of the index
nextBeginIdx := strings.Index(fldPath, IdxStart) // get the next "[" if any
nextEndIdx := strings.Index(fldPath, IdxEnd) // get the next "]" if any
if nextEndIdx == -1 { // no end index found so return error
err = ErrWrongPath
newPath = EmptyString
return
}
// parse the rest of the field path until we match the [ ]
bIdx, eIdx := nextBeginIdx, nextEndIdx
for nextBeginIdx != -1 && nextBeginIdx < nextEndIdx { // do this until no new [ is found or the next begining [ is after the end ]
nextBeginIdx = strings.Index(fldPath[bIdx+1:], IdxStart) // get the next "[" if any
nextEndIdx = strings.Index(fldPath[eIdx+1:], IdxEnd) // get the next "]" if any
if nextEndIdx == -1 { // no end index found so return error
err = ErrWrongPath
newPath = EmptyString
return
}
if nextBeginIdx == -1 { // if no index found do not increment but replace it
bIdx = -1
} else {
bIdx += nextBeginIdx + 1
}
// increment the indexes
eIdx += nextEndIdx + 1
}
var val string
for _, path := range strings.Split(fldPath[:eIdx], PipeSep) { // proccess the found path
var iface interface{}
if iface, err = DPDynamicInterface(path, ddp); err != nil {
newPath = EmptyString
return
}
val += IfaceAsString(iface) // compose the value
}
if bIdx == -1 { // if is the last ocurence add the rest of the path and exit
newPath += val + fldPath[eIdx:]
} else {
// else just add until the next [
newPath += val + fldPath[eIdx:bIdx+1]
}
idx = bIdx
}
return
}

View File

@@ -1,254 +0,0 @@
/*
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 <http://www.gnu.org/licenses/>
*/
package utils
import (
"strings"
"testing"
)
func TestDynamicDataProviderFieldAsInterface(t *testing.T) {
dp := MapStorage{
MetaCgrep: MapStorage{
"Stir": MapStorage{
"CHRG_ROUTE1_END": "Identity1",
"CHRG_ROUTE2_END": "Identity2",
"CHRG_ROUTE3_END": "Identity3",
"CHRG_ROUTE4_END": "Identity4",
},
"Routes": MapStorage{
"SortedRoutes": []MapStorage{
{"ID": "ROUTE1"},
{"ID": "ROUTE2"},
{"ID": "ROUTE3"},
{"ID": "ROUTE4"},
},
},
"BestRoute": 0,
},
}
ddp := NewDynamicDataProvider(dp)
path := "*cgrep.Stir[CHRG_|~*cgrep.Routes.SortedRoutes[~*cgrep.BestRoute].ID|_END]"
out, err := ddp.FieldAsInterface(strings.Split(path, NestingSep))
if err != nil {
t.Fatal(err)
}
expected := "Identity1"
if out != expected {
t.Errorf("Expected: %q,received %q", expected, out)
}
path = "*cgrep.Stir[CHRG_|~*cgrep.Routes.SortedRoutes[~*cgrep.BestRoute].ID|_END"
_, err = ddp.FieldAsInterface(strings.Split(path, NestingSep))
if err != ErrWrongPath {
t.Errorf("Expected error %s received %v", ErrWrongPath, err)
}
}
func TestDynamicDataProviderFieldAsInterface2(t *testing.T) {
dp := MapStorage{
MetaCgrep: MapStorage{
"Stir": map[string]interface{}{
"CHRG_ROUTE1_END": "Identity1",
"CHRG_ROUTE2_END": "Identity2",
"CHRG_ROUTE3_END": "Identity3",
"CHRG_ROUTE4_END": "Identity4",
},
"Routes": map[string]interface{}{
"SortedRoutes": []map[string]interface{}{
{"ID": "ROUTE1"},
{"ID": "ROUTE2"},
{"ID": "ROUTE3"},
{"ID": "ROUTE4"},
},
},
"BestRoute": 0,
},
}
ddp := NewDynamicDataProvider(dp)
path := "*cgrep.Stir[CHRG_|~*cgrep.Routes.SortedRoutes[~*cgrep.BestRoute].ID|_END]"
out, err := ddp.FieldAsInterface(strings.Split(path, NestingSep))
if err != nil {
t.Fatal(err)
}
expected := "Identity1"
if out != expected {
t.Errorf("Expected: %q,received %q", expected, out)
}
path = "*cgrep.Stir[CHRG_|~*cgrep.Routes.SortedRoutes[~*cgrep.BestRoute].ID|_END"
_, err = ddp.FieldAsInterface(strings.Split(path, NestingSep))
if err != ErrWrongPath {
t.Errorf("Expected error %s received %v", ErrWrongPath, err)
}
}
func TestDynamicDataProviderProccesFieldPath2(t *testing.T) {
dp := MapStorage{
MetaCgrep: MapStorage{
"Stir": MapStorage{
"CHRG_ROUTE1_END": "Identity1",
"CHRG_ROUTE2_END": "Identity2",
"CHRG_ROUTE3_END": "Identity3",
"CHRG_ROUTE4_END": "Identity4",
},
"Routes": MapStorage{
"SortedRoutes": []MapStorage{
{"ID": "ROUTE1"},
{"ID": "ROUTE2"},
{"ID": "ROUTE3"},
{"ID": "ROUTE4"},
},
},
"BestRoute": 0,
},
}
ddp := NewDynamicDataProvider(dp)
newpath, err := ddp.processFieldPathForSet("~*cgrep.Stir[CHRG_|~*cgrep.Routes.SortedRoutes[1].ID|_END].Something[CHRG_|~*cgrep.Routes.SortedRoutes[~*cgrep.BestRoute].ID|_END]")
if err != nil {
t.Fatal(err)
}
expectedPath := "~*cgrep.Stir.CHRG_ROUTE2_END.Something.CHRG_ROUTE1_END"
if newpath != expectedPath {
t.Errorf("Expected: %q,received %q", expectedPath, newpath)
}
_, err = ddp.processFieldPathForSet("~*cgrep.Stir[CHRG_|~*cgrep.Routes.SortedRoutes[1].ID|_END].Something[CHRG_|~*cgrep.Routes.SortedRoutes[~*cgrep.BestRoute].ID|_END")
if err != ErrWrongPath {
t.Errorf("Expected error %s received %v", ErrWrongPath, err)
}
_, err = ddp.processFieldPathForSet("~*cgrep.Stir[CHRG_")
if err != ErrWrongPath {
t.Errorf("Expected error %s received %v", ErrWrongPath, err)
}
_, err = ddp.processFieldPathForSet("~*cgrep.Stir[CHRG_|~*cgrep.Routes.SortedRoutes[1].ID2|_END]")
if err != ErrNotFound {
t.Errorf("Expected error %s received %v", ErrNotFound, err)
}
newpath, err = ddp.processFieldPathForSet("~*cgrep.Stir[1]")
if err != nil {
t.Fatal(err)
}
if newpath != EmptyString {
t.Errorf("Expected: %q,received %q", EmptyString, newpath)
}
}
func TestDynamicDataProviderFieldAsString(t *testing.T) {
dp := MapStorage{
MetaCgrep: MapStorage{
"Stir": map[string]interface{}{
"CHRG_ROUTE1_END": "Identity1",
"CHRG_ROUTE2_END": "Identity2",
"CHRG_ROUTE3_END": "Identity3",
"CHRG_ROUTE4_END": "Identity4",
},
"Routes": map[string]interface{}{
"SortedRoutes": []map[string]interface{}{
{"ID": "ROUTE1"},
{"ID": "ROUTE2"},
{"ID": "ROUTE3"},
{"ID": "ROUTE4"},
},
},
"BestRoute": 0,
},
}
ddp := NewDynamicDataProvider(dp)
path := "*cgrep.Stir[CHRG_|~*cgrep.Routes.SortedRoutes[~*cgrep.BestRoute].ID|_END]"
out, err := ddp.FieldAsString(strings.Split(path, NestingSep))
if err != nil {
t.Fatal(err)
}
expected := "Identity1"
if out != expected {
t.Errorf("Expected: %q,received %q", expected, out)
}
path = "*cgrep.Stir[CHRG_|~*cgrep.Routes.SortedRoutes[~*cgrep.BestRoute].ID|_END"
_, err = ddp.FieldAsString(strings.Split(path, NestingSep))
if err != ErrWrongPath {
t.Errorf("Expected error %s received %v", ErrWrongPath, err)
}
}
func TestDynamicDataProviderGetFullFieldPath(t *testing.T) {
dp := MapStorage{
MetaCgrep: MapStorage{
"Stir": MapStorage{
"CHRG_ROUTE1_END": "Identity1",
"CHRG_ROUTE2_END": "Identity2",
"CHRG_ROUTE3_END": "Identity3",
"CHRG_ROUTE4_END": "Identity4",
},
"Routes": MapStorage{
"SortedRoutes": []MapStorage{
{"ID": "ROUTE1"},
{"ID": "ROUTE2"},
{"ID": "ROUTE3"},
{"ID": "ROUTE4"},
},
},
"BestRoute": 0,
},
}
ddp := NewDynamicDataProvider(dp)
newpath, err := ddp.GetFullFieldPath("~*cgrep.Stir[CHRG_|~*cgrep.Routes.SortedRoutes[1].ID|_END].Something[CHRG_|~*cgrep.Routes.SortedRoutes[~*cgrep.BestRoute].ID|_END]")
if err != nil {
t.Fatal(err)
}
expectedPath := "~*cgrep.Stir.CHRG_ROUTE2_END.Something.CHRG_ROUTE1_END"
if newpath.Path != expectedPath {
t.Errorf("Expected: %q,received %q", expectedPath, newpath)
}
_, err = ddp.GetFullFieldPath("~*cgrep.Stir[CHRG_|~*cgrep.Routes.SortedRoutes[1].ID|_END].Something[CHRG_|~*cgrep.Routes.SortedRoutes[~*cgrep.BestRoute].ID|_END")
if err != ErrWrongPath {
t.Errorf("Expected error %s received %v", ErrWrongPath, err)
}
_, err = ddp.GetFullFieldPath("~*cgrep.Stir[CHRG_")
if err != ErrWrongPath {
t.Errorf("Expected error %s received %v", ErrWrongPath, err)
}
_, err = ddp.GetFullFieldPath("~*cgrep.Stir[CHRG_|~*cgrep.Routes.SortedRoutes[1].ID2|_END]")
if err != ErrNotFound {
t.Errorf("Expected error %s received %v", ErrNotFound, err)
}
newpath, err = ddp.GetFullFieldPath("~*cgrep.Stir[1]")
if err != nil {
t.Fatal(err)
}
if newpath != nil {
t.Errorf("Expected: %v,received %q", nil, newpath)
}
newpath, err = ddp.GetFullFieldPath("~*cgrep.Stir")
if err != nil {
t.Fatal(err)
}
if newpath != nil {
t.Errorf("Expected: %v,received %q", nil, newpath)
}
newpath, err = ddp.GetFullFieldPath("*cgrep.Stir[CHRG_|~*cgrep.Routes.SortedRoutes[~*cgrep.BestRoute].ID|_END]")
if err != nil {
t.Fatal(err)
}
if newpath == nil {
t.Errorf("Expected: %v,received %q", nil, newpath)
}
}

91
utils/dynamicfieldpath.go Normal file
View File

@@ -0,0 +1,91 @@
/*
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 <http://www.gnu.org/licenses/>
*/
package utils
import (
"strings"
)
// GetFullFieldPath returns the full path for the
func GetFullFieldPath(fldPath string, dP DataProvider) (fpath *FullPath, err error) {
var newPath string
if newPath, err = processFieldPath(fldPath, dP); err != nil || newPath == EmptyString {
return
}
fpath = &FullPath{
PathItems: NewPathItems(strings.Split(newPath, NestingSep)),
Path: newPath,
}
return
}
// replaces the dynamic path between <>
func processFieldPath(fldPath string, dP DataProvider) (newPath string, err error) {
idx := strings.IndexByte(fldPath, RSRDynStartChar)
if idx == -1 {
return // no proccessing requred
}
newPath = fldPath[:idx] // add the first path of the path without the "<"
for idx != -1 { // stop when we do not find any "<"
fldPath = fldPath[idx+1:] // move the path to the begining of the index
nextBeginIdx := strings.IndexByte(fldPath, RSRDynStartChar) // get the next "<" if any
nextEndIdx := strings.IndexByte(fldPath, RSRDynEndChar) // get the next ">" if any
if nextEndIdx == -1 { // no end index found so return error
err = ErrWrongPath
newPath = EmptyString
return
}
// parse the rest of the field path until we match the [ ]
bIdx, eIdx := nextBeginIdx, nextEndIdx
for nextBeginIdx != -1 && nextBeginIdx < nextEndIdx { // do this until no new [ is found or the next begining [ is after the end ]
nextBeginIdx = strings.IndexByte(fldPath[bIdx+1:], RSRDynStartChar) // get the next "<" if any
nextEndIdx = strings.IndexByte(fldPath[eIdx+1:], RSRDynEndChar) // get the next ">" if any
if nextEndIdx == -1 { // no end index found so return error
err = ErrWrongPath
newPath = EmptyString
return
}
if nextBeginIdx == -1 { // if no index found do not increment but replace it
bIdx = -1
} else {
bIdx += nextBeginIdx + 1
}
// increment the indexes
eIdx += nextEndIdx + 1
}
var val string
for _, path := range strings.Split(fldPath[:eIdx], PipeSep) { // proccess the found path
if val, err = DPDynamicString(path, dP); err != nil {
newPath = EmptyString
return
}
}
if bIdx == -1 { // if is the last ocurence add the rest of the path and exit
newPath += val + fldPath[eIdx+1:]
} else {
// else just add until the next [
newPath += val + fldPath[eIdx+1:bIdx]
}
idx = bIdx
}
return
}

View File

@@ -0,0 +1,140 @@
/*
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 <http://www.gnu.org/licenses/>
*/
package utils
import (
"testing"
)
func TestDynamicDataProviderProccesFieldPath(t *testing.T) {
dp := MapStorage{
MetaCgrep: MapStorage{
"Stir": MapStorage{
"CHRG_ROUTE1_END": "Identity1",
"CHRG_ROUTE2_END": "Identity2",
"CHRG_ROUTE3_END": "Identity3",
"CHRG_ROUTE4_END": "Identity4",
},
"Routes": MapStorage{
"SortedRoutes": []MapStorage{
{"ID": "ROUTE1"},
{"ID": "ROUTE2"},
{"ID": "ROUTE3"},
{"ID": "ROUTE4"},
},
},
"BestRoute": 0,
},
}
newpath, err := processFieldPath("~*cgrep.Stir[CHRG_|~*cgrep.Routes.SortedRoutes[1].ID|_END].Something[CHRG_|~*cgrep.Routes.SortedRoutes[~*cgrep.BestRoute].ID|_END]", dp)
if err != nil {
t.Fatal(err)
}
expectedPath := "~*cgrep.Stir.CHRG_ROUTE2_END.Something.CHRG_ROUTE1_END"
if newpath != expectedPath {
t.Errorf("Expected: %q,received %q", expectedPath, newpath)
}
_, err = processFieldPath("~*cgrep.Stir[CHRG_|~*cgrep.Routes.SortedRoutes[1].ID|_END].Something[CHRG_|~*cgrep.Routes.SortedRoutes[~*cgrep.BestRoute].ID|_END", dp)
if err != ErrWrongPath {
t.Errorf("Expected error %s received %v", ErrWrongPath, err)
}
_, err = processFieldPath("~*cgrep.Stir[CHRG_", dp)
if err != ErrWrongPath {
t.Errorf("Expected error %s received %v", ErrWrongPath, err)
}
_, err = processFieldPath("~*cgrep.Stir[CHRG_|~*cgrep.Routes.SortedRoutes[1].ID2|_END]", dp)
if err != ErrNotFound {
t.Errorf("Expected error %s received %v", ErrNotFound, err)
}
newpath, err = processFieldPath("~*cgrep.Stir[1]", dp)
if err != nil {
t.Fatal(err)
}
if newpath != EmptyString {
t.Errorf("Expected: %q,received %q", EmptyString, newpath)
}
}
func TestDynamicDataProviderGetFullFieldPath(t *testing.T) {
dp := MapStorage{
MetaCgrep: MapStorage{
"Stir": MapStorage{
"CHRG_ROUTE1_END": "Identity1",
"CHRG_ROUTE2_END": "Identity2",
"CHRG_ROUTE3_END": "Identity3",
"CHRG_ROUTE4_END": "Identity4",
},
"Routes": MapStorage{
"SortedRoutes": []MapStorage{
{"ID": "ROUTE1"},
{"ID": "ROUTE2"},
{"ID": "ROUTE3"},
{"ID": "ROUTE4"},
},
},
"BestRoute": 0,
},
}
newpath, err := GetFullFieldPath("~*cgrep.Stir[CHRG_|~*cgrep.Routes.SortedRoutes[1].ID|_END].Something[CHRG_|~*cgrep.Routes.SortedRoutes[~*cgrep.BestRoute].ID|_END]", dp)
if err != nil {
t.Fatal(err)
}
expectedPath := "~*cgrep.Stir.CHRG_ROUTE2_END.Something.CHRG_ROUTE1_END"
if newpath.Path != expectedPath {
t.Errorf("Expected: %q,received %q", expectedPath, newpath)
}
_, err = GetFullFieldPath("~*cgrep.Stir[CHRG_|~*cgrep.Routes.SortedRoutes[1].ID|_END].Something[CHRG_|~*cgrep.Routes.SortedRoutes[~*cgrep.BestRoute].ID|_END", dp)
if err != ErrWrongPath {
t.Errorf("Expected error %s received %v", ErrWrongPath, err)
}
_, err = GetFullFieldPath("~*cgrep.Stir[CHRG_", dp)
if err != ErrWrongPath {
t.Errorf("Expected error %s received %v", ErrWrongPath, err)
}
_, err = GetFullFieldPath("~*cgrep.Stir[CHRG_|~*cgrep.Routes.SortedRoutes[1].ID2|_END]", dp)
if err != ErrNotFound {
t.Errorf("Expected error %s received %v", ErrNotFound, err)
}
newpath, err = GetFullFieldPath("~*cgrep.Stir[1]", dp)
if err != nil {
t.Fatal(err)
}
if newpath != nil {
t.Errorf("Expected: %v,received %q", nil, newpath)
}
newpath, err = GetFullFieldPath("~*cgrep.Stir", dp)
if err != nil {
t.Fatal(err)
}
if newpath != nil {
t.Errorf("Expected: %v,received %q", nil, newpath)
}
newpath, err = GetFullFieldPath("*cgrep.Stir[CHRG_|~*cgrep.Routes.SortedRoutes[~*cgrep.BestRoute].ID|_END]", dp)
if err != nil {
t.Fatal(err)
}
if newpath == nil {
t.Errorf("Expected: %v,received %q", nil, newpath)
}
}