From 1703277205889c9b1245ec85dd19a4da71808d8b Mon Sep 17 00:00:00 2001 From: Anevo Date: Fri, 20 Apr 2018 05:24:24 -0400 Subject: [PATCH] Changed ping strings to lower case, added sessionSv1 commands to console. --- console/ping.go | 17 +++--- console/session_authorize_event.go | 70 +++++++++++++++++++++++++ console/session_initiate.go | 70 +++++++++++++++++++++++++ console/session_process_cdr.go | 70 +++++++++++++++++++++++++ console/session_process_event.go | 70 +++++++++++++++++++++++++ console/session_terminate.go | 70 +++++++++++++++++++++++++ console/session_update.go | 70 +++++++++++++++++++++++++ data/conf/samples/tutmysql/cgrates.json | 12 +++++ 8 files changed, 441 insertions(+), 8 deletions(-) create mode 100644 console/session_authorize_event.go create mode 100644 console/session_initiate.go create mode 100644 console/session_process_cdr.go create mode 100644 console/session_process_event.go create mode 100644 console/session_terminate.go create mode 100644 console/session_update.go diff --git a/console/ping.go b/console/ping.go index 68ce01348..8a7d64eb8 100644 --- a/console/ping.go +++ b/console/ping.go @@ -20,6 +20,7 @@ package console import ( "github.com/cgrates/cgrates/utils" + "strings" ) func init() { @@ -48,21 +49,21 @@ func (self *CmdApierPing) Name() string { func (self *CmdApierPing) RpcMethod() string { switch self.rpcParams.Item { - case utils.SupplierS: + case strings.ToLower(utils.SupplierS): return utils.SupplierSv1Ping - case utils.AttributeS: + case strings.ToLower(utils.AttributeS): return utils.AttributeSv1Ping - case utils.ResourceS: + case strings.ToLower(utils.ResourceS): return utils.ResourceSv1Ping - case utils.StatService: + case strings.ToLower(utils.StatService): return utils.StatSv1Ping - case utils.ThresholdS: + case strings.ToLower(utils.ThresholdS): return utils.ThresholdSv1Ping - case utils.SessionS: + case strings.ToLower(utils.SessionS): return utils.SessionSv1Ping - case utils.LoaderS: + case strings.ToLower(utils.LoaderS): return utils.LoaderSv1Ping - case utils.DispatcherS: + case strings.ToLower(utils.DispatcherS): return utils.DispatcherSv1Ping default: } diff --git a/console/session_authorize_event.go b/console/session_authorize_event.go new file mode 100644 index 000000000..422522b0f --- /dev/null +++ b/console/session_authorize_event.go @@ -0,0 +1,70 @@ +/* +Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments +Copyright (C) ITsysCOM GmbH + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see +*/ + +package console + +import ( + "time" + + "github.com/cgrates/cgrates/sessions" + "github.com/cgrates/cgrates/utils" +) + +func init() { + c := &CmdSessionsAuthorize{ + name: "session_authorize_event", + rpcMethod: utils.SessionSv1AuthorizeEventWithDigest, + rpcParams: &sessions.V1AuthorizeArgs{}, + } + commands[c.Name()] = c + c.CommandExecuter = &CommandExecuter{c} +} + +type CmdSessionsAuthorize struct { + name string + rpcMethod string + rpcParams *sessions.V1AuthorizeArgs + *CommandExecuter +} + +func (self *CmdSessionsAuthorize) Name() string { + return self.name +} + +func (self *CmdSessionsAuthorize) RpcMethod() string { + return self.rpcMethod +} + +func (self *CmdSessionsAuthorize) RpcParams(reset bool) interface{} { + if reset || self.rpcParams == nil { + self.rpcParams = &sessions.V1AuthorizeArgs{} + } + return self.rpcParams +} + +func (self *CmdSessionsAuthorize) PostprocessRpcParams() error { + if self.rpcParams.CGREvent.Time == nil { + self.rpcParams.CGREvent.Time = utils.TimePointer(time.Now()) + } + return nil +} + +func (self *CmdSessionsAuthorize) RpcResult() interface{} { + var atr *sessions.V1AuthorizeReplyWithDigest + return &atr +} diff --git a/console/session_initiate.go b/console/session_initiate.go new file mode 100644 index 000000000..ccc9cd7d4 --- /dev/null +++ b/console/session_initiate.go @@ -0,0 +1,70 @@ +/* +Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments +Copyright (C) ITsysCOM GmbH + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see +*/ + +package console + +import ( + "time" + + "github.com/cgrates/cgrates/sessions" + "github.com/cgrates/cgrates/utils" +) + +func init() { + c := &CmdSessionsInitiate{ + name: "session_initiate", + rpcMethod: utils.SessionSv1InitiateSession, + rpcParams: &sessions.V1InitSessionArgs{}, + } + commands[c.Name()] = c + c.CommandExecuter = &CommandExecuter{c} +} + +type CmdSessionsInitiate struct { + name string + rpcMethod string + rpcParams *sessions.V1InitSessionArgs + *CommandExecuter +} + +func (self *CmdSessionsInitiate) Name() string { + return self.name +} + +func (self *CmdSessionsInitiate) RpcMethod() string { + return self.rpcMethod +} + +func (self *CmdSessionsInitiate) RpcParams(reset bool) interface{} { + if reset || self.rpcParams == nil { + self.rpcParams = &sessions.V1InitSessionArgs{} + } + return self.rpcParams +} + +func (self *CmdSessionsInitiate) PostprocessRpcParams() error { + if self.rpcParams.CGREvent.Time == nil { + self.rpcParams.CGREvent.Time = utils.TimePointer(time.Now()) + } + return nil +} + +func (self *CmdSessionsInitiate) RpcResult() interface{} { + var atr *sessions.V1InitSessionReply + return &atr +} diff --git a/console/session_process_cdr.go b/console/session_process_cdr.go new file mode 100644 index 000000000..acfca886a --- /dev/null +++ b/console/session_process_cdr.go @@ -0,0 +1,70 @@ +/* +Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments +Copyright (C) ITsysCOM GmbH + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see +*/ + +package console + +import ( + "time" + + // "github.com/cgrates/cgrates/sessions" + "github.com/cgrates/cgrates/utils" +) + +func init() { + c := &CmdSessionsProcessCDR{ + name: "session_process_cdr", + rpcMethod: utils.SessionSv1ProcessCDR, + rpcParams: &utils.CGREvent{}, + } + commands[c.Name()] = c + c.CommandExecuter = &CommandExecuter{c} +} + +type CmdSessionsProcessCDR struct { + name string + rpcMethod string + rpcParams *utils.CGREvent + *CommandExecuter +} + +func (self *CmdSessionsProcessCDR) Name() string { + return self.name +} + +func (self *CmdSessionsProcessCDR) RpcMethod() string { + return self.rpcMethod +} + +func (self *CmdSessionsProcessCDR) RpcParams(reset bool) interface{} { + if reset || self.rpcParams == nil { + self.rpcParams = &utils.CGREvent{} + } + return self.rpcParams +} + +func (self *CmdSessionsProcessCDR) PostprocessRpcParams() error { + if self.rpcParams.Time == nil { + self.rpcParams.Time = utils.TimePointer(time.Now()) + } + return nil +} + +func (self *CmdSessionsProcessCDR) RpcResult() interface{} { + var atr *string + return &atr +} diff --git a/console/session_process_event.go b/console/session_process_event.go new file mode 100644 index 000000000..99bb4cf3d --- /dev/null +++ b/console/session_process_event.go @@ -0,0 +1,70 @@ +/* +Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments +Copyright (C) ITsysCOM GmbH + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see +*/ + +package console + +import ( + "time" + + "github.com/cgrates/cgrates/sessions" + "github.com/cgrates/cgrates/utils" +) + +func init() { + c := &CmdSessionsProcessEvent{ + name: "session_process_event", + rpcMethod: utils.SessionSv1ProcessEvent, + rpcParams: &sessions.V1ProcessEventArgs{}, + } + commands[c.Name()] = c + c.CommandExecuter = &CommandExecuter{c} +} + +type CmdSessionsProcessEvent struct { + name string + rpcMethod string + rpcParams *sessions.V1ProcessEventArgs + *CommandExecuter +} + +func (self *CmdSessionsProcessEvent) Name() string { + return self.name +} + +func (self *CmdSessionsProcessEvent) RpcMethod() string { + return self.rpcMethod +} + +func (self *CmdSessionsProcessEvent) RpcParams(reset bool) interface{} { + if reset || self.rpcParams == nil { + self.rpcParams = &sessions.V1ProcessEventArgs{} + } + return self.rpcParams +} + +func (self *CmdSessionsProcessEvent) PostprocessRpcParams() error { + if self.rpcParams.CGREvent.Time == nil { + self.rpcParams.CGREvent.Time = utils.TimePointer(time.Now()) + } + return nil +} + +func (self *CmdSessionsProcessEvent) RpcResult() interface{} { + var atr *sessions.V1ProcessEventReply + return &atr +} diff --git a/console/session_terminate.go b/console/session_terminate.go new file mode 100644 index 000000000..c6d3558fa --- /dev/null +++ b/console/session_terminate.go @@ -0,0 +1,70 @@ +/* +Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments +Copyright (C) ITsysCOM GmbH + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see +*/ + +package console + +import ( + "time" + + "github.com/cgrates/cgrates/sessions" + "github.com/cgrates/cgrates/utils" +) + +func init() { + c := &CmdSessionsTerminate{ + name: "session_terminate", + rpcMethod: utils.SessionSv1TerminateSession, + rpcParams: &sessions.V1TerminateSessionArgs{}, + } + commands[c.Name()] = c + c.CommandExecuter = &CommandExecuter{c} +} + +type CmdSessionsTerminate struct { + name string + rpcMethod string + rpcParams *sessions.V1TerminateSessionArgs + *CommandExecuter +} + +func (self *CmdSessionsTerminate) Name() string { + return self.name +} + +func (self *CmdSessionsTerminate) RpcMethod() string { + return self.rpcMethod +} + +func (self *CmdSessionsTerminate) RpcParams(reset bool) interface{} { + if reset || self.rpcParams == nil { + self.rpcParams = &sessions.V1TerminateSessionArgs{} + } + return self.rpcParams +} + +func (self *CmdSessionsTerminate) PostprocessRpcParams() error { + if self.rpcParams.CGREvent.Time == nil { + self.rpcParams.CGREvent.Time = utils.TimePointer(time.Now()) + } + return nil +} + +func (self *CmdSessionsTerminate) RpcResult() interface{} { + var atr *string + return &atr +} diff --git a/console/session_update.go b/console/session_update.go new file mode 100644 index 000000000..d9659dd48 --- /dev/null +++ b/console/session_update.go @@ -0,0 +1,70 @@ +/* +Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments +Copyright (C) ITsysCOM GmbH + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see +*/ + +package console + +import ( + "time" + + "github.com/cgrates/cgrates/sessions" + "github.com/cgrates/cgrates/utils" +) + +func init() { + c := &CmdSessionsUpdate{ + name: "session_update", + rpcMethod: utils.SessionSv1UpdateSession, + rpcParams: &sessions.V1UpdateSessionArgs{}, + } + commands[c.Name()] = c + c.CommandExecuter = &CommandExecuter{c} +} + +type CmdSessionsUpdate struct { + name string + rpcMethod string + rpcParams *sessions.V1UpdateSessionArgs + *CommandExecuter +} + +func (self *CmdSessionsUpdate) Name() string { + return self.name +} + +func (self *CmdSessionsUpdate) RpcMethod() string { + return self.rpcMethod +} + +func (self *CmdSessionsUpdate) RpcParams(reset bool) interface{} { + if reset || self.rpcParams == nil { + self.rpcParams = &sessions.V1UpdateSessionArgs{} + } + return self.rpcParams +} + +func (self *CmdSessionsUpdate) PostprocessRpcParams() error { + if self.rpcParams.CGREvent.Time == nil { + self.rpcParams.CGREvent.Time = utils.TimePointer(time.Now()) + } + return nil +} + +func (self *CmdSessionsUpdate) RpcResult() interface{} { + var atr *sessions.V1UpdateSessionReply + return &atr +} diff --git a/data/conf/samples/tutmysql/cgrates.json b/data/conf/samples/tutmysql/cgrates.json index c4c36ac74..580f0e983 100644 --- a/data/conf/samples/tutmysql/cgrates.json +++ b/data/conf/samples/tutmysql/cgrates.json @@ -292,6 +292,18 @@ "sessions": { "enabled": true, + "suppliers_conns": [ + {"address": "*internal"} + ], + "resources_conns": [ + {"address": "*internal"} + ], + "attributes_conns": [ + {"address": "*internal"} + ], + "rals_conns": [ + {"address": "*internal"} + ], },