From c7ce232499ee1a53466bfd598b0cab03ba132e17 Mon Sep 17 00:00:00 2001 From: Nicolas Chaulet Date: Wed, 13 Nov 2024 15:07:41 -0500 Subject: [PATCH] [Fleet] Revert enrollment api key list removal --- .../fleet/common/types/rest_spec/enrollment_api_key.ts | 5 ++++- .../fleet/server/routes/enrollment_api_key/handler.ts | 1 + .../plugins/fleet/server/routes/enrollment_api_key/index.ts | 5 ++++- .../fleet_api_integration/apis/enrollment_api_keys/crud.ts | 2 ++ 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/x-pack/plugins/fleet/common/types/rest_spec/enrollment_api_key.ts b/x-pack/plugins/fleet/common/types/rest_spec/enrollment_api_key.ts index e1509d551bdef..7fa724e5079c8 100644 --- a/x-pack/plugins/fleet/common/types/rest_spec/enrollment_api_key.ts +++ b/x-pack/plugins/fleet/common/types/rest_spec/enrollment_api_key.ts @@ -13,7 +13,10 @@ export interface GetEnrollmentAPIKeysRequest { query: ListWithKuery; } -export type GetEnrollmentAPIKeysResponse = ListResult; +export type GetEnrollmentAPIKeysResponse = ListResult & { + // deprecated in 8.x + list?: EnrollmentAPIKey[]; +}; export interface GetOneEnrollmentAPIKeyRequest { params: { diff --git a/x-pack/plugins/fleet/server/routes/enrollment_api_key/handler.ts b/x-pack/plugins/fleet/server/routes/enrollment_api_key/handler.ts index cfce60b0f18f5..a38f5bdadc617 100644 --- a/x-pack/plugins/fleet/server/routes/enrollment_api_key/handler.ts +++ b/x-pack/plugins/fleet/server/routes/enrollment_api_key/handler.ts @@ -43,6 +43,7 @@ export const getEnrollmentApiKeysHandler: RequestHandler< spaceId: useSpaceAwareness ? getCurrentNamespace(soClient) : undefined, }); const body: GetEnrollmentAPIKeysResponse = { + list: items, // deprecated items, total, page, diff --git a/x-pack/plugins/fleet/server/routes/enrollment_api_key/index.ts b/x-pack/plugins/fleet/server/routes/enrollment_api_key/index.ts index 58538ba18f359..e593bac3180fe 100644 --- a/x-pack/plugins/fleet/server/routes/enrollment_api_key/index.ts +++ b/x-pack/plugins/fleet/server/routes/enrollment_api_key/index.ts @@ -111,7 +111,10 @@ export const registerRoutes = (router: FleetAuthzRouter) => { request: GetEnrollmentAPIKeysRequestSchema, response: { 200: { - body: () => ListResponseSchema(EnrollmentAPIKeySchema), + body: () => + ListResponseSchema(EnrollmentAPIKeySchema).extends({ + list: schema.arrayOf(EnrollmentAPIKeySchema, { meta: { deprecated: true } }), + }), }, 400: { body: genericErrorResponse, diff --git a/x-pack/test/fleet_api_integration/apis/enrollment_api_keys/crud.ts b/x-pack/test/fleet_api_integration/apis/enrollment_api_keys/crud.ts index 24d1520d8d6f8..686532f8eae50 100644 --- a/x-pack/test/fleet_api_integration/apis/enrollment_api_keys/crud.ts +++ b/x-pack/test/fleet_api_integration/apis/enrollment_api_keys/crud.ts @@ -43,6 +43,8 @@ export default function (providerContext: FtrProviderContext) { expect(apiResponse.total).to.be(2); expect(apiResponse.items[0]).to.have.keys('id', 'api_key_id', 'name'); + // Deprecated property list + expect(apiResponse.list[0]).to.have.keys('id', 'api_key_id', 'name'); expect(apiResponse).to.have.keys('items'); });