mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
added apier method
This commit is contained in:
@@ -210,6 +210,25 @@ func (self *ApierV1) SetAccount(attr utils.AttrSetAccount, reply *string) error
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *ApierV1) RemoveAccount(attr utils.AttrRemoveAccount, reply *string) error {
|
||||
if missing := utils.MissingStructFields(&attr, []string{"Tenant", "Direction", "Account"}); len(missing) != 0 {
|
||||
return utils.NewErrMandatoryIeMissing(missing...)
|
||||
}
|
||||
accountId := utils.AccountKey(attr.Tenant, attr.Account, attr.Direction)
|
||||
_, err := engine.Guardian.Guard(func() (interface{}, error) {
|
||||
if err := self.AccountDb.RemoveAccount(accountId); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return 0, nil
|
||||
}, accountId)
|
||||
if err != nil {
|
||||
return utils.NewErrServerError(err)
|
||||
}
|
||||
|
||||
*reply = OK
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *ApierV1) GetAccounts(attr utils.AttrGetAccounts, reply *[]*engine.Account) error {
|
||||
if len(attr.Tenant) == 0 {
|
||||
return utils.NewErrMandatoryIeMissing("Tenanat")
|
||||
|
||||
@@ -1074,6 +1074,12 @@ type AttrSetAccount struct {
|
||||
AllowNegative bool
|
||||
}
|
||||
|
||||
type AttrRemoveAccount struct {
|
||||
Tenant string
|
||||
Direction string
|
||||
Account string
|
||||
}
|
||||
|
||||
type AttrGetSMASessions struct {
|
||||
SessionManagerIndex int // Index of the session manager queried, defaults to first in the list
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user