Add APIKey authentification

This commit is contained in:
TeoV
2018-06-06 10:00:02 -04:00
committed by Dan Christian Bogos
parent 3543d10e9c
commit ebc419771d
22 changed files with 604 additions and 190 deletions

View File

@@ -21,6 +21,7 @@ package console
import (
"time"
"github.com/cgrates/cgrates/dispatcher"
"github.com/cgrates/cgrates/engine"
"github.com/cgrates/cgrates/utils"
)
@@ -29,7 +30,7 @@ func init() {
c := &CmdGetResourceForEvent{
name: "resources_for_event",
rpcMethod: utils.ResourceSv1GetResourcesForEvent,
rpcParams: &utils.ArgRSv1ResourceUsage{},
rpcParams: &dispatcher.ArgsV1ResUsageWithApiKey{},
}
commands[c.Name()] = c
c.CommandExecuter = &CommandExecuter{c}
@@ -39,7 +40,7 @@ func init() {
type CmdGetResourceForEvent struct {
name string
rpcMethod string
rpcParams *utils.ArgRSv1ResourceUsage
rpcParams *dispatcher.ArgsV1ResUsageWithApiKey
*CommandExecuter
}
@@ -53,7 +54,7 @@ func (self *CmdGetResourceForEvent) RpcMethod() string {
func (self *CmdGetResourceForEvent) RpcParams(reset bool) interface{} {
if reset || self.rpcParams == nil {
self.rpcParams = &utils.ArgRSv1ResourceUsage{}
self.rpcParams = &dispatcher.ArgsV1ResUsageWithApiKey{}
}
return self.rpcParams
}

View File

@@ -19,6 +19,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
package console
import (
"time"
"github.com/cgrates/cgrates/dispatcher"
"github.com/cgrates/cgrates/utils"
)
@@ -26,7 +29,7 @@ func init() {
c := &CmdStatsQueueForEvent{
name: "stats_for_event",
rpcMethod: utils.StatSv1GetStatQueuesForEvent,
rpcParams: &utils.CGREvent{},
rpcParams: &dispatcher.CGREvWithApiKey{},
}
commands[c.Name()] = c
c.CommandExecuter = &CommandExecuter{c}
@@ -36,7 +39,7 @@ func init() {
type CmdStatsQueueForEvent struct {
name string
rpcMethod string
rpcParams *utils.CGREvent
rpcParams *dispatcher.CGREvWithApiKey
*CommandExecuter
}
@@ -50,12 +53,15 @@ func (self *CmdStatsQueueForEvent) RpcMethod() string {
func (self *CmdStatsQueueForEvent) RpcParams(reset bool) interface{} {
if reset || self.rpcParams == nil {
self.rpcParams = &utils.CGREvent{}
self.rpcParams = &dispatcher.CGREvWithApiKey{}
}
return self.rpcParams
}
func (self *CmdStatsQueueForEvent) PostprocessRpcParams() error {
if self.rpcParams.Time == nil {
self.rpcParams.Time = utils.TimePointer(time.Now())
}
return nil
}

View File

@@ -19,6 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
package console
import (
"github.com/cgrates/cgrates/dispatcher"
"github.com/cgrates/cgrates/utils"
)
@@ -26,7 +27,7 @@ func init() {
c := &CmdGetStatQueueStringMetrics{
name: "stats_metrics",
rpcMethod: utils.StatSv1GetQueueStringMetrics,
rpcParams: &utils.TenantID{},
rpcParams: &dispatcher.TntIDWithApiKey{},
}
commands[c.Name()] = c
c.CommandExecuter = &CommandExecuter{c}
@@ -36,7 +37,7 @@ func init() {
type CmdGetStatQueueStringMetrics struct {
name string
rpcMethod string
rpcParams *utils.TenantID
rpcParams *dispatcher.TntIDWithApiKey
*CommandExecuter
}
@@ -50,7 +51,7 @@ func (self *CmdGetStatQueueStringMetrics) RpcMethod() string {
func (self *CmdGetStatQueueStringMetrics) RpcParams(reset bool) interface{} {
if reset || self.rpcParams == nil {
self.rpcParams = &utils.TenantID{}
self.rpcParams = &dispatcher.TntIDWithApiKey{}
}
return self.rpcParams
}

View File

@@ -21,6 +21,7 @@ package console
import (
"time"
"github.com/cgrates/cgrates/dispatcher"
"github.com/cgrates/cgrates/utils"
)
@@ -28,7 +29,7 @@ func init() {
c := &CmdStatQueueProcessEvent{
name: "stats_process_event",
rpcMethod: utils.StatSv1ProcessEvent,
rpcParams: &utils.CGREvent{},
rpcParams: &dispatcher.CGREvWithApiKey{},
}
commands[c.Name()] = c
c.CommandExecuter = &CommandExecuter{c}
@@ -38,7 +39,7 @@ func init() {
type CmdStatQueueProcessEvent struct {
name string
rpcMethod string
rpcParams *utils.CGREvent
rpcParams *dispatcher.CGREvWithApiKey
*CommandExecuter
}
@@ -52,7 +53,7 @@ func (self *CmdStatQueueProcessEvent) RpcMethod() string {
func (self *CmdStatQueueProcessEvent) RpcParams(reset bool) interface{} {
if reset || self.rpcParams == nil {
self.rpcParams = &utils.CGREvent{}
self.rpcParams = &dispatcher.CGREvWithApiKey{}
}
return self.rpcParams
}

View File

@@ -19,15 +19,18 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
package console
import (
"github.com/cgrates/cgrates/dispatcher"
"github.com/cgrates/cgrates/engine"
"github.com/cgrates/cgrates/utils"
)
//
func init() {
c := &CmdThresholdsForEvent{
name: "thresholds_for_event",
rpcMethod: utils.ThresholdSv1GetThresholdsForEvent,
rpcParams: &engine.ArgsProcessEvent{},
rpcParams: &dispatcher.ArgsProcessEventWithApiKey{},
}
commands[c.Name()] = c
c.CommandExecuter = &CommandExecuter{c}
@@ -36,7 +39,7 @@ func init() {
type CmdThresholdsForEvent struct {
name string
rpcMethod string
rpcParams *engine.ArgsProcessEvent
rpcParams *dispatcher.ArgsProcessEventWithApiKey
*CommandExecuter
}
@@ -50,7 +53,7 @@ func (self *CmdThresholdsForEvent) RpcMethod() string {
func (self *CmdThresholdsForEvent) RpcParams(reset bool) interface{} {
if reset || self.rpcParams == nil {
self.rpcParams = &engine.ArgsProcessEvent{}
self.rpcParams = &dispatcher.ArgsProcessEventWithApiKey{}
}
return self.rpcParams
}

View File

@@ -21,7 +21,7 @@ package console
import (
"time"
"github.com/cgrates/cgrates/engine"
"github.com/cgrates/cgrates/dispatcher"
"github.com/cgrates/cgrates/utils"
)
@@ -29,7 +29,7 @@ func init() {
c := &CmdThresholdProcessEvent{
name: "thresholds_process_event",
rpcMethod: utils.ThresholdSv1ProcessEvent,
rpcParams: new(engine.ArgsProcessEvent),
rpcParams: &dispatcher.ArgsProcessEventWithApiKey{},
}
commands[c.Name()] = c
c.CommandExecuter = &CommandExecuter{c}
@@ -38,7 +38,7 @@ func init() {
type CmdThresholdProcessEvent struct {
name string
rpcMethod string
rpcParams *engine.ArgsProcessEvent
rpcParams *dispatcher.ArgsProcessEventWithApiKey
*CommandExecuter
}
@@ -52,7 +52,7 @@ func (self *CmdThresholdProcessEvent) RpcMethod() string {
func (self *CmdThresholdProcessEvent) RpcParams(reset bool) interface{} {
if reset || self.rpcParams == nil {
self.rpcParams = &engine.ArgsProcessEvent{}
self.rpcParams = &dispatcher.ArgsProcessEventWithApiKey{}
}
return self.rpcParams
}