ActionSv1 ScheduleActions and ExecuteActions API calls

This commit is contained in:
DanB
2020-12-22 11:28:06 +01:00
parent 822ab977ff
commit 6d5b7ef313
5 changed files with 33 additions and 19 deletions

View File

@@ -283,13 +283,18 @@ func (aS *ActionS) asapExecuteActions(sActs *scheduledActs) (err error) {
return
}
type ArgActionSv1ExecuteActions struct {
*utils.CGREventWithOpts
ActionProfileIDs []string
// V1ScheduleActions will be called to schedule actions matching the arguments
func (aS *ActionS) V1ScheduleActions(args *utils.ArgActionSv1ScheduleActions, rpl *string) (err error) {
if err = aS.scheduleActions([]*utils.CGREventWithOpts{args.CGREventWithOpts},
args.ActionProfileIDs, false); err != nil {
return
}
*rpl = utils.OK
return
}
// V1ExecuteActions will be called to execute ASAP action profiles, ignoring their Schedule field
func (aS *ActionS) V1ExecuteActions(args *ArgActionSv1ExecuteActions, rpl *string) (err error) {
func (aS *ActionS) V1ExecuteActions(args *utils.ArgActionSv1ScheduleActions, rpl *string) (err error) {
var schedActSet []*scheduledActs
if schedActSet, err = aS.scheduledActions(args.CGREventWithOpts.Tenant,
args.CGREventWithOpts, args.ActionProfileIDs, true); err != nil {
@@ -309,13 +314,3 @@ func (aS *ActionS) V1ExecuteActions(args *ArgActionSv1ExecuteActions, rpl *strin
*rpl = utils.OK
return
}
// V1ExecuteActions will be called to schedule actions matching the arguments
func (aS *ActionS) V1ScheduleActions(args *ArgActionSv1ExecuteActions, rpl *string) (err error) {
if err = aS.scheduleActions([]*utils.CGREventWithOpts{args.CGREventWithOpts},
args.ActionProfileIDs, false); err != nil {
return
}
*rpl = utils.OK
return
}

View File

@@ -163,3 +163,13 @@ func (aSv1 *ActionSv1) Ping(ign *utils.CGREventWithOpts, reply *string) error {
*reply = utils.Pong
return nil
}
// ScheduleActions will be called to schedule actions matching the arguments
func (aSv1 *ActionSv1) ScheduleActions(args *utils.ArgActionSv1ScheduleActions, rpl *string) error {
return aSv1.aS.V1ExecuteActions(args, rpl)
}
// ExecuteActions will be called to execute ASAP action profiles, ignoring their Schedule field
func (aSv1 *ActionSv1) ExecuteActions(args *utils.ArgActionSv1ScheduleActions, rpl *string) error {
return aSv1.aS.V1ExecuteActions(args, rpl)
}

View File

@@ -1562,3 +1562,9 @@ type TPAccountBalance struct {
Opts string
Value float64
}
// ArgActionSv1ScheduleActions is used in ActionSv1 methods
type ArgActionSv1ScheduleActions struct {
*CGREventWithOpts
ActionProfileIDs []string
}

View File

@@ -1547,11 +1547,6 @@ const (
RateSv1Ping = "RateSv1.Ping"
)
const (
ActionSv1 = "ActionSv1"
ActionSv1Ping = "ActionSv1.Ping"
)
const (
AccountSv1 = "AccountSv1"
AccountSv1Ping = "AccountSv1.Ping"
@@ -2744,6 +2739,14 @@ var (
}
)
// ActionSv1
const (
ActionSv1 = "ActionSv1"
ActionSv1Ping = "ActionSv1.Ping"
ActionSv1ScheduleActions = "ActionSv1.ScheduleActions"
ActionSv1ExecuteActions = "ActionSv1.ExecuteActions"
)
func buildCacheInstRevPrefixes() {
CachePrefixToInstance = make(map[string]string)
for k, v := range CacheInstanceToPrefix {