@@ -231,8 +231,8 @@ func (e *EMLB) ReconcileVIPOrigin(ctx context.Context, machineScope *scope.Machi
231231 return nil
232232}
233233
234- // DeleteLoadBalancer deletes the Equinix Metal Load Balancer associated with a given ClusterScope.
235- func (e * EMLB ) DeleteLoadBalancer (ctx context.Context , clusterScope * scope.ClusterScope ) error {
234+ // DeleteClusterLoadBalancer deletes the Equinix Metal Load Balancer associated with a given ClusterScope.
235+ func (e * EMLB ) DeleteClusterLoadBalancer (ctx context.Context , clusterScope * scope.ClusterScope ) error {
236236 log := ctrl .LoggerFrom (ctx )
237237
238238 packetCluster := clusterScope .PacketCluster
@@ -247,7 +247,7 @@ func (e *EMLB) DeleteLoadBalancer(ctx context.Context, clusterScope *scope.Clust
247247
248248 log .Info ("Deleting EMLB" , "Cluster Metro" , e .metro , "Cluster Name" , clusterName , "Project ID" , e .projectID , "Load Balancer ID" , lbID )
249249
250- resp , err := e .deleteLoadBalancer (ctx , lbID )
250+ resp , err := e .DeleteLoadBalancer (ctx , lbID )
251251 if err != nil {
252252 if resp .StatusCode == http .StatusNotFound {
253253 return nil
@@ -273,7 +273,7 @@ func (e *EMLB) DeleteLoadBalancerOrigin(ctx context.Context, machineScope *scope
273273
274274 log .Info ("Deleting EMLB Pool" , "Cluster Metro" , e .metro , "Cluster Name" , clusterName , "Project ID" , e .projectID , "Pool ID" , lbPoolID )
275275
276- resp , err := e .deletePool (ctx , lbPoolID )
276+ resp , err := e .DeleteLoadBalancerPool (ctx , lbPoolID )
277277 if err != nil {
278278 if resp .StatusCode != http .StatusNotFound {
279279 return nil
@@ -284,6 +284,22 @@ func (e *EMLB) DeleteLoadBalancerOrigin(ctx context.Context, machineScope *scope
284284 return err
285285}
286286
287+ // GetLoadBalancers returns a Load Balancer Collection of all the Equinix Metal Load Balancers in a project.
288+ func (e * EMLB ) GetLoadBalancers (ctx context.Context ) (* lbaas.LoadBalancerCollection , * http.Response , error ) {
289+ ctx = context .WithValue (ctx , lbaas .ContextOAuth2 , e .tokenExchanger )
290+
291+ LoadBalancerCollection , resp , err := e .client .ProjectsApi .ListLoadBalancers (ctx , e .projectID ).Execute ()
292+ return LoadBalancerCollection , resp , err
293+ }
294+
295+ // GetLoadBalancerPools returns a Load Balancer Collection of all the Equinix Metal Load Balancers in a project.
296+ func (e * EMLB ) GetLoadBalancerPools (ctx context.Context ) (* lbaas.LoadBalancerPoolCollection , * http.Response , error ) {
297+ ctx = context .WithValue (ctx , lbaas .ContextOAuth2 , e .tokenExchanger )
298+
299+ LoadBalancerPoolCollection , resp , err := e .client .ProjectsApi .ListPools (ctx , e .projectID ).Execute ()
300+ return LoadBalancerPoolCollection , resp , err
301+ }
302+
287303// getLoadBalancer Returns a Load Balancer object given an id.
288304func (e * EMLB ) getLoadBalancer (ctx context.Context , id string ) (* lbaas.LoadBalancer , * http.Response , error ) {
289305 ctx = context .WithValue (ctx , lbaas .ContextOAuth2 , e .tokenExchanger )
@@ -452,12 +468,14 @@ func (e *EMLB) createOrigin(ctx context.Context, poolID, originName string, targ
452468 return e .client .PoolsApi .CreateLoadBalancerPoolOrigin (ctx , poolID ).LoadBalancerPoolOriginCreate (createOriginRequest ).Execute ()
453469}
454470
455- func (e * EMLB ) deleteLoadBalancer (ctx context.Context , lbID string ) (* http.Response , error ) {
471+ // DeleteLoadBalancer deletes an Equinix Metal Load Balancer given an ID.
472+ func (e * EMLB ) DeleteLoadBalancer (ctx context.Context , lbID string ) (* http.Response , error ) {
456473 ctx = context .WithValue (ctx , lbaas .ContextOAuth2 , e .tokenExchanger )
457474 return e .client .LoadBalancersApi .DeleteLoadBalancer (ctx , lbID ).Execute ()
458475}
459476
460- func (e * EMLB ) deletePool (ctx context.Context , poolID string ) (* http.Response , error ) {
477+ // DeleteLoadBalancerPool deletes an Equinix Metal Load Balancer Origin Pool given an ID.
478+ func (e * EMLB ) DeleteLoadBalancerPool (ctx context.Context , poolID string ) (* http.Response , error ) {
461479 ctx = context .WithValue (ctx , lbaas .ContextOAuth2 , e .tokenExchanger )
462480 return e .client .PoolsApi .DeleteLoadBalancerPool (ctx , poolID ).Execute ()
463481}
0 commit comments