Sha256: 756e9265676423834a35378781c9aceba4961f99027b797ac2328a86fce1fed6

Contents?: true

Size: 1.91 KB

Versions: 15

Compression:

Stored size: 1.91 KB

Contents

# Update a cloud configuration rule's details returns "OK" response

require "datadog_api_client"
api_instance = DatadogAPIClient::V2::SecurityMonitoringAPI.new

# there is a valid "cloud_configuration_rule" in the system
CLOUD_CONFIGURATION_RULE_ID = ENV["CLOUD_CONFIGURATION_RULE_ID"]

body = DatadogAPIClient::V2::SecurityMonitoringRuleUpdatePayload.new({
  name: "Example-Security-Monitoring_cloud_updated",
  is_enabled: false,
  cases: [
    DatadogAPIClient::V2::SecurityMonitoringRuleCase.new({
      status: DatadogAPIClient::V2::SecurityMonitoringRuleSeverity::INFO,
      notifications: [],
    }),
  ],
  options: DatadogAPIClient::V2::SecurityMonitoringRuleOptions.new({
    compliance_rule_options: DatadogAPIClient::V2::CloudConfigurationComplianceRuleOptions.new({
      resource_type: "gcp_compute_disk",
      rego_rule: DatadogAPIClient::V2::CloudConfigurationRegoRule.new({
        policy: 'package datadog\n\nimport data.datadog.output as dd_output\n\nimport future.keywords.contains\nimport future.keywords.if\nimport future.keywords.in\n\nmilliseconds_in_a_day := ((1000 * 60) * 60) * 24\n\neval(iam_service_account_key) = "skip" if {\n\tiam_service_account_key.disabled\n} else = "pass" if {\n\t(iam_service_account_key.resource_seen_at / milliseconds_in_a_day) - (iam_service_account_key.valid_after_time / milliseconds_in_a_day) <= 90\n} else = "fail"\n\n# This part remains unchanged for all rules\nresults contains result if {\n\tsome resource in input.resources[input.main_resource_type]\n\tresult := dd_output.format(resource, eval(resource))\n}\n',
        resource_types: [
          "gcp_compute_disk",
        ],
      }),
    }),
  }),
  message: "ddd",
  tags: [],
  compliance_signal_options: DatadogAPIClient::V2::CloudConfigurationRuleComplianceSignalOptions.new({
    user_activation_status: false,
    user_group_by_fields: [],
  }),
})
p api_instance.update_security_monitoring_rule(CLOUD_CONFIGURATION_RULE_ID, body)

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
datadog_api_client-2.29.1 examples/v2/security-monitoring/UpdateSecurityMonitoringRule_428087276.rb
datadog_api_client-2.28.1 examples/v2/security-monitoring/UpdateSecurityMonitoringRule_428087276.rb
datadog_api_client-2.27.1 examples/v2/security-monitoring/UpdateSecurityMonitoringRule_428087276.rb
datadog_api_client-2.26.1 examples/v2/security-monitoring/UpdateSecurityMonitoringRule_428087276.rb
datadog_api_client-2.26.0 examples/v2/security-monitoring/UpdateSecurityMonitoringRule_428087276.rb
datadog_api_client-2.25.0 examples/v2/security-monitoring/UpdateSecurityMonitoringRule_428087276.rb
datadog_api_client-2.24.0 examples/v2/security-monitoring/UpdateSecurityMonitoringRule_428087276.rb
datadog_api_client-2.22.0 examples/v2/security-monitoring/UpdateSecurityMonitoringRule_428087276.rb
datadog_api_client-2.21.0 examples/v2/security-monitoring/UpdateSecurityMonitoringRule_428087276.rb
datadog_api_client-2.20.0 examples/v2/security-monitoring/UpdateSecurityMonitoringRule_428087276.rb
datadog_api_client-2.19.0 examples/v2/security-monitoring/UpdateSecurityMonitoringRule_428087276.rb
datadog_api_client-2.18.0 examples/v2/security-monitoring/UpdateSecurityMonitoringRule_428087276.rb
datadog_api_client-2.17.0 examples/v2/security-monitoring/UpdateSecurityMonitoringRule_428087276.rb
datadog_api_client-2.16.0 examples/v2/security-monitoring/UpdateSecurityMonitoringRule_428087276.rb
datadog_api_client-2.15.0 examples/v2/security-monitoring/UpdateSecurityMonitoringRule_428087276.rb