diff --git a/apier/v1/apier.go b/apier/v1/apier.go
index 74623a90c..1ac7ebd7a 100644
--- a/apier/v1/apier.go
+++ b/apier/v1/apier.go
@@ -1133,10 +1133,10 @@ func (self *ApierV1) LoadCache(args utils.AttrReloadCache, reply *string) (err e
} else {
splpIDs = *args.SupplierProfileIDs
}
- if args.AliasProfileIDs == nil {
+ if args.AttributeProfileIDs == nil {
alsPrfIDs = nil
} else {
- alsPrfIDs = *args.AliasProfileIDs
+ alsPrfIDs = *args.AttributeProfileIDs
}
if err := self.DataManager.LoadDataDBCache(dstIDs, rvDstIDs, rplIDs, rpfIDs, actIDs, aplIDs, aapIDs, atrgIDs, sgIDs, lcrIDs, dcIDs, alsIDs, rvAlsIDs, rspIDs, resIDs, stqIDs, stqpIDs, thIDs, thpIDs, fltrIDs, splpIDs, alsPrfIDs); err != nil {
return utils.NewErrServerError(err)
@@ -1292,11 +1292,11 @@ func (self *ApierV1) FlushCache(args utils.AttrReloadCache, reply *string) (err
cache.RemKey(utils.SupplierProfilePrefix+key, true, utils.NonTransactional)
}
}
- if args.AliasProfileIDs == nil {
- cache.RemPrefixKey(utils.AliasProfilePrefix, true, utils.NonTransactional)
- } else if len(*args.AliasProfileIDs) != 0 {
- for _, key := range *args.AliasProfileIDs {
- cache.RemKey(utils.AliasProfilePrefix+key, true, utils.NonTransactional)
+ if args.AttributeProfileIDs == nil {
+ cache.RemPrefixKey(utils.AttributeProfilePrefix, true, utils.NonTransactional)
+ } else if len(*args.AttributeProfileIDs) != 0 {
+ for _, key := range *args.AttributeProfileIDs {
+ cache.RemKey(utils.AttributeProfilePrefix+key, true, utils.NonTransactional)
}
}
@@ -1326,7 +1326,7 @@ func (self *ApierV1) GetCacheStats(attrs utils.AttrCacheStats, reply *utils.Cach
cs.ThresholdProfiles = cache.CountEntries(utils.ThresholdProfilePrefix)
cs.Filters = cache.CountEntries(utils.FilterPrefix)
cs.SupplierProfiles = cache.CountEntries(utils.SupplierProfilePrefix)
- cs.AliasProfiles = cache.CountEntries(utils.AliasProfilePrefix)
+ cs.AttributeProfiles = cache.CountEntries(utils.AttributeProfilePrefix)
if self.CdrStatsSrv != nil {
var queueIds []string
@@ -1735,22 +1735,22 @@ func (v1 *ApierV1) GetCacheKeys(args utils.ArgsCacheKeys, reply *utils.ArgsCache
}
}
- if args.AliasProfileIDs != nil {
+ if args.AttributeProfileIDs != nil {
var ids []string
- if len(*args.AliasProfileIDs) != 0 {
- for _, id := range *args.AliasProfileIDs {
- if _, hasIt := cache.Get(utils.AliasProfilePrefix + id); hasIt {
+ if len(*args.AttributeProfileIDs) != 0 {
+ for _, id := range *args.AttributeProfileIDs {
+ if _, hasIt := cache.Get(utils.AttributeProfilePrefix + id); hasIt {
ids = append(ids, id)
}
}
} else {
- for _, id := range cache.GetEntryKeys(utils.AliasProfilePrefix) {
- ids = append(ids, id[len(utils.AliasProfilePrefix):])
+ for _, id := range cache.GetEntryKeys(utils.AttributeProfilePrefix) {
+ ids = append(ids, id[len(utils.AttributeProfilePrefix):])
}
}
ids = args.Paginator.PaginateStringSlice(ids)
if len(ids) != 0 {
- reply.AliasProfileIDs = &ids
+ reply.AttributeProfileIDs = &ids
}
}
@@ -1791,7 +1791,7 @@ func (self *ApierV1) LoadTariffPlanFromFolder(attrs utils.AttrLoadTpFromFolder,
path.Join(attrs.FolderPath, utils.ThresholdsCsv),
path.Join(attrs.FolderPath, utils.FiltersCsv),
path.Join(attrs.FolderPath, utils.SuppliersCsv),
- path.Join(attrs.FolderPath, utils.AliasCsv),
+ path.Join(attrs.FolderPath, utils.AttributesCsv),
), "", self.Config.DefaultTimezone)
if err := loader.LoadAll(); err != nil {
return utils.NewErrServerError(err)
@@ -1833,7 +1833,7 @@ func (self *ApierV1) LoadTariffPlanFromFolder(attrs utils.AttrLoadTpFromFolder,
utils.ThresholdProfilePrefix,
utils.FilterPrefix,
utils.SupplierProfilePrefix,
- utils.AliasProfilePrefix} {
+ utils.AttributeProfilePrefix} {
loadedIDs, _ := loader.GetLoadedIds(prfx)
if err := self.DataManager.CacheDataFromDB(prfx, loadedIDs, true); err != nil {
return utils.NewErrServerError(err)
diff --git a/apier/v1/alias.go b/apier/v1/attributes.go
similarity index 56%
rename from apier/v1/alias.go
rename to apier/v1/attributes.go
index 8cb86ecaa..aa7c2d399 100644
--- a/apier/v1/alias.go
+++ b/apier/v1/attributes.go
@@ -23,41 +23,41 @@ import (
"github.com/cgrates/cgrates/utils"
)
-// GetAliasProfile returns an Alias Profile
-func (apierV1 *ApierV1) GetAliasProfile(arg utils.TenantID, reply *engine.ExternalAliasProfile) error {
+// GetAttributeProfile returns an Attribute Profile
+func (apierV1 *ApierV1) GetAttributeProfile(arg utils.TenantID, reply *engine.ExternalAttributeProfile) error {
if missing := utils.MissingStructFields(&arg, []string{"Tenant", "ID"}); len(missing) != 0 { //Params missing
return utils.NewErrMandatoryIeMissing(missing...)
}
- if alsPrf, err := apierV1.DataManager.GetAliasProfile(arg.Tenant, arg.ID, true, utils.NonTransactional); err != nil {
+ if alsPrf, err := apierV1.DataManager.GetAttributeProfile(arg.Tenant, arg.ID, true, utils.NonTransactional); err != nil {
if err.Error() != utils.ErrNotFound.Error() {
err = utils.NewErrServerError(err)
}
return err
} else {
- *reply = *engine.NewExternalAliasProfileFromAliasProfile(alsPrf)
+ *reply = *engine.NewExternalAttributeProfileFromAttributeProfile(alsPrf)
}
return nil
}
-//SetAliasProfile add a new Alias Profile
-func (apierV1 *ApierV1) SetAliasProfile(extAls *engine.ExternalAliasProfile, reply *string) error {
+//SetAttributeProfile add/update a new Attribute Profile
+func (apierV1 *ApierV1) SetAttributeProfile(extAls *engine.ExternalAttributeProfile, reply *string) error {
if missing := utils.MissingStructFields(extAls, []string{"Tenant", "ID"}); len(missing) != 0 {
return utils.NewErrMandatoryIeMissing(missing...)
}
- alsPrf := extAls.AsAliasProfile()
- if err := apierV1.DataManager.SetAliasProfile(alsPrf); err != nil {
+ alsPrf := extAls.AsAttributeProfile()
+ if err := apierV1.DataManager.SetAttributeProfile(alsPrf); err != nil {
return utils.APIErrorHandler(err)
}
*reply = utils.OK
return nil
}
-//RemAliasProfile remove a specific Alias Profile
-func (apierV1 *ApierV1) RemAliasProfile(arg utils.TenantID, reply *string) error {
+//RemAttributeProfile remove a specific Attribute Profile
+func (apierV1 *ApierV1) RemAttributeProfile(arg utils.TenantID, reply *string) error {
if missing := utils.MissingStructFields(&arg, []string{"Tenant", "ID"}); len(missing) != 0 { //Params missing
return utils.NewErrMandatoryIeMissing(missing...)
}
- if err := apierV1.DataManager.RemoveAliasProfile(arg.Tenant, arg.ID, utils.NonTransactional); err != nil {
+ if err := apierV1.DataManager.RemoveAttributeProfile(arg.Tenant, arg.ID, utils.NonTransactional); err != nil {
if err.Error() != utils.ErrNotFound.Error() {
err = utils.NewErrServerError(err)
}
@@ -67,29 +67,29 @@ func (apierV1 *ApierV1) RemAliasProfile(arg utils.TenantID, reply *string) error
return nil
}
-func NewAliasSv1(alS *engine.AliasService) *AliasSv1 {
- return &AliasSv1{alS: alS}
+func NewAttributeSv1(attrS *engine.AttributeService) *AttributeSv1 {
+ return &AttributeSv1{attrS: attrS}
}
// Exports RPC from RLs
-type AliasSv1 struct {
- alS *engine.AliasService
+type AttributeSv1 struct {
+ attrS *engine.AttributeService
}
// Call implements rpcclient.RpcClientConnection interface for internal RPC
-func (alSv1 *AliasSv1) Call(serviceMethod string,
+func (alSv1 *AttributeSv1) Call(serviceMethod string,
args interface{}, reply interface{}) error {
return utils.APIerRPCCall(alSv1, serviceMethod, args, reply)
}
-// GetAliasForEvent returns matching AliasProfile for Event
-func (alSv1 *AliasSv1) GetAliasForEvent(ev *utils.CGREvent,
- reply *engine.ExternalAliasProfile) error {
- return alSv1.alS.V1GetAliasForEvent(ev, reply)
+// GetAttributeForEvent returns matching AttributeProfile for Event
+func (alSv1 *AttributeSv1) GetAttributeForEvent(ev *utils.CGREvent,
+ reply *engine.ExternalAttributeProfile) error {
+ return alSv1.attrS.V1GetAttributeForEvent(ev, reply)
}
-// ProcessEvent will replace event fields with the ones in maching AliasProfile
-func (alSv1 *AliasSv1) ProcessEvent(ev *utils.CGREvent,
+// ProcessEvent will replace event fields with the ones in maching AttributeProfile
+func (alSv1 *AttributeSv1) ProcessEvent(ev *utils.CGREvent,
reply *string) error {
- return alSv1.alS.V1ProcessEvent(ev, reply)
+ return alSv1.attrS.V1ProcessEvent(ev, reply)
}
diff --git a/apier/v1/alias_it_test.go b/apier/v1/attributes_it_test.go
similarity index 77%
rename from apier/v1/alias_it_test.go
rename to apier/v1/attributes_it_test.go
index 01d4d138a..4ee399a6b 100644
--- a/apier/v1/alias_it_test.go
+++ b/apier/v1/attributes_it_test.go
@@ -38,7 +38,7 @@ var (
alsPrfCfg *config.CGRConfig
alsPrfRPC *rpc.Client
alsPrfDataDir = "/usr/share/cgrates"
- alsPrf *engine.ExternalAliasProfile
+ alsPrf *engine.ExternalAttributeProfile
alsPrfDelay int
alsPrfConfigDIR string //run tests for specific configuration
)
@@ -120,8 +120,8 @@ func testAlsPrfRPCConn(t *testing.T) {
}
func testAlsPrfGetAlsPrfBeforeSet(t *testing.T) {
- var reply *engine.ExternalAliasProfile
- if err := alsPrfRPC.Call("ApierV1.GetAliasProfile", &utils.TenantID{Tenant: "cgrates.org", ID: "ApierTest"}, &reply); err == nil || err.Error() != utils.ErrNotFound.Error() {
+ var reply *engine.ExternalAttributeProfile
+ if err := alsPrfRPC.Call("ApierV1.GetAttributeProfile", &utils.TenantID{Tenant: "cgrates.org", ID: "ApierTest"}, &reply); err == nil || err.Error() != utils.ErrNotFound.Error() {
t.Error(err)
}
}
@@ -144,20 +144,20 @@ func testAlsPrfGetAliasForEvent(t *testing.T) {
"Destination": "+491511231234",
},
}
- eAlsPrfl := engine.ExternalAliasProfile{
+ eAlsPrfl := engine.ExternalAttributeProfile{
Tenant: ev.Tenant,
ID: "ALS1",
FilterIDs: []string{"FLTR_ACNT_1007"},
ActivationInterval: &utils.ActivationInterval{
ActivationTime: time.Date(2014, 7, 14, 14, 35, 0, 0, time.UTC).Local()},
- Aliases: []*engine.AliasEntry{
- &engine.AliasEntry{
+ Attributes: []*engine.Attribute{
+ &engine.Attribute{
FieldName: utils.ACCOUNT,
Initial: utils.ANY,
Alias: "1001",
Append: false,
},
- &engine.AliasEntry{
+ &engine.Attribute{
FieldName: utils.SUBJECT,
Initial: utils.ANY,
Alias: "1001",
@@ -166,8 +166,8 @@ func testAlsPrfGetAliasForEvent(t *testing.T) {
},
Weight: 10.0,
}
- var alsReply engine.ExternalAliasProfile
- if err := alsPrfRPC.Call(utils.AliasSv1GetAliasForEvent,
+ var alsReply engine.ExternalAttributeProfile
+ if err := alsPrfRPC.Call(utils.AttributeSv1GetAliasForEvent,
ev, &alsReply); err != nil {
t.Error(err)
} else if !reflect.DeepEqual(eAlsPrfl, alsReply) {
@@ -177,7 +177,7 @@ func testAlsPrfGetAliasForEvent(t *testing.T) {
}
func testAlsPrfSetAlsPrf(t *testing.T) {
- alsPrf = &engine.ExternalAliasProfile{
+ alsPrf = &engine.ExternalAttributeProfile{
Tenant: "cgrates.org",
ID: "ApierTest",
FilterIDs: []string{"FLTR_ACNT_dan", "FLTR_DST_DE"},
@@ -185,63 +185,66 @@ func testAlsPrfSetAlsPrf(t *testing.T) {
ActivationTime: time.Date(2014, 7, 14, 14, 35, 0, 0, time.UTC).Local(),
ExpiryTime: time.Date(2014, 7, 14, 14, 35, 0, 0, time.UTC).Local(),
},
- Aliases: []*engine.AliasEntry{
- &engine.AliasEntry{
+ Attributes: []*engine.Attribute{
+ &engine.Attribute{
FieldName: "FL1",
Initial: "In1",
Alias: "Al1",
+ Append: true,
},
},
Weight: 20,
}
var result string
- if err := alsPrfRPC.Call("ApierV1.SetAliasProfile", alsPrf, &result); err != nil {
+ if err := alsPrfRPC.Call("ApierV1.SetAttributeProfile", alsPrf, &result); err != nil {
t.Error(err)
} else if result != utils.OK {
t.Error("Unexpected reply returned", result)
}
- var reply *engine.ExternalAliasProfile
- if err := alsPrfRPC.Call("ApierV1.GetAliasProfile", &utils.TenantID{Tenant: "cgrates.org", ID: "ApierTest"}, &reply); err != nil {
+ var reply *engine.ExternalAttributeProfile
+ if err := alsPrfRPC.Call("ApierV1.GetAttributeProfile", &utils.TenantID{Tenant: "cgrates.org", ID: "ApierTest"}, &reply); err != nil {
t.Error(err)
} else if !reflect.DeepEqual(alsPrf.FilterIDs, reply.FilterIDs) {
t.Errorf("Expecting : %+v, received: %+v", alsPrf.FilterIDs, reply.FilterIDs)
} else if !reflect.DeepEqual(alsPrf.ActivationInterval, reply.ActivationInterval) {
t.Errorf("Expecting : %+v, received: %+v", alsPrf.ActivationInterval, reply.ActivationInterval)
- } else if !reflect.DeepEqual(len(alsPrf.Aliases), len(reply.Aliases)) {
- t.Errorf("Expecting : %+v, received: %+v", utils.ToJSON(alsPrf.Aliases), utils.ToJSON(reply.Aliases))
+ } else if !reflect.DeepEqual(len(alsPrf.Attributes), len(reply.Attributes)) {
+ t.Errorf("Expecting : %+v, received: %+v", utils.ToJSON(alsPrf.Attributes), utils.ToJSON(reply.Attributes))
} else if !reflect.DeepEqual(alsPrf.ID, reply.ID) {
t.Errorf("Expecting : %+v, received: %+v", alsPrf.ID, reply.ID)
}
}
func testAlsPrfUpdateAlsPrf(t *testing.T) {
- alsPrf.Aliases = []*engine.AliasEntry{
- &engine.AliasEntry{
+ alsPrf.Attributes = []*engine.Attribute{
+ &engine.Attribute{
FieldName: "FL1",
Initial: "In1",
Alias: "Al1",
+ Append: true,
},
- &engine.AliasEntry{
+ &engine.Attribute{
FieldName: "FL2",
Initial: "In2",
Alias: "Al2",
+ Append: false,
},
}
var result string
- if err := alsPrfRPC.Call("ApierV1.SetAliasProfile", alsPrf, &result); err != nil {
+ if err := alsPrfRPC.Call("ApierV1.SetAttributeProfile", alsPrf, &result); err != nil {
t.Error(err)
} else if result != utils.OK {
t.Error("Unexpected reply returned", result)
}
- var reply *engine.ExternalAliasProfile
- if err := alsPrfRPC.Call("ApierV1.GetAliasProfile", &utils.TenantID{Tenant: "cgrates.org", ID: "ApierTest"}, &reply); err != nil {
+ var reply *engine.ExternalAttributeProfile
+ if err := alsPrfRPC.Call("ApierV1.GetAttributeProfile", &utils.TenantID{Tenant: "cgrates.org", ID: "ApierTest"}, &reply); err != nil {
t.Error(err)
} else if !reflect.DeepEqual(alsPrf.FilterIDs, reply.FilterIDs) {
t.Errorf("Expecting : %+v, received: %+v", alsPrf.FilterIDs, reply.FilterIDs)
} else if !reflect.DeepEqual(alsPrf.ActivationInterval, reply.ActivationInterval) {
t.Errorf("Expecting : %+v, received: %+v", alsPrf.ActivationInterval, reply.ActivationInterval)
- } else if !reflect.DeepEqual(len(alsPrf.Aliases), len(reply.Aliases)) {
- t.Errorf("Expecting : %+v, received: %+v", utils.ToJSON(alsPrf.Aliases), utils.ToJSON(reply.Aliases))
+ } else if !reflect.DeepEqual(len(alsPrf.Attributes), len(reply.Attributes)) {
+ t.Errorf("Expecting : %+v, received: %+v", utils.ToJSON(alsPrf.Attributes), utils.ToJSON(reply.Attributes))
} else if !reflect.DeepEqual(alsPrf.ID, reply.ID) {
t.Errorf("Expecting : %+v, received: %+v", alsPrf.ID, reply.ID)
}
@@ -249,13 +252,13 @@ func testAlsPrfUpdateAlsPrf(t *testing.T) {
func testAlsPrfRemAlsPrf(t *testing.T) {
var resp string
- if err := alsPrfRPC.Call("ApierV1.RemAliasProfile", &utils.TenantID{Tenant: "cgrates.org", ID: "ApierTest"}, &resp); err != nil {
+ if err := alsPrfRPC.Call("ApierV1.RemAttributeProfile", &utils.TenantID{Tenant: "cgrates.org", ID: "ApierTest"}, &resp); err != nil {
t.Error(err)
} else if resp != utils.OK {
t.Error("Unexpected reply returned", resp)
}
- var reply *engine.ExternalAliasProfile
- if err := alsPrfRPC.Call("ApierV1.GetAliasProfile", &utils.TenantID{Tenant: "cgrates.org", ID: "ApierTest"}, &reply); err == nil || err.Error() != utils.ErrNotFound.Error() {
+ var reply *engine.ExternalAttributeProfile
+ if err := alsPrfRPC.Call("ApierV1.GetAttributeProfile", &utils.TenantID{Tenant: "cgrates.org", ID: "ApierTest"}, &reply); err == nil || err.Error() != utils.ErrNotFound.Error() {
t.Error(err)
}
}
diff --git a/apier/v1/smgenericv1_it_test.go b/apier/v1/smgenericv1_it_test.go
index a01de3c21..77bb9da2a 100644
--- a/apier/v1/smgenericv1_it_test.go
+++ b/apier/v1/smgenericv1_it_test.go
@@ -103,7 +103,7 @@ func TestSMGV1CacheStats(t *testing.T) {
expectedStats := &utils.CacheStats{Destinations: 5, ReverseDestinations: 7, RatingPlans: 4, RatingProfiles: 10,
Actions: 9, ActionPlans: 4, AccountActionPlans: 5, SharedGroups: 1, DerivedChargers: 1,
LcrProfiles: 5, CdrStats: 6, Users: 3, Aliases: 1, ReverseAliases: 2, ResourceProfiles: 3, Resources: 3, StatQueues: 1,
- StatQueueProfiles: 1, Thresholds: 7, ThresholdProfiles: 7, Filters: 16, SupplierProfiles: 3, AliasProfiles: 1}
+ StatQueueProfiles: 1, Thresholds: 7, ThresholdProfiles: 7, Filters: 16, SupplierProfiles: 3, AttributeProfiles: 1}
var args utils.AttrCacheStats
if err := smgV1Rpc.Call("ApierV1.GetCacheStats", args, &rcvStats); err != nil {
t.Error("Got error on ApierV1.GetCacheStats: ", err.Error())
diff --git a/apier/v1/tpaliasprofiles.go b/apier/v1/tpattributes.go
similarity index 66%
rename from apier/v1/tpaliasprofiles.go
rename to apier/v1/tpattributes.go
index 0d32a997d..1725c024b 100644
--- a/apier/v1/tpaliasprofiles.go
+++ b/apier/v1/tpattributes.go
@@ -22,29 +22,29 @@ import (
"github.com/cgrates/cgrates/utils"
)
-// Creates a new alias within a tariff plan
-func (self *ApierV1) SetTPAliasProfile(attrs utils.TPAlias, reply *string) error {
+// Creates a new attribute within a tariff plan
+func (self *ApierV1) SetTPAttribute(attrs utils.TPAttribute, reply *string) error {
if missing := utils.MissingStructFields(&attrs, []string{"TPid", "Tenant", "ID"}); len(missing) != 0 {
return utils.NewErrMandatoryIeMissing(missing...)
}
- if err := self.StorDb.SetTPAliasProfiles([]*utils.TPAlias{&attrs}); err != nil {
+ if err := self.StorDb.SetTPAttributes([]*utils.TPAttribute{&attrs}); err != nil {
return utils.NewErrServerError(err)
}
*reply = utils.OK
return nil
}
-type AttrGetTPAliasProfile struct {
+type AttrGetTPAttribute struct {
TPid string // Tariff plan id
ID string
}
-// Queries specific Alias on Tariff plan
-func (self *ApierV1) GetTPAliasProfile(attr AttrGetTPAliasProfile, reply *utils.TPAlias) error {
+// Queries specific Attribute on Tariff plan
+func (self *ApierV1) GetTPAttribute(attr AttrGetTPAttribute, reply *utils.TPAttribute) error {
if missing := utils.MissingStructFields(&attr, []string{"TPid", "ID"}); len(missing) != 0 { //Params missing
return utils.NewErrMandatoryIeMissing(missing...)
}
- if als, err := self.StorDb.GetTPAliasProfiles(attr.TPid, attr.ID); err != nil {
+ if als, err := self.StorDb.GetTPAttributes(attr.TPid, attr.ID); err != nil {
if err.Error() != utils.ErrNotFound.Error() {
err = utils.NewErrServerError(err)
}
@@ -55,17 +55,17 @@ func (self *ApierV1) GetTPAliasProfile(attr AttrGetTPAliasProfile, reply *utils.
return nil
}
-type AttrGetTPAliasProfileIds struct {
+type AttrGetTPAttributeIds struct {
TPid string // Tariff plan id
utils.Paginator
}
-// Queries alias identities on specific tariff plan.
-func (self *ApierV1) GetTPAliasProfileIds(attrs AttrGetTPAliasProfileIds, reply *[]string) error {
+// Queries attribute identities on specific tariff plan.
+func (self *ApierV1) GetTPAttributeIds(attrs AttrGetTPAttributeIds, reply *[]string) error {
if missing := utils.MissingStructFields(&attrs, []string{"TPid"}); len(missing) != 0 { //Params missing
return utils.NewErrMandatoryIeMissing(missing...)
}
- if ids, err := self.StorDb.GetTpTableIds(attrs.TPid, utils.TBLTPAlias, utils.TPDistinctIds{"id"}, nil, &attrs.Paginator); err != nil {
+ if ids, err := self.StorDb.GetTpTableIds(attrs.TPid, utils.TBLTPAttributes, utils.TPDistinctIds{"id"}, nil, &attrs.Paginator); err != nil {
return utils.NewErrServerError(err)
} else if ids == nil {
return utils.ErrNotFound
@@ -75,18 +75,18 @@ func (self *ApierV1) GetTPAliasProfileIds(attrs AttrGetTPAliasProfileIds, reply
return nil
}
-type AttrRemTPAliasProfiles struct {
+type AttrRemTPAttribute struct {
TPid string // Tariff plan id
Tenant string
- ID string // LCR id
+ ID string // Attribute id
}
-// Removes specific Alias on Tariff plan
-func (self *ApierV1) RemTPAliasProfile(attrs AttrRemTPAliasProfiles, reply *string) error {
+// Removes specific Attribute on Tariff plan
+func (self *ApierV1) RemTPAttribute(attrs AttrRemTPAttribute, reply *string) error {
if missing := utils.MissingStructFields(&attrs, []string{"TPid", "Tenant", "ID"}); len(missing) != 0 { //Params missing
return utils.NewErrMandatoryIeMissing(missing...)
}
- if err := self.StorDb.RemTpData(utils.TBLTPAlias, attrs.TPid, map[string]string{"tenant": attrs.Tenant, "id": attrs.ID}); err != nil {
+ if err := self.StorDb.RemTpData(utils.TBLTPAttributes, attrs.TPid, map[string]string{"tenant": attrs.Tenant, "id": attrs.ID}); err != nil {
return utils.NewErrServerError(err)
} else {
*reply = utils.OK
diff --git a/apier/v1/tpaliasprofiles_it_test.go b/apier/v1/tpattributes_it_test.go
similarity index 74%
rename from apier/v1/tpaliasprofiles_it_test.go
rename to apier/v1/tpattributes_it_test.go
index 752e4c6ce..d1e4d3c19 100644
--- a/apier/v1/tpaliasprofiles_it_test.go
+++ b/apier/v1/tpattributes_it_test.go
@@ -36,7 +36,7 @@ var (
tpAlsPrfCfg *config.CGRConfig
tpAlsPrfRPC *rpc.Client
tpAlsPrfDataDir = "/usr/share/cgrates"
- tpAlsPrf *utils.TPAlias
+ tpAlsPrf *utils.TPAttribute
tpAlsPrfDelay int
tpAlsPrfConfigDIR string //run tests for specific configuration
)
@@ -113,33 +113,35 @@ func testTPAlsPrfRPCConn(t *testing.T) {
}
func testTPAlsPrfGetTPAlsPrfBeforeSet(t *testing.T) {
- var reply *utils.TPAlias
- if err := tpAlsPrfRPC.Call("ApierV1.GetTPAliasProfile", &AttrGetTPAliasProfile{TPid: "TP1", ID: "ALS1"}, &reply); err == nil || err.Error() != utils.ErrNotFound.Error() {
+ var reply *utils.TPAttribute
+ if err := tpAlsPrfRPC.Call("ApierV1.GetTPAttribute", &AttrGetTPAttribute{TPid: "TP1", ID: "ALS1"}, &reply); err == nil || err.Error() != utils.ErrNotFound.Error() {
t.Error(err)
}
}
func testTPAlsPrfSetTPAlsPrf(t *testing.T) {
- tpAlsPrf = &utils.TPAlias{
+ tpAlsPrf = &utils.TPAttribute{
TPid: "TP1",
Tenant: "cgrates.org",
- ID: "ALS1",
+ ID: "Attr1",
FilterIDs: []string{"FLTR_ACNT_dan", "FLTR_DST_DE"},
ActivationInterval: &utils.TPActivationInterval{
ActivationTime: "2014-07-29T15:00:00Z",
ExpiryTime: "",
},
- Aliases: []*utils.TPAliasEntry{
- &utils.TPAliasEntry{
+ Context: "con1",
+ Attributes: []*utils.TPRequestAttribute{
+ &utils.TPRequestAttribute{
FieldName: "FL1",
Initial: "In1",
Alias: "Al1",
+ Append: true,
},
},
Weight: 20,
}
var result string
- if err := tpAlsPrfRPC.Call("ApierV1.SetTPAliasProfile", tpAlsPrf, &result); err != nil {
+ if err := tpAlsPrfRPC.Call("ApierV1.SetTPAttribute", tpAlsPrf, &result); err != nil {
t.Error(err)
} else if result != utils.OK {
t.Error("Unexpected reply returned", result)
@@ -147,8 +149,8 @@ func testTPAlsPrfSetTPAlsPrf(t *testing.T) {
}
func testTPAlsPrfGetTPAlsPrfAfterSet(t *testing.T) {
- var reply *utils.TPAlias
- if err := tpAlsPrfRPC.Call("ApierV1.GetTPAliasProfile", &AttrGetTPAliasProfile{TPid: "TP1", ID: "ALS1"}, &reply); err != nil {
+ var reply *utils.TPAttribute
+ if err := tpAlsPrfRPC.Call("ApierV1.GetTPAttribute", &AttrGetTPAttribute{TPid: "TP1", ID: "Attr1"}, &reply); err != nil {
t.Error(err)
} else if !reflect.DeepEqual(tpAlsPrf, reply) {
t.Errorf("Expecting : %+v, received: %+v", tpAlsPrf, reply)
@@ -157,8 +159,8 @@ func testTPAlsPrfGetTPAlsPrfAfterSet(t *testing.T) {
func testTPAlsPrfGetTPAlsPrfIDs(t *testing.T) {
var result []string
- expectedTPID := []string{"ALS1"}
- if err := tpAlsPrfRPC.Call("ApierV1.GetTPAliasProfileIds", &AttrGetTPAliasProfileIds{TPid: "TP1"}, &result); err != nil {
+ expectedTPID := []string{"Attr1"}
+ if err := tpAlsPrfRPC.Call("ApierV1.GetTPAttributeIds", &AttrGetTPAttributeIds{TPid: "TP1"}, &result); err != nil {
t.Error(err)
} else if !reflect.DeepEqual(expectedTPID, result) {
t.Errorf("Expecting: %+v, received: %+v", expectedTPID, result)
@@ -166,20 +168,22 @@ func testTPAlsPrfGetTPAlsPrfIDs(t *testing.T) {
}
func testTPAlsPrfUpdateTPAlsPrf(t *testing.T) {
- tpAlsPrf.Aliases = []*utils.TPAliasEntry{
- &utils.TPAliasEntry{
+ tpAlsPrf.Attributes = []*utils.TPRequestAttribute{
+ &utils.TPRequestAttribute{
FieldName: "FL1",
Initial: "In1",
Alias: "Al1",
+ Append: true,
},
- &utils.TPAliasEntry{
+ &utils.TPRequestAttribute{
FieldName: "FL2",
Initial: "In2",
Alias: "Al2",
+ Append: false,
},
}
var result string
- if err := tpAlsPrfRPC.Call("ApierV1.SetTPAliasProfile", tpAlsPrf, &result); err != nil {
+ if err := tpAlsPrfRPC.Call("ApierV1.SetTPAttribute", tpAlsPrf, &result); err != nil {
t.Error(err)
} else if result != utils.OK {
t.Error("Unexpected reply returned", result)
@@ -187,18 +191,17 @@ func testTPAlsPrfUpdateTPAlsPrf(t *testing.T) {
}
func testTPAlsPrfGetTPAlsPrfAfterUpdate(t *testing.T) {
- var result []string
- expectedTPID := []string{"ALS1"}
- if err := tpAlsPrfRPC.Call("ApierV1.GetTPAliasProfileIds", &AttrGetTPAliasProfileIds{TPid: "TP1"}, &result); err != nil {
+ var reply *utils.TPAttribute
+ if err := tpAlsPrfRPC.Call("ApierV1.GetTPAttribute", &AttrGetTPAttribute{TPid: "TP1", ID: "Attr1"}, &reply); err != nil {
t.Error(err)
- } else if !reflect.DeepEqual(expectedTPID, result) {
- t.Errorf("Expecting: %+v, received: %+v", expectedTPID, result)
+ } else if !reflect.DeepEqual(tpAlsPrf, reply) {
+ t.Errorf("Expecting : %+v, received: %+v", tpAlsPrf, reply)
}
}
func testTPAlsPrfRemTPAlsPrf(t *testing.T) {
var resp string
- if err := tpAlsPrfRPC.Call("ApierV1.RemTPAliasProfile", &AttrRemTPAliasProfiles{TPid: "TP1", Tenant: "cgrates.org", ID: "ALS1"}, &resp); err != nil {
+ if err := tpAlsPrfRPC.Call("ApierV1.RemTPAttribute", &AttrRemTPAttribute{TPid: "TP1", Tenant: "cgrates.org", ID: "Attr1"}, &resp); err != nil {
t.Error(err)
} else if resp != utils.OK {
t.Error("Unexpected reply returned", resp)
@@ -206,8 +209,8 @@ func testTPAlsPrfRemTPAlsPrf(t *testing.T) {
}
func testTPAlsPrfGetTPAlsPrfAfterRemove(t *testing.T) {
- var reply *utils.TPAlias
- if err := tpAlsPrfRPC.Call("ApierV1.GetTPAliasProfile", &AttrGetTPAliasProfile{TPid: "TP1", ID: "ALS1"}, &reply); err == nil || err.Error() != utils.ErrNotFound.Error() {
+ var reply *utils.TPAttribute
+ if err := tpAlsPrfRPC.Call("ApierV1.GetTPAttribute", &AttrGetTPAttribute{TPid: "TP1", ID: "ALS1"}, &reply); err == nil || err.Error() != utils.ErrNotFound.Error() {
t.Error(err)
}
}
diff --git a/apier/v2/apier.go b/apier/v2/apier.go
index e84bd5010..a707d6dd0 100644
--- a/apier/v2/apier.go
+++ b/apier/v2/apier.go
@@ -145,7 +145,7 @@ func (self *ApierV2) LoadTariffPlanFromFolder(attrs utils.AttrLoadTpFromFolder,
path.Join(attrs.FolderPath, utils.ThresholdsCsv),
path.Join(attrs.FolderPath, utils.FiltersCsv),
path.Join(attrs.FolderPath, utils.SuppliersCsv),
- path.Join(attrs.FolderPath, utils.AliasCsv),
+ path.Join(attrs.FolderPath, utils.AttributesCsv),
), "", self.Config.DefaultTimezone)
if err := loader.LoadAll(); err != nil {
return utils.NewErrServerError(err)
diff --git a/cmd/cgr-engine/cgr-engine.go b/cmd/cgr-engine/cgr-engine.go
index e528b23a1..d3a6ce206 100644
--- a/cmd/cgr-engine/cgr-engine.go
+++ b/cmd/cgr-engine/cgr-engine.go
@@ -538,28 +538,28 @@ func startUsersServer(internalUserSChan chan rpcclient.RpcClientConnection, dm *
internalUserSChan <- userServer
}
-// startAliasService fires up the AliasS
-func startAliasService(internalAliasSChan chan rpcclient.RpcClientConnection, cfg *config.CGRConfig,
+// startAttributeService fires up the AttributeS
+func startAttributeService(internalAttributeSChan chan rpcclient.RpcClientConnection, cfg *config.CGRConfig,
dm *engine.DataManager, server *utils.Server, exitChan chan bool, filterSChan chan *engine.FilterS) {
filterS := <-filterSChan
filterSChan <- filterS
- aS, err := engine.NewAliasService(dm, filterS, cfg.AliasSCfg().IndexedFields)
+ aS, err := engine.NewAttributeService(dm, filterS, cfg.AttributeSCfg().IndexedFields)
if err != nil {
- utils.Logger.Crit(fmt.Sprintf("<%s> Could not init, error: %s", utils.AliasS, err.Error()))
+ utils.Logger.Crit(fmt.Sprintf("<%s> Could not init, error: %s", utils.AttributeS, err.Error()))
exitChan <- true
return
}
go func() {
if err := aS.ListenAndServe(exitChan); err != nil {
- utils.Logger.Crit(fmt.Sprintf("<%s> Error: %s listening for packets", utils.AliasS, err.Error()))
+ utils.Logger.Crit(fmt.Sprintf("<%s> Error: %s listening for packets", utils.AttributeS, err.Error()))
}
aS.Shutdown()
exitChan <- true
return
}()
- aSv1 := v1.NewAliasSv1(aS)
+ aSv1 := v1.NewAttributeSv1(aS)
server.RpcRegister(aSv1)
- internalAliasSChan <- aSv1
+ internalAttributeSChan <- aSv1
}
func startResourceService(internalRsChan, internalThresholdSChan chan rpcclient.RpcClientConnection, cfg *config.CGRConfig,
@@ -891,7 +891,7 @@ func main() {
internalUserSChan := make(chan rpcclient.RpcClientConnection, 1)
internalAliaseSChan := make(chan rpcclient.RpcClientConnection, 1)
internalSMGChan := make(chan *sessionmanager.SMGeneric, 1)
- internalAliasSChan := make(chan rpcclient.RpcClientConnection, 1)
+ internalAttributeSChan := make(chan rpcclient.RpcClientConnection, 1)
internalRsChan := make(chan rpcclient.RpcClientConnection, 1)
internalStatSChan := make(chan rpcclient.RpcClientConnection, 1)
internalThresholdSChan := make(chan rpcclient.RpcClientConnection, 1)
@@ -990,8 +990,8 @@ func main() {
// Start FilterS
go startFilterService(filterSChan, internalStatSChan, cfg, dm, exitChan)
- if cfg.AliasSCfg().Enabled {
- go startAliasService(internalAliasSChan, cfg, dm, server, exitChan, filterSChan)
+ if cfg.AttributeSCfg().Enabled {
+ go startAttributeService(internalAttributeSChan, cfg, dm, server, exitChan, filterSChan)
}
// Start RL service
diff --git a/cmd/cgr-engine/rater.go b/cmd/cgr-engine/rater.go
index ea14fc036..567476035 100755
--- a/cmd/cgr-engine/rater.go
+++ b/cmd/cgr-engine/rater.go
@@ -107,7 +107,7 @@ func startRater(internalRaterChan chan rpcclient.RpcClientConnection, cacheDoneC
if cCfg, has := cacheCfg[utils.CacheSupplierProfiles]; !has || !cCfg.Precache {
sppIDs = make([]string, 0)
}
- if cCfg, has := cacheCfg[utils.CacheAliasProfiles]; !has || !cCfg.Precache {
+ if cCfg, has := cacheCfg[utils.CacheAttributeProfiles]; !has || !cCfg.Precache {
alsPrfIDs = make([]string, 0)
}
diff --git a/cmd/cgr-loader/cgr-loader.go b/cmd/cgr-loader/cgr-loader.go
index 98a37d8b5..d55e01a2e 100755
--- a/cmd/cgr-loader/cgr-loader.go
+++ b/cmd/cgr-loader/cgr-loader.go
@@ -150,7 +150,7 @@ func main() {
path.Join(*dataPath, utils.ThresholdsCsv),
path.Join(*dataPath, utils.FiltersCsv),
path.Join(*dataPath, utils.SuppliersCsv),
- path.Join(*dataPath, utils.AliasCsv),
+ path.Join(*dataPath, utils.AttributesCsv),
)
}
diff --git a/config/aliascfg.go b/config/aliascfg.go
index 1f3291468..d56f847bd 100644
--- a/config/aliascfg.go
+++ b/config/aliascfg.go
@@ -19,12 +19,12 @@ along with this program. If not, see
package config
// SupplierSCfg is the configuration of supplier service
-type AliasSCfg struct {
+type AttributeSCfg struct {
Enabled bool
IndexedFields []string
}
-func (alS *AliasSCfg) loadFromJsonCfg(jsnCfg *AliasSJsonCfg) (err error) {
+func (alS *AttributeSCfg) loadFromJsonCfg(jsnCfg *AttributeSJsonCfg) (err error) {
if jsnCfg == nil {
return
}
diff --git a/config/config.go b/config/config.go
index d0a8d674c..8ef73736f 100755
--- a/config/config.go
+++ b/config/config.go
@@ -273,7 +273,7 @@ type CGRConfig struct {
AliasesServerEnabled bool // Starts PubSub as server: .
UserServerEnabled bool // Starts User as server:
UserServerIndexes []string // List of user profile field indexes
- aliasSCfg *AliasSCfg // Alias service configuration
+ attributeSCfg *AttributeSCfg // Attribute service configuration
resourceSCfg *ResourceSConfig // Configuration for resource limiter
statsCfg *StatSCfg // Configuration for StatS
thresholdSCfg *ThresholdSCfg // configuration for ThresholdS
@@ -688,7 +688,7 @@ func (self *CGRConfig) loadFromJsonCfg(jsnCfg *CgrJsonCfg) (err error) {
return err
}
- jsnAliasSCfg, err := jsnCfg.AliaServJsonCfg()
+ jsnAttributeSCfg, err := jsnCfg.AttributeServJsonCfg()
if err != nil {
return err
}
@@ -1173,11 +1173,11 @@ func (self *CGRConfig) loadFromJsonCfg(jsnCfg *CgrJsonCfg) (err error) {
}
}
- if jsnAliasSCfg != nil {
- if self.aliasSCfg == nil {
- self.aliasSCfg = new(AliasSCfg)
+ if jsnAttributeSCfg != nil {
+ if self.attributeSCfg == nil {
+ self.attributeSCfg = new(AttributeSCfg)
}
- if self.aliasSCfg.loadFromJsonCfg(jsnAliasSCfg); err != nil {
+ if self.attributeSCfg.loadFromJsonCfg(jsnAttributeSCfg); err != nil {
return err
}
}
@@ -1271,8 +1271,8 @@ func (self *CGRConfig) RadiusAgentCfg() *RadiusAgentCfg {
return self.radiusAgentCfg
}
-func (cfg *CGRConfig) AliasSCfg() *AliasSCfg {
- return cfg.aliasSCfg
+func (cfg *CGRConfig) AttributeSCfg() *AttributeSCfg {
+ return cfg.attributeSCfg
}
// ToDo: fix locking here
diff --git a/config/config_defaults.go b/config/config_defaults.go
index 425b48966..1fe562c78 100755
--- a/config/config_defaults.go
+++ b/config/config_defaults.go
@@ -121,7 +121,7 @@ const CGRATES_CFG_JSON = `
"thresholds": {"limit": -1, "ttl": "", "static_ttl": false, "precache": false}, // control thresholds caching
"filters": {"limit": -1, "ttl": "", "static_ttl": false, "precache": false}, // control filters caching
"supplier_profiles": {"limit": -1, "ttl": "", "static_ttl": false, "precache": false}, // control supplier profile caching
- "alias_profiles": {"limit": -1, "ttl": "", "static_ttl": false, "precache": false}, // control alias profile caching
+ "attribute_profiles": {"limit": -1, "ttl": "", "static_ttl": false, "precache": false}, // control attribute profile caching
},
@@ -424,8 +424,8 @@ const CGRATES_CFG_JSON = `
},
-"alias": { // Alias service (*new)
- "enabled": false, // starts Alias service: .
+"attributes": { // Attribute service
+ "enabled": false, // starts attribute service: .
"indexed_fields": [], // query indexes based on these fields for faster processing
},
diff --git a/config/config_json.go b/config/config_json.go
index 13887b53a..77c4e12c8 100644
--- a/config/config_json.go
+++ b/config/config_json.go
@@ -57,7 +57,7 @@ const (
PUBSUBSERV_JSN = "pubsubs"
ALIASESSERV_JSN = "aliases"
USERSERV_JSN = "users"
- ALIAS_JSN = "alias"
+ ATTRIBUTE_JSN = "attributes"
RESOURCES_JSON = "resources"
STATS_JSON = "stats"
THRESHOLDS_JSON = "thresholds"
@@ -366,12 +366,12 @@ func (self CgrJsonCfg) UserServJsonCfg() (*UserServJsonCfg, error) {
return cfg, nil
}
-func (cgrJsn CgrJsonCfg) AliaServJsonCfg() (*AliasSJsonCfg, error) {
- rawCfg, hasKey := cgrJsn[ALIAS_JSN]
+func (cgrJsn CgrJsonCfg) AttributeServJsonCfg() (*AttributeSJsonCfg, error) {
+ rawCfg, hasKey := cgrJsn[ATTRIBUTE_JSN]
if !hasKey {
return nil, nil
}
- cfg := new(AliasSJsonCfg)
+ cfg := new(AttributeSJsonCfg)
if err := json.Unmarshal(*rawCfg, cfg); err != nil {
return nil, err
}
diff --git a/config/config_json_test.go b/config/config_json_test.go
index 7757f7671..8fa7f714a 100755
--- a/config/config_json_test.go
+++ b/config/config_json_test.go
@@ -139,7 +139,7 @@ func TestCacheJsonCfg(t *testing.T) {
utils.CacheSupplierProfiles: &CacheParamJsonCfg{Limit: utils.IntPointer(-1),
Ttl: utils.StringPointer(""), Static_ttl: utils.BoolPointer(false),
Precache: utils.BoolPointer(false)},
- utils.CacheAliasProfiles: &CacheParamJsonCfg{Limit: utils.IntPointer(-1),
+ utils.CacheAttributeProfiles: &CacheParamJsonCfg{Limit: utils.IntPointer(-1),
Ttl: utils.StringPointer(""), Static_ttl: utils.BoolPointer(false),
Precache: utils.BoolPointer(false)},
}
@@ -697,12 +697,12 @@ func TestDfUserServJsonCfg(t *testing.T) {
}
}
-func TestDfAliaServJsonCfg(t *testing.T) {
- eCfg := &AliasSJsonCfg{
+func TestDfAttributeServJsonCfg(t *testing.T) {
+ eCfg := &AttributeSJsonCfg{
Enabled: utils.BoolPointer(false),
Indexed_fields: utils.StringSlicePointer([]string{}),
}
- if cfg, err := dfCgrJsonCfg.AliaServJsonCfg(); err != nil {
+ if cfg, err := dfCgrJsonCfg.AttributeServJsonCfg(); err != nil {
t.Error(err)
} else if !reflect.DeepEqual(eCfg, cfg) {
t.Error("Received: ", cfg)
diff --git a/config/config_test.go b/config/config_test.go
index 253a079cd..c22afbaaa 100755
--- a/config/config_test.go
+++ b/config/config_test.go
@@ -511,7 +511,7 @@ func TestCgrCfgJSONDefaultsCacheCFG(t *testing.T) {
TTL: time.Duration(0), StaticTTL: false, Precache: false},
utils.CacheSupplierProfiles: &CacheParamConfig{Limit: -1,
TTL: time.Duration(0), StaticTTL: false, Precache: false},
- utils.CacheAliasProfiles: &CacheParamConfig{Limit: -1,
+ utils.CacheAttributeProfiles: &CacheParamConfig{Limit: -1,
TTL: time.Duration(0), StaticTTL: false, Precache: false}}
if !reflect.DeepEqual(eCacheCfg, cgrCfg.CacheCfg()) {
t.Errorf("received: %s, \nexpecting: %s",
@@ -637,13 +637,13 @@ func TestCgrCfgJSONDefaultFiltersCfg(t *testing.T) {
}
}
-func TestCgrCfgJSONDefaultSAliasSCfg(t *testing.T) {
- eAliasSCfg := &AliasSCfg{
+func TestCgrCfgJSONDefaultSAttributeSCfg(t *testing.T) {
+ eAliasSCfg := &AttributeSCfg{
Enabled: false,
IndexedFields: []string{},
}
- if !reflect.DeepEqual(eAliasSCfg, cgrCfg.aliasSCfg) {
- t.Errorf("received: %+v, expecting: %+v", eAliasSCfg, cgrCfg.aliasSCfg)
+ if !reflect.DeepEqual(eAliasSCfg, cgrCfg.attributeSCfg) {
+ t.Errorf("received: %+v, expecting: %+v", eAliasSCfg, cgrCfg.attributeSCfg)
}
}
diff --git a/config/libconfig_json.go b/config/libconfig_json.go
index 0f5020a48..cbff84f13 100755
--- a/config/libconfig_json.go
+++ b/config/libconfig_json.go
@@ -387,8 +387,8 @@ type UserServJsonCfg struct {
Indexes *[]string
}
-// Supplier service config section
-type AliasSJsonCfg struct {
+// Attribute service config section
+type AttributeSJsonCfg struct {
Enabled *bool
Indexed_fields *[]string
}
diff --git a/data/conf/cgrates/cgrates.json b/data/conf/cgrates/cgrates.json
index fe6b267ba..ad81d3f5b 100644
--- a/data/conf/cgrates/cgrates.json
+++ b/data/conf/cgrates/cgrates.json
@@ -46,7 +46,8 @@
// "derived_chargers": {"limit": 10000, "ttl":"0s", "precache": false}, // control derived charging rule caching
// "resource_limits": {"limit": 10000, "ttl":"0s", "precache": false}, // control resource limits caching
// "timings": {"limit": 10000, "ttl":"0s", "precache": false}, // control timings caching
-// "supplier_profiles": {"limit": 10000, "ttl":"0s", "precache": true}, // control lcr_rofiles caching
+// "supplier_profiles": {"limit": 10000, "ttl":"0s", "precache": true}, // control supplier_profile caching
+// "attribute_profiles": {"limit": 10000, "ttl":"0s", "precache": true}, // control attribute_profiles caching
// },
diff --git a/data/conf/samples/tutmongo/cgrates.json b/data/conf/samples/tutmongo/cgrates.json
index 7fc5fb1b5..12664e7ca 100644
--- a/data/conf/samples/tutmongo/cgrates.json
+++ b/data/conf/samples/tutmongo/cgrates.json
@@ -50,7 +50,7 @@
"threshold_profiles": {"limit": 10000, "ttl":"0s", "precache": true},
"filters": {"limit": 10000, "ttl":"0s", "precache": true},
"supplier_profiles": {"limit": 10000, "ttl":"0s", "precache": true},
- "alias_profiles": {"limit": 10000, "ttl":"0s", "precache": true},
+ "attribute_profiles": {"limit": 10000, "ttl":"0s", "precache": true},
},
diff --git a/data/conf/samples/tutmysql/cgrates.json b/data/conf/samples/tutmysql/cgrates.json
index d9b270523..60cdd6e27 100644
--- a/data/conf/samples/tutmysql/cgrates.json
+++ b/data/conf/samples/tutmysql/cgrates.json
@@ -43,7 +43,7 @@
"threshold_profiles": {"limit": 10000, "ttl":"0s", "precache": true},
"filters": {"limit": 10000, "ttl":"0s", "precache": true},
"supplier_profiles": {"limit": 10000, "ttl":"0s", "precache": true},
- "alias_profiles": {"limit": 10000, "ttl":"0s", "precache": true},
+ "attribute_profiles": {"limit": 10000, "ttl":"0s", "precache": true},
},
@@ -116,7 +116,7 @@
},
-"alias": { // Alias service (*new)
+"attributes": { // Attribute service
"enabled": true, // starts Alias service: .
"indexed_fields": [], // query indexes based on these fields for faster processing
},
diff --git a/data/storage/mysql/create_tariffplan_tables.sql b/data/storage/mysql/create_tariffplan_tables.sql
index 003bd58e5..cb4554179 100644
--- a/data/storage/mysql/create_tariffplan_tables.sql
+++ b/data/storage/mysql/create_tariffplan_tables.sql
@@ -520,26 +520,28 @@ CREATE TABLE tp_suppliers (
);
--
--- Table structure for table `tp_alias`
+-- Table structure for table `tp_attributes`
--
-DROP TABLE IF EXISTS tp_alias;
-CREATE TABLE tp_alias (
+DROP TABLE IF EXISTS tp_attributes;
+CREATE TABLE tp_attributes (
`pk` int(11) NOT NULL AUTO_INCREMENT,
`tpid` varchar(64) NOT NULL,
`tenant` varchar(64) NOT NULL,
`id` varchar(64) NOT NULL,
`filter_ids` varchar(64) NOT NULL,
`activation_interval` varchar(64) NOT NULL,
+ `context` varchar(64) NOT NULL,
`field_name` varchar(64) NOT NULL,
`initial` varchar(64) NOT NULL,
`alias` varchar(64) NOT NULL,
+ `append` BOOLEAN NOT NULL,
`weight` decimal(8,2) NOT NULL,
`created_at` TIMESTAMP,
PRIMARY KEY (`pk`),
KEY `tpid` (`tpid`),
- UNIQUE KEY `unique_tp_alias` (`tpid`,`tenant`,
+ UNIQUE KEY `unique_tp_attributes` (`tpid`,`tenant`,
`id`,`filter_ids`,`field_name`,`initial`,`alias` )
);
diff --git a/data/storage/postgres/create_tariffplan_tables.sql b/data/storage/postgres/create_tariffplan_tables.sql
index 4571e7d1e..d406603f3 100644
--- a/data/storage/postgres/create_tariffplan_tables.sql
+++ b/data/storage/postgres/create_tariffplan_tables.sql
@@ -511,25 +511,27 @@ CREATE INDEX tp_suppliers_unique ON tp_suppliers ("tpid", "tenant", "id",
"supplier_ratingplan_ids","supplier_resource_ids","supplier_stat_ids");
--
- -- Table structure for table `tp_alias_profiles`
+ -- Table structure for table `tp_attributes`
--
- DROP TABLE IF EXISTS tp_alias;
- CREATE TABLE tp_alias (
+ DROP TABLE IF EXISTS tp_attributes;
+ CREATE TABLE tp_attributes (
"pk" SERIAL PRIMARY KEY,
"tpid" varchar(64) NOT NULL,
"tenant"varchar(64) NOT NULL,
"id" varchar(64) NOT NULL,
"filter_ids" varchar(64) NOT NULL,
"activation_interval" varchar(64) NOT NULL,
+ "context" varchar(64) NOT NULL,
"field_name" varchar(64) NOT NULL,
"initial" varchar(64) NOT NULL,
"alias" varchar(64) NOT NULL,
+ "append" BOOLEAN NOT NULL,
"weight" decimal(8,2) NOT NULL,
"created_at" TIMESTAMP WITH TIME ZONE
);
- CREATE INDEX tp_alias_ids ON tp_alias (tpid);
- CREATE INDEX tp_alias_unique ON tp_alias ("tpid", "tenant", "id",
+ CREATE INDEX tp_attributes_ids ON tp_attributes (tpid);
+ CREATE INDEX tp_attributes_unique ON tp_attributes ("tpid", "tenant", "id",
"filter_ids","field_name","initial","alias");
diff --git a/data/tariffplans/testtp/Alias.csv b/data/tariffplans/testtp/Alias.csv
deleted file mode 100644
index eb883cb54..000000000
--- a/data/tariffplans/testtp/Alias.csv
+++ /dev/null
@@ -1,3 +0,0 @@
-#Tenant,ID,FilterIDs,ActivationInterval,FieldName,Initial,Alias,Weight
-cgrates.org,ALS1,FLTR_1,2014-01-14T00:00:00Z,Field1,Initial1,Alias1,20
-cgrates.org,ALS1,,,Field2,Initial2,Alias2,20
diff --git a/data/tariffplans/testtp/Attributes.csv b/data/tariffplans/testtp/Attributes.csv
new file mode 100644
index 000000000..48a2af10f
--- /dev/null
+++ b/data/tariffplans/testtp/Attributes.csv
@@ -0,0 +1,3 @@
+#,Tenant,ID,FilterIDs,ActivationInterval,Context,FieldName,Initial,Alias,Append,Weight
+cgrates.org,ALS1,FLTR_1,2014-07-29T15:00:00Z,con1,Field1,Initial1,Alias1,true,20
+cgrates.org,ALS1,,,,Field2,Initial2,Alias2,false,
diff --git a/data/tariffplans/tutorial/Alias.csv b/data/tariffplans/tutorial/Alias.csv
deleted file mode 100644
index a7a31f09b..000000000
--- a/data/tariffplans/tutorial/Alias.csv
+++ /dev/null
@@ -1,3 +0,0 @@
-#Tenant,ID,FilterIDs,ActivationInterval,Context,FieldName,Initial,Alias,Append,Weight
-cgrates.org,ALS1,FLTR_ACNT_1007,2014-01-14T00:00:00Z,Account,*any,1001,10
-cgrates.org,ALS1,,,Subject,*any,1001,
diff --git a/data/tariffplans/tutorial/Attributes.csv b/data/tariffplans/tutorial/Attributes.csv
new file mode 100644
index 000000000..dc87aeb31
--- /dev/null
+++ b/data/tariffplans/tutorial/Attributes.csv
@@ -0,0 +1,3 @@
+#Tenant,ID,FilterIDs,ActivationInterval,Context,FieldName,Initial,Alias,Append,Weight
+cgrates.org,ALS1,FLTR_ACNT_1007,2014-01-14T00:00:00Z,con1,Account,*any,1001,true,10
+cgrates.org,ALS1,,,,Subject,*any,1001,true,
diff --git a/engine/alias.go b/engine/attribbutes.go
similarity index 61%
rename from engine/alias.go
rename to engine/attribbutes.go
index ddee306b4..e5b2d64fc 100644
--- a/engine/alias.go
+++ b/engine/attribbutes.go
@@ -27,44 +27,44 @@ import (
"github.com/cgrates/cgrates/utils"
)
-func NewAliasService(dm *DataManager, filterS *FilterS, indexedFields []string) (*AliasService, error) {
- return &AliasService{dm: dm, filterS: filterS, indexedFields: indexedFields}, nil
+func NewAttributeService(dm *DataManager, filterS *FilterS, indexedFields []string) (*AttributeService, error) {
+ return &AttributeService{dm: dm, filterS: filterS, indexedFields: indexedFields}, nil
}
-type AliasService struct {
+type AttributeService struct {
dm *DataManager
filterS *FilterS
indexedFields []string
}
// ListenAndServe will initialize the service
-func (alS *AliasService) ListenAndServe(exitChan chan bool) (err error) {
- utils.Logger.Info("Starting Alias service")
+func (alS *AttributeService) ListenAndServe(exitChan chan bool) (err error) {
+ utils.Logger.Info("Starting Attribute service")
e := <-exitChan
exitChan <- e // put back for the others listening for shutdown request
return
}
// Shutdown is called to shutdown the service
-func (alS *AliasService) Shutdown() (err error) {
- utils.Logger.Info(fmt.Sprintf("<%s> shutdown initialized", utils.AliasS))
- utils.Logger.Info(fmt.Sprintf("<%s> shutdown complete", utils.AliasS))
+func (alS *AttributeService) Shutdown() (err error) {
+ utils.Logger.Info(fmt.Sprintf("<%s> shutdown initialized", utils.AttributeS))
+ utils.Logger.Info(fmt.Sprintf("<%s> shutdown complete", utils.AttributeS))
return
}
-// matchingSupplierProfilesForEvent returns ordered list of matching resources which are active by the time of the call
-func (alS *AliasService) matchingAliasProfilesForEvent(ev *utils.CGREvent) (aPrfls AliasProfiles, err error) {
- matchingAPs := make(map[string]*AliasProfile)
+// matchingAttributeProfilesForEvent returns ordered list of matching resources which are active by the time of the call
+func (alS *AttributeService) matchingAttributeProfilesForEvent(ev *utils.CGREvent) (aPrfls AttributeProfiles, err error) {
+ matchingAPs := make(map[string]*AttributeProfile)
aPrflIDs, err := matchingItemIDsForEvent(ev.Event, alS.indexedFields,
- alS.dm, utils.AliasProfilesStringIndex+ev.Tenant)
+ alS.dm, utils.AttributeProfilesStringIndex+ev.Tenant)
if err != nil {
return nil, err
}
- lockIDs := utils.PrefixSliceItems(aPrflIDs.Slice(), utils.AliasProfilesStringIndex)
+ lockIDs := utils.PrefixSliceItems(aPrflIDs.Slice(), utils.AttributeProfilesStringIndex)
guardian.Guardian.GuardIDs(config.CgrConfig().LockingTimeout, lockIDs...)
defer guardian.Guardian.UnguardIDs(lockIDs...)
for apID := range aPrflIDs {
- aPrfl, err := alS.dm.GetAliasProfile(ev.Tenant, apID, false, utils.NonTransactional)
+ aPrfl, err := alS.dm.GetAttributeProfile(ev.Tenant, apID, false, utils.NonTransactional)
if err != nil {
if err == utils.ErrNotFound {
continue
@@ -88,7 +88,7 @@ func (alS *AliasService) matchingAliasProfilesForEvent(ev *utils.CGREvent) (aPrf
matchingAPs[apID] = aPrfl
}
// All good, convert from Map to Slice so we can sort
- aPrfls = make(AliasProfiles, len(matchingAPs))
+ aPrfls = make(AttributeProfiles, len(matchingAPs))
i := 0
for _, aPrfl := range matchingAPs {
aPrfls[i] = aPrfl
@@ -98,9 +98,9 @@ func (alS *AliasService) matchingAliasProfilesForEvent(ev *utils.CGREvent) (aPrf
return
}
-func (alS *AliasService) aliasProfileForEvent(ev *utils.CGREvent) (alsPrfl *AliasProfile, err error) {
- var alsPrfls AliasProfiles
- if alsPrfls, err = alS.matchingAliasProfilesForEvent(ev); err != nil {
+func (alS *AttributeService) attributeProfileForEvent(ev *utils.CGREvent) (alsPrfl *AttributeProfile, err error) {
+ var alsPrfls AttributeProfiles
+ if alsPrfls, err = alS.matchingAttributeProfilesForEvent(ev); err != nil {
return
} else if len(alsPrfls) == 0 {
return nil, utils.ErrNotFound
@@ -108,21 +108,21 @@ func (alS *AliasService) aliasProfileForEvent(ev *utils.CGREvent) (alsPrfl *Alia
return alsPrfls[0], nil
}
-func (alS *AliasService) V1GetAliasForEvent(ev *utils.CGREvent,
- extAlsPrf *ExternalAliasProfile) (err error) {
- alsPrf, err := alS.aliasProfileForEvent(ev)
+func (alS *AttributeService) V1GetAttributeForEvent(ev *utils.CGREvent,
+ extAlsPrf *ExternalAttributeProfile) (err error) {
+ alsPrf, err := alS.attributeProfileForEvent(ev)
if err != nil {
if err != utils.ErrNotFound {
err = utils.NewErrServerError(err)
}
return err
}
- eAlsPrfl := NewExternalAliasProfileFromAliasProfile(alsPrf)
+ eAlsPrfl := NewExternalAttributeProfileFromAttributeProfile(alsPrf)
*extAlsPrf = *eAlsPrfl
return
}
-func (alS *AliasService) V1ProcessEvent(ev *utils.CGREvent,
+func (alS *AttributeService) V1ProcessEvent(ev *utils.CGREvent,
reply *string) (err error) {
return
}
diff --git a/engine/alias_it_test.go b/engine/attributes_it_test.go
similarity index 69%
rename from engine/alias_it_test.go
rename to engine/attributes_it_test.go
index 12b2ddf82..c03347aa9 100644
--- a/engine/alias_it_test.go
+++ b/engine/attributes_it_test.go
@@ -26,8 +26,8 @@ import (
"github.com/cgrates/cgrates/utils"
)
-func TestExternalAliasProfileAsAliasProfile(t *testing.T) {
- extAls := &ExternalAliasProfile{
+func TestExternalAttributeProfileAsAttributeProfile(t *testing.T) {
+ extAttr := &ExternalAttributeProfile{
Tenant: "cgrates.org",
ID: "ALS1",
FilterIDs: []string{"FLTR_ACNT_dan", "FLTR_DST_DE"},
@@ -35,19 +35,26 @@ func TestExternalAliasProfileAsAliasProfile(t *testing.T) {
ActivationTime: time.Date(2014, 7, 14, 14, 35, 0, 0, time.UTC).Local(),
ExpiryTime: time.Date(2014, 7, 14, 14, 35, 0, 0, time.UTC).Local(),
},
- Aliases: []*AliasEntry{
- &AliasEntry{
+ Context: "con1",
+ Attributes: []*Attribute{
+ &Attribute{
FieldName: "FL1",
Initial: "In1",
Alias: "Al1",
+ Append: true,
},
},
Weight: 20,
}
- alsMap := make(map[string]map[string]string)
- alsMap["FL1"] = make(map[string]string)
- alsMap["FL1"]["In1"] = "Al1"
- expected := &AliasProfile{
+ attrMap := make(map[string]map[string]*Attribute)
+ attrMap["FL1"] = make(map[string]*Attribute)
+ attrMap["FL1"]["In1"] = &Attribute{
+ FieldName: "FL1",
+ Initial: "In1",
+ Alias: "Al1",
+ Append: true,
+ }
+ expected := &AttributeProfile{
Tenant: "cgrates.org",
ID: "ALS1",
FilterIDs: []string{"FLTR_ACNT_dan", "FLTR_DST_DE"},
@@ -55,21 +62,27 @@ func TestExternalAliasProfileAsAliasProfile(t *testing.T) {
ActivationTime: time.Date(2014, 7, 14, 14, 35, 0, 0, time.UTC).Local(),
ExpiryTime: time.Date(2014, 7, 14, 14, 35, 0, 0, time.UTC).Local(),
},
- Aliases: alsMap,
- Weight: 20,
+ Context: "con1",
+ Attributes: attrMap,
+ Weight: 20,
}
- rcv := extAls.AsAliasProfile()
+ rcv := extAttr.AsAttributeProfile()
if !reflect.DeepEqual(expected, rcv) {
t.Errorf("Expecting : %+v, received: %+v", utils.ToJSON(expected), utils.ToJSON(rcv))
}
}
-func TestNewExternalAliasProfileFromAliasProfile(t *testing.T) {
- alsMap := make(map[string]map[string]string)
- alsMap["FL1"] = make(map[string]string)
- alsMap["FL1"]["In1"] = "Al1"
- alsPrf := &AliasProfile{
+func TestNewExternalAttributeProfileFromAttributeProfile(t *testing.T) {
+ attrMap := make(map[string]map[string]*Attribute)
+ attrMap["FL1"] = make(map[string]*Attribute)
+ attrMap["FL1"]["In1"] = &Attribute{
+ FieldName: "FL1",
+ Initial: "In1",
+ Alias: "Al1",
+ Append: true,
+ }
+ attrPrf := &AttributeProfile{
Tenant: "cgrates.org",
ID: "ALS1",
FilterIDs: []string{"FLTR_ACNT_dan", "FLTR_DST_DE"},
@@ -77,11 +90,12 @@ func TestNewExternalAliasProfileFromAliasProfile(t *testing.T) {
ActivationTime: time.Date(2014, 7, 14, 14, 35, 0, 0, time.UTC).Local(),
ExpiryTime: time.Date(2014, 7, 14, 14, 35, 0, 0, time.UTC).Local(),
},
- Aliases: alsMap,
- Weight: 20,
+ Context: "con1",
+ Attributes: attrMap,
+ Weight: 20,
}
- expected := &ExternalAliasProfile{
+ expected := &ExternalAttributeProfile{
Tenant: "cgrates.org",
ID: "ALS1",
FilterIDs: []string{"FLTR_ACNT_dan", "FLTR_DST_DE"},
@@ -89,17 +103,19 @@ func TestNewExternalAliasProfileFromAliasProfile(t *testing.T) {
ActivationTime: time.Date(2014, 7, 14, 14, 35, 0, 0, time.UTC).Local(),
ExpiryTime: time.Date(2014, 7, 14, 14, 35, 0, 0, time.UTC).Local(),
},
- Aliases: []*AliasEntry{
- &AliasEntry{
+ Context: "con1",
+ Attributes: []*Attribute{
+ &Attribute{
FieldName: "FL1",
Initial: "In1",
Alias: "Al1",
+ Append: true,
},
},
Weight: 20,
}
- rcv := NewExternalAliasProfileFromAliasProfile(alsPrf)
+ rcv := NewExternalAttributeProfileFromAttributeProfile(attrPrf)
if !reflect.DeepEqual(expected, rcv) {
t.Errorf("Expecting : %+v, received: %+v", utils.ToJSON(expected), utils.ToJSON(rcv))
}
diff --git a/engine/datamanager.go b/engine/datamanager.go
index 3816bed3e..3240ee73f 100644
--- a/engine/datamanager.go
+++ b/engine/datamanager.go
@@ -52,7 +52,7 @@ func (dm *DataManager) LoadDataDBCache(dstIDs, rvDstIDs, rplIDs, rpfIDs, actIDs,
utils.ACTION_PREFIX, utils.ACTION_PLAN_PREFIX, utils.ACTION_TRIGGER_PREFIX,
utils.SHARED_GROUP_PREFIX, utils.ALIASES_PREFIX, utils.REVERSE_ALIASES_PREFIX, utils.StatQueuePrefix,
utils.StatQueueProfilePrefix, utils.ThresholdPrefix, utils.ThresholdProfilePrefix,
- utils.FilterPrefix, utils.SupplierProfilePrefix, utils.AliasProfilePrefix}, k) && cacheCfg.Precache {
+ utils.FilterPrefix, utils.SupplierProfilePrefix, utils.AttributeProfilePrefix}, k) && cacheCfg.Precache {
if err := dm.PreloadCacheForPrefix(k); err != nil && err != utils.ErrInvalidKey {
return err
}
@@ -82,7 +82,7 @@ func (dm *DataManager) LoadDataDBCache(dstIDs, rvDstIDs, rplIDs, rpfIDs, actIDs,
utils.ThresholdProfilePrefix: thpIDs,
utils.FilterPrefix: fltrIDs,
utils.SupplierProfilePrefix: splPrflIDs,
- utils.AliasProfilePrefix: alsPrfIDs,
+ utils.AttributeProfilePrefix: alsPrfIDs,
} {
if err = dm.CacheDataFromDB(key, ids, false); err != nil {
return
@@ -141,7 +141,7 @@ func (dm *DataManager) CacheDataFromDB(prfx string, ids []string, mustBeCached b
utils.ThresholdProfilePrefix,
utils.FilterPrefix,
utils.SupplierProfilePrefix,
- utils.AliasProfilePrefix}, prfx) {
+ utils.AttributeProfilePrefix}, prfx) {
return utils.NewCGRError(utils.MONGO,
utils.MandatoryIEMissingCaps,
utils.UnsupportedCachePrefix,
@@ -230,9 +230,9 @@ func (dm *DataManager) CacheDataFromDB(prfx string, ids []string, mustBeCached b
case utils.SupplierProfilePrefix:
tntID := utils.NewTenantID(dataID)
_, err = dm.GetSupplierProfile(tntID.Tenant, tntID.ID, true, utils.NonTransactional)
- case utils.AliasProfilePrefix:
+ case utils.AttributeProfilePrefix:
tntID := utils.NewTenantID(dataID)
- _, err = dm.GetAliasProfile(tntID.Tenant, tntID.ID, true, utils.NonTransactional)
+ _, err = dm.GetAttributeProfile(tntID.Tenant, tntID.ID, true, utils.NonTransactional)
}
if err != nil {
return utils.NewCGRError(utils.MONGO,
@@ -883,17 +883,17 @@ func (dm *DataManager) RemoveSupplierProfile(tenant, id, transactionID string) (
return
}
-func (dm *DataManager) GetAliasProfile(tenant, id string, skipCache bool, transactionID string) (alsPrf *AliasProfile, err error) {
- key := utils.AliasProfilePrefix + utils.ConcatenatedKey(tenant, id)
+func (dm *DataManager) GetAttributeProfile(tenant, id string, skipCache bool, transactionID string) (alsPrf *AttributeProfile, err error) {
+ key := utils.AttributeProfilePrefix + utils.ConcatenatedKey(tenant, id)
if !skipCache {
if x, ok := cache.Get(key); ok {
if x == nil {
return nil, utils.ErrNotFound
}
- return x.(*AliasProfile), nil
+ return x.(*AttributeProfile), nil
}
}
- alsPrf, err = dm.dataDB.GetAliasProfileDrv(tenant, id)
+ alsPrf, err = dm.dataDB.GetAttributeProfileDrv(tenant, id)
if err != nil {
if err == utils.ErrNotFound {
cache.Set(key, nil, cacheCommit(transactionID), transactionID)
@@ -904,15 +904,15 @@ func (dm *DataManager) GetAliasProfile(tenant, id string, skipCache bool, transa
return
}
-func (dm *DataManager) SetAliasProfile(alsPrf *AliasProfile) (err error) {
- return dm.DataDB().SetAliasProfileDrv(alsPrf)
+func (dm *DataManager) SetAttributeProfile(alsPrf *AttributeProfile) (err error) {
+ return dm.DataDB().SetAttributeProfileDrv(alsPrf)
}
-func (dm *DataManager) RemoveAliasProfile(tenant, id, transactionID string) (err error) {
- if err = dm.DataDB().RemoveAliasProfileDrv(tenant, id); err != nil {
+func (dm *DataManager) RemoveAttributeProfile(tenant, id, transactionID string) (err error) {
+ if err = dm.DataDB().RemoveAttributeProfileDrv(tenant, id); err != nil {
return
}
- cache.RemKey(utils.AliasProfilePrefix+utils.ConcatenatedKey(tenant, id),
+ cache.RemKey(utils.AttributeProfilePrefix+utils.ConcatenatedKey(tenant, id),
cacheCommit(transactionID), transactionID)
return
}
diff --git a/engine/filterindexer.go b/engine/filterindexer.go
index 5bf133c63..71ade910c 100644
--- a/engine/filterindexer.go
+++ b/engine/filterindexer.go
@@ -168,9 +168,9 @@ func GetDBIndexKey(itemType, dbKeySuffix string, reverse bool) (dbKey string) {
case utils.SupplierProfilePrefix:
idxPrefix = utils.SupplierProfilesStringIndex
rIdxPrefix = utils.SupplierProfilesStringRevIndex
- case utils.AliasProfilePrefix:
- idxPrefix = utils.AliasProfilesStringIndex
- rIdxPrefix = utils.AliasProfilesStringRevIndex
+ case utils.AttributeProfilePrefix:
+ idxPrefix = utils.AttributeProfilesStringIndex
+ rIdxPrefix = utils.AttributeProfilesStringRevIndex
}
if reverse {
return rIdxPrefix + dbKeySuffix
diff --git a/engine/libalias.go b/engine/libattributes.go
similarity index 57%
rename from engine/libalias.go
rename to engine/libattributes.go
index 04ecfc111..52a508d24 100644
--- a/engine/libalias.go
+++ b/engine/libattributes.go
@@ -24,78 +24,81 @@ import (
"github.com/cgrates/cgrates/utils"
)
-type AliasEntry struct {
+type Attribute struct {
FieldName string
Initial string
Alias string
Append bool
}
-type AliasProfile struct {
+type AttributeProfile struct {
Tenant string
ID string
FilterIDs []string
- ActivationInterval *utils.ActivationInterval // Activation interval
- Context string // bind this AliasProfile to specific context
- Aliases map[string]map[string]string // map[FieldName][InitialValue]AliasValue
+ ActivationInterval *utils.ActivationInterval // Activation interval
+ Context string // bind this AttributeProfile to specific context
+ Attributes map[string]map[string]*Attribute // map[FieldName][InitialValue]*Attribute
Weight float64
}
-func (als *AliasProfile) TenantID() string {
+func (als *AttributeProfile) TenantID() string {
return utils.ConcatenatedKey(als.Tenant, als.ID)
}
-// AliasProfiles is a sortable list of Alias profiles
-type AliasProfiles []*AliasProfile
+// AttributeProfiles is a sortable list of Attribute profiles
+type AttributeProfiles []*AttributeProfile
// Sort is part of sort interface, sort based on Weight
-func (aps AliasProfiles) Sort() {
+func (aps AttributeProfiles) Sort() {
sort.Slice(aps, func(i, j int) bool { return aps[i].Weight > aps[j].Weight })
}
-type ExternalAliasProfile struct {
+type ExternalAttributeProfile struct {
Tenant string
ID string
FilterIDs []string
ActivationInterval *utils.ActivationInterval // Activation interval
- Aliases []*AliasEntry
+ Context string // bind this AttributeProfile to specific context
+ Attributes []*Attribute
Weight float64
}
-func (eap *ExternalAliasProfile) AsAliasProfile() *AliasProfile {
- alsPrf := &AliasProfile{
+func (eap *ExternalAttributeProfile) AsAttributeProfile() *AttributeProfile {
+ alsPrf := &AttributeProfile{
Tenant: eap.Tenant,
ID: eap.ID,
Weight: eap.Weight,
FilterIDs: eap.FilterIDs,
ActivationInterval: eap.ActivationInterval,
+ Context: eap.Context,
}
- alsMap := make(map[string]map[string]string)
- for _, als := range eap.Aliases {
- alsMap[als.FieldName] = make(map[string]string)
- alsMap[als.FieldName][als.Initial] = als.Alias
+ alsMap := make(map[string]map[string]*Attribute)
+ for _, als := range eap.Attributes {
+ alsMap[als.FieldName] = make(map[string]*Attribute)
+ alsMap[als.FieldName][als.Initial] = als
}
- alsPrf.Aliases = alsMap
+ alsPrf.Attributes = alsMap
return alsPrf
}
-func NewExternalAliasProfileFromAliasProfile(alsPrf *AliasProfile) *ExternalAliasProfile {
- extals := &ExternalAliasProfile{
+func NewExternalAttributeProfileFromAttributeProfile(alsPrf *AttributeProfile) *ExternalAttributeProfile {
+ extals := &ExternalAttributeProfile{
Tenant: alsPrf.Tenant,
ID: alsPrf.ID,
Weight: alsPrf.Weight,
ActivationInterval: alsPrf.ActivationInterval,
+ Context: alsPrf.Context,
FilterIDs: alsPrf.FilterIDs,
}
- for key, val := range alsPrf.Aliases {
+ for key, val := range alsPrf.Attributes {
for key2, val2 := range val {
- extals.Aliases = append(extals.Aliases, &AliasEntry{
+ extals.Attributes = append(extals.Attributes, &Attribute{
FieldName: key,
Initial: key2,
- Alias: val2,
+ Alias: val2.Alias,
+ Append: val2.Append,
})
}
}
return extals
-
}
diff --git a/engine/libtest.go b/engine/libtest.go
index 3742fde6d..a73d5a09e 100644
--- a/engine/libtest.go
+++ b/engine/libtest.go
@@ -137,7 +137,7 @@ func LoadTariffPlanFromFolder(tpPath, timezone string, dm *DataManager, disable_
path.Join(tpPath, utils.ThresholdsCsv),
path.Join(tpPath, utils.FiltersCsv),
path.Join(tpPath, utils.SuppliersCsv),
- path.Join(tpPath, utils.AliasCsv),
+ path.Join(tpPath, utils.AttributesCsv),
), "", timezone)
if err := loader.LoadAll(); err != nil {
return utils.NewErrServerError(err)
diff --git a/engine/loader_csv_test.go b/engine/loader_csv_test.go
index 09ed71fae..312b83e6e 100755
--- a/engine/loader_csv_test.go
+++ b/engine/loader_csv_test.go
@@ -297,10 +297,10 @@ cgrates.org,SPP_1,,,,,supplier1,,,RPL_2,ResGroup2,,10,,
cgrates.org,SPP_1,,,,,supplier1,FLTR_DST_DE,Account2,RPL_3,ResGroup3,Stat2,10,,
cgrates.org,SPP_1,,,,,supplier1,,,,ResGroup4,Stat3,10,,
`
- aliasProfiles = `
-#,Tenant,ID,FilterIDs,ActivationInterval,FieldName,Initial,Alias,Weight
-cgrates.org,ALS1,FLTR_1,2014-07-29T15:00:00Z,Field1,Initial1,Alias1,20
-cgrates.org,ALS1,,,Field2,Initial2,Alias2,
+ attributeProfiles = `
+#,Tenant,ID,FilterIDs,ActivationInterval,Context,FieldName,Initial,Alias,Append,Weight
+cgrates.org,ALS1,FLTR_1,2014-07-29T15:00:00Z,con1,Field1,Initial1,Alias1,true,20
+cgrates.org,ALS1,,,,Field2,Initial2,Alias2,false,
`
)
@@ -309,7 +309,7 @@ var csvr *TpReader
func init() {
csvr = NewTpReader(dm.dataDB, NewStringCSVStorage(',', destinations, timings, rates, destinationRates, ratingPlans, ratingProfiles,
sharedGroups, lcrs, actions, actionPlans, actionTriggers, accountActions, derivedCharges,
- cdrStats, users, aliases, resProfiles, stats, thresholds, filters, sppProfiles, aliasProfiles), testTPID, "")
+ cdrStats, users, aliases, resProfiles, stats, thresholds, filters, sppProfiles, attributeProfiles), testTPID, "")
if err := csvr.LoadDestinations(); err != nil {
log.Print("error in LoadDestinations:", err)
@@ -374,8 +374,8 @@ func init() {
if err := csvr.LoadSupplierProfiles(); err != nil {
log.Print("error in LoadSupplierProfiles:", err)
}
- if err := csvr.LoadAliasProfiles(); err != nil {
- log.Print("error in LoadAliasProfiles:", err)
+ if err := csvr.LoadAttributeProfiles(); err != nil {
+ log.Print("error in LoadAttributeProfiles:", err)
}
csvr.WriteToDatabase(false, false, false)
cache.Flush()
@@ -1665,9 +1665,9 @@ func TestLoadSupplierProfiles(t *testing.T) {
}
}
-func TestLoadAliasProfiles(t *testing.T) {
- eAlsProfiles := map[utils.TenantID]*utils.TPAlias{
- utils.TenantID{Tenant: "cgrates.org", ID: "ALS1"}: &utils.TPAlias{
+func TestLoadAttributeProfiles(t *testing.T) {
+ eAttrProfiles := map[utils.TenantID]*utils.TPAttribute{
+ utils.TenantID{Tenant: "cgrates.org", ID: "ALS1"}: &utils.TPAttribute{
TPid: testTPID,
Tenant: "cgrates.org",
ID: "ALS1",
@@ -1675,26 +1675,29 @@ func TestLoadAliasProfiles(t *testing.T) {
ActivationInterval: &utils.TPActivationInterval{
ActivationTime: "2014-07-29T15:00:00Z",
},
- Aliases: []*utils.TPAliasEntry{
- &utils.TPAliasEntry{
+ Context: "con1",
+ Attributes: []*utils.TPRequestAttribute{
+ &utils.TPRequestAttribute{
FieldName: "Field1",
Initial: "Initial1",
Alias: "Alias1",
+ Append: true,
},
- &utils.TPAliasEntry{
+ &utils.TPRequestAttribute{
FieldName: "Field2",
Initial: "Initial2",
Alias: "Alias2",
+ Append: false,
},
},
Weight: 20,
},
}
resKey := utils.TenantID{Tenant: "cgrates.org", ID: "ALS1"}
- if len(csvr.aliasProfiles) != len(eAlsProfiles) {
- t.Errorf("Failed to load AliasProfiles: %s", utils.ToIJSON(csvr.aliasProfiles))
- } else if !reflect.DeepEqual(eAlsProfiles[resKey], csvr.aliasProfiles[resKey]) {
- t.Errorf("Expecting: %+v, received: %+v", eAlsProfiles[resKey], csvr.aliasProfiles[resKey])
+ if len(csvr.attributeProfiles) != len(eAttrProfiles) {
+ t.Errorf("Failed to load attributeProfiles: %s", utils.ToIJSON(csvr.attributeProfiles))
+ } else if !reflect.DeepEqual(eAttrProfiles[resKey], csvr.attributeProfiles[resKey]) {
+ t.Errorf("Expecting: %+v, received: %+v", eAttrProfiles[resKey], csvr.attributeProfiles[resKey])
}
}
diff --git a/engine/loader_it_test.go b/engine/loader_it_test.go
index cb3914849..23da3e1f7 100755
--- a/engine/loader_it_test.go
+++ b/engine/loader_it_test.go
@@ -109,7 +109,7 @@ func TestLoaderITLoadFromCSV(t *testing.T) {
path.Join(*dataDir, "tariffplans", *tpCsvScenario, utils.ThresholdsCsv),
path.Join(*dataDir, "tariffplans", *tpCsvScenario, utils.FiltersCsv),
path.Join(*dataDir, "tariffplans", *tpCsvScenario, utils.SuppliersCsv),
- path.Join(*dataDir, "tariffplans", *tpCsvScenario, utils.AliasCsv),
+ path.Join(*dataDir, "tariffplans", *tpCsvScenario, utils.AttributesCsv),
), "", "")
if err = loader.LoadDestinations(); err != nil {
@@ -169,7 +169,7 @@ func TestLoaderITLoadFromCSV(t *testing.T) {
if err = loader.LoadSupplierProfiles(); err != nil {
t.Error("Failed loading Supplier profiles: ", err.Error())
}
- if err = loader.LoadAliasProfiles(); err != nil {
+ if err = loader.LoadAttributeProfiles(); err != nil {
t.Error("Failed loading Alias profiles: ", err.Error())
}
if err := loader.WriteToDatabase(true, false, false); err != nil {
@@ -376,12 +376,12 @@ func TestLoaderITWriteToDatabase(t *testing.T) {
}
}
- for tenatid, th := range loader.aliasProfiles {
- rcv, err := loader.dm.GetAliasProfile(tenatid.Tenant, tenatid.ID, true, utils.NonTransactional)
+ for tenatid, th := range loader.attributeProfiles {
+ rcv, err := loader.dm.GetAttributeProfile(tenatid.Tenant, tenatid.ID, true, utils.NonTransactional)
if err != nil {
- t.Errorf("Failed GetAliasProfile, tenant: %s, id: %s, error: %s ", th.Tenant, th.ID, err.Error())
+ t.Errorf("Failed GetAttributeProfile, tenant: %s, id: %s, error: %s ", th.Tenant, th.ID, err.Error())
}
- sts, err := APItoAliasProfile(th, "UTC")
+ sts, err := APItoAttributeProfile(th, "UTC")
if err != nil {
t.Error(err)
}
diff --git a/engine/model_helpers.go b/engine/model_helpers.go
index 3aac56fa6..ed5258ab0 100755
--- a/engine/model_helpers.go
+++ b/engine/model_helpers.go
@@ -2634,14 +2634,14 @@ func APItoSupplierProfile(tpTH *utils.TPSupplier, timezone string) (th *Supplier
return th, nil
}
-type TPAliases []*TPAlias
+type TPAttributes []*TPAttribute
-func (tps TPAliases) AsTPAlias() (result []*utils.TPAlias) {
- mst := make(map[string]*utils.TPAlias)
+func (tps TPAttributes) AsTPAttributes() (result []*utils.TPAttribute) {
+ mst := make(map[string]*utils.TPAttribute)
for _, tp := range tps {
th, found := mst[tp.ID]
if !found {
- th = &utils.TPAlias{
+ th = &utils.TPAttribute{
TPid: tp.Tpid,
Tenant: tp.Tenant,
ID: tp.ID,
@@ -2666,16 +2666,20 @@ func (tps TPAliases) AsTPAlias() (result []*utils.TPAlias) {
th.FilterIDs = append(th.FilterIDs, filter)
}
}
+ if tp.Context != "" {
+ th.Context = tp.Context
+ }
if tp.FieldName != "" {
- th.Aliases = append(th.Aliases, &utils.TPAliasEntry{
+ th.Attributes = append(th.Attributes, &utils.TPRequestAttribute{
FieldName: tp.FieldName,
Initial: tp.Initial,
Alias: tp.Alias,
+ Append: tp.Append,
})
}
mst[tp.ID] = th
}
- result = make([]*utils.TPAlias, len(mst))
+ result = make([]*utils.TPAttribute, len(mst))
i := 0
for _, th := range mst {
result[i] = th
@@ -2684,12 +2688,12 @@ func (tps TPAliases) AsTPAlias() (result []*utils.TPAlias) {
return
}
-func APItoModelTPAlias(th *utils.TPAlias) (mdls TPAliases) {
- if len(th.Aliases) == 0 {
+func APItoModelTPAttribute(th *utils.TPAttribute) (mdls TPAttributes) {
+ if len(th.Attributes) == 0 {
return
}
- for i, aliasEntry := range th.Aliases {
- mdl := &TPAlias{
+ for i, reqAttribute := range th.Attributes {
+ mdl := &TPAttribute{
Tpid: th.TPid,
Tenant: th.Tenant,
ID: th.ID,
@@ -2703,6 +2707,9 @@ func APItoModelTPAlias(th *utils.TPAlias) (mdls TPAliases) {
mdl.ActivationInterval += utils.INFIELD_SEP + th.ActivationInterval.ExpiryTime
}
}
+ if th.Context != "" {
+ mdl.Context = th.Context
+ }
for i, val := range th.FilterIDs {
if i != 0 {
mdl.FilterIDs += utils.INFIELD_SEP
@@ -2713,30 +2720,37 @@ func APItoModelTPAlias(th *utils.TPAlias) (mdls TPAliases) {
mdl.Weight = th.Weight
}
}
- mdl.FieldName = aliasEntry.FieldName
- mdl.Initial = aliasEntry.Initial
- mdl.Alias = aliasEntry.Alias
+ mdl.FieldName = reqAttribute.FieldName
+ mdl.Initial = reqAttribute.Initial
+ mdl.Alias = reqAttribute.Alias
+ mdl.Append = reqAttribute.Append
mdls = append(mdls, mdl)
}
return
}
-func APItoAliasProfile(tpTH *utils.TPAlias, timezone string) (th *AliasProfile, err error) {
- th = &AliasProfile{
- Tenant: tpTH.Tenant,
- ID: tpTH.ID,
- Weight: tpTH.Weight,
- FilterIDs: []string{},
- Aliases: make(map[string]map[string]string, len(tpTH.Aliases)),
+func APItoAttributeProfile(tpTH *utils.TPAttribute, timezone string) (th *AttributeProfile, err error) {
+ th = &AttributeProfile{
+ Tenant: tpTH.Tenant,
+ ID: tpTH.ID,
+ Weight: tpTH.Weight,
+ FilterIDs: []string{},
+ Context: tpTH.Context,
+ Attributes: make(map[string]map[string]*Attribute, len(tpTH.Attributes)),
}
for _, fli := range tpTH.FilterIDs {
th.FilterIDs = append(th.FilterIDs, fli)
}
- for _, f := range tpTH.Aliases {
- if _, has := th.Aliases[f.FieldName]; !has {
- th.Aliases[f.FieldName] = make(map[string]string)
+ for _, reqAttr := range tpTH.Attributes {
+ if _, has := th.Attributes[reqAttr.FieldName]; !has {
+ th.Attributes[reqAttr.FieldName] = make(map[string]*Attribute)
+ }
+ th.Attributes[reqAttr.FieldName][reqAttr.Initial] = &Attribute{
+ FieldName: reqAttr.FieldName,
+ Initial: reqAttr.Initial,
+ Alias: reqAttr.Alias,
+ Append: reqAttr.Append,
}
- th.Aliases[f.FieldName][f.Initial] = f.Alias
}
if tpTH.ActivationInterval != nil {
if th.ActivationInterval, err = tpTH.ActivationInterval.AsActivationInterval(timezone); err != nil {
diff --git a/engine/model_helpers_test.go b/engine/model_helpers_test.go
index 2e53c39c8..393adfe13 100755
--- a/engine/model_helpers_test.go
+++ b/engine/model_helpers_test.go
@@ -1060,8 +1060,8 @@ func TestFilterToTPFilter(t *testing.T) {
}
}
-func TestAPItoAliasProfile(t *testing.T) {
- tpAlsPrf := &utils.TPAlias{
+func TestAPItoAttributeProfile(t *testing.T) {
+ tpAlsPrf := &utils.TPAttribute{
TPid: "TP1",
Tenant: "cgrates.org",
ID: "ALS1",
@@ -1070,37 +1070,45 @@ func TestAPItoAliasProfile(t *testing.T) {
ActivationTime: "2014-07-14T14:35:00Z",
ExpiryTime: "",
},
- Aliases: []*utils.TPAliasEntry{
- &utils.TPAliasEntry{
+ Context: "con1",
+ Attributes: []*utils.TPRequestAttribute{
+ &utils.TPRequestAttribute{
FieldName: "FL1",
Initial: "In1",
Alias: "Al1",
+ Append: true,
},
},
Weight: 20,
}
- alsMap := make(map[string]map[string]string)
- alsMap["FL1"] = make(map[string]string)
- alsMap["FL1"]["In1"] = "Al1"
- expected := &AliasProfile{
+ attrMap := make(map[string]map[string]*Attribute)
+ attrMap["FL1"] = make(map[string]*Attribute)
+ attrMap["FL1"]["In1"] = &Attribute{
+ FieldName: "FL1",
+ Initial: "In1",
+ Alias: "Al1",
+ Append: true,
+ }
+ expected := &AttributeProfile{
Tenant: "cgrates.org",
ID: "ALS1",
FilterIDs: []string{"FLTR_ACNT_dan", "FLTR_DST_DE"},
ActivationInterval: &utils.ActivationInterval{
ActivationTime: time.Date(2014, 7, 14, 14, 35, 0, 0, time.UTC),
},
- Aliases: alsMap,
- Weight: 20,
+ Context: "con1",
+ Attributes: attrMap,
+ Weight: 20,
}
- if rcv, err := APItoAliasProfile(tpAlsPrf, "UTC"); err != nil {
+ if rcv, err := APItoAttributeProfile(tpAlsPrf, "UTC"); err != nil {
t.Error(err)
} else if !reflect.DeepEqual(expected, rcv) {
t.Errorf("Expecting : %+v, received: %+v", utils.ToJSON(expected), utils.ToJSON(rcv))
}
}
-func TestAPItoModelTPAlias(t *testing.T) {
- tpAlsPrf := &utils.TPAlias{
+func TestAPItoModelTPAttribute(t *testing.T) {
+ tpAlsPrf := &utils.TPAttribute{
TPid: "TP1",
Tenant: "cgrates.org",
ID: "ALS1",
@@ -1109,49 +1117,55 @@ func TestAPItoModelTPAlias(t *testing.T) {
ActivationTime: "2014-07-14T14:35:00Z",
ExpiryTime: "",
},
- Aliases: []*utils.TPAliasEntry{
- &utils.TPAliasEntry{
+ Context: "con1",
+ Attributes: []*utils.TPRequestAttribute{
+ &utils.TPRequestAttribute{
FieldName: "FL1",
Initial: "In1",
Alias: "Al1",
+ Append: true,
},
},
Weight: 20,
}
- expected := TPAliases{
- &TPAlias{
+ expected := TPAttributes{
+ &TPAttribute{
Tpid: "TP1",
Tenant: "cgrates.org",
ID: "ALS1",
FilterIDs: "FLTR_ACNT_dan;FLTR_DST_DE",
+ Context: "con1",
FieldName: "FL1",
Initial: "In1",
Alias: "Al1",
+ Append: true,
ActivationInterval: "2014-07-14T14:35:00Z",
Weight: 20,
},
}
- rcv := APItoModelTPAlias(tpAlsPrf)
+ rcv := APItoModelTPAttribute(tpAlsPrf)
if !reflect.DeepEqual(expected, rcv) {
t.Errorf("Expecting : %+v, received: %+v", utils.ToJSON(expected), utils.ToJSON(rcv))
}
}
-func TestModelAsTPAlias(t *testing.T) {
- model := TPAliases{
- &TPAlias{
+func TestModelAsTPAttribute(t *testing.T) {
+ models := TPAttributes{
+ &TPAttribute{
Tpid: "TP1",
Tenant: "cgrates.org",
ID: "ALS1",
FilterIDs: "FLTR_ACNT_dan;FLTR_DST_DE",
+ Context: "con1",
FieldName: "FL1",
Initial: "In1",
Alias: "Al1",
+ Append: true,
ActivationInterval: "2014-07-14T14:35:00Z",
Weight: 20,
},
}
- expected := &utils.TPAlias{
+ expected := &utils.TPAttribute{
TPid: "TP1",
Tenant: "cgrates.org",
ID: "ALS1",
@@ -1160,16 +1174,18 @@ func TestModelAsTPAlias(t *testing.T) {
ActivationTime: "2014-07-14T14:35:00Z",
ExpiryTime: "",
},
- Aliases: []*utils.TPAliasEntry{
- &utils.TPAliasEntry{
+ Context: "con1",
+ Attributes: []*utils.TPRequestAttribute{
+ &utils.TPRequestAttribute{
FieldName: "FL1",
Initial: "In1",
Alias: "Al1",
+ Append: true,
},
},
Weight: 20,
}
- rcv := model.AsTPAlias()
+ rcv := models.AsTPAttributes()
if !reflect.DeepEqual(expected, rcv[0]) {
t.Errorf("Expecting : %+v, received: %+v", utils.ToJSON(expected), utils.ToJSON(rcv[0]))
}
diff --git a/engine/models.go b/engine/models.go
index 3804aabe5..8e9ac8a95 100755
--- a/engine/models.go
+++ b/engine/models.go
@@ -541,20 +541,18 @@ type TpSupplier struct {
CreatedAt time.Time
}
-type TPAlias struct {
+type TPAttribute struct {
PK uint `gorm:"primary_key"`
Tpid string
Tenant string `index:"0" re:""`
ID string `index:"1" re:""`
FilterIDs string `index:"2" re:""`
ActivationInterval string `index:"3" re:""`
- FieldName string `index:"4" re:""`
- Initial string `index:"5" re:""`
- Alias string `index:"6" re:""`
- Weight float64 `index:"7" re:"\d+\.?\d*"`
+ Context string `index:"4" re:""`
+ FieldName string `index:"5" re:""`
+ Initial string `index:"6" re:""`
+ Alias string `index:"7" re:""`
+ Append bool `index:"8" re:""`
+ Weight float64 `index:"9" re:"\d+\.?\d*"`
CreatedAt time.Time
}
-
-func (t TPAlias) TableName() string {
- return utils.TBLTPAlias
-}
diff --git a/engine/onstor_it_test.go b/engine/onstor_it_test.go
index 2268428af..83023bee3 100644
--- a/engine/onstor_it_test.go
+++ b/engine/onstor_it_test.go
@@ -70,7 +70,7 @@ var sTestsOnStorIT = []func(t *testing.T){
testOnStorITCacheTiming,
testOnStorITCacheFilter,
testOnStorITCacheSupplierProfile,
- testOnStorITCacheAliasProfile,
+ testOnStorITCacheAttributeProfile,
// ToDo: test cache flush for a prefix
// ToDo: testOnStorITLoadAccountingCache
testOnStorITHasData,
@@ -103,7 +103,7 @@ var sTestsOnStorIT = []func(t *testing.T){
testOnStorITCRUDThreshold,
testOnStorITCRUDFilter,
testOnStorITCRUDSupplierProfile,
- testOnStorITCRUDAliasProfile,
+ testOnStorITCRUDAttributeProfile,
}
func TestOnStorITRedisConnect(t *testing.T) {
@@ -1147,40 +1147,46 @@ func testOnStorITCacheSupplierProfile(t *testing.T) {
}
}
-func testOnStorITCacheAliasProfile(t *testing.T) {
- mapAliases := make(map[string]map[string]string)
- mapAliases["FN1"] = make(map[string]string)
- mapAliases["FN1"]["Init1"] = "Al1"
- alsProfile := &AliasProfile{
+func testOnStorITCacheAttributeProfile(t *testing.T) {
+ mapAttributes := make(map[string]map[string]*Attribute)
+ mapAttributes["FN1"] = make(map[string]*Attribute)
+ mapAttributes["FN1"]["Init1"] = &Attribute{
+ FieldName: "FN1",
+ Initial: "Init1",
+ Alias: "Val1",
+ Append: true,
+ }
+ attrProfile := &AttributeProfile{
Tenant: "cgrates.org",
- ID: "ALS1",
+ ID: "ATTRPRF1",
FilterIDs: []string{"FLTR_ACNT_dan", "FLTR_DST_DE"},
ActivationInterval: &utils.ActivationInterval{
ActivationTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC).Local(),
},
- Aliases: mapAliases,
- Weight: 20,
+ Context: "con1",
+ Attributes: mapAttributes,
+ Weight: 20,
}
- if err := onStor.SetAliasProfile(alsProfile); err != nil {
+ if err := onStor.SetAttributeProfile(attrProfile); err != nil {
t.Error(err)
}
- expectedT := []string{"alp_cgrates.org:ALS1"}
- if itm, err := onStor.DataDB().GetKeysForPrefix(utils.AliasProfilePrefix); err != nil {
+ expectedT := []string{"alp_cgrates.org:ATTRPRF1"}
+ if itm, err := onStor.DataDB().GetKeysForPrefix(utils.AttributeProfilePrefix); err != nil {
t.Error(err)
} else if !reflect.DeepEqual(expectedT, itm) {
t.Errorf("Expected : %+v, but received %+v", expectedT, itm)
}
- if _, hasIt := cache.Get(utils.AliasProfilePrefix + alsProfile.TenantID()); hasIt {
+ if _, hasIt := cache.Get(utils.AttributeProfilePrefix + attrProfile.TenantID()); hasIt {
t.Error("Already in cache")
}
- if err := onStor.CacheDataFromDB(utils.AliasProfilePrefix, []string{alsProfile.TenantID()}, false); err != nil {
+ if err := onStor.CacheDataFromDB(utils.AttributeProfilePrefix, []string{attrProfile.TenantID()}, false); err != nil {
t.Error(err)
}
- if itm, hasIt := cache.Get(utils.AliasProfilePrefix + alsProfile.TenantID()); !hasIt {
+ if itm, hasIt := cache.Get(utils.AttributeProfilePrefix + attrProfile.TenantID()); !hasIt {
t.Error("Did not cache")
- } else if rcv := itm.(*AliasProfile); !reflect.DeepEqual(alsProfile, rcv) {
- t.Errorf("Expecting: %+v, received: %+v", alsProfile, rcv)
+ } else if rcv := itm.(*AttributeProfile); !reflect.DeepEqual(attrProfile, rcv) {
+ t.Errorf("Expecting: %+v, received: %+v", attrProfile, rcv)
}
}
@@ -2486,40 +2492,46 @@ func testOnStorITCRUDSupplierProfile(t *testing.T) {
}
}
-func testOnStorITCRUDAliasProfile(t *testing.T) {
- mapAliases := make(map[string]map[string]string)
- mapAliases["FN1"] = make(map[string]string)
- mapAliases["FN1"]["Init1"] = "Al1"
- alsProfile := &AliasProfile{
+func testOnStorITCRUDAttributeProfile(t *testing.T) {
+ mapAttributes := make(map[string]map[string]*Attribute)
+ mapAttributes["FN1"] = make(map[string]*Attribute)
+ mapAttributes["FN1"]["Init1"] = &Attribute{
+ FieldName: "FN1",
+ Initial: "Init1",
+ Alias: "Val1",
+ Append: true,
+ }
+ attrProfile := &AttributeProfile{
Tenant: "cgrates.org",
- ID: "ALS1",
+ ID: "AttrPrf1",
FilterIDs: []string{"FLTR_ACNT_dan", "FLTR_DST_DE"},
ActivationInterval: &utils.ActivationInterval{
ActivationTime: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC).Local(),
},
- Aliases: mapAliases,
- Weight: 20,
+ Context: "con1",
+ Attributes: mapAttributes,
+ Weight: 20,
}
- if _, rcvErr := onStor.GetAliasProfile("cgrates.org", "ALS1", true, utils.NonTransactional); rcvErr != nil && rcvErr != utils.ErrNotFound {
+ if _, rcvErr := onStor.GetAttributeProfile("cgrates.org", "AttrPrf1", true, utils.NonTransactional); rcvErr != nil && rcvErr != utils.ErrNotFound {
t.Error(rcvErr)
}
- if err := onStor.SetAliasProfile(alsProfile); err != nil {
+ if err := onStor.SetAttributeProfile(attrProfile); err != nil {
t.Error(err)
}
- if rcv, err := onStor.GetAliasProfile("cgrates.org", "ALS1", true, utils.NonTransactional); err != nil {
+ if rcv, err := onStor.GetAttributeProfile("cgrates.org", "AttrPrf1", true, utils.NonTransactional); err != nil {
t.Error(err)
- } else if !(reflect.DeepEqual(alsProfile, rcv)) {
- t.Errorf("Expecting: %v, received: %v", alsProfile, rcv)
+ } else if !(reflect.DeepEqual(attrProfile, rcv)) {
+ t.Errorf("Expecting: %v, received: %v", attrProfile, rcv)
}
- if rcv, err := onStor.GetAliasProfile("cgrates.org", "ALS1", false, utils.NonTransactional); err != nil {
+ if rcv, err := onStor.GetAttributeProfile("cgrates.org", "AttrPrf1", false, utils.NonTransactional); err != nil {
t.Error(err)
- } else if !reflect.DeepEqual(alsProfile, rcv) {
- t.Errorf("Expecting: %v, received: %v", alsProfile, rcv)
+ } else if !reflect.DeepEqual(attrProfile, rcv) {
+ t.Errorf("Expecting: %v, received: %v", attrProfile, rcv)
}
- if err := onStor.RemoveAliasProfile(alsProfile.Tenant, alsProfile.ID, utils.NonTransactional); err != nil {
+ if err := onStor.RemoveAttributeProfile(attrProfile.Tenant, attrProfile.ID, utils.NonTransactional); err != nil {
t.Error(err)
}
- if _, rcvErr := onStor.GetAliasProfile("cgrates.org", "ALS1", true, utils.NonTransactional); rcvErr != nil && rcvErr != utils.ErrNotFound {
+ if _, rcvErr := onStor.GetAttributeProfile("cgrates.org", "AttrPrf1", true, utils.NonTransactional); rcvErr != nil && rcvErr != utils.ErrNotFound {
t.Error(rcvErr)
}
}
diff --git a/engine/storage_csv.go b/engine/storage_csv.go
index 5561dbefd..de4843739 100755
--- a/engine/storage_csv.go
+++ b/engine/storage_csv.go
@@ -34,34 +34,34 @@ type CSVStorage struct {
// file names
destinationsFn, ratesFn, destinationratesFn, timingsFn, destinationratetimingsFn, ratingprofilesFn,
sharedgroupsFn, lcrFn, actionsFn, actiontimingsFn, actiontriggersFn, accountactionsFn, derivedChargersFn,
- cdrStatsFn, usersFn, aliasesFn, resProfilesFn, statsFn, thresholdsFn, filterFn, suppProfilesFn, aliasProfilesFn string
+ cdrStatsFn, usersFn, aliasesFn, resProfilesFn, statsFn, thresholdsFn, filterFn, suppProfilesFn, attributeProfilesFn string
}
func NewFileCSVStorage(sep rune,
destinationsFn, timingsFn, ratesFn, destinationratesFn, destinationratetimingsFn, ratingprofilesFn, sharedgroupsFn, lcrFn,
actionsFn, actiontimingsFn, actiontriggersFn, accountactionsFn, derivedChargersFn, cdrStatsFn, usersFn, aliasesFn,
- resProfilesFn, statsFn, thresholdsFn, filterFn, suppProfilesFn, aliasProfilesFn string) *CSVStorage {
+ resProfilesFn, statsFn, thresholdsFn, filterFn, suppProfilesFn, attributeProfilesFn string) *CSVStorage {
c := new(CSVStorage)
c.sep = sep
c.readerFunc = openFileCSVStorage
c.destinationsFn, c.timingsFn, c.ratesFn, c.destinationratesFn, c.destinationratetimingsFn, c.ratingprofilesFn,
c.sharedgroupsFn, c.lcrFn, c.actionsFn, c.actiontimingsFn, c.actiontriggersFn, c.accountactionsFn,
- c.derivedChargersFn, c.cdrStatsFn, c.usersFn, c.aliasesFn, c.resProfilesFn, c.statsFn,
- c.thresholdsFn, c.filterFn, c.suppProfilesFn, c.aliasProfilesFn = destinationsFn, timingsFn,
+ c.derivedChargersFn, c.cdrStatsFn, c.usersFn, c.aliasesFn, c.resProfilesFn, c.statsFn, c.thresholdsFn,
+ c.filterFn, c.suppProfilesFn, c.attributeProfilesFn = destinationsFn, timingsFn,
ratesFn, destinationratesFn, destinationratetimingsFn, ratingprofilesFn, sharedgroupsFn, lcrFn,
actionsFn, actiontimingsFn, actiontriggersFn, accountactionsFn, derivedChargersFn, cdrStatsFn,
- usersFn, aliasesFn, resProfilesFn, statsFn, thresholdsFn, filterFn, suppProfilesFn, aliasProfilesFn
+ usersFn, aliasesFn, resProfilesFn, statsFn, thresholdsFn, filterFn, suppProfilesFn, attributeProfilesFn
return c
}
func NewStringCSVStorage(sep rune,
destinationsFn, timingsFn, ratesFn, destinationratesFn, destinationratetimingsFn, ratingprofilesFn, sharedgroupsFn, lcrFn,
actionsFn, actiontimingsFn, actiontriggersFn, accountactionsFn, derivedChargersFn, cdrStatsFn, usersFn,
- aliasesFn, resProfilesFn, statsFn, thresholdsFn, filterFn, suppProfilesFn, aliasProfilesFn string) *CSVStorage {
+ aliasesFn, resProfilesFn, statsFn, thresholdsFn, filterFn, suppProfilesFn, attributeProfilesFn string) *CSVStorage {
c := NewFileCSVStorage(sep, destinationsFn, timingsFn, ratesFn, destinationratesFn, destinationratetimingsFn,
ratingprofilesFn, sharedgroupsFn, lcrFn, actionsFn, actiontimingsFn, actiontriggersFn,
accountactionsFn, derivedChargersFn, cdrStatsFn, usersFn, aliasesFn, resProfilesFn,
- statsFn, thresholdsFn, filterFn, suppProfilesFn, aliasProfilesFn)
+ statsFn, thresholdsFn, filterFn, suppProfilesFn, attributeProfilesFn)
c.readerFunc = openStringCSVStorage
return c
}
@@ -742,8 +742,8 @@ func (csvs *CSVStorage) GetTPSuppliers(tpid, id string) ([]*utils.TPSupplier, er
return tpSPPs.AsTPSuppliers(), nil
}
-func (csvs *CSVStorage) GetTPAliasProfiles(tpid, id string) ([]*utils.TPAlias, error) {
- csvReader, fp, err := csvs.readerFunc(csvs.aliasProfilesFn, csvs.sep, getColumnCount(TPAlias{}))
+func (csvs *CSVStorage) GetTPAttributes(tpid, id string) ([]*utils.TPAttribute, error) {
+ csvReader, fp, err := csvs.readerFunc(csvs.attributeProfilesFn, csvs.sep, getColumnCount(TPAttribute{}))
if err != nil {
//log.Print("Could not load AliasProfile file: ", err)
// allow writing of the other values
@@ -752,22 +752,22 @@ func (csvs *CSVStorage) GetTPAliasProfiles(tpid, id string) ([]*utils.TPAlias, e
if fp != nil {
defer fp.Close()
}
- var tpAls TPAliases
+ var tpAls TPAttributes
for record, err := csvReader.Read(); err != io.EOF; record, err = csvReader.Read() {
if err != nil {
- log.Printf("bad line in %s, %s\n", csvs.aliasProfilesFn, err.Error())
+ log.Printf("bad line in %s, %s\n", csvs.attributeProfilesFn, err.Error())
return nil, err
}
- if aliasProfile, err := csvLoad(TPAlias{}, record); err != nil {
+ if attributeProfile, err := csvLoad(TPAttribute{}, record); err != nil {
log.Print("error loading tpAliasProfile: ", err)
return nil, err
} else {
- aliasProfile := aliasProfile.(TPAlias)
- aliasProfile.Tpid = tpid
- tpAls = append(tpAls, &aliasProfile)
+ attributeProfile := attributeProfile.(TPAttribute)
+ attributeProfile.Tpid = tpid
+ tpAls = append(tpAls, &attributeProfile)
}
}
- return tpAls.AsTPAlias(), nil
+ return tpAls.AsTPAttributes(), nil
}
func (csvs *CSVStorage) GetTpIds(colName string) ([]string, error) {
diff --git a/engine/storage_interface.go b/engine/storage_interface.go
index cf48be095..d447460b0 100755
--- a/engine/storage_interface.go
+++ b/engine/storage_interface.go
@@ -131,9 +131,9 @@ type DataDB interface {
GetSupplierProfileDrv(string, string) (*SupplierProfile, error)
SetSupplierProfileDrv(*SupplierProfile) error
RemoveSupplierProfileDrv(string, string) error
- GetAliasProfileDrv(string, string) (*AliasProfile, error)
- SetAliasProfileDrv(*AliasProfile) error
- RemoveAliasProfileDrv(string, string) error
+ GetAttributeProfileDrv(string, string) (*AttributeProfile, error)
+ SetAttributeProfileDrv(*AttributeProfile) error
+ RemoveAttributeProfileDrv(string, string) error
}
type StorDB interface {
@@ -182,7 +182,7 @@ type LoadReader interface {
GetTPThresholds(string, string) ([]*utils.TPThreshold, error)
GetTPFilters(string, string) ([]*utils.TPFilter, error)
GetTPSuppliers(string, string) ([]*utils.TPSupplier, error)
- GetTPAliasProfiles(string, string) ([]*utils.TPAlias, error)
+ GetTPAttributes(string, string) ([]*utils.TPAttribute, error)
}
type LoadWriter interface {
@@ -208,7 +208,7 @@ type LoadWriter interface {
SetTPThresholds([]*utils.TPThreshold) error
SetTPFilters([]*utils.TPFilter) error
SetTPSuppliers([]*utils.TPSupplier) error
- SetTPAliasProfiles([]*utils.TPAlias) error
+ SetTPAttributes([]*utils.TPAttribute) error
}
// NewMarshaler returns the marshaler type selected by mrshlerStr
diff --git a/engine/storage_map.go b/engine/storage_map.go
index 171a925b5..e2a077a55 100755
--- a/engine/storage_map.go
+++ b/engine/storage_map.go
@@ -172,7 +172,7 @@ func (ms *MapStorage) HasDataDrv(categ, subject string) (bool, error) {
case utils.DESTINATION_PREFIX, utils.RATING_PLAN_PREFIX, utils.RATING_PROFILE_PREFIX,
utils.ACTION_PREFIX, utils.ACTION_PLAN_PREFIX, utils.ACCOUNT_PREFIX, utils.DERIVEDCHARGERS_PREFIX,
utils.ResourcesPrefix, utils.StatQueuePrefix, utils.ThresholdPrefix,
- utils.FilterPrefix, utils.SupplierProfilePrefix, utils.AliasProfilePrefix:
+ utils.FilterPrefix, utils.SupplierProfilePrefix, utils.AttributeProfilePrefix:
_, exists := ms.dict[categ+subject]
return exists, nil
}
@@ -1405,10 +1405,10 @@ func (ms *MapStorage) RemoveSupplierProfileDrv(tenant, id string) (err error) {
return
}
-func (ms *MapStorage) GetAliasProfileDrv(tenant, id string) (r *AliasProfile, err error) {
+func (ms *MapStorage) GetAttributeProfileDrv(tenant, id string) (r *AttributeProfile, err error) {
ms.mu.RLock()
defer ms.mu.RUnlock()
- values, ok := ms.dict[utils.AliasProfilePrefix+utils.ConcatenatedKey(tenant, id)]
+ values, ok := ms.dict[utils.AttributeProfilePrefix+utils.ConcatenatedKey(tenant, id)]
if !ok {
return nil, utils.ErrNotFound
}
@@ -1419,21 +1419,21 @@ func (ms *MapStorage) GetAliasProfileDrv(tenant, id string) (r *AliasProfile, er
return
}
-func (ms *MapStorage) SetAliasProfileDrv(r *AliasProfile) (err error) {
+func (ms *MapStorage) SetAttributeProfileDrv(r *AttributeProfile) (err error) {
ms.mu.Lock()
defer ms.mu.Unlock()
result, err := ms.ms.Marshal(r)
if err != nil {
return err
}
- ms.dict[utils.AliasProfilePrefix+utils.ConcatenatedKey(r.Tenant, r.ID)] = result
+ ms.dict[utils.AttributeProfilePrefix+utils.ConcatenatedKey(r.Tenant, r.ID)] = result
return
}
-func (ms *MapStorage) RemoveAliasProfileDrv(tenant, id string) (err error) {
+func (ms *MapStorage) RemoveAttributeProfileDrv(tenant, id string) (err error) {
ms.mu.Lock()
defer ms.mu.Unlock()
- key := utils.AliasProfilePrefix + utils.ConcatenatedKey(tenant, id)
+ key := utils.AttributeProfilePrefix + utils.ConcatenatedKey(tenant, id)
delete(ms.dict, key)
return
}
diff --git a/engine/storage_mongo_datadb.go b/engine/storage_mongo_datadb.go
index 794680957..f40b29b4c 100755
--- a/engine/storage_mongo_datadb.go
+++ b/engine/storage_mongo_datadb.go
@@ -34,38 +34,38 @@ import (
)
const (
- colDst = "destinations"
- colRds = "reverse_destinations"
- colAct = "actions"
- colApl = "action_plans"
- colAAp = "account_action_plans"
- colTsk = "tasks"
- colAtr = "action_triggers"
- colRpl = "rating_plans"
- colRpf = "rating_profiles"
- colAcc = "accounts"
- colShg = "shared_groups"
- colLcr = "lcr_rules"
- colDcs = "derived_chargers"
- colAls = "aliases"
- colRCfgs = "reverse_aliases"
- colStq = "stat_qeues"
- colPbs = "pubsub"
- colUsr = "users"
- colCrs = "cdr_stats"
- colLht = "load_history"
- colVer = "versions"
- colRsP = "resource_profiles"
- colRFI = "request_filter_indexes"
- colTmg = "timings"
- colRes = "resources"
- colSqs = "statqueues"
- colSqp = "statqueue_profiles"
- colTps = "threshold_profiles"
- colThs = "thresholds"
- colFlt = "filters"
- colSpp = "supplier_profiles"
- colAlsPrf = "alias_profiles"
+ colDst = "destinations"
+ colRds = "reverse_destinations"
+ colAct = "actions"
+ colApl = "action_plans"
+ colAAp = "account_action_plans"
+ colTsk = "tasks"
+ colAtr = "action_triggers"
+ colRpl = "rating_plans"
+ colRpf = "rating_profiles"
+ colAcc = "accounts"
+ colShg = "shared_groups"
+ colLcr = "lcr_rules"
+ colDcs = "derived_chargers"
+ colAls = "aliases"
+ colRCfgs = "reverse_aliases"
+ colStq = "stat_qeues"
+ colPbs = "pubsub"
+ colUsr = "users"
+ colCrs = "cdr_stats"
+ colLht = "load_history"
+ colVer = "versions"
+ colRsP = "resource_profiles"
+ colRFI = "request_filter_indexes"
+ colTmg = "timings"
+ colRes = "resources"
+ colSqs = "statqueues"
+ colSqp = "statqueue_profiles"
+ colTps = "threshold_profiles"
+ colThs = "thresholds"
+ colFlt = "filters"
+ colSpp = "supplier_profiles"
+ colAttr = "attribute_profiles"
)
var (
@@ -338,7 +338,7 @@ func (ms *MongoStorage) getColNameForPrefix(prefix string) (name string, ok bool
utils.ThresholdPrefix: colThs,
utils.FilterPrefix: colFlt,
utils.SupplierProfilePrefix: colSpp,
- utils.AliasProfilePrefix: colAlsPrf,
+ utils.AttributeProfilePrefix: colAttr,
}
name, ok = colMap[prefix]
return
@@ -583,10 +583,10 @@ func (ms *MongoStorage) GetKeysForPrefix(prefix string) (result []string, err er
for iter.Next(&idResult) {
result = append(result, utils.SupplierProfilePrefix+utils.ConcatenatedKey(idResult.Tenant, idResult.Id))
}
- case utils.AliasProfilePrefix:
- iter := db.C(colAlsPrf).Find(bson.M{"id": bson.M{"$regex": bson.RegEx{Pattern: subject}}}).Select(bson.M{"tenant": 1, "id": 1}).Iter()
+ case utils.AttributeProfilePrefix:
+ iter := db.C(colAttr).Find(bson.M{"id": bson.M{"$regex": bson.RegEx{Pattern: subject}}}).Select(bson.M{"tenant": 1, "id": 1}).Iter()
for iter.Next(&idResult) {
- result = append(result, utils.AliasProfilePrefix+utils.ConcatenatedKey(idResult.Tenant, idResult.Id))
+ result = append(result, utils.AttributeProfilePrefix+utils.ConcatenatedKey(idResult.Tenant, idResult.Id))
}
default:
err = fmt.Errorf("unsupported prefix in GetKeysForPrefix: %s", prefix)
@@ -633,8 +633,8 @@ func (ms *MongoStorage) HasDataDrv(category, subject string) (has bool, err erro
case utils.SupplierProfilePrefix:
count, err = db.C(colSpp).Find(bson.M{"id": subject}).Count()
has = count > 0
- case utils.AliasProfilePrefix:
- count, err = db.C(colAlsPrf).Find(bson.M{"id": subject}).Count()
+ case utils.AttributeProfilePrefix:
+ count, err = db.C(colAttr).Find(bson.M{"id": subject}).Count()
has = count > 0
default:
err = fmt.Errorf("unsupported category in HasData: %s", category)
@@ -2005,8 +2005,8 @@ func (ms *MongoStorage) RemoveSupplierProfileDrv(tenant, id string) (err error)
return nil
}
-func (ms *MongoStorage) GetAliasProfileDrv(tenant, id string) (r *AliasProfile, err error) {
- session, col := ms.conn(colAlsPrf)
+func (ms *MongoStorage) GetAttributeProfileDrv(tenant, id string) (r *AttributeProfile, err error) {
+ session, col := ms.conn(colAttr)
defer session.Close()
if err = col.Find(bson.M{"tenant": tenant, "id": id}).One(&r); err != nil {
if err == mgo.ErrNotFound {
@@ -2017,15 +2017,15 @@ func (ms *MongoStorage) GetAliasProfileDrv(tenant, id string) (r *AliasProfile,
return
}
-func (ms *MongoStorage) SetAliasProfileDrv(r *AliasProfile) (err error) {
- session, col := ms.conn(colAlsPrf)
+func (ms *MongoStorage) SetAttributeProfileDrv(r *AttributeProfile) (err error) {
+ session, col := ms.conn(colAttr)
defer session.Close()
_, err = col.Upsert(bson.M{"tenant": r.Tenant, "id": r.ID}, r)
return
}
-func (ms *MongoStorage) RemoveAliasProfileDrv(tenant, id string) (err error) {
- session, col := ms.conn(colAlsPrf)
+func (ms *MongoStorage) RemoveAttributeProfileDrv(tenant, id string) (err error) {
+ session, col := ms.conn(colAttr)
defer session.Close()
if err = col.Remove(bson.M{"tenant": tenant, "id": id}); err != nil {
return
diff --git a/engine/storage_mongo_stordb.go b/engine/storage_mongo_stordb.go
index dc5b5c4fd..288945e1e 100755
--- a/engine/storage_mongo_stordb.go
+++ b/engine/storage_mongo_stordb.go
@@ -1258,15 +1258,15 @@ func (ms *MongoStorage) SetTPSuppliers(tpSPs []*utils.TPSupplier) (err error) {
return
}
-func (ms *MongoStorage) GetTPAliasProfiles(tpid, id string) ([]*utils.TPAlias, error) {
+func (ms *MongoStorage) GetTPAttributes(tpid, id string) ([]*utils.TPAttribute, error) {
filter := bson.M{
"tpid": tpid,
}
if id != "" {
filter["id"] = id
}
- var results []*utils.TPAlias
- session, col := ms.conn(utils.TBLTPAlias)
+ var results []*utils.TPAttribute
+ session, col := ms.conn(utils.TBLTPAttributes)
defer session.Close()
err := col.Find(filter).All(&results)
if len(results) == 0 {
@@ -1275,11 +1275,11 @@ func (ms *MongoStorage) GetTPAliasProfiles(tpid, id string) ([]*utils.TPAlias, e
return results, err
}
-func (ms *MongoStorage) SetTPAliasProfiles(tpSPs []*utils.TPAlias) (err error) {
+func (ms *MongoStorage) SetTPAttributes(tpSPs []*utils.TPAttribute) (err error) {
if len(tpSPs) == 0 {
return
}
- session, col := ms.conn(utils.TBLTPAlias)
+ session, col := ms.conn(utils.TBLTPAttributes)
defer session.Close()
tx := col.Bulk()
for _, tp := range tpSPs {
diff --git a/engine/storage_redis.go b/engine/storage_redis.go
index cab12a4a5..7e309d8c9 100755
--- a/engine/storage_redis.go
+++ b/engine/storage_redis.go
@@ -209,7 +209,7 @@ func (rs *RedisStorage) HasDataDrv(category, subject string) (bool, error) {
case utils.DESTINATION_PREFIX, utils.RATING_PLAN_PREFIX, utils.RATING_PROFILE_PREFIX,
utils.ACTION_PREFIX, utils.ACTION_PLAN_PREFIX, utils.ACCOUNT_PREFIX, utils.DERIVEDCHARGERS_PREFIX,
utils.ResourcesPrefix, utils.StatQueuePrefix, utils.ThresholdPrefix,
- utils.FilterPrefix, utils.SupplierProfilePrefix, utils.AliasProfilePrefix:
+ utils.FilterPrefix, utils.SupplierProfilePrefix, utils.AttributeProfilePrefix:
i, err := rs.Cmd("EXISTS", category+subject).Int()
return i == 1, err
}
@@ -1543,8 +1543,8 @@ func (rs *RedisStorage) RemoveSupplierProfileDrv(tenant, id string) (err error)
return
}
-func (rs *RedisStorage) GetAliasProfileDrv(tenant, id string) (r *AliasProfile, err error) {
- key := utils.AliasProfilePrefix + utils.ConcatenatedKey(tenant, id)
+func (rs *RedisStorage) GetAttributeProfileDrv(tenant, id string) (r *AttributeProfile, err error) {
+ key := utils.AttributeProfilePrefix + utils.ConcatenatedKey(tenant, id)
var values []byte
if values, err = rs.Cmd("GET", key).Bytes(); err != nil {
if err == redis.ErrRespNil { // did not find the destination
@@ -1558,16 +1558,16 @@ func (rs *RedisStorage) GetAliasProfileDrv(tenant, id string) (r *AliasProfile,
return
}
-func (rs *RedisStorage) SetAliasProfileDrv(r *AliasProfile) (err error) {
+func (rs *RedisStorage) SetAttributeProfileDrv(r *AttributeProfile) (err error) {
result, err := rs.ms.Marshal(r)
if err != nil {
return err
}
- return rs.Cmd("SET", utils.AliasProfilePrefix+utils.ConcatenatedKey(r.Tenant, r.ID), result).Err
+ return rs.Cmd("SET", utils.AttributeProfilePrefix+utils.ConcatenatedKey(r.Tenant, r.ID), result).Err
}
-func (rs *RedisStorage) RemoveAliasProfileDrv(tenant, id string) (err error) {
- key := utils.AliasProfilePrefix + utils.ConcatenatedKey(tenant, id)
+func (rs *RedisStorage) RemoveAttributeProfileDrv(tenant, id string) (err error) {
+ key := utils.AttributeProfilePrefix + utils.ConcatenatedKey(tenant, id)
if err = rs.Cmd("DEL", key).Err; err != nil {
return
}
diff --git a/engine/storage_sql.go b/engine/storage_sql.go
index db6c81b13..4eee84321 100755
--- a/engine/storage_sql.go
+++ b/engine/storage_sql.go
@@ -108,7 +108,7 @@ func (self *SQLStorage) IsDBEmpty() (resp bool, err error) {
utils.TBLTPActionTriggers, utils.TBLTPAccountActions, utils.TBLTPDerivedChargers, utils.TBLTPUsers,
utils.TBLTPAliases, utils.TBLTPResources, utils.TBLTPStats, utils.TBLTPThresholds,
utils.TBLTPFilters, utils.SMCostsTBL, utils.CDRsTBL, utils.TBLTPActionPlans,
- utils.TBLVersions, utils.TBLTPSuppliers, utils.TBLTPAlias,
+ utils.TBLVersions, utils.TBLTPSuppliers, utils.TBLTPAttributes,
}
for _, tbl := range tbls {
if self.db.HasTable(tbl) {
@@ -149,7 +149,7 @@ func (self *SQLStorage) GetTpIds(colName string) ([]string, error) {
utils.TBLTPFilters,
utils.TBLTPActionPlans,
utils.TBLTPSuppliers,
- utils.TBLTPAlias)
+ utils.TBLTPAttributes)
}
rows, err = self.Db.Query(qryStr)
if err != nil {
@@ -239,7 +239,7 @@ func (self *SQLStorage) RemTpData(table, tpid string, args map[string]string) er
utils.TBLTPDestinationRates, utils.TBLTPRatingPlans, utils.TBLTPRateProfiles, utils.TBLTPSharedGroups,
utils.TBLTPCdrStats, utils.TBLTPLcrs, utils.TBLTPActions, utils.TBLTPActionPlans, utils.TBLTPActionTriggers,
utils.TBLTPAccountActions, utils.TBLTPDerivedChargers, utils.TBLTPAliases, utils.TBLTPUsers,
- utils.TBLTPResources, utils.TBLTPStats, utils.TBLTPFilters, utils.TBLTPSuppliers, utils.TBLTPAlias} {
+ utils.TBLTPResources, utils.TBLTPStats, utils.TBLTPFilters, utils.TBLTPSuppliers, utils.TBLTPAttributes} {
if err := tx.Table(tblName).Where("tpid = ?", tpid).Delete(nil).Error; err != nil {
tx.Rollback()
return err
@@ -716,18 +716,18 @@ func (self *SQLStorage) SetTPSuppliers(tpSPs []*utils.TPSupplier) error {
return nil
}
-func (self *SQLStorage) SetTPAliasProfiles(tpSPs []*utils.TPAlias) error {
- if len(tpSPs) == 0 {
+func (self *SQLStorage) SetTPAttributes(tpAttrs []*utils.TPAttribute) error {
+ if len(tpAttrs) == 0 {
return nil
}
tx := self.db.Begin()
- for _, stq := range tpSPs {
+ for _, stq := range tpAttrs {
// Remove previous
- if err := tx.Where(&TPAlias{Tpid: stq.TPid, ID: stq.ID}).Delete(TPAlias{}).Error; err != nil {
+ if err := tx.Where(&TPAttribute{Tpid: stq.TPid, ID: stq.ID}).Delete(TPAttribute{}).Error; err != nil {
tx.Rollback()
return err
}
- for _, mst := range APItoModelTPAlias(stq) {
+ for _, mst := range APItoModelTPAttribute(stq) {
if err := tx.Save(&mst).Error; err != nil {
tx.Rollback()
return err
@@ -1597,8 +1597,8 @@ func (self *SQLStorage) GetTPSuppliers(tpid, id string) ([]*utils.TPSupplier, er
return arls, nil
}
-func (self *SQLStorage) GetTPAliasProfiles(tpid, id string) ([]*utils.TPAlias, error) {
- var sps TPAliases
+func (self *SQLStorage) GetTPAttributes(tpid, id string) ([]*utils.TPAttribute, error) {
+ var sps TPAttributes
q := self.db.Where("tpid = ?", tpid)
if len(id) != 0 {
q = q.Where("id = ?", id)
@@ -1606,7 +1606,7 @@ func (self *SQLStorage) GetTPAliasProfiles(tpid, id string) ([]*utils.TPAlias, e
if err := q.Find(&sps).Error; err != nil {
return nil, err
}
- arls := sps.AsTPAlias()
+ arls := sps.AsTPAttributes()
if len(arls) == 0 {
return arls, utils.ErrNotFound
}
diff --git a/engine/tp_reader.go b/engine/tp_reader.go
index a7f1a6226..74b01183f 100755
--- a/engine/tp_reader.go
+++ b/engine/tp_reader.go
@@ -31,47 +31,47 @@ import (
)
type TpReader struct {
- tpid string
- timezone string
- dm *DataManager
- lr LoadReader
- actions map[string][]*Action
- actionPlans map[string]*ActionPlan
- actionsTriggers map[string]ActionTriggers
- accountActions map[string]*Account
- dirtyRpAliases []*TenantRatingSubject // used to clean aliases that might have changed
- dirtyAccAliases []*TenantAccount // used to clean aliases that might have changed
- destinations map[string]*Destination
- timings map[string]*utils.TPTiming
- rates map[string]*utils.TPRate
- destinationRates map[string]*utils.TPDestinationRate
- ratingPlans map[string]*RatingPlan
- ratingProfiles map[string]*RatingProfile
- sharedGroups map[string]*SharedGroup
- lcrs map[string]*LCR
- derivedChargers map[string]*utils.DerivedChargers
- cdrStats map[string]*CdrStats
- users map[string]*UserProfile
- aliases map[string]*Alias
- resProfiles map[utils.TenantID]*utils.TPResource
- sqProfiles map[utils.TenantID]*utils.TPStats
- thProfiles map[utils.TenantID]*utils.TPThreshold
- filters map[utils.TenantID]*utils.TPFilter
- sppProfiles map[utils.TenantID]*utils.TPSupplier
- aliasProfiles map[utils.TenantID]*utils.TPAlias
- resources []*utils.TenantID // IDs of resources which need creation based on resourceProfiles
- statQueues []*utils.TenantID // IDs of statQueues which need creation based on statQueueProfiles
- thresholds []*utils.TenantID // IDs of thresholds which need creation based on thresholdProfiles
- suppliers []*utils.TenantID // IDs of suppliers which need creation based on sppProfiles
- aliasTntID []*utils.TenantID // IDs of suppliers which need creation based on aliasProfiles
+ tpid string
+ timezone string
+ dm *DataManager
+ lr LoadReader
+ actions map[string][]*Action
+ actionPlans map[string]*ActionPlan
+ actionsTriggers map[string]ActionTriggers
+ accountActions map[string]*Account
+ dirtyRpAliases []*TenantRatingSubject // used to clean aliases that might have changed
+ dirtyAccAliases []*TenantAccount // used to clean aliases that might have changed
+ destinations map[string]*Destination
+ timings map[string]*utils.TPTiming
+ rates map[string]*utils.TPRate
+ destinationRates map[string]*utils.TPDestinationRate
+ ratingPlans map[string]*RatingPlan
+ ratingProfiles map[string]*RatingProfile
+ sharedGroups map[string]*SharedGroup
+ lcrs map[string]*LCR
+ derivedChargers map[string]*utils.DerivedChargers
+ cdrStats map[string]*CdrStats
+ users map[string]*UserProfile
+ aliases map[string]*Alias
+ resProfiles map[utils.TenantID]*utils.TPResource
+ sqProfiles map[utils.TenantID]*utils.TPStats
+ thProfiles map[utils.TenantID]*utils.TPThreshold
+ filters map[utils.TenantID]*utils.TPFilter
+ sppProfiles map[utils.TenantID]*utils.TPSupplier
+ attributeProfiles map[utils.TenantID]*utils.TPAttribute
+ resources []*utils.TenantID // IDs of resources which need creation based on resourceProfiles
+ statQueues []*utils.TenantID // IDs of statQueues which need creation based on statQueueProfiles
+ thresholds []*utils.TenantID // IDs of thresholds which need creation based on thresholdProfiles
+ suppliers []*utils.TenantID // IDs of suppliers which need creation based on sppProfiles
+ attrTntID []*utils.TenantID // IDs of suppliers which need creation based on attributeProfiles
revDests,
revAliases,
acntActionPlans map[string][]string
- thdsIndexers map[string]*ReqFilterIndexer // tenant, indexer
- sqpIndexers map[string]*ReqFilterIndexer // tenant, indexer
- resIndexers map[string]*ReqFilterIndexer // tenant, indexer
- sppIndexers map[string]*ReqFilterIndexer // tenant, indexer
- aliasIndexers map[string]*ReqFilterIndexer // tenant, indexer
+ thdsIndexers map[string]*ReqFilterIndexer // tenant, indexer
+ sqpIndexers map[string]*ReqFilterIndexer // tenant, indexer
+ resIndexers map[string]*ReqFilterIndexer // tenant, indexer
+ sppIndexers map[string]*ReqFilterIndexer // tenant, indexer
+ attrIndexers map[string]*ReqFilterIndexer // tenant, indexer
}
func NewTpReader(db DataDB, lr LoadReader, tpid, timezone string) *TpReader {
@@ -143,7 +143,7 @@ func (tpr *TpReader) Init() {
tpr.sqProfiles = make(map[utils.TenantID]*utils.TPStats)
tpr.thProfiles = make(map[utils.TenantID]*utils.TPThreshold)
tpr.sppProfiles = make(map[utils.TenantID]*utils.TPSupplier)
- tpr.aliasProfiles = make(map[utils.TenantID]*utils.TPAlias)
+ tpr.attributeProfiles = make(map[utils.TenantID]*utils.TPAttribute)
tpr.filters = make(map[utils.TenantID]*utils.TPFilter)
tpr.revDests = make(map[string][]string)
tpr.revAliases = make(map[string][]string)
@@ -152,7 +152,7 @@ func (tpr *TpReader) Init() {
tpr.sqpIndexers = make(map[string]*ReqFilterIndexer)
tpr.resIndexers = make(map[string]*ReqFilterIndexer)
tpr.sppIndexers = make(map[string]*ReqFilterIndexer)
- tpr.aliasIndexers = make(map[string]*ReqFilterIndexer)
+ tpr.attrIndexers = make(map[string]*ReqFilterIndexer)
}
func (tpr *TpReader) LoadDestinationsFiltered(tag string) (bool, error) {
@@ -1813,25 +1813,25 @@ func (tpr *TpReader) LoadSupplierProfiles() error {
return tpr.LoadSupplierProfilesFiltered("")
}
-func (tpr *TpReader) LoadAliasProfilesFiltered(tag string) (err error) {
- rls, err := tpr.lr.GetTPAliasProfiles(tpr.tpid, tag)
+func (tpr *TpReader) LoadAttributeProfilesFiltered(tag string) (err error) {
+ rls, err := tpr.lr.GetTPAttributes(tpr.tpid, tag)
if err != nil {
return err
}
- mapRsPfls := make(map[utils.TenantID]*utils.TPAlias)
+ mapRsPfls := make(map[utils.TenantID]*utils.TPAttribute)
for _, rl := range rls {
mapRsPfls[utils.TenantID{Tenant: rl.Tenant, ID: rl.ID}] = rl
}
- tpr.aliasProfiles = mapRsPfls
+ tpr.attributeProfiles = mapRsPfls
for tntID, res := range mapRsPfls {
- if has, err := tpr.dm.HasData(utils.AliasProfilePrefix, tntID.TenantID()); err != nil {
+ if has, err := tpr.dm.HasData(utils.AttributeProfilePrefix, tntID.TenantID()); err != nil {
return err
} else if !has {
- tpr.aliasTntID = append(tpr.aliasTntID, &utils.TenantID{Tenant: tntID.Tenant, ID: tntID.ID})
+ tpr.attrTntID = append(tpr.attrTntID, &utils.TenantID{Tenant: tntID.Tenant, ID: tntID.ID})
}
- // index alias profile for filters
- if _, has := tpr.aliasIndexers[tntID.Tenant]; !has {
- if tpr.aliasIndexers[tntID.Tenant], err = NewReqFilterIndexer(tpr.dm, utils.AliasProfilePrefix, tntID.Tenant); err != nil {
+ // index attribute profile for filters
+ if _, has := tpr.attrIndexers[tntID.Tenant]; !has {
+ if tpr.attrIndexers[tntID.Tenant], err = NewReqFilterIndexer(tpr.dm, utils.AttributeProfilePrefix, tntID.Tenant); err != nil {
return
}
}
@@ -1848,15 +1848,15 @@ func (tpr *TpReader) LoadAliasProfilesFiltered(tag string) (err error) {
tpFltr = FilterToTPFilter(fltr)
}
} else {
- tpr.aliasIndexers[tntID.Tenant].IndexTPFilter(tpFltr, res.ID)
+ tpr.attrIndexers[tntID.Tenant].IndexTPFilter(tpFltr, res.ID)
}
}
}
return nil
}
-func (tpr *TpReader) LoadAliasProfiles() error {
- return tpr.LoadAliasProfilesFiltered("")
+func (tpr *TpReader) LoadAttributeProfiles() error {
+ return tpr.LoadAttributeProfilesFiltered("")
}
func (tpr *TpReader) LoadAll() (err error) {
@@ -1923,7 +1923,7 @@ func (tpr *TpReader) LoadAll() (err error) {
if err = tpr.LoadSupplierProfiles(); err != nil && err.Error() != utils.NotFoundCaps {
return
}
- if err = tpr.LoadAliasProfiles(); err != nil && err.Error() != utils.NotFoundCaps {
+ if err = tpr.LoadAttributeProfiles(); err != nil && err.Error() != utils.NotFoundCaps {
return
}
return nil
@@ -2278,14 +2278,14 @@ func (tpr *TpReader) WriteToDatabase(flush, verbose, disable_reverse bool) (err
}
if verbose {
- log.Print("AliasProfiles:")
+ log.Print("AttributeProfiles:")
}
- for _, tpTH := range tpr.aliasProfiles {
- th, err := APItoAliasProfile(tpTH, tpr.timezone)
+ for _, tpTH := range tpr.attributeProfiles {
+ th, err := APItoAttributeProfile(tpTH, tpr.timezone)
if err != nil {
return err
}
- if err = tpr.dm.SetAliasProfile(th); err != nil {
+ if err = tpr.dm.SetAttributeProfile(th); err != nil {
return err
}
if verbose {
@@ -2391,9 +2391,9 @@ func (tpr *TpReader) WriteToDatabase(flush, verbose, disable_reverse bool) (err
}
if verbose {
- log.Print("Indexing Alias Profiles")
+ log.Print("Indexing Attribute Profiles")
}
- for tenant, fltrIdxer := range tpr.aliasIndexers {
+ for tenant, fltrIdxer := range tpr.attrIndexers {
if err := fltrIdxer.StoreIndexes(); err != nil {
return err
}
@@ -2474,8 +2474,8 @@ func (tpr *TpReader) ShowStatistics() {
log.Print("Filters: ", len(tpr.filters))
// Supplier profiles
log.Print("SupplierProfiles: ", len(tpr.sppProfiles))
- // Alias profiles
- log.Print("SupplierProfiles: ", len(tpr.aliasProfiles))
+ // Attribute profiles
+ log.Print("AttributeProfiles: ", len(tpr.attributeProfiles))
}
// Returns the identities loaded for a specific category, useful for cache reloads
@@ -2641,10 +2641,10 @@ func (tpr *TpReader) GetLoadedIds(categ string) ([]string, error) {
i++
}
return keys, nil
- case utils.AliasProfilePrefix:
- keys := make([]string, len(tpr.aliasProfiles))
+ case utils.AttributeProfilePrefix:
+ keys := make([]string, len(tpr.attributeProfiles))
i := 0
- for k, _ := range tpr.aliasProfiles {
+ for k, _ := range tpr.attributeProfiles {
keys[i] = k.TenantID()
i++
}
diff --git a/engine/tpexporter.go b/engine/tpexporter.go
index 2b1fec91b..432808b54 100644
--- a/engine/tpexporter.go
+++ b/engine/tpexporter.go
@@ -284,14 +284,14 @@ func (self *TPExporter) Run() error {
}
}
- storDataAlias, err := self.storDb.GetTPAliasProfiles(self.tpID, "")
+ storDataAlias, err := self.storDb.GetTPAttributes(self.tpID, "")
if err != nil && err.Error() != utils.ErrNotFound.Error() {
return err
}
for _, sd := range storDataAlias {
- sdModels := APItoModelTPAlias(sd)
+ sdModels := APItoModelTPAttribute(sd)
for _, sdModel := range sdModels {
- toExportMap[utils.AliasCsv] = append(toExportMap[utils.AliasCsv], sdModel)
+ toExportMap[utils.AttributesCsv] = append(toExportMap[utils.AttributesCsv], sdModel)
}
}
diff --git a/engine/tpimporter_csv.go b/engine/tpimporter_csv.go
index 2be04bd99..f36863bec 100755
--- a/engine/tpimporter_csv.go
+++ b/engine/tpimporter_csv.go
@@ -62,7 +62,7 @@ var fileHandlers = map[string]func(*TPCSVImporter, string) error{
utils.ThresholdsCsv: (*TPCSVImporter).importThresholds,
utils.FiltersCsv: (*TPCSVImporter).importFilters,
utils.SuppliersCsv: (*TPCSVImporter).importSuppliers,
- utils.AliasCsv: (*TPCSVImporter).importAliasProfiles,
+ utils.AttributesCsv: (*TPCSVImporter).importAttributeProfiles,
}
func (self *TPCSVImporter) Run() error {
@@ -88,7 +88,7 @@ func (self *TPCSVImporter) Run() error {
path.Join(self.DirPath, utils.ThresholdsCsv),
path.Join(self.DirPath, utils.FiltersCsv),
path.Join(self.DirPath, utils.SuppliersCsv),
- path.Join(self.DirPath, utils.AliasCsv),
+ path.Join(self.DirPath, utils.AttributesCsv),
)
files, _ := ioutil.ReadDir(self.DirPath)
for _, f := range files {
@@ -413,13 +413,13 @@ func (self *TPCSVImporter) importSuppliers(fn string) error {
return self.StorDb.SetTPSuppliers(rls)
}
-func (self *TPCSVImporter) importAliasProfiles(fn string) error {
+func (self *TPCSVImporter) importAttributeProfiles(fn string) error {
if self.Verbose {
log.Printf("Processing file: <%s> ", fn)
}
- rls, err := self.csvr.GetTPAliasProfiles(self.TPid, "")
+ rls, err := self.csvr.GetTPAttributes(self.TPid, "")
if err != nil {
return err
}
- return self.StorDb.SetTPAliasProfiles(rls)
+ return self.StorDb.SetTPAttributes(rls)
}
diff --git a/general_tests/tut_smgeneric_it_test.go b/general_tests/tut_smgeneric_it_test.go
index 9a75a6e06..d06eae691 100644
--- a/general_tests/tut_smgeneric_it_test.go
+++ b/general_tests/tut_smgeneric_it_test.go
@@ -101,7 +101,7 @@ func TestTutSMGCacheStats(t *testing.T) {
expectedStats := &utils.CacheStats{Destinations: 5, ReverseDestinations: 7, RatingPlans: 4, RatingProfiles: 10,
Actions: 9, ActionPlans: 4, AccountActionPlans: 5, SharedGroups: 1, DerivedChargers: 1, LcrProfiles: 5,
CdrStats: 6, Users: 3, Aliases: 1, ReverseAliases: 2, ResourceProfiles: 3, Resources: 3, StatQueues: 1,
- StatQueueProfiles: 1, Thresholds: 7, ThresholdProfiles: 7, Filters: 16, SupplierProfiles: 3, AliasProfiles: 1}
+ StatQueueProfiles: 1, Thresholds: 7, ThresholdProfiles: 7, Filters: 16, SupplierProfiles: 3, AttributeProfiles: 1}
var args utils.AttrCacheStats
if err := tutSMGRpc.Call("ApierV2.GetCacheStats", args, &rcvStats); err != nil {
t.Error("Got error on ApierV2.GetCacheStats: ", err.Error())
diff --git a/general_tests/tutorial_it_test.go b/general_tests/tutorial_it_test.go
index 6aa20d505..583aa3ea9 100644
--- a/general_tests/tutorial_it_test.go
+++ b/general_tests/tutorial_it_test.go
@@ -105,7 +105,7 @@ func TestTutITCacheStats(t *testing.T) {
expectedStats := &utils.CacheStats{Destinations: 5, ReverseDestinations: 7, RatingPlans: 4, RatingProfiles: 10,
Actions: 9, ActionPlans: 4, AccountActionPlans: 5, SharedGroups: 1, DerivedChargers: 1, LcrProfiles: 5,
CdrStats: 6, Users: 3, Aliases: 1, ReverseAliases: 2, ResourceProfiles: 3, Resources: 3, StatQueues: 1,
- StatQueueProfiles: 1, Thresholds: 7, ThresholdProfiles: 7, Filters: 16, SupplierProfiles: 3, AliasProfiles: 1}
+ StatQueueProfiles: 1, Thresholds: 7, ThresholdProfiles: 7, Filters: 16, SupplierProfiles: 3, AttributeProfiles: 1}
var args utils.AttrCacheStats
if err := tutLocalRpc.Call("ApierV1.GetCacheStats", args, &rcvStats); err != nil {
t.Error("Got error on ApierV1.GetCacheStats: ", err.Error())
diff --git a/utils/apitpdata.go b/utils/apitpdata.go
index cbc602389..e139b0d4c 100755
--- a/utils/apitpdata.go
+++ b/utils/apitpdata.go
@@ -676,7 +676,7 @@ type ArgsCache struct {
ThresholdProfileIDs *[]string
FilterIDs *[]string
SupplierProfileIDs *[]string
- AliasProfileIDs *[]string
+ AttributeProfileIDs *[]string
}
// Data used to do remote cache reloads via api
@@ -719,7 +719,7 @@ type CacheStats struct {
ThresholdProfiles int
Filters int
SupplierProfiles int
- AliasProfiles int
+ AttributeProfiles int
}
type AttrExpFileCdrs struct {
@@ -1382,18 +1382,20 @@ type TPSupplier struct {
Weight float64
}
-type TPAliasEntry struct {
+type TPRequestAttribute struct {
FieldName string
Initial string
Alias string
+ Append bool
}
-type TPAlias struct {
+type TPAttribute struct {
TPid string
Tenant string
ID string
FilterIDs []string
ActivationInterval *TPActivationInterval // Time when this limit becomes active and expires
- Aliases []*TPAliasEntry
+ Context string // bind this TPAttribute to specific context
+ Attributes []*TPRequestAttribute
Weight float64
}
diff --git a/utils/consts.go b/utils/consts.go
index a5870a8a2..c9fa37005 100755
--- a/utils/consts.go
+++ b/utils/consts.go
@@ -65,288 +65,288 @@ var (
CacheThresholds: ThresholdPrefix,
CacheFilters: FilterPrefix,
CacheSupplierProfiles: SupplierProfilePrefix,
- CacheAliasProfiles: AliasProfilePrefix,
+ CacheAttributeProfiles: AttributeProfilePrefix,
}
CachePrefixToInstance map[string]string // will be built on init
)
const (
- CGRateS = "CGRateS"
- VERSION = "0.9.1~rc8"
- GitLastLogFileName = ".git_lastlog.txt"
- DIAMETER_FIRMWARE_REVISION = 918
- REDIS_MAX_CONNS = 10
- POSTGRES = "postgres"
- MYSQL = "mysql"
- MONGO = "mongo"
- REDIS = "redis"
- MAPSTOR = "mapstor"
- LOCALHOST = "127.0.0.1"
- FSCDR_FILE_CSV = "freeswitch_file_csv"
- FSCDR_HTTP_JSON = "freeswitch_http_json"
- NOT_IMPLEMENTED = "not implemented"
- PREPAID = "prepaid"
- META_PREPAID = "*prepaid"
- POSTPAID = "postpaid"
- META_POSTPAID = "*postpaid"
- PSEUDOPREPAID = "pseudoprepaid"
- META_PSEUDOPREPAID = "*pseudoprepaid"
- META_RATED = "*rated"
- META_NONE = "*none"
- META_NOW = "*now"
- TBLTPTimings = "tp_timings"
- TBLTPDestinations = "tp_destinations"
- TBLTPRates = "tp_rates"
- TBLTPDestinationRates = "tp_destination_rates"
- TBLTPRatingPlans = "tp_rating_plans"
- TBLTPRateProfiles = "tp_rating_profiles"
- TBLTPSharedGroups = "tp_shared_groups"
- TBLTPCdrStats = "tp_cdr_stats"
- TBLTPLcrs = "tp_lcr_rules"
- TBLTPActions = "tp_actions"
- TBLTPActionPlans = "tp_action_plans"
- TBLTPActionTriggers = "tp_action_triggers"
- TBLTPAccountActions = "tp_account_actions"
- TBLTPDerivedChargers = "tp_derived_chargers"
- TBLTPUsers = "tp_users"
- TBLTPAliases = "tp_aliases"
- TBLTPResources = "tp_resources"
- TBLTPStats = "tp_stats"
- TBLTPThresholds = "tp_thresholds"
- TBLTPFilters = "tp_filters"
- SMCostsTBL = "sm_costs"
- CDRsTBL = "cdrs"
- TBLTPSuppliers = "tp_suppliers"
- TBLTPAlias = "tp_alias"
- TBLVersions = "versions"
- TIMINGS_CSV = "Timings.csv"
- DESTINATIONS_CSV = "Destinations.csv"
- RATES_CSV = "Rates.csv"
- DESTINATION_RATES_CSV = "DestinationRates.csv"
- RATING_PLANS_CSV = "RatingPlans.csv"
- RATING_PROFILES_CSV = "RatingProfiles.csv"
- SHARED_GROUPS_CSV = "SharedGroups.csv"
- LCRS_CSV = "LcrRules.csv"
- ACTIONS_CSV = "Actions.csv"
- ACTION_PLANS_CSV = "ActionPlans.csv"
- ACTION_TRIGGERS_CSV = "ActionTriggers.csv"
- ACCOUNT_ACTIONS_CSV = "AccountActions.csv"
- DERIVED_CHARGERS_CSV = "DerivedChargers.csv"
- CDR_STATS_CSV = "CdrStats.csv"
- USERS_CSV = "Users.csv"
- ALIASES_CSV = "Aliases.csv"
- ResourcesCsv = "Resources.csv"
- StatsCsv = "Stats.csv"
- ThresholdsCsv = "Thresholds.csv"
- FiltersCsv = "Filters.csv"
- SuppliersCsv = "Suppliers.csv"
- AliasCsv = "Alias.csv"
- ROUNDING_UP = "*up"
- ROUNDING_MIDDLE = "*middle"
- ROUNDING_DOWN = "*down"
- ANY = "*any"
- UNLIMITED = "*unlimited"
- ZERO = "*zero"
- ASAP = "*asap"
- USERS = "*users"
- COMMENT_CHAR = '#'
- CSV_SEP = ','
- FALLBACK_SEP = ';'
- INFIELD_SEP = ";"
- MetaPipe = "*|"
- FIELDS_SEP = ","
- InInFieldSep = ":"
- STATIC_HDRVAL_SEP = "::"
- REGEXP_PREFIX = "~"
- FILTER_VAL_START = "("
- FILTER_VAL_END = ")"
- JSON = "json"
- GOB = "gob"
- MSGPACK = "msgpack"
- CSV_LOAD = "CSVLOAD"
- CGRID = "CGRID"
- TOR = "ToR"
- ORDERID = "OrderID"
- ACCID = "OriginID"
- InitialOriginID = "InitialOriginID"
- OriginIDPrefix = "OriginIDPrefix"
- CDRSOURCE = "Source"
- CDRHOST = "OriginHost"
- REQTYPE = "RequestType"
- DIRECTION = "Direction"
- TENANT = "Tenant"
- CATEGORY = "Category"
- ACCOUNT = "Account"
- SUBJECT = "Subject"
- DESTINATION = "Destination"
- SETUP_TIME = "SetupTime"
- ANSWER_TIME = "AnswerTime"
- USAGE = "Usage"
- LastUsed = "LastUsed"
- PDD = "PDD"
- SUPPLIER = "Supplier"
- MEDI_RUNID = "RunID"
- COST = "Cost"
- COST_DETAILS = "CostDetails"
- RATED = "rated"
- RATED_FLD = "Rated"
- PartialField = "Partial"
- DEFAULT_RUNID = "*default"
- META_DEFAULT = "*default"
- STATIC_VALUE_PREFIX = "^"
- CSV = "csv"
- FWV = "fwv"
- PartialCSV = "partial_csv"
- DRYRUN = "dry_run"
- META_COMBIMED = "*combimed"
- MetaInternal = "*internal"
- ZERO_RATING_SUBJECT_PREFIX = "*zero"
- OK = "OK"
- CDRE_FIXED_WIDTH = "fwv"
- XML_PROFILE_PREFIX = "*xml:"
- CDRE = "cdre"
- CDRC = "cdrc"
- MASK_CHAR = "*"
- CONCATENATED_KEY_SEP = ":"
- FORKED_CDR = "forked_cdr"
- UNIT_TEST = "UNIT_TEST"
- HDR_VAL_SEP = "/"
- MONETARY = "*monetary"
- SMS = "*sms"
- MMS = "*mms"
- GENERIC = "*generic"
- DATA = "*data"
- VOICE = "*voice"
- MAX_COST_FREE = "*free"
- MAX_COST_DISCONNECT = "*disconnect"
- HOURS = "hours"
- MINUTES = "minutes"
- NANOSECONDS = "nanoseconds"
- SECONDS = "seconds"
- OUT = "*out"
- IN = "*in"
- META_OUT = "*out"
- META_ANY = "*any"
- MetaExists = "*exists"
- CDR_IMPORT = "cdr_import"
- CDR_EXPORT = "cdr_export"
- ASR = "ASR"
- ACD = "ACD"
- FILTER_REGEXP_TPL = "$1$2$3$4$5"
- TASKS_KEY = "tasks"
- ACTION_PLAN_PREFIX = "apl_"
- AccountActionPlansPrefix = "aap_"
- ACTION_TRIGGER_PREFIX = "atr_"
- REVERSE_ACTION_TRIGGER_PREFIX = "rtr_"
- RATING_PLAN_PREFIX = "rpl_"
- RATING_PROFILE_PREFIX = "rpf_"
- ACTION_PREFIX = "act_"
- SHARED_GROUP_PREFIX = "shg_"
- ACCOUNT_PREFIX = "acc_"
- DESTINATION_PREFIX = "dst_"
- REVERSE_DESTINATION_PREFIX = "rds_"
- LCR_PREFIX = "lcr_"
- DERIVEDCHARGERS_PREFIX = "dcs_"
- CDR_STATS_QUEUE_PREFIX = "csq_"
- PUBSUB_SUBSCRIBERS_PREFIX = "pss_"
- USERS_PREFIX = "usr_"
- ALIASES_PREFIX = "als_"
- REVERSE_ALIASES_PREFIX = "rls_"
- ResourcesPrefix = "res_"
- ResourceProfilesStringIndex = "rsi_"
- ResourceProfilesStringRevIndex = "rsr_"
- ResourceProfilesPrefix = "rsp_"
- StatQueuesStringIndex = "ssi_"
- StatQueuesStringRevIndex = "ssr_"
- ThresholdPrefix = "thd_"
- ThresholdStringIndex = "tsi_"
- ThresholdStringRevIndex = "tsr_"
- TimingsPrefix = "tmg_"
- FilterPrefix = "ftr_"
- FilterIndex = "fti_"
- CDR_STATS_PREFIX = "cst_"
- TEMP_DESTINATION_PREFIX = "tmp_"
- LOG_CALL_COST_PREFIX = "cco_"
- LOG_ACTION_TIMMING_PREFIX = "ltm_"
- LOG_ACTION_TRIGGER_PREFIX = "ltr_"
- VERSION_PREFIX = "ver_"
- LOG_ERR = "ler_"
- LOG_CDR = "cdr_"
- LOG_MEDIATED_CDR = "mcd_"
- StatQueueProfilePrefix = "sqp_"
- SupplierProfilePrefix = "spp_"
- SupplierProfilesStringIndex = "spi_"
- SupplierProfilesStringRevIndex = "spr_"
- AliasProfilePrefix = "alp_"
- AliasProfilesStringIndex = "ali_"
- AliasProfilesStringRevIndex = "alr_"
- ThresholdProfilePrefix = "thp_"
- StatQueuePrefix = "stq_"
- LOADINST_KEY = "load_history"
- SESSION_MANAGER_SOURCE = "SMR"
- MEDIATOR_SOURCE = "MED"
- CDRS_SOURCE = "CDRS"
- SCHED_SOURCE = "SCH"
- RATER_SOURCE = "RAT"
- CREATE_CDRS_TABLES_SQL = "create_cdrs_tables.sql"
- CREATE_TARIFFPLAN_TABLES_SQL = "create_tariffplan_tables.sql"
- TEST_SQL = "TEST_SQL"
- DESTINATIONS_LOAD_THRESHOLD = 0.1
- META_CONSTANT = "*constant"
- META_FILLER = "*filler"
- META_HANDLER = "*handler"
- META_HTTP_POST = "*http_post"
- MetaHTTPjson = "*http_json"
- MetaHTTPjsonCDR = "*http_json_cdr"
- META_HTTP_JSONRPC = "*http_jsonrpc"
- MetaHTTPjsonMap = "*http_json_map"
- MetaAMQPjsonCDR = "*amqp_json_cdr"
- MetaAMQPjsonMap = "*amqp_json_map"
- NANO_MULTIPLIER = 1000000000
- CGR_AUTHORIZE = "CGR_AUTHORIZE"
- CONFIG_DIR = "/etc/cgrates/"
- CGR_ACCOUNT = "cgr_account"
- CGR_SUPPLIER = "cgr_supplier"
- CGR_DESTINATION = "cgr_destination"
- CGR_SUBJECT = "cgr_subject"
- CGR_CATEGORY = "cgr_category"
- CGR_REQTYPE = "cgr_reqtype"
- CGR_TENANT = "cgr_tenant"
- CGR_TOR = "cgr_tor"
- CGR_ACCID = "cgr_accid"
- CGR_HOST = "cgr_host"
- CGR_PDD = "cgr_pdd"
- DISCONNECT_CAUSE = "DisconnectCause"
- CGR_DISCONNECT_CAUSE = "cgr_disconnectcause"
- CGR_COMPUTELCR = "cgr_computelcr"
- CGR_SUPPLIERS = "cgr_suppliers"
- CGRFlags = "cgr_flags"
- KAM_FLATSTORE = "kamailio_flatstore"
- OSIPS_FLATSTORE = "opensips_flatstore"
- MAX_DEBIT_CACHE_PREFIX = "MAX_DEBIT_"
- REFUND_INCR_CACHE_PREFIX = "REFUND_INCR_"
- REFUND_ROUND_CACHE_PREFIX = "REFUND_ROUND_"
- GET_SESS_RUNS_CACHE_PREFIX = "GET_SESS_RUNS_"
- GET_DERIV_MAX_SESS_TIME = "GET_DERIV_MAX_SESS_TIME_"
- LOG_CALL_COST_CACHE_PREFIX = "LOG_CALL_COSTS_"
- LCRCachePrefix = "LCR_"
- ALIAS_CONTEXT_RATING = "*rating"
- NOT_AVAILABLE = "N/A"
- MetaEmpty = "*empty"
- CALL = "call"
- EXTRA_FIELDS = "ExtraFields"
- META_SURETAX = "*sure_tax"
- SURETAX = "suretax"
- DIAMETER_AGENT = "diameter_agent"
- COUNTER_EVENT = "*event"
- COUNTER_BALANCE = "*balance"
- EVENT_NAME = "EventName"
- COMPUTE_LCR = "ComputeLcr"
- CGR_AUTHORIZATION = "CgrAuthorization"
- CGR_SESSION_START = "CgrSessionStart"
- CGR_SESSION_UPDATE = "CgrSessionUpdate"
- CGR_SESSION_END = "CgrSessionEnd"
- CGR_LCR_REQUEST = "CgrLcrRequest"
+ CGRateS = "CGRateS"
+ VERSION = "0.9.1~rc8"
+ GitLastLogFileName = ".git_lastlog.txt"
+ DIAMETER_FIRMWARE_REVISION = 918
+ REDIS_MAX_CONNS = 10
+ POSTGRES = "postgres"
+ MYSQL = "mysql"
+ MONGO = "mongo"
+ REDIS = "redis"
+ MAPSTOR = "mapstor"
+ LOCALHOST = "127.0.0.1"
+ FSCDR_FILE_CSV = "freeswitch_file_csv"
+ FSCDR_HTTP_JSON = "freeswitch_http_json"
+ NOT_IMPLEMENTED = "not implemented"
+ PREPAID = "prepaid"
+ META_PREPAID = "*prepaid"
+ POSTPAID = "postpaid"
+ META_POSTPAID = "*postpaid"
+ PSEUDOPREPAID = "pseudoprepaid"
+ META_PSEUDOPREPAID = "*pseudoprepaid"
+ META_RATED = "*rated"
+ META_NONE = "*none"
+ META_NOW = "*now"
+ TBLTPTimings = "tp_timings"
+ TBLTPDestinations = "tp_destinations"
+ TBLTPRates = "tp_rates"
+ TBLTPDestinationRates = "tp_destination_rates"
+ TBLTPRatingPlans = "tp_rating_plans"
+ TBLTPRateProfiles = "tp_rating_profiles"
+ TBLTPSharedGroups = "tp_shared_groups"
+ TBLTPCdrStats = "tp_cdr_stats"
+ TBLTPLcrs = "tp_lcr_rules"
+ TBLTPActions = "tp_actions"
+ TBLTPActionPlans = "tp_action_plans"
+ TBLTPActionTriggers = "tp_action_triggers"
+ TBLTPAccountActions = "tp_account_actions"
+ TBLTPDerivedChargers = "tp_derived_chargers"
+ TBLTPUsers = "tp_users"
+ TBLTPAliases = "tp_aliases"
+ TBLTPResources = "tp_resources"
+ TBLTPStats = "tp_stats"
+ TBLTPThresholds = "tp_thresholds"
+ TBLTPFilters = "tp_filters"
+ SMCostsTBL = "sm_costs"
+ CDRsTBL = "cdrs"
+ TBLTPSuppliers = "tp_suppliers"
+ TBLTPAttributes = "tp_attributes"
+ TBLVersions = "versions"
+ TIMINGS_CSV = "Timings.csv"
+ DESTINATIONS_CSV = "Destinations.csv"
+ RATES_CSV = "Rates.csv"
+ DESTINATION_RATES_CSV = "DestinationRates.csv"
+ RATING_PLANS_CSV = "RatingPlans.csv"
+ RATING_PROFILES_CSV = "RatingProfiles.csv"
+ SHARED_GROUPS_CSV = "SharedGroups.csv"
+ LCRS_CSV = "LcrRules.csv"
+ ACTIONS_CSV = "Actions.csv"
+ ACTION_PLANS_CSV = "ActionPlans.csv"
+ ACTION_TRIGGERS_CSV = "ActionTriggers.csv"
+ ACCOUNT_ACTIONS_CSV = "AccountActions.csv"
+ DERIVED_CHARGERS_CSV = "DerivedChargers.csv"
+ CDR_STATS_CSV = "CdrStats.csv"
+ USERS_CSV = "Users.csv"
+ ALIASES_CSV = "Aliases.csv"
+ ResourcesCsv = "Resources.csv"
+ StatsCsv = "Stats.csv"
+ ThresholdsCsv = "Thresholds.csv"
+ FiltersCsv = "Filters.csv"
+ SuppliersCsv = "Suppliers.csv"
+ AttributesCsv = "Attributes.csv"
+ ROUNDING_UP = "*up"
+ ROUNDING_MIDDLE = "*middle"
+ ROUNDING_DOWN = "*down"
+ ANY = "*any"
+ UNLIMITED = "*unlimited"
+ ZERO = "*zero"
+ ASAP = "*asap"
+ USERS = "*users"
+ COMMENT_CHAR = '#'
+ CSV_SEP = ','
+ FALLBACK_SEP = ';'
+ INFIELD_SEP = ";"
+ MetaPipe = "*|"
+ FIELDS_SEP = ","
+ InInFieldSep = ":"
+ STATIC_HDRVAL_SEP = "::"
+ REGEXP_PREFIX = "~"
+ FILTER_VAL_START = "("
+ FILTER_VAL_END = ")"
+ JSON = "json"
+ GOB = "gob"
+ MSGPACK = "msgpack"
+ CSV_LOAD = "CSVLOAD"
+ CGRID = "CGRID"
+ TOR = "ToR"
+ ORDERID = "OrderID"
+ ACCID = "OriginID"
+ InitialOriginID = "InitialOriginID"
+ OriginIDPrefix = "OriginIDPrefix"
+ CDRSOURCE = "Source"
+ CDRHOST = "OriginHost"
+ REQTYPE = "RequestType"
+ DIRECTION = "Direction"
+ TENANT = "Tenant"
+ CATEGORY = "Category"
+ ACCOUNT = "Account"
+ SUBJECT = "Subject"
+ DESTINATION = "Destination"
+ SETUP_TIME = "SetupTime"
+ ANSWER_TIME = "AnswerTime"
+ USAGE = "Usage"
+ LastUsed = "LastUsed"
+ PDD = "PDD"
+ SUPPLIER = "Supplier"
+ MEDI_RUNID = "RunID"
+ COST = "Cost"
+ COST_DETAILS = "CostDetails"
+ RATED = "rated"
+ RATED_FLD = "Rated"
+ PartialField = "Partial"
+ DEFAULT_RUNID = "*default"
+ META_DEFAULT = "*default"
+ STATIC_VALUE_PREFIX = "^"
+ CSV = "csv"
+ FWV = "fwv"
+ PartialCSV = "partial_csv"
+ DRYRUN = "dry_run"
+ META_COMBIMED = "*combimed"
+ MetaInternal = "*internal"
+ ZERO_RATING_SUBJECT_PREFIX = "*zero"
+ OK = "OK"
+ CDRE_FIXED_WIDTH = "fwv"
+ XML_PROFILE_PREFIX = "*xml:"
+ CDRE = "cdre"
+ CDRC = "cdrc"
+ MASK_CHAR = "*"
+ CONCATENATED_KEY_SEP = ":"
+ FORKED_CDR = "forked_cdr"
+ UNIT_TEST = "UNIT_TEST"
+ HDR_VAL_SEP = "/"
+ MONETARY = "*monetary"
+ SMS = "*sms"
+ MMS = "*mms"
+ GENERIC = "*generic"
+ DATA = "*data"
+ VOICE = "*voice"
+ MAX_COST_FREE = "*free"
+ MAX_COST_DISCONNECT = "*disconnect"
+ HOURS = "hours"
+ MINUTES = "minutes"
+ NANOSECONDS = "nanoseconds"
+ SECONDS = "seconds"
+ OUT = "*out"
+ IN = "*in"
+ META_OUT = "*out"
+ META_ANY = "*any"
+ MetaExists = "*exists"
+ CDR_IMPORT = "cdr_import"
+ CDR_EXPORT = "cdr_export"
+ ASR = "ASR"
+ ACD = "ACD"
+ FILTER_REGEXP_TPL = "$1$2$3$4$5"
+ TASKS_KEY = "tasks"
+ ACTION_PLAN_PREFIX = "apl_"
+ AccountActionPlansPrefix = "aap_"
+ ACTION_TRIGGER_PREFIX = "atr_"
+ REVERSE_ACTION_TRIGGER_PREFIX = "rtr_"
+ RATING_PLAN_PREFIX = "rpl_"
+ RATING_PROFILE_PREFIX = "rpf_"
+ ACTION_PREFIX = "act_"
+ SHARED_GROUP_PREFIX = "shg_"
+ ACCOUNT_PREFIX = "acc_"
+ DESTINATION_PREFIX = "dst_"
+ REVERSE_DESTINATION_PREFIX = "rds_"
+ LCR_PREFIX = "lcr_"
+ DERIVEDCHARGERS_PREFIX = "dcs_"
+ CDR_STATS_QUEUE_PREFIX = "csq_"
+ PUBSUB_SUBSCRIBERS_PREFIX = "pss_"
+ USERS_PREFIX = "usr_"
+ ALIASES_PREFIX = "als_"
+ REVERSE_ALIASES_PREFIX = "rls_"
+ ResourcesPrefix = "res_"
+ ResourceProfilesStringIndex = "rsi_"
+ ResourceProfilesStringRevIndex = "rsr_"
+ ResourceProfilesPrefix = "rsp_"
+ StatQueuesStringIndex = "ssi_"
+ StatQueuesStringRevIndex = "ssr_"
+ ThresholdPrefix = "thd_"
+ ThresholdStringIndex = "tsi_"
+ ThresholdStringRevIndex = "tsr_"
+ TimingsPrefix = "tmg_"
+ FilterPrefix = "ftr_"
+ FilterIndex = "fti_"
+ CDR_STATS_PREFIX = "cst_"
+ TEMP_DESTINATION_PREFIX = "tmp_"
+ LOG_CALL_COST_PREFIX = "cco_"
+ LOG_ACTION_TIMMING_PREFIX = "ltm_"
+ LOG_ACTION_TRIGGER_PREFIX = "ltr_"
+ VERSION_PREFIX = "ver_"
+ LOG_ERR = "ler_"
+ LOG_CDR = "cdr_"
+ LOG_MEDIATED_CDR = "mcd_"
+ StatQueueProfilePrefix = "sqp_"
+ SupplierProfilePrefix = "spp_"
+ SupplierProfilesStringIndex = "spi_"
+ SupplierProfilesStringRevIndex = "spr_"
+ AttributeProfilePrefix = "alp_"
+ AttributeProfilesStringIndex = "ali_"
+ AttributeProfilesStringRevIndex = "alr_"
+ ThresholdProfilePrefix = "thp_"
+ StatQueuePrefix = "stq_"
+ LOADINST_KEY = "load_history"
+ SESSION_MANAGER_SOURCE = "SMR"
+ MEDIATOR_SOURCE = "MED"
+ CDRS_SOURCE = "CDRS"
+ SCHED_SOURCE = "SCH"
+ RATER_SOURCE = "RAT"
+ CREATE_CDRS_TABLES_SQL = "create_cdrs_tables.sql"
+ CREATE_TARIFFPLAN_TABLES_SQL = "create_tariffplan_tables.sql"
+ TEST_SQL = "TEST_SQL"
+ DESTINATIONS_LOAD_THRESHOLD = 0.1
+ META_CONSTANT = "*constant"
+ META_FILLER = "*filler"
+ META_HANDLER = "*handler"
+ META_HTTP_POST = "*http_post"
+ MetaHTTPjson = "*http_json"
+ MetaHTTPjsonCDR = "*http_json_cdr"
+ META_HTTP_JSONRPC = "*http_jsonrpc"
+ MetaHTTPjsonMap = "*http_json_map"
+ MetaAMQPjsonCDR = "*amqp_json_cdr"
+ MetaAMQPjsonMap = "*amqp_json_map"
+ NANO_MULTIPLIER = 1000000000
+ CGR_AUTHORIZE = "CGR_AUTHORIZE"
+ CONFIG_DIR = "/etc/cgrates/"
+ CGR_ACCOUNT = "cgr_account"
+ CGR_SUPPLIER = "cgr_supplier"
+ CGR_DESTINATION = "cgr_destination"
+ CGR_SUBJECT = "cgr_subject"
+ CGR_CATEGORY = "cgr_category"
+ CGR_REQTYPE = "cgr_reqtype"
+ CGR_TENANT = "cgr_tenant"
+ CGR_TOR = "cgr_tor"
+ CGR_ACCID = "cgr_accid"
+ CGR_HOST = "cgr_host"
+ CGR_PDD = "cgr_pdd"
+ DISCONNECT_CAUSE = "DisconnectCause"
+ CGR_DISCONNECT_CAUSE = "cgr_disconnectcause"
+ CGR_COMPUTELCR = "cgr_computelcr"
+ CGR_SUPPLIERS = "cgr_suppliers"
+ CGRFlags = "cgr_flags"
+ KAM_FLATSTORE = "kamailio_flatstore"
+ OSIPS_FLATSTORE = "opensips_flatstore"
+ MAX_DEBIT_CACHE_PREFIX = "MAX_DEBIT_"
+ REFUND_INCR_CACHE_PREFIX = "REFUND_INCR_"
+ REFUND_ROUND_CACHE_PREFIX = "REFUND_ROUND_"
+ GET_SESS_RUNS_CACHE_PREFIX = "GET_SESS_RUNS_"
+ GET_DERIV_MAX_SESS_TIME = "GET_DERIV_MAX_SESS_TIME_"
+ LOG_CALL_COST_CACHE_PREFIX = "LOG_CALL_COSTS_"
+ LCRCachePrefix = "LCR_"
+ ALIAS_CONTEXT_RATING = "*rating"
+ NOT_AVAILABLE = "N/A"
+ MetaEmpty = "*empty"
+ CALL = "call"
+ EXTRA_FIELDS = "ExtraFields"
+ META_SURETAX = "*sure_tax"
+ SURETAX = "suretax"
+ DIAMETER_AGENT = "diameter_agent"
+ COUNTER_EVENT = "*event"
+ COUNTER_BALANCE = "*balance"
+ EVENT_NAME = "EventName"
+ COMPUTE_LCR = "ComputeLcr"
+ CGR_AUTHORIZATION = "CgrAuthorization"
+ CGR_SESSION_START = "CgrSessionStart"
+ CGR_SESSION_UPDATE = "CgrSessionUpdate"
+ CGR_SESSION_END = "CgrSessionEnd"
+ CGR_LCR_REQUEST = "CgrLcrRequest"
// action trigger threshold types
TRIGGER_MIN_EVENT_COUNTER = "*min_event_counter"
TRIGGER_MIN_BALANCE_COUNTER = "*min_balance_counter"
@@ -490,7 +490,7 @@ const (
CacheThresholds = "thresholds"
CacheFilters = "filters"
CacheSupplierProfiles = "supplier_profiles"
- CacheAliasProfiles = "alias_profiles"
+ CacheAttributeProfiles = "attribute_profiles"
AccountUpdate = "AccountUpdate"
BalanceUpdate = "BalanceUpdate"
StatUpdate = "StatUpdate"
@@ -603,7 +603,7 @@ const (
Weight = "Weight"
Cost = "Cost"
RatingPlanID = "RatingPlanID"
- AliasS = "AliasS"
+ AttributeS = "AttributeS"
)
//Meta
@@ -629,7 +629,7 @@ const (
// AliasS APIs
const (
- AliasSv1GetAliasForEvent = "AliasSv1.GetAliasForEvent"
+ AttributeSv1GetAliasForEvent = "AttributeSv1.GetAttributeForEvent"
)
func buildCacheInstRevPrefixes() {