mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
change IP API methods from plural to singular
This commit is contained in:
committed by
Dan Christian Bogos
parent
33735613e7
commit
d22727782e
18
ips/apis.go
18
ips/apis.go
@@ -86,8 +86,8 @@ func (s *IPService) V1GetIPAllocationsForEvent(ctx *context.Context, args *utils
|
||||
return
|
||||
}
|
||||
|
||||
// V1AuthorizeIPs queries service to find if an Usage is allowed
|
||||
func (s *IPService) V1AuthorizeIPs(ctx *context.Context, args *utils.CGREvent, reply *string) (err error) {
|
||||
// V1AuthorizeIP queries service to find if an Usage is allowed
|
||||
func (s *IPService) V1AuthorizeIP(ctx *context.Context, args *utils.CGREvent, reply *string) (err error) {
|
||||
if args == nil {
|
||||
return utils.NewErrMandatoryIeMissing(utils.Event)
|
||||
}
|
||||
@@ -124,7 +124,7 @@ func (s *IPService) V1AuthorizeIPs(ctx *context.Context, args *utils.CGREvent, r
|
||||
|
||||
// RPC caching
|
||||
if config.CgrConfig().CacheCfg().Partitions[utils.CacheRPCResponses].Limit != 0 {
|
||||
cacheKey := utils.ConcatenatedKey(utils.IPsV1AuthorizeIPs, utils.ConcatenatedKey(tnt, args.ID))
|
||||
cacheKey := utils.ConcatenatedKey(utils.IPsV1AuthorizeIP, utils.ConcatenatedKey(tnt, args.ID))
|
||||
refID := guardian.Guardian.GuardIDs("",
|
||||
config.CgrConfig().GeneralCfg().LockingTimeout, cacheKey) // RPC caching needs to be atomic
|
||||
defer guardian.Guardian.UnguardIDs(refID)
|
||||
@@ -156,8 +156,8 @@ func (s *IPService) V1AuthorizeIPs(ctx *context.Context, args *utils.CGREvent, r
|
||||
return
|
||||
}
|
||||
|
||||
// V1AllocateIPs is called when an IP requires allocation.
|
||||
func (s *IPService) V1AllocateIPs(ctx *context.Context, args *utils.CGREvent, reply *string) (err error) {
|
||||
// V1AllocateIP is called when an IP requires allocation.
|
||||
func (s *IPService) V1AllocateIP(ctx *context.Context, args *utils.CGREvent, reply *string) (err error) {
|
||||
if args == nil {
|
||||
return utils.NewErrMandatoryIeMissing(utils.Event)
|
||||
}
|
||||
@@ -194,7 +194,7 @@ func (s *IPService) V1AllocateIPs(ctx *context.Context, args *utils.CGREvent, re
|
||||
|
||||
// RPC caching
|
||||
if config.CgrConfig().CacheCfg().Partitions[utils.CacheRPCResponses].Limit != 0 {
|
||||
cacheKey := utils.ConcatenatedKey(utils.IPsV1AllocateIPs, utils.ConcatenatedKey(tnt, args.ID))
|
||||
cacheKey := utils.ConcatenatedKey(utils.IPsV1AllocateIP, utils.ConcatenatedKey(tnt, args.ID))
|
||||
refID := guardian.Guardian.GuardIDs("",
|
||||
config.CgrConfig().GeneralCfg().LockingTimeout, cacheKey) // RPC caching needs to be atomic
|
||||
defer guardian.Guardian.UnguardIDs(refID)
|
||||
@@ -231,8 +231,8 @@ func (s *IPService) V1AllocateIPs(ctx *context.Context, args *utils.CGREvent, re
|
||||
return
|
||||
}
|
||||
|
||||
// V1ReleaseIPs is called when we need to clear an allocation
|
||||
func (s *IPService) V1ReleaseIPs(ctx *context.Context, args *utils.CGREvent, reply *string) (err error) {
|
||||
// V1ReleaseIP is called when we need to clear an allocation
|
||||
func (s *IPService) V1ReleaseIP(ctx *context.Context, args *utils.CGREvent, reply *string) (err error) {
|
||||
if args == nil {
|
||||
return utils.NewErrMandatoryIeMissing(utils.Event)
|
||||
}
|
||||
@@ -264,7 +264,7 @@ func (s *IPService) V1ReleaseIPs(ctx *context.Context, args *utils.CGREvent, rep
|
||||
|
||||
// RPC caching
|
||||
if config.CgrConfig().CacheCfg().Partitions[utils.CacheRPCResponses].Limit != 0 {
|
||||
cacheKey := utils.ConcatenatedKey(utils.IPsV1ReleaseIPs, utils.ConcatenatedKey(tnt, args.ID))
|
||||
cacheKey := utils.ConcatenatedKey(utils.IPsV1ReleaseIP, utils.ConcatenatedKey(tnt, args.ID))
|
||||
refID := guardian.Guardian.GuardIDs("",
|
||||
config.CgrConfig().GeneralCfg().LockingTimeout, cacheKey) // RPC caching needs to be atomic
|
||||
defer guardian.Guardian.UnguardIDs(refID)
|
||||
|
||||
@@ -243,10 +243,10 @@ cgrates.org,IPs2,*string:~*req.Account:1002,;20,2s,false,POOL1,*string:~*req.Des
|
||||
}
|
||||
|
||||
var reply string
|
||||
if err := client.Call(context.Background(), utils.IPsV1AuthorizeIPs,
|
||||
if err := client.Call(context.Background(), utils.IPsV1AuthorizeIP,
|
||||
&utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "AuthorizeIPs1",
|
||||
ID: "AuthorizeIP1",
|
||||
Event: map[string]any{
|
||||
utils.AccountField: "1001",
|
||||
},
|
||||
@@ -259,10 +259,10 @@ cgrates.org,IPs2,*string:~*req.Account:1002,;20,2s,false,POOL1,*string:~*req.Des
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
if err := client.Call(context.Background(), utils.IPsV1AllocateIPs,
|
||||
if err := client.Call(context.Background(), utils.IPsV1AllocateIP,
|
||||
&utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "AllocateIPs1",
|
||||
ID: "AllocateIP1",
|
||||
Event: map[string]any{
|
||||
utils.AccountField: "1001",
|
||||
},
|
||||
@@ -275,10 +275,10 @@ cgrates.org,IPs2,*string:~*req.Account:1002,;20,2s,false,POOL1,*string:~*req.Des
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
if err := client.Call(context.Background(), utils.IPsV1ReleaseIPs,
|
||||
if err := client.Call(context.Background(), utils.IPsV1ReleaseIP,
|
||||
&utils.CGREvent{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "ReleaseIPs1",
|
||||
ID: "ReleaseIP1",
|
||||
Event: map[string]any{
|
||||
utils.AccountField: "1001",
|
||||
},
|
||||
|
||||
@@ -161,7 +161,7 @@ func (sS *SessionS) BiRPCv1AuthorizeEvent(ctx *context.Context,
|
||||
args.APIOpts[utils.OptsIPsUsageID] = originID
|
||||
args.APIOpts[utils.OptsIPsUnits] = 1
|
||||
var allocMsg string
|
||||
if err = sS.connMgr.Call(ctx, sS.cfg.SessionSCfg().IPsConns, utils.IPsV1AuthorizeIPs,
|
||||
if err = sS.connMgr.Call(ctx, sS.cfg.SessionSCfg().IPsConns, utils.IPsV1AuthorizeIP,
|
||||
args, &allocMsg); err != nil {
|
||||
return utils.NewErrIPs(err)
|
||||
}
|
||||
@@ -394,14 +394,14 @@ func (sS *SessionS) BiRPCv1InitiateSession(ctx *context.Context,
|
||||
args.APIOpts[utils.OptsIPsUnits] = 1
|
||||
var allocMessage string
|
||||
if err = sS.connMgr.Call(ctx, sS.cfg.SessionSCfg().IPsConns,
|
||||
utils.IPsV1AllocateIPs, args, &allocMessage); err != nil {
|
||||
utils.IPsV1AllocateIP, args, &allocMessage); err != nil {
|
||||
return utils.NewErrIPs(err)
|
||||
}
|
||||
rply.IPAllocation = &allocMessage
|
||||
defer func() { // we need to release the IPs back in case of errors
|
||||
if err != nil {
|
||||
var reply string
|
||||
if err = sS.connMgr.Call(ctx, sS.cfg.SessionSCfg().IPsConns, utils.IPsV1ReleaseIPs,
|
||||
if err = sS.connMgr.Call(ctx, sS.cfg.SessionSCfg().IPsConns, utils.IPsV1ReleaseIP,
|
||||
args, &reply); err != nil {
|
||||
utils.Logger.Warning(
|
||||
fmt.Sprintf("<%s> error: %s releasing IPs for event %+v.",
|
||||
|
||||
@@ -376,7 +376,7 @@ func (sS *SessionS) forceSTerminate(ctx *context.Context, s *Session, extraUsage
|
||||
args.APIOpts[utils.OptsIPsUsageID] = s.ID
|
||||
args.APIOpts[utils.OptsIPsUnits] = 1
|
||||
if err := sS.connMgr.Call(ctx, sS.cfg.SessionSCfg().IPsConns,
|
||||
utils.IPsV1ReleaseIPs,
|
||||
utils.IPsV1ReleaseIP,
|
||||
args, &reply); err != nil {
|
||||
utils.Logger.Warning(
|
||||
fmt.Sprintf("<%s> error: %s could not release IP %q",
|
||||
|
||||
@@ -1613,9 +1613,9 @@ const (
|
||||
IPsV1Ping = "IPsV1.Ping"
|
||||
IPsV1GetIPAllocations = "IPsV1.GetIPAllocations"
|
||||
IPsV1GetIPAllocationsForEvent = "IPsV1.GetIPAllocationsForEvent"
|
||||
IPsV1AuthorizeIPs = "IPsV1.AuthorizeIPs"
|
||||
IPsV1AllocateIPs = "IPsV1.AllocateIPs"
|
||||
IPsV1ReleaseIPs = "IPsV1.ReleaseIPs"
|
||||
IPsV1AuthorizeIP = "IPsV1.AuthorizeIP"
|
||||
IPsV1AllocateIP = "IPsV1.AllocateIP"
|
||||
IPsV1ReleaseIP = "IPsV1.ReleaseIP"
|
||||
AdminSv1SetIPProfile = "AdminSv1.SetIPProfile"
|
||||
AdminSv1GetIPProfiles = "AdminSv1.GetIPProfiles"
|
||||
AdminSv1RemoveIPProfile = "AdminSv1.RemoveIPProfile"
|
||||
|
||||
Reference in New Issue
Block a user