mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-21 15:18:44 +05:00
Removed Context parameter for RemoveAttributeProfile API
This commit is contained in:
committed by
Dan Christian Bogos
parent
c7c62fd8ad
commit
2583be9e32
@@ -80,17 +80,16 @@ func (apierV1 *ApierV1) SetAttributeProfile(alsPrf *engine.AttributeProfile, rep
|
||||
}
|
||||
|
||||
type ArgRemoveAttrProfile struct {
|
||||
Tenant string
|
||||
ID string
|
||||
Contexts []string
|
||||
Tenant string
|
||||
ID string
|
||||
}
|
||||
|
||||
//RemoveAttributeProfile remove a specific Attribute Profile
|
||||
func (apierV1 *ApierV1) RemoveAttributeProfile(arg *ArgRemoveAttrProfile, reply *string) error {
|
||||
if missing := utils.MissingStructFields(arg, []string{"Tenant", "ID", "Contexts"}); len(missing) != 0 { //Params missing
|
||||
if missing := utils.MissingStructFields(arg, []string{"Tenant", "ID"}); len(missing) != 0 { //Params missing
|
||||
return utils.NewErrMandatoryIeMissing(missing...)
|
||||
}
|
||||
if err := apierV1.DataManager.RemoveAttributeProfile(arg.Tenant, arg.ID, arg.Contexts, utils.NonTransactional, true); err != nil {
|
||||
if err := apierV1.DataManager.RemoveAttributeProfile(arg.Tenant, arg.ID, utils.NonTransactional, true); err != nil {
|
||||
if err.Error() != utils.ErrNotFound.Error() {
|
||||
err = utils.NewErrServerError(err)
|
||||
}
|
||||
|
||||
@@ -704,8 +704,7 @@ func testAttributeSUpdateAlsPrf(t *testing.T) {
|
||||
func testAttributeSRemAlsPrf(t *testing.T) {
|
||||
var resp string
|
||||
if err := attrSRPC.Call("ApierV1.RemoveAttributeProfile",
|
||||
&ArgRemoveAttrProfile{Tenant: alsPrf.Tenant, ID: alsPrf.ID,
|
||||
Contexts: alsPrf.Contexts}, &resp); err != nil {
|
||||
&ArgRemoveAttrProfile{Tenant: alsPrf.Tenant, ID: alsPrf.ID}, &resp); err != nil {
|
||||
t.Error(err)
|
||||
} else if resp != utils.OK {
|
||||
t.Error("Unexpected reply returned", resp)
|
||||
@@ -716,6 +715,12 @@ func testAttributeSRemAlsPrf(t *testing.T) {
|
||||
&reply); err == nil || err.Error() != utils.ErrNotFound.Error() {
|
||||
t.Error(err)
|
||||
}
|
||||
// remove twice shoud return not found
|
||||
resp = ""
|
||||
if err := attrSRPC.Call("ApierV1.RemoveAttributeProfile",
|
||||
&ArgRemoveAttrProfile{Tenant: alsPrf.Tenant, ID: alsPrf.ID}, &resp); err == nil || err.Error() != utils.ErrNotFound.Error() {
|
||||
t.Error(err)
|
||||
}
|
||||
}
|
||||
|
||||
func testAttributeSSetAlsPrf2(t *testing.T) {
|
||||
|
||||
@@ -1396,17 +1396,15 @@ func testV1FIdxRemoveAttributeProfile(t *testing.T) {
|
||||
t.Error("Unexpected reply returned", result)
|
||||
}
|
||||
if err := tFIdxRpc.Call("ApierV1.RemoveAttributeProfile", &ArgRemoveAttrProfile{
|
||||
Tenant: tenant,
|
||||
ID: "ApierTest",
|
||||
Contexts: []string{utils.MetaSessionS}}, &result); err != nil {
|
||||
Tenant: tenant,
|
||||
ID: "ApierTest"}, &result); err != nil {
|
||||
t.Error(err)
|
||||
} else if result != utils.OK {
|
||||
t.Error("Unexpected reply returned", result)
|
||||
}
|
||||
if err := tFIdxRpc.Call("ApierV1.RemoveAttributeProfile", &ArgRemoveAttrProfile{
|
||||
Tenant: tenant,
|
||||
ID: "ApierTest2",
|
||||
Contexts: []string{utils.MetaSessionS}}, &result); err != nil {
|
||||
Tenant: tenant,
|
||||
ID: "ApierTest2"}, &result); err != nil {
|
||||
t.Error(err)
|
||||
} else if result != utils.OK {
|
||||
t.Error("Unexpected reply returned", result)
|
||||
|
||||
@@ -1063,7 +1063,7 @@ func testV1FIdxCaRemoveAttributeProfile(t *testing.T) {
|
||||
}
|
||||
//Remove threshold profile that was set form api
|
||||
if err := tFIdxCaRpc.Call("ApierV1.RemoveAttributeProfile", &ArgRemoveAttrProfile{Tenant: "cgrates.org",
|
||||
ID: "TEST_PROFILE1", Contexts: []string{utils.MetaSessionS}}, &resp); err != nil {
|
||||
ID: "TEST_PROFILE1"}, &resp); err != nil {
|
||||
t.Error(err)
|
||||
} else if resp != utils.OK {
|
||||
t.Error("Unexpected reply returned", resp)
|
||||
@@ -1077,7 +1077,7 @@ func testV1FIdxCaRemoveAttributeProfile(t *testing.T) {
|
||||
}
|
||||
//Remove threshold profile that was set form tariffplan
|
||||
if err := tFIdxCaRpc.Call("ApierV1.RemoveAttributeProfile", &ArgRemoveAttrProfile{Tenant: "cgrates.org",
|
||||
ID: "ATTR_1", Contexts: []string{utils.MetaSessionS}}, &resp); err != nil {
|
||||
ID: "ATTR_1"}, &resp); err != nil {
|
||||
t.Error(err)
|
||||
} else if resp != utils.OK {
|
||||
t.Error("Unexpected reply returned", resp)
|
||||
|
||||
@@ -1228,10 +1228,9 @@ func (dm *DataManager) SetAttributeProfile(ap *AttributeProfile, withIndex bool)
|
||||
return
|
||||
}
|
||||
|
||||
func (dm *DataManager) RemoveAttributeProfile(tenant, id string, contexts []string,
|
||||
transactionID string, withIndex bool) (err error) {
|
||||
func (dm *DataManager) RemoveAttributeProfile(tenant, id string, transactionID string, withIndex bool) (err error) {
|
||||
oldAttr, err := dm.GetAttributeProfile(tenant, id, true, false, utils.NonTransactional)
|
||||
if err != nil && err != utils.ErrNotFound {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err = dm.DataDB().RemoveAttributeProfileDrv(tenant, id); err != nil {
|
||||
@@ -1240,7 +1239,7 @@ func (dm *DataManager) RemoveAttributeProfile(tenant, id string, contexts []stri
|
||||
Cache.Remove(utils.CacheAttributeProfiles, utils.ConcatenatedKey(tenant, id),
|
||||
cacheCommit(transactionID), transactionID)
|
||||
if withIndex {
|
||||
for _, context := range contexts {
|
||||
for _, context := range oldAttr.Contexts {
|
||||
if err = NewFilterIndexer(dm, utils.AttributeProfilePrefix,
|
||||
utils.ConcatenatedKey(tenant, context)).RemoveItemFromIndex(tenant, id, oldAttr.FilterIDs); err != nil {
|
||||
return
|
||||
|
||||
@@ -485,7 +485,7 @@ func testITTestAttributeProfileFilterIndexes(t *testing.T) {
|
||||
}
|
||||
|
||||
if err := dataManager.RemoveAttributeProfile(attrProfile.Tenant,
|
||||
attrProfile.ID, attrProfile.Contexts, utils.NonTransactional, true); err != nil {
|
||||
attrProfile.ID, utils.NonTransactional, true); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
//check if index is removed
|
||||
|
||||
@@ -2539,7 +2539,7 @@ func testOnStorITAttributeProfile(t *testing.T) {
|
||||
t.Errorf("Expecting: %v, received: %v", attrProfile, rcv)
|
||||
}
|
||||
if err := onStor.RemoveAttributeProfile(attrProfile.Tenant,
|
||||
attrProfile.ID, attrProfile.Contexts, utils.NonTransactional, false); err != nil {
|
||||
attrProfile.ID, utils.NonTransactional, false); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
//check cache if removed
|
||||
|
||||
@@ -2786,7 +2786,8 @@ func (tpr *TpReader) RemoveFromDatabase(verbose, disable_reverse bool) (err erro
|
||||
log.Print("AttributeProfiles:")
|
||||
}
|
||||
for _, tpTH := range tpr.attributeProfiles {
|
||||
if err = tpr.dm.RemoveAttributeProfile(tpTH.Tenant, tpTH.ID, tpTH.Contexts, utils.NonTransactional, false); err != nil {
|
||||
if err = tpr.dm.RemoveAttributeProfile(tpTH.Tenant, tpTH.ID,
|
||||
utils.NonTransactional, false); err != nil && err.Error() != utils.ErrNotFound.Error() {
|
||||
return err
|
||||
}
|
||||
if verbose {
|
||||
|
||||
@@ -63,7 +63,7 @@ func (m *Migrator) migrateCurrentAttributeProfile() (err error) {
|
||||
return err
|
||||
}
|
||||
if err := m.dmIN.DataManager().RemoveAttributeProfile(tenant,
|
||||
idg, attrPrf.Contexts, utils.NonTransactional, false); err != nil {
|
||||
idg, utils.NonTransactional, false); err != nil {
|
||||
return err
|
||||
}
|
||||
m.stats[utils.Attributes] += 1
|
||||
|
||||
Reference in New Issue
Block a user