From c7ce232499ee1a53466bfd598b0cab03ba132e17 Mon Sep 17 00:00:00 2001 From: Nicolas Chaulet Date: Wed, 13 Nov 2024 15:07:41 -0500 Subject: [PATCH 1/3] [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'); }); From 7ab6478ce6d7fda4b3e8832711767f03d1c6257f Mon Sep 17 00:00:00 2001 From: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Date: Wed, 13 Nov 2024 20:23:18 +0000 Subject: [PATCH 2/3] [CI] Auto-commit changed files from 'node scripts/capture_oas_snapshot --include-path /api/status --include-path /api/alerting/rule/ --include-path /api/alerting/rules --include-path /api/actions --include-path /api/security/role --include-path /api/spaces --include-path /api/fleet --update' --- oas_docs/bundle.json | 46 ++++++++++++++++++++++++++++++++- oas_docs/bundle.serverless.json | 46 ++++++++++++++++++++++++++++++++- 2 files changed, 90 insertions(+), 2 deletions(-) diff --git a/oas_docs/bundle.json b/oas_docs/bundle.json index aa53ce68e54fd..0fde92c1fa3f9 100644 --- a/oas_docs/bundle.json +++ b/oas_docs/bundle.json @@ -16951,6 +16951,49 @@ }, "type": "array" }, + "list": { + "deprecated": true, + "items": { + "additionalProperties": false, + "properties": { + "active": { + "description": "When false, the enrollment API key is revoked and cannot be used for enrolling Elastic Agents.", + "type": "boolean" + }, + "api_key": { + "description": "The enrollment API key (token) used for enrolling Elastic Agents.", + "type": "string" + }, + "api_key_id": { + "description": "The ID of the API key in the Security API.", + "type": "string" + }, + "created_at": { + "type": "string" + }, + "id": { + "type": "string" + }, + "name": { + "description": "The name of the enrollment API key.", + "type": "string" + }, + "policy_id": { + "description": "The ID of the agent policy the Elastic Agent will be enrolled in.", + "type": "string" + } + }, + "required": [ + "id", + "api_key_id", + "api_key", + "active", + "created_at" + ], + "type": "object" + }, + "type": "array" + }, "page": { "type": "number" }, @@ -16965,7 +17008,8 @@ "items", "total", "page", - "perPage" + "perPage", + "list" ], "type": "object" } diff --git a/oas_docs/bundle.serverless.json b/oas_docs/bundle.serverless.json index 1267027a3687a..229bda84b8629 100644 --- a/oas_docs/bundle.serverless.json +++ b/oas_docs/bundle.serverless.json @@ -16951,6 +16951,49 @@ }, "type": "array" }, + "list": { + "deprecated": true, + "items": { + "additionalProperties": false, + "properties": { + "active": { + "description": "When false, the enrollment API key is revoked and cannot be used for enrolling Elastic Agents.", + "type": "boolean" + }, + "api_key": { + "description": "The enrollment API key (token) used for enrolling Elastic Agents.", + "type": "string" + }, + "api_key_id": { + "description": "The ID of the API key in the Security API.", + "type": "string" + }, + "created_at": { + "type": "string" + }, + "id": { + "type": "string" + }, + "name": { + "description": "The name of the enrollment API key.", + "type": "string" + }, + "policy_id": { + "description": "The ID of the agent policy the Elastic Agent will be enrolled in.", + "type": "string" + } + }, + "required": [ + "id", + "api_key_id", + "api_key", + "active", + "created_at" + ], + "type": "object" + }, + "type": "array" + }, "page": { "type": "number" }, @@ -16965,7 +17008,8 @@ "items", "total", "page", - "perPage" + "perPage", + "list" ], "type": "object" } From 90b1ae0f62f2fe1e8bdc6ffaca4965900bbe30d6 Mon Sep 17 00:00:00 2001 From: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Date: Wed, 13 Nov 2024 20:38:53 +0000 Subject: [PATCH 3/3] [CI] Auto-commit changed files from 'make api-docs' --- oas_docs/output/kibana.serverless.yaml | 39 ++++++++++++++++++++++++++ oas_docs/output/kibana.yaml | 39 ++++++++++++++++++++++++++ 2 files changed, 78 insertions(+) diff --git a/oas_docs/output/kibana.serverless.yaml b/oas_docs/output/kibana.serverless.yaml index 2b64330a1937a..c8f41889053e4 100644 --- a/oas_docs/output/kibana.serverless.yaml +++ b/oas_docs/output/kibana.serverless.yaml @@ -17704,6 +17704,44 @@ paths: - active - created_at type: array + list: + deprecated: true + items: + additionalProperties: false + type: object + properties: + active: + description: >- + When false, the enrollment API key is revoked and + cannot be used for enrolling Elastic Agents. + type: boolean + api_key: + description: >- + The enrollment API key (token) used for enrolling + Elastic Agents. + type: string + api_key_id: + description: The ID of the API key in the Security API. + type: string + created_at: + type: string + id: + type: string + name: + description: The name of the enrollment API key. + type: string + policy_id: + description: >- + The ID of the agent policy the Elastic Agent will be + enrolled in. + type: string + required: + - id + - api_key_id + - api_key + - active + - created_at + type: array page: type: number perPage: @@ -17715,6 +17753,7 @@ paths: - total - page - perPage + - list '400': content: application/json; Elastic-Api-Version=2023-10-31: diff --git a/oas_docs/output/kibana.yaml b/oas_docs/output/kibana.yaml index db3282f2c7899..8b7335f5ef609 100644 --- a/oas_docs/output/kibana.yaml +++ b/oas_docs/output/kibana.yaml @@ -21023,6 +21023,44 @@ paths: - active - created_at type: array + list: + deprecated: true + items: + additionalProperties: false + type: object + properties: + active: + description: >- + When false, the enrollment API key is revoked and + cannot be used for enrolling Elastic Agents. + type: boolean + api_key: + description: >- + The enrollment API key (token) used for enrolling + Elastic Agents. + type: string + api_key_id: + description: The ID of the API key in the Security API. + type: string + created_at: + type: string + id: + type: string + name: + description: The name of the enrollment API key. + type: string + policy_id: + description: >- + The ID of the agent policy the Elastic Agent will be + enrolled in. + type: string + required: + - id + - api_key_id + - api_key + - active + - created_at + type: array page: type: number perPage: @@ -21034,6 +21072,7 @@ paths: - total - page - perPage + - list '400': content: application/json; Elastic-Api-Version=2023-10-31: