added user service console commands

This commit is contained in:
Radu Ioan Fericean
2015-07-10 23:23:56 +03:00
parent 8f7e3efd61
commit 87d8dee93a
6 changed files with 329 additions and 5 deletions

63
console/user_addindex.go Normal file
View File

@@ -0,0 +1,63 @@
/*
Rating system designed to be used in VoIP Carriers World
Copyright (C) 2012-2015 ITsysCOM
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
func init() {
c := &CmdUserAddIndex{
name: "user_addindex",
rpcMethod: "UsersV1.AddIndex",
}
commands[c.Name()] = c
c.CommandExecuter = &CommandExecuter{c}
}
// Commander implementation
type CmdUserAddIndex struct {
name string
rpcMethod string
rpcParams *[]string
*CommandExecuter
}
func (self *CmdUserAddIndex) Name() string {
return self.name
}
func (self *CmdUserAddIndex) RpcMethod() string {
return self.rpcMethod
}
func (self *CmdUserAddIndex) RpcParams(ptr bool) interface{} {
if self.rpcParams == nil {
self.rpcParams = &[]string{}
}
if ptr {
return self.rpcParams
}
return *self.rpcParams
}
func (self *CmdUserAddIndex) PostprocessRpcParams() error {
return nil
}
func (self *CmdUserAddIndex) RpcResult() interface{} {
var s string
return &s
}

65
console/user_remove.go Normal file
View File

@@ -0,0 +1,65 @@
/*
Rating system designed to be used in VoIP Carriers World
Copyright (C) 2012-2015 ITsysCOM
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 := &CmdUserRemove{
name: "user_remove",
rpcMethod: "UsersV1.RemoveUser",
}
commands[c.Name()] = c
c.CommandExecuter = &CommandExecuter{c}
}
// Commander implementation
type CmdUserRemove struct {
name string
rpcMethod string
rpcParams *engine.UserProfile
*CommandExecuter
}
func (self *CmdUserRemove) Name() string {
return self.name
}
func (self *CmdUserRemove) RpcMethod() string {
return self.rpcMethod
}
func (self *CmdUserRemove) RpcParams(ptr bool) interface{} {
if self.rpcParams == nil {
self.rpcParams = &engine.UserProfile{}
}
if ptr {
return self.rpcParams
}
return *self.rpcParams
}
func (self *CmdUserRemove) PostprocessRpcParams() error {
return nil
}
func (self *CmdUserRemove) RpcResult() interface{} {
var s string
return &s
}

65
console/user_set.go Normal file
View File

@@ -0,0 +1,65 @@
/*
Rating system designed to be used in VoIP Carriers World
Copyright (C) 2012-2015 ITsysCOM
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 := &CmdSetUser{
name: "user_set",
rpcMethod: "UsersV1.SetUser",
}
commands[c.Name()] = c
c.CommandExecuter = &CommandExecuter{c}
}
// Commander implementation
type CmdSetUser struct {
name string
rpcMethod string
rpcParams *engine.UserProfile
*CommandExecuter
}
func (self *CmdSetUser) Name() string {
return self.name
}
func (self *CmdSetUser) RpcMethod() string {
return self.rpcMethod
}
func (self *CmdSetUser) RpcParams(ptr bool) interface{} {
if self.rpcParams == nil {
self.rpcParams = &engine.UserProfile{}
}
if ptr {
return self.rpcParams
}
return *self.rpcParams
}
func (self *CmdSetUser) PostprocessRpcParams() error {
return nil
}
func (self *CmdSetUser) RpcResult() interface{} {
var s string
return &s
}

65
console/user_update.go Normal file
View File

@@ -0,0 +1,65 @@
/*
Rating system designed to be used in VoIP Carriers World
Copyright (C) 2012-2015 ITsysCOM
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 := &CmdUpdateUser{
name: "user_update",
rpcMethod: "UsersV1.UpdateUser",
}
commands[c.Name()] = c
c.CommandExecuter = &CommandExecuter{c}
}
// Commander implementation
type CmdUpdateUser struct {
name string
rpcMethod string
rpcParams *engine.UserProfile
*CommandExecuter
}
func (self *CmdUpdateUser) Name() string {
return self.name
}
func (self *CmdUpdateUser) RpcMethod() string {
return self.rpcMethod
}
func (self *CmdUpdateUser) RpcParams(ptr bool) interface{} {
if self.rpcParams == nil {
self.rpcParams = &engine.UserProfile{}
}
if ptr {
return self.rpcParams
}
return *self.rpcParams
}
func (self *CmdUpdateUser) PostprocessRpcParams() error {
return nil
}
func (self *CmdUpdateUser) RpcResult() interface{} {
var s string
return &s
}

66
console/users.go Normal file
View File

@@ -0,0 +1,66 @@
/*
Rating system designed to be used in VoIP Carriers World
Copyright (C) 2012-2015 ITsysCOM
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 := &CmdGetUsers{
name: "users",
rpcMethod: "UsersV1.GetUsers",
rpcParams: &engine.UserProfile{},
}
commands[c.Name()] = c
c.CommandExecuter = &CommandExecuter{c}
}
// Commander implementation
type CmdGetUsers struct {
name string
rpcMethod string
rpcParams *engine.UserProfile
*CommandExecuter
}
func (self *CmdGetUsers) Name() string {
return self.name
}
func (self *CmdGetUsers) RpcMethod() string {
return self.rpcMethod
}
func (self *CmdGetUsers) RpcParams(ptr bool) interface{} {
if self.rpcParams == nil {
self.rpcParams = &engine.UserProfile{}
}
if ptr {
return self.rpcParams
}
return *self.rpcParams
}
func (self *CmdGetUsers) PostprocessRpcParams() error {
return nil
}
func (self *CmdGetUsers) RpcResult() interface{} {
s := []*engine.UserProfile{}
return &s
}

View File

@@ -201,21 +201,21 @@ func NewProxyUserService(addr string, attempts, reconnects int) (*ProxyUserServi
}
func (ps *ProxyUserService) SetUser(ud UserProfile, reply *string) error {
return ps.Client.Call("UserService.SetUser", ud, reply)
return ps.Client.Call("UsersV1.SetUser", ud, reply)
}
func (ps *ProxyUserService) RemoveUser(ud UserProfile, reply *string) error {
return ps.Client.Call("UserService.RemoveUser", ud, reply)
return ps.Client.Call("UsersV1.RemoveUser", ud, reply)
}
func (ps *ProxyUserService) UpdateUser(ud UserProfile, reply *string) error {
return ps.Client.Call("UserService.UpdateUser", ud, reply)
return ps.Client.Call("UsersV1.UpdateUser", ud, reply)
}
func (ps *ProxyUserService) GetUsers(ud UserProfile, users *[]*UserProfile) error {
return ps.Client.Call("UserService.GetUsers", ud, users)
return ps.Client.Call("UsersV1.GetUsers", ud, users)
}
func (ps *ProxyUserService) AddIndex(indexes []string, reply *string) error {
return ps.Client.Call("UserService.AddIndex", indexes, reply)
return ps.Client.Call("UsersV1.AddIndex", indexes, reply)
}