Skip to content

Commit b34d533

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Updated findings api error responses (#1164)
Co-authored-by: ci.datadog-api-spec <[email protected]>
1 parent 6485c3a commit b34d533

File tree

8 files changed

+128
-111
lines changed

8 files changed

+128
-111
lines changed

.apigentools-info

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
"spec_versions": {
55
"v1": {
66
"apigentools_version": "1.6.4",
7-
"regenerated": "2023-06-14 07:20:46.323324",
8-
"spec_repo_commit": "87ef2d8d"
7+
"regenerated": "2023-06-14 09:53:17.094283",
8+
"spec_repo_commit": "e0974b9b"
99
},
1010
"v2": {
1111
"apigentools_version": "1.6.4",
12-
"regenerated": "2023-06-14 07:20:46.341098",
13-
"spec_repo_commit": "87ef2d8d"
12+
"regenerated": "2023-06-14 09:53:17.110011",
13+
"spec_repo_commit": "e0974b9b"
1414
}
1515
}
1616
}

.generator/schemas/v2/openapi.yaml

Lines changed: 78 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,31 @@ components:
477477
schema:
478478
$ref: '#/components/schemas/APIErrorResponse'
479479
description: Conflict
480+
FindingsBadRequestResponse:
481+
content:
482+
application/json:
483+
schema:
484+
$ref: '#/components/schemas/JSONAPIErrorResponse'
485+
description: 'Bad Request: The server cannot process the request due to invalid
486+
syntax in the request.'
487+
FindingsForbiddenResponse:
488+
content:
489+
application/json:
490+
schema:
491+
$ref: '#/components/schemas/JSONAPIErrorResponse'
492+
description: 'Forbidden: Access denied'
493+
FindingsNotFoundResponse:
494+
content:
495+
application/json:
496+
schema:
497+
$ref: '#/components/schemas/JSONAPIErrorResponse'
498+
description: 'Not Found: The requested finding cannot be found.'
499+
FindingsTooManyRequestsResponse:
500+
content:
501+
application/json:
502+
schema:
503+
$ref: '#/components/schemas/JSONAPIErrorResponse'
504+
description: 'Too many requests: The rate limit set by the API has been exceeded.'
480505
ForbiddenResponse:
481506
content:
482507
application/json:
@@ -4520,34 +4545,6 @@ components:
45204545
type: string
45214546
x-enum-varnames:
45224547
- FINDING
4523-
FindingsErrorItem:
4524-
description: API error response body
4525-
properties:
4526-
detail:
4527-
description: A human-readable explanation specific to this occurrence of
4528-
the error.
4529-
example: attribute "muted" is required
4530-
type: string
4531-
status:
4532-
description: Status code of the response.
4533-
example: '400'
4534-
type: string
4535-
title:
4536-
description: Short human-readable summary of the error.
4537-
example: Bad Request
4538-
type: string
4539-
type: object
4540-
FindingsErrorResponse:
4541-
description: API error response.
4542-
properties:
4543-
errors:
4544-
description: A list of errors.
4545-
items:
4546-
$ref: '#/components/schemas/FindingsErrorItem'
4547-
type: array
4548-
required:
4549-
- errors
4550-
type: object
45514548
FormulaLimit:
45524549
description: Message for specifying limits to the number of values returned
45534550
by a query.
@@ -6839,6 +6836,34 @@ components:
68396836
type: string
68406837
type: array
68416838
type: object
6839+
JSONAPIErrorItem:
6840+
description: API error response body
6841+
properties:
6842+
detail:
6843+
description: A human-readable explanation specific to this occurrence of
6844+
the error.
6845+
example: Missing required attribute in body
6846+
type: string
6847+
status:
6848+
description: Status code of the response.
6849+
example: '400'
6850+
type: string
6851+
title:
6852+
description: Short human-readable summary of the error.
6853+
example: Bad Request
6854+
type: string
6855+
type: object
6856+
JSONAPIErrorResponse:
6857+
description: API error response.
6858+
properties:
6859+
errors:
6860+
description: A list of errors.
6861+
items:
6862+
$ref: '#/components/schemas/JSONAPIErrorItem'
6863+
type: array
6864+
required:
6865+
- errors
6866+
type: object
68426867
JiraIntegrationMetadata:
68436868
description: Incident integration metadata for the Jira integration.
68446869
properties:
@@ -20715,13 +20740,16 @@ paths:
2071520740
can also use the negation operator on strings. For example, use `filter[resource_type]=-aws*`
2071620741
to filter for any non-AWS resources.\n\nThe operator must come after the equal
2071720742
sign. For example, to filter with the `>=` operator, add the operator after
20718-
the equal sign: `filter[evaluation_changed_at]=>=1678809373257`.\n\n### Response\n\nThe
20719-
response includes an array of finding objects, pagination metadata, and a
20720-
count of items that match the query.\n\nEach finding object contains the following:\n\n-
20721-
The finding ID that can be used in a `GetFinding` request to retrieve the
20722-
full finding details.\n- Core attributes, including status, evaluation, high-level
20723-
resource details, muted state, and rule details.\n- `evaluation_changed_at`
20724-
and `resource_discovery_date` time stamps.\n- An array of associated tags.\n"
20743+
the equal sign: `filter[evaluation_changed_at]=>=1678809373257`.\n\nQuery
20744+
parameters must be only among the documented ones and with values of correct
20745+
types. Duplicated query parameters (e.g. `filter[status]=low&filter[status]=info`)
20746+
are not allowed.\n\n### Response\n\nThe response includes an array of finding
20747+
objects, pagination metadata, and a count of items that match the query.\n\nEach
20748+
finding object contains the following:\n\n- The finding ID that can be used
20749+
in a `GetFinding` request to retrieve the full finding details.\n- Core attributes,
20750+
including status, evaluation, high-level resource details, muted state, and
20751+
rule details.\n- `evaluation_changed_at` and `resource_discovery_date` time
20752+
stamps.\n- An array of associated tags.\n"
2072520753
operationId: ListFindings
2072620754
parameters:
2072720755
- description: Limit the number of findings returned. Must be <= 1000.
@@ -20821,17 +20849,13 @@ paths:
2082120849
$ref: '#/components/schemas/ListFindingsResponse'
2082220850
description: OK
2082320851
'400':
20824-
content:
20825-
application/json:
20826-
schema:
20827-
$ref: '#/components/schemas/APIErrorResponse'
20828-
description: Bad Request
20852+
$ref: '#/components/responses/FindingsBadRequestResponse'
2082920853
'403':
20830-
$ref: '#/components/responses/ForbiddenResponse'
20854+
$ref: '#/components/responses/FindingsForbiddenResponse'
2083120855
'404':
20832-
$ref: '#/components/responses/NotFoundResponse'
20856+
$ref: '#/components/responses/FindingsNotFoundResponse'
2083320857
'429':
20834-
$ref: '#/components/responses/TooManyRequestsResponse'
20858+
$ref: '#/components/responses/FindingsTooManyRequestsResponse'
2083520859
security:
2083620860
- apiKeyAuth: []
2083720861
appKeyAuth: []
@@ -20876,17 +20900,13 @@ paths:
2087620900
$ref: '#/components/schemas/GetFindingResponse'
2087720901
description: OK
2087820902
'400':
20879-
content:
20880-
application/json:
20881-
schema:
20882-
$ref: '#/components/schemas/APIErrorResponse'
20883-
description: Bad Request
20903+
$ref: '#/components/responses/FindingsBadRequestResponse'
2088420904
'403':
20885-
$ref: '#/components/responses/ForbiddenResponse'
20905+
$ref: '#/components/responses/FindingsForbiddenResponse'
2088620906
'404':
20887-
$ref: '#/components/responses/NotFoundResponse'
20907+
$ref: '#/components/responses/FindingsNotFoundResponse'
2088820908
'429':
20889-
$ref: '#/components/responses/TooManyRequestsResponse'
20909+
$ref: '#/components/responses/FindingsTooManyRequestsResponse'
2089020910
security:
2089120911
- apiKeyAuth: []
2089220912
appKeyAuth: []
@@ -20934,39 +20954,27 @@ paths:
2093420954
$ref: '#/components/schemas/MuteFindingResponse'
2093520955
description: OK
2093620956
'400':
20937-
content:
20938-
application/json:
20939-
schema:
20940-
$ref: '#/components/schemas/FindingsErrorResponse'
20941-
description: 'Bad Request: The server cannot process the request due to
20942-
invalid syntax in the request.'
20957+
$ref: '#/components/responses/FindingsBadRequestResponse'
20958+
'403':
20959+
$ref: '#/components/responses/FindingsForbiddenResponse'
2094320960
'404':
20944-
content:
20945-
application/json:
20946-
schema:
20947-
$ref: '#/components/schemas/FindingsErrorResponse'
20948-
description: 'Not Found: The requested finding cannot be found.'
20961+
$ref: '#/components/responses/FindingsNotFoundResponse'
2094920962
'409':
2095020963
content:
2095120964
application/json:
2095220965
schema:
20953-
$ref: '#/components/schemas/FindingsErrorResponse'
20966+
$ref: '#/components/schemas/JSONAPIErrorResponse'
2095420967
description: 'Resource Conflict: The finding has already been muted or unmuted
2095520968
within the last 60 seconds.'
2095620969
'422':
2095720970
content:
2095820971
application/json:
2095920972
schema:
20960-
$ref: '#/components/schemas/FindingsErrorResponse'
20973+
$ref: '#/components/schemas/JSONAPIErrorResponse'
2096120974
description: 'Invalid Request: The server understands the request syntax
2096220975
but cannot process it due to invalid data.'
2096320976
'429':
20964-
content:
20965-
application/json:
20966-
schema:
20967-
$ref: '#/components/schemas/FindingsErrorResponse'
20968-
description: 'Too many requests: The rate limit set by the API has been
20969-
exceeded.'
20977+
$ref: '#/components/responses/FindingsTooManyRequestsResponse'
2097020978
security:
2097120979
- apiKeyAuth: []
2097220980
appKeyAuth: []

