From f9fd56d9d41b7b8e24bb86d6c82d36bb228e4f65 Mon Sep 17 00:00:00 2001 From: Pushpalatha555 Date: Tue, 7 Jun 2022 12:52:27 +0530 Subject: [PATCH] addressed the comments --- pkg/client/load_balancer.go | 40 ++++++++++++++++++------------------- pkg/common/constants.go | 4 ++-- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/pkg/client/load_balancer.go b/pkg/client/load_balancer.go index cb36298..df90e5d 100644 --- a/pkg/client/load_balancer.go +++ b/pkg/client/load_balancer.go @@ -23,7 +23,7 @@ func (lb *LoadBalancerAPIService) CreateLoadBalancer( loadBalancerResp := models.CreateNetworkLoadBalancerResp{} loadBalancerAPI := &api{ method: "POST", - path: fmt.Sprintf("%s/%s", consts.NetworkLoadBalancerPath, consts.LoadBalancerPath), + path: fmt.Sprintf("%s/%s", consts.BasePath, consts.LoadBalancerPath), client: lb.Client, jsonParser: func(body []byte) error { return json.Unmarshal(body, &loadBalancerResp) @@ -42,7 +42,7 @@ func (lb *LoadBalancerAPIService) DeleteLoadBalancer( loadBalancerAPI := &api{ method: "DELETE", path: fmt.Sprintf("%s/%s/%d", - consts.NetworkLoadBalancerPath, consts.LoadBalancerPath, lbID), + consts.BasePath, consts.LoadBalancerPath, lbID), client: lb.Client, jsonParser: func(body []byte) error { return json.Unmarshal(body, &loadBalancerResp) @@ -59,7 +59,7 @@ func (lb *LoadBalancerAPIService) GetLoadBalancers( loadBalancerResp := models.GetNetworkLoadBalancers{} loadBalancerAPI := &api{ method: "GET", - path: fmt.Sprintf("%s/%s", consts.NetworkLoadBalancerPath, consts.LoadBalancerPath), + path: fmt.Sprintf("%s/%s", consts.BasePath, consts.LoadBalancerPath), client: lb.Client, jsonParser: func(body []byte) error { return json.Unmarshal(body, &loadBalancerResp) @@ -77,7 +77,7 @@ func (lb *LoadBalancerAPIService) GetSpecificLoadBalancers( loadBalancerResp := models.GetSpecificNetworkLoadBalancer{} loadBalancerAPI := &api{ method: "GET", - path: fmt.Sprintf("%s/%s/%d", consts.NetworkLoadBalancerPath, + path: fmt.Sprintf("%s/%s/%d", consts.BasePath, consts.LoadBalancerPath, lbID), client: lb.Client, jsonParser: func(body []byte) error { @@ -97,7 +97,7 @@ func (lb *LoadBalancerAPIService) CreateLBMonitor( LBMonitorResp := models.CreateLBMonitorResp{} LBMonitorAPI := &api{ method: "POST", - path: fmt.Sprintf("%s/%s/%d/%s", consts.NetworkLoadBalancerPath, + path: fmt.Sprintf("%s/%s/%d/%s", consts.BasePath, consts.LoadBalancerPath, lbID, consts.LoadBalancerMonitorPath), client: lb.Client, jsonParser: func(body []byte) error { @@ -118,7 +118,7 @@ func (lb *LoadBalancerAPIService) DeleteLBMonitor( LBMonitorAPI := &api{ method: "DELETE", path: fmt.Sprintf("%s/%s/%d/%s/%d", - consts.NetworkLoadBalancerPath, consts.LoadBalancerPath, lbID, + consts.BasePath, consts.LoadBalancerPath, lbID, consts.LoadBalancerMonitorPath, lbMonitorID), client: lb.Client, jsonParser: func(body []byte) error { @@ -137,7 +137,7 @@ func (lb *LoadBalancerAPIService) GetLBMonitors( LBMonitorResp := models.GetLBMonitors{} LBMonitorAPI := &api{ method: "GET", - path: fmt.Sprintf("%s/%s/%d/%s", consts.NetworkLoadBalancerPath, + path: fmt.Sprintf("%s/%s/%d/%s", consts.BasePath, consts.LoadBalancerPath, lbID, consts.LoadBalancerMonitorPath), client: lb.Client, jsonParser: func(body []byte) error { @@ -157,7 +157,7 @@ func (lb *LoadBalancerAPIService) GetSpecificLBMonitor( LBMonitorResp := models.GetSpecificLBMonitor{} LBMonitorAPI := &api{ method: "GET", - path: fmt.Sprintf("%s/%s/%d/%s/%d", consts.NetworkLoadBalancerPath, + path: fmt.Sprintf("%s/%s/%d/%s/%d", consts.BasePath, consts.LoadBalancerPath, lbID, consts.LoadBalancerMonitorPath, lbmonitorID), client: lb.Client, jsonParser: func(body []byte) error { @@ -177,7 +177,7 @@ func (lb *LoadBalancerAPIService) CreateLBProfile( LBProfileResp := models.CreateLBProfileResp{} LBProfileAPI := &api{ method: "POST", - path: fmt.Sprintf("%s/%s/%d/%s", consts.NetworkLoadBalancerPath, + path: fmt.Sprintf("%s/%s/%d/%s", consts.BasePath, consts.LoadBalancerPath, lbID, consts.LoadBalancerProfilePath), client: lb.Client, jsonParser: func(body []byte) error { @@ -198,7 +198,7 @@ func (lb *LoadBalancerAPIService) DeleteLBProfile( LBProfileAPI := &api{ method: "DELETE", path: fmt.Sprintf("%s/%s/%d/%s/%d", - consts.NetworkLoadBalancerPath, consts.LoadBalancerPath, lbID, + consts.BasePath, consts.LoadBalancerPath, lbID, consts.LoadBalancerProfilePath, lbProfileID), client: lb.Client, jsonParser: func(body []byte) error { @@ -217,7 +217,7 @@ func (lb *LoadBalancerAPIService) GetLBProfiles( LBProfileResp := models.GetLBProfile{} LBProfileAPI := &api{ method: "GET", - path: fmt.Sprintf("%s/%s/%d/%s", consts.NetworkLoadBalancerPath, + path: fmt.Sprintf("%s/%s/%d/%s", consts.BasePath, consts.LoadBalancerPath, lbID, consts.LoadBalancerProfilePath), client: lb.Client, jsonParser: func(body []byte) error { @@ -237,7 +237,7 @@ func (lb *LoadBalancerAPIService) GetSpecificLBProfile( LBProfileResp := models.GetLBSpecificProfile{} LBProfileAPI := &api{ method: "GET", - path: fmt.Sprintf("%s/%s/%d/%s/%d", consts.NetworkLoadBalancerPath, + path: fmt.Sprintf("%s/%s/%d/%s/%d", consts.BasePath, consts.LoadBalancerPath, lbID, consts.LoadBalancerProfilePath, lbProfileID), client: lb.Client, jsonParser: func(body []byte) error { @@ -257,7 +257,7 @@ func (lb *LoadBalancerAPIService) CreateLBPool( LBPoolResp := models.CreateLBPoolResp{} LBPoolAPI := &api{ method: "POST", - path: fmt.Sprintf("%s/%s/%d/%s", consts.NetworkLoadBalancerPath, + path: fmt.Sprintf("%s/%s/%d/%s", consts.BasePath, consts.LoadBalancerPath, lbID, consts.LoadBalancerPoolPath), client: lb.Client, jsonParser: func(body []byte) error { @@ -278,7 +278,7 @@ func (lb *LoadBalancerAPIService) DeleteLBPool( LBPoolAPI := &api{ method: "DELETE", path: fmt.Sprintf("%s/%s/%d/%s/%d", - consts.NetworkLoadBalancerPath, consts.LoadBalancerPath, lbID, + consts.BasePath, consts.LoadBalancerPath, lbID, consts.LoadBalancerPoolPath, lbPoolID), client: lb.Client, jsonParser: func(body []byte) error { @@ -297,7 +297,7 @@ func (lb *LoadBalancerAPIService) GetLBPools( LBPoolResp := models.GetLBPools{} LBPoolAPI := &api{ method: "GET", - path: fmt.Sprintf("%s/%s/%d/%s", consts.NetworkLoadBalancerPath, + path: fmt.Sprintf("%s/%s/%d/%s", consts.BasePath, consts.LoadBalancerPath, lbID, consts.LoadBalancerPoolPath), client: lb.Client, jsonParser: func(body []byte) error { @@ -317,7 +317,7 @@ func (lb *LoadBalancerAPIService) GetSpecificLBPool( LBPoolResp := models.GetSpecificLBPool{} LBPoolAPI := &api{ method: "GET", - path: fmt.Sprintf("%s/%s/%d/%s/%d", consts.NetworkLoadBalancerPath, + path: fmt.Sprintf("%s/%s/%d/%s/%d", consts.BasePath, consts.LoadBalancerPath, lbID, consts.LoadBalancerPoolPath, lbPoolID), client: lb.Client, jsonParser: func(body []byte) error { @@ -337,7 +337,7 @@ func (lb *LoadBalancerAPIService) CreateLBVirtualServers( LBVSResp := models.LBVirtualServersResp{} LBVSAPI := &api{ method: "POST", - path: fmt.Sprintf("%s/%s/%d/%s", consts.NetworkLoadBalancerPath, + path: fmt.Sprintf("%s/%s/%d/%s", consts.BasePath, consts.LoadBalancerPath, lbID, consts.LoadBalancerVirtualServersPath), client: lb.Client, jsonParser: func(body []byte) error { @@ -358,7 +358,7 @@ func (lb *LoadBalancerAPIService) DeleteLBVirtualServers( LBVSAPI := &api{ method: "DELETE", path: fmt.Sprintf("%s/%s/%d/%s/%d", - consts.NetworkLoadBalancerPath, consts.LoadBalancerPath, lbID, + consts.BasePath, consts.LoadBalancerPath, lbID, consts.LoadBalancerVirtualServersPath, lbVirtualServerID), client: lb.Client, jsonParser: func(body []byte) error { @@ -377,7 +377,7 @@ func (lb *LoadBalancerAPIService) GetLBVirtualServers( LBVSResp := models.GetLBVirtualServers{} LBVSAPI := &api{ method: "GET", - path: fmt.Sprintf("%s/%s/%d/%s", consts.NetworkLoadBalancerPath, + path: fmt.Sprintf("%s/%s/%d/%s", consts.BasePath, consts.LoadBalancerPath, lbID, consts.LoadBalancerVirtualServersPath), client: lb.Client, jsonParser: func(body []byte) error { @@ -397,7 +397,7 @@ func (lb *LoadBalancerAPIService) GetSpecificLBVirtualServer( LBVSResp := models.GetSpecificLBVirtualServers{} LBVSAPI := &api{ method: "GET", - path: fmt.Sprintf("%s/%s/%d/%s/%d", consts.NetworkLoadBalancerPath, + path: fmt.Sprintf("%s/%s/%d/%s/%d", consts.BasePath, consts.LoadBalancerPath, lbID, consts.LoadBalancerVirtualServersPath, lbVSID), client: lb.Client, jsonParser: func(body []byte) error { diff --git a/pkg/common/constants.go b/pkg/common/constants.go index fea7fcb..502882a 100644 --- a/pkg/common/constants.go +++ b/pkg/common/constants.go @@ -13,8 +13,8 @@ const ( GroupsPath = "groups" // NetworksPath NetworksPath = "networks" - // LoadBalancerPath - NetworkLoadBalancerPath = "api" + // BasePath + BasePath = "api" // NetworkTypePath NetworkTypePath = "network-types" NetworkPoolPath = "pools"