From e3e8693c4509855578dbef45174c23ed01f8701a Mon Sep 17 00:00:00 2001 From: TeoV Date: Tue, 18 Feb 2020 11:39:24 +0200 Subject: [PATCH] Add *group type in AgentRequest + update changelog --- agents/agentreq.go | 8 +- agents/agentreq_test.go | 42 +++++++ changelog | 5 + .../samples/diamagent_internal/dryrun.json | 4 +- data/conf/samples/diamagent_mongo/dryrun.json | 4 +- data/conf/samples/diamagent_mysql/dryrun.json | 4 +- .../diamsctpagent_internal/dryrun.json | 4 +- .../samples/diamsctpagent_mongo/dryrun.json | 4 +- .../samples/diamsctpagent_mysql/dryrun.json | 4 +- .../samples/dispatchers/diamagent/dryrun.json | 4 +- .../samples/dnsagent_internal/suppliers.json | 24 ++-- .../samples/dnsagent_mongo/suppliers.json | 118 +++++++++--------- .../samples/dnsagent_mysql/suppliers.json | 118 +++++++++--------- .../samples/httpagent_internal/httpagent.json | 2 +- .../httpagent_internal_gob/httpagent.json | 2 +- .../samples/httpagent_mongo/httpagent.json | 2 +- .../httpagent_mongo_gob/httpagent.json | 2 +- .../samples/httpagent_mysql/httpagent.json | 2 +- .../httpagent_mysql_gob/httpagent.json | 2 +- .../httpagenttls_internal/httpagent.json | 2 +- .../httpagenttls_internal_gob/httpagent.json | 2 +- .../samples/httpagenttls_mongo/httpagent.json | 2 +- .../httpagenttls_mongo_gob/httpagent.json | 2 +- .../samples/httpagenttls_mysql/httpagent.json | 2 +- .../httpagenttls_mysql_gob/httpagent.json | 2 +- utils/consts.go | 1 + 26 files changed, 209 insertions(+), 159 deletions(-) diff --git a/agents/agentreq.go b/agents/agentreq.go index 732ceeebd..0186f74e7 100644 --- a/agents/agentreq.go +++ b/agents/agentreq.go @@ -170,12 +170,14 @@ func (ar *AgentRequest) SetFields(tplFlds []*config.FCTemplate) (err error) { } } else { valSet = nMFields.([]*config.NMItem) // start from previous stored fields - if tplFld.Type == utils.META_COMPOSED { + switch tplFld.Type { + case utils.META_COMPOSED: prevNMItem := valSet[len(valSet)-1] // could be we need nil protection here *nMItm = *prevNMItem // inherit the particularities, ie AttributeName nMItm.Data = utils.IfaceAsString(prevNMItem.Data) + utils.IfaceAsString(out) valSet = valSet[:len(valSet)-1] // discard the last item since we have captured it in nmItem - } else { + case utils.MetaGroup: // in case of *group type simply append to valSet + default: valSet = nil } } @@ -221,7 +223,7 @@ func (ar *AgentRequest) ParseField( case utils.MetaRemoteHost: out = ar.RemoteHost().String() isString = true - case utils.MetaVariable, utils.META_COMPOSED: + case utils.MetaVariable, utils.META_COMPOSED, utils.MetaGroup: out, err = cfgFld.Value.ParseDataProvider(ar, utils.NestingSep) isString = true case utils.META_USAGE_DIFFERENCE: diff --git a/agents/agentreq_test.go b/agents/agentreq_test.go index 440cd02b2..f5d5614b2 100644 --- a/agents/agentreq_test.go +++ b/agents/agentreq_test.go @@ -1442,3 +1442,45 @@ func TestAgReqOverwrite(t *testing.T) { "OverwrittenAccountWithComposed", (rcv.([]*config.NMItem))[0].Data) } } + +func TestAgReqGroupType(t *testing.T) { + cfg, _ := config.NewDefaultCGRConfig() + data := engine.NewInternalDB(nil, nil, true, cfg.DataDbCfg().Items) + dm := engine.NewDataManager(data, config.CgrConfig().CacheCfg(), nil) + filterS := engine.NewFilterS(cfg, nil, dm) + agReq := NewAgentRequest(nil, nil, nil, nil, nil, "cgrates.org", "", filterS, nil, nil) + // populate request, emulating the way will be done in HTTPAgent + agReq.CGRRequest.Set([]string{utils.ToR}, utils.VOICE, false, false) + agReq.CGRRequest.Set([]string{utils.Account}, "1001", false, false) + agReq.CGRRequest.Set([]string{utils.Destination}, "1002", false, false) + agReq.CGRRequest.Set([]string{utils.AnswerTime}, + time.Date(2013, 12, 30, 15, 0, 1, 0, time.UTC), false, false) + agReq.CGRRequest.Set([]string{utils.RequestType}, utils.META_PREPAID, false, false) + + agReq.CGRReply = config.NewNavigableMap(nil) + + tplFlds := []*config.FCTemplate{ + &config.FCTemplate{Tag: "Account", + Path: utils.MetaCgrep + utils.NestingSep + utils.Account, Type: utils.MetaGroup, + Value: config.NewRSRParsersMustCompile("cgrates.org", true, utils.INFIELD_SEP)}, + &config.FCTemplate{Tag: "Account", + Path: utils.MetaCgrep + utils.NestingSep + utils.Account, Type: utils.MetaGroup, + Value: config.NewRSRParsersMustCompile("test", true, utils.INFIELD_SEP)}, + } + + if err := agReq.SetFields(tplFlds); err != nil { + t.Error(err) + } + + if rcv, err := agReq.CGRReply.GetField([]string{utils.Account}); err != nil { + t.Error(err) + } else if sls, canCast := rcv.([]*config.NMItem); !canCast { + t.Errorf("Cannot cast to []*config.NMItem %+v", rcv) + } else if len(sls) != 2 { + t.Errorf("expecting: %+v, \n received: %+v ", 1, len(sls)) + } else if sls[0].Data != "cgrates.org" { + t.Errorf("expecting: %+v, \n received: %+v ", "cgrates.org", sls[0].Data) + } else if sls[1].Data != "test" { + t.Errorf("expecting: %+v, \n received: %+v ", "test", sls[0].Data) + } +} diff --git a/changelog b/changelog index b84e517a8..6eb6fff48 100644 --- a/changelog +++ b/changelog @@ -1,9 +1,14 @@ cgrates (0.10) UNRELEASED; urgency=medium + [ Alexandru Tripon ] * [FilterS] Removed rals_conns in favor of reading the account directly from DataDB * [SessionS] Added check for missing CGRevent * [DiameterAgent] Using String function from diam.Message instead of ToJSON for request String method + [ Voivozeanu Teofil ] + * [AgentRequest] Add support for *group type and correctly overwrite + the values in case of *variable + -- Alexandru Tripon Tue, 18 Feb 2020 08:44:41 +0200 diff --git a/data/conf/samples/diamagent_internal/dryrun.json b/data/conf/samples/diamagent_internal/dryrun.json index e42442702..2323e3f42 100644 --- a/data/conf/samples/diamagent_internal/dryrun.json +++ b/data/conf/samples/diamagent_internal/dryrun.json @@ -181,14 +181,14 @@ { "tag": "RatingGroup", "path": "*rep.Multiple-Services-Credit-Control.Rating-Group", - "type": "*constant", + "type": "*group", "value": "2", "new_branch": true }, { "tag": "CCTotalOctets2", "path": "*rep.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets", - "type": "*variable", + "type": "*group", "value": "~*cgreq.UsedUnits2" }, ], diff --git a/data/conf/samples/diamagent_mongo/dryrun.json b/data/conf/samples/diamagent_mongo/dryrun.json index e42442702..2323e3f42 100644 --- a/data/conf/samples/diamagent_mongo/dryrun.json +++ b/data/conf/samples/diamagent_mongo/dryrun.json @@ -181,14 +181,14 @@ { "tag": "RatingGroup", "path": "*rep.Multiple-Services-Credit-Control.Rating-Group", - "type": "*constant", + "type": "*group", "value": "2", "new_branch": true }, { "tag": "CCTotalOctets2", "path": "*rep.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets", - "type": "*variable", + "type": "*group", "value": "~*cgreq.UsedUnits2" }, ], diff --git a/data/conf/samples/diamagent_mysql/dryrun.json b/data/conf/samples/diamagent_mysql/dryrun.json index e42442702..2323e3f42 100644 --- a/data/conf/samples/diamagent_mysql/dryrun.json +++ b/data/conf/samples/diamagent_mysql/dryrun.json @@ -181,14 +181,14 @@ { "tag": "RatingGroup", "path": "*rep.Multiple-Services-Credit-Control.Rating-Group", - "type": "*constant", + "type": "*group", "value": "2", "new_branch": true }, { "tag": "CCTotalOctets2", "path": "*rep.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets", - "type": "*variable", + "type": "*group", "value": "~*cgreq.UsedUnits2" }, ], diff --git a/data/conf/samples/diamsctpagent_internal/dryrun.json b/data/conf/samples/diamsctpagent_internal/dryrun.json index 9606545cc..c64413e4b 100755 --- a/data/conf/samples/diamsctpagent_internal/dryrun.json +++ b/data/conf/samples/diamsctpagent_internal/dryrun.json @@ -61,9 +61,9 @@ ], "reply_fields":[ {"tag": "RatingGroup", "path": "*rep.Multiple-Services-Credit-Control.Rating-Group", - "type": "*constant", "value": "2","new_branch": true}, + "type": "*group", "value": "2","new_branch": true}, {"tag": "CCTotalOctets2", "path": "*rep.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets", - "type": "*variable", "value": "~*cgreq.UsedUnits2"}, + "type": "*group", "value": "~*cgreq.UsedUnits2"}, ], }, diff --git a/data/conf/samples/diamsctpagent_mongo/dryrun.json b/data/conf/samples/diamsctpagent_mongo/dryrun.json index 9606545cc..c64413e4b 100755 --- a/data/conf/samples/diamsctpagent_mongo/dryrun.json +++ b/data/conf/samples/diamsctpagent_mongo/dryrun.json @@ -61,9 +61,9 @@ ], "reply_fields":[ {"tag": "RatingGroup", "path": "*rep.Multiple-Services-Credit-Control.Rating-Group", - "type": "*constant", "value": "2","new_branch": true}, + "type": "*group", "value": "2","new_branch": true}, {"tag": "CCTotalOctets2", "path": "*rep.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets", - "type": "*variable", "value": "~*cgreq.UsedUnits2"}, + "type": "*group", "value": "~*cgreq.UsedUnits2"}, ], }, diff --git a/data/conf/samples/diamsctpagent_mysql/dryrun.json b/data/conf/samples/diamsctpagent_mysql/dryrun.json index 9606545cc..c64413e4b 100755 --- a/data/conf/samples/diamsctpagent_mysql/dryrun.json +++ b/data/conf/samples/diamsctpagent_mysql/dryrun.json @@ -61,9 +61,9 @@ ], "reply_fields":[ {"tag": "RatingGroup", "path": "*rep.Multiple-Services-Credit-Control.Rating-Group", - "type": "*constant", "value": "2","new_branch": true}, + "type": "*group", "value": "2","new_branch": true}, {"tag": "CCTotalOctets2", "path": "*rep.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets", - "type": "*variable", "value": "~*cgreq.UsedUnits2"}, + "type": "*group", "value": "~*cgreq.UsedUnits2"}, ], }, diff --git a/data/conf/samples/dispatchers/diamagent/dryrun.json b/data/conf/samples/dispatchers/diamagent/dryrun.json index 09e04c3b1..26f5c2a30 100644 --- a/data/conf/samples/dispatchers/diamagent/dryrun.json +++ b/data/conf/samples/dispatchers/diamagent/dryrun.json @@ -63,9 +63,9 @@ ], "reply_fields":[ {"tag": "RatingGroup", "path": "*rep.Multiple-Services-Credit-Control.Rating-Group", - "type": "*constant", "value": "2","new_branch": true}, + "type": "*group", "value": "2","new_branch": true}, {"tag": "CCTotalOctets2", "path": "*rep.Multiple-Services-Credit-Control.Used-Service-Unit.CC-Total-Octets", - "type": "*variable", "value": "~*cgreq.UsedUnits2"}, + "type": "*group", "value": "~*cgreq.UsedUnits2"}, ], }, diff --git a/data/conf/samples/dnsagent_internal/suppliers.json b/data/conf/samples/dnsagent_internal/suppliers.json index 734c16e82..a845df6ef 100644 --- a/data/conf/samples/dnsagent_internal/suppliers.json +++ b/data/conf/samples/dnsagent_internal/suppliers.json @@ -23,17 +23,17 @@ "flags": ["*none","*continue"], // do not send request to CGRateS "reply_fields":[ {"tag": "NAPTROrder", "path": "*rep.Order", - "type": "*constant", "value": "100"}, + "type": "*group", "value": "100"}, {"tag": "NAPTRPreference", "path": "*rep.Preference", - "type": "*constant", "value": "10"}, + "type": "*group", "value": "10"}, {"tag": "NAPTRFlags", "path": "*rep.Flags", - "type": "*constant", "value": "U"}, + "type": "*group", "value": "U"}, {"tag": "NAPTRService", "path": "*rep.Service", - "type": "*constant", "value": "E2U+SIP"}, - {"tag": "NAPTRRegexp", "path": "*rep.Regexp", "type": "*variable", + "type": "*group", "value": "E2U+SIP"}, + {"tag": "NAPTRRegexp", "path": "*rep.Regexp", "type": "*group", "value": "~*cgrep.Suppliers.SortedSuppliers[0].SupplierParameters"}, {"tag": "NAPTRReplacement", "path": "*rep.Replacement", - "type": "*constant", "value": "."}, + "type": "*group", "value": "."}, ], }, { @@ -43,18 +43,18 @@ "*gte:~*cgrep.Suppliers.Count:2"], "flags": ["*none","*continue"], "reply_fields":[ - {"tag": "NAPTROrder", "type": "*constant", "new_branch": true, + {"tag": "NAPTROrder", "type": "*group", "new_branch": true, "path": "*rep.Order", "value": "100"}, {"tag": "NAPTRPreference", "path": "*rep.Preference", - "type": "*constant", "value": "10"}, + "type": "*group", "value": "10"}, {"tag": "NAPTRFlags", "path": "*rep.Flags", - "type": "*constant", "value": "U"}, + "type": "*group", "value": "U"}, {"tag": "NAPTRService", "path": "*rep.Service", - "type": "*constant", "value": "E2U+SIP"}, - {"tag": "NAPTRRegexp", "path": "*rep.Regexp", "type": "*variable", + "type": "*group", "value": "E2U+SIP"}, + {"tag": "NAPTRRegexp", "path": "*rep.Regexp", "type": "*group", "value": "~*cgrep.Suppliers.SortedSuppliers[1].SupplierParameters"}, {"tag": "NAPTRReplacement", "path": "*rep.Replacement", - "type": "*constant", "value": "."}, + "type": "*group", "value": "."}, ], }, ], diff --git a/data/conf/samples/dnsagent_mongo/suppliers.json b/data/conf/samples/dnsagent_mongo/suppliers.json index 734c16e82..3427261f8 100644 --- a/data/conf/samples/dnsagent_mongo/suppliers.json +++ b/data/conf/samples/dnsagent_mongo/suppliers.json @@ -1,63 +1,63 @@ { -"dns_agent": { - "request_processors": [ - { - "id": "NAPTRSuppliersQuery", - "filters": ["*string:~*vars.QueryType:NAPTR", - "*string:~*vars.E164Address:4986517174965"], - "flags": ["*message", "*suppliers","*continue"], - "request_fields":[ - {"tag": "ToR", "path": "*cgreq.Account", "type": "*constant", "value": "1001"}, // so we can match the supplier profile - ], - "reply_fields":[ - {"tag": "DispatchReply", "type": "*none", - "blocker": true}, // enforces continue_on_success so we can check answer with filters - ], - }, - { - "id": "NAPTRSuppliersOneSupplier", - "filters": ["*string:~*vars.QueryType:NAPTR", - "*string:~*vars.E164Address:4986517174965", - "*gte:~*cgrep.Suppliers.Count:1"], - "flags": ["*none","*continue"], // do not send request to CGRateS - "reply_fields":[ - {"tag": "NAPTROrder", "path": "*rep.Order", - "type": "*constant", "value": "100"}, - {"tag": "NAPTRPreference", "path": "*rep.Preference", - "type": "*constant", "value": "10"}, - {"tag": "NAPTRFlags", "path": "*rep.Flags", - "type": "*constant", "value": "U"}, - {"tag": "NAPTRService", "path": "*rep.Service", - "type": "*constant", "value": "E2U+SIP"}, - {"tag": "NAPTRRegexp", "path": "*rep.Regexp", "type": "*variable", - "value": "~*cgrep.Suppliers.SortedSuppliers[0].SupplierParameters"}, - {"tag": "NAPTRReplacement", "path": "*rep.Replacement", - "type": "*constant", "value": "."}, - ], - }, - { - "id": "NAPTRSuppliersTwoSuppliers", - "filters": ["*string:~*vars.QueryType:NAPTR", - "*string:~*vars.E164Address:4986517174965", - "*gte:~*cgrep.Suppliers.Count:2"], - "flags": ["*none","*continue"], - "reply_fields":[ - {"tag": "NAPTROrder", "type": "*constant", "new_branch": true, - "path": "*rep.Order", "value": "100"}, - {"tag": "NAPTRPreference", "path": "*rep.Preference", - "type": "*constant", "value": "10"}, - {"tag": "NAPTRFlags", "path": "*rep.Flags", - "type": "*constant", "value": "U"}, - {"tag": "NAPTRService", "path": "*rep.Service", - "type": "*constant", "value": "E2U+SIP"}, - {"tag": "NAPTRRegexp", "path": "*rep.Regexp", "type": "*variable", - "value": "~*cgrep.Suppliers.SortedSuppliers[1].SupplierParameters"}, - {"tag": "NAPTRReplacement", "path": "*rep.Replacement", - "type": "*constant", "value": "."}, - ], - }, - ], -}, + "dns_agent": { + "request_processors": [ + { + "id": "NAPTRSuppliersQuery", + "filters": ["*string:~*vars.QueryType:NAPTR", + "*string:~*vars.E164Address:4986517174965"], + "flags": ["*message", "*suppliers","*continue"], + "request_fields":[ + {"tag": "ToR", "path": "*cgreq.Account", "type": "*constant", "value": "1001"}, // so we can match the supplier profile + ], + "reply_fields":[ + {"tag": "DispatchReply", "type": "*none", + "blocker": true}, // enforces continue_on_success so we can check answer with filters + ], + }, + { + "id": "NAPTRSuppliersOneSupplier", + "filters": ["*string:~*vars.QueryType:NAPTR", + "*string:~*vars.E164Address:4986517174965", + "*gte:~*cgrep.Suppliers.Count:1"], + "flags": ["*none","*continue"], // do not send request to CGRateS + "reply_fields":[ + {"tag": "NAPTROrder", "path": "*rep.Order", + "type": "*group", "value": "100"}, + {"tag": "NAPTRPreference", "path": "*rep.Preference", + "type": "*group", "value": "10"}, + {"tag": "NAPTRFlags", "path": "*rep.Flags", + "type": "*group", "value": "U"}, + {"tag": "NAPTRService", "path": "*rep.Service", + "type": "*group", "value": "E2U+SIP"}, + {"tag": "NAPTRRegexp", "path": "*rep.Regexp", "type": "*group", + "value": "~*cgrep.Suppliers.SortedSuppliers[0].SupplierParameters"}, + {"tag": "NAPTRReplacement", "path": "*rep.Replacement", + "type": "*group", "value": "."}, + ], + }, + { + "id": "NAPTRSuppliersTwoSuppliers", + "filters": ["*string:~*vars.QueryType:NAPTR", + "*string:~*vars.E164Address:4986517174965", + "*gte:~*cgrep.Suppliers.Count:2"], + "flags": ["*none","*continue"], + "reply_fields":[ + {"tag": "NAPTROrder", "type": "*group", "new_branch": true, + "path": "*rep.Order", "value": "100"}, + {"tag": "NAPTRPreference", "path": "*rep.Preference", + "type": "*group", "value": "10"}, + {"tag": "NAPTRFlags", "path": "*rep.Flags", + "type": "*group", "value": "U"}, + {"tag": "NAPTRService", "path": "*rep.Service", + "type": "*group", "value": "E2U+SIP"}, + {"tag": "NAPTRRegexp", "path": "*rep.Regexp", "type": "*group", + "value": "~*cgrep.Suppliers.SortedSuppliers[1].SupplierParameters"}, + {"tag": "NAPTRReplacement", "path": "*rep.Replacement", + "type": "*group", "value": "."}, + ], + }, + ], + }, } diff --git a/data/conf/samples/dnsagent_mysql/suppliers.json b/data/conf/samples/dnsagent_mysql/suppliers.json index 734c16e82..3427261f8 100644 --- a/data/conf/samples/dnsagent_mysql/suppliers.json +++ b/data/conf/samples/dnsagent_mysql/suppliers.json @@ -1,63 +1,63 @@ { -"dns_agent": { - "request_processors": [ - { - "id": "NAPTRSuppliersQuery", - "filters": ["*string:~*vars.QueryType:NAPTR", - "*string:~*vars.E164Address:4986517174965"], - "flags": ["*message", "*suppliers","*continue"], - "request_fields":[ - {"tag": "ToR", "path": "*cgreq.Account", "type": "*constant", "value": "1001"}, // so we can match the supplier profile - ], - "reply_fields":[ - {"tag": "DispatchReply", "type": "*none", - "blocker": true}, // enforces continue_on_success so we can check answer with filters - ], - }, - { - "id": "NAPTRSuppliersOneSupplier", - "filters": ["*string:~*vars.QueryType:NAPTR", - "*string:~*vars.E164Address:4986517174965", - "*gte:~*cgrep.Suppliers.Count:1"], - "flags": ["*none","*continue"], // do not send request to CGRateS - "reply_fields":[ - {"tag": "NAPTROrder", "path": "*rep.Order", - "type": "*constant", "value": "100"}, - {"tag": "NAPTRPreference", "path": "*rep.Preference", - "type": "*constant", "value": "10"}, - {"tag": "NAPTRFlags", "path": "*rep.Flags", - "type": "*constant", "value": "U"}, - {"tag": "NAPTRService", "path": "*rep.Service", - "type": "*constant", "value": "E2U+SIP"}, - {"tag": "NAPTRRegexp", "path": "*rep.Regexp", "type": "*variable", - "value": "~*cgrep.Suppliers.SortedSuppliers[0].SupplierParameters"}, - {"tag": "NAPTRReplacement", "path": "*rep.Replacement", - "type": "*constant", "value": "."}, - ], - }, - { - "id": "NAPTRSuppliersTwoSuppliers", - "filters": ["*string:~*vars.QueryType:NAPTR", - "*string:~*vars.E164Address:4986517174965", - "*gte:~*cgrep.Suppliers.Count:2"], - "flags": ["*none","*continue"], - "reply_fields":[ - {"tag": "NAPTROrder", "type": "*constant", "new_branch": true, - "path": "*rep.Order", "value": "100"}, - {"tag": "NAPTRPreference", "path": "*rep.Preference", - "type": "*constant", "value": "10"}, - {"tag": "NAPTRFlags", "path": "*rep.Flags", - "type": "*constant", "value": "U"}, - {"tag": "NAPTRService", "path": "*rep.Service", - "type": "*constant", "value": "E2U+SIP"}, - {"tag": "NAPTRRegexp", "path": "*rep.Regexp", "type": "*variable", - "value": "~*cgrep.Suppliers.SortedSuppliers[1].SupplierParameters"}, - {"tag": "NAPTRReplacement", "path": "*rep.Replacement", - "type": "*constant", "value": "."}, - ], - }, - ], -}, + "dns_agent": { + "request_processors": [ + { + "id": "NAPTRSuppliersQuery", + "filters": ["*string:~*vars.QueryType:NAPTR", + "*string:~*vars.E164Address:4986517174965"], + "flags": ["*message", "*suppliers","*continue"], + "request_fields":[ + {"tag": "ToR", "path": "*cgreq.Account", "type": "*constant", "value": "1001"}, // so we can match the supplier profile + ], + "reply_fields":[ + {"tag": "DispatchReply", "type": "*none", + "blocker": true}, // enforces continue_on_success so we can check answer with filters + ], + }, + { + "id": "NAPTRSuppliersOneSupplier", + "filters": ["*string:~*vars.QueryType:NAPTR", + "*string:~*vars.E164Address:4986517174965", + "*gte:~*cgrep.Suppliers.Count:1"], + "flags": ["*none","*continue"], // do not send request to CGRateS + "reply_fields":[ + {"tag": "NAPTROrder", "path": "*rep.Order", + "type": "*group", "value": "100"}, + {"tag": "NAPTRPreference", "path": "*rep.Preference", + "type": "*group", "value": "10"}, + {"tag": "NAPTRFlags", "path": "*rep.Flags", + "type": "*group", "value": "U"}, + {"tag": "NAPTRService", "path": "*rep.Service", + "type": "*group", "value": "E2U+SIP"}, + {"tag": "NAPTRRegexp", "path": "*rep.Regexp", "type": "*group", + "value": "~*cgrep.Suppliers.SortedSuppliers[0].SupplierParameters"}, + {"tag": "NAPTRReplacement", "path": "*rep.Replacement", + "type": "*group", "value": "."}, + ], + }, + { + "id": "NAPTRSuppliersTwoSuppliers", + "filters": ["*string:~*vars.QueryType:NAPTR", + "*string:~*vars.E164Address:4986517174965", + "*gte:~*cgrep.Suppliers.Count:2"], + "flags": ["*none","*continue"], + "reply_fields":[ + {"tag": "NAPTROrder", "type": "*group", "new_branch": true, + "path": "*rep.Order", "value": "100"}, + {"tag": "NAPTRPreference", "path": "*rep.Preference", + "type": "*group", "value": "10"}, + {"tag": "NAPTRFlags", "path": "*rep.Flags", + "type": "*group", "value": "U"}, + {"tag": "NAPTRService", "path": "*rep.Service", + "type": "*group", "value": "E2U+SIP"}, + {"tag": "NAPTRRegexp", "path": "*rep.Regexp", "type": "*group", + "value": "~*cgrep.Suppliers.SortedSuppliers[1].SupplierParameters"}, + {"tag": "NAPTRReplacement", "path": "*rep.Replacement", + "type": "*group", "value": "."}, + ], + }, + ], + }, } diff --git a/data/conf/samples/httpagent_internal/httpagent.json b/data/conf/samples/httpagent_internal/httpagent.json index a9310450a..957d8be8f 100644 --- a/data/conf/samples/httpagent_internal/httpagent.json +++ b/data/conf/samples/httpagent_internal/httpagent.json @@ -155,7 +155,7 @@ "flags": ["*dryrun"], "request_fields":[], "reply_fields":[ - {"tag": "Field1", "path": "*rep.Item1.1", "type": "*variable", + {"tag": "Field1", "path": "*rep.Item1.1", "type": "*group", "value": "Val2", "mandatory": true}, ], }, diff --git a/data/conf/samples/httpagent_internal_gob/httpagent.json b/data/conf/samples/httpagent_internal_gob/httpagent.json index a9310450a..957d8be8f 100644 --- a/data/conf/samples/httpagent_internal_gob/httpagent.json +++ b/data/conf/samples/httpagent_internal_gob/httpagent.json @@ -155,7 +155,7 @@ "flags": ["*dryrun"], "request_fields":[], "reply_fields":[ - {"tag": "Field1", "path": "*rep.Item1.1", "type": "*variable", + {"tag": "Field1", "path": "*rep.Item1.1", "type": "*group", "value": "Val2", "mandatory": true}, ], }, diff --git a/data/conf/samples/httpagent_mongo/httpagent.json b/data/conf/samples/httpagent_mongo/httpagent.json index a9310450a..957d8be8f 100644 --- a/data/conf/samples/httpagent_mongo/httpagent.json +++ b/data/conf/samples/httpagent_mongo/httpagent.json @@ -155,7 +155,7 @@ "flags": ["*dryrun"], "request_fields":[], "reply_fields":[ - {"tag": "Field1", "path": "*rep.Item1.1", "type": "*variable", + {"tag": "Field1", "path": "*rep.Item1.1", "type": "*group", "value": "Val2", "mandatory": true}, ], }, diff --git a/data/conf/samples/httpagent_mongo_gob/httpagent.json b/data/conf/samples/httpagent_mongo_gob/httpagent.json index a9310450a..957d8be8f 100644 --- a/data/conf/samples/httpagent_mongo_gob/httpagent.json +++ b/data/conf/samples/httpagent_mongo_gob/httpagent.json @@ -155,7 +155,7 @@ "flags": ["*dryrun"], "request_fields":[], "reply_fields":[ - {"tag": "Field1", "path": "*rep.Item1.1", "type": "*variable", + {"tag": "Field1", "path": "*rep.Item1.1", "type": "*group", "value": "Val2", "mandatory": true}, ], }, diff --git a/data/conf/samples/httpagent_mysql/httpagent.json b/data/conf/samples/httpagent_mysql/httpagent.json index a9310450a..957d8be8f 100644 --- a/data/conf/samples/httpagent_mysql/httpagent.json +++ b/data/conf/samples/httpagent_mysql/httpagent.json @@ -155,7 +155,7 @@ "flags": ["*dryrun"], "request_fields":[], "reply_fields":[ - {"tag": "Field1", "path": "*rep.Item1.1", "type": "*variable", + {"tag": "Field1", "path": "*rep.Item1.1", "type": "*group", "value": "Val2", "mandatory": true}, ], }, diff --git a/data/conf/samples/httpagent_mysql_gob/httpagent.json b/data/conf/samples/httpagent_mysql_gob/httpagent.json index a9310450a..957d8be8f 100644 --- a/data/conf/samples/httpagent_mysql_gob/httpagent.json +++ b/data/conf/samples/httpagent_mysql_gob/httpagent.json @@ -155,7 +155,7 @@ "flags": ["*dryrun"], "request_fields":[], "reply_fields":[ - {"tag": "Field1", "path": "*rep.Item1.1", "type": "*variable", + {"tag": "Field1", "path": "*rep.Item1.1", "type": "*group", "value": "Val2", "mandatory": true}, ], }, diff --git a/data/conf/samples/httpagenttls_internal/httpagent.json b/data/conf/samples/httpagenttls_internal/httpagent.json index a9310450a..957d8be8f 100644 --- a/data/conf/samples/httpagenttls_internal/httpagent.json +++ b/data/conf/samples/httpagenttls_internal/httpagent.json @@ -155,7 +155,7 @@ "flags": ["*dryrun"], "request_fields":[], "reply_fields":[ - {"tag": "Field1", "path": "*rep.Item1.1", "type": "*variable", + {"tag": "Field1", "path": "*rep.Item1.1", "type": "*group", "value": "Val2", "mandatory": true}, ], }, diff --git a/data/conf/samples/httpagenttls_internal_gob/httpagent.json b/data/conf/samples/httpagenttls_internal_gob/httpagent.json index a9310450a..957d8be8f 100644 --- a/data/conf/samples/httpagenttls_internal_gob/httpagent.json +++ b/data/conf/samples/httpagenttls_internal_gob/httpagent.json @@ -155,7 +155,7 @@ "flags": ["*dryrun"], "request_fields":[], "reply_fields":[ - {"tag": "Field1", "path": "*rep.Item1.1", "type": "*variable", + {"tag": "Field1", "path": "*rep.Item1.1", "type": "*group", "value": "Val2", "mandatory": true}, ], }, diff --git a/data/conf/samples/httpagenttls_mongo/httpagent.json b/data/conf/samples/httpagenttls_mongo/httpagent.json index a9310450a..957d8be8f 100644 --- a/data/conf/samples/httpagenttls_mongo/httpagent.json +++ b/data/conf/samples/httpagenttls_mongo/httpagent.json @@ -155,7 +155,7 @@ "flags": ["*dryrun"], "request_fields":[], "reply_fields":[ - {"tag": "Field1", "path": "*rep.Item1.1", "type": "*variable", + {"tag": "Field1", "path": "*rep.Item1.1", "type": "*group", "value": "Val2", "mandatory": true}, ], }, diff --git a/data/conf/samples/httpagenttls_mongo_gob/httpagent.json b/data/conf/samples/httpagenttls_mongo_gob/httpagent.json index a9310450a..957d8be8f 100644 --- a/data/conf/samples/httpagenttls_mongo_gob/httpagent.json +++ b/data/conf/samples/httpagenttls_mongo_gob/httpagent.json @@ -155,7 +155,7 @@ "flags": ["*dryrun"], "request_fields":[], "reply_fields":[ - {"tag": "Field1", "path": "*rep.Item1.1", "type": "*variable", + {"tag": "Field1", "path": "*rep.Item1.1", "type": "*group", "value": "Val2", "mandatory": true}, ], }, diff --git a/data/conf/samples/httpagenttls_mysql/httpagent.json b/data/conf/samples/httpagenttls_mysql/httpagent.json index a9310450a..957d8be8f 100644 --- a/data/conf/samples/httpagenttls_mysql/httpagent.json +++ b/data/conf/samples/httpagenttls_mysql/httpagent.json @@ -155,7 +155,7 @@ "flags": ["*dryrun"], "request_fields":[], "reply_fields":[ - {"tag": "Field1", "path": "*rep.Item1.1", "type": "*variable", + {"tag": "Field1", "path": "*rep.Item1.1", "type": "*group", "value": "Val2", "mandatory": true}, ], }, diff --git a/data/conf/samples/httpagenttls_mysql_gob/httpagent.json b/data/conf/samples/httpagenttls_mysql_gob/httpagent.json index a9310450a..957d8be8f 100644 --- a/data/conf/samples/httpagenttls_mysql_gob/httpagent.json +++ b/data/conf/samples/httpagenttls_mysql_gob/httpagent.json @@ -155,7 +155,7 @@ "flags": ["*dryrun"], "request_fields":[], "reply_fields":[ - {"tag": "Field1", "path": "*rep.Item1.1", "type": "*variable", + {"tag": "Field1", "path": "*rep.Item1.1", "type": "*group", "value": "Val2", "mandatory": true}, ], }, diff --git a/utils/consts.go b/utils/consts.go index 0019e548a..3ad1ee348 100755 --- a/utils/consts.go +++ b/utils/consts.go @@ -652,6 +652,7 @@ const ( MetaLoaders = "*loaders" TmpSuffix = ".tmp" MetaDiamreq = "*diamreq" + MetaGroup = "*group" ) // Migrator Action