mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Merge branch 'master' of https://github.com/cgrates/cgrates
This commit is contained in:
@@ -26,7 +26,11 @@ import (
|
||||
"github.com/cgrates/cgrates/utils"
|
||||
)
|
||||
|
||||
type Apier struct {
|
||||
const (
|
||||
OK = "OK"
|
||||
)
|
||||
|
||||
type ApierV1 struct {
|
||||
StorDb engine.DataStorage
|
||||
DataDb engine.DataStorage
|
||||
Sched *scheduler.Scheduler
|
||||
@@ -37,7 +41,7 @@ type AttrDestination struct {
|
||||
Prefixes []string
|
||||
}
|
||||
|
||||
func (self *Apier) GetDestination(attr *AttrDestination, reply *AttrDestination) error {
|
||||
func (self *ApierV1) GetDestination(attr *AttrDestination, reply *AttrDestination) error {
|
||||
if dst, err := self.DataDb.GetDestination(attr.Id); err != nil {
|
||||
return errors.New(utils.ERR_NOT_FOUND)
|
||||
} else {
|
||||
@@ -55,7 +59,7 @@ type AttrGetBalance struct {
|
||||
}
|
||||
|
||||
// Get balance
|
||||
func (self *Apier) GetBalance(attr *AttrGetBalance, reply *float64) error {
|
||||
func (self *ApierV1) GetBalance(attr *AttrGetBalance, reply *float64) error {
|
||||
tag := fmt.Sprintf("%s:%s:%s", attr.Direction, attr.Tenant, attr.Account)
|
||||
userBalance, err := self.DataDb.GetUserBalance(tag)
|
||||
if err != nil {
|
||||
@@ -82,7 +86,7 @@ type AttrAddBalance struct {
|
||||
Value float64
|
||||
}
|
||||
|
||||
func (self *Apier) AddBalance(attr *AttrAddBalance, reply *float64) error {
|
||||
func (self *ApierV1) AddBalance(attr *AttrAddBalance, reply *string) error {
|
||||
// what storage instance do we use?
|
||||
tag := fmt.Sprintf("%s:%s:%s", attr.Direction, attr.Tenant, attr.Account)
|
||||
|
||||
@@ -92,6 +96,7 @@ func (self *Apier) AddBalance(attr *AttrAddBalance, reply *float64) error {
|
||||
Id: tag,
|
||||
}
|
||||
if err := self.DataDb.SetUserBalance(ub); err != nil {
|
||||
*reply = err.Error()
|
||||
return err
|
||||
}
|
||||
}
|
||||
@@ -107,9 +112,10 @@ func (self *Apier) AddBalance(attr *AttrAddBalance, reply *float64) error {
|
||||
at.SetActions(engine.Actions{&engine.Action{ActionType: engine.TOPUP, BalanceId: attr.BalanceId, Direction: attr.Direction, Units: attr.Value}})
|
||||
|
||||
if err := at.Execute(); err != nil {
|
||||
*reply = err.Error()
|
||||
return err
|
||||
}
|
||||
// what to put in replay?
|
||||
*reply = OK
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -120,7 +126,7 @@ type AttrExecuteAction struct {
|
||||
ActionsId string
|
||||
}
|
||||
|
||||
func (self *Apier) ExecuteAction(attr *AttrExecuteAction, reply *float64) error {
|
||||
func (self *ApierV1) ExecuteAction(attr *AttrExecuteAction, reply *string) error {
|
||||
tag := fmt.Sprintf("%s:%s:%s", attr.Direction, attr.Tenant, attr.Account)
|
||||
at := &engine.ActionTiming{
|
||||
UserBalanceIds: []string{tag},
|
||||
@@ -128,9 +134,10 @@ func (self *Apier) ExecuteAction(attr *AttrExecuteAction, reply *float64) error
|
||||
}
|
||||
|
||||
if err := at.Execute(); err != nil {
|
||||
*reply = err.Error()
|
||||
return err
|
||||
}
|
||||
// what to put in replay
|
||||
*reply = OK
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -140,7 +147,7 @@ type AttrSetRatingProfile struct {
|
||||
}
|
||||
|
||||
// Process dependencies and load a specific rating profile from storDb into dataDb.
|
||||
func (self *Apier) SetRatingProfile(attrs AttrSetRatingProfile, reply *string) error {
|
||||
func (self *ApierV1) SetRatingProfile(attrs AttrSetRatingProfile, reply *string) error {
|
||||
if missing := utils.MissingStructFields(&attrs, []string{"TPid", "RateProfileId"}); len(missing) != 0 {
|
||||
return fmt.Errorf("%s:%v", utils.ERR_MANDATORY_IE_MISSING, missing)
|
||||
}
|
||||
@@ -150,11 +157,11 @@ func (self *Apier) SetRatingProfile(attrs AttrSetRatingProfile, reply *string) e
|
||||
return fmt.Errorf("%s:%s", utils.ERR_SERVER_ERROR, err.Error())
|
||||
}
|
||||
|
||||
*reply = "OK"
|
||||
*reply = OK
|
||||
return nil
|
||||
}
|
||||
|
||||
type AttrActionTrigger struct {
|
||||
type AttrAddActionTrigger struct {
|
||||
Tenant string
|
||||
Account string
|
||||
Direction string
|
||||
@@ -165,7 +172,7 @@ type AttrActionTrigger struct {
|
||||
ActionsId string
|
||||
}
|
||||
|
||||
func (self *Apier) AddTriggeredAction(attr AttrActionTrigger, reply *float64) error {
|
||||
func (self *ApierV1) AddTriggeredAction(attr AttrAddActionTrigger, reply *string) error {
|
||||
if attr.Direction == "" {
|
||||
attr.Direction = engine.OUTBOUND
|
||||
}
|
||||
@@ -182,27 +189,28 @@ func (self *Apier) AddTriggeredAction(attr AttrActionTrigger, reply *float64) er
|
||||
}
|
||||
|
||||
tag := fmt.Sprintf("%s:%s:%s", attr.Direction, attr.Tenant, attr.Account)
|
||||
var dbErr error
|
||||
engine.AccLock.Guard(tag, func() (float64, error) {
|
||||
_, err := engine.AccLock.Guard(tag, func() (float64, error) {
|
||||
userBalance, err := self.DataDb.GetUserBalance(tag)
|
||||
if err != nil {
|
||||
dbErr = err
|
||||
return 0, err
|
||||
}
|
||||
|
||||
userBalance.ActionTriggers = append(userBalance.ActionTriggers, at)
|
||||
|
||||
if err = self.DataDb.SetUserBalance(userBalance); err != nil {
|
||||
dbErr = err
|
||||
return 0, err
|
||||
}
|
||||
return 0, nil
|
||||
})
|
||||
|
||||
return dbErr
|
||||
if err != nil {
|
||||
*reply = err.Error()
|
||||
return err
|
||||
}
|
||||
*reply = OK
|
||||
return nil
|
||||
}
|
||||
|
||||
type AttrAccount struct {
|
||||
type AttrAddAccount struct {
|
||||
Tenant string
|
||||
Direction string
|
||||
Account string
|
||||
@@ -211,8 +219,9 @@ type AttrAccount struct {
|
||||
}
|
||||
|
||||
// Ads a new account into dataDb. If already defined, returns success.
|
||||
func (self *Apier) AddAccount(attr *AttrAccount, reply *float64) error {
|
||||
func (self *ApierV1) AddAccount(attr *AttrAddAccount, reply *string) error {
|
||||
if missing := utils.MissingStructFields(&attr, []string{"Tenant", "Direction", "Account", "Type", "ActionTimingsId"}); len(missing) != 0 {
|
||||
*reply = fmt.Sprintf("%s:%v", utils.ERR_MANDATORY_IE_MISSING, missing)
|
||||
return fmt.Errorf("%s:%v", utils.ERR_MANDATORY_IE_MISSING, missing)
|
||||
}
|
||||
tag := fmt.Sprintf("%s:%s:%s", attr.Direction, attr.Tenant, attr.Account)
|
||||
@@ -234,12 +243,15 @@ func (self *Apier) AddAccount(attr *AttrAccount, reply *float64) error {
|
||||
}
|
||||
}
|
||||
if err := self.DataDb.SetUserBalance(ub); err != nil {
|
||||
*reply = fmt.Sprintf("%s:%s", utils.ERR_SERVER_ERROR, err.Error())
|
||||
return fmt.Errorf("%s:%s", utils.ERR_SERVER_ERROR, err.Error())
|
||||
}
|
||||
} else {
|
||||
*reply = fmt.Sprintf("%s:%s", utils.ERR_SERVER_ERROR, err.Error())
|
||||
return fmt.Errorf("%s:%s", utils.ERR_SERVER_ERROR, err.Error())
|
||||
}
|
||||
}
|
||||
*reply = OK
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -249,7 +261,7 @@ type AttrSetAccountActions struct {
|
||||
}
|
||||
|
||||
// Process dependencies and load a specific AccountActions profile from storDb into dataDb.
|
||||
func (self *Apier) SetAccountActions(attrs AttrSetAccountActions, reply *string) error {
|
||||
func (self *ApierV1) SetAccountActions(attrs AttrSetAccountActions, reply *string) error {
|
||||
if missing := utils.MissingStructFields(&attrs, []string{"TPid", "AccountActionsId"}); len(missing) != 0 {
|
||||
return fmt.Errorf("%s:%v", utils.ERR_MANDATORY_IE_MISSING, missing)
|
||||
}
|
||||
@@ -267,6 +279,6 @@ func (self *Apier) SetAccountActions(attrs AttrSetAccountActions, reply *string)
|
||||
self.Sched.LoadActionTimings(self.DataDb)
|
||||
self.Sched.Restart()
|
||||
}
|
||||
*reply = "OK"
|
||||
*reply = OK
|
||||
return nil
|
||||
}
|
||||
@@ -30,7 +30,7 @@ type AttrGetTPIds struct {
|
||||
}
|
||||
|
||||
// Queries tarrif plan identities gathered from all tables.
|
||||
func (self *Apier) GetTPIds(attrs AttrGetTPIds, reply *[]string) error {
|
||||
func (self *ApierV1) GetTPIds(attrs AttrGetTPIds, reply *[]string) error {
|
||||
if ids, err := self.StorDb.GetTPIds(); err != nil {
|
||||
return fmt.Errorf("%s:%s", utils.ERR_SERVER_ERROR, err.Error())
|
||||
} else if ids == nil {
|
||||
@@ -26,7 +26,7 @@ import (
|
||||
)
|
||||
|
||||
// Creates a new AccountActions profile within a tariff plan
|
||||
func (self *Apier) SetTPAccountActions(attrs utils.ApiTPAccountActions, reply *string) error {
|
||||
func (self *ApierV1) SetTPAccountActions(attrs utils.ApiTPAccountActions, reply *string) error {
|
||||
if missing := utils.MissingStructFields(&attrs,
|
||||
[]string{"TPid", "AccountActionsId", "Tenant", "Account", "Direction", "ActionTimingsId", "ActionTriggersId"}); len(missing) != 0 {
|
||||
return fmt.Errorf("%s:%v", utils.ERR_MANDATORY_IE_MISSING, missing)
|
||||
@@ -54,7 +54,7 @@ type AttrGetTPAccountActions struct {
|
||||
}
|
||||
|
||||
// Queries specific AccountActions profile on tariff plan
|
||||
func (self *Apier) GetTPAccountActions(attrs AttrGetTPAccountActions, reply *utils.ApiTPAccountActions) error {
|
||||
func (self *ApierV1) GetTPAccountActions(attrs AttrGetTPAccountActions, reply *utils.ApiTPAccountActions) error {
|
||||
if missing := utils.MissingStructFields(&attrs, []string{"TPid", "AccountActionsId"}); len(missing) != 0 { //Params missing
|
||||
return fmt.Errorf("%s:%v", utils.ERR_MANDATORY_IE_MISSING, missing)
|
||||
}
|
||||
@@ -79,7 +79,7 @@ type AttrGetTPAccountActionIds struct {
|
||||
}
|
||||
|
||||
// Queries AccountActions identities on specific tariff plan.
|
||||
func (self *Apier) GetTPAccountActionIds(attrs AttrGetTPAccountActionIds, reply *[]string) error {
|
||||
func (self *ApierV1) GetTPAccountActionIds(attrs AttrGetTPAccountActionIds, reply *[]string) error {
|
||||
if missing := utils.MissingStructFields(&attrs, []string{"TPid"}); len(missing) != 0 { //Params missing
|
||||
return fmt.Errorf("%s:%v", utils.ERR_MANDATORY_IE_MISSING, missing)
|
||||
}
|
||||
@@ -26,7 +26,7 @@ import (
|
||||
)
|
||||
|
||||
// Creates a new Actions profile within a tariff plan
|
||||
func (self *Apier) SetTPActions(attrs utils.TPActions, reply *string) error {
|
||||
func (self *ApierV1) SetTPActions(attrs utils.TPActions, reply *string) error {
|
||||
if missing := utils.MissingStructFields(&attrs, []string{"TPid", "ActionsId", "Actions"}); len(missing) != 0 {
|
||||
return fmt.Errorf("%s:%v", utils.ERR_MANDATORY_IE_MISSING, missing)
|
||||
}
|
||||
@@ -72,7 +72,7 @@ type AttrGetTPActions struct {
|
||||
}
|
||||
|
||||
// Queries specific Actions profile on tariff plan
|
||||
func (self *Apier) GetTPActions(attrs AttrGetTPActions, reply *utils.TPActions) error {
|
||||
func (self *ApierV1) GetTPActions(attrs AttrGetTPActions, reply *utils.TPActions) error {
|
||||
if missing := utils.MissingStructFields(&attrs, []string{"TPid", "ActionsId"}); len(missing) != 0 { //Params missing
|
||||
return fmt.Errorf("%s:%v", utils.ERR_MANDATORY_IE_MISSING, missing)
|
||||
}
|
||||
@@ -91,7 +91,7 @@ type AttrGetTPActionIds struct {
|
||||
}
|
||||
|
||||
// Queries Actions identities on specific tariff plan.
|
||||
func (self *Apier) GetTPActionIds(attrs AttrGetTPActionIds, reply *[]string) error {
|
||||
func (self *ApierV1) GetTPActionIds(attrs AttrGetTPActionIds, reply *[]string) error {
|
||||
if missing := utils.MissingStructFields(&attrs, []string{"TPid"}); len(missing) != 0 { //Params missing
|
||||
return fmt.Errorf("%s:%v", utils.ERR_MANDATORY_IE_MISSING, missing)
|
||||
}
|
||||
@@ -26,7 +26,7 @@ import (
|
||||
)
|
||||
|
||||
// Creates a new ActionTimings profile within a tariff plan
|
||||
func (self *Apier) SetTPActionTimings(attrs utils.ApiTPActionTimings, reply *string) error {
|
||||
func (self *ApierV1) SetTPActionTimings(attrs utils.ApiTPActionTimings, reply *string) error {
|
||||
if missing := utils.MissingStructFields(&attrs, []string{"TPid", "ActionTimingsId", "ActionTimings"}); len(missing) != 0 {
|
||||
return fmt.Errorf("%s:%v", utils.ERR_MANDATORY_IE_MISSING, missing)
|
||||
}
|
||||
@@ -63,7 +63,7 @@ type AttrGetTPActionTimings struct {
|
||||
}
|
||||
|
||||
// Queries specific ActionTimings profile on tariff plan
|
||||
func (self *Apier) GetTPActionTimings(attrs AttrGetTPActionTimings, reply *utils.ApiTPActionTimings) error {
|
||||
func (self *ApierV1) GetTPActionTimings(attrs AttrGetTPActionTimings, reply *utils.ApiTPActionTimings) error {
|
||||
if missing := utils.MissingStructFields(&attrs, []string{"TPid", "ActionTimingsId"}); len(missing) != 0 { //Params missing
|
||||
return fmt.Errorf("%s:%v", utils.ERR_MANDATORY_IE_MISSING, missing)
|
||||
}
|
||||
@@ -86,7 +86,7 @@ type AttrGetTPActionTimingIds struct {
|
||||
}
|
||||
|
||||
// Queries ActionTimings identities on specific tariff plan.
|
||||
func (self *Apier) GetTPActionTimingIds(attrs AttrGetTPActionTimingIds, reply *[]string) error {
|
||||
func (self *ApierV1) GetTPActionTimingIds(attrs AttrGetTPActionTimingIds, reply *[]string) error {
|
||||
if missing := utils.MissingStructFields(&attrs, []string{"TPid"}); len(missing) != 0 { //Params missing
|
||||
return fmt.Errorf("%s:%v", utils.ERR_MANDATORY_IE_MISSING, missing)
|
||||
}
|
||||
@@ -26,7 +26,7 @@ import (
|
||||
)
|
||||
|
||||
// Creates a new ActionTriggers profile within a tariff plan
|
||||
func (self *Apier) SetTPActionTriggers(attrs utils.ApiTPActionTriggers, reply *string) error {
|
||||
func (self *ApierV1) SetTPActionTriggers(attrs utils.ApiTPActionTriggers, reply *string) error {
|
||||
if missing := utils.MissingStructFields(&attrs,
|
||||
[]string{"TPid", "ActionTriggersId"}); len(missing) != 0 {
|
||||
return fmt.Errorf("%s:%v", utils.ERR_MANDATORY_IE_MISSING, missing)
|
||||
@@ -70,7 +70,7 @@ type AttrGetTPActionTriggers struct {
|
||||
}
|
||||
|
||||
// Queries specific ActionTriggers profile on tariff plan
|
||||
func (self *Apier) GetTPActionTriggers(attrs AttrGetTPActionTriggers, reply *utils.ApiTPActionTriggers) error {
|
||||
func (self *ApierV1) GetTPActionTriggers(attrs AttrGetTPActionTriggers, reply *utils.ApiTPActionTriggers) error {
|
||||
if missing := utils.MissingStructFields(&attrs, []string{"TPid", "ActionTriggersId"}); len(missing) != 0 { //Params missing
|
||||
return fmt.Errorf("%s:%v", utils.ERR_MANDATORY_IE_MISSING, missing)
|
||||
}
|
||||
@@ -103,7 +103,7 @@ type AttrGetTPActionTriggerIds struct {
|
||||
}
|
||||
|
||||
// Queries ActionTriggers identities on specific tariff plan.
|
||||
func (self *Apier) GetTPActionTriggerIds(attrs AttrGetTPActionTriggerIds, reply *[]string) error {
|
||||
func (self *ApierV1) GetTPActionTriggerIds(attrs AttrGetTPActionTriggerIds, reply *[]string) error {
|
||||
if missing := utils.MissingStructFields(&attrs, []string{"TPid"}); len(missing) != 0 { //Params missing
|
||||
return fmt.Errorf("%s:%v", utils.ERR_MANDATORY_IE_MISSING, missing)
|
||||
}
|
||||
@@ -28,7 +28,7 @@ import (
|
||||
)
|
||||
|
||||
// Creates a new DestinationRate profile within a tariff plan
|
||||
func (self *Apier) SetTPDestinationRate(attrs utils.TPDestinationRate, reply *string) error {
|
||||
func (self *ApierV1) SetTPDestinationRate(attrs utils.TPDestinationRate, reply *string) error {
|
||||
if missing := utils.MissingStructFields(&attrs, []string{"TPid", "DestinationRateId", "DestinationRates"}); len(missing) != 0 {
|
||||
return fmt.Errorf("%s:%v", utils.ERR_MANDATORY_IE_MISSING, missing)
|
||||
}
|
||||
@@ -54,7 +54,7 @@ type AttrGetTPDestinationRate struct {
|
||||
}
|
||||
|
||||
// Queries specific DestinationRate profile on tariff plan
|
||||
func (self *Apier) GetTPDestinationRate(attrs AttrGetTPDestinationRate, reply *utils.TPDestinationRate) error {
|
||||
func (self *ApierV1) GetTPDestinationRate(attrs AttrGetTPDestinationRate, reply *utils.TPDestinationRate) error {
|
||||
if missing := utils.MissingStructFields(&attrs, []string{"TPid", "DestinationRateId"}); len(missing) != 0 { //Params missing
|
||||
return fmt.Errorf("%s:%v", utils.ERR_MANDATORY_IE_MISSING, missing)
|
||||
}
|
||||
@@ -73,7 +73,7 @@ type AttrTPDestinationRateIds struct {
|
||||
}
|
||||
|
||||
// Queries DestinationRate identities on specific tariff plan.
|
||||
func (self *Apier) GetTPDestinationRateIds(attrs AttrGetTPRateIds, reply *[]string) error {
|
||||
func (self *ApierV1) GetTPDestinationRateIds(attrs AttrGetTPRateIds, reply *[]string) error {
|
||||
if missing := utils.MissingStructFields(&attrs, []string{"TPid"}); len(missing) != 0 { //Params missing
|
||||
return fmt.Errorf("%s:%v", utils.ERR_MANDATORY_IE_MISSING, missing)
|
||||
}
|
||||
@@ -32,7 +32,7 @@ type ApierTPDestination struct {
|
||||
}
|
||||
|
||||
// Creates a new destination within a tariff plan
|
||||
func (self *Apier) SetTPDestination(attrs ApierTPDestination, reply *string) error {
|
||||
func (self *ApierV1) SetTPDestination(attrs ApierTPDestination, reply *string) error {
|
||||
if missing := utils.MissingStructFields(&attrs, []string{"TPid", "DestinationId", "Prefixes"}); len(missing) != 0 { //Params missing
|
||||
return fmt.Errorf("%s:%v", utils.ERR_MANDATORY_IE_MISSING, missing)
|
||||
}
|
||||
@@ -54,7 +54,7 @@ type AttrGetTPDestination struct {
|
||||
}
|
||||
|
||||
// Queries a specific destination
|
||||
func (self *Apier) GetTPDestination(attrs AttrGetTPDestination, reply *ApierTPDestination) error {
|
||||
func (self *ApierV1) GetTPDestination(attrs AttrGetTPDestination, reply *ApierTPDestination) error {
|
||||
if missing := utils.MissingStructFields(&attrs, []string{"TPid", "DestinationId"}); len(missing) != 0 { //Params missing
|
||||
return fmt.Errorf("%s:%v", utils.ERR_MANDATORY_IE_MISSING, missing)
|
||||
}
|
||||
@@ -73,7 +73,7 @@ type AttrGetTPDestinationIds struct {
|
||||
}
|
||||
|
||||
// Queries destination identities on specific tariff plan.
|
||||
func (self *Apier) GetTPDestinationIds(attrs AttrGetTPDestinationIds, reply *[]string) error {
|
||||
func (self *ApierV1) GetTPDestinationIds(attrs AttrGetTPDestinationIds, reply *[]string) error {
|
||||
if missing := utils.MissingStructFields(&attrs, []string{"TPid"}); len(missing) != 0 { //Params missing
|
||||
return fmt.Errorf("%s:%v", utils.ERR_MANDATORY_IE_MISSING, missing)
|
||||
}
|
||||
@@ -28,7 +28,7 @@ import (
|
||||
)
|
||||
|
||||
// Creates a new DestinationRateTiming profile within a tariff plan
|
||||
func (self *Apier) SetTPDestRateTiming(attrs utils.TPDestRateTiming, reply *string) error {
|
||||
func (self *ApierV1) SetTPDestRateTiming(attrs utils.TPDestRateTiming, reply *string) error {
|
||||
if missing := utils.MissingStructFields(&attrs, []string{"TPid", "DestRateTimingId", "DestRateTimings"}); len(missing) != 0 {
|
||||
return fmt.Errorf("%s:%v", utils.ERR_MANDATORY_IE_MISSING, missing)
|
||||
}
|
||||
@@ -58,7 +58,7 @@ type AttrGetTPDestRateTiming struct {
|
||||
}
|
||||
|
||||
// Queries specific DestRateTiming profile on tariff plan
|
||||
func (self *Apier) GetTPDestRateTiming(attrs AttrGetTPDestRateTiming, reply *utils.TPDestRateTiming) error {
|
||||
func (self *ApierV1) GetTPDestRateTiming(attrs AttrGetTPDestRateTiming, reply *utils.TPDestRateTiming) error {
|
||||
if missing := utils.MissingStructFields(&attrs, []string{"TPid", "DestRateTimingId"}); len(missing) != 0 { //Params missing
|
||||
return fmt.Errorf("%s:%v", utils.ERR_MANDATORY_IE_MISSING, missing)
|
||||
}
|
||||
@@ -77,7 +77,7 @@ type AttrTPDestRateTimingIds struct {
|
||||
}
|
||||
|
||||
// Queries DestRateTiming identities on specific tariff plan.
|
||||
func (self *Apier) GetTPDestRateTimingIds(attrs AttrGetTPRateIds, reply *[]string) error {
|
||||
func (self *ApierV1) GetTPDestRateTimingIds(attrs AttrGetTPRateIds, reply *[]string) error {
|
||||
if missing := utils.MissingStructFields(&attrs, []string{"TPid"}); len(missing) != 0 { //Params missing
|
||||
return fmt.Errorf("%s:%v", utils.ERR_MANDATORY_IE_MISSING, missing)
|
||||
}
|
||||
@@ -28,7 +28,7 @@ import (
|
||||
)
|
||||
|
||||
// Creates a new rate within a tariff plan
|
||||
func (self *Apier) SetTPRate(attrs utils.TPRate, reply *string) error {
|
||||
func (self *ApierV1) SetTPRate(attrs utils.TPRate, reply *string) error {
|
||||
if missing := utils.MissingStructFields(&attrs, []string{"TPid", "RateId", "RateSlots"}); len(missing) != 0 {
|
||||
return fmt.Errorf("%s:%v", utils.ERR_MANDATORY_IE_MISSING, missing)
|
||||
}
|
||||
@@ -55,7 +55,7 @@ type AttrGetTPRate struct {
|
||||
}
|
||||
|
||||
// Queries specific Rate on tariff plan
|
||||
func (self *Apier) GetTPRate(attrs AttrGetTPRate, reply *utils.TPRate) error {
|
||||
func (self *ApierV1) GetTPRate(attrs AttrGetTPRate, reply *utils.TPRate) error {
|
||||
if missing := utils.MissingStructFields(&attrs, []string{"TPid", "RateId"}); len(missing) != 0 { //Params missing
|
||||
return fmt.Errorf("%s:%v", utils.ERR_MANDATORY_IE_MISSING, missing)
|
||||
}
|
||||
@@ -74,7 +74,7 @@ type AttrGetTPRateIds struct {
|
||||
}
|
||||
|
||||
// Queries rate identities on specific tariff plan.
|
||||
func (self *Apier) GetTPRateIds(attrs AttrGetTPRateIds, reply *[]string) error {
|
||||
func (self *ApierV1) GetTPRateIds(attrs AttrGetTPRateIds, reply *[]string) error {
|
||||
if missing := utils.MissingStructFields(&attrs, []string{"TPid"}); len(missing) != 0 { //Params missing
|
||||
return fmt.Errorf("%s:%v", utils.ERR_MANDATORY_IE_MISSING, missing)
|
||||
}
|
||||
@@ -28,7 +28,7 @@ import (
|
||||
)
|
||||
|
||||
// Creates a new RatingProfile within a tariff plan
|
||||
func (self *Apier) SetTPRatingProfile(attrs utils.TPRatingProfile, reply *string) error {
|
||||
func (self *ApierV1) SetTPRatingProfile(attrs utils.TPRatingProfile, reply *string) error {
|
||||
if missing := utils.MissingStructFields(&attrs, []string{"TPid", "RatingProfileId", "Tenant", "TOR", "Direction", "Subject", "RatingActivations"}); len(missing) != 0 {
|
||||
return fmt.Errorf("%s:%v", utils.ERR_MANDATORY_IE_MISSING, missing)
|
||||
}
|
||||
@@ -62,7 +62,7 @@ type AttrGetTPRatingProfile struct {
|
||||
}
|
||||
|
||||
// Queries specific RatingProfile on tariff plan
|
||||
func (self *Apier) GetTPRatingProfile(attrs AttrGetTPRatingProfile, reply *utils.TPRatingProfile) error {
|
||||
func (self *ApierV1) GetTPRatingProfile(attrs AttrGetTPRatingProfile, reply *utils.TPRatingProfile) error {
|
||||
if missing := utils.MissingStructFields(&attrs, []string{"TPid", "RatingProfileId"}); len(missing) != 0 { //Params missing
|
||||
return fmt.Errorf("%s:%v", utils.ERR_MANDATORY_IE_MISSING, missing)
|
||||
}
|
||||
@@ -77,7 +77,7 @@ func (self *Apier) GetTPRatingProfile(attrs AttrGetTPRatingProfile, reply *utils
|
||||
}
|
||||
|
||||
// Queries RatingProfile identities on specific tariff plan.
|
||||
func (self *Apier) GetTPRatingProfileIds(attrs utils.AttrTPRatingProfileIds, reply *[]string) error {
|
||||
func (self *ApierV1) GetTPRatingProfileIds(attrs utils.AttrTPRatingProfileIds, reply *[]string) error {
|
||||
if missing := utils.MissingStructFields(&attrs, []string{"TPid"}); len(missing) != 0 { //Params missing
|
||||
return fmt.Errorf("%s:%v", utils.ERR_MANDATORY_IE_MISSING, missing)
|
||||
}
|
||||
@@ -36,7 +36,7 @@ type ApierTPTiming struct {
|
||||
}
|
||||
|
||||
// Creates a new timing within a tariff plan
|
||||
func (self *Apier) SetTPTiming(attrs ApierTPTiming, reply *string) error {
|
||||
func (self *ApierV1) SetTPTiming(attrs ApierTPTiming, reply *string) error {
|
||||
if missing := utils.MissingStructFields(&attrs, []string{"TPid", "TimingId", "Years", "Months", "MonthDays", "WeekDays", "Time"}); len(missing) != 0 {
|
||||
return fmt.Errorf("%s:%v", utils.ERR_MANDATORY_IE_MISSING, missing)
|
||||
}
|
||||
@@ -59,7 +59,7 @@ type AttrGetTPTiming struct {
|
||||
}
|
||||
|
||||
// Queries specific Timing on Tariff plan
|
||||
func (self *Apier) GetTPTiming(attrs AttrGetTPTiming, reply *ApierTPTiming) error {
|
||||
func (self *ApierV1) GetTPTiming(attrs AttrGetTPTiming, reply *ApierTPTiming) error {
|
||||
if missing := utils.MissingStructFields(&attrs, []string{"TPid", "TimingId"}); len(missing) != 0 { //Params missing
|
||||
return fmt.Errorf("%s:%v", utils.ERR_MANDATORY_IE_MISSING, missing)
|
||||
}
|
||||
@@ -79,7 +79,7 @@ type AttrGetTPTimingIds struct {
|
||||
}
|
||||
|
||||
// Queries timing identities on specific tariff plan.
|
||||
func (self *Apier) GetTPTimingIds(attrs AttrGetTPTimingIds, reply *[]string) error {
|
||||
func (self *ApierV1) GetTPTimingIds(attrs AttrGetTPTimingIds, reply *[]string) error {
|
||||
if missing := utils.MissingStructFields(&attrs, []string{"TPid"}); len(missing) != 0 { //Params missing
|
||||
return fmt.Errorf("%s:%v", utils.ERR_MANDATORY_IE_MISSING, missing)
|
||||
}
|
||||
@@ -19,6 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"flag"
|
||||
"fmt"
|
||||
"github.com/cgrates/cgrates/console"
|
||||
@@ -32,7 +33,7 @@ import (
|
||||
var (
|
||||
version = flag.Bool("version", false, "Prints the application version.")
|
||||
server = flag.String("server", "127.0.0.1:2012", "server address host:port")
|
||||
rpc_encoding = flag.String("rpc_encoding", "gob", "RPC encoding used <gob|json>")
|
||||
rpc_encoding = flag.String("rpc_encoding", "json", "RPC encoding used <gob|json>")
|
||||
)
|
||||
|
||||
func main() {
|
||||
@@ -61,7 +62,9 @@ func main() {
|
||||
}
|
||||
res := cmd.RpcResult()
|
||||
if rpcErr := client.Call(cmd.RpcMethod(), cmd.RpcParams(), res); rpcErr != nil {
|
||||
fmt.Println("Error executing command: " + rpcErr.Error())
|
||||
}
|
||||
fmt.Println("Result:", res)
|
||||
result, _ := json.Marshal(res)
|
||||
fmt.Println(string(result))
|
||||
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ import (
|
||||
"errors"
|
||||
"flag"
|
||||
"fmt"
|
||||
"github.com/cgrates/cgrates/apier"
|
||||
"github.com/cgrates/cgrates/apier/v1"
|
||||
"github.com/cgrates/cgrates/balancer2go"
|
||||
"github.com/cgrates/cgrates/cdrs"
|
||||
"github.com/cgrates/cgrates/config"
|
||||
@@ -64,7 +64,7 @@ var (
|
||||
err error
|
||||
)
|
||||
|
||||
func listenToRPCRequests(rpcResponder interface{}, apier *apier.Apier, rpcAddress string, rpc_encoding string, getter engine.DataStorage, loggerDb engine.DataStorage) {
|
||||
func listenToRPCRequests(rpcResponder interface{}, apier *apier.ApierV1, rpcAddress string, rpc_encoding string, getter engine.DataStorage, loggerDb engine.DataStorage) {
|
||||
l, err := net.Listen("tcp", rpcAddress)
|
||||
if err != nil {
|
||||
engine.Logger.Crit(fmt.Sprintf("<Rater> Could not listen to %v: %v", rpcAddress, err))
|
||||
@@ -335,7 +335,7 @@ func main() {
|
||||
go stopRaterSingnalHandler()
|
||||
}
|
||||
responder := &engine.Responder{ExitChan: exitChan}
|
||||
apier := &apier.Apier{StorDb: loggerDb, DataDb: getter}
|
||||
apier := &apier.ApierV1{StorDb: loggerDb, DataDb: getter}
|
||||
if cfg.RaterEnabled && !cfg.BalancerEnabled && cfg.RaterListen != INTERNAL {
|
||||
engine.Logger.Info(fmt.Sprintf("Starting CGRateS Rater on %s.", cfg.RaterListen))
|
||||
go listenToRPCRequests(responder, apier, cfg.RaterListen, cfg.RPCEncoding, getter, loggerDb)
|
||||
|
||||
@@ -52,10 +52,10 @@ var (
|
||||
dataPath = flag.String("path", ".", "The path containing the data files")
|
||||
version = flag.Bool("version", false, "Prints the application version.")
|
||||
verbose = flag.Bool("verbose", false, "Enable detailed verbose logging output")
|
||||
fromStorDb = flag.Bool("from-stordb", false, "Load the tariff plan from storDb to dataDb")
|
||||
toStorDb = flag.Bool("to-stordb", false, "Import the tariff plan from files to storDb")
|
||||
historyServer = flag.String("history-server", "", "The history server address:port")
|
||||
rpcEncoding = flag.String("rpc-encoding", "json", "The history server rpc encoding json|gob")
|
||||
fromStorDb = flag.Bool("from_stordb", false, "Load the tariff plan from storDb to dataDb")
|
||||
toStorDb = flag.Bool("to_stordb", false, "Import the tariff plan from files to storDb")
|
||||
historyServer = flag.String("history_server", "", "The history server address:port")
|
||||
rpcEncoding = flag.String("rpc_encoding", "json", "The history server rpc encoding json|gob")
|
||||
runId = flag.String("runid", "", "Uniquely identify an import/load, postpended to some automatic fields")
|
||||
)
|
||||
|
||||
|
||||
58
console/add_account.go
Normal file
58
console/add_account.go
Normal file
@@ -0,0 +1,58 @@
|
||||
package console
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/cgrates/cgrates/apier/v1"
|
||||
)
|
||||
|
||||
func init() {
|
||||
commands["add_account"] = &CmdAddAccount{}
|
||||
}
|
||||
|
||||
// Commander implementation
|
||||
type CmdAddAccount struct {
|
||||
rpcMethod string
|
||||
rpcParams *apier.AttrAddAccount
|
||||
rpcResult string
|
||||
}
|
||||
|
||||
// name should be exec's name
|
||||
func (self *CmdAddAccount) Usage(name string) string {
|
||||
return fmt.Sprintf("\n\tUsage: cgr-console [cfg_opts...{-h}] add_account <tenant> <account> <type=prepaid|postpaid> <actiontimingsid> [<direction>]")
|
||||
}
|
||||
|
||||
// set param defaults
|
||||
func (self *CmdAddAccount) defaults() error {
|
||||
self.rpcMethod = "ApierV1.AddAccount"
|
||||
self.rpcParams = &apier.AttrAddAccount{Direction: "*out"}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Parses command line args and builds CmdBalance value
|
||||
func (self *CmdAddAccount) FromArgs(args []string) error {
|
||||
if len(args) < 6 {
|
||||
return fmt.Errorf(self.Usage(""))
|
||||
}
|
||||
// Args look OK, set defaults before going further
|
||||
self.defaults()
|
||||
self.rpcParams.Tenant = args[2]
|
||||
self.rpcParams.Account = args[3]
|
||||
self.rpcParams.Type = args[4]
|
||||
self.rpcParams.ActionTimingsId = args[5]
|
||||
if len(args) > 6 {
|
||||
self.rpcParams.Direction = args[6]
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *CmdAddAccount) RpcMethod() string {
|
||||
return self.rpcMethod
|
||||
}
|
||||
|
||||
func (self *CmdAddAccount) RpcParams() interface{} {
|
||||
return self.rpcParams
|
||||
}
|
||||
|
||||
func (self *CmdAddAccount) RpcResult() interface{} {
|
||||
return &self.rpcResult
|
||||
}
|
||||
67
console/add_balance.go
Normal file
67
console/add_balance.go
Normal file
@@ -0,0 +1,67 @@
|
||||
package console
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/cgrates/cgrates/apier/v1"
|
||||
"github.com/cgrates/cgrates/engine"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
func init() {
|
||||
commands["add_balance"] = &CmdAddBalance{}
|
||||
}
|
||||
|
||||
// Commander implementation
|
||||
type CmdAddBalance struct {
|
||||
rpcMethod string
|
||||
rpcParams *apier.AttrAddBalance
|
||||
rpcResult string
|
||||
}
|
||||
|
||||
// name should be exec's name
|
||||
func (self *CmdAddBalance) Usage(name string) string {
|
||||
return fmt.Sprintf("\n\tUsage: cgr-console [cfg_opts...{-h}] add_balance <tenant> <account> <value> [<balanceid=monetary|sms|internet|internet_time|minutes> [<direction>]]")
|
||||
}
|
||||
|
||||
// set param defaults
|
||||
func (self *CmdAddBalance) defaults() error {
|
||||
self.rpcMethod = "ApierV1.AddBalance"
|
||||
self.rpcParams = &apier.AttrAddBalance{BalanceId: engine.CREDIT}
|
||||
self.rpcParams.Direction = "*out"
|
||||
return nil
|
||||
}
|
||||
|
||||
// Parses command line args and builds CmdBalance value
|
||||
func (self *CmdAddBalance) FromArgs(args []string) error {
|
||||
if len(args) < 5 {
|
||||
return fmt.Errorf(self.Usage(""))
|
||||
}
|
||||
// Args look OK, set defaults before going further
|
||||
self.defaults()
|
||||
self.rpcParams.Tenant = args[2]
|
||||
self.rpcParams.Account = args[3]
|
||||
value, err := strconv.ParseFloat(args[4], 64)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
self.rpcParams.Value = value
|
||||
if len(args) > 5 {
|
||||
self.rpcParams.BalanceId = args[5]
|
||||
}
|
||||
if len(args) > 6 {
|
||||
self.rpcParams.Direction = args[6]
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *CmdAddBalance) RpcMethod() string {
|
||||
return self.rpcMethod
|
||||
}
|
||||
|
||||
func (self *CmdAddBalance) RpcParams() interface{} {
|
||||
return self.rpcParams
|
||||
}
|
||||
|
||||
func (self *CmdAddBalance) RpcResult() interface{} {
|
||||
return &self.rpcResult
|
||||
}
|
||||
71
console/add_triggeredaction.go
Normal file
71
console/add_triggeredaction.go
Normal file
@@ -0,0 +1,71 @@
|
||||
package console
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/cgrates/cgrates/apier/v1"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
func init() {
|
||||
commands["add_triggeredaction"] = &CmdAddTriggeredAction{}
|
||||
}
|
||||
|
||||
// Commander implementation
|
||||
type CmdAddTriggeredAction struct {
|
||||
rpcMethod string
|
||||
rpcParams *apier.AttrAddActionTrigger
|
||||
rpcResult string
|
||||
}
|
||||
|
||||
// name should be exec's name
|
||||
func (self *CmdAddTriggeredAction) Usage(name string) string {
|
||||
return fmt.Sprintf("\n\tUsage: cgr-console [cfg_opts...{-h}] add_triggeredaction <tenant> <account> <balanceid> <thresholdvalue> <destinationid> <weight> <actionsid> [<direction>]")
|
||||
}
|
||||
|
||||
// set param defaults
|
||||
func (self *CmdAddTriggeredAction) defaults() error {
|
||||
self.rpcMethod = "ApierV1.AddTriggeredAction"
|
||||
self.rpcParams = &apier.AttrAddActionTrigger{Direction: "*out"}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Parses command line args and builds CmdBalance value
|
||||
func (self *CmdAddTriggeredAction) FromArgs(args []string) error {
|
||||
if len(args) < 9 {
|
||||
return fmt.Errorf(self.Usage(""))
|
||||
}
|
||||
// Args look OK, set defaults before going further
|
||||
self.defaults()
|
||||
self.rpcParams.Tenant = args[2]
|
||||
self.rpcParams.Account = args[3]
|
||||
self.rpcParams.BalanceId = args[4]
|
||||
thresholdvalue, err := strconv.ParseFloat(args[5], 64)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
self.rpcParams.ThresholdValue = thresholdvalue
|
||||
self.rpcParams.DestinationId = args[6]
|
||||
weight, err := strconv.ParseFloat(args[7], 64)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
self.rpcParams.Weight = weight
|
||||
self.rpcParams.ActionsId = args[8]
|
||||
|
||||
if len(args) > 9 {
|
||||
self.rpcParams.Direction = args[9]
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *CmdAddTriggeredAction) RpcMethod() string {
|
||||
return self.rpcMethod
|
||||
}
|
||||
|
||||
func (self *CmdAddTriggeredAction) RpcParams() interface{} {
|
||||
return self.rpcParams
|
||||
}
|
||||
|
||||
func (self *CmdAddTriggeredAction) RpcResult() interface{} {
|
||||
return &self.rpcResult
|
||||
}
|
||||
@@ -2,6 +2,8 @@ package console
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -25,7 +27,11 @@ func GetCommandValue(args []string) (Commander, error) {
|
||||
}
|
||||
cmdVal, exists := commands[args[1]]
|
||||
if !exists {
|
||||
return nil, errors.New("\n\tUsage: cgr-console [cfg_opts...{-h}] <status|get_balance>\n")
|
||||
var keys []string
|
||||
for key, _ := range commands {
|
||||
keys = append(keys, key)
|
||||
}
|
||||
return nil, fmt.Errorf("\n\tUsage: cgr-console [cfg_opts...{-h}] <%s>\n", strings.Join(keys, "|"))
|
||||
}
|
||||
if err := cmdVal.FromArgs(args); err != nil {
|
||||
return nil, err
|
||||
|
||||
53
console/destination.go
Normal file
53
console/destination.go
Normal file
@@ -0,0 +1,53 @@
|
||||
package console
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/cgrates/cgrates/apier/v1"
|
||||
)
|
||||
|
||||
func init() {
|
||||
commands["get_destination"] = &CmdGetDestination{}
|
||||
}
|
||||
|
||||
// Commander implementation
|
||||
type CmdGetDestination struct {
|
||||
rpcMethod string
|
||||
rpcParams *apier.AttrDestination
|
||||
rpcResult *apier.AttrDestination
|
||||
}
|
||||
|
||||
// name should be exec's name
|
||||
func (self *CmdGetDestination) Usage(name string) string {
|
||||
return fmt.Sprintf("\n\tUsage: cgr-console [cfg_opts...{-h}] get_destination <id>")
|
||||
}
|
||||
|
||||
// set param defaults
|
||||
func (self *CmdGetDestination) defaults() error {
|
||||
self.rpcMethod = "Apier.GetDestination"
|
||||
self.rpcParams = &apier.AttrDestination{}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Parses command line args and builds CmdBalance value
|
||||
func (self *CmdGetDestination) FromArgs(args []string) error {
|
||||
if len(args) < 3 {
|
||||
return fmt.Errorf(self.Usage(""))
|
||||
}
|
||||
// Args look OK, set defaults before going further
|
||||
self.defaults()
|
||||
self.rpcParams.Id = args[2]
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *CmdGetDestination) RpcMethod() string {
|
||||
return self.rpcMethod
|
||||
}
|
||||
|
||||
func (self *CmdGetDestination) RpcParams() interface{} {
|
||||
return self.rpcParams
|
||||
}
|
||||
|
||||
func (self *CmdGetDestination) RpcResult() interface{} {
|
||||
self.rpcResult = &apier.AttrDestination{}
|
||||
return self.rpcResult
|
||||
}
|
||||
57
console/execute_action.go
Normal file
57
console/execute_action.go
Normal file
@@ -0,0 +1,57 @@
|
||||
package console
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/cgrates/cgrates/apier/v1"
|
||||
)
|
||||
|
||||
func init() {
|
||||
commands["execute_action"] = &CmdExecuteAction{}
|
||||
}
|
||||
|
||||
// Commander implementation
|
||||
type CmdExecuteAction struct {
|
||||
rpcMethod string
|
||||
rpcParams *apier.AttrExecuteAction
|
||||
rpcResult string
|
||||
}
|
||||
|
||||
// name should be exec's name
|
||||
func (self *CmdExecuteAction) Usage(name string) string {
|
||||
return fmt.Sprintf("\n\tUsage: cgr-console [cfg_opts...{-h}] execute_action <tenant> <account> <actionsid> [<direction>]")
|
||||
}
|
||||
|
||||
// set param defaults
|
||||
func (self *CmdExecuteAction) defaults() error {
|
||||
self.rpcMethod = "ApierV1.ExecuteAction"
|
||||
self.rpcParams = &apier.AttrExecuteAction{Direction: "*out"}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Parses command line args and builds CmdBalance value
|
||||
func (self *CmdExecuteAction) FromArgs(args []string) error {
|
||||
if len(args) < 5 {
|
||||
return fmt.Errorf(self.Usage(""))
|
||||
}
|
||||
// Args look OK, set defaults before going further
|
||||
self.defaults()
|
||||
self.rpcParams.Tenant = args[2]
|
||||
self.rpcParams.Account = args[3]
|
||||
self.rpcParams.ActionsId = args[4]
|
||||
if len(args) > 5 {
|
||||
self.rpcParams.Direction = args[5]
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *CmdExecuteAction) RpcMethod() string {
|
||||
return self.rpcMethod
|
||||
}
|
||||
|
||||
func (self *CmdExecuteAction) RpcParams() interface{} {
|
||||
return self.rpcParams
|
||||
}
|
||||
|
||||
func (self *CmdExecuteAction) RpcResult() interface{} {
|
||||
return &self.rpcResult
|
||||
}
|
||||
@@ -1,9 +1,8 @@
|
||||
/* Implementing balance related console commands.
|
||||
*/
|
||||
package console
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/cgrates/cgrates/apier/v1"
|
||||
"github.com/cgrates/cgrates/engine"
|
||||
)
|
||||
|
||||
@@ -14,19 +13,20 @@ func init() {
|
||||
// Commander implementation
|
||||
type CmdGetBalance struct {
|
||||
rpcMethod string
|
||||
rpcParams *engine.CallDescriptor
|
||||
rpcResult *engine.CallCost
|
||||
rpcParams *apier.AttrGetBalance
|
||||
rpcResult float64
|
||||
}
|
||||
|
||||
// name should be exec's name
|
||||
func (self *CmdGetBalance) Usage(name string) string {
|
||||
return fmt.Sprintf("\n\tUsage: cgr-console [cfg_opts...{-h}] get_balance <tenant> <user> [<balanceid> [<direction>]]")
|
||||
return fmt.Sprintf("\n\tUsage: cgr-console [cfg_opts...{-h}] get_balance <tenant> <account> [<balanceid=monetary|sms|internet|internet_time|minutes> [<direction>]]")
|
||||
}
|
||||
|
||||
// set param defaults
|
||||
func (self *CmdGetBalance) defaults() error {
|
||||
self.rpcMethod = "Responder.GetMonetary"
|
||||
self.rpcParams = &engine.CallDescriptor{Direction: "*out"}
|
||||
self.rpcMethod = "ApierV1.GetBalance"
|
||||
self.rpcParams = &apier.AttrGetBalance{BalanceId: engine.CREDIT}
|
||||
self.rpcParams.Direction = "*out"
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -35,25 +35,15 @@ func (self *CmdGetBalance) FromArgs(args []string) error {
|
||||
if len(args) < 4 {
|
||||
return fmt.Errorf(self.Usage(""))
|
||||
}
|
||||
// Args look OK, set defaults before going further
|
||||
// Args look OK, set defaults before going further
|
||||
self.defaults()
|
||||
self.rpcParams.Tenant = args[2]
|
||||
self.rpcParams.Account = args[3]
|
||||
if len(args) > 4 {
|
||||
switch args[4] {
|
||||
case "MONETARY":
|
||||
self.rpcMethod = "Responder.GetMonetary"
|
||||
case "SMS":
|
||||
self.rpcMethod = "Responder.GetSMS"
|
||||
case "INETRNET":
|
||||
self.rpcMethod = "Responder.GetInternet"
|
||||
case "INTERNET_TIME":
|
||||
self.rpcMethod = "Responder.GetInternetTime"
|
||||
case "MINUTES":
|
||||
self.rpcMethod = "Responder.GetMonetary"
|
||||
}
|
||||
self.rpcParams.BalanceId = args[4]
|
||||
}
|
||||
if len(args) > 5 {
|
||||
|
||||
self.rpcParams.Direction = args[5]
|
||||
}
|
||||
return nil
|
||||
@@ -68,6 +58,5 @@ func (self *CmdGetBalance) RpcParams() interface{} {
|
||||
}
|
||||
|
||||
func (self *CmdGetBalance) RpcResult() interface{} {
|
||||
self.rpcResult = &engine.CallCost{}
|
||||
return self.rpcResult
|
||||
return &self.rpcResult
|
||||
}
|
||||
53
console/set_accountactions.go
Normal file
53
console/set_accountactions.go
Normal file
@@ -0,0 +1,53 @@
|
||||
package console
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/cgrates/cgrates/apier/v1"
|
||||
)
|
||||
|
||||
func init() {
|
||||
commands["set_accountactions"] = &CmdSetAccountActions{}
|
||||
}
|
||||
|
||||
// Commander implementation
|
||||
type CmdSetAccountActions struct {
|
||||
rpcMethod string
|
||||
rpcParams *apier.AttrSetAccountActions
|
||||
rpcResult string
|
||||
}
|
||||
|
||||
// name should be exec's name
|
||||
func (self *CmdSetAccountActions) Usage(name string) string {
|
||||
return fmt.Sprintf("\n\tUsage: cgr-console [cfg_opts...{-h}] set_accountactions <tpid> <accountactionsid>")
|
||||
}
|
||||
|
||||
// set param defaults
|
||||
func (self *CmdSetAccountActions) defaults() error {
|
||||
self.rpcMethod = "ApierV1.SetAccountActions"
|
||||
self.rpcParams = &apier.AttrSetAccountActions{}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Parses command line args and builds CmdBalance value
|
||||
func (self *CmdSetAccountActions) FromArgs(args []string) error {
|
||||
if len(args) < 3 {
|
||||
return fmt.Errorf(self.Usage(""))
|
||||
}
|
||||
// Args look OK, set defaults before going further
|
||||
self.defaults()
|
||||
self.rpcParams.TPid = args[2]
|
||||
self.rpcParams.AccountActionsId = args[3]
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *CmdSetAccountActions) RpcMethod() string {
|
||||
return self.rpcMethod
|
||||
}
|
||||
|
||||
func (self *CmdSetAccountActions) RpcParams() interface{} {
|
||||
return self.rpcParams
|
||||
}
|
||||
|
||||
func (self *CmdSetAccountActions) RpcResult() interface{} {
|
||||
return &self.rpcResult
|
||||
}
|
||||
53
console/set_ratingprofile.go
Normal file
53
console/set_ratingprofile.go
Normal file
@@ -0,0 +1,53 @@
|
||||
package console
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/cgrates/cgrates/apier/v1"
|
||||
)
|
||||
|
||||
func init() {
|
||||
commands["set_ratingprofile"] = &CmdSetrRatingProfile{}
|
||||
}
|
||||
|
||||
// Commander implementation
|
||||
type CmdSetrRatingProfile struct {
|
||||
rpcMethod string
|
||||
rpcParams *apier.AttrSetRatingProfile
|
||||
rpcResult string
|
||||
}
|
||||
|
||||
// name should be exec's name
|
||||
func (self *CmdSetrRatingProfile) Usage(name string) string {
|
||||
return fmt.Sprintf("\n\tUsage: cgr-console [cfg_opts...{-h}] set_ratingprofile <tpid> <rateprofileid>")
|
||||
}
|
||||
|
||||
// set param defaults
|
||||
func (self *CmdSetrRatingProfile) defaults() error {
|
||||
self.rpcMethod = "ApierV1.SetRatingProfile"
|
||||
self.rpcParams = &apier.AttrSetRatingProfile{}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Parses command line args and builds CmdBalance value
|
||||
func (self *CmdSetrRatingProfile) FromArgs(args []string) error {
|
||||
if len(args) < 3 {
|
||||
return fmt.Errorf(self.Usage(""))
|
||||
}
|
||||
// Args look OK, set defaults before going further
|
||||
self.defaults()
|
||||
self.rpcParams.TPid = args[2]
|
||||
self.rpcParams.RateProfileId = args[3]
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *CmdSetrRatingProfile) RpcMethod() string {
|
||||
return self.rpcMethod
|
||||
}
|
||||
|
||||
func (self *CmdSetrRatingProfile) RpcParams() interface{} {
|
||||
return self.rpcParams
|
||||
}
|
||||
|
||||
func (self *CmdSetrRatingProfile) RpcResult() interface{} {
|
||||
return &self.rpcResult
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
Apier.SetAccountActions
|
||||
ApierV1.SetAccountActions
|
||||
+++++++++++++++++++++++
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ Process dependencies and load a specific AccountActions profile from storDb into
|
||||
|
||||
{
|
||||
"id": 0,
|
||||
"method": "Apier.SetAccountActions",
|
||||
"method": "ApierV1.SetAccountActions",
|
||||
"params": [
|
||||
{
|
||||
"AccountActionsId": "SAMPLE_AA_1",
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
Apier.SetRatingProfile
|
||||
ApierV1.SetRatingProfile
|
||||
++++++++++++++++++++++
|
||||
|
||||
Process dependencies and load a specific rating profile from storDb into dataDb.
|
||||
@@ -20,7 +20,7 @@ Process dependencies and load a specific rating profile from storDb into dataDb.
|
||||
|
||||
{
|
||||
"id": 0,
|
||||
"method": "Apier.SetRatingProfile",
|
||||
"method": "ApierV1.SetRatingProfile",
|
||||
"params": [
|
||||
{
|
||||
"RateProfileId": "RPF_SAMPLE_1",
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
Apier.GetTPIds
|
||||
ApierV1.GetTPIds
|
||||
+++++++++++++++++++++++++
|
||||
|
||||
// Queries tarrif plan identities gathered from all tables.
|
||||
@@ -16,7 +16,7 @@ Apier.GetTPIds
|
||||
|
||||
{
|
||||
"id": 9,
|
||||
"method": "Apier.GetTPIds",
|
||||
"method": "ApierV1.GetTPIds",
|
||||
"params": []
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
Apier.SetTPAccountActions
|
||||
ApierV1.SetTPAccountActions
|
||||
+++++++++++++++++++++++++
|
||||
|
||||
Creates a new AccountActions profile within a tariff plan.
|
||||
@@ -25,7 +25,7 @@ Creates a new AccountActions profile within a tariff plan.
|
||||
|
||||
{
|
||||
"id": 2,
|
||||
"method": "Apier.SetTPAccountActions",
|
||||
"method": "ApierV1.SetTPAccountActions",
|
||||
"params": [
|
||||
{
|
||||
"Account": "ACNT1",
|
||||
@@ -67,7 +67,7 @@ Creates a new AccountActions profile within a tariff plan.
|
||||
``DUPLICATE`` - The specified combination of TPid/AccountActionsId already present in StorDb.
|
||||
|
||||
|
||||
Apier.GetTPAccountActions
|
||||
ApierV1.GetTPAccountActions
|
||||
+++++++++++++++++++++++++
|
||||
|
||||
Queries specific AccountActions profile on tariff plan.
|
||||
@@ -89,7 +89,7 @@ Queries specific AccountActions profile on tariff plan.
|
||||
|
||||
{
|
||||
"id": 3,
|
||||
"method": "Apier.GetTPAccountActions",
|
||||
"method": "ApierV1.GetTPAccountActions",
|
||||
"params": [
|
||||
{
|
||||
"AccountActionsId": "AA_SAMPLE_2",
|
||||
@@ -139,7 +139,7 @@ Queries specific AccountActions profile on tariff plan.
|
||||
``NOT_FOUND`` - Requested AccountActions profile not found.
|
||||
|
||||
|
||||
Apier.GetTPAccountActionIds
|
||||
ApierV1.GetTPAccountActionIds
|
||||
+++++++++++++++++++++++++++
|
||||
|
||||
Queries AccountActions identities on specific tariff plan.
|
||||
@@ -160,7 +160,7 @@ Queries AccountActions identities on specific tariff plan.
|
||||
|
||||
{
|
||||
"id": 4,
|
||||
"method": "Apier.GetTPAccountActionIds",
|
||||
"method": "ApierV1.GetTPAccountActionIds",
|
||||
"params": [
|
||||
{
|
||||
"TPid": "SAMPLE_TP_1"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
Apier.SetTPActions
|
||||
ApierV1.SetTPActions
|
||||
++++++++++++++++++
|
||||
|
||||
Creates a new Actions profile within a tariff plan.
|
||||
@@ -34,7 +34,7 @@ Creates a new Actions profile within a tariff plan.
|
||||
|
||||
{
|
||||
"id": 3,
|
||||
"method": "Apier.SetTPActions",
|
||||
"method": "ApierV1.SetTPActions",
|
||||
"params": [
|
||||
{
|
||||
"Actions": [
|
||||
@@ -85,7 +85,7 @@ Creates a new Actions profile within a tariff plan.
|
||||
``DUPLICATE`` - The specified combination of TPid/ActionsId already present in StorDb.
|
||||
|
||||
|
||||
Apier.GetTPActions
|
||||
ApierV1.GetTPActions
|
||||
++++++++++++++++++
|
||||
|
||||
Queries specific Actions profile on tariff plan.
|
||||
@@ -107,7 +107,7 @@ Queries specific Actions profile on tariff plan.
|
||||
|
||||
{
|
||||
"id": 5,
|
||||
"method": "Apier.GetTPActions",
|
||||
"method": "ApierV1.GetTPActions",
|
||||
"params": [
|
||||
{
|
||||
"ActionsId": "SAMPLE_ACTS_1",
|
||||
@@ -175,7 +175,7 @@ Queries specific Actions profile on tariff plan.
|
||||
``NOT_FOUND`` - Requested Actions profile not found.
|
||||
|
||||
|
||||
Apier.GetTPActionIds
|
||||
ApierV1.GetTPActionIds
|
||||
++++++++++++++++++++
|
||||
|
||||
Queries Actions identities on specific tariff plan.
|
||||
@@ -196,7 +196,7 @@ Queries Actions identities on specific tariff plan.
|
||||
|
||||
{
|
||||
"id": 6,
|
||||
"method": "Apier.GetTPActionIds",
|
||||
"method": "ApierV1.GetTPActionIds",
|
||||
"params": [
|
||||
{
|
||||
"TPid": "SAMPLE_TP_1"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
Apier.SetTPActionTimings
|
||||
ApierV1.SetTPActionTimings
|
||||
++++++++++++++++++++++++
|
||||
|
||||
Creates a new ActionTimings profile within a tariff plan.
|
||||
@@ -27,7 +27,7 @@ Creates a new ActionTimings profile within a tariff plan.
|
||||
|
||||
{
|
||||
"id": 7,
|
||||
"method": "Apier.SetTPActionTimings",
|
||||
"method": "ApierV1.SetTPActionTimings",
|
||||
"params": [
|
||||
{
|
||||
"ActionTimings": [
|
||||
@@ -76,7 +76,7 @@ Creates a new ActionTimings profile within a tariff plan.
|
||||
``DUPLICATE`` - The specified combination of TPid/ActionTimingsId already present in StorDb.
|
||||
|
||||
|
||||
Apier.GetTPActionTimings
|
||||
ApierV1.GetTPActionTimings
|
||||
++++++++++++++++++++++++
|
||||
|
||||
Queries specific ActionTimings profile on tariff plan.
|
||||
@@ -98,7 +98,7 @@ Queries specific ActionTimings profile on tariff plan.
|
||||
|
||||
{
|
||||
"id": 8,
|
||||
"method": "Apier.GetTPActionTimings",
|
||||
"method": "ApierV1.GetTPActionTimings",
|
||||
"params": [
|
||||
{
|
||||
"ActionTimingsId": "SAMPLE_AT3",
|
||||
@@ -157,7 +157,7 @@ Queries specific ActionTimings profile on tariff plan.
|
||||
``NOT_FOUND`` - Requested ActionTimings profile not found.
|
||||
|
||||
|
||||
Apier.GetTPActionTimingIds
|
||||
ApierV1.GetTPActionTimingIds
|
||||
++++++++++++++++++++++++++
|
||||
|
||||
Queries ActionTimings identities on specific tariff plan.
|
||||
@@ -178,7 +178,7 @@ Queries ActionTimings identities on specific tariff plan.
|
||||
|
||||
{
|
||||
"id": 9,
|
||||
"method": "Apier.GetTPActionTimingIds",
|
||||
"method": "ApierV1.GetTPActionTimingIds",
|
||||
"params": [
|
||||
{
|
||||
"TPid": "SAMPLE_TP_1"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
Apier.SetTPActionTriggers
|
||||
ApierV1.SetTPActionTriggers
|
||||
+++++++++++++++++++++++++
|
||||
|
||||
Creates a new ActionTriggers profile within a tariff plan.
|
||||
@@ -32,7 +32,7 @@ Creates a new ActionTriggers profile within a tariff plan.
|
||||
|
||||
{
|
||||
"id": 2,
|
||||
"method": "Apier.SetTPActionTriggers",
|
||||
"method": "ApierV1.SetTPActionTriggers",
|
||||
"params": [
|
||||
{
|
||||
"ActionTriggers": [
|
||||
@@ -80,7 +80,7 @@ Creates a new ActionTriggers profile within a tariff plan.
|
||||
``DUPLICATE`` - The specified combination of TPid/ActionTriggersId already present in StorDb.
|
||||
|
||||
|
||||
Apier.GetTPActionTriggers
|
||||
ApierV1.GetTPActionTriggers
|
||||
+++++++++++++++++++++++++
|
||||
|
||||
Queries specific ActionTriggers profile on tariff plan.
|
||||
@@ -102,7 +102,7 @@ Queries specific ActionTriggers profile on tariff plan.
|
||||
|
||||
{
|
||||
"id": 0,
|
||||
"method": "Apier.GetTPActionTriggers",
|
||||
"method": "ApierV1.GetTPActionTriggers",
|
||||
"params": [
|
||||
{
|
||||
"ActionTriggersId": "SAMPLE_ATS_1",
|
||||
@@ -165,7 +165,7 @@ Queries specific ActionTriggers profile on tariff plan.
|
||||
``NOT_FOUND`` - Requested ActionTriggersId profile not found.
|
||||
|
||||
|
||||
Apier.GetTPActionTriggerIds
|
||||
ApierV1.GetTPActionTriggerIds
|
||||
+++++++++++++++++++++++++++
|
||||
|
||||
Queries ActionTriggers identities on specific tariff plan.
|
||||
@@ -186,7 +186,7 @@ Queries ActionTriggers identities on specific tariff plan.
|
||||
|
||||
{
|
||||
"id": 5,
|
||||
"method": "Apier.GetTPActionTriggerIds",
|
||||
"method": "ApierV1.GetTPActionTriggerIds",
|
||||
"params": [
|
||||
{
|
||||
"TPid": "SAMPLE_TP_2"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
Apier.SetTPDestinationRate
|
||||
ApierV1.SetTPDestinationRate
|
||||
++++++++++++++++++++++++++
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ Creates a new DestinationRate profile within a tariff plan.
|
||||
|
||||
{
|
||||
"id": 2,
|
||||
"method": "Apier.SetTPDestinationRate",
|
||||
"method": "ApierV1.SetTPDestinationRate",
|
||||
"params": [
|
||||
{
|
||||
"DestinationRateId": "DST_RATE_1",
|
||||
@@ -78,7 +78,7 @@ Creates a new DestinationRate profile within a tariff plan.
|
||||
``DUPLICATE`` - The specified combination of TPid/DestinationRateId already exists in StorDb.
|
||||
|
||||
|
||||
Apier.GetTPDestinationRate
|
||||
ApierV1.GetTPDestinationRate
|
||||
+++++++++++++++
|
||||
|
||||
Queries specific DestinationRate profile on tariff plan.
|
||||
@@ -100,7 +100,7 @@ Queries specific DestinationRate profile on tariff plan.
|
||||
|
||||
{
|
||||
"id": 2,
|
||||
"method": "Apier.GetTPDestinationRate",
|
||||
"method": "ApierV1.GetTPDestinationRate",
|
||||
"params": [
|
||||
{
|
||||
"DestinationRateId": "DST_RATE_1",
|
||||
@@ -161,7 +161,7 @@ Queries specific DestinationRate profile on tariff plan.
|
||||
``NOT_FOUND`` - Requested DestinationRate id not found.
|
||||
|
||||
|
||||
Apier.GetTPDestinationRateIds
|
||||
ApierV1.GetTPDestinationRateIds
|
||||
+++++++++++++++++++++++++++++
|
||||
|
||||
Queries DestinationRate identities on specific tariff plan.
|
||||
@@ -182,7 +182,7 @@ Queries DestinationRate identities on specific tariff plan.
|
||||
|
||||
{
|
||||
"id": 3,
|
||||
"method": "Apier.GetTPDestinationRateIds",
|
||||
"method": "ApierV1.GetTPDestinationRateIds",
|
||||
"params": [
|
||||
{
|
||||
"TPid": "FIST_TP"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
Apier.SetTPDestination
|
||||
ApierV1.SetTPDestination
|
||||
++++++++++++++++++++++
|
||||
|
||||
Creates a new destination within a tariff plan id.
|
||||
@@ -21,7 +21,7 @@ Creates a new destination within a tariff plan id.
|
||||
|
||||
{
|
||||
"id": 2,
|
||||
"method": "Apier.SetTPDestination",
|
||||
"method": "ApierV1.SetTPDestination",
|
||||
"params": [
|
||||
{
|
||||
"DestinationId": "FIST_DST2",
|
||||
@@ -62,7 +62,7 @@ Creates a new destination within a tariff plan id.
|
||||
``DUPLICATE`` - The specified combination of TPid/DestinationId already exists in StorDb.
|
||||
|
||||
|
||||
Apier.GetTPDestination
|
||||
ApierV1.GetTPDestination
|
||||
++++++++++++++++++++++
|
||||
|
||||
Queries a specific destination.
|
||||
@@ -84,7 +84,7 @@ Queries a specific destination.
|
||||
|
||||
{
|
||||
"id": 0,
|
||||
"method": "Apier.GetTPDestination",
|
||||
"method": "ApierV1.GetTPDestination",
|
||||
"params": [
|
||||
{
|
||||
"DestinationId": "FIRST_DST2",
|
||||
@@ -130,7 +130,7 @@ Queries a specific destination.
|
||||
``NOT_FOUND`` - Requested destination id not found.
|
||||
|
||||
|
||||
Apier.GetTPDestinationIds
|
||||
ApierV1.GetTPDestinationIds
|
||||
+++++++++++++++++++++++++
|
||||
|
||||
Queries destination identities on specific tariff plan.
|
||||
@@ -151,7 +151,7 @@ Queries destination identities on specific tariff plan.
|
||||
|
||||
{
|
||||
"id": 1,
|
||||
"method": "Apier.GetTPDestinationIds",
|
||||
"method": "ApierV1.GetTPDestinationIds",
|
||||
"params": [
|
||||
{
|
||||
"TPid": "FIST_TP"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
Apier.SetTPDestRateTiming
|
||||
ApierV1.SetTPDestRateTiming
|
||||
+++++++++++++++++++++++++
|
||||
|
||||
Creates a new DestinationRateTiming profile within a tariff plan.
|
||||
@@ -27,7 +27,7 @@ Creates a new DestinationRateTiming profile within a tariff plan.
|
||||
|
||||
{
|
||||
"id": 0,
|
||||
"method": "Apier.SetTPDestRateTiming",
|
||||
"method": "ApierV1.SetTPDestRateTiming",
|
||||
"params": [
|
||||
{
|
||||
"DestRateTimingId": "SAMPLE_DRTIMING_1",
|
||||
@@ -71,7 +71,7 @@ Creates a new DestinationRateTiming profile within a tariff plan.
|
||||
``DUPLICATE`` - The specified combination of TPid/DestRateTimingId already exists in StorDb.
|
||||
|
||||
|
||||
Apier.GetTPDestRateTiming
|
||||
ApierV1.GetTPDestRateTiming
|
||||
+++++++++++++++++++++++++
|
||||
|
||||
Queries specific DestRateTiming profile on tariff plan.
|
||||
@@ -93,7 +93,7 @@ Queries specific DestRateTiming profile on tariff plan.
|
||||
|
||||
{
|
||||
"id": 4,
|
||||
"method": "Apier.GetTPDestRateTiming",
|
||||
"method": "ApierV1.GetTPDestRateTiming",
|
||||
"params": [
|
||||
{
|
||||
"DestRateTimingId": "SAMPLE_DRTIMING_1",
|
||||
@@ -147,7 +147,7 @@ Queries specific DestRateTiming profile on tariff plan.
|
||||
``NOT_FOUND`` - Requested DestRateTiming profile not found.
|
||||
|
||||
|
||||
Apier.GetTPDestRateTimingIds
|
||||
ApierV1.GetTPDestRateTimingIds
|
||||
++++++++++++++++++++++++++++
|
||||
|
||||
Queries DestRateTiming identities on specific tariff plan.
|
||||
@@ -168,7 +168,7 @@ Queries DestRateTiming identities on specific tariff plan.
|
||||
|
||||
{
|
||||
"id": 5,
|
||||
"method": "Apier.GetTPDestRateTimingIds",
|
||||
"method": "ApierV1.GetTPDestRateTimingIds",
|
||||
"params": [
|
||||
{
|
||||
"TPid": "SAMPLE_TP"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
Apier.SetTPRate
|
||||
ApierV1.SetTPRate
|
||||
+++++++++++++++
|
||||
|
||||
Creates a new rate within a tariff plan.
|
||||
@@ -32,7 +32,7 @@ Creates a new rate within a tariff plan.
|
||||
|
||||
{
|
||||
"id": 1,
|
||||
"method": "Apier.SetTPRate",
|
||||
"method": "ApierV1.SetTPRate",
|
||||
"params": [
|
||||
{
|
||||
"RateId": "SAMPLE_RATE_2",
|
||||
@@ -91,7 +91,7 @@ Creates a new rate within a tariff plan.
|
||||
``DUPLICATE`` - The specified combination of TPid/RateId already exists in StorDb.
|
||||
|
||||
|
||||
Apier.GetTPRate
|
||||
ApierV1.GetTPRate
|
||||
+++++++++++++++
|
||||
|
||||
Queries specific rate on tariff plan.
|
||||
@@ -113,7 +113,7 @@ Queries specific rate on tariff plan.
|
||||
|
||||
{
|
||||
"id": 1,
|
||||
"method": "Apier.GetTPRate",
|
||||
"method": "ApierV1.GetTPRate",
|
||||
"params": [
|
||||
{
|
||||
"RateId": "SAMPLE_RATE_4",
|
||||
@@ -187,7 +187,7 @@ Queries specific rate on tariff plan.
|
||||
``NOT_FOUND`` - Requested rate id not found.
|
||||
|
||||
|
||||
Apier.GetTPRateIds
|
||||
ApierV1.GetTPRateIds
|
||||
++++++++++++++++++
|
||||
|
||||
Queries rate identities on tariff plan.
|
||||
@@ -208,7 +208,7 @@ Queries rate identities on tariff plan.
|
||||
|
||||
{
|
||||
"id": 1,
|
||||
"method": "Apier.GetTPRateIds",
|
||||
"method": "ApierV1.GetTPRateIds",
|
||||
"params": [
|
||||
{
|
||||
"TPid": "SAMPLE_TP"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
Apier.SetTPRatingProfile
|
||||
ApierV1.SetTPRatingProfile
|
||||
++++++++++++++++++++++++
|
||||
|
||||
Creates a new RatingProfile within a tariff plan.
|
||||
@@ -31,7 +31,7 @@ Creates a new RatingProfile within a tariff plan.
|
||||
|
||||
{
|
||||
"id": 3,
|
||||
"method": "Apier.SetTPRatingProfile",
|
||||
"method": "ApierV1.SetTPRatingProfile",
|
||||
"params": [
|
||||
{
|
||||
"Direction": "*out",
|
||||
@@ -82,7 +82,7 @@ Creates a new RatingProfile within a tariff plan.
|
||||
``DUPLICATE`` - The specified combination of TPid/RatingProfileId already exists in StorDb.
|
||||
|
||||
|
||||
Apier.GetTPRatingProfile
|
||||
ApierV1.GetTPRatingProfile
|
||||
++++++++++++++++++++++++
|
||||
|
||||
Queries specific RatingProfile on tariff plan.
|
||||
@@ -104,7 +104,7 @@ Queries specific RatingProfile on tariff plan.
|
||||
|
||||
{
|
||||
"id": 0,
|
||||
"method": "Apier.GetTPRatingProfile",
|
||||
"method": "ApierV1.GetTPRatingProfile",
|
||||
"params": [
|
||||
{
|
||||
"RatingProfileId": "SAMPLE_RP_2",
|
||||
@@ -170,7 +170,7 @@ Queries specific RatingProfile on tariff plan.
|
||||
``NOT_FOUND`` - Requested RatingProfile profile not found.
|
||||
|
||||
|
||||
Apier.GetTPRatingProfileIds
|
||||
ApierV1.GetTPRatingProfileIds
|
||||
+++++++++++++++++++++++++++
|
||||
|
||||
Queries specific RatingProfile on tariff plan. Attribute parameters used as extra filters.
|
||||
@@ -195,7 +195,7 @@ Queries specific RatingProfile on tariff plan. Attribute parameters used as extr
|
||||
|
||||
{
|
||||
"id": 0,
|
||||
"method": "Apier.GetTPRatingProfileIds",
|
||||
"method": "ApierV1.GetTPRatingProfileIds",
|
||||
"params": [
|
||||
{
|
||||
"Subject": "dan",
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
Apier.SetTPTiming
|
||||
ApierV1.SetTPTiming
|
||||
+++++++++++++++++
|
||||
|
||||
Creates a new timing within a tariff plan.
|
||||
@@ -25,7 +25,7 @@ Creates a new timing within a tariff plan.
|
||||
|
||||
{
|
||||
"id": 3,
|
||||
"method": "Apier.SetTPTiming",
|
||||
"method": "ApierV1.SetTPTiming",
|
||||
"params": [
|
||||
{
|
||||
"MonthDays": "1;2;3;31",
|
||||
@@ -67,7 +67,7 @@ Creates a new timing within a tariff plan.
|
||||
``DUPLICATE`` - The specified combination of TPid/TimingId already exists in StorDb.
|
||||
|
||||
|
||||
Apier.GetTPTiming
|
||||
ApierV1.GetTPTiming
|
||||
+++++++++++++++++
|
||||
|
||||
Queries specific Timing on tariff plan.
|
||||
@@ -89,7 +89,7 @@ Queries specific Timing on tariff plan.
|
||||
|
||||
{
|
||||
"id": 4,
|
||||
"method": "Apier.GetTPTiming",
|
||||
"method": "ApierV1.GetTPTiming",
|
||||
"params": [
|
||||
{
|
||||
"TPid": "SAMPLE_TP",
|
||||
@@ -139,7 +139,7 @@ Queries specific Timing on tariff plan.
|
||||
``NOT_FOUND`` - Requested timing id not found.
|
||||
|
||||
|
||||
Apier.GetTPTimingIds
|
||||
ApierV1.GetTPTimingIds
|
||||
+++++++++++++++++++++++++
|
||||
|
||||
Queries timing identities on tariff plan.
|
||||
@@ -160,7 +160,7 @@ Queries timing identities on tariff plan.
|
||||
|
||||
{
|
||||
"id": 5,
|
||||
"method": "Apier.GetTPTimingIds",
|
||||
"method": "ApierV1.GetTPTimingIds",
|
||||
"params": [
|
||||
{
|
||||
"TPid": "SAMPLE_TP"
|
||||
|
||||
@@ -312,7 +312,7 @@ AddTriggeredAction
|
||||
|
||||
::
|
||||
|
||||
type AttrActionTrigger struct {
|
||||
type AttrAddActionTrigger struct {
|
||||
Tenant string
|
||||
Account string
|
||||
Direction string
|
||||
@@ -324,14 +324,14 @@ AddTriggeredAction
|
||||
}
|
||||
|
||||
Example
|
||||
AddTriggeredAction(attr \*AttrActionTrigger, reply \*float64)
|
||||
AddTriggeredAction(attr \*AttrAddActionTrigger, reply \*float64)
|
||||
|
||||
AddAcount
|
||||
+++++++++
|
||||
|
||||
::
|
||||
|
||||
type AttrAccount struct {
|
||||
type AttrAddAccount struct {
|
||||
Tenant string
|
||||
Direction string
|
||||
Account string
|
||||
@@ -340,7 +340,7 @@ AddAcount
|
||||
}
|
||||
|
||||
Example
|
||||
AddAccount(attr \*AttrAccount, reply \*float64)
|
||||
AddAccount(attr \*AttrAddAccount, reply \*float64)
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -221,6 +221,7 @@ func (at *ActionTiming) Execute() (err error) {
|
||||
ub, err := storageGetter.GetUserBalance(ubId)
|
||||
if err != nil {
|
||||
Logger.Warning(fmt.Sprintf("Could not get user balances for this id: %s. Skipping!", ubId))
|
||||
return 0, err
|
||||
}
|
||||
|
||||
Logger.Info(fmt.Sprintf("Executing %v on %v", a.ActionType, ub.Id))
|
||||
|
||||
@@ -37,7 +37,7 @@ const (
|
||||
)
|
||||
|
||||
type FileScribe struct {
|
||||
mu sync.RWMutex
|
||||
mu sync.Mutex
|
||||
fileRoot string
|
||||
gitCommand string
|
||||
destinations records
|
||||
@@ -65,8 +65,6 @@ func NewFileScribe(fileRoot string) (*FileScribe, error) {
|
||||
}
|
||||
|
||||
func (s *FileScribe) Record(rec *Record, out *int) error {
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
var fileToSave string
|
||||
switch {
|
||||
case strings.HasPrefix(rec.Key, DESTINATION_PREFIX):
|
||||
@@ -104,6 +102,8 @@ func (s *FileScribe) Record(rec *Record, out *int) error {
|
||||
}
|
||||
|
||||
func (s *FileScribe) gitInit() error {
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
if _, err := os.Stat(s.fileRoot); os.IsNotExist(err) {
|
||||
if err := os.MkdirAll(s.fileRoot, os.ModeDir|0755); err != nil {
|
||||
return errors.New("<History> Error creating history folder: " + err.Error())
|
||||
@@ -144,6 +144,8 @@ func (s *FileScribe) gitCommit() error {
|
||||
}
|
||||
|
||||
func (s *FileScribe) load(filename string) error {
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
f, err := os.Open(filepath.Join(s.fileRoot, filename))
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -167,6 +169,8 @@ func (s *FileScribe) load(filename string) error {
|
||||
}
|
||||
|
||||
func (s *FileScribe) save(filename string) error {
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
f, err := os.Create(filepath.Join(s.fileRoot, filename))
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -28,7 +28,7 @@ import (
|
||||
)
|
||||
|
||||
type MockScribe struct {
|
||||
sync.RWMutex
|
||||
sync.Mutex
|
||||
destinations records
|
||||
ratingProfiles records
|
||||
DestBuf bytes.Buffer
|
||||
@@ -40,8 +40,6 @@ func NewMockScribe() (*MockScribe, error) {
|
||||
}
|
||||
|
||||
func (s *MockScribe) Record(rec *Record, out *int) error {
|
||||
s.Lock()
|
||||
defer s.Unlock()
|
||||
switch {
|
||||
case strings.HasPrefix(rec.Key, DESTINATION_PREFIX):
|
||||
s.destinations = s.destinations.SetOrAdd(&Record{rec.Key[len(DESTINATION_PREFIX):], rec.Object})
|
||||
@@ -55,6 +53,8 @@ func (s *MockScribe) Record(rec *Record, out *int) error {
|
||||
}
|
||||
|
||||
func (s *MockScribe) save(filename string) error {
|
||||
s.Lock()
|
||||
defer s.Unlock()
|
||||
switch filename {
|
||||
case DESTINATIONS_FILE:
|
||||
s.DestBuf.Reset()
|
||||
|
||||
@@ -202,7 +202,7 @@ func (self *Mediator) getCostsFromRater(cdr utils.CDR) (*engine.CallCost, error)
|
||||
// If the mediator calculated a price it will write it to logdb
|
||||
self.storDb.LogCallCost(cdr.GetCgrId(), engine.MEDIATOR_SOURCE, cc)
|
||||
}
|
||||
return cc, nil
|
||||
return cc, err
|
||||
}
|
||||
|
||||
// Parse the files and get cost for every record
|
||||
|
||||
Reference in New Issue
Block a user