mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-25 00:58:45 +05:00
updated apis
This commit is contained in:
@@ -119,9 +119,10 @@ func (self *ApierV1) GetAccountActionTriggers(attrs AttrAcntAction, reply *engin
|
||||
}
|
||||
|
||||
type AttrRemAcntActionTriggers struct {
|
||||
Tenant string // Tenant he account belongs to
|
||||
Account string // Account name
|
||||
ActionTriggersId string // Id filtering only specific id to remove (can be regexp pattern)
|
||||
Tenant string // Tenant he account belongs to
|
||||
Account string // Account name
|
||||
ActionTriggersId string // Id filtering only specific id to remove (can be regexp pattern)
|
||||
ActionTriggersUniqueId string
|
||||
}
|
||||
|
||||
// Returns a list of ActionTriggers on an account
|
||||
@@ -137,10 +138,14 @@ func (self *ApierV1) RemAccountActionTriggers(attrs AttrRemAcntActionTriggers, r
|
||||
}
|
||||
nactrs := make(engine.ActionTriggers, 0)
|
||||
for _, actr := range ub.ActionTriggers {
|
||||
match, _ := regexp.MatchString(attrs.ActionTriggersId, actr.Id)
|
||||
if len(attrs.ActionTriggersId) != 0 && !match {
|
||||
nactrs = append(nactrs, actr)
|
||||
match, _ := regexp.MatchString(attrs.ActionTriggersId, actr.ID)
|
||||
if len(attrs.ActionTriggersId) != 0 && match {
|
||||
continue
|
||||
}
|
||||
if len(attrs.ActionTriggersUniqueId) != 0 && attrs.ActionTriggersUniqueId == actr.UniqueID {
|
||||
continue
|
||||
}
|
||||
nactrs = append(nactrs, actr)
|
||||
}
|
||||
ub.ActionTriggers = nactrs
|
||||
if err := self.AccountDb.SetAccount(ub); err != nil {
|
||||
@@ -202,7 +207,7 @@ func (self *ApierV1) SetAccount(attr utils.AttrSetAccount, reply *string) error
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
ub.ActionTriggers = atrs.Clone()
|
||||
ub.ActionTriggers = atrs
|
||||
ub.InitCounters()
|
||||
}
|
||||
if attr.AllowNegative != nil {
|
||||
|
||||
@@ -807,21 +807,22 @@ func (self *ApierV1) GetActionPlan(attr AttrGetActionPlan, reply *[]engine.Actio
|
||||
}
|
||||
|
||||
type AttrAddActionTrigger struct {
|
||||
ActionTriggersId string
|
||||
Tenant string
|
||||
Account string
|
||||
ThresholdType string
|
||||
ThresholdValue float64
|
||||
BalanceId string
|
||||
BalanceType string
|
||||
BalanceDirection string
|
||||
BalanceDestinationIds string
|
||||
BalanceRatingSubject string //ToDo
|
||||
BalanceWeight float64
|
||||
BalanceExpiryTime string
|
||||
BalanceSharedGroup string //ToDo
|
||||
Weight float64
|
||||
ActionsId string
|
||||
ActionTriggersId string
|
||||
ActionTriggersUniqueId string
|
||||
Tenant string
|
||||
Account string
|
||||
ThresholdType string
|
||||
ThresholdValue float64
|
||||
BalanceId string
|
||||
BalanceType string
|
||||
BalanceDirection string
|
||||
BalanceDestinationIds string
|
||||
BalanceRatingSubject string //ToDo
|
||||
BalanceWeight float64
|
||||
BalanceExpiryTime string
|
||||
BalanceSharedGroup string //ToDo
|
||||
Weight float64
|
||||
ActionsId string
|
||||
}
|
||||
|
||||
func (self *ApierV1) AddTriggeredAction(attr AttrAddActionTrigger, reply *string) error {
|
||||
@@ -833,7 +834,8 @@ func (self *ApierV1) AddTriggeredAction(attr AttrAddActionTrigger, reply *string
|
||||
return utils.NewErrServerError(err)
|
||||
}
|
||||
at := &engine.ActionTrigger{
|
||||
Id: attr.ActionTriggersId,
|
||||
ID: attr.ActionTriggersId,
|
||||
UniqueID: attr.ActionTriggersUniqueId,
|
||||
ThresholdType: attr.ThresholdType,
|
||||
ThresholdValue: attr.ThresholdValue,
|
||||
BalanceId: attr.BalanceId,
|
||||
|
||||
@@ -1054,7 +1054,7 @@ func TestApierRemAccountActionTriggers(t *testing.T) {
|
||||
t.Errorf("Unexpected action triggers received %v", reply)
|
||||
}
|
||||
var rmReply string
|
||||
rmReq := AttrRemAcntActionTriggers{Tenant: "cgrates.org", Account: "dan2", ActionTriggersId: reply[0].Id}
|
||||
rmReq := AttrRemAcntActionTriggers{Tenant: "cgrates.org", Account: "dan2", ActionTriggersId: reply[0].UniqueID}
|
||||
if err := rater.Call("ApierV1.RemAccountActionTriggers", rmReq, &rmReply); err != nil {
|
||||
t.Error("Got error on ApierV1.RemActionTiming: ", err.Error())
|
||||
} else if rmReply != OK {
|
||||
|
||||
Reference in New Issue
Block a user