Skip to content

Commit

Permalink
Adds openAPI spec for get alerts endpoint (#137332)
Browse files Browse the repository at this point in the history
(cherry picked from commit e19714a)
  • Loading branch information
lcawl committed Jul 28, 2022
1 parent ef923cd commit d0fb80a
Show file tree
Hide file tree
Showing 8 changed files with 292 additions and 9 deletions.
10 changes: 5 additions & 5 deletions docs/api/cases/cases-api-get-alerts.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ default space is used.

=== {api-examples-title}

Return all alerts attached to case `293f1bc0-74f6-11ea-b83a-553aecdb28b6`:
Return all alerts attached to case `a8b26350-0c55-11ed-918a-2d2edf3e58bc`:

[source,sh]
--------------------------------------------------
GET api/cases/293f1bc0-74f6-11ea-b83a-553aecdb28b6/alerts
GET api/cases/a8b26350-0c55-11ed-918a-2d2edf3e58bc/alerts
--------------------------------------------------
// KIBANA

Expand All @@ -52,9 +52,9 @@ The API returns a JSON array listing the alerts. For example:
--------------------------------------------------
[
{
"id": "09f0c261e39e36351d75995b78bb83673774d1bc2cca9df2d15f0e5c0a99a540",
"index": ".internal.alerts-security.alerts-default-000001",
"attached_at": "2022-04-13T21:35:24.602Z"
"id": "f6a7d0c3-d52d-432c-b2e6-447cd7fce04d",
"index": ".alerts-observability.logs.alerts-default",
"attached_at": "2022-07-25T20:09:40.963Z"
}
]
--------------------------------------------------
124 changes: 124 additions & 0 deletions x-pack/plugins/cases/docs/openapi/bundled.json
Original file line number Diff line number Diff line change
Expand Up @@ -2857,6 +2857,53 @@
}
]
},
"/api/cases/{caseId}/alerts": {
"get": {
"summary": "Gets all alerts attached to a case in the default space.",
"description": "You must have `read` privileges for the **Cases** feature in the **Management**, **Observability**, or **Security** section of the Kibana feature privileges, depending on the owner of the cases you're seeking.\n",
"operationId": "getCaseAlertsDefaultSpace",
"tags": [
"cases",
"kibana"
],
"x-technical-preview": true,
"parameters": [
{
"$ref": "#/components/parameters/case_id"
}
],
"responses": {
"200": {
"description": "Indicates a successful call.",
"content": {
"application/json; charset=utf-8": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/alert_response_properties"
}
},
"examples": {
"createCaseCommentResponse": {
"$ref": "#/components/examples/get_case_alerts_response"
}
}
}
}
}
},
"servers": [
{
"url": "https://localhost:5601"
}
]
},
"servers": [
{
"url": "https://localhost:5601"
}
]
},
"/api/cases/{caseId}/comments": {
"post": {
"summary": "Adds a comment or alert to a case in the default space.",
Expand Down Expand Up @@ -6511,6 +6558,56 @@
}
]
},
"/s/{spaceId}/api/cases/{caseId}/alerts": {
"get": {
"summary": "Gets all alerts attached to a case.",
"description": "You must have `read` privileges for the **Cases** feature in the **Management**, **Observability**, or **Security** section of the Kibana feature privileges, depending on the owner of the cases you're seeking.\n",
"x-technical-preview": true,
"operationId": "getCaseAlerts",
"tags": [
"cases",
"kibana"
],
"parameters": [
{
"$ref": "#/components/parameters/case_id"
},
{
"$ref": "#/components/parameters/space_id"
}
],
"responses": {
"200": {
"description": "Indicates a successful call.",
"content": {
"application/json; charset=utf-8": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/alert_response_properties"
}
},
"examples": {
"createCaseCommentResponse": {
"$ref": "#/components/examples/get_case_alerts_response"
}
}
}
}
}
},
"servers": [
{
"url": "https://localhost:5601"
}
]
},
"servers": [
{
"url": "https://localhost:5601"
}
]
},
"/s/{spaceId}/api/cases/{caseId}/comments": {
"post": {
"summary": "Adds a comment or alert to a case.",
Expand Down Expand Up @@ -7738,6 +7835,23 @@
],
"example": "close-by-user"
},
"alert_response_properties": {
"type": "object",
"properties": {
"attached_at": {
"type": "string",
"format": "date-time"
},
"id": {
"description": "The alert identifier.",
"type": "string"
},
"index": {
"description": "The alert index.",
"type": "string"
}
}
},
"add_alert_comment_request_properties": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -8759,6 +8873,16 @@
"external_service": null
}
},
"get_case_alerts_response": {
"summary": "Retrieves all alerts attached to a case",
"value": [
{
"id": "f6a7d0c3-d52d-432c-b2e6-447cd7fce04d",
"index": ".alerts-observability.logs.alerts-default",
"attached_at": "2022-07-25T20:09:40.963Z"
}
]
},
"add_comment_request": {
"summary": "Adds a comment to a case.",
"value": {
Expand Down
79 changes: 79 additions & 0 deletions x-pack/plugins/cases/docs/openapi/bundled.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2417,6 +2417,36 @@ paths:
- url: https://localhost:5601
servers:
- url: https://localhost:5601
/api/cases/{caseId}/alerts:
get:
summary: Gets all alerts attached to a case in the default space.
description: >
You must have `read` privileges for the **Cases** feature in the
**Management**, **Observability**, or **Security** section of the Kibana
feature privileges, depending on the owner of the cases you're seeking.
operationId: getCaseAlertsDefaultSpace
tags:
- cases
- kibana
x-technical-preview: true
parameters:
- $ref: '#/components/parameters/case_id'
responses:
'200':
description: Indicates a successful call.
content:
application/json; charset=utf-8:
schema:
type: array
items:
$ref: '#/components/schemas/alert_response_properties'
examples:
createCaseCommentResponse:
$ref: '#/components/examples/get_case_alerts_response'
servers:
- url: https://localhost:5601
servers:
- url: https://localhost:5601
/api/cases/{caseId}/comments:
post:
summary: Adds a comment or alert to a case in the default space.
Expand Down Expand Up @@ -5440,6 +5470,37 @@ paths:
- url: https://localhost:5601
servers:
- url: https://localhost:5601
/s/{spaceId}/api/cases/{caseId}/alerts:
get:
summary: Gets all alerts attached to a case.
description: >
You must have `read` privileges for the **Cases** feature in the
**Management**, **Observability**, or **Security** section of the Kibana
feature privileges, depending on the owner of the cases you're seeking.
x-technical-preview: true
operationId: getCaseAlerts
tags:
- cases
- kibana
parameters:
- $ref: '#/components/parameters/case_id'
- $ref: '#/components/parameters/space_id'
responses:
'200':
description: Indicates a successful call.
content:
application/json; charset=utf-8:
schema:
type: array
items:
$ref: '#/components/schemas/alert_response_properties'
examples:
createCaseCommentResponse:
$ref: '#/components/examples/get_case_alerts_response'
servers:
- url: https://localhost:5601
servers:
- url: https://localhost:5601
/s/{spaceId}/api/cases/{caseId}/comments:
post:
summary: Adds a comment or alert to a case.
Expand Down Expand Up @@ -6375,6 +6436,18 @@ components:
- close-by-pushing
- close-by-user
example: close-by-user
alert_response_properties:
type: object
properties:
attached_at:
type: string
format: date-time
id:
description: The alert identifier.
type: string
index:
description: The alert index.
type: string
add_alert_comment_request_properties:
type: object
properties:
Expand Down Expand Up @@ -7206,6 +7279,12 @@ components:
type: .none
fields: null
external_service: null
get_case_alerts_response:
summary: Retrieves all alerts attached to a case
value:
- id: f6a7d0c3-d52d-432c-b2e6-447cd7fce04d
index: .alerts-observability.logs.alerts-default
attached_at: '2022-07-25T20:09:40.963Z'
add_comment_request:
summary: Adds a comment to a case.
value:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
summary: Retrieves all alerts attached to a case
value:
[
{
"id": "f6a7d0c3-d52d-432c-b2e6-447cd7fce04d",
"index": ".alerts-observability.logs.alerts-default",
"attached_at": "2022-07-25T20:09:40.963Z"
}
]

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
type: object
properties:
attached_at:
type: string
format: date-time
id:
description: The alert identifier.
type: string
index:
description: The alert index.
type: string
8 changes: 4 additions & 4 deletions x-pack/plugins/cases/docs/openapi/entrypoint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ paths:
$ref: 'paths/api@[email protected]'
'/api/cases/{caseId}':
$ref: 'paths/api@cases@{caseid}.yaml'
# '/api/cases/{caseId}/alerts':
# $ref: 'paths/api@cases@{caseid}@alerts.yaml'
'/api/cases/{caseId}/alerts':
$ref: 'paths/api@cases@{caseid}@alerts.yaml'
'/api/cases/{caseId}/comments':
$ref: 'paths/api@cases@{caseid}@comments.yaml'
'/api/cases/{caseId}/comments/{commentId}':
Expand Down Expand Up @@ -68,8 +68,8 @@ paths:
$ref: 'paths/s@{spaceid}@api@[email protected]'
'/s/{spaceId}/api/cases/{caseId}':
$ref: 'paths/s@{spaceid}@api@cases@{caseid}.yaml'
# '/s/{spaceId}/api/cases/{caseId}/alerts':
# $ref: 'paths/s@{spaceid}@api@cases@{caseid}@alerts.yaml'
'/s/{spaceId}/api/cases/{caseId}/alerts':
$ref: 'paths/s@{spaceid}@api@cases@{caseid}@alerts.yaml'
'/s/{spaceId}/api/cases/{caseId}/comments':
$ref: 'paths/s@{spaceid}@api@cases@{caseid}@comments.yaml'
'/s/{spaceId}/api/cases/{caseId}/comments/{commentId}':
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
get:
summary: Gets all alerts attached to a case in the default space.
description: >
You must have `read` privileges for the **Cases** feature in the
**Management**, **Observability**, or **Security** section of the Kibana
feature privileges, depending on the owner of the cases you're seeking.
operationId: getCaseAlertsDefaultSpace
tags:
- cases
- kibana
x-technical-preview: true
parameters:
- $ref: ../components/parameters/case_id.yaml
responses:
'200':
description: Indicates a successful call.
content:
application/json; charset=utf-8:
schema:
type: array
items:
$ref: '../components/schemas/alert_response_properties.yaml'
examples:
createCaseCommentResponse:
$ref: '../components/examples/get_case_alerts_response.yaml'
servers:
- url: https://localhost:5601
servers:
- url: https://localhost:5601
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
get:
summary: Gets all alerts attached to a case.
description: >
You must have `read` privileges for the **Cases** feature in the
**Management**, **Observability**, or **Security** section of the Kibana
feature privileges, depending on the owner of the cases you're seeking.
x-technical-preview: true
operationId: getCaseAlerts
tags:
- cases
- kibana
parameters:
- $ref: ../components/parameters/case_id.yaml
- $ref: '../components/parameters/space_id.yaml'
responses:
'200':
description: Indicates a successful call.
content:
application/json; charset=utf-8:
schema:
type: array
items:
$ref: '../components/schemas/alert_response_properties.yaml'
examples:
createCaseCommentResponse:
$ref: '../components/examples/get_case_alerts_response.yaml'
servers:
- url: https://localhost:5601
servers:
- url: https://localhost:5601

0 comments on commit d0fb80a

Please sign in to comment.