Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Investigations] - Add timeline api codegen #187172

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
cbe8c98
update timeline api's to use codegen
michaelolo24 Nov 6, 2023
0c538ca
properly require fields
michaelolo24 Nov 7, 2023
b6aba77
additional cleanup
michaelolo24 Nov 7, 2023
2ce1115
[CI] Auto-commit changed files from 'yarn openapi:generate'
kibanamachine Nov 7, 2023
e7cf737
remove circular dependency for now
michaelolo24 Nov 8, 2023
e9f9c69
very rough first pass at recursive template changes
michaelolo24 Nov 15, 2023
eb0a656
update recursive call
michaelolo24 Nov 21, 2023
a638e33
fix lint errors
michaelolo24 Jan 31, 2024
7719929
Merge remote-tracking branch 'upstream/main' into add-timeline-api-co…
michaelolo24 Jun 28, 2024
fdd0c16
update with main
michaelolo24 Jun 28, 2024
1e51fd0
update with main
michaelolo24 Jun 28, 2024
0aac6c5
Merge remote-tracking branch 'upstream/main' into add-timeline-api-co…
michaelolo24 Jun 28, 2024
4d1ac51
Merge remote-tracking branch 'upstream/main' into add-timeline-api-co…
michaelolo24 Jul 2, 2024
2374b79
update with deleteNote
michaelolo24 Jul 2, 2024
fcb4cb0
Merge remote-tracking branch 'upstream/main' into add-timeline-api-co…
michaelolo24 Jul 3, 2024
48f5a16
fix additional merge conflict
michaelolo24 Jul 3, 2024
9842519
get openapi codegen up to date
michaelolo24 Jul 8, 2024
1e5dd0c
Merge remote-tracking branch 'upstream/main' into add-timeline-api-co…
michaelolo24 Jul 8, 2024
f067c72
update with main
michaelolo24 Jul 8, 2024
2d44e35
Merge branch 'main' into add-timeline-api-codegen
michaelolo24 Jul 9, 2024
c3b174f
Merge branch 'main' into add-timeline-api-codegen
michaelolo24 Jul 11, 2024
5726ceb
Merge branch 'main' into add-timeline-api-codegen
michaelolo24 Jul 17, 2024
8ab5b45
Merge remote-tracking branch 'upstream/main' into add-timeline-api-co…
michaelolo24 Jul 19, 2024
b49ac0d
fix ref in resolve api schema
michaelolo24 Jul 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
{{~else~}}
.merge({{> zod_schema_item }})
{{~/if~}}
{{~#if ../nullable}}.nullable(){{/if~}}
Copy link
Contributor Author

@michaelolo24 michaelolo24 Jul 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needed to update based on how nullable: true interacts with the $ref. Reference Issue

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@michaelolo24 is this something you consider a blocker for this PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I updated this, so it was more of a note. Updated the text from Need => Needed as it was done :)

{{~#if (eq ../requiredBool false)}}.optional(){{/if~}}
{{~/each~}}
{{~/if~}}

Expand Down
Original file line number Diff line number Diff line change
@@ -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.
*/

/*
* 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<typeof CleanDraftTimelinesRequestBody>;
export const CleanDraftTimelinesRequestBody = z.object({
timelineType: TimelineType,
});
export type CleanDraftTimelinesRequestBodyInput = z.input<typeof CleanDraftTimelinesRequestBody>;

export type CleanDraftTimelinesResponse = z.infer<typeof CleanDraftTimelinesResponse>;
export const CleanDraftTimelinesResponse = z.object({
data: z.object({
persistTimeline: z.object({
timeline: TimelineResponse,
}),
}),
});
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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.
Expand All @@ -25,27 +26,29 @@ paths:
application/json:
schema:
type: object
required: [timelineType]
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.
content:
application/json:
schema:
type: object
required: [data]
properties:
data:
type: object
required: [persistTimeline]
properties:
persistTimeline:
type: object
required: [timeline]
properties:
timeline:
$ref: '../model/components.yaml#/components/schemas/TimelineResponse'
required:
- data
$ref: '../model/components.schema.yaml#/components/schemas/TimelineResponse'
'403':
description: Indicates that the user does not have the required permissions to create a draft timeline.
content:
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
*/

/*
* 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,
SavedTimeline,
TimelineResponse,
} from '../model/components.gen';

export type CreateTimelinesRequestBody = z.infer<typeof CreateTimelinesRequestBody>;
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<typeof CreateTimelinesRequestBody>;

export type CreateTimelinesResponse = z.infer<typeof CreateTimelinesResponse>;
export const CreateTimelinesResponse = z.object({
data: z.object({
persistTimeline: TimelineResponse,
}),
});
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -15,7 +15,8 @@ servers:
paths:
/api/timeline:
post:
operationId: createTimelines
operationId: CreateTimelines
x-codegen-enabled: true
summary: Creates a new timeline.
tags:
- access:securitySolution
Expand All @@ -26,13 +27,12 @@ paths:
application/json:
schema:
type: object
required:
- timeline
required: [timeline]
properties:
status:
nullable: true
allOf:
- $ref: '../model/components.yaml#/components/schemas/TimelineStatus'
- nullable: true
- $ref: '../model/components.schema.yaml#/components/schemas/TimelineStatus'
timelineId:
type: string
nullable: true
Expand All @@ -43,32 +43,29 @@ paths:
type: number
nullable: true
timelineType:
nullable: true
allOf:
- $ref: '../model/components.yaml#/components/schemas/TimelineType'
- nullable: true
- $ref: '../model/components.schema.yaml#/components/schemas/TimelineType'
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.
content:
application/json:
schema:
type: object
required: [data]
properties:
data:
type: object
required: [persistTimeline]
properties:
persistTimeline:
type: object
properties:
timeline:
$ref: '../model/components.yaml#/components/schemas/TimelineResponse'
required:
- data
$ref: '../model/components.schema.yaml#/components/schemas/TimelineResponse'
'405':
description: Indicates that there was an error in the timeline creation.
content:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* 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.
*/

/*
* 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<typeof DeleteNoteRequestBody>;
export const DeleteNoteRequestBody = z.object({
noteId: z.string().nullable().optional(),
noteIds: z.array(z.string()).nullable().optional(),
});
export type DeleteNoteRequestBodyInput = z.input<typeof DeleteNoteRequestBody>;

export type DeleteNoteResponse = z.infer<typeof DeleteNoteResponse>;
export const DeleteNoteResponse = z.object({
data: z.object({}).optional(),
});
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -12,7 +12,8 @@ servers:
paths:
/api/note:
delete:
operationId: deleteNote
x-codegen-enabled: true
operationId: DeleteNote
summary: Deletes a note from a timeline.
tags:
- access:securitySolution
Expand All @@ -22,19 +23,16 @@ paths:
content:
application/json:
schema:
oneOf:
type: object
properties:
noteId:
type: string
nullable: true
type: object
properties:
noteIds:
type: object
properties:
noteId:
type: string
nullable: true
noteIds:
nullable: true
type: array
items:
type: string
nullable: true
responses:
'200':
description: Indicates the note was successfully deleted.
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
*/

/*
* 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<typeof DeleteTimelinesRequestBody>;
export const DeleteTimelinesRequestBody = z.object({
savedObjectIds: z.array(z.string()),
/**
* Saved search ids that should be deleted alongside the timelines
*/
searchIds: z.array(z.string()).optional(),
});
export type DeleteTimelinesRequestBodyInput = z.input<typeof DeleteTimelinesRequestBody>;

export type DeleteTimelinesResponse = z.infer<typeof DeleteTimelinesResponse>;
export const DeleteTimelinesResponse = z.object({
data: z.object({
deleteTimeline: z.boolean(),
}),
});
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -15,7 +15,8 @@ servers:
paths:
/api/timeline:
delete:
operationId: deleteTimelines
x-codegen-enabled: true
operationId: DeleteTimelines
summary: Deletes one or more timelines or timeline templates.
tags:
- access:securitySolution
Expand All @@ -26,8 +27,7 @@ paths:
application/json:
schema:
type: object
required:
- savedObjectIds
required: [savedObjectIds]
properties:
savedObjectIds:
type: array
Expand All @@ -45,11 +45,11 @@ paths:
application/json:
schema:
type: object
required: [data]
properties:
data:
type: object
required: [deleteTimeline]
properties:
deleteTimeline:
type: boolean
required:
- data
type: boolean
Loading