From cbe8c98a6ff102dd828db463f5a07f1cbea449b9 Mon Sep 17 00:00:00 2001 From: Michael Olorunnisola Date: Mon, 6 Nov 2023 13:20:25 -0500 Subject: [PATCH 01/15] update timeline api's to use codegen --- .../clean_draft_timelines_route.gen.ts | 32 ++ ...> clean_draft_timelines_route.schema.yaml} | 9 +- .../create_timelines_route.gen.ts | 43 ++ ...aml => create_timelines_route.schema.yaml} | 17 +- .../delete_note/delete_note_route.gen.ts | 19 + ...ema.yaml => delete_note_route.schema.yaml} | 5 +- .../delete_timelines_route_schema.yaml | 5 +- .../export_timelines_route.gen.ts | 28 + ...aml => export_timelines_route.schema.yaml} | 5 +- .../get_draft_timelines_route.gen.ts | 34 ++ ... => get_draft_timelines_route.schema.yaml} | 9 +- .../get_timeline/get_timeline_route.gen.ts | 35 ++ ...ma.yaml => get_timeline_route.schema.yaml} | 9 +- .../get_timelines/get_timelines_route.gen.ts | 49 ++ ...a.yaml => get_timelines_route.schema.yaml} | 19 +- .../import_timelines_route.gen.ts | 35 ++ ...aml => import_timelines_route.schema.yaml} | 29 +- ...ll_prepackaged_timelines_route_schema.yaml | 17 +- .../api/timeline/model/components.gen.ts | 325 ++++++++++++ ...components.yaml => components.schema.yaml} | 483 +++++++++--------- .../patch_timeline_route.gen.ts | 34 ++ ....yaml => patch_timeline_route.schema.yaml} | 9 +- .../persist_favorite_route.gen.ts | 31 ++ ...aml => persist_favorite_route.schema.yaml} | 11 +- .../persist_note/persist_note_route.gen.ts | 37 ++ ...ma.yaml => persist_note_route.schema.yaml} | 9 +- .../pinned_events/pinned_events_route.gen.ts | 35 ++ ...a.yaml => pinned_events_route.schema.yaml} | 7 +- 28 files changed, 1060 insertions(+), 320 deletions(-) create mode 100644 x-pack/plugins/security_solution/common/api/timeline/clean_draft_timelines/clean_draft_timelines_route.gen.ts rename x-pack/plugins/security_solution/common/api/timeline/clean_draft_timelines/{clean_draft_timelines_route_schema.yaml => clean_draft_timelines_route.schema.yaml} (88%) create mode 100644 x-pack/plugins/security_solution/common/api/timeline/create_timelines/create_timelines_route.gen.ts rename x-pack/plugins/security_solution/common/api/timeline/create_timelines/{create_timelines_route_schema.yaml => create_timelines_route.schema.yaml} (80%) create mode 100644 x-pack/plugins/security_solution/common/api/timeline/delete_note/delete_note_route.gen.ts rename x-pack/plugins/security_solution/common/api/timeline/delete_note/{delete_note_route_schema.yaml => delete_note_route.schema.yaml} (89%) create mode 100644 x-pack/plugins/security_solution/common/api/timeline/export_timelines/export_timelines_route.gen.ts rename x-pack/plugins/security_solution/common/api/timeline/export_timelines/{export_timelines_route_schema.yaml => export_timelines_route.schema.yaml} (94%) create mode 100644 x-pack/plugins/security_solution/common/api/timeline/get_draft_timelines/get_draft_timelines_route.gen.ts rename x-pack/plugins/security_solution/common/api/timeline/get_draft_timelines/{get_draft_timelines_route_schema.yaml => get_draft_timelines_route.schema.yaml} (88%) create mode 100644 x-pack/plugins/security_solution/common/api/timeline/get_timeline/get_timeline_route.gen.ts rename x-pack/plugins/security_solution/common/api/timeline/get_timeline/{get_timeline_route_schema.yaml => get_timeline_route.schema.yaml} (86%) create mode 100644 x-pack/plugins/security_solution/common/api/timeline/get_timelines/get_timelines_route.gen.ts rename x-pack/plugins/security_solution/common/api/timeline/get_timelines/{get_timelines_route_schema.yaml => get_timelines_route.schema.yaml} (85%) create mode 100644 x-pack/plugins/security_solution/common/api/timeline/import_timelines/import_timelines_route.gen.ts rename x-pack/plugins/security_solution/common/api/timeline/import_timelines/{import_timelines_route_schema.yaml => import_timelines_route.schema.yaml} (77%) create mode 100644 x-pack/plugins/security_solution/common/api/timeline/model/components.gen.ts rename x-pack/plugins/security_solution/common/api/timeline/model/{components.yaml => components.schema.yaml} (96%) create mode 100644 x-pack/plugins/security_solution/common/api/timeline/patch_timelines/patch_timeline_route.gen.ts rename x-pack/plugins/security_solution/common/api/timeline/patch_timelines/{patch_timeline_route_schema.yaml => patch_timeline_route.schema.yaml} (87%) create mode 100644 x-pack/plugins/security_solution/common/api/timeline/persist_favorite/persist_favorite_route.gen.ts rename x-pack/plugins/security_solution/common/api/timeline/persist_favorite/{persist_favorite_route_schema.yaml => persist_favorite_route.schema.yaml} (85%) create mode 100644 x-pack/plugins/security_solution/common/api/timeline/persist_note/persist_note_route.gen.ts rename x-pack/plugins/security_solution/common/api/timeline/persist_note/{persist_note_route_schema.yaml => persist_note_route.schema.yaml} (86%) create mode 100644 x-pack/plugins/security_solution/common/api/timeline/pinned_events/pinned_events_route.gen.ts rename x-pack/plugins/security_solution/common/api/timeline/pinned_events/{pinned_events_route_schema.yaml => pinned_events_route.schema.yaml} (89%) diff --git a/x-pack/plugins/security_solution/common/api/timeline/clean_draft_timelines/clean_draft_timelines_route.gen.ts b/x-pack/plugins/security_solution/common/api/timeline/clean_draft_timelines/clean_draft_timelines_route.gen.ts new file mode 100644 index 0000000000000..5eac8d39582b9 --- /dev/null +++ b/x-pack/plugins/security_solution/common/api/timeline/clean_draft_timelines/clean_draft_timelines_route.gen.ts @@ -0,0 +1,32 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { z } from 'zod'; + +/* + * NOTICE: Do not edit this file manually. + * This file is automatically generated by the OpenAPI Generator, @kbn/openapi-generator. + */ + +import { TimelineType, TimelineResponse } from '../model/components.gen'; + +export type CleanDraftTimelinesRequestBody = z.infer; +export const CleanDraftTimelinesRequestBody = z.object({ + timelineType: TimelineType.optional(), +}); +export type CleanDraftTimelinesRequestBodyInput = z.input; + +export type CleanDraftTimelinesResponse = z.infer; +export const CleanDraftTimelinesResponse = z.object({ + data: z.object({ + persistTimeline: z + .object({ + timeline: TimelineResponse.optional(), + }) + .optional(), + }), +}); diff --git a/x-pack/plugins/security_solution/common/api/timeline/clean_draft_timelines/clean_draft_timelines_route_schema.yaml b/x-pack/plugins/security_solution/common/api/timeline/clean_draft_timelines/clean_draft_timelines_route.schema.yaml similarity index 88% rename from x-pack/plugins/security_solution/common/api/timeline/clean_draft_timelines/clean_draft_timelines_route_schema.yaml rename to x-pack/plugins/security_solution/common/api/timeline/clean_draft_timelines/clean_draft_timelines_route.schema.yaml index 7e839763d52e0..7bbc666d731c1 100644 --- a/x-pack/plugins/security_solution/common/api/timeline/clean_draft_timelines/clean_draft_timelines_route_schema.yaml +++ b/x-pack/plugins/security_solution/common/api/timeline/clean_draft_timelines/clean_draft_timelines_route.schema.yaml @@ -1,7 +1,7 @@ openapi: 3.0.0 info: title: Elastic Security - Timeline - Draft Timeline API - version: 8.9.0 + version: '2023-10-31' servers: - url: 'http://{kibana_host}:{port}' variables: @@ -12,7 +12,8 @@ servers: paths: /api/timeline/_draft: post: - operationId: cleanDraftTimelines + operationId: CleanDraftTimelines + x-codegen-enabled: true summary: Retrieves a draft timeline or timeline template. description: | Retrieves a clean draft timeline. If a draft timeline does not exist, it is created and returned. @@ -27,7 +28,7 @@ paths: type: object properties: timelineType: - $ref: '../model/components.yaml#/components/schemas/TimelineType' + $ref: '../model/components.schema.yaml#/components/schemas/TimelineType' responses: 200: description: Indicates that the draft timeline was successfully created. In the event the user already has a draft timeline, the existing draft timeline is cleared and returned. @@ -43,7 +44,7 @@ paths: type: object properties: timeline: - $ref: '../model/components.yaml#/components/schemas/TimelineResponse' + $ref: '../model/components.schema.yaml#/components/schemas/TimelineResponse' required: - data 403: diff --git a/x-pack/plugins/security_solution/common/api/timeline/create_timelines/create_timelines_route.gen.ts b/x-pack/plugins/security_solution/common/api/timeline/create_timelines/create_timelines_route.gen.ts new file mode 100644 index 0000000000000..98a99edfc3d31 --- /dev/null +++ b/x-pack/plugins/security_solution/common/api/timeline/create_timelines/create_timelines_route.gen.ts @@ -0,0 +1,43 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { z } from 'zod'; + +/* + * NOTICE: Do not edit this file manually. + * This file is automatically generated by the OpenAPI Generator, @kbn/openapi-generator. + */ + +import { + TimelineStatus, + TimelineType, + SavedTimeline, + TimelineResponse, +} from '../model/components.gen'; + +export type CreateTimelinesRequestBody = z.infer; +export const CreateTimelinesRequestBody = z.object({ + status: TimelineStatus.nullable().optional(), + timelineId: z.string().nullable().optional(), + templateTimelineId: z.string().nullable().optional(), + templateTimelineVersion: z.number().nullable().optional(), + timelineType: TimelineType.nullable().optional(), + version: z.string().nullable().optional(), + timeline: SavedTimeline, +}); +export type CreateTimelinesRequestBodyInput = z.input; + +export type CreateTimelinesResponse = z.infer; +export const CreateTimelinesResponse = z.object({ + data: z.object({ + persistTimeline: z + .object({ + timeline: TimelineResponse.optional(), + }) + .optional(), + }), +}); diff --git a/x-pack/plugins/security_solution/common/api/timeline/create_timelines/create_timelines_route_schema.yaml b/x-pack/plugins/security_solution/common/api/timeline/create_timelines/create_timelines_route.schema.yaml similarity index 80% rename from x-pack/plugins/security_solution/common/api/timeline/create_timelines/create_timelines_route_schema.yaml rename to x-pack/plugins/security_solution/common/api/timeline/create_timelines/create_timelines_route.schema.yaml index 8c4585c83926a..877ffafb42372 100644 --- a/x-pack/plugins/security_solution/common/api/timeline/create_timelines/create_timelines_route_schema.yaml +++ b/x-pack/plugins/security_solution/common/api/timeline/create_timelines/create_timelines_route.schema.yaml @@ -1,7 +1,7 @@ openapi: 3.0.0 info: title: Elastic Security - Timeline - Create Timelines API - version: 8.9.0 + version: '2023-10-31' externalDocs: url: https://www.elastic.co/guide/en/security/current/timeline-api-create.html description: Documentation @@ -15,7 +15,8 @@ servers: paths: /api/timeline: post: - operationId: createTimelines + operationId: CreateTimelines + x-codegen-enabled: true description: Creates a new timeline. tags: - access:securitySolution @@ -31,8 +32,8 @@ paths: properties: status: allOf: - - $ref: '../model/components.yaml#/components/schemas/TimelineStatus' - - nullable: true + $ref: '../model/components.schema.yaml#/components/schemas/TimelineStatus' + nullable: true timelineId: type: string nullable: true @@ -44,13 +45,13 @@ paths: nullable: true timelineType: allOf: - - $ref: '../model/components.yaml#/components/schemas/TimelineType' - - nullable: true + $ref: '../model/components.schema.yaml#/components/schemas/TimelineType' + nullable: true version: type: string nullable: true timeline: - $ref: '../model/components.yaml#/components/schemas/SavedTimeline' + $ref: '../model/components.schema.yaml#/components/schemas/SavedTimeline' responses: 200: description: Indicates the timeline was successfully created. @@ -66,7 +67,7 @@ paths: type: object properties: timeline: - $ref: '../model/components.yaml#/components/schemas/TimelineResponse' + $ref: '../model/components.schema.yaml#/components/schemas/TimelineResponse' required: - data 405: diff --git a/x-pack/plugins/security_solution/common/api/timeline/delete_note/delete_note_route.gen.ts b/x-pack/plugins/security_solution/common/api/timeline/delete_note/delete_note_route.gen.ts new file mode 100644 index 0000000000000..ac46b5015650b --- /dev/null +++ b/x-pack/plugins/security_solution/common/api/timeline/delete_note/delete_note_route.gen.ts @@ -0,0 +1,19 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { z } from 'zod'; + +/* + * NOTICE: Do not edit this file manually. + * This file is automatically generated by the OpenAPI Generator, @kbn/openapi-generator. + */ + +export type DeleteNoteRequestBody = z.infer; +export const DeleteNoteRequestBody = z.object({ + noteId: z.string().nullable().optional(), +}); +export type DeleteNoteRequestBodyInput = z.input; diff --git a/x-pack/plugins/security_solution/common/api/timeline/delete_note/delete_note_route_schema.yaml b/x-pack/plugins/security_solution/common/api/timeline/delete_note/delete_note_route.schema.yaml similarity index 89% rename from x-pack/plugins/security_solution/common/api/timeline/delete_note/delete_note_route_schema.yaml rename to x-pack/plugins/security_solution/common/api/timeline/delete_note/delete_note_route.schema.yaml index e05666a3319a8..cfe4566f4d7fb 100644 --- a/x-pack/plugins/security_solution/common/api/timeline/delete_note/delete_note_route_schema.yaml +++ b/x-pack/plugins/security_solution/common/api/timeline/delete_note/delete_note_route.schema.yaml @@ -1,7 +1,7 @@ openapi: 3.0.0 info: title: Elastic Security - Timeline - Notes API - version: 8.9.0 + version: '2023-10-31' servers: - url: 'http://{kibana_host}:{port}' variables: @@ -12,7 +12,8 @@ servers: paths: /api/note: delete: - operationId: deleteNote + operationId: DeleteNote + x-codegen-enabled: true description: Deletes a note from a timeline. tags: - access:securitySolution diff --git a/x-pack/plugins/security_solution/common/api/timeline/delete_timelines/delete_timelines_route_schema.yaml b/x-pack/plugins/security_solution/common/api/timeline/delete_timelines/delete_timelines_route_schema.yaml index dba0471992729..3acc7c67a1ef6 100644 --- a/x-pack/plugins/security_solution/common/api/timeline/delete_timelines/delete_timelines_route_schema.yaml +++ b/x-pack/plugins/security_solution/common/api/timeline/delete_timelines/delete_timelines_route_schema.yaml @@ -1,7 +1,7 @@ openapi: 3.0.0 info: title: Elastic Security - Timeline - Delete Timelines API - version: 8.9.0 + version: '2023-10-31' externalDocs: url: https://www.elastic.co/guide/en/security/current/timeline-api-delete.html description: Documentation @@ -15,7 +15,8 @@ servers: paths: /api/timeline: delete: - operationId: deleteTimelines + operationId: DeleteTimelines + x-codegen-enabled: true description: Deletes one or more timelines or timeline templates. tags: - access:securitySolution diff --git a/x-pack/plugins/security_solution/common/api/timeline/export_timelines/export_timelines_route.gen.ts b/x-pack/plugins/security_solution/common/api/timeline/export_timelines/export_timelines_route.gen.ts new file mode 100644 index 0000000000000..0df4a48ffc31b --- /dev/null +++ b/x-pack/plugins/security_solution/common/api/timeline/export_timelines/export_timelines_route.gen.ts @@ -0,0 +1,28 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { z } from 'zod'; + +/* + * NOTICE: Do not edit this file manually. + * This file is automatically generated by the OpenAPI Generator, @kbn/openapi-generator. + */ + +export type ExportTimelinesRequestQuery = z.infer; +export const ExportTimelinesRequestQuery = z.object({ + /** + * The name of the file to export + */ + file_name: z.string().optional(), +}); +export type ExportTimelinesRequestQueryInput = z.input; + +export type ExportTimelinesRequestBody = z.infer; +export const ExportTimelinesRequestBody = z.object({ + ids: z.array(z.string()).nullable().optional(), +}); +export type ExportTimelinesRequestBodyInput = z.input; diff --git a/x-pack/plugins/security_solution/common/api/timeline/export_timelines/export_timelines_route_schema.yaml b/x-pack/plugins/security_solution/common/api/timeline/export_timelines/export_timelines_route.schema.yaml similarity index 94% rename from x-pack/plugins/security_solution/common/api/timeline/export_timelines/export_timelines_route_schema.yaml rename to x-pack/plugins/security_solution/common/api/timeline/export_timelines/export_timelines_route.schema.yaml index c846de607b909..727c6fc807000 100644 --- a/x-pack/plugins/security_solution/common/api/timeline/export_timelines/export_timelines_route_schema.yaml +++ b/x-pack/plugins/security_solution/common/api/timeline/export_timelines/export_timelines_route.schema.yaml @@ -1,7 +1,7 @@ openapi: 3.0.0 info: title: Elastic Security - Timeline - Import Timelines API - version: 8.9.0 + version: '2023-10-31' externalDocs: url: https://www.elastic.co/guide/en/security/current/timeline-api-import.html description: Documentation @@ -15,7 +15,8 @@ servers: paths: /api/timeline/_export: post: - operationId: exportTimelines + operationId: ExportTimelines + x-codegen-enabled: true description: Exports timelines as an NDJSON file tags: - access:securitySolution diff --git a/x-pack/plugins/security_solution/common/api/timeline/get_draft_timelines/get_draft_timelines_route.gen.ts b/x-pack/plugins/security_solution/common/api/timeline/get_draft_timelines/get_draft_timelines_route.gen.ts new file mode 100644 index 0000000000000..fb379767be02b --- /dev/null +++ b/x-pack/plugins/security_solution/common/api/timeline/get_draft_timelines/get_draft_timelines_route.gen.ts @@ -0,0 +1,34 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { z } from 'zod'; + +/* + * NOTICE: Do not edit this file manually. + * This file is automatically generated by the OpenAPI Generator, @kbn/openapi-generator. + */ + +import { TimelineType, TimelineResponse } from '../model/components.gen'; + +export type GetDraftTimelinesRequestQuery = z.infer; +export const GetDraftTimelinesRequestQuery = z.object({ + timelineType: TimelineType.optional(), +}); +export type GetDraftTimelinesRequestQueryInput = z.input; + +export type GetDraftTimelinesResponse = z.infer; +export const GetDraftTimelinesResponse = z.object({ + data: z + .object({ + persistTimeline: z + .object({ + timeline: TimelineResponse.optional(), + }) + .optional(), + }) + .optional(), +}); diff --git a/x-pack/plugins/security_solution/common/api/timeline/get_draft_timelines/get_draft_timelines_route_schema.yaml b/x-pack/plugins/security_solution/common/api/timeline/get_draft_timelines/get_draft_timelines_route.schema.yaml similarity index 88% rename from x-pack/plugins/security_solution/common/api/timeline/get_draft_timelines/get_draft_timelines_route_schema.yaml rename to x-pack/plugins/security_solution/common/api/timeline/get_draft_timelines/get_draft_timelines_route.schema.yaml index 722f6c3ad0a53..17fdc11ebfd70 100644 --- a/x-pack/plugins/security_solution/common/api/timeline/get_draft_timelines/get_draft_timelines_route_schema.yaml +++ b/x-pack/plugins/security_solution/common/api/timeline/get_draft_timelines/get_draft_timelines_route.schema.yaml @@ -1,7 +1,7 @@ openapi: 3.0.0 info: title: Elastic Security - Timeline - Get Draft Timelines API - version: 8.9.0 + version: '2023-10-31' externalDocs: url: https://www.elastic.co/guide/en/security/current/_get_timeline_timeline_template_by_savedobjectid.html description: Documentation @@ -15,7 +15,8 @@ servers: paths: /api/timeline/_draft: get: - operationId: getDraftTimelines + operationId: GetDraftTimelines + x-codegen-enabled: true description: Retrieves the draft timeline for the current user. If the user does not have a draft timeline, an empty timeline is returned. tags: - access:securitySolution @@ -23,7 +24,7 @@ paths: - in: query name: timelineType schema: - $ref: '../model/components.yaml#/components/schemas/TimelineType' + $ref: '../model/components.schema.yaml#/components/schemas/TimelineType' responses: 200: description: Indicates that the draft timeline was successfully retrieved. @@ -39,7 +40,7 @@ paths: type: object properties: timeline: - $ref: '../model/components.yaml#/components/schemas/TimelineResponse' + $ref: '../model/components.schema.yaml#/components/schemas/TimelineResponse' 403: description: If a draft timeline was not found and we attempted to create one, it indicates that the user does not have the required permissions to create a draft timeline. content: diff --git a/x-pack/plugins/security_solution/common/api/timeline/get_timeline/get_timeline_route.gen.ts b/x-pack/plugins/security_solution/common/api/timeline/get_timeline/get_timeline_route.gen.ts new file mode 100644 index 0000000000000..902bef7eaf530 --- /dev/null +++ b/x-pack/plugins/security_solution/common/api/timeline/get_timeline/get_timeline_route.gen.ts @@ -0,0 +1,35 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { z } from 'zod'; + +/* + * NOTICE: Do not edit this file manually. + * This file is automatically generated by the OpenAPI Generator, @kbn/openapi-generator. + */ + +import { TimelineResponse } from '../model/components.gen'; + +export type GetTimelineRequestQuery = z.infer; +export const GetTimelineRequestQuery = z.object({ + /** + * The ID of the template timeline to retrieve + */ + template_timeline_id: z.string().optional(), + /** + * The ID of the timeline to retrieve + */ + id: z.string().optional(), +}); +export type GetTimelineRequestQueryInput = z.input; + +export type GetTimelineResponse = z.infer; +export const GetTimelineResponse = z.object({ + data: z.object({ + getOneTimeline: TimelineResponse.nullable().optional(), + }), +}); diff --git a/x-pack/plugins/security_solution/common/api/timeline/get_timeline/get_timeline_route_schema.yaml b/x-pack/plugins/security_solution/common/api/timeline/get_timeline/get_timeline_route.schema.yaml similarity index 86% rename from x-pack/plugins/security_solution/common/api/timeline/get_timeline/get_timeline_route_schema.yaml rename to x-pack/plugins/security_solution/common/api/timeline/get_timeline/get_timeline_route.schema.yaml index 9415a8ce2b60c..b19482630b05b 100644 --- a/x-pack/plugins/security_solution/common/api/timeline/get_timeline/get_timeline_route_schema.yaml +++ b/x-pack/plugins/security_solution/common/api/timeline/get_timeline/get_timeline_route.schema.yaml @@ -1,7 +1,7 @@ openapi: 3.0.0 info: title: Elastic Security - Timeline - Get Timeline API - version: 8.9.0 + version: '2023-10-31' externalDocs: url: https://www.elastic.co/guide/en/security/current/_get_timeline_timeline_template_by_savedobjectid.html description: Documentation @@ -15,7 +15,8 @@ servers: paths: /api/timeline: get: - operationId: getTimeline + operationId: GetTimeline + x-codegen-enabled: true description: Get an existing saved timeline or timeline template. This API is used to retrieve an existing saved timeline or timeline template. tags: - access:securitySolution @@ -43,7 +44,7 @@ paths: properties: getOneTimeline: oneOf: - - $ref: '../model/components.yaml#/components/schemas/TimelineResponse' - - nullable: true + $ref: '../model/components.schema.yaml#/components/schemas/TimelineResponse' + nullable: true required: - data \ No newline at end of file diff --git a/x-pack/plugins/security_solution/common/api/timeline/get_timelines/get_timelines_route.gen.ts b/x-pack/plugins/security_solution/common/api/timeline/get_timelines/get_timelines_route.gen.ts new file mode 100644 index 0000000000000..0850aa09c6636 --- /dev/null +++ b/x-pack/plugins/security_solution/common/api/timeline/get_timelines/get_timelines_route.gen.ts @@ -0,0 +1,49 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { z } from 'zod'; + +/* + * NOTICE: Do not edit this file manually. + * This file is automatically generated by the OpenAPI Generator, @kbn/openapi-generator. + */ + +import { + TimelineType, + SortFieldTimeline, + TimelineStatus, + TimelineResponse, +} from '../model/components.gen'; + +export type GetTimelinesRequestQuery = z.infer; +export const GetTimelinesRequestQuery = z.object({ + /** + * If true, only timelines that are marked as favorites by the user are returned. + */ + only_user_favorite: z.enum(['true', 'false']).nullable().optional(), + timeline_type: TimelineType.nullable().optional(), + sort_field: SortFieldTimeline.optional(), + sort_order: z.enum(['asc', 'desc']).optional(), + page_size: z.string().nullable().optional(), + page_index: z.string().nullable().optional(), + search: z.string().nullable().optional(), + status: TimelineStatus.nullable().optional(), +}); +export type GetTimelinesRequestQueryInput = z.input; + +export type GetTimelinesResponse = z.infer; +export const GetTimelinesResponse = z.object({ + data: z.object({ + timelines: z.array(TimelineResponse).optional(), + totalCount: z.number().optional(), + defaultTimelineCount: z.number().optional(), + templateTimelineCount: z.number().optional(), + favoriteCount: z.number().optional(), + elasticTemplateTimelineCount: z.number().optional(), + customTemplateTimelineCount: z.number().optional(), + }), +}); diff --git a/x-pack/plugins/security_solution/common/api/timeline/get_timelines/get_timelines_route_schema.yaml b/x-pack/plugins/security_solution/common/api/timeline/get_timelines/get_timelines_route.schema.yaml similarity index 85% rename from x-pack/plugins/security_solution/common/api/timeline/get_timelines/get_timelines_route_schema.yaml rename to x-pack/plugins/security_solution/common/api/timeline/get_timelines/get_timelines_route.schema.yaml index ac501f0d7729e..3d6cc9e2bf0f0 100644 --- a/x-pack/plugins/security_solution/common/api/timeline/get_timelines/get_timelines_route_schema.yaml +++ b/x-pack/plugins/security_solution/common/api/timeline/get_timelines/get_timelines_route.schema.yaml @@ -1,7 +1,7 @@ openapi: 3.0.0 info: title: Elastic Security - Timeline - Get Timelines API - version: 8.9.0 + version: '2023-10-31' externalDocs: url: https://www.elastic.co/guide/en/security/current/timeline-api-get.html description: Documentation @@ -15,7 +15,8 @@ servers: paths: /api/timelines: get: - operationId: getTimelines + operationId: GetTimelines + x-codegen-enabled: true description: This API is used to retrieve a list of existing saved timelines or timeline templates. tags: - access:securitySolution @@ -32,13 +33,12 @@ paths: - in: query name: timeline_type schema: - allOf: - - $ref: '../model/components.yaml#/components/schemas/TimelineType' - - nullable: true + $ref: '../model/components.schema.yaml#/components/schemas/TimelineType' + nullable: true - in: query name: sort_field schema: - $ref: '../model/components.yaml#/components/schemas/SortFieldTimeline' + $ref: '../model/components.schema.yaml#/components/schemas/SortFieldTimeline' - in: query name: sort_order schema: @@ -64,9 +64,8 @@ paths: - in: query name: status schema: - allOf: - - $ref: '../model/components.yaml#/components/schemas/TimelineStatus' - - nullable: true + $ref: '../model/components.schema.yaml#/components/schemas/TimelineStatus' + nullable: true responses: 200: description: Indicates that the draft timeline was successfully created. In the event the user already has a draft timeline, the existing draft timeline is cleared and returned. @@ -81,7 +80,7 @@ paths: timelines: type: array items: - $ref: '../model/components.yaml#/components/schemas/TimelineResponse' + $ref: '../model/components.schema.yaml#/components/schemas/TimelineResponse' totalCount: type: number defaultTimelineCount: diff --git a/x-pack/plugins/security_solution/common/api/timeline/import_timelines/import_timelines_route.gen.ts b/x-pack/plugins/security_solution/common/api/timeline/import_timelines/import_timelines_route.gen.ts new file mode 100644 index 0000000000000..cc6074a2f97df --- /dev/null +++ b/x-pack/plugins/security_solution/common/api/timeline/import_timelines/import_timelines_route.gen.ts @@ -0,0 +1,35 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { z } from 'zod'; + +/* + * NOTICE: Do not edit this file manually. + * This file is automatically generated by the OpenAPI Generator, @kbn/openapi-generator. + */ + +import { Readable, ImportTimelineResult } from '../model/components.gen'; + +export type ImportTimelinesRequestBody = z.infer; +export const ImportTimelinesRequestBody = z.object({ + file: Readable.and( + z.object({ + hapi: z + .object({ + filename: z.string().optional(), + headers: z.object({}).optional(), + }) + .optional(), + }) + ), +}); +export type ImportTimelinesRequestBodyInput = z.input; + +export type ImportTimelinesResponse = z.infer; +export const ImportTimelinesResponse = z.object({ + data: ImportTimelineResult, +}); diff --git a/x-pack/plugins/security_solution/common/api/timeline/import_timelines/import_timelines_route_schema.yaml b/x-pack/plugins/security_solution/common/api/timeline/import_timelines/import_timelines_route.schema.yaml similarity index 77% rename from x-pack/plugins/security_solution/common/api/timeline/import_timelines/import_timelines_route_schema.yaml rename to x-pack/plugins/security_solution/common/api/timeline/import_timelines/import_timelines_route.schema.yaml index d12a9ca1b9210..a13e4b12743dc 100644 --- a/x-pack/plugins/security_solution/common/api/timeline/import_timelines/import_timelines_route_schema.yaml +++ b/x-pack/plugins/security_solution/common/api/timeline/import_timelines/import_timelines_route.schema.yaml @@ -1,7 +1,7 @@ openapi: 3.0.0 info: title: Elastic Security - Timeline - Import Timelines API - version: 8.9.0 + version: '2023-10-31' externalDocs: url: https://www.elastic.co/guide/en/security/current/timeline-api-import.html description: Documentation @@ -15,7 +15,8 @@ servers: paths: /api/timeline/_import: post: - operationId: importTimelines + operationId: ImportTimelines + x-codegen-enabled: true description: Imports timelines. tags: - access:securitySolution @@ -28,17 +29,17 @@ paths: type: object properties: file: - type: object allOf: - - $ref: '../model/components.yaml#/components/schemas/Readable' - - properties: - hapi: - type: object - properties: - filename: - type: string - headers: - type: object + - $ref: '../model/components.schema.yaml#/components/schemas/Readable' + - type: object + properties: + hapi: + type: object + properties: + filename: + type: string + headers: + type: object responses: 200: description: Indicates the import of timelines was successful. @@ -48,7 +49,7 @@ paths: type: object properties: data: - $ref: '../model/components.yaml#/components/schemas/ImportTimelineResult' + $ref: '../model/components.schema.yaml#/components/schemas/ImportTimelineResult' required: - data @@ -89,4 +90,4 @@ paths: body: type: string statusCode: - type: number \ No newline at end of file + type: number diff --git a/x-pack/plugins/security_solution/common/api/timeline/install_prepackaged_timelines/install_prepackaged_timelines_route_schema.yaml b/x-pack/plugins/security_solution/common/api/timeline/install_prepackaged_timelines/install_prepackaged_timelines_route_schema.yaml index ffad91cab9635..86a76766e4cee 100644 --- a/x-pack/plugins/security_solution/common/api/timeline/install_prepackaged_timelines/install_prepackaged_timelines_route_schema.yaml +++ b/x-pack/plugins/security_solution/common/api/timeline/install_prepackaged_timelines/install_prepackaged_timelines_route_schema.yaml @@ -1,7 +1,7 @@ openapi: 3.0.0 info: title: Elastic Security - Timeline - Install Prepackaged Timelines API - version: 8.9.0 + version: '2023-10-31' servers: - url: 'http://{kibana_host}:{port}' variables: @@ -12,7 +12,8 @@ servers: paths: /api/timeline/_prepackaged: post: - operationId: installPrepackedTimelines + operationId: InstallPrepackedTimelines + x-codegen-enabled: true description: Installs prepackaged timelines. tags: - access:securitySolution @@ -28,18 +29,18 @@ paths: type: array items: allOf: - - $ref: '../model/components.yaml#/components/schemas/ImportTimelines' - - nullable: true + $ref: '../model/components.schema.yaml#/components/schemas/ImportTimelines' + nullable: true timelinesToUpdate: type: array items: allOf: - - $ref: '../model/components.yaml#/components/schemas/ImportTimelines' - - nullable: true + $ref: '../model/components.schema.yaml#/components/schemas/ImportTimelines' + nullable: true prepackagedTimelines: type: array items: - $ref: '../model/components.yaml#/components/schemas/SavedTimeline' + $ref: '../model/components.schema.yaml#/components/schemas/SavedTimeline' responses: 200: description: Indicates the installation of prepackaged timelines was successful. @@ -49,7 +50,7 @@ paths: type: object properties: data: - $ref: '../model/components.yaml#/components/schemas/ImportTimelineResult' + $ref: '../model/components.schema.yaml#/components/schemas/ImportTimelineResult' required: - data 500: diff --git a/x-pack/plugins/security_solution/common/api/timeline/model/components.gen.ts b/x-pack/plugins/security_solution/common/api/timeline/model/components.gen.ts new file mode 100644 index 0000000000000..9a70053876586 --- /dev/null +++ b/x-pack/plugins/security_solution/common/api/timeline/model/components.gen.ts @@ -0,0 +1,325 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { z } from 'zod'; + +/* + * NOTICE: Do not edit this file manually. + * This file is automatically generated by the OpenAPI Generator, @kbn/openapi-generator. + */ + +export type PinnedEvent = z.infer; +export const PinnedEvent = z.object({ + pinnedEventId: z.string().optional(), + eventId: z.string().optional(), + timelineId: z.string().optional(), + created: z.number().optional(), + createdBy: z.string().optional(), + updated: z.number().optional(), + updatedBy: z.string().optional(), + version: z.string().optional(), + timelineVersion: z.string().optional(), +}); + +export type Sort = z.infer; +export const Sort = z.object({ + columnId: z.string().optional(), + sortDirection: z.string().optional(), +}); + +export type BareNote = z.infer; +export const BareNote = z.object({ + eventId: z.string().optional(), + note: z.string().optional(), + timelineId: z.string().optional(), + created: z.number().optional(), + createdBy: z.string().optional(), + updated: z.number().optional(), + updatedBy: z.string().optional(), +}); + +export type Note = z.infer; +export const Note = BareNote.and( + z.object({ + noteId: z.string().optional(), + version: z.string().optional(), + timelineVersion: z.string().nullable().optional(), + }) +); + +export type GlobalNote = z.infer; +export const GlobalNote = z.object({ + noteId: z.string().optional(), + version: z.string().optional(), + timelineVersion: z.string().nullable().optional(), + note: z.string().optional(), + timelineId: z.string().optional(), + created: z.number().optional(), + createdBy: z.string().optional(), + updated: z.number().optional(), + updatedBy: z.string().optional(), +}); + +/** + * The status of the timeline. Valid values are `active`, `draft`, and `immutable`. + */ +export type TimelineStatus = z.infer; +export const TimelineStatus = z.enum(['active', 'draft', 'immutable']); +export type TimelineStatusEnum = typeof TimelineStatus.enum; +export const TimelineStatusEnum = TimelineStatus.enum; + +/** + * The type of data provider to create. Valid values are `default` and `template`. + */ +export type DataProviderType = z.infer; +export const DataProviderType = z.enum(['default', 'template']); +export type DataProviderTypeEnum = typeof DataProviderType.enum; +export const DataProviderTypeEnum = DataProviderType.enum; + +export type RowRendererId = z.infer; +export const RowRendererId = z.enum([ + 'alert', + 'alerts', + 'auditd', + 'auditd_file', + 'library', + 'netflow', + 'plain', + 'registry', + 'suricata', + 'system', + 'system_dns', + 'system_endgame_process', + 'system_file', + 'system_fim', + 'system_security_event', + 'system_socket', + 'threat_match', + 'zeek', +]); +export type RowRendererIdEnum = typeof RowRendererId.enum; +export const RowRendererIdEnum = RowRendererId.enum; + +export type QueryMatchResult = z.infer; +export const QueryMatchResult = z.object({ + field: z.string().optional(), + displayField: z.string().optional(), + value: z.string().optional(), + displayValue: z.string().optional(), + operator: z.string().optional(), +}); + +export type DataProviderResult = z.infer; +export const DataProviderResult = z.object({ + id: z.string().optional(), + name: z.string().optional(), + enabled: z.boolean().optional(), + excluded: z.boolean().optional(), + kqlQuery: z.string().optional(), + queryMatch: QueryMatchResult.optional(), + and: z.array(DataProviderResult).optional(), + type: DataProviderType.optional(), +}); + +export type FavoriteTimelineResult = z.infer; +export const FavoriteTimelineResult = z.object({ + fullName: z.string().optional(), + userName: z.string().optional(), + favoriteDate: z.number().optional(), +}); + +export type FilterTimelineResult = z.infer; +export const FilterTimelineResult = z.object({ + exists: z.boolean().optional(), + meta: z + .object({ + alias: z.string().optional(), + controlledBy: z.string().optional(), + disabled: z.boolean().optional(), + field: z.string().optional(), + formattedValue: z.string().optional(), + index: z.string().optional(), + key: z.string().optional(), + negate: z.boolean().optional(), + params: z.string().optional(), + type: z.string().optional(), + value: z.string().optional(), + }) + .optional(), + match_all: z.string().optional(), + missing: z.string().optional(), + query: z.string().optional(), + range: z.string().optional(), + script: z.string().optional(), +}); + +export type SerializedFilterQueryResult = z.infer; +export const SerializedFilterQueryResult = z.object({ + filterQuery: z + .object({ + kuery: z + .object({ + kind: z.string().optional(), + expression: z.string().optional(), + }) + .optional(), + serializedQuery: z.string().optional(), + }) + .optional(), +}); + +/** + * The field to sort the timelines by. + */ +export type SortFieldTimeline = z.infer; +export const SortFieldTimeline = z.object({ + title: z.string().optional(), + description: z.string().optional(), + updated: z.string().optional(), + created: z.string().optional(), +}); + +export type ColumnHeaderResult = z.infer; +export const ColumnHeaderResult = z.object({ + aggregatable: z.boolean().optional(), + category: z.string().optional(), + columnHeaderType: z.string().optional(), + description: z.string().optional(), + example: z.union([z.string(), z.number()]).optional(), + indexes: z.array(z.string()).optional(), + id: z.string().optional(), + name: z.string().optional(), + placeholder: z.string().optional(), + searchable: z.boolean().optional(), + type: z.string().optional(), +}); + +/** + * The type of timeline to create. Valid values are `default` and `template`. + */ +export type TimelineType = z.infer; +export const TimelineType = z.enum(['default', 'template']); +export type TimelineTypeEnum = typeof TimelineType.enum; +export const TimelineTypeEnum = TimelineType.enum; + +export type SavedTimeline = z.infer; +export const SavedTimeline = z.object({ + columns: ColumnHeaderResult.optional(), + created: z.number().optional(), + createdBy: z.string().optional(), + dataProviders: z.array(DataProviderResult).optional(), + dataViewId: z.string().optional(), + dateRange: z + .object({ + end: z.union([z.string(), z.number()]).optional(), + start: z.union([z.string(), z.number()]).optional(), + }) + .optional(), + description: z.string().optional(), + eqlOptions: z + .object({ + eventCategoryField: z.string().optional(), + tiebreakerField: z.string().optional(), + timestampField: z.string().optional(), + }) + .optional(), + eventType: z.string().optional(), + excludedRowRendererIds: z.array(RowRendererId).optional(), + favorite: z.array(FavoriteTimelineResult).optional(), + filters: z.array(FilterTimelineResult).optional(), + kqlMode: z.string().optional(), + kqlQuery: SerializedFilterQueryResult.optional(), + indexNames: z.array(z.string()).optional(), + savedQueryId: z.string().optional(), + sort: Sort.optional(), + status: z.enum(['active', 'draft', 'immutable']).optional(), + title: z.string().optional(), + templateTimelineId: z.string().optional(), + templateTimelineVersion: z.number().optional(), + timelineType: TimelineType.optional(), + updated: z.number().optional(), + updatedBy: z.string().optional(), +}); + +export type TimelineResponse = z.infer; +export const TimelineResponse = SavedTimeline.and( + z.object({ + eventIdToNoteIds: z.array(Note).optional(), + notes: z.array(Note).optional(), + noteIds: z.array(z.string()).optional(), + pinnedEventIds: z.array(z.string()).optional(), + pinnedEventsSaveObject: z.array(PinnedEvent).optional(), + savedObjectId: z.string(), + version: z.string(), + }) +); + +export type FavoriteTimelineResponse = z.infer; +export const FavoriteTimelineResponse = z.object({ + savedObjectId: z.string(), + version: z.string(), + code: z.number().nullable().optional(), + message: z.string().nullable().optional(), + templateTimelineId: z.string().nullable().optional(), + templateTimelineVersion: z.number().nullable().optional(), + timelineType: TimelineType.optional(), + favorite: z.array(FavoriteTimelineResult).optional(), +}); + +export type ImportTimelines = z.infer; +export const ImportTimelines = SavedTimeline.and( + z.object({ + savedObjectId: z.string().nullable().optional(), + version: z.string().nullable().optional(), + globalNotes: z.array(BareNote).nullable().optional(), + eventNotes: z.array(BareNote).nullable().optional(), + pinnedEventIds: z.array(z.string()).nullable().optional(), + }) +); + +export type ImportTimelineResult = z.infer; +export const ImportTimelineResult = z.object({ + success: z.boolean().optional(), + success_count: z.number().optional(), + timelines_installed: z.number().optional(), + timelines_updated: z.number().optional(), + errors: z + .array( + z.object({ + id: z.string().optional(), + error: z + .object({ + message: z.string().optional(), + status_code: z.number().optional(), + }) + .optional(), + }) + ) + .optional(), +}); + +export type ExportedTimelines = z.infer; +export const ExportedTimelines = SavedTimeline.and( + z.object({ + globalNotes: z.array(Note).optional(), + eventNotes: z.array(Note).optional(), + pinnedEventIds: z.array(z.string()).optional(), + }) +); + +export type Readable = z.infer; +export const Readable = z.object({ + _maxListeners: z.object({}).optional(), + _readableState: z.object({}).optional(), + _read: z.object({}).optional(), + readable: z.boolean().optional(), + _events: z.object({}).optional(), + _eventsCount: z.number().optional(), + _data: z.object({}).optional(), + _position: z.number().optional(), + _encoding: z.string().optional(), +}); diff --git a/x-pack/plugins/security_solution/common/api/timeline/model/components.yaml b/x-pack/plugins/security_solution/common/api/timeline/model/components.schema.yaml similarity index 96% rename from x-pack/plugins/security_solution/common/api/timeline/model/components.yaml rename to x-pack/plugins/security_solution/common/api/timeline/model/components.schema.yaml index 3ecd8d7f153ed..2e06812b745e0 100644 --- a/x-pack/plugins/security_solution/common/api/timeline/model/components.yaml +++ b/x-pack/plugins/security_solution/common/api/timeline/model/components.schema.yaml @@ -1,223 +1,38 @@ +openapi: 3.0.0 +info: + title: Common Timeline Attributes + version: '2023-10-31' +paths: { } components: schemas: - TimelineType: - type: string - enum: - - default - - template - default: default - description: The type of timeline to create. Valid values are `default` and `template`. - DataProviderType: - type: string - enum: - - default - - template - default: default - description: The type of data provider to create. Valid values are `default` and `template`. - SavedTimeline: + PinnedEvent: type: object properties: - columns: - $ref: '#/components/schemas/ColumnHeaderResult' - created: - type: number - createdBy: - type: string - dataProviders: - type: array - items: - $ref: '#/components/schemas/DataProviderResult' - dataViewId: - type: string - dateRange: - type: object - properties: - end: - oneOf: - - type: string - - type: number - start: - oneOf: - - type: string - - type: number - description: - type: string - eqlOptions: - type: object - properties: - eventCategoryField: - type: string - tiebreakerField: - type: string - timestampField: - type: string - eventType: - type: string - excludedRowRendererIds: - type: array - items: - $ref: '#/components/schemas/RowRendererId' - favorite: - type: array - items: - $ref: '#/components/schemas/FavoriteTimelineResult' - filters: - type: array - items: - $ref: '#/components/schemas/FilterTimelineResult' - kqlMode: - type: string - kqlQuery: - $ref: '#/components/schemas/SerializedFilterQueryResult' - indexNames: - type: array - items: - type: string - savedQueryId: - type: string - sort: - $ref: '#/components/schemas/Sort' - status: + pinnedEventId: type: string - enum: - - active - - draft - - immutable - title: + eventId: type: string - templateTimelineId: + timelineId: type: string - templateTimelineVersion: + created: type: number - timelineType: - $ref: '#/components/schemas/TimelineType' + createdBy: + type: string updated: type: number updatedBy: type: string - TimelineResponse: - allOf: - - $ref: '#/components/schemas/SavedTimeline' - - type: object - required: - - savedObjectId - - version - properties: - eventIdToNoteIds: - type: array - items: - $ref: '#/components/schemas/Note' - notes: - type: array - items: - $ref: '#/components/schemas/Note' - noteIds: - type: array - items: - type: string - pinnedEventIds: - type: array - items: - type: string - pinnedEventsSaveObject: - type: array - items: - $ref: '#/components/schemas/PinnedEvent' - savedObjectId: - type: string - version: - type: string - FavoriteTimelineResponse: - type: object - required: - - savedObjectId - - version - properties: - savedObjectId: - type: string version: type: string - code: - type: number - nullable: true - message: - type: string - nullable: true - templateTimelineId: - type: string - nullable: true - templateTimelineVersion: - type: number - nullable: true - timelineType: - $ref: '#/components/schemas/TimelineType' - favorite: - type: array - items: - $ref: '#/components/schemas/FavoriteTimelineResult' - ColumnHeaderResult: - type: object - properties: - aggregatable: - type: boolean - category: - type: string - columnHeaderType: - type: string - description: - type: string - example: - oneOf: - - type: string - - type: number - indexes: - type: array - items: - type: string - id: - type: string - name: - type: string - placeholder: - type: string - searchable: - type: boolean - type: - type: string - QueryMatchResult: - type: object - properties: - field: - type: string - displayField: - type: string - value: - type: string - displayValue: - type: string - operator: + timelineVersion: type: string - DataProviderResult: + Sort: type: object properties: - id: - type: string - name: + columnId: type: string - enabled: - type: boolean - excluded: - type: boolean - kqlQuery: + sortDirection: type: string - queryMatch: - $ref: '#/components/schemas/QueryMatchResult' - and: - type: array - items: - $ref: '#/components/schemas/DataProviderResult' - type: - $ref: '#/components/schemas/DataProviderType' BareNote: type: object properties: @@ -268,18 +83,20 @@ components: updated: type: number updatedBy: - type: string - Note: - allOf: - - $ref: '#/components/schemas/BareNote' - - type: object - properties: - noteId: - type: string - version: - type: string - timelineVersion: - type: string + type: string + TimelineStatus: + type: string + enum: + - active + - draft + - immutable + description: The status of the timeline. Valid values are `active`, `draft`, and `immutable`. + DataProviderType: + type: string + enum: + - default + - template + description: The type of data provider to create. Valid values are `default` and `template`. RowRendererId: type: string enum: @@ -301,6 +118,40 @@ components: - system_socket - threat_match - zeek + QueryMatchResult: + type: object + properties: + field: + type: string + displayField: + type: string + value: + type: string + displayValue: + type: string + operator: + type: string + DataProviderResult: + type: object + properties: + id: + type: string + name: + type: string + enabled: + type: boolean + excluded: + type: boolean + kqlQuery: + type: string + queryMatch: + $ref: '#/components/schemas/QueryMatchResult' + and: + type: array + items: + $ref: '#/components/schemas/DataProviderResult' + type: + $ref: '#/components/schemas/DataProviderType' FavoriteTimelineResult: type: object properties: @@ -365,54 +216,194 @@ components: type: string serializedQuery: type: string - PinnedEvent: + SortFieldTimeline: type: object + description: The field to sort the timelines by. properties: - pinnedEventId: + title: type: string - eventId: + description: type: string - timelineId: + updated: type: string created: - type: number - createdBy: + type: string + ColumnHeaderResult: + type: object + properties: + aggregatable: + type: boolean + category: type: string - updated: - type: number - updatedBy: + columnHeaderType: type: string - version: + description: type: string - timelineVersion: + example: + oneOf: + - type: string + - type: number + indexes: + type: array + items: + type: string + id: type: string - Sort: - type: object - properties: - columnId: + name: type: string - sortDirection: + placeholder: type: string - SortFieldTimeline: + searchable: + type: boolean + type: + type: string + TimelineType: + type: string + enum: + - default + - template + description: The type of timeline to create. Valid values are `default` and `template`. + SavedTimeline: type: object - description: The field to sort the timelines by. properties: - title: + columns: + $ref: '#/components/schemas/ColumnHeaderResult' + created: + type: number + createdBy: type: string + dataProviders: + type: array + items: + $ref: '#/components/schemas/DataProviderResult' + dataViewId: + type: string + dateRange: + type: object + properties: + end: + oneOf: + - type: string + - type: number + start: + oneOf: + - type: string + - type: number description: type: string + eqlOptions: + type: object + properties: + eventCategoryField: + type: string + tiebreakerField: + type: string + timestampField: + type: string + eventType: + type: string + excludedRowRendererIds: + type: array + items: + $ref: '#/components/schemas/RowRendererId' + favorite: + type: array + items: + $ref: '#/components/schemas/FavoriteTimelineResult' + filters: + type: array + items: + $ref: '#/components/schemas/FilterTimelineResult' + kqlMode: + type: string + kqlQuery: + $ref: '#/components/schemas/SerializedFilterQueryResult' + indexNames: + type: array + items: + type: string + savedQueryId: + type: string + sort: + $ref: '#/components/schemas/Sort' + status: + type: string + enum: + - active + - draft + - immutable + title: + type: string + templateTimelineId: + type: string + templateTimelineVersion: + type: number + timelineType: + $ref: '#/components/schemas/TimelineType' updated: + type: number + updatedBy: type: string - created: + TimelineResponse: + allOf: + - $ref: '#/components/schemas/SavedTimeline' + - type: object + required: + - savedObjectId + - version + properties: + eventIdToNoteIds: + type: array + items: + $ref: '#/components/schemas/Note' + notes: + type: array + items: + $ref: '#/components/schemas/Note' + noteIds: + type: array + items: + type: string + pinnedEventIds: + type: array + items: + type: string + pinnedEventsSaveObject: + type: array + items: + $ref: '#/components/schemas/PinnedEvent' + savedObjectId: + type: string + version: + type: string + FavoriteTimelineResponse: + type: object + required: + - savedObjectId + - version + properties: + savedObjectId: type: string - TimelineStatus: - type: string - enum: - - active - - draft - - immutable - default: draft - description: The status of the timeline. Valid values are `active`, `draft`, and `immutable`. + version: + type: string + code: + type: number + nullable: true + message: + type: string + nullable: true + templateTimelineId: + type: string + nullable: true + templateTimelineVersion: + type: number + nullable: true + timelineType: + $ref: '#/components/schemas/TimelineType' + favorite: + type: array + items: + $ref: '#/components/schemas/FavoriteTimelineResult' ImportTimelines: allOf: - $ref: '#/components/schemas/SavedTimeline' @@ -485,19 +476,19 @@ components: type: object properties: _maxListeners: - type: {} + type: object _readableState: - type: {} + type: object _read: - type: {} + type: object readable: type: boolean _events: - type: {} + type: object _eventsCount: type: number _data: - type: {} + type: object _position: type: number _encoding: diff --git a/x-pack/plugins/security_solution/common/api/timeline/patch_timelines/patch_timeline_route.gen.ts b/x-pack/plugins/security_solution/common/api/timeline/patch_timelines/patch_timeline_route.gen.ts new file mode 100644 index 0000000000000..a715475ed424e --- /dev/null +++ b/x-pack/plugins/security_solution/common/api/timeline/patch_timelines/patch_timeline_route.gen.ts @@ -0,0 +1,34 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { z } from 'zod'; + +/* + * NOTICE: Do not edit this file manually. + * This file is automatically generated by the OpenAPI Generator, @kbn/openapi-generator. + */ + +import { SavedTimeline, TimelineResponse } from '../model/components.gen'; + +export type PatchTimelineRequestBody = z.infer; +export const PatchTimelineRequestBody = z.object({ + timelineId: z.string().optional(), + version: z.string().optional(), + timeline: SavedTimeline.optional(), +}); +export type PatchTimelineRequestBodyInput = z.input; + +export type PatchTimelineResponse = z.infer; +export const PatchTimelineResponse = z.object({ + data: z.object({ + persistTimeline: z + .object({ + timeline: TimelineResponse.optional(), + }) + .optional(), + }), +}); diff --git a/x-pack/plugins/security_solution/common/api/timeline/patch_timelines/patch_timeline_route_schema.yaml b/x-pack/plugins/security_solution/common/api/timeline/patch_timelines/patch_timeline_route.schema.yaml similarity index 87% rename from x-pack/plugins/security_solution/common/api/timeline/patch_timelines/patch_timeline_route_schema.yaml rename to x-pack/plugins/security_solution/common/api/timeline/patch_timelines/patch_timeline_route.schema.yaml index 4783e42411973..307d1fb1eda86 100644 --- a/x-pack/plugins/security_solution/common/api/timeline/patch_timelines/patch_timeline_route_schema.yaml +++ b/x-pack/plugins/security_solution/common/api/timeline/patch_timelines/patch_timeline_route.schema.yaml @@ -1,7 +1,7 @@ openapi: 3.0.0 info: title: Elastic Security - Timeline - Patch Timeline API - version: 8.9.0 + version: '2023-10-31' servers: - url: 'http://{kibana_host}:{port}' variables: @@ -12,7 +12,8 @@ servers: paths: /api/timeline: patch: - operationId: patchTimeline + operationId: PatchTimeline + x-codegen-enabled: true summary: Updates an existing timeline. description: Updates an existing timeline. This API is used to update the title, description, date range, pinned events, pinned queries, and/or pinned saved queries of an existing timeline. tags: @@ -30,7 +31,7 @@ paths: version: type: string timeline: - $ref: '../model/components.yaml#/components/schemas/SavedTimeline' + $ref: '../model/components.schema.yaml#/components/schemas/SavedTimeline' responses: 200: description: Indicates that the draft timeline was successfully created. In the event the user already has a draft timeline, the existing draft timeline is cleared and returned. @@ -46,7 +47,7 @@ paths: type: object properties: timeline: - $ref: '../model/components.yaml#/components/schemas/TimelineResponse' + $ref: '../model/components.schema.yaml#/components/schemas/TimelineResponse' required: - data 405: diff --git a/x-pack/plugins/security_solution/common/api/timeline/persist_favorite/persist_favorite_route.gen.ts b/x-pack/plugins/security_solution/common/api/timeline/persist_favorite/persist_favorite_route.gen.ts new file mode 100644 index 0000000000000..98a2f8b810864 --- /dev/null +++ b/x-pack/plugins/security_solution/common/api/timeline/persist_favorite/persist_favorite_route.gen.ts @@ -0,0 +1,31 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { z } from 'zod'; + +/* + * NOTICE: Do not edit this file manually. + * This file is automatically generated by the OpenAPI Generator, @kbn/openapi-generator. + */ + +import { TimelineType, FavoriteTimelineResponse } from '../model/components.gen'; + +export type PersistFavoriteRequestBody = z.infer; +export const PersistFavoriteRequestBody = z.object({ + timelineId: z.string().nullable().optional(), + templateTimelineId: z.string().nullable().optional(), + templateTimelineVersion: z.number().nullable().optional(), + timelineType: TimelineType.nullable().optional(), +}); +export type PersistFavoriteRequestBodyInput = z.input; + +export type PersistFavoriteResponse = z.infer; +export const PersistFavoriteResponse = z.object({ + data: z.object({ + persistFavorite: FavoriteTimelineResponse.optional(), + }), +}); diff --git a/x-pack/plugins/security_solution/common/api/timeline/persist_favorite/persist_favorite_route_schema.yaml b/x-pack/plugins/security_solution/common/api/timeline/persist_favorite/persist_favorite_route.schema.yaml similarity index 85% rename from x-pack/plugins/security_solution/common/api/timeline/persist_favorite/persist_favorite_route_schema.yaml rename to x-pack/plugins/security_solution/common/api/timeline/persist_favorite/persist_favorite_route.schema.yaml index aef8f2b2cf4c1..7cc897af7f12a 100644 --- a/x-pack/plugins/security_solution/common/api/timeline/persist_favorite/persist_favorite_route_schema.yaml +++ b/x-pack/plugins/security_solution/common/api/timeline/persist_favorite/persist_favorite_route.schema.yaml @@ -1,7 +1,7 @@ openapi: 3.0.0 info: title: Elastic Security - Timeline - Favorite API (https://www.elastic.co/guide/en/security/current/timeline-api-delete.html) - version: 8.9.0 + version: '2023-10-31' servers: - url: 'http://{kibana_host}:{port}' variables: @@ -12,7 +12,8 @@ servers: paths: /api/timeline/_favorite: patch: - operationId: persistFavoriteRoute + operationId: PersistFavorite + x-codegen-enabled: true description: Persists a given users favorite status of a timeline. tags: - access:securitySolution @@ -35,8 +36,8 @@ paths: nullable: true timelineType: allOf: - - $ref: '../model/components.yaml#/components/schemas/TimelineType' - - nullable: true + $ref: '../model/components.schema.yaml#/components/schemas/TimelineType' + nullable: true responses: 200: description: Indicates the favorite status was successfully updated. @@ -49,7 +50,7 @@ paths: type: object properties: persistFavorite: - $ref: '../model/components.yaml#/components/schemas/FavoriteTimelineResponse' + $ref: '../model/components.schema.yaml#/components/schemas/FavoriteTimelineResponse' required: - data 403: diff --git a/x-pack/plugins/security_solution/common/api/timeline/persist_note/persist_note_route.gen.ts b/x-pack/plugins/security_solution/common/api/timeline/persist_note/persist_note_route.gen.ts new file mode 100644 index 0000000000000..ca807d04a30dc --- /dev/null +++ b/x-pack/plugins/security_solution/common/api/timeline/persist_note/persist_note_route.gen.ts @@ -0,0 +1,37 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { z } from 'zod'; + +/* + * NOTICE: Do not edit this file manually. + * This file is automatically generated by the OpenAPI Generator, @kbn/openapi-generator. + */ + +import { BareNote, Note } from '../model/components.gen'; + +export type PersistNoteRequestBody = z.infer; +export const PersistNoteRequestBody = z.object({ + note: BareNote, + overrideOwner: z.boolean().nullable().nullable().optional(), + noteId: z.string().nullable().optional(), + version: z.string().nullable().optional(), +}); +export type PersistNoteRequestBodyInput = z.input; + +export type PersistNoteResponse = z.infer; +export const PersistNoteResponse = z.object({ + data: z.object({ + persistNote: z + .object({ + code: z.number().optional(), + message: z.string().optional(), + note: Note.optional(), + }) + .optional(), + }), +}); diff --git a/x-pack/plugins/security_solution/common/api/timeline/persist_note/persist_note_route_schema.yaml b/x-pack/plugins/security_solution/common/api/timeline/persist_note/persist_note_route.schema.yaml similarity index 86% rename from x-pack/plugins/security_solution/common/api/timeline/persist_note/persist_note_route_schema.yaml rename to x-pack/plugins/security_solution/common/api/timeline/persist_note/persist_note_route.schema.yaml index 789d4e97e63f7..9a0e23ae19ef7 100644 --- a/x-pack/plugins/security_solution/common/api/timeline/persist_note/persist_note_route_schema.yaml +++ b/x-pack/plugins/security_solution/common/api/timeline/persist_note/persist_note_route.schema.yaml @@ -1,7 +1,7 @@ openapi: 3.0.0 info: title: Elastic Security - Timeline - Notes API - version: 8.9.0 + version: '2023-10-31' externalDocs: url: https://www.elastic.co/guide/en/security/current/timeline-api-update.html description: Documentation @@ -15,7 +15,8 @@ servers: paths: /api/note: patch: - operationId: persistNoteroute + operationId: PersistNote + x-codegen-enabled: true description: Persists a note to a timeline. tags: - access:securitySolution @@ -30,7 +31,7 @@ paths: - note properties: note: - $ref: '../model/components.yaml#/components/schemas/BareNote' + $ref: '../model/components.schema.yaml#/components/schemas/BareNote' overrideOwner: type: boolean nullable: true @@ -59,6 +60,6 @@ paths: message: type: string note: - $ref: '../model/components.yaml#/components/schemas/Note' + $ref: '../model/components.schema.yaml#/components/schemas/Note' required: - data diff --git a/x-pack/plugins/security_solution/common/api/timeline/pinned_events/pinned_events_route.gen.ts b/x-pack/plugins/security_solution/common/api/timeline/pinned_events/pinned_events_route.gen.ts new file mode 100644 index 0000000000000..d6a28b63d9b88 --- /dev/null +++ b/x-pack/plugins/security_solution/common/api/timeline/pinned_events/pinned_events_route.gen.ts @@ -0,0 +1,35 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { z } from 'zod'; + +/* + * NOTICE: Do not edit this file manually. + * This file is automatically generated by the OpenAPI Generator, @kbn/openapi-generator. + */ + +import { PinnedEvent } from '../model/components.gen'; + +export type PersistPinnedEventRequestBody = z.infer; +export const PersistPinnedEventRequestBody = z.object({ + eventId: z.string(), + pinnedEventId: z.string().nullable().optional(), + timelineId: z.string().nullable().optional(), +}); +export type PersistPinnedEventRequestBodyInput = z.input; + +export type PersistPinnedEventResponse = z.infer; +export const PersistPinnedEventResponse = z.object({ + data: z.object({ + persistPinnedEventOnTimeline: PinnedEvent.and( + z.object({ + code: z.number().optional(), + message: z.string().optional(), + }) + ), + }), +}); diff --git a/x-pack/plugins/security_solution/common/api/timeline/pinned_events/pinned_events_route_schema.yaml b/x-pack/plugins/security_solution/common/api/timeline/pinned_events/pinned_events_route.schema.yaml similarity index 89% rename from x-pack/plugins/security_solution/common/api/timeline/pinned_events/pinned_events_route_schema.yaml rename to x-pack/plugins/security_solution/common/api/timeline/pinned_events/pinned_events_route.schema.yaml index 0d8611bfcab5f..8b1da2cc0d7fe 100644 --- a/x-pack/plugins/security_solution/common/api/timeline/pinned_events/pinned_events_route_schema.yaml +++ b/x-pack/plugins/security_solution/common/api/timeline/pinned_events/pinned_events_route.schema.yaml @@ -1,7 +1,7 @@ openapi: 3.0.0 info: title: Elastic Security - Timeline - Pinned Event API (https://www.elastic.co/guide/en/security/current/_pin_an_event_to_an_existing_timeline.html) - version: 8.9.0 + version: '2023-10-31' servers: - url: 'http://{kibana_host}:{port}' variables: @@ -12,7 +12,8 @@ servers: paths: /api/pinned_event: patch: - operationId: persistPinnedEventRoute + operationId: PersistPinnedEvent + x-codegen-enabled: true description: Persists a pinned event to a timeline. tags: - access:securitySolution @@ -47,7 +48,7 @@ paths: properties: persistPinnedEventOnTimeline: allOf: - - $ref: '../model/components.yaml#/components/schemas/PinnedEvent' + - $ref: '../model/components.schema.yaml#/components/schemas/PinnedEvent' - type: object properties: code: From 0c538ca445f753bf43745e8c34181e9093cb8fb9 Mon Sep 17 00:00:00 2001 From: Michael Olorunnisola Date: Tue, 7 Nov 2023 10:54:48 -0500 Subject: [PATCH 02/15] properly require fields --- .../clean_draft_timelines_route.gen.ts | 10 +++--- .../clean_draft_timelines_route.schema.yaml | 6 ++-- .../create_timelines_route.gen.ts | 20 ++++++------ .../create_timelines_route.schema.yaml | 7 ++-- .../delete_note/delete_note_route.gen.ts | 2 +- .../delete_note/delete_note_route.schema.yaml | 1 + .../delete_timelines_route.gen.ts | 26 +++++++++++++++ ...aml => delete_timelines_route.schema.yaml} | 9 +++--- .../export_timelines_route.gen.ts | 4 +-- .../export_timelines_route.schema.yaml | 2 ++ .../get_draft_timelines_route.gen.ts | 16 ++++------ .../get_draft_timelines_route.schema.yaml | 4 +++ .../get_timeline/get_timeline_route.gen.ts | 4 +-- .../get_timeline_route.schema.yaml | 8 +++-- .../get_timelines/get_timelines_route.gen.ts | 30 ++++++++--------- .../get_timelines_route.schema.yaml | 27 +++++++++++++--- .../import_timelines_route.gen.ts | 10 +++--- .../import_timelines_route.schema.yaml | 5 +-- ...install_prepackaged_timelines_route.gen.ts | 32 +++++++++++++++++++ ...l_prepackaged_timelines_route.schema.yaml} | 4 +-- .../patch_timeline_route.gen.ts | 14 ++++---- .../patch_timeline_route.schema.yaml | 8 +++-- .../persist_favorite_route.gen.ts | 10 +++--- .../persist_favorite_route.schema.yaml | 5 +-- .../persist_note/persist_note_route.gen.ts | 18 +++++------ .../persist_note_route.schema.yaml | 10 +++--- .../pinned_events/pinned_events_route.gen.ts | 4 +-- .../pinned_events_route.schema.yaml | 9 +++--- 28 files changed, 191 insertions(+), 114 deletions(-) create mode 100644 x-pack/plugins/security_solution/common/api/timeline/delete_timelines/delete_timelines_route.gen.ts rename x-pack/plugins/security_solution/common/api/timeline/delete_timelines/{delete_timelines_route_schema.yaml => delete_timelines_route.schema.yaml} (90%) create mode 100644 x-pack/plugins/security_solution/common/api/timeline/install_prepackaged_timelines/install_prepackaged_timelines_route.gen.ts rename x-pack/plugins/security_solution/common/api/timeline/install_prepackaged_timelines/{install_prepackaged_timelines_route_schema.yaml => install_prepackaged_timelines_route.schema.yaml} (94%) diff --git a/x-pack/plugins/security_solution/common/api/timeline/clean_draft_timelines/clean_draft_timelines_route.gen.ts b/x-pack/plugins/security_solution/common/api/timeline/clean_draft_timelines/clean_draft_timelines_route.gen.ts index 5eac8d39582b9..5e80026930d2b 100644 --- a/x-pack/plugins/security_solution/common/api/timeline/clean_draft_timelines/clean_draft_timelines_route.gen.ts +++ b/x-pack/plugins/security_solution/common/api/timeline/clean_draft_timelines/clean_draft_timelines_route.gen.ts @@ -16,17 +16,15 @@ import { TimelineType, TimelineResponse } from '../model/components.gen'; export type CleanDraftTimelinesRequestBody = z.infer; export const CleanDraftTimelinesRequestBody = z.object({ - timelineType: TimelineType.optional(), + timelineType: TimelineType, }); export type CleanDraftTimelinesRequestBodyInput = z.input; export type CleanDraftTimelinesResponse = z.infer; export const CleanDraftTimelinesResponse = z.object({ data: z.object({ - persistTimeline: z - .object({ - timeline: TimelineResponse.optional(), - }) - .optional(), + persistTimeline: z.object({ + timeline: TimelineResponse, + }), }), }); diff --git a/x-pack/plugins/security_solution/common/api/timeline/clean_draft_timelines/clean_draft_timelines_route.schema.yaml b/x-pack/plugins/security_solution/common/api/timeline/clean_draft_timelines/clean_draft_timelines_route.schema.yaml index 7bbc666d731c1..28e7374351457 100644 --- a/x-pack/plugins/security_solution/common/api/timeline/clean_draft_timelines/clean_draft_timelines_route.schema.yaml +++ b/x-pack/plugins/security_solution/common/api/timeline/clean_draft_timelines/clean_draft_timelines_route.schema.yaml @@ -26,6 +26,7 @@ paths: application/json: schema: type: object + required: [timelineType] properties: timelineType: $ref: '../model/components.schema.yaml#/components/schemas/TimelineType' @@ -36,17 +37,18 @@ paths: application/json: schema: type: object + required: [data] properties: data: type: object + required: [persistTimeline] properties: persistTimeline: type: object + required: [timeline] properties: timeline: $ref: '../model/components.schema.yaml#/components/schemas/TimelineResponse' - required: - - data 403: description: Indicates that the user does not have the required permissions to create a draft timeline. content: diff --git a/x-pack/plugins/security_solution/common/api/timeline/create_timelines/create_timelines_route.gen.ts b/x-pack/plugins/security_solution/common/api/timeline/create_timelines/create_timelines_route.gen.ts index 98a99edfc3d31..38aef3e1d733f 100644 --- a/x-pack/plugins/security_solution/common/api/timeline/create_timelines/create_timelines_route.gen.ts +++ b/x-pack/plugins/security_solution/common/api/timeline/create_timelines/create_timelines_route.gen.ts @@ -21,12 +21,12 @@ import { export type CreateTimelinesRequestBody = z.infer; export const CreateTimelinesRequestBody = z.object({ - status: TimelineStatus.nullable().optional(), - timelineId: z.string().nullable().optional(), - templateTimelineId: z.string().nullable().optional(), - templateTimelineVersion: z.number().nullable().optional(), - timelineType: TimelineType.nullable().optional(), - version: z.string().nullable().optional(), + status: TimelineStatus.nullable(), + timelineId: z.string().nullable(), + templateTimelineId: z.string().nullable(), + templateTimelineVersion: z.number().nullable(), + timelineType: TimelineType.nullable(), + version: z.string().nullable(), timeline: SavedTimeline, }); export type CreateTimelinesRequestBodyInput = z.input; @@ -34,10 +34,8 @@ export type CreateTimelinesRequestBodyInput = z.input; export const CreateTimelinesResponse = z.object({ data: z.object({ - persistTimeline: z - .object({ - timeline: TimelineResponse.optional(), - }) - .optional(), + persistTimeline: z.object({ + timeline: TimelineResponse, + }), }), }); diff --git a/x-pack/plugins/security_solution/common/api/timeline/create_timelines/create_timelines_route.schema.yaml b/x-pack/plugins/security_solution/common/api/timeline/create_timelines/create_timelines_route.schema.yaml index 877ffafb42372..282570ffc5bac 100644 --- a/x-pack/plugins/security_solution/common/api/timeline/create_timelines/create_timelines_route.schema.yaml +++ b/x-pack/plugins/security_solution/common/api/timeline/create_timelines/create_timelines_route.schema.yaml @@ -28,7 +28,7 @@ paths: schema: type: object required: - - timeline + [status, timelineId, templateTimelineId, templateTimelineVersion, timelineType, version, timeline] properties: status: allOf: @@ -59,17 +59,18 @@ paths: application/json: schema: type: object + required: [data] properties: data: type: object + required: [persistTimeline] properties: persistTimeline: type: object + required: [timeline] properties: timeline: $ref: '../model/components.schema.yaml#/components/schemas/TimelineResponse' - required: - - data 405: description: Indicates that there was an error in the timeline creation. content: diff --git a/x-pack/plugins/security_solution/common/api/timeline/delete_note/delete_note_route.gen.ts b/x-pack/plugins/security_solution/common/api/timeline/delete_note/delete_note_route.gen.ts index ac46b5015650b..ad764d66b79fb 100644 --- a/x-pack/plugins/security_solution/common/api/timeline/delete_note/delete_note_route.gen.ts +++ b/x-pack/plugins/security_solution/common/api/timeline/delete_note/delete_note_route.gen.ts @@ -14,6 +14,6 @@ import { z } from 'zod'; export type DeleteNoteRequestBody = z.infer; export const DeleteNoteRequestBody = z.object({ - noteId: z.string().nullable().optional(), + noteId: z.string().nullable(), }); export type DeleteNoteRequestBodyInput = z.input; diff --git a/x-pack/plugins/security_solution/common/api/timeline/delete_note/delete_note_route.schema.yaml b/x-pack/plugins/security_solution/common/api/timeline/delete_note/delete_note_route.schema.yaml index cfe4566f4d7fb..ec31ef7d0a178 100644 --- a/x-pack/plugins/security_solution/common/api/timeline/delete_note/delete_note_route.schema.yaml +++ b/x-pack/plugins/security_solution/common/api/timeline/delete_note/delete_note_route.schema.yaml @@ -24,6 +24,7 @@ paths: application/json: schema: type: object + required: [noteId] properties: noteId: type: string diff --git a/x-pack/plugins/security_solution/common/api/timeline/delete_timelines/delete_timelines_route.gen.ts b/x-pack/plugins/security_solution/common/api/timeline/delete_timelines/delete_timelines_route.gen.ts new file mode 100644 index 0000000000000..3bc9432b586c9 --- /dev/null +++ b/x-pack/plugins/security_solution/common/api/timeline/delete_timelines/delete_timelines_route.gen.ts @@ -0,0 +1,26 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { z } from 'zod'; + +/* + * NOTICE: Do not edit this file manually. + * This file is automatically generated by the OpenAPI Generator, @kbn/openapi-generator. + */ + +export type DeleteTimelinesRequestBody = z.infer; +export const DeleteTimelinesRequestBody = z.object({ + savedObjectIds: z.array(z.string()), +}); +export type DeleteTimelinesRequestBodyInput = z.input; + +export type DeleteTimelinesResponse = z.infer; +export const DeleteTimelinesResponse = z.object({ + data: z.object({ + deleteTimeline: z.boolean(), + }), +}); diff --git a/x-pack/plugins/security_solution/common/api/timeline/delete_timelines/delete_timelines_route_schema.yaml b/x-pack/plugins/security_solution/common/api/timeline/delete_timelines/delete_timelines_route.schema.yaml similarity index 90% rename from x-pack/plugins/security_solution/common/api/timeline/delete_timelines/delete_timelines_route_schema.yaml rename to x-pack/plugins/security_solution/common/api/timeline/delete_timelines/delete_timelines_route.schema.yaml index 3acc7c67a1ef6..560992ccf4cf0 100644 --- a/x-pack/plugins/security_solution/common/api/timeline/delete_timelines/delete_timelines_route_schema.yaml +++ b/x-pack/plugins/security_solution/common/api/timeline/delete_timelines/delete_timelines_route.schema.yaml @@ -27,8 +27,7 @@ paths: application/json: schema: type: object - required: - - savedObjectIds + required: [savedObjectIds] properties: savedObjectIds: type: array @@ -45,11 +44,11 @@ paths: application/json: schema: type: object + required: [data] properties: data: type: object + required: [deleteTimeline] properties: deleteTimeline: - type: boolean - required: - - data \ No newline at end of file + type: boolean \ No newline at end of file diff --git a/x-pack/plugins/security_solution/common/api/timeline/export_timelines/export_timelines_route.gen.ts b/x-pack/plugins/security_solution/common/api/timeline/export_timelines/export_timelines_route.gen.ts index 0df4a48ffc31b..171bfc0c3aa7f 100644 --- a/x-pack/plugins/security_solution/common/api/timeline/export_timelines/export_timelines_route.gen.ts +++ b/x-pack/plugins/security_solution/common/api/timeline/export_timelines/export_timelines_route.gen.ts @@ -17,12 +17,12 @@ export const ExportTimelinesRequestQuery = z.object({ /** * The name of the file to export */ - file_name: z.string().optional(), + file_name: z.string(), }); export type ExportTimelinesRequestQueryInput = z.input; export type ExportTimelinesRequestBody = z.infer; export const ExportTimelinesRequestBody = z.object({ - ids: z.array(z.string()).nullable().optional(), + ids: z.array(z.string()).nullable(), }); export type ExportTimelinesRequestBodyInput = z.input; diff --git a/x-pack/plugins/security_solution/common/api/timeline/export_timelines/export_timelines_route.schema.yaml b/x-pack/plugins/security_solution/common/api/timeline/export_timelines/export_timelines_route.schema.yaml index 727c6fc807000..32d57a3ae2035 100644 --- a/x-pack/plugins/security_solution/common/api/timeline/export_timelines/export_timelines_route.schema.yaml +++ b/x-pack/plugins/security_solution/common/api/timeline/export_timelines/export_timelines_route.schema.yaml @@ -23,6 +23,7 @@ paths: parameters: - in: query name: file_name + required: true schema: type: string description: The name of the file to export @@ -33,6 +34,7 @@ paths: application/json: schema: type: object + required: [ids] properties: ids: nullable: true diff --git a/x-pack/plugins/security_solution/common/api/timeline/get_draft_timelines/get_draft_timelines_route.gen.ts b/x-pack/plugins/security_solution/common/api/timeline/get_draft_timelines/get_draft_timelines_route.gen.ts index fb379767be02b..00013a540c682 100644 --- a/x-pack/plugins/security_solution/common/api/timeline/get_draft_timelines/get_draft_timelines_route.gen.ts +++ b/x-pack/plugins/security_solution/common/api/timeline/get_draft_timelines/get_draft_timelines_route.gen.ts @@ -16,19 +16,15 @@ import { TimelineType, TimelineResponse } from '../model/components.gen'; export type GetDraftTimelinesRequestQuery = z.infer; export const GetDraftTimelinesRequestQuery = z.object({ - timelineType: TimelineType.optional(), + timelineType: TimelineType, }); export type GetDraftTimelinesRequestQueryInput = z.input; export type GetDraftTimelinesResponse = z.infer; export const GetDraftTimelinesResponse = z.object({ - data: z - .object({ - persistTimeline: z - .object({ - timeline: TimelineResponse.optional(), - }) - .optional(), - }) - .optional(), + data: z.object({ + persistTimeline: z.object({ + timeline: TimelineResponse, + }), + }), }); diff --git a/x-pack/plugins/security_solution/common/api/timeline/get_draft_timelines/get_draft_timelines_route.schema.yaml b/x-pack/plugins/security_solution/common/api/timeline/get_draft_timelines/get_draft_timelines_route.schema.yaml index 17fdc11ebfd70..3d8586627bef1 100644 --- a/x-pack/plugins/security_solution/common/api/timeline/get_draft_timelines/get_draft_timelines_route.schema.yaml +++ b/x-pack/plugins/security_solution/common/api/timeline/get_draft_timelines/get_draft_timelines_route.schema.yaml @@ -23,6 +23,7 @@ paths: parameters: - in: query name: timelineType + required: true schema: $ref: '../model/components.schema.yaml#/components/schemas/TimelineType' responses: @@ -32,12 +33,15 @@ paths: application/json: schema: type: object + required: [data] properties: data: type: object + required: [persistTimeline] properties: persistTimeline: type: object + required: [timeline] properties: timeline: $ref: '../model/components.schema.yaml#/components/schemas/TimelineResponse' diff --git a/x-pack/plugins/security_solution/common/api/timeline/get_timeline/get_timeline_route.gen.ts b/x-pack/plugins/security_solution/common/api/timeline/get_timeline/get_timeline_route.gen.ts index 902bef7eaf530..797f7d30cb7fd 100644 --- a/x-pack/plugins/security_solution/common/api/timeline/get_timeline/get_timeline_route.gen.ts +++ b/x-pack/plugins/security_solution/common/api/timeline/get_timeline/get_timeline_route.gen.ts @@ -19,11 +19,11 @@ export const GetTimelineRequestQuery = z.object({ /** * The ID of the template timeline to retrieve */ - template_timeline_id: z.string().optional(), + template_timeline_id: z.string(), /** * The ID of the timeline to retrieve */ - id: z.string().optional(), + id: z.string(), }); export type GetTimelineRequestQueryInput = z.input; diff --git a/x-pack/plugins/security_solution/common/api/timeline/get_timeline/get_timeline_route.schema.yaml b/x-pack/plugins/security_solution/common/api/timeline/get_timeline/get_timeline_route.schema.yaml index b19482630b05b..ab7038af70faf 100644 --- a/x-pack/plugins/security_solution/common/api/timeline/get_timeline/get_timeline_route.schema.yaml +++ b/x-pack/plugins/security_solution/common/api/timeline/get_timeline/get_timeline_route.schema.yaml @@ -23,11 +23,13 @@ paths: parameters: - in: query name: template_timeline_id + required: true schema: type: string description: The ID of the template timeline to retrieve - in: query name: id + required: true schema: type: string description: The ID of the timeline to retrieve @@ -38,13 +40,13 @@ paths: application/json: schema: type: object + required: [data] properties: data: type: object + required: [getOnetimeline] properties: getOneTimeline: oneOf: $ref: '../model/components.schema.yaml#/components/schemas/TimelineResponse' - nullable: true - required: - - data \ No newline at end of file + nullable: true \ No newline at end of file diff --git a/x-pack/plugins/security_solution/common/api/timeline/get_timelines/get_timelines_route.gen.ts b/x-pack/plugins/security_solution/common/api/timeline/get_timelines/get_timelines_route.gen.ts index 0850aa09c6636..c1f1329abfd41 100644 --- a/x-pack/plugins/security_solution/common/api/timeline/get_timelines/get_timelines_route.gen.ts +++ b/x-pack/plugins/security_solution/common/api/timeline/get_timelines/get_timelines_route.gen.ts @@ -24,26 +24,26 @@ export const GetTimelinesRequestQuery = z.object({ /** * If true, only timelines that are marked as favorites by the user are returned. */ - only_user_favorite: z.enum(['true', 'false']).nullable().optional(), - timeline_type: TimelineType.nullable().optional(), - sort_field: SortFieldTimeline.optional(), - sort_order: z.enum(['asc', 'desc']).optional(), - page_size: z.string().nullable().optional(), - page_index: z.string().nullable().optional(), - search: z.string().nullable().optional(), - status: TimelineStatus.nullable().optional(), + only_user_favorite: z.enum(['true', 'false']).nullable(), + timeline_type: TimelineType.nullable(), + sort_field: SortFieldTimeline, + sort_order: z.enum(['asc', 'desc']), + page_size: z.string().nullable(), + page_index: z.string().nullable(), + search: z.string().nullable(), + status: TimelineStatus.nullable(), }); export type GetTimelinesRequestQueryInput = z.input; export type GetTimelinesResponse = z.infer; export const GetTimelinesResponse = z.object({ data: z.object({ - timelines: z.array(TimelineResponse).optional(), - totalCount: z.number().optional(), - defaultTimelineCount: z.number().optional(), - templateTimelineCount: z.number().optional(), - favoriteCount: z.number().optional(), - elasticTemplateTimelineCount: z.number().optional(), - customTemplateTimelineCount: z.number().optional(), + timelines: z.array(TimelineResponse), + totalCount: z.number(), + defaultTimelineCount: z.number(), + templateTimelineCount: z.number(), + favoriteCount: z.number(), + elasticTemplateTimelineCount: z.number(), + customTemplateTimelineCount: z.number(), }), }); diff --git a/x-pack/plugins/security_solution/common/api/timeline/get_timelines/get_timelines_route.schema.yaml b/x-pack/plugins/security_solution/common/api/timeline/get_timelines/get_timelines_route.schema.yaml index 3d6cc9e2bf0f0..5d567d5eb9a31 100644 --- a/x-pack/plugins/security_solution/common/api/timeline/get_timelines/get_timelines_route.schema.yaml +++ b/x-pack/plugins/security_solution/common/api/timeline/get_timelines/get_timelines_route.schema.yaml @@ -23,6 +23,7 @@ paths: parameters: - in: query name: only_user_favorite + required: true schema: nullable: true type: string @@ -32,15 +33,18 @@ paths: description: If true, only timelines that are marked as favorites by the user are returned. - in: query name: timeline_type + required: true schema: $ref: '../model/components.schema.yaml#/components/schemas/TimelineType' nullable: true - in: query name: sort_field - schema: + required: true + schema: $ref: '../model/components.schema.yaml#/components/schemas/SortFieldTimeline' - in: query name: sort_order + required: true schema: type: string enum: @@ -48,21 +52,25 @@ paths: - desc - in: query name: page_size + required: true schema: nullable: true type: string - in: query name: page_index + required: true schema: nullable: true type: string - in: query name: search + required: true schema: nullable: true type: string - in: query name: status + required: true schema: $ref: '../model/components.schema.yaml#/components/schemas/TimelineStatus' nullable: true @@ -73,14 +81,25 @@ paths: application/json: schema: type: object + required: [data] properties: data: type: object + required: + [ + timelines, + totalCount, + defaultTimelineCount, + templateTimelineCount, + favoriteCount, + elasticTemplateTimelineCount, + customTemplateTimelineCount, + ] properties: timelines: type: array items: - $ref: '../model/components.schema.yaml#/components/schemas/TimelineResponse' + $ref: '../model/components.schema.yaml#/components/schemas/TimelineResponse' totalCount: type: number defaultTimelineCount: @@ -93,8 +112,6 @@ paths: type: number customTemplateTimelineCount: type: number - required: - - data 400: description: Bad request. The user supplied invalid data. content: @@ -105,4 +122,4 @@ paths: body: type: string statusCode: - type: number \ No newline at end of file + type: number diff --git a/x-pack/plugins/security_solution/common/api/timeline/import_timelines/import_timelines_route.gen.ts b/x-pack/plugins/security_solution/common/api/timeline/import_timelines/import_timelines_route.gen.ts index cc6074a2f97df..be732ab4d0a98 100644 --- a/x-pack/plugins/security_solution/common/api/timeline/import_timelines/import_timelines_route.gen.ts +++ b/x-pack/plugins/security_solution/common/api/timeline/import_timelines/import_timelines_route.gen.ts @@ -18,12 +18,10 @@ export type ImportTimelinesRequestBody = z.infer; +export const InstallPrepackedTimelinesRequestBody = z.object({ + timelinesToInstall: z.array(ImportTimelines.nullable()), + timelinesToUpdate: z.array(ImportTimelines.nullable()), + prepackagedTimelines: z.array(SavedTimeline), +}); +export type InstallPrepackedTimelinesRequestBodyInput = z.input< + typeof InstallPrepackedTimelinesRequestBody +>; + +export type InstallPrepackedTimelinesResponse = z.infer; +export const InstallPrepackedTimelinesResponse = z.object({ + data: ImportTimelineResult, +}); diff --git a/x-pack/plugins/security_solution/common/api/timeline/install_prepackaged_timelines/install_prepackaged_timelines_route_schema.yaml b/x-pack/plugins/security_solution/common/api/timeline/install_prepackaged_timelines/install_prepackaged_timelines_route.schema.yaml similarity index 94% rename from x-pack/plugins/security_solution/common/api/timeline/install_prepackaged_timelines/install_prepackaged_timelines_route_schema.yaml rename to x-pack/plugins/security_solution/common/api/timeline/install_prepackaged_timelines/install_prepackaged_timelines_route.schema.yaml index 86a76766e4cee..5b475f57375d1 100644 --- a/x-pack/plugins/security_solution/common/api/timeline/install_prepackaged_timelines/install_prepackaged_timelines_route_schema.yaml +++ b/x-pack/plugins/security_solution/common/api/timeline/install_prepackaged_timelines/install_prepackaged_timelines_route.schema.yaml @@ -24,6 +24,7 @@ paths: application/json: schema: type: object + required: [timelinesToInstall, timelinesToUpdate, prepackagedTimelines] properties: timelinesToInstall: type: array @@ -48,11 +49,10 @@ paths: application/json: schema: type: object + required: [data] properties: data: $ref: '../model/components.schema.yaml#/components/schemas/ImportTimelineResult' - required: - - data 500: description: Indicates the installation of prepackaged timelines was unsuccessful. content: diff --git a/x-pack/plugins/security_solution/common/api/timeline/patch_timelines/patch_timeline_route.gen.ts b/x-pack/plugins/security_solution/common/api/timeline/patch_timelines/patch_timeline_route.gen.ts index a715475ed424e..bf46a85eddab9 100644 --- a/x-pack/plugins/security_solution/common/api/timeline/patch_timelines/patch_timeline_route.gen.ts +++ b/x-pack/plugins/security_solution/common/api/timeline/patch_timelines/patch_timeline_route.gen.ts @@ -16,19 +16,17 @@ import { SavedTimeline, TimelineResponse } from '../model/components.gen'; export type PatchTimelineRequestBody = z.infer; export const PatchTimelineRequestBody = z.object({ - timelineId: z.string().optional(), - version: z.string().optional(), - timeline: SavedTimeline.optional(), + timelineId: z.string().nullable(), + version: z.string().nullable(), + timeline: SavedTimeline, }); export type PatchTimelineRequestBodyInput = z.input; export type PatchTimelineResponse = z.infer; export const PatchTimelineResponse = z.object({ data: z.object({ - persistTimeline: z - .object({ - timeline: TimelineResponse.optional(), - }) - .optional(), + persistTimeline: z.object({ + timeline: TimelineResponse, + }), }), }); diff --git a/x-pack/plugins/security_solution/common/api/timeline/patch_timelines/patch_timeline_route.schema.yaml b/x-pack/plugins/security_solution/common/api/timeline/patch_timelines/patch_timeline_route.schema.yaml index 307d1fb1eda86..7231788428722 100644 --- a/x-pack/plugins/security_solution/common/api/timeline/patch_timelines/patch_timeline_route.schema.yaml +++ b/x-pack/plugins/security_solution/common/api/timeline/patch_timelines/patch_timeline_route.schema.yaml @@ -25,11 +25,14 @@ paths: application/json: schema: type: object + required: [timelineId, version, timeline] properties: timelineId: type: string + nullable: true version: type: string + nullable: true timeline: $ref: '../model/components.schema.yaml#/components/schemas/SavedTimeline' responses: @@ -39,17 +42,18 @@ paths: application/json: schema: type: object + required: [data] properties: data: type: object + required: [persistTimeline] properties: persistTimeline: type: object + required: [timeline] properties: timeline: $ref: '../model/components.schema.yaml#/components/schemas/TimelineResponse' - required: - - data 405: description: Indicates that the user does not have the required access to create a draft timeline. content: diff --git a/x-pack/plugins/security_solution/common/api/timeline/persist_favorite/persist_favorite_route.gen.ts b/x-pack/plugins/security_solution/common/api/timeline/persist_favorite/persist_favorite_route.gen.ts index 98a2f8b810864..3864085e66507 100644 --- a/x-pack/plugins/security_solution/common/api/timeline/persist_favorite/persist_favorite_route.gen.ts +++ b/x-pack/plugins/security_solution/common/api/timeline/persist_favorite/persist_favorite_route.gen.ts @@ -16,16 +16,16 @@ import { TimelineType, FavoriteTimelineResponse } from '../model/components.gen' export type PersistFavoriteRequestBody = z.infer; export const PersistFavoriteRequestBody = z.object({ - timelineId: z.string().nullable().optional(), - templateTimelineId: z.string().nullable().optional(), - templateTimelineVersion: z.number().nullable().optional(), - timelineType: TimelineType.nullable().optional(), + timelineId: z.string().nullable(), + templateTimelineId: z.string().nullable(), + templateTimelineVersion: z.number().nullable(), + timelineType: TimelineType.nullable(), }); export type PersistFavoriteRequestBodyInput = z.input; export type PersistFavoriteResponse = z.infer; export const PersistFavoriteResponse = z.object({ data: z.object({ - persistFavorite: FavoriteTimelineResponse.optional(), + persistFavorite: FavoriteTimelineResponse, }), }); diff --git a/x-pack/plugins/security_solution/common/api/timeline/persist_favorite/persist_favorite_route.schema.yaml b/x-pack/plugins/security_solution/common/api/timeline/persist_favorite/persist_favorite_route.schema.yaml index 7cc897af7f12a..37be8e713c917 100644 --- a/x-pack/plugins/security_solution/common/api/timeline/persist_favorite/persist_favorite_route.schema.yaml +++ b/x-pack/plugins/security_solution/common/api/timeline/persist_favorite/persist_favorite_route.schema.yaml @@ -24,6 +24,7 @@ paths: application/json: schema: type: object + required: [timelineId, templateTimelineId, templateTimelineVersion, timelineType] properties: timelineId: type: string @@ -45,14 +46,14 @@ paths: application/json: schema: type: object + required: [data] properties: data: type: object + required: [persistFavorite] properties: persistFavorite: $ref: '../model/components.schema.yaml#/components/schemas/FavoriteTimelineResponse' - required: - - data 403: description: Indicates the user does not have the required permissions to persist the favorite status. content: diff --git a/x-pack/plugins/security_solution/common/api/timeline/persist_note/persist_note_route.gen.ts b/x-pack/plugins/security_solution/common/api/timeline/persist_note/persist_note_route.gen.ts index ca807d04a30dc..fdb0913cd874c 100644 --- a/x-pack/plugins/security_solution/common/api/timeline/persist_note/persist_note_route.gen.ts +++ b/x-pack/plugins/security_solution/common/api/timeline/persist_note/persist_note_route.gen.ts @@ -17,21 +17,19 @@ import { BareNote, Note } from '../model/components.gen'; export type PersistNoteRequestBody = z.infer; export const PersistNoteRequestBody = z.object({ note: BareNote, - overrideOwner: z.boolean().nullable().nullable().optional(), - noteId: z.string().nullable().optional(), - version: z.string().nullable().optional(), + overrideOwner: z.boolean().nullable().nullable(), + noteId: z.string().nullable(), + version: z.string().nullable(), }); export type PersistNoteRequestBodyInput = z.input; export type PersistNoteResponse = z.infer; export const PersistNoteResponse = z.object({ data: z.object({ - persistNote: z - .object({ - code: z.number().optional(), - message: z.string().optional(), - note: Note.optional(), - }) - .optional(), + persistNote: z.object({ + code: z.number(), + message: z.string(), + note: Note, + }), }), }); diff --git a/x-pack/plugins/security_solution/common/api/timeline/persist_note/persist_note_route.schema.yaml b/x-pack/plugins/security_solution/common/api/timeline/persist_note/persist_note_route.schema.yaml index 9a0e23ae19ef7..236777bb3bb34 100644 --- a/x-pack/plugins/security_solution/common/api/timeline/persist_note/persist_note_route.schema.yaml +++ b/x-pack/plugins/security_solution/common/api/timeline/persist_note/persist_note_route.schema.yaml @@ -27,8 +27,7 @@ paths: application/json: schema: type: object - required: - - note + required: [note, overrideOwner, noteId, version] properties: note: $ref: '../model/components.schema.yaml#/components/schemas/BareNote' @@ -48,18 +47,19 @@ paths: application/json: schema: type: object + required: [data] properties: data: type: object + required: [persistNote] properties: persistNote: type: object + required: [code, message, note] properties: code: type: number message: type: string note: - $ref: '../model/components.schema.yaml#/components/schemas/Note' - required: - - data + $ref: '../model/components.schema.yaml#/components/schemas/Note' \ No newline at end of file diff --git a/x-pack/plugins/security_solution/common/api/timeline/pinned_events/pinned_events_route.gen.ts b/x-pack/plugins/security_solution/common/api/timeline/pinned_events/pinned_events_route.gen.ts index d6a28b63d9b88..2d365e1a62a7a 100644 --- a/x-pack/plugins/security_solution/common/api/timeline/pinned_events/pinned_events_route.gen.ts +++ b/x-pack/plugins/security_solution/common/api/timeline/pinned_events/pinned_events_route.gen.ts @@ -17,8 +17,8 @@ import { PinnedEvent } from '../model/components.gen'; export type PersistPinnedEventRequestBody = z.infer; export const PersistPinnedEventRequestBody = z.object({ eventId: z.string(), - pinnedEventId: z.string().nullable().optional(), - timelineId: z.string().nullable().optional(), + pinnedEventId: z.string().nullable(), + timelineId: z.string().nullable(), }); export type PersistPinnedEventRequestBodyInput = z.input; diff --git a/x-pack/plugins/security_solution/common/api/timeline/pinned_events/pinned_events_route.schema.yaml b/x-pack/plugins/security_solution/common/api/timeline/pinned_events/pinned_events_route.schema.yaml index 8b1da2cc0d7fe..dd00ee13cfda4 100644 --- a/x-pack/plugins/security_solution/common/api/timeline/pinned_events/pinned_events_route.schema.yaml +++ b/x-pack/plugins/security_solution/common/api/timeline/pinned_events/pinned_events_route.schema.yaml @@ -24,8 +24,7 @@ paths: application/json: schema: type: object - required: - - eventId + required: [eventId, pinnedEventId, timelineId] properties: eventId: type: string @@ -42,9 +41,11 @@ paths: application/json: schema: type: object + required: [data] properties: data: type: object + required: [persistPinnedEventOnTimeline] properties: persistPinnedEventOnTimeline: allOf: @@ -54,6 +55,4 @@ paths: code: type: number message: - type: string - required: - - data \ No newline at end of file + type: string \ No newline at end of file From b6aba77738323fe8246cf40f78fdd905c5c475e7 Mon Sep 17 00:00:00 2001 From: Michael Olorunnisola Date: Tue, 7 Nov 2023 11:28:08 -0500 Subject: [PATCH 03/15] additional cleanup --- .../api/timeline/model/components.gen.ts | 123 ++++++++-------- .../api/timeline/model/components.schema.yaml | 134 ++++++++++++------ 2 files changed, 152 insertions(+), 105 deletions(-) diff --git a/x-pack/plugins/security_solution/common/api/timeline/model/components.gen.ts b/x-pack/plugins/security_solution/common/api/timeline/model/components.gen.ts index 9a70053876586..e7cba0b2428ef 100644 --- a/x-pack/plugins/security_solution/common/api/timeline/model/components.gen.ts +++ b/x-pack/plugins/security_solution/common/api/timeline/model/components.gen.ts @@ -14,54 +14,55 @@ import { z } from 'zod'; export type PinnedEvent = z.infer; export const PinnedEvent = z.object({ - pinnedEventId: z.string().optional(), - eventId: z.string().optional(), - timelineId: z.string().optional(), - created: z.number().optional(), - createdBy: z.string().optional(), - updated: z.number().optional(), - updatedBy: z.string().optional(), - version: z.string().optional(), - timelineVersion: z.string().optional(), + pinnedEventId: z.string(), + eventId: z.string(), + timelineId: z.string(), + created: z.number().nullable().optional(), + createdBy: z.string().nullable().optional(), + updated: z.number().nullable().optional(), + updatedBy: z.string().nullable().optional(), + version: z.string(), + timelineVersion: z.string().nullable().optional(), }); export type Sort = z.infer; export const Sort = z.object({ - columnId: z.string().optional(), - sortDirection: z.string().optional(), + columnId: z.string().nullable().optional(), + columnType: z.string().nullable().optional(), + sortDirection: z.string().nullable().optional(), }); export type BareNote = z.infer; export const BareNote = z.object({ - eventId: z.string().optional(), - note: z.string().optional(), - timelineId: z.string().optional(), - created: z.number().optional(), - createdBy: z.string().optional(), - updated: z.number().optional(), - updatedBy: z.string().optional(), + eventId: z.string().nullable().optional(), + note: z.string().nullable().optional(), + timelineId: z.string().nullable(), + created: z.number().nullable().optional(), + createdBy: z.string().nullable().optional(), + updated: z.number().nullable().optional(), + updatedBy: z.string().nullable().optional(), }); export type Note = z.infer; export const Note = BareNote.and( z.object({ - noteId: z.string().optional(), - version: z.string().optional(), + noteId: z.string(), + version: z.string(), timelineVersion: z.string().nullable().optional(), }) ); export type GlobalNote = z.infer; export const GlobalNote = z.object({ - noteId: z.string().optional(), - version: z.string().optional(), + noteId: z.string(), + version: z.string(), timelineVersion: z.string().nullable().optional(), - note: z.string().optional(), - timelineId: z.string().optional(), - created: z.number().optional(), - createdBy: z.string().optional(), - updated: z.number().optional(), - updatedBy: z.string().optional(), + note: z.string().nullable().optional(), + timelineId: z.string().nullable().optional(), + created: z.number().nullable().optional(), + createdBy: z.string().nullable().optional(), + updated: z.number().nullable().optional(), + updatedBy: z.string().nullable().optional(), }); /** @@ -113,7 +114,6 @@ export const QueryMatchResult = z.object({ operator: z.string().optional(), }); -export type DataProviderResult = z.infer; export const DataProviderResult = z.object({ id: z.string().optional(), name: z.string().optional(), @@ -121,15 +121,17 @@ export const DataProviderResult = z.object({ excluded: z.boolean().optional(), kqlQuery: z.string().optional(), queryMatch: QueryMatchResult.optional(), - and: z.array(DataProviderResult).optional(), + and: z.lazy(() => DataProviderResult.array()).optional(), type: DataProviderType.optional(), }); +export type IDataProviderResult = z.infer; + export type FavoriteTimelineResult = z.infer; export const FavoriteTimelineResult = z.object({ - fullName: z.string().optional(), - userName: z.string().optional(), - favoriteDate: z.number().optional(), + fullName: z.string().nullable().optional(), + userName: z.string().nullable().optional(), + favoriteDate: z.number().nullable().optional(), }); export type FilterTimelineResult = z.infer; @@ -176,12 +178,9 @@ export const SerializedFilterQueryResult = z.object({ * The field to sort the timelines by. */ export type SortFieldTimeline = z.infer; -export const SortFieldTimeline = z.object({ - title: z.string().optional(), - description: z.string().optional(), - updated: z.string().optional(), - created: z.string().optional(), -}); +export const SortFieldTimeline = z.enum(['title', 'description', 'updated', 'created']); +export type SortFieldTimelineEnum = typeof SortFieldTimeline.enum; +export const SortFieldTimelineEnum = SortFieldTimeline.enum; export type ColumnHeaderResult = z.infer; export const ColumnHeaderResult = z.object({ @@ -208,41 +207,43 @@ export const TimelineTypeEnum = TimelineType.enum; export type SavedTimeline = z.infer; export const SavedTimeline = z.object({ - columns: ColumnHeaderResult.optional(), - created: z.number().optional(), - createdBy: z.string().optional(), - dataProviders: z.array(DataProviderResult).optional(), - dataViewId: z.string().optional(), + columns: ColumnHeaderResult.nullable().optional(), + created: z.number().nullable().optional(), + createdBy: z.string().nullable().optional(), + dataProviders: z.array(DataProviderResult).nullable().optional(), + dataViewId: z.string().nullable().optional(), dateRange: z .object({ end: z.union([z.string(), z.number()]).optional(), start: z.union([z.string(), z.number()]).optional(), }) + .nullable() .optional(), - description: z.string().optional(), + description: z.string().nullable().optional(), eqlOptions: z .object({ eventCategoryField: z.string().optional(), tiebreakerField: z.string().optional(), timestampField: z.string().optional(), }) + .nullable() .optional(), - eventType: z.string().optional(), - excludedRowRendererIds: z.array(RowRendererId).optional(), - favorite: z.array(FavoriteTimelineResult).optional(), - filters: z.array(FilterTimelineResult).optional(), - kqlMode: z.string().optional(), - kqlQuery: SerializedFilterQueryResult.optional(), - indexNames: z.array(z.string()).optional(), - savedQueryId: z.string().optional(), - sort: Sort.optional(), - status: z.enum(['active', 'draft', 'immutable']).optional(), - title: z.string().optional(), - templateTimelineId: z.string().optional(), - templateTimelineVersion: z.number().optional(), - timelineType: TimelineType.optional(), - updated: z.number().optional(), - updatedBy: z.string().optional(), + eventType: z.string().nullable().optional(), + excludedRowRendererIds: z.array(RowRendererId).nullable().optional(), + favorite: z.array(FavoriteTimelineResult).nullable().optional(), + filters: z.array(FilterTimelineResult).nullable().optional(), + kqlMode: z.string().nullable().optional(), + kqlQuery: SerializedFilterQueryResult.nullable().optional(), + indexNames: z.array(z.string()).nullable().optional(), + savedQueryId: z.string().nullable().optional(), + sort: Sort.nullable().optional(), + status: z.enum(['active', 'draft', 'immutable']).nullable().optional(), + title: z.string().nullable().optional(), + templateTimelineId: z.string().nullable().optional(), + templateTimelineVersion: z.number().nullable().optional(), + timelineType: TimelineType.nullable().optional(), + updated: z.number().nullable().optional(), + updatedBy: z.string().nullable().optional(), }); export type TimelineResponse = z.infer; diff --git a/x-pack/plugins/security_solution/common/api/timeline/model/components.schema.yaml b/x-pack/plugins/security_solution/common/api/timeline/model/components.schema.yaml index 2e06812b745e0..fd27b0df41dcc 100644 --- a/x-pack/plugins/security_solution/common/api/timeline/model/components.schema.yaml +++ b/x-pack/plugins/security_solution/common/api/timeline/model/components.schema.yaml @@ -2,11 +2,12 @@ openapi: 3.0.0 info: title: Common Timeline Attributes version: '2023-10-31' -paths: { } +paths: {} components: schemas: PinnedEvent: type: object + required: [pinnedEventId, eventId, timelineId, version] properties: pinnedEventId: type: string @@ -16,44 +17,63 @@ components: type: string created: type: number + nullable: true createdBy: type: string + nullable: true updated: type: number + nullable: true updatedBy: type: string + nullable: true version: type: string timelineVersion: type: string + nullable: true Sort: type: object properties: columnId: type: string + nullable: true + columnType: + type: string + nullable: true sortDirection: type: string + nullable: true BareNote: type: object + required: [timelineId] properties: eventId: type: string + nullable: true note: type: string + nullable: true timelineId: type: string + nullable: true created: type: number + nullable: true createdBy: type: string + nullable: true updated: type: number + nullable: true updatedBy: type: string + nullable: true Note: allOf: - $ref: '#/components/schemas/BareNote' - type: object + required: [noteId, version] properties: noteId: type: string @@ -61,29 +81,36 @@ components: type: string timelineVersion: nullable: true - type: string + type: string GlobalNote: type: object + required: [noteId, version] properties: noteId: type: string version: type: string timelineVersion: + type: string nullable: true - type: string note: type: string + nullable: true timelineId: type: string + nullable: true created: type: number + nullable: true createdBy: type: string + nullable: true updated: type: number + nullable: true updatedBy: - type: string + type: string + nullable: true TimelineStatus: type: string enum: @@ -157,10 +184,13 @@ components: properties: fullName: type: string + nullable: true userName: type: string + nullable: true favoriteDate: type: number + nullable: true FilterTimelineResult: type: object properties: @@ -217,17 +247,13 @@ components: serializedQuery: type: string SortFieldTimeline: - type: object + type: string description: The field to sort the timelines by. - properties: - title: - type: string - description: - type: string - updated: - type: string - created: - type: string + enum: + - title + - description + - updated + - created ColumnHeaderResult: type: object properties: @@ -267,19 +293,25 @@ components: type: object properties: columns: - $ref: '#/components/schemas/ColumnHeaderResult' + $ref: '#/components/schemas/ColumnHeaderResult' + nullable: true created: type: number + nullable: true createdBy: type: string + nullable: true dataProviders: type: array + nullable: true items: $ref: '#/components/schemas/DataProviderResult' dataViewId: type: string + nullable: true dateRange: type: object + nullable: true properties: end: oneOf: @@ -291,8 +323,10 @@ components: - type: number description: type: string + nullable: true eqlOptions: type: object + nullable: true properties: eventCategoryField: type: string @@ -302,55 +336,69 @@ components: type: string eventType: type: string + nullable: true excludedRowRendererIds: type: array + nullable: true items: $ref: '#/components/schemas/RowRendererId' favorite: type: array + nullable: true items: $ref: '#/components/schemas/FavoriteTimelineResult' filters: type: array + nullable: true items: $ref: '#/components/schemas/FilterTimelineResult' kqlMode: type: string + nullable: true kqlQuery: + nullable: true $ref: '#/components/schemas/SerializedFilterQueryResult' indexNames: type: array + nullable: true items: type: string savedQueryId: type: string + nullable: true sort: + nullable: true $ref: '#/components/schemas/Sort' status: type: string + nullable: true enum: - active - draft - immutable title: type: string + nullable: true templateTimelineId: type: string + nullable: true templateTimelineVersion: type: number + nullable: true timelineType: + nullable: true $ref: '#/components/schemas/TimelineType' updated: type: number + nullable: true updatedBy: type: string + nullable: true TimelineResponse: allOf: - $ref: '#/components/schemas/SavedTimeline' - type: object - required: - - savedObjectId - - version + required: [savedObjectId, version] properties: eventIdToNoteIds: type: array @@ -378,9 +426,7 @@ components: type: string FavoriteTimelineResponse: type: object - required: - - savedObjectId - - version + required: [savedObjectId, version] properties: savedObjectId: type: string @@ -406,30 +452,30 @@ components: $ref: '#/components/schemas/FavoriteTimelineResult' ImportTimelines: allOf: - - $ref: '#/components/schemas/SavedTimeline' - - type: object - properties: - savedObjectId: - type: string - nullable: true - version: + - $ref: '#/components/schemas/SavedTimeline' + - type: object + properties: + savedObjectId: + type: string + nullable: true + version: + type: string + nullable: true + globalNotes: + nullable: true + type: array + items: + $ref: '#/components/schemas/BareNote' + eventNotes: + nullable: true + type: array + items: + $ref: '#/components/schemas/BareNote' + pinnedEventIds: + nullable: true + type: array + items: type: string - nullable: true - globalNotes: - nullable: true - type: array - items: - $ref: '#/components/schemas/BareNote' - eventNotes: - nullable: true - type: array - items: - $ref: '#/components/schemas/BareNote' - pinnedEventIds: - nullable: true - type: array - items: - type: string ImportTimelineResult: type: object properties: From 2ce1115d4573ecd7918e6a2cc4df6ee91471856b Mon Sep 17 00:00:00 2001 From: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Date: Tue, 7 Nov 2023 17:00:39 +0000 Subject: [PATCH 04/15] [CI] Auto-commit changed files from 'yarn openapi:generate' --- .../common/api/timeline/model/components.gen.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/x-pack/plugins/security_solution/common/api/timeline/model/components.gen.ts b/x-pack/plugins/security_solution/common/api/timeline/model/components.gen.ts index e7cba0b2428ef..13b65a74e913d 100644 --- a/x-pack/plugins/security_solution/common/api/timeline/model/components.gen.ts +++ b/x-pack/plugins/security_solution/common/api/timeline/model/components.gen.ts @@ -114,6 +114,7 @@ export const QueryMatchResult = z.object({ operator: z.string().optional(), }); +export type DataProviderResult = z.infer; export const DataProviderResult = z.object({ id: z.string().optional(), name: z.string().optional(), @@ -121,12 +122,10 @@ export const DataProviderResult = z.object({ excluded: z.boolean().optional(), kqlQuery: z.string().optional(), queryMatch: QueryMatchResult.optional(), - and: z.lazy(() => DataProviderResult.array()).optional(), + and: z.array(DataProviderResult).optional(), type: DataProviderType.optional(), }); -export type IDataProviderResult = z.infer; - export type FavoriteTimelineResult = z.infer; export const FavoriteTimelineResult = z.object({ fullName: z.string().nullable().optional(), From e7cf737ee78c7765c1851368d8fe94162f3a560e Mon Sep 17 00:00:00 2001 From: Michael Olorunnisola Date: Wed, 8 Nov 2023 15:54:48 -0500 Subject: [PATCH 05/15] remove circular dependency for now --- .../common/api/timeline/model/components.gen.ts | 1 - .../common/api/timeline/model/components.schema.yaml | 8 ++++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/x-pack/plugins/security_solution/common/api/timeline/model/components.gen.ts b/x-pack/plugins/security_solution/common/api/timeline/model/components.gen.ts index 13b65a74e913d..d1780cfe9e4b3 100644 --- a/x-pack/plugins/security_solution/common/api/timeline/model/components.gen.ts +++ b/x-pack/plugins/security_solution/common/api/timeline/model/components.gen.ts @@ -122,7 +122,6 @@ export const DataProviderResult = z.object({ excluded: z.boolean().optional(), kqlQuery: z.string().optional(), queryMatch: QueryMatchResult.optional(), - and: z.array(DataProviderResult).optional(), type: DataProviderType.optional(), }); diff --git a/x-pack/plugins/security_solution/common/api/timeline/model/components.schema.yaml b/x-pack/plugins/security_solution/common/api/timeline/model/components.schema.yaml index fd27b0df41dcc..355c58a7359cb 100644 --- a/x-pack/plugins/security_solution/common/api/timeline/model/components.schema.yaml +++ b/x-pack/plugins/security_solution/common/api/timeline/model/components.schema.yaml @@ -173,10 +173,10 @@ components: type: string queryMatch: $ref: '#/components/schemas/QueryMatchResult' - and: - type: array - items: - $ref: '#/components/schemas/DataProviderResult' + # and: + # type: array + # items: + # $ref: '#/components/schemas/DataProviderResult' type: $ref: '#/components/schemas/DataProviderType' FavoriteTimelineResult: From e9f9c69c47bf2de8fb1b03464fd5eb1dc75c95c9 Mon Sep 17 00:00:00 2001 From: Michael Olorunnisola Date: Wed, 15 Nov 2023 12:14:30 -0500 Subject: [PATCH 06/15] very rough first pass at recursive template changes --- .../templates/zod_operation_schema.handlebars | 10 +++++++-- .../templates/zod_schema_item.handlebars | 2 +- .../api/timeline/model/components.gen.ts | 13 ++++++++++-- .../api/timeline/model/components.schema.yaml | 21 ++++++++++++++----- 4 files changed, 36 insertions(+), 10 deletions(-) diff --git a/packages/kbn-openapi-generator/src/template_service/templates/zod_operation_schema.handlebars b/packages/kbn-openapi-generator/src/template_service/templates/zod_operation_schema.handlebars index 5395edbcf5f25..7fec205d26317 100644 --- a/packages/kbn-openapi-generator/src/template_service/templates/zod_operation_schema.handlebars +++ b/packages/kbn-openapi-generator/src/template_service/templates/zod_operation_schema.handlebars @@ -22,8 +22,14 @@ import { * {{{.}}} */ {{/description}} -export type {{@key}} = z.infer; -export const {{@key}} = {{> zod_schema_item}}; +{{#if x-recursive}} +export type {{@key}} = z.infer & { {{x-recursive-prop}} {{#if x-recursive-prop-optional}}?{{/if}}:{{x-recursive-value}} }; +{{else}} export type {{@key}} = z.infer; +{{/if}} +{{#if x-recursive}} +export const {{@key}}: z.ZodType<{{@key}}> = {{> zod_schema_item}}; +{{else}} export const {{@key}} = {{> zod_schema_item}}; +{{/if}} {{#if enum}} {{#unless (isSingle enum)}} export type {{@key}}Enum = typeof {{@key}}.enum; diff --git a/packages/kbn-openapi-generator/src/template_service/templates/zod_schema_item.handlebars b/packages/kbn-openapi-generator/src/template_service/templates/zod_schema_item.handlebars index 29d4453da4d7b..2f2bb551e9cf1 100644 --- a/packages/kbn-openapi-generator/src/template_service/templates/zod_schema_item.handlebars +++ b/packages/kbn-openapi-generator/src/template_service/templates/zod_schema_item.handlebars @@ -6,7 +6,7 @@ {{~/if~}} {{~#if $ref~}} - {{referenceName}} + {{~#if (eq x-lazy true)}}z.lazy(() => {{referenceName}}){{~else~}}{{referenceName}}{{~/if~}} {{~#if nullable}}.nullable(){{/if~}} {{~#if (eq requiredBool false)}}.optional(){{/if~}} {{~#if (defined default)}}.default({{{toJSON default}}}){{/if~}} diff --git a/x-pack/plugins/security_solution/common/api/timeline/model/components.gen.ts b/x-pack/plugins/security_solution/common/api/timeline/model/components.gen.ts index d1780cfe9e4b3..32fa26c8c5a6b 100644 --- a/x-pack/plugins/security_solution/common/api/timeline/model/components.gen.ts +++ b/x-pack/plugins/security_solution/common/api/timeline/model/components.gen.ts @@ -114,8 +114,8 @@ export const QueryMatchResult = z.object({ operator: z.string().optional(), }); -export type DataProviderResult = z.infer; -export const DataProviderResult = z.object({ +export type BaseDataProviderResult = z.infer; +export const BaseDataProviderResult = z.object({ id: z.string().optional(), name: z.string().optional(), enabled: z.boolean().optional(), @@ -125,6 +125,15 @@ export const DataProviderResult = z.object({ type: DataProviderType.optional(), }); +export type DataProviderResult = z.infer & { + and?: DataProviderResult[]; +}; +export const DataProviderResult: z.ZodType = BaseDataProviderResult.and( + z.object({ + and: z.array(z.lazy(() => DataProviderResult)).optional(), + }) +); + export type FavoriteTimelineResult = z.infer; export const FavoriteTimelineResult = z.object({ fullName: z.string().nullable().optional(), diff --git a/x-pack/plugins/security_solution/common/api/timeline/model/components.schema.yaml b/x-pack/plugins/security_solution/common/api/timeline/model/components.schema.yaml index 355c58a7359cb..298128bee8354 100644 --- a/x-pack/plugins/security_solution/common/api/timeline/model/components.schema.yaml +++ b/x-pack/plugins/security_solution/common/api/timeline/model/components.schema.yaml @@ -158,7 +158,7 @@ components: type: string operator: type: string - DataProviderResult: + BaseDataProviderResult: type: object properties: id: @@ -173,12 +173,23 @@ components: type: string queryMatch: $ref: '#/components/schemas/QueryMatchResult' - # and: - # type: array - # items: - # $ref: '#/components/schemas/DataProviderResult' type: $ref: '#/components/schemas/DataProviderType' + DataProviderResult: + x-recursive: true + x-recursive-prop: and + x-recursive-value: DataProviderResult[] + x-recursive-prop-optional: true + x-base-type: BaseDataProviderResult + allOf: + - $ref: '#/components/schemas/BaseDataProviderResult' + - type: object + properties: + and: + type: array + items: + x-lazy: true + $ref: '#/components/schemas/DataProviderResult' FavoriteTimelineResult: type: object properties: From eb0a656c366c73bdb9eb932f00c68d0250999471 Mon Sep 17 00:00:00 2001 From: Michael Olorunnisola Date: Tue, 21 Nov 2023 10:19:59 -0500 Subject: [PATCH 07/15] update recursive call --- .../templates/zod_operation_schema.handlebars | 7 ++----- .../common/api/timeline/model/components.schema.yaml | 1 - 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/packages/kbn-openapi-generator/src/template_service/templates/zod_operation_schema.handlebars b/packages/kbn-openapi-generator/src/template_service/templates/zod_operation_schema.handlebars index 7fec205d26317..58b26dfa27ee8 100644 --- a/packages/kbn-openapi-generator/src/template_service/templates/zod_operation_schema.handlebars +++ b/packages/kbn-openapi-generator/src/template_service/templates/zod_operation_schema.handlebars @@ -23,13 +23,10 @@ import { */ {{/description}} {{#if x-recursive}} -export type {{@key}} = z.infer & { {{x-recursive-prop}} {{#if x-recursive-prop-optional}}?{{/if}}:{{x-recursive-value}} }; +export type {{@key}} = z.infer & { {{x-recursive-prop}}?:{{x-recursive-value}} }; {{else}} export type {{@key}} = z.infer; {{/if}} -{{#if x-recursive}} -export const {{@key}}: z.ZodType<{{@key}}> = {{> zod_schema_item}}; -{{else}} export const {{@key}} = {{> zod_schema_item}}; -{{/if}} +export const {{@key}}{{#if x-recursive}}: z.ZodType<{{@key}}>{{/if}} = {{> zod_schema_item}}; {{#if enum}} {{#unless (isSingle enum)}} export type {{@key}}Enum = typeof {{@key}}.enum; diff --git a/x-pack/plugins/security_solution/common/api/timeline/model/components.schema.yaml b/x-pack/plugins/security_solution/common/api/timeline/model/components.schema.yaml index 298128bee8354..3ed3e70b52e6e 100644 --- a/x-pack/plugins/security_solution/common/api/timeline/model/components.schema.yaml +++ b/x-pack/plugins/security_solution/common/api/timeline/model/components.schema.yaml @@ -179,7 +179,6 @@ components: x-recursive: true x-recursive-prop: and x-recursive-value: DataProviderResult[] - x-recursive-prop-optional: true x-base-type: BaseDataProviderResult allOf: - $ref: '#/components/schemas/BaseDataProviderResult' From a638e3353cc616b5df6af0d046275b3296100209 Mon Sep 17 00:00:00 2001 From: Michael Olorunnisola Date: Wed, 31 Jan 2024 11:18:52 -0500 Subject: [PATCH 08/15] fix lint errors --- .../templates/zod_operation_schema.handlebars | 6 ++++-- .../templates/zod_schema_item.handlebars | 3 ++- .../create_timelines_route.schema.yaml | 10 ++++++---- .../get_timeline/get_timeline_route.schema.yaml | 5 +++-- .../persist_favorite_route.schema.yaml | 5 +++-- 5 files changed, 18 insertions(+), 11 deletions(-) diff --git a/packages/kbn-openapi-generator/src/template_service/templates/zod_operation_schema.handlebars b/packages/kbn-openapi-generator/src/template_service/templates/zod_operation_schema.handlebars index 58b26dfa27ee8..e3b1e64718efd 100644 --- a/packages/kbn-openapi-generator/src/template_service/templates/zod_operation_schema.handlebars +++ b/packages/kbn-openapi-generator/src/template_service/templates/zod_operation_schema.handlebars @@ -22,11 +22,13 @@ import { * {{{.}}} */ {{/description}} -{{#if x-recursive}} +export type {{@key}} = z.infer; +export const {{@key}} = {{> zod_schema_item}}; +{{!-- {{#if x-recursive}} export type {{@key}} = z.infer & { {{x-recursive-prop}}?:{{x-recursive-value}} }; {{else}} export type {{@key}} = z.infer; {{/if}} -export const {{@key}}{{#if x-recursive}}: z.ZodType<{{@key}}>{{/if}} = {{> zod_schema_item}}; +export const {{@key}}{{#if x-recursive}}: z.ZodType<{{@key}}>{{/if}} = {{> zod_schema_item}}; --}} {{#if enum}} {{#unless (isSingle enum)}} export type {{@key}}Enum = typeof {{@key}}.enum; diff --git a/packages/kbn-openapi-generator/src/template_service/templates/zod_schema_item.handlebars b/packages/kbn-openapi-generator/src/template_service/templates/zod_schema_item.handlebars index 2f2bb551e9cf1..5ca63facdf8a7 100644 --- a/packages/kbn-openapi-generator/src/template_service/templates/zod_schema_item.handlebars +++ b/packages/kbn-openapi-generator/src/template_service/templates/zod_schema_item.handlebars @@ -6,7 +6,8 @@ {{~/if~}} {{~#if $ref~}} - {{~#if (eq x-lazy true)}}z.lazy(() => {{referenceName}}){{~else~}}{{referenceName}}{{~/if~}} + {{referenceName}} + {{!-- {{~#if (eq x-lazy true)}}z.lazy(() => {{referenceName}}){{~else~}}{{referenceName}}{{~/if~}} --}} {{~#if nullable}}.nullable(){{/if~}} {{~#if (eq requiredBool false)}}.optional(){{/if~}} {{~#if (defined default)}}.default({{{toJSON default}}}){{/if~}} diff --git a/x-pack/plugins/security_solution/common/api/timeline/create_timelines/create_timelines_route.schema.yaml b/x-pack/plugins/security_solution/common/api/timeline/create_timelines/create_timelines_route.schema.yaml index 282570ffc5bac..85c7a5f9b78ec 100644 --- a/x-pack/plugins/security_solution/common/api/timeline/create_timelines/create_timelines_route.schema.yaml +++ b/x-pack/plugins/security_solution/common/api/timeline/create_timelines/create_timelines_route.schema.yaml @@ -31,9 +31,10 @@ paths: [status, timelineId, templateTimelineId, templateTimelineVersion, timelineType, version, timeline] properties: status: - allOf: - $ref: '../model/components.schema.yaml#/components/schemas/TimelineStatus' nullable: true + type: string + allOf: + - $ref: '../model/components.schema.yaml#/components/schemas/TimelineStatus' timelineId: type: string nullable: true @@ -44,9 +45,10 @@ paths: type: number nullable: true timelineType: - allOf: - $ref: '../model/components.schema.yaml#/components/schemas/TimelineType' nullable: true + type: string + allOf: + - $ref: '../model/components.schema.yaml#/components/schemas/TimelineType' version: type: string nullable: true diff --git a/x-pack/plugins/security_solution/common/api/timeline/get_timeline/get_timeline_route.schema.yaml b/x-pack/plugins/security_solution/common/api/timeline/get_timeline/get_timeline_route.schema.yaml index ab7038af70faf..1732be47f4d0e 100644 --- a/x-pack/plugins/security_solution/common/api/timeline/get_timeline/get_timeline_route.schema.yaml +++ b/x-pack/plugins/security_solution/common/api/timeline/get_timeline/get_timeline_route.schema.yaml @@ -47,6 +47,7 @@ paths: required: [getOnetimeline] properties: getOneTimeline: + nullable: true + type: object oneOf: - $ref: '../model/components.schema.yaml#/components/schemas/TimelineResponse' - nullable: true \ No newline at end of file + - $ref: '../model/components.schema.yaml#/components/schemas/TimelineResponse' \ No newline at end of file diff --git a/x-pack/plugins/security_solution/common/api/timeline/persist_favorite/persist_favorite_route.schema.yaml b/x-pack/plugins/security_solution/common/api/timeline/persist_favorite/persist_favorite_route.schema.yaml index 37be8e713c917..1d1b884101f8e 100644 --- a/x-pack/plugins/security_solution/common/api/timeline/persist_favorite/persist_favorite_route.schema.yaml +++ b/x-pack/plugins/security_solution/common/api/timeline/persist_favorite/persist_favorite_route.schema.yaml @@ -36,9 +36,10 @@ paths: type: number nullable: true timelineType: - allOf: - $ref: '../model/components.schema.yaml#/components/schemas/TimelineType' nullable: true + type: object + allOf: + - $ref: '../model/components.schema.yaml#/components/schemas/TimelineType' responses: 200: description: Indicates the favorite status was successfully updated. From fdd0c16528ef5601abe13b101a151f8fbf1d0c4f Mon Sep 17 00:00:00 2001 From: Michael Olorunnisola Date: Fri, 28 Jun 2024 12:59:58 -0400 Subject: [PATCH 09/15] update with main --- .../clean_draft_timelines_route.gen.ts | 8 ++- .../create_timelines_route.gen.ts | 8 ++- .../create_timelines_route.schema.yaml | 8 +-- .../delete_note/delete_note_route.gen.ts | 8 ++- .../delete_timelines_route.gen.ts | 9 ++- .../export_timelines_route.gen.ts | 8 ++- .../get_draft_timelines_route.gen.ts | 8 ++- .../get_timeline/get_timeline_route.gen.ts | 8 ++- .../get_timeline_route.schema.yaml | 4 +- .../get_timelines/get_timelines_route.gen.ts | 8 ++- .../import_timelines_route.gen.ts | 10 ++- ...install_prepackaged_timelines_route.gen.ts | 8 ++- .../api/timeline/model/components.gen.ts | 65 +++++++++++------ .../api/timeline/model/components.schema.yaml | 70 +++++++++---------- .../patch_timeline_route.gen.ts | 8 ++- .../persist_favorite_route.gen.ts | 8 ++- .../persist_favorite_route.schema.yaml | 4 +- .../persist_note/persist_note_route.gen.ts | 10 ++- .../pinned_events/pinned_events_route.gen.ts | 12 ++-- 19 files changed, 168 insertions(+), 104 deletions(-) diff --git a/x-pack/plugins/security_solution/common/api/timeline/clean_draft_timelines/clean_draft_timelines_route.gen.ts b/x-pack/plugins/security_solution/common/api/timeline/clean_draft_timelines/clean_draft_timelines_route.gen.ts index 5e80026930d2b..ecdbf03058130 100644 --- a/x-pack/plugins/security_solution/common/api/timeline/clean_draft_timelines/clean_draft_timelines_route.gen.ts +++ b/x-pack/plugins/security_solution/common/api/timeline/clean_draft_timelines/clean_draft_timelines_route.gen.ts @@ -5,13 +5,17 @@ * 2.0. */ -import { z } from 'zod'; - /* * NOTICE: Do not edit this file manually. * This file is automatically generated by the OpenAPI Generator, @kbn/openapi-generator. + * + * info: + * title: Elastic Security - Timeline - Draft Timeline API + * version: 2023-10-31 */ +import { z } from 'zod'; + import { TimelineType, TimelineResponse } from '../model/components.gen'; export type CleanDraftTimelinesRequestBody = z.infer; diff --git a/x-pack/plugins/security_solution/common/api/timeline/create_timelines/create_timelines_route.gen.ts b/x-pack/plugins/security_solution/common/api/timeline/create_timelines/create_timelines_route.gen.ts index 38aef3e1d733f..aebe245b03f0c 100644 --- a/x-pack/plugins/security_solution/common/api/timeline/create_timelines/create_timelines_route.gen.ts +++ b/x-pack/plugins/security_solution/common/api/timeline/create_timelines/create_timelines_route.gen.ts @@ -5,13 +5,17 @@ * 2.0. */ -import { z } from 'zod'; - /* * NOTICE: Do not edit this file manually. * This file is automatically generated by the OpenAPI Generator, @kbn/openapi-generator. + * + * info: + * title: Elastic Security - Timeline - Create Timelines API + * version: 2023-10-31 */ +import { z } from 'zod'; + import { TimelineStatus, TimelineType, diff --git a/x-pack/plugins/security_solution/common/api/timeline/create_timelines/create_timelines_route.schema.yaml b/x-pack/plugins/security_solution/common/api/timeline/create_timelines/create_timelines_route.schema.yaml index 85c7a5f9b78ec..b0f92b349f77a 100644 --- a/x-pack/plugins/security_solution/common/api/timeline/create_timelines/create_timelines_route.schema.yaml +++ b/x-pack/plugins/security_solution/common/api/timeline/create_timelines/create_timelines_route.schema.yaml @@ -32,9 +32,7 @@ paths: properties: status: nullable: true - type: string - allOf: - - $ref: '../model/components.schema.yaml#/components/schemas/TimelineStatus' + $ref: '../model/components.schema.yaml#/components/schemas/TimelineStatus' timelineId: type: string nullable: true @@ -46,9 +44,7 @@ paths: nullable: true timelineType: nullable: true - type: string - allOf: - - $ref: '../model/components.schema.yaml#/components/schemas/TimelineType' + $ref: '../model/components.schema.yaml#/components/schemas/TimelineType' version: type: string nullable: true diff --git a/x-pack/plugins/security_solution/common/api/timeline/delete_note/delete_note_route.gen.ts b/x-pack/plugins/security_solution/common/api/timeline/delete_note/delete_note_route.gen.ts index ad764d66b79fb..8da6cab7bcc08 100644 --- a/x-pack/plugins/security_solution/common/api/timeline/delete_note/delete_note_route.gen.ts +++ b/x-pack/plugins/security_solution/common/api/timeline/delete_note/delete_note_route.gen.ts @@ -5,13 +5,17 @@ * 2.0. */ -import { z } from 'zod'; - /* * NOTICE: Do not edit this file manually. * This file is automatically generated by the OpenAPI Generator, @kbn/openapi-generator. + * + * info: + * title: Elastic Security - Timeline - Notes API + * version: 2023-10-31 */ +import { z } from 'zod'; + export type DeleteNoteRequestBody = z.infer; export const DeleteNoteRequestBody = z.object({ noteId: z.string().nullable(), diff --git a/x-pack/plugins/security_solution/common/api/timeline/delete_timelines/delete_timelines_route.gen.ts b/x-pack/plugins/security_solution/common/api/timeline/delete_timelines/delete_timelines_route.gen.ts index 3bc9432b586c9..474498549c415 100644 --- a/x-pack/plugins/security_solution/common/api/timeline/delete_timelines/delete_timelines_route.gen.ts +++ b/x-pack/plugins/security_solution/common/api/timeline/delete_timelines/delete_timelines_route.gen.ts @@ -5,16 +5,21 @@ * 2.0. */ -import { z } from 'zod'; - /* * NOTICE: Do not edit this file manually. * This file is automatically generated by the OpenAPI Generator, @kbn/openapi-generator. + * + * info: + * title: Elastic Security - Timeline - Delete Timelines API + * version: 2023-10-31 */ +import { z } from 'zod'; + export type DeleteTimelinesRequestBody = z.infer; export const DeleteTimelinesRequestBody = z.object({ savedObjectIds: z.array(z.string()), + searchId: z.array(z.string()).optional(), }); export type DeleteTimelinesRequestBodyInput = z.input; diff --git a/x-pack/plugins/security_solution/common/api/timeline/export_timelines/export_timelines_route.gen.ts b/x-pack/plugins/security_solution/common/api/timeline/export_timelines/export_timelines_route.gen.ts index 171bfc0c3aa7f..1ec97cb947291 100644 --- a/x-pack/plugins/security_solution/common/api/timeline/export_timelines/export_timelines_route.gen.ts +++ b/x-pack/plugins/security_solution/common/api/timeline/export_timelines/export_timelines_route.gen.ts @@ -5,13 +5,17 @@ * 2.0. */ -import { z } from 'zod'; - /* * NOTICE: Do not edit this file manually. * This file is automatically generated by the OpenAPI Generator, @kbn/openapi-generator. + * + * info: + * title: Elastic Security - Timeline - Import Timelines API + * version: 2023-10-31 */ +import { z } from 'zod'; + export type ExportTimelinesRequestQuery = z.infer; export const ExportTimelinesRequestQuery = z.object({ /** diff --git a/x-pack/plugins/security_solution/common/api/timeline/get_draft_timelines/get_draft_timelines_route.gen.ts b/x-pack/plugins/security_solution/common/api/timeline/get_draft_timelines/get_draft_timelines_route.gen.ts index 00013a540c682..db0c0db421df2 100644 --- a/x-pack/plugins/security_solution/common/api/timeline/get_draft_timelines/get_draft_timelines_route.gen.ts +++ b/x-pack/plugins/security_solution/common/api/timeline/get_draft_timelines/get_draft_timelines_route.gen.ts @@ -5,13 +5,17 @@ * 2.0. */ -import { z } from 'zod'; - /* * NOTICE: Do not edit this file manually. * This file is automatically generated by the OpenAPI Generator, @kbn/openapi-generator. + * + * info: + * title: Elastic Security - Timeline - Get Draft Timelines API + * version: 2023-10-31 */ +import { z } from 'zod'; + import { TimelineType, TimelineResponse } from '../model/components.gen'; export type GetDraftTimelinesRequestQuery = z.infer; diff --git a/x-pack/plugins/security_solution/common/api/timeline/get_timeline/get_timeline_route.gen.ts b/x-pack/plugins/security_solution/common/api/timeline/get_timeline/get_timeline_route.gen.ts index 797f7d30cb7fd..5f01b9a74e814 100644 --- a/x-pack/plugins/security_solution/common/api/timeline/get_timeline/get_timeline_route.gen.ts +++ b/x-pack/plugins/security_solution/common/api/timeline/get_timeline/get_timeline_route.gen.ts @@ -5,13 +5,17 @@ * 2.0. */ -import { z } from 'zod'; - /* * NOTICE: Do not edit this file manually. * This file is automatically generated by the OpenAPI Generator, @kbn/openapi-generator. + * + * info: + * title: Elastic Security - Timeline - Get Timeline API + * version: 2023-10-31 */ +import { z } from 'zod'; + import { TimelineResponse } from '../model/components.gen'; export type GetTimelineRequestQuery = z.infer; diff --git a/x-pack/plugins/security_solution/common/api/timeline/get_timeline/get_timeline_route.schema.yaml b/x-pack/plugins/security_solution/common/api/timeline/get_timeline/get_timeline_route.schema.yaml index 1732be47f4d0e..ca14a556b6cb3 100644 --- a/x-pack/plugins/security_solution/common/api/timeline/get_timeline/get_timeline_route.schema.yaml +++ b/x-pack/plugins/security_solution/common/api/timeline/get_timeline/get_timeline_route.schema.yaml @@ -48,6 +48,4 @@ paths: properties: getOneTimeline: nullable: true - type: object - oneOf: - - $ref: '../model/components.schema.yaml#/components/schemas/TimelineResponse' \ No newline at end of file + $ref: '../model/components.schema.yaml#/components/schemas/TimelineResponse' \ No newline at end of file diff --git a/x-pack/plugins/security_solution/common/api/timeline/get_timelines/get_timelines_route.gen.ts b/x-pack/plugins/security_solution/common/api/timeline/get_timelines/get_timelines_route.gen.ts index c1f1329abfd41..2685240a67775 100644 --- a/x-pack/plugins/security_solution/common/api/timeline/get_timelines/get_timelines_route.gen.ts +++ b/x-pack/plugins/security_solution/common/api/timeline/get_timelines/get_timelines_route.gen.ts @@ -5,13 +5,17 @@ * 2.0. */ -import { z } from 'zod'; - /* * NOTICE: Do not edit this file manually. * This file is automatically generated by the OpenAPI Generator, @kbn/openapi-generator. + * + * info: + * title: Elastic Security - Timeline - Get Timelines API + * version: 2023-10-31 */ +import { z } from 'zod'; + import { TimelineType, SortFieldTimeline, diff --git a/x-pack/plugins/security_solution/common/api/timeline/import_timelines/import_timelines_route.gen.ts b/x-pack/plugins/security_solution/common/api/timeline/import_timelines/import_timelines_route.gen.ts index be732ab4d0a98..cbe1deb98b554 100644 --- a/x-pack/plugins/security_solution/common/api/timeline/import_timelines/import_timelines_route.gen.ts +++ b/x-pack/plugins/security_solution/common/api/timeline/import_timelines/import_timelines_route.gen.ts @@ -5,18 +5,22 @@ * 2.0. */ -import { z } from 'zod'; - /* * NOTICE: Do not edit this file manually. * This file is automatically generated by the OpenAPI Generator, @kbn/openapi-generator. + * + * info: + * title: Elastic Security - Timeline - Import Timelines API + * version: 2023-10-31 */ +import { z } from 'zod'; + import { Readable, ImportTimelineResult } from '../model/components.gen'; export type ImportTimelinesRequestBody = z.infer; export const ImportTimelinesRequestBody = z.object({ - file: Readable.and( + file: Readable.merge( z.object({ hapi: z.object({ filename: z.string().optional(), diff --git a/x-pack/plugins/security_solution/common/api/timeline/install_prepackaged_timelines/install_prepackaged_timelines_route.gen.ts b/x-pack/plugins/security_solution/common/api/timeline/install_prepackaged_timelines/install_prepackaged_timelines_route.gen.ts index 008acfb2ea420..befdf84f496e4 100644 --- a/x-pack/plugins/security_solution/common/api/timeline/install_prepackaged_timelines/install_prepackaged_timelines_route.gen.ts +++ b/x-pack/plugins/security_solution/common/api/timeline/install_prepackaged_timelines/install_prepackaged_timelines_route.gen.ts @@ -5,13 +5,17 @@ * 2.0. */ -import { z } from 'zod'; - /* * NOTICE: Do not edit this file manually. * This file is automatically generated by the OpenAPI Generator, @kbn/openapi-generator. + * + * info: + * title: Elastic Security - Timeline - Install Prepackaged Timelines API + * version: 2023-10-31 */ +import { z } from 'zod'; + import { ImportTimelines, SavedTimeline, ImportTimelineResult } from '../model/components.gen'; export type InstallPrepackedTimelinesRequestBody = z.infer< diff --git a/x-pack/plugins/security_solution/common/api/timeline/model/components.gen.ts b/x-pack/plugins/security_solution/common/api/timeline/model/components.gen.ts index 32fa26c8c5a6b..319667ad4342b 100644 --- a/x-pack/plugins/security_solution/common/api/timeline/model/components.gen.ts +++ b/x-pack/plugins/security_solution/common/api/timeline/model/components.gen.ts @@ -5,16 +5,21 @@ * 2.0. */ -import { z } from 'zod'; - /* * NOTICE: Do not edit this file manually. * This file is automatically generated by the OpenAPI Generator, @kbn/openapi-generator. + * + * info: + * title: Common Timeline Attributes + * version: 2023-10-31 */ +import type { ZodTypeDef } from 'zod'; +import { z } from 'zod'; + export type PinnedEvent = z.infer; export const PinnedEvent = z.object({ - pinnedEventId: z.string(), + columns: ColumnHeaderResult.optional(), eventId: z.string(), timelineId: z.string(), created: z.number().nullable().optional(), @@ -44,11 +49,10 @@ export const BareNote = z.object({ }); export type Note = z.infer; -export const Note = BareNote.and( +export const Note = BareNote.merge( z.object({ noteId: z.string(), version: z.string(), - timelineVersion: z.string().nullable().optional(), }) ); @@ -56,13 +60,12 @@ export type GlobalNote = z.infer; export const GlobalNote = z.object({ noteId: z.string(), version: z.string(), - timelineVersion: z.string().nullable().optional(), note: z.string().nullable().optional(), timelineId: z.string().nullable().optional(), created: z.number().nullable().optional(), createdBy: z.string().nullable().optional(), updated: z.number().nullable().optional(), - updatedBy: z.string().nullable().optional(), + updatedBy: z.string().optional(), }); /** @@ -114,8 +117,31 @@ export const QueryMatchResult = z.object({ operator: z.string().optional(), }); -export type BaseDataProviderResult = z.infer; -export const BaseDataProviderResult = z.object({ +export interface DataProviderResult { + id?: string; + name?: string; + enabled?: boolean; + excluded?: boolean; + kqlQuery?: string; + queryMatch?: QueryMatchResult; + type?: DataProviderType; + and?: DataProviderResult[]; +} +export interface DataProviderResultInput { + id?: string; + name?: string; + enabled?: boolean; + excluded?: boolean; + kqlQuery?: string; + queryMatch?: QueryMatchResultInput; + type?: DataProviderTypeInput; + and?: DataProviderResultInput[]; +} +export const DataProviderResult: z.ZodType< + DataProviderResult, + ZodTypeDef, + DataProviderResultInput +> = z.object({ id: z.string().optional(), name: z.string().optional(), enabled: z.boolean().optional(), @@ -123,17 +149,9 @@ export const BaseDataProviderResult = z.object({ kqlQuery: z.string().optional(), queryMatch: QueryMatchResult.optional(), type: DataProviderType.optional(), + and: z.array(z.lazy(() => DataProviderResult)).optional(), }); -export type DataProviderResult = z.infer & { - and?: DataProviderResult[]; -}; -export const DataProviderResult: z.ZodType = BaseDataProviderResult.and( - z.object({ - and: z.array(z.lazy(() => DataProviderResult)).optional(), - }) -); - export type FavoriteTimelineResult = z.infer; export const FavoriteTimelineResult = z.object({ fullName: z.string().nullable().optional(), @@ -217,7 +235,10 @@ export const SavedTimeline = z.object({ columns: ColumnHeaderResult.nullable().optional(), created: z.number().nullable().optional(), createdBy: z.string().nullable().optional(), - dataProviders: z.array(DataProviderResult).nullable().optional(), + dataProviders: z + .array(z.lazy(() => DataProviderResult)) + .nullable() + .optional(), dataViewId: z.string().nullable().optional(), dateRange: z .object({ @@ -254,7 +275,7 @@ export const SavedTimeline = z.object({ }); export type TimelineResponse = z.infer; -export const TimelineResponse = SavedTimeline.and( +export const TimelineResponse = SavedTimeline.merge( z.object({ eventIdToNoteIds: z.array(Note).optional(), notes: z.array(Note).optional(), @@ -279,7 +300,7 @@ export const FavoriteTimelineResponse = z.object({ }); export type ImportTimelines = z.infer; -export const ImportTimelines = SavedTimeline.and( +export const ImportTimelines = SavedTimeline.merge( z.object({ savedObjectId: z.string().nullable().optional(), version: z.string().nullable().optional(), @@ -311,7 +332,7 @@ export const ImportTimelineResult = z.object({ }); export type ExportedTimelines = z.infer; -export const ExportedTimelines = SavedTimeline.and( +export const ExportedTimelines = SavedTimeline.merge( z.object({ globalNotes: z.array(Note).optional(), eventNotes: z.array(Note).optional(), diff --git a/x-pack/plugins/security_solution/common/api/timeline/model/components.schema.yaml b/x-pack/plugins/security_solution/common/api/timeline/model/components.schema.yaml index 2e61258d16ced..797f42c52efa2 100644 --- a/x-pack/plugins/security_solution/common/api/timeline/model/components.schema.yaml +++ b/x-pack/plugins/security_solution/common/api/timeline/model/components.schema.yaml @@ -11,10 +11,6 @@ components: properties: columns: $ref: '#/components/schemas/ColumnHeaderResult' - created: - type: number - createdBy: - type: string eventId: type: string timelineId: @@ -108,15 +104,19 @@ components: nullable: true updatedBy: type: string - Note: - allOf: - - $ref: '#/components/schemas/BareNote' - - type: object - properties: - noteId: - type: string - version: - type: string + TimelineStatus: + type: string + enum: + - active + - draft + - immutable + description: The status of the timeline. Valid values are `active`, `draft`, and `immutable`. + DataProviderType: + type: string + enum: + - default + - template + description: The type of data provider to create. Valid values are `default` and `template`. RowRendererId: type: string enum: @@ -151,33 +151,27 @@ components: type: string operator: type: string - BaseDataProviderResult: + DataProviderResult: type: object properties: - id: - type: string - name: - type: string - enabled: - type: boolean - excluded: - type: boolean - kqlQuery: - type: string - queryMatch: - $ref: '#/components/schemas/QueryMatchResult' - type: - $ref: '#/components/schemas/DataProviderType' - DataProviderResult: - allOf: - - $ref: '#/components/schemas/BaseDataProviderResult' - - type: object - properties: - and: - type: array - items: - x-lazy: true - $ref: '#/components/schemas/DataProviderResult' + id: + type: string + name: + type: string + enabled: + type: boolean + excluded: + type: boolean + kqlQuery: + type: string + queryMatch: + $ref: '#/components/schemas/QueryMatchResult' + type: + $ref: '#/components/schemas/DataProviderType' + and: + type: array + items: + $ref: '#/components/schemas/DataProviderResult' FavoriteTimelineResult: type: object properties: diff --git a/x-pack/plugins/security_solution/common/api/timeline/patch_timelines/patch_timeline_route.gen.ts b/x-pack/plugins/security_solution/common/api/timeline/patch_timelines/patch_timeline_route.gen.ts index bf46a85eddab9..9dd91246a9144 100644 --- a/x-pack/plugins/security_solution/common/api/timeline/patch_timelines/patch_timeline_route.gen.ts +++ b/x-pack/plugins/security_solution/common/api/timeline/patch_timelines/patch_timeline_route.gen.ts @@ -5,13 +5,17 @@ * 2.0. */ -import { z } from 'zod'; - /* * NOTICE: Do not edit this file manually. * This file is automatically generated by the OpenAPI Generator, @kbn/openapi-generator. + * + * info: + * title: Elastic Security - Timeline - Patch Timeline API + * version: 2023-10-31 */ +import { z } from 'zod'; + import { SavedTimeline, TimelineResponse } from '../model/components.gen'; export type PatchTimelineRequestBody = z.infer; diff --git a/x-pack/plugins/security_solution/common/api/timeline/persist_favorite/persist_favorite_route.gen.ts b/x-pack/plugins/security_solution/common/api/timeline/persist_favorite/persist_favorite_route.gen.ts index 3864085e66507..f85ba8f9a6866 100644 --- a/x-pack/plugins/security_solution/common/api/timeline/persist_favorite/persist_favorite_route.gen.ts +++ b/x-pack/plugins/security_solution/common/api/timeline/persist_favorite/persist_favorite_route.gen.ts @@ -5,13 +5,17 @@ * 2.0. */ -import { z } from 'zod'; - /* * NOTICE: Do not edit this file manually. * This file is automatically generated by the OpenAPI Generator, @kbn/openapi-generator. + * + * info: + * title: Elastic Security - Timeline - Favorite API (https://www.elastic.co/guide/en/security/current/timeline-api-delete.html) + * version: 2023-10-31 */ +import { z } from 'zod'; + import { TimelineType, FavoriteTimelineResponse } from '../model/components.gen'; export type PersistFavoriteRequestBody = z.infer; diff --git a/x-pack/plugins/security_solution/common/api/timeline/persist_favorite/persist_favorite_route.schema.yaml b/x-pack/plugins/security_solution/common/api/timeline/persist_favorite/persist_favorite_route.schema.yaml index 1d1b884101f8e..4c8e89c470564 100644 --- a/x-pack/plugins/security_solution/common/api/timeline/persist_favorite/persist_favorite_route.schema.yaml +++ b/x-pack/plugins/security_solution/common/api/timeline/persist_favorite/persist_favorite_route.schema.yaml @@ -37,9 +37,7 @@ paths: nullable: true timelineType: nullable: true - type: object - allOf: - - $ref: '../model/components.schema.yaml#/components/schemas/TimelineType' + $ref: '../model/components.schema.yaml#/components/schemas/TimelineType' responses: 200: description: Indicates the favorite status was successfully updated. diff --git a/x-pack/plugins/security_solution/common/api/timeline/persist_note/persist_note_route.gen.ts b/x-pack/plugins/security_solution/common/api/timeline/persist_note/persist_note_route.gen.ts index fdb0913cd874c..8653a2afd9e61 100644 --- a/x-pack/plugins/security_solution/common/api/timeline/persist_note/persist_note_route.gen.ts +++ b/x-pack/plugins/security_solution/common/api/timeline/persist_note/persist_note_route.gen.ts @@ -5,19 +5,23 @@ * 2.0. */ -import { z } from 'zod'; - /* * NOTICE: Do not edit this file manually. * This file is automatically generated by the OpenAPI Generator, @kbn/openapi-generator. + * + * info: + * title: Elastic Security - Timeline - Notes API + * version: 2023-10-31 */ +import { z } from 'zod'; + import { BareNote, Note } from '../model/components.gen'; export type PersistNoteRequestBody = z.infer; export const PersistNoteRequestBody = z.object({ note: BareNote, - overrideOwner: z.boolean().nullable().nullable(), + overrideOwner: z.boolean().nullable(), noteId: z.string().nullable(), version: z.string().nullable(), }); diff --git a/x-pack/plugins/security_solution/common/api/timeline/pinned_events/pinned_events_route.gen.ts b/x-pack/plugins/security_solution/common/api/timeline/pinned_events/pinned_events_route.gen.ts index 2d365e1a62a7a..975cdcf350a52 100644 --- a/x-pack/plugins/security_solution/common/api/timeline/pinned_events/pinned_events_route.gen.ts +++ b/x-pack/plugins/security_solution/common/api/timeline/pinned_events/pinned_events_route.gen.ts @@ -5,27 +5,31 @@ * 2.0. */ -import { z } from 'zod'; - /* * NOTICE: Do not edit this file manually. * This file is automatically generated by the OpenAPI Generator, @kbn/openapi-generator. + * + * info: + * title: Elastic Security - Timeline - Pinned Event API (https://www.elastic.co/guide/en/security/current/_pin_an_event_to_an_existing_timeline.html) + * version: 2023-10-31 */ +import { z } from 'zod'; + import { PinnedEvent } from '../model/components.gen'; export type PersistPinnedEventRequestBody = z.infer; export const PersistPinnedEventRequestBody = z.object({ eventId: z.string(), pinnedEventId: z.string().nullable(), - timelineId: z.string().nullable(), + timelineId: z.string(), }); export type PersistPinnedEventRequestBodyInput = z.input; export type PersistPinnedEventResponse = z.infer; export const PersistPinnedEventResponse = z.object({ data: z.object({ - persistPinnedEventOnTimeline: PinnedEvent.and( + persistPinnedEventOnTimeline: PinnedEvent.merge( z.object({ code: z.number().optional(), message: z.string().optional(), From 1e51fd05ed3113c4ef94a65078ecc8c45a7d3160 Mon Sep 17 00:00:00 2001 From: Michael Olorunnisola Date: Fri, 28 Jun 2024 13:00:19 -0400 Subject: [PATCH 10/15] update with main --- .../services/security_solution_api.gen.ts | 216 ++++++++++++++++++ 1 file changed, 216 insertions(+) diff --git a/x-pack/test/api_integration/services/security_solution_api.gen.ts b/x-pack/test/api_integration/services/security_solution_api.gen.ts index 9f6d717ea9dff..758be54f9d464 100644 --- a/x-pack/test/api_integration/services/security_solution_api.gen.ts +++ b/x-pack/test/api_integration/services/security_solution_api.gen.ts @@ -24,17 +24,26 @@ import { BulkCreateRulesRequestBodyInput } from '@kbn/security-solution-plugin/c import { BulkDeleteRulesRequestBodyInput } from '@kbn/security-solution-plugin/common/api/detection_engine/rule_management/bulk_crud/bulk_delete_rules/bulk_delete_rules_route.gen'; import { BulkPatchRulesRequestBodyInput } from '@kbn/security-solution-plugin/common/api/detection_engine/rule_management/bulk_crud/bulk_patch_rules/bulk_patch_rules_route.gen'; import { BulkUpdateRulesRequestBodyInput } from '@kbn/security-solution-plugin/common/api/detection_engine/rule_management/bulk_crud/bulk_update_rules/bulk_update_rules_route.gen'; +import { CleanDraftTimelinesRequestBodyInput } from '@kbn/security-solution-plugin/common/api/timeline/clean_draft_timelines/clean_draft_timelines_route.gen'; import { CreateAlertsMigrationRequestBodyInput } from '@kbn/security-solution-plugin/common/api/detection_engine/signals_migration/create_signals_migration/create_signals_migration.gen'; import { CreateRuleRequestBodyInput } from '@kbn/security-solution-plugin/common/api/detection_engine/rule_management/crud/create_rule/create_rule_route.gen'; +import { CreateTimelinesRequestBodyInput } from '@kbn/security-solution-plugin/common/api/timeline/create_timelines/create_timelines_route.gen'; +import { DeleteNoteRequestBodyInput } from '@kbn/security-solution-plugin/common/api/timeline/delete_note/delete_note_route.gen'; import { DeleteRuleRequestQueryInput } from '@kbn/security-solution-plugin/common/api/detection_engine/rule_management/crud/delete_rule/delete_rule_route.gen'; +import { DeleteTimelinesRequestBodyInput } from '@kbn/security-solution-plugin/common/api/timeline/delete_timelines/delete_timelines_route.gen'; import { ExportRulesRequestQueryInput, ExportRulesRequestBodyInput, } from '@kbn/security-solution-plugin/common/api/detection_engine/rule_management/export_rules/export_rules_route.gen'; +import { + ExportTimelinesRequestQueryInput, + ExportTimelinesRequestBodyInput, +} from '@kbn/security-solution-plugin/common/api/timeline/export_timelines/export_timelines_route.gen'; import { FinalizeAlertsMigrationRequestBodyInput } from '@kbn/security-solution-plugin/common/api/detection_engine/signals_migration/finalize_signals_migration/finalize_signals_migration.gen'; import { FindRulesRequestQueryInput } from '@kbn/security-solution-plugin/common/api/detection_engine/rule_management/find_rules/find_rules_route.gen'; import { GetAgentPolicySummaryRequestQueryInput } from '@kbn/security-solution-plugin/common/api/endpoint/policy/policy.gen'; import { GetAlertsMigrationStatusRequestQueryInput } from '@kbn/security-solution-plugin/common/api/detection_engine/signals_migration/get_signals_migration_status/get_signals_migration_status.gen'; +import { GetDraftTimelinesRequestQueryInput } from '@kbn/security-solution-plugin/common/api/timeline/get_draft_timelines/get_draft_timelines_route.gen'; import { GetEndpointSuggestionsRequestParamsInput, GetEndpointSuggestionsRequestBodyInput, @@ -48,13 +57,21 @@ import { GetRuleExecutionResultsRequestQueryInput, GetRuleExecutionResultsRequestParamsInput, } from '@kbn/security-solution-plugin/common/api/detection_engine/rule_monitoring/rule_execution_logs/get_rule_execution_results/get_rule_execution_results_route.gen'; +import { GetTimelineRequestQueryInput } from '@kbn/security-solution-plugin/common/api/timeline/get_timeline/get_timeline_route.gen'; +import { GetTimelinesRequestQueryInput } from '@kbn/security-solution-plugin/common/api/timeline/get_timelines/get_timelines_route.gen'; import { ImportRulesRequestQueryInput } from '@kbn/security-solution-plugin/common/api/detection_engine/rule_management/import_rules/import_rules_route.gen'; +import { ImportTimelinesRequestBodyInput } from '@kbn/security-solution-plugin/common/api/timeline/import_timelines/import_timelines_route.gen'; +import { InstallPrepackedTimelinesRequestBodyInput } from '@kbn/security-solution-plugin/common/api/timeline/install_prepackaged_timelines/install_prepackaged_timelines_route.gen'; import { ManageAlertTagsRequestBodyInput } from '@kbn/security-solution-plugin/common/api/detection_engine/alert_tags/set_alert_tags/set_alert_tags.gen'; import { PatchRuleRequestBodyInput } from '@kbn/security-solution-plugin/common/api/detection_engine/rule_management/crud/patch_rule/patch_rule_route.gen'; +import { PatchTimelineRequestBodyInput } from '@kbn/security-solution-plugin/common/api/timeline/patch_timelines/patch_timeline_route.gen'; import { PerformBulkActionRequestQueryInput, PerformBulkActionRequestBodyInput, } from '@kbn/security-solution-plugin/common/api/detection_engine/rule_management/bulk_actions/bulk_actions_route.gen'; +import { PersistFavoriteRequestBodyInput } from '@kbn/security-solution-plugin/common/api/timeline/persist_favorite/persist_favorite_route.gen'; +import { PersistNoteRequestBodyInput } from '@kbn/security-solution-plugin/common/api/timeline/persist_note/persist_note_route.gen'; +import { PersistPinnedEventRequestBodyInput } from '@kbn/security-solution-plugin/common/api/timeline/pinned_events/pinned_events_route.gen'; import { ReadRuleRequestQueryInput } from '@kbn/security-solution-plugin/common/api/detection_engine/rule_management/crud/read_rule/read_rule_route.gen'; import { SearchAlertsRequestBodyInput } from '@kbn/security-solution-plugin/common/api/detection_engine/signals/query_signals/query_signals_route.gen'; import { SetAlertAssigneesRequestBodyInput } from '@kbn/security-solution-plugin/common/api/detection_engine/alert_assignees/set_alert_assignees_route.gen'; @@ -127,6 +144,18 @@ after 30 days. It also deletes other artifacts specific to the migration impleme .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') .send(props.body as object); }, + /** + * Retrieves a clean draft timeline. If a draft timeline does not exist, it is created and returned. + + */ + cleanDraftTimelines(props: CleanDraftTimelinesProps) { + return supertest + .post('/api/timeline/_draft') + .set('kbn-xsrf', 'true') + .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') + .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') + .send(props.body as object); + }, createAlertsIndex() { return supertest .post('/api/detection_engine/index') @@ -153,6 +182,17 @@ after 30 days. It also deletes other artifacts specific to the migration impleme .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') .send(props.body as object); }, + /** + * Creates a new timeline. + */ + createTimelines(props: CreateTimelinesProps) { + return supertest + .post('/api/timeline') + .set('kbn-xsrf', 'true') + .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') + .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') + .send(props.body as object); + }, deleteAlertsIndex() { return supertest .delete('/api/detection_engine/index') @@ -160,6 +200,17 @@ after 30 days. It also deletes other artifacts specific to the migration impleme .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana'); }, + /** + * Deletes a note from a timeline. + */ + deleteNote(props: DeleteNoteProps) { + return supertest + .delete('/api/note') + .set('kbn-xsrf', 'true') + .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') + .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') + .send(props.body as object); + }, /** * Deletes a single rule using the `rule_id` or `id` field. */ @@ -171,6 +222,17 @@ after 30 days. It also deletes other artifacts specific to the migration impleme .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') .query(props.query); }, + /** + * Deletes one or more timelines or timeline templates. + */ + deleteTimelines(props: DeleteTimelinesProps) { + return supertest + .delete('/api/timeline') + .set('kbn-xsrf', 'true') + .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') + .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') + .send(props.body as object); + }, /** * Exports rules to an `.ndjson` file. The following configuration items are also included in the `.ndjson` file - Actions, Exception lists. Prebuilt rules cannot be exported. */ @@ -183,6 +245,18 @@ after 30 days. It also deletes other artifacts specific to the migration impleme .send(props.body as object) .query(props.query); }, + /** + * Exports timelines as an NDJSON file + */ + exportTimelines(props: ExportTimelinesProps) { + return supertest + .post('/api/timeline/_export') + .set('kbn-xsrf', 'true') + .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') + .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') + .send(props.body as object) + .query(props.query); + }, /** * The finalization endpoint replaces the original index's alias with the successfully migrated index's alias. The endpoint is idempotent; therefore, it can safely be used to poll a given migration and, upon completion, @@ -231,6 +305,17 @@ finalize it. .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') .query(props.query); }, + /** + * Retrieves the draft timeline for the current user. If the user does not have a draft timeline, an empty timeline is returned. + */ + getDraftTimelines(props: GetDraftTimelinesProps) { + return supertest + .get('/api/timeline/_draft') + .set('kbn-xsrf', 'true') + .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') + .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') + .query(props.query); + }, getEndpointSuggestions(props: GetEndpointSuggestionsProps) { return supertest .post(replaceParams('/api/endpoint/suggestions/{suggestion_type}', props.params)) @@ -274,6 +359,28 @@ finalize it. .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') .query(props.query); }, + /** + * Get an existing saved timeline or timeline template. This API is used to retrieve an existing saved timeline or timeline template. + */ + getTimeline(props: GetTimelineProps) { + return supertest + .get('/api/timeline') + .set('kbn-xsrf', 'true') + .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') + .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') + .query(props.query); + }, + /** + * This API is used to retrieve a list of existing saved timelines or timeline templates. + */ + getTimelines(props: GetTimelinesProps) { + return supertest + .get('/api/timelines') + .set('kbn-xsrf', 'true') + .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') + .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') + .query(props.query); + }, /** * Imports rules from an `.ndjson` file, including actions and exception lists. */ @@ -285,6 +392,17 @@ finalize it. .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') .query(props.query); }, + /** + * Imports timelines. + */ + importTimelines(props: ImportTimelinesProps) { + return supertest + .post('/api/timeline/_import') + .set('kbn-xsrf', 'true') + .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') + .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') + .send(props.body as object); + }, installPrebuiltRulesAndTimelines() { return supertest .put('/api/detection_engine/rules/prepackaged') @@ -292,6 +410,17 @@ finalize it. .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana'); }, + /** + * Installs prepackaged timelines. + */ + installPrepackedTimelines(props: InstallPrepackedTimelinesProps) { + return supertest + .post('/api/timeline/_prepackaged') + .set('kbn-xsrf', 'true') + .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') + .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') + .send(props.body as object); + }, manageAlertTags(props: ManageAlertTagsProps) { return supertest .post('/api/detection_engine/signals/tags') @@ -311,6 +440,17 @@ finalize it. .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') .send(props.body as object); }, + /** + * Updates an existing timeline. This API is used to update the title, description, date range, pinned events, pinned queries, and/or pinned saved queries of an existing timeline. + */ + patchTimeline(props: PatchTimelineProps) { + return supertest + .patch('/api/timeline') + .set('kbn-xsrf', 'true') + .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') + .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') + .send(props.body as object); + }, /** * The bulk action is applied to all rules that match the filter or to the list of rules by their IDs. */ @@ -323,6 +463,39 @@ finalize it. .send(props.body as object) .query(props.query); }, + /** + * Persists a given users favorite status of a timeline. + */ + persistFavorite(props: PersistFavoriteProps) { + return supertest + .patch('/api/timeline/_favorite') + .set('kbn-xsrf', 'true') + .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') + .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') + .send(props.body as object); + }, + /** + * Persists a note to a timeline. + */ + persistNote(props: PersistNoteProps) { + return supertest + .patch('/api/note') + .set('kbn-xsrf', 'true') + .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') + .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') + .send(props.body as object); + }, + /** + * Persists a pinned event to a timeline. + */ + persistPinnedEvent(props: PersistPinnedEventProps) { + return supertest + .patch('/api/pinned_event') + .set('kbn-xsrf', 'true') + .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') + .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') + .send(props.body as object); + }, /** * Read a single rule */ @@ -408,19 +581,35 @@ export interface BulkPatchRulesProps { export interface BulkUpdateRulesProps { body: BulkUpdateRulesRequestBodyInput; } +export interface CleanDraftTimelinesProps { + body: CleanDraftTimelinesRequestBodyInput; +} export interface CreateAlertsMigrationProps { body: CreateAlertsMigrationRequestBodyInput; } export interface CreateRuleProps { body: CreateRuleRequestBodyInput; } +export interface CreateTimelinesProps { + body: CreateTimelinesRequestBodyInput; +} +export interface DeleteNoteProps { + body: DeleteNoteRequestBodyInput; +} export interface DeleteRuleProps { query: DeleteRuleRequestQueryInput; } +export interface DeleteTimelinesProps { + body: DeleteTimelinesRequestBodyInput; +} export interface ExportRulesProps { query: ExportRulesRequestQueryInput; body: ExportRulesRequestBodyInput; } +export interface ExportTimelinesProps { + query: ExportTimelinesRequestQueryInput; + body: ExportTimelinesRequestBodyInput; +} export interface FinalizeAlertsMigrationProps { body: FinalizeAlertsMigrationRequestBodyInput; } @@ -433,6 +622,9 @@ export interface GetAgentPolicySummaryProps { export interface GetAlertsMigrationStatusProps { query: GetAlertsMigrationStatusRequestQueryInput; } +export interface GetDraftTimelinesProps { + query: GetDraftTimelinesRequestQueryInput; +} export interface GetEndpointSuggestionsProps { params: GetEndpointSuggestionsRequestParamsInput; body: GetEndpointSuggestionsRequestBodyInput; @@ -448,19 +640,43 @@ export interface GetRuleExecutionResultsProps { query: GetRuleExecutionResultsRequestQueryInput; params: GetRuleExecutionResultsRequestParamsInput; } +export interface GetTimelineProps { + query: GetTimelineRequestQueryInput; +} +export interface GetTimelinesProps { + query: GetTimelinesRequestQueryInput; +} export interface ImportRulesProps { query: ImportRulesRequestQueryInput; } +export interface ImportTimelinesProps { + body: ImportTimelinesRequestBodyInput; +} +export interface InstallPrepackedTimelinesProps { + body: InstallPrepackedTimelinesRequestBodyInput; +} export interface ManageAlertTagsProps { body: ManageAlertTagsRequestBodyInput; } export interface PatchRuleProps { body: PatchRuleRequestBodyInput; } +export interface PatchTimelineProps { + body: PatchTimelineRequestBodyInput; +} export interface PerformBulkActionProps { query: PerformBulkActionRequestQueryInput; body: PerformBulkActionRequestBodyInput; } +export interface PersistFavoriteProps { + body: PersistFavoriteRequestBodyInput; +} +export interface PersistNoteProps { + body: PersistNoteRequestBodyInput; +} +export interface PersistPinnedEventProps { + body: PersistPinnedEventRequestBodyInput; +} export interface ReadRuleProps { query: ReadRuleRequestQueryInput; } From 2374b794d7e1c1681e1e28e118206ddd9cacc24f Mon Sep 17 00:00:00 2001 From: Michael Olorunnisola Date: Tue, 2 Jul 2024 15:42:22 -0400 Subject: [PATCH 11/15] update with deleteNote --- .../common/api/timeline/delete_note/delete_note_route.gen.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/x-pack/plugins/security_solution/common/api/timeline/delete_note/delete_note_route.gen.ts b/x-pack/plugins/security_solution/common/api/timeline/delete_note/delete_note_route.gen.ts index 8da6cab7bcc08..095dca2001db6 100644 --- a/x-pack/plugins/security_solution/common/api/timeline/delete_note/delete_note_route.gen.ts +++ b/x-pack/plugins/security_solution/common/api/timeline/delete_note/delete_note_route.gen.ts @@ -18,6 +18,7 @@ import { z } from 'zod'; export type DeleteNoteRequestBody = z.infer; export const DeleteNoteRequestBody = z.object({ - noteId: z.string().nullable(), + noteId: z.string().nullable().optional(), + noteIds: z.array(z.string().nullable()).optional(), }); export type DeleteNoteRequestBodyInput = z.input; From 48f5a16d550dc286dadf00b5b99cf0070216d5bf Mon Sep 17 00:00:00 2001 From: Michael Olorunnisola Date: Wed, 3 Jul 2024 15:04:26 -0400 Subject: [PATCH 12/15] fix additional merge conflict --- .../clean_draft_timelines_route.schema.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/plugins/security_solution/common/api/timeline/clean_draft_timelines/clean_draft_timelines_route.schema.yaml b/x-pack/plugins/security_solution/common/api/timeline/clean_draft_timelines/clean_draft_timelines_route.schema.yaml index 04be06e3a7faf..680da29e71a20 100644 --- a/x-pack/plugins/security_solution/common/api/timeline/clean_draft_timelines/clean_draft_timelines_route.schema.yaml +++ b/x-pack/plugins/security_solution/common/api/timeline/clean_draft_timelines/clean_draft_timelines_route.schema.yaml @@ -49,7 +49,7 @@ paths: properties: timeline: $ref: '../model/components.schema.yaml#/components/schemas/TimelineResponse' - 403: + '403': description: Indicates that the user does not have the required permissions to create a draft timeline. content: application:json: From 98425194ac85ff537bf7807d2a339b8655b84ef4 Mon Sep 17 00:00:00 2001 From: Michael Olorunnisola Date: Mon, 8 Jul 2024 13:20:11 -0400 Subject: [PATCH 13/15] get openapi codegen up to date --- .../templates/zod_schema_item.handlebars | 2 + .../create_timelines_route.gen.ts | 16 ++--- .../create_timelines_route.schema.yaml | 17 ++--- .../delete_note/delete_note_route.gen.ts | 7 +- .../delete_note/delete_note_route.schema.yaml | 4 +- .../delete_timelines_route.gen.ts | 5 +- .../delete_timelines_route.schema.yaml | 2 +- .../export_timelines_route.gen.ts | 2 +- .../export_timelines_route.schema.yaml | 3 +- .../get_draft_timelines_route.schema.yaml | 2 +- ...chema.yaml => get_notes_route.schema.yaml} | 13 +++- .../get_timeline/get_timeline_route.gen.ts | 6 +- .../get_timeline_route.schema.yaml | 9 ++- .../get_timelines/get_timelines_route.gen.ts | 34 +++++----- .../get_timelines_route.schema.yaml | 67 +++++++++---------- .../import_timelines_route.gen.ts | 5 +- .../import_timelines_route.schema.yaml | 8 ++- ...ll_prepackaged_timelines_route.schema.yaml | 10 +-- .../api/timeline/model/components.schema.yaml | 12 ++-- .../patch_timeline_route.gen.ts | 4 +- .../patch_timeline_route.schema.yaml | 6 +- .../persist_favorite_route.gen.ts | 12 ++-- .../persist_favorite_route.schema.yaml | 5 +- .../persist_note/persist_note_route.gen.ts | 19 +++--- .../persist_note_route.schema.yaml | 13 +++- .../pinned_events/pinned_events_route.gen.ts | 16 +++-- .../pinned_events_route.schema.yaml | 4 +- .../services/security_solution_api.gen.ts | 60 ++++------------- 28 files changed, 178 insertions(+), 185 deletions(-) rename x-pack/plugins/security_solution/common/api/timeline/get_notes/{get_notes_route_schema.yaml => get_notes_route.schema.yaml} (81%) diff --git a/packages/kbn-openapi-generator/src/template_service/templates/zod_schema_item.handlebars b/packages/kbn-openapi-generator/src/template_service/templates/zod_schema_item.handlebars index 8e4c5aef616fb..b5e649bb8fd4c 100644 --- a/packages/kbn-openapi-generator/src/template_service/templates/zod_schema_item.handlebars +++ b/packages/kbn-openapi-generator/src/template_service/templates/zod_schema_item.handlebars @@ -25,6 +25,8 @@ {{~else~}} .merge({{> zod_schema_item }}) {{~/if~}} + {{~#if ../nullable}}.nullable(){{/if~}} + {{~#if (eq ../requiredBool false)}}.optional(){{/if~}} {{~/each~}} {{~/if~}} diff --git a/x-pack/plugins/security_solution/common/api/timeline/create_timelines/create_timelines_route.gen.ts b/x-pack/plugins/security_solution/common/api/timeline/create_timelines/create_timelines_route.gen.ts index aebe245b03f0c..27e0fc5b7db46 100644 --- a/x-pack/plugins/security_solution/common/api/timeline/create_timelines/create_timelines_route.gen.ts +++ b/x-pack/plugins/security_solution/common/api/timeline/create_timelines/create_timelines_route.gen.ts @@ -25,12 +25,12 @@ import { export type CreateTimelinesRequestBody = z.infer; export const CreateTimelinesRequestBody = z.object({ - status: TimelineStatus.nullable(), - timelineId: z.string().nullable(), - templateTimelineId: z.string().nullable(), - templateTimelineVersion: z.number().nullable(), - timelineType: TimelineType.nullable(), - version: z.string().nullable(), + status: TimelineStatus.nullable().optional(), + timelineId: z.string().nullable().optional(), + templateTimelineId: z.string().nullable().optional(), + templateTimelineVersion: z.number().nullable().optional(), + timelineType: TimelineType.nullable().optional(), + version: z.string().nullable().optional(), timeline: SavedTimeline, }); export type CreateTimelinesRequestBodyInput = z.input; @@ -38,8 +38,6 @@ export type CreateTimelinesRequestBodyInput = z.input; export const CreateTimelinesResponse = z.object({ data: z.object({ - persistTimeline: z.object({ - timeline: TimelineResponse, - }), + persistTimeline: TimelineResponse, }), }); diff --git a/x-pack/plugins/security_solution/common/api/timeline/create_timelines/create_timelines_route.schema.yaml b/x-pack/plugins/security_solution/common/api/timeline/create_timelines/create_timelines_route.schema.yaml index 1d56b2f75fe68..38a666111f13e 100644 --- a/x-pack/plugins/security_solution/common/api/timeline/create_timelines/create_timelines_route.schema.yaml +++ b/x-pack/plugins/security_solution/common/api/timeline/create_timelines/create_timelines_route.schema.yaml @@ -15,7 +15,7 @@ servers: paths: /api/timeline: post: - operationId: createTimelines + operationId: CreateTimelines x-codegen-enabled: true summary: Creates a new timeline. tags: @@ -27,12 +27,12 @@ paths: application/json: schema: type: object - required: - [status, timelineId, templateTimelineId, templateTimelineVersion, timelineType, version, timeline] + required: [timeline] properties: status: nullable: true - $ref: '../model/components.schema.yaml#/components/schemas/TimelineStatus' + allOf: + - $ref: '../model/components.schema.yaml#/components/schemas/TimelineStatus' timelineId: type: string nullable: true @@ -44,7 +44,8 @@ paths: nullable: true timelineType: nullable: true - $ref: '../model/components.schema.yaml#/components/schemas/TimelineType' + allOf: + - $ref: '../model/components.schema.yaml#/components/schemas/TimelineType' version: type: string nullable: true @@ -64,11 +65,7 @@ paths: required: [persistTimeline] properties: persistTimeline: - type: object - required: [timeline] - properties: - timeline: - $ref: '../model/components.schema.yaml#/components/schemas/TimelineResponse' + $ref: '../model/components.schema.yaml#/components/schemas/TimelineResponse' '405': description: Indicates that there was an error in the timeline creation. content: diff --git a/x-pack/plugins/security_solution/common/api/timeline/delete_note/delete_note_route.gen.ts b/x-pack/plugins/security_solution/common/api/timeline/delete_note/delete_note_route.gen.ts index 095dca2001db6..b26439b67737c 100644 --- a/x-pack/plugins/security_solution/common/api/timeline/delete_note/delete_note_route.gen.ts +++ b/x-pack/plugins/security_solution/common/api/timeline/delete_note/delete_note_route.gen.ts @@ -19,6 +19,11 @@ import { z } from 'zod'; export type DeleteNoteRequestBody = z.infer; export const DeleteNoteRequestBody = z.object({ noteId: z.string().nullable().optional(), - noteIds: z.array(z.string().nullable()).optional(), + noteIds: z.array(z.string()).nullable().optional(), }); export type DeleteNoteRequestBodyInput = z.input; + +export type DeleteNoteResponse = z.infer; +export const DeleteNoteResponse = z.object({ + data: z.object({}).optional(), +}); diff --git a/x-pack/plugins/security_solution/common/api/timeline/delete_note/delete_note_route.schema.yaml b/x-pack/plugins/security_solution/common/api/timeline/delete_note/delete_note_route.schema.yaml index d7d101de63388..36594f8a941e8 100644 --- a/x-pack/plugins/security_solution/common/api/timeline/delete_note/delete_note_route.schema.yaml +++ b/x-pack/plugins/security_solution/common/api/timeline/delete_note/delete_note_route.schema.yaml @@ -13,7 +13,7 @@ paths: /api/note: delete: x-codegen-enabled: true - operationId: deleteNote + operationId: DeleteNote summary: Deletes a note from a timeline. tags: - access:securitySolution @@ -29,10 +29,10 @@ paths: type: string nullable: true noteIds: + nullable: true type: array items: type: string - nullable: true responses: '200': description: Indicates the note was successfully deleted. diff --git a/x-pack/plugins/security_solution/common/api/timeline/delete_timelines/delete_timelines_route.gen.ts b/x-pack/plugins/security_solution/common/api/timeline/delete_timelines/delete_timelines_route.gen.ts index 474498549c415..a52a5779770b3 100644 --- a/x-pack/plugins/security_solution/common/api/timeline/delete_timelines/delete_timelines_route.gen.ts +++ b/x-pack/plugins/security_solution/common/api/timeline/delete_timelines/delete_timelines_route.gen.ts @@ -19,7 +19,10 @@ import { z } from 'zod'; export type DeleteTimelinesRequestBody = z.infer; export const DeleteTimelinesRequestBody = z.object({ savedObjectIds: z.array(z.string()), - searchId: z.array(z.string()).optional(), + /** + * Saved search ids that should be deleted alongside the timelines + */ + searchIds: z.array(z.string()).optional(), }); export type DeleteTimelinesRequestBodyInput = z.input; diff --git a/x-pack/plugins/security_solution/common/api/timeline/delete_timelines/delete_timelines_route.schema.yaml b/x-pack/plugins/security_solution/common/api/timeline/delete_timelines/delete_timelines_route.schema.yaml index c759fcec0b47a..b32879e33c97c 100644 --- a/x-pack/plugins/security_solution/common/api/timeline/delete_timelines/delete_timelines_route.schema.yaml +++ b/x-pack/plugins/security_solution/common/api/timeline/delete_timelines/delete_timelines_route.schema.yaml @@ -16,7 +16,7 @@ paths: /api/timeline: delete: x-codegen-enabled: true - operationId: deleteTimelines + operationId: DeleteTimelines summary: Deletes one or more timelines or timeline templates. tags: - access:securitySolution diff --git a/x-pack/plugins/security_solution/common/api/timeline/export_timelines/export_timelines_route.gen.ts b/x-pack/plugins/security_solution/common/api/timeline/export_timelines/export_timelines_route.gen.ts index 1ec97cb947291..fbe1957522b75 100644 --- a/x-pack/plugins/security_solution/common/api/timeline/export_timelines/export_timelines_route.gen.ts +++ b/x-pack/plugins/security_solution/common/api/timeline/export_timelines/export_timelines_route.gen.ts @@ -27,6 +27,6 @@ export type ExportTimelinesRequestQueryInput = z.input; export const ExportTimelinesRequestBody = z.object({ - ids: z.array(z.string()).nullable(), + ids: z.array(z.string()).nullable().optional(), }); export type ExportTimelinesRequestBodyInput = z.input; diff --git a/x-pack/plugins/security_solution/common/api/timeline/export_timelines/export_timelines_route.schema.yaml b/x-pack/plugins/security_solution/common/api/timeline/export_timelines/export_timelines_route.schema.yaml index c747d81bae3fc..f846380f2bcaa 100644 --- a/x-pack/plugins/security_solution/common/api/timeline/export_timelines/export_timelines_route.schema.yaml +++ b/x-pack/plugins/security_solution/common/api/timeline/export_timelines/export_timelines_route.schema.yaml @@ -16,7 +16,7 @@ paths: /api/timeline/_export: post: x-codegen-enabled: true - operationId: exportTimelines + operationId: ExportTimelines summary: Exports timelines as an NDJSON file tags: - access:securitySolution @@ -34,7 +34,6 @@ paths: application/json: schema: type: object - required: [ids] properties: ids: nullable: true diff --git a/x-pack/plugins/security_solution/common/api/timeline/get_draft_timelines/get_draft_timelines_route.schema.yaml b/x-pack/plugins/security_solution/common/api/timeline/get_draft_timelines/get_draft_timelines_route.schema.yaml index 83f9c25f8acc2..83e569075e30c 100644 --- a/x-pack/plugins/security_solution/common/api/timeline/get_draft_timelines/get_draft_timelines_route.schema.yaml +++ b/x-pack/plugins/security_solution/common/api/timeline/get_draft_timelines/get_draft_timelines_route.schema.yaml @@ -16,7 +16,7 @@ paths: /api/timeline/_draft: get: x-codegen-enabled: true - operationId: getDraftTimelines + operationId: GetDraftTimelines summary: Retrieves the draft timeline for the current user. If the user does not have a draft timeline, an empty timeline is returned. tags: - access:securitySolution diff --git a/x-pack/plugins/security_solution/common/api/timeline/get_notes/get_notes_route_schema.yaml b/x-pack/plugins/security_solution/common/api/timeline/get_notes/get_notes_route.schema.yaml similarity index 81% rename from x-pack/plugins/security_solution/common/api/timeline/get_notes/get_notes_route_schema.yaml rename to x-pack/plugins/security_solution/common/api/timeline/get_notes/get_notes_route.schema.yaml index a78b7e6f9cbee..af0c57a63dc12 100644 --- a/x-pack/plugins/security_solution/common/api/timeline/get_notes/get_notes_route_schema.yaml +++ b/x-pack/plugins/security_solution/common/api/timeline/get_notes/get_notes_route.schema.yaml @@ -12,14 +12,17 @@ servers: paths: /api/note: get: - operationId: getNotes + operationId: GetNotes description: Gets notes + summary: Get all notes for a given document. tags: - access:securitySolution parameters: - name: documentIds in: query + required: true schema: + nullable: true oneOf: - type: array items: @@ -27,34 +30,40 @@ paths: - type: string - name: page in: query + required: true schema: type: number nullable: true - name: perPage in: query + required: true schema: type: number nullable: true - name: search in: query + required: true schema: type: string nullable: true - name: sortField in: query + required: true schema: type: string nullable: true - name: sortOrder in: query + required: true schema: type: string nullable: true - name: filter in: query + required: true schema: type: string nullable: true responses: - 200: + '200': description: Indicates the requested notes were returned. diff --git a/x-pack/plugins/security_solution/common/api/timeline/get_timeline/get_timeline_route.gen.ts b/x-pack/plugins/security_solution/common/api/timeline/get_timeline/get_timeline_route.gen.ts index 5f01b9a74e814..d178b80e35b7f 100644 --- a/x-pack/plugins/security_solution/common/api/timeline/get_timeline/get_timeline_route.gen.ts +++ b/x-pack/plugins/security_solution/common/api/timeline/get_timeline/get_timeline_route.gen.ts @@ -23,17 +23,17 @@ export const GetTimelineRequestQuery = z.object({ /** * The ID of the template timeline to retrieve */ - template_timeline_id: z.string(), + template_timeline_id: z.string().optional(), /** * The ID of the timeline to retrieve */ - id: z.string(), + id: z.string().optional(), }); export type GetTimelineRequestQueryInput = z.input; export type GetTimelineResponse = z.infer; export const GetTimelineResponse = z.object({ data: z.object({ - getOneTimeline: TimelineResponse.nullable().optional(), + getOneTimeline: TimelineResponse.nullable(), }), }); diff --git a/x-pack/plugins/security_solution/common/api/timeline/get_timeline/get_timeline_route.schema.yaml b/x-pack/plugins/security_solution/common/api/timeline/get_timeline/get_timeline_route.schema.yaml index b4e7aae302444..53f9a3861a72f 100644 --- a/x-pack/plugins/security_solution/common/api/timeline/get_timeline/get_timeline_route.schema.yaml +++ b/x-pack/plugins/security_solution/common/api/timeline/get_timeline/get_timeline_route.schema.yaml @@ -16,20 +16,18 @@ paths: /api/timeline: get: x-codegen-enabled: true - operationId: getTimeline + operationId: GetTimeline summary: Get an existing saved timeline or timeline template. This API is used to retrieve an existing saved timeline or timeline template. tags: - access:securitySolution parameters: - in: query name: template_timeline_id - required: true schema: type: string description: The ID of the template timeline to retrieve - in: query name: id - required: true schema: type: string description: The ID of the timeline to retrieve @@ -44,8 +42,9 @@ paths: properties: data: type: object - required: [getOnetimeline] + required: [getOneTimeline] properties: getOneTimeline: nullable: true - $ref: '../model/components.schema.yaml#/components/schemas/TimelineResponse' \ No newline at end of file + allOf: + - $ref: '../model/components.schema.yaml#/components/schemas/TimelineResponse' \ No newline at end of file diff --git a/x-pack/plugins/security_solution/common/api/timeline/get_timelines/get_timelines_route.gen.ts b/x-pack/plugins/security_solution/common/api/timeline/get_timelines/get_timelines_route.gen.ts index 2685240a67775..34689edd726d1 100644 --- a/x-pack/plugins/security_solution/common/api/timeline/get_timelines/get_timelines_route.gen.ts +++ b/x-pack/plugins/security_solution/common/api/timeline/get_timelines/get_timelines_route.gen.ts @@ -28,26 +28,30 @@ export const GetTimelinesRequestQuery = z.object({ /** * If true, only timelines that are marked as favorites by the user are returned. */ - only_user_favorite: z.enum(['true', 'false']).nullable(), - timeline_type: TimelineType.nullable(), - sort_field: SortFieldTimeline, - sort_order: z.enum(['asc', 'desc']), - page_size: z.string().nullable(), - page_index: z.string().nullable(), - search: z.string().nullable(), - status: TimelineStatus.nullable(), + only_user_favorite: z.enum(['true', 'false']).nullable().optional(), + timeline_type: TimelineType.optional(), + sort_field: SortFieldTimeline.optional(), + sort_order: z.enum(['asc', 'desc']).optional(), + page_size: z.string().nullable().optional(), + page_index: z.string().nullable().optional(), + search: z.string().nullable().optional(), + status: TimelineStatus.optional(), }); export type GetTimelinesRequestQueryInput = z.input; export type GetTimelinesResponse = z.infer; export const GetTimelinesResponse = z.object({ data: z.object({ - timelines: z.array(TimelineResponse), - totalCount: z.number(), - defaultTimelineCount: z.number(), - templateTimelineCount: z.number(), - favoriteCount: z.number(), - elasticTemplateTimelineCount: z.number(), - customTemplateTimelineCount: z.number(), + getOneTimeline: z + .object({ + timelines: z.array(TimelineResponse), + totalCount: z.number(), + defaultTimelineCount: z.number(), + templateTimelineCount: z.number(), + favoriteCount: z.number(), + elasticTemplateTimelineCount: z.number(), + customTemplateTimelineCount: z.number(), + }) + .optional(), }), }); diff --git a/x-pack/plugins/security_solution/common/api/timeline/get_timelines/get_timelines_route.schema.yaml b/x-pack/plugins/security_solution/common/api/timeline/get_timelines/get_timelines_route.schema.yaml index dd58f3731a911..e735f923483cb 100644 --- a/x-pack/plugins/security_solution/common/api/timeline/get_timelines/get_timelines_route.schema.yaml +++ b/x-pack/plugins/security_solution/common/api/timeline/get_timelines/get_timelines_route.schema.yaml @@ -16,14 +16,13 @@ paths: /api/timelines: get: x-codegen-enabled: true - operationId: getTimelines + operationId: GetTimelines summary: This API is used to retrieve a list of existing saved timelines or timeline templates. tags: - access:securitySolution parameters: - in: query name: only_user_favorite - required: true schema: nullable: true type: string @@ -33,18 +32,14 @@ paths: description: If true, only timelines that are marked as favorites by the user are returned. - in: query name: timeline_type - required: true schema: $ref: '../model/components.schema.yaml#/components/schemas/TimelineType' - nullable: true - in: query name: sort_field - required: true schema: $ref: '../model/components.schema.yaml#/components/schemas/SortFieldTimeline' - in: query name: sort_order - required: true schema: type: string enum: @@ -52,28 +47,23 @@ paths: - desc - in: query name: page_size - required: true schema: nullable: true type: string - in: query name: page_index - required: true schema: nullable: true type: string - in: query name: search - required: true schema: nullable: true type: string - in: query name: status - required: true schema: $ref: '../model/components.schema.yaml#/components/schemas/TimelineStatus' - nullable: true responses: '200': description: Indicates that the (template) timelines were found and returned. @@ -85,33 +75,36 @@ paths: properties: data: type: object - required: - [ - timelines, - totalCount, - defaultTimelineCount, - templateTimelineCount, - favoriteCount, - elasticTemplateTimelineCount, - customTemplateTimelineCount, - ] properties: - timelines: - type: array - items: - $ref: '../model/components.schema.yaml#/components/schemas/TimelineResponse' - totalCount: - type: number - defaultTimelineCount: - type: number - templateTimelineCount: - type: number - favoriteCount: - type: number - elasticTemplateTimelineCount: - type: number - customTemplateTimelineCount: - type: number + getOneTimeline: + type: object + required: + [ + timelines, + totalCount, + defaultTimelineCount, + templateTimelineCount, + favoriteCount, + elasticTemplateTimelineCount, + customTemplateTimelineCount, + ] + properties: + timelines: + type: array + items: + $ref: '../model/components.schema.yaml#/components/schemas/TimelineResponse' + totalCount: + type: number + defaultTimelineCount: + type: number + templateTimelineCount: + type: number + favoriteCount: + type: number + elasticTemplateTimelineCount: + type: number + customTemplateTimelineCount: + type: number '400': description: Bad request. The user supplied invalid data. content: diff --git a/x-pack/plugins/security_solution/common/api/timeline/import_timelines/import_timelines_route.gen.ts b/x-pack/plugins/security_solution/common/api/timeline/import_timelines/import_timelines_route.gen.ts index cbe1deb98b554..650b41d7746aa 100644 --- a/x-pack/plugins/security_solution/common/api/timeline/import_timelines/import_timelines_route.gen.ts +++ b/x-pack/plugins/security_solution/common/api/timeline/import_timelines/import_timelines_route.gen.ts @@ -23,9 +23,10 @@ export const ImportTimelinesRequestBody = z.object({ file: Readable.merge( z.object({ hapi: z.object({ - filename: z.string().optional(), - headers: z.object({}).optional(), + filename: z.string(), + headers: z.object({}), }), + isImmutable: z.enum(['true', 'false']).optional(), }) ), }); diff --git a/x-pack/plugins/security_solution/common/api/timeline/import_timelines/import_timelines_route.schema.yaml b/x-pack/plugins/security_solution/common/api/timeline/import_timelines/import_timelines_route.schema.yaml index b90c3273acec5..5a70d3de9c8fd 100644 --- a/x-pack/plugins/security_solution/common/api/timeline/import_timelines/import_timelines_route.schema.yaml +++ b/x-pack/plugins/security_solution/common/api/timeline/import_timelines/import_timelines_route.schema.yaml @@ -16,7 +16,7 @@ paths: /api/timeline/_import: post: x-codegen-enabled: true - operationId: importTimelines + operationId: ImportTimelines summary: Imports timelines. tags: - access:securitySolution @@ -37,11 +37,17 @@ paths: properties: hapi: type: object + required: [filename, headers] properties: filename: type: string headers: type: object + isImmutable: + type: string + enum: + - 'true' + - 'false' responses: '200': description: Indicates the import of timelines was successful. diff --git a/x-pack/plugins/security_solution/common/api/timeline/install_prepackaged_timelines/install_prepackaged_timelines_route.schema.yaml b/x-pack/plugins/security_solution/common/api/timeline/install_prepackaged_timelines/install_prepackaged_timelines_route.schema.yaml index 6efdd2cc4ff62..8de6f3d444ffa 100644 --- a/x-pack/plugins/security_solution/common/api/timeline/install_prepackaged_timelines/install_prepackaged_timelines_route.schema.yaml +++ b/x-pack/plugins/security_solution/common/api/timeline/install_prepackaged_timelines/install_prepackaged_timelines_route.schema.yaml @@ -13,7 +13,7 @@ paths: /api/timeline/_prepackaged: post: x-codegen-enabled: true - operationId: installPrepackedTimelines + operationId: InstallPrepackedTimelines summary: Installs prepackaged timelines. tags: - access:securitySolution @@ -29,15 +29,15 @@ paths: timelinesToInstall: type: array items: - allOf: - $ref: '../model/components.schema.yaml#/components/schemas/ImportTimelines' nullable: true + allOf: + - $ref: '../model/components.schema.yaml#/components/schemas/ImportTimelines' timelinesToUpdate: type: array items: - allOf: - $ref: '../model/components.schema.yaml#/components/schemas/ImportTimelines' nullable: true + allOf: + - $ref: '../model/components.schema.yaml#/components/schemas/ImportTimelines' prepackagedTimelines: type: array items: diff --git a/x-pack/plugins/security_solution/common/api/timeline/model/components.schema.yaml b/x-pack/plugins/security_solution/common/api/timeline/model/components.schema.yaml index 797f42c52efa2..4b7b6b6c60e06 100644 --- a/x-pack/plugins/security_solution/common/api/timeline/model/components.schema.yaml +++ b/x-pack/plugins/security_solution/common/api/timeline/model/components.schema.yaml @@ -286,8 +286,9 @@ components: type: object properties: columns: - $ref: '#/components/schemas/ColumnHeaderResult' nullable: true + allOf: + - $ref: '#/components/schemas/ColumnHeaderResult' created: type: number nullable: true @@ -350,7 +351,8 @@ components: nullable: true kqlQuery: nullable: true - $ref: '#/components/schemas/SerializedFilterQueryResult' + allOf: + - $ref: '#/components/schemas/SerializedFilterQueryResult' indexNames: type: array nullable: true @@ -361,7 +363,8 @@ components: nullable: true sort: nullable: true - $ref: '#/components/schemas/Sort' + allOf: + - $ref: '#/components/schemas/Sort' status: type: string nullable: true @@ -380,7 +383,8 @@ components: nullable: true timelineType: nullable: true - $ref: '#/components/schemas/TimelineType' + allOf: + - $ref: '#/components/schemas/TimelineType' updated: type: number nullable: true diff --git a/x-pack/plugins/security_solution/common/api/timeline/patch_timelines/patch_timeline_route.gen.ts b/x-pack/plugins/security_solution/common/api/timeline/patch_timelines/patch_timeline_route.gen.ts index 9dd91246a9144..53c9b7b84d8a8 100644 --- a/x-pack/plugins/security_solution/common/api/timeline/patch_timelines/patch_timeline_route.gen.ts +++ b/x-pack/plugins/security_solution/common/api/timeline/patch_timelines/patch_timeline_route.gen.ts @@ -29,8 +29,6 @@ export type PatchTimelineRequestBodyInput = z.input; export const PatchTimelineResponse = z.object({ data: z.object({ - persistTimeline: z.object({ - timeline: TimelineResponse, - }), + persistTimeline: TimelineResponse, }), }); diff --git a/x-pack/plugins/security_solution/common/api/timeline/patch_timelines/patch_timeline_route.schema.yaml b/x-pack/plugins/security_solution/common/api/timeline/patch_timelines/patch_timeline_route.schema.yaml index 109c2509f3038..1b264867c7ffd 100644 --- a/x-pack/plugins/security_solution/common/api/timeline/patch_timelines/patch_timeline_route.schema.yaml +++ b/x-pack/plugins/security_solution/common/api/timeline/patch_timelines/patch_timeline_route.schema.yaml @@ -49,11 +49,7 @@ paths: required: [persistTimeline] properties: persistTimeline: - type: object - required: [timeline] - properties: - timeline: - $ref: '../model/components.schema.yaml#/components/schemas/TimelineResponse' + $ref: '../model/components.schema.yaml#/components/schemas/TimelineResponse' '405': description: Indicates that the user does not have the required access to create a draft timeline. content: diff --git a/x-pack/plugins/security_solution/common/api/timeline/persist_favorite/persist_favorite_route.gen.ts b/x-pack/plugins/security_solution/common/api/timeline/persist_favorite/persist_favorite_route.gen.ts index f85ba8f9a6866..f28483e8f0e66 100644 --- a/x-pack/plugins/security_solution/common/api/timeline/persist_favorite/persist_favorite_route.gen.ts +++ b/x-pack/plugins/security_solution/common/api/timeline/persist_favorite/persist_favorite_route.gen.ts @@ -10,7 +10,7 @@ * This file is automatically generated by the OpenAPI Generator, @kbn/openapi-generator. * * info: - * title: Elastic Security - Timeline - Favorite API (https://www.elastic.co/guide/en/security/current/timeline-api-delete.html) + * title: Elastic Security - Timeline - Favorite API * version: 2023-10-31 */ @@ -18,17 +18,17 @@ import { z } from 'zod'; import { TimelineType, FavoriteTimelineResponse } from '../model/components.gen'; -export type PersistFavoriteRequestBody = z.infer; -export const PersistFavoriteRequestBody = z.object({ +export type PersistFavoriteRouteRequestBody = z.infer; +export const PersistFavoriteRouteRequestBody = z.object({ timelineId: z.string().nullable(), templateTimelineId: z.string().nullable(), templateTimelineVersion: z.number().nullable(), timelineType: TimelineType.nullable(), }); -export type PersistFavoriteRequestBodyInput = z.input; +export type PersistFavoriteRouteRequestBodyInput = z.input; -export type PersistFavoriteResponse = z.infer; -export const PersistFavoriteResponse = z.object({ +export type PersistFavoriteRouteResponse = z.infer; +export const PersistFavoriteRouteResponse = z.object({ data: z.object({ persistFavorite: FavoriteTimelineResponse, }), diff --git a/x-pack/plugins/security_solution/common/api/timeline/persist_favorite/persist_favorite_route.schema.yaml b/x-pack/plugins/security_solution/common/api/timeline/persist_favorite/persist_favorite_route.schema.yaml index 862d1a26c6649..b9b0edc5d82b1 100644 --- a/x-pack/plugins/security_solution/common/api/timeline/persist_favorite/persist_favorite_route.schema.yaml +++ b/x-pack/plugins/security_solution/common/api/timeline/persist_favorite/persist_favorite_route.schema.yaml @@ -13,7 +13,7 @@ paths: /api/timeline/_favorite: patch: x-codegen-enabled: true - operationId: persistFavoriteRoute + operationId: PersistFavoriteRoute summary: Persists a given users favorite status of a timeline. tags: - access:securitySolution @@ -37,7 +37,8 @@ paths: nullable: true timelineType: nullable: true - $ref: '../model/components.schema.yaml#/components/schemas/TimelineType' + allOf: + - $ref: '../model/components.schema.yaml#/components/schemas/TimelineType' responses: '200': description: Indicates the favorite status was successfully updated. diff --git a/x-pack/plugins/security_solution/common/api/timeline/persist_note/persist_note_route.gen.ts b/x-pack/plugins/security_solution/common/api/timeline/persist_note/persist_note_route.gen.ts index 8653a2afd9e61..5cbb0464218fb 100644 --- a/x-pack/plugins/security_solution/common/api/timeline/persist_note/persist_note_route.gen.ts +++ b/x-pack/plugins/security_solution/common/api/timeline/persist_note/persist_note_route.gen.ts @@ -18,17 +18,20 @@ import { z } from 'zod'; import { BareNote, Note } from '../model/components.gen'; -export type PersistNoteRequestBody = z.infer; -export const PersistNoteRequestBody = z.object({ +export type PersistNoteRouteRequestBody = z.infer; +export const PersistNoteRouteRequestBody = z.object({ note: BareNote, - overrideOwner: z.boolean().nullable(), - noteId: z.string().nullable(), - version: z.string().nullable(), + overrideOwner: z.boolean().nullable().optional(), + noteId: z.string().nullable().optional(), + version: z.string().nullable().optional(), + eventIngested: z.string().nullable().optional(), + eventTimestamp: z.string().nullable().optional(), + eventDataView: z.string().nullable().optional(), }); -export type PersistNoteRequestBodyInput = z.input; +export type PersistNoteRouteRequestBodyInput = z.input; -export type PersistNoteResponse = z.infer; -export const PersistNoteResponse = z.object({ +export type PersistNoteRouteResponse = z.infer; +export const PersistNoteRouteResponse = z.object({ data: z.object({ persistNote: z.object({ code: z.number(), diff --git a/x-pack/plugins/security_solution/common/api/timeline/persist_note/persist_note_route.schema.yaml b/x-pack/plugins/security_solution/common/api/timeline/persist_note/persist_note_route.schema.yaml index 65a1aac0325f5..81d5e2fb67cc7 100644 --- a/x-pack/plugins/security_solution/common/api/timeline/persist_note/persist_note_route.schema.yaml +++ b/x-pack/plugins/security_solution/common/api/timeline/persist_note/persist_note_route.schema.yaml @@ -16,7 +16,7 @@ paths: /api/note: patch: x-codegen-enabled: true - operationId: persistNoteRoute + operationId: PersistNoteRoute summary: Persists a note to a timeline. tags: - access:securitySolution @@ -27,7 +27,7 @@ paths: application/json: schema: type: object - required: [note, overrideOwner, noteId, version] + required: [note] properties: note: $ref: '../model/components.schema.yaml#/components/schemas/BareNote' @@ -40,6 +40,15 @@ paths: version: type: string nullable: true + eventIngested: + type: string + nullable: true + eventTimestamp: + type: string + nullable: true + eventDataView: + type: string + nullable: true responses: '200': description: Indicates the note was successfully created. diff --git a/x-pack/plugins/security_solution/common/api/timeline/pinned_events/pinned_events_route.gen.ts b/x-pack/plugins/security_solution/common/api/timeline/pinned_events/pinned_events_route.gen.ts index 975cdcf350a52..20556779db7c4 100644 --- a/x-pack/plugins/security_solution/common/api/timeline/pinned_events/pinned_events_route.gen.ts +++ b/x-pack/plugins/security_solution/common/api/timeline/pinned_events/pinned_events_route.gen.ts @@ -10,7 +10,7 @@ * This file is automatically generated by the OpenAPI Generator, @kbn/openapi-generator. * * info: - * title: Elastic Security - Timeline - Pinned Event API (https://www.elastic.co/guide/en/security/current/_pin_an_event_to_an_existing_timeline.html) + * title: Elastic Security - Timeline - Pinned Event API * version: 2023-10-31 */ @@ -18,16 +18,18 @@ import { z } from 'zod'; import { PinnedEvent } from '../model/components.gen'; -export type PersistPinnedEventRequestBody = z.infer; -export const PersistPinnedEventRequestBody = z.object({ +export type PersistPinnedEventRouteRequestBody = z.infer; +export const PersistPinnedEventRouteRequestBody = z.object({ eventId: z.string(), - pinnedEventId: z.string().nullable(), + pinnedEventId: z.string().nullable().optional(), timelineId: z.string(), }); -export type PersistPinnedEventRequestBodyInput = z.input; +export type PersistPinnedEventRouteRequestBodyInput = z.input< + typeof PersistPinnedEventRouteRequestBody +>; -export type PersistPinnedEventResponse = z.infer; -export const PersistPinnedEventResponse = z.object({ +export type PersistPinnedEventRouteResponse = z.infer; +export const PersistPinnedEventRouteResponse = z.object({ data: z.object({ persistPinnedEventOnTimeline: PinnedEvent.merge( z.object({ diff --git a/x-pack/plugins/security_solution/common/api/timeline/pinned_events/pinned_events_route.schema.yaml b/x-pack/plugins/security_solution/common/api/timeline/pinned_events/pinned_events_route.schema.yaml index 8c2351f29150d..ba5229f48e6e3 100644 --- a/x-pack/plugins/security_solution/common/api/timeline/pinned_events/pinned_events_route.schema.yaml +++ b/x-pack/plugins/security_solution/common/api/timeline/pinned_events/pinned_events_route.schema.yaml @@ -16,7 +16,7 @@ paths: /api/pinned_event: patch: x-codegen-enabled: true - operationId: persistPinnedEventRoute + operationId: PersistPinnedEventRoute summary: Persists a pinned event to a timeline. tags: - access:securitySolution @@ -27,7 +27,7 @@ paths: application/json: schema: type: object - required: [eventId, pinnedEventId, timelineId] + required: [eventId, timelineId] properties: eventId: type: string diff --git a/x-pack/test/api_integration/services/security_solution_api.gen.ts b/x-pack/test/api_integration/services/security_solution_api.gen.ts index 758be54f9d464..e06db3f581757 100644 --- a/x-pack/test/api_integration/services/security_solution_api.gen.ts +++ b/x-pack/test/api_integration/services/security_solution_api.gen.ts @@ -69,9 +69,9 @@ import { PerformBulkActionRequestQueryInput, PerformBulkActionRequestBodyInput, } from '@kbn/security-solution-plugin/common/api/detection_engine/rule_management/bulk_actions/bulk_actions_route.gen'; -import { PersistFavoriteRequestBodyInput } from '@kbn/security-solution-plugin/common/api/timeline/persist_favorite/persist_favorite_route.gen'; -import { PersistNoteRequestBodyInput } from '@kbn/security-solution-plugin/common/api/timeline/persist_note/persist_note_route.gen'; -import { PersistPinnedEventRequestBodyInput } from '@kbn/security-solution-plugin/common/api/timeline/pinned_events/pinned_events_route.gen'; +import { PersistFavoriteRouteRequestBodyInput } from '@kbn/security-solution-plugin/common/api/timeline/persist_favorite/persist_favorite_route.gen'; +import { PersistNoteRouteRequestBodyInput } from '@kbn/security-solution-plugin/common/api/timeline/persist_note/persist_note_route.gen'; +import { PersistPinnedEventRouteRequestBodyInput } from '@kbn/security-solution-plugin/common/api/timeline/pinned_events/pinned_events_route.gen'; import { ReadRuleRequestQueryInput } from '@kbn/security-solution-plugin/common/api/detection_engine/rule_management/crud/read_rule/read_rule_route.gen'; import { SearchAlertsRequestBodyInput } from '@kbn/security-solution-plugin/common/api/detection_engine/signals/query_signals/query_signals_route.gen'; import { SetAlertAssigneesRequestBodyInput } from '@kbn/security-solution-plugin/common/api/detection_engine/alert_assignees/set_alert_assignees_route.gen'; @@ -182,9 +182,6 @@ after 30 days. It also deletes other artifacts specific to the migration impleme .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') .send(props.body as object); }, - /** - * Creates a new timeline. - */ createTimelines(props: CreateTimelinesProps) { return supertest .post('/api/timeline') @@ -200,9 +197,6 @@ after 30 days. It also deletes other artifacts specific to the migration impleme .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana'); }, - /** - * Deletes a note from a timeline. - */ deleteNote(props: DeleteNoteProps) { return supertest .delete('/api/note') @@ -222,9 +216,6 @@ after 30 days. It also deletes other artifacts specific to the migration impleme .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') .query(props.query); }, - /** - * Deletes one or more timelines or timeline templates. - */ deleteTimelines(props: DeleteTimelinesProps) { return supertest .delete('/api/timeline') @@ -245,9 +236,6 @@ after 30 days. It also deletes other artifacts specific to the migration impleme .send(props.body as object) .query(props.query); }, - /** - * Exports timelines as an NDJSON file - */ exportTimelines(props: ExportTimelinesProps) { return supertest .post('/api/timeline/_export') @@ -305,9 +293,6 @@ finalize it. .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') .query(props.query); }, - /** - * Retrieves the draft timeline for the current user. If the user does not have a draft timeline, an empty timeline is returned. - */ getDraftTimelines(props: GetDraftTimelinesProps) { return supertest .get('/api/timeline/_draft') @@ -359,9 +344,6 @@ finalize it. .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') .query(props.query); }, - /** - * Get an existing saved timeline or timeline template. This API is used to retrieve an existing saved timeline or timeline template. - */ getTimeline(props: GetTimelineProps) { return supertest .get('/api/timeline') @@ -370,9 +352,6 @@ finalize it. .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') .query(props.query); }, - /** - * This API is used to retrieve a list of existing saved timelines or timeline templates. - */ getTimelines(props: GetTimelinesProps) { return supertest .get('/api/timelines') @@ -392,9 +371,6 @@ finalize it. .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') .query(props.query); }, - /** - * Imports timelines. - */ importTimelines(props: ImportTimelinesProps) { return supertest .post('/api/timeline/_import') @@ -410,9 +386,6 @@ finalize it. .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana'); }, - /** - * Installs prepackaged timelines. - */ installPrepackedTimelines(props: InstallPrepackedTimelinesProps) { return supertest .post('/api/timeline/_prepackaged') @@ -463,10 +436,7 @@ finalize it. .send(props.body as object) .query(props.query); }, - /** - * Persists a given users favorite status of a timeline. - */ - persistFavorite(props: PersistFavoriteProps) { + persistFavoriteRoute(props: PersistFavoriteRouteProps) { return supertest .patch('/api/timeline/_favorite') .set('kbn-xsrf', 'true') @@ -474,10 +444,7 @@ finalize it. .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') .send(props.body as object); }, - /** - * Persists a note to a timeline. - */ - persistNote(props: PersistNoteProps) { + persistNoteRoute(props: PersistNoteRouteProps) { return supertest .patch('/api/note') .set('kbn-xsrf', 'true') @@ -485,10 +452,7 @@ finalize it. .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') .send(props.body as object); }, - /** - * Persists a pinned event to a timeline. - */ - persistPinnedEvent(props: PersistPinnedEventProps) { + persistPinnedEventRoute(props: PersistPinnedEventRouteProps) { return supertest .patch('/api/pinned_event') .set('kbn-xsrf', 'true') @@ -668,14 +632,14 @@ export interface PerformBulkActionProps { query: PerformBulkActionRequestQueryInput; body: PerformBulkActionRequestBodyInput; } -export interface PersistFavoriteProps { - body: PersistFavoriteRequestBodyInput; +export interface PersistFavoriteRouteProps { + body: PersistFavoriteRouteRequestBodyInput; } -export interface PersistNoteProps { - body: PersistNoteRequestBodyInput; +export interface PersistNoteRouteProps { + body: PersistNoteRouteRequestBodyInput; } -export interface PersistPinnedEventProps { - body: PersistPinnedEventRequestBodyInput; +export interface PersistPinnedEventRouteProps { + body: PersistPinnedEventRouteRequestBodyInput; } export interface ReadRuleProps { query: ReadRuleRequestQueryInput; From f067c72a1f3994b90247c13344b5deeea8b71d6c Mon Sep 17 00:00:00 2001 From: Michael Olorunnisola Date: Mon, 8 Jul 2024 13:22:25 -0400 Subject: [PATCH 14/15] update with main --- .../api/timeline/model/components.gen.ts | 34 +++++++++---------- .../services/security_solution_api.gen.ts | 28 +++++++++++++++ 2 files changed, 45 insertions(+), 17 deletions(-) diff --git a/x-pack/plugins/security_solution/common/api/timeline/model/components.gen.ts b/x-pack/plugins/security_solution/common/api/timeline/model/components.gen.ts index 319667ad4342b..72229f97b4795 100644 --- a/x-pack/plugins/security_solution/common/api/timeline/model/components.gen.ts +++ b/x-pack/plugins/security_solution/common/api/timeline/model/components.gen.ts @@ -17,6 +17,21 @@ import type { ZodTypeDef } from 'zod'; import { z } from 'zod'; +export type ColumnHeaderResult = z.infer; +export const ColumnHeaderResult = z.object({ + aggregatable: z.boolean().optional(), + category: z.string().optional(), + columnHeaderType: z.string().optional(), + description: z.string().optional(), + example: z.union([z.string(), z.number()]).optional(), + indexes: z.array(z.string()).optional(), + id: z.string().optional(), + name: z.string().optional(), + placeholder: z.string().optional(), + searchable: z.boolean().optional(), + type: z.string().optional(), +}); + export type PinnedEvent = z.infer; export const PinnedEvent = z.object({ columns: ColumnHeaderResult.optional(), @@ -133,8 +148,8 @@ export interface DataProviderResultInput { enabled?: boolean; excluded?: boolean; kqlQuery?: string; - queryMatch?: QueryMatchResultInput; - type?: DataProviderTypeInput; + queryMatch?: QueryMatchResult; + type?: DataProviderType; and?: DataProviderResultInput[]; } export const DataProviderResult: z.ZodType< @@ -207,21 +222,6 @@ export const SortFieldTimeline = z.enum(['title', 'description', 'updated', 'cre export type SortFieldTimelineEnum = typeof SortFieldTimeline.enum; export const SortFieldTimelineEnum = SortFieldTimeline.enum; -export type ColumnHeaderResult = z.infer; -export const ColumnHeaderResult = z.object({ - aggregatable: z.boolean().optional(), - category: z.string().optional(), - columnHeaderType: z.string().optional(), - description: z.string().optional(), - example: z.union([z.string(), z.number()]).optional(), - indexes: z.array(z.string()).optional(), - id: z.string().optional(), - name: z.string().optional(), - placeholder: z.string().optional(), - searchable: z.boolean().optional(), - type: z.string().optional(), -}); - /** * The type of timeline to create. Valid values are `default` and `template`. */ diff --git a/x-pack/test/api_integration/services/security_solution_api.gen.ts b/x-pack/test/api_integration/services/security_solution_api.gen.ts index cba66212c4fee..6bbfb474305d6 100644 --- a/x-pack/test/api_integration/services/security_solution_api.gen.ts +++ b/x-pack/test/api_integration/services/security_solution_api.gen.ts @@ -27,11 +27,14 @@ import { BulkUpdateRulesRequestBodyInput } from '@kbn/security-solution-plugin/c import { CleanDraftTimelinesRequestBodyInput } from '@kbn/security-solution-plugin/common/api/timeline/clean_draft_timelines/clean_draft_timelines_route.gen'; import { CreateAlertsMigrationRequestBodyInput } from '@kbn/security-solution-plugin/common/api/detection_engine/signals_migration/create_signals_migration/create_signals_migration.gen'; import { CreateRuleRequestBodyInput } from '@kbn/security-solution-plugin/common/api/detection_engine/rule_management/crud/create_rule/create_rule_route.gen'; +import { CreateTimelinesRequestBodyInput } from '@kbn/security-solution-plugin/common/api/timeline/create_timelines/create_timelines_route.gen'; import { CreateUpdateProtectionUpdatesNoteRequestParamsInput, CreateUpdateProtectionUpdatesNoteRequestBodyInput, } from '@kbn/security-solution-plugin/common/api/endpoint/protection_updates_note/protection_updates_note.gen'; +import { DeleteNoteRequestBodyInput } from '@kbn/security-solution-plugin/common/api/timeline/delete_note/delete_note_route.gen'; import { DeleteRuleRequestQueryInput } from '@kbn/security-solution-plugin/common/api/detection_engine/rule_management/crud/delete_rule/delete_rule_route.gen'; +import { DeleteTimelinesRequestBodyInput } from '@kbn/security-solution-plugin/common/api/timeline/delete_timelines/delete_timelines_route.gen'; import { EndpointIsolateRedirectRequestBodyInput } from '@kbn/security-solution-plugin/common/api/endpoint/actions/isolate_route.gen'; import { EndpointUnisolateRedirectRequestBodyInput } from '@kbn/security-solution-plugin/common/api/endpoint/actions/unisolate_route.gen'; import { @@ -186,6 +189,14 @@ after 30 days. It also deletes other artifacts specific to the migration impleme .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') .send(props.body as object); }, + createTimelines(props: CreateTimelinesProps) { + return supertest + .post('/api/timeline') + .set('kbn-xsrf', 'true') + .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') + .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') + .send(props.body as object); + }, createUpdateProtectionUpdatesNote(props: CreateUpdateProtectionUpdatesNoteProps) { return supertest .post( @@ -222,6 +233,14 @@ after 30 days. It also deletes other artifacts specific to the migration impleme .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') .query(props.query); }, + deleteTimelines(props: DeleteTimelinesProps) { + return supertest + .delete('/api/timeline') + .set('kbn-xsrf', 'true') + .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') + .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') + .send(props.body as object); + }, endpointIsolateRedirect(props: EndpointIsolateRedirectProps) { return supertest .post('/api/endpoint/isolate') @@ -577,13 +596,22 @@ export interface CreateAlertsMigrationProps { export interface CreateRuleProps { body: CreateRuleRequestBodyInput; } +export interface CreateTimelinesProps { + body: CreateTimelinesRequestBodyInput; +} export interface CreateUpdateProtectionUpdatesNoteProps { params: CreateUpdateProtectionUpdatesNoteRequestParamsInput; body: CreateUpdateProtectionUpdatesNoteRequestBodyInput; } +export interface DeleteNoteProps { + body: DeleteNoteRequestBodyInput; +} export interface DeleteRuleProps { query: DeleteRuleRequestQueryInput; } +export interface DeleteTimelinesProps { + body: DeleteTimelinesRequestBodyInput; +} export interface EndpointIsolateRedirectProps { body: EndpointIsolateRedirectRequestBodyInput; } From b49ac0dedb0fba5a6cbd9084cc1e675cb3594f92 Mon Sep 17 00:00:00 2001 From: Michael Olorunnisola Date: Fri, 19 Jul 2024 06:40:43 -0400 Subject: [PATCH 15/15] fix ref in resolve api schema --- .../resolve_timeline_route_schema.yaml | 6 ++--- .../services/security_solution_api.gen.ts | 27 +++++++++++++++++++ 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/x-pack/plugins/security_solution/common/api/timeline/resolve_timeline/resolve_timeline_route_schema.yaml b/x-pack/plugins/security_solution/common/api/timeline/resolve_timeline/resolve_timeline_route_schema.yaml index 5c5a4b228339c..006729e8736be 100644 --- a/x-pack/plugins/security_solution/common/api/timeline/resolve_timeline/resolve_timeline_route_schema.yaml +++ b/x-pack/plugins/security_solution/common/api/timeline/resolve_timeline/resolve_timeline_route_schema.yaml @@ -39,9 +39,9 @@ paths: type: object properties: getOneTimeline: - oneOf: - - $ref: '../model/components.yaml#/components/schemas/TimelineResponse' - - nullable: true + nullable: true + allOf: + - $ref: '../model/components.schema.yaml#/components/schemas/TimelineResponse' required: - data '400': diff --git a/x-pack/test/api_integration/services/security_solution_api.gen.ts b/x-pack/test/api_integration/services/security_solution_api.gen.ts index 235aea6adf242..5eac6273d2ff2 100644 --- a/x-pack/test/api_integration/services/security_solution_api.gen.ts +++ b/x-pack/test/api_integration/services/security_solution_api.gen.ts @@ -465,6 +465,14 @@ detection engine rules. .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') .query(props.query); }, + importTimelines(props: ImportTimelinesProps) { + return supertest + .post('/api/timeline/_import') + .set('kbn-xsrf', 'true') + .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') + .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') + .send(props.body as object); + }, /** * Install and update all Elastic prebuilt detection rules and Timelines. */ @@ -475,6 +483,14 @@ detection engine rules. .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana'); }, + installPrepackedTimelines(props: InstallPrepackedTimelinesProps) { + return supertest + .post('/api/timeline/_prepackaged') + .set('kbn-xsrf', 'true') + .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') + .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') + .send(props.body as object); + }, /** * And tags to detection alerts, and remove them from alerts. > info @@ -500,6 +516,17 @@ detection engine rules. .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') .send(props.body as object); }, + /** + * Updates an existing timeline. This API is used to update the title, description, date range, pinned events, pinned queries, and/or pinned saved queries of an existing timeline. + */ + patchTimeline(props: PatchTimelineProps) { + return supertest + .patch('/api/timeline') + .set('kbn-xsrf', 'true') + .set(ELASTIC_HTTP_VERSION_HEADER, '2023-10-31') + .set(X_ELASTIC_INTERNAL_ORIGIN_REQUEST, 'kibana') + .send(props.body as object); + }, /** * Apply a bulk action, such as bulk edit, duplicate, or delete, to multiple detection rules. The bulk action is applied to all rules that match the query or to the rules listed by their IDs. */