Delete unused opt retrieval functions

This commit is contained in:
ionutboangiu
2021-10-06 12:59:13 +03:00
committed by Dan Christian Bogos
parent 1e7ff42468
commit 37e8f358b7
4 changed files with 0 additions and 451 deletions

View File

@@ -26,27 +26,6 @@ import (
"github.com/ericlagergren/decimal"
)
// FilterFloat64CfgOpts returns the option as float64 if the filters match
func FilterFloat64CfgOpts(ctx *context.Context, tnt string, ev utils.DataProvider, fS *FilterS, dynOpts []*utils.DynamicFloat64Opt) (dft float64, err error) {
var hasDefault bool
for _, opt := range dynOpts { // iterate through the options
if len(opt.FilterIDs) == 1 && opt.FilterIDs[0] == utils.MetaDefault {
hasDefault = true
dft = opt.Value
continue
}
if pass, err := fS.Pass(ctx, tnt, opt.FilterIDs, ev); err != nil { // check if the filter is passing for the DataProvider and return the option if it does
return 0, err
} else if pass {
return opt.Value, nil
}
}
if !hasDefault {
err = utils.ErrNotFound
}
return // return the option or NOT_FOUND if there are no options or none of the filters pass
}
// GetFloat64Opts checks the specified option names in order among the keys in APIOpts returning the first value it finds as float64, otherwise it
// returns the config option if at least one filter passes or NOT_FOUND if none of them do
func GetFloat64Opts(ctx *context.Context, tnt string, ev *utils.CGREvent, fS *FilterS, dynOpts []*utils.DynamicFloat64Opt,
@@ -76,27 +55,6 @@ func GetFloat64Opts(ctx *context.Context, tnt string, ev *utils.CGREvent, fS *Fi
return // return the option or NOT_FOUND if there are no options or none of the filters pass
}
// FilterDurationCfgOpts returns the option as time.Duration if the filters match
func FilterDurationCfgOpts(ctx *context.Context, tnt string, ev utils.DataProvider, fS *FilterS, dynOpts []*utils.DynamicDurationOpt) (dft time.Duration, err error) {
var hasDefault bool
for _, opt := range dynOpts { // iterate through the options
if len(opt.FilterIDs) == 1 && opt.FilterIDs[0] == utils.MetaDefault {
hasDefault = true
dft = opt.Value
continue
}
if pass, err := fS.Pass(ctx, tnt, opt.FilterIDs, ev); err != nil { // check if the filter is passing for the DataProvider and return the option if it does
return 0, err
} else if pass {
return opt.Value, nil
}
}
if !hasDefault {
err = utils.ErrNotFound
}
return // return the option or NOT_FOUND if there are no options or none of the filters pass
}
// GetDurationOpts checks the specified option names in order among the keys in APIOpts returning the first value it finds as time.Duration, otherwise it
// returns the config option if at least one filter passes or NOT_FOUND if none of them do
func GetDurationOpts(ctx *context.Context, tnt string, ev *utils.CGREvent, fS *FilterS, dynOpts []*utils.DynamicDurationOpt,
@@ -126,27 +84,6 @@ func GetDurationOpts(ctx *context.Context, tnt string, ev *utils.CGREvent, fS *F
return // return the option or NOT_FOUND if there are no options or none of the filters pass
}
// FilterStringCfgOpts returns the option as string if the filters match
func FilterStringCfgOpts(ctx *context.Context, tnt string, ev utils.DataProvider, fS *FilterS, dynOpts []*utils.DynamicStringOpt) (dft string, err error) {
var hasDefault bool
for _, opt := range dynOpts { // iterate through the options
if len(opt.FilterIDs) == 1 && opt.FilterIDs[0] == utils.MetaDefault {
hasDefault = true
dft = opt.Value
continue
}
if pass, err := fS.Pass(ctx, tnt, opt.FilterIDs, ev); err != nil { // check if the filter is passing for the DataProvider and return the option if it does
return utils.EmptyString, err
} else if pass {
return opt.Value, nil
}
}
if !hasDefault {
err = utils.ErrNotFound
}
return // return the option or NOT_FOUND if there are no options or none of the filters pass
}
// GetStringOpts checks the specified option names in order among the keys in APIOpts returning the first value it finds as string, otherwise it
// returns the config option if at least one filter passes or NOT_FOUND if none of them do
func GetStringOpts(ctx *context.Context, tnt string, ev *utils.CGREvent, fS *FilterS, dynOpts []*utils.DynamicStringOpt,
@@ -208,27 +145,6 @@ func GetTimeOpts(ctx *context.Context, tnt string, ev *utils.CGREvent, fS *Filte
return utils.ParseTimeDetectLayout(cfgOptStr, tmz) // return the option or NOT_FOUND if there are no options or none of the filters pass
}
// FilterStringSliceCfgOpts returns the option as []string if the filters match
func FilterStringSliceCfgOpts(ctx *context.Context, tnt string, ev utils.DataProvider, fS *FilterS, dynOpts []*utils.DynamicStringSliceOpt) (dft []string, err error) {
var hasDefault bool
for _, opt := range dynOpts { // iterate through the options
if len(opt.FilterIDs) == 1 && opt.FilterIDs[0] == utils.MetaDefault {
hasDefault = true
dft = opt.Value
continue
}
if pass, err := fS.Pass(ctx, tnt, opt.FilterIDs, ev); err != nil { // check if the filter is passing for the DataProvider and return the option if it does
return nil, err
} else if pass {
return opt.Value, nil
}
}
if !hasDefault {
err = utils.ErrNotFound
}
return // return the option or NOT_FOUND if there are no options or none of the filters pass
}
// GetStringSliceOpts checks the specified option names in order among the keys in APIOpts returning the first value it finds as []string, otherwise it
// returns the config option if at least one filter passes or NOT_FOUND if none of them do
func GetStringSliceOpts(ctx *context.Context, tnt string, ev *utils.CGREvent, fS *FilterS, dynOpts []*utils.DynamicStringSliceOpt,
@@ -258,27 +174,6 @@ func GetStringSliceOpts(ctx *context.Context, tnt string, ev *utils.CGREvent, fS
return // return the option or NOT_FOUND if there are no options or none of the filters pass
}
// FilterIntCfgOpts returns the option as int if the filters match
func FilterIntCfgOpts(ctx *context.Context, tnt string, ev utils.DataProvider, fS *FilterS, dynOpts []*utils.DynamicIntOpt) (dft int, err error) {
var hasDefault bool
for _, opt := range dynOpts { // iterate through the options
if len(opt.FilterIDs) == 1 && opt.FilterIDs[0] == utils.MetaDefault {
hasDefault = true
dft = opt.Value
continue
}
if pass, err := fS.Pass(ctx, tnt, opt.FilterIDs, ev); err != nil { // check if the filter is passing for the DataProvider and return the option if it does
return 0, err
} else if pass {
return opt.Value, nil
}
}
if !hasDefault {
err = utils.ErrNotFound
}
return // return the option or NOT_FOUND if there are no options or none of the filters pass
}
// GetIntOpts checks the specified option names in order among the keys in APIOpts returning the first value it finds as int, otherwise it
// returns the config option if at least one filter passes or NOT_FOUND if none of them do
func GetIntOpts(ctx *context.Context, tnt string, ev *utils.CGREvent, fS *FilterS, dynOpts []*utils.DynamicIntOpt,
@@ -312,27 +207,6 @@ func GetIntOpts(ctx *context.Context, tnt string, ev *utils.CGREvent, fS *Filter
return // return the option or NOT_FOUND if there are no options or none of the filters pass
}
// FilterBoolCfgOpts returns the option as bool if the filters match
func FilterBoolCfgOpts(ctx *context.Context, tnt string, ev utils.DataProvider, fS *FilterS, dynOpts []*utils.DynamicBoolOpt) (dft bool, err error) {
var hasDefault bool
for _, opt := range dynOpts { // iterate through the options
if len(opt.FilterIDs) == 1 && opt.FilterIDs[0] == utils.MetaDefault {
hasDefault = true
dft = opt.Value
continue
}
if pass, err := fS.Pass(ctx, tnt, opt.FilterIDs, ev); err != nil { // check if the filter is passing for the DataProvider and return the option if it does
return false, err
} else if pass {
return opt.Value, nil
}
}
if !hasDefault {
err = utils.ErrNotFound
}
return // return the option or NOT_FOUND if there are no options or none of the filters pass
}
// GetBoolOpts checks the specified option names in order among the keys in APIOpts returning the first value it finds as bool, otherwise it
// returns the config option if at least one filter passes or NOT_FOUND if none of them do
func GetBoolOpts(ctx *context.Context, tnt string, ev *utils.CGREvent, fS *FilterS, dynOpts []*utils.DynamicBoolOpt,
@@ -362,27 +236,6 @@ func GetBoolOpts(ctx *context.Context, tnt string, ev *utils.CGREvent, fS *Filte
return // return the option or NOT_FOUND if there are no options or none of the filters pass
}
// FilterDurationCfgOpts returns the option as time.Duration if the filters match
func FilterDecimalBigCfgOpts(ctx *context.Context, tnt string, ev utils.DataProvider, fS *FilterS, dynOpts []*utils.DynamicDecimalBigOpt) (dft *decimal.Big, err error) {
var hasDefault bool
for _, opt := range dynOpts { // iterate through the options
if len(opt.FilterIDs) == 1 && opt.FilterIDs[0] == utils.MetaDefault {
hasDefault = true
dft = opt.Value
continue
}
if pass, err := fS.Pass(ctx, tnt, opt.FilterIDs, ev); err != nil { // check if the filter is passing for the DataProvider and return the option if it does
return nil, err
} else if pass {
return opt.Value, nil
}
}
if !hasDefault {
err = utils.ErrNotFound
}
return // return the option or NOT_FOUND if there are no options or none of the filters pass
}
// GetDecimalBigOpts checks the specified option names in order among the keys in APIOpts returning the first value it finds as *decimal.Big, otherwise it
// returns the config option if at least one filter passes or NOT_FOUND if none of them do
func GetDecimalBigOpts(ctx *context.Context, tnt string, ev *utils.CGREvent, fS *FilterS, dynOpts []*utils.DynamicDecimalBigOpt,
@@ -412,27 +265,6 @@ func GetDecimalBigOpts(ctx *context.Context, tnt string, ev *utils.CGREvent, fS
return // return the option or NOT_FOUND if there are no options or none of the filters pass
}
// FilterInterfaceCfgOpts returns the option as interface{} if the filters match
func FilterInterfaceCfgOpts(ctx *context.Context, tnt string, ev utils.DataProvider, fS *FilterS, dynOpts []*utils.DynamicInterfaceOpt) (dft interface{}, err error) {
var hasDefault bool
for _, opt := range dynOpts { // iterate through the options
if len(opt.FilterIDs) == 1 && opt.FilterIDs[0] == utils.MetaDefault {
hasDefault = true
dft = opt.Value
continue
}
if pass, err := fS.Pass(ctx, tnt, opt.FilterIDs, ev); err != nil { // check if the filter is passing for the DataProvider and return the option if it does
return false, err
} else if pass {
return opt.Value, nil
}
}
if !hasDefault {
err = utils.ErrNotFound
}
return // return the option or NOT_FOUND if there are no options or none of the filters pass
}
// GetInterfaceOpts checks the specified option names in order among the keys in APIOpts returning the first value it finds as interface{}, otherwise it
// returns the config option if at least one filter passes or NOT_FOUND if none of them do
func GetInterfaceOpts(ctx *context.Context, tnt string, ev *utils.CGREvent, fS *FilterS, dynOpts []*utils.DynamicInterfaceOpt,