diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 90e1196820..53a4ea6a1a 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -75076,6 +75076,18 @@ components: required: - data type: object + OwnershipConfidenceLevel: + description: The ownership confidence level. + enum: + - high + - medium + - low + example: high + type: string + x-enum-varnames: + - HIGH + - MEDIUM + - LOW OwnershipEvidenceAttributes: description: The attributes of an ownership evidence response. properties: @@ -75639,6 +75651,152 @@ components: - TEAM - SERVICE - UNKNOWN + OwnershipSettingsAttributes: + description: The attributes of the ownership settings response. + properties: + auto_tag: + description: Whether automatic ownership tagging is enabled. + example: true + type: boolean + confidence_level: + $ref: "#/components/schemas/OwnershipConfidenceLevel" + version: + description: The current version of the ownership settings. + example: 1 + format: int64 + type: integer + required: + - version + - auto_tag + - confidence_level + type: object + OwnershipSettingsData: + description: The data wrapper for an ownership settings response. + properties: + attributes: + $ref: "#/components/schemas/OwnershipSettingsAttributes" + id: + description: The identifier of the ownership settings resource. + example: settings + type: string + type: + $ref: "#/components/schemas/OwnershipSettingsType" + required: + - id + - type + - attributes + type: object + OwnershipSettingsRequest: + description: The request body for updating ownership settings. + properties: + data: + $ref: "#/components/schemas/OwnershipSettingsRequestData" + required: + - data + type: object + OwnershipSettingsRequestAttributes: + description: The attributes of an ownership settings request. + properties: + auto_tag: + description: Whether automatic ownership tagging is enabled. + example: true + type: boolean + confidence_level: + $ref: "#/components/schemas/OwnershipConfidenceLevel" + required: + - auto_tag + - confidence_level + type: object + OwnershipSettingsRequestData: + description: The data wrapper for an ownership settings request. + properties: + attributes: + $ref: "#/components/schemas/OwnershipSettingsRequestAttributes" + type: + $ref: "#/components/schemas/OwnershipSettingsType" + required: + - type + - attributes + type: object + OwnershipSettingsResponse: + description: The response returned when retrieving or updating ownership settings. + properties: + data: + $ref: "#/components/schemas/OwnershipSettingsData" + required: + - data + type: object + OwnershipSettingsType: + default: ownership_settings + description: The type of the ownership settings resource. The value should always be `ownership_settings`. + enum: + - ownership_settings + example: ownership_settings + type: string + x-enum-varnames: + - OWNERSHIP_SETTINGS + OwnershipUntaggedFindingsAttributes: + description: The counts of findings without a team tag by ownership confidence. + properties: + high_confidence: + description: The number of high confidence findings without a team tag. + example: 30 + format: int64 + type: integer + low_confidence: + description: The number of low confidence findings without a team tag. + example: 42 + format: int64 + type: integer + medium_confidence: + description: The number of medium confidence findings without a team tag. + example: 70 + format: int64 + type: integer + total: + description: The total number of findings without a team tag. + example: 142 + format: int64 + type: integer + required: + - total + - high_confidence + - medium_confidence + - low_confidence + type: object + OwnershipUntaggedFindingsData: + description: The data wrapper for an ownership untagged findings response. + properties: + attributes: + $ref: "#/components/schemas/OwnershipUntaggedFindingsAttributes" + id: + description: The identifier of the ownership untagged findings resource. + example: untagged + type: string + type: + $ref: "#/components/schemas/OwnershipUntaggedFindingsType" + required: + - id + - type + - attributes + type: object + OwnershipUntaggedFindingsResponse: + description: The response returned when counting findings without a team tag by ownership confidence. + properties: + data: + $ref: "#/components/schemas/OwnershipUntaggedFindingsData" + required: + - data + type: object + OwnershipUntaggedFindingsType: + default: ownership_untagged_findings + description: The type of the ownership untagged findings resource. The value should always be `ownership_untagged_findings`. + enum: + - ownership_untagged_findings + example: ownership_untagged_findings + type: string + x-enum-varnames: + - OWNERSHIP_UNTAGGED_FINDINGS PageAnnotationsAttributes: description: Attributes of the annotations on a page. properties: @@ -132295,6 +132453,128 @@ paths: $ref: "#/components/responses/TooManyRequestsResponse" summary: Get all CSM Serverless Agents tags: ["CSM Agents"] + /api/v2/csm/ownership/settings: + get: + description: Get ownership settings for the org. When settings are unset, the API returns the default opt-out configuration with `auto_tag` set to `true` and `confidence_level` set to `high`. + operationId: GetOwnershipSettings + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + attributes: + auto_tag: true + confidence_level: high + version: 1 + id: settings + type: ownership_settings + schema: + $ref: "#/components/schemas/OwnershipSettingsResponse" + description: OK + "401": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Unauthorized + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + summary: Get ownership settings for the org + tags: ["CSM Ownership"] + x-unstable: |- + **Note**: This endpoint is in Preview and may be subject to change. + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). + post: + description: Update ownership settings for the org. + operationId: PostOwnershipSettings + requestBody: + content: + application/json: + examples: + default: + value: + data: + attributes: + auto_tag: true + confidence_level: high + type: ownership_settings + schema: + $ref: "#/components/schemas/OwnershipSettingsRequest" + required: true + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + attributes: + auto_tag: true + confidence_level: high + version: 1 + id: settings + type: ownership_settings + schema: + $ref: "#/components/schemas/OwnershipSettingsResponse" + description: OK + "400": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Bad Request + "401": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Unauthorized + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + summary: Update ownership settings for the org + tags: ["CSM Ownership"] + x-unstable: |- + **Note**: This endpoint is in Preview and may be subject to change. + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). + /api/v2/csm/ownership/settings/untagged: + get: + description: Count findings with no team tag, grouped by ownership confidence level. + operationId: GetOwnershipUntaggedFindings + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + attributes: + high_confidence: 30 + low_confidence: 42 + medium_confidence: 70 + total: 142 + id: untagged + type: ownership_untagged_findings + schema: + $ref: "#/components/schemas/OwnershipUntaggedFindingsResponse" + description: OK + "401": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Unauthorized + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + summary: Count untagged findings by ownership confidence + tags: ["CSM Ownership"] + x-unstable: |- + **Note**: This endpoint is in Preview and may be subject to change. + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). /api/v2/csm/ownership/{resource_id}: get: description: Get all current ownership inferences for a resource, one per owner type (`user`, `team`, `service`, `unknown`). diff --git a/docs/datadog_api_client.v2.model.rst b/docs/datadog_api_client.v2.model.rst index f8ad6785c8..e1cdea6bac 100644 --- a/docs/datadog_api_client.v2.model.rst +++ b/docs/datadog_api_client.v2.model.rst @@ -31469,6 +31469,13 @@ datadog\_api\_client.v2.model.overwrite\_allocations\_request module :members: :show-inheritance: +datadog\_api\_client.v2.model.ownership\_confidence\_level module +----------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.ownership_confidence_level + :members: + :show-inheritance: + datadog\_api\_client.v2.model.ownership\_evidence\_attributes module -------------------------------------------------------------------- @@ -31686,6 +31693,83 @@ datadog\_api\_client.v2.model.ownership\_owner\_type module :members: :show-inheritance: +datadog\_api\_client.v2.model.ownership\_settings\_attributes module +-------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.ownership_settings_attributes + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.ownership\_settings\_data module +-------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.ownership_settings_data + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.ownership\_settings\_request module +----------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.ownership_settings_request + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.ownership\_settings\_request\_attributes module +----------------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.ownership_settings_request_attributes + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.ownership\_settings\_request\_data module +----------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.ownership_settings_request_data + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.ownership\_settings\_response module +------------------------------------------------------------------ + +.. automodule:: datadog_api_client.v2.model.ownership_settings_response + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.ownership\_settings\_type module +-------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.ownership_settings_type + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.ownership\_untagged\_findings\_attributes module +------------------------------------------------------------------------------ + +.. automodule:: datadog_api_client.v2.model.ownership_untagged_findings_attributes + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.ownership\_untagged\_findings\_data module +------------------------------------------------------------------------ + +.. automodule:: datadog_api_client.v2.model.ownership_untagged_findings_data + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.ownership\_untagged\_findings\_response module +---------------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.ownership_untagged_findings_response + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.ownership\_untagged\_findings\_type module +------------------------------------------------------------------------ + +.. automodule:: datadog_api_client.v2.model.ownership_untagged_findings_type + :members: + :show-inheritance: + datadog\_api\_client.v2.model.page\_annotations\_attributes module ------------------------------------------------------------------ diff --git a/examples/v2/csm-ownership/GetOwnershipSettings.py b/examples/v2/csm-ownership/GetOwnershipSettings.py new file mode 100644 index 0000000000..1ba8d98c62 --- /dev/null +++ b/examples/v2/csm-ownership/GetOwnershipSettings.py @@ -0,0 +1,14 @@ +""" +Get ownership settings for the org returns "OK" response +""" + +from datadog_api_client import ApiClient, Configuration +from datadog_api_client.v2.api.csm_ownership_api import CSMOwnershipApi + +configuration = Configuration() +configuration.unstable_operations["get_ownership_settings"] = True +with ApiClient(configuration) as api_client: + api_instance = CSMOwnershipApi(api_client) + response = api_instance.get_ownership_settings() + + print(response) diff --git a/examples/v2/csm-ownership/GetOwnershipUntaggedFindings.py b/examples/v2/csm-ownership/GetOwnershipUntaggedFindings.py new file mode 100644 index 0000000000..f58e12d845 --- /dev/null +++ b/examples/v2/csm-ownership/GetOwnershipUntaggedFindings.py @@ -0,0 +1,14 @@ +""" +Count untagged findings by ownership confidence returns "OK" response +""" + +from datadog_api_client import ApiClient, Configuration +from datadog_api_client.v2.api.csm_ownership_api import CSMOwnershipApi + +configuration = Configuration() +configuration.unstable_operations["get_ownership_untagged_findings"] = True +with ApiClient(configuration) as api_client: + api_instance = CSMOwnershipApi(api_client) + response = api_instance.get_ownership_untagged_findings() + + print(response) diff --git a/examples/v2/csm-ownership/PostOwnershipSettings.py b/examples/v2/csm-ownership/PostOwnershipSettings.py new file mode 100644 index 0000000000..5ac0c5f90e --- /dev/null +++ b/examples/v2/csm-ownership/PostOwnershipSettings.py @@ -0,0 +1,29 @@ +""" +Update ownership settings for the org returns "OK" response +""" + +from datadog_api_client import ApiClient, Configuration +from datadog_api_client.v2.api.csm_ownership_api import CSMOwnershipApi +from datadog_api_client.v2.model.ownership_confidence_level import OwnershipConfidenceLevel +from datadog_api_client.v2.model.ownership_settings_request import OwnershipSettingsRequest +from datadog_api_client.v2.model.ownership_settings_request_attributes import OwnershipSettingsRequestAttributes +from datadog_api_client.v2.model.ownership_settings_request_data import OwnershipSettingsRequestData +from datadog_api_client.v2.model.ownership_settings_type import OwnershipSettingsType + +body = OwnershipSettingsRequest( + data=OwnershipSettingsRequestData( + attributes=OwnershipSettingsRequestAttributes( + auto_tag=True, + confidence_level=OwnershipConfidenceLevel.HIGH, + ), + type=OwnershipSettingsType.OWNERSHIP_SETTINGS, + ), +) + +configuration = Configuration() +configuration.unstable_operations["post_ownership_settings"] = True +with ApiClient(configuration) as api_client: + api_instance = CSMOwnershipApi(api_client) + response = api_instance.post_ownership_settings(body=body) + + print(response) diff --git a/src/datadog_api_client/configuration.py b/src/datadog_api_client/configuration.py index 87a66d2fbd..b6c6b761f1 100644 --- a/src/datadog_api_client/configuration.py +++ b/src/datadog_api_client/configuration.py @@ -465,9 +465,12 @@ def __init__( "v2.create_ownership_feedback": False, "v2.get_ownership_evidence": False, "v2.get_ownership_inference": False, + "v2.get_ownership_settings": False, + "v2.get_ownership_untagged_findings": False, "v2.list_ownership_history": False, "v2.list_ownership_history_by_owner_type": False, "v2.list_ownership_inferences": False, + "v2.post_ownership_settings": False, "v2.get_csm_agentless_host_facet_info": False, "v2.get_csm_unified_host_facet_info": False, "v2.list_csm_agentless_host_facets": False, diff --git a/src/datadog_api_client/v2/api/csm_ownership_api.py b/src/datadog_api_client/v2/api/csm_ownership_api.py index bf7db77ae7..bcea54c759 100644 --- a/src/datadog_api_client/v2/api/csm_ownership_api.py +++ b/src/datadog_api_client/v2/api/csm_ownership_api.py @@ -11,6 +11,9 @@ UnsetType, unset, ) +from datadog_api_client.v2.model.ownership_settings_response import OwnershipSettingsResponse +from datadog_api_client.v2.model.ownership_settings_request import OwnershipSettingsRequest +from datadog_api_client.v2.model.ownership_untagged_findings_response import OwnershipUntaggedFindingsResponse from datadog_api_client.v2.model.ownership_inference_list_response import OwnershipInferenceListResponse from datadog_api_client.v2.model.ownership_history_response import OwnershipHistoryResponse from datadog_api_client.v2.model.ownership_inference_response import OwnershipInferenceResponse @@ -134,6 +137,38 @@ def __init__(self, api_client=None): api_client=api_client, ) + self._get_ownership_settings_endpoint = _Endpoint( + settings={ + "response_type": (OwnershipSettingsResponse,), + "auth": ["apiKeyAuth", "appKeyAuth"], + "endpoint_path": "/api/v2/csm/ownership/settings", + "operation_id": "get_ownership_settings", + "http_method": "GET", + "version": "v2", + }, + params_map={}, + headers_map={ + "accept": ["application/json"], + }, + api_client=api_client, + ) + + self._get_ownership_untagged_findings_endpoint = _Endpoint( + settings={ + "response_type": (OwnershipUntaggedFindingsResponse,), + "auth": ["apiKeyAuth", "appKeyAuth"], + "endpoint_path": "/api/v2/csm/ownership/settings/untagged", + "operation_id": "get_ownership_untagged_findings", + "http_method": "GET", + "version": "v2", + }, + params_map={}, + headers_map={ + "accept": ["application/json"], + }, + api_client=api_client, + ) + self._list_ownership_history_endpoint = _Endpoint( settings={ "response_type": (OwnershipHistoryResponse,), @@ -237,6 +272,26 @@ def __init__(self, api_client=None): api_client=api_client, ) + self._post_ownership_settings_endpoint = _Endpoint( + settings={ + "response_type": (OwnershipSettingsResponse,), + "auth": ["apiKeyAuth", "appKeyAuth"], + "endpoint_path": "/api/v2/csm/ownership/settings", + "operation_id": "post_ownership_settings", + "http_method": "POST", + "version": "v2", + }, + params_map={ + "body": { + "required": True, + "openapi_types": (OwnershipSettingsRequest,), + "location": "body", + }, + }, + headers_map={"accept": ["application/json"], "content_type": ["application/json"]}, + api_client=api_client, + ) + def create_ownership_feedback( self, resource_id: str, @@ -329,6 +384,30 @@ def get_ownership_inference( return self._get_ownership_inference_endpoint.call_with_http_info(**kwargs) + def get_ownership_settings( + self, + ) -> OwnershipSettingsResponse: + """Get ownership settings for the org. + + Get ownership settings for the org. When settings are unset, the API returns the default opt-out configuration with ``auto_tag`` set to ``true`` and ``confidence_level`` set to ``high``. + + :rtype: OwnershipSettingsResponse + """ + kwargs: Dict[str, Any] = {} + return self._get_ownership_settings_endpoint.call_with_http_info(**kwargs) + + def get_ownership_untagged_findings( + self, + ) -> OwnershipUntaggedFindingsResponse: + """Count untagged findings by ownership confidence. + + Count findings with no team tag, grouped by ownership confidence level. + + :rtype: OwnershipUntaggedFindingsResponse + """ + kwargs: Dict[str, Any] = {} + return self._get_ownership_untagged_findings_endpoint.call_with_http_info(**kwargs) + def list_ownership_history( self, resource_id: str, @@ -410,3 +489,19 @@ def list_ownership_inferences( kwargs["resource_id"] = resource_id return self._list_ownership_inferences_endpoint.call_with_http_info(**kwargs) + + def post_ownership_settings( + self, + body: OwnershipSettingsRequest, + ) -> OwnershipSettingsResponse: + """Update ownership settings for the org. + + Update ownership settings for the org. + + :type body: OwnershipSettingsRequest + :rtype: OwnershipSettingsResponse + """ + kwargs: Dict[str, Any] = {} + kwargs["body"] = body + + return self._post_ownership_settings_endpoint.call_with_http_info(**kwargs) diff --git a/src/datadog_api_client/v2/model/ownership_confidence_level.py b/src/datadog_api_client/v2/model/ownership_confidence_level.py new file mode 100644 index 0000000000..d3e8d4b3b8 --- /dev/null +++ b/src/datadog_api_client/v2/model/ownership_confidence_level.py @@ -0,0 +1,41 @@ +# 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 datadog_api_client.model_utils import ( + ModelSimple, + cached_property, +) + +from typing import ClassVar + + +class OwnershipConfidenceLevel(ModelSimple): + """ + The ownership confidence level. + + :param value: Must be one of ["high", "medium", "low"]. + :type value: str + """ + + allowed_values = { + "high", + "medium", + "low", + } + HIGH: ClassVar["OwnershipConfidenceLevel"] + MEDIUM: ClassVar["OwnershipConfidenceLevel"] + LOW: ClassVar["OwnershipConfidenceLevel"] + + @cached_property + def openapi_types(_): + return { + "value": (str,), + } + + +OwnershipConfidenceLevel.HIGH = OwnershipConfidenceLevel("high") +OwnershipConfidenceLevel.MEDIUM = OwnershipConfidenceLevel("medium") +OwnershipConfidenceLevel.LOW = OwnershipConfidenceLevel("low") diff --git a/src/datadog_api_client/v2/model/ownership_settings_attributes.py b/src/datadog_api_client/v2/model/ownership_settings_attributes.py new file mode 100644 index 0000000000..148789465d --- /dev/null +++ b/src/datadog_api_client/v2/model/ownership_settings_attributes.py @@ -0,0 +1,52 @@ +# 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.ownership_confidence_level import OwnershipConfidenceLevel + + +class OwnershipSettingsAttributes(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.ownership_confidence_level import OwnershipConfidenceLevel + + return { + "auto_tag": (bool,), + "confidence_level": (OwnershipConfidenceLevel,), + "version": (int,), + } + + attribute_map = { + "auto_tag": "auto_tag", + "confidence_level": "confidence_level", + "version": "version", + } + + def __init__(self_, auto_tag: bool, confidence_level: OwnershipConfidenceLevel, version: int, **kwargs): + """ + The attributes of the ownership settings response. + + :param auto_tag: Whether automatic ownership tagging is enabled. + :type auto_tag: bool + + :param confidence_level: The ownership confidence level. + :type confidence_level: OwnershipConfidenceLevel + + :param version: The current version of the ownership settings. + :type version: int + """ + super().__init__(kwargs) + + self_.auto_tag = auto_tag + self_.confidence_level = confidence_level + self_.version = version diff --git a/src/datadog_api_client/v2/model/ownership_settings_data.py b/src/datadog_api_client/v2/model/ownership_settings_data.py new file mode 100644 index 0000000000..5908128804 --- /dev/null +++ b/src/datadog_api_client/v2/model/ownership_settings_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.ownership_settings_attributes import OwnershipSettingsAttributes + from datadog_api_client.v2.model.ownership_settings_type import OwnershipSettingsType + + +class OwnershipSettingsData(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.ownership_settings_attributes import OwnershipSettingsAttributes + from datadog_api_client.v2.model.ownership_settings_type import OwnershipSettingsType + + return { + "attributes": (OwnershipSettingsAttributes,), + "id": (str,), + "type": (OwnershipSettingsType,), + } + + attribute_map = { + "attributes": "attributes", + "id": "id", + "type": "type", + } + + def __init__(self_, attributes: OwnershipSettingsAttributes, id: str, type: OwnershipSettingsType, **kwargs): + """ + The data wrapper for an ownership settings response. + + :param attributes: The attributes of the ownership settings response. + :type attributes: OwnershipSettingsAttributes + + :param id: The identifier of the ownership settings resource. + :type id: str + + :param type: The type of the ownership settings resource. The value should always be ``ownership_settings``. + :type type: OwnershipSettingsType + """ + super().__init__(kwargs) + + self_.attributes = attributes + self_.id = id + self_.type = type diff --git a/src/datadog_api_client/v2/model/ownership_settings_request.py b/src/datadog_api_client/v2/model/ownership_settings_request.py new file mode 100644 index 0000000000..4825d5fee6 --- /dev/null +++ b/src/datadog_api_client/v2/model/ownership_settings_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.ownership_settings_request_data import OwnershipSettingsRequestData + + +class OwnershipSettingsRequest(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.ownership_settings_request_data import OwnershipSettingsRequestData + + return { + "data": (OwnershipSettingsRequestData,), + } + + attribute_map = { + "data": "data", + } + + def __init__(self_, data: OwnershipSettingsRequestData, **kwargs): + """ + The request body for updating ownership settings. + + :param data: The data wrapper for an ownership settings request. + :type data: OwnershipSettingsRequestData + """ + super().__init__(kwargs) + + self_.data = data diff --git a/src/datadog_api_client/v2/model/ownership_settings_request_attributes.py b/src/datadog_api_client/v2/model/ownership_settings_request_attributes.py new file mode 100644 index 0000000000..b2d6ca85fc --- /dev/null +++ b/src/datadog_api_client/v2/model/ownership_settings_request_attributes.py @@ -0,0 +1,46 @@ +# 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.ownership_confidence_level import OwnershipConfidenceLevel + + +class OwnershipSettingsRequestAttributes(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.ownership_confidence_level import OwnershipConfidenceLevel + + return { + "auto_tag": (bool,), + "confidence_level": (OwnershipConfidenceLevel,), + } + + attribute_map = { + "auto_tag": "auto_tag", + "confidence_level": "confidence_level", + } + + def __init__(self_, auto_tag: bool, confidence_level: OwnershipConfidenceLevel, **kwargs): + """ + The attributes of an ownership settings request. + + :param auto_tag: Whether automatic ownership tagging is enabled. + :type auto_tag: bool + + :param confidence_level: The ownership confidence level. + :type confidence_level: OwnershipConfidenceLevel + """ + super().__init__(kwargs) + + self_.auto_tag = auto_tag + self_.confidence_level = confidence_level diff --git a/src/datadog_api_client/v2/model/ownership_settings_request_data.py b/src/datadog_api_client/v2/model/ownership_settings_request_data.py new file mode 100644 index 0000000000..8cead7f97f --- /dev/null +++ b/src/datadog_api_client/v2/model/ownership_settings_request_data.py @@ -0,0 +1,48 @@ +# 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.ownership_settings_request_attributes import OwnershipSettingsRequestAttributes + from datadog_api_client.v2.model.ownership_settings_type import OwnershipSettingsType + + +class OwnershipSettingsRequestData(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.ownership_settings_request_attributes import OwnershipSettingsRequestAttributes + from datadog_api_client.v2.model.ownership_settings_type import OwnershipSettingsType + + return { + "attributes": (OwnershipSettingsRequestAttributes,), + "type": (OwnershipSettingsType,), + } + + attribute_map = { + "attributes": "attributes", + "type": "type", + } + + def __init__(self_, attributes: OwnershipSettingsRequestAttributes, type: OwnershipSettingsType, **kwargs): + """ + The data wrapper for an ownership settings request. + + :param attributes: The attributes of an ownership settings request. + :type attributes: OwnershipSettingsRequestAttributes + + :param type: The type of the ownership settings resource. The value should always be ``ownership_settings``. + :type type: OwnershipSettingsType + """ + super().__init__(kwargs) + + self_.attributes = attributes + self_.type = type diff --git a/src/datadog_api_client/v2/model/ownership_settings_response.py b/src/datadog_api_client/v2/model/ownership_settings_response.py new file mode 100644 index 0000000000..5252411396 --- /dev/null +++ b/src/datadog_api_client/v2/model/ownership_settings_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.ownership_settings_data import OwnershipSettingsData + + +class OwnershipSettingsResponse(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.ownership_settings_data import OwnershipSettingsData + + return { + "data": (OwnershipSettingsData,), + } + + attribute_map = { + "data": "data", + } + + def __init__(self_, data: OwnershipSettingsData, **kwargs): + """ + The response returned when retrieving or updating ownership settings. + + :param data: The data wrapper for an ownership settings response. + :type data: OwnershipSettingsData + """ + super().__init__(kwargs) + + self_.data = data diff --git a/src/datadog_api_client/v2/model/ownership_settings_type.py b/src/datadog_api_client/v2/model/ownership_settings_type.py new file mode 100644 index 0000000000..5b8abbeaf3 --- /dev/null +++ b/src/datadog_api_client/v2/model/ownership_settings_type.py @@ -0,0 +1,35 @@ +# 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 datadog_api_client.model_utils import ( + ModelSimple, + cached_property, +) + +from typing import ClassVar + + +class OwnershipSettingsType(ModelSimple): + """ + The type of the ownership settings resource. The value should always be `ownership_settings`. + + :param value: If omitted defaults to "ownership_settings". Must be one of ["ownership_settings"]. + :type value: str + """ + + allowed_values = { + "ownership_settings", + } + OWNERSHIP_SETTINGS: ClassVar["OwnershipSettingsType"] + + @cached_property + def openapi_types(_): + return { + "value": (str,), + } + + +OwnershipSettingsType.OWNERSHIP_SETTINGS = OwnershipSettingsType("ownership_settings") diff --git a/src/datadog_api_client/v2/model/ownership_untagged_findings_attributes.py b/src/datadog_api_client/v2/model/ownership_untagged_findings_attributes.py new file mode 100644 index 0000000000..837f1e8191 --- /dev/null +++ b/src/datadog_api_client/v2/model/ownership_untagged_findings_attributes.py @@ -0,0 +1,51 @@ +# 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 datadog_api_client.model_utils import ( + ModelNormal, + cached_property, +) + + +class OwnershipUntaggedFindingsAttributes(ModelNormal): + @cached_property + def openapi_types(_): + return { + "high_confidence": (int,), + "low_confidence": (int,), + "medium_confidence": (int,), + "total": (int,), + } + + attribute_map = { + "high_confidence": "high_confidence", + "low_confidence": "low_confidence", + "medium_confidence": "medium_confidence", + "total": "total", + } + + def __init__(self_, high_confidence: int, low_confidence: int, medium_confidence: int, total: int, **kwargs): + """ + The counts of findings without a team tag by ownership confidence. + + :param high_confidence: The number of high confidence findings without a team tag. + :type high_confidence: int + + :param low_confidence: The number of low confidence findings without a team tag. + :type low_confidence: int + + :param medium_confidence: The number of medium confidence findings without a team tag. + :type medium_confidence: int + + :param total: The total number of findings without a team tag. + :type total: int + """ + super().__init__(kwargs) + + self_.high_confidence = high_confidence + self_.low_confidence = low_confidence + self_.medium_confidence = medium_confidence + self_.total = total diff --git a/src/datadog_api_client/v2/model/ownership_untagged_findings_data.py b/src/datadog_api_client/v2/model/ownership_untagged_findings_data.py new file mode 100644 index 0000000000..06835d646a --- /dev/null +++ b/src/datadog_api_client/v2/model/ownership_untagged_findings_data.py @@ -0,0 +1,58 @@ +# 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.ownership_untagged_findings_attributes import OwnershipUntaggedFindingsAttributes + from datadog_api_client.v2.model.ownership_untagged_findings_type import OwnershipUntaggedFindingsType + + +class OwnershipUntaggedFindingsData(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.ownership_untagged_findings_attributes import ( + OwnershipUntaggedFindingsAttributes, + ) + from datadog_api_client.v2.model.ownership_untagged_findings_type import OwnershipUntaggedFindingsType + + return { + "attributes": (OwnershipUntaggedFindingsAttributes,), + "id": (str,), + "type": (OwnershipUntaggedFindingsType,), + } + + attribute_map = { + "attributes": "attributes", + "id": "id", + "type": "type", + } + + def __init__( + self_, attributes: OwnershipUntaggedFindingsAttributes, id: str, type: OwnershipUntaggedFindingsType, **kwargs + ): + """ + The data wrapper for an ownership untagged findings response. + + :param attributes: The counts of findings without a team tag by ownership confidence. + :type attributes: OwnershipUntaggedFindingsAttributes + + :param id: The identifier of the ownership untagged findings resource. + :type id: str + + :param type: The type of the ownership untagged findings resource. The value should always be ``ownership_untagged_findings``. + :type type: OwnershipUntaggedFindingsType + """ + super().__init__(kwargs) + + self_.attributes = attributes + self_.id = id + self_.type = type diff --git a/src/datadog_api_client/v2/model/ownership_untagged_findings_response.py b/src/datadog_api_client/v2/model/ownership_untagged_findings_response.py new file mode 100644 index 0000000000..616fbafe96 --- /dev/null +++ b/src/datadog_api_client/v2/model/ownership_untagged_findings_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.ownership_untagged_findings_data import OwnershipUntaggedFindingsData + + +class OwnershipUntaggedFindingsResponse(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.ownership_untagged_findings_data import OwnershipUntaggedFindingsData + + return { + "data": (OwnershipUntaggedFindingsData,), + } + + attribute_map = { + "data": "data", + } + + def __init__(self_, data: OwnershipUntaggedFindingsData, **kwargs): + """ + The response returned when counting findings without a team tag by ownership confidence. + + :param data: The data wrapper for an ownership untagged findings response. + :type data: OwnershipUntaggedFindingsData + """ + super().__init__(kwargs) + + self_.data = data diff --git a/src/datadog_api_client/v2/model/ownership_untagged_findings_type.py b/src/datadog_api_client/v2/model/ownership_untagged_findings_type.py new file mode 100644 index 0000000000..e19a05eea0 --- /dev/null +++ b/src/datadog_api_client/v2/model/ownership_untagged_findings_type.py @@ -0,0 +1,35 @@ +# 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 datadog_api_client.model_utils import ( + ModelSimple, + cached_property, +) + +from typing import ClassVar + + +class OwnershipUntaggedFindingsType(ModelSimple): + """ + The type of the ownership untagged findings resource. The value should always be `ownership_untagged_findings`. + + :param value: If omitted defaults to "ownership_untagged_findings". Must be one of ["ownership_untagged_findings"]. + :type value: str + """ + + allowed_values = { + "ownership_untagged_findings", + } + OWNERSHIP_UNTAGGED_FINDINGS: ClassVar["OwnershipUntaggedFindingsType"] + + @cached_property + def openapi_types(_): + return { + "value": (str,), + } + + +OwnershipUntaggedFindingsType.OWNERSHIP_UNTAGGED_FINDINGS = OwnershipUntaggedFindingsType("ownership_untagged_findings") diff --git a/src/datadog_api_client/v2/models/__init__.py b/src/datadog_api_client/v2/models/__init__.py index eef2bea108..6a5be67096 100644 --- a/src/datadog_api_client/v2/models/__init__.py +++ b/src/datadog_api_client/v2/models/__init__.py @@ -6332,6 +6332,7 @@ from datadog_api_client.v2.model.output_schema_parameters import OutputSchemaParameters from datadog_api_client.v2.model.output_schema_parameters_type import OutputSchemaParametersType from datadog_api_client.v2.model.overwrite_allocations_request import OverwriteAllocationsRequest +from datadog_api_client.v2.model.ownership_confidence_level import OwnershipConfidenceLevel from datadog_api_client.v2.model.ownership_evidence_attributes import OwnershipEvidenceAttributes from datadog_api_client.v2.model.ownership_evidence_data import OwnershipEvidenceData from datadog_api_client.v2.model.ownership_evidence_response import OwnershipEvidenceResponse @@ -6364,6 +6365,17 @@ from datadog_api_client.v2.model.ownership_inference_type import OwnershipInferenceType from datadog_api_client.v2.model.ownership_inferences_type import OwnershipInferencesType from datadog_api_client.v2.model.ownership_owner_type import OwnershipOwnerType +from datadog_api_client.v2.model.ownership_settings_attributes import OwnershipSettingsAttributes +from datadog_api_client.v2.model.ownership_settings_data import OwnershipSettingsData +from datadog_api_client.v2.model.ownership_settings_request import OwnershipSettingsRequest +from datadog_api_client.v2.model.ownership_settings_request_attributes import OwnershipSettingsRequestAttributes +from datadog_api_client.v2.model.ownership_settings_request_data import OwnershipSettingsRequestData +from datadog_api_client.v2.model.ownership_settings_response import OwnershipSettingsResponse +from datadog_api_client.v2.model.ownership_settings_type import OwnershipSettingsType +from datadog_api_client.v2.model.ownership_untagged_findings_attributes import OwnershipUntaggedFindingsAttributes +from datadog_api_client.v2.model.ownership_untagged_findings_data import OwnershipUntaggedFindingsData +from datadog_api_client.v2.model.ownership_untagged_findings_response import OwnershipUntaggedFindingsResponse +from datadog_api_client.v2.model.ownership_untagged_findings_type import OwnershipUntaggedFindingsType from datadog_api_client.v2.model.page_annotations_attributes import PageAnnotationsAttributes from datadog_api_client.v2.model.page_annotations_data import PageAnnotationsData from datadog_api_client.v2.model.page_annotations_response import PageAnnotationsResponse @@ -14433,6 +14445,7 @@ "OutputSchemaParameters", "OutputSchemaParametersType", "OverwriteAllocationsRequest", + "OwnershipConfidenceLevel", "OwnershipEvidenceAttributes", "OwnershipEvidenceData", "OwnershipEvidenceResponse", @@ -14465,6 +14478,17 @@ "OwnershipInferenceType", "OwnershipInferencesType", "OwnershipOwnerType", + "OwnershipSettingsAttributes", + "OwnershipSettingsData", + "OwnershipSettingsRequest", + "OwnershipSettingsRequestAttributes", + "OwnershipSettingsRequestData", + "OwnershipSettingsResponse", + "OwnershipSettingsType", + "OwnershipUntaggedFindingsAttributes", + "OwnershipUntaggedFindingsData", + "OwnershipUntaggedFindingsResponse", + "OwnershipUntaggedFindingsType", "PageAnnotationsAttributes", "PageAnnotationsData", "PageAnnotationsResponse", diff --git a/tests/v2/features/csm_ownership.feature b/tests/v2/features/csm_ownership.feature index 58498ca155..661e420b5c 100644 --- a/tests/v2/features/csm_ownership.feature +++ b/tests/v2/features/csm_ownership.feature @@ -12,6 +12,13 @@ Feature: CSM Ownership And a valid "appKeyAuth" key in the system And an instance of "CSMOwnership" API + @generated @skip @team:DataDog/k9-misconfigs + Scenario: Count untagged findings by ownership confidence returns "OK" response + Given operation "GetOwnershipUntaggedFindings" enabled + And new "GetOwnershipUntaggedFindings" request + When the request is sent + Then the response status is 200 OK + @generated @skip @team:DataDog/k9-misconfigs Scenario: Get an ownership inference by owner type returns "Bad Request" response Given operation "GetOwnershipInference" enabled @@ -39,6 +46,13 @@ Feature: CSM Ownership When the request is sent Then the response status is 200 OK + @generated @skip @team:DataDog/k9-misconfigs + Scenario: Get ownership settings for the org returns "OK" response + Given operation "GetOwnershipSettings" enabled + And new "GetOwnershipSettings" request + When the request is sent + Then the response status is 200 OK + @generated @skip @team:DataDog/k9-misconfigs Scenario: Get the evidence for an ownership inference returns "Bad Request" response Given operation "GetOwnershipEvidence" enabled @@ -163,3 +177,19 @@ Feature: CSM Ownership And body with value {"data": {"attributes": {"action": "confirm", "actor_handle": "user@example.com", "actor_type": "user", "corrected_owner_handle": "team-b", "corrected_owner_type": "team", "inference_checksum": "abc123", "reason": "Confirmed by team lead."}, "type": "ownership_feedback"}} When the request is sent Then the response status is 404 Not Found + + @generated @skip @team:DataDog/k9-misconfigs + Scenario: Update ownership settings for the org returns "Bad Request" response + Given operation "PostOwnershipSettings" enabled + And new "PostOwnershipSettings" request + And body with value {"data": {"attributes": {"auto_tag": true, "confidence_level": "high"}, "type": "ownership_settings"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/k9-misconfigs + Scenario: Update ownership settings for the org returns "OK" response + Given operation "PostOwnershipSettings" enabled + And new "PostOwnershipSettings" request + And body with value {"data": {"attributes": {"auto_tag": true, "confidence_level": "high"}, "type": "ownership_settings"}} + When the request is sent + Then the response status is 200 OK diff --git a/tests/v2/features/undo.json b/tests/v2/features/undo.json index e72767d8e0..10ae8ac71d 100644 --- a/tests/v2/features/undo.json +++ b/tests/v2/features/undo.json @@ -2049,6 +2049,24 @@ "type": "safe" } }, + "GetOwnershipSettings": { + "tag": "CSM Ownership", + "undo": { + "type": "safe" + } + }, + "PostOwnershipSettings": { + "tag": "CSM Ownership", + "undo": { + "type": "idempotent" + } + }, + "GetOwnershipUntaggedFindings": { + "tag": "CSM Ownership", + "undo": { + "type": "safe" + } + }, "ListOwnershipInferences": { "tag": "CSM Ownership", "undo": {