mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Added Replication APIs to dispatcher
This commit is contained in:
committed by
Dan Christian Bogos
parent
fb73873d43
commit
488956f7bc
@@ -168,3 +168,33 @@ type CoreSv1Interface interface {
|
||||
Status(arg *utils.TenantWithArgDispatcher, reply *map[string]interface{}) error
|
||||
Ping(ign *utils.CGREventWithArgDispatcher, reply *string) error
|
||||
}
|
||||
|
||||
type ReplicatorSv1Interface interface {
|
||||
Ping(ign *utils.CGREventWithArgDispatcher, reply *string) error
|
||||
GetAccount(args *dispatchers.StringWithApiKey, reply *engine.Account) error
|
||||
GetDestination(key *dispatchers.StringWithApiKey, reply *engine.Destination) error
|
||||
GetReverseDestination(key *dispatchers.StringWithApiKey, reply *[]string) error
|
||||
GetStatQueue(tntID *utils.TenantIDWithArgDispatcher, reply *engine.StatQueue) error
|
||||
GetFilter(tntID *utils.TenantIDWithArgDispatcher, reply *engine.Filter) error
|
||||
GetThreshold(tntID *utils.TenantIDWithArgDispatcher, reply *engine.Threshold) error
|
||||
GetThresholdProfile(tntID *utils.TenantIDWithArgDispatcher, reply *engine.ThresholdProfile) error
|
||||
GetStatQueueProfile(tntID *utils.TenantIDWithArgDispatcher, reply *engine.StatQueueProfile) error
|
||||
GetTiming(id *dispatchers.StringWithApiKey, reply *utils.TPTiming) error
|
||||
GetResource(tntID *utils.TenantIDWithArgDispatcher, reply *engine.Resource) error
|
||||
GetResourceProfile(tntID *utils.TenantIDWithArgDispatcher, reply *engine.ResourceProfile) error
|
||||
GetActionTriggers(id *dispatchers.StringWithApiKey, reply *engine.ActionTriggers) error
|
||||
GetShareGroup(id *dispatchers.StringWithApiKey, reply *engine.SharedGroup) error
|
||||
GetActions(id *dispatchers.StringWithApiKey, reply *engine.Actions) error
|
||||
GetActionPlan(id *dispatchers.StringWithApiKey, reply *engine.ActionPlan) error
|
||||
GetAllActionPlans(_ *dispatchers.StringWithApiKey, reply *map[string]*engine.ActionPlan) error
|
||||
GetAccountActionPlans(id *dispatchers.StringWithApiKey, reply *[]string) error
|
||||
GetRatingPlan(id *dispatchers.StringWithApiKey, reply *engine.RatingPlan) error
|
||||
GetRatingProfile(id *dispatchers.StringWithApiKey, reply *engine.RatingProfile) error
|
||||
GetSupplierProfile(tntID *utils.TenantIDWithArgDispatcher, reply *engine.SupplierProfile) error
|
||||
GetAttributeProfile(tntID *utils.TenantIDWithArgDispatcher, reply *engine.AttributeProfile) error
|
||||
GetChargerProfile(tntID *utils.TenantIDWithArgDispatcher, reply *engine.ChargerProfile) error
|
||||
GetDispatcherProfile(tntID *utils.TenantIDWithArgDispatcher, reply *engine.DispatcherProfile) error
|
||||
GetDispatcherHost(tntID *utils.TenantIDWithArgDispatcher, reply *engine.DispatcherHost) error
|
||||
GetItemLoadIDs(itemID *dispatchers.StringWithApiKey, reply *map[string]int64) error
|
||||
GetFilterIndexes(args *utils.GetFilterIndexesArgWithArgDispatcher, reply *map[string]utils.StringMap) error
|
||||
}
|
||||
|
||||
@@ -103,3 +103,8 @@ func TestCoreSv1Interface(t *testing.T) {
|
||||
_ = CoreSv1Interface(NewDispatcherCoreSv1(nil))
|
||||
_ = CoreSv1Interface(NewCoreSv1(nil))
|
||||
}
|
||||
|
||||
func TestReplicatorSv1Interface(t *testing.T) {
|
||||
_ = ReplicatorSv1Interface(NewDispatcherReplicatorSv1(nil))
|
||||
_ = ReplicatorSv1Interface(NewReplicatorSv1(nil))
|
||||
}
|
||||
|
||||
@@ -826,3 +826,146 @@ func (dS *DispatcherRALsV1) GetRatingPlansCost(args *utils.RatingPlanCostArg, re
|
||||
func (dS *DispatcherRALsV1) Ping(args *utils.CGREventWithArgDispatcher, reply *string) error {
|
||||
return dS.dS.RALsV1Ping(args, reply)
|
||||
}
|
||||
|
||||
type DispatcherReplicatorSv1 struct {
|
||||
dS *dispatchers.DispatcherService
|
||||
}
|
||||
|
||||
func NewDispatcherReplicatorSv1(dps *dispatchers.DispatcherService) *DispatcherReplicatorSv1 {
|
||||
return &DispatcherReplicatorSv1{dS: dps}
|
||||
}
|
||||
|
||||
// Ping used to detreminate if component is active
|
||||
func (dS *DispatcherReplicatorSv1) Ping(args *utils.CGREventWithArgDispatcher, reply *string) error {
|
||||
return dS.dS.ReplicatorSv1Ping(args, reply)
|
||||
}
|
||||
|
||||
// GetAccount
|
||||
func (dS *DispatcherReplicatorSv1) GetAccount(args *dispatchers.StringWithApiKey, reply *engine.Account) error {
|
||||
return dS.dS.ReplicatorSv1GetAccount(args, reply)
|
||||
}
|
||||
|
||||
// GetDestination
|
||||
func (dS *DispatcherReplicatorSv1) GetDestination(key *dispatchers.StringWithApiKey, reply *engine.Destination) error {
|
||||
return dS.dS.ReplicatorSv1GetDestination(key, reply)
|
||||
}
|
||||
|
||||
// GetReverseDestination
|
||||
func (dS *DispatcherReplicatorSv1) GetReverseDestination(key *dispatchers.StringWithApiKey, reply *[]string) error {
|
||||
return dS.dS.ReplicatorSv1GetReverseDestination(key, reply)
|
||||
}
|
||||
|
||||
// GetStatQueue
|
||||
func (dS *DispatcherReplicatorSv1) GetStatQueue(tntID *utils.TenantIDWithArgDispatcher, reply *engine.StatQueue) error {
|
||||
return dS.dS.ReplicatorSv1GetStatQueue(tntID, reply)
|
||||
}
|
||||
|
||||
// GetFilter
|
||||
func (dS *DispatcherReplicatorSv1) GetFilter(tntID *utils.TenantIDWithArgDispatcher, reply *engine.Filter) error {
|
||||
return dS.dS.ReplicatorSv1GetFilter(tntID, reply)
|
||||
}
|
||||
|
||||
// GetThreshold
|
||||
func (dS *DispatcherReplicatorSv1) GetThreshold(tntID *utils.TenantIDWithArgDispatcher, reply *engine.Threshold) error {
|
||||
return dS.dS.ReplicatorSv1GetThreshold(tntID, reply)
|
||||
}
|
||||
|
||||
// GetThresholdProfile
|
||||
func (dS *DispatcherReplicatorSv1) GetThresholdProfile(tntID *utils.TenantIDWithArgDispatcher, reply *engine.ThresholdProfile) error {
|
||||
return dS.dS.ReplicatorSv1GetThresholdProfile(tntID, reply)
|
||||
}
|
||||
|
||||
// GetStatQueueProfile
|
||||
func (dS *DispatcherReplicatorSv1) GetStatQueueProfile(tntID *utils.TenantIDWithArgDispatcher, reply *engine.StatQueueProfile) error {
|
||||
return dS.dS.ReplicatorSv1GetStatQueueProfile(tntID, reply)
|
||||
}
|
||||
|
||||
// GetTiming
|
||||
func (dS *DispatcherReplicatorSv1) GetTiming(id *dispatchers.StringWithApiKey, reply *utils.TPTiming) error {
|
||||
return dS.dS.ReplicatorSv1GetTiming(id, reply)
|
||||
}
|
||||
|
||||
// GetResource
|
||||
func (dS *DispatcherReplicatorSv1) GetResource(tntID *utils.TenantIDWithArgDispatcher, reply *engine.Resource) error {
|
||||
return dS.dS.ReplicatorSv1GetResource(tntID, reply)
|
||||
}
|
||||
|
||||
// GetResourceProfile
|
||||
func (dS *DispatcherReplicatorSv1) GetResourceProfile(tntID *utils.TenantIDWithArgDispatcher, reply *engine.ResourceProfile) error {
|
||||
return dS.dS.ReplicatorSv1GetResourceProfile(tntID, reply)
|
||||
}
|
||||
|
||||
// GetActionTriggers
|
||||
func (dS *DispatcherReplicatorSv1) GetActionTriggers(id *dispatchers.StringWithApiKey, reply *engine.ActionTriggers) error {
|
||||
return dS.dS.ReplicatorSv1GetActionTriggers(id, reply)
|
||||
}
|
||||
|
||||
// GetShareGroup
|
||||
func (dS *DispatcherReplicatorSv1) GetShareGroup(id *dispatchers.StringWithApiKey, reply *engine.SharedGroup) error {
|
||||
return dS.dS.ReplicatorSv1GetShareGroup(id, reply)
|
||||
}
|
||||
|
||||
// GetActions
|
||||
func (dS *DispatcherReplicatorSv1) GetActions(id *dispatchers.StringWithApiKey, reply *engine.Actions) error {
|
||||
return dS.dS.ReplicatorSv1GetActions(id, reply)
|
||||
}
|
||||
|
||||
// GetActionPlan
|
||||
func (dS *DispatcherReplicatorSv1) GetActionPlan(id *dispatchers.StringWithApiKey, reply *engine.ActionPlan) error {
|
||||
return dS.dS.ReplicatorSv1GetActionPlan(id, reply)
|
||||
}
|
||||
|
||||
// GetAllActionPlans
|
||||
func (dS *DispatcherReplicatorSv1) GetAllActionPlans(args *dispatchers.StringWithApiKey, reply *map[string]*engine.ActionPlan) error {
|
||||
return dS.dS.ReplicatorSv1GetAllActionPlans(args, reply)
|
||||
}
|
||||
|
||||
// GetAccountActionPlans
|
||||
func (dS *DispatcherReplicatorSv1) GetAccountActionPlans(id *dispatchers.StringWithApiKey, reply *[]string) error {
|
||||
return dS.dS.ReplicatorSv1GetAccountActionPlans(id, reply)
|
||||
}
|
||||
|
||||
// GetRatingPlan
|
||||
func (dS *DispatcherReplicatorSv1) GetRatingPlan(id *dispatchers.StringWithApiKey, reply *engine.RatingPlan) error {
|
||||
return dS.dS.ReplicatorSv1GetRatingPlan(id, reply)
|
||||
}
|
||||
|
||||
// GetRatingProfile
|
||||
func (dS *DispatcherReplicatorSv1) GetRatingProfile(id *dispatchers.StringWithApiKey, reply *engine.RatingProfile) error {
|
||||
return dS.dS.ReplicatorSv1GetRatingProfile(id, reply)
|
||||
}
|
||||
|
||||
// GetSupplierProfile
|
||||
func (dS *DispatcherReplicatorSv1) GetSupplierProfile(tntID *utils.TenantIDWithArgDispatcher, reply *engine.SupplierProfile) error {
|
||||
return dS.dS.ReplicatorSv1GetSupplierProfile(tntID, reply)
|
||||
}
|
||||
|
||||
// GetAttributeProfile
|
||||
func (dS *DispatcherReplicatorSv1) GetAttributeProfile(tntID *utils.TenantIDWithArgDispatcher, reply *engine.AttributeProfile) error {
|
||||
return dS.dS.ReplicatorSv1GetAttributeProfile(tntID, reply)
|
||||
}
|
||||
|
||||
// GetChargerProfile
|
||||
func (dS *DispatcherReplicatorSv1) GetChargerProfile(tntID *utils.TenantIDWithArgDispatcher, reply *engine.ChargerProfile) error {
|
||||
return dS.dS.ReplicatorSv1GetChargerProfile(tntID, reply)
|
||||
}
|
||||
|
||||
// GetDispatcherProfile
|
||||
func (dS *DispatcherReplicatorSv1) GetDispatcherProfile(tntID *utils.TenantIDWithArgDispatcher, reply *engine.DispatcherProfile) error {
|
||||
return dS.dS.ReplicatorSv1GetDispatcherProfile(tntID, reply)
|
||||
}
|
||||
|
||||
// GetDispatcherHost
|
||||
func (dS *DispatcherReplicatorSv1) GetDispatcherHost(tntID *utils.TenantIDWithArgDispatcher, reply *engine.DispatcherHost) error {
|
||||
return dS.dS.ReplicatorSv1GetDispatcherHost(tntID, reply)
|
||||
}
|
||||
|
||||
// GetItemLoadIDs
|
||||
func (dS *DispatcherReplicatorSv1) GetItemLoadIDs(itemID *dispatchers.StringWithApiKey, reply *map[string]int64) error {
|
||||
return dS.dS.ReplicatorSv1GetItemLoadIDs(itemID, reply)
|
||||
}
|
||||
|
||||
// GetFilterIndexes
|
||||
func (dS *DispatcherReplicatorSv1) GetFilterIndexes(args *utils.GetFilterIndexesArgWithArgDispatcher, reply *map[string]utils.StringMap) error {
|
||||
return dS.dS.ReplicatorSv1GetFilterIndexes(args, reply)
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
package v1
|
||||
|
||||
import (
|
||||
"github.com/cgrates/cgrates/dispatchers"
|
||||
"github.com/cgrates/cgrates/engine"
|
||||
"github.com/cgrates/cgrates/utils"
|
||||
)
|
||||
@@ -38,8 +39,8 @@ func (rplSv1 *ReplicatorSv1) Call(serviceMethod string, args interface{}, reply
|
||||
}
|
||||
|
||||
//GetAccount
|
||||
func (rplSv1 *ReplicatorSv1) GetAccount(id string, reply *engine.Account) error {
|
||||
if rcv, err := rplSv1.dm.GetAccount(id); err != nil {
|
||||
func (rplSv1 *ReplicatorSv1) GetAccount(args *dispatchers.StringWithApiKey, reply *engine.Account) error {
|
||||
if rcv, err := rplSv1.dm.GetAccount(args.Arg); err != nil {
|
||||
return err
|
||||
} else {
|
||||
*reply = *rcv
|
||||
@@ -48,8 +49,8 @@ func (rplSv1 *ReplicatorSv1) GetAccount(id string, reply *engine.Account) error
|
||||
}
|
||||
|
||||
//GetDestination
|
||||
func (rplSv1 *ReplicatorSv1) GetDestination(key string, reply *engine.Destination) error {
|
||||
if rcv, err := rplSv1.dm.DataDB().GetDestinationDrv(key, true, utils.NonTransactional); err != nil {
|
||||
func (rplSv1 *ReplicatorSv1) GetDestination(key *dispatchers.StringWithApiKey, reply *engine.Destination) error {
|
||||
if rcv, err := rplSv1.dm.DataDB().GetDestinationDrv(key.Arg, true, utils.NonTransactional); err != nil {
|
||||
return err
|
||||
} else {
|
||||
*reply = *rcv
|
||||
@@ -58,8 +59,8 @@ func (rplSv1 *ReplicatorSv1) GetDestination(key string, reply *engine.Destinatio
|
||||
}
|
||||
|
||||
//GetDestination
|
||||
func (rplSv1 *ReplicatorSv1) GetReverseDestination(key string, reply *[]string) error {
|
||||
if rcv, err := rplSv1.dm.DataDB().GetReverseDestinationDrv(key, true, utils.NonTransactional); err != nil {
|
||||
func (rplSv1 *ReplicatorSv1) GetReverseDestination(key *dispatchers.StringWithApiKey, reply *[]string) error {
|
||||
if rcv, err := rplSv1.dm.DataDB().GetReverseDestinationDrv(key.Arg, true, utils.NonTransactional); err != nil {
|
||||
return err
|
||||
} else {
|
||||
*reply = rcv
|
||||
@@ -68,7 +69,7 @@ func (rplSv1 *ReplicatorSv1) GetReverseDestination(key string, reply *[]string)
|
||||
}
|
||||
|
||||
//GetStatQueue
|
||||
func (rplSv1 *ReplicatorSv1) GetStatQueue(tntID *utils.TenantID, reply *engine.StatQueue) error {
|
||||
func (rplSv1 *ReplicatorSv1) GetStatQueue(tntID *utils.TenantIDWithArgDispatcher, reply *engine.StatQueue) error {
|
||||
if rcv, err := rplSv1.dm.DataDB().GetStatQueueDrv(tntID.Tenant, tntID.ID); err != nil {
|
||||
return err
|
||||
} else {
|
||||
@@ -78,7 +79,7 @@ func (rplSv1 *ReplicatorSv1) GetStatQueue(tntID *utils.TenantID, reply *engine.S
|
||||
}
|
||||
|
||||
//GetFilter
|
||||
func (rplSv1 *ReplicatorSv1) GetFilter(tntID *utils.TenantID, reply *engine.Filter) error {
|
||||
func (rplSv1 *ReplicatorSv1) GetFilter(tntID *utils.TenantIDWithArgDispatcher, reply *engine.Filter) error {
|
||||
if rcv, err := rplSv1.dm.DataDB().GetFilterDrv(tntID.Tenant, tntID.ID); err != nil {
|
||||
return err
|
||||
} else {
|
||||
@@ -88,7 +89,7 @@ func (rplSv1 *ReplicatorSv1) GetFilter(tntID *utils.TenantID, reply *engine.Filt
|
||||
}
|
||||
|
||||
//GetThreshold
|
||||
func (rplSv1 *ReplicatorSv1) GetThreshold(tntID *utils.TenantID, reply *engine.Threshold) error {
|
||||
func (rplSv1 *ReplicatorSv1) GetThreshold(tntID *utils.TenantIDWithArgDispatcher, reply *engine.Threshold) error {
|
||||
if rcv, err := rplSv1.dm.DataDB().GetThresholdDrv(tntID.Tenant, tntID.ID); err != nil {
|
||||
return err
|
||||
} else {
|
||||
@@ -98,7 +99,7 @@ func (rplSv1 *ReplicatorSv1) GetThreshold(tntID *utils.TenantID, reply *engine.T
|
||||
}
|
||||
|
||||
//GetThresholdProfile
|
||||
func (rplSv1 *ReplicatorSv1) GetThresholdProfile(tntID *utils.TenantID, reply *engine.ThresholdProfile) error {
|
||||
func (rplSv1 *ReplicatorSv1) GetThresholdProfile(tntID *utils.TenantIDWithArgDispatcher, reply *engine.ThresholdProfile) error {
|
||||
if rcv, err := rplSv1.dm.DataDB().GetThresholdProfileDrv(tntID.Tenant, tntID.ID); err != nil {
|
||||
return err
|
||||
} else {
|
||||
@@ -108,7 +109,7 @@ func (rplSv1 *ReplicatorSv1) GetThresholdProfile(tntID *utils.TenantID, reply *e
|
||||
}
|
||||
|
||||
//GetStatQueueProfile
|
||||
func (rplSv1 *ReplicatorSv1) GetStatQueueProfile(tntID *utils.TenantID, reply *engine.StatQueueProfile) error {
|
||||
func (rplSv1 *ReplicatorSv1) GetStatQueueProfile(tntID *utils.TenantIDWithArgDispatcher, reply *engine.StatQueueProfile) error {
|
||||
if rcv, err := rplSv1.dm.DataDB().GetStatQueueProfileDrv(tntID.Tenant, tntID.ID); err != nil {
|
||||
return err
|
||||
} else {
|
||||
@@ -118,8 +119,8 @@ func (rplSv1 *ReplicatorSv1) GetStatQueueProfile(tntID *utils.TenantID, reply *e
|
||||
}
|
||||
|
||||
//GetTiming
|
||||
func (rplSv1 *ReplicatorSv1) GetTiming(id string, reply *utils.TPTiming) error {
|
||||
if rcv, err := rplSv1.dm.DataDB().GetTimingDrv(id); err != nil {
|
||||
func (rplSv1 *ReplicatorSv1) GetTiming(id *dispatchers.StringWithApiKey, reply *utils.TPTiming) error {
|
||||
if rcv, err := rplSv1.dm.DataDB().GetTimingDrv(id.Arg); err != nil {
|
||||
return err
|
||||
} else {
|
||||
*reply = *rcv
|
||||
@@ -128,7 +129,7 @@ func (rplSv1 *ReplicatorSv1) GetTiming(id string, reply *utils.TPTiming) error {
|
||||
}
|
||||
|
||||
//GetResource
|
||||
func (rplSv1 *ReplicatorSv1) GetResource(tntID *utils.TenantID, reply *engine.Resource) error {
|
||||
func (rplSv1 *ReplicatorSv1) GetResource(tntID *utils.TenantIDWithArgDispatcher, reply *engine.Resource) error {
|
||||
if rcv, err := rplSv1.dm.DataDB().GetResourceDrv(tntID.Tenant, tntID.ID); err != nil {
|
||||
return err
|
||||
} else {
|
||||
@@ -138,7 +139,7 @@ func (rplSv1 *ReplicatorSv1) GetResource(tntID *utils.TenantID, reply *engine.Re
|
||||
}
|
||||
|
||||
//GetResourceProfile
|
||||
func (rplSv1 *ReplicatorSv1) GetResourceProfile(tntID *utils.TenantID, reply *engine.ResourceProfile) error {
|
||||
func (rplSv1 *ReplicatorSv1) GetResourceProfile(tntID *utils.TenantIDWithArgDispatcher, reply *engine.ResourceProfile) error {
|
||||
if rcv, err := rplSv1.dm.DataDB().GetResourceProfileDrv(tntID.Tenant, tntID.ID); err != nil {
|
||||
return err
|
||||
} else {
|
||||
@@ -148,18 +149,18 @@ func (rplSv1 *ReplicatorSv1) GetResourceProfile(tntID *utils.TenantID, reply *en
|
||||
}
|
||||
|
||||
//GetActionTriggers
|
||||
func (rplSv1 *ReplicatorSv1) GetActionTriggers(id string, reply engine.ActionTriggers) error {
|
||||
if rcv, err := rplSv1.dm.DataDB().GetActionTriggersDrv(id); err != nil {
|
||||
func (rplSv1 *ReplicatorSv1) GetActionTriggers(id *dispatchers.StringWithApiKey, reply *engine.ActionTriggers) error {
|
||||
if rcv, err := rplSv1.dm.DataDB().GetActionTriggersDrv(id.Arg); err != nil {
|
||||
return err
|
||||
} else {
|
||||
reply = rcv
|
||||
*reply = rcv
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
//GetShareGroup
|
||||
func (rplSv1 *ReplicatorSv1) GetShareGroup(id string, reply *engine.SharedGroup) error {
|
||||
if rcv, err := rplSv1.dm.DataDB().GetSharedGroupDrv(id); err != nil {
|
||||
func (rplSv1 *ReplicatorSv1) GetShareGroup(id *dispatchers.StringWithApiKey, reply *engine.SharedGroup) error {
|
||||
if rcv, err := rplSv1.dm.DataDB().GetSharedGroupDrv(id.Arg); err != nil {
|
||||
return err
|
||||
} else {
|
||||
*reply = *rcv
|
||||
@@ -168,8 +169,8 @@ func (rplSv1 *ReplicatorSv1) GetShareGroup(id string, reply *engine.SharedGroup)
|
||||
}
|
||||
|
||||
//GetActions
|
||||
func (rplSv1 *ReplicatorSv1) GetActions(id string, reply *engine.Actions) error {
|
||||
if rcv, err := rplSv1.dm.DataDB().GetActionsDrv(id); err != nil {
|
||||
func (rplSv1 *ReplicatorSv1) GetActions(id *dispatchers.StringWithApiKey, reply *engine.Actions) error {
|
||||
if rcv, err := rplSv1.dm.DataDB().GetActionsDrv(id.Arg); err != nil {
|
||||
return err
|
||||
} else {
|
||||
*reply = rcv
|
||||
@@ -178,8 +179,8 @@ func (rplSv1 *ReplicatorSv1) GetActions(id string, reply *engine.Actions) error
|
||||
}
|
||||
|
||||
//GetActions
|
||||
func (rplSv1 *ReplicatorSv1) GetActionPlan(id string, reply *engine.ActionPlan) error {
|
||||
if rcv, err := rplSv1.dm.DataDB().GetActionPlanDrv(id, true, utils.NonTransactional); err != nil {
|
||||
func (rplSv1 *ReplicatorSv1) GetActionPlan(id *dispatchers.StringWithApiKey, reply *engine.ActionPlan) error {
|
||||
if rcv, err := rplSv1.dm.DataDB().GetActionPlanDrv(id.Arg, true, utils.NonTransactional); err != nil {
|
||||
return err
|
||||
} else {
|
||||
*reply = *rcv
|
||||
@@ -188,7 +189,7 @@ func (rplSv1 *ReplicatorSv1) GetActionPlan(id string, reply *engine.ActionPlan)
|
||||
}
|
||||
|
||||
//GetAllActionPlans
|
||||
func (rplSv1 *ReplicatorSv1) GetAllActionPlans(_ string, reply *map[string]*engine.ActionPlan) error {
|
||||
func (rplSv1 *ReplicatorSv1) GetAllActionPlans(_ *dispatchers.StringWithApiKey, reply *map[string]*engine.ActionPlan) error {
|
||||
if rcv, err := rplSv1.dm.DataDB().GetAllActionPlansDrv(); err != nil {
|
||||
return err
|
||||
} else {
|
||||
@@ -198,8 +199,8 @@ func (rplSv1 *ReplicatorSv1) GetAllActionPlans(_ string, reply *map[string]*engi
|
||||
}
|
||||
|
||||
//GetAccountActionPlans
|
||||
func (rplSv1 *ReplicatorSv1) GetAccountActionPlans(id string, reply *[]string) error {
|
||||
if rcv, err := rplSv1.dm.DataDB().GetAccountActionPlansDrv(id, false, utils.NonTransactional); err != nil {
|
||||
func (rplSv1 *ReplicatorSv1) GetAccountActionPlans(id *dispatchers.StringWithApiKey, reply *[]string) error {
|
||||
if rcv, err := rplSv1.dm.DataDB().GetAccountActionPlansDrv(id.Arg, false, utils.NonTransactional); err != nil {
|
||||
return err
|
||||
} else {
|
||||
*reply = rcv
|
||||
@@ -208,8 +209,8 @@ func (rplSv1 *ReplicatorSv1) GetAccountActionPlans(id string, reply *[]string) e
|
||||
}
|
||||
|
||||
//GetAllActionPlans
|
||||
func (rplSv1 *ReplicatorSv1) GetRatingPlan(id string, reply *engine.RatingPlan) error {
|
||||
if rcv, err := rplSv1.dm.DataDB().GetRatingPlanDrv(id); err != nil {
|
||||
func (rplSv1 *ReplicatorSv1) GetRatingPlan(id *dispatchers.StringWithApiKey, reply *engine.RatingPlan) error {
|
||||
if rcv, err := rplSv1.dm.DataDB().GetRatingPlanDrv(id.Arg); err != nil {
|
||||
return err
|
||||
} else {
|
||||
*reply = *rcv
|
||||
@@ -218,8 +219,8 @@ func (rplSv1 *ReplicatorSv1) GetRatingPlan(id string, reply *engine.RatingPlan)
|
||||
}
|
||||
|
||||
//GetAllActionPlans
|
||||
func (rplSv1 *ReplicatorSv1) GetRatingProfile(id string, reply *engine.RatingProfile) error {
|
||||
if rcv, err := rplSv1.dm.DataDB().GetRatingProfileDrv(id); err != nil {
|
||||
func (rplSv1 *ReplicatorSv1) GetRatingProfile(id *dispatchers.StringWithApiKey, reply *engine.RatingProfile) error {
|
||||
if rcv, err := rplSv1.dm.DataDB().GetRatingProfileDrv(id.Arg); err != nil {
|
||||
return err
|
||||
} else {
|
||||
*reply = *rcv
|
||||
@@ -228,7 +229,7 @@ func (rplSv1 *ReplicatorSv1) GetRatingProfile(id string, reply *engine.RatingPro
|
||||
}
|
||||
|
||||
//GetResourceProfile
|
||||
func (rplSv1 *ReplicatorSv1) GetSupplierProfile(tntID *utils.TenantID, reply *engine.SupplierProfile) error {
|
||||
func (rplSv1 *ReplicatorSv1) GetSupplierProfile(tntID *utils.TenantIDWithArgDispatcher, reply *engine.SupplierProfile) error {
|
||||
if rcv, err := rplSv1.dm.DataDB().GetSupplierProfileDrv(tntID.Tenant, tntID.ID); err != nil {
|
||||
return err
|
||||
} else {
|
||||
@@ -238,7 +239,7 @@ func (rplSv1 *ReplicatorSv1) GetSupplierProfile(tntID *utils.TenantID, reply *en
|
||||
}
|
||||
|
||||
//GetResourceProfile
|
||||
func (rplSv1 *ReplicatorSv1) GetAttributeProfile(tntID *utils.TenantID, reply *engine.AttributeProfile) error {
|
||||
func (rplSv1 *ReplicatorSv1) GetAttributeProfile(tntID *utils.TenantIDWithArgDispatcher, reply *engine.AttributeProfile) error {
|
||||
if rcv, err := rplSv1.dm.DataDB().GetAttributeProfileDrv(tntID.Tenant, tntID.ID); err != nil {
|
||||
return err
|
||||
} else {
|
||||
@@ -248,7 +249,7 @@ func (rplSv1 *ReplicatorSv1) GetAttributeProfile(tntID *utils.TenantID, reply *e
|
||||
}
|
||||
|
||||
//GetResourceProfile
|
||||
func (rplSv1 *ReplicatorSv1) GetChargerProfile(tntID *utils.TenantID, reply *engine.ChargerProfile) error {
|
||||
func (rplSv1 *ReplicatorSv1) GetChargerProfile(tntID *utils.TenantIDWithArgDispatcher, reply *engine.ChargerProfile) error {
|
||||
if rcv, err := rplSv1.dm.DataDB().GetChargerProfileDrv(tntID.Tenant, tntID.ID); err != nil {
|
||||
return err
|
||||
} else {
|
||||
@@ -258,7 +259,7 @@ func (rplSv1 *ReplicatorSv1) GetChargerProfile(tntID *utils.TenantID, reply *eng
|
||||
}
|
||||
|
||||
//GetResourceProfile
|
||||
func (rplSv1 *ReplicatorSv1) GetDispatcherProfile(tntID *utils.TenantID, reply *engine.DispatcherProfile) error {
|
||||
func (rplSv1 *ReplicatorSv1) GetDispatcherProfile(tntID *utils.TenantIDWithArgDispatcher, reply *engine.DispatcherProfile) error {
|
||||
if rcv, err := rplSv1.dm.DataDB().GetDispatcherProfileDrv(tntID.Tenant, tntID.ID); err != nil {
|
||||
return err
|
||||
} else {
|
||||
@@ -268,7 +269,7 @@ func (rplSv1 *ReplicatorSv1) GetDispatcherProfile(tntID *utils.TenantID, reply *
|
||||
}
|
||||
|
||||
//GetResourceProfile
|
||||
func (rplSv1 *ReplicatorSv1) GetDispatcherHost(tntID *utils.TenantID, reply *engine.DispatcherHost) error {
|
||||
func (rplSv1 *ReplicatorSv1) GetDispatcherHost(tntID *utils.TenantIDWithArgDispatcher, reply *engine.DispatcherHost) error {
|
||||
if rcv, err := rplSv1.dm.DataDB().GetDispatcherHostDrv(tntID.Tenant, tntID.ID); err != nil {
|
||||
return err
|
||||
} else {
|
||||
@@ -278,8 +279,8 @@ func (rplSv1 *ReplicatorSv1) GetDispatcherHost(tntID *utils.TenantID, reply *eng
|
||||
}
|
||||
|
||||
//GetResourceProfile
|
||||
func (rplSv1 *ReplicatorSv1) GetItemLoadIDs(itemID string, reply *map[string]int64) error {
|
||||
if rcv, err := rplSv1.dm.DataDB().GetItemLoadIDsDrv(itemID); err != nil {
|
||||
func (rplSv1 *ReplicatorSv1) GetItemLoadIDs(itemID *dispatchers.StringWithApiKey, reply *map[string]int64) error {
|
||||
if rcv, err := rplSv1.dm.DataDB().GetItemLoadIDsDrv(itemID.Arg); err != nil {
|
||||
return err
|
||||
} else {
|
||||
*reply = rcv
|
||||
@@ -288,7 +289,7 @@ func (rplSv1 *ReplicatorSv1) GetItemLoadIDs(itemID string, reply *map[string]int
|
||||
}
|
||||
|
||||
//GetResourceProfile
|
||||
func (rplSv1 *ReplicatorSv1) GetFilterIndexes(args *utils.GetFilterIndexesArg, reply *map[string]utils.StringMap) error {
|
||||
func (rplSv1 *ReplicatorSv1) GetFilterIndexes(args *utils.GetFilterIndexesArgWithArgDispatcher, reply *map[string]utils.StringMap) error {
|
||||
if rcv, err := rplSv1.dm.DataDB().GetFilterIndexesDrv(args.CacheID, args.ItemIDPrefix,
|
||||
args.FilterType, args.FldNameVal); err != nil {
|
||||
return err
|
||||
|
||||
@@ -130,6 +130,9 @@ type ItemOpt struct {
|
||||
Remote bool
|
||||
Replicate bool
|
||||
TTL time.Duration
|
||||
// used for ArgDispatcher in case we send this to a dispatcer engine
|
||||
RouteID string
|
||||
APIKey string
|
||||
}
|
||||
|
||||
func (itm *ItemOpt) loadFromJsonCfg(jsonItm *ItemOptJson) (err error) {
|
||||
@@ -147,5 +150,11 @@ func (itm *ItemOpt) loadFromJsonCfg(jsonItm *ItemOptJson) (err error) {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if jsonItm.Route_id != nil {
|
||||
itm.RouteID = *jsonItm.Route_id
|
||||
}
|
||||
if jsonItm.Api_key != nil {
|
||||
itm.APIKey = *jsonItm.Api_key
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@@ -101,6 +101,9 @@ type ItemOptJson struct {
|
||||
Remote *bool
|
||||
Replicate *bool
|
||||
Ttl *string
|
||||
// used for ArgDispatcher in case we send this to a dispatcer engine
|
||||
Route_id *string
|
||||
Api_key *string
|
||||
}
|
||||
|
||||
// Filters config
|
||||
|
||||
@@ -19,6 +19,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
package dispatchers
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/cgrates/cgrates/utils"
|
||||
)
|
||||
|
||||
@@ -52,7 +54,7 @@ func (dS *DispatcherService) RALsV1GetRatingPlansCost(args *utils.RatingPlanCost
|
||||
}
|
||||
if err = dS.authorize(utils.RALsV1GetRatingPlansCost,
|
||||
tenant,
|
||||
args.APIKey, &nowTime); err != nil {
|
||||
args.APIKey, utils.TimePointer(time.Now())); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
608
dispatchers/replicator.go
Normal file
608
dispatchers/replicator.go
Normal file
@@ -0,0 +1,608 @@
|
||||
/*
|
||||
Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
|
||||
Copyright (C) ITsysCOM GmbH
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
|
||||
package dispatchers
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/cgrates/cgrates/engine"
|
||||
"github.com/cgrates/cgrates/utils"
|
||||
)
|
||||
|
||||
func (dS *DispatcherService) ReplicatorSv1Ping(args *utils.CGREventWithArgDispatcher, rpl *string) (err error) {
|
||||
if args == nil {
|
||||
args = utils.NewCGREventWithArgDispatcher()
|
||||
}
|
||||
args.CGREvent.Tenant = utils.FirstNonEmpty(args.CGREvent.Tenant, dS.cfg.GeneralCfg().DefaultTenant)
|
||||
if len(dS.cfg.DispatcherSCfg().AttributeSConns) != 0 {
|
||||
if args.ArgDispatcher == nil {
|
||||
return utils.NewErrMandatoryIeMissing(utils.ArgDispatcherField)
|
||||
}
|
||||
if err = dS.authorize(utils.ReplicatorSv1Ping, args.CGREvent.Tenant,
|
||||
args.APIKey, args.CGREvent.Time); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
var routeID *string
|
||||
if args.ArgDispatcher != nil {
|
||||
routeID = args.ArgDispatcher.RouteID
|
||||
}
|
||||
return dS.Dispatch(args.CGREvent, utils.MetaReplicator, routeID,
|
||||
utils.ReplicatorSv1Ping, args, rpl)
|
||||
}
|
||||
|
||||
func (dS *DispatcherService) ReplicatorSv1GetAccount(args *StringWithApiKey, rpl *engine.Account) (err error) {
|
||||
if args == nil {
|
||||
args = &StringWithApiKey{}
|
||||
}
|
||||
args.TenantArg.Tenant = utils.FirstNonEmpty(args.TenantArg.Tenant, dS.cfg.GeneralCfg().DefaultTenant)
|
||||
if len(dS.cfg.DispatcherSCfg().AttributeSConns) != 0 {
|
||||
if args.ArgDispatcher == nil {
|
||||
return utils.NewErrMandatoryIeMissing(utils.ArgDispatcherField)
|
||||
}
|
||||
if err = dS.authorize(utils.ReplicatorSv1GetAccount, args.TenantArg.Tenant,
|
||||
args.APIKey, utils.TimePointer(time.Now())); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
var routeID *string
|
||||
if args.ArgDispatcher != nil {
|
||||
routeID = args.ArgDispatcher.RouteID
|
||||
}
|
||||
return dS.Dispatch(&utils.CGREvent{Tenant: args.TenantArg.Tenant}, utils.MetaReplicator, routeID,
|
||||
utils.ReplicatorSv1GetAccount, args, rpl)
|
||||
}
|
||||
|
||||
func (dS *DispatcherService) ReplicatorSv1GetDestination(args *StringWithApiKey, rpl *engine.Destination) (err error) {
|
||||
if args == nil {
|
||||
args = &StringWithApiKey{}
|
||||
}
|
||||
args.TenantArg.Tenant = utils.FirstNonEmpty(args.TenantArg.Tenant, dS.cfg.GeneralCfg().DefaultTenant)
|
||||
if len(dS.cfg.DispatcherSCfg().AttributeSConns) != 0 {
|
||||
if args.ArgDispatcher == nil {
|
||||
return utils.NewErrMandatoryIeMissing(utils.ArgDispatcherField)
|
||||
}
|
||||
if err = dS.authorize(utils.ReplicatorSv1GetDestination, args.TenantArg.Tenant,
|
||||
args.APIKey, utils.TimePointer(time.Now())); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
var routeID *string
|
||||
if args.ArgDispatcher != nil {
|
||||
routeID = args.ArgDispatcher.RouteID
|
||||
}
|
||||
return dS.Dispatch(&utils.CGREvent{Tenant: args.TenantArg.Tenant}, utils.MetaReplicator, routeID,
|
||||
utils.ReplicatorSv1GetDestination, args, rpl)
|
||||
}
|
||||
|
||||
func (dS *DispatcherService) ReplicatorSv1GetReverseDestination(args *StringWithApiKey, rpl *[]string) (err error) {
|
||||
if args == nil {
|
||||
args = &StringWithApiKey{}
|
||||
}
|
||||
args.TenantArg.Tenant = utils.FirstNonEmpty(args.TenantArg.Tenant, dS.cfg.GeneralCfg().DefaultTenant)
|
||||
if len(dS.cfg.DispatcherSCfg().AttributeSConns) != 0 {
|
||||
if args.ArgDispatcher == nil {
|
||||
return utils.NewErrMandatoryIeMissing(utils.ArgDispatcherField)
|
||||
}
|
||||
if err = dS.authorize(utils.ReplicatorSv1GetReverseDestination, args.TenantArg.Tenant,
|
||||
args.APIKey, utils.TimePointer(time.Now())); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
var routeID *string
|
||||
if args.ArgDispatcher != nil {
|
||||
routeID = args.ArgDispatcher.RouteID
|
||||
}
|
||||
return dS.Dispatch(&utils.CGREvent{Tenant: args.TenantArg.Tenant}, utils.MetaReplicator, routeID,
|
||||
utils.ReplicatorSv1GetReverseDestination, args, rpl)
|
||||
}
|
||||
|
||||
func (dS *DispatcherService) ReplicatorSv1GetStatQueue(args *utils.TenantIDWithArgDispatcher, reply *engine.StatQueue) (err error) {
|
||||
tnt := dS.cfg.GeneralCfg().DefaultTenant
|
||||
if args.TenantID != nil && args.TenantID.Tenant != utils.EmptyString {
|
||||
tnt = args.TenantID.Tenant
|
||||
}
|
||||
if args.ArgDispatcher == nil {
|
||||
return utils.NewErrMandatoryIeMissing(utils.ArgDispatcherField)
|
||||
}
|
||||
if len(dS.cfg.DispatcherSCfg().AttributeSConns) != 0 {
|
||||
if err = dS.authorize(utils.ReplicatorSv1GetStatQueue, tnt,
|
||||
args.APIKey, utils.TimePointer(time.Now())); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
routeID := args.ArgDispatcher.RouteID
|
||||
return dS.Dispatch(&utils.CGREvent{
|
||||
Tenant: tnt,
|
||||
ID: args.ID,
|
||||
}, utils.MetaReplicator, routeID, utils.ReplicatorSv1GetStatQueue, args, reply)
|
||||
}
|
||||
|
||||
func (dS *DispatcherService) ReplicatorSv1GetFilter(args *utils.TenantIDWithArgDispatcher, reply *engine.Filter) (err error) {
|
||||
tnt := dS.cfg.GeneralCfg().DefaultTenant
|
||||
if args.TenantID != nil && args.TenantID.Tenant != utils.EmptyString {
|
||||
tnt = args.TenantID.Tenant
|
||||
}
|
||||
if args.ArgDispatcher == nil {
|
||||
return utils.NewErrMandatoryIeMissing(utils.ArgDispatcherField)
|
||||
}
|
||||
if len(dS.cfg.DispatcherSCfg().AttributeSConns) != 0 {
|
||||
if err = dS.authorize(utils.ReplicatorSv1GetFilter, tnt,
|
||||
args.APIKey, utils.TimePointer(time.Now())); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
routeID := args.ArgDispatcher.RouteID
|
||||
return dS.Dispatch(&utils.CGREvent{
|
||||
Tenant: tnt,
|
||||
ID: args.ID,
|
||||
}, utils.MetaReplicator, routeID, utils.ReplicatorSv1GetFilter, args, reply)
|
||||
}
|
||||
|
||||
func (dS *DispatcherService) ReplicatorSv1GetThreshold(args *utils.TenantIDWithArgDispatcher, reply *engine.Threshold) (err error) {
|
||||
tnt := dS.cfg.GeneralCfg().DefaultTenant
|
||||
if args.TenantID != nil && args.TenantID.Tenant != utils.EmptyString {
|
||||
tnt = args.TenantID.Tenant
|
||||
}
|
||||
if args.ArgDispatcher == nil {
|
||||
return utils.NewErrMandatoryIeMissing(utils.ArgDispatcherField)
|
||||
}
|
||||
if len(dS.cfg.DispatcherSCfg().AttributeSConns) != 0 {
|
||||
if err = dS.authorize(utils.ReplicatorSv1GetThreshold, tnt,
|
||||
args.APIKey, utils.TimePointer(time.Now())); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
routeID := args.ArgDispatcher.RouteID
|
||||
return dS.Dispatch(&utils.CGREvent{
|
||||
Tenant: tnt,
|
||||
ID: args.ID,
|
||||
}, utils.MetaReplicator, routeID, utils.ReplicatorSv1GetThreshold, args, reply)
|
||||
}
|
||||
|
||||
func (dS *DispatcherService) ReplicatorSv1GetThresholdProfile(args *utils.TenantIDWithArgDispatcher, reply *engine.ThresholdProfile) (err error) {
|
||||
tnt := dS.cfg.GeneralCfg().DefaultTenant
|
||||
if args.TenantID != nil && args.TenantID.Tenant != utils.EmptyString {
|
||||
tnt = args.TenantID.Tenant
|
||||
}
|
||||
if args.ArgDispatcher == nil {
|
||||
return utils.NewErrMandatoryIeMissing(utils.ArgDispatcherField)
|
||||
}
|
||||
if len(dS.cfg.DispatcherSCfg().AttributeSConns) != 0 {
|
||||
if err = dS.authorize(utils.ReplicatorSv1GetThresholdProfile, tnt,
|
||||
args.APIKey, utils.TimePointer(time.Now())); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
routeID := args.ArgDispatcher.RouteID
|
||||
return dS.Dispatch(&utils.CGREvent{
|
||||
Tenant: tnt,
|
||||
ID: args.ID,
|
||||
}, utils.MetaReplicator, routeID, utils.ReplicatorSv1GetThresholdProfile, args, reply)
|
||||
}
|
||||
|
||||
func (dS *DispatcherService) ReplicatorSv1GetStatQueueProfile(args *utils.TenantIDWithArgDispatcher, reply *engine.StatQueueProfile) (err error) {
|
||||
tnt := dS.cfg.GeneralCfg().DefaultTenant
|
||||
if args.TenantID != nil && args.TenantID.Tenant != utils.EmptyString {
|
||||
tnt = args.TenantID.Tenant
|
||||
}
|
||||
if args.ArgDispatcher == nil {
|
||||
return utils.NewErrMandatoryIeMissing(utils.ArgDispatcherField)
|
||||
}
|
||||
if len(dS.cfg.DispatcherSCfg().AttributeSConns) != 0 {
|
||||
if err = dS.authorize(utils.ReplicatorSv1GetStatQueueProfile, tnt,
|
||||
args.APIKey, utils.TimePointer(time.Now())); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
routeID := args.ArgDispatcher.RouteID
|
||||
return dS.Dispatch(&utils.CGREvent{
|
||||
Tenant: tnt,
|
||||
ID: args.ID,
|
||||
}, utils.MetaReplicator, routeID, utils.ReplicatorSv1GetStatQueueProfile, args, reply)
|
||||
}
|
||||
|
||||
func (dS *DispatcherService) ReplicatorSv1GetTiming(args *StringWithApiKey, rpl *utils.TPTiming) (err error) {
|
||||
if args == nil {
|
||||
args = &StringWithApiKey{}
|
||||
}
|
||||
args.TenantArg.Tenant = utils.FirstNonEmpty(args.TenantArg.Tenant, dS.cfg.GeneralCfg().DefaultTenant)
|
||||
if len(dS.cfg.DispatcherSCfg().AttributeSConns) != 0 {
|
||||
if args.ArgDispatcher == nil {
|
||||
return utils.NewErrMandatoryIeMissing(utils.ArgDispatcherField)
|
||||
}
|
||||
if err = dS.authorize(utils.ReplicatorSv1GetTiming, args.TenantArg.Tenant,
|
||||
args.APIKey, utils.TimePointer(time.Now())); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
var routeID *string
|
||||
if args.ArgDispatcher != nil {
|
||||
routeID = args.ArgDispatcher.RouteID
|
||||
}
|
||||
return dS.Dispatch(&utils.CGREvent{Tenant: args.TenantArg.Tenant}, utils.MetaReplicator, routeID,
|
||||
utils.ReplicatorSv1GetTiming, args, rpl)
|
||||
}
|
||||
|
||||
func (dS *DispatcherService) ReplicatorSv1GetResource(args *utils.TenantIDWithArgDispatcher, reply *engine.Resource) (err error) {
|
||||
tnt := dS.cfg.GeneralCfg().DefaultTenant
|
||||
if args.TenantID != nil && args.TenantID.Tenant != utils.EmptyString {
|
||||
tnt = args.TenantID.Tenant
|
||||
}
|
||||
if args.ArgDispatcher == nil {
|
||||
return utils.NewErrMandatoryIeMissing(utils.ArgDispatcherField)
|
||||
}
|
||||
if len(dS.cfg.DispatcherSCfg().AttributeSConns) != 0 {
|
||||
if err = dS.authorize(utils.ReplicatorSv1GetResource, tnt,
|
||||
args.APIKey, utils.TimePointer(time.Now())); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
routeID := args.ArgDispatcher.RouteID
|
||||
return dS.Dispatch(&utils.CGREvent{
|
||||
Tenant: tnt,
|
||||
ID: args.ID,
|
||||
}, utils.MetaReplicator, routeID, utils.ReplicatorSv1GetResource, args, reply)
|
||||
}
|
||||
|
||||
func (dS *DispatcherService) ReplicatorSv1GetResourceProfile(args *utils.TenantIDWithArgDispatcher, reply *engine.ResourceProfile) (err error) {
|
||||
tnt := dS.cfg.GeneralCfg().DefaultTenant
|
||||
if args.TenantID != nil && args.TenantID.Tenant != utils.EmptyString {
|
||||
tnt = args.TenantID.Tenant
|
||||
}
|
||||
if args.ArgDispatcher == nil {
|
||||
return utils.NewErrMandatoryIeMissing(utils.ArgDispatcherField)
|
||||
}
|
||||
if len(dS.cfg.DispatcherSCfg().AttributeSConns) != 0 {
|
||||
if err = dS.authorize(utils.ReplicatorSv1GetResourceProfile, tnt,
|
||||
args.APIKey, utils.TimePointer(time.Now())); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
routeID := args.ArgDispatcher.RouteID
|
||||
return dS.Dispatch(&utils.CGREvent{
|
||||
Tenant: tnt,
|
||||
ID: args.ID,
|
||||
}, utils.MetaReplicator, routeID, utils.ReplicatorSv1GetResourceProfile, args, reply)
|
||||
}
|
||||
|
||||
func (dS *DispatcherService) ReplicatorSv1GetActionTriggers(args *StringWithApiKey, rpl *engine.ActionTriggers) (err error) {
|
||||
if args == nil {
|
||||
args = &StringWithApiKey{}
|
||||
}
|
||||
args.TenantArg.Tenant = utils.FirstNonEmpty(args.TenantArg.Tenant, dS.cfg.GeneralCfg().DefaultTenant)
|
||||
if len(dS.cfg.DispatcherSCfg().AttributeSConns) != 0 {
|
||||
if args.ArgDispatcher == nil {
|
||||
return utils.NewErrMandatoryIeMissing(utils.ArgDispatcherField)
|
||||
}
|
||||
if err = dS.authorize(utils.ReplicatorSv1GetActionTriggers, args.TenantArg.Tenant,
|
||||
args.APIKey, utils.TimePointer(time.Now())); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
var routeID *string
|
||||
if args.ArgDispatcher != nil {
|
||||
routeID = args.ArgDispatcher.RouteID
|
||||
}
|
||||
return dS.Dispatch(&utils.CGREvent{Tenant: args.TenantArg.Tenant}, utils.MetaReplicator, routeID,
|
||||
utils.ReplicatorSv1GetActionTriggers, args, rpl)
|
||||
}
|
||||
|
||||
func (dS *DispatcherService) ReplicatorSv1GetShareGroup(args *StringWithApiKey, rpl *engine.SharedGroup) (err error) {
|
||||
if args == nil {
|
||||
args = &StringWithApiKey{}
|
||||
}
|
||||
args.TenantArg.Tenant = utils.FirstNonEmpty(args.TenantArg.Tenant, dS.cfg.GeneralCfg().DefaultTenant)
|
||||
if len(dS.cfg.DispatcherSCfg().AttributeSConns) != 0 {
|
||||
if args.ArgDispatcher == nil {
|
||||
return utils.NewErrMandatoryIeMissing(utils.ArgDispatcherField)
|
||||
}
|
||||
if err = dS.authorize(utils.ReplicatorSv1GetShareGroup, args.TenantArg.Tenant,
|
||||
args.APIKey, utils.TimePointer(time.Now())); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
var routeID *string
|
||||
if args.ArgDispatcher != nil {
|
||||
routeID = args.ArgDispatcher.RouteID
|
||||
}
|
||||
return dS.Dispatch(&utils.CGREvent{Tenant: args.TenantArg.Tenant}, utils.MetaReplicator, routeID,
|
||||
utils.ReplicatorSv1GetShareGroup, args, rpl)
|
||||
}
|
||||
|
||||
func (dS *DispatcherService) ReplicatorSv1GetActions(args *StringWithApiKey, rpl *engine.Actions) (err error) {
|
||||
if args == nil {
|
||||
args = &StringWithApiKey{}
|
||||
}
|
||||
args.TenantArg.Tenant = utils.FirstNonEmpty(args.TenantArg.Tenant, dS.cfg.GeneralCfg().DefaultTenant)
|
||||
if len(dS.cfg.DispatcherSCfg().AttributeSConns) != 0 {
|
||||
if args.ArgDispatcher == nil {
|
||||
return utils.NewErrMandatoryIeMissing(utils.ArgDispatcherField)
|
||||
}
|
||||
if err = dS.authorize(utils.ReplicatorSv1GetActions, args.TenantArg.Tenant,
|
||||
args.APIKey, utils.TimePointer(time.Now())); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
var routeID *string
|
||||
if args.ArgDispatcher != nil {
|
||||
routeID = args.ArgDispatcher.RouteID
|
||||
}
|
||||
return dS.Dispatch(&utils.CGREvent{Tenant: args.TenantArg.Tenant}, utils.MetaReplicator, routeID,
|
||||
utils.ReplicatorSv1GetActions, args, rpl)
|
||||
}
|
||||
|
||||
func (dS *DispatcherService) ReplicatorSv1GetActionPlan(args *StringWithApiKey, rpl *engine.ActionPlan) (err error) {
|
||||
if args == nil {
|
||||
args = &StringWithApiKey{}
|
||||
}
|
||||
args.TenantArg.Tenant = utils.FirstNonEmpty(args.TenantArg.Tenant, dS.cfg.GeneralCfg().DefaultTenant)
|
||||
if len(dS.cfg.DispatcherSCfg().AttributeSConns) != 0 {
|
||||
if args.ArgDispatcher == nil {
|
||||
return utils.NewErrMandatoryIeMissing(utils.ArgDispatcherField)
|
||||
}
|
||||
if err = dS.authorize(utils.ReplicatorSv1GetActionPlan, args.TenantArg.Tenant,
|
||||
args.APIKey, utils.TimePointer(time.Now())); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
var routeID *string
|
||||
if args.ArgDispatcher != nil {
|
||||
routeID = args.ArgDispatcher.RouteID
|
||||
}
|
||||
return dS.Dispatch(&utils.CGREvent{Tenant: args.TenantArg.Tenant}, utils.MetaReplicator, routeID,
|
||||
utils.ReplicatorSv1GetActionPlan, args, rpl)
|
||||
}
|
||||
|
||||
func (dS *DispatcherService) ReplicatorSv1GetAllActionPlans(args *StringWithApiKey, rpl *map[string]*engine.ActionPlan) (err error) {
|
||||
if args == nil {
|
||||
args = &StringWithApiKey{}
|
||||
}
|
||||
args.TenantArg.Tenant = utils.FirstNonEmpty(args.TenantArg.Tenant, dS.cfg.GeneralCfg().DefaultTenant)
|
||||
if len(dS.cfg.DispatcherSCfg().AttributeSConns) != 0 {
|
||||
if args.ArgDispatcher == nil {
|
||||
return utils.NewErrMandatoryIeMissing(utils.ArgDispatcherField)
|
||||
}
|
||||
if err = dS.authorize(utils.ReplicatorSv1GetAllActionPlans, args.TenantArg.Tenant,
|
||||
args.APIKey, utils.TimePointer(time.Now())); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
var routeID *string
|
||||
if args.ArgDispatcher != nil {
|
||||
routeID = args.ArgDispatcher.RouteID
|
||||
}
|
||||
return dS.Dispatch(&utils.CGREvent{Tenant: args.TenantArg.Tenant}, utils.MetaReplicator, routeID,
|
||||
utils.ReplicatorSv1GetAllActionPlans, args, rpl)
|
||||
}
|
||||
|
||||
func (dS *DispatcherService) ReplicatorSv1GetAccountActionPlans(args *StringWithApiKey, rpl *[]string) (err error) {
|
||||
if args == nil {
|
||||
args = &StringWithApiKey{}
|
||||
}
|
||||
args.TenantArg.Tenant = utils.FirstNonEmpty(args.TenantArg.Tenant, dS.cfg.GeneralCfg().DefaultTenant)
|
||||
if len(dS.cfg.DispatcherSCfg().AttributeSConns) != 0 {
|
||||
if args.ArgDispatcher == nil {
|
||||
return utils.NewErrMandatoryIeMissing(utils.ArgDispatcherField)
|
||||
}
|
||||
if err = dS.authorize(utils.ReplicatorSv1GetAccountActionPlans, args.TenantArg.Tenant,
|
||||
args.APIKey, utils.TimePointer(time.Now())); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
var routeID *string
|
||||
if args.ArgDispatcher != nil {
|
||||
routeID = args.ArgDispatcher.RouteID
|
||||
}
|
||||
return dS.Dispatch(&utils.CGREvent{Tenant: args.TenantArg.Tenant}, utils.MetaReplicator, routeID,
|
||||
utils.ReplicatorSv1GetAccountActionPlans, args, rpl)
|
||||
}
|
||||
|
||||
func (dS *DispatcherService) ReplicatorSv1GetRatingPlan(args *StringWithApiKey, rpl *engine.RatingPlan) (err error) {
|
||||
if args == nil {
|
||||
args = &StringWithApiKey{}
|
||||
}
|
||||
args.TenantArg.Tenant = utils.FirstNonEmpty(args.TenantArg.Tenant, dS.cfg.GeneralCfg().DefaultTenant)
|
||||
if len(dS.cfg.DispatcherSCfg().AttributeSConns) != 0 {
|
||||
if args.ArgDispatcher == nil {
|
||||
return utils.NewErrMandatoryIeMissing(utils.ArgDispatcherField)
|
||||
}
|
||||
if err = dS.authorize(utils.ReplicatorSv1GetRatingPlan, args.TenantArg.Tenant,
|
||||
args.APIKey, utils.TimePointer(time.Now())); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
var routeID *string
|
||||
if args.ArgDispatcher != nil {
|
||||
routeID = args.ArgDispatcher.RouteID
|
||||
}
|
||||
return dS.Dispatch(&utils.CGREvent{Tenant: args.TenantArg.Tenant}, utils.MetaReplicator, routeID,
|
||||
utils.ReplicatorSv1GetRatingPlan, args, rpl)
|
||||
}
|
||||
|
||||
func (dS *DispatcherService) ReplicatorSv1GetRatingProfile(args *StringWithApiKey, rpl *engine.RatingProfile) (err error) {
|
||||
if args == nil {
|
||||
args = &StringWithApiKey{}
|
||||
}
|
||||
args.TenantArg.Tenant = utils.FirstNonEmpty(args.TenantArg.Tenant, dS.cfg.GeneralCfg().DefaultTenant)
|
||||
if len(dS.cfg.DispatcherSCfg().AttributeSConns) != 0 {
|
||||
if args.ArgDispatcher == nil {
|
||||
return utils.NewErrMandatoryIeMissing(utils.ArgDispatcherField)
|
||||
}
|
||||
if err = dS.authorize(utils.ReplicatorSv1GetRatingProfile, args.TenantArg.Tenant,
|
||||
args.APIKey, utils.TimePointer(time.Now())); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
var routeID *string
|
||||
if args.ArgDispatcher != nil {
|
||||
routeID = args.ArgDispatcher.RouteID
|
||||
}
|
||||
return dS.Dispatch(&utils.CGREvent{Tenant: args.TenantArg.Tenant}, utils.MetaReplicator, routeID,
|
||||
utils.ReplicatorSv1GetRatingProfile, args, rpl)
|
||||
}
|
||||
|
||||
func (dS *DispatcherService) ReplicatorSv1GetSupplierProfile(args *utils.TenantIDWithArgDispatcher, reply *engine.SupplierProfile) (err error) {
|
||||
tnt := dS.cfg.GeneralCfg().DefaultTenant
|
||||
if args.TenantID != nil && args.TenantID.Tenant != utils.EmptyString {
|
||||
tnt = args.TenantID.Tenant
|
||||
}
|
||||
if args.ArgDispatcher == nil {
|
||||
return utils.NewErrMandatoryIeMissing(utils.ArgDispatcherField)
|
||||
}
|
||||
if len(dS.cfg.DispatcherSCfg().AttributeSConns) != 0 {
|
||||
if err = dS.authorize(utils.ReplicatorSv1GetSupplierProfile, tnt,
|
||||
args.APIKey, utils.TimePointer(time.Now())); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
routeID := args.ArgDispatcher.RouteID
|
||||
return dS.Dispatch(&utils.CGREvent{
|
||||
Tenant: tnt,
|
||||
ID: args.ID,
|
||||
}, utils.MetaReplicator, routeID, utils.ReplicatorSv1GetSupplierProfile, args, reply)
|
||||
}
|
||||
|
||||
func (dS *DispatcherService) ReplicatorSv1GetAttributeProfile(args *utils.TenantIDWithArgDispatcher, reply *engine.AttributeProfile) (err error) {
|
||||
tnt := dS.cfg.GeneralCfg().DefaultTenant
|
||||
if args.TenantID != nil && args.TenantID.Tenant != utils.EmptyString {
|
||||
tnt = args.TenantID.Tenant
|
||||
}
|
||||
if args.ArgDispatcher == nil {
|
||||
return utils.NewErrMandatoryIeMissing(utils.ArgDispatcherField)
|
||||
}
|
||||
if len(dS.cfg.DispatcherSCfg().AttributeSConns) != 0 {
|
||||
if err = dS.authorize(utils.ReplicatorSv1GetAttributeProfile, tnt,
|
||||
args.APIKey, utils.TimePointer(time.Now())); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
routeID := args.ArgDispatcher.RouteID
|
||||
return dS.Dispatch(&utils.CGREvent{
|
||||
Tenant: tnt,
|
||||
ID: args.ID,
|
||||
}, utils.MetaReplicator, routeID, utils.ReplicatorSv1GetAttributeProfile, args, reply)
|
||||
}
|
||||
|
||||
func (dS *DispatcherService) ReplicatorSv1GetChargerProfile(args *utils.TenantIDWithArgDispatcher, reply *engine.ChargerProfile) (err error) {
|
||||
tnt := dS.cfg.GeneralCfg().DefaultTenant
|
||||
if args.TenantID != nil && args.TenantID.Tenant != utils.EmptyString {
|
||||
tnt = args.TenantID.Tenant
|
||||
}
|
||||
if args.ArgDispatcher == nil {
|
||||
return utils.NewErrMandatoryIeMissing(utils.ArgDispatcherField)
|
||||
}
|
||||
if len(dS.cfg.DispatcherSCfg().AttributeSConns) != 0 {
|
||||
if err = dS.authorize(utils.ReplicatorSv1GetChargerProfile, tnt,
|
||||
args.APIKey, utils.TimePointer(time.Now())); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
routeID := args.ArgDispatcher.RouteID
|
||||
return dS.Dispatch(&utils.CGREvent{
|
||||
Tenant: tnt,
|
||||
ID: args.ID,
|
||||
}, utils.MetaReplicator, routeID, utils.ReplicatorSv1GetChargerProfile, args, reply)
|
||||
}
|
||||
|
||||
func (dS *DispatcherService) ReplicatorSv1GetDispatcherProfile(args *utils.TenantIDWithArgDispatcher, reply *engine.DispatcherProfile) (err error) {
|
||||
tnt := dS.cfg.GeneralCfg().DefaultTenant
|
||||
if args.TenantID != nil && args.TenantID.Tenant != utils.EmptyString {
|
||||
tnt = args.TenantID.Tenant
|
||||
}
|
||||
if args.ArgDispatcher == nil {
|
||||
return utils.NewErrMandatoryIeMissing(utils.ArgDispatcherField)
|
||||
}
|
||||
if len(dS.cfg.DispatcherSCfg().AttributeSConns) != 0 {
|
||||
if err = dS.authorize(utils.ReplicatorSv1GetDispatcherProfile, tnt,
|
||||
args.APIKey, utils.TimePointer(time.Now())); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
routeID := args.ArgDispatcher.RouteID
|
||||
return dS.Dispatch(&utils.CGREvent{
|
||||
Tenant: tnt,
|
||||
ID: args.ID,
|
||||
}, utils.MetaReplicator, routeID, utils.ReplicatorSv1GetDispatcherProfile, args, reply)
|
||||
}
|
||||
|
||||
func (dS *DispatcherService) ReplicatorSv1GetDispatcherHost(args *utils.TenantIDWithArgDispatcher, reply *engine.DispatcherHost) (err error) {
|
||||
tnt := dS.cfg.GeneralCfg().DefaultTenant
|
||||
if args.TenantID != nil && args.TenantID.Tenant != utils.EmptyString {
|
||||
tnt = args.TenantID.Tenant
|
||||
}
|
||||
if args.ArgDispatcher == nil {
|
||||
return utils.NewErrMandatoryIeMissing(utils.ArgDispatcherField)
|
||||
}
|
||||
if len(dS.cfg.DispatcherSCfg().AttributeSConns) != 0 {
|
||||
if err = dS.authorize(utils.ReplicatorSv1GetDispatcherHost, tnt,
|
||||
args.APIKey, utils.TimePointer(time.Now())); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
routeID := args.ArgDispatcher.RouteID
|
||||
return dS.Dispatch(&utils.CGREvent{
|
||||
Tenant: tnt,
|
||||
ID: args.ID,
|
||||
}, utils.MetaReplicator, routeID, utils.ReplicatorSv1GetDispatcherHost, args, reply)
|
||||
}
|
||||
|
||||
func (dS *DispatcherService) ReplicatorSv1GetItemLoadIDs(args *StringWithApiKey, rpl *map[string]int64) (err error) {
|
||||
if args == nil {
|
||||
args = &StringWithApiKey{}
|
||||
}
|
||||
args.TenantArg.Tenant = utils.FirstNonEmpty(args.TenantArg.Tenant, dS.cfg.GeneralCfg().DefaultTenant)
|
||||
if len(dS.cfg.DispatcherSCfg().AttributeSConns) != 0 {
|
||||
if args.ArgDispatcher == nil {
|
||||
return utils.NewErrMandatoryIeMissing(utils.ArgDispatcherField)
|
||||
}
|
||||
if err = dS.authorize(utils.ReplicatorSv1GetItemLoadIDs, args.TenantArg.Tenant,
|
||||
args.APIKey, utils.TimePointer(time.Now())); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
var routeID *string
|
||||
if args.ArgDispatcher != nil {
|
||||
routeID = args.ArgDispatcher.RouteID
|
||||
}
|
||||
return dS.Dispatch(&utils.CGREvent{Tenant: args.TenantArg.Tenant}, utils.MetaReplicator, routeID,
|
||||
utils.ReplicatorSv1GetItemLoadIDs, args, rpl)
|
||||
}
|
||||
|
||||
func (dS *DispatcherService) ReplicatorSv1GetFilterIndexes(args *utils.GetFilterIndexesArgWithArgDispatcher, rpl *map[string]utils.StringMap) (err error) {
|
||||
if args == nil {
|
||||
args = &utils.GetFilterIndexesArgWithArgDispatcher{}
|
||||
}
|
||||
args.TenantArg.Tenant = utils.FirstNonEmpty(args.TenantArg.Tenant, dS.cfg.GeneralCfg().DefaultTenant)
|
||||
if len(dS.cfg.DispatcherSCfg().AttributeSConns) != 0 {
|
||||
if args.ArgDispatcher == nil {
|
||||
return utils.NewErrMandatoryIeMissing(utils.ArgDispatcherField)
|
||||
}
|
||||
if err = dS.authorize(utils.ReplicatorSv1GetFilterIndexes, args.TenantArg.Tenant,
|
||||
args.APIKey, utils.TimePointer(time.Now())); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
var routeID *string
|
||||
if args.ArgDispatcher != nil {
|
||||
routeID = args.ArgDispatcher.RouteID
|
||||
}
|
||||
return dS.Dispatch(&utils.CGREvent{Tenant: args.TenantArg.Tenant}, utils.MetaReplicator, routeID,
|
||||
utils.ReplicatorSv1GetFilterIndexes, args, rpl)
|
||||
}
|
||||
@@ -361,6 +361,7 @@ const (
|
||||
MetaScheduler = "*scheduler"
|
||||
MetaSessionsCosts = "*sessions_costs"
|
||||
MetaRALs = "*rals"
|
||||
MetaReplicator = "*replicator"
|
||||
MetaRerate = "*rerate"
|
||||
MetaRefund = "*refund"
|
||||
MetaStats = "*stats"
|
||||
|
||||
@@ -912,3 +912,9 @@ func GetPathIndex(spath string) (opath string, idx *int) {
|
||||
}
|
||||
return opath, &idxVal
|
||||
}
|
||||
|
||||
type GetFilterIndexesArgWithArgDispatcher struct {
|
||||
*GetFilterIndexesArg
|
||||
TenantArg
|
||||
*ArgDispatcher
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user