diff --git a/console/resources_allocate.go b/console/resources_allocate.go new file mode 100644 index 000000000..72b93c6ab --- /dev/null +++ b/console/resources_allocate.go @@ -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 +*/ + +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 +} diff --git a/console/resources_authorize.go b/console/resources_authorize.go new file mode 100644 index 000000000..dc57448a7 --- /dev/null +++ b/console/resources_authorize.go @@ -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 +*/ + +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 +} diff --git a/console/resources_release.go b/console/resources_release.go new file mode 100644 index 000000000..59362542d --- /dev/null +++ b/console/resources_release.go @@ -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 +*/ + +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 +}