Adding cgr-console stats related APIs

This commit is contained in:
edwardro22
2017-12-15 09:14:24 +02:00
committed by Dan Christian Bogos
parent 787cc55d15
commit d8418b8a56
5 changed files with 169 additions and 14 deletions

View File

@@ -20,11 +20,12 @@ package console
import (
"github.com/cgrates/cgrates/config"
"github.com/cgrates/cgrates/engine"
"github.com/cgrates/cgrates/utils"
)
func init() {
c := &CmdAttributesProcessEvent{
c := &CmdGetAttributeForEvent{
name: "get_attribute_for_event",
rpcMethod: "AttributeSv1.GetAttributeForEvent",
}
@@ -33,22 +34,22 @@ func init() {
}
// Commander implementation
type CmdAttributesProcessEvent struct {
type CmdGetAttributeForEvent struct {
name string
rpcMethod string
rpcParams interface{}
*CommandExecuter
}
func (self *CmdAttributesProcessEvent) Name() string {
func (self *CmdGetAttributeForEvent) Name() string {
return self.name
}
func (self *CmdAttributesProcessEvent) RpcMethod() string {
func (self *CmdGetAttributeForEvent) RpcMethod() string {
return self.rpcMethod
}
func (self *CmdAttributesProcessEvent) RpcParams(reset bool) interface{} {
func (self *CmdGetAttributeForEvent) RpcParams(reset bool) interface{} {
if reset || self.rpcParams == nil {
mp := make(map[string]interface{})
self.rpcParams = &mp
@@ -56,7 +57,7 @@ func (self *CmdAttributesProcessEvent) RpcParams(reset bool) interface{} {
return self.rpcParams
}
func (self *CmdAttributesProcessEvent) PostprocessRpcParams() error { //utils.CGREvent
func (self *CmdGetAttributeForEvent) PostprocessRpcParams() error { //utils.CGREvent
param := self.rpcParams.(*map[string]interface{})
cgrev := utils.CGREvent{
Tenant: config.CgrConfig().DefaultTenant,
@@ -70,7 +71,7 @@ func (self *CmdAttributesProcessEvent) PostprocessRpcParams() error { //utils.CG
return nil
}
func (self *CmdAttributesProcessEvent) RpcResult() interface{} {
func (self *CmdGetAttributeForEvent) RpcResult() interface{} {
atr := engine.ExternalAttributeProfile{}
return &atr
}

View File

@@ -20,6 +20,7 @@ package console
import (
"github.com/cgrates/cgrates/config"
"github.com/cgrates/cgrates/engine"
"github.com/cgrates/cgrates/utils"
)

View File

@@ -21,7 +21,7 @@ package console
import "github.com/cgrates/cgrates/engine"
func init() {
c := &CmdSetResource{
c := &CmdSetAttributes{
name: "attributes_set",
rpcMethod: "ApierV1.SetAttributeProfile",
rpcParams: &engine.ExternalAttributeProfile{},
@@ -31,33 +31,33 @@ func init() {
}
// Commander implementation
type CmdSetResource struct {
type CmdSetAttributes struct {
name string
rpcMethod string
rpcParams *engine.ExternalAttributeProfile
*CommandExecuter
}
func (self *CmdSetResource) Name() string {
func (self *CmdSetAttributes) Name() string {
return self.name
}
func (self *CmdSetResource) RpcMethod() string {
func (self *CmdSetAttributes) RpcMethod() string {
return self.rpcMethod
}
func (self *CmdSetResource) RpcParams(reset bool) interface{} {
func (self *CmdSetAttributes) RpcParams(reset bool) interface{} {
if reset || self.rpcParams == nil {
self.rpcParams = &engine.ExternalAttributeProfile{}
}
return self.rpcParams
}
func (self *CmdSetResource) PostprocessRpcParams() error {
func (self *CmdSetAttributes) PostprocessRpcParams() error {
return nil
}
func (self *CmdSetResource) RpcResult() interface{} {
func (self *CmdSetAttributes) RpcResult() interface{} {
var s string
return &s
}

View File

@@ -0,0 +1,77 @@
/*
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 <http://www.gnu.org/licenses/>
*/
package console
import (
"github.com/cgrates/cgrates/config"
"github.com/cgrates/cgrates/engine"
"github.com/cgrates/cgrates/utils"
)
func init() {
c := &CmdStatsQueueProcessEvent{
name: "statsqueue_for_event",
rpcMethod: "StatSv1.GetStatQueuesForEvent",
}
commands[c.Name()] = c
c.CommandExecuter = &CommandExecuter{c}
}
// Commander implementation
type CmdStatsQueueProcessEvent struct {
name string
rpcMethod string
rpcParams interface{}
*CommandExecuter
}
func (self *CmdStatsQueueProcessEvent) Name() string {
return self.name
}
func (self *CmdStatsQueueProcessEvent) RpcMethod() string {
return self.rpcMethod
}
func (self *CmdStatsQueueProcessEvent) RpcParams(reset bool) interface{} {
if reset || self.rpcParams == nil {
mp := make(map[string]interface{})
self.rpcParams = &mp
}
return self.rpcParams
}
func (self *CmdStatsQueueProcessEvent) PostprocessRpcParams() error { //utils.CGREvent
param := self.rpcParams.(*map[string]interface{})
cgrev := utils.CGREvent{
Tenant: config.CgrConfig().DefaultTenant,
ID: utils.UUIDSha1Prefix(),
Event: *param,
}
if (*param)[utils.Tenant] != nil && (*param)[utils.Tenant].(string) != "" {
cgrev.Tenant = (*param)[utils.Tenant].(string)
}
self.rpcParams = cgrev
return nil
}
func (self *CmdStatsQueueProcessEvent) RpcResult() interface{} {
s := engine.StatQueues{}
return &s
}

View File

@@ -0,0 +1,76 @@
/*
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 <http://www.gnu.org/licenses/>
*/
package console
import (
"github.com/cgrates/cgrates/config"
"github.com/cgrates/cgrates/utils"
)
func init() {
c := &CmdStatQueueProcessEvent{
name: "statqueue_process_event",
rpcMethod: "StatSv1.ProcessEvent",
}
commands[c.Name()] = c
c.CommandExecuter = &CommandExecuter{c}
}
// Commander implementation
type CmdStatQueueProcessEvent struct {
name string
rpcMethod string
rpcParams interface{}
*CommandExecuter
}
func (self *CmdStatQueueProcessEvent) Name() string {
return self.name
}
func (self *CmdStatQueueProcessEvent) RpcMethod() string {
return self.rpcMethod
}
func (self *CmdStatQueueProcessEvent) RpcParams(reset bool) interface{} {
if reset || self.rpcParams == nil {
mp := make(map[string]interface{})
self.rpcParams = &mp
}
return self.rpcParams
}
func (self *CmdStatQueueProcessEvent) PostprocessRpcParams() error { //utils.CGREvent
param := self.rpcParams.(*map[string]interface{})
cgrev := utils.CGREvent{
Tenant: config.CgrConfig().DefaultTenant,
ID: utils.UUIDSha1Prefix(),
Event: *param,
}
if (*param)[utils.Tenant] != nil && (*param)[utils.Tenant].(string) != "" {
cgrev.Tenant = (*param)[utils.Tenant].(string)
}
self.rpcParams = cgrev
return nil
}
func (self *CmdStatQueueProcessEvent) RpcResult() interface{} {
var s string
return &s
}