Made Host Results endpoint URL consistent (33714) (#41501)

Resolves #33714

Added alias `GET /api/v1/fleet/scripts/batch/abc-def/host_results` for
`GET /api/v1/fleet/scripts/batch/abc-def/host-results` for consistency
sake.
This commit is contained in:
Juan Fernandez
2026-03-13 14:00:26 -04:00
committed by GitHub
parent da34876029
commit 067e5fb33f
5 changed files with 7 additions and 5 deletions
@@ -0,0 +1 @@
* Made the host results endpoint URL consistent with the other URLs.
+1 -1
View File
@@ -9508,7 +9508,7 @@ Returns a summary of a batch-run script, including host counts and current statu
Returns a list hosts targeted in a batch script run, along with their script execution status.
`GET /api/v1/fleet/scripts/batch/:batch_execution_id/host-results`
`GET /api/v1/fleet/scripts/batch/:batch_execution_id/host_results`
#### Parameters
+1 -1
View File
@@ -302,7 +302,7 @@ export default {
`/${API_VERSION}/fleet/scripts/batch/${id}`,
SCRIPT_RUN_BATCH_SUMMARIES: `/${API_VERSION}/fleet/scripts/batch`,
SCRIPT_BATCH_HOST_RESULTS: (id: string) =>
`/${API_VERSION}/fleet/scripts/batch/${id}/host-results`,
`/${API_VERSION}/fleet/scripts/batch/${id}/host_results`,
// Command endpoints
COMMANDS: `/${API_VERSION}/fleet/commands`,
+2 -1
View File
@@ -551,7 +551,8 @@ func attachFleetAPIRoutes(r *mux.Router, svc fleet.Service, config config.FleetC
ue.POST("/api/_version_/fleet/scripts/batch/{batch_execution_id:[a-zA-Z0-9-]+}/cancel", batchScriptCancelEndpoint, batchScriptCancelRequest{})
// Deprecated, will remove in favor of batchScriptExecutionStatusEndpoint when batch script details page is ready.
ue.GET("/api/_version_/fleet/scripts/batch/summary/{batch_execution_id:[a-zA-Z0-9-]+}", batchScriptExecutionSummaryEndpoint, batchScriptExecutionSummaryRequest{})
ue.GET("/api/_version_/fleet/scripts/batch/{batch_execution_id:[a-zA-Z0-9-]+}/host-results", batchScriptExecutionHostResultsEndpoint, batchScriptExecutionHostResultsRequest{})
ue.WithAltPaths("/api/_version_/fleet/scripts/batch/{batch_execution_id:[a-zA-Z0-9-]+}/host-results"). // .../host-results is DEPRECATED but we need to maintain for backwards compatibility because customers may already be using it
GET("/api/_version_/fleet/scripts/batch/{batch_execution_id:[a-zA-Z0-9-]+}/host_results", batchScriptExecutionHostResultsEndpoint, batchScriptExecutionHostResultsRequest{})
ue.GET("/api/_version_/fleet/scripts/batch/{batch_execution_id:[a-zA-Z0-9-]+}", batchScriptExecutionStatusEndpoint, batchScriptExecutionStatusRequest{})
ue.GET("/api/_version_/fleet/scripts/batch", batchScriptExecutionListEndpoint, batchScriptExecutionListRequest{})
@@ -7631,12 +7631,12 @@ func (s *integrationEnterpriseTestSuite) TestRunBatchScript() {
)
var batchPendingHostsResp batchScriptExecutionHostResultsResponse
res := s.Do("GET", fmt.Sprintf("/api/latest/fleet/scripts/batch/%s/host-results", batchRes.BatchExecutionID), nil, http.StatusBadRequest)
res := s.Do("GET", fmt.Sprintf("/api/latest/fleet/scripts/batch/%s/host_results", batchRes.BatchExecutionID), nil, http.StatusBadRequest)
errMsg := extractServerErrorText(res.Body)
require.Contains(t, errMsg, "Param status is required")
// List pending hosts
s.DoJSON("GET", fmt.Sprintf("/api/latest/fleet/scripts/batch/%s/host-results?status=pending", batchRes.BatchExecutionID), nil, http.StatusOK, &batchPendingHostsResp)
s.DoJSON("GET", fmt.Sprintf("/api/latest/fleet/scripts/batch/%s/host_results?status=pending", batchRes.BatchExecutionID), nil, http.StatusOK, &batchPendingHostsResp)
require.Len(t, batchPendingHostsResp.Hosts, 2)
require.Equal(t, batchPendingHostsResp.Count, uint(2))
require.Equal(t, batchPendingHostsResp.Meta.HasNextResults, false)