mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Add API for SetVersions for both stordb and datadb
This commit is contained in:
committed by
Dan Christian Bogos
parent
17db4f634d
commit
b7a2b1cc7b
@@ -46,3 +46,32 @@ func (self *ApierV1) GetStorDBVersions(ign string, reply *engine.Versions) error
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type SetVersionsArg struct {
|
||||
Versions engine.Versions
|
||||
Overwrite bool
|
||||
}
|
||||
|
||||
// Queries all versions from dataDB
|
||||
func (self *ApierV1) SetDataDBVersions(arg SetVersionsArg, reply *string) error {
|
||||
if arg.Versions == nil {
|
||||
arg.Versions = engine.CurrentDataDBVersions()
|
||||
}
|
||||
if err := self.DataManager.DataDB().SetVersions(arg.Versions, arg.Overwrite); err != nil {
|
||||
return utils.NewErrServerError(err)
|
||||
}
|
||||
*reply = utils.OK
|
||||
return nil
|
||||
}
|
||||
|
||||
// Queries all versions from stordb
|
||||
func (self *ApierV1) SetStorDBVersions(arg SetVersionsArg, reply *string) error {
|
||||
if arg.Versions == nil {
|
||||
arg.Versions = engine.CurrentDataDBVersions()
|
||||
}
|
||||
if err := self.StorDb.SetVersions(arg.Versions, arg.Overwrite); err != nil {
|
||||
return utils.NewErrServerError(err)
|
||||
}
|
||||
*reply = utils.OK
|
||||
return nil
|
||||
}
|
||||
|
||||
65
console/set_datadb_versions.go
Normal file
65
console/set_datadb_versions.go
Normal file
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
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 (
|
||||
v1 "github.com/cgrates/cgrates/apier/v1"
|
||||
"github.com/cgrates/cgrates/utils"
|
||||
)
|
||||
|
||||
func init() {
|
||||
c := &CmdSetDataDBVersions{
|
||||
name: "set_datadb_versions",
|
||||
rpcMethod: utils.ApierV1SetDataDBVersions,
|
||||
rpcParams: &v1.SetVersionsArg{},
|
||||
}
|
||||
commands[c.Name()] = c
|
||||
c.CommandExecuter = &CommandExecuter{c}
|
||||
}
|
||||
|
||||
type CmdSetDataDBVersions struct {
|
||||
name string
|
||||
rpcMethod string
|
||||
rpcParams *v1.SetVersionsArg
|
||||
*CommandExecuter
|
||||
}
|
||||
|
||||
func (self *CmdSetDataDBVersions) Name() string {
|
||||
return self.name
|
||||
}
|
||||
|
||||
func (self *CmdSetDataDBVersions) RpcMethod() string {
|
||||
return self.rpcMethod
|
||||
}
|
||||
|
||||
func (self *CmdSetDataDBVersions) RpcParams(reset bool) interface{} {
|
||||
if reset || self.rpcParams == nil {
|
||||
self.rpcParams = &v1.SetVersionsArg{}
|
||||
}
|
||||
return self.rpcParams
|
||||
}
|
||||
|
||||
func (self *CmdSetDataDBVersions) PostprocessRpcParams() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *CmdSetDataDBVersions) RpcResult() interface{} {
|
||||
var atr string
|
||||
return &atr
|
||||
}
|
||||
65
console/set_stordb_versions.go
Normal file
65
console/set_stordb_versions.go
Normal file
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
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 (
|
||||
v1 "github.com/cgrates/cgrates/apier/v1"
|
||||
"github.com/cgrates/cgrates/utils"
|
||||
)
|
||||
|
||||
func init() {
|
||||
c := &CmdSetStorDBVersions{
|
||||
name: "set_stordb_versions",
|
||||
rpcMethod: utils.ApierV1SetStorDBVersions,
|
||||
rpcParams: &v1.SetVersionsArg{},
|
||||
}
|
||||
commands[c.Name()] = c
|
||||
c.CommandExecuter = &CommandExecuter{c}
|
||||
}
|
||||
|
||||
type CmdSetStorDBVersions struct {
|
||||
name string
|
||||
rpcMethod string
|
||||
rpcParams *v1.SetVersionsArg
|
||||
*CommandExecuter
|
||||
}
|
||||
|
||||
func (self *CmdSetStorDBVersions) Name() string {
|
||||
return self.name
|
||||
}
|
||||
|
||||
func (self *CmdSetStorDBVersions) RpcMethod() string {
|
||||
return self.rpcMethod
|
||||
}
|
||||
|
||||
func (self *CmdSetStorDBVersions) RpcParams(reset bool) interface{} {
|
||||
if reset || self.rpcParams == nil {
|
||||
self.rpcParams = &v1.SetVersionsArg{}
|
||||
}
|
||||
return self.rpcParams
|
||||
}
|
||||
|
||||
func (self *CmdSetStorDBVersions) PostprocessRpcParams() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *CmdSetStorDBVersions) RpcResult() interface{} {
|
||||
var atr string
|
||||
return &atr
|
||||
}
|
||||
@@ -784,6 +784,8 @@ const (
|
||||
ApierV1RemoveRatingProfile = "ApierV1.RemoveRatingProfile"
|
||||
ApierV1SetRatingProfile = "ApierV1.SetRatingProfile"
|
||||
ApierV1GetRatingProfileIDs = "ApierV1.GetRatingProfileIDs"
|
||||
ApierV1SetDataDBVersions = "ApierV1.SetDataDBVersions"
|
||||
ApierV1SetStorDBVersions = "ApierV1.SetStorDBVersions"
|
||||
)
|
||||
|
||||
const (
|
||||
|
||||
Reference in New Issue
Block a user