added apier method

This commit is contained in:
Radu Ioan Fericean
2015-07-13 20:41:24 +03:00
parent 4954332087
commit fd7beda6a9
2 changed files with 25 additions and 0 deletions

View File

@@ -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")

View File

@@ -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
}