mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Add resources_allocate/resources_authorize/resources_release commands in cgr-console
This commit is contained in:
committed by
Dan Christian Bogos
parent
aadabd26ac
commit
c55505500a
70
console/resources_allocate.go
Normal file
70
console/resources_allocate.go
Normal file
@@ -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 <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
|
||||
package console
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/cgrates/cgrates/utils"
|
||||
)
|
||||
|
||||
func init() {
|
||||
c := &CmdResourceAllocate{
|
||||
name: "resources_allocate",
|
||||
rpcMethod: utils.ResourceSv1AllocateResources,
|
||||
rpcParams: &utils.ArgRSv1ResourceUsage{},
|
||||
}
|
||||
commands[c.Name()] = c
|
||||
c.CommandExecuter = &CommandExecuter{c}
|
||||
}
|
||||
|
||||
// Commander implementation
|
||||
type CmdResourceAllocate struct {
|
||||
name string
|
||||
rpcMethod string
|
||||
rpcParams *utils.ArgRSv1ResourceUsage
|
||||
*CommandExecuter
|
||||
}
|
||||
|
||||
func (self *CmdResourceAllocate) Name() string {
|
||||
return self.name
|
||||
}
|
||||
|
||||
func (self *CmdResourceAllocate) RpcMethod() string {
|
||||
return self.rpcMethod
|
||||
}
|
||||
|
||||
func (self *CmdResourceAllocate) RpcParams(reset bool) interface{} {
|
||||
if reset || self.rpcParams == nil {
|
||||
self.rpcParams = &utils.ArgRSv1ResourceUsage{ArgDispatcher: new(utils.ArgDispatcher)}
|
||||
}
|
||||
return self.rpcParams
|
||||
}
|
||||
|
||||
func (self *CmdResourceAllocate) PostprocessRpcParams() error {
|
||||
if self.rpcParams.CGREvent.Time == nil {
|
||||
self.rpcParams.CGREvent.Time = utils.TimePointer(time.Now())
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *CmdResourceAllocate) RpcResult() interface{} {
|
||||
var atr *string
|
||||
return &atr
|
||||
}
|
||||
70
console/resources_authorize.go
Normal file
70
console/resources_authorize.go
Normal file
@@ -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 <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
|
||||
package console
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/cgrates/cgrates/utils"
|
||||
)
|
||||
|
||||
func init() {
|
||||
c := &CmdResourceAuthorize{
|
||||
name: "resources_authorize",
|
||||
rpcMethod: utils.ResourceSv1AuthorizeResources,
|
||||
rpcParams: &utils.ArgRSv1ResourceUsage{},
|
||||
}
|
||||
commands[c.Name()] = c
|
||||
c.CommandExecuter = &CommandExecuter{c}
|
||||
}
|
||||
|
||||
// Commander implementation
|
||||
type CmdResourceAuthorize struct {
|
||||
name string
|
||||
rpcMethod string
|
||||
rpcParams *utils.ArgRSv1ResourceUsage
|
||||
*CommandExecuter
|
||||
}
|
||||
|
||||
func (self *CmdResourceAuthorize) Name() string {
|
||||
return self.name
|
||||
}
|
||||
|
||||
func (self *CmdResourceAuthorize) RpcMethod() string {
|
||||
return self.rpcMethod
|
||||
}
|
||||
|
||||
func (self *CmdResourceAuthorize) RpcParams(reset bool) interface{} {
|
||||
if reset || self.rpcParams == nil {
|
||||
self.rpcParams = &utils.ArgRSv1ResourceUsage{ArgDispatcher: new(utils.ArgDispatcher)}
|
||||
}
|
||||
return self.rpcParams
|
||||
}
|
||||
|
||||
func (self *CmdResourceAuthorize) PostprocessRpcParams() error {
|
||||
if self.rpcParams.CGREvent.Time == nil {
|
||||
self.rpcParams.CGREvent.Time = utils.TimePointer(time.Now())
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *CmdResourceAuthorize) RpcResult() interface{} {
|
||||
var atr *string
|
||||
return &atr
|
||||
}
|
||||
70
console/resources_release.go
Normal file
70
console/resources_release.go
Normal file
@@ -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 <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
|
||||
package console
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/cgrates/cgrates/utils"
|
||||
)
|
||||
|
||||
func init() {
|
||||
c := &CmdResourceRelease{
|
||||
name: "resources_release",
|
||||
rpcMethod: utils.ResourceSv1ReleaseResources,
|
||||
rpcParams: &utils.ArgRSv1ResourceUsage{},
|
||||
}
|
||||
commands[c.Name()] = c
|
||||
c.CommandExecuter = &CommandExecuter{c}
|
||||
}
|
||||
|
||||
// Commander implementation
|
||||
type CmdResourceRelease struct {
|
||||
name string
|
||||
rpcMethod string
|
||||
rpcParams *utils.ArgRSv1ResourceUsage
|
||||
*CommandExecuter
|
||||
}
|
||||
|
||||
func (self *CmdResourceRelease) Name() string {
|
||||
return self.name
|
||||
}
|
||||
|
||||
func (self *CmdResourceRelease) RpcMethod() string {
|
||||
return self.rpcMethod
|
||||
}
|
||||
|
||||
func (self *CmdResourceRelease) RpcParams(reset bool) interface{} {
|
||||
if reset || self.rpcParams == nil {
|
||||
self.rpcParams = &utils.ArgRSv1ResourceUsage{ArgDispatcher: new(utils.ArgDispatcher)}
|
||||
}
|
||||
return self.rpcParams
|
||||
}
|
||||
|
||||
func (self *CmdResourceRelease) PostprocessRpcParams() error {
|
||||
if self.rpcParams.CGREvent.Time == nil {
|
||||
self.rpcParams.CGREvent.Time = utils.TimePointer(time.Now())
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *CmdResourceRelease) RpcResult() interface{} {
|
||||
var atr *string
|
||||
return &atr
|
||||
}
|
||||
Reference in New Issue
Block a user