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

[Security Solution] Add missing alerts (signals) API endpoints OpenAPI specs #184838

Merged
merged 16 commits into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -5,4 +5,4 @@
* 2.0.
*/

export * from './set_alert_tags/set_alert_tags_route';
export * from './set_alert_tags/set_alert_tags.gen';
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* 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: Manage alert tags API endpoint
* version: 2023-10-31
*/

import { z } from 'zod';

import { AlertIds, AlertTags } from '../../../model/alert.gen';

export type ManageAlertTags = z.infer<typeof ManageAlertTags>;
export const ManageAlertTags = z.object({
tags_to_add: AlertTags,
tags_to_remove: AlertTags,
});

export type ManageAlertTagsRequestBody = z.infer<typeof ManageAlertTagsRequestBody>;
export const ManageAlertTagsRequestBody = z.object({
ids: AlertIds,
tags: ManageAlertTags,
});
export type ManageAlertTagsRequestBodyInput = z.input<typeof ManageAlertTagsRequestBody>;

/**
* Elasticsearch update by query response
*/
export type ManageAlertTagsResponse = z.infer<typeof ManageAlertTagsResponse>;
export const ManageAlertTagsResponse = z.object({}).catchall(z.unknown());
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
openapi: 3.0.0
info:
title: Manage alert tags API endpoint
version: '2023-10-31'
paths:
/api/detection_engine/signals/tags:
post:
x-labels: [serverless, ess]
operationId: ManageAlertTags
x-codegen-enabled: true
summary: Manage alert tags for a one or more alerts
tags:
- Alerts API
requestBody:
description: An object containing tags to add or remove and alert ids the changes will be applied
required: true
content:
application/json:
schema:
type: object
properties:
ids:
$ref: '../../../model/alert.schema.yaml#/components/schemas/AlertIds'
tags:
$ref: '#/components/schemas/ManageAlertTags'
required:
- ids
- tags
responses:
200:
description: Successful response
content:
application/json:
schema:
type: object
additionalProperties: true
description: Elasticsearch update by query response
400:
description: Invalid input data response
content:
application/json:
schema:
oneOf:
- $ref: '../../../model/error_responses.schema.yaml#/components/schemas/PlatformErrorResponse'
- $ref: '../../../model/error_responses.schema.yaml#/components/schemas/SiemErrorResponse'
401:
description: Unsuccessful authentication response
content:
application/json:
schema:
$ref: '../../../model/error_responses.schema.yaml#/components/schemas/PlatformErrorResponse'
500:
description: Internal server error response
content:
application/json:
schema:
$ref: '../../../model/error_responses.schema.yaml#/components/schemas/SiemErrorResponse'

components:
schemas:
ManageAlertTags:
type: object
properties:
tags_to_add:
$ref: '../../../model/alert.schema.yaml#/components/schemas/AlertTags'
tags_to_remove:
$ref: '../../../model/alert.schema.yaml#/components/schemas/AlertTags'
required:
- tags_to_add
- tags_to_remove
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
* 2.0.
*/

import type { SetAlertTagsRequestBody } from './set_alert_tags_route';
import type { ManageAlertTagsRequestBody } from './set_alert_tags.gen';

export const getSetAlertTagsRequestMock = (
tagsToAdd: string[] = [],
tagsToRemove: string[] = [],
ids: string[] = []
): SetAlertTagsRequestBody => ({
): ManageAlertTagsRequestBody => ({
tags: { tags_to_add: tagsToAdd, tags_to_remove: tagsToRemove },
ids,
});

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,5 @@
* 2.0.
*/

export * from './query_signals/query_signals_route';
export * from './set_signal_status/set_signal_status_route';
export * from './set_signal_status/set_signal_status_type_dependents';
export * from './query_signals/query_signals_route.gen';
export * from './set_signal_status/set_signals_status_route.gen';
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* 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: Alerts search API endpoint
* version: 2023-10-31
*/

import { z } from 'zod';

export type AlertsSortCombinations = z.infer<typeof AlertsSortCombinations>;
export const AlertsSortCombinations = z.union([z.string(), z.object({}).catchall(z.unknown())]);

export type AlertsSort = z.infer<typeof AlertsSort>;
export const AlertsSort = z.union([AlertsSortCombinations, z.array(AlertsSortCombinations)]);

/**
* Elasticsearch query and aggregation request
*/
export type SearchAlertsRequestBody = z.infer<typeof SearchAlertsRequestBody>;
export const SearchAlertsRequestBody = z.object({
query: z.object({}).catchall(z.unknown()).optional(),
aggs: z.object({}).catchall(z.unknown()).optional(),
size: z.number().int().min(0).optional(),
track_total_hits: z.boolean().optional(),
_source: z.union([z.boolean(), z.string(), z.array(z.string())]).optional(),
fields: z.array(z.string()).optional(),
runtime_mappings: z.object({}).catchall(z.unknown()).optional(),
sort: AlertsSort.optional(),
});
export type SearchAlertsRequestBodyInput = z.input<typeof SearchAlertsRequestBody>;

/**
* Elasticsearch search response
*/
export type SearchAlertsResponse = z.infer<typeof SearchAlertsResponse>;
export const SearchAlertsResponse = z.object({}).catchall(z.unknown());
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
openapi: 3.0.0
info:
title: Alerts search API endpoint
version: '2023-10-31'
paths:
/api/detection_engine/signals/search:
post:
x-labels: [serverless, ess]
operationId: SearchAlerts
x-codegen-enabled: true
summary: Find and/or aggregate detection alerts that match the given query
tags:
- Alerts API
requestBody:
description: Search and/or aggregation query
required: true
content:
application/json:
schema:
type: object
properties:
query:
type: object
additionalProperties: true
aggs:
type: object
additionalProperties: true
size:
type: integer
minimum: 0
track_total_hits:
type: boolean
_source:
oneOf:
- type: boolean
- type: string
- type: array
items:
type: string
fields:
type: array
items:
type: string
runtime_mappings:
type: object
additionalProperties: true
sort:
$ref: '#/components/schemas/AlertsSort'
description: Elasticsearch query and aggregation request
responses:
200:
description: Successful response
content:
application/json:
schema:
type: object
additionalProperties: true
description: Elasticsearch search response
400:
description: Invalid input data response
content:
application/json:
schema:
oneOf:
- $ref: '../../../model/error_responses.schema.yaml#/components/schemas/PlatformErrorResponse'
- $ref: '../../../model/error_responses.schema.yaml#/components/schemas/SiemErrorResponse'
401:
description: Unsuccessful authentication response
content:
application/json:
schema:
$ref: '../../../model/error_responses.schema.yaml#/components/schemas/PlatformErrorResponse'
500:
description: Internal server error response
content:
application/json:
schema:
$ref: '../../../model/error_responses.schema.yaml#/components/schemas/SiemErrorResponse'

components:
schemas:
AlertsSortCombinations:
anyOf:
- type: string
- type: object
additionalProperties: true

AlertsSort:
oneOf:
- $ref: '#/components/schemas/AlertsSortCombinations'
- type: array
items:
$ref: '#/components/schemas/AlertsSortCombinations'
Loading