From d22727782e08c2821c36ac3d19f6daaf71737044 Mon Sep 17 00:00:00 2001 From: ionutboangiu Date: Tue, 3 Jun 2025 17:03:46 +0300 Subject: [PATCH] change IP API methods from plural to singular --- ips/apis.go | 18 +++++++++--------- ips/ips_it_test.go | 12 ++++++------ sessions/apis.go | 6 +++--- sessions/sessions.go | 2 +- utils/consts.go | 6 +++--- 5 files changed, 22 insertions(+), 22 deletions(-) diff --git a/ips/apis.go b/ips/apis.go index 2d63757a6..591a307f4 100644 --- a/ips/apis.go +++ b/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) diff --git a/ips/ips_it_test.go b/ips/ips_it_test.go index 96ed1542e..821fb7575 100644 --- a/ips/ips_it_test.go +++ b/ips/ips_it_test.go @@ -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", }, diff --git a/sessions/apis.go b/sessions/apis.go index 2645cfc59..cedd190c0 100644 --- a/sessions/apis.go +++ b/sessions/apis.go @@ -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.", diff --git a/sessions/sessions.go b/sessions/sessions.go index eaa4b6da0..96b851541 100644 --- a/sessions/sessions.go +++ b/sessions/sessions.go @@ -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", diff --git a/utils/consts.go b/utils/consts.go index b011f74a7..6ae3a77bc 100644 --- a/utils/consts.go +++ b/utils/consts.go @@ -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"