Added GetAccountsCount API

This commit is contained in:
adragusin
2020-05-14 18:00:27 +03:00
committed by Dan Christian Bogos
parent 4a458c7a76
commit ac5ca11eb8
2 changed files with 19 additions and 0 deletions

View File

@@ -80,6 +80,21 @@ func (apiv2 *APIerSv2) GetAccounts(attr utils.AttrGetAccounts, reply *[]*engine.
return nil
}
// GetAccountsCount returns the total number of accounts
func (apiv2 *APIerSv2) GetAccountsCount(attr utils.AttrGetAccountsCount, reply *int) (err error) {
if len(attr.Tenant) == 0 {
return utils.NewErrMandatoryIeMissing("Tenant")
}
var accountKeys []string
if accountKeys, err = apiv2.DataManager.DataDB().GetKeysForPrefix(utils.ACCOUNT_PREFIX + attr.Tenant); err != nil {
return err
}
*reply = len(accountKeys)
return
}
// Get balance
func (apiv2 *APIerSv2) GetAccount(attr *utils.AttrGetAccount, reply *engine.Account) error {
tag := utils.ConcatenatedKey(attr.Tenant, attr.Account)

View File

@@ -434,6 +434,10 @@ type AttrGetAccounts struct {
Filter map[string]bool
}
type AttrGetAccountsCount struct {
Tenant string
}
type ArgsCache struct {
DestinationIDs []string
ReverseDestinationIDs []string