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'); });