diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index d8f50ea93052..06d25d8d70b2 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -100798,6 +100798,208 @@ components: required: - type type: object + SeverityModifierRuleAction: + description: |- + The action to take when a severity modifier rule matches a finding. This is a discriminated union on `type`: `set` assigns a fixed severity, while `shift` moves the severity up or down by one rank. + + A severity modifier rule's `rule.query` must not filter on `@severity` or on the `@severity_details.user_adjusted.*` namespace; use `@severity_details.adjusted.value` to filter on the Datadog-adjusted severity instead. + discriminator: + mapping: + set: "#/components/schemas/SeverityModifierRuleSetAction" + shift: "#/components/schemas/SeverityModifierRuleShiftAction" + propertyName: type + oneOf: + - $ref: "#/components/schemas/SeverityModifierRuleSetAction" + - $ref: "#/components/schemas/SeverityModifierRuleShiftAction" + SeverityModifierRuleAttributesCreate: + description: Attributes for creating or updating a severity modifier rule. + properties: + action: + $ref: "#/components/schemas/SeverityModifierRuleAction" + enabled: + description: Whether the severity modifier rule is enabled. + example: true + type: boolean + name: + description: The name of the severity modifier rule. + example: "Downgrade misconfigurations in dev" + maxLength: 255 + minLength: 1 + type: string + rule: + $ref: "#/components/schemas/AutomationRuleScope" + required: + - name + - rule + - action + type: object + SeverityModifierRuleAttributesResponse: + description: Attributes of a severity modifier rule as returned by the API. + properties: + action: + $ref: "#/components/schemas/SeverityModifierRuleAction" + created_at: + description: The Unix timestamp in milliseconds when the rule was created. + example: 1722439510282 + format: int64 + type: integer + created_by: + $ref: "#/components/schemas/AutomationRuleCreatedBy" + enabled: + description: Whether the severity modifier rule is enabled. + example: true + type: boolean + modified_at: + description: The Unix timestamp in milliseconds when the rule was last modified. + example: 1722439510282 + format: int64 + type: integer + modified_by: + $ref: "#/components/schemas/AutomationRuleModifiedBy" + name: + description: The name of the severity modifier rule. + example: "Downgrade misconfigurations in dev" + maxLength: 255 + minLength: 1 + type: string + rule: + $ref: "#/components/schemas/AutomationRuleScope" + required: + - name + - enabled + - rule + - action + - created_at + - created_by + - modified_at + - modified_by + type: object + SeverityModifierRuleCreateRequest: + description: The body of a severity modifier rule create request. + properties: + data: + $ref: "#/components/schemas/SeverityModifierRuleDataCreate" + required: + - data + type: object + SeverityModifierRuleDataCreate: + description: The data object for a severity modifier rule create or update request. + properties: + attributes: + $ref: "#/components/schemas/SeverityModifierRuleAttributesCreate" + type: + $ref: "#/components/schemas/SeverityModifierRuleType" + required: + - type + - attributes + type: object + SeverityModifierRuleDataResponse: + description: The data object for a severity modifier rule as returned by the API. + properties: + attributes: + $ref: "#/components/schemas/SeverityModifierRuleAttributesResponse" + id: + description: The ID of the severity modifier rule. + example: "00000000-0000-0000-0000-000000000000" + format: uuid + type: string + type: + $ref: "#/components/schemas/SeverityModifierRuleType" + required: + - id + - type + - attributes + type: object + SeverityModifierRuleResponse: + description: A single severity modifier rule response. + properties: + data: + $ref: "#/components/schemas/SeverityModifierRuleDataResponse" + required: + - data + type: object + SeverityModifierRuleSetAction: + description: Sets matched findings to a fixed severity. + properties: + description: + description: An optional free-form explanation for the severity change. + example: "Lower severity for dev environment noise" + maxLength: 20000 + type: string + severity: + $ref: "#/components/schemas/SeverityModifierSeverity" + type: + $ref: "#/components/schemas/SeverityModifierRuleSetActionType" + required: + - type + - severity + type: object + SeverityModifierRuleSetActionType: + description: The type of a severity modifier rule action that sets a fixed severity. + enum: + - set + example: set + type: string + x-enum-varnames: + - SET + SeverityModifierRuleShiftAction: + description: Shifts matched findings up or down by one severity rank. + properties: + description: + description: An optional free-form explanation for the severity change. + example: "Lower severity for dev environment noise" + maxLength: 20000 + type: string + severity_delta: + $ref: "#/components/schemas/SeverityModifierSeverityDelta" + type: + $ref: "#/components/schemas/SeverityModifierRuleShiftActionType" + required: + - type + - severity_delta + type: object + SeverityModifierRuleShiftActionType: + description: The type of a severity modifier rule action that shifts the severity by one rank. + enum: + - shift + example: shift + type: string + x-enum-varnames: + - SHIFT + SeverityModifierRuleType: + description: The JSON:API type for severity modifier rules. + enum: + - severity_modifier_rules + example: severity_modifier_rules + type: string + x-enum-varnames: + - SEVERITY_MODIFIER_RULES + SeverityModifierSeverity: + description: The severity to assign to matched findings. `info_none` is not supported for the `iac_misconfiguration`, `runtime_code_vulnerability`, `secret`, or `static_code_vulnerability` finding types. + enum: + - info_none + - low + - medium + - high + - critical + example: low + type: string + x-enum-varnames: + - INFO_NONE + - LOW + - MEDIUM + - HIGH + - CRITICAL + SeverityModifierSeverityDelta: + description: The direction in which to shift the severity of matched findings by one rank. + enum: + - up_one + - down_one + example: up_one + type: string + x-enum-varnames: + - UP_ONE + - DOWN_ONE SharedDashboardGlobalTime: additionalProperties: {} description: Default time range configuration for the shared dashboard. @@ -185952,6 +186154,196 @@ 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/findings/automation/severity_modifier_rules: + post: + description: Create a new severity modifier rule for the current organization. + operationId: CreateSecurityFindingsAutomationSeverityModifierRule + requestBody: + content: + application/json: + examples: + default: + value: + data: + attributes: + action: + description: "Lower severity for dev environment noise" + severity: low + type: set + enabled: true + name: "Downgrade misconfigurations in dev" + rule: + finding_types: + - misconfiguration + query: "env:dev" + type: severity_modifier_rules + schema: + $ref: "#/components/schemas/SeverityModifierRuleCreateRequest" + required: true + responses: + "201": + content: + application/json: + examples: + default: + value: + data: + attributes: + action: + description: "Lower severity for dev environment noise" + severity: low + type: set + created_at: 1722439510282 + created_by: + id: "00000000-0000-0000-0000-000000000000" + name: "Jane Doe" + type: user + enabled: true + modified_at: 1722439510282 + modified_by: + id: "00000000-0000-0000-0000-000000000000" + name: "Jane Doe" + type: user + name: "Downgrade misconfigurations in dev" + rule: + finding_types: + - misconfiguration + query: "env:dev" + id: "00000000-0000-0000-0000-000000000000" + type: severity_modifier_rules + schema: + $ref: "#/components/schemas/SeverityModifierRuleResponse" + description: Successfully created the severity modifier rule + "400": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Bad Request + "403": + $ref: "#/components/responses/ForbiddenResponse" + "422": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Unprocessable Entity + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: + - apiKeyAuth: [] + appKeyAuth: [] + summary: Create a severity modifier rule + tags: + - Security Monitoring + x-codegen-request-body-name: body + x-permission: + operator: OR + permissions: + - security_pipelines_write + 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/findings/automation/severity_modifier_rules/{rule_id}: + delete: + description: Delete an existing severity modifier rule by ID. + operationId: DeleteSecurityFindingsAutomationSeverityModifierRule + parameters: + - description: The ID of the severity modifier rule. + in: path + name: rule_id + required: true + schema: + example: "00000000-0000-0000-0000-000000000000" + format: uuid + type: string + responses: + "204": + description: "Rule successfully deleted." + "403": + $ref: "#/components/responses/ForbiddenResponse" + "404": + $ref: "#/components/responses/NotFoundResponse" + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: + - apiKeyAuth: [] + appKeyAuth: [] + summary: Delete a severity modifier rule + tags: + - Security Monitoring + x-permission: + operator: OR + permissions: + - security_pipelines_write + 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/). + get: + description: Get the details of a severity modifier rule by ID. + operationId: GetSecurityFindingsAutomationSeverityModifierRule + parameters: + - description: The ID of the severity modifier rule. + in: path + name: rule_id + required: true + schema: + example: "00000000-0000-0000-0000-000000000000" + format: uuid + type: string + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + attributes: + action: + description: "Lower severity for dev environment noise" + severity: low + type: set + created_at: 1722439510282 + created_by: + id: "00000000-0000-0000-0000-000000000000" + name: "Jane Doe" + type: user + enabled: true + modified_at: 1722439510282 + modified_by: + id: "00000000-0000-0000-0000-000000000000" + name: "Jane Doe" + type: user + name: "Downgrade misconfigurations in dev" + rule: + finding_types: + - misconfiguration + query: "env:dev" + id: "00000000-0000-0000-0000-000000000000" + type: severity_modifier_rules + schema: + $ref: "#/components/schemas/SeverityModifierRuleResponse" + description: Successfully retrieved the severity modifier rule + "403": + $ref: "#/components/responses/ForbiddenResponse" + "404": + $ref: "#/components/responses/NotFoundResponse" + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: + - apiKeyAuth: [] + appKeyAuth: [] + summary: Get a severity modifier rule + tags: + - Security Monitoring + x-permission: + operator: OR + permissions: + - security_pipelines_read + 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/findings/automation/ticket_creation_rules: get: description: Get all ticket creation rules for the current organization. diff --git a/cassettes/features/v2/security_monitoring/Delete-a-severity-modifier-rule-returns-Rule-successfully-deleted-response.frozen b/cassettes/features/v2/security_monitoring/Delete-a-severity-modifier-rule-returns-Rule-successfully-deleted-response.frozen new file mode 100644 index 000000000000..5812a38a0479 --- /dev/null +++ b/cassettes/features/v2/security_monitoring/Delete-a-severity-modifier-rule-returns-Rule-successfully-deleted-response.frozen @@ -0,0 +1 @@ +2026-08-03T09:17:25.445Z \ No newline at end of file diff --git a/cassettes/features/v2/security_monitoring/Delete-a-severity-modifier-rule-returns-Rule-successfully-deleted-response.yml b/cassettes/features/v2/security_monitoring/Delete-a-severity-modifier-rule-returns-Rule-successfully-deleted-response.yml new file mode 100644 index 000000000000..676d018856b4 --- /dev/null +++ b/cassettes/features/v2/security_monitoring/Delete-a-severity-modifier-rule-returns-Rule-successfully-deleted-response.yml @@ -0,0 +1,61 @@ +http_interactions: +- recorded_at: Mon, 03 Aug 2026 09:17:25 GMT + request: + body: + encoding: UTF-8 + string: '{"data":{"attributes":{"action":{"severity":"low","type":"set"},"enabled":true,"name":"Test-Delete_a_severity_modifier_rule_returns_Rule_successfully_deleted_response-1785748645","rule":{"finding_types":["misconfiguration"],"query":"env:staging"}},"type":"severity_modifier_rules"}}' + headers: + Accept: + - application/json + Content-Type: + - application/json + method: POST + uri: https://api.datadoghq.com/api/v2/security/findings/automation/severity_modifier_rules + response: + body: + encoding: UTF-8 + string: '{"data":{"id":"ec796c54-ec53-4b2f-bb14-36d4b224f92c","type":"severity_modifier_rules","attributes":{"action":{"type":"set","severity":"low"},"created_at":1785748647705,"created_by":{"type":"user","id":"9919ec9b-ebc7-49ee-8dc8-03626e717cca","name":"CI + Account"},"enabled":true,"modified_at":1785748647705,"modified_by":{"type":"user","id":"9919ec9b-ebc7-49ee-8dc8-03626e717cca","name":"CI + Account"},"name":"Test-Delete_a_severity_modifier_rule_returns_Rule_successfully_deleted_response-1785748645","rule":{"finding_types":["misconfiguration"],"query":"env:staging"}}}}' + headers: + Content-Type: + - application/vnd.api+json + status: + code: 201 + message: Created +- recorded_at: Mon, 03 Aug 2026 09:17:25 GMT + request: + body: null + headers: + Accept: + - '*/*' + method: DELETE + uri: https://api.datadoghq.com/api/v2/security/findings/automation/severity_modifier_rules/ec796c54-ec53-4b2f-bb14-36d4b224f92c + response: + body: + encoding: UTF-8 + string: '' + headers: {} + status: + code: 204 + message: No Content +- recorded_at: Mon, 03 Aug 2026 09:17:25 GMT + request: + body: null + headers: + Accept: + - '*/*' + method: DELETE + uri: https://api.datadoghq.com/api/v2/security/findings/automation/severity_modifier_rules/ec796c54-ec53-4b2f-bb14-36d4b224f92c + response: + body: + encoding: UTF-8 + string: '{"errors":[{"status":"404","title":"Not Found","detail":"rule does + not exist"}]}' + headers: + Content-Type: + - application/vnd.api+json + status: + code: 404 + message: Not Found +recorded_with: VCR 6.0.0 diff --git a/cassettes/features/v2/security_monitoring/Get-a-severity-modifier-rule-returns-Successfully-retrieved-the-severity-modifier-rule-response.frozen b/cassettes/features/v2/security_monitoring/Get-a-severity-modifier-rule-returns-Successfully-retrieved-the-severity-modifier-rule-response.frozen new file mode 100644 index 000000000000..87000b7fb8d9 --- /dev/null +++ b/cassettes/features/v2/security_monitoring/Get-a-severity-modifier-rule-returns-Successfully-retrieved-the-severity-modifier-rule-response.frozen @@ -0,0 +1 @@ +2026-08-03T09:17:28.616Z \ No newline at end of file diff --git a/cassettes/features/v2/security_monitoring/Get-a-severity-modifier-rule-returns-Successfully-retrieved-the-severity-modifier-rule-response.yml b/cassettes/features/v2/security_monitoring/Get-a-severity-modifier-rule-returns-Successfully-retrieved-the-severity-modifier-rule-response.yml new file mode 100644 index 000000000000..e7c77c61e37b --- /dev/null +++ b/cassettes/features/v2/security_monitoring/Get-a-severity-modifier-rule-returns-Successfully-retrieved-the-severity-modifier-rule-response.yml @@ -0,0 +1,62 @@ +http_interactions: +- recorded_at: Mon, 03 Aug 2026 09:17:28 GMT + request: + body: + encoding: UTF-8 + string: '{"data":{"attributes":{"action":{"severity":"low","type":"set"},"enabled":true,"name":"Test-Get_a_severity_modifier_rule_returns_Successfully_retrieved_the_severity_modifier_rule_response-1785748648","rule":{"finding_types":["misconfiguration"],"query":"env:staging"}},"type":"severity_modifier_rules"}}' + headers: + Accept: + - application/json + Content-Type: + - application/json + method: POST + uri: https://api.datadoghq.com/api/v2/security/findings/automation/severity_modifier_rules + response: + body: + encoding: UTF-8 + string: '{"data":{"id":"fec045ba-40ba-42ef-a107-f7fba8717e11","type":"severity_modifier_rules","attributes":{"action":{"type":"set","severity":"low"},"created_at":1785748648838,"created_by":{"type":"user","id":"9919ec9b-ebc7-49ee-8dc8-03626e717cca","name":"CI + Account"},"enabled":true,"modified_at":1785748648838,"modified_by":{"type":"user","id":"9919ec9b-ebc7-49ee-8dc8-03626e717cca","name":"CI + Account"},"name":"Test-Get_a_severity_modifier_rule_returns_Successfully_retrieved_the_severity_modifier_rule_response-1785748648","rule":{"finding_types":["misconfiguration"],"query":"env:staging"}}}}' + headers: + Content-Type: + - application/vnd.api+json + status: + code: 201 + message: Created +- recorded_at: Mon, 03 Aug 2026 09:17:28 GMT + request: + body: null + headers: + Accept: + - application/json + method: GET + uri: https://api.datadoghq.com/api/v2/security/findings/automation/severity_modifier_rules/fec045ba-40ba-42ef-a107-f7fba8717e11 + response: + body: + encoding: UTF-8 + string: '{"data":{"id":"fec045ba-40ba-42ef-a107-f7fba8717e11","type":"severity_modifier_rules","attributes":{"action":{"type":"set","severity":"low"},"created_at":1785748648838,"created_by":{"type":"user","id":"9919ec9b-ebc7-49ee-8dc8-03626e717cca","name":"CI + Account"},"enabled":true,"modified_at":1785748648838,"modified_by":{"type":"user","id":"9919ec9b-ebc7-49ee-8dc8-03626e717cca","name":"CI + Account"},"name":"Test-Get_a_severity_modifier_rule_returns_Successfully_retrieved_the_severity_modifier_rule_response-1785748648","rule":{"finding_types":["misconfiguration"],"query":"env:staging"}}}}' + headers: + Content-Type: + - application/vnd.api+json + status: + code: 200 + message: OK +- recorded_at: Mon, 03 Aug 2026 09:17:28 GMT + request: + body: null + headers: + Accept: + - '*/*' + method: DELETE + uri: https://api.datadoghq.com/api/v2/security/findings/automation/severity_modifier_rules/fec045ba-40ba-42ef-a107-f7fba8717e11 + response: + body: + encoding: UTF-8 + string: '' + headers: {} + status: + code: 204 + message: No Content +recorded_with: VCR 6.0.0 diff --git a/examples/v2/security-monitoring/CreateSecurityFindingsAutomationSeverityModifierRule.rb b/examples/v2/security-monitoring/CreateSecurityFindingsAutomationSeverityModifierRule.rb new file mode 100644 index 000000000000..45bd66932191 --- /dev/null +++ b/examples/v2/security-monitoring/CreateSecurityFindingsAutomationSeverityModifierRule.rb @@ -0,0 +1,29 @@ +# Create a severity modifier rule returns "Successfully created the severity modifier rule" response + +require "datadog_api_client" +DatadogAPIClient.configure do |config| + config.unstable_operations["v2.create_security_findings_automation_severity_modifier_rule".to_sym] = true +end +api_instance = DatadogAPIClient::V2::SecurityMonitoringAPI.new + +body = DatadogAPIClient::V2::SeverityModifierRuleCreateRequest.new({ + data: DatadogAPIClient::V2::SeverityModifierRuleDataCreate.new({ + attributes: DatadogAPIClient::V2::SeverityModifierRuleAttributesCreate.new({ + action: DatadogAPIClient::V2::SeverityModifierRuleSetAction.new({ + description: "Lower severity for dev environment noise", + severity: DatadogAPIClient::V2::SeverityModifierSeverity::LOW, + type: DatadogAPIClient::V2::SeverityModifierRuleSetActionType::SET, + }), + enabled: true, + name: "Downgrade misconfigurations in dev", + rule: DatadogAPIClient::V2::AutomationRuleScope.new({ + finding_types: [ + DatadogAPIClient::V2::SecurityFindingType::MISCONFIGURATION, + ], + query: "env:prod team:platform", + }), + }), + type: DatadogAPIClient::V2::SeverityModifierRuleType::SEVERITY_MODIFIER_RULES, + }), +}) +p api_instance.create_security_findings_automation_severity_modifier_rule(body) diff --git a/examples/v2/security-monitoring/DeleteSecurityFindingsAutomationSeverityModifierRule.rb b/examples/v2/security-monitoring/DeleteSecurityFindingsAutomationSeverityModifierRule.rb new file mode 100644 index 000000000000..150d1d36499d --- /dev/null +++ b/examples/v2/security-monitoring/DeleteSecurityFindingsAutomationSeverityModifierRule.rb @@ -0,0 +1,11 @@ +# Delete a severity modifier rule returns "Rule successfully deleted." response + +require "datadog_api_client" +DatadogAPIClient.configure do |config| + config.unstable_operations["v2.delete_security_findings_automation_severity_modifier_rule".to_sym] = true +end +api_instance = DatadogAPIClient::V2::SecurityMonitoringAPI.new + +# there is a valid "valid_severity_modifier_rule" in the system +VALID_SEVERITY_MODIFIER_RULE_DATA_ID = ENV["VALID_SEVERITY_MODIFIER_RULE_DATA_ID"] +api_instance.delete_security_findings_automation_severity_modifier_rule(VALID_SEVERITY_MODIFIER_RULE_DATA_ID) diff --git a/examples/v2/security-monitoring/GetSecurityFindingsAutomationSeverityModifierRule.rb b/examples/v2/security-monitoring/GetSecurityFindingsAutomationSeverityModifierRule.rb new file mode 100644 index 000000000000..4f4ec197e558 --- /dev/null +++ b/examples/v2/security-monitoring/GetSecurityFindingsAutomationSeverityModifierRule.rb @@ -0,0 +1,11 @@ +# Get a severity modifier rule returns "Successfully retrieved the severity modifier rule" response + +require "datadog_api_client" +DatadogAPIClient.configure do |config| + config.unstable_operations["v2.get_security_findings_automation_severity_modifier_rule".to_sym] = true +end +api_instance = DatadogAPIClient::V2::SecurityMonitoringAPI.new + +# there is a valid "valid_severity_modifier_rule" in the system +VALID_SEVERITY_MODIFIER_RULE_DATA_ID = ENV["VALID_SEVERITY_MODIFIER_RULE_DATA_ID"] +p api_instance.get_security_findings_automation_severity_modifier_rule(VALID_SEVERITY_MODIFIER_RULE_DATA_ID) diff --git a/features/scenarios_model_mapping.rb b/features/scenarios_model_mapping.rb index c4bfa9ae1080..612fc9ed74df 100644 --- a/features/scenarios_model_mapping.rb +++ b/features/scenarios_model_mapping.rb @@ -2130,6 +2130,15 @@ "rule_id" => "UUID", "body" => "MuteRuleUpdateRequest", }, + "v2.CreateSecurityFindingsAutomationSeverityModifierRule" => { + "body" => "SeverityModifierRuleCreateRequest", + }, + "v2.DeleteSecurityFindingsAutomationSeverityModifierRule" => { + "rule_id" => "UUID", + }, + "v2.GetSecurityFindingsAutomationSeverityModifierRule" => { + "rule_id" => "UUID", + }, "v2.ListSecurityFindingsAutomationTicketCreationRules" => { "page_size" => "Integer", "page_number" => "Integer", diff --git a/features/v2/given.json b/features/v2/given.json index 6e48ed1fc534..55b45d6012ed 100644 --- a/features/v2/given.json +++ b/features/v2/given.json @@ -1354,6 +1354,18 @@ "tag": "Security Monitoring", "operationId": "CreateSecurityFindingsAutomationMuteRule" }, + { + "parameters": [ + { + "name": "body", + "value": "{\n \"data\": {\n \"type\": \"severity_modifier_rules\",\n \"attributes\": {\n \"name\": \"{{ unique }}\",\n \"enabled\": true,\n \"rule\": {\n \"finding_types\": [\"misconfiguration\"],\n \"query\": \"env:staging\"\n },\n \"action\": {\n \"type\": \"set\",\n \"severity\": \"low\"\n }\n }\n }\n}" + } + ], + "step": "there is a valid \"valid_severity_modifier_rule\" in the system", + "key": "valid_severity_modifier_rule", + "tag": "Security Monitoring", + "operationId": "CreateSecurityFindingsAutomationSeverityModifierRule" + }, { "parameters": [ { diff --git a/features/v2/security_monitoring.feature b/features/v2/security_monitoring.feature index 14f3d34a11de..e0e806566535 100644 --- a/features/v2/security_monitoring.feature +++ b/features/v2/security_monitoring.feature @@ -952,6 +952,30 @@ Feature: Security Monitoring And the response "data.attributes.exclusion_filters[0].name" is equal to "Exclude staging" And the response "data.attributes.exclusion_filters[0].query" is equal to "source:staging" + @generated @skip @team:DataDog/k9-automation + Scenario: Create a severity modifier rule returns "Bad Request" response + Given operation "CreateSecurityFindingsAutomationSeverityModifierRule" enabled + And new "CreateSecurityFindingsAutomationSeverityModifierRule" request + And body with value {"data": {"attributes": {"action": {"description": "Lower severity for dev environment noise", "severity": "low", "type": "set"}, "enabled": true, "name": "Downgrade misconfigurations in dev", "rule": {"finding_types": ["misconfiguration"], "query": "env:prod team:platform"}}, "type": "severity_modifier_rules"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/k9-automation + Scenario: Create a severity modifier rule returns "Successfully created the severity modifier rule" response + Given operation "CreateSecurityFindingsAutomationSeverityModifierRule" enabled + And new "CreateSecurityFindingsAutomationSeverityModifierRule" request + And body with value {"data": {"attributes": {"action": {"description": "Lower severity for dev environment noise", "severity": "low", "type": "set"}, "enabled": true, "name": "Downgrade misconfigurations in dev", "rule": {"finding_types": ["misconfiguration"], "query": "env:prod team:platform"}}, "type": "severity_modifier_rules"}} + When the request is sent + Then the response status is 201 Successfully created the severity modifier rule + + @generated @skip @team:DataDog/k9-automation + Scenario: Create a severity modifier rule returns "Unprocessable Entity" response + Given operation "CreateSecurityFindingsAutomationSeverityModifierRule" enabled + And new "CreateSecurityFindingsAutomationSeverityModifierRule" request + And body with value {"data": {"attributes": {"action": {"description": "Lower severity for dev environment noise", "severity": "low", "type": "set"}, "enabled": true, "name": "Downgrade misconfigurations in dev", "rule": {"finding_types": ["misconfiguration"], "query": "env:prod team:platform"}}, "type": "severity_modifier_rules"}} + When the request is sent + Then the response status is 422 Unprocessable Entity + @generated @skip @team:DataDog/cloud-siem Scenario: Create a suppression rule returns "Bad Request" response Given new "CreateSecurityMonitoringSuppression" request @@ -1265,6 +1289,23 @@ Feature: Security Monitoring When the request is sent Then the response status is 204 OK + @generated @skip @team:DataDog/k9-automation + Scenario: Delete a severity modifier rule returns "Not Found" response + Given operation "DeleteSecurityFindingsAutomationSeverityModifierRule" enabled + And new "DeleteSecurityFindingsAutomationSeverityModifierRule" request + And request contains "rule_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + + @team:DataDog/k9-automation + Scenario: Delete a severity modifier rule returns "Rule successfully deleted." response + Given operation "DeleteSecurityFindingsAutomationSeverityModifierRule" enabled + And there is a valid "valid_severity_modifier_rule" in the system + And new "DeleteSecurityFindingsAutomationSeverityModifierRule" request + And request contains "rule_id" parameter from "valid_severity_modifier_rule.data.id" + When the request is sent + Then the response status is 204 Rule successfully deleted. + @team:DataDog/cloud-security-posture-management Scenario: Delete a signal-based notification rule returns "Not Found" response Given new "DeleteSignalNotificationRule" request @@ -1866,6 +1907,25 @@ Feature: Security Monitoring And the response "data.attributes.exclusion_filters[0].name" is equal to "Exclude logs from staging" And the response "data.attributes.exclusion_filters[0].query" is equal to "source:staging" + @generated @skip @team:DataDog/k9-automation + Scenario: Get a severity modifier rule returns "Not Found" response + Given operation "GetSecurityFindingsAutomationSeverityModifierRule" enabled + And new "GetSecurityFindingsAutomationSeverityModifierRule" request + And request contains "rule_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + + @team:DataDog/k9-automation + Scenario: Get a severity modifier rule returns "Successfully retrieved the severity modifier rule" response + Given operation "GetSecurityFindingsAutomationSeverityModifierRule" enabled + And there is a valid "valid_severity_modifier_rule" in the system + And new "GetSecurityFindingsAutomationSeverityModifierRule" request + And request contains "rule_id" parameter from "valid_severity_modifier_rule.data.id" + When the request is sent + Then the response status is 200 Successfully retrieved the severity modifier rule + And the response "data.id" is equal to "{{ valid_severity_modifier_rule.data.id }}" + And the response "data.type" is equal to "severity_modifier_rules" + @replay-only @team:DataDog/cloud-siem Scenario: Get a signal's details returns "Not Found" response Given new "GetSecurityMonitoringSignal" request diff --git a/features/v2/undo.json b/features/v2/undo.json index 133ab9ade47d..07c604333044 100644 --- a/features/v2/undo.json +++ b/features/v2/undo.json @@ -7454,6 +7454,31 @@ "type": "idempotent" } }, + "CreateSecurityFindingsAutomationSeverityModifierRule": { + "tag": "Security Monitoring", + "undo": { + "operationId": "DeleteSecurityFindingsAutomationSeverityModifierRule", + "parameters": [ + { + "name": "rule_id", + "source": "data.id" + } + ], + "type": "unsafe" + } + }, + "DeleteSecurityFindingsAutomationSeverityModifierRule": { + "tag": "Security Monitoring", + "undo": { + "type": "idempotent" + } + }, + "GetSecurityFindingsAutomationSeverityModifierRule": { + "tag": "Security Monitoring", + "undo": { + "type": "safe" + } + }, "ListSecurityFindingsAutomationTicketCreationRules": { "tag": "Security Monitoring", "undo": { diff --git a/lib/datadog_api_client/configuration.rb b/lib/datadog_api_client/configuration.rb index 5a416e62be64..55b60539e56c 100644 --- a/lib/datadog_api_client/configuration.rb +++ b/lib/datadog_api_client/configuration.rb @@ -305,6 +305,7 @@ def initialize "v2.create_sample_log_generation_subscription": false, "v2.create_security_findings_automation_due_date_rule": false, "v2.create_security_findings_automation_mute_rule": false, + "v2.create_security_findings_automation_severity_modifier_rule": false, "v2.create_security_findings_automation_ticket_creation_rule": false, "v2.create_security_monitoring_dataset": false, "v2.create_security_monitoring_integration_config": false, @@ -316,6 +317,7 @@ def initialize "v2.delete_sample_log_generation_subscription": false, "v2.delete_security_findings_automation_due_date_rule": false, "v2.delete_security_findings_automation_mute_rule": false, + "v2.delete_security_findings_automation_severity_modifier_rule": false, "v2.delete_security_findings_automation_ticket_creation_rule": false, "v2.delete_security_monitoring_dataset": false, "v2.delete_security_monitoring_integration_config": false, @@ -330,6 +332,7 @@ def initialize "v2.get_secrets_rules": false, "v2.get_security_findings_automation_due_date_rule": false, "v2.get_security_findings_automation_mute_rule": false, + "v2.get_security_findings_automation_severity_modifier_rule": false, "v2.get_security_findings_automation_ticket_creation_rule": false, "v2.get_security_monitoring_dataset": false, "v2.get_security_monitoring_dataset_by_version": false, diff --git a/lib/datadog_api_client/inflector.rb b/lib/datadog_api_client/inflector.rb index 1bc8cbc8c62f..cd3a0e91fe5f 100644 --- a/lib/datadog_api_client/inflector.rb +++ b/lib/datadog_api_client/inflector.rb @@ -7268,6 +7268,20 @@ def overrides "v2.service_repository_info_status" => "ServiceRepositoryInfoStatus", "v2.session_id_array" => "SessionIdArray", "v2.session_id_data" => "SessionIdData", + "v2.severity_modifier_rule_action" => "SeverityModifierRuleAction", + "v2.severity_modifier_rule_attributes_create" => "SeverityModifierRuleAttributesCreate", + "v2.severity_modifier_rule_attributes_response" => "SeverityModifierRuleAttributesResponse", + "v2.severity_modifier_rule_create_request" => "SeverityModifierRuleCreateRequest", + "v2.severity_modifier_rule_data_create" => "SeverityModifierRuleDataCreate", + "v2.severity_modifier_rule_data_response" => "SeverityModifierRuleDataResponse", + "v2.severity_modifier_rule_response" => "SeverityModifierRuleResponse", + "v2.severity_modifier_rule_set_action" => "SeverityModifierRuleSetAction", + "v2.severity_modifier_rule_set_action_type" => "SeverityModifierRuleSetActionType", + "v2.severity_modifier_rule_shift_action" => "SeverityModifierRuleShiftAction", + "v2.severity_modifier_rule_shift_action_type" => "SeverityModifierRuleShiftActionType", + "v2.severity_modifier_rule_type" => "SeverityModifierRuleType", + "v2.severity_modifier_severity" => "SeverityModifierSeverity", + "v2.severity_modifier_severity_delta" => "SeverityModifierSeverityDelta", "v2.shared_dashboard_included" => "SharedDashboardIncluded", "v2.shared_dashboard_included_dashboard" => "SharedDashboardIncludedDashboard", "v2.shared_dashboard_included_dashboard_attributes" => "SharedDashboardIncludedDashboardAttributes", 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 c807fd7d9bea..24e9023a98bd 100644 --- a/lib/datadog_api_client/v2/api/security_monitoring_api.rb +++ b/lib/datadog_api_client/v2/api/security_monitoring_api.rb @@ -2114,6 +2114,79 @@ def create_security_findings_automation_mute_rule_with_http_info(body, opts = {} return data, status_code, headers end + # Create a severity modifier rule. + # + # @see #create_security_findings_automation_severity_modifier_rule_with_http_info + def create_security_findings_automation_severity_modifier_rule(body, opts = {}) + data, _status_code, _headers = create_security_findings_automation_severity_modifier_rule_with_http_info(body, opts) + data + end + + # Create a severity modifier rule. + # + # Create a new severity modifier rule for the current organization. + # + # @param body [SeverityModifierRuleCreateRequest] + # @param opts [Hash] the optional parameters + # @return [Array<(SeverityModifierRuleResponse, Integer, Hash)>] SeverityModifierRuleResponse data, response status code and response headers + def create_security_findings_automation_severity_modifier_rule_with_http_info(body, opts = {}) + unstable_enabled = @api_client.config.unstable_operations["v2.create_security_findings_automation_severity_modifier_rule".to_sym] + if unstable_enabled + @api_client.config.logger.warn format("Using unstable operation '%s'", "v2.create_security_findings_automation_severity_modifier_rule") + else + raise DatadogAPIClient::APIError.new(message: format("Unstable operation '%s' is disabled", "v2.create_security_findings_automation_severity_modifier_rule")) + end + + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: SecurityMonitoringAPI.create_security_findings_automation_severity_modifier_rule ...' + 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.create_security_findings_automation_severity_modifier_rule" + end + # resource path + local_var_path = '/api/v2/security/findings/automation/severity_modifier_rules' + + # 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] || 'SeverityModifierRuleResponse' + + # auth_names + auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth] + + new_options = opts.merge( + :operation => :create_security_findings_automation_severity_modifier_rule, + :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#create_security_findings_automation_severity_modifier_rule\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + # Create a ticket creation rule. # # @see #create_security_findings_automation_ticket_creation_rule_with_http_info @@ -3452,6 +3525,77 @@ def delete_security_findings_automation_mute_rule_with_http_info(rule_id, opts = return data, status_code, headers end + # Delete a severity modifier rule. + # + # @see #delete_security_findings_automation_severity_modifier_rule_with_http_info + def delete_security_findings_automation_severity_modifier_rule(rule_id, opts = {}) + delete_security_findings_automation_severity_modifier_rule_with_http_info(rule_id, opts) + nil + end + + # Delete a severity modifier rule. + # + # Delete an existing severity modifier rule by ID. + # + # @param rule_id [UUID] The ID of the severity modifier rule. + # @param opts [Hash] the optional parameters + # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers + def delete_security_findings_automation_severity_modifier_rule_with_http_info(rule_id, opts = {}) + unstable_enabled = @api_client.config.unstable_operations["v2.delete_security_findings_automation_severity_modifier_rule".to_sym] + if unstable_enabled + @api_client.config.logger.warn format("Using unstable operation '%s'", "v2.delete_security_findings_automation_severity_modifier_rule") + else + raise DatadogAPIClient::APIError.new(message: format("Unstable operation '%s' is disabled", "v2.delete_security_findings_automation_severity_modifier_rule")) + end + + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: SecurityMonitoringAPI.delete_security_findings_automation_severity_modifier_rule ...' + end + # verify the required parameter 'rule_id' is set + if @api_client.config.client_side_validation && rule_id.nil? + fail ArgumentError, "Missing the required parameter 'rule_id' when calling SecurityMonitoringAPI.delete_security_findings_automation_severity_modifier_rule" + end + # resource path + local_var_path = '/api/v2/security/findings/automation/severity_modifier_rules/{rule_id}'.sub('{rule_id}', CGI.escape(rule_id.to_s).gsub('%2F', '/')) + + # 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(['*/*']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] + + # auth_names + auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth] + + new_options = opts.merge( + :operation => :delete_security_findings_automation_severity_modifier_rule, + :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::Delete, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: SecurityMonitoringAPI#delete_security_findings_automation_severity_modifier_rule\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + # Delete a ticket creation rule. # # @see #delete_security_findings_automation_ticket_creation_rule_with_http_info @@ -5584,6 +5728,77 @@ def get_security_findings_automation_mute_rule_with_http_info(rule_id, opts = {} return data, status_code, headers end + # Get a severity modifier rule. + # + # @see #get_security_findings_automation_severity_modifier_rule_with_http_info + def get_security_findings_automation_severity_modifier_rule(rule_id, opts = {}) + data, _status_code, _headers = get_security_findings_automation_severity_modifier_rule_with_http_info(rule_id, opts) + data + end + + # Get a severity modifier rule. + # + # Get the details of a severity modifier rule by ID. + # + # @param rule_id [UUID] The ID of the severity modifier rule. + # @param opts [Hash] the optional parameters + # @return [Array<(SeverityModifierRuleResponse, Integer, Hash)>] SeverityModifierRuleResponse data, response status code and response headers + def get_security_findings_automation_severity_modifier_rule_with_http_info(rule_id, opts = {}) + unstable_enabled = @api_client.config.unstable_operations["v2.get_security_findings_automation_severity_modifier_rule".to_sym] + if unstable_enabled + @api_client.config.logger.warn format("Using unstable operation '%s'", "v2.get_security_findings_automation_severity_modifier_rule") + else + raise DatadogAPIClient::APIError.new(message: format("Unstable operation '%s' is disabled", "v2.get_security_findings_automation_severity_modifier_rule")) + end + + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: SecurityMonitoringAPI.get_security_findings_automation_severity_modifier_rule ...' + end + # verify the required parameter 'rule_id' is set + if @api_client.config.client_side_validation && rule_id.nil? + fail ArgumentError, "Missing the required parameter 'rule_id' when calling SecurityMonitoringAPI.get_security_findings_automation_severity_modifier_rule" + end + # resource path + local_var_path = '/api/v2/security/findings/automation/severity_modifier_rules/{rule_id}'.sub('{rule_id}', CGI.escape(rule_id.to_s).gsub('%2F', '/')) + + # 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']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'SeverityModifierRuleResponse' + + # auth_names + auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth] + + new_options = opts.merge( + :operation => :get_security_findings_automation_severity_modifier_rule, + :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::Get, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: SecurityMonitoringAPI#get_security_findings_automation_severity_modifier_rule\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + # Get a ticket creation rule. # # @see #get_security_findings_automation_ticket_creation_rule_with_http_info diff --git a/lib/datadog_api_client/v2/models/severity_modifier_rule_action.rb b/lib/datadog_api_client/v2/models/severity_modifier_rule_action.rb new file mode 100644 index 000000000000..e8cf14506b88 --- /dev/null +++ b/lib/datadog_api_client/v2/models/severity_modifier_rule_action.rb @@ -0,0 +1,49 @@ +=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 action to take when a severity modifier rule matches a finding. This is a discriminated union on `type`: `set` assigns a fixed severity, while `shift` moves the severity up or down by one rank. + # + # A severity modifier rule's `rule.query` must not filter on `@severity` or on the `@severity_details.user_adjusted.*` namespace; use `@severity_details.adjusted.value` to filter on the Datadog-adjusted severity instead. + module SeverityModifierRuleAction + class << self + include BaseOneOfModel + + # List of class defined in oneOf (OpenAPI v3) + def openapi_one_of + [ + :'SeverityModifierRuleSetAction', + :'SeverityModifierRuleShiftAction' + ] + end + # Discriminator's property name (OpenAPI v3) + def openapi_discriminator_name + :'type' + end + + # Builds the object + # @param data [Mixed] Data to be matched against the list of oneOf items + # @return [Object] Returns the model or the data itself + def build(data) + discriminator_value = data[openapi_discriminator_name] + return nil unless discriminator_value + + end + end + end +end diff --git a/lib/datadog_api_client/v2/models/severity_modifier_rule_attributes_create.rb b/lib/datadog_api_client/v2/models/severity_modifier_rule_attributes_create.rb new file mode 100644 index 000000000000..9b0a6b7da6ca --- /dev/null +++ b/lib/datadog_api_client/v2/models/severity_modifier_rule_attributes_create.rb @@ -0,0 +1,185 @@ +=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 for creating or updating a severity modifier rule. + class SeverityModifierRuleAttributesCreate + include BaseGenericModel + + # The action to take when a severity modifier rule matches a finding. This is a discriminated union on `type`: `set` assigns a fixed severity, while `shift` moves the severity up or down by one rank. + # + # A severity modifier rule's `rule.query` must not filter on `@severity` or on the `@severity_details.user_adjusted.*` namespace; use `@severity_details.adjusted.value` to filter on the Datadog-adjusted severity instead. + attr_reader :action + + # Whether the severity modifier rule is enabled. + attr_accessor :enabled + + # The name of the severity modifier rule. + attr_reader :name + + # Defines the scope of findings to which the automation rule applies. + attr_reader :rule + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'action' => :'action', + :'enabled' => :'enabled', + :'name' => :'name', + :'rule' => :'rule' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'action' => :'SeverityModifierRuleAction', + :'enabled' => :'Boolean', + :'name' => :'String', + :'rule' => :'AutomationRuleScope' + } + 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::SeverityModifierRuleAttributesCreate` 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?(:'action') + self.action = attributes[:'action'] + end + + if attributes.key?(:'enabled') + self.enabled = attributes[:'enabled'] + end + + if attributes.key?(:'name') + self.name = attributes[:'name'] + end + + if attributes.key?(:'rule') + self.rule = attributes[:'rule'] + 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 @action.nil? + return false if @name.nil? + return false if @name.to_s.length > 255 + return false if @name.to_s.length < 1 + return false if @rule.nil? + true + end + + # Custom attribute writer method with validation + # @param action [Object] Object to be assigned + # @!visibility private + def action=(action) + if action.nil? + fail ArgumentError, 'invalid value for "action", action cannot be nil.' + end + @action = action + end + + # Custom attribute writer method with validation + # @param name [Object] Object to be assigned + # @!visibility private + def name=(name) + if name.nil? + fail ArgumentError, 'invalid value for "name", name cannot be nil.' + end + if name.to_s.length > 255 + fail ArgumentError, 'invalid value for "name", the character length must be smaller than or equal to 255.' + end + if name.to_s.length < 1 + fail ArgumentError, 'invalid value for "name", the character length must be great than or equal to 1.' + end + @name = name + end + + # Custom attribute writer method with validation + # @param rule [Object] Object to be assigned + # @!visibility private + def rule=(rule) + if rule.nil? + fail ArgumentError, 'invalid value for "rule", rule cannot be nil.' + end + @rule = rule + 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 && + action == o.action && + enabled == o.enabled && + name == o.name && + rule == o.rule && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [action, enabled, name, rule, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/severity_modifier_rule_attributes_response.rb b/lib/datadog_api_client/v2/models/severity_modifier_rule_attributes_response.rb new file mode 100644 index 000000000000..3f091ddd2cdd --- /dev/null +++ b/lib/datadog_api_client/v2/models/severity_modifier_rule_attributes_response.rb @@ -0,0 +1,280 @@ +=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 a severity modifier rule as returned by the API. + class SeverityModifierRuleAttributesResponse + include BaseGenericModel + + # The action to take when a severity modifier rule matches a finding. This is a discriminated union on `type`: `set` assigns a fixed severity, while `shift` moves the severity up or down by one rank. + # + # A severity modifier rule's `rule.query` must not filter on `@severity` or on the `@severity_details.user_adjusted.*` namespace; use `@severity_details.adjusted.value` to filter on the Datadog-adjusted severity instead. + attr_reader :action + + # The Unix timestamp in milliseconds when the rule was created. + attr_reader :created_at + + # The user or Datadog system who created the rule. + attr_reader :created_by + + # Whether the severity modifier rule is enabled. + attr_reader :enabled + + # The Unix timestamp in milliseconds when the rule was last modified. + attr_reader :modified_at + + # The user or Datadog system who last modified the rule. + attr_reader :modified_by + + # The name of the severity modifier rule. + attr_reader :name + + # Defines the scope of findings to which the automation rule applies. + attr_reader :rule + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'action' => :'action', + :'created_at' => :'created_at', + :'created_by' => :'created_by', + :'enabled' => :'enabled', + :'modified_at' => :'modified_at', + :'modified_by' => :'modified_by', + :'name' => :'name', + :'rule' => :'rule' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'action' => :'SeverityModifierRuleAction', + :'created_at' => :'Integer', + :'created_by' => :'AutomationRuleCreatedBy', + :'enabled' => :'Boolean', + :'modified_at' => :'Integer', + :'modified_by' => :'AutomationRuleModifiedBy', + :'name' => :'String', + :'rule' => :'AutomationRuleScope' + } + 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::SeverityModifierRuleAttributesResponse` 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?(:'action') + self.action = attributes[:'action'] + end + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + end + + if attributes.key?(:'created_by') + self.created_by = attributes[:'created_by'] + end + + if attributes.key?(:'enabled') + self.enabled = attributes[:'enabled'] + end + + if attributes.key?(:'modified_at') + self.modified_at = attributes[:'modified_at'] + end + + if attributes.key?(:'modified_by') + self.modified_by = attributes[:'modified_by'] + end + + if attributes.key?(:'name') + self.name = attributes[:'name'] + end + + if attributes.key?(:'rule') + self.rule = attributes[:'rule'] + 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 @action.nil? + return false if @created_at.nil? + return false if @created_by.nil? + return false if @enabled.nil? + return false if @modified_at.nil? + return false if @modified_by.nil? + return false if @name.nil? + return false if @name.to_s.length > 255 + return false if @name.to_s.length < 1 + return false if @rule.nil? + true + end + + # Custom attribute writer method with validation + # @param action [Object] Object to be assigned + # @!visibility private + def action=(action) + if action.nil? + fail ArgumentError, 'invalid value for "action", action cannot be nil.' + end + @action = action + end + + # Custom attribute writer method with validation + # @param created_at [Object] Object to be assigned + # @!visibility private + def created_at=(created_at) + if created_at.nil? + fail ArgumentError, 'invalid value for "created_at", created_at cannot be nil.' + end + @created_at = created_at + end + + # Custom attribute writer method with validation + # @param created_by [Object] Object to be assigned + # @!visibility private + def created_by=(created_by) + if created_by.nil? + fail ArgumentError, 'invalid value for "created_by", created_by cannot be nil.' + end + @created_by = created_by + end + + # Custom attribute writer method with validation + # @param enabled [Object] Object to be assigned + # @!visibility private + def enabled=(enabled) + if enabled.nil? + fail ArgumentError, 'invalid value for "enabled", enabled cannot be nil.' + end + @enabled = enabled + end + + # Custom attribute writer method with validation + # @param modified_at [Object] Object to be assigned + # @!visibility private + def modified_at=(modified_at) + if modified_at.nil? + fail ArgumentError, 'invalid value for "modified_at", modified_at cannot be nil.' + end + @modified_at = modified_at + end + + # Custom attribute writer method with validation + # @param modified_by [Object] Object to be assigned + # @!visibility private + def modified_by=(modified_by) + if modified_by.nil? + fail ArgumentError, 'invalid value for "modified_by", modified_by cannot be nil.' + end + @modified_by = modified_by + end + + # Custom attribute writer method with validation + # @param name [Object] Object to be assigned + # @!visibility private + def name=(name) + if name.nil? + fail ArgumentError, 'invalid value for "name", name cannot be nil.' + end + if name.to_s.length > 255 + fail ArgumentError, 'invalid value for "name", the character length must be smaller than or equal to 255.' + end + if name.to_s.length < 1 + fail ArgumentError, 'invalid value for "name", the character length must be great than or equal to 1.' + end + @name = name + end + + # Custom attribute writer method with validation + # @param rule [Object] Object to be assigned + # @!visibility private + def rule=(rule) + if rule.nil? + fail ArgumentError, 'invalid value for "rule", rule cannot be nil.' + end + @rule = rule + 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 && + action == o.action && + created_at == o.created_at && + created_by == o.created_by && + enabled == o.enabled && + modified_at == o.modified_at && + modified_by == o.modified_by && + name == o.name && + rule == o.rule && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [action, created_at, created_by, enabled, modified_at, modified_by, name, rule, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/severity_modifier_rule_create_request.rb b/lib/datadog_api_client/v2/models/severity_modifier_rule_create_request.rb new file mode 100644 index 000000000000..ece7e4de8f19 --- /dev/null +++ b/lib/datadog_api_client/v2/models/severity_modifier_rule_create_request.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 + # The body of a severity modifier rule create request. + class SeverityModifierRuleCreateRequest + include BaseGenericModel + + # The data object for a severity modifier rule create or update request. + 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' => :'SeverityModifierRuleDataCreate' + } + 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::SeverityModifierRuleCreateRequest` 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/severity_modifier_rule_data_create.rb b/lib/datadog_api_client/v2/models/severity_modifier_rule_data_create.rb new file mode 100644 index 000000000000..492fda51c48c --- /dev/null +++ b/lib/datadog_api_client/v2/models/severity_modifier_rule_data_create.rb @@ -0,0 +1,144 @@ +=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 data object for a severity modifier rule create or update request. + class SeverityModifierRuleDataCreate + include BaseGenericModel + + # Attributes for creating or updating a severity modifier rule. + attr_reader :attributes + + # The JSON:API type for severity modifier rules. + 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', + :'type' => :'type' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'attributes' => :'SeverityModifierRuleAttributesCreate', + :'type' => :'SeverityModifierRuleType' + } + 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::SeverityModifierRuleDataCreate` 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?(:'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 && + 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, type, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/severity_modifier_rule_data_response.rb b/lib/datadog_api_client/v2/models/severity_modifier_rule_data_response.rb new file mode 100644 index 000000000000..210af8d6a880 --- /dev/null +++ b/lib/datadog_api_client/v2/models/severity_modifier_rule_data_response.rb @@ -0,0 +1,165 @@ +=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 data object for a severity modifier rule as returned by the API. + class SeverityModifierRuleDataResponse + include BaseGenericModel + + # Attributes of a severity modifier rule as returned by the API. + attr_reader :attributes + + # The ID of the severity modifier rule. + attr_reader :id + + # The JSON:API type for severity modifier rules. + 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' => :'SeverityModifierRuleAttributesResponse', + :'id' => :'UUID', + :'type' => :'SeverityModifierRuleType' + } + 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::SeverityModifierRuleDataResponse` 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 @id.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 id [Object] Object to be assigned + # @!visibility private + def id=(id) + if id.nil? + fail ArgumentError, 'invalid value for "id", id cannot be nil.' + end + @id = id + 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/severity_modifier_rule_response.rb b/lib/datadog_api_client/v2/models/severity_modifier_rule_response.rb new file mode 100644 index 000000000000..380cf702427c --- /dev/null +++ b/lib/datadog_api_client/v2/models/severity_modifier_rule_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 + # A single severity modifier rule response. + class SeverityModifierRuleResponse + include BaseGenericModel + + # The data object for a severity modifier rule as returned by the API. + 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' => :'SeverityModifierRuleDataResponse' + } + 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::SeverityModifierRuleResponse` 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/severity_modifier_rule_set_action.rb b/lib/datadog_api_client/v2/models/severity_modifier_rule_set_action.rb new file mode 100644 index 000000000000..4b4c4ba745fa --- /dev/null +++ b/lib/datadog_api_client/v2/models/severity_modifier_rule_set_action.rb @@ -0,0 +1,165 @@ +=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 + # Sets matched findings to a fixed severity. + class SeverityModifierRuleSetAction + include BaseGenericModel + + # An optional free-form explanation for the severity change. + attr_reader :description + + # The severity to assign to matched findings. `info_none` is not supported for the `iac_misconfiguration`, `runtime_code_vulnerability`, `secret`, or `static_code_vulnerability` finding types. + attr_reader :severity + + # The type of a severity modifier rule action that sets a fixed severity. + attr_reader :type + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'description' => :'description', + :'severity' => :'severity', + :'type' => :'type' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'description' => :'String', + :'severity' => :'SeverityModifierSeverity', + :'type' => :'SeverityModifierRuleSetActionType' + } + 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::SeverityModifierRuleSetAction` 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?(:'description') + self.description = attributes[:'description'] + end + + if attributes.key?(:'severity') + self.severity = attributes[:'severity'] + 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 !@description.nil? && @description.to_s.length > 20000 + return false if @severity.nil? + return false if @type.nil? + true + end + + # Custom attribute writer method with validation + # @param description [Object] Object to be assigned + # @!visibility private + def description=(description) + if !description.nil? && description.to_s.length > 20000 + fail ArgumentError, 'invalid value for "description", the character length must be smaller than or equal to 20000.' + end + @description = description + end + + # Custom attribute writer method with validation + # @param severity [Object] Object to be assigned + # @!visibility private + def severity=(severity) + if severity.nil? + fail ArgumentError, 'invalid value for "severity", severity cannot be nil.' + end + @severity = severity + 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 && + description == o.description && + severity == o.severity && + type == o.type && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [description, severity, type, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/severity_modifier_rule_set_action_type.rb b/lib/datadog_api_client/v2/models/severity_modifier_rule_set_action_type.rb new file mode 100644 index 000000000000..34a225fec2ed --- /dev/null +++ b/lib/datadog_api_client/v2/models/severity_modifier_rule_set_action_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 a severity modifier rule action that sets a fixed severity. + class SeverityModifierRuleSetActionType + include BaseEnumModel + + SET = "set".freeze + end +end diff --git a/lib/datadog_api_client/v2/models/severity_modifier_rule_shift_action.rb b/lib/datadog_api_client/v2/models/severity_modifier_rule_shift_action.rb new file mode 100644 index 000000000000..b459a175a4c7 --- /dev/null +++ b/lib/datadog_api_client/v2/models/severity_modifier_rule_shift_action.rb @@ -0,0 +1,165 @@ +=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 + # Shifts matched findings up or down by one severity rank. + class SeverityModifierRuleShiftAction + include BaseGenericModel + + # An optional free-form explanation for the severity change. + attr_reader :description + + # The direction in which to shift the severity of matched findings by one rank. + attr_reader :severity_delta + + # The type of a severity modifier rule action that shifts the severity by one rank. + attr_reader :type + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'description' => :'description', + :'severity_delta' => :'severity_delta', + :'type' => :'type' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'description' => :'String', + :'severity_delta' => :'SeverityModifierSeverityDelta', + :'type' => :'SeverityModifierRuleShiftActionType' + } + 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::SeverityModifierRuleShiftAction` 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?(:'description') + self.description = attributes[:'description'] + end + + if attributes.key?(:'severity_delta') + self.severity_delta = attributes[:'severity_delta'] + 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 !@description.nil? && @description.to_s.length > 20000 + return false if @severity_delta.nil? + return false if @type.nil? + true + end + + # Custom attribute writer method with validation + # @param description [Object] Object to be assigned + # @!visibility private + def description=(description) + if !description.nil? && description.to_s.length > 20000 + fail ArgumentError, 'invalid value for "description", the character length must be smaller than or equal to 20000.' + end + @description = description + end + + # Custom attribute writer method with validation + # @param severity_delta [Object] Object to be assigned + # @!visibility private + def severity_delta=(severity_delta) + if severity_delta.nil? + fail ArgumentError, 'invalid value for "severity_delta", severity_delta cannot be nil.' + end + @severity_delta = severity_delta + 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 && + description == o.description && + severity_delta == o.severity_delta && + type == o.type && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [description, severity_delta, type, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/severity_modifier_rule_shift_action_type.rb b/lib/datadog_api_client/v2/models/severity_modifier_rule_shift_action_type.rb new file mode 100644 index 000000000000..33863dd3717f --- /dev/null +++ b/lib/datadog_api_client/v2/models/severity_modifier_rule_shift_action_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 a severity modifier rule action that shifts the severity by one rank. + class SeverityModifierRuleShiftActionType + include BaseEnumModel + + SHIFT = "shift".freeze + end +end diff --git a/lib/datadog_api_client/v2/models/severity_modifier_rule_type.rb b/lib/datadog_api_client/v2/models/severity_modifier_rule_type.rb new file mode 100644 index 000000000000..9c42ee301bf9 --- /dev/null +++ b/lib/datadog_api_client/v2/models/severity_modifier_rule_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 JSON:API type for severity modifier rules. + class SeverityModifierRuleType + include BaseEnumModel + + SEVERITY_MODIFIER_RULES = "severity_modifier_rules".freeze + end +end diff --git a/lib/datadog_api_client/v2/models/severity_modifier_severity.rb b/lib/datadog_api_client/v2/models/severity_modifier_severity.rb new file mode 100644 index 000000000000..4bff93445bd3 --- /dev/null +++ b/lib/datadog_api_client/v2/models/severity_modifier_severity.rb @@ -0,0 +1,30 @@ +=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 severity to assign to matched findings. `info_none` is not supported for the `iac_misconfiguration`, `runtime_code_vulnerability`, `secret`, or `static_code_vulnerability` finding types. + class SeverityModifierSeverity + include BaseEnumModel + + INFO_NONE = "info_none".freeze + LOW = "low".freeze + MEDIUM = "medium".freeze + HIGH = "high".freeze + CRITICAL = "critical".freeze + end +end diff --git a/lib/datadog_api_client/v2/models/severity_modifier_severity_delta.rb b/lib/datadog_api_client/v2/models/severity_modifier_severity_delta.rb new file mode 100644 index 000000000000..58d29f000bcd --- /dev/null +++ b/lib/datadog_api_client/v2/models/severity_modifier_severity_delta.rb @@ -0,0 +1,27 @@ +=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 direction in which to shift the severity of matched findings by one rank. + class SeverityModifierSeverityDelta + include BaseEnumModel + + UP_ONE = "up_one".freeze + DOWN_ONE = "down_one".freeze + end +end