mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-21 23:28:44 +05:00
Add APIKey authentification
This commit is contained in:
committed by
Dan Christian Bogos
parent
3543d10e9c
commit
ebc419771d
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user