diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index e694506b53cd..3359e9a3754a 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -23518,6 +23518,8 @@ components: $ref: "#/components/schemas/Enabled" name: $ref: "#/components/schemas/RuleName" + routing: + $ref: "#/components/schemas/NotificationRuleRouting" selectors: $ref: "#/components/schemas/Selectors" targets: @@ -59051,6 +59053,76 @@ components: - targets - version type: object + NotificationRulePreviewNotificationStatus: + description: The notification status for the given rule type. `SUCCESS` means a matching event was found and the notification was sent successfully. `DEFAULT` means no matching event was found and a default placeholder notification was sent instead. `ERROR` means an error occurred while sending the notification. + enum: + - SUCCESS + - DEFAULT + - ERROR + example: SUCCESS + type: string + x-enum-varnames: + - SUCCESS + - DEFAULT + - ERROR + NotificationRulePreviewResponse: + description: Response from the notification preview request. + properties: + data: + $ref: "#/components/schemas/NotificationRulePreviewResponseData" + required: + - data + type: object + NotificationRulePreviewResponseAttributes: + description: Attributes of the notification preview response. + properties: + preview_results: + $ref: "#/components/schemas/NotificationRulePreviewResults" + required: + - preview_results + type: object + NotificationRulePreviewResponseData: + description: The notification preview response data. + properties: + attributes: + $ref: "#/components/schemas/NotificationRulePreviewResponseAttributes" + id: + description: The ID of the notification preview response. + example: rka-loa-zwu + type: string + type: + $ref: "#/components/schemas/NotificationRulePreviewResponseType" + required: + - type + - attributes + type: object + NotificationRulePreviewResponseType: + description: The type of the notification preview response. + enum: + - notification_preview_response + example: notification_preview_response + type: string + x-enum-varnames: + - NOTIFICATION_PREVIEW_RESPONSE + NotificationRulePreviewResult: + description: The preview result for a single rule type. + properties: + notification_status: + $ref: "#/components/schemas/NotificationRulePreviewNotificationStatus" + rule_type: + $ref: "#/components/schemas/RuleTypesItems" + required: + - rule_type + - notification_status + type: object + NotificationRulePreviewResults: + description: List of preview results for each rule type matched by the notification rule. + example: + - notification_status: DEFAULT + rule_type: log_detection + items: + $ref: "#/components/schemas/NotificationRulePreviewResult" + type: array NotificationRuleQuery: description: The query is composed of one or several key:value pairs, which can be used to filter security issues on tags and attributes. example: (source:production_service OR env:prod) @@ -59061,6 +59133,22 @@ components: data: $ref: "#/components/schemas/NotificationRule" type: object + NotificationRuleRouting: + description: Routing configuration for the notification rule. + properties: + mode: + $ref: "#/components/schemas/NotificationRuleRoutingMode" + required: + - mode + type: object + NotificationRuleRoutingMode: + description: The routing mode for the notification rule. `manual` sends notifications to the configured targets. + enum: + - manual + example: manual + type: string + x-enum-varnames: + - MANUAL NotificationRulesListResponse: description: The list of notification rules. properties: @@ -68865,6 +68953,8 @@ components: $ref: "#/components/schemas/Enabled" name: $ref: "#/components/schemas/RuleName" + routing: + $ref: "#/components/schemas/NotificationRuleRouting" selectors: $ref: "#/components/schemas/Selectors" targets: @@ -75175,6 +75265,7 @@ components: - iac_misconfiguration - sast_vulnerability - secret_vulnerability + example: log_detection type: string x-enum-varnames: - APPLICATION_SECURITY @@ -164024,6 +164115,73 @@ paths: x-unstable: |- **Note**: This endpoint is in preview and is subject to change. If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). + /api/v2/security_monitoring/configuration/notification_rules/send_notification_preview: + post: + description: Send a notification preview to test that a notification rule's targets are properly configured. + operationId: SendSecurityMonitoringNotificationPreview + requestBody: + content: + application/json: + examples: + default: + value: + data: + attributes: + enabled: true + name: Rule 1 + selectors: + query: env:prod + rule_types: + - log_detection + severities: + - critical + trigger_source: security_signals + targets: + - "@john.doe@email.com" + type: notification_rules + schema: + $ref: "#/components/schemas/CreateNotificationRuleParameters" + required: true + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + attributes: + preview_results: + - notification_status: DEFAULT + rule_type: log_detection + id: rka-loa-zwu + type: notification_preview_response + schema: + $ref: "#/components/schemas/NotificationRulePreviewResponse" + description: OK + "400": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Bad Request + "403": + $ref: "#/components/responses/NotAuthorizedResponse" + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - security_monitoring_notification_profiles_write + summary: Test a notification rule + tags: + - Security Monitoring + x-codegen-request-body-name: body + "x-permission": + operator: OR + permissions: + - security_monitoring_notification_profiles_write /api/v2/security_monitoring/configuration/security_filters: get: description: Get the list of configured security filters with their definitions. diff --git a/cassettes/features/v2/security_monitoring/Test-a-notification-rule-returns-OK-response.frozen b/cassettes/features/v2/security_monitoring/Test-a-notification-rule-returns-OK-response.frozen new file mode 100644 index 000000000000..dbdcb687dab6 --- /dev/null +++ b/cassettes/features/v2/security_monitoring/Test-a-notification-rule-returns-OK-response.frozen @@ -0,0 +1 @@ +2026-06-10T09:27:59.116Z \ No newline at end of file diff --git a/cassettes/features/v2/security_monitoring/Test-a-notification-rule-returns-OK-response.yml b/cassettes/features/v2/security_monitoring/Test-a-notification-rule-returns-OK-response.yml new file mode 100644 index 000000000000..20d833d63242 --- /dev/null +++ b/cassettes/features/v2/security_monitoring/Test-a-notification-rule-returns-OK-response.yml @@ -0,0 +1,24 @@ +http_interactions: +- recorded_at: Wed, 10 Jun 2026 09:27:59 GMT + request: + body: + encoding: UTF-8 + string: '{"data":{"attributes":{"enabled":true,"name":"Rule 1","selectors":{"query":"env:prod","rule_types":["log_detection"],"severities":["critical"],"trigger_source":"security_signals"},"targets":["@john.doe@email.com"]},"type":"notification_rules"}}' + headers: + Accept: + - application/json + Content-Type: + - application/json + method: POST + uri: https://api.datadoghq.com/api/v2/security_monitoring/configuration/notification_rules/send_notification_preview + response: + body: + encoding: UTF-8 + string: '{"data":{"id":"rka-loa-zwu","attributes":{"preview_results":[{"rule_type":"log_detection","notification_status":"DEFAULT"}]},"type":"notification_preview_response"}}' + headers: + Content-Type: + - application/json + status: + code: 200 + message: OK +recorded_with: VCR 6.0.0 diff --git a/examples/v2/security-monitoring/SendSecurityMonitoringNotificationPreview.rb b/examples/v2/security-monitoring/SendSecurityMonitoringNotificationPreview.rb new file mode 100644 index 000000000000..211e81fbb778 --- /dev/null +++ b/examples/v2/security-monitoring/SendSecurityMonitoringNotificationPreview.rb @@ -0,0 +1,28 @@ +# Test a notification rule returns "OK" response + +require "datadog_api_client" +api_instance = DatadogAPIClient::V2::SecurityMonitoringAPI.new + +body = DatadogAPIClient::V2::CreateNotificationRuleParameters.new({ + data: DatadogAPIClient::V2::CreateNotificationRuleParametersData.new({ + attributes: DatadogAPIClient::V2::CreateNotificationRuleParametersDataAttributes.new({ + enabled: true, + name: "Rule 1", + selectors: DatadogAPIClient::V2::Selectors.new({ + query: "env:prod", + rule_types: [ + DatadogAPIClient::V2::RuleTypesItems::LOG_DETECTION, + ], + severities: [ + DatadogAPIClient::V2::RuleSeverity::CRITICAL, + ], + trigger_source: DatadogAPIClient::V2::TriggerSource::SECURITY_SIGNALS, + }), + targets: [ + "@john.doe@email.com", + ], + }), + type: DatadogAPIClient::V2::NotificationRulesType::NOTIFICATION_RULES, + }), +}) +p api_instance.send_security_monitoring_notification_preview(body) diff --git a/features/scenarios_model_mapping.rb b/features/scenarios_model_mapping.rb index 9707cb7577db..409b0a04df1b 100644 --- a/features/scenarios_model_mapping.rb +++ b/features/scenarios_model_mapping.rb @@ -2212,6 +2212,9 @@ "v2.ValidateSecurityMonitoringIntegrationConfig" => { "integration_config_id" => "String", }, + "v2.SendSecurityMonitoringNotificationPreview" => { + "body" => "CreateNotificationRuleParameters", + }, "v2.CreateSecurityFilter" => { "body" => "SecurityFilterCreateRequest", }, diff --git a/features/v2/security_monitoring.feature b/features/v2/security_monitoring.feature index bae8918780ee..7e93f0077ade 100644 --- a/features/v2/security_monitoring.feature +++ b/features/v2/security_monitoring.feature @@ -759,7 +759,7 @@ Feature: Security Monitoring @generated @skip @team:DataDog/cloud-security-posture-management Scenario: Create a new signal-based notification rule returns "Bad Request" response Given new "CreateSignalNotificationRule" request - And body with value {"data": {"attributes": {"enabled": true, "name": "Rule 1", "selectors": {"query": "(source:production_service OR env:prod)", "rule_types": ["misconfiguration", "attack_path"], "severities": ["critical"], "trigger_source": "security_findings"}, "targets": ["@john.doe@email.com"], "time_aggregation": 86400}, "type": "notification_rules"}} + And body with value {"data": {"attributes": {"enabled": true, "name": "Rule 1", "routing": {"mode": "manual"}, "selectors": {"query": "(source:production_service OR env:prod)", "rule_types": ["misconfiguration", "attack_path"], "severities": ["critical"], "trigger_source": "security_findings"}, "targets": ["@john.doe@email.com"], "time_aggregation": 86400}, "type": "notification_rules"}} When the request is sent Then the response status is 400 Bad Request @@ -773,7 +773,7 @@ Feature: Security Monitoring @generated @skip @team:DataDog/cloud-security-posture-management Scenario: Create a new vulnerability-based notification rule returns "Bad Request" response Given new "CreateVulnerabilityNotificationRule" request - And body with value {"data": {"attributes": {"enabled": true, "name": "Rule 1", "selectors": {"query": "(source:production_service OR env:prod)", "rule_types": ["misconfiguration", "attack_path"], "severities": ["critical"], "trigger_source": "security_findings"}, "targets": ["@john.doe@email.com"], "time_aggregation": 86400}, "type": "notification_rules"}} + And body with value {"data": {"attributes": {"enabled": true, "name": "Rule 1", "routing": {"mode": "manual"}, "selectors": {"query": "(source:production_service OR env:prod)", "rule_types": ["misconfiguration", "attack_path"], "severities": ["critical"], "trigger_source": "security_findings"}, "targets": ["@john.doe@email.com"], "time_aggregation": 86400}, "type": "notification_rules"}} When the request is sent Then the response status is 400 Bad Request @@ -2470,7 +2470,7 @@ Feature: Security Monitoring Scenario: Patch a signal-based notification rule returns "The server cannot process the request because it contains invalid data." response Given new "PatchSignalNotificationRule" request And request contains "id" parameter from "REPLACE.ME" - And body with value {"data": {"attributes": {"enabled": true, "name": "Rule 1", "selectors": {"query": "(source:production_service OR env:prod)", "rule_types": ["misconfiguration", "attack_path"], "severities": ["critical"], "trigger_source": "security_findings"}, "targets": ["@john.doe@email.com"], "time_aggregation": 86400, "version": 1}, "id": "aaa-bbb-ccc", "type": "notification_rules"}} + And body with value {"data": {"attributes": {"enabled": true, "name": "Rule 1", "routing": {"mode": "manual"}, "selectors": {"query": "(source:production_service OR env:prod)", "rule_types": ["misconfiguration", "attack_path"], "severities": ["critical"], "trigger_source": "security_findings"}, "targets": ["@john.doe@email.com"], "time_aggregation": 86400, "version": 1}, "id": "aaa-bbb-ccc", "type": "notification_rules"}} When the request is sent Then the response status is 422 The server cannot process the request because it contains invalid data. @@ -2504,7 +2504,7 @@ Feature: Security Monitoring Scenario: Patch a vulnerability-based notification rule returns "The server cannot process the request because it contains invalid data." response Given new "PatchVulnerabilityNotificationRule" request And request contains "id" parameter from "REPLACE.ME" - And body with value {"data": {"attributes": {"enabled": true, "name": "Rule 1", "selectors": {"query": "(source:production_service OR env:prod)", "rule_types": ["misconfiguration", "attack_path"], "severities": ["critical"], "trigger_source": "security_findings"}, "targets": ["@john.doe@email.com"], "time_aggregation": 86400, "version": 1}, "id": "aaa-bbb-ccc", "type": "notification_rules"}} + And body with value {"data": {"attributes": {"enabled": true, "name": "Rule 1", "routing": {"mode": "manual"}, "selectors": {"query": "(source:production_service OR env:prod)", "rule_types": ["misconfiguration", "attack_path"], "severities": ["critical"], "trigger_source": "security_findings"}, "targets": ["@john.doe@email.com"], "time_aggregation": 86400, "version": 1}, "id": "aaa-bbb-ccc", "type": "notification_rules"}} When the request is sent Then the response status is 422 The server cannot process the request because it contains invalid data. @@ -2611,6 +2611,20 @@ Feature: Security Monitoring When the request is sent Then the response status is 200 OK + @generated @skip @team:DataDog/k9-cloud-siem + Scenario: Test a notification rule returns "Bad Request" response + Given new "SendSecurityMonitoringNotificationPreview" request + And body with value {"data": {"attributes": {"enabled": true, "name": "Rule 1", "routing": {"mode": "manual"}, "selectors": {"query": "(source:production_service OR env:prod)", "rule_types": ["misconfiguration", "attack_path"], "severities": ["critical"], "trigger_source": "security_findings"}, "targets": ["@john.doe@email.com"], "time_aggregation": 86400}, "type": "notification_rules"}} + When the request is sent + Then the response status is 400 Bad Request + + @team:DataDog/k9-cloud-siem + Scenario: Test a notification rule returns "OK" response + Given new "SendSecurityMonitoringNotificationPreview" request + And body with value {"data": {"attributes": {"enabled": true, "name": "Rule 1", "selectors": {"query": "env:prod", "rule_types": ["log_detection"], "severities": ["critical"], "trigger_source": "security_signals"}, "targets": ["@john.doe@email.com"]}, "type": "notification_rules"}} + When the request is sent + Then the response status is 200 OK + @skip @team:DataDog/k9-cloud-siem Scenario: Test a rule returns "Bad Request" response Given new "TestSecurityMonitoringRule" request diff --git a/features/v2/undo.json b/features/v2/undo.json index 811e650c25b9..72c8a80e0e0a 100644 --- a/features/v2/undo.json +++ b/features/v2/undo.json @@ -7025,6 +7025,12 @@ "type": "safe" } }, + "SendSecurityMonitoringNotificationPreview": { + "tag": "Security Monitoring", + "undo": { + "type": "safe" + } + }, "ListSecurityFilters": { "tag": "Security Monitoring", "undo": { diff --git a/lib/datadog_api_client/inflector.rb b/lib/datadog_api_client/inflector.rb index 93b0106d173c..9d517e4f078c 100644 --- a/lib/datadog_api_client/inflector.rb +++ b/lib/datadog_api_client/inflector.rb @@ -4655,7 +4655,15 @@ def overrides "v2.notification_channel_type" => "NotificationChannelType", "v2.notification_rule" => "NotificationRule", "v2.notification_rule_attributes" => "NotificationRuleAttributes", + "v2.notification_rule_preview_notification_status" => "NotificationRulePreviewNotificationStatus", + "v2.notification_rule_preview_response" => "NotificationRulePreviewResponse", + "v2.notification_rule_preview_response_attributes" => "NotificationRulePreviewResponseAttributes", + "v2.notification_rule_preview_response_data" => "NotificationRulePreviewResponseData", + "v2.notification_rule_preview_response_type" => "NotificationRulePreviewResponseType", + "v2.notification_rule_preview_result" => "NotificationRulePreviewResult", "v2.notification_rule_response" => "NotificationRuleResponse", + "v2.notification_rule_routing" => "NotificationRuleRouting", + "v2.notification_rule_routing_mode" => "NotificationRuleRoutingMode", "v2.notification_rules_list_response" => "NotificationRulesListResponse", "v2.notification_rules_type" => "NotificationRulesType", "v2.notion_api_key" => "NotionAPIKey", diff --git a/lib/datadog_api_client/v2/api/security_monitoring_api.rb b/lib/datadog_api_client/v2/api/security_monitoring_api.rb index 765c57639dc6..94b3626f3971 100644 --- a/lib/datadog_api_client/v2/api/security_monitoring_api.rb +++ b/lib/datadog_api_client/v2/api/security_monitoring_api.rb @@ -8746,6 +8746,73 @@ def search_security_monitoring_signals_with_pagination(opts = {}) end end + # Test a notification rule. + # + # @see #send_security_monitoring_notification_preview_with_http_info + def send_security_monitoring_notification_preview(body, opts = {}) + data, _status_code, _headers = send_security_monitoring_notification_preview_with_http_info(body, opts) + data + end + + # Test a notification rule. + # + # Send a notification preview to test that a notification rule's targets are properly configured. + # + # @param body [CreateNotificationRuleParameters] + # @param opts [Hash] the optional parameters + # @return [Array<(NotificationRulePreviewResponse, Integer, Hash)>] NotificationRulePreviewResponse data, response status code and response headers + def send_security_monitoring_notification_preview_with_http_info(body, opts = {}) + + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: SecurityMonitoringAPI.send_security_monitoring_notification_preview ...' + end + # verify the required parameter 'body' is set + if @api_client.config.client_side_validation && body.nil? + fail ArgumentError, "Missing the required parameter 'body' when calling SecurityMonitoringAPI.send_security_monitoring_notification_preview" + end + # resource path + local_var_path = '/api/v2/security_monitoring/configuration/notification_rules/send_notification_preview' + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + # HTTP header 'Content-Type' + header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] || @api_client.object_to_http_body(body) + + # return_type + return_type = opts[:debug_return_type] || 'NotificationRulePreviewResponse' + + # auth_names + auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth, :AuthZ] + + new_options = opts.merge( + :operation => :send_security_monitoring_notification_preview, + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type, + :api_version => "V2" + ) + + data, status_code, headers = @api_client.call_api(Net::HTTP::Post, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: SecurityMonitoringAPI#send_security_monitoring_notification_preview\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + # Test an existing rule. # # @see #test_existing_security_monitoring_rule_with_http_info diff --git a/lib/datadog_api_client/v2/models/create_notification_rule_parameters_data_attributes.rb b/lib/datadog_api_client/v2/models/create_notification_rule_parameters_data_attributes.rb index 2c532b40b073..87495be7cf29 100644 --- a/lib/datadog_api_client/v2/models/create_notification_rule_parameters_data_attributes.rb +++ b/lib/datadog_api_client/v2/models/create_notification_rule_parameters_data_attributes.rb @@ -27,6 +27,9 @@ class CreateNotificationRuleParametersDataAttributes # Name of the notification rule. attr_reader :name + # Routing configuration for the notification rule. + attr_accessor :routing + # Selectors are used to filter security issues for which notifications should be generated. # Users can specify rule severities, rule types, a query to filter security issues on tags and attributes, and the trigger source. # Only the trigger_source field is required. @@ -52,6 +55,7 @@ def self.attribute_map { :'enabled' => :'enabled', :'name' => :'name', + :'routing' => :'routing', :'selectors' => :'selectors', :'targets' => :'targets', :'time_aggregation' => :'time_aggregation' @@ -64,6 +68,7 @@ def self.openapi_types { :'enabled' => :'Boolean', :'name' => :'String', + :'routing' => :'NotificationRuleRouting', :'selectors' => :'Selectors', :'targets' => :'Array', :'time_aggregation' => :'Integer' @@ -96,6 +101,10 @@ def initialize(attributes = {}) self.name = attributes[:'name'] end + if attributes.key?(:'routing') + self.routing = attributes[:'routing'] + end + if attributes.key?(:'selectors') self.selectors = attributes[:'selectors'] end @@ -179,6 +188,7 @@ def ==(o) self.class == o.class && enabled == o.enabled && name == o.name && + routing == o.routing && selectors == o.selectors && targets == o.targets && time_aggregation == o.time_aggregation && @@ -189,7 +199,7 @@ def ==(o) # @return [Integer] Hash code # @!visibility private def hash - [enabled, name, selectors, targets, time_aggregation, additional_properties].hash + [enabled, name, routing, selectors, targets, time_aggregation, additional_properties].hash end end end diff --git a/lib/datadog_api_client/v2/models/notification_rule_preview_notification_status.rb b/lib/datadog_api_client/v2/models/notification_rule_preview_notification_status.rb new file mode 100644 index 000000000000..007dc55d455b --- /dev/null +++ b/lib/datadog_api_client/v2/models/notification_rule_preview_notification_status.rb @@ -0,0 +1,28 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # The notification status for the given rule type. `SUCCESS` means a matching event was found and the notification was sent successfully. `DEFAULT` means no matching event was found and a default placeholder notification was sent instead. `ERROR` means an error occurred while sending the notification. + class NotificationRulePreviewNotificationStatus + include BaseEnumModel + + SUCCESS = "SUCCESS".freeze + DEFAULT = "DEFAULT".freeze + ERROR = "ERROR".freeze + end +end diff --git a/lib/datadog_api_client/v2/models/notification_rule_preview_response.rb b/lib/datadog_api_client/v2/models/notification_rule_preview_response.rb new file mode 100644 index 000000000000..0812e2844b74 --- /dev/null +++ b/lib/datadog_api_client/v2/models/notification_rule_preview_response.rb @@ -0,0 +1,123 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # Response from the notification preview request. + class NotificationRulePreviewResponse + include BaseGenericModel + + # The notification preview response data. + attr_reader :data + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'data' => :'data' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'data' => :'NotificationRulePreviewResponseData' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::NotificationRulePreviewResponse` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'data') + self.data = attributes[:'data'] + end + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + # @!visibility private + def valid? + return false if @data.nil? + true + end + + # Custom attribute writer method with validation + # @param data [Object] Object to be assigned + # @!visibility private + def data=(data) + if data.nil? + fail ArgumentError, 'invalid value for "data", data cannot be nil.' + end + @data = data + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + data == o.data && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [data, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/notification_rule_preview_response_attributes.rb b/lib/datadog_api_client/v2/models/notification_rule_preview_response_attributes.rb new file mode 100644 index 000000000000..846e8297b168 --- /dev/null +++ b/lib/datadog_api_client/v2/models/notification_rule_preview_response_attributes.rb @@ -0,0 +1,125 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # Attributes of the notification preview response. + class NotificationRulePreviewResponseAttributes + include BaseGenericModel + + # List of preview results for each rule type matched by the notification rule. + attr_reader :preview_results + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'preview_results' => :'preview_results' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'preview_results' => :'Array' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::NotificationRulePreviewResponseAttributes` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'preview_results') + if (value = attributes[:'preview_results']).is_a?(Array) + self.preview_results = value + end + end + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + # @!visibility private + def valid? + return false if @preview_results.nil? + true + end + + # Custom attribute writer method with validation + # @param preview_results [Object] Object to be assigned + # @!visibility private + def preview_results=(preview_results) + if preview_results.nil? + fail ArgumentError, 'invalid value for "preview_results", preview_results cannot be nil.' + end + @preview_results = preview_results + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + preview_results == o.preview_results && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [preview_results, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/notification_rule_preview_response_data.rb b/lib/datadog_api_client/v2/models/notification_rule_preview_response_data.rb new file mode 100644 index 000000000000..b68d7e9b1369 --- /dev/null +++ b/lib/datadog_api_client/v2/models/notification_rule_preview_response_data.rb @@ -0,0 +1,154 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # The notification preview response data. + class NotificationRulePreviewResponseData + include BaseGenericModel + + # Attributes of the notification preview response. + attr_reader :attributes + + # The ID of the notification preview response. + attr_accessor :id + + # The type of the notification preview response. + attr_reader :type + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'attributes' => :'attributes', + :'id' => :'id', + :'type' => :'type' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'attributes' => :'NotificationRulePreviewResponseAttributes', + :'id' => :'String', + :'type' => :'NotificationRulePreviewResponseType' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::NotificationRulePreviewResponseData` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'attributes') + self.attributes = attributes[:'attributes'] + end + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + end + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + # @!visibility private + def valid? + return false if @attributes.nil? + return false if @type.nil? + true + end + + # Custom attribute writer method with validation + # @param attributes [Object] Object to be assigned + # @!visibility private + def attributes=(attributes) + if attributes.nil? + fail ArgumentError, 'invalid value for "attributes", attributes cannot be nil.' + end + @attributes = attributes + end + + # Custom attribute writer method with validation + # @param type [Object] Object to be assigned + # @!visibility private + def type=(type) + if type.nil? + fail ArgumentError, 'invalid value for "type", type cannot be nil.' + end + @type = type + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + attributes == o.attributes && + id == o.id && + type == o.type && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [attributes, id, type, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/notification_rule_preview_response_type.rb b/lib/datadog_api_client/v2/models/notification_rule_preview_response_type.rb new file mode 100644 index 000000000000..4e386e466f16 --- /dev/null +++ b/lib/datadog_api_client/v2/models/notification_rule_preview_response_type.rb @@ -0,0 +1,26 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # The type of the notification preview response. + class NotificationRulePreviewResponseType + include BaseEnumModel + + NOTIFICATION_PREVIEW_RESPONSE = "notification_preview_response".freeze + end +end diff --git a/lib/datadog_api_client/v2/models/notification_rule_preview_result.rb b/lib/datadog_api_client/v2/models/notification_rule_preview_result.rb new file mode 100644 index 000000000000..34f18b9bd4d0 --- /dev/null +++ b/lib/datadog_api_client/v2/models/notification_rule_preview_result.rb @@ -0,0 +1,149 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # The preview result for a single rule type. + class NotificationRulePreviewResult + include BaseGenericModel + + # The notification status for the given rule type. `SUCCESS` means a matching event was found and the notification was sent successfully. `DEFAULT` means no matching event was found and a default placeholder notification was sent instead. `ERROR` means an error occurred while sending the notification. + attr_reader :notification_status + + # Security rule type which can be used in security rules. + # Signal-based notification rules can filter signals based on rule types application_security, log_detection, + # workload_security, signal_correlation, cloud_configuration and infrastructure_configuration. + # Vulnerability-based notification rules can filter vulnerabilities based on rule types application_code_vulnerability, + # application_library_vulnerability, attack_path, container_image_vulnerability, identity_risk, misconfiguration, + # api_security, host_vulnerability, iac_misconfiguration, sast_vulnerability and secret_vulnerability. + attr_reader :rule_type + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'notification_status' => :'notification_status', + :'rule_type' => :'rule_type' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'notification_status' => :'NotificationRulePreviewNotificationStatus', + :'rule_type' => :'RuleTypesItems' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::NotificationRulePreviewResult` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'notification_status') + self.notification_status = attributes[:'notification_status'] + end + + if attributes.key?(:'rule_type') + self.rule_type = attributes[:'rule_type'] + end + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + # @!visibility private + def valid? + return false if @notification_status.nil? + return false if @rule_type.nil? + true + end + + # Custom attribute writer method with validation + # @param notification_status [Object] Object to be assigned + # @!visibility private + def notification_status=(notification_status) + if notification_status.nil? + fail ArgumentError, 'invalid value for "notification_status", notification_status cannot be nil.' + end + @notification_status = notification_status + end + + # Custom attribute writer method with validation + # @param rule_type [Object] Object to be assigned + # @!visibility private + def rule_type=(rule_type) + if rule_type.nil? + fail ArgumentError, 'invalid value for "rule_type", rule_type cannot be nil.' + end + @rule_type = rule_type + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + notification_status == o.notification_status && + rule_type == o.rule_type && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [notification_status, rule_type, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/notification_rule_routing.rb b/lib/datadog_api_client/v2/models/notification_rule_routing.rb new file mode 100644 index 000000000000..f45ca96bf37a --- /dev/null +++ b/lib/datadog_api_client/v2/models/notification_rule_routing.rb @@ -0,0 +1,123 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # Routing configuration for the notification rule. + class NotificationRuleRouting + include BaseGenericModel + + # The routing mode for the notification rule. `manual` sends notifications to the configured targets. + attr_reader :mode + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'mode' => :'mode' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'mode' => :'NotificationRuleRoutingMode' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::NotificationRuleRouting` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'mode') + self.mode = attributes[:'mode'] + end + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + # @!visibility private + def valid? + return false if @mode.nil? + true + end + + # Custom attribute writer method with validation + # @param mode [Object] Object to be assigned + # @!visibility private + def mode=(mode) + if mode.nil? + fail ArgumentError, 'invalid value for "mode", mode cannot be nil.' + end + @mode = mode + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + mode == o.mode && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [mode, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/notification_rule_routing_mode.rb b/lib/datadog_api_client/v2/models/notification_rule_routing_mode.rb new file mode 100644 index 000000000000..bb4d3a3d1bb6 --- /dev/null +++ b/lib/datadog_api_client/v2/models/notification_rule_routing_mode.rb @@ -0,0 +1,26 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # The routing mode for the notification rule. `manual` sends notifications to the configured targets. + class NotificationRuleRoutingMode + include BaseEnumModel + + MANUAL = "manual".freeze + end +end diff --git a/lib/datadog_api_client/v2/models/patch_notification_rule_parameters_data_attributes.rb b/lib/datadog_api_client/v2/models/patch_notification_rule_parameters_data_attributes.rb index 52208cdc5d69..32b16f959dac 100644 --- a/lib/datadog_api_client/v2/models/patch_notification_rule_parameters_data_attributes.rb +++ b/lib/datadog_api_client/v2/models/patch_notification_rule_parameters_data_attributes.rb @@ -27,6 +27,9 @@ class PatchNotificationRuleParametersDataAttributes # Name of the notification rule. attr_accessor :name + # Routing configuration for the notification rule. + attr_accessor :routing + # Selectors are used to filter security issues for which notifications should be generated. # Users can specify rule severities, rule types, a query to filter security issues on tags and attributes, and the trigger source. # Only the trigger_source field is required. @@ -55,6 +58,7 @@ def self.attribute_map { :'enabled' => :'enabled', :'name' => :'name', + :'routing' => :'routing', :'selectors' => :'selectors', :'targets' => :'targets', :'time_aggregation' => :'time_aggregation', @@ -68,6 +72,7 @@ def self.openapi_types { :'enabled' => :'Boolean', :'name' => :'String', + :'routing' => :'NotificationRuleRouting', :'selectors' => :'Selectors', :'targets' => :'Array', :'time_aggregation' => :'Integer', @@ -101,6 +106,10 @@ def initialize(attributes = {}) self.name = attributes[:'name'] end + if attributes.key?(:'routing') + self.routing = attributes[:'routing'] + end + if attributes.key?(:'selectors') self.selectors = attributes[:'selectors'] end @@ -148,6 +157,7 @@ def ==(o) self.class == o.class && enabled == o.enabled && name == o.name && + routing == o.routing && selectors == o.selectors && targets == o.targets && time_aggregation == o.time_aggregation && @@ -159,7 +169,7 @@ def ==(o) # @return [Integer] Hash code # @!visibility private def hash - [enabled, name, selectors, targets, time_aggregation, version, additional_properties].hash + [enabled, name, routing, selectors, targets, time_aggregation, version, additional_properties].hash end end end