mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-22 15:48:44 +05:00
Added GetAccountsCount API
This commit is contained in:
committed by
Dan Christian Bogos
parent
4a458c7a76
commit
ac5ca11eb8
@@ -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)
|
||||
|
||||
@@ -434,6 +434,10 @@ type AttrGetAccounts struct {
|
||||
Filter map[string]bool
|
||||
}
|
||||
|
||||
type AttrGetAccountsCount struct {
|
||||
Tenant string
|
||||
}
|
||||
|
||||
type ArgsCache struct {
|
||||
DestinationIDs []string
|
||||
ReverseDestinationIDs []string
|
||||
|
||||
Reference in New Issue
Block a user