features/v2/security_monitoring.feature

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -199,20 +199,20 @@ Feature: Security Monitoring
199199
And the response "id" has the same value as "cloud_configuration_rule.id"
200200

201201
@generated @skip @team:DataDog/cloud-security-posture-management
202-
Scenario: Get a finding returns "Bad Request" response
202+
Scenario: Get a finding returns "Bad Request: The server cannot process the request due to invalid syntax in the request." response
203203
Given operation "GetFinding" enabled
204204
And new "GetFinding" request
205205
And request contains "finding_id" parameter from "REPLACE.ME"
206206
When the request is sent
207-
Then the response status is 400 Bad Request
207+
Then the response status is 400 Bad Request: The server cannot process the request due to invalid syntax in the request.
208208

209209
@generated @skip @team:DataDog/cloud-security-posture-management
210-
Scenario: Get a finding returns "Not Found" response
210+
Scenario: Get a finding returns "Not Found: The requested finding cannot be found." response
211211
Given operation "GetFinding" enabled
212212
And new "GetFinding" request
213213
And request contains "finding_id" parameter from "REPLACE.ME"
214214
When the request is sent
215-
Then the response status is 404 Not Found
215+
Then the response status is 404 Not Found: The requested finding cannot be found.
216216

217217
@replay-only @team:DataDog/cloud-security-posture-management
218218
Scenario: Get a finding returns "OK" response
@@ -325,18 +325,18 @@ Feature: Security Monitoring
325325
And the response "data" has item with field "attributes.is_builtin" with value true
326326

