mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
SessionSv1.AuthorizeEventWithDigest API
This commit is contained in:
@@ -36,12 +36,13 @@ type SessionSv1 struct {
|
||||
// Publishes BiJSONRPC methods exported by SessionSv1
|
||||
func (ssv1 *SessionSv1) Handlers() map[string]interface{} {
|
||||
return map[string]interface{}{
|
||||
utils.SessionSv1AuthorizeEvent: ssv1.BiRpcAuthorizeEvent,
|
||||
utils.SessionSv1InitiateSession: ssv1.BiRpcInitiateSession,
|
||||
utils.SessionSv1UpdateSession: ssv1.BiRpcUpdateSession,
|
||||
utils.SessionSv1TerminateSession: ssv1.BiRpcTerminateSession,
|
||||
utils.SessionSv1ProcessCDR: ssv1.BiRpcProcessCDR,
|
||||
utils.SessionSv1ProcessEvent: ssv1.BiRpcProcessEvent,
|
||||
utils.SessionSv1AuthorizeEvent: ssv1.BiRpcAuthorizeEvent,
|
||||
utils.SessionSv1AuthorizeEventWithDigest: ssv1.BiRpcAuthorizeEventWithDigest,
|
||||
utils.SessionSv1InitiateSession: ssv1.BiRpcInitiateSession,
|
||||
utils.SessionSv1UpdateSession: ssv1.BiRpcUpdateSession,
|
||||
utils.SessionSv1TerminateSession: ssv1.BiRpcTerminateSession,
|
||||
utils.SessionSv1ProcessCDR: ssv1.BiRpcProcessCDR,
|
||||
utils.SessionSv1ProcessEvent: ssv1.BiRpcProcessEvent,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,6 +51,11 @@ func (ssv1 *SessionSv1) AuthorizeEvent(args *sessionmanager.V1AuthorizeArgs,
|
||||
return ssv1.SMG.BiRPCv1AuthorizeEvent(nil, args, rply)
|
||||
}
|
||||
|
||||
func (ssv1 *SessionSv1) AuthorizeEventWithDigest(args *sessionmanager.V1AuthorizeArgs,
|
||||
rply *sessionmanager.V1AuthorizeReplyWithDigest) error {
|
||||
return ssv1.SMG.BiRPCv1AuthorizeEventWithDigest(nil, args, rply)
|
||||
}
|
||||
|
||||
func (ssv1 *SessionSv1) InitiateSession(args *sessionmanager.V1InitSessionArgs,
|
||||
rply *sessionmanager.V1InitSessionReply) error {
|
||||
return ssv1.SMG.BiRPCv1InitiateSession(nil, args, rply)
|
||||
@@ -79,6 +85,11 @@ func (ssv1 *SessionSv1) BiRpcAuthorizeEvent(clnt *rpc2.Client, args *sessionmana
|
||||
return ssv1.SMG.BiRPCv1AuthorizeEvent(clnt, args, rply)
|
||||
}
|
||||
|
||||
func (ssv1 *SessionSv1) BiRpcAuthorizeEventWithDigest(clnt *rpc2.Client, args *sessionmanager.V1AuthorizeArgs,
|
||||
rply *sessionmanager.V1AuthorizeReplyWithDigest) error {
|
||||
return ssv1.SMG.BiRPCv1AuthorizeEventWithDigest(clnt, args, rply)
|
||||
}
|
||||
|
||||
func (ssv1 *SessionSv1) BiRpcInitiateSession(clnt *rpc2.Client, args *sessionmanager.V1InitSessionArgs,
|
||||
rply *sessionmanager.V1InitSessionReply) error {
|
||||
return ssv1.SMG.BiRPCv1InitiateSession(clnt, args, rply)
|
||||
|
||||
@@ -1371,6 +1371,36 @@ func (smg *SMGeneric) BiRPCv1AuthorizeEvent(clnt rpcclient.RpcClientConnection,
|
||||
return nil
|
||||
}
|
||||
|
||||
type V1AuthorizeReplyWithDigest struct {
|
||||
AttributesDigest *string
|
||||
ResourceAllocation *string
|
||||
MaxUsage *time.Duration
|
||||
SuppliersDigest *string
|
||||
}
|
||||
|
||||
// BiRPCv1AuthorizeEventWithDigest performs authorization for CGREvent based on specific components
|
||||
// returning one level fields instead of multiple ones returned by BiRPCv1AuthorizeEvent
|
||||
func (smg *SMGeneric) BiRPCv1AuthorizeEventWithDigest(clnt rpcclient.RpcClientConnection,
|
||||
args *V1AuthorizeArgs, authReply *V1AuthorizeReplyWithDigest) (err error) {
|
||||
var initAuthRply V1AuthorizeReply
|
||||
if err = smg.BiRPCv1AuthorizeEvent(clnt, args, &initAuthRply); err != nil {
|
||||
return
|
||||
}
|
||||
if args.GetAttributes {
|
||||
authReply.AttributesDigest = utils.StringPointer(initAuthRply.Attributes.Digest())
|
||||
}
|
||||
if args.AuthorizeResources {
|
||||
authReply.ResourceAllocation = initAuthRply.ResourceAllocation
|
||||
}
|
||||
if args.GetMaxUsage {
|
||||
authReply.MaxUsage = initAuthRply.MaxUsage
|
||||
}
|
||||
if args.GetSuppliers {
|
||||
authReply.SuppliersDigest = utils.StringPointer(initAuthRply.Suppliers.Digest())
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type V1InitSessionArgs struct {
|
||||
GetAttributes bool
|
||||
AllocateResources bool
|
||||
|
||||
@@ -595,16 +595,17 @@ const (
|
||||
|
||||
//SessionS APIs
|
||||
const (
|
||||
SessionSv1AuthorizeEvent = "SessionSv1.AuthorizeEvent"
|
||||
SessionSv1InitiateSession = "SessionSv1.InitiateSession"
|
||||
SessionSv1UpdateSession = "SessionSv1.UpdateSession"
|
||||
SessionSv1TerminateSession = "SessionSv1.TerminateSession"
|
||||
SessionSv1ProcessCDR = "SessionSv1.ProcessCDR"
|
||||
SessionSv1ProcessEvent = "SessionSv1.ProcessEvent"
|
||||
SessionSv1DisconnectSession = "SessionSv1.DisconnectSession"
|
||||
SMGenericV1InitiateSession = "SMGenericV1.InitiateSession"
|
||||
SMGenericV2InitiateSession = "SMGenericV2.InitiateSession"
|
||||
SMGenericV2UpdateSession = "SMGenericV2.UpdateSession"
|
||||
SessionSv1AuthorizeEvent = "SessionSv1.AuthorizeEvent"
|
||||
SessionSv1AuthorizeEventWithDigest = "SessionSv1.AuthorizeEventWithDigest"
|
||||
SessionSv1InitiateSession = "SessionSv1.InitiateSession"
|
||||
SessionSv1UpdateSession = "SessionSv1.UpdateSession"
|
||||
SessionSv1TerminateSession = "SessionSv1.TerminateSession"
|
||||
SessionSv1ProcessCDR = "SessionSv1.ProcessCDR"
|
||||
SessionSv1ProcessEvent = "SessionSv1.ProcessEvent"
|
||||
SessionSv1DisconnectSession = "SessionSv1.DisconnectSession"
|
||||
SMGenericV1InitiateSession = "SMGenericV1.InitiateSession"
|
||||
SMGenericV2InitiateSession = "SMGenericV2.InitiateSession"
|
||||
SMGenericV2UpdateSession = "SMGenericV2.UpdateSession"
|
||||
)
|
||||
|
||||
//CSV file name
|
||||
|
||||
Reference in New Issue
Block a user