mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Added new SessionSv1 methods in Dispatcher
This commit is contained in:
committed by
Dan Christian Bogos
parent
c65fc66407
commit
3e99bc3ad4
@@ -327,3 +327,38 @@ func (dS *DispatcherSessionSv1) UpdateSession(args *dispatchers.UpdateSessionWit
|
||||
reply *sessions.V1UpdateSessionReply) (err error) {
|
||||
return dS.dS.SessionSv1UpdateSession(args, reply)
|
||||
}
|
||||
|
||||
func (dS *DispatcherSessionSv1) GetActiveSessions(args *dispatchers.FilterSessionWithApiKey,
|
||||
reply *[]*sessions.ActiveSession) (err error) {
|
||||
return dS.dS.SessionSv1GetActiveSessions(args, reply)
|
||||
}
|
||||
|
||||
func (dS *DispatcherSessionSv1) GetActiveSessionsCount(args *dispatchers.FilterSessionWithApiKey,
|
||||
reply *int) (err error) {
|
||||
return dS.dS.SessionSv1GetActiveSessionsCount(args, reply)
|
||||
}
|
||||
|
||||
func (dS *DispatcherSessionSv1) ForceDisconnect(args *dispatchers.FilterSessionWithApiKey,
|
||||
reply *string) (err error) {
|
||||
return dS.dS.SessionSv1ForceDisconnect(args, reply)
|
||||
}
|
||||
|
||||
func (dS *DispatcherSessionSv1) GetPassiveSessions(args *dispatchers.FilterSessionWithApiKey,
|
||||
reply *[]*sessions.ActiveSession) (err error) {
|
||||
return dS.dS.SessionSv1GetPassiveSessions(args, reply)
|
||||
}
|
||||
|
||||
func (dS *DispatcherSessionSv1) GetPassiveSessionsCount(args *dispatchers.FilterSessionWithApiKey,
|
||||
reply *int) (err error) {
|
||||
return dS.dS.SessionSv1GetPassiveSessionsCount(args, reply)
|
||||
}
|
||||
|
||||
func (dS *DispatcherSessionSv1) ReplicateSessions(args *dispatchers.ArgsReplicateSessionsWithApiKey,
|
||||
reply *string) (err error) {
|
||||
return dS.dS.SessionSv1ReplicateSessions(args, reply)
|
||||
}
|
||||
|
||||
func (dS *DispatcherSessionSv1) SetPassiveSession(args *dispatchers.SessionWithApiKey,
|
||||
reply *string) (err error) {
|
||||
return dS.dS.SessionSv1SetPassiveSession(args, reply)
|
||||
}
|
||||
|
||||
@@ -7,5 +7,5 @@ cgrates.org,ATTR_API_THR_AUTH,*auth,*string:APIKey:thr12345,,APIMethods,*any,Thr
|
||||
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&StatSv1.GetQueueIDs&StatSv1.GetQueueFloatMetrics,true,false,20
|
||||
cgrates.org,ATTR_API_RES_AUTH,*auth,*string:APIKey:res12345,,APIMethods,*any,ResourceSv1.Ping&ResourceSv1.GetResourcesForEvent&ResourceSv1.AuthorizeResources&ResourceSv1.AllocateResources&ResourceSv1.ReleaseResources,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
|
||||
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&SessionSv1.GetActiveSessions&SessionSv1.GetActiveSessionsCount&SessionSv1.ForceDisconnect&SessionSv1.GetPassiveSessions&SessionSv1.GetPassiveSessionsCount&SessionSv1.SetPassiveSession&SessionSv1.ReplicateSessions,true,false,20
|
||||
|
||||
|
||||
|
@@ -153,3 +153,94 @@ func (dS *DispatcherService) SessionSv1ProcessEvent(args *ProcessEventWithApiKey
|
||||
return dS.Dispatch(&args.CGREvent, utils.MetaSessionS, args.RouteID,
|
||||
utils.SessionSv1ProcessEvent, args.V1ProcessEventArgs, reply)
|
||||
}
|
||||
|
||||
func (dS *DispatcherService) SessionSv1GetActiveSessions(args *FilterSessionWithApiKey,
|
||||
reply *[]*sessions.ActiveSession) (err error) {
|
||||
if dS.attrS != nil {
|
||||
if err = dS.authorize(utils.SessionSv1GetActiveSessions,
|
||||
args.TenantArg.Tenant,
|
||||
args.APIKey, utils.TimePointer(time.Now())); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
return dS.Dispatch(&utils.CGREvent{Tenant: args.TenantArg.Tenant}, utils.MetaSessionS, args.RouteID,
|
||||
utils.SessionSv1GetActiveSessions, args.Filters, reply)
|
||||
}
|
||||
|
||||
func (dS *DispatcherService) SessionSv1GetActiveSessionsCount(args *FilterSessionWithApiKey,
|
||||
reply *int) (err error) {
|
||||
if dS.attrS != nil {
|
||||
if err = dS.authorize(utils.SessionSv1GetActiveSessionsCount,
|
||||
args.TenantArg.Tenant,
|
||||
args.APIKey, utils.TimePointer(time.Now())); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
return dS.Dispatch(&utils.CGREvent{Tenant: args.TenantArg.Tenant}, utils.MetaSessionS, args.RouteID,
|
||||
utils.SessionSv1GetActiveSessionsCount, args.Filters, reply)
|
||||
}
|
||||
|
||||
func (dS *DispatcherService) SessionSv1ForceDisconnect(args *FilterSessionWithApiKey,
|
||||
reply *string) (err error) {
|
||||
if dS.attrS != nil {
|
||||
if err = dS.authorize(utils.SessionSv1ForceDisconnect,
|
||||
args.TenantArg.Tenant,
|
||||
args.APIKey, utils.TimePointer(time.Now())); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
return dS.Dispatch(&utils.CGREvent{Tenant: args.TenantArg.Tenant}, utils.MetaSessionS, args.RouteID,
|
||||
utils.SessionSv1ForceDisconnect, args.Filters, reply)
|
||||
}
|
||||
|
||||
func (dS *DispatcherService) SessionSv1GetPassiveSessions(args *FilterSessionWithApiKey,
|
||||
reply *[]*sessions.ActiveSession) (err error) {
|
||||
if dS.attrS != nil {
|
||||
if err = dS.authorize(utils.SessionSv1GetPassiveSessions,
|
||||
args.TenantArg.Tenant,
|
||||
args.APIKey, utils.TimePointer(time.Now())); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
return dS.Dispatch(&utils.CGREvent{Tenant: args.TenantArg.Tenant}, utils.MetaSessionS, args.RouteID,
|
||||
utils.SessionSv1GetPassiveSessions, args.Filters, reply)
|
||||
}
|
||||
|
||||
func (dS *DispatcherService) SessionSv1GetPassiveSessionsCount(args *FilterSessionWithApiKey,
|
||||
reply *int) (err error) {
|
||||
if dS.attrS != nil {
|
||||
if err = dS.authorize(utils.SessionSv1GetPassiveSessionsCount,
|
||||
args.TenantArg.Tenant,
|
||||
args.APIKey, utils.TimePointer(time.Now())); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
return dS.Dispatch(&utils.CGREvent{Tenant: args.TenantArg.Tenant}, utils.MetaSessionS, args.RouteID,
|
||||
utils.SessionSv1GetPassiveSessionsCount, args.Filters, reply)
|
||||
}
|
||||
|
||||
func (dS *DispatcherService) SessionSv1ReplicateSessions(args *ArgsReplicateSessionsWithApiKey,
|
||||
reply *string) (err error) {
|
||||
if dS.attrS != nil {
|
||||
if err = dS.authorize(utils.SessionSv1ReplicateSessions,
|
||||
args.TenantArg.Tenant,
|
||||
args.APIKey, utils.TimePointer(time.Now())); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
return dS.Dispatch(&utils.CGREvent{Tenant: args.TenantArg.Tenant}, utils.MetaSessionS, args.RouteID,
|
||||
utils.SessionSv1ReplicateSessions, args.ArgsReplicateSessions, reply)
|
||||
}
|
||||
|
||||
func (dS *DispatcherService) SessionSv1SetPassiveSession(args *SessionWithApiKey,
|
||||
reply *string) (err error) {
|
||||
if dS.attrS != nil {
|
||||
if err = dS.authorize(utils.SessionSv1SetPassiveSession,
|
||||
args.Session.Tenant,
|
||||
args.APIKey, utils.TimePointer(time.Now())); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
return dS.Dispatch(&utils.CGREvent{Tenant: args.Session.Tenant}, utils.MetaSessionS, args.RouteID,
|
||||
utils.SessionSv1SetPassiveSession, args.Session, reply)
|
||||
}
|
||||
|
||||
@@ -103,6 +103,23 @@ type UpdateSessionWithApiKey struct {
|
||||
sessions.V1UpdateSessionArgs
|
||||
}
|
||||
|
||||
type FilterSessionWithApiKey struct {
|
||||
DispatcherResource
|
||||
utils.TenantArg
|
||||
Filters map[string]string
|
||||
}
|
||||
|
||||
type ArgsReplicateSessionsWithApiKey struct {
|
||||
DispatcherResource
|
||||
utils.TenantArg
|
||||
sessions.ArgsReplicateSessions
|
||||
}
|
||||
|
||||
type SessionWithApiKey struct {
|
||||
DispatcherResource
|
||||
sessions.Session
|
||||
}
|
||||
|
||||
func ParseStringMap(s string) utils.StringMap {
|
||||
if s == utils.ZERO {
|
||||
return make(utils.StringMap)
|
||||
|
||||
Reference in New Issue
Block a user