diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index b37669c620a3..e8790871ff0c 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -67723,6 +67723,10 @@ components: The `parse_grok` processor extracts structured fields from unstructured log messages using Grok patterns. **Supported pipeline types:** logs + example: + id: "parse-grok-processor" + include: "service:my-service" + type: "parse_grok" properties: disable_library_rules: default: false @@ -67735,6 +67739,11 @@ components: description: Indicates whether the processor is enabled. example: true type: boolean + field: + default: "message" + description: The log field to parse with the Grok rules. + example: "message" + type: string id: description: A unique identifier for this processor. example: "parse-grok-processor" @@ -67744,9 +67753,9 @@ components: example: "service:my-service" type: string rules: - description: The list of Grok parsing rules. If multiple matching rules are provided, they are evaluated in order. The first successful match is applied. + description: The list of Grok parsing rules selected by either source field or include query. items: - $ref: "#/components/schemas/ObservabilityPipelineParseGrokProcessorRule" + $ref: "#/components/schemas/ObservabilityPipelineParseGrokProcessorRuleItem" type: array type: $ref: "#/components/schemas/ObservabilityPipelineParseGrokProcessorType" @@ -67758,6 +67767,37 @@ components: - enabled type: object x-pipeline-types: [logs] + ObservabilityPipelineParseGrokProcessorIncludeRule: + description: |- + A Grok parsing rule selected using the `include` query. Each rule defines how to extract structured fields + from logs matching a Datadog search query. + properties: + include: + description: A Datadog search query used to determine which logs this Grok rule targets. + example: "service:my-service" + type: string + match_rules: + description: |- + A list of Grok parsing rules that define how to extract fields from matching logs. + Each rule must contain a name and a valid Grok pattern. + example: + - name: "MyParsingRule" + rule: '%{word:user} connected on %{date("MM/dd/yyyy"):date}' + items: + $ref: "#/components/schemas/ObservabilityPipelineParseGrokProcessorRuleMatchRule" + type: array + support_rules: + description: A list of Grok helper rules that can be referenced by the parsing rules. + example: + - name: "user" + rule: "%{word:user.name}" + items: + $ref: "#/components/schemas/ObservabilityPipelineParseGrokProcessorRuleSupportRule" + type: array + required: + - include + - match_rules + type: object ObservabilityPipelineParseGrokProcessorRule: description: |- A Grok parsing rule used in the `parse_grok` processor. Each rule defines how to extract structured fields @@ -67790,6 +67830,11 @@ components: - source - match_rules type: object + ObservabilityPipelineParseGrokProcessorRuleItem: + description: A single Grok parsing rule, selected by either source field or include query. + oneOf: + - $ref: "#/components/schemas/ObservabilityPipelineParseGrokProcessorRule" + - $ref: "#/components/schemas/ObservabilityPipelineParseGrokProcessorIncludeRule" ObservabilityPipelineParseGrokProcessorRuleMatchRule: description: |- Defines a Grok parsing rule, which extracts structured fields from log content using named Grok patterns. diff --git a/cassettes/features/v2/observability_pipelines/Validate-an-observability-pipeline-with-parse-grok-processor-include-rules-returns-OK-response.frozen b/cassettes/features/v2/observability_pipelines/Validate-an-observability-pipeline-with-parse-grok-processor-include-rules-returns-OK-response.frozen new file mode 100644 index 000000000000..985fe4f60aeb --- /dev/null +++ b/cassettes/features/v2/observability_pipelines/Validate-an-observability-pipeline-with-parse-grok-processor-include-rules-returns-OK-response.frozen @@ -0,0 +1 @@ +2026-06-29T20:01:05.978Z \ No newline at end of file diff --git a/cassettes/features/v2/observability_pipelines/Validate-an-observability-pipeline-with-parse-grok-processor-include-rules-returns-OK-response.yml b/cassettes/features/v2/observability_pipelines/Validate-an-observability-pipeline-with-parse-grok-processor-include-rules-returns-OK-response.yml new file mode 100644 index 000000000000..66e846593dd9 --- /dev/null +++ b/cassettes/features/v2/observability_pipelines/Validate-an-observability-pipeline-with-parse-grok-processor-include-rules-returns-OK-response.yml @@ -0,0 +1,27 @@ +http_interactions: +- recorded_at: Mon, 29 Jun 2026 20:01:05 GMT + request: + body: + encoding: UTF-8 + string: '{"data":{"attributes":{"config":{"destinations":[{"id":"datadog-logs-destination","inputs":["my-processor-group"],"type":"datadog_logs"}],"processor_groups":[{"enabled":true,"id":"my-processor-group","include":"service:my-service","inputs":["datadog-agent-source"],"processors":[{"enabled":true,"field":"content","id":"parse-grok-processor","include":"*","rules":[{"include":"service:foo","match_rules":[{"name":"MyParsingRule","rule":"%{word:user}"}]}],"type":"parse_grok"}]}],"sources":[{"id":"datadog-agent-source","type":"datadog_agent"}]},"name":"Pipeline + with Parse Grok Include Rules"},"type":"pipelines"}}' + headers: + Accept: + - application/json + Content-Type: + - application/json + method: POST + uri: https://api.datadoghq.com/api/v2/obs-pipelines/pipelines/validate + response: + body: + encoding: UTF-8 + string: '{"errors":[]} + + ' + headers: + Content-Type: + - application/vnd.api+json + status: + code: 200 + message: OK +recorded_with: VCR 6.0.0 diff --git a/cassettes/features/v2/observability_pipelines/Validate-an-observability-pipeline-with-parse-grok-processor-source-rules-returns-OK-response.frozen b/cassettes/features/v2/observability_pipelines/Validate-an-observability-pipeline-with-parse-grok-processor-source-rules-returns-OK-response.frozen new file mode 100644 index 000000000000..4db9a90b937e --- /dev/null +++ b/cassettes/features/v2/observability_pipelines/Validate-an-observability-pipeline-with-parse-grok-processor-source-rules-returns-OK-response.frozen @@ -0,0 +1 @@ +2026-06-29T18:24:15.839Z \ No newline at end of file diff --git a/cassettes/features/v2/observability_pipelines/Validate-an-observability-pipeline-with-parse-grok-processor-source-rules-returns-OK-response.yml b/cassettes/features/v2/observability_pipelines/Validate-an-observability-pipeline-with-parse-grok-processor-source-rules-returns-OK-response.yml new file mode 100644 index 000000000000..ac9e6191b357 --- /dev/null +++ b/cassettes/features/v2/observability_pipelines/Validate-an-observability-pipeline-with-parse-grok-processor-source-rules-returns-OK-response.yml @@ -0,0 +1,27 @@ +http_interactions: +- recorded_at: Mon, 29 Jun 2026 18:24:15 GMT + request: + body: + encoding: UTF-8 + string: '{"data":{"attributes":{"config":{"destinations":[{"id":"datadog-logs-destination","inputs":["my-processor-group"],"type":"datadog_logs"}],"processor_groups":[{"enabled":true,"id":"my-processor-group","include":"service:my-service","inputs":["datadog-agent-source"],"processors":[{"enabled":true,"id":"parse-grok-processor","include":"*","rules":[{"match_rules":[{"name":"MyParsingRule","rule":"%{word:user}"}],"source":"message"}],"type":"parse_grok"}]}],"sources":[{"id":"datadog-agent-source","type":"datadog_agent"}]},"name":"Pipeline + with Parse Grok Source Rules"},"type":"pipelines"}}' + headers: + Accept: + - application/json + Content-Type: + - application/json + method: POST + uri: https://api.datadoghq.com/api/v2/obs-pipelines/pipelines/validate + response: + body: + encoding: UTF-8 + string: '{"errors":[]} + + ' + headers: + Content-Type: + - application/vnd.api+json + status: + code: 200 + message: OK +recorded_with: VCR 6.0.0 diff --git a/examples/v2/observability-pipelines/ValidatePipeline_3345949653.rb b/examples/v2/observability-pipelines/ValidatePipeline_3345949653.rb new file mode 100644 index 000000000000..57e5d4158841 --- /dev/null +++ b/examples/v2/observability-pipelines/ValidatePipeline_3345949653.rb @@ -0,0 +1,60 @@ +# Validate an observability pipeline with parse grok processor source rules returns "OK" response + +require "datadog_api_client" +api_instance = DatadogAPIClient::V2::ObservabilityPipelinesAPI.new + +body = DatadogAPIClient::V2::ObservabilityPipelineSpec.new({ + data: DatadogAPIClient::V2::ObservabilityPipelineSpecData.new({ + attributes: DatadogAPIClient::V2::ObservabilityPipelineDataAttributes.new({ + config: DatadogAPIClient::V2::ObservabilityPipelineConfig.new({ + destinations: [ + DatadogAPIClient::V2::ObservabilityPipelineDatadogLogsDestination.new({ + id: "datadog-logs-destination", + inputs: [ + "my-processor-group", + ], + type: DatadogAPIClient::V2::ObservabilityPipelineDatadogLogsDestinationType::DATADOG_LOGS, + }), + ], + processor_groups: [ + DatadogAPIClient::V2::ObservabilityPipelineConfigProcessorGroup.new({ + enabled: true, + id: "my-processor-group", + include: "service:my-service", + inputs: [ + "datadog-agent-source", + ], + processors: [ + DatadogAPIClient::V2::ObservabilityPipelineParseGrokProcessor.new({ + enabled: true, + id: "parse-grok-processor", + include: "*", + type: DatadogAPIClient::V2::ObservabilityPipelineParseGrokProcessorType::PARSE_GROK, + rules: [ + DatadogAPIClient::V2::ObservabilityPipelineParseGrokProcessorRule.new({ + source: "message", + match_rules: [ + DatadogAPIClient::V2::ObservabilityPipelineParseGrokProcessorRuleMatchRule.new({ + name: "MyParsingRule", + rule: "%{word:user}", + }), + ], + }), + ], + }), + ], + }), + ], + sources: [ + DatadogAPIClient::V2::ObservabilityPipelineDatadogAgentSource.new({ + id: "datadog-agent-source", + type: DatadogAPIClient::V2::ObservabilityPipelineDatadogAgentSourceType::DATADOG_AGENT, + }), + ], + }), + name: "Pipeline with Parse Grok Source Rules", + }), + type: "pipelines", + }), +}) +p api_instance.validate_pipeline(body) diff --git a/examples/v2/observability-pipelines/ValidatePipeline_3928499240.rb b/examples/v2/observability-pipelines/ValidatePipeline_3928499240.rb new file mode 100644 index 000000000000..88e409a34f09 --- /dev/null +++ b/examples/v2/observability-pipelines/ValidatePipeline_3928499240.rb @@ -0,0 +1,61 @@ +# Validate an observability pipeline with parse grok processor include rules returns "OK" response + +require "datadog_api_client" +api_instance = DatadogAPIClient::V2::ObservabilityPipelinesAPI.new + +body = DatadogAPIClient::V2::ObservabilityPipelineSpec.new({ + data: DatadogAPIClient::V2::ObservabilityPipelineSpecData.new({ + attributes: DatadogAPIClient::V2::ObservabilityPipelineDataAttributes.new({ + config: DatadogAPIClient::V2::ObservabilityPipelineConfig.new({ + destinations: [ + DatadogAPIClient::V2::ObservabilityPipelineDatadogLogsDestination.new({ + id: "datadog-logs-destination", + inputs: [ + "my-processor-group", + ], + type: DatadogAPIClient::V2::ObservabilityPipelineDatadogLogsDestinationType::DATADOG_LOGS, + }), + ], + processor_groups: [ + DatadogAPIClient::V2::ObservabilityPipelineConfigProcessorGroup.new({ + enabled: true, + id: "my-processor-group", + include: "service:my-service", + inputs: [ + "datadog-agent-source", + ], + processors: [ + DatadogAPIClient::V2::ObservabilityPipelineParseGrokProcessor.new({ + enabled: true, + id: "parse-grok-processor", + include: "*", + type: DatadogAPIClient::V2::ObservabilityPipelineParseGrokProcessorType::PARSE_GROK, + field: "content", + rules: [ + DatadogAPIClient::V2::ObservabilityPipelineParseGrokProcessorIncludeRule.new({ + include: "service:foo", + match_rules: [ + DatadogAPIClient::V2::ObservabilityPipelineParseGrokProcessorRuleMatchRule.new({ + name: "MyParsingRule", + rule: "%{word:user}", + }), + ], + }), + ], + }), + ], + }), + ], + sources: [ + DatadogAPIClient::V2::ObservabilityPipelineDatadogAgentSource.new({ + id: "datadog-agent-source", + type: DatadogAPIClient::V2::ObservabilityPipelineDatadogAgentSourceType::DATADOG_AGENT, + }), + ], + }), + name: "Pipeline with Parse Grok Include Rules", + }), + type: "pipelines", + }), +}) +p api_instance.validate_pipeline(body) diff --git a/features/v2/observability_pipelines.feature b/features/v2/observability_pipelines.feature index e42bbd7b0335..8aa6ef361596 100644 --- a/features/v2/observability_pipelines.feature +++ b/features/v2/observability_pipelines.feature @@ -295,6 +295,22 @@ Feature: Observability Pipelines Then the response status is 200 OK And the response "errors" has length 0 + @team:DataDog/observability-pipelines + Scenario: Validate an observability pipeline with parse grok processor include rules returns "OK" response + Given new "ValidatePipeline" request + And body with value {"data": {"attributes": {"config": {"destinations": [{"id": "datadog-logs-destination", "inputs": ["my-processor-group"], "type": "datadog_logs"}], "processor_groups": [{"enabled": true, "id": "my-processor-group", "include": "service:my-service", "inputs": ["datadog-agent-source"], "processors": [{"enabled": true, "id": "parse-grok-processor", "include": "*", "type": "parse_grok", "field": "content", "rules": [{"include": "service:foo", "match_rules": [{"name": "MyParsingRule", "rule": "%{word:user}"}]}]}]}], "sources": [{"id": "datadog-agent-source", "type": "datadog_agent"}]}, "name": "Pipeline with Parse Grok Include Rules"}, "type": "pipelines"}} + When the request is sent + Then the response status is 200 OK + And the response "errors" has length 0 + + @team:DataDog/observability-pipelines + Scenario: Validate an observability pipeline with parse grok processor source rules returns "OK" response + Given new "ValidatePipeline" request + And body with value {"data": {"attributes": {"config": {"destinations": [{"id": "datadog-logs-destination", "inputs": ["my-processor-group"], "type": "datadog_logs"}], "processor_groups": [{"enabled": true, "id": "my-processor-group", "include": "service:my-service", "inputs": ["datadog-agent-source"], "processors": [{"enabled": true, "id": "parse-grok-processor", "include": "*", "type": "parse_grok", "rules": [{"source": "message", "match_rules": [{"name": "MyParsingRule", "rule": "%{word:user}"}]}]}]}], "sources": [{"id": "datadog-agent-source", "type": "datadog_agent"}]}, "name": "Pipeline with Parse Grok Source Rules"}, "type": "pipelines"}} + When the request is sent + Then the response status is 200 OK + And the response "errors" has length 0 + @team:DataDog/observability-pipelines Scenario: Validate an observability pipeline with source secret key returns "OK" response Given new "ValidatePipeline" request diff --git a/lib/datadog_api_client/inflector.rb b/lib/datadog_api_client/inflector.rb index fb2afd8ccf6a..60146fbaa7eb 100644 --- a/lib/datadog_api_client/inflector.rb +++ b/lib/datadog_api_client/inflector.rb @@ -5117,7 +5117,9 @@ def overrides "v2.observability_pipeline_opentelemetry_source" => "ObservabilityPipelineOpentelemetrySource", "v2.observability_pipeline_opentelemetry_source_type" => "ObservabilityPipelineOpentelemetrySourceType", "v2.observability_pipeline_parse_grok_processor" => "ObservabilityPipelineParseGrokProcessor", + "v2.observability_pipeline_parse_grok_processor_include_rule" => "ObservabilityPipelineParseGrokProcessorIncludeRule", "v2.observability_pipeline_parse_grok_processor_rule" => "ObservabilityPipelineParseGrokProcessorRule", + "v2.observability_pipeline_parse_grok_processor_rule_item" => "ObservabilityPipelineParseGrokProcessorRuleItem", "v2.observability_pipeline_parse_grok_processor_rule_match_rule" => "ObservabilityPipelineParseGrokProcessorRuleMatchRule", "v2.observability_pipeline_parse_grok_processor_rule_support_rule" => "ObservabilityPipelineParseGrokProcessorRuleSupportRule", "v2.observability_pipeline_parse_grok_processor_type" => "ObservabilityPipelineParseGrokProcessorType", diff --git a/lib/datadog_api_client/v2/models/observability_pipeline_parse_grok_processor.rb b/lib/datadog_api_client/v2/models/observability_pipeline_parse_grok_processor.rb index e7f3e1ab34e1..802f43a6f112 100644 --- a/lib/datadog_api_client/v2/models/observability_pipeline_parse_grok_processor.rb +++ b/lib/datadog_api_client/v2/models/observability_pipeline_parse_grok_processor.rb @@ -32,13 +32,16 @@ class ObservabilityPipelineParseGrokProcessor # Indicates whether the processor is enabled. attr_reader :enabled + # The log field to parse with the Grok rules. + attr_accessor :field + # A unique identifier for this processor. attr_reader :id # A Datadog search query used to determine which logs this processor targets. attr_reader :include - # The list of Grok parsing rules. If multiple matching rules are provided, they are evaluated in order. The first successful match is applied. + # The list of Grok parsing rules selected by either source field or include query. attr_reader :rules # The processor type. The value should always be `parse_grok`. @@ -53,6 +56,7 @@ def self.attribute_map :'disable_library_rules' => :'disable_library_rules', :'display_name' => :'display_name', :'enabled' => :'enabled', + :'field' => :'field', :'id' => :'id', :'include' => :'include', :'rules' => :'rules', @@ -67,9 +71,10 @@ def self.openapi_types :'disable_library_rules' => :'Boolean', :'display_name' => :'String', :'enabled' => :'Boolean', + :'field' => :'String', :'id' => :'String', :'include' => :'String', - :'rules' => :'Array', + :'rules' => :'Array', :'type' => :'ObservabilityPipelineParseGrokProcessorType' } end @@ -104,6 +109,10 @@ def initialize(attributes = {}) self.enabled = attributes[:'enabled'] end + if attributes.key?(:'field') + self.field = attributes[:'field'] + end + if attributes.key?(:'id') self.id = attributes[:'id'] end @@ -214,6 +223,7 @@ def ==(o) disable_library_rules == o.disable_library_rules && display_name == o.display_name && enabled == o.enabled && + field == o.field && id == o.id && include == o.include && rules == o.rules && @@ -225,7 +235,7 @@ def ==(o) # @return [Integer] Hash code # @!visibility private def hash - [disable_library_rules, display_name, enabled, id, include, rules, type, additional_properties].hash + [disable_library_rules, display_name, enabled, field, id, include, rules, type, additional_properties].hash end end end diff --git a/lib/datadog_api_client/v2/models/observability_pipeline_parse_grok_processor_include_rule.rb b/lib/datadog_api_client/v2/models/observability_pipeline_parse_grok_processor_include_rule.rb new file mode 100644 index 000000000000..b173475cab06 --- /dev/null +++ b/lib/datadog_api_client/v2/models/observability_pipeline_parse_grok_processor_include_rule.rb @@ -0,0 +1,160 @@ +=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 Grok parsing rule selected using the `include` query. Each rule defines how to extract structured fields + # from logs matching a Datadog search query. + class ObservabilityPipelineParseGrokProcessorIncludeRule + include BaseGenericModel + + # A Datadog search query used to determine which logs this Grok rule targets. + attr_reader :include + + # A list of Grok parsing rules that define how to extract fields from matching logs. + # Each rule must contain a name and a valid Grok pattern. + attr_reader :match_rules + + # A list of Grok helper rules that can be referenced by the parsing rules. + attr_accessor :support_rules + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'include' => :'include', + :'match_rules' => :'match_rules', + :'support_rules' => :'support_rules' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'include' => :'String', + :'match_rules' => :'Array', + :'support_rules' => :'Array' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::ObservabilityPipelineParseGrokProcessorIncludeRule` 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?(:'include') + self.include = attributes[:'include'] + end + + if attributes.key?(:'match_rules') + if (value = attributes[:'match_rules']).is_a?(Array) + self.match_rules = value + end + end + + if attributes.key?(:'support_rules') + if (value = attributes[:'support_rules']).is_a?(Array) + self.support_rules = value + end + end + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + # @!visibility private + def valid? + return false if @include.nil? + return false if @match_rules.nil? + true + end + + # Custom attribute writer method with validation + # @param include [Object] Object to be assigned + # @!visibility private + def include=(include) + if include.nil? + fail ArgumentError, 'invalid value for "include", include cannot be nil.' + end + @include = include + end + + # Custom attribute writer method with validation + # @param match_rules [Object] Object to be assigned + # @!visibility private + def match_rules=(match_rules) + if match_rules.nil? + fail ArgumentError, 'invalid value for "match_rules", match_rules cannot be nil.' + end + @match_rules = match_rules + 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 && + include == o.include && + match_rules == o.match_rules && + support_rules == o.support_rules && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [include, match_rules, support_rules, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/observability_pipeline_parse_grok_processor_rule_item.rb b/lib/datadog_api_client/v2/models/observability_pipeline_parse_grok_processor_rule_item.rb new file mode 100644 index 000000000000..65e254c5854f --- /dev/null +++ b/lib/datadog_api_client/v2/models/observability_pipeline_parse_grok_processor_rule_item.rb @@ -0,0 +1,63 @@ +=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 Grok parsing rule, selected by either source field or include query. + module ObservabilityPipelineParseGrokProcessorRuleItem + class << self + include BaseOneOfModel + include BaseOneOfModelNoDiscriminator + + # List of class defined in oneOf (OpenAPI v3) + def openapi_one_of + [ + :'ObservabilityPipelineParseGrokProcessorRule', + :'ObservabilityPipelineParseGrokProcessorIncludeRule' + ] + 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) + # Go through the list of oneOf items and attempt to identify the appropriate one. + # Note: + # - We do not attempt to check whether exactly one item matches. + # - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 }) + # due to the way the deserialization is made in the base_object template (it just casts without verifying). + # - TODO: scalar values are de facto behaving as if they were nullable. + # - TODO: logging when debugging is set. + openapi_one_of.each do |klass| + begin + next if klass == :AnyType # "nullable: true" + typed_data = find_and_cast_into_type(klass, data) + next if typed_data.respond_to?(:_unparsed) && typed_data._unparsed + return typed_data if typed_data + rescue # rescue all errors so we keep iterating even if the current item lookup raises + end + end + + if openapi_one_of.include?(:AnyType) + data + else + self._unparsed = true + DatadogAPIClient::UnparsedObject.new(data) + end + end + end + end +end