Adding cgr-console attributes related APIs

This commit is contained in:
edwardro22
2017-12-15 08:54:56 +02:00
committed by Dan Christian Bogos
parent cec463f658
commit 787cc55d15
5 changed files with 344 additions and 0 deletions

66
console/atributes.go Normal file
View File

@@ -0,0 +1,66 @@
/*
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/engine"
"github.com/cgrates/cgrates/utils"
)
func init() {
c := &CmdGetAtributes{
name: "atributes",
rpcMethod: "ApierV1.GetAttributeProfile",
rpcParams: &utils.TenantID{},
}
commands[c.Name()] = c
c.CommandExecuter = &CommandExecuter{c}
}
// Commander implementation
type CmdGetAtributes struct {
name string
rpcMethod string
rpcParams *utils.TenantID
*CommandExecuter
}
func (self *CmdGetAtributes) Name() string {
return self.name
}
func (self *CmdGetAtributes) RpcMethod() string {
return self.rpcMethod
}
func (self *CmdGetAtributes) RpcParams(reset bool) interface{} {
if reset || self.rpcParams == nil {
self.rpcParams = &utils.TenantID{}
}
return self.rpcParams
}
func (self *CmdGetAtributes) PostprocessRpcParams() error {
return nil
}
func (self *CmdGetAtributes) RpcResult() interface{} {
atr := engine.ExternalAttributeProfile{}
return &atr
}

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 := &CmdAttributesProcessEvent{
name: "get_attribute_for_event",
rpcMethod: "AttributeSv1.GetAttributeForEvent",
}
commands[c.Name()] = c
c.CommandExecuter = &CommandExecuter{c}
}
// Commander implementation
type CmdAttributesProcessEvent struct {
name string
rpcMethod string
rpcParams interface{}
*CommandExecuter
}
func (self *CmdAttributesProcessEvent) Name() string {
return self.name
}
func (self *CmdAttributesProcessEvent) RpcMethod() string {
return self.rpcMethod
}
func (self *CmdAttributesProcessEvent) RpcParams(reset bool) interface{} {
if reset || self.rpcParams == nil {
mp := make(map[string]interface{})
self.rpcParams = &mp
}
return self.rpcParams
}
func (self *CmdAttributesProcessEvent) 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 *CmdAttributesProcessEvent) RpcResult() interface{} {
atr := engine.ExternalAttributeProfile{}
return &atr
}

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 := &CmdAttributesProcessEvent{
name: "attributes_process_event",
rpcMethod: "AttributeSv1.ProcessEvent",
}
commands[c.Name()] = c
c.CommandExecuter = &CommandExecuter{c}
}
// Commander implementation
type CmdAttributesProcessEvent struct {
name string
rpcMethod string
rpcParams interface{}
*CommandExecuter
}
func (self *CmdAttributesProcessEvent) Name() string {
return self.name
}
func (self *CmdAttributesProcessEvent) RpcMethod() string {
return self.rpcMethod
}
func (self *CmdAttributesProcessEvent) RpcParams(reset bool) interface{} {
if reset || self.rpcParams == nil {
mp := make(map[string]interface{})
self.rpcParams = &mp
}
return self.rpcParams
}
func (self *CmdAttributesProcessEvent) 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 *CmdAttributesProcessEvent) RpcResult() interface{} {
atr := engine.AttrSProcessEventReply{}
return &atr
}

View File

@@ -0,0 +1,63 @@
/*
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/utils"
func init() {
c := &CmdRemoveAtributes{
name: "atributes_remove",
rpcMethod: "ApierV1.RemAttributeProfile",
rpcParams: &utils.TenantID{},
}
commands[c.Name()] = c
c.CommandExecuter = &CommandExecuter{c}
}
// Commander implementation
type CmdRemoveAtributes struct {
name string
rpcMethod string
rpcParams *utils.TenantID
*CommandExecuter
}
func (self *CmdRemoveAtributes) Name() string {
return self.name
}
func (self *CmdRemoveAtributes) RpcMethod() string {
return self.rpcMethod
}
func (self *CmdRemoveAtributes) RpcParams(reset bool) interface{} {
if reset || self.rpcParams == nil {
self.rpcParams = &utils.TenantID{}
}
return self.rpcParams
}
func (self *CmdRemoveAtributes) PostprocessRpcParams() error {
return nil
}
func (self *CmdRemoveAtributes) RpcResult() interface{} {
var s string
return &s
}

63
console/atributes_set.go Normal file
View File

@@ -0,0 +1,63 @@
/*
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/engine"
func init() {
c := &CmdSetResource{
name: "attributes_set",
rpcMethod: "ApierV1.SetAttributeProfile",
rpcParams: &engine.ExternalAttributeProfile{},
}
commands[c.Name()] = c
c.CommandExecuter = &CommandExecuter{c}
}
// Commander implementation
type CmdSetResource struct {
name string
rpcMethod string
rpcParams *engine.ExternalAttributeProfile
*CommandExecuter
}
func (self *CmdSetResource) Name() string {
return self.name
}
func (self *CmdSetResource) RpcMethod() string {
return self.rpcMethod
}
func (self *CmdSetResource) RpcParams(reset bool) interface{} {
if reset || self.rpcParams == nil {
self.rpcParams = &engine.ExternalAttributeProfile{}
}
return self.rpcParams
}
func (self *CmdSetResource) PostprocessRpcParams() error {
return nil
}
func (self *CmdSetResource) RpcResult() interface{} {
var s string
return &s
}