327327
@generated @skip @team:DataDog/cloud-security-posture-management
328-
Scenario: List findings returns "Bad Request" response
328+
Scenario: List findings returns "Bad Request: The server cannot process the request due to invalid syntax in the request." response
329329
Given operation "ListFindings" enabled
330330
And new "ListFindings" request
331331
When the request is sent
332-
Then the response status is 400 Bad Request
332+
Then the response status is 400 Bad Request: The server cannot process the request due to invalid syntax in the request.
333333

334334
@generated @skip @team:DataDog/cloud-security-posture-management
335-
Scenario: List findings returns "Not Found" response
335+
Scenario: List findings returns "Not Found: The requested finding cannot be found." response
336336
Given operation "ListFindings" enabled
337337
And new "ListFindings" request
338338
When the request is sent
339-
Then the response status is 404 Not Found
339+
Then the response status is 404 Not Found: The requested finding cannot be found.
340340

341341
@replay-only @team:DataDog/cloud-security-posture-management
342342
Scenario: List findings returns "OK" response

packages/datadog-api-client-v2/apis/SecurityMonitoringApi.ts

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ import { ApiException } from "../../datadog-api-client-common/exception";
2020
import { APIErrorResponse } from "../models/APIErrorResponse";
2121
import { Finding } from "../models/Finding";
2222
import { FindingEvaluation } from "../models/FindingEvaluation";
23-
import { FindingsErrorResponse } from "../models/FindingsErrorResponse";
2423
import { FindingStatus } from "../models/FindingStatus";
2524
import { GetFindingResponse } from "../models/GetFindingResponse";
25+
import { JSONAPIErrorResponse } from "../models/JSONAPIErrorResponse";
2626
import { ListFindingsResponse } from "../models/ListFindingsResponse";
2727
import { MuteFindingRequest } from "../models/MuteFindingRequest";
2828
import { MuteFindingResponse } from "../models/MuteFindingResponse";
@@ -1469,20 +1469,23 @@ export class SecurityMonitoringApiResponseProcessor {
14691469
await response.body.text(),
14701470
contentType
14711471
);
1472-
let body: APIErrorResponse;
1472+
let body: JSONAPIErrorResponse;
14731473
try {
14741474
body = ObjectSerializer.deserialize(
14751475
bodyText,
1476-
"APIErrorResponse"
1477-
) as APIErrorResponse;
1476+
"JSONAPIErrorResponse"
1477+
) as JSONAPIErrorResponse;
14781478
} catch (error) {
14791479
logger.info(`Got error deserializing error: ${error}`);
1480-
throw new ApiException<APIErrorResponse>(
1480+
throw new ApiException<JSONAPIErrorResponse>(
14811481
response.httpStatusCode,
14821482
bodyText
14831483
);
14841484
}
1485-
throw new ApiException<APIErrorResponse>(response.httpStatusCode, body);
1485+
throw new ApiException<JSONAPIErrorResponse>(
1486+
response.httpStatusCode,
1487+
body
1488+
);
14861489
}
14871490

