cfg: update ips opts

removed units and renamed usageID -> allocationID
This commit is contained in:
ionutboangiu
2025-11-24 21:05:04 +02:00
committed by Dan Christian Bogos
parent eab21e5d8d
commit 3889e9d91e
6 changed files with 17 additions and 34 deletions

View File

@@ -1490,9 +1490,8 @@ const CGRATES_CFG_JSON = `
"exists_indexed_fields": [], // query indexes based on these fields for faster processing
"nested_fields": false, // determines which field is checked when matching indexed filters(true: all; false: only the one on the first level)
"opts": {
"*usageID": "",
// "*ttl": "72h",
"*units": 1
"*allocationID": "",
"*ttl": "72h"
}
}

File diff suppressed because one or more lines are too long

View File

@@ -126,17 +126,16 @@ func (c IPsCfg) AsMapInterface() any {
}
type IPsOpts struct {
UsageID string
TTL *time.Duration
Units float64
AllocationID string
TTL *time.Duration
}
func (o *IPsOpts) loadFromJSONCfg(jc *IPsOptsJson) error {
if jc == nil {
return nil
}
if jc.UsageID != nil {
o.UsageID = *jc.UsageID
if jc.AllocationID != nil {
o.AllocationID = *jc.AllocationID
}
if jc.TTL != nil {
ttl, err := utils.ParseDurationWithNanosecs(*jc.TTL)
@@ -145,17 +144,13 @@ func (o *IPsOpts) loadFromJSONCfg(jc *IPsOptsJson) error {
}
o.TTL = &ttl
}
if jc.Units != nil {
o.Units = *jc.Units
}
return nil
}
// Clone returns a deep copy of IPsOpts.
func (o *IPsOpts) Clone() *IPsOpts {
cln := &IPsOpts{
UsageID: o.UsageID,
Units: o.Units,
AllocationID: o.AllocationID,
}
if o.TTL != nil {
cln.TTL = new(time.Duration)
@@ -167,8 +162,7 @@ func (o *IPsOpts) Clone() *IPsOpts {
// AsMapInterface returns the config as a map[string]any.
func (o *IPsOpts) AsMapInterface() map[string]any {
m := map[string]any{
utils.MetaUsageIDCfg: o.UsageID,
utils.MetaUnitsCfg: o.Units,
utils.MetaAllocationIDCfg: o.AllocationID,
}
if o.TTL != nil {
m[utils.MetaTTLCfg] = *o.TTL

View File

@@ -1006,9 +1006,8 @@ type CoreSJsonCfg struct {
}
type IPsOptsJson struct {
UsageID *string `json:"*usageID"`
TTL *string `json:"*ttl"`
Units *float64 `json:"*units"`
AllocationID *string `json:"*allocationID"`
TTL *string `json:"*ttl"`
}
// IPsJsonCfg holds the unparsed ips section configuration as found in the