From 87413598e96c850bded57447defce3505dc5f55f Mon Sep 17 00:00:00 2001 From: "ci.datadog-api-spec" Date: Tue, 18 Jan 2022 13:40:27 +0000 Subject: [PATCH] Regenerate client from commit a6ad2ff of spec repo --- .apigentools-info | 8 +- .generator/schemas/v2/openapi.yaml | 32 ++ ...hod-third-party-returns-OK-response.frozen | 1 + ...method-third-party-returns-OK-response.yml | 34 +++ docs/v2/README.md | 1 + docs/v2/SecurityMonitoringRuleOptions.md | 18 +- ...SecurityMonitoringRuleThirdPartyOptions.md | 27 ++ ...CreateSecurityMonitoringRule_3348700599.rb | 38 +++ features/v2/security_monitoring.feature | 13 +- lib/datadog_api_client/v2.rb | 1 + ...curity_monitoring_rule_detection_method.rb | 1 + .../security_monitoring_rule_options.rb | 17 +- ...urity_monitoring_rule_query_aggregation.rb | 1 + ...ity_monitoring_rule_third_party_options.rb | 284 ++++++++++++++++++ .../security_monitoring_rule_options_spec.rb | 6 + ...onitoring_rule_third_party_options_spec.rb | 67 +++++ 16 files changed, 530 insertions(+), 19 deletions(-) create mode 100644 cassettes/features/v2/security_monitoring/Create-a-detection-rule-with-detection-method-third-party-returns-OK-response.frozen create mode 100644 cassettes/features/v2/security_monitoring/Create-a-detection-rule-with-detection-method-third-party-returns-OK-response.yml create mode 100644 docs/v2/SecurityMonitoringRuleThirdPartyOptions.md create mode 100644 examples/v2/security-monitoring/CreateSecurityMonitoringRule_3348700599.rb create mode 100644 lib/datadog_api_client/v2/models/security_monitoring_rule_third_party_options.rb create mode 100644 spec/v2/models/security_monitoring_rule_third_party_options_spec.rb diff --git a/.apigentools-info b/.apigentools-info index cb2745dfe881..3ffcf4a75432 100644 --- a/.apigentools-info +++ b/.apigentools-info @@ -4,13 +4,13 @@ "spec_versions": { "v1": { "apigentools_version": "1.6.1", - "regenerated": "2022-01-18 11:51:58.575036", - "spec_repo_commit": "5808ab7" + "regenerated": "2022-01-18 13:39:04.398943", + "spec_repo_commit": "a6ad2ff" }, "v2": { "apigentools_version": "1.6.1", - "regenerated": "2022-01-18 11:51:58.597917", - "spec_repo_commit": "5808ab7" + "regenerated": "2022-01-18 13:39:04.424643", + "spec_repo_commit": "a6ad2ff" } } } \ No newline at end of file diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 6d0f001437e0..8596b0ae8c8d 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -4745,11 +4745,13 @@ components: - threshold - new_value - anomaly_detection + - third_party type: string x-enum-varnames: - THRESHOLD - NEW_VALUE - ANOMALY_DETECTION + - THIRD_PARTY SecurityMonitoringRuleEvaluationWindow: description: 'A time window is specified to match when at least one of the cases matches true. This is a sliding window @@ -4889,6 +4891,8 @@ components: $ref: '#/components/schemas/SecurityMonitoringRuleMaxSignalDuration' newValueOptions: $ref: '#/components/schemas/SecurityMonitoringRuleNewValueOptions' + thirdPartyRuleOptions: + $ref: '#/components/schemas/SecurityMonitoringRuleThirdPartyOptions' type: object SecurityMonitoringRuleQuery: description: Query for matching rule. @@ -4927,6 +4931,7 @@ components: - sum - max - new_value + - none type: string x-enum-varnames: - COUNT @@ -4934,6 +4939,7 @@ components: - SUM - MAX - NEW_VALUE + - NONE SecurityMonitoringRuleQueryCreate: description: Query for matching rule. properties: @@ -5049,6 +5055,32 @@ components: - MEDIUM - HIGH - CRITICAL + SecurityMonitoringRuleThirdPartyOptions: + description: Options for third-party rules. + properties: + defaultNotifications: + description: Notification targets for the root query. + items: + description: Notification + type: string + type: array + defaultStatus: + $ref: '#/components/schemas/SecurityMonitoringRuleSeverity' + firstSeenOverride: + description: '(Optional): the name of an attribute to override the first + seen value of the third party signal.' + type: string + lastSeenOverride: + description: '(Optional): the name of an attribute to override the last + seen value of the third party signal.' + type: string + rootQuery: + description: Root query of the rule. + type: string + signalId: + description: Optional mapping of the third-party signal ID. + type: string + type: object SecurityMonitoringRuleTypeCreate: description: The rule type. enum: diff --git a/cassettes/features/v2/security_monitoring/Create-a-detection-rule-with-detection-method-third-party-returns-OK-response.frozen b/cassettes/features/v2/security_monitoring/Create-a-detection-rule-with-detection-method-third-party-returns-OK-response.frozen new file mode 100644 index 000000000000..4214cacda1aa --- /dev/null +++ b/cassettes/features/v2/security_monitoring/Create-a-detection-rule-with-detection-method-third-party-returns-OK-response.frozen @@ -0,0 +1 @@ +2022-01-18T13:36:07.397Z \ No newline at end of file diff --git a/cassettes/features/v2/security_monitoring/Create-a-detection-rule-with-detection-method-third-party-returns-OK-response.yml b/cassettes/features/v2/security_monitoring/Create-a-detection-rule-with-detection-method-third-party-returns-OK-response.yml new file mode 100644 index 000000000000..40c7bc92d910 --- /dev/null +++ b/cassettes/features/v2/security_monitoring/Create-a-detection-rule-with-detection-method-third-party-returns-OK-response.yml @@ -0,0 +1,34 @@ +http_interactions: +- recorded_at: Tue, 18 Jan 2022 13:36:07 GMT + request: + body: + encoding: UTF-8 + string: '{"cases":[{"name":"","notifications":[],"status":"info"}],"filters":[],"isEnabled":true,"message":"Test-Create_a_detection_rule_with_detection_method_third_party_returns_OK_response-1642512967 + message","name":"Test-Create_a_detection_rule_with_detection_method_third_party_returns_OK_response-1642512967","options":{"detectionMethod":"third_party","evaluationWindow":0,"keepAlive":3600,"maxSignalDuration":86400,"thirdPartyRuleOptions":{"defaultStatus":"low","rootQuery":"@pop"}},"queries":[{"aggregation":"none","distinctFields":[],"groupByFields":[],"query":"@test:true"}],"tags":[]}' + headers: + Content-Type: + - application/json;charset=utf-8 + method: POST + uri: https://api.datadoghq.com/api/v2/security_monitoring/rules + response: + body: + encoding: UTF-8 + string: '{"creationAuthorId":1445416,"tags":[],"isEnabled":true,"hasExtendedTitle":false,"message":"Test-Create_a_detection_rule_with_detection_method_third_party_returns_OK_response-1642512967 + message","options":{"detectionMethod":"third_party","evaluationWindow":0,"maxSignalDuration":86400,"thirdPartyRuleOptions":{"defaultStatus":"low","defaultNotifications":[],"rootQuery":"@pop"},"keepAlive":3600},"version":1,"createdAt":1642512967974,"filters":[],"queries":[{"query":"@test:true","groupByFields":[],"aggregation":"none","name":"","distinctFields":[]}],"isDeleted":false,"cases":[{"status":"info","notifications":[],"name":""}],"type":"log_detection","id":"4fd-sl4-onv","isDefault":false,"name":"Test-Create_a_detection_rule_with_detection_method_third_party_returns_OK_response-1642512967"}' + status: + code: 200 + message: OK +- recorded_at: Tue, 18 Jan 2022 13:36:07 GMT + request: + body: null + headers: {} + method: DELETE + uri: https://api.datadoghq.com/api/v2/security_monitoring/rules/4fd-sl4-onv + response: + body: + encoding: UTF-8 + string: '' + status: + code: 204 + message: No Content +recorded_with: VCR 6.0.0 diff --git a/docs/v2/README.md b/docs/v2/README.md index 613976ad41b9..44491871a847 100644 --- a/docs/v2/README.md +++ b/docs/v2/README.md @@ -448,6 +448,7 @@ All URIs are relative to *https://api.datadoghq.com* - [DatadogAPIClient::V2::SecurityMonitoringRuleQueryCreate](SecurityMonitoringRuleQueryCreate.md) - [DatadogAPIClient::V2::SecurityMonitoringRuleResponse](SecurityMonitoringRuleResponse.md) - [DatadogAPIClient::V2::SecurityMonitoringRuleSeverity](SecurityMonitoringRuleSeverity.md) +- [DatadogAPIClient::V2::SecurityMonitoringRuleThirdPartyOptions](SecurityMonitoringRuleThirdPartyOptions.md) - [DatadogAPIClient::V2::SecurityMonitoringRuleTypeCreate](SecurityMonitoringRuleTypeCreate.md) - [DatadogAPIClient::V2::SecurityMonitoringRuleTypeRead](SecurityMonitoringRuleTypeRead.md) - [DatadogAPIClient::V2::SecurityMonitoringRuleUpdatePayload](SecurityMonitoringRuleUpdatePayload.md) diff --git a/docs/v2/SecurityMonitoringRuleOptions.md b/docs/v2/SecurityMonitoringRuleOptions.md index 465e298ea897..865bc86a6f6b 100644 --- a/docs/v2/SecurityMonitoringRuleOptions.md +++ b/docs/v2/SecurityMonitoringRuleOptions.md @@ -2,13 +2,14 @@ ## Properties -| Name | Type | Description | Notes | -| ----------------------- | ----------------------------------------------------------------------------------------- | ----------- | ---------- | -| **detection_method** | [**SecurityMonitoringRuleDetectionMethod**](SecurityMonitoringRuleDetectionMethod.md) | | [optional] | -| **evaluation_window** | [**SecurityMonitoringRuleEvaluationWindow**](SecurityMonitoringRuleEvaluationWindow.md) | | [optional] | -| **keep_alive** | [**SecurityMonitoringRuleKeepAlive**](SecurityMonitoringRuleKeepAlive.md) | | [optional] | -| **max_signal_duration** | [**SecurityMonitoringRuleMaxSignalDuration**](SecurityMonitoringRuleMaxSignalDuration.md) | | [optional] | -| **new_value_options** | [**SecurityMonitoringRuleNewValueOptions**](SecurityMonitoringRuleNewValueOptions.md) | | [optional] | +| Name | Type | Description | Notes | +| ---------------------------- | ----------------------------------------------------------------------------------------- | ----------- | ---------- | +| **detection_method** | [**SecurityMonitoringRuleDetectionMethod**](SecurityMonitoringRuleDetectionMethod.md) | | [optional] | +| **evaluation_window** | [**SecurityMonitoringRuleEvaluationWindow**](SecurityMonitoringRuleEvaluationWindow.md) | | [optional] | +| **keep_alive** | [**SecurityMonitoringRuleKeepAlive**](SecurityMonitoringRuleKeepAlive.md) | | [optional] | +| **max_signal_duration** | [**SecurityMonitoringRuleMaxSignalDuration**](SecurityMonitoringRuleMaxSignalDuration.md) | | [optional] | +| **new_value_options** | [**SecurityMonitoringRuleNewValueOptions**](SecurityMonitoringRuleNewValueOptions.md) | | [optional] | +| **third_party_rule_options** | [**SecurityMonitoringRuleThirdPartyOptions**](SecurityMonitoringRuleThirdPartyOptions.md) | | [optional] | ## Example @@ -20,6 +21,7 @@ instance = DatadogAPIClient::V2::SecurityMonitoringRuleOptions.new( evaluation_window: null, keep_alive: null, max_signal_duration: null, - new_value_options: null + new_value_options: null, + third_party_rule_options: null ) ``` diff --git a/docs/v2/SecurityMonitoringRuleThirdPartyOptions.md b/docs/v2/SecurityMonitoringRuleThirdPartyOptions.md new file mode 100644 index 000000000000..3a86eda18c85 --- /dev/null +++ b/docs/v2/SecurityMonitoringRuleThirdPartyOptions.md @@ -0,0 +1,27 @@ +# DatadogAPIClient::V2::SecurityMonitoringRuleThirdPartyOptions + +## Properties + +| Name | Type | Description | Notes | +| ------------------------- | ----------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------ | ---------- | +| **default_notifications** | **Array<String>** | Notification targets for the root query. | [optional] | +| **default_status** | [**SecurityMonitoringRuleSeverity**](SecurityMonitoringRuleSeverity.md) | | [optional] | +| **first_seen_override** | **String** | (Optional): the name of an attribute to override the first seen value of the third party signal. | [optional] | +| **last_seen_override** | **String** | (Optional): the name of an attribute to override the last seen value of the third party signal. | [optional] | +| **root_query** | **String** | Root query of the rule. | [optional] | +| **signal_id** | **String** | Optional mapping of the third-party signal ID. | [optional] | + +## Example + +```ruby +require 'datadog_api_client/v2' + +instance = DatadogAPIClient::V2::SecurityMonitoringRuleThirdPartyOptions.new( + default_notifications: null, + default_status: null, + first_seen_override: null, + last_seen_override: null, + root_query: null, + signal_id: null +) +``` diff --git a/examples/v2/security-monitoring/CreateSecurityMonitoringRule_3348700599.rb b/examples/v2/security-monitoring/CreateSecurityMonitoringRule_3348700599.rb new file mode 100644 index 000000000000..828d8112faaa --- /dev/null +++ b/examples/v2/security-monitoring/CreateSecurityMonitoringRule_3348700599.rb @@ -0,0 +1,38 @@ +# Create a detection rule with detection method "third_party" returns "OK" response + +require "datadog_api_client" +api_instance = DatadogAPIClient::V2::SecurityMonitoringAPI.new + +body = DatadogAPIClient::V2::SecurityMonitoringRuleCreatePayload.new({ + name: "Example-Create_a_detection_rule_with_detection_method_third_party_returns_OK_response", + queries: [ + DatadogAPIClient::V2::SecurityMonitoringRuleQueryCreate.new({ + query: "@test:true", + aggregation: DatadogAPIClient::V2::SecurityMonitoringRuleQueryAggregation::NONE, + group_by_fields: [], + distinct_fields: [], + }), + ], + filters: [], + cases: [ + DatadogAPIClient::V2::SecurityMonitoringRuleCaseCreate.new({ + name: "", + status: DatadogAPIClient::V2::SecurityMonitoringRuleSeverity::INFO, + notifications: [], + }), + ], + options: DatadogAPIClient::V2::SecurityMonitoringRuleOptions.new({ + detection_method: DatadogAPIClient::V2::SecurityMonitoringRuleDetectionMethod::THIRD_PARTY, + evaluation_window: DatadogAPIClient::V2::SecurityMonitoringRuleEvaluationWindow::ZERO_MINUTES, + keep_alive: DatadogAPIClient::V2::SecurityMonitoringRuleKeepAlive::ONE_HOUR, + max_signal_duration: DatadogAPIClient::V2::SecurityMonitoringRuleMaxSignalDuration::ONE_DAY, + third_party_rule_options: DatadogAPIClient::V2::SecurityMonitoringRuleThirdPartyOptions.new({ + root_query: "@pop", + default_status: DatadogAPIClient::V2::SecurityMonitoringRuleSeverity::LOW, + }), + }), + message: "Example-Create_a_detection_rule_with_detection_method_third_party_returns_OK_response message", + tags: [], + is_enabled: true, +}) +p api_instance.create_security_monitoring_rule(body) diff --git a/features/v2/security_monitoring.feature b/features/v2/security_monitoring.feature index 4a91d1f4c5d8..a6c18134886c 100644 --- a/features/v2/security_monitoring.feature +++ b/features/v2/security_monitoring.feature @@ -21,6 +21,13 @@ Feature: Security Monitoring When the request is sent Then the response status is 200 OK + @team:DataDog/security-monitoring + Scenario: Create a detection rule with detection method "third_party" returns "OK" response + Given new "CreateSecurityMonitoringRule" request + And body with value {"name":"{{ unique }}", "queries":[{"query":"@test:true","aggregation":"none","groupByFields":[],"distinctFields":[]}],"filters":[],"cases":[{"name":"","status":"info","notifications":[]}],"options":{"detectionMethod":"third_party","evaluationWindow": 0, "keepAlive":3600,"maxSignalDuration":86400, "thirdPartyRuleOptions":{"rootQuery":"@pop","defaultStatus":"low"}},"message":"{{ unique}} message","tags":[],"isEnabled":true} + When the request is sent + Then the response status is 200 OK + @team:DataDog/security-monitoring Scenario: Create a detection rule with type 'workload_security' returns "OK" response Given new "CreateSecurityMonitoringRule" request @@ -207,7 +214,7 @@ Feature: Security Monitoring Scenario: Update an existing rule returns "Bad Request" response Given new "UpdateSecurityMonitoringRule" request And request contains "rule_id" parameter from "REPLACE.ME" - And body with value {"cases": [{"condition": null, "name": null, "notifications": [null], "status": "critical"}], "filters": [{"action": "require", "query": null}], "hasExtendedTitle": true, "isEnabled": null, "message": null, "name": null, "options": {"detectionMethod": "threshold", "evaluationWindow": 0, "keepAlive": 0, "maxSignalDuration": 0, "newValueOptions": {"forgetAfter": 1, "learningDuration": 0}}, "queries": [{"aggregation": "count", "distinctFields": [null], "groupByFields": [null], "metric": null, "name": null, "query": null}], "tags": [null], "version": 1} + And body with value {"cases": [{"condition": null, "name": null, "notifications": [null], "status": "critical"}], "filters": [{"action": "require", "query": null}], "hasExtendedTitle": true, "isEnabled": null, "message": null, "name": null, "options": {"detectionMethod": "threshold", "evaluationWindow": 0, "keepAlive": 0, "maxSignalDuration": 0, "newValueOptions": {"forgetAfter": 1, "learningDuration": 0}, "thirdPartyRuleOptions": {"defaultNotifications": [null], "defaultStatus": "critical", "firstSeenOverride": null, "lastSeenOverride": null, "rootQuery": null, "signalId": null}}, "queries": [{"aggregation": "count", "distinctFields": [null], "groupByFields": [null], "metric": null, "name": null, "query": null}], "tags": [null], "version": 1} When the request is sent Then the response status is 400 Bad Request @@ -215,7 +222,7 @@ Feature: Security Monitoring Scenario: Update an existing rule returns "Not Found" response Given new "UpdateSecurityMonitoringRule" request And request contains "rule_id" parameter from "REPLACE.ME" - And body with value {"cases": [{"condition": null, "name": null, "notifications": [null], "status": "critical"}], "filters": [{"action": "require", "query": null}], "hasExtendedTitle": true, "isEnabled": null, "message": null, "name": null, "options": {"detectionMethod": "threshold", "evaluationWindow": 0, "keepAlive": 0, "maxSignalDuration": 0, "newValueOptions": {"forgetAfter": 1, "learningDuration": 0}}, "queries": [{"aggregation": "count", "distinctFields": [null], "groupByFields": [null], "metric": null, "name": null, "query": null}], "tags": [null], "version": 1} + And body with value {"cases": [{"condition": null, "name": null, "notifications": [null], "status": "critical"}], "filters": [{"action": "require", "query": null}], "hasExtendedTitle": true, "isEnabled": null, "message": null, "name": null, "options": {"detectionMethod": "threshold", "evaluationWindow": 0, "keepAlive": 0, "maxSignalDuration": 0, "newValueOptions": {"forgetAfter": 1, "learningDuration": 0}, "thirdPartyRuleOptions": {"defaultNotifications": [null], "defaultStatus": "critical", "firstSeenOverride": null, "lastSeenOverride": null, "rootQuery": null, "signalId": null}}, "queries": [{"aggregation": "count", "distinctFields": [null], "groupByFields": [null], "metric": null, "name": null, "query": null}], "tags": [null], "version": 1} When the request is sent Then the response status is 404 Not Found @@ -223,6 +230,6 @@ Feature: Security Monitoring Scenario: Update an existing rule returns "OK" response Given new "UpdateSecurityMonitoringRule" request And request contains "rule_id" parameter from "REPLACE.ME" - And body with value {"cases": [{"condition": null, "name": null, "notifications": [null], "status": "critical"}], "filters": [{"action": "require", "query": null}], "hasExtendedTitle": true, "isEnabled": null, "message": null, "name": null, "options": {"detectionMethod": "threshold", "evaluationWindow": 0, "keepAlive": 0, "maxSignalDuration": 0, "newValueOptions": {"forgetAfter": 1, "learningDuration": 0}}, "queries": [{"aggregation": "count", "distinctFields": [null], "groupByFields": [null], "metric": null, "name": null, "query": null}], "tags": [null], "version": 1} + And body with value {"cases": [{"condition": null, "name": null, "notifications": [null], "status": "critical"}], "filters": [{"action": "require", "query": null}], "hasExtendedTitle": true, "isEnabled": null, "message": null, "name": null, "options": {"detectionMethod": "threshold", "evaluationWindow": 0, "keepAlive": 0, "maxSignalDuration": 0, "newValueOptions": {"forgetAfter": 1, "learningDuration": 0}, "thirdPartyRuleOptions": {"defaultNotifications": [null], "defaultStatus": "critical", "firstSeenOverride": null, "lastSeenOverride": null, "rootQuery": null, "signalId": null}}, "queries": [{"aggregation": "count", "distinctFields": [null], "groupByFields": [null], "metric": null, "name": null, "query": null}], "tags": [null], "version": 1} When the request is sent Then the response status is 200 OK diff --git a/lib/datadog_api_client/v2.rb b/lib/datadog_api_client/v2.rb index 4f24764f04d6..cbb461590f20 100644 --- a/lib/datadog_api_client/v2.rb +++ b/lib/datadog_api_client/v2.rb @@ -328,6 +328,7 @@ require 'datadog_api_client/v2/models/security_monitoring_rule_query_create' require 'datadog_api_client/v2/models/security_monitoring_rule_response' require 'datadog_api_client/v2/models/security_monitoring_rule_severity' +require 'datadog_api_client/v2/models/security_monitoring_rule_third_party_options' require 'datadog_api_client/v2/models/security_monitoring_rule_type_create' require 'datadog_api_client/v2/models/security_monitoring_rule_type_read' require 'datadog_api_client/v2/models/security_monitoring_rule_update_payload' diff --git a/lib/datadog_api_client/v2/models/security_monitoring_rule_detection_method.rb b/lib/datadog_api_client/v2/models/security_monitoring_rule_detection_method.rb index e8b642747838..7a5f2f352238 100644 --- a/lib/datadog_api_client/v2/models/security_monitoring_rule_detection_method.rb +++ b/lib/datadog_api_client/v2/models/security_monitoring_rule_detection_method.rb @@ -21,6 +21,7 @@ class SecurityMonitoringRuleDetectionMethod THRESHOLD = "threshold".freeze NEW_VALUE = "new_value".freeze ANOMALY_DETECTION = "anomaly_detection".freeze + THIRD_PARTY = "third_party".freeze # Builds the enum from string # @param [String] The enum value in the form of the string diff --git a/lib/datadog_api_client/v2/models/security_monitoring_rule_options.rb b/lib/datadog_api_client/v2/models/security_monitoring_rule_options.rb index 37146adbd868..f65e18236552 100644 --- a/lib/datadog_api_client/v2/models/security_monitoring_rule_options.rb +++ b/lib/datadog_api_client/v2/models/security_monitoring_rule_options.rb @@ -32,6 +32,8 @@ class SecurityMonitoringRuleOptions attr_accessor :new_value_options + attr_accessor :third_party_rule_options + # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { @@ -39,7 +41,8 @@ def self.attribute_map :'evaluation_window' => :'evaluationWindow', :'keep_alive' => :'keepAlive', :'max_signal_duration' => :'maxSignalDuration', - :'new_value_options' => :'newValueOptions' + :'new_value_options' => :'newValueOptions', + :'third_party_rule_options' => :'thirdPartyRuleOptions' } end @@ -55,7 +58,8 @@ def self.openapi_types :'evaluation_window' => :'SecurityMonitoringRuleEvaluationWindow', :'keep_alive' => :'SecurityMonitoringRuleKeepAlive', :'max_signal_duration' => :'SecurityMonitoringRuleMaxSignalDuration', - :'new_value_options' => :'SecurityMonitoringRuleNewValueOptions' + :'new_value_options' => :'SecurityMonitoringRuleNewValueOptions', + :'third_party_rule_options' => :'SecurityMonitoringRuleThirdPartyOptions' } end @@ -99,6 +103,10 @@ def initialize(attributes = {}) if attributes.key?(:'new_value_options') self.new_value_options = attributes[:'new_value_options'] end + + if attributes.key?(:'third_party_rule_options') + self.third_party_rule_options = attributes[:'third_party_rule_options'] + end end # Show invalid properties with the reasons. Usually used together with valid? @@ -123,7 +131,8 @@ def ==(o) evaluation_window == o.evaluation_window && keep_alive == o.keep_alive && max_signal_duration == o.max_signal_duration && - new_value_options == o.new_value_options + new_value_options == o.new_value_options && + third_party_rule_options == o.third_party_rule_options end # @see the `==` method @@ -135,7 +144,7 @@ def eql?(o) # Calculates hash code according to all attributes. # @return [Integer] Hash code def hash - [detection_method, evaluation_window, keep_alive, max_signal_duration, new_value_options].hash + [detection_method, evaluation_window, keep_alive, max_signal_duration, new_value_options, third_party_rule_options].hash end # Builds the object from hash diff --git a/lib/datadog_api_client/v2/models/security_monitoring_rule_query_aggregation.rb b/lib/datadog_api_client/v2/models/security_monitoring_rule_query_aggregation.rb index 483bdace1ebc..ac6f7e6979fd 100644 --- a/lib/datadog_api_client/v2/models/security_monitoring_rule_query_aggregation.rb +++ b/lib/datadog_api_client/v2/models/security_monitoring_rule_query_aggregation.rb @@ -23,6 +23,7 @@ class SecurityMonitoringRuleQueryAggregation SUM = "sum".freeze MAX = "max".freeze NEW_VALUE = "new_value".freeze + NONE = "none".freeze # Builds the enum from string # @param [String] The enum value in the form of the string diff --git a/lib/datadog_api_client/v2/models/security_monitoring_rule_third_party_options.rb b/lib/datadog_api_client/v2/models/security_monitoring_rule_third_party_options.rb new file mode 100644 index 000000000000..2493d7977bff --- /dev/null +++ b/lib/datadog_api_client/v2/models/security_monitoring_rule_third_party_options.rb @@ -0,0 +1,284 @@ +=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://openapi-generator.tech + + 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 + # Options for third-party rules. + class SecurityMonitoringRuleThirdPartyOptions + # whether the object has unparsed attributes + attr_accessor :_unparsed + + # Notification targets for the root query. + attr_accessor :default_notifications + + attr_accessor :default_status + + # (Optional): the name of an attribute to override the first seen value of the third party signal. + attr_accessor :first_seen_override + + # (Optional): the name of an attribute to override the last seen value of the third party signal. + attr_accessor :last_seen_override + + # Root query of the rule. + attr_accessor :root_query + + # Optional mapping of the third-party signal ID. + attr_accessor :signal_id + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'default_notifications' => :'defaultNotifications', + :'default_status' => :'defaultStatus', + :'first_seen_override' => :'firstSeenOverride', + :'last_seen_override' => :'lastSeenOverride', + :'root_query' => :'rootQuery', + :'signal_id' => :'signalId' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'default_notifications' => :'Array', + :'default_status' => :'SecurityMonitoringRuleSeverity', + :'first_seen_override' => :'String', + :'last_seen_override' => :'String', + :'root_query' => :'String', + :'signal_id' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::SecurityMonitoringRuleThirdPartyOptions` initialize method" + end + + # 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)) + fail ArgumentError, "`#{k}` is not a valid attribute in `DatadogAPIClient::V2::SecurityMonitoringRuleThirdPartyOptions`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'default_notifications') + if (value = attributes[:'default_notifications']).is_a?(Array) + self.default_notifications = value + end + end + + if attributes.key?(:'default_status') + self.default_status = attributes[:'default_status'] + end + + if attributes.key?(:'first_seen_override') + self.first_seen_override = attributes[:'first_seen_override'] + end + + if attributes.key?(:'last_seen_override') + self.last_seen_override = attributes[:'last_seen_override'] + end + + if attributes.key?(:'root_query') + self.root_query = attributes[:'root_query'] + end + + if attributes.key?(:'signal_id') + self.signal_id = attributes[:'signal_id'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + default_notifications == o.default_notifications && + default_status == o.default_status && + first_seen_override == o.first_seen_override && + last_seen_override == o.last_seen_override && + root_query == o.root_query && + signal_id == o.signal_id + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [default_notifications, default_status, first_seen_override, last_seen_override, root_query, signal_id].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + new.build_from_hash(attributes) + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + self.class.openapi_types.each_pair do |key, type| + if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key) + self.send("#{key}=", nil) + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[self.class.attribute_map[key]].is_a?(Array) + self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) }) + end + elsif !attributes[self.class.attribute_map[key]].nil? + self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) + end + end + + self + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def _deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when :Array + # generic array, return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = DatadogAPIClient::V2.const_get(type) + res = klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + if res.instance_of? DatadogAPIClient::V2::UnparsedObject + self._unparsed = true + end + res + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + 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 + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/spec/v2/models/security_monitoring_rule_options_spec.rb b/spec/v2/models/security_monitoring_rule_options_spec.rb index 9114828a4162..90f49c71a542 100644 --- a/spec/v2/models/security_monitoring_rule_options_spec.rb +++ b/spec/v2/models/security_monitoring_rule_options_spec.rb @@ -58,4 +58,10 @@ end end + describe 'test attribute "third_party_rule_options"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + end diff --git a/spec/v2/models/security_monitoring_rule_third_party_options_spec.rb b/spec/v2/models/security_monitoring_rule_third_party_options_spec.rb new file mode 100644 index 000000000000..bde423cb7541 --- /dev/null +++ b/spec/v2/models/security_monitoring_rule_third_party_options_spec.rb @@ -0,0 +1,67 @@ +=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://openapi-generator.tech + + 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 'spec_helper' +require 'json' +require 'date' + +# Unit tests for DatadogAPIClient::V2::SecurityMonitoringRuleThirdPartyOptions +# Automatically generated by openapi-generator (https://openapi-generator.tech) +# Please update as you see appropriate +describe DatadogAPIClient::V2::SecurityMonitoringRuleThirdPartyOptions do + let(:instance) { DatadogAPIClient::V2::SecurityMonitoringRuleThirdPartyOptions.new } + + describe 'test an instance of SecurityMonitoringRuleThirdPartyOptions' do + it 'should create an instance of SecurityMonitoringRuleThirdPartyOptions' do + expect(instance).to be_instance_of(DatadogAPIClient::V2::SecurityMonitoringRuleThirdPartyOptions) + end + end + describe 'test attribute "default_notifications"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + describe 'test attribute "default_status"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + describe 'test attribute "first_seen_override"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + describe 'test attribute "last_seen_override"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + describe 'test attribute "root_query"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + describe 'test attribute "signal_id"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + +end