diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 7052372666..74bf0b3861 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -29120,6 +29120,92 @@ components: user_defined_fields: $ref: '#/components/schemas/RelationshipToIncidentUserDefinedFields' type: object + IncidentRuleAttributesRequest: + properties: + name: + description: The name of the rule + example: High Severity Rule + type: string + required: + - name + type: object + IncidentRuleAttributesResponse: + properties: + createdAt: + description: When the rule was created + example: '2026-01-13T17:15:53.208340Z' + format: date-time + type: string + modifiedAt: + description: When the rule was last modified + example: '2026-01-13T17:15:53.208340Z' + format: date-time + type: string + name: + description: The name of the rule + example: High Severity Rule + type: string + required: + - name + - createdAt + - modifiedAt + type: object + IncidentRuleDataRequest: + properties: + attributes: + $ref: '#/components/schemas/IncidentRuleAttributesRequest' + type: + $ref: '#/components/schemas/IncidentRuleType' + required: + - type + - attributes + type: object + IncidentRuleDataResponse: + properties: + attributes: + $ref: '#/components/schemas/IncidentRuleAttributesResponse' + id: + description: The ID of the rule + example: 612e0c88-9137-4bd2-8de4-9356867d4c6a + type: string + type: + $ref: '#/components/schemas/IncidentRuleType' + required: + - id + - type + - attributes + type: object + IncidentRuleRequest: + properties: + data: + $ref: '#/components/schemas/IncidentRuleDataRequest' + required: + - data + type: object + IncidentRuleResponse: + properties: + data: + $ref: '#/components/schemas/IncidentRuleDataResponse' + required: + - data + type: object + IncidentRuleType: + description: Incident rule resource type + enum: + - incident_rule + example: incident_rule + type: string + x-enum-varnames: + - INCIDENT_RULE + IncidentRulesResponse: + properties: + data: + items: + $ref: '#/components/schemas/IncidentRuleDataResponse' + type: array + required: + - data + type: object IncidentSearchResponse: description: Response with incidents and facets. properties: @@ -75865,6 +75951,178 @@ paths: - incident_notification_settings_write x-unstable: '**Note**: This endpoint is in Preview. + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + /api/v2/incidents/config/rules: + get: + description: Retrieve a list of all incident rules for the organization. + operationId: ListIncidentConfigRules + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/IncidentRulesResponse' + description: OK + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Bad Request + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: List incident rules + tags: + - Incidents + x-unstable: '**Note**: This endpoint is in public beta and is subject to change. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + post: + description: Create a new incident rule for the organization. + operationId: CreateIncidentConfigRule + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/IncidentRuleRequest' + required: true + responses: + '201': + content: + application/json: + schema: + $ref: '#/components/schemas/IncidentRuleResponse' + description: Created + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Bad Request + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: Create incident rule + tags: + - Incidents + x-unstable: '**Note**: This endpoint is in public beta and is subject to change. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + /api/v2/incidents/config/rules/{rule_id}: + delete: + description: Delete an incident rule. + operationId: DeleteIncidentConfigRule + parameters: + - description: The ID of the incident rule + in: path + name: rule_id + required: true + schema: + example: 612e0c88-9137-4bd2-8de4-9356867d4c6a + type: string + responses: + '204': + description: No Content + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Bad Request + '404': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Not Found + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: Delete incident rule + tags: + - Incidents + x-unstable: '**Note**: This endpoint is in public beta and is subject to change. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + get: + description: Retrieve details of a specific incident rule. + operationId: GetIncidentConfigRule + parameters: + - description: The ID of the incident rule + in: path + name: rule_id + required: true + schema: + example: 612e0c88-9137-4bd2-8de4-9356867d4c6a + type: string + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/IncidentRuleResponse' + description: OK + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Bad Request + '404': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Not Found + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: Get incident rule + tags: + - Incidents + x-unstable: '**Note**: This endpoint is in public beta and is subject to change. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + patch: + description: Update an existing incident rule. + operationId: UpdateIncidentConfigRule + parameters: + - description: The ID of the incident rule + in: path + name: rule_id + required: true + schema: + example: 612e0c88-9137-4bd2-8de4-9356867d4c6a + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/IncidentRuleRequest' + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/IncidentRuleResponse' + description: OK + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Bad Request + '404': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Not Found + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: Update incident rule + tags: + - Incidents + x-unstable: '**Note**: This endpoint is in public beta and is subject to change. + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' /api/v2/incidents/config/types: get: diff --git a/docs/datadog_api_client.v2.model.rst b/docs/datadog_api_client.v2.model.rst index 69abe69668..64f0c3e50c 100644 --- a/docs/datadog_api_client.v2.model.rst +++ b/docs/datadog_api_client.v2.model.rst @@ -12296,6 +12296,62 @@ datadog\_api\_client.v2.model.incident\_response\_relationships module :members: :show-inheritance: +datadog\_api\_client.v2.model.incident\_rule\_attributes\_request module +------------------------------------------------------------------------ + +.. automodule:: datadog_api_client.v2.model.incident_rule_attributes_request + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.incident\_rule\_attributes\_response module +------------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.incident_rule_attributes_response + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.incident\_rule\_data\_request module +------------------------------------------------------------------ + +.. automodule:: datadog_api_client.v2.model.incident_rule_data_request + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.incident\_rule\_data\_response module +------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.incident_rule_data_response + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.incident\_rule\_request module +------------------------------------------------------------ + +.. automodule:: datadog_api_client.v2.model.incident_rule_request + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.incident\_rule\_response module +------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.incident_rule_response + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.incident\_rule\_type module +--------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.incident_rule_type + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.incident\_rules\_response module +-------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.incident_rules_response + :members: + :show-inheritance: + datadog\_api\_client.v2.model.incident\_search\_response module --------------------------------------------------------------- diff --git a/examples/v2/incidents/CreateIncidentConfigRule.py b/examples/v2/incidents/CreateIncidentConfigRule.py new file mode 100644 index 0000000000..5a4be12e82 --- /dev/null +++ b/examples/v2/incidents/CreateIncidentConfigRule.py @@ -0,0 +1,27 @@ +""" +Create incident rule returns "Created" response +""" + +from datadog_api_client import ApiClient, Configuration +from datadog_api_client.v2.api.incidents_api import IncidentsApi +from datadog_api_client.v2.model.incident_rule_attributes_request import IncidentRuleAttributesRequest +from datadog_api_client.v2.model.incident_rule_data_request import IncidentRuleDataRequest +from datadog_api_client.v2.model.incident_rule_request import IncidentRuleRequest +from datadog_api_client.v2.model.incident_rule_type import IncidentRuleType + +body = IncidentRuleRequest( + data=IncidentRuleDataRequest( + attributes=IncidentRuleAttributesRequest( + name="High Severity Rule", + ), + type=IncidentRuleType.INCIDENT_RULE, + ), +) + +configuration = Configuration() +configuration.unstable_operations["create_incident_config_rule"] = True +with ApiClient(configuration) as api_client: + api_instance = IncidentsApi(api_client) + response = api_instance.create_incident_config_rule(body=body) + + print(response) diff --git a/examples/v2/incidents/DeleteIncidentConfigRule.py b/examples/v2/incidents/DeleteIncidentConfigRule.py new file mode 100644 index 0000000000..764d773e81 --- /dev/null +++ b/examples/v2/incidents/DeleteIncidentConfigRule.py @@ -0,0 +1,14 @@ +""" +Delete incident rule returns "No Content" response +""" + +from datadog_api_client import ApiClient, Configuration +from datadog_api_client.v2.api.incidents_api import IncidentsApi + +configuration = Configuration() +configuration.unstable_operations["delete_incident_config_rule"] = True +with ApiClient(configuration) as api_client: + api_instance = IncidentsApi(api_client) + api_instance.delete_incident_config_rule( + rule_id="612e0c88-9137-4bd2-8de4-9356867d4c6a", + ) diff --git a/examples/v2/incidents/GetIncidentConfigRule.py b/examples/v2/incidents/GetIncidentConfigRule.py new file mode 100644 index 0000000000..7f94e21d3a --- /dev/null +++ b/examples/v2/incidents/GetIncidentConfigRule.py @@ -0,0 +1,16 @@ +""" +Get incident rule returns "OK" response +""" + +from datadog_api_client import ApiClient, Configuration +from datadog_api_client.v2.api.incidents_api import IncidentsApi + +configuration = Configuration() +configuration.unstable_operations["get_incident_config_rule"] = True +with ApiClient(configuration) as api_client: + api_instance = IncidentsApi(api_client) + response = api_instance.get_incident_config_rule( + rule_id="612e0c88-9137-4bd2-8de4-9356867d4c6a", + ) + + print(response) diff --git a/examples/v2/incidents/ListIncidentConfigRules.py b/examples/v2/incidents/ListIncidentConfigRules.py new file mode 100644 index 0000000000..c8a43e7734 --- /dev/null +++ b/examples/v2/incidents/ListIncidentConfigRules.py @@ -0,0 +1,14 @@ +""" +List incident rules returns "OK" response +""" + +from datadog_api_client import ApiClient, Configuration +from datadog_api_client.v2.api.incidents_api import IncidentsApi + +configuration = Configuration() +configuration.unstable_operations["list_incident_config_rules"] = True +with ApiClient(configuration) as api_client: + api_instance = IncidentsApi(api_client) + response = api_instance.list_incident_config_rules() + + print(response) diff --git a/examples/v2/incidents/UpdateIncidentConfigRule.py b/examples/v2/incidents/UpdateIncidentConfigRule.py new file mode 100644 index 0000000000..cba6f1bd60 --- /dev/null +++ b/examples/v2/incidents/UpdateIncidentConfigRule.py @@ -0,0 +1,27 @@ +""" +Update incident rule returns "OK" response +""" + +from datadog_api_client import ApiClient, Configuration +from datadog_api_client.v2.api.incidents_api import IncidentsApi +from datadog_api_client.v2.model.incident_rule_attributes_request import IncidentRuleAttributesRequest +from datadog_api_client.v2.model.incident_rule_data_request import IncidentRuleDataRequest +from datadog_api_client.v2.model.incident_rule_request import IncidentRuleRequest +from datadog_api_client.v2.model.incident_rule_type import IncidentRuleType + +body = IncidentRuleRequest( + data=IncidentRuleDataRequest( + attributes=IncidentRuleAttributesRequest( + name="High Severity Rule", + ), + type=IncidentRuleType.INCIDENT_RULE, + ), +) + +configuration = Configuration() +configuration.unstable_operations["update_incident_config_rule"] = True +with ApiClient(configuration) as api_client: + api_instance = IncidentsApi(api_client) + response = api_instance.update_incident_config_rule(rule_id="612e0c88-9137-4bd2-8de4-9356867d4c6a", body=body) + + print(response) diff --git a/src/datadog_api_client/configuration.py b/src/datadog_api_client/configuration.py index cf63f54a1c..8b90cc6e88 100644 --- a/src/datadog_api_client/configuration.py +++ b/src/datadog_api_client/configuration.py @@ -307,6 +307,7 @@ def __init__( "v2.create_global_incident_handle": False, "v2.create_incident": False, "v2.create_incident_attachment": False, + "v2.create_incident_config_rule": False, "v2.create_incident_integration": False, "v2.create_incident_notification_rule": False, "v2.create_incident_notification_template": False, @@ -316,6 +317,7 @@ def __init__( "v2.delete_global_incident_handle": False, "v2.delete_incident": False, "v2.delete_incident_attachment": False, + "v2.delete_incident_config_rule": False, "v2.delete_incident_integration": False, "v2.delete_incident_notification_rule": False, "v2.delete_incident_notification_template": False, @@ -323,6 +325,7 @@ def __init__( "v2.delete_incident_type": False, "v2.get_global_incident_settings": False, "v2.get_incident": False, + "v2.get_incident_config_rule": False, "v2.get_incident_integration": False, "v2.get_incident_notification_rule": False, "v2.get_incident_notification_template": False, @@ -330,6 +333,7 @@ def __init__( "v2.get_incident_type": False, "v2.list_global_incident_handles": False, "v2.list_incident_attachments": False, + "v2.list_incident_config_rules": False, "v2.list_incident_integrations": False, "v2.list_incident_notification_rules": False, "v2.list_incident_notification_templates": False, @@ -341,6 +345,7 @@ def __init__( "v2.update_global_incident_settings": False, "v2.update_incident": False, "v2.update_incident_attachment": False, + "v2.update_incident_config_rule": False, "v2.update_incident_integration": False, "v2.update_incident_notification_rule": False, "v2.update_incident_notification_template": False, diff --git a/src/datadog_api_client/v2/api/incidents_api.py b/src/datadog_api_client/v2/api/incidents_api.py index fc3297f913..db561b21d7 100644 --- a/src/datadog_api_client/v2/api/incidents_api.py +++ b/src/datadog_api_client/v2/api/incidents_api.py @@ -37,6 +37,9 @@ from datadog_api_client.v2.model.patch_incident_notification_template_request import ( PatchIncidentNotificationTemplateRequest, ) +from datadog_api_client.v2.model.incident_rules_response import IncidentRulesResponse +from datadog_api_client.v2.model.incident_rule_response import IncidentRuleResponse +from datadog_api_client.v2.model.incident_rule_request import IncidentRuleRequest from datadog_api_client.v2.model.incident_type_list_response import IncidentTypeListResponse from datadog_api_client.v2.model.incident_type_response import IncidentTypeResponse from datadog_api_client.v2.model.incident_type_create_request import IncidentTypeCreateRequest @@ -156,6 +159,26 @@ def __init__(self, api_client=None): api_client=api_client, ) + self._create_incident_config_rule_endpoint = _Endpoint( + settings={ + "response_type": (IncidentRuleResponse,), + "auth": ["apiKeyAuth", "appKeyAuth"], + "endpoint_path": "/api/v2/incidents/config/rules", + "operation_id": "create_incident_config_rule", + "http_method": "POST", + "version": "v2", + }, + params_map={ + "body": { + "required": True, + "openapi_types": (IncidentRuleRequest,), + "location": "body", + }, + }, + headers_map={"accept": ["application/json"], "content_type": ["application/json"]}, + api_client=api_client, + ) + self._create_incident_impact_endpoint = _Endpoint( settings={ "response_type": (IncidentImpactResponse,), @@ -394,6 +417,29 @@ def __init__(self, api_client=None): api_client=api_client, ) + self._delete_incident_config_rule_endpoint = _Endpoint( + settings={ + "response_type": None, + "auth": ["apiKeyAuth", "appKeyAuth"], + "endpoint_path": "/api/v2/incidents/config/rules/{rule_id}", + "operation_id": "delete_incident_config_rule", + "http_method": "DELETE", + "version": "v2", + }, + params_map={ + "rule_id": { + "required": True, + "openapi_types": (str,), + "attribute": "rule_id", + "location": "path", + }, + }, + headers_map={ + "accept": ["*/*"], + }, + api_client=api_client, + ) + self._delete_incident_impact_endpoint = _Endpoint( settings={ "response_type": None, @@ -605,6 +651,29 @@ def __init__(self, api_client=None): api_client=api_client, ) + self._get_incident_config_rule_endpoint = _Endpoint( + settings={ + "response_type": (IncidentRuleResponse,), + "auth": ["apiKeyAuth", "appKeyAuth"], + "endpoint_path": "/api/v2/incidents/config/rules/{rule_id}", + "operation_id": "get_incident_config_rule", + "http_method": "GET", + "version": "v2", + }, + params_map={ + "rule_id": { + "required": True, + "openapi_types": (str,), + "attribute": "rule_id", + "location": "path", + }, + }, + headers_map={ + "accept": ["application/json"], + }, + api_client=api_client, + ) + self._get_incident_integration_endpoint = _Endpoint( settings={ "response_type": (IncidentIntegrationMetadataResponse,), @@ -797,6 +866,22 @@ def __init__(self, api_client=None): api_client=api_client, ) + self._list_incident_config_rules_endpoint = _Endpoint( + settings={ + "response_type": (IncidentRulesResponse,), + "auth": ["apiKeyAuth", "appKeyAuth"], + "endpoint_path": "/api/v2/incidents/config/rules", + "operation_id": "list_incident_config_rules", + "http_method": "GET", + "version": "v2", + }, + params_map={}, + headers_map={ + "accept": ["application/json"], + }, + api_client=api_client, + ) + self._list_incident_impacts_endpoint = _Endpoint( settings={ "response_type": (IncidentImpactsResponse,), @@ -1133,6 +1218,32 @@ def __init__(self, api_client=None): api_client=api_client, ) + self._update_incident_config_rule_endpoint = _Endpoint( + settings={ + "response_type": (IncidentRuleResponse,), + "auth": ["apiKeyAuth", "appKeyAuth"], + "endpoint_path": "/api/v2/incidents/config/rules/{rule_id}", + "operation_id": "update_incident_config_rule", + "http_method": "PATCH", + "version": "v2", + }, + params_map={ + "rule_id": { + "required": True, + "openapi_types": (str,), + "attribute": "rule_id", + "location": "path", + }, + "body": { + "required": True, + "openapi_types": (IncidentRuleRequest,), + "location": "body", + }, + }, + headers_map={"accept": ["application/json"], "content_type": ["application/json"]}, + api_client=api_client, + ) + self._update_incident_integration_endpoint = _Endpoint( settings={ "response_type": (IncidentIntegrationMetadataResponse,), @@ -1353,6 +1464,22 @@ def create_incident_attachment( return self._create_incident_attachment_endpoint.call_with_http_info(**kwargs) + def create_incident_config_rule( + self, + body: IncidentRuleRequest, + ) -> IncidentRuleResponse: + """Create incident rule. + + Create a new incident rule for the organization. + + :type body: IncidentRuleRequest + :rtype: IncidentRuleResponse + """ + kwargs: Dict[str, Any] = {} + kwargs["body"] = body + + return self._create_incident_config_rule_endpoint.call_with_http_info(**kwargs) + def create_incident_impact( self, incident_id: str, @@ -1545,6 +1672,23 @@ def delete_incident_attachment( return self._delete_incident_attachment_endpoint.call_with_http_info(**kwargs) + def delete_incident_config_rule( + self, + rule_id: str, + ) -> None: + """Delete incident rule. + + Delete an incident rule. + + :param rule_id: The ID of the incident rule + :type rule_id: str + :rtype: None + """ + kwargs: Dict[str, Any] = {} + kwargs["rule_id"] = rule_id + + return self._delete_incident_config_rule_endpoint.call_with_http_info(**kwargs) + def delete_incident_impact( self, incident_id: str, @@ -1712,6 +1856,23 @@ def get_incident( return self._get_incident_endpoint.call_with_http_info(**kwargs) + def get_incident_config_rule( + self, + rule_id: str, + ) -> IncidentRuleResponse: + """Get incident rule. + + Retrieve details of a specific incident rule. + + :param rule_id: The ID of the incident rule + :type rule_id: str + :rtype: IncidentRuleResponse + """ + kwargs: Dict[str, Any] = {} + kwargs["rule_id"] = rule_id + + return self._get_incident_config_rule_endpoint.call_with_http_info(**kwargs) + def get_incident_integration( self, incident_id: str, @@ -1870,6 +2031,18 @@ def list_incident_attachments( return self._list_incident_attachments_endpoint.call_with_http_info(**kwargs) + def list_incident_config_rules( + self, + ) -> IncidentRulesResponse: + """List incident rules. + + Retrieve a list of all incident rules for the organization. + + :rtype: IncidentRulesResponse + """ + kwargs: Dict[str, Any] = {} + return self._list_incident_config_rules_endpoint.call_with_http_info(**kwargs) + def list_incident_impacts( self, incident_id: str, @@ -2264,6 +2437,27 @@ def update_incident_attachment( return self._update_incident_attachment_endpoint.call_with_http_info(**kwargs) + def update_incident_config_rule( + self, + rule_id: str, + body: IncidentRuleRequest, + ) -> IncidentRuleResponse: + """Update incident rule. + + Update an existing incident rule. + + :param rule_id: The ID of the incident rule + :type rule_id: str + :type body: IncidentRuleRequest + :rtype: IncidentRuleResponse + """ + kwargs: Dict[str, Any] = {} + kwargs["rule_id"] = rule_id + + kwargs["body"] = body + + return self._update_incident_config_rule_endpoint.call_with_http_info(**kwargs) + def update_incident_integration( self, incident_id: str, diff --git a/src/datadog_api_client/v2/model/incident_rule_attributes_request.py b/src/datadog_api_client/v2/model/incident_rule_attributes_request.py new file mode 100644 index 0000000000..cb15e39af0 --- /dev/null +++ b/src/datadog_api_client/v2/model/incident_rule_attributes_request.py @@ -0,0 +1,33 @@ +# 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 IncidentRuleAttributesRequest(ModelNormal): + @cached_property + def openapi_types(_): + return { + "name": (str,), + } + + attribute_map = { + "name": "name", + } + + def __init__(self_, name: str, **kwargs): + """ + + + :param name: The name of the rule + :type name: str + """ + super().__init__(kwargs) + + self_.name = name diff --git a/src/datadog_api_client/v2/model/incident_rule_attributes_response.py b/src/datadog_api_client/v2/model/incident_rule_attributes_response.py new file mode 100644 index 0000000000..4afd499008 --- /dev/null +++ b/src/datadog_api_client/v2/model/incident_rule_attributes_response.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 datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + datetime, +) + + +class IncidentRuleAttributesResponse(ModelNormal): + @cached_property + def openapi_types(_): + return { + "created_at": (datetime,), + "modified_at": (datetime,), + "name": (str,), + } + + attribute_map = { + "created_at": "createdAt", + "modified_at": "modifiedAt", + "name": "name", + } + + def __init__(self_, created_at: datetime, modified_at: datetime, name: str, **kwargs): + """ + + + :param created_at: When the rule was created + :type created_at: datetime + + :param modified_at: When the rule was last modified + :type modified_at: datetime + + :param name: The name of the rule + :type name: str + """ + super().__init__(kwargs) + + self_.created_at = created_at + self_.modified_at = modified_at + self_.name = name diff --git a/src/datadog_api_client/v2/model/incident_rule_data_request.py b/src/datadog_api_client/v2/model/incident_rule_data_request.py new file mode 100644 index 0000000000..d1a51d0783 --- /dev/null +++ b/src/datadog_api_client/v2/model/incident_rule_data_request.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.incident_rule_attributes_request import IncidentRuleAttributesRequest + from datadog_api_client.v2.model.incident_rule_type import IncidentRuleType + + +class IncidentRuleDataRequest(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.incident_rule_attributes_request import IncidentRuleAttributesRequest + from datadog_api_client.v2.model.incident_rule_type import IncidentRuleType + + return { + "attributes": (IncidentRuleAttributesRequest,), + "type": (IncidentRuleType,), + } + + attribute_map = { + "attributes": "attributes", + "type": "type", + } + + def __init__(self_, attributes: IncidentRuleAttributesRequest, type: IncidentRuleType, **kwargs): + """ + + + :param attributes: + :type attributes: IncidentRuleAttributesRequest + + :param type: Incident rule resource type + :type type: IncidentRuleType + """ + super().__init__(kwargs) + + self_.attributes = attributes + self_.type = type diff --git a/src/datadog_api_client/v2/model/incident_rule_data_response.py b/src/datadog_api_client/v2/model/incident_rule_data_response.py new file mode 100644 index 0000000000..94c48e7ebf --- /dev/null +++ b/src/datadog_api_client/v2/model/incident_rule_data_response.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.incident_rule_attributes_response import IncidentRuleAttributesResponse + from datadog_api_client.v2.model.incident_rule_type import IncidentRuleType + + +class IncidentRuleDataResponse(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.incident_rule_attributes_response import IncidentRuleAttributesResponse + from datadog_api_client.v2.model.incident_rule_type import IncidentRuleType + + return { + "attributes": (IncidentRuleAttributesResponse,), + "id": (str,), + "type": (IncidentRuleType,), + } + + attribute_map = { + "attributes": "attributes", + "id": "id", + "type": "type", + } + + def __init__(self_, attributes: IncidentRuleAttributesResponse, id: str, type: IncidentRuleType, **kwargs): + """ + + + :param attributes: + :type attributes: IncidentRuleAttributesResponse + + :param id: The ID of the rule + :type id: str + + :param type: Incident rule resource type + :type type: IncidentRuleType + """ + super().__init__(kwargs) + + self_.attributes = attributes + self_.id = id + self_.type = type diff --git a/src/datadog_api_client/v2/model/incident_rule_request.py b/src/datadog_api_client/v2/model/incident_rule_request.py new file mode 100644 index 0000000000..2c6f6bc55f --- /dev/null +++ b/src/datadog_api_client/v2/model/incident_rule_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.incident_rule_data_request import IncidentRuleDataRequest + + +class IncidentRuleRequest(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.incident_rule_data_request import IncidentRuleDataRequest + + return { + "data": (IncidentRuleDataRequest,), + } + + attribute_map = { + "data": "data", + } + + def __init__(self_, data: IncidentRuleDataRequest, **kwargs): + """ + + + :param data: + :type data: IncidentRuleDataRequest + """ + super().__init__(kwargs) + + self_.data = data diff --git a/src/datadog_api_client/v2/model/incident_rule_response.py b/src/datadog_api_client/v2/model/incident_rule_response.py new file mode 100644 index 0000000000..ab086d656e --- /dev/null +++ b/src/datadog_api_client/v2/model/incident_rule_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.incident_rule_data_response import IncidentRuleDataResponse + + +class IncidentRuleResponse(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.incident_rule_data_response import IncidentRuleDataResponse + + return { + "data": (IncidentRuleDataResponse,), + } + + attribute_map = { + "data": "data", + } + + def __init__(self_, data: IncidentRuleDataResponse, **kwargs): + """ + + + :param data: + :type data: IncidentRuleDataResponse + """ + super().__init__(kwargs) + + self_.data = data diff --git a/src/datadog_api_client/v2/model/incident_rule_type.py b/src/datadog_api_client/v2/model/incident_rule_type.py new file mode 100644 index 0000000000..afff7d919a --- /dev/null +++ b/src/datadog_api_client/v2/model/incident_rule_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 IncidentRuleType(ModelSimple): + """ + Incident rule resource type + + :param value: If omitted defaults to "incident_rule". Must be one of ["incident_rule"]. + :type value: str + """ + + allowed_values = { + "incident_rule", + } + INCIDENT_RULE: ClassVar["IncidentRuleType"] + + @cached_property + def openapi_types(_): + return { + "value": (str,), + } + + +IncidentRuleType.INCIDENT_RULE = IncidentRuleType("incident_rule") diff --git a/src/datadog_api_client/v2/model/incident_rules_response.py b/src/datadog_api_client/v2/model/incident_rules_response.py new file mode 100644 index 0000000000..cf2134aa8a --- /dev/null +++ b/src/datadog_api_client/v2/model/incident_rules_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.incident_rule_data_response import IncidentRuleDataResponse + + +class IncidentRulesResponse(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.incident_rule_data_response import IncidentRuleDataResponse + + return { + "data": ([IncidentRuleDataResponse],), + } + + attribute_map = { + "data": "data", + } + + def __init__(self_, data: List[IncidentRuleDataResponse], **kwargs): + """ + + + :param data: + :type data: [IncidentRuleDataResponse] + """ + super().__init__(kwargs) + + self_.data = data diff --git a/src/datadog_api_client/v2/models/__init__.py b/src/datadog_api_client/v2/models/__init__.py index e413caa873..69ddbf7455 100644 --- a/src/datadog_api_client/v2/models/__init__.py +++ b/src/datadog_api_client/v2/models/__init__.py @@ -2374,6 +2374,14 @@ from datadog_api_client.v2.model.incident_response_meta import IncidentResponseMeta from datadog_api_client.v2.model.incident_response_meta_pagination import IncidentResponseMetaPagination from datadog_api_client.v2.model.incident_response_relationships import IncidentResponseRelationships +from datadog_api_client.v2.model.incident_rule_attributes_request import IncidentRuleAttributesRequest +from datadog_api_client.v2.model.incident_rule_attributes_response import IncidentRuleAttributesResponse +from datadog_api_client.v2.model.incident_rule_data_request import IncidentRuleDataRequest +from datadog_api_client.v2.model.incident_rule_data_response import IncidentRuleDataResponse +from datadog_api_client.v2.model.incident_rule_request import IncidentRuleRequest +from datadog_api_client.v2.model.incident_rule_response import IncidentRuleResponse +from datadog_api_client.v2.model.incident_rule_type import IncidentRuleType +from datadog_api_client.v2.model.incident_rules_response import IncidentRulesResponse from datadog_api_client.v2.model.incident_search_response import IncidentSearchResponse from datadog_api_client.v2.model.incident_search_response_attributes import IncidentSearchResponseAttributes from datadog_api_client.v2.model.incident_search_response_data import IncidentSearchResponseData @@ -7551,6 +7559,14 @@ "IncidentResponseMeta", "IncidentResponseMetaPagination", "IncidentResponseRelationships", + "IncidentRuleAttributesRequest", + "IncidentRuleAttributesResponse", + "IncidentRuleDataRequest", + "IncidentRuleDataResponse", + "IncidentRuleRequest", + "IncidentRuleResponse", + "IncidentRuleType", + "IncidentRulesResponse", "IncidentSearchResponse", "IncidentSearchResponseAttributes", "IncidentSearchResponseData", diff --git a/tests/v2/features/incidents.feature b/tests/v2/features/incidents.feature index db70635584..64c59703a9 100644 --- a/tests/v2/features/incidents.feature +++ b/tests/v2/features/incidents.feature @@ -272,6 +272,22 @@ Feature: Incidents When the request is sent Then the response status is 404 Not Found + @generated @skip @team:DataDog/incident-app + Scenario: Create incident rule returns "Bad Request" response + Given operation "CreateIncidentConfigRule" enabled + And new "CreateIncidentConfigRule" request + And body with value {"data": {"attributes": {"name": "High Severity Rule"}, "type": "incident_rule"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/incident-app + Scenario: Create incident rule returns "Created" response + Given operation "CreateIncidentConfigRule" enabled + And new "CreateIncidentConfigRule" request + And body with value {"data": {"attributes": {"name": "High Severity Rule"}, "type": "incident_rule"}} + When the request is sent + Then the response status is 201 Created + @generated @skip @team:DataDog/incident-app Scenario: Create postmortem attachment returns "Bad Request" response Given operation "CreateIncidentPostmortemAttachment" enabled @@ -537,6 +553,30 @@ Feature: Incidents When the request is sent Then the response status is 204 No Content + @generated @skip @team:DataDog/incident-app + Scenario: Delete incident rule returns "Bad Request" response + Given operation "DeleteIncidentConfigRule" enabled + And new "DeleteIncidentConfigRule" request + And request contains "rule_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/incident-app + Scenario: Delete incident rule returns "No Content" response + Given operation "DeleteIncidentConfigRule" enabled + And new "DeleteIncidentConfigRule" request + And request contains "rule_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 204 No Content + + @generated @skip @team:DataDog/incident-app + Scenario: Delete incident rule returns "Not Found" response + Given operation "DeleteIncidentConfigRule" enabled + And new "DeleteIncidentConfigRule" request + And request contains "rule_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + @generated @skip @team:DataDog/incident-app Scenario: Get a list of an incident's integration metadata returns "Bad Request" response Given operation "ListIncidentIntegrations" enabled @@ -756,6 +796,30 @@ Feature: Incidents And the response "data" has field "attributes" And the response "data" has field "relationships" + @generated @skip @team:DataDog/incident-app + Scenario: Get incident rule returns "Bad Request" response + Given operation "GetIncidentConfigRule" enabled + And new "GetIncidentConfigRule" request + And request contains "rule_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/incident-app + Scenario: Get incident rule returns "Not Found" response + Given operation "GetIncidentConfigRule" enabled + And new "GetIncidentConfigRule" request + And request contains "rule_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/incident-app + Scenario: Get incident rule returns "OK" response + Given operation "GetIncidentConfigRule" enabled + And new "GetIncidentConfigRule" request + And request contains "rule_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 200 OK + @generated @skip @team:Datadog/incident-app Scenario: Get incident todo details returns "Bad Request" response Given operation "GetIncidentTodo" enabled @@ -940,6 +1004,20 @@ Feature: Incidents Then the response status is 200 OK And the response "data" has length 0 + @generated @skip @team:DataDog/incident-app + Scenario: List incident rules returns "Bad Request" response + Given operation "ListIncidentConfigRules" enabled + And new "ListIncidentConfigRules" request + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/incident-app + Scenario: List incident rules returns "OK" response + Given operation "ListIncidentConfigRules" enabled + And new "ListIncidentConfigRules" request + When the request is sent + Then the response status is 200 OK + @team:DataDog/incident-app Scenario: Remove commander from an incident returns "OK" response Given operation "UpdateIncident" enabled @@ -1270,3 +1348,30 @@ Feature: Incidents And the response "data.id" has the same value as "notification_template.data.id" And the response "data.attributes.name" has the same value as "unique" And the response "data.attributes.category" is equal to "update" + + @generated @skip @team:DataDog/incident-app + Scenario: Update incident rule returns "Bad Request" response + Given operation "UpdateIncidentConfigRule" enabled + And new "UpdateIncidentConfigRule" request + And request contains "rule_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"name": "High Severity Rule"}, "type": "incident_rule"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/incident-app + Scenario: Update incident rule returns "Not Found" response + Given operation "UpdateIncidentConfigRule" enabled + And new "UpdateIncidentConfigRule" request + And request contains "rule_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"name": "High Severity Rule"}, "type": "incident_rule"}} + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/incident-app + Scenario: Update incident rule returns "OK" response + Given operation "UpdateIncidentConfigRule" enabled + And new "UpdateIncidentConfigRule" request + And request contains "rule_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"name": "High Severity Rule"}, "type": "incident_rule"}} + 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 5a347bddf1..bae2754c7e 100644 --- a/tests/v2/features/undo.json +++ b/tests/v2/features/undo.json @@ -1714,6 +1714,43 @@ "type": "idempotent" } }, + "ListIncidentConfigRules": { + "tag": "Incidents", + "undo": { + "type": "safe" + } + }, + "CreateIncidentConfigRule": { + "tag": "Incidents", + "undo": { + "operationId": "DeleteIncidentConfigRule", + "parameters": [ + { + "name": "rule_id", + "source": "" + } + ], + "type": "unsafe" + } + }, + "DeleteIncidentConfigRule": { + "tag": "Incidents", + "undo": { + "type": "idempotent" + } + }, + "GetIncidentConfigRule": { + "tag": "Incidents", + "undo": { + "type": "safe" + } + }, + "UpdateIncidentConfigRule": { + "tag": "Incidents", + "undo": { + "type": "idempotent" + } + }, "ListIncidentTypes": { "tag": "Incidents", "undo": {