
{

"diameter_agent": {
	"request_processors": [
		{
			"id": "VoiceInit",
			"filters": ["*string:~*vars.*cmd:CCR", "*string:~*req.CC-Request-Type:1",
				"*prefix:~*req.Service-Context-Id:voice"],
			"flags": ["*initiate", "*accounts", "*attributes"],
			"request_fields":[
				{"tag": "TOR", "field_id": "ToR", "type": "*constant", "value": "*voice"},
				{"tag": "OriginID", "field_id": "OriginID", "type": "*composed", 
					"value": "~*req.Session-Id", "mandatory": true},
				{"tag": "OriginHost", "field_id": "OriginHost", "type": "*remote_host", 
					"mandatory": true},
				{"tag": "RequestType", "field_id": "RequestType", "type": "*constant", "value": "*attributes"},
				{"tag": "Category", "field_id": "Category", "type": "*constant", "value": "call"},
				{"tag": "Account", "field_id": "Account", "type": "*constant", "value": "*attributes"},
				{"tag": "Destination", "field_id": "Destination", "type": "*composed", 
					"value": "~*req.Service-Information.IN-Information.Real-Called-Number", "mandatory": true},
				{"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*composed", 
					"value": "~*req.Event-Timestamp", "mandatory": true},
				{"tag": "Usage", "field_id": "Usage", "type": "*composed", 
					"value": "~*req.Requested-Service-Unit.CC-Time:s/(.*)/${1}s/", "mandatory": true},
				{"tag": "SubscriberID", "field_id": "SubscriberId", "type": "*composed", 
					"value": "~*req.Subscription-Id.Subscription-Id-Data", "mandatory": true},
			],
			"reply_fields":[
				{"tag": "ResultCode",  "filters": ["*rsr::~*cgrep.Error(!^$)"], 
					"field_id": "Result-Code", "type": "*constant", "value": "5030", "blocker": true},
				{"tag": "ResultCode", "field_id": "Result-Code", "type": "*constant", "value": "2001"},
				{"tag": "GrantedUnits", "field_id": "Granted-Service-Unit.CC-Time", "type": "*composed", 
					"value": "~*cgrep.MaxUsage{*duration_seconds}", "mandatory": true},
			],
		},
		{
			"id": "VoiceUpdate",
			"filters": ["*string:~*vars.*cmd:CCR", "*string:~*req.CC-Request-Type:2",
				"*prefix:~*req.Service-Context-Id:voice"],
			"flags": ["*update", "*accounts", "*attributes"],
			"request_fields":[
				{"tag": "TOR", "field_id": "ToR", "type": "*constant", "value": "*voice"},
				{"tag": "OriginID", "field_id": "OriginID", "type": "*composed", 
					"value": "~*req.Session-Id", "mandatory": true},
				{"tag": "OriginHost", "field_id": "OriginHost", "type": "*remote_host", 
					"mandatory": true},
				{"tag": "RequestType", "field_id": "RequestType", "type": "*constant", "value": "*attributes"},
				{"tag": "Category", "field_id": "Category", "type": "*constant", "value": "call"},
				{"tag": "Account", "field_id": "Account", "type": "*constant", "value": "*attributes"},
				{"tag": "Destination", "field_id": "Destination", "type": "*composed", 
					"value": "~*req.Service-Information.IN-Information.Real-Called-Number", "mandatory": true},
				{"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*composed", 
					"value": "~*req.Event-Timestamp", "mandatory": true},
				{"tag": "Usage", "field_id": "Usage", "type": "*composed", 
					"value": "~*req.Requested-Service-Unit.CC-Time:s/(.*)/${1}s/", "mandatory": true},
				{"tag": "LastUsed", "field_id": "LastUsed", "type": "*composed", 
					"value": "~*req.Used-Service-Unit.CC-Time:s/(.*)/${1}s/", "mandatory": true},
				{"tag": "SubscriberID", "field_id": "SubscriberId", "type": "*composed", 
					"value": "~*req.Subscription-Id.Subscription-Id-Data", "mandatory": true},
			],
			"reply_fields":[
				{"tag": "ResultCode",  "filters": ["*rsr::~*cgrep.Error(!^$)"], 
					"field_id": "Result-Code", "type": "*constant", "value": "5030", "blocker": true},
				{"tag": "ResultCode", "field_id": "Result-Code", "type": "*constant", "value": "2001"},
				{"tag": "GrantedUnits", "field_id": "Granted-Service-Unit.CC-Time", "type": "*composed", 
					"value": "~*cgrep.MaxUsage{*duration_seconds}", "mandatory": true},
			],
		},
		{
			"id": "VoiceTerminate",
			"filters": ["*string:~*vars.*cmd:CCR", "*string:~*req.CC-Request-Type:3",
				"*prefix:~*req.Service-Context-Id:voice"],
			"flags": ["*terminate", "*accounts", "*attributes", "*cdrs"],
			"request_fields":[
				{"tag": "TOR", "field_id": "ToR", "type": "*constant", "value": "*voice"},
				{"tag": "OriginID", "field_id": "OriginID", "type": "*composed", 
					"value": "~*req.Session-Id", "mandatory": true},
				{"tag": "OriginHost", "field_id": "OriginHost", "type": "*remote_host", 
					"mandatory": true},
				{"tag": "RequestType", "field_id": "RequestType", "type": "*constant", "value": "*attributes"},
				{"tag": "Account", "field_id": "Account", "type": "*constant", "value": "*attributes"},
				{"tag": "Destination", "field_id": "Destination", "type": "*composed", 
					"value": "~*req.Service-Information.IN-Information.Real-Called-Number", "mandatory": true},
				{"tag": "AnswerTime", "field_id": "AnswerTime", "type": "*composed", 
					"value": "~*req.Event-Timestamp", "mandatory": true},
				{"tag": "Usage", "field_id": "Usage", "type": "*cc_usage", "mandatory": true, 
					"value":  "~*req.CC-Request-Number;~*req.Used-Service-Unit.CC-Time:s/(.*)/${1}s/;5m"},
				{"tag": "LastUsed", "field_id": "LastUsed", "type": "*composed", 
					"value": "~*req.Used-Service-Unit.CC-Time:s/(.*)/${1}s/", "mandatory": true},
				{"tag": "SubscriberID", "field_id": "SubscriberId", "type": "*composed", 
					"value": "~*req.Subscription-Id.Subscription-Id-Data", "mandatory": true},
			],
			"reply_fields":[
				{"tag": "ResultCode",  "filters": ["*rsr::~*cgrep.Error(!^$)"], 
					"field_id": "Result-Code", "type": "*constant", "value": "5030", "blocker": true},
				{"tag": "ResultCode", "field_id": "Result-Code", "type": "*constant", "value": "2001"},
			],
		},
	],
},

}