From a5824d41fa9972a4b83ceef05f261cae301cee01 Mon Sep 17 00:00:00 2001 From: "api-clients-generation-pipeline[bot]" <54105614+api-clients-generation-pipeline[bot]@users.noreply.github.com> Date: Mon, 5 Jun 2023 15:50:22 +0000 Subject: [PATCH] Add support for mute findings endpoint (#1469) Co-authored-by: ci.datadog-api-spec --- .apigentools-info | 8 +- .generator/schemas/v2/openapi.yaml | 264 +++++++++++++++++- docs/datadog_api_client.v2.model.rst | 70 +++++ .../v2/security-monitoring/UpdateFinding.py | 37 +++ src/datadog_api_client/configuration.py | 1 + .../v2/api/security_monitoring_api.py | 55 ++++ src/datadog_api_client/v2/model/finding.py | 2 +- .../v2/model/finding_mute.py | 10 +- .../v2/model/finding_mute_reason.py | 19 +- .../v2/model/findings_error_item.py | 56 ++++ .../v2/model/findings_error_response.py | 40 +++ .../v2/model/mute_finding_request.py | 40 +++ .../model/mute_finding_request_attributes.py | 40 +++ .../v2/model/mute_finding_request_data.py | 54 ++++ .../model/mute_finding_request_properties.py | 70 +++++ .../v2/model/mute_finding_response.py | 40 +++ .../model/mute_finding_response_attributes.py | 125 +++++++++ .../v2/model/mute_finding_response_data.py | 64 +++++ .../model/mute_finding_response_properties.py | 72 +++++ src/datadog_api_client/v2/models/__init__.py | 10 + ...nmute_a_finding_returns_ok_response.frozen | 1 + ..._unmute_a_finding_returns_ok_response.yaml | 22 ++ tests/v2/features/security_monitoring.feature | 46 +++ tests/v2/features/undo.json | 6 + 24 files changed, 1129 insertions(+), 23 deletions(-) create mode 100644 examples/v2/security-monitoring/UpdateFinding.py create mode 100644 src/datadog_api_client/v2/model/findings_error_item.py create mode 100644 src/datadog_api_client/v2/model/findings_error_response.py create mode 100644 src/datadog_api_client/v2/model/mute_finding_request.py create mode 100644 src/datadog_api_client/v2/model/mute_finding_request_attributes.py create mode 100644 src/datadog_api_client/v2/model/mute_finding_request_data.py create mode 100644 src/datadog_api_client/v2/model/mute_finding_request_properties.py create mode 100644 src/datadog_api_client/v2/model/mute_finding_response.py create mode 100644 src/datadog_api_client/v2/model/mute_finding_response_attributes.py create mode 100644 src/datadog_api_client/v2/model/mute_finding_response_data.py create mode 100644 src/datadog_api_client/v2/model/mute_finding_response_properties.py create mode 100644 tests/v2/cassettes/test_scenarios/test_mute_or_unmute_a_finding_returns_ok_response.frozen create mode 100644 tests/v2/cassettes/test_scenarios/test_mute_or_unmute_a_finding_returns_ok_response.yaml diff --git a/.apigentools-info b/.apigentools-info index 7f38d7f39f..e1e66b1ba9 100644 --- a/.apigentools-info +++ b/.apigentools-info @@ -4,13 +4,13 @@ "spec_versions": { "v1": { "apigentools_version": "1.6.4", - "regenerated": "2023-06-05 14:46:50.084688", - "spec_repo_commit": "060dc917" + "regenerated": "2023-06-05 15:08:59.861687", + "spec_repo_commit": "2638a894" }, "v2": { "apigentools_version": "1.6.4", - "regenerated": "2023-06-05 14:46:50.097095", - "spec_repo_commit": "060dc917" + "regenerated": "2023-06-05 15:08:59.874012", + "spec_repo_commit": "2638a894" } } } \ No newline at end of file diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 30105fc778..ca4e366cbb 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -3674,7 +3674,7 @@ components: type: array type: object Finding: - description: A single finding without message and resource configuration. + description: A single finding without the message and resource configuration. properties: attributes: $ref: '#/components/schemas/FindingAttributes' @@ -3732,16 +3732,16 @@ components: properties: description: description: Additional information about the reason why this finding is - muted. + muted or unmuted. example: To be resolved later type: string expiration_date: - description: The end of the mute period. + description: The expiration date of the mute or unmute action (Unix ms). example: 1778721573794 format: int64 type: integer muted: - description: Whether this finding is muted. + description: Whether this finding is muted or unmuted. example: true type: boolean reason: @@ -3752,23 +3752,29 @@ components: format: int64 type: integer uuid: - description: The ID of the user who muted this finding. + description: The ID of the user who muted or unmuted this finding. example: e51c9744-d158-11ec-ad23-da7ad0900002 type: string type: object FindingMuteReason: - description: The reason why this finding is muted. + description: The reason why this finding is muted or unmuted. enum: - - ACCEPTED_RISK - PENDING_FIX - FALSE_POSITIVE + - ACCEPTED_RISK + - NO_PENDING_FIX + - HUMAN_ERROR + - NO_LONGER_ACCEPTED_RISK - OTHER example: ACCEPTED_RISK type: string x-enum-varnames: - - ACCEPTED_RISK - PENDING_FIX - FALSE_POSITIVE + - ACCEPTED_RISK + - NO_PENDING_FIX + - HUMAN_ERROR + - NO_LONGER_ACCEPTED_RISK - OTHER FindingResource: description: The resource name of this finding. @@ -3831,6 +3837,34 @@ 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. @@ -8471,6 +8505,139 @@ components: description: The monitor type. type: string type: object + MuteFindingRequest: + description: The new mute finding request. + properties: + data: + $ref: '#/components/schemas/MuteFindingRequestData' + required: + - data + type: object + MuteFindingRequestAttributes: + additionalProperties: false + description: The mute properties to be updated. + properties: + mute: + $ref: '#/components/schemas/MuteFindingRequestProperties' + required: + - mute + type: object + MuteFindingRequestData: + description: Data object containing the new mute properties of the finding. + properties: + attributes: + $ref: '#/components/schemas/MuteFindingRequestAttributes' + id: + $ref: '#/components/schemas/FindingID' + type: + $ref: '#/components/schemas/FindingType' + required: + - id + - type + - attributes + type: object + MuteFindingRequestProperties: + additionalProperties: false + description: Object containing the new mute properties of the finding. + properties: + description: + description: Additional information about the reason why this finding is + muted or unmuted. This field has a maximum limit of 280 characters. + example: To be resolved later + type: string + expiration_date: + description: 'The expiration date of the mute or unmute action (Unix ms). + It must be set to a value greater than the current timestamp. + + If this field is not provided, the finding will be muted or unmuted indefinitely, + which is equivalent to setting the expiration date to 9999999999999. + + ' + example: 1778721573794 + format: int64 + type: integer + muted: + description: Whether this finding is muted or unmuted. + example: true + type: boolean + reason: + $ref: '#/components/schemas/FindingMuteReason' + required: + - muted + - reason + type: object + MuteFindingResponse: + description: The expected response schema. + properties: + data: + $ref: '#/components/schemas/MuteFindingResponseData' + required: + - data + type: object + MuteFindingResponseAttributes: + description: The JSON:API attributes of the finding. + properties: + evaluation: + $ref: '#/components/schemas/FindingEvaluation' + evaluation_changed_at: + $ref: '#/components/schemas/FindingEvaluationChangedAt' + mute: + $ref: '#/components/schemas/MuteFindingResponseProperties' + resource: + $ref: '#/components/schemas/FindingResource' + resource_discovery_date: + $ref: '#/components/schemas/FindingResourceDiscoveryDate' + resource_type: + $ref: '#/components/schemas/FindingResourceType' + rule: + $ref: '#/components/schemas/FindingRule' + status: + $ref: '#/components/schemas/FindingStatus' + tags: + $ref: '#/components/schemas/FindingTags' + type: object + MuteFindingResponseData: + description: Data object containing the updated finding. + properties: + attributes: + $ref: '#/components/schemas/MuteFindingResponseAttributes' + id: + $ref: '#/components/schemas/FindingID' + type: + $ref: '#/components/schemas/FindingType' + type: object + MuteFindingResponseProperties: + additionalProperties: false + description: Information about the mute status of this finding. + properties: + description: + description: 'Additional information about the reason why this finding is + muted or unmuted. + + This attribute will not be included in the response if the description + is not provided in the request body. + + ' + example: To be resolved later + type: string + expiration_date: + description: 'The expiration date of the mute or unmute action. + + If the expiration date is not provided in the request body, this attribute + will not be included in the response and the finding will be muted or + unmuted indefinitely. + + ' + example: 1778721573794 + format: int64 + type: integer + muted: + description: Whether this finding is muted or unmuted. + example: true + type: boolean + reason: + $ref: '#/components/schemas/FindingMuteReason' + type: object NullableRelationshipToUser: description: Relationship to user. properties: @@ -19954,6 +20121,87 @@ paths: x-unstable: '**Note**: This endpoint is in public beta. If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + patch: + description: 'Mute or unmute a specific finding. + + The API returns the updated finding object when the request is successful.' + operationId: UpdateFinding + parameters: + - description: The ID of the finding. + in: path + name: finding_id + required: true + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/MuteFindingRequest' + description: 'To mute or unmute a finding, the request body should include + at least two attributes: `muted` and `reason`. The allowed reasons depend + on whether the finding is being muted or unmuted: + + - To mute a finding: `PENDING_FIX`, `FALSE_POSITIVE`, `ACCEPTED_RISK`, `OTHER`. + + - To unmute a finding : `NO_PENDING_FIX`, `HUMAN_ERROR`, `NO_LONGER_ACCEPTED_RISK`, + `OTHER`. + + ' + required: true + responses: + '200': + content: + application/json: + schema: + $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.' + '404': + content: + application/json: + schema: + $ref: '#/components/schemas/FindingsErrorResponse' + description: 'Not Found: The requested finding cannot be found.' + '409': + content: + application/json: + schema: + $ref: '#/components/schemas/FindingsErrorResponse' + 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' + 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.' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - security_monitoring_findings_write + summary: Mute or unmute a finding + tags: + - Security Monitoring + x-codegen-request-body-name: body + x-unstable: '**Note**: This endpoint is in public beta. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' /api/v2/processes: get: description: Get all processes for your organization. diff --git a/docs/datadog_api_client.v2.model.rst b/docs/datadog_api_client.v2.model.rst index 977f9842c9..5aa364f9ea 100644 --- a/docs/datadog_api_client.v2.model.rst +++ b/docs/datadog_api_client.v2.model.rst @@ -1562,6 +1562,20 @@ finding\_type :members: :show-inheritance: +findings\_error\_item +--------------------- + +.. automodule:: datadog_api_client.v2.model.findings_error_item + :members: + :show-inheritance: + +findings\_error\_response +------------------------- + +.. automodule:: datadog_api_client.v2.model.findings_error_response + :members: + :show-inheritance: + formula\_limit -------------- @@ -3809,6 +3823,62 @@ monitor\_type :members: :show-inheritance: +mute\_finding\_request +---------------------- + +.. automodule:: datadog_api_client.v2.model.mute_finding_request + :members: + :show-inheritance: + +mute\_finding\_request\_attributes +---------------------------------- + +.. automodule:: datadog_api_client.v2.model.mute_finding_request_attributes + :members: + :show-inheritance: + +mute\_finding\_request\_data +---------------------------- + +.. automodule:: datadog_api_client.v2.model.mute_finding_request_data + :members: + :show-inheritance: + +mute\_finding\_request\_properties +---------------------------------- + +.. automodule:: datadog_api_client.v2.model.mute_finding_request_properties + :members: + :show-inheritance: + +mute\_finding\_response +----------------------- + +.. automodule:: datadog_api_client.v2.model.mute_finding_response + :members: + :show-inheritance: + +mute\_finding\_response\_attributes +----------------------------------- + +.. automodule:: datadog_api_client.v2.model.mute_finding_response_attributes + :members: + :show-inheritance: + +mute\_finding\_response\_data +----------------------------- + +.. automodule:: datadog_api_client.v2.model.mute_finding_response_data + :members: + :show-inheritance: + +mute\_finding\_response\_properties +----------------------------------- + +.. automodule:: datadog_api_client.v2.model.mute_finding_response_properties + :members: + :show-inheritance: + nullable\_relationship\_to\_user -------------------------------- diff --git a/examples/v2/security-monitoring/UpdateFinding.py b/examples/v2/security-monitoring/UpdateFinding.py new file mode 100644 index 0000000000..37728066c2 --- /dev/null +++ b/examples/v2/security-monitoring/UpdateFinding.py @@ -0,0 +1,37 @@ +""" +Mute or unmute a finding returns "OK" response +""" + +from datadog_api_client import ApiClient, Configuration +from datadog_api_client.v2.api.security_monitoring_api import SecurityMonitoringApi +from datadog_api_client.v2.model.finding_mute_reason import FindingMuteReason +from datadog_api_client.v2.model.finding_type import FindingType +from datadog_api_client.v2.model.mute_finding_request import MuteFindingRequest +from datadog_api_client.v2.model.mute_finding_request_attributes import MuteFindingRequestAttributes +from datadog_api_client.v2.model.mute_finding_request_data import MuteFindingRequestData +from datadog_api_client.v2.model.mute_finding_request_properties import MuteFindingRequestProperties + +body = MuteFindingRequest( + data=MuteFindingRequestData( + attributes=MuteFindingRequestAttributes( + mute=MuteFindingRequestProperties( + description="To be resolved later", + expiration_date=1778721573794, + muted=True, + reason=FindingMuteReason.ACCEPTED_RISK, + ), + ), + id="AQAAAYbb1i0gijTHEQAAAABBWWJiMWkwZ0FBQ2FuNzBJVGZXZ3B3QUE", + type=FindingType.FINDING, + ), +) + +configuration = Configuration() +configuration.unstable_operations["update_finding"] = True +with ApiClient(configuration) as api_client: + api_instance = SecurityMonitoringApi(api_client) + response = api_instance.update_finding( + finding_id="AQAAAYbb1i0gijTHEQAAAABBWWJiMWkwZ0FBQ2FuNzBJVGZXZ3B3QUE", body=body + ) + + print(response) diff --git a/src/datadog_api_client/configuration.py b/src/datadog_api_client/configuration.py index 93afa0b436..002d143b43 100644 --- a/src/datadog_api_client/configuration.py +++ b/src/datadog_api_client/configuration.py @@ -245,6 +245,7 @@ def __init__( "v2.query_timeseries_data": False, "v2.get_finding": False, "v2.list_findings": False, + "v2.update_finding": False, "v2.create_incident_service": False, "v2.delete_incident_service": False, "v2.get_incident_service": False, diff --git a/src/datadog_api_client/v2/api/security_monitoring_api.py b/src/datadog_api_client/v2/api/security_monitoring_api.py index 8cf196e1eb..8c6e8e9fee 100644 --- a/src/datadog_api_client/v2/api/security_monitoring_api.py +++ b/src/datadog_api_client/v2/api/security_monitoring_api.py @@ -20,6 +20,8 @@ from datadog_api_client.v2.model.finding_status import FindingStatus from datadog_api_client.v2.model.finding import Finding from datadog_api_client.v2.model.get_finding_response import GetFindingResponse +from datadog_api_client.v2.model.mute_finding_response import MuteFindingResponse +from datadog_api_client.v2.model.mute_finding_request import MuteFindingRequest from datadog_api_client.v2.model.security_filters_response import SecurityFiltersResponse from datadog_api_client.v2.model.security_filter_response import SecurityFilterResponse from datadog_api_client.v2.model.security_filter_create_request import SecurityFilterCreateRequest @@ -550,6 +552,33 @@ def __init__(self, api_client=None): api_client=api_client, ) + self._update_finding_endpoint = _Endpoint( + settings={ + "response_type": (MuteFindingResponse,), + "auth": ["apiKeyAuth", "appKeyAuth", "AuthZ"], + "endpoint_path": "/api/v2/posture_management/findings/{finding_id}", + "operation_id": "update_finding", + "http_method": "PATCH", + "version": "v2", + "servers": None, + }, + params_map={ + "finding_id": { + "required": True, + "openapi_types": (str,), + "attribute": "finding_id", + "location": "path", + }, + "body": { + "required": True, + "openapi_types": (MuteFindingRequest,), + "location": "body", + }, + }, + headers_map={"accept": ["application/json"], "content_type": ["application/json"]}, + api_client=api_client, + ) + self._update_security_filter_endpoint = _Endpoint( settings={ "response_type": (SecurityFilterResponse,), @@ -1234,6 +1263,32 @@ def search_security_monitoring_signals_with_pagination( kwargs, "body.page.cursor", get_attribute_from_path(response, "meta.page.after"), endpoint.params_map ) + def update_finding( + self, + finding_id: str, + body: MuteFindingRequest, + ) -> MuteFindingResponse: + """Mute or unmute a finding. + + Mute or unmute a specific finding. + The API returns the updated finding object when the request is successful. + + :param finding_id: The ID of the finding. + :type finding_id: str + :param body: To mute or unmute a finding, the request body should include at least two attributes: ``muted`` and ``reason``. The allowed reasons depend on whether the finding is being muted or unmuted: + + * To mute a finding: ``PENDING_FIX`` , ``FALSE_POSITIVE`` , ``ACCEPTED_RISK`` , ``OTHER``. + * To unmute a finding : ``NO_PENDING_FIX`` , ``HUMAN_ERROR`` , ``NO_LONGER_ACCEPTED_RISK`` , ``OTHER``. + :type body: MuteFindingRequest + :rtype: MuteFindingResponse + """ + kwargs: Dict[str, Any] = {} + kwargs["finding_id"] = finding_id + + kwargs["body"] = body + + return self._update_finding_endpoint.call_with_http_info(**kwargs) + def update_security_filter( self, security_filter_id: str, diff --git a/src/datadog_api_client/v2/model/finding.py b/src/datadog_api_client/v2/model/finding.py index c00afcfe82..d2d2fc8626 100644 --- a/src/datadog_api_client/v2/model/finding.py +++ b/src/datadog_api_client/v2/model/finding.py @@ -44,7 +44,7 @@ def __init__( **kwargs, ): """ - A single finding without message and resource configuration. + A single finding without the message and resource configuration. :param attributes: The JSON:API attributes of the finding. :type attributes: FindingAttributes, optional diff --git a/src/datadog_api_client/v2/model/finding_mute.py b/src/datadog_api_client/v2/model/finding_mute.py index a9f8f38ab0..7dcec4322d 100644 --- a/src/datadog_api_client/v2/model/finding_mute.py +++ b/src/datadog_api_client/v2/model/finding_mute.py @@ -53,22 +53,22 @@ def __init__( """ Information about the mute status of this finding. - :param description: Additional information about the reason why this finding is muted. + :param description: Additional information about the reason why this finding is muted or unmuted. :type description: str, optional - :param expiration_date: The end of the mute period. + :param expiration_date: The expiration date of the mute or unmute action (Unix ms). :type expiration_date: int, optional - :param muted: Whether this finding is muted. + :param muted: Whether this finding is muted or unmuted. :type muted: bool, optional - :param reason: The reason why this finding is muted. + :param reason: The reason why this finding is muted or unmuted. :type reason: FindingMuteReason, optional :param start_date: The start of the mute period. :type start_date: int, optional - :param uuid: The ID of the user who muted this finding. + :param uuid: The ID of the user who muted or unmuted this finding. :type uuid: str, optional """ if description is not unset: diff --git a/src/datadog_api_client/v2/model/finding_mute_reason.py b/src/datadog_api_client/v2/model/finding_mute_reason.py index c73d6d5cc6..f78136d833 100644 --- a/src/datadog_api_client/v2/model/finding_mute_reason.py +++ b/src/datadog_api_client/v2/model/finding_mute_reason.py @@ -14,21 +14,27 @@ class FindingMuteReason(ModelSimple): """ - The reason why this finding is muted. + The reason why this finding is muted or unmuted. - :param value: Must be one of ["ACCEPTED_RISK", "PENDING_FIX", "FALSE_POSITIVE", "OTHER"]. + :param value: Must be one of ["PENDING_FIX", "FALSE_POSITIVE", "ACCEPTED_RISK", "NO_PENDING_FIX", "HUMAN_ERROR", "NO_LONGER_ACCEPTED_RISK", "OTHER"]. :type value: str """ allowed_values = { - "ACCEPTED_RISK", "PENDING_FIX", "FALSE_POSITIVE", + "ACCEPTED_RISK", + "NO_PENDING_FIX", + "HUMAN_ERROR", + "NO_LONGER_ACCEPTED_RISK", "OTHER", } - ACCEPTED_RISK: ClassVar["FindingMuteReason"] PENDING_FIX: ClassVar["FindingMuteReason"] FALSE_POSITIVE: ClassVar["FindingMuteReason"] + ACCEPTED_RISK: ClassVar["FindingMuteReason"] + NO_PENDING_FIX: ClassVar["FindingMuteReason"] + HUMAN_ERROR: ClassVar["FindingMuteReason"] + NO_LONGER_ACCEPTED_RISK: ClassVar["FindingMuteReason"] OTHER: ClassVar["FindingMuteReason"] @cached_property @@ -38,7 +44,10 @@ def openapi_types(_): } -FindingMuteReason.ACCEPTED_RISK = FindingMuteReason("ACCEPTED_RISK") FindingMuteReason.PENDING_FIX = FindingMuteReason("PENDING_FIX") FindingMuteReason.FALSE_POSITIVE = FindingMuteReason("FALSE_POSITIVE") +FindingMuteReason.ACCEPTED_RISK = FindingMuteReason("ACCEPTED_RISK") +FindingMuteReason.NO_PENDING_FIX = FindingMuteReason("NO_PENDING_FIX") +FindingMuteReason.HUMAN_ERROR = FindingMuteReason("HUMAN_ERROR") +FindingMuteReason.NO_LONGER_ACCEPTED_RISK = FindingMuteReason("NO_LONGER_ACCEPTED_RISK") FindingMuteReason.OTHER = FindingMuteReason("OTHER") diff --git a/src/datadog_api_client/v2/model/findings_error_item.py b/src/datadog_api_client/v2/model/findings_error_item.py new file mode 100644 index 0000000000..e7137ec582 --- /dev/null +++ b/src/datadog_api_client/v2/model/findings_error_item.py @@ -0,0 +1,56 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + +from typing import Union + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + unset, + UnsetType, +) + + +class FindingsErrorItem(ModelNormal): + @cached_property + def openapi_types(_): + return { + "detail": (str,), + "status": (str,), + "title": (str,), + } + + attribute_map = { + "detail": "detail", + "status": "status", + "title": "title", + } + + def __init__( + self_, + detail: Union[str, UnsetType] = unset, + status: Union[str, UnsetType] = unset, + title: Union[str, UnsetType] = unset, + **kwargs, + ): + """ + API error response body + + :param detail: A human-readable explanation specific to this occurrence of the error. + :type detail: str, optional + + :param status: Status code of the response. + :type status: str, optional + + :param title: Short human-readable summary of the error. + :type title: str, optional + """ + if detail is not unset: + kwargs["detail"] = detail + if status is not unset: + kwargs["status"] = status + if title is not unset: + kwargs["title"] = title + super().__init__(kwargs) diff --git a/src/datadog_api_client/v2/model/findings_error_response.py b/src/datadog_api_client/v2/model/findings_error_response.py new file mode 100644 index 0000000000..a6487b887e --- /dev/null +++ b/src/datadog_api_client/v2/model/findings_error_response.py @@ -0,0 +1,40 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + +from typing import List, TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.findings_error_item import FindingsErrorItem + + +class FindingsErrorResponse(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.findings_error_item import FindingsErrorItem + + return { + "errors": ([FindingsErrorItem],), + } + + attribute_map = { + "errors": "errors", + } + + def __init__(self_, errors: List[FindingsErrorItem], **kwargs): + """ + API error response. + + :param errors: A list of errors. + :type errors: [FindingsErrorItem] + """ + super().__init__(kwargs) + + self_.errors = errors diff --git a/src/datadog_api_client/v2/model/mute_finding_request.py b/src/datadog_api_client/v2/model/mute_finding_request.py new file mode 100644 index 0000000000..b572c12587 --- /dev/null +++ b/src/datadog_api_client/v2/model/mute_finding_request.py @@ -0,0 +1,40 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + +from typing import TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.mute_finding_request_data import MuteFindingRequestData + + +class MuteFindingRequest(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.mute_finding_request_data import MuteFindingRequestData + + return { + "data": (MuteFindingRequestData,), + } + + attribute_map = { + "data": "data", + } + + def __init__(self_, data: MuteFindingRequestData, **kwargs): + """ + The new mute finding request. + + :param data: Data object containing the new mute properties of the finding. + :type data: MuteFindingRequestData + """ + super().__init__(kwargs) + + self_.data = data diff --git a/src/datadog_api_client/v2/model/mute_finding_request_attributes.py b/src/datadog_api_client/v2/model/mute_finding_request_attributes.py new file mode 100644 index 0000000000..f4d28846a7 --- /dev/null +++ b/src/datadog_api_client/v2/model/mute_finding_request_attributes.py @@ -0,0 +1,40 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + +from typing import TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.mute_finding_request_properties import MuteFindingRequestProperties + + +class MuteFindingRequestAttributes(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.mute_finding_request_properties import MuteFindingRequestProperties + + return { + "mute": (MuteFindingRequestProperties,), + } + + attribute_map = { + "mute": "mute", + } + + def __init__(self_, mute: MuteFindingRequestProperties, **kwargs): + """ + The mute properties to be updated. + + :param mute: Object containing the new mute properties of the finding. + :type mute: MuteFindingRequestProperties + """ + super().__init__(kwargs) + + self_.mute = mute diff --git a/src/datadog_api_client/v2/model/mute_finding_request_data.py b/src/datadog_api_client/v2/model/mute_finding_request_data.py new file mode 100644 index 0000000000..72cafe872e --- /dev/null +++ b/src/datadog_api_client/v2/model/mute_finding_request_data.py @@ -0,0 +1,54 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + +from typing import TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.mute_finding_request_attributes import MuteFindingRequestAttributes + from datadog_api_client.v2.model.finding_type import FindingType + + +class MuteFindingRequestData(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.mute_finding_request_attributes import MuteFindingRequestAttributes + from datadog_api_client.v2.model.finding_type import FindingType + + return { + "attributes": (MuteFindingRequestAttributes,), + "id": (str,), + "type": (FindingType,), + } + + attribute_map = { + "attributes": "attributes", + "id": "id", + "type": "type", + } + + def __init__(self_, attributes: MuteFindingRequestAttributes, id: str, type: FindingType, **kwargs): + """ + Data object containing the new mute properties of the finding. + + :param attributes: The mute properties to be updated. + :type attributes: MuteFindingRequestAttributes + + :param id: The unique ID for this finding. + :type id: str + + :param type: The JSON:API type for findings. + :type type: FindingType + """ + super().__init__(kwargs) + + self_.attributes = attributes + self_.id = id + self_.type = type diff --git a/src/datadog_api_client/v2/model/mute_finding_request_properties.py b/src/datadog_api_client/v2/model/mute_finding_request_properties.py new file mode 100644 index 0000000000..5f9a70d20d --- /dev/null +++ b/src/datadog_api_client/v2/model/mute_finding_request_properties.py @@ -0,0 +1,70 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + +from typing import Union, TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + unset, + UnsetType, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.finding_mute_reason import FindingMuteReason + + +class MuteFindingRequestProperties(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.finding_mute_reason import FindingMuteReason + + return { + "description": (str,), + "expiration_date": (int,), + "muted": (bool,), + "reason": (FindingMuteReason,), + } + + attribute_map = { + "description": "description", + "expiration_date": "expiration_date", + "muted": "muted", + "reason": "reason", + } + + def __init__( + self_, + muted: bool, + reason: FindingMuteReason, + description: Union[str, UnsetType] = unset, + expiration_date: Union[int, UnsetType] = unset, + **kwargs, + ): + """ + Object containing the new mute properties of the finding. + + :param description: Additional information about the reason why this finding is muted or unmuted. This field has a maximum limit of 280 characters. + :type description: str, optional + + :param expiration_date: The expiration date of the mute or unmute action (Unix ms). It must be set to a value greater than the current timestamp. + If this field is not provided, the finding will be muted or unmuted indefinitely, which is equivalent to setting the expiration date to 9999999999999. + :type expiration_date: int, optional + + :param muted: Whether this finding is muted or unmuted. + :type muted: bool + + :param reason: The reason why this finding is muted or unmuted. + :type reason: FindingMuteReason + """ + if description is not unset: + kwargs["description"] = description + if expiration_date is not unset: + kwargs["expiration_date"] = expiration_date + super().__init__(kwargs) + + self_.muted = muted + self_.reason = reason diff --git a/src/datadog_api_client/v2/model/mute_finding_response.py b/src/datadog_api_client/v2/model/mute_finding_response.py new file mode 100644 index 0000000000..e310592fd2 --- /dev/null +++ b/src/datadog_api_client/v2/model/mute_finding_response.py @@ -0,0 +1,40 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + +from typing import TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.mute_finding_response_data import MuteFindingResponseData + + +class MuteFindingResponse(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.mute_finding_response_data import MuteFindingResponseData + + return { + "data": (MuteFindingResponseData,), + } + + attribute_map = { + "data": "data", + } + + def __init__(self_, data: MuteFindingResponseData, **kwargs): + """ + The expected response schema. + + :param data: Data object containing the updated finding. + :type data: MuteFindingResponseData + """ + super().__init__(kwargs) + + self_.data = data diff --git a/src/datadog_api_client/v2/model/mute_finding_response_attributes.py b/src/datadog_api_client/v2/model/mute_finding_response_attributes.py new file mode 100644 index 0000000000..84c3a2d4a1 --- /dev/null +++ b/src/datadog_api_client/v2/model/mute_finding_response_attributes.py @@ -0,0 +1,125 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + +from typing import List, Union, TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + unset, + UnsetType, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.finding_evaluation import FindingEvaluation + from datadog_api_client.v2.model.mute_finding_response_properties import MuteFindingResponseProperties + from datadog_api_client.v2.model.finding_rule import FindingRule + from datadog_api_client.v2.model.finding_status import FindingStatus + + +class MuteFindingResponseAttributes(ModelNormal): + validations = { + "evaluation_changed_at": { + "inclusive_minimum": 1, + }, + "resource_discovery_date": { + "inclusive_minimum": 1, + }, + } + + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.finding_evaluation import FindingEvaluation + from datadog_api_client.v2.model.mute_finding_response_properties import MuteFindingResponseProperties + from datadog_api_client.v2.model.finding_rule import FindingRule + from datadog_api_client.v2.model.finding_status import FindingStatus + + return { + "evaluation": (FindingEvaluation,), + "evaluation_changed_at": (int,), + "mute": (MuteFindingResponseProperties,), + "resource": (str,), + "resource_discovery_date": (int,), + "resource_type": (str,), + "rule": (FindingRule,), + "status": (FindingStatus,), + "tags": ([str],), + } + + attribute_map = { + "evaluation": "evaluation", + "evaluation_changed_at": "evaluation_changed_at", + "mute": "mute", + "resource": "resource", + "resource_discovery_date": "resource_discovery_date", + "resource_type": "resource_type", + "rule": "rule", + "status": "status", + "tags": "tags", + } + + def __init__( + self_, + evaluation: Union[FindingEvaluation, UnsetType] = unset, + evaluation_changed_at: Union[int, UnsetType] = unset, + mute: Union[MuteFindingResponseProperties, UnsetType] = unset, + resource: Union[str, UnsetType] = unset, + resource_discovery_date: Union[int, UnsetType] = unset, + resource_type: Union[str, UnsetType] = unset, + rule: Union[FindingRule, UnsetType] = unset, + status: Union[FindingStatus, UnsetType] = unset, + tags: Union[List[str], UnsetType] = unset, + **kwargs, + ): + """ + The JSON:API attributes of the finding. + + :param evaluation: The evaluation of the finding. + :type evaluation: FindingEvaluation, optional + + :param evaluation_changed_at: The date on which the evaluation for this finding changed (Unix ms). + :type evaluation_changed_at: int, optional + + :param mute: Information about the mute status of this finding. + :type mute: MuteFindingResponseProperties, optional + + :param resource: The resource name of this finding. + :type resource: str, optional + + :param resource_discovery_date: The date on which the resource was discovered (Unix ms). + :type resource_discovery_date: int, optional + + :param resource_type: The resource type of this finding. + :type resource_type: str, optional + + :param rule: The rule that triggered this finding. + :type rule: FindingRule, optional + + :param status: The status of the finding. + :type status: FindingStatus, optional + + :param tags: The tags associated with this finding. + :type tags: [str], optional + """ + if evaluation is not unset: + kwargs["evaluation"] = evaluation + if evaluation_changed_at is not unset: + kwargs["evaluation_changed_at"] = evaluation_changed_at + if mute is not unset: + kwargs["mute"] = mute + if resource is not unset: + kwargs["resource"] = resource + if resource_discovery_date is not unset: + kwargs["resource_discovery_date"] = resource_discovery_date + if resource_type is not unset: + kwargs["resource_type"] = resource_type + if rule is not unset: + kwargs["rule"] = rule + if status is not unset: + kwargs["status"] = status + if tags is not unset: + kwargs["tags"] = tags + super().__init__(kwargs) diff --git a/src/datadog_api_client/v2/model/mute_finding_response_data.py b/src/datadog_api_client/v2/model/mute_finding_response_data.py new file mode 100644 index 0000000000..b41948b0be --- /dev/null +++ b/src/datadog_api_client/v2/model/mute_finding_response_data.py @@ -0,0 +1,64 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + +from typing import Union, TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + unset, + UnsetType, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.mute_finding_response_attributes import MuteFindingResponseAttributes + from datadog_api_client.v2.model.finding_type import FindingType + + +class MuteFindingResponseData(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.mute_finding_response_attributes import MuteFindingResponseAttributes + from datadog_api_client.v2.model.finding_type import FindingType + + return { + "attributes": (MuteFindingResponseAttributes,), + "id": (str,), + "type": (FindingType,), + } + + attribute_map = { + "attributes": "attributes", + "id": "id", + "type": "type", + } + + def __init__( + self_, + attributes: Union[MuteFindingResponseAttributes, UnsetType] = unset, + id: Union[str, UnsetType] = unset, + type: Union[FindingType, UnsetType] = unset, + **kwargs, + ): + """ + Data object containing the updated finding. + + :param attributes: The JSON:API attributes of the finding. + :type attributes: MuteFindingResponseAttributes, optional + + :param id: The unique ID for this finding. + :type id: str, optional + + :param type: The JSON:API type for findings. + :type type: FindingType, optional + """ + if attributes is not unset: + kwargs["attributes"] = attributes + if id is not unset: + kwargs["id"] = id + if type is not unset: + kwargs["type"] = type + super().__init__(kwargs) diff --git a/src/datadog_api_client/v2/model/mute_finding_response_properties.py b/src/datadog_api_client/v2/model/mute_finding_response_properties.py new file mode 100644 index 0000000000..0253690328 --- /dev/null +++ b/src/datadog_api_client/v2/model/mute_finding_response_properties.py @@ -0,0 +1,72 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + +from typing import Union, TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + unset, + UnsetType, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.finding_mute_reason import FindingMuteReason + + +class MuteFindingResponseProperties(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.finding_mute_reason import FindingMuteReason + + return { + "description": (str,), + "expiration_date": (int,), + "muted": (bool,), + "reason": (FindingMuteReason,), + } + + attribute_map = { + "description": "description", + "expiration_date": "expiration_date", + "muted": "muted", + "reason": "reason", + } + + def __init__( + self_, + description: Union[str, UnsetType] = unset, + expiration_date: Union[int, UnsetType] = unset, + muted: Union[bool, UnsetType] = unset, + reason: Union[FindingMuteReason, UnsetType] = unset, + **kwargs, + ): + """ + Information about the mute status of this finding. + + :param description: Additional information about the reason why this finding is muted or unmuted. + This attribute will not be included in the response if the description is not provided in the request body. + :type description: str, optional + + :param expiration_date: The expiration date of the mute or unmute action. + If the expiration date is not provided in the request body, this attribute will not be included in the response and the finding will be muted or unmuted indefinitely. + :type expiration_date: int, optional + + :param muted: Whether this finding is muted or unmuted. + :type muted: bool, optional + + :param reason: The reason why this finding is muted or unmuted. + :type reason: FindingMuteReason, optional + """ + if description is not unset: + kwargs["description"] = description + if expiration_date is not unset: + kwargs["expiration_date"] = expiration_date + if muted is not unset: + kwargs["muted"] = muted + if reason is not unset: + kwargs["reason"] = reason + super().__init__(kwargs) diff --git a/src/datadog_api_client/v2/models/__init__.py b/src/datadog_api_client/v2/models/__init__.py index 94e2acd7ce..a6fd262341 100644 --- a/src/datadog_api_client/v2/models/__init__.py +++ b/src/datadog_api_client/v2/models/__init__.py @@ -261,6 +261,8 @@ from datadog_api_client.v2.model.finding_rule import FindingRule from datadog_api_client.v2.model.finding_status import FindingStatus from datadog_api_client.v2.model.finding_type import FindingType +from datadog_api_client.v2.model.findings_error_item import FindingsErrorItem +from datadog_api_client.v2.model.findings_error_response import FindingsErrorResponse from datadog_api_client.v2.model.formula_limit import FormulaLimit from datadog_api_client.v2.model.full_api_key import FullAPIKey from datadog_api_client.v2.model.full_api_key_attributes import FullAPIKeyAttributes @@ -634,6 +636,14 @@ ) from datadog_api_client.v2.model.monitor_config_policy_type import MonitorConfigPolicyType from datadog_api_client.v2.model.monitor_type import MonitorType +from datadog_api_client.v2.model.mute_finding_request import MuteFindingRequest +from datadog_api_client.v2.model.mute_finding_request_attributes import MuteFindingRequestAttributes +from datadog_api_client.v2.model.mute_finding_request_data import MuteFindingRequestData +from datadog_api_client.v2.model.mute_finding_request_properties import MuteFindingRequestProperties +from datadog_api_client.v2.model.mute_finding_response import MuteFindingResponse +from datadog_api_client.v2.model.mute_finding_response_attributes import MuteFindingResponseAttributes +from datadog_api_client.v2.model.mute_finding_response_data import MuteFindingResponseData +from datadog_api_client.v2.model.mute_finding_response_properties import MuteFindingResponseProperties from datadog_api_client.v2.model.nullable_relationship_to_user import NullableRelationshipToUser from datadog_api_client.v2.model.nullable_relationship_to_user_data import NullableRelationshipToUserData from datadog_api_client.v2.model.on_demand_concurrency_cap import OnDemandConcurrencyCap diff --git a/tests/v2/cassettes/test_scenarios/test_mute_or_unmute_a_finding_returns_ok_response.frozen b/tests/v2/cassettes/test_scenarios/test_mute_or_unmute_a_finding_returns_ok_response.frozen new file mode 100644 index 0000000000..0bbac63155 --- /dev/null +++ b/tests/v2/cassettes/test_scenarios/test_mute_or_unmute_a_finding_returns_ok_response.frozen @@ -0,0 +1 @@ +2023-05-30T22:58:28.319Z \ No newline at end of file diff --git a/tests/v2/cassettes/test_scenarios/test_mute_or_unmute_a_finding_returns_ok_response.yaml b/tests/v2/cassettes/test_scenarios/test_mute_or_unmute_a_finding_returns_ok_response.yaml new file mode 100644 index 0000000000..60a0cd6fc9 --- /dev/null +++ b/tests/v2/cassettes/test_scenarios/test_mute_or_unmute_a_finding_returns_ok_response.yaml @@ -0,0 +1,22 @@ +interactions: +- request: + body: '{"data":{"attributes":{"mute":{"description":"To be resolved later","expiration_date":1778721573794,"muted":true,"reason":"ACCEPTED_RISK"}},"id":"AQAAAYbb1i0gijTHEQAAAABBWWJiMWkwZ0FBQ2FuNzBJVGZXZ3B3QUE","type":"finding"}}' + headers: + accept: + - application/json + content-type: + - application/json + method: PATCH + uri: https://api.datadoghq.com/api/v2/posture_management/findings/AQAAAYbb1i0gijTHEQAAAABBWWJiMWkwZ0FBQ2FuNzBJVGZXZ3B3QUE + response: + body: + string: '{"data":{"id":"AQAAAYbb1i0gijTHEQAAAABBWWJiMWkwZ0FBQ2FuNzBJVGZXZ3B3QUE","type":"finding","attributes":{"evaluation":"pass","evaluation_changed_at":1681220975000,"mute":{"description":"To + be resolved later","expiration_date":1778721573794,"muted":true,"reason":"ACCEPTED_RISK"},"resource":"dd-chaos-cloud-xuxu-eu-north-1","resource_discovery_date":1681220975000,"resource_type":"aws_s3_bucket","rule":{"name":"S3 + bucket ACL does not grant full bucket control to everyone","id":"gkb-eoz-lut"},"status":"critical","tags":["requirement:AWS","scored:true","aws_account:013910733512","framework:gdpr","control:164.308-a-3-i","requirement:Compliance","framework:iso-27001","framework:hipaa","requirement:Access-Control","source:s3","requirement:Information-Access-Management","region:eu-north-1","control:164.308-a-4-ii-B","framework:pci","control:164.308-a-4-ii-C","control:25.2","requirement:Workforce-Security","control:1.1","security:compliance","requirement:Least-Privileged-Access","cloud_provider:aws","requirement:Data-Protection","control:7.2.1","control:7.2.2","requirement:Security-of-Processing","control:A.18.1.3","framework:soc-2","scope:s3","control:A.9.2.3","control:32.1a","requirement:Logical-and-Physical-Access-Control","control:CC6.3","framework:security-labs","control:CC6.1"]}}}' + headers: + content-type: + - application/vnd.api+json + status: + code: 200 + message: OK +version: 1 diff --git a/tests/v2/features/security_monitoring.feature b/tests/v2/features/security_monitoring.feature index 6c66b15860..cdbcb18dff 100644 --- a/tests/v2/features/security_monitoring.feature +++ b/tests/v2/features/security_monitoring.feature @@ -389,6 +389,52 @@ Feature: Security Monitoring When the request is sent Then the response status is 200 OK + @generated @skip @team:DataDog/cloud-security-posture-management + Scenario: Mute or unmute a finding returns "Bad Request: The server cannot process the request due to invalid syntax in the request." response + Given operation "UpdateFinding" enabled + And new "UpdateFinding" request + And request contains "finding_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"mute": {"description": "To be resolved later", "expiration_date": 1778721573794, "muted": true, "reason": "ACCEPTED_RISK"}}, "id": "AQAAAYbb1i0gijTHEQAAAABBWWJiMWkwZ0FBQ2FuNzBJVGZXZ3B3QUE", "type": "finding"}} + When the request is sent + 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: Mute or unmute a finding returns "Invalid Request: The server understands the request syntax but cannot process it due to invalid data." response + Given operation "UpdateFinding" enabled + And new "UpdateFinding" request + And request contains "finding_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"mute": {"description": "To be resolved later", "expiration_date": 1778721573794, "muted": true, "reason": "ACCEPTED_RISK"}}, "id": "AQAAAYbb1i0gijTHEQAAAABBWWJiMWkwZ0FBQ2FuNzBJVGZXZ3B3QUE", "type": "finding"}} + When the request is sent + Then the response status is 422 Invalid Request: The server understands the request syntax but cannot process it due to invalid data. + + @generated @skip @team:DataDog/cloud-security-posture-management + Scenario: Mute or unmute a finding returns "Not Found: The requested finding cannot be found." response + Given operation "UpdateFinding" enabled + And new "UpdateFinding" request + And request contains "finding_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"mute": {"description": "To be resolved later", "expiration_date": 1778721573794, "muted": true, "reason": "ACCEPTED_RISK"}}, "id": "AQAAAYbb1i0gijTHEQAAAABBWWJiMWkwZ0FBQ2FuNzBJVGZXZ3B3QUE", "type": "finding"}} + When the request is sent + Then the response status is 404 Not Found: The requested finding cannot be found. + + @replay-only @team:DataDog/cloud-security-posture-management + Scenario: Mute or unmute a finding returns "OK" response + Given operation "UpdateFinding" enabled + And new "UpdateFinding" request + And request contains "finding_id" parameter with value "AQAAAYbb1i0gijTHEQAAAABBWWJiMWkwZ0FBQ2FuNzBJVGZXZ3B3QUE" + And body with value {"data": {"attributes": {"mute": {"description": "To be resolved later", "expiration_date": 1778721573794, "muted": true, "reason": "ACCEPTED_RISK"}}, "id": "AQAAAYbb1i0gijTHEQAAAABBWWJiMWkwZ0FBQ2FuNzBJVGZXZ3B3QUE", "type": "finding"}} + When the request is sent + Then the response status is 200 OK + And the response "data.attributes.mute.muted" is equal to true + + @generated @skip @team:DataDog/cloud-security-posture-management + Scenario: Mute or unmute a finding returns "Resource Conflict: The finding has already been muted or unmuted within the last 60 seconds." response + Given operation "UpdateFinding" enabled + And new "UpdateFinding" request + And request contains "finding_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"mute": {"description": "To be resolved later", "expiration_date": 1778721573794, "muted": true, "reason": "ACCEPTED_RISK"}}, "id": "AQAAAYbb1i0gijTHEQAAAABBWWJiMWkwZ0FBQ2FuNzBJVGZXZ3B3QUE", "type": "finding"}} + When the request is sent + Then the response status is 409 Resource Conflict: The finding has already been muted or unmuted within the last 60 seconds. + @team:DataDog/k9-cloud-security-platform Scenario: Update a cloud configuration rule's details returns "OK" response Given new "UpdateSecurityMonitoringRule" request diff --git a/tests/v2/features/undo.json b/tests/v2/features/undo.json index 6a3bd0e049..8958efda75 100644 --- a/tests/v2/features/undo.json +++ b/tests/v2/features/undo.json @@ -925,6 +925,12 @@ "type": "safe" } }, + "UpdateFinding": { + "tag": "Security Monitoring", + "undo": { + "type": "safe" + } + }, "ListProcesses": { "tag": "Processes", "undo": {