From a48e6eca303a4c3c84d0c4df791d8451b8706953 Mon Sep 17 00:00:00 2001 From: Mallory Hill Date: Thu, 14 May 2026 22:50:11 -0400 Subject: [PATCH] HYPERFLEET-978 - feat: (2/2) Include routes in API for PUT status updates --- plugins/clusters/plugin.go | 2 -- test/integration/clusters_test.go | 20 ++++++++++---------- test/integration/node_pools_test.go | 16 ++++++++-------- 3 files changed, 18 insertions(+), 20 deletions(-) diff --git a/plugins/clusters/plugin.go b/plugins/clusters/plugin.go index 497684c..ce3c34f 100644 --- a/plugins/clusters/plugin.go +++ b/plugins/clusters/plugin.go @@ -66,7 +66,6 @@ func init() { // Nested resource: cluster statuses clusterStatusHandler := handlers.NewClusterStatusHandler(adapterStatus.Service(envServices), Service(envServices)) clustersRouter.HandleFunc("/{id}/statuses", clusterStatusHandler.List).Methods(http.MethodGet) - clustersRouter.HandleFunc("/{id}/statuses", clusterStatusHandler.Create).Methods(http.MethodPost) clustersRouter.HandleFunc("/{id}/statuses", clusterStatusHandler.Create).Methods(http.MethodPut) // Nested resource: cluster nodepools @@ -84,7 +83,6 @@ func init() { // Nested resource: nodepool statuses nodepoolStatusHandler := handlers.NewNodePoolStatusHandler(adapterStatus.Service(envServices), nodePools.Service(envServices)) clustersRouter.HandleFunc("/{id}/nodepools/{nodepool_id}/statuses", nodepoolStatusHandler.List).Methods(http.MethodGet) - clustersRouter.HandleFunc("/{id}/nodepools/{nodepool_id}/statuses", nodepoolStatusHandler.Create).Methods(http.MethodPost) clustersRouter.HandleFunc("/{id}/nodepools/{nodepool_id}/statuses", nodepoolStatusHandler.Create).Methods(http.MethodPut) clustersRouter.Use(authMiddleware.AuthenticateAccountJWT) diff --git a/test/integration/clusters_test.go b/test/integration/clusters_test.go index 5248358..1a7da4f 100644 --- a/test/integration/clusters_test.go +++ b/test/integration/clusters_test.go @@ -1163,9 +1163,9 @@ func TestClusterHardDelete(t *testing.T) { }, nil, ) - statusResp, loopErr := client.PostClusterStatusesWithResponse( + statusResp, loopErr := client.PutClusterStatusesWithResponse( ctx, cluster.ID, - openapi.PostClusterStatusesJSONRequestBody(statusInput), test.WithAuthToken(ctx), + openapi.PutClusterStatusesJSONRequestBody(statusInput), test.WithAuthToken(ctx), ) Expect(loopErr).NotTo(HaveOccurred()) Expect(statusResp.StatusCode()).To(Equal(http.StatusCreated)) @@ -1224,9 +1224,9 @@ func TestClusterHardDelete(t *testing.T) { }, nil, ) - statusResp, err := client.PostClusterStatusesWithResponse( + statusResp, err := client.PutClusterStatusesWithResponse( ctx, cluster.ID, - openapi.PostClusterStatusesJSONRequestBody(statusInput), test.WithAuthToken(ctx), + openapi.PutClusterStatusesJSONRequestBody(statusInput), test.WithAuthToken(ctx), ) Expect(err).NotTo(HaveOccurred()) Expect(statusResp.StatusCode()).To(Equal(http.StatusCreated)) @@ -1295,9 +1295,9 @@ func TestClusterHardDelete(t *testing.T) { }, nil, ) - statusResp, loopErr := client.PostClusterStatusesWithResponse( + statusResp, loopErr := client.PutClusterStatusesWithResponse( ctx, cluster.ID, - openapi.PostClusterStatusesJSONRequestBody(statusInput), test.WithAuthToken(ctx), + openapi.PutClusterStatusesJSONRequestBody(statusInput), test.WithAuthToken(ctx), ) Expect(loopErr).NotTo(HaveOccurred()) Expect(statusResp.StatusCode()).To(Equal(http.StatusCreated)) @@ -1334,9 +1334,9 @@ func TestClusterHardDelete(t *testing.T) { }, nil, ) - _, loopErr := client.PostNodePoolStatusesWithResponse( + _, loopErr := client.PutNodePoolStatusesWithResponse( ctx, cluster.ID, nodePool.ID, - openapi.PostNodePoolStatusesJSONRequestBody(statusInput), test.WithAuthToken(ctx), + openapi.PutNodePoolStatusesJSONRequestBody(statusInput), test.WithAuthToken(ctx), ) Expect(loopErr).NotTo(HaveOccurred()) } @@ -1371,9 +1371,9 @@ func TestClusterHardDelete(t *testing.T) { }, nil, ) - finalResp, err := client.PostClusterStatusesWithResponse( + finalResp, err := client.PutClusterStatusesWithResponse( ctx, cluster.ID, - openapi.PostClusterStatusesJSONRequestBody(statusInput), test.WithAuthToken(ctx), + openapi.PutClusterStatusesJSONRequestBody(statusInput), test.WithAuthToken(ctx), ) Expect(err).NotTo(HaveOccurred()) Expect(finalResp.StatusCode()).To(Equal(http.StatusCreated)) diff --git a/test/integration/node_pools_test.go b/test/integration/node_pools_test.go index bba22a0..1185a8c 100644 --- a/test/integration/node_pools_test.go +++ b/test/integration/node_pools_test.go @@ -754,9 +754,9 @@ func TestNodePoolHardDelete(t *testing.T) { }, nil, ) - statusResp, loopErr := client.PostNodePoolStatusesWithResponse( + statusResp, loopErr := client.PutNodePoolStatusesWithResponse( ctx, cluster.ID, nodePool.ID, - openapi.PostNodePoolStatusesJSONRequestBody(statusInput), test.WithAuthToken(ctx), + openapi.PutNodePoolStatusesJSONRequestBody(statusInput), test.WithAuthToken(ctx), ) Expect(loopErr).NotTo(HaveOccurred()) Expect(statusResp.StatusCode()).To(Equal(http.StatusCreated)) @@ -815,9 +815,9 @@ func TestNodePoolHardDelete(t *testing.T) { }, nil, ) - statusResp, err := client.PostNodePoolStatusesWithResponse( + statusResp, err := client.PutNodePoolStatusesWithResponse( ctx, cluster.ID, nodePool.ID, - openapi.PostNodePoolStatusesJSONRequestBody(statusInput), test.WithAuthToken(ctx), + openapi.PutNodePoolStatusesJSONRequestBody(statusInput), test.WithAuthToken(ctx), ) Expect(err).NotTo(HaveOccurred()) Expect(statusResp.StatusCode()).To(Equal(http.StatusCreated)) @@ -870,9 +870,9 @@ func TestNodePoolHardDelete(t *testing.T) { }, nil, ) - statusResp, err := client.PostNodePoolStatusesWithResponse( + statusResp, err := client.PutNodePoolStatusesWithResponse( ctx, cluster.ID, nodePool.ID, - openapi.PostNodePoolStatusesJSONRequestBody(statusInput), test.WithAuthToken(ctx), + openapi.PutNodePoolStatusesJSONRequestBody(statusInput), test.WithAuthToken(ctx), ) Expect(err).NotTo(HaveOccurred()) Expect(statusResp.StatusCode()).To(Equal(http.StatusCreated)) @@ -923,9 +923,9 @@ func TestNodePoolHardDelete(t *testing.T) { }, nil, ) - statusResp, loopErr := client.PostNodePoolStatusesWithResponse( + statusResp, loopErr := client.PutNodePoolStatusesWithResponse( ctx, cluster.ID, nodePool.ID, - openapi.PostNodePoolStatusesJSONRequestBody(statusInput), test.WithAuthToken(ctx), + openapi.PutNodePoolStatusesJSONRequestBody(statusInput), test.WithAuthToken(ctx), ) Expect(loopErr).NotTo(HaveOccurred()) Expect(statusResp.StatusCode()).To(Equal(http.StatusCreated))