Updated diameter filter

This commit is contained in:
Trial97
2020-05-22 17:51:02 +03:00
committed by Dan Christian Bogos
parent 90ca5eded0
commit a436718fc8
47 changed files with 352 additions and 123 deletions

View File

@@ -216,9 +216,14 @@ func (ar *AgentRequest) SetFields(tplFlds []*config.FCTemplate) (err error) {
}
return
}
fullPath := &utils.FullPath{
PathItems: tplFld.GetPathItems().Clone(), // need to clone so me do not modify the template
Path: tplFld.Path,
var fullPath *utils.FullPath
if fullPath, err = ar.dynamicProvider.GetFullFieldPath(tplFld.Path); err != nil {
return
} else if fullPath == nil { // no dynamic path
fullPath = &utils.FullPath{
PathItems: tplFld.GetPathItems().Clone(), // need to clone so me do not modify the template
Path: tplFld.Path,
}
}
nMItm := &config.NMItem{Data: out, Path: tplFld.GetPathSlice()[1:], Config: tplFld}

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, "<"); len(splt) != 1 {
lastPath = splt[0]
if splt[1][len(splt[1])-1:] != "]" {
if splt[1][len(splt[1])-1:] != ">" {
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

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

@@ -188,7 +188,7 @@ With explanations in the comments:
"path": "*cgreq.Account",
"type": "*variable", // value is taken dynamically from a group AVP
"mandatory": true, // where Subscription-Id-Type is 0
"value": "~*req.Subscription-Id.Subscription-Id-Data[~Subscription-Id-Type(0)]"
"value": "~*req.Subscription-Id.Subscription-Id-Data<~Subscription-Id-Type(0)>"
},
{
"tag": "Destination", // Destination is used for charging
@@ -324,10 +324,10 @@ filters
**\*req**
Diameter request as it comes from the *DiameterClient*.
Special selector format defined in case of groups *\*req.Path.To.Attribute[$groupIndex]* or *\*req.Absolute.Path.To.Attribute[~AnotherAttributeRelativePath($valueAnotherAttribute)]*.
Special selector format defined in case of groups *\*req.Path.To.Attribute[$groupIndex]* or *\*req.Absolute.Path.To.Attribute<~AnotherAttributeRelativePath($valueAnotherAttribute)>*.
Example 1: *~\*req.Multiple-Services-Credit-Control.Rating-Group[1]* translates to: value of the group attribute at path Multiple-Services-Credit-Control.Rating-Group which is located in the second group (groups start at index 0).
Example 2: *~\*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Input-Octets[~Rating-Group(1)]* which translates to: value of the group attribute at path: *Multiple-Services-Credit-Control.Used-Service-Unit.CC-Input-Octets* where Multiple-Services-Credit-Control.Used-Service-Unit.Rating-Group has value of "1".
Example 1: *~\*req.Multiple-Services-Credit-Control.Rating-Group<1>* translates to: value of the group attribute at path Multiple-Services-Credit-Control.Rating-Group which is located in the second group (groups start at index 0).
Example 2: *~\*req.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Input-Octets<~Rating-Group(1)>* which translates to: value of the group attribute at path: *Multiple-Services-Credit-Control.Used-Service-Unit.CC-Input-Octets* where Multiple-Services-Credit-Control.Used-Service-Unit.Rating-Group has value of "1".
**\*rep**
Diameter reply going to *DiameterClient*.

View File

@@ -115,13 +115,14 @@ func (ddp *DynamicDataProvider) proccesFieldPath(fldPath string) (newPath string
// GetFullFieldPath returns the full path for the
func (ddp *DynamicDataProvider) GetFullFieldPath(fldPath string) (fpath *FullPath, err error) {
var newPath string
if newPath, err = ddp.proccesFieldPath(fldPath); err != nil || newPath == EmptyString {
if newPath, err = ddp.proccesFieldPathForSet(fldPath); err != nil || newPath == EmptyString {
return
}
fpath = &FullPath{
PathItems: NewPathItems(strings.Split(newPath, NestingSep)),
Path: newPath,
}
return
}
@@ -133,3 +134,77 @@ func (ddp DynamicDataProvider) FieldAsString(fldPath []string) (str string, err
}
return IfaceAsString(val), nil
}
// does the same thing as ... but replaces [ with . if the value between [] is dynamic
func (ddp *DynamicDataProvider) proccesFieldPathForSet(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
}

View File

@@ -141,3 +141,152 @@ func TestDynamicDataProviderFieldAsInterface2(t *testing.T) {
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.proccesFieldPathForSet("~*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.proccesFieldPathForSet("~*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.proccesFieldPathForSet("~*cgrep.Stir[CHRG_")
if err != ErrWrongPath {
t.Errorf("Expected error %s received %v", ErrWrongPath, err)
}
_, err = ddp.proccesFieldPathForSet("~*cgrep.Stir[CHRG_|~*cgrep.Routes.SortedRoutes[1].ID2|_END]")
if err != ErrNotFound {
t.Errorf("Expected error %s received %v", ErrNotFound, err)
}
newpath, err = ddp.proccesFieldPathForSet("~*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)
}
}