From fd7beda6a9a9fe360c73c79d21a8a03129f81980 Mon Sep 17 00:00:00 2001 From: Radu Ioan Fericean Date: Mon, 13 Jul 2015 20:41:24 +0300 Subject: [PATCH] added apier method --- apier/v1/accounts.go | 19 +++++++++++++++++++ utils/apitpdata.go | 6 ++++++ 2 files changed, 25 insertions(+) diff --git a/apier/v1/accounts.go b/apier/v1/accounts.go index b4dc192f8..a6b0f4435 100644 --- a/apier/v1/accounts.go +++ b/apier/v1/accounts.go @@ -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") diff --git a/utils/apitpdata.go b/utils/apitpdata.go index 61b937680..9c5dda207 100644 --- a/utils/apitpdata.go +++ b/utils/apitpdata.go @@ -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 }