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

Updated findings api error responses #1164

Merged
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
8 changes: 4 additions & 4 deletions .apigentools-info
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
"spec_versions": {
"v1": {
"apigentools_version": "1.6.4",
"regenerated": "2023-06-14 07:20:46.323324",
"spec_repo_commit": "87ef2d8d"
"regenerated": "2023-06-14 09:53:17.094283",
"spec_repo_commit": "e0974b9b"
},
"v2": {
"apigentools_version": "1.6.4",
"regenerated": "2023-06-14 07:20:46.341098",
"spec_repo_commit": "87ef2d8d"
"regenerated": "2023-06-14 09:53:17.110011",
"spec_repo_commit": "e0974b9b"
}
}
}
148 changes: 78 additions & 70 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,31 @@ components:
schema:
$ref: '#/components/schemas/APIErrorResponse'
description: Conflict
FindingsBadRequestResponse:
content:
application/json:
schema:
$ref: '#/components/schemas/JSONAPIErrorResponse'
description: 'Bad Request: The server cannot process the request due to invalid
syntax in the request.'
FindingsForbiddenResponse:
content:
application/json:
schema:
$ref: '#/components/schemas/JSONAPIErrorResponse'
description: 'Forbidden: Access denied'
FindingsNotFoundResponse:
content:
application/json:
schema:
$ref: '#/components/schemas/JSONAPIErrorResponse'
description: 'Not Found: The requested finding cannot be found.'
FindingsTooManyRequestsResponse:
content:
application/json:
schema:
$ref: '#/components/schemas/JSONAPIErrorResponse'
description: 'Too many requests: The rate limit set by the API has been exceeded.'
ForbiddenResponse:
content:
application/json:
Expand Down Expand Up @@ -4520,34 +4545,6 @@ components:
type: string
x-enum-varnames:
- FINDING
FindingsErrorItem:
description: API error response body
properties:
detail:
description: A human-readable explanation specific to this occurrence of
the error.
example: attribute "muted" is required
type: string
status:
description: Status code of the response.
example: '400'
type: string
title:
description: Short human-readable summary of the error.
example: Bad Request
type: string
type: object
FindingsErrorResponse:
description: API error response.
properties:
errors:
description: A list of errors.
items:
$ref: '#/components/schemas/FindingsErrorItem'
type: array
required:
- errors
type: object
FormulaLimit:
description: Message for specifying limits to the number of values returned
by a query.
Expand Down Expand Up @@ -6839,6 +6836,34 @@ components:
type: string
type: array
type: object
JSONAPIErrorItem:
description: API error response body
properties:
detail:
description: A human-readable explanation specific to this occurrence of
the error.
example: Missing required attribute in body
type: string
status:
description: Status code of the response.
example: '400'
type: string
title:
description: Short human-readable summary of the error.
example: Bad Request
type: string
type: object
JSONAPIErrorResponse:
description: API error response.
properties:
errors:
description: A list of errors.
items:
$ref: '#/components/schemas/JSONAPIErrorItem'
type: array
required:
- errors
type: object
JiraIntegrationMetadata:
description: Incident integration metadata for the Jira integration.
properties:
Expand Down Expand Up @@ -20715,13 +20740,16 @@ paths:
can also use the negation operator on strings. For example, use `filter[resource_type]=-aws*`
to filter for any non-AWS resources.\n\nThe 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`.\n\n### Response\n\nThe
response includes an array of finding objects, pagination metadata, and a
count of items that match the query.\n\nEach finding object contains the following:\n\n-
The finding ID that can be used in a `GetFinding` request to retrieve the
full finding details.\n- Core attributes, including status, evaluation, high-level
resource details, muted state, and rule details.\n- `evaluation_changed_at`
and `resource_discovery_date` time stamps.\n- An array of associated tags.\n"
the equal sign: `filter[evaluation_changed_at]=>=1678809373257`.\n\nQuery
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.\n\n### Response\n\nThe response includes an array of finding
objects, pagination metadata, and a count of items that match the query.\n\nEach
finding object contains the following:\n\n- The finding ID that can be used
in a `GetFinding` request to retrieve the full finding details.\n- Core attributes,
including status, evaluation, high-level resource details, muted state, and
rule details.\n- `evaluation_changed_at` and `resource_discovery_date` time
stamps.\n- An array of associated tags.\n"
operationId: ListFindings
parameters:
- description: Limit the number of findings returned. Must be <= 1000.
Expand Down Expand Up @@ -20821,17 +20849,13 @@ paths:
$ref: '#/components/schemas/ListFindingsResponse'
description: OK
'400':
content:
application/json:
schema:
$ref: '#/components/schemas/APIErrorResponse'
description: Bad Request
$ref: '#/components/responses/FindingsBadRequestResponse'
'403':
$ref: '#/components/responses/ForbiddenResponse'
$ref: '#/components/responses/FindingsForbiddenResponse'
'404':
$ref: '#/components/responses/NotFoundResponse'
$ref: '#/components/responses/FindingsNotFoundResponse'
'429':
$ref: '#/components/responses/TooManyRequestsResponse'
$ref: '#/components/responses/FindingsTooManyRequestsResponse'
security:
- apiKeyAuth: []
appKeyAuth: []
Expand Down Expand Up @@ -20876,17 +20900,13 @@ paths:
$ref: '#/components/schemas/GetFindingResponse'
description: OK
'400':
content:
application/json:
schema:
$ref: '#/components/schemas/APIErrorResponse'
description: Bad Request
$ref: '#/components/responses/FindingsBadRequestResponse'
'403':
$ref: '#/components/responses/ForbiddenResponse'
$ref: '#/components/responses/FindingsForbiddenResponse'
'404':
$ref: '#/components/responses/NotFoundResponse'
$ref: '#/components/responses/FindingsNotFoundResponse'
'429':
$ref: '#/components/responses/TooManyRequestsResponse'
$ref: '#/components/responses/FindingsTooManyRequestsResponse'
security:
- apiKeyAuth: []
appKeyAuth: []
Expand Down Expand Up @@ -20934,39 +20954,27 @@ paths:
$ref: '#/components/schemas/MuteFindingResponse'
description: OK
'400':
content:
application/json:
schema:
$ref: '#/components/schemas/FindingsErrorResponse'
description: 'Bad Request: The server cannot process the request due to
invalid syntax in the request.'
$ref: '#/components/responses/FindingsBadRequestResponse'
'403':
$ref: '#/components/responses/FindingsForbiddenResponse'
'404':
content:
application/json:
schema:
$ref: '#/components/schemas/FindingsErrorResponse'
description: 'Not Found: The requested finding cannot be found.'
$ref: '#/components/responses/FindingsNotFoundResponse'
'409':
content:
application/json:
schema:
$ref: '#/components/schemas/FindingsErrorResponse'
$ref: '#/components/schemas/JSONAPIErrorResponse'
description: 'Resource Conflict: The finding has already been muted or unmuted
within the last 60 seconds.'
'422':
content:
application/json:
schema:
$ref: '#/components/schemas/FindingsErrorResponse'
$ref: '#/components/schemas/JSONAPIErrorResponse'
description: 'Invalid Request: The server understands the request syntax
but cannot process it due to invalid data.'
'429':
content:
application/json:
schema:
$ref: '#/components/schemas/FindingsErrorResponse'
description: 'Too many requests: The rate limit set by the API has been
exceeded.'
$ref: '#/components/responses/FindingsTooManyRequestsResponse'
security:
- apiKeyAuth: []
appKeyAuth: []
Expand Down
16 changes: 8 additions & 8 deletions features/v2/security_monitoring.feature
Original file line number Diff line number Diff line change
Expand Up @@ -199,20 +199,20 @@ Feature: Security Monitoring
And the response "id" has the same value as "cloud_configuration_rule.id"

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

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

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

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

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

@replay-only @team:DataDog/cloud-security-posture-management
Scenario: List findings returns "OK" response
Expand Down
41 changes: 25 additions & 16 deletions packages/datadog-api-client-v2/apis/SecurityMonitoringApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ import { ApiException } from "../../datadog-api-client-common/exception";
import { APIErrorResponse } from "../models/APIErrorResponse";
import { Finding } from "../models/Finding";
import { FindingEvaluation } from "../models/FindingEvaluation";
import { FindingsErrorResponse } from "../models/FindingsErrorResponse";
import { FindingStatus } from "../models/FindingStatus";
import { GetFindingResponse } from "../models/GetFindingResponse";
import { JSONAPIErrorResponse } from "../models/JSONAPIErrorResponse";
import { ListFindingsResponse } from "../models/ListFindingsResponse";
import { MuteFindingRequest } from "../models/MuteFindingRequest";
import { MuteFindingResponse } from "../models/MuteFindingResponse";
Expand Down Expand Up @@ -1469,20 +1469,23 @@ export class SecurityMonitoringApiResponseProcessor {
await response.body.text(),
contentType
);
let body: APIErrorResponse;
let body: JSONAPIErrorResponse;
try {
body = ObjectSerializer.deserialize(
bodyText,
"APIErrorResponse"
) as APIErrorResponse;
"JSONAPIErrorResponse"
) as JSONAPIErrorResponse;
} catch (error) {
logger.info(`Got error deserializing error: ${error}`);
throw new ApiException<APIErrorResponse>(
throw new ApiException<JSONAPIErrorResponse>(
response.httpStatusCode,
bodyText
);
}
throw new ApiException<APIErrorResponse>(response.httpStatusCode, body);
throw new ApiException<JSONAPIErrorResponse>(
response.httpStatusCode,
body
);
}

// Work around for missing responses in specification, e.g. for petstore.yaml
Expand Down Expand Up @@ -1710,20 +1713,23 @@ export class SecurityMonitoringApiResponseProcessor {
await response.body.text(),
contentType
);
let body: APIErrorResponse;
let body: JSONAPIErrorResponse;
try {
body = ObjectSerializer.deserialize(
bodyText,
"APIErrorResponse"
) as APIErrorResponse;
"JSONAPIErrorResponse"
) as JSONAPIErrorResponse;
} catch (error) {
logger.info(`Got error deserializing error: ${error}`);
throw new ApiException<APIErrorResponse>(
throw new ApiException<JSONAPIErrorResponse>(
response.httpStatusCode,
bodyText
);
}
throw new ApiException<APIErrorResponse>(response.httpStatusCode, body);
throw new ApiException<JSONAPIErrorResponse>(
response.httpStatusCode,
body
);
}

// Work around for missing responses in specification, e.g. for petstore.yaml
Expand Down Expand Up @@ -2011,6 +2017,7 @@ export class SecurityMonitoringApiResponseProcessor {
}
if (
response.httpStatusCode == 400 ||
response.httpStatusCode == 403 ||
response.httpStatusCode == 404 ||
response.httpStatusCode == 409 ||
response.httpStatusCode == 422 ||
Expand All @@ -2020,20 +2027,20 @@ export class SecurityMonitoringApiResponseProcessor {
await response.body.text(),
contentType
);
let body: FindingsErrorResponse;
let body: JSONAPIErrorResponse;
try {
body = ObjectSerializer.deserialize(
bodyText,
"FindingsErrorResponse"
) as FindingsErrorResponse;
"JSONAPIErrorResponse"
) as JSONAPIErrorResponse;
} catch (error) {
logger.info(`Got error deserializing error: ${error}`);
throw new ApiException<FindingsErrorResponse>(
throw new ApiException<JSONAPIErrorResponse>(
response.httpStatusCode,
bodyText
);
}
throw new ApiException<FindingsErrorResponse>(
throw new ApiException<JSONAPIErrorResponse>(
response.httpStatusCode,
body
);
Expand Down Expand Up @@ -2736,6 +2743,8 @@ export class SecurityMonitoringApi {
*
* 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`.
*
* 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.
*
* ### Response
*
* The response includes an array of finding objects, pagination metadata, and a count of items that match the query.
Expand Down
Loading