14881491
// Work around for missing responses in specification, e.g. for petstore.yaml
@@ -1710,20 +1713,23 @@ export class SecurityMonitoringApiResponseProcessor {
17101713
await response.body.text(),
17111714
contentType
17121715
);
1713-
let body: APIErrorResponse;
1716+
let body: JSONAPIErrorResponse;
17141717
try {
17151718
body = ObjectSerializer.deserialize(
17161719
bodyText,
1717-
"APIErrorResponse"
1718-
) as APIErrorResponse;
1720+
"JSONAPIErrorResponse"
1721+
) as JSONAPIErrorResponse;
17191722
} catch (error) {
17201723
logger.info(`Got error deserializing error: ${error}`);
1721-
throw new ApiException<APIErrorResponse>(
1724+
throw new ApiException<JSONAPIErrorResponse>(
17221725
response.httpStatusCode,
17231726
bodyText
17241727
);
17251728
}
1726-
throw new ApiException<APIErrorResponse>(response.httpStatusCode, body);
1729+
throw new ApiException<JSONAPIErrorResponse>(
1730+
response.httpStatusCode,
1731+
body
1732+
);
17271733
}
17281734

17291735
// Work around for missing responses in specification, e.g. for petstore.yaml
@@ -2011,6 +2017,7 @@ export class SecurityMonitoringApiResponseProcessor {
20112017
}
20122018
if (
20132019
response.httpStatusCode == 400 ||
2020+
response.httpStatusCode == 403 ||
20142021
response.httpStatusCode == 404 ||
20152022
response.httpStatusCode == 409 ||
20162023
response.httpStatusCode == 422 ||
@@ -2020,20 +2027,20 @@ export class SecurityMonitoringApiResponseProcessor {
20202027
await response.body.text(),
20212028
contentType
20222029
);
2023-
let body: FindingsErrorResponse;
2030+
let body: JSONAPIErrorResponse;
20242031
try {
20252032
body = ObjectSerializer.deserialize(
20262033
bodyText,
2027-
"FindingsErrorResponse"
2028-
) as FindingsErrorResponse;
2034+
"JSONAPIErrorResponse"
2035+
) as JSONAPIErrorResponse;
20292036
} catch (error) {
20302037
logger.info(`Got error deserializing error: ${error}`);
2031-
throw new ApiException<FindingsErrorResponse>(
2038+
throw new ApiException<JSONAPIErrorResponse>(
20322039
response.httpStatusCode,
20332040
bodyText
20342041
);
20352042
}
2036-
throw new ApiException<FindingsErrorResponse>(
2043+
throw new ApiException<JSONAPIErrorResponse>(
20372044
response.httpStatusCode,
20382045
body
20392046
);
@@ -2736,6 +2743,8 @@ export class SecurityMonitoringApi {
27362743
*
27372744
* The operator must come after the equal sign. For example, to filter with the `>=` operator, add the operator after the equal sign: `filter[evaluation_changed_at]=>=1678809373257`.
27382745
*
2746+
* Query parameters must be only among the documented ones and with values of correct types. Duplicated query parameters (e.g. `filter[status]=low&filter[status]=info`) are not allowed.
2747+
*
27392748
* ### Response
27402749
*
27412750
* The response includes an array of finding objects, pagination metadata, and a count of items that match the query.

0 commit comments

Comments
 (0)