mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-15 21:29:52 +05:00
Split GetCDRs argument in two structs and update ping methods from dispatcher
This commit is contained in:
committed by
Dan Christian Bogos
parent
59652ed5df
commit
4f96ca590b
@@ -26,15 +26,15 @@ import (
|
||||
// AttributeSv1Ping interogates AttributeS server responsible to process the event
|
||||
func (dS *DispatcherService) AttributeSv1Ping(args *utils.CGREventWithArgDispatcher,
|
||||
reply *string) (err error) {
|
||||
tnt := dS.cfg.GeneralCfg().DefaultTenant
|
||||
if args.CGREvent != nil && args.CGREvent.Tenant != utils.EmptyString {
|
||||
tnt = args.CGREvent.Tenant
|
||||
if args == nil {
|
||||
args = utils.NewCGREventWithArgDispatcher()
|
||||
}
|
||||
args.CGREvent.Tenant = utils.FirstNonEmpty(args.CGREvent.Tenant, dS.cfg.GeneralCfg().DefaultTenant)
|
||||
if dS.attrS != nil {
|
||||
if args.ArgDispatcher == nil {
|
||||
return utils.NewErrMandatoryIeMissing(utils.ArgDispatcherField)
|
||||
}
|
||||
if err = dS.authorize(utils.AttributeSv1Ping, tnt,
|
||||
if err = dS.authorize(utils.AttributeSv1Ping, args.CGREvent.Tenant,
|
||||
args.APIKey, args.Time); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -28,15 +28,15 @@ import (
|
||||
// CacheSv1Ping interogates CacheSv1 server responsible to process the event
|
||||
func (dS *DispatcherService) CacheSv1Ping(args *utils.CGREventWithArgDispatcher,
|
||||
reply *string) (err error) {
|
||||
tnt := dS.cfg.GeneralCfg().DefaultTenant
|
||||
if args.CGREvent != nil && args.CGREvent.Tenant != utils.EmptyString {
|
||||
tnt = args.CGREvent.Tenant
|
||||
if args == nil {
|
||||
args = utils.NewCGREventWithArgDispatcher()
|
||||
}
|
||||
args.CGREvent.Tenant = utils.FirstNonEmpty(args.CGREvent.Tenant, dS.cfg.GeneralCfg().DefaultTenant)
|
||||
if dS.attrS != nil {
|
||||
if args.ArgDispatcher == nil {
|
||||
return utils.NewErrMandatoryIeMissing(utils.ArgDispatcherField)
|
||||
}
|
||||
if err = dS.authorize(utils.CacheSv1Ping, tnt,
|
||||
if err = dS.authorize(utils.CacheSv1Ping, args.CGREvent.Tenant,
|
||||
args.APIKey, args.CGREvent.Time); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -28,6 +28,9 @@ import (
|
||||
// CDRsV1Ping interogates CDRsV1 server responsible to process the event
|
||||
func (dS *DispatcherService) CDRsV1Ping(args *utils.CGREventWithArgDispatcher,
|
||||
reply *string) (err error) {
|
||||
if args == nil {
|
||||
args = utils.NewCGREventWithArgDispatcher()
|
||||
}
|
||||
tnt := dS.cfg.GeneralCfg().DefaultTenant
|
||||
if args.CGREvent != nil && args.CGREvent.Tenant != utils.EmptyString {
|
||||
tnt = args.CGREvent.Tenant
|
||||
|
||||
@@ -40,11 +40,27 @@ var sTestsDspCDRs = []func(t *testing.T){
|
||||
testDspCDRsGetCDR3,
|
||||
}
|
||||
|
||||
var sTestsDspCDRsWithoutAuth = []func(t *testing.T){
|
||||
testDspCDRsPingNoAuth,
|
||||
testDspCDRsProcessEventNoAuth,
|
||||
testDspCDRsCountCDRNoAuth,
|
||||
testDspCDRsGetCDRNoAuth,
|
||||
testDspCDRsGetCDRNoAuthWithoutTenant,
|
||||
testDspCDRsProcessCDRNoAuth,
|
||||
testDspCDRsGetCDR2NoAuth,
|
||||
testDspCDRsProcessExternalCDRNoAuth,
|
||||
testDspCDRsGetCDR3NoAuth,
|
||||
}
|
||||
|
||||
//Test start here
|
||||
func TestDspCDRsITMySQL(t *testing.T) {
|
||||
testDsp(t, sTestsDspCDRs, "TestDspCDRs", "all", "all2", "dispatchers", "tutorial", "oldtutorial", "dispatchers")
|
||||
}
|
||||
|
||||
func TestDspCDRsITMySQLWithoutAuth(t *testing.T) {
|
||||
testDsp(t, sTestsDspCDRsWithoutAuth, "TestDspCDRsWithoutAuth", "all", "all2", "dispatchers_no_attributes", "tutorial", "oldtutorial", "dispatchers")
|
||||
}
|
||||
|
||||
func TestDspCDRsITMongo(t *testing.T) {
|
||||
testDsp(t, sTestsDspCDRs, "TestDspCDRs", "all", "all2", "dispatchers_mongo", "tutorial", "oldtutorial", "dispatchers")
|
||||
}
|
||||
@@ -109,13 +125,11 @@ func testDspCDRsCountCDR(t *testing.T) {
|
||||
Accounts: []string{"1001"},
|
||||
RunIDs: []string{utils.MetaDefault},
|
||||
},
|
||||
TenantWithArgDispatcher: &utils.TenantWithArgDispatcher{
|
||||
TenantArg: &utils.TenantArg{
|
||||
Tenant: "cgrates.org",
|
||||
},
|
||||
ArgDispatcher: &utils.ArgDispatcher{
|
||||
APIKey: utils.StringPointer("cdrs12345"),
|
||||
},
|
||||
TenantArg: &utils.TenantArg{
|
||||
Tenant: "cgrates.org",
|
||||
},
|
||||
ArgDispatcher: &utils.ArgDispatcher{
|
||||
APIKey: utils.StringPointer("cdrs12345"),
|
||||
},
|
||||
}
|
||||
|
||||
@@ -133,13 +147,11 @@ func testDspCDRsGetCDR(t *testing.T) {
|
||||
Accounts: []string{"1001"},
|
||||
RunIDs: []string{utils.MetaDefault},
|
||||
},
|
||||
TenantWithArgDispatcher: &utils.TenantWithArgDispatcher{
|
||||
TenantArg: &utils.TenantArg{
|
||||
Tenant: "cgrates.org",
|
||||
},
|
||||
ArgDispatcher: &utils.ArgDispatcher{
|
||||
APIKey: utils.StringPointer("cdrs12345"),
|
||||
},
|
||||
TenantArg: &utils.TenantArg{
|
||||
Tenant: "cgrates.org",
|
||||
},
|
||||
ArgDispatcher: &utils.ArgDispatcher{
|
||||
APIKey: utils.StringPointer("cdrs12345"),
|
||||
},
|
||||
}
|
||||
|
||||
@@ -159,10 +171,8 @@ func testDspCDRsGetCDRWithoutTenant(t *testing.T) {
|
||||
Accounts: []string{"1001"},
|
||||
RunIDs: []string{utils.MetaDefault},
|
||||
},
|
||||
TenantWithArgDispatcher: &utils.TenantWithArgDispatcher{
|
||||
ArgDispatcher: &utils.ArgDispatcher{
|
||||
APIKey: utils.StringPointer("cdrs12345"),
|
||||
},
|
||||
ArgDispatcher: &utils.ArgDispatcher{
|
||||
APIKey: utils.StringPointer("cdrs12345"),
|
||||
},
|
||||
}
|
||||
|
||||
@@ -210,13 +220,11 @@ func testDspCDRsGetCDR2(t *testing.T) {
|
||||
RunIDs: []string{utils.MetaDefault},
|
||||
OriginIDs: []string{"testDspCDRsProcessCDR"},
|
||||
},
|
||||
TenantWithArgDispatcher: &utils.TenantWithArgDispatcher{
|
||||
TenantArg: &utils.TenantArg{
|
||||
Tenant: "cgrates.org",
|
||||
},
|
||||
ArgDispatcher: &utils.ArgDispatcher{
|
||||
APIKey: utils.StringPointer("cdrs12345"),
|
||||
},
|
||||
TenantArg: &utils.TenantArg{
|
||||
Tenant: "cgrates.org",
|
||||
},
|
||||
ArgDispatcher: &utils.ArgDispatcher{
|
||||
APIKey: utils.StringPointer("cdrs12345"),
|
||||
},
|
||||
}
|
||||
|
||||
@@ -268,13 +276,212 @@ func testDspCDRsGetCDR3(t *testing.T) {
|
||||
RunIDs: []string{utils.MetaDefault},
|
||||
OriginIDs: []string{"testDspCDRsProcessExternalCDR"},
|
||||
},
|
||||
TenantWithArgDispatcher: &utils.TenantWithArgDispatcher{
|
||||
TenantArg: &utils.TenantArg{
|
||||
Tenant: "cgrates.org",
|
||||
},
|
||||
ArgDispatcher: &utils.ArgDispatcher{
|
||||
APIKey: utils.StringPointer("cdrs12345"),
|
||||
},
|
||||
TenantArg: &utils.TenantArg{
|
||||
Tenant: "cgrates.org",
|
||||
},
|
||||
ArgDispatcher: &utils.ArgDispatcher{
|
||||
APIKey: utils.StringPointer("cdrs12345"),
|
||||
},
|
||||
}
|
||||
|
||||
if err := dispEngine.RCP.Call(utils.CDRsV1GetCDRs, args, &reply); err != nil {
|
||||
t.Error(err)
|
||||
} else if len(reply) != 1 {
|
||||
t.Errorf("Received: %+v", reply)
|
||||
} else if reply[0].CGRID != "8ae63781b39f3265d014d2ba6a70437172fba46d" {
|
||||
t.Errorf("Expected: 8ae63781b39f3265d014d2ba6a70437172fba46d , received:%v", reply[0].CGRID)
|
||||
}
|
||||
}
|
||||
|
||||
func testDspCDRsPingNoAuth(t *testing.T) {
|
||||
var reply string
|
||||
if err := allEngine.RCP.Call(utils.CDRsV1Ping, new(utils.CGREvent), &reply); err != nil {
|
||||
t.Error(err)
|
||||
} else if reply != utils.Pong {
|
||||
t.Errorf("Received: %s", reply)
|
||||
}
|
||||
if err := dispEngine.RCP.Call(utils.CDRsV1Ping, &utils.CGREventWithArgDispatcher{
|
||||
CGREvent: &utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
},
|
||||
}, &reply); err != nil {
|
||||
t.Error(err)
|
||||
} else if reply != utils.Pong {
|
||||
t.Errorf("Received: %s", reply)
|
||||
}
|
||||
}
|
||||
|
||||
func testDspCDRsProcessEventNoAuth(t *testing.T) {
|
||||
var reply string
|
||||
args := &engine.ArgV1ProcessEvent{
|
||||
CGREvent: utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
Event: map[string]interface{}{
|
||||
utils.OriginID: "testDspCDRsProcessEvent",
|
||||
utils.OriginHost: "192.168.1.1",
|
||||
utils.Source: "testDspCDRsProcessEvent",
|
||||
utils.RequestType: utils.META_RATED,
|
||||
utils.Account: "1001",
|
||||
utils.Subject: "1001",
|
||||
utils.Destination: "1002",
|
||||
utils.AnswerTime: time.Date(2018, 8, 24, 16, 00, 26, 0, time.UTC),
|
||||
utils.Usage: time.Duration(1) * time.Minute,
|
||||
"field_extr1": "val_extr1",
|
||||
"fieldextr2": "valextr2",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
if err := dispEngine.RCP.Call(utils.CDRsV1ProcessEvent, args, &reply); err != nil {
|
||||
t.Error(err)
|
||||
} else if reply != utils.OK {
|
||||
t.Errorf("Received: %s", reply)
|
||||
}
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
}
|
||||
|
||||
func testDspCDRsCountCDRNoAuth(t *testing.T) {
|
||||
var reply int64
|
||||
args := &utils.RPCCDRsFilterWithArgDispatcher{
|
||||
RPCCDRsFilter: &utils.RPCCDRsFilter{
|
||||
Accounts: []string{"1001"},
|
||||
RunIDs: []string{utils.MetaDefault},
|
||||
},
|
||||
TenantArg: &utils.TenantArg{
|
||||
Tenant: "cgrates.org",
|
||||
},
|
||||
}
|
||||
|
||||
if err := dispEngine.RCP.Call(utils.CDRsV1CountCDRs, args, &reply); err != nil {
|
||||
t.Error(err)
|
||||
} else if reply != 1 {
|
||||
t.Errorf("Received: %+v", reply)
|
||||
}
|
||||
}
|
||||
|
||||
func testDspCDRsGetCDRNoAuth(t *testing.T) {
|
||||
var reply []*engine.CDR
|
||||
args := utils.RPCCDRsFilterWithArgDispatcher{
|
||||
RPCCDRsFilter: &utils.RPCCDRsFilter{
|
||||
Accounts: []string{"1001"},
|
||||
RunIDs: []string{utils.MetaDefault},
|
||||
},
|
||||
TenantArg: &utils.TenantArg{
|
||||
Tenant: "cgrates.org",
|
||||
},
|
||||
}
|
||||
|
||||
if err := dispEngine.RCP.Call(utils.CDRsV1GetCDRs, args, &reply); err != nil {
|
||||
t.Error(err)
|
||||
} else if len(reply) != 1 {
|
||||
t.Errorf("Received: %+v", reply)
|
||||
} else if reply[0].CGRID != "9ee4c71fcd67eef5fb25a4bb3f190487de3073f5" {
|
||||
t.Errorf("Expected: 9ee4c71fcd67eef5fb25a4bb3f190487de3073f5 , received:%v", reply[0].CGRID)
|
||||
}
|
||||
}
|
||||
|
||||
func testDspCDRsGetCDRNoAuthWithoutTenant(t *testing.T) {
|
||||
var reply []*engine.CDR
|
||||
args := utils.RPCCDRsFilterWithArgDispatcher{
|
||||
RPCCDRsFilter: &utils.RPCCDRsFilter{
|
||||
Accounts: []string{"1001"},
|
||||
RunIDs: []string{utils.MetaDefault},
|
||||
},
|
||||
}
|
||||
|
||||
if err := dispEngine.RCP.Call(utils.CDRsV1GetCDRs, args, &reply); err != nil {
|
||||
t.Error(err)
|
||||
} else if len(reply) != 1 {
|
||||
t.Errorf("Received: %+v", reply)
|
||||
} else if reply[0].CGRID != "9ee4c71fcd67eef5fb25a4bb3f190487de3073f5" {
|
||||
t.Errorf("Expected: 9ee4c71fcd67eef5fb25a4bb3f190487de3073f5 , received:%v", reply[0].CGRID)
|
||||
}
|
||||
}
|
||||
|
||||
func testDspCDRsProcessCDRNoAuth(t *testing.T) {
|
||||
var reply string
|
||||
args := &engine.CDRWithArgDispatcher{
|
||||
CDR: &engine.CDR{
|
||||
Tenant: "cgrates.org",
|
||||
OriginID: "testDspCDRsProcessCDR",
|
||||
OriginHost: "192.168.1.1",
|
||||
Source: "testDspCDRsProcessCDR",
|
||||
RequestType: utils.META_RATED,
|
||||
Account: "1001",
|
||||
Subject: "1001",
|
||||
Destination: "1002",
|
||||
AnswerTime: time.Date(2018, 8, 24, 16, 00, 26, 0, time.UTC),
|
||||
Usage: time.Duration(2) * time.Minute,
|
||||
},
|
||||
}
|
||||
if err := dispEngine.RCP.Call(utils.CDRsV1ProcessCDR, args, &reply); err != nil {
|
||||
t.Error(err)
|
||||
} else if reply != utils.OK {
|
||||
t.Errorf("Received: %s", reply)
|
||||
}
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
}
|
||||
|
||||
func testDspCDRsGetCDR2NoAuth(t *testing.T) {
|
||||
var reply []*engine.CDR
|
||||
args := utils.RPCCDRsFilterWithArgDispatcher{
|
||||
RPCCDRsFilter: &utils.RPCCDRsFilter{
|
||||
Accounts: []string{"1001"},
|
||||
RunIDs: []string{utils.MetaDefault},
|
||||
OriginIDs: []string{"testDspCDRsProcessCDR"},
|
||||
},
|
||||
TenantArg: &utils.TenantArg{
|
||||
Tenant: "cgrates.org",
|
||||
},
|
||||
}
|
||||
|
||||
if err := dispEngine.RCP.Call(utils.CDRsV1GetCDRs, args, &reply); err != nil {
|
||||
t.Error(err)
|
||||
} else if len(reply) != 1 {
|
||||
t.Errorf("Received: %+v", reply)
|
||||
} else if reply[0].CGRID != "f08dfd32930b6bea326bb8ec4e38ab03d781c0bf" {
|
||||
t.Errorf("Expected: f08dfd32930b6bea326bb8ec4e38ab03d781c0bf , received:%v", reply[0].CGRID)
|
||||
}
|
||||
}
|
||||
|
||||
func testDspCDRsProcessExternalCDRNoAuth(t *testing.T) {
|
||||
var reply string
|
||||
args := &engine.ExternalCDRWithArgDispatcher{
|
||||
ExternalCDR: &engine.ExternalCDR{
|
||||
ToR: utils.VOICE,
|
||||
OriginID: "testDspCDRsProcessExternalCDR",
|
||||
OriginHost: "127.0.0.1",
|
||||
Source: utils.UNIT_TEST,
|
||||
RequestType: utils.META_RATED,
|
||||
Tenant: "cgrates.org",
|
||||
Category: "call",
|
||||
Account: "1003",
|
||||
Subject: "1003",
|
||||
Destination: "1001",
|
||||
SetupTime: "2014-08-04T13:00:00Z",
|
||||
AnswerTime: "2014-08-04T13:00:07Z",
|
||||
Usage: "1s",
|
||||
ExtraFields: map[string]string{"field_extr1": "val_extr1", "fieldextr2": "valextr2"},
|
||||
},
|
||||
}
|
||||
if err := dispEngine.RCP.Call(utils.CDRsV1ProcessExternalCDR, args, &reply); err != nil {
|
||||
t.Error(err)
|
||||
} else if reply != utils.OK {
|
||||
t.Errorf("Received: %s", reply)
|
||||
}
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
}
|
||||
|
||||
func testDspCDRsGetCDR3NoAuth(t *testing.T) {
|
||||
var reply []*engine.CDR
|
||||
args := utils.RPCCDRsFilterWithArgDispatcher{
|
||||
RPCCDRsFilter: &utils.RPCCDRsFilter{
|
||||
Accounts: []string{"1003"},
|
||||
RunIDs: []string{utils.MetaDefault},
|
||||
OriginIDs: []string{"testDspCDRsProcessExternalCDR"},
|
||||
},
|
||||
TenantArg: &utils.TenantArg{
|
||||
Tenant: "cgrates.org",
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@@ -24,15 +24,15 @@ import (
|
||||
)
|
||||
|
||||
func (dS *DispatcherService) ChargerSv1Ping(args *utils.CGREventWithArgDispatcher, reply *string) (err error) {
|
||||
tnt := dS.cfg.GeneralCfg().DefaultTenant
|
||||
if args.CGREvent != nil && args.CGREvent.Tenant != utils.EmptyString {
|
||||
tnt = args.CGREvent.Tenant
|
||||
if args == nil {
|
||||
args = utils.NewCGREventWithArgDispatcher()
|
||||
}
|
||||
args.CGREvent.Tenant = utils.FirstNonEmpty(args.CGREvent.Tenant, dS.cfg.GeneralCfg().DefaultTenant)
|
||||
if dS.attrS != nil {
|
||||
if args.ArgDispatcher == nil {
|
||||
return utils.NewErrMandatoryIeMissing(utils.ArgDispatcherField)
|
||||
}
|
||||
if err = dS.authorize(utils.ChargerSv1Ping, tnt,
|
||||
if err = dS.authorize(utils.ChargerSv1Ping, args.CGREvent.Tenant,
|
||||
args.APIKey, args.Time); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -27,6 +27,9 @@ import (
|
||||
// GuardianSv1Ping interogates GuardianSv1 server responsible to process the event
|
||||
func (dS *DispatcherService) GuardianSv1Ping(args *utils.CGREventWithArgDispatcher,
|
||||
reply *string) (err error) {
|
||||
if args == nil {
|
||||
args = utils.NewCGREventWithArgDispatcher()
|
||||
}
|
||||
args.CGREvent.Tenant = utils.FirstNonEmpty(args.CGREvent.Tenant, dS.cfg.GeneralCfg().DefaultTenant)
|
||||
if dS.attrS != nil {
|
||||
if args.ArgDispatcher == nil {
|
||||
|
||||
@@ -40,6 +40,11 @@ func TestDspGuardianSTMySQL(t *testing.T) {
|
||||
|
||||
func testDspGrdPing(t *testing.T) {
|
||||
var reply string
|
||||
if err := allEngine.RCP.Call(utils.GuardianSv1Ping, nil, &reply); err != nil {
|
||||
t.Error(err)
|
||||
} else if reply != utils.Pong {
|
||||
t.Errorf("Received: %s", reply)
|
||||
}
|
||||
if err := allEngine.RCP.Call(utils.GuardianSv1Ping, new(utils.CGREvent), &reply); err != nil {
|
||||
t.Error(err)
|
||||
} else if reply != utils.Pong {
|
||||
|
||||
@@ -23,15 +23,15 @@ import (
|
||||
)
|
||||
|
||||
func (dS *DispatcherService) RALsV1Ping(args *utils.CGREventWithArgDispatcher, rpl *string) (err error) {
|
||||
tnt := dS.cfg.GeneralCfg().DefaultTenant
|
||||
if args.CGREvent != nil && args.CGREvent.Tenant != utils.EmptyString {
|
||||
tnt = args.CGREvent.Tenant
|
||||
if args == nil {
|
||||
args = utils.NewCGREventWithArgDispatcher()
|
||||
}
|
||||
args.CGREvent.Tenant = utils.FirstNonEmpty(args.CGREvent.Tenant, dS.cfg.GeneralCfg().DefaultTenant)
|
||||
if dS.attrS != nil {
|
||||
if args.ArgDispatcher == nil {
|
||||
return utils.NewErrMandatoryIeMissing(utils.ArgDispatcherField)
|
||||
}
|
||||
if err = dS.authorize(utils.RALsV1Ping, tnt,
|
||||
if err = dS.authorize(utils.RALsV1Ping, args.CGREvent.Tenant,
|
||||
args.APIKey, args.CGREvent.Time); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -24,15 +24,15 @@ import (
|
||||
)
|
||||
|
||||
func (dS *DispatcherService) ResourceSv1Ping(args *utils.CGREventWithArgDispatcher, rpl *string) (err error) {
|
||||
tnt := dS.cfg.GeneralCfg().DefaultTenant
|
||||
if args.CGREvent != nil && args.CGREvent.Tenant != utils.EmptyString {
|
||||
tnt = args.CGREvent.Tenant
|
||||
if args == nil {
|
||||
args = utils.NewCGREventWithArgDispatcher()
|
||||
}
|
||||
args.CGREvent.Tenant = utils.FirstNonEmpty(args.CGREvent.Tenant, dS.cfg.GeneralCfg().DefaultTenant)
|
||||
if dS.attrS != nil {
|
||||
if args.ArgDispatcher == nil {
|
||||
return utils.NewErrMandatoryIeMissing(utils.ArgDispatcherField)
|
||||
}
|
||||
if err = dS.authorize(utils.ResourceSv1Ping, tnt,
|
||||
if err = dS.authorize(utils.ResourceSv1Ping, args.CGREvent.Tenant,
|
||||
args.APIKey, args.CGREvent.Time); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -28,15 +28,15 @@ import (
|
||||
// ResponderPing interogates Responder server responsible to process the event
|
||||
func (dS *DispatcherService) ResponderPing(args *utils.CGREventWithArgDispatcher,
|
||||
reply *string) (err error) {
|
||||
tnt := dS.cfg.GeneralCfg().DefaultTenant
|
||||
if args.CGREvent != nil && args.CGREvent.Tenant != utils.EmptyString {
|
||||
tnt = args.CGREvent.Tenant
|
||||
if args == nil {
|
||||
args = utils.NewCGREventWithArgDispatcher()
|
||||
}
|
||||
args.CGREvent.Tenant = utils.FirstNonEmpty(args.CGREvent.Tenant, dS.cfg.GeneralCfg().DefaultTenant)
|
||||
if dS.attrS != nil {
|
||||
if args.ArgDispatcher == nil {
|
||||
return utils.NewErrMandatoryIeMissing(utils.ArgDispatcherField)
|
||||
}
|
||||
if err = dS.authorize(utils.ResponderPing, tnt,
|
||||
if err = dS.authorize(utils.ResponderPing, args.CGREvent.Tenant,
|
||||
args.APIKey, args.CGREvent.Time); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -23,6 +23,9 @@ import (
|
||||
)
|
||||
|
||||
func (dS *DispatcherService) SchedulerSv1Ping(args *utils.CGREventWithArgDispatcher, reply *string) (err error) {
|
||||
if args == nil {
|
||||
args = utils.NewCGREventWithArgDispatcher()
|
||||
}
|
||||
args.CGREvent.Tenant = utils.FirstNonEmpty(args.CGREvent.Tenant, dS.cfg.GeneralCfg().DefaultTenant)
|
||||
if dS.attrS != nil {
|
||||
if args.ArgDispatcher == nil {
|
||||
|
||||
@@ -27,6 +27,9 @@ import (
|
||||
// ServiceManagerV1Ping interogates ServiceManager server responsible to process the event
|
||||
func (dS *DispatcherService) ServiceManagerV1Ping(args *utils.CGREventWithArgDispatcher,
|
||||
reply *string) (err error) {
|
||||
if args == nil {
|
||||
args = utils.NewCGREventWithArgDispatcher()
|
||||
}
|
||||
args.CGREvent.Tenant = utils.FirstNonEmpty(args.CGREvent.Tenant, dS.cfg.GeneralCfg().DefaultTenant)
|
||||
if dS.attrS != nil {
|
||||
if args.ArgDispatcher == nil {
|
||||
|
||||
@@ -26,6 +26,10 @@ import (
|
||||
)
|
||||
|
||||
func (dS *DispatcherService) StatSv1Ping(args *utils.CGREventWithArgDispatcher, reply *string) (err error) {
|
||||
if args == nil {
|
||||
args = utils.NewCGREventWithArgDispatcher()
|
||||
}
|
||||
args.CGREvent.Tenant = utils.FirstNonEmpty(args.CGREvent.Tenant, dS.cfg.GeneralCfg().DefaultTenant)
|
||||
if dS.attrS != nil {
|
||||
if args.ArgDispatcher == nil {
|
||||
return utils.NewErrMandatoryIeMissing(utils.ArgDispatcherField)
|
||||
|
||||
@@ -24,6 +24,9 @@ import (
|
||||
)
|
||||
|
||||
func (dS *DispatcherService) SupplierSv1Ping(args *utils.CGREventWithArgDispatcher, reply *string) (err error) {
|
||||
if args == nil {
|
||||
args = utils.NewCGREventWithArgDispatcher()
|
||||
}
|
||||
args.CGREvent.Tenant = utils.FirstNonEmpty(args.CGREvent.Tenant, dS.cfg.GeneralCfg().DefaultTenant)
|
||||
if dS.attrS != nil {
|
||||
if args.ArgDispatcher == nil {
|
||||
|
||||
@@ -26,6 +26,9 @@ import (
|
||||
)
|
||||
|
||||
func (dS *DispatcherService) ThresholdSv1Ping(args *utils.CGREventWithArgDispatcher, reply *string) (err error) {
|
||||
if args == nil {
|
||||
args = utils.NewCGREventWithArgDispatcher()
|
||||
}
|
||||
args.CGREvent.Tenant = utils.FirstNonEmpty(args.CGREvent.Tenant, dS.cfg.GeneralCfg().DefaultTenant)
|
||||
if args.ArgDispatcher == nil {
|
||||
return utils.NewErrMandatoryIeMissing(utils.ArgDispatcherField)
|
||||
|
||||
@@ -628,45 +628,48 @@ type AttrGetCdrs struct {
|
||||
Paginator
|
||||
}
|
||||
|
||||
func (self *AttrGetCdrs) AsCDRsFilter(timezone string) (*CDRsFilter, error) {
|
||||
cdrFltr := &CDRsFilter{
|
||||
CGRIDs: self.CgrIds,
|
||||
RunIDs: self.MediationRunIds,
|
||||
ToRs: self.TORs,
|
||||
OriginHosts: self.CdrHosts,
|
||||
Sources: self.CdrSources,
|
||||
RequestTypes: self.ReqTypes,
|
||||
Tenants: self.Tenants,
|
||||
Categories: self.Categories,
|
||||
Accounts: self.Accounts,
|
||||
Subjects: self.Subjects,
|
||||
DestinationPrefixes: self.DestinationPrefixes,
|
||||
OrderIDStart: self.OrderIdStart,
|
||||
OrderIDEnd: self.OrderIdEnd,
|
||||
Paginator: self.Paginator,
|
||||
OrderBy: self.OrderBy,
|
||||
func (fltr *AttrGetCdrs) AsCDRsFilter(timezone string) (cdrFltr *CDRsFilter, err error) {
|
||||
if fltr == nil {
|
||||
return
|
||||
}
|
||||
if len(self.TimeStart) != 0 {
|
||||
if answerTimeStart, err := ParseTimeDetectLayout(self.TimeStart, timezone); err != nil {
|
||||
cdrFltr = &CDRsFilter{
|
||||
CGRIDs: fltr.CgrIds,
|
||||
RunIDs: fltr.MediationRunIds,
|
||||
ToRs: fltr.TORs,
|
||||
OriginHosts: fltr.CdrHosts,
|
||||
Sources: fltr.CdrSources,
|
||||
RequestTypes: fltr.ReqTypes,
|
||||
Tenants: fltr.Tenants,
|
||||
Categories: fltr.Categories,
|
||||
Accounts: fltr.Accounts,
|
||||
Subjects: fltr.Subjects,
|
||||
DestinationPrefixes: fltr.DestinationPrefixes,
|
||||
OrderIDStart: fltr.OrderIdStart,
|
||||
OrderIDEnd: fltr.OrderIdEnd,
|
||||
Paginator: fltr.Paginator,
|
||||
OrderBy: fltr.OrderBy,
|
||||
}
|
||||
if len(fltr.TimeStart) != 0 {
|
||||
if answerTimeStart, err := ParseTimeDetectLayout(fltr.TimeStart, timezone); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
cdrFltr.AnswerTimeStart = &answerTimeStart
|
||||
}
|
||||
}
|
||||
if len(self.TimeEnd) != 0 {
|
||||
if answerTimeEnd, err := ParseTimeDetectLayout(self.TimeEnd, timezone); err != nil {
|
||||
if len(fltr.TimeEnd) != 0 {
|
||||
if answerTimeEnd, err := ParseTimeDetectLayout(fltr.TimeEnd, timezone); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
cdrFltr.AnswerTimeEnd = &answerTimeEnd
|
||||
}
|
||||
}
|
||||
if self.SkipRated {
|
||||
if fltr.SkipRated {
|
||||
cdrFltr.MaxCost = Float64Pointer(-1.0)
|
||||
} else if self.SkipRated {
|
||||
} else if fltr.SkipRated {
|
||||
cdrFltr.MinCost = Float64Pointer(0.0)
|
||||
cdrFltr.MaxCost = Float64Pointer(-1.0)
|
||||
}
|
||||
return cdrFltr, nil
|
||||
return
|
||||
}
|
||||
|
||||
type AttrRemCdrs struct {
|
||||
@@ -835,102 +838,105 @@ type RPCCDRsFilter struct {
|
||||
Paginator // Add pagination
|
||||
}
|
||||
|
||||
func (self *RPCCDRsFilter) AsCDRsFilter(timezone string) (*CDRsFilter, error) {
|
||||
cdrFltr := &CDRsFilter{
|
||||
CGRIDs: self.CGRIDs,
|
||||
NotCGRIDs: self.NotCGRIDs,
|
||||
RunIDs: self.RunIDs,
|
||||
NotRunIDs: self.NotRunIDs,
|
||||
OriginIDs: self.OriginIDs,
|
||||
NotOriginIDs: self.NotOriginIDs,
|
||||
ToRs: self.ToRs,
|
||||
NotToRs: self.NotToRs,
|
||||
OriginHosts: self.OriginHosts,
|
||||
NotOriginHosts: self.NotOriginHosts,
|
||||
Sources: self.Sources,
|
||||
NotSources: self.NotSources,
|
||||
RequestTypes: self.RequestTypes,
|
||||
NotRequestTypes: self.NotRequestTypes,
|
||||
Tenants: self.Tenants,
|
||||
NotTenants: self.NotTenants,
|
||||
Categories: self.Categories,
|
||||
NotCategories: self.NotCategories,
|
||||
Accounts: self.Accounts,
|
||||
NotAccounts: self.NotAccounts,
|
||||
Subjects: self.Subjects,
|
||||
NotSubjects: self.NotSubjects,
|
||||
DestinationPrefixes: self.DestinationPrefixes,
|
||||
NotDestinationPrefixes: self.NotDestinationPrefixes,
|
||||
Costs: self.Costs,
|
||||
NotCosts: self.NotCosts,
|
||||
ExtraFields: self.ExtraFields,
|
||||
NotExtraFields: self.NotExtraFields,
|
||||
OrderIDStart: self.OrderIDStart,
|
||||
OrderIDEnd: self.OrderIDEnd,
|
||||
MinUsage: self.MinUsage,
|
||||
MaxUsage: self.MaxUsage,
|
||||
MinCost: self.MinCost,
|
||||
MaxCost: self.MaxCost,
|
||||
Paginator: self.Paginator,
|
||||
OrderBy: self.OrderBy,
|
||||
func (fltr *RPCCDRsFilter) AsCDRsFilter(timezone string) (cdrFltr *CDRsFilter, err error) {
|
||||
if fltr == nil {
|
||||
return
|
||||
}
|
||||
if len(self.SetupTimeStart) != 0 {
|
||||
if sTimeStart, err := ParseTimeDetectLayout(self.SetupTimeStart, timezone); err != nil {
|
||||
cdrFltr = &CDRsFilter{
|
||||
CGRIDs: fltr.CGRIDs,
|
||||
NotCGRIDs: fltr.NotCGRIDs,
|
||||
RunIDs: fltr.RunIDs,
|
||||
NotRunIDs: fltr.NotRunIDs,
|
||||
OriginIDs: fltr.OriginIDs,
|
||||
NotOriginIDs: fltr.NotOriginIDs,
|
||||
ToRs: fltr.ToRs,
|
||||
NotToRs: fltr.NotToRs,
|
||||
OriginHosts: fltr.OriginHosts,
|
||||
NotOriginHosts: fltr.NotOriginHosts,
|
||||
Sources: fltr.Sources,
|
||||
NotSources: fltr.NotSources,
|
||||
RequestTypes: fltr.RequestTypes,
|
||||
NotRequestTypes: fltr.NotRequestTypes,
|
||||
Tenants: fltr.Tenants,
|
||||
NotTenants: fltr.NotTenants,
|
||||
Categories: fltr.Categories,
|
||||
NotCategories: fltr.NotCategories,
|
||||
Accounts: fltr.Accounts,
|
||||
NotAccounts: fltr.NotAccounts,
|
||||
Subjects: fltr.Subjects,
|
||||
NotSubjects: fltr.NotSubjects,
|
||||
DestinationPrefixes: fltr.DestinationPrefixes,
|
||||
NotDestinationPrefixes: fltr.NotDestinationPrefixes,
|
||||
Costs: fltr.Costs,
|
||||
NotCosts: fltr.NotCosts,
|
||||
ExtraFields: fltr.ExtraFields,
|
||||
NotExtraFields: fltr.NotExtraFields,
|
||||
OrderIDStart: fltr.OrderIDStart,
|
||||
OrderIDEnd: fltr.OrderIDEnd,
|
||||
MinUsage: fltr.MinUsage,
|
||||
MaxUsage: fltr.MaxUsage,
|
||||
MinCost: fltr.MinCost,
|
||||
MaxCost: fltr.MaxCost,
|
||||
Paginator: fltr.Paginator,
|
||||
OrderBy: fltr.OrderBy,
|
||||
}
|
||||
if len(fltr.SetupTimeStart) != 0 {
|
||||
if sTimeStart, err := ParseTimeDetectLayout(fltr.SetupTimeStart, timezone); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
cdrFltr.SetupTimeStart = &sTimeStart
|
||||
}
|
||||
}
|
||||
if len(self.SetupTimeEnd) != 0 {
|
||||
if sTimeEnd, err := ParseTimeDetectLayout(self.SetupTimeEnd, timezone); err != nil {
|
||||
if len(fltr.SetupTimeEnd) != 0 {
|
||||
if sTimeEnd, err := ParseTimeDetectLayout(fltr.SetupTimeEnd, timezone); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
cdrFltr.SetupTimeEnd = &sTimeEnd
|
||||
}
|
||||
}
|
||||
if len(self.AnswerTimeStart) != 0 {
|
||||
if aTimeStart, err := ParseTimeDetectLayout(self.AnswerTimeStart, timezone); err != nil {
|
||||
if len(fltr.AnswerTimeStart) != 0 {
|
||||
if aTimeStart, err := ParseTimeDetectLayout(fltr.AnswerTimeStart, timezone); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
cdrFltr.AnswerTimeStart = &aTimeStart
|
||||
}
|
||||
}
|
||||
if len(self.AnswerTimeEnd) != 0 {
|
||||
if aTimeEnd, err := ParseTimeDetectLayout(self.AnswerTimeEnd, timezone); err != nil {
|
||||
if len(fltr.AnswerTimeEnd) != 0 {
|
||||
if aTimeEnd, err := ParseTimeDetectLayout(fltr.AnswerTimeEnd, timezone); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
cdrFltr.AnswerTimeEnd = &aTimeEnd
|
||||
}
|
||||
}
|
||||
if len(self.CreatedAtStart) != 0 {
|
||||
if tStart, err := ParseTimeDetectLayout(self.CreatedAtStart, timezone); err != nil {
|
||||
if len(fltr.CreatedAtStart) != 0 {
|
||||
if tStart, err := ParseTimeDetectLayout(fltr.CreatedAtStart, timezone); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
cdrFltr.CreatedAtStart = &tStart
|
||||
}
|
||||
}
|
||||
if len(self.CreatedAtEnd) != 0 {
|
||||
if tEnd, err := ParseTimeDetectLayout(self.CreatedAtEnd, timezone); err != nil {
|
||||
if len(fltr.CreatedAtEnd) != 0 {
|
||||
if tEnd, err := ParseTimeDetectLayout(fltr.CreatedAtEnd, timezone); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
cdrFltr.CreatedAtEnd = &tEnd
|
||||
}
|
||||
}
|
||||
if len(self.UpdatedAtStart) != 0 {
|
||||
if tStart, err := ParseTimeDetectLayout(self.UpdatedAtStart, timezone); err != nil {
|
||||
if len(fltr.UpdatedAtStart) != 0 {
|
||||
if tStart, err := ParseTimeDetectLayout(fltr.UpdatedAtStart, timezone); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
cdrFltr.UpdatedAtStart = &tStart
|
||||
}
|
||||
}
|
||||
if len(self.UpdatedAtEnd) != 0 {
|
||||
if tEnd, err := ParseTimeDetectLayout(self.UpdatedAtEnd, timezone); err != nil {
|
||||
if len(fltr.UpdatedAtEnd) != 0 {
|
||||
if tEnd, err := ParseTimeDetectLayout(fltr.UpdatedAtEnd, timezone); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
cdrFltr.UpdatedAtEnd = &tEnd
|
||||
}
|
||||
}
|
||||
return cdrFltr, nil
|
||||
return
|
||||
}
|
||||
|
||||
type AttrSetActions struct {
|
||||
@@ -1361,7 +1367,8 @@ func AppendToSMCostFilter(smcFilter *SMCostFilter, fieldType, fieldName string,
|
||||
|
||||
type RPCCDRsFilterWithArgDispatcher struct {
|
||||
*RPCCDRsFilter
|
||||
*TenantWithArgDispatcher
|
||||
*ArgDispatcher
|
||||
*TenantArg
|
||||
}
|
||||
|
||||
type ArgsGetCacheItemIDsWithArgDispatcher struct {
|
||||
|
||||
@@ -231,6 +231,10 @@ type CGREvents struct {
|
||||
Events []map[string]interface{}
|
||||
}
|
||||
|
||||
func NewCGREventWithArgDispatcher() *CGREventWithArgDispatcher {
|
||||
return new(CGREventWithArgDispatcher)
|
||||
}
|
||||
|
||||
type CGREventWithArgDispatcher struct {
|
||||
*CGREvent
|
||||
*ArgDispatcher
|
||||
|
||||
Reference in New Issue
Block a user