mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Added more DispatcherService StatSv1
This commit is contained in:
committed by
Dan Christian Bogos
parent
b948114d1e
commit
5ecd996e2f
@@ -145,6 +145,16 @@ func (dSts *DispatcherStatSv1) GetQueueStringMetrics(args *dispatchers.TntIDWith
|
||||
return dSts.dS.StatSv1GetQueueStringMetrics(args, reply)
|
||||
}
|
||||
|
||||
func (dSts *DispatcherStatSv1) GetQueueFloatMetrics(args *dispatchers.TntIDWithApiKey,
|
||||
reply *map[string]float64) error {
|
||||
return dSts.dS.StatSv1GetQueueFloatMetrics(args, reply)
|
||||
}
|
||||
|
||||
func (dSts *DispatcherStatSv1) GetQueueIDs(args *dispatchers.TntWithApiKey,
|
||||
reply *[]string) error {
|
||||
return dSts.dS.StatSv1GetQueueIDs(args, reply)
|
||||
}
|
||||
|
||||
// GetQueueStringMetrics implements StatSv1ProcessEvent
|
||||
func (dSts *DispatcherStatSv1) ProcessEvent(args *dispatchers.ArgsStatProcessEventWithApiKey, reply *[]string) error {
|
||||
return dSts.dS.StatSv1ProcessEvent(args, reply)
|
||||
|
||||
@@ -5,7 +5,7 @@ cgrates.org,ATTR_API_ATTR_AUTH,*auth,*string:APIKey:attr12345,,APIMethods,*any,A
|
||||
cgrates.org,ATTR_API_CHRG_AUTH,*auth,*string:APIKey:chrg12345,,APIMethods,*any,ChargerSv1.Ping&ChargerSv1.GetChargersForEvent&ChargerSv1.ProcessEvent,true,false,20
|
||||
cgrates.org,ATTR_API_THR_AUTH,*auth,*string:APIKey:thr12345,,APIMethods,*any,ThresholdSv1.Ping&ThresholdSv1.GetThresholdsForEvent&ThresholdSv1.ProcessEvent&ThresholdSv1.GetThreshold&ThresholdSv1.GetThresholdIDs,true,false,20
|
||||
cgrates.org,ATTR_API_SUP_AUTH,*auth,*string:APIKey:sup12345,,APIMethods,*any,SupplierSv1.Ping&SupplierSv1.GetSuppliers,true,false,20
|
||||
cgrates.org,ATTR_API_STAT_AUTH,*auth,*string:APIKey:stat12345,,APIMethods,*any,StatSv1.Ping&StatSv1.GetStatQueuesForEvent&StatSv1.GetQueueStringMetrics&StatSv1.ProcessEvent,true,false,20
|
||||
cgrates.org,ATTR_API_STAT_AUTH,*auth,*string:APIKey:stat12345,,APIMethods,*any,StatSv1.Ping&StatSv1.GetStatQueuesForEvent&StatSv1.GetQueueStringMetrics&StatSv1.ProcessEvent&StatSv1.GetQueueIDs&StatSv1.GetQueueFloatMetrics,true,false,20
|
||||
cgrates.org,ATTR_API_RES_AUTH,*auth,*string:APIKey:res12345,,APIMethods,*any,ResourceSv1.Ping&ResourceSv1.GetResourcesForEvent,true,false,20
|
||||
cgrates.org,ATTR_API_SES_AUTH,*auth,*string:APIKey:ses12345,,APIMethods,*any,SessionSv1.Ping&SessionSv1.AuthorizeEventWithDigest&SessionSv1.InitiateSessionWithDigest&SessionSv1.UpdateSession&SessionSv1.TerminateSession&SessionSv1.ProcessCDR&SessionSv1.ProcessEvent,true,false,20
|
||||
|
||||
|
||||
|
@@ -77,3 +77,33 @@ func (dS *DispatcherService) StatSv1ProcessEvent(args *ArgsStatProcessEventWithA
|
||||
return dS.Dispatch(&args.CGREvent, utils.MetaStats, args.RouteID,
|
||||
utils.StatSv1ProcessEvent, args.StatsArgsProcessEvent, reply)
|
||||
}
|
||||
|
||||
func (dS *DispatcherService) StatSv1GetQueueFloatMetrics(args *TntIDWithApiKey,
|
||||
reply *map[string]float64) (err error) {
|
||||
if dS.attrS != nil {
|
||||
if err = dS.authorize(utils.StatSv1GetQueueFloatMetrics,
|
||||
args.TenantID.Tenant,
|
||||
args.APIKey, utils.TimePointer(time.Now())); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
return dS.Dispatch(&utils.CGREvent{
|
||||
Tenant: args.Tenant,
|
||||
ID: args.ID,
|
||||
}, utils.MetaStats, args.RouteID, utils.StatSv1GetQueueFloatMetrics,
|
||||
args.TenantID, reply)
|
||||
}
|
||||
|
||||
func (dS *DispatcherService) StatSv1GetQueueIDs(args *TntWithApiKey,
|
||||
reply *[]string) (err error) {
|
||||
if dS.attrS != nil {
|
||||
if err = dS.authorize(utils.StatSv1GetQueueIDs,
|
||||
args.TenantArg.Tenant,
|
||||
args.APIKey, utils.TimePointer(time.Now())); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
return dS.Dispatch(&utils.CGREvent{Tenant: args.Tenant},
|
||||
utils.MetaStats, args.RouteID, utils.StatSv1GetQueueIDs,
|
||||
args.TenantArg, reply)
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@ var sTestsDspSts = []func(t *testing.T){
|
||||
testDspStsPing,
|
||||
testDspStsTestAuthKey,
|
||||
testDspStsTestAuthKey2,
|
||||
testDspStsTestAuthKey3,
|
||||
}
|
||||
|
||||
//Test start here
|
||||
@@ -293,3 +294,45 @@ func testDspStsTestAuthKey2(t *testing.T) {
|
||||
t.Errorf("expecting: %+v, received reply: %s", expectedMetrics, metrics)
|
||||
}
|
||||
}
|
||||
|
||||
func testDspStsTestAuthKey3(t *testing.T) {
|
||||
var reply []string
|
||||
var metrics map[string]float64
|
||||
|
||||
args2 := TntIDWithApiKey{
|
||||
DispatcherResource: DispatcherResource{
|
||||
APIKey: "stat12345",
|
||||
},
|
||||
TenantID: utils.TenantID{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "Stats2",
|
||||
},
|
||||
}
|
||||
expectedMetrics := map[string]float64{
|
||||
utils.MetaTCC: 133,
|
||||
utils.MetaTCD: 180,
|
||||
}
|
||||
|
||||
if err := dispEngine.RCP.Call(utils.StatSv1GetQueueFloatMetrics,
|
||||
args2, &metrics); err != nil {
|
||||
t.Error(err)
|
||||
} else if !reflect.DeepEqual(expectedMetrics, metrics) {
|
||||
t.Errorf("expecting: %+v, received reply: %v", expectedMetrics, metrics)
|
||||
}
|
||||
|
||||
estats := []string{"Stats2", "Stats2_1"}
|
||||
if err := dispEngine.RCP.Call(utils.StatSv1GetQueueIDs,
|
||||
&TntWithApiKey{
|
||||
TenantArg: utils.TenantArg{
|
||||
Tenant: "cgrates.org",
|
||||
},
|
||||
DispatcherResource: DispatcherResource{
|
||||
APIKey: "stat12345",
|
||||
},
|
||||
}, &reply); err != nil {
|
||||
t.Error(err)
|
||||
} else if !reflect.DeepEqual(estats, reply) {
|
||||
t.Errorf("expecting: %+v, received reply: %v", estats, reply)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user