From 5d8e04821aa1dc453d9dffb0dec08d5a647c1f9c Mon Sep 17 00:00:00 2001 From: porosnicuadrian Date: Thu, 8 Apr 2021 15:58:38 +0300 Subject: [PATCH] Removed profile from all accounts in all packages --- accounts/accounts.go | 14 +-- accounts/libaccounts.go | 2 +- apier/v1/accountprofiles.go | 40 ++++----- apier/v1/api_interfaces.go | 8 +- apier/v1/apier.go | 8 +- apier/v1/dispatcher.go | 22 ++--- apier/v1/filter_indexes.go | 16 ++-- apier/v1/replicator.go | 24 ++--- apier/v1/tpaccountprofiles.go | 20 ++--- config/config_defaults.go | 13 ++- console/accounts_profile.go | 2 +- console/accounts_profile_ids.go | 2 +- console/accounts_profile_rem.go | 2 +- console/accounts_profile_set.go | 2 +- data/conf/cgrates/cgrates.json | 4 +- data/tariffplans/dispatchers/Attributes.csv | 2 +- dispatchers/accounts.go | 6 +- dispatchers/replicator.go | 18 ++-- engine/datadbmock.go | 6 +- engine/datamanager.go | 34 +++---- engine/dynamicdp.go | 2 +- engine/libindex.go | 2 +- engine/libtest.go | 98 ++++++++++----------- engine/models.go | 2 +- engine/storage_csv.go | 8 +- engine/storage_interface.go | 6 +- engine/storage_internal_datadb.go | 12 +-- engine/storage_internal_stordb.go | 6 +- engine/storage_mongo_datadb.go | 16 ++-- engine/storage_mongo_stordb.go | 4 +- engine/storage_redis.go | 12 +-- engine/storage_sql.go | 2 +- engine/tpexporter.go | 4 +- engine/tpimporter_csv.go | 4 +- engine/tpreader.go | 12 +-- loaders/loader.go | 12 +-- migrator/account_profiles.go | 26 +++--- migrator/migrator.go | 4 +- migrator/stats.go | 1 + services/accounts.go | 4 +- utils/accountprofile.go | 12 +-- utils/apitpdata.go | 24 ++--- 42 files changed, 259 insertions(+), 259 deletions(-) diff --git a/accounts/accounts.go b/accounts/accounts.go index 3e4ae0dd8..b39d3746f 100644 --- a/accounts/accounts.go +++ b/accounts/accounts.go @@ -65,7 +65,7 @@ func (aS *AccountS) Call(serviceMethod string, args interface{}, reply interface } // matchingAccountsForEvent returns the matched Accounts for the given event -// if lked option is passed, each AccountProfile will be also locked +// if lked option is passed, each Account will be also locked // so it becomes responsibility of upper layers to release the lock func (aS *AccountS) matchingAccountsForEvent(tnt string, cgrEv *utils.CGREvent, acntIDs []string, lked bool) (acnts utils.AccountsWithWeight, err error) { @@ -81,7 +81,7 @@ func (aS *AccountS) matchingAccountsForEvent(tnt string, cgrEv *utils.CGREvent, aS.cfg.AccountSCfg().PrefixIndexedFields, aS.cfg.AccountSCfg().SuffixIndexedFields, aS.dm, - utils.CacheAccountProfilesFilterIndexes, + utils.CacheAccountsFilterIndexes, tnt, aS.cfg.AccountSCfg().IndexedSelects, aS.cfg.AccountSCfg().NestedFields, @@ -93,7 +93,7 @@ func (aS *AccountS) matchingAccountsForEvent(tnt string, cgrEv *utils.CGREvent, for _, acntID := range acntIDs { var refID string if lked { - cacheKey := utils.ConcatenatedKey(utils.CacheAccountProfiles, tnt, acntID) + cacheKey := utils.ConcatenatedKey(utils.CacheAccounts, tnt, acntID) refID = guardian.Guardian.GuardIDs("", aS.cfg.GeneralCfg().LockingTimeout, cacheKey) // RPC caching needs to be atomic } @@ -253,8 +253,8 @@ func (aS *AccountS) accountDebit(acnt *utils.Account, usage *decimal.Big, return } -// V1AccountProfilesForEvent returns the matching AccountProfiles for Event -func (aS *AccountS) V1AccountProfilesForEvent(args *utils.ArgsAccountsForEvent, aps *[]*utils.Account) (err error) { +// V1AccountsForEvent returns the matching Accounts for Event +func (aS *AccountS) V1AccountsForEvent(args *utils.ArgsAccountsForEvent, aps *[]*utils.Account) (err error) { var acnts utils.AccountsWithWeight if acnts, err = aS.matchingAccountsForEvent(args.CGREvent.Tenant, args.CGREvent, args.AccountIDs, false); err != nil { @@ -382,7 +382,7 @@ func (aS *AccountS) V1ActionSetBalance(args *utils.ArgsActSetBalance, rply *stri if _, err = guardian.Guardian.Guard(func() (interface{}, error) { return nil, actSetAccount(aS.dm, tnt, args.AccountID, args.Diktats, args.Reset) }, aS.cfg.GeneralCfg().LockingTimeout, - utils.ConcatenatedKey(utils.CacheAccountProfiles, tnt, args.AccountID)); err != nil { + utils.ConcatenatedKey(utils.CacheAccounts, tnt, args.AccountID)); err != nil { return } @@ -412,7 +412,7 @@ func (aS *AccountS) V1ActionRemoveBalance(args *utils.ArgsActRemoveBalances, rpl } return nil, aS.dm.SetAccount(qAcnt, false) }, aS.cfg.GeneralCfg().LockingTimeout, - utils.ConcatenatedKey(utils.CacheAccountProfiles, tnt, args.AccountID)); err != nil { + utils.ConcatenatedKey(utils.CacheAccounts, tnt, args.AccountID)); err != nil { return } *rply = utils.OK diff --git a/accounts/libaccounts.go b/accounts/libaccounts.go index 205e2b600..7cbe6004b 100644 --- a/accounts/libaccounts.go +++ b/accounts/libaccounts.go @@ -345,7 +345,7 @@ func restoreAccounts(dm *engine.DataManager, } } -// unlockAccountProfiles is used to unlock the accounts based on their lock identifiers +// unlockAccounts is used to unlock the accounts based on their lock identifiers func unlockAccounts(acnts utils.AccountsWithWeight) { for _, lkID := range acnts.LockIDs() { guardian.Guardian.UnguardIDs(lkID) diff --git a/apier/v1/accountprofiles.go b/apier/v1/accountprofiles.go index dd7042cff..3c7a9f5bd 100644 --- a/apier/v1/accountprofiles.go +++ b/apier/v1/accountprofiles.go @@ -26,8 +26,8 @@ import ( "github.com/cgrates/cgrates/utils" ) -// GetAccountProfile returns an Account Profile -func (apierSv1 *APIerSv1) GetAccountProfile(arg *utils.TenantIDWithAPIOpts, reply *utils.Account) error { +// GetAccount returns an Account +func (apierSv1 *APIerSv1) GetAccount(arg *utils.TenantIDWithAPIOpts, reply *utils.Account) error { if missing := utils.MissingStructFields(arg, []string{utils.ID}); len(missing) != 0 { //Params missing return utils.NewErrMandatoryIeMissing(missing...) } @@ -46,13 +46,13 @@ func (apierSv1 *APIerSv1) GetAccountProfile(arg *utils.TenantIDWithAPIOpts, repl return nil } -// GetAccountProfileIDs returns list of action profile IDs registered for a tenant -func (apierSv1 *APIerSv1) GetAccountProfileIDs(args *utils.PaginatorWithTenant, actPrfIDs *[]string) error { +// GetAccountIDs returns list of action profile IDs registered for a tenant +func (apierSv1 *APIerSv1) GetAccountIDs(args *utils.PaginatorWithTenant, actPrfIDs *[]string) error { tnt := args.Tenant if tnt == utils.EmptyString { tnt = apierSv1.Config.GeneralCfg().DefaultTenant } - prfx := utils.AccountProfilePrefix + tnt + utils.ConcatenatedKeySep + prfx := utils.AccountPrefix + tnt + utils.ConcatenatedKeySep keys, err := apierSv1.DataManager.DataDB().GetKeysForPrefix(prfx) if err != nil { return err @@ -68,15 +68,15 @@ func (apierSv1 *APIerSv1) GetAccountProfileIDs(args *utils.PaginatorWithTenant, return nil } -// GetAccountProfileIDsCount sets in reply var the total number of AccountProfileIDs registered for a tenant -// returns ErrNotFound in case of 0 AccountProfileIDs -func (apierSv1 *APIerSv1) GetAccountProfileIDsCount(args *utils.TenantWithAPIOpts, reply *int) (err error) { +// GetAccountIDsCount sets in reply var the total number of AccountIDs registered for a tenant +// returns ErrNotFound in case of 0 AccountIDs +func (apierSv1 *APIerSv1) GetAccountIDsCount(args *utils.TenantWithAPIOpts, reply *int) (err error) { tnt := args.Tenant if tnt == utils.EmptyString { tnt = apierSv1.Config.GeneralCfg().DefaultTenant } var keys []string - prfx := utils.AccountProfilePrefix + tnt + utils.ConcatenatedKeySep + prfx := utils.AccountPrefix + tnt + utils.ConcatenatedKeySep if keys, err = apierSv1.DataManager.DataDB().GetKeysForPrefix(prfx); err != nil { return err } @@ -87,8 +87,8 @@ func (apierSv1 *APIerSv1) GetAccountProfileIDsCount(args *utils.TenantWithAPIOpt return } -//SetAccountProfile add/update a new Account Profile -func (apierSv1 *APIerSv1) SetAccountProfile(extAp *utils.APIAccountWithOpts, reply *string) error { +//SetAccount add/update a new Account +func (apierSv1 *APIerSv1) SetAccount(extAp *utils.APIAccountWithOpts, reply *string) error { if missing := utils.MissingStructFields(extAp.APIAccount, []string{utils.ID}); len(missing) != 0 { return utils.NewErrMandatoryIeMissing(missing...) } @@ -102,16 +102,16 @@ func (apierSv1 *APIerSv1) SetAccountProfile(extAp *utils.APIAccountWithOpts, rep if err := apierSv1.DataManager.SetAccount(ap, true); err != nil { return utils.APIErrorHandler(err) } - //generate a loadID for CacheAccountProfiles and store it in database - if err := apierSv1.DataManager.SetLoadIDs(map[string]int64{utils.CacheAccountProfiles: time.Now().UnixNano()}); err != nil { + //generate a loadID for CacheAccounts and store it in database + if err := apierSv1.DataManager.SetLoadIDs(map[string]int64{utils.CacheAccounts: time.Now().UnixNano()}); err != nil { return utils.APIErrorHandler(err) } *reply = utils.OK return nil } -// RemoveAccountProfile remove a specific Account Profile -func (apierSv1 *APIerSv1) RemoveAccountProfile(arg *utils.TenantIDWithAPIOpts, reply *string) error { +// RemoveAccount remove a specific Account +func (apierSv1 *APIerSv1) RemoveAccount(arg *utils.TenantIDWithAPIOpts, reply *string) error { if missing := utils.MissingStructFields(arg, []string{utils.ID}); len(missing) != 0 { //Params missing return utils.NewErrMandatoryIeMissing(missing...) } @@ -123,8 +123,8 @@ func (apierSv1 *APIerSv1) RemoveAccountProfile(arg *utils.TenantIDWithAPIOpts, r utils.NonTransactional, true); err != nil { return utils.APIErrorHandler(err) } - //generate a loadID for CacheAccountProfiles and store it in database - if err := apierSv1.DataManager.SetLoadIDs(map[string]int64{utils.CacheAccountProfiles: time.Now().UnixNano()}); err != nil { + //generate a loadID for CacheAccounts and store it in database + if err := apierSv1.DataManager.SetLoadIDs(map[string]int64{utils.CacheAccounts: time.Now().UnixNano()}); err != nil { return utils.APIErrorHandler(err) } *reply = utils.OK @@ -153,10 +153,10 @@ func (aSv1 *AccountSv1) Ping(ign *utils.CGREvent, reply *string) error { return nil } -// AccountProfilesForEvent returns the matching AccountProfile for Event -func (aSv1 *AccountSv1) AccountProfilesForEvent(args *utils.ArgsAccountsForEvent, +// AccountsForEvent returns the matching Account for Event +func (aSv1 *AccountSv1) AccountsForEvent(args *utils.ArgsAccountsForEvent, aps *[]*utils.Account) (err error) { - return aSv1.aS.V1AccountProfilesForEvent(args, aps) + return aSv1.aS.V1AccountsForEvent(args, aps) } // MaxAbstracts returns the maximum abstracts for the event, based on matching Account diff --git a/apier/v1/api_interfaces.go b/apier/v1/api_interfaces.go index a1f89b4a5..648e458a6 100644 --- a/apier/v1/api_interfaces.go +++ b/apier/v1/api_interfaces.go @@ -219,9 +219,9 @@ type ReplicatorSv1Interface interface { SetIndexes(args *utils.SetIndexesArg, reply *string) error RemoveIndexes(args *utils.GetIndexesArg, reply *string) error - GetAccountProfile(tntID *utils.TenantIDWithAPIOpts, reply *utils.Account) error - SetAccountProfile(args *utils.AccountWithAPIOpts, reply *string) error - RemoveAccountProfile(args *utils.TenantIDWithAPIOpts, reply *string) error + GetAccount(tntID *utils.TenantIDWithAPIOpts, reply *utils.Account) error + SetAccount(args *utils.AccountWithAPIOpts, reply *string) error + RemoveAccount(args *utils.TenantIDWithAPIOpts, reply *string) error GetActionProfile(tntID *utils.TenantIDWithAPIOpts, reply *engine.ActionProfile) error SetActionProfile(args *engine.ActionProfileWithAPIOpts, reply *string) error @@ -236,7 +236,7 @@ type ActionSv1Interface interface { type AccountSv1Interface interface { Ping(ign *utils.CGREvent, reply *string) error - AccountProfilesForEvent(args *utils.ArgsAccountsForEvent, aps *[]*utils.Account) error + AccountsForEvent(args *utils.ArgsAccountsForEvent, aps *[]*utils.Account) error MaxAbstracts(args *utils.ArgsAccountsForEvent, eEc *utils.ExtEventCharges) error DebitAbstracts(args *utils.ArgsAccountsForEvent, eEc *utils.ExtEventCharges) error ActionSetBalance(args *utils.ArgsActSetBalance, eEc *string) (err error) diff --git a/apier/v1/apier.go b/apier/v1/apier.go index 98f99bcca..809dd8bb8 100644 --- a/apier/v1/apier.go +++ b/apier/v1/apier.go @@ -666,7 +666,7 @@ func (apierSv1 *APIerSv1) ExportToFolder(arg *utils.ArgExportToFolder, reply *st if len(arg.Items) == 0 { arg.Items = []string{utils.MetaAttributes, utils.MetaChargers, utils.MetaDispatchers, utils.MetaDispatcherHosts, utils.MetaFilters, utils.MetaResources, utils.MetaStats, - utils.MetaRoutes, utils.MetaThresholds, utils.MetaRateProfiles, utils.MetaActionProfiles, utils.MetaAccountProfiles} + utils.MetaRoutes, utils.MetaThresholds, utils.MetaRateProfiles, utils.MetaActionProfiles, utils.MetaAccounts} } if _, err := os.Stat(arg.Path); os.IsNotExist(err) { os.Mkdir(arg.Path, os.ModeDir) @@ -1088,8 +1088,8 @@ func (apierSv1 *APIerSv1) ExportToFolder(arg *utils.ArgExportToFolder, reply *st } } csvWriter.Flush() - case utils.MetaAccountProfiles: - prfx := utils.AccountProfilePrefix + case utils.MetaAccounts: + prfx := utils.AccountPrefix keys, err := apierSv1.DataManager.DataDB().GetKeysForPrefix(prfx) if err != nil { return err @@ -1097,7 +1097,7 @@ func (apierSv1 *APIerSv1) ExportToFolder(arg *utils.ArgExportToFolder, reply *st if len(keys) == 0 { continue } - f, err := os.Create(path.Join(arg.Path, utils.AccountProfilesCsv)) + f, err := os.Create(path.Join(arg.Path, utils.AccountsCsv)) if err != nil { return err } diff --git a/apier/v1/dispatcher.go b/apier/v1/dispatcher.go index 9777ee081..a23d5c635 100755 --- a/apier/v1/dispatcher.go +++ b/apier/v1/dispatcher.go @@ -1058,19 +1058,19 @@ func (dS *DispatcherReplicatorSv1) RemoveIndexes(args *utils.GetIndexesArg, repl return dS.dS.ReplicatorSv1RemoveIndexes(args, reply) } -// GetAccountProfile . -func (dS *DispatcherReplicatorSv1) GetAccountProfile(tntID *utils.TenantIDWithAPIOpts, reply *utils.Account) error { - return dS.dS.ReplicatorSv1GetAccountProfile(tntID, reply) +// GetAccount . +func (dS *DispatcherReplicatorSv1) GetAccount(tntID *utils.TenantIDWithAPIOpts, reply *utils.Account) error { + return dS.dS.ReplicatorSv1GetAccount(tntID, reply) } -// SetAccountProfile . -func (dS *DispatcherReplicatorSv1) SetAccountProfile(args *utils.AccountWithAPIOpts, reply *string) error { - return dS.dS.ReplicatorSv1SetAccountProfile(args, reply) +// SetAccount . +func (dS *DispatcherReplicatorSv1) SetAccount(args *utils.AccountWithAPIOpts, reply *string) error { + return dS.dS.ReplicatorSv1SetAccount(args, reply) } -// RemoveAccountProfile . -func (dS *DispatcherReplicatorSv1) RemoveAccountProfile(args *utils.TenantIDWithAPIOpts, reply *string) error { - return dS.dS.ReplicatorSv1RemoveAccountProfile(args, reply) +// RemoveAccount . +func (dS *DispatcherReplicatorSv1) RemoveAccount(args *utils.TenantIDWithAPIOpts, reply *string) error { + return dS.dS.ReplicatorSv1RemoveAccount(args, reply) } // GetActionProfile . @@ -1141,8 +1141,8 @@ func (dR *DispatcherAccountSv1) Ping(args *utils.CGREvent, reply *string) error return dR.dR.AccountSv1Ping(args, reply) } -func (dR *DispatcherAccountSv1) AccountProfilesForEvent(args *utils.ArgsAccountsForEvent, aps *[]*utils.Account) error { - return dR.dR.AccountProfilesForEvent(args, aps) +func (dR *DispatcherAccountSv1) AccountsForEvent(args *utils.ArgsAccountsForEvent, aps *[]*utils.Account) error { + return dR.dR.AccountsForEvent(args, aps) } func (dR *DispatcherAccountSv1) MaxAbstracts(args *utils.ArgsAccountsForEvent, eEc *utils.ExtEventCharges) error { diff --git a/apier/v1/filter_indexes.go b/apier/v1/filter_indexes.go index 6f4232b97..818008c7f 100644 --- a/apier/v1/filter_indexes.go +++ b/apier/v1/filter_indexes.go @@ -61,8 +61,8 @@ func (apierSv1 *APIerSv1) RemoveFilterIndexes(arg *AttrRemFilterIndexes, reply * arg.ItemType = utils.CacheResourceFilterIndexes case utils.MetaChargers: arg.ItemType = utils.CacheChargerFilterIndexes - case utils.MetaAccountProfiles: - arg.ItemType = utils.CacheAccountProfilesFilterIndexes + case utils.MetaAccounts: + arg.ItemType = utils.CacheAccountsFilterIndexes case utils.MetaActionProfiles: arg.ItemType = utils.CacheActionProfilesFilterIndexes case utils.MetaRateProfiles: @@ -116,8 +116,8 @@ func (apierSv1 *APIerSv1) GetFilterIndexes(arg *AttrGetFilterIndexes, reply *[]s arg.ItemType = utils.CacheResourceFilterIndexes case utils.MetaChargers: arg.ItemType = utils.CacheChargerFilterIndexes - case utils.MetaAccountProfiles: - arg.ItemType = utils.CacheAccountProfilesFilterIndexes + case utils.MetaAccounts: + arg.ItemType = utils.CacheAccountsFilterIndexes case utils.MetaActionProfiles: arg.ItemType = utils.CacheActionProfilesFilterIndexes case utils.MetaRateProfiles: @@ -328,7 +328,7 @@ func (apierSv1 *APIerSv1) ComputeFilterIndexes(args *utils.ArgsComputeFilterInde } //Account Indexes if args.AccountS { - if args.AccountS, err = engine.ComputeIndexes(apierSv1.DataManager, tnt, args.Context, utils.CacheAccountProfilesFilterIndexes, + if args.AccountS, err = engine.ComputeIndexes(apierSv1.DataManager, tnt, args.Context, utils.CacheAccountsFilterIndexes, nil, transactionID, func(tnt, id, ctx string) (*[]string, error) { acp, e := apierSv1.DataManager.GetAccount(tnt, id) if e != nil { @@ -467,7 +467,7 @@ func (apierSv1 *APIerSv1) ComputeFilterIndexes(args *utils.ArgsComputeFilterInde } //Account Indexes if args.AccountS { - if err = apierSv1.DataManager.SetIndexes(utils.CacheAccountProfilesFilterIndexes, tnt, nil, true, transactionID); err != nil { + if err = apierSv1.DataManager.SetIndexes(utils.CacheAccountsFilterIndexes, tnt, nil, true, transactionID); err != nil { return } } @@ -578,8 +578,8 @@ func (apierSv1 *APIerSv1) ComputeFilterIndexIDs(args *utils.ArgsComputeFilterInd return utils.APIErrorHandler(err) } //Account Indexes - if _, err = engine.ComputeIndexes(apierSv1.DataManager, tnt, args.Context, utils.CacheAccountProfilesFilterIndexes, - &args.AccountProfileIDs, transactionID, func(tnt, id, ctx string) (*[]string, error) { + if _, err = engine.ComputeIndexes(apierSv1.DataManager, tnt, args.Context, utils.CacheAccountsFilterIndexes, + &args.AccountIDs, transactionID, func(tnt, id, ctx string) (*[]string, error) { acp, e := apierSv1.DataManager.GetAccount(tnt, id) if e != nil { return nil, e diff --git a/apier/v1/replicator.go b/apier/v1/replicator.go index 6ea0f8b01..924d4a09a 100644 --- a/apier/v1/replicator.go +++ b/apier/v1/replicator.go @@ -231,10 +231,10 @@ func (rplSv1 *ReplicatorSv1) GetActionProfile(tntID *utils.TenantIDWithAPIOpts, return nil } -// GetAccountProfile is the remote method coresponding to the dataDb driver method -func (rplSv1 *ReplicatorSv1) GetAccountProfile(tntID *utils.TenantIDWithAPIOpts, reply *utils.Account) error { - engine.UpdateReplicationFilters(utils.AccountProfilePrefix, tntID.TenantID.TenantID(), utils.IfaceAsString(tntID.APIOpts[utils.RemoteHostOpt])) - rcv, err := rplSv1.dm.DataDB().GetAccountProfileDrv(tntID.Tenant, tntID.ID) +// GetAccount is the remote method coresponding to the dataDb driver method +func (rplSv1 *ReplicatorSv1) GetAccount(tntID *utils.TenantIDWithAPIOpts, reply *utils.Account) error { + engine.UpdateReplicationFilters(utils.AccountPrefix, tntID.TenantID.TenantID(), utils.IfaceAsString(tntID.APIOpts[utils.RemoteHostOpt])) + rcv, err := rplSv1.dm.DataDB().GetAccountDrv(tntID.Tenant, tntID.ID) if err != nil { return err } @@ -485,13 +485,13 @@ func (rplSv1 *ReplicatorSv1) SetActionProfile(acp *engine.ActionProfileWithAPIOp return } -// SetAccountProfile is the replication method coresponding to the dataDb driver method -func (rplSv1 *ReplicatorSv1) SetAccountProfile(acp *utils.AccountWithAPIOpts, reply *string) (err error) { - if err = rplSv1.dm.DataDB().SetAccountProfileDrv(acp.Account); err != nil { +// SetAccount is the replication method coresponding to the dataDb driver method +func (rplSv1 *ReplicatorSv1) SetAccount(acp *utils.AccountWithAPIOpts, reply *string) (err error) { + if err = rplSv1.dm.DataDB().SetAccountDrv(acp.Account); err != nil { return } if err = rplSv1.v1.CallCache(utils.IfaceAsString(acp.APIOpts[utils.CacheOpt]), - acp.Tenant, utils.CacheAccountProfiles, acp.TenantID(), &acp.FilterIDs, nil, acp.APIOpts); err != nil { + acp.Tenant, utils.CacheAccounts, acp.TenantID(), &acp.FilterIDs, nil, acp.APIOpts); err != nil { return } *reply = utils.OK @@ -727,13 +727,13 @@ func (rplSv1 *ReplicatorSv1) RemoveActionProfile(args *utils.TenantIDWithAPIOpts return } -// RemoveAccountProfile is the replication method coresponding to the dataDb driver method -func (rplSv1 *ReplicatorSv1) RemoveAccountProfile(args *utils.TenantIDWithAPIOpts, reply *string) (err error) { - if err = rplSv1.dm.DataDB().RemoveAccountProfileDrv(args.Tenant, args.ID); err != nil { +// RemoveAccount is the replication method coresponding to the dataDb driver method +func (rplSv1 *ReplicatorSv1) RemoveAccount(args *utils.TenantIDWithAPIOpts, reply *string) (err error) { + if err = rplSv1.dm.DataDB().RemoveAccountDrv(args.Tenant, args.ID); err != nil { return } if err = rplSv1.v1.CallCache(utils.IfaceAsString(args.APIOpts[utils.CacheOpt]), - args.Tenant, utils.CacheAccountProfiles, args.TenantID.TenantID(), nil, nil, args.APIOpts); err != nil { + args.Tenant, utils.CacheAccounts, args.TenantID.TenantID(), nil, nil, args.APIOpts); err != nil { return } *reply = utils.OK diff --git a/apier/v1/tpaccountprofiles.go b/apier/v1/tpaccountprofiles.go index 778cf575e..3edb861ac 100644 --- a/apier/v1/tpaccountprofiles.go +++ b/apier/v1/tpaccountprofiles.go @@ -22,8 +22,8 @@ import ( "github.com/cgrates/cgrates/utils" ) -// SetTPAccountProfile creates a new TPAccountProfile within a tariff plan -func (apierSv1 *APIerSv1) SetTPAccountProfile(attrs *utils.TPAccount, reply *string) error { +// SetTPAccount creates a new TPAccount within a tariff plan +func (apierSv1 *APIerSv1) SetTPAccount(attrs *utils.TPAccount, reply *string) error { if missing := utils.MissingStructFields(attrs, []string{utils.TPid, utils.ID}); len(missing) != 0 { return utils.NewErrMandatoryIeMissing(missing...) } @@ -37,8 +37,8 @@ func (apierSv1 *APIerSv1) SetTPAccountProfile(attrs *utils.TPAccount, reply *str return nil } -// GetTPAccountProfile queries specific TPAccountProfile on tariff plan -func (apierSv1 *APIerSv1) GetTPAccountProfile(attr *utils.TPTntID, reply *utils.TPAccount) error { +// GetTPAccount queries specific TPAccount on tariff plan +func (apierSv1 *APIerSv1) GetTPAccount(attr *utils.TPTntID, reply *utils.TPAccount) error { if missing := utils.MissingStructFields(attr, []string{utils.TPid, utils.ID}); len(missing) != 0 { //Params missing return utils.NewErrMandatoryIeMissing(missing...) } @@ -61,12 +61,12 @@ type AttrGetTPAccountIDs struct { utils.PaginatorWithSearch } -// GetTPRouteProfileIDs queries TPAccountProfiles identities on specific tariff plan. -func (apierSv1 *APIerSv1) GetTPAccountProfileIDs(attrs *AttrGetTPAccountIDs, reply *[]string) error { +// GetTPRouteIDs queries TPAccounts identities on specific tariff plan. +func (apierSv1 *APIerSv1) GetTPAccountIDs(attrs *AttrGetTPAccountIDs, reply *[]string) error { if missing := utils.MissingStructFields(attrs, []string{utils.TPid}); len(missing) != 0 { //Params missing return utils.NewErrMandatoryIeMissing(missing...) } - ids, err := apierSv1.StorDb.GetTpTableIds(attrs.TPid, utils.TBLTPAccountProfiles, + ids, err := apierSv1.StorDb.GetTpTableIds(attrs.TPid, utils.TBLTPAccounts, []string{"tenant", "id"}, nil, &attrs.PaginatorWithSearch) if err != nil { if err.Error() != utils.ErrNotFound.Error() { @@ -78,15 +78,15 @@ func (apierSv1 *APIerSv1) GetTPAccountProfileIDs(attrs *AttrGetTPAccountIDs, rep return nil } -// RemoveTPAccountProfile removes specific TPAccountProfile on Tariff plan -func (apierSv1 *APIerSv1) RemoveTPAccountProfile(attrs *utils.TPTntID, reply *string) error { +// RemoveTPAccount removes specific TPAccount on Tariff plan +func (apierSv1 *APIerSv1) RemoveTPAccount(attrs *utils.TPTntID, reply *string) error { if missing := utils.MissingStructFields(attrs, []string{utils.TPid, utils.ID}); len(missing) != 0 { //Params missing return utils.NewErrMandatoryIeMissing(missing...) } if attrs.Tenant == utils.EmptyString { attrs.Tenant = apierSv1.Config.GeneralCfg().DefaultTenant } - if err := apierSv1.StorDb.RemTpData(utils.TBLTPAccountProfiles, attrs.TPid, + if err := apierSv1.StorDb.RemTpData(utils.TBLTPAccounts, attrs.TPid, map[string]string{utils.TenantCfg: attrs.Tenant, utils.IDCfg: attrs.ID}); err != nil { return utils.NewErrServerError(err) } diff --git a/config/config_defaults.go b/config/config_defaults.go index fb7aa25b2..5460c7c46 100644 --- a/config/config_defaults.go +++ b/config/config_defaults.go @@ -103,7 +103,6 @@ const CGRATES_CFG_JSON = ` "*dispatcher_hosts":{"remote":false, "replicate":false}, "*rate_profiles":{"remote":false, "replicate":false}, "*action_profiles":{"remote":false, "replicate":false}, - "*account_profiles":{"remote":false, "replicate":false}, "*load_ids":{"remote":false, "replicate":false}, "*indexes":{"remote":false, "replicate":false}, }, @@ -155,7 +154,7 @@ const CGRATES_CFG_JSON = ` "*tp_dispatcher_hosts":{"remote":false, "replicate":false}, "*tp_rate_profiles":{"remote":false, "replicate":false}, "*tp_action_profiles":{"remote":false, "replicate":false}, - "*tp_account_profiles":{"remote":false, "replicate":false}, + "*tp_accounts":{"remote":false, "replicate":false}, }, }, @@ -229,7 +228,7 @@ const CGRATES_CFG_JSON = ` "*dispatcher_hosts": {"limit": -1, "ttl": "", "static_ttl": false, "precache": false, "replicate": false}, // control dispatcher hosts caching "*rate_profiles": {"limit": -1, "ttl": "", "static_ttl": false, "precache": false, "replicate": false}, // control rate profile caching "*action_profiles": {"limit": -1, "ttl": "", "static_ttl": false, "precache": false, "replicate": false}, // control action profile caching - "*account_profiles": {"limit": -1, "ttl": "", "static_ttl": false, "precache": false, "replicate": false}, // control account profile caching + "*accounts": {"limit": -1, "ttl": "", "static_ttl": false, "precache": false, "replicate": false}, // control account profile caching "*resource_filter_indexes" : {"limit": -1, "ttl": "", "static_ttl": false, "replicate": false}, // control resource filter indexes caching "*stat_filter_indexes" : {"limit": -1, "ttl": "", "static_ttl": false, "replicate": false}, // control stat filter indexes caching "*threshold_filter_indexes" : {"limit": -1, "ttl": "", "static_ttl": false, "replicate": false}, // control threshold filter indexes caching @@ -240,7 +239,7 @@ const CGRATES_CFG_JSON = ` "*rate_profile_filter_indexes" : {"limit": -1, "ttl": "", "static_ttl": false, "replicate": false}, // control rate profile filter indexes caching "*rate_filter_indexes" : {"limit": -1, "ttl": "", "static_ttl": false, "replicate": false}, // control rate filter indexes caching "*action_profile_filter_indexes" : {"limit": -1, "ttl": "", "static_ttl": false, "replicate": false}, // control action profile filter indexes caching - "*account_profile_filter_indexes" : {"limit": -1, "ttl": "", "static_ttl": false, "replicate": false}, // control coount profile filter indexes caching + "*account_filter_indexes" : {"limit": -1, "ttl": "", "static_ttl": false, "replicate": false}, // control coount profile filter indexes caching "*reverse_filter_indexes" : {"limit": -1, "ttl": "", "static_ttl": false, "replicate": false}, // control reverse filter indexes caching used only for set and remove filters "*dispatcher_routes": {"limit": -1, "ttl": "", "static_ttl": false, "replicate": false}, // control dispatcher routes caching "*dispatcher_loads": {"limit": -1, "ttl": "", "static_ttl": false, "replicate": false}, // control dispatcher load( in case of *ratio ConnParams is present) @@ -277,7 +276,7 @@ const CGRATES_CFG_JSON = ` "*tp_dispatcher_hosts":{"limit": -1, "ttl": "", "static_ttl": false, "replicate": false}, "*tp_rate_profiles":{"limit": -1, "ttl": "", "static_ttl": false, "replicate": false}, "*tp_action_profiles":{"limit": -1, "ttl": "", "static_ttl": false, "replicate": false}, - "*tp_account_profiles":{"limit": -1, "ttl": "", "static_ttl": false, "replicate": false}, + "*tp_accounts":{"limit": -1, "ttl": "", "static_ttl": false, "replicate": false}, }, "replication_conns": [], }, @@ -785,8 +784,8 @@ const CGRATES_CFG_JSON = ` ], }, { - "type": "*account_profiles", // data source type - "file_name": "AccountProfiles.csv", // file name in the tp_in_dir + "type": "*accounts", // data source type + "file_name": "Accounts.csv", // file name in the tp_in_dir "fields": [ {"tag": "Tenant", "path": "Tenant", "type": "*variable", "value": "~*req.0", "mandatory": true}, {"tag": "ID", "path": "ID", "type": "*variable", "value": "~*req.1", "mandatory": true}, diff --git a/console/accounts_profile.go b/console/accounts_profile.go index 0294c21f5..e7784afb1 100644 --- a/console/accounts_profile.go +++ b/console/accounts_profile.go @@ -25,7 +25,7 @@ import ( func init() { c := &CmdGetAccountsProfile{ name: "accounts_profile", - rpcMethod: utils.APIerSv1GetAccountProfile, + rpcMethod: utils.APIerSv1GetAccount, rpcParams: &utils.TenantIDWithAPIOpts{}, } commands[c.Name()] = c diff --git a/console/accounts_profile_ids.go b/console/accounts_profile_ids.go index 658cd3e67..6292ab909 100644 --- a/console/accounts_profile_ids.go +++ b/console/accounts_profile_ids.go @@ -25,7 +25,7 @@ import ( func init() { c := &CmdGetAccountsProfileIDs{ name: "accounts_profile_ids", - rpcMethod: utils.APIerSv1GetAccountProfileIDs, + rpcMethod: utils.APIerSv1GetAccountIDs, rpcParams: &utils.PaginatorWithTenant{}, } commands[c.Name()] = c diff --git a/console/accounts_profile_rem.go b/console/accounts_profile_rem.go index dfae57eb0..e1ca1d75a 100644 --- a/console/accounts_profile_rem.go +++ b/console/accounts_profile_rem.go @@ -23,7 +23,7 @@ import "github.com/cgrates/cgrates/utils" func init() { c := &CmdRemoveAccountsProfile{ name: "accounts_profile_remove", - rpcMethod: utils.APIerSv1RemoveAccountProfile, + rpcMethod: utils.APIerSv1RemoveAccount, rpcParams: &utils.TenantIDWithAPIOpts{}, } commands[c.Name()] = c diff --git a/console/accounts_profile_set.go b/console/accounts_profile_set.go index 68eef8b97..d22d9d9d3 100644 --- a/console/accounts_profile_set.go +++ b/console/accounts_profile_set.go @@ -25,7 +25,7 @@ import ( func init() { c := &CmdSetAccountProfile{ name: "accounts_profile_set", - rpcMethod: utils.APIerSv1SetAccountProfile, + rpcMethod: utils.APIerSv1SetAccount, rpcParams: &utils.APIAccountWithOpts{}, } commands[c.Name()] = c diff --git a/data/conf/cgrates/cgrates.json b/data/conf/cgrates/cgrates.json index d0120d353..66bb2448e 100755 --- a/data/conf/cgrates/cgrates.json +++ b/data/conf/cgrates/cgrates.json @@ -799,8 +799,8 @@ // ], // }, // { -// "type": "*account_profiles", // data source type -// "file_name": "AccountProfiles.csv", // file name in the tp_in_dir +// "type": "*accounts", // data source type +// "file_name": "Accounts.csv", // file name in the tp_in_dir // "fields": [ // {"tag": "Tenant", "path": "Tenant", "type": "*variable", "value": "~*req.0", "mandatory": true}, // {"tag": "ID", "path": "ID", "type": "*variable", "value": "~*req.1", "mandatory": true}, diff --git a/data/tariffplans/dispatchers/Attributes.csv b/data/tariffplans/dispatchers/Attributes.csv index 549968fc8..0f52420c7 100644 --- a/data/tariffplans/dispatchers/Attributes.csv +++ b/data/tariffplans/dispatchers/Attributes.csv @@ -20,7 +20,7 @@ cgrates.org,ATTR_API_PSE_AUTH,*auth,*string:~*req.ApiKey:pse12345,,,*req.APIMeth cgrates.org,ATTR_API_CFG_AUTH,*auth,*string:~*req.ApiKey:cfg12345,,,*req.APIMethods,*constant,ConfigSv1.GetConfig&ConfigSv1.ReloadConfig,false,20 cgrates.org,ATTR_API_APIER_AUTH,*auth,*string:~*req.ApiKey:apier12345,,,*req.APIMethods,*constant,APIerSv1.GetAttributeProfile&APIerSv1.SetAttributeProfile,false,20 cgrates.org,ATTR_API_RALS_AUTH,*auth,*string:~*req.ApiKey:rals12345,,,*req.APIMethods,*constant,RALsV1.Ping&RALsV1.GetRatingPlansCost,false,20 -cgrates.org,ATTR_API_REPLICATOR_AUTH,*auth,*string:~*req.ApiKey:repl12345,,,*req.APIMethods,*constant,ReplicatorSv1.Ping&ReplicatorSv1.GetAccount&ReplicatorSv1.SetAccount&ReplicatorSv1.RemoveAccount&ReplicatorSv1.GetRouteProfile&ReplicatorSv1.SetRouteProfile&ReplicatorSv1.RemoveRouteProfile&ReplicatorSv1.GetAttributeProfile&ReplicatorSv1.SetAttributeProfile&ReplicatorSv1.RemoveAttributeProfile&ReplicatorSv1.SetChargerProfile&ReplicatorSv1.GetChargerProfile&ReplicatorSv1.RemoveChargerProfile&ReplicatorSv1.GetDispatcherProfile&ReplicatorSv1.SetDispatcherProfile&ReplicatorSv1.RemoveDispatcherProfile&ReplicatorSv1.GetDispatcherHost&ReplicatorSv1.SetDispatcherHost&ReplicatorSv1.RemoveDispatcherHost&ReplicatorSv1.GetFilter&ReplicatorSv1.SetFilter&ReplicatorSv1.RemoveFilter&ReplicatorSv1.GetThreshold&ReplicatorSv1.SetThreshold&ReplicatorSv1.RemoveThreshold&ReplicatorSv1.GetStatQueue&ReplicatorSv1.SetStatQueue&ReplicatorSv1.RemoveStatQueue&ReplicatorSv1.GetResource&ReplicatorSv1.SetResource&ReplicatorSv1.RemoveResource&ReplicatorSv1.GetResourceProfile&ReplicatorSv1.SetResourceProfile&ReplicatorSv1.RemoveResourceProfile&ReplicatorSv1.GetStatQueueProfile&ReplicatorSv1.SetStatQueueProfile&ReplicatorSv1.RemoveStatQueueProfile&ReplicatorSv1.GetThresholdProfile&ReplicatorSv1.SetThresholdProfile&ReplicatorSv1.RemoveThresholdProfile&ReplicatorSv1.GetTiming&ReplicatorSv1.SetTiming&ReplicatorSv1.RemoveTiming&ReplicatorSv1.GetActionTriggers&ReplicatorSv1.SetActionTriggers&ReplicatorSv1.RemoveActionTriggers&ReplicatorSv1.SetSharedGroup&ReplicatorSv1.GetSharedGroup&ReplicatorSv1.RemoveSharedGroup&ReplicatorSv1.SetActions&ReplicatorSv1.GetActions&ReplicatorSv1.RemoveActions&ReplicatorSv1.SetActionPlan&ReplicatorSv1.GetActionPlan&ReplicatorSv1.RemoveActionPlan&ReplicatorSv1.SetAccountActionPlans&ReplicatorSv1.GetAccountActionPlans&ReplicatorSv1.RemAccountActionPlans&ReplicatorSv1.SetRatingPlan&ReplicatorSv1.GetRatingPlan&ReplicatorSv1.RemoveRatingPlan&ReplicatorSv1.SetRatingProfile&ReplicatorSv1.GetRatingProfile&ReplicatorSv1.RemoveRatingProfile&ReplicatorSv1.SetDestination&ReplicatorSv1.GetDestination&ReplicatorSv1.RemoveDestination&ReplicatorSv1.SetLoadIDs&ReplicatorSv1.GetItemLoadIDs&ReplicatorSv1.SetRateProfile&ReplicatorSv1.GetRateProfile&ReplicatorSv1.RemoveRateProfile&ReplicatorSv1.SetAccountProfile&ReplicatorSv1.GetAccountProfile&ReplicatorSv1.RemoveAccountProfile&ReplicatorSv1.SetActionProfile&ReplicatorSv1.GetActionProfile&ReplicatorSv1.RemoveActionProfile,false,20 +cgrates.org,ATTR_API_REPLICATOR_AUTH,*auth,*string:~*req.ApiKey:repl12345,,,*req.APIMethods,*constant,ReplicatorSv1.Ping&ReplicatorSv1.GetAccount&ReplicatorSv1.SetAccount&ReplicatorSv1.RemoveAccount&ReplicatorSv1.GetRouteProfile&ReplicatorSv1.SetRouteProfile&ReplicatorSv1.RemoveRouteProfile&ReplicatorSv1.GetAttributeProfile&ReplicatorSv1.SetAttributeProfile&ReplicatorSv1.RemoveAttributeProfile&ReplicatorSv1.SetChargerProfile&ReplicatorSv1.GetChargerProfile&ReplicatorSv1.RemoveChargerProfile&ReplicatorSv1.GetDispatcherProfile&ReplicatorSv1.SetDispatcherProfile&ReplicatorSv1.RemoveDispatcherProfile&ReplicatorSv1.GetDispatcherHost&ReplicatorSv1.SetDispatcherHost&ReplicatorSv1.RemoveDispatcherHost&ReplicatorSv1.GetFilter&ReplicatorSv1.SetFilter&ReplicatorSv1.RemoveFilter&ReplicatorSv1.GetThreshold&ReplicatorSv1.SetThreshold&ReplicatorSv1.RemoveThreshold&ReplicatorSv1.GetStatQueue&ReplicatorSv1.SetStatQueue&ReplicatorSv1.RemoveStatQueue&ReplicatorSv1.GetResource&ReplicatorSv1.SetResource&ReplicatorSv1.RemoveResource&ReplicatorSv1.GetResourceProfile&ReplicatorSv1.SetResourceProfile&ReplicatorSv1.RemoveResourceProfile&ReplicatorSv1.GetStatQueueProfile&ReplicatorSv1.SetStatQueueProfile&ReplicatorSv1.RemoveStatQueueProfile&ReplicatorSv1.GetThresholdProfile&ReplicatorSv1.SetThresholdProfile&ReplicatorSv1.RemoveThresholdProfile&ReplicatorSv1.GetTiming&ReplicatorSv1.SetTiming&ReplicatorSv1.RemoveTiming&ReplicatorSv1.GetActionTriggers&ReplicatorSv1.SetActionTriggers&ReplicatorSv1.RemoveActionTriggers&ReplicatorSv1.SetSharedGroup&ReplicatorSv1.GetSharedGroup&ReplicatorSv1.RemoveSharedGroup&ReplicatorSv1.SetActions&ReplicatorSv1.GetActions&ReplicatorSv1.RemoveActions&ReplicatorSv1.SetActionPlan&ReplicatorSv1.GetActionPlan&ReplicatorSv1.RemoveActionPlan&ReplicatorSv1.SetAccountActionPlans&ReplicatorSv1.GetAccountActionPlans&ReplicatorSv1.RemAccountActionPlans&ReplicatorSv1.SetRatingPlan&ReplicatorSv1.GetRatingPlan&ReplicatorSv1.RemoveRatingPlan&ReplicatorSv1.SetRatingProfile&ReplicatorSv1.GetRatingProfile&ReplicatorSv1.RemoveRatingProfile&ReplicatorSv1.SetDestination&ReplicatorSv1.GetDestination&ReplicatorSv1.RemoveDestination&ReplicatorSv1.SetLoadIDs&ReplicatorSv1.GetItemLoadIDs&ReplicatorSv1.SetRateProfile&ReplicatorSv1.GetRateProfile&ReplicatorSv1.RemoveRateProfile&ReplicatorSv1.SetAccount&ReplicatorSv1.GetAccount&ReplicatorSv1.RemoveAccount&ReplicatorSv1.SetActionProfile&ReplicatorSv1.GetActionProfile&ReplicatorSv1.RemoveActionProfile,false,20 cgrates.org,ATTR_API_CDRSV2,*auth,*string:~*req.ApiKey:cdrsv212345,,,*req.APIMethods,*constant,CDRsV2.ProcessEvent&CDRsV2.StoreSessionCost,false,20 cgrates.org,ATTR_API_RATES_AUTH,*auth,*string:~*req.ApiKey:rPrf12345,,,*req.APIMethods,*constant,RateSv1.Ping&RateSv1.CostForEvent,false,20 cgrates.org,ATTR_API_CORE_AUTH,*auth,*string:~*req.ApiKey:core12345,,,*req.APIMethods,*constant,CoreSv1.Status&CoreSv1.Ping&CoreSv1.Sleep,false,20 diff --git a/dispatchers/accounts.go b/dispatchers/accounts.go index a932e4552..ebca629b9 100644 --- a/dispatchers/accounts.go +++ b/dispatchers/accounts.go @@ -38,18 +38,18 @@ func (dS *DispatcherService) AccountSv1Ping(args *utils.CGREvent, rpl *string) ( return dS.Dispatch(args, utils.MetaAccounts, utils.AccountSv1Ping, args, rpl) } -func (dS *DispatcherService) AccountProfilesForEvent(args *utils.ArgsAccountsForEvent, reply *[]*utils.Account) (err error) { +func (dS *DispatcherService) AccountsForEvent(args *utils.ArgsAccountsForEvent, reply *[]*utils.Account) (err error) { tnt := dS.cfg.GeneralCfg().DefaultTenant if args.CGREvent != nil && args.CGREvent.Tenant != utils.EmptyString { tnt = args.CGREvent.Tenant } if len(dS.cfg.DispatcherSCfg().AttributeSConns) != 0 { - if err = dS.authorize(utils.AccountSv1AccountProfilesForEvent, tnt, + if err = dS.authorize(utils.AccountSv1AccountsForEvent, tnt, utils.IfaceAsString(args.APIOpts[utils.OptsAPIKey]), args.CGREvent.Time); err != nil { return } } - return dS.Dispatch(args.CGREvent, utils.MetaAccounts, utils.AccountSv1AccountProfilesForEvent, args, reply) + return dS.Dispatch(args.CGREvent, utils.MetaAccounts, utils.AccountSv1AccountsForEvent, args, reply) } func (dS *DispatcherService) MaxAbstracts(args *utils.ArgsAccountsForEvent, reply *utils.ExtEventCharges) (err error) { diff --git a/dispatchers/replicator.go b/dispatchers/replicator.go index 235ece26a..b167b30b4 100644 --- a/dispatchers/replicator.go +++ b/dispatchers/replicator.go @@ -1008,13 +1008,13 @@ func (dS *DispatcherService) ReplicatorSv1RemoveIndexes(args *utils.GetIndexesAr }, utils.MetaReplicator, utils.ReplicatorSv1RemoveIndexes, args, reply) } -func (dS *DispatcherService) ReplicatorSv1GetAccountProfile(args *utils.TenantIDWithAPIOpts, reply *utils.Account) (err error) { +func (dS *DispatcherService) ReplicatorSv1GetAccount(args *utils.TenantIDWithAPIOpts, reply *utils.Account) (err error) { tnt := dS.cfg.GeneralCfg().DefaultTenant if args.TenantID != nil && args.TenantID.Tenant != utils.EmptyString { tnt = args.TenantID.Tenant } if len(dS.cfg.DispatcherSCfg().AttributeSConns) != 0 { - if err = dS.authorize(utils.ReplicatorSv1GetAccountProfile, tnt, + if err = dS.authorize(utils.ReplicatorSv1GetAccount, tnt, utils.IfaceAsString(args.APIOpts[utils.OptsAPIKey]), utils.TimePointer(time.Now())); err != nil { return } @@ -1023,16 +1023,16 @@ func (dS *DispatcherService) ReplicatorSv1GetAccountProfile(args *utils.TenantID Tenant: tnt, ID: args.ID, APIOpts: args.APIOpts, - }, utils.MetaReplicator, utils.ReplicatorSv1GetAccountProfile, args, reply) + }, utils.MetaReplicator, utils.ReplicatorSv1GetAccount, args, reply) } -func (dS *DispatcherService) ReplicatorSv1SetAccountProfile(args *utils.AccountWithAPIOpts, rpl *string) (err error) { +func (dS *DispatcherService) ReplicatorSv1SetAccount(args *utils.AccountWithAPIOpts, rpl *string) (err error) { if args == nil { args = &utils.AccountWithAPIOpts{} } args.Tenant = utils.FirstNonEmpty(args.Tenant, dS.cfg.GeneralCfg().DefaultTenant) if len(dS.cfg.DispatcherSCfg().AttributeSConns) != 0 { - if err = dS.authorize(utils.ReplicatorSv1SetAccountProfile, args.Tenant, + if err = dS.authorize(utils.ReplicatorSv1SetAccount, args.Tenant, utils.IfaceAsString(args.APIOpts[utils.OptsAPIKey]), utils.TimePointer(time.Now())); err != nil { return } @@ -1040,16 +1040,16 @@ func (dS *DispatcherService) ReplicatorSv1SetAccountProfile(args *utils.AccountW return dS.Dispatch(&utils.CGREvent{ Tenant: args.Tenant, APIOpts: args.APIOpts, - }, utils.MetaReplicator, utils.ReplicatorSv1SetAccountProfile, args, rpl) + }, utils.MetaReplicator, utils.ReplicatorSv1SetAccount, args, rpl) } -func (dS *DispatcherService) ReplicatorSv1RemoveAccountProfile(args *utils.TenantIDWithAPIOpts, rpl *string) (err error) { +func (dS *DispatcherService) ReplicatorSv1RemoveAccount(args *utils.TenantIDWithAPIOpts, rpl *string) (err error) { if args == nil { args = &utils.TenantIDWithAPIOpts{} } args.Tenant = utils.FirstNonEmpty(args.Tenant, dS.cfg.GeneralCfg().DefaultTenant) if len(dS.cfg.DispatcherSCfg().AttributeSConns) != 0 { - if err = dS.authorize(utils.ReplicatorSv1RemoveAccountProfile, args.Tenant, + if err = dS.authorize(utils.ReplicatorSv1RemoveAccount, args.Tenant, utils.IfaceAsString(args.APIOpts[utils.OptsAPIKey]), utils.TimePointer(time.Now())); err != nil { return } @@ -1057,5 +1057,5 @@ func (dS *DispatcherService) ReplicatorSv1RemoveAccountProfile(args *utils.Tenan return dS.Dispatch(&utils.CGREvent{ Tenant: args.Tenant, APIOpts: args.APIOpts, - }, utils.MetaReplicator, utils.ReplicatorSv1RemoveAccountProfile, args, rpl) + }, utils.MetaReplicator, utils.ReplicatorSv1RemoveAccount, args, rpl) } diff --git a/engine/datadbmock.go b/engine/datadbmock.go index 0a594cf12..d14f247f2 100644 --- a/engine/datadbmock.go +++ b/engine/datadbmock.go @@ -301,15 +301,15 @@ func (dbM *DataDBMock) RemoveActionProfileDrv(string, string) error { return utils.ErrNotImplemented } -func (dbM *DataDBMock) GetAccountProfileDrv(string, string) (*utils.Account, error) { +func (dbM *DataDBMock) GetAccountDrv(string, string) (*utils.Account, error) { return nil, utils.ErrNotImplemented } -func (dbM *DataDBMock) SetAccountProfileDrv(profile *utils.Account) error { +func (dbM *DataDBMock) SetAccountDrv(profile *utils.Account) error { return utils.ErrNotImplemented } -func (dbM *DataDBMock) RemoveAccountProfileDrv(string, string) error { +func (dbM *DataDBMock) RemoveAccountDrv(string, string) error { return utils.ErrNotImplemented } diff --git a/engine/datamanager.go b/engine/datamanager.go index f8e40530f..575466d7a 100644 --- a/engine/datamanager.go +++ b/engine/datamanager.go @@ -39,7 +39,7 @@ var ( utils.RateFilterIndexPrfx: {}, utils.ActionPlanIndexes: {}, utils.FilterIndexPrfx: {}, - utils.AccountProfileFilterIndexPrfx: {}, + utils.AccountFilterIndexPrfx: {}, } cachePrefixMap = utils.StringSet{ utils.DestinationPrefix: {}, @@ -267,12 +267,12 @@ func (dm *DataManager) CacheDataFromDB(prfx string, ids []string, mustBeCached b return } _, err = dm.GetIndexes(utils.CacheActionProfilesFilterIndexes, tntCtx, idxKey, false, true) - case utils.AccountProfileFilterIndexPrfx: + case utils.AccountFilterIndexPrfx: var tntCtx, idxKey string if tntCtx, idxKey, err = splitFilterIndex(dataID); err != nil { return } - _, err = dm.GetIndexes(utils.CacheAccountProfilesFilterIndexes, tntCtx, idxKey, false, true) + _, err = dm.GetIndexes(utils.CacheAccountsFilterIndexes, tntCtx, idxKey, false, true) case utils.FilterIndexPrfx: idx := strings.LastIndexByte(dataID, utils.InInFieldSep[0]) if idx < 0 { @@ -2836,18 +2836,18 @@ func (dm *DataManager) GetAccount(tenant, id string) (ap *utils.Account, err err err = utils.ErrNoDatabaseConn return } - ap, err = dm.dataDB.GetAccountProfileDrv(tenant, id) + ap, err = dm.dataDB.GetAccountDrv(tenant, id) if err != nil { - if itm := config.CgrConfig().DataDbCfg().Items[utils.MetaAccountProfiles]; err == utils.ErrNotFound && itm.Remote { + if itm := config.CgrConfig().DataDbCfg().Items[utils.MetaAccounts]; err == utils.ErrNotFound && itm.Remote { if err = dm.connMgr.Call(config.CgrConfig().DataDbCfg().RmtConns, nil, - utils.ReplicatorSv1GetAccountProfile, + utils.ReplicatorSv1GetAccount, &utils.TenantIDWithAPIOpts{ TenantID: &utils.TenantID{Tenant: tenant, ID: id}, APIOpts: utils.GenerateDBItemOpts(itm.APIKey, itm.RouteID, utils.EmptyString, utils.FirstNonEmpty(config.CgrConfig().DataDbCfg().RmtConnID, config.CgrConfig().GeneralCfg().NodeID)), }, &ap); err == nil { - err = dm.dataDB.SetAccountProfileDrv(ap) + err = dm.dataDB.SetAccountDrv(ap) } } if err != nil { @@ -2872,7 +2872,7 @@ func (dm *DataManager) SetAccount(ap *utils.Account, withIndex bool) (err error) if err != nil && err != utils.ErrNotFound { return err } - if err = dm.DataDB().SetAccountProfileDrv(ap); err != nil { + if err = dm.DataDB().SetAccountDrv(ap); err != nil { return err } if withIndex { @@ -2880,16 +2880,16 @@ func (dm *DataManager) SetAccount(ap *utils.Account, withIndex bool) (err error) if oldRpp != nil { oldFiltersIDs = &oldRpp.FilterIDs } - if err := updatedIndexes(dm, utils.CacheAccountProfilesFilterIndexes, ap.Tenant, + if err := updatedIndexes(dm, utils.CacheAccountsFilterIndexes, ap.Tenant, utils.EmptyString, ap.ID, oldFiltersIDs, ap.FilterIDs, false); err != nil { return err } } - if itm := config.CgrConfig().DataDbCfg().Items[utils.MetaAccountProfiles]; itm.Replicate { + if itm := config.CgrConfig().DataDbCfg().Items[utils.MetaAccounts]; itm.Replicate { err = replicate(dm.connMgr, config.CgrConfig().DataDbCfg().RplConns, config.CgrConfig().DataDbCfg().RplFiltered, - utils.AccountProfilePrefix, ap.TenantID(), // this are used to get the host IDs from cache - utils.ReplicatorSv1SetAccountProfile, + utils.AccountPrefix, ap.TenantID(), // this are used to get the host IDs from cache + utils.ReplicatorSv1SetAccount, &utils.AccountWithAPIOpts{ Account: ap, APIOpts: utils.GenerateDBItemOpts(itm.APIKey, itm.RouteID, @@ -2907,23 +2907,23 @@ func (dm *DataManager) RemoveAccount(tenant, id string, if err != nil && err != utils.ErrNotFound { return err } - if err = dm.DataDB().RemoveAccountProfileDrv(tenant, id); err != nil { + if err = dm.DataDB().RemoveAccountDrv(tenant, id); err != nil { return } if oldRpp == nil { return utils.ErrNotFound } if withIndex { - if err = removeItemFromFilterIndex(dm, utils.CacheAccountProfilesFilterIndexes, + if err = removeItemFromFilterIndex(dm, utils.CacheAccountsFilterIndexes, tenant, utils.EmptyString, id, oldRpp.FilterIDs); err != nil { return } } - if itm := config.CgrConfig().DataDbCfg().Items[utils.MetaAccountProfiles]; itm.Replicate { + if itm := config.CgrConfig().DataDbCfg().Items[utils.MetaAccounts]; itm.Replicate { replicate(dm.connMgr, config.CgrConfig().DataDbCfg().RplConns, config.CgrConfig().DataDbCfg().RplFiltered, - utils.AccountProfilePrefix, utils.ConcatenatedKey(tenant, id), // this are used to get the host IDs from cache - utils.ReplicatorSv1RemoveAccountProfile, + utils.AccountPrefix, utils.ConcatenatedKey(tenant, id), // this are used to get the host IDs from cache + utils.ReplicatorSv1RemoveAccount, &utils.TenantIDWithAPIOpts{ TenantID: &utils.TenantID{Tenant: tenant, ID: id}, APIOpts: utils.GenerateDBItemOpts(itm.APIKey, itm.RouteID, diff --git a/engine/dynamicdp.go b/engine/dynamicdp.go index 91815fb09..0183b96cd 100644 --- a/engine/dynamicdp.go +++ b/engine/dynamicdp.go @@ -91,7 +91,7 @@ func (dDP *dynamicDP) fieldAsInterface(fldPath []string) (val interface{}, err e // fieldNameType (~*accounts), accountID(1001) and queried part (BalanceMap.*monetary[0].Value) var account utils.Account - if err = connMgr.Call(dDP.apiConns, nil, utils.APIerSv1GetAccountProfile, + if err = connMgr.Call(dDP.apiConns, nil, utils.APIerSv1GetAccount, &utils.TenantIDWithAPIOpts{TenantID: &utils.TenantID{Tenant: dDP.tenant, ID: fldPath[1]}}, &account); err != nil { return } diff --git a/engine/libindex.go b/engine/libindex.go index 57c2efceb..e39023b07 100644 --- a/engine/libindex.go +++ b/engine/libindex.go @@ -693,7 +693,7 @@ func UpdateFilterIndex(dm *DataManager, oldFlt, newFlt *Filter) (err error) { }); err != nil && err != utils.ErrNotFound { return utils.APIErrorHandler(err) } - case utils.CacheAccountProfilesFilterIndexes: + case utils.CacheAccountsFilterIndexes: if err = removeFilterIndexesForFilter(dm, idxItmType, newFlt.Tenant, //remove the indexes for the filter removeIndexKeys, indx); err != nil { return diff --git a/engine/libtest.go b/engine/libtest.go index 2f38ad90f..536fb931f 100644 --- a/engine/libtest.go +++ b/engine/libtest.go @@ -160,7 +160,7 @@ cgrates.org,ONE_TIME_ACT,,,,,,,TOPUP_TEST_VOICE,,false,0s,*add_balance,,*balance cgrates.org,ONE_TIME_ACT,,,,,,,TOPUP_TEST_VOICE,,false,0s,*add_balance,,*balance.TestVoiceBalance2.Value,15m15s ` - AccountProfileCSVContent = ` + AccountCSVContent = ` #Tenant,ID,FilterIDs,ActivationInterval,Weights,Opts,BalanceID,BalanceFilterIDs,BalanceWeights,BalanceType,BalanceUnits,BalanceUnitFactors,BalanceOpts,BalanceCostIncrements,BalanceAttributeIDs,BalanceRateProfileIDs,ThresholdIDs cgrates.org,1001,,,;20,,MonetaryBalance,,;10,*monetary,14,fltr1&fltr2;100;fltr3;200,,fltr1&fltr2;1.3;2.3;3.3,attr1;attr2,,*none cgrates.org,1001,,,,,VoiceBalance,,;10,*voice,3600000000000,,,,,, @@ -370,53 +370,53 @@ func CallScript(scriptPath string, subcommand string, waitMs int) error { func GetDefaultEmptyCacheStats() map[string]*ltcache.CacheStats { return map[string]*ltcache.CacheStats{ - utils.MetaDefault: {}, - utils.CacheAttributeFilterIndexes: {}, - utils.CacheAttributeProfiles: {}, - utils.CacheChargerFilterIndexes: {}, - utils.CacheChargerProfiles: {}, - utils.CacheDispatcherFilterIndexes: {}, - utils.CacheDispatcherProfiles: {}, - utils.CacheDispatcherHosts: {}, - utils.CacheDispatcherRoutes: {}, - utils.CacheDispatcherLoads: {}, - utils.CacheDispatchers: {}, - utils.CacheDestinations: {}, - utils.CacheEventResources: {}, - utils.CacheFilters: {}, - utils.CacheResourceFilterIndexes: {}, - utils.CacheResourceProfiles: {}, - utils.CacheResources: {}, - utils.CacheReverseDestinations: {}, - utils.CacheRPCResponses: {}, - utils.CacheStatFilterIndexes: {}, - utils.CacheStatQueueProfiles: {}, - utils.CacheStatQueues: {}, - utils.CacheSTIR: {}, - utils.CacheRouteFilterIndexes: {}, - utils.CacheRouteProfiles: {}, - utils.CacheThresholdFilterIndexes: {}, - utils.CacheThresholdProfiles: {}, - utils.CacheThresholds: {}, - utils.CacheRateProfiles: {}, - utils.CacheRateProfilesFilterIndexes: {}, - utils.CacheRateFilterIndexes: {}, - utils.CacheTimings: {}, - utils.CacheDiameterMessages: {}, - utils.CacheClosedSessions: {}, - utils.CacheLoadIDs: {}, - utils.CacheRPCConnections: {}, - utils.CacheCDRIDs: {}, - utils.CacheUCH: {}, - utils.CacheEventCharges: {}, - utils.CacheReverseFilterIndexes: {}, - utils.MetaAPIBan: {}, - utils.CacheCapsEvents: {}, - utils.CacheActionProfiles: {}, - utils.CacheActionProfilesFilterIndexes: {}, - utils.CacheAccountProfiles: {}, - utils.CacheAccountProfilesFilterIndexes: {}, - utils.CacheReplicationHosts: {}, + utils.MetaDefault: {}, + utils.CacheAttributeFilterIndexes: {}, + utils.CacheAttributeProfiles: {}, + utils.CacheChargerFilterIndexes: {}, + utils.CacheChargerProfiles: {}, + utils.CacheDispatcherFilterIndexes: {}, + utils.CacheDispatcherProfiles: {}, + utils.CacheDispatcherHosts: {}, + utils.CacheDispatcherRoutes: {}, + utils.CacheDispatcherLoads: {}, + utils.CacheDispatchers: {}, + utils.CacheDestinations: {}, + utils.CacheEventResources: {}, + utils.CacheFilters: {}, + utils.CacheResourceFilterIndexes: {}, + utils.CacheResourceProfiles: {}, + utils.CacheResources: {}, + utils.CacheReverseDestinations: {}, + utils.CacheRPCResponses: {}, + utils.CacheStatFilterIndexes: {}, + utils.CacheStatQueueProfiles: {}, + utils.CacheStatQueues: {}, + utils.CacheSTIR: {}, + utils.CacheRouteFilterIndexes: {}, + utils.CacheRouteProfiles: {}, + utils.CacheThresholdFilterIndexes: {}, + utils.CacheThresholdProfiles: {}, + utils.CacheThresholds: {}, + utils.CacheRateProfiles: {}, + utils.CacheRateProfilesFilterIndexes: {}, + utils.CacheRateFilterIndexes: {}, + utils.CacheTimings: {}, + utils.CacheDiameterMessages: {}, + utils.CacheClosedSessions: {}, + utils.CacheLoadIDs: {}, + utils.CacheRPCConnections: {}, + utils.CacheCDRIDs: {}, + utils.CacheUCH: {}, + utils.CacheEventCharges: {}, + utils.CacheReverseFilterIndexes: {}, + utils.MetaAPIBan: {}, + utils.CacheCapsEvents: {}, + utils.CacheActionProfiles: {}, + utils.CacheActionProfilesFilterIndexes: {}, + utils.CacheAccounts: {}, + utils.CacheAccountsFilterIndexes: {}, + utils.CacheReplicationHosts: {}, utils.CacheVersions: {}, utils.CacheTBLTPTimings: {}, @@ -434,7 +434,7 @@ func GetDefaultEmptyCacheStats() map[string]*ltcache.CacheStats { utils.CacheTBLTPDispatcherHosts: {}, utils.CacheTBLTPRateProfiles: {}, utils.CacheTBLTPActionProfiles: {}, - utils.CacheTBLTPAccountProfiles: {}, + utils.CacheTBLTPAccounts: {}, } } diff --git a/engine/models.go b/engine/models.go index 99e68c7ad..7da12b567 100644 --- a/engine/models.go +++ b/engine/models.go @@ -406,5 +406,5 @@ type AccountMdl struct { } func (AccountMdl) TableName() string { - return utils.TBLTPAccountProfiles + return utils.TBLTPAccounts } diff --git a/engine/storage_csv.go b/engine/storage_csv.go index 14b1748ba..b223c6d16 100644 --- a/engine/storage_csv.go +++ b/engine/storage_csv.go @@ -105,7 +105,7 @@ func NewFileCSVStorage(sep rune, dataPath string) *CSVStorage { dispatcherhostsPaths := appendName(allFoldersPath, utils.DispatcherHostsCsv) rateProfilesFn := appendName(allFoldersPath, utils.RateProfilesCsv) actionProfilesFn := appendName(allFoldersPath, utils.ActionProfilesCsv) - accountProfilesFn := appendName(allFoldersPath, utils.AccountProfilesCsv) + accountProfilesFn := appendName(allFoldersPath, utils.AccountsCsv) return NewCSVStorage(sep, destinationsPaths, timingsPaths, @@ -169,7 +169,7 @@ func NewGoogleCSVStorage(sep rune, spreadsheetID string) (*CSVStorage, error) { getIfExist(utils.DispatcherHosts), getIfExist(utils.RateProfiles), getIfExist(utils.ActionProfiles), - getIfExist(utils.AccountProfilesString)) + getIfExist(utils.AccountsString)) c.generator = func() csvReaderCloser { return &csvGoogle{ spreadsheetID: spreadsheetID, @@ -211,7 +211,7 @@ func NewURLCSVStorage(sep rune, dataPath string) *CSVStorage { dispatcherhostsPaths = append(dispatcherhostsPaths, joinURL(baseURL, utils.DispatcherHostsCsv)) rateProfilesPaths = append(rateProfilesPaths, joinURL(baseURL, utils.RateProfilesCsv)) actionProfilesPaths = append(actionProfilesPaths, joinURL(baseURL, utils.ActionProfilesCsv)) - accountProfilesPaths = append(accountProfilesPaths, joinURL(baseURL, utils.AccountProfilesCsv)) + accountProfilesPaths = append(accountProfilesPaths, joinURL(baseURL, utils.AccountsCsv)) continue } switch { @@ -241,7 +241,7 @@ func NewURLCSVStorage(sep rune, dataPath string) *CSVStorage { rateProfilesPaths = append(rateProfilesPaths, baseURL) case strings.HasSuffix(baseURL, utils.ActionProfilesCsv): actionProfilesPaths = append(actionProfilesPaths, baseURL) - case strings.HasSuffix(baseURL, utils.AccountProfilesCsv): + case strings.HasSuffix(baseURL, utils.AccountsCsv): accountProfilesPaths = append(accountProfilesPaths, baseURL) } diff --git a/engine/storage_interface.go b/engine/storage_interface.go index 9be826bd2..0707585aa 100644 --- a/engine/storage_interface.go +++ b/engine/storage_interface.go @@ -107,9 +107,9 @@ type DataDB interface { GetActionProfileDrv(string, string) (*ActionProfile, error) SetActionProfileDrv(*ActionProfile) error RemoveActionProfileDrv(string, string) error - GetAccountProfileDrv(string, string) (*utils.Account, error) - SetAccountProfileDrv(profile *utils.Account) error - RemoveAccountProfileDrv(string, string) error + GetAccountDrv(string, string) (*utils.Account, error) + SetAccountDrv(profile *utils.Account) error + RemoveAccountDrv(string, string) error } type StorDB interface { diff --git a/engine/storage_internal_datadb.go b/engine/storage_internal_datadb.go index dc9abe2d7..6e0a675f9 100644 --- a/engine/storage_internal_datadb.go +++ b/engine/storage_internal_datadb.go @@ -677,22 +677,22 @@ func (iDB *InternalDB) RemoveIndexesDrv(idxItmType, tntCtx, idxKey string) (err return } -func (iDB *InternalDB) GetAccountProfileDrv(tenant, id string) (ap *utils.Account, err error) { - x, ok := Cache.Get(utils.CacheAccountProfiles, utils.ConcatenatedKey(tenant, id)) +func (iDB *InternalDB) GetAccountDrv(tenant, id string) (ap *utils.Account, err error) { + x, ok := Cache.Get(utils.CacheAccounts, utils.ConcatenatedKey(tenant, id)) if !ok || x == nil { return nil, utils.ErrNotFound } return x.(*utils.Account).Clone(), nil } -func (iDB *InternalDB) SetAccountProfileDrv(ap *utils.Account) (err error) { - Cache.SetWithoutReplicate(utils.CacheAccountProfiles, ap.TenantID(), ap, nil, +func (iDB *InternalDB) SetAccountDrv(ap *utils.Account) (err error) { + Cache.SetWithoutReplicate(utils.CacheAccounts, ap.TenantID(), ap, nil, cacheCommit(utils.NonTransactional), utils.NonTransactional) return } -func (iDB *InternalDB) RemoveAccountProfileDrv(tenant, id string) (err error) { - Cache.RemoveWithoutReplicate(utils.CacheAccountProfiles, utils.ConcatenatedKey(tenant, id), +func (iDB *InternalDB) RemoveAccountDrv(tenant, id string) (err error) { + Cache.RemoveWithoutReplicate(utils.CacheAccounts, utils.ConcatenatedKey(tenant, id), cacheCommit(utils.NonTransactional), utils.NonTransactional) return } diff --git a/engine/storage_internal_stordb.go b/engine/storage_internal_stordb.go index a9d6a0333..f4c075730 100644 --- a/engine/storage_internal_stordb.go +++ b/engine/storage_internal_stordb.go @@ -354,9 +354,9 @@ func (iDB *InternalDB) GetTPAccounts(tpid, tenant, id string) (tpPrfs []*utils.T if id != utils.EmptyString { key += utils.ConcatenatedKeySep + id } - ids := Cache.GetItemIDs(utils.CacheTBLTPAccountProfiles, key) + ids := Cache.GetItemIDs(utils.CacheTBLTPAccounts, key) for _, id := range ids { - x, ok := Cache.Get(utils.CacheTBLTPAccountProfiles, id) + x, ok := Cache.Get(utils.CacheTBLTPAccounts, id) if !ok || x == nil { return nil, utils.ErrNotFound } @@ -536,7 +536,7 @@ func (iDB *InternalDB) SetTPAccounts(tpPrfs []*utils.TPAccount) (err error) { return nil } for _, tpPrf := range tpPrfs { - Cache.SetWithoutReplicate(utils.CacheTBLTPAccountProfiles, utils.ConcatenatedKey(tpPrf.TPid, tpPrf.Tenant, tpPrf.ID), tpPrf, nil, + Cache.SetWithoutReplicate(utils.CacheTBLTPAccounts, utils.ConcatenatedKey(tpPrf.TPid, tpPrf.Tenant, tpPrf.ID), tpPrf, nil, cacheCommit(utils.NonTransactional), utils.NonTransactional) } return diff --git a/engine/storage_mongo_datadb.go b/engine/storage_mongo_datadb.go index 70fd1924e..723dcdf8f 100644 --- a/engine/storage_mongo_datadb.go +++ b/engine/storage_mongo_datadb.go @@ -592,8 +592,8 @@ func (ms *MongoStorage) GetKeysForPrefix(prefix string) (result []string, err er result, err = ms.getField2(sctx, ColRpp, utils.RateProfilePrefix, subject, tntID) case utils.ActionProfilePrefix: result, err = ms.getField2(sctx, ColApp, utils.ActionProfilePrefix, subject, tntID) - case utils.AccountProfilePrefix: - result, err = ms.getField2(sctx, ColAnp, utils.AccountProfilePrefix, subject, tntID) + case utils.AccountPrefix: + result, err = ms.getField2(sctx, ColAnp, utils.AccountPrefix, subject, tntID) case utils.DispatcherHostPrefix: result, err = ms.getField2(sctx, ColDph, utils.DispatcherHostPrefix, subject, tntID) case utils.AttributeFilterIndexes: @@ -614,8 +614,8 @@ func (ms *MongoStorage) GetKeysForPrefix(prefix string) (result []string, err er result, err = ms.getField3(sctx, ColIndx, utils.ActionPlanIndexes, "key") case utils.ActionProfilesFilterIndexPrfx: result, err = ms.getField3(sctx, ColIndx, utils.ActionProfilesFilterIndexPrfx, "key") - case utils.AccountProfileFilterIndexPrfx: - result, err = ms.getField3(sctx, ColIndx, utils.AccountProfileFilterIndexPrfx, "key") + case utils.AccountFilterIndexPrfx: + result, err = ms.getField3(sctx, ColIndx, utils.AccountFilterIndexPrfx, "key") case utils.RateProfilesFilterIndexPrfx: result, err = ms.getField3(sctx, ColIndx, utils.RateProfilesFilterIndexPrfx, "key") case utils.RateFilterIndexPrfx: @@ -664,7 +664,7 @@ func (ms *MongoStorage) HasDataDrv(category, subject, tenant string) (has bool, count, err = ms.getCol(ColRpp).CountDocuments(sctx, bson.M{"tenant": tenant, "id": subject}) case utils.ActionProfilePrefix: count, err = ms.getCol(ColApp).CountDocuments(sctx, bson.M{"tenant": tenant, "id": subject}) - case utils.AccountProfilePrefix: + case utils.AccountPrefix: count, err = ms.getCol(ColAnp).CountDocuments(sctx, bson.M{"tenant": tenant, "id": subject}) default: err = fmt.Errorf("unsupported category in HasData: %s", category) @@ -1612,7 +1612,7 @@ func (ms *MongoStorage) RemoveIndexesDrv(idxItmType, tntCtx, idxKey string) (err }) } -func (ms *MongoStorage) GetAccountProfileDrv(tenant, id string) (ap *utils.Account, err error) { +func (ms *MongoStorage) GetAccountDrv(tenant, id string) (ap *utils.Account, err error) { ap = new(utils.Account) err = ms.query(func(sctx mongo.SessionContext) (err error) { cur := ms.getCol(ColAnp).FindOne(sctx, bson.M{"tenant": tenant, "id": id}) @@ -1628,7 +1628,7 @@ func (ms *MongoStorage) GetAccountProfileDrv(tenant, id string) (ap *utils.Accou return } -func (ms *MongoStorage) SetAccountProfileDrv(ap *utils.Account) (err error) { +func (ms *MongoStorage) SetAccountDrv(ap *utils.Account) (err error) { return ms.query(func(sctx mongo.SessionContext) (err error) { _, err = ms.getCol(ColAnp).UpdateOne(sctx, bson.M{"tenant": ap.Tenant, "id": ap.ID}, bson.M{"$set": ap}, @@ -1638,7 +1638,7 @@ func (ms *MongoStorage) SetAccountProfileDrv(ap *utils.Account) (err error) { }) } -func (ms *MongoStorage) RemoveAccountProfileDrv(tenant, id string) (err error) { +func (ms *MongoStorage) RemoveAccountDrv(tenant, id string) (err error) { return ms.query(func(sctx mongo.SessionContext) (err error) { dr, err := ms.getCol(ColAnp).DeleteOne(sctx, bson.M{"tenant": tenant, "id": id}) if dr.DeletedCount == 0 { diff --git a/engine/storage_mongo_stordb.go b/engine/storage_mongo_stordb.go index 8b7d66862..b09b9e2e9 100644 --- a/engine/storage_mongo_stordb.go +++ b/engine/storage_mongo_stordb.go @@ -1065,7 +1065,7 @@ func (ms *MongoStorage) GetTPAccounts(tpid, tenant, id string) ([]*utils.TPAccou } var results []*utils.TPAccount err := ms.query(func(sctx mongo.SessionContext) (err error) { - cur, err := ms.getCol(utils.TBLTPAccountProfiles).Find(sctx, filter) + cur, err := ms.getCol(utils.TBLTPAccounts).Find(sctx, filter) if err != nil { return err } @@ -1109,7 +1109,7 @@ func (ms *MongoStorage) SetTPAccounts(tpAps []*utils.TPAccount) (err error) { } return ms.query(func(sctx mongo.SessionContext) (err error) { for _, tp := range tpAps { - _, err = ms.getCol(utils.TBLTPAccountProfiles).UpdateOne(sctx, bson.M{"tpid": tp.TPid, "id": tp.ID}, + _, err = ms.getCol(utils.TBLTPAccounts).UpdateOne(sctx, bson.M{"tpid": tp.TPid, "id": tp.ID}, bson.M{"$set": tp}, options.Update().SetUpsert(true), ) diff --git a/engine/storage_redis.go b/engine/storage_redis.go index 60d74a1a5..db4e514b8 100644 --- a/engine/storage_redis.go +++ b/engine/storage_redis.go @@ -937,9 +937,9 @@ func (rs *RedisStorage) RemoveIndexesDrv(idxItmType, tntCtx, idxKey string) (err return rs.Cmd(nil, redisHDEL, utils.CacheInstanceToPrefix[idxItmType]+tntCtx, idxKey) } -func (rs *RedisStorage) GetAccountProfileDrv(tenant, id string) (ap *utils.Account, err error) { +func (rs *RedisStorage) GetAccountDrv(tenant, id string) (ap *utils.Account, err error) { var values []byte - if err = rs.Cmd(&values, redisGET, utils.AccountProfilePrefix+utils.ConcatenatedKey(tenant, id)); err != nil { + if err = rs.Cmd(&values, redisGET, utils.AccountPrefix+utils.ConcatenatedKey(tenant, id)); err != nil { return } else if len(values) == 0 { err = utils.ErrNotFound @@ -949,14 +949,14 @@ func (rs *RedisStorage) GetAccountProfileDrv(tenant, id string) (ap *utils.Accou return } -func (rs *RedisStorage) SetAccountProfileDrv(ap *utils.Account) (err error) { +func (rs *RedisStorage) SetAccountDrv(ap *utils.Account) (err error) { var result []byte if result, err = rs.ms.Marshal(ap); err != nil { return } - return rs.Cmd(nil, redisSET, utils.AccountProfilePrefix+utils.ConcatenatedKey(ap.Tenant, ap.ID), string(result)) + return rs.Cmd(nil, redisSET, utils.AccountPrefix+utils.ConcatenatedKey(ap.Tenant, ap.ID), string(result)) } -func (rs *RedisStorage) RemoveAccountProfileDrv(tenant, id string) (err error) { - return rs.Cmd(nil, redisDEL, utils.AccountProfilePrefix+utils.ConcatenatedKey(tenant, id)) +func (rs *RedisStorage) RemoveAccountDrv(tenant, id string) (err error) { + return rs.Cmd(nil, redisDEL, utils.AccountPrefix+utils.ConcatenatedKey(tenant, id)) } diff --git a/engine/storage_sql.go b/engine/storage_sql.go index 43f6bc4c4..432d421f9 100644 --- a/engine/storage_sql.go +++ b/engine/storage_sql.go @@ -231,7 +231,7 @@ func (sqls *SQLStorage) RemTpData(table, tpid string, args map[string]string) er for _, tblName := range []string{utils.TBLTPTimings, utils.TBLTPDestinations, utils.TBLTPResources, utils.TBLTPStats, utils.TBLTPThresholds, utils.TBLTPFilters, utils.TBLTPRoutes, utils.TBLTPAttributes, - utils.TBLTPChargers, utils.TBLTPDispatchers, utils.TBLTPDispatcherHosts, utils.TBLTPAccountProfiles, + utils.TBLTPChargers, utils.TBLTPDispatchers, utils.TBLTPDispatcherHosts, utils.TBLTPAccounts, utils.TBLTPActionProfiles, utils.TBLTPRateProfiles} { if err := tx.Table(tblName).Where("tpid = ?", tpid).Delete(nil).Error; err != nil { tx.Rollback() diff --git a/engine/tpexporter.go b/engine/tpexporter.go index 0cc455201..32ea9f440 100644 --- a/engine/tpexporter.go +++ b/engine/tpexporter.go @@ -239,13 +239,13 @@ func (tpExp *TPExporter) Run() error { storDataAccountProfiles, err := tpExp.storDB.GetTPAccounts(tpExp.tpID, "", "") if err != nil && err.Error() != utils.ErrNotFound.Error() { - utils.Logger.Warning(fmt.Sprintf("<%s> error: %s, when getting %s from stordb for export", utils.ApierS, err, utils.TpAccountProfiles)) + utils.Logger.Warning(fmt.Sprintf("<%s> error: %s, when getting %s from stordb for export", utils.ApierS, err, utils.TpAccounts)) withError = true } for _, sd := range storDataAccountProfiles { sdModels := APItoModelTPAccount(sd) for _, sdModel := range sdModels { - toExportMap[utils.AccountProfilesCsv] = append(toExportMap[utils.AccountProfilesCsv], sdModel) + toExportMap[utils.AccountsCsv] = append(toExportMap[utils.AccountsCsv], sdModel) } } diff --git a/engine/tpimporter_csv.go b/engine/tpimporter_csv.go index 29e2f8f61..3eb44a03d 100644 --- a/engine/tpimporter_csv.go +++ b/engine/tpimporter_csv.go @@ -53,7 +53,7 @@ var fileHandlers = map[string]func(*TPCSVImporter, string) error{ utils.DispatcherHostsCsv: (*TPCSVImporter).importDispatcherHosts, utils.RateProfilesCsv: (*TPCSVImporter).importRateProfiles, utils.ActionProfilesCsv: (*TPCSVImporter).importActionProfiles, - utils.AccountProfilesCsv: (*TPCSVImporter).importAccountProfiles, + utils.AccountsCsv: (*TPCSVImporter).importAccounts, } func (tpImp *TPCSVImporter) Run() error { @@ -228,7 +228,7 @@ func (tpImp *TPCSVImporter) importActionProfiles(fn string) error { return tpImp.StorDB.SetTPActionProfiles(rpps) } -func (tpImp *TPCSVImporter) importAccountProfiles(fn string) error { +func (tpImp *TPCSVImporter) importAccounts(fn string) error { if tpImp.Verbose { log.Printf("Processing file: <%s> ", fn) } diff --git a/engine/tpreader.go b/engine/tpreader.go index b3d2227bc..148e1caf6 100644 --- a/engine/tpreader.go +++ b/engine/tpreader.go @@ -760,7 +760,7 @@ func (tpr *TpReader) WriteToDatabase(verbose, disableReverse bool) (err error) { } if verbose { - log.Print("AccountProfiles:") + log.Print("Accounts:") } for _, tpAP := range tpr.accountProfiles { var ap *utils.Account @@ -775,7 +775,7 @@ func (tpr *TpReader) WriteToDatabase(verbose, disableReverse bool) (err error) { } } if len(tpr.accountProfiles) != 0 { - loadIDs[utils.CacheAccountProfiles] = loadID + loadIDs[utils.CacheAccounts] = loadID } if verbose { @@ -1118,7 +1118,7 @@ func (tpr *TpReader) RemoveFromDatabase(verbose, disableReverse bool) (err error } if verbose { - log.Print("AccountProfiles:") + log.Print("Accounts:") } for _, tpAp := range tpr.accountProfiles { if err = tpr.dm.RemoveAccount(tpAp.Tenant, tpAp.ID, @@ -1211,7 +1211,7 @@ func (tpr *TpReader) RemoveFromDatabase(verbose, disableReverse bool) (err error loadIDs[utils.CacheActionProfiles] = loadID } if len(tpr.accountProfiles) != 0 { - loadIDs[utils.CacheAccountProfiles] = loadID + loadIDs[utils.CacheAccounts] = loadID } if len(tpr.timings) != 0 { loadIDs[utils.CacheTimings] = loadID @@ -1244,7 +1244,7 @@ func (tpr *TpReader) ReloadCache(caching string, verbose bool, opts map[string]i dphIDs, _ := tpr.GetLoadedIds(utils.DispatcherHostPrefix) ratePrfIDs, _ := tpr.GetLoadedIds(utils.RateProfilePrefix) actionPrfIDs, _ := tpr.GetLoadedIds(utils.ActionProfilePrefix) - accountPrfIDs, _ := tpr.GetLoadedIds(utils.AccountProfilePrefix) + accountPrfIDs, _ := tpr.GetLoadedIds(utils.AccountPrefix) //compose Reload Cache argument cacheArgs := utils.AttrReloadCacheWithAPIOpts{ @@ -1325,7 +1325,7 @@ func (tpr *TpReader) ReloadCache(caching string, verbose bool, opts map[string]i cacheIDs = append(cacheIDs, utils.CacheActionProfilesFilterIndexes) } if len(accountPrfIDs) != 0 { - cacheIDs = append(cacheIDs, utils.CacheAccountProfilesFilterIndexes) + cacheIDs = append(cacheIDs, utils.CacheAccountsFilterIndexes) } if len(flrIDs) != 0 { cacheIDs = append(cacheIDs, utils.CacheReverseFilterIndexes) diff --git a/loaders/loader.go b/loaders/loader.go index 456f23a75..b8bac2719 100644 --- a/loaders/loader.go +++ b/loaders/loader.go @@ -639,8 +639,8 @@ func (ldr *Loader) storeLoadedData(loaderType string, cacheArgs[utils.ActionProfileIDs] = ids } } - case utils.MetaAccountProfiles: - cacheIDs = []string{utils.CacheAccountProfilesFilterIndexes} + case utils.MetaAccounts: + cacheIDs = []string{utils.CacheAccountsFilterIndexes} for _, lDataSet := range lds { acpsModels := make(engine.AccountMdls, len(lDataSet)) for i, ld := range lDataSet { @@ -660,7 +660,7 @@ func (ldr *Loader) storeLoadedData(loaderType string, } if ldr.dryRun { utils.Logger.Info( - fmt.Sprintf("<%s-%s> DRY_RUN: AccountProfiles: %s", + fmt.Sprintf("<%s-%s> DRY_RUN: Accounts: %s", utils.LoaderS, ldr.ldrID, utils.ToJSON(acp))) continue } @@ -1010,12 +1010,12 @@ func (ldr *Loader) removeLoadedData(loaderType string, lds map[string][]LoaderDa cacheArgs[utils.ActionProfileIDs] = ids } } - case utils.MetaAccountProfiles: - cacheIDs = []string{utils.CacheAccountProfiles, utils.CacheAccountProfilesFilterIndexes} + case utils.MetaAccounts: + cacheIDs = []string{utils.CacheAccounts, utils.CacheAccountsFilterIndexes} for tntID := range lds { if ldr.dryRun { utils.Logger.Info( - fmt.Sprintf("<%s-%s> DRY_RUN: AccountProfileIDs: %s", + fmt.Sprintf("<%s-%s> DRY_RUN: AccountIDs: %s", utils.LoaderS, ldr.ldrID, tntID)) } else { tntIDStruct := utils.NewTenantID(tntID) diff --git a/migrator/account_profiles.go b/migrator/account_profiles.go index 7990f576c..e54c2222e 100644 --- a/migrator/account_profiles.go +++ b/migrator/account_profiles.go @@ -27,16 +27,16 @@ import ( "github.com/cgrates/cgrates/utils" ) -func (m *Migrator) migrateCurrentAccountProfiles() (err error) { +func (m *Migrator) migrateCurrentAccounts() (err error) { var ids []string - ids, err = m.dmIN.DataManager().DataDB().GetKeysForPrefix(utils.AccountProfilePrefix) + ids, err = m.dmIN.DataManager().DataDB().GetKeysForPrefix(utils.AccountPrefix) if err != nil { return err } for _, id := range ids { - tntID := strings.SplitN(strings.TrimPrefix(id, utils.AccountProfilePrefix), utils.InInFieldSep, 2) + tntID := strings.SplitN(strings.TrimPrefix(id, utils.AccountPrefix), utils.InInFieldSep, 2) if len(tntID) < 2 { - return fmt.Errorf("Invalid key <%s> when migrating from account profiles", id) + return fmt.Errorf("Invalid key <%s> when migrating from account ", id) } ap, err := m.dmIN.DataManager().GetAccount(tntID[0], tntID[1]) if err != nil { @@ -51,44 +51,44 @@ func (m *Migrator) migrateCurrentAccountProfiles() (err error) { if err := m.dmIN.DataManager().RemoveAccount(tntID[0], tntID[1], utils.NonTransactional, false); err != nil { return err } - m.stats[utils.AccountProfilesString]++ + m.stats[utils.AccountsString]++ } return } -func (m *Migrator) migrateAccountProfiles() (err error) { +func (m *Migrator) migrateAccounts() (err error) { var vrs engine.Versions current := engine.CurrentDataDBVersions() - if vrs, err = m.getVersions(utils.AccountProfilesString); err != nil { + if vrs, err = m.getVersions(utils.AccountsString); err != nil { return } migrated := true for { - version := vrs[utils.AccountProfilesString] + version := vrs[utils.AccountsString] for { switch version { default: return fmt.Errorf("Unsupported version %v", version) - case current[utils.AccountProfilesString]: + case current[utils.AccountsString]: migrated = false if m.sameDataDB { break } - if err = m.migrateCurrentAccountProfiles(); err != nil { + if err = m.migrateCurrentAccounts(); err != nil { return } } - if version == current[utils.AccountProfilesString] || err == utils.ErrNoMoreData { + if version == current[utils.AccountsString] || err == utils.ErrNoMoreData { break } } if err == utils.ErrNoMoreData || !migrated { break } - m.stats[utils.AccountProfilesString]++ + m.stats[utils.AccountsString]++ } //All done, update version with current one - if err = m.setVersions(utils.AccountProfilesString); err != nil { + if err = m.setVersions(utils.AccountsString); err != nil { return } return m.ensureIndexesDataDB(engine.ColApp) diff --git a/migrator/migrator.go b/migrator/migrator.go index 970ce1774..319f05e25 100755 --- a/migrator/migrator.go +++ b/migrator/migrator.go @@ -115,8 +115,8 @@ func (m *Migrator) Migrate(taskIDs []string) (err error, stats map[string]int) { err = m.migrateFilters() case utils.MetaRoutes: err = m.migrateRouteProfiles() - case utils.MetaAccountProfiles: - err = m.migrateAccountProfiles() + case utils.MetaAccounts: + err = m.migrateAccounts() //only Move case utils.MetaActionProfiles: err = m.migrateActionProfiles() diff --git a/migrator/stats.go b/migrator/stats.go index 532abcc40..86ee9ab3d 100644 --- a/migrator/stats.go +++ b/migrator/stats.go @@ -71,6 +71,7 @@ func (m *Migrator) moveStatQueueProfile() (err error) { return fmt.Errorf("Invalid key <%s> when migrating stat queue profiles", id) } sgs, err := m.dmIN.DataManager().GetStatQueueProfile(tntID[0], tntID[1], false, false, utils.NonTransactional) + fmt.Println("sgs", utils.ToJSON(sgs)) if err != nil { return err } diff --git a/services/accounts.go b/services/accounts.go index 4f2b9f3c1..af3e590ec 100644 --- a/services/accounts.go +++ b/services/accounts.go @@ -79,8 +79,8 @@ func (acts *AccountService) Start() (err error) { return utils.ErrServiceAlreadyRunning } - <-acts.cacheS.GetPrecacheChannel(utils.CacheAccountProfiles) - <-acts.cacheS.GetPrecacheChannel(utils.CacheAccountProfilesFilterIndexes) + <-acts.cacheS.GetPrecacheChannel(utils.CacheAccounts) + <-acts.cacheS.GetPrecacheChannel(utils.CacheAccountsFilterIndexes) filterS := <-acts.filterSChan acts.filterSChan <- filterS diff --git a/utils/accountprofile.go b/utils/accountprofile.go index 185a0e546..9eeca0aaa 100644 --- a/utils/accountprofile.go +++ b/utils/accountprofile.go @@ -25,7 +25,7 @@ import ( "github.com/ericlagergren/decimal" ) -// AccountProfile represents one Account on a Tenant +// Account represents one Account on a Tenant type Account struct { Tenant string ID string // Account identificator, unique within the tenant @@ -284,14 +284,14 @@ func (bL *Balance) Clone() (blnc *Balance) { return } -// AccountProfileWithWeight attaches static weight to AccountProfile +// AccountWithWeight attaches static weight to Account type AccountWithWeight struct { *Account Weight float64 LockID string } -// AccountProfilesWithWeight is a sortable list of AccountProfileWithWeight +// AccountsWithWeight is a sortable list of AccountWithWeight type AccountsWithWeight []*AccountWithWeight // Sort is part of sort interface, sort based on Weight @@ -346,7 +346,7 @@ func (bWws BalancesWithWeight) Balances() (blncs []*Balance) { return } -// APIAccountProfileWithOpts is used in API calls +// APIAccountWithOpts is used in API calls type APIAccountWithOpts struct { *APIAccount APIOpts map[string]interface{} @@ -363,7 +363,7 @@ type ArgsAccountsForEvent struct { AccountIDs []string } -// APIAccountProfile represents one APIAccount on a Tenant +// APIAccount represents one APIAccount on a Tenant type APIAccount struct { Tenant string ID string @@ -375,7 +375,7 @@ type APIAccount struct { ThresholdIDs []string } -// AsAccount convert APIAccount struct to AccountProfile struct +// AsAccount convert APIAccount struct to Account struct func (ext *APIAccount) AsAccount() (profile *Account, err error) { profile = &Account{ Tenant: ext.Tenant, diff --git a/utils/apitpdata.go b/utils/apitpdata.go index 3cf8b906d..699727754 100755 --- a/utils/apitpdata.go +++ b/utils/apitpdata.go @@ -542,18 +542,18 @@ func (attr *ArgRSv1ResourceUsage) Clone() *ArgRSv1ResourceUsage { } type ArgsComputeFilterIndexIDs struct { - Tenant string - Context string - AttributeIDs []string - ResourceIDs []string - StatIDs []string - RouteIDs []string - ThresholdIDs []string - ChargerIDs []string - DispatcherIDs []string - RateProfileIDs []string - AccountProfileIDs []string - ActionProfileIDs []string + Tenant string + Context string + AttributeIDs []string + ResourceIDs []string + StatIDs []string + RouteIDs []string + ThresholdIDs []string + ChargerIDs []string + DispatcherIDs []string + RateProfileIDs []string + AccountIDs []string + ActionProfileIDs []string } type ArgsComputeFilterIndexes struct {